ccdeck 3.38.5 → 3.38.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,309 +0,0 @@
1
- var B4=Object.defineProperty;var q4=(e,t,n)=>t in e?B4(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var kp=(e,t,n)=>q4(e,typeof t!="symbol"?t+"":t,n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const o of s)if(o.type==="childList")for(const l of o.addedNodes)l.tagName==="LINK"&&l.rel==="modulepreload"&&r(l)}).observe(document,{childList:!0,subtree:!0});function n(s){const o={};return s.integrity&&(o.integrity=s.integrity),s.referrerPolicy&&(o.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?o.credentials="include":s.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(s){if(s.ep)return;s.ep=!0;const o=n(s);fetch(s.href,o)}})();var Au=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Vb(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Np={exports:{}},wl={},jp={exports:{}},De={};/**
2
- * @license React
3
- * react.production.min.js
4
- *
5
- * Copyright (c) Facebook, Inc. and its affiliates.
6
- *
7
- * This source code is licensed under the MIT license found in the
8
- * LICENSE file in the root directory of this source tree.
9
- */var IN;function U4(){if(IN)return De;IN=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),l=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),p=Symbol.iterator;function g(D){return D===null||typeof D!="object"?null:(D=p&&D[p]||D["@@iterator"],typeof D=="function"?D:null)}var v={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},j=Object.assign,k={};function x(D,V,J){this.props=D,this.context=V,this.refs=k,this.updater=J||v}x.prototype.isReactComponent={},x.prototype.setState=function(D,V){if(typeof D!="object"&&typeof D!="function"&&D!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,D,V,"setState")},x.prototype.forceUpdate=function(D){this.updater.enqueueForceUpdate(this,D,"forceUpdate")};function N(){}N.prototype=x.prototype;function b(D,V,J){this.props=D,this.context=V,this.refs=k,this.updater=J||v}var S=b.prototype=new N;S.constructor=b,j(S,x.prototype),S.isPureReactComponent=!0;var E=Array.isArray,R=Object.prototype.hasOwnProperty,I={current:null},A={key:!0,ref:!0,__self:!0,__source:!0};function q(D,V,J){var W,Z={},Y=null,X=null;if(V!=null)for(W in V.ref!==void 0&&(X=V.ref),V.key!==void 0&&(Y=""+V.key),V)R.call(V,W)&&!A.hasOwnProperty(W)&&(Z[W]=V[W]);var ee=arguments.length-2;if(ee===1)Z.children=J;else if(1<ee){for(var ae=Array(ee),ce=0;ce<ee;ce++)ae[ce]=arguments[ce+2];Z.children=ae}if(D&&D.defaultProps)for(W in ee=D.defaultProps,ee)Z[W]===void 0&&(Z[W]=ee[W]);return{$$typeof:e,type:D,key:Y,ref:X,props:Z,_owner:I.current}}function $(D,V){return{$$typeof:e,type:D.type,key:V,ref:D.ref,props:D.props,_owner:D._owner}}function B(D){return typeof D=="object"&&D!==null&&D.$$typeof===e}function L(D){var V={"=":"=0",":":"=2"};return"$"+D.replace(/[=:]/g,function(J){return V[J]})}var M=/\/+/g;function F(D,V){return typeof D=="object"&&D!==null&&D.key!=null?L(""+D.key):V.toString(36)}function T(D,V,J,W,Z){var Y=typeof D;(Y==="undefined"||Y==="boolean")&&(D=null);var X=!1;if(D===null)X=!0;else switch(Y){case"string":case"number":X=!0;break;case"object":switch(D.$$typeof){case e:case t:X=!0}}if(X)return X=D,Z=Z(X),D=W===""?"."+F(X,0):W,E(Z)?(J="",D!=null&&(J=D.replace(M,"$&/")+"/"),T(Z,V,J,"",function(ce){return ce})):Z!=null&&(B(Z)&&(Z=$(Z,J+(!Z.key||X&&X.key===Z.key?"":(""+Z.key).replace(M,"$&/")+"/")+D)),V.push(Z)),1;if(X=0,W=W===""?".":W+":",E(D))for(var ee=0;ee<D.length;ee++){Y=D[ee];var ae=W+F(Y,ee);X+=T(Y,V,J,ae,Z)}else if(ae=g(D),typeof ae=="function")for(D=ae.call(D),ee=0;!(Y=D.next()).done;)Y=Y.value,ae=W+F(Y,ee++),X+=T(Y,V,J,ae,Z);else if(Y==="object")throw V=String(D),Error("Objects are not valid as a React child (found: "+(V==="[object Object]"?"object with keys {"+Object.keys(D).join(", ")+"}":V)+"). If you meant to render a collection of children, use an array instead.");return X}function P(D,V,J){if(D==null)return D;var W=[],Z=0;return T(D,W,"","",function(Y){return V.call(J,Y,Z++)}),W}function O(D){if(D._status===-1){var V=D._result;V=V(),V.then(function(J){(D._status===0||D._status===-1)&&(D._status=1,D._result=J)},function(J){(D._status===0||D._status===-1)&&(D._status=2,D._result=J)}),D._status===-1&&(D._status=0,D._result=V)}if(D._status===1)return D._result.default;throw D._result}var G={current:null},K={transition:null},U={ReactCurrentDispatcher:G,ReactCurrentBatchConfig:K,ReactCurrentOwner:I};function H(){throw Error("act(...) is not supported in production builds of React.")}return De.Children={map:P,forEach:function(D,V,J){P(D,function(){V.apply(this,arguments)},J)},count:function(D){var V=0;return P(D,function(){V++}),V},toArray:function(D){return P(D,function(V){return V})||[]},only:function(D){if(!B(D))throw Error("React.Children.only expected to receive a single React element child.");return D}},De.Component=x,De.Fragment=n,De.Profiler=s,De.PureComponent=b,De.StrictMode=r,De.Suspense=d,De.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=U,De.act=H,De.cloneElement=function(D,V,J){if(D==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+D+".");var W=j({},D.props),Z=D.key,Y=D.ref,X=D._owner;if(V!=null){if(V.ref!==void 0&&(Y=V.ref,X=I.current),V.key!==void 0&&(Z=""+V.key),D.type&&D.type.defaultProps)var ee=D.type.defaultProps;for(ae in V)R.call(V,ae)&&!A.hasOwnProperty(ae)&&(W[ae]=V[ae]===void 0&&ee!==void 0?ee[ae]:V[ae])}var ae=arguments.length-2;if(ae===1)W.children=J;else if(1<ae){ee=Array(ae);for(var ce=0;ce<ae;ce++)ee[ce]=arguments[ce+2];W.children=ee}return{$$typeof:e,type:D.type,key:Z,ref:Y,props:W,_owner:X}},De.createContext=function(D){return D={$$typeof:l,_currentValue:D,_currentValue2:D,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},D.Provider={$$typeof:o,_context:D},D.Consumer=D},De.createElement=q,De.createFactory=function(D){var V=q.bind(null,D);return V.type=D,V},De.createRef=function(){return{current:null}},De.forwardRef=function(D){return{$$typeof:c,render:D}},De.isValidElement=B,De.lazy=function(D){return{$$typeof:f,_payload:{_status:-1,_result:D},_init:O}},De.memo=function(D,V){return{$$typeof:h,type:D,compare:V===void 0?null:V}},De.startTransition=function(D){var V=K.transition;K.transition={};try{D()}finally{K.transition=V}},De.unstable_act=H,De.useCallback=function(D,V){return G.current.useCallback(D,V)},De.useContext=function(D){return G.current.useContext(D)},De.useDebugValue=function(){},De.useDeferredValue=function(D){return G.current.useDeferredValue(D)},De.useEffect=function(D,V){return G.current.useEffect(D,V)},De.useId=function(){return G.current.useId()},De.useImperativeHandle=function(D,V,J){return G.current.useImperativeHandle(D,V,J)},De.useInsertionEffect=function(D,V){return G.current.useInsertionEffect(D,V)},De.useLayoutEffect=function(D,V){return G.current.useLayoutEffect(D,V)},De.useMemo=function(D,V){return G.current.useMemo(D,V)},De.useReducer=function(D,V,J){return G.current.useReducer(D,V,J)},De.useRef=function(D){return G.current.useRef(D)},De.useState=function(D){return G.current.useState(D)},De.useSyncExternalStore=function(D,V,J){return G.current.useSyncExternalStore(D,V,J)},De.useTransition=function(){return G.current.useTransition()},De.version="18.3.1",De}var ON;function pc(){return ON||(ON=1,jp.exports=U4()),jp.exports}/**
10
- * @license React
11
- * react-jsx-runtime.production.min.js
12
- *
13
- * Copyright (c) Facebook, Inc. and its affiliates.
14
- *
15
- * This source code is licensed under the MIT license found in the
16
- * LICENSE file in the root directory of this source tree.
17
- */var LN;function z4(){if(LN)return wl;LN=1;var e=pc(),t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,s=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function l(c,d,h){var f,p={},g=null,v=null;h!==void 0&&(g=""+h),d.key!==void 0&&(g=""+d.key),d.ref!==void 0&&(v=d.ref);for(f in d)r.call(d,f)&&!o.hasOwnProperty(f)&&(p[f]=d[f]);if(c&&c.defaultProps)for(f in d=c.defaultProps,d)p[f]===void 0&&(p[f]=d[f]);return{$$typeof:t,type:c,key:g,ref:v,props:p,_owner:s.current}}return wl.Fragment=n,wl.jsx=l,wl.jsxs=l,wl}var PN;function W4(){return PN||(PN=1,Np.exports=z4()),Np.exports}var a=W4(),Ru={},Sp={exports:{}},hn={},_p={exports:{}},Ep={};/**
18
- * @license React
19
- * scheduler.production.min.js
20
- *
21
- * Copyright (c) Facebook, Inc. and its affiliates.
22
- *
23
- * This source code is licensed under the MIT license found in the
24
- * LICENSE file in the root directory of this source tree.
25
- */var DN;function H4(){return DN||(DN=1,(function(e){function t(K,U){var H=K.length;K.push(U);e:for(;0<H;){var D=H-1>>>1,V=K[D];if(0<s(V,U))K[D]=U,K[H]=V,H=D;else break e}}function n(K){return K.length===0?null:K[0]}function r(K){if(K.length===0)return null;var U=K[0],H=K.pop();if(H!==U){K[0]=H;e:for(var D=0,V=K.length,J=V>>>1;D<J;){var W=2*(D+1)-1,Z=K[W],Y=W+1,X=K[Y];if(0>s(Z,H))Y<V&&0>s(X,Z)?(K[D]=X,K[Y]=H,D=Y):(K[D]=Z,K[W]=H,D=W);else if(Y<V&&0>s(X,H))K[D]=X,K[Y]=H,D=Y;else break e}}return U}function s(K,U){var H=K.sortIndex-U.sortIndex;return H!==0?H:K.id-U.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var l=Date,c=l.now();e.unstable_now=function(){return l.now()-c}}var d=[],h=[],f=1,p=null,g=3,v=!1,j=!1,k=!1,x=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,b=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function S(K){for(var U=n(h);U!==null;){if(U.callback===null)r(h);else if(U.startTime<=K)r(h),U.sortIndex=U.expirationTime,t(d,U);else break;U=n(h)}}function E(K){if(k=!1,S(K),!j)if(n(d)!==null)j=!0,O(R);else{var U=n(h);U!==null&&G(E,U.startTime-K)}}function R(K,U){j=!1,k&&(k=!1,N(q),q=-1),v=!0;var H=g;try{for(S(U),p=n(d);p!==null&&(!(p.expirationTime>U)||K&&!L());){var D=p.callback;if(typeof D=="function"){p.callback=null,g=p.priorityLevel;var V=D(p.expirationTime<=U);U=e.unstable_now(),typeof V=="function"?p.callback=V:p===n(d)&&r(d),S(U)}else r(d);p=n(d)}if(p!==null)var J=!0;else{var W=n(h);W!==null&&G(E,W.startTime-U),J=!1}return J}finally{p=null,g=H,v=!1}}var I=!1,A=null,q=-1,$=5,B=-1;function L(){return!(e.unstable_now()-B<$)}function M(){if(A!==null){var K=e.unstable_now();B=K;var U=!0;try{U=A(!0,K)}finally{U?F():(I=!1,A=null)}}else I=!1}var F;if(typeof b=="function")F=function(){b(M)};else if(typeof MessageChannel<"u"){var T=new MessageChannel,P=T.port2;T.port1.onmessage=M,F=function(){P.postMessage(null)}}else F=function(){x(M,0)};function O(K){A=K,I||(I=!0,F())}function G(K,U){q=x(function(){K(e.unstable_now())},U)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(K){K.callback=null},e.unstable_continueExecution=function(){j||v||(j=!0,O(R))},e.unstable_forceFrameRate=function(K){0>K||125<K?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):$=0<K?Math.floor(1e3/K):5},e.unstable_getCurrentPriorityLevel=function(){return g},e.unstable_getFirstCallbackNode=function(){return n(d)},e.unstable_next=function(K){switch(g){case 1:case 2:case 3:var U=3;break;default:U=g}var H=g;g=U;try{return K()}finally{g=H}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(K,U){switch(K){case 1:case 2:case 3:case 4:case 5:break;default:K=3}var H=g;g=K;try{return U()}finally{g=H}},e.unstable_scheduleCallback=function(K,U,H){var D=e.unstable_now();switch(typeof H=="object"&&H!==null?(H=H.delay,H=typeof H=="number"&&0<H?D+H:D):H=D,K){case 1:var V=-1;break;case 2:V=250;break;case 5:V=1073741823;break;case 4:V=1e4;break;default:V=5e3}return V=H+V,K={id:f++,callback:U,priorityLevel:K,startTime:H,expirationTime:V,sortIndex:-1},H>D?(K.sortIndex=H,t(h,K),n(d)===null&&K===n(h)&&(k?(N(q),q=-1):k=!0,G(E,H-D))):(K.sortIndex=V,t(d,K),j||v||(j=!0,O(R))),K},e.unstable_shouldYield=L,e.unstable_wrapCallback=function(K){var U=g;return function(){var H=g;g=U;try{return K.apply(this,arguments)}finally{g=H}}}})(Ep)),Ep}var FN;function V4(){return FN||(FN=1,_p.exports=H4()),_p.exports}/**
26
- * @license React
27
- * react-dom.production.min.js
28
- *
29
- * Copyright (c) Facebook, Inc. and its affiliates.
30
- *
31
- * This source code is licensed under the MIT license found in the
32
- * LICENSE file in the root directory of this source tree.
33
- */var BN;function G4(){if(BN)return hn;BN=1;var e=pc(),t=V4();function n(i){for(var u="https://reactjs.org/docs/error-decoder.html?invariant="+i,m=1;m<arguments.length;m++)u+="&args[]="+encodeURIComponent(arguments[m]);return"Minified React error #"+i+"; visit "+u+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,s={};function o(i,u){l(i,u),l(i+"Capture",u)}function l(i,u){for(s[i]=u,i=0;i<u.length;i++)r.add(u[i])}var c=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),d=Object.prototype.hasOwnProperty,h=/^[: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]*$/,f={},p={};function g(i){return d.call(p,i)?!0:d.call(f,i)?!1:h.test(i)?p[i]=!0:(f[i]=!0,!1)}function v(i,u,m,w){if(m!==null&&m.type===0)return!1;switch(typeof u){case"function":case"symbol":return!0;case"boolean":return w?!1:m!==null?!m.acceptsBooleans:(i=i.toLowerCase().slice(0,5),i!=="data-"&&i!=="aria-");default:return!1}}function j(i,u,m,w){if(u===null||typeof u>"u"||v(i,u,m,w))return!0;if(w)return!1;if(m!==null)switch(m.type){case 3:return!u;case 4:return u===!1;case 5:return isNaN(u);case 6:return isNaN(u)||1>u}return!1}function k(i,u,m,w,_,C,z){this.acceptsBooleans=u===2||u===3||u===4,this.attributeName=w,this.attributeNamespace=_,this.mustUseProperty=m,this.propertyName=i,this.type=u,this.sanitizeURL=C,this.removeEmptyString=z}var x={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(i){x[i]=new k(i,0,!1,i,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(i){var u=i[0];x[u]=new k(u,1,!1,i[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(i){x[i]=new k(i,2,!1,i.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(i){x[i]=new k(i,2,!1,i,null,!1,!1)}),"allowFullScreen async autoFocus autoPlay controls default defer disabled disablePictureInPicture disableRemotePlayback formNoValidate hidden loop noModule noValidate open playsInline readOnly required reversed scoped seamless itemScope".split(" ").forEach(function(i){x[i]=new k(i,3,!1,i.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(i){x[i]=new k(i,3,!0,i,null,!1,!1)}),["capture","download"].forEach(function(i){x[i]=new k(i,4,!1,i,null,!1,!1)}),["cols","rows","size","span"].forEach(function(i){x[i]=new k(i,6,!1,i,null,!1,!1)}),["rowSpan","start"].forEach(function(i){x[i]=new k(i,5,!1,i.toLowerCase(),null,!1,!1)});var N=/[\-:]([a-z])/g;function b(i){return i[1].toUpperCase()}"accent-height alignment-baseline arabic-form baseline-shift cap-height clip-path clip-rule color-interpolation color-interpolation-filters color-profile color-rendering dominant-baseline enable-background fill-opacity fill-rule flood-color flood-opacity font-family font-size font-size-adjust font-stretch font-style font-variant font-weight glyph-name glyph-orientation-horizontal glyph-orientation-vertical horiz-adv-x horiz-origin-x image-rendering letter-spacing lighting-color marker-end marker-mid marker-start overline-position overline-thickness paint-order panose-1 pointer-events rendering-intent shape-rendering stop-color stop-opacity strikethrough-position strikethrough-thickness stroke-dasharray stroke-dashoffset stroke-linecap stroke-linejoin stroke-miterlimit stroke-opacity stroke-width text-anchor text-decoration text-rendering underline-position underline-thickness unicode-bidi unicode-range units-per-em v-alphabetic v-hanging v-ideographic v-mathematical vector-effect vert-adv-y vert-origin-x vert-origin-y word-spacing writing-mode xmlns:xlink x-height".split(" ").forEach(function(i){var u=i.replace(N,b);x[u]=new k(u,1,!1,i,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(i){var u=i.replace(N,b);x[u]=new k(u,1,!1,i,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(i){var u=i.replace(N,b);x[u]=new k(u,1,!1,i,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(i){x[i]=new k(i,1,!1,i.toLowerCase(),null,!1,!1)}),x.xlinkHref=new k("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(i){x[i]=new k(i,1,!1,i.toLowerCase(),null,!0,!0)});function S(i,u,m,w){var _=x.hasOwnProperty(u)?x[u]:null;(_!==null?_.type!==0:w||!(2<u.length)||u[0]!=="o"&&u[0]!=="O"||u[1]!=="n"&&u[1]!=="N")&&(j(u,m,_,w)&&(m=null),w||_===null?g(u)&&(m===null?i.removeAttribute(u):i.setAttribute(u,""+m)):_.mustUseProperty?i[_.propertyName]=m===null?_.type===3?!1:"":m:(u=_.attributeName,w=_.attributeNamespace,m===null?i.removeAttribute(u):(_=_.type,m=_===3||_===4&&m===!0?"":""+m,w?i.setAttributeNS(w,u,m):i.setAttribute(u,m))))}var E=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,R=Symbol.for("react.element"),I=Symbol.for("react.portal"),A=Symbol.for("react.fragment"),q=Symbol.for("react.strict_mode"),$=Symbol.for("react.profiler"),B=Symbol.for("react.provider"),L=Symbol.for("react.context"),M=Symbol.for("react.forward_ref"),F=Symbol.for("react.suspense"),T=Symbol.for("react.suspense_list"),P=Symbol.for("react.memo"),O=Symbol.for("react.lazy"),G=Symbol.for("react.offscreen"),K=Symbol.iterator;function U(i){return i===null||typeof i!="object"?null:(i=K&&i[K]||i["@@iterator"],typeof i=="function"?i:null)}var H=Object.assign,D;function V(i){if(D===void 0)try{throw Error()}catch(m){var u=m.stack.trim().match(/\n( *(at )?)/);D=u&&u[1]||""}return`
34
- `+D+i}var J=!1;function W(i,u){if(!i||J)return"";J=!0;var m=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(u)if(u=function(){throw Error()},Object.defineProperty(u.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(u,[])}catch(ue){var w=ue}Reflect.construct(i,[],u)}else{try{u.call()}catch(ue){w=ue}i.call(u.prototype)}else{try{throw Error()}catch(ue){w=ue}i()}}catch(ue){if(ue&&w&&typeof ue.stack=="string"){for(var _=ue.stack.split(`
35
- `),C=w.stack.split(`
36
- `),z=_.length-1,Q=C.length-1;1<=z&&0<=Q&&_[z]!==C[Q];)Q--;for(;1<=z&&0<=Q;z--,Q--)if(_[z]!==C[Q]){if(z!==1||Q!==1)do if(z--,Q--,0>Q||_[z]!==C[Q]){var te=`
37
- `+_[z].replace(" at new "," at ");return i.displayName&&te.includes("<anonymous>")&&(te=te.replace("<anonymous>",i.displayName)),te}while(1<=z&&0<=Q);break}}}finally{J=!1,Error.prepareStackTrace=m}return(i=i?i.displayName||i.name:"")?V(i):""}function Z(i){switch(i.tag){case 5:return V(i.type);case 16:return V("Lazy");case 13:return V("Suspense");case 19:return V("SuspenseList");case 0:case 2:case 15:return i=W(i.type,!1),i;case 11:return i=W(i.type.render,!1),i;case 1:return i=W(i.type,!0),i;default:return""}}function Y(i){if(i==null)return null;if(typeof i=="function")return i.displayName||i.name||null;if(typeof i=="string")return i;switch(i){case A:return"Fragment";case I:return"Portal";case $:return"Profiler";case q:return"StrictMode";case F:return"Suspense";case T:return"SuspenseList"}if(typeof i=="object")switch(i.$$typeof){case L:return(i.displayName||"Context")+".Consumer";case B:return(i._context.displayName||"Context")+".Provider";case M:var u=i.render;return i=i.displayName,i||(i=u.displayName||u.name||"",i=i!==""?"ForwardRef("+i+")":"ForwardRef"),i;case P:return u=i.displayName||null,u!==null?u:Y(i.type)||"Memo";case O:u=i._payload,i=i._init;try{return Y(i(u))}catch{}}return null}function X(i){var u=i.type;switch(i.tag){case 24:return"Cache";case 9:return(u.displayName||"Context")+".Consumer";case 10:return(u._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return i=u.render,i=i.displayName||i.name||"",u.displayName||(i!==""?"ForwardRef("+i+")":"ForwardRef");case 7:return"Fragment";case 5:return u;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Y(u);case 8:return u===q?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof u=="function")return u.displayName||u.name||null;if(typeof u=="string")return u}return null}function ee(i){switch(typeof i){case"boolean":case"number":case"string":case"undefined":return i;case"object":return i;default:return""}}function ae(i){var u=i.type;return(i=i.nodeName)&&i.toLowerCase()==="input"&&(u==="checkbox"||u==="radio")}function ce(i){var u=ae(i)?"checked":"value",m=Object.getOwnPropertyDescriptor(i.constructor.prototype,u),w=""+i[u];if(!i.hasOwnProperty(u)&&typeof m<"u"&&typeof m.get=="function"&&typeof m.set=="function"){var _=m.get,C=m.set;return Object.defineProperty(i,u,{configurable:!0,get:function(){return _.call(this)},set:function(z){w=""+z,C.call(this,z)}}),Object.defineProperty(i,u,{enumerable:m.enumerable}),{getValue:function(){return w},setValue:function(z){w=""+z},stopTracking:function(){i._valueTracker=null,delete i[u]}}}}function ge(i){i._valueTracker||(i._valueTracker=ce(i))}function ye(i){if(!i)return!1;var u=i._valueTracker;if(!u)return!0;var m=u.getValue(),w="";return i&&(w=ae(i)?i.checked?"true":"false":i.value),i=w,i!==m?(u.setValue(i),!0):!1}function se(i){if(i=i||(typeof document<"u"?document:void 0),typeof i>"u")return null;try{return i.activeElement||i.body}catch{return i.body}}function pe(i,u){var m=u.checked;return H({},u,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:m??i._wrapperState.initialChecked})}function fe(i,u){var m=u.defaultValue==null?"":u.defaultValue,w=u.checked!=null?u.checked:u.defaultChecked;m=ee(u.value!=null?u.value:m),i._wrapperState={initialChecked:w,initialValue:m,controlled:u.type==="checkbox"||u.type==="radio"?u.checked!=null:u.value!=null}}function de(i,u){u=u.checked,u!=null&&S(i,"checked",u,!1)}function me(i,u){de(i,u);var m=ee(u.value),w=u.type;if(m!=null)w==="number"?(m===0&&i.value===""||i.value!=m)&&(i.value=""+m):i.value!==""+m&&(i.value=""+m);else if(w==="submit"||w==="reset"){i.removeAttribute("value");return}u.hasOwnProperty("value")?oe(i,u.type,m):u.hasOwnProperty("defaultValue")&&oe(i,u.type,ee(u.defaultValue)),u.checked==null&&u.defaultChecked!=null&&(i.defaultChecked=!!u.defaultChecked)}function ne(i,u,m){if(u.hasOwnProperty("value")||u.hasOwnProperty("defaultValue")){var w=u.type;if(!(w!=="submit"&&w!=="reset"||u.value!==void 0&&u.value!==null))return;u=""+i._wrapperState.initialValue,m||u===i.value||(i.value=u),i.defaultValue=u}m=i.name,m!==""&&(i.name=""),i.defaultChecked=!!i._wrapperState.initialChecked,m!==""&&(i.name=m)}function oe(i,u,m){(u!=="number"||se(i.ownerDocument)!==i)&&(m==null?i.defaultValue=""+i._wrapperState.initialValue:i.defaultValue!==""+m&&(i.defaultValue=""+m))}var Ne=Array.isArray;function we(i,u,m,w){if(i=i.options,u){u={};for(var _=0;_<m.length;_++)u["$"+m[_]]=!0;for(m=0;m<i.length;m++)_=u.hasOwnProperty("$"+i[m].value),i[m].selected!==_&&(i[m].selected=_),_&&w&&(i[m].defaultSelected=!0)}else{for(m=""+ee(m),u=null,_=0;_<i.length;_++){if(i[_].value===m){i[_].selected=!0,w&&(i[_].defaultSelected=!0);return}u!==null||i[_].disabled||(u=i[_])}u!==null&&(u.selected=!0)}}function Me(i,u){if(u.dangerouslySetInnerHTML!=null)throw Error(n(91));return H({},u,{value:void 0,defaultValue:void 0,children:""+i._wrapperState.initialValue})}function Le(i,u){var m=u.value;if(m==null){if(m=u.children,u=u.defaultValue,m!=null){if(u!=null)throw Error(n(92));if(Ne(m)){if(1<m.length)throw Error(n(93));m=m[0]}u=m}u==null&&(u=""),m=u}i._wrapperState={initialValue:ee(m)}}function Be(i,u){var m=ee(u.value),w=ee(u.defaultValue);m!=null&&(m=""+m,m!==i.value&&(i.value=m),u.defaultValue==null&&i.defaultValue!==m&&(i.defaultValue=m)),w!=null&&(i.defaultValue=""+w)}function Pe(i){var u=i.textContent;u===i._wrapperState.initialValue&&u!==""&&u!==null&&(i.value=u)}function Qe(i){switch(i){case"svg":return"http://www.w3.org/2000/svg";case"math":return"http://www.w3.org/1998/Math/MathML";default:return"http://www.w3.org/1999/xhtml"}}function qe(i,u){return i==null||i==="http://www.w3.org/1999/xhtml"?Qe(u):i==="http://www.w3.org/2000/svg"&&u==="foreignObject"?"http://www.w3.org/1999/xhtml":i}var Ze,lt=(function(i){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(u,m,w,_){MSApp.execUnsafeLocalFunction(function(){return i(u,m,w,_)})}:i})(function(i,u){if(i.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in i)i.innerHTML=u;else{for(Ze=Ze||document.createElement("div"),Ze.innerHTML="<svg>"+u.valueOf().toString()+"</svg>",u=Ze.firstChild;i.firstChild;)i.removeChild(i.firstChild);for(;u.firstChild;)i.appendChild(u.firstChild)}});function Nt(i,u){if(u){var m=i.firstChild;if(m&&m===i.lastChild&&m.nodeType===3){m.nodeValue=u;return}}i.textContent=u}var Xe={animationIterationCount:!0,aspectRatio:!0,borderImageOutset:!0,borderImageSlice:!0,borderImageWidth:!0,boxFlex:!0,boxFlexGroup:!0,boxOrdinalGroup:!0,columnCount:!0,columns:!0,flex:!0,flexGrow:!0,flexPositive:!0,flexShrink:!0,flexNegative:!0,flexOrder:!0,gridArea:!0,gridRow:!0,gridRowEnd:!0,gridRowSpan:!0,gridRowStart:!0,gridColumn:!0,gridColumnEnd:!0,gridColumnSpan:!0,gridColumnStart:!0,fontWeight:!0,lineClamp:!0,lineHeight:!0,opacity:!0,order:!0,orphans:!0,tabSize:!0,widows:!0,zIndex:!0,zoom:!0,fillOpacity:!0,floodOpacity:!0,stopOpacity:!0,strokeDasharray:!0,strokeDashoffset:!0,strokeMiterlimit:!0,strokeOpacity:!0,strokeWidth:!0},tt=["Webkit","ms","Moz","O"];Object.keys(Xe).forEach(function(i){tt.forEach(function(u){u=u+i.charAt(0).toUpperCase()+i.substring(1),Xe[u]=Xe[i]})});function Ge(i,u,m){return u==null||typeof u=="boolean"||u===""?"":m||typeof u!="number"||u===0||Xe.hasOwnProperty(i)&&Xe[i]?(""+u).trim():u+"px"}function ct(i,u){i=i.style;for(var m in u)if(u.hasOwnProperty(m)){var w=m.indexOf("--")===0,_=Ge(m,u[m],w);m==="float"&&(m="cssFloat"),w?i.setProperty(m,_):i[m]=_}}var en=H({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Dt(i,u){if(u){if(en[i]&&(u.children!=null||u.dangerouslySetInnerHTML!=null))throw Error(n(137,i));if(u.dangerouslySetInnerHTML!=null){if(u.children!=null)throw Error(n(60));if(typeof u.dangerouslySetInnerHTML!="object"||!("__html"in u.dangerouslySetInnerHTML))throw Error(n(61))}if(u.style!=null&&typeof u.style!="object")throw Error(n(62))}}function gt(i,u){if(i.indexOf("-")===-1)return typeof u.is=="string";switch(i){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 wt=null;function zt(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var Rt=null,ht=null,tn=null;function Wt(i){if(i=rl(i)){if(typeof Rt!="function")throw Error(n(280));var u=i.stateNode;u&&(u=Hc(u),Rt(i.stateNode,i.type,u))}}function jt(i){ht?tn?tn.push(i):tn=[i]:ht=i}function Jn(){if(ht){var i=ht,u=tn;if(tn=ht=null,Wt(i),u)for(i=0;i<u.length;i++)Wt(u[i])}}function yn(i,u){return i(u)}function Qn(){}var Rn=!1;function Yr(i,u,m){if(Rn)return i(u,m);Rn=!0;try{return yn(i,u,m)}finally{Rn=!1,(ht!==null||tn!==null)&&(Qn(),Jn())}}function Mn(i,u){var m=i.stateNode;if(m===null)return null;var w=Hc(m);if(w===null)return null;m=w[u];e:switch(u){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(w=!w.disabled)||(i=i.type,w=!(i==="button"||i==="input"||i==="select"||i==="textarea")),i=!w;break e;default:i=!1}if(i)return null;if(m&&typeof m!="function")throw Error(n(231,u,typeof m));return m}var wn=!1;if(c)try{var $n={};Object.defineProperty($n,"passive",{get:function(){wn=!0}}),window.addEventListener("test",$n,$n),window.removeEventListener("test",$n,$n)}catch{wn=!1}function _s(i,u,m,w,_,C,z,Q,te){var ue=Array.prototype.slice.call(arguments,3);try{u.apply(m,ue)}catch(xe){this.onError(xe)}}var In=!1,er=null,Er=!1,Xr=null,Mt={onError:function(i){In=!0,er=i}};function ua(i,u,m,w,_,C,z,Q,te){In=!1,er=null,_s.apply(Mt,arguments)}function tr(i,u,m,w,_,C,z,Q,te){if(ua.apply(this,arguments),In){if(In){var ue=er;In=!1,er=null}else throw Error(n(198));Er||(Er=!0,Xr=ue)}}function nn(i){var u=i,m=i;if(i.alternate)for(;u.return;)u=u.return;else{i=u;do u=i,(u.flags&4098)!==0&&(m=u.return),i=u.return;while(i)}return u.tag===3?m:null}function Cr(i){if(i.tag===13){var u=i.memoizedState;if(u===null&&(i=i.alternate,i!==null&&(u=i.memoizedState)),u!==null)return u.dehydrated}return null}function Es(i){if(nn(i)!==i)throw Error(n(188))}function Cs(i){var u=i.alternate;if(!u){if(u=nn(i),u===null)throw Error(n(188));return u!==i?null:i}for(var m=i,w=u;;){var _=m.return;if(_===null)break;var C=_.alternate;if(C===null){if(w=_.return,w!==null){m=w;continue}break}if(_.child===C.child){for(C=_.child;C;){if(C===m)return Es(_),i;if(C===w)return Es(_),u;C=C.sibling}throw Error(n(188))}if(m.return!==w.return)m=_,w=C;else{for(var z=!1,Q=_.child;Q;){if(Q===m){z=!0,m=_,w=C;break}if(Q===w){z=!0,w=_,m=C;break}Q=Q.sibling}if(!z){for(Q=C.child;Q;){if(Q===m){z=!0,m=C,w=_;break}if(Q===w){z=!0,w=C,m=_;break}Q=Q.sibling}if(!z)throw Error(n(189))}}if(m.alternate!==w)throw Error(n(190))}if(m.tag!==3)throw Error(n(188));return m.stateNode.current===m?i:u}function nr(i){return i=Cs(i),i!==null?Zr(i):null}function Zr(i){if(i.tag===5||i.tag===6)return i;for(i=i.child;i!==null;){var u=Zr(i);if(u!==null)return u;i=i.sibling}return null}var Ts=t.unstable_scheduleCallback,Tr=t.unstable_cancelCallback,Ar=t.unstable_shouldYield,be=t.unstable_requestPaint,Re=t.unstable_now,ze=t.unstable_getCurrentPriorityLevel,rn=t.unstable_ImmediatePriority,Jr=t.unstable_UserBlockingPriority,Ht=t.unstable_NormalPriority,rr=t.unstable_LowPriority,sr=t.unstable_IdlePriority,On=null,sn=null;function As(i){if(sn&&typeof sn.onCommitFiberRoot=="function")try{sn.onCommitFiberRoot(On,i,void 0,(i.current.flags&128)===128)}catch{}}var an=Math.clz32?Math.clz32:Cc,Kh=Math.log,Ec=Math.LN2;function Cc(i){return i>>>=0,i===0?32:31-(Kh(i)/Ec|0)|0}var vn=64,ho=4194304;function da(i){switch(i&-i){case 1:return 1;case 2:return 2;case 4:return 4;case 8:return 8;case 16:return 16;case 32:return 32;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return i&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return i&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return i}}function ha(i,u){var m=i.pendingLanes;if(m===0)return 0;var w=0,_=i.suspendedLanes,C=i.pingedLanes,z=m&268435455;if(z!==0){var Q=z&~_;Q!==0?w=da(Q):(C&=z,C!==0&&(w=da(C)))}else z=m&~_,z!==0?w=da(z):C!==0&&(w=da(C));if(w===0)return 0;if(u!==0&&u!==w&&(u&_)===0&&(_=w&-w,C=u&-u,_>=C||_===16&&(C&4194240)!==0))return u;if((w&4)!==0&&(w|=m&16),u=i.entangledLanes,u!==0)for(i=i.entanglements,u&=w;0<u;)m=31-an(u),_=1<<m,w|=i[m],u&=~_;return w}function Tc(i,u){switch(i){case 1:case 2:case 4:return u+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return u+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Bi(i,u){for(var m=i.suspendedLanes,w=i.pingedLanes,_=i.expirationTimes,C=i.pendingLanes;0<C;){var z=31-an(C),Q=1<<z,te=_[z];te===-1?((Q&m)===0||(Q&w)!==0)&&(_[z]=Tc(Q,u)):te<=u&&(i.expiredLanes|=Q),C&=~Q}}function fa(i){return i=i.pendingLanes&-1073741825,i!==0?i:i&1073741824?1073741824:0}function Rr(){var i=vn;return vn<<=1,(vn&4194240)===0&&(vn=64),i}function qi(i){for(var u=[],m=0;31>m;m++)u.push(i);return u}function pa(i,u,m){i.pendingLanes|=u,u!==536870912&&(i.suspendedLanes=0,i.pingedLanes=0),i=i.eventTimes,u=31-an(u),i[u]=m}function Yh(i,u){var m=i.pendingLanes&~u;i.pendingLanes=u,i.suspendedLanes=0,i.pingedLanes=0,i.expiredLanes&=u,i.mutableReadLanes&=u,i.entangledLanes&=u,u=i.entanglements;var w=i.eventTimes;for(i=i.expirationTimes;0<m;){var _=31-an(m),C=1<<_;u[_]=0,w[_]=-1,i[_]=-1,m&=~C}}function fo(i,u){var m=i.entangledLanes|=u;for(i=i.entanglements;m;){var w=31-an(m),_=1<<w;_&u|i[w]&u&&(i[w]|=u),m&=~_}}var Ue=0;function Ac(i){return i&=-i,1<i?4<i?(i&268435455)!==0?16:536870912:4:1}var Ui,po,mo,Rc,Mc,ma=!1,ga=[],Mr=null,$r=null,Ir=null,Qr=new Map,ya=new Map,ar=[],Xh="mousedown mouseup touchcancel touchend touchstart auxclick dblclick pointercancel pointerdown pointerup dragend dragstart drop compositionend compositionstart keydown keypress keyup input textInput copy cut paste click change contextmenu reset submit".split(" ");function $c(i,u){switch(i){case"focusin":case"focusout":Mr=null;break;case"dragenter":case"dragleave":$r=null;break;case"mouseover":case"mouseout":Ir=null;break;case"pointerover":case"pointerout":Qr.delete(u.pointerId);break;case"gotpointercapture":case"lostpointercapture":ya.delete(u.pointerId)}}function wa(i,u,m,w,_,C){return i===null||i.nativeEvent!==C?(i={blockedOn:u,domEventName:m,eventSystemFlags:w,nativeEvent:C,targetContainers:[_]},u!==null&&(u=rl(u),u!==null&&po(u)),i):(i.eventSystemFlags|=w,u=i.targetContainers,_!==null&&u.indexOf(_)===-1&&u.push(_),i)}function Ic(i,u,m,w,_){switch(u){case"focusin":return Mr=wa(Mr,i,u,m,w,_),!0;case"dragenter":return $r=wa($r,i,u,m,w,_),!0;case"mouseover":return Ir=wa(Ir,i,u,m,w,_),!0;case"pointerover":var C=_.pointerId;return Qr.set(C,wa(Qr.get(C)||null,i,u,m,w,_)),!0;case"gotpointercapture":return C=_.pointerId,ya.set(C,wa(ya.get(C)||null,i,u,m,w,_)),!0}return!1}function Oc(i){var u=Sa(i.target);if(u!==null){var m=nn(u);if(m!==null){if(u=m.tag,u===13){if(u=Cr(m),u!==null){i.blockedOn=u,Mc(i.priority,function(){mo(m)});return}}else if(u===3&&m.stateNode.current.memoizedState.isDehydrated){i.blockedOn=m.tag===3?m.stateNode.containerInfo:null;return}}}i.blockedOn=null}function go(i){if(i.blockedOn!==null)return!1;for(var u=i.targetContainers;0<u.length;){var m=ka(i.domEventName,i.eventSystemFlags,u[0],i.nativeEvent);if(m===null){m=i.nativeEvent;var w=new m.constructor(m.type,m);wt=w,m.target.dispatchEvent(w),wt=null}else return u=rl(m),u!==null&&po(u),i.blockedOn=m,!1;u.shift()}return!0}function zi(i,u,m){go(i)&&m.delete(u)}function va(){ma=!1,Mr!==null&&go(Mr)&&(Mr=null),$r!==null&&go($r)&&($r=null),Ir!==null&&go(Ir)&&(Ir=null),Qr.forEach(zi),ya.forEach(zi)}function es(i,u){i.blockedOn===u&&(i.blockedOn=null,ma||(ma=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,va)))}function xn(i){function u(_){return es(_,i)}if(0<ga.length){es(ga[0],i);for(var m=1;m<ga.length;m++){var w=ga[m];w.blockedOn===i&&(w.blockedOn=null)}}for(Mr!==null&&es(Mr,i),$r!==null&&es($r,i),Ir!==null&&es(Ir,i),Qr.forEach(u),ya.forEach(u),m=0;m<ar.length;m++)w=ar[m],w.blockedOn===i&&(w.blockedOn=null);for(;0<ar.length&&(m=ar[0],m.blockedOn===null);)Oc(m),m.blockedOn===null&&ar.shift()}var ts=E.ReactCurrentBatchConfig,xa=!0;function Lc(i,u,m,w){var _=Ue,C=ts.transition;ts.transition=null;try{Ue=1,ba(i,u,m,w)}finally{Ue=_,ts.transition=C}}function Pc(i,u,m,w){var _=Ue,C=ts.transition;ts.transition=null;try{Ue=4,ba(i,u,m,w)}finally{Ue=_,ts.transition=C}}function ba(i,u,m,w){if(xa){var _=ka(i,u,m,w);if(_===null)hf(i,u,w,yo,m),$c(i,w);else if(Ic(_,i,u,m,w))w.stopPropagation();else if($c(i,w),u&4&&-1<Xh.indexOf(i)){for(;_!==null;){var C=rl(_);if(C!==null&&Ui(C),C=ka(i,u,m,w),C===null&&hf(i,u,w,yo,m),C===_)break;_=C}_!==null&&w.stopPropagation()}else hf(i,u,w,null,m)}}var yo=null;function ka(i,u,m,w){if(yo=null,i=zt(w),i=Sa(i),i!==null)if(u=nn(i),u===null)i=null;else if(m=u.tag,m===13){if(i=Cr(u),i!==null)return i;i=null}else if(m===3){if(u.stateNode.current.memoizedState.isDehydrated)return u.tag===3?u.stateNode.containerInfo:null;i=null}else u!==i&&(i=null);return yo=i,null}function Wi(i){switch(i){case"cancel":case"click":case"close":case"contextmenu":case"copy":case"cut":case"auxclick":case"dblclick":case"dragend":case"dragstart":case"drop":case"focusin":case"focusout":case"input":case"invalid":case"keydown":case"keypress":case"keyup":case"mousedown":case"mouseup":case"paste":case"pause":case"play":case"pointercancel":case"pointerdown":case"pointerup":case"ratechange":case"reset":case"resize":case"seeked":case"submit":case"touchcancel":case"touchend":case"touchstart":case"volumechange":case"change":case"selectionchange":case"textInput":case"compositionstart":case"compositionend":case"compositionupdate":case"beforeblur":case"afterblur":case"beforeinput":case"blur":case"fullscreenchange":case"focus":case"hashchange":case"popstate":case"select":case"selectstart":return 1;case"drag":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"mousemove":case"mouseout":case"mouseover":case"pointermove":case"pointerout":case"pointerover":case"scroll":case"toggle":case"touchmove":case"wheel":case"mouseenter":case"mouseleave":case"pointerenter":case"pointerleave":return 4;case"message":switch(ze()){case rn:return 1;case Jr:return 4;case Ht:case rr:return 16;case sr:return 536870912;default:return 16}default:return 16}}var or=null,Hi=null,wo=null;function vo(){if(wo)return wo;var i,u=Hi,m=u.length,w,_="value"in or?or.value:or.textContent,C=_.length;for(i=0;i<m&&u[i]===_[i];i++);var z=m-i;for(w=1;w<=z&&u[m-w]===_[C-w];w++);return wo=_.slice(i,1<w?1-w:void 0)}function ns(i){var u=i.keyCode;return"charCode"in i?(i=i.charCode,i===0&&u===13&&(i=13)):i=u,i===10&&(i=13),32<=i||i===13?i:0}function xo(){return!0}function Rs(){return!1}function Xt(i){function u(m,w,_,C,z){this._reactName=m,this._targetInst=_,this.type=w,this.nativeEvent=C,this.target=z,this.currentTarget=null;for(var Q in i)i.hasOwnProperty(Q)&&(m=i[Q],this[Q]=m?m(C):C[Q]);return this.isDefaultPrevented=(C.defaultPrevented!=null?C.defaultPrevented:C.returnValue===!1)?xo:Rs,this.isPropagationStopped=Rs,this}return H(u.prototype,{preventDefault:function(){this.defaultPrevented=!0;var m=this.nativeEvent;m&&(m.preventDefault?m.preventDefault():typeof m.returnValue!="unknown"&&(m.returnValue=!1),this.isDefaultPrevented=xo)},stopPropagation:function(){var m=this.nativeEvent;m&&(m.stopPropagation?m.stopPropagation():typeof m.cancelBubble!="unknown"&&(m.cancelBubble=!0),this.isPropagationStopped=xo)},persist:function(){},isPersistent:xo}),u}var Ms={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Vi=Xt(Ms),$s=H({},Ms,{view:0,detail:0}),Zh=Xt($s),Gi,bo,ir,Na=H({},$s,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:ef,button:0,buttons:0,relatedTarget:function(i){return i.relatedTarget===void 0?i.fromElement===i.srcElement?i.toElement:i.fromElement:i.relatedTarget},movementX:function(i){return"movementX"in i?i.movementX:(i!==ir&&(ir&&i.type==="mousemove"?(Gi=i.screenX-ir.screenX,bo=i.screenY-ir.screenY):bo=Gi=0,ir=i),Gi)},movementY:function(i){return"movementY"in i?i.movementY:bo}}),ko=Xt(Na),Jh=H({},Na,{dataTransfer:0}),ja=Xt(Jh),g3=H({},$s,{relatedTarget:0}),Qh=Xt(g3),y3=H({},Ms,{animationName:0,elapsedTime:0,pseudoElement:0}),w3=Xt(y3),v3=H({},Ms,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),x3=Xt(v3),b3=H({},Ms,{data:0}),j0=Xt(b3),k3={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},N3={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"},j3={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function S3(i){var u=this.nativeEvent;return u.getModifierState?u.getModifierState(i):(i=j3[i])?!!u[i]:!1}function ef(){return S3}var _3=H({},$s,{key:function(i){if(i.key){var u=k3[i.key]||i.key;if(u!=="Unidentified")return u}return i.type==="keypress"?(i=ns(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?N3[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:ef,charCode:function(i){return i.type==="keypress"?ns(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?ns(i):i.type==="keydown"||i.type==="keyup"?i.keyCode:0}}),E3=Xt(_3),C3=H({},Na,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),S0=Xt(C3),T3=H({},$s,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:ef}),A3=Xt(T3),R3=H({},Ms,{propertyName:0,elapsedTime:0,pseudoElement:0}),M3=Xt(R3),$3=H({},Na,{deltaX:function(i){return"deltaX"in i?i.deltaX:"wheelDeltaX"in i?-i.wheelDeltaX:0},deltaY:function(i){return"deltaY"in i?i.deltaY:"wheelDeltaY"in i?-i.wheelDeltaY:"wheelDelta"in i?-i.wheelDelta:0},deltaZ:0,deltaMode:0}),I3=Xt($3),O3=[9,13,27,32],tf=c&&"CompositionEvent"in window,Ki=null;c&&"documentMode"in document&&(Ki=document.documentMode);var L3=c&&"TextEvent"in window&&!Ki,_0=c&&(!tf||Ki&&8<Ki&&11>=Ki),E0=" ",C0=!1;function T0(i,u){switch(i){case"keyup":return O3.indexOf(u.keyCode)!==-1;case"keydown":return u.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function A0(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var No=!1;function P3(i,u){switch(i){case"compositionend":return A0(u);case"keypress":return u.which!==32?null:(C0=!0,E0);case"textInput":return i=u.data,i===E0&&C0?null:i;default:return null}}function D3(i,u){if(No)return i==="compositionend"||!tf&&T0(i,u)?(i=vo(),wo=Hi=or=null,No=!1,i):null;switch(i){case"paste":return null;case"keypress":if(!(u.ctrlKey||u.altKey||u.metaKey)||u.ctrlKey&&u.altKey){if(u.char&&1<u.char.length)return u.char;if(u.which)return String.fromCharCode(u.which)}return null;case"compositionend":return _0&&u.locale!=="ko"?null:u.data;default:return null}}var F3={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 R0(i){var u=i&&i.nodeName&&i.nodeName.toLowerCase();return u==="input"?!!F3[i.type]:u==="textarea"}function M0(i,u,m,w){jt(w),u=Uc(u,"onChange"),0<u.length&&(m=new Vi("onChange","change",null,m,w),i.push({event:m,listeners:u}))}var Yi=null,Xi=null;function B3(i){X0(i,0)}function Dc(i){var u=Co(i);if(ye(u))return i}function q3(i,u){if(i==="change")return u}var $0=!1;if(c){var nf;if(c){var rf="oninput"in document;if(!rf){var I0=document.createElement("div");I0.setAttribute("oninput","return;"),rf=typeof I0.oninput=="function"}nf=rf}else nf=!1;$0=nf&&(!document.documentMode||9<document.documentMode)}function O0(){Yi&&(Yi.detachEvent("onpropertychange",L0),Xi=Yi=null)}function L0(i){if(i.propertyName==="value"&&Dc(Xi)){var u=[];M0(u,Xi,i,zt(i)),Yr(B3,u)}}function U3(i,u,m){i==="focusin"?(O0(),Yi=u,Xi=m,Yi.attachEvent("onpropertychange",L0)):i==="focusout"&&O0()}function z3(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return Dc(Xi)}function W3(i,u){if(i==="click")return Dc(u)}function H3(i,u){if(i==="input"||i==="change")return Dc(u)}function V3(i,u){return i===u&&(i!==0||1/i===1/u)||i!==i&&u!==u}var lr=typeof Object.is=="function"?Object.is:V3;function Zi(i,u){if(lr(i,u))return!0;if(typeof i!="object"||i===null||typeof u!="object"||u===null)return!1;var m=Object.keys(i),w=Object.keys(u);if(m.length!==w.length)return!1;for(w=0;w<m.length;w++){var _=m[w];if(!d.call(u,_)||!lr(i[_],u[_]))return!1}return!0}function P0(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function D0(i,u){var m=P0(i);i=0;for(var w;m;){if(m.nodeType===3){if(w=i+m.textContent.length,i<=u&&w>=u)return{node:m,offset:u-i};i=w}e:{for(;m;){if(m.nextSibling){m=m.nextSibling;break e}m=m.parentNode}m=void 0}m=P0(m)}}function F0(i,u){return i&&u?i===u?!0:i&&i.nodeType===3?!1:u&&u.nodeType===3?F0(i,u.parentNode):"contains"in i?i.contains(u):i.compareDocumentPosition?!!(i.compareDocumentPosition(u)&16):!1:!1}function B0(){for(var i=window,u=se();u instanceof i.HTMLIFrameElement;){try{var m=typeof u.contentWindow.location.href=="string"}catch{m=!1}if(m)i=u.contentWindow;else break;u=se(i.document)}return u}function sf(i){var u=i&&i.nodeName&&i.nodeName.toLowerCase();return u&&(u==="input"&&(i.type==="text"||i.type==="search"||i.type==="tel"||i.type==="url"||i.type==="password")||u==="textarea"||i.contentEditable==="true")}function G3(i){var u=B0(),m=i.focusedElem,w=i.selectionRange;if(u!==m&&m&&m.ownerDocument&&F0(m.ownerDocument.documentElement,m)){if(w!==null&&sf(m)){if(u=w.start,i=w.end,i===void 0&&(i=u),"selectionStart"in m)m.selectionStart=u,m.selectionEnd=Math.min(i,m.value.length);else if(i=(u=m.ownerDocument||document)&&u.defaultView||window,i.getSelection){i=i.getSelection();var _=m.textContent.length,C=Math.min(w.start,_);w=w.end===void 0?C:Math.min(w.end,_),!i.extend&&C>w&&(_=w,w=C,C=_),_=D0(m,C);var z=D0(m,w);_&&z&&(i.rangeCount!==1||i.anchorNode!==_.node||i.anchorOffset!==_.offset||i.focusNode!==z.node||i.focusOffset!==z.offset)&&(u=u.createRange(),u.setStart(_.node,_.offset),i.removeAllRanges(),C>w?(i.addRange(u),i.extend(z.node,z.offset)):(u.setEnd(z.node,z.offset),i.addRange(u)))}}for(u=[],i=m;i=i.parentNode;)i.nodeType===1&&u.push({element:i,left:i.scrollLeft,top:i.scrollTop});for(typeof m.focus=="function"&&m.focus(),m=0;m<u.length;m++)i=u[m],i.element.scrollLeft=i.left,i.element.scrollTop=i.top}}var K3=c&&"documentMode"in document&&11>=document.documentMode,jo=null,af=null,Ji=null,of=!1;function q0(i,u,m){var w=m.window===m?m.document:m.nodeType===9?m:m.ownerDocument;of||jo==null||jo!==se(w)||(w=jo,"selectionStart"in w&&sf(w)?w={start:w.selectionStart,end:w.selectionEnd}:(w=(w.ownerDocument&&w.ownerDocument.defaultView||window).getSelection(),w={anchorNode:w.anchorNode,anchorOffset:w.anchorOffset,focusNode:w.focusNode,focusOffset:w.focusOffset}),Ji&&Zi(Ji,w)||(Ji=w,w=Uc(af,"onSelect"),0<w.length&&(u=new Vi("onSelect","select",null,u,m),i.push({event:u,listeners:w}),u.target=jo)))}function Fc(i,u){var m={};return m[i.toLowerCase()]=u.toLowerCase(),m["Webkit"+i]="webkit"+u,m["Moz"+i]="moz"+u,m}var So={animationend:Fc("Animation","AnimationEnd"),animationiteration:Fc("Animation","AnimationIteration"),animationstart:Fc("Animation","AnimationStart"),transitionend:Fc("Transition","TransitionEnd")},lf={},U0={};c&&(U0=document.createElement("div").style,"AnimationEvent"in window||(delete So.animationend.animation,delete So.animationiteration.animation,delete So.animationstart.animation),"TransitionEvent"in window||delete So.transitionend.transition);function Bc(i){if(lf[i])return lf[i];if(!So[i])return i;var u=So[i],m;for(m in u)if(u.hasOwnProperty(m)&&m in U0)return lf[i]=u[m];return i}var z0=Bc("animationend"),W0=Bc("animationiteration"),H0=Bc("animationstart"),V0=Bc("transitionend"),G0=new Map,K0="abort auxClick cancel canPlay canPlayThrough click close contextMenu copy cut drag dragEnd dragEnter dragExit dragLeave dragOver dragStart drop durationChange emptied encrypted ended error gotPointerCapture input invalid keyDown keyPress keyUp load loadedData loadedMetadata loadStart lostPointerCapture mouseDown mouseMove mouseOut mouseOver mouseUp paste pause play playing pointerCancel pointerDown pointerMove pointerOut pointerOver pointerUp progress rateChange reset resize seeked seeking stalled submit suspend timeUpdate touchCancel touchEnd touchStart volumeChange scroll toggle touchMove waiting wheel".split(" ");function Is(i,u){G0.set(i,u),o(u,[i])}for(var cf=0;cf<K0.length;cf++){var uf=K0[cf],Y3=uf.toLowerCase(),X3=uf[0].toUpperCase()+uf.slice(1);Is(Y3,"on"+X3)}Is(z0,"onAnimationEnd"),Is(W0,"onAnimationIteration"),Is(H0,"onAnimationStart"),Is("dblclick","onDoubleClick"),Is("focusin","onFocus"),Is("focusout","onBlur"),Is(V0,"onTransitionEnd"),l("onMouseEnter",["mouseout","mouseover"]),l("onMouseLeave",["mouseout","mouseover"]),l("onPointerEnter",["pointerout","pointerover"]),l("onPointerLeave",["pointerout","pointerover"]),o("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),o("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),o("onBeforeInput",["compositionend","keypress","textInput","paste"]),o("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),o("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),o("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Qi="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(" "),Z3=new Set("cancel close invalid load scroll toggle".split(" ").concat(Qi));function Y0(i,u,m){var w=i.type||"unknown-event";i.currentTarget=m,tr(w,u,void 0,i),i.currentTarget=null}function X0(i,u){u=(u&4)!==0;for(var m=0;m<i.length;m++){var w=i[m],_=w.event;w=w.listeners;e:{var C=void 0;if(u)for(var z=w.length-1;0<=z;z--){var Q=w[z],te=Q.instance,ue=Q.currentTarget;if(Q=Q.listener,te!==C&&_.isPropagationStopped())break e;Y0(_,Q,ue),C=te}else for(z=0;z<w.length;z++){if(Q=w[z],te=Q.instance,ue=Q.currentTarget,Q=Q.listener,te!==C&&_.isPropagationStopped())break e;Y0(_,Q,ue),C=te}}}if(Er)throw i=Xr,Er=!1,Xr=null,i}function nt(i,u){var m=u[wf];m===void 0&&(m=u[wf]=new Set);var w=i+"__bubble";m.has(w)||(Z0(u,i,2,!1),m.add(w))}function df(i,u,m){var w=0;u&&(w|=4),Z0(m,i,w,u)}var qc="_reactListening"+Math.random().toString(36).slice(2);function el(i){if(!i[qc]){i[qc]=!0,r.forEach(function(m){m!=="selectionchange"&&(Z3.has(m)||df(m,!1,i),df(m,!0,i))});var u=i.nodeType===9?i:i.ownerDocument;u===null||u[qc]||(u[qc]=!0,df("selectionchange",!1,u))}}function Z0(i,u,m,w){switch(Wi(u)){case 1:var _=Lc;break;case 4:_=Pc;break;default:_=ba}m=_.bind(null,u,m,i),_=void 0,!wn||u!=="touchstart"&&u!=="touchmove"&&u!=="wheel"||(_=!0),w?_!==void 0?i.addEventListener(u,m,{capture:!0,passive:_}):i.addEventListener(u,m,!0):_!==void 0?i.addEventListener(u,m,{passive:_}):i.addEventListener(u,m,!1)}function hf(i,u,m,w,_){var C=w;if((u&1)===0&&(u&2)===0&&w!==null)e:for(;;){if(w===null)return;var z=w.tag;if(z===3||z===4){var Q=w.stateNode.containerInfo;if(Q===_||Q.nodeType===8&&Q.parentNode===_)break;if(z===4)for(z=w.return;z!==null;){var te=z.tag;if((te===3||te===4)&&(te=z.stateNode.containerInfo,te===_||te.nodeType===8&&te.parentNode===_))return;z=z.return}for(;Q!==null;){if(z=Sa(Q),z===null)return;if(te=z.tag,te===5||te===6){w=C=z;continue e}Q=Q.parentNode}}w=w.return}Yr(function(){var ue=C,xe=zt(m),ke=[];e:{var ve=G0.get(i);if(ve!==void 0){var Se=Vi,Ee=i;switch(i){case"keypress":if(ns(m)===0)break e;case"keydown":case"keyup":Se=E3;break;case"focusin":Ee="focus",Se=Qh;break;case"focusout":Ee="blur",Se=Qh;break;case"beforeblur":case"afterblur":Se=Qh;break;case"click":if(m.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Se=ko;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Se=ja;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Se=A3;break;case z0:case W0:case H0:Se=w3;break;case V0:Se=M3;break;case"scroll":Se=Zh;break;case"wheel":Se=I3;break;case"copy":case"cut":case"paste":Se=x3;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Se=S0}var Ce=(u&4)!==0,yt=!Ce&&i==="scroll",ie=Ce?ve!==null?ve+"Capture":null:ve;Ce=[];for(var re=ue,le;re!==null;){le=re;var je=le.stateNode;if(le.tag===5&&je!==null&&(le=je,ie!==null&&(je=Mn(re,ie),je!=null&&Ce.push(tl(re,je,le)))),yt)break;re=re.return}0<Ce.length&&(ve=new Se(ve,Ee,null,m,xe),ke.push({event:ve,listeners:Ce}))}}if((u&7)===0){e:{if(ve=i==="mouseover"||i==="pointerover",Se=i==="mouseout"||i==="pointerout",ve&&m!==wt&&(Ee=m.relatedTarget||m.fromElement)&&(Sa(Ee)||Ee[rs]))break e;if((Se||ve)&&(ve=xe.window===xe?xe:(ve=xe.ownerDocument)?ve.defaultView||ve.parentWindow:window,Se?(Ee=m.relatedTarget||m.toElement,Se=ue,Ee=Ee?Sa(Ee):null,Ee!==null&&(yt=nn(Ee),Ee!==yt||Ee.tag!==5&&Ee.tag!==6)&&(Ee=null)):(Se=null,Ee=ue),Se!==Ee)){if(Ce=ko,je="onMouseLeave",ie="onMouseEnter",re="mouse",(i==="pointerout"||i==="pointerover")&&(Ce=S0,je="onPointerLeave",ie="onPointerEnter",re="pointer"),yt=Se==null?ve:Co(Se),le=Ee==null?ve:Co(Ee),ve=new Ce(je,re+"leave",Se,m,xe),ve.target=yt,ve.relatedTarget=le,je=null,Sa(xe)===ue&&(Ce=new Ce(ie,re+"enter",Ee,m,xe),Ce.target=le,Ce.relatedTarget=yt,je=Ce),yt=je,Se&&Ee)t:{for(Ce=Se,ie=Ee,re=0,le=Ce;le;le=_o(le))re++;for(le=0,je=ie;je;je=_o(je))le++;for(;0<re-le;)Ce=_o(Ce),re--;for(;0<le-re;)ie=_o(ie),le--;for(;re--;){if(Ce===ie||ie!==null&&Ce===ie.alternate)break t;Ce=_o(Ce),ie=_o(ie)}Ce=null}else Ce=null;Se!==null&&J0(ke,ve,Se,Ce,!1),Ee!==null&&yt!==null&&J0(ke,yt,Ee,Ce,!0)}}e:{if(ve=ue?Co(ue):window,Se=ve.nodeName&&ve.nodeName.toLowerCase(),Se==="select"||Se==="input"&&ve.type==="file")var Te=q3;else if(R0(ve))if($0)Te=H3;else{Te=z3;var $e=U3}else(Se=ve.nodeName)&&Se.toLowerCase()==="input"&&(ve.type==="checkbox"||ve.type==="radio")&&(Te=W3);if(Te&&(Te=Te(i,ue))){M0(ke,Te,m,xe);break e}$e&&$e(i,ve,ue),i==="focusout"&&($e=ve._wrapperState)&&$e.controlled&&ve.type==="number"&&oe(ve,"number",ve.value)}switch($e=ue?Co(ue):window,i){case"focusin":(R0($e)||$e.contentEditable==="true")&&(jo=$e,af=ue,Ji=null);break;case"focusout":Ji=af=jo=null;break;case"mousedown":of=!0;break;case"contextmenu":case"mouseup":case"dragend":of=!1,q0(ke,m,xe);break;case"selectionchange":if(K3)break;case"keydown":case"keyup":q0(ke,m,xe)}var Ie;if(tf)e:{switch(i){case"compositionstart":var Oe="onCompositionStart";break e;case"compositionend":Oe="onCompositionEnd";break e;case"compositionupdate":Oe="onCompositionUpdate";break e}Oe=void 0}else No?T0(i,m)&&(Oe="onCompositionEnd"):i==="keydown"&&m.keyCode===229&&(Oe="onCompositionStart");Oe&&(_0&&m.locale!=="ko"&&(No||Oe!=="onCompositionStart"?Oe==="onCompositionEnd"&&No&&(Ie=vo()):(or=xe,Hi="value"in or?or.value:or.textContent,No=!0)),$e=Uc(ue,Oe),0<$e.length&&(Oe=new j0(Oe,i,null,m,xe),ke.push({event:Oe,listeners:$e}),Ie?Oe.data=Ie:(Ie=A0(m),Ie!==null&&(Oe.data=Ie)))),(Ie=L3?P3(i,m):D3(i,m))&&(ue=Uc(ue,"onBeforeInput"),0<ue.length&&(xe=new j0("onBeforeInput","beforeinput",null,m,xe),ke.push({event:xe,listeners:ue}),xe.data=Ie))}X0(ke,u)})}function tl(i,u,m){return{instance:i,listener:u,currentTarget:m}}function Uc(i,u){for(var m=u+"Capture",w=[];i!==null;){var _=i,C=_.stateNode;_.tag===5&&C!==null&&(_=C,C=Mn(i,m),C!=null&&w.unshift(tl(i,C,_)),C=Mn(i,u),C!=null&&w.push(tl(i,C,_))),i=i.return}return w}function _o(i){if(i===null)return null;do i=i.return;while(i&&i.tag!==5);return i||null}function J0(i,u,m,w,_){for(var C=u._reactName,z=[];m!==null&&m!==w;){var Q=m,te=Q.alternate,ue=Q.stateNode;if(te!==null&&te===w)break;Q.tag===5&&ue!==null&&(Q=ue,_?(te=Mn(m,C),te!=null&&z.unshift(tl(m,te,Q))):_||(te=Mn(m,C),te!=null&&z.push(tl(m,te,Q)))),m=m.return}z.length!==0&&i.push({event:u,listeners:z})}var J3=/\r\n?/g,Q3=/\u0000|\uFFFD/g;function Q0(i){return(typeof i=="string"?i:""+i).replace(J3,`
38
- `).replace(Q3,"")}function zc(i,u,m){if(u=Q0(u),Q0(i)!==u&&m)throw Error(n(425))}function Wc(){}var ff=null,pf=null;function mf(i,u){return i==="textarea"||i==="noscript"||typeof u.children=="string"||typeof u.children=="number"||typeof u.dangerouslySetInnerHTML=="object"&&u.dangerouslySetInnerHTML!==null&&u.dangerouslySetInnerHTML.__html!=null}var gf=typeof setTimeout=="function"?setTimeout:void 0,e4=typeof clearTimeout=="function"?clearTimeout:void 0,e1=typeof Promise=="function"?Promise:void 0,t4=typeof queueMicrotask=="function"?queueMicrotask:typeof e1<"u"?function(i){return e1.resolve(null).then(i).catch(n4)}:gf;function n4(i){setTimeout(function(){throw i})}function yf(i,u){var m=u,w=0;do{var _=m.nextSibling;if(i.removeChild(m),_&&_.nodeType===8)if(m=_.data,m==="/$"){if(w===0){i.removeChild(_),xn(u);return}w--}else m!=="$"&&m!=="$?"&&m!=="$!"||w++;m=_}while(m);xn(u)}function Os(i){for(;i!=null;i=i.nextSibling){var u=i.nodeType;if(u===1||u===3)break;if(u===8){if(u=i.data,u==="$"||u==="$!"||u==="$?")break;if(u==="/$")return null}}return i}function t1(i){i=i.previousSibling;for(var u=0;i;){if(i.nodeType===8){var m=i.data;if(m==="$"||m==="$!"||m==="$?"){if(u===0)return i;u--}else m==="/$"&&u++}i=i.previousSibling}return null}var Eo=Math.random().toString(36).slice(2),Or="__reactFiber$"+Eo,nl="__reactProps$"+Eo,rs="__reactContainer$"+Eo,wf="__reactEvents$"+Eo,r4="__reactListeners$"+Eo,s4="__reactHandles$"+Eo;function Sa(i){var u=i[Or];if(u)return u;for(var m=i.parentNode;m;){if(u=m[rs]||m[Or]){if(m=u.alternate,u.child!==null||m!==null&&m.child!==null)for(i=t1(i);i!==null;){if(m=i[Or])return m;i=t1(i)}return u}i=m,m=i.parentNode}return null}function rl(i){return i=i[Or]||i[rs],!i||i.tag!==5&&i.tag!==6&&i.tag!==13&&i.tag!==3?null:i}function Co(i){if(i.tag===5||i.tag===6)return i.stateNode;throw Error(n(33))}function Hc(i){return i[nl]||null}var vf=[],To=-1;function Ls(i){return{current:i}}function rt(i){0>To||(i.current=vf[To],vf[To]=null,To--)}function et(i,u){To++,vf[To]=i.current,i.current=u}var Ps={},Vt=Ls(Ps),on=Ls(!1),_a=Ps;function Ao(i,u){var m=i.type.contextTypes;if(!m)return Ps;var w=i.stateNode;if(w&&w.__reactInternalMemoizedUnmaskedChildContext===u)return w.__reactInternalMemoizedMaskedChildContext;var _={},C;for(C in m)_[C]=u[C];return w&&(i=i.stateNode,i.__reactInternalMemoizedUnmaskedChildContext=u,i.__reactInternalMemoizedMaskedChildContext=_),_}function ln(i){return i=i.childContextTypes,i!=null}function Vc(){rt(on),rt(Vt)}function n1(i,u,m){if(Vt.current!==Ps)throw Error(n(168));et(Vt,u),et(on,m)}function r1(i,u,m){var w=i.stateNode;if(u=u.childContextTypes,typeof w.getChildContext!="function")return m;w=w.getChildContext();for(var _ in w)if(!(_ in u))throw Error(n(108,X(i)||"Unknown",_));return H({},m,w)}function Gc(i){return i=(i=i.stateNode)&&i.__reactInternalMemoizedMergedChildContext||Ps,_a=Vt.current,et(Vt,i),et(on,on.current),!0}function s1(i,u,m){var w=i.stateNode;if(!w)throw Error(n(169));m?(i=r1(i,u,_a),w.__reactInternalMemoizedMergedChildContext=i,rt(on),rt(Vt),et(Vt,i)):rt(on),et(on,m)}var ss=null,Kc=!1,xf=!1;function a1(i){ss===null?ss=[i]:ss.push(i)}function a4(i){Kc=!0,a1(i)}function Ds(){if(!xf&&ss!==null){xf=!0;var i=0,u=Ue;try{var m=ss;for(Ue=1;i<m.length;i++){var w=m[i];do w=w(!0);while(w!==null)}ss=null,Kc=!1}catch(_){throw ss!==null&&(ss=ss.slice(i+1)),Ts(rn,Ds),_}finally{Ue=u,xf=!1}}return null}var Ro=[],Mo=0,Yc=null,Xc=0,Ln=[],Pn=0,Ea=null,as=1,os="";function Ca(i,u){Ro[Mo++]=Xc,Ro[Mo++]=Yc,Yc=i,Xc=u}function o1(i,u,m){Ln[Pn++]=as,Ln[Pn++]=os,Ln[Pn++]=Ea,Ea=i;var w=as;i=os;var _=32-an(w)-1;w&=~(1<<_),m+=1;var C=32-an(u)+_;if(30<C){var z=_-_%5;C=(w&(1<<z)-1).toString(32),w>>=z,_-=z,as=1<<32-an(u)+_|m<<_|w,os=C+i}else as=1<<C|m<<_|w,os=i}function bf(i){i.return!==null&&(Ca(i,1),o1(i,1,0))}function kf(i){for(;i===Yc;)Yc=Ro[--Mo],Ro[Mo]=null,Xc=Ro[--Mo],Ro[Mo]=null;for(;i===Ea;)Ea=Ln[--Pn],Ln[Pn]=null,os=Ln[--Pn],Ln[Pn]=null,as=Ln[--Pn],Ln[Pn]=null}var bn=null,kn=null,at=!1,cr=null;function i1(i,u){var m=qn(5,null,null,0);m.elementType="DELETED",m.stateNode=u,m.return=i,u=i.deletions,u===null?(i.deletions=[m],i.flags|=16):u.push(m)}function l1(i,u){switch(i.tag){case 5:var m=i.type;return u=u.nodeType!==1||m.toLowerCase()!==u.nodeName.toLowerCase()?null:u,u!==null?(i.stateNode=u,bn=i,kn=Os(u.firstChild),!0):!1;case 6:return u=i.pendingProps===""||u.nodeType!==3?null:u,u!==null?(i.stateNode=u,bn=i,kn=null,!0):!1;case 13:return u=u.nodeType!==8?null:u,u!==null?(m=Ea!==null?{id:as,overflow:os}:null,i.memoizedState={dehydrated:u,treeContext:m,retryLane:1073741824},m=qn(18,null,null,0),m.stateNode=u,m.return=i,i.child=m,bn=i,kn=null,!0):!1;default:return!1}}function Nf(i){return(i.mode&1)!==0&&(i.flags&128)===0}function jf(i){if(at){var u=kn;if(u){var m=u;if(!l1(i,u)){if(Nf(i))throw Error(n(418));u=Os(m.nextSibling);var w=bn;u&&l1(i,u)?i1(w,m):(i.flags=i.flags&-4097|2,at=!1,bn=i)}}else{if(Nf(i))throw Error(n(418));i.flags=i.flags&-4097|2,at=!1,bn=i}}}function c1(i){for(i=i.return;i!==null&&i.tag!==5&&i.tag!==3&&i.tag!==13;)i=i.return;bn=i}function Zc(i){if(i!==bn)return!1;if(!at)return c1(i),at=!0,!1;var u;if((u=i.tag!==3)&&!(u=i.tag!==5)&&(u=i.type,u=u!=="head"&&u!=="body"&&!mf(i.type,i.memoizedProps)),u&&(u=kn)){if(Nf(i))throw u1(),Error(n(418));for(;u;)i1(i,u),u=Os(u.nextSibling)}if(c1(i),i.tag===13){if(i=i.memoizedState,i=i!==null?i.dehydrated:null,!i)throw Error(n(317));e:{for(i=i.nextSibling,u=0;i;){if(i.nodeType===8){var m=i.data;if(m==="/$"){if(u===0){kn=Os(i.nextSibling);break e}u--}else m!=="$"&&m!=="$!"&&m!=="$?"||u++}i=i.nextSibling}kn=null}}else kn=bn?Os(i.stateNode.nextSibling):null;return!0}function u1(){for(var i=kn;i;)i=Os(i.nextSibling)}function $o(){kn=bn=null,at=!1}function Sf(i){cr===null?cr=[i]:cr.push(i)}var o4=E.ReactCurrentBatchConfig;function sl(i,u,m){if(i=m.ref,i!==null&&typeof i!="function"&&typeof i!="object"){if(m._owner){if(m=m._owner,m){if(m.tag!==1)throw Error(n(309));var w=m.stateNode}if(!w)throw Error(n(147,i));var _=w,C=""+i;return u!==null&&u.ref!==null&&typeof u.ref=="function"&&u.ref._stringRef===C?u.ref:(u=function(z){var Q=_.refs;z===null?delete Q[C]:Q[C]=z},u._stringRef=C,u)}if(typeof i!="string")throw Error(n(284));if(!m._owner)throw Error(n(290,i))}return i}function Jc(i,u){throw i=Object.prototype.toString.call(u),Error(n(31,i==="[object Object]"?"object with keys {"+Object.keys(u).join(", ")+"}":i))}function d1(i){var u=i._init;return u(i._payload)}function h1(i){function u(ie,re){if(i){var le=ie.deletions;le===null?(ie.deletions=[re],ie.flags|=16):le.push(re)}}function m(ie,re){if(!i)return null;for(;re!==null;)u(ie,re),re=re.sibling;return null}function w(ie,re){for(ie=new Map;re!==null;)re.key!==null?ie.set(re.key,re):ie.set(re.index,re),re=re.sibling;return ie}function _(ie,re){return ie=Vs(ie,re),ie.index=0,ie.sibling=null,ie}function C(ie,re,le){return ie.index=le,i?(le=ie.alternate,le!==null?(le=le.index,le<re?(ie.flags|=2,re):le):(ie.flags|=2,re)):(ie.flags|=1048576,re)}function z(ie){return i&&ie.alternate===null&&(ie.flags|=2),ie}function Q(ie,re,le,je){return re===null||re.tag!==6?(re=gp(le,ie.mode,je),re.return=ie,re):(re=_(re,le),re.return=ie,re)}function te(ie,re,le,je){var Te=le.type;return Te===A?xe(ie,re,le.props.children,je,le.key):re!==null&&(re.elementType===Te||typeof Te=="object"&&Te!==null&&Te.$$typeof===O&&d1(Te)===re.type)?(je=_(re,le.props),je.ref=sl(ie,re,le),je.return=ie,je):(je=ku(le.type,le.key,le.props,null,ie.mode,je),je.ref=sl(ie,re,le),je.return=ie,je)}function ue(ie,re,le,je){return re===null||re.tag!==4||re.stateNode.containerInfo!==le.containerInfo||re.stateNode.implementation!==le.implementation?(re=yp(le,ie.mode,je),re.return=ie,re):(re=_(re,le.children||[]),re.return=ie,re)}function xe(ie,re,le,je,Te){return re===null||re.tag!==7?(re=La(le,ie.mode,je,Te),re.return=ie,re):(re=_(re,le),re.return=ie,re)}function ke(ie,re,le){if(typeof re=="string"&&re!==""||typeof re=="number")return re=gp(""+re,ie.mode,le),re.return=ie,re;if(typeof re=="object"&&re!==null){switch(re.$$typeof){case R:return le=ku(re.type,re.key,re.props,null,ie.mode,le),le.ref=sl(ie,null,re),le.return=ie,le;case I:return re=yp(re,ie.mode,le),re.return=ie,re;case O:var je=re._init;return ke(ie,je(re._payload),le)}if(Ne(re)||U(re))return re=La(re,ie.mode,le,null),re.return=ie,re;Jc(ie,re)}return null}function ve(ie,re,le,je){var Te=re!==null?re.key:null;if(typeof le=="string"&&le!==""||typeof le=="number")return Te!==null?null:Q(ie,re,""+le,je);if(typeof le=="object"&&le!==null){switch(le.$$typeof){case R:return le.key===Te?te(ie,re,le,je):null;case I:return le.key===Te?ue(ie,re,le,je):null;case O:return Te=le._init,ve(ie,re,Te(le._payload),je)}if(Ne(le)||U(le))return Te!==null?null:xe(ie,re,le,je,null);Jc(ie,le)}return null}function Se(ie,re,le,je,Te){if(typeof je=="string"&&je!==""||typeof je=="number")return ie=ie.get(le)||null,Q(re,ie,""+je,Te);if(typeof je=="object"&&je!==null){switch(je.$$typeof){case R:return ie=ie.get(je.key===null?le:je.key)||null,te(re,ie,je,Te);case I:return ie=ie.get(je.key===null?le:je.key)||null,ue(re,ie,je,Te);case O:var $e=je._init;return Se(ie,re,le,$e(je._payload),Te)}if(Ne(je)||U(je))return ie=ie.get(le)||null,xe(re,ie,je,Te,null);Jc(re,je)}return null}function Ee(ie,re,le,je){for(var Te=null,$e=null,Ie=re,Oe=re=0,Ot=null;Ie!==null&&Oe<le.length;Oe++){Ie.index>Oe?(Ot=Ie,Ie=null):Ot=Ie.sibling;var Ke=ve(ie,Ie,le[Oe],je);if(Ke===null){Ie===null&&(Ie=Ot);break}i&&Ie&&Ke.alternate===null&&u(ie,Ie),re=C(Ke,re,Oe),$e===null?Te=Ke:$e.sibling=Ke,$e=Ke,Ie=Ot}if(Oe===le.length)return m(ie,Ie),at&&Ca(ie,Oe),Te;if(Ie===null){for(;Oe<le.length;Oe++)Ie=ke(ie,le[Oe],je),Ie!==null&&(re=C(Ie,re,Oe),$e===null?Te=Ie:$e.sibling=Ie,$e=Ie);return at&&Ca(ie,Oe),Te}for(Ie=w(ie,Ie);Oe<le.length;Oe++)Ot=Se(Ie,ie,Oe,le[Oe],je),Ot!==null&&(i&&Ot.alternate!==null&&Ie.delete(Ot.key===null?Oe:Ot.key),re=C(Ot,re,Oe),$e===null?Te=Ot:$e.sibling=Ot,$e=Ot);return i&&Ie.forEach(function(Gs){return u(ie,Gs)}),at&&Ca(ie,Oe),Te}function Ce(ie,re,le,je){var Te=U(le);if(typeof Te!="function")throw Error(n(150));if(le=Te.call(le),le==null)throw Error(n(151));for(var $e=Te=null,Ie=re,Oe=re=0,Ot=null,Ke=le.next();Ie!==null&&!Ke.done;Oe++,Ke=le.next()){Ie.index>Oe?(Ot=Ie,Ie=null):Ot=Ie.sibling;var Gs=ve(ie,Ie,Ke.value,je);if(Gs===null){Ie===null&&(Ie=Ot);break}i&&Ie&&Gs.alternate===null&&u(ie,Ie),re=C(Gs,re,Oe),$e===null?Te=Gs:$e.sibling=Gs,$e=Gs,Ie=Ot}if(Ke.done)return m(ie,Ie),at&&Ca(ie,Oe),Te;if(Ie===null){for(;!Ke.done;Oe++,Ke=le.next())Ke=ke(ie,Ke.value,je),Ke!==null&&(re=C(Ke,re,Oe),$e===null?Te=Ke:$e.sibling=Ke,$e=Ke);return at&&Ca(ie,Oe),Te}for(Ie=w(ie,Ie);!Ke.done;Oe++,Ke=le.next())Ke=Se(Ie,ie,Oe,Ke.value,je),Ke!==null&&(i&&Ke.alternate!==null&&Ie.delete(Ke.key===null?Oe:Ke.key),re=C(Ke,re,Oe),$e===null?Te=Ke:$e.sibling=Ke,$e=Ke);return i&&Ie.forEach(function(F4){return u(ie,F4)}),at&&Ca(ie,Oe),Te}function yt(ie,re,le,je){if(typeof le=="object"&&le!==null&&le.type===A&&le.key===null&&(le=le.props.children),typeof le=="object"&&le!==null){switch(le.$$typeof){case R:e:{for(var Te=le.key,$e=re;$e!==null;){if($e.key===Te){if(Te=le.type,Te===A){if($e.tag===7){m(ie,$e.sibling),re=_($e,le.props.children),re.return=ie,ie=re;break e}}else if($e.elementType===Te||typeof Te=="object"&&Te!==null&&Te.$$typeof===O&&d1(Te)===$e.type){m(ie,$e.sibling),re=_($e,le.props),re.ref=sl(ie,$e,le),re.return=ie,ie=re;break e}m(ie,$e);break}else u(ie,$e);$e=$e.sibling}le.type===A?(re=La(le.props.children,ie.mode,je,le.key),re.return=ie,ie=re):(je=ku(le.type,le.key,le.props,null,ie.mode,je),je.ref=sl(ie,re,le),je.return=ie,ie=je)}return z(ie);case I:e:{for($e=le.key;re!==null;){if(re.key===$e)if(re.tag===4&&re.stateNode.containerInfo===le.containerInfo&&re.stateNode.implementation===le.implementation){m(ie,re.sibling),re=_(re,le.children||[]),re.return=ie,ie=re;break e}else{m(ie,re);break}else u(ie,re);re=re.sibling}re=yp(le,ie.mode,je),re.return=ie,ie=re}return z(ie);case O:return $e=le._init,yt(ie,re,$e(le._payload),je)}if(Ne(le))return Ee(ie,re,le,je);if(U(le))return Ce(ie,re,le,je);Jc(ie,le)}return typeof le=="string"&&le!==""||typeof le=="number"?(le=""+le,re!==null&&re.tag===6?(m(ie,re.sibling),re=_(re,le),re.return=ie,ie=re):(m(ie,re),re=gp(le,ie.mode,je),re.return=ie,ie=re),z(ie)):m(ie,re)}return yt}var Io=h1(!0),f1=h1(!1),Qc=Ls(null),eu=null,Oo=null,_f=null;function Ef(){_f=Oo=eu=null}function Cf(i){var u=Qc.current;rt(Qc),i._currentValue=u}function Tf(i,u,m){for(;i!==null;){var w=i.alternate;if((i.childLanes&u)!==u?(i.childLanes|=u,w!==null&&(w.childLanes|=u)):w!==null&&(w.childLanes&u)!==u&&(w.childLanes|=u),i===m)break;i=i.return}}function Lo(i,u){eu=i,_f=Oo=null,i=i.dependencies,i!==null&&i.firstContext!==null&&((i.lanes&u)!==0&&(cn=!0),i.firstContext=null)}function Dn(i){var u=i._currentValue;if(_f!==i)if(i={context:i,memoizedValue:u,next:null},Oo===null){if(eu===null)throw Error(n(308));Oo=i,eu.dependencies={lanes:0,firstContext:i}}else Oo=Oo.next=i;return u}var Ta=null;function Af(i){Ta===null?Ta=[i]:Ta.push(i)}function p1(i,u,m,w){var _=u.interleaved;return _===null?(m.next=m,Af(u)):(m.next=_.next,_.next=m),u.interleaved=m,is(i,w)}function is(i,u){i.lanes|=u;var m=i.alternate;for(m!==null&&(m.lanes|=u),m=i,i=i.return;i!==null;)i.childLanes|=u,m=i.alternate,m!==null&&(m.childLanes|=u),m=i,i=i.return;return m.tag===3?m.stateNode:null}var Fs=!1;function Rf(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function m1(i,u){i=i.updateQueue,u.updateQueue===i&&(u.updateQueue={baseState:i.baseState,firstBaseUpdate:i.firstBaseUpdate,lastBaseUpdate:i.lastBaseUpdate,shared:i.shared,effects:i.effects})}function ls(i,u){return{eventTime:i,lane:u,tag:0,payload:null,callback:null,next:null}}function Bs(i,u,m){var w=i.updateQueue;if(w===null)return null;if(w=w.shared,(Ve&2)!==0){var _=w.pending;return _===null?u.next=u:(u.next=_.next,_.next=u),w.pending=u,is(i,m)}return _=w.interleaved,_===null?(u.next=u,Af(w)):(u.next=_.next,_.next=u),w.interleaved=u,is(i,m)}function tu(i,u,m){if(u=u.updateQueue,u!==null&&(u=u.shared,(m&4194240)!==0)){var w=u.lanes;w&=i.pendingLanes,m|=w,u.lanes=m,fo(i,m)}}function g1(i,u){var m=i.updateQueue,w=i.alternate;if(w!==null&&(w=w.updateQueue,m===w)){var _=null,C=null;if(m=m.firstBaseUpdate,m!==null){do{var z={eventTime:m.eventTime,lane:m.lane,tag:m.tag,payload:m.payload,callback:m.callback,next:null};C===null?_=C=z:C=C.next=z,m=m.next}while(m!==null);C===null?_=C=u:C=C.next=u}else _=C=u;m={baseState:w.baseState,firstBaseUpdate:_,lastBaseUpdate:C,shared:w.shared,effects:w.effects},i.updateQueue=m;return}i=m.lastBaseUpdate,i===null?m.firstBaseUpdate=u:i.next=u,m.lastBaseUpdate=u}function nu(i,u,m,w){var _=i.updateQueue;Fs=!1;var C=_.firstBaseUpdate,z=_.lastBaseUpdate,Q=_.shared.pending;if(Q!==null){_.shared.pending=null;var te=Q,ue=te.next;te.next=null,z===null?C=ue:z.next=ue,z=te;var xe=i.alternate;xe!==null&&(xe=xe.updateQueue,Q=xe.lastBaseUpdate,Q!==z&&(Q===null?xe.firstBaseUpdate=ue:Q.next=ue,xe.lastBaseUpdate=te))}if(C!==null){var ke=_.baseState;z=0,xe=ue=te=null,Q=C;do{var ve=Q.lane,Se=Q.eventTime;if((w&ve)===ve){xe!==null&&(xe=xe.next={eventTime:Se,lane:0,tag:Q.tag,payload:Q.payload,callback:Q.callback,next:null});e:{var Ee=i,Ce=Q;switch(ve=u,Se=m,Ce.tag){case 1:if(Ee=Ce.payload,typeof Ee=="function"){ke=Ee.call(Se,ke,ve);break e}ke=Ee;break e;case 3:Ee.flags=Ee.flags&-65537|128;case 0:if(Ee=Ce.payload,ve=typeof Ee=="function"?Ee.call(Se,ke,ve):Ee,ve==null)break e;ke=H({},ke,ve);break e;case 2:Fs=!0}}Q.callback!==null&&Q.lane!==0&&(i.flags|=64,ve=_.effects,ve===null?_.effects=[Q]:ve.push(Q))}else Se={eventTime:Se,lane:ve,tag:Q.tag,payload:Q.payload,callback:Q.callback,next:null},xe===null?(ue=xe=Se,te=ke):xe=xe.next=Se,z|=ve;if(Q=Q.next,Q===null){if(Q=_.shared.pending,Q===null)break;ve=Q,Q=ve.next,ve.next=null,_.lastBaseUpdate=ve,_.shared.pending=null}}while(!0);if(xe===null&&(te=ke),_.baseState=te,_.firstBaseUpdate=ue,_.lastBaseUpdate=xe,u=_.shared.interleaved,u!==null){_=u;do z|=_.lane,_=_.next;while(_!==u)}else C===null&&(_.shared.lanes=0);Ma|=z,i.lanes=z,i.memoizedState=ke}}function y1(i,u,m){if(i=u.effects,u.effects=null,i!==null)for(u=0;u<i.length;u++){var w=i[u],_=w.callback;if(_!==null){if(w.callback=null,w=m,typeof _!="function")throw Error(n(191,_));_.call(w)}}}var al={},Lr=Ls(al),ol=Ls(al),il=Ls(al);function Aa(i){if(i===al)throw Error(n(174));return i}function Mf(i,u){switch(et(il,u),et(ol,i),et(Lr,al),i=u.nodeType,i){case 9:case 11:u=(u=u.documentElement)?u.namespaceURI:qe(null,"");break;default:i=i===8?u.parentNode:u,u=i.namespaceURI||null,i=i.tagName,u=qe(u,i)}rt(Lr),et(Lr,u)}function Po(){rt(Lr),rt(ol),rt(il)}function w1(i){Aa(il.current);var u=Aa(Lr.current),m=qe(u,i.type);u!==m&&(et(ol,i),et(Lr,m))}function $f(i){ol.current===i&&(rt(Lr),rt(ol))}var ut=Ls(0);function ru(i){for(var u=i;u!==null;){if(u.tag===13){var m=u.memoizedState;if(m!==null&&(m=m.dehydrated,m===null||m.data==="$?"||m.data==="$!"))return u}else if(u.tag===19&&u.memoizedProps.revealOrder!==void 0){if((u.flags&128)!==0)return u}else if(u.child!==null){u.child.return=u,u=u.child;continue}if(u===i)break;for(;u.sibling===null;){if(u.return===null||u.return===i)return null;u=u.return}u.sibling.return=u.return,u=u.sibling}return null}var If=[];function Of(){for(var i=0;i<If.length;i++)If[i]._workInProgressVersionPrimary=null;If.length=0}var su=E.ReactCurrentDispatcher,Lf=E.ReactCurrentBatchConfig,Ra=0,dt=null,St=null,$t=null,au=!1,ll=!1,cl=0,i4=0;function Gt(){throw Error(n(321))}function Pf(i,u){if(u===null)return!1;for(var m=0;m<u.length&&m<i.length;m++)if(!lr(i[m],u[m]))return!1;return!0}function Df(i,u,m,w,_,C){if(Ra=C,dt=u,u.memoizedState=null,u.updateQueue=null,u.lanes=0,su.current=i===null||i.memoizedState===null?d4:h4,i=m(w,_),ll){C=0;do{if(ll=!1,cl=0,25<=C)throw Error(n(301));C+=1,$t=St=null,u.updateQueue=null,su.current=f4,i=m(w,_)}while(ll)}if(su.current=lu,u=St!==null&&St.next!==null,Ra=0,$t=St=dt=null,au=!1,u)throw Error(n(300));return i}function Ff(){var i=cl!==0;return cl=0,i}function Pr(){var i={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return $t===null?dt.memoizedState=$t=i:$t=$t.next=i,$t}function Fn(){if(St===null){var i=dt.alternate;i=i!==null?i.memoizedState:null}else i=St.next;var u=$t===null?dt.memoizedState:$t.next;if(u!==null)$t=u,St=i;else{if(i===null)throw Error(n(310));St=i,i={memoizedState:St.memoizedState,baseState:St.baseState,baseQueue:St.baseQueue,queue:St.queue,next:null},$t===null?dt.memoizedState=$t=i:$t=$t.next=i}return $t}function ul(i,u){return typeof u=="function"?u(i):u}function Bf(i){var u=Fn(),m=u.queue;if(m===null)throw Error(n(311));m.lastRenderedReducer=i;var w=St,_=w.baseQueue,C=m.pending;if(C!==null){if(_!==null){var z=_.next;_.next=C.next,C.next=z}w.baseQueue=_=C,m.pending=null}if(_!==null){C=_.next,w=w.baseState;var Q=z=null,te=null,ue=C;do{var xe=ue.lane;if((Ra&xe)===xe)te!==null&&(te=te.next={lane:0,action:ue.action,hasEagerState:ue.hasEagerState,eagerState:ue.eagerState,next:null}),w=ue.hasEagerState?ue.eagerState:i(w,ue.action);else{var ke={lane:xe,action:ue.action,hasEagerState:ue.hasEagerState,eagerState:ue.eagerState,next:null};te===null?(Q=te=ke,z=w):te=te.next=ke,dt.lanes|=xe,Ma|=xe}ue=ue.next}while(ue!==null&&ue!==C);te===null?z=w:te.next=Q,lr(w,u.memoizedState)||(cn=!0),u.memoizedState=w,u.baseState=z,u.baseQueue=te,m.lastRenderedState=w}if(i=m.interleaved,i!==null){_=i;do C=_.lane,dt.lanes|=C,Ma|=C,_=_.next;while(_!==i)}else _===null&&(m.lanes=0);return[u.memoizedState,m.dispatch]}function qf(i){var u=Fn(),m=u.queue;if(m===null)throw Error(n(311));m.lastRenderedReducer=i;var w=m.dispatch,_=m.pending,C=u.memoizedState;if(_!==null){m.pending=null;var z=_=_.next;do C=i(C,z.action),z=z.next;while(z!==_);lr(C,u.memoizedState)||(cn=!0),u.memoizedState=C,u.baseQueue===null&&(u.baseState=C),m.lastRenderedState=C}return[C,w]}function v1(){}function x1(i,u){var m=dt,w=Fn(),_=u(),C=!lr(w.memoizedState,_);if(C&&(w.memoizedState=_,cn=!0),w=w.queue,Uf(N1.bind(null,m,w,i),[i]),w.getSnapshot!==u||C||$t!==null&&$t.memoizedState.tag&1){if(m.flags|=2048,dl(9,k1.bind(null,m,w,_,u),void 0,null),It===null)throw Error(n(349));(Ra&30)!==0||b1(m,u,_)}return _}function b1(i,u,m){i.flags|=16384,i={getSnapshot:u,value:m},u=dt.updateQueue,u===null?(u={lastEffect:null,stores:null},dt.updateQueue=u,u.stores=[i]):(m=u.stores,m===null?u.stores=[i]:m.push(i))}function k1(i,u,m,w){u.value=m,u.getSnapshot=w,j1(u)&&S1(i)}function N1(i,u,m){return m(function(){j1(u)&&S1(i)})}function j1(i){var u=i.getSnapshot;i=i.value;try{var m=u();return!lr(i,m)}catch{return!0}}function S1(i){var u=is(i,1);u!==null&&fr(u,i,1,-1)}function _1(i){var u=Pr();return typeof i=="function"&&(i=i()),u.memoizedState=u.baseState=i,i={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:ul,lastRenderedState:i},u.queue=i,i=i.dispatch=u4.bind(null,dt,i),[u.memoizedState,i]}function dl(i,u,m,w){return i={tag:i,create:u,destroy:m,deps:w,next:null},u=dt.updateQueue,u===null?(u={lastEffect:null,stores:null},dt.updateQueue=u,u.lastEffect=i.next=i):(m=u.lastEffect,m===null?u.lastEffect=i.next=i:(w=m.next,m.next=i,i.next=w,u.lastEffect=i)),i}function E1(){return Fn().memoizedState}function ou(i,u,m,w){var _=Pr();dt.flags|=i,_.memoizedState=dl(1|u,m,void 0,w===void 0?null:w)}function iu(i,u,m,w){var _=Fn();w=w===void 0?null:w;var C=void 0;if(St!==null){var z=St.memoizedState;if(C=z.destroy,w!==null&&Pf(w,z.deps)){_.memoizedState=dl(u,m,C,w);return}}dt.flags|=i,_.memoizedState=dl(1|u,m,C,w)}function C1(i,u){return ou(8390656,8,i,u)}function Uf(i,u){return iu(2048,8,i,u)}function T1(i,u){return iu(4,2,i,u)}function A1(i,u){return iu(4,4,i,u)}function R1(i,u){if(typeof u=="function")return i=i(),u(i),function(){u(null)};if(u!=null)return i=i(),u.current=i,function(){u.current=null}}function M1(i,u,m){return m=m!=null?m.concat([i]):null,iu(4,4,R1.bind(null,u,i),m)}function zf(){}function $1(i,u){var m=Fn();u=u===void 0?null:u;var w=m.memoizedState;return w!==null&&u!==null&&Pf(u,w[1])?w[0]:(m.memoizedState=[i,u],i)}function I1(i,u){var m=Fn();u=u===void 0?null:u;var w=m.memoizedState;return w!==null&&u!==null&&Pf(u,w[1])?w[0]:(i=i(),m.memoizedState=[i,u],i)}function O1(i,u,m){return(Ra&21)===0?(i.baseState&&(i.baseState=!1,cn=!0),i.memoizedState=m):(lr(m,u)||(m=Rr(),dt.lanes|=m,Ma|=m,i.baseState=!0),u)}function l4(i,u){var m=Ue;Ue=m!==0&&4>m?m:4,i(!0);var w=Lf.transition;Lf.transition={};try{i(!1),u()}finally{Ue=m,Lf.transition=w}}function L1(){return Fn().memoizedState}function c4(i,u,m){var w=Ws(i);if(m={lane:w,action:m,hasEagerState:!1,eagerState:null,next:null},P1(i))D1(u,m);else if(m=p1(i,u,m,w),m!==null){var _=Jt();fr(m,i,w,_),F1(m,u,w)}}function u4(i,u,m){var w=Ws(i),_={lane:w,action:m,hasEagerState:!1,eagerState:null,next:null};if(P1(i))D1(u,_);else{var C=i.alternate;if(i.lanes===0&&(C===null||C.lanes===0)&&(C=u.lastRenderedReducer,C!==null))try{var z=u.lastRenderedState,Q=C(z,m);if(_.hasEagerState=!0,_.eagerState=Q,lr(Q,z)){var te=u.interleaved;te===null?(_.next=_,Af(u)):(_.next=te.next,te.next=_),u.interleaved=_;return}}catch{}finally{}m=p1(i,u,_,w),m!==null&&(_=Jt(),fr(m,i,w,_),F1(m,u,w))}}function P1(i){var u=i.alternate;return i===dt||u!==null&&u===dt}function D1(i,u){ll=au=!0;var m=i.pending;m===null?u.next=u:(u.next=m.next,m.next=u),i.pending=u}function F1(i,u,m){if((m&4194240)!==0){var w=u.lanes;w&=i.pendingLanes,m|=w,u.lanes=m,fo(i,m)}}var lu={readContext:Dn,useCallback:Gt,useContext:Gt,useEffect:Gt,useImperativeHandle:Gt,useInsertionEffect:Gt,useLayoutEffect:Gt,useMemo:Gt,useReducer:Gt,useRef:Gt,useState:Gt,useDebugValue:Gt,useDeferredValue:Gt,useTransition:Gt,useMutableSource:Gt,useSyncExternalStore:Gt,useId:Gt,unstable_isNewReconciler:!1},d4={readContext:Dn,useCallback:function(i,u){return Pr().memoizedState=[i,u===void 0?null:u],i},useContext:Dn,useEffect:C1,useImperativeHandle:function(i,u,m){return m=m!=null?m.concat([i]):null,ou(4194308,4,R1.bind(null,u,i),m)},useLayoutEffect:function(i,u){return ou(4194308,4,i,u)},useInsertionEffect:function(i,u){return ou(4,2,i,u)},useMemo:function(i,u){var m=Pr();return u=u===void 0?null:u,i=i(),m.memoizedState=[i,u],i},useReducer:function(i,u,m){var w=Pr();return u=m!==void 0?m(u):u,w.memoizedState=w.baseState=u,i={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:i,lastRenderedState:u},w.queue=i,i=i.dispatch=c4.bind(null,dt,i),[w.memoizedState,i]},useRef:function(i){var u=Pr();return i={current:i},u.memoizedState=i},useState:_1,useDebugValue:zf,useDeferredValue:function(i){return Pr().memoizedState=i},useTransition:function(){var i=_1(!1),u=i[0];return i=l4.bind(null,i[1]),Pr().memoizedState=i,[u,i]},useMutableSource:function(){},useSyncExternalStore:function(i,u,m){var w=dt,_=Pr();if(at){if(m===void 0)throw Error(n(407));m=m()}else{if(m=u(),It===null)throw Error(n(349));(Ra&30)!==0||b1(w,u,m)}_.memoizedState=m;var C={value:m,getSnapshot:u};return _.queue=C,C1(N1.bind(null,w,C,i),[i]),w.flags|=2048,dl(9,k1.bind(null,w,C,m,u),void 0,null),m},useId:function(){var i=Pr(),u=It.identifierPrefix;if(at){var m=os,w=as;m=(w&~(1<<32-an(w)-1)).toString(32)+m,u=":"+u+"R"+m,m=cl++,0<m&&(u+="H"+m.toString(32)),u+=":"}else m=i4++,u=":"+u+"r"+m.toString(32)+":";return i.memoizedState=u},unstable_isNewReconciler:!1},h4={readContext:Dn,useCallback:$1,useContext:Dn,useEffect:Uf,useImperativeHandle:M1,useInsertionEffect:T1,useLayoutEffect:A1,useMemo:I1,useReducer:Bf,useRef:E1,useState:function(){return Bf(ul)},useDebugValue:zf,useDeferredValue:function(i){var u=Fn();return O1(u,St.memoizedState,i)},useTransition:function(){var i=Bf(ul)[0],u=Fn().memoizedState;return[i,u]},useMutableSource:v1,useSyncExternalStore:x1,useId:L1,unstable_isNewReconciler:!1},f4={readContext:Dn,useCallback:$1,useContext:Dn,useEffect:Uf,useImperativeHandle:M1,useInsertionEffect:T1,useLayoutEffect:A1,useMemo:I1,useReducer:qf,useRef:E1,useState:function(){return qf(ul)},useDebugValue:zf,useDeferredValue:function(i){var u=Fn();return St===null?u.memoizedState=i:O1(u,St.memoizedState,i)},useTransition:function(){var i=qf(ul)[0],u=Fn().memoizedState;return[i,u]},useMutableSource:v1,useSyncExternalStore:x1,useId:L1,unstable_isNewReconciler:!1};function ur(i,u){if(i&&i.defaultProps){u=H({},u),i=i.defaultProps;for(var m in i)u[m]===void 0&&(u[m]=i[m]);return u}return u}function Wf(i,u,m,w){u=i.memoizedState,m=m(w,u),m=m==null?u:H({},u,m),i.memoizedState=m,i.lanes===0&&(i.updateQueue.baseState=m)}var cu={isMounted:function(i){return(i=i._reactInternals)?nn(i)===i:!1},enqueueSetState:function(i,u,m){i=i._reactInternals;var w=Jt(),_=Ws(i),C=ls(w,_);C.payload=u,m!=null&&(C.callback=m),u=Bs(i,C,_),u!==null&&(fr(u,i,_,w),tu(u,i,_))},enqueueReplaceState:function(i,u,m){i=i._reactInternals;var w=Jt(),_=Ws(i),C=ls(w,_);C.tag=1,C.payload=u,m!=null&&(C.callback=m),u=Bs(i,C,_),u!==null&&(fr(u,i,_,w),tu(u,i,_))},enqueueForceUpdate:function(i,u){i=i._reactInternals;var m=Jt(),w=Ws(i),_=ls(m,w);_.tag=2,u!=null&&(_.callback=u),u=Bs(i,_,w),u!==null&&(fr(u,i,w,m),tu(u,i,w))}};function B1(i,u,m,w,_,C,z){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(w,C,z):u.prototype&&u.prototype.isPureReactComponent?!Zi(m,w)||!Zi(_,C):!0}function q1(i,u,m){var w=!1,_=Ps,C=u.contextType;return typeof C=="object"&&C!==null?C=Dn(C):(_=ln(u)?_a:Vt.current,w=u.contextTypes,C=(w=w!=null)?Ao(i,_):Ps),u=new u(m,C),i.memoizedState=u.state!==null&&u.state!==void 0?u.state:null,u.updater=cu,i.stateNode=u,u._reactInternals=i,w&&(i=i.stateNode,i.__reactInternalMemoizedUnmaskedChildContext=_,i.__reactInternalMemoizedMaskedChildContext=C),u}function U1(i,u,m,w){i=u.state,typeof u.componentWillReceiveProps=="function"&&u.componentWillReceiveProps(m,w),typeof u.UNSAFE_componentWillReceiveProps=="function"&&u.UNSAFE_componentWillReceiveProps(m,w),u.state!==i&&cu.enqueueReplaceState(u,u.state,null)}function Hf(i,u,m,w){var _=i.stateNode;_.props=m,_.state=i.memoizedState,_.refs={},Rf(i);var C=u.contextType;typeof C=="object"&&C!==null?_.context=Dn(C):(C=ln(u)?_a:Vt.current,_.context=Ao(i,C)),_.state=i.memoizedState,C=u.getDerivedStateFromProps,typeof C=="function"&&(Wf(i,u,C,m),_.state=i.memoizedState),typeof u.getDerivedStateFromProps=="function"||typeof _.getSnapshotBeforeUpdate=="function"||typeof _.UNSAFE_componentWillMount!="function"&&typeof _.componentWillMount!="function"||(u=_.state,typeof _.componentWillMount=="function"&&_.componentWillMount(),typeof _.UNSAFE_componentWillMount=="function"&&_.UNSAFE_componentWillMount(),u!==_.state&&cu.enqueueReplaceState(_,_.state,null),nu(i,m,_,w),_.state=i.memoizedState),typeof _.componentDidMount=="function"&&(i.flags|=4194308)}function Do(i,u){try{var m="",w=u;do m+=Z(w),w=w.return;while(w);var _=m}catch(C){_=`
39
- Error generating stack: `+C.message+`
40
- `+C.stack}return{value:i,source:u,stack:_,digest:null}}function Vf(i,u,m){return{value:i,source:null,stack:m??null,digest:u??null}}function Gf(i,u){try{console.error(u.value)}catch(m){setTimeout(function(){throw m})}}var p4=typeof WeakMap=="function"?WeakMap:Map;function z1(i,u,m){m=ls(-1,m),m.tag=3,m.payload={element:null};var w=u.value;return m.callback=function(){gu||(gu=!0,lp=w),Gf(i,u)},m}function W1(i,u,m){m=ls(-1,m),m.tag=3;var w=i.type.getDerivedStateFromError;if(typeof w=="function"){var _=u.value;m.payload=function(){return w(_)},m.callback=function(){Gf(i,u)}}var C=i.stateNode;return C!==null&&typeof C.componentDidCatch=="function"&&(m.callback=function(){Gf(i,u),typeof w!="function"&&(Us===null?Us=new Set([this]):Us.add(this));var z=u.stack;this.componentDidCatch(u.value,{componentStack:z!==null?z:""})}),m}function H1(i,u,m){var w=i.pingCache;if(w===null){w=i.pingCache=new p4;var _=new Set;w.set(u,_)}else _=w.get(u),_===void 0&&(_=new Set,w.set(u,_));_.has(m)||(_.add(m),i=C4.bind(null,i,u,m),u.then(i,i))}function V1(i){do{var u;if((u=i.tag===13)&&(u=i.memoizedState,u=u!==null?u.dehydrated!==null:!0),u)return i;i=i.return}while(i!==null);return null}function G1(i,u,m,w,_){return(i.mode&1)===0?(i===u?i.flags|=65536:(i.flags|=128,m.flags|=131072,m.flags&=-52805,m.tag===1&&(m.alternate===null?m.tag=17:(u=ls(-1,1),u.tag=2,Bs(m,u,1))),m.lanes|=1),i):(i.flags|=65536,i.lanes=_,i)}var m4=E.ReactCurrentOwner,cn=!1;function Zt(i,u,m,w){u.child=i===null?f1(u,null,m,w):Io(u,i.child,m,w)}function K1(i,u,m,w,_){m=m.render;var C=u.ref;return Lo(u,_),w=Df(i,u,m,w,C,_),m=Ff(),i!==null&&!cn?(u.updateQueue=i.updateQueue,u.flags&=-2053,i.lanes&=~_,cs(i,u,_)):(at&&m&&bf(u),u.flags|=1,Zt(i,u,w,_),u.child)}function Y1(i,u,m,w,_){if(i===null){var C=m.type;return typeof C=="function"&&!mp(C)&&C.defaultProps===void 0&&m.compare===null&&m.defaultProps===void 0?(u.tag=15,u.type=C,X1(i,u,C,w,_)):(i=ku(m.type,null,w,u,u.mode,_),i.ref=u.ref,i.return=u,u.child=i)}if(C=i.child,(i.lanes&_)===0){var z=C.memoizedProps;if(m=m.compare,m=m!==null?m:Zi,m(z,w)&&i.ref===u.ref)return cs(i,u,_)}return u.flags|=1,i=Vs(C,w),i.ref=u.ref,i.return=u,u.child=i}function X1(i,u,m,w,_){if(i!==null){var C=i.memoizedProps;if(Zi(C,w)&&i.ref===u.ref)if(cn=!1,u.pendingProps=w=C,(i.lanes&_)!==0)(i.flags&131072)!==0&&(cn=!0);else return u.lanes=i.lanes,cs(i,u,_)}return Kf(i,u,m,w,_)}function Z1(i,u,m){var w=u.pendingProps,_=w.children,C=i!==null?i.memoizedState:null;if(w.mode==="hidden")if((u.mode&1)===0)u.memoizedState={baseLanes:0,cachePool:null,transitions:null},et(Bo,Nn),Nn|=m;else{if((m&1073741824)===0)return i=C!==null?C.baseLanes|m:m,u.lanes=u.childLanes=1073741824,u.memoizedState={baseLanes:i,cachePool:null,transitions:null},u.updateQueue=null,et(Bo,Nn),Nn|=i,null;u.memoizedState={baseLanes:0,cachePool:null,transitions:null},w=C!==null?C.baseLanes:m,et(Bo,Nn),Nn|=w}else C!==null?(w=C.baseLanes|m,u.memoizedState=null):w=m,et(Bo,Nn),Nn|=w;return Zt(i,u,_,m),u.child}function J1(i,u){var m=u.ref;(i===null&&m!==null||i!==null&&i.ref!==m)&&(u.flags|=512,u.flags|=2097152)}function Kf(i,u,m,w,_){var C=ln(m)?_a:Vt.current;return C=Ao(u,C),Lo(u,_),m=Df(i,u,m,w,C,_),w=Ff(),i!==null&&!cn?(u.updateQueue=i.updateQueue,u.flags&=-2053,i.lanes&=~_,cs(i,u,_)):(at&&w&&bf(u),u.flags|=1,Zt(i,u,m,_),u.child)}function Q1(i,u,m,w,_){if(ln(m)){var C=!0;Gc(u)}else C=!1;if(Lo(u,_),u.stateNode===null)du(i,u),q1(u,m,w),Hf(u,m,w,_),w=!0;else if(i===null){var z=u.stateNode,Q=u.memoizedProps;z.props=Q;var te=z.context,ue=m.contextType;typeof ue=="object"&&ue!==null?ue=Dn(ue):(ue=ln(m)?_a:Vt.current,ue=Ao(u,ue));var xe=m.getDerivedStateFromProps,ke=typeof xe=="function"||typeof z.getSnapshotBeforeUpdate=="function";ke||typeof z.UNSAFE_componentWillReceiveProps!="function"&&typeof z.componentWillReceiveProps!="function"||(Q!==w||te!==ue)&&U1(u,z,w,ue),Fs=!1;var ve=u.memoizedState;z.state=ve,nu(u,w,z,_),te=u.memoizedState,Q!==w||ve!==te||on.current||Fs?(typeof xe=="function"&&(Wf(u,m,xe,w),te=u.memoizedState),(Q=Fs||B1(u,m,Q,w,ve,te,ue))?(ke||typeof z.UNSAFE_componentWillMount!="function"&&typeof z.componentWillMount!="function"||(typeof z.componentWillMount=="function"&&z.componentWillMount(),typeof z.UNSAFE_componentWillMount=="function"&&z.UNSAFE_componentWillMount()),typeof z.componentDidMount=="function"&&(u.flags|=4194308)):(typeof z.componentDidMount=="function"&&(u.flags|=4194308),u.memoizedProps=w,u.memoizedState=te),z.props=w,z.state=te,z.context=ue,w=Q):(typeof z.componentDidMount=="function"&&(u.flags|=4194308),w=!1)}else{z=u.stateNode,m1(i,u),Q=u.memoizedProps,ue=u.type===u.elementType?Q:ur(u.type,Q),z.props=ue,ke=u.pendingProps,ve=z.context,te=m.contextType,typeof te=="object"&&te!==null?te=Dn(te):(te=ln(m)?_a:Vt.current,te=Ao(u,te));var Se=m.getDerivedStateFromProps;(xe=typeof Se=="function"||typeof z.getSnapshotBeforeUpdate=="function")||typeof z.UNSAFE_componentWillReceiveProps!="function"&&typeof z.componentWillReceiveProps!="function"||(Q!==ke||ve!==te)&&U1(u,z,w,te),Fs=!1,ve=u.memoizedState,z.state=ve,nu(u,w,z,_);var Ee=u.memoizedState;Q!==ke||ve!==Ee||on.current||Fs?(typeof Se=="function"&&(Wf(u,m,Se,w),Ee=u.memoizedState),(ue=Fs||B1(u,m,ue,w,ve,Ee,te)||!1)?(xe||typeof z.UNSAFE_componentWillUpdate!="function"&&typeof z.componentWillUpdate!="function"||(typeof z.componentWillUpdate=="function"&&z.componentWillUpdate(w,Ee,te),typeof z.UNSAFE_componentWillUpdate=="function"&&z.UNSAFE_componentWillUpdate(w,Ee,te)),typeof z.componentDidUpdate=="function"&&(u.flags|=4),typeof z.getSnapshotBeforeUpdate=="function"&&(u.flags|=1024)):(typeof z.componentDidUpdate!="function"||Q===i.memoizedProps&&ve===i.memoizedState||(u.flags|=4),typeof z.getSnapshotBeforeUpdate!="function"||Q===i.memoizedProps&&ve===i.memoizedState||(u.flags|=1024),u.memoizedProps=w,u.memoizedState=Ee),z.props=w,z.state=Ee,z.context=te,w=ue):(typeof z.componentDidUpdate!="function"||Q===i.memoizedProps&&ve===i.memoizedState||(u.flags|=4),typeof z.getSnapshotBeforeUpdate!="function"||Q===i.memoizedProps&&ve===i.memoizedState||(u.flags|=1024),w=!1)}return Yf(i,u,m,w,C,_)}function Yf(i,u,m,w,_,C){J1(i,u);var z=(u.flags&128)!==0;if(!w&&!z)return _&&s1(u,m,!1),cs(i,u,C);w=u.stateNode,m4.current=u;var Q=z&&typeof m.getDerivedStateFromError!="function"?null:w.render();return u.flags|=1,i!==null&&z?(u.child=Io(u,i.child,null,C),u.child=Io(u,null,Q,C)):Zt(i,u,Q,C),u.memoizedState=w.state,_&&s1(u,m,!0),u.child}function eN(i){var u=i.stateNode;u.pendingContext?n1(i,u.pendingContext,u.pendingContext!==u.context):u.context&&n1(i,u.context,!1),Mf(i,u.containerInfo)}function tN(i,u,m,w,_){return $o(),Sf(_),u.flags|=256,Zt(i,u,m,w),u.child}var Xf={dehydrated:null,treeContext:null,retryLane:0};function Zf(i){return{baseLanes:i,cachePool:null,transitions:null}}function nN(i,u,m){var w=u.pendingProps,_=ut.current,C=!1,z=(u.flags&128)!==0,Q;if((Q=z)||(Q=i!==null&&i.memoizedState===null?!1:(_&2)!==0),Q?(C=!0,u.flags&=-129):(i===null||i.memoizedState!==null)&&(_|=1),et(ut,_&1),i===null)return jf(u),i=u.memoizedState,i!==null&&(i=i.dehydrated,i!==null)?((u.mode&1)===0?u.lanes=1:i.data==="$!"?u.lanes=8:u.lanes=1073741824,null):(z=w.children,i=w.fallback,C?(w=u.mode,C=u.child,z={mode:"hidden",children:z},(w&1)===0&&C!==null?(C.childLanes=0,C.pendingProps=z):C=Nu(z,w,0,null),i=La(i,w,m,null),C.return=u,i.return=u,C.sibling=i,u.child=C,u.child.memoizedState=Zf(m),u.memoizedState=Xf,i):Jf(u,z));if(_=i.memoizedState,_!==null&&(Q=_.dehydrated,Q!==null))return g4(i,u,z,w,Q,_,m);if(C){C=w.fallback,z=u.mode,_=i.child,Q=_.sibling;var te={mode:"hidden",children:w.children};return(z&1)===0&&u.child!==_?(w=u.child,w.childLanes=0,w.pendingProps=te,u.deletions=null):(w=Vs(_,te),w.subtreeFlags=_.subtreeFlags&14680064),Q!==null?C=Vs(Q,C):(C=La(C,z,m,null),C.flags|=2),C.return=u,w.return=u,w.sibling=C,u.child=w,w=C,C=u.child,z=i.child.memoizedState,z=z===null?Zf(m):{baseLanes:z.baseLanes|m,cachePool:null,transitions:z.transitions},C.memoizedState=z,C.childLanes=i.childLanes&~m,u.memoizedState=Xf,w}return C=i.child,i=C.sibling,w=Vs(C,{mode:"visible",children:w.children}),(u.mode&1)===0&&(w.lanes=m),w.return=u,w.sibling=null,i!==null&&(m=u.deletions,m===null?(u.deletions=[i],u.flags|=16):m.push(i)),u.child=w,u.memoizedState=null,w}function Jf(i,u){return u=Nu({mode:"visible",children:u},i.mode,0,null),u.return=i,i.child=u}function uu(i,u,m,w){return w!==null&&Sf(w),Io(u,i.child,null,m),i=Jf(u,u.pendingProps.children),i.flags|=2,u.memoizedState=null,i}function g4(i,u,m,w,_,C,z){if(m)return u.flags&256?(u.flags&=-257,w=Vf(Error(n(422))),uu(i,u,z,w)):u.memoizedState!==null?(u.child=i.child,u.flags|=128,null):(C=w.fallback,_=u.mode,w=Nu({mode:"visible",children:w.children},_,0,null),C=La(C,_,z,null),C.flags|=2,w.return=u,C.return=u,w.sibling=C,u.child=w,(u.mode&1)!==0&&Io(u,i.child,null,z),u.child.memoizedState=Zf(z),u.memoizedState=Xf,C);if((u.mode&1)===0)return uu(i,u,z,null);if(_.data==="$!"){if(w=_.nextSibling&&_.nextSibling.dataset,w)var Q=w.dgst;return w=Q,C=Error(n(419)),w=Vf(C,w,void 0),uu(i,u,z,w)}if(Q=(z&i.childLanes)!==0,cn||Q){if(w=It,w!==null){switch(z&-z){case 4:_=2;break;case 16:_=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:_=32;break;case 536870912:_=268435456;break;default:_=0}_=(_&(w.suspendedLanes|z))!==0?0:_,_!==0&&_!==C.retryLane&&(C.retryLane=_,is(i,_),fr(w,i,_,-1))}return pp(),w=Vf(Error(n(421))),uu(i,u,z,w)}return _.data==="$?"?(u.flags|=128,u.child=i.child,u=T4.bind(null,i),_._reactRetry=u,null):(i=C.treeContext,kn=Os(_.nextSibling),bn=u,at=!0,cr=null,i!==null&&(Ln[Pn++]=as,Ln[Pn++]=os,Ln[Pn++]=Ea,as=i.id,os=i.overflow,Ea=u),u=Jf(u,w.children),u.flags|=4096,u)}function rN(i,u,m){i.lanes|=u;var w=i.alternate;w!==null&&(w.lanes|=u),Tf(i.return,u,m)}function Qf(i,u,m,w,_){var C=i.memoizedState;C===null?i.memoizedState={isBackwards:u,rendering:null,renderingStartTime:0,last:w,tail:m,tailMode:_}:(C.isBackwards=u,C.rendering=null,C.renderingStartTime=0,C.last=w,C.tail=m,C.tailMode=_)}function sN(i,u,m){var w=u.pendingProps,_=w.revealOrder,C=w.tail;if(Zt(i,u,w.children,m),w=ut.current,(w&2)!==0)w=w&1|2,u.flags|=128;else{if(i!==null&&(i.flags&128)!==0)e:for(i=u.child;i!==null;){if(i.tag===13)i.memoizedState!==null&&rN(i,m,u);else if(i.tag===19)rN(i,m,u);else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===u)break e;for(;i.sibling===null;){if(i.return===null||i.return===u)break e;i=i.return}i.sibling.return=i.return,i=i.sibling}w&=1}if(et(ut,w),(u.mode&1)===0)u.memoizedState=null;else switch(_){case"forwards":for(m=u.child,_=null;m!==null;)i=m.alternate,i!==null&&ru(i)===null&&(_=m),m=m.sibling;m=_,m===null?(_=u.child,u.child=null):(_=m.sibling,m.sibling=null),Qf(u,!1,_,m,C);break;case"backwards":for(m=null,_=u.child,u.child=null;_!==null;){if(i=_.alternate,i!==null&&ru(i)===null){u.child=_;break}i=_.sibling,_.sibling=m,m=_,_=i}Qf(u,!0,m,null,C);break;case"together":Qf(u,!1,null,null,void 0);break;default:u.memoizedState=null}return u.child}function du(i,u){(u.mode&1)===0&&i!==null&&(i.alternate=null,u.alternate=null,u.flags|=2)}function cs(i,u,m){if(i!==null&&(u.dependencies=i.dependencies),Ma|=u.lanes,(m&u.childLanes)===0)return null;if(i!==null&&u.child!==i.child)throw Error(n(153));if(u.child!==null){for(i=u.child,m=Vs(i,i.pendingProps),u.child=m,m.return=u;i.sibling!==null;)i=i.sibling,m=m.sibling=Vs(i,i.pendingProps),m.return=u;m.sibling=null}return u.child}function y4(i,u,m){switch(u.tag){case 3:eN(u),$o();break;case 5:w1(u);break;case 1:ln(u.type)&&Gc(u);break;case 4:Mf(u,u.stateNode.containerInfo);break;case 10:var w=u.type._context,_=u.memoizedProps.value;et(Qc,w._currentValue),w._currentValue=_;break;case 13:if(w=u.memoizedState,w!==null)return w.dehydrated!==null?(et(ut,ut.current&1),u.flags|=128,null):(m&u.child.childLanes)!==0?nN(i,u,m):(et(ut,ut.current&1),i=cs(i,u,m),i!==null?i.sibling:null);et(ut,ut.current&1);break;case 19:if(w=(m&u.childLanes)!==0,(i.flags&128)!==0){if(w)return sN(i,u,m);u.flags|=128}if(_=u.memoizedState,_!==null&&(_.rendering=null,_.tail=null,_.lastEffect=null),et(ut,ut.current),w)break;return null;case 22:case 23:return u.lanes=0,Z1(i,u,m)}return cs(i,u,m)}var aN,ep,oN,iN;aN=function(i,u){for(var m=u.child;m!==null;){if(m.tag===5||m.tag===6)i.appendChild(m.stateNode);else if(m.tag!==4&&m.child!==null){m.child.return=m,m=m.child;continue}if(m===u)break;for(;m.sibling===null;){if(m.return===null||m.return===u)return;m=m.return}m.sibling.return=m.return,m=m.sibling}},ep=function(){},oN=function(i,u,m,w){var _=i.memoizedProps;if(_!==w){i=u.stateNode,Aa(Lr.current);var C=null;switch(m){case"input":_=pe(i,_),w=pe(i,w),C=[];break;case"select":_=H({},_,{value:void 0}),w=H({},w,{value:void 0}),C=[];break;case"textarea":_=Me(i,_),w=Me(i,w),C=[];break;default:typeof _.onClick!="function"&&typeof w.onClick=="function"&&(i.onclick=Wc)}Dt(m,w);var z;m=null;for(ue in _)if(!w.hasOwnProperty(ue)&&_.hasOwnProperty(ue)&&_[ue]!=null)if(ue==="style"){var Q=_[ue];for(z in Q)Q.hasOwnProperty(z)&&(m||(m={}),m[z]="")}else ue!=="dangerouslySetInnerHTML"&&ue!=="children"&&ue!=="suppressContentEditableWarning"&&ue!=="suppressHydrationWarning"&&ue!=="autoFocus"&&(s.hasOwnProperty(ue)?C||(C=[]):(C=C||[]).push(ue,null));for(ue in w){var te=w[ue];if(Q=_!=null?_[ue]:void 0,w.hasOwnProperty(ue)&&te!==Q&&(te!=null||Q!=null))if(ue==="style")if(Q){for(z in Q)!Q.hasOwnProperty(z)||te&&te.hasOwnProperty(z)||(m||(m={}),m[z]="");for(z in te)te.hasOwnProperty(z)&&Q[z]!==te[z]&&(m||(m={}),m[z]=te[z])}else m||(C||(C=[]),C.push(ue,m)),m=te;else ue==="dangerouslySetInnerHTML"?(te=te?te.__html:void 0,Q=Q?Q.__html:void 0,te!=null&&Q!==te&&(C=C||[]).push(ue,te)):ue==="children"?typeof te!="string"&&typeof te!="number"||(C=C||[]).push(ue,""+te):ue!=="suppressContentEditableWarning"&&ue!=="suppressHydrationWarning"&&(s.hasOwnProperty(ue)?(te!=null&&ue==="onScroll"&&nt("scroll",i),C||Q===te||(C=[])):(C=C||[]).push(ue,te))}m&&(C=C||[]).push("style",m);var ue=C;(u.updateQueue=ue)&&(u.flags|=4)}},iN=function(i,u,m,w){m!==w&&(u.flags|=4)};function hl(i,u){if(!at)switch(i.tailMode){case"hidden":u=i.tail;for(var m=null;u!==null;)u.alternate!==null&&(m=u),u=u.sibling;m===null?i.tail=null:m.sibling=null;break;case"collapsed":m=i.tail;for(var w=null;m!==null;)m.alternate!==null&&(w=m),m=m.sibling;w===null?u||i.tail===null?i.tail=null:i.tail.sibling=null:w.sibling=null}}function Kt(i){var u=i.alternate!==null&&i.alternate.child===i.child,m=0,w=0;if(u)for(var _=i.child;_!==null;)m|=_.lanes|_.childLanes,w|=_.subtreeFlags&14680064,w|=_.flags&14680064,_.return=i,_=_.sibling;else for(_=i.child;_!==null;)m|=_.lanes|_.childLanes,w|=_.subtreeFlags,w|=_.flags,_.return=i,_=_.sibling;return i.subtreeFlags|=w,i.childLanes=m,u}function w4(i,u,m){var w=u.pendingProps;switch(kf(u),u.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Kt(u),null;case 1:return ln(u.type)&&Vc(),Kt(u),null;case 3:return w=u.stateNode,Po(),rt(on),rt(Vt),Of(),w.pendingContext&&(w.context=w.pendingContext,w.pendingContext=null),(i===null||i.child===null)&&(Zc(u)?u.flags|=4:i===null||i.memoizedState.isDehydrated&&(u.flags&256)===0||(u.flags|=1024,cr!==null&&(dp(cr),cr=null))),ep(i,u),Kt(u),null;case 5:$f(u);var _=Aa(il.current);if(m=u.type,i!==null&&u.stateNode!=null)oN(i,u,m,w,_),i.ref!==u.ref&&(u.flags|=512,u.flags|=2097152);else{if(!w){if(u.stateNode===null)throw Error(n(166));return Kt(u),null}if(i=Aa(Lr.current),Zc(u)){w=u.stateNode,m=u.type;var C=u.memoizedProps;switch(w[Or]=u,w[nl]=C,i=(u.mode&1)!==0,m){case"dialog":nt("cancel",w),nt("close",w);break;case"iframe":case"object":case"embed":nt("load",w);break;case"video":case"audio":for(_=0;_<Qi.length;_++)nt(Qi[_],w);break;case"source":nt("error",w);break;case"img":case"image":case"link":nt("error",w),nt("load",w);break;case"details":nt("toggle",w);break;case"input":fe(w,C),nt("invalid",w);break;case"select":w._wrapperState={wasMultiple:!!C.multiple},nt("invalid",w);break;case"textarea":Le(w,C),nt("invalid",w)}Dt(m,C),_=null;for(var z in C)if(C.hasOwnProperty(z)){var Q=C[z];z==="children"?typeof Q=="string"?w.textContent!==Q&&(C.suppressHydrationWarning!==!0&&zc(w.textContent,Q,i),_=["children",Q]):typeof Q=="number"&&w.textContent!==""+Q&&(C.suppressHydrationWarning!==!0&&zc(w.textContent,Q,i),_=["children",""+Q]):s.hasOwnProperty(z)&&Q!=null&&z==="onScroll"&&nt("scroll",w)}switch(m){case"input":ge(w),ne(w,C,!0);break;case"textarea":ge(w),Pe(w);break;case"select":case"option":break;default:typeof C.onClick=="function"&&(w.onclick=Wc)}w=_,u.updateQueue=w,w!==null&&(u.flags|=4)}else{z=_.nodeType===9?_:_.ownerDocument,i==="http://www.w3.org/1999/xhtml"&&(i=Qe(m)),i==="http://www.w3.org/1999/xhtml"?m==="script"?(i=z.createElement("div"),i.innerHTML="<script><\/script>",i=i.removeChild(i.firstChild)):typeof w.is=="string"?i=z.createElement(m,{is:w.is}):(i=z.createElement(m),m==="select"&&(z=i,w.multiple?z.multiple=!0:w.size&&(z.size=w.size))):i=z.createElementNS(i,m),i[Or]=u,i[nl]=w,aN(i,u,!1,!1),u.stateNode=i;e:{switch(z=gt(m,w),m){case"dialog":nt("cancel",i),nt("close",i),_=w;break;case"iframe":case"object":case"embed":nt("load",i),_=w;break;case"video":case"audio":for(_=0;_<Qi.length;_++)nt(Qi[_],i);_=w;break;case"source":nt("error",i),_=w;break;case"img":case"image":case"link":nt("error",i),nt("load",i),_=w;break;case"details":nt("toggle",i),_=w;break;case"input":fe(i,w),_=pe(i,w),nt("invalid",i);break;case"option":_=w;break;case"select":i._wrapperState={wasMultiple:!!w.multiple},_=H({},w,{value:void 0}),nt("invalid",i);break;case"textarea":Le(i,w),_=Me(i,w),nt("invalid",i);break;default:_=w}Dt(m,_),Q=_;for(C in Q)if(Q.hasOwnProperty(C)){var te=Q[C];C==="style"?ct(i,te):C==="dangerouslySetInnerHTML"?(te=te?te.__html:void 0,te!=null&&lt(i,te)):C==="children"?typeof te=="string"?(m!=="textarea"||te!=="")&&Nt(i,te):typeof te=="number"&&Nt(i,""+te):C!=="suppressContentEditableWarning"&&C!=="suppressHydrationWarning"&&C!=="autoFocus"&&(s.hasOwnProperty(C)?te!=null&&C==="onScroll"&&nt("scroll",i):te!=null&&S(i,C,te,z))}switch(m){case"input":ge(i),ne(i,w,!1);break;case"textarea":ge(i),Pe(i);break;case"option":w.value!=null&&i.setAttribute("value",""+ee(w.value));break;case"select":i.multiple=!!w.multiple,C=w.value,C!=null?we(i,!!w.multiple,C,!1):w.defaultValue!=null&&we(i,!!w.multiple,w.defaultValue,!0);break;default:typeof _.onClick=="function"&&(i.onclick=Wc)}switch(m){case"button":case"input":case"select":case"textarea":w=!!w.autoFocus;break e;case"img":w=!0;break e;default:w=!1}}w&&(u.flags|=4)}u.ref!==null&&(u.flags|=512,u.flags|=2097152)}return Kt(u),null;case 6:if(i&&u.stateNode!=null)iN(i,u,i.memoizedProps,w);else{if(typeof w!="string"&&u.stateNode===null)throw Error(n(166));if(m=Aa(il.current),Aa(Lr.current),Zc(u)){if(w=u.stateNode,m=u.memoizedProps,w[Or]=u,(C=w.nodeValue!==m)&&(i=bn,i!==null))switch(i.tag){case 3:zc(w.nodeValue,m,(i.mode&1)!==0);break;case 5:i.memoizedProps.suppressHydrationWarning!==!0&&zc(w.nodeValue,m,(i.mode&1)!==0)}C&&(u.flags|=4)}else w=(m.nodeType===9?m:m.ownerDocument).createTextNode(w),w[Or]=u,u.stateNode=w}return Kt(u),null;case 13:if(rt(ut),w=u.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(at&&kn!==null&&(u.mode&1)!==0&&(u.flags&128)===0)u1(),$o(),u.flags|=98560,C=!1;else if(C=Zc(u),w!==null&&w.dehydrated!==null){if(i===null){if(!C)throw Error(n(318));if(C=u.memoizedState,C=C!==null?C.dehydrated:null,!C)throw Error(n(317));C[Or]=u}else $o(),(u.flags&128)===0&&(u.memoizedState=null),u.flags|=4;Kt(u),C=!1}else cr!==null&&(dp(cr),cr=null),C=!0;if(!C)return u.flags&65536?u:null}return(u.flags&128)!==0?(u.lanes=m,u):(w=w!==null,w!==(i!==null&&i.memoizedState!==null)&&w&&(u.child.flags|=8192,(u.mode&1)!==0&&(i===null||(ut.current&1)!==0?_t===0&&(_t=3):pp())),u.updateQueue!==null&&(u.flags|=4),Kt(u),null);case 4:return Po(),ep(i,u),i===null&&el(u.stateNode.containerInfo),Kt(u),null;case 10:return Cf(u.type._context),Kt(u),null;case 17:return ln(u.type)&&Vc(),Kt(u),null;case 19:if(rt(ut),C=u.memoizedState,C===null)return Kt(u),null;if(w=(u.flags&128)!==0,z=C.rendering,z===null)if(w)hl(C,!1);else{if(_t!==0||i!==null&&(i.flags&128)!==0)for(i=u.child;i!==null;){if(z=ru(i),z!==null){for(u.flags|=128,hl(C,!1),w=z.updateQueue,w!==null&&(u.updateQueue=w,u.flags|=4),u.subtreeFlags=0,w=m,m=u.child;m!==null;)C=m,i=w,C.flags&=14680066,z=C.alternate,z===null?(C.childLanes=0,C.lanes=i,C.child=null,C.subtreeFlags=0,C.memoizedProps=null,C.memoizedState=null,C.updateQueue=null,C.dependencies=null,C.stateNode=null):(C.childLanes=z.childLanes,C.lanes=z.lanes,C.child=z.child,C.subtreeFlags=0,C.deletions=null,C.memoizedProps=z.memoizedProps,C.memoizedState=z.memoizedState,C.updateQueue=z.updateQueue,C.type=z.type,i=z.dependencies,C.dependencies=i===null?null:{lanes:i.lanes,firstContext:i.firstContext}),m=m.sibling;return et(ut,ut.current&1|2),u.child}i=i.sibling}C.tail!==null&&Re()>qo&&(u.flags|=128,w=!0,hl(C,!1),u.lanes=4194304)}else{if(!w)if(i=ru(z),i!==null){if(u.flags|=128,w=!0,m=i.updateQueue,m!==null&&(u.updateQueue=m,u.flags|=4),hl(C,!0),C.tail===null&&C.tailMode==="hidden"&&!z.alternate&&!at)return Kt(u),null}else 2*Re()-C.renderingStartTime>qo&&m!==1073741824&&(u.flags|=128,w=!0,hl(C,!1),u.lanes=4194304);C.isBackwards?(z.sibling=u.child,u.child=z):(m=C.last,m!==null?m.sibling=z:u.child=z,C.last=z)}return C.tail!==null?(u=C.tail,C.rendering=u,C.tail=u.sibling,C.renderingStartTime=Re(),u.sibling=null,m=ut.current,et(ut,w?m&1|2:m&1),u):(Kt(u),null);case 22:case 23:return fp(),w=u.memoizedState!==null,i!==null&&i.memoizedState!==null!==w&&(u.flags|=8192),w&&(u.mode&1)!==0?(Nn&1073741824)!==0&&(Kt(u),u.subtreeFlags&6&&(u.flags|=8192)):Kt(u),null;case 24:return null;case 25:return null}throw Error(n(156,u.tag))}function v4(i,u){switch(kf(u),u.tag){case 1:return ln(u.type)&&Vc(),i=u.flags,i&65536?(u.flags=i&-65537|128,u):null;case 3:return Po(),rt(on),rt(Vt),Of(),i=u.flags,(i&65536)!==0&&(i&128)===0?(u.flags=i&-65537|128,u):null;case 5:return $f(u),null;case 13:if(rt(ut),i=u.memoizedState,i!==null&&i.dehydrated!==null){if(u.alternate===null)throw Error(n(340));$o()}return i=u.flags,i&65536?(u.flags=i&-65537|128,u):null;case 19:return rt(ut),null;case 4:return Po(),null;case 10:return Cf(u.type._context),null;case 22:case 23:return fp(),null;case 24:return null;default:return null}}var hu=!1,Yt=!1,x4=typeof WeakSet=="function"?WeakSet:Set,_e=null;function Fo(i,u){var m=i.ref;if(m!==null)if(typeof m=="function")try{m(null)}catch(w){ft(i,u,w)}else m.current=null}function tp(i,u,m){try{m()}catch(w){ft(i,u,w)}}var lN=!1;function b4(i,u){if(ff=xa,i=B0(),sf(i)){if("selectionStart"in i)var m={start:i.selectionStart,end:i.selectionEnd};else e:{m=(m=i.ownerDocument)&&m.defaultView||window;var w=m.getSelection&&m.getSelection();if(w&&w.rangeCount!==0){m=w.anchorNode;var _=w.anchorOffset,C=w.focusNode;w=w.focusOffset;try{m.nodeType,C.nodeType}catch{m=null;break e}var z=0,Q=-1,te=-1,ue=0,xe=0,ke=i,ve=null;t:for(;;){for(var Se;ke!==m||_!==0&&ke.nodeType!==3||(Q=z+_),ke!==C||w!==0&&ke.nodeType!==3||(te=z+w),ke.nodeType===3&&(z+=ke.nodeValue.length),(Se=ke.firstChild)!==null;)ve=ke,ke=Se;for(;;){if(ke===i)break t;if(ve===m&&++ue===_&&(Q=z),ve===C&&++xe===w&&(te=z),(Se=ke.nextSibling)!==null)break;ke=ve,ve=ke.parentNode}ke=Se}m=Q===-1||te===-1?null:{start:Q,end:te}}else m=null}m=m||{start:0,end:0}}else m=null;for(pf={focusedElem:i,selectionRange:m},xa=!1,_e=u;_e!==null;)if(u=_e,i=u.child,(u.subtreeFlags&1028)!==0&&i!==null)i.return=u,_e=i;else for(;_e!==null;){u=_e;try{var Ee=u.alternate;if((u.flags&1024)!==0)switch(u.tag){case 0:case 11:case 15:break;case 1:if(Ee!==null){var Ce=Ee.memoizedProps,yt=Ee.memoizedState,ie=u.stateNode,re=ie.getSnapshotBeforeUpdate(u.elementType===u.type?Ce:ur(u.type,Ce),yt);ie.__reactInternalSnapshotBeforeUpdate=re}break;case 3:var le=u.stateNode.containerInfo;le.nodeType===1?le.textContent="":le.nodeType===9&&le.documentElement&&le.removeChild(le.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(je){ft(u,u.return,je)}if(i=u.sibling,i!==null){i.return=u.return,_e=i;break}_e=u.return}return Ee=lN,lN=!1,Ee}function fl(i,u,m){var w=u.updateQueue;if(w=w!==null?w.lastEffect:null,w!==null){var _=w=w.next;do{if((_.tag&i)===i){var C=_.destroy;_.destroy=void 0,C!==void 0&&tp(u,m,C)}_=_.next}while(_!==w)}}function fu(i,u){if(u=u.updateQueue,u=u!==null?u.lastEffect:null,u!==null){var m=u=u.next;do{if((m.tag&i)===i){var w=m.create;m.destroy=w()}m=m.next}while(m!==u)}}function np(i){var u=i.ref;if(u!==null){var m=i.stateNode;switch(i.tag){case 5:i=m;break;default:i=m}typeof u=="function"?u(i):u.current=i}}function cN(i){var u=i.alternate;u!==null&&(i.alternate=null,cN(u)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(u=i.stateNode,u!==null&&(delete u[Or],delete u[nl],delete u[wf],delete u[r4],delete u[s4])),i.stateNode=null,i.return=null,i.dependencies=null,i.memoizedProps=null,i.memoizedState=null,i.pendingProps=null,i.stateNode=null,i.updateQueue=null}function uN(i){return i.tag===5||i.tag===3||i.tag===4}function dN(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||uN(i.return))return null;i=i.return}for(i.sibling.return=i.return,i=i.sibling;i.tag!==5&&i.tag!==6&&i.tag!==18;){if(i.flags&2||i.child===null||i.tag===4)continue e;i.child.return=i,i=i.child}if(!(i.flags&2))return i.stateNode}}function rp(i,u,m){var w=i.tag;if(w===5||w===6)i=i.stateNode,u?m.nodeType===8?m.parentNode.insertBefore(i,u):m.insertBefore(i,u):(m.nodeType===8?(u=m.parentNode,u.insertBefore(i,m)):(u=m,u.appendChild(i)),m=m._reactRootContainer,m!=null||u.onclick!==null||(u.onclick=Wc));else if(w!==4&&(i=i.child,i!==null))for(rp(i,u,m),i=i.sibling;i!==null;)rp(i,u,m),i=i.sibling}function sp(i,u,m){var w=i.tag;if(w===5||w===6)i=i.stateNode,u?m.insertBefore(i,u):m.appendChild(i);else if(w!==4&&(i=i.child,i!==null))for(sp(i,u,m),i=i.sibling;i!==null;)sp(i,u,m),i=i.sibling}var Ft=null,dr=!1;function qs(i,u,m){for(m=m.child;m!==null;)hN(i,u,m),m=m.sibling}function hN(i,u,m){if(sn&&typeof sn.onCommitFiberUnmount=="function")try{sn.onCommitFiberUnmount(On,m)}catch{}switch(m.tag){case 5:Yt||Fo(m,u);case 6:var w=Ft,_=dr;Ft=null,qs(i,u,m),Ft=w,dr=_,Ft!==null&&(dr?(i=Ft,m=m.stateNode,i.nodeType===8?i.parentNode.removeChild(m):i.removeChild(m)):Ft.removeChild(m.stateNode));break;case 18:Ft!==null&&(dr?(i=Ft,m=m.stateNode,i.nodeType===8?yf(i.parentNode,m):i.nodeType===1&&yf(i,m),xn(i)):yf(Ft,m.stateNode));break;case 4:w=Ft,_=dr,Ft=m.stateNode.containerInfo,dr=!0,qs(i,u,m),Ft=w,dr=_;break;case 0:case 11:case 14:case 15:if(!Yt&&(w=m.updateQueue,w!==null&&(w=w.lastEffect,w!==null))){_=w=w.next;do{var C=_,z=C.destroy;C=C.tag,z!==void 0&&((C&2)!==0||(C&4)!==0)&&tp(m,u,z),_=_.next}while(_!==w)}qs(i,u,m);break;case 1:if(!Yt&&(Fo(m,u),w=m.stateNode,typeof w.componentWillUnmount=="function"))try{w.props=m.memoizedProps,w.state=m.memoizedState,w.componentWillUnmount()}catch(Q){ft(m,u,Q)}qs(i,u,m);break;case 21:qs(i,u,m);break;case 22:m.mode&1?(Yt=(w=Yt)||m.memoizedState!==null,qs(i,u,m),Yt=w):qs(i,u,m);break;default:qs(i,u,m)}}function fN(i){var u=i.updateQueue;if(u!==null){i.updateQueue=null;var m=i.stateNode;m===null&&(m=i.stateNode=new x4),u.forEach(function(w){var _=A4.bind(null,i,w);m.has(w)||(m.add(w),w.then(_,_))})}}function hr(i,u){var m=u.deletions;if(m!==null)for(var w=0;w<m.length;w++){var _=m[w];try{var C=i,z=u,Q=z;e:for(;Q!==null;){switch(Q.tag){case 5:Ft=Q.stateNode,dr=!1;break e;case 3:Ft=Q.stateNode.containerInfo,dr=!0;break e;case 4:Ft=Q.stateNode.containerInfo,dr=!0;break e}Q=Q.return}if(Ft===null)throw Error(n(160));hN(C,z,_),Ft=null,dr=!1;var te=_.alternate;te!==null&&(te.return=null),_.return=null}catch(ue){ft(_,u,ue)}}if(u.subtreeFlags&12854)for(u=u.child;u!==null;)pN(u,i),u=u.sibling}function pN(i,u){var m=i.alternate,w=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:if(hr(u,i),Dr(i),w&4){try{fl(3,i,i.return),fu(3,i)}catch(Ce){ft(i,i.return,Ce)}try{fl(5,i,i.return)}catch(Ce){ft(i,i.return,Ce)}}break;case 1:hr(u,i),Dr(i),w&512&&m!==null&&Fo(m,m.return);break;case 5:if(hr(u,i),Dr(i),w&512&&m!==null&&Fo(m,m.return),i.flags&32){var _=i.stateNode;try{Nt(_,"")}catch(Ce){ft(i,i.return,Ce)}}if(w&4&&(_=i.stateNode,_!=null)){var C=i.memoizedProps,z=m!==null?m.memoizedProps:C,Q=i.type,te=i.updateQueue;if(i.updateQueue=null,te!==null)try{Q==="input"&&C.type==="radio"&&C.name!=null&&de(_,C),gt(Q,z);var ue=gt(Q,C);for(z=0;z<te.length;z+=2){var xe=te[z],ke=te[z+1];xe==="style"?ct(_,ke):xe==="dangerouslySetInnerHTML"?lt(_,ke):xe==="children"?Nt(_,ke):S(_,xe,ke,ue)}switch(Q){case"input":me(_,C);break;case"textarea":Be(_,C);break;case"select":var ve=_._wrapperState.wasMultiple;_._wrapperState.wasMultiple=!!C.multiple;var Se=C.value;Se!=null?we(_,!!C.multiple,Se,!1):ve!==!!C.multiple&&(C.defaultValue!=null?we(_,!!C.multiple,C.defaultValue,!0):we(_,!!C.multiple,C.multiple?[]:"",!1))}_[nl]=C}catch(Ce){ft(i,i.return,Ce)}}break;case 6:if(hr(u,i),Dr(i),w&4){if(i.stateNode===null)throw Error(n(162));_=i.stateNode,C=i.memoizedProps;try{_.nodeValue=C}catch(Ce){ft(i,i.return,Ce)}}break;case 3:if(hr(u,i),Dr(i),w&4&&m!==null&&m.memoizedState.isDehydrated)try{xn(u.containerInfo)}catch(Ce){ft(i,i.return,Ce)}break;case 4:hr(u,i),Dr(i);break;case 13:hr(u,i),Dr(i),_=i.child,_.flags&8192&&(C=_.memoizedState!==null,_.stateNode.isHidden=C,!C||_.alternate!==null&&_.alternate.memoizedState!==null||(ip=Re())),w&4&&fN(i);break;case 22:if(xe=m!==null&&m.memoizedState!==null,i.mode&1?(Yt=(ue=Yt)||xe,hr(u,i),Yt=ue):hr(u,i),Dr(i),w&8192){if(ue=i.memoizedState!==null,(i.stateNode.isHidden=ue)&&!xe&&(i.mode&1)!==0)for(_e=i,xe=i.child;xe!==null;){for(ke=_e=xe;_e!==null;){switch(ve=_e,Se=ve.child,ve.tag){case 0:case 11:case 14:case 15:fl(4,ve,ve.return);break;case 1:Fo(ve,ve.return);var Ee=ve.stateNode;if(typeof Ee.componentWillUnmount=="function"){w=ve,m=ve.return;try{u=w,Ee.props=u.memoizedProps,Ee.state=u.memoizedState,Ee.componentWillUnmount()}catch(Ce){ft(w,m,Ce)}}break;case 5:Fo(ve,ve.return);break;case 22:if(ve.memoizedState!==null){yN(ke);continue}}Se!==null?(Se.return=ve,_e=Se):yN(ke)}xe=xe.sibling}e:for(xe=null,ke=i;;){if(ke.tag===5){if(xe===null){xe=ke;try{_=ke.stateNode,ue?(C=_.style,typeof C.setProperty=="function"?C.setProperty("display","none","important"):C.display="none"):(Q=ke.stateNode,te=ke.memoizedProps.style,z=te!=null&&te.hasOwnProperty("display")?te.display:null,Q.style.display=Ge("display",z))}catch(Ce){ft(i,i.return,Ce)}}}else if(ke.tag===6){if(xe===null)try{ke.stateNode.nodeValue=ue?"":ke.memoizedProps}catch(Ce){ft(i,i.return,Ce)}}else if((ke.tag!==22&&ke.tag!==23||ke.memoizedState===null||ke===i)&&ke.child!==null){ke.child.return=ke,ke=ke.child;continue}if(ke===i)break e;for(;ke.sibling===null;){if(ke.return===null||ke.return===i)break e;xe===ke&&(xe=null),ke=ke.return}xe===ke&&(xe=null),ke.sibling.return=ke.return,ke=ke.sibling}}break;case 19:hr(u,i),Dr(i),w&4&&fN(i);break;case 21:break;default:hr(u,i),Dr(i)}}function Dr(i){var u=i.flags;if(u&2){try{e:{for(var m=i.return;m!==null;){if(uN(m)){var w=m;break e}m=m.return}throw Error(n(160))}switch(w.tag){case 5:var _=w.stateNode;w.flags&32&&(Nt(_,""),w.flags&=-33);var C=dN(i);sp(i,C,_);break;case 3:case 4:var z=w.stateNode.containerInfo,Q=dN(i);rp(i,Q,z);break;default:throw Error(n(161))}}catch(te){ft(i,i.return,te)}i.flags&=-3}u&4096&&(i.flags&=-4097)}function k4(i,u,m){_e=i,mN(i)}function mN(i,u,m){for(var w=(i.mode&1)!==0;_e!==null;){var _=_e,C=_.child;if(_.tag===22&&w){var z=_.memoizedState!==null||hu;if(!z){var Q=_.alternate,te=Q!==null&&Q.memoizedState!==null||Yt;Q=hu;var ue=Yt;if(hu=z,(Yt=te)&&!ue)for(_e=_;_e!==null;)z=_e,te=z.child,z.tag===22&&z.memoizedState!==null?wN(_):te!==null?(te.return=z,_e=te):wN(_);for(;C!==null;)_e=C,mN(C),C=C.sibling;_e=_,hu=Q,Yt=ue}gN(i)}else(_.subtreeFlags&8772)!==0&&C!==null?(C.return=_,_e=C):gN(i)}}function gN(i){for(;_e!==null;){var u=_e;if((u.flags&8772)!==0){var m=u.alternate;try{if((u.flags&8772)!==0)switch(u.tag){case 0:case 11:case 15:Yt||fu(5,u);break;case 1:var w=u.stateNode;if(u.flags&4&&!Yt)if(m===null)w.componentDidMount();else{var _=u.elementType===u.type?m.memoizedProps:ur(u.type,m.memoizedProps);w.componentDidUpdate(_,m.memoizedState,w.__reactInternalSnapshotBeforeUpdate)}var C=u.updateQueue;C!==null&&y1(u,C,w);break;case 3:var z=u.updateQueue;if(z!==null){if(m=null,u.child!==null)switch(u.child.tag){case 5:m=u.child.stateNode;break;case 1:m=u.child.stateNode}y1(u,z,m)}break;case 5:var Q=u.stateNode;if(m===null&&u.flags&4){m=Q;var te=u.memoizedProps;switch(u.type){case"button":case"input":case"select":case"textarea":te.autoFocus&&m.focus();break;case"img":te.src&&(m.src=te.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(u.memoizedState===null){var ue=u.alternate;if(ue!==null){var xe=ue.memoizedState;if(xe!==null){var ke=xe.dehydrated;ke!==null&&xn(ke)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}Yt||u.flags&512&&np(u)}catch(ve){ft(u,u.return,ve)}}if(u===i){_e=null;break}if(m=u.sibling,m!==null){m.return=u.return,_e=m;break}_e=u.return}}function yN(i){for(;_e!==null;){var u=_e;if(u===i){_e=null;break}var m=u.sibling;if(m!==null){m.return=u.return,_e=m;break}_e=u.return}}function wN(i){for(;_e!==null;){var u=_e;try{switch(u.tag){case 0:case 11:case 15:var m=u.return;try{fu(4,u)}catch(te){ft(u,m,te)}break;case 1:var w=u.stateNode;if(typeof w.componentDidMount=="function"){var _=u.return;try{w.componentDidMount()}catch(te){ft(u,_,te)}}var C=u.return;try{np(u)}catch(te){ft(u,C,te)}break;case 5:var z=u.return;try{np(u)}catch(te){ft(u,z,te)}}}catch(te){ft(u,u.return,te)}if(u===i){_e=null;break}var Q=u.sibling;if(Q!==null){Q.return=u.return,_e=Q;break}_e=u.return}}var N4=Math.ceil,pu=E.ReactCurrentDispatcher,ap=E.ReactCurrentOwner,Bn=E.ReactCurrentBatchConfig,Ve=0,It=null,vt=null,Bt=0,Nn=0,Bo=Ls(0),_t=0,pl=null,Ma=0,mu=0,op=0,ml=null,un=null,ip=0,qo=1/0,us=null,gu=!1,lp=null,Us=null,yu=!1,zs=null,wu=0,gl=0,cp=null,vu=-1,xu=0;function Jt(){return(Ve&6)!==0?Re():vu!==-1?vu:vu=Re()}function Ws(i){return(i.mode&1)===0?1:(Ve&2)!==0&&Bt!==0?Bt&-Bt:o4.transition!==null?(xu===0&&(xu=Rr()),xu):(i=Ue,i!==0||(i=window.event,i=i===void 0?16:Wi(i.type)),i)}function fr(i,u,m,w){if(50<gl)throw gl=0,cp=null,Error(n(185));pa(i,m,w),((Ve&2)===0||i!==It)&&(i===It&&((Ve&2)===0&&(mu|=m),_t===4&&Hs(i,Bt)),dn(i,w),m===1&&Ve===0&&(u.mode&1)===0&&(qo=Re()+500,Kc&&Ds()))}function dn(i,u){var m=i.callbackNode;Bi(i,u);var w=ha(i,i===It?Bt:0);if(w===0)m!==null&&Tr(m),i.callbackNode=null,i.callbackPriority=0;else if(u=w&-w,i.callbackPriority!==u){if(m!=null&&Tr(m),u===1)i.tag===0?a4(xN.bind(null,i)):a1(xN.bind(null,i)),t4(function(){(Ve&6)===0&&Ds()}),m=null;else{switch(Ac(w)){case 1:m=rn;break;case 4:m=Jr;break;case 16:m=Ht;break;case 536870912:m=sr;break;default:m=Ht}m=CN(m,vN.bind(null,i))}i.callbackPriority=u,i.callbackNode=m}}function vN(i,u){if(vu=-1,xu=0,(Ve&6)!==0)throw Error(n(327));var m=i.callbackNode;if(Uo()&&i.callbackNode!==m)return null;var w=ha(i,i===It?Bt:0);if(w===0)return null;if((w&30)!==0||(w&i.expiredLanes)!==0||u)u=bu(i,w);else{u=w;var _=Ve;Ve|=2;var C=kN();(It!==i||Bt!==u)&&(us=null,qo=Re()+500,Ia(i,u));do try{_4();break}catch(Q){bN(i,Q)}while(!0);Ef(),pu.current=C,Ve=_,vt!==null?u=0:(It=null,Bt=0,u=_t)}if(u!==0){if(u===2&&(_=fa(i),_!==0&&(w=_,u=up(i,_))),u===1)throw m=pl,Ia(i,0),Hs(i,w),dn(i,Re()),m;if(u===6)Hs(i,w);else{if(_=i.current.alternate,(w&30)===0&&!j4(_)&&(u=bu(i,w),u===2&&(C=fa(i),C!==0&&(w=C,u=up(i,C))),u===1))throw m=pl,Ia(i,0),Hs(i,w),dn(i,Re()),m;switch(i.finishedWork=_,i.finishedLanes=w,u){case 0:case 1:throw Error(n(345));case 2:Oa(i,un,us);break;case 3:if(Hs(i,w),(w&130023424)===w&&(u=ip+500-Re(),10<u)){if(ha(i,0)!==0)break;if(_=i.suspendedLanes,(_&w)!==w){Jt(),i.pingedLanes|=i.suspendedLanes&_;break}i.timeoutHandle=gf(Oa.bind(null,i,un,us),u);break}Oa(i,un,us);break;case 4:if(Hs(i,w),(w&4194240)===w)break;for(u=i.eventTimes,_=-1;0<w;){var z=31-an(w);C=1<<z,z=u[z],z>_&&(_=z),w&=~C}if(w=_,w=Re()-w,w=(120>w?120:480>w?480:1080>w?1080:1920>w?1920:3e3>w?3e3:4320>w?4320:1960*N4(w/1960))-w,10<w){i.timeoutHandle=gf(Oa.bind(null,i,un,us),w);break}Oa(i,un,us);break;case 5:Oa(i,un,us);break;default:throw Error(n(329))}}}return dn(i,Re()),i.callbackNode===m?vN.bind(null,i):null}function up(i,u){var m=ml;return i.current.memoizedState.isDehydrated&&(Ia(i,u).flags|=256),i=bu(i,u),i!==2&&(u=un,un=m,u!==null&&dp(u)),i}function dp(i){un===null?un=i:un.push.apply(un,i)}function j4(i){for(var u=i;;){if(u.flags&16384){var m=u.updateQueue;if(m!==null&&(m=m.stores,m!==null))for(var w=0;w<m.length;w++){var _=m[w],C=_.getSnapshot;_=_.value;try{if(!lr(C(),_))return!1}catch{return!1}}}if(m=u.child,u.subtreeFlags&16384&&m!==null)m.return=u,u=m;else{if(u===i)break;for(;u.sibling===null;){if(u.return===null||u.return===i)return!0;u=u.return}u.sibling.return=u.return,u=u.sibling}}return!0}function Hs(i,u){for(u&=~op,u&=~mu,i.suspendedLanes|=u,i.pingedLanes&=~u,i=i.expirationTimes;0<u;){var m=31-an(u),w=1<<m;i[m]=-1,u&=~w}}function xN(i){if((Ve&6)!==0)throw Error(n(327));Uo();var u=ha(i,0);if((u&1)===0)return dn(i,Re()),null;var m=bu(i,u);if(i.tag!==0&&m===2){var w=fa(i);w!==0&&(u=w,m=up(i,w))}if(m===1)throw m=pl,Ia(i,0),Hs(i,u),dn(i,Re()),m;if(m===6)throw Error(n(345));return i.finishedWork=i.current.alternate,i.finishedLanes=u,Oa(i,un,us),dn(i,Re()),null}function hp(i,u){var m=Ve;Ve|=1;try{return i(u)}finally{Ve=m,Ve===0&&(qo=Re()+500,Kc&&Ds())}}function $a(i){zs!==null&&zs.tag===0&&(Ve&6)===0&&Uo();var u=Ve;Ve|=1;var m=Bn.transition,w=Ue;try{if(Bn.transition=null,Ue=1,i)return i()}finally{Ue=w,Bn.transition=m,Ve=u,(Ve&6)===0&&Ds()}}function fp(){Nn=Bo.current,rt(Bo)}function Ia(i,u){i.finishedWork=null,i.finishedLanes=0;var m=i.timeoutHandle;if(m!==-1&&(i.timeoutHandle=-1,e4(m)),vt!==null)for(m=vt.return;m!==null;){var w=m;switch(kf(w),w.tag){case 1:w=w.type.childContextTypes,w!=null&&Vc();break;case 3:Po(),rt(on),rt(Vt),Of();break;case 5:$f(w);break;case 4:Po();break;case 13:rt(ut);break;case 19:rt(ut);break;case 10:Cf(w.type._context);break;case 22:case 23:fp()}m=m.return}if(It=i,vt=i=Vs(i.current,null),Bt=Nn=u,_t=0,pl=null,op=mu=Ma=0,un=ml=null,Ta!==null){for(u=0;u<Ta.length;u++)if(m=Ta[u],w=m.interleaved,w!==null){m.interleaved=null;var _=w.next,C=m.pending;if(C!==null){var z=C.next;C.next=_,w.next=z}m.pending=w}Ta=null}return i}function bN(i,u){do{var m=vt;try{if(Ef(),su.current=lu,au){for(var w=dt.memoizedState;w!==null;){var _=w.queue;_!==null&&(_.pending=null),w=w.next}au=!1}if(Ra=0,$t=St=dt=null,ll=!1,cl=0,ap.current=null,m===null||m.return===null){_t=1,pl=u,vt=null;break}e:{var C=i,z=m.return,Q=m,te=u;if(u=Bt,Q.flags|=32768,te!==null&&typeof te=="object"&&typeof te.then=="function"){var ue=te,xe=Q,ke=xe.tag;if((xe.mode&1)===0&&(ke===0||ke===11||ke===15)){var ve=xe.alternate;ve?(xe.updateQueue=ve.updateQueue,xe.memoizedState=ve.memoizedState,xe.lanes=ve.lanes):(xe.updateQueue=null,xe.memoizedState=null)}var Se=V1(z);if(Se!==null){Se.flags&=-257,G1(Se,z,Q,C,u),Se.mode&1&&H1(C,ue,u),u=Se,te=ue;var Ee=u.updateQueue;if(Ee===null){var Ce=new Set;Ce.add(te),u.updateQueue=Ce}else Ee.add(te);break e}else{if((u&1)===0){H1(C,ue,u),pp();break e}te=Error(n(426))}}else if(at&&Q.mode&1){var yt=V1(z);if(yt!==null){(yt.flags&65536)===0&&(yt.flags|=256),G1(yt,z,Q,C,u),Sf(Do(te,Q));break e}}C=te=Do(te,Q),_t!==4&&(_t=2),ml===null?ml=[C]:ml.push(C),C=z;do{switch(C.tag){case 3:C.flags|=65536,u&=-u,C.lanes|=u;var ie=z1(C,te,u);g1(C,ie);break e;case 1:Q=te;var re=C.type,le=C.stateNode;if((C.flags&128)===0&&(typeof re.getDerivedStateFromError=="function"||le!==null&&typeof le.componentDidCatch=="function"&&(Us===null||!Us.has(le)))){C.flags|=65536,u&=-u,C.lanes|=u;var je=W1(C,Q,u);g1(C,je);break e}}C=C.return}while(C!==null)}jN(m)}catch(Te){u=Te,vt===m&&m!==null&&(vt=m=m.return);continue}break}while(!0)}function kN(){var i=pu.current;return pu.current=lu,i===null?lu:i}function pp(){(_t===0||_t===3||_t===2)&&(_t=4),It===null||(Ma&268435455)===0&&(mu&268435455)===0||Hs(It,Bt)}function bu(i,u){var m=Ve;Ve|=2;var w=kN();(It!==i||Bt!==u)&&(us=null,Ia(i,u));do try{S4();break}catch(_){bN(i,_)}while(!0);if(Ef(),Ve=m,pu.current=w,vt!==null)throw Error(n(261));return It=null,Bt=0,_t}function S4(){for(;vt!==null;)NN(vt)}function _4(){for(;vt!==null&&!Ar();)NN(vt)}function NN(i){var u=EN(i.alternate,i,Nn);i.memoizedProps=i.pendingProps,u===null?jN(i):vt=u,ap.current=null}function jN(i){var u=i;do{var m=u.alternate;if(i=u.return,(u.flags&32768)===0){if(m=w4(m,u,Nn),m!==null){vt=m;return}}else{if(m=v4(m,u),m!==null){m.flags&=32767,vt=m;return}if(i!==null)i.flags|=32768,i.subtreeFlags=0,i.deletions=null;else{_t=6,vt=null;return}}if(u=u.sibling,u!==null){vt=u;return}vt=u=i}while(u!==null);_t===0&&(_t=5)}function Oa(i,u,m){var w=Ue,_=Bn.transition;try{Bn.transition=null,Ue=1,E4(i,u,m,w)}finally{Bn.transition=_,Ue=w}return null}function E4(i,u,m,w){do Uo();while(zs!==null);if((Ve&6)!==0)throw Error(n(327));m=i.finishedWork;var _=i.finishedLanes;if(m===null)return null;if(i.finishedWork=null,i.finishedLanes=0,m===i.current)throw Error(n(177));i.callbackNode=null,i.callbackPriority=0;var C=m.lanes|m.childLanes;if(Yh(i,C),i===It&&(vt=It=null,Bt=0),(m.subtreeFlags&2064)===0&&(m.flags&2064)===0||yu||(yu=!0,CN(Ht,function(){return Uo(),null})),C=(m.flags&15990)!==0,(m.subtreeFlags&15990)!==0||C){C=Bn.transition,Bn.transition=null;var z=Ue;Ue=1;var Q=Ve;Ve|=4,ap.current=null,b4(i,m),pN(m,i),G3(pf),xa=!!ff,pf=ff=null,i.current=m,k4(m),be(),Ve=Q,Ue=z,Bn.transition=C}else i.current=m;if(yu&&(yu=!1,zs=i,wu=_),C=i.pendingLanes,C===0&&(Us=null),As(m.stateNode),dn(i,Re()),u!==null)for(w=i.onRecoverableError,m=0;m<u.length;m++)_=u[m],w(_.value,{componentStack:_.stack,digest:_.digest});if(gu)throw gu=!1,i=lp,lp=null,i;return(wu&1)!==0&&i.tag!==0&&Uo(),C=i.pendingLanes,(C&1)!==0?i===cp?gl++:(gl=0,cp=i):gl=0,Ds(),null}function Uo(){if(zs!==null){var i=Ac(wu),u=Bn.transition,m=Ue;try{if(Bn.transition=null,Ue=16>i?16:i,zs===null)var w=!1;else{if(i=zs,zs=null,wu=0,(Ve&6)!==0)throw Error(n(331));var _=Ve;for(Ve|=4,_e=i.current;_e!==null;){var C=_e,z=C.child;if((_e.flags&16)!==0){var Q=C.deletions;if(Q!==null){for(var te=0;te<Q.length;te++){var ue=Q[te];for(_e=ue;_e!==null;){var xe=_e;switch(xe.tag){case 0:case 11:case 15:fl(8,xe,C)}var ke=xe.child;if(ke!==null)ke.return=xe,_e=ke;else for(;_e!==null;){xe=_e;var ve=xe.sibling,Se=xe.return;if(cN(xe),xe===ue){_e=null;break}if(ve!==null){ve.return=Se,_e=ve;break}_e=Se}}}var Ee=C.alternate;if(Ee!==null){var Ce=Ee.child;if(Ce!==null){Ee.child=null;do{var yt=Ce.sibling;Ce.sibling=null,Ce=yt}while(Ce!==null)}}_e=C}}if((C.subtreeFlags&2064)!==0&&z!==null)z.return=C,_e=z;else e:for(;_e!==null;){if(C=_e,(C.flags&2048)!==0)switch(C.tag){case 0:case 11:case 15:fl(9,C,C.return)}var ie=C.sibling;if(ie!==null){ie.return=C.return,_e=ie;break e}_e=C.return}}var re=i.current;for(_e=re;_e!==null;){z=_e;var le=z.child;if((z.subtreeFlags&2064)!==0&&le!==null)le.return=z,_e=le;else e:for(z=re;_e!==null;){if(Q=_e,(Q.flags&2048)!==0)try{switch(Q.tag){case 0:case 11:case 15:fu(9,Q)}}catch(Te){ft(Q,Q.return,Te)}if(Q===z){_e=null;break e}var je=Q.sibling;if(je!==null){je.return=Q.return,_e=je;break e}_e=Q.return}}if(Ve=_,Ds(),sn&&typeof sn.onPostCommitFiberRoot=="function")try{sn.onPostCommitFiberRoot(On,i)}catch{}w=!0}return w}finally{Ue=m,Bn.transition=u}}return!1}function SN(i,u,m){u=Do(m,u),u=z1(i,u,1),i=Bs(i,u,1),u=Jt(),i!==null&&(pa(i,1,u),dn(i,u))}function ft(i,u,m){if(i.tag===3)SN(i,i,m);else for(;u!==null;){if(u.tag===3){SN(u,i,m);break}else if(u.tag===1){var w=u.stateNode;if(typeof u.type.getDerivedStateFromError=="function"||typeof w.componentDidCatch=="function"&&(Us===null||!Us.has(w))){i=Do(m,i),i=W1(u,i,1),u=Bs(u,i,1),i=Jt(),u!==null&&(pa(u,1,i),dn(u,i));break}}u=u.return}}function C4(i,u,m){var w=i.pingCache;w!==null&&w.delete(u),u=Jt(),i.pingedLanes|=i.suspendedLanes&m,It===i&&(Bt&m)===m&&(_t===4||_t===3&&(Bt&130023424)===Bt&&500>Re()-ip?Ia(i,0):op|=m),dn(i,u)}function _N(i,u){u===0&&((i.mode&1)===0?u=1:(u=ho,ho<<=1,(ho&130023424)===0&&(ho=4194304)));var m=Jt();i=is(i,u),i!==null&&(pa(i,u,m),dn(i,m))}function T4(i){var u=i.memoizedState,m=0;u!==null&&(m=u.retryLane),_N(i,m)}function A4(i,u){var m=0;switch(i.tag){case 13:var w=i.stateNode,_=i.memoizedState;_!==null&&(m=_.retryLane);break;case 19:w=i.stateNode;break;default:throw Error(n(314))}w!==null&&w.delete(u),_N(i,m)}var EN;EN=function(i,u,m){if(i!==null)if(i.memoizedProps!==u.pendingProps||on.current)cn=!0;else{if((i.lanes&m)===0&&(u.flags&128)===0)return cn=!1,y4(i,u,m);cn=(i.flags&131072)!==0}else cn=!1,at&&(u.flags&1048576)!==0&&o1(u,Xc,u.index);switch(u.lanes=0,u.tag){case 2:var w=u.type;du(i,u),i=u.pendingProps;var _=Ao(u,Vt.current);Lo(u,m),_=Df(null,u,w,i,_,m);var C=Ff();return u.flags|=1,typeof _=="object"&&_!==null&&typeof _.render=="function"&&_.$$typeof===void 0?(u.tag=1,u.memoizedState=null,u.updateQueue=null,ln(w)?(C=!0,Gc(u)):C=!1,u.memoizedState=_.state!==null&&_.state!==void 0?_.state:null,Rf(u),_.updater=cu,u.stateNode=_,_._reactInternals=u,Hf(u,w,i,m),u=Yf(null,u,w,!0,C,m)):(u.tag=0,at&&C&&bf(u),Zt(null,u,_,m),u=u.child),u;case 16:w=u.elementType;e:{switch(du(i,u),i=u.pendingProps,_=w._init,w=_(w._payload),u.type=w,_=u.tag=M4(w),i=ur(w,i),_){case 0:u=Kf(null,u,w,i,m);break e;case 1:u=Q1(null,u,w,i,m);break e;case 11:u=K1(null,u,w,i,m);break e;case 14:u=Y1(null,u,w,ur(w.type,i),m);break e}throw Error(n(306,w,""))}return u;case 0:return w=u.type,_=u.pendingProps,_=u.elementType===w?_:ur(w,_),Kf(i,u,w,_,m);case 1:return w=u.type,_=u.pendingProps,_=u.elementType===w?_:ur(w,_),Q1(i,u,w,_,m);case 3:e:{if(eN(u),i===null)throw Error(n(387));w=u.pendingProps,C=u.memoizedState,_=C.element,m1(i,u),nu(u,w,null,m);var z=u.memoizedState;if(w=z.element,C.isDehydrated)if(C={element:w,isDehydrated:!1,cache:z.cache,pendingSuspenseBoundaries:z.pendingSuspenseBoundaries,transitions:z.transitions},u.updateQueue.baseState=C,u.memoizedState=C,u.flags&256){_=Do(Error(n(423)),u),u=tN(i,u,w,m,_);break e}else if(w!==_){_=Do(Error(n(424)),u),u=tN(i,u,w,m,_);break e}else for(kn=Os(u.stateNode.containerInfo.firstChild),bn=u,at=!0,cr=null,m=f1(u,null,w,m),u.child=m;m;)m.flags=m.flags&-3|4096,m=m.sibling;else{if($o(),w===_){u=cs(i,u,m);break e}Zt(i,u,w,m)}u=u.child}return u;case 5:return w1(u),i===null&&jf(u),w=u.type,_=u.pendingProps,C=i!==null?i.memoizedProps:null,z=_.children,mf(w,_)?z=null:C!==null&&mf(w,C)&&(u.flags|=32),J1(i,u),Zt(i,u,z,m),u.child;case 6:return i===null&&jf(u),null;case 13:return nN(i,u,m);case 4:return Mf(u,u.stateNode.containerInfo),w=u.pendingProps,i===null?u.child=Io(u,null,w,m):Zt(i,u,w,m),u.child;case 11:return w=u.type,_=u.pendingProps,_=u.elementType===w?_:ur(w,_),K1(i,u,w,_,m);case 7:return Zt(i,u,u.pendingProps,m),u.child;case 8:return Zt(i,u,u.pendingProps.children,m),u.child;case 12:return Zt(i,u,u.pendingProps.children,m),u.child;case 10:e:{if(w=u.type._context,_=u.pendingProps,C=u.memoizedProps,z=_.value,et(Qc,w._currentValue),w._currentValue=z,C!==null)if(lr(C.value,z)){if(C.children===_.children&&!on.current){u=cs(i,u,m);break e}}else for(C=u.child,C!==null&&(C.return=u);C!==null;){var Q=C.dependencies;if(Q!==null){z=C.child;for(var te=Q.firstContext;te!==null;){if(te.context===w){if(C.tag===1){te=ls(-1,m&-m),te.tag=2;var ue=C.updateQueue;if(ue!==null){ue=ue.shared;var xe=ue.pending;xe===null?te.next=te:(te.next=xe.next,xe.next=te),ue.pending=te}}C.lanes|=m,te=C.alternate,te!==null&&(te.lanes|=m),Tf(C.return,m,u),Q.lanes|=m;break}te=te.next}}else if(C.tag===10)z=C.type===u.type?null:C.child;else if(C.tag===18){if(z=C.return,z===null)throw Error(n(341));z.lanes|=m,Q=z.alternate,Q!==null&&(Q.lanes|=m),Tf(z,m,u),z=C.sibling}else z=C.child;if(z!==null)z.return=C;else for(z=C;z!==null;){if(z===u){z=null;break}if(C=z.sibling,C!==null){C.return=z.return,z=C;break}z=z.return}C=z}Zt(i,u,_.children,m),u=u.child}return u;case 9:return _=u.type,w=u.pendingProps.children,Lo(u,m),_=Dn(_),w=w(_),u.flags|=1,Zt(i,u,w,m),u.child;case 14:return w=u.type,_=ur(w,u.pendingProps),_=ur(w.type,_),Y1(i,u,w,_,m);case 15:return X1(i,u,u.type,u.pendingProps,m);case 17:return w=u.type,_=u.pendingProps,_=u.elementType===w?_:ur(w,_),du(i,u),u.tag=1,ln(w)?(i=!0,Gc(u)):i=!1,Lo(u,m),q1(u,w,_),Hf(u,w,_,m),Yf(null,u,w,!0,i,m);case 19:return sN(i,u,m);case 22:return Z1(i,u,m)}throw Error(n(156,u.tag))};function CN(i,u){return Ts(i,u)}function R4(i,u,m,w){this.tag=i,this.key=m,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=u,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=w,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function qn(i,u,m,w){return new R4(i,u,m,w)}function mp(i){return i=i.prototype,!(!i||!i.isReactComponent)}function M4(i){if(typeof i=="function")return mp(i)?1:0;if(i!=null){if(i=i.$$typeof,i===M)return 11;if(i===P)return 14}return 2}function Vs(i,u){var m=i.alternate;return m===null?(m=qn(i.tag,u,i.key,i.mode),m.elementType=i.elementType,m.type=i.type,m.stateNode=i.stateNode,m.alternate=i,i.alternate=m):(m.pendingProps=u,m.type=i.type,m.flags=0,m.subtreeFlags=0,m.deletions=null),m.flags=i.flags&14680064,m.childLanes=i.childLanes,m.lanes=i.lanes,m.child=i.child,m.memoizedProps=i.memoizedProps,m.memoizedState=i.memoizedState,m.updateQueue=i.updateQueue,u=i.dependencies,m.dependencies=u===null?null:{lanes:u.lanes,firstContext:u.firstContext},m.sibling=i.sibling,m.index=i.index,m.ref=i.ref,m}function ku(i,u,m,w,_,C){var z=2;if(w=i,typeof i=="function")mp(i)&&(z=1);else if(typeof i=="string")z=5;else e:switch(i){case A:return La(m.children,_,C,u);case q:z=8,_|=8;break;case $:return i=qn(12,m,u,_|2),i.elementType=$,i.lanes=C,i;case F:return i=qn(13,m,u,_),i.elementType=F,i.lanes=C,i;case T:return i=qn(19,m,u,_),i.elementType=T,i.lanes=C,i;case G:return Nu(m,_,C,u);default:if(typeof i=="object"&&i!==null)switch(i.$$typeof){case B:z=10;break e;case L:z=9;break e;case M:z=11;break e;case P:z=14;break e;case O:z=16,w=null;break e}throw Error(n(130,i==null?i:typeof i,""))}return u=qn(z,m,u,_),u.elementType=i,u.type=w,u.lanes=C,u}function La(i,u,m,w){return i=qn(7,i,w,u),i.lanes=m,i}function Nu(i,u,m,w){return i=qn(22,i,w,u),i.elementType=G,i.lanes=m,i.stateNode={isHidden:!1},i}function gp(i,u,m){return i=qn(6,i,null,u),i.lanes=m,i}function yp(i,u,m){return u=qn(4,i.children!==null?i.children:[],i.key,u),u.lanes=m,u.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},u}function $4(i,u,m,w,_){this.tag=u,this.containerInfo=i,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=qi(0),this.expirationTimes=qi(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=qi(0),this.identifierPrefix=w,this.onRecoverableError=_,this.mutableSourceEagerHydrationData=null}function wp(i,u,m,w,_,C,z,Q,te){return i=new $4(i,u,m,Q,te),u===1?(u=1,C===!0&&(u|=8)):u=0,C=qn(3,null,null,u),i.current=C,C.stateNode=i,C.memoizedState={element:w,isDehydrated:m,cache:null,transitions:null,pendingSuspenseBoundaries:null},Rf(C),i}function I4(i,u,m){var w=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:I,key:w==null?null:""+w,children:i,containerInfo:u,implementation:m}}function TN(i){if(!i)return Ps;i=i._reactInternals;e:{if(nn(i)!==i||i.tag!==1)throw Error(n(170));var u=i;do{switch(u.tag){case 3:u=u.stateNode.context;break e;case 1:if(ln(u.type)){u=u.stateNode.__reactInternalMemoizedMergedChildContext;break e}}u=u.return}while(u!==null);throw Error(n(171))}if(i.tag===1){var m=i.type;if(ln(m))return r1(i,m,u)}return u}function AN(i,u,m,w,_,C,z,Q,te){return i=wp(m,w,!0,i,_,C,z,Q,te),i.context=TN(null),m=i.current,w=Jt(),_=Ws(m),C=ls(w,_),C.callback=u??null,Bs(m,C,_),i.current.lanes=_,pa(i,_,w),dn(i,w),i}function ju(i,u,m,w){var _=u.current,C=Jt(),z=Ws(_);return m=TN(m),u.context===null?u.context=m:u.pendingContext=m,u=ls(C,z),u.payload={element:i},w=w===void 0?null:w,w!==null&&(u.callback=w),i=Bs(_,u,z),i!==null&&(fr(i,_,z,C),tu(i,_,z)),z}function Su(i){if(i=i.current,!i.child)return null;switch(i.child.tag){case 5:return i.child.stateNode;default:return i.child.stateNode}}function RN(i,u){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var m=i.retryLane;i.retryLane=m!==0&&m<u?m:u}}function vp(i,u){RN(i,u),(i=i.alternate)&&RN(i,u)}function O4(){return null}var MN=typeof reportError=="function"?reportError:function(i){console.error(i)};function xp(i){this._internalRoot=i}_u.prototype.render=xp.prototype.render=function(i){var u=this._internalRoot;if(u===null)throw Error(n(409));ju(i,u,null,null)},_u.prototype.unmount=xp.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var u=i.containerInfo;$a(function(){ju(null,i,null,null)}),u[rs]=null}};function _u(i){this._internalRoot=i}_u.prototype.unstable_scheduleHydration=function(i){if(i){var u=Rc();i={blockedOn:null,target:i,priority:u};for(var m=0;m<ar.length&&u!==0&&u<ar[m].priority;m++);ar.splice(m,0,i),m===0&&Oc(i)}};function bp(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11)}function Eu(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11&&(i.nodeType!==8||i.nodeValue!==" react-mount-point-unstable "))}function $N(){}function L4(i,u,m,w,_){if(_){if(typeof w=="function"){var C=w;w=function(){var ue=Su(z);C.call(ue)}}var z=AN(u,w,i,0,null,!1,!1,"",$N);return i._reactRootContainer=z,i[rs]=z.current,el(i.nodeType===8?i.parentNode:i),$a(),z}for(;_=i.lastChild;)i.removeChild(_);if(typeof w=="function"){var Q=w;w=function(){var ue=Su(te);Q.call(ue)}}var te=wp(i,0,!1,null,null,!1,!1,"",$N);return i._reactRootContainer=te,i[rs]=te.current,el(i.nodeType===8?i.parentNode:i),$a(function(){ju(u,te,m,w)}),te}function Cu(i,u,m,w,_){var C=m._reactRootContainer;if(C){var z=C;if(typeof _=="function"){var Q=_;_=function(){var te=Su(z);Q.call(te)}}ju(u,z,i,_)}else z=L4(m,u,i,_,w);return Su(z)}Ui=function(i){switch(i.tag){case 3:var u=i.stateNode;if(u.current.memoizedState.isDehydrated){var m=da(u.pendingLanes);m!==0&&(fo(u,m|1),dn(u,Re()),(Ve&6)===0&&(qo=Re()+500,Ds()))}break;case 13:$a(function(){var w=is(i,1);if(w!==null){var _=Jt();fr(w,i,1,_)}}),vp(i,1)}},po=function(i){if(i.tag===13){var u=is(i,134217728);if(u!==null){var m=Jt();fr(u,i,134217728,m)}vp(i,134217728)}},mo=function(i){if(i.tag===13){var u=Ws(i),m=is(i,u);if(m!==null){var w=Jt();fr(m,i,u,w)}vp(i,u)}},Rc=function(){return Ue},Mc=function(i,u){var m=Ue;try{return Ue=i,u()}finally{Ue=m}},Rt=function(i,u,m){switch(u){case"input":if(me(i,m),u=m.name,m.type==="radio"&&u!=null){for(m=i;m.parentNode;)m=m.parentNode;for(m=m.querySelectorAll("input[name="+JSON.stringify(""+u)+'][type="radio"]'),u=0;u<m.length;u++){var w=m[u];if(w!==i&&w.form===i.form){var _=Hc(w);if(!_)throw Error(n(90));ye(w),me(w,_)}}}break;case"textarea":Be(i,m);break;case"select":u=m.value,u!=null&&we(i,!!m.multiple,u,!1)}},yn=hp,Qn=$a;var P4={usingClientEntryPoint:!1,Events:[rl,Co,Hc,jt,Jn,hp]},yl={findFiberByHostInstance:Sa,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},D4={bundleType:yl.bundleType,version:yl.version,rendererPackageName:yl.rendererPackageName,rendererConfig:yl.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:E.ReactCurrentDispatcher,findHostInstanceByFiber:function(i){return i=nr(i),i===null?null:i.stateNode},findFiberByHostInstance:yl.findFiberByHostInstance||O4,findHostInstancesForRefresh:null,scheduleRefresh:null,scheduleRoot:null,setRefreshHandler:null,getCurrentFiber:null,reconcilerVersion:"18.3.1-next-f1338f8080-20240426"};if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__<"u"){var Tu=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Tu.isDisabled&&Tu.supportsFiber)try{On=Tu.inject(D4),sn=Tu}catch{}}return hn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=P4,hn.createPortal=function(i,u){var m=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!bp(u))throw Error(n(200));return I4(i,u,null,m)},hn.createRoot=function(i,u){if(!bp(i))throw Error(n(299));var m=!1,w="",_=MN;return u!=null&&(u.unstable_strictMode===!0&&(m=!0),u.identifierPrefix!==void 0&&(w=u.identifierPrefix),u.onRecoverableError!==void 0&&(_=u.onRecoverableError)),u=wp(i,1,!1,null,null,m,!1,w,_),i[rs]=u.current,el(i.nodeType===8?i.parentNode:i),new xp(u)},hn.findDOMNode=function(i){if(i==null)return null;if(i.nodeType===1)return i;var u=i._reactInternals;if(u===void 0)throw typeof i.render=="function"?Error(n(188)):(i=Object.keys(i).join(","),Error(n(268,i)));return i=nr(u),i=i===null?null:i.stateNode,i},hn.flushSync=function(i){return $a(i)},hn.hydrate=function(i,u,m){if(!Eu(u))throw Error(n(200));return Cu(null,i,u,!0,m)},hn.hydrateRoot=function(i,u,m){if(!bp(i))throw Error(n(405));var w=m!=null&&m.hydratedSources||null,_=!1,C="",z=MN;if(m!=null&&(m.unstable_strictMode===!0&&(_=!0),m.identifierPrefix!==void 0&&(C=m.identifierPrefix),m.onRecoverableError!==void 0&&(z=m.onRecoverableError)),u=AN(u,null,i,1,m??null,_,!1,C,z),i[rs]=u.current,el(i),w)for(i=0;i<w.length;i++)m=w[i],_=m._getVersion,_=_(m._source),u.mutableSourceEagerHydrationData==null?u.mutableSourceEagerHydrationData=[m,_]:u.mutableSourceEagerHydrationData.push(m,_);return new _u(u)},hn.render=function(i,u,m){if(!Eu(u))throw Error(n(200));return Cu(null,i,u,!1,m)},hn.unmountComponentAtNode=function(i){if(!Eu(i))throw Error(n(40));return i._reactRootContainer?($a(function(){Cu(null,null,i,!1,function(){i._reactRootContainer=null,i[rs]=null})}),!0):!1},hn.unstable_batchedUpdates=hp,hn.unstable_renderSubtreeIntoContainer=function(i,u,m,w){if(!Eu(m))throw Error(n(200));if(i==null||i._reactInternals===void 0)throw Error(n(38));return Cu(i,u,m,!1,w)},hn.version="18.3.1-next-f1338f8080-20240426",hn}var qN;function ZM(){if(qN)return Sp.exports;qN=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),Sp.exports=G4(),Sp.exports}var UN;function K4(){if(UN)return Ru;UN=1;var e=ZM();return Ru.createRoot=e.createRoot,Ru.hydrateRoot=e.hydrateRoot,Ru}var Y4=K4(),y=pc();const he=Vb(y);function Ut(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,r;n<e.length;n++)(r=Ut(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var Cp={exports:{}},Tp={},Ap={exports:{}},Rp={};/**
41
- * @license React
42
- * use-sync-external-store-shim.production.js
43
- *
44
- * Copyright (c) Meta Platforms, Inc. and affiliates.
45
- *
46
- * This source code is licensed under the MIT license found in the
47
- * LICENSE file in the root directory of this source tree.
48
- */var zN;function X4(){if(zN)return Rp;zN=1;var e=pc();function t(p,g){return p===g&&(p!==0||1/p===1/g)||p!==p&&g!==g}var n=typeof Object.is=="function"?Object.is:t,r=e.useState,s=e.useEffect,o=e.useLayoutEffect,l=e.useDebugValue;function c(p,g){var v=g(),j=r({inst:{value:v,getSnapshot:g}}),k=j[0].inst,x=j[1];return o(function(){k.value=v,k.getSnapshot=g,d(k)&&x({inst:k})},[p,v,g]),s(function(){return d(k)&&x({inst:k}),p(function(){d(k)&&x({inst:k})})},[p]),l(v),v}function d(p){var g=p.getSnapshot;p=p.value;try{var v=g();return!n(p,v)}catch{return!0}}function h(p,g){return g()}var f=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h:c;return Rp.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:f,Rp}var WN;function Z4(){return WN||(WN=1,Ap.exports=X4()),Ap.exports}/**
49
- * @license React
50
- * use-sync-external-store-shim/with-selector.production.js
51
- *
52
- * Copyright (c) Meta Platforms, Inc. and affiliates.
53
- *
54
- * This source code is licensed under the MIT license found in the
55
- * LICENSE file in the root directory of this source tree.
56
- */var HN;function J4(){if(HN)return Tp;HN=1;var e=pc(),t=Z4();function n(h,f){return h===f&&(h!==0||1/h===1/f)||h!==h&&f!==f}var r=typeof Object.is=="function"?Object.is:n,s=t.useSyncExternalStore,o=e.useRef,l=e.useEffect,c=e.useMemo,d=e.useDebugValue;return Tp.useSyncExternalStoreWithSelector=function(h,f,p,g,v){var j=o(null);if(j.current===null){var k={hasValue:!1,value:null};j.current=k}else k=j.current;j=c(function(){function N(I){if(!b){if(b=!0,S=I,I=g(I),v!==void 0&&k.hasValue){var A=k.value;if(v(A,I))return E=A}return E=I}if(A=E,r(S,I))return A;var q=g(I);return v!==void 0&&v(A,q)?(S=I,A):(S=I,E=q)}var b=!1,S,E,R=p===void 0?null:p;return[function(){return N(f())},R===null?void 0:function(){return N(R())}]},[f,p,g,v]);var x=s(h,j[0],j[1]);return l(function(){k.hasValue=!0,k.value=x},[x]),d(x),x},Tp}var VN;function Q4(){return VN||(VN=1,Cp.exports=J4()),Cp.exports}var eD=Q4();const tD=Vb(eD),nD={},GN=e=>{let t;const n=new Set,r=(f,p)=>{const g=typeof f=="function"?f(t):f;if(!Object.is(g,t)){const v=t;t=p??(typeof g!="object"||g===null)?g:Object.assign({},t,g),n.forEach(j=>j(t,v))}},s=()=>t,d={setState:r,getState:s,getInitialState:()=>h,subscribe:f=>(n.add(f),()=>n.delete(f)),destroy:()=>{(nD?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},h=t=e(r,s,d);return d},rD=e=>e?GN(e):GN,{useDebugValue:sD}=he,{useSyncExternalStoreWithSelector:aD}=tD,oD=e=>e;function JM(e,t=oD,n){const r=aD(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return sD(r),r}const KN=(e,t)=>{const n=rD(e),r=(s,o=t)=>JM(n,s,o);return Object.assign(r,n),r},iD=(e,t)=>e?KN(e,t):KN;function At(e,t){if(Object.is(e,t))return!0;if(typeof e!="object"||e===null||typeof t!="object"||t===null)return!1;if(e instanceof Map&&t instanceof Map){if(e.size!==t.size)return!1;for(const[r,s]of e)if(!Object.is(s,t.get(r)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const r of e)if(!t.has(r))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const r of n)if(!Object.prototype.hasOwnProperty.call(t,r)||!Object.is(e[r],t[r]))return!1;return!0}var lD={value:()=>{}};function Qd(){for(var e=0,t=arguments.length,n={},r;e<t;++e){if(!(r=arguments[e]+"")||r in n||/[\s.]/.test(r))throw new Error("illegal type: "+r);n[r]=[]}return new ad(n)}function ad(e){this._=e}function cD(e,t){return e.trim().split(/^|\s+/).map(function(n){var r="",s=n.indexOf(".");if(s>=0&&(r=n.slice(s+1),n=n.slice(0,s)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:r}})}ad.prototype=Qd.prototype={constructor:ad,on:function(e,t){var n=this._,r=cD(e+"",n),s,o=-1,l=r.length;if(arguments.length<2){for(;++o<l;)if((s=(e=r[o]).type)&&(s=uD(n[s],e.name)))return s;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++o<l;)if(s=(e=r[o]).type)n[s]=YN(n[s],e.name,t);else if(t==null)for(s in n)n[s]=YN(n[s],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new ad(e)},call:function(e,t){if((s=arguments.length-2)>0)for(var n=new Array(s),r=0,s,o;r<s;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(o=this._[e],r=0,s=o.length;r<s;++r)o[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],s=0,o=r.length;s<o;++s)r[s].value.apply(t,n)}};function uD(e,t){for(var n=0,r=e.length,s;n<r;++n)if((s=e[n]).name===t)return s.value}function YN(e,t,n){for(var r=0,s=e.length;r<s;++r)if(e[r].name===t){e[r]=lD,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var Rx="http://www.w3.org/1999/xhtml";const XN={svg:"http://www.w3.org/2000/svg",xhtml:Rx,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function eh(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),XN.hasOwnProperty(t)?{space:XN[t],local:e}:e}function dD(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Rx&&t.documentElement.namespaceURI===Rx?t.createElement(e):t.createElementNS(n,e)}}function hD(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function QM(e){var t=eh(e);return(t.local?hD:dD)(t)}function fD(){}function Gb(e){return e==null?fD:function(){return this.querySelector(e)}}function pD(e){typeof e!="function"&&(e=Gb(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var o=t[s],l=o.length,c=r[s]=new Array(l),d,h,f=0;f<l;++f)(d=o[f])&&(h=e.call(d,d.__data__,f,o))&&("__data__"in d&&(h.__data__=d.__data__),c[f]=h);return new Tn(r,this._parents)}function mD(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function gD(){return[]}function e2(e){return e==null?gD:function(){return this.querySelectorAll(e)}}function yD(e){return function(){return mD(e.apply(this,arguments))}}function wD(e){typeof e=="function"?e=yD(e):e=e2(e);for(var t=this._groups,n=t.length,r=[],s=[],o=0;o<n;++o)for(var l=t[o],c=l.length,d,h=0;h<c;++h)(d=l[h])&&(r.push(e.call(d,d.__data__,h,l)),s.push(d));return new Tn(r,s)}function t2(e){return function(){return this.matches(e)}}function n2(e){return function(t){return t.matches(e)}}var vD=Array.prototype.find;function xD(e){return function(){return vD.call(this.children,e)}}function bD(){return this.firstElementChild}function kD(e){return this.select(e==null?bD:xD(typeof e=="function"?e:n2(e)))}var ND=Array.prototype.filter;function jD(){return Array.from(this.children)}function SD(e){return function(){return ND.call(this.children,e)}}function _D(e){return this.selectAll(e==null?jD:SD(typeof e=="function"?e:n2(e)))}function ED(e){typeof e!="function"&&(e=t2(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var o=t[s],l=o.length,c=r[s]=[],d,h=0;h<l;++h)(d=o[h])&&e.call(d,d.__data__,h,o)&&c.push(d);return new Tn(r,this._parents)}function r2(e){return new Array(e.length)}function CD(){return new Tn(this._enter||this._groups.map(r2),this._parents)}function yd(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}yd.prototype={constructor:yd,appendChild:function(e){return this._parent.insertBefore(e,this._next)},insertBefore:function(e,t){return this._parent.insertBefore(e,t)},querySelector:function(e){return this._parent.querySelector(e)},querySelectorAll:function(e){return this._parent.querySelectorAll(e)}};function TD(e){return function(){return e}}function AD(e,t,n,r,s,o){for(var l=0,c,d=t.length,h=o.length;l<h;++l)(c=t[l])?(c.__data__=o[l],r[l]=c):n[l]=new yd(e,o[l]);for(;l<d;++l)(c=t[l])&&(s[l]=c)}function RD(e,t,n,r,s,o,l){var c,d,h=new Map,f=t.length,p=o.length,g=new Array(f),v;for(c=0;c<f;++c)(d=t[c])&&(g[c]=v=l.call(d,d.__data__,c,t)+"",h.has(v)?s[c]=d:h.set(v,d));for(c=0;c<p;++c)v=l.call(e,o[c],c,o)+"",(d=h.get(v))?(r[c]=d,d.__data__=o[c],h.delete(v)):n[c]=new yd(e,o[c]);for(c=0;c<f;++c)(d=t[c])&&h.get(g[c])===d&&(s[c]=d)}function MD(e){return e.__data__}function $D(e,t){if(!arguments.length)return Array.from(this,MD);var n=t?RD:AD,r=this._parents,s=this._groups;typeof e!="function"&&(e=TD(e));for(var o=s.length,l=new Array(o),c=new Array(o),d=new Array(o),h=0;h<o;++h){var f=r[h],p=s[h],g=p.length,v=ID(e.call(f,f&&f.__data__,h,r)),j=v.length,k=c[h]=new Array(j),x=l[h]=new Array(j),N=d[h]=new Array(g);n(f,p,k,x,N,v,t);for(var b=0,S=0,E,R;b<j;++b)if(E=k[b]){for(b>=S&&(S=b+1);!(R=x[S])&&++S<j;);E._next=R||null}}return l=new Tn(l,r),l._enter=c,l._exit=d,l}function ID(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function OD(){return new Tn(this._exit||this._groups.map(r2),this._parents)}function LD(e,t,n){var r=this.enter(),s=this,o=this.exit();return typeof e=="function"?(r=e(r),r&&(r=r.selection())):r=r.append(e+""),t!=null&&(s=t(s),s&&(s=s.selection())),n==null?o.remove():n(o),r&&s?r.merge(s).order():s}function PD(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,s=n.length,o=r.length,l=Math.min(s,o),c=new Array(s),d=0;d<l;++d)for(var h=n[d],f=r[d],p=h.length,g=c[d]=new Array(p),v,j=0;j<p;++j)(v=h[j]||f[j])&&(g[j]=v);for(;d<s;++d)c[d]=n[d];return new Tn(c,this._parents)}function DD(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],s=r.length-1,o=r[s],l;--s>=0;)(l=r[s])&&(o&&l.compareDocumentPosition(o)^4&&o.parentNode.insertBefore(l,o),o=l);return this}function FD(e){e||(e=BD);function t(p,g){return p&&g?e(p.__data__,g.__data__):!p-!g}for(var n=this._groups,r=n.length,s=new Array(r),o=0;o<r;++o){for(var l=n[o],c=l.length,d=s[o]=new Array(c),h,f=0;f<c;++f)(h=l[f])&&(d[f]=h);d.sort(t)}return new Tn(s,this._parents).order()}function BD(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function qD(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function UD(){return Array.from(this)}function zD(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],s=0,o=r.length;s<o;++s){var l=r[s];if(l)return l}return null}function WD(){let e=0;for(const t of this)++e;return e}function HD(){return!this.node()}function VD(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var s=t[n],o=0,l=s.length,c;o<l;++o)(c=s[o])&&e.call(c,c.__data__,o,s);return this}function GD(e){return function(){this.removeAttribute(e)}}function KD(e){return function(){this.removeAttributeNS(e.space,e.local)}}function YD(e,t){return function(){this.setAttribute(e,t)}}function XD(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function ZD(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function JD(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttributeNS(e.space,e.local):this.setAttributeNS(e.space,e.local,n)}}function QD(e,t){var n=eh(e);if(arguments.length<2){var r=this.node();return n.local?r.getAttributeNS(n.space,n.local):r.getAttribute(n)}return this.each((t==null?n.local?KD:GD:typeof t=="function"?n.local?JD:ZD:n.local?XD:YD)(n,t))}function s2(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function eF(e){return function(){this.style.removeProperty(e)}}function tF(e,t,n){return function(){this.style.setProperty(e,t,n)}}function nF(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function rF(e,t,n){return arguments.length>1?this.each((t==null?eF:typeof t=="function"?nF:tF)(e,t,n??"")):mi(this.node(),e)}function mi(e,t){return e.style.getPropertyValue(t)||s2(e).getComputedStyle(e,null).getPropertyValue(t)}function sF(e){return function(){delete this[e]}}function aF(e,t){return function(){this[e]=t}}function oF(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function iF(e,t){return arguments.length>1?this.each((t==null?sF:typeof t=="function"?oF:aF)(e,t)):this.node()[e]}function a2(e){return e.trim().split(/^|\s+/)}function Kb(e){return e.classList||new o2(e)}function o2(e){this._node=e,this._names=a2(e.getAttribute("class")||"")}o2.prototype={add:function(e){var t=this._names.indexOf(e);t<0&&(this._names.push(e),this._node.setAttribute("class",this._names.join(" ")))},remove:function(e){var t=this._names.indexOf(e);t>=0&&(this._names.splice(t,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(e){return this._names.indexOf(e)>=0}};function i2(e,t){for(var n=Kb(e),r=-1,s=t.length;++r<s;)n.add(t[r])}function l2(e,t){for(var n=Kb(e),r=-1,s=t.length;++r<s;)n.remove(t[r])}function lF(e){return function(){i2(this,e)}}function cF(e){return function(){l2(this,e)}}function uF(e,t){return function(){(t.apply(this,arguments)?i2:l2)(this,e)}}function dF(e,t){var n=a2(e+"");if(arguments.length<2){for(var r=Kb(this.node()),s=-1,o=n.length;++s<o;)if(!r.contains(n[s]))return!1;return!0}return this.each((typeof t=="function"?uF:t?lF:cF)(n,t))}function hF(){this.textContent=""}function fF(e){return function(){this.textContent=e}}function pF(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function mF(e){return arguments.length?this.each(e==null?hF:(typeof e=="function"?pF:fF)(e)):this.node().textContent}function gF(){this.innerHTML=""}function yF(e){return function(){this.innerHTML=e}}function wF(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function vF(e){return arguments.length?this.each(e==null?gF:(typeof e=="function"?wF:yF)(e)):this.node().innerHTML}function xF(){this.nextSibling&&this.parentNode.appendChild(this)}function bF(){return this.each(xF)}function kF(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function NF(){return this.each(kF)}function jF(e){var t=typeof e=="function"?e:QM(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function SF(){return null}function _F(e,t){var n=typeof e=="function"?e:QM(e),r=t==null?SF:typeof t=="function"?t:Gb(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function EF(){var e=this.parentNode;e&&e.removeChild(this)}function CF(){return this.each(EF)}function TF(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function AF(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function RF(e){return this.select(e?AF:TF)}function MF(e){return arguments.length?this.property("__data__",e):this.node().__data__}function $F(e){return function(t){e.call(this,t,this.__data__)}}function IF(e){return e.trim().split(/^|\s+/).map(function(t){var n="",r=t.indexOf(".");return r>=0&&(n=t.slice(r+1),t=t.slice(0,r)),{type:t,name:n}})}function OF(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,s=t.length,o;n<s;++n)o=t[n],(!e.type||o.type===e.type)&&o.name===e.name?this.removeEventListener(o.type,o.listener,o.options):t[++r]=o;++r?t.length=r:delete this.__on}}}function LF(e,t,n){return function(){var r=this.__on,s,o=$F(t);if(r){for(var l=0,c=r.length;l<c;++l)if((s=r[l]).type===e.type&&s.name===e.name){this.removeEventListener(s.type,s.listener,s.options),this.addEventListener(s.type,s.listener=o,s.options=n),s.value=t;return}}this.addEventListener(e.type,o,n),s={type:e.type,name:e.name,value:t,listener:o,options:n},r?r.push(s):this.__on=[s]}}function PF(e,t,n){var r=IF(e+""),s,o=r.length,l;if(arguments.length<2){var c=this.node().__on;if(c){for(var d=0,h=c.length,f;d<h;++d)for(s=0,f=c[d];s<o;++s)if((l=r[s]).type===f.type&&l.name===f.name)return f.value}return}for(c=t?LF:OF,s=0;s<o;++s)this.each(c(r[s],t,n));return this}function c2(e,t,n){var r=s2(e),s=r.CustomEvent;typeof s=="function"?s=new s(t,n):(s=r.document.createEvent("Event"),n?(s.initEvent(t,n.bubbles,n.cancelable),s.detail=n.detail):s.initEvent(t,!1,!1)),e.dispatchEvent(s)}function DF(e,t){return function(){return c2(this,e,t)}}function FF(e,t){return function(){return c2(this,e,t.apply(this,arguments))}}function BF(e,t){return this.each((typeof t=="function"?FF:DF)(e,t))}function*qF(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],s=0,o=r.length,l;s<o;++s)(l=r[s])&&(yield l)}var u2=[null];function Tn(e,t){this._groups=e,this._parents=t}function mc(){return new Tn([[document.documentElement]],u2)}function UF(){return this}Tn.prototype=mc.prototype={constructor:Tn,select:pD,selectAll:wD,selectChild:kD,selectChildren:_D,filter:ED,data:$D,enter:CD,exit:OD,join:LD,merge:PD,selection:UF,order:DD,sort:FD,call:qD,nodes:UD,node:zD,size:WD,empty:HD,each:VD,attr:QD,style:rF,property:iF,classed:dF,text:mF,html:vF,raise:bF,lower:NF,append:jF,insert:_F,remove:CF,clone:RF,datum:MF,on:PF,dispatch:BF,[Symbol.iterator]:qF};function Hn(e){return typeof e=="string"?new Tn([[document.querySelector(e)]],[document.documentElement]):new Tn([[e]],u2)}function zF(e){let t;for(;t=e.sourceEvent;)e=t;return e}function yr(e,t){if(e=zF(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var r=n.createSVGPoint();return r.x=e.clientX,r.y=e.clientY,r=r.matrixTransform(t.getScreenCTM().inverse()),[r.x,r.y]}if(t.getBoundingClientRect){var s=t.getBoundingClientRect();return[e.clientX-s.left-t.clientLeft,e.clientY-s.top-t.clientTop]}}return[e.pageX,e.pageY]}const WF={passive:!1},Hl={capture:!0,passive:!1};function Mp(e){e.stopImmediatePropagation()}function ci(e){e.preventDefault(),e.stopImmediatePropagation()}function d2(e){var t=e.document.documentElement,n=Hn(e).on("dragstart.drag",ci,Hl);"onselectstart"in t?n.on("selectstart.drag",ci,Hl):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function h2(e,t){var n=e.document.documentElement,r=Hn(e).on("dragstart.drag",null);t&&(r.on("click.drag",ci,Hl),setTimeout(function(){r.on("click.drag",null)},0)),"onselectstart"in n?r.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const Mu=e=>()=>e;function Mx(e,{sourceEvent:t,subject:n,target:r,identifier:s,active:o,x:l,y:c,dx:d,dy:h,dispatch:f}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:s,enumerable:!0,configurable:!0},active:{value:o,enumerable:!0,configurable:!0},x:{value:l,enumerable:!0,configurable:!0},y:{value:c,enumerable:!0,configurable:!0},dx:{value:d,enumerable:!0,configurable:!0},dy:{value:h,enumerable:!0,configurable:!0},_:{value:f}})}Mx.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function HF(e){return!e.ctrlKey&&!e.button}function VF(){return this.parentNode}function GF(e,t){return t??{x:e.x,y:e.y}}function KF(){return navigator.maxTouchPoints||"ontouchstart"in this}function YF(){var e=HF,t=VF,n=GF,r=KF,s={},o=Qd("start","drag","end"),l=0,c,d,h,f,p=0;function g(E){E.on("mousedown.drag",v).filter(r).on("touchstart.drag",x).on("touchmove.drag",N,WF).on("touchend.drag touchcancel.drag",b).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function v(E,R){if(!(f||!e.call(this,E,R))){var I=S(this,t.call(this,E,R),E,R,"mouse");I&&(Hn(E.view).on("mousemove.drag",j,Hl).on("mouseup.drag",k,Hl),d2(E.view),Mp(E),h=!1,c=E.clientX,d=E.clientY,I("start",E))}}function j(E){if(ci(E),!h){var R=E.clientX-c,I=E.clientY-d;h=R*R+I*I>p}s.mouse("drag",E)}function k(E){Hn(E.view).on("mousemove.drag mouseup.drag",null),h2(E.view,h),ci(E),s.mouse("end",E)}function x(E,R){if(e.call(this,E,R)){var I=E.changedTouches,A=t.call(this,E,R),q=I.length,$,B;for($=0;$<q;++$)(B=S(this,A,E,R,I[$].identifier,I[$]))&&(Mp(E),B("start",E,I[$]))}}function N(E){var R=E.changedTouches,I=R.length,A,q;for(A=0;A<I;++A)(q=s[R[A].identifier])&&(ci(E),q("drag",E,R[A]))}function b(E){var R=E.changedTouches,I=R.length,A,q;for(f&&clearTimeout(f),f=setTimeout(function(){f=null},500),A=0;A<I;++A)(q=s[R[A].identifier])&&(Mp(E),q("end",E,R[A]))}function S(E,R,I,A,q,$){var B=o.copy(),L=yr($||I,R),M,F,T;if((T=n.call(E,new Mx("beforestart",{sourceEvent:I,target:g,identifier:q,active:l,x:L[0],y:L[1],dx:0,dy:0,dispatch:B}),A))!=null)return M=T.x-L[0]||0,F=T.y-L[1]||0,function P(O,G,K){var U=L,H;switch(O){case"start":s[q]=P,H=l++;break;case"end":delete s[q],--l;case"drag":L=yr(K||G,R),H=l;break}B.call(O,E,new Mx(O,{sourceEvent:G,subject:T,target:g,identifier:q,active:H,x:L[0]+M,y:L[1]+F,dx:L[0]-U[0],dy:L[1]-U[1],dispatch:B}),A)}}return g.filter=function(E){return arguments.length?(e=typeof E=="function"?E:Mu(!!E),g):e},g.container=function(E){return arguments.length?(t=typeof E=="function"?E:Mu(E),g):t},g.subject=function(E){return arguments.length?(n=typeof E=="function"?E:Mu(E),g):n},g.touchable=function(E){return arguments.length?(r=typeof E=="function"?E:Mu(!!E),g):r},g.on=function(){var E=o.on.apply(o,arguments);return E===o?g:E},g.clickDistance=function(E){return arguments.length?(p=(E=+E)*E,g):Math.sqrt(p)},g}function Yb(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function f2(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function gc(){}var Vl=.7,wd=1/Vl,ui="\\s*([+-]?\\d+)\\s*",Gl="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",zr="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",XF=/^#([0-9a-f]{3,8})$/,ZF=new RegExp(`^rgb\\(${ui},${ui},${ui}\\)$`),JF=new RegExp(`^rgb\\(${zr},${zr},${zr}\\)$`),QF=new RegExp(`^rgba\\(${ui},${ui},${ui},${Gl}\\)$`),e5=new RegExp(`^rgba\\(${zr},${zr},${zr},${Gl}\\)$`),t5=new RegExp(`^hsl\\(${Gl},${zr},${zr}\\)$`),n5=new RegExp(`^hsla\\(${Gl},${zr},${zr},${Gl}\\)$`),ZN={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};Yb(gc,Kl,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:JN,formatHex:JN,formatHex8:r5,formatHsl:s5,formatRgb:QN,toString:QN});function JN(){return this.rgb().formatHex()}function r5(){return this.rgb().formatHex8()}function s5(){return p2(this).formatHsl()}function QN(){return this.rgb().formatRgb()}function Kl(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=XF.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?ej(t):n===3?new pn(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?$u(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?$u(t>>12&15|t>>8&240,t>>8&15|t>>4&240,t>>4&15|t&240,((t&15)<<4|t&15)/255):null):(t=ZF.exec(e))?new pn(t[1],t[2],t[3],1):(t=JF.exec(e))?new pn(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=QF.exec(e))?$u(t[1],t[2],t[3],t[4]):(t=e5.exec(e))?$u(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=t5.exec(e))?rj(t[1],t[2]/100,t[3]/100,1):(t=n5.exec(e))?rj(t[1],t[2]/100,t[3]/100,t[4]):ZN.hasOwnProperty(e)?ej(ZN[e]):e==="transparent"?new pn(NaN,NaN,NaN,0):null}function ej(e){return new pn(e>>16&255,e>>8&255,e&255,1)}function $u(e,t,n,r){return r<=0&&(e=t=n=NaN),new pn(e,t,n,r)}function a5(e){return e instanceof gc||(e=Kl(e)),e?(e=e.rgb(),new pn(e.r,e.g,e.b,e.opacity)):new pn}function $x(e,t,n,r){return arguments.length===1?a5(e):new pn(e,t,n,r??1)}function pn(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Yb(pn,$x,f2(gc,{brighter(e){return e=e==null?wd:Math.pow(wd,e),new pn(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Vl:Math.pow(Vl,e),new pn(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new pn(Ga(this.r),Ga(this.g),Ga(this.b),vd(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:tj,formatHex:tj,formatHex8:o5,formatRgb:nj,toString:nj}));function tj(){return`#${za(this.r)}${za(this.g)}${za(this.b)}`}function o5(){return`#${za(this.r)}${za(this.g)}${za(this.b)}${za((isNaN(this.opacity)?1:this.opacity)*255)}`}function nj(){const e=vd(this.opacity);return`${e===1?"rgb(":"rgba("}${Ga(this.r)}, ${Ga(this.g)}, ${Ga(this.b)}${e===1?")":`, ${e})`}`}function vd(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Ga(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function za(e){return e=Ga(e),(e<16?"0":"")+e.toString(16)}function rj(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new wr(e,t,n,r)}function p2(e){if(e instanceof wr)return new wr(e.h,e.s,e.l,e.opacity);if(e instanceof gc||(e=Kl(e)),!e)return new wr;if(e instanceof wr)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,s=Math.min(t,n,r),o=Math.max(t,n,r),l=NaN,c=o-s,d=(o+s)/2;return c?(t===o?l=(n-r)/c+(n<r)*6:n===o?l=(r-t)/c+2:l=(t-n)/c+4,c/=d<.5?o+s:2-o-s,l*=60):c=d>0&&d<1?0:l,new wr(l,c,d,e.opacity)}function i5(e,t,n,r){return arguments.length===1?p2(e):new wr(e,t,n,r??1)}function wr(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Yb(wr,i5,f2(gc,{brighter(e){return e=e==null?wd:Math.pow(wd,e),new wr(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Vl:Math.pow(Vl,e),new wr(this.h,this.s,this.l*e,this.opacity)},rgb(){var e=this.h%360+(this.h<0)*360,t=isNaN(e)||isNaN(this.s)?0:this.s,n=this.l,r=n+(n<.5?n:1-n)*t,s=2*n-r;return new pn($p(e>=240?e-240:e+120,s,r),$p(e,s,r),$p(e<120?e+240:e-120,s,r),this.opacity)},clamp(){return new wr(sj(this.h),Iu(this.s),Iu(this.l),vd(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const e=vd(this.opacity);return`${e===1?"hsl(":"hsla("}${sj(this.h)}, ${Iu(this.s)*100}%, ${Iu(this.l)*100}%${e===1?")":`, ${e})`}`}}));function sj(e){return e=(e||0)%360,e<0?e+360:e}function Iu(e){return Math.max(0,Math.min(1,e||0))}function $p(e,t,n){return(e<60?t+(n-t)*e/60:e<180?n:e<240?t+(n-t)*(240-e)/60:t)*255}const m2=e=>()=>e;function l5(e,t){return function(n){return e+n*t}}function c5(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(r){return Math.pow(e+r*t,n)}}function u5(e){return(e=+e)==1?g2:function(t,n){return n-t?c5(t,n,e):m2(isNaN(t)?n:t)}}function g2(e,t){var n=t-e;return n?l5(e,n):m2(isNaN(e)?t:e)}const aj=(function e(t){var n=u5(t);function r(s,o){var l=n((s=$x(s)).r,(o=$x(o)).r),c=n(s.g,o.g),d=n(s.b,o.b),h=g2(s.opacity,o.opacity);return function(f){return s.r=l(f),s.g=c(f),s.b=d(f),s.opacity=h(f),s+""}}return r.gamma=e,r})(1);function Xs(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var Ix=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Ip=new RegExp(Ix.source,"g");function d5(e){return function(){return e}}function h5(e){return function(t){return e(t)+""}}function f5(e,t){var n=Ix.lastIndex=Ip.lastIndex=0,r,s,o,l=-1,c=[],d=[];for(e=e+"",t=t+"";(r=Ix.exec(e))&&(s=Ip.exec(t));)(o=s.index)>n&&(o=t.slice(n,o),c[l]?c[l]+=o:c[++l]=o),(r=r[0])===(s=s[0])?c[l]?c[l]+=s:c[++l]=s:(c[++l]=null,d.push({i:l,x:Xs(r,s)})),n=Ip.lastIndex;return n<t.length&&(o=t.slice(n),c[l]?c[l]+=o:c[++l]=o),c.length<2?d[0]?h5(d[0].x):d5(t):(t=d.length,function(h){for(var f=0,p;f<t;++f)c[(p=d[f]).i]=p.x(h);return c.join("")})}var oj=180/Math.PI,Ox={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function y2(e,t,n,r,s,o){var l,c,d;return(l=Math.sqrt(e*e+t*t))&&(e/=l,t/=l),(d=e*n+t*r)&&(n-=e*d,r-=t*d),(c=Math.sqrt(n*n+r*r))&&(n/=c,r/=c,d/=c),e*r<t*n&&(e=-e,t=-t,d=-d,l=-l),{translateX:s,translateY:o,rotate:Math.atan2(t,e)*oj,skewX:Math.atan(d)*oj,scaleX:l,scaleY:c}}var Ou;function p5(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Ox:y2(t.a,t.b,t.c,t.d,t.e,t.f)}function m5(e){return e==null||(Ou||(Ou=document.createElementNS("http://www.w3.org/2000/svg","g")),Ou.setAttribute("transform",e),!(e=Ou.transform.baseVal.consolidate()))?Ox:(e=e.matrix,y2(e.a,e.b,e.c,e.d,e.e,e.f))}function w2(e,t,n,r){function s(h){return h.length?h.pop()+" ":""}function o(h,f,p,g,v,j){if(h!==p||f!==g){var k=v.push("translate(",null,t,null,n);j.push({i:k-4,x:Xs(h,p)},{i:k-2,x:Xs(f,g)})}else(p||g)&&v.push("translate("+p+t+g+n)}function l(h,f,p,g){h!==f?(h-f>180?f+=360:f-h>180&&(h+=360),g.push({i:p.push(s(p)+"rotate(",null,r)-2,x:Xs(h,f)})):f&&p.push(s(p)+"rotate("+f+r)}function c(h,f,p,g){h!==f?g.push({i:p.push(s(p)+"skewX(",null,r)-2,x:Xs(h,f)}):f&&p.push(s(p)+"skewX("+f+r)}function d(h,f,p,g,v,j){if(h!==p||f!==g){var k=v.push(s(v)+"scale(",null,",",null,")");j.push({i:k-4,x:Xs(h,p)},{i:k-2,x:Xs(f,g)})}else(p!==1||g!==1)&&v.push(s(v)+"scale("+p+","+g+")")}return function(h,f){var p=[],g=[];return h=e(h),f=e(f),o(h.translateX,h.translateY,f.translateX,f.translateY,p,g),l(h.rotate,f.rotate,p,g),c(h.skewX,f.skewX,p,g),d(h.scaleX,h.scaleY,f.scaleX,f.scaleY,p,g),h=f=null,function(v){for(var j=-1,k=g.length,x;++j<k;)p[(x=g[j]).i]=x.x(v);return p.join("")}}}var g5=w2(p5,"px, ","px)","deg)"),y5=w2(m5,", ",")",")"),w5=1e-12;function ij(e){return((e=Math.exp(e))+1/e)/2}function v5(e){return((e=Math.exp(e))-1/e)/2}function x5(e){return((e=Math.exp(2*e))-1)/(e+1)}const b5=(function e(t,n,r){function s(o,l){var c=o[0],d=o[1],h=o[2],f=l[0],p=l[1],g=l[2],v=f-c,j=p-d,k=v*v+j*j,x,N;if(k<w5)N=Math.log(g/h)/t,x=function(A){return[c+A*v,d+A*j,h*Math.exp(t*A*N)]};else{var b=Math.sqrt(k),S=(g*g-h*h+r*k)/(2*h*n*b),E=(g*g-h*h-r*k)/(2*g*n*b),R=Math.log(Math.sqrt(S*S+1)-S),I=Math.log(Math.sqrt(E*E+1)-E);N=(I-R)/t,x=function(A){var q=A*N,$=ij(R),B=h/(n*b)*($*x5(t*q+R)-v5(R));return[c+B*v,d+B*j,h*$/ij(t*q+R)]}}return x.duration=N*1e3*t/Math.SQRT2,x}return s.rho=function(o){var l=Math.max(.001,+o),c=l*l,d=c*c;return e(l,c,d)},s})(Math.SQRT2,2,4);var gi=0,Tl=0,vl=0,v2=1e3,xd,Al,bd=0,Ja=0,th=0,Yl=typeof performance=="object"&&performance.now?performance:Date,x2=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Xb(){return Ja||(x2(k5),Ja=Yl.now()+th)}function k5(){Ja=0}function kd(){this._call=this._time=this._next=null}kd.prototype=b2.prototype={constructor:kd,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Xb():+n)+(t==null?0:+t),!this._next&&Al!==this&&(Al?Al._next=this:xd=this,Al=this),this._call=e,this._time=n,Lx()},stop:function(){this._call&&(this._call=null,this._time=1/0,Lx())}};function b2(e,t,n){var r=new kd;return r.restart(e,t,n),r}function N5(){Xb(),++gi;for(var e=xd,t;e;)(t=Ja-e._time)>=0&&e._call.call(void 0,t),e=e._next;--gi}function lj(){Ja=(bd=Yl.now())+th,gi=Tl=0;try{N5()}finally{gi=0,S5(),Ja=0}}function j5(){var e=Yl.now(),t=e-bd;t>v2&&(th-=t,bd=e)}function S5(){for(var e,t=xd,n,r=1/0;t;)t._call?(r>t._time&&(r=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:xd=n);Al=e,Lx(r)}function Lx(e){if(!gi){Tl&&(Tl=clearTimeout(Tl));var t=e-Ja;t>24?(e<1/0&&(Tl=setTimeout(lj,e-Yl.now()-th)),vl&&(vl=clearInterval(vl))):(vl||(bd=Yl.now(),vl=setInterval(j5,v2)),gi=1,x2(lj))}}function cj(e,t,n){var r=new kd;return t=t==null?0:+t,r.restart(s=>{r.stop(),e(s+t)},t,n),r}var _5=Qd("start","end","cancel","interrupt"),E5=[],k2=0,uj=1,Px=2,od=3,dj=4,Dx=5,id=6;function nh(e,t,n,r,s,o){var l=e.__transition;if(!l)e.__transition={};else if(n in l)return;C5(e,n,{name:t,index:r,group:s,on:_5,tween:E5,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:k2})}function Zb(e,t){var n=Sr(e,t);if(n.state>k2)throw new Error("too late; already scheduled");return n}function Gr(e,t){var n=Sr(e,t);if(n.state>od)throw new Error("too late; already running");return n}function Sr(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function C5(e,t,n){var r=e.__transition,s;r[t]=n,n.timer=b2(o,0,n.time);function o(h){n.state=uj,n.timer.restart(l,n.delay,n.time),n.delay<=h&&l(h-n.delay)}function l(h){var f,p,g,v;if(n.state!==uj)return d();for(f in r)if(v=r[f],v.name===n.name){if(v.state===od)return cj(l);v.state===dj?(v.state=id,v.timer.stop(),v.on.call("interrupt",e,e.__data__,v.index,v.group),delete r[f]):+f<t&&(v.state=id,v.timer.stop(),v.on.call("cancel",e,e.__data__,v.index,v.group),delete r[f])}if(cj(function(){n.state===od&&(n.state=dj,n.timer.restart(c,n.delay,n.time),c(h))}),n.state=Px,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Px){for(n.state=od,s=new Array(g=n.tween.length),f=0,p=-1;f<g;++f)(v=n.tween[f].value.call(e,e.__data__,n.index,n.group))&&(s[++p]=v);s.length=p+1}}function c(h){for(var f=h<n.duration?n.ease.call(null,h/n.duration):(n.timer.restart(d),n.state=Dx,1),p=-1,g=s.length;++p<g;)s[p].call(e,f);n.state===Dx&&(n.on.call("end",e,e.__data__,n.index,n.group),d())}function d(){n.state=id,n.timer.stop(),delete r[t];for(var h in r)return;delete e.__transition}}function ld(e,t){var n=e.__transition,r,s,o=!0,l;if(n){t=t==null?null:t+"";for(l in n){if((r=n[l]).name!==t){o=!1;continue}s=r.state>Px&&r.state<Dx,r.state=id,r.timer.stop(),r.on.call(s?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[l]}o&&delete e.__transition}}function T5(e){return this.each(function(){ld(this,e)})}function A5(e,t){var n,r;return function(){var s=Gr(this,e),o=s.tween;if(o!==n){r=n=o;for(var l=0,c=r.length;l<c;++l)if(r[l].name===t){r=r.slice(),r.splice(l,1);break}}s.tween=r}}function R5(e,t,n){var r,s;if(typeof n!="function")throw new Error;return function(){var o=Gr(this,e),l=o.tween;if(l!==r){s=(r=l).slice();for(var c={name:t,value:n},d=0,h=s.length;d<h;++d)if(s[d].name===t){s[d]=c;break}d===h&&s.push(c)}o.tween=s}}function M5(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=Sr(this.node(),n).tween,s=0,o=r.length,l;s<o;++s)if((l=r[s]).name===e)return l.value;return null}return this.each((t==null?A5:R5)(n,e,t))}function Jb(e,t,n){var r=e._id;return e.each(function(){var s=Gr(this,r);(s.value||(s.value={}))[t]=n.apply(this,arguments)}),function(s){return Sr(s,r).value[t]}}function N2(e,t){var n;return(typeof t=="number"?Xs:t instanceof Kl?aj:(n=Kl(t))?(t=n,aj):f5)(e,t)}function $5(e){return function(){this.removeAttribute(e)}}function I5(e){return function(){this.removeAttributeNS(e.space,e.local)}}function O5(e,t,n){var r,s=n+"",o;return function(){var l=this.getAttribute(e);return l===s?null:l===r?o:o=t(r=l,n)}}function L5(e,t,n){var r,s=n+"",o;return function(){var l=this.getAttributeNS(e.space,e.local);return l===s?null:l===r?o:o=t(r=l,n)}}function P5(e,t,n){var r,s,o;return function(){var l,c=n(this),d;return c==null?void this.removeAttribute(e):(l=this.getAttribute(e),d=c+"",l===d?null:l===r&&d===s?o:(s=d,o=t(r=l,c)))}}function D5(e,t,n){var r,s,o;return function(){var l,c=n(this),d;return c==null?void this.removeAttributeNS(e.space,e.local):(l=this.getAttributeNS(e.space,e.local),d=c+"",l===d?null:l===r&&d===s?o:(s=d,o=t(r=l,c)))}}function F5(e,t){var n=eh(e),r=n==="transform"?y5:N2;return this.attrTween(e,typeof t=="function"?(n.local?D5:P5)(n,r,Jb(this,"attr."+e,t)):t==null?(n.local?I5:$5)(n):(n.local?L5:O5)(n,r,t))}function B5(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function q5(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function U5(e,t){var n,r;function s(){var o=t.apply(this,arguments);return o!==r&&(n=(r=o)&&q5(e,o)),n}return s._value=t,s}function z5(e,t){var n,r;function s(){var o=t.apply(this,arguments);return o!==r&&(n=(r=o)&&B5(e,o)),n}return s._value=t,s}function W5(e,t){var n="attr."+e;if(arguments.length<2)return(n=this.tween(n))&&n._value;if(t==null)return this.tween(n,null);if(typeof t!="function")throw new Error;var r=eh(e);return this.tween(n,(r.local?U5:z5)(r,t))}function H5(e,t){return function(){Zb(this,e).delay=+t.apply(this,arguments)}}function V5(e,t){return t=+t,function(){Zb(this,e).delay=t}}function G5(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?H5:V5)(t,e)):Sr(this.node(),t).delay}function K5(e,t){return function(){Gr(this,e).duration=+t.apply(this,arguments)}}function Y5(e,t){return t=+t,function(){Gr(this,e).duration=t}}function X5(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?K5:Y5)(t,e)):Sr(this.node(),t).duration}function Z5(e,t){if(typeof t!="function")throw new Error;return function(){Gr(this,e).ease=t}}function J5(e){var t=this._id;return arguments.length?this.each(Z5(t,e)):Sr(this.node(),t).ease}function Q5(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Gr(this,e).ease=n}}function e6(e){if(typeof e!="function")throw new Error;return this.each(Q5(this._id,e))}function t6(e){typeof e!="function"&&(e=t2(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var o=t[s],l=o.length,c=r[s]=[],d,h=0;h<l;++h)(d=o[h])&&e.call(d,d.__data__,h,o)&&c.push(d);return new vs(r,this._parents,this._name,this._id)}function n6(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,s=n.length,o=Math.min(r,s),l=new Array(r),c=0;c<o;++c)for(var d=t[c],h=n[c],f=d.length,p=l[c]=new Array(f),g,v=0;v<f;++v)(g=d[v]||h[v])&&(p[v]=g);for(;c<r;++c)l[c]=t[c];return new vs(l,this._parents,this._name,this._id)}function r6(e){return(e+"").trim().split(/^|\s+/).every(function(t){var n=t.indexOf(".");return n>=0&&(t=t.slice(0,n)),!t||t==="start"})}function s6(e,t,n){var r,s,o=r6(t)?Zb:Gr;return function(){var l=o(this,e),c=l.on;c!==r&&(s=(r=c).copy()).on(t,n),l.on=s}}function a6(e,t){var n=this._id;return arguments.length<2?Sr(this.node(),n).on.on(e):this.each(s6(n,e,t))}function o6(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function i6(){return this.on("end.remove",o6(this._id))}function l6(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Gb(e));for(var r=this._groups,s=r.length,o=new Array(s),l=0;l<s;++l)for(var c=r[l],d=c.length,h=o[l]=new Array(d),f,p,g=0;g<d;++g)(f=c[g])&&(p=e.call(f,f.__data__,g,c))&&("__data__"in f&&(p.__data__=f.__data__),h[g]=p,nh(h[g],t,n,g,h,Sr(f,n)));return new vs(o,this._parents,t,n)}function c6(e){var t=this._name,n=this._id;typeof e!="function"&&(e=e2(e));for(var r=this._groups,s=r.length,o=[],l=[],c=0;c<s;++c)for(var d=r[c],h=d.length,f,p=0;p<h;++p)if(f=d[p]){for(var g=e.call(f,f.__data__,p,d),v,j=Sr(f,n),k=0,x=g.length;k<x;++k)(v=g[k])&&nh(v,t,n,k,g,j);o.push(g),l.push(f)}return new vs(o,l,t,n)}var u6=mc.prototype.constructor;function d6(){return new u6(this._groups,this._parents)}function h6(e,t){var n,r,s;return function(){var o=mi(this,e),l=(this.style.removeProperty(e),mi(this,e));return o===l?null:o===n&&l===r?s:s=t(n=o,r=l)}}function j2(e){return function(){this.style.removeProperty(e)}}function f6(e,t,n){var r,s=n+"",o;return function(){var l=mi(this,e);return l===s?null:l===r?o:o=t(r=l,n)}}function p6(e,t,n){var r,s,o;return function(){var l=mi(this,e),c=n(this),d=c+"";return c==null&&(d=c=(this.style.removeProperty(e),mi(this,e))),l===d?null:l===r&&d===s?o:(s=d,o=t(r=l,c))}}function m6(e,t){var n,r,s,o="style."+t,l="end."+o,c;return function(){var d=Gr(this,e),h=d.on,f=d.value[o]==null?c||(c=j2(t)):void 0;(h!==n||s!==f)&&(r=(n=h).copy()).on(l,s=f),d.on=r}}function g6(e,t,n){var r=(e+="")=="transform"?g5:N2;return t==null?this.styleTween(e,h6(e,r)).on("end.style."+e,j2(e)):typeof t=="function"?this.styleTween(e,p6(e,r,Jb(this,"style."+e,t))).each(m6(this._id,e)):this.styleTween(e,f6(e,r,t),n).on("end.style."+e,null)}function y6(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function w6(e,t,n){var r,s;function o(){var l=t.apply(this,arguments);return l!==s&&(r=(s=l)&&y6(e,l,n)),r}return o._value=t,o}function v6(e,t,n){var r="style."+(e+="");if(arguments.length<2)return(r=this.tween(r))&&r._value;if(t==null)return this.tween(r,null);if(typeof t!="function")throw new Error;return this.tween(r,w6(e,t,n??""))}function x6(e){return function(){this.textContent=e}}function b6(e){return function(){var t=e(this);this.textContent=t??""}}function k6(e){return this.tween("text",typeof e=="function"?b6(Jb(this,"text",e)):x6(e==null?"":e+""))}function N6(e){return function(t){this.textContent=e.call(this,t)}}function j6(e){var t,n;function r(){var s=e.apply(this,arguments);return s!==n&&(t=(n=s)&&N6(s)),t}return r._value=e,r}function S6(e){var t="text";if(arguments.length<1)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;return this.tween(t,j6(e))}function _6(){for(var e=this._name,t=this._id,n=S2(),r=this._groups,s=r.length,o=0;o<s;++o)for(var l=r[o],c=l.length,d,h=0;h<c;++h)if(d=l[h]){var f=Sr(d,t);nh(d,e,n,h,l,{time:f.time+f.delay+f.duration,delay:0,duration:f.duration,ease:f.ease})}return new vs(r,this._parents,e,n)}function E6(){var e,t,n=this,r=n._id,s=n.size();return new Promise(function(o,l){var c={value:l},d={value:function(){--s===0&&o()}};n.each(function(){var h=Gr(this,r),f=h.on;f!==e&&(t=(e=f).copy(),t._.cancel.push(c),t._.interrupt.push(c),t._.end.push(d)),h.on=t}),s===0&&o()})}var C6=0;function vs(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function S2(){return++C6}var ds=mc.prototype;vs.prototype={constructor:vs,select:l6,selectAll:c6,selectChild:ds.selectChild,selectChildren:ds.selectChildren,filter:t6,merge:n6,selection:d6,transition:_6,call:ds.call,nodes:ds.nodes,node:ds.node,size:ds.size,empty:ds.empty,each:ds.each,on:a6,attr:F5,attrTween:W5,style:g6,styleTween:v6,text:k6,textTween:S6,remove:i6,tween:M5,delay:G5,duration:X5,ease:J5,easeVarying:e6,end:E6,[Symbol.iterator]:ds[Symbol.iterator]};function T6(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var A6={time:null,delay:0,duration:250,ease:T6};function R6(e,t){for(var n;!(n=e.__transition)||!(n=n[t]);)if(!(e=e.parentNode))throw new Error(`transition ${t} not found`);return n}function M6(e){var t,n;e instanceof vs?(t=e._id,e=e._name):(t=S2(),(n=A6).time=Xb(),e=e==null?null:e+"");for(var r=this._groups,s=r.length,o=0;o<s;++o)for(var l=r[o],c=l.length,d,h=0;h<c;++h)(d=l[h])&&nh(d,e,t,h,l,n||R6(d,t));return new vs(r,this._parents,e,t)}mc.prototype.interrupt=T5;mc.prototype.transition=M6;const Lu=e=>()=>e;function $6(e,{sourceEvent:t,target:n,transform:r,dispatch:s}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},target:{value:n,enumerable:!0,configurable:!0},transform:{value:r,enumerable:!0,configurable:!0},_:{value:s}})}function ms(e,t,n){this.k=e,this.x=t,this.y=n}ms.prototype={constructor:ms,scale:function(e){return e===1?this:new ms(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new ms(this.k,this.x+this.k*e,this.y+this.k*t)},apply:function(e){return[e[0]*this.k+this.x,e[1]*this.k+this.y]},applyX:function(e){return e*this.k+this.x},applyY:function(e){return e*this.k+this.y},invert:function(e){return[(e[0]-this.x)/this.k,(e[1]-this.y)/this.k]},invertX:function(e){return(e-this.x)/this.k},invertY:function(e){return(e-this.y)/this.k},rescaleX:function(e){return e.copy().domain(e.range().map(this.invertX,this).map(e.invert,e))},rescaleY:function(e){return e.copy().domain(e.range().map(this.invertY,this).map(e.invert,e))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var ys=new ms(1,0,0);ms.prototype;function Op(e){e.stopImmediatePropagation()}function xl(e){e.preventDefault(),e.stopImmediatePropagation()}function I6(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function O6(){var e=this;return e instanceof SVGElement?(e=e.ownerSVGElement||e,e.hasAttribute("viewBox")?(e=e.viewBox.baseVal,[[e.x,e.y],[e.x+e.width,e.y+e.height]]):[[0,0],[e.width.baseVal.value,e.height.baseVal.value]]):[[0,0],[e.clientWidth,e.clientHeight]]}function hj(){return this.__zoom||ys}function L6(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function P6(){return navigator.maxTouchPoints||"ontouchstart"in this}function D6(e,t,n){var r=e.invertX(t[0][0])-n[0][0],s=e.invertX(t[1][0])-n[1][0],o=e.invertY(t[0][1])-n[0][1],l=e.invertY(t[1][1])-n[1][1];return e.translate(s>r?(r+s)/2:Math.min(0,r)||Math.max(0,s),l>o?(o+l)/2:Math.min(0,o)||Math.max(0,l))}function _2(){var e=I6,t=O6,n=D6,r=L6,s=P6,o=[0,1/0],l=[[-1/0,-1/0],[1/0,1/0]],c=250,d=b5,h=Qd("start","zoom","end"),f,p,g,v=500,j=150,k=0,x=10;function N(T){T.property("__zoom",hj).on("wheel.zoom",q,{passive:!1}).on("mousedown.zoom",$).on("dblclick.zoom",B).filter(s).on("touchstart.zoom",L).on("touchmove.zoom",M).on("touchend.zoom touchcancel.zoom",F).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}N.transform=function(T,P,O,G){var K=T.selection?T.selection():T;K.property("__zoom",hj),T!==K?R(T,P,O,G):K.interrupt().each(function(){I(this,arguments).event(G).start().zoom(null,typeof P=="function"?P.apply(this,arguments):P).end()})},N.scaleBy=function(T,P,O,G){N.scaleTo(T,function(){var K=this.__zoom.k,U=typeof P=="function"?P.apply(this,arguments):P;return K*U},O,G)},N.scaleTo=function(T,P,O,G){N.transform(T,function(){var K=t.apply(this,arguments),U=this.__zoom,H=O==null?E(K):typeof O=="function"?O.apply(this,arguments):O,D=U.invert(H),V=typeof P=="function"?P.apply(this,arguments):P;return n(S(b(U,V),H,D),K,l)},O,G)},N.translateBy=function(T,P,O,G){N.transform(T,function(){return n(this.__zoom.translate(typeof P=="function"?P.apply(this,arguments):P,typeof O=="function"?O.apply(this,arguments):O),t.apply(this,arguments),l)},null,G)},N.translateTo=function(T,P,O,G,K){N.transform(T,function(){var U=t.apply(this,arguments),H=this.__zoom,D=G==null?E(U):typeof G=="function"?G.apply(this,arguments):G;return n(ys.translate(D[0],D[1]).scale(H.k).translate(typeof P=="function"?-P.apply(this,arguments):-P,typeof O=="function"?-O.apply(this,arguments):-O),U,l)},G,K)};function b(T,P){return P=Math.max(o[0],Math.min(o[1],P)),P===T.k?T:new ms(P,T.x,T.y)}function S(T,P,O){var G=P[0]-O[0]*T.k,K=P[1]-O[1]*T.k;return G===T.x&&K===T.y?T:new ms(T.k,G,K)}function E(T){return[(+T[0][0]+ +T[1][0])/2,(+T[0][1]+ +T[1][1])/2]}function R(T,P,O,G){T.on("start.zoom",function(){I(this,arguments).event(G).start()}).on("interrupt.zoom end.zoom",function(){I(this,arguments).event(G).end()}).tween("zoom",function(){var K=this,U=arguments,H=I(K,U).event(G),D=t.apply(K,U),V=O==null?E(D):typeof O=="function"?O.apply(K,U):O,J=Math.max(D[1][0]-D[0][0],D[1][1]-D[0][1]),W=K.__zoom,Z=typeof P=="function"?P.apply(K,U):P,Y=d(W.invert(V).concat(J/W.k),Z.invert(V).concat(J/Z.k));return function(X){if(X===1)X=Z;else{var ee=Y(X),ae=J/ee[2];X=new ms(ae,V[0]-ee[0]*ae,V[1]-ee[1]*ae)}H.zoom(null,X)}})}function I(T,P,O){return!O&&T.__zooming||new A(T,P)}function A(T,P){this.that=T,this.args=P,this.active=0,this.sourceEvent=null,this.extent=t.apply(T,P),this.taps=0}A.prototype={event:function(T){return T&&(this.sourceEvent=T),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(T,P){return this.mouse&&T!=="mouse"&&(this.mouse[1]=P.invert(this.mouse[0])),this.touch0&&T!=="touch"&&(this.touch0[1]=P.invert(this.touch0[0])),this.touch1&&T!=="touch"&&(this.touch1[1]=P.invert(this.touch1[0])),this.that.__zoom=P,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(T){var P=Hn(this.that).datum();h.call(T,this.that,new $6(T,{sourceEvent:this.sourceEvent,target:N,transform:this.that.__zoom,dispatch:h}),P)}};function q(T,...P){if(!e.apply(this,arguments))return;var O=I(this,P).event(T),G=this.__zoom,K=Math.max(o[0],Math.min(o[1],G.k*Math.pow(2,r.apply(this,arguments)))),U=yr(T);if(O.wheel)(O.mouse[0][0]!==U[0]||O.mouse[0][1]!==U[1])&&(O.mouse[1]=G.invert(O.mouse[0]=U)),clearTimeout(O.wheel);else{if(G.k===K)return;O.mouse=[U,G.invert(U)],ld(this),O.start()}xl(T),O.wheel=setTimeout(H,j),O.zoom("mouse",n(S(b(G,K),O.mouse[0],O.mouse[1]),O.extent,l));function H(){O.wheel=null,O.end()}}function $(T,...P){if(g||!e.apply(this,arguments))return;var O=T.currentTarget,G=I(this,P,!0).event(T),K=Hn(T.view).on("mousemove.zoom",V,!0).on("mouseup.zoom",J,!0),U=yr(T,O),H=T.clientX,D=T.clientY;d2(T.view),Op(T),G.mouse=[U,this.__zoom.invert(U)],ld(this),G.start();function V(W){if(xl(W),!G.moved){var Z=W.clientX-H,Y=W.clientY-D;G.moved=Z*Z+Y*Y>k}G.event(W).zoom("mouse",n(S(G.that.__zoom,G.mouse[0]=yr(W,O),G.mouse[1]),G.extent,l))}function J(W){K.on("mousemove.zoom mouseup.zoom",null),h2(W.view,G.moved),xl(W),G.event(W).end()}}function B(T,...P){if(e.apply(this,arguments)){var O=this.__zoom,G=yr(T.changedTouches?T.changedTouches[0]:T,this),K=O.invert(G),U=O.k*(T.shiftKey?.5:2),H=n(S(b(O,U),G,K),t.apply(this,P),l);xl(T),c>0?Hn(this).transition().duration(c).call(R,H,G,T):Hn(this).call(N.transform,H,G,T)}}function L(T,...P){if(e.apply(this,arguments)){var O=T.touches,G=O.length,K=I(this,P,T.changedTouches.length===G).event(T),U,H,D,V;for(Op(T),H=0;H<G;++H)D=O[H],V=yr(D,this),V=[V,this.__zoom.invert(V),D.identifier],K.touch0?!K.touch1&&K.touch0[2]!==V[2]&&(K.touch1=V,K.taps=0):(K.touch0=V,U=!0,K.taps=1+!!f);f&&(f=clearTimeout(f)),U&&(K.taps<2&&(p=V[0],f=setTimeout(function(){f=null},v)),ld(this),K.start())}}function M(T,...P){if(this.__zooming){var O=I(this,P).event(T),G=T.changedTouches,K=G.length,U,H,D,V;for(xl(T),U=0;U<K;++U)H=G[U],D=yr(H,this),O.touch0&&O.touch0[2]===H.identifier?O.touch0[0]=D:O.touch1&&O.touch1[2]===H.identifier&&(O.touch1[0]=D);if(H=O.that.__zoom,O.touch1){var J=O.touch0[0],W=O.touch0[1],Z=O.touch1[0],Y=O.touch1[1],X=(X=Z[0]-J[0])*X+(X=Z[1]-J[1])*X,ee=(ee=Y[0]-W[0])*ee+(ee=Y[1]-W[1])*ee;H=b(H,Math.sqrt(X/ee)),D=[(J[0]+Z[0])/2,(J[1]+Z[1])/2],V=[(W[0]+Y[0])/2,(W[1]+Y[1])/2]}else if(O.touch0)D=O.touch0[0],V=O.touch0[1];else return;O.zoom("touch",n(S(H,D,V),O.extent,l))}}function F(T,...P){if(this.__zooming){var O=I(this,P).event(T),G=T.changedTouches,K=G.length,U,H;for(Op(T),g&&clearTimeout(g),g=setTimeout(function(){g=null},v),U=0;U<K;++U)H=G[U],O.touch0&&O.touch0[2]===H.identifier?delete O.touch0:O.touch1&&O.touch1[2]===H.identifier&&delete O.touch1;if(O.touch1&&!O.touch0&&(O.touch0=O.touch1,delete O.touch1),O.touch0)O.touch0[1]=this.__zoom.invert(O.touch0[0]);else if(O.end(),O.taps===2&&(H=yr(H,this),Math.hypot(p[0]-H[0],p[1]-H[1])<x)){var D=Hn(this).on("dblclick.zoom");D&&D.apply(this,arguments)}}}return N.wheelDelta=function(T){return arguments.length?(r=typeof T=="function"?T:Lu(+T),N):r},N.filter=function(T){return arguments.length?(e=typeof T=="function"?T:Lu(!!T),N):e},N.touchable=function(T){return arguments.length?(s=typeof T=="function"?T:Lu(!!T),N):s},N.extent=function(T){return arguments.length?(t=typeof T=="function"?T:Lu([[+T[0][0],+T[0][1]],[+T[1][0],+T[1][1]]]),N):t},N.scaleExtent=function(T){return arguments.length?(o[0]=+T[0],o[1]=+T[1],N):[o[0],o[1]]},N.translateExtent=function(T){return arguments.length?(l[0][0]=+T[0][0],l[1][0]=+T[1][0],l[0][1]=+T[0][1],l[1][1]=+T[1][1],N):[[l[0][0],l[0][1]],[l[1][0],l[1][1]]]},N.constrain=function(T){return arguments.length?(n=T,N):n},N.duration=function(T){return arguments.length?(c=+T,N):c},N.interpolate=function(T){return arguments.length?(d=T,N):d},N.on=function(){var T=h.on.apply(h,arguments);return T===h?N:T},N.clickDistance=function(T){return arguments.length?(k=(T=+T)*T,N):Math.sqrt(k)},N.tapDistance=function(T){return arguments.length?(x=+T,N):x},N}var Pt=ZM();const rh=y.createContext(null),F6=rh.Provider,xs={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,t)=>`Couldn't create edge for ${e?"target":"source"} handle id: "${e?t.targetHandle:t.sourceHandle}", edge id: ${t.id}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`},E2=xs.error001();function He(e,t){const n=y.useContext(rh);if(n===null)throw new Error(E2);return JM(n,e,t)}const bt=()=>{const e=y.useContext(rh);if(e===null)throw new Error(E2);return y.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy}),[e])},B6=e=>e.userSelectionActive?"none":"all";function Qb({position:e,children:t,className:n,style:r,...s}){const o=He(B6),l=`${e}`.split("-");return he.createElement("div",{className:Ut(["react-flow__panel",n,...l]),style:{...r,pointerEvents:o},...s},t)}function q6({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:he.createElement(Qb,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://reactflow.dev/pro"},he.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}const U6=({x:e,y:t,label:n,labelStyle:r={},labelShowBg:s=!0,labelBgStyle:o={},labelBgPadding:l=[2,4],labelBgBorderRadius:c=2,children:d,className:h,...f})=>{const p=y.useRef(null),[g,v]=y.useState({x:0,y:0,width:0,height:0}),j=Ut(["react-flow__edge-textwrapper",h]);return y.useEffect(()=>{if(p.current){const k=p.current.getBBox();v({x:k.x,y:k.y,width:k.width,height:k.height})}},[n]),typeof n>"u"||!n?null:he.createElement("g",{transform:`translate(${e-g.width/2} ${t-g.height/2})`,className:j,visibility:g.width?"visible":"hidden",...f},s&&he.createElement("rect",{width:g.width+2*l[0],x:-l[0],y:-l[1],height:g.height+2*l[1],className:"react-flow__edge-textbg",style:o,rx:c,ry:c}),he.createElement("text",{className:"react-flow__edge-text",y:g.height/2,dy:"0.3em",ref:p,style:r},n),d)};var z6=y.memo(U6);const ek=e=>({width:e.offsetWidth,height:e.offsetHeight}),yi=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),tk=(e={x:0,y:0},t)=>({x:yi(e.x,t[0][0],t[1][0]),y:yi(e.y,t[0][1],t[1][1])}),fj=(e,t,n)=>e<t?yi(Math.abs(e-t),1,50)/50:e>n?-yi(Math.abs(e-n),1,50)/50:0,C2=(e,t)=>{const n=fj(e.x,35,t.width-35)*20,r=fj(e.y,35,t.height-35)*20;return[n,r]},T2=e=>{var t;return((t=e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},A2=(e,t)=>({x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x2,t.x2),y2:Math.max(e.y2,t.y2)}),Xl=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),R2=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),pj=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),W6=(e,t)=>R2(A2(Xl(e),Xl(t))),Fx=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),r=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*r)},H6=e=>Vn(e.width)&&Vn(e.height)&&Vn(e.x)&&Vn(e.y),Vn=e=>!isNaN(e)&&isFinite(e),pt=Symbol.for("internals"),M2=["Enter"," ","Escape"],V6=(e,t)=>{},G6=e=>"nativeEvent"in e;function Bx(e){var s,o;const t=G6(e)?e.nativeEvent:e,n=((o=(s=t.composedPath)==null?void 0:s.call(t))==null?void 0:o[0])||e.target;return["INPUT","SELECT","TEXTAREA"].includes(n==null?void 0:n.nodeName)||(n==null?void 0:n.hasAttribute("contenteditable"))||!!(n!=null&&n.closest(".nokey"))}const $2=e=>"clientX"in e,ra=(e,t)=>{var o,l;const n=$2(e),r=n?e.clientX:(o=e.touches)==null?void 0:o[0].clientX,s=n?e.clientY:(l=e.touches)==null?void 0:l[0].clientY;return{x:r-((t==null?void 0:t.left)??0),y:s-((t==null?void 0:t.top)??0)}},Nd=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0},yc=({id:e,path:t,labelX:n,labelY:r,label:s,labelStyle:o,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:p,markerStart:g,interactionWidth:v=20})=>he.createElement(he.Fragment,null,he.createElement("path",{id:e,style:f,d:t,fill:"none",className:"react-flow__edge-path",markerEnd:p,markerStart:g}),v&&he.createElement("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:v,className:"react-flow__edge-interaction"}),s&&Vn(n)&&Vn(r)?he.createElement(z6,{x:n,y:r,label:s,labelStyle:o,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h}):null);yc.displayName="BaseEdge";function bl(e,t,n){return n===void 0?n:r=>{const s=t().edges.find(o=>o.id===e);s&&n(r,{...s})}}function I2({sourceX:e,sourceY:t,targetX:n,targetY:r}){const s=Math.abs(n-e)/2,o=n<e?n+s:n-s,l=Math.abs(r-t)/2,c=r<t?r+l:r-l;return[o,c,s,l]}function O2({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:s,sourceControlY:o,targetControlX:l,targetControlY:c}){const d=e*.125+s*.375+l*.375+n*.125,h=t*.125+o*.375+c*.375+r*.125,f=Math.abs(d-e),p=Math.abs(h-t);return[d,h,f,p]}var Qa;(function(e){e.Strict="strict",e.Loose="loose"})(Qa||(Qa={}));var Wa;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Wa||(Wa={}));var Zl;(function(e){e.Partial="partial",e.Full="full"})(Zl||(Zl={}));var Js;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Js||(Js={}));var jd;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(jd||(jd={}));var Ae;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Ae||(Ae={}));function mj({pos:e,x1:t,y1:n,x2:r,y2:s}){return e===Ae.Left||e===Ae.Right?[.5*(t+r),n]:[t,.5*(n+s)]}function L2({sourceX:e,sourceY:t,sourcePosition:n=Ae.Bottom,targetX:r,targetY:s,targetPosition:o=Ae.Top}){const[l,c]=mj({pos:n,x1:e,y1:t,x2:r,y2:s}),[d,h]=mj({pos:o,x1:r,y1:s,x2:e,y2:t}),[f,p,g,v]=O2({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:l,sourceControlY:c,targetControlX:d,targetControlY:h});return[`M${e},${t} C${l},${c} ${d},${h} ${r},${s}`,f,p,g,v]}const nk=y.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:s=Ae.Bottom,targetPosition:o=Ae.Top,label:l,labelStyle:c,labelShowBg:d,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:g,markerEnd:v,markerStart:j,interactionWidth:k})=>{const[x,N,b]=L2({sourceX:e,sourceY:t,sourcePosition:s,targetX:n,targetY:r,targetPosition:o});return he.createElement(yc,{path:x,labelX:N,labelY:b,label:l,labelStyle:c,labelShowBg:d,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:g,markerEnd:v,markerStart:j,interactionWidth:k})});nk.displayName="SimpleBezierEdge";const gj={[Ae.Left]:{x:-1,y:0},[Ae.Right]:{x:1,y:0},[Ae.Top]:{x:0,y:-1},[Ae.Bottom]:{x:0,y:1}},K6=({source:e,sourcePosition:t=Ae.Bottom,target:n})=>t===Ae.Left||t===Ae.Right?e.x<n.x?{x:1,y:0}:{x:-1,y:0}:e.y<n.y?{x:0,y:1}:{x:0,y:-1},yj=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function Y6({source:e,sourcePosition:t=Ae.Bottom,target:n,targetPosition:r=Ae.Top,center:s,offset:o}){const l=gj[t],c=gj[r],d={x:e.x+l.x*o,y:e.y+l.y*o},h={x:n.x+c.x*o,y:n.y+c.y*o},f=K6({source:d,sourcePosition:t,target:h}),p=f.x!==0?"x":"y",g=f[p];let v=[],j,k;const x={x:0,y:0},N={x:0,y:0},[b,S,E,R]=I2({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(l[p]*c[p]===-1){j=s.x??b,k=s.y??S;const A=[{x:j,y:d.y},{x:j,y:h.y}],q=[{x:d.x,y:k},{x:h.x,y:k}];l[p]===g?v=p==="x"?A:q:v=p==="x"?q:A}else{const A=[{x:d.x,y:h.y}],q=[{x:h.x,y:d.y}];if(p==="x"?v=l.x===g?q:A:v=l.y===g?A:q,t===r){const F=Math.abs(e[p]-n[p]);if(F<=o){const T=Math.min(o-1,o-F);l[p]===g?x[p]=(d[p]>e[p]?-1:1)*T:N[p]=(h[p]>n[p]?-1:1)*T}}if(t!==r){const F=p==="x"?"y":"x",T=l[p]===c[F],P=d[F]>h[F],O=d[F]<h[F];(l[p]===1&&(!T&&P||T&&O)||l[p]!==1&&(!T&&O||T&&P))&&(v=p==="x"?A:q)}const $={x:d.x+x.x,y:d.y+x.y},B={x:h.x+N.x,y:h.y+N.y},L=Math.max(Math.abs($.x-v[0].x),Math.abs(B.x-v[0].x)),M=Math.max(Math.abs($.y-v[0].y),Math.abs(B.y-v[0].y));L>=M?(j=($.x+B.x)/2,k=v[0].y):(j=v[0].x,k=($.y+B.y)/2)}return[[e,{x:d.x+x.x,y:d.y+x.y},...v,{x:h.x+N.x,y:h.y+N.y},n],j,k,E,R]}function X6(e,t,n,r){const s=Math.min(yj(e,t)/2,yj(t,n)/2,r),{x:o,y:l}=t;if(e.x===o&&o===n.x||e.y===l&&l===n.y)return`L${o} ${l}`;if(e.y===l){const h=e.x<n.x?-1:1,f=e.y<n.y?1:-1;return`L ${o+s*h},${l}Q ${o},${l} ${o},${l+s*f}`}const c=e.x<n.x?1:-1,d=e.y<n.y?-1:1;return`L ${o},${l+s*d}Q ${o},${l} ${o+s*c},${l}`}function qx({sourceX:e,sourceY:t,sourcePosition:n=Ae.Bottom,targetX:r,targetY:s,targetPosition:o=Ae.Top,borderRadius:l=5,centerX:c,centerY:d,offset:h=20}){const[f,p,g,v,j]=Y6({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:s},targetPosition:o,center:{x:c,y:d},offset:h});return[f.reduce((x,N,b)=>{let S="";return b>0&&b<f.length-1?S=X6(f[b-1],N,f[b+1],l):S=`${b===0?"M":"L"}${N.x} ${N.y}`,x+=S,x},""),p,g,v,j]}const sh=y.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,label:s,labelStyle:o,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:f,sourcePosition:p=Ae.Bottom,targetPosition:g=Ae.Top,markerEnd:v,markerStart:j,pathOptions:k,interactionWidth:x})=>{const[N,b,S]=qx({sourceX:e,sourceY:t,sourcePosition:p,targetX:n,targetY:r,targetPosition:g,borderRadius:k==null?void 0:k.borderRadius,offset:k==null?void 0:k.offset});return he.createElement(yc,{path:N,labelX:b,labelY:S,label:s,labelStyle:o,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:v,markerStart:j,interactionWidth:x})});sh.displayName="SmoothStepEdge";const rk=y.memo(e=>{var t;return he.createElement(sh,{...e,pathOptions:y.useMemo(()=>{var n;return{borderRadius:0,offset:(n=e.pathOptions)==null?void 0:n.offset}},[(t=e.pathOptions)==null?void 0:t.offset])})});rk.displayName="StepEdge";function Z6({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[s,o,l,c]=I2({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,s,o,l,c]}const sk=y.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,label:s,labelStyle:o,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:p,markerStart:g,interactionWidth:v})=>{const[j,k,x]=Z6({sourceX:e,sourceY:t,targetX:n,targetY:r});return he.createElement(yc,{path:j,labelX:k,labelY:x,label:s,labelStyle:o,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:p,markerStart:g,interactionWidth:v})});sk.displayName="StraightEdge";function Pu(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function wj({pos:e,x1:t,y1:n,x2:r,y2:s,c:o}){switch(e){case Ae.Left:return[t-Pu(t-r,o),n];case Ae.Right:return[t+Pu(r-t,o),n];case Ae.Top:return[t,n-Pu(n-s,o)];case Ae.Bottom:return[t,n+Pu(s-n,o)]}}function ak({sourceX:e,sourceY:t,sourcePosition:n=Ae.Bottom,targetX:r,targetY:s,targetPosition:o=Ae.Top,curvature:l=.25}){const[c,d]=wj({pos:n,x1:e,y1:t,x2:r,y2:s,c:l}),[h,f]=wj({pos:o,x1:r,y1:s,x2:e,y2:t,c:l}),[p,g,v,j]=O2({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:c,sourceControlY:d,targetControlX:h,targetControlY:f});return[`M${e},${t} C${c},${d} ${h},${f} ${r},${s}`,p,g,v,j]}const Sd=y.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:s=Ae.Bottom,targetPosition:o=Ae.Top,label:l,labelStyle:c,labelShowBg:d,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:g,markerEnd:v,markerStart:j,pathOptions:k,interactionWidth:x})=>{const[N,b,S]=ak({sourceX:e,sourceY:t,sourcePosition:s,targetX:n,targetY:r,targetPosition:o,curvature:k==null?void 0:k.curvature});return he.createElement(yc,{path:N,labelX:b,labelY:S,label:l,labelStyle:c,labelShowBg:d,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:g,markerEnd:v,markerStart:j,interactionWidth:x})});Sd.displayName="BezierEdge";const ok=y.createContext(null),J6=ok.Provider;ok.Consumer;const Q6=()=>y.useContext(ok),eB=e=>"id"in e&&"source"in e&&"target"in e,tB=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`reactflow__edge-${e}${t||""}-${n}${r||""}`,Ux=(e,t)=>typeof e>"u"?"":typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`,nB=(e,t)=>t.some(n=>n.source===e.source&&n.target===e.target&&(n.sourceHandle===e.sourceHandle||!n.sourceHandle&&!e.sourceHandle)&&(n.targetHandle===e.targetHandle||!n.targetHandle&&!e.targetHandle)),rB=(e,t)=>{if(!e.source||!e.target)return t;let n;return eB(e)?n={...e}:n={...e,id:tB(e)},nB(n,t)?t:t.concat(n)},zx=({x:e,y:t},[n,r,s],o,[l,c])=>{const d={x:(e-n)/s,y:(t-r)/s};return o?{x:l*Math.round(d.x/l),y:c*Math.round(d.y/c)}:d},P2=({x:e,y:t},[n,r,s])=>({x:e*s+n,y:t*s+r}),Ka=(e,t=[0,0])=>{if(!e)return{x:0,y:0,positionAbsolute:{x:0,y:0}};const n=(e.width??0)*t[0],r=(e.height??0)*t[1],s={x:e.position.x-n,y:e.position.y-r};return{...s,positionAbsolute:e.positionAbsolute?{x:e.positionAbsolute.x-n,y:e.positionAbsolute.y-r}:s}},ah=(e,t=[0,0])=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((r,s)=>{const{x:o,y:l}=Ka(s,t).positionAbsolute;return A2(r,Xl({x:o,y:l,width:s.width||0,height:s.height||0}))},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return R2(n)},D2=(e,t,[n,r,s]=[0,0,1],o=!1,l=!1,c=[0,0])=>{const d={x:(t.x-n)/s,y:(t.y-r)/s,width:t.width/s,height:t.height/s},h=[];return e.forEach(f=>{const{width:p,height:g,selectable:v=!0,hidden:j=!1}=f;if(l&&!v||j)return!1;const{positionAbsolute:k}=Ka(f,c),x={x:k.x,y:k.y,width:p||0,height:g||0},N=Fx(d,x),b=typeof p>"u"||typeof g>"u"||p===null||g===null,S=o&&N>0,E=(p||0)*(g||0);(b||S||N>=E||f.dragging)&&h.push(f)}),h},F2=(e,t)=>{const n=e.map(r=>r.id);return t.filter(r=>n.includes(r.source)||n.includes(r.target))},B2=(e,t,n,r,s,o=.1)=>{const l=t/(e.width*(1+o)),c=n/(e.height*(1+o)),d=Math.min(l,c),h=yi(d,r,s),f=e.x+e.width/2,p=e.y+e.height/2,g=t/2-f*h,v=n/2-p*h;return{x:g,y:v,zoom:h}},Da=(e,t=0)=>e.transition().duration(t);function vj(e,t,n,r){return(t[n]||[]).reduce((s,o)=>{var l,c;return`${e.id}-${o.id}-${n}`!==r&&s.push({id:o.id||null,type:n,nodeId:e.id,x:(((l=e.positionAbsolute)==null?void 0:l.x)??0)+o.x+o.width/2,y:(((c=e.positionAbsolute)==null?void 0:c.y)??0)+o.y+o.height/2}),s},[])}function sB(e,t,n,r,s,o){const{x:l,y:c}=ra(e),h=t.elementsFromPoint(l,c).find(j=>j.classList.contains("react-flow__handle"));if(h){const j=h.getAttribute("data-nodeid");if(j){const k=ik(void 0,h),x=h.getAttribute("data-handleid"),N=o({nodeId:j,id:x,type:k});if(N){const b=s.find(S=>S.nodeId===j&&S.type===k&&S.id===x);return{handle:{id:x,type:k,nodeId:j,x:(b==null?void 0:b.x)||n.x,y:(b==null?void 0:b.y)||n.y},validHandleResult:N}}}}let f=[],p=1/0;if(s.forEach(j=>{const k=Math.sqrt((j.x-n.x)**2+(j.y-n.y)**2);if(k<=r){const x=o(j);k<=p&&(k<p?f=[{handle:j,validHandleResult:x}]:k===p&&f.push({handle:j,validHandleResult:x}),p=k)}}),!f.length)return{handle:null,validHandleResult:q2()};if(f.length===1)return f[0];const g=f.some(({validHandleResult:j})=>j.isValid),v=f.some(({handle:j})=>j.type==="target");return f.find(({handle:j,validHandleResult:k})=>v?j.type==="target":g?k.isValid:!0)||f[0]}const aB={source:null,target:null,sourceHandle:null,targetHandle:null},q2=()=>({handleDomNode:null,isValid:!1,connection:aB,endHandle:null});function U2(e,t,n,r,s,o,l){const c=s==="target",d=l.querySelector(`.react-flow__handle[data-id="${e==null?void 0:e.nodeId}-${e==null?void 0:e.id}-${e==null?void 0:e.type}"]`),h={...q2(),handleDomNode:d};if(d){const f=ik(void 0,d),p=d.getAttribute("data-nodeid"),g=d.getAttribute("data-handleid"),v=d.classList.contains("connectable"),j=d.classList.contains("connectableend"),k={source:c?p:n,sourceHandle:c?g:r,target:c?n:p,targetHandle:c?r:g};h.connection=k,v&&j&&(t===Qa.Strict?c&&f==="source"||!c&&f==="target":p!==n||g!==r)&&(h.endHandle={nodeId:p,handleId:g,type:f},h.isValid=o(k))}return h}function oB({nodes:e,nodeId:t,handleId:n,handleType:r}){return e.reduce((s,o)=>{if(o[pt]){const{handleBounds:l}=o[pt];let c=[],d=[];l&&(c=vj(o,l,"source",`${t}-${n}-${r}`),d=vj(o,l,"target",`${t}-${n}-${r}`)),s.push(...c,...d)}return s},[])}function ik(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function Lp(e){e==null||e.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function iB(e,t){let n=null;return t?n="valid":e&&!t&&(n="invalid"),n}function z2({event:e,handleId:t,nodeId:n,onConnect:r,isTarget:s,getState:o,setState:l,isValidConnection:c,edgeUpdaterType:d,onReconnectEnd:h}){const f=T2(e.target),{connectionMode:p,domNode:g,autoPanOnConnect:v,connectionRadius:j,onConnectStart:k,panBy:x,getNodes:N,cancelConnection:b}=o();let S=0,E;const{x:R,y:I}=ra(e),A=f==null?void 0:f.elementFromPoint(R,I),q=ik(d,A),$=g==null?void 0:g.getBoundingClientRect();if(!$||!q)return;let B,L=ra(e,$),M=!1,F=null,T=!1,P=null;const O=oB({nodes:N(),nodeId:n,handleId:t,handleType:q}),G=()=>{if(!v)return;const[H,D]=C2(L,$);x({x:H,y:D}),S=requestAnimationFrame(G)};l({connectionPosition:L,connectionStatus:null,connectionNodeId:n,connectionHandleId:t,connectionHandleType:q,connectionStartHandle:{nodeId:n,handleId:t,type:q},connectionEndHandle:null}),k==null||k(e,{nodeId:n,handleId:t,handleType:q});function K(H){const{transform:D}=o();L=ra(H,$);const{handle:V,validHandleResult:J}=sB(H,f,zx(L,D,!1,[1,1]),j,O,W=>U2(W,p,n,t,s?"target":"source",c,f));if(E=V,M||(G(),M=!0),P=J.handleDomNode,F=J.connection,T=J.isValid,l({connectionPosition:E&&T?P2({x:E.x,y:E.y},D):L,connectionStatus:iB(!!E,T),connectionEndHandle:J.endHandle}),!E&&!T&&!P)return Lp(B);F.source!==F.target&&P&&(Lp(B),B=P,P.classList.add("connecting","react-flow__handle-connecting"),P.classList.toggle("valid",T),P.classList.toggle("react-flow__handle-valid",T))}function U(H){var D,V;(E||P)&&F&&T&&(r==null||r(F)),(V=(D=o()).onConnectEnd)==null||V.call(D,H),d&&(h==null||h(H)),Lp(B),b(),cancelAnimationFrame(S),M=!1,T=!1,F=null,P=null,f.removeEventListener("mousemove",K),f.removeEventListener("mouseup",U),f.removeEventListener("touchmove",K),f.removeEventListener("touchend",U)}f.addEventListener("mousemove",K),f.addEventListener("mouseup",U),f.addEventListener("touchmove",K),f.addEventListener("touchend",U)}const xj=()=>!0,lB=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),cB=(e,t,n)=>r=>{const{connectionStartHandle:s,connectionEndHandle:o,connectionClickStartHandle:l}=r;return{connecting:(s==null?void 0:s.nodeId)===e&&(s==null?void 0:s.handleId)===t&&(s==null?void 0:s.type)===n||(o==null?void 0:o.nodeId)===e&&(o==null?void 0:o.handleId)===t&&(o==null?void 0:o.type)===n,clickConnecting:(l==null?void 0:l.nodeId)===e&&(l==null?void 0:l.handleId)===t&&(l==null?void 0:l.type)===n}},W2=y.forwardRef(({type:e="source",position:t=Ae.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:s=!0,isConnectableEnd:o=!0,id:l,onConnect:c,children:d,className:h,onMouseDown:f,onTouchStart:p,...g},v)=>{var $,B;const j=l||null,k=e==="target",x=bt(),N=Q6(),{connectOnClick:b,noPanClassName:S}=He(lB,At),{connecting:E,clickConnecting:R}=He(cB(N,j,e),At);N||(B=($=x.getState()).onError)==null||B.call($,"010",xs.error010());const I=L=>{const{defaultEdgeOptions:M,onConnect:F,hasDefaultEdges:T}=x.getState(),P={...M,...L};if(T){const{edges:O,setEdges:G}=x.getState();G(rB(P,O))}F==null||F(P),c==null||c(P)},A=L=>{if(!N)return;const M=$2(L);s&&(M&&L.button===0||!M)&&z2({event:L,handleId:j,nodeId:N,onConnect:I,isTarget:k,getState:x.getState,setState:x.setState,isValidConnection:n||x.getState().isValidConnection||xj}),M?f==null||f(L):p==null||p(L)},q=L=>{const{onClickConnectStart:M,onClickConnectEnd:F,connectionClickStartHandle:T,connectionMode:P,isValidConnection:O}=x.getState();if(!N||!T&&!s)return;if(!T){M==null||M(L,{nodeId:N,handleId:j,handleType:e}),x.setState({connectionClickStartHandle:{nodeId:N,type:e,handleId:j}});return}const G=T2(L.target),K=n||O||xj,{connection:U,isValid:H}=U2({nodeId:N,id:j,type:e},P,T.nodeId,T.handleId||null,T.type,K,G);H&&I(U),F==null||F(L),x.setState({connectionClickStartHandle:null})};return he.createElement("div",{"data-handleid":j,"data-nodeid":N,"data-handlepos":t,"data-id":`${N}-${j}-${e}`,className:Ut(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",S,h,{source:!k,target:k,connectable:r,connectablestart:s,connectableend:o,connecting:R,connectionindicator:r&&(s&&!E||o&&E)}]),onMouseDown:A,onTouchStart:A,onClick:b?q:void 0,ref:v,...g},d)});W2.displayName="Handle";var eo=y.memo(W2);const H2=({data:e,isConnectable:t,targetPosition:n=Ae.Top,sourcePosition:r=Ae.Bottom})=>he.createElement(he.Fragment,null,he.createElement(eo,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,he.createElement(eo,{type:"source",position:r,isConnectable:t}));H2.displayName="DefaultNode";var Wx=y.memo(H2);const V2=({data:e,isConnectable:t,sourcePosition:n=Ae.Bottom})=>he.createElement(he.Fragment,null,e==null?void 0:e.label,he.createElement(eo,{type:"source",position:n,isConnectable:t}));V2.displayName="InputNode";var G2=y.memo(V2);const K2=({data:e,isConnectable:t,targetPosition:n=Ae.Top})=>he.createElement(he.Fragment,null,he.createElement(eo,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label);K2.displayName="OutputNode";var Y2=y.memo(K2);const lk=()=>null;lk.displayName="GroupNode";const uB=e=>({selectedNodes:e.getNodes().filter(t=>t.selected),selectedEdges:e.edges.filter(t=>t.selected).map(t=>({...t}))}),Du=e=>e.id;function dB(e,t){return At(e.selectedNodes.map(Du),t.selectedNodes.map(Du))&&At(e.selectedEdges.map(Du),t.selectedEdges.map(Du))}const X2=y.memo(({onSelectionChange:e})=>{const t=bt(),{selectedNodes:n,selectedEdges:r}=He(uB,dB);return y.useEffect(()=>{const s={nodes:n,edges:r};e==null||e(s),t.getState().onSelectionChange.forEach(o=>o(s))},[n,r,e]),null});X2.displayName="SelectionListener";const hB=e=>!!e.onSelectionChange;function fB({onSelectionChange:e}){const t=He(hB);return e||t?he.createElement(X2,{onSelectionChange:e}):null}const pB=e=>({setNodes:e.setNodes,setEdges:e.setEdges,setDefaultNodesAndEdges:e.setDefaultNodesAndEdges,setMinZoom:e.setMinZoom,setMaxZoom:e.setMaxZoom,setTranslateExtent:e.setTranslateExtent,setNodeExtent:e.setNodeExtent,reset:e.reset});function zo(e,t){y.useEffect(()=>{typeof e<"u"&&t(e)},[e])}function Fe(e,t,n){y.useEffect(()=>{typeof t<"u"&&n({[e]:t})},[t])}const mB=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:s,onConnectStart:o,onConnectEnd:l,onClickConnectStart:c,onClickConnectEnd:d,nodesDraggable:h,nodesConnectable:f,nodesFocusable:p,edgesFocusable:g,edgesUpdatable:v,elevateNodesOnSelect:j,minZoom:k,maxZoom:x,nodeExtent:N,onNodesChange:b,onEdgesChange:S,elementsSelectable:E,connectionMode:R,snapGrid:I,snapToGrid:A,translateExtent:q,connectOnClick:$,defaultEdgeOptions:B,fitView:L,fitViewOptions:M,onNodesDelete:F,onEdgesDelete:T,onNodeDrag:P,onNodeDragStart:O,onNodeDragStop:G,onSelectionDrag:K,onSelectionDragStart:U,onSelectionDragStop:H,noPanClassName:D,nodeOrigin:V,rfId:J,autoPanOnConnect:W,autoPanOnNodeDrag:Z,onError:Y,connectionRadius:X,isValidConnection:ee,nodeDragThreshold:ae})=>{const{setNodes:ce,setEdges:ge,setDefaultNodesAndEdges:ye,setMinZoom:se,setMaxZoom:pe,setTranslateExtent:fe,setNodeExtent:de,reset:me}=He(pB,At),ne=bt();return y.useEffect(()=>{const oe=r==null?void 0:r.map(Ne=>({...Ne,...B}));return ye(n,oe),()=>{me()}},[]),Fe("defaultEdgeOptions",B,ne.setState),Fe("connectionMode",R,ne.setState),Fe("onConnect",s,ne.setState),Fe("onConnectStart",o,ne.setState),Fe("onConnectEnd",l,ne.setState),Fe("onClickConnectStart",c,ne.setState),Fe("onClickConnectEnd",d,ne.setState),Fe("nodesDraggable",h,ne.setState),Fe("nodesConnectable",f,ne.setState),Fe("nodesFocusable",p,ne.setState),Fe("edgesFocusable",g,ne.setState),Fe("edgesUpdatable",v,ne.setState),Fe("elementsSelectable",E,ne.setState),Fe("elevateNodesOnSelect",j,ne.setState),Fe("snapToGrid",A,ne.setState),Fe("snapGrid",I,ne.setState),Fe("onNodesChange",b,ne.setState),Fe("onEdgesChange",S,ne.setState),Fe("connectOnClick",$,ne.setState),Fe("fitViewOnInit",L,ne.setState),Fe("fitViewOnInitOptions",M,ne.setState),Fe("onNodesDelete",F,ne.setState),Fe("onEdgesDelete",T,ne.setState),Fe("onNodeDrag",P,ne.setState),Fe("onNodeDragStart",O,ne.setState),Fe("onNodeDragStop",G,ne.setState),Fe("onSelectionDrag",K,ne.setState),Fe("onSelectionDragStart",U,ne.setState),Fe("onSelectionDragStop",H,ne.setState),Fe("noPanClassName",D,ne.setState),Fe("nodeOrigin",V,ne.setState),Fe("rfId",J,ne.setState),Fe("autoPanOnConnect",W,ne.setState),Fe("autoPanOnNodeDrag",Z,ne.setState),Fe("onError",Y,ne.setState),Fe("connectionRadius",X,ne.setState),Fe("isValidConnection",ee,ne.setState),Fe("nodeDragThreshold",ae,ne.setState),zo(e,ce),zo(t,ge),zo(k,se),zo(x,pe),zo(q,fe),zo(N,de),null},bj={display:"none"},gB={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},Z2="react-flow__node-desc",J2="react-flow__edge-desc",yB="react-flow__aria-live",wB=e=>e.ariaLiveMessage;function vB({rfId:e}){const t=He(wB);return he.createElement("div",{id:`${yB}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:gB},t)}function xB({rfId:e,disableKeyboardA11y:t}){return he.createElement(he.Fragment,null,he.createElement("div",{id:`${Z2}-${e}`,style:bj},"Press enter or space to select a node.",!t&&"You can then use the arrow keys to move the node around."," Press delete to remove it and escape to cancel."," "),he.createElement("div",{id:`${J2}-${e}`,style:bj},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!t&&he.createElement(vB,{rfId:e}))}var Jl=(e=null,t={actInsideInputWithModifier:!0})=>{const[n,r]=y.useState(!1),s=y.useRef(!1),o=y.useRef(new Set([])),[l,c]=y.useMemo(()=>{if(e!==null){const h=(Array.isArray(e)?e:[e]).filter(p=>typeof p=="string").map(p=>p.split("+")),f=h.reduce((p,g)=>p.concat(...g),[]);return[h,f]}return[[],[]]},[e]);return y.useEffect(()=>{const d=typeof document<"u"?document:null,h=(t==null?void 0:t.target)||d;if(e!==null){const f=v=>{if(s.current=v.ctrlKey||v.metaKey||v.shiftKey,(!s.current||s.current&&!t.actInsideInputWithModifier)&&Bx(v))return!1;const k=Nj(v.code,c);o.current.add(v[k]),kj(l,o.current,!1)&&(v.preventDefault(),r(!0))},p=v=>{if((!s.current||s.current&&!t.actInsideInputWithModifier)&&Bx(v))return!1;const k=Nj(v.code,c);kj(l,o.current,!0)?(r(!1),o.current.clear()):o.current.delete(v[k]),v.key==="Meta"&&o.current.clear(),s.current=!1},g=()=>{o.current.clear(),r(!1)};return h==null||h.addEventListener("keydown",f),h==null||h.addEventListener("keyup",p),window.addEventListener("blur",g),()=>{h==null||h.removeEventListener("keydown",f),h==null||h.removeEventListener("keyup",p),window.removeEventListener("blur",g)}}},[e,r]),n};function kj(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(s=>t.has(s)))}function Nj(e,t){return t.includes(e)?"code":"key"}function Q2(e,t,n,r){var c,d;const s=e.parentNode||e.parentId;if(!s)return n;const o=t.get(s),l=Ka(o,r);return Q2(o,t,{x:(n.x??0)+l.x,y:(n.y??0)+l.y,z:(((c=o[pt])==null?void 0:c.z)??0)>(n.z??0)?((d=o[pt])==null?void 0:d.z)??0:n.z??0},r)}function e$(e,t,n){e.forEach(r=>{var o;const s=r.parentNode||r.parentId;if(s&&!e.has(s))throw new Error(`Parent node ${s} not found`);if(s||n!=null&&n[r.id]){const{x:l,y:c,z:d}=Q2(r,e,{...r.position,z:((o=r[pt])==null?void 0:o.z)??0},t);r.positionAbsolute={x:l,y:c},r[pt].z=d,n!=null&&n[r.id]&&(r[pt].isParent=!0)}})}function Pp(e,t,n,r){const s=new Map,o={},l=r?1e3:0;return e.forEach(c=>{var v;const d=(Vn(c.zIndex)?c.zIndex:0)+(c.selected?l:0),h=t.get(c.id),f={...c,positionAbsolute:{x:c.position.x,y:c.position.y}},p=c.parentNode||c.parentId;p&&(o[p]=!0);const g=(h==null?void 0:h.type)&&(h==null?void 0:h.type)!==c.type;Object.defineProperty(f,pt,{enumerable:!1,value:{handleBounds:g||(v=h==null?void 0:h[pt])==null?void 0:v.handleBounds,z:d}}),s.set(c.id,f)}),e$(s,n,o),s}function t$(e,t={}){const{getNodes:n,width:r,height:s,minZoom:o,maxZoom:l,d3Zoom:c,d3Selection:d,fitViewOnInitDone:h,fitViewOnInit:f,nodeOrigin:p}=e(),g=t.initial&&!h&&f;if(c&&d&&(g||!t.initial)){const j=n().filter(x=>{var b;const N=t.includeHiddenNodes?x.width&&x.height:!x.hidden;return(b=t.nodes)!=null&&b.length?N&&t.nodes.some(S=>S.id===x.id):N}),k=j.every(x=>x.width&&x.height);if(j.length>0&&k){const x=ah(j,p),{x:N,y:b,zoom:S}=B2(x,r,s,t.minZoom??o,t.maxZoom??l,t.padding??.1),E=ys.translate(N,b).scale(S);return typeof t.duration=="number"&&t.duration>0?c.transform(Da(d,t.duration),E):c.transform(d,E),!0}}return!1}function bB(e,t){return e.forEach(n=>{const r=t.get(n.id);r&&t.set(r.id,{...r,[pt]:r[pt],selected:n.selected})}),new Map(t)}function kB(e,t){return t.map(n=>{const r=e.find(s=>s.id===n.id);return r&&(n.selected=r.selected),n})}function Fu({changedNodes:e,changedEdges:t,get:n,set:r}){const{nodeInternals:s,edges:o,onNodesChange:l,onEdgesChange:c,hasDefaultNodes:d,hasDefaultEdges:h}=n();e!=null&&e.length&&(d&&r({nodeInternals:bB(e,s)}),l==null||l(e)),t!=null&&t.length&&(h&&r({edges:kB(t,o)}),c==null||c(t))}const Wo=()=>{},NB={zoomIn:Wo,zoomOut:Wo,zoomTo:Wo,getZoom:()=>1,setViewport:Wo,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:Wo,fitBounds:Wo,project:e=>e,screenToFlowPosition:e=>e,flowToScreenPosition:e=>e,viewportInitialized:!1},jB=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection}),SB=()=>{const e=bt(),{d3Zoom:t,d3Selection:n}=He(jB,At);return y.useMemo(()=>n&&t?{zoomIn:s=>t.scaleBy(Da(n,s==null?void 0:s.duration),1.2),zoomOut:s=>t.scaleBy(Da(n,s==null?void 0:s.duration),1/1.2),zoomTo:(s,o)=>t.scaleTo(Da(n,o==null?void 0:o.duration),s),getZoom:()=>e.getState().transform[2],setViewport:(s,o)=>{const[l,c,d]=e.getState().transform,h=ys.translate(s.x??l,s.y??c).scale(s.zoom??d);t.transform(Da(n,o==null?void 0:o.duration),h)},getViewport:()=>{const[s,o,l]=e.getState().transform;return{x:s,y:o,zoom:l}},fitView:s=>t$(e.getState,s),setCenter:(s,o,l)=>{const{width:c,height:d,maxZoom:h}=e.getState(),f=typeof(l==null?void 0:l.zoom)<"u"?l.zoom:h,p=c/2-s*f,g=d/2-o*f,v=ys.translate(p,g).scale(f);t.transform(Da(n,l==null?void 0:l.duration),v)},fitBounds:(s,o)=>{const{width:l,height:c,minZoom:d,maxZoom:h}=e.getState(),{x:f,y:p,zoom:g}=B2(s,l,c,d,h,(o==null?void 0:o.padding)??.1),v=ys.translate(f,p).scale(g);t.transform(Da(n,o==null?void 0:o.duration),v)},project:s=>{const{transform:o,snapToGrid:l,snapGrid:c}=e.getState();return console.warn("[DEPRECATED] `project` is deprecated. Instead use `screenToFlowPosition`. There is no need to subtract the react flow bounds anymore! https://reactflow.dev/api-reference/types/react-flow-instance#screen-to-flow-position"),zx(s,o,l,c)},screenToFlowPosition:s=>{const{transform:o,snapToGrid:l,snapGrid:c,domNode:d}=e.getState();if(!d)return s;const{x:h,y:f}=d.getBoundingClientRect(),p={x:s.x-h,y:s.y-f};return zx(p,o,l,c)},flowToScreenPosition:s=>{const{transform:o,domNode:l}=e.getState();if(!l)return s;const{x:c,y:d}=l.getBoundingClientRect(),h=P2(s,o);return{x:h.x+c,y:h.y+d}},viewportInitialized:!0}:NB,[t,n])};function Ai(){const e=SB(),t=bt(),n=y.useCallback(()=>t.getState().getNodes().map(k=>({...k})),[]),r=y.useCallback(k=>t.getState().nodeInternals.get(k),[]),s=y.useCallback(()=>{const{edges:k=[]}=t.getState();return k.map(x=>({...x}))},[]),o=y.useCallback(k=>{const{edges:x=[]}=t.getState();return x.find(N=>N.id===k)},[]),l=y.useCallback(k=>{const{getNodes:x,setNodes:N,hasDefaultNodes:b,onNodesChange:S}=t.getState(),E=x(),R=typeof k=="function"?k(E):k;if(b)N(R);else if(S){const I=R.length===0?E.map(A=>({type:"remove",id:A.id})):R.map(A=>({item:A,type:"reset"}));S(I)}},[]),c=y.useCallback(k=>{const{edges:x=[],setEdges:N,hasDefaultEdges:b,onEdgesChange:S}=t.getState(),E=typeof k=="function"?k(x):k;if(b)N(E);else if(S){const R=E.length===0?x.map(I=>({type:"remove",id:I.id})):E.map(I=>({item:I,type:"reset"}));S(R)}},[]),d=y.useCallback(k=>{const x=Array.isArray(k)?k:[k],{getNodes:N,setNodes:b,hasDefaultNodes:S,onNodesChange:E}=t.getState();if(S){const I=[...N(),...x];b(I)}else if(E){const R=x.map(I=>({item:I,type:"add"}));E(R)}},[]),h=y.useCallback(k=>{const x=Array.isArray(k)?k:[k],{edges:N=[],setEdges:b,hasDefaultEdges:S,onEdgesChange:E}=t.getState();if(S)b([...N,...x]);else if(E){const R=x.map(I=>({item:I,type:"add"}));E(R)}},[]),f=y.useCallback(()=>{const{getNodes:k,edges:x=[],transform:N}=t.getState(),[b,S,E]=N;return{nodes:k().map(R=>({...R})),edges:x.map(R=>({...R})),viewport:{x:b,y:S,zoom:E}}},[]),p=y.useCallback(({nodes:k,edges:x})=>{const{nodeInternals:N,getNodes:b,edges:S,hasDefaultNodes:E,hasDefaultEdges:R,onNodesDelete:I,onEdgesDelete:A,onNodesChange:q,onEdgesChange:$}=t.getState(),B=(k||[]).map(P=>P.id),L=(x||[]).map(P=>P.id),M=b().reduce((P,O)=>{const G=O.parentNode||O.parentId,K=!B.includes(O.id)&&G&&P.find(H=>H.id===G);return(typeof O.deletable=="boolean"?O.deletable:!0)&&(B.includes(O.id)||K)&&P.push(O),P},[]),F=S.filter(P=>typeof P.deletable=="boolean"?P.deletable:!0),T=F.filter(P=>L.includes(P.id));if(M||T){const P=F2(M,F),O=[...T,...P],G=O.reduce((K,U)=>(K.includes(U.id)||K.push(U.id),K),[]);if((R||E)&&(R&&t.setState({edges:S.filter(K=>!G.includes(K.id))}),E&&(M.forEach(K=>{N.delete(K.id)}),t.setState({nodeInternals:new Map(N)}))),G.length>0&&(A==null||A(O),$&&$(G.map(K=>({id:K,type:"remove"})))),M.length>0&&(I==null||I(M),q)){const K=M.map(U=>({id:U.id,type:"remove"}));q(K)}}},[]),g=y.useCallback(k=>{const x=H6(k),N=x?null:t.getState().nodeInternals.get(k.id);return!x&&!N?[null,null,x]:[x?k:pj(N),N,x]},[]),v=y.useCallback((k,x=!0,N)=>{const[b,S,E]=g(k);return b?(N||t.getState().getNodes()).filter(R=>{if(!E&&(R.id===S.id||!R.positionAbsolute))return!1;const I=pj(R),A=Fx(I,b);return x&&A>0||A>=b.width*b.height}):[]},[]),j=y.useCallback((k,x,N=!0)=>{const[b]=g(k);if(!b)return!1;const S=Fx(b,x);return N&&S>0||S>=b.width*b.height},[]);return y.useMemo(()=>({...e,getNodes:n,getNode:r,getEdges:s,getEdge:o,setNodes:l,setEdges:c,addNodes:d,addEdges:h,toObject:f,deleteElements:p,getIntersectingNodes:v,isNodeIntersecting:j}),[e,n,r,s,o,l,c,d,h,f,p,v,j])}const _B={actInsideInputWithModifier:!1};var EB=({deleteKeyCode:e,multiSelectionKeyCode:t})=>{const n=bt(),{deleteElements:r}=Ai(),s=Jl(e,_B),o=Jl(t);y.useEffect(()=>{if(s){const{edges:l,getNodes:c}=n.getState(),d=c().filter(f=>f.selected),h=l.filter(f=>f.selected);r({nodes:d,edges:h}),n.setState({nodesSelectionActive:!1})}},[s]),y.useEffect(()=>{n.setState({multiSelectionActive:o})},[o])};function CB(e){const t=bt();y.useEffect(()=>{let n;const r=()=>{var o,l;if(!e.current)return;const s=ek(e.current);(s.height===0||s.width===0)&&((l=(o=t.getState()).onError)==null||l.call(o,"004",xs.error004())),t.setState({width:s.width||500,height:s.height||500})};return r(),window.addEventListener("resize",r),e.current&&(n=new ResizeObserver(()=>r()),n.observe(e.current)),()=>{window.removeEventListener("resize",r),n&&e.current&&n.unobserve(e.current)}},[])}const ck={position:"absolute",width:"100%",height:"100%",top:0,left:0},TB=(e,t)=>e.x!==t.x||e.y!==t.y||e.zoom!==t.k,Bu=e=>({x:e.x,y:e.y,zoom:e.k}),Ho=(e,t)=>e.target.closest(`.${t}`),jj=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),Sj=e=>{const t=e.ctrlKey&&Nd()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t},AB=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),RB=({onMove:e,onMoveStart:t,onMoveEnd:n,onPaneContextMenu:r,zoomOnScroll:s=!0,zoomOnPinch:o=!0,panOnScroll:l=!1,panOnScrollSpeed:c=.5,panOnScrollMode:d=Wa.Free,zoomOnDoubleClick:h=!0,elementsSelectable:f,panOnDrag:p=!0,defaultViewport:g,translateExtent:v,minZoom:j,maxZoom:k,zoomActivationKeyCode:x,preventScrolling:N=!0,children:b,noWheelClassName:S,noPanClassName:E})=>{const R=y.useRef(),I=bt(),A=y.useRef(!1),q=y.useRef(!1),$=y.useRef(null),B=y.useRef({x:0,y:0,zoom:0}),{d3Zoom:L,d3Selection:M,d3ZoomHandler:F,userSelectionActive:T}=He(AB,At),P=Jl(x),O=y.useRef(0),G=y.useRef(!1),K=y.useRef();return CB($),y.useEffect(()=>{if($.current){const U=$.current.getBoundingClientRect(),H=_2().scaleExtent([j,k]).translateExtent(v),D=Hn($.current).call(H),V=ys.translate(g.x,g.y).scale(yi(g.zoom,j,k)),J=[[0,0],[U.width,U.height]],W=H.constrain()(V,J,v);H.transform(D,W),H.wheelDelta(Sj),I.setState({d3Zoom:H,d3Selection:D,d3ZoomHandler:D.on("wheel.zoom"),transform:[W.x,W.y,W.k],domNode:$.current.closest(".react-flow")})}},[]),y.useEffect(()=>{M&&L&&(l&&!P&&!T?M.on("wheel.zoom",U=>{if(Ho(U,S))return!1;U.preventDefault(),U.stopImmediatePropagation();const H=M.property("__zoom").k||1;if(U.ctrlKey&&o){const ee=yr(U),ae=Sj(U),ce=H*Math.pow(2,ae);L.scaleTo(M,ce,ee,U);return}const D=U.deltaMode===1?20:1;let V=d===Wa.Vertical?0:U.deltaX*D,J=d===Wa.Horizontal?0:U.deltaY*D;!Nd()&&U.shiftKey&&d!==Wa.Vertical&&(V=U.deltaY*D,J=0),L.translateBy(M,-(V/H)*c,-(J/H)*c,{internal:!0});const W=Bu(M.property("__zoom")),{onViewportChangeStart:Z,onViewportChange:Y,onViewportChangeEnd:X}=I.getState();clearTimeout(K.current),G.current||(G.current=!0,t==null||t(U,W),Z==null||Z(W)),G.current&&(e==null||e(U,W),Y==null||Y(W),K.current=setTimeout(()=>{n==null||n(U,W),X==null||X(W),G.current=!1},150))},{passive:!1}):typeof F<"u"&&M.on("wheel.zoom",function(U,H){if(!N&&U.type==="wheel"&&!U.ctrlKey||Ho(U,S))return null;U.preventDefault(),F.call(this,U,H)},{passive:!1}))},[T,l,d,M,L,F,P,o,N,S,t,e,n]),y.useEffect(()=>{L&&L.on("start",U=>{var V,J;if(!U.sourceEvent||U.sourceEvent.internal)return null;O.current=(V=U.sourceEvent)==null?void 0:V.button;const{onViewportChangeStart:H}=I.getState(),D=Bu(U.transform);A.current=!0,B.current=D,((J=U.sourceEvent)==null?void 0:J.type)==="mousedown"&&I.setState({paneDragging:!0}),H==null||H(D),t==null||t(U.sourceEvent,D)})},[L,t]),y.useEffect(()=>{L&&(T&&!A.current?L.on("zoom",null):T||L.on("zoom",U=>{var D;const{onViewportChange:H}=I.getState();if(I.setState({transform:[U.transform.x,U.transform.y,U.transform.k]}),q.current=!!(r&&jj(p,O.current??0)),(e||H)&&!((D=U.sourceEvent)!=null&&D.internal)){const V=Bu(U.transform);H==null||H(V),e==null||e(U.sourceEvent,V)}}))},[T,L,e,p,r]),y.useEffect(()=>{L&&L.on("end",U=>{if(!U.sourceEvent||U.sourceEvent.internal)return null;const{onViewportChangeEnd:H}=I.getState();if(A.current=!1,I.setState({paneDragging:!1}),r&&jj(p,O.current??0)&&!q.current&&r(U.sourceEvent),q.current=!1,(n||H)&&TB(B.current,U.transform)){const D=Bu(U.transform);B.current=D,clearTimeout(R.current),R.current=setTimeout(()=>{H==null||H(D),n==null||n(U.sourceEvent,D)},l?150:0)}})},[L,l,p,n,r]),y.useEffect(()=>{L&&L.filter(U=>{const H=P||s,D=o&&U.ctrlKey;if((p===!0||Array.isArray(p)&&p.includes(1))&&U.button===1&&U.type==="mousedown"&&(Ho(U,"react-flow__node")||Ho(U,"react-flow__edge")))return!0;if(!p&&!H&&!l&&!h&&!o||T||!h&&U.type==="dblclick"||Ho(U,S)&&U.type==="wheel"||Ho(U,E)&&(U.type!=="wheel"||l&&U.type==="wheel"&&!P)||!o&&U.ctrlKey&&U.type==="wheel"||!H&&!l&&!D&&U.type==="wheel"||!p&&(U.type==="mousedown"||U.type==="touchstart")||Array.isArray(p)&&!p.includes(U.button)&&U.type==="mousedown")return!1;const V=Array.isArray(p)&&p.includes(U.button)||!U.button||U.button<=1;return(!U.ctrlKey||U.type==="wheel")&&V})},[T,L,s,o,l,h,p,f,P]),he.createElement("div",{className:"react-flow__renderer",ref:$,style:ck},b)},MB=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function $B(){const{userSelectionActive:e,userSelectionRect:t}=He(MB,At);return e&&t?he.createElement("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}function _j(e,t){const n=t.parentNode||t.parentId,r=e.find(s=>s.id===n);if(r){const s=t.position.x+t.width-r.width,o=t.position.y+t.height-r.height;if(s>0||o>0||t.position.x<0||t.position.y<0){if(r.style={...r.style},r.style.width=r.style.width??r.width,r.style.height=r.style.height??r.height,s>0&&(r.style.width+=s),o>0&&(r.style.height+=o),t.position.x<0){const l=Math.abs(t.position.x);r.position.x=r.position.x-l,r.style.width+=l,t.position.x=0}if(t.position.y<0){const l=Math.abs(t.position.y);r.position.y=r.position.y-l,r.style.height+=l,t.position.y=0}r.width=r.style.width,r.height=r.style.height}}}function IB(e,t){if(e.some(r=>r.type==="reset"))return e.filter(r=>r.type==="reset").map(r=>r.item);const n=e.filter(r=>r.type==="add").map(r=>r.item);return t.reduce((r,s)=>{const o=e.filter(c=>c.id===s.id);if(o.length===0)return r.push(s),r;const l={...s};for(const c of o)if(c)switch(c.type){case"select":{l.selected=c.selected;break}case"position":{typeof c.position<"u"&&(l.position=c.position),typeof c.positionAbsolute<"u"&&(l.positionAbsolute=c.positionAbsolute),typeof c.dragging<"u"&&(l.dragging=c.dragging),l.expandParent&&_j(r,l);break}case"dimensions":{typeof c.dimensions<"u"&&(l.width=c.dimensions.width,l.height=c.dimensions.height),typeof c.updateStyle<"u"&&(l.style={...l.style||{},...c.dimensions}),typeof c.resizing=="boolean"&&(l.resizing=c.resizing),l.expandParent&&_j(r,l);break}case"remove":return r}return r.push(l),r},n)}function OB(e,t){return IB(e,t)}const Zs=(e,t)=>({id:e,type:"select",selected:t});function ai(e,t){return e.reduce((n,r)=>{const s=t.includes(r.id);return!r.selected&&s?(r.selected=!0,n.push(Zs(r.id,!0))):r.selected&&!s&&(r.selected=!1,n.push(Zs(r.id,!1))),n},[])}const Dp=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},LB=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),n$=y.memo(({isSelecting:e,selectionMode:t=Zl.Full,panOnDrag:n,onSelectionStart:r,onSelectionEnd:s,onPaneClick:o,onPaneContextMenu:l,onPaneScroll:c,onPaneMouseEnter:d,onPaneMouseMove:h,onPaneMouseLeave:f,children:p})=>{const g=y.useRef(null),v=bt(),j=y.useRef(0),k=y.useRef(0),x=y.useRef(),{userSelectionActive:N,elementsSelectable:b,dragging:S}=He(LB,At),E=()=>{v.setState({userSelectionActive:!1,userSelectionRect:null}),j.current=0,k.current=0},R=F=>{o==null||o(F),v.getState().resetSelectedElements(),v.setState({nodesSelectionActive:!1})},I=F=>{if(Array.isArray(n)&&(n!=null&&n.includes(2))){F.preventDefault();return}l==null||l(F)},A=c?F=>c(F):void 0,q=F=>{const{resetSelectedElements:T,domNode:P}=v.getState();if(x.current=P==null?void 0:P.getBoundingClientRect(),!b||!e||F.button!==0||F.target!==g.current||!x.current)return;const{x:O,y:G}=ra(F,x.current);T(),v.setState({userSelectionRect:{width:0,height:0,startX:O,startY:G,x:O,y:G}}),r==null||r(F)},$=F=>{const{userSelectionRect:T,nodeInternals:P,edges:O,transform:G,onNodesChange:K,onEdgesChange:U,nodeOrigin:H,getNodes:D}=v.getState();if(!e||!x.current||!T)return;v.setState({userSelectionActive:!0,nodesSelectionActive:!1});const V=ra(F,x.current),J=T.startX??0,W=T.startY??0,Z={...T,x:V.x<J?V.x:J,y:V.y<W?V.y:W,width:Math.abs(V.x-J),height:Math.abs(V.y-W)},Y=D(),X=D2(P,Z,G,t===Zl.Partial,!0,H),ee=F2(X,O).map(ce=>ce.id),ae=X.map(ce=>ce.id);if(j.current!==ae.length){j.current=ae.length;const ce=ai(Y,ae);ce.length&&(K==null||K(ce))}if(k.current!==ee.length){k.current=ee.length;const ce=ai(O,ee);ce.length&&(U==null||U(ce))}v.setState({userSelectionRect:Z})},B=F=>{if(F.button!==0)return;const{userSelectionRect:T}=v.getState();!N&&T&&F.target===g.current&&(R==null||R(F)),v.setState({nodesSelectionActive:j.current>0}),E(),s==null||s(F)},L=F=>{N&&(v.setState({nodesSelectionActive:j.current>0}),s==null||s(F)),E()},M=b&&(e||N);return he.createElement("div",{className:Ut(["react-flow__pane",{dragging:S,selection:e}]),onClick:M?void 0:Dp(R,g),onContextMenu:Dp(I,g),onWheel:Dp(A,g),onMouseEnter:M?void 0:d,onMouseDown:M?q:void 0,onMouseMove:M?$:h,onMouseUp:M?B:void 0,onMouseLeave:M?L:f,ref:g,style:ck},p,he.createElement($B,null))});n$.displayName="Pane";function r$(e,t){const n=e.parentNode||e.parentId;if(!n)return!1;const r=t.get(n);return r?r.selected?!0:r$(r,t):!1}function Ej(e,t,n){let r=e;do{if(r!=null&&r.matches(t))return!0;if(r===n.current)return!1;r=r.parentElement}while(r);return!1}function PB(e,t,n,r){return Array.from(e.values()).filter(s=>(s.selected||s.id===r)&&(!s.parentNode||s.parentId||!r$(s,e))&&(s.draggable||t&&typeof s.draggable>"u")).map(s=>{var o,l;return{id:s.id,position:s.position||{x:0,y:0},positionAbsolute:s.positionAbsolute||{x:0,y:0},distance:{x:n.x-(((o=s.positionAbsolute)==null?void 0:o.x)??0),y:n.y-(((l=s.positionAbsolute)==null?void 0:l.y)??0)},delta:{x:0,y:0},extent:s.extent,parentNode:s.parentNode||s.parentId,parentId:s.parentNode||s.parentId,width:s.width,height:s.height,expandParent:s.expandParent}})}function DB(e,t){return!t||t==="parent"?t:[t[0],[t[1][0]-(e.width||0),t[1][1]-(e.height||0)]]}function s$(e,t,n,r,s=[0,0],o){const l=DB(e,e.extent||r);let c=l;const d=e.parentNode||e.parentId;if(e.extent==="parent"&&!e.expandParent)if(d&&e.width&&e.height){const p=n.get(d),{x:g,y:v}=Ka(p,s).positionAbsolute;c=p&&Vn(g)&&Vn(v)&&Vn(p.width)&&Vn(p.height)?[[g+e.width*s[0],v+e.height*s[1]],[g+p.width-e.width+e.width*s[0],v+p.height-e.height+e.height*s[1]]]:c}else o==null||o("005",xs.error005()),c=l;else if(e.extent&&d&&e.extent!=="parent"){const p=n.get(d),{x:g,y:v}=Ka(p,s).positionAbsolute;c=[[e.extent[0][0]+g,e.extent[0][1]+v],[e.extent[1][0]+g,e.extent[1][1]+v]]}let h={x:0,y:0};if(d){const p=n.get(d);h=Ka(p,s).positionAbsolute}const f=c&&c!=="parent"?tk(t,c):t;return{position:{x:f.x-h.x,y:f.y-h.y},positionAbsolute:f}}function Fp({nodeId:e,dragItems:t,nodeInternals:n}){const r=t.map(s=>({...n.get(s.id),position:s.position,positionAbsolute:s.positionAbsolute}));return[e?r.find(s=>s.id===e):r[0],r]}const Cj=(e,t,n,r)=>{const s=t.querySelectorAll(e);if(!s||!s.length)return null;const o=Array.from(s),l=t.getBoundingClientRect(),c={x:l.width*r[0],y:l.height*r[1]};return o.map(d=>{const h=d.getBoundingClientRect();return{id:d.getAttribute("data-handleid"),position:d.getAttribute("data-handlepos"),x:(h.left-l.left-c.x)/n,y:(h.top-l.top-c.y)/n,...ek(d)}})};function kl(e,t,n){return n===void 0?n:r=>{const s=t().nodeInternals.get(e);s&&n(r,{...s})}}function Hx({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:s,unselectNodesAndEdges:o,multiSelectionActive:l,nodeInternals:c,onError:d}=t.getState(),h=c.get(e);if(!h){d==null||d("012",xs.error012(e));return}t.setState({nodesSelectionActive:!1}),h.selected?(n||h.selected&&l)&&(o({nodes:[h],edges:[]}),requestAnimationFrame(()=>{var f;return(f=r==null?void 0:r.current)==null?void 0:f.blur()})):s([e])}function FB(){const e=bt();return y.useCallback(({sourceEvent:n})=>{const{transform:r,snapGrid:s,snapToGrid:o}=e.getState(),l=n.touches?n.touches[0].clientX:n.clientX,c=n.touches?n.touches[0].clientY:n.clientY,d={x:(l-r[0])/r[2],y:(c-r[1])/r[2]};return{xSnapped:o?s[0]*Math.round(d.x/s[0]):d.x,ySnapped:o?s[1]*Math.round(d.y/s[1]):d.y,...d}},[])}function Bp(e){return(t,n,r)=>e==null?void 0:e(t,r)}function a$({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:s,isSelectable:o,selectNodesOnDrag:l}){const c=bt(),[d,h]=y.useState(!1),f=y.useRef([]),p=y.useRef({x:null,y:null}),g=y.useRef(0),v=y.useRef(null),j=y.useRef({x:0,y:0}),k=y.useRef(null),x=y.useRef(!1),N=y.useRef(!1),b=y.useRef(!1),S=FB();return y.useEffect(()=>{if(e!=null&&e.current){const E=Hn(e.current),R=({x:q,y:$})=>{const{nodeInternals:B,onNodeDrag:L,onSelectionDrag:M,updateNodePositions:F,nodeExtent:T,snapGrid:P,snapToGrid:O,nodeOrigin:G,onError:K}=c.getState();p.current={x:q,y:$};let U=!1,H={x:0,y:0,x2:0,y2:0};if(f.current.length>1&&T){const V=ah(f.current,G);H=Xl(V)}if(f.current=f.current.map(V=>{const J={x:q-V.distance.x,y:$-V.distance.y};O&&(J.x=P[0]*Math.round(J.x/P[0]),J.y=P[1]*Math.round(J.y/P[1]));const W=[[T[0][0],T[0][1]],[T[1][0],T[1][1]]];f.current.length>1&&T&&!V.extent&&(W[0][0]=V.positionAbsolute.x-H.x+T[0][0],W[1][0]=V.positionAbsolute.x+(V.width??0)-H.x2+T[1][0],W[0][1]=V.positionAbsolute.y-H.y+T[0][1],W[1][1]=V.positionAbsolute.y+(V.height??0)-H.y2+T[1][1]);const Z=s$(V,J,B,W,G,K);return U=U||V.position.x!==Z.position.x||V.position.y!==Z.position.y,V.position=Z.position,V.positionAbsolute=Z.positionAbsolute,V}),!U)return;F(f.current,!0,!0),h(!0);const D=s?L:Bp(M);if(D&&k.current){const[V,J]=Fp({nodeId:s,dragItems:f.current,nodeInternals:B});D(k.current,V,J)}},I=()=>{if(!v.current)return;const[q,$]=C2(j.current,v.current);if(q!==0||$!==0){const{transform:B,panBy:L}=c.getState();p.current.x=(p.current.x??0)-q/B[2],p.current.y=(p.current.y??0)-$/B[2],L({x:q,y:$})&&R(p.current)}g.current=requestAnimationFrame(I)},A=q=>{var G;const{nodeInternals:$,multiSelectionActive:B,nodesDraggable:L,unselectNodesAndEdges:M,onNodeDragStart:F,onSelectionDragStart:T}=c.getState();N.current=!0;const P=s?F:Bp(T);(!l||!o)&&!B&&s&&((G=$.get(s))!=null&&G.selected||M()),s&&o&&l&&Hx({id:s,store:c,nodeRef:e});const O=S(q);if(p.current=O,f.current=PB($,L,O,s),P&&f.current){const[K,U]=Fp({nodeId:s,dragItems:f.current,nodeInternals:$});P(q.sourceEvent,K,U)}};if(t)E.on(".drag",null);else{const q=YF().on("start",$=>{const{domNode:B,nodeDragThreshold:L}=c.getState();L===0&&A($),b.current=!1;const M=S($);p.current=M,v.current=(B==null?void 0:B.getBoundingClientRect())||null,j.current=ra($.sourceEvent,v.current)}).on("drag",$=>{var F,T;const B=S($),{autoPanOnNodeDrag:L,nodeDragThreshold:M}=c.getState();if($.sourceEvent.type==="touchmove"&&$.sourceEvent.touches.length>1&&(b.current=!0),!b.current){if(!x.current&&N.current&&L&&(x.current=!0,I()),!N.current){const P=B.xSnapped-(((F=p==null?void 0:p.current)==null?void 0:F.x)??0),O=B.ySnapped-(((T=p==null?void 0:p.current)==null?void 0:T.y)??0);Math.sqrt(P*P+O*O)>M&&A($)}(p.current.x!==B.xSnapped||p.current.y!==B.ySnapped)&&f.current&&N.current&&(k.current=$.sourceEvent,j.current=ra($.sourceEvent,v.current),R(B))}}).on("end",$=>{if(!(!N.current||b.current)&&(h(!1),x.current=!1,N.current=!1,cancelAnimationFrame(g.current),f.current)){const{updateNodePositions:B,nodeInternals:L,onNodeDragStop:M,onSelectionDragStop:F}=c.getState(),T=s?M:Bp(F);if(B(f.current,!1,!1),T){const[P,O]=Fp({nodeId:s,dragItems:f.current,nodeInternals:L});T($.sourceEvent,P,O)}}}).filter($=>{const B=$.target;return!$.button&&(!n||!Ej(B,`.${n}`,e))&&(!r||Ej(B,r,e))});return E.call(q),()=>{E.on(".drag",null)}}}},[e,t,n,r,o,c,s,l,S]),d}function o$(){const e=bt();return y.useCallback(n=>{const{nodeInternals:r,nodeExtent:s,updateNodePositions:o,getNodes:l,snapToGrid:c,snapGrid:d,onError:h,nodesDraggable:f}=e.getState(),p=l().filter(b=>b.selected&&(b.draggable||f&&typeof b.draggable>"u")),g=c?d[0]:5,v=c?d[1]:5,j=n.isShiftPressed?4:1,k=n.x*g*j,x=n.y*v*j,N=p.map(b=>{if(b.positionAbsolute){const S={x:b.positionAbsolute.x+k,y:b.positionAbsolute.y+x};c&&(S.x=d[0]*Math.round(S.x/d[0]),S.y=d[1]*Math.round(S.y/d[1]));const{positionAbsolute:E,position:R}=s$(b,S,r,s,void 0,h);b.position=R,b.positionAbsolute=E}return b});o(N,!0,!1)},[])}const di={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var Nl=e=>{const t=({id:n,type:r,data:s,xPos:o,yPos:l,xPosOrigin:c,yPosOrigin:d,selected:h,onClick:f,onMouseEnter:p,onMouseMove:g,onMouseLeave:v,onContextMenu:j,onDoubleClick:k,style:x,className:N,isDraggable:b,isSelectable:S,isConnectable:E,isFocusable:R,selectNodesOnDrag:I,sourcePosition:A,targetPosition:q,hidden:$,resizeObserver:B,dragHandle:L,zIndex:M,isParent:F,noDragClassName:T,noPanClassName:P,initialized:O,disableKeyboardA11y:G,ariaLabel:K,rfId:U,hasHandleBounds:H})=>{const D=bt(),V=y.useRef(null),J=y.useRef(null),W=y.useRef(A),Z=y.useRef(q),Y=y.useRef(r),X=S||b||f||p||g||v,ee=o$(),ae=kl(n,D.getState,p),ce=kl(n,D.getState,g),ge=kl(n,D.getState,v),ye=kl(n,D.getState,j),se=kl(n,D.getState,k),pe=me=>{const{nodeDragThreshold:ne}=D.getState();if(S&&(!I||!b||ne>0)&&Hx({id:n,store:D,nodeRef:V}),f){const oe=D.getState().nodeInternals.get(n);oe&&f(me,{...oe})}},fe=me=>{if(!Bx(me)&&!G)if(M2.includes(me.key)&&S){const ne=me.key==="Escape";Hx({id:n,store:D,unselect:ne,nodeRef:V})}else b&&h&&Object.prototype.hasOwnProperty.call(di,me.key)&&(D.setState({ariaLiveMessage:`Moved selected node ${me.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~o}, y: ${~~l}`}),ee({x:di[me.key].x,y:di[me.key].y,isShiftPressed:me.shiftKey}))};y.useEffect(()=>()=>{J.current&&(B==null||B.unobserve(J.current),J.current=null)},[]),y.useEffect(()=>{if(V.current&&!$){const me=V.current;(!O||!H||J.current!==me)&&(J.current&&(B==null||B.unobserve(J.current)),B==null||B.observe(me),J.current=me)}},[$,O,H]),y.useEffect(()=>{const me=Y.current!==r,ne=W.current!==A,oe=Z.current!==q;V.current&&(me||ne||oe)&&(me&&(Y.current=r),ne&&(W.current=A),oe&&(Z.current=q),D.getState().updateNodeDimensions([{id:n,nodeElement:V.current,forceUpdate:!0}]))},[n,r,A,q]);const de=a$({nodeRef:V,disabled:$||!b,noDragClassName:T,handleSelector:L,nodeId:n,isSelectable:S,selectNodesOnDrag:I});return $?null:he.createElement("div",{className:Ut(["react-flow__node",`react-flow__node-${r}`,{[P]:b},N,{selected:h,selectable:S,parent:F,dragging:de}]),ref:V,style:{zIndex:M,transform:`translate(${c}px,${d}px)`,pointerEvents:X?"all":"none",visibility:O?"visible":"hidden",...x},"data-id":n,"data-testid":`rf__node-${n}`,onMouseEnter:ae,onMouseMove:ce,onMouseLeave:ge,onContextMenu:ye,onClick:pe,onDoubleClick:se,onKeyDown:R?fe:void 0,tabIndex:R?0:void 0,role:R?"button":void 0,"aria-describedby":G?void 0:`${Z2}-${U}`,"aria-label":K},he.createElement(J6,{value:n},he.createElement(e,{id:n,data:s,type:r,xPos:o,yPos:l,selected:h,isConnectable:E,sourcePosition:A,targetPosition:q,dragging:de,dragHandle:L,zIndex:M})))};return t.displayName="NodeWrapper",y.memo(t)};const BB=e=>{const t=e.getNodes().filter(n=>n.selected);return{...ah(t,e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive}};function qB({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=bt(),{width:s,height:o,x:l,y:c,transformString:d,userSelectionActive:h}=He(BB,At),f=o$(),p=y.useRef(null);if(y.useEffect(()=>{var j;n||(j=p.current)==null||j.focus({preventScroll:!0})},[n]),a$({nodeRef:p}),h||!s||!o)return null;const g=e?j=>{const k=r.getState().getNodes().filter(x=>x.selected);e(j,k)}:void 0,v=j=>{Object.prototype.hasOwnProperty.call(di,j.key)&&f({x:di[j.key].x,y:di[j.key].y,isShiftPressed:j.shiftKey})};return he.createElement("div",{className:Ut(["react-flow__nodesselection","react-flow__container",t]),style:{transform:d}},he.createElement("div",{ref:p,className:"react-flow__nodesselection-rect",onContextMenu:g,tabIndex:n?void 0:-1,onKeyDown:n?void 0:v,style:{width:s,height:o,top:c,left:l}}))}var UB=y.memo(qB);const zB=e=>e.nodesSelectionActive,i$=({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:o,onPaneScroll:l,deleteKeyCode:c,onMove:d,onMoveStart:h,onMoveEnd:f,selectionKeyCode:p,selectionOnDrag:g,selectionMode:v,onSelectionStart:j,onSelectionEnd:k,multiSelectionKeyCode:x,panActivationKeyCode:N,zoomActivationKeyCode:b,elementsSelectable:S,zoomOnScroll:E,zoomOnPinch:R,panOnScroll:I,panOnScrollSpeed:A,panOnScrollMode:q,zoomOnDoubleClick:$,panOnDrag:B,defaultViewport:L,translateExtent:M,minZoom:F,maxZoom:T,preventScrolling:P,onSelectionContextMenu:O,noWheelClassName:G,noPanClassName:K,disableKeyboardA11y:U})=>{const H=He(zB),D=Jl(p),V=Jl(N),J=V||B,W=V||I,Z=D||g&&J!==!0;return EB({deleteKeyCode:c,multiSelectionKeyCode:x}),he.createElement(RB,{onMove:d,onMoveStart:h,onMoveEnd:f,onPaneContextMenu:o,elementsSelectable:S,zoomOnScroll:E,zoomOnPinch:R,panOnScroll:W,panOnScrollSpeed:A,panOnScrollMode:q,zoomOnDoubleClick:$,panOnDrag:!D&&J,defaultViewport:L,translateExtent:M,minZoom:F,maxZoom:T,zoomActivationKeyCode:b,preventScrolling:P,noWheelClassName:G,noPanClassName:K},he.createElement(n$,{onSelectionStart:j,onSelectionEnd:k,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:o,onPaneScroll:l,panOnDrag:J,isSelecting:!!Z,selectionMode:v},e,H&&he.createElement(UB,{onSelectionContextMenu:O,noPanClassName:K,disableKeyboardA11y:U})))};i$.displayName="FlowRenderer";var WB=y.memo(i$);function HB(e){return He(y.useCallback(n=>e?D2(n.nodeInternals,{x:0,y:0,width:n.width,height:n.height},n.transform,!0):n.getNodes(),[e]))}function VB(e){const t={input:Nl(e.input||G2),default:Nl(e.default||Wx),output:Nl(e.output||Y2),group:Nl(e.group||lk)},n={},r=Object.keys(e).filter(s=>!["input","default","output","group"].includes(s)).reduce((s,o)=>(s[o]=Nl(e[o]||Wx),s),n);return{...t,...r}}const GB=({x:e,y:t,width:n,height:r,origin:s})=>!n||!r?{x:e,y:t}:s[0]<0||s[1]<0||s[0]>1||s[1]>1?{x:e,y:t}:{x:e-n*s[0],y:t-r*s[1]},KB=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),l$=e=>{const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:s,updateNodeDimensions:o,onError:l}=He(KB,At),c=HB(e.onlyRenderVisibleElements),d=y.useRef(),h=y.useMemo(()=>{if(typeof ResizeObserver>"u")return null;const f=new ResizeObserver(p=>{const g=p.map(v=>({id:v.target.getAttribute("data-id"),nodeElement:v.target,forceUpdate:!0}));o(g)});return d.current=f,f},[]);return y.useEffect(()=>()=>{var f;(f=d==null?void 0:d.current)==null||f.disconnect()},[]),he.createElement("div",{className:"react-flow__nodes",style:ck},c.map(f=>{var R,I,A;let p=f.type||"default";e.nodeTypes[p]||(l==null||l("003",xs.error003(p)),p="default");const g=e.nodeTypes[p]||e.nodeTypes.default,v=!!(f.draggable||t&&typeof f.draggable>"u"),j=!!(f.selectable||s&&typeof f.selectable>"u"),k=!!(f.connectable||n&&typeof f.connectable>"u"),x=!!(f.focusable||r&&typeof f.focusable>"u"),N=e.nodeExtent?tk(f.positionAbsolute,e.nodeExtent):f.positionAbsolute,b=(N==null?void 0:N.x)??0,S=(N==null?void 0:N.y)??0,E=GB({x:b,y:S,width:f.width??0,height:f.height??0,origin:e.nodeOrigin});return he.createElement(g,{key:f.id,id:f.id,className:f.className,style:f.style,type:p,data:f.data,sourcePosition:f.sourcePosition||Ae.Bottom,targetPosition:f.targetPosition||Ae.Top,hidden:f.hidden,xPos:b,yPos:S,xPosOrigin:E.x,yPosOrigin:E.y,selectNodesOnDrag:e.selectNodesOnDrag,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,selected:!!f.selected,isDraggable:v,isSelectable:j,isConnectable:k,isFocusable:x,resizeObserver:h,dragHandle:f.dragHandle,zIndex:((R=f[pt])==null?void 0:R.z)??0,isParent:!!((I=f[pt])!=null&&I.isParent),noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,initialized:!!f.width&&!!f.height,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,ariaLabel:f.ariaLabel,hasHandleBounds:!!((A=f[pt])!=null&&A.handleBounds)})}))};l$.displayName="NodeRenderer";var YB=y.memo(l$);const XB=(e,t,n)=>n===Ae.Left?e-t:n===Ae.Right?e+t:e,ZB=(e,t,n)=>n===Ae.Top?e-t:n===Ae.Bottom?e+t:e,Tj="react-flow__edgeupdater",Aj=({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:s,onMouseEnter:o,onMouseOut:l,type:c})=>he.createElement("circle",{onMouseDown:s,onMouseEnter:o,onMouseOut:l,className:Ut([Tj,`${Tj}-${c}`]),cx:XB(t,r,e),cy:ZB(n,r,e),r,stroke:"transparent",fill:"transparent"}),JB=()=>!0;var Vo=e=>{const t=({id:n,className:r,type:s,data:o,onClick:l,onEdgeDoubleClick:c,selected:d,animated:h,label:f,labelStyle:p,labelShowBg:g,labelBgStyle:v,labelBgPadding:j,labelBgBorderRadius:k,style:x,source:N,target:b,sourceX:S,sourceY:E,targetX:R,targetY:I,sourcePosition:A,targetPosition:q,elementsSelectable:$,hidden:B,sourceHandleId:L,targetHandleId:M,onContextMenu:F,onMouseEnter:T,onMouseMove:P,onMouseLeave:O,reconnectRadius:G,onReconnect:K,onReconnectStart:U,onReconnectEnd:H,markerEnd:D,markerStart:V,rfId:J,ariaLabel:W,isFocusable:Z,isReconnectable:Y,pathOptions:X,interactionWidth:ee,disableKeyboardA11y:ae})=>{const ce=y.useRef(null),[ge,ye]=y.useState(!1),[se,pe]=y.useState(!1),fe=bt(),de=y.useMemo(()=>`url('#${Ux(V,J)}')`,[V,J]),me=y.useMemo(()=>`url('#${Ux(D,J)}')`,[D,J]);if(B)return null;const ne=Xe=>{var gt;const{edges:tt,addSelectedEdges:Ge,unselectNodesAndEdges:ct,multiSelectionActive:en}=fe.getState(),Dt=tt.find(wt=>wt.id===n);Dt&&($&&(fe.setState({nodesSelectionActive:!1}),Dt.selected&&en?(ct({nodes:[],edges:[Dt]}),(gt=ce.current)==null||gt.blur()):Ge([n])),l&&l(Xe,Dt))},oe=bl(n,fe.getState,c),Ne=bl(n,fe.getState,F),we=bl(n,fe.getState,T),Me=bl(n,fe.getState,P),Le=bl(n,fe.getState,O),Be=(Xe,tt)=>{if(Xe.button!==0)return;const{edges:Ge,isValidConnection:ct}=fe.getState(),en=tt?b:N,Dt=(tt?M:L)||null,gt=tt?"target":"source",wt=ct||JB,zt=tt,Rt=Ge.find(Wt=>Wt.id===n);pe(!0),U==null||U(Xe,Rt,gt);const ht=Wt=>{pe(!1),H==null||H(Wt,Rt,gt)};z2({event:Xe,handleId:Dt,nodeId:en,onConnect:Wt=>K==null?void 0:K(Rt,Wt),isTarget:zt,getState:fe.getState,setState:fe.setState,isValidConnection:wt,edgeUpdaterType:gt,onReconnectEnd:ht})},Pe=Xe=>Be(Xe,!0),Qe=Xe=>Be(Xe,!1),qe=()=>ye(!0),Ze=()=>ye(!1),lt=!$&&!l,Nt=Xe=>{var tt;if(!ae&&M2.includes(Xe.key)&&$){const{unselectNodesAndEdges:Ge,addSelectedEdges:ct,edges:en}=fe.getState();Xe.key==="Escape"?((tt=ce.current)==null||tt.blur(),Ge({edges:[en.find(gt=>gt.id===n)]})):ct([n])}};return he.createElement("g",{className:Ut(["react-flow__edge",`react-flow__edge-${s}`,r,{selected:d,animated:h,inactive:lt,updating:ge}]),onClick:ne,onDoubleClick:oe,onContextMenu:Ne,onMouseEnter:we,onMouseMove:Me,onMouseLeave:Le,onKeyDown:Z?Nt:void 0,tabIndex:Z?0:void 0,role:Z?"button":"img","data-testid":`rf__edge-${n}`,"aria-label":W===null?void 0:W||`Edge from ${N} to ${b}`,"aria-describedby":Z?`${J2}-${J}`:void 0,ref:ce},!se&&he.createElement(e,{id:n,source:N,target:b,selected:d,animated:h,label:f,labelStyle:p,labelShowBg:g,labelBgStyle:v,labelBgPadding:j,labelBgBorderRadius:k,data:o,style:x,sourceX:S,sourceY:E,targetX:R,targetY:I,sourcePosition:A,targetPosition:q,sourceHandleId:L,targetHandleId:M,markerStart:de,markerEnd:me,pathOptions:X,interactionWidth:ee}),Y&&he.createElement(he.Fragment,null,(Y==="source"||Y===!0)&&he.createElement(Aj,{position:A,centerX:S,centerY:E,radius:G,onMouseDown:Pe,onMouseEnter:qe,onMouseOut:Ze,type:"source"}),(Y==="target"||Y===!0)&&he.createElement(Aj,{position:q,centerX:R,centerY:I,radius:G,onMouseDown:Qe,onMouseEnter:qe,onMouseOut:Ze,type:"target"})))};return t.displayName="EdgeWrapper",y.memo(t)};function QB(e){const t={default:Vo(e.default||Sd),straight:Vo(e.bezier||sk),step:Vo(e.step||rk),smoothstep:Vo(e.step||sh),simplebezier:Vo(e.simplebezier||nk)},n={},r=Object.keys(e).filter(s=>!["default","bezier"].includes(s)).reduce((s,o)=>(s[o]=Vo(e[o]||Sd),s),n);return{...t,...r}}function Rj(e,t,n=null){const r=((n==null?void 0:n.x)||0)+t.x,s=((n==null?void 0:n.y)||0)+t.y,o=(n==null?void 0:n.width)||t.width,l=(n==null?void 0:n.height)||t.height;switch(e){case Ae.Top:return{x:r+o/2,y:s};case Ae.Right:return{x:r+o,y:s+l/2};case Ae.Bottom:return{x:r+o/2,y:s+l};case Ae.Left:return{x:r,y:s+l/2}}}function Mj(e,t){return e?e.length===1||!t?e[0]:t&&e.find(n=>n.id===t)||null:null}const e8=(e,t,n,r,s,o)=>{const l=Rj(n,e,t),c=Rj(o,r,s);return{sourceX:l.x,sourceY:l.y,targetX:c.x,targetY:c.y}};function t8({sourcePos:e,targetPos:t,sourceWidth:n,sourceHeight:r,targetWidth:s,targetHeight:o,width:l,height:c,transform:d}){const h={x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x+n,t.x+s),y2:Math.max(e.y+r,t.y+o)};h.x===h.x2&&(h.x2+=1),h.y===h.y2&&(h.y2+=1);const f=Xl({x:(0-d[0])/d[2],y:(0-d[1])/d[2],width:l/d[2],height:c/d[2]}),p=Math.max(0,Math.min(f.x2,h.x2)-Math.max(f.x,h.x)),g=Math.max(0,Math.min(f.y2,h.y2)-Math.max(f.y,h.y));return Math.ceil(p*g)>0}function $j(e){var r,s,o,l,c;const t=((r=e==null?void 0:e[pt])==null?void 0:r.handleBounds)||null,n=t&&(e==null?void 0:e.width)&&(e==null?void 0:e.height)&&typeof((s=e==null?void 0:e.positionAbsolute)==null?void 0:s.x)<"u"&&typeof((o=e==null?void 0:e.positionAbsolute)==null?void 0:o.y)<"u";return[{x:((l=e==null?void 0:e.positionAbsolute)==null?void 0:l.x)||0,y:((c=e==null?void 0:e.positionAbsolute)==null?void 0:c.y)||0,width:(e==null?void 0:e.width)||0,height:(e==null?void 0:e.height)||0},t,!!n]}const n8=[{level:0,isMaxLevel:!0,edges:[]}];function r8(e,t,n=!1){let r=-1;const s=e.reduce((l,c)=>{var f,p;const d=Vn(c.zIndex);let h=d?c.zIndex:0;if(n){const g=t.get(c.target),v=t.get(c.source),j=c.selected||(g==null?void 0:g.selected)||(v==null?void 0:v.selected),k=Math.max(((f=v==null?void 0:v[pt])==null?void 0:f.z)||0,((p=g==null?void 0:g[pt])==null?void 0:p.z)||0,1e3);h=(d?c.zIndex:0)+(j?k:0)}return l[h]?l[h].push(c):l[h]=[c],r=h>r?h:r,l},{}),o=Object.entries(s).map(([l,c])=>{const d=+l;return{edges:c,level:d,isMaxLevel:d===r}});return o.length===0?n8:o}function s8(e,t,n){const r=He(y.useCallback(s=>e?s.edges.filter(o=>{const l=t.get(o.source),c=t.get(o.target);return(l==null?void 0:l.width)&&(l==null?void 0:l.height)&&(c==null?void 0:c.width)&&(c==null?void 0:c.height)&&t8({sourcePos:l.positionAbsolute||{x:0,y:0},targetPos:c.positionAbsolute||{x:0,y:0},sourceWidth:l.width,sourceHeight:l.height,targetWidth:c.width,targetHeight:c.height,width:s.width,height:s.height,transform:s.transform})}):s.edges,[e,t]));return r8(r,t,n)}const a8=({color:e="none",strokeWidth:t=1})=>he.createElement("polyline",{style:{stroke:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),o8=({color:e="none",strokeWidth:t=1})=>he.createElement("polyline",{style:{stroke:e,fill:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"}),Ij={[jd.Arrow]:a8,[jd.ArrowClosed]:o8};function i8(e){const t=bt();return y.useMemo(()=>{var s,o;return Object.prototype.hasOwnProperty.call(Ij,e)?Ij[e]:((o=(s=t.getState()).onError)==null||o.call(s,"009",xs.error009(e)),null)},[e])}const l8=({id:e,type:t,color:n,width:r=12.5,height:s=12.5,markerUnits:o="strokeWidth",strokeWidth:l,orient:c="auto-start-reverse"})=>{const d=i8(t);return d?he.createElement("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${s}`,viewBox:"-10 -10 20 20",markerUnits:o,orient:c,refX:"0",refY:"0"},he.createElement(d,{color:n,strokeWidth:l})):null},c8=({defaultColor:e,rfId:t})=>n=>{const r=[];return n.edges.reduce((s,o)=>([o.markerStart,o.markerEnd].forEach(l=>{if(l&&typeof l=="object"){const c=Ux(l,t);r.includes(c)||(s.push({id:c,color:l.color||e,...l}),r.push(c))}}),s),[]).sort((s,o)=>s.id.localeCompare(o.id))},c$=({defaultColor:e,rfId:t})=>{const n=He(y.useCallback(c8({defaultColor:e,rfId:t}),[e,t]),(r,s)=>!(r.length!==s.length||r.some((o,l)=>o.id!==s[l].id)));return he.createElement("defs",null,n.map(r=>he.createElement(l8,{id:r.id,key:r.id,type:r.type,color:r.color,width:r.width,height:r.height,markerUnits:r.markerUnits,strokeWidth:r.strokeWidth,orient:r.orient})))};c$.displayName="MarkerDefinitions";var u8=y.memo(c$);const d8=e=>({nodesConnectable:e.nodesConnectable,edgesFocusable:e.edgesFocusable,edgesUpdatable:e.edgesUpdatable,elementsSelectable:e.elementsSelectable,width:e.width,height:e.height,connectionMode:e.connectionMode,nodeInternals:e.nodeInternals,onError:e.onError}),u$=({defaultMarkerColor:e,onlyRenderVisibleElements:t,elevateEdgesOnSelect:n,rfId:r,edgeTypes:s,noPanClassName:o,onEdgeContextMenu:l,onEdgeMouseEnter:c,onEdgeMouseMove:d,onEdgeMouseLeave:h,onEdgeClick:f,onEdgeDoubleClick:p,onReconnect:g,onReconnectStart:v,onReconnectEnd:j,reconnectRadius:k,children:x,disableKeyboardA11y:N})=>{const{edgesFocusable:b,edgesUpdatable:S,elementsSelectable:E,width:R,height:I,connectionMode:A,nodeInternals:q,onError:$}=He(d8,At),B=s8(t,q,n);return R?he.createElement(he.Fragment,null,B.map(({level:L,edges:M,isMaxLevel:F})=>he.createElement("svg",{key:L,style:{zIndex:L},width:R,height:I,className:"react-flow__edges react-flow__container"},F&&he.createElement(u8,{defaultColor:e,rfId:r}),he.createElement("g",null,M.map(T=>{const[P,O,G]=$j(q.get(T.source)),[K,U,H]=$j(q.get(T.target));if(!G||!H)return null;let D=T.type||"default";s[D]||($==null||$("011",xs.error011(D)),D="default");const V=s[D]||s.default,J=A===Qa.Strict?U.target:(U.target??[]).concat(U.source??[]),W=Mj(O.source,T.sourceHandle),Z=Mj(J,T.targetHandle),Y=(W==null?void 0:W.position)||Ae.Bottom,X=(Z==null?void 0:Z.position)||Ae.Top,ee=!!(T.focusable||b&&typeof T.focusable>"u"),ae=T.reconnectable||T.updatable,ce=typeof g<"u"&&(ae||S&&typeof ae>"u");if(!W||!Z)return $==null||$("008",xs.error008(W,T)),null;const{sourceX:ge,sourceY:ye,targetX:se,targetY:pe}=e8(P,W,Y,K,Z,X);return he.createElement(V,{key:T.id,id:T.id,className:Ut([T.className,o]),type:D,data:T.data,selected:!!T.selected,animated:!!T.animated,hidden:!!T.hidden,label:T.label,labelStyle:T.labelStyle,labelShowBg:T.labelShowBg,labelBgStyle:T.labelBgStyle,labelBgPadding:T.labelBgPadding,labelBgBorderRadius:T.labelBgBorderRadius,style:T.style,source:T.source,target:T.target,sourceHandleId:T.sourceHandle,targetHandleId:T.targetHandle,markerEnd:T.markerEnd,markerStart:T.markerStart,sourceX:ge,sourceY:ye,targetX:se,targetY:pe,sourcePosition:Y,targetPosition:X,elementsSelectable:E,onContextMenu:l,onMouseEnter:c,onMouseMove:d,onMouseLeave:h,onClick:f,onEdgeDoubleClick:p,onReconnect:g,onReconnectStart:v,onReconnectEnd:j,reconnectRadius:k,rfId:r,ariaLabel:T.ariaLabel,isFocusable:ee,isReconnectable:ce,pathOptions:"pathOptions"in T?T.pathOptions:void 0,interactionWidth:T.interactionWidth,disableKeyboardA11y:N})})))),x):null};u$.displayName="EdgeRenderer";var h8=y.memo(u$);const f8=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function p8({children:e}){const t=He(f8);return he.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:t}},e)}function m8(e){const t=Ai(),n=y.useRef(!1);y.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const g8={[Ae.Left]:Ae.Right,[Ae.Right]:Ae.Left,[Ae.Top]:Ae.Bottom,[Ae.Bottom]:Ae.Top},d$=({nodeId:e,handleType:t,style:n,type:r=Js.Bezier,CustomComponent:s,connectionStatus:o})=>{var I,A,q;const{fromNode:l,handleId:c,toX:d,toY:h,connectionMode:f}=He(y.useCallback($=>({fromNode:$.nodeInternals.get(e),handleId:$.connectionHandleId,toX:($.connectionPosition.x-$.transform[0])/$.transform[2],toY:($.connectionPosition.y-$.transform[1])/$.transform[2],connectionMode:$.connectionMode}),[e]),At),p=(I=l==null?void 0:l[pt])==null?void 0:I.handleBounds;let g=p==null?void 0:p[t];if(f===Qa.Loose&&(g=g||(p==null?void 0:p[t==="source"?"target":"source"])),!l||!g)return null;const v=c?g.find($=>$.id===c):g[0],j=v?v.x+v.width/2:(l.width??0)/2,k=v?v.y+v.height/2:l.height??0,x=(((A=l.positionAbsolute)==null?void 0:A.x)??0)+j,N=(((q=l.positionAbsolute)==null?void 0:q.y)??0)+k,b=v==null?void 0:v.position,S=b?g8[b]:null;if(!b||!S)return null;if(s)return he.createElement(s,{connectionLineType:r,connectionLineStyle:n,fromNode:l,fromHandle:v,fromX:x,fromY:N,toX:d,toY:h,fromPosition:b,toPosition:S,connectionStatus:o});let E="";const R={sourceX:x,sourceY:N,sourcePosition:b,targetX:d,targetY:h,targetPosition:S};return r===Js.Bezier?[E]=ak(R):r===Js.Step?[E]=qx({...R,borderRadius:0}):r===Js.SmoothStep?[E]=qx(R):r===Js.SimpleBezier?[E]=L2(R):E=`M${x},${N} ${d},${h}`,he.createElement("path",{d:E,fill:"none",className:"react-flow__connection-path",style:n})};d$.displayName="ConnectionLine";const y8=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function w8({containerStyle:e,style:t,type:n,component:r}){const{nodeId:s,handleType:o,nodesConnectable:l,width:c,height:d,connectionStatus:h}=He(y8,At);return!(s&&o&&c&&l)?null:he.createElement("svg",{style:e,width:c,height:d,className:"react-flow__edges react-flow__connectionline react-flow__container"},he.createElement("g",{className:Ut(["react-flow__connection",h])},he.createElement(d$,{nodeId:s,handleType:o,style:t,type:n,CustomComponent:r,connectionStatus:h})))}function Oj(e,t){return y.useRef(null),bt(),y.useMemo(()=>t(e),[e])}const h$=({nodeTypes:e,edgeTypes:t,onMove:n,onMoveStart:r,onMoveEnd:s,onInit:o,onNodeClick:l,onEdgeClick:c,onNodeDoubleClick:d,onEdgeDoubleClick:h,onNodeMouseEnter:f,onNodeMouseMove:p,onNodeMouseLeave:g,onNodeContextMenu:v,onSelectionContextMenu:j,onSelectionStart:k,onSelectionEnd:x,connectionLineType:N,connectionLineStyle:b,connectionLineComponent:S,connectionLineContainerStyle:E,selectionKeyCode:R,selectionOnDrag:I,selectionMode:A,multiSelectionKeyCode:q,panActivationKeyCode:$,zoomActivationKeyCode:B,deleteKeyCode:L,onlyRenderVisibleElements:M,elementsSelectable:F,selectNodesOnDrag:T,defaultViewport:P,translateExtent:O,minZoom:G,maxZoom:K,preventScrolling:U,defaultMarkerColor:H,zoomOnScroll:D,zoomOnPinch:V,panOnScroll:J,panOnScrollSpeed:W,panOnScrollMode:Z,zoomOnDoubleClick:Y,panOnDrag:X,onPaneClick:ee,onPaneMouseEnter:ae,onPaneMouseMove:ce,onPaneMouseLeave:ge,onPaneScroll:ye,onPaneContextMenu:se,onEdgeContextMenu:pe,onEdgeMouseEnter:fe,onEdgeMouseMove:de,onEdgeMouseLeave:me,onReconnect:ne,onReconnectStart:oe,onReconnectEnd:Ne,reconnectRadius:we,noDragClassName:Me,noWheelClassName:Le,noPanClassName:Be,elevateEdgesOnSelect:Pe,disableKeyboardA11y:Qe,nodeOrigin:qe,nodeExtent:Ze,rfId:lt})=>{const Nt=Oj(e,VB),Xe=Oj(t,QB);return m8(o),he.createElement(WB,{onPaneClick:ee,onPaneMouseEnter:ae,onPaneMouseMove:ce,onPaneMouseLeave:ge,onPaneContextMenu:se,onPaneScroll:ye,deleteKeyCode:L,selectionKeyCode:R,selectionOnDrag:I,selectionMode:A,onSelectionStart:k,onSelectionEnd:x,multiSelectionKeyCode:q,panActivationKeyCode:$,zoomActivationKeyCode:B,elementsSelectable:F,onMove:n,onMoveStart:r,onMoveEnd:s,zoomOnScroll:D,zoomOnPinch:V,zoomOnDoubleClick:Y,panOnScroll:J,panOnScrollSpeed:W,panOnScrollMode:Z,panOnDrag:X,defaultViewport:P,translateExtent:O,minZoom:G,maxZoom:K,onSelectionContextMenu:j,preventScrolling:U,noDragClassName:Me,noWheelClassName:Le,noPanClassName:Be,disableKeyboardA11y:Qe},he.createElement(p8,null,he.createElement(h8,{edgeTypes:Xe,onEdgeClick:c,onEdgeDoubleClick:h,onlyRenderVisibleElements:M,onEdgeContextMenu:pe,onEdgeMouseEnter:fe,onEdgeMouseMove:de,onEdgeMouseLeave:me,onReconnect:ne,onReconnectStart:oe,onReconnectEnd:Ne,reconnectRadius:we,defaultMarkerColor:H,noPanClassName:Be,elevateEdgesOnSelect:!!Pe,disableKeyboardA11y:Qe,rfId:lt},he.createElement(w8,{style:b,type:N,component:S,containerStyle:E})),he.createElement("div",{className:"react-flow__edgelabel-renderer"}),he.createElement(YB,{nodeTypes:Nt,onNodeClick:l,onNodeDoubleClick:d,onNodeMouseEnter:f,onNodeMouseMove:p,onNodeMouseLeave:g,onNodeContextMenu:v,selectNodesOnDrag:T,onlyRenderVisibleElements:M,noPanClassName:Be,noDragClassName:Me,disableKeyboardA11y:Qe,nodeOrigin:qe,nodeExtent:Ze,rfId:lt})))};h$.displayName="GraphView";var v8=y.memo(h$);const Vx=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Ks={rfId:"1",width:0,height:0,transform:[0,0,1],nodeInternals:new Map,edges:[],onNodesChange:null,onEdgesChange:null,hasDefaultNodes:!1,hasDefaultEdges:!1,d3Zoom:null,d3Selection:null,d3ZoomHandler:void 0,minZoom:.5,maxZoom:2,translateExtent:Vx,nodeExtent:Vx,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:Qa.Strict,domNode:null,paneDragging:!1,noPanClassName:"nopan",nodeOrigin:[0,0],nodeDragThreshold:0,snapGrid:[15,15],snapToGrid:!1,nodesDraggable:!0,nodesConnectable:!0,nodesFocusable:!0,edgesFocusable:!0,edgesUpdatable:!0,elementsSelectable:!0,elevateNodesOnSelect:!0,fitViewOnInit:!1,fitViewOnInitDone:!1,fitViewOnInitOptions:void 0,onSelectionChange:[],multiSelectionActive:!1,connectionStartHandle:null,connectionEndHandle:null,connectionClickStartHandle:null,connectOnClick:!0,ariaLiveMessage:"",autoPanOnConnect:!0,autoPanOnNodeDrag:!0,connectionRadius:20,onError:V6,isValidConnection:void 0},x8=()=>iD((e,t)=>({...Ks,setNodes:n=>{const{nodeInternals:r,nodeOrigin:s,elevateNodesOnSelect:o}=t();e({nodeInternals:Pp(n,r,s,o)})},getNodes:()=>Array.from(t().nodeInternals.values()),setEdges:n=>{const{defaultEdgeOptions:r={}}=t();e({edges:n.map(s=>({...r,...s}))})},setDefaultNodesAndEdges:(n,r)=>{const s=typeof n<"u",o=typeof r<"u",l=s?Pp(n,new Map,t().nodeOrigin,t().elevateNodesOnSelect):new Map;e({nodeInternals:l,edges:o?r:[],hasDefaultNodes:s,hasDefaultEdges:o})},updateNodeDimensions:n=>{const{onNodesChange:r,nodeInternals:s,fitViewOnInit:o,fitViewOnInitDone:l,fitViewOnInitOptions:c,domNode:d,nodeOrigin:h}=t(),f=d==null?void 0:d.querySelector(".react-flow__viewport");if(!f)return;const p=window.getComputedStyle(f),{m22:g}=new window.DOMMatrixReadOnly(p.transform),v=n.reduce((k,x)=>{const N=s.get(x.id);if(N!=null&&N.hidden)s.set(N.id,{...N,[pt]:{...N[pt],handleBounds:void 0}});else if(N){const b=ek(x.nodeElement);!!(b.width&&b.height&&(N.width!==b.width||N.height!==b.height||x.forceUpdate))&&(s.set(N.id,{...N,[pt]:{...N[pt],handleBounds:{source:Cj(".source",x.nodeElement,g,h),target:Cj(".target",x.nodeElement,g,h)}},...b}),k.push({id:N.id,type:"dimensions",dimensions:b}))}return k},[]);e$(s,h);const j=l||o&&!l&&t$(t,{initial:!0,...c});e({nodeInternals:new Map(s),fitViewOnInitDone:j}),(v==null?void 0:v.length)>0&&(r==null||r(v))},updateNodePositions:(n,r=!0,s=!1)=>{const{triggerNodeChanges:o}=t(),l=n.map(c=>{const d={id:c.id,type:"position",dragging:s};return r&&(d.positionAbsolute=c.positionAbsolute,d.position=c.position),d});o(l)},triggerNodeChanges:n=>{const{onNodesChange:r,nodeInternals:s,hasDefaultNodes:o,nodeOrigin:l,getNodes:c,elevateNodesOnSelect:d}=t();if(n!=null&&n.length){if(o){const h=OB(n,c()),f=Pp(h,s,l,d);e({nodeInternals:f})}r==null||r(n)}},addSelectedNodes:n=>{const{multiSelectionActive:r,edges:s,getNodes:o}=t();let l,c=null;r?l=n.map(d=>Zs(d,!0)):(l=ai(o(),n),c=ai(s,[])),Fu({changedNodes:l,changedEdges:c,get:t,set:e})},addSelectedEdges:n=>{const{multiSelectionActive:r,edges:s,getNodes:o}=t();let l,c=null;r?l=n.map(d=>Zs(d,!0)):(l=ai(s,n),c=ai(o(),[])),Fu({changedNodes:c,changedEdges:l,get:t,set:e})},unselectNodesAndEdges:({nodes:n,edges:r}={})=>{const{edges:s,getNodes:o}=t(),l=n||o(),c=r||s,d=l.map(f=>(f.selected=!1,Zs(f.id,!1))),h=c.map(f=>Zs(f.id,!1));Fu({changedNodes:d,changedEdges:h,get:t,set:e})},setMinZoom:n=>{const{d3Zoom:r,maxZoom:s}=t();r==null||r.scaleExtent([n,s]),e({minZoom:n})},setMaxZoom:n=>{const{d3Zoom:r,minZoom:s}=t();r==null||r.scaleExtent([s,n]),e({maxZoom:n})},setTranslateExtent:n=>{var r;(r=t().d3Zoom)==null||r.translateExtent(n),e({translateExtent:n})},resetSelectedElements:()=>{const{edges:n,getNodes:r}=t(),o=r().filter(c=>c.selected).map(c=>Zs(c.id,!1)),l=n.filter(c=>c.selected).map(c=>Zs(c.id,!1));Fu({changedNodes:o,changedEdges:l,get:t,set:e})},setNodeExtent:n=>{const{nodeInternals:r}=t();r.forEach(s=>{s.positionAbsolute=tk(s.position,n)}),e({nodeExtent:n,nodeInternals:new Map(r)})},panBy:n=>{const{transform:r,width:s,height:o,d3Zoom:l,d3Selection:c,translateExtent:d}=t();if(!l||!c||!n.x&&!n.y)return!1;const h=ys.translate(r[0]+n.x,r[1]+n.y).scale(r[2]),f=[[0,0],[s,o]],p=l==null?void 0:l.constrain()(h,f,d);return l.transform(c,p),r[0]!==p.x||r[1]!==p.y||r[2]!==p.k},cancelConnection:()=>e({connectionNodeId:Ks.connectionNodeId,connectionHandleId:Ks.connectionHandleId,connectionHandleType:Ks.connectionHandleType,connectionStatus:Ks.connectionStatus,connectionStartHandle:Ks.connectionStartHandle,connectionEndHandle:Ks.connectionEndHandle}),reset:()=>e({...Ks})}),Object.is),uk=({children:e})=>{const t=y.useRef(null);return t.current||(t.current=x8()),he.createElement(F6,{value:t.current},e)};uk.displayName="ReactFlowProvider";const f$=({children:e})=>y.useContext(rh)?he.createElement(he.Fragment,null,e):he.createElement(uk,null,e);f$.displayName="ReactFlowWrapper";const b8={input:G2,default:Wx,output:Y2,group:lk},k8={default:Sd,straight:sk,step:rk,smoothstep:sh,simplebezier:nk},N8=[0,0],j8=[15,15],S8={x:0,y:0,zoom:1},_8={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},p$=y.forwardRef(({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:s,nodeTypes:o=b8,edgeTypes:l=k8,onNodeClick:c,onEdgeClick:d,onInit:h,onMove:f,onMoveStart:p,onMoveEnd:g,onConnect:v,onConnectStart:j,onConnectEnd:k,onClickConnectStart:x,onClickConnectEnd:N,onNodeMouseEnter:b,onNodeMouseMove:S,onNodeMouseLeave:E,onNodeContextMenu:R,onNodeDoubleClick:I,onNodeDragStart:A,onNodeDrag:q,onNodeDragStop:$,onNodesDelete:B,onEdgesDelete:L,onSelectionChange:M,onSelectionDragStart:F,onSelectionDrag:T,onSelectionDragStop:P,onSelectionContextMenu:O,onSelectionStart:G,onSelectionEnd:K,connectionMode:U=Qa.Strict,connectionLineType:H=Js.Bezier,connectionLineStyle:D,connectionLineComponent:V,connectionLineContainerStyle:J,deleteKeyCode:W="Backspace",selectionKeyCode:Z="Shift",selectionOnDrag:Y=!1,selectionMode:X=Zl.Full,panActivationKeyCode:ee="Space",multiSelectionKeyCode:ae=Nd()?"Meta":"Control",zoomActivationKeyCode:ce=Nd()?"Meta":"Control",snapToGrid:ge=!1,snapGrid:ye=j8,onlyRenderVisibleElements:se=!1,selectNodesOnDrag:pe=!0,nodesDraggable:fe,nodesConnectable:de,nodesFocusable:me,nodeOrigin:ne=N8,edgesFocusable:oe,edgesUpdatable:Ne,elementsSelectable:we,defaultViewport:Me=S8,minZoom:Le=.5,maxZoom:Be=2,translateExtent:Pe=Vx,preventScrolling:Qe=!0,nodeExtent:qe,defaultMarkerColor:Ze="#b1b1b7",zoomOnScroll:lt=!0,zoomOnPinch:Nt=!0,panOnScroll:Xe=!1,panOnScrollSpeed:tt=.5,panOnScrollMode:Ge=Wa.Free,zoomOnDoubleClick:ct=!0,panOnDrag:en=!0,onPaneClick:Dt,onPaneMouseEnter:gt,onPaneMouseMove:wt,onPaneMouseLeave:zt,onPaneScroll:Rt,onPaneContextMenu:ht,children:tn,onEdgeContextMenu:Wt,onEdgeDoubleClick:jt,onEdgeMouseEnter:Jn,onEdgeMouseMove:yn,onEdgeMouseLeave:Qn,onEdgeUpdate:Rn,onEdgeUpdateStart:Yr,onEdgeUpdateEnd:Mn,onReconnect:wn,onReconnectStart:$n,onReconnectEnd:_s,reconnectRadius:In=10,edgeUpdaterRadius:er=10,onNodesChange:Er,onEdgesChange:Xr,noDragClassName:Mt="nodrag",noWheelClassName:ua="nowheel",noPanClassName:tr="nopan",fitView:nn=!1,fitViewOptions:Cr,connectOnClick:Es=!0,attributionPosition:Cs,proOptions:nr,defaultEdgeOptions:Zr,elevateNodesOnSelect:Ts=!0,elevateEdgesOnSelect:Tr=!1,disableKeyboardA11y:Ar=!1,autoPanOnConnect:be=!0,autoPanOnNodeDrag:Re=!0,connectionRadius:ze=20,isValidConnection:rn,onError:Jr,style:Ht,id:rr,nodeDragThreshold:sr,...On},sn)=>{const As=rr||"1";return he.createElement("div",{...On,style:{...Ht,..._8},ref:sn,className:Ut(["react-flow",s]),"data-testid":"rf__wrapper",id:rr},he.createElement(f$,null,he.createElement(v8,{onInit:h,onMove:f,onMoveStart:p,onMoveEnd:g,onNodeClick:c,onEdgeClick:d,onNodeMouseEnter:b,onNodeMouseMove:S,onNodeMouseLeave:E,onNodeContextMenu:R,onNodeDoubleClick:I,nodeTypes:o,edgeTypes:l,connectionLineType:H,connectionLineStyle:D,connectionLineComponent:V,connectionLineContainerStyle:J,selectionKeyCode:Z,selectionOnDrag:Y,selectionMode:X,deleteKeyCode:W,multiSelectionKeyCode:ae,panActivationKeyCode:ee,zoomActivationKeyCode:ce,onlyRenderVisibleElements:se,selectNodesOnDrag:pe,defaultViewport:Me,translateExtent:Pe,minZoom:Le,maxZoom:Be,preventScrolling:Qe,zoomOnScroll:lt,zoomOnPinch:Nt,zoomOnDoubleClick:ct,panOnScroll:Xe,panOnScrollSpeed:tt,panOnScrollMode:Ge,panOnDrag:en,onPaneClick:Dt,onPaneMouseEnter:gt,onPaneMouseMove:wt,onPaneMouseLeave:zt,onPaneScroll:Rt,onPaneContextMenu:ht,onSelectionContextMenu:O,onSelectionStart:G,onSelectionEnd:K,onEdgeContextMenu:Wt,onEdgeDoubleClick:jt,onEdgeMouseEnter:Jn,onEdgeMouseMove:yn,onEdgeMouseLeave:Qn,onReconnect:wn??Rn,onReconnectStart:$n??Yr,onReconnectEnd:_s??Mn,reconnectRadius:In??er,defaultMarkerColor:Ze,noDragClassName:Mt,noWheelClassName:ua,noPanClassName:tr,elevateEdgesOnSelect:Tr,rfId:As,disableKeyboardA11y:Ar,nodeOrigin:ne,nodeExtent:qe}),he.createElement(mB,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:v,onConnectStart:j,onConnectEnd:k,onClickConnectStart:x,onClickConnectEnd:N,nodesDraggable:fe,nodesConnectable:de,nodesFocusable:me,edgesFocusable:oe,edgesUpdatable:Ne,elementsSelectable:we,elevateNodesOnSelect:Ts,minZoom:Le,maxZoom:Be,nodeExtent:qe,onNodesChange:Er,onEdgesChange:Xr,snapToGrid:ge,snapGrid:ye,connectionMode:U,translateExtent:Pe,connectOnClick:Es,defaultEdgeOptions:Zr,fitView:nn,fitViewOptions:Cr,onNodesDelete:B,onEdgesDelete:L,onNodeDragStart:A,onNodeDrag:q,onNodeDragStop:$,onSelectionDrag:T,onSelectionDragStart:F,onSelectionDragStop:P,noPanClassName:tr,nodeOrigin:ne,rfId:As,autoPanOnConnect:be,autoPanOnNodeDrag:Re,onError:Jr,connectionRadius:ze,isValidConnection:rn,nodeDragThreshold:sr}),he.createElement(fB,{onSelectionChange:M}),tn,he.createElement(q6,{proOptions:nr,position:Cs}),he.createElement(xB,{rfId:As,disableKeyboardA11y:Ar})))});p$.displayName="ReactFlow";const E8=e=>({x:e.transform[0],y:e.transform[1],zoom:e.transform[2]});function m$(){return He(E8,At)}const g$=({id:e,x:t,y:n,width:r,height:s,style:o,color:l,strokeColor:c,strokeWidth:d,className:h,borderRadius:f,shapeRendering:p,onClick:g,selected:v})=>{const{background:j,backgroundColor:k}=o||{},x=l||j||k;return he.createElement("rect",{className:Ut(["react-flow__minimap-node",{selected:v},h]),x:t,y:n,rx:f,ry:f,width:r,height:s,fill:x,stroke:c,strokeWidth:d,shapeRendering:p,onClick:g?N=>g(N,e):void 0})};g$.displayName="MiniMapNode";var C8=y.memo(g$);const T8=e=>e.nodeOrigin,A8=e=>e.getNodes().filter(t=>!t.hidden&&t.width&&t.height),qp=e=>e instanceof Function?e:()=>e;function R8({nodeStrokeColor:e="transparent",nodeColor:t="#e2e2e2",nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:s=2,nodeComponent:o=C8,onClick:l}){const c=He(A8,At),d=He(T8),h=qp(t),f=qp(e),p=qp(n),g=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return he.createElement(he.Fragment,null,c.map(v=>{const{x:j,y:k}=Ka(v,d).positionAbsolute;return he.createElement(o,{key:v.id,x:j,y:k,width:v.width,height:v.height,style:v.style,selected:v.selected,className:p(v),color:h(v),borderRadius:r,strokeColor:f(v),strokeWidth:s,shapeRendering:g,onClick:l,id:v.id})}))}var M8=y.memo(R8);const $8=200,I8=150,O8=e=>{const t=e.getNodes(),n={x:-e.transform[0]/e.transform[2],y:-e.transform[1]/e.transform[2],width:e.width/e.transform[2],height:e.height/e.transform[2]};return{viewBB:n,boundingRect:t.length>0?W6(ah(t,e.nodeOrigin),n):n,rfId:e.rfId}},L8="react-flow__minimap-desc";function y$({style:e,className:t,nodeStrokeColor:n="transparent",nodeColor:r="#e2e2e2",nodeClassName:s="",nodeBorderRadius:o=5,nodeStrokeWidth:l=2,nodeComponent:c,maskColor:d="rgb(240, 240, 240, 0.6)",maskStrokeColor:h="none",maskStrokeWidth:f=1,position:p="bottom-right",onClick:g,onNodeClick:v,pannable:j=!1,zoomable:k=!1,ariaLabel:x="React Flow mini map",inversePan:N=!1,zoomStep:b=10,offsetScale:S=5}){const E=bt(),R=y.useRef(null),{boundingRect:I,viewBB:A,rfId:q}=He(O8,At),$=(e==null?void 0:e.width)??$8,B=(e==null?void 0:e.height)??I8,L=I.width/$,M=I.height/B,F=Math.max(L,M),T=F*$,P=F*B,O=S*F,G=I.x-(T-I.width)/2-O,K=I.y-(P-I.height)/2-O,U=T+O*2,H=P+O*2,D=`${L8}-${q}`,V=y.useRef(0);V.current=F,y.useEffect(()=>{if(R.current){const Z=Hn(R.current),Y=ae=>{const{transform:ce,d3Selection:ge,d3Zoom:ye}=E.getState();if(ae.sourceEvent.type!=="wheel"||!ge||!ye)return;const se=-ae.sourceEvent.deltaY*(ae.sourceEvent.deltaMode===1?.05:ae.sourceEvent.deltaMode?1:.002)*b,pe=ce[2]*Math.pow(2,se);ye.scaleTo(ge,pe)},X=ae=>{const{transform:ce,d3Selection:ge,d3Zoom:ye,translateExtent:se,width:pe,height:fe}=E.getState();if(ae.sourceEvent.type!=="mousemove"||!ge||!ye)return;const de=V.current*Math.max(1,ce[2])*(N?-1:1),me={x:ce[0]-ae.sourceEvent.movementX*de,y:ce[1]-ae.sourceEvent.movementY*de},ne=[[0,0],[pe,fe]],oe=ys.translate(me.x,me.y).scale(ce[2]),Ne=ye.constrain()(oe,ne,se);ye.transform(ge,Ne)},ee=_2().on("zoom",j?X:null).on("zoom.wheel",k?Y:null);return Z.call(ee),()=>{Z.on("zoom",null)}}},[j,k,N,b]);const J=g?Z=>{const Y=yr(Z);g(Z,{x:Y[0],y:Y[1]})}:void 0,W=v?(Z,Y)=>{const X=E.getState().nodeInternals.get(Y);v(Z,X)}:void 0;return he.createElement(Qb,{position:p,style:e,className:Ut(["react-flow__minimap",t]),"data-testid":"rf__minimap"},he.createElement("svg",{width:$,height:B,viewBox:`${G} ${K} ${U} ${H}`,role:"img","aria-labelledby":D,ref:R,onClick:J},x&&he.createElement("title",{id:D},x),he.createElement(M8,{onClick:W,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:o,nodeClassName:s,nodeStrokeWidth:l,nodeComponent:c}),he.createElement("path",{className:"react-flow__minimap-mask",d:`M${G-O},${K-O}h${U+O*2}v${H+O*2}h${-U-O*2}z
57
- M${A.x},${A.y}h${A.width}v${A.height}h${-A.width}z`,fill:d,fillRule:"evenodd",stroke:h,strokeWidth:f,pointerEvents:"none"})))}y$.displayName="MiniMap";var P8=y.memo(y$);function D8(){return he.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},he.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function F8(){return he.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},he.createElement("path",{d:"M0 0h32v4.2H0z"}))}function B8(){return he.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},he.createElement("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"}))}function q8(){return he.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},he.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"}))}function U8(){return he.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},he.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"}))}const zn=({children:e,className:t,...n})=>he.createElement("button",{type:"button",className:Ut(["react-flow__controls-button",t]),...n},e);zn.displayName="ControlButton";const z8=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),w$=({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:s,onZoomIn:o,onZoomOut:l,onFitView:c,onInteractiveChange:d,className:h,children:f,position:p="bottom-left"})=>{const g=bt(),[v,j]=y.useState(!1),{isInteractive:k,minZoomReached:x,maxZoomReached:N}=He(z8,At),{zoomIn:b,zoomOut:S,fitView:E}=Ai();if(y.useEffect(()=>{j(!0)},[]),!v)return null;const R=()=>{b(),o==null||o()},I=()=>{S(),l==null||l()},A=()=>{E(s),c==null||c()},q=()=>{g.setState({nodesDraggable:!k,nodesConnectable:!k,elementsSelectable:!k}),d==null||d(!k)};return he.createElement(Qb,{className:Ut(["react-flow__controls",h]),position:p,style:e,"data-testid":"rf__controls"},t&&he.createElement(he.Fragment,null,he.createElement(zn,{onClick:R,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:N},he.createElement(D8,null)),he.createElement(zn,{onClick:I,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:x},he.createElement(F8,null))),n&&he.createElement(zn,{className:"react-flow__controls-fitview",onClick:A,title:"fit view","aria-label":"fit view"},he.createElement(B8,null)),r&&he.createElement(zn,{className:"react-flow__controls-interactive",onClick:q,title:"toggle interactivity","aria-label":"toggle interactivity"},k?he.createElement(U8,null):he.createElement(q8,null)),f)};w$.displayName="Controls";var W8=y.memo(w$),br;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(br||(br={}));function H8({color:e,dimensions:t,lineWidth:n}){return he.createElement("path",{stroke:e,strokeWidth:n,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`})}function V8({color:e,radius:t}){return he.createElement("circle",{cx:t,cy:t,r:t,fill:e})}const G8={[br.Dots]:"#91919a",[br.Lines]:"#eee",[br.Cross]:"#e2e2e2"},K8={[br.Dots]:1,[br.Lines]:1,[br.Cross]:6},Y8=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function v$({id:e,variant:t=br.Dots,gap:n=20,size:r,lineWidth:s=1,offset:o=2,color:l,style:c,className:d}){const h=y.useRef(null),{transform:f,patternId:p}=He(Y8,At),g=l||G8[t],v=r||K8[t],j=t===br.Dots,k=t===br.Cross,x=Array.isArray(n)?n:[n,n],N=[x[0]*f[2]||1,x[1]*f[2]||1],b=v*f[2],S=k?[b,b]:N,E=j?[b/o,b/o]:[S[0]/o,S[1]/o];return he.createElement("svg",{className:Ut(["react-flow__background",d]),style:{...c,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:h,"data-testid":"rf__background"},he.createElement("pattern",{id:p+e,x:f[0]%N[0],y:f[1]%N[1],width:N[0],height:N[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${E[0]},-${E[1]})`},j?he.createElement(V8,{color:g,radius:b/o}):he.createElement(H8,{dimensions:S,color:g,lineWidth:s})),he.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${p+e})`}))}v$.displayName="Background";var X8=y.memo(v$);function Z8(e,t){return e?t==="gone"?"entering":t==="leaving"?"here":t:t==="gone"?"gone":"leaving"}function Fa(e){return e!=="gone"}function cd(e,t){const[n,r]=y.useState(()=>e?"here":"gone"),s=y.useRef(null);return y.useEffect(()=>{r(o=>Z8(e,o))},[e]),y.useEffect(()=>{if(n==="leaving")return s.current=window.setTimeout(()=>r("gone"),t),()=>{s.current!=null&&window.clearTimeout(s.current)}},[n,t]),y.useEffect(()=>{n==="entering"&&r("here")},[n]),n}const Lj="agent-dag.fm-custom-stations",Pj="agent-dag.fm-muted",Gx="custom:",J8=/^UC[A-Za-z0-9_-]{22}$/,Q8=/^[A-Za-z0-9_-]{11}$/,dk=/^[A-Za-z0-9_-]{1,80}$/,eq=/\.(mp3|aac|ogg)$/i,tq=/\.m3u8$/i,x$=2048,Ql=80;function to(e){return`${Gx}${e}`}function wi(e){if(!e.startsWith(Gx))return null;const t=e.slice(Gx.length);return dk.test(t)?t:null}function Dj(e){return wi(e)??e}function nq(e){return e?"This station could not be played. Check its link, pick another, or pick it again to retry.":"This station is not live right now. Pick another, or pick it again later to retry."}function hk(e){var l,c;const t=e.trim();if(t.length>x$)return null;let n;try{n=new URL(t)}catch{return null}if(n.protocol!=="https:"||n.username||n.password)return null;const r=n.toString(),s=n.hostname.toLowerCase();if(s==="youtube.com"||s==="www.youtube.com"||s==="m.youtube.com"){if(n.port)return null;const d=(l=/^\/channel\/([^/]+)(?:\/live)?\/?$/.exec(n.pathname))==null?void 0:l[1];if(d&&J8.test(d))return{kind:"youtube-channel",url:r,channel:d};const h=(c=/^\/@([^/]+)\/live\/?$/.exec(n.pathname))==null?void 0:c[1];if(h&&/^[A-Za-z0-9._-]{1,64}$/.test(h))return{kind:"youtube-handle",url:r,handle:h};if(n.pathname==="/watch"){const f=n.searchParams.get("v")??"";if(Q8.test(f))return{kind:"youtube-video",url:r,video:f}}return null}return tq.test(n.pathname)?{kind:"direct-audio",url:r,format:"hls"}:eq.test(n.pathname)?{kind:"direct-audio",url:r,format:"audio"}:null}function rq(e){return e==="1"}function sq(e){if(!e)return[];let t;try{t=JSON.parse(e)}catch{return[]}if(!Array.isArray(t))return[];const n=new Set,r=[];for(const s of t){if(!s||typeof s!="object")continue;const o=typeof s.id=="string"?s.id:"",l=typeof s.name=="string"?s.name.trim():"",c=typeof s.url=="string"?s.url.trim():"",d=hk(c);!dk.test(o)||n.has(o)||!l||l.length>Ql||!d||(n.add(o),r.push({id:o,name:l,url:d.url}))}return r}function aq(e,t,n){const r=wi(e??"");return r&&t.some(s=>s.id===r)?to(r):n(e)}function oq(e,t){return e===to(t)?"claude-fm":e}function iq(){try{if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch{}return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function lq(e,t,n=iq()){const r=e.trim(),s=hk(t);return!r||r.length>Ql||!dk.test(n)||!s?null:{id:n,name:r,url:s.url}}const b$=.2,k$=1.6;function cq(e){if(!e)return null;let t;try{t=JSON.parse(e)}catch{return null}if(!t||typeof t!="object")return null;const{x:n,y:r,zoom:s}=t;return typeof n!="number"||typeof r!="number"||typeof s!="number"||!Number.isFinite(n)||!Number.isFinite(r)||!Number.isFinite(s)||s<b$||s>k$?null:{x:n,y:r,zoom:s}}function Kx({durationMs:e,documentHidden:t,reducedMotion:n=fk()}){return t||n?!1:Number.isFinite(e)&&e>0}function fk(){return typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches}const uq=["us-gov","global","apac","us","eu","jp","au"],dq=new RegExp(`^(?:(?:${uq.join("|")})\\.)?anthropic\\.`,"i");function gs(e){return e.replace(dq,"")}const hq=/^(?:claude[-_]|gpt[-_]|o\d|codex[-_])/i,fq=new Set(["tool_input","tool_response"]);function N$(e,t=0){if(!e||typeof e!="object"||t>6)return null;const n=e;if(typeof n.model=="string"&&hq.test(gs(n.model)))return n.model;for(const[r,s]of Object.entries(n)){if(fq.has(r))continue;const o=N$(s,t+1);if(o)return o}return null}function pk(){return{agents:new Map,toolIndex:new Map,activeSubagentStack:new Map,subagentTombstones:new Map,parkedEnrichment:new Map,pendingSubagentModels:new Map,lastSeq:0,seqEpoch:null,totalEvents:0,revision:0}}function Ns(e,t){return`${e}::${t}`}function Ri(e,t){return`${e}\0${t}`}const pq=/[0-9a-f]{16,}/i,mq=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function j$(e){return pq.test(e)||mq.test(e)}function gq(e){if(!e)return;const t=e.replace(/\\/g,"/").split("/").filter(Boolean);for(let n=t.length-1;n>=0;n--)if(!j$(t[n]))return t[n];return t[t.length-1]}function S$(){return{inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0}}function _$(e){const t=e.cache_creation,n=t&&typeof t=="object"?t:e,r=n.ephemeral_1h_input_tokens,s=n.ephemeral_5m_input_tokens;return typeof r!="number"&&typeof s!="number"?{}:{cacheCreate1hTokens:Number(r??0),cacheCreate5mTokens:Number(s??0)}}function mk(e){const t=_$(e),n={inputTokens:Number(e.input_tokens??0),outputTokens:Number(e.output_tokens??0),cacheReadTokens:Number(e.cache_read_input_tokens??e.cached_input_tokens??0),cacheCreateTokens:Number(e.cache_creation_input_tokens??e.cache_write_input_tokens??0),cacheCreate1hTokens:t.cacheCreate1hTokens,cacheCreate5mTokens:t.cacheCreate5mTokens};return typeof e.reasoning_output_tokens=="number"&&(n.reasoningOutputTokens=Number(e.reasoning_output_tokens)),n}function yq(e){if(!e||typeof e!="object"||Array.isArray(e))return;const t={};for(const[n,r]of Object.entries(e)){if(!n||!r||typeof r!="object")continue;const s=r;t[n]=mk(s);const o=wq(s.speeds);o&&(t[n].bySpeed=o)}return Object.keys(t).length?t:void 0}function wq(e){if(!e||typeof e!="object"||Array.isArray(e))return;const t=Object.entries(e).filter(([n,r])=>n&&r&&typeof r=="object").map(([n,r])=>[n,mk(r)]);return t.length?Object.fromEntries(t):void 0}function E$(e,t=0){if(!e||typeof e!="object"||t>6)return null;const n=e;if(typeof n.input_tokens=="number"||typeof n.output_tokens=="number"||typeof n.cache_read_input_tokens=="number"||typeof n.cache_creation_input_tokens=="number")return{inputTokens:Number(n.input_tokens??0),outputTokens:Number(n.output_tokens??0),cacheReadTokens:Number(n.cache_read_input_tokens??0),cacheCreateTokens:Number(n.cache_creation_input_tokens??0),..._$(n)};for(const r of Object.values(n)){const s=E$(r,t+1);if(s)return s}return null}function gk(e){return gq(e)}function yk(e){const t=e.agent_type??e.subagent_type;return t&&!j$(t)?t:"subagent"}function Mi(e){return e.agent_id?e.agent_id:e.parent_tool_use_id?e.parent_tool_use_id:null}function ec(e,t){!e.cwd&&t.cwd&&(e.cwd=t.cwd,e.cwdBasename=gk(t.cwd))}function C$(e,t){e.label==="session"&&t.cwd&&(e.label=gk(t.cwd)??"session")}function T$(e,t){const n=yk(t);n&&(e.label==="subagent"||!e.label)&&(e.label=n)}function $i(e,t,n,r){const s=t;let o=e.agents.get(s);return o||(o={id:s,sessionId:t,label:"session",kind:"root",state:"active",startedAt:n,lastEventAt:n,tools:[],prompts:[],toolCount:0,childCount:0,synthetic:r,usage:S$()},e.agents.set(s,o),o)}function A$(e,t,n,r){const s=Ns(t,n),o=e.agents.get(s);return o?(ec(o,r),T$(o,r),o):null}function vq(e,t,n){var h;const r=t.session_id??"unknown",s=Mi(t);if(s){const f=A$(e,r,s,t);if(f)return f}const l=((h=e.agents.get(r))==null?void 0:h.keyedSubagents)===!0?void 0:e.activeSubagentStack.get(r),c=l&&l.length>0?l[l.length-1]:null;if(c){const f=e.agents.get(Ns(r,c));if(f)return ec(f,t),f}const d=$i(e,r,n,t.hook_event_name!=="SessionStart");return ec(d,t),C$(d,t),d}function xq(e,t,n,r){if(t==="SubagentStart"||t==="SubagentStop"||typeof n.agent_id!="string"||n.agent_id==="")return!1;const s=e.agents.get(r);return!s||s.keyedSubagents?!1:(s.keyedSubagents=!0,!0)}function bq(e,t,n,r,s){const o=Ns(t,n),l=$i(e,t,s,!0);let c=e.agents.get(o);if(c)return ec(c,r),T$(c,r),c;c={id:o,sessionId:t,label:yk(r),kind:"subagent",parentId:l.id,state:"active",startedAt:s,tools:[],prompts:[],cwd:r.cwd,cwdBasename:gk(r.cwd),toolCount:0,childCount:0,usage:S$()},e.agents.set(o,c);const d=e.pendingSubagentModels.get(o);return d&&(c.model=d,e.pendingSubagentModels.delete(o)),l.childCount+=1,c}function kq(e,t,n){const r=e.activeSubagentStack.get(t)??[];r.includes(n)||(r.push(n),e.activeSubagentStack.set(t,r))}function R$(e,t,n){const r=e.activeSubagentStack.get(t);if(r){for(let s=r.length-1;s>=0;s--)if(r[s]===n){r.splice(s,1);break}r.length===0&&e.activeSubagentStack.delete(t)}}function M$(){return{msgsUser:0,msgsAssistant:0,toolUses:0,toolResults:0,systemReminders:0,currentContextTokens:0,memoryFiles:[]}}function $$(e,t,n){if(typeof t.model_context_window=="number"&&t.model_context_window>0){const r=e.agents.get(n);r&&(r.contextWindow=t.model_context_window)}if(typeof t.approval_policy=="string"&&t.approval_policy){const r=e.agents.get(n);r&&(r.approvalPolicy=t.approval_policy)}if(typeof t.context_tokens=="number"&&t.context_tokens>=0){const r=e.agents.get(n);r&&(r.context={...r.context??M$(),currentContextTokens:t.context_tokens})}}const Nq=6e4,Fj=64;function I$(e,t,n){const r=typeof t.model=="string"?t.model:null;if(r){const o=e.agents.get(n);o&&(o.model=r)}const s=t.subagentModels;if(s&&typeof s=="object")for(const[o,l]of Object.entries(s)){if(typeof l!="string")continue;const c=Ns(n,o),d=e.agents.get(c);if(d)d.model=l,e.pendingSubagentModels.delete(c);else if(e.pendingSubagentModels.delete(c),e.pendingSubagentModels.set(c,l),e.pendingSubagentModels.size>256){const h=e.pendingSubagentModels.keys().next().value;h!==void 0&&e.pendingSubagentModels.delete(h)}}}function O$(e,t,n){const r=t.context??null;if(r){const s=e.agents.get(n);if(s){const o=s.context??M$(),l=(d,h)=>typeof r[d]=="number"?r[d]:h,c=Array.isArray(r.memoryFiles)?r.memoryFiles:Array.isArray(r.claudeMdFiles)?r.claudeMdFiles:null;s.context={msgsUser:l("msgsUser",o.msgsUser),msgsAssistant:l("msgsAssistant",o.msgsAssistant),toolUses:l("toolUses",o.toolUses),toolResults:l("toolResults",o.toolResults),systemReminders:l("systemReminders",o.systemReminders),currentContextTokens:l("currentContextTokens",o.currentContextTokens),memoryFiles:c??o.memoryFiles}}}}function L$(e,t,n){const r=e.agents.get(n);if(r){const s=typeof t.sessionName=="string"?t.sessionName.trim():"",o=typeof t.sessionTitle=="string"?t.sessionTitle.trim():"";s&&(r.sessionName=s),o&&(r.sessionTitle=o);const l=r.sessionName??"";r.sessionTitle&&l&&r.sessionTitle.toLowerCase()===l.toLowerCase()&&(r.sessionTitle=void 0)}}function jq(e,t,n){const r=e.agents.get(n);if(r){const s=t.recap;s===null?r.recap=void 0:s&&typeof s.text=="string"&&s.text.trim()&&Number.isFinite(s.at)&&(r.recap={text:s.text.trim(),at:s.at})}}function P$(e,t,n){const r=e.agents.get(n),s=t.activity;!r||!s||typeof s.text!="string"||!s.text.trim()||!Number.isFinite(s.at)||r.activity&&s.at<r.activity.at||(r.activity={text:s.text.trim(),source:s.source==="said"?"said":"tool",at:s.at})}const Sq=new Set(["working","blocked","done","failed","stopped"]);function D$(e,t,n){const r=e.agents.get(n);if(!r)return;const s=t.job;if(s===null){r.job=void 0;return}if(!s||typeof s!="object"||!Sq.has(s.state))return;const o=l=>typeof l=="string"&&l.trim()?l.trim():void 0;r.job={id:o(s.id)??"",state:s.state,detail:o(s.detail)??"",needs:o(s.needs),suggestedReply:o(s.suggestedReply),result:o(s.result),updatedAt:Number.isFinite(s.updatedAt)?s.updatedAt:0}}function _q(e,t,n,r){const s=t.kind==="thinking"||t.kind==="text"||t.kind==="tool_use"?t.kind:null,o=typeof t.at=="number"&&Number.isFinite(t.at)?t.at:r;if(!s)return;const l=e.agents.get(n);if(l&&!(l.lastOutputAt!=null&&o<=l.lastOutputAt)){if(l.lastOutputAt=o,s!=="tool_use"){const c=(l.outputs??[]).filter(d=>o-d<Nq);c.push(o),l.outputs=c.length>Fj?c.slice(-Fj):c}e.revision+=1}}function F$(e,t,n){const r=t.usage??null;if(r){const s=e.agents.get(n);s&&(Object.assign(s.usage,mk(r)),s.usageByModel=yq(t.usageByModel))}}const Eq=256,ud={ModelObserved:I$,UsageObserved:F$,ContextObserved:O$,SessionNamed:L$,ActivityObserved:P$,JobObserved:D$},fs=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),qu=e=>typeof e=="string"&&e.trim()!=="",Cq=[["model_context_window",e=>typeof e=="number"&&e>0],["approval_policy",e=>typeof e=="string"&&e!==""],["context_tokens",e=>typeof e=="number"&&e>=0]],Tq=new Set(["working","blocked","done","failed","stopped"]),Bj=e=>fs(e)&&typeof e.text=="string"&&e.text.trim()!==""&&Number.isFinite(e.at);function Aq(e,t){if(!e)return t;const n={...e};for(const[s,o]of Object.entries(t))o!==void 0&&(n[s]=o);const r=s=>{s in e?n[s]=e[s]:delete n[s]};for(const[s,o]of Cq)o(t[s])||r(s);switch(t.hook_event_name){case"ModelObserved":typeof t.model=="string"&&t.model!==""||r("model"),(fs(e.subagentModels)||fs(t.subagentModels))&&(n.subagentModels={...fs(e.subagentModels)?e.subagentModels:{},...fs(t.subagentModels)?t.subagentModels:{}});break;case"ContextObserved":{if(!fs(t.context)){r("context");break}const s=fs(e.context)?{...e.context}:{};for(const[o,l]of Object.entries(t.context))(typeof l=="number"||Array.isArray(l))&&(s[o]=l);n.context=s;break}case"SessionNamed":{const s=qu(t.sessionName)?t.sessionName:e.sessionName??null;let o=qu(t.sessionTitle)?t.sessionTitle:e.sessionTitle??null;qu(s)&&qu(o)&&o.trim().toLowerCase()===s.trim().toLowerCase()&&(o=null),n.sessionName=s,n.sessionTitle=o;break}case"ActivityObserved":(!Bj(t.activity)||Bj(e.activity)&&t.activity.at<e.activity.at)&&r("activity");break;case"JobObserved":t.job===null||fs(t.job)&&Tq.has(t.job.state)||r("job");break;case"UsageObserved":fs(t.usage)?t.usageByModel===void 0&&delete n.usageByModel:(r("usage"),r("usageByModel"));break}return n}function Rq(e,t,n,r){if(!(t in ud)||e.agents.has(r))return!1;const s=e.parkedEnrichment.get(r)??new Map,o=Aq(s.get(t),n);for(s.delete(t),s.set(t,o),e.parkedEnrichment.delete(r),e.parkedEnrichment.set(r,s);e.parkedEnrichment.size>Eq;){const l=e.parkedEnrichment.keys().next().value;if(l===void 0)break;e.parkedEnrichment.delete(l)}return!0}function Mq(e,t){var r;const n=e.parkedEnrichment.get(t);if(!(!n||!e.agents.has(t))){e.parkedEnrichment.delete(t);for(const[s,o]of n)$$(e,o,t),(r=ud[s])==null||r.call(ud,e,o,t)}}function B$(e,t){e.parkedEnrichment.delete(t)}function Lt(e,t){return Object.hasOwn(e,t)?e[t]:void 0}const $q=/^\s*<task-notification>([\s\S]*?)<\/task-notification>/;function qj(e,t){var n;return((n=new RegExp(`<${t}>([\\s\\S]*?)</${t}>`).exec(e))==null?void 0:n[1].trim())||void 0}const Iq={completed:"background task finished",failed:"background task failed",killed:"background task stopped"};function oh(e){const t=$q.exec(e);if(!t)return null;const n=qj(t[1],"status");return{label:(n?Lt(Iq,n):void 0)??"background task update",detail:qj(t[1],"summary")}}function q$(e){return e.filter(t=>!oh(t.text))}const Uj=2e3;function Oq(e,t,n){for(let r=e.length-1;r>=0;r--){const s=e[r];if(s.at<t-Uj)return!1;if(s.text===n&&s.at<=t+Uj)return!0}return!1}function Lq(e,t,n){if(Oq(e,t,n))return!1;let r=e.length;for(;r>0&&e[r-1].at>t;)r--;return e.splice(r,0,{at:t,text:n}),!0}const _d=2e3;function Pq(e){const t=e.prompts[e.prompts.length-1];return t&&t.at>e.startedAt?t.at:e.startedAt}const zj=["B","KB","MB","GB","TB"];function Qs(e){if(e==null||!Number.isFinite(e)||e<0)return"—";if(e===0)return"0 B";let t=e,n=0;for(;n<zj.length-1&&Number(t.toFixed(1))>=1024;)t/=1024,n++;return`${t.toFixed(1)} ${zj[n]}`}const Dq=60,Fq=6e3,Gn=e=>e!=null&&typeof e=="object"&&!Array.isArray(e),jn=e=>typeof e=="string"?e:null;function Bq(e){return Gn(e)&&e.ccdeck_truncated===!0&&typeof e.chars=="number"&&Object.keys(e).length===2?e.chars:null}function vi(e){const t=Bq(e);if(t!=null)return`(too large to show — ${Qs(t)}, cut by the hook)`;if(Array.isArray(e)){const n=e.map(vi);return n.some((r,s)=>r!==e[s])?n:e}if(Gn(e)){let n=!1;const r={};for(const[s,o]of Object.entries(e))r[s]=vi(o),r[s]!==o&&(n=!0);return n?r:e}return e}function no(e,t=""){if(e==null)return"(none)";if(typeof e=="string")return e;if(typeof e!="object")return String(e);const n=Array.isArray(e),r=n?e.map((o,l)=>[String(l),o]):Object.entries(e);if(r.length===0)return n?"[]":"{}";const s=[];for(const[o,l]of r){const c=n?`${t}-`:`${t}${o}:`;if(typeof l=="string"&&l.includes(`
58
- `)){s.push(c);for(const d of l.split(`
59
- `))s.push(`${t} ${d}`)}else if(l!==null&&typeof l=="object"){const d=no(l,`${t} `);d==="[]"||d==="{}"?s.push(`${c} ${d}`):s.push(c,d)}else s.push(`${c} ${l===void 0?"(none)":String(l)}`)}return s.join(`
60
- `)}function qq(e){return e.lines??e.text.split(`
61
- `).map(t=>({text:t}))}function U$(e,t){if(t)return{shown:e,cut:!1};const n=[];let r=0;for(const s of e){if(n.length===Dq)return{shown:n,cut:!0};const o=Fq-r;if(s.text.length>o)return n.push({...s,text:`${s.text.slice(0,Math.max(o,0))}…`}),{shown:n,cut:!0};n.push(s),r+=s.text.length+1}return{shown:n,cut:!1}}function Uq(e,t){return U$(e,!1).cut?t?{label:"show less",expanded:!0}:{label:"show all",expanded:!1}:null}const Qt=(e,t,n=!1)=>({...e?{label:e}:{},text:t,...n?{err:!0}:{}}),Sn=(e,t)=>({label:e,text:t,inline:!0}),z$=(e,t)=>({label:e,text:t.map(n=>n.text).join(`
62
- `),lines:t});function zq(e,t){return[...e.split(`
63
- `).map(n=>({text:`- ${n}`,tone:"del"})),...t.split(`
64
- `).map(n=>({text:`+ ${n}`,tone:"add"}))]}function Wq(e){if(!Array.isArray(e)||e.length===0)return null;const t=[];for(const n of e){if(!Gn(n)||!Array.isArray(n.lines))return null;t.push({text:`@@ -${n.oldStart},${n.oldLines} +${n.newStart},${n.newLines} @@`,tone:"ctx"});for(const r of n.lines){const s=String(r);t.push(s.startsWith("+")?{text:s,tone:"add"}:s.startsWith("-")?{text:s,tone:"del"}:{text:s})}}return t}function Wj(e){if(typeof e=="string")return[Qt(void 0,e)];if(!Gn(e))return[Qt(void 0,no(e))];const t=[],n=jn(e.type);n==="create"&&t.push(Sn("result","created the file"));const r=Wq(e.structuredPatch);return r&&t.push(z$("applied",r)),e.userModified===!0&&t.push(Sn("note","the user changed it before it was applied")),t.length?t:[Sn("result",n==="update"?"updated the file":"done")]}function Hq(e){const t=typeof e.offset=="number"?e.offset:null,n=typeof e.limit=="number"?e.limit:null;if(t==null&&n==null)return null;const r=t??1;return n!=null?`${r}–${r+n-1}`:`from ${r}`}function Vq(e){if(typeof e=="string")return[Qt(void 0,e)];const t=Gn(e)&&Gn(e.file)?e.file:null,n=jn(t==null?void 0:t.content);if(t&&n!=null){const s=[],o=Number(t.numLines),l=Number(t.totalLines),c=Number(t.startLine);return Number.isFinite(o)&&Number.isFinite(l)&&l>0&&s.push(Sn("lines",o>=l?`all ${l}`:Number.isFinite(c)?`${c}–${c+o-1} of ${l}`:`${o} of ${l}`)),s.push(Qt("content",n)),s}const r=Gn(e)?jn(e.type):null;return r&&r!=="text"?[Sn("result",`${/^[aeiou]/i.test(r)?"an":"a"} ${r} file`)]:[Qt(void 0,no(e))]}function Gq(e){if(typeof e=="string")return[Qt("output",e)];if(!Gn(e))return[Qt(void 0,no(e))];const t=jn(e.stdout),n=jn(e.stderr);if(t==null&&n==null)return[Qt(void 0,no(e))];const r=[];return t&&r.push(Qt("output",t.replace(/\n$/,""))),n&&r.push(Qt("errors",n.replace(/\n$/,""),!0)),e.interrupted===!0&&r.push(Sn("note","interrupted before it finished")),r.length?r:[Sn("output","none")]}function Kq(e,t,n){const r=vi(t),s=vi(n),o=Gn(r)?r:null;if(o&&(e==="Edit"||e==="MultiEdit")){const l=jn(o.file_path),c=(e==="MultiEdit"?Array.isArray(o.edits)?o.edits:[]:[o]).filter(Gn).filter(d=>jn(d.old_string)!=null&&jn(d.new_string)!=null);if(l&&c.length){const d=[Sn("file",l)];return c.forEach((h,f)=>{const p=h.replace_all===!0?", every occurrence":"";d.push(z$(c.length>1?`change ${f+1}${p}`:`change${p}`,zq(h.old_string,h.new_string)))}),{input:d,response:Wj(s)}}}if(o&&e==="Write"){const l=jn(o.file_path),c=jn(o.content);if(l&&c!=null)return{input:[Sn("file",l),Qt("content",c)],response:Wj(s)}}if(o&&e==="Read"){const l=jn(o.file_path);if(l){const c=Hq(o);return{input:c?[Sn("file",l),Sn("lines",c)]:[Sn("file",l)],response:Vq(s)}}}if(o&&e==="Bash"){const l=jn(o.command);if(l!=null){const c=jn(o.description);return{input:c?[Qt("command",l),Sn("why",c)]:[Qt("command",l)],response:Gq(s)}}}return{input:[Qt(void 0,no(r))],response:[Qt(void 0,no(s))]}}function Hj(e,t,n){const r=vi(n);if(r==null)return"";if(typeof r=="string")return r;if(Gn(r)){if(e==="Bash"&&t==="input"&&typeof r.command=="string")return r.command;if(e==="Bash"&&t==="response"&&(typeof r.stdout=="string"||typeof r.stderr=="string"))return[r.stdout,r.stderr].filter(s=>typeof s=="string"&&s!=="").join(`
65
- `);if(e==="Read"&&t==="response"&&Gn(r.file)&&typeof r.file.content=="string")return r.file.content}try{return JSON.stringify(r,null,2)??String(r)}catch{return String(r)}}function Ed(e,t=80){const n=vi(e);if(n==null)return"";if(typeof n=="string")return n.length>t?n.slice(0,t-1)+"…":n;try{const r=JSON.stringify(n);return r.length>t?r.slice(0,t-1)+"…":r}catch{return String(n)}}const Vj=200;function W$(e,t,n){const r=t.ok===!1;t.ok=n,e&&r===n&&(e.toolErrorCount=(e.toolErrorCount??0)+(n?-1:1))}function H$(e,t){return t.agentId==null?void 0:e.agents.get(t.agentId)}function Ll(e,t,n){const r=e.toolCountByName??(e.toolCountByName=new Map),s=(r.get(t)??0)+n;s>0?r.set(t,s):r.delete(t)}function Yq(e,t,n){var r;return((r=e.get(t))==null?void 0:r.tools.find(s=>s.id===n))??null}const V$=25;function G$(e,t){const n=t.tools;if(n.length>Vj){const r=n.splice(0,n.length-Vj);for(const s of r)Y$(e,t,s)}for(let r=n.length-V$-1;r>=0;r--){const s=n[r];if(s.trimmed)break;s.input=void 0,s.response=void 0,s.trimmed=!0}}function Xq(e,t,n){const r=e.toolIndex.get(Ri(t.sessionId,n));if(r)return r;for(let s=t.tools.length-1;s>=0;s--)if(t.tools[s].id===n)return t.tools[s];return null}function K$(e,t){for(const n of t.tools)Y$(e,t,n)}function Y$(e,t,n){const r=Ri(t.sessionId,n.id);e.toolIndex.get(r)===n&&e.toolIndex.delete(r)}function Zq(e,t){const n=e.agents.get(t);if(!n)return;let r=!1;for(const s of e.agents.values()){if(s===n||s.sessionId!==t)continue;const o=s.tools.filter(l=>l.explicitSubagentId==null);if(o.length!==0){for(const l of o)s.toolCount-=1,Ll(s,l.name,-1),l.ok===!1&&(s.toolErrorCount=(s.toolErrorCount??0)-1),l.agentId=n.id,n.tools.push(l),n.toolCount+=1,Ll(n,l.name,1),l.ok===!1&&(n.toolErrorCount=(n.toolErrorCount??0)+1);s.tools=s.tools.filter(l=>l.explicitSubagentId!=null),r=!0}}if(r){n.tools.sort((s,o)=>s.startedAt-o.startedAt),G$(e,n);for(let s=0;s<n.tools.length-V$;s++){const o=n.tools[s];o.trimmed||(o.input=void 0,o.response=void 0,o.trimmed=!0)}}}const Jq="no result reached the deck — events were dropped while the deck was paused";function X$(e,t,n,r,s){n.endedAt=r,W$(t,n,!1),n.errorPreview=n.outcomeGap?Jq:s,e.toolIndex.delete(Ri(t.sessionId,n.id))}function Qq(e,t){const n=t==null?void 0:t.payload,r=n==null?void 0:n.hook_event_name;if(r!=="PostToolUse"&&r!=="PostToolUseFailure")return!1;const s=n==null?void 0:n.tool_use_id;return typeof s!="string"||s.length===0?!1:e.toolIndex.has(Ri((n==null?void 0:n.session_id)??"unknown",s))}function eU(e,t,n,r,s){const o=t.tool_use_id?Xq(e,r,t.tool_use_id):null;if(o){if(t.tool_name&&o.name==="?"){o.name=t.tool_name;const h=H$(e,o);h&&(Ll(h,"?",-1),Ll(h,o.name,1))}o.endedAt==null&&!o.trimmed&&t.tool_input!==void 0&&(o.input=t.tool_input,o.inputPreview=Ed(t.tool_input));return}const l=t.tool_use_id??`${r.id}:${r.toolCount}`,c=Mi(t),d={id:l,name:t.tool_name??"?",input:t.tool_input,inputPreview:Ed(t.tool_input),agentId:r.id,explicitSubagentId:c?Ns(n,c):void 0,startedAt:s};r.tools.push(d),r.toolCount+=1,Ll(r,d.name,1),r.state="active",e.toolIndex.set(Ri(r.sessionId,l),d),G$(e,r)}function tU(e,t,n,r,s){const o=t.tool_use_id;if(!o)return;const l=Ri(r,o);let c=e.toolIndex.get(l),d=!1;if(!c)for(const f of e.agents.values()){if(f.sessionId!==r)continue;const p=f.tools.find(g=>g.id===o);if(p){c=p,d=!0;break}}if(!c||c.outcomeApplied)return;c.outcomeApplied=!0,c.outcomeGap=void 0,c.endedAt=s,W$(H$(e,c),c,n==="PostToolUse"),c.trimmed||(c.response=t.tool_response),n==="PostToolUseFailure"?c.errorPreview=Ed(t.tool_response):d&&(c.errorPreview=void 0);const h=E$(t.tool_response);h&&(c.usage=h),e.toolIndex.delete(l)}function nU(e,t,n){const r=e.agents.get(t);r&&n>(r.lastEventAt??0)&&(r.lastEventAt=n,r.reaped&&(r.reaped=!1,r.state="active",r.endedAt=void 0,r.closedAt=void 0))}function rU(e,t,n,r){const s=$i(e,n,r,!1);s.synthetic=!1,s.state="active",s.closedAt=void 0,s.endedAt=void 0,s.startedAt=Math.min(s.startedAt??r,r),ec(s,t),C$(s,t)}function sU(e,t,n,r){for(const l of e.agents.values())l.sessionId===n&&l.kind==="subagent"&&l.state==="done"&&l.exitAt==null&&l.endedAt!=null&&l.endedAt<r&&(l.exitAt=r);const s=$i(e,n,r,!1);s.state="active",s.endedAt=void 0,s.closedAt=void 0,s.exitAt=void 0;const o=(typeof t.prompt=="string"?t.prompt:typeof t.message=="string"?t.message:"")??"";o&&Lq(s.prompts,r,o)&&!s.firstPrompt&&!oh(o)&&(s.firstPrompt=Ed(o,120))}function aU(e,t,n,r){const s=$i(e,n,r,!1),o=Pq(s);if(r<o)return;const l=s.lastTurnEndAt;if(!(l!=null&&o>l&&r<=l+_d)){s.state="done",s.endedAt=r,s.lastTurnEndAt=r;for(const c of s.provider==="codex"?[]:e.agents.values())if(c.sessionId===n)for(const d of c.tools)d.endedAt==null&&d.explicitSubagentId==null&&X$(e,c,d,r,"the turn ended before this call returned");t==="SessionEnd"&&(s.closedAt=r),e.activeSubagentStack.delete(n)}}function oU(e,t,n,r){const s=Mi(t);if(!s)return;const o=bq(e,n,s,t,r),l=yk(t);l&&(o.label=l);const c=e.subagentTombstones.get(o.id);c!=null&&e.subagentTombstones.delete(o.id);const d=o.endedAt!=null&&r-o.endedAt<=_d,h=c!=null&&r-c<=_d;if(d||h){const f=h?c:o.endedAt;o.state="done",o.endedAt=f,o.startedAt=Math.min(o.startedAt,f),R$(e,n,s);return}o.state="active",o.startedAt=o.startedAt||r,o.exitAt=void 0,o.endedAt=void 0,kq(e,n,s)}function iU(e,t,n,r){const s=Mi(t);if(!s)return;const o=A$(e,n,s,t);if(!o){for(const[l,c]of e.subagentTombstones)r-c>_d&&e.subagentTombstones.delete(l);e.subagentTombstones.set(Ns(n,s),r);return}o.state="done",o.endedAt=Math.min(o.endedAt??r,r),R$(e,n,s)}const lU=["command","cmd","file_path","path","url","pattern","notebook_path"],Gj=120,Up=e=>e.length>Gj?`${e.slice(0,Gj-1)}…`:e;function cU(e){if(typeof e=="string")return e.trim()?Up(e.trim()):null;if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e;for(const n of lU){const r=t[n];if(typeof r=="string"&&r.trim())return Up(r.trim());if(Array.isArray(r)&&r.length>0&&r.every(s=>typeof s=="string")){const s=r.join(" ").trim();if(s)return Up(s)}}return null}function uU(e){return e==="permission_prompt"?"permission":e==="agent_needs_input"?"asked":e==="idle_prompt"?"idle":null}const dU=new Set(["Notification","ModelObserved","ContextObserved","UsageObserved","SessionNamed","SessionRecapped","OutputObserved","ActivityObserved","JobObserved"]);function hU(e,t){let n=null;for(const r of e.toolIndex.values()){const s=r.agentId?e.agents.get(r.agentId):void 0;!s||s.sessionId!==t||(!n||r.startedAt>n.startedAt)&&(n=r)}return n}const fU=3e4;function pU(e,t){if(!(!e||!e.name)&&!(t-e.startedAt>fU)&&!(e.startedAt>t))return{name:e.name,preview:cU(e.input)??""}}function mU(e,t,n,r,s){if(n!=="permission")return{kind:n,message:r,since:s};const o=hU(e,t),l={kind:n,message:r,since:s};o!=null&&o.explicitSubagentId&&(l.subagentId=o.explicitSubagentId);const c=pU(o,s);return c&&(l.tool=c),l}function gU(e,t,n){if(e.kind==="idle")return!0;const r=Mi(t);return r==null?!0:e.subagentId!=null&&Ns(n,r)===e.subagentId}function yU(e,t,n,r){if(!dU.has(t)){const s=e.agents.get(r);s!=null&&s.waiting&&gU(s.waiting,n,r)&&(s.waiting=null)}}function wU(e,t,n,r){const s=uU(t.notification_type);if(!s)return;const o=$i(e,n,r,!1),l=typeof t.message=="string"?t.message:"",c=o.waiting;o.waiting=c&&c.kind===s&&c.message===l?{...c,since:Math.min(c.since,r)}:mU(e,n,s,l,r)}function wc(e,t){return t&&(e.revision+=1),t}function vU(e,t,n,r,s){if(e.agents.size<=n)return!1;const o=p=>p.state==="done"&&p.endedAt!=null&&t-p.endedAt>r,l=[],c=new Map;for(const[p,g]of e.agents){if(g.parentId!=null){const v=c.get(g.parentId);v?v.push(p):c.set(g.parentId,[p])}o(g)&&l.push({id:p,endedAt:g.endedAt})}if(l.length===0)return!1;l.sort((p,g)=>p.endedAt-g.endedAt);let d=0;const h=new Set,f=p=>{const g=e.agents.get(p);g&&(K$(e,g),e.agents.delete(p),g.kind==="root"&&B$(e,g.sessionId),h.add(g.sessionId),d++)};for(const p of l){if(e.agents.size<=n)break;if(!e.agents.has(p.id))continue;const g=(c.get(p.id)??[]).map(v=>e.agents.get(v)).filter(v=>v!=null);if(!g.some(v=>!o(v))){for(const v of g)f(v.id);f(p.id)}}if(s&&h.size>0){const p=new Set;for(const g of e.agents.values())p.add(g.sessionId);for(const g of h)p.has(g)||s(g)}return wc(e,d>0)}function xU(e,t,n,r,s){const o=new Map;for(const[f,p]of e.agents){let g=o.get(p.sessionId);g||(g={ids:[],endedAt:0,live:!1,closed:!1},o.set(p.sessionId,g)),g.ids.push(f),p.kind==="root"&&p.closedAt!=null&&(g.closed=!0),p.state==="done"&&p.endedAt!=null?g.endedAt=Math.max(g.endedAt,p.endedAt):g.live=!0}const l=[...o].filter(([,f])=>!f.live&&f.endedAt>0&&t-f.endedAt>r).sort(([,f],[,p])=>f.closed===p.closed?f.endedAt-p.endedAt:f.closed?-1:1);let d=[...o.values()].filter(f=>!f.live).length-n;if(d<=0)return!1;let h=!1;for(const[f,p]of l){if(d<=0)break;for(const v of p.ids){const j=e.agents.get(v);j&&K$(e,j),e.agents.delete(v)}B$(e,f);const g=Ns(f,"");for(const v of e.pendingSubagentModels.keys())v.startsWith(g)&&e.pendingSubagentModels.delete(v);s==null||s(f),d--,h=!0}return wc(e,h)}function bU(e){let t=!1;for(const n of e.agents.values())for(const r of n.tools)r.endedAt!=null||r.outcomeGap||(r.outcomeGap=!0,t=!0);return wc(e,t)}function kU(e,t,n){let r=!1;for(const s of e.agents.values()){if(s.provider==="codex")continue;const o=e.agents.get(s.sessionId),l=(o==null?void 0:o.lastEventAt)??(o==null?void 0:o.startedAt);for(const c of s.tools){const d=Math.max(c.startedAt,l??c.startedAt);c.endedAt==null&&t-d>n&&(X$(e,s,c,d,"session ended before this call returned"),r=!0)}}return wc(e,r)}const Kj=90*6e4;function NU(e,t,n){let r=!1;for(const s of e.agents.values()){if(s.kind!=="root")continue;const o=s.lastEventAt??s.startedAt;if(!(t-o<=n)){s.waiting&&(s.waiting=null,r=!0),s.closedAt==null&&(s.closedAt=o),s.state==="active"&&(s.state="done",s.endedAt=o,s.reaped=!0,r=!0);for(const l of e.agents.values())l.sessionId!==s.sessionId||l.kind==="root"||l.state!=="active"||(l.state="done",l.endedAt=o,r=!0);e.activeSubagentStack.delete(s.sessionId)}}return wc(e,r)}function tc(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n);return Math.abs(t)%360}function Z$(e,t){const n=t.epoch??null;if(n!==null&&n!==e.seqEpoch)e.seqEpoch=n,e.lastSeq=0;else if(t.seq<=e.lastSeq)return e;const r=t.payload??{},s=t.receivedAt,o=r.hook_event_name??"Unknown";if(o==="__clear")return{...pk(),lastSeq:t.seq,seqEpoch:e.seqEpoch,revision:e.revision+1};e.totalEvents+=1,e.lastSeq=t.seq,e.revision+=1;const l=r.session_id??"unknown";if(yU(e,o,r,l),o!=="JobObserved"&&nU(e,l,s),$$(e,r,l),Rq(e,o,r,l))return e;switch(o){case"ModelObserved":return I$(e,r,l),e;case"ContextObserved":return O$(e,r,l),e;case"SessionNamed":return L$(e,r,l),e;case"SessionRecapped":return jq(e,r,l),e;case"ActivityObserved":return P$(e,r,l),e;case"JobObserved":return D$(e,r,l),e;case"OutputObserved":return _q(e,r,l,s),e;case"UsageObserved":return F$(e,r,l),e}const c=vq(e,r,s);Mq(e,l),xq(e,o,r,l)&&Zq(e,l),c.provider||(c.provider=r.provider==="codex"?"codex":"claude");const d=N$(r),h=Mi(r),f=h?Ns(l,h):l;switch(d&&c.id===f&&(c.model=d),o){case"SessionStart":rU(e,r,l,s);break;case"UserPromptSubmit":sU(e,r,l,s);break;case"PreToolUse":eU(e,r,l,c,s);break;case"PostToolUse":case"PostToolUseFailure":tU(e,r,o,l,s);break;case"SubagentStart":oU(e,r,l,s);break;case"SubagentStop":iU(e,r,l,s);break;case"Stop":case"SessionEnd":aU(e,o,l,s);break;case"Notification":wU(e,r,l,s);break}return e}const jU={input:2,output:10,cacheRead:.2,cacheWrite:2.5,cacheWrite1h:4},SU=[{match:/^claude[-_](fable|mythos)[-_]5[-_.]1\b(?![-_.]\d{1,7}(?!\d))/i,rates:{input:10,output:50,cacheRead:.25,cacheWrite:12.5,cacheWrite1h:20}},{match:/^claude[-_](fable|mythos)[-_]5\b(?![-_.]\d{1,7}(?!\d))/i,rates:{input:10,output:50,cacheRead:1,cacheWrite:12.5,cacheWrite1h:20}},{match:/^claude[-_]opus[-_]5[-_.]5\b(?![-_.]\d{1,7}(?!\d))/i,rates:{input:4,output:20,cacheRead:.2,cacheWrite:5,cacheWrite1h:8}},{match:/^claude[-_]opus[-_]5\b(?![-_.]\d{1,7}(?!\d))/i,rates:{input:5,output:25,cacheRead:.5,cacheWrite:6.25,cacheWrite1h:10}},{match:/^claude[-_]sonnet[-_]5[-_.]5\b(?![-_.]\d{1,7}(?!\d))/i,rates:{input:2,output:10,cacheRead:.2,cacheWrite:2.5,cacheWrite1h:4}},{match:/^claude[-_]sonnet[-_]5\b(?![-_.]\d{1,7}(?!\d))/i,rates:jU},{match:/^claude[-_]opus[-_]4[-_.](?:5|6|7|8)\b(?![-_.]\d{1,7}(?!\d))/i,rates:{input:5,output:25,cacheRead:.5,cacheWrite:6.25,cacheWrite1h:10}},{match:/^claude[-_]opus[-_]4(?:[-_.]1)?\b(?![-_.]\d{1,7}(?!\d))/i,rates:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75,cacheWrite1h:30}},{match:/^claude[-_]sonnet[-_]4[-_.](?:5|6)\b(?![-_.]\d{1,7}(?!\d))/i,rates:{input:3,output:15,cacheRead:.3,cacheWrite:3.75,cacheWrite1h:6}},{match:/^claude[-_]sonnet[-_]4\b(?![-_.]\d{1,7}(?!\d))/i,rates:{input:3,output:15,cacheRead:.3,cacheWrite:3.75,cacheWrite1h:6}},{match:/^claude[-_]haiku[-_]4[-_.]5\b(?![-_.]\d{1,7}(?!\d))/i,rates:{input:1,output:5,cacheRead:.1,cacheWrite:1.25,cacheWrite1h:2}},{match:/^claude[-_]haiku[-_]3[-_.]5\b(?![-_.]\d{1,7}(?!\d))/i,rates:{input:.8,output:4,cacheRead:.08,cacheWrite:1,cacheWrite1h:1.6}},{match:/^gpt[-_]6[-_]astra\b(?![-_][A-Za-z])/i,rates:{input:10,output:50,cacheRead:1,cacheWrite:12.5}},{match:/^gpt[-_]6[-_.]1[-_]sol\b(?![-_][A-Za-z])/i,rates:{input:2,output:10,cacheRead:.1,cacheWrite:2.5}},{match:/^gpt[-_]6[-_]sol\b(?![-_][A-Za-z])/i,rates:{input:2,output:10,cacheRead:.2,cacheWrite:2.5}},{match:/^gpt[-_]6[-_]luna\b(?![-_][A-Za-z])/i,rates:{input:.1,output:.5,cacheRead:.01,cacheWrite:.125}},{match:/^gpt[-_]5[-_.]6[-_]cyber/i,rates:{input:12.5,output:75,cacheRead:1.25,cacheWrite:15.625}},{match:/^gpt[-_]5[-_.]6[-_]luna/i,rates:{input:.2,output:1.2,cacheRead:.02,cacheWrite:.25}},{match:/^gpt[-_]5[-_.]6[-_]terra/i,rates:{input:2,output:12,cacheRead:.2,cacheWrite:2.5}},{match:/^gpt[-_]5[-_.]6(?:[-_]sol)?\b(?![-_][A-Za-z])/i,rates:{input:4,output:20,cacheRead:.4,cacheWrite:5}},{match:/^gpt[-_]5[-_.]5[-_]pro/i,rates:{input:30,output:180,cacheRead:30,cacheWrite:0}},{match:/^gpt[-_]5[-_.]5\b(?![-_][A-Za-z])/i,rates:{input:5,output:30,cacheRead:.5,cacheWrite:0}},{match:/^gpt[-_]5[-_.]4[-_]pro/i,rates:{input:30,output:180,cacheRead:3,cacheWrite:0}},{match:/^gpt[-_]5[-_.]4[-_]mini/i,rates:{input:.75,output:4.5,cacheRead:.075,cacheWrite:0}},{match:/^gpt[-_]5[-_.]4[-_]nano/i,rates:{input:.2,output:1.25,cacheRead:.02,cacheWrite:0}},{match:/^gpt[-_]5[-_.]4\b/i,rates:{input:2.5,output:15,cacheRead:.25,cacheWrite:0}},{match:/^gpt[-_]5[-_.]3[-_]codex/i,rates:{input:1.75,output:14,cacheRead:.175,cacheWrite:0}},{match:/^gpt[-_]5[-_.]2[-_]pro/i,rates:{input:21,output:168,cacheRead:21,cacheWrite:0}},{match:/^gpt[-_]5[-_.]2\b/i,rates:{input:1.75,output:14,cacheRead:.175,cacheWrite:0}},{match:/^gpt[-_]5[-_.]1[-_]codex[-_]mini/i,rates:{input:.25,output:2,cacheRead:.025,cacheWrite:0}},{match:/^gpt[-_]5[-_.]1(?!\d)/i,rates:{input:1.25,output:10,cacheRead:.125,cacheWrite:0}},{match:/^gpt[-_]5[-_]pro\b/i,rates:{input:15,output:120,cacheRead:15,cacheWrite:0}},{match:/^gpt[-_]5[-_]mini/i,rates:{input:.25,output:2,cacheRead:.025,cacheWrite:0}},{match:/^gpt[-_]5[-_]nano/i,rates:{input:.05,output:.4,cacheRead:.005,cacheWrite:0}},{match:/^gpt[-_]5(?![-_.]\d)/i,rates:{input:1.25,output:10,cacheRead:.125,cacheWrite:0}},{match:/^codex[-_]mini/i,rates:{input:1.5,output:6,cacheRead:.375,cacheWrite:0}},{match:/^o1[-_]pro/i,rates:{input:150,output:600,cacheRead:150,cacheWrite:0}},{match:/^o1[-_]mini/i,rates:{input:1.1,output:4.4,cacheRead:.55,cacheWrite:0}},{match:/^o1\b/i,rates:{input:15,output:60,cacheRead:7.5,cacheWrite:0}},{match:/^o3[-_]deep[-_]research/i,rates:{input:10,output:40,cacheRead:2.5,cacheWrite:0}},{match:/^o3[-_]mini/i,rates:{input:1.1,output:4.4,cacheRead:.55,cacheWrite:0}},{match:/^o3[-_]pro/i,rates:{input:20,output:80,cacheRead:20,cacheWrite:0}},{match:/^o4[-_]mini[-_]deep[-_]research/i,rates:{input:2,output:8,cacheRead:.5,cacheWrite:0}},{match:/^o4[-_]mini/i,rates:{input:1.1,output:4.4,cacheRead:.275,cacheWrite:0}},{match:/^o3\b/i,rates:{input:2,output:8,cacheRead:.5,cacheWrite:0}}],_U=[{match:/^claude[-_]opus[-_]5[-_.]5\b(?![-_.]\d{1,7}(?!\d))/i,rates:{input:8,output:40,cacheRead:.4,cacheWrite:10,cacheWrite1h:16}},{match:/^claude[-_]opus[-_]5\b(?![-_.]\d{1,7}(?!\d))/i,rates:{input:10,output:50,cacheRead:1,cacheWrite:12.5,cacheWrite1h:20}},{match:/^claude[-_]opus[-_]4[-_.]8\b(?![-_.]\d{1,7}(?!\d))/i,rates:{input:10,output:50,cacheRead:1,cacheWrite:12.5,cacheWrite1h:20}}];function EU(e){return e?/^(?:gpt[-_]|codex[-_]|o\d)/i.test(e):!1}function la(e,t=Date.now(),n=aa){if(!e)return null;const r=CU.get(n);if(!r)return null;const s=gs(e);for(const o of r)if(o.match.test(s))return typeof o.rates=="function"?o.rates(t):o.rates;return null}const aa="standard",CU=new Map([[aa,SU],["fast",_U]]);function Pl(e,t){return e*t/1e6}function J$(e,t){const n=Math.max(0,e.cacheCreate1hTokens??0),r=Math.max(0,e.cacheCreate5mTokens??0),s=Math.max(0,e.cacheCreateTokens-n-r),o=r+s,l=t.cacheWrite1h??t.cacheWrite;return{tokens5m:o,tokens1h:n,usd5m:Pl(o,t.cacheWrite),usd1h:Pl(n,l)}}function Q$(e,t,n=Date.now()){if(!EU(t))return e.inputTokens;const r=la(t,n),s=((r==null?void 0:r.cacheWrite)??0)>0?Math.max(0,e.cacheCreateTokens):0;return Math.max(0,e.inputTokens-e.cacheReadTokens-s)}function ih(e,t,n=Date.now()){const r={input:0,output:0,cacheRead:0,cacheWrite:0,total:0};for(const s of lh(e)){const o=Cd(s.usage,t,s.speed,n);r.input+=o.input,r.output+=o.output,r.cacheRead+=o.cacheRead,r.cacheWrite+=o.cacheWrite,r.total+=o.total}return r}function Cd(e,t,n,r=Date.now()){const s=la(t,r,n);if(!s)return{input:0,output:0,cacheRead:0,cacheWrite:0,total:0};const o=Pl(Q$(e,t,r),s.input),l=Pl(e.outputTokens,s.output),c=Pl(e.cacheReadTokens,s.cacheRead),d=J$(e,s),h=d.usd5m+d.usd1h;return{input:o,output:l,cacheRead:c,cacheWrite:h,total:o+l+c+h}}function lh(e){const t=e.bySpeed?Object.entries(e.bySpeed):[];return t.length===0?[{speed:aa,usage:e}]:[{speed:aa,usage:TU(e,t.map(([,n])=>n))},...t.map(([n,r])=>({speed:n,usage:r}))]}function TU(e,t){const n=o=>t.reduce((l,c)=>l+(o(c)??0),0),r=o=>Math.max(0,(o(e)??0)-n(o)),s={inputTokens:r(o=>o.inputTokens),outputTokens:r(o=>o.outputTokens),cacheReadTokens:r(o=>o.cacheReadTokens),cacheCreateTokens:r(o=>o.cacheCreateTokens)};return(e.cacheCreate1hTokens!==void 0||e.cacheCreate5mTokens!==void 0)&&(s.cacheCreate1hTokens=r(o=>o.cacheCreate1hTokens),s.cacheCreate5mTokens=r(o=>o.cacheCreate5mTokens)),e.reasoningOutputTokens!==void 0&&(s.reasoningOutputTokens=e.reasoningOutputTokens),s}const bs="not priced";function Dl(e,t,n){const r=e.toFixed(t);return Number(r)<n?r:null}function We(e){if(e<=0)return"—";if(e<.005)return"<1¢";if(e<1){const t=Dl(e*100,e<.1?1:0,100);if(t!==null)return`${t}¢`}if(e<100){const t=Dl(e,2,100);if(t!==null)return`$${t}`}if(e<1e4){const t=Dl(e,0,1e4);if(t!==null)return`$${t}`}return`$${(e/1e3).toFixed(1)}k`}function wk(e,t){if(e<=0||t<10)return null;const n=e/t,r=n*60;return r>=.01?`${We(r)}/min`:`${We(n*3600)}/hr`}function eI(e,t){const n={inputTokens:e.inputTokens+t.inputTokens,outputTokens:e.outputTokens+t.outputTokens,cacheReadTokens:e.cacheReadTokens+t.cacheReadTokens,cacheCreateTokens:e.cacheCreateTokens+t.cacheCreateTokens};if((e.cacheCreate1hTokens!==void 0||e.cacheCreate5mTokens!==void 0||t.cacheCreate1hTokens!==void 0||t.cacheCreate5mTokens!==void 0)&&(n.cacheCreate1hTokens=(e.cacheCreate1hTokens??0)+(t.cacheCreate1hTokens??0),n.cacheCreate5mTokens=(e.cacheCreate5mTokens??0)+(t.cacheCreate5mTokens??0)),(e.reasoningOutputTokens!==void 0||t.reasoningOutputTokens!==void 0)&&(n.reasoningOutputTokens=(e.reasoningOutputTokens??0)+(t.reasoningOutputTokens??0)),e.bySpeed||t.bySpeed){const r=new Map(Object.entries(e.bySpeed??{}));for(const[s,o]of Object.entries(t.bySpeed??{})){const l=r.get(s);r.set(s,l?eI(l,o):o)}n.bySpeed=Object.fromEntries(r)}return n}function AU(e,t){let n=0,r=0,s=0,o=0,l=0,c=0;for(const p of t)n+=p.inputTokens,r+=p.outputTokens,s+=p.cacheReadTokens,o+=p.cacheCreateTokens,l+=p.cacheCreate1hTokens??0,c+=p.cacheCreate5mTokens??0;const d=(p,g)=>Math.max(0,p-g),h={inputTokens:d(e.inputTokens,n),outputTokens:d(e.outputTokens,r),cacheReadTokens:d(e.cacheReadTokens,s),cacheCreateTokens:d(e.cacheCreateTokens,o)};return(e.cacheCreate1hTokens!==void 0||e.cacheCreate5mTokens!==void 0)&&(h.cacheCreate1hTokens=d(e.cacheCreate1hTokens??0,l),h.cacheCreate5mTokens=d(e.cacheCreate5mTokens??0,c)),h.inputTokens+h.outputTokens+h.cacheReadTokens+h.cacheCreateTokens>0?h:null}function vc(e){const t=e.usageByModel,n=t?Object.keys(t):[];if(!t||n.length===0)return[{model:e.model,usage:e.usage}];const r=n.map(o=>({model:o,usage:t[o]})),s=AU(e.usage,r.map(o=>o.usage));if(s){const o=r.findIndex(l=>l.model===e.model);o>=0?r[o]={model:r[o].model,usage:eI(r[o].usage,s)}:r.push({model:e.model,usage:s})}return r}function gn(e,t=Date.now()){const n={input:0,output:0,cacheRead:0,cacheWrite:0,total:0};for(const r of vc(e)){const s=ih(r.usage,r.model,t);n.input+=s.input,n.output+=s.output,n.cacheRead+=s.cacheRead,n.cacheWrite+=s.cacheWrite,n.total+=s.total}return n}function nc(e,t=Date.now()){let n=0;for(const r of vc(e))for(const s of lh(r.usage))la(r.model,t,s.speed)==null&&(n+=s.usage.inputTokens+s.usage.outputTokens);return n}function tI(e){const t=[];for(const n of vc(e)){if(!n.model||t.includes(n.model))continue;const r=n.usage;r.inputTokens+r.outputTokens+r.cacheReadTokens+r.cacheCreateTokens<=0||t.push(n.model)}return t}function vk(e){return tI(e).filter(t=>t!==e.model)}function Yj(e,t){if(!e.bySpeed)return zp(e,t,aa);const n=lh(e).filter(r=>r.speed!==aa||RU(r.usage));return n.length===1?zp(n[0].usage,t,n[0].speed):[...n.map(r=>zp(r.usage,t,r.speed)),"═════════════════════════════════════════",`all speeds = ${We(ih(e,t).total)}`].join(`
66
- `)}function RU(e){return e.inputTokens+e.outputTokens+e.cacheReadTokens+e.cacheCreateTokens>0}function zp(e,t,n){const r=la(t,Date.now(),n),s=n===aa?`model: ${t}`:`model: ${t} · ${n}`;if(!r)return`${s}
67
- no published rate in this build — the tokens are counted, the dollars are not`;const o=g=>g.toLocaleString(),l=g=>`$${g}/MTok`,c=Cd(e,t,n),d=J$(e,r),h=d.tokens1h>0?[`cache w5m${o(d.tokens5m).padStart(14)} × ${l(r.cacheWrite).padEnd(11)} = ${We(d.usd5m)}`,`cache w1h${o(d.tokens1h).padStart(14)} × ${l(r.cacheWrite1h??r.cacheWrite).padEnd(11)} = ${We(d.usd1h)}`]:[`cache w ${o(d.tokens5m).padStart(14)} × ${l(r.cacheWrite).padEnd(11)} = ${We(d.usd5m)}`],f=Q$(e,t),p=f===e.inputTokens?"input":"uncached";return[s,`${p.padEnd(9)}${o(f).padStart(14)} × ${l(r.input).padEnd(11)} = ${We(c.input)}`,`output ${o(e.outputTokens).padStart(14)} × ${l(r.output).padEnd(11)} = ${We(c.output)}`,`cache r ${o(e.cacheReadTokens).padStart(14)} × ${l(r.cacheRead).padEnd(11)} = ${We(c.cacheRead)}`,...h,"─────────────────────────────────────────",`total = ${We(c.total)}`].join(`
68
- `)}function Xj(e){const t=vc(e),[n]=t;return t.length<=1?Yj(n.usage,n.model):[...t.map(r=>Yj(r.usage,r.model)),"═════════════════════════════════════════",`all models = ${We(gn(e).total)}`].join(`
69
- `)}function MU(e){if(!e.model)return null;const t=la(e.model),n=gn(e),r=nc(e);if(!t&&n.total<=0)return e.usage.inputTokens+e.usage.outputTokens<=0?null:{kind:"unpriced",tt:Xj(e)};if(n.total<=0)return null;const s=Math.max(0,((e.endedAt??Date.now())-e.startedAt)/1e3),o=e.state==="active"&&!e.synthetic?wk(n.total,s):null,l=Xj(e)+(o?`
70
- burn: ${o}`:"");return{kind:"spent",total:n.total,floor:r>0,tt:l}}const $U=new Set(["untrusted","on-request","on-failure"]);function IU(e){return typeof e!="string"||!e?null:$U.has(e)?!0:e==="never"?!1:null}function nI(e){if(e.provider!=="codex"||e.kind!=="root"||e.waiting||e.state!=="active")return null;const t=IU(e.approvalPolicy);return t===!1?null:{label:"approvals not visible",detail:`${t===!0?`This session's approval policy is "${e.approvalPolicy}", so Codex can stop and ask you to approve a command.`:"This session's approval policy has not been read yet, so it may be able to stop and ask you to approve a command."}
71
-
72
- Codex writes no approval request to its rollout files, which are the only thing this deck can read — so when it does ask, this card, the sidebar, the topbar count, the tab title and the favicon will all stay silent. Check the terminal.`}}function Zj(e){return e[0].toUpperCase()+e.slice(1).toLowerCase()}function ks(e){const t=gs(e).replace(/[-_]\d{8}(?!\d)/,""),n=t.match(/^claude[-_](opus|sonnet|haiku|fable|mythos)[-_](\d+(?:[-_.]\d+)*)/i);if(n){const s=Zj(n[1]),o=n[2].replace(/[-_]/g,".");return`${s} ${o}`}const r=t.match(/^gpt[-_](\d+(?:[-_.]\d+)*)((?:[-_][A-Za-z0-9.]+)*)$/i);if(r){const s=r[1].replace(/[-_]/g,"."),o=r[2].split(/[-_]/).filter(Boolean).map(Zj);return[`GPT-${s}`,...o].join(" ")}return e}function ch(e){const t=gs(e??""),n=t.match(/^claude[-_](opus|sonnet|haiku|fable|mythos)[-_]/i);return n?n[1].toLowerCase():/^gpt[-_]/i.test(t)?"gpt":""}function En(e){return(e==null?void 0:e.kind)==="permission"||(e==null?void 0:e.kind)==="asked"}function Yx(e){const t=[];for(const n of e)n.kind==="root"&&En(n.waiting)&&t.push({id:n.id,label:n.label,waiting:n.waiting});return t.sort((n,r)=>n.waiting.since-r.waiting.since)}function OU(e,t){if(e.length===0)return null;const n=e.findIndex(r=>r.id===t);return e[(n+1)%e.length]}function LU(e){const t=new Set;for(const n of e)n.state==="active"&&t.add(n.sessionId);return t.size}function uh(e,t){return`${e}@${t.since}`}function rI(e,t){if(!e.tool)return null;const{name:n,preview:r}=e.tool,s=new RegExp(`\\b${n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`,"i").test(t);return r?s?r:`${n} · ${r}`:s?null:n}function PU(e){const t=e.message||"Needs your permission",n=rI(e,t);return n?`${t}
73
- Likely on: ${n}`:t}function DU(e,t,n,r=!0){if(!r)return[];if(n)return[];const s=[];for(const o of e){if(!En(o.waiting))continue;const l=uh(o.id,o.waiting);t.has(l)||s.push({key:l,title:o.label,body:PU(o.waiting),sessionId:o.id})}return s}function FU(e,t,n){const r=new Set;for(const o of e)r.add(uh(o.id,o.waiting));const s=new Set;for(const o of n)r.has(o)&&s.add(o);for(const o of t)s.add(o.key);return s}function Uu(e){return new Set(e.map(t=>uh(t.id,t.waiting)))}function BU(e,t){return e!==t}function qU(e,t){return!e&&t!=null}function UU(e,t){return e!==null&&t!=null}function xi(e){return e==="active"?"live":e==="done"?"done":"err"}function bi(e){return e.message?e.message:e.kind==="permission"?"Needs your permission":"Waiting for your input"}function zU(e){return`${e} subagent${e===1?"":"s"} spawned`}function WU(e){const t=[e.kind==="root"?"session":"subagent"];if(e.childCount>0&&t.push(`→ ${e.childCount}`),e.kind==="subagent"&&e.cwdBasename&&t.push(e.cwdBasename),e.model){const n=vk(e).length;t.push(`${ks(e.model)}${n>0?` +${n}`:""}`)}else e.provider==="codex"&&t.push("Codex");return t.join(" · ")}function HU(e,t=Date.now(),n=!1){const r=e.toolErrorCount??0,s=gn(e,t).total;return[e.label,e.kind==="root"?"session":"subagent",xi(e.state),En(e.waiting)?bi(e.waiting):null,e.model?ks(e.model):null,`${e.toolCount} ${e.toolCount===1?"tool":"tools"}`,r>0?`${r} failed`:null,s>0?`${We(s)}${nc(e,t)>0?"+":""}`:null,n?"selected":null].filter(Boolean).join(", ")}function VU(e,t){const n=rI(e,t);return n?`Likely on: ${n}`:null}function Td(e){return e.kind==="idle"?"Your turn":bi(e)}function st(e){const t=Math.round(e);if(t<1e3)return`${t}`;if(t<1e6){const n=Dl(t/1e3,1,1e3);if(n!==null)return`${n}k`}if(t<1e9){const n=Dl(t/1e6,2,1e3);if(n!==null)return`${n}M`}return`${(t/1e9).toFixed(2)}B`}function ki(e,t,n){const r=(t??n)-e;if(r<1e3)return`${Math.max(0,r)}ms`;const s=Math.floor(r/1e3);if(s<60)return`${s}s`;const o=Math.floor(s/60);if(o>=100)return`${Math.floor(o/60)}h ${o%60}m`;const l=s%60;return`${o}m ${String(l).padStart(2,"0")}s`}function sI(e,t){if(e.endedAt==null)return t;const n=e.endedAt-e.startedAt;return n<1e3?`${n}ms`:`${(n/1e3).toFixed(2)}s`}function xk(e,t){const n=typeof e=="string"?e.trim():"",r=typeof t=="string"?t.trim():"";return{face:n||r||void 0,tooltip:r||n||void 0}}const Jj=2e5,GU=1e6,KU=[/\[1m\]/i,/^claude[-_]opus[-_]5\b/i,/^claude[-_]sonnet[-_]5\b/i,/^claude[-_]opus[-_]4[-_.](?:6|7|8)\b/i,/^claude[-_]sonnet[-_]4[-_.]6\b/i,/^claude[-_](fable|mythos)[-_]5\b/i],YU=[{match:/^gpt[-_]6[-_]astra/i,window:105e4},{match:/^gpt[-_]6[-_.]1[-_]sol/i,window:105e4},{match:/^gpt[-_]6[-_](?:sol|luna)/i,window:105e4},{match:/^gpt[-_]5[-_.]6[-_]cyber/i,window:4e5},{match:/^gpt[-_]5[-_.]6/i,window:105e4},{match:/^gpt[-_]5[-_.]5/i,window:105e4},{match:/^gpt[-_]5[-_.]4[-_](?:mini|nano)/i,window:4e5},{match:/^gpt[-_]5[-_.]4/i,window:105e4},{match:/^gpt[-_]5[-_.]3[-_]codex[-_]spark/i,window:128e3},{match:/^gpt[-_]5[-_.]3[-_]codex/i,window:4e5},{match:/^gpt[-_]5[-_.]2/i,window:4e5},{match:/^gpt[-_]5/i,window:4e5},{match:/^codex[-_]mini/i,window:2e5},{match:/^o\d/i,window:2e5}];function XU(e){if(!e)return Jj;const t=gs(e);for(const n of KU)if(n.test(t))return GU;for(const n of YU)if(n.match.test(t))return n.window;return Jj}function aI(e,t){return typeof e=="number"&&e>0?e:XU(t)}const ZU=1;function JU(){const e=[];let t=0;function n(){let r;for(const s of e)(!r||s.layer>r.layer||s.layer===r.layer&&s.seq>r.seq)&&(r=s);return r}return{push(r,s=0,o="dialog"){const l={dismiss:r,layer:s,kind:o,seq:t++};return e.push(l),()=>{const c=e.indexOf(l);c!==-1&&e.splice(c,1)}},dismissTop(){const r=n();return r?(r.dismiss(),!0):!1},isTop(r){const s=n();return s!=null&&s.dismiss===r},depth(){return e.length},dialogDepth(){return e.filter(r=>r.kind==="dialog").length}}}const qr=JU(),oI=e=>e==="Escape";function QU(e){return e.overlayOpen?"dismiss":e.typing?"blur":"clear-selection"}function Qj(e){return String(e.tagName??"").toUpperCase()==="BODY"}function ez(e,t){return!e||!e.isConnected||Qj(e)?!1:t==null||Qj(t)}const eS="a[href], button, input, select, textarea, summary, [tabindex]";function tz(e){return!e||e.disabled||e.rendered===!1?!1:(e.tabIndex??0)>=0}function nz(e){if(!e||!e.overflowing||e.hasFocusable)return!1;const t=String(e.overflow??"").toLowerCase();return t==="auto"||t==="scroll"}function rz({count:e,index:t,shiftKey:n}){return e<=0?{kind:"hold"}:t<0||t>=e?{kind:"focus",index:n?e-1:0}:!n&&t===e-1?{kind:"focus",index:0}:n&&t===0?{kind:"focus",index:e-1}:{kind:"allow"}}function dh(e){return e.ctrlKey||e.metaKey||e.altKey}const sz=new Set(["button","checkbox","color","file","image","radio","range","reset","submit"]),az=new Set(["INPUT","TEXTAREA","SELECT","OPTION","BUTTON","SUMMARY","A"]),oz=new Set(["button","checkbox","combobox","link","listbox","menu","menubar","menuitem","menuitemcheckbox","menuitemradio","option","radio","searchbox","slider","spinbutton","switch","tab","textbox","treeitem"]);function bk(e){return typeof e.tagName=="string"?e.tagName.toUpperCase():""}function iz(e){return bk(e)==="BUTTON"?!0:(typeof e.role=="string"?e.role.trim().toLowerCase():"").split(/\s+/).includes("button")}function Ni(e){if(!e)return!1;if(e.isContentEditable)return!0;const t=bk(e);return t==="TEXTAREA"?!0:t!=="INPUT"?!1:!sz.has(String(e.type??"text").toLowerCase())}function lz(e,t){if(!e)return!1;if(Ni(e))return!0;if(t!=null&&(t.length===1||t==="Delete")&&t!==" "&&e.pointerFocused&&iz(e))return!1;if(az.has(bk(e)))return!0;const n=typeof e.role=="string"?e.role.trim().toLowerCase():"";return n!==""&&n.split(/\s+/).some(r=>oz.has(r))}function cz({key:e,modalOpen:t,sheetOpen:n}){return t?!(e==="?"&&n):!1}function uz({key:e,sheetOpen:t,target:n}){return t&&e==="?"&&!Ni(n)}function Xx({appModal:e,dialogDepth:t}){return e||t>0}function iI(e){return e?Array.from(e.querySelectorAll("*")).filter(t=>{if(t.matches(eS))return tz({disabled:t.disabled,tabIndex:t.tabIndex,rendered:t.checkVisibility?t.checkVisibility():t.getClientRects().length>0});const n=t.scrollHeight>t.clientHeight;return n&&nz({overflowing:n,overflow:getComputedStyle(t).overflowY,hasFocusable:t.querySelector(eS)!=null})}):[]}function dz(e,t){const n=iI(e);if(!t||!e.contains(t)||n.includes(t))return n;const r=n.findIndex(s=>(t.compareDocumentPosition(s)&Node.DOCUMENT_POSITION_FOLLOWING)!==0);return r===-1?[...n,t]:[...n.slice(0,r),t,...n.slice(r)]}function ot(e,t={}){const{focusRef:n,layer:r,popover:s}=t,o=s?"popover":"dialog",l=y.useRef(null),c=y.useRef(e);c.current=e;const d=y.useRef(null);d.current===null&&(d.current=()=>c.current());const h=d.current;return y.useEffect(()=>qr.push(h,r,o),[h,r,o]),y.useEffect(()=>{var p;const f=document.activeElement;return(p=(n==null?void 0:n.current)??iI(l.current)[0])==null||p.focus(),()=>{ez(f,document.activeElement)&&f.focus()}},[]),y.useEffect(()=>{const f=p=>{var N;if(p.key!=="Tab"||dh(p))return;const g=l.current;if(!g)return;const v=document.activeElement;if(!(v!=null&&g.contains(v))&&!qr.isTop(h))return;const k=dz(g,v),x=rz({count:k.length,index:v?k.indexOf(v):-1,shiftKey:p.shiftKey});x.kind!=="allow"&&(p.preventDefault(),x.kind==="focus"&&((N=k[x.index])==null||N.focus()))};return window.addEventListener("keydown",f),()=>window.removeEventListener("keydown",f)},[h]),l}function mt(e){const t=y.useRef(!1);return{onPointerDown:n=>{t.current=n.target===n.currentTarget},onPointerUp:n=>{n.target!==n.currentTarget&&(t.current=!1)},onClick:n=>{const r=t.current&&n.target===n.currentTarget;t.current=!1,r&&e()}}}function hz(e){return e==="codex"?{subtitle:"reported by the Codex CLI — as of its most recent request",windowScope:"last request",compositionCounted:!1,compositionUncounted:"Not counted for Codex — the deck reconstructs the session from its rollout file and skips whatever was written before it attached, so a message and tool-call breakdown here would be short by an unknown amount. The window figure above is the CLI's own and is unaffected.",memoryHeading:"AGENTS.md files in scope",memoryEmpty:"No AGENTS.md files found on the path from cwd to the filesystem root, or in $CODEX_HOME."}:{subtitle:"approximation — CC's /context isn't hook-exposed",windowScope:"current turn",compositionCounted:!0,compositionUncounted:"",memoryHeading:"CLAUDE.md files in scope",memoryEmpty:"No CLAUDE.md files found on the path from cwd to ~/.claude."}}function Un(e){return e.toLocaleString()}const fz=60;function pz(e,t=fz){if(e.length<=t)return e;const n=e.slice(e.length-(t-1)),r=n.search(/[/\\]/);return"…"+(r===-1?n:n.slice(r))}function mz({agent:e,onClose:t}){var v;const n=y.useRef(null),r=ot(t,{focusRef:n}),s=mt(t),o=e.context,l=e.usage,c=(o==null?void 0:o.currentContextTokens)??0,d=aI(e.contextWindow,e.model),h=Math.min(100,c/d*100),f=gn(e),p=e.provider==="codex"?l.inputTokens+l.outputTokens:l.inputTokens+l.outputTokens+l.cacheReadTokens+l.cacheCreateTokens,g=hz(e.provider);return a.jsx("div",{className:"modal-backdrop",...s,role:"presentation",children:a.jsxs("div",{ref:r,className:"modal ctx-modal",onClick:j=>j.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Context breakdown",children:[a.jsxs("header",{className:"ctx-modal-head",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"ctx-modal-title",children:["Context · ",e.label]}),a.jsx("div",{className:"ctx-modal-sub",children:g.subtitle})]}),a.jsx("button",{type:"button",ref:n,className:"glyph-btn ctx-modal-close",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]}),a.jsxs("section",{className:"ctx-window-row",children:[a.jsx("div",{className:"ctx-window-bar",role:"progressbar","aria-label":"Context window used","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(h),children:a.jsx("div",{className:"ctx-window-fill",style:{transform:`scaleX(${Math.min(100,Math.max(0,h))/100})`}})}),a.jsxs("div",{className:"ctx-window-meta",children:[a.jsxs("span",{className:"ctx-window-pct",children:[h.toFixed(1),"%"]}),a.jsxs("span",{children:[Un(c)," / ",Un(d)," tok (",g.windowScope,")"]})]})]}),a.jsx("h3",{className:"ctx-section-title",children:"Cumulative usage · whole session"}),a.jsxs("div",{className:"ctx-grid",children:[a.jsx(pr,{label:"input tokens",val:Un(l.inputTokens)}),a.jsx(pr,{label:"output tokens",val:Un(l.outputTokens)}),a.jsx(pr,{label:"cache reads",val:Un(l.cacheReadTokens)}),a.jsx(pr,{label:"cache writes",val:Un(l.cacheCreateTokens)}),a.jsx(pr,{label:"cumulative total",val:Un(p)}),a.jsx(pr,{label:"estimated cost",val:We(f.total),accent:!0})]}),a.jsx("h3",{className:"ctx-section-title",children:"Transcript composition"}),g.compositionCounted?a.jsxs("div",{className:"ctx-grid",children:[a.jsx(pr,{label:"user messages",val:Un((o==null?void 0:o.msgsUser)??0)}),a.jsx(pr,{label:"assistant messages",val:Un((o==null?void 0:o.msgsAssistant)??0)}),a.jsx(pr,{label:"tool uses",val:Un((o==null?void 0:o.toolUses)??0)}),a.jsx(pr,{label:"tool results",val:Un((o==null?void 0:o.toolResults)??0)}),a.jsx(pr,{label:"system-reminders",val:Un((o==null?void 0:o.systemReminders)??0)})]}):a.jsx("div",{className:"ctx-empty",children:g.compositionUncounted}),a.jsx("h3",{className:"ctx-section-title",children:g.memoryHeading}),(((v=o==null?void 0:o.memoryFiles)==null?void 0:v.length)??0)===0?a.jsx("div",{className:"ctx-empty",children:g.memoryEmpty}):a.jsx("ul",{className:"ctx-md-list",children:o.memoryFiles.map(j=>a.jsxs("li",{children:[a.jsx("span",{className:"ctx-md-path",title:j.path,children:pz(j.path)}),a.jsx("span",{className:"ctx-md-size",children:Qs(j.bytes)})]},j.path))})]})})}function pr({label:e,val:t,accent:n}){return a.jsxs("div",{className:`ctx-row${n?" accent":""}`,children:[a.jsx("span",{className:"ctx-row-label",children:e}),a.jsx("span",{className:"ctx-row-val",children:t})]})}function gz({currentContextTokens:e,modelId:t,contextWindow:n,size:r=26,onClick:s}){const o=aI(n,t),l=Math.min(1,e/o),c=r/2-3,d=r/2,h=2*Math.PI*c,f=h*l,p=l>.9?"var(--err)":l>.7?"var(--warn)":"var(--accent)";return a.jsx("button",{type:"button",className:"ctx-donut",onClick:g=>{g.stopPropagation(),s==null||s()},title:`context: ${e.toLocaleString()} / ${o.toLocaleString()} (${(l*100).toFixed(1)}%)`,"aria-label":`Context ${Math.round(l*100)}% of ${o.toLocaleString()} tokens — show breakdown`,children:a.jsxs("svg",{width:r,height:r,viewBox:`0 0 ${r} ${r}`,"aria-hidden":"true",children:[a.jsx("circle",{cx:d,cy:d,r:c,stroke:"var(--line)",strokeWidth:"2.5",fill:"none"}),a.jsx("circle",{cx:d,cy:d,r:c,stroke:p,strokeWidth:"2.5",fill:"none",strokeDasharray:`${f} ${h-f}`,strokeDashoffset:h/4,strokeLinecap:"round",style:{transition:"var(--ctx-arc-transition)"}}),a.jsx("text",{x:d,y:d+3,textAnchor:"middle",fontSize:"8",fill:"var(--text)",fontWeight:"600",children:Math.round(l*100)})]})})}const tS=new Map;function lI(e){let t=tS.get(e);return t||(t={now:Date.now(),listeners:new Set,timer:null},tS.set(e,t)),t}function yz(e,t){const n=lI(e);return n.listeners.add(t),n.timer===null&&(n.now=Date.now(),n.timer=setInterval(()=>{n.now=Date.now();for(const r of n.listeners)r()},e)),()=>{n.listeners.delete(t),n.listeners.size===0&&n.timer!==null&&(clearInterval(n.timer),n.timer=null)}}function wz(e){return lI(e).now}const nS=new Map,rS=new Map;function Ii(e=1e3){let t=nS.get(e);t||(t=r=>yz(e,r),nS.set(e,t));let n=rS.get(e);return n||(n=()=>wz(e),rS.set(e,n)),y.useSyncExternalStore(t,n,n)}function vz(e){const t=e.recap;if(e.kind!=="root"||!t||e.state==="active"||e.closedAt!=null)return null;for(const n of e.prompts)if(n.at>t.at)return null;return t}const xz="1",sS="agent-dag.schema",bz=["agent-dag.layout","agent-dag.viewport"];function Je(e){if(typeof window>"u")return null;try{return window.localStorage.getItem(e)}catch{return null}}function Ye(e,t){if(!(typeof window>"u"))try{window.localStorage.setItem(e,t)}catch{}}function ws(e){if(!(typeof window>"u"))try{window.localStorage.removeItem(e)}catch{}}function Fl(){if(typeof window>"u")return null;try{return window.localStorage}catch{return null}}function kz(e,t=xz){let n=null;try{n=e.getItem(sS)}catch{return[]}if(n===t)return[];const r=[];if(n!==null)for(const s of bz)try{e.getItem(s)!==null&&(e.removeItem(s),r.push(s))}catch{}try{e.setItem(sS,t)}catch{}return r}const cI="agent-dag.recapsDismissed",aS=200;function Nz(){const e=Je(cI);if(!e)return[];try{const t=JSON.parse(e);return Array.isArray(t)?t.filter(n=>typeof n=="string"):[]}catch{return[]}}let ji=new Set(Nz());const Zx=new Set;let uI=0;function dI(e){return Zx.add(e),()=>{Zx.delete(e)}}function hI(e){ji=e,uI++;const t=Array.from(e);Ye(cI,JSON.stringify(t.length>aS?t.slice(-aS):t));for(const n of Zx)n()}function jz(e,t){return`${e}@${t}`}function Sz(e){return ji.has(e)}function _z(e){if(ji.has(e))return;const t=new Set(ji);t.add(e),hI(t)}function Ez(e){const t=new Set(ji);t.delete(e)||t.add(e),hI(t)}function Cz(e){return y.useSyncExternalStore(dI,()=>e!=null&&ji.has(e),()=>!1)}function kk(e){return`recap:${e}`}function Tz(e){return e.startsWith("recap:")}function Az(){return y.useSyncExternalStore(dI,()=>uI,()=>0)}function sa(e){switch(e){case"recap":return"recap";case"needs":return"needs you";case"done":return"done";case"failed":return"failed";case"last":return"last";default:return"now"}}function Rz(e){let t,n;switch(e.state){case"blocked":t="needs",n=e.needs||e.detail;break;case"done":t="done",n=e.result||e.detail;break;case"failed":t="failed",n=e.detail||e.result||"";break;case"working":t="now",n=e.detail;break;default:return null}if(!n)return null;const r={kind:t,text:n,at:e.updatedAt,source:"job"};return t==="needs"&&e.suggestedReply&&(r.reply=e.suggestedReply),r}function Mz(e){let t=null;for(const n of e.prompts)(!t||n.at>t.at)&&(t=n);return t}const oS=160;function $z(e){const t=oh(e);if(t)return t.detail?`${t.label}: ${t.detail}`:t.label;const r=(e.split(`
74
- `).map(s=>s.trim()).find(Boolean)??"").replace(/\s+/g," ");return r.length>oS?r.slice(0,oS-1).trimEnd()+"…":r}function Iz(e){const t=Mz(e),n=(t==null?void 0:t.at)??e.startedAt,r=l=>({...l,key:`${e.sessionId}@${l.kind==="last"?"now":l.kind}:${n}`}),s=e.job?Rz(e.job):null;if(s)return r(s);const o=e.activity;if(o&&(!t||t.at<=o.at))return r({kind:e.state==="active"?"now":"last",text:o.text,at:o.at,source:"activity"});if(t&&e.state==="active"){const l=$z(t.text);if(l)return r({kind:"now",text:l,at:t.at,source:"prompt"})}return null}function hh(e){if(e.kind!=="root"||e.closedAt!=null)return null;const t=Iz(e),n=vz(e),r=n?{kind:"recap",text:n.text,at:n.at,source:"recap",key:jz(e.sessionId,n.at)}:null;return t&&r?r.at>t.at?r:t:t??r}function fh(e){switch(e.source){case"recap":return"Claude Code's recap";case"job":return"Claude Code's own line for this background session";case"prompt":return"The prompt this turn began with — the model has not answered yet";default:return e.kind==="last"?"What the session did last, until Claude Code's recap":"From the session's newest reply"}}function Oz(e){const t=new Map;for(const n of e){if(n.kind!=="subagent"||n.exitAt!=null)continue;let r=t.get(n.sessionId);r||(r={total:0,live:0,done:0,err:0,failed:0},t.set(n.sessionId,r)),r.total+=1,n.state==="active"?r.live+=1:n.state==="err"?r.err+=1:r.done+=1,r.failed+=n.toolErrorCount??0}return t}function fI(e){return[`${e.total} ${e.total===1?"subagent":"subagents"}`,e.live>0?`${e.live} live`:null,e.done>0?`${e.done} done`:null,e.err>0?`${e.err} err`:null].filter(Boolean).join(" · ")}function pI(e){return e.live>0?`→ ${e.total} · ${e.live} live`:`→ ${e.total} · done`}function Lz(e,t,n){const r=e.kind==="root"?e.waiting:null;if(r&&En(r))return{tone:"warn",long:n.sayWaiting(r),short:r.kind==="permission"?"Needs you":"Asked you"};if(r&&r.kind==="idle"){const o=n.sayWaiting(r);return{tone:"idle",long:o,short:o}}const s=e.toolErrorCount??0;if(s>0)return{tone:"err",long:`${s} tool ${s===1?"call":"calls"} failed`,short:`${s} failed`};if(t&&t.total>0)return{tone:"muted",long:fI(t),short:pI(t)};if(e.state==="active")for(let o=e.tools.length-1;o>=0;o--){const l=e.tools[o];if(l.endedAt!=null)continue;const{name:c,subject:d}=n.describeCall(l);return{tone:"muted",long:d?`${c} · ${d}`:c,short:c}}return null}function Pz(e,t){return t?t.includes(e)?t:`${e}
75
- ${t}`:e}function Jx(e){return e==="active"?"live":e==="done"?"done":"err"}const ph={exec:{category:"shell",emoji:"⚡",label:"Shell",shell:!0},shell:{category:"shell",emoji:"⚡",label:"Shell",shell:!0},exec_command:{category:"shell",emoji:"⚡",label:"Shell",shell:!0},shell_command:{category:"shell",emoji:"⚡",label:"Shell",shell:!0},write_stdin:{category:"shell",emoji:"💻",label:"stdin",shell:!0},wait:{category:"shell",emoji:"⏳",label:"wait",shell:!0},apply_patch:{category:"file",emoji:"🩹",label:"Edit"},update_plan:{category:"task",emoji:"📋",label:"Plan"},run:{category:"web",emoji:"🌐",label:"Web"}},Dz=Object.fromEntries(Object.entries(ph).map(([e,t])=>[e,t.category])),Fz=Object.fromEntries(Object.entries(ph).map(([e,t])=>[e,t.emoji])),Bz=Object.fromEntries(Object.entries(ph).map(([e,t])=>[e,t.label])),qz=new Set(Object.entries(ph).filter(([,e])=>e.shell).map(([e])=>e)),Uz={Read:"file",Write:"file",Edit:"file",MultiEdit:"file",Glob:"file",Grep:"file",LS:"file",NotebookEdit:"file",Bash:"shell",PowerShell:"shell",WebFetch:"web",WebSearch:"web",Task:"agent",Agent:"agent",TodoWrite:"task",TaskCreate:"task",TaskUpdate:"task",TaskList:"task",TaskGet:"task",TaskOutput:"task",TaskStop:"task",EnterPlanMode:"plan",ExitPlanMode:"plan",AskUserQuestion:"plan",Skill:"plan",Workflow:"plan",...Dz};function mI(e){return e.startsWith("mcp__")?"mcp":Lt(Uz,e)??"other"}const zz=/\btools\.exec_command\s*\(\s*\{[^{}]*?\bcmd\s*:\s*(["'`])((?:\\.|(?!\1)[^\\])*)\1/,Wz=/\btools\.([A-Za-z_$][\w$]*)\s*\(/;function Hz(e){if(typeof e!="string"||!e)return null;const t=zz.exec(e);if(t){const r=Vz(t[2]);if(r.trim())return r}const n=Wz.exec(e);return n?n[1]:null}function Vz(e){return e.replace(/\\(["'`\\nrt])/g,(t,n)=>n==="n"?`
76
- `:n==="r"?"\r":n==="t"?" ":n)}const Gz={Read:"📖",Write:"💾",Edit:"✏️",MultiEdit:"🔧",Glob:"🗺️",Grep:"🔎",Bash:"⚡",PowerShell:"💻",LS:"📂",Task:"🤖",Agent:"🤖",TodoWrite:"📋",TaskCreate:"📋",TaskUpdate:"📝",TaskList:"🗂️",TaskGet:"🗂️",TaskOutput:"📤",TaskStop:"🛑",WebFetch:"🌐",WebSearch:"🔭",ToolSearch:"🧰",NotebookEdit:"📓",EnterPlanMode:"🧭",ExitPlanMode:"🏁",AskUserQuestion:"❓",ScheduleWakeup:"⏰",CronCreate:"⏰",CronList:"📅",CronDelete:"🗑️",Skill:"🎯",Workflow:"🎬",Monitor:"📡",PushNotification:"🔔",RemoteTrigger:"📡",...Fz};function iS(e){return e.startsWith("mcp__")?"🔌":Lt(Gz,e)??"✨"}const Kz={git:"🐙",gh:"🐙",glab:"🐙",npm:"📦",pnpm:"📦",yarn:"📦",bun:"📦",brew:"🍺",node:"🟢",deno:"🟢",python:"🐍",python3:"🐍",py:"🐍",pip:"🐍",pip3:"🐍",uv:"🐍",ruby:"💎",bundle:"💎",gem:"💎",cargo:"🦀",rustc:"🦀",rustup:"🦀",go:"🐹",docker:"🐳","docker-compose":"🐳",podman:"🐳",kubectl:"☸️",helm:"☸️",k9s:"☸️",grep:"🔎",rg:"🔎",ag:"🔎",ack:"🔎",find:"🔍",fd:"🔍",locate:"🔍",which:"🔍",ls:"📂",dir:"📂",tree:"📂",cat:"📄",head:"📄",tail:"📄",less:"📄",more:"📄",bat:"📄",cp:"📋",mv:"✂️",rm:"🗑️",rmdir:"🗑️",mkdir:"📁",touch:"📁",sed:"✏️",awk:"✏️",tr:"✏️",curl:"🌐",wget:"🌐",http:"🌐",httpie:"🌐",ssh:"🔐",scp:"🔐",rsync:"🔐",ping:"📡",make:"🔨",cmake:"🔨",ninja:"🔨",bazel:"🔨",just:"🔨",terraform:"🏗️",ansible:"📕",pulumi:"🏗️",ps:"📊",top:"📊",htop:"📊",btm:"📊",kill:"💀",pkill:"💀",systemctl:"⚙️",service:"⚙️",tar:"🗜️",zip:"🗜️",unzip:"🗜️",gzip:"🗜️","7z":"🗜️",vim:"📝",nvim:"📝",nano:"📝",emacs:"📝",code:"📝",jq:"🪺",yq:"🪺",echo:"💬",printf:"💬",ffmpeg:"🎞️",ffprobe:"🎞️",imagemagick:"🖼️",convert:"🖼️","Get-ChildItem":"📂","Get-Content":"📄","Set-Content":"💾","Out-File":"💾","Add-Content":"💾","Set-Location":"📍","Get-Location":"📍","Get-Process":"📊","Start-Process":"▶️","Stop-Process":"💀","Invoke-WebRequest":"🌐","Invoke-RestMethod":"🌐","New-Item":"📁","Remove-Item":"🗑️","Copy-Item":"📋","Move-Item":"✂️","Test-Path":"🔍","Where-Object":"🔎","ForEach-Object":"🔁","Select-Object":"🎯","Measure-Object":"📊","Get-Service":"⚙️","Restart-Service":"⚙️","ConvertTo-Json":"🪺","ConvertFrom-Json":"🪺"};function gI(e){return/^-(?:Command|c)$/i.test(e)||/^-[a-z]+c$/.test(e)}function yI(e){if(!e)return null;let t=e.trim();if(!t)return null;const n=t.match(/^(?:bash|sh|zsh|fish|powershell|pwsh)(?:\.exe)?((?:\s+-[A-Za-z]+)+)\s*["']([^"']+)["']/i);if(n&&n[1].trim().split(/\s+/).every(o=>gI(o)||/^-(?:NoProfile|NonInteractive)$/i.test(o)))return yI(n[2]);for(;;){const o=t.match(/^([A-Z_][A-Z0-9_]*=\S*)\s+/);if(!o)break;t=t.slice(o[0].length)}t=t.replace(/^sudo(?:\s+-\S+)*\s+/,""),t=t.replace(/^(?:time|nohup|xargs)\s+/,"");const r=t.match(/^([^\s|;&<>(]+)/);if(!r)return null;let s=r[1];return/^[A-Za-z0-9_][\w.+-]*$/.test(s.replace(/^.*[/\\]/,""))?(s=s.replace(/^.*[/\\]/,""),s=s.replace(/\.(exe|cmd|bat|ps1)$/i,""),s||null):null}function Yz(e){if(typeof e=="string")return e;if(!e||typeof e!="object")return null;const t=e;if(typeof t.script=="string"){const n=Hz(t.script);if(n)return n}if(typeof t.cmd=="string")return t.cmd;if(typeof t.command=="string")return t.command;if(Array.isArray(t.command)&&t.command.every(n=>typeof n=="string")){const n=t.command;if(/powershell|cmd|bash|sh(\.exe)?$/i.test(n[0]??"")){const r=n.findIndex(gI);if(r>=0&&r+1<n.length)return n[r+1]}return n.join(" ")}return typeof t.script=="string"?t.script:null}const Xz=new Set(["Bash","PowerShell",...qz]);function Zz(e,t){if(!Xz.has(e))return null;const n=Yz(t);if(!n)return null;const r=yI(n);return r?{emoji:Lt(Kz,r)??"⚙️",label:r,category:"shell",detail:n}:null}const Jz=new Set(["Read","Write","Edit","MultiEdit","NotebookEdit","LS","Glob","apply_patch"]),Qz={ts:"🟦",tsx:"🟦",d:"🟦",js:"🟨",jsx:"🟨",mjs:"🟨",cjs:"🟨",py:"🐍",pyi:"🐍",ipynb:"📓",rs:"🦀",go:"🐹",rb:"💎",erb:"💎",java:"☕",kt:"☕",scala:"☕",gradle:"☕",cs:"🔷",fs:"🔷",php:"🐘",swift:"🦅",c:"🇨",cpp:"🇨",cc:"🇨",h:"🇨",hpp:"🇨",md:"📝",mdx:"📝",rst:"📝",json:"🪺",json5:"🪺",jsonl:"🪺",yaml:"⚙️",yml:"⚙️",toml:"⚙️",ini:"⚙️",conf:"⚙️",cfg:"⚙️",xml:"📰",html:"🌐",htm:"🌐",vue:"🌐",svelte:"🌐",css:"🎨",scss:"🎨",sass:"🎨",less:"🎨",sh:"⚡",bash:"⚡",zsh:"⚡",fish:"⚡",ps1:"⚡",txt:"📄",log:"📄",out:"📄",csv:"📊",tsv:"📊",xlsx:"📊",xls:"📊",pdf:"📕",png:"🖼️",jpg:"🖼️",jpeg:"🖼️",gif:"🖼️",webp:"🖼️",svg:"🖼️",ico:"🖼️",mp4:"🎬",mov:"🎬",avi:"🎬",mkv:"🎬",webm:"🎬",mp3:"🎵",wav:"🎵",ogg:"🎵",flac:"🎵",zip:"🗜️",tar:"🗜️",gz:"🗜️",bz2:"🗜️","7z":"🗜️",xz:"🗜️",rar:"🗜️",env:"🔐",lock:"🔐",pem:"🔐",key:"🔐",crt:"🔐",sql:"🗄️",db:"🗄️",sqlite:"🗄️",parquet:"🗄️"},eW={dockerfile:"🐳",makefile:"🔨",rakefile:"💎","package.json":"📦","pnpm-lock.yaml":"📦","yarn.lock":"📦","cargo.toml":"🦀","cargo.lock":"🦀","go.mod":"🐹","go.sum":"🐹","pyproject.toml":"🐍","requirements.txt":"🐍","readme.md":"📖",readme:"📖",license:"📜",".gitignore":"🐙",".gitattributes":"🐙",".env":"🔐",".dockerignore":"🐳"};function tW(e){const n=e.replace(/\\/g,"/").replace(/\/+$/,""),r=n.lastIndexOf("/");return r>=0?n.slice(r+1):n}function nW(e){const t=e.toLowerCase(),n=Lt(eW,t);if(n!==void 0)return n;if(t.startsWith("dockerfile."))return"🐳";if(/\.(test|spec)\.[a-z]+$/.test(t))return"🧪";const r=t.lastIndexOf(".");if(r>0&&r<t.length-1){const s=Lt(Qz,t.slice(r+1));if(s!==void 0)return s}return"📄"}function rW(e,t){if(!t||typeof t!="object")return null;const n=t;if(e==="apply_patch"&&typeof n.patch=="string"){const r=n.patch.match(/^\*\*\* (?:Update|Add|Delete) File: (.+)$/m);return r?r[1].trim():null}return typeof n.file_path=="string"?n.file_path:typeof n.notebook_path=="string"?n.notebook_path:typeof n.path=="string"?n.path:e==="Glob"&&typeof n.pattern=="string"?n.pattern:null}function sW(e,t){if(!Jz.has(e))return null;const n=rW(e,t);if(!n)return null;const r=tW(n);return r?{emoji:e==="LS"?"📂":nW(r),label:r,category:"file",detail:n}:null}const aW={github:{emoji:"🐙",name:"GitHub"},git:{emoji:"🐙",name:"Git"},gitlab:{emoji:"🦊",name:"GitLab"},slack:{emoji:"💬",name:"Slack"},discord:{emoji:"💬",name:"Discord"},linear:{emoji:"📐",name:"Linear"},jira:{emoji:"🅹",name:"Jira"},atlassian:{emoji:"🅰️",name:"Atlassian"},notion:{emoji:"📓",name:"Notion"},asana:{emoji:"📋",name:"Asana"},intercom:{emoji:"💬",name:"Intercom"},figma:{emoji:"🎨",name:"Figma"},gmail:{emoji:"📧",name:"Gmail"},calendar:{emoji:"📅",name:"Calendar"},drive:{emoji:"☁️",name:"Drive"},zoom:{emoji:"📹",name:"Zoom"},spotify:{emoji:"🎵",name:"Spotify"},youtube:{emoji:"📺",name:"YouTube"},ccd_session:{emoji:"📡",name:"Session"},ccd_directory:{emoji:"📂",name:"Directory"},ccd_session_mgmt:{emoji:"📡",name:"Sessions"},mcp_registry:{emoji:"🧰",name:"Registry"},"computer-use":{emoji:"🖱️",name:"Computer"},"claude-in-chrome":{emoji:"🌐",name:"Chrome"},"claude-preview":{emoji:"👀",name:"Preview"},"scheduled-tasks":{emoji:"⏰",name:"Scheduler"},visualize:{emoji:"🎨",name:"Visualize"},"plugin-design-asana":{emoji:"📋",name:"Asana"},"plugin-design-atlassian":{emoji:"🅰️",name:"Atlassian"},"plugin-design-figma":{emoji:"🎨",name:"Figma"},"plugin-design-intercom":{emoji:"💬",name:"Intercom"},"plugin-design-linear":{emoji:"📐",name:"Linear"},"plugin-design-notion":{emoji:"📓",name:"Notion"},"plugin-design-slack":{emoji:"💬",name:"Slack"}};function Nk(e){if(!e.startsWith("mcp__"))return null;const t=e.slice(5),n=t.indexOf("__");return n<=0?{server:t,method:""}:{server:t.slice(0,n),method:t.slice(n+2)}}function oW(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n);return Math.abs(t)%360}function wI(e){return Lt(aW,e.toLowerCase())}function iW(e,t){const n=Nk(e);if(!n)return null;const{server:r,method:s}=n;if(!s)return null;const o=wI(r);return{emoji:(o==null?void 0:o.emoji)??"🔌",label:s,category:"mcp",detail:o?`${o.name} · ${s}`:`${r} · ${s}`}}function vI(e,t){return Zz(e,t)??sW(e,t)??iW(e)}function lW(e,t){var n;return((n=vI(e,t))==null?void 0:n.label)??null}const cW=Bz,lS=18;function zu(e){const t=[...e];return t.length<=lS?e:t.slice(0,lS-1).join("")+"…"}const Wp=13,uW=6;function dW(e,t){const n=[...e];if(n.length<=Wp)return e;const r=n.lastIndexOf("."),s=r>0?n.slice(r):[];return t==="file"&&s.length>1&&s.length<=uW?n.slice(0,Wp-1-s.length).join("")+"…"+s.join(""):n.slice(0,Wp-1).join("")+"…"}function jk(e){const t=Nk(e);if(t){const r=wI(t.server);return r?{emoji:r.emoji,label:zu(r.name)}:{emoji:"🔌",label:zu(t.server),hue:oW(t.server)}}const n=Lt(cW,e)??"";return n?{emoji:iS(e),label:zu(n)}:{emoji:iS(e),label:zu(e)}}function hW(e){let t=null,n="";for(const r of e){const s=Nk(r);if(s){if(!s.server)return null;if(t===null)t=s.server,n=r;else if(s.server!==t)return null}}return t===null?null:jk(n)}const Qx=6e4,hi=24,cS=Qx/hi,Hp=132,dd=14;function fW(e,t,n){const r=new Array(hi).fill(0);let s=0;const o=g=>{const v=n-g;if(v<0||v>=Qx)return;const j=hi-1-Math.floor(v/cS);j>=0&&j<hi&&(r[j]+=1,s+=1)};for(const g of e)o(g.startedAt);for(const g of t??[])o(g);const c=Math.max(0,...r)/(cS/1e3),d=e.filter(g=>n-g.startedAt>=0&&n-g.startedAt<Qx).length,h=s-d,f=[d>0?`${d} tool ${d===1?"call":"calls"}`:"",h>0?`${h} ${h===1?"block":"blocks"} of thinking and writing`:""].filter(Boolean),p=s===0?"nothing in the last 60s":`${f.join(" · ")} in last 60s · peak ${c.toFixed(1)}/s`;return{counts:r,title:p}}const pW=2;function mW(e){return e===0?1.5:Math.max(1.5,Math.min(1,e/pW)*dd)}function xI({kind:e}){return a.jsxs("svg",{className:"state-mark","data-kind":e,viewBox:"0 0 10 10",width:"10",height:"10","aria-hidden":"true",focusable:"false",children:[e==="live"&&a.jsx("circle",{cx:"5",cy:"5",r:"3.2",fill:"currentColor"}),e==="done"&&a.jsx("path",{d:"M2.2 5.3l1.9 1.9 3.8-4.4",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),e==="err"&&a.jsx("path",{d:"M2.8 2.8l4.4 4.4M7.2 2.8l-4.4 4.4",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",fill:"none"})]})}function Sk(){return a.jsxs("svg",{className:"alert-mark",viewBox:"0 0 12 12",width:"12",height:"12","aria-hidden":"true",focusable:"false",children:[a.jsx("path",{d:"M6 1.4l4.7 8.3H1.3z",stroke:"currentColor",strokeWidth:"1.3",strokeLinejoin:"round",fill:"none"}),a.jsx("path",{d:"M6 4.6v2.4",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round"}),a.jsx("circle",{cx:"6",cy:"8.35",r:"0.72",fill:"currentColor"})]})}function bI(){return a.jsxs("svg",{className:"recap-glyph",viewBox:"0 0 12 12",width:"10",height:"10","aria-hidden":"true",focusable:"false",children:[a.jsx("path",{d:"M3.3 3.3l5.4 5.4M8.7 3.3l-5.4 5.4",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",fill:"none"}),a.jsx("circle",{cx:"6",cy:"1.2",r:"1.05",fill:"currentColor"}),a.jsx("circle",{cx:"6",cy:"10.8",r:"1.05",fill:"currentColor"}),a.jsx("circle",{cx:"1.2",cy:"6",r:"1.05",fill:"currentColor"}),a.jsx("circle",{cx:"10.8",cy:"6",r:"1.05",fill:"currentColor"})]})}function Ad({recap:e}){return e?a.jsx(bI,{}):a.jsx("svg",{className:"recap-glyph note-glyph",viewBox:"0 0 12 12",width:"10",height:"10","aria-hidden":"true",focusable:"false",children:a.jsx("circle",{cx:"6",cy:"6",r:"3",fill:"currentColor"})})}function gW({data:e}){var N,b;const t=["agent-node",`state-${e.state}`,e.synthetic?"synthetic":""].filter(Boolean).join(" "),n=e.tools.filter(S=>!S.endedAt).length,r=e.toolErrorCount??0,s=tc(e.sessionId),o=((N=e.context)==null?void 0:N.currentContextTokens)??0,l=e.kind==="root"&&o>0,c=e.sessionTitle?e.cwd?`${e.cwd}
77
- ${e.sessionTitle}`:e.sessionTitle:e.cwd,d=vk(e),h=d.length>0?`${e.model}
78
- spend on this card also covers:
79
- ${d.join(`
80
- `)}`:e.model,f=xk(e.sessionName,e.sessionTitle),p=hh(e),g=p?p.key:null,v=Cz(g),j=p!=null&&!v,k=(p==null?void 0:p.kind)==="recap",x=MU(e);return a.jsxs("div",{className:t,style:{"--session-hue":s},children:[a.jsx("span",{className:"accent-stripe"}),a.jsx(eo,{type:"target",position:Ae.Left,style:{background:"transparent",border:"none"}}),a.jsxs("div",{className:"head",children:[a.jsxs("div",{className:"title",children:[a.jsx(xW,{state:e.state}),a.jsx("span",{className:"label",title:c,children:e.label}),e.synthetic&&a.jsx("span",{className:"synth-tag",title:"No SessionStart captured — synthesised",children:"?"}),p&&g&&a.jsx("button",{type:"button",className:"glyph-btn recap-pin","aria-label":k?"Claude Code's recap":`Session note: ${sa(p.kind)}`,"aria-expanded":j,title:k?j?"Hide the recap":"Show Claude Code's recap":j?"Hide this note":"Show what this session is doing",onClick:S=>{S.stopPropagation(),Ez(g)},children:a.jsx(Ad,{recap:k})})]}),a.jsxs("div",{className:"head-right",children:[l&&e.onOpenContext&&a.jsx(gz,{currentContextTokens:o,modelId:e.model,contextWindow:e.contextWindow,onClick:()=>e.onOpenContext(e.sessionId)}),a.jsxs("div",{className:"time",title:e.synthetic?`The deck joined this session after it began, so it has run at least this long — first seen ${new Date(e.startedAt).toLocaleTimeString()}`:`Started ${new Date(e.startedAt).toLocaleTimeString()}`,children:[e.synthetic?"≥ ":"",a.jsx(vW,{start:e.startedAt,end:e.endedAt})]})]})]}),a.jsxs("div",{className:"sub",title:WU(e),children:[e.kind==="root"?"session":"subagent",e.childCount>0&&a.jsxs("span",{className:"spawn-badge",title:zU(e.childCount),children:["→ ",e.childCount]}),e.cwdBasename&&e.kind==="subagent"?` · ${e.cwdBasename}`:"",e.model?a.jsxs("span",{className:"model-chip","data-family":ch(e.model),title:h,children:[ks(e.model),d.length>0?` +${d.length}`:""]}):e.provider==="codex"?a.jsx("span",{className:"model-chip",title:"OpenAI Codex — no model reported yet",children:"Codex"}):null]}),e.kind==="root"&&f.face&&a.jsx("div",{className:"session-name",title:f.tooltip,children:f.face}),e.waiting&&a.jsx(bW,{waiting:e.waiting}),(()=>{const S=nI(e);return S?a.jsxs("div",{className:"approval-blind-row",title:S.detail,children:[a.jsx("span",{className:"approval-blind-dot","aria-hidden":!0}),a.jsx("span",{className:"approval-blind-said",children:S.label})]}):null})(),(e.tools.length>0||(((b=e.outputs)==null?void 0:b.length)??0)>0)&&a.jsx(kW,{tools:e.tools,outputs:e.outputs}),a.jsxs("div",{className:"meta",children:[a.jsxs("span",{children:[a.jsx("b",{children:e.toolCount})," ",e.toolCount===1?"tool":"tools"]}),r>0&&a.jsxs("span",{className:"failed-meta",title:`${r} tool ${r===1?"call":"calls"} returned an error`,children:[a.jsx("b",{children:r})," err"]}),n>0&&a.jsxs("span",{className:"inflight-meta",children:[a.jsx("b",{children:n})," in-flight"]}),e.usage.inputTokens+e.usage.outputTokens>0&&a.jsxs("span",{className:"tokens-meta",title:`in:${e.usage.inputTokens} out:${e.usage.outputTokens} cache-r:${e.usage.cacheReadTokens} cache-c:${e.usage.cacheCreateTokens}${(e.usage.reasoningOutputTokens??0)>0?` reasoning:${e.usage.reasoningOutputTokens}`:""}`,children:[a.jsx("b",{children:st(e.usage.inputTokens+e.usage.outputTokens)})," tok"]}),(x==null?void 0:x.kind)==="unpriced"&&a.jsx("span",{className:"cost-unpriced",title:x.tt,children:bs}),(x==null?void 0:x.kind)==="spent"&&a.jsx("span",{className:"cost-meta",title:x.tt,children:a.jsxs("b",{children:[We(x.total),x.floor?"+":""]})})]}),a.jsx(wW,{data:e,title:e.kind==="root"?f.face:void 0}),a.jsx(eo,{type:"source",position:Ae.Right,style:{background:"transparent",border:"none"}})]})}const yW=y.memo(gW);function wW({data:e,title:t}){const n=e.kind==="root"&&En(e.waiting),r=Lz(e,e.branch,{sayWaiting:Td,describeCall:s=>({name:jk(s.name).label,subject:lW(s.name,s.input)})});return a.jsxs("div",{className:"lod-face","data-kind":e.kind,"data-alarm":n?"":void 0,"data-signal":r?"":void 0,"aria-hidden":!0,children:[a.jsxs("div",{className:"lod-id",children:[a.jsx(xI,{kind:Jx(e.state)}),a.jsx("span",{className:"lod-name",children:e.label}),r&&a.jsx("span",{className:"lod-inline","data-tone":r.tone,children:r.short}),n&&a.jsx(Sk,{})]}),t&&a.jsx("div",{className:"lod-title",children:t}),r&&a.jsxs("div",{className:"lod-signal","data-tone":r.tone,children:[a.jsx("span",{className:"lod-long",children:r.long}),a.jsx("span",{className:"lod-short",children:r.short})]})]})}function vW({start:e,end:t}){const n=Ii(1e3);return a.jsx(a.Fragment,{children:ki(e,t,n)})}function xW({state:e}){return a.jsx("span",{className:`state-pill state-${e}`,children:xi(e)})}function bW({waiting:e}){const t=Ii(1e3),n=En(e),r=bi(e);return a.jsxs("div",{className:n?"waiting-row permission":"waiting-row idle",title:`${r}
81
- Blocked for ${ki(e.since,void 0,t)} — the answer goes in the terminal, not here.`,children:[n?a.jsx("span",{className:"ap-pulse","aria-hidden":!0}):a.jsx("span",{className:"waiting-dot","aria-hidden":!0}),a.jsx("span",{className:"waiting-said",children:Td(e)}),a.jsx("b",{children:ki(e.since,void 0,t)})]})}function kW({tools:e,outputs:t}){const n=Ii(1e3),{counts:r,title:s}=fW(e,t,n),o=Hp/hi;return a.jsxs("div",{className:"tool-spark-row",title:s,children:[a.jsx("svg",{className:"tool-spark",width:Hp,height:dd,viewBox:`0 0 ${Hp} ${dd}`,"aria-hidden":!0,children:r.map((l,c)=>{const d=mW(l),h=c===hi-1&&l>0,p=`tool-spark-bar${l>0?" active":""}${h?" latest":""}`;return a.jsx("rect",{x:c*o+.4,y:dd-d,width:Math.max(.5,o-1),height:d,rx:.8,className:p},h?`landed:${l}`:c)})}),a.jsx("span",{className:"tool-spark-label",children:"60s"})]})}function NW({enableAutoFitAndRefit:e}){return a.jsxs("div",{className:"autofit-chip",children:[a.jsx("span",{className:"autofit-state",title:"New sessions are not brought into view while you are moving it yourself",children:"Auto-fit off"}),a.jsx("button",{type:"button",className:"autofit-resume",onClick:e,title:"Bring new sessions into view again","aria-label":"Resume auto-fit",children:"Resume"})]})}function Rd(e){const t=Math.max(0,Math.floor(e));return`${t} event${t===1?"":"s"}`}const uS=99;function jW(e){const t=Math.max(0,Math.floor(e));return t>uS?`${uS}+`:String(t)}const SW="Pause the canvas";function _W(e){if(!e.paused)return"Pause live updates — events keep arriving and are applied when you resume (Space)";const t=Math.max(0,Math.floor(e.dropped??0));return t>0?`The pause is full — ${Rd(e.held)} held and ${t} older ${t===1?"one":"ones"} already dropped. Resume to follow the canvas again (Space)`:e.held<=0?"Nothing has arrived since you paused. Resume to follow the canvas again (Space)":`${Rd(e.held)} arrived while paused and will be applied in order when you resume (Space)`}function EW(e){return e.connected||!e.paused?null:"The canvas is paused as well — Space resumes it, but nothing new arrives until the stream is back."}const kI="paused · full",CW=(e,t)=>t>0?kI:e>0?`paused · ${jW(e)}`:"paused";function TW(e){const t=Math.max(0,Math.floor(e.dropped??0));return e.connected?e.paused?{tone:"paused",resting:!1,label:CW(e.held,t),widest:kI,title:t>0?`Connected — the pause is full at ${Rd(e.held)}; the oldest are being dropped as new ones arrive. Resume to catch up (Space)`:e.held>0?`Connected — ${Rd(e.held)} held until you resume (Space)`:"Connected — updates held until you resume (Space)"}:{tone:"live",resting:!0,label:"live",widest:"live",title:"Receiving events"}:{tone:"dead",resting:!1,label:"offline",widest:"offline",title:e.paused?"SSE disconnected — and the canvas is paused, so resuming will not bring events back until it reconnects":"SSE disconnected"}}const AW=e=>e.transform[2]>=e.maxZoom,RW=e=>e.transform[2]<=e.minZoom;function MW({autoFitDisabled:e,enableAutoFitAndRefit:t,paused:n,pauseGate:r,togglePause:s,handleRelayout:o,requestClear:l,setKeyHelpOpen:c}){const d=Ai(),h=He(AW),f=He(RW);return a.jsxs(W8,{showInteractive:!1,showFitView:!1,showZoom:!1,children:[a.jsx(zn,{onClick:()=>{h||d.zoomIn()},title:"Zoom in","aria-label":"Zoom in","aria-disabled":h||void 0,children:a.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:a.jsx("path",{d:"M12 5v14M5 12h14",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})})}),a.jsx(zn,{onClick:()=>{f||d.zoomOut()},title:"Zoom out","aria-label":"Zoom out","aria-disabled":f||void 0,children:a.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:a.jsx("path",{d:"M5 12h14",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})})}),a.jsx(zn,{onClick:t,title:e?"Recenter view + re-enable autofit":"Recenter view (autofit already on)","aria-label":"Recenter view","data-nudge":e?"":void 0,children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[a.jsx("circle",{cx:"12",cy:"12",r:"3.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),a.jsx("path",{d:"M12 2v4M12 18v4M2 12h4M18 12h4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})]})}),a.jsx(zn,{"data-group-start":"",onClick:s,title:_W({paused:n,held:r.size,dropped:r.dropped}),"aria-label":SW,"aria-pressed":n,children:a.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:a.jsx("path",{d:"M9 5.5v13M15 5.5v13",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})})}),a.jsx(zn,{onClick:o,title:"Auto-arrange — clear pins (R)","aria-label":"Re-arrange the canvas",children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[a.jsx("rect",{x:"8.5",y:"2",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),a.jsx("rect",{x:"1.5",y:"17",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),a.jsx("rect",{x:"15.5",y:"17",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),a.jsx("path",{d:"M12 7v6.5M5 17v-3.5h14V17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]})}),a.jsx(zn,{"data-group-start":"","data-danger":"",onClick:()=>l("button"),title:"Clear the canvas and the server's event log — asks first (C)","aria-label":"Clear the canvas",children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[a.jsx("path",{d:"M4 6.2h16",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"}),a.jsx("path",{d:"M9 6.2V4.4a1.6 1.6 0 0 1 1.6-1.6h2.8a1.6 1.6 0 0 1 1.6 1.6v1.8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),a.jsx("path",{d:"M17.4 6.4 16.7 20a2 2 0 0 1-2 1.9H9.3a2 2 0 0 1-2-1.9L6.6 6.4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),a.jsx("path",{d:"M10.3 10.6v6.8M13.7 10.6v6.8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})]})}),a.jsx(zn,{"data-group-start":"",onClick:()=>c(p=>!p),title:"Keyboard shortcuts (?)","aria-label":"Open the keyboard shortcuts","aria-haspopup":"dialog",children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[a.jsx("path",{d:"M8.6 8.4a3.5 3.5 0 1 1 4.6 3.35c-.85.3-1.2 1-1.2 1.85v1",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),a.jsx("path",{d:"M12 18.4v.2",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",fill:"none"})]})})]})}const Ya=148,dS=6e3,$W=16e3,NI=46,ta=34;function IW(e,t,n=Ya){let r=-Math.round(t()*n);if(Math.abs(r-e)<ta){const s=e-ta>=-n?-ta:ta;r=Math.max(-n,Math.min(0,Math.round(e+s)))}return{to:r,ms:Math.round(Math.abs(r-e)*NI)}}function OW(e){return Math.round(dS+e()*($W-dS))}const hS=[{kind:"stroll",weight:44},{kind:"tidy",weight:17},{kind:"kick",weight:17},{kind:"sit",weight:12},{kind:"watch",weight:16},{kind:"leave",weight:7},{kind:"fish",weight:12},{kind:"skip",weight:10}];function LW(e){const t=hS.reduce((r,s)=>r+s.weight,0);let n=e()*t;for(const r of hS)if(n-=r.weight,n<0)return r.kind;return"stroll"}const PW=720,DW=260,FW=620,BW=220,fS=520,jI=1600,pS=7e3,qW=15e3,mS=6e3,UW=14e3;function Go(e,t,n=Ya){let r=-Math.round(t()*n);if(Math.abs(r-e)<ta){const s=e-ta>=-n?-ta:ta;r=Math.max(-n,Math.min(0,Math.round(e+s)))}return r}const Tt=(e,t)=>Math.round(Math.abs(t-e)*NI),zW=120,Wu=0;function WW(e,t){const n=r=>({kind:"litter",at:t,...r});return[{x:t,prop:n({}),act:"walk",ms:Tt(e,t)},{x:t,prop:n({}),act:"stoop",ms:PW},{x:Wu,prop:n({held:!0}),act:"carry",ms:Tt(t,Wu)},{x:Wu,prop:n({held:!0}),act:"windup",ms:DW},{x:Wu,prop:n({held:!0,leaving:!0}),act:"toss",ms:FW}]}function HW(e,t){const n=t>e?1:-1,r=t-n*Math.min(15,Math.abs(t-e)),s=(o={})=>({kind:"ball",at:t,...o});return[{x:r,prop:s(),act:"walk",ms:Tt(e,r)},{x:r,prop:s(),act:"windup",ms:BW,facing:n>0?"right":"left"},{x:r,prop:s({leaving:!0}),act:"kick",ms:fS,facing:n>0?"right":"left"},{x:r,prop:s({leaving:!0}),act:"stand",ms:jI-fS}]}const SI=640;function VW(e,t,n){const r=Math.max(-70,Math.min(-20,t)),s={x:r,prop:null,facing:"left"};return[{x:r,prop:null,act:"walk",ms:Tt(e,r)},{...s,act:"sit",ms:600},{...s,act:"cast",ms:900},{...s,act:"fish",ms:6e3+Math.round(n()*4e3)},{...s,act:"reel",ms:1200},{...s,act:"stow",ms:500},{...s,act:"stand",ms:400},{x:0,prop:null,act:"walk",ms:Tt(r,0)}]}function GW(e,t,n){const r=Math.max(-110,Math.min(-30,t)),s={x:r,prop:null};return[{...s,act:"walk",ms:Tt(e,r)},{...s,act:"skip-ready",ms:500},{...s,act:"skip",ms:SI*(6+Math.floor(n()*5))},{...s,act:"skip-rest",ms:600},{...s,act:"stand",ms:350},{x:0,prop:null,act:"walk",ms:Tt(r,0)}]}function KW(e,t,n){return[{x:t,prop:null,act:"walk",ms:Tt(e,t)},{x:t,prop:null,act:"sit",ms:Math.round(mS+n()*(UW-mS))},{x:t,prop:null,act:"stand",ms:400}]}function YW(e,t,n){t=Math.max(-110,Math.min(0,t));const r=()=>({kind:"scope",at:t,held:!0});return[{x:t,prop:null,act:"walk",ms:Tt(e,t)},{x:t,prop:r(),act:"watch",ms:Math.round(pS+n()*(qW-pS))},{x:t,prop:r(),act:"scope-pack",ms:480},{x:t,prop:null,act:"stand",ms:240}]}function Vp(e,t,n){return e.facing?e.facing:e.act==="watch"||e.act==="scope-pack"?"left":e.x===t?n:e.x>t?"right":"left"}const XW=1500,ZW=e=>Math.round(1e3*Math.sqrt(2*e/XW)),JW=115,QW=e=>Math.round(e/JW*1e3),eH=620,tH=200,nH=760,rH=600,sH=240;function aH(e,t,n){const s=-(t.ledgeSpan??Ya),o=ZW(t.ledgeH),l=QW(t.ledgeH),c=n(),d=n(),h=-Math.round(c*t.floorSpan),f=-Math.round(d*t.floorSpan);return[{x:s,act:"walk",prop:null,ms:Tt(e,s)},{x:s,act:"peer",prop:null,ms:eH},{x:s,act:"fall",prop:null,ms:o,place:"floor"},{x:s,act:"land",prop:null,ms:tH,place:"floor"},{x:h,act:"walk",prop:null,ms:Tt(s,h),place:"floor",floorFrac:c},{x:f,act:"walk",prop:null,ms:Tt(h,f),place:"floor",floorFrac:d},{x:s,act:"walk",prop:null,ms:Tt(f,s),place:"floor"},{x:s,act:"lasso",prop:null,ms:nH,place:"floor"},{x:s,act:"rope-throw",prop:null,ms:rH,place:"floor"},{x:s,act:"rope-catch",prop:null,ms:sH,place:"floor"},{x:s,act:"climb",prop:null,ms:l},{x:s,act:"pull-up",prop:null,ms:480}]}function oH(e,t,n){const r=(n==null?void 0:n.ledgeSpan)??Ya;switch(LW(t)){case"tidy":return WW(e,Go(e,t,r));case"kick":return HW(e,Go(e,t,r));case"sit":return KW(e,Go(e,t,r),t);case"watch":return YW(e,Go(e,t,r),t);case"fish":return VW(e,Go(e,t,r),t);case"skip":return GW(e,Go(e,t,r),t);case"leave":{if(!n||!(n.ledgeH>0)||!(n.floorSpan>0))break;return aH(e,n,t)}}const o=IW(e,t,r);return[{x:o.to,prop:null,act:"walk",ms:o.ms}]}const iH=420;function lH(e,t,n){const r=t==="right"?n-e-18:e-18;return(t==="right"?1:-1)*Math.min(iH,Math.max(0,r))}const cH=260,uH=200;function dH(e,t,n){const r=(f,p=Tt(e,f))=>({x:f,prop:null,act:"walk",ms:p,place:"floor"});if(!n||n.height<=0)return[r(t)];const s=Math.min(e,t);if(Math.max(e,t)<=n.left||s>=n.right)return[r(t)];const l=t>e,c=l?n.left:n.right,d=l?n.right:n.left,h={place:"floor",riser:n.height,prop:null};return[r(c,Tt(e,c)),{...h,x:c,act:"mount",ms:cH},{...h,x:d,act:"walk",ms:Tt(c,d)},{x:d,prop:null,act:"dismount",ms:uH,place:"floor"},{x:t,prop:null,act:"walk",ms:Tt(d,t),place:"floor"}]}const _I=["bob","sway","groove"],gS=9e3,hH=16e3,EI=1e3,fH=.08;function pH(e,t){const n=_I.filter(o=>o!==e),r=n[Math.min(n.length-1,Math.floor(t()*n.length))],s=(t()*2-1)*fH;return{dance:r,beatMs:Math.round(EI*(1+s))}}function mH(e){return Math.round(gS+e()*(hH-gS))}const CI=["......aaaaaa......","....aa......aa....","...a..bbbbbs..a...","...cpcbbbbbscpc...","...cpcbebbescpc...","...cpcbbbbbscpc...","...cpcbbbbbscpc...","....ccbbbbbscc....","....bbbbbbbbbs....","....bbbbbbbbbs....","......bbbbbs......","......bb..bs......","......bb..bs......","......bb..bs......"],yS=18,gH=CI.length,TI=new Set(["a","c","p"]);function mh(e=CI){const t=[];return e.forEach((n,r)=>{let s=0;for(;s<n.length;){const o=n[s];if(o==="."){s+=1;continue}let l=1;for(;s+l<n.length&&n[s+l]===o;)l+=1;t.push({x:s,y:r,w:l,cell:o}),s+=l}}),t}const yH=[".xx.","xxxx",".xx."],wH=["..xx..",".xsxx.","xssxxx","xxxxsx",".xxxx.","..xx.."],vH=["...xx...............","..xaax..............",".xaallx.............","xaallllx............",".xllllllx...........","..xllllllx..........","...xllllllx.........","....xllllllxx.......",".....xllllxsxx..xx..","......xllxsssx.xllxx",".......xxssssxxxllxx","........xssssssxx...",".........xssssx.....","..........xxxx......","..........xax.......",".........xxxxx......","........xx.x.xx.....","........xl.x.lx.....",".......xl..x..lx....",".......xl..x..lx....","......xl...x...lx...","......xl...x...lx...",".....xl....x....lx..","....xxx...xxx...xxx."],Gp={litter:yH,ball:wH,scope:vH},xH=["...hhhhhh...","...hhhhhh...","...kkkkkk...","hhhhhhhhhhhh"],bH=3,kH=-1,eb=11,wS=9,tb="https://www.youtube-nocookie.com";function NH(e,t,n){const r=new URLSearchParams({...n?{}:{channel:e},enablejsapi:"1",autoplay:"1",playsinline:"1",rel:"0",modestbranding:"1",origin:t});return`${tb}/embed/${n?encodeURIComponent(n):"live_stream"}?${r.toString()}`}function Ko(e,t=[]){return JSON.stringify({event:"command",func:e,args:t})}function jH(e="claude-fm"){return JSON.stringify({event:"listening",id:e,channel:"widget"})}const SH=[1,3],_H=[0,2],EH=[2,5,100,101,150];function CH(e){let t=e;if(typeof e=="string")try{t=JSON.parse(e)}catch{return null}if(!t||typeof t!="object")return null;const{event:n,info:r}=t;if(n==="onReady")return{kind:"ready"};if(n==="onError"){const s=typeof r=="number"?r:Number(r==null?void 0:r.errorCode);return Number.isFinite(s)?{kind:"error",code:s}:null}if(n==="onStateChange"||n==="infoDelivery"){const s=typeof r=="number"?r:r==null?void 0:r.playerState;return typeof s!="number"||!Number.isFinite(s)?null:SH.includes(s)?{kind:"playing",playing:!0}:_H.includes(s)?{kind:"playing",playing:!1}:null}return null}const TH="modulepreload",AH=function(e){return"/"+e},vS={},_k=function(t,n,r){let s=Promise.resolve();if(n&&n.length>0){let l=function(h){return Promise.all(h.map(f=>Promise.resolve(f).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),d=(c==null?void 0:c.nonce)||(c==null?void 0:c.getAttribute("nonce"));s=l(n.map(h=>{if(h=AH(h),h in vS)return;vS[h]=!0;const f=h.endsWith(".css"),p=f?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${p}`))return;const g=document.createElement("link");if(g.rel=f?"stylesheet":TH,f||(g.as="script"),g.crossOrigin="",g.href=h,d&&g.setAttribute("nonce",d),document.head.appendChild(g),f)return new Promise((v,j)=>{g.addEventListener("load",v),g.addEventListener("error",()=>j(new Error(`Unable to preload CSS for ${h}`)))})}))}function o(l){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=l,window.dispatchEvent(c),!c.defaultPrevented)throw l}return s.then(l=>{for(const c of l||[])c.status==="rejected"&&o(c.reason);return t().catch(o)})},jl=new Set;let xS="";function bS(e){const t=new Date().toISOString().slice(0,10);if(t!==xS&&(jl.clear(),xS=t),!jl.has(e)){jl.add(e);try{const n=typeof navigator>"u"?void 0:navigator;(!n||typeof n.sendBeacon!="function"||!n.sendBeacon("/api/feature",JSON.stringify({name:e})))&&jl.delete(e)}catch{jl.delete(e)}}}const kS=864e5,RH=6e4;function qt(e,t=!0){y.useEffect(()=>{if(!t)return;bS(e);let n;const r=()=>{n=setTimeout(()=>{bS(e),r()},kS-Date.now()%kS+RH)};return r(),()=>clearTimeout(n)},[e,t])}const MH={"claude-fm":null,"lofi-relax":null,"lofi-game":null,"lofi-vibe":null,"lofi-sleep":null,"radio-mix":"/api/live-radio-mix","best-of-nostalgia":"/api/best-of-nostalgia","good-life-radio":"/api/good-life-radio","cafe-music-bgm":"/api/cafe-music-bgm"};function $H({fetchImpl:e,volume:t,muted:n,source:r,playRequest:s,customStation:o,onAvailabilityChange:l}){const[c,d]=y.useState(null),[h,f]=y.useState(!1),[p,g]=y.useState(!1),[v,j]=y.useState(!1);qt("claude-fm",v);const k=y.useRef(s),x=y.useRef(null),N=y.useRef(null),b=y.useRef(null),S=y.useCallback(()=>{var B;(B=N.current)==null||B.destroy(),N.current=null;const $=x.current;$&&($.pause(),$.removeAttribute("src"),$.load(),x.current=null)},[]),E=y.useCallback($=>{var B,L;(L=(B=b.current)==null?void 0:B.contentWindow)==null||L.postMessage($,tb)},[]),R=y.useRef(t);R.current=t;const I=y.useRef(n);I.current=n;const A=y.useCallback(($,B,L)=>{S();const M=new Audio;M.preload="none",M.volume=R.current/100,M.muted=I.current,x.current=M,g(!0),j(!0);const F=()=>x.current===M,T=()=>{S(),g(!1),j(!1)},P=()=>{F()&&(T(),f(!0),l==null||l(L,!0))},O=G=>{if(F()){if(G instanceof DOMException&&G.name==="NotAllowedError"){T();return}P()}};M.addEventListener("playing",()=>{F()&&(j(!0),l==null||l(L,!1))}),M.addEventListener("ended",()=>{F()&&T()}),M.addEventListener("error",P,{once:!0}),B&&!M.canPlayType("application/vnd.apple.mpegurl")?_k(async()=>{const{default:G}=await import("./hls-BFpXDghs.js");return{default:G}},[]).then(({default:G})=>{if(!F())return;if(!G.isSupported()){P();return}const K=new G;N.current=K,K.on(G.Events.ERROR,(U,H)=>{H.fatal&&P()}),K.on(G.Events.MEDIA_ATTACHED,()=>K.loadSource($)),K.on(G.Events.MANIFEST_PARSED,()=>{M.play().catch(O)}),K.attachMedia(M)},P):(M.src=$,M.play().catch(O))},[l,S]);return y.useEffect(()=>{p&&(E(Ko("setVolume",[t])),E(Ko(n?"mute":"unMute")),x.current&&(x.current.volume=t/100,x.current.muted=n))},[t,n,p,E]),y.useEffect(()=>{let $=!0;const B=e??fetch,L=k.current!==s;k.current=s,d(null),f(!1),g(L),j(L),S();const M=o&&to(o.id)===r?hk(o.url):null;if(M)return M.kind==="direct-audio"?(d({live:!0,channel:"",audio:M.url,hls:M.format==="hls"}),l==null||l(r,!1),L&&A(M.url,M.format==="hls",r),()=>{$=!1}):(B(`/api/fm-station?url=${encodeURIComponent(M.url)}`).then(P=>P.ok?P.json():null).then(P=>{$&&(P!=null&&P.channel||P!=null&&P.video?(d({live:!0,channel:P.channel??"",video:P.video??void 0}),l==null||l(r,!1)):(f(!0),l==null||l(r,!0)))}).catch(()=>{$&&(f(!0),l==null||l(r,!0))}),()=>{$=!1});if(wi(r))return f(!0),l==null||l(r,!0),()=>{$=!1};const F=r,T=MH[F];if(T)B(T).then(P=>P.ok?P.json():null).then(P=>{$&&(P!=null&&P.video&&d({live:!0,channel:"",video:P.video}),l==null||l(r,!(P!=null&&P.video)))}).catch(()=>{$&&(l==null||l(r,!0))});else if(F!=="claude-fm"){const P=F.replace("lofi-","");B(`/api/lofi-girl?station=${encodeURIComponent(P)}`).then(O=>O.ok?O.json():null).then(O=>{$&&(O!=null&&O.video&&d({live:!0,channel:"",video:O.video}),l==null||l(r,!(O!=null&&O.video)))}).catch(()=>{$&&(l==null||l(r,!0))})}else B("/api/claude-fm").then(P=>P.ok?P.json():null).then(P=>{if(!$)return;const O=!!(P!=null&&P.live&&(P!=null&&P.channel));O&&d({live:!0,channel:P.channel}),l==null||l(r,!O)}).catch(()=>{$&&(l==null||l(r,!0))});return()=>{$=!1}},[o==null?void 0:o.id,o==null?void 0:o.url,e,l,s,r,A,S]),y.useEffect(()=>()=>S(),[S]),y.useEffect(()=>{if(!p)return;const $=B=>{var M;if(B.origin!==tb||B.source!==((M=b.current)==null?void 0:M.contentWindow))return;const L=CH(B.data);if(L){if(L.kind==="ready"){E(Ko("setVolume",[R.current])),E(Ko(n?"mute":"unMute")),E(Ko("playVideo"));return}if(L.kind==="playing"){j(L.playing);return}EH.includes(L.code)&&(g(!1),j(!1),f(!0),l==null||l(r,!0))}};return window.addEventListener("message",$),()=>window.removeEventListener("message",$)},[p,n,l,E,r]),{probe:c,dead:h,armed:p,playing:v,frame:b,say:E,press:()=>{if(!c)return;if(c.audio){if(p){S(),g(!1),j(!1);return}A(c.audio,c.hls===!0,r);return}if(!p){g(!0),j(!0);return}const $=!v;j($),E(Ko($?"playVideo":"pauseVideo")),$||g(!1)}}}function NS(e){let t=null,n=null,r=0,s=0,o=!1;const l=()=>{t!==null&&clearTimeout(t),t=null},c=()=>{o||e.hidden||!n||t!==null||(s=performance.now(),t=setTimeout(()=>{t=null;const h=n;n=null,h==null||h()},r))},d=()=>{e.hidden&&t!==null?(r=Math.max(0,r-(performance.now()-s)),l()):e.hidden||c()};return e.addEventListener("visibilitychange",d),{schedule(h,f){o||(l(),n=h,r=Math.max(0,f),c())},dispose(){o=!0,l(),n=null,e.removeEventListener("visibilitychange",d)}}}function IH(e,t,n){const[r,s]=y.useState(0),[o,l]=y.useState(0),[c,d]=y.useState(null),[h,f]=y.useState(null),[p,g]=y.useState({x:0,drop:0}),[v,j]=y.useState("ledge"),[k,x]=y.useState("left"),[N,b]=y.useState(0),S=y.useRef(null),[E,R]=y.useState(()=>document.hidden);y.useEffect(()=>{const M=new Set,F=()=>{var T;if(document.hidden){for(const P of((T=S.current)==null?void 0:T.getAnimations({subtree:!0}))??[])if(P.playState==="running"||P.pending){const O=P.currentTime;P.pause(),O!==null&&(P.currentTime=O),M.add(P)}}else{for(const P of M)P.playState==="paused"&&P.play();M.clear()}R(document.hidden)};return F(),document.addEventListener("visibilitychange",F),()=>document.removeEventListener("visibilitychange",F)},[e,t]);const[I,A]=y.useState(null),[q,$]=y.useState(EI),[B,L]=y.useState(()=>{var M;return((M=window.matchMedia)==null?void 0:M.call(window,"(prefers-reduced-motion: reduce)").matches)??!1});return y.useEffect(()=>{var T;const M=(T=window.matchMedia)==null?void 0:T.call(window,"(prefers-reduced-motion: reduce)");if(!M)return;const F=()=>L(M.matches);return F(),M.addEventListener("change",F),()=>M.removeEventListener("change",F)},[]),y.useEffect(()=>{var Y;if(!e||t||B)return;const M=NS(document);let F=0;s(X=>F=X);let T=null,P=0,O=0;const G=X=>{var ye,se;const[ee,...ae]=X;if(!ee){T=null,d(null),f(null),J();return}d(ee.act),f(ee.prop),j(ee.place??"ledge"),b(ee.riser??0);const ce=F,ge=D(ee);if(ee.act==="kick"){const pe=(se=(ye=S.current)==null?void 0:ye.querySelector('.fm-prop[data-prop="ball"]'))==null?void 0:se.getBoundingClientRect();pe&&g({x:lH(pe.x,Vp(ee,ce,"left"),window.innerWidth),drop:Math.max(48,window.innerHeight-pe.y+24)})}O=ee.act==="walk"?Math.max(Tt(ce,ge),zW):ee.ms,ee.act==="carry"&&(O=Tt(ce,ge)),l(O),x(pe=>Vp({...ee,x:ge},ce,pe)),s(ge),F=ge,T=ee,P=Date.now(),M.schedule(()=>G(ae),O)},K=()=>{const X=S.current,ee=X==null?void 0:X.querySelector(".fm-sprite"),ae=X==null?void 0:X.parentElement;if(!X||!ee||!ae)return null;const ce=X.getBoundingClientRect(),ge=ae.getBoundingClientRect(),ye=ge.right-ce.right,se=ge.width-ye*2-ee.offsetWidth;return se>0?se:null},U=()=>{const X=S.current,ee=X==null?void 0:X.querySelector(".fm-walker"),ae=K();if(!X||!ee||ae==null)return;const ce=X.getBoundingClientRect().bottom-ee.getBoundingClientRect().bottom;if(ce>0)return{ledgeH:ce,floorSpan:ae}},H=()=>{const X=S.current,ee=document.querySelector(".autofit-chip");if(!X||!ee)return null;const ae=X.getBoundingClientRect(),ce=ee.getBoundingClientRect();return ce.width<=0||ce.height<=0?null:{left:ce.left-ae.right,right:ce.right-ae.right,height:ce.height}},D=X=>{const ee=(X.place??"ledge")==="floor",ae=ee?K()??Ya:Ya,ce=ee&&X.floorFrac!=null?-Math.round(X.floorFrac*ae):X.x;return Math.max(-ae,Math.min(0,ce))},V=()=>{if(!T)return;const X=D(T);X!==F&&(l(Math.max(0,P+O-Date.now())),x(ee=>Vp({...T,x:X},F,ee)),s(X),F=X)},J=()=>{M.schedule(()=>{const X=oH(F,Math.random,U()),ee=X.some(ge=>ge.place==="floor")?H():null;let ae=F;const ce=X.flatMap(ge=>{const ye=ae;if(ae=ge.x,!(ge.place==="floor"&&ge.act==="walk"))return[ge];const se=dH(ye,ge.x,ee),pe=se.length-1;return ge.floorFrac==null?se:se.map((fe,de)=>de===pe?{...fe,floorFrac:ge.floorFrac}:fe)});G(ce)},OW(Math.random))},W=(Y=S.current)==null?void 0:Y.parentElement,Z=typeof ResizeObserver>"u"?null:new ResizeObserver(V);return W&&Z&&Z.observe(W),J(),()=>{M.dispose(),Z==null||Z.disconnect(),j("ledge"),s(X=>Math.max(-Ya,Math.min(0,X))),l(0),d(null),f(null),b(0)}},[e,t,B]),y.useEffect(()=>{if(!n||B){A(null);return}const M=NS(document),F=T=>{const P=pH(T,Math.random);A(P.dance),$(P.beatMs),M.schedule(()=>F(P.dance),mH(Math.random))};return F(null),()=>M.dispose()},[n,B]),{scene:S,suspended:E,x:r,walkMs:o,act:c,prop:h,ballFlight:p,place:v,facing:k,riser:N,dance:I,beatMs:q}}const Kp={e:"fm-eye",s:"fm-shade",p:"fm-pad"},Md=mh().filter(e=>!TI.has(e.cell)),OH=mh().filter(e=>TI.has(e.cell)),jS=Md.filter(e=>e.cell==="e"),LH=mh(xH),PH=Md.filter(e=>e.y<eb&&e.cell!=="e").map(e=>{if(e.y!==8&&e.y!==9)return e;const t=Math.max(6,e.x);return{...e,x:t,w:Math.max(0,Math.min(12,e.x+e.w)-t)}}).filter(e=>e.w>0),DH={left:Md.filter(e=>e.y>=eb&&e.x<wS),right:Md.filter(e=>e.y>=eb&&e.x>=wS)},FH=y.memo(function({act:t,facing:n}){return a.jsxs("svg",{viewBox:`0 0 ${yS} ${gH}`,shapeRendering:"crispEdges","aria-hidden":!0,children:[a.jsx("g",{className:"fm-gear",children:a.jsx("g",{className:"fm-gear-motion",children:OH.map(r=>a.jsx("rect",{x:r.x,y:r.y,width:r.w,height:1,className:Kp[r.cell]},`g${r.y}-${r.x}`))})}),a.jsxs("g",{className:"fm-body",children:[jS.map(r=>a.jsx("rect",{x:r.x,y:r.y,width:r.w,height:1,fill:"var(--accent)"},`eye-bed-${r.x}`)),PH.map(r=>a.jsx("rect",{x:r.x,y:r.y,width:r.w,height:1,className:Kp[r.cell]},`b${r.y}-${r.x}`)),a.jsxs("g",{className:"fm-arms",children:[a.jsx("rect",{x:4,y:8,width:2,height:2}),a.jsx("rect",{x:12,y:8,width:1,height:2}),a.jsx("rect",{x:13,y:8,width:1,height:2,className:"fm-shade"})]}),jS.map(r=>a.jsx("rect",{x:r.x-(r.x>=yS/2?1:0)+(n==="right"?1:0),y:r.y,width:r.w,height:1,className:"fm-eye"},`eye-${r.x}`))]}),a.jsx("g",{className:"fm-hat",children:LH.map(r=>a.jsx("rect",{x:bH+r.x,y:kH+r.y,width:r.w,height:1,className:r.cell==="k"?"fm-hatband":void 0},`h${r.y}-${r.x}`))}),(t==="climb"||t==="rope-throw"||t==="rope-catch"||t==="pull-up")&&a.jsxs("g",{className:"fm-grip",children:[a.jsx("path",{className:"fm-grip-left",d:"M5 9H4V4H7V3H9V5H6V9Z"}),a.jsx("path",{className:"fm-grip-right",d:"M12 9H14V6H11V5H9V7H12Z"})]}),(t==="land"||t==="dismount")&&a.jsxs("g",{className:"fm-crouch-legs",children:[a.jsx("path",{d:"M6 11H8V13H6Z"}),a.jsx("path",{d:"M10 11H12V13H10Z"})]}),["sit","cast","fish","reel","stow"].includes(t)&&a.jsxs("g",{className:"fm-seated-legs",children:[a.jsx("path",{className:"fm-seated-far",d:"M10 10H12V11H11V14H8V13H9V11H10Z"}),a.jsx("path",{d:"M6 10H9V11H7V15H4V14H5V11H6Z"})]}),["left","right"].map(r=>a.jsx("g",{className:"fm-leg","data-side":r,children:DH[r].map(s=>a.jsx("rect",{x:s.x,y:s.y,width:s.w,height:1,className:Kp[s.cell]},`${r}${s.y}-${s.x}`))},r))]})}),BH={"claude-fm":"Claude FM","lofi-relax":"Lofi Girl relax/study","lofi-game":"Lofi Girl chill/game","lofi-vibe":"Lofi Girl vibe/chill","lofi-sleep":"Lofi Girl sleep/chill","radio-mix":"Radio Mix Live","best-of-nostalgia":"Best of Nostalgia Live","good-life-radio":"The Good Life Radio Live","cafe-music-bgm":"Cafe Music BGM Live"};function qH(e,t){return t&&to(t.id)===e?t.name:wi(e)?"Custom FM":BH[e]}function Yp(e,t){var r;const n=((r=e[0])==null?void 0:r.length)??0;return a.jsx("svg",{viewBox:`0 0 ${n} ${e.length}`,shapeRendering:"crispEdges","aria-hidden":!0,children:mh(e).map(s=>a.jsx("rect",{x:s.x,y:s.y,width:s.w,height:1,fill:s.cell==="s"?"var(--fm-prop-shadow, var(--bg))":s.cell==="l"?"var(--fm-prop-light, var(--text))":s.cell==="a"?"var(--accent)":void 0},`${t}${s.y}-${s.x}`))})}const SS={litter:Yp(Gp.litter,"litter"),ball:Yp(Gp.ball,"ball"),scope:Yp(Gp.scope,"scope")};function UH(e){try{return new URL(e).host}catch{return"the station's server"}}const zH=y.memo(function({fetchImpl:t,volume:n,muted:r=!1,source:s="claude-fm",playRequest:o=0,customStation:l,onAvailabilityChange:c}){const{probe:d,dead:h,armed:f,playing:p,frame:g,say:v,press:j}=$H({fetchImpl:t,volume:n,muted:r,source:s,playRequest:o,customStation:l,onAvailabilityChange:c}),{scene:k,suspended:x,x:N,walkMs:b,act:S,prop:E,ballFlight:R,place:I,facing:A,riser:q,dance:$,beatMs:B}=IH(d,h,p);if(!d||h)return null;const L=qH(s,l),M=d.audio?UH(d.audio):"YouTube";return a.jsxs("div",{ref:k,className:"fm","data-suspended":x?"":void 0,"data-place":I,style:{"--fm-beat":`${B}ms`},children:[E&&!E.held&&a.jsx("div",{className:"fm-prop","data-prop":E.kind,"data-leaving":E.leaving?"":void 0,style:{"--fm-prop-x":`${E.at}px`,"--fm-roll-to":`${R.x}px`,"--fm-ball-drop":`${R.drop}px`,"--fm-ball-flight-ms":`${jI}ms`,"--fm-ball-turn":A==="right"?"1080deg":"-1080deg"},children:SS[E.kind]}),(S==="lasso"||S==="rope-throw"||S==="rope-catch"||S==="climb"||S==="pull-up")&&a.jsxs("div",{className:"fm-rope","data-act":S,style:{"--fm-rope-x":`${N}px`,"--fm-rope-ms":`${b}ms`},children:[a.jsx("div",{className:"fm-rope-line"}),a.jsxs("svg",{className:"fm-rope-hook",viewBox:"0 0 9 9",shapeRendering:"crispEdges","aria-hidden":!0,children:[a.jsx("path",{d:"M4 8V3H3V1H1V3H0V5H2V4H3V6H5V4H6V5H8V3H7V1H5V3H4"}),a.jsx("rect",{className:"fm-rope-knot",x:"3",y:"6",width:"3",height:"2"})]})]}),a.jsxs("div",{className:"fm-walker","data-act":S??void 0,"data-place":I,"data-facing":A,style:{"--fm-x":`${N}px`,"--fm-walk-ms":`${b}ms`,"--fm-riser":`${q}px`,"--fm-skip-beat":`${SI}ms`},children:[(E==null?void 0:E.held)&&a.jsx("div",{className:"fm-held","data-prop":E.kind,"data-toss":E.leaving?"":void 0,children:SS[E.kind]}),["cast","fish","reel","stow"].includes(S)&&a.jsxs("svg",{className:"fm-fishing",viewBox:"0 0 24 32",shapeRendering:"crispEdges","aria-hidden":!0,children:[a.jsxs("g",{children:[a.jsx("path",{d:"M24 11H22V9H20V7H18V5H16V3H13V2H8"}),a.jsx("rect",{className:"fm-fishing-grip",x:"21",y:"9",width:"3",height:"3"})]}),a.jsxs("g",{className:"fm-fishing-line",children:[a.jsx("path",{d:"M8 2V26"}),a.jsxs("g",{className:"fm-float",children:[a.jsx("rect",{x:"7",y:"25",width:"3",height:"2"}),a.jsx("rect",{x:"8",y:"24",width:"1",height:"1"})]})]}),a.jsx("path",{className:"fm-ripple",d:"M3 28H6M10 28H14M5 30H12"})]}),["skip-ready","skip","skip-rest"].includes(S)&&a.jsxs("svg",{className:"fm-skipping-rope",viewBox:"0 0 26 26",shapeRendering:"crispEdges","aria-hidden":!0,children:[a.jsx("path",{className:"fm-skip-back",d:"M5 18H3V8H5V5H8V2H18V5H21V8H23V18H21"}),a.jsx("path",{className:"fm-skip-forward",d:"M5 18H3V14H5V11H8V9H18V11H21V14H23V18H21"}),a.jsx("path",{className:"fm-skip-front",d:"M5 18H3V21H5V23H8V25H18V23H21V21H23V18H21"}),a.jsx("path",{className:"fm-skip-return",d:"M5 18H3V19H8V20H18V19H23V18H21"}),a.jsx("path",{className:"fm-skip-handles",d:"M5 17V19M21 17V19"})]}),a.jsx("button",{type:"button",className:"fm-sprite","data-playing":p?"":void 0,"data-dance":p?$??_I[0]:void 0,onClick:j,title:p?`Stop ${L}`:`Play ${L} — streams from ${M}`,"aria-label":p?`Stop ${L}`:`Play ${L}`,children:a.jsx(FH,{act:S,facing:A})})]}),f&&!d.audio&&(d.channel||d.video)&&a.jsx("iframe",{ref:g,className:"fm-frame",title:L,src:NH(d.channel,window.location.origin,d.video),onLoad:()=>v(jH()),allow:"autoplay; encrypted-media",sandbox:"allow-scripts allow-same-origin allow-presentation"})]})});function AI(e){const t=Math.max(0,e);return t<60?"just now":t<3600?`${Math.floor(t/60)}m ago`:t<86400?`${Math.floor(t/3600)}h ago`:`${Math.floor(t/86400)}d ago`}function $d(e){return AI(Math.floor(e/1e3))}function gh(e,t){const n=e-t;if(n<=0)return null;const r=Math.floor(n/86400),s=Math.floor(n%86400/3600),o=Math.floor(n%3600/60);return r>0?`${r}d ${s}h`:s>0?`${s}h ${o}m`:`${o}m`}function WH(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function Id(e,t,n){const r=new Date(e),s=$d(t-e);return{label:WH(r,new Date(t))?s:`${s} · ${r.toLocaleDateString(n,{month:"short",day:"numeric"})}`,title:r.toLocaleString(n,{dateStyle:"medium",timeStyle:"medium"})}}function HH({data:e}){const t=Ii(3e4),n=e.note,r=n.kind==="recap",s=Id(n.at,t),o=r?"recap-note":`recap-note is-status status-${n.kind}`,l=r?void 0:fh(n);return a.jsxs("div",{className:o,role:"note","aria-label":r?"Claude Code's recap":`Session note: ${sa(n.kind)}`,"aria-description":l,style:{"--session-hue":e.hue},children:[a.jsxs("div",{className:"recap-note-head",title:l,children:[a.jsxs("span",{className:"recap-note-mark",children:[a.jsx(Ad,{recap:r}),sa(n.kind)]}),a.jsx("span",{className:"recap-note-age",title:s.title,children:s.label}),a.jsx("button",{type:"button",className:"glyph-btn recap-note-close","aria-label":r?"Hide the recap":"Hide this note",title:"Hide — the mark on the card brings it back",onClick:c=>{c.stopPropagation(),_z(e.noteKey)},children:"×"})]}),a.jsx("p",{className:"recap-note-text",title:Pz(n.text,l),children:n.text}),n.reply&&a.jsxs("p",{className:"recap-note-reply",title:`suggested reply “${n.reply}”`,children:["suggested reply “",n.reply,"”"]}),a.jsxs("div",{className:"lod-face recap-face","aria-hidden":!0,children:[a.jsxs("div",{className:"lod-id",children:[a.jsxs("span",{className:"recap-note-mark",children:[a.jsx(Ad,{recap:r}),sa(n.kind)]}),a.jsx("span",{className:"recap-face-age",children:s.label})]}),a.jsx("p",{className:"recap-face-text",children:n.text})]}),a.jsx(eo,{type:"source",position:Ae.Right,style:{background:"transparent",border:"none"}})]})}function VH({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:s,targetPosition:o,style:l}){const[c]=ak({sourceX:e,sourceY:t,sourcePosition:s,targetX:n,targetY:r,targetPosition:o,curvature:.35});return a.jsxs("g",{className:"recap-tie",style:l,children:[a.jsx("path",{className:"recap-tie-thread",d:c}),a.jsx("path",{className:"recap-tie-beads",d:c}),a.jsx("circle",{className:"recap-tie-end",cx:e,cy:t,r:3.5}),a.jsx("circle",{className:"recap-tie-end",cx:n,cy:r,r:3.5})]})}function nb(e){return e.replace(/[^a-zA-Z0-9]/g,"")}function Ek(e,t){const n=nb(e);return n?n.slice(-t):e.slice(-t)}function RI(e,t,n=4){const r=nb(e);if(!r)return Ek(e,n);let s=n;for(const o of t){if(o===e)continue;const l=nb(o);let c=0;for(;c<r.length&&c<l.length&&r[r.length-1-c]===l[l.length-1-c];)c++;s=Math.max(s,c+1)}return r.slice(-s)}const Bl=" · ",GH=32,KH=/[\u1100-\u115F\u2E80-\u303E\u3041-\u33FF\u3400-\u4DBF\u4E00-\u9FFF\uA000-\uA4CF\uAC00-\uD7A3\uF900-\uFAFF\uFE30-\uFE6F\uFF00-\uFF60\uFFE0-\uFFE6]/;function _S(e){return KH.test(e)?2:1}function ES(e,t=GH){const n=[...e];let r=0;for(const l of n)r+=_S(l);if(r<=t)return e;const s=[];let o=0;for(const l of n){const c=_S(l);if(o+c>t-1)break;s.push(l),o+=c}for(;s.length&&/[\s\-_.:/]/.test(s[s.length-1]);)s.pop();return`${s.join("")}…`}function YH(e,t,n,r,s=[],{branch:o,alarm:l=!1}={}){const c=(t==null?void 0:t.trim())??"",d=r?RI(n,s):void 0,h=[e,c||void 0,d].filter(Boolean),f=[e,o,c||void 0,d].filter(Boolean).join(Bl);return{label:ES(e),name:c?ES(c):void 0,shortId:d,fullLabel:h.join(Bl),title:`${l?"waiting on you: ":""}${f}
82
- Zoom to this session
83
- drag the wrapper to move the whole session`}}const Ha=18,rb=26,Ck=12,XH=240,MI=16;function $I(e,t){return(e+XH)*(t||1)}function ZH(e,t){return{position:"absolute",left:0,top:0,transform:`translate(${e.x}px, ${e.y}px)`,width:e.w,height:e.h,"--session-hue":t}}function JH(e,t,n,r){return{position:"absolute",left:e.x+MI,top:e.y-Ck/(t||1),transform:`scale(${1/(t||1)})`,transformOrigin:"left top",maxWidth:r??$I(e.w,t),"--session-hue":n}}function QH(e){const t=new Map;for(const s of e){if(s.type!=="agent"&&s.type!=="recapNote")continue;const o=s.data;if(!(o!=null&&o.sessionId)||o.exitAt!=null||s.width==null||s.height==null)continue;const l=s.position.x,c=s.position.y,d=l+s.width,h=c+s.height,f=t.get(o.sessionId),p=e7(o);f?(f.minX=Math.min(f.minX,l),f.minY=Math.min(f.minY,c),f.maxX=Math.max(f.maxX,d),f.maxY=Math.max(f.maxY,h),p&&(f.label=p.label??f.label,f.name=p.name,f.alarm=p.alarm,f.branch=p.branch)):t.set(o.sessionId,{minX:l,minY:c,maxX:d,maxY:h,label:(p==null?void 0:p.label)??o.sessionId,name:p==null?void 0:p.name,alarm:(p==null?void 0:p.alarm)??!1,branch:p==null?void 0:p.branch})}const n=new Map;for(const[s,o]of t){const l=n.get(o.label);l?l.push(s):n.set(o.label,[s])}const r=[];for(const[s,o]of t){const l=n.get(o.label)??[],c=l.length>1;r.push({sessionId:s,...YH(o.label,o.name,s,c,l,{branch:o.branch,alarm:o.alarm}),x:o.minX-Ha,y:o.minY-Ha-rb,w:o.maxX-o.minX+Ha*2,h:o.maxY-o.minY+Ha*2+rb,...o.alarm?{alarm:!0}:null,...o.branch?{branch:o.branch}:null})}return r}function e7(e){if(e.kind!=="root")return null;const t=e.branch;return{label:e.label,name:xk(e.sessionName,e.sessionTitle).face,alarm:En(e.waiting),branch:t&&t.total>0?pI(t):void 0}}function t7(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){const r=e[n],s=t[n];if(r.sessionId!==s.sessionId||r.label!==s.label||r.name!==s.name||r.shortId!==s.shortId||r.alarm!==s.alarm||r.branch!==s.branch||r.fullLabel!==s.fullLabel||r.title!==s.title||r.x!==s.x||r.y!==s.y||r.w!==s.w||r.h!==s.h)return!1}return!0}const n7=20,hs=4,r7=64,s7=".cat-filter-bar, .react-flow__panel, .autofit-chip, .usage-panel, .sysdetail, .detail";function a7(e,t,n,r){const s=t.zoom||1,o=$I(e.w,s);if(n.width<=0||n.height<=0)return{maxWidth:o,hidden:!1};const l=(e.x+MI)*s+t.x,c=e.y*s+t.y-Ck,d=c+n7;let h=Math.min(o,n.width-hs-l),f=l<hs||c<hs||d>n.height-hs;for(const p of r)if(!(p.top-hs>=d||p.bottom+hs<=c)&&!(p.right+hs<=l)){if(p.left-hs<=l){f=!0;break}h=Math.min(h,p.left-hs-l)}return h<r7&&(f=!0),{maxWidth:Math.max(0,h),hidden:f}}function o7(e){const t=e.getBoundingClientRect(),n=[];for(const r of e.ownerDocument.querySelectorAll(s7)){const s=r.getBoundingClientRect(),o=Math.max(s.left,t.left)-t.left,l=Math.max(s.top,t.top)-t.top,c=Math.min(s.right,t.right)-t.left,d=Math.min(s.bottom,t.bottom)-t.top;c-o<1||d-l<1||n.push({left:Math.round(o),top:Math.round(l),right:Math.round(c),bottom:Math.round(d)})}return n}function i7(e,t){return e.length===t.length&&e.every((n,r)=>{const s=t[r];return n.left===s.left&&n.top===s.top&&n.right===s.right&&n.bottom===s.bottom})}const l7=500;function II({focus:e,setTimeout:t,clearTimeout:n,ms:r=l7}){let s=null;const o=()=>{s!==null&&(n(s),s=null)};return{hold(l){o(),s=t(()=>{s=null;try{e(l)}catch{}},r)},cancel:o}}function c7(e){return QH(e.nodeInternals.values())}const u7=e=>e.width,d7=e=>e.height,h7=e=>{var t;return((t=e.domNode)==null?void 0:t.querySelector(".react-flow__viewport"))??null};function f7({onFocusSession:e}){const{x:t,y:n,zoom:r}=m$(),s=He(c7,t7),o=He(u7),l=He(d7),c={width:o,height:l},d=y.useRef(null),h=He(h7),[f,p]=y.useState([]);y.useLayoutEffect(()=>{var R;const S=(R=d.current)==null?void 0:R.parentElement;if(!S)return;const E=o7(S);p(I=>i7(I,E)?I:E)});const g=y.useRef(e);g.current=e;const[v]=y.useState(()=>II({focus:S=>{var E;return(E=g.current)==null?void 0:E.call(g,S)},setTimeout:(S,E)=>window.setTimeout(S,E),clearTimeout:S=>window.clearTimeout(S)}));if(y.useEffect(()=>()=>v.cancel(),[v]),s.length<=1)return null;const j=S=>{try{e==null||e(S)}catch{}},k=(S,E)=>{S.detail>0&&fk()?v.hold(E):j(E)},x={transform:`translate(${t}px, ${n}px) scale(${r})`},N=a.jsx("div",{className:"session-clusters",style:x,ref:d,children:s.map(S=>{const E=tc(S.sessionId),R=ZH(S,E);return a.jsx("div",{className:"cluster-card",style:R,"aria-hidden":!0},S.sessionId)})}),b=h&&Pt.createPortal(a.jsx("div",{className:"cluster-labels nopan",children:s.map(S=>{const E=tc(S.sessionId),R=a7(S,{x:t,y:n,zoom:r},c,f),I=JH(S,r,E,R.maxWidth);return a.jsxs("button",{type:"button",className:"cluster-label","data-alarm":S.alarm?"":void 0,"data-offpane":R.hidden?"":void 0,style:I,title:S.title,onClick:A=>k(A,S.sessionId),children:[S.alarm?a.jsxs(a.Fragment,{children:[a.jsx(Sk,{}),a.jsx("span",{className:"cluster-label-said",children:"waiting on you: "})]}):null,S.label,S.branch?a.jsx("span",{className:"cluster-label-branch",children:Bl+S.branch}):null,S.name?a.jsx("span",{className:"cluster-label-name",children:Bl+S.name}):null,S.shortId?a.jsx("span",{className:"cluster-label-id",children:Bl+S.shortId}):null]},S.sessionId)})}),h);return a.jsxs(a.Fragment,{children:[N,b]})}function p7({data:e}){return a.jsx("div",{className:"session-group-handle",style:{width:(e==null?void 0:e.w)??0,height:(e==null?void 0:e.h)??0}})}const OI=600,m7=4,g7=36,sb=16,y7=60,w7=6,CS=220,v7=96,x7=28;function b7(e,t){return Math.max(v7,61+[...t].length*6.8)}function k7(e){return e.endedAt==null?"inflight":e.ok===!1?"err":"done"}function N7(e,t){if(t==null)return 1;const n=e-t;return n<0?1:Math.max(0,1-n/OI)}function j7(e,t){const n=[],r=new Set;for(let s=e.length-1;s>=0&&n.length<t;s--){const o=e[s];r.has(o.id)||(r.add(o.id),n.push(o))}return n.reverse()}function S7(e,t,n,r,s,o){const l=[];for(const c of e.values()){if(!t.has(c.id)||c.exitAt!=null&&o-c.exitAt>OI)continue;const d=r.get(c.id)??n.get(c.id);if(!d)continue;const h=j7(c.tools,m7);if(h.length===0)continue;const f=c.exitAt??null,p=s.get(c.id),g=Math.max((p==null?void 0:p.width)??CS,CS),v=(p==null?void 0:p.height)??130,j=d.x,k=d.y,x=j+g,N=k+v/2;h.forEach((b,S)=>{const E=S*g7,R=j+g+y7,I=k+w7+E,A=N7(o,f),q=b.inputPreview??"",$=k7(b),B=A<.999,L=jk(b.name);l.push({id:`${c.id}::${b.id}`,toolId:b.id,agentId:c.id,toolName:b.name,name:L.label,emoji:L.emoji,status:$,category:mI(b.name),mcpHue:L.hue,inputPreview:q,fade:A,fading:B,worldX:R,worldY:I,anchorX:x,anchorY:N,spawnDx:x-R,spawnDy:N-(I+sb)});const M=vI(b.name,b.input);if(M){const F=b7(b.name,L.label),T=R+F+x7,P=I,O=R+F,G=I+sb;l.push({id:`sub:${c.id}::${b.id}`,toolId:b.id,agentId:c.id,toolName:b.name,name:dW(M.label,M.category),fullName:M.label,emoji:M.emoji,isSub:!0,status:$,category:M.category,inputPreview:M.detail??q,fade:A,fading:B,worldX:T,worldY:P,anchorX:O,anchorY:G,spawnDx:O-T,spawnDy:0})}})}return l}function _7({agents:e,visibleAgentIds:t,positions:n,pinned:r,measured:s,spotlight:o,hiddenCategories:l,now:c,onOpenTool:d}){const h=S7(e,t,n,r,s,c),f=l&&l.size>0?h.filter(p=>!l.has(p.category)):h;return a.jsx(E7,{bursts:f,spotlight:o,onOpenTool:d})}function E7({bursts:e,spotlight:t,onOpenTool:n}){const r=e.map(o=>{const l=o.anchorX,c=o.anchorY,d=o.worldX+6,h=o.worldY+sb,f=Math.max(1,d-l),p=Math.min(1,Math.abs(h-c)/f),g=l+f*(.55-.22*p),v=t!=null&&!t.has(o.agentId),j=o.fade*(v?.14:1);return a.jsx("path",{d:`M ${l} ${c} Q ${g} ${c}, ${d} ${h}`,className:`tool-conn status-${o.status}${o.fading?" fading":""}`,opacity:j,vectorEffect:"non-scaling-stroke"},`l:${o.id}`)}),s=e.map(o=>a.jsx(A7,{b:o,dim:t!=null&&!t.has(o.agentId),onOpenTool:n},o.id));return a.jsx(C7,{connectors:r,bubbles:s})}function C7({connectors:e,bubbles:t}){const{x:n,y:r,zoom:s}=m$();return a.jsxs("div",{className:"tool-bursts-layer","aria-hidden":!0,children:[a.jsx("svg",{className:"tool-bursts-svg",children:a.jsx("g",{transform:`translate(${n} ${r}) scale(${s})`,children:e})}),a.jsx("div",{className:"tool-bursts-world",style:{transform:`translate(${n}px, ${r}px) scale(${s})`},children:t})]})}function T7(e,t){const n=e.b,r=t.b;return e.dim===t.dim&&e.onOpenTool===t.onOpenTool&&n.id===r.id&&n.toolId===r.toolId&&n.worldX===r.worldX&&n.worldY===r.worldY&&n.spawnDx===r.spawnDx&&n.spawnDy===r.spawnDy&&n.status===r.status&&n.fading===r.fading&&n.category===r.category&&n.mcpHue===r.mcpHue&&n.isSub===r.isSub&&n.emoji===r.emoji&&n.name===r.name&&n.fullName===r.fullName&&n.toolName===r.toolName&&n.inputPreview===r.inputPreview}const A7=y.memo(function({b:t,dim:n,onOpenTool:r}){const s={left:`${t.worldX}px`,top:`${t.worldY}px`,"--spawn-dx":`${t.spawnDx}px`,"--spawn-dy":`${t.spawnDy}px`},o=t.isSub?`${t.toolName} · ${t.fullName??t.name}`:t.toolName,l=t.inputPreview?`${o} · ${t.inputPreview}`:o,c=r!=null,d=t.mcpHue!=null?{"--mcp-hue":t.mcpHue}:{},h=n?" dim":"";return a.jsx("div",{className:"tool-burst-wrap",style:s,children:a.jsxs("div",{className:`tool-burst cat-${t.category}${t.mcpHue!=null?" mcp-hue":""} status-${t.status}${t.fading?" fading":""}${c?" clickable":""}${t.isSub?" sub":""}${h}`,style:d,title:l,onClick:c?()=>r(t.agentId,t.toolId):void 0,children:[a.jsx("span",{className:"tb-emoji",children:t.emoji}),a.jsx("span",{className:"tb-name",children:t.name}),t.status==="inflight"&&a.jsx("span",{className:"tb-spin"}),t.status==="done"&&a.jsx("span",{className:"tb-mark done",children:"✓"}),t.status==="err"&&a.jsx("span",{className:"tb-mark err",children:"×"})]})})},T7),R7={agent:yW,sessionGroup:p7,recapNote:HH},M7={recapTie:VH},TS=400;function $7({graph:e,layout:t,viewport:n,clicks:r,drag:s,appearance:o,fm:l,autoFit:c,pause:d,stateRef:h,measuredRef:f,hiddenCats:p,now:g,openTool:v,focusAgent:j,requestClear:k,setKeyHelpOpen:x}){const{allNodes:N,edges:b,visibleAgentIds:S,spotlightSet:E}=e,{positionsRef:R,pinnedRef:I,handleRelayout:A}=t,{restoredViewport:q,onMoveStart:$,onMove:B}=n,{onNodeClick:L,onPaneClick:M,onNodeDoubleClick:F,onNodeMouseEnter:T,onNodeMouseLeave:P}=r,{onNodeDragStart:O,onNodeDrag:G,onNodeDragStop:K}=s,{palette:U,minimapNodeFill:H,characterEnabled:D}=o,{fmVolume:V,fmMuted:J,fmSource:W,fmPlayRequest:Z,customFmStations:Y,markFmStationAvailability:X}=l,{autoFitDisabled:ee,enableAutoFitAndRefit:ae}=c,{paused:ce,pauseGate:ge,togglePause:ye}=d;return a.jsxs(p$,{nodes:N,edges:b,nodeTypes:R7,edgesFocusable:!1,edgeTypes:M7,fitView:!q,fitViewOptions:{padding:.25,duration:Kx({durationMs:TS,documentHidden:document.hidden})?TS:0},minZoom:b$,maxZoom:k$,panOnScroll:!0,panActivationKeyCode:null,nodesDraggable:!0,nodesConnectable:!1,selectionOnDrag:!1,nodeDragThreshold:5,disableKeyboardA11y:!0,deleteKeyCode:null,onNodeClick:L,onPaneClick:M,onNodeDoubleClick:F,onNodeMouseEnter:T,onNodeMouseLeave:P,onMoveStart:$,onMove:B,onNodeDragStart:O,onNodeDrag:G,onNodeDragStop:K,children:[a.jsx(X8,{gap:28,size:1,color:U["--grid-line"]}),a.jsx(f7,{onFocusSession:j}),a.jsx(_7,{agents:h.current.agents,visibleAgentIds:S,positions:R.current,pinned:I.current,measured:f.current,spotlight:E,hiddenCategories:p,now:g,onOpenTool:v}),ee&&a.jsx(NW,{enableAutoFitAndRefit:ae}),a.jsx(MW,{autoFitDisabled:ee,enableAutoFitAndRefit:ae,paused:ce,pauseGate:ge,togglePause:ye,handleRelayout:A,requestClear:k,setKeyHelpOpen:x}),a.jsx(P8,{zoomable:!0,pannable:!0,nodeColor:H,nodeStrokeWidth:2,maskColor:U["--minimap-mask"],maskStrokeColor:U["--line"]}),D&&a.jsx(zH,{volume:V,muted:J,source:W,playRequest:Z,customStation:Y.find(se=>to(se.id)===W),onAvailabilityChange:X})]})}function I7(e){const t={input:0,output:0,cacheRead:0,cacheWrite:0,total:0};let n=0,r=0,s=0,o=0;for(const l of e){const c=gn(l);t.input+=c.input,t.output+=c.output,t.cacheRead+=c.cacheRead,t.cacheWrite+=c.cacheWrite,t.total+=c.total,n+=l.usage.inputTokens,r+=l.usage.outputTokens,s+=l.usage.cacheReadTokens,o+=l.usage.cacheCreateTokens}return{cost:t,inputTokens:n,outputTokens:r,cacheReadTokens:s,cacheCreateTokens:o,sum:n+r}}const O7="spend on this board",L7="on this board",AS=`Everything on the board right now, and only that.
84
- Finished sessions are evicted from the canvas a couple of minutes after they end, and their tokens and dollars leave with them — so this figure falls on its own.
85
- Press H for the totals ccusage reads off the logs on disk, which do not forget.`,LI="session spend",ab="__unknown__",P7=12;function D7(e,t=Date.now()){const n=new Map;for(const r of e)for(const s of vc(r)){const o=s.model??ab,l=ih(s.usage,s.model,t),c=n.get(o);c?(c.inputTokens+=s.usage.inputTokens,c.outputTokens+=s.usage.outputTokens,c.cacheReadTokens+=s.usage.cacheReadTokens,c.cacheCreateTokens+=s.usage.cacheCreateTokens,c.cost.total+=l.total,c.cost.input+=l.input,c.cost.output+=l.output,c.cost.cacheRead+=l.cacheRead,c.cost.cacheWrite+=l.cacheWrite,c.agentCount++):n.set(o,{model:o,inputTokens:s.usage.inputTokens,outputTokens:s.usage.outputTokens,cacheReadTokens:s.usage.cacheReadTokens,cacheCreateTokens:s.usage.cacheCreateTokens,cost:{...l},agentCount:1,priced:la(s.model,t)!=null})}return Array.from(n.values()).sort((r,s)=>s.cost.total-r.cost.total||s.inputTokens+s.outputTokens-(r.inputTokens+r.outputTokens))}function F7(e,t=Date.now()){const n=[...e],r=[];for(const s of n){if(s.kind!=="root")continue;let o=gn(s,t).total,l=s.usage.inputTokens,c=s.usage.outputTokens,d=nc(s,t);for(const h of n)h.sessionId!==s.sessionId||h.kind==="root"||(o+=gn(h,t).total,l+=h.usage.inputTokens,c+=h.usage.outputTokens,d+=nc(h,t));r.push({sessionId:s.sessionId,label:s.label||s.cwdBasename||"session",state:s.state,cost:o,inputTokens:l,outputTokens:c,unpricedTokens:d})}return r.sort((s,o)=>o.cost-s.cost||o.inputTokens+o.outputTokens-(s.inputTokens+s.outputTokens)).slice(0,P7)}const B7=600;function yh(e,t){return!(e.exitAt!=null&&t-e.exitAt>B7||e.kind==="root"&&e.state==="done"&&e.tools.length===0&&e.endedAt!=null&&e.endedAt-e.startedAt<3e3)}function q7(e,t){const n=new Set;for(const r of e.agents.values())yh(r,t)&&n.add(r.id);return n}function U7(e,t,n=0){return e.right+n>t.left&&e.left-n<t.right&&e.bottom+n>t.top&&e.top-n<t.bottom}function z7(e,t,n=0){if(!e)return!1;for(const r of t)if(U7(e,r,n))return!0;return!1}function RS(e){return e.waiting?En(e.waiting)?0:1:e.state==="active"?2:3}function W7(e,t){const n=[];for(const r of e.agents.values()){if(r.kind!=="root")continue;let s=r.toolCount,o=gn(r).total,l=r.endedAt??r.startedAt;for(const f of e.agents.values()){if(f.sessionId!==r.sessionId||f.kind==="root")continue;s+=f.toolCount,o+=gn(f).total;const p=f.endedAt??f.startedAt;p>l&&(l=p)}const c=hh(r),d=(c==null?void 0:c.kind)==="recap"?{text:c.text,at:c.at}:null,h=c&&c.kind!=="recap"?c:null;n.push({sessionId:r.sessionId,label:r.label||r.cwdBasename||"session",cwdBasename:r.cwdBasename,state:r.state,waiting:r.waiting,recap:d,status:h,modelId:r.model,toolCount:s,cost:o,startedAt:r.startedAt,lastActivity:l})}return n.sort((r,s)=>{const o=RS(r),l=RS(s);return o!==l?o-l:r.waiting&&s.waiting?r.waiting.since-s.waiting.since:s.lastActivity-r.lastActivity}),n}function H7(e){return[e.text,e.reply?`Suggested reply: ${e.reply}`:"",fh(e)].filter(Boolean).join(`
86
- `)}function MS(e,t,n){const r=(t??n)-e;if(r<1e3)return"<1s";const s=Math.floor(r/1e3);if(s<60)return`${s}s`;const o=Math.floor(s/60);return o<60?`${o}m`:`${Math.floor(o/60)}h ${o%60}m`}function V7({state:e,now:t,selectedIds:n,onSelect:r,onClose:s,removedIds:o,onBringBackAll:l}){const c=y.useMemo(()=>W7(e),[e,e.revision,t]),d=c.filter(f=>f.state==="active").length,h=c.filter(f=>En(f.waiting)).length;return a.jsxs("aside",{className:"session-list",id:"session-list","aria-label":"Sessions",children:[a.jsxs("div",{className:"sl-header",children:[a.jsxs("h2",{children:["Sessions ",a.jsx("span",{className:"sl-count",children:c.length})]}),h>0&&a.jsxs("span",{className:"sl-waiting-count",children:[h," waiting"]}),d>0&&a.jsxs("span",{className:"sl-live-count",children:[d," live"]}),a.jsx("button",{className:"glyph-btn sl-close",onClick:s,title:"Hide sidebar (L)","aria-label":"Hide session list",children:"‹"})]}),a.jsxs("ul",{className:"sl-rows",children:[c.length===0&&a.jsx("li",{className:"sl-empty",children:"No sessions yet."}),c.map(f=>{var v;const p=n.has(f.sessionId),g=(o==null?void 0:o.has(f.sessionId))??!1;return a.jsx("li",{className:"sl-row-item",children:a.jsxs("button",{type:"button",className:`sl-row state-${f.state}${p?" selected":""}${g?" removed":""}`,"aria-current":p?"true":void 0,onClick:()=>r(f.sessionId),title:g?`Bring ${f.label} back to the board`:`Focus ${f.label}`,children:[a.jsx("span",{className:`sl-dot state-${f.state}`,"aria-hidden":!0}),a.jsx("span",{className:"vis-hidden",children:xi(f.state)}),a.jsxs("div",{className:"sl-row-body",children:[a.jsxs("div",{className:"sl-row-head",children:[a.jsx("span",{className:"sl-label",children:f.label}),g&&a.jsx("span",{className:"sl-removed",children:"off the board"}),f.modelId&&a.jsx("span",{className:"model-chip","data-family":ch(f.modelId),title:f.modelId,children:ks(f.modelId)})]}),a.jsxs("div",{className:"sl-row-meta",children:[a.jsxs("span",{title:"tool calls",children:[a.jsx("b",{children:f.toolCount})," ",f.toolCount===1?"tool":"tools"]}),f.cost>0&&a.jsx("span",{className:"sl-cost",title:LI,children:a.jsx("b",{children:We(f.cost)})}),f.waiting?a.jsxs("span",{className:"sl-waiting",title:[bi(f.waiting),VU(f.waiting,bi(f.waiting)),`${En(f.waiting)?"Blocked":"Your turn"} since ${new Date(f.waiting.since).toLocaleTimeString()} · started ${new Date(f.startedAt).toLocaleString()}`].filter(Boolean).join(`
87
- `),children:[En(f.waiting)?"waiting":"your turn"," ",MS(f.waiting.since,void 0,t),f.waiting.tool&&a.jsxs("span",{className:"sl-waiting-tool",children:[" · ",f.waiting.tool.name]})]}):a.jsx("span",{className:"sl-elapsed",title:`Started ${new Date(f.startedAt).toLocaleString()}`,children:MS(f.startedAt,f.state==="active"?void 0:f.lastActivity,t)})]}),f.recap&&a.jsxs("span",{className:"sl-recap",title:f.recap.text,children:[a.jsx(bI,{}),f.recap.text]}),f.status&&a.jsxs("span",{className:`sl-status status-${f.status.kind}`,title:H7(f.status),children:[a.jsx("span",{className:"sl-status-tag",children:sa(f.status.kind)})," ",f.status.text]}),((v=f.status)==null?void 0:v.reply)&&a.jsxs("span",{className:"sl-status-reply",title:`suggested reply “${f.status.reply}”`,children:["suggested reply “",f.status.reply,"”"]})]})]})},f.sessionId)})]}),(()=>{let f=0;for(const p of o??[]){const g=e.agents.get(p);g&&yh(g,t)&&f++}return f===0||!l?null:a.jsx("div",{className:"sl-foot",children:a.jsxs("button",{type:"button",className:"btn sl-bring-back",onClick:p=>{const g=p.currentTarget.closest(".session-list");l(),requestAnimationFrame(()=>{var v;return(v=g==null?void 0:g.querySelector(".sl-row"))==null?void 0:v.focus()})},children:["Bring back ",f," removed ",f===1?"card":"cards"]})})})()]})}const ob={cost:0,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0,sessions:0};function G7(e){if(!e.synthetic)return!1;const t=e.usage;return t.inputTokens+t.outputTokens+t.cacheReadTokens+t.cacheCreateTokens<=0}function ib(e,t){const n=new Map;for(const r of e){if(r.kind!=="root"||!r.sessionId||G7(r))continue;const s=gn(r,t);n.set(r.sessionId,{cost:s.total,inputTokens:r.usage.inputTokens,outputTokens:r.usage.outputTokens,cacheReadTokens:r.usage.cacheReadTokens,cacheCreateTokens:r.usage.cacheCreateTokens})}return n}function K7(e,t){if(!e)return ob;const n={...ob};for(const[r,s]of t){const o=e.get(r);if(!o)continue;const l={cost:s.cost-o.cost,inputTokens:s.inputTokens-o.inputTokens,outputTokens:s.outputTokens-o.outputTokens,cacheReadTokens:s.cacheReadTokens-o.cacheReadTokens,cacheCreateTokens:s.cacheCreateTokens-o.cacheCreateTokens};l.cost<0||l.inputTokens<0||l.outputTokens<0||l.cost===0&&l.inputTokens===0&&l.outputTokens===0&&l.cacheReadTokens===0&&l.cacheCreateTokens===0||(n.cost+=l.cost,n.inputTokens+=Math.max(0,l.inputTokens),n.outputTokens+=Math.max(0,l.outputTokens),n.cacheReadTokens+=Math.max(0,l.cacheReadTokens),n.cacheCreateTokens+=Math.max(0,l.cacheCreateTokens),n.sessions+=1)}return n}function lb(e,t=new Date){return new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate()-(e-1))).toISOString().slice(0,10).replace(/-/g,"")}const wh=[{key:"today",label:"today",noun:"today",hint:"Since midnight, on this machine's clock."},{key:"month",label:"month",noun:"this month",hint:"Since the 1st of this calendar month — not the last 30 days."},{key:"all",label:"all",noun:"all time",hint:"Every transcript on disk, back to 2020."}];function Y7(e,t,n=wh.length){return n<=0?null:e==="ArrowRight"||e==="ArrowDown"?(t+1)%n:e==="ArrowLeft"||e==="ArrowUp"?(t-1+n)%n:e==="Home"?0:e==="End"?n-1:null}function PI(e,t=new Date){return e==="today"?lb(1,t):e==="month"?lb(t.getDate(),t):"20200101"}const fn=e=>typeof e=="number"&&Number.isFinite(e)?e:0,hd=e=>typeof e=="string"?e:"";function DI(e){const t=Array.isArray(e==null?void 0:e.days)?e.days:[],n=new Map;for(const r of t){const s=Array.isArray(r==null?void 0:r.modelBreakdowns)?r.modelBreakdowns:[];for(const o of s){const l=hd(o==null?void 0:o.modelName);if(!l)continue;let c=n.get(l);c||(c={model:l,cost:0,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0,get tokens(){return this.inputTokens+this.outputTokens+this.cacheReadTokens+this.cacheCreateTokens}},n.set(l,c)),c.cost+=fn(o==null?void 0:o.cost),c.inputTokens+=fn(o==null?void 0:o.inputTokens),c.outputTokens+=fn(o==null?void 0:o.outputTokens),c.cacheReadTokens+=fn(o==null?void 0:o.cacheReadTokens),c.cacheCreateTokens+=fn(o==null?void 0:o.cacheCreationTokens)}}return[...n.values()].sort((r,s)=>s.cost-r.cost||s.tokens-r.tokens)}const X7=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Z7(e){var t;return((t=X7.exec(e))==null?void 0:t[0])??e}function J7(e,t=new Map){const n=Array.isArray(e==null?void 0:e.sessions)?e.sessions:[],r=[];for(const s of n){const o=hd(s==null?void 0:s.period);if(!o)continue;const l=Z7(o),c=s==null?void 0:s.metadata,d=typeof(c==null?void 0:c.lastActivity)=="string"?Date.parse(c.lastActivity):NaN;r.push({sessionId:l,label:t.get(l)??null,agent:hd(s==null?void 0:s.agent)||"claude",cost:fn(s==null?void 0:s.totalCost),tokens:fn(s==null?void 0:s.totalTokens),models:Array.isArray(s==null?void 0:s.modelsUsed)?s.modelsUsed.map(hd).filter(Boolean):[],lastActivityMs:Number.isFinite(d)?d:null})}return r.sort((s,o)=>o.cost-s.cost||o.tokens-s.tokens)}function Q7(e,t=vh(e).cost){const r=(Array.isArray(e==null?void 0:e.sessions)?e.sessions:[]).reduce((o,l)=>o+fn(l==null?void 0:l.totalCost),0),s=Math.max(.01,t*.01);return{sum:r,total:t,over:r>t+s}}function e9(e,t,n){const r=`Sessions with activity ${e}, and what ccusage puts against each one.`;return t.over?`${r}
88
- They add up to ${n(t.sum)}, more than the ${n(t.total)} above: what a session cost and what a day cost are two different measurements, and they need not agree.`:r}function vh(e){const t=e==null?void 0:e.totals;if(t&&typeof t=="object"){const d=fn(t.cacheReadTokens),h=fn(t.cacheCreationTokens),f=fn(t.inputTokens),p=fn(t.outputTokens);return{cost:fn(t.totalCost),inputTokens:f,outputTokens:p,cacheReadTokens:d,cacheCreateTokens:h,tokens:fn(t.totalTokens)||f+p+d+h}}const n=DI(e),r=d=>n.reduce((h,f)=>h+d(f),0),s=r(d=>d.inputTokens),o=r(d=>d.outputTokens),l=r(d=>d.cacheReadTokens),c=r(d=>d.cacheCreateTokens);return{cost:r(d=>d.cost),inputTokens:s,outputTokens:o,cacheReadTokens:l,cacheCreateTokens:c,tokens:s+o+l+c}}function t9(e,t){return{data:(e==null?void 0:e.data)??null,shown:(e==null?void 0:e.period)??null,stale:e!=null&&e.period!==t,baseline:(e==null?void 0:e.baseline)??null}}function FI(e,t){var n;return((n=wh.find(r=>r.key===(e??t)))==null?void 0:n.noun)??"today"}function n9(e,t,n){const r=e!=null,s=vh(e);return{fromRange:r,cost:r?s.cost+n.cost:t.cost.total,inputTokens:r?s.inputTokens+n.inputTokens:t.inputTokens,outputTokens:r?s.outputTokens+n.outputTokens:t.outputTokens,cacheReadTokens:r?s.cacheReadTokens+n.cacheReadTokens:t.cacheReadTokens,cacheCreateTokens:r?s.cacheCreateTokens+n.cacheCreateTokens:t.cacheCreateTokens,hasCost:r?s.cost>0:t.cost.total>0,tokenSum:r?s.tokens:t.sum,showCostBar:!r}}const BI="agent-dag.usagePeriod";function r9(){const e=Je(BI);return wh.some(t=>t.key===e)?e:"today"}function s9(e){Ye(BI,e)}const qI="agent-dag.usageSessionsOpen";function a9(){return Je(qI)==="1"}function o9(e){Ye(qI,e?"1":"0")}function Tk({cost:e,size:t="md"}){const n=e.total;if(n<=0)return null;const r=(o,l,c)=>{if(o<=0)return null;const d=o/n*100;return a.jsx("span",{className:`cb-seg ${l}`,style:{width:`${d}%`},title:`${c}: ${We(o)} (${d.toFixed(0)}%)`},l)},s=t==="lg";return a.jsxs("div",{className:s?"cost-bar cost-bar-lg":"cost-bar",role:"img","aria-label":"Cost breakdown",children:[r(e.input,"cb-input","input"),r(e.output,"cb-output","output"),r(e.cacheRead,"cb-cache-r","cache read"),r(e.cacheWrite,"cb-cache-w","cache write")]})}const Hu="https://ccdeck.dev/guides",i9={localNetwork:{href:`${Hu}/local-network/#film`,subject:"Local network"},claudeAccounts:{href:`${Hu}/claude-accounts/#film`,subject:"Claude accounts"},usage:{href:`${Hu}/cost-and-quota/#film`,subject:"cost and quota"},tour:{href:`${Hu}/first-run/#film`,subject:"first run"}};function rc({film:e}){const{href:t,subject:n}=i9[e];return a.jsxs("a",{className:"film-link",href:t,target:"_blank",rel:"noopener noreferrer",title:`The ${n} video on ccdeck.dev, 30 seconds — opens in your browser`,children:["Watch · 30 s",a.jsxs("span",{className:"vis-hidden",children:[": the ",n," video on ccdeck.dev, opens in your browser"]})]})}const xt="ccdeck",l9="/brand/ccdeck-mark-gradient-small-optical.svg",c9="/brand/ccdeck-mark-mono-dark-small-optical.svg";function UI(e,t){const n=t.nextExpiryAt!=null?` · expires ${new Date(t.nextExpiryAt).toLocaleDateString("en-US",{month:"short",day:"numeric"})}`:"";return`${t.availableCount} ${e}${t.availableCount!==1?"s":""} available${n}`}function u9({incidents:e}){return a.jsx(a.Fragment,{children:e.map(t=>a.jsxs("a",{className:t.stale?"provider-incident provider-incident-stale":"provider-incident","data-state":t.state,href:t.href,target:"_blank",rel:"noopener noreferrer",title:t.detail,children:[a.jsx("span",{className:"pi-dot","aria-hidden":!0}),a.jsx("span",{className:"pi-name",children:t.name}),a.jsxs("span",{className:"pi-words",children:["· ",t.chipWords]}),a.jsxs("span",{className:"pi-short",children:["· ",t.shortWords]}),t.asOf&&a.jsxs("span",{className:"pi-asof",children:["· as of ",t.asOf]}),a.jsx("span",{className:"pi-go","aria-hidden":!0,children:"↗"}),a.jsxs("span",{className:"vis-hidden",children:[", on ",t.host,", opens in a new tab"]})]},t.provider))})}function zI({incident:e}){return e?a.jsxs("a",{className:e.stale?"up-incident up-incident-stale":"up-incident","data-state":e.state,href:e.href,target:"_blank",rel:"noopener noreferrer",title:e.detail,children:[a.jsx("span",{className:"pi-dot","aria-hidden":!0}),a.jsxs("span",{className:"up-incident-words",children:[a.jsxs("span",{className:"vis-hidden",children:[e.name,": "]}),e.words[0].toUpperCase()+e.words.slice(1),e.asOf?` · as of ${e.asOf}`:""]}),a.jsx("span",{className:"up-incident-go","aria-hidden":!0,children:"↗"}),e.what&&a.jsx("span",{className:"up-incident-what",children:e.what}),a.jsxs("span",{className:"vis-hidden",children:[", on ",e.host,", opens in a new tab"]})]}):null}function d9(e,t,n,r,s=!1){const o=Math.max(0,t-r),l=Math.max(0,n-o);if(l<120)return null;const c=Math.min(100,l/n*100),d=e-c;if(s||e>=100)return{label:"used up",color:"var(--warn)",expectedPct:c,isDeficit:!0};if(Math.abs(d)<3)return{label:"on pace",color:"var(--ok)",expectedPct:c,isDeficit:!1};if(d>0){const h=100-e,f=l>0?e/l:0,p=f>0?h/f:1/0,g={label:`${Math.round(d)}% over pace`,color:"var(--warn)",expectedPct:c,isDeficit:!0};if(p<o&&p<86400){const v=Math.floor(p/3600),j=Math.floor(p%3600/60);g.runsOutIn=v>0?`${v}h ${j}m`:`${j}m`}return g}return{label:`${Math.round(-d)}% under pace`,color:"var(--ok)",expectedPct:c,isDeficit:!1}}function ea({pct:e,label:t,reset:n,resetAt:r,windowSec:s,limitReached:o,nowSec:l}){const c=!!r&&r<=l,d=e!=null&&!c,h=d?Math.min(100,Math.max(0,e)):0,p=o||h>=90?"var(--err)":h>=70?"var(--warn)":"var(--accent)",g=h<1,v=c?"reset":d?g?"< 1%":`${Math.round(h)}%`:"no reading",j=g?2:h,k=r&&!c?gh(r,l):null,x=d&&r&&s?d9(h,r,s,l,o):null,[N,b]=y.useState(!1),S=y.useId();return a.jsxs("div",{className:"qb-row",children:[a.jsxs("div",{className:"qb-meta",children:[a.jsxs("span",{className:"qb-label",children:[t,o&&!c&&a.jsx("span",{className:"qb-limit-badge",title:"Rate limit reached",children:"⛔"})]}),a.jsx("span",{className:"qb-pct",style:{color:d?p:"var(--muted)"},children:v})]}),a.jsxs("div",{className:"qb-track",children:[d&&a.jsx("div",{className:"qb-fill",style:{transform:`scaleX(${j/100})`,background:p,opacity:g?.4:1}}),x&&a.jsx("div",{className:"qb-pace-rail",style:{transform:`translateX(${x.expectedPct}%)`},children:a.jsx("div",{"aria-hidden":!0,className:"qb-pace-marker",style:{background:x.isDeficit?"var(--err)":"var(--ok)"},title:`To last until reset, stay near ${Math.round(x.expectedPct)}% by now`})})]}),a.jsxs("div",{className:"qb-reset-row",children:[c?a.jsx("span",{className:"qb-reset",children:"waiting for a new reading"}):k?a.jsxs("span",{className:"qb-reset",children:["resets in ",k]}):n?a.jsxs("span",{className:"qb-reset",children:["resets ",n]}):null,x&&a.jsxs("button",{type:"button",className:"qb-pace",style:{color:x.color},"aria-expanded":N,"aria-controls":N?S:void 0,onClick:()=>b(E=>!E),children:[a.jsx("i",{className:"qb-pace-key","aria-hidden":!0,style:{background:x.isDeficit?"var(--err)":"var(--ok)"}}),x.runsOutIn?`runs out in ${x.runsOutIn}`:x.label]})]}),N&&x&&a.jsxs("div",{id:S,className:"qb-why",children:["To last until reset, stay near ",Math.round(x.expectedPct),"% by now."]})]})}function WI(e,t){if(!e)return null;const n=t-Math.floor(e/1e3);return n<10?"just now":n<60?`${n}s ago`:n<3600?`${Math.floor(n/60)}m ago`:`${Math.floor(n/3600)}h ago`}function h9(e){return e==="claude-swap"?"Read from claude-swap's last collection — costs no request against your usage-endpoint budget. Saved limit resets, which it does not collect, are read separately: every 30 minutes, or 5 on refresh":e==="api"?"Fetched from Anthropic's usage endpoint, at most once every 5 minutes":e==="cli"?"Parsed from `claude /usage`, at most once every 5 minutes":"Last update"}function f9(e){switch(e){case"no_subscription":return"This install signs in with an API key (or Bedrock/Vertex), which is billed per token and has no session window.";case"rate_limited":return"Anthropic asked the deck to wait — it will retry on its own.";case"waiting":return"Waiting for the next allowed read — or click ↻.";default:return"Run /usage in a claude session, then click ↻"}}function p9(e){switch(e){case"no_token":return"Run codex login to authenticate.";case"api_key_mode":return"API-key login — ChatGPT quota is only available for codex login.";case"refresh_rejected":return"Codex session expired — run codex login.";case"refresh_failed":return"Couldn't refresh the Codex token — click ↻ to retry.";case"untrusted_base_url":return"chatgpt_base_url in ~/.codex/config.toml is not an https OpenAI host, so the token was not sent.";case"rate_limited":return"OpenAI asked the deck to wait — it will retry on its own.";case"waiting":return"Waiting for the next allowed read — or click ↻.";default:return"ChatGPT API unreachable — click ↻ to retry."}}function m9({quota:e,quotaLoading:t,nowSec:n,incident:r}){const s=WI(e==null?void 0:e.fetchedAt,n);return a.jsxs("section",{className:"up-section up-quota-section",children:[a.jsxs("h3",{className:"up-section-title",children:["Claude quota",s&&!t&&a.jsxs("span",{className:"up-section-age",title:h9(e==null?void 0:e.source),children:[s,(e==null?void 0:e.stale)&&" · no newer reading"]})]}),a.jsx(zI,{incident:r}),e!=null&&e.ok?a.jsxs("div",{className:"up-quota-bars",children:[e.session5hPct!=null&&a.jsx(ea,{label:"5-hour window",pct:e.session5hPct,reset:e.session5hReset,resetAt:e.session5hResetAt,windowSec:e.session5hWindowSec,nowSec:n}),a.jsx(ea,{label:"7-day window",pct:e.week7dPct??null,reset:e.week7dReset,resetAt:e.week7dResetAt,windowSec:e.week7dWindowSec,nowSec:n}),e.weekSonnetPct!=null&&a.jsx(ea,{label:"Sonnet (7d)",pct:e.weekSonnetPct,nowSec:n}),e.weekOpusPct!=null&&a.jsx(ea,{label:"Opus (7d)",pct:e.weekOpusPct,nowSec:n}),e.extraEnabled&&e.extraUsedCredits!=null&&e.extraMonthlyLimit?a.jsx(ea,{label:`Extra credits (month${e.extraCurrency?`, ${e.extraCurrency}`:""})`,pct:Math.min(100,Math.round(e.extraUsedCredits/e.extraMonthlyLimit*100)),nowSec:n}):e.extraEnabled&&a.jsx("div",{className:"up-quota-sub up-credits",children:"extra usage credits: on"}),e.resetCredits&&e.resetCredits.availableCount>0&&a.jsx("div",{className:"up-quota-sub up-reset-credits",title:`Saved in Claude as "Reset for free". Redeem one in Claude on the web or desktop — ${xt} only reports them`,children:UI("limit reset",e.resetCredits)})]}):(e==null?void 0:e.ok)===!1?a.jsxs("div",{className:"up-quota-na",children:[a.jsx("span",{children:e.reason==="no_subscription"?"No quota to show.":"Quota unavailable."}),a.jsx("span",{className:"up-quota-hint",children:f9(e.reason)})]}):a.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]})}function g9({codexQuota:e,codexLoading:t,codexUsage:n,nowSec:r,incident:s}){var l,c;const o=WI(e==null?void 0:e.fetchedAt,r);return a.jsxs("section",{className:"up-section up-quota-section",children:[a.jsxs("h3",{className:"up-section-title",children:["Codex quota",(e==null?void 0:e.ok)&&e.planLabel&&a.jsx("span",{className:"up-plan-badge",children:e.planLabel}),o&&!t&&a.jsx("span",{className:"up-section-age",title:"Fetched from the Codex usage endpoint",children:o})]}),a.jsx(zI,{incident:s}),e!=null&&e.ok?a.jsxs("div",{className:"up-quota-bars",children:[(l=e.windows)==null?void 0:l.map(d=>a.jsx(ea,{label:d.label,pct:d.pct,reset:d.reset??void 0,resetAt:d.resetAt??void 0,windowSec:d.windowSec??void 0,limitReached:e.limitReached&&d.pct>=100,nowSec:r},d.id)),(c=e.extraWindows)==null?void 0:c.map(d=>a.jsx(ea,{label:d.label,pct:d.pct,reset:d.reset??void 0,resetAt:d.resetAt??void 0,windowSec:d.windowSec??void 0,nowSec:r},d.id)),e.creditLimit&&a.jsx(ea,{label:`spend cap · $${Math.round(e.creditLimit.used)} of $${Math.round(e.creditLimit.limit)}`,pct:e.creditLimit.usedPct,reset:e.creditLimit.reset??void 0,resetAt:e.creditLimit.resetAt??void 0,limitReached:e.spendControlReached,nowSec:r}),e.creditsBalance&&!e.creditsUnlimited&&a.jsxs("div",{className:"up-quota-sub up-credits",children:["credits: $",e.creditsBalance,e.overageReached&&" · overage limit reached"]}),e.creditsUnlimited&&a.jsx("div",{className:"up-quota-sub up-credits",children:"credits: unlimited"}),e.resetCredits&&e.resetCredits.availableCount>0&&a.jsx("div",{className:"up-quota-sub up-reset-credits",title:`Redeem in the Codex CLI or ChatGPT — ${xt} only reports them`,children:UI("rate-limit reset",e.resetCredits)}),e.promo&&a.jsx("div",{className:"up-quota-sub",children:e.promo}),e.partial&&a.jsx("div",{className:"up-quota-sub up-quota-hint",children:"Partial data — OpenAI returned limits this build doesn't recognise."})]}):(e==null?void 0:e.ok)===!1?a.jsxs("div",{className:"up-quota-na",children:[a.jsx("span",{children:"Quota unavailable."}),a.jsx("span",{className:"up-quota-hint",children:p9(e.reason)})]}):a.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"}),(n==null?void 0:n.ok)&&n.window7d&&n.window7d.sessionCount>0&&a.jsxs("div",{className:"up-quota-sub",title:`Counted from the rollout files under CODEX_HOME — no network, no account${n.window5h?`
89
- last 5h: ${st(n.window5h.totalTokens)} tokens · ${n.window5h.sessionCount} session${n.window5h.sessionCount!==1?"s":""}`:""}`,children:[st(n.window7d.totalTokens)," tokens · ",n.window7d.sessionCount," session",n.window7d.sessionCount!==1?"s":""," (7d)"]})]})}function y9({fromRange:e,rangeModelRows:t,boardModelRows:n}){return a.jsxs("section",{className:"up-section",children:[a.jsx("h3",{className:"up-section-title",children:"By model"}),a.jsxs("table",{className:"up-table",children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx("th",{children:"Model"}),a.jsx("th",{children:"Tokens"}),a.jsx("th",{children:"Cost"})]})}),a.jsx("tbody",{children:e?t.map(r=>a.jsxs("tr",{children:[a.jsx("td",{className:"up-model-name",title:r.model,children:ks(r.model)}),a.jsx("td",{className:"up-num",children:st(r.tokens)}),r.cost>0?a.jsx("td",{className:"up-num up-cost-val",children:We(r.cost)}):a.jsx("td",{className:"up-num up-unpriced",children:bs})]},r.model)):n.map(r=>a.jsxs("tr",{children:[a.jsx("td",{className:"up-model-name",title:r.model===ab?"no model reported yet":r.model,children:r.model===ab?"unknown":ks(r.model)}),a.jsx("td",{className:"up-num",children:st(r.inputTokens+r.outputTokens)}),r.priced?a.jsx("td",{className:"up-num up-cost-val",children:We(r.cost.total)}):a.jsx("td",{className:"up-num up-unpriced",children:bs})]},r.model))})]})]})}function w9({period:e,rangePending:t,setPeriod:n}){const r=y.useRef([]);return a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"uh-range up-period",role:"toolbar","aria-orientation":"horizontal","aria-label":"Period","aria-busy":t||void 0,onKeyDown:s=>{var c;const o=r.current.indexOf(s.target);if(o<0)return;const l=Y7(s.key,o);l!==null&&(s.preventDefault(),(c=r.current[l])==null||c.focus())},children:wh.map((s,o)=>a.jsx("button",{type:"button",ref:l=>{r.current[o]=l},tabIndex:e===s.key?0:-1,"aria-pressed":e===s.key,"data-pending":e===s.key&&t?"":void 0,title:e===s.key&&t?`Reading ${s.noun} from the transcripts on this machine…`:s.hint,className:"uh-range-btn",onClick:()=>n(s.key),children:s.label},s.key))}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:t?`Reading ${FI(e,e)}…`:""})]})}function v9({fromRange:e,rangeSessionRows:t,boardSessionRows:n,boardStates:r,sessionsOpen:s,setSessionsOpen:o,periodNoun:l,sessionScale:c}){const d=e?t.length:n.length;return a.jsxs("section",{className:"up-section",children:[a.jsx("h3",{className:"up-section-title",children:a.jsxs("button",{type:"button",className:"up-disclose","aria-expanded":s,"aria-controls":"up-sessions",title:s?"Hide the per-session breakdown":`Show the per-session breakdown — ${d} session${d===1?"":"s"}`,onClick:()=>o(h=>!h),children:["By session",e&&a.jsxs("span",{className:"up-section-age",title:e9(l,c,We),children:["active ",l]}),a.jsx("svg",{className:"up-chev",width:"9",height:"9",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:a.jsx("path",{d:"M2.2 3.6 5 6.4 7.8 3.6"})})]})}),a.jsxs("div",{className:"up-sessions",id:"up-sessions",hidden:!s,children:[e&&t.map(h=>{const f=r.get(h.sessionId);return a.jsxs("div",{className:"up-session-row",children:[f?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:`sl-dot state-${f}`,"aria-hidden":!0}),a.jsx("span",{className:"vis-hidden",children:xi(f)})]}):a.jsx("span",{className:"sl-dot up-dot-past","aria-hidden":!0}),a.jsx("span",{className:`up-session-label${h.label?"":" up-session-id"}`,title:h.label?`${h.label}
90
- ${h.sessionId}`:h.sessionId,children:h.label??Ek(h.sessionId,8)}),a.jsx("span",{className:"up-session-tokens",children:st(h.tokens)}),h.cost>0?a.jsx("span",{className:"up-session-cost",title:h.models.join(", ")||void 0,children:We(h.cost)}):a.jsx("span",{className:"up-session-cost up-unpriced",children:bs})]},h.sessionId)}),!e&&n.map(h=>a.jsxs("div",{className:"up-session-row",children:[a.jsx("span",{className:`sl-dot state-${h.state}`,"aria-hidden":!0}),a.jsx("span",{className:"vis-hidden",children:xi(h.state)}),a.jsx("span",{className:"up-session-label",children:h.label}),a.jsx("span",{className:"up-session-tokens",children:st(h.inputTokens+h.outputTokens)}),h.cost>0?a.jsxs("span",{className:"up-session-cost",title:h.unpricedTokens>0?`${st(h.unpricedTokens)} tokens in this session are on an unpriced model, so this is a floor`:void 0,children:[We(h.cost),h.unpricedTokens>0?"+":""]}):a.jsx("span",{className:"up-session-cost up-unpriced",children:bs})]},h.sessionId))]})]})}function oa(e,t){return{disabled:e!=null&&e!==t,busy:e===t}}function xh(e){return e==null}const cb="self";function Wr(e,t=!1){const n=oa(e?cb:null,cb);return{disabled:t||n.disabled,"aria-busy":n.busy}}function xr(e){return xh(e?cb:null)}const ro=400;function so({armedFor:e,target:t,armedAt:n,now:r,gapMs:s}){return e!==t?"arm":r-n<s?"ignore":"fire"}function HI(e){return[...e==null?[]:[`#ap-more-${e}`],".accounts-panel .ap-refresh"]}function An(e){return e==null||e==="BODY"||e==="HTML"}const x9=6e4,b9=2e4;function k9(e){const[t,n]=y.useState(null),[r,s]=y.useState(!1),o=y.useRef(null),l=y.useRef(!1),c=async(h=!1)=>{if(!(h&&!xr(l.current))){h&&(l.current=!0,s(!0));try{const p=await fetch(h?"/api/quota?refresh=1":"/api/quota",{signal:AbortSignal.timeout(b9)});p.ok&&n(await p.json())}catch{}finally{h&&(l.current=!1,s(!1))}}};return y.useEffect(()=>{if(e)return c(!0),o.current=window.setInterval(()=>c(!1),x9),()=>{o.current!=null&&window.clearInterval(o.current)}},[e]),{quota:t,loading:r,refresh:()=>{e&&c(!0)}}}const VI=6e4;function N9(e){const[t,n]=y.useState(null),[r,s]=y.useState(!1),o=y.useRef(null),l=y.useRef(!1),c=async(h=!1)=>{if(!(h&&!xr(l.current))){h&&(l.current=!0,s(!0));try{const p=await fetch(h?"/api/codex-quota?refresh=1":"/api/codex-quota");p.ok&&n(await p.json())}catch{}finally{h&&(l.current=!1,s(!1))}}};return y.useEffect(()=>{if(e)return c(!0),o.current=window.setInterval(()=>c(!1),VI),()=>{o.current!=null&&window.clearInterval(o.current)}},[e]),{data:t,loading:r,refresh:()=>{e&&c(!0)}}}function j9(e){const[t,n]=y.useState(null),r=y.useRef(null),s=async()=>{try{const o=await fetch("/api/codex-usage");o.ok&&n(await o.json())}catch{}};return y.useEffect(()=>{if(e)return s(),r.current=window.setInterval(s,VI),()=>{r.current!=null&&window.clearInterval(r.current)}},[e]),{data:t}}const $S=6e4;function S9(e,t,n){const[r,s]=y.useState(null),[o,l]=y.useState(!1),[c,d]=y.useState(0),h=y.useRef(0);y.useEffect(()=>{const p=()=>document.visibilityState==="visible",g=()=>{p()&&d(k=>k+1)},v=window.setInterval(g,$S),j=()=>{p()&&Date.now()-h.current>=$S&&d(k=>k+1)};return document.addEventListener("visibilitychange",j),()=>{window.clearInterval(v),document.removeEventListener("visibilitychange",j)}},[]);const f=y.useRef(t);return y.useEffect(()=>{let p=!0;const g=t!==f.current;f.current=t;const v=e,j=PI(v);return l(!0),fetch(`/api/ccusage?since=${j}${g?"&refresh=1":""}`).then(k=>k.ok?k.json():null).then(k=>{!p||!(k!=null&&k.ok)||(h.current=Date.now(),s({period:v,data:k,baseline:n()}))}).catch(()=>{}).finally(()=>{p&&l(!1)}),()=>{p=!1}},[e,t,c]),{...t9(r,e),loading:o}}const _9=e=>1-Math.pow(1-e,5),GI=420;function E9(e,t){if(!Number.isFinite(e)||!Number.isFinite(t)||e===t)return!1;const n=Math.abs(t-e);if(n<1)return!1;const r=Math.max(Math.abs(e),Math.abs(t));return r===0||n/r>=.005}function C9(e,t,n,r=GI){return n>=r?t:n<=0?e:e+(t-e)*_9(n/r)}function KI(){return typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches}function IS(e,t,n,r={}){const s=r.now??(()=>performance.now()),o=r.raf??(v=>requestAnimationFrame(v)),l=r.cancel??(v=>cancelAnimationFrame(v)),c=r.reducedMotion??KI,d=r.hidden??(()=>typeof document=="object"&&document.hidden===!0);if(c()||d()||!E9(e,t))return n(t),()=>{};const h=s();let f=0,p=!0;const g=()=>{if(!p)return;const v=s()-h;n(C9(e,t,v)),v<GI&&(f=o(g))};return f=o(g),()=>{p=!1,f&&l(f)}}const T9=typeof window>"u"?y.useEffect:y.useLayoutEffect;function qa(e,{countIn:t=!1}={}){const[n,r]=y.useState(e),s=y.useRef(e),o=y.useRef(!0);return y.useEffect(()=>{s.current=n},[n]),T9(()=>{!t||KI()||(s.current=0,r(0))},[]),y.useEffect(()=>{if(o.current){if(o.current=!1,t)return IS(0,e,c=>{s.current=c,r(c)});s.current=e,r(e);return}return IS(s.current,e,c=>{s.current=c,r(c)})},[e]),n}function YI(e,t,n){const r=R9*Math.max(1,n/ZI);let s=0;for(const[o,l]of t){const c=e.get(o);if(c===void 0)continue;const d=l.cost-c.cost;d>0&&d<=r&&(s+=d)}return s}const OS={samples:[],last:new Map,watched:0},XI=10*6e4,A9=6e4,ZI=5e3,R9=20;function M9(e,t,n){const r=e.samples[e.samples.length-1];if(r&&t-r.t<ZI)return e;const s=e.watched+YI(e.last,n,r?t-r.t:0),o=e.samples.filter(l=>t-l.t<=XI);return o.push({t,watched:s}),{samples:o,last:n,watched:s}}function $9(e,t,n){const r=e.samples[0];if(!r)return null;const s=t-r.t;if(s<A9)return null;const o=e.samples[e.samples.length-1].t,l=e.watched+YI(e.last,n,t-o)-r.watched;return l>0?{spent:l,spanSec:s/1e3,spanMin:Math.min(XI/6e4,Math.ceil(s/6e4))}:null}function I9(e,t,n){const r=y.useRef(OS),s=y.useRef(null);return y.useMemo(()=>{const o=D7(e.agents.values()),l=I7(e.agents.values());s.current!==n&&(s.current=n,r.current=OS);const c=ib(e.agents.values(),t);n!=null&&(r.current=M9(r.current,t,c));const d=n==null?null:$9(r.current,t,c),h=d?{label:wk(d.spent,d.spanSec),spanMin:d.spanMin}:null;return{byModel:o,totalCost:l.cost,totalTokens:l,burnRate:h}},[e,e.revision,t,n])}const O9=3e4;function JI(){const[e,t]=y.useState(()=>Math.floor(Date.now()/1e3));return y.useEffect(()=>{const n=window.setInterval(()=>t(Math.floor(Date.now()/1e3)),O9);return()=>window.clearInterval(n)},[]),e}function LS(e){return(typeof e.cost=="number"?e.cost:e.cost.total)>0||e.inputTokens+e.outputTokens>0}function L9(e,t,n){return e?t.some(r=>r.cost<=0&&r.tokens>0):n.some(r=>!r.priced)}function P9(e){return e.claude&&e.codex?"Refresh Claude + Codex quota":e.codex?"Refresh Codex quota":"Refresh Claude quota"}function D9(e){const t=new Map;for(const n of e){if(n.kind!=="root"||!n.sessionId)continue;const r=n.label||n.cwdBasename;r&&t.set(n.sessionId,r)}return t}function F9(e){const t=new Map;for(const n of e)n.kind!=="root"||!n.sessionId||t.set(n.sessionId,n.state);return t}function B9(e){const t=new Map;for(const n of e){if(!n.label)continue;const r=t.get(n.label);r?r.push(n.sessionId):t.set(n.label,[n.sessionId])}return e.map(n=>{const r=n.label?t.get(n.label)??[]:[];return r.length>1?{...n,label:`${n.label} ${RI(n.sessionId,r)}`}:n})}function q9({state:e,now:t,providers:n,incidents:r=[],leaving:s,onClose:o,liveSince:l=null}){const{quota:c,loading:d,refresh:h}=k9(n.claude),{data:f,loading:p,refresh:g}=N9(n.codex),{data:v}=j9(n.codex),j=JI(),{byModel:k,totalCost:x,totalTokens:N,burnRate:b}=I9(e,t,l),S=y.useMemo(()=>F7(e.agents.values()),[e,e.revision]),[E,R]=y.useState(r9);y.useEffect(()=>{s9(E)},[E]);const[I,A]=y.useState(a9);y.useEffect(()=>{o9(I)},[I]);const[q,$]=y.useState(0),B=y.useRef(()=>new Map);B.current=()=>l==null?null:ib(e.agents.values(),t);const L=y.useCallback(()=>B.current(),[]),{data:M,shown:F,stale:T,loading:P,baseline:O}=S9(E,q,L),G=M!=null,K=P&&T,U=y.useMemo(()=>D9(e.agents.values()),[e,e.revision]),H=y.useMemo(()=>F9(e.agents.values()),[e,e.revision]),D=y.useMemo(()=>G?DI(M):[],[M,G]),V=y.useMemo(()=>G?B9(J7(M,U).slice(0,12)):[],[M,G,U]),J=y.useMemo(()=>vh(M),[M]),W=y.useMemo(()=>Q7(M,J.cost),[M,J.cost]),Z=FI(F,E),Y=y.useMemo(()=>G?K7(O,ib(e.agents.values(),t)):ob,[e,e.revision,O,G,t]),X=n9(M,{...N,cost:x},Y),ee=X.hasCost,ae=X.tokenSum,ce=qa(X.cost),ge=qa(X.inputTokens),ye=qa(X.outputTokens),se=qa(X.cacheReadTokens),pe=qa(X.cacheCreateTokens),fe=k.filter(LS),de=S.filter(LS),me=L9(G,D,fe),ne=d||p,oe=()=>{h(),g(),$(we=>we+1)},Ne=P9(n);return a.jsxs("aside",{className:`usage-panel${s?" leaving":""}`,id:"usage-panel","aria-label":"Usage",children:[a.jsxs("div",{className:"up-header",children:[a.jsx("h2",{children:"Usage"}),b&&a.jsxs("span",{className:"up-rate",title:`Spend on this board over the last ${b.spanMin} min`,children:[b.label,a.jsxs("span",{className:"up-rate-span",children:[" · ",b.spanMin," min"]})]}),a.jsxs("div",{className:"up-header-right",children:[(n.claude||n.codex)&&a.jsx("button",{type:"button",className:"glyph-btn up-refresh-btn",onClick:oe,...Wr(ne),"aria-label":Ne,title:Ne,children:ne?"…":"↻"}),a.jsx("button",{type:"button",className:"glyph-btn up-close",onClick:o,"aria-label":"Close usage panel",title:"Close (U)",children:"×"})]})]}),n.claude&&a.jsx(m9,{quota:c,quotaLoading:d,nowSec:j,incident:r.find(we=>we.provider==="claude")}),n.codex&&a.jsx(g9,{codexQuota:f,codexLoading:p,codexUsage:v,nowSec:j,incident:r.find(we=>we.provider==="codex")}),G&&a.jsx(w9,{period:E,rangePending:K,setPeriod:R}),ae>0?a.jsxs(a.Fragment,{children:[ee&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"up-total",title:G?void 0:AS,children:[a.jsx("span",{className:"up-total-value",children:We(ce)}),a.jsx("span",{className:"up-total-label",children:G?Z:O7})]}),X.showCostBar&&a.jsx(Tk,{cost:x})]}),a.jsxs("div",{className:"up-tokens-row",title:G?void 0:AS,children:[a.jsxs("span",{className:"up-tok",children:[a.jsx("span",{className:"up-k",children:"in"}),st(ge)]}),a.jsxs("span",{className:"up-tok",children:[a.jsx("span",{className:"up-k",children:"out"}),st(ye)]}),X.cacheReadTokens>0&&a.jsxs("span",{className:"up-tok",children:[a.jsx("span",{className:"up-k",children:"cache r"}),st(se)]}),X.cacheCreateTokens>0&&a.jsxs("span",{className:"up-tok",children:[a.jsx("span",{className:"up-k",children:"cache c"}),st(pe)]}),!ee&&a.jsx("span",{className:"up-tok up-scope",children:L7})]}),(G?D.length:fe.length)>0&&a.jsx(y9,{fromRange:G,rangeModelRows:D,boardModelRows:fe}),G&&V.length===0&&J.tokens>0&&a.jsxs("section",{className:"up-section",children:[a.jsx("h3",{className:"up-section-title",children:"By session"}),a.jsxs("div",{className:"up-hint",children:["No session is dated ",Z," yet — ccusage dates sessions in UTC, and the totals above are your local day."]})]}),(G?V.length:de.length)>0&&a.jsx(v9,{fromRange:G,rangeSessionRows:V,boardSessionRows:de,boardStates:H,sessionsOpen:I,setSessionsOpen:A,periodNoun:Z,sessionScale:W}),me&&a.jsxs("div",{className:"up-hint",children:["“",bs,"” means this build holds no published rate for that model — those tokens are counted above and their dollars are not."]})]}):a.jsx("div",{className:"up-empty",children:G?(F??E)==="all"?a.jsx(a.Fragment,{children:"No usage in any transcript on this machine."}):a.jsxs(a.Fragment,{children:["No usage ",Z,".",a.jsx("br",{}),"Try a longer period."]}):a.jsxs(a.Fragment,{children:["No usage data yet.",a.jsx("br",{}),"Start a Claude Code or Codex session."]})}),a.jsx("div",{className:"film-foot",children:a.jsx(rc,{film:"usage"})})]})}function Xp(e){return e<9.95?e.toFixed(1):String(Math.round(e))}function Ak(e){const t=Number.isFinite(e)?Math.max(0,e):0;return t<50?{value:"0",unit:"KB/s"}:t<999500?{value:Xp(t/1e3),unit:"KB/s"}:t<9995e5?{value:Xp(t/1e6),unit:"MB/s"}:{value:Xp(t/1e9),unit:"GB/s"}}function bh(e){const t=Number.isFinite(e)?Math.max(0,e):0;return t<999.5?{value:String(Math.round(t)),unit:"ms"}:{value:(t/1e3).toFixed(1),unit:"s"}}function sc(e){return e.unit?e.unit==="%"||e.unit==="°C"?`${e.value}${e.unit}`:`${e.value} ${e.unit}`:e.value}const U9="thermal:Throttling";function Rk(e){const t="timeHeld"in e?e.timeHeld:100-e.speedLimit;return Math.max(0,Math.min(100,t))}function z9(e){var n,r,s,o;const t={};e.cpu!=null&&(t["cpu:all"]=e.cpu),(n=e.perCore)!=null&&n.length&&(t["cpu:busiest"]=Math.max(...e.perCore)),e.memory&&(t["mem:physical"]=e.memory.usedPct),e.swap&&e.swap.total>0&&(t["mem:swap"]=Math.round(e.swap.used/e.swap.total*1e3)/10),(r=e.loadavg)!=null&&r.length&&(t["load:1m"]=e.loadavg[0]);for(const l of((s=e.thermal)==null?void 0:s.celsius)??[])t[`thermal:${l.label}`]=l.celsius;return(o=e.thermal)!=null&&o.throttle&&(t[U9]=Rk(e.thermal.throttle)),t}function ql(e,t){return t==="B/s"?sc(Ak(e)):t==="ms"?sc(bh(e)):t==="C"?`${Math.round(e)}°`:t==="%"?`${Math.round(e)}%`:e.toFixed(2)}function Vu(e,t){return t==="B/s"||t==="ms"||!Number.isInteger(e)?ql(e,t):t==="C"?`${e}°`:t==="%"?`${e}%`:`${e}`}function W9(e,t,n){return e>=n?"hot":e>=t?"warn":"calm"}function H9(e,t,n=Date.now()){const r=Rk(e),s="timeHeld"in e;return{pct:r,value:`${r}%`,tone:r===0?"calm":r>=30?"hot":"warn",note:r>0?s?`CPU throttled ${r}% of the time to cool down`:`CPU held to ${100-r}% of full speed to cool down`:t?s?`at full speed · ${t.peak}% throttled ${PS(t.lastMs,n)}`:`at full speed · held to ${100-t.peak}% ${PS(t.lastMs,n)}`:"running at full speed, and never held back"}}function PS(e,t=Date.now()){const n=Math.max(0,Math.floor((t-e)/6e4));if(n<2)return"just now";if(n<60)return`${n} minutes ago`;const r=Math.floor(n/60);return r===1?"an hour ago":`${r} hours ago`}function V9(e){const t=Math.floor(e/86400),n=Math.floor(e%86400/3600),r=Math.floor(e%3600/60);return t>0?`${t}d ${n}h`:n>0?`${n}h ${r}m`:`${r}m`}function G9(e){var r,s;const t=(r=e.thermal)==null?void 0:r.throttle,n=t?Rk(t):0;return t&&n>0?"timeHeld"in t?`throttled ${n}% of the time`:`throttled to ${100-n}% of full speed`:e.memory&&e.memory.usedPct>=90?`physical memory ${Math.round(e.memory.usedPct)}% full`:(s=e.network)!=null&&s.api&&e.network.api.ms==null?"the Claude API is not answering":null}function K9(e){return e.kind==="tailscale-exit"?e.node?`Tailscale exit node ${e.node}`:"a Tailscale exit node":e.kind==="tailscale"?"Tailscale":`${e.name?`${e.name} `:""}VPN${e.iface?` (${e.iface})`:""}`}const Y9=3e3;function X9(){const[e,t]=y.useState(null),n=y.useRef(null);return y.useEffect(()=>{let r=!0;const s=async()=>{if(document.visibilityState!=="hidden")try{const d=await fetch("/api/system");if(!d.ok)return;const h=await d.json();r&&(h!=null&&h.ok)&&t(h)}catch{}},o=()=>{n.current==null&&(s(),n.current=window.setInterval(s,Y9))},l=()=>{n.current!=null&&(window.clearInterval(n.current),n.current=null)},c=()=>{if(document.visibilityState==="hidden"){l();return}o(),s()};return o(),document.addEventListener("visibilitychange",c),()=>{r=!1,l(),document.removeEventListener("visibilitychange",c)}},[]),e}function Z9(e,t){return!e||e.key!==t?"none":e.dir==="asc"?"ascending":"descending"}function Rl({col:e,label:t,note:n,sort:r,next:s,onSort:o,className:l}){const c=Z9(r,e);return a.jsx("th",{scope:"col","aria-sort":c,className:l,children:a.jsxs("button",{type:"button",className:"sd-sort",title:n?`Sort by ${t}
91
-
92
- ${n}`:`Sort by ${t}`,onClick:()=>o(s(r,e)),children:[t,a.jsx("span",{className:"sd-sort-dir","aria-hidden":!0,children:c==="none"?"":c==="ascending"?"↑":"↓"})]})})}function Zp(e,t){return t==="B/s"?Ak(e):t==="ms"?bh(e):{value:String(e),unit:t==="C"?"°C":t}}const Et={l:30,r:6,t:6,b:2},Ys={l:0,r:0,t:2,b:1},kh=104,J9=64;function vr(e,t=100,n=kh,r=Et){const s=n-r.t-r.b;return r.t+s*(1-Math.max(0,Math.min(t,e))/t)}function QI(e,t){return t??[e[0].t,e[e.length-1].t]}function Mk(e,[t,n],r,s=Et){const o=r-s.l-s.r,l=n-t;return s.l+(l>0?o*(e-t)/l:o/2)}function eO(e,t,n,r=100,s=kh,o=Et,l){if(!e.length)return"";const c=QI(e,l),d=p=>Mk(p,c,t,o);let h="",f=null;for(const p of e){const g=f&&p.t-f.t<=n*2?"L":"M";h+=`${g}${d(p.t).toFixed(1)} ${vr(p.v,r,s,o).toFixed(1)}`,f=p}return h}function tO(e,t,n,r=100,s=kh,o=Et,l){if(e.length<2)return"";const c=s-o.b,d=QI(e,l),h=v=>Mk(v,d,t,o);let f="",p=[];const g=()=>{if(p.length>=2){let v=`M${h(p[0].t).toFixed(1)} ${c}`;for(const j of p)v+=`L${h(j.t).toFixed(1)} ${vr(j.v,r,s,o).toFixed(1)}`;f+=`${v}L${h(p[p.length-1].t).toFixed(1)} ${c}Z`}p=[]};for(const v of e)p.length&&v.t-p[p.length-1].t>n*2&&g(),p.push(v);return g(),f}function Q9(e){return e.length?{now:e[e.length-1].v,peak:e.reduce((t,n)=>Math.max(t,n.v),e[0].v)}:{now:null,peak:null}}function nO(e,t,n){return n!=null&&e>=n?"hot":t!=null&&e>=t?"warn":""}function eV(e,t,n=r=>Ua(r)){const r=e.filter(l=>l.v>0);if(!e.length)return null;if(!r.length)return"never held back";const s=r.length*(t/6e4),o=r[r.length-1];return`held back for ${s===1?"1 minute":`${s} minutes`}, last at ${n(o.t)}`}function Ua(e){const t=new Date(e);return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}function $k(e,t){const n=Math.max(0,Math.floor((t-e)/6e4));if(n<1)return"less than a minute";if(n<60)return`${n} minute${n===1?"":"s"}`;const r=Math.floor(n/60),s=n%60;return s?`${r}h ${s}m`:`${r}h`}function tV({group:e,title:t,onClose:n}){const r=ot(n),s=mt(n),[o,l]=y.useState(null);y.useEffect(()=>{let p=!0;const g=async()=>{try{const j=await fetch(`/api/system/history?group=${e}`);if(!j.ok)return;const k=await j.json();p&&(k!=null&&k.ok)&&l(k)}catch{}};g();const v=window.setInterval(g,2e4);return()=>{p=!1,window.clearInterval(v)}},[e]);const c=(o==null?void 0:o.series)??[],[d,h,f]=y.useMemo(()=>{let p=1/0,g=0;for(const v of c)v.points.length&&(p=Math.min(p,v.points[0].t),g=Math.max(g,v.points[v.points.length-1].t));return Number.isFinite(p)?[Math.max(p,(o==null?void 0:o.sinceMs)??0),g,[p,g]]:[(o==null?void 0:o.sinceMs)??0,g,void 0]},[c,o==null?void 0:o.sinceMs]);return Pt.createPortal(a.jsx("div",{className:"modal-backdrop",...s,role:"presentation",children:a.jsxs("div",{ref:r,className:"modal hist-modal",onClick:p=>p.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"hist-modal-title",children:[a.jsxs("div",{className:"modal-head",children:[a.jsx("span",{className:"modal-title",id:"hist-modal-title",children:t}),o&&d>0&&a.jsxs("span",{className:"hist-since",children:["since ",Ua(d)," · ",$k(d,h||Date.now())]}),a.jsx("button",{type:"button",className:"glyph-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]}),a.jsx("div",{className:"hist-body",children:o==null?a.jsx("p",{className:"hist-empty",children:"Reading…"}):c.length===0?a.jsx("p",{className:"hist-empty",children:"Nothing has been measured yet."}):c.map(p=>a.jsx(nV,{series:p,stepMs:o.stepMs,domain:f},p.label))})]})}),document.body)}function nV({series:e,stepMs:t,domain:n}){const r=y.useRef(null),[s,o]=y.useState(560),[l,c]=y.useState(null);y.useEffect(()=>{const L=r.current;if(!L||typeof ResizeObserver>"u")return;const M=new ResizeObserver(([F])=>o(Math.max(160,F.contentRect.width)));return M.observe(L),()=>M.disconnect()},[]);const{points:d,unit:h,warnAt:f,critAt:p,label:g,top:v,restsAtZero:j,changes:k}=e,x=j?J9:kh,{now:N,peak:b}=Q9(d),S=N!=null?Zp(N,h):null,E=b!=null?Zp(b,h):null,R=g==="Throttling"?eV(d,t):null,I=l!=null?d[l]:null,[A,q]=n??(d.length?[d[0].t,d[d.length-1].t]:[0,0]),$=L=>Mk(L,[A,q],s),B=L=>{if(d.length<2)return;const M=L.currentTarget.getBoundingClientRect(),F=(L.clientX-M.left-Et.l)/Math.max(1,M.width-Et.l-Et.r),T=A+(q-A)*Math.max(0,Math.min(1,F));let P=0;for(let O=1;O<d.length;O++)Math.abs(d[O].t-T)<Math.abs(d[P].t-T)&&(P=O);c(P)};return a.jsxs("section",{className:"hist-series","aria-label":`${g} history`,children:[a.jsxs("div",{className:"hist-head",children:[a.jsx("span",{className:"hist-label",children:g}),a.jsxs("span",{className:"hist-stats",children:[S&&a.jsxs(a.Fragment,{children:[a.jsx("b",{children:S.value}),a.jsxs("span",{children:[S.unit," now"]})]}),b!=null&&E&&a.jsxs(a.Fragment,{children:[a.jsx("b",{className:nO(b,f,p),children:E.value}),a.jsxs("span",{children:[E.unit," peak"]})]})]})]}),a.jsx("div",{className:"hist-plot",ref:r,children:a.jsxs("svg",{className:"hist-chart",width:"100%",height:x,viewBox:`0 0 ${s} ${x}`,preserveAspectRatio:"none",role:"img","aria-label":S==null||E==null?`${g}: nothing measured yet`:`${g}: ${sc(S)} now, peak ${sc(E)}, over ${$k(d[0].t,d[d.length-1].t)}`,onPointerMove:B,onPointerLeave:()=>c(null),children:[[["warn",f],["hot",p]].map(([L,M])=>M==null||M>v?null:a.jsxs("g",{children:[a.jsx("line",{className:`hist-rule ${L}`,x1:Et.l,x2:s-Et.r,y1:vr(M,v,x),y2:vr(M,v,x)}),a.jsx("text",{className:`hist-rule-tag ${L}`,x:2,y:vr(M,v,x)+3,children:M})]},L)),a.jsx("line",{className:"hist-floor",x1:Et.l,x2:s-Et.r,y1:x-Et.b,y2:x-Et.b}),(k??[]).filter(L=>L.from!=null&&d.length>1&&L.t>=A&&L.t<=q).map(L=>a.jsx("line",{className:"hist-mark",x1:$(L.t),x2:$(L.t),y1:Et.t,y2:x-Et.b},L.t)),a.jsx("path",{className:"hist-area",d:tO(d,s,t,v,x,Et,[A,q])}),a.jsx("path",{className:"hist-line",d:eO(d,s,t,v,x,Et,[A,q])}),d.length===1&&a.jsx("circle",{className:"hist-dot",cx:$(d[0].t),cy:vr(d[0].v,v,x),r:3}),I&&a.jsxs("g",{children:[a.jsx("line",{className:"hist-cross",x1:$(I.t),x2:$(I.t),y1:Et.t,y2:x-Et.b}),a.jsx("circle",{className:"hist-dot",cx:$(I.t),cy:vr(I.v,v,x),r:3})]})]})}),a.jsx("div",{className:"hist-axis",children:I?a.jsxs("span",{className:"hist-at",children:[Ua(I.t)," — ",(()=>{const L=Zp(I.v,h);return a.jsxs(a.Fragment,{children:[a.jsx("b",{children:L.value}),L.unit==="%"||L.unit==="°C"||!L.unit?L.unit:` ${L.unit}`]})})()]}):a.jsxs(a.Fragment,{children:[a.jsx("span",{children:d.length?Ua(A):""}),a.jsx("span",{children:d.length?Ua(q):""})]})}),R&&a.jsx("div",{className:"hist-note",children:R}),k==null?void 0:k.slice(-3).map(L=>a.jsx("div",{className:"hist-note hist-route",children:L.from==null?`Since ${Ua(L.t)} — ${L.label}`:`${Ua(L.t)} — ${L.label.charAt(0).toUpperCase()+L.label.slice(1)}`},L.t))]})}const DS=["cores","memory","load","thermal"],Pa=116,Fr=24,rV=60,sV=6e4;function aV(e){return e.points.length?e.restsAtZero?e.points.some(t=>t.v>0):!0:!1}function oV(e){return e.unit==="C"?`${e.label} temp`:e.key==="mem:physical"?"Physical RAM":e.key==="mem:swap"?`${e.label} memory`:e.label}function iV(e,t=rV){return e.points.length<=t?e:{...e,points:e.points.slice(-t)}}function lV({sys:e}){const[t,n]=y.useState({});y.useEffect(()=>{let l=!0;const c=async()=>{const h=await Promise.all(DS.map(async f=>{try{const p=await fetch(`/api/system/history?group=${f}`);return p.ok?[f,await p.json()]:[f,null]}catch{return[f,null]}}));l&&n(f=>{const p={...f};for(const[g,v]of h)v!=null&&v.ok&&(p[g]=v);return p})};c();const d=setInterval(()=>void c(),sV);return()=>{l=!1,clearInterval(d)}},[]);const r=y.useMemo(()=>z9(e),[e]),s=y.useMemo(()=>DS.flatMap(l=>{const c=t[l];return c?c.series.filter(aV).map(d=>({series:iV(d),stepMs:c.stepMs})):[]}),[t]),o=y.useMemo(()=>{let l=1/0,c=-1/0;for(const{series:d}of s){const h=d.points;h.length&&(l=Math.min(l,h[0].t),c=Math.max(c,h[h.length-1].t))}return Number.isFinite(l)?$k(l,c):"less than a minute"},[s]);return Object.keys(r).length?a.jsx("div",{className:"pl-strip",role:"group","aria-label":`This machine, over the last ${o}`,children:s.map(({series:l,stepMs:c})=>a.jsx(cV,{series:l,stepMs:c,now:r[l.key],span:o},l.key))}):null}function cV({series:e,stepMs:t,now:n,span:r}){var v;const{points:s,top:o,unit:l,warnAt:c,critAt:d}=e,h=oV(e),f=n??((v=s[s.length-1])==null?void 0:v.v),p=f==null?"":nO(f,c,d),g=Math.max(...s.map(j=>j.v));return a.jsxs("div",{className:`pl-cell${p?` ${p}`:""}`,title:[`${h} · peak ${ql(g,l)} over the last ${r}`,c!=null?`over ${Vu(c,l)} is uncomfortable`:"",d!=null?`over ${Vu(d,l)} the machine acts`:""].filter(Boolean).join(" · "),children:[a.jsxs("div",{className:"pl-cell-head",children:[a.jsx("span",{className:"pl-cell-label",children:h}),a.jsx("span",{className:"pl-cell-now",children:f==null?"—":ql(f,l)})]}),a.jsxs("svg",{className:"pl-spark",width:Pa,height:Fr,viewBox:`0 0 ${Pa} ${Fr}`,preserveAspectRatio:"none","aria-hidden":!0,children:[a.jsx("line",{className:"pl-spark-floor",x1:0,x2:Pa,y1:Fr-Ys.b,y2:Fr-Ys.b}),a.jsx("path",{className:"pl-spark-area",d:tO(s,Pa,t,o,Fr,Ys)}),c!=null&&a.jsx("line",{className:"pl-rule warn",x1:0,x2:Pa,y1:vr(c,o,Fr,Ys),y2:vr(c,o,Fr,Ys)}),d!=null&&a.jsx("line",{className:"pl-rule hot",x1:0,x2:Pa,y1:vr(d,o,Fr,Ys),y2:vr(d,o,Fr,Ys)}),a.jsx("path",{className:"pl-spark-line",d:eO(s,Pa,t,o,Fr,Ys)})]}),a.jsxs("span",{className:"vis-hidden",children:["peak ",ql(g,l)," over the last ",r,c!=null&&`, uncomfortable over ${Vu(c,l)}`,d!=null&&`, the machine acts over ${Vu(d,l)}`]})]})}const rO={key:"cpu",dir:"desc"};function uV(e,t){return e.key===t?{...e,dir:e.dir==="asc"?"desc":"asc"}:{key:t,dir:t==="name"||t==="user"?"asc":"desc"}}function dV(e,t){const n=t.dir==="asc"?1:-1,r=o=>t.key==="cpu"?o.cpu:t.key==="mem"?o.mem:t.key==="rss"?o.rssBytes:t.key==="threads"?o.threads:o.uptimeSec,s=(o,l)=>{if(t.key==="name")return n*o.name.localeCompare(l.name,void 0,{sensitivity:"base"});if(t.key==="user"){const h=o.user??"",f=l.user??"";return!h||!f?h===f?0:h?-1:1:n*h.localeCompare(f,void 0,{sensitivity:"base"})}const c=r(o),d=r(l);return c==null||d==null?c==null?d==null?0:1:-1:n*(c-d)};return[...e].sort((o,l)=>s(o,l)||(l.cpu??-1)-(o.cpu??-1)||l.mem-o.mem||o.pid-l.pid)}const hV=4e3;function fV(e,t){const n=t!=null&&t.ok&&Array.isArray(t.procs)?t.procs:[];return n.length?{procs:n,total:t.total??0}:e??{procs:[],total:0}}function pV(){const[e,t]=y.useState(null);return y.useEffect(()=>{let n=!0;const r=async()=>{if(document.visibilityState!=="hidden")try{const o=await fetch("/api/system/processes?detail=1");if(!o.ok)return;const l=await o.json();n&&t(c=>fV(c,l))}catch{}};r();const s=window.setInterval(r,hV);return()=>{n=!1,window.clearInterval(s)}},[]),e}function mV(e){return e==null||!Number.isFinite(e)||e<0?"—":e<60?`${Math.floor(e)}s`:e<3600?`${Math.floor(e/60)}m`:e<86400?`${Math.floor(e/3600)}h`:`${Math.floor(e/86400)}d`}function gV({sys:e,onClose:t}){qt("process-list");const n=ot(t),r=mt(t),[s,o]=y.useState(rO),l=pV();return Pt.createPortal(a.jsx("div",{className:"modal-backdrop",...r,role:"presentation",children:a.jsx("div",{ref:n,className:"modal pl-modal",onClick:c=>c.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"pl-modal-title",children:a.jsx(yV,{read:l,sort:s,onSort:o,sys:e,onClose:t})})}),document.body)}function yV({read:e,sort:t,onSort:n,sys:r,onClose:s}){const o=e?dV(e.procs,t):null;return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"modal-head",children:[a.jsx("span",{className:"modal-title",id:"pl-modal-title",children:"Busiest processes"}),o!=null&&o.length>0&&a.jsxs("span",{className:"pl-count",children:[o.length," of ",e.total," running"]}),a.jsx("button",{type:"button",className:"glyph-btn",onClick:s,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]}),a.jsxs("div",{className:"pl-split",children:[a.jsx("div",{className:"pl-body",children:o==null?a.jsx("p",{className:"pl-empty",children:"Reading the process list…"}):o.length===0?a.jsx("p",{className:"pl-empty",children:"Could not read the process list — retrying."}):a.jsxs("table",{className:"sd-procs pl-table",children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx(Yo,{col:"cpu",label:"cpu",sort:t,onSort:n}),a.jsx(Yo,{col:"rss",label:"memory",note:"Resident set size, which is what ps and Task Manager report; macOS Activity Monitor shows a different figure.",sort:t,onSort:n}),a.jsx(Yo,{col:"threads",label:"threads",sort:t,onSort:n}),a.jsx(Yo,{col:"uptime",label:"up",sort:t,onSort:n}),a.jsx(Yo,{col:"user",label:"user",sort:t,onSort:n}),a.jsx("th",{scope:"col",className:"pl-pid-h",children:"pid"}),a.jsx(Yo,{col:"name",label:"process",note:"Command lines have anything secret-shaped removed, which is a filter and not a guarantee.",sort:t,onSort:n})]})}),a.jsx("tbody",{children:o.map(l=>a.jsxs("tr",{children:[a.jsx("td",{className:"sd-num",children:l.cpu==null?"—":l.cpu.toFixed(0)}),a.jsx("td",{className:"sd-num sd-dim",title:`${l.mem.toFixed(1)}% of installed memory`,children:Qs(l.rssBytes)}),a.jsx("td",{className:"sd-num sd-dim",children:l.threads??"—"}),a.jsx("td",{className:"sd-num sd-dim",children:mV(l.uptimeSec)}),a.jsx("td",{className:"sd-dim pl-user",children:l.user??"—"}),a.jsx("td",{className:"sd-num sd-dim pl-pid",children:l.pid}),a.jsxs("td",{className:"pl-name",children:[l.name,l.cmd&&a.jsxs("span",{className:"pl-cmd",title:l.cmd,children:[" ",l.cmd]})]})]},l.pid))})]})}),a.jsx(lV,{sys:r})]})]})}function Yo(e){return a.jsx(Rl,{...e,next:(t,n)=>uV(t??rO,n)})}function ub({value:e,unit:t,cap:n}){return t?a.jsxs("span",{className:"sd-fig",children:[a.jsx("span",{className:"sd-fig-cap",children:n}),a.jsxs("span",{className:"sd-fig-read",children:[a.jsx("b",{children:e})," ",a.jsx("span",{className:"sd-fig-unit",children:t})]})]}):a.jsxs("span",{className:"sd-fig",children:[a.jsx("b",{children:e}),a.jsx("span",{className:"sd-fig-cap",children:n})]})}const wV=300;function ac({group:e,title:t,action:n,label:r,value:s,hint:o,children:l}){const[c,d]=y.useState(!1),h=y.useRef(null),f=y.useRef(null),p=()=>{f.current!=null&&window.clearTimeout(f.current),f.current=null};y.useEffect(()=>p,[]);const g=v=>{var j;p(),!(v.detail>1||((j=window.getSelection())==null?void 0:j.isCollapsed)===!1)&&(f.current=window.setTimeout(()=>{var k,x;f.current=null,((k=window.getSelection())==null?void 0:k.isCollapsed)!==!1&&((x=h.current)==null||x.focus({preventScroll:!0}),d(!0))},wV))};return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"sd-reading",onClick:g,children:[a.jsx("button",{ref:h,type:"button",className:"sd-open",onClick:v=>{v.stopPropagation(),p(),d(!0)},title:n,"aria-label":s==null?`${r}: show history`:`${r}: show history, now ${s}`,"aria-describedby":o?`sd-hint-${e}`:void 0,children:a.jsxs("span",{className:"sd-h","aria-hidden":!0,children:[r," ",a.jsx("i",{className:"sd-row-more",children:"›"}),s!=null&&a.jsx("span",{className:"sd-h-val",children:s})]})}),l]}),o&&a.jsx("span",{id:`sd-hint-${e}`,className:"vis-hidden",children:o}),c&&a.jsx(tV,{group:e,title:t,onClose:()=>d(!1)})]})}function Od({label:e,value:t,pct:n,tone:r="calm",note:s,mark:o,title:l,trackLabel:c}){return a.jsxs("div",{className:"sd-row",title:l,children:[a.jsxs("div",{className:"sd-row-head",children:[a.jsx("span",{className:"sd-row-label",children:e}),a.jsx("span",{className:"sd-row-val",children:t})]}),a.jsxs("span",{className:"sd-track",role:c?"img":void 0,"aria-label":c,children:[a.jsx("span",{className:`sd-fill${r==="calm"?"":` ${r}`}`,style:{transform:`scaleX(${n<=0?0:Math.max(1,Math.min(100,n))/100})`}}),o!=null&&o>0&&o<100&&a.jsx("span",{className:"sd-mark",style:{left:`${o}%`},"aria-hidden":!0})]}),s&&a.jsx("div",{className:"sd-note",children:s})]})}function vV(e,t,n){if(n<=0||dh(e))return{kind:"pass"};const r=t>=0&&t<n?t:-1;switch(e.key){case"ArrowDown":return{kind:"focus",index:r===-1?0:(r+1)%n};case"ArrowUp":return{kind:"focus",index:r===-1?n-1:(r-1+n)%n};case"Home":return{kind:"focus",index:0};case"End":return{kind:"focus",index:n-1};default:return{kind:"pass"}}}const na=4,Wn=8;function Ik(e,t,n){const r=n.width-Wn-(e.right+na),s=e.left-na-Wn,o=t.width<=r||r>=s?"right":"left",l=o==="right"?e.right+na:e.left-na-t.width,c=n.height-Wn*2,d=t.height<=c,h=d?t.height:Math.max(0,c),f=Math.max(Wn,Math.min(e.top,n.height-Wn-h)),p=Math.max(Wn,Math.min(l,n.width-Wn-t.width));return{top:f,left:p,side:o,maxHeight:d?null:h}}function xV(e,t,n){const r=n.height-Wn-(e.bottom+na),s=e.top-na-Wn,o=t.height<=r||r>=s?"below":"above",l=o==="below"?r:s,c=t.height<=l,d=c?t.height:Math.max(0,l),h=o==="below"?e.bottom+na:e.top-na-d,f=Math.max(Wn,Math.min(e.right-t.width,n.width-Wn-t.width));return{top:Math.max(Wn,h),left:f,side:o,maxHeight:c?null:d}}function bV(e,t,n){return!(!e||t!=null&&t.contains(e)||n!=null&&n.contains(e))}function sO(e,t,n){const r=y.useRef(t);r.current=t;const s=y.useRef(n);s.current=n,y.useEffect(()=>{const o=l=>{bV(l.target,e.current,r.current())&&s.current()};return window.addEventListener("pointerdown",o,!0),()=>window.removeEventListener("pointerdown",o,!0)},[e])}const aO='[role="menuitem"]';function FS(e){return e?Array.from(e.querySelectorAll(aO)).filter(t=>!t.disabled):[]}function Nh({anchorId:e,boundaryId:t,id:n,className:r,role:s,labelledBy:o,start:l="first",focusRef:c,fallbackFocus:d,onClose:h,children:f}){const p=y.useRef(h);p.current=h;const g=y.useRef(d);g.current=d;const v=ot(()=>{var b;(b=document.getElementById(e))==null||b.focus(),p.current()},{popover:!0,focusRef:c}),j=y.useCallback(()=>{var A,q,$;const b=v.current;if(!b)return;const S=document.getElementById(e);if(!S){p.current();return}if(S.getClientRects().length===0){b.contains(document.activeElement)&&((q=(A=g.current)==null?void 0:A.call(g))==null||q.focus()),p.current();return}const E=S.getBoundingClientRect(),R=t?($=document.getElementById(t))==null?void 0:$.getBoundingClientRect():null;if(R&&(E.bottom<=R.top||E.top>=R.bottom)){b.contains(document.activeElement)&&S.focus({preventScroll:!0}),p.current();return}b.style.maxHeight="";const I=xV(E,{width:b.offsetWidth,height:b.offsetHeight},{width:window.innerWidth,height:window.innerHeight});b.style.top=`${I.top}px`,b.style.left=`${I.left}px`,b.style.maxHeight=I.maxHeight==null?"":`${I.maxHeight}px`,b.dataset.side=I.side},[e,t,v]);y.useLayoutEffect(()=>{j()}),y.useEffect(()=>{const b=S=>{var E;(E=v.current)!=null&&E.contains(S.target)||j()};return window.addEventListener("scroll",b,!0),window.addEventListener("resize",j),()=>{window.removeEventListener("scroll",b,!0),window.removeEventListener("resize",j)}},[j,v]),sO(v,()=>document.getElementById(e),h),y.useEffect(()=>{var S;if(s!=="menu")return;const b=FS(v.current);(S=l==="last"?b[b.length-1]:b[0])==null||S.focus()},[]);const k=b=>{var S;if(s==="menu"&&b.key==="Tab"){b.stopPropagation(),(S=document.getElementById(e))==null||S.focus(),b.shiftKey&&b.preventDefault(),p.current();return}if(s==="menu"){const E=FS(v.current),R=vV(b,E.indexOf(document.activeElement),E.length);R.kind==="focus"&&(b.preventDefault(),E[R.index].focus())}b.key.length===1&&b.stopPropagation()},x=b=>{b.target.closest("button, input, select, textarea, code")||b.preventDefault()},N=b=>{if(s!=="menu"||b.pointerType==="touch")return;const S=b.target.closest(aO);S&&!S.disabled&&document.activeElement!==S&&S.focus({preventScroll:!0})};return Pt.createPortal(a.jsx("div",{ref:v,id:n,className:`anchored-popover${r?` ${r}`:""}`,role:s,"aria-labelledby":o,onKeyDown:k,onMouseDown:x,onPointerMove:N,children:f}),document.body)}function kV({network:e}){const{down:t,up:n,api:r,route:s}=e,[o,l]=y.useState(!1),c=r&&r.ms!=null?bh(r.ms):null,d=t!=null&&n!=null;return a.jsxs("div",{className:"sd-section",role:"group","aria-label":"Network",children:[a.jsxs(ac,{group:"network",title:"Network history",action:"Show network history",label:"Network",children:[(d||c)&&a.jsxs("div",{className:"sd-figs sd-figs-named",children:[d&&[["Download",t],["Upload",n]].map(([h,f])=>{const p=Ak(f);return a.jsx(ub,{value:p.value,unit:p.unit,cap:h},h)}),c&&a.jsx(ub,{value:c.value,unit:c.unit,cap:"Claude API"})]}),!d&&a.jsx("div",{className:"sd-note",children:"measuring…"}),r&&r.ms==null&&a.jsx("div",{className:"sd-note sd-note-warn",children:"Can’t reach Claude"})]}),s&&a.jsxs(a.Fragment,{children:[a.jsxs("button",{type:"button",className:"sd-detail",id:"sd-conn","aria-expanded":o,"aria-haspopup":"dialog",onClick:()=>l(h=>!h),children:["Connection details",s.relay&&a.jsx("span",{className:"sd-route-relay",children:" · relayed"}),a.jsx("i",{className:"sd-row-more","aria-hidden":!0,children:"›"})]}),o&&a.jsx(NV,{route:s,api:r,onClose:()=>l(!1)})]})]})}function NV({route:e,api:t,onClose:n}){return a.jsxs(Nh,{anchorId:"sd-conn",boundaryId:"system-panel",id:"sd-conn-pop",className:"sd-pop",role:"dialog",labelledBy:"sd-conn-title",onClose:n,children:[a.jsx("p",{className:"sd-pop-title",id:"sd-conn-title",children:"Connection"}),a.jsxs("dl",{className:"sd-pop-rows",children:[a.jsxs("div",{className:"sd-pop-row",children:[a.jsx("dt",{children:e.to==="claude"?"Traffic to Claude":"Internet traffic"}),a.jsxs("dd",{children:["through ",K9(e)]})]}),e.relay&&a.jsxs("div",{className:"sd-pop-row",children:[a.jsx("dt",{children:"Relay"}),a.jsxs("dd",{children:[a.jsx("span",{className:"sd-route-relay",children:e.relay})," — not a direct path, so every packet carries one more round trip than it has to"]})]}),t&&a.jsxs("div",{className:"sd-pop-row",children:[a.jsx("dt",{children:"Round trip"}),a.jsx("dd",{children:t.ms==null?`${t.host} did not answer`:`${sc(bh(t.ms))} to open a connection to ${t.host}`})]}),a.jsxs("div",{className:"sd-pop-row",children:[a.jsx("dt",{children:"Throughput"}),a.jsx("dd",{children:"every interface on this machine, not this path alone"})]})]})]})}function BS({usageOpen:e,leaving:t,sub:n,flag:r,onClose:s,children:o}){return a.jsxs("aside",{className:`sysdetail${e?" shifted":""}${t?" leaving":""}`,id:"system-panel","aria-labelledby":"sd-title",children:[a.jsxs("div",{className:"sd-top",children:[a.jsxs("div",{className:"sd-head",children:[a.jsx("h2",{className:"sd-title",id:"sd-title",children:"This machine"}),n&&a.jsx("span",{className:"sd-sub",children:n}),a.jsx("button",{type:"button",className:"glyph-btn sd-close",onClick:s,"aria-label":"Close",title:"Close",children:"×"})]}),r&&a.jsx("p",{className:"sd-flag",children:r})]}),o]})}function jV({usageOpen:e,leaving:t,onClose:n}){const r=X9();if(!r||r.cpu==null||!r.memory)return a.jsx(BS,{usageOpen:e,leaving:t,onClose:n,children:a.jsx("div",{className:"sd-note",children:"reading this machine…"})});const{memory:s,swap:o,perCore:l,loadavg:c,cores:d,uptimeSec:h,platform:f,thermal:p,network:g,cpu:v}=r;return a.jsxs(BS,{usageOpen:e,leaving:t,sub:`up ${V9(h)} · ${d} cores`,flag:G9(r),onClose:n,children:[a.jsx(SV,{cpu:v,perCore:l,loadavg:c,cores:d}),a.jsx(_V,{memory:s,swap:o,platform:f}),g&&a.jsx(kV,{network:g}),a.jsx(EV,{thermal:p}),a.jsx(CV,{sys:r})]})}function SV({cpu:e,perCore:t,loadavg:n,cores:r}){const s=!!t&&t.length>0;return!s&&!n?null:a.jsxs("div",{className:"sd-section sd-cpu",role:"group","aria-label":"CPU",children:[s&&a.jsx(ac,{group:"cores",title:"Core history",action:"Show core history",label:"CPU",value:e==null?null:`${Math.round(e)}%`,children:a.jsx("div",{className:"sd-cores",role:"img","aria-label":`${t.length} logical cores, busiest at ${Math.round(Math.max(...t))}%`,children:t.map((o,l)=>a.jsx("span",{className:"sd-core",title:`logical core ${l+1} · ${o}% busy`,children:a.jsx("span",{className:"sd-core-fill",style:{transform:`scaleY(${Math.max(2,o)/100})`}})},l))})}),n&&a.jsxs(ac,{group:"load",title:"Load history",action:"Show load history",label:"Load average",hint:"the queue for the cores, counted in tasks rather than as a share of them",children:[a.jsx("div",{className:"sd-figs",title:"The queue for this machine's cores, averaged over one, five and fifteen minutes. A count of tasks, not a share of the CPU.",children:n.map((o,l)=>a.jsx(ub,{value:o.toFixed(2),cap:["1m","5m","15m"][l]},l))}),n[0]>r&&a.jsx("div",{className:"sd-note",children:`${(n[0]/r).toFixed(1)}× more work queued than cores to run it`})]})]})}function _V({memory:e,swap:t,platform:n}){const r=e.total-e.available,s=n==="win32"?"Commit":"Swap",o=t&&t.total>0?t.used/t.total*100:0;return a.jsx("div",{className:"sd-section",role:"group","aria-label":"Memory",children:a.jsxs(ac,{group:"memory",title:"Memory history",action:"Show memory history",label:"Memory",children:[a.jsx(Od,{label:"Physical",value:a.jsxs(a.Fragment,{children:[a.jsx("b",{children:Qs(r)})," of ",Qs(e.total)]}),pct:e.usedPct,tone:e.usedPct>=90?"warn":"calm",note:`${Qs(e.available)} available`}),t&&t.total>0&&a.jsx(Od,{label:s,value:a.jsxs(a.Fragment,{children:[a.jsx("b",{children:Qs(t.used)})," of ",Qs(t.total)]}),pct:o,tone:o>=90?"warn":"calm"})]})})}function EV({thermal:e}){if(!e)return null;const t=e.throttle?H9(e.throttle,e.heldBack):null;return a.jsx("div",{className:"sd-section",role:"group","aria-label":"Thermal",children:a.jsxs(ac,{group:"thermal",title:"Thermal history",action:"Show thermal history",label:"Thermal",children:[e.celsius.map(n=>a.jsx(Od,{label:n.label,value:a.jsxs(a.Fragment,{children:[a.jsx("b",{children:n.celsius})," °C"]}),pct:n.celsius/n.critAt*100,mark:n.warnAt/n.critAt*100,tone:W9(n.celsius,n.warnAt,n.critAt),title:`bar runs 0–${n.critAt} °C · amber from ${n.warnAt} °C, red at ${n.critAt} °C`,trackLabel:`${n.celsius} °C on a bar that runs to ${n.critAt} °C, amber from ${n.warnAt} °C`},n.label)),t&&a.jsx(Od,{label:"Throttling",value:a.jsx("b",{children:t.value}),pct:t.pct,tone:t.tone,note:t.note})]})})}function CV({sys:e}){const[t,n]=y.useState(!1);return a.jsxs("div",{className:"sd-section sd-door-section",children:[a.jsx("button",{type:"button",className:"sd-open sd-door",onClick:()=>n(!0),"aria-label":"Busiest processes: show every process the deck is watching",children:a.jsxs("span",{className:"sd-door-plate",children:[a.jsxs("span",{className:"sd-door-name",children:["Busiest processes",a.jsx("i",{className:"sd-row-more","aria-hidden":!0,children:"›"})]}),a.jsx("span",{className:"sd-door-sub",children:"every process, with its command line"})]})}),t&&a.jsx(gV,{sys:e,onClose:()=>n(!1)})]})}function Ok(e){const t={inputTokens:e.i,outputTokens:e.o,cacheReadTokens:e.cr,cacheCreateTokens:e.cc,cacheCreate1hTokens:e.c1h,cacheCreate5mTokens:e.c5m},n=e.s?Object.entries(e.s):[];return n.length>0&&(t.bySpeed=Object.fromEntries(n.map(([r,s])=>[r,Ok(s)]))),t}function qS(e){const t=r=>({...r,cacheCreate1hTokens:0,cacheCreate5mTokens:0}),n=t(Ok(e));return n.bySpeed&&(n.bySpeed=Object.fromEntries(Object.entries(n.bySpeed).map(([r,s])=>[r,t(s)]))),n}function oO(e){return e.i+e.o+e.cr+e.cc}function iO(e,t){var n;e.i+=t.i,e.o+=t.o,e.cr+=t.cr,e.cc+=t.cc,e.c1h+=t.c1h,e.c5m+=t.c5m;for(const[r,s]of Object.entries(t.s??{}))iO((n=e.s??(e.s={}))[r]??(n[r]={i:0,o:0,cr:0,cc:0,c1h:0,c5m:0}),s);return e}function US(e,t,n){let r=0,s=0,o=0;const l=[];for(const c of lh(e)){if(!la(t,n,c.speed)){const d=c.usage,h=d.inputTokens+d.outputTokens+d.cacheReadTokens+d.cacheCreateTokens;h>0&&(o+=h,l.push(c.speed));continue}r+=Cd(c.usage,t,c.speed,n).total,s+=Cd(c.usage,t,aa,n).total}return{atSpeed:r,atStandard:s,unpriced:o,unpricedSpeeds:l}}function zS(e){let t=0;for(const n of Object.values(e))t+=oO(n);return t}function TV(e){const t=s=>typeof s=="number"&&Number.isFinite(s)?s:0,n=new Map,r=e&&Array.isArray(e.days)?e.days:[];for(const s of r){const o=typeof s.period=="string"?s.period:"",l=Array.isArray(s.modelBreakdowns)?s.modelBreakdowns:[];for(const c of l){const d=typeof c.modelName=="string"?c.modelName:"";if(!o||!/claude/i.test(d)||c.missingPricing===!0)continue;const h=`${o}|${d}`,f=n.get(h),p=f?f.usage:{inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0,cacheCreate1hTokens:0,cacheCreate5mTokens:0};p.inputTokens+=t(c.inputTokens),p.outputTokens+=t(c.outputTokens),p.cacheReadTokens+=t(c.cacheReadTokens),p.cacheCreateTokens+=t(c.cacheCreationTokens),f?f.cost+=t(c.cost):n.set(h,{cost:t(c.cost),usage:p})}}return n}function AV(e,t,n,r=Date.now()){const s=new Map;for(const A of e){const q={},$=B=>{for(const[L,M]of Object.entries(B))iO(q[L]??(q[L]={i:0,o:0,cr:0,cc:0,c1h:0,c5m:0}),M)};for(const B of A.projects)$(B.models);A.unattributed&&$(A.unattributed);for(const[B,L]of Object.entries(q)){if(!L.s)continue;const{atSpeed:M,atStandard:F}=US(qS(L),B,r);if(!(M>0&&F>0))continue;let T=s.get(A.day);T||(T=new Map,s.set(A.day,T)),T.set(B,M/F),T.has(gs(B))||T.set(gs(B),M/F)}}const o=(A,q)=>{const $=s.get(A);return($==null?void 0:$.get(q))??($==null?void 0:$.get(gs(q)))??1},l=new Map;let c=0,d=0;for(const[A,q]of n){const $=A.indexOf("|"),B=A.slice(0,$),L=A.slice($+1),M=ih(q.usage,L,r).total*o(B,L);if(!(M>0&&q.cost>0))continue;c+=q.cost,d+=M;let F=l.get(B);F||(F=new Map,l.set(B,F)),F.set(L,q.cost/M)}const h=d>0,f=(A,q)=>{const $=l.get(A);return($==null?void 0:$.get(q))??($==null?void 0:$.get(gs(q)))??null},p=new Set,g=(A,q)=>{let $=0,B=0;for(const[L,M]of Object.entries(A)){if(la(L,r)){const T=q(L),P=US(T===null?Ok(M):qS(M),L,r);$+=T===null?P.atSpeed:P.atSpeed*T,B+=P.unpriced;for(const O of P.unpricedSpeeds)p.add(`${L} (${O})`);continue}const F=oO(M);F>0&&(B+=F,p.add(L))}return{cost:$,unpriced:B}},v=new Map,j=[];for(const A of e){const q=new Map,$=new Map;let B=0;for(const L of A.projects){const{cost:M,unpriced:F}=g(L.models,P=>f(A.day,P));q.set(L.path,(q.get(L.path)??0)+M),F>0&&$.set(L.path,($.get(L.path)??0)+F),B+=M;let T=v.get(L.path);T||(T={path:L.path,cost:0,tokens:0,unpricedTokens:0},v.set(L.path,T)),T.cost+=M,T.tokens+=zS(L.models),T.unpricedTokens+=F}j.push({day:A.day,total:B,byPath:q,unpricedByPath:$})}const k=[...v.values()].sort((A,q)=>q.cost-A.cost||q.tokens-A.tokens),x=k.reduce((A,q)=>A+q.cost,0),N=k.reduce((A,q)=>A+q.tokens,0),b=k.reduce((A,q)=>A+q.unpricedTokens,0),S=h?c/d:null,E=t?zS(t):0,R=t?g(t,()=>S):{cost:0,unpriced:0},I=R.cost>0||E>0?{cost:R.cost,tokens:E,unpricedTokens:R.unpriced}:null;return{projects:k,totalCost:x,totalTokens:N,unpricedTokens:b,perDay:j,unattributed:I,unpricedModels:[...p].sort(),calibrated:h,reconciled:h&&b===0}}function Br(e,t,n=We){return t>0?e>0?`${n(e)}+`:bs:n(e)}function Xo(e){return e>0?`${st(e)} of these tokens are on an unpriced model, so this is a floor`:void 0}function RV(e){if(e.length===0)return null;const t=e.length===1,n=t?e[0]:`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`;return t?`${n} is ${bs}: this build holds no published rate for it, so its tokens are counted and its dollars are not.`:`${n} are ${bs}: this build holds no published rate for them, so their tokens are counted and their dollars are not.`}const MV={phase:"running"},$V={phase:"failed"},IV={gen:0,report:null,error:null,early:null};function OV(e,t){var n,r;if(t.type!=="start"&&t.gen!==e.gen)return e;switch(t.type){case"start":return{...e,gen:t.gen,error:null,early:null};case"report":{const s=((n=e.early)==null?void 0:n.gen)===t.gen?e.early.cost:MV;return{...e,report:{gen:t.gen,days:t.days,data:t.data,cost:s},early:null}}case"reportFailed":return{...e,report:null,error:t.message,early:null};case"cost":return((r=e.report)==null?void 0:r.gen)===t.gen?{...e,report:{...e.report,cost:t.cost}}:{...e,early:{gen:t.gen,cost:t.cost}}}}function LV(e){var t;return((t=e.report)==null?void 0:t.gen)!==e.gen&&e.error===null}function PV(e){const t=e;return t&&t.ok!==!1?{phase:"ready",range:t}:$V}function DV(e){return`${e.getFullYear()}${String(e.getMonth()+1).padStart(2,"0")}${String(e.getDate()).padStart(2,"0")}`}function FV(e,t,n=Date.now()){const r=t===0?60:t,s=new Date(n),o=lb(r,s),l=DV(s);return{report:`/api/account-projects?num=${e}&days=${t}`,ccusage:`/api/ccusage?since=${o}&until=${l}`}}function BV({num:e,days:t,gen:n,dispatch:r,get:s=(l,c)=>fetch(l,c),now:o=Date.now()}){const l=FV(e,t,o),c={credentials:"same-origin"};s(l.report,c).then(d=>d.ok?d.json():Promise.reject(new Error(`HTTP ${d.status}`))).then(d=>r({type:"report",gen:n,days:t,data:d}),d=>r({type:"reportFailed",gen:n,message:(d==null?void 0:d.message)||"Could not load"})),s(l.ccusage,c).then(d=>d.ok?d.json():null).catch(()=>null).then(d=>r({type:"cost",gen:n,cost:PV(d)}))}async function oo(e,t=500){var r;if(!e)return!1;let n=!1;try{n=await Promise.race([((r=navigator.clipboard)==null?void 0:r.writeText(e).then(()=>!0))??Promise.resolve(!1),new Promise(s=>window.setTimeout(()=>s(!1),t))])}catch{n=!1}if(n)return!0;try{const s=document.createElement("textarea");s.value=e,s.setAttribute("readonly",""),s.style.cssText="position:fixed;top:0;left:0;opacity:0",document.body.appendChild(s),s.select(),n=document.execCommand("copy"),s.remove()}catch{n=!1}return n}function lO(e){return/^[A-Za-z]:[\\/]$/.test(e)?e:e.replace(/[\\/]+$/,"")}function Jp(e){const t=lO(e).replace(/\\/g,"/");return/^[A-Za-z]:\//.test(t)?t.toLowerCase():t}function WS(e){if(!e)return e;const t=lO(e),n=t.match(/^\/(?:Users|home)\/[^/]+(\/.*)?$/);if(n)return`~${n[1]??""}`;const r=t.replace(/\\/g,"/").match(/^[A-Za-z]:\/Users\/[^/]+(\/.*)?$/i);return r?`~${r[1]??""}`:t.replace(/\\/g,"/")}function qV(e,t){const n=Jp(e);let r;for(const s of t){const o=Jp(s.path);!o||o===n||!n.startsWith(`${o}/`)||(!r||Jp(r.path).length<o.length)&&(r=s)}return r==null?void 0:r.label}function db(e){return e===0?"all time":e===1?"today":`the last ${e} days`}function UV(e){return e===1?"No work attributed to this account yet today.":`No work attributed to this account in ${db(e)}.`}function zV(e){return e===1?7:e===7?30:e===30?0:null}function WV(e,t){return e!==1&&t>0}const HV=[{days:1,label:"Today"},{days:7,label:"7d"},{days:30,label:"30d"},{days:0,label:"All"}],Zo=["var(--usage-blue)","var(--usage-teal)","var(--usage-lime)","var(--usage-purple)","var(--usage-indigo)","var(--usage-pink)","var(--usage-orange)","var(--usage-zinc)"],VV="var(--usage-zinc)",Qp=6,GV=1600;function KV(e){const t=We(e),n=/^\$(\d{4,})$/.exec(t);return n?`$${Number(n[1]).toLocaleString("en-US")}`:t}function Gu(e,t){if(t<=0||e<=0)return"0%";const n=e/t*100;return n<.01?"<0.01%":n<1?`${n.toFixed(2)}%`:n<10?`${n.toFixed(1)}%`:`${Math.round(n)}%`}function YV(e){const t=/^\d{4}-(\d{2})-(\d{2})$/.exec(e);return t?`${Number(t[1])}/${Number(t[2])}`:e}function XV(e){const t=Math.max(1,Math.ceil(e/6));return n=>n===0||n===e-1||n%t===0}function em(e){if(!e)return"";try{return new Date(e).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return""}}function ZV({num:e,name:t,onClose:n}){var O,G,K,U;qt("account-projects");const[r,s]=y.useState(1),[o,l]=y.useReducer(OV,IV),c=((O=o.report)==null?void 0:O.data)??null,d=((G=o.report)==null?void 0:G.days)??r,h=((K=o.report)==null?void 0:K.cost.phase)==="ready"?o.report.cost.range:null,f=((U=o.report)==null?void 0:U.cost.phase)==="running",[p,g]=y.useState(null),[v,j]=y.useState(()=>new Set),k=LV(o),x=o.error,[N,b]=y.useState(null),S=y.useRef(void 0),E=y.useRef(!0);y.useEffect(()=>()=>{E.current=!1,window.clearTimeout(S.current)},[]);const R=y.useRef(null),I=ot(n,{focusRef:R}),A=mt(n),q=y.useRef(0);y.useEffect(()=>{const H=++q.current;l({type:"start",gen:H}),g(null),j(new Set),BV({num:e,days:r,gen:H,dispatch:l})},[e,r]);const $=y.useMemo(()=>{const H=Date.now();if(!c)return null;const D=AV(c.daily??[],c.unattributed,TV(h),H),V=oe=>oe.replace(/[\\/]+$/,"").split(/[\\/]/).pop()||oe||"(unknown)",J=new Map;for(const oe of D.projects)J.set(V(oe.path),(J.get(V(oe.path))??0)+1);const W=oe=>{const Ne=V(oe);if((J.get(Ne)??0)<=1)return Ne;const we=oe.replace(/[\\/]+$/,"").split(/[\\/]/).slice(-2,-1)[0];return we?`${we}/${Ne}`:Ne},Z=D.projects.map(oe=>({path:oe.path,label:W(oe.path)})),Y=oe=>({path:oe.path,label:W(oe.path),parentLabel:qV(oe.path,Z),cost:oe.cost,tokens:oe.tokens,unpricedTokens:oe.unpricedTokens}),X=Zo[Qp%Zo.length],ee=new Map,ae=[],ce=D.projects.slice(0,Qp),ge=D.projects.slice(Qp);ce.forEach((oe,Ne)=>{ee.set(oe.path,Zo[Ne%Zo.length]),ae.push({key:oe.path,...Y(oe),color:Zo[Ne%Zo.length]})}),ge.length&&ae.push({key:"__other__",label:`Other · ${ge.length} project${ge.length>1?"s":""}`,cost:ge.reduce((oe,Ne)=>oe+Ne.cost,0),tokens:ge.reduce((oe,Ne)=>oe+Ne.tokens,0),unpricedTokens:ge.reduce((oe,Ne)=>oe+Ne.unpricedTokens,0),color:X,muted:!0,members:ge.map(Y)});const ye=D.totalCost,se=D.totalTokens,pe=ye>0&&D.unpricedTokens===0?"cost":"tokens",fe=pe==="cost"?ye:se,de=ae.map(oe=>oe.color),me=D.perDay.map(oe=>{const Ne=new Map;for(const[Le,Be]of oe.byPath){const Pe=ee.get(Le)??X;Ne.set(Pe,(Ne.get(Pe)??0)+Be)}const we=new Map;let Me=0;for(const[Le,Be]of oe.unpricedByPath){const Pe=ee.get(Le)??X;we.set(Pe,(we.get(Pe)??0)+Be),Me+=Be}return{day:oe.day,total:oe.total,costByColor:Ne,unpricedByColor:we,unpriced:Me}}),ne=me.reduce((oe,Ne)=>Math.max(oe,Ne.total),0);return{projectCount:D.projects.length,rows:ae,totalCost:ye,totalTokens:se,basis:pe,denom:fe,un:D.unattributed,chart:me,maxDay:ne,colorOrder:de,unpricedTokens:D.unpricedTokens,unpricedNote:RV(D.unpricedModels),calibrated:D.calibrated,reconciled:D.reconciled}},[c,h]),B=(H,D)=>{oo(H).then(V=>{E.current&&(window.clearTimeout(S.current),b({path:H,label:D,ok:V}),S.current=window.setTimeout(()=>{E.current&&b(null)},GV))})},L=H=>N!=null&&N.ok&&N.path===H?"Copied":"Copy",M=c!=null&&c.trackedSince?`Tracked since ${em(c.trackedSince)}`:"Tracking starts with this version",F=db(d),T=zV(d),P=k&&!!c;return Pt.createPortal(a.jsx("div",{className:"modal-backdrop",...A,role:"presentation",children:a.jsxs("div",{ref:I,className:"modal ap-proj-modal",onClick:H=>H.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ap-proj-title ap-proj-sub",children:[a.jsxs("header",{className:"ap-proj-head",children:[a.jsxs("div",{className:"ap-proj-titlewrap",children:[a.jsx("div",{className:"ap-proj-title",id:"ap-proj-title",children:"Projects"}),a.jsx("div",{className:"ap-proj-sub",id:"ap-proj-sub",title:t,children:t})]}),a.jsx("div",{className:"uh-range",role:"group","aria-label":"Range",children:HV.map(H=>a.jsx("button",{type:"button",className:"uh-range-btn","aria-pressed":r===H.days,onClick:()=>s(H.days),children:H.label},H.days))}),a.jsx("button",{ref:R,className:"glyph-btn ap-proj-close",onClick:n,"aria-label":"Close",children:"×"})]}),a.jsxs("div",{className:`ap-proj-body${P?" refreshing":""}`,"aria-busy":k,children:[k&&!c&&a.jsx("div",{className:"ap-proj-state",children:"Loading…"}),!k&&x&&a.jsxs("div",{className:"ap-proj-state ap-proj-error",children:["Couldn’t load this report: ",x]}),!x&&$&&a.jsx(a.Fragment,{children:$.rows.length===0?a.jsxs("div",{className:"ap-proj-state",children:[P?"Updating…":UV(d),T!=null&&a.jsx("div",{className:"ap-proj-widen-wrap",children:a.jsxs("button",{type:"button",className:"ap-proj-copy",onClick:()=>s(T),children:["Show ",db(T)]})}),a.jsxs("div",{className:"ap-proj-note",children:[M,". Only work from this version onward can be tied to an account."]})]}):a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"ap-proj-bar",role:"img","aria-label":`Share of ${$.basis==="cost"?We($.totalCost):`${st($.totalTokens)} tokens`} across ${$.projectCount} project${$.projectCount>1?"s":""}`,children:$.rows.map(H=>{const D=$.basis==="cost"?H.cost:H.tokens,V=$.denom>0?D/$.denom*100:0;if(V<=0)return null;const J=$.basis==="cost"?Gu(H.cost,$.totalCost):`${Gu(H.tokens,$.totalTokens)} of tokens`;return a.jsx("span",{className:"ap-proj-seg",style:{width:`${V}%`,background:H.color},title:`${H.label} · ${Br(H.cost,H.unpricedTokens)} · ${J}${H.tokens?` · ${st(H.tokens)} tokens`:""}`},H.key)})}),a.jsxs("div",{className:"ap-proj-totals",children:[a.jsx("span",{className:"ap-proj-total-cost",title:Xo($.unpricedTokens),children:Br($.totalCost,$.unpricedTokens)}),a.jsxs("span",{className:"ap-proj-total-tok",children:[st($.totalTokens)," tokens"]}),a.jsxs("span",{className:"ap-proj-total-win",children:["· ",P?"updating…":F]}),f&&a.jsx("span",{className:"ap-proj-total-pending",children:"Reconciling cost…"})]}),$.unpricedNote&&a.jsx("div",{className:"ap-proj-note",children:$.unpricedNote}),WV(d,$.chart.length)&&a.jsxs("div",{className:"ap-proj-days",children:[a.jsxs("div",{className:"ap-proj-days-cap",children:["By day",$.chart.length>1?" · click a bar":""]}),a.jsx("div",{className:"ap-proj-days-plot",role:"group","aria-label":`Spend across ${$.chart.length} day${$.chart.length>1?"s":""}`,children:$.chart.map(H=>{const D=$.maxDay>0?H.total/$.maxDay*100:0,V=p===H.day,J=$.rows.map(Z=>({label:Z.label,c:H.costByColor.get(Z.color)??0,u:H.unpricedByColor.get(Z.color)??0})).filter(Z=>Z.c>0||Z.u>0),W=`${em(Date.parse(`${H.day}T00:00:00`))}, ${Br(H.total,H.unpriced)}. ${J.map(Z=>`${Z.label} ${Br(Z.c,Z.u)}`).join(", ")}`;return a.jsx("button",{type:"button",className:`ap-proj-day${V?" selected":""}`,"aria-pressed":V,"aria-label":W,title:`${H.day} · ${Br(H.total,H.unpriced)}`,onClick:()=>g(Z=>Z===H.day?null:H.day),children:a.jsx("span",{className:"ap-proj-col",style:{height:`${D}%`},children:$.colorOrder.map((Z,Y)=>{const X=H.costByColor.get(Z)??0;return X<=0||H.total<=0?null:a.jsx("span",{className:"ap-proj-colseg",style:{height:`${X/H.total*100}%`,background:Z}},Y)})})},H.day)})}),(()=>{const H=XV($.chart.length);return a.jsx("div",{className:"ap-proj-days-axis","aria-hidden":"true",children:$.chart.map((D,V)=>a.jsx("div",{className:"ap-proj-axis-cell",children:H(V)?YV(D.day):""},D.day))})})(),(()=>{const H=p?$.chart.find(V=>V.day===p):null;if(!H)return null;const D=$.rows.map(V=>({r:V,c:H.costByColor.get(V.color)??0,u:H.unpricedByColor.get(V.color)??0})).filter(V=>V.c>0||V.u>0);return a.jsxs("div",{className:"ap-proj-day-detail",children:[a.jsxs("div",{className:"ap-proj-day-detail-head",children:[a.jsx("span",{children:em(Date.parse(`${H.day}T00:00:00`))}),a.jsx("span",{className:"ap-proj-day-detail-total",title:Xo(H.unpriced),children:Br(H.total,H.unpriced)})]}),D.map(({r:V,c:J,u:W})=>a.jsxs("div",{className:"ap-proj-day-detail-row",children:[a.jsx("span",{className:"ap-proj-dot",style:{background:V.color},"aria-hidden":"true"}),a.jsx("span",{className:"ap-proj-day-detail-name",children:V.label}),a.jsx("span",{className:"ap-proj-day-detail-cost",title:Xo(W),children:Br(J,W)})]},V.key))]})})()]}),a.jsx("ul",{className:"ap-proj-list",children:$.rows.map((H,D)=>{const V=$.basis==="cost"?H.cost:H.tokens,J=$.denom>0?V/$.denom*100:0,W=v.has(H.key),Z=`ap-proj-details-${D}`,Y=W&&(!!H.path||!!H.members),X=H.members?`${W?"Hide":"Show"} the ${H.members.length} project${H.members.length>1?"s":""} folded into Other`:`${W?"Hide":"Show"} location for ${H.label}`;return a.jsxs("li",{className:`ap-proj-row${H.muted?" muted":""}${W?" expanded":""}`,children:[a.jsx("span",{className:"ap-proj-dot",style:{background:H.color},"aria-hidden":"true"}),a.jsxs("span",{className:"ap-proj-name",children:[H.label,H.parentLabel&&a.jsxs("span",{className:"ap-proj-parent",children:[" · in ",H.parentLabel]})]}),a.jsx("span",{className:"ap-proj-track",title:$.basis==="cost"?`${Gu(H.cost,$.totalCost)} of tracked cost`:`${Gu(H.tokens,$.totalTokens)} of tracked tokens`,children:a.jsx("span",{className:"ap-proj-fill",style:{width:`${J}%`,background:H.color}})}),a.jsx("span",{className:"ap-proj-cost",title:Xo(H.unpricedTokens),children:Br(H.cost,H.unpricedTokens)}),a.jsx("span",{className:"ap-proj-tok",children:st(H.tokens)}),a.jsx("button",{type:"button",className:"glyph-btn ap-proj-info","aria-expanded":W,"aria-controls":Y?Z:void 0,"aria-label":X,onClick:()=>j(ee=>{const ae=new Set(ee);return ae.has(H.key)?ae.delete(H.key):ae.add(H.key),ae}),children:"ⓘ"}),W&&H.path&&a.jsxs("div",{className:"ap-proj-details",id:Z,children:[a.jsx("code",{className:"ap-proj-path",children:WS(H.path)}),a.jsx("button",{type:"button",className:"ap-proj-copy","aria-label":`${L(H.path)} location for ${H.label}`,onClick:()=>B(H.path,H.label),children:L(H.path)})]}),W&&H.members&&a.jsx("div",{className:"ap-proj-details ap-proj-other-members",id:Z,children:H.members.map(ee=>a.jsxs("div",{className:"ap-proj-other-member",children:[a.jsxs("div",{className:"ap-proj-other-name",children:[ee.label,ee.parentLabel&&a.jsxs("span",{className:"ap-proj-parent",children:[" · in ",ee.parentLabel]})]}),a.jsx("code",{className:"ap-proj-path",children:WS(ee.path)}),a.jsx("span",{className:"ap-proj-cost",title:Xo(ee.unpricedTokens),children:Br(ee.cost,ee.unpricedTokens)}),a.jsx("span",{className:"ap-proj-tok",children:st(ee.tokens)}),a.jsx("button",{type:"button",className:"ap-proj-copy","aria-label":`${L(ee.path)} location for ${ee.label}`,onClick:()=>B(ee.path,ee.label),children:L(ee.path)})]},ee.path))})]},H.key)})}),$.un&&a.jsxs("div",{className:"ap-proj-unattributed",children:[a.jsx("span",{className:"ap-proj-dot",style:{background:VV},"aria-hidden":"true"}),a.jsxs("div",{className:"ap-proj-un-labels",children:[a.jsx("span",{className:"ap-proj-un-title",children:"Unattributed usage"}),a.jsx("span",{className:"ap-proj-un-tag",children:"Excluded from the project totals"})]}),a.jsx("span",{className:"ap-proj-un-cost",title:Xo($.un.unpricedTokens),children:Br($.un.cost,$.un.unpricedTokens,KV)}),a.jsx("span",{className:"ap-proj-un-tok",children:st($.un.tokens)}),a.jsx("div",{className:"ap-proj-note",children:"Work no account could be tied to — from before tracking, or a gap."})]}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:N&&(N.ok?`Copied the location of ${N.label}`:`Could not copy the location of ${N.label} — select it and copy it by hand`)}),a.jsxs("div",{className:"ap-proj-foot",children:[f?"Dollars estimated · ccusage still running":$.reconciled?"Dollars from ccusage · split by activity":$.calibrated?"Dollars from ccusage for the priced models · split by activity":h?"Dollars estimated · ccusage could not price this window":"Dollars estimated · ccusage unavailable"," · ",M]})]})})]})]})}),document.body)}function Si(e,t){return AI(t-Math.floor(e/1e3))}function JV(e,t){if(!e)return"";const n=Math.floor(e/1e3)-t;return n<=0?" · due":n<60?` · next in ${n}s`:` · next in ${Math.round(n/60)}m`}function Lk(){return a.jsxs("svg",{className:"ap-warn-glyph",width:"12",height:"12",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("path",{d:"M7 1.9 12.9 12H1.1Z"}),a.jsx("path",{d:"M7 5.6v2.9"}),a.jsx("path",{d:"M7 10.3v.05"})]})}function QV({anchorId:e,boundaryId:t,issue:n,who:r,fetchedAt:s,nowSec:o,onClose:l,onSignIn:c,onReport:d}){const h=y.useRef(null);return a.jsx(Nh,{anchorId:e,boundaryId:t,id:"ap-issue-pop",className:"ap-pop ap-issue-pop",role:"dialog",labelledBy:"ap-issue-title",focusRef:h,onClose:()=>l(),children:a.jsxs("div",{className:"ap-pop-form",children:[a.jsxs("p",{className:"ap-pop-title ap-issue-title",id:"ap-issue-title","data-tone":n.tone,children:[n.tone==="warn"&&a.jsx(Lk,{}),n.text]}),a.jsx("p",{className:"ap-pop-note ap-issue-hint",children:n.hint}),a.jsxs("p",{className:"ap-pop-note ap-issue-when",children:[a.jsx("span",{className:"ap-issue-who",children:r})," · ",s?`last collected ${Si(s,o)}`:"never collected"]}),a.jsxs("div",{className:"ap-pop-actions",children:[d&&a.jsx("button",{type:"button",className:"ap-issue-report",onClick:()=>{l(),d()},children:"Report this"}),a.jsx("button",{type:"button",ref:h,className:"btn",onClick:()=>l(!0),children:"Done"}),n.fix&&a.jsx("button",{type:"button",className:"btn primary",onClick:()=>{l(!0),c()},title:"Open the sign-in dialog. Signing in as this account puts its login back in this slot — it keeps its slot, its alias and its history.",children:n.fix})]})]})})}function Ml(e){return e.charAt(0).toUpperCase()+e.slice(1)}function eG(e,t){const n="The deck can still see this account — its live usage is being read — but claude-swap's own stored copy of the login was rejected, so these numbers stopped updating.";if((e==null?void 0:e.state)==="running")return{text:"resuming…",hint:`${n} The deck is re-capturing it from the login you already have. No sign-in, no switch.`};if((e==null?void 0:e.state)==="failed"){const r=Math.max(1,Math.ceil((e.retryAt/1e3-t)/60)),s=e.reason?`Re-capturing it from the login you already have did not work (${e.reason}).`:"The deck re-captured it from the login you already have, and claude-swap still cannot read it.";return{text:"numbers paused",hint:`${n} ${s} It tries again in ${r}m. No sign-in, no switch.`}}return{text:"numbers paused",hint:n}}function tG(e){switch(e){case"invalid_grant":case"no_refresh_token":return{text:"login expired",hint:"claude-swap's stored login for this account was rejected and cannot be refreshed. Signing in again replaces it — the account keeps its slot, its alias and its history.",fixable:!0};case"http-401":return{text:"re-login needed",hint:"Anthropic refused this account's token.",fixable:!0};case"http-429":return{text:"rate limited",hint:"Anthropic is throttling requests for this account. It clears on its own.",fixable:!1};case"transient":return{text:"temporary error",hint:"A network or server hiccup while reading usage. The next collection retries.",fixable:!1};case"timeout":return{text:"timed out",hint:"Reading this account's usage took too long. The next collection retries.",fixable:!1};case"network":return{text:"unreachable",hint:"Could not reach Anthropic to read this account's usage.",fixable:!1};default:return{text:e,hint:`claude-swap reported "${e}" for this account.`,fixable:!1}}}function nG(e){switch(e){case"no_credentials":return{text:"no stored login",hint:"claude-swap holds no credentials for this account, so there is nothing to read its usage with and nothing to switch to. A paired deck that has them sends them on its own; signing in as this account puts them there by hand.",fix:"sign in"};case"relogin_required":return{text:"login expired",hint:"claude-swap's stored login for this account was rejected and cannot be refreshed. Signing in again replaces it — the account keeps its slot, its alias and its history.",fix:"sign in again"};case"keychain_unavailable":return{text:"keychain unreadable",hint:"This is about the deck, not the account: claude-swap could not open your keychain, so it cannot read any account's stored login. A deck started from a background session cannot reach the keychain at all — start it from a terminal, or let it start at login, and this clears."};case"token_expired":return{text:"token expired",hint:"The access token ran out and the refresh was deferred. The next collection retries."};case"foreign_credential":return{text:"wrong credential",hint:"The live credential belongs to a different account. Switching to this one repairs it."};case null:case void 0:return null;default:return{text:e,hint:`claude-swap reported "${e}" for this account.`}}}const HS={text:"Login expired on all online decks",hint:"Every paired deck online right now that shares this account holds a copy that has expired too, so none of them can repair this one. Claude retires a login's other copies each time one machine refreshes it, which is how shared copies expire together. Sign in again on any one machine that shares it; the others repair from it on their next round."};function _i(e,t,n){const r=sG(e,t);return!r||!(n!=null&&n.noCopyWorksNearby)||!rG(e)?r:{...r,text:HS.text,hint:HS.hint}}function rG(e){return e.staleCopy?!1:e.stopped?e.collector==="relogin_required":e.error==="invalid_grant"||e.error==="no_refresh_token"}function sG(e,t){if(e.staleCopy){const n=eG(e.repair??null,t);return{text:Ml(n.text),hint:n.hint,fix:null,tone:"quiet",blocksSwitch:!1}}if(e.stopped){const n=nG(e.collector??null);if(!n)return{text:"Not collecting",hint:"claude-swap has collected nothing for this account in over half a day and has not said why. A paired deck holding a working copy of this account will replace it on its own. To do it by hand, sign in as this account from + Add.",fix:null,tone:"quiet",blocksSwitch:!1};const r=e.collector==="no_credentials"||e.collector==="relogin_required";return{text:Ml(n.text),hint:n.hint,fix:n.fix?Ml(n.fix):null,tone:r||e.collector==="keychain_unavailable"?"warn":"quiet",blocksSwitch:r}}if(e.error){const n=tG(e.error);return{text:Ml(n.text),hint:n.hint,fix:n.fixable?"Sign in again":null,tone:n.fixable?"warn":"quiet",blocksSwitch:n.fixable}}return null}function VS(e){return typeof e.id=="string"&&e.id.startsWith("scoped-")}function GS(e){const t=e.filter(c=>!VS(c)),n=e.filter(c=>VS(c)),r=t.length?t:n,s=t.length?n:[],o=r.reduce((c,d)=>c&&c.pct>=d.pct?c:d,null);let l=null;for(const c of s)o&&c.pct<=o.pct||(!l||c.pct>l.pct)&&(l=c);return{shown:r,rest:s,fuller:l,peak:l??o}}function oc(e,t){return!!e.resetAt&&e.resetAt<=t}function Pk(e,t){const n=e.lanes??[],r=n.filter(s=>!oc(s,t));return r.length===n.length?e.headroom:r.length?Math.max(0,100-Math.max(...r.map(s=>s.pct))):null}const aG="\0";function Ur(e){const t=typeof e.email=="string"?e.email.trim():"";if(!t)return`slot:${e.num}`;const n=typeof e.org=="string"?e.org.trim():"";return`acct:${t}${aG}${n}`}function oG(e,t,n=Ur){const r=n(t);return e.includes(r)?e.filter(s=>s!==r):[...e,r]}const jh="slot",Dk=[{lane:"five_hour",name:"5h"},{lane:"seven_day",name:"7d"}],cO=e=>e.id.startsWith("scoped-");function iG(e){var t;return((t=Dk.find(n=>n.lane===e.id))==null?void 0:t.name)??e.label}function lG(e){if(e==="room")return"room";const t=/^(.+):(full|empty)$/.exec(e);return t?t[1]:null}function uO(e){const t=[...new Set(e.flatMap(r=>(r.lanes??[]).filter(cO).map(s=>s.label)))].sort((r,s)=>r.localeCompare(s)),n=[...Dk.map(r=>r.name),...t];return[{id:jh,label:"Slot"},...n.flatMap(r=>[{id:`${r}:full`,label:`${r} · fullest`},{id:`${r}:empty`,label:`${r} · emptiest`}]),{id:"room",label:"Most room"}]}function KS(e,t,n){const r=Dk.find(o=>o.name===t),s=(e.lanes??[]).find(o=>r?o.id===r.lane:cO(o)&&o.label===t);return s&&n!=null&&oc(s,n)?null:s&&Number.isFinite(s.pct)?s.pct:null}function cG(e,t,n=()=>!0,r){const s=[...e],o=f=>[...f.filter(n),...f.filter(p=>!n(p))];if(t==="room"){const f=p=>r==null?p.headroom:Pk(p,r);return o(YS(s,p=>{const g=f(p);return Number.isFinite(g)?g:null},"desc"))}const l=/^(.+):(full|empty)$/.exec(t);if(!l)return s;const[,c,d]=l;if(!s.some(f=>KS(f,c,r)!=null))return s;const h=YS(s,f=>KS(f,c,r),d==="full"?"desc":"asc");return d==="empty"?o(h):h}function YS(e,t,n){const r=e.filter(o=>t(o)!=null),s=e.filter(o=>t(o)==null);return r.sort((o,l)=>n==="desc"?t(l)-t(o):t(o)-t(l)),[...r,...s]}function uG(e,t){return uO(t).some(n=>n.id===e)?e:jh}function hb(e,t){if(!t)return[...e];const n=new Map(t.map((o,l)=>[o,l])),r=e.filter(o=>n.has(Ur(o))).sort((o,l)=>n.get(Ur(o))-n.get(Ur(l))),s=e.filter(o=>!n.has(Ur(o)));return[...r,...s]}function Fk(e){const t=Ur(e);return t.startsWith("slot:")?t:`h:${dG(t)}`}function dG(e){let t=3735928559,n=1103547991;for(let r=0;r<e.length;r++){const s=e.charCodeAt(r);t=Math.imul(t^s,2654435761),n=Math.imul(n^s,1597334677)}return t=Math.imul(t^t>>>16,2246822507)^Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507)^Math.imul(t^t>>>13,3266489909),(4294967296*(2097151&n)+(t>>>0)).toString(36)}const fb={mode:"some",keys:[]};function dO(e,t){const n=e.keys.includes(Fk(t));return e.mode==="all"?!n:n}function hG(e,t){return{mode:e.mode,keys:oG(e.keys,t,Fk)}}function hO(e,t){return t.length>0&&t.every(n=>dO(e,n))}function fG(e,t){return hO(e,t)?fb:{mode:"all",keys:[]}}function pG(e,t){if(!Array.isArray(t))return e;const n=new Set(t.map(Fk)),r=e.keys.filter(s=>n.has(s));return r.length===e.keys.length?e:{mode:e.mode,keys:r}}function mG(e){return e>=90?"hi":e>=70?"mid":void 0}function gG({lane:e,nowSec:t,frozen:n,sortedBy:r}){const s=Math.min(100,Math.max(0,e.pct)),o=oc(e,t),l=n||o,c=l?"var(--muted)":s>=90?"var(--err)":s>=70?"var(--warn)":"var(--accent)",d=e.resetAt&&!l?gh(e.resetAt,t):null;return a.jsxs("div",{className:"ap-lane","data-sort-key":r?"":void 0,children:[a.jsx("span",{className:"ap-lane-label",title:e.label,children:e.label}),a.jsx("div",{className:"ap-lane-track",children:a.jsx("div",{className:"ap-lane-fill",style:{width:`${s===0?1.5:s}%`,background:c,opacity:s===0||l?.4:1}})}),a.jsxs("span",{className:"ap-lane-pct",style:{color:c},children:[Math.round(s),"%"]}),a.jsxs("span",{className:"ap-lane-reset",title:d?`${e.label} resets in ${d}`:o&&!n?`${e.label} has reset since this reading`:void 0,children:[d&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"vis-hidden",children:"resets in "}),d]}),o&&!n&&"reset"]})]})}function yG({a:e,nowSec:t,lan:n,opened:r,onToggleLanes:s,busy:o,pressProps:l,onSwitch:c,menuOpen:d,onOpenMenu:h,onCloseMenu:f,refusal:p,onDismissRefusal:g,switchedHere:v,swapped:j,displaced:k,issueExpanded:x,onOpenIssue:N,sortKey:b=null}){const S=e.lanes.filter(T=>!oc(T,t)),{shown:E}=GS(e.lanes),{fuller:R}=GS(S),I=b==="room"?S.reduce((T,P)=>T&&T.pct>=P.pct?T:P,null):b?e.lanes.find(T=>iG(T)===b)??null:null,A=_i(e,t,n),q=e.active||r,$=e.alias??e.email??`account ${e.num}`,B=e.alias&&e.email?`${e.alias} · ${e.email}`:$,L=e.stale||(A==null?void 0:A.blocksSwitch)===!0,M=R?[...E,R]:E,F=e.fetchedAt?Si(e.fetchedAt,t):null;return a.jsxs("li",{className:`ap-account${e.active?" active":""}`,"aria-current":e.active?"true":void 0,"data-open":q?"":void 0,"data-frozen":L?"":void 0,children:[!e.active&&a.jsx("button",{type:"button",className:"ap-row-open",id:`ap-row-${e.num}`,title:B,"aria-expanded":q,"aria-controls":q?`ap-detail-${e.num}`:void 0,"aria-describedby":[e.alias&&e.email?`ap-email-${e.num}`:null,!q&&!(A!=null&&A.blocksSwitch)?`ap-quota-${e.num}`:null].filter(Boolean).join(" ")||void 0,onClick:()=>s(),children:a.jsxs("span",{className:"vis-hidden",children:[$,", ",q?"hide details":"details"]})}),a.jsxs("div",{className:"ap-account-head",children:[e.active?a.jsx("span",{className:"ap-live",title:`Active account · slot ${e.num}`,children:a.jsxs("span",{className:"vis-hidden",children:["Active account, slot ",e.num,":"]})}):a.jsx("span",{className:"ap-num",children:e.num}),e.alias&&a.jsx("span",{className:"ap-alias",title:e.alias,children:e.alias}),a.jsx("span",{className:"ap-email",id:`ap-email-${e.num}`,title:e.email??void 0,children:e.email}),e.disabled&&a.jsx("span",{className:"ap-held",children:"held out"}),!e.active&&!e.disabled&&!(A!=null&&A.blocksSwitch)&&a.jsx("button",{type:"button",className:"ap-switch",...l(`switch-${e.num}`),onClick:()=>c(e.num,$),"aria-label":`Switch to ${$}`,title:`Switch to ${e.alias??e.email}`,children:o===`switch-${e.num}`?"…":"Switch"}),a.jsx("button",{type:"button",id:`ap-more-${e.num}`,className:"ap-more","aria-label":`More actions for ${e.email??e.alias??`account ${e.num}`}`,"aria-haspopup":"menu","aria-expanded":d,"aria-controls":d?`ap-menu-${e.num}`:void 0,title:"More actions",onClick:()=>d?f():h(e.num),onKeyDown:T=>{T.key!=="ArrowDown"&&T.key!=="ArrowUp"||(T.preventDefault(),h(e.num,T.key==="ArrowUp"?"last":"first"))},children:a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"currentColor","aria-hidden":!0,children:[a.jsx("circle",{cx:"2.8",cy:"7",r:"1.15"}),a.jsx("circle",{cx:"7",cy:"7",r:"1.15"}),a.jsx("circle",{cx:"11.2",cy:"7",r:"1.15"})]})})]}),p&&a.jsxs("div",{className:"ap-failure ap-row-failure",role:"alert",children:[a.jsx("span",{className:"ap-failure-text",title:p.raw||void 0,children:p.text}),a.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>g(),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),e.active&&v&&a.jsx("p",{className:"ap-switched",children:"Now active. New sessions start on it; ones already running pick it up on their next message, up to about 30 seconds later on macOS."}),j&&(()=>{const T=(k==null?void 0:k.alias)??(k==null?void 0:k.email)??"the account that was there";return a.jsxs("p",{className:"ap-note ap-swap-note",title:`Slot ${j.at} was taken, so the two accounts traded places: ${T} now holds slot ${j.displaced}.`,children:["swapped with slot ",j.displaced]})})(),A&&a.jsxs("div",{className:"ap-issue-line",children:[a.jsxs("button",{type:"button",id:`ap-issue-${e.num}`,className:"ap-issue","data-tone":A.tone,"aria-haspopup":"dialog","aria-expanded":x,"aria-controls":x?"ap-issue-pop":void 0,onClick:()=>N(e.num,`ap-issue-${e.num}`),children:[A.tone==="warn"&&a.jsx(Lk,{}),a.jsx("span",{className:"ap-issue-text",children:A.text})]}),!q&&a.jsx("span",{className:"ap-issue-age",title:"When claude-swap last read this account's usage",children:F??"never collected"})]}),!q&&!(A!=null&&A.blocksSwitch)&&a.jsxs("p",{className:"ap-quota",id:`ap-quota-${e.num}`,children:[M.length?M.map(T=>a.jsxs("span",{className:"ap-q","data-sort-key":T.id===(I==null?void 0:I.id)?"":void 0,children:[a.jsx("span",{className:"ap-q-label",children:T.label})," ",oc(T,t)?a.jsx("span",{className:"ap-q-pct",title:`${T.label} has reset since this reading`,children:"reset"}):a.jsxs("span",{className:"ap-q-pct","data-level":L?void 0:mG(T.pct),children:[Math.round(T.pct),"%"]})]},T.id)):a.jsx("span",{className:"ap-q-label",children:"no usage recorded yet"}),e.stale&&!A&&a.jsx("span",{className:"ap-q-age","data-never":F?void 0:"",title:"When claude-swap last read this account's usage",children:F??"never collected"})]}),q&&a.jsxs("div",{className:"ap-detail",id:`ap-detail-${e.num}`,children:[a.jsx("div",{className:"ap-lanes",children:e.lanes.length?e.lanes.map(T=>a.jsx(gG,{lane:T,nowSec:t,frozen:L,sortedBy:T.id===(I==null?void 0:I.id)},T.id)):a.jsx("div",{className:"ap-hint",children:"No usage recorded yet."})}),a.jsx("div",{className:"ap-meta",children:e.fetchedAt?a.jsxs("span",{className:`ap-age${e.stale&&!A?" ap-stale":""}`,title:"When claude-swap last read this account's usage, and when it plans to read it again. It sets that interval itself — 3 minutes at the fastest, wider while an account is recovering from a rate limit — and every surface, including `cswap watch`, follows the same plan.",children:["collected ",Si(e.fetchedAt,t),A!=null&&A.blocksSwitch?"":JV(e.nextAt,t)]}):a.jsx("span",{className:"ap-age ap-stale",title:"claude-swap has not read this account yet",children:"never collected"})})]})]})}function wG({data:e}){return a.jsx("div",{className:"ap-empty",children:e.reason==="cswap_installing"?a.jsxs(a.Fragment,{children:[a.jsx("span",{children:"Installing claude-swap…"}),a.jsx("span",{className:"ap-hint",children:"The deck is setting it up in the background, so there is nothing to do here. On a new machine this can take a few minutes; the panel fills in by itself when it is done."})]}):e.reason==="no_cswap"?a.jsxs(a.Fragment,{children:[a.jsx("span",{children:"claude-swap isn't installed."}),a.jsx("span",{className:"ap-hint",children:"This panel reads the account store claude-swap keeps — without it there is nothing to show. It is a separate tool, published on PyPI, so it does not come with this package."}),e.hint&&a.jsx("code",{className:"ap-cmd",children:e.hint}),a.jsxs("span",{className:"ap-hint",children:["Then add an account with the ",a.jsx("strong",{children:"+"})," button above."]})]}):e.reason==="cswap_refused"?a.jsxs(a.Fragment,{children:[a.jsx("span",{children:"claude-swap was installed, but not the version the deck asked for."}),a.jsxs("span",{className:"ap-hint",children:[e.version?`v${e.version} answered`:"A different version answered",e.want?` where ${e.want} was asked for`:"",", so the deck is not driving it. Install the version it asked for, or set AGENTS_DECK_CSWAP to a claude-swap you trust."]})]}):e.reason==="no_accounts"?a.jsxs(a.Fragment,{children:[a.jsx("span",{children:"No accounts added yet."}),a.jsxs("span",{className:"ap-hint",children:["claude-swap is installed but has nothing in its store. Use the ",a.jsx("strong",{children:"+"})," above to sign one in, or to paste one shared from another deck."]})]}):a.jsxs(a.Fragment,{children:[a.jsx("span",{children:"Couldn't read the account store."}),a.jsxs("span",{className:"ap-hint",children:["claude-swap is installed, but its store could not be read",e.reason?` (${e.reason})`:"","."]})]})})}function vG({canShare:e,canReport:t,onAdd:n,onReport:r,onShareSet:s,onReload:o,pressProps:l,reloading:c,closeButton:d}){return a.jsxs("div",{className:"ap-header",children:[a.jsx("h2",{children:"Claude accounts"}),a.jsxs("div",{className:"ap-header-right",children:[a.jsx("button",{type:"button",className:"glyph-btn ap-add",onClick:()=>n(),"aria-label":"Add an account",title:"Sign in to another Claude account, or paste one shared from another deck",children:a.jsx("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":!0,children:a.jsx("path",{d:"M7 2.2v9.6M2.2 7h9.6"})})}),t&&a.jsx("button",{type:"button",className:"glyph-btn",onClick:()=>r(),"aria-label":"Account capacity","aria-haspopup":"dialog",title:"Account capacity — how many accounts are ready, and what the 5h and 7d windows have left",children:a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":!0,children:[a.jsx("path",{d:"M2.5 10.9A5.2 5.2 0 1 1 11.5 10.9"}),a.jsx("path",{d:"M7 8.3l2.1-2.1"})]})}),e&&a.jsx("button",{type:"button",className:"glyph-btn",onClick:()=>s(),"aria-label":"Share accounts with another deck",title:`Copy several accounts to another ${xt} in one paste. The text carries a live login for each one — treat it as those passwords.`,children:a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("path",{d:"M3.3 10.7L10.7 3.3"}),a.jsx("path",{d:"M5.5 3.3h5.2v5.2"})]})}),a.jsx("button",{type:"button",className:"glyph-btn ap-refresh",onClick:()=>o(),...l("reload",c),"aria-label":"Reload accounts",title:"Reload from claude-swap",children:a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("path",{d:"M11.6 6.2A4.8 4.8 0 1 0 11 9.6"}),a.jsx("path",{d:"M11.9 2.6v3.7h-3.6"})]})}),d]})]})}const Xa=[{id:"five_hour",label:"5h",long:"5-hour"},{id:"seven_day",label:"7d",long:"7-day"}];function XS(e){return e.counted?e.pct:e.why==="login"?null:e.estimate}function xG(e){const t=XS(e.five_hour),n=XS(e.seven_day);if(t==null||n==null)return"stale";const r=+(t>=100)+ +(n>=100);return r===0?"ready":r===1?"limited":"exhausted"}function bG(e,t){const n=Xa.map(r=>e.cells[r.id]);for(const r of n)if(!r.counted&&(r.why==="login"||r.why==="none"))return{text:r.say,old:!0};return e.updatedAt==null?{text:"never read",old:!0}:n.every(r=>r.counted)?{text:"now",old:!1}:{text:Si(e.updatedAt,t),old:!0}}const kG=15*6e4,NG=e=>e.alias??e.email??`account ${e.num}`;function ZS(e,t,n){const r=Xa.find(f=>f.id===t).label,s=(e.lanes??[]).find(f=>f.id===t),o=s&&Number.isFinite(s.pct)?jG(s.pct):null,l=_i(e,n),c=(s==null?void 0:s.resetAt)!=null&&s.resetAt<=n,d=(f,p)=>({counted:!1,why:f,say:p,last:o,estimate:o==null?null:c?0:o,resetAt:c?null:(s==null?void 0:s.resetAt)??null});return l!=null&&l.blocksSwitch?d("login",l.text):o==null?d("none",`No ${r} reading`):e.stale||e.fetchedAt==null||n*1e3-e.fetchedAt>kG?d("stale",e.fetchedAt?`Updated ${Si(e.fetchedAt,n)}`:"Never read"):c?d("reset",`Reset ${Si(s.resetAt*1e3,n)}, not updated`):{counted:!0,pct:o,resetAt:s.resetAt}}const jG=e=>Math.min(100,Math.max(0,e));function SG(e,t){const n=Xa.find(h=>h.id===t);let r=0,s=0,o=0;const l=[];for(const h of e){const f=h.cells[t],p=f.counted?f.pct:f.estimate;p!=null&&(r+=p,o++,f.counted&&s++,f.resetAt!=null&&l.push({at:f.resetAt,name:h.name,pct:p}))}const c=l.reduce((h,f)=>!h||f.at<h.at?f:h,null),d=c&&{...c,more:l.filter(h=>h!==c&&h.at-c.at<60).length};return{id:t,label:n.label,long:n.long,reporting:s,included:o,total:e.length,used:o?r/o:null,nextReset:d}}function fO(e,t){const n=e.map(s=>{const o={five_hour:ZS(s,"five_hour",t),seven_day:ZS(s,"seven_day",t)};return{num:s.num,key:Ur(s),name:NG(s),active:s.active,heldOut:s.disabled===!0,cells:o,status:xG(o),updatedAt:s.fetchedAt??null}}),r=n.filter(s=>s.status==="ready").length;return{rows:n,windows:Xa.map(s=>SG(n,s.id)),roomInBoth:r}}function Ku(e,t){return(e==null?void 0:e.key)===t?{key:t,dir:e.dir==="asc"?"desc":"asc"}:{key:t,dir:"asc"}}const _G={ready:0,limited:1,exhausted:2,stale:3};function EG(e){return e.counted?e.pct:e.last}function JS(e,t){return t==="status"?_G[e.status]:t==="updated"?e.updatedAt==null?null:-e.updatedAt:EG(e.cells[t])}function CG(e,t){if(!t)return[...e];const n=t.dir==="asc"?1:-1,r=new Map(e.map((o,l)=>[o.num,l])),s=(o,l)=>{if(t.key==="account")return n*o.name.localeCompare(l.name,void 0,{sensitivity:"base"});const c=JS(o,t.key),d=JS(l,t.key);return c==null||d==null?c==null?d==null?0:1:-1:n*(c-d)};return[...e].sort((o,l)=>s(o,l)||r.get(o.num)-r.get(l.num))}function Ld(e){return e>=100?100:Math.min(99,Math.round(e))}function TG(e){const t=Ld(e);return{used:t,available:100-t}}function AG(e,t,n){return e?`${e} These are the last readings.`:t&&n?"The account store could not be read just now. These are the last readings.":null}function pO(e){return e>=90?"hi":e>=70?"mid":void 0}const mO=(e,t,n)=>`${e} ${e===1?t:n}`;function QS(e){const t=e.more>0?`, and ${mO(e.more,"more account","more accounts")} in the same minute`:"";return`First: ${e.name} (${Ld(e.pct)}% used)${t}`}function RG({w:e,nowSec:t}){const n=`ap-report-${e.id}`,r=e.total-e.included,s=r>0&&a.jsxs("p",{className:"ap-report-basis",children:[r," never read"]}),{used:o,available:l}=TG(e.used??0),c=Math.round(qa(l,{countIn:!0}));if(e.used==null)return a.jsxs("section",{className:"ap-report-sum","aria-labelledby":n,children:[a.jsxs("h3",{className:"ap-report-win",id:n,children:[e.long," window"]}),a.jsxs("p",{className:"ap-report-none",children:["No account has a ",e.long," reading yet."]}),s]});const d=e.nextReset?gh(e.nextReset.at,t):null;return a.jsxs("section",{className:"ap-report-sum","aria-labelledby":n,children:[a.jsxs("h3",{className:"ap-report-win",id:n,children:[e.long," window"]}),a.jsxs("p",{className:"ap-report-left",children:[a.jsxs("b",{children:[c,"%"]})," remaining"]}),a.jsx("div",{className:"ap-report-meter","data-level":pO(o),"aria-hidden":!0,children:a.jsx("i",{style:{"--left":l/100}})}),d&&e.nextReset&&a.jsxs("p",{className:"ap-report-reset",title:QS(e.nextReset),children:[a.jsxs("span",{children:["Next reset in ",a.jsx("span",{className:"ap-report-num",children:d})]}),a.jsx("span",{"aria-hidden":!0,children:"·"}),a.jsx("span",{className:"ap-report-who",children:e.nextReset.name}),e.nextReset.more>0&&a.jsxs("span",{className:"ap-report-more",children:["+",e.nextReset.more]}),a.jsxs("span",{className:"vis-hidden",children:[". ",QS(e.nextReset)]})]}),s]})}function MG({cell:e,nowSec:t}){if(!e.counted)return a.jsxs("td",{className:"ap-report-cell","data-uncounted":"",children:[a.jsx("span",{className:"ap-report-pct",children:e.last==null?a.jsxs(a.Fragment,{children:[a.jsx("span",{"aria-hidden":!0,children:"—"}),a.jsx("span",{className:"vis-hidden",children:"no reading"})]}):`${Ld(e.last)}%`}),a.jsx("span",{className:"vis-hidden",children:", not counted"})]});const n=e.resetAt!=null?gh(e.resetAt,t):null;return a.jsxs("td",{className:"ap-report-cell",children:[a.jsxs("span",{className:"ap-report-pct","data-level":pO(e.pct),children:[Ld(e.pct),"%"]}),n&&a.jsxs("span",{className:"ap-report-in",children:[a.jsx("span",{className:"vis-hidden",children:"resets in "}),n]})]})}const $G={ready:"Ready",limited:"Limited",exhausted:"Exhausted",stale:"Stale"};function IG({row:e}){return a.jsx("td",{className:"ap-report-state","data-status":e.status,children:a.jsxs("span",{className:"ap-report-state-word",children:[a.jsx("i",{"aria-hidden":!0}),$G[e.status]]})})}function OG({row:e,nowSec:t}){const n=bG(e,t);return a.jsx("td",{className:"ap-report-upd","data-old":n.old?"":void 0,children:n.text})}function LG(){return a.jsxs("svg",{className:"ap-report-how-mark",viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":!0,focusable:"false",children:[a.jsx("circle",{cx:"8",cy:"8",r:"6.5",fill:"none",stroke:"currentColor",strokeWidth:"1.4"}),a.jsx("path",{d:"M8 7.2v4.1M8 4.8v.1",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})]})}function PG({accounts:e,nowSec:t,held:n,sort:r=null,onSort:s=()=>{}}){const o=fO(e,t),l=o.rows.length,c=Math.round(qa(o.roomInBoth,{countIn:!0}));return a.jsxs("div",{className:"ap-proj-body ap-report-body",role:"region","aria-label":"Report",children:[n&&a.jsx("p",{className:"ap-report-held",children:n}),a.jsxs("p",{className:"ap-report-lead",children:[a.jsx("b",{children:c})," of ",mO(l,"Claude account","Claude accounts")," ready"]}),a.jsx("div",{className:"ap-report-sums",children:o.windows.map(d=>a.jsx(RG,{w:d,nowSec:t},d.id))}),a.jsxs("table",{className:"ap-report-table",children:[a.jsx("caption",{className:"vis-hidden",children:"Each account's use of each window, and what it can do now"}),a.jsxs("colgroup",{children:[a.jsx("col",{}),Xa.map(d=>a.jsx("col",{className:"ap-report-col-win"},d.id)),a.jsx("col",{className:"ap-report-col-state"}),a.jsx("col",{className:"ap-report-col-upd"})]}),a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx(Rl,{col:"account",label:"Account",sort:r,next:Ku,onSort:s}),Xa.map(d=>a.jsx(Rl,{col:d.id,label:`${d.label} used`,sort:r,next:Ku,onSort:s},d.id)),a.jsx(Rl,{col:"status",label:"Status",sort:r,next:Ku,onSort:s}),a.jsx(Rl,{col:"updated",label:"Updated",className:"ap-report-upd-h",sort:r,next:Ku,onSort:s})]})}),a.jsx("tbody",{children:o.rows.map((d,h)=>a.jsxs("tr",{"data-active":d.active?"":void 0,style:{"--row":h},children:[a.jsx("th",{scope:"row",className:"ap-report-acct",children:a.jsxs("span",{className:"ap-report-acct-in",children:[a.jsx("span",{className:"ap-report-name",title:d.name,children:d.name}),d.active&&a.jsx("span",{className:"ap-report-current",children:"Current"}),d.heldOut&&a.jsx("span",{className:"ap-report-tag",children:"held out"})]})}),Xa.map(f=>a.jsx(MG,{cell:d.cells[f.id],nowSec:t},f.id)),a.jsx(IG,{row:d}),a.jsx(OG,{row:d,nowSec:t})]},d.num))})]}),a.jsxs("details",{className:"ap-report-how",children:[a.jsxs("summary",{children:[a.jsx(LG,{}),"How usage is calculated"]}),a.jsxs("div",{className:"ap-report-how-body",children:[a.jsxs("p",{children:["Every account here, at its last reading: ",a.jsx("b",{children:"used"})," is their average, and ",a.jsx("b",{children:"remaining"})," is the rest."]}),a.jsxs("p",{children:[a.jsx("b",{children:"Ready"})," has room in both windows. ",a.jsx("b",{children:"Limited"})," is at the limit of one, and ",a.jsx("b",{children:"Exhausted"})," of both. ",a.jsx("b",{children:"Stale"})," was never read, or is signed out."]})]})]})]})}function DG({accounts:e,order:t,failed:n,nowSec:r,onClose:s}){const o=y.useRef(null),l=ot(s,{focusRef:o}),c=mt(s),[d,h]=y.useState(e??[]);y.useEffect(()=>{e&&e.length>0&&h(e)},[e]);const f=AG(n,!e||e.length===0,d.length>0),[p,g]=y.useState(null),v=hb(d,(p==null?void 0:p.order)??t),j=k=>{const x=fO(hb(d,t),r).rows;g({sort:k,order:CG(x,k).map(N=>N.key)})};return Pt.createPortal(a.jsx("div",{className:"modal-backdrop",...c,role:"presentation",children:a.jsxs("div",{ref:l,className:"modal ap-report-modal",onClick:k=>k.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ap-report-title",children:[a.jsxs("header",{className:"ap-proj-head",children:[a.jsx("div",{className:"ap-proj-titlewrap",children:a.jsx("h2",{className:"ap-proj-title",id:"ap-report-title",children:"Account capacity"})}),a.jsx("button",{ref:o,type:"button",className:"glyph-btn ap-proj-close",onClick:s,"aria-label":"Close",children:"×"})]}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:f??""}),a.jsx(PG,{accounts:v,nowSec:r,held:f,sort:(p==null?void 0:p.sort)??null,onSort:j})]})}),document.body)}const tm=[70,80,85,90,95],gO="custom",ri=50,si=99,FG=`A whole percent from ${ri} to ${si}.`;function BG(e){const t=Number(e);return[...Number.isFinite(t)&&t>0&&!tm.includes(t)?[...tm,t]:tm].sort((r,s)=>r-s)}function qG(e){const t=e.trim().replace(/\s*%$/,"");if(t==="")return{ok:!1,reason:"empty",message:`Enter a number from ${ri} to ${si}.`};if(!/^\d+(\.\d*)?$|^\.\d+$/.test(t))return{ok:!1,reason:"not_a_number",message:`Enter a number from ${ri} to ${si}.`};const n=Number(t);return Number.isInteger(n)?n<ri?{ok:!1,reason:"too_low",message:`The lowest is ${ri}%.`}:n>si?{ok:!1,reason:"too_high",message:`The highest is ${si}%.`}:{ok:!0,value:String(n)}:{ok:!1,reason:"not_whole",message:`Use a whole number from ${ri} to ${si}.`}}const pb={pick:null,custom:null,refusal:null};function UG(e,t){switch(t.kind){case"pick":return t.pick===gO?{...e,custom:{from:e.pick},refusal:null}:{pick:t.pick,custom:null,refusal:null};case"type":return{...e,pick:t.text,refusal:null};case"cancel":return e.custom?{pick:e.custom.from,custom:null,refusal:null}:e;case"refuse":return{...e,refusal:t.message};case"settle":return pb;case"leave":return e.custom&&(e.pick??t.stored)===t.stored?pb:e}}async function zG(e,t,n){if(!t.sends)return{kind:"unchanged"};const r=qG(e);if(!r.ok)return{kind:"refused",message:r.message};const s=await n({action:"setting",key:"autoswitch.threshold",value:r.value},"threshold");return{kind:"sent",ok:(s==null?void 0:s.ok)===!0}}function WG({auto:e,threshold:t,thresholdPick:n,thresholdCtl:r,thresholdSaved:s,thresholdRef:o,thresholdSaveRef:l,thresholdCustom:c,thresholdRefusal:d,thresholdFieldRef:h,proposeThreshold:f,typeThreshold:p,cancelThreshold:g,leaveThreshold:v,doThreshold:j,pressProps:k,post:x,load:N}){const b=y.useId();return a.jsxs("div",{className:"ap-policy-block",children:[a.jsxs("div",{className:"ap-policy",onKeyDown:c?g:void 0,children:[a.jsx("h3",{className:"ap-auto-title",children:"Auto-switch"}),c?a.jsx("form",{className:"ap-threshold-form",noValidate:!0,onSubmit:S=>{S.preventDefault(),j(n,r)},children:a.jsxs("span",{className:"ap-threshold-field",title:"Switch once the active account passes this much of its limit",children:[a.jsx("input",{ref:h,className:"ap-manage-input ap-threshold-input",type:"text",inputMode:"numeric","aria-label":"Switch threshold","aria-describedby":b,"aria-invalid":d?!0:void 0,value:n,...k("threshold"),onChange:S=>p(S.target.value),onBlur:()=>v(),autoComplete:"off",spellCheck:!1}),a.jsx("span",{className:"ap-threshold-unit","aria-hidden":!0,children:"%"})]})}):a.jsx("span",{className:"ap-field",title:"Switch once the active account passes this much of its limit",children:a.jsxs("select",{ref:o,"aria-label":"Switch threshold",value:n,...k("threshold"),onChange:S=>f(S.target.value),children:[BG(t).map(S=>a.jsxs("option",{value:S,children:[S,"%"]},S)),a.jsx("option",{value:gO,children:"Custom…"})]})}),(r.sends||s)&&a.jsx("button",{ref:l,type:"button",className:"ap-manage-btn",...k("threshold"),title:r.title,onClick:()=>j(n,r),children:s&&!r.sends?r.done:r.label}),a.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":e.enabled,"aria-label":"Auto-switch",...k("enable"),onClick:()=>x({action:"enable",enabled:!e.enabled},"enable").then(()=>N(!0)),title:e.enabled?"Stop switching accounts automatically":"Switch accounts automatically when the active one nears its limit",children:a.jsx("span",{className:"switch-knob"})})]}),d?a.jsx("p",{id:b,className:"ap-threshold-note",role:"alert","data-tone":"err",children:d},"refusal"):c?a.jsx("p",{id:b,className:"ap-threshold-note",children:FG},"hint"):null,e.external&&a.jsxs("p",{className:"ap-auto-note",children:[a.jsx("i",{className:"ap-pulse","aria-hidden":!0})," A ",a.jsx("code",{children:"cswap auto"})," loop in your terminal is doing the switching. The deck stands down while it runs",e.enabled?" — this toggle takes over when you stop it.":"."]})]})}const e_=18,HG=1100,Jo=(e,t)=>{const n=Math.sin(e*12.9898+t*78.233)*43758.5453;return n-Math.floor(n)},VG=Array.from({length:e_},(e,t)=>{const n=-72+144*t/(e_-1)+(Jo(t,1)-.5)*9,r=(n-90)*(Math.PI/180),s=(54+32*Math.cos(n*Math.PI/180))*(.74+Jo(t,2)*.52);return{dx:Math.cos(r)*s,dy:Math.sin(r)*s,rot:(t%2?1:-1)*(100+Jo(t,3)*260),delay:Math.round(Jo(t,4)*90),dur:760+Math.round(Jo(t,5)*260),scale:.8+Jo(t,6)*.45,hue:t%4,round:t%3===0}});function t_({anchor:e}){var s;const[t,n]=y.useState(null),r=typeof window<"u"&&((s=window.matchMedia)==null?void 0:s.call(window,"(prefers-reduced-motion: reduce)").matches);return y.useEffect(()=>{if(r)return;const o=e.current;if(!o)return;const l=o.getBoundingClientRect();n({x:l.left+l.width/2,y:l.top+l.height/2});const c=window.setTimeout(()=>n(null),HG);return()=>window.clearTimeout(c)},[e,r]),r||!t?null:Pt.createPortal(a.jsx("div",{className:"confetti",style:{left:`${t.x}px`,top:`${t.y}px`},"aria-hidden":!0,children:VG.map((o,l)=>a.jsx("span",{className:`confetti-bit${o.round?" round":""}`,"data-hue":o.hue,style:{"--dx":`${o.dx.toFixed(1)}px`,"--dy":`${o.dy.toFixed(1)}px`,"--rot":`${o.rot}deg`,"--s":o.scale.toFixed(2),animationDelay:`${o.delay}ms`,animationDuration:`${o.dur}ms, ${o.dur}ms`}},l))}),document.body)}const Pd=y.forwardRef((e,t)=>a.jsxs("svg",{className:"aa-mark",viewBox:"0 0 44 44","aria-hidden":!0,ref:t,children:[a.jsx("circle",{className:"aa-mark-ring",cx:"22",cy:"22",r:"20"}),a.jsx("path",{className:"aa-mark-tick",d:"M13.5 22.5 L19.5 28.5 L31 17"})]}));Pd.displayName="SuccessMark";const yO=new Set(["awaiting_url","awaiting_code","registering"]);function wO(e){return e!=null&&yO.has(e)}function vO(e){return e!=null&&e!=="done"&&!yO.has(e)}const GG="the sign-in ended before it finished — the deck restarted, or it was cancelled in another tab",KG="the sign-in did not complete";function YG({state:e,serverError:t,localError:n}){const r=e==="idle";return{title:r?"Sign-in ended":"Sign-in failed",message:n||t||(r?GG:KG)}}function XG({restored:e,activeAccount:t}){if(e!==!1)return null;const n=(t==null?void 0:t.email)||((t==null?void 0:t.num)!=null?`account ${t.num}`:null);return n?`This machine is now signed in as ${n} — the account you were using could not be put back. Switch back from the accounts panel.`:"The account you were using could not be put back — check which account this machine is signed in as from the accounts panel."}function ZG({started:e,state:t}){return!e||t==="done"?null:{action:"login-cancel"}}function JG({login:e,started:t,loginError:n,loginBusy:r}){return(e==null?void 0:e.state)==="done"&&e.account?"done":(e==null?void 0:e.state)==="awaiting_code"||(e==null?void 0:e.state)==="registering"?"code":vO(e==null?void 0:e.state)||n&&t&&!r?"ended":r||wO(e==null?void 0:e.state)?"asking":"primer"}const QG="done";function eK(){let e=!1;return{shouldAnnounce(t){return t!==QG?(e=!1,!1):e?!1:(e=!0,!0)}}}function Bk(e,t){return t?Lt(e,t):void 0}const tK={already_running:"a sign-in is already in progress",no_url:"the claude CLI did not offer a sign-in link — is it installed?",not_waiting:"that sign-in is no longer waiting for a code",not_prompted:"the CLI has not asked for a code yet",code_rejected:"that code was not accepted — copy it again from the browser",no_verdict:"the claude CLI has not answered — try the code again",empty_code:"paste the code from the browser first",login_failed:"the code was not accepted",no_identity:"signed in, but the CLI still reports nobody logged in",add_failed:"signed in, but claude-swap could not record the account",not_a_share:"that does not look like a shared account — it should start with ccdeck2:",corrupt:"that share is incomplete — copy the whole thing",wrong_version:`that share was made by a newer ${xt}`,expired:"that share has expired — make a new one",import_failed:"claude-swap refused the import",unreadable_export:"claude-swap wrote something this deck could not read — try again, and upgrade it if this repeats",mixed_versions:"claude-swap changed format part-way through — try again",nothing_to_share:"none of those accounts could be exported",too_many:"that is more accounts than one share can carry",not_in_bundle:"that account is not in this share",bad_value:"an alias can only use letters, numbers, spaces, dots, dashes and underscores, up to 64 characters, and cannot start with a dash",bad_email:"that does not look like an email address — it cannot contain spaces or start with a dash"},nK={no_cswap:"claude-swap could not be run — it is not on this deck's PATH. Set AGENTS_DECK_CSWAP to its full path",timeout:"claude-swap took too long and was stopped — try again",switch_failed:"claude-swap refused the switch",bad_account:"that is not an account claude-swap has",unknown_setting:"claude-swap has no such setting",out_of_range:"that value is outside what the setting allows",bad_value:"claude-swap does not accept that value",set_failed:"claude-swap refused the change",command_failed:"claude-swap refused the command"},qk=`claude-swap could not read the login keychain — start ${xt} from a Terminal window rather than a background service`,rK={unreadable_here:{short:"Keychain locked on this Mac",long:`${qk}.`},no_credentials_here:{short:"no stored login here",long:"claude-swap still holds no login for it here."},relogin_required_here:{short:"login expired",long:"the imported login was rejected — sign in again on a deck where it still works."},unverified_here:{short:"not checked",long:"claude-swap could not confirm whether this Mac can read it."}};function Dd(e){return e?Lt(rK,e)??null:null}const xO={401:"this deck did not accept the page as its own, so nothing was changed",403:"this deck refused a change from this address — open it on the address the deck prints, not through a proxy"};function mb(e,t,n){const r=n==null?null:xO[n];if(r)return r;if((e==null?void 0:e.reason)!=="no_cswap"&&/keychain/i.test(ic(e)))return qk;const s=Bk(nK,e==null?void 0:e.reason);return s||(e==null?void 0:e.reason)||t}function ic(e){return((e==null?void 0:e.output)||(e==null?void 0:e.detail)||(e==null?void 0:e.error)||"").trim()}const sK={no_install:"ccusage is not installed, and AGENTS_DECK_NO_INSTALL=1 forbids fetching it — unset that variable and restart the deck, or install ccusage yourself so it is on this deck's PATH",bad_override:"AGENTS_DECK_CCUSAGE names a file that is not there — correct it to the full path of your ccusage, or unset it to let the deck find its own",timeout:"ccusage took more than 90 seconds and was stopped — a narrower range usually finishes",bad_output:"ccusage ran but printed no usage data — try again, and run ccusage daily --json in a terminal if it keeps happening",run_failed:"ccusage could not report usage — try again",bad_range:"that date range is not a YYYYMMDD date — reopen the modal and pick one of the presets",unreachable:"the deck did not answer — check it is still running, then try again"},aK="ccusage could not be started — npx is not on this deck's PATH. Install Node's npm/npx, or put ccusage on PATH yourself";function oK(e){return/\bnpx\b/i.test(e)&&/(command not found|not found|not recognized|ENOENT)/i.test(e)}const iK="ccusage could not be started — the deck launched npx and Node could not load the npm script it points at. An older deck asked cmd.exe for a bare npx.cmd, which made the shim look for that script under the deck's working directory instead of beside itself; update the deck and reopen this modal",lK="ccusage could not be started — the copy npx fetched will not load: Node could not resolve a file inside it. That copy is in npx's own cache, which the deck never rewrites, so clear it with `npm cache clean --force` and reopen this modal",cK=e=>/\b(?:ERR_)?MODULE_NOT_FOUND\b|cannot find (?:module|package)/i.test(e),uK=/node_modules[\\/]npm[\\/]bin[\\/]|\bnpm-prefix\.js\b|\bnp[mx][-.][\w.-]*cli\.js\b/i,dK=/[\\/]_npx[\\/]/i,hK=`the copy of ccusage ${xt} installed for itself`;function fK(e){const t=String((e==null?void 0:e.install)??"").replace(/\s+/g," ").trim();return t.length>240?`${t.slice(0,239)}…`:t}function Eue(e,t){const n=pK(e,t),r=fK(e);switch(e==null?void 0:e.stage){case"npx":return r?`ccusage failed on both of its paths. The managed install failed first — ${r} — and the deck then fell back to npx, where ${Sl(n)}`:`there is no managed copy of ccusage on this machine, and the npx fallback failed: ${Sl(n)}`;case"managed":return`${hK} failed to run: ${Sl(n)}`;case"path":return e.bin?`the ccusage this deck found at ${e.bin} failed to run: ${Sl(n)}`:`the ccusage this deck found on your PATH failed to run: ${Sl(n)}`;default:return n}}const Sl=e=>/^[A-Z][a-z]/.test(e)?e[0].toLowerCase()+e.slice(1):e;function pK(e,t){const n=ic(e);if(cK(n)){if(dK.test(n))return lK;if(uK.test(n))return iK}if(oK(n))return aK;const r=Bk(sK,e==null?void 0:e.reason);return r||(e==null?void 0:e.reason)||t}function oi(e,t,n){const r=n==null?null:xO[n];if(r)return r;if(e!=null&&e.detail)return e.detail;if(e!=null&&e.error&&vO(e.state))return e.error;const s=Bk(tK,e==null?void 0:e.reason);return s||(e!=null&&e.error?e.error:(e==null?void 0:e.reason)||t)}function bO(e,t,n,r="horizontal"){if(n<=0||dh(e))return{kind:"pass"};const s=t>=0&&t<n?t:-1,o=r==="vertical",l=e.key==="ArrowRight"||o&&e.key==="ArrowDown",c=e.key==="ArrowLeft"||o&&e.key==="ArrowUp";if(l)return{kind:"select",index:s===-1?0:(s+1)%n};if(c)return{kind:"select",index:s===-1?n-1:(s-1+n)%n};switch(e.key){case"Home":return{kind:"select",index:0};case"End":return{kind:"select",index:n-1};default:return{kind:"pass"}}}function kO(e,t){const n=Math.round(e/1e3)-t;return n<=0?{text:"expired",tone:"gone"}:n<60?{text:`expires in ${n}s`,tone:"soon"}:{text:`expires in ${Math.round(n/60)}m`,tone:"ok"}}function mK(e){const t=new Map;for(const n of e){const r=(n.email??"").trim().toLowerCase();r&&t.set(r,(t.get(r)??0)+1)}return e.map(n=>{const r=(n.email??"").trim(),s=n.alias||r||`account ${n.num}`,o=[];return n.alias&&r&&o.push(r),r&&(t.get(r.toLowerCase())??0)>1&&o.push(n.org||`slot ${n.num}`),{num:n.num,label:s,sub:o.length?o.join(" · "):null}})}function gK(e,t){return e.filter(n=>!t.includes(n.num)).map(n=>n.num)}function yK(e,t){return e.includes(t)?e.filter(n=>n!==t):[...e,t]}function wK(e){return e.length?{action:"share",accounts:[...e]}:null}function vK(e){return e<=0?"Nothing picked yet.":e===1?"1 account — its sign-in token will be on your clipboard.":`${e} accounts — ${e} sign-in tokens will be on your clipboard.`}function gb(e){return`${e.email}|${e.org??""}`}function xK(e,t,n){return e&&e.map(r=>gb(r)===t?n:r)}function bK(e){switch(e){case"imported":return"imported";case"healed":return"dead token replaced";case"updated":return"updated";case"present":return"already here";default:return"not imported"}}function kK(e){const t=e.length;if(!t)return"Nothing to import.";const n=f=>e.filter(p=>p.state===f).length,r=[],s=n("imported");s&&r.push(`${s} of ${t} imported`);const o=n("healed");o&&r.push(`${o} had a dead token replaced`);const l=n("updated");l&&r.push(`${l} updated`);const c=n("present");c&&r.push(`${c} already here`);const d=n("failed");d&&r.push(`${d} did not arrive`);const h=[...new Set(e.map(f=>{var p;return(p=Dd(f.check))==null?void 0:p.short}).filter(f=>!!f))];return`${r.join(", ")}${h.length?`, ${h.join(", ")}`:""}.`}const NK=1500,Yu=[{id:"login",label:"Sign in"},{id:"paste",label:"Paste a share"}],n_="aa-panel",r_=e=>`aa-tab-${e}`;async function Qo(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}function NO({onClose:e,onChanged:t,email:n=null,onSignedIn:r}){qt("add-account");const[s,o]=y.useState("login"),[l,c]=y.useState(null),[d,h]=y.useState(""),[f,p]=y.useState(""),[g,v]=y.useState(!1),[j,k]=y.useState(!1),[x,N]=y.useState(null),[b,S]=y.useState(null),E=g||j,[R,I]=y.useState(null),[A,q]=y.useState(null),[$,B]=y.useState(null),L=y.useRef(""),M=y.useRef(!1),F=y.useRef(!1),T=y.useRef(null),P=y.useRef(null),O=y.useRef(null),G=y.useRef(null),K=y.useRef([]),U=y.useRef(!1),H=y.useCallback(()=>{const de=ZG({started:M.current,state:l==null?void 0:l.state});de&&Qo(de).catch(()=>{}),e()},[e,l==null?void 0:l.state]),D=ot(H,{focusRef:O}),V=mt(H),J=y.useCallback(async()=>{if(!xr(F.current))return;F.current=!0,v(!0),N(null),M.current=!0;let de=await Qo(n?{action:"login",email:n}:{action:"login"}).catch(()=>null);if(n&&(de==null?void 0:de.reason)==="bad_email"&&(de=await Qo({action:"login"}).catch(()=>null)),F.current=!1,v(!1),!(de!=null&&de.ok)){N(oi(de,"could not start the sign-in"));return}c(de)},[n]);y.useEffect(()=>{if(!wO(l==null?void 0:l.state))return;const de=window.setInterval(async()=>{try{const me=await fetch("/api/claude-accounts/login");me.ok&&c(await me.json())}catch{}},NK);return()=>window.clearInterval(de)},[l]);const W=y.useRef(t);W.current=t;const Z=y.useState(eK)[0];y.useEffect(()=>{var de;(l==null?void 0:l.state)==="awaiting_code"&&((de=T.current)==null||de.focus()),Z.shouldAnnounce(l==null?void 0:l.state)&&W.current()},[l==null?void 0:l.state,Z]);const Y=y.useRef(r);Y.current=r;const X=y.useRef(null);y.useEffect(()=>{var ne;const de=(l==null?void 0:l.state)==="done"?l.account:null,me=de?`${de.num??""}|${de.email}`:null;!de||X.current===me||(X.current=me,(ne=Y.current)==null||ne.call(Y,de))},[l]),y.useEffect(()=>{var de;s==="paste"&&!U.current&&((de=P.current)==null||de.focus()),U.current=!1},[s]);const ee=y.useCallback(de=>{var ne;const me=bO(de,Yu.findIndex(oe=>oe.id===s),Yu.length);me.kind!=="pass"&&(de.preventDefault(),U.current=!0,o(Yu[me.index].id),(ne=K.current[me.index])==null||ne.focus())},[s]),ae=y.useCallback(async()=>{var me;if(!xr(F.current))return;F.current=!0,v(!0),N(null);const de=await Qo({action:"login-code",code:d}).catch(()=>null);if(F.current=!1,v(!1),!(de!=null&&de.ok)){N(oi(de,"the code was not accepted")),de!=null&&de.state&&c(de),(me=T.current)==null||me.select();return}h(""),c(de)},[d,l]),ce=y.useCallback(async()=>{if(!xr(F.current))return;F.current=!0,k(!0),S(null);const de=await Qo({action:"import",blob:f}).catch(()=>null);if(F.current=!1,k(!1),!(de!=null&&de.ok)){S(oi(de,"the import failed"));return}L.current=f,p(""),B(null),I(de.results??[]),t()},[f,t]),ge=y.useCallback(async de=>{const me=gb(de);if(!xr(F.current)||!L.current)return;F.current=!0,k(!0),q(me),B(null);const ne=await Qo({action:"import",blob:L.current,force:!0,only:{email:de.email,org:de.org??""}}).catch(()=>null);if(F.current=!1,k(!1),q(null),!(ne!=null&&ne.ok)){B({key:me,text:oi(ne,"that account could not be updated")});return}const oe=(ne.results??[])[0];oe&&I(Ne=>xK(Ne,me,oe)),t()},[t]),ye=(l==null?void 0:l.state)==="done"?l.account:null,se=XG({restored:l==null?void 0:l.restored,activeAccount:l==null?void 0:l.activeAccount}),pe=JG({login:l,started:M.current,loginError:x,loginBusy:g}),fe=YG({state:l==null?void 0:l.state,serverError:l==null?void 0:l.error,localError:x});return Pt.createPortal(a.jsx("div",{className:"modal-backdrop",...V,role:"presentation",children:a.jsxs("div",{ref:D,className:"modal aa-modal",onClick:de=>de.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Add a Claude account",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{className:"aa-tabs",role:"tablist","aria-label":"How to add the account",onKeyDown:ee,children:Yu.map((de,me)=>a.jsx("button",{type:"button",role:"tab",id:r_(de.id),ref:ne=>{K.current[me]=ne},"aria-selected":s===de.id,"aria-controls":n_,tabIndex:s===de.id?0:-1,className:`aa-tab${s===de.id?" on":""}`,onClick:()=>{U.current=!1,o(de.id)},children:de.label},de.id))})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:H,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsx("section",{className:"modal-body aa-body",id:n_,role:"tabpanel","aria-labelledby":r_(s),children:s==="login"?pe==="done"&&ye?a.jsxs("div",{className:"aa-done",children:[a.jsx(Pd,{ref:G}),a.jsx(t_,{anchor:G}),a.jsx("h4",{children:ye.added?`Account ${ye.num} added`:"Credentials refreshed"}),a.jsxs("p",{className:"aa-note",children:[a.jsx("strong",{children:ye.email}),ye.added?se?" is in the rotation.":" is in the rotation. The account you were using is still active.":" was already managed, so its stored credentials were replaced."]}),se?a.jsx("p",{className:"aa-note aa-warn",role:"status",children:se}):null,a.jsx("button",{type:"button",className:"btn primary",onClick:H,children:"Done"})]}):pe==="code"&&l?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"aa-step",children:[a.jsx("h4",{children:"1 · Approve in the browser"}),a.jsx("p",{className:"aa-note",children:"A tab should have opened. If not, use this link:"}),a.jsx("a",{className:"aa-link",href:l.url??"#",target:"_blank",rel:"noreferrer noopener",children:l.url})]}),a.jsxs("div",{className:"aa-step",children:[a.jsx("h4",{children:"2 · Paste a code, if the page shows one"}),a.jsx("p",{className:"aa-note",children:"It usually finishes on its own — if the page says you are all set, there is nothing to do here."}),a.jsxs("div",{className:"aa-field",children:[a.jsx("input",{ref:T,type:"text",value:d,onChange:de=>h(de.target.value),onKeyDown:de=>{de.key==="Enter"&&d.trim()&&!E&&ae()},placeholder:"paste the code here",spellCheck:!1,autoComplete:"off","aria-label":"Sign-in code",disabled:l.state==="registering"}),a.jsx("button",{type:"button",className:"btn primary",...Wr(E,!d.trim()||l.state==="registering"),onClick:ae,children:l.state==="registering"?"registering…":"Continue"})]}),(x||l.error)&&a.jsx("p",{className:"aa-err",children:x??l.error}),a.jsx("p",{className:"aa-note",children:"The code goes straight to the claude CLI on this machine. It is never stored or sent anywhere else."})]})]}):pe==="ended"?a.jsxs("div",{className:"aa-step",children:[a.jsx("h4",{children:fe.title}),a.jsx("p",{className:"aa-err",children:fe.message}),a.jsx("button",{type:"button",className:"btn",onClick:()=>{M.current=!1,c(null),N(null),J()},children:"Try again"})]}):pe==="asking"?a.jsx("div",{className:"aa-step",children:a.jsx("p",{className:"aa-note",children:"Asking the claude CLI for a sign-in link…"})}):a.jsxs("div",{className:"aa-step aa-primer",children:[a.jsx("h4",{children:n?a.jsxs(a.Fragment,{children:["Sign in again as ",a.jsx("strong",{children:n})]}):"Sign in to Anthropic"}),a.jsxs("p",{className:"aa-note",children:["Opens a browser tab where you approve the sign-in",n?", with this address already filled in":"",". It normally completes by itself; only if the page hands you a code does it need pasting back here.",n?" claude-swap replaces the expired login in place — the account keeps its slot, its alias and its history — and the account you are using now stays active.":" claude-swap records the account when it completes, and the account you are using now stays active."]}),a.jsx("div",{className:"aa-actions",children:a.jsx("button",{type:"button",ref:O,className:"btn primary",...Wr(E),onClick:J,children:"Open the sign-in page"})})]}):R?(()=>{const de=R.filter(ne=>ne.state==="imported").length,me=R.some(ne=>Dd(ne.check));return a.jsxs("div",{className:"aa-done",children:[!me&&a.jsx(Pd,{ref:G}),de>0&&!me&&a.jsx(t_,{anchor:G}),a.jsx("h4",{children:kK(R)}),R.length>0&&a.jsx("ul",{className:"aa-results",children:R.map(ne=>{const oe=gb(ne),Ne=Dd(ne.check);return a.jsxs("li",{className:`aa-result ${ne.state}`,children:[a.jsx("span",{className:"aa-result-who",children:ne.email||(ne.num?`slot ${ne.num}`:"an account")}),a.jsx("span",{className:"aa-result-what",children:bK(ne.state)}),ne.state==="present"&&a.jsx("button",{type:"button",className:"aa-result-fix","aria-busy":A===oe,title:`Overwrite the stored login for ${ne.email} with the one in this share. Do this when that account has stopped working here; if it works, leave it.`,onClick:()=>ge(ne),children:A===oe?"updating…":"update anyway"}),Ne&&a.jsx("span",{className:"aa-result-err",children:Ne.long}),($==null?void 0:$.key)===oe&&a.jsx("span",{className:"aa-result-err",children:$.text})]},oe)})}),a.jsxs("p",{className:"aa-note",children:["Nothing changed on the deck you copied this from. An account already here is left as it is, unless its stored login was dead or you pressed",a.jsx("strong",{children:" update anyway"}),"."]}),a.jsxs("div",{className:"aa-actions",children:[a.jsx("button",{type:"button",className:"btn primary",onClick:H,children:"Done"}),a.jsx("button",{type:"button",className:"btn",onClick:()=>{L.current="",B(null),I(null)},children:"Import another"})]})]})})():a.jsxs("div",{className:"aa-step",children:[a.jsx("h4",{children:"Paste an account shared from another deck"}),a.jsxs("div",{className:"aa-field",children:[a.jsx("input",{ref:P,type:"text",value:f,onChange:de=>p(de.target.value),onKeyDown:de=>{de.key==="Enter"&&f.trim()&&!E&&ce()},placeholder:"ccdeck2:…",spellCheck:!1,autoComplete:"off","aria-label":"Shared account"}),a.jsx("button",{type:"button",className:"btn primary",...Wr(E,!f.trim()),onClick:ce,children:j?"importing…":"Import"})]}),b&&a.jsx("p",{className:"aa-err",children:b}),a.jsxs("p",{className:"aa-note",children:["Use ",a.jsx("strong",{children:"share"})," on one account in the other deck, or ",a.jsx("strong",{children:"↗"})," above its list to send several at once. A share carries a live login for every account in it and expires ten minutes after it is made."]})]})})]})}),document.body)}function jK(e,t){const n=new Set(e),r=e.length?Math.max(...e):0;return[...new Set([...e,r+1])].sort((s,o)=>s-o).map(s=>{const o=s===t?"here":n.has(s)?"swap":"free";return{slot:s,kind:o,label:o==="here"?`slot ${s}`:`slot ${s} · ${o}`}})}function SK(e,t,n){if(!(n!=null&&n.ok))return null;const r=Number.isInteger(n.to)?n.to:null;if(r==null)return{menuFor:null,confirmRemove:null,shareFor:null,swapNote:null};const s=n.swapped===!0&&r!==t;return{menuFor:e.menuFor===t?r:s&&e.menuFor===r?t:e.menuFor,confirmRemove:null,shareFor:null,swapNote:s?{at:r,displaced:t}:null}}const _K=64;function EK(e,t){const n=e.trim();return{alias:n,commit:n!==(t??"").trim()}}function CK(e,t,n){return t!=null&&e.some(r=>r.slot===t)?t:n}function TK(e,t,n){var s;const r=((s=e.find(o=>o.slot===t))==null?void 0:s.kind)??"here";return r==="swap"?{label:"swap",done:"swapped",sends:!0,swaps:!0,title:`Send this account to slot ${t}. That slot is taken, so the two accounts trade places and the one standing there moves to slot ${n}.`}:r==="free"?{label:"move",done:"moved",sends:!0,swaps:!1,title:`Send this account to slot ${t}. That slot is empty, so no other account moves.`}:{label:"move",done:"here",sends:!1,swaps:!1,title:`This account already holds slot ${n}.`}}function AK(e,t){return{label:"save",done:"saved",sends:e!==t,swaps:!1,title:`Switch the active account out once it passes ${e}% of its limit.`}}function RK({a:e,slots:t,nowSec:n,boundaryId:r,accountMenu:s,busy:o,pressProps:l,rotating:c,onProjects:d,onRotation:h}){const{menu:f,menuError:p,aliasDraft:g,confirmRemove:v,share:j,shareCopied:k,slotDraft:x,dropMenu:N,closeMenu:b,startRename:S,typeAlias:E,doAlias:R,startMove:I,pickSlot:A,doSlot:q,makeShare:$,copyShare:B,pressRemove:L}=s;if(!f)return null;const M=`ap-pop-title-${e.num}`,F=p&&a.jsx("p",{className:"ap-pop-error",role:"alert",title:p.raw||void 0,children:p.text});return a.jsxs(Nh,{anchorId:`ap-more-${e.num}`,boundaryId:r,id:`ap-menu-${e.num}`,className:"ap-pop",role:f.view==="menu"?"menu":"dialog",labelledBy:f.view==="menu"?`ap-more-${e.num}`:M,start:f.start,onClose:N,children:[f.view==="menu"&&a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",onClick:()=>S(e.num,e.alias),children:"Rename"}),a.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",onClick:()=>I(e.num),children:"Move to slot…"}),a.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",...l(`share-${e.num}`),title:`Copy this account to another ${xt}. Anyone who has the text can use the account — treat it as the password. The other deck stops accepting it after 10 minutes; that does not make an escaped copy safe.`,onClick:()=>$(e.num),children:o===`share-${e.num}`?"Sharing…":"Share"}),a.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",title:"See how much this account worked in each project",onClick:()=>d(),children:"Projects"}),(c&&!e.active||e.disabled)&&a.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",...l(`rot-${e.num}`),title:e.disabled?"Return this account to auto-rotation":"Hold this account out of auto-rotation",onClick:()=>h(),children:e.disabled?"Put back in rotation":"Hold out of rotation"}),a.jsx("div",{role:"separator",className:"ap-menu-sep"}),a.jsx("button",{type:"button",role:"menuitem",className:`ap-menu-item danger${v===e.num?" armed":""}`,...l(`rm-${e.num}`),"aria-label":v===e.num?"Confirm remove":void 0,title:v===e.num?"This deletes the stored credentials for this account":"Remove this account from claude-swap",onClick:()=>L(e.num),children:o===`rm-${e.num}`?"Removing…":v===e.num?"Confirm":"Remove"}),F]}),f.view==="rename"&&a.jsxs("form",{className:"ap-pop-form",onSubmit:T=>{T.preventDefault(),R(e.num,e.alias)},children:[a.jsx("label",{className:"ap-pop-title",id:M,htmlFor:`ap-alias-${e.num}`,children:"Rename account"}),a.jsx("input",{id:`ap-alias-${e.num}`,className:"ap-manage-input",type:"text",value:g,onChange:T=>E(T.target.value),maxLength:_K,placeholder:"e.g. work",spellCheck:!1,autoComplete:"off",autoFocus:!0,onFocus:T=>T.currentTarget.select()}),F,a.jsxs("div",{className:"ap-pop-actions",children:[a.jsx("button",{type:"button",className:"btn",onClick:()=>b(),children:"Cancel"}),a.jsx("button",{type:"submit",className:"btn primary",...l(`alias-${e.num}`),title:"A short name to show instead of the email",children:o===`alias-${e.num}`?"…":"Save"})]})]}),f.view==="move"&&(()=>{const T=jK(t,e.num),P=CK(T,x,e.num),O=TK(T,P,e.num);return a.jsxs("div",{className:"ap-pop-form",children:[a.jsx("label",{className:"ap-pop-title",id:M,htmlFor:`ap-slot-${e.num}`,children:"Move to slot"}),a.jsx("span",{className:"ap-field",children:a.jsx("select",{id:`ap-slot-${e.num}`,value:String(P),...l(`move-${e.num}`),onChange:G=>A(Number(G.target.value)),autoFocus:!0,children:T.map(G=>a.jsx("option",{value:G.slot,children:G.label},G.slot))})}),F,a.jsxs("div",{className:"ap-pop-actions",children:[a.jsx("button",{type:"button",className:"btn",onClick:()=>b(),children:"Cancel"}),a.jsx("button",{type:"button",className:"btn primary",...l(`move-${e.num}`),title:O.title,onClick:()=>q(e.num,P,O),children:o===`move-${e.num}`?"…":Ml(O.label)})]})]})})(),f.view==="share"&&(j==null?void 0:j.num)===e.num&&(()=>{const T=kO(j.expiresAt,n),P=T.tone==="gone";return a.jsxs("div",{className:"ap-pop-form",children:[a.jsx("p",{className:"ap-pop-title",id:M,children:"Share account"}),a.jsx("code",{className:"ap-share-blob",children:j.blob}),a.jsxs("p",{className:"ap-pop-note",title:"This text is the account's password. It is base64 of plain JSON — the expiry inside it is not signed, so anyone holding a copy can change it, and the login itself is in there in the clear either way. The countdown only says how long another deck's import dialog will still accept it. If a copy escapes, sign the account out and back in.",children:[a.jsx("span",{className:"ap-share-warn",children:"This is the password"})," · ",a.jsx("span",{className:`ap-share-expiry ${T.tone}`,children:T.text})]}),F,a.jsxs("div",{className:"ap-pop-actions",children:[a.jsx("button",{type:"button",className:"btn",onClick:()=>b(),children:"Done"}),a.jsx("button",{type:"button",className:"btn primary",...l(`share-${e.num}`),autoFocus:!0,onClick:async()=>{if(P){await $(e.num);return}await B(j.blob)},children:P?"Make a new share":k?"Copied":"Copy"})]})]})})()]})}const MK=6;function $K(e,t){const n=e.filter(c=>c.ready);if(t.armed&&e.length>0&&n.length===0)return{text:"Auto-switch has nowhere to go",tone:"bad",free:null};const r=n.length===e.length?`${e.length} ready`:n.length===0?e.length===1?"not ready":`none of ${e.length} ready`:`${n.length} of ${e.length} ready`,s=n.length?"ok":"idle",o=t.strained&&!t.armed?IK(n):null,l=[r];return o!=null&&l.push(`${o}% free`),l.push(t.armed?`auto ${t.threshold??"on"}${t.threshold?"%":""}`:"auto off"),{text:l.join(" · "),tone:s,free:o}}function IK(e){const t=e.map(n=>n.headroom).filter(n=>typeof n=="number");return t.length?Math.round(Math.max(...t)):null}function OK(e){const t=[...e].sort((s,o)=>{if(s.ready!==o.ready)return s.ready?-1:1;if(!s.ready)return s.name.localeCompare(o.name);const l=s.headroom,c=o.headroom;return l==null&&c==null?s.name.localeCompare(o.name):l==null?1:c==null?-1:c-l}),n=t.slice(0,MK),r=t.length-n.length;return{title:e.some(s=>s.ready)?"Where you could switch":"Nothing to switch to",shown:n,rest:r>0?`and ${r} more`:null}}function Hr(e,t){if(e==null)return"not seen";const n=Math.max(0,Math.round((t-e)/1e3));if(n<90)return"now";const r=Math.round(n/60);if(r<60)return`${r}m ago`;const s=Math.round(r/60);return s<48?`${s}h ago`:`${Math.round(s/24)}d ago`}const LK={keychain_unavailable:{short:"Keychain locked on the other Mac",long:`the other Mac could not export it. On that Mac: ${qk}. The next round brings it.`}};function yb(e){return e.why?Lt(LK,e.why)??Dd(e.why):null}const Uk={"waiting for the other deck to accept this one":{text:"waiting for them to say yes",tone:"idle"},"that deck said no":{text:"it said no",tone:"bad"},"that deck pairs only by invite":{text:"it pairs only by invite",tone:"idle"},"this deck pairs only by invite":{text:"needs an invite · your setting",tone:"idle"}},PK={ECONNREFUSED:"not listening",EHOSTUNREACH:"no route to it",ENETUNREACH:"no network here",ETIMEDOUT:"no answer",ECONNRESET:"it hung up",EHOSTDOWN:"it is down",ENOTFOUND:"name not found",EACCES:"blocked here",EPIPE:"it hung up"};function s_(e){var r;const t=DK[e];if(t)return t;const n=(r=/\b(E[A-Z]{3,})\b/.exec(e))==null?void 0:r[1];return n&&PK[n]||e}const DK={"handshake timed out":"no answer","peer closed the connection":"it hung up","peer went quiet":"it stopped mid-sentence","bad reply":"it answered with nonsense","no manifest":"it would not say what it has","bad challenge":"it answered as somebody else","a different deck is answering at that address":"a different deck is at that address","that deck could not prove its own key":"it could not prove who it is","the other deck refused this one's proof":"it would not take this deck's word","the other deck refused this handshake":"it turned this deck away","that deck has this one pinned under a different key":"it knows this deck by another key"};function Sh(e,t){var f;if(!e)return null;if(e.error&&((f=e.done)!=null&&f.length)){const p=Sh({...e,error:void 0},t),g=` · ${Hr(e.at,t)}`;return{...p,text:`${p.text.slice(0,-g.length)}, then ${s_(e.error)}${g}`,tone:"bad"}}if(e.error)return Uk[e.error]??{text:s_(e.error),tone:"bad"};const n=e.done??[];if(!n.length)return{text:`all logins fine · ${Hr(e.at,t)}`,tone:"idle"};const r=n.filter(p=>p.ok),s=r.length===1?"login":"logins",o=n.map(p=>({d:p,why:yb(p)})).filter(p=>p.why),l=[...new Set(o.map(p=>p.why.short))],c=l.length?`, ${l.join(", ")}`:"",d=o.length?o.map(p=>`${p.d.email}: ${p.why.long}`).join(" "):void 0,h=Hr(e.at,t);return r.length===n.length?{text:`${r.length} ${s} arrived${c} · ${h}`,tone:o.length?"warn":"ok",...d?{hint:d}:{}}:{text:`${r.length} of ${n.length} logins arrived${c} · ${h}`,tone:"bad",...d?{hint:d}:{}}}const FK=9e4;function BK({error:e,host:t,port:n},r,s,o=45317){if(e!=="handshake timed out")return null;const l=(t??"").trim();if(!l)return null;const c=r.filter(h=>h.addr===l&&h.port&&h.at>0&&s-h.at<FK);if(!c.length)return null;const d=[...new Set(c.map(h=>h.port))];if(n!=null&&!d.includes(n)){const h=d.length===1?`port ${d[0]}`:`ports ${d.join(" and ")}`;return`A deck at ${l} is announcing itself on ${h}, not on ${n}. This deck already hears it and dials it there, so this typed row has nothing to reach.`}return`That machine is running the deck — its beacon arrives here every half minute — and what this deck sends back never gets there. That is a firewall on ${l}, not a network fault. Whoever uses it can allow two ports: UDP ${o} and TCP ${n??d[0]}.`}function _h(e,t){var n,r;return(n=e.last)!=null&&n.error&&!Uk[e.last.error]?!1:!!((r=e.last)!=null&&r.at&&t-e.last.at<wb||e.lastSeen!=null&&t-e.lastSeen<wb)}const wb=95e3;function qK(e,t){if(!e)return{text:"checking…",tone:"idle"};if(!e.enabled)return{text:"",tone:"idle"};if(e.stalled)return{text:`could not start — ${e.stalled}`,tone:"bad"};if(!e.running)return{text:"starting…",tone:"wait"};const n=(e.pending??[]).length;if(n)return{text:n===1?"1 deck is waiting for your answer":`${n} decks are waiting for your answer`,tone:"wait"};const r=(e.peers??[]).filter(p=>p.paired!==!1||p.met);if(!r.length)return{text:"no deck paired yet",tone:"idle"};const s=p=>p.waiting?jO(p.lastSeen,t):_h(p,t),o=p=>{var g;return!p.waiting&&((g=p.last)==null?void 0:g.error)==="waiting for the other deck to accept this one"},l=e.aliases??{};let c=0,d=0,h=0;for(const p of _O(r,g=>SO(g,g.peerFp??g.fp,l).name,g=>g.addr??"")){const g=p.filter(s);if(!g.length){h++;continue}c++,g.every(o)&&d++}if(c&&d===c)return{text:c===1?"1 deck found · waiting for them to accept":`${c} decks found · waiting for them to accept`,tone:"wait"};if(!c)return{text:h===1?"this deck cannot reach the one it is paired with":`this deck cannot reach any of its ${h} decks`,tone:"bad"};const f=c===1?"1 deck ready":`${c} decks ready`;return{text:h?`${f} · ${h} away`:f,tone:"ok"}}function UK(e,t,n){if(n)return"checking…";if(e==null)return"not checked yet";const r=Hr(e,t);return r==="now"?"checked just now":`checked ${r}`}function zk(e,t){const n=Math.max(0,Math.round((t-e)/1e3));if(n<90)return"just now";const r=Math.round(n/60);return r<60?`${r}m ago`:`${Math.round(r/60)}h ago`}function jO(e,t){return e!=null&&t-e<wb}function zK(e,t){if(e==null)return{text:"one-way · has not called yet",here:!1};const n=jO(e,t);return{text:n?"online · one-way, it calls in":`one-way · last online ${Hr(e,t)}`,here:n}}function a_(e,t,n){return t?"online":e.lastSeen!=null?`last online ${Hr(e.lastSeen,n)}`:e.waiting?"has not called yet":"never reached"}function WK(e,t){if(!e)return[];const n=[],r=new Set,s=(p,g)=>p.name.localeCompare(g.name,void 0,{numeric:!0}),o=e.aliases??{};for(const p of e.pending??[])!(p!=null&&p.fp)||r.has(p.fp)||(r.add(p.fp),n.push(HK(p,o,t)));const l=[],c=[];for(const p of e.peers??[]){const g=p.peerFp??p.fp;!g||r.has(g)||(r.add(g),!p.paired&&p.manual&&!p.met?c.push(VK(p,g,t)):l.push(GK(p,g,o,t)))}n.push(...XK(l).sort(s),...c.sort(s));const d=[];for(const p of e.strangers??[])!(p!=null&&p.fp)||r.has(p.fp)||(r.add(p.fp),d.push(KK(p,o,e.pairingMode)));n.push(...d.sort(s));const h=[];for(const p of e.declined??[])!(p!=null&&p.fp)||r.has(p.fp)||(r.add(p.fp),h.push(YK(p,o)));n.push(...h.sort(s));const f=new Map;for(const p of n)f.set(p.name,(f.get(p.name)??0)+1);for(const p of n)(f.get(p.name)??0)<2||!p.addr||(p.state=p.quiet||!p.state?p.addr:`${p.addr} · ${p.state}`,p.quiet=!1);return n}function HK(e,t,n){const r=Eh(t,e.fp,e.name||e.fp);return{fp:e.fp,...r,addr:e.addr??"",kind:"asks",state:`wants to pair · ${zk(e.at,n)}`,tone:"wait",here:!0,hint:`${r.name} at ${e.addr}${e.via==="tailscale"?", over Tailscale,":""} is waiting for an answer.`,...Ch(e.via)}}function VK(e,t,n){var o;const r=Sh(e.last,n),s=e.addr?`${e.addr}:${e.port}`:"";return{fp:s,name:s||e.name||t,addr:e.addr??"",kind:"dialling",state:r?vb(r):"trying…",tone:r?r.tone:"idle",here:!1,hint:(o=e.last)!=null&&o.error?`Nothing has answered at ${s} yet — ${e.last.error}.`:`Dialling ${s} until something answers.`,...Ch(e.via)}}function GK(e,t,n,r){var v,j,k,x;const s=Sh(e.last,r),o=_h(e,r),l=e.addr?`${e.addr}:${e.port}`:"",c=e.waiting?zK(e.lastSeen,r):null,d=c?c.here:o,h=!c&&s?d?`online · ${vb(s)}`:`${vb(s)} · ${a_(e,d,r)}`:c?c.text:a_(e,d,r),f=(v=e.last)!=null&&v.error?Uk[e.last.error]:null,p=!c&&d&&!((j=e.last)!=null&&j.error)&&!(((k=e.last)==null?void 0:k.done)??[]).length,g=SO(e,t,n);return{fp:t,...g,addr:e.addr??"",kind:"paired",state:h,quiet:p,tone:f?f.tone==="bad"?"bad":"wait":s?s.tone:d?"ok":"idle",here:c?c.here:o,...Ch(e.via),hint:c?`${g.name} calls this deck, and this deck has no address to call back on — so it can repair its logins from here, and this deck cannot repair from it. ${e.lastSeen==null?"It has not called since this deck started.":`It last called ${Hr(e.lastSeen,r)}.`} Add its address through Add a deck, the link at the top of this view, to reach it either way.`:`${g.name}${l?` at ${l}`:""}${(x=e.last)!=null&&x.error?` — ${e.last.error}`:""}${s!=null&&s.hint?` — ${s.hint}`:""}`}}function SO(e,t,n){return e.manual&&!e.met?{name:e.addr?`${e.addr}:${e.port}`:""}:Eh(n,t,e.name||t)}function KK(e,t,n){const r=Eh(t,e.fp,e.name||e.fp);return{fp:e.fp,...r,addr:e.addr??"",kind:"nearby",state:n==="invite"?"needs an invite":"not paired yet",tone:"idle",here:!0,hint:e.via==="tailscale"?`${r.name} at ${e.addr} is on your tailnet and nothing is shared with it.`:`${r.name} at ${e.addr} is on this network and nothing is shared with it.`,...Ch(e.via)}}function YK(e,t){const n=Eh(t,e.fp,e.name||e.fp);return{fp:e.fp,...n,addr:e.addr??"",kind:"declined",state:"you said no",tone:"idle",here:!1,hint:`${n.name} asked and was turned away. It is not asking any more.`}}function Eh(e,t,n){const r=t?e[t]:void 0;return r&&r!==n?{name:r,self:n}:{name:n}}function Ch(e){return e==="tailscale"?{via:"tailscale"}:{}}function vb(e){return e.text.replace(/ · .*$/,"")}function XK(e){return _O(e,t=>t.name,t=>t.addr).map(ZK)}function _O(e,t,n){const r=new Map;for(const o of e){const l=r.get(t(o));l?l.push(o):r.set(t(o),[o])}const s=[];for(const o of r.values()){const l=[...new Set(o.map(n).filter(Boolean))];if(l.length>1){for(const c of l)s.push(o.filter(d=>n(d)===c));for(const c of o)n(c)||s.push([c])}else s.push(o)}return s}function ZK(e){const[t,...n]=[...e].sort((r,s)=>Number(s.here)-Number(r.here)||+!!s.addr-+!!r.addr);return n.length?{...t,twins:n}:t}function o_(e,t){return t?e.map(n=>t[n.fp]?{...n,name:t[n.fp]}:n):e}function lc(e,t){if(!e)return{};switch(t.kind){case"paired":return{peer:(e.peers??[]).find(n=>(n.peerFp??n.fp)===t.fp)??null};case"dialling":return{peer:(e.peers??[]).find(n=>n.manual&&!n.met&&`${n.addr}:${n.port}`===t.fp)??null};case"nearby":return{stranger:(e.strangers??[]).find(n=>n.fp===t.fp)??null};case"declined":return{stranger:(e.declined??[]).find(n=>n.fp===t.fp)??null};case"asks":return{stranger:(e.pending??[]).find(n=>n.fp===t.fp)??null}}}function JK(e,t){var o;if(!e)return{text:"checking…",tone:"idle",live:!1};if(!e.enabled)return{text:"Off",tone:"idle",live:!1};if(e.stalled)return{text:"could not start",tone:"bad",live:!1};if(!e.running)return{text:"starting…",tone:"wait",live:!1};const n=t.filter(l=>l.kind==="asks").length;if(n)return{text:n===1?"1 deck wants to pair":`${n} decks want to pair`,tone:"wait",live:!1};if((o=e.reach)!=null&&o.blocked)return{text:"nothing can get in",tone:"bad",live:!1};const r=t.filter(l=>l.kind==="paired");if(!r.length)return{text:"On · none paired yet",tone:"idle",live:!1};const s=r.filter(l=>l.here).length;return s?s===r.length?{text:`${s} online`,tone:"ok",live:!0}:{text:`${s} of ${r.length} online`,tone:"ok",live:!0}:{text:`none of ${r.length} online`,tone:"idle",live:!1}}function QK(e,t){const n=e.filter(f=>f.kind==="asks"),r=e.filter(f=>f.kind!=="asks"),s=r.filter(f=>f.here),o=r.filter(f=>!f.here),l=o.filter(f=>f.tone==="bad").length,c=t||s.length===0,d=c?[...s,...o]:s,h=r.filter(f=>f.kind==="paired").length;return{asks:n,rest:r,live:s,folded:o,troubled:l,showFolded:c,shown:d,paired:h}}function i_(e){return e.map(t=>({key:`${String(t.email??"").trim().toLowerCase()}@@${t.orgUuid??""}`,email:t.email??"",alive:t.alive===!0,shareable:t.collector==="ok"||t.collector==null&&!t.active}))}function eY(e,t,n){if(!(t!=null&&t.enabled))return!1;const r=(t.peers??[]).filter(s=>s.paired&&_h(s,n)).map(s=>{var o,l;return(l=(o=s.offers)==null?void 0:o.accounts)==null?void 0:l.find(c=>c.key===e)}).filter(s=>s!=null);return r.length>0&&r.every(s=>!s.alive)}function tY(e,t,n,r){if(!(n!=null&&n.enabled)||n.running===!1)return!1;const s=String(t??"").trim().toLowerCase();return(n.peers??[]).some(o=>{var c,d,h,f;if(!o.paired||!_h(o,r))return!1;const l=(d=(c=o.offers)==null?void 0:c.accounts)==null?void 0:d.find(p=>p.key===e);return!(l!=null&&l.alive)||l.shareable===!1?!1:!((f=(h=o.last)==null?void 0:h.done)!=null&&f.some(p=>p.action==="heal"&&String(p.email??"").trim().toLowerCase()===s))})}const EO=160,CO=140;function nY(){const[e,t]=y.useState(!1),n=y.useRef(0);return y.useEffect(()=>()=>window.clearTimeout(n.current),[]),{peek:e,openPeek:c=>{window.clearTimeout(n.current),n.current=window.setTimeout(()=>t(!0),c)},shutPeek:()=>{window.clearTimeout(n.current),n.current=window.setTimeout(()=>t(!1),CO)},holdPeek:()=>window.clearTimeout(n.current),dropPeek:()=>{window.clearTimeout(n.current),t(!1)}}}function rY(e){var t;return((t=e==null?void 0:e.detail)==null?void 0:t.fix)==="give_back"}function gr(e,t){return{text:e,giveBack:rY(t),done:!1}}async function sY(){try{return await(await fetch("/api/prefs/give-back",{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"})).json().catch(()=>null)}catch{return null}}const aY={cancelled:"Nothing changed — the password dialog was closed. The folder still belongs to another user.",timed_out:"Nothing changed — the password dialog was not answered in time.",busy:"The password dialog is already open. It may be behind this window."};function oY(e){if(e!=null&&e.ok)return{text:e.changed===!1?"The settings folder is already yours, and the deck has read it again. Try that once more.":"Done — the settings folder is yours again, and the deck has read it again. Try that once more.",giveBack:!1,done:!0};if(e==null)return{text:"Could not give it back — the deck did not answer.",giveBack:!0,done:!1};const t=e.reason?aY[e.reason]:void 0;return t?{text:t,giveBack:!0,done:!1}:{text:"macOS did not give the folder back. The deck's log has the command that does it by hand.",giveBack:!1,done:!1}}const xb=5e3,TO=6e4;function Ct(e,t){if(t==null)return`Could not ${e} — the deck did not answer.`;const n=t.reason?cY(t.reason,t.detail):void 0;return n?`Could not ${e} — ${n}`:t.reason?`Could not ${e} — the deck refused it (${t.reason}).`:`Could not ${e}.`}const iY={prefs_unreadable:"this deck cannot read its settings file, so it will not write over it. The file may belong to another user, for example after ccdeck was run with sudo. The deck's log names the file.",prefs_not_writable:"this deck is not allowed to save its settings. The settings folder may belong to another user, for example after ccdeck was run with sudo, or another program may be holding the file. The deck's log names the folder."},lY=new Set(["EACCES","EPERM"]);function cY(e,t){const n=iY[e];if(!n)return;const r=e==="prefs_unreadable"&&t?uY(t):void 0,s=t!=null&&t.code&&t.code!=="BADJSON"?` Error code: ${t.code}.`:"";return(r??n)+s}function uY({code:e,owner:t,on:n}){if(e==="BADJSON")return"its settings file is damaged and could not be moved aside, so it will not write over it. The deck's log names the file.";if(n==="folder"&&t==="other")return"this deck cannot open its settings folder, which belongs to another user, for example after ccdeck was run with sudo. The deck's log has the command that gives it back.";if(n==="folder"&&t==="you")return"this deck cannot open its own settings folder, so it will not write over what is in it. The deck's log names the folder.";if(t==="other")return"its settings file belongs to another user and could not be moved aside, so it will not write over it. The deck's log names the file.";if(t==="you")return"this deck cannot read its settings file although the file is yours, so it will not write over it. Something on this machine is blocking the read; the deck's log names the file.";if(e&&!lY.has(e))return"this deck cannot read its settings file, so it will not write over it. The deck's log names the file."}async function ei(e,t){return(await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).json().catch(()=>null)}function dY(e,t){const[n,r]=y.useState(null),[s,o]=y.useState([]),[l,c]=y.useState(null),[d,h]=y.useState(null),f=y.useRef(null),p=y.useCallback(L=>xh(f.current)?(f.current=L,c(L),!0):!1,[]),g=y.useCallback(()=>{f.current=null,x.current&&c(null)},[]),v=L=>{const M=oa(l,L);return{disabled:M.disabled,"aria-busy":M.busy}},[j,k]=y.useState(()=>Date.now()),x=y.useRef(!0),N=y.useRef(xb),b=y.useCallback(async()=>{var L,M;try{const[F,T]=await Promise.all([fetch("/api/lan").then(P=>P.json()),fetch("/api/prefs").then(P=>P.json())]);if(!x.current)return;F!=null&&F.ok&&r(F),T!=null&&T.ok&&o(Array.isArray((M=(L=T.prefs)==null?void 0:L.lan)==null?void 0:M.manual)?T.prefs.lan.manual:[]),N.current=(F==null?void 0:F.enabled)===!0?xb:TO}catch{}},[]);y.useEffect(()=>{x.current=!0;let L=0;const M=async()=>{k(Date.now()),await b(),x.current&&(L=window.setTimeout(M,N.current))};return M(),()=>{x.current=!1,window.clearTimeout(L)}},[b]);const S=y.useCallback(async()=>{const L=(n==null?void 0:n.enabled)===!0;if(p("switch"))try{const M=await ei("/api/prefs",{lan:{enabled:!L}});if(!x.current)return;M!=null&&M.ok?(h(null),L||t()):h(gr(Ct(L?"turn this off":"turn this on",M),M)),await b()}catch{x.current&&h(gr(Ct(L?"turn this off":"turn this on",null)))}finally{g()}},[n==null?void 0:n.enabled,b,p,g,t]),E=y.useCallback(async(L,M,F)=>{if(!p(`${L}:${M}`))return null;let T=null;try{const P=await ei("/api/lan/peer",{action:L,fp:M});if(!x.current)return null;P!=null&&P.ok?(r(P),h(null)):(T=Ct(F,P),h(gr(T,P))),await b()}catch{T=Ct(F,null),x.current&&h(gr(T))}finally{g()}return T},[b,p,g]),R=y.useCallback(async L=>{if(!p(`drop:${L}`))return null;let M=null;try{const F=await ei("/api/prefs",{lan:{manual:s.filter(T=>T!==L)}});if(!x.current)return null;F!=null&&F.ok?(h(null),e()):(M=Ct("stop dialling that address",F),h(gr(M,F))),await b()}catch{M=Ct("stop dialling that address",null),x.current&&h(gr(M))}finally{g()}return M},[s,b,e,p,g]),I=y.useCallback(async(L,M)=>{if(!p(`alias:${L}`))return"Something else is still being saved. Try again in a moment.";try{const F=await ei("/api/lan/peer",{action:"alias",fp:L,name:M});return x.current?F!=null&&F.ok?(r(F),null):Ct("rename that deck",F):null}catch{return Ct("rename that deck",null)}finally{g()}},[p,g]),A=y.useCallback(async L=>{if(!p(`check:${L}`))return null;try{const M=await ei("/api/lan/sync",{fp:L});return x.current?M!=null&&M.ok?(r(M),e(),null):(M==null?void 0:M.reason)==="no_address"?"There is no address here to call it on. It calls this deck, and it is up to date each time it does.":Ct("check that deck",M):null}catch{return Ct("check that deck",null)}finally{g()}},[p,g,e]),q=y.useCallback(async()=>{if(p("check"))try{const L=await ei("/api/lan/sync",{});if(!x.current)return;L!=null&&L.ok?(r(L),h(null)):h(gr(Ct("check the other decks",L),L)),e()}catch{x.current&&h(gr(Ct("check the other decks",null)))}finally{g()}},[p,g,e]);return{status:n,manual:s,now:j,busy:l,failure:d,dismissFailure:()=>h(null),answerGiveBack:L=>{h(L),L.done&&(b(),e())},pressProps:v,load:b,toggle:S,answer:E,dropAddress:R,rename:I,checkOne:A,checkNow:q}}function hY(e){const[t,n]=y.useState(null),r=y.useRef(0);return y.useEffect(()=>{if(t==null)return;const o=window.setTimeout(()=>n(null),4e3);return()=>window.clearTimeout(o)},[t]),{armed:t,pressUnpair:o=>{const l=Date.now(),c=so({armedFor:t,target:o.fp,armedAt:r.current,now:l,gapMs:ro});if(c==="arm"){n(o.fp),r.current=l;return}c!=="ignore"&&(n(null),e("unpair",o.fp,"unpair that deck"))}}}function AO({title:e,steps:t,finish:n,aside:r,onClose:s}){const o=y.useRef(null),l=ot(s,{focusRef:o}),c=mt(s),[d,h]=y.useState(0),f=d===t.length-1,p=t[d],g=k=>h(Math.max(0,Math.min(t.length-1,k)));y.useEffect(()=>{var k,x;An(((k=document.activeElement)==null?void 0:k.tagName)??null)&&((x=o.current)==null||x.focus())},[d]);const v=k=>{k.key!=="ArrowRight"&&k.key!=="ArrowLeft"||(k.preventDefault(),k.stopPropagation(),g(k.key==="ArrowRight"?d+1:d-1))},j=()=>{if(!f){g(d+1);return}n?n.act():s()};return Pt.createPortal(a.jsx("div",{className:"modal-backdrop",...c,role:"presentation",children:a.jsxs("div",{ref:l,className:"modal guide",onClick:k=>k.stopPropagation(),onKeyDown:v,role:"dialog","aria-modal":"true","aria-labelledby":"guide-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsxs("div",{className:"modal-title",children:[a.jsx("span",{id:"guide-title",className:"modal-tool-name",children:e}),a.jsxs("span",{className:"modal-tool-id",children:[d+1," / ",t.length]})]}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:s,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[a.jsx("div",{className:"guide-stage",children:p.art},d),a.jsx("p",{className:"guide-line","aria-live":"polite",children:p.line}),a.jsx("p",{className:"guide-tip",children:p.tip??""}),a.jsxs("div",{className:"guide-foot",children:[a.jsx("div",{className:"guide-dots",children:t.map((k,x)=>a.jsx("button",{type:"button",className:"glyph-btn guide-dot","aria-label":`Step ${x+1} of ${t.length}`,"aria-current":x===d?"step":void 0,onClick:()=>g(x)},x))}),f&&r&&a.jsx("button",{type:"button",className:"ap-lan-word guide-aside",onClick:r.act,children:r.label}),d>0&&a.jsx("button",{type:"button",className:"btn",onClick:()=>g(d-1),children:"Back"}),a.jsx("button",{ref:o,type:"button",className:"btn primary",onClick:j,children:f?(n==null?void 0:n.label)??"Done":"Next"})]})]})]})}),document.body)}const bb={ok:"ga-ok",warn:"ga-warn",accent:"ga-accent",flight:"ga-flight"};function Yn({children:e}){return a.jsx("svg",{className:"guide-art",viewBox:"0 0 440 200","aria-hidden":!0,focusable:"false",children:e})}function Kn({x:e,y:t=34,w:n=176,h:r=132,label:s}){return a.jsxs(a.Fragment,{children:[s&&a.jsx("text",{x:e+2,y:t-9,className:"ga-cap",children:s}),a.jsx("rect",{x:e,y:t,width:n,height:r,rx:10,className:"ga-screen"})]})}function kr({x:e,y:t,email:n,state:r,tone:s,bars:o}){return a.jsxs(a.Fragment,{children:[a.jsx("circle",{cx:e+3,cy:t-4,r:3,className:bb[s]}),a.jsx("text",{x:e+12,y:t,className:"ga-t ga-mono",children:n}),a.jsx("text",{x:e+12,y:t+16,className:`ga-s ${bb[s]}`,children:r}),o==null?void 0:o.map((l,c)=>a.jsxs("g",{children:[a.jsx("text",{x:e,y:t+40+c*18,className:"ga-s",children:c?"7d":"5h"}),a.jsx("rect",{x:e+22,y:t+35+c*18,width:96,height:4,rx:2,className:"ga-track"}),a.jsx("rect",{x:e+22,y:t+35+c*18,width:96*l/100,height:4,rx:2,className:"ga-accent"}),a.jsxs("text",{x:e+148,y:t+40+c*18,className:"ga-s ga-accent",textAnchor:"end",children:[l,"%"]})]},c))]})}function RO({x:e,y:t,on:n}){return a.jsxs(a.Fragment,{children:[a.jsx("rect",{x:e,y:t,width:30,height:18,rx:9,className:n?"ga-switch-on":"ga-switch"}),a.jsx("circle",{cx:n?e+21:e+9,cy:t+9,r:6,className:n?"ga-knob-on":"ga-knob"})]})}function Xu({x:e,y:t,name:n,here:r=!0}){return a.jsxs(a.Fragment,{children:[a.jsx("circle",{cx:e+3,cy:t-4,r:3,className:r?"ga-ok":"ga-dim"}),a.jsx("text",{x:e+12,y:t,className:r?"ga-t":"ga-s",children:n})]})}function l_({x:e,y:t,on:n}){return n?a.jsxs(a.Fragment,{children:[a.jsx("rect",{x:e,y:t,width:12,height:12,rx:3,className:"ga-accent"}),a.jsx("path",{d:`M${e+3} ${t+6.2}l2.3 2.3 4-4.6`,className:"ga-tick"})]}):a.jsx("rect",{x:e+.5,y:t+.5,width:11,height:11,rx:3,className:"ga-box"})}function c_({x:e,y:t,d:n}){return a.jsx("path",{d:n,transform:`translate(${e} ${t})`,className:"ga-glyph"})}function Wk({x:e,y:t}){return a.jsx("path",{d:`M${e} ${t}l0 13 3.4-3 2.4 5.2 2-.9-2.4-5.1 4.6-.2z`,className:"ga-pointer"})}function Hk(){return a.jsxs(a.Fragment,{children:[a.jsx("circle",{r:9,className:"ga-key-bed"}),a.jsxs("g",{transform:"translate(-6 -6) scale(0.857)",className:"ga-key",children:[a.jsx("circle",{cx:4.6,cy:7,r:2.6}),a.jsx("path",{d:"M7.2 7h5.2M10.6 7v2.2M12.4 7v1.6"})]})]})}function ii({x:e,y:t,w:n,title:r,sub:s,tone:o}){return a.jsxs(a.Fragment,{children:[a.jsx("rect",{x:e,y:t,width:n,height:40,rx:8,className:"ga-screen"}),a.jsx("rect",{x:e+6,y:t+10,width:3,height:20,rx:1.5,className:bb[o]}),a.jsx("text",{x:e+16,y:t+17,className:"ga-t ga-strong",children:r}),a.jsx("text",{x:e+16,y:t+31,className:"ga-s",children:s})]})}function fi({x:e,y:t,label:n,live:r}){return a.jsxs(a.Fragment,{children:[a.jsx("rect",{x:e,y:t,width:46,height:20,rx:10,className:r?"ga-chip-live":"ga-chip"}),a.jsx("text",{x:e+23,y:t+14,className:"ga-s ga-mono",textAnchor:"middle",children:n})]})}function Fd({x:e,y:t}){return a.jsxs(a.Fragment,{children:[a.jsx("text",{x:e,y:t,className:"ga-cap",children:"LOCAL NETWORK"}),a.jsx(RO,{x:e+118,y:t-13,on:!0})]})}function fY(){return a.jsxs(Yn,{children:[a.jsx("rect",{x:14,y:14,width:206,height:172,rx:10,className:"ga-screen"}),a.jsx("text",{x:28,y:38,className:"ga-t ga-strong",children:"Sessions"}),a.jsx("text",{x:206,y:38,className:"ga-s ga-warn",textAnchor:"end",children:"1 waiting"}),a.jsx("rect",{x:20,y:50,width:194,height:42,rx:6,className:"ga-bed-warn"}),a.jsx("circle",{cx:33,cy:64,r:7,className:"ga-ring-warn ga-ping"}),a.jsx("circle",{cx:33,cy:64,r:3.5,className:"ga-warn"}),a.jsx("text",{x:44,y:68,className:"ga-t",children:"api-server"}),a.jsx("text",{x:44,y:83,className:"ga-s ga-warn",children:"waiting 6m · Bash"}),a.jsx("circle",{cx:33,cy:108,r:3.5,className:"ga-flight"}),a.jsx("text",{x:44,y:112,className:"ga-t",children:"docs-site"}),a.jsx("text",{x:44,y:127,className:"ga-s",children:"running · 12 tools"}),a.jsx("circle",{cx:33,cy:150,r:3.5,className:"ga-ok"}),a.jsx("text",{x:44,y:154,className:"ga-t",children:"billing"}),a.jsx("text",{x:44,y:169,className:"ga-s",children:"done · $0.84"}),a.jsx("path",{d:"M216 71C234 71 230 100 244 100",className:"ga-arc"}),a.jsx("path",{d:"M239 96l5 4-5 4",className:"ga-arrow"}),a.jsx("rect",{x:248,y:44,width:178,height:112,rx:10,className:"ga-screen"}),a.jsx("text",{x:262,y:64,className:"ga-cap",children:"API-SERVER"}),a.jsx("line",{x1:248,y1:74,x2:426,y2:74,className:"ga-line"}),a.jsx("text",{x:262,y:96,className:"ga-s ga-mono",children:"Bash(npm test)"}),a.jsx("text",{x:262,y:116,className:"ga-t ga-mono ga-warn",children:"Allow this command?"}),a.jsx("text",{x:262,y:136,className:"ga-s ga-mono",children:"> 1. Yes 2. No"})]})}function pY(){return a.jsxs(Yn,{children:[a.jsx("path",{d:"M136 100C166 100 166 38 196 38",className:"ga-edge ga-flow"}),a.jsx("path",{d:"M136 100H196",className:"ga-edge ga-flow"}),a.jsx("path",{d:"M136 100C166 100 166 162 196 162",className:"ga-edge-done"}),a.jsx("path",{d:"M308 38H326M308 100H326",className:"ga-edge"}),a.jsx(ii,{x:20,y:80,w:116,title:"main",sub:"Opus 5 · 9 tools",tone:"accent"}),a.jsx(ii,{x:196,y:18,w:112,title:"explore",sub:"Haiku · 14 tools",tone:"flight"}),a.jsx(ii,{x:196,y:80,w:112,title:"tests",sub:"Sonnet · 6 tools",tone:"flight"}),a.jsx(ii,{x:196,y:142,w:112,title:"review",sub:"done · 38s",tone:"ok"}),a.jsx(fi,{x:326,y:28,label:"Read"}),a.jsx(fi,{x:380,y:28,label:"Grep",live:!0}),a.jsx(fi,{x:326,y:90,label:"Bash",live:!0})]})}function u_({x:e,y:t,label:n,pct:r,note:s}){return a.jsxs(a.Fragment,{children:[a.jsx("text",{x:e,y:t,className:"ga-s",children:n}),a.jsxs("text",{x:e+194,y:t,className:"ga-s ga-accent",textAnchor:"end",children:[r,"%"]}),a.jsx("rect",{x:e,y:t+7,width:194,height:5,rx:2.5,className:"ga-track"}),a.jsx("rect",{x:e,y:t+7,width:194*r/100,height:5,rx:2.5,className:"ga-accent"}),a.jsx("text",{x:e,y:t+26,className:"ga-s",children:s})]})}function mY(){return a.jsxs(Yn,{children:[a.jsx("rect",{x:14,y:30,width:172,height:140,rx:10,className:"ga-screen"}),a.jsx("text",{x:30,y:56,className:"ga-cap",children:"THIS SESSION"}),a.jsx("text",{x:30,y:98,className:"ga-big",children:"$3.66"}),a.jsx("text",{x:30,y:122,className:"ga-s",children:"Opus 5 · 1.2M tokens"}),a.jsx("text",{x:30,y:150,className:"ga-s",children:"$21.40 today"}),a.jsx("rect",{x:200,y:30,width:226,height:140,rx:10,className:"ga-screen"}),a.jsx("text",{x:216,y:56,className:"ga-cap",children:"CLAUDE QUOTA"}),a.jsx(u_,{x:216,y:80,label:"5-hour window",pct:24,note:"resets in 53m"}),a.jsx(u_,{x:216,y:124,label:"7-day window",pct:61,note:"resets in 4d"})]})}function gY(){return a.jsxs(Yn,{children:[a.jsx("rect",{x:14,y:40,width:172,height:120,rx:10,className:"ga-canvas"}),a.jsx(ii,{x:30,y:80,w:140,title:"tests",sub:"Sonnet 5 · 6 tools",tone:"flight"}),a.jsx(Wk,{x:156,y:106}),a.jsx("path",{d:"M170 92C186 92 184 60 200 60",className:"ga-arc"}),a.jsx("path",{d:"M195 56l5 4-5 4",className:"ga-arrow"}),a.jsx(Kn,{x:200,y:22,w:226,h:160}),a.jsx("text",{x:214,y:46,className:"ga-t ga-strong",children:"tests"}),a.jsx("text",{x:412,y:46,className:"ga-s",textAnchor:"end",children:"Sonnet 5 · 38s"}),a.jsx("line",{x1:200,y1:56,x2:426,y2:56,className:"ga-line"}),a.jsx("text",{x:214,y:76,className:"ga-cap",children:"PROMPT"}),a.jsx("text",{x:214,y:92,className:"ga-t",children:"Run the suite and fix what fails"}),a.jsx("text",{x:214,y:116,className:"ga-cap",children:"TOOLS · 6"}),a.jsx(fi,{x:214,y:122,label:"Read"}),a.jsx(fi,{x:266,y:122,label:"Edit"}),a.jsx(fi,{x:318,y:122,label:"Bash",live:!0}),a.jsx("text",{x:214,y:164,className:"ga-cap",children:"TOKENS"}),a.jsx("text",{x:214,y:178,className:"ga-s ga-mono",children:"41k in · 2.1k out · $0.12"})]})}function yY(){const e=[18,24,28,14,22,26,30,16,24,28,20,26];return a.jsxs(Yn,{children:[a.jsx(Kn,{x:14,y:20,w:412,h:160}),a.jsx("text",{x:28,y:44,className:"ga-t ga-strong",children:"This machine"}),a.jsx("text",{x:412,y:44,className:"ga-s",textAnchor:"end",children:"12 cores · up 10d"}),a.jsx("line",{x1:14,y1:56,x2:426,y2:56,className:"ga-line"}),a.jsx("text",{x:28,y:76,className:"ga-cap",children:"CORES"}),e.map((t,n)=>a.jsxs("g",{children:[a.jsx("rect",{x:28+n*15,y:82,width:10,height:30,rx:2,className:"ga-track"}),a.jsx("rect",{x:28+n*15,y:112-t,width:10,height:t,rx:2,className:"ga-accent"})]},n)),a.jsx("text",{x:28,y:136,className:"ga-cap",children:"MEMORY"}),a.jsx("rect",{x:28,y:143,width:178,height:5,rx:2.5,className:"ga-track"}),a.jsx("rect",{x:28,y:143,width:105,height:5,rx:2.5,className:"ga-accent"}),a.jsx("text",{x:28,y:165,className:"ga-s",children:"18.9 GB of 32.0 GB"}),a.jsx("text",{x:240,y:76,className:"ga-cap",children:"THERMAL"}),a.jsx("text",{x:240,y:100,className:"ga-big",children:"66 °C"}),a.jsx("text",{x:240,y:118,className:"ga-s ga-ok",children:"running at full speed"}),a.jsx("text",{x:240,y:142,className:"ga-cap",children:"BUSIEST PROCESSES"}),a.jsx("text",{x:240,y:160,className:"ga-s ga-mono",children:"node · claude"}),a.jsx("text",{x:412,y:160,className:"ga-s ga-mono",textAnchor:"end",children:"38%"}),a.jsx("text",{x:240,y:176,className:"ga-s ga-mono",children:"esbuild"}),a.jsx("text",{x:412,y:176,className:"ga-s ga-mono",textAnchor:"end",children:"21%"})]})}function wY(){return a.jsxs(Yn,{children:[a.jsx("rect",{x:14,y:40,width:188,height:120,rx:10,className:"ga-screen"}),a.jsx("text",{x:28,y:60,className:"ga-cap",children:"~/MY-PROJECT"}),a.jsx("line",{x1:14,y1:70,x2:202,y2:70,className:"ga-line"}),a.jsxs("text",{x:28,y:100,className:"ga-t ga-mono",children:[a.jsx("tspan",{className:"ga-accent",children:"$"})," claude"]}),a.jsx("rect",{x:86,y:90,width:7,height:13,className:"ga-caret ga-blink"}),a.jsx("text",{x:28,y:130,className:"ga-s ga-mono",children:"or: codex"}),a.jsx("path",{d:"M210 100H238",className:"ga-arc"}),a.jsx("path",{d:"M233 95l6 5-6 5",className:"ga-arrow"}),a.jsx("rect",{x:250,y:40,width:176,height:120,rx:10,className:"ga-canvas"}),a.jsx("g",{className:"ga-pop",children:a.jsx(ii,{x:278,y:80,w:120,title:"my-project",sub:"Opus 5 · live",tone:"accent"})})]})}function vY(){return a.jsxs(Yn,{children:[a.jsx(Kn,{x:14,y:16,w:232,h:170}),a.jsx("text",{x:28,y:40,className:"ga-t ga-strong",children:"Claude accounts"}),a.jsx(c_,{x:196,y:33,d:"M7 2.2v9.6M2.2 7h9.6"}),a.jsx(c_,{x:220,y:33,d:"M3.3 10.7L10.7 3.3M5.2 3.3h5.5v5.5"}),a.jsx("line",{x1:14,y1:52,x2:246,y2:52,className:"ga-line"}),a.jsx(kr,{x:28,y:74,email:"work@team.dev",state:"working",tone:"ok",bars:[24,61]}),a.jsx("rect",{x:190,y:62,width:44,height:18,rx:9,className:"ga-accent"}),a.jsx("text",{x:212,y:74,className:"ga-s ga-on-accent",textAnchor:"middle",children:"active"}),a.jsx("line",{x1:14,y1:140,x2:246,y2:140,className:"ga-line"}),a.jsx(kr,{x:28,y:160,email:"personal@me.dev",state:"signed in",tone:"ok"}),a.jsx("rect",{x:188,y:148,width:46,height:18,rx:9,className:"ga-chip"}),a.jsx("text",{x:211,y:160,className:"ga-s",textAnchor:"middle",children:"switch"}),a.jsx(Wk,{x:221,y:161}),a.jsx("path",{d:"M250 40C270 40 262 78 282 78",className:"ga-arc"}),a.jsx("path",{d:"M277 74l5 4-5 4",className:"ga-arrow"}),a.jsx(Kn,{x:282,y:62,w:144,h:64,label:"ANOTHER MACHINE"}),a.jsx("g",{className:"ga-pop",children:a.jsx(kr,{x:296,y:92,email:"work@team.dev",state:"shared here",tone:"ok"})})]})}function xY(){return a.jsxs(Yn,{children:[a.jsx(Kn,{x:14,label:"THIS MACHINE"}),a.jsx(Fd,{x:28,y:60}),a.jsx("g",{className:"ga-swap-out",children:a.jsx(kr,{x:28,y:98,email:"work@team.dev",state:"login expired",tone:"warn"})}),a.jsx("g",{className:"ga-swap-in",children:a.jsx(kr,{x:28,y:98,email:"work@team.dev",state:"working again",tone:"ok",bars:[24,61]})}),a.jsx(Kn,{x:250,label:"ANOTHER MACHINE"}),a.jsx(Fd,{x:264,y:60}),a.jsx(kr,{x:264,y:98,email:"work@team.dev",state:"working",tone:"ok",bars:[24,61]}),a.jsx("path",{d:"M246 120C234 80 206 80 194 120",className:"ga-arc"}),a.jsx("g",{className:"ga-travel ga-travel-low",transform:"translate(220 90)",children:a.jsx(Hk,{})})]})}const bY=[{art:a.jsx(fY,{}),line:"Sessions waiting on you top the session list, longest wait first.",tip:"A tone and a system notification when one stops to ask. The speaker in the topbar."},{art:a.jsx(pY,{}),line:"Every agent and subagent is a node. Tool calls light up as they run."},{art:a.jsx(gY,{}),line:"Double-click any node: its prompt, every tool call, tokens and timing."},{art:a.jsx(mY,{}),line:"What each session costs, and how much quota is left."},{art:a.jsx(yY,{}),line:"Cores, memory and heat while the agents run, and what is hogging them."},{art:a.jsx(vY,{}),line:"Several Claude accounts: switch, add one, share one to another machine."},{art:a.jsx(xY,{}),line:"Your machines repair each other's expired logins over the local network.",tip:"Open it from the row at the foot of the Claude accounts panel."},{art:a.jsx(wY,{}),line:"Run claude or codex in any folder. It shows up here on its own."}];function kY(){return a.jsxs(Yn,{children:[a.jsx(Kn,{x:14,label:"THIS MACHINE"}),a.jsx(kr,{x:28,y:64,email:"work@team.dev",state:"login expired",tone:"warn"}),a.jsx("rect",{x:40,y:94,width:86,height:20,rx:10,className:"ga-pill-warn"}),a.jsx("text",{x:83,y:108,className:"ga-s ga-warn",textAnchor:"middle",children:"sign in again"}),a.jsx("line",{x1:198,y1:100,x2:242,y2:100,className:"ga-off"}),a.jsx(Kn,{x:250,label:"ANOTHER MACHINE"}),a.jsx(kr,{x:264,y:64,email:"work@team.dev",state:"working",tone:"ok",bars:[24,61]})]})}function NY(){return a.jsxs(Yn,{children:[a.jsx(Kn,{x:14,label:"THIS MACHINE"}),a.jsx(Fd,{x:28,y:60}),a.jsx(Xu,{x:28,y:92,name:"Ana's MacBook"}),a.jsx(Xu,{x:28,y:114,name:"Dorin's PC"}),a.jsx(Kn,{x:250,label:"ANOTHER MACHINE"}),a.jsx(Fd,{x:264,y:60}),a.jsx(Xu,{x:264,y:92,name:"Your MacBook"}),a.jsx(Xu,{x:264,y:114,name:"Dorin's PC"}),a.jsx("line",{x1:196,y1:100,x2:244,y2:100,className:"ga-arc"}),a.jsx("circle",{cx:220,cy:100,r:10,className:"ga-ring ga-ping"}),a.jsx("circle",{cx:220,cy:100,r:10,className:"ga-ring ga-ping ga-ping-2"}),a.jsx("circle",{cx:220,cy:100,r:3,className:"ga-accent"})]})}function jY(){return a.jsxs(Yn,{children:[a.jsx("rect",{x:90,y:18,width:260,height:164,rx:10,className:"ga-screen"}),a.jsx("text",{x:106,y:42,className:"ga-t ga-strong",children:"This deck on the network"}),a.jsx("line",{x1:90,y1:54,x2:350,y2:54,className:"ga-line"}),a.jsx("text",{x:106,y:76,className:"ga-cap",children:"SHARE THESE ACCOUNTS"}),a.jsx(l_,{x:106,y:88,on:!0}),a.jsx("text",{x:126,y:98,className:"ga-t ga-mono",children:"work@team.dev"}),a.jsx(l_,{x:106,y:112}),a.jsx("text",{x:126,y:122,className:"ga-s ga-mono",children:"personal@me.dev"}),a.jsx("text",{x:106,y:150,className:"ga-cap",children:"PAIRING"}),a.jsx("text",{x:106,y:168,className:"ga-s",children:"Say yes to every deck that asks"}),a.jsx(RO,{x:304,y:157,on:!0}),a.jsx(Wk,{x:115,y:97})]})}function SY(){return a.jsxs(Yn,{children:[a.jsx(Kn,{x:14,label:"THIS MACHINE"}),a.jsx("g",{className:"ga-swap-out",children:a.jsx(kr,{x:28,y:64,email:"work@team.dev",state:"login expired",tone:"warn"})}),a.jsx("g",{className:"ga-swap-in",children:a.jsx(kr,{x:28,y:64,email:"work@team.dev",state:"working again",tone:"ok",bars:[24,61]})}),a.jsx(Kn,{x:250,label:"ANOTHER MACHINE"}),a.jsx(kr,{x:264,y:64,email:"work@team.dev",state:"working",tone:"ok",bars:[24,61]}),a.jsx("path",{d:"M246 96C234 56 206 56 194 96",className:"ga-arc"}),a.jsx("g",{className:"ga-travel",transform:"translate(220 66)",children:a.jsx(Hk,{})})]})}const _Y=[{art:a.jsx(kY,{}),line:"A login can expire on one machine while it still works on another."},{art:a.jsx(NY,{}),line:"Both decks are on. They find each other and ask to pair.",tip:"Not showing up? Add a deck, the link at the top, takes an address or invite."},{art:a.jsx(jY,{}),line:"Tick which logins this machine may hand out. Nothing is shared until you do."},{art:a.jsx(SY,{}),line:"An expired login is copied from a paired machine within a minute."}];function EY(){return a.jsxs("svg",{className:"guide-art",viewBox:"0 0 232 60","aria-hidden":!0,focusable:"false",children:[a.jsx("rect",{x:1,y:14,width:78,height:42,rx:7,className:"ga-screen"}),a.jsx("circle",{cx:13,cy:29,r:3,className:"ga-warn"}),a.jsx("rect",{x:21,y:27,width:46,height:4,rx:2,className:"ga-track"}),a.jsx("rect",{x:13,y:39,width:40,height:3,rx:1.5,className:"ga-track"}),a.jsx("rect",{x:153,y:14,width:78,height:42,rx:7,className:"ga-screen"}),a.jsx("circle",{cx:165,cy:29,r:3,className:"ga-ok"}),a.jsx("rect",{x:173,y:27,width:46,height:4,rx:2,className:"ga-track"}),a.jsx("rect",{x:165,y:39,width:40,height:3,rx:1.5,className:"ga-accent"}),a.jsx("path",{d:"M150 36C138 6 94 6 82 36",className:"ga-arc"}),a.jsx("g",{transform:"translate(116 13)",children:a.jsx(Hk,{})})]})}const CY={panel:"Nothing here is stuck: whoever pastes an invite is the one dialling out. Ask them for one and paste it behind Add a deck, the link above, where an address can be typed too.",dialog:"Nothing here is stuck: whoever pastes an invite is the one dialling out. Ask them for one and paste it below, or type their address."},TY=1600;function MO({reach:e,where:t}){const[n,r]=y.useState(!1),s=y.useRef(!0);y.useEffect(()=>()=>{s.current=!1},[]);const o=(e==null?void 0:e.steps)??[],l=y.useCallback(async()=>{await oo(o.join(`
93
- `))&&s.current&&(r(!0),window.setTimeout(()=>{s.current&&r(!1)},TY))},[o]);if(!(e!=null&&e.blocked))return null;const c=e.shell==="sh",d=!!e.tool;return a.jsxs("div",{className:"ap-lan-reach",children:[a.jsx("p",{className:"lan-warn",children:e.text}),a.jsx("p",{className:"lan-note",children:CY[t]}),o.length>0&&a.jsxs("details",{className:"ap-lan-reach-fix",children:[a.jsx("summary",{children:"or let them find this deck on their own"}),a.jsxs("p",{className:"lan-note",children:[d?a.jsx(a.Fragment,{children:"Run this in a terminal on this machine. It applies at once, and this note goes away when another deck connects."}):c?a.jsx(a.Fragment,{children:"Run this in a terminal on this machine, then restart the deck."}):a.jsxs(a.Fragment,{children:["Run this in PowerShell ",a.jsx("strong",{children:"as Administrator"}),", then restart the deck."]}),e.category==="Public"&&a.jsx(a.Fragment,{children:" The first line marks this network as a home or office one — leave it out on a network you do not trust."}),e.unsure&&a.jsxs(a.Fragment,{children:[" ",e.unsure]})]}),a.jsx("pre",{className:"ap-lan-cmd",children:a.jsx("code",{children:o.join(`
94
- `)})}),a.jsx("button",{type:"button",className:"ap-manage-btn",onClick:()=>void l(),title:c?"Copy these lines, then paste them into a terminal":"Copy these lines, then paste them into an elevated PowerShell",children:n?"copied":"copy command"})]})]})}function AY(e){const t=(e??"").trim(),n=t.lastIndexOf(":");if(n<=0||n===t.length-1)return null;const r=t.slice(0,n).trim(),s=Number(t.slice(n+1).trim());return!r||!Number.isInteger(s)||s<1||s>65535||r.includes(":")&&!(r.startsWith("[")&&r.endsWith("]"))?null:{addr:r,port:s}}function RY(e,t){const n=Math.max(0,Math.round((e-t)/1e3));return`${Math.floor(n/60)}:${String(n%60).padStart(2,"0")}`}async function nm(e,t){return(await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).json().catch(()=>null)}const MY={not_an_invite:"That is not an invite — paste the whole line they sent you.",expired:"That invite has run out. Ask them for a fresh one.",not_running:"This deck is not on the network yet. Turn Local network on, then try again."},$Y={not_running:"This deck is not on the network yet. Turn Local network on, then make one."};function d_(e,t,n){return(t==null?void 0:t.reason)&&e[t.reason]||Ct(n,t)}function IY({status:e,manual:t,startWith:n,onClose:r,onChanged:s}){const o=y.useRef(null),l=y.useRef(null),c=y.useRef(null),d=y.useRef(null),h=e.pairingMode==="invite",f=ot(r,{focusRef:h?l:o}),p=mt(r),[g,v]=y.useState(""),[j,k]=y.useState(""),[x,N]=y.useState(null),[b,S]=y.useState(null),[E,R]=y.useState(null),[I,A]=y.useState(null),[q,$]=y.useState(()=>Date.now());y.useEffect(()=>{const Y=window.setInterval(()=>$(Date.now()),1e3);return()=>window.clearInterval(Y)},[]);const B=y.useRef(!0);y.useEffect(()=>()=>{B.current=!1},[]);const L=y.useRef(null),M=y.useRef(null),F=y.useCallback(Y=>xh(L.current)?(L.current=Y,R(Y),!0):!1,[]),T=y.useCallback(()=>{L.current=null,B.current&&R(null)},[]),P=Y=>{const X=oa(E,Y);return{disabled:X.disabled,"aria-busy":X.busy}},O=Y=>(x==null?void 0:x.field)===Y?{"aria-invalid":!0,"aria-describedby":"lan-add-failure"}:{},G=Y=>N(X=>X&&X.field===Y?null:X),K=y.useCallback(async()=>{if(h)return;const Y=AY(g);if(!Y){N({text:OY(g),field:"addr"});return}const X=`${Y.addr}:${Y.port}`,ee=e.peers.find(ae=>ae.addr===Y.addr&&ae.port===Y.port&&ae.paired);if(ee){N({text:`Already paired with ${ee.name} at that address.`,field:"addr"});return}if(t.includes(X)){N({text:"This deck already calls that address.",field:"addr"});return}if(F("add"))try{const ae=await nm("/api/prefs",{lan:{manual:[...t,X]}});if(!B.current)return;ae!=null&&ae.ok?(N(null),v(""),s(),r()):N({text:Ct("add that address",ae),field:"addr"})}catch{B.current&&N({text:Ct("add that address",null),field:"addr"})}finally{T()}},[g,h,t,e.peers,s,r,F,T]),U=y.useCallback(async Y=>{if(!F(`invite:${Y}`))return;const X=Y==="make"?"make an invite":"cancel that invite";try{const ee=await nm("/api/lan/invite",{action:Y});if(!B.current)return;ee!=null&&ee.ok?(M.current=Y,N(null),S(null),s()):N({text:d_($Y,ee,X)})}catch{B.current&&N({text:Ct(X,null)})}finally{T()}},[s,F,T]),H=y.useCallback(async()=>{const Y=j.trim();if(!(!Y||!F("join"))){A(null);try{const X=await nm("/api/lan/invite",{action:"join",token:Y});if(!B.current)return;X!=null&&X.ok?(k(""),N(null),s(),r()):(X==null?void 0:X.reason)==="unreachable"&&Array.isArray(X.tried)&&X.tried.length?(A(X.tried),N(null)):(A(null),N({text:d_(MY,X,"use that invite"),field:"join"}))}catch{B.current&&N({text:Ct("use that invite",null),field:"join"})}finally{T()}}},[j,s,r,F,T]),D=y.useCallback(async(Y,X)=>{try{await navigator.clipboard.writeText(Y),S(X),window.setTimeout(()=>{B.current&&S(ee=>ee===X?null:ee)},1600)}catch{N({text:"Could not copy it — select the text and copy it by hand."})}},[]),V=e.invite&&e.invite.expiresAt>q?e.invite:null,J=y.useRef(!1);y.useEffect(()=>{n!=="invite"||J.current||V||(J.current=!0,U("make"))},[n,V,U]);const W=y.useRef(!1);y.useEffect(()=>{var Y;n!=="invite"||W.current||!V||(W.current=!0,(Y=c.current)==null||Y.focus())},[n,V]),y.useEffect(()=>{var X,ee;const Y=M.current;!Y||Y==="make"!=!!V||(M.current=null,An(((X=document.activeElement)==null?void 0:X.tagName)??null)&&((ee=(Y==="make"?c:d).current)==null||ee.focus()))},[V]);const Z=e.port!=null?(e.addrs??[]).map(Y=>`${Y}:${e.port}`):[];return Pt.createPortal(a.jsx("div",{className:"modal-backdrop",...p,role:"presentation",children:a.jsxs("div",{ref:f,className:"modal lan-add",onClick:Y=>Y.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-add-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{id:"lan-add-title",className:"modal-tool-name",children:"Add a deck"})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{className:"glyph-btn",onClick:r,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[x&&a.jsxs("div",{className:"ap-failure",role:"alert",children:[a.jsx("span",{id:"lan-add-failure",className:"ap-failure-text",children:x.text}),a.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>N(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),a.jsx(MO,{reach:e.reach,where:"dialog"}),h&&a.jsx("div",{className:"modal-section",children:a.jsx("p",{className:"lan-note",children:"Adding by address is off while this deck pairs only by invite."})}),!h&&a.jsxs("div",{className:"modal-section",children:[a.jsx("h3",{className:"lan-h",children:"By address"}),a.jsxs("div",{className:"ap-lan-row",children:[a.jsx("input",{ref:o,className:"ap-manage-input ap-lan-input","aria-label":"Another deck's address",value:g,placeholder:"192.168.1.5:54340",spellCheck:!1,...O("addr"),onChange:Y=>{v(Y.target.value),G("addr")},onKeyDown:Y=>{Y.key==="Enter"&&K()}}),g.trim()!==""&&a.jsx("button",{type:"button",className:"ap-manage-btn",...P("add"),onClick:()=>void K(),title:"Add it to the decks this one calls, starting now.",children:"add"})]}),a.jsx("p",{className:"lan-note",children:"This deck calls that address until somebody there accepts."}),e.port!=null&&Z.length>0&&a.jsxs("p",{className:"lan-note",children:["They type this deck’s own address into the same field on theirs:"," ",Z.map((Y,X)=>a.jsxs("span",{children:[X>0&&" or ",a.jsx("code",{className:"ap-lan-code",children:Y})]},Y)),a.jsx("button",{type:"button",className:"ap-lan-word lan-copy",...P("copy:mine"),onClick:()=>void D(Z.join(" "),"mine"),title:"Copy this deck's address, to send to whoever is adding it",children:b==="mine"?"copied":"copy"})]})]}),a.jsxs("div",{className:"modal-section",children:[a.jsxs("h3",{className:"lan-h",children:["With an invite",!V&&a.jsx("button",{type:"button",className:"ap-lan-word lan-h-act",ref:d,...P("invite:make"),onClick:()=>void U("make"),title:"One piece of text you send them. They paste it, and the two decks pair — nobody has to press anything here.",children:E==="invite:make"?"making…":"make one to send"})]}),a.jsxs("div",{className:"ap-lan-row",children:[a.jsx("input",{ref:l,className:"ap-manage-input ap-lan-input","aria-label":"An invite you were sent",value:j,placeholder:"paste one you were sent",spellCheck:!1,...O("join"),onChange:Y=>{k(Y.target.value),A(null),G("join")},onKeyDown:Y=>{Y.key==="Enter"&&H()}}),j.trim()!==""&&a.jsx("button",{type:"button",className:"ap-manage-btn",...P("join"),onClick:()=>void H(),title:"Reach that deck and pair with it. Nobody has to press anything there.",children:E==="join"?"joining…":"join"})]}),a.jsx("p",{className:"lan-note",children:"Pasting one pairs both decks on the spot — nobody has to accept."}),I&&a.jsxs("div",{className:"ap-lan-tried",children:[a.jsx("span",{className:"lan-note",children:"Nothing answered at any address in that invite. Check that deck is running with its Local network switch on."}),I.map(Y=>a.jsxs("span",{className:"ap-lan-tried-row",children:[a.jsx("code",{className:"ap-lan-code",children:Y.addr}),a.jsx("span",{className:"ap-lan-bad",children:Y.why})]},Y.addr))]}),V&&a.jsxs("div",{className:"ap-lan-invite",children:[a.jsxs("div",{className:"ap-lan-invite-head",children:[a.jsx("span",{className:"ap-lan-invite-title",children:"Send this to them"}),a.jsxs("span",{className:"ap-lan-invite-left",id:"lan-invite-left",children:[RY(V.expiresAt,q)," left"]})]}),a.jsx("code",{className:"ap-lan-token",children:V.token}),a.jsxs("div",{className:"ap-lan-acts",children:[a.jsx("button",{type:"button",className:"ap-manage-btn",ref:c,...P("copy:invite"),"aria-label":b==="invite"?"Invite copied":"Copy invite","aria-describedby":"lan-invite-left",onClick:()=>void D(V.token,"invite"),title:"Copy it, and send it however you already talk to them",children:b==="invite"?"copied":"copy"}),a.jsx("button",{type:"button",className:"ap-manage-btn",...P("invite:withdraw"),onClick:()=>void U("withdraw"),title:"Cancel it. Anybody already holding the text can no longer use it.",children:"cancel"})]}),a.jsx("p",{className:"lan-warn",children:"Anyone who gets this text can pair with this deck until it runs out."})]})]})]})]})}),document.body)}function OY(e){const t=(e??"").trim();if(t==="")return"Type an address and a port, like 192.168.1.5:54340.";if(!t.startsWith("[")&&(t.match(/:/g)??[]).length>1)return"Too many colons to split. Use that deck's IPv4 address or its name, like 192.168.1.5:54340.";if(!t.includes(":"))return`Add the port too, like ${t}:54340.`;const n=t.slice(t.lastIndexOf(":")+1).trim();return n===""?"That is missing its port — try 192.168.1.5:54340.":/^\d+$/.test(n)?`A port runs from 1 to 65535, and this one is ${n}.`:`A port is a number, and this one is "${n}".`}function LY({asks:e,pressProps:t,answer:n}){return a.jsx("div",{className:"ap-lan-asks",role:"alert",children:e.map(r=>a.jsxs("div",{className:"ap-lan-ask",children:[a.jsxs("span",{className:"ap-lan-ask-what",children:[a.jsx("strong",{className:"ap-lan-peer-name",children:r.name})," at ",a.jsx("code",{className:"ap-lan-code",children:r.addr})," wants to pair"]}),a.jsxs("span",{className:"ap-lan-ask-fp",id:`lan-ask-fp-${r.fp}`,children:["fingerprint ",a.jsx("code",{className:"ap-lan-code",children:r.fp})]}),a.jsxs("span",{className:"ap-lan-ask-acts",children:[a.jsx("button",{type:"button",className:"ap-manage-btn",...t(`accept:${r.fp}`),"aria-label":`Accept ${r.name}`,"aria-describedby":`lan-ask-fp-${r.fp}`,onClick:()=>void n("accept",r.fp,"accept that deck"),title:`Talk to this deck from now on. Its fingerprint is ${r.fp} — check it matches the one on their screen before you accept.`,children:"accept"}),a.jsx("button",{type:"button",className:"ap-manage-btn",...t(`dismiss:${r.fp}`),"aria-label":`Decline ${r.name}`,"aria-describedby":`lan-ask-fp-${r.fp}`,onClick:()=>void n("dismiss",r.fp,"decline that request"),title:"Say no. Nothing is shared, and that deck is told rather than left waiting.",children:"decline"})]})]},r.fp))})}function PY({rows:e,pairingMode:t,armed:n,pressProps:r,answer:s,dropAddress:o,onUnpair:l,onOpenPeer:c,onInvite:d}){return a.jsx("ul",{className:"ap-lan-here",children:e.map((h,f)=>a.jsxs("li",{className:"ap-lan-who","data-tone":h.tone,children:[a.jsx("i",{className:h.here?"ap-pulse":"ap-dot","aria-hidden":!0}),a.jsxs("span",{className:"ap-lan-who-name","aria-hidden":!0,children:[h.name,h.via==="tailscale"&&a.jsx("span",{className:"ap-lan-via",children:" · Tailscale"})]}),a.jsx("button",{type:"button",className:"ap-lan-who-open","aria-haspopup":"dialog","aria-describedby":`lan-who-state-${f}`,onClick:()=>c(h.fp),children:a.jsxs("span",{className:"vis-hidden",children:[h.name,h.via==="tailscale"?", over Tailscale":"",", details"]})}),a.jsx("span",{id:`lan-who-state-${f}`,className:h.quiet?"vis-hidden":"ap-lan-who-when",children:h.state}),h.kind==="nearby"&&t!=="invite"&&a.jsx("button",{type:"button",className:"ap-manage-btn ap-lan-do",...r(`accept:${h.fp}`),onClick:()=>void s("accept",h.fp,"reach that deck"),"aria-label":`Ask ${h.name} to pair`,title:`Send ${h.name} a request. Somebody at that machine has to accept it before anything is shared. Its fingerprint is ${h.fp}.`,children:"ask"}),(h.kind==="nearby"||h.kind==="declined")&&t==="invite"&&a.jsx("button",{type:"button",className:"ap-manage-btn ap-lan-do","aria-haspopup":"dialog",onClick:d,"aria-label":`Invite ${h.name} to pair`,title:`This deck pairs only by invite. Make one and send it to whoever is at ${h.name}.`,children:"invite"}),h.kind==="paired"&&a.jsx("button",{type:"button",className:`ap-manage-btn ap-lan-do danger${n===h.fp?" armed":""}`,...r(`unpair:${h.fp}`),onClick:()=>l(h),"aria-label":n===h.fp?`Confirm unpairing ${h.name}`:`Unpair ${h.name}`,title:n===h.fp?"Press again to stop talking to this deck. Logins it already has stay with it.":"Stop talking to this deck from now on",children:n===h.fp?"confirm":"unpair"}),h.kind==="dialling"&&a.jsx("button",{type:"button",className:"ap-manage-btn ap-lan-do",...r(`drop:${h.fp}`),onClick:()=>void o(h.fp),"aria-label":`Stop dialling ${h.name}`,title:"Stop trying this address. Nothing was ever paired here.",children:"stop"}),h.kind==="declined"&&t!=="invite"&&a.jsx("button",{type:"button",className:"ap-manage-btn ap-lan-do",...r(`allow:${h.fp}`),onClick:()=>void s("allow",h.fp,"let that deck ask again"),"aria-label":`Let ${h.name} ask again`,title:"Take the no back. That deck is still trying, so the request comes round again on its own.",children:"allow"})]},`${h.kind}:${h.fp}`))})}function DY(e){var t;return(t=e.tailscale)!=null&&t.exitNode?"Tailscale sends this machine's local network through an exit node, so decks on this network cannot find this one. Turn on Allow local network access in Tailscale's exit node menu to bring them back.":"This machine sends its local network through a VPN, so decks on this network cannot find this one. Allowing local network access in the VPN brings them back."}function FY({on:e,status:t}){return a.jsxs(a.Fragment,{children:[e&&a.jsx(MO,{reach:t==null?void 0:t.reach,where:"panel"}),e&&(t==null?void 0:t.deaf)&&a.jsx("p",{className:"ap-lan-fine",children:t.deaf}),e&&(t==null?void 0:t.lanTunneled)&&a.jsx("p",{className:"ap-lan-fine",children:DY(t)})]})}const h_=["online","offline","loose"],BY={online:0,offline:1,loose:2};function qY(e){return e.kind==="declined"?null:e.kind==="paired"?e.here?"online":"offline":"loose"}const UY=76,zY=62,Bd=96,WY={1:[.62],2:[.58,1],3:[.42,.72,1]},HY=.2,VY=.16,GY=.05,KY=20,YY=17,Zu=7,XY=30,ZY=116,JY=6.6,QY=6,eX=e=>Vk(e,null),tX=1.5,nX=80,rX=.45,f_=40,sX=64,aX=150,p_=.3,m_=84,g_=8,oX=1.3,qd=6,iX=5.94,y_=7,w_=16,_l=4,v_=.16;function kb(e,t){return Math.PI*(3*(e+t)-Math.sqrt((3*e+t)*(e+3*t)))}function $O(e,t){return t<-Math.abs(e)*.6?"top":"bottom"}function lX(e,t){if(e<=2)return t%2===0?0:90;const n=360/e;return-90+(t%2===0?0:n/2)}function cX(e){return e.map((t,n)=>({...t,i:n})).sort((t,n)=>h_.indexOf(t.tier)-h_.indexOf(n.tier)||+(t.row.via==="tailscale")-+(n.row.via==="tailscale")||t.i-n.i).map(({row:t,tier:n})=>({row:t,tier:n}))}function x_(e,t){let n=2166136261^t;for(let r=0;r<e.length;r++)n^=e.charCodeAt(r),n=Math.imul(n,16777619);return(n>>>0)%2e4/1e4-1}function uX(e,t,n){const r=[...WY[e.length]??[]];for(let s=0;s<r.length;s++){const o=e[s];if(o<2)continue;const l=kb(t*r[s],n*r[s])/o;if(!(l>0)||l>=Bd)continue;const c=s+1<r.length?r[s+1]-HY:1;r[s]=Math.max(r[s],Math.min(c,r[s]*(Bd/l)*1.02))}return r}const Ba=(e,t)=>e.x0<t.x1&&t.x0<e.x1&&e.y0<t.y1&&t.y0<e.y1,rm={h:16,ch:6.1,maxW:100};function dX(e){const t=e?Math.max(80,e.length*7.2+16):128;return{x0:-t/2,y0:32,x1:t/2,y1:66}}function IO(e,t,n,r,s,o){const l=t==="loose"?YY:KY,c=!s||e.kind==="asks",d=c?XY:rm.h,h=s?rm.ch:JY,f=c?o.length:0,p=Math.min(s?rm.maxW:ZY,Math.max(2*l,LO(e).length*h,f*QY)),g={x0:n-l,y0:r-l,x1:n+l,y1:r+l},v=$O(n,r)==="top"?{x0:n-p/2,y0:r-l-Zu-d,x1:n+p/2,y1:r-l-Zu}:{x0:n-p/2,y0:r+l+Zu,x1:n+p/2,y1:r+l+Zu+d};return[g,v]}const Nb=e=>{const t=e.theta*Math.PI/180;return[Math.cos(t)*e.ring.rx*e.reach,Math.sin(t)*e.ring.ry*e.reach]},Ju=(e,t)=>((e-t)%360+540)%360-180;function b_(e,t,n){const r=new Map;for(const f of e)r.has(f.ring)||r.set(f.ring,[]),r.get(f.ring).push(f);const s=()=>e.map(f=>{const[p,g]=Nb(f);return IO(f.row,f.tier,p,g,t,f.caption)}),o=(f,p,g=!1)=>{if(f.count<=2&&!g)return!1;const v=f.theta+p*tX,j=r.get(f.ring),k=(f.count>2?360/f.count:f.turn)*rX,x=j[(f.index+1)%f.count],N=j[(f.index-1+f.count)%f.count];return!(x===f||(p>0?Ju(x.theta,v)>=k:Ju(v,N.theta)>=k))||v<f.lo||v>f.hi?!1:(f.theta=v,!0)},l=([f,p],[g,v])=>Ba(p,g)||Ba(v,f)||Ba(p,v)||Ba(f,g),c=([f,p])=>Ba(f,n)||Ba(p,n);for(let f=0;f<nX;f++){const p=s();let g=!1;for(let v=0;v<e.length;v++){c(p[v])&&(g=o(e[v],Ju(e[v].theta,90)>=0?1:-1,!0)||g);for(let j=v+1;j<e.length;j++){if(!l(p[v],p[j]))continue;const k=e[v],x=e[j],N=x.ring.ring>k.ring.ring||x.ring===k.ring&&j>v?x:k,b=N===x?k:x,S=Ju(N.theta,b.theta)>=0?1:-1;g=o(N,S)||o(b,-S)||g}}if(!g)break}const d=s();let h=0;for(let f=0;f<d.length;f++){c(d[f])&&h++;for(let p=f+1;p<d.length;p++)l(d[f],d[p])&&h++}return h}const hX={online:0,offline:1,loose:1};function fX(e,t,n,r="",s=eX){const o=[];for(const l of[!0,!1]){const c=k_(e,t,n,r,BY,s,l);if(c.clashes===0)return c.named();if(o.push(c),c.layout.rings.length===3){const d=k_(e,t,n,r,hX,s,l),h={clashes:d.clashes,named:()=>({...d.named(),folded:!0})};if(h.clashes===0)return h.named();o.push(h)}if(!c.layout.zone)break}return o.reduce((l,c)=>c.clashes<l.clashes?c:l).named()}function k_(e,t,n,r,s,o,l=!0){const c=new Map;for(const F of e){const T=qY(F);if(!T)continue;const P=s[T];c.has(P)||c.set(P,[]),c.get(P).push({row:F,tier:T})}const d=[...c.keys()].sort((F,T)=>F-T),h=Math.max(0,t/2-UY),f=Math.max(0,n/2-zY),p=uX(d.map(F=>c.get(F).length),h,f),g=d.map((F,T)=>({ring:F,rx:h*p[T],ry:f*p[T],count:c.get(F).length})),v=g.reduce((F,T)=>F+T.count,0),j=F=>F.row.via==="tailscale",k=[...c.values()].flat().filter(j).length,x=Math.max(0,...g.map(F=>{const T=c.get(F.ring).filter(j).length,P=kb(F.rx,F.ry);return T>0&&P>0?T*Bd*oX/P*360:0})),N=l&&k>0&&k<v?Math.min(aX,Math.max(sX,k/v*360,x)):0,b=f_-N/2,S=f_+N/2,E=[];let R=!1;g.forEach((F,T)=>{const P=cX(c.get(F.ring)),O=P.length,G=O>1&&kb(F.rx,F.ry)/O<Bd;G&&(R=!0);const K=T===g.length-1,U=K?-v_*(p[T]-(p[T-1]??0)):v_*(p[T+1]-p[T]),H=N>0?[{members:P.filter(V=>V.row.via!=="tailscale"),from:S,width:360-N},{members:P.filter(V=>V.row.via==="tailscale"),from:b+360,width:N}]:[{members:P,from:null,width:360}];let D=0;for(const V of H){const J=V.members.length;if(J===0)continue;const W=V.width/J,Z=J>2;V.members.forEach(({row:Y,tier:X},ee)=>{const ae=mr(Y),ce=V.from==null?lX(J,T)+W*ee:V.from+W*(ee+.5),ge=Z?x_(ae,1)*VY*W:0,ye=G&&D%2===1?1+U/p[T]:1,se=Z?x_(ae,2)*GY:0,pe=W*.3;E.push({row:Y,tier:X,ring:F,index:D,count:O,theta:ce+ge,reach:ye*(1+(K?-Math.abs(se):se)),lo:V.from==null?-1/0:V.from+pe,hi:V.from==null?1/0:V.from+V.width-pe,turn:W,caption:o(Y)}),D++})}});const I=dX(r);let A=b_(E,R,I);A>0&&!R&&(R=!0,A=b_(E,!0,I));const q=E.map((F,T)=>{const[P,O]=Nb(F);return{row:F.row,tier:F.tier,ring:F.ring.ring,x:P,y:O,angle:pX(Math.atan2(O,P)*180/Math.PI),dist:Math.hypot(P,O),side:$O(P,O),order:T}}),$=g.reduce((F,T,P)=>c.get(T.ring).some(j)?Math.max(F,p[P]):F,0),B=F=>({from:b,to:S,inner:{rx:h*p_,ry:f*p_},outer:{rx:Math.min(t/2-8,h*$+F),ry:Math.min(n/2-8,f*$+F)},count:k}),L={nodes:q,rings:g,dense:R,zone:N>0?{...B(m_),labelAt:null}:null};return{layout:L,clashes:A,named:()=>{if(!L.zone)return L;const F=E.flatMap(O=>{const[G,K]=Nb(O);return IO(O.row,O.tier,G,K,R,O.caption)});let T={...L.zone,labelAt:N_(L.zone,F)},P=T.outer;for(let O=m_+g_;T.labelAt==null;O+=g_){const G=B(O);if(G.outer.rx===P.rx&&G.outer.ry===P.ry)break;P=G.outer;const K=N_(G,F);K!=null&&(T={...G,labelAt:K})}return{...L,zone:T}}}}function OO(e){return`Tailscale · ${e} deck${e===1?"":"s"}`}function N_(e,t){const n={rx:e.outer.rx-qd,ry:e.outer.ry-qd};if(!(n.rx>0&&n.ry>0))return null;const r=Math.min(.5,2/Math.max(n.rx,n.ry)*(180/Math.PI)),s=[];for(let b=e.to;b>=e.from;b-=r){const S=b*Math.PI/180;s.push([Math.cos(S)*n.rx,Math.sin(S)*n.ry])}const o=y_+_l,l={x0:Math.min(...s.map(b=>b[0]))-o,x1:Math.max(...s.map(b=>b[0]))+o,y0:Math.min(...s.map(b=>b[1]))-o,y1:Math.max(...s.map(b=>b[1]))+o},c=t.map(b=>({x0:b.x0-_l,y0:b.y0-_l,x1:b.x1+_l,y1:b.y1+_l})).filter(b=>Ba(b,l)),d=(b,S)=>c.some(E=>b>E.x0&&b<E.x1&&S>E.y0&&S<E.y1),h=[],f=[];let p=0;s.forEach(([b,S],E)=>{E>0&&(p+=Math.hypot(b-s[E-1][0],S-s[E-1][1]));const R=Math.hypot(b,S)||1;let I=!1;for(let A=0;A<=y_&&!I;A+=1.75)I=d(b-b/R*A,S-S/R*A);h.push(p),f.push((f.at(-1)??0)+(I?1:0))});const g=OO(e.count).length*iX/2,v=g+w_,j=p-g-w_;if(!(p>0)||j<v)return null;const k=b=>{let S=0,E=h.length;for(;S<E;){const R=S+E>>1;h[R]<b?S=R+1:E=R}return S},x=b=>{const S=k(b-g),E=k(b+g+1e-9)-1;return E<S||f[E]-(S>0?f[S-1]:0)===0},N=p/2;for(let b=0;N-b>=v;b+=2)for(const S of b===0?[N]:[N-b,N+b])if(x(S))return S/p;return null}function pX(e){return(e%360+360)%360}function mX(e){const t=n=>e.filter(n).length;return{paired:t(n=>n.kind==="paired"),online:t(n=>n.kind==="paired"&&n.here),offline:t(n=>n.kind==="paired"&&!n.here),nearby:t(n=>n.kind==="nearby"),asks:t(n=>n.kind==="asks"),dialling:t(n=>n.kind==="dialling"),declined:t(n=>n.kind==="declined"),tailnet:t(n=>n.kind!=="declined"&&n.via==="tailscale"),oneWay:t(n=>n.kind==="paired"&&!n.here&&n.state.startsWith("one-way"))}}function gX(e){const t=[];return e.asks&&t.push(e.asks===1?"1 deck wants to pair":`${e.asks} decks want to pair`),e.paired===0?t.push("no paired decks yet"):e.paired===1?t.push(e.online?"1 paired deck, online":"1 paired deck, away"):e.online===e.paired?t.push(`${e.paired} paired decks, all online`):t.push(`${e.online} of ${e.paired} paired decks online`),e.nearby&&t.push(`${e.nearby} nearby, not paired`),e.dialling&&t.push(`${e.dialling} still dialling`),t.join(" · ")}function Vk(e,t){switch(e.kind){case"asks":return"wants to pair";case"nearby":return e.state;case"dialling":return PO(e)?`${e.name.slice(e.addr.length)} · dialling`:"dialling";case"declined":return"declined";case"paired":{if(e.here)return t?yX(t):"online";const n=FO(e);return n?n==="now"?"away · just now":`away · ${n}`:e.state.startsWith("one-way")?"has not called yet":"away"}}}function LO(e){return PO(e)?e.addr:e.name}function PO(e){return e.kind==="dialling"&&!!e.addr&&e.name.startsWith(`${e.addr}:`)}function DO(e){if(e.kind!=="paired")return e.via==="tailscale"?`${e.state}, over Tailscale`:e.state;if(e.here)return e.via==="tailscale"?"online, over Tailscale":"online";const t=FO(e),n=t?t==="now"?"away · last online just now":`away · last online ${t}`:e.state.startsWith("one-way")?e.state:"away";return e.via==="tailscale"?`${n}, over Tailscale`:n}function FO(e){var t;return((t=/last online (.+)$/.exec(e.state))==null?void 0:t[1])??null}function yX(e){return e.trim().split(/\s+/).slice(0,2).join(" ")}function wX(e){var r;if(!e)return[];const t=(e.addrs??[]).map(s=>`${s}:${e.port}`),n=(r=e.tailscale)==null?void 0:r.addr;return n&&!(e.addrs??[]).includes(n)&&t.push(`${n}:${e.port}`),t}function mr(e){let t=e.fp;for(const n of e.twins??[])n.fp<t&&(t=n.fp);return t}function vX(e,t){if(e==null)return t;const n=((t-e)%360+540)%360-180;return e+n}function xX(e,t){if(e.asks)return e.asks===1?"1 deck wants to pair. Answer it in the Local network list, behind this map.":`${e.asks} decks want to pair. Answer them in the Local network list, behind this map.`;if(e.oneWay)return`${e.oneWay} away deck${e.oneWay===1?" only calls":"s only call"} in, and this deck has no address to call ${e.oneWay===1?"it":"them"} on. Add ${e.oneWay===1?"its address":"their addresses"} through Add a deck to reach ${e.oneWay===1?"it":"them"} both ways.`;if(e.dialling)return e.dialling===1?"1 address has never answered. Open it to stop dialling it.":`${e.dialling} addresses have never answered. Open one to stop dialling it.`;if(e.nearby){const n=e.nearby===1?"1 deck nearby is not paired.":`${e.nearby} decks nearby are not paired.`;return t==="invite"?`${n} ${BO}`:e.nearby===1?`${n} Open it to ask to pair.`:`${n} Open one to ask to pair.`}return null}const BO="This deck pairs by invite only. Send one from Add a deck.";function bX(e,t){switch(e.kind){case"asks":return"Waiting for your answer, in the Local network list behind this map.";case"dialling":return"Nothing has answered here yet. Its dialog can stop dialling it.";case"nearby":return t==="invite"?BO:"Not paired yet. Its dialog can ask to pair.";case"paired":return!e.here&&e.state.startsWith("one-way")?"It can reach this deck, not the other way. Add its address through Add a deck.":null;default:return null}}function kX(e){const t={bad:0,wait:1,idle:2,ok:3};return e.map((n,r)=>({l:n,i:r})).sort((n,r)=>t[n.l.tone]-t[r.l.tone]||n.i-r.i).map(({l:n})=>n)}function NX(e,t){const n=/^(\d+)\.(\d+)\.(\d+)/.exec(e??""),r=/^(\d+)\.(\d+)\.(\d+)/.exec(t??"");if(!n||!r)return null;for(let s=1;s<=3;s++){const o=Number(n[s])-Number(r[s]);if(o)return Math.sign(o)}return 0}function jX(e,t){const n=t?t.alive?t.shareable===!1?"cannot share here":"works here":"expired here":"not on this deck";if(e.alive&&e.shareable===!1)return{there:"cannot share there",here:n,note:null,tone:"idle"};if(!e.alive){const r=t&&!t.alive?"neither copy works — sign in again here":null;return{there:"broken there",here:n,note:r,tone:r?"bad":"idle"}}return t?t.alive?{there:"works there",here:n,note:null,tone:t.shareable===!1?"idle":"ok"}:{there:"works there",here:n,note:"repairs next round",tone:"wait"}:{there:"works there",here:n,note:"arrives next round",tone:"wait"}}function SX(e,t,n,r=null){var d;const s=new Map;for(const h of t)(d=s.get(h.key))!=null&&d.alive||s.set(h.key,h);const o=new Set(n),l=[],c=new Set;for(const h of e??[]){if(c.has(h.key))continue;c.add(h.key);const f=s.get(h.key)??null,p=o.has(h.key),g=jX(h,f),v=f?f.alive?f.shareable===!1?"unavailable":"works":"expired":"missing",j=!h.alive&&f&&!f.alive?g.note:[v==="works"?null:g.here,h.alive&&h.shareable!==!1?null:g.there,g.note].filter(Boolean).join(" · ")||null;l.push({key:h.key,email:h.email,here:v,there:h.alive?h.shareable===!1?"unavailable":"works":"broken",in:!h.alive||h.shareable===!1?"cut":g.tone==="wait"?"wait":"live",out:p&&f?f.alive&&f.shareable!==!1?"live":"cut":null,caption:j,tone:g.tone,usedThere:r===h.key})}for(const h of n){const f=s.get(h);!f||c.has(h)||(c.add(h),l.push({key:h,email:f.email,here:f.alive?f.shareable===!1?"unavailable":"works":"expired",there:"unknown",in:null,out:f.alive&&f.shareable!==!1?"live":"cut",caption:f.alive?f.shareable===!1?"cannot share here":null:"expired here",tone:f.alive?f.shareable===!1?"idle":"ok":"bad",usedThere:!1}))}return l}const _X=1e3;function EX(e,t){const n=new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),r=Hr(e,t);return`${n} · ${r==="now"?"just now":r}`}function jb(e){return e&&[e.version,e.os,e.arch].filter(Boolean).join(" · ")||null}const qO={works:"works here",expired:"expired here",missing:"not on this deck",unavailable:"cannot share here"},UO={works:"works there",broken:"broken there",unavailable:"cannot share there",unknown:"not offered by that deck"};function zO(e){const t=e.in&&e.out?"offered both ways":e.in?"offered by that deck":"offered by this deck";return`${qO[e.here]}, ${UO[e.there]}, ${t}${e.usedThere?", in use there":""}.`}function WO({row:e,source:t,status:n,accounts:r,now:s}){var X,ee,ae,ce,ge;const{peer:o,stranger:l}=t,c=e.kind==="paired",d=e.self??e.name,h=e.kind!=="dialling",f=e.kind==="dialling"?null:e.fp,p=o?o.addr?`${o.addr}:${o.port}`:"":l?l.port?`${l.addr}:${l.port}`:l.addr:e.addr,g=(o==null?void 0:o.about)??null,v=((X=n.about)==null?void 0:X.version)??null,j=c?o!=null&&o.waiting?o.lastSeen!=null?"not said — it runs an older version":"not said yet — it says when it next calls":o!=null&&o.offers?"not said — it runs an older version":"not reached yet":"shown once paired",k=jb(n.about),x=jb(g),N=g!=null&&g.version&&v?NX(g.version,v):null,b=o?Sh(o.last,s):null,S=o&&((ee=o.last)!=null&&ee.error)?BK({error:o.last.error,host:o.addr,port:o.port},[...n.strangers??[],...n.pending??[],...(n.peers??[]).filter(ye=>!ye.manual&&ye.addr).map(ye=>({fp:ye.fp,name:ye.name,addr:ye.addr,port:ye.port,at:ye.lastSeen??0}))],s):null,E=(ae=o==null?void 0:o.last)!=null&&ae.error&&b&&b.text!==o.last.error?o.last.error:null,R=((ce=o==null?void 0:o.last)==null?void 0:ce.done)??[],I=!!b&&!!E&&!e.quiet&&e.state.startsWith(b.text),A=c||e.kind==="dialling",q=((o==null?void 0:o.via)??e.via)==="tailscale",$=o?o.waiting?null:o.manual?q?"added by its Tailscale address":"added by address":q?"over Tailscale":"on this network":e.kind==="nearby"?q?"heard over Tailscale":"heard on this network":q?"asked this deck to pair, over Tailscale":"asked this deck to pair",B=e.tone==="bad"?"bad":c?e.here?"up":"down":"loose",L=(o==null?void 0:o.offers)??null,M=B==="up"?(L==null?void 0:L.current)??null:null,F=M&&"key"in M?M.key:null,T=!!M&&"hidden"in M,P=!!M&&"other"in M,O=(n.shared??[]).filter(ye=>{var se;return!((se=o==null?void 0:o.notOffered)!=null&&se.includes(ye))}),G=c?SX((L==null?void 0:L.accounts)??null,r,O,F):[],K=G.filter(ye=>ye.in==null&&ye.out==="cut"),U=G.some(ye=>ye.in!=null),H=G.some(ye=>ye.out!=null),D=new Set((n.peers??[]).filter(ye=>ye.paired).flatMap(ye=>ye.notOffered??[])),V=G.some(ye=>ye.out!=null&&D.has(ye.key))?"decks you chose":"every paired deck",J=new Map(R.map(ye=>[ye.email,ye])),W=R.filter(ye=>!G.some(se=>se.email===ye.email)),Z=c?L?L.accounts.length===0?"That deck offers nothing. Nobody there has chosen a login to share.":null:o!=null&&o.waiting?"What that deck offers is not known yet. A deck that calls in says so each time it calls — one on an older version never does.":(ge=o==null?void 0:o.last)!=null&&ge.error?"What that deck offers is not known — the last attempt to ask it did not get through.":"Nobody has asked that deck what it offers yet. The next round asks it.":null,Y=L&&(o!=null&&o.last)&&o.last.at-L.at>_X?Hr(L.at,s):null;return{peer:o,stranger:l,paired:c,own:d,canRename:h,fp:f,where:p,about:g,unsaid:j,hereRuns:k,thereRuns:x,order:N,line:b,silence:S,raw:E,echoed:I,showRound:A,how:$,link:B,hiddenThere:T,otherThere:P,lanes:G,spent:K,taking:U,giving:H,givenTo:V,told:J,unplaced:W,unknown:Z,stale:Y}}function Sb(){return a.jsxs("svg",{className:"lan-machine",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("rect",{x:"2.5",y:"3",width:"11",height:"7.5",rx:"1.2"}),a.jsx("path",{d:"M1 13h14"})]})}function Qu({dir:e}){return a.jsx("svg",{className:"lan-chev","data-dir":e,width:"8",height:"8",viewBox:"0 0 8 8",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:a.jsx("path",{d:e==="out"?"M2.8 1L6 4 2.8 7":"M5.2 1L2 4l3.2 3"})})}function CX({view:e,row:t,status:n,asking:r,drawn:s,onSettings:o}){const{peer:l,paired:c,where:d,about:h,unsaid:f,hereRuns:p,thereRuns:g,order:v,line:j,silence:k,raw:x,echoed:N,showRound:b,how:S,link:E,hiddenThere:R,otherThere:I,lanes:A,spent:q,taking:$,giving:B,givenTo:L,told:M,unplaced:F,unknown:T,stale:P}=e;return a.jsxs("div",{className:"lan-map","data-link":E,"data-asking":r||void 0,"data-bus":A.length>0||void 0,children:[a.jsxs("div",{className:"lan-ends",children:[a.jsxs("p",{className:"lan-end",children:[a.jsx("span",{className:"lan-end-name",children:"This deck"}),p&&a.jsx("span",{className:"lan-end-runs",children:p}),c&&n.shareActive===!1&&a.jsx("span",{className:"lan-end-note",children:"current account hidden"})]}),a.jsxs("p",{className:"lan-end","data-side":"there",children:[a.jsx("span",{className:"lan-end-name",children:t.name}),t.kind!=="dialling"&&a.jsxs("span",{className:"lan-end-runs",children:[g??(h?"not said":f),v?` · ${v<0?"older":"newer"}`:null]}),R&&a.jsx("span",{className:"lan-end-note",children:"current account hidden"}),I&&a.jsx("span",{className:"lan-end-note",children:"on another account"})]})]}),a.jsxs("div",{className:"lan-link",children:[a.jsx(Sb,{}),a.jsxs("span",{className:"lan-span",children:[a.jsxs("span",{className:"lan-wire","aria-hidden":!0,children:[a.jsx("i",{className:"lan-glint","data-dir":"out"}),a.jsx("i",{className:"lan-glint","data-dir":"in"})]}),a.jsx("span",{className:"lan-link-label",children:d?a.jsx("code",{className:"ap-lan-code",children:d}):"none here — it calls this deck"})]}),a.jsx(Sb,{}),(d&&S||b)&&a.jsxs("p",{className:"lan-link-sub",children:[d&&S,d&&S&&b&&" · ",b&&(j?N?a.jsx("code",{className:"ap-lan-code",children:x}):a.jsx("span",{className:"lan-round","data-tone":j.tone,children:j.text.replace(/ · now$/," · just now")}):"not asked yet"),b&&x&&!N&&a.jsx("code",{className:"lan-fact-raw",children:x})]}),F.length>0&&a.jsx("ul",{className:"lan-done",children:F.map(O=>{const G=yb(O);return a.jsxs("li",{"data-ok":O.ok&&!G,children:[O.email," ",a.jsxs("span",{className:"lan-done-what",children:[O.ok?"arrived":"did not arrive",G&&` — ${G.long}`]})]},`${O.email}:${O.action}`)})}),k&&a.jsx("p",{className:"lan-note lan-link-note",children:k}),(l==null?void 0:l.waiting)&&a.jsx("p",{className:"lan-note lan-link-note",children:t.hint}),(j==null?void 0:j.hint)&&a.jsx("p",{className:"lan-note lan-link-note",children:j.hint})]}),A.length>0&&a.jsx("ul",{className:"lan-lanes",role:"list","aria-label":`Logins between this deck and ${t.name}`,children:A.map((O,G)=>{const K=M.get(O.email),U=K?yb(K):null,H=O.out==="live"||O.in!=null&&O.in!=="cut";return a.jsxs("li",{role:"listitem",className:"lan-lane","data-tone":O.tone,"data-draw":O.in&&O.out?"both":O.in?"in":"out","data-used-there":O.usedThere||void 0,style:{"--i":G},children:[a.jsx("i",{className:"lan-pip","data-end":"here","data-state":O.here,"aria-hidden":!0}),a.jsxs("span",{className:"lan-track",children:[a.jsxs("span",{className:"lan-wire","data-flow":H?"live":"cut","aria-hidden":!0,children:[(O.in==="live"||O.in==="wait")&&a.jsx("i",{className:"lan-glint","data-dir":"in","data-tone":O.in}),O.out==="live"&&a.jsx("i",{className:"lan-glint","data-dir":"out"})]}),O.in&&O.in!=="cut"&&a.jsx(Qu,{dir:"in"}),O.out==="live"&&a.jsx(Qu,{dir:"out"}),a.jsx("span",{className:"lan-lane-email",children:O.email})]}),a.jsx("i",{className:"lan-pip","data-end":"there","data-state":O.there,"aria-hidden":!0}),a.jsx("span",{className:"vis-hidden",children:zO(O)}),(O.caption||K)&&a.jsxs("span",{className:"lan-lane-note",children:[O.caption,O.caption&&K&&" · ",K&&a.jsxs("span",{className:"lan-lane-done","data-ok":K.ok&&!U,children:[K.ok?"arrived last round":"did not arrive last round",U&&` — ${U.long}`]})]})]},O.key)})},s),c&&a.jsxs(a.Fragment,{children:[q.length>0&&a.jsxs("p",{className:"lan-spent",children:["Paired decks get nothing from ",q.length===1?q[0].email:"the expired ones"," until you sign in again here."]}),T&&a.jsx("p",{className:"lan-empty",children:T}),P&&a.jsxs("p",{className:"lan-stale",children:["As of ",P==="now"?"just now":P,", when it last answered."]}),a.jsxs("div",{className:"lan-legend",children:[$&&a.jsxs("span",{className:"lan-key",children:[a.jsx("span",{className:"lan-key-wire","data-dir":"in","aria-hidden":!0,children:a.jsx(Qu,{dir:"in"})}),"from ",t.name]}),B?a.jsxs("span",{className:"lan-key",children:[a.jsx("span",{className:"lan-key-wire","data-dir":"out","aria-hidden":!0,children:a.jsx(Qu,{dir:"out"})}),"from this deck, to ",L]}):a.jsx("span",{className:"lan-key",children:"This deck offers nothing yet."}),a.jsx("button",{type:"button",className:"ap-lan-word lan-legend-act",onClick:o,"aria-label":"Change what this deck offers",children:"change"})]})]})]})}const TX=20,AX=17,j_=34,RX=160,MX=80,$X=200,IX=8,OX=14,LX=10,PX=.61803398875;function DX({status:e,rows:t,accounts:n,now:r,covered:s,onOpenDeck:o,onClose:l}){const c=y.useRef(null),d=ot(l,{focusRef:c}),h=mt(l),f=y.useRef(null),[p,g]=y.useState(null),[v,j]=y.useState(!1),k=y.useRef(null);y.useLayoutEffect(()=>{const se=f.current;if(!se)return;let pe=null;const fe=()=>{const me=Math.round(se.clientWidth),ne=Math.round(se.clientHeight);pe&&pe.w===me&&pe.h===ne||(pe&&(j(!0),k.current!=null&&window.clearTimeout(k.current),k.current=window.setTimeout(()=>j(!1),$X)),pe={w:me,h:ne},g(pe))};if(fe(),typeof ResizeObserver>"u")return;const de=new ResizeObserver(fe);return de.observe(se),()=>{de.disconnect(),k.current!=null&&window.clearTimeout(k.current)}},[]);const x=y.useMemo(()=>p?fX(t,p.w,p.h,(e==null?void 0:e.name)??"",se=>{var pe,fe;return Vk(se,(fe=(pe=lc(e,se).peer)==null?void 0:pe.about)==null?void 0:fe.os)}):null,[t,p,e]),N=y.useMemo(()=>mX(t),[t]),b=(x==null?void 0:x.nodes)??[],S=y.useRef(new Map),E=y.useMemo(()=>{const se=new Map;for(const pe of b){const fe=mr(pe.row);se.set(fe,vX(S.current.get(fe),pe.angle))}return S.current=se,se},[b]),[R,I]=y.useState(null),[A,q]=y.useState(null),[$,B]=y.useState("none"),L=y.useRef(null),M=y.useCallback((se,pe)=>{L.current!==se&&(L.current=se,B(pe),q(se))},[]),F=y.useRef(null),T=y.useRef(null),P=y.useCallback(()=>{T.current!=null&&window.clearTimeout(T.current),T.current=null},[]),O=y.useCallback((se,pe)=>{if(F.current!=null&&window.clearTimeout(F.current),F.current=null,P(),I(se),pe==="keyboard"){M(se,"none");return}T.current=window.setTimeout(()=>M(se,L.current?"swap":"full"),MX)},[M,P]),G=y.useCallback(()=>{F.current!=null&&window.clearTimeout(F.current),P(),F.current=window.setTimeout(()=>I(null),RX)},[P]);y.useEffect(()=>()=>{F.current!=null&&window.clearTimeout(F.current),P()},[P]);const K=R&&b.some(se=>mr(se.row)===R)?R:null,U=A?t.find(se=>mr(se)===A)??null:null;y.useEffect(()=>{A&&!U&&M(null,"swap")},[A,U,M]);const[H,D]=y.useState(null),V=y.useRef(new Map),J=b.findIndex(se=>mr(se.row)===H),W=J<0?0:J,Z=se=>{var me;if(b.length===0)return;const pe=se.key==="ArrowRight"||se.key==="ArrowDown"?1:se.key==="ArrowLeft"||se.key==="ArrowUp"?-1:0,fe=se.key==="Home"?0:se.key==="End"?b.length-1:pe?(W+pe+b.length)%b.length:null;if(fe==null)return;se.preventDefault();const de=mr(b[fe].row);D(de),(me=V.current.get(de))==null||me.focus()},[Y,X]=y.useState(()=>typeof document<"u"&&document.hidden);y.useEffect(()=>{const se=()=>X(document.hidden);return document.addEventListener("visibilitychange",se),()=>document.removeEventListener("visibilitychange",se)},[]);const ee=(e==null?void 0:e.enabled)===!0,ae=e?ee?gX(N):"Local network is off":"checking…",ce=()=>{P(),M(null,"swap"),I(null)},ge=K?b.find(se=>mr(se.row)===K)??null:null,ye=()=>{var se;A&&((se=V.current.get(A))==null||se.focus()),ce()};return Pt.createPortal(a.jsx("div",{className:"modal-backdrop",...h,role:"presentation",children:a.jsxs("div",{ref:d,className:"modal nm-modal",onClick:se=>se.stopPropagation(),"data-paused":s||Y||void 0,role:"dialog","aria-modal":"true","aria-labelledby":"nm-title","aria-describedby":"nm-sub",children:[a.jsxs("header",{className:"modal-head nm-head",children:[a.jsxs("div",{className:"nm-heading",children:[a.jsx("h2",{id:"nm-title",className:"modal-title nm-title",children:"Network map"}),a.jsx("p",{id:"nm-sub",className:"nm-sub",children:ae})]}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{ref:c,type:"button",className:"glyph-btn",onClick:l,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("div",{className:"nm-body",children:[a.jsxs("div",{className:"nm-view",children:[a.jsx("div",{ref:f,className:"nm-stage","data-focus":K?"":void 0,"data-focus-via":ge==null?void 0:ge.row.via,"data-dense":(x==null?void 0:x.dense)||void 0,"data-still":v||void 0,onClick:se=>{se.target===se.currentTarget&&ce()},children:p&&x&&a.jsxs(a.Fragment,{children:[a.jsx(FX,{layout:x,w:p.w,h:p.h}),b.map(se=>{const pe=mr(se.row);return a.jsx(UX,{node:se,angle:E.get(pe)??se.angle,lit:K===pe},pe)}),a.jsx(zX,{status:e}),a.jsx("span",{id:"nm-ring-hint",className:"vis-hidden",children:"Arrow keys move between decks. Enter opens the deck's own dialog."}),a.jsx("div",{className:"nm-ring",role:"group","aria-label":`Decks around this deck, ${b.length}`,"aria-describedby":"nm-ring-hint",onKeyDown:Z,children:b.map((se,pe)=>{var de,me;const fe=mr(se.row);return a.jsx(WX,{node:se,angle:E.get(fe)??se.angle,os:(me=(de=lc(e,se.row).peer)==null?void 0:de.about)==null?void 0:me.os,lit:K===fe,shown:A===fe,tabbable:pe===W,register:ne=>{ne?V.current.set(fe,ne):V.current.delete(fe)},onHold:ne=>{D(fe),O(fe,ne)},onRelease:G,onOpen:()=>o(se.row.fp)},fe)})}),b.length===0&&a.jsx(HX,{status:e})]})}),a.jsx(VX,{slice:(x==null?void 0:x.zone)!=null})]}),a.jsx("aside",{className:"nm-side","aria-label":"Details",children:U&&e?a.jsx(KX,{row:U,status:e,accounts:n,now:r,entrance:$,onOpen:()=>o(U.fp),onBack:ye},mr(U)):a.jsx(GX,{status:e,summary:N,entrance:$,slice:(x==null?void 0:x.zone)!=null})})]})]})}),document.body)}function HO(){return a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("circle",{cx:"7",cy:"7.4",r:"1.8"}),a.jsx("circle",{cx:"2.4",cy:"2.9",r:"1.2"}),a.jsx("circle",{cx:"11.6",cy:"2.9",r:"1.2"}),a.jsx("circle",{cx:"7",cy:"12.4",r:"1.1"}),a.jsx("path",{d:"M5.7 6.1 3.3 3.8M8.3 6.1l2.4-2.3M7 9.2v2.1"})]})}function FX({layout:e,w:t,h:n}){const{zone:r}=e;return a.jsxs("svg",{className:"nm-orbits",width:t,height:n,viewBox:`0 0 ${t} ${n}`,"aria-hidden":!0,children:[r&&a.jsxs(a.Fragment,{children:[a.jsxs("defs",{children:[a.jsx("path",{id:"nm-zone-arc",d:qX(r,t/2,n/2)}),a.jsxs("radialGradient",{id:"nm-zone-fill",gradientUnits:"userSpaceOnUse",cx:t/2,cy:n/2,r:Math.max(r.outer.rx,r.outer.ry),children:[a.jsx("stop",{className:"nm-zone-stop",offset:"0.2","data-at":"in"}),a.jsx("stop",{className:"nm-zone-stop",offset:"0.5","data-at":"mid"}),a.jsx("stop",{className:"nm-zone-stop",offset:"1","data-at":"out"})]})]}),a.jsx("path",{className:"nm-zone",d:BX(r,t/2,n/2),fill:"url(#nm-zone-fill)"}),r.labelAt!=null&&a.jsx("text",{className:"nm-zone-label",children:a.jsx("textPath",{href:"#nm-zone-arc",startOffset:`${(r.labelAt*100).toFixed(2)}%`,textAnchor:"middle",children:OO(r.count)})})]}),e.rings.map((s,o)=>a.jsx("ellipse",{className:"nm-orbit","data-ring":s.ring,"data-folded":e.folded&&s.ring===1||void 0,cx:t/2,cy:n/2,rx:s.rx,ry:s.ry,style:{"--ring":o}},s.ring))]})}function S_(e,t,n,r){const s=r*Math.PI/180;return`${(t+Math.cos(s)*e.rx).toFixed(1)},${(n+Math.sin(s)*e.ry).toFixed(1)}`}function BX(e,t,n){const r=e.to-e.from>180?1:0,s=(N,b)=>{const S=b*Math.PI/180;return[t+Math.cos(S)*N.rx,n+Math.sin(S)*N.ry]},o=(N,b)=>b/((N.rx+N.ry)/2)*(180/Math.PI),l=(N,b,S)=>{const E=Math.hypot(b[0]-N[0],b[1]-N[1])||1,R=Math.min(.5,S/E);return[N[0]+(b[0]-N[0])*R,N[1]+(b[1]-N[1])*R]},c=([N,b])=>`${N.toFixed(1)},${b.toFixed(1)}`,d=LX,h=OX,f=o(e.inner,d),p=o(e.outer,h),g=s(e.inner,e.from),v=s(e.outer,e.from),j=s(e.outer,e.to),k=s(e.inner,e.to),x=N=>`${N.rx.toFixed(1)},${N.ry.toFixed(1)}`;return[`M${c(s(e.inner,e.from+f))}`,`Q${c(g)} ${c(l(g,v,d))}`,`L${c(l(v,g,h))}`,`Q${c(v)} ${c(s(e.outer,e.from+p))}`,`A${x(e.outer)} 0 ${r} 1 ${c(s(e.outer,e.to-p))}`,`Q${c(j)} ${c(l(j,k,h))}`,`L${c(l(k,j,d))}`,`Q${c(k)} ${c(s(e.inner,e.to-f))}`,`A${x(e.inner)} 0 ${r} 0 ${c(s(e.inner,e.from+f))}`,"Z"].join(" ")}function qX(e,t,n){const r={rx:e.outer.rx-qd,ry:e.outer.ry-qd},s=e.to-e.from>180?1:0;return`M${S_(r,t,n,e.to)} A${r.rx.toFixed(1)},${r.ry.toFixed(1)} 0 ${s} 0 ${S_(r,t,n,e.from)}`}function UX({node:e,angle:t,lit:n}){const r=e.row.kind==="paired"&&e.row.here,s=e.order*PX%1*IX;return a.jsx("span",{className:"nm-wire","aria-hidden":!0,"data-tier":e.tier,"data-via":e.row.via,"data-on":n||void 0,style:{"--nm-a":`${t.toFixed(2)}deg`,"--nm-d":`${e.dist.toFixed(1)}px`,"--from":`${j_}px`,"--gap":`${j_+(e.tier==="loose"?AX:TX)}px`,"--i":e.order,"--phase":`${s.toFixed(2)}s`},children:r&&a.jsx("i",{className:"nm-glint"})})}function zX({status:e}){const t=(e==null?void 0:e.enabled)===!0&&e.running;return a.jsxs("div",{className:"nm-core","data-listening":t||void 0,children:[a.jsx("span",{className:"nm-core-orb","aria-hidden":!0}),a.jsxs("span",{className:"nm-core-label",children:[a.jsx("span",{className:"nm-core-name",children:(e==null?void 0:e.name)??"…"}),a.jsx("span",{className:"nm-core-what",children:"this deck"})]})]})}function WX({node:e,angle:t,os:n,lit:r,shown:s,tabbable:o,register:l,onHold:c,onRelease:d,onOpen:h}){const{row:f}=e,p=`nm-d-${YX(mr(f))}`,g=e.angle*Math.PI/180,v=Vk(f,n);return a.jsxs("button",{ref:l,type:"button",className:"nm-node",tabIndex:o?0:-1,"data-tier":e.tier,"data-kind":f.kind,"data-side":e.side,"data-via":f.via,"data-on":r||void 0,"data-shown":s||void 0,"aria-label":`${f.name}: ${DO(f)}`,"aria-describedby":e.tier==="online"?p:void 0,style:{"--nm-a":`${t.toFixed(2)}deg`,"--nm-d":`${e.dist.toFixed(1)}px`,"--i":e.order,"--in-x":`${(-Math.cos(g)*14).toFixed(1)}px`,"--in-y":`${(-Math.sin(g)*14).toFixed(1)}px`},onPointerEnter:j=>{j.pointerType==="mouse"&&c("pointer")},onPointerLeave:d,onFocus:j=>c(j.currentTarget.matches(":focus-visible")?"keyboard":"pointer"),onBlur:d,onClick:h,children:[a.jsx("i",{className:"nm-halo","data-tier":e.tier,"aria-hidden":!0}),f.kind==="dialling"?a.jsx("i",{className:"nm-addr-dot","aria-hidden":!0}):a.jsx(Sb,{}),e.tier!=="online"&&a.jsx("i",{className:"nm-mark","data-tier":e.tier,"data-kind":f.kind,"aria-hidden":!0}),a.jsxs("span",{className:"nm-label","aria-hidden":!0,children:[a.jsx("span",{className:"nm-name",children:LO(f)}),a.jsx("span",{className:"nm-cap",children:v})]}),e.tier==="online"&&a.jsx("span",{id:p,className:"vis-hidden",children:v})]})}function HX({status:e}){const t=(e==null?void 0:e.enabled)===!0;return a.jsx("p",{className:"nm-empty",children:e?t?"No other deck yet. Decks on one network usually find each other within a minute; one on another network needs its address, through Add a deck in Local network.":"Local network is off, so this deck is not looking for any other.":"Asking this deck about the network…"})}function VX({slice:e}){return a.jsxs("ul",{className:"nm-legend",children:[a.jsxs("li",{children:[a.jsxs("span",{className:"nm-key","aria-hidden":!0,children:[a.jsx("i",{className:"nm-key-wire","data-tier":"online"}),a.jsx("i",{className:"nm-key-mark","data-tier":"online"})]}),"online"]}),a.jsxs("li",{children:[a.jsxs("span",{className:"nm-key","aria-hidden":!0,children:[a.jsx("i",{className:"nm-key-wire","data-tier":"offline"}),a.jsx("i",{className:"nm-key-mark","data-tier":"offline"})]}),"away"]}),a.jsxs("li",{children:[a.jsxs("span",{className:"nm-key","aria-hidden":!0,children:[a.jsx("i",{className:"nm-key-wire","data-tier":"loose"}),a.jsx("i",{className:"nm-key-mark","data-tier":"loose"})]}),"not paired"]}),e&&a.jsxs("li",{children:[a.jsx("i",{className:"nm-key-zone","aria-hidden":!0}),"over Tailscale"]})]})}function VO({facts:e}){return a.jsx("dl",{className:"lan-facts nm-facts",children:e.map(t=>a.jsxs("div",{className:"lan-fact","data-tone":t.quiet?"quiet":void 0,children:[a.jsx("dt",{children:t.label}),a.jsx("dd",{children:t.value})]},t.label))})}function GX({status:e,summary:t,entrance:n,slice:r}){const s=wX(e),o=jb(e==null?void 0:e.about),l=[];o&&l.push({label:"Runs",value:o}),l.push({label:s.length>1?"Addresses":"Address",value:s.length?a.jsx("span",{className:"nm-addrs",children:s.map(h=>a.jsx("code",{className:"ap-lan-code",children:h},h))}):"none yet",quiet:s.length===0}),e!=null&&e.pairingMode&&l.push({label:"Pairing",value:e.pairingMode==="invite"?"by invite only":"asks and answers"});const c=[{key:"online",n:t.online,words:"online",mark:a.jsx("i",{className:"nm-key-mark","data-tier":"online","aria-hidden":!0})},{key:"away",n:t.offline,words:"away",mark:a.jsx("i",{className:"nm-key-mark","data-tier":"offline","aria-hidden":!0})},{key:"asks",n:t.asks,words:"asking to pair",mark:a.jsx("i",{className:"nm-key-mark","data-tier":"loose","data-kind":"asks","aria-hidden":!0})},{key:"nearby",n:t.nearby,words:"nearby, not paired",mark:a.jsx("i",{className:"nm-key-mark","data-tier":"loose","aria-hidden":!0})},{key:"dialling",n:t.dialling,words:"still dialling",mark:a.jsx("i",{className:"nm-key-mark","data-tier":"loose","aria-hidden":!0})},{key:"declined",n:t.declined,words:"declined, not drawn",mark:a.jsx("i",{"aria-hidden":!0})}],d=xX(t,e==null?void 0:e.pairingMode);return a.jsxs("div",{className:"nm-panel","data-view":"network","data-entrance":n,children:[a.jsx("h3",{className:"nm-panel-name",children:(e==null?void 0:e.name)??"…"}),a.jsx("p",{className:"nm-panel-self",children:"this deck, at the centre of the map"}),a.jsx("ul",{className:"nm-counts",children:c.filter(h=>h.n>0).map(h=>a.jsxs("li",{"data-count":h.key,children:[h.mark,a.jsx("span",{className:"nm-count-n",children:h.n}),a.jsx("span",{className:"nm-count-words",children:h.words})]},h.key))}),t.tailnet>0&&a.jsxs("p",{className:"nm-counts-note",children:[t.tailnet," reached over Tailscale",r?" — the shaded slice, lower right":""]}),d&&a.jsx("p",{className:"nm-next",children:d}),a.jsx(VO,{facts:l}),a.jsx("p",{className:"nm-panel-hint",children:"Point at a deck, or reach one with the arrow keys, to see it here. Press it to open its own dialog."})]})}function KX({row:e,status:t,accounts:n,now:r,entrance:s,onOpen:o,onBack:l}){var x;const c=WO({row:e,source:lc(t,e),status:t,accounts:n,now:r}),d=[];c.where&&d.push({label:"Address",value:a.jsx("code",{className:"ap-lan-code",children:c.where})}),c.thereRuns&&d.push({label:"Runs",value:`${c.thereRuns}${c.order?` · ${c.order<0?"older than this deck":"newer than this deck"}`:""}`}),c.hiddenThere&&d.push({label:"Signed in to",value:"not said — its owner hides it",quiet:!0}),c.otherThere&&d.push({label:"Signed in to",value:"an account it does not share",quiet:!0});const h=e.kind==="paired"&&e.here||e.kind==="asks",f=bX(e,t.pairingMode),p=kX(c.lanes),g=p.length,v=p.filter(N=>N.tone==="ok").length,j=g===0?"No shared logins":v===g?`${g} shared login${g===1?", fine":"s, all fine"}`:`${g} shared login${g===1?"":"s"} · ${v} fine`,k=c.unknown&&((x=c.peer)!=null&&x.waiting)&&!c.peer.offers?"Its side is not known until it next calls.":c.unknown;return a.jsxs("div",{className:"nm-panel","data-view":"deck","data-entrance":s,"data-tier":e.kind==="paired"?e.here?"online":"offline":"loose",children:[a.jsxs("button",{type:"button",className:"ap-lan-word nm-back",onClick:l,children:[a.jsx("span",{"aria-hidden":!0,children:"‹ "}),"the whole network"]}),a.jsxs("div",{className:"nm-panel-head",children:[a.jsxs("h3",{className:"nm-panel-name",children:[a.jsx("i",{className:h?"ap-pulse":"ap-dot","data-kind":e.kind,"aria-hidden":!0}),a.jsx("span",{className:"nm-panel-title",children:e.name})]}),a.jsx("button",{type:"button",className:"btn nm-open",onClick:o,"aria-label":`Open ${e.name}`,children:"Open"})]}),e.self&&a.jsxs("p",{className:"nm-panel-self",children:["calls itself ",e.self]}),a.jsx("p",{className:"nm-panel-state","data-kind":e.kind,children:DO(e)}),f&&a.jsx("p",{className:"nm-next",children:f}),d.length>0&&a.jsx(VO,{facts:d}),c.paired&&a.jsxs("section",{className:"nm-logins","aria-label":"Logins the two decks share",children:[a.jsx("p",{className:"nm-logins-title",children:j}),g>0&&a.jsx("ul",{className:"nm-lanes",children:p.map((N,b)=>a.jsxs("li",{className:"nm-lane","data-tone":N.tone,style:{"--k":b},children:[a.jsx("i",{className:"nm-lane-dot","aria-hidden":!0}),a.jsx("span",{className:"nm-lane-email","aria-hidden":!0,children:N.email}),__(N)&&a.jsx("span",{className:"nm-lane-said","aria-hidden":!0,children:__(N)}),N.usedThere&&a.jsx("span",{className:"nm-lane-used","aria-hidden":!0,children:"in use there"}),a.jsxs("span",{className:"vis-hidden",children:[N.email,": ",zO(N)]})]},N.key))}),k&&a.jsx("p",{className:"nm-panel-hint",children:k})]})]})}function __(e){return e.caption?e.caption:e.tone==="ok"?null:`${qO[e.here]} · ${UO[e.there]}`}function YX(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(36)}const XX=6;function ZX({anchorId:e,id:t,rows:n,onHold:r,onLet:s}){const o=y.useRef(null),l=n.filter(g=>g.kind==="paired"),c=l.filter(g=>g.here),d=c.slice(0,XX),h=l.length-c.length,f=c.length>d.length?`and ${c.length-d.length} more`:h>0?`${h} not on right now`:null,p=y.useCallback(()=>{const g=o.current,v=document.getElementById(e);if(!g||!v)return;g.style.maxHeight="";const j=Ik(v.getBoundingClientRect(),{width:g.offsetWidth,height:g.offsetHeight},{width:window.innerWidth,height:window.innerHeight});g.style.top=`${j.top}px`,g.style.left=`${j.left}px`,g.style.maxHeight=j.maxHeight==null?"":`${j.maxHeight}px`,g.dataset.side=j.side},[e]);return y.useLayoutEffect(()=>{p()}),y.useEffect(()=>(window.addEventListener("scroll",p,!0),window.addEventListener("resize",p),()=>{window.removeEventListener("scroll",p,!0),window.removeEventListener("resize",p)}),[p]),Pt.createPortal(a.jsxs("div",{ref:o,id:t,className:"ap-peek",role:"tooltip",onPointerEnter:r,onPointerLeave:s,children:[a.jsx("p",{className:"ap-peek-title",children:c.length?"On the network now":"Nobody on the network"}),d.length>0&&a.jsx("div",{className:"ap-peek-list",children:d.map(g=>a.jsxs("span",{className:"ap-peek-who",children:[a.jsx("i",{className:"ap-nav-live","aria-hidden":!0}),a.jsxs("span",{title:g.via==="tailscale"?`${g.name} · Tailscale`:g.name,children:[g.name,g.via==="tailscale"&&a.jsx("span",{className:"ap-lan-via",children:" · Tailscale"})]})]},`${g.kind}:${g.fp}`))}),f&&a.jsx("p",{className:"ap-peek-rest",children:f})]}),document.body)}function JX({entry:e,rows:t,onOpen:n,onMap:r,peek:s,openPeek:o,shutPeek:l,holdPeek:c,dropPeek:d}){return a.jsxs(a.Fragment,{children:[a.jsxs("button",{type:"button",id:"ap-lan-entry",className:"ap-nav",onClick:()=>{d(),n()},"aria-describedby":s?"ap-lan-peek":void 0,onPointerEnter:h=>{h.pointerType==="mouse"&&o(EO)},onPointerLeave:l,onFocus:h=>{h.target.matches(":focus-visible")&&o(0)},onBlur:l,children:[a.jsxs("svg",{className:"ap-nav-glyph",width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("rect",{x:"1.8",y:"2.3",width:"10.4",height:"7.2",rx:"1.2"}),a.jsx("path",{d:"M5 11.9h4M7 9.5v2.4"})]}),a.jsxs("span",{className:"ap-nav-text",children:[a.jsx("span",{className:"ap-nav-name",children:"Local network"}),a.jsxs("span",{className:"ap-nav-state","data-tone":e.tone,children:[e.live&&a.jsx("i",{className:"ap-nav-live","aria-hidden":!0}),e.text]})]}),a.jsx("svg",{className:"ap-nav-chev",width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:a.jsx("path",{d:"M5.6 3.4 9.2 7l-3.6 3.6"})})]}),r&&a.jsx("button",{type:"button",className:"ap-lan-map",onClick:()=>{d(),r()},"aria-label":"Show the network map",title:"Network map — every deck this one knows, drawn around it",children:a.jsx(HO,{})}),s&&a.jsx(ZX,{anchorId:"ap-lan-entry",id:"ap-lan-peek",rows:t,onHold:c,onLet:l})]})}function QX({row:e,run:t,onVerb:n,onUnpair:r}){const[s,o]=y.useState(!1),l=y.useRef(0),[c,d]=y.useState(null);return y.useEffect(()=>{if(!s)return;const p=window.setTimeout(()=>o(!1),4e3);return()=>window.clearTimeout(p)},[s]),y.useEffect(()=>{if(!c)return;const p=window.setTimeout(()=>d(null),4e3);return()=>window.clearTimeout(p)},[c]),{armed:s,armedTwin:c,pressOwn:()=>{const p=Date.now(),g=so({armedFor:s?e.fp:null,target:e.fp,armedAt:l.current,now:p,gapMs:ro});if(g==="arm"){o(!0),d(null),l.current=p;return}g!=="ignore"&&(o(!1),t(n))},pressTwin:p=>{if(!r)return;const g=Date.now(),v=so({armedFor:c,target:p,armedAt:l.current,now:g,gapMs:ro});if(v==="arm"){d(p),o(!1),l.current=g;return}v!=="ignore"&&(d(null),t(()=>r(p)))}}}function eZ({row:e,paired:t,peer:n,status:r,busy:s,press:o,checkNow:l,armed:c,pressOwn:d,run:h,onVerb:f,onInvite:p}){return a.jsxs("footer",{className:"lan-peer-foot",children:[e.kind==="asks"&&a.jsx("p",{className:"lan-foot-note",children:"This deck is now asking to pair. Answer it from the panel behind this."}),t&&!(n!=null&&n.waiting)&&a.jsx("button",{type:"button",className:"btn",...o(`check:${e.fp}`),onClick:l,title:"Ask this deck now instead of waiting for the next round",children:s===`check:${e.fp}`?"Checking…":"Check now"}),e.kind==="paired"&&a.jsx("button",{type:"button",className:`btn danger lan-peer-verb${c?" armed":""}`,...o(`unpair:${e.fp}`),onKeyDown:g=>{g.repeat&&g.preventDefault()},onClick:()=>d(),"aria-label":c?`Confirm unpairing ${e.name}`:`Unpair ${e.name}`,title:c?"Press again to stop talking to this deck. Logins it already has stay with it.":"Stop talking to this deck from now on",children:s===`unpair:${e.fp}`?"Unpairing…":c?"Confirm unpair":"Unpair"}),e.kind==="nearby"&&r.pairingMode!=="invite"&&a.jsx("button",{type:"button",className:"btn primary lan-peer-verb",...o(`accept:${e.fp}`),onClick:()=>void h(f),title:"Send it a request. Somebody at that machine has to accept it before anything is shared.",children:s===`accept:${e.fp}`?"Asking…":"Ask to pair"}),e.kind==="dialling"&&a.jsx("button",{type:"button",className:"btn lan-peer-verb",...o(`drop:${e.fp}`),onClick:()=>void h(f),title:"Stop trying this address. Nothing was ever paired here.",children:s===`drop:${e.fp}`?"Stopping…":"Stop dialling"}),e.kind==="declined"&&r.pairingMode!=="invite"&&a.jsx("button",{type:"button",className:"btn lan-peer-verb",...o(`allow:${e.fp}`),onClick:()=>void h(f),title:"Take the no back. That deck is still trying, so its request comes round again on its own.",children:s===`allow:${e.fp}`?"Allowing…":"Let it ask again"}),(e.kind==="nearby"||e.kind==="declined")&&r.pairingMode==="invite"&&p&&a.jsx("button",{type:"button",className:"btn primary lan-peer-verb",onClick:p,title:"This deck pairs only by invite. Make one and send it to whoever is at that machine.",children:"Invite to pair"})]})}function tZ({instances:e,now:t,busy:n,press:r,armedTwin:s,pressTwin:o,onUnpair:l}){return a.jsxs("div",{className:"modal-section",children:[a.jsxs("h3",{className:"lan-h",children:[e.length," decks on this machine"]}),a.jsx("ul",{className:"lan-twins",role:"list",children:e.map((c,d)=>{var j,k,x,N;const h=(j=c.peer)!=null&&j.addr?`${c.peer.addr}:${c.peer.port}`:c.row.addr,f=h||c.row.fp,p=(k=c.peer)!=null&&k.pairedAt?Hr(c.peer.pairedAt,t):null,g=[(N=(x=c.peer)==null?void 0:x.about)!=null&&N.version?`runs ${c.peer.about.version}`:null,p?`paired ${p==="now"?"just now":p}`:null,c.row.state].filter(Boolean).join(" · "),v=c.row.fp;return a.jsxs("li",{role:"listitem",className:"lan-twin","data-tone":c.row.tone,children:[a.jsx("i",{className:c.row.here?"ap-pulse":"ap-dot","aria-hidden":!0}),h?a.jsx("code",{className:"ap-lan-code lan-twin-at",children:h}):a.jsx("span",{className:"lan-twin-at lan-twin-none",children:"no address here"}),a.jsx("code",{className:"ap-lan-code lan-twin-fp",children:v}),d>0&&l&&a.jsx("button",{type:"button",className:`ap-manage-btn danger lan-twin-do${s===v?" armed":""}`,...r(`unpair:${v}`),onKeyDown:b=>{b.repeat&&b.preventDefault()},onClick:()=>o(v),"aria-label":s===v?`Confirm unpairing ${f}`:`Unpair ${f}`,title:s===v?"Press again to stop talking to this deck. Logins it already has stay with it.":"Stop talking to this one of the machine's decks",children:n===`unpair:${v}`?"unpairing…":s===v?"confirm":"unpair"}),a.jsx("span",{className:"lan-twin-meta",children:d===0?`${g} · shown above`:g})]},v)})})]})}function nZ(){return a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("path",{d:"M9.6 2.4l2 2L5 11l-2.6.6L3 9z"}),a.jsx("path",{d:"M8.4 3.6l2 2"})]})}function rZ({row:e,source:t,status:n,accounts:r,now:s,busy:o,onClose:l,onRename:c,onCheck:d,onVerb:h,onSettings:f,onInvite:p,twins:g=[],onUnpair:v}){const j=y.useRef(null),k=ot(l,{focusRef:j}),x=mt(l),[N,b]=y.useState(null),[S,E]=y.useState(null),[R,I]=y.useState(!1),[A,q]=y.useState(0),$=y.useRef(null),B=y.useRef(null),L=y.useRef(!0);y.useEffect(()=>()=>{L.current=!1},[]);const M=N!=null;y.useEffect(()=>{var se;M&&((se=$.current)==null||se.select())},[M]);const F=y.useRef(!1);y.useEffect(()=>{var se,pe;F.current&&!M&&An(((se=document.activeElement)==null?void 0:se.tagName)??null)&&((pe=B.current)==null||pe.focus()),F.current=M},[M]);const T=se=>{const pe=oa(o,se);return{disabled:pe.disabled,"aria-busy":pe.busy}},P=async se=>{const pe=await se();return L.current&&E(pe),pe==null},{armed:O,armedTwin:G,pressOwn:K,pressTwin:U}=QX({row:e,run:P,onVerb:h,onUnpair:v}),H=WO({row:e,source:t,status:n,accounts:r,now:s}),{peer:D,stranger:V,paired:J,own:W,canRename:Z,fp:Y}=H,X=o===`check:${e.fp}`,ee=async se=>{const pe=se.trim()===W?"":se;await P(()=>c(pe))&&b(null)},ae=()=>void P(d).then(se=>{se&&L.current&&q(pe=>pe+1)}),ce=async()=>{if(Y)try{if(await navigator.clipboard.writeText(Y),!L.current)return;I(!0),window.setTimeout(()=>{L.current&&I(!1)},1600)}catch{L.current&&E("Could not copy it — select the fingerprint and copy it by hand.")}},ge=[];J&&(D!=null&&D.pairedAt)?ge.push({label:"Paired",value:EX(D.pairedAt,s),tone:"meta"}):e.kind==="declined"&&V&&ge.push({label:"Paired",value:`no · you said no ${zk(V.at,s)}`,tone:"meta"}),ge.push({label:"Fingerprint",value:Y?a.jsxs("span",{className:"lan-fp",children:[a.jsx("code",{className:"ap-lan-code",children:Y}),a.jsx("button",{type:"button",className:"ap-lan-word lan-copy",onClick:()=>void ce(),"aria-label":R?"Fingerprint copied":"Copy the fingerprint",children:R?"copied":"copy"})]}):"not known — nothing has answered there",tone:Y?void 0:"quiet"});const ye=g.length?[{row:e,peer:D??null},...g]:[];return Pt.createPortal(a.jsx("div",{className:"modal-backdrop",...x,role:"presentation",children:a.jsxs("div",{ref:k,className:"modal lan-peer","data-tone":e.tone,onClick:se=>se.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-peer-title","aria-describedby":"lan-peer-sub",children:[a.jsxs("header",{className:"modal-head lan-peer-head",children:[a.jsx("i",{className:e.here?"ap-pulse":"ap-dot","aria-hidden":!0}),a.jsxs("div",{className:"lan-peer-id",children:[M?a.jsxs("form",{className:"lan-peer-edit",onSubmit:se=>{se.preventDefault(),ee(N??"")},children:[a.jsx("span",{id:"lan-peer-title",className:"vis-hidden",children:e.name}),a.jsx("input",{ref:$,className:"ap-manage-input lan-peer-input",value:N??"",maxLength:48,placeholder:W,"aria-label":"Name for this deck, shown on this deck only",onChange:se=>b(se.target.value)}),a.jsx("button",{type:"submit",className:"ap-manage-btn",...T(`alias:${e.fp}`),children:"save"}),a.jsx("button",{type:"button",className:"ap-manage-btn",onClick:()=>b(null),children:"cancel"})]}):a.jsxs("span",{className:"lan-peer-title",children:[a.jsx("span",{id:"lan-peer-title",className:"lan-peer-name",children:e.name}),Z&&a.jsx("button",{type:"button",className:"glyph-btn lan-peer-rename",ref:B,onClick:()=>{E(null),b(e.name)},"aria-label":`Rename ${e.name} on this deck`,title:"Give it a name of your own. Only this deck sees it.",children:a.jsx(nZ,{})})]}),a.jsxs("p",{id:"lan-peer-sub",className:"lan-peer-sub",children:[e.self&&a.jsxs(a.Fragment,{children:["calls itself ",a.jsx("span",{className:"lan-peer-self",children:e.self}),M&&a.jsx("button",{type:"button",className:"ap-lan-word lan-peer-restore",...T(`alias:${e.fp}`),onClick:()=>void ee(""),children:"use this name"}),a.jsx("span",{className:"vis-hidden",children:". "}),!e.quiet&&a.jsx("span",{"aria-hidden":!0,children:" · "})]}),a.jsx("span",{className:e.quiet?"vis-hidden":"lan-peer-state",children:e.state})]})]}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{ref:j,type:"button",className:"glyph-btn",onClick:l,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body lan-peer-body",children:[S&&a.jsxs("div",{className:"ap-failure",role:"alert",children:[a.jsx("span",{className:"ap-failure-text",children:S}),a.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>E(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),a.jsx(CX,{view:H,row:e,status:n,asking:X,drawn:A,onSettings:f}),a.jsx("dl",{className:"lan-facts",children:ge.map(se=>a.jsxs("div",{className:"lan-fact","data-tone":se.tone,children:[a.jsx("dt",{children:se.label}),a.jsx("dd",{children:se.value})]},se.label))}),ye.length>1&&a.jsx(tZ,{instances:ye,now:s,busy:o,press:T,armedTwin:G,pressTwin:U,onUnpair:v})]}),a.jsx(eZ,{row:e,paired:J,peer:D,status:n,busy:o,press:T,checkNow:ae,armed:O,pressOwn:K,run:P,onVerb:h,onInvite:p})]})}),document.body)}function ps(e,t){const n=y.useRef(!1);return y.useEffect(()=>{var r,s;!e||!n.current||(n.current=!1,An(((r=document.activeElement)==null?void 0:r.tagName)??null)&&(typeof t=="function"?t():(s=t.current)==null||s.focus()))},[e]),()=>{n.current=!0}}function sZ(e,t){if(e.length!==t.length)return!1;const n=new Set(e);return t.every(r=>n.has(r))}function aZ(e,t,n,r){const s=new Set(e??t);return r?s.add(n):s.delete(n),[...s]}function E_(e,t,n){return e==null||n!=null&&!n.ok||sZ(e,t)?null:e}function GO({line:e,onDismiss:t,onAnswer:n}){const[r,s]=y.useState(!1),o=y.useRef(!1),l=y.useRef(!0);y.useEffect(()=>(l.current=!0,()=>{l.current=!1}),[]);const c=y.useRef(null),d=y.useRef(null),h=y.useRef(!1);if(y.useEffect(()=>{var p;h.current&&(h.current=!1,e!=null&&e.giveBack||(p=d.current)==null||p.focus())},[e]),!e)return null;const f=async()=>{if(o.current)return;o.current=!0,s(!0);const p=await sY();o.current=!1,l.current&&(s(!1),h.current=document.activeElement===c.current,n(oY(p)))};return a.jsxs("div",{className:e.done?"ap-failure ap-failure-done":"ap-failure",role:"alert",children:[a.jsx("span",{className:"ap-failure-text",children:e.text}),e.giveBack&&a.jsx("button",{ref:c,type:"button",className:"ap-fix ap-give-back","aria-busy":r,onClick:f,title:"Opens macOS's password dialog to make the settings folder yours again",children:r?"waiting for macOS…":"give it back"}),a.jsx("button",{ref:d,type:"button",className:"ap-failure-x",onClick:t,"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]})}function oZ(e){if(!e.running)return`Tailscale is ${e.state==="Stopped"?"turned off":e.state==="NeedsLogin"||e.state==="NeedsMachineAuth"?"signed out":e.state==="Starting"?"still starting":"not answering"} on this machine`;const t=e.login??"your Tailscale account";return e.on?`${e.devices} online · ${t}`:t}const ed="Paused while this deck pairs only by invite. Turn that off above to use it.";function iZ({status:e,accounts:t,onClose:n,onChanged:r}){qt("lan-setup");const s=ot(n),o=mt(n),[l,c]=y.useState(null),[d,h]=y.useState(null),[f,p]=y.useState(!1),[g,v]=y.useState(null),j=y.useRef(null),k=U=>{const H=oa(g,U);return{disabled:H.disabled,"aria-busy":H.busy}},x=y.useRef(null),N=y.useRef(!0);y.useEffect(()=>()=>{N.current=!1},[]),y.useEffect(()=>{x.current=E_(x.current,e.shared??[],null)},[e.shared]);const b=y.useCallback(async(U,H,D="write")=>{j.current=D,v(D);try{const J=await(await fetch("/api/prefs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({lan:U})})).json().catch(()=>null);return N.current?(J!=null&&J.ok?h(null):h(gr(Ct(H,J),J)),r(),(J==null?void 0:J.ok)===!0):!1}catch{return N.current&&h(gr(Ct(H,null))),!1}finally{j.current=null,N.current&&v(null)}},[r]),S=y.useCallback(async U=>{const H=await b({name:U},"save the name","name");return H&&N.current&&c(D=>D===U?null:D),H},[b]),E=y.useRef(null),R=l!=null&&l!==(e.name??""),I=ps(!R,E),A=y.useCallback(async()=>{R&&!await S(l)||n()},[R,l,S,n]),q=async()=>{if(!e.fp)return;const U=await oo(e.fp);if(N.current){if(!U){h(gr("Could not copy it — select the fingerprint and copy it by hand."));return}p(!0),window.setTimeout(()=>{N.current&&p(!1)},1600)}},$=new Set(x.current??e.shared??[]),B=e.autoAsk!==!1,L=e.autoAccept!==!1,M=e.pairingMode==="invite",F=U=>{const H=k(U);return{...H,disabled:H.disabled||M}},T=e.shareActive!==!1,P=e.tailscale??null,O=!!(P!=null&&P.on),G=(P==null?void 0:P.ask)!==!1,K=(P==null?void 0:P.accept)!==!1;return Pt.createPortal(a.jsx("div",{className:"modal-backdrop",...o,role:"presentation",children:a.jsxs("div",{ref:s,className:"modal lan-modal",onClick:U=>U.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-modal-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{id:"lan-modal-title",className:"modal-tool-name",children:"This deck on the network"})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{className:"glyph-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[a.jsx(GO,{line:d,onDismiss:()=>h(null),onAnswer:U=>{h(U),U.done&&r()}}),a.jsxs("div",{className:"modal-section",children:[a.jsx("h3",{className:"lan-h",children:"Name"}),a.jsxs("div",{className:"ap-lan-row",children:[a.jsx("span",{className:"ap-lan-label",children:"appear as"}),a.jsx("input",{ref:E,className:"ap-manage-input ap-lan-input","aria-label":"This deck's name on the network",value:l??e.name??"",placeholder:"this machine",onChange:U=>c(U.target.value),onKeyDown:U=>{U.key!=="Enter"||l==null||S(l)}}),R&&a.jsx("button",{type:"button",className:"ap-manage-btn",...k("name"),onClick:()=>{I(),S(l)},title:"Save it. This is the name other decks show for this one.",children:"save"})]}),a.jsxs("div",{className:"ap-lan-row",children:[a.jsx("span",{className:"ap-lan-label",children:"fingerprint"}),e.fp?a.jsxs("span",{className:"lan-fp",children:[a.jsx("code",{className:"ap-lan-code",children:e.fp}),a.jsx("button",{type:"button",className:"ap-lan-word lan-copy",onClick:()=>void q(),"aria-label":f?"Fingerprint copied":"Copy this deck's fingerprint",children:f?"copied":"copy"})]}):a.jsx("span",{className:"ap-lan-label",children:"not known yet"})]})]}),a.jsxs("div",{className:"modal-section",children:[a.jsx("h3",{className:"lan-h",children:"Share these accounts"}),a.jsxs("div",{className:"ap-lan-picks",children:[t.length===0&&a.jsx("span",{className:"ap-lan-empty",children:"No Claude accounts on this deck yet — add one with + at the top of this panel."}),t.map(U=>a.jsxs("label",{className:"ap-lan-pick",title:U.alive?"Offer this account to the decks you have paired with, so one whose copy has died can heal from yours. Unticking stops it being offered from now on; it does not take back a copy somebody already has.":"This deck cannot use this login, so it has nothing to offer — a deck that can will heal it",children:[a.jsx("input",{type:"checkbox",checked:$.has(U.key),onChange:H=>{const D=aZ(x.current,e.shared??[],U.key,H.target.checked);x.current=D,b({shared:D},H.target.checked?"share that account":"stop sharing that account").then(V=>{x.current===D&&(x.current=E_(D,e.shared??[],{ok:V}))})}}),a.jsx("span",{className:"ap-lan-pick-name",children:U.email}),!U.alive&&a.jsx("span",{className:"ap-lan-dead",children:"not working here"})]},U.key))]}),t.length>0&&a.jsxs("div",{className:"lan-switch",children:[a.jsx("span",{className:"lan-switch-what",children:"Show paired decks which of these this deck is using"}),a.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":T,"aria-label":"Show paired decks which of these this deck is using",...k("current"),onClick:()=>void b({shareActive:!T},T?"stop showing which account this deck is using":"show which account this deck is using","current"),title:T?"Stop telling paired decks which account this one is on. They read “current account hidden” instead.":"Tell paired decks which of the ticked accounts this one is on. An unticked account is never named.",children:a.jsx("span",{className:"switch-knob"})})]})]}),a.jsxs("div",{className:"modal-section",children:[a.jsx("h3",{className:"lan-h",id:"lan-pairing-h",children:"Pairing"}),a.jsx("div",{className:"lan-switches lan-switches-lead",role:"group","aria-labelledby":"lan-pairing-h",children:a.jsxs("div",{className:"lan-switch",children:[a.jsxs("span",{className:"lan-switch-what",children:["Pair new decks only by invite",M&&a.jsx("span",{id:"lan-invite-only-detail",className:"lan-switch-detail",children:"A new deck needs an invite from Add a deck, the link at the top of Local network. Paired decks stay paired."})]}),a.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":M,"aria-label":"Pair new decks only by invite","aria-describedby":M?"lan-invite-only-detail":void 0,...k("mode"),onKeyDown:U=>{U.repeat&&U.preventDefault()},onClick:()=>void b({pairingMode:M?"automatic":"invite"},M?"let decks pair on their own again":"pair new decks only by invite","mode"),title:M?"Let decks on this network pair as the two switches below say again.":"Only a deck you send an invite to can pair with this one. Nearby decks can't ask, and requests waiting now are turned away.",children:a.jsx("span",{className:"switch-knob"})})]})}),a.jsxs("div",{className:"lan-auto",role:"group","aria-labelledby":"lan-auto-h",children:[a.jsxs("p",{className:"lan-sub",id:"lan-auto-h",children:["Automatic pairing",M&&a.jsx("span",{className:"lan-sub-state",children:" · paused while pairing is invite-only"})]}),a.jsxs("div",{className:"lan-switches","data-paused":M||void 0,children:[a.jsxs("div",{className:"lan-switch",children:[a.jsx("span",{className:"lan-switch-what",children:"Ask every deck this one finds"}),a.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":B,"aria-label":"Ask every deck this one finds",...F("ask"),onClick:()=>void b({autoAsk:!B},B?"stop asking automatically":"ask every deck this one finds","ask"),title:M?ed:B?"Stop sending requests on their own. You press ask on the row instead.":"Send a pairing request to every deck heard on this network. Somebody over there still has to say yes.",children:a.jsx("span",{className:"switch-knob"})})]}),a.jsxs("div",{className:"lan-switch",children:[a.jsx("span",{className:"lan-switch-what",children:"Say yes to every deck that asks"}),a.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":L,"aria-label":"Say yes to every deck that asks","data-tone":"warn",...F("accept"),onKeyDown:U=>{U.repeat&&U.preventDefault()},onClick:()=>void b({autoAccept:!L},L?"stop accepting automatically":"accept every deck that asks","accept"),title:M?ed:L?"Stop saying yes for you. A deck that asks waits in the panel again, and adds no login here until somebody here accepts it.":"Say yes for you. Every deck on this network that asks is paired without anybody being asked here. Each can then add the logins ticked on it to this deck.",children:a.jsx("span",{className:"switch-knob"})})]})]})]})]}),(P==null?void 0:P.found)&&a.jsxs("div",{className:"modal-section",children:[a.jsx("h3",{className:"lan-h",children:"Tailscale"}),a.jsxs("div",{className:"lan-switches",children:[a.jsxs("div",{className:"lan-switch",children:[a.jsxs("span",{className:"lan-switch-what",children:["Look for my devices",a.jsx("span",{id:"lan-ts-detail",className:"lan-switch-detail",children:oZ(P)})]}),a.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":O,"aria-label":"Look for my devices over Tailscale","aria-describedby":"lan-ts-detail",...k("tailscale"),onClick:()=>void b({tailscale:!O},O?"stop looking over Tailscale":"look for your devices over Tailscale","tailscale"),title:O?"Stop. Nothing is looked for or answered over the tailnet; decks already paired stay paired.":"Find the decks on your other machines on Tailscale, wherever they are. Only machines signed in to your Tailscale account are asked.",children:a.jsx("span",{className:"switch-knob"})})]}),O&&a.jsxs("div",{className:"lan-auto",role:"group","aria-labelledby":"lan-ts-auto-h",children:[a.jsxs("p",{className:"lan-sub",id:"lan-ts-auto-h",children:["Automatic pairing with my devices",M&&a.jsx("span",{className:"lan-sub-state",children:" · paused while pairing is invite-only"})]}),a.jsxs("div",{className:"lan-switches",children:[a.jsxs("div",{className:"lan-switch","data-paused":M||void 0,children:[a.jsx("span",{className:"lan-switch-what",children:"Ask each device it finds"}),a.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":G,"aria-label":"Ask each of my devices it finds over Tailscale",...F("tailscale-ask"),onClick:()=>void b({tailscaleAsk:!G},G?"stop asking your devices automatically":"ask your devices automatically","tailscale-ask"),title:M?ed:G?"Stop sending requests on their own. You press ask on the row instead.":"Send a pairing request to every deck found on your devices over Tailscale.",children:a.jsx("span",{className:"switch-knob"})})]}),a.jsxs("div",{className:"lan-switch","data-paused":M||void 0,children:[a.jsx("span",{className:"lan-switch-what",children:"Say yes to each device that asks"}),a.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":K,"aria-label":"Say yes to my devices when they ask over Tailscale","data-tone":"warn",...F("tailscale-accept"),onKeyDown:U=>{U.repeat&&U.preventDefault()},onClick:()=>void b({tailscaleAccept:!K},K?"stop accepting your devices automatically":"accept your devices automatically","tailscale-accept"),title:M?ed:K?"Stop saying yes for you. A device that asks waits in the panel again.":"Say yes for you when a deck on one of your own devices asks. Anybody else on the tailnet still waits for a press.",children:a.jsx("span",{className:"switch-knob"})})]})]})]})]})]})]}),a.jsxs("footer",{className:"lan-setup-foot",children:[a.jsx("span",{className:"lan-foot-note",children:"Changes are saved as you make them."}),a.jsx("button",{type:"button",className:"btn primary",...k("name"),onClick:()=>void A(),children:"Done"})]})]})}),document.body)}function lZ({on:e,status:t,paired:n,busy:r,pressProps:s,checkNow:o,setAddOpen:l,setSetupOpen:c,setMapOpen:d,onBack:h,closeButton:f}){return a.jsxs("div",{className:"ap-header",children:[a.jsx("button",{type:"button",id:"ap-lan-back",className:"glyph-btn ap-back",onClick:h,"aria-label":"Back to Claude accounts",title:"Back to Claude accounts",children:a.jsx("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:a.jsx("path",{d:"M8.4 3.4 4.8 7l3.6 3.6"})})}),a.jsx("h2",{id:"ap-lan-title",children:"Local network"}),a.jsxs("div",{className:"ap-header-right",children:[e&&a.jsx("button",{type:"button",className:"glyph-btn",onClick:()=>d(!0),"aria-label":"Show the network map",title:"Network map — every deck this one knows, drawn around it",children:a.jsx(HO,{})}),e&&a.jsx("button",{type:"button",className:"glyph-btn ap-lan-plus",onClick:()=>l("add"),"aria-label":"Add a deck",title:(t==null?void 0:t.pairingMode)==="invite"?"Send an invite, or use one you were sent. This deck pairs only by invite.":"Reach a deck that has not turned up on its own — by address, or with an invite",children:a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("path",{d:"M6.1 7.9a2.6 2.6 0 0 0 3.7 0l1.9-1.9a2.6 2.6 0 0 0-3.7-3.7l-.9.9"}),a.jsx("path",{d:"M7.9 6.1a2.6 2.6 0 0 0-3.7 0L2.3 8a2.6 2.6 0 0 0 3.7 3.7l.9-.9"})]})}),e&&n>0&&a.jsx("button",{type:"button",className:"glyph-btn ap-lan-check",...s("check"),onClick:()=>void o(),"aria-label":r==="check"?"Checking every paired deck":"Check every paired deck now",title:"Ask every paired deck now for anything this deck's expired logins need, instead of waiting for the next round",children:a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("circle",{cx:"7",cy:"7",r:"1.1",fill:"currentColor",stroke:"none"}),a.jsx("path",{d:"M4.6 4.6a3.4 3.4 0 0 0 0 4.8M9.4 4.6a3.4 3.4 0 0 1 0 4.8"}),a.jsx("path",{d:"M2.6 2.6a6.2 6.2 0 0 0 0 8.8M11.4 2.6a6.2 6.2 0 0 1 0 8.8"})]})}),e&&a.jsx("button",{type:"button",className:"glyph-btn ap-lan-set",...s("setup"),onClick:()=>c(!0),"aria-label":"This deck's name and shared logins",title:"This deck's name on the network, and which of its logins it offers",children:a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":!0,children:[a.jsx("path",{d:"M1.8 4.7h10.4M1.8 9.3h10.4"}),a.jsx("circle",{cx:"9.1",cy:"4.7",r:"1.6",fill:"var(--panel)"}),a.jsx("circle",{cx:"4.9",cy:"9.3",r:"1.6",fill:"var(--panel)"})]})}),f]})]})}function cZ({accounts:e,onChanged:t,onNoCopy:n,view:r,onOpen:s,onBack:o,closeButton:l}){const[c,d]=y.useState(!1),[h,f]=y.useState(!1),[p,g]=y.useState(!1),v=nY(),[j,k]=y.useState(!1),{status:x,manual:N,now:b,busy:S,failure:E,dismissFailure:R,answerGiveBack:I,pressProps:A,load:q,toggle:$,answer:B,dropAddress:L,rename:M,checkOne:F,checkNow:T}=dY(t,()=>d(!0)),{armed:P,pressUnpair:O}=hY(B),[G,K]=y.useState(null),[U,H]=y.useState(!1),D=y.useMemo(()=>e.filter(fe=>eY(fe.key,x??null,b)).map(fe=>fe.key).sort().join(`
95
- `),[e,x,b]);y.useEffect(()=>{n==null||n(D?D.split(`
96
- `):[])},[D,n]);const V=(x==null?void 0:x.enabled)===!0,J=y.useMemo(()=>WK((x==null?void 0:x.pairingMode)==="invite"&&x?{...x,pending:[]}:x,b),[x,b]),W=G?J.find(fe=>{var de;return fe.fp===G||((de=fe.twins)==null?void 0:de.some(me=>me.fp===G))})??null:null;y.useEffect(()=>{G&&x&&!W&&K(null)},[G,x,W]);const{asks:Z,rest:Y,live:X,folded:ee,troubled:ae,shown:ce,paired:ge}=QK(J,j),ye=qK(x,b),se=JK(x,J),pe=a.jsxs(a.Fragment,{children:[h&&x&&a.jsx(IY,{status:x,manual:N,startWith:h==="invite"?"invite":void 0,onClose:()=>f(!1),onChanged:()=>{q(),t()}}),p&&a.jsx(AO,{title:"How Local network works",steps:_Y,finish:V?void 0:{label:"Turn it on",act:()=>{g(!1),$()}},onClose:()=>g(!1)}),c&&x&&a.jsx(iZ,{status:{...x,manualRows:N},accounts:e,manual:N,onClose:()=>d(!1),onChanged:()=>{q(),t()}}),U&&a.jsx(DX,{status:x,rows:J,accounts:e,now:b,covered:!!W||c||!!h||p,onOpenDeck:K,onClose:()=>H(!1)}),W&&x&&a.jsx(rZ,{row:W,source:lc(x,W),status:x,accounts:e,now:b,busy:S,onClose:()=>K(null),onRename:fe=>M(W.fp,fe),onCheck:()=>F(W.fp),onVerb:()=>{switch(W.kind){case"paired":return B("unpair",W.fp,"unpair that deck");case"nearby":return B("accept",W.fp,"reach that deck");case"declined":return B("allow",W.fp,"let that deck ask again");case"dialling":return L(W.fp);default:return Promise.resolve(null)}},onSettings:()=>{K(null),d(!0)},onInvite:()=>{K(null),f("invite")},twins:(W.twins??[]).map(fe=>({row:fe,peer:lc(x,fe).peer??null})),onUnpair:fe=>B("unpair",fe,"unpair that deck")})]});return r?a.jsxs("div",{className:"ap-lan-view",children:[a.jsx(lZ,{on:V,status:x,paired:ge,busy:S,pressProps:A,checkNow:T,setAddOpen:f,setSetupOpen:d,setMapOpen:H,onBack:o,closeButton:l}),a.jsx("div",{className:"ap-scroll",id:"ap-lan-scroll",children:a.jsxs("div",{className:"ap-lan",children:[a.jsxs("div",{className:"ap-policy",children:[a.jsx("h3",{className:"ap-auto-title",children:"Sync with paired decks"}),a.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":V,"aria-label":"Sync with paired decks",...A("switch"),onClick:()=>void $(),title:V?"Stop talking to other decks. Nothing is shared while this is off.":"Let the decks you pair with repair this one's expired logins",children:a.jsx("span",{className:"switch-knob"})})]}),a.jsx(FY,{on:V,status:x}),!V&&a.jsxs("div",{className:"ap-lan-intro-row",children:[a.jsxs("button",{type:"button",className:"ap-lan-intro",onClick:()=>g(!0),title:"Four pictures: what this does, and what to do on each machine",children:[a.jsx(EY,{}),a.jsx("span",{className:"ap-lan-intro-text",children:"Paired machines repair each other's expired logins."}),a.jsx("span",{className:"ap-lan-intro-go",children:"See how it works"})]}),a.jsx(rc,{film:"localNetwork"})]}),a.jsx("p",{className:`ap-lan-status ${ye.tone}`,role:"status",children:ye.tone==="ok"?"":ye.text}),a.jsx(GO,{line:E,onDismiss:R,onAnswer:I}),V&&a.jsxs(a.Fragment,{children:[Z.length>0&&a.jsx(LY,{asks:Z,pressProps:A,answer:B}),ce.length>0&&a.jsx(PY,{rows:ce,pairingMode:x==null?void 0:x.pairingMode,armed:P,pressProps:A,answer:B,dropAddress:L,onUnpair:O,onOpenPeer:K,onInvite:()=>f("invite")}),(X.length>0&&ee.length>0||V&&ge>0)&&a.jsxs("div",{className:"ap-lan-tail",children:[X.length>0&&ee.length>0&&a.jsxs("button",{type:"button",className:"ap-lan-word ap-lan-more","aria-expanded":j,onClick:()=>k(fe=>!fe),title:j?"Show only the decks that are on":`Show the ${ee.length} deck${ee.length===1?"":"s"} that are not responding right now`,children:[a.jsx("span",{className:`ap-lan-chev${j?" open":""}`,"aria-hidden":!0,children:"›"}),j?"fewer":`${ee.length} more`,!j&&ae>0&&a.jsxs("span",{className:"ap-lan-more-bad",children:[" · ",ae," not responding"]})]}),V&&ge>0&&a.jsx("span",{className:"ap-lan-checked",children:UK(x==null?void 0:x.checkedAt,b,S==="check")})]}),Y.length===0&&Z.length===0&&!(x!=null&&x.stalled)&&!(x!=null&&x.deaf)&&!(x!=null&&x.lanTunneled)&&a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"ap-lan-fine",children:"No other deck yet. Decks on one network usually find each other on their own; when that has not happened, the link at the top of this view reaches one by address or by invite."}),a.jsx("button",{type:"button",className:"ap-lan-word ap-lan-how",onClick:()=>g(!0),children:"How it works"}),a.jsx(rc,{film:"localNetwork"})]})]})]})}),pe]}):a.jsxs("div",{className:"ap-foot",children:[a.jsx(JX,{entry:se,rows:J,onOpen:s,onMap:V?()=>H(!0):void 0,...v}),a.jsx("p",{className:"vis-hidden",role:"status",children:ye.tone==="ok"?"":ye.text}),pe]})}function uZ({anchorId:e,id:t,peers:n,onHold:r,onLet:s}){const o=y.useRef(null),{title:l,shown:c,rest:d}=OK(n),h=y.useCallback(()=>{const f=o.current,p=document.getElementById(e);if(!f||!p)return;f.style.maxHeight="";const g=Ik(p.getBoundingClientRect(),{width:f.offsetWidth,height:f.offsetHeight},{width:window.innerWidth,height:window.innerHeight});f.style.top=`${g.top}px`,f.style.left=`${g.left}px`,f.style.maxHeight=g.maxHeight==null?"":`${g.maxHeight}px`,f.dataset.side=g.side},[e]);return y.useLayoutEffect(()=>{h()}),y.useEffect(()=>(window.addEventListener("scroll",h,!0),window.addEventListener("resize",h),()=>{window.removeEventListener("scroll",h,!0),window.removeEventListener("resize",h)}),[h]),Pt.createPortal(a.jsxs("div",{ref:o,id:t,className:"ap-peek ap-fold-peek",role:"tooltip",onPointerEnter:r,onPointerLeave:s,children:[a.jsx("p",{className:"ap-peek-title",children:l}),a.jsx("div",{className:"ap-peek-list",children:c.map(f=>a.jsxs("span",{className:"ap-peek-who ap-fold-who",children:[a.jsx("span",{className:"ap-fold-name",title:f.name,children:f.name}),a.jsx("span",{className:"ap-fold-state","data-tone":f.ready?"ok":f.warn?"warn":"idle",children:f.ready?f.headroom==null?"not read yet":`${Math.round(f.headroom)}% free`:f.why})]},f.key))}),d&&a.jsx("p",{className:"ap-peek-rest",children:d})]}),document.body)}function dZ({peers:e,strained:t,armed:n,threshold:r,open:s,onToggle:o,order:l,choices:c,onOrder:d,allOpen:h,onToggleAll:f,held:p=!1}){const[g,v]=y.useState(!1),j=y.useRef(0);y.useEffect(()=>()=>window.clearTimeout(j.current),[]),y.useEffect(()=>{s&&(window.clearTimeout(j.current),v(!1))},[s]);const k=E=>{s||(window.clearTimeout(j.current),j.current=window.setTimeout(()=>v(!0),E))},x=()=>{window.clearTimeout(j.current),j.current=window.setTimeout(()=>v(!1),CO)},N=()=>window.clearTimeout(j.current),b=()=>{window.clearTimeout(j.current),v(!1)},S=$K(e,{strained:t&&!s,armed:n,threshold:r});return a.jsxs("div",{className:"ap-rest",children:[a.jsxs("button",{type:"button",id:"ap-rest-entry",className:"ap-nav","aria-expanded":s,"aria-controls":s?"ap-rest-panel":void 0,"aria-describedby":g?"ap-rest-peek":void 0,onClick:()=>{b(),o()},onPointerEnter:E=>{E.pointerType==="mouse"&&k(EO)},onPointerLeave:x,onFocus:E=>{E.target.matches(":focus-visible")&&k(0)},onBlur:x,children:[a.jsxs("span",{className:"ap-nav-text",children:[a.jsx("span",{className:"ap-nav-name",children:"Other accounts"}),a.jsx("span",{className:"ap-nav-state","data-tone":S.tone,children:S.text})]}),a.jsx("svg",{className:"ap-nav-chev",width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:a.jsx("path",{d:"M5.6 3.4 9.2 7l-3.6 3.6"})})]}),g&&a.jsx(uZ,{anchorId:"ap-rest-entry",id:"ap-rest-peek",peers:e,onHold:N,onLet:x}),s&&a.jsx(hZ,{order:l,choices:c,onOrder:d,allOpen:h,onToggleAll:f,held:p})]})}function hZ({order:e,choices:t,onOrder:n,allOpen:r,onToggleAll:s,held:o}){var d;const l=y.useRef(null);y.useLayoutEffect(()=>{const h=l.current,f=h==null?void 0:h.parentElement;if(!h||!f)return;const p=()=>f.style.setProperty("--rest-tools-w",`${Math.ceil(h.offsetWidth)}px`);if(p(),typeof ResizeObserver>"u")return;const g=new ResizeObserver(p);return g.observe(h),()=>{g.disconnect(),f.style.removeProperty("--rest-tools-w")}},[]);const c=((d=t.find(h=>h.id===e))==null?void 0:d.label)??"Slot";return a.jsxs("div",{className:"ap-rest-tools",ref:l,children:[a.jsxs("span",{className:"ap-rest-sort",children:[a.jsx("select",{value:e,onChange:h=>n(h.target.value),"aria-label":"Order of the other accounts",title:o?`${c} — held where it was while you are in the list`:c,"data-sorted":e===jh?void 0:"","data-held":o?"":void 0,children:t.map(h=>a.jsx("option",{value:h.id,children:h.label},h.id))}),a.jsx("svg",{width:"9",height:"9",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:a.jsx("path",{d:"M2.5 3.8 5 6.3l2.5-2.5"})})]}),a.jsx("button",{type:"button",className:"ap-rest-all","aria-label":"Expand every account","aria-pressed":r,"aria-controls":"ap-rest-list",title:r?"Collapse every account":"Expand every account",onClick:s,children:a.jsx("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:a.jsx("path",{d:r?"M2 7h10M7 1.5V5M5.2 3.2 7 5l1.8-1.8M7 12.5V9M5.2 10.8 7 9l1.8 1.8":"M2 7h10M7 1.5V5M5.2 3.3 7 1.5l1.8 1.8M7 12.5V9M5.2 10.7 7 12.5l1.8-1.8"})})})]})}async function fZ(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}const pZ=1800;function mZ({accounts:e,onClose:t,copyText:n}){qt("share-accounts");const[r,s]=y.useState([]),[o,l]=y.useState(null),[c,d]=y.useState(!1),[h,f]=y.useState(null),[p,g]=y.useState(!1),[v,j]=y.useState(()=>Math.floor(Date.now()/1e3)),k=y.useRef(null),x=y.useRef(!1),N=ot(t,{focusRef:k}),b=mt(t),S=ps(o!=null,k),E=ps(o==null,k);y.useEffect(()=>{if(!o)return;j(Math.floor(Date.now()/1e3));const O=window.setInterval(()=>j(Math.floor(Date.now()/1e3)),1e3);return()=>window.clearInterval(O)},[o]);const R=mK(e),I=gK(e,r),A=I.length===e.length,q=O=>s(G=>yK(G,O)),$=y.useCallback(async()=>{const O=wK(I);if(!xr(x.current)||!O)return;x.current=!0,d(!0),f(null),g(!1);const G=await fZ(O).catch(()=>null);if(x.current=!1,d(!1),!(G!=null&&G.ok)){f(oi(G,"the share could not be made"));return}l({blob:G.blob,expiresAt:G.expiresAt,shared:G.shared??[],failed:G.failed??[]})},[e,I]),B=o?kO(o.expiresAt,v):null,L=(B==null?void 0:B.tone)==="gone",M=(o==null?void 0:o.shared.length)??0,F=L?"This share has expired":M===1?"1 account, ready to paste":`${M} accounts, ready to paste`,T=M===1?"this is the password":`this is ${M} passwords`,P=o?L?F:`${F} — ${T}`:"";return Pt.createPortal(a.jsx("div",{className:"modal-backdrop",...b,role:"presentation",children:a.jsxs("div",{ref:N,className:"modal sa-modal",onClick:O=>O.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Share accounts with another deck",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("h3",{children:"Share accounts"})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body sa-body",children:[a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:P}),o?a.jsxs("div",{className:"sa-step",children:[a.jsx("h4",{children:F}),a.jsx("code",{className:"ap-share-blob",children:o.blob}),a.jsxs("div",{className:"ap-share-foot",children:[a.jsx("button",{type:"button",className:"ap-manage-btn",ref:k,onClick:async()=>{if(L){E(),S(),l(null),$();return}await n(o.blob)&&(g(!0),window.setTimeout(()=>g(!1),pZ))},children:L?"make a new share":p?"copied":`copy ${M===1?"the share":"all "+M}`}),a.jsxs("span",{className:"ap-manage-hint",title:"This text is the sign-in for every account in it. It is base64 of plain JSON — the expiry inside it is not signed, so anyone holding a copy can change it, and the logins themselves are in there in the clear either way. The countdown only says how long another deck's import dialog will still accept it. If a copy escapes, sign those accounts out and back in.",children:[a.jsx("span",{className:"ap-share-warn",children:T})," · ",a.jsx("span",{className:`ap-share-expiry ${B==null?void 0:B.tone}`,children:B==null?void 0:B.text})]})]}),o.failed.length>0&&a.jsxs("div",{className:"sa-failed",role:"alert",children:[a.jsx("p",{className:"sa-failed-head",children:o.failed.length===1?"One account is not in this bundle:":`${o.failed.length} accounts are not in this bundle:`}),a.jsx("ul",{className:"sa-list",children:o.failed.map(O=>{var K;const G=!!(O.email&&((K=O.detail)!=null&&K.includes(O.email)));return a.jsxs("li",{children:[!G&&a.jsx("span",{className:"sa-who",children:O.email||`account ${O.num}`}),a.jsx("span",{className:"sa-why",children:O.detail||"could not be exported"})]},`${O.num}-${O.email}`)})})]}),a.jsx("p",{className:"sa-note",children:L?a.jsx(a.Fragment,{children:"Another deck will refuse this text now. Make a new one — the same accounts are still picked."}):a.jsxs(a.Fragment,{children:["Paste it into the other deck with ",a.jsx("strong",{children:"+"})," → ",a.jsx("strong",{children:"Paste a share"}),". Accounts it already holds are left exactly as they are."]})}),a.jsxs("div",{className:"sa-actions",children:[a.jsx("button",{type:"button",className:"btn",onClick:()=>{E(),l(null),g(!1)},children:"Pick again"}),a.jsx("button",{type:"button",className:"btn primary",onClick:t,children:"Done"})]})]}):e.length===0?a.jsxs("div",{className:"sa-step",children:[a.jsx("h4",{children:"Nothing to share"}),a.jsxs("p",{className:"sa-note",children:["This deck is not holding any accounts right now. Sign one in with ",a.jsx("strong",{children:"+"}),", or wait — the panel is still reading the store."]}),a.jsx("div",{className:"sa-actions",children:a.jsx("button",{type:"button",className:"btn primary",ref:k,onClick:t,children:"Close"})})]}):a.jsxs("div",{className:"sa-step",children:[a.jsxs("h4",{children:["Which accounts go to the other ",xt,"?"]}),a.jsx("p",{className:`sa-count${I.length?"":" empty"}`,children:vK(I.length)}),a.jsx("ul",{className:"sa-list sa-pick",children:R.map(O=>a.jsx("li",{children:a.jsxs("label",{className:"sa-row",children:[a.jsx("input",{type:"checkbox",checked:I.includes(O.num),onChange:()=>q(O.num)}),a.jsx("span",{className:"sa-who",children:O.label}),O.sub&&a.jsx("span",{className:"sa-sub",children:O.sub})]})},O.num))}),h&&a.jsx("p",{className:"aa-err",role:"alert",children:h}),a.jsxs("div",{className:"sa-actions",children:[a.jsx("button",{type:"button",className:"btn",onClick:()=>s(A?e.map(O=>O.num):[]),children:A?"Clear all":"Select all"}),a.jsx("button",{type:"button",className:"btn primary",ref:k,...Wr(c,!I.length),onClick:()=>{S(),$()},children:c?"making the share…":I.length===0?"Share":I.length===1?"Share 1 account":`Share ${I.length} accounts`})]})]})]})]})}),document.body)}function KO(e,t){var n;return!e.disabled&&!((n=_i(e,t))!=null&&n.blocksSwitch)}function gZ(e,t,n){return e.map(r=>{const s=_i(r,t,n==null?void 0:n(r));return{key:Ur(r),name:r.alias??r.email??`account ${r.num}`,ready:KO(r,t),why:r.disabled?"held out":s!=null&&s.blocksSwitch?s.text:null,warn:(s==null?void 0:s.tone)==="warn",headroom:Pk(r,t)}})}function yZ(e,t,n){const r=Number(t),s=e&&(n==null?e.headroom:Pk(e,n));return s!=null&&Number.isFinite(r)&&100-s>=r}function wZ(e){return(e==null?void 0:e.ok)===!0&&(e.enabled||e.external)}const YO="agent-dag.otherAccountsOrder",XO="agent-dag.otherAccountsOpen";function vZ(){const e=Je(YO);return typeof e=="string"&&e.length>0&&e.length<=64?e:jh}function xZ(e){Ye(YO,e)}function bZ(){const e=Je(XO);if(!e)return fb;try{const t=JSON.parse(e);if(((t==null?void 0:t.mode)==="some"||(t==null?void 0:t.mode)==="all")&&Array.isArray(t.keys)&&t.keys.every(n=>typeof n=="string"))return{mode:t.mode,keys:t.keys.slice(0,200)}}catch{}return fb}function kZ(e){Ye(XO,JSON.stringify({mode:e.mode,keys:e.keys.filter(t=>!t.startsWith("slot:"))}))}function NZ(){const[e,t]=y.useState(null),n=y.useRef(null),r=y.useCallback(l=>xh(n.current)?(n.current=l,t(l),!0):!1,[]),s=y.useCallback(()=>{n.current=null,t(null)},[]);return{busy:e,claim:r,release:s,pressProps:(l,c=!1)=>{const d=oa(e,l);return{disabled:d.disabled,"aria-busy":d.busy||c}}}}const jZ=8e3,SZ=1800,_Z=4e3;function EZ({claim:e,release:t,load:n,clearFailure:r,rescueFocus:s}){const[o,l]=y.useState(null),c=(o==null?void 0:o.num)??null,d=y.useRef(o);d.current=o;const[h,f]=y.useState(null),[p,g]=y.useState(""),[v,j]=y.useState(null),k=y.useRef(0);y.useEffect(()=>{if(v==null)return;const J=window.setTimeout(()=>j(null),_Z);return()=>window.clearTimeout(J)},[v]);const[x,N]=y.useState(null),[b,S]=y.useState(!1),[E,R]=y.useState(null),[I,A]=y.useState(null),q=y.useCallback(async(J,W)=>{if(!e(W))return null;r(),f(null);try{const Z=await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(J)}),Y=await Z.json().catch(()=>null);return Y!=null&&Y.ok||f({text:oi(Y,"command failed",Z.status)}),Y}catch{return f({text:"server unreachable"}),null}finally{t()}},[e,t,r]),$=y.useCallback(()=>{l(null),f(null),j(null),N(null),S(!1)},[]),B=(J,W="first")=>{$(),A(null),l({num:J,view:"menu",start:W})},L=y.useCallback(J=>{var Y,X;const W=d.current;if(!W||J!=null&&W.num!==J)return;const Z=document.getElementById(`ap-menu-${W.num}`);(Z!=null&&Z.contains(document.activeElement)||An(((Y=document.activeElement)==null?void 0:Y.tagName)??null))&&((X=document.getElementById(`ap-more-${W.num}`))==null||X.focus()),$()},[$]),M=y.useCallback(J=>f(J),[]),F=(J,W)=>{g(W??""),f(null),l({num:J,view:"rename"})},T=J=>g(J),P=J=>{A(null),f(null),l({num:J,view:"move"})},O=J=>A(J),G=async J=>{var Z;S(!1);const W=await q({action:"share",account:J},`share-${J}`);!(W!=null&&W.ok)||((Z=d.current)==null?void 0:Z.num)!==J||(N({num:J,blob:W.blob,expiresAt:W.expiresAt}),l({num:J,view:"share"}))},K=async J=>{await oo(J)&&(S(!0),window.setTimeout(()=>S(!1),SZ))},U=async(J,W)=>{const{commit:Z,alias:Y}=EK(p,W);if(Z){const X=await q({action:"alias",account:J,alias:Y},`alias-${J}`);if(await n(!0),!(X!=null&&X.ok))return}L(J)},H=async(J,W)=>{var X,ee,ae;const Z=await q({action:"move",account:J,slot:W},`move-${J}`),Y=SK({menuFor:((X=d.current)==null?void 0:X.num)??null,shareFor:(x==null?void 0:x.num)??null},J,Z);if(await n(!0),Y){if(Y.menuFor!=null){const ge=document.getElementById(`ap-menu-${J}`),ye=document.getElementById(`ap-more-${Y.menuFor}`);ye&&(ge!=null&&ge.contains(document.activeElement)||An(((ee=document.activeElement)==null?void 0:ee.tagName)??null))&&ye.focus()}((ae=d.current)==null?void 0:ae.num)===J&&$(),j(Y.confirmRemove),Y.shareFor==null&&(N(null),S(!1)),R(Y.swapNote);const ce=Y.swapNote;ce&&window.setTimeout(()=>R(ge=>ge===ce?null:ge),jZ),A(null),s(Y.menuFor)}return Z};return{menu:o,menuFor:c,menuError:h,aliasDraft:p,confirmRemove:v,share:x,shareCopied:b,slotDraft:I,swapNote:E,showMenu:B,dropMenu:$,closeMenu:L,sayInMenu:M,startRename:F,typeAlias:T,doAlias:U,startMove:P,pickSlot:O,doSlot:async(J,W,Z)=>{if(!Z.sends){L(J);return}await H(J,W)},makeShare:G,copyShare:K,pressRemove:J=>{const W=Date.now(),Z=so({armedFor:v,target:J,armedAt:k.current,now:W,gapMs:ro});if(Z==="arm"){j(J),k.current=W;return}Z!=="ignore"&&(j(null),q({action:"remove",account:J},`rm-${J}`).then(Y=>{var X;n(!0),Y!=null&&Y.ok&&(((X=d.current)==null?void 0:X.num)===J&&$(),s(null))}))}}}function CZ(e,t){return!e||!t||t.some(n=>n.num===e.num&&n.active)?e:null}function TZ({data:e,claim:t,release:n,load:r,sayFailure:s,clearFailure:o,sayInMenu:l,rescueFocus:c}){const[d,h]=y.useState(null),f=y.useCallback(async(g,v,j="panel")=>{if(!t(v))return null;const k=j==="menu"?l:s;k(null);try{const x=await fetch("/api/cswap-auto",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(g)}),N=await x.json().catch(()=>null);return N!=null&&N.ok||k({text:mb(N,"command failed",x.status),raw:ic(N)}),N}catch{return k({text:"server unreachable"}),null}finally{n()}},[t,n,l,s]);return y.useEffect(()=>{!(e!=null&&e.ok)||!e.accounts||h(g=>CZ(g,e.accounts))},[e]),{switched:d,post:f,doSwitch:async(g,v)=>{if(t(`switch-${g}`)){o(),h(null);try{const k=await(await fetch("/api/claude-accounts/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({account:g})})).json().catch(()=>null);k!=null&&k.ok?h({num:g,name:v}):s({text:mb(k,"the switch failed"),raw:ic(k),row:g}),await r(!0)}catch{s({text:"server unreachable",row:g})}finally{n(),c(g)}}}}}const AZ=1800;function RZ({auto:e,post:t,load:n}){var I;const[r,s]=y.useReducer(UG,pb),[o,l]=y.useState(!1),c=y.useRef(null),d=y.useRef(null),h=y.useRef(null),f=y.useRef(!1),p=((I=e==null?void 0:e.settings["autoswitch.threshold"])==null?void 0:I.value)??"90",g=r.pick??p,v=AK(g,p),j=r.custom!=null,k=r.refusal,x=y.useRef(j);return y.useEffect(()=>{var A,q,$;x.current!==j&&(x.current=j,j?((A=h.current)==null||A.focus(),(q=h.current)==null||q.select()):f.current&&(($=c.current)==null||$.focus()),f.current=!1)},[j]),{threshold:p,thresholdPick:g,thresholdCtl:v,thresholdSaved:o,thresholdRef:c,thresholdSaveRef:d,thresholdCustom:j,thresholdRefusal:k,thresholdFieldRef:h,proposeThreshold:A=>s({kind:"pick",pick:A}),typeThreshold:A=>s({kind:"type",text:A}),cancelThreshold:A=>{A.key!=="Escape"||A.nativeEvent.isComposing||!r.custom||(A.preventDefault(),A.stopPropagation(),f.current=!0,s({kind:"cancel"}))},leaveThreshold:()=>s({kind:"leave",stored:p}),doThreshold:async(A,q)=>{const $=await zG(A,q,t);if($.kind==="refused"){s({kind:"refuse",message:$.message});return}$.kind==="sent"&&(await n(!0),!$.ok)||(f.current=document.activeElement===h.current,s({kind:"settle"}),l(!0),window.setTimeout(()=>{var B;document.activeElement===d.current&&((B=c.current)==null||B.focus()),l(!1)},AZ))}}}const MZ=Object.freeze({text:"couldn't reach the deck server",reload:!0}),$Z=Object.freeze({text:"still waiting on the deck server — claude-swap can be slow to answer",reload:!0});async function C_(e){return e.ok?{ok:!0,status:e.status,body:null}:{ok:!1,status:e.status,body:await e.json().catch(()=>null)}}function IZ(e){const t=e.find(r=>!r.ok);if(!t)return null;const n=ic(t.body);return{text:mb(t.body,`the deck server answered ${t.status}`),...n?{raw:n}:{},reload:!0}}function T_(e,t){return t?e!=null&&e.reload&&e.text===t.text&&e.raw===t.raw?e:t:e!=null&&e.reload?null:e}const ZO=15e3,OZ=3e4;function LZ(e){const[t,n]=y.useState(null),[r,s]=y.useState(null),[o,l]=y.useState(!1),[c,d]=y.useState(null),h=y.useRef(null),f=y.useCallback(async(v=!1)=>{v&&l(!0);const j=new AbortController,k=window.setTimeout(()=>j.abort(),OZ);try{const[x,N]=await Promise.all([fetch(`/api/claude-accounts${v?"?refresh=1":""}`,{signal:j.signal}),fetch("/api/cswap-auto",{signal:j.signal})]);if(x.ok){const S=await x.json();n(S),e(S)}N.ok&&s(await N.json());const b=IZ([await C_(x),await C_(N)]);d(S=>T_(S,b))}catch{d(x=>T_(x,j.signal.aborted?$Z:MZ))}finally{window.clearTimeout(k),v&&l(!1)}},[e]);y.useEffect(()=>(f(!0),h.current=window.setInterval(()=>f(!1),ZO),()=>{h.current!=null&&window.clearInterval(h.current)}),[f]);const p=y.useCallback(v=>d(v),[]),g=y.useCallback(()=>d(null),[]);return{data:t,auto:r,reloading:o,failure:c,load:f,sayFailure:p,clearFailure:g}}const PZ="#ap-rest-entry";function DZ(e){return[`#${e}`,PZ,...HI(null)]}function FZ(e){const t=y.useRef(null),n=s=>{t.current=s.target.id||null},r=s=>{s.target.isConnected&&(t.current=null)};return y.useLayoutEffect(()=>{var o;const s=t.current;if(!(!s||!An(((o=document.activeElement)==null?void 0:o.tagName)??null)))for(const l of DZ(s)){const c=document.querySelector(l);if(c){c.focus();return}}},[e]),{onFocus:n,onBlur:r}}function BZ({onClose:e,leaving:t,onReport:n,onRoster:r}){var Ts,Tr,Ar;qt("accounts-panel");const{busy:s,claim:o,release:l,pressProps:c}=NZ(),[d,h]=y.useState("accounts"),[f,p]=y.useState(!1),[g,v]=y.useState(null),j=y.useRef(g);j.current=g;const[k,x]=y.useState(!1),[N,b]=y.useState(!1),[S,E]=y.useState([]),[R,I]=y.useState(!1),[A,q]=y.useState(null),[$,B]=y.useState(bZ),[L,M]=y.useState(vZ),[F,T]=y.useState(null),[P,O]=y.useState(!1),G=y.useRef(r);G.current=r;const K=y.useCallback(be=>{var Re;B(ze=>pG(ze,be.accounts)),(Re=G.current)==null||Re.call(G,be)},[]),{data:U,auto:H,reloading:D,failure:V,load:J,sayFailure:W,clearFailure:Z}=LZ(K),Y=FZ(U),X=y.useCallback(be=>{window.requestAnimationFrame(()=>{var Re;if(An(((Re=document.activeElement)==null?void 0:Re.tagName)??null))for(const ze of HI(be)){const rn=document.querySelector(ze);if(rn){rn.focus();return}}})},[]),ee=EZ({claim:o,release:l,load:J,clearFailure:Z,rescueFocus:X}),{menu:ae,menuFor:ce,swapNote:ge,showMenu:ye,dropMenu:se,closeMenu:pe,sayInMenu:fe}=ee,{switched:de,post:me,doSwitch:ne}=TZ({data:U,claim:o,release:l,load:J,sayFailure:W,clearFailure:Z,sayInMenu:fe,rescueFocus:X}),{threshold:oe,thresholdPick:Ne,thresholdCtl:we,thresholdSaved:Me,thresholdRef:Le,thresholdSaveRef:Be,thresholdCustom:Pe,thresholdRefusal:Qe,thresholdFieldRef:qe,proposeThreshold:Ze,typeThreshold:lt,cancelThreshold:Nt,leaveThreshold:Xe,doThreshold:tt}=RZ({auto:H,post:me,load:J}),Ge=JI();y.useEffect(()=>{kZ($)},[$]),y.useEffect(()=>{xZ(L)},[L]);const[ct,en]=y.useState(()=>new Set),Dt=y.useCallback(be=>en(new Set(be)),[]),gt=be=>({noCopyWorksNearby:ct.has(i_([be])[0].key)}),wt=(Ts=U==null?void 0:U.accounts)==null?void 0:Ts.find(be=>be.active),zt=wt?_i(wt,Ge,gt(wt)):null,Rt=(U==null?void 0:U.accounts)??[],ht=wt?Rt.filter(be=>!be.active):[],tn=uO(ht),Wt=uG(L,ht),jt=hb(cG(ht,Wt,be=>KO(be,Ge),Ge),F),Jn=y.useRef(!1),yn=y.useRef(!1),Qn=y.useRef(!1),Rn=y.useCallback(()=>{!Jn.current&&!yn.current&&!Qn.current&&T(null)},[]),Yr=()=>T(be=>be??jt.map(Ur)),Mn={onPointerEnter:()=>{Jn.current=!0,Yr()},onPointerLeave:()=>{Jn.current=!1,Rn()},onFocus:be=>{be.target.matches(":focus-visible")&&(yn.current=!0,Yr())},onBlur:be=>{be.currentTarget.contains(be.relatedTarget)||(yn.current=!1,Rn())}},wn=ce!=null&&ht.some(be=>be.num===ce)||g!=null&&ht.some(be=>be.num===g.num);y.useEffect(()=>{Qn.current=wn,wn||Rn()},[wn,Rn]);const $n=P&&ht.length>0;y.useEffect(()=>{$n||(Jn.current=yn.current=Qn.current=!1,T(null))},[$n]);const _s=y.useRef(!1);y.useEffect(()=>{_s.current&&ht.length===0&&X(null),_s.current=ht.length>0},[ht.length,X]);const In=jt.length?Rt.filter(be=>be.active):Rt,er=gZ(jt,Ge,gt),Er=yZ(wt,oe,Ge),Xr=wZ(H),Mt=be=>P&&jt.some(Re=>Re.num===be)?"ap-rest-list":"ap-scroll",ua=(be,Re="first")=>{ye(be,Re),v(null)},tr=(be,Re)=>{se(),v(ze=>(ze==null?void 0:ze.anchor)===Re?null:{num:be,anchor:Re})},nn=y.useCallback((be=!1)=>{var ze;const Re=j.current;be&&Re&&((ze=document.getElementById(Re.anchor))==null||ze.focus()),v(null)},[]),Cr=()=>{se(),v(null),h("lan")},Es=y.useRef(d);y.useEffect(()=>{Es.current!==d&&(Es.current=d,window.requestAnimationFrame(()=>{var be;(be=document.getElementById(d==="lan"?"ap-lan-back":"ap-lan-entry"))==null||be.focus()}))},[d]),y.useEffect(()=>{U!=null&&U.ok&&p(!0)},[U==null?void 0:U.ok]),y.useEffect(()=>{t&&(se(),v(null))},[t,se]),y.useEffect(()=>{ae&&(U!=null&&U.accounts)&&!U.accounts.some(be=>be.num===ae.num)&&se(),g&&(U!=null&&U.accounts)&&!U.accounts.some(be=>be.num===g.num)&&v(null)},[U,ae,g,se]),y.useEffect(()=>{A==null||!(U!=null&&U.accounts)||U.accounts.some(be=>be.num===A.num)||(q(null),X(null))},[U,A,X]);const Cs=a.jsx("button",{type:"button",className:"glyph-btn",onClick:e,"aria-label":"Close accounts panel",title:"Close (A)",children:a.jsx("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":!0,children:a.jsx("path",{d:"M3.4 3.4l7.2 7.2M10.6 3.4l-7.2 7.2"})})}),nr=be=>{const Re=dO($,be),ze=ce===be.num,rn=(V==null?void 0:V.row)===be.num?V:null,Jr=(de==null?void 0:de.num)===be.num,Ht=(ge==null?void 0:ge.at)===be.num?ge:null,rr=Ht?Rt.find(On=>On.num===Ht.displaced):void 0,sr=(g==null?void 0:g.anchor)===`ap-issue-${be.num}`;return a.jsx(yG,{a:be,nowSec:Ge,lan:gt(be),opened:Re,onToggleLanes:()=>B(On=>hG(On,be)),busy:s,pressProps:c,onSwitch:ne,menuOpen:ze,onOpenMenu:ua,onCloseMenu:pe,refusal:rn,onDismissRefusal:()=>Z(),switchedHere:Jr,swapped:Ht,displaced:rr,issueExpanded:sr,onOpenIssue:tr,sortKey:be.active?null:lG(Wt)},be.num)},Zr=U!=null&&U.ok&&(H!=null&&H.ok)?a.jsx(WG,{auto:H,threshold:oe,thresholdPick:Ne,thresholdCtl:we,thresholdSaved:Me,thresholdRef:Le,thresholdSaveRef:Be,thresholdCustom:Pe,thresholdRefusal:Qe,thresholdFieldRef:qe,proposeThreshold:Ze,typeThreshold:lt,cancelThreshold:Nt,leaveThreshold:Xe,doThreshold:tt,pressProps:c,post:me,load:J}):null;return a.jsxs("aside",{className:`accounts-panel${t?" leaving":""}`,id:"accounts-panel","aria-label":"Claude accounts",onFocus:Y.onFocus,onBlur:Y.onBlur,children:[d==="accounts"&&a.jsx(vG,{canShare:(((Tr=U==null?void 0:U.accounts)==null?void 0:Tr.length)??0)>0,canReport:(((Ar=U==null?void 0:U.accounts)==null?void 0:Ar.length)??0)>1||N,onAdd:()=>x(!0),onReport:()=>{E([...In,...jt].map(Ur)),b(!0)},onShareSet:()=>I(!0),onReload:()=>J(!0),pressProps:c,reloading:D,closeButton:Cs}),d==="accounts"&&a.jsxs("div",{className:"ap-scroll",id:"ap-scroll",children:[U==null?V?a.jsxs("div",{className:"ap-empty",role:"alert",children:[a.jsx("span",{title:V.raw||void 0,children:V.text}),a.jsxs("span",{className:"ap-hint",children:["No accounts have arrived, so there is nothing to show yet. The panel keeps trying every ",ZO/1e3," seconds."]}),a.jsx("button",{type:"button",className:"ap-fix",...c("reload",D),onClick:()=>J(!0).then(()=>X(null)),children:D?"trying…":"try again"})]}):a.jsx("div",{className:"ap-empty",children:"Checking…"}):U.ok?a.jsxs(a.Fragment,{children:[wt&&(zt==null?void 0:zt.tone)==="warn"&&a.jsxs("div",{className:"ap-notice",children:[a.jsxs("button",{type:"button",id:"ap-notice",className:"ap-issue","data-tone":"warn","aria-haspopup":"dialog","aria-expanded":(g==null?void 0:g.anchor)==="ap-notice","aria-controls":(g==null?void 0:g.anchor)==="ap-notice"?"ap-issue-pop":void 0,onClick:()=>tr(wt.num,"ap-notice"),children:[a.jsx(Lk,{}),a.jsx("span",{className:"ap-issue-text",children:"Current account needs attention"})]}),zt.fix&&a.jsx("button",{type:"button",className:"ap-notice-fix",onClick:()=>x(!0),title:"Open the sign-in dialog. Signing in as this account replaces its stored login in place.",children:"Sign in"})]}),a.jsx("ul",{className:"ap-list",children:In.map(nr)}),jt.length>0&&a.jsx(dZ,{peers:er,strained:Er,armed:Xr,threshold:H!=null&&H.ok?oe:null,open:P,onToggle:()=>O(be=>!be),order:Wt,choices:tn,onOrder:M,allOpen:hO($,jt),onToggleAll:()=>B(be=>fG(be,jt)),held:F!=null}),jt.length>0&&P&&a.jsxs("div",{className:"ap-rest-panel",id:"ap-rest-panel",children:[a.jsx("ul",{className:"ap-list ap-others",id:"ap-rest-list",...Mn,children:jt.map(nr)}),Zr]}),jt.length===0&&Zr,V&&V.row==null&&a.jsxs("div",{className:"ap-failure",role:"alert",children:[a.jsx("span",{className:"ap-failure-text",title:V.raw||void 0,children:V.text}),a.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>Z(),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),ae&&(()=>{var Re;const be=(Re=U.accounts)==null?void 0:Re.find(ze=>ze.num===ae.num);return be?a.jsx(RK,{a:be,accountMenu:ee,slots:(U.accounts??[]).map(ze=>ze.num),boundaryId:Mt(be.num),nowSec:Ge,busy:s,pressProps:c,rotating:!!(H!=null&&H.enabled||H!=null&&H.external),onProjects:()=>{q({num:be.num,name:be.alias??be.email??`account ${be.num}`}),pe(be.num)},onRotation:()=>me({action:"account",account:be.num,enabled:be.disabled},`rot-${be.num}`,"menu").then(ze=>{J(!0),ze!=null&&ze.ok&&pe(be.num)})}):null})(),g&&(()=>{var ze;const be=(ze=U.accounts)==null?void 0:ze.find(rn=>rn.num===g.num),Re=be?_i(be,Ge,gt(be)):null;return!be||!Re?null:a.jsx(QV,{anchorId:g.anchor,boundaryId:g.anchor==="ap-notice"?"ap-scroll":Mt(be.num),issue:Re,who:be.alias??be.email??`account ${be.num}`,fetchedAt:be.fetchedAt,nowSec:Ge,onClose:nn,onSignIn:()=>x(!0),onReport:n&&(()=>n({initialKind:Re.tone==="warn"?"bug":"other",initialBody:`Account issue: ${Re.text}. ${Re.hint}`}))})})()]}):a.jsx(wG,{data:U}),a.jsx("div",{className:"film-foot",children:a.jsx(rc,{film:"claudeAccounts"})})]}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:de?`Now active: ${de.name}`:""}),f&&a.jsx(cZ,{accounts:i_((U==null?void 0:U.accounts)??[]),onChanged:()=>J(!0),onNoCopy:Dt,view:d==="lan",onOpen:Cr,onBack:()=>h("accounts"),closeButton:Cs}),k&&a.jsx(NO,{onClose:()=>x(!1),onChanged:()=>J(!0)}),R&&a.jsx(mZ,{accounts:((U==null?void 0:U.accounts)??[]).map(be=>({num:be.num,email:be.email,alias:be.alias,org:be.org})),onClose:()=>I(!1),copyText:oo}),A!=null&&(()=>{var Re;const be=(Re=U==null?void 0:U.accounts)==null?void 0:Re.find(ze=>ze.num===A.num);return U!=null&&U.accounts&&!be?null:a.jsx(ZV,{num:A.num,name:be?be.alias??be.email??`account ${be.num}`:A.name,onClose:()=>q(null)})})(),N&&a.jsx(DG,{accounts:(U==null?void 0:U.accounts)??null,order:S,failed:V!=null&&V.reload?V.text:null,nowSec:Ge,onClose:()=>b(!1)})]})}const qZ=16,UZ=120;function zZ(e,t,n=0){return e.clientX>=t.left-n&&e.clientX<=t.right+n&&e.clientY>=t.top-n&&e.clientY<=t.bottom+n}function WZ(e,t){const n=Math.max(t.left-e.clientX,0,e.clientX-t.right),r=Math.max(t.top-e.clientY,0,e.clientY-t.bottom);return Math.hypot(n,r)}function HZ(e,t){return zZ(e,t,qZ)?"over":WZ(e,t)<=UZ?"near":"far"}function VZ(e){var n,r;if(typeof e.clientX=="number"&&typeof e.clientY=="number")return{clientX:e.clientX,clientY:e.clientY};const t=((n=e.changedTouches)==null?void 0:n[0])??((r=e.touches)==null?void 0:r[0]);return t?{clientX:t.clientX,clientY:t.clientY}:null}function GZ(){const[e,t]=y.useState(!1),[n,r]=y.useState(""),[s,o]=y.useState("far"),l=y.useRef(null),c=cd(e,140),d=y.useCallback(g=>{var k;const v=(k=l.current)==null?void 0:k.getBoundingClientRect(),j=VZ(g);return v&&j?HZ(j,v):"far"},[]),h=y.useCallback(g=>{g!==null&&(r(g),t(!0)),o("far")},[]),f=y.useCallback(g=>{o(d(g))},[d]),p=y.useCallback((g,v)=>{const j=v&&d(g)==="over";return t(!1),j},[d]);return{trashDragging:e,trashLabel:n,trashState:s,trashZoneRef:l,trashPhase:c,beginTrashDrag:h,trackTrashDrag:f,endTrashDrag:p}}const KZ=420;function YZ(){const[e,t]=y.useState(!1),n=y.useRef(null),r=y.useCallback(()=>{n.current&&(window.clearTimeout(n.current),n.current=null),t(!1)},[]),s=y.useCallback(o=>{o.length!==0&&queueMicrotask(()=>{t(!0),n.current&&window.clearTimeout(n.current),n.current=window.setTimeout(()=>t(!1),KZ+80)})},[]);return y.useEffect(()=>()=>{n.current&&window.clearTimeout(n.current)},[]),{bubbling:e,endBubble:r,onBubble:s}}const Gk=11,JO=7.2,QO=6.6,XZ={width:104,height:48},A_={width:96,height:44},eL={width:220,height:103};function ZZ(e){let t=1/0,n=1/0;for(const r of e)!(r.width>0)||!(r.height>0)||(t=Math.min(t,r.width),n=Math.min(n,r.height));return!Number.isFinite(t)||!Number.isFinite(n)?eL:{width:Math.max(160,t),height:Math.max(72,n)}}function sm(e,t,n){return e.width*t>=n.width&&e.height*t>=n.height}function JZ(e,t,n=eL){if(!Number.isFinite(t)||t<=0)return e??"detail";const r=Gk*t;return e==="detail"?r>=QO?"detail":sm(n,t,A_)?"compact":"overview":r>=JO?"detail":e==="compact"?sm(n,t,A_)?"compact":"overview":sm(n,t,XZ)?"compact":"overview"}const QZ=JO/Gk,eJ=QO/Gk;function tJ(e,t){return e>=QZ?e:Math.max(e,Math.min(t,eJ-.001))}const nJ=.8,rJ=1;function sJ({stateRef:e,measuredRef:t,measuredVersionRef:n,canvasRef:r}){const[s,o]=y.useState("detail"),l=y.useRef(null),c=y.useRef(null),d=y.useCallback(()=>{var v;const f=n.current;if(((v=c.current)==null?void 0:v.version)===f)return c.current.card;const p=[];for(const j of e.current.agents.keys()){const k=t.current.get(j);k&&p.push(k)}const g=ZZ(p);return c.current={version:f,card:g},g},[]),h=y.useCallback(f=>{var g;const p=JZ(l.current,f,d());return p===l.current?null:(l.current=p,(g=r.current)==null||g.setAttribute("data-lod",p),o(p),p)},[d,r]);return{lod:s,lodRef:l,applyZoom:h}}const aJ=40,oJ=120;function iJ(e,t){let n=null,r=0,s=Number.NEGATIVE_INFINITY;const o=()=>{n=null,s=t.now(),e()},l=()=>{n!=null&&(t.clearTimeout(n),n=null)},c=(d,h,f)=>{if(n!=null){if(r<=d)return;l()}const p=Math.min(f,Math.max(0,d-h));r=d,n=t.setTimeout(o,p)};return{live(d=aJ){const h=t.now(),f=Math.max(s+d,h);if(f<=h){l(),o();return}c(f,h,d)},replay(d=oJ){l(),r=t.now()+d,n=t.setTimeout(o,d)},flush(){l(),o()},cancel(){l()}}}const lJ=1024*1024,R_=5,tL=.8,_b=24,cJ="agent-dag.soundCustom.done",uJ="agent-dag.soundCustom.needs-input",Ul={done:cJ,"needs-input":uJ};function cc(e){if(e.kind!=="audio")return e;const{bytes:t,...n}=e;return n}function M_(e){return!e||!/^[a-zA-Z0-9._-]{1,96}$/.test(e)?null:e}function dJ(e){return{done:M_(e(Ul.done)),"needs-input":M_(e(Ul["needs-input"]))}}function hJ(e,t){return{done:e.done===t?null:e.done,"needs-input":e["needs-input"]===t?null:e["needs-input"]}}function fJ(e){return e.done&&e.done===e["needs-input"]?e.done:null}const pJ={wav:"audio/wav",wave:"audio/wav",mp3:"audio/mpeg",ogg:"audio/ogg",oga:"audio/ogg",webm:"audio/webm",m4a:"audio/mp4",mp4:"audio/mp4"},nL=new Set(["audio/wav","audio/x-wav","audio/mpeg","audio/mp3","audio/ogg","audio/webm","audio/mp4"]);function rL(e,t){const n=t.toLowerCase().split(";")[0].trim();if(nL.has(n))return n;const r=e.toLowerCase().split(".").pop()??"";return pJ[r]??n}function $_(e,t){const n=rL(e.name,e.type);if(!nL.has(n))return"Use a WAV, MP3, OGG, or browser-recorded audio file.";if(!Number.isFinite(e.size)||e.size<=0)return"The audio file is empty.";if(e.size>lJ)return"Audio must be 1 MB or smaller.";if(t!==void 0){if(!Number.isFinite(t)||t<=0)return"The audio file could not be decoded.";if(t>R_)return`Audio must be ${R_} seconds or shorter.`}return null}function Eb(e){return e>=_b?`There are already ${_b} custom sounds. Delete one first.`:null}function mJ(e,t){const n=e.indexOf(t);return n<0?null:e[n+1]??e[n-1]??null}function gJ(e){let t=0;for(const n of e)for(let r=0;r<n.length;r++)t=Math.max(t,Math.abs(n[r]));return t<=1e-5?1:Math.min(16,tL/t)}function sL(){try{if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch{}return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}async function yJ(e,t,n=sL()){var h;const r=((h=e.name)==null?void 0:h.trim())||"Custom sound",s=$_({name:r,type:e.type,size:e.size});if(s)throw new Error(s);const o=await e.arrayBuffer();let l;try{l=await t(o.slice(0))}catch{throw new Error("The audio file could not be decoded.")}const c=$_({name:r,type:e.type,size:e.size},l.duration);if(c)throw new Error(c);const d=Array.from({length:l.numberOfChannels},(f,p)=>l.getChannelData(p));return{id:n,name:r.replace(/\.(wav|wave|mp3|ogg|oga|webm|m4a|mp4)$/i,"")||"Custom sound",kind:"audio",mime:rL(r,e.type),duration:l.duration,normalizationGain:gJ(d),bytes:o}}function wJ(e,t=sL()){const n=e.name.trim()||"Custom voice",r=e.text.trim();if(!r)throw new Error("Enter the words this voice should say.");const s=Number.isFinite(e.rate)?e.rate:1,o=Number.isFinite(e.pitch)?e.pitch:1;return{id:t,name:n,kind:"tts",text:r.slice(0,180),voiceURI:e.voiceURI??"",rate:Math.min(2,Math.max(.5,s)),pitch:Math.min(2,Math.max(.5,o))}}const vJ="ccdeck-notification-audio",xJ=2,Nr="assets",Vr="summaries";function xc(){return typeof window<"u"?window.ccdeckNotificationAudio??null:null}function bJ(){return new Promise((e,t)=>{const n=indexedDB.open(vJ,xJ);n.onupgradeneeded=r=>{const s=n.result,o=s.objectStoreNames.contains(Nr)?n.transaction.objectStore(Nr):s.createObjectStore(Nr,{keyPath:"id"});if(s.objectStoreNames.contains(Vr))return;const l=s.createObjectStore(Vr,{keyPath:"id"});if(r.oldVersion<1)return;const c=o.openCursor();c.onsuccess=()=>{const d=c.result;d&&(l.put(cc(d.value)),d.continue())}},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error??new Error("Could not open local audio storage."))})}async function bc(e,t,n){const r=await bJ();try{return await new Promise((s,o)=>{const l=r.transaction(e,t),c=n(l),d=()=>o(l.error??new Error("Local audio storage failed."));l.oncomplete=()=>s(c?c.result:void 0),l.onerror=d,l.onabort=d})}finally{r.close()}}async function kJ(){const e=xc();return e?e.list():typeof indexedDB>"u"?[]:await bc([Vr],"readonly",t=>t.objectStore(Vr).getAll())??[]}async function NJ(e){const t=xc();return t?t.get(e):typeof indexedDB>"u"?null:await bc([Nr],"readonly",n=>n.objectStore(Nr).get(e))??null}async function I_(e){const t=xc();if(t){await t.put(e);return}if(typeof indexedDB>"u")throw new Error("Local audio storage is unavailable in this browser.");await bc([Nr,Vr],"readwrite",n=>{n.objectStore(Nr).put(e),n.objectStore(Vr).put(cc(e))})}async function jJ(e,t){const n=xc();if(n){const r=await n.get(e);r&&await n.put({...r,name:t});return}if(typeof indexedDB>"u")throw new Error("Local audio storage is unavailable in this browser.");await bc([Nr,Vr],"readwrite",r=>{const s=r.objectStore(Nr),o=s.get(e);o.onsuccess=()=>{const l=o.result;if(!l)return;const c={...l,name:t};s.put(c),r.objectStore(Vr).put(cc(c))}})}async function SJ(e){const t=xc();if(t){await t.remove(e);return}typeof indexedDB>"u"||await bc([Nr,Vr],"readwrite",n=>{n.objectStore(Nr).delete(e),n.objectStore(Vr).delete(e)})}const zl=["done","needs-input"],_J=[{id:"two",label:"Two notes",notes:[{at:0,hz:740,ms:90},{at:.085,hz:440,ms:150}]},{id:"arc",label:"Descent",notes:[{at:0,hz:988,ms:80},{at:.07,hz:659,ms:80},{at:.14,hz:440,ms:160}]},{id:"tap",label:"Double tap",notes:[{at:0,hz:740,ms:55},{at:.055,hz:740,ms:55},{at:.165,hz:440,ms:150}]},{id:"chord",label:"Chord",trim:.7,notes:[{at:0,hz:988,ms:110},{at:0,hz:740,ms:110},{at:.1,hz:440,ms:170}]},{id:"bell",label:"Bell",type:"triangle",notes:[{at:0,hz:740,ms:120},{at:.11,hz:440,ms:260}]},{id:"blip",label:"Blip",type:"square",trim:.7,notes:[{at:0,hz:740,ms:55},{at:.06,hz:440,ms:90}]}],EJ=[{id:"two",label:"Two notes",notes:[{at:0,hz:440,ms:90},{at:.085,hz:740,ms:150}]},{id:"arc",label:"Ascent",notes:[{at:0,hz:440,ms:80},{at:.07,hz:659,ms:80},{at:.14,hz:988,ms:160}]},{id:"tap",label:"Double tap",notes:[{at:0,hz:440,ms:55},{at:.055,hz:440,ms:55},{at:.165,hz:740,ms:150}]},{id:"chord",label:"Chord",trim:.7,notes:[{at:0,hz:440,ms:110},{at:.1,hz:740,ms:170},{at:.1,hz:988,ms:170}]},{id:"bell",label:"Bell",type:"triangle",notes:[{at:0,hz:440,ms:120},{at:.11,hz:740,ms:260}]},{id:"blip",label:"Blip",type:"square",trim:.7,notes:[{at:0,hz:440,ms:55},{at:.06,hz:740,ms:90}]}],Kk={done:_J,"needs-input":EJ},_n="two";function Cb(e,t){const n=Kk[e];return n.find(r=>r.id===t)??n.find(r=>r.id===_n)??n[0]}function aL(e,t){return Kk[e].some(r=>r.id===t)?t:_n}Cb("done",_n).notes,Cb("needs-input",_n).notes;const O_=.04,oL=.24,fd=0,Ud=100,Tb=5,ao=50;function Ei(e){if(!Number.isFinite(e))return ao;const t=Math.round(e/Tb)*Tb;return Math.min(Ud,Math.max(fd,t))}function iL(e){if(e==null)return ao;const t=e.trim();return/^-?\d+(\.\d+)?$/.test(t)?Ei(Number(t)):ao}function Yk(e){const t=Ei(e),n=O_+(oL-O_)*(t/Ud);return Math.round(n*1e4)/1e4}function CJ(e,t){const n=t.trim,r=typeof n=="number"&&Number.isFinite(n)&&n>0&&n<=1?n:1;return Math.round(Yk(e)*r*1e4)/1e4}const TJ=.012,L_=1e-4;function AJ(e){return Math.min(1,Yk(e)/oL)}function RJ(e,t){const n=e*(Yk(t)/tL);return Math.max(1e-4,n)}const MJ=160,$J="agent-dag.soundLevel.done",IJ="agent-dag.soundLevel.needs-input",OJ="agent-dag.soundFigure.done",LJ="agent-dag.soundFigure.needs-input",lL={done:$J,"needs-input":IJ},zd={done:OJ,"needs-input":LJ},Ab={done:{level:ao,figure:_n},"needs-input":{level:ao,figure:_n}};function PJ(e){const t=n=>({level:iL(e(lL[n])),figure:aL(n,e(zd[n]))});return{done:t("done"),"needs-input":t("needs-input")}}function DJ(e,t){return(e??Ab)[t]??Ab[t]}const FJ={Stop:"done",Notification:"needs-input"};function BJ(e,t){var r;if(t)return null;const n=(r=e==null?void 0:e.payload)==null?void 0:r.hook_event_name;return typeof n!="string"?null:Lt(FJ,n)??null}const qJ=6,UJ="ccdeck-tabs";function zJ(e){return e>=qJ}function WJ(e,t,n){const r=s=>{const o=s.data;(o==null?void 0:o.kind)==="who"&&o.from!==t&&e.postMessage({kind:"here",from:t,to:o.from,streaming:n()})};return e.addEventListener("message",r),{ask(s,o=(l,c)=>setTimeout(l,c)){return new Promise(l=>{const c=new Set,d=h=>{const f=h.data;(f==null?void 0:f.kind)==="here"&&f.to===t&&f.streaming&&c.add(f.from)};e.addEventListener("message",d),e.postMessage({kind:"who",from:t}),o(()=>{e.removeEventListener("message",d),l(c.size)},s)})},leave(){var s;e.removeEventListener("message",r),(s=e.close)==null||s.call(e)}}}function HJ({stateRef:e,rerender:t,pauseGate:n,chimesRef:r,desktopUpdateRef:s}){const[o,l]=y.useState(!1),[c,d]=y.useState(!1),[h,f]=y.useState(!1),p=y.useRef(!0),[g,v]=y.useState(null);return y.useEffect(()=>{const j=new EventSource("/events"),k=iJ(t,{now:()=>Date.now(),setTimeout:(S,E)=>window.setTimeout(S,E),clearTimeout:S=>window.clearTimeout(S)});let x=!1;const N=typeof BroadcastChannel=="function"?WJ(new BroadcastChannel(UJ),Math.random().toString(36).slice(2),()=>x):null,b=window.setInterval(()=>{x||!N||N.ask(600).then(S=>{x||d(zJ(S))})},3e3);return j.addEventListener("open",()=>{l(!0),f(!0)}),j.addEventListener("error",()=>{l(!1),v(null)}),j.addEventListener("open",()=>{x=!0,d(!1)}),j.addEventListener("error",()=>{x=!1}),j.addEventListener("replay-end",()=>{p.current=!1,k.flush(),v(Date.now())}),j.addEventListener("desktop-update",S=>s.current(S.data)),j.addEventListener("hook",S=>{var E;try{const R=JSON.parse(S.data);if(!n.accept(R))return;e.current=Z$(e.current,R);const I=R.replay===!0||p.current||Date.now()-R.receivedAt>3e4;I?k.replay():k.live();const A=BJ(R,I);A&&((E=r.current)==null||E.play(A))}catch{}}),()=>{j.close(),k.cancel(),window.clearInterval(b),N==null||N.leave()}},[t]),{live:o,tabCapped:c,everConnected:h,liveSince:g}}const VJ=200,GJ=5*6e4,KJ=6,YJ=2*6e4;function td(e,t){if(t.size!==0)for(const n of Array.from(e.keys()))t.has(n)||e.delete(n)}function XJ(e,t){let n=!1;for(const s of e)if(!t.has(s)){n=!0;break}if(!n)return e;const r=new Set;for(const s of e)t.has(s)&&r.add(s);return r}function ZJ(e){const t=new Set;for(const n of e)t.add(n.id),t.add(`group:${n.sessionId}`),n.kind==="root"&&t.add(kk(n.id));return t}function JJ(e){const t=new Set;for(const n of e)t.add(n.id),n.kind==="root"&&t.add(kk(n.id));return t}function QJ(e,t){let n=kU(e,t,Kj);NU(e,t,Kj)&&(n=!0);const r=[],s=o=>{r.push(o)};return vU(e,t,VJ,GJ,s)&&(n=!0),xU(e,t,KJ,YJ,s)&&(n=!0),{changed:n,forgotten:r}}function eQ(e,t,n){if(!n)return{ids:new Set([t]),primary:t};const r=new Set(e.ids);if(!r.has(t))return r.add(t),{ids:r,primary:t};if(r.delete(t),e.primary!==t)return{ids:r,primary:e.primary};let s=null;for(const o of r)s=o;return{ids:r,primary:s}}function tQ(e,t){const[n,r]=y.useState(()=>({ids:new Set,primary:null})),{ids:s,primary:o}=n,l=y.useCallback((h,f,p=!f)=>{r(g=>eQ(g,h,f)),!f&&p&&t(!0)},[]),c=y.useCallback(()=>{r({ids:new Set,primary:null})},[]),d=y.useCallback(()=>{r(h=>{const f=XJ(h.ids,e.current.agents),p=h.primary!=null&&!e.current.agents.has(h.primary)?null:h.primary;return f===h.ids&&p===h.primary?h:{ids:f,primary:p}})},[e]);return{selectedIds:s,primarySelectedId:o,selectAgent:l,clearSelection:c,pruneSelectionToBoard:d}}function nQ({stateRef:e,rerender:t,pruneSelectionToBoard:n,setContextFor:r,setSummaryFor:s}){const[o,l]=y.useState(Date.now());return y.useEffect(()=>{const c=setInterval(()=>{const d=Date.now();l(d);const{changed:h,forgotten:f}=QJ(e.current,d);f.length>0&&fetch("/api/forget",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({ids:f})}).catch(()=>{}),n(),r(p=>p!=null&&!e.current.agents.has(p)?null:p),s(p=>p!=null&&!e.current.agents.has(p)?null:p),h&&t()},250);return()=>clearInterval(c)},[t]),o}function Xk(e){throw new Error('Could not dynamically require "'+e+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var am,P_;function rQ(){if(P_)return am;P_=1;function e(){this.__data__=[],this.size=0}return am=e,am}var om,D_;function Oi(){if(D_)return om;D_=1;function e(t,n){return t===n||t!==t&&n!==n}return om=e,om}var im,F_;function Th(){if(F_)return im;F_=1;var e=Oi();function t(n,r){for(var s=n.length;s--;)if(e(n[s][0],r))return s;return-1}return im=t,im}var lm,B_;function sQ(){if(B_)return lm;B_=1;var e=Th(),t=Array.prototype,n=t.splice;function r(s){var o=this.__data__,l=e(o,s);if(l<0)return!1;var c=o.length-1;return l==c?o.pop():n.call(o,l,1),--this.size,!0}return lm=r,lm}var cm,q_;function aQ(){if(q_)return cm;q_=1;var e=Th();function t(n){var r=this.__data__,s=e(r,n);return s<0?void 0:r[s][1]}return cm=t,cm}var um,U_;function oQ(){if(U_)return um;U_=1;var e=Th();function t(n){return e(this.__data__,n)>-1}return um=t,um}var dm,z_;function iQ(){if(z_)return dm;z_=1;var e=Th();function t(n,r){var s=this.__data__,o=e(s,n);return o<0?(++this.size,s.push([n,r])):s[o][1]=r,this}return dm=t,dm}var hm,W_;function Ah(){if(W_)return hm;W_=1;var e=rQ(),t=sQ(),n=aQ(),r=oQ(),s=iQ();function o(l){var c=-1,d=l==null?0:l.length;for(this.clear();++c<d;){var h=l[c];this.set(h[0],h[1])}}return o.prototype.clear=e,o.prototype.delete=t,o.prototype.get=n,o.prototype.has=r,o.prototype.set=s,hm=o,hm}var fm,H_;function lQ(){if(H_)return fm;H_=1;var e=Ah();function t(){this.__data__=new e,this.size=0}return fm=t,fm}var pm,V_;function cQ(){if(V_)return pm;V_=1;function e(t){var n=this.__data__,r=n.delete(t);return this.size=n.size,r}return pm=e,pm}var mm,G_;function uQ(){if(G_)return mm;G_=1;function e(t){return this.__data__.get(t)}return mm=e,mm}var gm,K_;function dQ(){if(K_)return gm;K_=1;function e(t){return this.__data__.has(t)}return gm=e,gm}var ym,Y_;function cL(){if(Y_)return ym;Y_=1;var e=typeof Au=="object"&&Au&&Au.Object===Object&&Au;return ym=e,ym}var wm,X_;function _r(){if(X_)return wm;X_=1;var e=cL(),t=typeof self=="object"&&self&&self.Object===Object&&self,n=e||t||Function("return this")();return wm=n,wm}var vm,Z_;function Li(){if(Z_)return vm;Z_=1;var e=_r(),t=e.Symbol;return vm=t,vm}var xm,J_;function hQ(){if(J_)return xm;J_=1;var e=Li(),t=Object.prototype,n=t.hasOwnProperty,r=t.toString,s=e?e.toStringTag:void 0;function o(l){var c=n.call(l,s),d=l[s];try{l[s]=void 0;var h=!0}catch{}var f=r.call(l);return h&&(c?l[s]=d:delete l[s]),f}return xm=o,xm}var bm,Q_;function fQ(){if(Q_)return bm;Q_=1;var e=Object.prototype,t=e.toString;function n(r){return t.call(r)}return bm=n,bm}var km,eE;function io(){if(eE)return km;eE=1;var e=Li(),t=hQ(),n=fQ(),r="[object Null]",s="[object Undefined]",o=e?e.toStringTag:void 0;function l(c){return c==null?c===void 0?s:r:o&&o in Object(c)?t(c):n(c)}return km=l,km}var Nm,tE;function Xn(){if(tE)return Nm;tE=1;function e(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}return Nm=e,Nm}var jm,nE;function kc(){if(nE)return jm;nE=1;var e=io(),t=Xn(),n="[object AsyncFunction]",r="[object Function]",s="[object GeneratorFunction]",o="[object Proxy]";function l(c){if(!t(c))return!1;var d=e(c);return d==r||d==s||d==n||d==o}return jm=l,jm}var Sm,rE;function pQ(){if(rE)return Sm;rE=1;var e=_r(),t=e["__core-js_shared__"];return Sm=t,Sm}var _m,sE;function mQ(){if(sE)return _m;sE=1;var e=pQ(),t=(function(){var r=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return r?"Symbol(src)_1."+r:""})();function n(r){return!!t&&t in r}return _m=n,_m}var Em,aE;function uL(){if(aE)return Em;aE=1;var e=Function.prototype,t=e.toString;function n(r){if(r!=null){try{return t.call(r)}catch{}try{return r+""}catch{}}return""}return Em=n,Em}var Cm,oE;function gQ(){if(oE)return Cm;oE=1;var e=kc(),t=mQ(),n=Xn(),r=uL(),s=/[\\^$.*+?()[\]{}|]/g,o=/^\[object .+?Constructor\]$/,l=Function.prototype,c=Object.prototype,d=l.toString,h=c.hasOwnProperty,f=RegExp("^"+d.call(h).replace(s,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function p(g){if(!n(g)||t(g))return!1;var v=e(g)?f:o;return v.test(r(g))}return Cm=p,Cm}var Tm,iE;function yQ(){if(iE)return Tm;iE=1;function e(t,n){return t==null?void 0:t[n]}return Tm=e,Tm}var Am,lE;function lo(){if(lE)return Am;lE=1;var e=gQ(),t=yQ();function n(r,s){var o=t(r,s);return e(o)?o:void 0}return Am=n,Am}var Rm,cE;function Zk(){if(cE)return Rm;cE=1;var e=lo(),t=_r(),n=e(t,"Map");return Rm=n,Rm}var Mm,uE;function Rh(){if(uE)return Mm;uE=1;var e=lo(),t=e(Object,"create");return Mm=t,Mm}var $m,dE;function wQ(){if(dE)return $m;dE=1;var e=Rh();function t(){this.__data__=e?e(null):{},this.size=0}return $m=t,$m}var Im,hE;function vQ(){if(hE)return Im;hE=1;function e(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n}return Im=e,Im}var Om,fE;function xQ(){if(fE)return Om;fE=1;var e=Rh(),t="__lodash_hash_undefined__",n=Object.prototype,r=n.hasOwnProperty;function s(o){var l=this.__data__;if(e){var c=l[o];return c===t?void 0:c}return r.call(l,o)?l[o]:void 0}return Om=s,Om}var Lm,pE;function bQ(){if(pE)return Lm;pE=1;var e=Rh(),t=Object.prototype,n=t.hasOwnProperty;function r(s){var o=this.__data__;return e?o[s]!==void 0:n.call(o,s)}return Lm=r,Lm}var Pm,mE;function kQ(){if(mE)return Pm;mE=1;var e=Rh(),t="__lodash_hash_undefined__";function n(r,s){var o=this.__data__;return this.size+=this.has(r)?0:1,o[r]=e&&s===void 0?t:s,this}return Pm=n,Pm}var Dm,gE;function NQ(){if(gE)return Dm;gE=1;var e=wQ(),t=vQ(),n=xQ(),r=bQ(),s=kQ();function o(l){var c=-1,d=l==null?0:l.length;for(this.clear();++c<d;){var h=l[c];this.set(h[0],h[1])}}return o.prototype.clear=e,o.prototype.delete=t,o.prototype.get=n,o.prototype.has=r,o.prototype.set=s,Dm=o,Dm}var Fm,yE;function jQ(){if(yE)return Fm;yE=1;var e=NQ(),t=Ah(),n=Zk();function r(){this.size=0,this.__data__={hash:new e,map:new(n||t),string:new e}}return Fm=r,Fm}var Bm,wE;function SQ(){if(wE)return Bm;wE=1;function e(t){var n=typeof t;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?t!=="__proto__":t===null}return Bm=e,Bm}var qm,vE;function Mh(){if(vE)return qm;vE=1;var e=SQ();function t(n,r){var s=n.__data__;return e(r)?s[typeof r=="string"?"string":"hash"]:s.map}return qm=t,qm}var Um,xE;function _Q(){if(xE)return Um;xE=1;var e=Mh();function t(n){var r=e(this,n).delete(n);return this.size-=r?1:0,r}return Um=t,Um}var zm,bE;function EQ(){if(bE)return zm;bE=1;var e=Mh();function t(n){return e(this,n).get(n)}return zm=t,zm}var Wm,kE;function CQ(){if(kE)return Wm;kE=1;var e=Mh();function t(n){return e(this,n).has(n)}return Wm=t,Wm}var Hm,NE;function TQ(){if(NE)return Hm;NE=1;var e=Mh();function t(n,r){var s=e(this,n),o=s.size;return s.set(n,r),this.size+=s.size==o?0:1,this}return Hm=t,Hm}var Vm,jE;function Jk(){if(jE)return Vm;jE=1;var e=jQ(),t=_Q(),n=EQ(),r=CQ(),s=TQ();function o(l){var c=-1,d=l==null?0:l.length;for(this.clear();++c<d;){var h=l[c];this.set(h[0],h[1])}}return o.prototype.clear=e,o.prototype.delete=t,o.prototype.get=n,o.prototype.has=r,o.prototype.set=s,Vm=o,Vm}var Gm,SE;function AQ(){if(SE)return Gm;SE=1;var e=Ah(),t=Zk(),n=Jk(),r=200;function s(o,l){var c=this.__data__;if(c instanceof e){var d=c.__data__;if(!t||d.length<r-1)return d.push([o,l]),this.size=++c.size,this;c=this.__data__=new n(d)}return c.set(o,l),this.size=c.size,this}return Gm=s,Gm}var Km,_E;function $h(){if(_E)return Km;_E=1;var e=Ah(),t=lQ(),n=cQ(),r=uQ(),s=dQ(),o=AQ();function l(c){var d=this.__data__=new e(c);this.size=d.size}return l.prototype.clear=t,l.prototype.delete=n,l.prototype.get=r,l.prototype.has=s,l.prototype.set=o,Km=l,Km}var Ym,EE;function Qk(){if(EE)return Ym;EE=1;function e(t,n){for(var r=-1,s=t==null?0:t.length;++r<s&&n(t[r],r,t)!==!1;);return t}return Ym=e,Ym}var Xm,CE;function dL(){if(CE)return Xm;CE=1;var e=lo(),t=(function(){try{var n=e(Object,"defineProperty");return n({},"",{}),n}catch{}})();return Xm=t,Xm}var Zm,TE;function Ih(){if(TE)return Zm;TE=1;var e=dL();function t(n,r,s){r=="__proto__"&&e?e(n,r,{configurable:!0,enumerable:!0,value:s,writable:!0}):n[r]=s}return Zm=t,Zm}var Jm,AE;function Oh(){if(AE)return Jm;AE=1;var e=Ih(),t=Oi(),n=Object.prototype,r=n.hasOwnProperty;function s(o,l,c){var d=o[l];(!(r.call(o,l)&&t(d,c))||c===void 0&&!(l in o))&&e(o,l,c)}return Jm=s,Jm}var Qm,RE;function Nc(){if(RE)return Qm;RE=1;var e=Oh(),t=Ih();function n(r,s,o,l){var c=!o;o||(o={});for(var d=-1,h=s.length;++d<h;){var f=s[d],p=l?l(o[f],r[f],f,o,r):void 0;p===void 0&&(p=r[f]),c?t(o,f,p):e(o,f,p)}return o}return Qm=n,Qm}var eg,ME;function RQ(){if(ME)return eg;ME=1;function e(t,n){for(var r=-1,s=Array(t);++r<t;)s[r]=n(r);return s}return eg=e,eg}var tg,$E;function Kr(){if($E)return tg;$E=1;function e(t){return t!=null&&typeof t=="object"}return tg=e,tg}var ng,IE;function MQ(){if(IE)return ng;IE=1;var e=io(),t=Kr(),n="[object Arguments]";function r(s){return t(s)&&e(s)==n}return ng=r,ng}var rg,OE;function jc(){if(OE)return rg;OE=1;var e=MQ(),t=Kr(),n=Object.prototype,r=n.hasOwnProperty,s=n.propertyIsEnumerable,o=e((function(){return arguments})())?e:function(l){return t(l)&&r.call(l,"callee")&&!s.call(l,"callee")};return rg=o,rg}var sg,LE;function kt(){if(LE)return sg;LE=1;var e=Array.isArray;return sg=e,sg}var $l={exports:{}},ag,PE;function $Q(){if(PE)return ag;PE=1;function e(){return!1}return ag=e,ag}$l.exports;var DE;function Pi(){return DE||(DE=1,(function(e,t){var n=_r(),r=$Q(),s=t&&!t.nodeType&&t,o=s&&!0&&e&&!e.nodeType&&e,l=o&&o.exports===s,c=l?n.Buffer:void 0,d=c?c.isBuffer:void 0,h=d||r;e.exports=h})($l,$l.exports)),$l.exports}var og,FE;function Lh(){if(FE)return og;FE=1;var e=9007199254740991,t=/^(?:0|[1-9]\d*)$/;function n(r,s){var o=typeof r;return s=s??e,!!s&&(o=="number"||o!="symbol"&&t.test(r))&&r>-1&&r%1==0&&r<s}return og=n,og}var ig,BE;function e0(){if(BE)return ig;BE=1;var e=9007199254740991;function t(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=e}return ig=t,ig}var lg,qE;function IQ(){if(qE)return lg;qE=1;var e=io(),t=e0(),n=Kr(),r="[object Arguments]",s="[object Array]",o="[object Boolean]",l="[object Date]",c="[object Error]",d="[object Function]",h="[object Map]",f="[object Number]",p="[object Object]",g="[object RegExp]",v="[object Set]",j="[object String]",k="[object WeakMap]",x="[object ArrayBuffer]",N="[object DataView]",b="[object Float32Array]",S="[object Float64Array]",E="[object Int8Array]",R="[object Int16Array]",I="[object Int32Array]",A="[object Uint8Array]",q="[object Uint8ClampedArray]",$="[object Uint16Array]",B="[object Uint32Array]",L={};L[b]=L[S]=L[E]=L[R]=L[I]=L[A]=L[q]=L[$]=L[B]=!0,L[r]=L[s]=L[x]=L[o]=L[N]=L[l]=L[c]=L[d]=L[h]=L[f]=L[p]=L[g]=L[v]=L[j]=L[k]=!1;function M(F){return n(F)&&t(F.length)&&!!L[e(F)]}return lg=M,lg}var cg,UE;function Ph(){if(UE)return cg;UE=1;function e(t){return function(n){return t(n)}}return cg=e,cg}var Il={exports:{}};Il.exports;var zE;function t0(){return zE||(zE=1,(function(e,t){var n=cL(),r=t&&!t.nodeType&&t,s=r&&!0&&e&&!e.nodeType&&e,o=s&&s.exports===r,l=o&&n.process,c=(function(){try{var d=s&&s.require&&s.require("util").types;return d||l&&l.binding&&l.binding("util")}catch{}})();e.exports=c})(Il,Il.exports)),Il.exports}var ug,WE;function Sc(){if(WE)return ug;WE=1;var e=IQ(),t=Ph(),n=t0(),r=n&&n.isTypedArray,s=r?t(r):e;return ug=s,ug}var dg,HE;function hL(){if(HE)return dg;HE=1;var e=RQ(),t=jc(),n=kt(),r=Pi(),s=Lh(),o=Sc(),l=Object.prototype,c=l.hasOwnProperty;function d(h,f){var p=n(h),g=!p&&t(h),v=!p&&!g&&r(h),j=!p&&!g&&!v&&o(h),k=p||g||v||j,x=k?e(h.length,String):[],N=x.length;for(var b in h)(f||c.call(h,b))&&!(k&&(b=="length"||v&&(b=="offset"||b=="parent")||j&&(b=="buffer"||b=="byteLength"||b=="byteOffset")||s(b,N)))&&x.push(b);return x}return dg=d,dg}var hg,VE;function Dh(){if(VE)return hg;VE=1;var e=Object.prototype;function t(n){var r=n&&n.constructor,s=typeof r=="function"&&r.prototype||e;return n===s}return hg=t,hg}var fg,GE;function fL(){if(GE)return fg;GE=1;function e(t,n){return function(r){return t(n(r))}}return fg=e,fg}var pg,KE;function OQ(){if(KE)return pg;KE=1;var e=fL(),t=e(Object.keys,Object);return pg=t,pg}var mg,YE;function n0(){if(YE)return mg;YE=1;var e=Dh(),t=OQ(),n=Object.prototype,r=n.hasOwnProperty;function s(o){if(!e(o))return t(o);var l=[];for(var c in Object(o))r.call(o,c)&&c!="constructor"&&l.push(c);return l}return mg=s,mg}var gg,XE;function js(){if(XE)return gg;XE=1;var e=kc(),t=e0();function n(r){return r!=null&&t(r.length)&&!e(r)}return gg=n,gg}var yg,ZE;function ca(){if(ZE)return yg;ZE=1;var e=hL(),t=n0(),n=js();function r(s){return n(s)?e(s):t(s)}return yg=r,yg}var wg,JE;function LQ(){if(JE)return wg;JE=1;var e=Nc(),t=ca();function n(r,s){return r&&e(s,t(s),r)}return wg=n,wg}var vg,QE;function PQ(){if(QE)return vg;QE=1;function e(t){var n=[];if(t!=null)for(var r in Object(t))n.push(r);return n}return vg=e,vg}var xg,eC;function DQ(){if(eC)return xg;eC=1;var e=Xn(),t=Dh(),n=PQ(),r=Object.prototype,s=r.hasOwnProperty;function o(l){if(!e(l))return n(l);var c=t(l),d=[];for(var h in l)h=="constructor"&&(c||!s.call(l,h))||d.push(h);return d}return xg=o,xg}var bg,tC;function co(){if(tC)return bg;tC=1;var e=hL(),t=DQ(),n=js();function r(s){return n(s)?e(s,!0):t(s)}return bg=r,bg}var kg,nC;function FQ(){if(nC)return kg;nC=1;var e=Nc(),t=co();function n(r,s){return r&&e(s,t(s),r)}return kg=n,kg}var Ol={exports:{}};Ol.exports;var rC;function pL(){return rC||(rC=1,(function(e,t){var n=_r(),r=t&&!t.nodeType&&t,s=r&&!0&&e&&!e.nodeType&&e,o=s&&s.exports===r,l=o?n.Buffer:void 0,c=l?l.allocUnsafe:void 0;function d(h,f){if(f)return h.slice();var p=h.length,g=c?c(p):new h.constructor(p);return h.copy(g),g}e.exports=d})(Ol,Ol.exports)),Ol.exports}var Ng,sC;function mL(){if(sC)return Ng;sC=1;function e(t,n){var r=-1,s=t.length;for(n||(n=Array(s));++r<s;)n[r]=t[r];return n}return Ng=e,Ng}var jg,aC;function gL(){if(aC)return jg;aC=1;function e(t,n){for(var r=-1,s=t==null?0:t.length,o=0,l=[];++r<s;){var c=t[r];n(c,r,t)&&(l[o++]=c)}return l}return jg=e,jg}var Sg,oC;function yL(){if(oC)return Sg;oC=1;function e(){return[]}return Sg=e,Sg}var _g,iC;function r0(){if(iC)return _g;iC=1;var e=gL(),t=yL(),n=Object.prototype,r=n.propertyIsEnumerable,s=Object.getOwnPropertySymbols,o=s?function(l){return l==null?[]:(l=Object(l),e(s(l),function(c){return r.call(l,c)}))}:t;return _g=o,_g}var Eg,lC;function BQ(){if(lC)return Eg;lC=1;var e=Nc(),t=r0();function n(r,s){return e(r,t(r),s)}return Eg=n,Eg}var Cg,cC;function s0(){if(cC)return Cg;cC=1;function e(t,n){for(var r=-1,s=n.length,o=t.length;++r<s;)t[o+r]=n[r];return t}return Cg=e,Cg}var Tg,uC;function Fh(){if(uC)return Tg;uC=1;var e=fL(),t=e(Object.getPrototypeOf,Object);return Tg=t,Tg}var Ag,dC;function wL(){if(dC)return Ag;dC=1;var e=s0(),t=Fh(),n=r0(),r=yL(),s=Object.getOwnPropertySymbols,o=s?function(l){for(var c=[];l;)e(c,n(l)),l=t(l);return c}:r;return Ag=o,Ag}var Rg,hC;function qQ(){if(hC)return Rg;hC=1;var e=Nc(),t=wL();function n(r,s){return e(r,t(r),s)}return Rg=n,Rg}var Mg,fC;function vL(){if(fC)return Mg;fC=1;var e=s0(),t=kt();function n(r,s,o){var l=s(r);return t(r)?l:e(l,o(r))}return Mg=n,Mg}var $g,pC;function xL(){if(pC)return $g;pC=1;var e=vL(),t=r0(),n=ca();function r(s){return e(s,n,t)}return $g=r,$g}var Ig,mC;function UQ(){if(mC)return Ig;mC=1;var e=vL(),t=wL(),n=co();function r(s){return e(s,n,t)}return Ig=r,Ig}var Og,gC;function zQ(){if(gC)return Og;gC=1;var e=lo(),t=_r(),n=e(t,"DataView");return Og=n,Og}var Lg,yC;function WQ(){if(yC)return Lg;yC=1;var e=lo(),t=_r(),n=e(t,"Promise");return Lg=n,Lg}var Pg,wC;function bL(){if(wC)return Pg;wC=1;var e=lo(),t=_r(),n=e(t,"Set");return Pg=n,Pg}var Dg,vC;function HQ(){if(vC)return Dg;vC=1;var e=lo(),t=_r(),n=e(t,"WeakMap");return Dg=n,Dg}var Fg,xC;function Di(){if(xC)return Fg;xC=1;var e=zQ(),t=Zk(),n=WQ(),r=bL(),s=HQ(),o=io(),l=uL(),c="[object Map]",d="[object Object]",h="[object Promise]",f="[object Set]",p="[object WeakMap]",g="[object DataView]",v=l(e),j=l(t),k=l(n),x=l(r),N=l(s),b=o;return(e&&b(new e(new ArrayBuffer(1)))!=g||t&&b(new t)!=c||n&&b(n.resolve())!=h||r&&b(new r)!=f||s&&b(new s)!=p)&&(b=function(S){var E=o(S),R=E==d?S.constructor:void 0,I=R?l(R):"";if(I)switch(I){case v:return g;case j:return c;case k:return h;case x:return f;case N:return p}return E}),Fg=b,Fg}var Bg,bC;function VQ(){if(bC)return Bg;bC=1;var e=Object.prototype,t=e.hasOwnProperty;function n(r){var s=r.length,o=new r.constructor(s);return s&&typeof r[0]=="string"&&t.call(r,"index")&&(o.index=r.index,o.input=r.input),o}return Bg=n,Bg}var qg,kC;function kL(){if(kC)return qg;kC=1;var e=_r(),t=e.Uint8Array;return qg=t,qg}var Ug,NC;function a0(){if(NC)return Ug;NC=1;var e=kL();function t(n){var r=new n.constructor(n.byteLength);return new e(r).set(new e(n)),r}return Ug=t,Ug}var zg,jC;function GQ(){if(jC)return zg;jC=1;var e=a0();function t(n,r){var s=r?e(n.buffer):n.buffer;return new n.constructor(s,n.byteOffset,n.byteLength)}return zg=t,zg}var Wg,SC;function KQ(){if(SC)return Wg;SC=1;var e=/\w*$/;function t(n){var r=new n.constructor(n.source,e.exec(n));return r.lastIndex=n.lastIndex,r}return Wg=t,Wg}var Hg,_C;function YQ(){if(_C)return Hg;_C=1;var e=Li(),t=e?e.prototype:void 0,n=t?t.valueOf:void 0;function r(s){return n?Object(n.call(s)):{}}return Hg=r,Hg}var Vg,EC;function NL(){if(EC)return Vg;EC=1;var e=a0();function t(n,r){var s=r?e(n.buffer):n.buffer;return new n.constructor(s,n.byteOffset,n.length)}return Vg=t,Vg}var Gg,CC;function XQ(){if(CC)return Gg;CC=1;var e=a0(),t=GQ(),n=KQ(),r=YQ(),s=NL(),o="[object Boolean]",l="[object Date]",c="[object Map]",d="[object Number]",h="[object RegExp]",f="[object Set]",p="[object String]",g="[object Symbol]",v="[object ArrayBuffer]",j="[object DataView]",k="[object Float32Array]",x="[object Float64Array]",N="[object Int8Array]",b="[object Int16Array]",S="[object Int32Array]",E="[object Uint8Array]",R="[object Uint8ClampedArray]",I="[object Uint16Array]",A="[object Uint32Array]";function q($,B,L){var M=$.constructor;switch(B){case v:return e($);case o:case l:return new M(+$);case j:return t($,L);case k:case x:case N:case b:case S:case E:case R:case I:case A:return s($,L);case c:return new M;case d:case p:return new M($);case h:return n($);case f:return new M;case g:return r($)}}return Gg=q,Gg}var Kg,TC;function jL(){if(TC)return Kg;TC=1;var e=Xn(),t=Object.create,n=(function(){function r(){}return function(s){if(!e(s))return{};if(t)return t(s);r.prototype=s;var o=new r;return r.prototype=void 0,o}})();return Kg=n,Kg}var Yg,AC;function SL(){if(AC)return Yg;AC=1;var e=jL(),t=Fh(),n=Dh();function r(s){return typeof s.constructor=="function"&&!n(s)?e(t(s)):{}}return Yg=r,Yg}var Xg,RC;function ZQ(){if(RC)return Xg;RC=1;var e=Di(),t=Kr(),n="[object Map]";function r(s){return t(s)&&e(s)==n}return Xg=r,Xg}var Zg,MC;function JQ(){if(MC)return Zg;MC=1;var e=ZQ(),t=Ph(),n=t0(),r=n&&n.isMap,s=r?t(r):e;return Zg=s,Zg}var Jg,$C;function QQ(){if($C)return Jg;$C=1;var e=Di(),t=Kr(),n="[object Set]";function r(s){return t(s)&&e(s)==n}return Jg=r,Jg}var Qg,IC;function eee(){if(IC)return Qg;IC=1;var e=QQ(),t=Ph(),n=t0(),r=n&&n.isSet,s=r?t(r):e;return Qg=s,Qg}var ey,OC;function _L(){if(OC)return ey;OC=1;var e=$h(),t=Qk(),n=Oh(),r=LQ(),s=FQ(),o=pL(),l=mL(),c=BQ(),d=qQ(),h=xL(),f=UQ(),p=Di(),g=VQ(),v=XQ(),j=SL(),k=kt(),x=Pi(),N=JQ(),b=Xn(),S=eee(),E=ca(),R=co(),I=1,A=2,q=4,$="[object Arguments]",B="[object Array]",L="[object Boolean]",M="[object Date]",F="[object Error]",T="[object Function]",P="[object GeneratorFunction]",O="[object Map]",G="[object Number]",K="[object Object]",U="[object RegExp]",H="[object Set]",D="[object String]",V="[object Symbol]",J="[object WeakMap]",W="[object ArrayBuffer]",Z="[object DataView]",Y="[object Float32Array]",X="[object Float64Array]",ee="[object Int8Array]",ae="[object Int16Array]",ce="[object Int32Array]",ge="[object Uint8Array]",ye="[object Uint8ClampedArray]",se="[object Uint16Array]",pe="[object Uint32Array]",fe={};fe[$]=fe[B]=fe[W]=fe[Z]=fe[L]=fe[M]=fe[Y]=fe[X]=fe[ee]=fe[ae]=fe[ce]=fe[O]=fe[G]=fe[K]=fe[U]=fe[H]=fe[D]=fe[V]=fe[ge]=fe[ye]=fe[se]=fe[pe]=!0,fe[F]=fe[T]=fe[J]=!1;function de(me,ne,oe,Ne,we,Me){var Le,Be=ne&I,Pe=ne&A,Qe=ne&q;if(oe&&(Le=we?oe(me,Ne,we,Me):oe(me)),Le!==void 0)return Le;if(!b(me))return me;var qe=k(me);if(qe){if(Le=g(me),!Be)return l(me,Le)}else{var Ze=p(me),lt=Ze==T||Ze==P;if(x(me))return o(me,Be);if(Ze==K||Ze==$||lt&&!we){if(Le=Pe||lt?{}:j(me),!Be)return Pe?d(me,s(Le,me)):c(me,r(Le,me))}else{if(!fe[Ze])return we?me:{};Le=v(me,Ze,Be)}}Me||(Me=new e);var Nt=Me.get(me);if(Nt)return Nt;Me.set(me,Le),S(me)?me.forEach(function(Ge){Le.add(de(Ge,ne,oe,Ge,me,Me))}):N(me)&&me.forEach(function(Ge,ct){Le.set(ct,de(Ge,ne,oe,ct,me,Me))});var Xe=Qe?Pe?f:h:Pe?R:E,tt=qe?void 0:Xe(me);return t(tt||me,function(Ge,ct){tt&&(ct=Ge,Ge=me[ct]),n(Le,ct,de(Ge,ne,oe,ct,me,Me))}),Le}return ey=de,ey}var ty,LC;function tee(){if(LC)return ty;LC=1;var e=_L(),t=4;function n(r){return e(r,t)}return ty=n,ty}var ny,PC;function o0(){if(PC)return ny;PC=1;function e(t){return function(){return t}}return ny=e,ny}var ry,DC;function nee(){if(DC)return ry;DC=1;function e(t){return function(n,r,s){for(var o=-1,l=Object(n),c=s(n),d=c.length;d--;){var h=c[t?d:++o];if(r(l[h],h,l)===!1)break}return n}}return ry=e,ry}var sy,FC;function i0(){if(FC)return sy;FC=1;var e=nee(),t=e();return sy=t,sy}var ay,BC;function l0(){if(BC)return ay;BC=1;var e=i0(),t=ca();function n(r,s){return r&&e(r,s,t)}return ay=n,ay}var oy,qC;function ree(){if(qC)return oy;qC=1;var e=js();function t(n,r){return function(s,o){if(s==null)return s;if(!e(s))return n(s,o);for(var l=s.length,c=r?l:-1,d=Object(s);(r?c--:++c<l)&&o(d[c],c,d)!==!1;);return s}}return oy=t,oy}var iy,UC;function Bh(){if(UC)return iy;UC=1;var e=l0(),t=ree(),n=t(e);return iy=n,iy}var ly,zC;function uo(){if(zC)return ly;zC=1;function e(t){return t}return ly=e,ly}var cy,WC;function EL(){if(WC)return cy;WC=1;var e=uo();function t(n){return typeof n=="function"?n:e}return cy=t,cy}var uy,HC;function CL(){if(HC)return uy;HC=1;var e=Qk(),t=Bh(),n=EL(),r=kt();function s(o,l){var c=r(o)?e:t;return c(o,n(l))}return uy=s,uy}var dy,VC;function TL(){return VC||(VC=1,dy=CL()),dy}var hy,GC;function see(){if(GC)return hy;GC=1;var e=Bh();function t(n,r){var s=[];return e(n,function(o,l,c){r(o,l,c)&&s.push(o)}),s}return hy=t,hy}var fy,KC;function aee(){if(KC)return fy;KC=1;var e="__lodash_hash_undefined__";function t(n){return this.__data__.set(n,e),this}return fy=t,fy}var py,YC;function oee(){if(YC)return py;YC=1;function e(t){return this.__data__.has(t)}return py=e,py}var my,XC;function AL(){if(XC)return my;XC=1;var e=Jk(),t=aee(),n=oee();function r(s){var o=-1,l=s==null?0:s.length;for(this.__data__=new e;++o<l;)this.add(s[o])}return r.prototype.add=r.prototype.push=t,r.prototype.has=n,my=r,my}var gy,ZC;function iee(){if(ZC)return gy;ZC=1;function e(t,n){for(var r=-1,s=t==null?0:t.length;++r<s;)if(n(t[r],r,t))return!0;return!1}return gy=e,gy}var yy,JC;function RL(){if(JC)return yy;JC=1;function e(t,n){return t.has(n)}return yy=e,yy}var wy,QC;function ML(){if(QC)return wy;QC=1;var e=AL(),t=iee(),n=RL(),r=1,s=2;function o(l,c,d,h,f,p){var g=d&r,v=l.length,j=c.length;if(v!=j&&!(g&&j>v))return!1;var k=p.get(l),x=p.get(c);if(k&&x)return k==c&&x==l;var N=-1,b=!0,S=d&s?new e:void 0;for(p.set(l,c),p.set(c,l);++N<v;){var E=l[N],R=c[N];if(h)var I=g?h(R,E,N,c,l,p):h(E,R,N,l,c,p);if(I!==void 0){if(I)continue;b=!1;break}if(S){if(!t(c,function(A,q){if(!n(S,q)&&(E===A||f(E,A,d,h,p)))return S.push(q)})){b=!1;break}}else if(!(E===R||f(E,R,d,h,p))){b=!1;break}}return p.delete(l),p.delete(c),b}return wy=o,wy}var vy,eT;function lee(){if(eT)return vy;eT=1;function e(t){var n=-1,r=Array(t.size);return t.forEach(function(s,o){r[++n]=[o,s]}),r}return vy=e,vy}var xy,tT;function c0(){if(tT)return xy;tT=1;function e(t){var n=-1,r=Array(t.size);return t.forEach(function(s){r[++n]=s}),r}return xy=e,xy}var by,nT;function cee(){if(nT)return by;nT=1;var e=Li(),t=kL(),n=Oi(),r=ML(),s=lee(),o=c0(),l=1,c=2,d="[object Boolean]",h="[object Date]",f="[object Error]",p="[object Map]",g="[object Number]",v="[object RegExp]",j="[object Set]",k="[object String]",x="[object Symbol]",N="[object ArrayBuffer]",b="[object DataView]",S=e?e.prototype:void 0,E=S?S.valueOf:void 0;function R(I,A,q,$,B,L,M){switch(q){case b:if(I.byteLength!=A.byteLength||I.byteOffset!=A.byteOffset)return!1;I=I.buffer,A=A.buffer;case N:return!(I.byteLength!=A.byteLength||!L(new t(I),new t(A)));case d:case h:case g:return n(+I,+A);case f:return I.name==A.name&&I.message==A.message;case v:case k:return I==A+"";case p:var F=s;case j:var T=$&l;if(F||(F=o),I.size!=A.size&&!T)return!1;var P=M.get(I);if(P)return P==A;$|=c,M.set(I,A);var O=r(F(I),F(A),$,B,L,M);return M.delete(I),O;case x:if(E)return E.call(I)==E.call(A)}return!1}return by=R,by}var ky,rT;function uee(){if(rT)return ky;rT=1;var e=xL(),t=1,n=Object.prototype,r=n.hasOwnProperty;function s(o,l,c,d,h,f){var p=c&t,g=e(o),v=g.length,j=e(l),k=j.length;if(v!=k&&!p)return!1;for(var x=v;x--;){var N=g[x];if(!(p?N in l:r.call(l,N)))return!1}var b=f.get(o),S=f.get(l);if(b&&S)return b==l&&S==o;var E=!0;f.set(o,l),f.set(l,o);for(var R=p;++x<v;){N=g[x];var I=o[N],A=l[N];if(d)var q=p?d(A,I,N,l,o,f):d(I,A,N,o,l,f);if(!(q===void 0?I===A||h(I,A,c,d,f):q)){E=!1;break}R||(R=N=="constructor")}if(E&&!R){var $=o.constructor,B=l.constructor;$!=B&&"constructor"in o&&"constructor"in l&&!(typeof $=="function"&&$ instanceof $&&typeof B=="function"&&B instanceof B)&&(E=!1)}return f.delete(o),f.delete(l),E}return ky=s,ky}var Ny,sT;function dee(){if(sT)return Ny;sT=1;var e=$h(),t=ML(),n=cee(),r=uee(),s=Di(),o=kt(),l=Pi(),c=Sc(),d=1,h="[object Arguments]",f="[object Array]",p="[object Object]",g=Object.prototype,v=g.hasOwnProperty;function j(k,x,N,b,S,E){var R=o(k),I=o(x),A=R?f:s(k),q=I?f:s(x);A=A==h?p:A,q=q==h?p:q;var $=A==p,B=q==p,L=A==q;if(L&&l(k)){if(!l(x))return!1;R=!0,$=!1}if(L&&!$)return E||(E=new e),R||c(k)?t(k,x,N,b,S,E):n(k,x,A,N,b,S,E);if(!(N&d)){var M=$&&v.call(k,"__wrapped__"),F=B&&v.call(x,"__wrapped__");if(M||F){var T=M?k.value():k,P=F?x.value():x;return E||(E=new e),S(T,P,N,b,E)}}return L?(E||(E=new e),r(k,x,N,b,S,E)):!1}return Ny=j,Ny}var jy,aT;function $L(){if(aT)return jy;aT=1;var e=dee(),t=Kr();function n(r,s,o,l,c){return r===s?!0:r==null||s==null||!t(r)&&!t(s)?r!==r&&s!==s:e(r,s,o,l,n,c)}return jy=n,jy}var Sy,oT;function hee(){if(oT)return Sy;oT=1;var e=$h(),t=$L(),n=1,r=2;function s(o,l,c,d){var h=c.length,f=h,p=!d;if(o==null)return!f;for(o=Object(o);h--;){var g=c[h];if(p&&g[2]?g[1]!==o[g[0]]:!(g[0]in o))return!1}for(;++h<f;){g=c[h];var v=g[0],j=o[v],k=g[1];if(p&&g[2]){if(j===void 0&&!(v in o))return!1}else{var x=new e;if(d)var N=d(j,k,v,o,l,x);if(!(N===void 0?t(k,j,n|r,d,x):N))return!1}}return!0}return Sy=s,Sy}var _y,iT;function IL(){if(iT)return _y;iT=1;var e=Xn();function t(n){return n===n&&!e(n)}return _y=t,_y}var Ey,lT;function fee(){if(lT)return Ey;lT=1;var e=IL(),t=ca();function n(r){for(var s=t(r),o=s.length;o--;){var l=s[o],c=r[l];s[o]=[l,c,e(c)]}return s}return Ey=n,Ey}var Cy,cT;function OL(){if(cT)return Cy;cT=1;function e(t,n){return function(r){return r==null?!1:r[t]===n&&(n!==void 0||t in Object(r))}}return Cy=e,Cy}var Ty,uT;function pee(){if(uT)return Ty;uT=1;var e=hee(),t=fee(),n=OL();function r(s){var o=t(s);return o.length==1&&o[0][2]?n(o[0][0],o[0][1]):function(l){return l===s||e(l,s,o)}}return Ty=r,Ty}var Ay,dT;function Fi(){if(dT)return Ay;dT=1;var e=io(),t=Kr(),n="[object Symbol]";function r(s){return typeof s=="symbol"||t(s)&&e(s)==n}return Ay=r,Ay}var Ry,hT;function u0(){if(hT)return Ry;hT=1;var e=kt(),t=Fi(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;function s(o,l){if(e(o))return!1;var c=typeof o;return c=="number"||c=="symbol"||c=="boolean"||o==null||t(o)?!0:r.test(o)||!n.test(o)||l!=null&&o in Object(l)}return Ry=s,Ry}var My,fT;function mee(){if(fT)return My;fT=1;var e=Jk(),t="Expected a function";function n(r,s){if(typeof r!="function"||s!=null&&typeof s!="function")throw new TypeError(t);var o=function(){var l=arguments,c=s?s.apply(this,l):l[0],d=o.cache;if(d.has(c))return d.get(c);var h=r.apply(this,l);return o.cache=d.set(c,h)||d,h};return o.cache=new(n.Cache||e),o}return n.Cache=e,My=n,My}var $y,pT;function gee(){if(pT)return $y;pT=1;var e=mee(),t=500;function n(r){var s=e(r,function(l){return o.size===t&&o.clear(),l}),o=s.cache;return s}return $y=n,$y}var Iy,mT;function yee(){if(mT)return Iy;mT=1;var e=gee(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,n=/\\(\\)?/g,r=e(function(s){var o=[];return s.charCodeAt(0)===46&&o.push(""),s.replace(t,function(l,c,d,h){o.push(d?h.replace(n,"$1"):c||l)}),o});return Iy=r,Iy}var Oy,gT;function qh(){if(gT)return Oy;gT=1;function e(t,n){for(var r=-1,s=t==null?0:t.length,o=Array(s);++r<s;)o[r]=n(t[r],r,t);return o}return Oy=e,Oy}var Ly,yT;function wee(){if(yT)return Ly;yT=1;var e=Li(),t=qh(),n=kt(),r=Fi(),s=e?e.prototype:void 0,o=s?s.toString:void 0;function l(c){if(typeof c=="string")return c;if(n(c))return t(c,l)+"";if(r(c))return o?o.call(c):"";var d=c+"";return d=="0"&&1/c==-1/0?"-0":d}return Ly=l,Ly}var Py,wT;function LL(){if(wT)return Py;wT=1;var e=wee();function t(n){return n==null?"":e(n)}return Py=t,Py}var Dy,vT;function Uh(){if(vT)return Dy;vT=1;var e=kt(),t=u0(),n=yee(),r=LL();function s(o,l){return e(o)?o:t(o,l)?[o]:n(r(o))}return Dy=s,Dy}var Fy,xT;function _c(){if(xT)return Fy;xT=1;var e=Fi();function t(n){if(typeof n=="string"||e(n))return n;var r=n+"";return r=="0"&&1/n==-1/0?"-0":r}return Fy=t,Fy}var By,bT;function zh(){if(bT)return By;bT=1;var e=Uh(),t=_c();function n(r,s){s=e(s,r);for(var o=0,l=s.length;r!=null&&o<l;)r=r[t(s[o++])];return o&&o==l?r:void 0}return By=n,By}var qy,kT;function vee(){if(kT)return qy;kT=1;var e=zh();function t(n,r,s){var o=n==null?void 0:e(n,r);return o===void 0?s:o}return qy=t,qy}var Uy,NT;function xee(){if(NT)return Uy;NT=1;function e(t,n){return t!=null&&n in Object(t)}return Uy=e,Uy}var zy,jT;function PL(){if(jT)return zy;jT=1;var e=Uh(),t=jc(),n=kt(),r=Lh(),s=e0(),o=_c();function l(c,d,h){d=e(d,c);for(var f=-1,p=d.length,g=!1;++f<p;){var v=o(d[f]);if(!(g=c!=null&&h(c,v)))break;c=c[v]}return g||++f!=p?g:(p=c==null?0:c.length,!!p&&s(p)&&r(v,p)&&(n(c)||t(c)))}return zy=l,zy}var Wy,ST;function DL(){if(ST)return Wy;ST=1;var e=xee(),t=PL();function n(r,s){return r!=null&&t(r,s,e)}return Wy=n,Wy}var Hy,_T;function bee(){if(_T)return Hy;_T=1;var e=$L(),t=vee(),n=DL(),r=u0(),s=IL(),o=OL(),l=_c(),c=1,d=2;function h(f,p){return r(f)&&s(p)?o(l(f),p):function(g){var v=t(g,f);return v===void 0&&v===p?n(g,f):e(p,v,c|d)}}return Hy=h,Hy}var Vy,ET;function FL(){if(ET)return Vy;ET=1;function e(t){return function(n){return n==null?void 0:n[t]}}return Vy=e,Vy}var Gy,CT;function kee(){if(CT)return Gy;CT=1;var e=zh();function t(n){return function(r){return e(r,n)}}return Gy=t,Gy}var Ky,TT;function Nee(){if(TT)return Ky;TT=1;var e=FL(),t=kee(),n=u0(),r=_c();function s(o){return n(o)?e(r(o)):t(o)}return Ky=s,Ky}var Yy,AT;function Ss(){if(AT)return Yy;AT=1;var e=pee(),t=bee(),n=uo(),r=kt(),s=Nee();function o(l){return typeof l=="function"?l:l==null?n:typeof l=="object"?r(l)?t(l[0],l[1]):e(l):s(l)}return Yy=o,Yy}var Xy,RT;function BL(){if(RT)return Xy;RT=1;var e=gL(),t=see(),n=Ss(),r=kt();function s(o,l){var c=r(o)?e:t;return c(o,n(l,3))}return Xy=s,Xy}var Zy,MT;function jee(){if(MT)return Zy;MT=1;var e=Object.prototype,t=e.hasOwnProperty;function n(r,s){return r!=null&&t.call(r,s)}return Zy=n,Zy}var Jy,$T;function qL(){if($T)return Jy;$T=1;var e=jee(),t=PL();function n(r,s){return r!=null&&t(r,s,e)}return Jy=n,Jy}var Qy,IT;function See(){if(IT)return Qy;IT=1;var e=n0(),t=Di(),n=jc(),r=kt(),s=js(),o=Pi(),l=Dh(),c=Sc(),d="[object Map]",h="[object Set]",f=Object.prototype,p=f.hasOwnProperty;function g(v){if(v==null)return!0;if(s(v)&&(r(v)||typeof v=="string"||typeof v.splice=="function"||o(v)||c(v)||n(v)))return!v.length;var j=t(v);if(j==d||j==h)return!v.size;if(l(v))return!e(v).length;for(var k in v)if(p.call(v,k))return!1;return!0}return Qy=g,Qy}var ew,OT;function UL(){if(OT)return ew;OT=1;function e(t){return t===void 0}return ew=e,ew}var tw,LT;function zL(){if(LT)return tw;LT=1;var e=Bh(),t=js();function n(r,s){var o=-1,l=t(r)?Array(r.length):[];return e(r,function(c,d,h){l[++o]=s(c,d,h)}),l}return tw=n,tw}var nw,PT;function WL(){if(PT)return nw;PT=1;var e=qh(),t=Ss(),n=zL(),r=kt();function s(o,l){var c=r(o)?e:n;return c(o,t(l,3))}return nw=s,nw}var rw,DT;function _ee(){if(DT)return rw;DT=1;function e(t,n,r,s){var o=-1,l=t==null?0:t.length;for(s&&l&&(r=t[++o]);++o<l;)r=n(r,t[o],o,t);return r}return rw=e,rw}var sw,FT;function Eee(){if(FT)return sw;FT=1;function e(t,n,r,s,o){return o(t,function(l,c,d){r=s?(s=!1,l):n(r,l,c,d)}),r}return sw=e,sw}var aw,BT;function HL(){if(BT)return aw;BT=1;var e=_ee(),t=Bh(),n=Ss(),r=Eee(),s=kt();function o(l,c,d){var h=s(l)?e:r,f=arguments.length<3;return h(l,n(c,4),d,f,t)}return aw=o,aw}var ow,qT;function Cee(){if(qT)return ow;qT=1;var e=io(),t=kt(),n=Kr(),r="[object String]";function s(o){return typeof o=="string"||!t(o)&&n(o)&&e(o)==r}return ow=s,ow}var iw,UT;function Tee(){if(UT)return iw;UT=1;var e=FL(),t=e("length");return iw=t,iw}var lw,zT;function Aee(){if(zT)return lw;zT=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",r="\\u20d0-\\u20ff",s=t+n+r,o="\\ufe0e\\ufe0f",l="\\u200d",c=RegExp("["+l+e+s+o+"]");function d(h){return c.test(h)}return lw=d,lw}var cw,WT;function Ree(){if(WT)return cw;WT=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",r="\\u20d0-\\u20ff",s=t+n+r,o="\\ufe0e\\ufe0f",l="["+e+"]",c="["+s+"]",d="\\ud83c[\\udffb-\\udfff]",h="(?:"+c+"|"+d+")",f="[^"+e+"]",p="(?:\\ud83c[\\udde6-\\uddff]){2}",g="[\\ud800-\\udbff][\\udc00-\\udfff]",v="\\u200d",j=h+"?",k="["+o+"]?",x="(?:"+v+"(?:"+[f,p,g].join("|")+")"+k+j+")*",N=k+j+x,b="(?:"+[f+c+"?",c,p,g,l].join("|")+")",S=RegExp(d+"(?="+d+")|"+b+N,"g");function E(R){for(var I=S.lastIndex=0;S.test(R);)++I;return I}return cw=E,cw}var uw,HT;function Mee(){if(HT)return uw;HT=1;var e=Tee(),t=Aee(),n=Ree();function r(s){return t(s)?n(s):e(s)}return uw=r,uw}var dw,VT;function $ee(){if(VT)return dw;VT=1;var e=n0(),t=Di(),n=js(),r=Cee(),s=Mee(),o="[object Map]",l="[object Set]";function c(d){if(d==null)return 0;if(n(d))return r(d)?s(d):d.length;var h=t(d);return h==o||h==l?d.size:e(d).length}return dw=c,dw}var hw,GT;function Iee(){if(GT)return hw;GT=1;var e=Qk(),t=jL(),n=l0(),r=Ss(),s=Fh(),o=kt(),l=Pi(),c=kc(),d=Xn(),h=Sc();function f(p,g,v){var j=o(p),k=j||l(p)||h(p);if(g=r(g,4),v==null){var x=p&&p.constructor;k?v=j?new x:[]:d(p)?v=c(x)?t(s(p)):{}:v={}}return(k?e:n)(p,function(N,b,S){return g(v,N,b,S)}),v}return hw=f,hw}var fw,KT;function Oee(){if(KT)return fw;KT=1;var e=Li(),t=jc(),n=kt(),r=e?e.isConcatSpreadable:void 0;function s(o){return n(o)||t(o)||!!(r&&o&&o[r])}return fw=s,fw}var pw,YT;function d0(){if(YT)return pw;YT=1;var e=s0(),t=Oee();function n(r,s,o,l,c){var d=-1,h=r.length;for(o||(o=t),c||(c=[]);++d<h;){var f=r[d];s>0&&o(f)?s>1?n(f,s-1,o,l,c):e(c,f):l||(c[c.length]=f)}return c}return pw=n,pw}var mw,XT;function Lee(){if(XT)return mw;XT=1;function e(t,n,r){switch(r.length){case 0:return t.call(n);case 1:return t.call(n,r[0]);case 2:return t.call(n,r[0],r[1]);case 3:return t.call(n,r[0],r[1],r[2])}return t.apply(n,r)}return mw=e,mw}var gw,ZT;function VL(){if(ZT)return gw;ZT=1;var e=Lee(),t=Math.max;function n(r,s,o){return s=t(s===void 0?r.length-1:s,0),function(){for(var l=arguments,c=-1,d=t(l.length-s,0),h=Array(d);++c<d;)h[c]=l[s+c];c=-1;for(var f=Array(s+1);++c<s;)f[c]=l[c];return f[s]=o(h),e(r,this,f)}}return gw=n,gw}var yw,JT;function Pee(){if(JT)return yw;JT=1;var e=o0(),t=dL(),n=uo(),r=t?function(s,o){return t(s,"toString",{configurable:!0,enumerable:!1,value:e(o),writable:!0})}:n;return yw=r,yw}var ww,QT;function Dee(){if(QT)return ww;QT=1;var e=800,t=16,n=Date.now;function r(s){var o=0,l=0;return function(){var c=n(),d=t-(c-l);if(l=c,d>0){if(++o>=e)return arguments[0]}else o=0;return s.apply(void 0,arguments)}}return ww=r,ww}var vw,eA;function GL(){if(eA)return vw;eA=1;var e=Pee(),t=Dee(),n=t(e);return vw=n,vw}var xw,tA;function Wh(){if(tA)return xw;tA=1;var e=uo(),t=VL(),n=GL();function r(s,o){return n(t(s,o,e),s+"")}return xw=r,xw}var bw,nA;function KL(){if(nA)return bw;nA=1;function e(t,n,r,s){for(var o=t.length,l=r+(s?1:-1);s?l--:++l<o;)if(n(t[l],l,t))return l;return-1}return bw=e,bw}var kw,rA;function Fee(){if(rA)return kw;rA=1;function e(t){return t!==t}return kw=e,kw}var Nw,sA;function Bee(){if(sA)return Nw;sA=1;function e(t,n,r){for(var s=r-1,o=t.length;++s<o;)if(t[s]===n)return s;return-1}return Nw=e,Nw}var jw,aA;function qee(){if(aA)return jw;aA=1;var e=KL(),t=Fee(),n=Bee();function r(s,o,l){return o===o?n(s,o,l):e(s,t,l)}return jw=r,jw}var Sw,oA;function Uee(){if(oA)return Sw;oA=1;var e=qee();function t(n,r){var s=n==null?0:n.length;return!!s&&e(n,r,0)>-1}return Sw=t,Sw}var _w,iA;function zee(){if(iA)return _w;iA=1;function e(t,n,r){for(var s=-1,o=t==null?0:t.length;++s<o;)if(r(n,t[s]))return!0;return!1}return _w=e,_w}var Ew,lA;function Wee(){if(lA)return Ew;lA=1;function e(){}return Ew=e,Ew}var Cw,cA;function Hee(){if(cA)return Cw;cA=1;var e=bL(),t=Wee(),n=c0(),r=1/0,s=e&&1/n(new e([,-0]))[1]==r?function(o){return new e(o)}:t;return Cw=s,Cw}var Tw,uA;function Vee(){if(uA)return Tw;uA=1;var e=AL(),t=Uee(),n=zee(),r=RL(),s=Hee(),o=c0(),l=200;function c(d,h,f){var p=-1,g=t,v=d.length,j=!0,k=[],x=k;if(f)j=!1,g=n;else if(v>=l){var N=h?null:s(d);if(N)return o(N);j=!1,g=r,x=new e}else x=h?[]:k;e:for(;++p<v;){var b=d[p],S=h?h(b):b;if(b=f||b!==0?b:0,j&&S===S){for(var E=x.length;E--;)if(x[E]===S)continue e;h&&x.push(S),k.push(b)}else g(x,S,f)||(x!==k&&x.push(S),k.push(b))}return k}return Tw=c,Tw}var Aw,dA;function YL(){if(dA)return Aw;dA=1;var e=js(),t=Kr();function n(r){return t(r)&&e(r)}return Aw=n,Aw}var Rw,hA;function Gee(){if(hA)return Rw;hA=1;var e=d0(),t=Wh(),n=Vee(),r=YL(),s=t(function(o){return n(e(o,1,r,!0))});return Rw=s,Rw}var Mw,fA;function Kee(){if(fA)return Mw;fA=1;var e=qh();function t(n,r){return e(r,function(s){return n[s]})}return Mw=t,Mw}var $w,pA;function XL(){if(pA)return $w;pA=1;var e=Kee(),t=ca();function n(r){return r==null?[]:e(r,t(r))}return $w=n,$w}var Iw,mA;function Zn(){if(mA)return Iw;mA=1;var e;if(typeof Xk=="function")try{e={clone:tee(),constant:o0(),each:TL(),filter:BL(),has:qL(),isArray:kt(),isEmpty:See(),isFunction:kc(),isUndefined:UL(),keys:ca(),map:WL(),reduce:HL(),size:$ee(),transform:Iee(),union:Gee(),values:XL()}}catch{}return e||(e=window._),Iw=e,Iw}var Ow,gA;function h0(){if(gA)return Ow;gA=1;var e=Zn();Ow=s;var t="\0",n="\0",r="";function s(f){this._isDirected=e.has(f,"directed")?f.directed:!0,this._isMultigraph=e.has(f,"multigraph")?f.multigraph:!1,this._isCompound=e.has(f,"compound")?f.compound:!1,this._label=void 0,this._defaultNodeLabelFn=e.constant(void 0),this._defaultEdgeLabelFn=e.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[n]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}s.prototype._nodeCount=0,s.prototype._edgeCount=0,s.prototype.isDirected=function(){return this._isDirected},s.prototype.isMultigraph=function(){return this._isMultigraph},s.prototype.isCompound=function(){return this._isCompound},s.prototype.setGraph=function(f){return this._label=f,this},s.prototype.graph=function(){return this._label},s.prototype.setDefaultNodeLabel=function(f){return e.isFunction(f)||(f=e.constant(f)),this._defaultNodeLabelFn=f,this},s.prototype.nodeCount=function(){return this._nodeCount},s.prototype.nodes=function(){return e.keys(this._nodes)},s.prototype.sources=function(){var f=this;return e.filter(this.nodes(),function(p){return e.isEmpty(f._in[p])})},s.prototype.sinks=function(){var f=this;return e.filter(this.nodes(),function(p){return e.isEmpty(f._out[p])})},s.prototype.setNodes=function(f,p){var g=arguments,v=this;return e.each(f,function(j){g.length>1?v.setNode(j,p):v.setNode(j)}),this},s.prototype.setNode=function(f,p){return e.has(this._nodes,f)?(arguments.length>1&&(this._nodes[f]=p),this):(this._nodes[f]=arguments.length>1?p:this._defaultNodeLabelFn(f),this._isCompound&&(this._parent[f]=n,this._children[f]={},this._children[n][f]=!0),this._in[f]={},this._preds[f]={},this._out[f]={},this._sucs[f]={},++this._nodeCount,this)},s.prototype.node=function(f){return this._nodes[f]},s.prototype.hasNode=function(f){return e.has(this._nodes,f)},s.prototype.removeNode=function(f){var p=this;if(e.has(this._nodes,f)){var g=function(v){p.removeEdge(p._edgeObjs[v])};delete this._nodes[f],this._isCompound&&(this._removeFromParentsChildList(f),delete this._parent[f],e.each(this.children(f),function(v){p.setParent(v)}),delete this._children[f]),e.each(e.keys(this._in[f]),g),delete this._in[f],delete this._preds[f],e.each(e.keys(this._out[f]),g),delete this._out[f],delete this._sucs[f],--this._nodeCount}return this},s.prototype.setParent=function(f,p){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(p))p=n;else{p+="";for(var g=p;!e.isUndefined(g);g=this.parent(g))if(g===f)throw new Error("Setting "+p+" as parent of "+f+" would create a cycle");this.setNode(p)}return this.setNode(f),this._removeFromParentsChildList(f),this._parent[f]=p,this._children[p][f]=!0,this},s.prototype._removeFromParentsChildList=function(f){delete this._children[this._parent[f]][f]},s.prototype.parent=function(f){if(this._isCompound){var p=this._parent[f];if(p!==n)return p}},s.prototype.children=function(f){if(e.isUndefined(f)&&(f=n),this._isCompound){var p=this._children[f];if(p)return e.keys(p)}else{if(f===n)return this.nodes();if(this.hasNode(f))return[]}},s.prototype.predecessors=function(f){var p=this._preds[f];if(p)return e.keys(p)},s.prototype.successors=function(f){var p=this._sucs[f];if(p)return e.keys(p)},s.prototype.neighbors=function(f){var p=this.predecessors(f);if(p)return e.union(p,this.successors(f))},s.prototype.isLeaf=function(f){var p;return this.isDirected()?p=this.successors(f):p=this.neighbors(f),p.length===0},s.prototype.filterNodes=function(f){var p=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});p.setGraph(this.graph());var g=this;e.each(this._nodes,function(k,x){f(x)&&p.setNode(x,k)}),e.each(this._edgeObjs,function(k){p.hasNode(k.v)&&p.hasNode(k.w)&&p.setEdge(k,g.edge(k))});var v={};function j(k){var x=g.parent(k);return x===void 0||p.hasNode(x)?(v[k]=x,x):x in v?v[x]:j(x)}return this._isCompound&&e.each(p.nodes(),function(k){p.setParent(k,j(k))}),p},s.prototype.setDefaultEdgeLabel=function(f){return e.isFunction(f)||(f=e.constant(f)),this._defaultEdgeLabelFn=f,this},s.prototype.edgeCount=function(){return this._edgeCount},s.prototype.edges=function(){return e.values(this._edgeObjs)},s.prototype.setPath=function(f,p){var g=this,v=arguments;return e.reduce(f,function(j,k){return v.length>1?g.setEdge(j,k,p):g.setEdge(j,k),k}),this},s.prototype.setEdge=function(){var f,p,g,v,j=!1,k=arguments[0];typeof k=="object"&&k!==null&&"v"in k?(f=k.v,p=k.w,g=k.name,arguments.length===2&&(v=arguments[1],j=!0)):(f=k,p=arguments[1],g=arguments[3],arguments.length>2&&(v=arguments[2],j=!0)),f=""+f,p=""+p,e.isUndefined(g)||(g=""+g);var x=c(this._isDirected,f,p,g);if(e.has(this._edgeLabels,x))return j&&(this._edgeLabels[x]=v),this;if(!e.isUndefined(g)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(f),this.setNode(p),this._edgeLabels[x]=j?v:this._defaultEdgeLabelFn(f,p,g);var N=d(this._isDirected,f,p,g);return f=N.v,p=N.w,Object.freeze(N),this._edgeObjs[x]=N,o(this._preds[p],f),o(this._sucs[f],p),this._in[p][x]=N,this._out[f][x]=N,this._edgeCount++,this},s.prototype.edge=function(f,p,g){var v=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,f,p,g);return this._edgeLabels[v]},s.prototype.hasEdge=function(f,p,g){var v=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,f,p,g);return e.has(this._edgeLabels,v)},s.prototype.removeEdge=function(f,p,g){var v=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,f,p,g),j=this._edgeObjs[v];return j&&(f=j.v,p=j.w,delete this._edgeLabels[v],delete this._edgeObjs[v],l(this._preds[p],f),l(this._sucs[f],p),delete this._in[p][v],delete this._out[f][v],this._edgeCount--),this},s.prototype.inEdges=function(f,p){var g=this._in[f];if(g){var v=e.values(g);return p?e.filter(v,function(j){return j.v===p}):v}},s.prototype.outEdges=function(f,p){var g=this._out[f];if(g){var v=e.values(g);return p?e.filter(v,function(j){return j.w===p}):v}},s.prototype.nodeEdges=function(f,p){var g=this.inEdges(f,p);if(g)return g.concat(this.outEdges(f,p))};function o(f,p){f[p]?f[p]++:f[p]=1}function l(f,p){--f[p]||delete f[p]}function c(f,p,g,v){var j=""+p,k=""+g;if(!f&&j>k){var x=j;j=k,k=x}return j+r+k+r+(e.isUndefined(v)?t:v)}function d(f,p,g,v){var j=""+p,k=""+g;if(!f&&j>k){var x=j;j=k,k=x}var N={v:j,w:k};return v&&(N.name=v),N}function h(f,p){return c(f,p.v,p.w,p.name)}return Ow}var Lw,yA;function Yee(){return yA||(yA=1,Lw="2.1.8"),Lw}var Pw,wA;function Xee(){return wA||(wA=1,Pw={Graph:h0(),version:Yee()}),Pw}var Dw,vA;function Zee(){if(vA)return Dw;vA=1;var e=Zn(),t=h0();Dw={write:n,read:o};function n(l){var c={options:{directed:l.isDirected(),multigraph:l.isMultigraph(),compound:l.isCompound()},nodes:r(l),edges:s(l)};return e.isUndefined(l.graph())||(c.value=e.clone(l.graph())),c}function r(l){return e.map(l.nodes(),function(c){var d=l.node(c),h=l.parent(c),f={v:c};return e.isUndefined(d)||(f.value=d),e.isUndefined(h)||(f.parent=h),f})}function s(l){return e.map(l.edges(),function(c){var d=l.edge(c),h={v:c.v,w:c.w};return e.isUndefined(c.name)||(h.name=c.name),e.isUndefined(d)||(h.value=d),h})}function o(l){var c=new t(l.options).setGraph(l.value);return e.each(l.nodes,function(d){c.setNode(d.v,d.value),d.parent&&c.setParent(d.v,d.parent)}),e.each(l.edges,function(d){c.setEdge({v:d.v,w:d.w,name:d.name},d.value)}),c}return Dw}var Fw,xA;function Jee(){if(xA)return Fw;xA=1;var e=Zn();Fw=t;function t(n){var r={},s=[],o;function l(c){e.has(r,c)||(r[c]=!0,o.push(c),e.each(n.successors(c),l),e.each(n.predecessors(c),l))}return e.each(n.nodes(),function(c){o=[],l(c),o.length&&s.push(o)}),s}return Fw}var Bw,bA;function ZL(){if(bA)return Bw;bA=1;var e=Zn();Bw=t;function t(){this._arr=[],this._keyIndices={}}return t.prototype.size=function(){return this._arr.length},t.prototype.keys=function(){return this._arr.map(function(n){return n.key})},t.prototype.has=function(n){return e.has(this._keyIndices,n)},t.prototype.priority=function(n){var r=this._keyIndices[n];if(r!==void 0)return this._arr[r].priority},t.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},t.prototype.add=function(n,r){var s=this._keyIndices;if(n=String(n),!e.has(s,n)){var o=this._arr,l=o.length;return s[n]=l,o.push({key:n,priority:r}),this._decrease(l),!0}return!1},t.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var n=this._arr.pop();return delete this._keyIndices[n.key],this._heapify(0),n.key},t.prototype.decrease=function(n,r){var s=this._keyIndices[n];if(r>this._arr[s].priority)throw new Error("New priority is greater than current priority. Key: "+n+" Old: "+this._arr[s].priority+" New: "+r);this._arr[s].priority=r,this._decrease(s)},t.prototype._heapify=function(n){var r=this._arr,s=2*n,o=s+1,l=n;s<r.length&&(l=r[s].priority<r[l].priority?s:l,o<r.length&&(l=r[o].priority<r[l].priority?o:l),l!==n&&(this._swap(n,l),this._heapify(l)))},t.prototype._decrease=function(n){for(var r=this._arr,s=r[n].priority,o;n!==0&&(o=n>>1,!(r[o].priority<s));)this._swap(n,o),n=o},t.prototype._swap=function(n,r){var s=this._arr,o=this._keyIndices,l=s[n],c=s[r];s[n]=c,s[r]=l,o[c.key]=n,o[l.key]=r},Bw}var qw,kA;function JL(){if(kA)return qw;kA=1;var e=Zn(),t=ZL();qw=r;var n=e.constant(1);function r(o,l,c,d){return s(o,String(l),c||n,d||function(h){return o.outEdges(h)})}function s(o,l,c,d){var h={},f=new t,p,g,v=function(j){var k=j.v!==p?j.v:j.w,x=h[k],N=c(j),b=g.distance+N;if(N<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+j+" Weight: "+N);b<x.distance&&(x.distance=b,x.predecessor=p,f.decrease(k,b))};for(o.nodes().forEach(function(j){var k=j===l?0:Number.POSITIVE_INFINITY;h[j]={distance:k},f.add(j,k)});f.size()>0&&(p=f.removeMin(),g=h[p],g.distance!==Number.POSITIVE_INFINITY);)d(p).forEach(v);return h}return qw}var Uw,NA;function Qee(){if(NA)return Uw;NA=1;var e=JL(),t=Zn();Uw=n;function n(r,s,o){return t.transform(r.nodes(),function(l,c){l[c]=e(r,c,s,o)},{})}return Uw}var zw,jA;function QL(){if(jA)return zw;jA=1;var e=Zn();zw=t;function t(n){var r=0,s=[],o={},l=[];function c(d){var h=o[d]={onStack:!0,lowlink:r,index:r++};if(s.push(d),n.successors(d).forEach(function(g){e.has(o,g)?o[g].onStack&&(h.lowlink=Math.min(h.lowlink,o[g].index)):(c(g),h.lowlink=Math.min(h.lowlink,o[g].lowlink))}),h.lowlink===h.index){var f=[],p;do p=s.pop(),o[p].onStack=!1,f.push(p);while(d!==p);l.push(f)}}return n.nodes().forEach(function(d){e.has(o,d)||c(d)}),l}return zw}var Ww,SA;function ete(){if(SA)return Ww;SA=1;var e=Zn(),t=QL();Ww=n;function n(r){return e.filter(t(r),function(s){return s.length>1||s.length===1&&r.hasEdge(s[0],s[0])})}return Ww}var Hw,_A;function tte(){if(_A)return Hw;_A=1;var e=Zn();Hw=n;var t=e.constant(1);function n(s,o,l){return r(s,o||t,l||function(c){return s.outEdges(c)})}function r(s,o,l){var c={},d=s.nodes();return d.forEach(function(h){c[h]={},c[h][h]={distance:0},d.forEach(function(f){h!==f&&(c[h][f]={distance:Number.POSITIVE_INFINITY})}),l(h).forEach(function(f){var p=f.v===h?f.w:f.v,g=o(f);c[h][p]={distance:g,predecessor:h}})}),d.forEach(function(h){var f=c[h];d.forEach(function(p){var g=c[p];d.forEach(function(v){var j=g[h],k=f[v],x=g[v],N=j.distance+k.distance;N<x.distance&&(x.distance=N,x.predecessor=k.predecessor)})})}),c}return Hw}var Vw,EA;function eP(){if(EA)return Vw;EA=1;var e=Zn();Vw=t,t.CycleException=n;function t(r){var s={},o={},l=[];function c(d){if(e.has(o,d))throw new n;e.has(s,d)||(o[d]=!0,s[d]=!0,e.each(r.predecessors(d),c),delete o[d],l.push(d))}if(e.each(r.sinks(),c),e.size(s)!==r.nodeCount())throw new n;return l}function n(){}return n.prototype=new Error,Vw}var Gw,CA;function nte(){if(CA)return Gw;CA=1;var e=eP();Gw=t;function t(n){try{e(n)}catch(r){if(r instanceof e.CycleException)return!1;throw r}return!0}return Gw}var Kw,TA;function tP(){if(TA)return Kw;TA=1;var e=Zn();Kw=t;function t(r,s,o){e.isArray(s)||(s=[s]);var l=(r.isDirected()?r.successors:r.neighbors).bind(r),c=[],d={};return e.each(s,function(h){if(!r.hasNode(h))throw new Error("Graph does not have node: "+h);n(r,h,o==="post",d,l,c)}),c}function n(r,s,o,l,c,d){e.has(l,s)||(l[s]=!0,o||d.push(s),e.each(c(s),function(h){n(r,h,o,l,c,d)}),o&&d.push(s))}return Kw}var Yw,AA;function rte(){if(AA)return Yw;AA=1;var e=tP();Yw=t;function t(n,r){return e(n,r,"post")}return Yw}var Xw,RA;function ste(){if(RA)return Xw;RA=1;var e=tP();Xw=t;function t(n,r){return e(n,r,"pre")}return Xw}var Zw,MA;function ate(){if(MA)return Zw;MA=1;var e=Zn(),t=h0(),n=ZL();Zw=r;function r(s,o){var l=new t,c={},d=new n,h;function f(g){var v=g.v===h?g.w:g.v,j=d.priority(v);if(j!==void 0){var k=o(g);k<j&&(c[v]=h,d.decrease(v,k))}}if(s.nodeCount()===0)return l;e.each(s.nodes(),function(g){d.add(g,Number.POSITIVE_INFINITY),l.setNode(g)}),d.decrease(s.nodes()[0],0);for(var p=!1;d.size()>0;){if(h=d.removeMin(),e.has(c,h))l.setEdge(h,c[h]);else{if(p)throw new Error("Input graph is not connected: "+s);p=!0}s.nodeEdges(h).forEach(f)}return l}return Zw}var Jw,$A;function ote(){return $A||($A=1,Jw={components:Jee(),dijkstra:JL(),dijkstraAll:Qee(),findCycles:ete(),floydWarshall:tte(),isAcyclic:nte(),postorder:rte(),preorder:ste(),prim:ate(),tarjan:QL(),topsort:eP()}),Jw}var Qw,IA;function ite(){if(IA)return Qw;IA=1;var e=Xee();return Qw={Graph:e.Graph,json:Zee(),alg:ote(),version:e.version},Qw}var ev,OA;function jr(){if(OA)return ev;OA=1;var e;if(typeof Xk=="function")try{e=ite()}catch{}return e||(e=window.graphlib),ev=e,ev}var tv,LA;function lte(){if(LA)return tv;LA=1;var e=_L(),t=1,n=4;function r(s){return e(s,t|n)}return tv=r,tv}var nv,PA;function Hh(){if(PA)return nv;PA=1;var e=Oi(),t=js(),n=Lh(),r=Xn();function s(o,l,c){if(!r(c))return!1;var d=typeof l;return(d=="number"?t(c)&&n(l,c.length):d=="string"&&l in c)?e(c[l],o):!1}return nv=s,nv}var rv,DA;function cte(){if(DA)return rv;DA=1;var e=Wh(),t=Oi(),n=Hh(),r=co(),s=Object.prototype,o=s.hasOwnProperty,l=e(function(c,d){c=Object(c);var h=-1,f=d.length,p=f>2?d[2]:void 0;for(p&&n(d[0],d[1],p)&&(f=1);++h<f;)for(var g=d[h],v=r(g),j=-1,k=v.length;++j<k;){var x=v[j],N=c[x];(N===void 0||t(N,s[x])&&!o.call(c,x))&&(c[x]=g[x])}return c});return rv=l,rv}var sv,FA;function ute(){if(FA)return sv;FA=1;var e=Ss(),t=js(),n=ca();function r(s){return function(o,l,c){var d=Object(o);if(!t(o)){var h=e(l,3);o=n(o),l=function(p){return h(d[p],p,d)}}var f=s(o,l,c);return f>-1?d[h?o[f]:f]:void 0}}return sv=r,sv}var av,BA;function dte(){if(BA)return av;BA=1;var e=/\s/;function t(n){for(var r=n.length;r--&&e.test(n.charAt(r)););return r}return av=t,av}var ov,qA;function hte(){if(qA)return ov;qA=1;var e=dte(),t=/^\s+/;function n(r){return r&&r.slice(0,e(r)+1).replace(t,"")}return ov=n,ov}var iv,UA;function fte(){if(UA)return iv;UA=1;var e=hte(),t=Xn(),n=Fi(),r=NaN,s=/^[-+]0x[0-9a-f]+$/i,o=/^0b[01]+$/i,l=/^0o[0-7]+$/i,c=parseInt;function d(h){if(typeof h=="number")return h;if(n(h))return r;if(t(h)){var f=typeof h.valueOf=="function"?h.valueOf():h;h=t(f)?f+"":f}if(typeof h!="string")return h===0?h:+h;h=e(h);var p=o.test(h);return p||l.test(h)?c(h.slice(2),p?2:8):s.test(h)?r:+h}return iv=d,iv}var lv,zA;function nP(){if(zA)return lv;zA=1;var e=fte(),t=1/0,n=17976931348623157e292;function r(s){if(!s)return s===0?s:0;if(s=e(s),s===t||s===-t){var o=s<0?-1:1;return o*n}return s===s?s:0}return lv=r,lv}var cv,WA;function pte(){if(WA)return cv;WA=1;var e=nP();function t(n){var r=e(n),s=r%1;return r===r?s?r-s:r:0}return cv=t,cv}var uv,HA;function mte(){if(HA)return uv;HA=1;var e=KL(),t=Ss(),n=pte(),r=Math.max;function s(o,l,c){var d=o==null?0:o.length;if(!d)return-1;var h=c==null?0:n(c);return h<0&&(h=r(d+h,0)),e(o,t(l,3),h)}return uv=s,uv}var dv,VA;function gte(){if(VA)return dv;VA=1;var e=ute(),t=mte(),n=e(t);return dv=n,dv}var hv,GA;function rP(){if(GA)return hv;GA=1;var e=d0();function t(n){var r=n==null?0:n.length;return r?e(n,1):[]}return hv=t,hv}var fv,KA;function yte(){if(KA)return fv;KA=1;var e=i0(),t=EL(),n=co();function r(s,o){return s==null?s:e(s,t(o),n)}return fv=r,fv}var pv,YA;function wte(){if(YA)return pv;YA=1;function e(t){var n=t==null?0:t.length;return n?t[n-1]:void 0}return pv=e,pv}var mv,XA;function vte(){if(XA)return mv;XA=1;var e=Ih(),t=l0(),n=Ss();function r(s,o){var l={};return o=n(o,3),t(s,function(c,d,h){e(l,d,o(c,d,h))}),l}return mv=r,mv}var gv,ZA;function f0(){if(ZA)return gv;ZA=1;var e=Fi();function t(n,r,s){for(var o=-1,l=n.length;++o<l;){var c=n[o],d=r(c);if(d!=null&&(h===void 0?d===d&&!e(d):s(d,h)))var h=d,f=c}return f}return gv=t,gv}var yv,JA;function xte(){if(JA)return yv;JA=1;function e(t,n){return t>n}return yv=e,yv}var wv,QA;function bte(){if(QA)return wv;QA=1;var e=f0(),t=xte(),n=uo();function r(s){return s&&s.length?e(s,n,t):void 0}return wv=r,wv}var vv,eR;function sP(){if(eR)return vv;eR=1;var e=Ih(),t=Oi();function n(r,s,o){(o!==void 0&&!t(r[s],o)||o===void 0&&!(s in r))&&e(r,s,o)}return vv=n,vv}var xv,tR;function kte(){if(tR)return xv;tR=1;var e=io(),t=Fh(),n=Kr(),r="[object Object]",s=Function.prototype,o=Object.prototype,l=s.toString,c=o.hasOwnProperty,d=l.call(Object);function h(f){if(!n(f)||e(f)!=r)return!1;var p=t(f);if(p===null)return!0;var g=c.call(p,"constructor")&&p.constructor;return typeof g=="function"&&g instanceof g&&l.call(g)==d}return xv=h,xv}var bv,nR;function aP(){if(nR)return bv;nR=1;function e(t,n){if(!(n==="constructor"&&typeof t[n]=="function")&&n!="__proto__")return t[n]}return bv=e,bv}var kv,rR;function Nte(){if(rR)return kv;rR=1;var e=Nc(),t=co();function n(r){return e(r,t(r))}return kv=n,kv}var Nv,sR;function jte(){if(sR)return Nv;sR=1;var e=sP(),t=pL(),n=NL(),r=mL(),s=SL(),o=jc(),l=kt(),c=YL(),d=Pi(),h=kc(),f=Xn(),p=kte(),g=Sc(),v=aP(),j=Nte();function k(x,N,b,S,E,R,I){var A=v(x,b),q=v(N,b),$=I.get(q);if($){e(x,b,$);return}var B=R?R(A,q,b+"",x,N,I):void 0,L=B===void 0;if(L){var M=l(q),F=!M&&d(q),T=!M&&!F&&g(q);B=q,M||F||T?l(A)?B=A:c(A)?B=r(A):F?(L=!1,B=t(q,!0)):T?(L=!1,B=n(q,!0)):B=[]:p(q)||o(q)?(B=A,o(A)?B=j(A):(!f(A)||h(A))&&(B=s(q))):L=!1}L&&(I.set(q,B),E(B,q,S,R,I),I.delete(q)),e(x,b,B)}return Nv=k,Nv}var jv,aR;function Ste(){if(aR)return jv;aR=1;var e=$h(),t=sP(),n=i0(),r=jte(),s=Xn(),o=co(),l=aP();function c(d,h,f,p,g){d!==h&&n(h,function(v,j){if(g||(g=new e),s(v))r(d,h,j,f,c,p,g);else{var k=p?p(l(d,j),v,j+"",d,h,g):void 0;k===void 0&&(k=v),t(d,j,k)}},o)}return jv=c,jv}var Sv,oR;function _te(){if(oR)return Sv;oR=1;var e=Wh(),t=Hh();function n(r){return e(function(s,o){var l=-1,c=o.length,d=c>1?o[c-1]:void 0,h=c>2?o[2]:void 0;for(d=r.length>3&&typeof d=="function"?(c--,d):void 0,h&&t(o[0],o[1],h)&&(d=c<3?void 0:d,c=1),s=Object(s);++l<c;){var f=o[l];f&&r(s,f,l,d)}return s})}return Sv=n,Sv}var _v,iR;function Ete(){if(iR)return _v;iR=1;var e=Ste(),t=_te(),n=t(function(r,s,o){e(r,s,o)});return _v=n,_v}var Ev,lR;function oP(){if(lR)return Ev;lR=1;function e(t,n){return t<n}return Ev=e,Ev}var Cv,cR;function Cte(){if(cR)return Cv;cR=1;var e=f0(),t=oP(),n=uo();function r(s){return s&&s.length?e(s,n,t):void 0}return Cv=r,Cv}var Tv,uR;function Tte(){if(uR)return Tv;uR=1;var e=f0(),t=Ss(),n=oP();function r(s,o){return s&&s.length?e(s,t(o,2),n):void 0}return Tv=r,Tv}var Av,dR;function Ate(){if(dR)return Av;dR=1;var e=_r(),t=function(){return e.Date.now()};return Av=t,Av}var Rv,hR;function Rte(){if(hR)return Rv;hR=1;var e=Oh(),t=Uh(),n=Lh(),r=Xn(),s=_c();function o(l,c,d,h){if(!r(l))return l;c=t(c,l);for(var f=-1,p=c.length,g=p-1,v=l;v!=null&&++f<p;){var j=s(c[f]),k=d;if(j==="__proto__"||j==="constructor"||j==="prototype")return l;if(f!=g){var x=v[j];k=h?h(x,j,v):void 0,k===void 0&&(k=r(x)?x:n(c[f+1])?[]:{})}e(v,j,k),v=v[j]}return l}return Rv=o,Rv}var Mv,fR;function Mte(){if(fR)return Mv;fR=1;var e=zh(),t=Rte(),n=Uh();function r(s,o,l){for(var c=-1,d=o.length,h={};++c<d;){var f=o[c],p=e(s,f);l(p,f)&&t(h,n(f,s),p)}return h}return Mv=r,Mv}var $v,pR;function $te(){if(pR)return $v;pR=1;var e=Mte(),t=DL();function n(r,s){return e(r,s,function(o,l){return t(r,l)})}return $v=n,$v}var Iv,mR;function Ite(){if(mR)return Iv;mR=1;var e=rP(),t=VL(),n=GL();function r(s){return n(t(s,void 0,e),s+"")}return Iv=r,Iv}var Ov,gR;function Ote(){if(gR)return Ov;gR=1;var e=$te(),t=Ite(),n=t(function(r,s){return r==null?{}:e(r,s)});return Ov=n,Ov}var Lv,yR;function Lte(){if(yR)return Lv;yR=1;var e=Math.ceil,t=Math.max;function n(r,s,o,l){for(var c=-1,d=t(e((s-r)/(o||1)),0),h=Array(d);d--;)h[l?d:++c]=r,r+=o;return h}return Lv=n,Lv}var Pv,wR;function Pte(){if(wR)return Pv;wR=1;var e=Lte(),t=Hh(),n=nP();function r(s){return function(o,l,c){return c&&typeof c!="number"&&t(o,l,c)&&(l=c=void 0),o=n(o),l===void 0?(l=o,o=0):l=n(l),c=c===void 0?o<l?1:-1:n(c),e(o,l,c,s)}}return Pv=r,Pv}var Dv,vR;function Dte(){if(vR)return Dv;vR=1;var e=Pte(),t=e();return Dv=t,Dv}var Fv,xR;function Fte(){if(xR)return Fv;xR=1;function e(t,n){var r=t.length;for(t.sort(n);r--;)t[r]=t[r].value;return t}return Fv=e,Fv}var Bv,bR;function Bte(){if(bR)return Bv;bR=1;var e=Fi();function t(n,r){if(n!==r){var s=n!==void 0,o=n===null,l=n===n,c=e(n),d=r!==void 0,h=r===null,f=r===r,p=e(r);if(!h&&!p&&!c&&n>r||c&&d&&f&&!h&&!p||o&&d&&f||!s&&f||!l)return 1;if(!o&&!c&&!p&&n<r||p&&s&&l&&!o&&!c||h&&s&&l||!d&&l||!f)return-1}return 0}return Bv=t,Bv}var qv,kR;function qte(){if(kR)return qv;kR=1;var e=Bte();function t(n,r,s){for(var o=-1,l=n.criteria,c=r.criteria,d=l.length,h=s.length;++o<d;){var f=e(l[o],c[o]);if(f){if(o>=h)return f;var p=s[o];return f*(p=="desc"?-1:1)}}return n.index-r.index}return qv=t,qv}var Uv,NR;function Ute(){if(NR)return Uv;NR=1;var e=qh(),t=zh(),n=Ss(),r=zL(),s=Fte(),o=Ph(),l=qte(),c=uo(),d=kt();function h(f,p,g){p.length?p=e(p,function(k){return d(k)?function(x){return t(x,k.length===1?k[0]:k)}:k}):p=[c];var v=-1;p=e(p,o(n));var j=r(f,function(k,x,N){var b=e(p,function(S){return S(k)});return{criteria:b,index:++v,value:k}});return s(j,function(k,x){return l(k,x,g)})}return Uv=h,Uv}var zv,jR;function zte(){if(jR)return zv;jR=1;var e=d0(),t=Ute(),n=Wh(),r=Hh(),s=n(function(o,l){if(o==null)return[];var c=l.length;return c>1&&r(o,l[0],l[1])?l=[]:c>2&&r(l[0],l[1],l[2])&&(l=[l[0]]),t(o,e(l,1),[])});return zv=s,zv}var Wv,SR;function Wte(){if(SR)return Wv;SR=1;var e=LL(),t=0;function n(r){var s=++t;return e(r)+s}return Wv=n,Wv}var Hv,_R;function Hte(){if(_R)return Hv;_R=1;function e(t,n,r){for(var s=-1,o=t.length,l=n.length,c={};++s<o;){var d=s<l?n[s]:void 0;r(c,t[s],d)}return c}return Hv=e,Hv}var Vv,ER;function Vte(){if(ER)return Vv;ER=1;var e=Oh(),t=Hte();function n(r,s){return t(r||[],s||[],e)}return Vv=n,Vv}var Gv,CR;function it(){if(CR)return Gv;CR=1;var e;if(typeof Xk=="function")try{e={cloneDeep:lte(),constant:o0(),defaults:cte(),each:TL(),filter:BL(),find:gte(),flatten:rP(),forEach:CL(),forIn:yte(),has:qL(),isUndefined:UL(),last:wte(),map:WL(),mapValues:vte(),max:bte(),merge:Ete(),min:Cte(),minBy:Tte(),now:Ate(),pick:Ote(),range:Dte(),reduce:HL(),sortBy:zte(),uniqueId:Wte(),values:XL(),zipObject:Vte()}}catch{}return e||(e=window._),Gv=e,Gv}var Kv,TR;function Gte(){if(TR)return Kv;TR=1,Kv=e;function e(){var r={};r._next=r._prev=r,this._sentinel=r}e.prototype.dequeue=function(){var r=this._sentinel,s=r._prev;if(s!==r)return t(s),s},e.prototype.enqueue=function(r){var s=this._sentinel;r._prev&&r._next&&t(r),r._next=s._next,s._next._prev=r,s._next=r,r._prev=s},e.prototype.toString=function(){for(var r=[],s=this._sentinel,o=s._prev;o!==s;)r.push(JSON.stringify(o,n)),o=o._prev;return"["+r.join(", ")+"]"};function t(r){r._prev._next=r._next,r._next._prev=r._prev,delete r._next,delete r._prev}function n(r,s){if(r!=="_next"&&r!=="_prev")return s}return Kv}var Yv,AR;function Kte(){if(AR)return Yv;AR=1;var e=it(),t=jr().Graph,n=Gte();Yv=s;var r=e.constant(1);function s(h,f){if(h.nodeCount()<=1)return[];var p=c(h,f||r),g=o(p.graph,p.buckets,p.zeroIdx);return e.flatten(e.map(g,function(v){return h.outEdges(v.v,v.w)}),!0)}function o(h,f,p){for(var g=[],v=f[f.length-1],j=f[0],k;h.nodeCount();){for(;k=j.dequeue();)l(h,f,p,k);for(;k=v.dequeue();)l(h,f,p,k);if(h.nodeCount()){for(var x=f.length-2;x>0;--x)if(k=f[x].dequeue(),k){g=g.concat(l(h,f,p,k,!0));break}}}return g}function l(h,f,p,g,v){var j=v?[]:void 0;return e.forEach(h.inEdges(g.v),function(k){var x=h.edge(k),N=h.node(k.v);v&&j.push({v:k.v,w:k.w}),N.out-=x,d(f,p,N)}),e.forEach(h.outEdges(g.v),function(k){var x=h.edge(k),N=k.w,b=h.node(N);b.in-=x,d(f,p,b)}),h.removeNode(g.v),j}function c(h,f){var p=new t,g=0,v=0;e.forEach(h.nodes(),function(x){p.setNode(x,{v:x,in:0,out:0})}),e.forEach(h.edges(),function(x){var N=p.edge(x.v,x.w)||0,b=f(x),S=N+b;p.setEdge(x.v,x.w,S),v=Math.max(v,p.node(x.v).out+=b),g=Math.max(g,p.node(x.w).in+=b)});var j=e.range(v+g+3).map(function(){return new n}),k=g+1;return e.forEach(p.nodes(),function(x){d(j,k,p.node(x))}),{graph:p,buckets:j,zeroIdx:k}}function d(h,f,p){p.out?p.in?h[p.out-p.in+f].enqueue(p):h[h.length-1].enqueue(p):h[0].enqueue(p)}return Yv}var Xv,RR;function Yte(){if(RR)return Xv;RR=1;var e=it(),t=Kte();Xv={run:n,undo:s};function n(o){var l=o.graph().acyclicer==="greedy"?t(o,c(o)):r(o);e.forEach(l,function(d){var h=o.edge(d);o.removeEdge(d),h.forwardName=d.name,h.reversed=!0,o.setEdge(d.w,d.v,h,e.uniqueId("rev"))});function c(d){return function(h){return d.edge(h).weight}}}function r(o){var l=[],c={},d={};function h(f){e.has(d,f)||(d[f]=!0,c[f]=!0,e.forEach(o.outEdges(f),function(p){e.has(c,p.w)?l.push(p):h(p.w)}),delete c[f])}return e.forEach(o.nodes(),h),l}function s(o){e.forEach(o.edges(),function(l){var c=o.edge(l);if(c.reversed){o.removeEdge(l);var d=c.forwardName;delete c.reversed,delete c.forwardName,o.setEdge(l.w,l.v,c,d)}})}return Xv}var Zv,MR;function mn(){if(MR)return Zv;MR=1;var e=it(),t=jr().Graph;Zv={addDummyNode:n,simplify:r,asNonCompoundGraph:s,successorWeights:o,predecessorWeights:l,intersectRect:c,buildLayerMatrix:d,normalizeRanks:h,removeEmptyRanks:f,addBorderNode:p,maxRank:g,partition:v,time:j,notime:k};function n(x,N,b,S){var E;do E=e.uniqueId(S);while(x.hasNode(E));return b.dummy=N,x.setNode(E,b),E}function r(x){var N=new t().setGraph(x.graph());return e.forEach(x.nodes(),function(b){N.setNode(b,x.node(b))}),e.forEach(x.edges(),function(b){var S=N.edge(b.v,b.w)||{weight:0,minlen:1},E=x.edge(b);N.setEdge(b.v,b.w,{weight:S.weight+E.weight,minlen:Math.max(S.minlen,E.minlen)})}),N}function s(x){var N=new t({multigraph:x.isMultigraph()}).setGraph(x.graph());return e.forEach(x.nodes(),function(b){x.children(b).length||N.setNode(b,x.node(b))}),e.forEach(x.edges(),function(b){N.setEdge(b,x.edge(b))}),N}function o(x){var N=e.map(x.nodes(),function(b){var S={};return e.forEach(x.outEdges(b),function(E){S[E.w]=(S[E.w]||0)+x.edge(E).weight}),S});return e.zipObject(x.nodes(),N)}function l(x){var N=e.map(x.nodes(),function(b){var S={};return e.forEach(x.inEdges(b),function(E){S[E.v]=(S[E.v]||0)+x.edge(E).weight}),S});return e.zipObject(x.nodes(),N)}function c(x,N){var b=x.x,S=x.y,E=N.x-b,R=N.y-S,I=x.width/2,A=x.height/2;if(!E&&!R)throw new Error("Not possible to find intersection inside of the rectangle");var q,$;return Math.abs(R)*I>Math.abs(E)*A?(R<0&&(A=-A),q=A*E/R,$=A):(E<0&&(I=-I),q=I,$=I*R/E),{x:b+q,y:S+$}}function d(x){var N=e.map(e.range(g(x)+1),function(){return[]});return e.forEach(x.nodes(),function(b){var S=x.node(b),E=S.rank;e.isUndefined(E)||(N[E][S.order]=b)}),N}function h(x){var N=e.min(e.map(x.nodes(),function(b){return x.node(b).rank}));e.forEach(x.nodes(),function(b){var S=x.node(b);e.has(S,"rank")&&(S.rank-=N)})}function f(x){var N=e.min(e.map(x.nodes(),function(R){return x.node(R).rank})),b=[];e.forEach(x.nodes(),function(R){var I=x.node(R).rank-N;b[I]||(b[I]=[]),b[I].push(R)});var S=0,E=x.graph().nodeRankFactor;e.forEach(b,function(R,I){e.isUndefined(R)&&I%E!==0?--S:S&&e.forEach(R,function(A){x.node(A).rank+=S})})}function p(x,N,b,S){var E={width:0,height:0};return arguments.length>=4&&(E.rank=b,E.order=S),n(x,"border",E,N)}function g(x){return e.max(e.map(x.nodes(),function(N){var b=x.node(N).rank;if(!e.isUndefined(b))return b}))}function v(x,N){var b={lhs:[],rhs:[]};return e.forEach(x,function(S){N(S)?b.lhs.push(S):b.rhs.push(S)}),b}function j(x,N){var b=e.now();try{return N()}finally{console.log(x+" time: "+(e.now()-b)+"ms")}}function k(x,N){return N()}return Zv}var Jv,$R;function Xte(){if($R)return Jv;$R=1;var e=it(),t=mn();Jv={run:n,undo:s};function n(o){o.graph().dummyChains=[],e.forEach(o.edges(),function(l){r(o,l)})}function r(o,l){var c=l.v,d=o.node(c).rank,h=l.w,f=o.node(h).rank,p=l.name,g=o.edge(l),v=g.labelRank;if(f!==d+1){o.removeEdge(l);var j,k,x;for(x=0,++d;d<f;++x,++d)g.points=[],k={width:0,height:0,edgeLabel:g,edgeObj:l,rank:d},j=t.addDummyNode(o,"edge",k,"_d"),d===v&&(k.width=g.width,k.height=g.height,k.dummy="edge-label",k.labelpos=g.labelpos),o.setEdge(c,j,{weight:g.weight},p),x===0&&o.graph().dummyChains.push(j),c=j;o.setEdge(c,h,{weight:g.weight},p)}}function s(o){e.forEach(o.graph().dummyChains,function(l){var c=o.node(l),d=c.edgeLabel,h;for(o.setEdge(c.edgeObj,d);c.dummy;)h=o.successors(l)[0],o.removeNode(l),d.points.push({x:c.x,y:c.y}),c.dummy==="edge-label"&&(d.x=c.x,d.y=c.y,d.width=c.width,d.height=c.height),l=h,c=o.node(l)})}return Jv}var Qv,IR;function Wd(){if(IR)return Qv;IR=1;var e=it();Qv={longestPath:t,slack:n};function t(r){var s={};function o(l){var c=r.node(l);if(e.has(s,l))return c.rank;s[l]=!0;var d=e.min(e.map(r.outEdges(l),function(h){return o(h.w)-r.edge(h).minlen}));return(d===Number.POSITIVE_INFINITY||d===void 0||d===null)&&(d=0),c.rank=d}e.forEach(r.sources(),o)}function n(r,s){return r.node(s.w).rank-r.node(s.v).rank-r.edge(s).minlen}return Qv}var ex,OR;function iP(){if(OR)return ex;OR=1;var e=it(),t=jr().Graph,n=Wd().slack;ex=r;function r(c){var d=new t({directed:!1}),h=c.nodes()[0],f=c.nodeCount();d.setNode(h,{});for(var p,g;s(d,c)<f;)p=o(d,c),g=d.hasNode(p.v)?n(c,p):-n(c,p),l(d,c,g);return d}function s(c,d){function h(f){e.forEach(d.nodeEdges(f),function(p){var g=p.v,v=f===g?p.w:g;!c.hasNode(v)&&!n(d,p)&&(c.setNode(v,{}),c.setEdge(f,v,{}),h(v))})}return e.forEach(c.nodes(),h),c.nodeCount()}function o(c,d){return e.minBy(d.edges(),function(h){if(c.hasNode(h.v)!==c.hasNode(h.w))return n(d,h)})}function l(c,d,h){e.forEach(c.nodes(),function(f){d.node(f).rank+=h})}return ex}var tx,LR;function Zte(){if(LR)return tx;LR=1;var e=it(),t=iP(),n=Wd().slack,r=Wd().longestPath,s=jr().alg.preorder,o=jr().alg.postorder,l=mn().simplify;tx=c,c.initLowLimValues=p,c.initCutValues=d,c.calcCutValue=f,c.leaveEdge=v,c.enterEdge=j,c.exchangeEdges=k;function c(S){S=l(S),r(S);var E=t(S);p(E),d(E,S);for(var R,I;R=v(E);)I=j(E,S,R),k(E,S,R,I)}function d(S,E){var R=o(S,S.nodes());R=R.slice(0,R.length-1),e.forEach(R,function(I){h(S,E,I)})}function h(S,E,R){var I=S.node(R),A=I.parent;S.edge(R,A).cutvalue=f(S,E,R)}function f(S,E,R){var I=S.node(R),A=I.parent,q=!0,$=E.edge(R,A),B=0;return $||(q=!1,$=E.edge(A,R)),B=$.weight,e.forEach(E.nodeEdges(R),function(L){var M=L.v===R,F=M?L.w:L.v;if(F!==A){var T=M===q,P=E.edge(L).weight;if(B+=T?P:-P,N(S,R,F)){var O=S.edge(R,F).cutvalue;B+=T?-O:O}}}),B}function p(S,E){arguments.length<2&&(E=S.nodes()[0]),g(S,{},1,E)}function g(S,E,R,I,A){var q=R,$=S.node(I);return E[I]=!0,e.forEach(S.neighbors(I),function(B){e.has(E,B)||(R=g(S,E,R,B,I))}),$.low=q,$.lim=R++,A?$.parent=A:delete $.parent,R}function v(S){return e.find(S.edges(),function(E){return S.edge(E).cutvalue<0})}function j(S,E,R){var I=R.v,A=R.w;E.hasEdge(I,A)||(I=R.w,A=R.v);var q=S.node(I),$=S.node(A),B=q,L=!1;q.lim>$.lim&&(B=$,L=!0);var M=e.filter(E.edges(),function(F){return L===b(S,S.node(F.v),B)&&L!==b(S,S.node(F.w),B)});return e.minBy(M,function(F){return n(E,F)})}function k(S,E,R,I){var A=R.v,q=R.w;S.removeEdge(A,q),S.setEdge(I.v,I.w,{}),p(S),d(S,E),x(S,E)}function x(S,E){var R=e.find(S.nodes(),function(A){return!E.node(A).parent}),I=s(S,R);I=I.slice(1),e.forEach(I,function(A){var q=S.node(A).parent,$=E.edge(A,q),B=!1;$||($=E.edge(q,A),B=!0),E.node(A).rank=E.node(q).rank+(B?$.minlen:-$.minlen)})}function N(S,E,R){return S.hasEdge(E,R)}function b(S,E,R){return R.low<=E.lim&&E.lim<=R.lim}return tx}var nx,PR;function Jte(){if(PR)return nx;PR=1;var e=Wd(),t=e.longestPath,n=iP(),r=Zte();nx=s;function s(d){switch(d.graph().ranker){case"network-simplex":c(d);break;case"tight-tree":l(d);break;case"longest-path":o(d);break;default:c(d)}}var o=t;function l(d){t(d),n(d)}function c(d){r(d)}return nx}var rx,DR;function Qte(){if(DR)return rx;DR=1;var e=it();rx=t;function t(s){var o=r(s);e.forEach(s.graph().dummyChains,function(l){for(var c=s.node(l),d=c.edgeObj,h=n(s,o,d.v,d.w),f=h.path,p=h.lca,g=0,v=f[g],j=!0;l!==d.w;){if(c=s.node(l),j){for(;(v=f[g])!==p&&s.node(v).maxRank<c.rank;)g++;v===p&&(j=!1)}if(!j){for(;g<f.length-1&&s.node(v=f[g+1]).minRank<=c.rank;)g++;v=f[g]}s.setParent(l,v),l=s.successors(l)[0]}})}function n(s,o,l,c){var d=[],h=[],f=Math.min(o[l].low,o[c].low),p=Math.max(o[l].lim,o[c].lim),g,v;g=l;do g=s.parent(g),d.push(g);while(g&&(o[g].low>f||p>o[g].lim));for(v=g,g=c;(g=s.parent(g))!==v;)h.push(g);return{path:d.concat(h.reverse()),lca:v}}function r(s){var o={},l=0;function c(d){var h=l;e.forEach(s.children(d),c),o[d]={low:h,lim:l++}}return e.forEach(s.children(),c),o}return rx}var sx,FR;function ene(){if(FR)return sx;FR=1;var e=it(),t=mn();sx={run:n,cleanup:l};function n(c){var d=t.addDummyNode(c,"root",{},"_root"),h=s(c),f=e.max(e.values(h))-1,p=2*f+1;c.graph().nestingRoot=d,e.forEach(c.edges(),function(v){c.edge(v).minlen*=p});var g=o(c)+1;e.forEach(c.children(),function(v){r(c,d,p,g,f,h,v)}),c.graph().nodeRankFactor=p}function r(c,d,h,f,p,g,v){var j=c.children(v);if(!j.length){v!==d&&c.setEdge(d,v,{weight:0,minlen:h});return}var k=t.addBorderNode(c,"_bt"),x=t.addBorderNode(c,"_bb"),N=c.node(v);c.setParent(k,v),N.borderTop=k,c.setParent(x,v),N.borderBottom=x,e.forEach(j,function(b){r(c,d,h,f,p,g,b);var S=c.node(b),E=S.borderTop?S.borderTop:b,R=S.borderBottom?S.borderBottom:b,I=S.borderTop?f:2*f,A=E!==R?1:p-g[v]+1;c.setEdge(k,E,{weight:I,minlen:A,nestingEdge:!0}),c.setEdge(R,x,{weight:I,minlen:A,nestingEdge:!0})}),c.parent(v)||c.setEdge(d,k,{weight:0,minlen:p+g[v]})}function s(c){var d={};function h(f,p){var g=c.children(f);g&&g.length&&e.forEach(g,function(v){h(v,p+1)}),d[f]=p}return e.forEach(c.children(),function(f){h(f,1)}),d}function o(c){return e.reduce(c.edges(),function(d,h){return d+c.edge(h).weight},0)}function l(c){var d=c.graph();c.removeNode(d.nestingRoot),delete d.nestingRoot,e.forEach(c.edges(),function(h){var f=c.edge(h);f.nestingEdge&&c.removeEdge(h)})}return sx}var ax,BR;function tne(){if(BR)return ax;BR=1;var e=it(),t=mn();ax=n;function n(s){function o(l){var c=s.children(l),d=s.node(l);if(c.length&&e.forEach(c,o),e.has(d,"minRank")){d.borderLeft=[],d.borderRight=[];for(var h=d.minRank,f=d.maxRank+1;h<f;++h)r(s,"borderLeft","_bl",l,d,h),r(s,"borderRight","_br",l,d,h)}}e.forEach(s.children(),o)}function r(s,o,l,c,d,h){var f={width:0,height:0,rank:h,borderType:o},p=d[o][h-1],g=t.addDummyNode(s,"border",f,l);d[o][h]=g,s.setParent(g,c),p&&s.setEdge(p,g,{weight:1})}return ax}var ox,qR;function nne(){if(qR)return ox;qR=1;var e=it();ox={adjust:t,undo:n};function t(h){var f=h.graph().rankdir.toLowerCase();(f==="lr"||f==="rl")&&r(h)}function n(h){var f=h.graph().rankdir.toLowerCase();(f==="bt"||f==="rl")&&o(h),(f==="lr"||f==="rl")&&(c(h),r(h))}function r(h){e.forEach(h.nodes(),function(f){s(h.node(f))}),e.forEach(h.edges(),function(f){s(h.edge(f))})}function s(h){var f=h.width;h.width=h.height,h.height=f}function o(h){e.forEach(h.nodes(),function(f){l(h.node(f))}),e.forEach(h.edges(),function(f){var p=h.edge(f);e.forEach(p.points,l),e.has(p,"y")&&l(p)})}function l(h){h.y=-h.y}function c(h){e.forEach(h.nodes(),function(f){d(h.node(f))}),e.forEach(h.edges(),function(f){var p=h.edge(f);e.forEach(p.points,d),e.has(p,"x")&&d(p)})}function d(h){var f=h.x;h.x=h.y,h.y=f}return ox}var ix,UR;function rne(){if(UR)return ix;UR=1;var e=it();ix=t;function t(n){var r={},s=e.filter(n.nodes(),function(h){return!n.children(h).length}),o=e.max(e.map(s,function(h){return n.node(h).rank})),l=e.map(e.range(o+1),function(){return[]});function c(h){if(!e.has(r,h)){r[h]=!0;var f=n.node(h);l[f.rank].push(h),e.forEach(n.successors(h),c)}}var d=e.sortBy(s,function(h){return n.node(h).rank});return e.forEach(d,c),l}return ix}var lx,zR;function sne(){if(zR)return lx;zR=1;var e=it();lx=t;function t(r,s){for(var o=0,l=1;l<s.length;++l)o+=n(r,s[l-1],s[l]);return o}function n(r,s,o){for(var l=e.zipObject(o,e.map(o,function(g,v){return v})),c=e.flatten(e.map(s,function(g){return e.sortBy(e.map(r.outEdges(g),function(v){return{pos:l[v.w],weight:r.edge(v).weight}}),"pos")}),!0),d=1;d<o.length;)d<<=1;var h=2*d-1;d-=1;var f=e.map(new Array(h),function(){return 0}),p=0;return e.forEach(c.forEach(function(g){var v=g.pos+d;f[v]+=g.weight;for(var j=0;v>0;)v%2&&(j+=f[v+1]),v=v-1>>1,f[v]+=g.weight;p+=g.weight*j})),p}return lx}var cx,WR;function ane(){if(WR)return cx;WR=1;var e=it();cx=t;function t(n,r){return e.map(r,function(s){var o=n.inEdges(s);if(o.length){var l=e.reduce(o,function(c,d){var h=n.edge(d),f=n.node(d.v);return{sum:c.sum+h.weight*f.order,weight:c.weight+h.weight}},{sum:0,weight:0});return{v:s,barycenter:l.sum/l.weight,weight:l.weight}}else return{v:s}})}return cx}var ux,HR;function one(){if(HR)return ux;HR=1;var e=it();ux=t;function t(s,o){var l={};e.forEach(s,function(d,h){var f=l[d.v]={indegree:0,in:[],out:[],vs:[d.v],i:h};e.isUndefined(d.barycenter)||(f.barycenter=d.barycenter,f.weight=d.weight)}),e.forEach(o.edges(),function(d){var h=l[d.v],f=l[d.w];!e.isUndefined(h)&&!e.isUndefined(f)&&(f.indegree++,h.out.push(l[d.w]))});var c=e.filter(l,function(d){return!d.indegree});return n(c)}function n(s){var o=[];function l(h){return function(f){f.merged||(e.isUndefined(f.barycenter)||e.isUndefined(h.barycenter)||f.barycenter>=h.barycenter)&&r(h,f)}}function c(h){return function(f){f.in.push(h),--f.indegree===0&&s.push(f)}}for(;s.length;){var d=s.pop();o.push(d),e.forEach(d.in.reverse(),l(d)),e.forEach(d.out,c(d))}return e.map(e.filter(o,function(h){return!h.merged}),function(h){return e.pick(h,["vs","i","barycenter","weight"])})}function r(s,o){var l=0,c=0;s.weight&&(l+=s.barycenter*s.weight,c+=s.weight),o.weight&&(l+=o.barycenter*o.weight,c+=o.weight),s.vs=o.vs.concat(s.vs),s.barycenter=l/c,s.weight=c,s.i=Math.min(o.i,s.i),o.merged=!0}return ux}var dx,VR;function ine(){if(VR)return dx;VR=1;var e=it(),t=mn();dx=n;function n(o,l){var c=t.partition(o,function(k){return e.has(k,"barycenter")}),d=c.lhs,h=e.sortBy(c.rhs,function(k){return-k.i}),f=[],p=0,g=0,v=0;d.sort(s(!!l)),v=r(f,h,v),e.forEach(d,function(k){v+=k.vs.length,f.push(k.vs),p+=k.barycenter*k.weight,g+=k.weight,v=r(f,h,v)});var j={vs:e.flatten(f,!0)};return g&&(j.barycenter=p/g,j.weight=g),j}function r(o,l,c){for(var d;l.length&&(d=e.last(l)).i<=c;)l.pop(),o.push(d.vs),c++;return c}function s(o){return function(l,c){return l.barycenter<c.barycenter?-1:l.barycenter>c.barycenter?1:o?c.i-l.i:l.i-c.i}}return dx}var hx,GR;function lne(){if(GR)return hx;GR=1;var e=it(),t=ane(),n=one(),r=ine();hx=s;function s(c,d,h,f){var p=c.children(d),g=c.node(d),v=g?g.borderLeft:void 0,j=g?g.borderRight:void 0,k={};v&&(p=e.filter(p,function(R){return R!==v&&R!==j}));var x=t(c,p);e.forEach(x,function(R){if(c.children(R.v).length){var I=s(c,R.v,h,f);k[R.v]=I,e.has(I,"barycenter")&&l(R,I)}});var N=n(x,h);o(N,k);var b=r(N,f);if(v&&(b.vs=e.flatten([v,b.vs,j],!0),c.predecessors(v).length)){var S=c.node(c.predecessors(v)[0]),E=c.node(c.predecessors(j)[0]);e.has(b,"barycenter")||(b.barycenter=0,b.weight=0),b.barycenter=(b.barycenter*b.weight+S.order+E.order)/(b.weight+2),b.weight+=2}return b}function o(c,d){e.forEach(c,function(h){h.vs=e.flatten(h.vs.map(function(f){return d[f]?d[f].vs:f}),!0)})}function l(c,d){e.isUndefined(c.barycenter)?(c.barycenter=d.barycenter,c.weight=d.weight):(c.barycenter=(c.barycenter*c.weight+d.barycenter*d.weight)/(c.weight+d.weight),c.weight+=d.weight)}return hx}var fx,KR;function cne(){if(KR)return fx;KR=1;var e=it(),t=jr().Graph;fx=n;function n(s,o,l){var c=r(s),d=new t({compound:!0}).setGraph({root:c}).setDefaultNodeLabel(function(h){return s.node(h)});return e.forEach(s.nodes(),function(h){var f=s.node(h),p=s.parent(h);(f.rank===o||f.minRank<=o&&o<=f.maxRank)&&(d.setNode(h),d.setParent(h,p||c),e.forEach(s[l](h),function(g){var v=g.v===h?g.w:g.v,j=d.edge(v,h),k=e.isUndefined(j)?0:j.weight;d.setEdge(v,h,{weight:s.edge(g).weight+k})}),e.has(f,"minRank")&&d.setNode(h,{borderLeft:f.borderLeft[o],borderRight:f.borderRight[o]}))}),d}function r(s){for(var o;s.hasNode(o=e.uniqueId("_root")););return o}return fx}var px,YR;function une(){if(YR)return px;YR=1;var e=it();px=t;function t(n,r,s){var o={},l;e.forEach(s,function(c){for(var d=n.parent(c),h,f;d;){if(h=n.parent(d),h?(f=o[h],o[h]=d):(f=l,l=d),f&&f!==d){r.setEdge(f,d);return}d=h}})}return px}var mx,XR;function dne(){if(XR)return mx;XR=1;var e=it(),t=rne(),n=sne(),r=lne(),s=cne(),o=une(),l=jr().Graph,c=mn();mx=d;function d(g){var v=c.maxRank(g),j=h(g,e.range(1,v+1),"inEdges"),k=h(g,e.range(v-1,-1,-1),"outEdges"),x=t(g);p(g,x);for(var N=Number.POSITIVE_INFINITY,b,S=0,E=0;E<4;++S,++E){f(S%2?j:k,S%4>=2),x=c.buildLayerMatrix(g);var R=n(g,x);R<N&&(E=0,b=e.cloneDeep(x),N=R)}p(g,b)}function h(g,v,j){return e.map(v,function(k){return s(g,k,j)})}function f(g,v){var j=new l;e.forEach(g,function(k){var x=k.graph().root,N=r(k,x,j,v);e.forEach(N.vs,function(b,S){k.node(b).order=S}),o(k,j,N.vs)})}function p(g,v){e.forEach(v,function(j){e.forEach(j,function(k,x){g.node(k).order=x})})}return mx}var gx,ZR;function hne(){if(ZR)return gx;ZR=1;var e=it(),t=jr().Graph,n=mn();gx={positionX:j,findType1Conflicts:r,findType2Conflicts:s,addConflict:l,hasConflict:c,verticalAlignment:d,horizontalCompaction:h,alignCoordinates:g,findSmallestWidthAlignment:p,balance:v};function r(N,b){var S={};function E(R,I){var A=0,q=0,$=R.length,B=e.last(I);return e.forEach(I,function(L,M){var F=o(N,L),T=F?N.node(F).order:$;(F||L===B)&&(e.forEach(I.slice(q,M+1),function(P){e.forEach(N.predecessors(P),function(O){var G=N.node(O),K=G.order;(K<A||T<K)&&!(G.dummy&&N.node(P).dummy)&&l(S,O,P)})}),q=M+1,A=T)}),I}return e.reduce(b,E),S}function s(N,b){var S={};function E(I,A,q,$,B){var L;e.forEach(e.range(A,q),function(M){L=I[M],N.node(L).dummy&&e.forEach(N.predecessors(L),function(F){var T=N.node(F);T.dummy&&(T.order<$||T.order>B)&&l(S,F,L)})})}function R(I,A){var q=-1,$,B=0;return e.forEach(A,function(L,M){if(N.node(L).dummy==="border"){var F=N.predecessors(L);F.length&&($=N.node(F[0]).order,E(A,B,M,q,$),B=M,q=$)}E(A,B,A.length,$,I.length)}),A}return e.reduce(b,R),S}function o(N,b){if(N.node(b).dummy)return e.find(N.predecessors(b),function(S){return N.node(S).dummy})}function l(N,b,S){if(b>S){var E=b;b=S,S=E}var R=N[b];R||(N[b]=R={}),R[S]=!0}function c(N,b,S){if(b>S){var E=b;b=S,S=E}return e.has(N[b],S)}function d(N,b,S,E){var R={},I={},A={};return e.forEach(b,function(q){e.forEach(q,function($,B){R[$]=$,I[$]=$,A[$]=B})}),e.forEach(b,function(q){var $=-1;e.forEach(q,function(B){var L=E(B);if(L.length){L=e.sortBy(L,function(O){return A[O]});for(var M=(L.length-1)/2,F=Math.floor(M),T=Math.ceil(M);F<=T;++F){var P=L[F];I[B]===B&&$<A[P]&&!c(S,B,P)&&(I[P]=B,I[B]=R[B]=R[P],$=A[P])}}})}),{root:R,align:I}}function h(N,b,S,E,R){var I={},A=f(N,b,S,R),q=R?"borderLeft":"borderRight";function $(M,F){for(var T=A.nodes(),P=T.pop(),O={};P;)O[P]?M(P):(O[P]=!0,T.push(P),T=T.concat(F(P))),P=T.pop()}function B(M){I[M]=A.inEdges(M).reduce(function(F,T){return Math.max(F,I[T.v]+A.edge(T))},0)}function L(M){var F=A.outEdges(M).reduce(function(P,O){return Math.min(P,I[O.w]-A.edge(O))},Number.POSITIVE_INFINITY),T=N.node(M);F!==Number.POSITIVE_INFINITY&&T.borderType!==q&&(I[M]=Math.max(I[M],F))}return $(B,A.predecessors.bind(A)),$(L,A.successors.bind(A)),e.forEach(E,function(M){I[M]=I[S[M]]}),I}function f(N,b,S,E){var R=new t,I=N.graph(),A=k(I.nodesep,I.edgesep,E);return e.forEach(b,function(q){var $;e.forEach(q,function(B){var L=S[B];if(R.setNode(L),$){var M=S[$],F=R.edge(M,L);R.setEdge(M,L,Math.max(A(N,B,$),F||0))}$=B})}),R}function p(N,b){return e.minBy(e.values(b),function(S){var E=Number.NEGATIVE_INFINITY,R=Number.POSITIVE_INFINITY;return e.forIn(S,function(I,A){var q=x(N,A)/2;E=Math.max(I+q,E),R=Math.min(I-q,R)}),E-R})}function g(N,b){var S=e.values(b),E=e.min(S),R=e.max(S);e.forEach(["u","d"],function(I){e.forEach(["l","r"],function(A){var q=I+A,$=N[q],B;if($!==b){var L=e.values($);B=A==="l"?E-e.min(L):R-e.max(L),B&&(N[q]=e.mapValues($,function(M){return M+B}))}})})}function v(N,b){return e.mapValues(N.ul,function(S,E){if(b)return N[b.toLowerCase()][E];var R=e.sortBy(e.map(N,E));return(R[1]+R[2])/2})}function j(N){var b=n.buildLayerMatrix(N),S=e.merge(r(N,b),s(N,b)),E={},R;e.forEach(["u","d"],function(A){R=A==="u"?b:e.values(b).reverse(),e.forEach(["l","r"],function(q){q==="r"&&(R=e.map(R,function(M){return e.values(M).reverse()}));var $=(A==="u"?N.predecessors:N.successors).bind(N),B=d(N,R,S,$),L=h(N,R,B.root,B.align,q==="r");q==="r"&&(L=e.mapValues(L,function(M){return-M})),E[A+q]=L})});var I=p(N,E);return g(E,I),v(E,N.graph().align)}function k(N,b,S){return function(E,R,I){var A=E.node(R),q=E.node(I),$=0,B;if($+=A.width/2,e.has(A,"labelpos"))switch(A.labelpos.toLowerCase()){case"l":B=-A.width/2;break;case"r":B=A.width/2;break}if(B&&($+=S?B:-B),B=0,$+=(A.dummy?b:N)/2,$+=(q.dummy?b:N)/2,$+=q.width/2,e.has(q,"labelpos"))switch(q.labelpos.toLowerCase()){case"l":B=q.width/2;break;case"r":B=-q.width/2;break}return B&&($+=S?B:-B),B=0,$}}function x(N,b){return N.node(b).width}return gx}var yx,JR;function fne(){if(JR)return yx;JR=1;var e=it(),t=mn(),n=hne().positionX;yx=r;function r(o){o=t.asNonCompoundGraph(o),s(o),e.forEach(n(o),function(l,c){o.node(c).x=l})}function s(o){var l=t.buildLayerMatrix(o),c=o.graph().ranksep,d=0;e.forEach(l,function(h){var f=e.max(e.map(h,function(p){return o.node(p).height}));e.forEach(h,function(p){o.node(p).y=d+f/2}),d+=f+c})}return yx}var wx,QR;function pne(){if(QR)return wx;QR=1;var e=it(),t=Yte(),n=Xte(),r=Jte(),s=mn().normalizeRanks,o=Qte(),l=mn().removeEmptyRanks,c=ene(),d=tne(),h=nne(),f=dne(),p=fne(),g=mn(),v=jr().Graph;wx=j;function j(W,Z){var Y=Z&&Z.debugTiming?g.time:g.notime;Y("layout",function(){var X=Y(" buildLayoutGraph",function(){return $(W)});Y(" runLayout",function(){k(X,Y)}),Y(" updateInputGraph",function(){x(W,X)})})}function k(W,Z){Z(" makeSpaceForEdgeLabels",function(){B(W)}),Z(" removeSelfEdges",function(){U(W)}),Z(" acyclic",function(){t.run(W)}),Z(" nestingGraph.run",function(){c.run(W)}),Z(" rank",function(){r(g.asNonCompoundGraph(W))}),Z(" injectEdgeLabelProxies",function(){L(W)}),Z(" removeEmptyRanks",function(){l(W)}),Z(" nestingGraph.cleanup",function(){c.cleanup(W)}),Z(" normalizeRanks",function(){s(W)}),Z(" assignRankMinMax",function(){M(W)}),Z(" removeEdgeLabelProxies",function(){F(W)}),Z(" normalize.run",function(){n.run(W)}),Z(" parentDummyChains",function(){o(W)}),Z(" addBorderSegments",function(){d(W)}),Z(" order",function(){f(W)}),Z(" insertSelfEdges",function(){H(W)}),Z(" adjustCoordinateSystem",function(){h.adjust(W)}),Z(" position",function(){p(W)}),Z(" positionSelfEdges",function(){D(W)}),Z(" removeBorderNodes",function(){K(W)}),Z(" normalize.undo",function(){n.undo(W)}),Z(" fixupEdgeLabelCoords",function(){O(W)}),Z(" undoCoordinateSystem",function(){h.undo(W)}),Z(" translateGraph",function(){T(W)}),Z(" assignNodeIntersects",function(){P(W)}),Z(" reversePoints",function(){G(W)}),Z(" acyclic.undo",function(){t.undo(W)})}function x(W,Z){e.forEach(W.nodes(),function(Y){var X=W.node(Y),ee=Z.node(Y);X&&(X.x=ee.x,X.y=ee.y,Z.children(Y).length&&(X.width=ee.width,X.height=ee.height))}),e.forEach(W.edges(),function(Y){var X=W.edge(Y),ee=Z.edge(Y);X.points=ee.points,e.has(ee,"x")&&(X.x=ee.x,X.y=ee.y)}),W.graph().width=Z.graph().width,W.graph().height=Z.graph().height}var N=["nodesep","edgesep","ranksep","marginx","marginy"],b={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},S=["acyclicer","ranker","rankdir","align"],E=["width","height"],R={width:0,height:0},I=["minlen","weight","width","height","labeloffset"],A={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},q=["labelpos"];function $(W){var Z=new v({multigraph:!0,compound:!0}),Y=J(W.graph());return Z.setGraph(e.merge({},b,V(Y,N),e.pick(Y,S))),e.forEach(W.nodes(),function(X){var ee=J(W.node(X));Z.setNode(X,e.defaults(V(ee,E),R)),Z.setParent(X,W.parent(X))}),e.forEach(W.edges(),function(X){var ee=J(W.edge(X));Z.setEdge(X,e.merge({},A,V(ee,I),e.pick(ee,q)))}),Z}function B(W){var Z=W.graph();Z.ranksep/=2,e.forEach(W.edges(),function(Y){var X=W.edge(Y);X.minlen*=2,X.labelpos.toLowerCase()!=="c"&&(Z.rankdir==="TB"||Z.rankdir==="BT"?X.width+=X.labeloffset:X.height+=X.labeloffset)})}function L(W){e.forEach(W.edges(),function(Z){var Y=W.edge(Z);if(Y.width&&Y.height){var X=W.node(Z.v),ee=W.node(Z.w),ae={rank:(ee.rank-X.rank)/2+X.rank,e:Z};g.addDummyNode(W,"edge-proxy",ae,"_ep")}})}function M(W){var Z=0;e.forEach(W.nodes(),function(Y){var X=W.node(Y);X.borderTop&&(X.minRank=W.node(X.borderTop).rank,X.maxRank=W.node(X.borderBottom).rank,Z=e.max(Z,X.maxRank))}),W.graph().maxRank=Z}function F(W){e.forEach(W.nodes(),function(Z){var Y=W.node(Z);Y.dummy==="edge-proxy"&&(W.edge(Y.e).labelRank=Y.rank,W.removeNode(Z))})}function T(W){var Z=Number.POSITIVE_INFINITY,Y=0,X=Number.POSITIVE_INFINITY,ee=0,ae=W.graph(),ce=ae.marginx||0,ge=ae.marginy||0;function ye(se){var pe=se.x,fe=se.y,de=se.width,me=se.height;Z=Math.min(Z,pe-de/2),Y=Math.max(Y,pe+de/2),X=Math.min(X,fe-me/2),ee=Math.max(ee,fe+me/2)}e.forEach(W.nodes(),function(se){ye(W.node(se))}),e.forEach(W.edges(),function(se){var pe=W.edge(se);e.has(pe,"x")&&ye(pe)}),Z-=ce,X-=ge,e.forEach(W.nodes(),function(se){var pe=W.node(se);pe.x-=Z,pe.y-=X}),e.forEach(W.edges(),function(se){var pe=W.edge(se);e.forEach(pe.points,function(fe){fe.x-=Z,fe.y-=X}),e.has(pe,"x")&&(pe.x-=Z),e.has(pe,"y")&&(pe.y-=X)}),ae.width=Y-Z+ce,ae.height=ee-X+ge}function P(W){e.forEach(W.edges(),function(Z){var Y=W.edge(Z),X=W.node(Z.v),ee=W.node(Z.w),ae,ce;Y.points?(ae=Y.points[0],ce=Y.points[Y.points.length-1]):(Y.points=[],ae=ee,ce=X),Y.points.unshift(g.intersectRect(X,ae)),Y.points.push(g.intersectRect(ee,ce))})}function O(W){e.forEach(W.edges(),function(Z){var Y=W.edge(Z);if(e.has(Y,"x"))switch((Y.labelpos==="l"||Y.labelpos==="r")&&(Y.width-=Y.labeloffset),Y.labelpos){case"l":Y.x-=Y.width/2+Y.labeloffset;break;case"r":Y.x+=Y.width/2+Y.labeloffset;break}})}function G(W){e.forEach(W.edges(),function(Z){var Y=W.edge(Z);Y.reversed&&Y.points.reverse()})}function K(W){e.forEach(W.nodes(),function(Z){if(W.children(Z).length){var Y=W.node(Z),X=W.node(Y.borderTop),ee=W.node(Y.borderBottom),ae=W.node(e.last(Y.borderLeft)),ce=W.node(e.last(Y.borderRight));Y.width=Math.abs(ce.x-ae.x),Y.height=Math.abs(ee.y-X.y),Y.x=ae.x+Y.width/2,Y.y=X.y+Y.height/2}}),e.forEach(W.nodes(),function(Z){W.node(Z).dummy==="border"&&W.removeNode(Z)})}function U(W){e.forEach(W.edges(),function(Z){if(Z.v===Z.w){var Y=W.node(Z.v);Y.selfEdges||(Y.selfEdges=[]),Y.selfEdges.push({e:Z,label:W.edge(Z)}),W.removeEdge(Z)}})}function H(W){var Z=g.buildLayerMatrix(W);e.forEach(Z,function(Y){var X=0;e.forEach(Y,function(ee,ae){var ce=W.node(ee);ce.order=ae+X,e.forEach(ce.selfEdges,function(ge){g.addDummyNode(W,"selfedge",{width:ge.label.width,height:ge.label.height,rank:ce.rank,order:ae+ ++X,e:ge.e,label:ge.label},"_se")}),delete ce.selfEdges})})}function D(W){e.forEach(W.nodes(),function(Z){var Y=W.node(Z);if(Y.dummy==="selfedge"){var X=W.node(Y.e.v),ee=X.x+X.width/2,ae=X.y,ce=Y.x-ee,ge=X.height/2;W.setEdge(Y.e,Y.label),W.removeNode(Z),Y.label.points=[{x:ee+2*ce/3,y:ae-ge},{x:ee+5*ce/6,y:ae-ge},{x:ee+ce,y:ae},{x:ee+5*ce/6,y:ae+ge},{x:ee+2*ce/3,y:ae+ge}],Y.label.x=Y.x,Y.label.y=Y.y}})}function V(W,Z){return e.mapValues(e.pick(W,Z),Number)}function J(W){var Z={};return e.forEach(W,function(Y,X){Z[X.toLowerCase()]=Y}),Z}return wx}var vx,eM;function mne(){if(eM)return vx;eM=1;var e=it(),t=mn(),n=jr().Graph;vx={debugOrdering:r};function r(s){var o=t.buildLayerMatrix(s),l=new n({compound:!0,multigraph:!0}).setGraph({});return e.forEach(s.nodes(),function(c){l.setNode(c,{label:c}),l.setParent(c,"layer"+s.node(c).rank)}),e.forEach(s.edges(),function(c){l.setEdge(c.v,c.w,{},c.name)}),e.forEach(o,function(c,d){var h="layer"+d;l.setNode(h,{rank:"same"}),e.reduce(c,function(f,p){return l.setEdge(f,p,{style:"invis"}),p})}),l}return vx}var xx,tM;function gne(){return tM||(tM=1,xx="0.8.5"),xx}var bx,nM;function yne(){return nM||(nM=1,bx={graphlib:jr(),layout:pne(),debug:mne(),util:{time:mn().time,notime:mn().notime},version:gne()}),bx}var wne=yne();const rM=Vb(wne),uc=240,lP=130,Rb=Ha*2+rb+Ck,vne=72,pi=Rb+vne,pd=24,cP=Ha*2+pd,Hd=pi;function uP(e,t){var r;let n=uc;for(const s of e)n=Math.max(n,((r=t.get(s.id))==null?void 0:r.width)??uc);return n}const Vd=420,dP=1;function xne(e,t,n,r){return Math.min(dP,n/Math.max(1,e),r/Math.max(1,t))}function Vh(e){var n;return((n=e.data)==null?void 0:n.sessionId)??"_default"}function Gh(e,t=()=>!0){const n=new Map;for(const r of e){if(!t(r))continue;const s=Vh(r),o=n.get(s);o?o.push(r):n.set(s,[r])}return n}function bne(e,t){return((t==null?void 0:t.get(e))??0)>0?Vd:0}function kne(e,t){const n=(t==null?void 0:t.get(e))??0;return n>0?6+n*36:0}function Gd(e,t){const n=t.get(e);return{w:(n==null?void 0:n.width)??uc,h:(n==null?void 0:n.height)??lP}}function dc(e,t,n){const r=Gd(e,t);return{w:r.w+bne(e,n),h:Math.max(r.h,kne(e,n))}}function Nne(e){return[...e.keys()].sort().map(t=>`${t}:${e.get(t)}`).join("|")}function jne(e,t,n){const r=Gh(e,s=>!t.has(s.id)&&n(s.id)!=null);if(r.size===0)return e;for(const s of r.values())s.sort((o,l)=>o.id.localeCompare(l.id));return e.map(s=>{var h;if(t.has(s.id)||n(s.id))return s;const o=r.get(Vh(s));if(!o)return s;const l=(h=s.data)==null?void 0:h.parentId,c=o.find(f=>f.id===l)??o[0],d=n(c.id);return{...s,position:{x:s.position.x+d.x-c.position.x,y:s.position.y+d.y-c.position.y}}})}function Sne(e,t,n,r,s,o,l){const c=S=>dc(S,r,o),d=S=>n.get(S)??t.get(S),h=S=>{const{w:E,h:R}=Gd(S,r);return{cw:E,ch:R}},f=l!=null&&l.width>0&&l.height>0,p=Gh(e,S=>d(S.id)!=null),g=new Set;for(const[S,E]of p)E.every(R=>s.has(R.id)&&!n.has(R.id))&&g.add(S);const v=new Map,j=[];for(const S of e){const E=d(S.id);if(!E)continue;const{w:R,h:I}=c(S.id),A=Vh(S);g.has(A)?(v.get(A)??v.set(A,[]).get(A)).push(S):j.push({x:E.x,y:E.y,w:R,h:I,...h(S.id)})}if(v.size===0||f&&j.length===0)return[];const k=Hd,x=(S,E,R,I)=>j.some(A=>S<A.x+A.w+Rb&&A.x<S+R+Rb&&E<A.y+A.h+k&&A.y<E+I+k),N=uP(e,r),b=[];for(const S of[...v.keys()].sort()){const E=v.get(S);let R=1/0,I=1/0,A=-1/0,q=-1/0,$=-1/0,B=-1/0;for(const G of E){const K=d(G.id),{w:U,h:H}=c(G.id),{cw:D,ch:V}=h(G.id);R=Math.min(R,K.x),I=Math.min(I,K.y),A=Math.max(A,K.x+U),q=Math.max(q,K.y+H),$=Math.max($,K.x+D),B=Math.max(B,K.y+V)}const L=A-R,M=q-I,F=[...new Set(j.map(G=>Math.round(G.x)))].sort((G,K)=>G-K),T=F.length?F:[R],P=[0,...j.map(G=>G.y+G.h+k)].sort((G,K)=>G-K);let O=null;if(f){let G=1/0,K=1/0,U=-1/0,H=-1/0;for(const Y of j)G=Math.min(G,Y.x),K=Math.min(K,Y.y),U=Math.max(U,Y.x+Y.cw),H=Math.max(H,Y.y+Y.ch);const D=(Y,X)=>{const ee=l.width/(Math.max(U,Y+$-R)-Math.min(G,Y)+Vd),ae=l.height/(Math.max(H,X+B-I)-Math.min(K,X));return[Math.min(dP,ee,ae),Math.min(ee,ae),Math.max(ee,ae)]},V=(Y,X)=>{for(let ee=0;ee<Y.length;ee++){if(Y[ee]>X[ee]+1e-9)return!0;if(Y[ee]<X[ee]-1e-9)return!1}return!1},J=Math.round(U+Vd+N),W=[...new Set([...P,K])].sort((Y,X)=>Y-X);let Z=null;for(const Y of[...T,J])for(const X of W){if(x(Y,X,L,M))continue;const ee=D(Y,X);(Z===null||V(ee,Z))&&(Z=ee,O={x:Y,y:X})}O&&O.x===R&&O.y===I&&(O=null)}else e:for(const G of T)for(const K of P){if(K>=I)break;if(!x(G,K,L,M)){O={x:G,y:K};break e}}if(O){const G=O.x-R,K=O.y-I;for(const U of E){const H=d(U.id);t.set(U.id,{x:H.x+G,y:H.y+K})}b.push(S)}for(const G of E){const K=d(G.id),{w:U,h:H}=c(G.id);j.push({x:K.x,y:K.y,w:U,h:H,...h(G.id)})}}return b}function _ne(e,t,n,r,s,o){const l=g=>dc(g,r,s),c=new Map(e.map(g=>[g.id,Vh(g)])),d=[],h=e.map(g=>({id:g.id,pos:n.get(g.id)??t.get(g.id)})).filter(g=>g.pos!=null).sort((g,v)=>g.pos.y-v.pos.y||g.pos.x-v.pos.x||g.id.localeCompare(v.id)),f=g=>(o==null?void 0:o.has(g))===!0&&!n.has(g);for(const{id:g,pos:v}of h){if(!f(g))continue;const{w:j,h:k}=l(g);d.push({x:v.x,y:v.y,w:j,h:k,sid:c.get(g)??"_default"})}const p=[];for(const{id:g,pos:v}of h){if(f(g))continue;const{w:j,h:k}=l(g),x=c.get(g)??"_default";if(n.has(g)){d.push({x:v.x,y:v.y,w:j,h:k,sid:x});continue}let N=v.y;for(let b=0;b<d.length+1;b++){const S=d.find(E=>{const R=E.sid===x?pd:cP,I=E.sid===x?pd:Hd;return v.x<E.x+E.w+R&&E.x<v.x+j+R&&N<E.y+E.h+I&&E.y<N+k+I});if(!S)break;N=S.y+S.h+(S.sid===x?pd:Hd)}N!==v.y&&(t.set(g,{x:v.x,y:N}),p.push(g)),d.push({x:v.x,y:N,w:j,h:k,sid:x})}return p}function Ene(e,t,n,r,s,o=!1,l){const d=cP+1,h=Hd+1,f=8,p=1.75,g=200,v=.7,j=.01,k=M=>dc(M,r,l),x=M=>n.get(M)??t.get(M),N=Gh(e,M=>x(M.id)!=null),b=[],S=new Set,E=new Set,R=s.size===0;for(const M of[...N.keys()].sort()){const F=N.get(M);let T=1/0,P=1/0,O=-1/0,G=-1/0,K=!1;for(const V of F){const J=x(V.id),{w:W,h:Z}=k(V.id);T=Math.min(T,J.x),P=Math.min(P,J.y),O=Math.max(O,J.x+W),G=Math.max(G,J.y+Z),n.has(V.id)&&(K=!0)}const U=O-T,H=G-P;E.add(M);const D=s.get(M);D&&(U>D.w+f||H>D.h+f)&&S.add(M),s.set(M,{w:U,h:H}),b.push({sid:M,members:F.map(V=>V.id),x:T,y:P,w:U,h:H,anchored:K,mass:1})}for(const M of[...s.keys()])E.has(M)||s.delete(M);if(o||R)return[];let I=!1;for(let M=0;M<b.length&&!I;M++)for(let F=M+1;F<b.length;F++){const T=b[M],P=b[F];if(!(T.anchored&&P.anchored)&&Math.abs(T.x+T.w/2-(P.x+P.w/2))<(T.w+P.w)/2+d&&Math.abs(T.y+T.h/2-(P.y+P.h/2))<(T.h+P.h)/2+h){I=!0;break}}if(S.size===0&&!I)return[];if(S.size>0)for(const M of b)S.has(M.sid)&&(M.mass=8);else for(const M of b)M.mass=Math.max(1,M.w*M.h/(uc*lP));const A=new Map(b.map(M=>[M.sid,M.x])),q=new Map(b.map(M=>[M.sid,M.y])),$=new Map(b.map(M=>[M.sid,Math.min(0,M.x)])),B=new Map(b.map(M=>[M.sid,Math.min(0,M.y)]));for(let M=0;M<g;M++){const F=new Map,T=new Map;let P=0;for(let O=0;O<b.length;O++)for(let G=O+1;G<b.length;G++){const K=b[O],U=b[G];if(K.anchored&&U.anchored)continue;const H=K.x+K.w/2,D=K.y+K.h/2,V=U.x+U.w/2,J=U.y+U.h/2,W=(K.w+U.w)/2+d-Math.abs(H-V),Z=(K.h+U.h)/2+h-Math.abs(D-J);if(W<=0||Z<=0)continue;const Y=(Pe,Qe)=>!Pe.anchored&&!(Qe<0&&Pe.x<=$.get(Pe.sid)),X=(Pe,Qe)=>!Pe.anchored&&!(Qe<0&&Pe.y<=B.get(Pe.sid)),ee=(Pe,Qe,qe)=>{const Ze=Pe===Qe,lt=Ze?K.sid<U.sid?-1:1:Math.sign(Pe-Qe);return qe(K,lt)||qe(U,-lt)?lt:Ze&&(qe(K,-lt)||qe(U,lt))?-lt:0},ae=ee(H,V,Y),ce=ee(D,J,X),ge=ae!==0,ye=ce!==0;if(!ge&&!ye)continue;const se=ge&&(!ye||W*p<Z),[pe,fe,de,me]=se?[ae,W,F,Y]:[ce,Z,T,X],ne=me(K,pe),oe=me(U,-pe),Ne=K.mass,we=U.mass,Me=ne?oe?we/(Ne+we):1:0,Le=oe?ne?Ne/(Ne+we):1:0,Be=fe*v;de.set(K.sid,(de.get(K.sid)??0)+pe*Be*Me),de.set(U.sid,(de.get(U.sid)??0)-pe*Be*Le),P+=Be}for(const O of b)O.anchored||(O.x=Math.max($.get(O.sid),O.x+(F.get(O.sid)??0)),O.y=Math.max(B.get(O.sid),O.y+(T.get(O.sid)??0)));if(P<j)break}const L=[];for(const M of b){const F=M.x-A.get(M.sid),T=M.y-q.get(M.sid);if(!(Math.abs(F)<1&&Math.abs(T)<1)){for(const P of M.members){if(n.has(P))continue;const O=t.get(P);O&&t.set(P,{x:O.x+F,y:O.y+T})}L.push(M.sid)}}return L}function Cne(e,t,n,r,s,o){const l=new rM.graphlib.Graph;l.setDefaultEdgeLabel(()=>({})),l.setGraph({rankdir:n,marginx:0,marginy:0,nodesep:70,ranksep:160,edgesep:30});const c=e.filter(N=>!s.has(N)),d=new Set(c);for(const N of c){const{w:b,h:S}=dc(N,r,o);l.setNode(N,{width:b,height:S})}for(const N of t)d.has(N.source)&&d.has(N.target)&&l.setEdge(N.source,N.target);rM.layout(l);const h=new Map;let f=1/0,p=1/0,g=-1/0,v=-1/0;for(const N of c){const b=l.node(N);if(!b)continue;const{w:S,h:E}=Gd(N,r),R=dc(N,r,o),I=b.x-R.w/2,A=b.y-R.h/2;h.set(N,{x:I,y:A}),I<f&&(f=I),A<p&&(p=A),I+S>g&&(g=I+S),A+E>v&&(v=A+E)}if(Number.isFinite(f)&&Number.isFinite(p))for(const[N,b]of h)h.set(N,{x:b.x-f,y:b.y-p});const j=Number.isFinite(g)?g-f:0,k=Number.isFinite(v)?v-p:0;let x=null;for(const N of e){const b=s.get(N);if(!b)continue;const{w:S,h:E}=Gd(N,r);x=x===null?{minX:b.x,minY:b.y,maxX:b.x+S,maxY:b.y+E}:{minX:Math.min(x.minX,b.x),minY:Math.min(x.minY,b.y),maxX:Math.max(x.maxX,b.x+S),maxY:Math.max(x.maxY,b.y+E)}}return{positions:h,width:j,height:k,pinnedBox:x}}function hP(e,t,n){const r=n.direction??"LR",s=n.pinned??new Map,o=n.measured??new Map,l=n.lanes,c=Gh(e);return{laid:Array.from(c.keys()).sort().map(f=>({sid:f,...Cne(c.get(f).map(p=>p.id),t,r,o,s,l)})),gap:uP(e,o)}}const fP=e=>e.reduce((t,n)=>Math.max(t,n.width),0)+Vd,Tne=e=>e.reduce((t,n)=>t+n.height,0)+pi*Math.max(0,e.length-1);function Mb(e,t,n,r){const s=d=>{const h=[[]];let f=0;for(const p of e)f>0&&f+p.height>d&&(h.push([]),f=0),h[h.length-1].push(p),f+=p.height+pi;return h},o=[];for(let d=0;d<e.length;d++){let h=-pi;for(let f=d;f<e.length;f++)o.push(h+=e[f].height+pi)}o.sort((d,h)=>d-h);const l=d=>{let h=0,f=o.length-1;for(;h<f;){const p=h+f>>1;s(o[p]).length<=d?f=p:h=p+1}return s(o[h])};let c=[e];if(n>0&&r>0){const d=f=>xne(f.reduce((p,g)=>p+fP(g),0)+t*(f.length-1),Math.max(...f.map(Tne)),n,r);let h=d(c);for(let f=2;f<=e.length;f++){const p=l(f),g=d(p);g>h+1e-9&&(h=g,c=p)}}return c}function Ane(e,t,n,r,s){if(!(r.width>0&&r.height>0&&s.width>0&&s.height>0))return!1;const{laid:o,gap:l}=hP(e,t,n);return o.length<2?!1:Mb(o,l,r.width,r.height).length!==Mb(o,l,s.width,s.height).length}function Rne(e,t,n={}){const r=n.pinned??new Map,{laid:s,gap:o}=hP(e,t,n),l=Mb(s,o,n.availableWidth??0,n.availableHeight??0),c=new Map;let d=0;for(const h of l){const f=fP(h);let p=0;for(const{positions:g,height:v,pinnedBox:j}of h){for(const[x,N]of g)c.set(x,{x:N.x+d,y:N.y+p});let k=p+v;j&&j.maxY>k&&j.minX<d+f&&d<j.maxX&&(k=j.maxY),p=k+pi}d+=f+o}return e.map(h=>{const f=r.get(h.id);if(f)return{...h,position:f};const p=c.get(h.id);return p?{...h,position:p}:h})}function md(e,t,n){return!t.has(e)||n.has(e)}function Mne(e,t,n,r){return!t.has(e)&&md(e,n,r)}function $ne(e,t,n){const r={x:0,y:0};return t.set(e,r),n.add(e),r}function sM(e,t,n,r){n.set(e,t),r.delete(e)}const Ine=300,aM=130,One=160,oM=new WeakMap;function Lne(e,t){let n=oM.get(e);(!n||n.revision!==e.revision||n.open!==t)&&(n={revision:e.revision,open:t,byId:new Map,branches:Oz(e.agents.values())},oM.set(e,n));const{byId:r,branches:s}=n;return o=>{let l=r.get(o.id);if(!l){const c=o.kind==="root"?s.get(o.sessionId):void 0;l=c?{...o,onOpenContext:t,branch:c}:{...o,onOpenContext:t},r.set(o.id,l)}return l}}function p0(e){const t=new Map;for(const n of e.agents.values())n.tools.length>0&&t.set(n.id,Math.min(4,n.tools.length));return t}function Pne(e,t){const n=l=>{var c;return((c=l.data)==null?void 0:c.sessionId)??l.id},r=new Map;for(const l of e){const c=n(l),d=l.position.x+(l.width??uc),h=r.get(c);h?(h.minX=Math.min(h.minX,l.position.x),h.maxX=Math.max(h.maxX,d),h.minY=Math.min(h.minY,l.position.y)):r.set(c,{minX:l.position.x,maxX:d,minY:l.position.y})}const s=[];for(const[l,c]of[...r].sort((d,h)=>d[1].minX-h[1].minX)){const d=s[s.length-1];d&&c.minX<d.maxX?(d.maxX=Math.max(d.maxX,c.maxX),d.sessions.push({sid:l,top:c.minY})):s.push({maxX:c.maxX,sessions:[{sid:l,top:c.minY}]})}const o=new Map;for(const l of s)for(const{sid:c}of l.sessions.sort((d,h)=>d.top-h.top))o.set(c,o.size);return e.slice().sort((l,c)=>o.get(n(l))-o.get(n(c))||t(l)-t(c)||l.position.y-c.position.y||l.position.x-c.position.x)}function Dne(e,t){var r;let n=0;for(let s=t.parentId;s!=null&&n<e.agents.size;s=(r=e.agents.get(s))==null?void 0:r.parentId)n++;return n}function Fne(e,t,n,r,s,o,l,c,d,h,f,p,g,v,j,k,x,N,b,S){var G,K,U,H;const E=[],R=[],I=Lne(e,N);for(const D of e.agents.values()){if(!x.has(D.id))continue;const V=D.exitAt!=null,J=k!=null&&!k.has(D.id),W=[V?"rf-exiting":"",J?"rf-spotlit-out":"",j.has(D.id)?"rf-selected":""].filter(Boolean).join(" ")||void 0,Z=o.get(D.id);if(E.push({id:D.id,type:"agent",position:{x:0,y:0},data:I(D),className:W,ariaLabel:HU(D,t,j.has(D.id)),...Z?{width:Z.width,height:Z.height}:null}),D.parentId&&x.has(D.parentId)){const ee=tc(D.sessionId),ae=V,ce=j.size>0&&(j.has(D.id)||j.has(D.parentId)),ge=k!=null&&!k.has(D.id)&&!k.has(D.parentId),ye=D.state==="active"?2:1.5,se=ce?ye+1.5:ye,pe=ae?.2:ge?.12:1,fe=["sess-edge",D.state==="active"?"sess-live":"sess-idle",ae?"rf-edge-exiting":"",ce?"rf-edge-selected":""].filter(Boolean).join(" ");R.push({id:`e:${D.parentId}->${D.id}`,source:D.parentId,target:D.id,animated:(D.state==="active"||ce)&&!ae,type:"smoothstep",style:{"--session-hue":ee,strokeWidth:`calc(${se}px * var(--edge-k, 1))`,opacity:pe,transition:"var(--edge-transition)"},className:fe})}const Y=D.kind==="root"?hh(D):null,X=Y?Y.key:null;if(Y&&X&&!Sz(X)){const ee=kk(D.id),ae=tc(D.sessionId),ce=o.get(ee);E.push({id:ee,type:"recapNote",position:{x:0,y:0},data:{sessionId:D.sessionId,parentId:D.id,note:Y,noteKey:X,hue:ae},className:J?"rf-spotlit-out":void 0,selectable:!1,focusable:!1,ariaLabel:Y.kind==="recap"?`Claude Code's recap for ${D.label}`:`${D.label}: ${sa(Y.kind)}`,...ce?{width:ce.width,height:ce.height}:null}),R.push({id:`e:recap:${D.id}`,source:ee,target:D.id,type:"recapTie",className:"recap-edge",focusable:!1,style:{"--session-hue":ae}})}}const A=p0(e),q=S.size>0&&!(d&&b);q||S.clear();const $=`${g}#lanes:${Nne(A)}${q?"#held":""}`,B=new Set(E.filter(D=>D.type==="recapNote").map(D=>D.id));for(const D of Array.from(f.keys()))b&&Tz(D)&&!B.has(D)&&!s.has(D)&&(f.delete(D),p.delete(D));const L=E.filter(D=>Mne(D.id,s,f,p));if(L.length>0||$!==v.current){if(L.length>0){for(const V of L)S.delete(V.id);const D=jne(Rne(E,R,{direction:"LR",pinned:s,measured:o,availableWidth:n,availableHeight:r,lanes:A}),s,V=>md(V,f,p)?void 0:f.get(V));for(const V of D)md(V.id,f,p)&&sM(V.id,V.position,f,p);Sne(E,f,s,o,new Set(L.filter(V=>V.type!=="recapNote").map(V=>V.id)),A,{width:n,height:r});for(const V of L){if(V.type!=="recapNote")continue;const J=(G=V.data)==null?void 0:G.parentId;if(!J)continue;const W=s.get(J)??(md(J,f,p)?void 0:f.get(J));if(!W)continue;const Z=((K=o.get(V.id))==null?void 0:K.width)??Ine,Y=((U=o.get(V.id))==null?void 0:U.height)??aM,X=((H=o.get(J))==null?void 0:H.height)??aM;sM(V.id,{x:W.x-One-Z,y:W.y+(X-Y)/2},f,p)}}_ne(E,f,s,o,A,q?S:void 0),v.current=$}const M=Ene(E,f,s,o,l,!d||h,A);M.length>0&&c(M);const F=JJ(e.agents.values());b&&td(f,F),td(p,F),b&&td(s,F),td(o,ZJ(e.agents.values()));const T=[];let P=!1;for(const D of E){let V=s.get(D.id)??f.get(D.id);V||(V=$ne(D.id,f,p),P=!0),T.push({...D,position:V})}return P&&(v.current=""),{nodes:Pne(T,D=>{if(D.type==="recapNote")return-1;const V=e.agents.get(D.id);return V?Dne(e,V):0}),edges:R}}function Bne(e){return e.slice().sort((t,n)=>t.y-n.y||t.x-n.x)}function qne(e,t,n){var l;if(e.length===0)return null;const r=Bne(e),s=t?r.findIndex(c=>c.id===t):-1,o=s===-1?n===1?0:r.length-1:(s+n+r.length)%r.length;return((l=r[o])==null?void 0:l.id)??null}const Une=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Escape","Backspace"]);function zne(e,t){return t==null?{kind:"deck",nodeId:null}:e.key==="Enter"||e.key===" "?{kind:"activate",nodeId:t,additive:e.shiftKey}:Une.has(e.key)?{kind:"node",nodeId:t}:{kind:"deck",nodeId:t}}const Wne=new Set(["","BODY","HTML","#DOCUMENT"]);function Hne(e){return!e||Ni(e)?!1:!Wne.has(String(e.tagName??"").toUpperCase())}const pP="react-flow__node";function m0(e){var t,n;return!!e&&((n=(t=e.classList)==null?void 0:t.contains)==null?void 0:n.call(t,pP))===!0}function mP(e){try{const t=document.querySelector(`.${pP}[data-id="${CSS.escape(e)}"]`);t==null||t.focus({preventScroll:!0})}catch{}}let Za=null,li=null;const $b=new Set,Ib=()=>{for(const e of $b)e()},Vne=e=>($b.add(e),()=>{$b.delete(e)}),iM=()=>Za,Gne=90;function gP(e){!li||e!=null&&li.at.id!==e||(clearTimeout(li.timer),li=null)}function yP(e,t,n="pointer"){gP();const r={id:e,anchor:t,by:n};if(Za||n==="focus"){Za=r,Ib();return}li={at:r,timer:setTimeout(()=>{li=null,Za=r,Ib()},Gne)}}function ia(e){gP(e),!(!Za||e!=null&&Za.id!==e)&&(Za=null,Ib())}function Kne({agentFor:e,recapFor:t,labelFor:n,bounds:r}){const s=y.useSyncExternalStore(Vne,iM,iM),o=s?e(s.id):void 0,l=s&&!o?t(s.id):void 0,c=s!=null&&(!o&&!l||!s.anchor.isConnected);return y.useEffect(()=>{c&&s&&ia(s.id)},[c,s]),!s||c?null:o?a.jsx(Xne,{a:o,anchor:s.anchor,parentLabel:o.parentId?n(o.parentId):void 0,bounds:r},s.id):l?a.jsx(Yne,{r:l,anchor:s.anchor,bounds:r},s.id):null}function wP(e,t){const n=y.useRef(null),r=y.useCallback(()=>{const s=n.current;if(!s||!e.isConnected)return;s.style.maxHeight="";const o=Ik(e.getBoundingClientRect(),{width:s.offsetWidth,height:s.offsetHeight},t());s.style.top=`${o.top}px`,s.style.left=`${o.left}px`,s.style.maxHeight=o.maxHeight==null?"":`${o.maxHeight}px`,s.dataset.side=o.side},[e,t]);return y.useLayoutEffect(()=>{r()}),n}function Yne({r:e,anchor:t,bounds:n}){const r=wP(t,n),s=Ii(3e4),o=e.note,l=o.kind==="recap",c=Id(o.at,s);return Pt.createPortal(a.jsxs("div",{ref:r,className:"ap-peek node-peek recap-peek",role:"tooltip",id:"node-peek",style:{"--session-hue":e.hue},children:[a.jsxs("div",{className:"node-peek-head",children:[a.jsxs("span",{className:"recap-peek-mark",children:[a.jsx(Ad,{recap:l}),sa(o.kind)]}),a.jsx("span",{className:"node-peek-time",title:c.title,children:c.label})]}),e.sessionLabel&&a.jsx("div",{className:"node-peek-kind",children:a.jsxs("span",{children:[fh(o)," · ",e.sessionLabel]})}),a.jsx("p",{className:"recap-peek-text",children:o.text}),o.reply&&a.jsxs("p",{className:"recap-peek-text",children:["Suggested reply: “",o.reply,"”"]}),a.jsx("p",{className:"node-peek-hint",children:"Click to go to the session · double-click for its details"})]}),document.body)}function Xne({a:e,anchor:t,parentLabel:n,bounds:r}){const s=wP(t,r),o=Ii(1e3),l=xk(e.sessionName,e.sessionTitle),c=e.toolErrorCount??0,d=e.tools.filter(k=>!k.endedAt).length,h=gn(e,o).total,f=e.usage.inputTokens+e.usage.outputTokens,p=e.kind==="root"&&En(e.waiting),g=nI(e),v=e.kind==="root"?"session":n?`subagent of ${n}`:"subagent",j=[`${e.toolCount} ${e.toolCount===1?"tool":"tools"}`,d>0?`${d} in-flight`:null,f>0?`${st(f)} tok`:null,h>0?`${We(h)}${nc(e,o)>0?"+":""}`:null].filter(Boolean).join(" · ");return Pt.createPortal(a.jsxs("div",{ref:s,className:"ap-peek node-peek",role:"tooltip",id:"node-peek",children:[a.jsxs("div",{className:"node-peek-head",children:[a.jsx("span",{className:"node-peek-name",title:e.label,children:e.label}),a.jsxs("span",{className:"node-peek-time",children:[e.synthetic?"≥ ":"",ki(e.startedAt,e.endedAt,o)]})]}),a.jsxs("div",{className:"node-peek-kind",children:[a.jsxs("span",{className:"node-peek-state","data-kind":Jx(e.state),children:[a.jsx(xI,{kind:Jx(e.state)}),xi(e.state)]}),a.jsx("span",{children:v}),e.model?a.jsx("span",{children:ks(e.model)}):null]}),e.kind==="root"&&l.face&&a.jsx("p",{className:"node-peek-title",title:l.face,children:l.face}),e.kind==="root"&&e.waiting&&a.jsxs("p",{className:`node-peek-wait${p?" warn":""}`,children:[p&&a.jsx(Sk,{}),a.jsxs("span",{className:"node-peek-said",title:Td(e.waiting),children:[a.jsx("span",{className:"node-peek-since",children:a.jsx("b",{children:ki(e.waiting.since,void 0,o)})}),Td(e.waiting)]})]}),g&&a.jsxs("p",{className:"node-peek-blind",children:[a.jsx("span",{className:"approval-blind-dot","aria-hidden":!0}),g.label]}),a.jsxs("p",{className:"node-peek-facts",children:[j,c>0&&a.jsxs("span",{className:"node-peek-failed",children:[" · ",c," failed"]})]}),e.branch&&e.branch.total>0&&a.jsx("p",{className:"node-peek-branch",children:fI(e.branch)}),a.jsx("p",{className:"node-peek-hint",children:"Click to go to the session · double-click for details"})]}),document.body)}function Zne(e){const t=e.minZoom??nJ,n=e.maxZoom??rJ,r=e.fill??.9,s=e.insets.left,o=e.insets.top,l=Math.max(1,e.pane.width-e.insets.left-e.insets.right),c=Math.max(1,e.pane.height-e.insets.top-e.insets.bottom),d=e.context,h=e.anchor,f=Math.min(l/Math.max(1,d.width),c/Math.max(1,d.height))*r,p=Math.max(t,Math.min(n,f)),g=(v,j,k,x,N,b)=>{let S=v+(j-x*p)/2-k*p;const E=N*p+S,R=(N+b)*p+S;return b*p<=j?E<v?S+=v-E:R>v+j&&(S-=R-(v+j)):S+=v-E,S};return{x:g(s,l,d.x,d.width,h.x,h.width),y:g(o,c,d.y,d.height,h.y,h.height),zoom:p}}function Jne(e){let t=1/0,n=1/0,r=-1/0,s=-1/0;for(const o of e)t=Math.min(t,o.x),n=Math.min(n,o.y),r=Math.max(r,o.x+o.width),s=Math.max(s,o.y+o.height);return Number.isFinite(t)?{x:t,y:n,width:r-t,height:s-n}:null}function Cn(e){const t=y.useRef(e);return t.current=e,t}const Ob=80,Lb=.86;function vP(e){if(!e)return 0;const t=e.getBoundingClientRect();let n=t.right;for(const r of document.querySelectorAll(".sysdetail:not(.leaving), .usage-panel:not(.leaving)")){const s=r.getBoundingClientRect();s.width>0&&s.left>t.left&&(n=Math.min(n,s.left))}return Math.max(0,t.right-n)}function Qne({canvasRef:e,canvasSize:t,machinePhase:n,usagePhase:r,usagePanelOpen:s,detailShown:o}){const[l,c]=y.useState(0);y.useEffect(()=>{const p=vP(e.current);c(g=>Math.abs(g-p)>40?p:g)},[n,r,s,o,t.w]);const d=Cn(l),h=t.w>0?Math.max(0,(t.w-l-Ob*2)*Lb):0,f=t.h>0?Math.max(0,(t.h-Ob*2)*Lb):0;return{railInsetRef:d,availableWidth:h,availableHeight:f}}const lM=1e-6;function Wl(e){return Number.isFinite(e[0])&&Number.isFinite(e[1])&&Number.isFinite(e[2])&&e[2]>0}function cM(e,t,n){return Math.abs(e[2]-t[2])<=lM*t[2]&&Math.hypot(e[0]-t[0],e[1]-t[1])<=lM*n}function ere(e,t){const n=t[2]/e[2];return r=>[e[0]+(t[0]-e[0])*r,e[1]+(t[1]-e[1])*r,e[2]*n**r]}function tre(e,t,n){const r=e(0),s=e(.5),o=e(1);if(!Wl(r)||!Wl(s)||!Wl(o))return!1;const l=Math.max(t[2],n[2]);return cM(r,t,l)&&cM(o,n,l)}function nre(e){return(t,n)=>{const r=e(t,n),s=tre(r,t,n)?r:ere(t,n);let o=Wl(t)?t:n;return l=>{const c=s(l);return Wl(c)&&(o=c),o}}}function rre(e){return Number.isFinite(e.x)&&Number.isFinite(e.y)&&Number.isFinite(e.zoom)&&e.zoom>0}const uM=new WeakSet,xP=420;function sre(){const e=Ai(),t=bt(),n=y.useCallback((d,h)=>{if(!rre(d))return;if(Kx({durationMs:h,documentHidden:document.hidden})){e.setViewport(d,{duration:h});return}const{d3Zoom:f,d3Selection:p}=t.getState(),g=p==null?void 0:p.property("__zoom");if(f&&p&&g&&g.k>0&&d.zoom>0){f.transform(p,g.scale(d.zoom/g.k).translate((d.x-g.x)/d.zoom,(d.y-g.y)/d.zoom));return}e.setViewport(d,{duration:0})},[e,t]);y.useEffect(()=>{const d=h=>{!h||uM.has(h)||(uM.add(h),h.interpolate(nre(h.interpolate())))};return d(t.getState().d3Zoom),t.subscribe(h=>d(h.d3Zoom))},[t]);const r=y.useRef(null),s=y.useRef(0),o=y.useRef(0),l=y.useCallback((d,h)=>{const f=++s.current;return n(d,h),o.current=Date.now(),r.current=Kx({durationMs:h,documentHidden:document.hidden})?{target:d,until:Date.now()+h+60}:null,f},[n]),c=y.useCallback((d=500)=>{const h=Ob,f=1,p=.2,g=Lb;try{const v=document.querySelector(".canvas-wrap"),j=Array.from(document.querySelectorAll(".react-flow__node")).filter(P=>P.offsetWidth>0);if(!v||j.length===0)return;const k=v.getBoundingClientRect(),x=e.getViewport();if(!Number.isFinite(x.zoom)||x.zoom<=0)return;const N=P=>(P-k.left-x.x)/x.zoom,b=P=>(P-k.top-x.y)/x.zoom,S=j.map(P=>P.getBoundingClientRect()),E=Math.min(...S.map(P=>N(P.left))),R=Math.max(...S.map(P=>N(P.right))),I=Math.min(...S.map(P=>b(P.top))),A=Math.max(...S.map(P=>b(P.bottom))),q=R-E,$=A-I;if(!(q>0&&$>0))return;const B=vP(v),L=P=>Math.max(p,Math.min(f,(k.width-B-h*2)/(q+P)*g,(k.height-h*2)/$*g)),M=tJ(L(xP),L(0)),F={x:h-E*M,y:Math.max(h,(k.height-$*M)/2)-I*M,zoom:M},T=l(F,d);window.setTimeout(()=>{var P;try{if(((P=r.current)==null?void 0:P.target)===F&&(r.current=null),s.current!==T)return;const O=e.getViewport();(Math.abs(O.zoom-M)>.01||Math.abs(O.x-F.x)>2)&&n(F,0)}catch{}},d+60)}catch{}},[e,n,l]);return y.useEffect(()=>{const d=()=>{if(!document.hidden)return;const h=r.current;if(r.current=null,!(!h||Date.now()>h.until)){try{n(h.target,0)}catch{}o.current=Date.now()}};return document.addEventListener("visibilitychange",d),()=>document.removeEventListener("visibilitychange",d)},[n]),{applyViewport:n,moveCamera:l,fitLeft:c,cameraEpochRef:s,lastFitTimeRef:o}}const are=450;function ore({canvasRef:e,stateRef:t,measuredRef:n,nodesRef:r,railInsetRef:s,moveCamera:o,disableAutoFit:l,lastFocusRef:c,focusAgentRef:d,selectAgent:h,primarySelectedIdRef:f}){const p=y.useCallback(j=>{var q;const k=e.current,x=t.current.agents.get(j);if(!k||!x)return;const N=p0(t.current),b=($,B)=>{const L=n.current.get($.id);if(!L)return null;const M=B&&N.has($.id)?xP:0;return{x:$.position.x,y:$.position.y,width:L.width+M,height:L.height}},S=r.current.find($=>$.id===j),E=S?b(S,!1):null;if(!E)return;const R=[];for(const $ of r.current){if($.type!=="agent"&&$.type!=="recapNote"||((q=$.data)==null?void 0:q.sessionId)!==x.sessionId)continue;const B=b($,$.type==="agent");B&&R.push(B)}const I=k.getBoundingClientRect(),A=Zne({pane:{width:I.width,height:I.height},insets:{top:56,left:72,bottom:32,right:s.current+32},context:Jne(R)??E,anchor:E});ia(),l(),c.current={id:j,at:Date.now()},o(A,are)},[o,l]);d.current=p;const g=y.useCallback(j=>{const k=r.current.filter(S=>S.type==="agent"),x=qne(k.map(S=>({id:S.id,x:S.position.x,y:S.position.y})),f.current,j),N=x?k.find(S=>S.id===x):void 0;if(!N)return;const b=m0(document.activeElement);h(N.id,!1),window.setTimeout(()=>{try{p(N.id)}catch{}b&&mP(N.id)},30)},[h,p]),v=y.useCallback(j=>{h(j,!1),window.setTimeout(()=>{try{p(j)}catch{}},60)},[h,p]);return{focusAgent:p,stepAgent:g,focusSession:v}}function ire({nodesRef:e,stateRef:t,canvasRef:n,railInsetRef:r}){const s=y.useCallback(d=>{const h=e.current.find(f=>f.id===d&&f.type==="agent");return h?h.data:void 0},[]),o=y.useCallback(d=>{var h;return(h=t.current.agents.get(d))==null?void 0:h.label},[]),l=y.useCallback(d=>{var p;const h=e.current.find(g=>g.id===d&&g.type==="recapNote");if(!h)return;const f=h.data;return{note:f.note,hue:f.hue,sessionLabel:(p=t.current.agents.get(f.parentId))==null?void 0:p.label}},[]),c=y.useCallback(()=>{var f;const d=(f=n.current)==null?void 0:f.getBoundingClientRect(),h=document.documentElement;return d?{width:d.right-r.current,height:d.bottom}:{width:h.clientWidth,height:h.clientHeight}},[]);return{peekAgent:s,peekLabel:o,peekRecap:l,peekBounds:c}}function lre(e){const t=new Set(e.pins),n=new Map,r=new Map;for(const[s,o]of e.positions)n.set(s,o),t.has(s)&&r.set(s,o);return{positions:n,pinned:r,restored:new Set(n.keys())}}function dM(e){return Object.entries(e??{}).filter(([,t])=>t&&typeof t.x=="number"&&typeof t.y=="number")}function cre(e){const t={positions:[],pins:[]};if(!e)return t;let n;try{n=JSON.parse(e)}catch{return t}if(!n||typeof n!="object")return t;if(!("v"in n)){const s=dM(n);return{positions:s,pins:s.map(([o])=>o)}}const r=n;return{positions:dM(r.positions),pins:Array.isArray(r.pins)?r.pins:[]}}function ure(e,t){const n={};for(const[r,s]of e)n[r]=s;for(const[r,s]of t)n[r]=s;return JSON.stringify({v:2,positions:n,pins:Array.from(t.keys())})}function dre(e){if(!e)return null;let t;try{t=JSON.parse(e)}catch{return null}return!(typeof(t==null?void 0:t.width)=="number"&&typeof(t==null?void 0:t.height)=="number")||!(t.width>0&&t.height>0)?null:{width:t.width,height:t.height}}const g0="agent-dag.layout",y0="agent-dag.layoutFrame",w0="agent-dag.viewport";function hre(){return cre(Je(g0))}function hc(e,t){Ye(g0,ure(e,t))}function fre(){return dre(Je(y0))}function bP(e){Ye(y0,JSON.stringify(e))}function pre(){return cq(Je(w0))}function mre(e){Ye(w0,JSON.stringify(e))}function kP(){ws(g0),ws(w0),ws(y0)}function gre(e){const t=y.useState(()=>lre(hre()))[0],n=y.useRef(t.pinned),r=y.useRef(t.positions),s=y.useRef(new Set),o=y.useRef(""),[l,c]=y.useState(0),d=y.useState(fre)[0],h=y.useRef(d),f=y.useCallback(()=>{n.current.clear(),r.current.clear(),o.current="",kP(),c(p=>p+1),window.setTimeout(()=>{hc(r.current,n.current),h.current&&bP(h.current),e(500)},80)},[e]);return{restoredLayout:t,pinnedRef:n,positionsRef:r,provisionalRef:s,lastLayoutSigRef:o,layoutEpoch:l,setLayoutEpoch:c,lastLayoutFrameRef:h,handleRelayout:f}}function yre(e,t){const{positionsRef:n,pinnedRef:r}=t,s=y.useRef(null);y.useEffect(()=>(s.current!=null&&window.clearTimeout(s.current),s.current=window.setTimeout(()=>{hc(n.current,r.current)},1500),()=>{s.current!=null&&window.clearTimeout(s.current)}),[e])}function wre({nodes:e,edges:t,settled:n,dragging:r,availableWidth:s,availableHeight:o,layout:l,camera:c,rf:d,measuredRef:h,stateRef:f,lastFocusRef:p,primarySelectedIdRef:g,focusAgentRef:v,autoFitDisabledRef:j}){const{lastLayoutFrameRef:k,pinnedRef:x,positionsRef:N,provisionalRef:b,lastLayoutSigRef:S,setLayoutEpoch:E}=l,{applyViewport:R,fitLeft:I,cameraEpochRef:A,lastFitTimeRef:q}=c;y.useEffect(()=>{if(!n||r)return;const $={width:s,height:o};if(!($.width>0&&$.height>0))return;const B=k.current;if(k.current=$,bP($),!B||B.width===$.width&&B.height===$.height)return;const L={direction:"LR",pinned:x.current,measured:h.current,lanes:p0(f.current)};if(!Ane(e,t,L,B,$))return;const M=p.current&&Date.now()-p.current.at<1500?p.current.id:null,F=M??g.current,T=F?x.current.get(F)??N.current.get(F):void 0;for(const P of Array.from(N.current.keys()))x.current.has(P)||N.current.delete(P);b.current.clear(),S.current="",E(P=>P+1),window.setTimeout(()=>{if(hc(N.current,x.current),j.current){if(M){v.current(M);return}const P=F?x.current.get(F)??N.current.get(F):void 0;if(T&&P&&(P.x!==T.x||P.y!==T.y)){const O=d.getViewport();A.current+=1,R({x:O.x-(P.x-T.x)*O.zoom,y:O.y-(P.y-T.y)*O.zoom,zoom:O.zoom},0),q.current=Date.now()}return}I(500)},80)},[s,o,n,r,I,d,R])}function vre(e,t,n,r,s){const o=[];for(const l of e)!yh(l,t)||n.has(l.id)||o.push(l.id+(l.parentId?`>${l.parentId}`:""));return o.sort(),`${o.join("|")}#sv${r}.${s}`}const v0="agent-dag.removedNodes";function xre(e){try{const t=JSON.parse((e==null?void 0:e.getItem(v0))??"[]");return new Set(Array.isArray(t)?t.filter(n=>typeof n=="string"):[])}catch{return new Set}}function hM(e,t){try{e==null||e.setItem(v0,JSON.stringify([...t]))}catch{}}function NP(e,t){const n=new Map(e.map(o=>[o.id,o.parentId])),r=new Set(t),s=o=>{if(r.has(o))return!0;const l=new Set([o]);let c=n.get(o);for(;c&&!l.has(c);){if(r.has(c))return r.add(o),!0;l.add(c),c=n.get(c)}return!1};return o=>s(o.id)||s(o.sessionId??o.id)}function bre(e,t){if(t.size===0)return new Set;const n=[...e],r=NP(n,t);return new Set(n.filter(r).map(s=>s.id))}function kre(e,t,n){const r=c=>({id:c.id,parentId:c.data.parentId,sessionId:c.data.sessionId}),s=NP(e.map(r),n),o=e.filter(c=>!s(r(c))),l=new Set(o.map(c=>c.id));return{nodes:o,edges:t.filter(c=>l.has(c.source)&&l.has(c.target))}}function Nre(e,t){let n=null;for(const r of t)e.has(r)&&(n??(n=new Set(e)),n.delete(r));return n??e}function jre(e,t){return t.size===0?[]:[...e].filter(n=>t.has(n.id)).map(n=>n.id)}function Sre(e){let t=e.kind==="subagent"?e.startedAt:-1/0;const n=e.tools[e.tools.length-1];n&&n.startedAt>t&&(t=n.startedAt);const r=e.prompts[e.prompts.length-1];return r&&r.at>t&&(t=r.at),e.lastOutputAt!=null&&e.lastOutputAt>t&&(t=e.lastOutputAt),t}function _re(e,t,n){let r=null;for(const s of t)e.has(s)||(r??(r=new Map(e)),r.set(s,n));for(const s of e.keys())t.has(s)||(r??(r=new Map(e)),r.delete(s));return r??e}function Ere(e,t,n,r){if(n.size===0)return[];let s=1/0;for(const l of r.values())l<s&&(s=l);const o=new Set;for(const l of t){const c=e.get(l);if(!c)continue;const d=Sre(c);if(d<=s)continue;const h=[],f=new Set,p=v=>{var j;for(let k=v;k&&!f.has(k);k=(j=e.get(k))==null?void 0:j.parentId)f.add(k),n.has(k)&&h.push(k)};p(c.id),p(c.sessionId);let g=-1/0;for(const v of h)g=Math.max(g,r.get(v)??1/0);if(d>g)for(const v of h)o.add(v)}return[...o]}const jP="sessionGroup";function Cre(e,t){var r,s;if(e.type===jP)return"transparent";if(En((r=e.data)==null?void 0:r.waiting))return t("--warn");if(e.type==="recapNote")return t("--muted");const n=(s=e.data)==null?void 0:s.state;return t(n==="err"?"--err":n==="active"?"--inflight":"--ok")}const nd=Ha;function Tre(e){const t=new Map;for(const r of e){const s=r.data;if(!(s!=null&&s.sessionId)||s.exitAt!=null)continue;const o=r.width,l=r.height;if(o==null||l==null)continue;const c=r.position.x,d=r.position.y,h=c+o,f=d+l,p=t.get(s.sessionId);p?(p.minX=Math.min(p.minX,c),p.minY=Math.min(p.minY,d),p.maxX=Math.max(p.maxX,h),p.maxY=Math.max(p.maxY,f)):t.set(s.sessionId,{minX:c,minY:d,maxX:h,maxY:f})}const n=[];for(const[r,s]of t){const o=s.maxX-s.minX+nd*2,l=s.maxY-s.minY+nd*2;n.push({id:`group:${r}`,type:jP,position:{x:s.minX-nd,y:s.minY-nd},data:{sessionId:r,w:o,h:l},width:o,height:l,style:{width:o,height:l},zIndex:-1,draggable:!0,selectable:!1,focusable:!1,deletable:!1,connectable:!1})}return n}function Are(e,t){if(!t||!e.agents.get(t))return null;const r=new Set([t]);let s=t;for(;s;){const l=e.agents.get(s);if(!(l!=null&&l.parentId)||r.has(l.parentId))break;r.add(l.parentId),s=l.parentId}let o=!0;for(;o;){o=!1;for(const l of e.agents.values())l.parentId&&r.has(l.parentId)&&!r.has(l.id)&&(r.add(l.id),o=!0)}return r}function Rre(e,t){const n=new Set;for(const r of t){const s=Are(e,r);if(s)for(const o of s)n.add(o)}return n.size>0?n:null}function Mre({stateRef:e,now:t,removedAgentIds:n,sizeVersion:r,domSizeVersion:s}){return y.useMemo(()=>vre(e.current.agents.values(),t,n,r,s),[e.current,e.current.revision,t,r,s,n])}function $re({stateRef:e,now:t,availableWidth:n,availableHeight:r,layout:s,measuredRef:o,onBubble:l,settled:c,dragging:d,layoutSig:h,selectedIds:f,openContext:p,historyReplayed:g,removedNodes:v,removedAgentIds:j,dragTick:k,dragPatchRef:x,dragMoveTick:N}){const{pinnedRef:b,positionsRef:S,provisionalRef:E,lastLayoutSigRef:R,restoredLayout:I,layoutEpoch:A}=s,q=y.useMemo(()=>Rre(e.current,f),[e.current,e.current.revision,f]),$=y.useMemo(()=>{const O=q7(e.current,t);for(const G of j)O.delete(G);return O},[e.current,e.current.revision,t,j]),B=y.useRef(new Map),L=Az(),{nodes:M,edges:F}=y.useMemo(()=>{const O=Fne(e.current,t,n,r,b.current,o.current,B.current,l,c,d,S.current,E.current,h,R,f,q,$,p,g,I.restored);return kre(O.nodes,O.edges,v)},[e.current,e.current.revision,t,n,r,c,d,h,f,q,$,p,k,L,v,A,g]),T=y.useMemo(()=>Tre(M),[M]),P=y.useMemo(()=>{const O=[...T,...M],G=x.current;return!G||G.size===0?O:O.map(K=>{const U=G.get(K.id);return U?{...K,position:U}:K})},[T,M,N]);return{spotlightSet:q,visibleAgentIds:$,nodes:M,edges:F,allNodes:P}}function Ire(e,t,n){const r=e.x*t.zoom+t.x,s=e.y*t.zoom+t.y,o=(e.x+e.width)*t.zoom+t.x,l=(e.y+e.height)*t.zoom+t.y;return o>0&&r<n.width&&l>0&&s<n.height}function Ore({pane:e,viewport:t,boxes:n}){if(!e||!(e.width>0)||!(e.height>0)||!Number.isFinite(t.zoom)||t.zoom<=0||!Number.isFinite(t.x)||!Number.isFinite(t.y))return!1;let r=!1;for(const s of n)if(r=!0,Ire(s,t,e))return!1;return r}function Lre({layoutSig:e,rf:t,stateRef:n,measuredRef:r,pinnedRef:s,positionsRef:o,paneSizeRef:l,lastInteractRef:c,autoFitDisabledRef:d,lastFitTimeRef:h,fitLeft:f}){const p=y.useRef(null),g=y.useRef("");y.useEffect(()=>{const v=setInterval(()=>{if(d.current||Date.now()-c.current<800)return;const j=n.current,k=Date.now(),x=[];for(const b of j.agents.values())yh(b,k)&&x.push({id:b.id});if(x.length===0)return;const N=[];for(const{id:b}of x){const S=r.current.get(b),E=s.current.get(b)??o.current.get(b);!S||!E||N.push({x:E.x,y:E.y,width:S.width,height:S.height})}Ore({pane:l.current,viewport:t.getViewport(),boxes:N})&&f(600)},1500);return()=>clearInterval(v)},[t]),y.useEffect(()=>{if(g.current===e)return;const v=g.current;if(g.current=e,!v||d.current)return;Date.now()-h.current>1200&&f(400),p.current&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>{d.current||f(500)},280)},[e,t,f])}function Pre({stateRef:e,pinnedRef:t,positionsRef:n,canvasRef:r,clearSelection:s,primarySelectedId:o}){const[l,c]=y.useState(()=>xre(Fl())),[d,h]=y.useState(null),f=y.useMemo(()=>bre(e.current.agents.values(),l),[e.current,e.current.revision,l]),p=y.useCallback(N=>{const b=e.current.agents.get(N);b&&(c(S=>{const E=new Set(S);return E.add(N),hM(Fl(),E),E}),h({id:N,label:b.label}),t.current.delete(N),n.current.delete(N),s())},[s]),g=y.useCallback(()=>{o&&p(o)},[o,p]),v=d&&l.has(d.id)?d:null;y.useEffect(()=>{var N;d&&((N=r.current)==null||N.focus())},[d]);const j=y.useCallback(N=>{const b=[...N];c(S=>{const E=Nre(S,b);return E!==S&&hM(Fl(),E),E})},[]),k=y.useCallback(()=>{j([...l]),h(null)},[j,l]),x=y.useCallback(()=>{c(new Set),h(null),ws(v0)},[]);return{removedNodes:l,lastRemoval:d,removedAgentIds:f,removeNode:p,removeSelectedNode:g,removalNotice:v,bringBack:j,bringBackAll:k,forgetRemovals:x}}function Dre({stateRef:e,waitingSessions:t,removedAgentIds:n,removedNodes:r,bringBack:s}){const o=y.useRef(new Map);y.useEffect(()=>{o.current=_re(o.current,r,Date.now());const l=[...jre(t,n),...Ere(e.current.agents,n,r,o.current)];l.length>0&&s(l)},[t,n,r,s])}function Fre({waiting:e,running:t,connected:n=!0}){return{title:e>0?`(${e}) ${xt}`:xt,icon:n?e>0?"waiting":t>0?"running":"idle":"offline"}}const SP=Object.freeze({offline:"/state/favicon-error.svg",waiting:"/state/favicon-waiting.svg",running:"/state/favicon-syncing.svg",idle:"/favicon.svg"}),_P=Object.freeze({offline:"/state/favicon-error-32.png",waiting:"/state/favicon-waiting-32.png",running:"/state/favicon-syncing-32.png",idle:"/favicon.ico"}),Bre=Object.freeze([...new Set([...Object.values(SP),...Object.values(_P)])]),Pb=new Map;function fM(e){return Pb.get(e)??e}async function qre(e,t=n=>fetch(n)){await Promise.all(e.map(async n=>{if(!Pb.has(n))try{const r=await t(n),s=(r.headers.get("Content-Type")??"").split(";")[0].trim();if(!r.ok||!s.startsWith("image/"))return;Pb.set(n,`data:${s};base64,${Ure(new Uint8Array(await r.arrayBuffer()))}`)}catch{}}))}function Ure(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function zre({stateRef:e,waitingSessions:t,live:n}){const r=y.useMemo(()=>LU(e.current.agents.values()),[e.current,e.current.revision]),s=y.useRef(null);y.useEffect(()=>{n&&qre(Bre)},[n]),y.useEffect(()=>{const o=Fre({waiting:t.length,running:r,connected:n}),l=s.current;s.current=o,(l==null?void 0:l.title)!==o.title&&(document.title=o.title),(l==null?void 0:l.icon)!==o.icon&&EP(o.icon)},[t.length,r,n])}function EP(e){const t=document.querySelector('link[rel="icon"][type="image/svg+xml"]');t&&(t.href=fM(SP[e]));const n=document.querySelector('link[rel="icon"][sizes="32x32"]');n&&(n.href=fM(_P[e]))}const Wre=1200,Hre=1e3;function kx(e){return e.lastDeckFitAt>0&&e.at-e.lastDeckFitAt<Wre?!1:e.hasSourceEvent?!0:e.lastCanvasInputAt>0&&e.at-e.lastCanvasInputAt<Hre}function Vre({applyViewport:e,lastFitTimeRef:t,cameraEpochRef:n,disableAutoFit:r,markInteract:s,canvasRef:o,applyZoom:l}){const c=y.useState(()=>pre())[0];y.useEffect(()=>{if(!c)return;const j=window.setTimeout(()=>{try{e(c,0)}catch{}t.current=Date.now()},60);return()=>window.clearTimeout(j)},[e,c]);const d=y.useRef(null),h=y.useRef(0),f=y.useCallback(()=>{h.current=Date.now()},[]),p=y.useCallback(j=>({hasSourceEvent:!!j,at:Date.now(),lastDeckFitAt:t.current,lastCanvasInputAt:h.current}),[]);return{restoredViewport:c,markCanvasInput:f,onMoveStart:j=>{ia(),kx(p(j))&&(n.current+=1),kx(p(j))&&r()},onMove:(j,k)=>{var x;s(),kx(p(j))&&r(),(x=o.current)==null||x.style.setProperty("--zoom",String(k.zoom)),l(k.zoom)==="detail"&&ia(),d.current&&window.clearTimeout(d.current),d.current=window.setTimeout(()=>mre(k),250)}}}function Gre({clearSelection:e,selectAgent:t,detailOpen:n,setDetailOpen:r,detailShown:s,focusAgent:o,draggingRef:l,lodRef:c}){const d=y.useRef(o);d.current=o;const[h]=y.useState(()=>II({focus:k=>d.current(k),setTimeout:(k,x)=>window.setTimeout(k,x),clearTimeout:k=>window.clearTimeout(k)}));return y.useEffect(()=>()=>h.cancel(),[h]),{onNodeClick:(k,x)=>{if(x.type==="sessionGroup"){h.cancel(),e();return}const N=x.type==="recapNote"?x.data.parentId:x.id;t(N,k.shiftKey,!1),!k.shiftKey&&(n&&r(!1),fk()?h.hold(N):s?window.setTimeout(()=>{try{o(N)}catch{}},80):o(N))},onPaneClick:()=>{h.cancel(),ia(),e()},onNodeDoubleClick:(k,x)=>{if(x.type!=="agent"&&x.type!=="recapNote")return;h.cancel();const N=x.type==="recapNote"?x.data.parentId:x.id;t(N,!1),window.setTimeout(()=>{try{o(N)}catch{}},80)},onNodeMouseEnter:(k,x)=>{x.type!=="agent"&&x.type!=="recapNote"||l.current||c.current==null||c.current==="detail"||yP(x.id,k.currentTarget)},onNodeMouseLeave:(k,x)=>ia(x.id)}}function Kre(){const e=y.useRef(null),t=y.useRef(null),[n,r]=y.useState({w:0,h:0});return y.useEffect(()=>{const s=t.current;if(!s||typeof ResizeObserver>"u")return;const o=new ResizeObserver(l=>{var d;const c=(d=l[0])==null?void 0:d.contentRect;c&&(e.current={width:c.width,height:c.height},r(h=>Math.abs(h.w-c.width)>40||Math.abs(h.h-c.height)>40?{w:c.width,h:c.height}:h))});return o.observe(s),e.current={width:s.clientWidth,height:s.clientHeight},r({w:s.clientWidth,h:s.clientHeight}),()=>o.disconnect()},[]),{canvasRef:t,canvasSize:n,paneSizeRef:e}}function Yre(e){const t=y.useRef(new Map),n=y.useRef(0),r=y.useCallback(c=>{const d=t.current;let h=!1;for(const f of c.nodeInternals.values()){const p=f.width,g=f.height;if(p==null||g==null)continue;const v=d.get(f.id);v?(Math.abs(v.height-g)>4||Math.abs(v.width-p)>4)&&(d.set(f.id,{width:p,height:g}),h=!0):(d.set(f.id,{width:p,height:g}),h=!0)}return h&&(n.current+=1),n.current},[]),s=He(r),[o,l]=y.useState(0);return y.useEffect(()=>{let c=0;const d=()=>{const f=t.current;let p=!1;for(const g of document.querySelectorAll(".react-flow__node[data-id]")){const v=g.getAttribute("data-id");if(!v)continue;const j=g.offsetWidth,k=g.offsetHeight;if(!j||!k)continue;const x=f.get(v);(!x||Math.abs(x.width-j)>4||Math.abs(x.height-k)>4)&&(f.set(v,{width:j,height:k}),p=!0)}p&&l(g=>g+1)};if(e.current)return;let h=0;return document.visibilityState==="hidden"?h=window.setTimeout(d,32):c=requestAnimationFrame(d),()=>{cancelAnimationFrame(c),window.clearTimeout(h)}}),{measuredRef:t,measuredVersionRef:n,sizeVersion:s,domSizeVersion:o}}function Xre(){const[e,t]=y.useState(!1);return y.useEffect(()=>{const n=window.setTimeout(()=>t(!0),2500);return()=>window.clearTimeout(n)},[]),e}function Zre(){const e=y.useRef(null);return y.useEffect(()=>{let t=-1/0;const n=()=>{t=performance.now()},r=s=>{e.current=performance.now()-t<250?s.target:null};return window.addEventListener("pointerdown",n,!0),window.addEventListener("focusin",r,!0),()=>{window.removeEventListener("pointerdown",n,!0),window.removeEventListener("focusin",r,!0)}},[]),e}function x0(){var t;return typeof navigator>"u"?"":((t=navigator.userAgentData)==null?void 0:t.platform)||navigator.platform||""}function b0(e){return/mac|iphone|ipad/i.test(e)}const gd=[{id:"general",label:"General"},{id:"notifications",label:"Notifications"},{id:"sounds",label:"Sounds"},{id:"music",label:"Music & character"}];function Jre(e){return Math.max(0,gd.findIndex(t=>t.id===e))}const pM="settings-tab-";function Qre(e,t){return e!=null&&e.startsWith(pM)?e===`${pM}${t}`?null:t:null}const ese={open:!1,section:"general"};function tse(e,t){return{open:!0,section:t??e.section}}function nse(e){return e.key===","&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey}function rse(e){return b0(e)?"⌘,":"Ctrl+,"}function sse({pointerFocusRef:e,nodesRef:t,stateRef:n,primarySelectedIdRef:r,providersRef:s,soundOnRef:o,keyHelpOpenRef:l,modalOpenRef:c,waitingCursorRef:d,removeSelectedRef:h,activateSoundRef:f,clearSelection:p,selectAgent:g,focusAgent:v,stepAgent:j,focusSession:k,requestClear:x,handleRelayout:N,handleFit:b,togglePause:S,toggleSessionList:E,toggleAccountsPanel:R,setDetailOpen:I,setUsageHistoryOpen:A,setUsagePanelOpen:q,setMachinePanelOpen:$,setBrowserWatchOpen:B,setSoundMenuOpen:L,setKeyHelpOpen:M,setTheme:F,openSettings:T}){y.useEffect(()=>{const P=O=>{var V,J;const G=O.target,K={tagName:G==null?void 0:G.tagName,isContentEditable:G==null?void 0:G.isContentEditable,role:(V=G==null?void 0:G.getAttribute)==null?void 0:V.call(G,"role"),type:G==null?void 0:G.type,pointerFocused:G!=null&&G===e.current};if(O.key==="Escape"){const W=QU({overlayOpen:qr.depth()>0,typing:Ni(K)});W==="dismiss"?qr.dismissTop():W==="blur"?G==null||G.blur():(Hne(K)&&(G==null||G.blur()),p());return}if(O.key===","&&nse(O)){if(Ni(K)||Xx({appModal:c.current,dialogDepth:qr.dialogDepth()}))return;O.preventDefault(),O.repeat||T();return}if(dh(O))return;const U=m0(G)?(J=G==null?void 0:G.getAttribute)==null?void 0:J.call(G,"data-id"):null,H=U&&t.current.some(W=>W.id===U)?U:null,D=zne(O,H);if(D.kind==="activate"){O.preventDefault(),g(D.nodeId,D.additive);return}if(D.kind!=="node"){if(uz({key:O.key,sheetOpen:l.current,target:K})){O.repeat||M(!1);return}if(!(D.nodeId==null&&lz(K,O.key))&&!cz({key:O.key,modalOpen:Xx({appModal:c.current,dialogDepth:qr.dialogDepth()}),sheetOpen:l.current})&&!(O.repeat&&!/^[ jkJK]$/.test(O.key))){if(O.key===" "&&(O.preventDefault(),O.repeat||S()),(O.key==="c"||O.key==="C")&&x("shortcut"),(O.key==="r"||O.key==="R")&&N(),(O.key==="f"||O.key==="F")&&b(),(O.key==="z"||O.key==="Z")&&r.current&&v(r.current),O.key==="Delete"&&h.current(),(O.key==="l"||O.key==="L")&&E(),O.key==="d"||O.key==="D")if(r.current)I(W=>!W);else{const W=Yx(n.current.agents.values());W.length>0?k(W[0].id):j(1)}if((O.key==="h"||O.key==="H")&&A(W=>!W),(O.key==="u"||O.key==="U")&&q(W=>!W),(O.key==="a"||O.key==="A")&&s.current.claude&&R(),(O.key==="j"||O.key==="J")&&j(1),(O.key==="k"||O.key==="K")&&j(-1),O.key==="w"||O.key==="W"){const W=OU(Yx(n.current.agents.values()),d.current);W&&(d.current=W.id,k(W.id))}(O.key==="t"||O.key==="T")&&F(W=>W==="dark"?"light":"dark"),(O.key==="m"||O.key==="M")&&o.current!==null&&f.current(O.shiftKey),(O.key==="s"||O.key==="S")&&$(W=>!W),(O.key==="b"||O.key==="B")&&B(W=>!W),(O.key==="v"||O.key==="V")&&s.current.claude&&o.current!==null&&L(W=>!W),O.key==="?"&&M(W=>!W)}}};return window.addEventListener("keydown",P),()=>window.removeEventListener("keydown",P)},[x,N,b,p,g,j,k,v,S])}function ase(){var e,t;return((t=(e=document.activeElement)==null?void 0:e.matches)==null?void 0:t.call(e,":focus-visible"))===!0}function ose({sessionListShown:e,usageShown:t,machineShown:n,accountsShown:r,detailShown:s,primarySelectedId:o,canvasRef:l}){const c={sessionList:y.useRef(null),usage:y.useRef(null),accounts:y.useRef(null),machine:y.useRef(null)},d=h=>()=>{ase()&&h()};return{toggles:c,sessionList:d(ps(!e,c.sessionList)),usage:d(ps(!t,c.usage)),machine:d(ps(!n,c.machine)),accounts:d(ps(!r,c.accounts)),detail:d(ps(!s,()=>{var h,f;o&&mP(o),An(((h=document.activeElement)==null?void 0:h.tagName)??null)&&((f=l.current)==null||f.focus({preventScroll:!0}))}))}}function ise({nodes:e,stateRef:t,pinnedRef:n,positionsRef:r,draggingRef:s,dragPatchRef:o,setDragging:l,setDragMoveTick:c,setDragTick:d,endBubble:h,markInteract:f,disableAutoFit:p,beginTrashDrag:g,trackTrashDrag:v,endTrashDrag:j,removeNode:k}){const x=y.useRef(null);return{onNodeDragStart:(E,R)=>{var I,A;if(ia(),h(),s.current=!0,o.current=new Map,l(!0),g(R.type==="agent"?((I=t.current.agents.get(R.id))==null?void 0:I.label)??"":null),f(),p(),R.type==="sessionGroup"){const q=(A=R.data)==null?void 0:A.sessionId,$=new Map;if(q)for(const B of e){const L=B.data;(L==null?void 0:L.sessionId)===q&&$.set(B.id,{x:B.position.x,y:B.position.y})}x.current={start:{x:R.position.x,y:R.position.y},members:$};return}n.current.set(R.id,{x:R.position.x,y:R.position.y})},onNodeDrag:(E,R)=>{var I;if(f(),R.type==="agent"&&v(E),R.type==="sessionGroup"){const A=x.current;if(!A)return;const q=R.position.x-A.start.x,$=R.position.y-A.start.y;for(const[L,M]of A.members){const F={x:M.x+q,y:M.y+$};n.current.set(L,F),r.current.set(L,F)}const B=o.current;if(B){for(const[L,M]of A.members)B.set(L,{x:M.x+q,y:M.y+$});B.set(R.id,{x:R.position.x,y:R.position.y})}c(L=>L+1);return}n.current.set(R.id,{x:R.position.x,y:R.position.y}),r.current.set(R.id,{x:R.position.x,y:R.position.y}),(I=o.current)==null||I.set(R.id,{x:R.position.x,y:R.position.y}),c(A=>A+1)},onNodeDragStop:(E,R)=>{f();const I=j(E,R.type==="agent");if(s.current=!1,o.current=null,l(!1),d(A=>A+1),R.type==="sessionGroup"){const A=x.current;if(A){const q=R.position.x-A.start.x,$=R.position.y-A.start.y;for(const[B,L]of A.members){const M={x:L.x+q,y:L.y+$};n.current.set(B,M),r.current.set(B,M)}}x.current=null,hc(r.current,n.current),d(q=>q+1);return}if(n.current.set(R.id,{x:R.position.x,y:R.position.y}),r.current.set(R.id,{x:R.position.x,y:R.position.y}),I){k(R.id);return}hc(r.current,n.current)}}}function lse(e){return e.claude&&e.codex?"Claude Code and Codex":e.claude?"Claude Code":e.codex?"Codex":null}const cse={claude:"Claude Code",codex:"Codex",opencode:"OpenCode",openclaw:"OpenClaw",copilot:"GitHub Copilot",pi:"pi-agent",zcode:"ZCode"};function use(e){const t=e.toLowerCase(),n=Lt(cse,t);return n!==void 0?n:t?t[0].toUpperCase()+t.slice(1):""}function dse(e){return e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function Cue(e,t=[]){const n=t.length?dse(t.map(use)):lse(e);return n?`via ccusage · local ${n} logs`:"via ccusage · local agent logs"}function hse(e){const t=e.claude?{provider:"claude",watching:!0,spans:[{text:"Claude Code sends its events through a hook in "},{text:"~/.claude/settings.json",code:!0},{text:" — or in "},{text:"$CLAUDE_CONFIG_DIR/settings.json",code:!0},{text:" when you have that set — which the deck installs on first run."}]}:{provider:"claude",watching:!1,spans:[{text:"Claude Code capture is off: no Claude Code was found on this machine, or the deck was started with "},{text:"--no-claude",code:!0},{text:"."}]},n=e.codex?{provider:"codex",watching:!0,spans:[{text:"Codex installs nothing and needs no trust prompt — the deck reads "},{text:"~/.codex/sessions/",code:!0},{text:" itself, so an empty canvas means no rollout has been written there yet, or that "},{text:"$CODEX_HOME",code:!0},{text:" points at a different tree."}]}:{provider:"codex",watching:!1,spans:[{text:"Codex capture is off: no "},{text:"~/.codex/",code:!0},{text:" was found — set "},{text:"$CODEX_HOME",code:!0},{text:" if yours lives elsewhere — or the deck was started with "},{text:"--no-codex",code:!0},{text:"."}]};return[t,n]}function fse(e,t){const n=t.prefs??Ab,r=Ei(n.done.level),s=Ei(n["needs-input"].level),o=r===s?`${r}%`:`${r}% and ${s}%`,l=t.on?`Sound: on at ${o} — a tone when a turn finishes, another when Claude asks for you (M)`:"Sound: off — press M, or use the switch in here, for a tone when a turn finishes (M)",c=e.codex?`
97
-
98
- Both CLIs get the finish tone. The second tone — Claude is waiting for you — has no Codex equivalent to fire on, so it only ever plays for Claude Code.`:"",d=t.on&&t.locked?`
99
-
100
- Waiting for a click: this browser plays no sound until the page has been used at least once. Anything you press unlocks it.`:"";return l+c+d+`
101
-
102
- Click to set the volume and the sound of each tone, and to hear either one.`}function pse(e){if(e==null)return{kind:"unknown",lead:"No data yet. Start a Claude Code or Codex session — it appears here as soon as the deck sees its first event.",workspace:null,tail:""};const t=e.trim();return t===""?{kind:"machine",lead:"No data yet. Start a Claude Code or Codex session anywhere on this machine — this deck is unscoped and captures every workspace.",workspace:null,tail:""}:{kind:"scoped",lead:"No data yet. This deck only captures sessions running under",workspace:t,tail:" — start one there, or restart it without --workspace/--scope to watch the whole machine."}}function mse(){return a.jsxs("div",{className:"empty-hero",children:[a.jsxs("div",{className:"orbit-stack","aria-hidden":!0,children:[a.jsx("div",{className:"core"}),a.jsxs("div",{className:"orbit r1",children:[a.jsx("span",{className:"dot"}),a.jsx("span",{className:"dot b"})]}),a.jsxs("div",{className:"orbit r2",children:[a.jsx("span",{className:"dot"}),a.jsx("span",{className:"dot b"})]}),a.jsxs("div",{className:"orbit r3",children:[a.jsx("span",{className:"dot"}),a.jsx("span",{className:"dot b"})]})]}),a.jsxs("h2",{children:["Too many ",xt," tabs are open"]}),a.jsxs("p",{children:["This browser keeps at most six live connections to one address, and other ",a.jsx("code",{children:xt})," tabs are holding them. Close one and this tab connects on its own."]})]})}function gse({live:e,everConnected:t,providers:n,workspace:r,onTour:s}){const o=!e;return a.jsxs("div",{className:"empty-hero",children:[a.jsxs("div",{className:"orbit-stack","aria-hidden":!0,children:[a.jsx("div",{className:"core"}),a.jsxs("div",{className:"orbit r1",children:[a.jsx("span",{className:"dot"}),a.jsx("span",{className:"dot b"})]}),a.jsxs("div",{className:"orbit r2",children:[a.jsx("span",{className:"dot"}),a.jsx("span",{className:"dot b"})]}),a.jsxs("div",{className:"orbit r3",children:[a.jsx("span",{className:"dot"}),a.jsx("span",{className:"dot b"})]})]}),o?a.jsxs(a.Fragment,{children:[a.jsx("h2",{children:t?"Disconnected from server":"Server unreachable"}),a.jsxs("p",{children:[t?"This page lost its connection to ":"This page cannot reach ",a.jsx("code",{children:xt}),". Check that it is still running in your terminal — the page picks up again on its own."]})]}):yse(n,r),!o&&a.jsx("button",{type:"button",className:"btn empty-tour",onClick:s,children:"Take the tour"}),!o&&a.jsx(rc,{film:"tour"})]})}function yse(e,t){const n=pse(t);return a.jsxs(a.Fragment,{children:[a.jsx("h2",{children:"Waiting for Claude Code or Codex"}),n.kind==="scoped"?a.jsxs("p",{children:[n.lead," ",a.jsx("code",{children:n.workspace}),n.tail]}):a.jsxs("p",{children:["Run ",a.jsx("code",{children:"claude"})," or ",a.jsx("code",{children:"codex"})," in any folder. As soon as a session sends an event, a node appears here and grows as subagents fork and tools are called."]}),hse(e).map(r=>a.jsx("p",{className:"hint-row",children:r.spans.map((s,o)=>s.code?a.jsx("code",{children:s.text},o):a.jsx("span",{children:s.text},o))},r.provider))]})}const wse=1;function vse(e){return{id:e.id,name:e.name,inputPreview:e.inputPreview,startedAt:e.startedAt,endedAt:e.endedAt,ok:e.ok,errorPreview:e.errorPreview,usage:e.usage}}function xse(e,t,n){const r=e.agents.get(t);if(!r)return null;const s=[];for(const o of e.agents.values())o.sessionId===t&&s.push(o);return{schemaVersion:wse,exportedAt:n,sessionId:t,label:r.label,cwd:r.cwd,startedAt:r.startedAt,endedAt:r.endedAt,model:r.model,agents:s.map(o=>({id:o.id,kind:o.kind,label:o.label,parentId:o.parentId,state:o.state,startedAt:o.startedAt,endedAt:o.endedAt,model:o.model,cwd:o.cwd,usage:o.usage,prompts:o.prompts,tools:o.tools.map(vse)}))}}function bse(e,t){const n=(e||"session").replace(/[^a-z0-9._-]/gi,"_");return`${xt}-${n}-${Ek(t,8)}.json`}const CP={file:"📁",shell:"⚡",web:"🌐",agent:"🤖",task:"📋",plan:"🧭",mcp:"🔌",other:"✨"},kse={file:"M3.4 1.8h4.5l2.7 2.7v7.7H3.4z M7.9 1.8v2.7h2.7",shell:"M2.4 3.8 5.6 7l-3.2 3.2 M7.4 10.6h4.2",web:"M7 1.8a5.2 5.2 0 1 0 0 10.4A5.2 5.2 0 1 0 7 1.8z M1.8 7h10.4 M7 1.8c-1.5 1.4-2.3 3.1-2.3 5.2s.8 3.8 2.3 5.2c1.5-1.4 2.3-3.1 2.3-5.2S8.5 3.2 7 1.8z",agent:"M3.3 4.8h7.4a1.2 1.2 0 0 1 1.2 1.2v4.8a1.2 1.2 0 0 1-1.2 1.2H3.3a1.2 1.2 0 0 1-1.2-1.2V6a1.2 1.2 0 0 1 1.2-1.2z M7 4.8V2.4 M5.3 8.2h.01 M8.7 8.2h.01",task:"M2.2 4l1.2 1.2 2-2.2 M7.4 4.2h4.4 M2.2 9.4l1.2 1.2 2-2.2 M7.4 9.6h4.4",plan:"M7 1.8a5.2 5.2 0 1 0 0 10.4A5.2 5.2 0 1 0 7 1.8z M9 5 8 8 5 9l1-3z",mcp:"M5 1.8v2.6 M9 1.8v2.6 M3.6 4.4h6.8v2.2a3.4 3.4 0 0 1-6.8 0z M7 10v2.2",other:"M3.5 7h.01 M7 7h.01 M10.5 7h.01"};function Nse({cat:e}){return a.jsx("svg",{className:"cat-glyph",width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:a.jsx("path",{d:kse[e]})})}const Kd={file:"file",shell:"shell",web:"web",agent:"agent",task:"task",plan:"plan",mcp:"mcp",other:"other"},TP=mI;function jse({agent:e,now:t,onOpenTool:n,onShowSummary:r,onExportSession:s,onRemove:o}){var k;const l=`${e.synthetic?"≥ ":""}${ki(e.startedAt,e.endedAt,t)}`,c=gn(e),d=c.total>0,h=e.usage.inputTokens+e.usage.outputTokens,f=new Map;for(const[x,N]of e.toolCountByName??[]){const b=TP(x);f.set(b,(f.get(b)??0)+N)}const p=e.toolErrorCount??0,g=e.tools.filter(x=>!x.endedAt).length,v=Array.from(f.entries()).sort((x,N)=>N[1]-x[1]),j=f.has("mcp")?hW(((k=e.toolCountByName)==null?void 0:k.keys())??[]):null;return a.jsxs(a.Fragment,{children:[a.jsxs("header",{className:"detail-hero",children:[a.jsxs("div",{className:"hero-line",children:[a.jsx("span",{className:`state-pill state-${e.state}`,children:e.state==="active"?"live":e.state}),a.jsx("h2",{className:"hero-title",title:e.cwd??e.label,children:e.label})]}),a.jsxs("div",{className:"hero-meta",children:[a.jsx("span",{className:"hero-meta-item",children:e.kind==="root"?"session":"subagent"}),a.jsx("span",{className:"hero-sep",children:"·"}),a.jsx("span",{className:"hero-meta-item",title:`started ${new Date(e.startedAt).toLocaleString()}`,children:l}),e.model&&(()=>{const x=vk(e);return a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"hero-sep",children:"·"}),a.jsxs("span",{className:"model-chip","data-family":ch(e.model),title:x.length>0?`${e.model}
103
- spend on this panel also covers:
104
- ${x.join(`
105
- `)}`:e.model,children:[ks(e.model),x.length>0?` +${x.length}`:""]})]})})()]}),d&&a.jsxs("div",{className:"hero-cost",children:[a.jsxs("div",{className:"hero-cost-headline",children:[a.jsx("span",{className:"hero-cost-value",children:We(c.total)}),a.jsx("span",{className:"hero-cost-label",children:"spend"})]}),a.jsx(Tk,{cost:c})]}),a.jsxs("div",{className:"hero-actions",children:[e.kind==="root"&&e.state==="done"&&r&&a.jsx("button",{type:"button",className:"btn hero-action-btn",onClick:()=>r(e.sessionId),title:"Reopen the end-of-session recap modal",children:"Show recap"}),s&&a.jsx("button",{type:"button",className:"btn hero-action-btn",onClick:()=>s(e.sessionId),title:"Download this session as JSON",children:"Export JSON"}),o&&a.jsx("button",{type:"button",className:"btn hero-action-btn",onClick:o,title:e.kind==="root"?"Take this session's cards off the board (Delete). The session carries on; the session list (L) brings it back":"Take this card and the ones under it off the board (Delete). The session list (L) brings it back",children:"Remove from board"})]})]}),(()=>{const x=hh(e);if(!x)return null;const N=Id(x.at,t),b=x.kind==="recap"?"Recap":sa(x.kind).replace(/^./,S=>S.toUpperCase());return a.jsxs("section",{className:"detail-section",children:[a.jsxs("h3",{children:[b," ",a.jsx("span",{className:"section-count",title:N.title,children:N.label})]}),a.jsx("p",{className:"detail-recap",title:fh(x),children:x.text}),x.reply&&a.jsxs("p",{className:"detail-recap detail-note-reply",children:["Suggested reply: “",x.reply,"”"]})]})})(),e.tools.length>0&&a.jsxs("section",{className:"detail-section",children:[a.jsx("h3",{children:"Activity"}),a.jsxs("div",{className:"activity-row",children:[a.jsxs("div",{className:"activity-counters",children:[a.jsxs("span",{className:"ac-item",children:[a.jsx("b",{children:e.toolCount})," calls"]}),g>0&&a.jsxs("span",{className:"ac-item ac-live",children:[a.jsx("b",{children:g})," live"]}),p>0&&a.jsxs("span",{className:"ac-item ac-err",children:[a.jsx("b",{children:p})," err"]})]}),a.jsx("div",{className:"cat-strip",children:v.map(([x,N])=>{const b=x==="mcp"?j:null,S=b==null?void 0:b.hue,E=`${N} ${Kd[x]} call${N===1?"":"s"}`;return a.jsxs("span",{className:`cat-chip cat-${x}${S!=null?" mcp-hue":""}`,style:S!=null?{"--mcp-hue":S}:void 0,title:b?`${E}, all to ${b.label}`:E,children:[a.jsx("span",{className:"cat-emoji","aria-hidden":!0,children:CP[x]}),a.jsx("span",{className:"cat-name",children:Kd[x]}),a.jsx("span",{className:"cat-count",children:N}),b&&a.jsx("span",{className:"cat-server",children:b.label})]},x)})})]})]}),h>0&&a.jsxs("section",{className:"detail-section",children:[a.jsx("h3",{children:"Tokens"}),a.jsxs("div",{className:"tokens-grid",children:[a.jsxs("div",{children:[a.jsx("span",{className:"k",children:"in"}),a.jsx("b",{title:e.usage.inputTokens.toLocaleString(),children:st(e.usage.inputTokens)})]}),a.jsxs("div",{children:[a.jsx("span",{className:"k",children:"out"}),a.jsx("b",{title:e.usage.outputTokens.toLocaleString(),children:st(e.usage.outputTokens)})]}),a.jsxs("div",{children:[a.jsx("span",{className:"k",children:"cache r"}),a.jsx("b",{title:e.usage.cacheReadTokens.toLocaleString(),children:st(e.usage.cacheReadTokens)})]}),a.jsxs("div",{children:[a.jsx("span",{className:"k",children:"cache c"}),a.jsx("b",{title:e.usage.cacheCreateTokens.toLocaleString(),children:st(e.usage.cacheCreateTokens)})]})]})]}),a.jsxs("section",{className:"detail-section",children:[a.jsx("h3",{children:"Identity"}),a.jsxs("div",{children:[e.cwd&&a.jsxs("div",{className:"row",children:[a.jsx("span",{className:"k",children:"cwd"}),a.jsx("span",{className:"v",title:e.cwd,children:e.cwd})]}),a.jsxs("div",{className:"row",children:[a.jsx("span",{className:"k",children:"session"}),a.jsxs("span",{className:"v",children:[e.sessionId.slice(0,12),"…"]})]}),e.parentId&&a.jsxs("div",{className:"row",children:[a.jsx("span",{className:"k",children:"parent"}),a.jsxs("span",{className:"v",children:[e.parentId.slice(0,12),"…"]})]})]})]}),e.prompts.length>0&&a.jsxs("section",{className:"detail-section",children:[a.jsxs("h3",{children:["Prompts ",a.jsx("span",{className:"section-count",children:q$(e.prompts).length})]}),a.jsx("div",{className:"prompts",children:Sse(e.prompts).reverse().map(({pr:x,key:N})=>{const b=Id(x.at,t),S=oh(x.text);return S?a.jsxs("details",{className:"prompt-entry prompt-injected",children:[a.jsxs("summary",{children:[a.jsx("span",{className:"prompt-time",title:b.title,children:b.label}),a.jsx("span",{className:"prompt-injected-label",children:S.label})]}),S.detail&&a.jsx("div",{className:"prompt-injected-detail",children:S.detail})]},N):a.jsxs("div",{className:"prompt-entry",children:[a.jsx("div",{className:"prompt-time",title:b.title,children:b.label}),a.jsx("div",{className:"prompt-text",children:x.text})]},N)})})]}),a.jsxs("section",{className:"detail-section",children:[a.jsxs("h3",{children:["Tool calls ",a.jsx("span",{className:"section-count",children:e.tools.length})]}),e.tools.length===0&&a.jsx("div",{className:"empty",children:"No tool calls yet."}),a.jsx("div",{children:e.tools.slice().reverse().map(x=>a.jsx(Ese,{t:x,onClick:()=>n(e.id,x.id)},x.id))})]})]})}function Sse(e){const t=new Map;return e.map(n=>{const r=t.get(n.at)??0;return t.set(n.at,r+1),{pr:n,key:r===0?String(n.at):`${n.at}:${r}`}})}const _se={inflight:"in-flight",done:"done",err:"error"};function Ese({t:e,onClick:t}){const n=e.endedAt==null?"inflight":e.ok===!1?"err":"done",r=sI(e,"…");return a.jsxs("button",{className:"tool clickable",title:e.inputPreview||e.name,onClick:t,children:[a.jsxs("span",{className:"name",children:[a.jsx("span",{className:`status-dot ${n}`,"aria-hidden":!0}),a.jsx("span",{className:"vis-hidden",children:_se[n]}),e.name]}),a.jsx("span",{style:{color:"var(--muted)"},children:r})]})}function Cse(e,t){const n=xse(e,t,new Date().toISOString());if(!n)return;const r=JSON.stringify(n,null,2),s=new Blob([r],{type:"application/json"}),o=URL.createObjectURL(s),l=document.createElement("a");l.href=o,l.download=bse(n.label,t),document.body.appendChild(l),l.click(),document.body.removeChild(l),setTimeout(()=>URL.revokeObjectURL(o),1e3)}function Tse({selected:e,now:t,openTool:n,setSummaryFor:r,onClose:s,stateRef:o,removeSelectedNode:l}){return qt("detail-panel"),a.jsxs("aside",{className:"detail","aria-label":"Detail",children:[a.jsx("button",{type:"button",className:"glyph-btn detail-close",title:"Close panel","aria-label":"Close detail panel",onClick:s,children:"×"}),a.jsx(jse,{agent:e,now:t,onOpenTool:n,onShowSummary:r,onExportSession:c=>Cse(o.current,c),onRemove:l})]})}function AP({soundOn:e,onToggleSound:t}){const n=y.useId();return a.jsxs("div",{className:"sm-setting",children:[a.jsxs("label",{className:"sm-switch",children:[a.jsx("span",{className:"sm-switch-label",id:n,children:"Sounds"}),a.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-labelledby":n,className:"switch",onClick:t,title:"A tone when a turn finishes, and when Claude asks for something",children:a.jsx("span",{className:"switch-knob"})})]}),a.jsxs("p",{className:"sm-note sm-key-note",children:[a.jsx("kbd",{children:"M"}),"Mute or unmute sounds anywhere."]})]})}const Db="custom:";function mM(e){return`${Db}${e}`}function Ase(e){return e.startsWith(Db)?e.slice(Db.length):null}function k0({id:e,label:t="Volume",value:n,onLevel:r,"aria-describedby":s}){return a.jsxs("div",{className:"sm-row",children:[a.jsx("label",{htmlFor:e,children:t}),a.jsx("input",{id:e,type:"range",min:fd,max:Ud,step:Tb,value:n,"aria-describedby":s,onChange:o=>r(Number(o.target.value)),style:{"--sm-level":`${(n-fd)/(Ud-fd)*100}%`}}),a.jsxs("span",{className:"sm-read",children:[n,"%"]})]})}const Fb={done:"Turn finished","needs-input":"Claude is asking"},Rse={done:"Plays when Claude or Codex finishes a turn.","needs-input":"Available in Claude Code only."};function Mse({chime:e,tone:t,soundOn:n,customAssets:r,customSelections:s,onLevel:o,onFigure:l,onPreview:c,onBuiltInSelected:d,onCustomSelected:h}){const f=`sm-level-${e}`,p=`sm-figure-${e}`,g=s[e];return a.jsxs("section",{className:"sm-tone","aria-labelledby":`sm-name-${e}`,children:[a.jsxs("div",{className:"sm-tone-head",children:[a.jsx("h3",{className:"sm-tone-name",id:`sm-name-${e}`,children:Fb[e]}),a.jsxs("button",{type:"button",className:"btn sm-hear",onClick:()=>c(e),"aria-label":`Hear the ${Fb[e].toLowerCase()} tone`,title:n?"Play this tone now, at what it is set to":"Plays even when Sounds is off","aria-describedby":n?void 0:"sm-preview-note",children:[a.jsx("svg",{width:"11",height:"11",viewBox:"0 0 12 12",fill:"currentColor","aria-hidden":!0,children:a.jsx("path",{d:"M3 1.6v8.8l7-4.4z"})}),"Hear it"]})]}),a.jsx(k0,{id:f,value:t.level,onLevel:v=>o(e,v)}),a.jsxs("div",{className:"sm-row",children:[a.jsx("label",{htmlFor:p,children:"Tone"}),a.jsxs("select",{id:p,className:"sm-select",value:g?mM(g):t.figure,onChange:v=>{const j=v.target.value,k=Ase(j);k!==null?h(e,k):(d(e),l(e,j))},children:[Kk[e].map(v=>a.jsx("option",{value:v.id,children:v.label},v.id)),r.length>0&&a.jsx("optgroup",{label:"Custom",children:r.map(v=>a.jsx("option",{value:mM(v.id),children:v.name},v.id))})]})]}),a.jsx("p",{className:"sm-note",children:Rse[e]})]})}function $se({onClose:e,soundOn:t,onToggleSound:n,prefs:r,onLevel:s,onAllSettings:o,openerRef:l}){const c=ot(e,{popover:!0});return sO(c,()=>l.current,e),a.jsxs("div",{ref:c,id:"sound-menu",className:"sound-menu",role:"dialog","aria-label":"Sound settings",children:[a.jsx(AP,{soundOn:t,onToggleSound:n}),a.jsx("div",{className:"sm-levels",children:zl.map(d=>a.jsx(k0,{id:`sm-quick-level-${d}`,label:Fb[d],value:r[d].level,onLevel:h=>s(d,h)},d))}),a.jsx("button",{type:"button",className:"btn sm-all-settings",onClick:o,children:"All sound settings…"})]})}const rd="tb-more",Bb="tb-more-menu";function Ise(){const e=Array.from(document.querySelectorAll(`#${Bb} [role="menuitem"]`));return document.querySelectorAll(".topbar .tb-fold")[Math.max(0,e.indexOf(document.activeElement))]??null}function Ose({watchUnseen:e,setUsageHistoryOpen:t,setBrowserWatchOpen:n,onFeedback:r}){const[s,o]=y.useState(null),l=s!==null,c=d=>()=>{var h;(h=document.getElementById(rd))==null||h.focus(),o(null),d()};return a.jsxs(a.Fragment,{children:[a.jsxs("button",{id:rd,className:"btn icon-btn tb-more",onClick:()=>o(l?null:"first"),onKeyDown:d=>{d.key!=="ArrowDown"&&d.key!=="ArrowUp"||(d.preventDefault(),o(d.key==="ArrowUp"?"last":"first"))},title:"More — usage history, Browser watch and feedback","aria-label":`More: usage history, Browser watch, feedback${e>0?`, ${e} unread`:""}`,"aria-haspopup":"menu","aria-expanded":l,"aria-controls":l?Bb:void 0,children:[a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("circle",{cx:"2.8",cy:"7",r:"0.7"}),a.jsx("circle",{cx:"7",cy:"7",r:"0.7"}),a.jsx("circle",{cx:"11.2",cy:"7",r:"0.7"})]}),e>0&&a.jsx("span",{className:"bw-badge","aria-hidden":!0,children:e})]}),l&&a.jsxs(Nh,{anchorId:rd,id:Bb,className:"ap-pop",role:"menu",labelledBy:rd,start:s,fallbackFocus:Ise,onClose:()=>o(null),children:[a.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",onClick:c(()=>t(!0)),children:"Usage history"}),a.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",onClick:c(()=>n(!0)),children:e>0?`Browser watch · ${e} unread`:"Browser watch"}),a.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",onClick:c(r),children:"Send feedback"})]})]})}function Lse({sessionListOpen:e,toggleSessionList:t,usagePanelOpen:n,setUsagePanelOpen:r,setUsageHistoryOpen:s,toggles:o}){return a.jsxs("div",{className:"action-run",children:[a.jsxs("button",{ref:o.sessionList,className:"btn icon-btn",onClick:t,title:`${e?"Hide":"Show"} session list (L)`,"aria-label":"Toggle session list","aria-expanded":e,"aria-controls":e?"session-list":void 0,children:[a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("path",{d:"M5.4 3.6h6.6M5.4 7h6.6M5.4 10.4h6.6"}),a.jsx("path",{d:"M2.2 3.6h.2M2.2 7h.2M2.2 10.4h.2"})]}),a.jsx("span",{className:"tb-word",children:"Session list"})]}),a.jsxs("button",{ref:o.usage,className:"btn icon-btn",onClick:()=>r(l=>!l),title:`${n?"Hide":"Show"} usage panel (U)`,"aria-label":"Toggle usage panel","aria-expanded":n,"aria-controls":n?"usage-panel":void 0,children:[a.jsxs("svg",{className:"tb-glyph-narrow",width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("path",{d:"M9.4 4.5C9 3.6 8.1 3.1 7 3.1c-1.4 0-2.4.8-2.4 1.9 0 1.2 1.2 1.6 2.4 2s2.4.8 2.4 2c0 1.1-1 1.9-2.4 1.9-1.1 0-2-.5-2.4-1.4"}),a.jsx("path",{d:"M7 1.6v1.5M7 10.9v1.5"})]}),a.jsx("span",{className:"tb-word",children:"Usage"})]}),a.jsxs("button",{className:"btn icon-btn tb-fold",onClick:()=>s(l=>!l),title:"Usage history — ccusage (H)","aria-label":"Open usage history","aria-haspopup":"dialog",children:[a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("line",{x1:"3",y1:"11.5",x2:"3",y2:"7"}),a.jsx("line",{x1:"7",y1:"11.5",x2:"7",y2:"3"}),a.jsx("line",{x1:"11",y1:"11.5",x2:"11",y2:"8.5"})]}),a.jsx("span",{className:"tb-word",children:"History"})]})]})}function Pse({providers:e,accountsPanelOpen:t,toggleAccountsPanel:n,machinePanelOpen:r,setMachinePanelOpen:s,watchOn:o,watchUnseen:l,setBrowserWatchOpen:c,toggles:d}){return a.jsxs("div",{className:"action-run",children:[e.claude&&a.jsxs("button",{ref:d.accounts,className:"btn icon-btn",onClick:n,title:`${t?"Hide":"Show"} accounts (A)`,"aria-label":"Toggle accounts panel","aria-expanded":t,"aria-controls":t?"accounts-panel":void 0,children:[a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("circle",{cx:"7",cy:"4.6",r:"2.4"}),a.jsx("path",{d:"M2.4 12c0-2.3 2.1-3.7 4.6-3.7s4.6 1.4 4.6 3.7"})]}),a.jsx("span",{className:"tb-word",children:"Accounts"})]}),a.jsxs("button",{ref:d.machine,className:"btn icon-btn",onClick:()=>s(h=>!h),title:`${r?"Hide":"Show"} this machine — cores, memory, temperature (S)`,"aria-label":"Toggle machine detail","aria-expanded":r,"aria-controls":r?"system-panel":void 0,children:[a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("rect",{x:"3.6",y:"3.6",width:"6.8",height:"6.8",rx:"1.2"}),a.jsx("path",{d:"M5.8 1.4v2.2M8.2 1.4v2.2M5.8 10.4v2.2M8.2 10.4v2.2M1.4 5.8h2.2M1.4 8.2h2.2M10.4 5.8h2.2M10.4 8.2h2.2"})]}),a.jsx("span",{className:"tb-word",children:"Machine"})]}),a.jsxs("button",{className:"btn icon-btn bw-btn tb-fold",onClick:()=>c(h=>!h),title:o?"Browser watch — watching; the deck is keeping its own copy (B)":"Browser watch — not watching; reading the browser's history live (B)","aria-label":`Browser watch, ${o?"watching":"not watching"}`+(l>0?`, ${l} unread`:""),"aria-haspopup":"dialog",children:[a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("path",{d:"M0.9 7s2.2-4 6.1-4 6.1 4 6.1 4-2.2 4-6.1 4S0.9 7 0.9 7Z"}),o||l>0?a.jsx("circle",{cx:"7",cy:"7",r:"1.8",fill:"currentColor",stroke:"none"}):a.jsx("line",{x1:"2.4",y1:"11.6",x2:"11.6",y2:"2.4"})]}),a.jsx("span",{className:"tb-word",children:"Browser watch"}),l>0&&a.jsx("span",{className:"bw-badge","aria-hidden":!0,children:l})]})]})}function RP({on:e}){return a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("path",{d:"M3.2 5.2h2L7.8 3v8L5.2 8.8h-2z"}),e?a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M9.8 5.4a2.4 2.4 0 0 1 0 3.2"}),a.jsx("path",{d:"M11.3 3.9a4.6 4.6 0 0 1 0 6.2"})]}):a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M10 5.6l2.6 2.8"}),a.jsx("path",{d:"M12.6 5.6L10 8.4"})]})]})}function Dse({providers:e,sound:t,tones:n,chimeState:r,menus:s,onFeedback:o,watchUnseen:l,setUsageHistoryOpen:c,setBrowserWatchOpen:d}){const{soundOn:h,toggleSound:f}=t,{tonePrefs:p,changeTone:g}=n,{soundMenuOpen:v,setSoundMenuOpen:j,soundButtonRef:k,openSettings:x}=s,N=`Settings (${rse(x0())})`;return a.jsxs("div",{className:"action-run action-run-utility",children:[e.claude&&h!==null&&a.jsxs("div",{className:"sound-slot",children:[a.jsxs("button",{ref:k,className:"btn icon-btn",onClick:()=>j(b=>!b),...Wr(!1),title:fse(e,{on:h===!0,locked:r==="locked",prefs:p}),"aria-label":`Sound settings, ${h?"on":"off"}`,"aria-haspopup":"dialog","aria-expanded":v,"aria-controls":v?"sound-menu":void 0,children:[a.jsx(RP,{on:h}),a.jsx("span",{className:"tb-word",children:"Sound"})]}),v&&a.jsx($se,{onClose:()=>j(!1),soundOn:h===!0,onToggleSound:f,prefs:p,onLevel:(b,S)=>g(b,{level:S}),onAllSettings:()=>x("sounds"),openerRef:k})]}),a.jsxs("button",{className:"btn icon-btn",onClick:()=>x(),title:N,"aria-label":"Settings","aria-haspopup":"dialog","aria-keyshortcuts":"Control+, Meta+,",children:[a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("path",{d:"M5.4 2.9L5.6 1.1L8.4 1.1L8.6 2.9L9.8 3.6L11.5 2.8L12.8 5.2L11.3 6.3L11.3 7.7L12.8 8.8L11.5 11.2L9.8 10.4L8.6 11.1L8.4 12.9L5.6 12.9L5.4 11.1L4.2 10.4L2.5 11.2L1.2 8.8L2.7 7.7L2.7 6.3L1.2 5.2L2.5 2.8L4.2 3.6Z"}),a.jsx("circle",{cx:"7",cy:"7",r:"1.9"})]}),a.jsx("span",{className:"tb-word-wider",children:"Settings"})]}),a.jsxs("button",{className:"btn icon-btn tb-fold",onClick:o,title:"Send feedback — a problem, an idea or anything else, to the people who make ccdeck","aria-label":"Send feedback","aria-haspopup":"dialog",children:[a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("path",{d:"M2.2 3.3h9.6v5.3H6.1L3.5 10.8V8.6H2.2Z"}),a.jsx("path",{d:"M7 4.9v1.7"}),a.jsx("path",{d:"M7 7.7v.05"})]}),a.jsx("span",{className:"tb-word-wide",children:"Feedback"})]}),a.jsx(Ose,{watchUnseen:l,setUsageHistoryOpen:c,setBrowserWatchOpen:d,onFeedback:o})]})}const Fse=5*6e4,Bse=6e4;function qse({shown:e,tabVisible:t,lastReadAt:n,now:r,lastSince:s,since:o}){return!e||!t?!1:s&&o&&s!==o?!0:n===null||r-n>=Fse}function gM(e=new Date){return PI("month",e)}function Use(e){const t=vh(e);return{cost:t.cost,tokens:t.tokens}}function yM(e){return e>0?We(e):"$0.00"}const zse=new Set(["idle","checking","current","downloading","ready","error"]);function wM(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.status!="string"||!zse.has(t.status))return null;const n=typeof t.version=="string"&&t.version.trim()?t.version.trim():null;return t.status==="ready"&&!n?null:{status:t.status,version:n}}function Wse(e){return(e==null?void 0:e.status)==="ready"&&e.version?{version:e.version}:null}function Hse(e=typeof navigator>"u"?"":navigator.userAgent){var t;return((t=/\bccdeck-desktop\/(\d[^\s]*)/.exec(e))==null?void 0:t[1])??null}const Yd="Restart to update",MP=3e4;function Vse(e=typeof navigator>"u"?"":navigator.userAgent){return/\bMac OS X\b|\bMacintosh\b/.test(e)?"the ccdeck menu in the menu bar":"the ccdeck tray menu"}function Gse(e,t){const n=`v${e} → v${t}`;return{text:n,label:`${n}, update downloaded and verified`,title:`ccdeck v${t} is downloaded and verified · click to open What's new, where ${Yd} comes first`}}function Kse(e){const t=e==null?void 0:e.reason;return t==="app_disconnected"||t==="update_not_ready"?t:"refused"}function Yse(e,t,n=typeof navigator>"u"?"":navigator.userAgent){const r=Vse(n),s=`Use ${Yd} in ${r}.`;switch(e){case"app_disconnected":return`Nothing restarted: the app is not connected to this deck, so the request had nowhere to go. ${s}`;case"update_not_ready":return`Nothing restarted: the app no longer has v${t} ready. When it has one, ${Yd} is in ${r}.`;case"timeout":return`ccdeck has not restarted after ${MP/1e3} seconds. ${s}`;case"refused":return`Nothing restarted: the deck turned the request down. ${s}`;case"unreachable":return`Nothing restarted: the request did not reach the deck. ${s}`}}const Xse="Update checks are off (AGENTS_DECK_NO_UPDATE_CHECK=1)",Nx="click for what's new";function Zse(e){if(e.checkDisabled)return`${Xse} · ${Nx}`;if(e.checking)return`Asking npm for the newest release… · ${Nx}`;const t=e.latest?`npm has v${e.latest}`:e.latestPending?`npm's latest tag names v${e.latestPending}, which it cannot serve yet`:"npm not reached yet",n=e.checkFailedAgo?` · could not reach npm ${e.checkFailedAgo}`:e.checkedAgo?` · checked ${e.checkedAgo}`:"";return`${t}${n} · re-checked periodically · ${Nx}, and to check npm now`}function Jse(e){const t=`Version v${e.running}, show what's new`;return e.checkDisabled?`${t} — update checks are off`:e.checking?`${t} — checking npm for a newer release`:e.checkFailedAgo?`${t} — npm could not be reached ${e.checkFailedAgo}, check again`:`${t} and check npm for a newer release`}function Qse(e){const t=e.kind==="restart"?`v${e.to} is installed and waiting for a restart`:`v${e.to} is available on npm`,n=e.open?"show what's new":"show what's new and the notice";return`Version v${e.from}, ${t} — ${n}`}function $P(e){return e?`${e.kind}:${e.to}`:""}function eae(e,t){return e!=null&&t!==$P(e)}function tae({readyAppUpdate:e,notice:t,noticeOpen:n,version:r,chipVersion:s,versionChecking:o,now:l,openReleaseNotes:c,showNotice:d,loadVersion:h}){return a.jsx(a.Fragment,{children:e?(()=>{const f=Gse(Hse()??s,e.version);return a.jsxs("button",{type:"button",className:"v ready",onClick:c,"aria-haspopup":"dialog","aria-label":f.label,title:f.title,children:[f.text,a.jsx("span",{className:"v-dot","aria-hidden":!0})]})})():t?a.jsxs("button",{type:"button",className:"v stale",onClick:()=>{c(),d()},"aria-haspopup":"dialog","aria-label":Qse({...t,open:n}),title:t.kind==="restart"?`Running v${t.from}; v${t.to} is installed on disk. Restart to pick it up · click for what's new`:`Running v${t.from}; v${t.to} is on npm · click for what's new`,children:["v",t.from,a.jsx("span",{className:"v-dot","aria-hidden":!0})]}):(()=>{const f={running:s,latest:r==null?void 0:r.latest,latestPending:r==null?void 0:r.latestPending,checkedAgo:r!=null&&r.checkedAt?$d(l-r.checkedAt):null,checkFailedAgo:r!=null&&r.checkFailedAt&&r.checkFailedAt>(r.checkedAt??0)?$d(l-r.checkFailedAt):null,checkDisabled:r==null?void 0:r.checkDisabled,checking:o};return a.jsxs("button",{type:"button",className:o?"v checking":"v",onClick:()=>{c(),h(!0)},"aria-busy":o||void 0,"aria-haspopup":"dialog","aria-label":Jse(f),title:Zse(f),children:["v",f.running]})})()})}function nae({live:e,paused:t,pauseGate:n,monthUsageRef:r,monthlyUsage:s,monthlyUsageUnavailable:o}){return a.jsxs("span",{className:"status",children:[(()=>{const l=TW({connected:e,paused:t,held:n.size,dropped:n.dropped});return l.resting?null:a.jsx("span",{className:`pill ${l.tone}`,title:l.title,children:a.jsxs("span",{className:"pill-box",children:[a.jsx("span",{className:"pill-widest","aria-hidden":!0,children:l.widest}),a.jsx("span",{className:"pill-label",children:l.label})]})})})(),a.jsxs("span",{ref:r,className:"month-usage",title:s?`${s.tokens.toLocaleString()} tokens · ${yM(s.cost)} spent since the 1st of this local calendar month`:o?"Monthly usage is unavailable — ccusage could not be read":"Loading usage since the 1st of this local calendar month",children:[a.jsx("span",{className:"month-usage-label",children:"this month"}),s?a.jsxs(a.Fragment,{children:[a.jsx("b",{children:st(s.tokens)}),a.jsx("span",{className:"month-usage-unit",children:"tokens"}),a.jsx("span",{className:"month-usage-sep","aria-hidden":!0,children:"·"}),a.jsx("b",{children:yM(s.cost)})]}):a.jsx("span",{className:"month-usage-pending",children:o?"unavailable":"…"})]})]})}function rae({waitingSessions:e,waitingCursorRef:t,focusSession:n,now:r}){return a.jsxs("button",{type:"button",className:"waiting-stat",onClick:()=>{t.current=e[0].id,n(e[0].id)},title:`Blocked waiting for you — click, or press W, to go to the one that has been stuck longest:
106
- ${e.map(s=>` ${s.label}: ${bi(s.waiting)} (${$d(r-s.waiting.since)})`).join(`
107
- `)}`,"aria-label":`${e.length} session${e.length===1?"":"s"} waiting for you`,children:[a.jsx("span",{className:"ap-pulse","aria-hidden":!0}),a.jsx("b",{children:e.length})," ",a.jsx("span",{className:"ws-word",children:"waiting"})]})}const qb={on:"The deck will raise a system notification when a session blocks on you and this tab is in the background",blocked:"Notifications are blocked for this page. Only your browser can undo that — its site settings for this address"};function sae(e){return e==="on"?`Notifications on. ${qb.on}.`:e==="blocked"?`${qb.blocked}.`:""}function aae({notifySaid:e}){return a.jsx("span",{className:e==="on"?"notify-said":"notify-said notify-said-blocked","aria-hidden":!0,title:qb[e],children:e==="on"?"notifications on":"notifications blocked"})}function oae({versionCheck:e,welcome:t,desktopUpdate:n,pause:r,monthly:s,announcements:o,notify:l,waitingSessions:c,waitingCursorRef:d,focusSession:h,live:f,now:p,incidents:g}){const{version:v,notice:j,noticeOpen:k,showNotice:x,versionChecking:N,loadVersion:b}=e,{chipVersion:S,openReleaseNotes:E}=t,{readyAppUpdate:R}=n,{paused:I,pauseGate:A}=r,{monthlyUsage:q,monthlyUsageUnavailable:$,monthUsageRef:B}=s,{blockedSaid:L,watchSaid:M,incidentSaid:F}=o,{notifySaid:T}=l;return a.jsxs("div",{className:"readout",children:[a.jsxs("div",{className:"brand",children:[a.jsx("img",{className:"logo logo-on-dark",src:l9,width:19,height:16,alt:""}),a.jsx("img",{className:"logo logo-on-light",src:c9,width:19,height:16,alt:""}),a.jsx("h1",{children:xt}),a.jsx(tae,{readyAppUpdate:R,notice:j,noticeOpen:k,version:v,chipVersion:S,versionChecking:N,now:p,openReleaseNotes:E,showNotice:x,loadVersion:b})]}),a.jsx(nae,{live:f,paused:I,pauseGate:A,monthUsageRef:B,monthlyUsage:q,monthlyUsageUnavailable:$}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:L}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:M}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:F}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:sae(T)}),a.jsx(u9,{incidents:g}),c.length>0&&a.jsx(rae,{waitingSessions:c,waitingCursorRef:d,focusSession:h,now:p}),T&&a.jsx(aae,{notifySaid:T})]})}function iae({selected:e,now:t,selectedIds:n,focusAgent:r,clearSelection:s}){const o=gn(e),l=Math.max(0,((e.endedAt??t)-e.startedAt)/1e3),c=e.state==="active"&&!e.synthetic?wk(o.total,l):null,d=n.size-1;return a.jsxs("button",{type:"button",className:"selected-ribbon",title:`Zoom to ${e.label} and its session (Z)${o.total>0?`
108
- ${We(o.total)} spent${c?` · ${c}`:""}`:""}`,onClick:()=>{try{r(e.id)}catch{}},children:[a.jsx("span",{className:`state-pill state-${e.state}`,children:e.state==="active"?"live":e.state}),a.jsx("span",{className:"selected-label",children:e.label}),o.total>0&&a.jsxs("span",{className:"selected-cost",children:[We(o.total),c?a.jsxs("span",{className:"selected-rate",children:[" · ",c]}):null]}),d>0&&a.jsxs("span",{className:"selected-extra",children:["+",d]}),a.jsx("span",{"aria-hidden":!0,className:"selected-close",onClick:h=>{h.stopPropagation(),s()},children:"×"})]})}function lae({catBarRef:e,catBarOccluded:t,presentCats:n,hiddenCats:r,toggleCat:s}){return a.jsx("div",{ref:e,className:`cat-filter-bar${t?" occluded":""}`,role:"group","aria-label":"Filter tools by category",children:n.map(o=>{const l=r.has(o);return a.jsxs("button",{type:"button",className:`cat-filter${l?" off":""}`,onClick:()=>s(o),"aria-pressed":!l,title:`${l?"Show":"Hide"} ${Kd[o]} tools`,children:[a.jsx(Nse,{cat:o}),a.jsx("span",{className:"cat-name",children:Kd[o]})]},o)})})}const cae=["a[href]","button:not(:disabled)","input:not(:disabled)","select:not(:disabled)","textarea:not(:disabled)","summary","[tabindex]"].join(",");function uae(e){var n,r;const t=e.target;!(t!=null&&t.closest)||t.closest(cae)!==e.currentTarget||(e.preventDefault(),(r=(n=document.activeElement)==null?void 0:n.blur)==null||r.call(n))}function dae({trashZoneRef:e,trashState:t,trashPhase:n,trashLabel:r}){return a.jsxs("div",{ref:e,className:`drag-trash-zone ${t}${n==="leaving"?" leaving":""}`,role:"status",children:[a.jsx("svg",{className:"drag-trash-icon",viewBox:"0 0 24 24","aria-hidden":"true",children:a.jsx("path",{d:"M8 7V5.8C8 4.8 8.8 4 9.8 4h4.4c1 0 1.8.8 1.8 1.8V7m-10 0h12M8 10v8m4-8v8m4-8v8M7 7l.7 13h8.6L17 7"})}),a.jsxs("span",{className:"drag-trash-copy",children:[a.jsx("span",{className:"drag-trash-text",children:t==="over"?a.jsxs(a.Fragment,{children:["Release to remove ",a.jsx("strong",{className:"drag-trash-name",children:r||"this card"})]}):"Drop here to remove from the board"}),a.jsx("span",{className:"drag-trash-hint",children:t==="over"?"The session list (L) brings it back":"The session keeps running"})]})]})}function hae({canvasRef:e,bubbling:t,dragging:n,trash:r,zoom:s,viewport:o,stateRef:l,peek:c,children:d}){const{trashDragging:h,trashState:f,trashPhase:p,trashZoneRef:g,trashLabel:v}=r,{lod:j,lodRef:k}=s,{markCanvasInput:x}=o,{peekAgent:N,peekLabel:b,peekRecap:S,peekBounds:E}=c;return a.jsxs("main",{id:"canvas",tabIndex:-1,className:`canvas-wrap${t?" bubbling":""}${n?" dragging-any":""}${h&&f==="over"?" trash-hover":""}`,"data-lod":j,ref:e,onMouseDownCapture:uae,onPointerDownCapture:x,onPointerUpCapture:x,onWheelCapture:x,onFocusCapture:R=>{const I=R.target;if(!m0(I)||k.current==null||k.current==="detail")return;const A=I.getAttribute("data-id");A&&l.current.agents.has(A)&&I.matches(":focus-visible")&&yP(A,I,"focus")},onBlurCapture:R=>{var A,q;const I=(q=(A=R.target).getAttribute)==null?void 0:q.call(A,"data-id");I&&ia(I)},children:[d,Fa(p)&&a.jsx(dae,{trashZoneRef:g,trashState:f,trashPhase:p,trashLabel:v}),a.jsx(Kne,{agentFor:N,recapFor:S,labelFor:b,bounds:E})]})}function fae({restarting:e,restartMode:t,live:n,paused:r}){return a.jsxs("div",{className:"conn-banner",role:"alert",children:[a.jsx("span",{className:"conn-dot"}),e?t==="npx"?"Fetching the new version with npx — this can take a minute…":`Restarting ${xt}…`:(()=>{const s=EW({connected:n,paused:r});return a.jsxs(a.Fragment,{children:[`Lost connection to the ${xt} server. Reconnecting…`,s&&a.jsx("span",{className:"conn-sub",children:s})]})})()]})}function pae({oldName:e,version:t,dismissOldName:n}){return a.jsxs("div",{className:"ver-banner",role:"status",children:[a.jsx("span",{className:"ver-dot"}),a.jsxs("strong",{children:[e," still works — the deck is called ",xt," now."]}),t!=null&&t.renameFix?a.jsx("span",{className:"ver-sub",children:t.renameFix}):null,a.jsx("button",{type:"button","aria-label":"Dismiss",className:"ver-close",onClick:n,children:"×"})]})}const IP="Thanks — that helps.",mae=Array.from({length:11},(e,t)=>t);function gae(e){return e===0?"0 out of 10, not useful":e===10?"10 out of 10, extremely useful":`${e} out of 10`}const yae=6;function wae(e){const t=y.useRef(null);return y.useLayoutEffect(()=>{const n=t.current,r=n==null?void 0:n.closest(".app");if(!n||!r)return;const s=()=>r.style.setProperty("--rating-h",`${Math.ceil(n.getBoundingClientRect().height)}px`);s();const o=typeof ResizeObserver>"u"?null:new ResizeObserver(s);return o==null||o.observe(n),()=>{o==null||o.disconnect(),r.style.removeProperty("--rating-h")}},[e]),t}function vae(){var e;(e=document.getElementById("canvas"))==null||e.focus()}function xae({phase:e,score:t,onAnswer:n,onLater:r,onClose:s,onFeedback:o,onHold:l}){const c=wae(e),d=y.useRef(null),h=y.useRef(null),f=y.useRef(!1);y.useEffect(()=>{var g,v;e!=="thanks"||!f.current||(f.current=!1,An(((g=document.activeElement)==null?void 0:g.tagName)??null)&&((v=d.current??h.current)==null||v.focus()))},[e]);const p=g=>{var v;(v=c.current)!=null&&v.contains(document.activeElement)&&vae(),g()};return e==="thanks"?a.jsxs("div",{ref:c,className:"ver-banner note rating-banner",onFocus:()=>l(!0),onBlur:g=>{g.currentTarget.contains(g.relatedTarget)||l(!1)},children:[a.jsx("span",{className:"ver-dot"}),a.jsx("strong",{children:IP}),t!==null&&t<=yae?a.jsx("button",{ref:d,type:"button",className:"ver-act",onClick:o,children:"Tell us what would make it better"}):null,a.jsx("button",{ref:h,type:"button","aria-label":"Dismiss",className:"ver-close",onClick:()=>p(s),children:"×"})]}):a.jsxs("div",{ref:c,className:"ver-banner note rating-banner",role:"group","aria-labelledby":"rating-question",children:[a.jsx("span",{className:"ver-dot"}),a.jsx("strong",{id:"rating-question",children:"How useful is ccdeck to you?"}),a.jsx("span",{className:"rating-scale",children:mae.map(g=>a.jsx("button",{type:"button",className:"rating-pick","aria-label":gae(g),onClick:v=>{f.current=v.detail===0||v.currentTarget.matches(":focus-visible"),n(g)},children:g},g))}),a.jsx("span",{className:"ver-sub rating-ends","aria-hidden":"true",children:"0 not at all · 10 extremely"}),a.jsx("button",{type:"button",className:"ver-act",onClick:()=>p(r),children:"Not now"})]})}const bae=3e4;function kae({bundle:e,running:t,lastTried:n}){return!t||e===t?!1:n!==t}function Nae({bundle:e,running:t,pending:n,lastTried:r}){return t?kae({bundle:e,running:t,lastTried:r})?"reload":n==null||n&&n!==t?"wait":"confirm":"wait"}function jae(e){return!e||e.state!=="failed"?null:`${typeof e.at=="number"?e.at:0}:${e.error??""}`}function Sae({asked:e,reported:t}){return t?t!==e:!1}function OP(e){const t=e.thresholdMs??bae;return!e.enabled||e.kind!=="restart"||!e.canRestart||!e.noticeOpen||!e.visible||e.busy?null:e.idleSince==null||e.now<e.idleSince?t:Math.max(0,t-(e.now-e.idleSince))}function _ae(e){const t=Math.max(0,Math.ceil(e/1e3));return t<60?`${t}s`:`${Math.floor(t/60)}:${String(t%60).padStart(2,"0")}`}function Eae(e,t){return e?t==null?"auto when idle":`auto in ${_ae(t)}`:"auto-restart off"}function vM(e){let t=0;for(const n of e)n.state==="active"&&t++;return t}function Cae(e,t=!1){return e<=0&&t?{label:"Restart anyway",clause:"the canvas is paused — running agents cannot be seen"}:e<=0?{label:"Restart now",clause:"nothing is running"}:{label:"Restart anyway",clause:`${e===1?"1 agent is running":`${e} agents are running`} — their events during the restart are lost`}}function Tae(e){const t=OP(e);return t==null?{idleSince:null,restart:!1,remainingMs:null}:e.idleSince==null||e.now<e.idleSince?{idleSince:e.now,restart:!1,remainingMs:t}:{idleSince:e.idleSince,restart:t===0,remainingMs:t}}const xM={git_checkout:"this deck runs from a git checkout — pull instead:",npx:"npx runs from a cache that cannot be upgraded in place — run:",one_off:"this deck runs from a one-off pnpm dlx, bunx or yarn dlx copy that cannot be upgraded in place — to keep one, run:",not_writable:"the install directory is not writable by this user — run:",opted_out:"installs are off (AGENTS_DECK_NO_INSTALL=1) — run:",retired_name:"this install came from a name that is no longer published — run:"};function Aae({notice:e,version:t,dismissNotice:n,upgradeState:r,startUpgrade:s,copyCommand:o,cmdCopied:l,autoRestart:c,toggleAutoRestart:d,askRestart:h,restartCopy:f,restartFuseMs:p,restarting:g}){var v,j,k;return a.jsxs("div",{className:`ver-banner ${e.kind}`,role:"status",children:[a.jsx("span",{className:`ver-dot${p==null?"":" armed"}`}),e.kind==="restart"?a.jsxs(a.Fragment,{children:[a.jsxs("strong",{children:["v",e.to," is installed — this deck still runs v",e.from,"."]}),t!=null&&t.canRestart?a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",className:"ver-act",onClick:()=>h(),...Wr(g),title:`Stop this process and bring it back on the same port. The canvas replays from the event log.
109
-
110
- Node loads every module once, at startup. An upgrade replaces the files on disk but not the code already in memory, so this process keeps running the old version until it is restarted.`,children:g?"restarting…":f.label}),!g&&a.jsx("span",{className:"ver-sub",children:f.clause}),a.jsxs("label",{className:"ver-auto",children:[a.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":c,onClick:d,"aria-label":"Auto-restart when idle",title:c?"Updates on its own. While you are here it restarts once nothing has been running for 30 seconds; while you are away it also installs the new version first. Click to require a click instead.":"Only updates when you click. Click to let it update itself when idle or while you are away.",children:a.jsx("span",{className:"switch-knob"})}),a.jsx("span",{"aria-hidden":!0,children:Eae(c,p)})]})]}):a.jsx("span",{className:"ver-sub",title:"Node loads every module once, at startup. An upgrade replaces the files on disk but not the code already in memory, so this process keeps running the old version until it is restarted.",children:"Restart it to pick up the new code."})]}):a.jsxs(a.Fragment,{children:[a.jsxs("strong",{children:[xt," v",e.to," is out — you are on v",e.from,"."]}),(t==null?void 0:t.upgradeMode)==="install"&&r!=="failed"&&a.jsx("button",{type:"button",className:"ver-act",onClick:s,...Wr(r==="running",r==="done"),title:`Runs ${((v=t==null?void 0:t.upgrade)==null?void 0:v.command)??(t==null?void 0:t.command)??"npm i -g"} here, then restarts once nothing is running.`,children:r==="running"?"installing…":r==="done"?"installed":"Update now"}),(t==null?void 0:t.upgradeMode)==="npx"&&(t==null?void 0:t.canRestart)&&a.jsx("button",{type:"button",className:"ver-act",onClick:()=>h({upgrade:!0}),...Wr(g),title:`Runs ${t==null?void 0:t.command} and hands it this port. Nothing is installed globally — npx unpacks its own copy.`,children:g?"fetching…":r==="failed"?"Retry update":"Update & restart"}),r==="failed"?a.jsxs("span",{className:"ver-sub fail",title:((j=t==null?void 0:t.upgrade)==null?void 0:j.error)??"",children:[(t==null?void 0:t.upgradeMode)==="npx"?"update failed":"install failed",": ",((k=t==null?void 0:t.upgrade)==null?void 0:k.error)??"unknown error"," — run it yourself:"]}):(t==null?void 0:t.upgradeMode)==="npx"?a.jsx("span",{className:"ver-sub",children:t!=null&&t.canRestart?"npx cannot upgrade in place, so the deck re-runs:":xM.npx}):t!=null&&t.upgradeBlocked?a.jsx("span",{className:"ver-sub",children:Lt(xM,t.upgradeBlocked)??"cannot install from here"}):null,a.jsxs("button",{type:"button",className:"ver-cmd",onClick:o,title:"Copy to clipboard",children:[a.jsx("code",{children:t==null?void 0:t.command}),a.jsx("span",{className:"ver-cmd-hint",children:l?"copied":"copy"})]})]}),a.jsx("button",{type:"button","aria-label":"Dismiss",className:"ver-close",onClick:n,children:"×"})]})}function Rae({restart:e,versionCheck:t,upgrade:n,oldNameNotice:r,rating:s,onFeedback:o,everConnected:l,live:c,paused:d}){const{autoRestart:h,toggleAutoRestart:f,restarting:p,restartMode:g,restartedTo:v,askRestart:j,restartCopy:k,restartFuseMs:x}=e,{version:N,notice:b,noticeOpen:S,dismissNotice:E}=t,{upgradeState:R,startUpgrade:I,copyCommand:A,cmdCopied:q}=n,{oldName:$,oldNameOpen:B,dismissOldName:L}=r,{ratingPhase:M,ratingScore:F,answerRating:T,rateLater:P,closeRating:O,holdThanks:G}=s,K=v?a.jsxs("div",{className:"ver-banner done",role:"status",children:[a.jsx("span",{className:"ver-dot"}),a.jsxs("strong",{children:["Restarted — now running v",v,"."]}),a.jsx("span",{className:"ver-sub",children:"The canvas replayed from the event log."})]}):l&&!c?a.jsx(fae,{restarting:p,restartMode:g,live:c,paused:d}):S&&b?a.jsx(Aae,{notice:b,version:N,dismissNotice:E,upgradeState:R,startUpgrade:I,copyCommand:A,cmdCopied:q,autoRestart:h,toggleAutoRestart:f,askRestart:j,restartCopy:k,restartFuseMs:x,restarting:p}):B&&$?a.jsx(pae,{oldName:$,version:N,dismissOldName:L}):M!=="hidden"?a.jsx(xae,{phase:M,score:F,onAnswer:T,onLater:P,onClose:O,onFeedback:o,onHold:G}):null;return a.jsxs(a.Fragment,{children:[K,a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:M==="thanks"?IP:""})]})}function Mae(e,t){return e==="confirmation"?t.confirmOpen?"clear":"ignore":t.modalOpen||t.confirmOpen?"ignore":"confirm"}function $ae(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.decks!="number"||typeof t.mine!="boolean")return null;const n=t.owner&&typeof t.owner=="object"?t.owner.port:null;return{path:typeof t.path=="string"&&t.path!==""?t.path:null,decks:t.decks,mine:t.mine,ownerPort:typeof n=="number"?n:null}}function Iae(e){return e<=0?null:e===1?"the one agent":`all ${e} agents`}function Oae(e,t){const n=Iae(e),r=(...l)=>[n?`${n} on the canvas`:null,...l,"layout, pins and selection"].filter(c=>c!==null),s="This cannot be undone.";if(!t)return{goes:r("the event log on disk — the file a restarted deck replays to rebuild what you see, and the file every deck on this machine shares unless one was told otherwise"),stays:[],final:s,confirm:"Clear everything"};if(!t.path)return{goes:r(),stays:[],final:`This deck keeps no event log, so nothing on disk changes — and nothing can bring the canvas back. ${s}`,confirm:"Clear everything"};if(!t.mine){const l=t.ownerPort===null?"another running deck owns that file":`the deck on port ${t.ownerPort} owns that file`,c=t.decks>2?`, one of ${t.decks} decks sharing it`:"";return{goes:r(),stays:[`the event log — ${l}${c}`,"restart this deck and the log replays back onto it"],final:null,confirm:"Clear this canvas"}}if(t.decks<=1)return{goes:r("this deck's event log — the file a restarted deck replays to rebuild what you see"),stays:[],final:s,confirm:"Clear everything"};const o=t.decks-1;return{goes:r(`the event log ${o===1?"1 other running deck shares":`${o} other running decks share`} with this one — every session recorded in it, not just the ones drawn here`),stays:[o===1?"what that deck shows, until it restarts — then it is gone there too":"what those decks show, until they restart — then it is gone there too"],final:s,confirm:"Clear everything"}}function Lae({agentCount:e,onConfirm:t,onCancel:n}){const r=y.useRef(null),s=ot(n,{focusRef:r,layer:ZU}),o=mt(n),[l,c]=y.useState(null);y.useEffect(()=>{let g=!1;return fetch("/api/clear").then(v=>v.ok?v.json():null).then(v=>{g||c($ae(v))}).catch(()=>{}),()=>{g=!0}},[]);const{goes:d,stays:h,final:f,confirm:p}=Oae(e,l);return a.jsx("div",{className:"modal-backdrop",...o,role:"presentation",children:a.jsxs("div",{ref:s,className:"modal clear-confirm",onClick:g=>g.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"clear-confirm-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsxs("div",{className:"modal-title",children:[a.jsx("span",{className:"status-dot err","aria-hidden":!0}),a.jsx("span",{id:"clear-confirm-title",className:"modal-tool-name",children:"Clear the deck?"})]}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:n,"aria-label":"Cancel (Esc)",title:"Cancel (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[a.jsxs("dl",{className:"cc-plan",children:[a.jsx("dt",{children:"Goes"}),a.jsx("dd",{children:d.map(g=>a.jsx("span",{children:g},g))}),a.jsx("dt",{children:"Stays"}),a.jsx("dd",{children:h.length>0?h.map(g=>a.jsx("span",{children:g},g)):a.jsx("span",{children:"nothing"})})]}),f&&a.jsx("p",{className:"cc-final",children:f}),a.jsxs("div",{className:"cc-actions",children:[a.jsx("button",{type:"button",ref:r,className:"btn",onClick:n,children:"Cancel"}),a.jsx("button",{type:"button",className:"btn danger",onClick:t,children:p})]})]})]})})}const Xd=[{value:"bug",label:"Bug",question:"What happened?",placeholder:`I was trying to…
111
- What did you expect to happen?`},{value:"idea",label:"Idea",question:"What would make ccdeck better?",placeholder:"It would be useful if…"},{value:"other",label:"Other",question:"What would you like to tell us?",placeholder:"Write anything…"}];function LP(e){return Xd.find(t=>t.value===e)??Xd[0]}const Ub=3,jx=120,PP=1e4,DP=200,Pae="Write something first.";function bM(e){return e.trim()!==""}function Dae(e){var o;const t=e.trim();if(t==="")return"";const n=kM(t.split(/\r?\n/,1)[0]),r=((o=/^(.+?[.!?])(?=\s|$)/.exec(n))==null?void 0:o[1])??n,s=Sx(r).length>=Ub?Sx(r):Sx(n);return Bae(s.length>=Ub?s:kM(t))}function Fae(e,t){const n=Dae(t);return n.length>=Ub?n:`${LP(e).label}: ${n}`}function kM(e){return e.replace(/\s+/g," ").trim()}function Sx(e){return/[^.]\.$/.test(e)?e.slice(0,-1):e}function Bae(e){if(e.length<=jx)return e;const t=e.slice(0,jx-1),n=t.lastIndexOf(" ");return`${(n>=jx/2?t.slice(0,n):t).replace(/[\uD800-\uDBFF]$/,"").replace(/[\s,;:.\-–—]+$/,"")}…`}function qae({kind:e,body:t,contact:n}){const r={kind:e,title:Fae(e,t),body:t.trim()};return n.trim()!==""&&(r.contact=n.trim()),r}function Uae(e){const t=e;return(t==null?void 0:t.ok)!==!0||typeof t.appVersion!="string"||typeof t.platform!="string"||t.appVersion===""||t.platform===""?null:{appVersion:t.appVersion,platform:t.platform}}const zae={darwin:"macOS",win32:"Windows",linux:"Linux"};function Wae(e){const t=e.indexOf("-"),n=t===-1?e:e.slice(0,t),r=t===-1?"":e.slice(t+1),s=zae[n]??n;return r?`${s} · ${r}`:s}function Hae(e){return e?`ccdeck ${e.appVersion} · ${Wae(e.platform)}`:null}const Vae="sent with it",Gae="Your ccdeck version and system are sent with it.",Kae="Add details",Yae="How to reach you",Xae="Email or GitHub @name",Zae="Only if you would like an answer.",Jae=["It all goes to the people who make ccdeck, with the version and system below.","Nothing becomes public by being sent. They may open a public GitHub issue from it, choosing its title and text; your contact and screenshots are never put on one."];function Qae(e){return e.key==="Enter"&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey&&!e.isComposing}function FP(e){return e.key==="Enter"&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey&&!e.isComposing}function eoe(e){return b0(e)?["⌘","Enter"]:["Ctrl","Enter"]}function toe(e){return[...e].length===1}const BP="Thanks — feedback sent.";function NM(e,t,n){if(t==="vetoed")return"This deck was started with AGENTS_DECK_NO_INSTALL=1, which keeps it off the network, so nothing was sent.";if(e===429||t==="too_many")return"Too much feedback from this network in the last hour. Try again later; your text is still here.";if(e===413||t==="too_large")return"The images are too large to send together. Remove one and send again; your text is still here.";const r=n==null?void 0:n.images;return e===400&&Array.isArray(r)&&typeof r[0]=="string"?`The server did not accept an image. ${r[0]} Remove it and send again; your text is still here.`:e===400?"The server did not accept the message. It is still here; check it and send again.":"ccdeck's server could not be reached. Nothing was sent; your text is still here."}function noe(e){return e==="sending"?"Sending…":e==="sent"?BP:""}const jM=1400,roe=160;function soe({kind:e,onChange:t}){return a.jsxs("fieldset",{className:"fb-kinds",children:[a.jsx("legend",{className:"vis-hidden",children:"Kind of feedback"}),Xd.map(n=>a.jsxs("label",{className:"fb-kind",children:[a.jsx("input",{type:"radio",name:"feedback-kind",value:n.value,checked:e===n.value,onChange:()=>t(n.value),onKeyDown:r=>{FP(r.nativeEvent)&&r.preventDefault()}}),n.label]},n.value))]})}const qP="fb-details";function aoe({open:e,onToggle:t}){return a.jsxs("button",{type:"button",className:"fb-tool fb-more","aria-expanded":e,"aria-controls":qP,onClick:t,children:[Kae,a.jsx("svg",{className:"fb-chev",width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,focusable:"false",children:a.jsx("path",{d:"M2.5 3.75 5 6.25l2.5-2.5"})})]})}function ooe({open:e,contact:t,onContact:n}){const r=y.useId();return a.jsx("div",{id:qP,className:"fb-details","data-open":e||void 0,children:a.jsx("div",{className:"fb-details-clip",children:a.jsxs("div",{className:"fb-details-body",children:[a.jsxs("div",{className:"fb-field",children:[a.jsxs("label",{className:"fb-field-label",htmlFor:"fb-contact",children:[Yae,a.jsx("span",{className:"fb-optional",children:"optional"})]}),a.jsx("input",{id:"fb-contact",className:"ap-manage-input",type:"text",value:t,maxLength:DP,autoComplete:"email",placeholder:Xae,"aria-describedby":r,onChange:s=>n(s.target.value),onKeyDown:s=>{FP(s.nativeEvent)&&s.preventDefault()}}),a.jsx("p",{id:r,className:"fb-hint",children:Zae})]}),a.jsx("div",{className:"fb-where",children:Jae.map(s=>a.jsx("p",{children:s},s))})]})})})}const Va=3,ioe=5*1024*1024,loe=12*1024*1024,zb=8192,coe=64*1024,uoe=256*1024,doe=.92,hoe=640,UP=.9,foe=.85,poe=6,moe=512*1024,Zd={png:"image/png",jpeg:"image/jpeg"},goe={png:"png",jpeg:"jpg"},yoe=[137,80,78,71,13,10,26,10],woe=[255,216,255];function zP(e){const t=n=>e.length>=n.length&&n.every((r,s)=>e[s]===r);return t(yoe)?"png":t(woe)?"jpeg":null}function voe(e){const t=zP(e);return t==="png"?xoe(e):t==="jpeg"?koe(e):null}function xoe(e){const t=[73,72,68,82];if(e.length<24||!t.every((r,s)=>e[12+s]===r))return null;const n=new DataView(e.buffer,e.byteOffset,e.byteLength);return{width:n.getUint32(16),height:n.getUint32(20)}}function boe(e){return e>=192&&e<=207&&e!==196&&e!==200&&e!==204}function koe(e){let t=2;for(;t<e.length;){if(e[t]!==255)return null;for(;t<e.length&&e[t]===255;)t++;const n=e[t++];if(n===void 0||n===217||n===218)return null;if(n===1||n>=208&&n<=215)continue;if(t+2>e.length)return null;const r=e[t]<<8|e[t+1];if(r<2)return null;if(boe(n))return t+7>e.length?null:{height:e[t+3]<<8|e[t+4],width:e[t+5]<<8|e[t+6]};t+=r}return null}function SM(e,t){return e.bytes>t||e.width>zb||e.height>zb}function Noe(e){return Math.min(ioe,loe-coe-e)}function WP(e,t){return{width:Math.max(1,Math.floor(e.width*t)),height:Math.max(1,Math.floor(e.height*t))}}function joe(e,t){const n=zb/Math.max(e.width,e.height),r=e.bytes>t?Math.sqrt(t/e.bytes)*UP:1;return WP(e,Math.min(1,n,r))}async function Soe(e,t,n){let r=joe(e,t),s=e.format;for(let o=0;o<poe;o++){const l=await n(r,s,s==="jpeg"?doe:void 0);if(!l)return null;if(l.size<=t)return{...r,blob:l,format:s};if(s==="png"){s="jpeg";continue}if(r=WP(r,Math.min(foe,Math.sqrt(t/l.size)*UP)),Math.max(r.width,r.height)<hoe)return null}return null}async function _oe(e,t,n){const r=new Uint8Array(await e.slice(0,moe).arrayBuffer()),s=zP(r);if(!s)return{ok:!1,problem:"type"};if(t<uoe)return{ok:!1,problem:"no_room"};const o=e.type===Zd[s]?e:new Blob([e],{type:Zd[s]}),l=voe(r);if(l&&!SM({...l,bytes:e.size},t))return{ok:!0,blob:o,resized:null};const c=await n(e).catch(()=>null);if(!c)return{ok:!1,problem:"unreadable"};try{const d={width:c.width,height:c.height,bytes:e.size,format:s};if(!SM(d,t))return{ok:!0,blob:o,resized:null};const h=await Soe(d,t,c.encoder);return h?{ok:!0,blob:h.blob,resized:{width:h.width,height:h.height}}:{ok:!1,problem:"too_large"}}finally{c.release()}}function Eoe(e){return({width:t,height:n},r,s)=>new Promise(o=>{const l=document.createElement("canvas");l.width=t,l.height=n;const c=l.getContext("2d");if(!c)return o(null);r==="jpeg"&&(c.fillStyle="white",c.fillRect(0,0,t,n)),c.imageSmoothingQuality="high",c.drawImage(e,0,0,t,n),l.toBlob(d=>{l.width=0,l.height=0,o(d)},Zd[r],s)})}const Coe=async e=>{const t=await createImageBitmap(e);return{width:t.width,height:t.height,encoder:Eoe(t),release:()=>t.close()}};function Toe(e){return e.includes("Files")}function Aoe({files:e,hasText:t,intoTextField:n}){return e>0&&(!t||!n)}function Roe(e,t){const n=e.indexOf(t);return e[n+1]??e[n-1]??null}function Moe(e,t){if(t.length===0)return{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)};const n=new FormData;return n.append("kind",e.kind),n.append("title",e.title),n.append("body",e.body),e.contact!==void 0&&n.append("contact",e.contact),t.forEach((r,s)=>{const o=r.type===Zd.jpeg?"jpeg":"png";n.append("images",r,`image-${s+1}.${goe[o]}`)}),{method:"POST",body:n}}const $oe="Add screenshot",_M="PNG or JPEG, up to three. You can also paste one, or drop it on this dialog.",Ioe="A screenshot can show emails, costs and paths. Crop out what should not be seen.",EM="Three images at most. Remove one to add another.",Ooe="An image could not be attached, so nothing was sent. Check the images and send again; your text is still here.";function Loe(e,t,n){const r=n?`, resized to ${n.width} × ${n.height} to fit`:"";return`Replace image ${e+1}: ${t}${r}`}function Poe(e,t){const n=`${e} of ${Va}`;return t>0?`${n} · ${t} resized to fit`:n}function Doe(e){return`Three images at most, so ${e===1?"one was":`${e} were`} left out.`}function Foe(e){return`“${e.length>40?`${e.slice(0,30)}…${e.slice(-9)}`:e}”`}function Boe(e,t){const n=Foe(t);return e==="type"?`${n} is not a PNG or a JPEG, so it was not added. GIF, WebP and HEIC are not converted; save it as a PNG or a JPEG first.`:e==="no_room"?`There is no room left for ${n}: images go at up to 12 MB in all. Remove one to add it.`:e==="unreadable"?`${n} could not be read as an image.`:`${n} could not be made small enough to send: images go at up to 5 MB each.`}const HP="image/png,image/jpeg";function VP({className:e="fb-glyph"}){return a.jsxs("svg",{className:e,width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,focusable:"false",children:[a.jsx("rect",{x:"1.8",y:"2.4",width:"10.4",height:"9.2",rx:"1.6"}),a.jsx("circle",{cx:"5",cy:"5.6",r:"1"}),a.jsx("path",{d:"M2.4 10.4 5.5 7.6l2.1 1.8 1.5-1.3 2.5 2.2"})]})}function qoe({images:e,buttonRef:t}){const n=y.useRef(null),r=e.shots.length>=Va;return a.jsxs(a.Fragment,{children:[a.jsxs("button",{ref:t,type:"button",className:"fb-tool",title:_M,"aria-describedby":"fb-attach-hint",onClick:()=>{var s;return r?e.sayFull():(s=n.current)==null?void 0:s.click()},children:[a.jsx(VP,{}),$oe]}),a.jsx("span",{id:"fb-attach-hint",hidden:!0,children:_M}),a.jsx("input",{ref:n,type:"file",accept:HP,multiple:!0,hidden:!0,onChange:s=>{e.add(Array.from(s.target.files??[])),s.target.value=""}})]})}function Uoe({images:e,addRef:t}){const n=y.useRef(new Map),r=y.useRef(null),s=y.useRef(null),o=y.useRef(null),[l,c]=y.useState(null),{shots:d}=e,h=Poe(d.length,d.filter(g=>g.resized).length);y.useLayoutEffect(()=>{var g;l!==null&&((g=l==="add"?t.current:n.current.get(l))==null||g.focus(),c(null))},[l,t]),y.useEffect(()=>{var g;e.problem&&((g=r.current)==null||g.scrollIntoView({block:"nearest"}))},[e.problem,e.problemId]);function f(g){c(Roe(d.map(v=>v.id),g)??"add"),e.remove(g)}function p(g){var v;o.current=g,(v=s.current)==null||v.click()}return a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"vis-hidden",role:"status",children:e.announcement}),a.jsx("input",{ref:s,type:"file",accept:HP,hidden:!0,onChange:g=>{const v=o.current;v!==null&&e.replace(v,Array.from(g.target.files??[])),o.current=null,g.target.value=""}}),d.length>0&&a.jsxs("div",{className:"fb-shots",children:[a.jsxs("div",{className:"fb-shots-row",children:[a.jsx("ul",{className:"fb-shots-list",children:d.map((g,v)=>a.jsxs("li",{className:"fb-shot","data-fitting":g.blob?void 0:!0,children:[a.jsxs("button",{type:"button",className:"fb-shot-pick","aria-label":Loe(v,g.name,g.resized),onClick:()=>p(g.id),children:[a.jsx("img",{className:"fb-shot-img",src:g.url,alt:""}),g.blob?a.jsx("span",{className:"fb-shot-cue","aria-hidden":"true",children:"Replace"}):a.jsx("span",{className:"fb-shot-busy","aria-hidden":"true",children:"Resizing…"})]}),a.jsx("button",{ref:j=>{j?n.current.set(g.id,j):n.current.delete(g.id)},type:"button",className:"glyph-btn fb-shot-remove","aria-label":`Remove image ${v+1}`,title:`Remove image ${v+1}`,onClick:()=>f(g.id),children:a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round","aria-hidden":!0,focusable:"false",children:a.jsx("path",{d:"M2.5 2.5 7.5 7.5M7.5 2.5 2.5 7.5"})})})]},g.id))}),a.jsx("span",{className:"fb-shots-count",children:h})]}),a.jsx("p",{className:"fb-hint",children:Ioe})]}),e.problem&&a.jsx("p",{ref:r,className:"fb-error",role:"alert",children:e.problem},e.problemId)]})}function zoe(e,t){return e.map((n,r)=>({id:t+r,name:n.name,url:URL.createObjectURL(n.blob),blob:n.blob,resized:n.resized}))}function Woe(e,t,n){return n?e.map(r=>r.id===t.id?t:r):[...e,t]}function Hoe(e,t,n){return n?e.map(r=>r.id===t?n:r):e.filter(r=>r.id!==t)}function Voe(e){const[t,n]=y.useState(()=>zoe((e==null?void 0:e.ready)??[],1)),[r,s]=y.useState({problem:"",id:0}),o=y.useRef(0),l=y.useCallback(M=>{M&&o.current++,s(F=>M?{problem:M,id:F.id+1}:F.problem?{problem:"",id:F.id}:F)},[]),[c,d]=y.useState(""),h=y.useRef(t),f=y.useRef(null),p=y.useRef(t.length),g=y.useRef(!0),v=y.useRef(new Map),j=y.useRef([]),k=y.useRef(0),x=y.useCallback(M=>{h.current=M(h.current),n(h.current)},[]);y.useEffect(()=>(g.current=!0,()=>{g.current=!1;for(const M of h.current)URL.revokeObjectURL(M.url)}),[]);const N=y.useCallback(async(M,F)=>{const T=h.current.reduce((J,W)=>{var Z;return J+(W.id===(F==null?void 0:F.id)?0:((Z=W.blob)==null?void 0:Z.size)??0)},0),P=(F==null?void 0:F.id)??++p.current,O=URL.createObjectURL(M),G={id:P,name:M.name||"image",url:O,blob:null,resized:null},K=k.current;v.current.set(P,M);let U=!1;const H=()=>{U||(U=!0,x(J=>Woe(J,G,F!==void 0)))},D=await _oe(M,Noe(T),async J=>(H(),Coe(J))).catch(()=>({ok:!1,problem:"unreadable"})),V=h.current.some(J=>J.id===P);return!g.current||k.current!==K||!V&&(U||F)?(URL.revokeObjectURL(O),F&&URL.revokeObjectURL(F.url),g.current&&v.current.delete(P),""):(v.current.delete(P),D.ok?(H(),F&&URL.revokeObjectURL(F.url),x(J=>J.map(W=>W.id===P?{...W,blob:D.blob,resized:D.resized}:W)),""):(URL.revokeObjectURL(O),U&&x(J=>Hoe(J,P,F)),Boe(D.problem,M.name||"image")))},[x]),b=y.useCallback(async M=>{l("");const F=k.current,T=[];let P=0,O=0;for(const K of M){if(!g.current||k.current!==F)return;const U=j.current.indexOf(K);if(U!==-1&&j.current.splice(U,1),h.current.length>=Va){P++;continue}const H=h.current.length,D=await N(K);D&&T.push(D),h.current.length>H&&O++}if(!g.current||k.current!==F)return;P>0&&T.push(O===0&&T.length===0?EM:Doe(P)),l(T.join(" "));const G=h.current.length;O>0&&d(`${O===1?"Image":`${O} images`} added, ${G} of ${Va}.`)},[N,l]),S=y.useCallback(async(M,F)=>{l("");const T=h.current.find(G=>G.id===M);if(!T)return b([F]);const P=await N(F,T);if(!g.current)return;l(P);const O=h.current.findIndex(G=>G.id===M);!P&&O!==-1&&d(`Image ${O+1} replaced, ${h.current.length} of ${Va}.`)},[b,N,l]),E=y.useCallback(M=>{const F=k.current;f.current=(f.current??Promise.resolve()).then(()=>k.current===F?M():void 0).catch(()=>{})},[]),R=y.useCallback(M=>{M.length!==0&&(j.current.push(...M),E(()=>b(M)))},[b,E]);y.useEffect(()=>{e&&e.waiting.length>0&&R(e.waiting)},[]);const I=y.useCallback((M,F)=>{const T=F[0];T&&E(()=>S(M,T))},[E,S]),A=y.useCallback(M=>{const F=h.current.find(T=>T.id===M);F&&(URL.revokeObjectURL(F.url),v.current.delete(M),x(T=>T.filter(P=>P.id!==M)),l(""),d(`Image removed, ${h.current.length} of ${Va}.`))},[x,l]),q=y.useCallback(()=>l(EM),[l]),$=y.useCallback(async()=>{const M=o.current;return await f.current,o.current!==M?null:h.current.flatMap(F=>F.blob?[F.blob]:[])},[]),B=y.useCallback(()=>({ready:h.current.flatMap(M=>M.blob&&!v.current.has(M.id)?[{name:M.name,blob:M.blob,resized:M.resized}]:[]),waiting:[...v.current.values(),...j.current]}),[]),L=y.useCallback(()=>{k.current++;for(const M of h.current)URL.revokeObjectURL(M.url);v.current.clear(),j.current=[],x(()=>[]),l("")},[x,l]);return{shots:t,problem:r.problem,problemId:r.id,announcement:c,add:R,replace:I,remove:A,sayFull:q,ready:$,kept:B,clear:L}}function Goe(){const[e,t]=y.useState(null);return y.useEffect(()=>{let n=!0;return fetch("/api/feedback").then(r=>r.ok?r.json():null).then(r=>{n&&t(Uae(r))}).catch(()=>{}),()=>{n=!1}},[]),e}function Koe(e){const[t,n]=y.useState({state:"idle"}),r=y.useRef(!1),s=y.useRef(null);y.useEffect(()=>()=>{var c;return(c=s.current)==null?void 0:c.abort()},[]);async function o(c){if(!xr(r.current))return;r.current=!0;const{signal:d}=s.current=new AbortController;n({state:"sending"});try{const h=await e.ready();if(d.aborted)return;if(!h){n({state:"failed",message:Ooe});return}const f=await fetch("/api/feedback",{...Moe(qae(c),h),signal:d}),p=await f.json().catch(()=>null);n(f.ok&&(p!=null&&p.ok)?{state:"sent"}:{state:"failed",message:NM(f.status,p==null?void 0:p.reason,p==null?void 0:p.errors)})}catch{d.aborted||n({state:"failed",message:NM(0,null)})}finally{r.current=!1}}const l=()=>n(c=>c.state==="failed"?{state:"idle"}:c);return{outcome:t,sending:t.state==="sending",send:o,clearFailure:l}}function Yoe(e,t){const[n,r]=y.useState(!1),s=y.useRef(t);return s.current=t,y.useEffect(()=>{if(!e)return;const o=window.setTimeout(()=>r(!0),jM),l=window.setTimeout(()=>s.current(),jM+roe);return()=>{window.clearTimeout(o),window.clearTimeout(l)}},[e]),n}const _x="agent-dag.feedbackDrafts",CM=4;function Xoe({initialKind:e,initialBody:t}){return{kind:e??"bug",body:t??""}}function Zoe(e){return JSON.stringify([e.kind,e.body])}function Joe(e){return e.ready.length+e.waiting.length}function GP(e,t){return e.body.trim()!==t.body.trim()||e.contact.trim()!==""||e.images>0}function Qoe(e){return e===1?"The screenshot was not kept through the page reload. Add it again to send it.":`The ${e} screenshots were not kept through the page reload. Add them again to send them.`}const eie="Discard",tie="Confirm discard",nie="Clear the message, the screenshots and the contact",TM="Press again to clear this draft. It cannot be brought back.",rie={ready:[],waiting:[]};function sie(e){if(!Array.isArray(e)||e.length!==2||typeof e[0]!="string")return null;const t=e[1];if(!t||typeof t!="object")return null;const{kind:n,body:r,contact:s,images:o}=t;return!Xd.some(l=>l.value===n)||typeof r!="string"||r.length>PP||typeof s!="string"||s.length>DP||typeof o!="number"||!Number.isInteger(o)||o<0||o>Va?null:[e[0],{kind:n,body:r,contact:s,images:o}]}function aie(e){let t=null;function n(){var o;if(t)return t;t=new Map;try{const l=(o=e())==null?void 0:o.getItem(_x),c=l?JSON.parse(l):[];if(Array.isArray(c))for(const d of c.slice(-CM)){const h=sie(d);h&&t.set(h[0],{...h[1],images:null,imageCount:h[1].images})}}catch{}return t}function r(){try{const o=e();if(!o)return;const l=[...n()].map(([c,d])=>[c,{kind:d.kind,body:d.body,contact:d.contact,images:d.imageCount}]);l.length===0?o.removeItem(_x):o.setItem(_x,JSON.stringify(l))}catch{}}function s(o){n().delete(o)&&r()}return{read(o){const l=n().get(o);return l?{kind:l.kind,body:l.body,contact:l.contact,images:l.images??rie,imagesLost:l.images?0:l.imageCount}:null},keep(o,l,c){const d=Joe(l.images);if(!GP({body:l.body,contact:l.contact,images:d},c)){s(o);return}const h=n();h.delete(o),h.set(o,{kind:l.kind,body:l.body,contact:l.contact,images:l.images,imageCount:d});for(const f of h.keys()){if(h.size<=CM)break;h.delete(f)}r()},forget:s}}function oie(){try{return typeof window>"u"?null:window.sessionStorage}catch{return null}}const Wb=aie(oie),iie=4e3;function lie(e,t,n,r,s){const o=y.useRef(null);o.current={key:e,seed:t,words:n,images:r,sent:s};const l=y.useCallback(()=>{const c=o.current;!c||c.sent||Wb.keep(c.key,{...c.words,images:c.images.kept()},c.seed)},[]);y.useEffect(l,[l,n.kind,n.body,n.contact,r.shots]),y.useEffect(()=>l,[l]),y.useEffect(()=>{s&&Wb.forget(e)},[s,e])}const AM="draft";function cie(e){const[t,n]=y.useState(!1),r=y.useRef(0);y.useEffect(()=>{if(!t)return;const o=window.setTimeout(()=>n(!1),iie);return()=>window.clearTimeout(o)},[t]);function s(){const o=Date.now(),l=so({armedFor:t?AM:null,target:AM,armedAt:r.current,now:o,gapMs:ro});if(l==="arm"){n(!0),r.current=o;return}l!=="ignore"&&(n(!1),e())}return{armed:t,press:s}}function KP({onClose:e,initialKind:t,initialBody:n}){const r=y.useRef(null),s=y.useRef(null),o=y.useRef(null),l=y.useRef(null),c=y.useRef(null),d=y.useRef(null),h=y.useRef(null),f=y.useRef(null),p=y.useRef(0),g=ot(e,{focusRef:r}),v=mt(e),j=Xoe({initialKind:t,initialBody:n}),k=Zoe(j),[x]=y.useState(()=>Wb.read(k)),[N,b]=y.useState((x==null?void 0:x.kind)??j.kind),[S,E]=y.useState((x==null?void 0:x.body)??j.body),[R,I]=y.useState((x==null?void 0:x.contact)??""),[A,q]=y.useState((x==null?void 0:x.imagesLost)??0),[$,B]=y.useState(!1),[L,M]=y.useState(!1),[F,T]=y.useState(!1),P=Voe(x==null?void 0:x.images),O=Hae(Goe()),{outcome:G,sending:K,send:U,clearFailure:H}=Koe(P),D=G.state==="sent",V=Yoe(D,e);lie(k,j,{kind:N,body:S,contact:R},P,D);const J=GP({body:S,contact:R,images:P.shots.length},j),W=cie(()=>{var we;b(j.kind),E(j.body),I(""),q(0),M(!1),P.clear(),H(),(we=r.current)==null||we.focus()}),Z=LP(N),Y=L&&!bM(S),X=A>0&&P.shots.length===0,ee=[Y&&"fb-body-error",X&&"fb-images-lost"].filter(Boolean).join(" ")||void 0,[ae,ce]=eoe(x0());y.useEffect(()=>{var Le,Be;const we=l.current;if(!we)return;const Me=we.contains(document.activeElement)||An(((Le=document.activeElement)==null?void 0:Le.tagName)??null);we.inert=D,D&&Me&&((Be=s.current)==null||Be.focus())},[D]),y.useEffect(()=>{var Pe,Qe;const we=c.current;if(!we)return;const Me=h.current;if(K){const qe=document.activeElement,Ze=qe!=null&&(we.contains(qe)||qe===Me);f.current=Ze?qe:null,we.inert=!0,Me&&(Me.inert=!0),f.current&&((Pe=d.current)==null||Pe.focus());return}we.inert=!1,Me&&(Me.inert=!1);const Le=f.current;f.current=null;const Be=document.activeElement===d.current||An(((Qe=document.activeElement)==null?void 0:Qe.tagName)??null);!D&&Le&&Be&&Le.focus()},[K,D]);function ge(we){var Me;if(we.preventDefault(),!bM(S)){M(!0),(Me=r.current)==null||Me.focus();return}U({kind:N,body:S,contact:R})}const ye=!D&&!K,se=we=>Toe(Array.from(we.dataTransfer.types));function pe(we){!se(we)||!ye||(we.preventDefault(),p.current++,T(!0))}function fe(we){se(we)&&(we.preventDefault(),we.dataTransfer.dropEffect=ye?"copy":"none")}function de(we){se(we)&&(p.current=Math.max(0,p.current-1),p.current===0&&T(!1))}function me(we){se(we)&&(we.preventDefault(),p.current=0,T(!1),ye&&P.add(Array.from(we.dataTransfer.files)))}function ne(we){we.target!==we.currentTarget||!se(we)||(we.preventDefault(),we.dataTransfer.dropEffect="none")}function oe(we){se(we)&&we.preventDefault()}function Ne(we){if(!ye)return;const Me=Array.from(we.clipboardData.files),Le=we.target,Be=Le instanceof HTMLTextAreaElement||Le instanceof HTMLInputElement,Pe=Array.from(we.clipboardData.types).includes("text/plain");Aoe({files:Me.length,hasText:Pe,intoTextField:Be})&&(we.preventDefault(),P.add(Me))}return a.jsx("div",{className:"modal-backdrop",...v,role:"presentation",onDragOver:ne,onDrop:oe,"data-leaving":V||void 0,children:a.jsxs("div",{ref:g,className:"modal feedback-dialog",onClick:we=>we.stopPropagation(),onDragEnter:pe,onDragOver:fe,onDragLeave:de,onDrop:me,onPaste:Ne,role:"dialog","aria-modal":"true","aria-labelledby":"feedback-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{id:"feedback-title",className:"modal-tool-name",children:"Send feedback"})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{ref:s,type:"button",className:"glyph-btn",onClick:e,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsx("p",{className:"vis-hidden",role:"status",children:W.armed?TM:noe(G.state)}),a.jsxs("div",{className:"fb-stage",children:[a.jsxs("form",{ref:l,className:"fb-form",onSubmit:ge,onKeyDown:we=>{Qae(we.nativeEvent)&&(we.preventDefault(),we.currentTarget.requestSubmit())},noValidate:!0,children:[a.jsxs("section",{ref:c,className:"modal-body fb-body",children:[a.jsx(soe,{kind:N,onChange:b}),a.jsxs("div",{className:"fb-compose",children:[a.jsx("label",{className:"fb-label",htmlFor:"fb-body",children:Z.question}),a.jsx("textarea",{ref:r,id:"fb-body",className:"ap-manage-input fb-message",value:S,maxLength:PP,rows:5,placeholder:Z.placeholder,onChange:we=>E(we.target.value),"aria-invalid":Y||void 0,"aria-describedby":ee,required:!0}),Y&&a.jsx("p",{id:"fb-body-error",className:"fb-error",children:Pae}),a.jsx(Uoe,{images:P,addRef:o}),X&&a.jsx("p",{id:"fb-images-lost",className:"fb-hint",children:Qoe(A)}),a.jsxs("div",{className:"fb-tools",children:[a.jsx(qoe,{images:P,buttonRef:o}),a.jsx(aoe,{open:$,onToggle:()=>B(we=>!we)})]}),a.jsx(ooe,{open:$,contact:R,onContact:I})]}),a.jsx("p",{className:"fb-facts",children:O?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"fb-facts-value",children:O})," — ",Vae]}):Gae}),G.state==="failed"&&a.jsx("p",{className:"fb-error",role:"alert",children:G.message})]}),a.jsxs("div",{className:"fb-foot",children:[J&&a.jsx("button",{ref:h,type:"button",className:`btn danger fb-discard${W.armed?" armed":""}`,onKeyDown:we=>{we.repeat&&we.preventDefault()},onClick:W.press,title:W.armed?TM:nie,children:W.armed?tie:eie}),a.jsxs("span",{className:"fb-shortcut","aria-hidden":"true",children:[a.jsx("kbd",{"data-symbol":toe(ae)||void 0,children:ae}),a.jsx("kbd",{children:ce})," to send"]}),a.jsx("button",{type:"button",className:"btn",onClick:e,children:"Cancel"}),a.jsx("button",{ref:d,type:"submit",className:"btn primary fb-send","aria-keyshortcuts":"Meta+Enter Control+Enter",...Wr(K),children:a.jsxs("span",{className:"fb-send-label",children:[a.jsx("span",{className:"fb-send-idle",children:"Send feedback"}),a.jsx("span",{className:"fb-send-busy",children:"Sending…"})]})})]})]}),D&&a.jsxs("div",{className:"fb-done",children:[a.jsx(Pd,{}),a.jsx("p",{className:"fb-done-line",children:BP})]})]}),a.jsx("div",{className:"fb-drop","aria-hidden":"true","data-active":F||void 0,children:a.jsxs("div",{className:"fb-drop-frame",children:[a.jsx(VP,{className:"fb-drop-glyph"}),a.jsx("p",{className:"fb-drop-title",children:"Drop to attach"}),a.jsx("p",{className:"fb-drop-note",children:"PNG or JPEG, up to three"})]})})]})})}const uie="Press Esc first if a key does nothing.",die=[{title:"Canvas",rows:[{cap:"Space",action:"pause or resume the stream",binds:[" "]},{cap:"J",action:"next agent",binds:["j","J"]},{cap:"K",action:"previous agent",binds:["k","K"]},{cap:"W",action:"the session waiting on you — oldest first, again for the next",binds:["w","W"]},{cap:"F",action:"fit every agent on screen",binds:["f","F"]},{cap:"Z",action:"zoom to the selected agent and its session",binds:["z","Z"]},{cap:"Delete",action:"take the selected card off the board — the session list (L) brings it back",binds:["Delete"]},{cap:"R",action:"re-arrange the canvas and drop the pins",binds:["r","R"]},{cap:"C",action:"clear the canvas and the event log — asks first",binds:["c","C"]}]},{title:"Panels and dialogs",rows:[{cap:"U",action:"usage panel",binds:["u","U"]},{cap:"L",action:"session list",binds:["l","L"]},{cap:"D",action:"detail panel",binds:["d","D"]},{cap:"H",action:"usage history",binds:["h","H"]},{cap:"A",action:"Claude accounts, where Claude Code is installed",binds:["a","A"]},{cap:"S",action:"this machine — cores, memory, temperature",binds:["s","S"]},{cap:"B",action:"Browser Watch",binds:["b","B"]},{cap:"V",action:"the sound popover — sounds on or off, and their volumes",binds:["v","V"]},{cap:"?",action:"this sheet",binds:["?"]}]},{title:"Settings",rows:[{cap:"Ctrl + ,",macCap:"⌘ ,",action:"all settings",binds:[","]},{cap:"M",action:"sound on or off",binds:["m","M"]},{cap:"T",action:"light or dark theme",binds:["t","T"]}]},{title:"Focus and selection",rows:[{cap:"Tab",action:"reach the agent cards",binds:[]},{cap:"Enter",action:"select the focused card",binds:["Enter"]},{cap:"Shift + Enter",action:"add the focused card to the selection",binds:["Enter"]},{cap:"Esc",action:"close what is open, deselect, release focus",binds:["Escape"]}]},{title:"Mouse",rows:[{cap:"drag",action:"move a node, and pin it where you dropped it",binds:[]},{cap:"shift-click",action:"add an agent to the selection",binds:[]},{cap:"click",action:"a card: go to it and its session",binds:[]},{cap:"double-click",action:"a card: its prompt, every tool call, tokens and timing",binds:[]},{cap:"hover",action:"zoomed out, a card's name, state and numbers",binds:[]},{cap:"click",action:"the topbar speaker: sounds on or off and their volumes, and the way to all sound settings",binds:[]}]}];function hie({onClose:e,onTour:t}){const n=ot(e),r=mt(e),s=b0(x0());return a.jsx("div",{className:"modal-backdrop",...r,role:"presentation",children:a.jsxs("div",{ref:n,className:"modal key-help",onClick:o=>o.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"key-help-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{id:"key-help-title",className:"modal-tool-name",children:"Keyboard shortcuts"})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:e,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[t&&a.jsxs("div",{className:"guide-door",children:[a.jsx("span",{children:"Eight pictures of what the deck shows."}),a.jsx("button",{type:"button",className:"btn",onClick:t,children:"Take the tour"})]}),a.jsx("div",{className:"shortcuts",children:die.map(o=>a.jsxs(y.Fragment,{children:[a.jsx("h3",{className:"kh-group",children:o.title}),o.rows.map(l=>a.jsxs("div",{className:"sc",children:[a.jsx("kbd",{children:s&&l.macCap?l.macCap:l.cap}),a.jsx("span",{children:l.action})]},`${o.title}:${l.cap}:${l.action}`))]},o.title))}),a.jsx("p",{className:"kh-foot",children:uie})]})]})})}function YP(e,t){return y.lazy(()=>e().catch(n=>(console.warn(`ccdeck could not load ${t}`,n),{default:({onClose:r})=>a.jsx(fie,{name:t,onClose:r})})))}function fie({name:e,onClose:t}){const n=y.useRef(null),r=ot(t,{focusRef:n}),s=mt(t);return a.jsx("div",{className:"modal-backdrop",...s,role:"presentation",children:a.jsxs("div",{ref:r,className:"modal dialog-missing",onClick:o=>o.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"dialog-missing-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{id:"dialog-missing-title",className:"modal-tool-name",children:e})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[a.jsxs("p",{className:"dm-note",children:[e," did not load. The deck has most likely been updated since this tab opened, and a reload picks up the new version."]}),a.jsxs("div",{className:"dm-actions",children:[a.jsx("button",{type:"button",className:"btn",onClick:t,children:"Close"}),a.jsx("button",{type:"button",ref:n,className:"btn primary",onClick:()=>window.location.reload(),children:"Reload"})]})]})]})})}function pie(e,t){return`${e}#${t}`}function mie(e,{lan:t,now:n,closed:r}){if(t===void 0)return[];const s=[];for(const o of e??[]){const l=o.reauth;if(!l||l.dismissed||o.origin!=="ccdeck_signin")continue;const c=pie(l.key,l.since);if(r.has(c)||tY(l.key,o.email,t,n))continue;const d=o.email??"";s.push({id:c,key:l.key,since:l.since,num:o.num,email:d,name:d||o.alias||`Account ${o.num}`,alias:d&&o.alias?o.alias:null})}return s}function gie(e,t){const n=String((t==null?void 0:t.email)??"").trim().toLowerCase();return n?e.filter(r=>r.email.toLowerCase()===n&&((t==null?void 0:t.num)==null||String(r.num)===String(t.num))).map(r=>r.id):[]}function XP({rows:e,ours:t,dialogs:n}){return e===0?!1:t||n===0}function yie(e){return e===1?"Account needs your attention":"Accounts need your attention"}function wie(e){return`${e===1?"One Claude account needs":`${e} Claude accounts need`} you to sign in again.`}const vie="Login expired",xie="Until then the deck cannot read its usage or switch to it. Signing in again brings it back — it keeps its slot, its alias and its history.",bie="The account stays marked in the Accounts panel. This will not ask again until it has worked and stopped again.";function kie(e,t){const n=(e??[]).filter(s=>s&&typeof s.fp=="string"&&!t.has(s.fp));if(!n.length)return{request:null,waiting:0};const r=[...n].sort((s,o)=>(s.at??0)-(o.at??0));return{request:r[0],waiting:r.length-1}}function Nie({request:e,waiting:t,busy:n,now:r,onAccept:s,onDecline:o,onLater:l}){const c=y.useRef(null),d=ot(l,{focusRef:c}),h=mt(l),f=oa(n,"accept"),p=oa(n,"dismiss");return a.jsx("div",{className:"modal-backdrop",...h,role:"presentation",children:a.jsxs("div",{ref:d,className:"modal lan-ask",onClick:g=>g.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-ask-title","aria-describedby":"lan-ask-who",children:[a.jsxs("header",{className:"modal-head",children:[a.jsxs("div",{className:"modal-title",children:[a.jsx("i",{className:"ap-pulse","aria-hidden":!0}),a.jsx("span",{id:"lan-ask-title",className:"modal-tool-name",children:"A deck wants to pair"})]}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:l,"aria-label":"Answer later (Esc)",title:"Answer later (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[a.jsxs("p",{id:"lan-ask-who",className:"lan-ask-who",children:[a.jsx("strong",{className:"lan-ask-name",children:e.name})," at ",a.jsx("code",{className:"ap-lan-code",children:e.addr})," · asked ",zk(e.at,r)]}),a.jsx("p",{className:"modal-note",children:"Paired decks repair each other's expired logins. Accept only if you know this machine — what it shares is an account, not a screen."}),a.jsxs("p",{className:"lan-ask-fp",children:["Its fingerprint is ",a.jsx("code",{className:"ap-lan-code",children:e.fp})," — that machine shows its own under This deck on the network; the two should match."]}),t>0&&a.jsx("p",{className:"lan-ask-more",children:t===1?"One more deck is waiting behind this one.":`${t} more decks are waiting behind this one.`}),a.jsxs("div",{className:"lan-ask-acts",children:[a.jsx("button",{type:"button",ref:c,className:"btn",disabled:p.disabled,"aria-busy":p.busy,onClick:o,title:"Nothing is shared. If that deck asks again, this comes back.",children:n==="dismiss"?"declining…":"Decline"}),a.jsx("button",{type:"button",className:"btn primary",disabled:f.disabled,"aria-busy":f.busy,onClick:s,title:"Talk to this deck from now on, and repair its expired logins with this deck's own.",children:n==="accept"?"accepting…":"Accept"})]})]})]})})}function jie(e){const t=y.useRef(!1),n=Sie(e),r=XP({rows:n?1:0,ours:t.current,dialogs:qr.dialogDepth()});return t.current=r,r?n:null}function Sie({lanPending:e,lanDeferred:t,lanBusy:n,answerLanPair:r,deferLanPair:s}){const{request:o,waiting:l}=kie(e,t.current);return o?a.jsx(Nie,{request:o,waiting:l,busy:n,now:Date.now(),onAccept:()=>void r("accept",o.fp),onDecline:()=>void r("dismiss",o.fp),onLater:()=>s(o.fp)},o.fp):null}function _ie({rows:e,onSignIn:t,onLater:n,firstRef:r}){const s=e.length===1?e[0]:null;return a.jsxs("section",{className:"modal-body",children:[s?a.jsxs(a.Fragment,{children:[a.jsxs("p",{id:"reauth-lead",className:"reauth-lead",children:["The Claude login for ",a.jsx("strong",{className:"reauth-name",children:s.name}),s.alias?a.jsxs("span",{className:"reauth-alias",children:[" (",s.alias,")"]}):null," ","has expired and needs a new sign","‑","in."]}),a.jsx("p",{className:"reauth-note",children:xie})]}):a.jsxs(a.Fragment,{children:[a.jsx("p",{id:"reauth-lead",className:"reauth-lead",children:wie(e.length)}),a.jsx("ul",{className:"reauth-list",children:e.map((o,l)=>a.jsxs("li",{className:"reauth-row",children:[a.jsxs("span",{className:"reauth-who",title:o.alias?`${o.alias} — ${o.name}`:o.name,children:[o.name,o.alias?a.jsxs("span",{className:"reauth-alias",children:[" ",o.alias]}):null]}),a.jsx("span",{className:"reauth-what",children:vie}),a.jsx("button",{type:"button",className:"btn",ref:l===0?r:void 0,"aria-label":`Sign in again as ${o.name}`,onClick:()=>t(o),children:"Sign in again"})]},o.id))}),a.jsx("p",{className:"reauth-note",children:"Each keeps its slot, its alias and its history."})]}),a.jsxs("div",{className:"reauth-acts",children:[a.jsx("button",{type:"button",className:"btn",title:bie,onClick:n,children:"Not now"}),s&&a.jsx("button",{type:"button",className:"btn primary",ref:r,onClick:()=>t(s),children:"Sign in again"})]})]})}function Eie({rows:e,onSignIn:t,onLater:n}){const r=y.useRef(null),s=ot(n,{focusRef:r}),o=mt(n);return a.jsx("div",{className:"modal-backdrop",...o,role:"presentation",children:a.jsxs("div",{ref:s,className:"modal reauth-ask",onClick:l=>l.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"reauth-title","aria-describedby":"reauth-lead",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{id:"reauth-title",className:"modal-tool-name",children:yie(e.length)})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:n,"aria-label":"Not now (Esc)",title:"Not now (Esc)",children:"×"})})]}),a.jsx(_ie,{rows:e,onSignIn:t,onLater:n,firstRef:r})]})})}function Cie({rows:e,signingIn:t,signIn:n,signedIn:r,refresh:s,closeSignIn:o,later:l,pairing:c=!1}){const d=y.useRef(!1),h=qr.dialogDepth()+(c?1:0),f=t!=null||XP({rows:e.length,ours:d.current,dialogs:h});return d.current=f,t?a.jsx(NO,{email:t.email||null,onClose:o,onChanged:s,onSignedIn:r}):f?a.jsx(Eie,{rows:e,onSignIn:n,onLater:l},e.length===1?"one":"many"):null}const Tie={"//":["What a user would NOTICE. One key per version that has something to say,","and no key at all for a version that has nothing — which is most of them.","","The rule this file exists to serve: before every release, ask 'what would a","user notice?' and write the answer here. 'Nothing user-visible' is a valid","and expected answer, and it is spelled by adding no key. A release with no","key shows no modal, and that silence is what keeps the modal worth reading","on the day it is not silent.","","What belongs here: something that changed on the user's machine or under","their hands — a hook written to or removed from settings.json, a default","that flipped, a control that moved or went away, a stored preference that","changed meaning. What does not: bounds, races, assertions that could not","fire, anything that is invisible when it is correct.","","Write it for the person running the deck, not for the person reading the","diff. `title` is the sentence they scan; `body` is what they need in order","to act on it, or to stop worrying about it.","","Keys are versions exactly as package.json spells them. A key that is not a","version, or an entry missing either field, fails the suite rather than","being quietly dropped — see src/web/__tests__/release-notes-file.test.ts.","Ordering here is for humans; the deck sorts by version itself.","","A title may open with an emoji, and if it does, put exactly ONE space after","it. Not two: the dialog gives a leading emoji its own optical gap, because","a colour glyph is drawn edge to edge inside its advance and one word space","after one reads as none. A second space here would be a lie in the data","about a defect in the type, and the suite refuses both it and no space at","all.","","A release that genuinely has nothing to say is spelled TWICE: no key here,",'and its version written into "//nothing-to-say" below. One spelling on its',"own is ambiguous — a missing key reads the same whether it was a decision","or a forgotten step, and five releases in a row were once forgotten. The list","is what tells the two apart, and release-notes-current-version.test.ts fails","the release whose version is in neither place. Any key opening with // is a","note to the author and never a release."],"//nothing-to-say":["3.23.1","3.23.2","3.23.3","3.23.4","3.26.0","3.26.1","3.26.3","3.26.4","3.26.5","3.27.6","3.27.7","3.28.0","3.28.1","3.29.3","3.29.4","3.29.6","3.29.7","3.29.9","3.33.1","3.35.0","3.35.1","3.36.0","3.36.1","3.36.4","3.36.5","3.36.6","3.36.7","3.36.8","3.36.9","3.37.0","3.38.0","3.38.1","3.38.2"],"3.38.5":[{title:"🔧 Settings are in one place now",body:"The theme, the sounds, notifications, Claude FM and the minimap character are all in Settings, behind the gear at the right of the topbar, or Cmd+, (Ctrl+, on Windows and Linux). The speaker beside it keeps the quick things one click away: sounds on or off, and how loud each tone is. Nothing you had set has changed, it has only moved, and T still switches the theme. The auto-switch threshold also takes a custom value now: pick Custom… and type a whole percent from 50 to 99."},{title:"Windows: no more temperature stuck at 28 °C",body:"On many Windows laptops the only temperature Windows offers is a thermal zone wired to nothing, which reads a fixed 28 °C however hot the CPU is, and the machine panel showed it as a reading. A thermal zone is now drawn only once its value has changed. Until then the panel shows LibreHardwareMonitor's readings if its web server is running, and otherwise no Thermal section at all: the deck never invents a reading."}],"3.38.4":[{title:"🔔 A notification when Auto-switch changes your account",body:'When Auto-switch moves Claude Code to another account, ccdeck now tells you once, with where it went and why, for example "Switched to work · personal@example.com reached 90%". You can turn it off in the sound settings, where two more wait, off until you turn them on: one when a quota window of the Claude or Codex account you are on reaches 90% and again at 100%, and one when a window that had reached 90% is available again. Each is said once per window and a restart does not repeat it. With either quota notification on, the deck reads quota about every two minutes even while no page is open.'}],"3.38.3":[{title:"🧾 Subagent costs count their whole reply",body:"A subagent's request was counted from the first moment of its reply, before most of it had been written, so much of its output was left out of the deck's token and cost counts, and a subagent turn in fast mode was priced at the standard rate. Each request is now counted from its finished reply. Days with subagents will read higher than before: that is the part that was missing, not a new charge. Projects counts its history again once after the update, so past days come out right too. Codex sessions on GPT-6 Sol, GPT-6.1 Sol and GPT-6 Luna now show a cost instead of not priced."}],"3.37.1":[{title:"🔁 Expired logins repair from your other machines",body:"When a login stops working on this machine and a machine you paired with still has it working and ticked, Local network now copies it back on the next round, whether or not the account is ticked here. Before, it stayed marked expired until the account was ticked here as well, or deleted so that it arrived again. A machine that paired on its own, through Say yes to every deck that asks, still repairs only the accounts ticked here."}],"3.36.3":[{title:"🔑 An expired login asks to be signed in again",body:"When an account you added with + → Sign in stops working, the deck now tells you in one dialog, with every affected account together and Sign in again beside each. That opens the usual sign-in with the address already filled in, and the account keeps its slot, its alias and its history. Not now leaves it marked in the Accounts panel and does not ask again until it has worked and stopped again. A paired deck holding a working copy gets to repair it first, and accounts that came from a share or Local network are never asked about."}],"3.34.1":[{title:"🗂️ The tray menu stays open while you read it",body:"On Linux the menu behind the tray icon could close by itself while agents were working, often before the row you pressed took the click, so it had to be opened and pressed again. It now changes only when something it says has changed, and stays open while you choose."}],"3.34.0":[{title:"🗺️ The network map shows who you are connected to",body:"Paired decks that are on stand closest to this one, and a light runs along their wires. Paired decks that are away come next, in a colour of their own, with how long they have been gone, and machines that are not paired stand outside in grey. Decks reached over Tailscale sit together in their own shaded slice instead of on dashed wires. Pointing at a deck opens its details beside the map: whether it is there, what to do next if anything, its address and what it runs, and every login the two share, the ones that need a look first."},{title:"🔑 A login that expired everywhere says so",body:`When a shared login expired on this deck and every paired deck that is on held an expired copy too, the row said "Login expired" and waited for a repair that could never come. It now says "Login expired on all online decks". Claude retires a login's other copies each time one machine refreshes it, so shared copies expire together: sign in again on any one machine and the others repair from it on their next round.`},{title:"💬 Send feedback from inside the deck",body:'Appearance settings has a "Send feedback…" button: pick what kind it is, write a title and a few lines, and add a way to reach you if you want an answer. It goes to the people who make ccdeck, who may open a public issue from it, never with your contact in it. If it cannot be sent, the form stays filled in and says why.'}],"3.33.0":[{title:"🪝 Hooks you add in Claude Code are no longer removed",body:"Claude Code's hook editor often files a new hook into the same group as the deck's own. Starting the deck, or uninstalling it, then removed the whole group, and your hook went with it without a word. The deck now takes out only its own command and leaves yours where it was, and the same goes for the old finish-sound hook. `ccdeck --uninstall` also stops the decks that are running, so an update in the background cannot put the hooks back."},{title:"🧵 Resumed Codex sessions show up again",body:"A Codex session picked up with `codex resume`, or one that ran for days, could go dark on the canvas and drop out of the 5-hour and 7-day usage, because the deck only looked in the two newest day folders. It now follows those sessions and counts their tokens. Two Codex sessions in the same folder get different id suffixes, and a `bash -lc` call shows the command it runs."},{title:"🤝 A deck paired by the accept switch brings in less",body:'A deck that paired through the automatic accept switch, and not through an invite, now brings in only the logins you have ticked on this deck, and nothing from it is ticked for sharing onward. Its dialog says "paired automatically — pair by invite to take it". Pairing by invite works as before. A typed address is no longer dropped after one failed round, and the sync port stays the same after a rename.'},{title:"⬆️ Desktop updates install when you expect them",body:'On Windows and Linux a downloaded update now installs when you quit. On a Mac, Quit installs it and the app stays closed. The Linux .deb needs an administrator password to install, so it no longer does that by itself: it waits for "Restart to update" and says a password is coming. "Start at login" now works on Linux, and "Restart ccdeck" stops a deck that has hung.'},{title:"🕵️ Browser Watch waits before it acts, and quits only its own browser",body:"A program's visit is now logged and reacted to once its quiet window has closed, about 16 minutes after it, and not on the first poll, so a visit that is withdrawn no longer quits the browser. On Linux the quit reaction ends only the browser that holds the watched profile; other Chrome channels and headless browsers keep running. When it cannot tell which process that is, it does nothing and says so, which includes a Flatpak Brave."},{title:"🧮 Figures that were off are right",body:`Spend by labelled and workflow subagents counts toward a session's tokens and cost. The Projects report prices 1-hour cache writes the way ccusage does, so its dollars match the Usage panel. After a restart the deck rebuilds its whole event history, where it used to rebuild about a third. On Linux the process list shows what each process is using now, not its lifetime average. A count near a boundary reads "1.00M", and a full quota window says "used up".`},{title:"🔑 The Usage panel's reads answer the deck's own page only",body:"The routes behind the Usage panel (/api/quota, /api/ccusage, /api/codex-usage, /api/codex-quota and /api/cswap-auto) now answer the deck's own page, or a client that sends the deck's token. A script that read them with a plain request gets 401 from this version on. The hook, the desktop app and the `ccdeck` command are not affected."},{title:"🛠️ Smaller fixes you may notice",body:"With the canvas paused, an update no longer restarts the server while an agent is working: it waits until no turn is open. `ccdeck --stop -p4317` stops that one deck. A deck started at login can update itself on Homebrew and nvm setups. Dialogs keep keyboard focus after a button goes away, screen readers hear pairing requests by deck name and the machine panel's readings, dim text is readable in both themes, Windows High Contrast shows what is selected, and below 640px the detail panel opens over the canvas."}],"3.32.2":[{title:"🔒 Self-updates wait until your screen is unlocked",body:"On Linux with GNOME, the app installs an update by itself when you leave it alone, which is often while your screen is locked. GNOME switches the panel's tray off under the lock screen, and a version that started then never showed its icon. The app now waits until you are back before restarting by itself, so its icon comes back with it."}],"3.32.1":[{title:"🔔 The tray icon comes back on Linux",body:"On Linux the app could lose its icon in the panel, after it updated itself or when the panel restarted, and stay without it until it was quit. It now notices within a minute and restarts by itself the next time you are away from its window, the way it installs an update. It does this at most once every six hours, and not again if a restart did not help."},{title:"🔕 A window you closed stays closed after a self-update",body:"When the app restarted by itself to install an update, it opened its window again even if you had closed it, and while that window was open the deck held back its notifications. A window you closed now stays closed."},{title:"🪟 No empty icon when ccdeck is already open",body:'Opening ccdeck again while it was running flashed an empty "…" icon in the Linux panel before bringing the window forward. It now only brings the window forward.'}],"3.32.0":[{title:"🗺️ A map of your network",body:"A new button on the Local network row, and in its view's header, opens a map of every deck around this one. This deck is at the centre and the paired decks that are on stand around it. Further out are the quiet ones, the machines nearby and any deck asking to pair. Wires are solid on your local network and dashed over Tailscale. Pointing at a deck says how it is reached, what it runs and which logins the two share, and pressing it opens that deck's own dialog."}],"3.31.0":[{title:"📊 Account capacity",body:"A gauge button in the accounts panel's header opens Account capacity: how many of your Claude accounts are ready now, what the 5-hour and 7-day windows have left across all of them, and a row for each account with its use, its state (Ready, Limited, Exhausted or Stale) and when it was last read. Each window also says whose reset comes next."},{title:"🚦 Claude and Codex incidents",body:"When Anthropic's or OpenAI's status page reports an incident on something your sessions use, the deck says so in the topbar, the Usage panel and the tray, and every mark links to the status page. A provider with nothing wrong draws nothing."},{title:"↕️ Order your other accounts",body:"The Other accounts row can sort the list by slot, by how full a window is, or by most room, and open every account at once. Both stay as you left them after a reload."},{title:"🔐 A settings folder left by sudo can be given back",body:'On a Mac, running ccdeck once with sudo left its settings folder owned by another user, and every settings change was refused, sharing an account included. The message now offers "give it back": macOS asks for your password, the folder is yours again, and the deck reads its settings back without a restart.'}],"3.30.0":[{title:"🧮 Token counts and costs are no longer doubled",body:"Claude Code writes a reply that has thinking, text and tool calls as several transcript lines, each carrying the whole request's usage. The deck added up every line, so a session's tokens and cost on its card came out close to twice what it was billed, and the context panel counted each part of a reply as its own message. Each request is now counted once. Expect the totals on your cards to come down."},{title:"⏳ Claude's saved limit resets on the Usage panel",body:`When your Claude account has free limit resets to spend ("Reset for free" in Claude's Settings → Usage), the Claude card now says how many there are and when the first one expires, the way the Codex card already did. The deck only reports them; you spend them in Claude's own settings.`},{title:"🔑 LAN invites need the other deck updated",body:`An invite's code is now a long random secret instead of six digits, so nobody else on the network can work it out and pair in your place, and a wrong code is refused by name. An invite made on this version can only be joined from a deck on this version or later: an older deck answers "That is not an invite". Update that deck, or make the invite on the older one and join it here.`},{title:"🔕 AGENTS_DECK_NO_NOTIFY keeps Browser Watch quiet too",body:"A deck started with AGENTS_DECK_NO_NOTIFY=1 still raised a desktop notification for every new Browser Watch finding. It no longer does. The finding is still in the Browser Watch panel and its log, which says why no notification came."},{title:"🛠️ Smaller fixes",body:'Delete removes the card you just clicked. A LAN address you typed stays in the list when a round cannot reach it, and the status line under the LAN switch now agrees with the rows below it. In the desktop app, a dismissed "update is ready" notice stays dismissed after you answer the first-launch question. Sizes read the same in every panel ("1.1 KB"). Faded text stays readable, a keyboard can see the scrollbar, and numbers use a monospaced font on Windows and Linux as well.'}],"3.29.11":[{title:"💲 Claude Sonnet 5.5 has a price",body:`Sessions on Claude Sonnet 5.5 showed "not priced" on the board, and the Projects report could only show a minimum for them. They are now priced at Anthropic's published rate, the same as Sonnet 5: $2 per million input tokens and $10 per million output tokens.`}],"3.29.10":[{title:"💲 Claude Opus 5.5 has a price",body:`Sessions on Claude Opus 5.5 showed "not priced" on the board, and the Projects report counted them as costing nothing, so its totals read far too low. They are now priced at Anthropic's published rate. If a model still has no price, Projects shows its total as a minimum, like $11.19+, and names the model, instead of a total that looks complete.`}],"3.29.8":[{title:"🔁 Removed cards come back when their agent works again",body:"Remove from board is for finished work. If the agent behind a card you removed starts a tool call, gets a new prompt or starts a subagent, the card returns on its own, together with the card it hangs from, and it stays back after a reload. Cards whose agents stay idle stay removed."}],"3.29.1":[{title:"🗂️ One row per project in Projects",body:"The Projects report now counts a session's work under the folder you started it in, the same name its card has on the canvas, instead of adding a row for every folder the agent moved into. The first start after updating re-reads your transcripts once to regroup the report."},{title:"🔔 Tidier custom sounds",body:"Importing a sound, recording one and choosing a spoken voice now sit in compact cards that respond to clicks and focus like the rest of the deck."}],"3.29.0":[{title:"🎵 Your own stations in Claude FM",body:"Add any YouTube live link or radio stream as a station in Appearance, next to the built-in ones, and mute the music without losing your volume. When a station is not live, the picker now says so instead of staying silent."},{title:"🔔 Notification sounds and voices of your own",body:"Pick a local audio file or a spoken voice for each alert, so the sound that means an agent is waiting is one you will recognise."},{title:"🗑️ Drag a card off the board to remove it",body:"Drag a card to the target at the bottom of the canvas to take it off the board, or use Remove from board in the detail panel (Delete). The session keeps running, and the session list (L) brings it back."},{title:"🔐 Optional invite-only pairing",body:"Pairing works as before, with or without an invite. If you want, Local network can now be set to accept only decks that join with an invite you created, so a nearby machine cannot ask to pair on its own."},{title:"🌐 Account sharing between your machines is more reliable",body:"A locked macOS Keychain is explained instead of failing silently, a login that is broken or belongs to another account is never shared, and a sync that stops partway keeps what already arrived."},{title:"📅 Projects opens on Today",body:"The Projects report per account starts with today's work, and an empty window offers the next wider one. The topbar also shows this month's usage, and the desktop app can restart into an update from its own window."}],"3.27.0":[{title:"📊 Projects: where each account spent its work",body:"Each account card's ⋯ menu now breaks its cost down by project, over 7d / 30d / all."}],"3.27.1":[{title:"🎨 Make Appearance easier to tune",body:"The Appearance dialog now has clearer sections, stronger selection states, and a calmer layout for choosing a theme and configuring music. Your existing settings and keyboard shortcuts continue to work."}],"3.27.2":[{title:"💰 Project costs now match Usage",body:"Project cost totals no longer count the same Claude request once for every content block. Existing project history is rebuilt automatically so the totals align with the Usage panel."}],"3.27.3":[{title:"🎵 Station selection works in the desktop app",body:"The music station picker now opens inside ccdeck instead of relying on the operating system popup, so choosing a station works reliably in the Electron app."}],"3.27.4":[{title:"✅ Desktop picker release checks are green",body:"The station picker now keeps the same keyboard, motion, focus, and layout behavior as the rest of ccdeck across desktop and browser builds."}],"3.27.5":[{title:"🧭 The welcome tour stays dismissed",body:"Electron now remembers that you completed the onboarding tour at the deck level, so an update or loopback port change no longer shows the same tour again."},{title:"🎵 The station picker has a clearer finish",body:"The music selector has a tighter trigger, a purposeful chevron, and more deliberate option spacing so it reads like a native part of Appearance."}],"3.25.0":[{title:"🖱️ A click goes to the session, a double-click opens the details",body:"Clicking a card frames it with the rest of its session and leaves the detail panel shut. Double-click a card to open its details; `j`/`k`, the session list, Enter and `D` still open them too."},{title:"🔭 Cards stay readable when you zoom out",body:"At every zoom a card shows its name, its state and anything waiting on you, instead of shrinking to a coloured pill. Hover or focus a card to see it whole. Recap notes read at a distance too, and show the full recap on hover."},{title:"🌐 The Machine panel shows your network",body:"A new Network section shows download, upload and the round trip to Claude's API, and names the route when traffic goes through a VPN or a Tailscale exit node. Those checks run only while the panel is open. The panel is regrouped into CPU, Memory, Network and Thermal, with a flag at the top when something needs attention."},{title:"🎨 See each theme before you pick it",body:"The Appearance menu shows a small preview of the deck in Light and in Dark. Claude FM also keeps its volume when a notification chime plays, instead of dipping under it."}],"3.24.1":[{title:"🎛️ Appearance is one small menu now",body:"The topbar's appearance control opens a compact menu where you can choose Light or Dark and show or hide the character. The character stays on by default, and your choice is remembered."}],"3.24.0":[{title:"🎧 Claude FM plays from the minimap",body:"A small character stands on the minimap's top edge. Press it and the Claude channel's live stream plays; press it again and it stops. It only turns up when the channel is actually broadcasting, so a deck with no network never shows it at all."},{title:"🤠 And it gets on with its day",body:"It walks that edge, tidies up what it finds, kicks a ball along it, sits with its legs over the side, and watches the board through a scope. Now and then it drops onto the canvas and ropes its way back up. Headphones on while the music plays, a hat when it does not."}],"3.23.5":[{title:"🧭 The accounts panel opens on the account you are on",body:"Its windows, its resets and how old the numbers are — whole, at the top of the column. Every other account stands behind one row that says how many of them a switch could actually reach; press it to see them, or rest on it to be shown their names and how much room each has left."},{title:"⚙️ Auto-switch moved in there with them",body:"It is behind that same row now, after the accounts it switches between, rather than at the foot of the panel. The row says `auto 90%` or `auto off` so you can tell what the policy is doing without opening it — and says so in amber when it is armed with nowhere left to go."}],"3.23.0":[{title:"🧭 The accounts column leads with accounts",body:`The live account is the open row: its windows as bars, when each one resets, and how old the numbers are. Every other account rests on the two figures a switch is decided by, and opens with a click when you want the rest.
112
-
113
- A problem stays on the row — an expired login, one that was never stored, a keychain the deck cannot open — with the reason and the sign-in one press away. Auto-switch is one row now: its threshold and its switch. Local network moved out of the column into a view of its own, reached from a row at the foot that says how many of the paired machines are on right now, and shows which ones when you hover it.`},{title:"💬 A resting session shows Claude Code's recap beside its card",body:"When a session stops, Claude Code's own recap of what it did is drawn beside the card — so a board you come back to says what happened without opening anything."},{title:"🪟 The chrome went quiet",body:`The topbar is borderless, one set of corners runs through the app, the canvas ground is flat, and the minimap, the zoom controls, the type filter and the Machine and Usage panels read as tooling rather than as cards.
114
-
115
- The canvas also says when auto-fit is off, with one press to bring new sessions back into view.`},{title:"🔍 A tool call's detail reads as the call",body:"A tool call's arguments are shown as the call rather than as escaped JSON, and can be copied."},{title:"🔐 Saying yes to every deck that asks takes two presses",body:"The switch that accepts every pairing request arms first and says what it hands over, so one stray click cannot put this machine's logins on another deck."},{title:"🖐️ Targets, themes and contrast",body:"The panel's smallest controls reach the 24px target floor, and grow further under a finger. A first run follows the system's light or dark setting instead of picking one. Status dots, meters and switch knobs survive a Windows Contrast theme."}],"3.22.15":[{title:"🖱️ Clicking a card opens its details",body:"Selecting an agent is inspecting it: a click, `j`/`k`, a session picked from the list and Enter on a focused card all open the detail panel — prompt, every tool call, tokens, timing. It used to open only with `D`, so anybody who closed it with its × and never found the key did not get it back. The × still closes it until the next selection, and `D` still toggles it.\n\n`D` with nothing selected now picks a card first — the session that has waited longest, or the one `j` would land on — instead of flipping a switch with nothing on screen to show for it."},{title:"⌨️ The keyboard and screen readers reach the whole deck",body:`Shortcuts keep working after a mouse click on a button. A click left focus on the button it pressed, and the key handler leaves a focused control its own keys, so every single-key shortcut was dead until you pressed Esc — with nothing on screen to say so.
116
-
117
- Tab follows the page now — topbar, the accounts column, the canvas, usage, machine — instead of zig-zagging left and right across it, and a canvas card reached by Tab draws the focus ring. A screen reader hears each card by name, with its kind, state, model and cost, rather than every word on it run together; the machine panel has a heading its region is named by; and the theme button is named for the theme it switches to.
118
-
119
- With **Reduce motion** set, the camera no longer flies across the canvas to a card.`},{title:"💵 The money figures say what they measure",body:"The usage header's **$/min** is spend over a trailing window, and says which span it measured: `$3.54/min · 2 min`. It used to divide the live agents' cost by how long the longest of them had been running, so one deck read $2.39/min in a tab left open and $19.49/min in a tab opened minutes later.\n\nA quota bar's pace says **over pace** or **under pace**. It said `ahead`, which is how plain English says winning, on the very line meant to warn you that you are burning the window faster than it lasts.\n\nA card's clock reads `≥ 53m 52s` for a session this page joined after it had started, instead of presenting the part it saw as the whole of it — and that card's per-minute burn is left out rather than divided by the short clock."},{title:"↔️ Narrow windows keep every topbar control on screen",body:`At 400px six of the topbar's buttons sat past the right edge and the page scrolled sideways. The readouts give way first now and the controls stay; below 640px the side panels span the window instead of leaving the canvas a sliver; and the category filter wraps inside the canvas rather than being clipped by it.
120
-
121
- Zoomed out, a card's name and a cluster's label stay readable instead of shrinking to about four pixels — which is the view a board of any size actually sits at.`},{title:"🔑 A paired deck's dialog says which account that machine is on",body:`The lane of the account the other machine is working on takes the accent and a slow ring on that machine's end. An account is named only if that deck shares it: on one it does not share, the dialog reads "on another account" and never which. A new switch under **SHARE THESE ACCOUNTS**, on by default, turns the telling off, and paired decks then read "current account hidden".
122
-
123
- **This deck on the network** prints this deck's own fingerprint again. A pairing request asks you to match it against the one on the other machine's screen, and no screen here was showing it — so the one check a person can make against a rogue deck could not be made, on the step that hands over logins.`},{title:"💬 The deck's messages send you somewhere worth going",body:'An empty canvas no longer ends with "Make sure ccdeck is running" while the page is plainly connected to it. The capture hints under that line, one per CLI, are the real reasons a canvas stays empty, and they stay. With the stream down the screen says whether this page lost a deck that was there or never found one, in those words, rather than naming the `/events` route nobody who typed `npx ccdeck` has seen.\n\nAnd a slow `claude-swap` now reads as a slow answer — "still waiting on the deck server" — instead of "couldn\'t reach the deck server", which sent people off to restart a server that was fine.'}],"3.22.10":[{title:"🖱️ Icon buttons are easier to hit",body:"Icon buttons react when the pointer is near them — no need to hit the icon exactly."},{title:"🧩 Sessions spread across the canvas",body:"Sessions now spread across the canvas in columns instead of one tall column, and new sessions and subagents land in the free space beside them. Nothing is placed under the Machine or Usage panels. Press R once to rearrange a board you already have."}],"3.21.0":[{title:"🖼️ The deck explains itself in pictures",body:"🎬 First run opens an eight-picture tour instead of the changelog — who is waiting on you, the tree, a node's inside, cost and quota, this machine, accounts, local network, how to start. `Take the tour` on an empty canvas brings it back.\n\n📡 **Local network** has a guide: a card while it is off, `How it works` under an empty list, four pictures ending on `Turn it on`. A machine's row opens its own dialog — address, version and system, the logins it offers, and a name of your own for it. Setup ends on Done.\n\n🔄 The deck updates itself when nobody is looking: no tab focused, no agent mid-turn, thirty seconds quiet. The banner's `auto when idle` switch governs it.\n\n🔑 An account whose numbers were paused resumes on its own, and the panel is titled **Claude accounts** — a Codex login is not in it."}],"3.20.0":[{title:"🟢 The deck keeps running after you close the terminal",body:"`ccdeck` prints the same boot report and gives you the prompt back. The deck stays up, and starts again when you log in.\n\n🛑 **`ccdeck --stop` is the off switch now** — Ctrl+C only cancels a start that is still printing. `--status` says what is running, `--logs` shows what the deck wrote while you were away, and `--foreground` holds the terminal the way every version before this one did.\n\n🔁 Typing `ccdeck` beside a deck that is already up opens **that deck's tab** instead of building a second one. `ccdeck --stop --all` clears any older deck still running from before this version. An `npx` run cannot start at login — `npx ccdeck --install` puts it on your PATH and sets that up.\n\n🔑 An account that will not collect now says which of three things is wrong: **no stored login**, a **login that expired**, or a **keychain the deck cannot open** — with the fix beside it. One with no stored login is filled over the local network by a paired deck that has it.\n\n📡 And decks find each other again on a machine with a VPN up: the beacon was going to an address that never left the machine, so this deck could hear colleagues and none of them could hear it."}],"3.19.0":[{title:"🟢 Local network: fixes and improvements",body:`The list of decks is quiet now. A deck that is **on**, with nothing to repair, is a name and a green mark — no sentence under it. Every healthy row used to carry the same words, so the one row worth reading looked like all the others. A failure, a login that arrived, a machine that is away, still say so, and they are now the only rows with anything written on them.
124
-
125
- \`unpair\` arrives when you point at a row rather than sitting on every one of them, two machines that share a name show their addresses, and the ↻ turns while a round is out.
126
-
127
- **Add a deck** is two ways in — by address, or with an invite — with \`make one to send\` beside the invite heading instead of under the paste field, where it read as that field's button. A refused address now says which mistake it was, and an invite that will not work says whether it ran out, was not an invite, or reached nothing.
128
-
129
- Switching **Local network** on opens your name and shared logins, every time, so nothing goes on the network without you having just seen what goes with it.`}],"3.18.3":[{title:"🟢 The list shows what is on, and folds the rest",body:'A machine that is off, or nearby and unpaired, or one you said no to, is context rather than an answer to "who can I use right now" — so the decks that are **on** lead the list and everything else is one line: `2 more`. Nothing worrying is hidden by it: a deck that cannot be reached is counted in that line, in the warning colour, so the fold says whether it is worth opening.\n\nThe round moved to a **↻ beside the switch**, where the accounts header has kept the same act since it was written, and the line under the state now says when it last ran — `checked 2m ago`, or `not checked yet`. A list that refreshes itself and a list that has stopped used to look identical, and pressing the button to find out was the only way to tell.'}],"3.18.1":[{title:"🔁 A deck stops asking to pair over and over",body:"Several decks on one computer share a config directory, so they start with one key. Each read the others' beacons as somebody wearing its name, took a fresh key, and wrote it to the file the others read — a loop that never settles. Every new key is a **new deck** to everyone else on the network, so one machine sent a fresh pairing request every few seconds and accepting one accomplished nothing: the deck that asked no longer existed by the time the answer arrived.\n\nDecks on one computer now recognise each other as the same machine and leave the key alone. The clash still worth healing — a `~/.claude` copied to a second machine — is unchanged.\n\nThis also collapses the rows: a computer that has run the deck a few times appeared several times on everybody else's panel and is one row now. **Both machines need this version** for that to take effect on the other one's screen.\n\nA deck that answered is no longer counted as unreachable, the list refreshes itself in seconds while somebody is deciding rather than at the next minute, and a failed round says what happened — `not listening`, `no route to it` — with the address and the raw error on the hover."}],"3.18.0":[{title:"🟢 A deck that is switched off no longer reads as on",body:"A paired deck this one has no address for was drawn **live** on the strength of being paired — a machine closed an hour ago still sat under `1 deck ready`. Every row now leads with whether that machine is actually there, and when it last was: `online · 1 login arrived`, `no answer · last online 20m ago`, `never reached`. The mark beside the name is a traffic light — green for a deck that answered, amber for one that cannot be reached, grey for one nothing has heard from.\n\n**+ add a deck** opens a dialog now instead of unfolding inside the panel. An address, an invite and the firewall note never fitted a 288px column, and unfolded they turned a list of machines into a form."}],"3.17.0":[{title:"🔔 Pairing is two presses",body:`When another deck asks to pair, the question now arrives **over the deck** rather than in a row three sections down a panel: its name, its address, the fingerprint to compare, **Accept** or **Decline**. Escape means later — the request stays in the panel until you answer it.
130
-
131
- The rest is one list. Every deck you are paired with, every deck on the network, and every one you turned away, each a row with its state under the name and one verb at the end — and a deck that cannot be reached now reads differently from one that is fine. Saying no also reaches the other machine now, instead of leaving it waiting forever; you can take it back.
132
-
133
- The dialog behind **setup** is down to the two things it is really about: what this deck is called, and which logins it offers.`}],"3.15.0":[{title:"🔗 Decks on one network heal each other's dead logins",body:`A login dies on the machine that has not used it while the same account keeps working on the machine that has. The fix was a blob copied out of one deck and pasted into another. Now: **Accounts ▸ Local network**, the same passphrase on each deck — it offers you six words — and they find each other and repair themselves.
134
-
135
- A deck only **adds** an account it does not have, or **replaces one it has proven dead** — proven by Anthropic refusing the token, not guessed. A credential that works is never touched. The passphrase is the only gate; a stranger on the same wifi sees that a deck exists and nothing else.`},{title:"⚠️ What sharing a login actually means",body:`**A login you share is a live one, and it cannot be taken back.** Turning the switch off stops what has not happened yet; a credential that has left your machine is gone, and the only real revocation is signing in again at Anthropic — which ends the session everywhere at once.
136
-
137
- Sharing a Claude account may also be against Anthropic's terms. Your call; the deck says it once and does not nag.`}],"3.14.0":[{title:"📊 The machine comes back beside the list that covers it",body:`**Busiest processes** opens over the machine panel and hides the very readings that sent you looking. They are back beside the list — cores, memory, swap, queued work, temperature — with up to an hour behind each: a column down the side on a wide screen, a band under the table on a narrow one.
138
-
139
- Each is drawn against the line it is measured to — memory and swap at 90%, load at your core count, the GPU at 75° and again at 90° — so swap sitting *on* its line is something you see rather than work out. The processor readings get no line on purpose: a CPU at 90% is your machine doing what you asked for. Throttling appears only once your machine has actually been held back, and the band says how much history it really has rather than claiming an hour it has not had.`},{title:"📋 The process dialog's footnote moved onto the columns it was about",body:"A band ran along the bottom of **Busiest processes** saying three things. Two were worth keeping and are now on the header of the column they describe — hover `memory` to read what that number measures, `process` to read that the command-line redaction is a filter rather than a promise.\n\nThe third said the list is the busiest by processor and memory, refreshed every four seconds. The heading, the count beside it and the moving numbers were already saying that."},{title:"📝 These notes render what they were written in",body:`Every note in this dialog is written in Markdown — **bold** for the sentence that carries the change, backticks for a flag or a path — and the dialog printed the string raw. So the first window you see after an upgrade has been showing you \`**this**\`, backticks and all, since the feature shipped: 25 of 52 notes, 52 bold spans, 54 code spans.
140
-
141
- What you are reading is the first version that does not.
142
-
143
- No Markdown library came along for it. Counted in the file: bold 52, code 54, links 0, headings 0, lists 0 — and the smallest library that reads all of Markdown is 40KB on a bundle the deck fetches while you wait for it to start.`},{title:"⎋ Esc leaves the machine panel where it is",body:"The × on **This machine** read `Close (Esc)`, so Escape put the panel away. Escape belongs to the canvas — it deselects and hands the keyboard back — and pressing it while you are reading your instruments should not close them.\n\nThe panel now closes the two ways it opens: its ×, and the meter in the topbar. The × says `Close`, and names no key it does not answer."},{title:"🖥 The machine moved out of the topbar and into a button",body:"The small CPU sparkline and memory bar in the topbar are gone. A chip glyph in the icon row beside `$` and the accounts silhouette opens the same **This machine** panel — cores, memory, swap, load, temperature, busiest processes — and the bar stops moving in the corner of your eye.\n\nIt also stops asking. The deck read your machine every three seconds for the life of every tab to feed that meter; it now reads only while the panel is open, and the history behind the readings is kept by the deck itself, so a panel opened an hour from now still has the hour behind it."},{title:"🔎 The panel's eight process rows became one way in",body:"The machine panel drew eight processes in a 280px box: three columns, names cut off mid-word, and a `ps` run every four seconds to keep them moving. **Busiest processes** is a single row you press now, and the dialog behind it is what it always was — every candidate the deck sees, its memory in bytes, threads, user, pid, and the command line that tells you which `node` this one is.\n\nWith that dialog closed, the deck reads no process list at all."},{title:"⏱ The restart banner says whether the press is safe, and shows the fuse",body:"The button read `Restart now` whether the machine was idle or five agents were mid-turn — and the events fired while the server is down are lost for good. It reads **`Restart anyway`** now when something is running, with the count beside it, and `Restart now` with *nothing is running* when the machine is quiet.\n\nThe automatic restart said only `auto when idle`, while a 30-second clock ran where nobody could see it. It counts — **`auto in 18s`** — which is also how you stop it, since the switch is the label. The amber dot pulses only while that clock runs.\n\nThe switch also says `auto-restart off` in words rather than in a colour, both its label and the button are readable in the light theme now, and a tab you are not looking at no longer restarts the deck under the tab you are."}],"3.13.0":[{title:"📊 Usage history stops jumping out from under you",body:`Pressing **H** put \`running ccusage…\` in a box 186px tall. Two to four seconds later the chart, the totals and the legend arrived and the box became 429px — and because the dialog is centred, that growth moved the whole thing **121px upward**, under the cursor that had just pressed something.
144
-
145
- The chart's place is now reserved from the first frame: the 168px the chart is tall plus the 16px it keeps for its day labels, both taken from the chart's own rule so the placeholder and the thing it holds room for cannot drift apart. The jump goes from 243px to 156px. It deliberately stops there — the totals and the legend are content, the legend's height depends on how many models ran, and reserving those would have meant drawing four plausible empty cards for a reading that had not arrived.
146
-
147
- What is drawn in the reserved space is **the chart's baseline and nothing else**: one line, in the same colour, at the height the columns will land on. Not a skeleton of grey bars — a skeleton stands in for content, an axis is furniture, and furniture is honest before the data exists. The light on it travels rather than fills, because the deck knows a subprocess is running and does not know how far through your transcripts it has got.
148
-
149
- Then the days rise out of that line, **oldest first**. The stagger is divided rather than fixed — 200ms of spread whether the range is 7 days or 90 — so the longest range is not also the slowest to appear.
150
-
151
- With reduced motion both loops and both entrances are off. The reserved space is layout, not animation, and stays outside that rule: asking for less movement gets you the same dialog that does not jump.`},{title:"⏳ The period mark says it is being read",body:"The first read of **today**, **month** or **all** takes two to three seconds — it walks the transcripts on this machine, and the cost is the walk, not the size of the range you asked for. Until now the panel said nothing for the whole of it, so pressing `month` looked like pressing nothing, and the honest response was to press it again.\n\nThe mark under the period now pulses while that read is in flight, and it **pulses rather than fills**: nothing measures how far through the transcripts ccusage has got, so a bar that filled would be inventing a number. Hovering the pending period says which one is being read, and screen readers are told the same thing through a live region rather than being left with a silent button."}],"3.12.0":[{title:"🔍 Busiest processes tells you which one",body:"The list could say what was eating the machine and not **which** of nine identical `Google Chrome Helper` rows was the headless Chrome you left running. It now shows the arguments after the name — `--type=renderer` beside one, `serve admin-portal --port 44440` beside a node — and four columns it did not have: **memory in MB and GB** instead of a percentage, **threads**, **how long it has been up**, and **user**. Every column sorts; press its heading.\n\n**Command lines have anything secret-shaped removed before they leave your machine** — the value of any flag whose name says token, password, key or secret, the password in a URL, and the shapes that identify themselves. It is a filter and not a guarantee: a secret that looks like an ordinary word looks like an ordinary word. The reading happens only while this modal is open, so a deck whose process list you never open never reads a command line at all.\n\n**Memory is resident set size** — what `ps` and Windows Task Manager report. On macOS this is *not* the number Activity Monitor shows in its Memory column; that one is the physical footprint, and on the machine this was built on the two disagree by up to fourteen times on the same process. No unprivileged command reports the footprint quickly, so the deck shows the figure that means the same thing on all three platforms and says which one it is.\n\n**There is no Ports column**, and the reason is the same kind of honesty: Mach ports do not exist on Linux, are not what Windows calls a handle, and on macOS the only way to count them takes four seconds — against a list that refreshes every four."},{title:"🔢 A token count that stays a whole number",body:"Switching the Usage panel from **month** to **today** counted down smoothly and then, for a fraction of a second, showed something like `in 594.3268260610639` where a token count belongs.\n\nThe count was never wrong; the printing was. The figures animate between two readings, so the formatter is handed a fraction on most of its frames — every size above a thousand was already rounded and the one below it was not."}],"3.11.0":[{title:"🗂 The session list waits to be asked for",body:`**BY SESSION in the Usage panel now starts collapsed.** It is the one block in that panel with no ceiling — every other section is two or three rows, or a model table bounded by the models that exist — and it was the reason the panel scrolled at all. Shut, the whole panel is one screen: quota, period, money, models. Press the heading to open it, and it stays open; ccdeck remembers your answer from then on.
152
-
153
- The count of what is behind it is on the heading's tooltip, so collapsing it does not hide how much there is.
154
-
155
- **Scrollbars are also gone until you point at the thing that scrolls.** Nothing moves when they appear — the track keeps its width in both states, so no text shifts under the pointer as it arrives.`},{title:"📊 today · month · all, as tabs that remember",body:"**The Usage panel's period switcher is a full-width row of tabs** rather than a pill floating over the column, with a thin cyan mark under the word it belongs to. It governs the figures beneath it, so it now looks like it does.\n\n**Your chosen period survives a reload.** It was the one preference in that panel that did not.\n\n**It costs one Tab stop instead of three.** Tab into the strip, then move with ←/→ or Home/End, and press Enter to choose. Arrowing past a period no longer starts reading it — moving and choosing are separate now, which matters on `all`.\n\nAnd **`month` says which month.** Hover it: this is the calendar month, from the 1st — not the last 30 days. `today` and `all` say what they cover too."},{title:"🔔 Sounds and Notifications are two switches, and Browser notifications is a channel",body:`**The sound menu has been rebuilt.** Sounds and Notifications are real switches now instead of words that read like status. Under them, **Browser notifications** is named as what it is — one of the two ways ccdeck can reach you — rather than sitting there as a third setting that seemed to contradict the one above it.
156
-
157
- There are two notifiers and they never both fire: the page raises one when the deck is open but hidden, and the server raises one when no page is open at all. Only the first needs a browser permission, which is why the permission belongs to a channel and not to the feature. **Turning Notifications on now asks the browser on that same press** — no second control to hunt for.
158
-
159
- \`M\` mutes and unmutes sounds from anywhere. **Hear it** plays the tone even when Sounds is off, so you can pick one before turning them back on.`},{title:"🧹 No agent, no empty panel",body:`**The detail panel no longer appears when nothing is selected.** It used to sit there empty, and a tab on the edge of the canvas existed to bring it back after you closed it — both are gone. Select an agent and the panel is there; press **D** to toggle it yourself.
160
-
161
- The canvas is that much wider whenever you are not reading one agent.`}],"3.10.0":[{title:"🔌 Who else can drive your browser, and where to see it",body:"**Browser Watch has a Remote control section.** The Claude in Chrome extension holds a connection open to Anthropic's relay, and that connection is registered against your **account**, not against this machine — so any Claude Code session signed in to the same account, running anywhere, can enumerate and drive this browser, and nothing prompts you on the machine being driven.\n\nThe panel now says whether that is the case here, and what the extension is actually allowed to do in each profile — enabled or switched off, every site or only the ones it was granted, and which of the powerful APIs it holds. That last part is not what `chrome://extensions` shows you: the per-site list there is enforced by the extension, on itself, while the grant underneath stays exactly as wide as it was.\n\nIf you want it closed, the section hands you the one command that closes it — as text, to paste in your own terminal. **ccdeck never runs it and never asks for your password**, and it never will: no part of this deck elevates, and a dashboard that could raise a password box on request would be a gift to anything else running on the machine. If the block is already in place, the section offers the command that takes it back out. And if something else in your hosts file already points that name somewhere, it says so and leaves the line alone — ccdeck only removes the line ccdeck wrote.\n\nAll of this is two file reads and no network call. It was written some releases ago and, until now, was not connected to any screen.\n\n**Also:** the README said `share` produces a `ccdeck1:` blob. It produces `ccdeck2:` — `ccdeck1:` has been read-only legacy for a while."}],"3.9.0":[{title:"🎛️ Five switches that were not where the thing they control is",body:'**The session list has a button again.** It lost one a while back and only the `L` key was left — and `L` is written down in one place, a shortcuts sheet behind a small `?` in the corner of the canvas. If you use a mouse there was no way to open the list at all. The `☰` is back at the left of the top bar.\n\n**The Notifications switch now tells you whether the browser will actually show one.** It said `on` while this browser had never been asked for permission, which is not the same thing. It now says so on that row and offers the ask right there. Before, the only place to grant it was a button that appears solely while a session is stuck waiting — so on a machine where that rarely happens you could not switch notifications on at all.\n\n**Started with `--workspace` or `--scope` and seeing nothing?** The empty screen used to tell everyone to "run `claude` or `codex` in any folder", which is the one thing that cannot work for you. It now names the folder the deck is actually watching.\n\n**Browser Watch says when a setting did not save.** Flipping the switch and having it fail showed a red line reading "Could not read" — about reading history, not about your press — and ten seconds later the panel wiped it and looked perfectly healthy with the setting unchanged. A failed save now says so, in its own words, and stays until you dismiss it. The "nobody browsing for" menu also follows the stored value again: change it in a second tab and this one never caught up.\n\n**The deck no longer restarts itself when nothing on screen offers to stop it.** Thirty seconds after the last agent went quiet, with a new version on disk, the server would exit, come back and reload the page. The `auto when idle` switch that controls that lives inside the update banner — so if you had closed the banner with its `×`, it happened with no visible setting anywhere. Closing the banner now also stands down the restart; clicking the version chip brings back both together.'}],"3.8.9":[{title:"🖥️ Four things that only went wrong on somebody else's operating system",body:"**Ubuntu:** the deck knew where Chromium and Brave keep their profiles when installed as a snap or a flatpak — which on a default Ubuntu is the only place Chromium is — but not what those programs are called. So it reported them as not running while they were, and refused to quit them. Both now work.\n\n**Windows:** the deck asked the system whether it could write to the folder an update installs into, and Windows always answers yes for a folder whatever the permissions say. It offered you an update that then died inside npm with a permission error. It now finds out by trying, and declines up front with the command to run yourself — which is what every other platform already got.\n\n**Linux:** if `XDG_DATA_HOME` was set to something starting with `~`, as it is from a systemd unit or a Dockerfile, the deck and claude-swap looked in two different places for your accounts. The panel said you had none while `cswap list` showed them all.\n\n**Plain terminals:** six messages used a typographic dash the old Windows console and the Linux text console cannot draw, so a box appeared mid-sentence — including in the line that explains why no events are arriving. They use the plain form on those terminals now, like everything else already did."}],"3.8.8":[{title:"📉 A false 99% on the memory chart, and three other quiet failures",body:`**The machine meter no longer invents a reading.** When the deck could not measure memory — a subprocess that would not start under load, or one that took too long — it substituted a number that means something else, and on a Mac that reads as about 99% used. The meter went red for half a minute, and because the chart keeps the highest value in each minute, that false peak stayed on it for a full day. A poll that cannot measure now keeps the last reading and records nothing: a gap in the chart is honest.
162
-
163
- **A failed ccusage repair no longer disables the repair.** If the deck found a half-installed copy it removes it and starts again. On Windows that removal can fail for a few seconds because the program it just ran still has the folder open — and the deck then treated the attempt as spent and never tried again for the rest of the session, leaving the panel permanently unable to read your usage. It now only counts a repair that happened.
164
-
165
- **Changing the auto-switch interval takes effect even during startup.** Set it in the first seconds after launch and the timer kept the old value for the life of the process, while the panel showed the new one.
166
-
167
- **Codex sessions with very large histories no longer cost hundreds of megabytes to read.** The deck read the whole file to find four values that live at its two ends — measured at 185 MB of memory and 95ms of frozen interface for one 44 MB session. It now reads only the ends.`}],"3.8.7":[{title:"🧠 Four things in the panel that behaved wrongly",body:`**Today's figure no longer overshoots.** Once a minute, when a fresh reading landed, the headline briefly counted past the true number and back down — it was measuring the last minute of spend from a starting point one moment out of date. The reading and its starting point are now recorded together, so there is no moment where they can disagree.
168
-
169
- **Browser Watch marks findings read when you close it, not when you open it.** It was clearing the badge immediately, and stamping every new finding as read the moment it arrived — so anything that turned up while you were reading was never badged at all. It was also writing to storage four times a second the whole time the panel was open.
170
-
171
- **A hidden tool category can always be brought back.** Hide one, leave the deck running, and once the canvas had turned over the row of chips disappeared while the filter stayed on — no bubbles, and nothing to press. Only reloading fixed it. The chips now stay for as long as anything is hidden.
172
-
173
- **Clicking a session's name no longer switches auto-fit off.** The deck was reading its own camera move as you grabbing the canvas, and remembered it across restarts, with nothing said.`}],"3.8.6":[{title:"🗂️ Two decks can no longer both claim the same log",body:"When several decks share one events log they elect a single writer for it, so nothing is recorded twice. That election compared the path as typed — so two decks reaching the SAME file by different spellings each thought they were alone, both wrote every event, and each believed the log was theirs to clear.\n\nDifferent spellings are ordinary, not exotic: a shortened Windows home directory, a mapped or substituted drive, a junction, or on macOS `/tmp` against `/private/tmp`. The visible symptoms were duplicated tool calls after a restart, and Clear wiping history belonging to another deck.\n\nThe path is now canonicalised the same way the watched folder already was. It works on a first run too, before the log file exists."}],"3.8.5":[{title:"⛔ Cancelling a sign-in no longer adds the account anyway",body:`Press Escape while adding a Claude account and the deck killed the sign-in — and then, sometimes, registered the account regardless, switched to it, and told you it had worked.
174
-
175
- The deck asks the tools it runs whether they finished cleanly. A program that is well behaved about being cancelled tidies up and exits with a success code, and the deck was reading that as "it finished" rather than "I stopped it". \`claude auth login\` is exactly that kind of program.
176
-
177
- A cancelled run now reports as cancelled. Everything that was not cancelled is unaffected.`}],"3.8.4":[{title:"🧷 Your own hooks can no longer be eaten by two decks starting together",body:'If you keep hooks of your own in `settings.json`, the deck parks them while it installs and puts them back afterwards. Two decks starting at the same moment could interleave inside that, and the loser wrote a version of the file computed before the restore — so your hook was gone from `settings.json` and gone from the park, which was its only other copy.\n\nThere was already a check for this, and it had a hole: if the last-moment re-read of the file failed, it read that as "nothing changed" and wrote anyway. A failed read is the one moment that check was most needed, because the usual reason a file cannot be read for a few milliseconds is that something else has just written it.\n\n`ccdeck --uninstall` had no such check at all and could overwrite a deck that was starting, then exit 0 saying it had succeeded. It has one now, and when it declines it says so and tells you to run it again rather than reporting that there was nothing to remove.'}],"3.8.3":[{title:"🪟 Windows: two settings files that could refuse to save",body:`On Windows a file cannot be moved into place while anything else has it open, and Defender and the search indexer open a file the instant it is written. The deck has had a retry for that for a long time, and two files written in the last few days were not using it: the notifications preference, and Browser Watch's episode archive.
178
-
179
- When it bit, the notifications switch silently did not stick, and Browser Watch answered an error and showed an empty panel. Both now retry the way everything else in the deck already did.
180
-
181
- Nothing changes on macOS or Linux, where the operating system never refused the move in the first place — which is why this got past a green test suite on both.`}],"3.8.2":[{title:"⌨️ A closed-behind-your-back dialog no longer kills every keyboard shortcut",body:`Open the context ring on a session's card and leave it open. The session finishes, and a couple of minutes later the canvas evicts it — or you press Clear. The dialog vanished, and from that moment every shortcut in the deck stopped working: Space, C, R, F, L, H, U, A, J, K, T, M, and the trash button too. Only reloading the page brought them back.
182
-
183
- The deck was still counting the dialog as open, because it remembered which session you had opened it for rather than whether anything was on screen. It now closes the dialog when its session leaves the board, which is what should have happened in the first place. The end-of-session recap had the same problem and is fixed with it.`}],"3.8.1":[{title:"🔒 Security: update if the deck runs on a Mac",body:"A local process able to reach the deck's port — no token, no browser, no tab — could get a string of its choosing compiled as AppleScript when the deck raised a desktop notification with no page open. On macOS that is code running as you.\n\nThe strings were already passed as arguments rather than pasted into the script, which is normally the whole defence. It is not enough for `osascript`: its option parser reads any argument starting with a dash as an option, so a name beginning with `-e` was taken as more script instead of as text. Every place the deck hands `osascript` or `notify-send` something from outside now carries an explicit end-of-options marker, so nothing from outside can be read as an instruction again.\n\nNothing to change on your side beyond updating. If you would rather keep the deck off the desktop entirely, the Notifications switch in the sound menu does that, and `AGENTS_DECK_NO_NOTIFY=1` does it at launch — but the fix is the thing to have."}],"3.8.0":[{title:"🔕 Notifications now have an off switch",body:`3.7.0 gave you a "notify me" button and no way back. Turning them off meant digging into your browser's site settings — which no page can do for you — and that still left the other notifier, the one the deck raises when no page is open at all. Silencing that one meant quitting the deck and starting it again with \`AGENTS_DECK_NO_NOTIFY=1\` in front. The person who wanted quiet was the one doing the work.
184
-
185
- There is a **Notifications** switch in the sound menu now, beside the one for sound — that menu is already "how loudly does this deck interrupt me". One switch governs both notifiers, it takes effect immediately without a restart, and it is remembered across restarts.
186
-
187
- It is kept by the deck rather than by your browser, because the second notifier runs when no page exists and a setting living in a page could never reach it. \`AGENTS_DECK_NO_NOTIFY=1\` still wins over the switch — a machine told at launch to stay off the desktop stays off it — and when that is the case the menu says so instead of showing an "on" that will not happen.`}],"3.7.1":[{title:"🔔 The notifications now fire on the thing that actually stops your agent",body:`3.7.0 could tell you a session was waiting — but only when Claude Code asked permission to run a tool. If you work with permissions bypassed, that never happens, and the whole feature was silent for you. Measured on one real log: 1683 events, every one of them in bypassPermissions, and a single permission prompt in the entire history.
188
-
189
- What fires constantly on that setup is the other kind: the agent asking you a question and stopping for the answer. The deck was throwing those away — no amber chip, no row in the sidebar, no notification, and no "notify me" button, because the button only appears while something is actually blocked.
190
-
191
- Now they count. The card carries the question itself rather than a generic "Your turn" — "paycore needs your input: merge both branches to main, or just one?" — and so does the notification, on the desktop, whether the tab is behind something or not open at all.
192
-
193
- An idle prompt still stays quiet: a turn that ended is not a session that is stuck, and a channel that cries wolf is one you switch off.`}],"3.7.0":[{title:"🔔 The deck can reach you when you are not looking at it",body:`The deck's whole point is telling you which agent is waiting on you, and until now it could only say so on screen — the amber chip, the tab title, the favicon. Every one of those is drawn inside a page, so the one moment it matters, when you have walked away and four agents have gone quiet, the deck was silent.
194
-
195
- Now it reaches the desktop, two ways that never overlap. With the deck open behind something, the page raises the notification itself: a "notify me" button appears in the top bar the first time a session blocks, and the browser asks you — nothing is requested before there is something to notify you about. With no page open at all, the server raises it, because it can see that nobody is connected and therefore that no other surface is saying anything.
196
-
197
- One notification per session, replaced rather than stacked if a second deck raises it too. Clicking it brings the tab forward. \`AGENTS_DECK_NO_NOTIFY=1\` turns the desktop side off entirely, and if you refuse the browser prompt the deck says so plainly instead of leaving you thinking you switched something on — after a refusal only your browser's site settings can undo it, which no page is allowed to touch.`},{title:"🧩 A blocked session now says what it is asking for",body:'"Waiting on you" told you to go and look. The session row and the card now carry the tool the prompt is most likely about, and the tooltip carries the one line of its input that a person actually reads — `rm -rf node_modules` rather than `{"command":"rm -rf node_modules"}`.\n\nIt is a guess and it is worded as one: the deck sees the tool calls, not the permission dialog, so it says "likely on". The deck still cannot allow, deny or answer anything for your agent, and it never will.'},{title:"🧮 Today's figure was counting some sessions twice",body:`The panel reads your usage from ccusage once a minute and fills the gap in between from what the deck is watching. The filling-in was wrong: any session that reached the canvas after the reading had landed was added in full, and since the canvas is still loading when the first reading arrives, that was most of them.
198
-
199
- Measured on a deck four seconds old: ccusage said $450 for today and the panel said $1,006. The table underneath it said $450 the whole time, which is the disagreement to trust.
200
-
201
- The deck now adds only work it has actually watched happen. A session that starts while you are looking shows up at the next reading instead of instantly — up to a minute — which is how the panel behaved before the live figure existed at all. Everything already on screen keeps moving as it did.`}],"3.6.0":[{title:"✂️ The two figures at the end of the top bar are gone",body:`The bar used to end with a token count and a dollar figure. Both were sums over what is on the canvas at that moment, and the canvas drops finished sessions a couple of minutes after they end — so both numbers fell on their own, with nothing on screen to explain the fall. They carried the word "board" and a three-line tooltip for exactly that reason.
202
-
203
- The usage panel answers the same question without the apology: it reads the logs on disk, it covers sessions this deck never watched, and it does not forget. Press U for the panel, or H for the full history.
204
-
205
- What is left in the bar is what is true right now — whether the stream is alive, and what your machine is doing.`}],"3.5.0":[{title:"⚡ The figures move when the work happens",body:`Reading your usage off the logs is not free — measured here, one reading is 7.8 seconds of CPU, because ccusage walks every transcript on the machine whatever period you asked for. Once a minute is affordable; once every ten seconds would be three quarters of a core, permanently, for numbers that move slowly.
206
-
207
- So the reading stays on a minute and the deck fills the gap with what it already knows. Every hook event carries its session's running total, so the panel adds whatever has been spent since the last reading and counts up to it. The headline now moves when a turn finishes rather than on the clock, and it costs nothing extra.
208
-
209
- It only ever adds. A session leaving the canvas cannot pull the figure down, and the next reading corrects whatever the estimate got wrong — the tokens are exact, and the dollars in between are priced by the deck's own table.
210
-
211
- Two smaller things with it: pressing today, month or all now counts between the two figures instead of swapping them, and coming back to the tab only re-reads if what is on screen is actually stale.`}],"3.4.0":[{title:"🔢 The figures count to their new value, once a minute",body:`The Usage panel re-reads its numbers every minute now rather than every five, and it is a real minute — the server used to hold a reading for two, so a shorter poll would have handed the same figure back.
212
-
213
- And they no longer teleport. Replaced in a single frame, $170 → $269 says only "this is different now": no direction, no sense of how much, and nothing at all if your eye was a few pixels away. Counted over a fifth of a second, the same change says up, and roughly how far.
214
-
215
- What deliberately does not count: the first paint, a change of period — "today" and "all time" are different quantities rather than one that moved — the tables, a change too small to read, and anything at all if you have reduced motion on or the tab is in the background.`},{title:"🧹 The board's own figure is out of the Usage panel",body:`3.3.0 put the canvas's live spend on its own labelled line, under whichever period you had chosen. In front of a panel that answers today, this month and all time from the logs on disk, that second money figure answers a question nobody asked at that moment — and it invited a comparison it could never win, $7,385 on the board beneath $170 for today.
216
-
217
- It is gone. The board's tokens and cost are still on the topbar, with the sentence that explains why they fall on their own, and the panel still shows them when ccusage cannot answer at all.`}],"3.3.0":[{title:"📊 The Usage panel answers for a period, not just for the board",body:`It used to add up the sessions drawn on the canvas — which is an honest number with a scope nobody reads it as having: finished sessions are evicted a couple of minutes after they end, so the figure fell on its own while nothing had happened and nothing was refunded.
218
-
219
- It now reads ccusage, the same source the H modal uses, and offers today, this month and all time. BY MODEL and BY SESSION come from there too, and each session is named by the project the board knows it as rather than by a uuid.
220
-
221
- The live figure is still there, on its own line and labelled — what the sessions currently on the board have spent — because that is a different question from what the month cost.
222
-
223
- One thing worth knowing about the source: ccusage reports a session's LIFETIME total, so the rows under "active today" can add up to more than the day above them. The heading says so.`},{title:"🪟 Windows: a deck started from an elevated terminal was being treated as dead",body:"The hook decides whether a deck is still running by trying to signal it. On POSIX a process you may not signal answers EPERM; on Windows it answers EACCES, and only EPERM was accepted — so a deck started from an elevated terminal, or under another account, read as gone. Its registration was deleted on every event and rewritten five seconds later, while its banner went on saying it was connected and almost nothing arrived.\n\nThree more Windows-only faults went with it: a read-only settings.json made every hook install fail for good (the atomic write could not replace the file); the machine panel answered 500 every four seconds whenever the process read failed; and a bare command name was looked for in the working directory before PATH, which is where `npx ccdeck` was run."},{title:"👁 Browser Watch reads nothing while it is switched off",body:`The switch used to control only what was KEPT. The read happened anyway — every five minutes, on every deck, the panel's badge poll discovered each Chromium profile and copied its whole History database to a temp file to query it. A switch that says off while that continues is not a switch.
224
-
225
- With the watch off, nothing touches a browser now. Opening the panel still reads live, because that is you looking, and a watch that is ON still records in the background — that is the feature. The trade is that the topbar badge no longer counts findings while the watch is off; open the panel to see them.
226
-
227
- The README has a Browser Watch section now: what is read, when, where the copy goes, and that only visits after the deck started are ever considered.`},{title:"🔒 The deck's own data is no longer readable by anything on the machine",body:"Changing an account needed the deck's credential; reading the event ring did not. Anything running on your machine could `curl` the events — prompt text, the commands an agent ran, the paths and contents it touched — plus the account list and the browsing episodes.\n\nThose reads now answer to the same rule the mutations do: the deck's own page, or its token. Nothing changes for you in the browser. A script of yours that reads those routes needs the token from `~/.claude/agent-dag/<pid>.json`, sent as `x-ccdeck-token`."},{title:"💳 An API-key, Bedrock or Vertex install is told there is no quota window",body:`Those installs are billed per token and have no five-hour window. The CLI ran, printed no quota lines, and the deck read that as a genuine "under 1%" — drawing two empty bars for a measurement nobody had taken, or telling you to run /usage, which cannot help there.
228
-
229
- It now says what it is, in one line, the way the Codex half already did.`},{title:"🎨 The model chip is coloured by its model again",body:`A session that switched model — Sonnet, then Opus — drew a chip reading "Opus 5 +1" in Sonnet blue, because the colour was picked from the tooltip and the tooltip lists every model the card's spend covers. Add a Fable turn and it went yellow.
230
-
231
- Also fixed on the way past: an account import the CLI rejected could take the whole deck down with it, and a corrupt compressed Codex rollout leaked a file handle on every poll.`}],"3.2.1":[{title:"💵 Sonnet 5 was being costed fifty per cent high",body:`Sonnet 5 launched at $2/$10 per million tokens as introductory pricing, with a rise to $3/$15 announced for September 1. The deck implemented that schedule, and on September 1 it started charging the higher rate.
232
-
233
- The increase was cancelled. Anthropic's pricing page now says the $2/$10 rate is simply the price and the rise "will not occur" — so every Sonnet 5 session since the 1st has been shown to you at half again what it cost.
234
-
235
- It is corrected, and there is no date logic left in that rate to go stale a second time. Numbers already on your board are recomputed from the log the next time the deck starts; nothing was billed by us, only displayed.
236
-
237
- Fable 5.1 and Mythos 5.1 are also priced now, including the cache read that is a quarter of Fable 5's — which is most of what a long session pays for.`}],"3.2.0":[{title:"🌡️ Windows shows a temperature where it can find one",body:`On most Windows laptops there is nothing to show, and that is Windows rather than this deck: modern machines declare no ACPI thermal zone, and the sensors that do exist sit behind an interface only an administrator may read. Measured on real hardware, elevated and not.
238
-
239
- One thing does work, and it costs you nothing to have. If LibreHardwareMonitor happens to be running with its web server on, the deck now reads its numbers over localhost — which needs no privileges at all.
240
-
241
- It is only ever a read. Nothing is installed, nothing is asked of you, and a machine without it shows no section, exactly as before.`}],"3.1.0":[{title:"🚀 The first run stops looking like it hung",body:`\`npx ccdeck\` on a machine that has never run it used to sit on a spinner at "checking claude-swap" and say nothing else. Measured on a Windows box: seventeen and a half seconds before it told you where to point a browser. It is now one and a half.
242
-
243
- The deck was waiting for an install nobody asked for during that boot — a Python toolchain being fetched so the accounts panel would work. The port had been open the whole time; there was just nothing on screen to say so.
244
-
245
- It no longer waits. Anything still working past the boot says so on its own line and keeps going in the background, and the deck comes up without it.`},{title:"⚡ Every start is quicker, and stays quicker",body:`The event log was read from the beginning on every boot to fill a buffer that only keeps the last two thousand events — so four fifths of that reading existed to be thrown away, and it got slower the longer you had been using the deck. It reads from the end now and stops when the buffer is full: 258ms down to 20ms here, on a 34 MB log, and it no longer grows.
246
-
247
- The accounts tool is also asked for its version once instead of twice, which on this machine was the single largest thing in an ordinary boot.`},{title:"📉 Ten fewer packages to install",body:"Opening your browser used to cost a dependency that brought nine more with it — ten downloads on a cold `npx ccdeck` before the deck's own files were unpacked. It is now done with the commands the operating system already has.\n\nThe package has no runtime dependencies at all."},{title:"🌡️ Temperature, on the machines that could not show it",body:`On Windows the deck was asking somewhere it is not allowed to look: that reading lives behind a namespace that needs administrator, so it failed for everybody and the section never appeared. It reads a performance counter now, which needs nothing.
248
-
249
- On Apple Silicon there is no command that ships with macOS which prints a temperature at all — the sensors are behind an interface only native code can reach. The deck fetches a small signed tool for it, verified against the checksum its release publishes, in the background and only on the Macs that need it. You do not have to install anything. \`AGENTS_DECK_NO_DOWNLOAD=1\` turns that off.
250
-
251
- A machine with no sensor still shows no section, which includes every virtual machine. Nothing is drawn that was not measured.`},{title:"😌 The terminal goes quiet when there is nothing happening",body:`The dot at the bottom blinked every 800ms for as long as the deck ran, which is what a terminal does while it is working — so a deck that had finished in a second looked like one that never finished.
252
-
253
- It now moves only while something actually is: a job still running, or hooks that cannot find the deck. Otherwise it is drawn once and left alone, and it says what the job is rather than just blinking. A step that takes more than three seconds shows how long it has been going, which is the whole of "is this stuck".
254
-
255
- And a machine with no Claude Code installed stops being told about it every few seconds — that one is said once now, on its own line instead of across the status line.`}],"3.0.0":[{title:"📈 The machine panel now shows what it DID, not just what it is",body:`Click any section of the machine panel — Cores, Memory, Load average, Thermal — and it opens a chart of what that reading has done since the deck started.
256
-
257
- The panel could always tell you the machine is busy now. It could not tell you whether it got hot while that three-hour build was running, or how deep the queue went while you were away, and those are the questions you actually have afterwards.
258
-
259
- Thermal is new as well. Where the machine will give degrees, it gives degrees; on a Mac it also reports whether the CPU is being held back to cool down, which is the consequence a temperature has to be interpreted into anyway. Nothing is drawn that was not measured — a machine with no sensor gets no section at all, rather than a zero.`},{title:"🔍 The whole process list, not just the busiest eight",body:`"more" beside Busiest processes opens the full list the deck is watching — around fifty processes rather than eight — with the pid and the untruncated name.
260
-
261
- This closes a gap. The panel's eight rows are the busiest, so sorting them by name only reorders those eight: "is my test runner still going" could not be answered if the test runner was not already on screen. Now it can.
262
-
263
- It is deliberately not a task manager. Nothing here ends a process; Activity Monitor and Task Manager are better at that and it is not a thing this deck should own.`},{title:"🔤 Process names in Cyrillic, Greek or with accents read correctly",body:`An application named Яндекс Музыка was showing up as M-PM-/M-PM-=M-PM-4M-PM-5… in the process list, and so was every other name the deck could not spell in plain ASCII.
264
-
265
- The deck was forcing a fixed locale on the commands it runs, to guarantee that a decimal point stays a point on a machine set to German or Russian — and that also forced the character set. It forces only the number format now. Your own character set is left alone, which is what makes the name arrive intact.`},{title:"📦 The text you copy to share accounts is a third of its size",body:`Sharing three accounts used to produce 6168 characters. It is now 1896.
266
-
267
- Most of that text was never the credentials — two OAuth tokens are about two hundred characters between them, and the rest was the envelope, whose field names repeated in full for every account added. So the saving grows with the number of accounts rather than shrinking.
268
-
269
- A blob you copied before this still imports until it expires. One made now cannot be read by a deck older than this version — that is the one thing in this release that older decks cannot follow.`}],"1.48.0":[{title:"👁 Browser Watch — see what a program opened while you were away",body:`There is a new eye in the top bar. It watches the browsers on this machine and tells you when a program — an extension, an agent, a command — opened pages while nobody was touching the browser.
270
-
271
- Usually that is your own agent doing what you asked, and the panel says so rather than crying intrusion. What it gives you is the evidence: which pages, in which browser, at what time, with every address written out in full.
272
-
273
- It is off until you switch it on, and nothing leaves this machine. It reads a copy of the browser's own history and only pages newer than the moment the deck started — never anything from before, never cookies, never saved passwords. Open ⚙ inside the panel and "What Browser Watch can access" says exactly what it reads, keeps and sends.
274
-
275
- When it finds something the eye turns amber with a count. You can dismiss a finding once you have looked at it and it stays gone, while the log file on disk keeps the record. On a Mac it can also close the tab it found, or quit the browser.`},{title:"🔑 Move all your accounts to another machine in one paste",body:`Sharing accounts between two decks used to be one account at a time, and step four of six is where people stop — leaving the second deck half set up with nothing saying so.
276
-
277
- Pick the accounts you want, copy one blob, paste it into the other deck. The import adds what is missing, leaves what already works alone, heals an account whose token has died, and tells you which of those happened to each one.
278
-
279
- The blob carries real credentials, so it expires ten minutes after you make it and the deck refuses an expired one before it unwraps anything.`}],"1.47.0":[{title:"🔌 The top bar goes quiet when everything is fine",body:`The green "live" pill used to sit up there permanently to tell you nothing was broken. It is gone while things are working.
280
-
281
- You will still see a pill when it matters: amber when you pause the canvas, with how many events are waiting, and red when the deck loses its connection to the server. No pill means all is well.`},{title:"🔴 The browser tab tells you when the connection drops",body:`The little icon in the tab has always shown what your sessions are doing — grey when it is quiet, blue when something is working, amber when a session is waiting on you.
282
-
283
- It could not say the one thing that matters most: that the deck has stopped hearing from the server. Until now it just kept showing whatever it had last seen. It turns into a broken red ring instead, so you can spot it from another tab without switching over.`}],"1.46.0":[{title:"🔊 Pick a volume and a sound for each of the two tones",body:`Click the speaker in the top bar and a small menu opens. There are two tones — one when a turn finishes, one when Claude is waiting for you — and each has its own volume and its own sound, six to choose from. Press "Hear it" to try one straight away, without waiting for a real turn.
284
-
285
- The two lists are separate on purpose, so you can never end up with both tones sounding the same. A finish tone always falls; an asking tone always rises. That is how you tell them apart without looking at the screen.
286
-
287
- M still turns the sound on and off from anywhere.`},{title:"✨ This box is new",body:`After an update, the deck tells you what changed — once, and only when there is something worth telling. Most updates have nothing to say and you will see nothing at all.
288
-
289
- Click the version at the top of the deck to read it again whenever you like.`}],"1.45.0":[{title:"🔕 The deck no longer puts anything in your settings.json",body:"It used to add a hook there so Claude Code would play a sound when a turn ended. That entry is removed the first time you start this version, and any sound hook you wrote yourself is put back exactly where you had it. Nothing else in that file is touched. The deck makes the sound itself now — which is also why you finally hear one when a Codex turn ends, not just a Claude one."}],"3.16.0":[{title:"🤝 Pair two decks with one piece of text",body:`**Accounts ▸ Local network ▸ setup… ▸ make an invite.** Send the text however you already talk to them; they paste it and the two decks are paired. Nobody presses accept, and neither of you has to know which of your addresses the other can reach — the invite carries them all and their deck tries each one.
290
-
291
- Decks on the same router still find each other on their own and appear under **on this network right now**. An invite is for the case that does not work: another subnet, a VPN, a firewall.
292
-
293
- The invite lasts 10 minutes and is used once. Anyone who gets hold of the text can pair with your deck until it runs out, so send it the way you would send anything else you would not want forwarded.`},{title:"⚠️ Both machines have to be on this version",body:`The two decks no longer speak the old protocol, and there is no fallback: a 3.15 deck and a 3.16 deck cannot see each other at all. Update both.
294
-
295
- The group passphrase is gone. If you had one set, that pairing is not carried over — make an invite and pair again. It was replaced because a passphrase that differs by one character produced a closed socket and no other symptom on either machine, and a secret is the one thing a panel must never print, so neither person could check theirs against the other's.`}],"3.22.1":[{title:"🖥️ A first run now opens This machine too",body:`Accounts and usage already opened themselves the first time you ran the deck; the machine panel did not, and now does. It is the panel that answers "is this box coping" — cores, memory, load, temperature — and somebody meeting the deck for the first time cannot ask for a panel they do not know is there.
296
-
297
- It only does this when you have never said otherwise. Close it once and it stays closed, on that browser, for good — the same rule the other two panels have always followed. Nothing reopens it behind you.
298
-
299
- While it is open it polls this machine once every few seconds, and it stops the moment you close it or switch tabs.`}],"3.22.4":[{title:"📈 A card stops looking idle while it is thinking",body:`The activity chart on each card counted tool calls and nothing else, so the time an agent spends reading, reasoning and writing drew as a flat line — measured on this machine, 16.5% of all working time, more than the time spent inside the tools themselves. A session that was busy looked exactly like one that had died, and the only way to tell them apart was to wait and see whether anything ever appeared.
300
-
301
- It marks that work now. A chart with bars in it means the agent is doing something, whether or not it has called a tool in the last minute; a flat chart means it genuinely is not. Hover it for the split — how many tool calls and how many blocks of thinking and writing landed in the last 60 seconds.
302
-
303
- Nothing was added to the card and nothing new is polled. The deck already reads each session's transcript for its token counts; this reads the same file for what the model has finished writing, and a session that is quiet costs one file check per second and a half.`}]},N0="agent-dag.releaseNotesSeen";function RM(e){return e.split(/[.\-+]/).map(t=>parseInt(t,10)).map(t=>Number.isNaN(t)?0:t)}function Ci(e,t){const n=RM(e),r=RM(t);for(let s=0;s<Math.max(n.length,r.length);s++){const o=(n[s]??0)-(r[s]??0);if(o!==0)return o<0?-1:1}return 0}function Ti(e){return typeof e=="string"&&/^\d+\.\d+\.\d+/.test(e)}function Aie(e){if(!e||typeof e!="object")return!1;const{title:t,body:n}=e;return typeof t=="string"&&t.trim()!==""&&typeof n=="string"&&n.trim()!==""}function Rie(e){if(!e||typeof e!="object")return[];const t=[];for(const[n,r]of Object.entries(e)){if(!Ti(n)||!Array.isArray(r))continue;const s=r.filter(Aie);s.length&&t.push({version:n,notes:s})}return t.sort((n,r)=>Ci(r.version,n.version))}const MM=Rie(Tie);function ZP(e,t,n){return e.filter(r=>Ci(r.version,n)<=0&&(t===null||Ci(r.version,t)>0))}function Mie(e,t){return e.filter(n=>Ci(n.version,t)===0)}function $ie(e){if(!e.length)return"";const t=e[0].version,n=e[e.length-1].version;return t===n?`v${t}`:`v${n} – v${t}`}function Iie({since:e,running:t,entries:n,firstRun:r}){if(!n.length)return"Nothing in this build has anything to report yet. Most releases do not, which is the point.";if(e!==null){const l=n.length===1?"one release":`${n.length} releases`;return`You were last caught up at v${e}. Since then ${l} changed something you would notice. Clicking the version in the topbar brings this back.`}if(r&&Ti(t))return`The deck has not run in this browser before, so this is what v${t} — the release you have — changed. Earlier releases are not repeated here; clicking the version in the topbar brings all of them back.`;const s=n[0].version;if(!Ti(t))return"Everything this build has to say, newest first. Most releases have nothing here, which is why the deck stays quiet about them.";const o=Ci(s,t);return o<0?`v${t} — the release you are running — changed nothing you would notice, which most releases do not. Below is the last release that did, and everything before it, newest first.`:o>0?"Everything this build has to say, newest first. Most releases have nothing here, which is why the deck stays quiet about them.":`You are running v${t}, and this is what it changed — and everything before it, newest first. Most releases have nothing here, which is why the deck stays quiet about them.`}const Oie=new RegExp("^(?:\\p{Extended_Pictographic}|\\p{Emoji_Modifier}|\\p{Regional_Indicator}|[\\u200D\\uFE0F])+(?= \\S)","u");function Lie(e){const t=Oie.exec(e);return t?{icon:t[0],rest:e.slice(t[0].length)}:{icon:null,rest:e}}function Pie(e){if(!e)return null;let t=null;try{t=e.getItem(N0)}catch{return null}return Ti(t)?t:null}function Die(e){if(!e)return!1;try{return e.getItem(N0),!0}catch{return!1}}function Fie(e,t){if(!e)return!1;try{return e.setItem(N0,t),!0}catch{return!1}}const JP="agent-dag.tourSeen";function Bie(e){if(!e)return!1;try{return e.getItem(JP)==="1"}catch{return!1}}function qie(e){if(!e)return!1;try{return e.setItem(JP,"1"),!0}catch{return!1}}function Uie({tourSeen:e,decision:t}){if(t.reason==="no-version"||t.reason==="cannot-remember")return{tour:!1,notes:"none"};if(t.reason==="welcome"||t.reason==="first-run")return{tour:!e,notes:"none"};const n=t.show.length>0;return e?{tour:!1,notes:n?"now":"none"}:{tour:!0,notes:n?"after":"none"}}function zie({stored:e,running:t,notes:n,remembers:r=!0}){if(!Ti(t))return{show:[],record:null,reason:"no-version"};if(!Ti(e)){if(!r)return{show:[],record:t,reason:"cannot-remember"};const l=Mie(n,t);return l.length?{show:l,record:t,reason:"welcome"}:{show:[],record:t,reason:"first-run"}}const s=Ci(e,t);if(s===0)return{show:[],record:null,reason:"seen"};if(s>0)return{show:[],record:null,reason:"ahead"};const o=ZP(n,e,t);return o.length?{show:o,record:t,reason:"new-notes"}:{show:[],record:t,reason:"nothing-new"}}function Wie(e,t){if(/\s|^$/.test(e[t+2]??""))return-1;let n=t+2;for(;n<e.length;){if(e[n]==="`"){const r=e.indexOf("`",n+1);if(r<0)break;n=r+1;continue}if(e.startsWith("**",n)&&!/\s/.test(e[n-1]??" "))return n;n++}return-1}function QP(e,t=!0){const n=[];let r="";const s=()=>{r&&(n.push({kind:"text",text:r}),r="")};let o=0;for(;o<e.length;){if(e[o]==="`"){const l=e.indexOf("`",o+1);if(l>o+1){s(),n.push({kind:"code",text:e.slice(o+1,l)}),o=l+1;continue}}else if(t&&e.startsWith("**",o)){const l=Wie(e,o);if(l>0){s(),n.push({kind:"bold",kids:QP(e.slice(o+2,l),!1)}),o=l+2;continue}}r+=e[o],o+=1}return s(),n}function Hie({entries:e,since:t,running:n,firstRun:r,onClose:s,onTour:o,updateVersion:l,updateBusy:c,onUpdateRestart:d,updateFailure:h,onRestart:f}){const p=ot(s),g=mt(s),v=$ie(e);return a.jsx("div",{className:"modal-backdrop",...g,role:"presentation",children:a.jsxs("div",{ref:p,className:"modal release-notes",onClick:j=>j.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"release-notes-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsxs("div",{className:"modal-title",children:[a.jsx("span",{id:"release-notes-title",className:"modal-tool-name",children:"What's new"}),v&&a.jsx("span",{className:"modal-tool-id",children:v})]}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:s,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[(l||h)&&a.jsxs("div",{className:"rn-update",children:[l&&d&&a.jsxs("div",{className:"guide-door",children:[a.jsxs("span",{children:["ccdeck v",l," is downloaded and verified."]}),a.jsx("button",{type:"button",className:"btn",onClick:d,"aria-busy":c||void 0,children:c?"Restarting…":Yd})]}),a.jsx("p",{className:"rn-update-said",role:"status",children:h})]}),a.jsx("p",{className:"modal-note",children:Iie({since:t,running:n,firstRun:r,entries:e})}),o&&!l&&a.jsxs("div",{className:"guide-door",children:[a.jsx("span",{children:"Eight pictures of what the deck shows."}),a.jsx("button",{type:"button",className:"btn",onClick:o,children:"Take the tour"})]}),f&&a.jsxs("div",{className:"guide-door",children:[a.jsx("span",{children:"Restart the deck. Sessions, settings and pairings come back as they were."}),a.jsx("button",{type:"button",className:"btn",onClick:f,children:"Restart"})]}),e.map(j=>a.jsxs("section",{className:"modal-section",children:[a.jsxs("h3",{className:"rn-version",children:["v",j.version]}),a.jsx("ul",{className:"rn-notes",children:j.notes.map((k,x)=>{const{icon:N,rest:b}=Lie(k.title);return a.jsxs("li",{className:"rn-note",children:[a.jsxs("p",{className:"rn-note-title",children:[N&&a.jsx("span",{className:"rn-note-icon",children:N}),b]}),a.jsx("p",{className:"rn-note-body",children:e3(QP(k.body))})]},x)})})]},j.version))]})]})})}function e3(e){return e.map((t,n)=>t.kind==="text"?t.text:t.kind==="code"?a.jsx("code",{className:"rn-code",children:t.text},n):a.jsx("strong",{className:"rn-strong",children:e3(t.kids)},n))}function Vie({state:e,sessionId:t,onClose:n}){const r=y.useMemo(()=>Gie(e,t),[e,e.revision,t]),s=y.useRef(null),o=ot(n,{focusRef:s}),l=mt(n);return r?a.jsx("div",{className:"modal-backdrop",...l,role:"presentation",children:a.jsxs("div",{ref:o,className:"modal session-summary",onClick:c=>c.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ss-title",children:[a.jsxs("div",{className:"modal-head",children:[a.jsxs("div",{className:"modal-title",children:[a.jsx("span",{className:"state-pill state-done","aria-hidden":!0,children:"done"}),a.jsx("span",{id:"ss-title",className:"modal-tool-name",title:r.cwd??r.sessionId,children:r.label}),a.jsxs("span",{className:"modal-tool-id",children:["· ",r.sessionId.slice(0,8)]})]}),a.jsxs("div",{className:"modal-actions",children:[a.jsx("span",{className:"modal-dur",title:"Total wall time",children:r.durationLabel}),a.jsx("button",{type:"button",ref:s,className:"glyph-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),a.jsxs("div",{className:"modal-body",children:[a.jsxs("section",{className:"ss-hero",children:[a.jsxs("div",{className:"ss-hero-left",children:[a.jsx("div",{className:"ss-cost-label",children:LI}),a.jsx("div",{className:"ss-cost",children:We(r.cost.total)}),r.modelChips.length>0&&a.jsx("div",{className:"ss-models",children:r.modelChips.map(c=>a.jsx("span",{className:"model-chip","data-family":ch(c),title:c,children:ks(c)},c))})]}),a.jsx("div",{className:"ss-hero-right",children:r.cost.total>0&&a.jsxs(a.Fragment,{children:[a.jsx(Tk,{cost:r.cost,size:"lg"}),a.jsxs("div",{className:"ss-cost-legend",children:[a.jsxs("span",{className:"ssl ssl-in",children:["input ",a.jsx("b",{children:We(r.cost.input)})]}),a.jsxs("span",{className:"ssl ssl-out",children:["output ",a.jsx("b",{children:We(r.cost.output)})]}),a.jsxs("span",{className:"ssl ssl-cr",children:["cache r ",a.jsx("b",{children:We(r.cost.cacheRead)})]}),a.jsxs("span",{className:"ssl ssl-cw",children:["cache w ",a.jsx("b",{children:We(r.cost.cacheWrite)})]})]})]})})]}),a.jsxs("section",{className:"ss-stats",children:[a.jsx(ti,{label:"agents",value:r.agentCount}),a.jsx(ti,{label:"subagents",value:r.subagentCount}),a.jsx(ti,{label:"tool calls",value:r.toolCount}),a.jsx(ti,{label:"prompts",value:r.promptCount}),a.jsx(ti,{label:"tokens",value:r.tokensSum.toLocaleString()}),r.errCount>0&&a.jsx(ti,{label:"errors",value:r.errCount,tone:"err"})]}),r.topTools.length>0&&a.jsxs("section",{className:"modal-section",children:[a.jsx("h4",{children:"Most-used tools"}),a.jsx("div",{className:"ss-top-tools",children:r.topTools.map(([c,d])=>a.jsxs("div",{className:"ss-tt",children:[a.jsx("span",{className:"ss-tt-name",children:c}),a.jsx("span",{className:"ss-tt-bar",children:a.jsx("span",{className:"ss-tt-bar-fill",style:{width:`${d/r.topTools[0][1]*100}%`}})}),a.jsx("span",{className:"ss-tt-count",children:d})]},c))})]}),r.firstPrompt&&a.jsxs("section",{className:"modal-section",children:[a.jsx("h4",{children:"Opening prompt"}),a.jsx("div",{className:"ss-prompt",children:r.firstPrompt})]})]})]})}):null}function ti({label:e,value:t,tone:n}){return a.jsxs("div",{className:`ss-stat${n?` tone-${n}`:""}`,children:[a.jsx("div",{className:"ss-stat-value",children:t}),a.jsx("div",{className:"ss-stat-label",children:e})]})}function Gie(e,t){const n=e.agents.get(t);if(!n)return null;const r=[];for(const S of e.agents.values())S.sessionId===t&&r.push(S);if(r.length===0)return null;const s={input:0,output:0,cacheRead:0,cacheWrite:0,total:0},o=new Set,l=new Map;let c=0,d=0,h=0,f=0,p=0,g,v=1/0,j=0;for(const S of r){const E=gn(S);s.input+=E.input,s.output+=E.output,s.cacheRead+=E.cacheRead,s.cacheWrite+=E.cacheWrite,s.total+=E.total;for(const I of tI(S))o.add(I);S.model&&o.add(S.model),S.kind==="subagent"&&p++;const R=q$(S.prompts);d+=R.length,!g&&R.length>0&&(g=R[0].text),h+=S.usage.inputTokens+S.usage.outputTokens,c+=S.toolCount,f+=S.toolErrorCount??0;for(const[I,A]of S.toolCountByName??[])l.set(I,(l.get(I)??0)+A);v=Math.min(v,S.startedAt),j=Math.max(j,S.endedAt??Date.now())}const k=Math.max(0,j-v),x=Math.floor(k/1e3),N=x<60?`${x}s`:x<3600?`${Math.floor(x/60)}m ${String(x%60).padStart(2,"0")}s`:`${Math.floor(x/3600)}h ${Math.floor(x%3600/60)}m`,b=Array.from(l.entries()).sort((S,E)=>E[1]-S[1]).slice(0,5);return{sessionId:t,label:n.label||n.cwdBasename||"session",cwd:n.cwd,durationLabel:N,cost:s,modelChips:Array.from(o),agentCount:r.length,subagentCount:p,toolCount:c,promptCount:d,tokensSum:h,errCount:f,topTools:b,firstPrompt:g}}const t3="agent-dag.character-enabled",n3="agent-dag.fm-volume",$M="agent-dag.fm-source",Kie=[{value:"claude-fm",label:"🎧 Claude FM"},{group:"📻 Lofi Girl",value:"lofi-relax",label:"📚 Relax / study"},{group:"📻 Lofi Girl",value:"lofi-game",label:"🎮 Chill / game"},{group:"📻 Lofi Girl",value:"lofi-vibe",label:"🌅 Vibe / chill"},{group:"📻 Lofi Girl",value:"lofi-sleep",label:"💤 Sleep / chill"},{group:"📻 Radio Mix",value:"radio-mix",label:"📡 Live radio mix"},{group:"📻 Best of Nostalgia",value:"best-of-nostalgia",label:"📼 Best of nostalgia live"},{group:"📻 The Good Life Radio",value:"good-life-radio",label:"🌴 The Good Life Radio"},{group:"☕ Cafe Music BGM",value:"cafe-music-bgm",label:"☕ Cafe music BGM"}];function Yie(e){return e==="lofi-relax"||e==="lofi-game"||e==="lofi-vibe"||e==="lofi-sleep"||e==="radio-mix"||e==="best-of-nostalgia"||e==="good-life-radio"||e==="cafe-music-bgm"?e:"claude-fm"}function Xie(e){return e!=="0"}function Zie(){return Xie(Je(t3))}function Jie(e){return iL(e)}function Qie(){return Jie(Je(n3))}const IM=Kie,ni="Give the station a name.",ele="Use an https YouTube live or channel link, or a .mp3, .aac, .ogg or .m3u8 stream.";function tle({characterEnabled:e,onToggleCharacter:t,fmVolume:n,onFmVolume:r,fmMuted:s,onFmMuted:o,fmSource:l,onFmSource:c,customFmStations:d,unavailableFmStations:h,onAddFmStation:f,onRenameFmStation:p,onRemoveFmStation:g}){var me;const v=[...IM.map(ne=>({...ne,label:h.has(ne.value)?`${ne.label} · not live`:ne.label,unavailable:h.has(ne.value)})),...d.map(ne=>({group:"🎵 Your stations",value:to(ne.id),label:h.has(ne.id)?`${ne.name} · unavailable`:ne.name,unavailable:h.has(ne.id)}))],j=v.some(ne=>ne.value===l&&ne.unavailable),k=[];v.forEach((ne,oe)=>{const Ne=k[k.length-1];Ne&&Ne.group===ne.group?Ne.indexes.push(oe):k.push({group:ne.group,indexes:[oe]})});const[x,N]=y.useState(!1),[b,S]=y.useState(()=>Math.max(0,v.findIndex(ne=>ne.value===l))),[E,R]=y.useState(!1),[I,A]=y.useState(""),[q,$]=y.useState(""),[B,L]=y.useState(""),[M,F]=y.useState(!1),[T,P]=y.useState(""),[O,G]=y.useState(""),[K,U]=y.useState(null),H=y.useRef(0),D=y.useRef(null),V=y.useRef(null),J=y.useRef(null),W=y.useRef(null),Z=y.useRef(null),Y=wi(l),X=Y?d.find(ne=>ne.id===Y):void 0;y.useEffect(()=>{const ne=v.findIndex(oe=>oe.value===l);S(ne<0?0:ne)},[l,d,h]),y.useEffect(()=>{F(!1),P((X==null?void 0:X.name)??"")},[X==null?void 0:X.id,X==null?void 0:X.name]),y.useEffect(()=>{var ne;x&&((ne=document.getElementById(`appearance-fm-option-${b}`))==null||ne.scrollIntoView({block:"nearest"}))},[b,x]),y.useEffect(()=>{if(!x)return;const ne=oe=>{var we,Me;const Ne=oe.target;!((we=D.current)!=null&&we.contains(Ne))&&!((Me=Z.current)!=null&&Me.contains(Ne))&&N(!1)};return document.addEventListener("pointerdown",ne),()=>document.removeEventListener("pointerdown",ne)},[x]);const ee=ne=>{const oe=ne.relatedTarget;oe&&!ne.currentTarget.contains(oe)&&N(!1)},ae=ne=>{var Ne;const oe=v[ne];oe&&(S(ne),c(oe.value),N(!1),(Ne=D.current)==null||Ne.focus())},ce=ne=>{if(oI(ne.key)){if(!x)return;ne.preventDefault(),ne.stopPropagation(),N(!1);return}if(ne.key==="Tab"){N(!1);return}if(ne.key==="Enter"||ne.key===" "){ne.preventDefault(),x?ae(b):N(!0);return}ne.key!=="ArrowDown"&&ne.key!=="ArrowUp"&&ne.key!=="Home"&&ne.key!=="End"||(ne.preventDefault(),N(!0),S(oe=>ne.key==="Home"?0:ne.key==="End"?v.length-1:Math.min(v.length-1,Math.max(0,oe+(ne.key==="ArrowDown"?1:-1)))))},ge=()=>{var ne;return(ne=D.current)==null?void 0:ne.focus()};y.useEffect(()=>{if(!K)return;const ne=window.setTimeout(()=>U(null),4e3);return()=>window.clearTimeout(ne)},[K]);const ye=()=>{if(!X)return;const ne=Date.now(),oe=so({armedFor:K,target:X.id,armedAt:H.current,now:ne,gapMs:ro});if(oe==="arm"){U(X.id),H.current=ne;return}oe!=="ignore"&&(U(null),g(X.id),ge())},se=X!==void 0&&K===X.id,pe=ne=>{var Ne,we;if(ne.preventDefault(),!I.trim()){L(ni),(Ne=V.current)==null||Ne.focus();return}const oe=lq(I,q);if(!oe){L(ele),(we=J.current)==null||we.focus();return}f(oe),c(to(oe.id)),A(""),$(""),L(""),R(!1),ge()},fe=ne=>{var oe;if(ne.preventDefault(),!!Y){if(!T.trim()){G(ni),(oe=W.current)==null||oe.focus();return}p(Y,T),F(!1),ge()}},de=ne=>{const oe=v[ne],Ne="unavailable"in oe&&oe.unavailable;return a.jsxs("div",{className:"appearance-source-option",role:"option",id:`appearance-fm-option-${ne}`,"aria-selected":l===oe.value,"data-highlighted":b===ne||void 0,"data-unavailable":Ne||void 0,onMouseEnter:()=>S(ne),onClick:()=>ae(ne),children:[a.jsx("span",{children:oe.label}),l===oe.value&&a.jsx("span",{"aria-hidden":!0,children:"✓"})]},oe.value)};return a.jsxs(a.Fragment,{children:[a.jsxs("section",{className:"settings-group","aria-labelledby":"appearance-fm-caption",children:[a.jsx("div",{className:"settings-caption",children:a.jsxs("div",{children:[a.jsx("h3",{id:"appearance-fm-caption",children:"Claude FM"}),a.jsx("p",{className:"settings-caption-note",children:"Music for the character to play while you work."})]})}),a.jsxs("div",{className:"appearance-controls",children:[a.jsxs("div",{className:"appearance-source-row",children:[a.jsx("label",{htmlFor:"appearance-fm-source",children:"Station"}),a.jsxs("div",{className:`appearance-source-picker${x?" is-open":""}`,onBlur:ee,children:[a.jsxs("button",{ref:D,type:"button",id:"appearance-fm-source",className:"appearance-source-trigger",role:"combobox","aria-haspopup":"listbox","aria-expanded":x,"aria-controls":x?"appearance-fm-source-list":void 0,"aria-activedescendant":x?`appearance-fm-option-${b}`:void 0,"aria-describedby":"appearance-fm-source-note",onClick:()=>N(ne=>!ne),onKeyDown:ce,children:[a.jsx("span",{children:((me=v.find(ne=>ne.value===l))==null?void 0:me.label)??IM[0].label}),a.jsx("svg",{viewBox:"0 0 12 12","aria-hidden":!0,focusable:"false",children:a.jsx("path",{d:"m2.5 4.5 3.5 3 3.5-3"})})]}),x&&a.jsx("div",{ref:Z,id:"appearance-fm-source-list",className:"appearance-source-list",role:"listbox","aria-label":"Music stations",children:k.map((ne,oe)=>ne.group?a.jsxs("div",{role:"group","aria-labelledby":`appearance-fm-group-${oe}`,children:[a.jsx("div",{id:`appearance-fm-group-${oe}`,className:"appearance-source-group",role:"presentation",children:ne.group}),ne.indexes.map(de)]},`group-${oe}`):ne.indexes.map(de))})]})]}),a.jsx("span",{id:"appearance-fm-source-note",className:"vis-hidden",children:"Changing station starts live playback automatically."}),a.jsx("p",{className:"appearance-fm-status",role:"status",children:j?nq(wi(l)!==null):""}),a.jsxs("div",{className:"appearance-station-manage",children:[a.jsx("button",{type:"button",className:"btn appearance-station-action","aria-expanded":E,onClick:()=>{R(ne=>!ne),L("")},children:E?"Cancel":"+ Add station"}),X&&!M&&a.jsxs("span",{className:"appearance-station-edit",children:[a.jsx("button",{type:"button",className:"btn appearance-station-action",onClick:()=>{P(X.name),G(""),F(!0)},children:"Rename"}),a.jsx("button",{type:"button",className:`btn danger appearance-station-action${se?" armed":""}`,onClick:ye,"aria-label":se?`Confirm removing ${X.name}`:`Remove ${X.name}`,title:se?"Press again to remove this station. It cannot be brought back.":"Remove this station",children:se?"Confirm":"Remove"})]})]}),E&&a.jsxs("form",{className:"appearance-station-form",onSubmit:pe,noValidate:!0,children:[a.jsxs("label",{className:"appearance-station-field",children:[a.jsx("span",{children:"Station name"}),a.jsx("input",{ref:V,className:"ap-manage-input",value:I,onChange:ne=>A(ne.target.value),"aria-invalid":B===ni||void 0,"aria-describedby":B===ni?"appearance-station-error":void 0,maxLength:Ql,autoFocus:!0})]}),a.jsxs("label",{className:"appearance-station-field",children:[a.jsx("span",{children:"Link"}),a.jsx("input",{ref:J,className:"ap-manage-input",value:q,onChange:ne=>$(ne.target.value),placeholder:"https://…","aria-invalid":B!==""&&B!==ni||void 0,"aria-describedby":B&&B!==ni?"appearance-station-error":void 0,inputMode:"url",autoComplete:"off",spellCheck:!1,maxLength:x$})]}),a.jsx("button",{type:"submit",className:"btn primary",children:"Add"}),B&&a.jsx("p",{id:"appearance-station-error",className:"appearance-station-error",role:"alert",children:B})]}),X&&M&&a.jsxs("form",{className:"appearance-station-form is-rename",onSubmit:fe,noValidate:!0,children:[a.jsxs("label",{className:"appearance-station-field",children:[a.jsx("span",{children:"Station name"}),a.jsx("input",{ref:W,className:"ap-manage-input",value:T,onChange:ne=>P(ne.target.value),"aria-invalid":O!==""||void 0,"aria-describedby":O?"appearance-rename-error":void 0,maxLength:Ql,autoFocus:!0})]}),a.jsx("button",{type:"submit",className:"btn primary",children:"Save"}),a.jsx("button",{type:"button",className:"btn",onClick:()=>{F(!1),ge()},children:"Cancel"}),O&&a.jsx("p",{id:"appearance-rename-error",className:"appearance-station-error",role:"alert",children:O})]}),a.jsx(k0,{id:"appearance-fm-volume",value:n,"aria-describedby":"appearance-fm-volume-note",onLevel:r}),a.jsxs("label",{className:"appearance-row",children:[a.jsx("span",{className:"appearance-row-label",id:"appearance-fm-mute-label",children:"Mute music"}),a.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":s,"aria-labelledby":"appearance-fm-mute-label",onClick:o,children:a.jsx("span",{className:"switch-knob"})})]})]}),a.jsx("span",{id:"appearance-fm-volume-note",className:"vis-hidden",children:"Controls live music volume."})]}),a.jsxs("section",{className:"settings-group","aria-labelledby":"appearance-character-caption",children:[a.jsx("div",{className:"settings-caption",children:a.jsx("h3",{id:"appearance-character-caption",children:"Character"})}),a.jsx("div",{className:"appearance-controls",children:a.jsxs("label",{className:"appearance-row",children:[a.jsx("span",{className:"appearance-row-label",id:"appearance-character-label",children:"Show character on minimap"}),a.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":e,"aria-labelledby":"appearance-character-label","aria-describedby":"appearance-character-note",onClick:t,children:a.jsx("span",{className:"switch-knob"})}),a.jsx("span",{id:"appearance-character-note",className:"appearance-row-note",children:"Claude FM plays through the character, so hiding it also stops the music."})]})})]})]})}const nle="With no deck tab open, get a notification wherever a sound would have played.",rle="With the ccdeck window closed, get a notification wherever a sound would have played.";function sle(e){return e?rle:nle}const ale="Held off for this run — the deck was started with alerts disabled. Your choice is saved for the next start.",ole=[{kind:"notifySwap",label:"Account auto-switched",title:"When auto-switch moves Claude Code to another account"},{kind:"notifyQuota",label:"Quota at 90% and 100%",title:"When a quota window of the account you're on reaches 90%, and again at 100%"},{kind:"notifyReset",label:"Quota reset",title:"When a quota window that reached 90% is available again"}],ile="For the Claude and Codex accounts you're on, whether or not the deck is open.",lle="Held off for this run too.",OM="Get notified when you're away from this tab.";function cle(e){switch(e){case"granted":return{status:"Enabled",ask:!1,ok:!0,note:OM};case"default":return{status:null,ask:!0,ok:!1,note:OM};case"denied":return{status:"Blocked",ask:!1,ok:!1,note:"Your browser is blocking them; only its own site settings can undo that. You'll still be told once this tab is closed."};default:return{status:"Unavailable",ask:!1,ok:!1,note:"This browser cannot show them. You'll still be told once this tab is closed."}}}function fc(e=typeof navigator>"u"?"":navigator.userAgent){return/\bccdeck-desktop\/\d/.test(e)}function ule({notifyOn:e,onToggleNotify:t,notifyVetoed:n,notifyPermission:r,onAskNotify:s,accountNotify:o,onToggleAccountNotify:l}){const c=cle(r),d=fc(),h=e&&!n&&!d,f=y.useRef(null),p=ps(!c.ask,f);return a.jsxs("div",{className:"sm-switches",children:[a.jsxs("div",{className:"sm-setting",children:[a.jsxs("label",{className:"sm-switch",children:[a.jsx("span",{className:"sm-switch-label",id:"sm-notify-label",children:"Notifications while closed"}),a.jsx("button",{ref:f,type:"button",role:"switch","aria-checked":e,"aria-labelledby":"sm-notify-label",className:"switch",onClick:t,title:"With no deck tab open, a notification wherever a sound would play",children:a.jsx("span",{className:"switch-knob"})})]}),a.jsx("p",{className:"sm-note",children:n?ale:sle(d)})]}),h&&a.jsxs("section",{className:"sm-channel","aria-labelledby":"sm-channel-name",children:[a.jsxs("div",{className:"sm-channel-head",children:[a.jsx("h3",{className:"sm-channel-name",id:"sm-channel-name",children:"Browser notifications"}),c.ask?a.jsx("button",{type:"button",className:"btn sm-channel-action",onClick:()=>{p(),s()},children:"Enable"}):a.jsxs("span",{className:"sm-channel-state","data-ok":c.ok||void 0,children:[c.ok&&a.jsx("svg",{width:"9",height:"9",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:a.jsx("path",{d:"M1.5 5.2 3.9 7.6 8.5 2.4"})}),c.status]})]}),a.jsx("p",{className:"sm-note",children:c.note})]}),a.jsxs("div",{className:"sm-account-switches",children:[a.jsx("p",{className:"sm-note",children:n?lle:ile}),ole.map(({kind:g,label:v,title:j})=>a.jsxs("label",{className:"sm-switch",children:[a.jsx("span",{className:"sm-switch-label",id:`sm-${g}-label`,children:v}),a.jsx("button",{type:"button",role:"switch","aria-checked":o[g],"aria-labelledby":`sm-${g}-label`,className:"switch",onClick:()=>l(g),title:j,children:a.jsx("span",{className:"switch-knob"})})]},g))]})]})}function dle({section:e}){return e==="sounds"?a.jsx(RP,{on:!0}):a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[e==="general"&&a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M1.5 3h4.3M9.2 3h3.3M1.5 7h1.3M6.2 7h6.3M1.5 11h6.3M11.2 11h1.3"}),a.jsx("circle",{cx:"7.5",cy:"3",r:"1.7"}),a.jsx("circle",{cx:"4.5",cy:"7",r:"1.7"}),a.jsx("circle",{cx:"9.5",cy:"11",r:"1.7"})]}),e==="notifications"&&a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M3.4 9.1c.6-.8.6-1.8.6-3V4.7a3 3 0 0 1 6 0v1.4c0 1.2 0 2.2.6 3"}),a.jsx("path",{d:"M2.2 9.1h9.6"}),a.jsx("path",{d:"M5.7 11.2a1.3 1.3 0 0 0 2.6 0"})]}),e==="music"&&a.jsx("path",{d:"M2 8.4h2a1 1 0 0 1 1 1v1.4a1 1 0 0 1-1 1H3a1 1 0 0 1-1-1V7.2a5 5 0 0 1 10 0v3.6a1 1 0 0 1-1 1h-1a1 1 0 0 1-1-1V9.4a1 1 0 0 1 1-1h2"})]})}const hle=["audio/webm;codecs=opus","audio/ogg;codecs=opus","audio/mp4"];function fle(e){return hle.find(t=>e(t))}const ple=4400;function mle(e){const t=e.split(";")[0];return{name:`Recorded voice.${t==="audio/mp4"?"m4a":t==="audio/ogg"?"ogg":"webm"}`,type:t}}function gle({full:e,setCustomError:t,runCustom:n,onImportCustom:r}){const[s,o]=y.useState(!1),l=y.useRef(null),c=y.useRef(null),d=y.useRef(!1),h=()=>{var p;c.current!==null&&clearTimeout(c.current),c.current=null,((p=l.current)==null?void 0:p.state)==="recording"&&l.current.stop()},f=async()=>{var g;if(e)return;if(t(""),!((g=navigator.mediaDevices)!=null&&g.getUserMedia)||typeof MediaRecorder>"u"){t("Microphone recording is unavailable in this browser.");return}let p;try{p=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{d.current||t("Microphone access was denied or unavailable.");return}if(d.current||l.current){p.getTracks().forEach(v=>v.stop());return}try{const v=fle(x=>MediaRecorder.isTypeSupported(x)),j=new MediaRecorder(p,v?{mimeType:v}:void 0),k=[];l.current=j,j.ondataavailable=x=>{x.data.size&&k.push(x.data)},j.onerror=()=>t("Recording failed. Please try again."),j.onstop=()=>{p.getTracks().forEach(S=>S.stop()),c.current!==null&&clearTimeout(c.current),c.current=null;const x=l.current===j;if(x&&(l.current=null),o(!1),!x||!k.length)return;const N=mle(j.mimeType),b=new File(k,N.name,{type:N.type});n(()=>r(b))},j.start(200),o(!0),c.current=setTimeout(h,ple)}catch{l.current=null,p.getTracks().forEach(v=>v.stop()),t("This browser cannot record a supported audio format.")}};return y.useEffect(()=>(d.current=!1,()=>{d.current=!0,c.current!==null&&clearTimeout(c.current);const p=l.current;l.current=null,(p==null?void 0:p.state)==="recording"&&p.stop()}),[]),{recording:s,startRecording:f,stopRecording:h}}function yle({full:e,fullProps:t,runCustom:n,onCreateVoice:r}){const[s,o]=y.useState("Custom voice"),[l,c]=y.useState("Your turn"),[d,h]=y.useState(""),[f,p]=y.useState("1"),[g,v]=y.useState("1"),[j,k]=y.useState([]);return y.useEffect(()=>{if(typeof window>"u"||!("speechSynthesis"in window))return;const x=()=>{k(window.speechSynthesis.getVoices())};return x(),window.speechSynthesis.addEventListener("voiceschanged",x),()=>window.speechSynthesis.removeEventListener("voiceschanged",x)},[]),a.jsxs("details",{className:"sm-voice",children:[a.jsxs("summary",{...t,onClick:x=>{const N=x.currentTarget.parentElement;e&&N&&!N.open&&x.preventDefault()},children:[a.jsx("span",{children:"Spoken voice"}),a.jsx("span",{children:"Create from text"})]}),a.jsxs("div",{className:"sm-voice-fields",children:[a.jsxs("label",{children:[a.jsx("span",{children:"Name"}),a.jsx("input",{className:"ap-manage-input",value:s,maxLength:80,onChange:x=>o(x.target.value)})]}),a.jsxs("label",{children:[a.jsx("span",{children:"Text"}),a.jsx("input",{className:"ap-manage-input",value:l,maxLength:180,onChange:x=>c(x.target.value)})]}),a.jsxs("label",{children:[a.jsx("span",{children:"Voice"}),a.jsxs("select",{className:"sm-select",value:d,onChange:x=>h(x.target.value),children:[a.jsx("option",{value:"",children:"System default"}),j.map(x=>a.jsx("option",{value:x.voiceURI,children:x.name},x.voiceURI))]})]}),a.jsxs("div",{className:"sm-voice-pair",children:[a.jsxs("label",{children:[a.jsx("span",{children:"Rate"}),a.jsx("input",{className:"ap-manage-input",type:"number",min:"0.5",max:"2",step:"0.1",value:f,onChange:x=>p(x.target.value)})]}),a.jsxs("label",{children:[a.jsx("span",{children:"Pitch"}),a.jsx("input",{className:"ap-manage-input",type:"number",min:"0.5",max:"2",step:"0.1",value:g,onChange:x=>v(x.target.value)})]})]}),a.jsx("button",{type:"button",className:"btn sm-custom-action",...t,onClick:()=>{e||n(async()=>{await r({name:s,text:l,voiceURI:d,rate:parseFloat(f),pitch:parseFloat(g)}),c("Your turn")})},children:"Add spoken voice"})]})]})}function wle({customAssets:e,onImportCustom:t,onCreateVoice:n,onRenameCustom:r,onPreviewCustom:s,onDeleteCustom:o}){const[l,c]=y.useState(""),d=e.length,h=Eb(d),f=h!==null,p=f?{"aria-disabled":!0,"aria-describedby":"sm-custom-full"}:{},[g,v]=y.useState(null),j=y.useRef(0),k=y.useRef(new Map),x=y.useRef(null),N=y.useRef(null);y.useEffect(()=>{if(!g)return;const A=window.setTimeout(()=>v(null),4e3);return()=>window.clearTimeout(A)},[g]);const b=async A=>{c("");try{await A()}catch(q){c(q instanceof Error?q.message:"Custom audio could not be saved.")}},S=(A,q)=>{const $=Date.now(),B=so({armedFor:g,target:A,armedAt:j.current,now:$,gapMs:ro});if(B==="arm"){v(A),j.current=$;return}if(B==="ignore")return;v(null);const L=mJ(e.map(M=>M.id),A);b(async()=>{var F;await o(A);const M=document.activeElement;M!==q&&!An((M==null?void 0:M.tagName)??null)||(F=L?k.current.get(L):x.current)==null||F.focus()})},{recording:E,startRecording:R,stopRecording:I}=gle({full:f,setCustomError:c,runCustom:b,onImportCustom:t});return a.jsxs("section",{className:"sm-custom","aria-labelledby":"sm-custom-title",children:[a.jsxs("div",{className:"sm-custom-head",children:[a.jsx("h3",{className:"sm-tone-name",id:"sm-custom-title",children:"Custom sounds"}),a.jsxs("span",{children:[d," of ",_b,", kept on this machine"]})]}),f&&a.jsx("p",{className:"sm-note",id:"sm-custom-full",children:h}),a.jsxs("div",{className:"sm-custom-actions",children:[a.jsxs("div",{className:"sm-custom-card",children:[a.jsxs("span",{className:"sm-custom-card-copy",children:[a.jsx("strong",{children:"Import audio"}),a.jsx("span",{children:"WAV, MP3 or OGG"})]}),a.jsx("button",{ref:x,type:"button",className:"btn sm-custom-action",...p,onClick:()=>{var A;f||(A=N.current)==null||A.click()},children:"Choose file"}),a.jsx("input",{ref:N,type:"file",hidden:!0,accept:"audio/wav,audio/x-wav,audio/mpeg,audio/mp3,audio/ogg,.wav,.mp3,.ogg",onChange:A=>{var $;const q=($=A.target.files)==null?void 0:$[0];A.currentTarget.value="",q&&!f&&b(()=>t(q))}})]}),a.jsxs("div",{className:"sm-custom-card",children:[a.jsxs("span",{className:"sm-custom-card-copy",children:[a.jsx("strong",{children:"Record a clip"}),a.jsx("span",{children:E?"Recording…":"Up to 5 seconds"})]}),E?a.jsx("button",{type:"button",className:"btn sm-custom-action",onClick:I,children:"Stop & save"}):a.jsx("button",{type:"button",className:"btn sm-custom-action",...p,onClick:()=>void R(),children:"Record"})]})]}),a.jsx(yle,{full:f,fullProps:p,runCustom:b,onCreateVoice:n}),e.length>0&&a.jsx("div",{className:"sm-custom-list",children:e.map(A=>a.jsxs("div",{className:"sm-custom-item",children:[a.jsx("input",{className:"ap-manage-input","aria-label":`Rename ${A.name}`,defaultValue:A.name,maxLength:80,onBlur:q=>{if(!q.target.value.trim()){q.target.value=A.name;return}b(()=>r(A.id,q.target.value))},onKeyDown:q=>{q.key==="Enter"&&q.currentTarget.blur()}}),a.jsx("span",{children:A.kind==="audio"?`${A.duration.toFixed(1)}s`:"Voice"}),a.jsx("button",{type:"button",className:"btn sm-custom-icon","aria-label":`Play ${A.name}`,onClick:()=>s(A.id),children:"Play"}),a.jsx("button",{type:"button",ref:q=>{q?k.current.set(A.id,q):k.current.delete(A.id)},className:`btn sm-custom-icon${g===A.id?" armed":""}`,onKeyDown:q=>{q.repeat&&q.preventDefault()},onClick:q=>S(A.id,q.currentTarget),"aria-label":g===A.id?`Confirm deleting ${A.name}`:`Delete ${A.name}`,title:g===A.id?"Press again to delete this sound. It cannot be brought back.":"Delete this sound",children:g===A.id?"Confirm":"Delete"})]},A.id))}),l&&a.jsx("p",{className:"sm-custom-error",role:"alert",children:l})]})}const vle="Claude Code isn't on this machine, so only Turn finished plays here — for Codex turns.";function xle({soundOn:e,onToggleSound:t,prefs:n,claudeHere:r,onLevel:s,onFigure:o,onPreview:l,customAssets:c,customSelections:d,onBuiltInSelected:h,onCustomSelected:f,onImportCustom:p,onCreateVoice:g,onRenameCustom:v,onPreviewCustom:j,onDeleteCustom:k}){var S;const x=fJ(d),N=((S=c.find(E=>E.id===x))==null?void 0:S.name)??"the same custom sound",b=x?`Both tones use “${N}”. They may be harder to tell apart.`:"";return a.jsxs("div",{className:"sm-sounds",children:[a.jsx(AP,{soundOn:e,onToggleSound:t}),!r&&a.jsx("p",{className:"sm-note",children:vle}),!e&&a.jsx("span",{id:"sm-preview-note",className:"vis-hidden",children:"Plays even when Sounds is off, so you can set a tone before turning sounds back on."}),a.jsx("div",{className:"sm-tones",children:zl.map(E=>a.jsx(Mse,{chime:E,tone:n[E],soundOn:e,customAssets:c,customSelections:d,onLevel:s,onFigure:o,onPreview:l,onBuiltInSelected:h,onCustomSelected:f},E))}),b&&a.jsx("p",{className:"sm-note","aria-hidden":!0,children:b}),a.jsx("p",{className:"vis-hidden",role:"status",children:b}),a.jsx(wle,{customAssets:c,onImportCustom:p,onCreateVoice:g,onRenameCustom:v,onPreviewCustom:j,onDeleteCustom:k})]})}const El=["light","dark"],ble={light:"Light",dark:"Dark"};function kle({theme:e}){return a.jsx("span",{className:"appearance-preview","data-swatch":e,children:a.jsxs("svg",{viewBox:"0 0 112 56","aria-hidden":!0,focusable:"false",children:[a.jsx("rect",{className:"tp-canvas",width:"112",height:"56"}),a.jsx("rect",{className:"tp-surface",width:"112",height:"7"}),a.jsx("rect",{className:"tp-rule",y:"7",width:"112",height:"1"}),a.jsx("rect",{className:"tp-surface",y:"8",width:"25",height:"48"}),a.jsx("rect",{className:"tp-rule",x:"25",y:"8",width:"1",height:"48"}),a.jsx("rect",{className:"tp-card",x:"36.5",y:"27.5",width:"28",height:"14",rx:"2.5"}),a.jsx("rect",{className:"tp-tag",x:"39.5",y:"25.5",width:"13",height:"4",rx:"2"}),a.jsx("rect",{className:"tp-card",x:"76.5",y:"14.5",width:"29",height:"20",rx:"2.5"}),a.jsx("rect",{className:"tp-rule",x:"81",y:"23",width:"20",height:"2",rx:"1"}),a.jsx("rect",{className:"tp-accent",x:"81",y:"23",width:"12",height:"2",rx:"1"})]})})}function Nle({theme:e,onTheme:t}){const n=r=>{var l;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(r.key))return;r.preventDefault();const o=(El.indexOf(e)+(r.key==="ArrowLeft"||r.key==="ArrowUp"?-1:1)+El.length)%El.length;t(El[o]),(l=r.currentTarget.querySelectorAll('[role="radio"]')[o])==null||l.focus()};return a.jsxs("section",{className:"settings-group","aria-labelledby":"appearance-theme-caption",children:[a.jsxs("div",{className:"settings-caption",children:[a.jsxs("div",{children:[a.jsx("h3",{id:"appearance-theme-caption",children:"Color theme"}),a.jsx("p",{className:"settings-caption-note",children:"Choose how the dashboard looks."})]}),a.jsx("kbd",{className:"settings-key","aria-hidden":!0,title:"Press T anywhere to switch themes",children:"T"})]}),a.jsx("div",{className:"appearance-themes",role:"radiogroup","aria-labelledby":"appearance-theme-caption","aria-keyshortcuts":"T",onKeyDown:n,children:El.map(r=>a.jsxs("button",{type:"button",className:"appearance-theme",role:"radio","aria-checked":e===r,tabIndex:e===r?0:-1,onClick:()=>t(r),children:[a.jsx(kle,{theme:r}),a.jsxs("span",{className:"appearance-theme-name",children:[ble[r],a.jsx("svg",{className:"appearance-check",viewBox:"0 0 12 12","aria-hidden":!0,focusable:"false",children:a.jsx("path",{d:"M2.5 6.4 4.9 8.7 9.5 3.6"})})]})]},r))})]})}function jle({section:e,onSection:t,onClose:n,providers:r,sound:s,tones:o,customTones:l,notify:c,appearance:d,fm:h}){const f=y.useRef(null),p=ot(n,{focusRef:f}),g=mt(n),v=y.useRef([]),j=Jre(e);y.useEffect(()=>{var oe,Ne;Qre((oe=document.activeElement)==null?void 0:oe.id,e)&&((Ne=f.current)==null||Ne.focus())},[e]);const{theme:k,setTheme:x,characterEnabled:N,setCharacterEnabled:b}=d,S=oe=>{var we;const Ne=bO(oe,j,gd.length,"vertical");Ne.kind!=="pass"&&(oe.preventDefault(),t(gd[Ne.index].id),(we=v.current[Ne.index])==null||we.focus())},E=oe=>{var Me;if(oe.key===" "){oe.stopPropagation();return}const Ne=oe.target;if(Ni(Ne)||Ne.tagName==="SELECT"||oe.key!=="t"&&oe.key!=="T"||oe.ctrlKey||oe.metaKey||oe.altKey)return;oe.preventDefault(),oe.stopPropagation(),x(k==="dark"?"light":"dark"),Ne.getAttribute("role")==="radio"&&((Me=oe.currentTarget.querySelector('[role="radio"][aria-checked="false"]'))==null||Me.focus())},{soundOn:R,toggleSound:I}=s,{tonePrefs:A,previewTone:q,changeTone:$}=o,{customSelections:B,customAssets:L,clearCustomOnly:M,selectCustomTone:F,importNotificationAudio:T,createNotificationVoice:P,renameCustomAsset:O,deleteCustomAsset:G,previewCustomAsset:K}=l,{notifyPermission:U,notifyOn:H,notifyVetoed:D,toggleNotify:V,notifySupported:J,askForNotifications:W,accountNotify:Z,toggleAccountNotify:Y}=c,{fmVolume:X,setFmVolume:ee,fmMuted:ae,setFmMuted:ce,fmSource:ge,customFmStations:ye,unavailableFmStations:se,addFmStation:pe,renameFmStation:fe,removeFmStation:de,pickFmSource:me}=h,ne=(()=>{switch(e){case"notifications":return a.jsx(ule,{notifyOn:H,onToggleNotify:V,notifyVetoed:D,notifyPermission:J?U:"unsupported",onAskNotify:W,accountNotify:Z,onToggleAccountNotify:Y});case"sounds":return a.jsx(xle,{soundOn:R===!0,onToggleSound:I,prefs:A,claudeHere:r.claude,onLevel:(oe,Ne)=>$(oe,{level:Ne}),onFigure:(oe,Ne)=>$(oe,{figure:Ne}),onPreview:oe=>q(oe),customAssets:L,customSelections:B,onBuiltInSelected:M,onCustomSelected:F,onImportCustom:T,onCreateVoice:P,onRenameCustom:O,onPreviewCustom:K,onDeleteCustom:G});case"music":return a.jsx(tle,{characterEnabled:N,onToggleCharacter:()=>b(oe=>!oe),fmVolume:X,onFmVolume:ee,fmMuted:ae,onFmMuted:()=>ce(oe=>!oe),fmSource:ge,onFmSource:me,customFmStations:ye,unavailableFmStations:se,onAddFmStation:pe,onRenameFmStation:fe,onRemoveFmStation:de});default:return a.jsx(Nle,{theme:k,onTheme:x})}})();return a.jsx("div",{className:"modal-backdrop",...g,role:"presentation",children:a.jsxs("div",{ref:p,id:"settings",className:"modal settings-modal",role:"dialog","aria-modal":"true","aria-labelledby":"settings-title",onClick:oe=>oe.stopPropagation(),onKeyDown:E,children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{id:"settings-title",className:"modal-tool-name",children:"Settings"})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:n,"aria-label":"Close settings",title:"Close (Esc)",children:"×"})})]}),a.jsxs("div",{className:"settings-body",children:[a.jsx("div",{className:"settings-nav",role:"tablist","aria-label":"Settings sections","aria-orientation":"vertical",onKeyDown:S,children:gd.map((oe,Ne)=>a.jsxs("button",{ref:we=>{v.current[Ne]=we,oe.id===e&&(f.current=we)},type:"button",role:"tab",id:`settings-tab-${oe.id}`,className:"settings-tab","aria-selected":oe.id===e,"aria-controls":"settings-pane",tabIndex:oe.id===e?0:-1,onClick:()=>t(oe.id),children:[a.jsx(dle,{section:oe.id}),a.jsx("span",{className:"settings-tab-label",children:oe.label})]},oe.id))}),a.jsx("div",{className:"settings-pane",role:"tabpanel",id:"settings-pane","aria-labelledby":`settings-tab-${e}`,children:ne},e)]})]})})}function Sle({tool:e,onClose:t}){const n=ot(t),r=mt(t),s=e.endedAt==null?"inflight":e.ok===!1?"err":"done",o=y.useRef({of:null});o.current.of!==e&&(o.current={of:e}),e.input!==void 0&&(o.current.input=e.input),e.response!==void 0&&(o.current.response=e.response);const l=o.current.input??e.inputPreview,c=o.current.response??e.errorPreview,d=e.trimmed===!0&&o.current.input===void 0&&o.current.response===void 0,h=y.useMemo(()=>{const f=Kq(e.name,l,c);return{input:f.input.map((p,g)=>a.jsx(LM,{block:p},g)),response:f.response.map((p,g)=>a.jsx(LM,{block:p},g)),copyInput:Hj(e.name,"input",l),copyResponse:Hj(e.name,"response",c)}},[e.name,l,c]);return a.jsx("div",{className:"modal-backdrop",...r,role:"presentation",children:a.jsxs("div",{ref:n,className:"modal",onClick:f=>f.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"tool-modal-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsxs("div",{className:"modal-title",children:[a.jsx("span",{className:`status-dot ${s}`,"aria-hidden":!0}),a.jsx("span",{id:"tool-modal-title",className:"modal-tool-name",children:e.name}),a.jsxs("span",{className:"modal-tool-id",title:e.id,children:[e.id.slice(0,12),"…"]})]}),a.jsxs("div",{className:"modal-actions",children:[a.jsx("span",{className:"modal-dur",children:sI(e,"in-flight…")}),a.jsx("button",{className:"glyph-btn",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),a.jsxs("section",{className:"modal-body",children:[d&&a.jsx("div",{className:"modal-section",children:a.jsx("p",{className:"modal-note",children:"Full payloads for this call were released to keep memory bounded — only the previews below are still held."})}),a.jsxs("div",{className:"modal-section",children:[a.jsxs("div",{className:"tm-head",children:[a.jsx("h4",{children:"Input"}),a.jsx(PM,{text:h.copyInput,what:"input"})]}),h.input]}),a.jsxs("div",{className:"modal-section",children:[a.jsxs("div",{className:"tm-head",children:[a.jsxs("h4",{children:["Response ",s==="err"&&a.jsx("span",{className:"err-tag",children:"error"})]}),e.endedAt!=null&&a.jsx(PM,{text:h.copyResponse,what:"response"})]}),e.endedAt==null?a.jsx("pre",{children:"(waiting…)"}):h.response]})]})]})})}const _le={del:"tm-del",add:"tm-add",ctx:"tm-ctx"};function LM({block:e}){const[t,n]=y.useState(!1);if(e.inline)return a.jsxs("p",{className:"tm-inline",children:[e.label&&a.jsx("span",{className:"tm-label",children:e.label}),a.jsx("code",{children:e.text})]});const r=y.useMemo(()=>qq(e),[e]),{shown:s}=U$(r,t),o=Uq(r,t);return a.jsxs("div",{className:"tm-block",children:[e.label&&a.jsx("span",{className:"tm-label",children:e.label}),a.jsx("pre",{className:e.err?"tm-err":void 0,children:e.lines?s.map((l,c)=>a.jsxs("span",{className:l.tone?_le[l.tone]:void 0,children:[l.text,c<s.length-1?`
304
- `:""]},c)):s.map(l=>l.text).join(`
305
- `)}),o&&a.jsx("button",{type:"button",className:"btn tm-more","aria-expanded":o.expanded,onClick:()=>n(l=>!l),children:o.label})]})}function PM({text:e,what:t}){const[n,r]=y.useState(!1),s=y.useRef(!0);return y.useEffect(()=>()=>{s.current=!1},[]),a.jsx("button",{type:"button",className:"btn tm-copy",disabled:!e,"aria-label":n?`The ${t} was copied`:`Copy the ${t}`,onClick:()=>void oo(e).then(o=>{!o||!s.current||(r(!0),window.setTimeout(()=>{s.current&&r(!1)},1600))}),children:n?"copied":"copy"})}const Ele=YP(()=>_k(()=>import("./UsageHistoryModal-o8amyWjp.js"),[]),"Usage history"),Cle=YP(()=>_k(()=>import("./BrowserWatchModal-DCC89YSC.js"),[]),"Browser Watch");function Tle({dialogs:e,welcome:t,desktopUpdate:n,versionCheck:r,restart:s,lanPairs:o,attention:l,clearFlow:c,watchBadge:d,announcements:h,appearance:f,providers:p,stateRef:g,agentCount:v,menus:j,sound:k,tones:x,customTones:N,notify:b,fm:S}){const{openedTool:E,setOpenedToolKey:R,usageHistoryOpen:I,setUsageHistoryOpen:A,browserWatchOpen:q,setBrowserWatchOpen:$,contextAgent:B,setContextFor:L,summaryFor:M,setSummaryFor:F,keyHelpOpen:T,setKeyHelpOpen:P,feedbackOpen:O,setFeedbackOpen:G,feedbackPrefill:K,setFeedbackPrefill:U}=e,{tourOpen:H,openTour:D,closeTour:V,releaseNotes:J,closeReleaseNotes:W,chipVersion:Z}=t,{desktopUpdateRestarting:Y,desktopUpdateFailure:X,readyAppUpdate:ee,askDesktopUpdateRestart:ae}=n,{version:ce}=r,{askRestart:ge}=s,{clearConfirmOpen:ye,setClearConfirmOpen:se,requestClear:pe}=c,{setWatchOn:fe,markWatchSeen:de}=d,{setWatchSaid:me}=h,{palette:ne}=f,{settingsOpen:oe,settingsSection:Ne,showSection:we,closeSettings:Me}=j;return a.jsxs(a.Fragment,{children:[E&&a.jsx(Sle,{tool:E,onClose:()=>R(null)}),I&&a.jsx(y.Suspense,{fallback:null,children:a.jsx(Ele,{providers:p,onClose:()=>A(!1)})}),q&&a.jsx(y.Suspense,{fallback:null,children:a.jsx(Cle,{onClose:()=>$(!1),onSeen:Le=>{me(""),de(Le)},onWatching:fe,palette:ne})}),B&&a.jsx(mz,{agent:B,onClose:()=>L(null)}),O&&a.jsx(KP,{initialKind:K==null?void 0:K.initialKind,initialBody:K==null?void 0:K.initialBody,onClose:()=>{G(!1),U(null)}}),M&&a.jsx(Vie,{state:g.current,sessionId:M,onClose:()=>F(null)}),oe&&a.jsx(jle,{section:Ne,onSection:we,onClose:Me,providers:p,sound:k,tones:x,customTones:N,notify:b,appearance:f,fm:S}),J&&a.jsx(Hie,{entries:J.entries,since:J.since,firstRun:J.firstRun,running:Z,onClose:W,onTour:()=>{W(),D()},updateVersion:ee==null?void 0:ee.version,updateBusy:Y,updateFailure:X&&(!ee||ee.version===X.version)?Yse(X.failure,X.version):void 0,onUpdateRestart:ee?()=>{ae(ee.version)}:void 0,onRestart:!ee&&(ce!=null&&ce.canRestart)?()=>{W(),ge()}:void 0}),a.jsx(Ale,{lanPairs:o,attention:l}),T&&a.jsx(hie,{onClose:()=>P(!1),onTour:()=>{P(!1),D()}}),H&&a.jsx(AO,{title:"What the deck shows you",steps:bY,onClose:V}),ye&&a.jsx(Lae,{agentCount:v,onConfirm:()=>pe("confirmation"),onCancel:()=>se(!1)})]})}function Ale({lanPairs:e,attention:t}){const n=jie(e);return a.jsxs(a.Fragment,{children:[n,a.jsx(Cie,{...t,pairing:n!=null})]})}const Rle=10,r3=500,s3=4e3,Mle=[/ResizeObserver loop/i,/^Script error\.?$/i],Jd=String.raw`[^\s\\/:'"\`<>|?*;,]`,$le=String.raw`${Jd}(?:[^\\/\r\n:'"\`<>|?*;,]*${Jd})?[\\/]`,Ile=String.raw`[^\s\\/:'"\`<>|?*;,()]+`,Cl=String.raw`(?:${$le})*(?:${Ile})?`,Ole=String.raw`(?<![\w.~/\\\]-]|<(?:deck|host)>)(?:file://(?:/[A-Za-z]:)?[^\s:'"\`<>()]*|~[\\/]${Cl}|[A-Za-z]:[\\/]${Cl}|\\\\(?:[?.]\\)?(?:[A-Za-z]:\\)?${Cl}|/(?=${Jd})${Cl}|(?<!:)//(?=${Jd})${Cl})`,Lle=String.raw`(?<![\w-])(?:[A-Za-z]--|-[A-Za-z0-9][\w.]*-)[\w.-]*`,Ple=new Set([".claude",".codex"]);function Dle(e){if(!e.startsWith("~"))return"<path>";const t=e[1],[n,...r]=e.slice(2).split(/[\\/]/);return n?Ple.has(n)?r.join("")?`~${t}${n}${t}<path>`:e:`~${t}<path>`:e}const Fle=String.raw`\b(https?|wss?)://[^\s/?#\\'"\x60<>(),;]+(?=(/assets/)?)`;function Ble(e,t,n){return n?"<deck>":`${t}://<host>`}const DM=String.raw`(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)`,a3=String.raw`${DM}(?:\.${DM}){3}`,Ex=String.raw`[0-9A-Fa-f]{1,4}`,FM=String.raw`(?=[0-9A-Fa-f:]*\d)(?=[0-9A-Fa-f:]*::|(?:${Ex}:){7})(?:(?:${Ex})?:)+(?:${a3}|${Ex})?`,BM=String.raw`%[\w-]+(?:\.[\w-]+)*`,qM=String.raw`(?:::1?|::ffff:(?:127(?:\.\d{1,3}){3}|0\.0\.0\.0))`,qle=String.raw`(?<![\w:.%-])(?:\[(?!${qM}\])${FM}(?:${BM})?\]|(?!${qM}(?::\d{1,5})?(?![\w:%]|\.\d))${FM}(?:${BM})?(?![\w%]|\.\d))|(?<![\w./-])(?!127\.|0\.0\.0\.0\b)${a3}(?![\w-]|\.\d)`,Cx=String.raw`(?=[\w.-]*[A-Za-z])[A-Za-z0-9][\w-]*(?:\.[\w-]+)*`,Ule=String.raw`(?<![\w.@/\\%-])(?!localhost(?![\w-]|\.\w))(?:(?<=\b(?:(?:getaddrinfo|connect) E[A-Z_]+|ENOTFOUND|EAI_AGAIN) )${Cx}|${Cx}(?=:\d{1,5}(?![\w:-]|\.\w))|${Cx}\.(?:local|lan|home|internal|ts\.net)(?![\w-]|\.\w))`;function UM(e){return String(e??"").replace(/\/(?:home|Users)\/[^/\s:'"]+/g,"~").replace(/[A-Za-z]:\\(?:Users|Documents and Settings)\\[^\\\r\n:'"]+/gi,"~").replace(new RegExp(Ole,"g"),Dle).replace(new RegExp(Lle,"g"),"<project>").replace(new RegExp(Fle,"g"),Ble).replace(new RegExp(qle,"g"),"<host>").replace(new RegExp(Ule,"g"),"<host>").replace(/[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}/g,"<email>").replace(/\b(?:sk-ant-[A-Za-z0-9_-]{8,}|sk-[A-Za-z0-9_-]{20,}|gh[pousr]_[A-Za-z0-9]{20,}|xox[abpr]-[A-Za-z0-9-]{10,}|eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}|[A-Fa-f0-9]{40,}|[A-Za-z0-9+_=-]{48,})/g,"<secret>")}const o3=e=>{fetch("/api/client-error",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e),keepalive:!0}).catch(()=>{})};function zle(e,t,n=o3){const r=String(e??"").slice(0,r3).trim();r&&n({message:r,stack:typeof t=="string"?t.slice(0,s3):void 0})}function Wle(e,t=window,n=o3){let r=0;const s=new Set,o=(d,h)=>{const f=String(d??"").slice(0,r3).trim();!e()||!f||r>=Rle||s.has(f)||Mle.some(p=>p.test(f))||(s.add(f),r++,n({message:f,stack:typeof h=="string"?h.slice(0,s3):void 0}))},l=d=>{var h,f;return o(((h=d.error)==null?void 0:h.message)??d.message,(f=d.error)==null?void 0:f.stack)},c=d=>typeof d.reason=="object"&&d.reason!==null?o(d.reason.message,d.reason.stack):o(d.reason,void 0);return t.addEventListener("error",l),t.addEventListener("unhandledrejection",c),()=>{t.removeEventListener("error",l),t.removeEventListener("unhandledrejection",c)}}const Hle=12;function Vle(e,t){const n=[UM(e).trim()||"The deck threw an error with no message."],r=t==null?void 0:t.trim();if(r){const s=r.split(`
306
- `).slice(0,Hle).join(`
307
- `);n.push("",UM(s).trim())}return n.join(`
308
- `)}class Gle extends y.Component{constructor(){super(...arguments);kp(this,"state",{error:null,componentStack:null,reportOpen:!1});kp(this,"onKey",n=>{oI(n.key)&&qr.dismissTop()})}static getDerivedStateFromError(n){return{error:n}}componentDidCatch(n,r){console.error("ccdeck hit a render error it could not draw past",n,r.componentStack),this.setState({componentStack:r.componentStack??null}),zle(n.message,n.stack),EP("offline")}componentDidUpdate(n,r){this.state.reportOpen!==r.reportOpen&&(this.state.reportOpen?window.addEventListener("keydown",this.onKey):window.removeEventListener("keydown",this.onKey))}componentWillUnmount(){window.removeEventListener("keydown",this.onKey)}render(){const{error:n,componentStack:r,reportOpen:s}=this.state;return n?a.jsxs("div",{className:"error-fallback",children:[a.jsxs("div",{className:"error-fallback-card",role:"alert",children:[a.jsx("p",{className:"error-fallback-title",children:"Something went wrong"}),a.jsx("p",{className:"error-fallback-note",children:"The deck hit an error it could not draw past. Reloading usually clears it — and if it keeps happening, a report tells the people who make ccdeck what broke."}),a.jsxs("div",{className:"error-fallback-actions",children:[a.jsx("button",{type:"button",className:"btn primary",onClick:()=>window.location.reload(),children:"Reload"}),a.jsx("button",{type:"button",className:"btn",onClick:()=>this.setState({reportOpen:!0}),"aria-haspopup":"dialog",children:"Send report"})]})]}),s&&a.jsx(KP,{initialKind:"bug",initialBody:Vle(n.message,r),onClose:()=>this.setState({reportOpen:!1})})]}):this.props.children}}const Kle=1e3;function Yle(e={}){const t=Math.max(1,Math.floor(e.limit??Kle)),n=e.protect;let r=!1,s=[],o=new Set,l=0,c=0,d=null;return{get paused(){return r},get size(){return s.length},get dropped(){return l},get overflowed(){return l>0},get through(){return c},accept(h){const f=typeof(h==null?void 0:h.seq)=="number"?h.seq:null,p=(h==null?void 0:h.epoch)??null,g=p!==null&&p!==d;g&&(d=p,c=0);const v=f!==null&&!g&&f<=c;if(f!==null&&f>c&&(c=f),!r)return!0;if(v)return!1;if(s.push(h),n!=null&&n(h)&&o.add(h),s.length>t){let j=0;if(o.size<s.length)for(;o.has(s[j]);)j++;const[k]=s.splice(j,1);o.delete(k),l++}return!1},setPaused(h){if(r=h,h)return[];const f=s;return s=[],o=new Set,l=0,f}}}function Xle(e){const t=y.useState(()=>Yle({protect:o=>Qq(e.current,o)}))[0],[n,r]=y.useState(!1),s=y.useCallback(()=>{const o=t.paused&&t.dropped>0,l=t.setPaused(!t.paused);o&&bU(e.current);for(const c of l)e.current=Z$(e.current,c);r(t.paused)},[t,e]);return{pauseGate:t,paused:n,togglePause:s}}const Hb={kind:"assumed",claude:!0,codex:!0};function Zle(e){if(!e||typeof e!="object")return Hb;const t=e.providers;if(!t||typeof t!="object")return Hb;const n=t;return{kind:"reported",claude:n.claude!==!1,codex:n.codex!==!1}}function Jle(e){const[t,n]=y.useState(null),[r,s]=y.useState(Hb);y.useEffect(()=>{let l=!1;return fetch("/api/health").then(c=>c.ok?c.json():null).then(c=>{l||(s(Zle(c)),!(!c||typeof c.workspace!="string")&&n(c.workspace))}).catch(()=>{}),()=>{l=!0}},[e]);const o=Cn(r);return{workspace:t,providers:r,providersRef:o}}const i3=3*6e4,Qle=2e4;function ece({fetchReport:e,visible:t,now:n,onReport:r}){let s=0,o=!0;const l=async()=>{if(!t())return;const c=await e();!o||!c||(s=n(),r(c))};return{tick:l,wake:async()=>{t()&&n()-s>=i3&&await l()},stop:()=>{o=!1}}}async function tce(){try{const e=await fetch("/api/provider-status",{signal:AbortSignal.timeout(Qle)});return e.ok?await e.json():null}catch{return null}}function nce(e){const[t,n]=y.useState(null);return y.useEffect(()=>{if(!e){n(null);return}const r=ece({fetchReport:tce,visible:()=>document.visibilityState==="visible",now:()=>Date.now(),onReport:n});r.tick();const s=window.setInterval(r.tick,i3),o=()=>{r.wake()};return document.addEventListener("visibilitychange",o),()=>{r.stop(),window.clearInterval(s),document.removeEventListener("visibilitychange",o)}},[e]),t}const rce={degraded:"degraded performance",partial_outage:"partial outage",major_outage:"major outage",maintenance:"maintenance"},sce={degraded:"degraded",partial_outage:"partial outage",major_outage:"major outage",maintenance:"maintenance"},ace={degraded:"degraded",partial_outage:"outage",major_outage:"outage",maintenance:"maint."},oce={claude:"Claude",codex:"Codex"},ice=new Set(["status.claude.com","status.openai.com"]),lce=30*6e4,cce=10*6e4;function uce(e){if(typeof e!="string")return null;try{const t=new URL(e);return t.protocol==="https:"&&ice.has(t.hostname)?t:null}catch{return null}}function zM(e){return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hourCycle:"h23"})}function dce(e){const t=Math.floor(e/6e4);return t<1?"just now":t<60?`${t} min ago`:`${Math.floor(t/60)} h ago`}function hce(e,t){if(!e||typeof e!="object")return null;const n=Lt(rce,e.state),r=Lt(oce,e.provider);if(!n||!r||typeof e.checkedAt!="number"||t-e.checkedAt>lce)return null;const s=uce(e.statusPageUrl);if(!s)return null;const o=Array.isArray(e.components)?e.components:[],l=e.stale===!0||t-e.checkedAt>cce,c=[`${r}: ${n}${e.summary?` — ${e.summary}`:""}`,o.length>0?`Affected: ${o.join(", ")}`:null,e.scope==="page"?`The page's overall status: it names none of ${r}'s components`:null,l?`Last read from ${s.hostname} at ${zM(e.checkedAt)}; this is the last thing it said`:`Reported by ${s.hostname}, checked ${dce(t-e.checkedAt)}`,"Opens the status page"],d=l?zM(e.checkedAt):null;return{provider:e.provider,state:e.state,name:r,label:`${r} · ${n}${d?` · as of ${d}`:""}`,words:n,chipWords:Lt(sce,e.state)??n,shortWords:Lt(ace,e.state)??n,asOf:d,what:e.summary||(o.length>0?o.join(", "):null),href:s.href,host:s.hostname,stale:l,detail:c.filter(Boolean).join(`
309
- `)}}function fce(e,t){return!(e!=null&&e.ok)||e.disabled||!Array.isArray(e.providers)?[]:e.providers.map(n=>hce(n,t)).filter(n=>n!==null)}function pce(e){return e.map(t=>`${t.name}'s status page reports ${t.state.endsWith("outage")?`a ${t.words}`:t.words}.`).join(" ")}const mce="The providers' status pages report no incident.";function gce({version:e,loadVersion:t}){var h;const[n,r]=y.useState(!1),s=((h=e==null?void 0:e.upgrade)==null?void 0:h.state)??"idle",o=jae(e==null?void 0:e.upgrade),l=y.useRef(!1),c=y.useCallback(async()=>{if(xr(l.current||s==="running")){l.current=!0;try{await fetch("/api/upgrade",{method:"POST"})}catch{}await t(),l.current=!1}},[s,t]);y.useEffect(()=>{if(s!=="running")return;const f=window.setInterval(t,3e3);return()=>window.clearInterval(f)},[s,t]);const d=y.useCallback(async()=>{const f=e==null?void 0:e.command;!f||!await oo(f)||(r(!0),window.setTimeout(()=>r(!1),1600))},[e==null?void 0:e.command]);return{upgradeState:s,upgradeFailure:o,startUpgrade:c,copyCommand:d,cmdCopied:n}}const WM="agent-dag.browserWatch.seenMs";function yce(e,t){return e.filter(n=>n.startMs>t)}function wce(){const[e,t]=y.useState(()=>Number(Je(WM))||0),[n,r]=y.useState([]),[s,o]=y.useState(!1);y.useEffect(()=>{let d=!0;const h=()=>{fetch("/api/browser-watch?live=0").then(p=>p.ok?p.json():null).then(p=>{var g;!d||!(p!=null&&p.ok)||(r(p.episodes??[]),o(((g=p.settings)==null?void 0:g.enabled)===!0))}).catch(()=>{})};h();const f=setInterval(h,5*6e4);return()=>{d=!1,clearInterval(f)}},[]);const l=y.useMemo(()=>yce(n,e).length,[n,e]),c=y.useCallback(d=>{t(d),Ye(WM,String(d))},[]);return{watchOn:s,setWatchOn:o,watchUnseen:l,markWatchSeen:c}}const l3=["--err","--inflight","--ok","--grid-line","--minimap-mask","--panel","--line","--accent","--text-dim","--bg"];function HM(e){const t={};for(const n of l3)t[n]=e(n);return t}function vce(e){return t=>e[t]??""}function xce(e,t){return l3.every(n=>e[n]===t[n])}const c3="agent-dag.theme";function bce(e,t=!1){return e==="light"||e==="dark"?e:t?"light":"dark"}function kce(){try{return window.matchMedia("(prefers-color-scheme: light)").matches}catch{return!1}}function Nce(){return bce(Je(c3),kce())}function VM(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}function jce(){const[e,t]=y.useState(Nce),[n,r]=y.useState(Zie),[s,o]=y.useState(()=>HM(VM)),l=y.useMemo(()=>vce(s),[s]),c=y.useCallback(d=>Cre(d,l),[l]);return y.useEffect(()=>{document.documentElement.dataset.theme=e,Ye(c3,e),o(d=>{const h=HM(VM);return xce(d,h)?d:h})},[e]),y.useEffect(()=>{Ye(t3,n?"1":"0")},[n]),y.useEffect(()=>{const d=document.querySelector('meta[name="theme-color"]'),h=s["--panel"];d&&h&&d.setAttribute("content",h)},[s]),{theme:e,setTheme:t,characterEnabled:n,setCharacterEnabled:r,palette:s,minimapNodeFill:c}}function Sce(e){const t=y.useRef(null),[n,r]=y.useState(!1),[s,o]=y.useState(()=>new Set),l=y.useMemo(()=>{const d=new Set;for(const h of e.current.agents.values())for(const f of h.tools)d.add(TP(f.name));return Object.keys(CP).filter(h=>d.has(h))},[e.current,e.current.revision]);y.useEffect(()=>{if(l.length<=1){r(!1);return}let d=0;const h=()=>{const f=t.current;if(f&&!document.hidden){const p=f.getBoundingClientRect(),g=Array.from(document.querySelectorAll(".react-flow__node, .tool-burst")).map(j=>j.getBoundingClientRect()),v=z7(p,g,8);r(j=>j===v?j:v)}d=window.setTimeout(h,300)};return h(),()=>window.clearTimeout(d)},[l.length]);const c=y.useCallback(d=>{o(h=>{const f=new Set(h);return f.has(d)?f.delete(d):f.add(d),f})},[]);return{presentCats:l,hiddenCats:s,toggleCat:c,catBarRef:t,catBarOccluded:n}}function _ce(e={enabled:()=>!0}){const t=e.ctor??(typeof window<"u"?window.AudioContext??window.webkitAudioContext??null:null);let n=null;const r=new Set,s=()=>e.enabled()?(n==null?void 0:n.state)==="running"?"ready":"locked":"off",o=()=>{var g;return(g=e.onState)==null?void 0:g.call(e,s())};function l(){var g,v;if(!(!t||(n==null?void 0:n.state)==="running"))try{n||(n=new t,(g=n.addEventListener)==null||g.call(n,"statechange",o)),(v=n.resume)==null||v.call(n).then(o,()=>{}),o()}catch{}}function c(g,v,j=v.figure){if(!n||n.state!=="running")return!1;const k=Cb(g,j),x=CJ(v.level,k),N=n.currentTime;for(const b of k.notes){const S=n.createOscillator(),E=n.createGain();S.type=k.type??"sine",S.frequency.value=b.hz;const R=N+b.at,I=R+b.ms/1e3;E.gain.setValueAtTime(L_,R),E.gain.exponentialRampToValueAtTime(x,R+TJ),E.gain.exponentialRampToValueAtTime(L_,I),S.connect(E).connect(n.destination),S.start(R),S.stop(I+.02)}return!0}async function d(g,v){var x;if(!e.loadCustom)return"unavailable";let j;try{j=await e.loadCustom(g)}catch{return"unavailable"}if(!j)return"missing";if(j.kind==="tts"){if(typeof window>"u"||!("speechSynthesis"in window)||typeof SpeechSynthesisUtterance>"u")return"unavailable";const N=new SpeechSynthesisUtterance(j.text),b=window.speechSynthesis.getVoices();N.voice=b.find(S=>S.voiceURI===j.voiceURI)??null,N.rate=j.rate,N.pitch=j.pitch,N.volume=AJ(v.level);try{return window.speechSynthesis.cancel(),window.speechSynthesis.speak(N),"played"}catch{return"unavailable"}}if(!n||n.state!=="running")return"locked";let k;try{k=await n.decodeAudioData(j.bytes.slice(0))}catch{return"broken"}try{const N=n.createBufferSource(),b=n.createGain();return N.buffer=k,b.gain.setValueAtTime(RJ(j.normalizationGain,v.level),n.currentTime),N.connect(b).connect(n.destination),r.add(N),(x=N.addEventListener)==null||x.call(N,"ended",()=>r.delete(N)),N.start(n.currentTime),"played"}catch{return"unavailable"}}function h(g,v=!1){var x,N;if(!v&&!e.enabled())return!1;const j=DJ((x=e.prefs)==null?void 0:x.call(e),g),k=((N=e.customSelection)==null?void 0:N.call(e)[g])??null;return k&&e.loadCustom?(d(k,j).then(b=>{var S;b==="played"||b==="locked"||((b==="missing"||b==="broken")&&((S=e.onCustomFailure)==null||S.call(e,g,k)),c(g,{...j,figure:_n},_n))}),!0):!n||n.state!=="running"?!1:c(g,j)}function f(g,v=ao){return d(g,{level:Ei(v),figure:_n}),!0}function p(){try{typeof window<"u"&&"speechSynthesis"in window&&window.speechSynthesis.cancel()}catch{}for(const g of r)try{g.stop()}catch{}r.clear()}return{unlock:l,play:h,previewCustom:f,silence:p,state:s,get context(){return n}}}function Ece({chimesRef:e,soundOnRef:t,tonePrefsRef:n,customSelectionsRef:r,fallbackCustomRef:s}){const[o,l]=y.useState("locked");return y.useEffect(()=>{const c=_ce({enabled:()=>t.current===!0,prefs:()=>n.current,customSelection:()=>r.current,loadCustom:NJ,onCustomFailure:(p,g)=>s.current(p,g),onState:l});e.current=c,l(c.state());const d=["pointerdown","pointerup","keydown"],h=()=>{for(const p of d)window.removeEventListener(p,f,{capture:!0})},f=()=>{var p;c.unlock(),((p=c.context)==null?void 0:p.state)==="running"&&h()};for(const p of d)window.addEventListener(p,f,{capture:!0});return h},[]),{chimeState:o}}function Cce(){const[e,t]=y.useState(Qie),[n,r]=y.useState(()=>sq(Je(Lj))),[s,o]=y.useState(()=>rq(Je(Pj))),[l,c]=y.useState(()=>aq(Je($M),n,Yie)),[d,h]=y.useState(()=>new Set),[f,p]=y.useState(0);y.useEffect(()=>{Ye(n3,String(e))},[e]),y.useEffect(()=>{Ye(Pj,s?"1":"0")},[s]),y.useEffect(()=>{Ye(Lj,JSON.stringify(n))},[n]),y.useEffect(()=>{Ye($M,l)},[l]);const g=y.useCallback(N=>{r(b=>b.some(S=>S.id===N.id)?b:[...b,N]),h(b=>{if(!b.has(N.id))return b;const S=new Set(b);return S.delete(N.id),S})},[]),v=y.useCallback((N,b)=>{const S=b.trim();!S||S.length>Ql||r(E=>E.map(R=>R.id===N?{...R,name:S}:R))},[]),j=y.useCallback(N=>{r(b=>b.filter(S=>S.id!==N)),c(b=>oq(b,N)),h(b=>{if(!b.has(N))return b;const S=new Set(b);return S.delete(N),S})},[]),k=y.useCallback(N=>{const b=Dj(N),S=d.has(b);N===l&&!S||(S&&h(E=>{const R=new Set(E);return R.delete(b),R}),c(N),p(E=>E+1))},[l,d]),x=y.useCallback((N,b)=>{const S=Dj(N);h(E=>{if(E.has(S)===b)return E;const I=new Set(E);return b?I.add(S):I.delete(S),I})},[]);return{fmVolume:e,setFmVolume:t,fmMuted:s,setFmMuted:o,fmSource:l,customFmStations:n,unavailableFmStations:d,fmPlayRequest:f,addFmStation:g,renameFmStation:v,removeFmStation:j,pickFmSource:k,markFmStationAvailability:x}}function Tce(e){const[t,n]=y.useState(null),[r,s]=y.useState(!1),[o,l]=y.useState(null),c=y.useRef(0);y.useEffect(()=>{if(!e||!fc())return;let j=!1;const k=c.current;return fetch("/api/desktop-update").then(x=>x.ok?x.json():null).then(x=>{if(j||c.current!==k)return;const N=wM(x);N&&n(N)}).catch(()=>{}),()=>{j=!0}},[e]);const d=Wse(t),h=y.useRef(!1),f=y.useRef(0),p=y.useRef(0);y.useEffect(()=>()=>window.clearTimeout(f.current),[]);const g=y.useCallback(async j=>{if(!xr(h.current))return;const k=++p.current;window.clearTimeout(f.current),h.current=!0,s(!0),l(null);const x=N=>{k===p.current&&(window.clearTimeout(f.current),h.current=!1,s(!1),l({failure:N,version:j}))};try{const N=await fetch("/api/desktop-update/restart",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({version:j})});if(!N.ok)return x(Kse(await N.json().catch(()=>null)))}catch{return x("unreachable")}k===p.current&&(f.current=window.setTimeout(()=>x("timeout"),MP))},[]),v=y.useCallback(j=>{if(fc())try{const k=wM(JSON.parse(j));k&&(c.current++,n(k),k.status!=="ready"&&(p.current++,window.clearTimeout(f.current),h.current=!1,s(!1)))}catch{}},[]);return{desktopUpdateRestarting:r,desktopUpdateFailure:o,readyAppUpdate:d,askDesktopUpdateRestart:g,onDesktopUpdateEvent:v}}const sd="agent-dag.autoRestart",GM="agent-dag.bundleReloadedFor";function Ace({now:e,stateRef:t,version:n,notice:r,noticeOpen:s,upgradeFailure:o,paused:l}){const[c,d]=y.useState(()=>Je(sd)!=="0"),h=y.useRef(!1),f=y.useCallback(()=>{const B=!c;h.current=!0,ws(sd),d(B),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:B})}).then(L=>L.ok?L.json():null).then(L=>{var M;L!=null&&L.ok&&d(((M=L.prefs)==null?void 0:M.autoUpdate)!==!1)}).catch(()=>{})},[c]),[p,g]=y.useState(!1),[v,j]=y.useState("restart"),[k,x]=y.useState(null),N=y.useRef(!1),b=y.useRef(null),S=y.useRef(0),E=y.useRef(null),R=y.useCallback(async B=>{if(!xr(N.current))return;const L=(B==null?void 0:B.upgrade)===!0,M=(B==null?void 0:B.whenIdle)===!0;N.current=!0,b.current=o;const F=++S.current,T=()=>{j(L?"npx":"restart"),g(!0)};M||T();try{window.sessionStorage.setItem("agent-dag.restartPending",(r==null?void 0:r.to)??"")}catch{}let P=!1;try{const O=await fetch("/api/restart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(M?{upgrade:L,whenIdle:M}:{upgrade:L})});P=M&&O.status===409}catch{}if(P){N.current=!1,E.current=null;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}return}M&&T(),window.setTimeout(()=>{if(S.current===F&&N.current){N.current=!1,g(!1);try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}}},L?18e4:3e4)},[r==null?void 0:r.to,o]);y.useEffect(()=>{const B=vM(t.current.agents.values())>0,L=Tae({enabled:c,kind:r==null?void 0:r.kind,canRestart:(n==null?void 0:n.canRestart)===!0,noticeOpen:s,visible:document.visibilityState==="visible",busy:B,idleSince:E.current,now:e});E.current=L.idleSince,L.restart&&R({whenIdle:!0})},[c,r==null?void 0:r.kind,n==null?void 0:n.canRestart,s,e,R]);const I=vM(t.current.agents.values()),A=Cae(I,l),q=OP({enabled:c,kind:r==null?void 0:r.kind,canRestart:(n==null?void 0:n.canRestart)===!0,noticeOpen:s,visible:document.visibilityState==="visible",busy:I>0,idleSince:E.current,now:e});y.useEffect(()=>{const B=n==null?void 0:n.running;let L=null,M=null;try{L=window.sessionStorage.getItem("agent-dag.restartPending"),M=window.sessionStorage.getItem(GM)}catch{return}const F=Nae({bundle:"3.38.5",running:B,pending:L,lastTried:M});if(F==="reload"){try{window.sessionStorage.setItem(GM,B??"")}catch{return}window.location.reload();return}if(F!=="confirm")return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}N.current=!1,g(!1),x(B??null);const T=window.setTimeout(()=>x(null),6e3);return()=>window.clearTimeout(T)},[n==null?void 0:n.running]),y.useEffect(()=>{if(p&&Sae({asked:b.current,reported:o})){try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}N.current=!1,g(!1)}},[p,o]);const $=y.useCallback(B=>{var L,M;if(!h.current){const F=Je(sd)==="0";ws(sd),F&&((L=B.prefs)==null?void 0:L.autoUpdate)!==!1?(d(!1),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:!1})}).catch(()=>{})):d(((M=B.prefs)==null?void 0:M.autoUpdate)!==!1)}},[]);return{autoRestart:c,toggleAutoRestart:f,restarting:p,restartMode:v,restartedTo:k,askRestart:R,restartCopy:A,restartFuseMs:q,loadAutoRestartPrefs:$}}function Rce(){const[e,t]=y.useState([]),n=y.useRef(new Set),[r,s]=y.useState(null),[o,l]=y.useState(void 0);y.useEffect(()=>{let h=!0,f=0;const p=()=>{fetch("/api/lan").then(g=>g.ok?g.json():null).then(g=>h?(g!=null&&g.ok&&t(o_(Array.isArray(g.pending)?g.pending:[],g.aliases)),g):null).catch(()=>null).then(g=>{h&&(l(v=>g!=null&&g.ok?g:v===void 0?null:v),f=window.setTimeout(p,(g==null?void 0:g.enabled)===!0?xb:TO))})};return p(),()=>{h=!1,window.clearTimeout(f)}},[]);const c=y.useCallback(async(h,f)=>{if(!r){s(h);try{const g=await(await fetch("/api/lan/peer",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:h,fp:f})})).json().catch(()=>null);g&&Array.isArray(g.pending)?t(o_(g.pending,g.aliases)):t(v=>v.filter(j=>j.fp!==f))}catch{}finally{s(null)}}},[r]),d=y.useCallback(h=>{r||(n.current.add(h),t(f=>[...f]))},[r]);return{lanPending:e,lanDeferred:n,lanBusy:r,answerLanPair:c,deferLanPair:d,lanStatus:o}}const Mce=6e4;function $ce({enabled:e,lanStatus:t,now:n}){const[r,s]=y.useState(null),[o,l]=y.useState(()=>new Set),[c,d]=y.useState(null),h=y.useCallback(N=>{N!=null&&N.ok&&Array.isArray(N.accounts)&&s(N.accounts)},[]),f=y.useCallback(async N=>{try{const b=await fetch(`/api/claude-accounts${N?"?refresh=1":""}`);b.ok&&h(await b.json())}catch{}},[h]);y.useEffect(()=>{e&&f(!1)},[e,f]),y.useEffect(()=>{if(!e)return;let N=Date.now();const b=()=>{document.visibilityState!=="visible"||Date.now()-N<Mce||(N=Date.now(),f(!1))};return document.addEventListener("visibilitychange",b),window.addEventListener("focus",b),()=>{document.removeEventListener("visibilitychange",b),window.removeEventListener("focus",b)}},[e,f]);const p=y.useMemo(()=>e?mie(r,{lan:t,now:n,closed:o}):[],[e,r,t,n,o]),g=y.useRef(p);g.current=p;const v=y.useCallback(N=>{N.length&&l(b=>new Set([...b,...N]))},[]),j=y.useCallback(()=>{const N=g.current;N.length&&(v(N.map(b=>b.id)),fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"reauth-later",incidents:N.map(b=>({key:b.key,since:b.since}))})}).catch(()=>{}))},[v]),k=y.useRef(c);k.current=c;const x=y.useCallback(N=>{const b=k.current;v(gie(b?[b,...g.current]:g.current,N))},[v]);return{rows:p,signingIn:c,observe:h,signIn:d,signedIn:x,refresh:y.useCallback(()=>{f(!0)},[f]),closeSignIn:y.useCallback(()=>d(null),[]),later:j}}const u3="agent-dag.sessionListOpen",d3="agent-dag.accountsPanelOpen";function Ice(){return Je(u3)==="1"}function Oce(e){Ye(u3,e?"1":"0")}function Lce(){const e=Je(d3);return e===null?!0:e==="1"}function Pce(){const[e,t]=y.useState(Ice);y.useEffect(()=>{Oce(e)},[e]);const n=y.useRef(!1),[r,s]=y.useState(()=>{const h=Lce();return h&&e?(n.current=!0,!1):h});y.useEffect(()=>{!r&&n.current||Ye(d3,r?"1":"0")},[r]),y.useEffect(()=>{!e&&n.current&&(n.current=!1,s(!0))},[e]);const o=y.useCallback(()=>{t(h=>(h||s(f=>(f&&(n.current=!0),!1)),!h))},[]),l=y.useCallback(()=>{n.current=!1,s(h=>(h||t(!1),!h))},[]),c=y.useCallback(()=>t(!1),[]),d=y.useCallback(()=>s(!1),[]);return{sessionListOpen:e,accountsPanelOpen:r,toggleSessionList:o,toggleAccountsPanel:l,closeSessionList:c,closeAccountsPanel:d}}const h3="agent-dag.detailOpen",f3="agent-dag.usagePanelOpen",p3="agent-dag.systemPanelOpen";function Dce(){return Je(h3)==="1"}function Fce(e){Ye(h3,e?"1":"0")}function Bce(){const e=Je(f3);return e===null?!0:e==="1"}function qce(e){Ye(f3,e?"1":"0")}function Uce(){const e=Je(p3);return e===null?!0:e==="1"}function zce(e){Ye(p3,e?"1":"0")}function Wce(){const[e,t]=y.useState(Dce);y.useEffect(()=>{Fce(e)},[e]);const[n,r]=y.useState(Bce);y.useEffect(()=>{qce(n)},[n]);const[s,o]=y.useState(Uce);return y.useEffect(()=>{zce(s)},[s]),qt("usage-panel",n),qt("machine-panel",s),{detailOpen:e,setDetailOpen:t,usagePanelOpen:n,setUsagePanelOpen:r,machinePanelOpen:s,setMachinePanelOpen:o}}const Hce={permission:"your permission",asked:"your answer"},Vce="No sessions are waiting for you.";function Gce(e){if(e.length===0)return"";const[t,...n]=e,r=t.waiting.kind,s=n.every(l=>l.waiting.kind===r)?Hce[r]??"you":"you";if(n.length===0)return`${t.label} is waiting for ${s}.`;const o=`${n.length} more session${n.length===1?"":"s"}`;return`${t.label} and ${o} are waiting for ${s}.`}function Tx(e,t,n=Vce){return t!==""?t:e===""?"":n}function Kce({waitingSessions:e,watchUnseen:t,incidents:n=[]}){const[r,s]=y.useState(""),o=Gce(e);y.useEffect(()=>{s(g=>Tx(g,o))},[o]);const[l,c]=y.useState(""),d=t>0?`Browser watch has ${t} unread ${t===1?"finding":"findings"}.`:"";y.useEffect(()=>{c(g=>Tx(g,d,"Browser watch has no unread findings."))},[d]);const[h,f]=y.useState(""),p=pce(n);return y.useEffect(()=>{f(g=>Tx(g,p,mce))},[p]),{blockedSaid:r,watchSaid:l,setWatchSaid:c,incidentSaid:h}}const Yce="/icon-192.png",m3=Object.freeze({notifySwap:!0,notifyQuota:!1,notifyReset:!1});function KM(e){const t=n=>typeof(e==null?void 0:e[n])=="boolean"?e[n]:m3[n];return{notifySwap:t("notifySwap"),notifyQuota:t("notifyQuota"),notifyReset:t("notifyReset")}}function Xce({waitingSessions:e,liveSince:t,focusSession:n}){const[r,s]=y.useState(()=>typeof Notification>"u"?"denied":Notification.permission),[o,l]=y.useState(null),[c,d]=y.useState(!1),[h,f]=y.useState(!1),[p,g]=y.useState(m3),v=y.useCallback(q=>{const $=!p[q];g(B=>({...B,[q]:$})),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({[q]:$})}).then(B=>B.ok?B.json():null).then(B=>{B!=null&&B.ok&&g(KM(B.prefs))}).catch(()=>{})},[p]),j=y.useRef(()=>{}),k=y.useRef(new Set),x=Cn(e),N=y.useCallback(()=>{const q=!c;d(q),q&&(k.current=Uu(x.current)),q&&typeof Notification<"u"&&Notification.permission==="default"&&j.current(),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({notifications:q})}).then($=>$.ok?$.json():null).then($=>{var B;$!=null&&$.ok&&(d(((B=$.prefs)==null?void 0:B.notifications)===!0),f($.notificationsVetoed===!0))}).catch(()=>{})},[c]),b=typeof Notification<"u";y.useEffect(()=>{if(!o)return;const $=setTimeout(()=>l(null),o==="blocked"?8e3:4e3);return()=>clearTimeout($)},[o]);const S=y.useCallback(()=>{typeof Notification>"u"||Notification.requestPermission().then(q=>{const $=q;s($),$==="granted"?l("on"):$==="denied"&&l("blocked")})},[]);j.current=S;const E=y.useRef(null),R=e.map(q=>uh(q.id,q.waiting)).join("|");y.useEffect(()=>{BU(E.current,r)&&(E.current=r,k.current=Uu(e))},[r]);const I=y.useRef(!1);y.useEffect(()=>{qU(I.current,t)&&(I.current=!0,k.current=Uu(e))},[t]),y.useEffect(()=>{if(typeof Notification>"u"||Notification.permission!=="granted"||!UU(E.current,t))return;const q=typeof document>"u"||!document.hidden,$=DU(e,k.current,q,c);for(const B of $)try{const L=new Notification(B.title,{body:B.body,tag:B.key,icon:Yce});L.onclick=()=>{window.focus(),n(B.sessionId),L.close()}}catch{}k.current=q?Uu(e):FU(e,$,k.current)},[R,t]);const A=y.useCallback(q=>{var $;d((($=q.prefs)==null?void 0:$.notifications)===!0),f(q.notificationsVetoed===!0),g(KM(q.prefs))},[]);return{notifyPermission:r,notifySaid:o,notifyOn:c,notifyVetoed:h,toggleNotify:N,notifySupported:b,askForNotifications:S,loadNotifyPrefs:A,accountNotify:p,toggleAccountNotify:v}}function Zce({openedTool:e,usageHistoryOpen:t,contextFor:n,tourOpen:r,summaryFor:s,browserWatchOpen:o,keyHelpOpen:l,releaseNotes:c,feedbackOpen:d}){const h=Cn(l),f=y.useRef(!1);return f.current=e!=null||t||n!=null||r||s!=null||o||l||c!=null||d,{keyHelpOpenRef:h,modalOpenRef:f}}function Jce({stateRef:e,tourOpen:t,releaseNotes:n}){const[r,s]=y.useState(null),o=y.useCallback((B,L)=>s({agentId:B,toolId:L}),[]),[l,c]=y.useState(null),[d,h]=y.useState(null),f=y.useCallback(B=>h(B),[]),[p,g]=y.useState(!1),[v,j]=y.useState(!1),[k,x]=y.useState(!1),[N,b]=y.useState(!1),[S,E]=y.useState(null),R=y.useCallback(B=>{E(B??null),b(!0)},[]);qt("tool-detail",r!==null),qt("session-summary",l!==null),qt("context-window",d!==null),qt("keyboard-help",p),qt("usage-history",v),qt("browser-watch",k),qt("feedback",N);const I=r?Yq(e.current.agents,r.agentId,r.toolId):null,A=d?e.current.agents.get(d):void 0,{keyHelpOpenRef:q,modalOpenRef:$}=Zce({openedTool:I,usageHistoryOpen:v,contextFor:d,tourOpen:t,summaryFor:l,browserWatchOpen:k,keyHelpOpen:p,releaseNotes:n,feedbackOpen:N});return{setOpenedToolKey:s,openTool:o,openedTool:I,summaryFor:l,setSummaryFor:c,contextFor:d,setContextFor:h,openContext:f,contextAgent:A,keyHelpOpen:p,setKeyHelpOpen:g,usageHistoryOpen:v,setUsageHistoryOpen:j,browserWatchOpen:k,setBrowserWatchOpen:x,feedbackOpen:N,setFeedbackOpen:b,feedbackPrefill:S,setFeedbackPrefill:E,openFeedback:R,keyHelpOpenRef:q,modalOpenRef:$}}function Qce({stateRef:e,pinnedRef:t,measuredRef:n,positionsRef:r,lastLayoutSigRef:s,forgetRemovals:o,clearSelection:l,rerender:c,modalOpenRef:d}){const[h,f]=y.useState(!1),p=y.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}e.current=pk(),t.current.clear(),n.current.clear(),r.current.clear(),s.current="",kP(),o(),l(),c()},[c,l,o]),g=Cn(h),v=y.useCallback(j=>{const k=Mae(j,{confirmOpen:g.current,modalOpen:d.current});k==="confirm"?f(!0):k==="clear"&&(f(!1),p())},[p]);return{clearConfirmOpen:h,setClearConfirmOpen:f,requestClear:v}}const YM="agent-dag.oldNameNoticeDismissed";function eue(e){const[t,n]=y.useState(()=>Je(YM)??""),r=e!=null&&e.invokedAs&&e.invokedAs!==xt?e.invokedAs:null,s=r!=null&&t!==r,o=y.useCallback(()=>{r&&(n(r),Ye(YM,r))},[r]);return{oldName:r,oldNameOpen:s,dismissOldName:o}}const tue=300*1e3,nue=1800*1e3,rue=8e3,sue=3e4;function XM(e){return fetch("/api/rating",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)}).catch(()=>null)}function aue({modalOpenRef:e}){const t=y.useCallback(()=>Xx({appModal:e.current,dialogDepth:qr.dialogDepth()}),[e]),[n,r]=y.useState("hidden"),[s,o]=y.useState(null),[l,c]=y.useState(!1),d=y.useRef(n);d.current=n,y.useEffect(()=>{let v=!1;const j=async()=>{if(d.current==="thanks"||d.current==="hidden"&&(document.hidden||t()))return;const N=await fetch("/api/rating").then(b=>b.ok?b.json():null).catch(()=>null);v||!N||r(b=>b==="thanks"?b:N.ask===!0?"asking":"hidden")},k=window.setTimeout(j,tue),x=window.setInterval(j,nue);return()=>{v=!0,window.clearTimeout(k),window.clearInterval(x)}},[t]),y.useEffect(()=>{if(n!=="thanks"||l)return;const v=s!==null&&s<=6?sue:rue;let j=0;const k=()=>{t()?j=window.setTimeout(k,v):r("hidden")};return j=window.setTimeout(k,v),()=>window.clearTimeout(j)},[n,s,l,t]);const h=y.useCallback(v=>{o(v),c(!1),r("thanks"),XM({score:v})},[]),f=y.useCallback(v=>c(v),[]),p=y.useCallback(()=>{r("hidden"),XM({later:!0})},[]),g=y.useCallback(()=>r("hidden"),[]);return{ratingPhase:n,ratingScore:s,answerRating:h,rateLater:p,closeRating:g,holdThanks:f}}function oue({chimesRef:e,setTonePrefs:t,tonePrefsRef:n,previewTone:r}){const[s,o]=y.useState(()=>dJ(Je)),l=Cn(s),[c,d]=y.useState([]),h=y.useCallback(b=>{o(S=>{const E={...S,[b]:null};return l.current=E,E}),ws(Ul[b])},[]),f=y.useCallback((b,S)=>{const E=l.current[b];S&&E!==S||(h(b),t(R=>{const I={...R,[b]:{...R[b],figure:_n}};return n.current=I,I}),Ye(zd[b],_n))},[h]),p=Cn(f);y.useEffect(()=>{let b=!0;return kJ().then(S=>{if(!b)return;d(S);const E=new Set(S.map(R=>R.id));for(const R of zl){const I=l.current[R];I&&!E.has(I)&&p.current(R,I)}},()=>{}),()=>{b=!1}},[]);const g=y.useCallback((b,S)=>{if(!c.some(R=>R.id===S))return;const E={...l.current,[b]:S};l.current=E,o(E),Ye(Ul[b],S),r(b,!0)},[c,r]),v=y.useCallback(async b=>{var I;const S=Eb(c.length);if(S)throw new Error(S);const E=window.AudioContext??window.webkitAudioContext;if(!E)throw new Error("This browser cannot decode audio files.");const R=new E;try{const A=await yJ(b,$=>R.decodeAudioData($));await I_(A);const q=cc(A);d($=>[...$.filter(B=>B.id!==q.id),q])}finally{(I=R.close)==null||I.call(R)}},[c.length]),j=y.useCallback(async b=>{const S=Eb(c.length);if(S)throw new Error(S);const E=wJ(b);await I_(E);const R=cc(E);d(I=>[...I.filter(A=>A.id!==R.id),R])},[c.length]),k=y.useCallback(async(b,S)=>{const E=c.find(I=>I.id===b),R=S.trim().slice(0,80);!E||!R||R===E.name||(await jJ(b,R),d(I=>I.map(A=>A.id===b?{...A,name:R}:A)))},[c]),x=y.useCallback(async b=>{await SJ(b),d(I=>I.filter(A=>A.id!==b));const S=l.current,E=hJ(S,b);l.current=E,o(E);const R=zl.filter(I=>S[I]===b);for(const I of R)ws(Ul[I]),Ye(zd[I],_n);R.length>0&&t(I=>{const A={...I};for(const q of R)A[q]={...A[q],figure:_n};return n.current=A,A})},[]),N=y.useCallback(b=>{var R,I;const S=zl.find(A=>l.current[A]===b),E=S?n.current[S].level:ao;(R=e.current)==null||R.unlock(),(I=e.current)==null||I.previewCustom(b,E)},[]);return{customSelections:s,customSelectionsRef:l,customAssets:c,clearCustomOnly:h,fallbackCustomRef:p,selectCustomTone:g,importNotificationAudio:v,createNotificationVoice:j,renameCustomAsset:k,deleteCustomAsset:x,previewCustomAsset:N}}function iue(e){const[t,n]=y.useState(()=>PJ(Je)),r=Cn(t),s=y.useRef(null),o=y.useCallback((c,d=!1)=>{var h,f;if((h=e.current)==null||h.unlock(),s.current!==null&&clearTimeout(s.current),s.current=null,!d){(f=e.current)==null||f.play(c,!0);return}s.current=setTimeout(()=>{var p;s.current=null,(p=e.current)==null||p.play(c,!0)},MJ)},[]),l=y.useCallback((c,d)=>{n(h=>{const f={level:Ei(d.level??h[c].level),figure:aL(c,d.figure??h[c].figure)};return Ye(lL[c],String(f.level)),Ye(zd[c],f.figure),{...h,[c]:f}}),o(c,!0)},[o]);return y.useEffect(()=>()=>{s.current!==null&&clearTimeout(s.current)},[]),{tonePrefs:t,setTonePrefs:n,tonePrefsRef:r,previewTone:o,changeTone:l}}const lue=15e3;function cue(e){return e.visibilityState==="visible"&&e.hasFocus()}function uue(e,t){return t||e===!0}function due(){try{if(typeof crypto<"u"&&typeof crypto.randomUUID=="function")return crypto.randomUUID()}catch{}return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,10)}`}function hue(){y.useEffect(()=>{const e=due();let t=null;const n=l=>{fetch("/api/presence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tab:e,looking:l}),keepalive:!0}).catch(()=>{})},r=()=>{const l=cue(document);uue(t,l)&&n(l),t=l},s=()=>{t&&n(!1),t=!1};r();const o=window.setInterval(r,lue);return window.addEventListener("focus",r),window.addEventListener("blur",r),document.addEventListener("visibilitychange",r),window.addEventListener("pagehide",s),()=>{window.clearInterval(o),window.removeEventListener("focus",r),window.removeEventListener("blur",r),document.removeEventListener("visibilitychange",r),window.removeEventListener("pagehide",s),s()}},[])}function fue({loadAutoRestartPrefs:e,loadNotifyPrefs:t,loadReportsPrefs:n}){y.useEffect(()=>{let r=!0;return fetch("/api/prefs").then(s=>s.ok?s.json():null).then(s=>{!r||!(s!=null&&s.ok)||(e(s),t(s),n(s))}).catch(()=>{}),()=>{r=!1}},[])}const Ax="agent-dag.versionNoticeDismissed",pue=15*6e4;function mue(e){const[t,n]=y.useState(null),[r,s]=y.useState(()=>Je(Ax)??""),o=y.useRef(0),[l,c]=y.useState(!1),d=y.useCallback((k=!1)=>(k&&(o.current=Date.now(),c(!0)),fetch(k?"/api/version?refresh=1":"/api/version").then(x=>x.ok?x.json():null).then(x=>{x&&n(x)}).catch(()=>{}).finally(()=>{k&&c(!1)})),[]),h=y.useCallback(()=>{d(Date.now()-o.current>=pue)},[d]);y.useEffect(()=>{d();const k=window.setInterval(h,5*6e4),x=()=>{document.visibilityState==="visible"&&h()};return document.addEventListener("visibilitychange",x),()=>{window.clearInterval(k),document.removeEventListener("visibilitychange",x)}},[d,h]),y.useEffect(()=>{e&&d()},[e,d]);const f=(t==null?void 0:t.notice)??null,p=$P(f),g=eae(f,r),v=y.useCallback(()=>{s(""),Ye(Ax,"")},[]),j=y.useCallback(()=>{f&&(s(p),Ye(Ax,p))},[f,p]);return{version:t,notice:f,noticeOpen:g,showNotice:v,dismissNotice:j,versionChecking:l,loadVersion:d}}function gue({version:e,readyAppUpdate:t}){const[n,r]=y.useState(!1),s=y.useRef(null),[o,l]=y.useState(null),c=o&&t?t.version:null,d=y.useRef(null);y.useEffect(()=>{!c||d.current===c||(d.current=c,fetch("/api/desktop-update/seen",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({version:c})}).catch(()=>{}))},[c]);const h=y.useRef(!1);y.useEffect(()=>{if(h.current)return;const x=Fl(),N=Pie(x),b=zie({stored:N,running:(e==null?void 0:e.running)??null,notes:MM,remembers:Die(x)});if(b.reason==="no-version")return;h.current=!0,b.record&&Fie(x,b.record);let S=!0;return(async()=>{var q;let R=Bie(x);if(fc())try{const $=await fetch("/api/prefs");if(!$.ok)throw new Error("desktop tour preferences unavailable");const B=await $.json();if(!(B!=null&&B.ok))throw new Error("desktop tour preferences unavailable");const L=((q=B.prefs)==null?void 0:q.tourSeen)===!0;R&&!L&&fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tourSeen:!0}),keepalive:!0}).catch(()=>{}),R=R||L}catch{R=!0}if(!S)return;const I=Uie({tourSeen:R,decision:b}),A=b.show.length?{entries:b.show,since:N,firstRun:!1}:null;I.tour&&r(!0),I.notes==="now"?l(A):I.notes==="after"&&(s.current=A)})(),()=>{S=!1}},[e==null?void 0:e.running]);const f=(e==null?void 0:e.running)??"3.38.5",p=y.useMemo(()=>ZP(MM,null,f),[f]),g=y.useCallback(()=>{l({entries:p,since:null,firstRun:!1})},[p]),v=y.useCallback(()=>r(!0),[]),j=y.useCallback(()=>l(null),[]),k=y.useCallback(()=>{r(!1),qie(Fl()),fc()&&fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tourSeen:!0}),keepalive:!0}).catch(()=>{});const x=s.current;s.current=null,x&&l(x)},[]);return{tourOpen:n,openTour:v,closeTour:k,releaseNotes:o,closeReleaseNotes:j,chipVersion:f,openReleaseNotes:g}}function yue(){const[e,t]=y.useState(void 0),[n,r]=y.useState(!1),s=y.useRef(!1);return s.current=e===!0&&!n,y.useEffect(()=>Wle(()=>s.current),[]),{loadReportsPrefs:y.useCallback(l=>{var c;t(((c=l.prefs)==null?void 0:c.reports)!==!1),r(l.reportsVetoed===!0)},[])}}function wue(){const[e,t]=y.useState(null),[n,r]=y.useState(!1),s=y.useRef(null);return y.useEffect(()=>{let o=!0,l=!1,c=null,d=null,h="";const f=k=>{o&&(r(!0),k!==h&&t(null))},p=()=>{if(l)return;l=!0,c=Date.now();const k=gM();d=k,fetch(`/api/ccusage?since=${k}`).then(x=>x.ok?x.json():null).then(x=>{if(o){if(!(x!=null&&x.ok)){f(k);return}h=k,t(Use(x)),r(!1)}}).catch(()=>f(k)).finally(()=>{l=!1})},g=()=>{const k=s.current;qse({shown:!!k&&k.getClientRects().length>0,tabVisible:document.visibilityState==="visible",lastSince:d,since:gM(),lastReadAt:c,now:Date.now()})&&p()};g();const v=window.setInterval(g,Bse);document.addEventListener("visibilitychange",g);let j=null;return s.current&&typeof ResizeObserver<"u"&&(j=new ResizeObserver(g),j.observe(s.current)),()=>{o=!1,window.clearInterval(v),document.removeEventListener("visibilitychange",g),j==null||j.disconnect()}},[]),{monthlyUsage:e,monthlyUsageUnavailable:n,monthUsageRef:s}}function vue(e){const[t,n]=y.useState(null);y.useEffect(()=>{const c=Je("agent-dag.sound");n(c===null?!0:c==="on")},[]);const r=y.useCallback(()=>{n(c=>{var h,f;const d=c!==!0;return Ye("agent-dag.sound",d?"on":"off"),d?(h=e.current)==null||h.unlock():(f=e.current)==null||f.silence(),d})},[]),s=y.useCallback(c=>{r()},[r]),o=Cn(s),l=Cn(t);return{soundOn:t,toggleSound:r,activateSoundRef:o,soundOnRef:l}}function xue(){const[e,t]=y.useState(!1),n=y.useRef(null),[r,s]=y.useState(ese),o=y.useCallback(d=>{t(!1),s(h=>tse(h,d))},[]),l=y.useCallback(()=>s(d=>({...d,open:!1})),[]),c=y.useCallback(d=>s(h=>({...h,section:d})),[]);return{soundMenuOpen:e,setSoundMenuOpen:t,soundButtonRef:n,settingsOpen:r.open,settingsSection:r.section,openSettings:o,closeSettings:l,showSection:c}}const bue="agent-dag.autoFitDisabled";function kue(e){const t=y.useRef(!1),[n,r]=y.useState(!1);y.useEffect(()=>{ws(bue)},[]);const s=y.useCallback(()=>{t.current||(t.current=!0,r(!0))},[]),o=y.useCallback(()=>{t.current=!1,r(!1),e(400)},[e]);return{autoFitDisabled:n,autoFitDisabledRef:t,disableAutoFit:s,enableAutoFitAndRefit:o}}function Nue(){return a.jsx(uk,{children:a.jsx(Gle,{children:a.jsx(jue,{})})})}function jue(){const e=Ai(),t=y.useState(pk)[0],n=y.useRef(t),[,r]=y.useState(0),s=y.useCallback(()=>r(ja=>ja+1),[]),{detailOpen:o,setDetailOpen:l,usagePanelOpen:c,setUsagePanelOpen:d,machinePanelOpen:h,setMachinePanelOpen:f}=Wce(),{selectedIds:p,primarySelectedId:g,selectAgent:v,clearSelection:j,pruneSelectionToBoard:k}=tQ(n,l),{sessionListOpen:x,accountsPanelOpen:N,toggleSessionList:b,toggleAccountsPanel:S,closeSessionList:E,closeAccountsPanel:R}=Pce(),I=wue(),A=cd(N,200),q=cd(c,130),$=cd(h,130),B=y.useRef(null),L=vue(B),{activateSoundRef:M,soundOnRef:F}=L,T=iue(B),{setTonePrefs:P,tonePrefsRef:O,previewTone:G}=T,K=oue({chimesRef:B,setTonePrefs:P,tonePrefsRef:O,previewTone:G}),{customSelectionsRef:U,fallbackCustomRef:H}=K,D=xue(),{setSoundMenuOpen:V,openSettings:J}=D,{chimeState:W}=Ece({chimesRef:B,soundOnRef:F,tonePrefsRef:O,customSelectionsRef:U,fallbackCustomRef:H}),Z=Xle(n),{pauseGate:Y,paused:X,togglePause:ee}=Z,ae=y.useRef(()=>{}),{live:ce,tabCapped:ge,everConnected:ye,liveSince:se}=HJ({stateRef:n,rerender:s,pauseGate:Y,chimesRef:B,desktopUpdateRef:ae}),pe=mue(ce),{version:fe,notice:de,noticeOpen:me,loadVersion:ne}=pe,oe=Tce(ce),{readyAppUpdate:Ne,onDesktopUpdateEvent:we}=oe;ae.current=we,hue();const Me=gue({version:fe,readyAppUpdate:Ne}),{tourOpen:Le,openTour:Be,releaseNotes:Pe}=Me,{workspace:Qe,providers:qe,providersRef:Ze}=Jle(ce),lt=eue(fe),Nt=gce({version:fe,loadVersion:ne}),{upgradeFailure:Xe}=Nt,tt=Jce({stateRef:n,tourOpen:Le,releaseNotes:Pe}),Ge=aue({modalOpenRef:tt.modalOpenRef}),{openTool:ct,setSummaryFor:en,setContextFor:Dt,openContext:gt,setKeyHelpOpen:wt,setUsageHistoryOpen:zt,setBrowserWatchOpen:Rt,keyHelpOpenRef:ht,modalOpenRef:tn}=tt,Wt=yue(),jt=wce(),{watchOn:Jn,watchUnseen:yn}=jt,Qn=Rce(),[Rn,Yr]=y.useState(0),{presentCats:Mn,hiddenCats:wn,toggleCat:$n,catBarRef:_s,catBarOccluded:In}=Sce(n),er=y.useRef(null),[Er,Xr]=y.useState(0),Mt=nQ({stateRef:n,rerender:s,pruneSelectionToBoard:k,setContextFor:Dt,setSummaryFor:en}),ua=nce(qe.claude||qe.codex),tr=fce(ua,Mt),nn=$ce({enabled:qe.claude,lanStatus:Qn.lanStatus,now:Mt}),Cr=Ace({now:Mt,stateRef:n,version:fe,notice:de,noticeOpen:me,upgradeFailure:Xe,paused:Z.paused}),{askRestart:Es,loadAutoRestartPrefs:Cs}=Cr,nr=jce(),{setTheme:Zr,palette:Ts}=nr,Tr=Cce(),Ar=sre(),{applyViewport:be,moveCamera:Re,fitLeft:ze,cameraEpochRef:rn,lastFitTimeRef:Jr}=Ar,Ht=gre(ze),{pinnedRef:rr,positionsRef:sr,lastLayoutSigRef:On,handleRelayout:sn}=Ht,As=y.useRef(null),an=y.useRef(()=>{}),Kh=se!==null,Ec=y.useRef(0),Cc=y.useCallback(()=>{Ec.current=Date.now()},[]),{canvasRef:vn,canvasSize:ho,paneSizeRef:da}=Kre(),ha=kue(ze),{autoFitDisabledRef:Tc,disableAutoFit:Bi}=ha,fa=y.useRef(!1),{measuredRef:Rr,measuredVersionRef:qi,sizeVersion:pa,domSizeVersion:Yh}=Yre(fa),{removedNodes:fo,removedAgentIds:Ue,removeNode:Ac,removeSelectedNode:Ui,removalNotice:po,bringBack:mo,bringBackAll:Rc,forgetRemovals:Mc}=Pre({stateRef:n,pinnedRef:rr,positionsRef:sr,canvasRef:vn,clearSelection:j,primarySelectedId:g}),ma=Mre({stateRef:n,now:Mt,removedAgentIds:Ue,sizeVersion:pa,domSizeVersion:Yh});yre(ma,Ht),Lre({layoutSig:ma,rf:e,stateRef:n,measuredRef:Rr,pinnedRef:rr,positionsRef:sr,paneSizeRef:da,lastInteractRef:Ec,autoFitDisabledRef:Tc,lastFitTimeRef:Jr,fitLeft:ze});const ga=Xre(),{bubbling:Mr,endBubble:$r,onBubble:Ir}=YZ(),[Qr,ya]=y.useState(!1),ar=GZ(),{beginTrashDrag:Xh,trackTrashDrag:$c,endTrashDrag:wa}=ar,Ic=sJ({stateRef:n,measuredRef:Rr,measuredVersionRef:qi,canvasRef:vn}),{lodRef:Oc,applyZoom:go}=Ic,zi=Vre({applyViewport:be,lastFitTimeRef:Jr,cameraEpochRef:rn,disableAutoFit:Bi,markInteract:Cc,canvasRef:vn,applyZoom:go}),va=g?n.current.agents.get(g):null,es=o&&va!=null,xn=ose({sessionListShown:x,usageShown:Fa(q),machineShown:Fa($),accountsShown:Fa(A)&&qe.claude,detailShown:es,primarySelectedId:g,canvasRef:vn}),{railInsetRef:ts,availableWidth:xa,availableHeight:Lc}=Qne({canvasRef:vn,canvasSize:ho,machinePhase:$,usagePhase:q,usagePanelOpen:c,detailShown:es}),Pc=$re({stateRef:n,now:Mt,availableWidth:xa,availableHeight:Lc,layout:Ht,measuredRef:Rr,onBubble:Ir,settled:ga,dragging:Qr,layoutSig:ma,selectedIds:p,openContext:gt,historyReplayed:Kh,removedNodes:fo,removedAgentIds:Ue,dragTick:Rn,dragPatchRef:er,dragMoveTick:Er}),{nodes:ba,edges:yo}=Pc,ka=Cn(g);wre({nodes:ba,edges:yo,settled:ga,dragging:Qr,availableWidth:xa,availableHeight:Lc,layout:Ht,camera:Ar,rf:e,measuredRef:Rr,stateRef:n,lastFocusRef:As,primarySelectedIdRef:ka,focusAgentRef:an,autoFitDisabledRef:Tc});const Wi=Qce({stateRef:n,pinnedRef:rr,measuredRef:Rr,positionsRef:sr,lastLayoutSigRef:On,forgetRemovals:Mc,clearSelection:j,rerender:s,modalOpenRef:tn}),{requestClear:or}=Wi,Hi=ise({nodes:ba,stateRef:n,pinnedRef:rr,positionsRef:sr,draggingRef:fa,dragPatchRef:er,setDragging:ya,setDragMoveTick:Xr,setDragTick:Yr,endBubble:$r,markInteract:Cc,disableAutoFit:Bi,beginTrashDrag:Xh,trackTrashDrag:$c,endTrashDrag:wa,removeNode:Ac}),wo=y.useCallback(()=>ze(500),[ze]),vo=Cn(ba),{focusAgent:ns,stepAgent:xo,focusSession:Rs}=ore({canvasRef:vn,stateRef:n,measuredRef:Rr,nodesRef:vo,railInsetRef:ts,moveCamera:Re,disableAutoFit:Bi,lastFocusRef:As,focusAgentRef:an,selectAgent:v,primarySelectedIdRef:ka}),Xt=Gre({clearSelection:j,selectAgent:v,detailOpen:o,setDetailOpen:l,detailShown:es,focusAgent:ns,draggingRef:fa,lodRef:Oc}),Ms=ire({nodesRef:vo,stateRef:n,canvasRef:vn,railInsetRef:ts}),Vi=Cn(Ui),$s=y.useRef(null),Zh=y.useCallback(ja=>{Ue.has(ja)&&mo([ja]),Rs(ja)},[Ue,mo,Rs]),Gi=Zre();sse({pointerFocusRef:Gi,nodesRef:vo,stateRef:n,primarySelectedIdRef:ka,providersRef:Ze,soundOnRef:F,keyHelpOpenRef:ht,modalOpenRef:tn,waitingCursorRef:$s,removeSelectedRef:Vi,activateSoundRef:M,clearSelection:j,selectAgent:v,focusAgent:ns,stepAgent:xo,focusSession:Rs,requestClear:or,handleRelayout:sn,handleFit:wo,togglePause:ee,toggleSessionList:b,toggleAccountsPanel:S,setDetailOpen:l,setUsageHistoryOpen:zt,setUsagePanelOpen:d,setMachinePanelOpen:f,setBrowserWatchOpen:Rt,setSoundMenuOpen:V,setKeyHelpOpen:wt,setTheme:Zr,openSettings:J});const bo=n.current.agents.size,ir=y.useMemo(()=>Yx(n.current.agents.values()),[n.current,n.current.revision]);Dre({stateRef:n,waitingSessions:ir,removedAgentIds:Ue,removedNodes:fo,bringBack:mo}),zre({stateRef:n,waitingSessions:ir,live:ce});const Na=Kce({waitingSessions:ir,watchUnseen:yn,incidents:tr}),ko=Xce({waitingSessions:ir,liveSince:se,focusSession:Rs}),{loadNotifyPrefs:Jh}=ko;return fue({loadAutoRestartPrefs:Cs,loadNotifyPrefs:Jh,loadReportsPrefs:Wt.loadReportsPrefs}),a.jsxs("div",{className:"app",children:[a.jsx("a",{className:"skip-link",href:"#canvas",children:"Skip to the canvas"}),a.jsxs("header",{className:"topbar",children:[a.jsx(oae,{versionCheck:pe,welcome:Me,desktopUpdate:oe,pause:Z,monthly:I,announcements:Na,notify:ko,waitingSessions:ir,waitingCursorRef:$s,focusSession:Rs,live:ce,now:Mt,incidents:tr}),va&&a.jsx(iae,{selected:va,now:Mt,selectedIds:p,focusAgent:ns,clearSelection:j}),a.jsxs("div",{className:"actions",children:[a.jsx(Lse,{sessionListOpen:x,toggleSessionList:b,usagePanelOpen:c,setUsagePanelOpen:d,setUsageHistoryOpen:zt,toggles:xn.toggles}),a.jsx(Pse,{providers:qe,accountsPanelOpen:N,toggleAccountsPanel:S,machinePanelOpen:h,setMachinePanelOpen:f,watchOn:Jn,watchUnseen:yn,setBrowserWatchOpen:Rt,toggles:xn.toggles}),a.jsx(Dse,{providers:qe,sound:L,tones:T,chimeState:W,menus:D,onFeedback:()=>tt.openFeedback(),watchUnseen:yn,setUsageHistoryOpen:zt,setBrowserWatchOpen:Rt})]})]}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:po?`${po.label} removed from the board.`:""}),a.jsx(Rae,{restart:Cr,versionCheck:pe,upgrade:Nt,oldNameNotice:lt,rating:Ge,onFeedback:tt.openFeedback,everConnected:ye,live:ce,paused:X}),Fa(A)&&qe.claude&&a.jsx(BZ,{leaving:A==="leaving",onReport:tt.openFeedback,onRoster:nn.observe,onClose:()=>{xn.accounts(),R()}}),x&&a.jsx(V7,{state:n.current,now:Mt,selectedIds:p,onSelect:Zh,onClose:()=>{xn.sessionList(),E()},removedIds:Ue,onBringBackAll:Rc}),a.jsxs(hae,{canvasRef:vn,bubbling:Mr,dragging:Qr,trash:ar,zoom:Ic,viewport:zi,stateRef:n,peek:Ms,children:[bo===0&&(!ce&&ge?a.jsx(mse,{}):a.jsx(gse,{live:ce,everConnected:ye,providers:qe,workspace:Qe,onTour:Be})),(Mn.length>1||wn.size>0)&&a.jsx(lae,{catBarRef:_s,catBarOccluded:In,presentCats:Mn,hiddenCats:wn,toggleCat:$n}),a.jsx($7,{graph:Pc,layout:Ht,viewport:zi,clicks:Xt,drag:Hi,appearance:nr,fm:Tr,autoFit:ha,pause:Z,stateRef:n,measuredRef:Rr,hiddenCats:wn,now:Mt,openTool:ct,focusAgent:ns,requestClear:or,setKeyHelpOpen:wt})]}),Fa(q)&&a.jsx(q9,{state:n.current,now:Mt,providers:qe,incidents:tr,liveSince:se,leaving:q==="leaving",onClose:()=>{xn.usage(),d(!1)}}),Fa($)&&a.jsx(jV,{usageOpen:c,leaving:$==="leaving",onClose:()=>{xn.machine(),f(!1)}}),o&&va?a.jsx(Tse,{selected:va,now:Mt,openTool:ct,setSummaryFor:en,stateRef:n,removeSelectedNode:Ui,onClose:()=>{xn.detail(),l(!1)}}):null,a.jsx(Tle,{dialogs:tt,welcome:Me,desktopUpdate:oe,versionCheck:pe,restart:Cr,lanPairs:Qn,attention:nn,clearFlow:Wi,watchBadge:jt,announcements:Na,appearance:nr,providers:qe,stateRef:n,agentCount:bo,menus:D,sound:L,tones:T,customTones:K,notify:ko,fm:Tr})]})}try{kz(window.localStorage)}catch{}const Sue=Y4.createRoot(document.getElementById("root"));Sue.render(a.jsx(Nue,{}));export{use as a,st as b,ks as c,mt as d,ps as e,We as f,Cue as g,Wr as h,Eue as i,a as j,ic as k,An as l,mJ as m,Qs as n,oo as o,lb as p,y as r,xr as s,ot as u};