ccdeck 3.38.6 → 3.39.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,303 +0,0 @@
1
- var P4=Object.defineProperty;var D4=(e,t,n)=>t in e?P4(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var xp=(e,t,n)=>D4(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 Eu=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Ub(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var bp={exports:{}},xl={},kp={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 CN;function F4(){if(CN)return De;CN=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,H,J){this.props=D,this.context=H,this.refs=k,this.updater=J||v}x.prototype.isReactComponent={},x.prototype.setState=function(D,H){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,H,"setState")},x.prototype.forceUpdate=function(D){this.updater.enqueueForceUpdate(this,D,"forceUpdate")};function N(){}N.prototype=x.prototype;function b(D,H,J){this.props=D,this.context=H,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,O={current:null},A={key:!0,ref:!0,__self:!0,__source:!0};function q(D,H,J){var V,Z={},Y=null,X=null;if(H!=null)for(V in H.ref!==void 0&&(X=H.ref),H.key!==void 0&&(Y=""+H.key),H)R.call(H,V)&&!A.hasOwnProperty(V)&&(Z[V]=H[V]);var ee=arguments.length-2;if(ee===1)Z.children=J;else if(1<ee){for(var ae=Array(ee),ue=0;ue<ee;ue++)ae[ue]=arguments[ue+2];Z.children=ae}if(D&&D.defaultProps)for(V in ee=D.defaultProps,ee)Z[V]===void 0&&(Z[V]=ee[V]);return{$$typeof:e,type:D,key:Y,ref:X,props:Z,_owner:O.current}}function I(D,H){return{$$typeof:e,type:D.type,key:H,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 H={"=":"=0",":":"=2"};return"$"+D.replace(/[=:]/g,function(J){return H[J]})}var M=/\/+/g;function F(D,H){return typeof D=="object"&&D!==null&&D.key!=null?L(""+D.key):H.toString(36)}function C(D,H,J,V,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=V===""?"."+F(X,0):V,E(Z)?(J="",D!=null&&(J=D.replace(M,"$&/")+"/"),C(Z,H,J,"",function(ue){return ue})):Z!=null&&(B(Z)&&(Z=I(Z,J+(!Z.key||X&&X.key===Z.key?"":(""+Z.key).replace(M,"$&/")+"/")+D)),H.push(Z)),1;if(X=0,V=V===""?".":V+":",E(D))for(var ee=0;ee<D.length;ee++){Y=D[ee];var ae=V+F(Y,ee);X+=C(Y,H,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=V+F(Y,ee++),X+=C(Y,H,J,ae,Z);else if(Y==="object")throw H=String(D),Error("Objects are not valid as a React child (found: "+(H==="[object Object]"?"object with keys {"+Object.keys(D).join(", ")+"}":H)+"). If you meant to render a collection of children, use an array instead.");return X}function $(D,H,J){if(D==null)return D;var V=[],Z=0;return C(D,V,"","",function(Y){return H.call(J,Y,Z++)}),V}function P(D){if(D._status===-1){var H=D._result;H=H(),H.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=H)}if(D._status===1)return D._result.default;throw D._result}var K={current:null},G={transition:null},U={ReactCurrentDispatcher:K,ReactCurrentBatchConfig:G,ReactCurrentOwner:O};function W(){throw Error("act(...) is not supported in production builds of React.")}return De.Children={map:$,forEach:function(D,H,J){$(D,function(){H.apply(this,arguments)},J)},count:function(D){var H=0;return $(D,function(){H++}),H},toArray:function(D){return $(D,function(H){return H})||[]},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=W,De.cloneElement=function(D,H,J){if(D==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+D+".");var V=j({},D.props),Z=D.key,Y=D.ref,X=D._owner;if(H!=null){if(H.ref!==void 0&&(Y=H.ref,X=O.current),H.key!==void 0&&(Z=""+H.key),D.type&&D.type.defaultProps)var ee=D.type.defaultProps;for(ae in H)R.call(H,ae)&&!A.hasOwnProperty(ae)&&(V[ae]=H[ae]===void 0&&ee!==void 0?ee[ae]:H[ae])}var ae=arguments.length-2;if(ae===1)V.children=J;else if(1<ae){ee=Array(ae);for(var ue=0;ue<ae;ue++)ee[ue]=arguments[ue+2];V.children=ee}return{$$typeof:e,type:D.type,key:Z,ref:Y,props:V,_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 H=q.bind(null,D);return H.type=D,H},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:P}},De.memo=function(D,H){return{$$typeof:h,type:D,compare:H===void 0?null:H}},De.startTransition=function(D){var H=G.transition;G.transition={};try{D()}finally{G.transition=H}},De.unstable_act=W,De.useCallback=function(D,H){return K.current.useCallback(D,H)},De.useContext=function(D){return K.current.useContext(D)},De.useDebugValue=function(){},De.useDeferredValue=function(D){return K.current.useDeferredValue(D)},De.useEffect=function(D,H){return K.current.useEffect(D,H)},De.useId=function(){return K.current.useId()},De.useImperativeHandle=function(D,H,J){return K.current.useImperativeHandle(D,H,J)},De.useInsertionEffect=function(D,H){return K.current.useInsertionEffect(D,H)},De.useLayoutEffect=function(D,H){return K.current.useLayoutEffect(D,H)},De.useMemo=function(D,H){return K.current.useMemo(D,H)},De.useReducer=function(D,H,J){return K.current.useReducer(D,H,J)},De.useRef=function(D){return K.current.useRef(D)},De.useState=function(D){return K.current.useState(D)},De.useSyncExternalStore=function(D,H,J){return K.current.useSyncExternalStore(D,H,J)},De.useTransition=function(){return K.current.useTransition()},De.version="18.3.1",De}var AN;function mc(){return AN||(AN=1,kp.exports=F4()),kp.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 RN;function B4(){if(RN)return xl;RN=1;var e=mc(),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 xl.Fragment=n,xl.jsx=l,xl.jsxs=l,xl}var MN;function q4(){return MN||(MN=1,bp.exports=B4()),bp.exports}var a=q4(),Tu={},Np={exports:{}},un={},jp={exports:{}},Sp={};/**
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 $N;function U4(){return $N||($N=1,(function(e){function t(G,U){var W=G.length;G.push(U);e:for(;0<W;){var D=W-1>>>1,H=G[D];if(0<s(H,U))G[D]=U,G[W]=H,W=D;else break e}}function n(G){return G.length===0?null:G[0]}function r(G){if(G.length===0)return null;var U=G[0],W=G.pop();if(W!==U){G[0]=W;e:for(var D=0,H=G.length,J=H>>>1;D<J;){var V=2*(D+1)-1,Z=G[V],Y=V+1,X=G[Y];if(0>s(Z,W))Y<H&&0>s(X,Z)?(G[D]=X,G[Y]=W,D=Y):(G[D]=Z,G[V]=W,D=V);else if(Y<H&&0>s(X,W))G[D]=X,G[Y]=W,D=Y;else break e}}return U}function s(G,U){var W=G.sortIndex-U.sortIndex;return W!==0?W:G.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(G){for(var U=n(h);U!==null;){if(U.callback===null)r(h);else if(U.startTime<=G)r(h),U.sortIndex=U.expirationTime,t(d,U);else break;U=n(h)}}function E(G){if(k=!1,S(G),!j)if(n(d)!==null)j=!0,P(R);else{var U=n(h);U!==null&&K(E,U.startTime-G)}}function R(G,U){j=!1,k&&(k=!1,N(q),q=-1),v=!0;var W=g;try{for(S(U),p=n(d);p!==null&&(!(p.expirationTime>U)||G&&!L());){var D=p.callback;if(typeof D=="function"){p.callback=null,g=p.priorityLevel;var H=D(p.expirationTime<=U);U=e.unstable_now(),typeof H=="function"?p.callback=H:p===n(d)&&r(d),S(U)}else r(d);p=n(d)}if(p!==null)var J=!0;else{var V=n(h);V!==null&&K(E,V.startTime-U),J=!1}return J}finally{p=null,g=W,v=!1}}var O=!1,A=null,q=-1,I=5,B=-1;function L(){return!(e.unstable_now()-B<I)}function M(){if(A!==null){var G=e.unstable_now();B=G;var U=!0;try{U=A(!0,G)}finally{U?F():(O=!1,A=null)}}else O=!1}var F;if(typeof b=="function")F=function(){b(M)};else if(typeof MessageChannel<"u"){var C=new MessageChannel,$=C.port2;C.port1.onmessage=M,F=function(){$.postMessage(null)}}else F=function(){x(M,0)};function P(G){A=G,O||(O=!0,F())}function K(G,U){q=x(function(){G(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(G){G.callback=null},e.unstable_continueExecution=function(){j||v||(j=!0,P(R))},e.unstable_forceFrameRate=function(G){0>G||125<G?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):I=0<G?Math.floor(1e3/G):5},e.unstable_getCurrentPriorityLevel=function(){return g},e.unstable_getFirstCallbackNode=function(){return n(d)},e.unstable_next=function(G){switch(g){case 1:case 2:case 3:var U=3;break;default:U=g}var W=g;g=U;try{return G()}finally{g=W}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(G,U){switch(G){case 1:case 2:case 3:case 4:case 5:break;default:G=3}var W=g;g=G;try{return U()}finally{g=W}},e.unstable_scheduleCallback=function(G,U,W){var D=e.unstable_now();switch(typeof W=="object"&&W!==null?(W=W.delay,W=typeof W=="number"&&0<W?D+W:D):W=D,G){case 1:var H=-1;break;case 2:H=250;break;case 5:H=1073741823;break;case 4:H=1e4;break;default:H=5e3}return H=W+H,G={id:f++,callback:U,priorityLevel:G,startTime:W,expirationTime:H,sortIndex:-1},W>D?(G.sortIndex=W,t(h,G),n(d)===null&&G===n(h)&&(k?(N(q),q=-1):k=!0,K(E,W-D))):(G.sortIndex=H,t(d,G),j||v||(j=!0,P(R))),G},e.unstable_shouldYield=L,e.unstable_wrapCallback=function(G){var U=g;return function(){var W=g;g=U;try{return G.apply(this,arguments)}finally{g=W}}}})(Sp)),Sp}var IN;function z4(){return IN||(IN=1,jp.exports=U4()),jp.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 ON;function W4(){if(ON)return un;ON=1;var e=mc(),t=z4();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,_,T,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=T,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"),O=Symbol.for("react.portal"),A=Symbol.for("react.fragment"),q=Symbol.for("react.strict_mode"),I=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"),C=Symbol.for("react.suspense_list"),$=Symbol.for("react.memo"),P=Symbol.for("react.lazy"),K=Symbol.for("react.offscreen"),G=Symbol.iterator;function U(i){return i===null||typeof i!="object"?null:(i=G&&i[G]||i["@@iterator"],typeof i=="function"?i:null)}var W=Object.assign,D;function H(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 V(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(ce){var w=ce}Reflect.construct(i,[],u)}else{try{u.call()}catch(ce){w=ce}i.call(u.prototype)}else{try{throw Error()}catch(ce){w=ce}i()}}catch(ce){if(ce&&w&&typeof ce.stack=="string"){for(var _=ce.stack.split(`
35
- `),T=w.stack.split(`
36
- `),z=_.length-1,Q=T.length-1;1<=z&&0<=Q&&_[z]!==T[Q];)Q--;for(;1<=z&&0<=Q;z--,Q--)if(_[z]!==T[Q]){if(z!==1||Q!==1)do if(z--,Q--,0>Q||_[z]!==T[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:"")?H(i):""}function Z(i){switch(i.tag){case 5:return H(i.type);case 16:return H("Lazy");case 13:return H("Suspense");case 19:return H("SuspenseList");case 0:case 2:case 15:return i=V(i.type,!1),i;case 11:return i=V(i.type.render,!1),i;case 1:return i=V(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 O:return"Portal";case I:return"Profiler";case q:return"StrictMode";case F:return"Suspense";case C: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 $:return u=i.displayName||null,u!==null?u:Y(i.type)||"Memo";case P: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 ue(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,T=m.set;return Object.defineProperty(i,u,{configurable:!0,get:function(){return _.call(this)},set:function(z){w=""+z,T.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=ue(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 me(i,u){var m=u.checked;return W({},u,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:m??i._wrapperState.initialChecked})}function pe(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 fe(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 Ie(i,u){if(u.dangerouslySetInnerHTML!=null)throw Error(n(91));return W({},u,{value:void 0,defaultValue:void 0,children:""+i._wrapperState.initialValue})}function Pe(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 Oe(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 Ye(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 Xe,ot=(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(Xe=Xe||document.createElement("div"),Xe.innerHTML="<svg>"+u.valueOf().toString()+"</svg>",u=Xe.firstChild;i.firstChild;)i.removeChild(i.firstChild);for(;u.firstChild;)i.appendChild(u.firstChild)}});function it(i,u){if(u){var m=i.firstChild;if(m&&m===i.lastChild&&m.nodeType===3){m.nodeValue=u;return}}i.textContent=u}var Ze={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},yt=["Webkit","ms","Moz","O"];Object.keys(Ze).forEach(function(i){yt.forEach(function(u){u=u+i.charAt(0).toUpperCase()+i.substring(1),Ze[u]=Ze[i]})});function ze(i,u,m){return u==null||typeof u=="boolean"||u===""?"":m||typeof u!="number"||u===0||Ze.hasOwnProperty(i)&&Ze[i]?(""+u).trim():u+"px"}function ht(i,u){i=i.style;for(var m in u)if(u.hasOwnProperty(m)){var w=m.indexOf("--")===0,_=ze(m,u[m],w);m==="float"&&(m="cssFloat"),w?i.setProperty(m,_):i[m]=_}}var mn=W({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 Mt(i,u){if(u){if(mn[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 lt(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 tn(i){return i=i.target||i.srcElement||window,i.correspondingUseElement&&(i=i.correspondingUseElement),i.nodeType===3?i.parentNode:i}var Ft=null,ft=null,nn=null;function Wt(i){if(i=al(i)){if(typeof Ft!="function")throw Error(n(280));var u=i.stateNode;u&&(u=Uc(u),Ft(i.stateNode,i.type,u))}}function xt(i){ft?nn?nn.push(i):nn=[i]:ft=i}function Tn(){if(ft){var i=ft,u=nn;if(nn=ft=null,Wt(i),u)for(i=0;i<u.length;i++)Wt(u[i])}}function Yn(i,u){return i(u)}function br(){}var gn=!1;function Xn(i,u,m){if(gn)return i(u,m);gn=!0;try{return Yn(i,u,m)}finally{gn=!1,(ft!==null||nn!==null)&&(br(),Tn())}}function Zn(i,u){var m=i.stateNode;if(m===null)return null;var w=Uc(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 Jn=!1;if(c)try{var Cn={};Object.defineProperty(Cn,"passive",{get:function(){Jn=!0}}),window.addEventListener("test",Cn,Cn),window.removeEventListener("test",Cn,Cn)}catch{Jn=!1}function Vr(i,u,m,w,_,T,z,Q,te){var ce=Array.prototype.slice.call(arguments,3);try{u.apply(m,ce)}catch(be){this.onError(be)}}var An=!1,kr=null,bt=!1,Gr=null,Nr={onError:function(i){An=!0,kr=i}};function Es(i,u,m,w,_,T,z,Q,te){An=!1,kr=null,Vr.apply(Nr,arguments)}function Qn(i,u,m,w,_,T,z,Q,te){if(Es.apply(this,arguments),An){if(An){var ce=kr;An=!1,kr=null}else throw Error(n(198));bt||(bt=!0,Gr=ce)}}function Rn(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 Ts(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 er(i){if(Rn(i)!==i)throw Error(n(188))}function Cs(i){var u=i.alternate;if(!u){if(u=Rn(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 T=_.alternate;if(T===null){if(w=_.return,w!==null){m=w;continue}break}if(_.child===T.child){for(T=_.child;T;){if(T===m)return er(_),i;if(T===w)return er(_),u;T=T.sibling}throw Error(n(188))}if(m.return!==w.return)m=_,w=T;else{for(var z=!1,Q=_.child;Q;){if(Q===m){z=!0,m=_,w=T;break}if(Q===w){z=!0,w=_,m=T;break}Q=Q.sibling}if(!z){for(Q=T.child;Q;){if(Q===m){z=!0,m=T,w=_;break}if(Q===w){z=!0,w=T,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 As(i){return i=Cs(i),i!==null?jr(i):null}function jr(i){if(i.tag===5||i.tag===6)return i;for(i=i.child;i!==null;){var u=jr(i);if(u!==null)return u;i=i.sibling}return null}var Sr=t.unstable_scheduleCallback,Kr=t.unstable_cancelCallback,Yr=t.unstable_shouldYield,ve=t.unstable_requestPaint,Re=t.unstable_now,He=t.unstable_getCurrentPriorityLevel,$t=t.unstable_ImmediatePriority,tr=t.unstable_UserBlockingPriority,Yt=t.unstable_NormalPriority,Rs=t.unstable_LowPriority,Ms=t.unstable_IdlePriority,yn=null,Xt=null;function ya(i){if(Xt&&typeof Xt.onCommitFiberRoot=="function")try{Xt.onCommitFiberRoot(yn,i,void 0,(i.current.flags&128)===128)}catch{}}var rn=Math.clz32?Math.clz32:Gh,Tc=Math.log,_r=Math.LN2;function Gh(i){return i>>>=0,i===0?32:31-(Tc(i)/_r|0)|0}var fo=64,wa=4194304;function $s(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 Is(i,u){var m=i.pendingLanes;if(m===0)return 0;var w=0,_=i.suspendedLanes,T=i.pingedLanes,z=m&268435455;if(z!==0){var Q=z&~_;Q!==0?w=$s(Q):(T&=z,T!==0&&(w=$s(T)))}else z=m&~_,z!==0?w=$s(z):T!==0&&(w=$s(T));if(w===0)return 0;if(u!==0&&u!==w&&(u&_)===0&&(_=w&-w,T=u&-u,_>=T||_===16&&(T&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-rn(u),_=1<<m,w|=i[m],u&=~_;return w}function Di(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 Xr(i,u){for(var m=i.suspendedLanes,w=i.pingedLanes,_=i.expirationTimes,T=i.pendingLanes;0<T;){var z=31-rn(T),Q=1<<z,te=_[z];te===-1?((Q&m)===0||(Q&w)!==0)&&(_[z]=Di(Q,u)):te<=u&&(i.expiredLanes|=Q),T&=~Q}}function Fi(i){return i=i.pendingLanes&-1073741825,i!==0?i:i&1073741824?1073741824:0}function Cc(){var i=fo;return fo<<=1,(fo&4194240)===0&&(fo=64),i}function Bi(i){for(var u=[],m=0;31>m;m++)u.push(i);return u}function Os(i,u,m){i.pendingLanes|=u,u!==536870912&&(i.suspendedLanes=0,i.pingedLanes=0),i=i.eventTimes,u=31-rn(u),i[u]=m}function Ls(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-rn(m),T=1<<_;u[_]=0,w[_]=-1,i[_]=-1,m&=~T}}function qi(i,u){var m=i.entangledLanes|=u;for(i=i.entanglements;m;){var w=31-rn(m),_=1<<w;_&u|i[w]&u&&(i[w]|=u),m&=~_}}var Ve=0;function Ui(i){return i&=-i,1<i?4<i?(i&268435455)!==0?16:536870912:4:1}var po,zi,Ac,mo,Wi,Hi=!1,go=[],Er=null,Mn=null,Tr=null,Ps=new Map,va=new Map,Cr=[],Kh="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 Vi(i,u){switch(i){case"focusin":case"focusout":Er=null;break;case"dragenter":case"dragleave":Mn=null;break;case"mouseover":case"mouseout":Tr=null;break;case"pointerover":case"pointerout":Ps.delete(u.pointerId);break;case"gotpointercapture":case"lostpointercapture":va.delete(u.pointerId)}}function xa(i,u,m,w,_,T){return i===null||i.nativeEvent!==T?(i={blockedOn:u,domEventName:m,eventSystemFlags:w,nativeEvent:T,targetContainers:[_]},u!==null&&(u=al(u),u!==null&&zi(u)),i):(i.eventSystemFlags|=w,u=i.targetContainers,_!==null&&u.indexOf(_)===-1&&u.push(_),i)}function Yh(i,u,m,w,_){switch(u){case"focusin":return Er=xa(Er,i,u,m,w,_),!0;case"dragenter":return Mn=xa(Mn,i,u,m,w,_),!0;case"mouseover":return Tr=xa(Tr,i,u,m,w,_),!0;case"pointerover":var T=_.pointerId;return Ps.set(T,xa(Ps.get(T)||null,i,u,m,w,_)),!0;case"gotpointercapture":return T=_.pointerId,va.set(T,xa(va.get(T)||null,i,u,m,w,_)),!0}return!1}function Gi(i){var u=_a(i.target);if(u!==null){var m=Rn(u);if(m!==null){if(u=m.tag,u===13){if(u=Ts(m),u!==null){i.blockedOn=u,Wi(i.priority,function(){Ac(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 Ar(i){if(i.blockedOn!==null)return!1;for(var u=i.targetContainers;0<u.length;){var m=wo(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=al(m),u!==null&&zi(u),i.blockedOn=m,!1;u.shift()}return!0}function yo(i,u,m){Ar(i)&&m.delete(u)}function Zr(){Hi=!1,Er!==null&&Ar(Er)&&(Er=null),Mn!==null&&Ar(Mn)&&(Mn=null),Tr!==null&&Ar(Tr)&&(Tr=null),Ps.forEach(yo),va.forEach(yo)}function Ds(i,u){i.blockedOn===u&&(i.blockedOn=null,Hi||(Hi=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,Zr)))}function Fs(i){function u(_){return Ds(_,i)}if(0<go.length){Ds(go[0],i);for(var m=1;m<go.length;m++){var w=go[m];w.blockedOn===i&&(w.blockedOn=null)}}for(Er!==null&&Ds(Er,i),Mn!==null&&Ds(Mn,i),Tr!==null&&Ds(Tr,i),Ps.forEach(u),va.forEach(u),m=0;m<Cr.length;m++)w=Cr[m],w.blockedOn===i&&(w.blockedOn=null);for(;0<Cr.length&&(m=Cr[0],m.blockedOn===null);)Gi(m),m.blockedOn===null&&Cr.shift()}var Jr=E.ReactCurrentBatchConfig,ba=!0;function Ki(i,u,m,w){var _=Ve,T=Jr.transition;Jr.transition=null;try{Ve=1,ka(i,u,m,w)}finally{Ve=_,Jr.transition=T}}function Xh(i,u,m,w){var _=Ve,T=Jr.transition;Jr.transition=null;try{Ve=4,ka(i,u,m,w)}finally{Ve=_,Jr.transition=T}}function ka(i,u,m,w){if(ba){var _=wo(i,u,m,w);if(_===null)uf(i,u,w,Na,m),Vi(i,w);else if(Yh(_,i,u,m,w))w.stopPropagation();else if(Vi(i,w),u&4&&-1<Kh.indexOf(i)){for(;_!==null;){var T=al(_);if(T!==null&&po(T),T=wo(i,u,m,w),T===null&&uf(i,u,w,Na,m),T===_)break;_=T}_!==null&&w.stopPropagation()}else uf(i,u,w,null,m)}}var Na=null;function wo(i,u,m,w){if(Na=null,i=tn(w),i=_a(i),i!==null)if(u=Rn(i),u===null)i=null;else if(m=u.tag,m===13){if(i=Ts(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 Na=i,null}function Rc(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(He()){case $t:return 1;case tr:return 4;case Yt:case Rs:return 16;case Ms:return 536870912;default:return 16}default:return 16}}var Rr=null,ja=null,Qr=null;function Mc(){if(Qr)return Qr;var i,u=ja,m=u.length,w,_="value"in Rr?Rr.value:Rr.textContent,T=_.length;for(i=0;i<m&&u[i]===_[i];i++);var z=m-i;for(w=1;w<=z&&u[m-w]===_[T-w];w++);return Qr=_.slice(i,1<w?1-w:void 0)}function Mr(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 vo(){return!0}function $c(){return!1}function Zt(i){function u(m,w,_,T,z){this._reactName=m,this._targetInst=_,this.type=w,this.nativeEvent=T,this.target=z,this.currentTarget=null;for(var Q in i)i.hasOwnProperty(Q)&&(m=i[Q],this[Q]=m?m(T):T[Q]);return this.isDefaultPrevented=(T.defaultPrevented!=null?T.defaultPrevented:T.returnValue===!1)?vo:$c,this.isPropagationStopped=$c,this}return W(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=vo)},stopPropagation:function(){var m=this.nativeEvent;m&&(m.stopPropagation?m.stopPropagation():typeof m.cancelBubble!="unknown"&&(m.cancelBubble=!0),this.isPropagationStopped=vo)},persist:function(){},isPersistent:vo}),u}var es={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(i){return i.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Yi=Zt(es),Sa=W({},es,{view:0,detail:0}),Ic=Zt(Sa),ts,xo,ns,bo=W({},Sa,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Jh,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!==ns&&(ns&&i.type==="mousemove"?(ts=i.screenX-ns.screenX,xo=i.screenY-ns.screenY):xo=ts=0,ns=i),ts)},movementY:function(i){return"movementY"in i?i.movementY:xo}}),Bs=Zt(bo),d3=W({},bo,{dataTransfer:0}),h3=Zt(d3),f3=W({},Sa,{relatedTarget:0}),Zh=Zt(f3),p3=W({},es,{animationName:0,elapsedTime:0,pseudoElement:0}),m3=Zt(p3),g3=W({},es,{clipboardData:function(i){return"clipboardData"in i?i.clipboardData:window.clipboardData}}),y3=Zt(g3),w3=W({},es,{data:0}),vk=Zt(w3),v3={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},x3={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"},b3={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function k3(i){var u=this.nativeEvent;return u.getModifierState?u.getModifierState(i):(i=b3[i])?!!u[i]:!1}function Jh(){return k3}var N3=W({},Sa,{key:function(i){if(i.key){var u=v3[i.key]||i.key;if(u!=="Unidentified")return u}return i.type==="keypress"?(i=Mr(i),i===13?"Enter":String.fromCharCode(i)):i.type==="keydown"||i.type==="keyup"?x3[i.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Jh,charCode:function(i){return i.type==="keypress"?Mr(i):0},keyCode:function(i){return i.type==="keydown"||i.type==="keyup"?i.keyCode:0},which:function(i){return i.type==="keypress"?Mr(i):i.type==="keydown"||i.type==="keyup"?i.keyCode:0}}),j3=Zt(N3),S3=W({},bo,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),xk=Zt(S3),_3=W({},Sa,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Jh}),E3=Zt(_3),T3=W({},es,{propertyName:0,elapsedTime:0,pseudoElement:0}),C3=Zt(T3),A3=W({},bo,{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}),R3=Zt(A3),M3=[9,13,27,32],Qh=c&&"CompositionEvent"in window,Xi=null;c&&"documentMode"in document&&(Xi=document.documentMode);var $3=c&&"TextEvent"in window&&!Xi,bk=c&&(!Qh||Xi&&8<Xi&&11>=Xi),kk=" ",Nk=!1;function jk(i,u){switch(i){case"keyup":return M3.indexOf(u.keyCode)!==-1;case"keydown":return u.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Sk(i){return i=i.detail,typeof i=="object"&&"data"in i?i.data:null}var ko=!1;function I3(i,u){switch(i){case"compositionend":return Sk(u);case"keypress":return u.which!==32?null:(Nk=!0,kk);case"textInput":return i=u.data,i===kk&&Nk?null:i;default:return null}}function O3(i,u){if(ko)return i==="compositionend"||!Qh&&jk(i,u)?(i=Mc(),Qr=ja=Rr=null,ko=!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 bk&&u.locale!=="ko"?null:u.data;default:return null}}var L3={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 _k(i){var u=i&&i.nodeName&&i.nodeName.toLowerCase();return u==="input"?!!L3[i.type]:u==="textarea"}function Ek(i,u,m,w){xt(w),u=Fc(u,"onChange"),0<u.length&&(m=new Yi("onChange","change",null,m,w),i.push({event:m,listeners:u}))}var Zi=null,Ji=null;function P3(i){Hk(i,0)}function Oc(i){var u=Eo(i);if(ye(u))return i}function D3(i,u){if(i==="change")return u}var Tk=!1;if(c){var ef;if(c){var tf="oninput"in document;if(!tf){var Ck=document.createElement("div");Ck.setAttribute("oninput","return;"),tf=typeof Ck.oninput=="function"}ef=tf}else ef=!1;Tk=ef&&(!document.documentMode||9<document.documentMode)}function Ak(){Zi&&(Zi.detachEvent("onpropertychange",Rk),Ji=Zi=null)}function Rk(i){if(i.propertyName==="value"&&Oc(Ji)){var u=[];Ek(u,Ji,i,tn(i)),Xn(P3,u)}}function F3(i,u,m){i==="focusin"?(Ak(),Zi=u,Ji=m,Zi.attachEvent("onpropertychange",Rk)):i==="focusout"&&Ak()}function B3(i){if(i==="selectionchange"||i==="keyup"||i==="keydown")return Oc(Ji)}function q3(i,u){if(i==="click")return Oc(u)}function U3(i,u){if(i==="input"||i==="change")return Oc(u)}function z3(i,u){return i===u&&(i!==0||1/i===1/u)||i!==i&&u!==u}var nr=typeof Object.is=="function"?Object.is:z3;function Qi(i,u){if(nr(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,_)||!nr(i[_],u[_]))return!1}return!0}function Mk(i){for(;i&&i.firstChild;)i=i.firstChild;return i}function $k(i,u){var m=Mk(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=Mk(m)}}function Ik(i,u){return i&&u?i===u?!0:i&&i.nodeType===3?!1:u&&u.nodeType===3?Ik(i,u.parentNode):"contains"in i?i.contains(u):i.compareDocumentPosition?!!(i.compareDocumentPosition(u)&16):!1:!1}function Ok(){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 nf(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 W3(i){var u=Ok(),m=i.focusedElem,w=i.selectionRange;if(u!==m&&m&&m.ownerDocument&&Ik(m.ownerDocument.documentElement,m)){if(w!==null&&nf(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,T=Math.min(w.start,_);w=w.end===void 0?T:Math.min(w.end,_),!i.extend&&T>w&&(_=w,w=T,T=_),_=$k(m,T);var z=$k(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(),T>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 H3=c&&"documentMode"in document&&11>=document.documentMode,No=null,rf=null,el=null,sf=!1;function Lk(i,u,m){var w=m.window===m?m.document:m.nodeType===9?m:m.ownerDocument;sf||No==null||No!==se(w)||(w=No,"selectionStart"in w&&nf(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}),el&&Qi(el,w)||(el=w,w=Fc(rf,"onSelect"),0<w.length&&(u=new Yi("onSelect","select",null,u,m),i.push({event:u,listeners:w}),u.target=No)))}function Lc(i,u){var m={};return m[i.toLowerCase()]=u.toLowerCase(),m["Webkit"+i]="webkit"+u,m["Moz"+i]="moz"+u,m}var jo={animationend:Lc("Animation","AnimationEnd"),animationiteration:Lc("Animation","AnimationIteration"),animationstart:Lc("Animation","AnimationStart"),transitionend:Lc("Transition","TransitionEnd")},af={},Pk={};c&&(Pk=document.createElement("div").style,"AnimationEvent"in window||(delete jo.animationend.animation,delete jo.animationiteration.animation,delete jo.animationstart.animation),"TransitionEvent"in window||delete jo.transitionend.transition);function Pc(i){if(af[i])return af[i];if(!jo[i])return i;var u=jo[i],m;for(m in u)if(u.hasOwnProperty(m)&&m in Pk)return af[i]=u[m];return i}var Dk=Pc("animationend"),Fk=Pc("animationiteration"),Bk=Pc("animationstart"),qk=Pc("transitionend"),Uk=new Map,zk="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 qs(i,u){Uk.set(i,u),o(u,[i])}for(var of=0;of<zk.length;of++){var lf=zk[of],V3=lf.toLowerCase(),G3=lf[0].toUpperCase()+lf.slice(1);qs(V3,"on"+G3)}qs(Dk,"onAnimationEnd"),qs(Fk,"onAnimationIteration"),qs(Bk,"onAnimationStart"),qs("dblclick","onDoubleClick"),qs("focusin","onFocus"),qs("focusout","onBlur"),qs(qk,"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 tl="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(" "),K3=new Set("cancel close invalid load scroll toggle".split(" ").concat(tl));function Wk(i,u,m){var w=i.type||"unknown-event";i.currentTarget=m,Qn(w,u,void 0,i),i.currentTarget=null}function Hk(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 T=void 0;if(u)for(var z=w.length-1;0<=z;z--){var Q=w[z],te=Q.instance,ce=Q.currentTarget;if(Q=Q.listener,te!==T&&_.isPropagationStopped())break e;Wk(_,Q,ce),T=te}else for(z=0;z<w.length;z++){if(Q=w[z],te=Q.instance,ce=Q.currentTarget,Q=Q.listener,te!==T&&_.isPropagationStopped())break e;Wk(_,Q,ce),T=te}}}if(bt)throw i=Gr,bt=!1,Gr=null,i}function tt(i,u){var m=u[gf];m===void 0&&(m=u[gf]=new Set);var w=i+"__bubble";m.has(w)||(Vk(u,i,2,!1),m.add(w))}function cf(i,u,m){var w=0;u&&(w|=4),Vk(m,i,w,u)}var Dc="_reactListening"+Math.random().toString(36).slice(2);function nl(i){if(!i[Dc]){i[Dc]=!0,r.forEach(function(m){m!=="selectionchange"&&(K3.has(m)||cf(m,!1,i),cf(m,!0,i))});var u=i.nodeType===9?i:i.ownerDocument;u===null||u[Dc]||(u[Dc]=!0,cf("selectionchange",!1,u))}}function Vk(i,u,m,w){switch(Rc(u)){case 1:var _=Ki;break;case 4:_=Xh;break;default:_=ka}m=_.bind(null,u,m,i),_=void 0,!Jn||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 uf(i,u,m,w,_){var T=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=_a(Q),z===null)return;if(te=z.tag,te===5||te===6){w=T=z;continue e}Q=Q.parentNode}}w=w.return}Xn(function(){var ce=T,be=tn(m),ke=[];e:{var xe=Uk.get(i);if(xe!==void 0){var Se=Yi,Ee=i;switch(i){case"keypress":if(Mr(m)===0)break e;case"keydown":case"keyup":Se=j3;break;case"focusin":Ee="focus",Se=Zh;break;case"focusout":Ee="blur",Se=Zh;break;case"beforeblur":case"afterblur":Se=Zh;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=Bs;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Se=h3;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Se=E3;break;case Dk:case Fk:case Bk:Se=m3;break;case qk:Se=C3;break;case"scroll":Se=Ic;break;case"wheel":Se=R3;break;case"copy":case"cut":case"paste":Se=y3;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Se=xk}var Te=(u&4)!==0,vt=!Te&&i==="scroll",ie=Te?xe!==null?xe+"Capture":null:xe;Te=[];for(var re=ce,le;re!==null;){le=re;var je=le.stateNode;if(le.tag===5&&je!==null&&(le=je,ie!==null&&(je=Zn(re,ie),je!=null&&Te.push(rl(re,je,le)))),vt)break;re=re.return}0<Te.length&&(xe=new Se(xe,Ee,null,m,be),ke.push({event:xe,listeners:Te}))}}if((u&7)===0){e:{if(xe=i==="mouseover"||i==="pointerover",Se=i==="mouseout"||i==="pointerout",xe&&m!==wt&&(Ee=m.relatedTarget||m.fromElement)&&(_a(Ee)||Ee[rs]))break e;if((Se||xe)&&(xe=be.window===be?be:(xe=be.ownerDocument)?xe.defaultView||xe.parentWindow:window,Se?(Ee=m.relatedTarget||m.toElement,Se=ce,Ee=Ee?_a(Ee):null,Ee!==null&&(vt=Rn(Ee),Ee!==vt||Ee.tag!==5&&Ee.tag!==6)&&(Ee=null)):(Se=null,Ee=ce),Se!==Ee)){if(Te=Bs,je="onMouseLeave",ie="onMouseEnter",re="mouse",(i==="pointerout"||i==="pointerover")&&(Te=xk,je="onPointerLeave",ie="onPointerEnter",re="pointer"),vt=Se==null?xe:Eo(Se),le=Ee==null?xe:Eo(Ee),xe=new Te(je,re+"leave",Se,m,be),xe.target=vt,xe.relatedTarget=le,je=null,_a(be)===ce&&(Te=new Te(ie,re+"enter",Ee,m,be),Te.target=le,Te.relatedTarget=vt,je=Te),vt=je,Se&&Ee)t:{for(Te=Se,ie=Ee,re=0,le=Te;le;le=So(le))re++;for(le=0,je=ie;je;je=So(je))le++;for(;0<re-le;)Te=So(Te),re--;for(;0<le-re;)ie=So(ie),le--;for(;re--;){if(Te===ie||ie!==null&&Te===ie.alternate)break t;Te=So(Te),ie=So(ie)}Te=null}else Te=null;Se!==null&&Gk(ke,xe,Se,Te,!1),Ee!==null&&vt!==null&&Gk(ke,vt,Ee,Te,!0)}}e:{if(xe=ce?Eo(ce):window,Se=xe.nodeName&&xe.nodeName.toLowerCase(),Se==="select"||Se==="input"&&xe.type==="file")var Ce=D3;else if(_k(xe))if(Tk)Ce=U3;else{Ce=B3;var Me=F3}else(Se=xe.nodeName)&&Se.toLowerCase()==="input"&&(xe.type==="checkbox"||xe.type==="radio")&&(Ce=q3);if(Ce&&(Ce=Ce(i,ce))){Ek(ke,Ce,m,be);break e}Me&&Me(i,xe,ce),i==="focusout"&&(Me=xe._wrapperState)&&Me.controlled&&xe.type==="number"&&oe(xe,"number",xe.value)}switch(Me=ce?Eo(ce):window,i){case"focusin":(_k(Me)||Me.contentEditable==="true")&&(No=Me,rf=ce,el=null);break;case"focusout":el=rf=No=null;break;case"mousedown":sf=!0;break;case"contextmenu":case"mouseup":case"dragend":sf=!1,Lk(ke,m,be);break;case"selectionchange":if(H3)break;case"keydown":case"keyup":Lk(ke,m,be)}var $e;if(Qh)e:{switch(i){case"compositionstart":var Le="onCompositionStart";break e;case"compositionend":Le="onCompositionEnd";break e;case"compositionupdate":Le="onCompositionUpdate";break e}Le=void 0}else ko?jk(i,m)&&(Le="onCompositionEnd"):i==="keydown"&&m.keyCode===229&&(Le="onCompositionStart");Le&&(bk&&m.locale!=="ko"&&(ko||Le!=="onCompositionStart"?Le==="onCompositionEnd"&&ko&&($e=Mc()):(Rr=be,ja="value"in Rr?Rr.value:Rr.textContent,ko=!0)),Me=Fc(ce,Le),0<Me.length&&(Le=new vk(Le,i,null,m,be),ke.push({event:Le,listeners:Me}),$e?Le.data=$e:($e=Sk(m),$e!==null&&(Le.data=$e)))),($e=$3?I3(i,m):O3(i,m))&&(ce=Fc(ce,"onBeforeInput"),0<ce.length&&(be=new vk("onBeforeInput","beforeinput",null,m,be),ke.push({event:be,listeners:ce}),be.data=$e))}Hk(ke,u)})}function rl(i,u,m){return{instance:i,listener:u,currentTarget:m}}function Fc(i,u){for(var m=u+"Capture",w=[];i!==null;){var _=i,T=_.stateNode;_.tag===5&&T!==null&&(_=T,T=Zn(i,m),T!=null&&w.unshift(rl(i,T,_)),T=Zn(i,u),T!=null&&w.push(rl(i,T,_))),i=i.return}return w}function So(i){if(i===null)return null;do i=i.return;while(i&&i.tag!==5);return i||null}function Gk(i,u,m,w,_){for(var T=u._reactName,z=[];m!==null&&m!==w;){var Q=m,te=Q.alternate,ce=Q.stateNode;if(te!==null&&te===w)break;Q.tag===5&&ce!==null&&(Q=ce,_?(te=Zn(m,T),te!=null&&z.unshift(rl(m,te,Q))):_||(te=Zn(m,T),te!=null&&z.push(rl(m,te,Q)))),m=m.return}z.length!==0&&i.push({event:u,listeners:z})}var Y3=/\r\n?/g,X3=/\u0000|\uFFFD/g;function Kk(i){return(typeof i=="string"?i:""+i).replace(Y3,`
38
- `).replace(X3,"")}function Bc(i,u,m){if(u=Kk(u),Kk(i)!==u&&m)throw Error(n(425))}function qc(){}var df=null,hf=null;function ff(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 pf=typeof setTimeout=="function"?setTimeout:void 0,Z3=typeof clearTimeout=="function"?clearTimeout:void 0,Yk=typeof Promise=="function"?Promise:void 0,J3=typeof queueMicrotask=="function"?queueMicrotask:typeof Yk<"u"?function(i){return Yk.resolve(null).then(i).catch(Q3)}:pf;function Q3(i){setTimeout(function(){throw i})}function mf(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(_),Fs(u);return}w--}else m!=="$"&&m!=="$?"&&m!=="$!"||w++;m=_}while(m);Fs(u)}function Us(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 Xk(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 _o=Math.random().toString(36).slice(2),$r="__reactFiber$"+_o,sl="__reactProps$"+_o,rs="__reactContainer$"+_o,gf="__reactEvents$"+_o,e4="__reactListeners$"+_o,t4="__reactHandles$"+_o;function _a(i){var u=i[$r];if(u)return u;for(var m=i.parentNode;m;){if(u=m[rs]||m[$r]){if(m=u.alternate,u.child!==null||m!==null&&m.child!==null)for(i=Xk(i);i!==null;){if(m=i[$r])return m;i=Xk(i)}return u}i=m,m=i.parentNode}return null}function al(i){return i=i[$r]||i[rs],!i||i.tag!==5&&i.tag!==6&&i.tag!==13&&i.tag!==3?null:i}function Eo(i){if(i.tag===5||i.tag===6)return i.stateNode;throw Error(n(33))}function Uc(i){return i[sl]||null}var yf=[],To=-1;function zs(i){return{current:i}}function nt(i){0>To||(i.current=yf[To],yf[To]=null,To--)}function et(i,u){To++,yf[To]=i.current,i.current=u}var Ws={},Ht=zs(Ws),sn=zs(!1),Ea=Ws;function Co(i,u){var m=i.type.contextTypes;if(!m)return Ws;var w=i.stateNode;if(w&&w.__reactInternalMemoizedUnmaskedChildContext===u)return w.__reactInternalMemoizedMaskedChildContext;var _={},T;for(T in m)_[T]=u[T];return w&&(i=i.stateNode,i.__reactInternalMemoizedUnmaskedChildContext=u,i.__reactInternalMemoizedMaskedChildContext=_),_}function an(i){return i=i.childContextTypes,i!=null}function zc(){nt(sn),nt(Ht)}function Zk(i,u,m){if(Ht.current!==Ws)throw Error(n(168));et(Ht,u),et(sn,m)}function Jk(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 W({},m,w)}function Wc(i){return i=(i=i.stateNode)&&i.__reactInternalMemoizedMergedChildContext||Ws,Ea=Ht.current,et(Ht,i),et(sn,sn.current),!0}function Qk(i,u,m){var w=i.stateNode;if(!w)throw Error(n(169));m?(i=Jk(i,u,Ea),w.__reactInternalMemoizedMergedChildContext=i,nt(sn),nt(Ht),et(Ht,i)):nt(sn),et(sn,m)}var ss=null,Hc=!1,wf=!1;function e1(i){ss===null?ss=[i]:ss.push(i)}function n4(i){Hc=!0,e1(i)}function Hs(){if(!wf&&ss!==null){wf=!0;var i=0,u=Ve;try{var m=ss;for(Ve=1;i<m.length;i++){var w=m[i];do w=w(!0);while(w!==null)}ss=null,Hc=!1}catch(_){throw ss!==null&&(ss=ss.slice(i+1)),Sr($t,Hs),_}finally{Ve=u,wf=!1}}return null}var Ao=[],Ro=0,Vc=null,Gc=0,$n=[],In=0,Ta=null,as=1,os="";function Ca(i,u){Ao[Ro++]=Gc,Ao[Ro++]=Vc,Vc=i,Gc=u}function t1(i,u,m){$n[In++]=as,$n[In++]=os,$n[In++]=Ta,Ta=i;var w=as;i=os;var _=32-rn(w)-1;w&=~(1<<_),m+=1;var T=32-rn(u)+_;if(30<T){var z=_-_%5;T=(w&(1<<z)-1).toString(32),w>>=z,_-=z,as=1<<32-rn(u)+_|m<<_|w,os=T+i}else as=1<<T|m<<_|w,os=i}function vf(i){i.return!==null&&(Ca(i,1),t1(i,1,0))}function xf(i){for(;i===Vc;)Vc=Ao[--Ro],Ao[Ro]=null,Gc=Ao[--Ro],Ao[Ro]=null;for(;i===Ta;)Ta=$n[--In],$n[In]=null,os=$n[--In],$n[In]=null,as=$n[--In],$n[In]=null}var wn=null,vn=null,st=!1,rr=null;function n1(i,u){var m=Dn(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 r1(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,wn=i,vn=Us(u.firstChild),!0):!1;case 6:return u=i.pendingProps===""||u.nodeType!==3?null:u,u!==null?(i.stateNode=u,wn=i,vn=null,!0):!1;case 13:return u=u.nodeType!==8?null:u,u!==null?(m=Ta!==null?{id:as,overflow:os}:null,i.memoizedState={dehydrated:u,treeContext:m,retryLane:1073741824},m=Dn(18,null,null,0),m.stateNode=u,m.return=i,i.child=m,wn=i,vn=null,!0):!1;default:return!1}}function bf(i){return(i.mode&1)!==0&&(i.flags&128)===0}function kf(i){if(st){var u=vn;if(u){var m=u;if(!r1(i,u)){if(bf(i))throw Error(n(418));u=Us(m.nextSibling);var w=wn;u&&r1(i,u)?n1(w,m):(i.flags=i.flags&-4097|2,st=!1,wn=i)}}else{if(bf(i))throw Error(n(418));i.flags=i.flags&-4097|2,st=!1,wn=i}}}function s1(i){for(i=i.return;i!==null&&i.tag!==5&&i.tag!==3&&i.tag!==13;)i=i.return;wn=i}function Kc(i){if(i!==wn)return!1;if(!st)return s1(i),st=!0,!1;var u;if((u=i.tag!==3)&&!(u=i.tag!==5)&&(u=i.type,u=u!=="head"&&u!=="body"&&!ff(i.type,i.memoizedProps)),u&&(u=vn)){if(bf(i))throw a1(),Error(n(418));for(;u;)n1(i,u),u=Us(u.nextSibling)}if(s1(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){vn=Us(i.nextSibling);break e}u--}else m!=="$"&&m!=="$!"&&m!=="$?"||u++}i=i.nextSibling}vn=null}}else vn=wn?Us(i.stateNode.nextSibling):null;return!0}function a1(){for(var i=vn;i;)i=Us(i.nextSibling)}function Mo(){vn=wn=null,st=!1}function Nf(i){rr===null?rr=[i]:rr.push(i)}var r4=E.ReactCurrentBatchConfig;function ol(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,T=""+i;return u!==null&&u.ref!==null&&typeof u.ref=="function"&&u.ref._stringRef===T?u.ref:(u=function(z){var Q=_.refs;z===null?delete Q[T]:Q[T]=z},u._stringRef=T,u)}if(typeof i!="string")throw Error(n(284));if(!m._owner)throw Error(n(290,i))}return i}function Yc(i,u){throw i=Object.prototype.toString.call(u),Error(n(31,i==="[object Object]"?"object with keys {"+Object.keys(u).join(", ")+"}":i))}function o1(i){var u=i._init;return u(i._payload)}function i1(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=Qs(ie,re),ie.index=0,ie.sibling=null,ie}function T(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=pp(le,ie.mode,je),re.return=ie,re):(re=_(re,le),re.return=ie,re)}function te(ie,re,le,je){var Ce=le.type;return Ce===A?be(ie,re,le.props.children,je,le.key):re!==null&&(re.elementType===Ce||typeof Ce=="object"&&Ce!==null&&Ce.$$typeof===P&&o1(Ce)===re.type)?(je=_(re,le.props),je.ref=ol(ie,re,le),je.return=ie,je):(je=vu(le.type,le.key,le.props,null,ie.mode,je),je.ref=ol(ie,re,le),je.return=ie,je)}function ce(ie,re,le,je){return re===null||re.tag!==4||re.stateNode.containerInfo!==le.containerInfo||re.stateNode.implementation!==le.implementation?(re=mp(le,ie.mode,je),re.return=ie,re):(re=_(re,le.children||[]),re.return=ie,re)}function be(ie,re,le,je,Ce){return re===null||re.tag!==7?(re=Pa(le,ie.mode,je,Ce),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=pp(""+re,ie.mode,le),re.return=ie,re;if(typeof re=="object"&&re!==null){switch(re.$$typeof){case R:return le=vu(re.type,re.key,re.props,null,ie.mode,le),le.ref=ol(ie,null,re),le.return=ie,le;case O:return re=mp(re,ie.mode,le),re.return=ie,re;case P:var je=re._init;return ke(ie,je(re._payload),le)}if(Ne(re)||U(re))return re=Pa(re,ie.mode,le,null),re.return=ie,re;Yc(ie,re)}return null}function xe(ie,re,le,je){var Ce=re!==null?re.key:null;if(typeof le=="string"&&le!==""||typeof le=="number")return Ce!==null?null:Q(ie,re,""+le,je);if(typeof le=="object"&&le!==null){switch(le.$$typeof){case R:return le.key===Ce?te(ie,re,le,je):null;case O:return le.key===Ce?ce(ie,re,le,je):null;case P:return Ce=le._init,xe(ie,re,Ce(le._payload),je)}if(Ne(le)||U(le))return Ce!==null?null:be(ie,re,le,je,null);Yc(ie,le)}return null}function Se(ie,re,le,je,Ce){if(typeof je=="string"&&je!==""||typeof je=="number")return ie=ie.get(le)||null,Q(re,ie,""+je,Ce);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,Ce);case O:return ie=ie.get(je.key===null?le:je.key)||null,ce(re,ie,je,Ce);case P:var Me=je._init;return Se(ie,re,le,Me(je._payload),Ce)}if(Ne(je)||U(je))return ie=ie.get(le)||null,be(re,ie,je,Ce,null);Yc(re,je)}return null}function Ee(ie,re,le,je){for(var Ce=null,Me=null,$e=re,Le=re=0,Lt=null;$e!==null&&Le<le.length;Le++){$e.index>Le?(Lt=$e,$e=null):Lt=$e.sibling;var Ge=xe(ie,$e,le[Le],je);if(Ge===null){$e===null&&($e=Lt);break}i&&$e&&Ge.alternate===null&&u(ie,$e),re=T(Ge,re,Le),Me===null?Ce=Ge:Me.sibling=Ge,Me=Ge,$e=Lt}if(Le===le.length)return m(ie,$e),st&&Ca(ie,Le),Ce;if($e===null){for(;Le<le.length;Le++)$e=ke(ie,le[Le],je),$e!==null&&(re=T($e,re,Le),Me===null?Ce=$e:Me.sibling=$e,Me=$e);return st&&Ca(ie,Le),Ce}for($e=w(ie,$e);Le<le.length;Le++)Lt=Se($e,ie,Le,le[Le],je),Lt!==null&&(i&&Lt.alternate!==null&&$e.delete(Lt.key===null?Le:Lt.key),re=T(Lt,re,Le),Me===null?Ce=Lt:Me.sibling=Lt,Me=Lt);return i&&$e.forEach(function(ea){return u(ie,ea)}),st&&Ca(ie,Le),Ce}function Te(ie,re,le,je){var Ce=U(le);if(typeof Ce!="function")throw Error(n(150));if(le=Ce.call(le),le==null)throw Error(n(151));for(var Me=Ce=null,$e=re,Le=re=0,Lt=null,Ge=le.next();$e!==null&&!Ge.done;Le++,Ge=le.next()){$e.index>Le?(Lt=$e,$e=null):Lt=$e.sibling;var ea=xe(ie,$e,Ge.value,je);if(ea===null){$e===null&&($e=Lt);break}i&&$e&&ea.alternate===null&&u(ie,$e),re=T(ea,re,Le),Me===null?Ce=ea:Me.sibling=ea,Me=ea,$e=Lt}if(Ge.done)return m(ie,$e),st&&Ca(ie,Le),Ce;if($e===null){for(;!Ge.done;Le++,Ge=le.next())Ge=ke(ie,Ge.value,je),Ge!==null&&(re=T(Ge,re,Le),Me===null?Ce=Ge:Me.sibling=Ge,Me=Ge);return st&&Ca(ie,Le),Ce}for($e=w(ie,$e);!Ge.done;Le++,Ge=le.next())Ge=Se($e,ie,Le,Ge.value,je),Ge!==null&&(i&&Ge.alternate!==null&&$e.delete(Ge.key===null?Le:Ge.key),re=T(Ge,re,Le),Me===null?Ce=Ge:Me.sibling=Ge,Me=Ge);return i&&$e.forEach(function(L4){return u(ie,L4)}),st&&Ca(ie,Le),Ce}function vt(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 Ce=le.key,Me=re;Me!==null;){if(Me.key===Ce){if(Ce=le.type,Ce===A){if(Me.tag===7){m(ie,Me.sibling),re=_(Me,le.props.children),re.return=ie,ie=re;break e}}else if(Me.elementType===Ce||typeof Ce=="object"&&Ce!==null&&Ce.$$typeof===P&&o1(Ce)===Me.type){m(ie,Me.sibling),re=_(Me,le.props),re.ref=ol(ie,Me,le),re.return=ie,ie=re;break e}m(ie,Me);break}else u(ie,Me);Me=Me.sibling}le.type===A?(re=Pa(le.props.children,ie.mode,je,le.key),re.return=ie,ie=re):(je=vu(le.type,le.key,le.props,null,ie.mode,je),je.ref=ol(ie,re,le),je.return=ie,ie=je)}return z(ie);case O:e:{for(Me=le.key;re!==null;){if(re.key===Me)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=mp(le,ie.mode,je),re.return=ie,ie=re}return z(ie);case P:return Me=le._init,vt(ie,re,Me(le._payload),je)}if(Ne(le))return Ee(ie,re,le,je);if(U(le))return Te(ie,re,le,je);Yc(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=pp(le,ie.mode,je),re.return=ie,ie=re),z(ie)):m(ie,re)}return vt}var $o=i1(!0),l1=i1(!1),Xc=zs(null),Zc=null,Io=null,jf=null;function Sf(){jf=Io=Zc=null}function _f(i){var u=Xc.current;nt(Xc),i._currentValue=u}function Ef(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 Oo(i,u){Zc=i,jf=Io=null,i=i.dependencies,i!==null&&i.firstContext!==null&&((i.lanes&u)!==0&&(on=!0),i.firstContext=null)}function On(i){var u=i._currentValue;if(jf!==i)if(i={context:i,memoizedValue:u,next:null},Io===null){if(Zc===null)throw Error(n(308));Io=i,Zc.dependencies={lanes:0,firstContext:i}}else Io=Io.next=i;return u}var Aa=null;function Tf(i){Aa===null?Aa=[i]:Aa.push(i)}function c1(i,u,m,w){var _=u.interleaved;return _===null?(m.next=m,Tf(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 Vs=!1;function Cf(i){i.updateQueue={baseState:i.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function u1(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 Gs(i,u,m){var w=i.updateQueue;if(w===null)return null;if(w=w.shared,(We&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,Tf(w)):(u.next=_.next,_.next=u),w.interleaved=u,is(i,m)}function Jc(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,qi(i,m)}}function d1(i,u){var m=i.updateQueue,w=i.alternate;if(w!==null&&(w=w.updateQueue,m===w)){var _=null,T=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};T===null?_=T=z:T=T.next=z,m=m.next}while(m!==null);T===null?_=T=u:T=T.next=u}else _=T=u;m={baseState:w.baseState,firstBaseUpdate:_,lastBaseUpdate:T,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 Qc(i,u,m,w){var _=i.updateQueue;Vs=!1;var T=_.firstBaseUpdate,z=_.lastBaseUpdate,Q=_.shared.pending;if(Q!==null){_.shared.pending=null;var te=Q,ce=te.next;te.next=null,z===null?T=ce:z.next=ce,z=te;var be=i.alternate;be!==null&&(be=be.updateQueue,Q=be.lastBaseUpdate,Q!==z&&(Q===null?be.firstBaseUpdate=ce:Q.next=ce,be.lastBaseUpdate=te))}if(T!==null){var ke=_.baseState;z=0,be=ce=te=null,Q=T;do{var xe=Q.lane,Se=Q.eventTime;if((w&xe)===xe){be!==null&&(be=be.next={eventTime:Se,lane:0,tag:Q.tag,payload:Q.payload,callback:Q.callback,next:null});e:{var Ee=i,Te=Q;switch(xe=u,Se=m,Te.tag){case 1:if(Ee=Te.payload,typeof Ee=="function"){ke=Ee.call(Se,ke,xe);break e}ke=Ee;break e;case 3:Ee.flags=Ee.flags&-65537|128;case 0:if(Ee=Te.payload,xe=typeof Ee=="function"?Ee.call(Se,ke,xe):Ee,xe==null)break e;ke=W({},ke,xe);break e;case 2:Vs=!0}}Q.callback!==null&&Q.lane!==0&&(i.flags|=64,xe=_.effects,xe===null?_.effects=[Q]:xe.push(Q))}else Se={eventTime:Se,lane:xe,tag:Q.tag,payload:Q.payload,callback:Q.callback,next:null},be===null?(ce=be=Se,te=ke):be=be.next=Se,z|=xe;if(Q=Q.next,Q===null){if(Q=_.shared.pending,Q===null)break;xe=Q,Q=xe.next,xe.next=null,_.lastBaseUpdate=xe,_.shared.pending=null}}while(!0);if(be===null&&(te=ke),_.baseState=te,_.firstBaseUpdate=ce,_.lastBaseUpdate=be,u=_.shared.interleaved,u!==null){_=u;do z|=_.lane,_=_.next;while(_!==u)}else T===null&&(_.shared.lanes=0);$a|=z,i.lanes=z,i.memoizedState=ke}}function h1(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 il={},Ir=zs(il),ll=zs(il),cl=zs(il);function Ra(i){if(i===il)throw Error(n(174));return i}function Af(i,u){switch(et(cl,u),et(ll,i),et(Ir,il),i=u.nodeType,i){case 9:case 11:u=(u=u.documentElement)?u.namespaceURI:Ye(null,"");break;default:i=i===8?u.parentNode:u,u=i.namespaceURI||null,i=i.tagName,u=Ye(u,i)}nt(Ir),et(Ir,u)}function Lo(){nt(Ir),nt(ll),nt(cl)}function f1(i){Ra(cl.current);var u=Ra(Ir.current),m=Ye(u,i.type);u!==m&&(et(ll,i),et(Ir,m))}function Rf(i){ll.current===i&&(nt(Ir),nt(ll))}var ct=zs(0);function eu(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 Mf=[];function $f(){for(var i=0;i<Mf.length;i++)Mf[i]._workInProgressVersionPrimary=null;Mf.length=0}var tu=E.ReactCurrentDispatcher,If=E.ReactCurrentBatchConfig,Ma=0,ut=null,_t=null,It=null,nu=!1,ul=!1,dl=0,s4=0;function Vt(){throw Error(n(321))}function Of(i,u){if(u===null)return!1;for(var m=0;m<u.length&&m<i.length;m++)if(!nr(i[m],u[m]))return!1;return!0}function Lf(i,u,m,w,_,T){if(Ma=T,ut=u,u.memoizedState=null,u.updateQueue=null,u.lanes=0,tu.current=i===null||i.memoizedState===null?l4:c4,i=m(w,_),ul){T=0;do{if(ul=!1,dl=0,25<=T)throw Error(n(301));T+=1,It=_t=null,u.updateQueue=null,tu.current=u4,i=m(w,_)}while(ul)}if(tu.current=au,u=_t!==null&&_t.next!==null,Ma=0,It=_t=ut=null,nu=!1,u)throw Error(n(300));return i}function Pf(){var i=dl!==0;return dl=0,i}function Or(){var i={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return It===null?ut.memoizedState=It=i:It=It.next=i,It}function Ln(){if(_t===null){var i=ut.alternate;i=i!==null?i.memoizedState:null}else i=_t.next;var u=It===null?ut.memoizedState:It.next;if(u!==null)It=u,_t=i;else{if(i===null)throw Error(n(310));_t=i,i={memoizedState:_t.memoizedState,baseState:_t.baseState,baseQueue:_t.baseQueue,queue:_t.queue,next:null},It===null?ut.memoizedState=It=i:It=It.next=i}return It}function hl(i,u){return typeof u=="function"?u(i):u}function Df(i){var u=Ln(),m=u.queue;if(m===null)throw Error(n(311));m.lastRenderedReducer=i;var w=_t,_=w.baseQueue,T=m.pending;if(T!==null){if(_!==null){var z=_.next;_.next=T.next,T.next=z}w.baseQueue=_=T,m.pending=null}if(_!==null){T=_.next,w=w.baseState;var Q=z=null,te=null,ce=T;do{var be=ce.lane;if((Ma&be)===be)te!==null&&(te=te.next={lane:0,action:ce.action,hasEagerState:ce.hasEagerState,eagerState:ce.eagerState,next:null}),w=ce.hasEagerState?ce.eagerState:i(w,ce.action);else{var ke={lane:be,action:ce.action,hasEagerState:ce.hasEagerState,eagerState:ce.eagerState,next:null};te===null?(Q=te=ke,z=w):te=te.next=ke,ut.lanes|=be,$a|=be}ce=ce.next}while(ce!==null&&ce!==T);te===null?z=w:te.next=Q,nr(w,u.memoizedState)||(on=!0),u.memoizedState=w,u.baseState=z,u.baseQueue=te,m.lastRenderedState=w}if(i=m.interleaved,i!==null){_=i;do T=_.lane,ut.lanes|=T,$a|=T,_=_.next;while(_!==i)}else _===null&&(m.lanes=0);return[u.memoizedState,m.dispatch]}function Ff(i){var u=Ln(),m=u.queue;if(m===null)throw Error(n(311));m.lastRenderedReducer=i;var w=m.dispatch,_=m.pending,T=u.memoizedState;if(_!==null){m.pending=null;var z=_=_.next;do T=i(T,z.action),z=z.next;while(z!==_);nr(T,u.memoizedState)||(on=!0),u.memoizedState=T,u.baseQueue===null&&(u.baseState=T),m.lastRenderedState=T}return[T,w]}function p1(){}function m1(i,u){var m=ut,w=Ln(),_=u(),T=!nr(w.memoizedState,_);if(T&&(w.memoizedState=_,on=!0),w=w.queue,Bf(w1.bind(null,m,w,i),[i]),w.getSnapshot!==u||T||It!==null&&It.memoizedState.tag&1){if(m.flags|=2048,fl(9,y1.bind(null,m,w,_,u),void 0,null),Ot===null)throw Error(n(349));(Ma&30)!==0||g1(m,u,_)}return _}function g1(i,u,m){i.flags|=16384,i={getSnapshot:u,value:m},u=ut.updateQueue,u===null?(u={lastEffect:null,stores:null},ut.updateQueue=u,u.stores=[i]):(m=u.stores,m===null?u.stores=[i]:m.push(i))}function y1(i,u,m,w){u.value=m,u.getSnapshot=w,v1(u)&&x1(i)}function w1(i,u,m){return m(function(){v1(u)&&x1(i)})}function v1(i){var u=i.getSnapshot;i=i.value;try{var m=u();return!nr(i,m)}catch{return!0}}function x1(i){var u=is(i,1);u!==null&&ir(u,i,1,-1)}function b1(i){var u=Or();return typeof i=="function"&&(i=i()),u.memoizedState=u.baseState=i,i={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:hl,lastRenderedState:i},u.queue=i,i=i.dispatch=i4.bind(null,ut,i),[u.memoizedState,i]}function fl(i,u,m,w){return i={tag:i,create:u,destroy:m,deps:w,next:null},u=ut.updateQueue,u===null?(u={lastEffect:null,stores:null},ut.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 k1(){return Ln().memoizedState}function ru(i,u,m,w){var _=Or();ut.flags|=i,_.memoizedState=fl(1|u,m,void 0,w===void 0?null:w)}function su(i,u,m,w){var _=Ln();w=w===void 0?null:w;var T=void 0;if(_t!==null){var z=_t.memoizedState;if(T=z.destroy,w!==null&&Of(w,z.deps)){_.memoizedState=fl(u,m,T,w);return}}ut.flags|=i,_.memoizedState=fl(1|u,m,T,w)}function N1(i,u){return ru(8390656,8,i,u)}function Bf(i,u){return su(2048,8,i,u)}function j1(i,u){return su(4,2,i,u)}function S1(i,u){return su(4,4,i,u)}function _1(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 E1(i,u,m){return m=m!=null?m.concat([i]):null,su(4,4,_1.bind(null,u,i),m)}function qf(){}function T1(i,u){var m=Ln();u=u===void 0?null:u;var w=m.memoizedState;return w!==null&&u!==null&&Of(u,w[1])?w[0]:(m.memoizedState=[i,u],i)}function C1(i,u){var m=Ln();u=u===void 0?null:u;var w=m.memoizedState;return w!==null&&u!==null&&Of(u,w[1])?w[0]:(i=i(),m.memoizedState=[i,u],i)}function A1(i,u,m){return(Ma&21)===0?(i.baseState&&(i.baseState=!1,on=!0),i.memoizedState=m):(nr(m,u)||(m=Cc(),ut.lanes|=m,$a|=m,i.baseState=!0),u)}function a4(i,u){var m=Ve;Ve=m!==0&&4>m?m:4,i(!0);var w=If.transition;If.transition={};try{i(!1),u()}finally{Ve=m,If.transition=w}}function R1(){return Ln().memoizedState}function o4(i,u,m){var w=Zs(i);if(m={lane:w,action:m,hasEagerState:!1,eagerState:null,next:null},M1(i))$1(u,m);else if(m=c1(i,u,m,w),m!==null){var _=Qt();ir(m,i,w,_),I1(m,u,w)}}function i4(i,u,m){var w=Zs(i),_={lane:w,action:m,hasEagerState:!1,eagerState:null,next:null};if(M1(i))$1(u,_);else{var T=i.alternate;if(i.lanes===0&&(T===null||T.lanes===0)&&(T=u.lastRenderedReducer,T!==null))try{var z=u.lastRenderedState,Q=T(z,m);if(_.hasEagerState=!0,_.eagerState=Q,nr(Q,z)){var te=u.interleaved;te===null?(_.next=_,Tf(u)):(_.next=te.next,te.next=_),u.interleaved=_;return}}catch{}finally{}m=c1(i,u,_,w),m!==null&&(_=Qt(),ir(m,i,w,_),I1(m,u,w))}}function M1(i){var u=i.alternate;return i===ut||u!==null&&u===ut}function $1(i,u){ul=nu=!0;var m=i.pending;m===null?u.next=u:(u.next=m.next,m.next=u),i.pending=u}function I1(i,u,m){if((m&4194240)!==0){var w=u.lanes;w&=i.pendingLanes,m|=w,u.lanes=m,qi(i,m)}}var au={readContext:On,useCallback:Vt,useContext:Vt,useEffect:Vt,useImperativeHandle:Vt,useInsertionEffect:Vt,useLayoutEffect:Vt,useMemo:Vt,useReducer:Vt,useRef:Vt,useState:Vt,useDebugValue:Vt,useDeferredValue:Vt,useTransition:Vt,useMutableSource:Vt,useSyncExternalStore:Vt,useId:Vt,unstable_isNewReconciler:!1},l4={readContext:On,useCallback:function(i,u){return Or().memoizedState=[i,u===void 0?null:u],i},useContext:On,useEffect:N1,useImperativeHandle:function(i,u,m){return m=m!=null?m.concat([i]):null,ru(4194308,4,_1.bind(null,u,i),m)},useLayoutEffect:function(i,u){return ru(4194308,4,i,u)},useInsertionEffect:function(i,u){return ru(4,2,i,u)},useMemo:function(i,u){var m=Or();return u=u===void 0?null:u,i=i(),m.memoizedState=[i,u],i},useReducer:function(i,u,m){var w=Or();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=o4.bind(null,ut,i),[w.memoizedState,i]},useRef:function(i){var u=Or();return i={current:i},u.memoizedState=i},useState:b1,useDebugValue:qf,useDeferredValue:function(i){return Or().memoizedState=i},useTransition:function(){var i=b1(!1),u=i[0];return i=a4.bind(null,i[1]),Or().memoizedState=i,[u,i]},useMutableSource:function(){},useSyncExternalStore:function(i,u,m){var w=ut,_=Or();if(st){if(m===void 0)throw Error(n(407));m=m()}else{if(m=u(),Ot===null)throw Error(n(349));(Ma&30)!==0||g1(w,u,m)}_.memoizedState=m;var T={value:m,getSnapshot:u};return _.queue=T,N1(w1.bind(null,w,T,i),[i]),w.flags|=2048,fl(9,y1.bind(null,w,T,m,u),void 0,null),m},useId:function(){var i=Or(),u=Ot.identifierPrefix;if(st){var m=os,w=as;m=(w&~(1<<32-rn(w)-1)).toString(32)+m,u=":"+u+"R"+m,m=dl++,0<m&&(u+="H"+m.toString(32)),u+=":"}else m=s4++,u=":"+u+"r"+m.toString(32)+":";return i.memoizedState=u},unstable_isNewReconciler:!1},c4={readContext:On,useCallback:T1,useContext:On,useEffect:Bf,useImperativeHandle:E1,useInsertionEffect:j1,useLayoutEffect:S1,useMemo:C1,useReducer:Df,useRef:k1,useState:function(){return Df(hl)},useDebugValue:qf,useDeferredValue:function(i){var u=Ln();return A1(u,_t.memoizedState,i)},useTransition:function(){var i=Df(hl)[0],u=Ln().memoizedState;return[i,u]},useMutableSource:p1,useSyncExternalStore:m1,useId:R1,unstable_isNewReconciler:!1},u4={readContext:On,useCallback:T1,useContext:On,useEffect:Bf,useImperativeHandle:E1,useInsertionEffect:j1,useLayoutEffect:S1,useMemo:C1,useReducer:Ff,useRef:k1,useState:function(){return Ff(hl)},useDebugValue:qf,useDeferredValue:function(i){var u=Ln();return _t===null?u.memoizedState=i:A1(u,_t.memoizedState,i)},useTransition:function(){var i=Ff(hl)[0],u=Ln().memoizedState;return[i,u]},useMutableSource:p1,useSyncExternalStore:m1,useId:R1,unstable_isNewReconciler:!1};function sr(i,u){if(i&&i.defaultProps){u=W({},u),i=i.defaultProps;for(var m in i)u[m]===void 0&&(u[m]=i[m]);return u}return u}function Uf(i,u,m,w){u=i.memoizedState,m=m(w,u),m=m==null?u:W({},u,m),i.memoizedState=m,i.lanes===0&&(i.updateQueue.baseState=m)}var ou={isMounted:function(i){return(i=i._reactInternals)?Rn(i)===i:!1},enqueueSetState:function(i,u,m){i=i._reactInternals;var w=Qt(),_=Zs(i),T=ls(w,_);T.payload=u,m!=null&&(T.callback=m),u=Gs(i,T,_),u!==null&&(ir(u,i,_,w),Jc(u,i,_))},enqueueReplaceState:function(i,u,m){i=i._reactInternals;var w=Qt(),_=Zs(i),T=ls(w,_);T.tag=1,T.payload=u,m!=null&&(T.callback=m),u=Gs(i,T,_),u!==null&&(ir(u,i,_,w),Jc(u,i,_))},enqueueForceUpdate:function(i,u){i=i._reactInternals;var m=Qt(),w=Zs(i),_=ls(m,w);_.tag=2,u!=null&&(_.callback=u),u=Gs(i,_,w),u!==null&&(ir(u,i,w,m),Jc(u,i,w))}};function O1(i,u,m,w,_,T,z){return i=i.stateNode,typeof i.shouldComponentUpdate=="function"?i.shouldComponentUpdate(w,T,z):u.prototype&&u.prototype.isPureReactComponent?!Qi(m,w)||!Qi(_,T):!0}function L1(i,u,m){var w=!1,_=Ws,T=u.contextType;return typeof T=="object"&&T!==null?T=On(T):(_=an(u)?Ea:Ht.current,w=u.contextTypes,T=(w=w!=null)?Co(i,_):Ws),u=new u(m,T),i.memoizedState=u.state!==null&&u.state!==void 0?u.state:null,u.updater=ou,i.stateNode=u,u._reactInternals=i,w&&(i=i.stateNode,i.__reactInternalMemoizedUnmaskedChildContext=_,i.__reactInternalMemoizedMaskedChildContext=T),u}function P1(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&&ou.enqueueReplaceState(u,u.state,null)}function zf(i,u,m,w){var _=i.stateNode;_.props=m,_.state=i.memoizedState,_.refs={},Cf(i);var T=u.contextType;typeof T=="object"&&T!==null?_.context=On(T):(T=an(u)?Ea:Ht.current,_.context=Co(i,T)),_.state=i.memoizedState,T=u.getDerivedStateFromProps,typeof T=="function"&&(Uf(i,u,T,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&&ou.enqueueReplaceState(_,_.state,null),Qc(i,m,_,w),_.state=i.memoizedState),typeof _.componentDidMount=="function"&&(i.flags|=4194308)}function Po(i,u){try{var m="",w=u;do m+=Z(w),w=w.return;while(w);var _=m}catch(T){_=`
39
- Error generating stack: `+T.message+`
40
- `+T.stack}return{value:i,source:u,stack:_,digest:null}}function Wf(i,u,m){return{value:i,source:null,stack:m??null,digest:u??null}}function Hf(i,u){try{console.error(u.value)}catch(m){setTimeout(function(){throw m})}}var d4=typeof WeakMap=="function"?WeakMap:Map;function D1(i,u,m){m=ls(-1,m),m.tag=3,m.payload={element:null};var w=u.value;return m.callback=function(){fu||(fu=!0,op=w),Hf(i,u)},m}function F1(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(){Hf(i,u)}}var T=i.stateNode;return T!==null&&typeof T.componentDidCatch=="function"&&(m.callback=function(){Hf(i,u),typeof w!="function"&&(Ys===null?Ys=new Set([this]):Ys.add(this));var z=u.stack;this.componentDidCatch(u.value,{componentStack:z!==null?z:""})}),m}function B1(i,u,m){var w=i.pingCache;if(w===null){w=i.pingCache=new d4;var _=new Set;w.set(u,_)}else _=w.get(u),_===void 0&&(_=new Set,w.set(u,_));_.has(m)||(_.add(m),i=S4.bind(null,i,u,m),u.then(i,i))}function q1(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 U1(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,Gs(m,u,1))),m.lanes|=1),i):(i.flags|=65536,i.lanes=_,i)}var h4=E.ReactCurrentOwner,on=!1;function Jt(i,u,m,w){u.child=i===null?l1(u,null,m,w):$o(u,i.child,m,w)}function z1(i,u,m,w,_){m=m.render;var T=u.ref;return Oo(u,_),w=Lf(i,u,m,w,T,_),m=Pf(),i!==null&&!on?(u.updateQueue=i.updateQueue,u.flags&=-2053,i.lanes&=~_,cs(i,u,_)):(st&&m&&vf(u),u.flags|=1,Jt(i,u,w,_),u.child)}function W1(i,u,m,w,_){if(i===null){var T=m.type;return typeof T=="function"&&!fp(T)&&T.defaultProps===void 0&&m.compare===null&&m.defaultProps===void 0?(u.tag=15,u.type=T,H1(i,u,T,w,_)):(i=vu(m.type,null,w,u,u.mode,_),i.ref=u.ref,i.return=u,u.child=i)}if(T=i.child,(i.lanes&_)===0){var z=T.memoizedProps;if(m=m.compare,m=m!==null?m:Qi,m(z,w)&&i.ref===u.ref)return cs(i,u,_)}return u.flags|=1,i=Qs(T,w),i.ref=u.ref,i.return=u,u.child=i}function H1(i,u,m,w,_){if(i!==null){var T=i.memoizedProps;if(Qi(T,w)&&i.ref===u.ref)if(on=!1,u.pendingProps=w=T,(i.lanes&_)!==0)(i.flags&131072)!==0&&(on=!0);else return u.lanes=i.lanes,cs(i,u,_)}return Vf(i,u,m,w,_)}function V1(i,u,m){var w=u.pendingProps,_=w.children,T=i!==null?i.memoizedState:null;if(w.mode==="hidden")if((u.mode&1)===0)u.memoizedState={baseLanes:0,cachePool:null,transitions:null},et(Fo,xn),xn|=m;else{if((m&1073741824)===0)return i=T!==null?T.baseLanes|m:m,u.lanes=u.childLanes=1073741824,u.memoizedState={baseLanes:i,cachePool:null,transitions:null},u.updateQueue=null,et(Fo,xn),xn|=i,null;u.memoizedState={baseLanes:0,cachePool:null,transitions:null},w=T!==null?T.baseLanes:m,et(Fo,xn),xn|=w}else T!==null?(w=T.baseLanes|m,u.memoizedState=null):w=m,et(Fo,xn),xn|=w;return Jt(i,u,_,m),u.child}function G1(i,u){var m=u.ref;(i===null&&m!==null||i!==null&&i.ref!==m)&&(u.flags|=512,u.flags|=2097152)}function Vf(i,u,m,w,_){var T=an(m)?Ea:Ht.current;return T=Co(u,T),Oo(u,_),m=Lf(i,u,m,w,T,_),w=Pf(),i!==null&&!on?(u.updateQueue=i.updateQueue,u.flags&=-2053,i.lanes&=~_,cs(i,u,_)):(st&&w&&vf(u),u.flags|=1,Jt(i,u,m,_),u.child)}function K1(i,u,m,w,_){if(an(m)){var T=!0;Wc(u)}else T=!1;if(Oo(u,_),u.stateNode===null)lu(i,u),L1(u,m,w),zf(u,m,w,_),w=!0;else if(i===null){var z=u.stateNode,Q=u.memoizedProps;z.props=Q;var te=z.context,ce=m.contextType;typeof ce=="object"&&ce!==null?ce=On(ce):(ce=an(m)?Ea:Ht.current,ce=Co(u,ce));var be=m.getDerivedStateFromProps,ke=typeof be=="function"||typeof z.getSnapshotBeforeUpdate=="function";ke||typeof z.UNSAFE_componentWillReceiveProps!="function"&&typeof z.componentWillReceiveProps!="function"||(Q!==w||te!==ce)&&P1(u,z,w,ce),Vs=!1;var xe=u.memoizedState;z.state=xe,Qc(u,w,z,_),te=u.memoizedState,Q!==w||xe!==te||sn.current||Vs?(typeof be=="function"&&(Uf(u,m,be,w),te=u.memoizedState),(Q=Vs||O1(u,m,Q,w,xe,te,ce))?(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=ce,w=Q):(typeof z.componentDidMount=="function"&&(u.flags|=4194308),w=!1)}else{z=u.stateNode,u1(i,u),Q=u.memoizedProps,ce=u.type===u.elementType?Q:sr(u.type,Q),z.props=ce,ke=u.pendingProps,xe=z.context,te=m.contextType,typeof te=="object"&&te!==null?te=On(te):(te=an(m)?Ea:Ht.current,te=Co(u,te));var Se=m.getDerivedStateFromProps;(be=typeof Se=="function"||typeof z.getSnapshotBeforeUpdate=="function")||typeof z.UNSAFE_componentWillReceiveProps!="function"&&typeof z.componentWillReceiveProps!="function"||(Q!==ke||xe!==te)&&P1(u,z,w,te),Vs=!1,xe=u.memoizedState,z.state=xe,Qc(u,w,z,_);var Ee=u.memoizedState;Q!==ke||xe!==Ee||sn.current||Vs?(typeof Se=="function"&&(Uf(u,m,Se,w),Ee=u.memoizedState),(ce=Vs||O1(u,m,ce,w,xe,Ee,te)||!1)?(be||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&&xe===i.memoizedState||(u.flags|=4),typeof z.getSnapshotBeforeUpdate!="function"||Q===i.memoizedProps&&xe===i.memoizedState||(u.flags|=1024),u.memoizedProps=w,u.memoizedState=Ee),z.props=w,z.state=Ee,z.context=te,w=ce):(typeof z.componentDidUpdate!="function"||Q===i.memoizedProps&&xe===i.memoizedState||(u.flags|=4),typeof z.getSnapshotBeforeUpdate!="function"||Q===i.memoizedProps&&xe===i.memoizedState||(u.flags|=1024),w=!1)}return Gf(i,u,m,w,T,_)}function Gf(i,u,m,w,_,T){G1(i,u);var z=(u.flags&128)!==0;if(!w&&!z)return _&&Qk(u,m,!1),cs(i,u,T);w=u.stateNode,h4.current=u;var Q=z&&typeof m.getDerivedStateFromError!="function"?null:w.render();return u.flags|=1,i!==null&&z?(u.child=$o(u,i.child,null,T),u.child=$o(u,null,Q,T)):Jt(i,u,Q,T),u.memoizedState=w.state,_&&Qk(u,m,!0),u.child}function Y1(i){var u=i.stateNode;u.pendingContext?Zk(i,u.pendingContext,u.pendingContext!==u.context):u.context&&Zk(i,u.context,!1),Af(i,u.containerInfo)}function X1(i,u,m,w,_){return Mo(),Nf(_),u.flags|=256,Jt(i,u,m,w),u.child}var Kf={dehydrated:null,treeContext:null,retryLane:0};function Yf(i){return{baseLanes:i,cachePool:null,transitions:null}}function Z1(i,u,m){var w=u.pendingProps,_=ct.current,T=!1,z=(u.flags&128)!==0,Q;if((Q=z)||(Q=i!==null&&i.memoizedState===null?!1:(_&2)!==0),Q?(T=!0,u.flags&=-129):(i===null||i.memoizedState!==null)&&(_|=1),et(ct,_&1),i===null)return kf(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,T?(w=u.mode,T=u.child,z={mode:"hidden",children:z},(w&1)===0&&T!==null?(T.childLanes=0,T.pendingProps=z):T=xu(z,w,0,null),i=Pa(i,w,m,null),T.return=u,i.return=u,T.sibling=i,u.child=T,u.child.memoizedState=Yf(m),u.memoizedState=Kf,i):Xf(u,z));if(_=i.memoizedState,_!==null&&(Q=_.dehydrated,Q!==null))return f4(i,u,z,w,Q,_,m);if(T){T=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=Qs(_,te),w.subtreeFlags=_.subtreeFlags&14680064),Q!==null?T=Qs(Q,T):(T=Pa(T,z,m,null),T.flags|=2),T.return=u,w.return=u,w.sibling=T,u.child=w,w=T,T=u.child,z=i.child.memoizedState,z=z===null?Yf(m):{baseLanes:z.baseLanes|m,cachePool:null,transitions:z.transitions},T.memoizedState=z,T.childLanes=i.childLanes&~m,u.memoizedState=Kf,w}return T=i.child,i=T.sibling,w=Qs(T,{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 Xf(i,u){return u=xu({mode:"visible",children:u},i.mode,0,null),u.return=i,i.child=u}function iu(i,u,m,w){return w!==null&&Nf(w),$o(u,i.child,null,m),i=Xf(u,u.pendingProps.children),i.flags|=2,u.memoizedState=null,i}function f4(i,u,m,w,_,T,z){if(m)return u.flags&256?(u.flags&=-257,w=Wf(Error(n(422))),iu(i,u,z,w)):u.memoizedState!==null?(u.child=i.child,u.flags|=128,null):(T=w.fallback,_=u.mode,w=xu({mode:"visible",children:w.children},_,0,null),T=Pa(T,_,z,null),T.flags|=2,w.return=u,T.return=u,w.sibling=T,u.child=w,(u.mode&1)!==0&&$o(u,i.child,null,z),u.child.memoizedState=Yf(z),u.memoizedState=Kf,T);if((u.mode&1)===0)return iu(i,u,z,null);if(_.data==="$!"){if(w=_.nextSibling&&_.nextSibling.dataset,w)var Q=w.dgst;return w=Q,T=Error(n(419)),w=Wf(T,w,void 0),iu(i,u,z,w)}if(Q=(z&i.childLanes)!==0,on||Q){if(w=Ot,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&&_!==T.retryLane&&(T.retryLane=_,is(i,_),ir(w,i,_,-1))}return hp(),w=Wf(Error(n(421))),iu(i,u,z,w)}return _.data==="$?"?(u.flags|=128,u.child=i.child,u=_4.bind(null,i),_._reactRetry=u,null):(i=T.treeContext,vn=Us(_.nextSibling),wn=u,st=!0,rr=null,i!==null&&($n[In++]=as,$n[In++]=os,$n[In++]=Ta,as=i.id,os=i.overflow,Ta=u),u=Xf(u,w.children),u.flags|=4096,u)}function J1(i,u,m){i.lanes|=u;var w=i.alternate;w!==null&&(w.lanes|=u),Ef(i.return,u,m)}function Zf(i,u,m,w,_){var T=i.memoizedState;T===null?i.memoizedState={isBackwards:u,rendering:null,renderingStartTime:0,last:w,tail:m,tailMode:_}:(T.isBackwards=u,T.rendering=null,T.renderingStartTime=0,T.last=w,T.tail=m,T.tailMode=_)}function Q1(i,u,m){var w=u.pendingProps,_=w.revealOrder,T=w.tail;if(Jt(i,u,w.children,m),w=ct.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&&J1(i,m,u);else if(i.tag===19)J1(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(ct,w),(u.mode&1)===0)u.memoizedState=null;else switch(_){case"forwards":for(m=u.child,_=null;m!==null;)i=m.alternate,i!==null&&eu(i)===null&&(_=m),m=m.sibling;m=_,m===null?(_=u.child,u.child=null):(_=m.sibling,m.sibling=null),Zf(u,!1,_,m,T);break;case"backwards":for(m=null,_=u.child,u.child=null;_!==null;){if(i=_.alternate,i!==null&&eu(i)===null){u.child=_;break}i=_.sibling,_.sibling=m,m=_,_=i}Zf(u,!0,m,null,T);break;case"together":Zf(u,!1,null,null,void 0);break;default:u.memoizedState=null}return u.child}function lu(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),$a|=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=Qs(i,i.pendingProps),u.child=m,m.return=u;i.sibling!==null;)i=i.sibling,m=m.sibling=Qs(i,i.pendingProps),m.return=u;m.sibling=null}return u.child}function p4(i,u,m){switch(u.tag){case 3:Y1(u),Mo();break;case 5:f1(u);break;case 1:an(u.type)&&Wc(u);break;case 4:Af(u,u.stateNode.containerInfo);break;case 10:var w=u.type._context,_=u.memoizedProps.value;et(Xc,w._currentValue),w._currentValue=_;break;case 13:if(w=u.memoizedState,w!==null)return w.dehydrated!==null?(et(ct,ct.current&1),u.flags|=128,null):(m&u.child.childLanes)!==0?Z1(i,u,m):(et(ct,ct.current&1),i=cs(i,u,m),i!==null?i.sibling:null);et(ct,ct.current&1);break;case 19:if(w=(m&u.childLanes)!==0,(i.flags&128)!==0){if(w)return Q1(i,u,m);u.flags|=128}if(_=u.memoizedState,_!==null&&(_.rendering=null,_.tail=null,_.lastEffect=null),et(ct,ct.current),w)break;return null;case 22:case 23:return u.lanes=0,V1(i,u,m)}return cs(i,u,m)}var eN,Jf,tN,nN;eN=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}},Jf=function(){},tN=function(i,u,m,w){var _=i.memoizedProps;if(_!==w){i=u.stateNode,Ra(Ir.current);var T=null;switch(m){case"input":_=me(i,_),w=me(i,w),T=[];break;case"select":_=W({},_,{value:void 0}),w=W({},w,{value:void 0}),T=[];break;case"textarea":_=Ie(i,_),w=Ie(i,w),T=[];break;default:typeof _.onClick!="function"&&typeof w.onClick=="function"&&(i.onclick=qc)}Mt(m,w);var z;m=null;for(ce in _)if(!w.hasOwnProperty(ce)&&_.hasOwnProperty(ce)&&_[ce]!=null)if(ce==="style"){var Q=_[ce];for(z in Q)Q.hasOwnProperty(z)&&(m||(m={}),m[z]="")}else ce!=="dangerouslySetInnerHTML"&&ce!=="children"&&ce!=="suppressContentEditableWarning"&&ce!=="suppressHydrationWarning"&&ce!=="autoFocus"&&(s.hasOwnProperty(ce)?T||(T=[]):(T=T||[]).push(ce,null));for(ce in w){var te=w[ce];if(Q=_!=null?_[ce]:void 0,w.hasOwnProperty(ce)&&te!==Q&&(te!=null||Q!=null))if(ce==="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||(T||(T=[]),T.push(ce,m)),m=te;else ce==="dangerouslySetInnerHTML"?(te=te?te.__html:void 0,Q=Q?Q.__html:void 0,te!=null&&Q!==te&&(T=T||[]).push(ce,te)):ce==="children"?typeof te!="string"&&typeof te!="number"||(T=T||[]).push(ce,""+te):ce!=="suppressContentEditableWarning"&&ce!=="suppressHydrationWarning"&&(s.hasOwnProperty(ce)?(te!=null&&ce==="onScroll"&&tt("scroll",i),T||Q===te||(T=[])):(T=T||[]).push(ce,te))}m&&(T=T||[]).push("style",m);var ce=T;(u.updateQueue=ce)&&(u.flags|=4)}},nN=function(i,u,m,w){m!==w&&(u.flags|=4)};function pl(i,u){if(!st)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 Gt(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 m4(i,u,m){var w=u.pendingProps;switch(xf(u),u.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Gt(u),null;case 1:return an(u.type)&&zc(),Gt(u),null;case 3:return w=u.stateNode,Lo(),nt(sn),nt(Ht),$f(),w.pendingContext&&(w.context=w.pendingContext,w.pendingContext=null),(i===null||i.child===null)&&(Kc(u)?u.flags|=4:i===null||i.memoizedState.isDehydrated&&(u.flags&256)===0||(u.flags|=1024,rr!==null&&(cp(rr),rr=null))),Jf(i,u),Gt(u),null;case 5:Rf(u);var _=Ra(cl.current);if(m=u.type,i!==null&&u.stateNode!=null)tN(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 Gt(u),null}if(i=Ra(Ir.current),Kc(u)){w=u.stateNode,m=u.type;var T=u.memoizedProps;switch(w[$r]=u,w[sl]=T,i=(u.mode&1)!==0,m){case"dialog":tt("cancel",w),tt("close",w);break;case"iframe":case"object":case"embed":tt("load",w);break;case"video":case"audio":for(_=0;_<tl.length;_++)tt(tl[_],w);break;case"source":tt("error",w);break;case"img":case"image":case"link":tt("error",w),tt("load",w);break;case"details":tt("toggle",w);break;case"input":pe(w,T),tt("invalid",w);break;case"select":w._wrapperState={wasMultiple:!!T.multiple},tt("invalid",w);break;case"textarea":Pe(w,T),tt("invalid",w)}Mt(m,T),_=null;for(var z in T)if(T.hasOwnProperty(z)){var Q=T[z];z==="children"?typeof Q=="string"?w.textContent!==Q&&(T.suppressHydrationWarning!==!0&&Bc(w.textContent,Q,i),_=["children",Q]):typeof Q=="number"&&w.textContent!==""+Q&&(T.suppressHydrationWarning!==!0&&Bc(w.textContent,Q,i),_=["children",""+Q]):s.hasOwnProperty(z)&&Q!=null&&z==="onScroll"&&tt("scroll",w)}switch(m){case"input":ge(w),ne(w,T,!0);break;case"textarea":ge(w),Oe(w);break;case"select":case"option":break;default:typeof T.onClick=="function"&&(w.onclick=qc)}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[$r]=u,i[sl]=w,eN(i,u,!1,!1),u.stateNode=i;e:{switch(z=lt(m,w),m){case"dialog":tt("cancel",i),tt("close",i),_=w;break;case"iframe":case"object":case"embed":tt("load",i),_=w;break;case"video":case"audio":for(_=0;_<tl.length;_++)tt(tl[_],i);_=w;break;case"source":tt("error",i),_=w;break;case"img":case"image":case"link":tt("error",i),tt("load",i),_=w;break;case"details":tt("toggle",i),_=w;break;case"input":pe(i,w),_=me(i,w),tt("invalid",i);break;case"option":_=w;break;case"select":i._wrapperState={wasMultiple:!!w.multiple},_=W({},w,{value:void 0}),tt("invalid",i);break;case"textarea":Pe(i,w),_=Ie(i,w),tt("invalid",i);break;default:_=w}Mt(m,_),Q=_;for(T in Q)if(Q.hasOwnProperty(T)){var te=Q[T];T==="style"?ht(i,te):T==="dangerouslySetInnerHTML"?(te=te?te.__html:void 0,te!=null&&ot(i,te)):T==="children"?typeof te=="string"?(m!=="textarea"||te!=="")&&it(i,te):typeof te=="number"&&it(i,""+te):T!=="suppressContentEditableWarning"&&T!=="suppressHydrationWarning"&&T!=="autoFocus"&&(s.hasOwnProperty(T)?te!=null&&T==="onScroll"&&tt("scroll",i):te!=null&&S(i,T,te,z))}switch(m){case"input":ge(i),ne(i,w,!1);break;case"textarea":ge(i),Oe(i);break;case"option":w.value!=null&&i.setAttribute("value",""+ee(w.value));break;case"select":i.multiple=!!w.multiple,T=w.value,T!=null?we(i,!!w.multiple,T,!1):w.defaultValue!=null&&we(i,!!w.multiple,w.defaultValue,!0);break;default:typeof _.onClick=="function"&&(i.onclick=qc)}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 Gt(u),null;case 6:if(i&&u.stateNode!=null)nN(i,u,i.memoizedProps,w);else{if(typeof w!="string"&&u.stateNode===null)throw Error(n(166));if(m=Ra(cl.current),Ra(Ir.current),Kc(u)){if(w=u.stateNode,m=u.memoizedProps,w[$r]=u,(T=w.nodeValue!==m)&&(i=wn,i!==null))switch(i.tag){case 3:Bc(w.nodeValue,m,(i.mode&1)!==0);break;case 5:i.memoizedProps.suppressHydrationWarning!==!0&&Bc(w.nodeValue,m,(i.mode&1)!==0)}T&&(u.flags|=4)}else w=(m.nodeType===9?m:m.ownerDocument).createTextNode(w),w[$r]=u,u.stateNode=w}return Gt(u),null;case 13:if(nt(ct),w=u.memoizedState,i===null||i.memoizedState!==null&&i.memoizedState.dehydrated!==null){if(st&&vn!==null&&(u.mode&1)!==0&&(u.flags&128)===0)a1(),Mo(),u.flags|=98560,T=!1;else if(T=Kc(u),w!==null&&w.dehydrated!==null){if(i===null){if(!T)throw Error(n(318));if(T=u.memoizedState,T=T!==null?T.dehydrated:null,!T)throw Error(n(317));T[$r]=u}else Mo(),(u.flags&128)===0&&(u.memoizedState=null),u.flags|=4;Gt(u),T=!1}else rr!==null&&(cp(rr),rr=null),T=!0;if(!T)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||(ct.current&1)!==0?Et===0&&(Et=3):hp())),u.updateQueue!==null&&(u.flags|=4),Gt(u),null);case 4:return Lo(),Jf(i,u),i===null&&nl(u.stateNode.containerInfo),Gt(u),null;case 10:return _f(u.type._context),Gt(u),null;case 17:return an(u.type)&&zc(),Gt(u),null;case 19:if(nt(ct),T=u.memoizedState,T===null)return Gt(u),null;if(w=(u.flags&128)!==0,z=T.rendering,z===null)if(w)pl(T,!1);else{if(Et!==0||i!==null&&(i.flags&128)!==0)for(i=u.child;i!==null;){if(z=eu(i),z!==null){for(u.flags|=128,pl(T,!1),w=z.updateQueue,w!==null&&(u.updateQueue=w,u.flags|=4),u.subtreeFlags=0,w=m,m=u.child;m!==null;)T=m,i=w,T.flags&=14680066,z=T.alternate,z===null?(T.childLanes=0,T.lanes=i,T.child=null,T.subtreeFlags=0,T.memoizedProps=null,T.memoizedState=null,T.updateQueue=null,T.dependencies=null,T.stateNode=null):(T.childLanes=z.childLanes,T.lanes=z.lanes,T.child=z.child,T.subtreeFlags=0,T.deletions=null,T.memoizedProps=z.memoizedProps,T.memoizedState=z.memoizedState,T.updateQueue=z.updateQueue,T.type=z.type,i=z.dependencies,T.dependencies=i===null?null:{lanes:i.lanes,firstContext:i.firstContext}),m=m.sibling;return et(ct,ct.current&1|2),u.child}i=i.sibling}T.tail!==null&&Re()>Bo&&(u.flags|=128,w=!0,pl(T,!1),u.lanes=4194304)}else{if(!w)if(i=eu(z),i!==null){if(u.flags|=128,w=!0,m=i.updateQueue,m!==null&&(u.updateQueue=m,u.flags|=4),pl(T,!0),T.tail===null&&T.tailMode==="hidden"&&!z.alternate&&!st)return Gt(u),null}else 2*Re()-T.renderingStartTime>Bo&&m!==1073741824&&(u.flags|=128,w=!0,pl(T,!1),u.lanes=4194304);T.isBackwards?(z.sibling=u.child,u.child=z):(m=T.last,m!==null?m.sibling=z:u.child=z,T.last=z)}return T.tail!==null?(u=T.tail,T.rendering=u,T.tail=u.sibling,T.renderingStartTime=Re(),u.sibling=null,m=ct.current,et(ct,w?m&1|2:m&1),u):(Gt(u),null);case 22:case 23:return dp(),w=u.memoizedState!==null,i!==null&&i.memoizedState!==null!==w&&(u.flags|=8192),w&&(u.mode&1)!==0?(xn&1073741824)!==0&&(Gt(u),u.subtreeFlags&6&&(u.flags|=8192)):Gt(u),null;case 24:return null;case 25:return null}throw Error(n(156,u.tag))}function g4(i,u){switch(xf(u),u.tag){case 1:return an(u.type)&&zc(),i=u.flags,i&65536?(u.flags=i&-65537|128,u):null;case 3:return Lo(),nt(sn),nt(Ht),$f(),i=u.flags,(i&65536)!==0&&(i&128)===0?(u.flags=i&-65537|128,u):null;case 5:return Rf(u),null;case 13:if(nt(ct),i=u.memoizedState,i!==null&&i.dehydrated!==null){if(u.alternate===null)throw Error(n(340));Mo()}return i=u.flags,i&65536?(u.flags=i&-65537|128,u):null;case 19:return nt(ct),null;case 4:return Lo(),null;case 10:return _f(u.type._context),null;case 22:case 23:return dp(),null;case 24:return null;default:return null}}var cu=!1,Kt=!1,y4=typeof WeakSet=="function"?WeakSet:Set,_e=null;function Do(i,u){var m=i.ref;if(m!==null)if(typeof m=="function")try{m(null)}catch(w){pt(i,u,w)}else m.current=null}function Qf(i,u,m){try{m()}catch(w){pt(i,u,w)}}var rN=!1;function w4(i,u){if(df=ba,i=Ok(),nf(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,T=w.focusNode;w=w.focusOffset;try{m.nodeType,T.nodeType}catch{m=null;break e}var z=0,Q=-1,te=-1,ce=0,be=0,ke=i,xe=null;t:for(;;){for(var Se;ke!==m||_!==0&&ke.nodeType!==3||(Q=z+_),ke!==T||w!==0&&ke.nodeType!==3||(te=z+w),ke.nodeType===3&&(z+=ke.nodeValue.length),(Se=ke.firstChild)!==null;)xe=ke,ke=Se;for(;;){if(ke===i)break t;if(xe===m&&++ce===_&&(Q=z),xe===T&&++be===w&&(te=z),(Se=ke.nextSibling)!==null)break;ke=xe,xe=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(hf={focusedElem:i,selectionRange:m},ba=!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 Te=Ee.memoizedProps,vt=Ee.memoizedState,ie=u.stateNode,re=ie.getSnapshotBeforeUpdate(u.elementType===u.type?Te:sr(u.type,Te),vt);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){pt(u,u.return,je)}if(i=u.sibling,i!==null){i.return=u.return,_e=i;break}_e=u.return}return Ee=rN,rN=!1,Ee}function ml(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 T=_.destroy;_.destroy=void 0,T!==void 0&&Qf(u,m,T)}_=_.next}while(_!==w)}}function uu(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 ep(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 sN(i){var u=i.alternate;u!==null&&(i.alternate=null,sN(u)),i.child=null,i.deletions=null,i.sibling=null,i.tag===5&&(u=i.stateNode,u!==null&&(delete u[$r],delete u[sl],delete u[gf],delete u[e4],delete u[t4])),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 aN(i){return i.tag===5||i.tag===3||i.tag===4}function oN(i){e:for(;;){for(;i.sibling===null;){if(i.return===null||aN(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 tp(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=qc));else if(w!==4&&(i=i.child,i!==null))for(tp(i,u,m),i=i.sibling;i!==null;)tp(i,u,m),i=i.sibling}function np(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(np(i,u,m),i=i.sibling;i!==null;)np(i,u,m),i=i.sibling}var Bt=null,ar=!1;function Ks(i,u,m){for(m=m.child;m!==null;)iN(i,u,m),m=m.sibling}function iN(i,u,m){if(Xt&&typeof Xt.onCommitFiberUnmount=="function")try{Xt.onCommitFiberUnmount(yn,m)}catch{}switch(m.tag){case 5:Kt||Do(m,u);case 6:var w=Bt,_=ar;Bt=null,Ks(i,u,m),Bt=w,ar=_,Bt!==null&&(ar?(i=Bt,m=m.stateNode,i.nodeType===8?i.parentNode.removeChild(m):i.removeChild(m)):Bt.removeChild(m.stateNode));break;case 18:Bt!==null&&(ar?(i=Bt,m=m.stateNode,i.nodeType===8?mf(i.parentNode,m):i.nodeType===1&&mf(i,m),Fs(i)):mf(Bt,m.stateNode));break;case 4:w=Bt,_=ar,Bt=m.stateNode.containerInfo,ar=!0,Ks(i,u,m),Bt=w,ar=_;break;case 0:case 11:case 14:case 15:if(!Kt&&(w=m.updateQueue,w!==null&&(w=w.lastEffect,w!==null))){_=w=w.next;do{var T=_,z=T.destroy;T=T.tag,z!==void 0&&((T&2)!==0||(T&4)!==0)&&Qf(m,u,z),_=_.next}while(_!==w)}Ks(i,u,m);break;case 1:if(!Kt&&(Do(m,u),w=m.stateNode,typeof w.componentWillUnmount=="function"))try{w.props=m.memoizedProps,w.state=m.memoizedState,w.componentWillUnmount()}catch(Q){pt(m,u,Q)}Ks(i,u,m);break;case 21:Ks(i,u,m);break;case 22:m.mode&1?(Kt=(w=Kt)||m.memoizedState!==null,Ks(i,u,m),Kt=w):Ks(i,u,m);break;default:Ks(i,u,m)}}function lN(i){var u=i.updateQueue;if(u!==null){i.updateQueue=null;var m=i.stateNode;m===null&&(m=i.stateNode=new y4),u.forEach(function(w){var _=E4.bind(null,i,w);m.has(w)||(m.add(w),w.then(_,_))})}}function or(i,u){var m=u.deletions;if(m!==null)for(var w=0;w<m.length;w++){var _=m[w];try{var T=i,z=u,Q=z;e:for(;Q!==null;){switch(Q.tag){case 5:Bt=Q.stateNode,ar=!1;break e;case 3:Bt=Q.stateNode.containerInfo,ar=!0;break e;case 4:Bt=Q.stateNode.containerInfo,ar=!0;break e}Q=Q.return}if(Bt===null)throw Error(n(160));iN(T,z,_),Bt=null,ar=!1;var te=_.alternate;te!==null&&(te.return=null),_.return=null}catch(ce){pt(_,u,ce)}}if(u.subtreeFlags&12854)for(u=u.child;u!==null;)cN(u,i),u=u.sibling}function cN(i,u){var m=i.alternate,w=i.flags;switch(i.tag){case 0:case 11:case 14:case 15:if(or(u,i),Lr(i),w&4){try{ml(3,i,i.return),uu(3,i)}catch(Te){pt(i,i.return,Te)}try{ml(5,i,i.return)}catch(Te){pt(i,i.return,Te)}}break;case 1:or(u,i),Lr(i),w&512&&m!==null&&Do(m,m.return);break;case 5:if(or(u,i),Lr(i),w&512&&m!==null&&Do(m,m.return),i.flags&32){var _=i.stateNode;try{it(_,"")}catch(Te){pt(i,i.return,Te)}}if(w&4&&(_=i.stateNode,_!=null)){var T=i.memoizedProps,z=m!==null?m.memoizedProps:T,Q=i.type,te=i.updateQueue;if(i.updateQueue=null,te!==null)try{Q==="input"&&T.type==="radio"&&T.name!=null&&de(_,T),lt(Q,z);var ce=lt(Q,T);for(z=0;z<te.length;z+=2){var be=te[z],ke=te[z+1];be==="style"?ht(_,ke):be==="dangerouslySetInnerHTML"?ot(_,ke):be==="children"?it(_,ke):S(_,be,ke,ce)}switch(Q){case"input":fe(_,T);break;case"textarea":Be(_,T);break;case"select":var xe=_._wrapperState.wasMultiple;_._wrapperState.wasMultiple=!!T.multiple;var Se=T.value;Se!=null?we(_,!!T.multiple,Se,!1):xe!==!!T.multiple&&(T.defaultValue!=null?we(_,!!T.multiple,T.defaultValue,!0):we(_,!!T.multiple,T.multiple?[]:"",!1))}_[sl]=T}catch(Te){pt(i,i.return,Te)}}break;case 6:if(or(u,i),Lr(i),w&4){if(i.stateNode===null)throw Error(n(162));_=i.stateNode,T=i.memoizedProps;try{_.nodeValue=T}catch(Te){pt(i,i.return,Te)}}break;case 3:if(or(u,i),Lr(i),w&4&&m!==null&&m.memoizedState.isDehydrated)try{Fs(u.containerInfo)}catch(Te){pt(i,i.return,Te)}break;case 4:or(u,i),Lr(i);break;case 13:or(u,i),Lr(i),_=i.child,_.flags&8192&&(T=_.memoizedState!==null,_.stateNode.isHidden=T,!T||_.alternate!==null&&_.alternate.memoizedState!==null||(ap=Re())),w&4&&lN(i);break;case 22:if(be=m!==null&&m.memoizedState!==null,i.mode&1?(Kt=(ce=Kt)||be,or(u,i),Kt=ce):or(u,i),Lr(i),w&8192){if(ce=i.memoizedState!==null,(i.stateNode.isHidden=ce)&&!be&&(i.mode&1)!==0)for(_e=i,be=i.child;be!==null;){for(ke=_e=be;_e!==null;){switch(xe=_e,Se=xe.child,xe.tag){case 0:case 11:case 14:case 15:ml(4,xe,xe.return);break;case 1:Do(xe,xe.return);var Ee=xe.stateNode;if(typeof Ee.componentWillUnmount=="function"){w=xe,m=xe.return;try{u=w,Ee.props=u.memoizedProps,Ee.state=u.memoizedState,Ee.componentWillUnmount()}catch(Te){pt(w,m,Te)}}break;case 5:Do(xe,xe.return);break;case 22:if(xe.memoizedState!==null){hN(ke);continue}}Se!==null?(Se.return=xe,_e=Se):hN(ke)}be=be.sibling}e:for(be=null,ke=i;;){if(ke.tag===5){if(be===null){be=ke;try{_=ke.stateNode,ce?(T=_.style,typeof T.setProperty=="function"?T.setProperty("display","none","important"):T.display="none"):(Q=ke.stateNode,te=ke.memoizedProps.style,z=te!=null&&te.hasOwnProperty("display")?te.display:null,Q.style.display=ze("display",z))}catch(Te){pt(i,i.return,Te)}}}else if(ke.tag===6){if(be===null)try{ke.stateNode.nodeValue=ce?"":ke.memoizedProps}catch(Te){pt(i,i.return,Te)}}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;be===ke&&(be=null),ke=ke.return}be===ke&&(be=null),ke.sibling.return=ke.return,ke=ke.sibling}}break;case 19:or(u,i),Lr(i),w&4&&lN(i);break;case 21:break;default:or(u,i),Lr(i)}}function Lr(i){var u=i.flags;if(u&2){try{e:{for(var m=i.return;m!==null;){if(aN(m)){var w=m;break e}m=m.return}throw Error(n(160))}switch(w.tag){case 5:var _=w.stateNode;w.flags&32&&(it(_,""),w.flags&=-33);var T=oN(i);np(i,T,_);break;case 3:case 4:var z=w.stateNode.containerInfo,Q=oN(i);tp(i,Q,z);break;default:throw Error(n(161))}}catch(te){pt(i,i.return,te)}i.flags&=-3}u&4096&&(i.flags&=-4097)}function v4(i,u,m){_e=i,uN(i)}function uN(i,u,m){for(var w=(i.mode&1)!==0;_e!==null;){var _=_e,T=_.child;if(_.tag===22&&w){var z=_.memoizedState!==null||cu;if(!z){var Q=_.alternate,te=Q!==null&&Q.memoizedState!==null||Kt;Q=cu;var ce=Kt;if(cu=z,(Kt=te)&&!ce)for(_e=_;_e!==null;)z=_e,te=z.child,z.tag===22&&z.memoizedState!==null?fN(_):te!==null?(te.return=z,_e=te):fN(_);for(;T!==null;)_e=T,uN(T),T=T.sibling;_e=_,cu=Q,Kt=ce}dN(i)}else(_.subtreeFlags&8772)!==0&&T!==null?(T.return=_,_e=T):dN(i)}}function dN(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:Kt||uu(5,u);break;case 1:var w=u.stateNode;if(u.flags&4&&!Kt)if(m===null)w.componentDidMount();else{var _=u.elementType===u.type?m.memoizedProps:sr(u.type,m.memoizedProps);w.componentDidUpdate(_,m.memoizedState,w.__reactInternalSnapshotBeforeUpdate)}var T=u.updateQueue;T!==null&&h1(u,T,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}h1(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 ce=u.alternate;if(ce!==null){var be=ce.memoizedState;if(be!==null){var ke=be.dehydrated;ke!==null&&Fs(ke)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}Kt||u.flags&512&&ep(u)}catch(xe){pt(u,u.return,xe)}}if(u===i){_e=null;break}if(m=u.sibling,m!==null){m.return=u.return,_e=m;break}_e=u.return}}function hN(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 fN(i){for(;_e!==null;){var u=_e;try{switch(u.tag){case 0:case 11:case 15:var m=u.return;try{uu(4,u)}catch(te){pt(u,m,te)}break;case 1:var w=u.stateNode;if(typeof w.componentDidMount=="function"){var _=u.return;try{w.componentDidMount()}catch(te){pt(u,_,te)}}var T=u.return;try{ep(u)}catch(te){pt(u,T,te)}break;case 5:var z=u.return;try{ep(u)}catch(te){pt(u,z,te)}}}catch(te){pt(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 x4=Math.ceil,du=E.ReactCurrentDispatcher,rp=E.ReactCurrentOwner,Pn=E.ReactCurrentBatchConfig,We=0,Ot=null,kt=null,qt=0,xn=0,Fo=zs(0),Et=0,gl=null,$a=0,hu=0,sp=0,yl=null,ln=null,ap=0,Bo=1/0,us=null,fu=!1,op=null,Ys=null,pu=!1,Xs=null,mu=0,wl=0,ip=null,gu=-1,yu=0;function Qt(){return(We&6)!==0?Re():gu!==-1?gu:gu=Re()}function Zs(i){return(i.mode&1)===0?1:(We&2)!==0&&qt!==0?qt&-qt:r4.transition!==null?(yu===0&&(yu=Cc()),yu):(i=Ve,i!==0||(i=window.event,i=i===void 0?16:Rc(i.type)),i)}function ir(i,u,m,w){if(50<wl)throw wl=0,ip=null,Error(n(185));Os(i,m,w),((We&2)===0||i!==Ot)&&(i===Ot&&((We&2)===0&&(hu|=m),Et===4&&Js(i,qt)),cn(i,w),m===1&&We===0&&(u.mode&1)===0&&(Bo=Re()+500,Hc&&Hs()))}function cn(i,u){var m=i.callbackNode;Xr(i,u);var w=Is(i,i===Ot?qt:0);if(w===0)m!==null&&Kr(m),i.callbackNode=null,i.callbackPriority=0;else if(u=w&-w,i.callbackPriority!==u){if(m!=null&&Kr(m),u===1)i.tag===0?n4(mN.bind(null,i)):e1(mN.bind(null,i)),J3(function(){(We&6)===0&&Hs()}),m=null;else{switch(Ui(w)){case 1:m=$t;break;case 4:m=tr;break;case 16:m=Yt;break;case 536870912:m=Ms;break;default:m=Yt}m=NN(m,pN.bind(null,i))}i.callbackPriority=u,i.callbackNode=m}}function pN(i,u){if(gu=-1,yu=0,(We&6)!==0)throw Error(n(327));var m=i.callbackNode;if(qo()&&i.callbackNode!==m)return null;var w=Is(i,i===Ot?qt:0);if(w===0)return null;if((w&30)!==0||(w&i.expiredLanes)!==0||u)u=wu(i,w);else{u=w;var _=We;We|=2;var T=yN();(Ot!==i||qt!==u)&&(us=null,Bo=Re()+500,Oa(i,u));do try{N4();break}catch(Q){gN(i,Q)}while(!0);Sf(),du.current=T,We=_,kt!==null?u=0:(Ot=null,qt=0,u=Et)}if(u!==0){if(u===2&&(_=Fi(i),_!==0&&(w=_,u=lp(i,_))),u===1)throw m=gl,Oa(i,0),Js(i,w),cn(i,Re()),m;if(u===6)Js(i,w);else{if(_=i.current.alternate,(w&30)===0&&!b4(_)&&(u=wu(i,w),u===2&&(T=Fi(i),T!==0&&(w=T,u=lp(i,T))),u===1))throw m=gl,Oa(i,0),Js(i,w),cn(i,Re()),m;switch(i.finishedWork=_,i.finishedLanes=w,u){case 0:case 1:throw Error(n(345));case 2:La(i,ln,us);break;case 3:if(Js(i,w),(w&130023424)===w&&(u=ap+500-Re(),10<u)){if(Is(i,0)!==0)break;if(_=i.suspendedLanes,(_&w)!==w){Qt(),i.pingedLanes|=i.suspendedLanes&_;break}i.timeoutHandle=pf(La.bind(null,i,ln,us),u);break}La(i,ln,us);break;case 4:if(Js(i,w),(w&4194240)===w)break;for(u=i.eventTimes,_=-1;0<w;){var z=31-rn(w);T=1<<z,z=u[z],z>_&&(_=z),w&=~T}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*x4(w/1960))-w,10<w){i.timeoutHandle=pf(La.bind(null,i,ln,us),w);break}La(i,ln,us);break;case 5:La(i,ln,us);break;default:throw Error(n(329))}}}return cn(i,Re()),i.callbackNode===m?pN.bind(null,i):null}function lp(i,u){var m=yl;return i.current.memoizedState.isDehydrated&&(Oa(i,u).flags|=256),i=wu(i,u),i!==2&&(u=ln,ln=m,u!==null&&cp(u)),i}function cp(i){ln===null?ln=i:ln.push.apply(ln,i)}function b4(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],T=_.getSnapshot;_=_.value;try{if(!nr(T(),_))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 Js(i,u){for(u&=~sp,u&=~hu,i.suspendedLanes|=u,i.pingedLanes&=~u,i=i.expirationTimes;0<u;){var m=31-rn(u),w=1<<m;i[m]=-1,u&=~w}}function mN(i){if((We&6)!==0)throw Error(n(327));qo();var u=Is(i,0);if((u&1)===0)return cn(i,Re()),null;var m=wu(i,u);if(i.tag!==0&&m===2){var w=Fi(i);w!==0&&(u=w,m=lp(i,w))}if(m===1)throw m=gl,Oa(i,0),Js(i,u),cn(i,Re()),m;if(m===6)throw Error(n(345));return i.finishedWork=i.current.alternate,i.finishedLanes=u,La(i,ln,us),cn(i,Re()),null}function up(i,u){var m=We;We|=1;try{return i(u)}finally{We=m,We===0&&(Bo=Re()+500,Hc&&Hs())}}function Ia(i){Xs!==null&&Xs.tag===0&&(We&6)===0&&qo();var u=We;We|=1;var m=Pn.transition,w=Ve;try{if(Pn.transition=null,Ve=1,i)return i()}finally{Ve=w,Pn.transition=m,We=u,(We&6)===0&&Hs()}}function dp(){xn=Fo.current,nt(Fo)}function Oa(i,u){i.finishedWork=null,i.finishedLanes=0;var m=i.timeoutHandle;if(m!==-1&&(i.timeoutHandle=-1,Z3(m)),kt!==null)for(m=kt.return;m!==null;){var w=m;switch(xf(w),w.tag){case 1:w=w.type.childContextTypes,w!=null&&zc();break;case 3:Lo(),nt(sn),nt(Ht),$f();break;case 5:Rf(w);break;case 4:Lo();break;case 13:nt(ct);break;case 19:nt(ct);break;case 10:_f(w.type._context);break;case 22:case 23:dp()}m=m.return}if(Ot=i,kt=i=Qs(i.current,null),qt=xn=u,Et=0,gl=null,sp=hu=$a=0,ln=yl=null,Aa!==null){for(u=0;u<Aa.length;u++)if(m=Aa[u],w=m.interleaved,w!==null){m.interleaved=null;var _=w.next,T=m.pending;if(T!==null){var z=T.next;T.next=_,w.next=z}m.pending=w}Aa=null}return i}function gN(i,u){do{var m=kt;try{if(Sf(),tu.current=au,nu){for(var w=ut.memoizedState;w!==null;){var _=w.queue;_!==null&&(_.pending=null),w=w.next}nu=!1}if(Ma=0,It=_t=ut=null,ul=!1,dl=0,rp.current=null,m===null||m.return===null){Et=1,gl=u,kt=null;break}e:{var T=i,z=m.return,Q=m,te=u;if(u=qt,Q.flags|=32768,te!==null&&typeof te=="object"&&typeof te.then=="function"){var ce=te,be=Q,ke=be.tag;if((be.mode&1)===0&&(ke===0||ke===11||ke===15)){var xe=be.alternate;xe?(be.updateQueue=xe.updateQueue,be.memoizedState=xe.memoizedState,be.lanes=xe.lanes):(be.updateQueue=null,be.memoizedState=null)}var Se=q1(z);if(Se!==null){Se.flags&=-257,U1(Se,z,Q,T,u),Se.mode&1&&B1(T,ce,u),u=Se,te=ce;var Ee=u.updateQueue;if(Ee===null){var Te=new Set;Te.add(te),u.updateQueue=Te}else Ee.add(te);break e}else{if((u&1)===0){B1(T,ce,u),hp();break e}te=Error(n(426))}}else if(st&&Q.mode&1){var vt=q1(z);if(vt!==null){(vt.flags&65536)===0&&(vt.flags|=256),U1(vt,z,Q,T,u),Nf(Po(te,Q));break e}}T=te=Po(te,Q),Et!==4&&(Et=2),yl===null?yl=[T]:yl.push(T),T=z;do{switch(T.tag){case 3:T.flags|=65536,u&=-u,T.lanes|=u;var ie=D1(T,te,u);d1(T,ie);break e;case 1:Q=te;var re=T.type,le=T.stateNode;if((T.flags&128)===0&&(typeof re.getDerivedStateFromError=="function"||le!==null&&typeof le.componentDidCatch=="function"&&(Ys===null||!Ys.has(le)))){T.flags|=65536,u&=-u,T.lanes|=u;var je=F1(T,Q,u);d1(T,je);break e}}T=T.return}while(T!==null)}vN(m)}catch(Ce){u=Ce,kt===m&&m!==null&&(kt=m=m.return);continue}break}while(!0)}function yN(){var i=du.current;return du.current=au,i===null?au:i}function hp(){(Et===0||Et===3||Et===2)&&(Et=4),Ot===null||($a&268435455)===0&&(hu&268435455)===0||Js(Ot,qt)}function wu(i,u){var m=We;We|=2;var w=yN();(Ot!==i||qt!==u)&&(us=null,Oa(i,u));do try{k4();break}catch(_){gN(i,_)}while(!0);if(Sf(),We=m,du.current=w,kt!==null)throw Error(n(261));return Ot=null,qt=0,Et}function k4(){for(;kt!==null;)wN(kt)}function N4(){for(;kt!==null&&!Yr();)wN(kt)}function wN(i){var u=kN(i.alternate,i,xn);i.memoizedProps=i.pendingProps,u===null?vN(i):kt=u,rp.current=null}function vN(i){var u=i;do{var m=u.alternate;if(i=u.return,(u.flags&32768)===0){if(m=m4(m,u,xn),m!==null){kt=m;return}}else{if(m=g4(m,u),m!==null){m.flags&=32767,kt=m;return}if(i!==null)i.flags|=32768,i.subtreeFlags=0,i.deletions=null;else{Et=6,kt=null;return}}if(u=u.sibling,u!==null){kt=u;return}kt=u=i}while(u!==null);Et===0&&(Et=5)}function La(i,u,m){var w=Ve,_=Pn.transition;try{Pn.transition=null,Ve=1,j4(i,u,m,w)}finally{Pn.transition=_,Ve=w}return null}function j4(i,u,m,w){do qo();while(Xs!==null);if((We&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 T=m.lanes|m.childLanes;if(Ls(i,T),i===Ot&&(kt=Ot=null,qt=0),(m.subtreeFlags&2064)===0&&(m.flags&2064)===0||pu||(pu=!0,NN(Yt,function(){return qo(),null})),T=(m.flags&15990)!==0,(m.subtreeFlags&15990)!==0||T){T=Pn.transition,Pn.transition=null;var z=Ve;Ve=1;var Q=We;We|=4,rp.current=null,w4(i,m),cN(m,i),W3(hf),ba=!!df,hf=df=null,i.current=m,v4(m),ve(),We=Q,Ve=z,Pn.transition=T}else i.current=m;if(pu&&(pu=!1,Xs=i,mu=_),T=i.pendingLanes,T===0&&(Ys=null),ya(m.stateNode),cn(i,Re()),u!==null)for(w=i.onRecoverableError,m=0;m<u.length;m++)_=u[m],w(_.value,{componentStack:_.stack,digest:_.digest});if(fu)throw fu=!1,i=op,op=null,i;return(mu&1)!==0&&i.tag!==0&&qo(),T=i.pendingLanes,(T&1)!==0?i===ip?wl++:(wl=0,ip=i):wl=0,Hs(),null}function qo(){if(Xs!==null){var i=Ui(mu),u=Pn.transition,m=Ve;try{if(Pn.transition=null,Ve=16>i?16:i,Xs===null)var w=!1;else{if(i=Xs,Xs=null,mu=0,(We&6)!==0)throw Error(n(331));var _=We;for(We|=4,_e=i.current;_e!==null;){var T=_e,z=T.child;if((_e.flags&16)!==0){var Q=T.deletions;if(Q!==null){for(var te=0;te<Q.length;te++){var ce=Q[te];for(_e=ce;_e!==null;){var be=_e;switch(be.tag){case 0:case 11:case 15:ml(8,be,T)}var ke=be.child;if(ke!==null)ke.return=be,_e=ke;else for(;_e!==null;){be=_e;var xe=be.sibling,Se=be.return;if(sN(be),be===ce){_e=null;break}if(xe!==null){xe.return=Se,_e=xe;break}_e=Se}}}var Ee=T.alternate;if(Ee!==null){var Te=Ee.child;if(Te!==null){Ee.child=null;do{var vt=Te.sibling;Te.sibling=null,Te=vt}while(Te!==null)}}_e=T}}if((T.subtreeFlags&2064)!==0&&z!==null)z.return=T,_e=z;else e:for(;_e!==null;){if(T=_e,(T.flags&2048)!==0)switch(T.tag){case 0:case 11:case 15:ml(9,T,T.return)}var ie=T.sibling;if(ie!==null){ie.return=T.return,_e=ie;break e}_e=T.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:uu(9,Q)}}catch(Ce){pt(Q,Q.return,Ce)}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(We=_,Hs(),Xt&&typeof Xt.onPostCommitFiberRoot=="function")try{Xt.onPostCommitFiberRoot(yn,i)}catch{}w=!0}return w}finally{Ve=m,Pn.transition=u}}return!1}function xN(i,u,m){u=Po(m,u),u=D1(i,u,1),i=Gs(i,u,1),u=Qt(),i!==null&&(Os(i,1,u),cn(i,u))}function pt(i,u,m){if(i.tag===3)xN(i,i,m);else for(;u!==null;){if(u.tag===3){xN(u,i,m);break}else if(u.tag===1){var w=u.stateNode;if(typeof u.type.getDerivedStateFromError=="function"||typeof w.componentDidCatch=="function"&&(Ys===null||!Ys.has(w))){i=Po(m,i),i=F1(u,i,1),u=Gs(u,i,1),i=Qt(),u!==null&&(Os(u,1,i),cn(u,i));break}}u=u.return}}function S4(i,u,m){var w=i.pingCache;w!==null&&w.delete(u),u=Qt(),i.pingedLanes|=i.suspendedLanes&m,Ot===i&&(qt&m)===m&&(Et===4||Et===3&&(qt&130023424)===qt&&500>Re()-ap?Oa(i,0):sp|=m),cn(i,u)}function bN(i,u){u===0&&((i.mode&1)===0?u=1:(u=wa,wa<<=1,(wa&130023424)===0&&(wa=4194304)));var m=Qt();i=is(i,u),i!==null&&(Os(i,u,m),cn(i,m))}function _4(i){var u=i.memoizedState,m=0;u!==null&&(m=u.retryLane),bN(i,m)}function E4(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),bN(i,m)}var kN;kN=function(i,u,m){if(i!==null)if(i.memoizedProps!==u.pendingProps||sn.current)on=!0;else{if((i.lanes&m)===0&&(u.flags&128)===0)return on=!1,p4(i,u,m);on=(i.flags&131072)!==0}else on=!1,st&&(u.flags&1048576)!==0&&t1(u,Gc,u.index);switch(u.lanes=0,u.tag){case 2:var w=u.type;lu(i,u),i=u.pendingProps;var _=Co(u,Ht.current);Oo(u,m),_=Lf(null,u,w,i,_,m);var T=Pf();return u.flags|=1,typeof _=="object"&&_!==null&&typeof _.render=="function"&&_.$$typeof===void 0?(u.tag=1,u.memoizedState=null,u.updateQueue=null,an(w)?(T=!0,Wc(u)):T=!1,u.memoizedState=_.state!==null&&_.state!==void 0?_.state:null,Cf(u),_.updater=ou,u.stateNode=_,_._reactInternals=u,zf(u,w,i,m),u=Gf(null,u,w,!0,T,m)):(u.tag=0,st&&T&&vf(u),Jt(null,u,_,m),u=u.child),u;case 16:w=u.elementType;e:{switch(lu(i,u),i=u.pendingProps,_=w._init,w=_(w._payload),u.type=w,_=u.tag=C4(w),i=sr(w,i),_){case 0:u=Vf(null,u,w,i,m);break e;case 1:u=K1(null,u,w,i,m);break e;case 11:u=z1(null,u,w,i,m);break e;case 14:u=W1(null,u,w,sr(w.type,i),m);break e}throw Error(n(306,w,""))}return u;case 0:return w=u.type,_=u.pendingProps,_=u.elementType===w?_:sr(w,_),Vf(i,u,w,_,m);case 1:return w=u.type,_=u.pendingProps,_=u.elementType===w?_:sr(w,_),K1(i,u,w,_,m);case 3:e:{if(Y1(u),i===null)throw Error(n(387));w=u.pendingProps,T=u.memoizedState,_=T.element,u1(i,u),Qc(u,w,null,m);var z=u.memoizedState;if(w=z.element,T.isDehydrated)if(T={element:w,isDehydrated:!1,cache:z.cache,pendingSuspenseBoundaries:z.pendingSuspenseBoundaries,transitions:z.transitions},u.updateQueue.baseState=T,u.memoizedState=T,u.flags&256){_=Po(Error(n(423)),u),u=X1(i,u,w,m,_);break e}else if(w!==_){_=Po(Error(n(424)),u),u=X1(i,u,w,m,_);break e}else for(vn=Us(u.stateNode.containerInfo.firstChild),wn=u,st=!0,rr=null,m=l1(u,null,w,m),u.child=m;m;)m.flags=m.flags&-3|4096,m=m.sibling;else{if(Mo(),w===_){u=cs(i,u,m);break e}Jt(i,u,w,m)}u=u.child}return u;case 5:return f1(u),i===null&&kf(u),w=u.type,_=u.pendingProps,T=i!==null?i.memoizedProps:null,z=_.children,ff(w,_)?z=null:T!==null&&ff(w,T)&&(u.flags|=32),G1(i,u),Jt(i,u,z,m),u.child;case 6:return i===null&&kf(u),null;case 13:return Z1(i,u,m);case 4:return Af(u,u.stateNode.containerInfo),w=u.pendingProps,i===null?u.child=$o(u,null,w,m):Jt(i,u,w,m),u.child;case 11:return w=u.type,_=u.pendingProps,_=u.elementType===w?_:sr(w,_),z1(i,u,w,_,m);case 7:return Jt(i,u,u.pendingProps,m),u.child;case 8:return Jt(i,u,u.pendingProps.children,m),u.child;case 12:return Jt(i,u,u.pendingProps.children,m),u.child;case 10:e:{if(w=u.type._context,_=u.pendingProps,T=u.memoizedProps,z=_.value,et(Xc,w._currentValue),w._currentValue=z,T!==null)if(nr(T.value,z)){if(T.children===_.children&&!sn.current){u=cs(i,u,m);break e}}else for(T=u.child,T!==null&&(T.return=u);T!==null;){var Q=T.dependencies;if(Q!==null){z=T.child;for(var te=Q.firstContext;te!==null;){if(te.context===w){if(T.tag===1){te=ls(-1,m&-m),te.tag=2;var ce=T.updateQueue;if(ce!==null){ce=ce.shared;var be=ce.pending;be===null?te.next=te:(te.next=be.next,be.next=te),ce.pending=te}}T.lanes|=m,te=T.alternate,te!==null&&(te.lanes|=m),Ef(T.return,m,u),Q.lanes|=m;break}te=te.next}}else if(T.tag===10)z=T.type===u.type?null:T.child;else if(T.tag===18){if(z=T.return,z===null)throw Error(n(341));z.lanes|=m,Q=z.alternate,Q!==null&&(Q.lanes|=m),Ef(z,m,u),z=T.sibling}else z=T.child;if(z!==null)z.return=T;else for(z=T;z!==null;){if(z===u){z=null;break}if(T=z.sibling,T!==null){T.return=z.return,z=T;break}z=z.return}T=z}Jt(i,u,_.children,m),u=u.child}return u;case 9:return _=u.type,w=u.pendingProps.children,Oo(u,m),_=On(_),w=w(_),u.flags|=1,Jt(i,u,w,m),u.child;case 14:return w=u.type,_=sr(w,u.pendingProps),_=sr(w.type,_),W1(i,u,w,_,m);case 15:return H1(i,u,u.type,u.pendingProps,m);case 17:return w=u.type,_=u.pendingProps,_=u.elementType===w?_:sr(w,_),lu(i,u),u.tag=1,an(w)?(i=!0,Wc(u)):i=!1,Oo(u,m),L1(u,w,_),zf(u,w,_,m),Gf(null,u,w,!0,i,m);case 19:return Q1(i,u,m);case 22:return V1(i,u,m)}throw Error(n(156,u.tag))};function NN(i,u){return Sr(i,u)}function T4(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 Dn(i,u,m,w){return new T4(i,u,m,w)}function fp(i){return i=i.prototype,!(!i||!i.isReactComponent)}function C4(i){if(typeof i=="function")return fp(i)?1:0;if(i!=null){if(i=i.$$typeof,i===M)return 11;if(i===$)return 14}return 2}function Qs(i,u){var m=i.alternate;return m===null?(m=Dn(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 vu(i,u,m,w,_,T){var z=2;if(w=i,typeof i=="function")fp(i)&&(z=1);else if(typeof i=="string")z=5;else e:switch(i){case A:return Pa(m.children,_,T,u);case q:z=8,_|=8;break;case I:return i=Dn(12,m,u,_|2),i.elementType=I,i.lanes=T,i;case F:return i=Dn(13,m,u,_),i.elementType=F,i.lanes=T,i;case C:return i=Dn(19,m,u,_),i.elementType=C,i.lanes=T,i;case K:return xu(m,_,T,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 $:z=14;break e;case P:z=16,w=null;break e}throw Error(n(130,i==null?i:typeof i,""))}return u=Dn(z,m,u,_),u.elementType=i,u.type=w,u.lanes=T,u}function Pa(i,u,m,w){return i=Dn(7,i,w,u),i.lanes=m,i}function xu(i,u,m,w){return i=Dn(22,i,w,u),i.elementType=K,i.lanes=m,i.stateNode={isHidden:!1},i}function pp(i,u,m){return i=Dn(6,i,null,u),i.lanes=m,i}function mp(i,u,m){return u=Dn(4,i.children!==null?i.children:[],i.key,u),u.lanes=m,u.stateNode={containerInfo:i.containerInfo,pendingChildren:null,implementation:i.implementation},u}function A4(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=Bi(0),this.expirationTimes=Bi(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Bi(0),this.identifierPrefix=w,this.onRecoverableError=_,this.mutableSourceEagerHydrationData=null}function gp(i,u,m,w,_,T,z,Q,te){return i=new A4(i,u,m,Q,te),u===1?(u=1,T===!0&&(u|=8)):u=0,T=Dn(3,null,null,u),i.current=T,T.stateNode=i,T.memoizedState={element:w,isDehydrated:m,cache:null,transitions:null,pendingSuspenseBoundaries:null},Cf(T),i}function R4(i,u,m){var w=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:O,key:w==null?null:""+w,children:i,containerInfo:u,implementation:m}}function jN(i){if(!i)return Ws;i=i._reactInternals;e:{if(Rn(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(an(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(an(m))return Jk(i,m,u)}return u}function SN(i,u,m,w,_,T,z,Q,te){return i=gp(m,w,!0,i,_,T,z,Q,te),i.context=jN(null),m=i.current,w=Qt(),_=Zs(m),T=ls(w,_),T.callback=u??null,Gs(m,T,_),i.current.lanes=_,Os(i,_,w),cn(i,w),i}function bu(i,u,m,w){var _=u.current,T=Qt(),z=Zs(_);return m=jN(m),u.context===null?u.context=m:u.pendingContext=m,u=ls(T,z),u.payload={element:i},w=w===void 0?null:w,w!==null&&(u.callback=w),i=Gs(_,u,z),i!==null&&(ir(i,_,z,T),Jc(i,_,z)),z}function ku(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 _N(i,u){if(i=i.memoizedState,i!==null&&i.dehydrated!==null){var m=i.retryLane;i.retryLane=m!==0&&m<u?m:u}}function yp(i,u){_N(i,u),(i=i.alternate)&&_N(i,u)}function M4(){return null}var EN=typeof reportError=="function"?reportError:function(i){console.error(i)};function wp(i){this._internalRoot=i}Nu.prototype.render=wp.prototype.render=function(i){var u=this._internalRoot;if(u===null)throw Error(n(409));bu(i,u,null,null)},Nu.prototype.unmount=wp.prototype.unmount=function(){var i=this._internalRoot;if(i!==null){this._internalRoot=null;var u=i.containerInfo;Ia(function(){bu(null,i,null,null)}),u[rs]=null}};function Nu(i){this._internalRoot=i}Nu.prototype.unstable_scheduleHydration=function(i){if(i){var u=mo();i={blockedOn:null,target:i,priority:u};for(var m=0;m<Cr.length&&u!==0&&u<Cr[m].priority;m++);Cr.splice(m,0,i),m===0&&Gi(i)}};function vp(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11)}function ju(i){return!(!i||i.nodeType!==1&&i.nodeType!==9&&i.nodeType!==11&&(i.nodeType!==8||i.nodeValue!==" react-mount-point-unstable "))}function TN(){}function $4(i,u,m,w,_){if(_){if(typeof w=="function"){var T=w;w=function(){var ce=ku(z);T.call(ce)}}var z=SN(u,w,i,0,null,!1,!1,"",TN);return i._reactRootContainer=z,i[rs]=z.current,nl(i.nodeType===8?i.parentNode:i),Ia(),z}for(;_=i.lastChild;)i.removeChild(_);if(typeof w=="function"){var Q=w;w=function(){var ce=ku(te);Q.call(ce)}}var te=gp(i,0,!1,null,null,!1,!1,"",TN);return i._reactRootContainer=te,i[rs]=te.current,nl(i.nodeType===8?i.parentNode:i),Ia(function(){bu(u,te,m,w)}),te}function Su(i,u,m,w,_){var T=m._reactRootContainer;if(T){var z=T;if(typeof _=="function"){var Q=_;_=function(){var te=ku(z);Q.call(te)}}bu(u,z,i,_)}else z=$4(m,u,i,_,w);return ku(z)}po=function(i){switch(i.tag){case 3:var u=i.stateNode;if(u.current.memoizedState.isDehydrated){var m=$s(u.pendingLanes);m!==0&&(qi(u,m|1),cn(u,Re()),(We&6)===0&&(Bo=Re()+500,Hs()))}break;case 13:Ia(function(){var w=is(i,1);if(w!==null){var _=Qt();ir(w,i,1,_)}}),yp(i,1)}},zi=function(i){if(i.tag===13){var u=is(i,134217728);if(u!==null){var m=Qt();ir(u,i,134217728,m)}yp(i,134217728)}},Ac=function(i){if(i.tag===13){var u=Zs(i),m=is(i,u);if(m!==null){var w=Qt();ir(m,i,u,w)}yp(i,u)}},mo=function(){return Ve},Wi=function(i,u){var m=Ve;try{return Ve=i,u()}finally{Ve=m}},Ft=function(i,u,m){switch(u){case"input":if(fe(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 _=Uc(w);if(!_)throw Error(n(90));ye(w),fe(w,_)}}}break;case"textarea":Be(i,m);break;case"select":u=m.value,u!=null&&we(i,!!m.multiple,u,!1)}},Yn=up,br=Ia;var I4={usingClientEntryPoint:!1,Events:[al,Eo,Uc,xt,Tn,up]},vl={findFiberByHostInstance:_a,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},O4={bundleType:vl.bundleType,version:vl.version,rendererPackageName:vl.rendererPackageName,rendererConfig:vl.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=As(i),i===null?null:i.stateNode},findFiberByHostInstance:vl.findFiberByHostInstance||M4,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 _u=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!_u.isDisabled&&_u.supportsFiber)try{yn=_u.inject(O4),Xt=_u}catch{}}return un.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=I4,un.createPortal=function(i,u){var m=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!vp(u))throw Error(n(200));return R4(i,u,null,m)},un.createRoot=function(i,u){if(!vp(i))throw Error(n(299));var m=!1,w="",_=EN;return u!=null&&(u.unstable_strictMode===!0&&(m=!0),u.identifierPrefix!==void 0&&(w=u.identifierPrefix),u.onRecoverableError!==void 0&&(_=u.onRecoverableError)),u=gp(i,1,!1,null,null,m,!1,w,_),i[rs]=u.current,nl(i.nodeType===8?i.parentNode:i),new wp(u)},un.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=As(u),i=i===null?null:i.stateNode,i},un.flushSync=function(i){return Ia(i)},un.hydrate=function(i,u,m){if(!ju(u))throw Error(n(200));return Su(null,i,u,!0,m)},un.hydrateRoot=function(i,u,m){if(!vp(i))throw Error(n(405));var w=m!=null&&m.hydratedSources||null,_=!1,T="",z=EN;if(m!=null&&(m.unstable_strictMode===!0&&(_=!0),m.identifierPrefix!==void 0&&(T=m.identifierPrefix),m.onRecoverableError!==void 0&&(z=m.onRecoverableError)),u=SN(u,null,i,1,m??null,_,!1,T,z),i[rs]=u.current,nl(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 Nu(u)},un.render=function(i,u,m){if(!ju(u))throw Error(n(200));return Su(null,i,u,!1,m)},un.unmountComponentAtNode=function(i){if(!ju(i))throw Error(n(40));return i._reactRootContainer?(Ia(function(){Su(null,null,i,!1,function(){i._reactRootContainer=null,i[rs]=null})}),!0):!1},un.unstable_batchedUpdates=up,un.unstable_renderSubtreeIntoContainer=function(i,u,m,w){if(!ju(m))throw Error(n(200));if(i==null||i._reactInternals===void 0)throw Error(n(38));return Su(i,u,m,!1,w)},un.version="18.3.1-next-f1338f8080-20240426",un}var LN;function KM(){if(LN)return Np.exports;LN=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(),Np.exports=W4(),Np.exports}var PN;function H4(){if(PN)return Tu;PN=1;var e=KM();return Tu.createRoot=e.createRoot,Tu.hydrateRoot=e.hydrateRoot,Tu}var V4=H4(),y=mc();const he=Ub(y);function zt(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=zt(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var _p={exports:{}},Ep={},Tp={exports:{}},Cp={};/**
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 DN;function G4(){if(DN)return Cp;DN=1;var e=mc();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 Cp.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:f,Cp}var FN;function K4(){return FN||(FN=1,Tp.exports=G4()),Tp.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 BN;function Y4(){if(BN)return Ep;BN=1;var e=mc(),t=K4();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 Ep.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(O){if(!b){if(b=!0,S=O,O=g(O),v!==void 0&&k.hasValue){var A=k.value;if(v(A,O))return E=A}return E=O}if(A=E,r(S,O))return A;var q=g(O);return v!==void 0&&v(A,q)?(S=O,A):(S=O,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},Ep}var qN;function X4(){return qN||(qN=1,_p.exports=Y4()),_p.exports}var Z4=X4();const J4=Ub(Z4),Q4={},UN=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:()=>{(Q4?"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},eD=e=>e?UN(e):UN,{useDebugValue:tD}=he,{useSyncExternalStoreWithSelector:nD}=J4,rD=e=>e;function YM(e,t=rD,n){const r=nD(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return tD(r),r}const zN=(e,t)=>{const n=eD(e),r=(s,o=t)=>YM(n,s,o);return Object.assign(r,n),r},sD=(e,t)=>e?zN(e,t):zN;function Rt(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 aD={value:()=>{}};function Zd(){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 nd(n)}function nd(e){this._=e}function oD(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}})}nd.prototype=Zd.prototype={constructor:nd,on:function(e,t){var n=this._,r=oD(e+"",n),s,o=-1,l=r.length;if(arguments.length<2){for(;++o<l;)if((s=(e=r[o]).type)&&(s=iD(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]=WN(n[s],e.name,t);else if(t==null)for(s in n)n[s]=WN(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 nd(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 iD(e,t){for(var n=0,r=e.length,s;n<r;++n)if((s=e[n]).name===t)return s.value}function WN(e,t,n){for(var r=0,s=e.length;r<s;++r)if(e[r].name===t){e[r]=aD,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var Cx="http://www.w3.org/1999/xhtml";const HN={svg:"http://www.w3.org/2000/svg",xhtml:Cx,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Jd(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),HN.hasOwnProperty(t)?{space:HN[t],local:e}:e}function lD(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Cx&&t.documentElement.namespaceURI===Cx?t.createElement(e):t.createElementNS(n,e)}}function cD(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function XM(e){var t=Jd(e);return(t.local?cD:lD)(t)}function uD(){}function zb(e){return e==null?uD:function(){return this.querySelector(e)}}function dD(e){typeof e!="function"&&(e=zb(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 _n(r,this._parents)}function hD(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function fD(){return[]}function ZM(e){return e==null?fD:function(){return this.querySelectorAll(e)}}function pD(e){return function(){return hD(e.apply(this,arguments))}}function mD(e){typeof e=="function"?e=pD(e):e=ZM(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 _n(r,s)}function JM(e){return function(){return this.matches(e)}}function QM(e){return function(t){return t.matches(e)}}var gD=Array.prototype.find;function yD(e){return function(){return gD.call(this.children,e)}}function wD(){return this.firstElementChild}function vD(e){return this.select(e==null?wD:yD(typeof e=="function"?e:QM(e)))}var xD=Array.prototype.filter;function bD(){return Array.from(this.children)}function kD(e){return function(){return xD.call(this.children,e)}}function ND(e){return this.selectAll(e==null?bD:kD(typeof e=="function"?e:QM(e)))}function jD(e){typeof e!="function"&&(e=JM(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 _n(r,this._parents)}function e2(e){return new Array(e.length)}function SD(){return new _n(this._enter||this._groups.map(e2),this._parents)}function md(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}md.prototype={constructor:md,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 _D(e){return function(){return e}}function ED(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 md(e,o[l]);for(;l<d;++l)(c=t[l])&&(s[l]=c)}function TD(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 md(e,o[c]);for(c=0;c<f;++c)(d=t[c])&&h.get(g[c])===d&&(s[c]=d)}function CD(e){return e.__data__}function AD(e,t){if(!arguments.length)return Array.from(this,CD);var n=t?TD:ED,r=this._parents,s=this._groups;typeof e!="function"&&(e=_D(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=RD(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 _n(l,r),l._enter=c,l._exit=d,l}function RD(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function MD(){return new _n(this._exit||this._groups.map(e2),this._parents)}function $D(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 ID(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 _n(c,this._parents)}function OD(){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 LD(e){e||(e=PD);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 _n(s,this._parents).order()}function PD(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function DD(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function FD(){return Array.from(this)}function BD(){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 qD(){let e=0;for(const t of this)++e;return e}function UD(){return!this.node()}function zD(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 WD(e){return function(){this.removeAttribute(e)}}function HD(e){return function(){this.removeAttributeNS(e.space,e.local)}}function VD(e,t){return function(){this.setAttribute(e,t)}}function GD(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function KD(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function YD(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 XD(e,t){var n=Jd(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?HD:WD:typeof t=="function"?n.local?YD:KD:n.local?GD:VD)(n,t))}function t2(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function ZD(e){return function(){this.style.removeProperty(e)}}function JD(e,t,n){return function(){this.style.setProperty(e,t,n)}}function QD(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function eF(e,t,n){return arguments.length>1?this.each((t==null?ZD:typeof t=="function"?QD:JD)(e,t,n??"")):pi(this.node(),e)}function pi(e,t){return e.style.getPropertyValue(t)||t2(e).getComputedStyle(e,null).getPropertyValue(t)}function tF(e){return function(){delete this[e]}}function nF(e,t){return function(){this[e]=t}}function rF(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function sF(e,t){return arguments.length>1?this.each((t==null?tF:typeof t=="function"?rF:nF)(e,t)):this.node()[e]}function n2(e){return e.trim().split(/^|\s+/)}function Wb(e){return e.classList||new r2(e)}function r2(e){this._node=e,this._names=n2(e.getAttribute("class")||"")}r2.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 s2(e,t){for(var n=Wb(e),r=-1,s=t.length;++r<s;)n.add(t[r])}function a2(e,t){for(var n=Wb(e),r=-1,s=t.length;++r<s;)n.remove(t[r])}function aF(e){return function(){s2(this,e)}}function oF(e){return function(){a2(this,e)}}function iF(e,t){return function(){(t.apply(this,arguments)?s2:a2)(this,e)}}function lF(e,t){var n=n2(e+"");if(arguments.length<2){for(var r=Wb(this.node()),s=-1,o=n.length;++s<o;)if(!r.contains(n[s]))return!1;return!0}return this.each((typeof t=="function"?iF:t?aF:oF)(n,t))}function cF(){this.textContent=""}function uF(e){return function(){this.textContent=e}}function dF(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function hF(e){return arguments.length?this.each(e==null?cF:(typeof e=="function"?dF:uF)(e)):this.node().textContent}function fF(){this.innerHTML=""}function pF(e){return function(){this.innerHTML=e}}function mF(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function gF(e){return arguments.length?this.each(e==null?fF:(typeof e=="function"?mF:pF)(e)):this.node().innerHTML}function yF(){this.nextSibling&&this.parentNode.appendChild(this)}function wF(){return this.each(yF)}function vF(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function xF(){return this.each(vF)}function bF(e){var t=typeof e=="function"?e:XM(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function kF(){return null}function NF(e,t){var n=typeof e=="function"?e:XM(e),r=t==null?kF:typeof t=="function"?t:zb(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function jF(){var e=this.parentNode;e&&e.removeChild(this)}function SF(){return this.each(jF)}function _F(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function EF(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function TF(e){return this.select(e?EF:_F)}function CF(e){return arguments.length?this.property("__data__",e):this.node().__data__}function AF(e){return function(t){e.call(this,t,this.__data__)}}function RF(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 MF(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 $F(e,t,n){return function(){var r=this.__on,s,o=AF(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 IF(e,t,n){var r=RF(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?$F:MF,s=0;s<o;++s)this.each(c(r[s],t,n));return this}function o2(e,t,n){var r=t2(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 OF(e,t){return function(){return o2(this,e,t)}}function LF(e,t){return function(){return o2(this,e,t.apply(this,arguments))}}function PF(e,t){return this.each((typeof t=="function"?LF:OF)(e,t))}function*DF(){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 i2=[null];function _n(e,t){this._groups=e,this._parents=t}function gc(){return new _n([[document.documentElement]],i2)}function FF(){return this}_n.prototype=gc.prototype={constructor:_n,select:dD,selectAll:mD,selectChild:vD,selectChildren:ND,filter:jD,data:AD,enter:SD,exit:MD,join:$D,merge:ID,selection:FF,order:OD,sort:LD,call:DD,nodes:FD,node:BD,size:qD,empty:UD,each:zD,attr:XD,style:eF,property:sF,classed:lF,text:hF,html:gF,raise:wF,lower:xF,append:bF,insert:NF,remove:SF,clone:TF,datum:CF,on:IF,dispatch:PF,[Symbol.iterator]:DF};function Un(e){return typeof e=="string"?new _n([[document.querySelector(e)]],[document.documentElement]):new _n([[e]],i2)}function BF(e){let t;for(;t=e.sourceEvent;)e=t;return e}function dr(e,t){if(e=BF(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 qF={passive:!1},Vl={capture:!0,passive:!1};function Ap(e){e.stopImmediatePropagation()}function li(e){e.preventDefault(),e.stopImmediatePropagation()}function l2(e){var t=e.document.documentElement,n=Un(e).on("dragstart.drag",li,Vl);"onselectstart"in t?n.on("selectstart.drag",li,Vl):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function c2(e,t){var n=e.document.documentElement,r=Un(e).on("dragstart.drag",null);t&&(r.on("click.drag",li,Vl),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 Cu=e=>()=>e;function Ax(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}})}Ax.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function UF(e){return!e.ctrlKey&&!e.button}function zF(){return this.parentNode}function WF(e,t){return t??{x:e.x,y:e.y}}function HF(){return navigator.maxTouchPoints||"ontouchstart"in this}function VF(){var e=UF,t=zF,n=WF,r=HF,s={},o=Zd("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,qF).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 O=S(this,t.call(this,E,R),E,R,"mouse");O&&(Un(E.view).on("mousemove.drag",j,Vl).on("mouseup.drag",k,Vl),l2(E.view),Ap(E),h=!1,c=E.clientX,d=E.clientY,O("start",E))}}function j(E){if(li(E),!h){var R=E.clientX-c,O=E.clientY-d;h=R*R+O*O>p}s.mouse("drag",E)}function k(E){Un(E.view).on("mousemove.drag mouseup.drag",null),c2(E.view,h),li(E),s.mouse("end",E)}function x(E,R){if(e.call(this,E,R)){var O=E.changedTouches,A=t.call(this,E,R),q=O.length,I,B;for(I=0;I<q;++I)(B=S(this,A,E,R,O[I].identifier,O[I]))&&(Ap(E),B("start",E,O[I]))}}function N(E){var R=E.changedTouches,O=R.length,A,q;for(A=0;A<O;++A)(q=s[R[A].identifier])&&(li(E),q("drag",E,R[A]))}function b(E){var R=E.changedTouches,O=R.length,A,q;for(f&&clearTimeout(f),f=setTimeout(function(){f=null},500),A=0;A<O;++A)(q=s[R[A].identifier])&&(Ap(E),q("end",E,R[A]))}function S(E,R,O,A,q,I){var B=o.copy(),L=dr(I||O,R),M,F,C;if((C=n.call(E,new Ax("beforestart",{sourceEvent:O,target:g,identifier:q,active:l,x:L[0],y:L[1],dx:0,dy:0,dispatch:B}),A))!=null)return M=C.x-L[0]||0,F=C.y-L[1]||0,function $(P,K,G){var U=L,W;switch(P){case"start":s[q]=$,W=l++;break;case"end":delete s[q],--l;case"drag":L=dr(G||K,R),W=l;break}B.call(P,E,new Ax(P,{sourceEvent:K,subject:C,target:g,identifier:q,active:W,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:Cu(!!E),g):e},g.container=function(E){return arguments.length?(t=typeof E=="function"?E:Cu(E),g):t},g.subject=function(E){return arguments.length?(n=typeof E=="function"?E:Cu(E),g):n},g.touchable=function(E){return arguments.length?(r=typeof E=="function"?E:Cu(!!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 Hb(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function u2(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function yc(){}var Gl=.7,gd=1/Gl,ci="\\s*([+-]?\\d+)\\s*",Kl="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",qr="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",GF=/^#([0-9a-f]{3,8})$/,KF=new RegExp(`^rgb\\(${ci},${ci},${ci}\\)$`),YF=new RegExp(`^rgb\\(${qr},${qr},${qr}\\)$`),XF=new RegExp(`^rgba\\(${ci},${ci},${ci},${Kl}\\)$`),ZF=new RegExp(`^rgba\\(${qr},${qr},${qr},${Kl}\\)$`),JF=new RegExp(`^hsl\\(${Kl},${qr},${qr}\\)$`),QF=new RegExp(`^hsla\\(${Kl},${qr},${qr},${Kl}\\)$`),VN={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};Hb(yc,Yl,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:GN,formatHex:GN,formatHex8:e5,formatHsl:t5,formatRgb:KN,toString:KN});function GN(){return this.rgb().formatHex()}function e5(){return this.rgb().formatHex8()}function t5(){return d2(this).formatHsl()}function KN(){return this.rgb().formatRgb()}function Yl(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=GF.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?YN(t):n===3?new hn(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Au(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Au(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=KF.exec(e))?new hn(t[1],t[2],t[3],1):(t=YF.exec(e))?new hn(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=XF.exec(e))?Au(t[1],t[2],t[3],t[4]):(t=ZF.exec(e))?Au(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=JF.exec(e))?JN(t[1],t[2]/100,t[3]/100,1):(t=QF.exec(e))?JN(t[1],t[2]/100,t[3]/100,t[4]):VN.hasOwnProperty(e)?YN(VN[e]):e==="transparent"?new hn(NaN,NaN,NaN,0):null}function YN(e){return new hn(e>>16&255,e>>8&255,e&255,1)}function Au(e,t,n,r){return r<=0&&(e=t=n=NaN),new hn(e,t,n,r)}function n5(e){return e instanceof yc||(e=Yl(e)),e?(e=e.rgb(),new hn(e.r,e.g,e.b,e.opacity)):new hn}function Rx(e,t,n,r){return arguments.length===1?n5(e):new hn(e,t,n,r??1)}function hn(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}Hb(hn,Rx,u2(yc,{brighter(e){return e=e==null?gd:Math.pow(gd,e),new hn(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Gl:Math.pow(Gl,e),new hn(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new hn(Ka(this.r),Ka(this.g),Ka(this.b),yd(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:XN,formatHex:XN,formatHex8:r5,formatRgb:ZN,toString:ZN}));function XN(){return`#${Wa(this.r)}${Wa(this.g)}${Wa(this.b)}`}function r5(){return`#${Wa(this.r)}${Wa(this.g)}${Wa(this.b)}${Wa((isNaN(this.opacity)?1:this.opacity)*255)}`}function ZN(){const e=yd(this.opacity);return`${e===1?"rgb(":"rgba("}${Ka(this.r)}, ${Ka(this.g)}, ${Ka(this.b)}${e===1?")":`, ${e})`}`}function yd(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Ka(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Wa(e){return e=Ka(e),(e<16?"0":"")+e.toString(16)}function JN(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new hr(e,t,n,r)}function d2(e){if(e instanceof hr)return new hr(e.h,e.s,e.l,e.opacity);if(e instanceof yc||(e=Yl(e)),!e)return new hr;if(e instanceof hr)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 hr(l,c,d,e.opacity)}function s5(e,t,n,r){return arguments.length===1?d2(e):new hr(e,t,n,r??1)}function hr(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}Hb(hr,s5,u2(yc,{brighter(e){return e=e==null?gd:Math.pow(gd,e),new hr(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Gl:Math.pow(Gl,e),new hr(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 hn(Rp(e>=240?e-240:e+120,s,r),Rp(e,s,r),Rp(e<120?e+240:e-120,s,r),this.opacity)},clamp(){return new hr(QN(this.h),Ru(this.s),Ru(this.l),yd(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=yd(this.opacity);return`${e===1?"hsl(":"hsla("}${QN(this.h)}, ${Ru(this.s)*100}%, ${Ru(this.l)*100}%${e===1?")":`, ${e})`}`}}));function QN(e){return e=(e||0)%360,e<0?e+360:e}function Ru(e){return Math.max(0,Math.min(1,e||0))}function Rp(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 h2=e=>()=>e;function a5(e,t){return function(n){return e+n*t}}function o5(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 i5(e){return(e=+e)==1?f2:function(t,n){return n-t?o5(t,n,e):h2(isNaN(t)?n:t)}}function f2(e,t){var n=t-e;return n?a5(e,n):h2(isNaN(e)?t:e)}const ej=(function e(t){var n=i5(t);function r(s,o){var l=n((s=Rx(s)).r,(o=Rx(o)).r),c=n(s.g,o.g),d=n(s.b,o.b),h=f2(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 ra(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var Mx=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Mp=new RegExp(Mx.source,"g");function l5(e){return function(){return e}}function c5(e){return function(t){return e(t)+""}}function u5(e,t){var n=Mx.lastIndex=Mp.lastIndex=0,r,s,o,l=-1,c=[],d=[];for(e=e+"",t=t+"";(r=Mx.exec(e))&&(s=Mp.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:ra(r,s)})),n=Mp.lastIndex;return n<t.length&&(o=t.slice(n),c[l]?c[l]+=o:c[++l]=o),c.length<2?d[0]?c5(d[0].x):l5(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 tj=180/Math.PI,$x={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function p2(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)*tj,skewX:Math.atan(d)*tj,scaleX:l,scaleY:c}}var Mu;function d5(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?$x:p2(t.a,t.b,t.c,t.d,t.e,t.f)}function h5(e){return e==null||(Mu||(Mu=document.createElementNS("http://www.w3.org/2000/svg","g")),Mu.setAttribute("transform",e),!(e=Mu.transform.baseVal.consolidate()))?$x:(e=e.matrix,p2(e.a,e.b,e.c,e.d,e.e,e.f))}function m2(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:ra(h,p)},{i:k-2,x:ra(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:ra(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:ra(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:ra(h,p)},{i:k-2,x:ra(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 f5=m2(d5,"px, ","px)","deg)"),p5=m2(h5,", ",")",")"),m5=1e-12;function nj(e){return((e=Math.exp(e))+1/e)/2}function g5(e){return((e=Math.exp(e))-1/e)/2}function y5(e){return((e=Math.exp(2*e))-1)/(e+1)}const w5=(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<m5)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),O=Math.log(Math.sqrt(E*E+1)-E);N=(O-R)/t,x=function(A){var q=A*N,I=nj(R),B=h/(n*b)*(I*y5(t*q+R)-g5(R));return[c+B*v,d+B*j,h*I/nj(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 mi=0,Rl=0,bl=0,g2=1e3,wd,Ml,vd=0,Qa=0,Qd=0,Xl=typeof performance=="object"&&performance.now?performance:Date,y2=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Vb(){return Qa||(y2(v5),Qa=Xl.now()+Qd)}function v5(){Qa=0}function xd(){this._call=this._time=this._next=null}xd.prototype=w2.prototype={constructor:xd,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Vb():+n)+(t==null?0:+t),!this._next&&Ml!==this&&(Ml?Ml._next=this:wd=this,Ml=this),this._call=e,this._time=n,Ix()},stop:function(){this._call&&(this._call=null,this._time=1/0,Ix())}};function w2(e,t,n){var r=new xd;return r.restart(e,t,n),r}function x5(){Vb(),++mi;for(var e=wd,t;e;)(t=Qa-e._time)>=0&&e._call.call(void 0,t),e=e._next;--mi}function rj(){Qa=(vd=Xl.now())+Qd,mi=Rl=0;try{x5()}finally{mi=0,k5(),Qa=0}}function b5(){var e=Xl.now(),t=e-vd;t>g2&&(Qd-=t,vd=e)}function k5(){for(var e,t=wd,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:wd=n);Ml=e,Ix(r)}function Ix(e){if(!mi){Rl&&(Rl=clearTimeout(Rl));var t=e-Qa;t>24?(e<1/0&&(Rl=setTimeout(rj,e-Xl.now()-Qd)),bl&&(bl=clearInterval(bl))):(bl||(vd=Xl.now(),bl=setInterval(b5,g2)),mi=1,y2(rj))}}function sj(e,t,n){var r=new xd;return t=t==null?0:+t,r.restart(s=>{r.stop(),e(s+t)},t,n),r}var N5=Zd("start","end","cancel","interrupt"),j5=[],v2=0,aj=1,Ox=2,rd=3,oj=4,Lx=5,sd=6;function eh(e,t,n,r,s,o){var l=e.__transition;if(!l)e.__transition={};else if(n in l)return;S5(e,n,{name:t,index:r,group:s,on:N5,tween:j5,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:v2})}function Gb(e,t){var n=vr(e,t);if(n.state>v2)throw new Error("too late; already scheduled");return n}function Wr(e,t){var n=vr(e,t);if(n.state>rd)throw new Error("too late; already running");return n}function vr(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function S5(e,t,n){var r=e.__transition,s;r[t]=n,n.timer=w2(o,0,n.time);function o(h){n.state=aj,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!==aj)return d();for(f in r)if(v=r[f],v.name===n.name){if(v.state===rd)return sj(l);v.state===oj?(v.state=sd,v.timer.stop(),v.on.call("interrupt",e,e.__data__,v.index,v.group),delete r[f]):+f<t&&(v.state=sd,v.timer.stop(),v.on.call("cancel",e,e.__data__,v.index,v.group),delete r[f])}if(sj(function(){n.state===rd&&(n.state=oj,n.timer.restart(c,n.delay,n.time),c(h))}),n.state=Ox,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Ox){for(n.state=rd,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=Lx,1),p=-1,g=s.length;++p<g;)s[p].call(e,f);n.state===Lx&&(n.on.call("end",e,e.__data__,n.index,n.group),d())}function d(){n.state=sd,n.timer.stop(),delete r[t];for(var h in r)return;delete e.__transition}}function ad(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>Ox&&r.state<Lx,r.state=sd,r.timer.stop(),r.on.call(s?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[l]}o&&delete e.__transition}}function _5(e){return this.each(function(){ad(this,e)})}function E5(e,t){var n,r;return function(){var s=Wr(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 T5(e,t,n){var r,s;if(typeof n!="function")throw new Error;return function(){var o=Wr(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 C5(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=vr(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?E5:T5)(n,e,t))}function Kb(e,t,n){var r=e._id;return e.each(function(){var s=Wr(this,r);(s.value||(s.value={}))[t]=n.apply(this,arguments)}),function(s){return vr(s,r).value[t]}}function x2(e,t){var n;return(typeof t=="number"?ra:t instanceof Yl?ej:(n=Yl(t))?(t=n,ej):u5)(e,t)}function A5(e){return function(){this.removeAttribute(e)}}function R5(e){return function(){this.removeAttributeNS(e.space,e.local)}}function M5(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 $5(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 I5(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 O5(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 L5(e,t){var n=Jd(e),r=n==="transform"?p5:x2;return this.attrTween(e,typeof t=="function"?(n.local?O5:I5)(n,r,Kb(this,"attr."+e,t)):t==null?(n.local?R5:A5)(n):(n.local?$5:M5)(n,r,t))}function P5(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function D5(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function F5(e,t){var n,r;function s(){var o=t.apply(this,arguments);return o!==r&&(n=(r=o)&&D5(e,o)),n}return s._value=t,s}function B5(e,t){var n,r;function s(){var o=t.apply(this,arguments);return o!==r&&(n=(r=o)&&P5(e,o)),n}return s._value=t,s}function q5(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=Jd(e);return this.tween(n,(r.local?F5:B5)(r,t))}function U5(e,t){return function(){Gb(this,e).delay=+t.apply(this,arguments)}}function z5(e,t){return t=+t,function(){Gb(this,e).delay=t}}function W5(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?U5:z5)(t,e)):vr(this.node(),t).delay}function H5(e,t){return function(){Wr(this,e).duration=+t.apply(this,arguments)}}function V5(e,t){return t=+t,function(){Wr(this,e).duration=t}}function G5(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?H5:V5)(t,e)):vr(this.node(),t).duration}function K5(e,t){if(typeof t!="function")throw new Error;return function(){Wr(this,e).ease=t}}function Y5(e){var t=this._id;return arguments.length?this.each(K5(t,e)):vr(this.node(),t).ease}function X5(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Wr(this,e).ease=n}}function Z5(e){if(typeof e!="function")throw new Error;return this.each(X5(this._id,e))}function J5(e){typeof e!="function"&&(e=JM(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 xs(r,this._parents,this._name,this._id)}function Q5(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 xs(l,this._parents,this._name,this._id)}function e6(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 t6(e,t,n){var r,s,o=e6(t)?Gb:Wr;return function(){var l=o(this,e),c=l.on;c!==r&&(s=(r=c).copy()).on(t,n),l.on=s}}function n6(e,t){var n=this._id;return arguments.length<2?vr(this.node(),n).on.on(e):this.each(t6(n,e,t))}function r6(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function s6(){return this.on("end.remove",r6(this._id))}function a6(e){var t=this._name,n=this._id;typeof e!="function"&&(e=zb(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,eh(h[g],t,n,g,h,vr(f,n)));return new xs(o,this._parents,t,n)}function o6(e){var t=this._name,n=this._id;typeof e!="function"&&(e=ZM(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=vr(f,n),k=0,x=g.length;k<x;++k)(v=g[k])&&eh(v,t,n,k,g,j);o.push(g),l.push(f)}return new xs(o,l,t,n)}var i6=gc.prototype.constructor;function l6(){return new i6(this._groups,this._parents)}function c6(e,t){var n,r,s;return function(){var o=pi(this,e),l=(this.style.removeProperty(e),pi(this,e));return o===l?null:o===n&&l===r?s:s=t(n=o,r=l)}}function b2(e){return function(){this.style.removeProperty(e)}}function u6(e,t,n){var r,s=n+"",o;return function(){var l=pi(this,e);return l===s?null:l===r?o:o=t(r=l,n)}}function d6(e,t,n){var r,s,o;return function(){var l=pi(this,e),c=n(this),d=c+"";return c==null&&(d=c=(this.style.removeProperty(e),pi(this,e))),l===d?null:l===r&&d===s?o:(s=d,o=t(r=l,c))}}function h6(e,t){var n,r,s,o="style."+t,l="end."+o,c;return function(){var d=Wr(this,e),h=d.on,f=d.value[o]==null?c||(c=b2(t)):void 0;(h!==n||s!==f)&&(r=(n=h).copy()).on(l,s=f),d.on=r}}function f6(e,t,n){var r=(e+="")=="transform"?f5:x2;return t==null?this.styleTween(e,c6(e,r)).on("end.style."+e,b2(e)):typeof t=="function"?this.styleTween(e,d6(e,r,Kb(this,"style."+e,t))).each(h6(this._id,e)):this.styleTween(e,u6(e,r,t),n).on("end.style."+e,null)}function p6(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function m6(e,t,n){var r,s;function o(){var l=t.apply(this,arguments);return l!==s&&(r=(s=l)&&p6(e,l,n)),r}return o._value=t,o}function g6(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,m6(e,t,n??""))}function y6(e){return function(){this.textContent=e}}function w6(e){return function(){var t=e(this);this.textContent=t??""}}function v6(e){return this.tween("text",typeof e=="function"?w6(Kb(this,"text",e)):y6(e==null?"":e+""))}function x6(e){return function(t){this.textContent=e.call(this,t)}}function b6(e){var t,n;function r(){var s=e.apply(this,arguments);return s!==n&&(t=(n=s)&&x6(s)),t}return r._value=e,r}function k6(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,b6(e))}function N6(){for(var e=this._name,t=this._id,n=k2(),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=vr(d,t);eh(d,e,n,h,l,{time:f.time+f.delay+f.duration,delay:0,duration:f.duration,ease:f.ease})}return new xs(r,this._parents,e,n)}function j6(){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=Wr(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 S6=0;function xs(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function k2(){return++S6}var ds=gc.prototype;xs.prototype={constructor:xs,select:a6,selectAll:o6,selectChild:ds.selectChild,selectChildren:ds.selectChildren,filter:J5,merge:Q5,selection:l6,transition:N6,call:ds.call,nodes:ds.nodes,node:ds.node,size:ds.size,empty:ds.empty,each:ds.each,on:n6,attr:L5,attrTween:q5,style:f6,styleTween:g6,text:v6,textTween:k6,remove:s6,tween:C5,delay:W5,duration:G5,ease:Y5,easeVarying:Z5,end:j6,[Symbol.iterator]:ds[Symbol.iterator]};function _6(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var E6={time:null,delay:0,duration:250,ease:_6};function T6(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 C6(e){var t,n;e instanceof xs?(t=e._id,e=e._name):(t=k2(),(n=E6).time=Vb(),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])&&eh(d,e,t,h,l,n||T6(d,t));return new xs(r,this._parents,e,t)}gc.prototype.interrupt=_5;gc.prototype.transition=C6;const $u=e=>()=>e;function A6(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 $p(e){e.stopImmediatePropagation()}function kl(e){e.preventDefault(),e.stopImmediatePropagation()}function R6(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function M6(){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 ij(){return this.__zoom||ys}function $6(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function I6(){return navigator.maxTouchPoints||"ontouchstart"in this}function O6(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 N2(){var e=R6,t=M6,n=O6,r=$6,s=I6,o=[0,1/0],l=[[-1/0,-1/0],[1/0,1/0]],c=250,d=w5,h=Zd("start","zoom","end"),f,p,g,v=500,j=150,k=0,x=10;function N(C){C.property("__zoom",ij).on("wheel.zoom",q,{passive:!1}).on("mousedown.zoom",I).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(C,$,P,K){var G=C.selection?C.selection():C;G.property("__zoom",ij),C!==G?R(C,$,P,K):G.interrupt().each(function(){O(this,arguments).event(K).start().zoom(null,typeof $=="function"?$.apply(this,arguments):$).end()})},N.scaleBy=function(C,$,P,K){N.scaleTo(C,function(){var G=this.__zoom.k,U=typeof $=="function"?$.apply(this,arguments):$;return G*U},P,K)},N.scaleTo=function(C,$,P,K){N.transform(C,function(){var G=t.apply(this,arguments),U=this.__zoom,W=P==null?E(G):typeof P=="function"?P.apply(this,arguments):P,D=U.invert(W),H=typeof $=="function"?$.apply(this,arguments):$;return n(S(b(U,H),W,D),G,l)},P,K)},N.translateBy=function(C,$,P,K){N.transform(C,function(){return n(this.__zoom.translate(typeof $=="function"?$.apply(this,arguments):$,typeof P=="function"?P.apply(this,arguments):P),t.apply(this,arguments),l)},null,K)},N.translateTo=function(C,$,P,K,G){N.transform(C,function(){var U=t.apply(this,arguments),W=this.__zoom,D=K==null?E(U):typeof K=="function"?K.apply(this,arguments):K;return n(ys.translate(D[0],D[1]).scale(W.k).translate(typeof $=="function"?-$.apply(this,arguments):-$,typeof P=="function"?-P.apply(this,arguments):-P),U,l)},K,G)};function b(C,$){return $=Math.max(o[0],Math.min(o[1],$)),$===C.k?C:new ms($,C.x,C.y)}function S(C,$,P){var K=$[0]-P[0]*C.k,G=$[1]-P[1]*C.k;return K===C.x&&G===C.y?C:new ms(C.k,K,G)}function E(C){return[(+C[0][0]+ +C[1][0])/2,(+C[0][1]+ +C[1][1])/2]}function R(C,$,P,K){C.on("start.zoom",function(){O(this,arguments).event(K).start()}).on("interrupt.zoom end.zoom",function(){O(this,arguments).event(K).end()}).tween("zoom",function(){var G=this,U=arguments,W=O(G,U).event(K),D=t.apply(G,U),H=P==null?E(D):typeof P=="function"?P.apply(G,U):P,J=Math.max(D[1][0]-D[0][0],D[1][1]-D[0][1]),V=G.__zoom,Z=typeof $=="function"?$.apply(G,U):$,Y=d(V.invert(H).concat(J/V.k),Z.invert(H).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,H[0]-ee[0]*ae,H[1]-ee[1]*ae)}W.zoom(null,X)}})}function O(C,$,P){return!P&&C.__zooming||new A(C,$)}function A(C,$){this.that=C,this.args=$,this.active=0,this.sourceEvent=null,this.extent=t.apply(C,$),this.taps=0}A.prototype={event:function(C){return C&&(this.sourceEvent=C),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(C,$){return this.mouse&&C!=="mouse"&&(this.mouse[1]=$.invert(this.mouse[0])),this.touch0&&C!=="touch"&&(this.touch0[1]=$.invert(this.touch0[0])),this.touch1&&C!=="touch"&&(this.touch1[1]=$.invert(this.touch1[0])),this.that.__zoom=$,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(C){var $=Un(this.that).datum();h.call(C,this.that,new A6(C,{sourceEvent:this.sourceEvent,target:N,transform:this.that.__zoom,dispatch:h}),$)}};function q(C,...$){if(!e.apply(this,arguments))return;var P=O(this,$).event(C),K=this.__zoom,G=Math.max(o[0],Math.min(o[1],K.k*Math.pow(2,r.apply(this,arguments)))),U=dr(C);if(P.wheel)(P.mouse[0][0]!==U[0]||P.mouse[0][1]!==U[1])&&(P.mouse[1]=K.invert(P.mouse[0]=U)),clearTimeout(P.wheel);else{if(K.k===G)return;P.mouse=[U,K.invert(U)],ad(this),P.start()}kl(C),P.wheel=setTimeout(W,j),P.zoom("mouse",n(S(b(K,G),P.mouse[0],P.mouse[1]),P.extent,l));function W(){P.wheel=null,P.end()}}function I(C,...$){if(g||!e.apply(this,arguments))return;var P=C.currentTarget,K=O(this,$,!0).event(C),G=Un(C.view).on("mousemove.zoom",H,!0).on("mouseup.zoom",J,!0),U=dr(C,P),W=C.clientX,D=C.clientY;l2(C.view),$p(C),K.mouse=[U,this.__zoom.invert(U)],ad(this),K.start();function H(V){if(kl(V),!K.moved){var Z=V.clientX-W,Y=V.clientY-D;K.moved=Z*Z+Y*Y>k}K.event(V).zoom("mouse",n(S(K.that.__zoom,K.mouse[0]=dr(V,P),K.mouse[1]),K.extent,l))}function J(V){G.on("mousemove.zoom mouseup.zoom",null),c2(V.view,K.moved),kl(V),K.event(V).end()}}function B(C,...$){if(e.apply(this,arguments)){var P=this.__zoom,K=dr(C.changedTouches?C.changedTouches[0]:C,this),G=P.invert(K),U=P.k*(C.shiftKey?.5:2),W=n(S(b(P,U),K,G),t.apply(this,$),l);kl(C),c>0?Un(this).transition().duration(c).call(R,W,K,C):Un(this).call(N.transform,W,K,C)}}function L(C,...$){if(e.apply(this,arguments)){var P=C.touches,K=P.length,G=O(this,$,C.changedTouches.length===K).event(C),U,W,D,H;for($p(C),W=0;W<K;++W)D=P[W],H=dr(D,this),H=[H,this.__zoom.invert(H),D.identifier],G.touch0?!G.touch1&&G.touch0[2]!==H[2]&&(G.touch1=H,G.taps=0):(G.touch0=H,U=!0,G.taps=1+!!f);f&&(f=clearTimeout(f)),U&&(G.taps<2&&(p=H[0],f=setTimeout(function(){f=null},v)),ad(this),G.start())}}function M(C,...$){if(this.__zooming){var P=O(this,$).event(C),K=C.changedTouches,G=K.length,U,W,D,H;for(kl(C),U=0;U<G;++U)W=K[U],D=dr(W,this),P.touch0&&P.touch0[2]===W.identifier?P.touch0[0]=D:P.touch1&&P.touch1[2]===W.identifier&&(P.touch1[0]=D);if(W=P.that.__zoom,P.touch1){var J=P.touch0[0],V=P.touch0[1],Z=P.touch1[0],Y=P.touch1[1],X=(X=Z[0]-J[0])*X+(X=Z[1]-J[1])*X,ee=(ee=Y[0]-V[0])*ee+(ee=Y[1]-V[1])*ee;W=b(W,Math.sqrt(X/ee)),D=[(J[0]+Z[0])/2,(J[1]+Z[1])/2],H=[(V[0]+Y[0])/2,(V[1]+Y[1])/2]}else if(P.touch0)D=P.touch0[0],H=P.touch0[1];else return;P.zoom("touch",n(S(W,D,H),P.extent,l))}}function F(C,...$){if(this.__zooming){var P=O(this,$).event(C),K=C.changedTouches,G=K.length,U,W;for($p(C),g&&clearTimeout(g),g=setTimeout(function(){g=null},v),U=0;U<G;++U)W=K[U],P.touch0&&P.touch0[2]===W.identifier?delete P.touch0:P.touch1&&P.touch1[2]===W.identifier&&delete P.touch1;if(P.touch1&&!P.touch0&&(P.touch0=P.touch1,delete P.touch1),P.touch0)P.touch0[1]=this.__zoom.invert(P.touch0[0]);else if(P.end(),P.taps===2&&(W=dr(W,this),Math.hypot(p[0]-W[0],p[1]-W[1])<x)){var D=Un(this).on("dblclick.zoom");D&&D.apply(this,arguments)}}}return N.wheelDelta=function(C){return arguments.length?(r=typeof C=="function"?C:$u(+C),N):r},N.filter=function(C){return arguments.length?(e=typeof C=="function"?C:$u(!!C),N):e},N.touchable=function(C){return arguments.length?(s=typeof C=="function"?C:$u(!!C),N):s},N.extent=function(C){return arguments.length?(t=typeof C=="function"?C:$u([[+C[0][0],+C[0][1]],[+C[1][0],+C[1][1]]]),N):t},N.scaleExtent=function(C){return arguments.length?(o[0]=+C[0],o[1]=+C[1],N):[o[0],o[1]]},N.translateExtent=function(C){return arguments.length?(l[0][0]=+C[0][0],l[1][0]=+C[1][0],l[0][1]=+C[0][1],l[1][1]=+C[1][1],N):[[l[0][0],l[0][1]],[l[1][0],l[1][1]]]},N.constrain=function(C){return arguments.length?(n=C,N):n},N.duration=function(C){return arguments.length?(c=+C,N):c},N.interpolate=function(C){return arguments.length?(d=C,N):d},N.on=function(){var C=h.on.apply(h,arguments);return C===h?N:C},N.clickDistance=function(C){return arguments.length?(k=(C=+C)*C,N):Math.sqrt(k)},N.tapDistance=function(C){return arguments.length?(x=+C,N):x},N}var Dt=KM();const th=y.createContext(null),L6=th.Provider,bs={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.`},j2=bs.error001();function Ue(e,t){const n=y.useContext(th);if(n===null)throw new Error(j2);return YM(n,e,t)}const jt=()=>{const e=y.useContext(th);if(e===null)throw new Error(j2);return y.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy}),[e])},P6=e=>e.userSelectionActive?"none":"all";function Yb({position:e,children:t,className:n,style:r,...s}){const o=Ue(P6),l=`${e}`.split("-");return he.createElement("div",{className:zt(["react-flow__panel",n,...l]),style:{...r,pointerEvents:o},...s},t)}function D6({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:he.createElement(Yb,{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 F6=({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=zt(["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 B6=y.memo(F6);const Xb=e=>({width:e.offsetWidth,height:e.offsetHeight}),gi=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Zb=(e={x:0,y:0},t)=>({x:gi(e.x,t[0][0],t[1][0]),y:gi(e.y,t[0][1],t[1][1])}),lj=(e,t,n)=>e<t?gi(Math.abs(e-t),1,50)/50:e>n?-gi(Math.abs(e-n),1,50)/50:0,S2=(e,t)=>{const n=lj(e.x,35,t.width-35)*20,r=lj(e.y,35,t.height-35)*20;return[n,r]},_2=e=>{var t;return((t=e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},E2=(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)}),Zl=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),T2=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),cj=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),q6=(e,t)=>T2(E2(Zl(e),Zl(t))),Px=(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)},U6=e=>zn(e.width)&&zn(e.height)&&zn(e.x)&&zn(e.y),zn=e=>!isNaN(e)&&isFinite(e),mt=Symbol.for("internals"),C2=["Enter"," ","Escape"],z6=(e,t)=>{},W6=e=>"nativeEvent"in e;function Dx(e){var s,o;const t=W6(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 A2=e=>"clientX"in e,ua=(e,t)=>{var o,l;const n=A2(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)}},bd=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0},wc=({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&&zn(n)&&zn(r)?he.createElement(B6,{x:n,y:r,label:s,labelStyle:o,labelShowBg:l,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h}):null);wc.displayName="BaseEdge";function Nl(e,t,n){return n===void 0?n:r=>{const s=t().edges.find(o=>o.id===e);s&&n(r,{...s})}}function R2({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 M2({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 eo;(function(e){e.Strict="strict",e.Loose="loose"})(eo||(eo={}));var Ha;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Ha||(Ha={}));var Jl;(function(e){e.Partial="partial",e.Full="full"})(Jl||(Jl={}));var aa;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(aa||(aa={}));var kd;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(kd||(kd={}));var Ae;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Ae||(Ae={}));function uj({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 $2({sourceX:e,sourceY:t,sourcePosition:n=Ae.Bottom,targetX:r,targetY:s,targetPosition:o=Ae.Top}){const[l,c]=uj({pos:n,x1:e,y1:t,x2:r,y2:s}),[d,h]=uj({pos:o,x1:r,y1:s,x2:e,y2:t}),[f,p,g,v]=M2({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 Jb=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]=$2({sourceX:e,sourceY:t,sourcePosition:s,targetX:n,targetY:r,targetPosition:o});return he.createElement(wc,{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})});Jb.displayName="SimpleBezierEdge";const dj={[Ae.Left]:{x:-1,y:0},[Ae.Right]:{x:1,y:0},[Ae.Top]:{x:0,y:-1},[Ae.Bottom]:{x:0,y:1}},H6=({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},hj=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function V6({source:e,sourcePosition:t=Ae.Bottom,target:n,targetPosition:r=Ae.Top,center:s,offset:o}){const l=dj[t],c=dj[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=H6({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]=R2({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 C=Math.min(o-1,o-F);l[p]===g?x[p]=(d[p]>e[p]?-1:1)*C:N[p]=(h[p]>n[p]?-1:1)*C}}if(t!==r){const F=p==="x"?"y":"x",C=l[p]===c[F],$=d[F]>h[F],P=d[F]<h[F];(l[p]===1&&(!C&&$||C&&P)||l[p]!==1&&(!C&&P||C&&$))&&(v=p==="x"?A:q)}const I={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(I.x-v[0].x),Math.abs(B.x-v[0].x)),M=Math.max(Math.abs(I.y-v[0].y),Math.abs(B.y-v[0].y));L>=M?(j=(I.x+B.x)/2,k=v[0].y):(j=v[0].x,k=(I.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 G6(e,t,n,r){const s=Math.min(hj(e,t)/2,hj(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 Fx({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]=V6({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=G6(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 nh=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]=Fx({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(wc,{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})});nh.displayName="SmoothStepEdge";const Qb=y.memo(e=>{var t;return he.createElement(nh,{...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])})});Qb.displayName="StepEdge";function K6({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[s,o,l,c]=R2({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,s,o,l,c]}const e0=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]=K6({sourceX:e,sourceY:t,targetX:n,targetY:r});return he.createElement(wc,{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})});e0.displayName="StraightEdge";function Iu(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function fj({pos:e,x1:t,y1:n,x2:r,y2:s,c:o}){switch(e){case Ae.Left:return[t-Iu(t-r,o),n];case Ae.Right:return[t+Iu(r-t,o),n];case Ae.Top:return[t,n-Iu(n-s,o)];case Ae.Bottom:return[t,n+Iu(s-n,o)]}}function t0({sourceX:e,sourceY:t,sourcePosition:n=Ae.Bottom,targetX:r,targetY:s,targetPosition:o=Ae.Top,curvature:l=.25}){const[c,d]=fj({pos:n,x1:e,y1:t,x2:r,y2:s,c:l}),[h,f]=fj({pos:o,x1:r,y1:s,x2:e,y2:t,c:l}),[p,g,v,j]=M2({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 Nd=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]=t0({sourceX:e,sourceY:t,sourcePosition:s,targetX:n,targetY:r,targetPosition:o,curvature:k==null?void 0:k.curvature});return he.createElement(wc,{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})});Nd.displayName="BezierEdge";const n0=y.createContext(null),Y6=n0.Provider;n0.Consumer;const X6=()=>y.useContext(n0),Z6=e=>"id"in e&&"source"in e&&"target"in e,J6=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`reactflow__edge-${e}${t||""}-${n}${r||""}`,Bx=(e,t)=>typeof e>"u"?"":typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`,Q6=(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)),eB=(e,t)=>{if(!e.source||!e.target)return t;let n;return Z6(e)?n={...e}:n={...e,id:J6(e)},Q6(n,t)?t:t.concat(n)},qx=({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},I2=({x:e,y:t},[n,r,s])=>({x:e*s+n,y:t*s+r}),Ya=(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}},rh=(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}=Ya(s,t).positionAbsolute;return E2(r,Zl({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 T2(n)},O2=(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}=Ya(f,c),x={x:k.x,y:k.y,width:p||0,height:g||0},N=Px(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},L2=(e,t)=>{const n=e.map(r=>r.id);return t.filter(r=>n.includes(r.source)||n.includes(r.target))},P2=(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=gi(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}},Fa=(e,t=0)=>e.transition().duration(t);function pj(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 tB(e,t,n,r,s,o){const{x:l,y:c}=ua(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=r0(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:D2()};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 nB={source:null,target:null,sourceHandle:null,targetHandle:null},D2=()=>({handleDomNode:null,isValid:!1,connection:nB,endHandle:null});function F2(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={...D2(),handleDomNode:d};if(d){const f=r0(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===eo.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 rB({nodes:e,nodeId:t,handleId:n,handleType:r}){return e.reduce((s,o)=>{if(o[mt]){const{handleBounds:l}=o[mt];let c=[],d=[];l&&(c=pj(o,l,"source",`${t}-${n}-${r}`),d=pj(o,l,"target",`${t}-${n}-${r}`)),s.push(...c,...d)}return s},[])}function r0(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function Ip(e){e==null||e.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function sB(e,t){let n=null;return t?n="valid":e&&!t&&(n="invalid"),n}function B2({event:e,handleId:t,nodeId:n,onConnect:r,isTarget:s,getState:o,setState:l,isValidConnection:c,edgeUpdaterType:d,onReconnectEnd:h}){const f=_2(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:O}=ua(e),A=f==null?void 0:f.elementFromPoint(R,O),q=r0(d,A),I=g==null?void 0:g.getBoundingClientRect();if(!I||!q)return;let B,L=ua(e,I),M=!1,F=null,C=!1,$=null;const P=rB({nodes:N(),nodeId:n,handleId:t,handleType:q}),K=()=>{if(!v)return;const[W,D]=S2(L,I);x({x:W,y:D}),S=requestAnimationFrame(K)};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 G(W){const{transform:D}=o();L=ua(W,I);const{handle:H,validHandleResult:J}=tB(W,f,qx(L,D,!1,[1,1]),j,P,V=>F2(V,p,n,t,s?"target":"source",c,f));if(E=H,M||(K(),M=!0),$=J.handleDomNode,F=J.connection,C=J.isValid,l({connectionPosition:E&&C?I2({x:E.x,y:E.y},D):L,connectionStatus:sB(!!E,C),connectionEndHandle:J.endHandle}),!E&&!C&&!$)return Ip(B);F.source!==F.target&&$&&(Ip(B),B=$,$.classList.add("connecting","react-flow__handle-connecting"),$.classList.toggle("valid",C),$.classList.toggle("react-flow__handle-valid",C))}function U(W){var D,H;(E||$)&&F&&C&&(r==null||r(F)),(H=(D=o()).onConnectEnd)==null||H.call(D,W),d&&(h==null||h(W)),Ip(B),b(),cancelAnimationFrame(S),M=!1,C=!1,F=null,$=null,f.removeEventListener("mousemove",G),f.removeEventListener("mouseup",U),f.removeEventListener("touchmove",G),f.removeEventListener("touchend",U)}f.addEventListener("mousemove",G),f.addEventListener("mouseup",U),f.addEventListener("touchmove",G),f.addEventListener("touchend",U)}const mj=()=>!0,aB=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),oB=(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}},q2=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 I,B;const j=l||null,k=e==="target",x=jt(),N=X6(),{connectOnClick:b,noPanClassName:S}=Ue(aB,Rt),{connecting:E,clickConnecting:R}=Ue(oB(N,j,e),Rt);N||(B=(I=x.getState()).onError)==null||B.call(I,"010",bs.error010());const O=L=>{const{defaultEdgeOptions:M,onConnect:F,hasDefaultEdges:C}=x.getState(),$={...M,...L};if(C){const{edges:P,setEdges:K}=x.getState();K(eB($,P))}F==null||F($),c==null||c($)},A=L=>{if(!N)return;const M=A2(L);s&&(M&&L.button===0||!M)&&B2({event:L,handleId:j,nodeId:N,onConnect:O,isTarget:k,getState:x.getState,setState:x.setState,isValidConnection:n||x.getState().isValidConnection||mj}),M?f==null||f(L):p==null||p(L)},q=L=>{const{onClickConnectStart:M,onClickConnectEnd:F,connectionClickStartHandle:C,connectionMode:$,isValidConnection:P}=x.getState();if(!N||!C&&!s)return;if(!C){M==null||M(L,{nodeId:N,handleId:j,handleType:e}),x.setState({connectionClickStartHandle:{nodeId:N,type:e,handleId:j}});return}const K=_2(L.target),G=n||P||mj,{connection:U,isValid:W}=F2({nodeId:N,id:j,type:e},$,C.nodeId,C.handleId||null,C.type,G,K);W&&O(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:zt(["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)});q2.displayName="Handle";var to=y.memo(q2);const U2=({data:e,isConnectable:t,targetPosition:n=Ae.Top,sourcePosition:r=Ae.Bottom})=>he.createElement(he.Fragment,null,he.createElement(to,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,he.createElement(to,{type:"source",position:r,isConnectable:t}));U2.displayName="DefaultNode";var Ux=y.memo(U2);const z2=({data:e,isConnectable:t,sourcePosition:n=Ae.Bottom})=>he.createElement(he.Fragment,null,e==null?void 0:e.label,he.createElement(to,{type:"source",position:n,isConnectable:t}));z2.displayName="InputNode";var W2=y.memo(z2);const H2=({data:e,isConnectable:t,targetPosition:n=Ae.Top})=>he.createElement(he.Fragment,null,he.createElement(to,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label);H2.displayName="OutputNode";var V2=y.memo(H2);const s0=()=>null;s0.displayName="GroupNode";const iB=e=>({selectedNodes:e.getNodes().filter(t=>t.selected),selectedEdges:e.edges.filter(t=>t.selected).map(t=>({...t}))}),Ou=e=>e.id;function lB(e,t){return Rt(e.selectedNodes.map(Ou),t.selectedNodes.map(Ou))&&Rt(e.selectedEdges.map(Ou),t.selectedEdges.map(Ou))}const G2=y.memo(({onSelectionChange:e})=>{const t=jt(),{selectedNodes:n,selectedEdges:r}=Ue(iB,lB);return y.useEffect(()=>{const s={nodes:n,edges:r};e==null||e(s),t.getState().onSelectionChange.forEach(o=>o(s))},[n,r,e]),null});G2.displayName="SelectionListener";const cB=e=>!!e.onSelectionChange;function uB({onSelectionChange:e}){const t=Ue(cB);return e||t?he.createElement(G2,{onSelectionChange:e}):null}const dB=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 Uo(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 hB=({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:O,snapToGrid:A,translateExtent:q,connectOnClick:I,defaultEdgeOptions:B,fitView:L,fitViewOptions:M,onNodesDelete:F,onEdgesDelete:C,onNodeDrag:$,onNodeDragStart:P,onNodeDragStop:K,onSelectionDrag:G,onSelectionDragStart:U,onSelectionDragStop:W,noPanClassName:D,nodeOrigin:H,rfId:J,autoPanOnConnect:V,autoPanOnNodeDrag:Z,onError:Y,connectionRadius:X,isValidConnection:ee,nodeDragThreshold:ae})=>{const{setNodes:ue,setEdges:ge,setDefaultNodesAndEdges:ye,setMinZoom:se,setMaxZoom:me,setTranslateExtent:pe,setNodeExtent:de,reset:fe}=Ue(dB,Rt),ne=jt();return y.useEffect(()=>{const oe=r==null?void 0:r.map(Ne=>({...Ne,...B}));return ye(n,oe),()=>{fe()}},[]),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",O,ne.setState),Fe("onNodesChange",b,ne.setState),Fe("onEdgesChange",S,ne.setState),Fe("connectOnClick",I,ne.setState),Fe("fitViewOnInit",L,ne.setState),Fe("fitViewOnInitOptions",M,ne.setState),Fe("onNodesDelete",F,ne.setState),Fe("onEdgesDelete",C,ne.setState),Fe("onNodeDrag",$,ne.setState),Fe("onNodeDragStart",P,ne.setState),Fe("onNodeDragStop",K,ne.setState),Fe("onSelectionDrag",G,ne.setState),Fe("onSelectionDragStart",U,ne.setState),Fe("onSelectionDragStop",W,ne.setState),Fe("noPanClassName",D,ne.setState),Fe("nodeOrigin",H,ne.setState),Fe("rfId",J,ne.setState),Fe("autoPanOnConnect",V,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),Uo(e,ue),Uo(t,ge),Uo(k,se),Uo(x,me),Uo(q,pe),Uo(N,de),null},gj={display:"none"},fB={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},K2="react-flow__node-desc",Y2="react-flow__edge-desc",pB="react-flow__aria-live",mB=e=>e.ariaLiveMessage;function gB({rfId:e}){const t=Ue(mB);return he.createElement("div",{id:`${pB}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:fB},t)}function yB({rfId:e,disableKeyboardA11y:t}){return he.createElement(he.Fragment,null,he.createElement("div",{id:`${K2}-${e}`,style:gj},"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:`${Y2}-${e}`,style:gj},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!t&&he.createElement(gB,{rfId:e}))}var Ql=(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)&&Dx(v))return!1;const k=wj(v.code,c);o.current.add(v[k]),yj(l,o.current,!1)&&(v.preventDefault(),r(!0))},p=v=>{if((!s.current||s.current&&!t.actInsideInputWithModifier)&&Dx(v))return!1;const k=wj(v.code,c);yj(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 yj(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(s=>t.has(s)))}function wj(e,t){return t.includes(e)?"code":"key"}function X2(e,t,n,r){var c,d;const s=e.parentNode||e.parentId;if(!s)return n;const o=t.get(s),l=Ya(o,r);return X2(o,t,{x:(n.x??0)+l.x,y:(n.y??0)+l.y,z:(((c=o[mt])==null?void 0:c.z)??0)>(n.z??0)?((d=o[mt])==null?void 0:d.z)??0:n.z??0},r)}function Z2(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}=X2(r,e,{...r.position,z:((o=r[mt])==null?void 0:o.z)??0},t);r.positionAbsolute={x:l,y:c},r[mt].z=d,n!=null&&n[r.id]&&(r[mt].isParent=!0)}})}function Op(e,t,n,r){const s=new Map,o={},l=r?1e3:0;return e.forEach(c=>{var v;const d=(zn(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,mt,{enumerable:!1,value:{handleBounds:g||(v=h==null?void 0:h[mt])==null?void 0:v.handleBounds,z:d}}),s.set(c.id,f)}),Z2(s,n,o),s}function J2(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=rh(j,p),{x:N,y:b,zoom:S}=P2(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(Fa(d,t.duration),E):c.transform(d,E),!0}}return!1}function wB(e,t){return e.forEach(n=>{const r=t.get(n.id);r&&t.set(r.id,{...r,[mt]:r[mt],selected:n.selected})}),new Map(t)}function vB(e,t){return t.map(n=>{const r=e.find(s=>s.id===n.id);return r&&(n.selected=r.selected),n})}function Lu({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:wB(e,s)}),l==null||l(e)),t!=null&&t.length&&(h&&r({edges:vB(t,o)}),c==null||c(t))}const zo=()=>{},xB={zoomIn:zo,zoomOut:zo,zoomTo:zo,getZoom:()=>1,setViewport:zo,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:zo,fitBounds:zo,project:e=>e,screenToFlowPosition:e=>e,flowToScreenPosition:e=>e,viewportInitialized:!1},bB=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection}),kB=()=>{const e=jt(),{d3Zoom:t,d3Selection:n}=Ue(bB,Rt);return y.useMemo(()=>n&&t?{zoomIn:s=>t.scaleBy(Fa(n,s==null?void 0:s.duration),1.2),zoomOut:s=>t.scaleBy(Fa(n,s==null?void 0:s.duration),1/1.2),zoomTo:(s,o)=>t.scaleTo(Fa(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(Fa(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=>J2(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(Fa(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}=P2(s,l,c,d,h,(o==null?void 0:o.padding)??.1),v=ys.translate(f,p).scale(g);t.transform(Fa(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"),qx(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 qx(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=I2(s,o);return{x:h.x+c,y:h.y+d}},viewportInitialized:!0}:xB,[t,n])};function Ti(){const e=kB(),t=jt(),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 O=R.length===0?E.map(A=>({type:"remove",id:A.id})):R.map(A=>({item:A,type:"reset"}));S(O)}},[]),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(O=>({type:"remove",id:O.id})):E.map(O=>({item:O,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 O=[...N(),...x];b(O)}else if(E){const R=x.map(O=>({item:O,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(O=>({item:O,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:O,onEdgesDelete:A,onNodesChange:q,onEdgesChange:I}=t.getState(),B=(k||[]).map($=>$.id),L=(x||[]).map($=>$.id),M=b().reduce(($,P)=>{const K=P.parentNode||P.parentId,G=!B.includes(P.id)&&K&&$.find(W=>W.id===K);return(typeof P.deletable=="boolean"?P.deletable:!0)&&(B.includes(P.id)||G)&&$.push(P),$},[]),F=S.filter($=>typeof $.deletable=="boolean"?$.deletable:!0),C=F.filter($=>L.includes($.id));if(M||C){const $=L2(M,F),P=[...C,...$],K=P.reduce((G,U)=>(G.includes(U.id)||G.push(U.id),G),[]);if((R||E)&&(R&&t.setState({edges:S.filter(G=>!K.includes(G.id))}),E&&(M.forEach(G=>{N.delete(G.id)}),t.setState({nodeInternals:new Map(N)}))),K.length>0&&(A==null||A(P),I&&I(K.map(G=>({id:G,type:"remove"})))),M.length>0&&(O==null||O(M),q)){const G=M.map(U=>({id:U.id,type:"remove"}));q(G)}}},[]),g=y.useCallback(k=>{const x=U6(k),N=x?null:t.getState().nodeInternals.get(k.id);return!x&&!N?[null,null,x]:[x?k:cj(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 O=cj(R),A=Px(O,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=Px(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 NB={actInsideInputWithModifier:!1};var jB=({deleteKeyCode:e,multiSelectionKeyCode:t})=>{const n=jt(),{deleteElements:r}=Ti(),s=Ql(e,NB),o=Ql(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 SB(e){const t=jt();y.useEffect(()=>{let n;const r=()=>{var o,l;if(!e.current)return;const s=Xb(e.current);(s.height===0||s.width===0)&&((l=(o=t.getState()).onError)==null||l.call(o,"004",bs.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 a0={position:"absolute",width:"100%",height:"100%",top:0,left:0},_B=(e,t)=>e.x!==t.x||e.y!==t.y||e.zoom!==t.k,Pu=e=>({x:e.x,y:e.y,zoom:e.k}),Wo=(e,t)=>e.target.closest(`.${t}`),vj=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),xj=e=>{const t=e.ctrlKey&&bd()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t},EB=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),TB=({onMove:e,onMoveStart:t,onMoveEnd:n,onPaneContextMenu:r,zoomOnScroll:s=!0,zoomOnPinch:o=!0,panOnScroll:l=!1,panOnScrollSpeed:c=.5,panOnScrollMode:d=Ha.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(),O=jt(),A=y.useRef(!1),q=y.useRef(!1),I=y.useRef(null),B=y.useRef({x:0,y:0,zoom:0}),{d3Zoom:L,d3Selection:M,d3ZoomHandler:F,userSelectionActive:C}=Ue(EB,Rt),$=Ql(x),P=y.useRef(0),K=y.useRef(!1),G=y.useRef();return SB(I),y.useEffect(()=>{if(I.current){const U=I.current.getBoundingClientRect(),W=N2().scaleExtent([j,k]).translateExtent(v),D=Un(I.current).call(W),H=ys.translate(g.x,g.y).scale(gi(g.zoom,j,k)),J=[[0,0],[U.width,U.height]],V=W.constrain()(H,J,v);W.transform(D,V),W.wheelDelta(xj),O.setState({d3Zoom:W,d3Selection:D,d3ZoomHandler:D.on("wheel.zoom"),transform:[V.x,V.y,V.k],domNode:I.current.closest(".react-flow")})}},[]),y.useEffect(()=>{M&&L&&(l&&!$&&!C?M.on("wheel.zoom",U=>{if(Wo(U,S))return!1;U.preventDefault(),U.stopImmediatePropagation();const W=M.property("__zoom").k||1;if(U.ctrlKey&&o){const ee=dr(U),ae=xj(U),ue=W*Math.pow(2,ae);L.scaleTo(M,ue,ee,U);return}const D=U.deltaMode===1?20:1;let H=d===Ha.Vertical?0:U.deltaX*D,J=d===Ha.Horizontal?0:U.deltaY*D;!bd()&&U.shiftKey&&d!==Ha.Vertical&&(H=U.deltaY*D,J=0),L.translateBy(M,-(H/W)*c,-(J/W)*c,{internal:!0});const V=Pu(M.property("__zoom")),{onViewportChangeStart:Z,onViewportChange:Y,onViewportChangeEnd:X}=O.getState();clearTimeout(G.current),K.current||(K.current=!0,t==null||t(U,V),Z==null||Z(V)),K.current&&(e==null||e(U,V),Y==null||Y(V),G.current=setTimeout(()=>{n==null||n(U,V),X==null||X(V),K.current=!1},150))},{passive:!1}):typeof F<"u"&&M.on("wheel.zoom",function(U,W){if(!N&&U.type==="wheel"&&!U.ctrlKey||Wo(U,S))return null;U.preventDefault(),F.call(this,U,W)},{passive:!1}))},[C,l,d,M,L,F,$,o,N,S,t,e,n]),y.useEffect(()=>{L&&L.on("start",U=>{var H,J;if(!U.sourceEvent||U.sourceEvent.internal)return null;P.current=(H=U.sourceEvent)==null?void 0:H.button;const{onViewportChangeStart:W}=O.getState(),D=Pu(U.transform);A.current=!0,B.current=D,((J=U.sourceEvent)==null?void 0:J.type)==="mousedown"&&O.setState({paneDragging:!0}),W==null||W(D),t==null||t(U.sourceEvent,D)})},[L,t]),y.useEffect(()=>{L&&(C&&!A.current?L.on("zoom",null):C||L.on("zoom",U=>{var D;const{onViewportChange:W}=O.getState();if(O.setState({transform:[U.transform.x,U.transform.y,U.transform.k]}),q.current=!!(r&&vj(p,P.current??0)),(e||W)&&!((D=U.sourceEvent)!=null&&D.internal)){const H=Pu(U.transform);W==null||W(H),e==null||e(U.sourceEvent,H)}}))},[C,L,e,p,r]),y.useEffect(()=>{L&&L.on("end",U=>{if(!U.sourceEvent||U.sourceEvent.internal)return null;const{onViewportChangeEnd:W}=O.getState();if(A.current=!1,O.setState({paneDragging:!1}),r&&vj(p,P.current??0)&&!q.current&&r(U.sourceEvent),q.current=!1,(n||W)&&_B(B.current,U.transform)){const D=Pu(U.transform);B.current=D,clearTimeout(R.current),R.current=setTimeout(()=>{W==null||W(D),n==null||n(U.sourceEvent,D)},l?150:0)}})},[L,l,p,n,r]),y.useEffect(()=>{L&&L.filter(U=>{const W=$||s,D=o&&U.ctrlKey;if((p===!0||Array.isArray(p)&&p.includes(1))&&U.button===1&&U.type==="mousedown"&&(Wo(U,"react-flow__node")||Wo(U,"react-flow__edge")))return!0;if(!p&&!W&&!l&&!h&&!o||C||!h&&U.type==="dblclick"||Wo(U,S)&&U.type==="wheel"||Wo(U,E)&&(U.type!=="wheel"||l&&U.type==="wheel"&&!$)||!o&&U.ctrlKey&&U.type==="wheel"||!W&&!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 H=Array.isArray(p)&&p.includes(U.button)||!U.button||U.button<=1;return(!U.ctrlKey||U.type==="wheel")&&H})},[C,L,s,o,l,h,p,f,$]),he.createElement("div",{className:"react-flow__renderer",ref:I,style:a0},b)},CB=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function AB(){const{userSelectionActive:e,userSelectionRect:t}=Ue(CB,Rt);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 bj(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 RB(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&&bj(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&&bj(r,l);break}case"remove":return r}return r.push(l),r},n)}function MB(e,t){return RB(e,t)}const sa=(e,t)=>({id:e,type:"select",selected:t});function si(e,t){return e.reduce((n,r)=>{const s=t.includes(r.id);return!r.selected&&s?(r.selected=!0,n.push(sa(r.id,!0))):r.selected&&!s&&(r.selected=!1,n.push(sa(r.id,!1))),n},[])}const Lp=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},$B=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),Q2=y.memo(({isSelecting:e,selectionMode:t=Jl.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=jt(),j=y.useRef(0),k=y.useRef(0),x=y.useRef(),{userSelectionActive:N,elementsSelectable:b,dragging:S}=Ue($B,Rt),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})},O=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:C,domNode:$}=v.getState();if(x.current=$==null?void 0:$.getBoundingClientRect(),!b||!e||F.button!==0||F.target!==g.current||!x.current)return;const{x:P,y:K}=ua(F,x.current);C(),v.setState({userSelectionRect:{width:0,height:0,startX:P,startY:K,x:P,y:K}}),r==null||r(F)},I=F=>{const{userSelectionRect:C,nodeInternals:$,edges:P,transform:K,onNodesChange:G,onEdgesChange:U,nodeOrigin:W,getNodes:D}=v.getState();if(!e||!x.current||!C)return;v.setState({userSelectionActive:!0,nodesSelectionActive:!1});const H=ua(F,x.current),J=C.startX??0,V=C.startY??0,Z={...C,x:H.x<J?H.x:J,y:H.y<V?H.y:V,width:Math.abs(H.x-J),height:Math.abs(H.y-V)},Y=D(),X=O2($,Z,K,t===Jl.Partial,!0,W),ee=L2(X,P).map(ue=>ue.id),ae=X.map(ue=>ue.id);if(j.current!==ae.length){j.current=ae.length;const ue=si(Y,ae);ue.length&&(G==null||G(ue))}if(k.current!==ee.length){k.current=ee.length;const ue=si(P,ee);ue.length&&(U==null||U(ue))}v.setState({userSelectionRect:Z})},B=F=>{if(F.button!==0)return;const{userSelectionRect:C}=v.getState();!N&&C&&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:zt(["react-flow__pane",{dragging:S,selection:e}]),onClick:M?void 0:Lp(R,g),onContextMenu:Lp(O,g),onWheel:Lp(A,g),onMouseEnter:M?void 0:d,onMouseDown:M?q:void 0,onMouseMove:M?I:h,onMouseUp:M?B:void 0,onMouseLeave:M?L:f,ref:g,style:a0},p,he.createElement(AB,null))});Q2.displayName="Pane";function e$(e,t){const n=e.parentNode||e.parentId;if(!n)return!1;const r=t.get(n);return r?r.selected?!0:e$(r,t):!1}function kj(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 IB(e,t,n,r){return Array.from(e.values()).filter(s=>(s.selected||s.id===r)&&(!s.parentNode||s.parentId||!e$(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 OB(e,t){return!t||t==="parent"?t:[t[0],[t[1][0]-(e.width||0),t[1][1]-(e.height||0)]]}function t$(e,t,n,r,s=[0,0],o){const l=OB(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}=Ya(p,s).positionAbsolute;c=p&&zn(g)&&zn(v)&&zn(p.width)&&zn(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",bs.error005()),c=l;else if(e.extent&&d&&e.extent!=="parent"){const p=n.get(d),{x:g,y:v}=Ya(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=Ya(p,s).positionAbsolute}const f=c&&c!=="parent"?Zb(t,c):t;return{position:{x:f.x-h.x,y:f.y-h.y},positionAbsolute:f}}function Pp({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 Nj=(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,...Xb(d)}})};function jl(e,t,n){return n===void 0?n:r=>{const s=t().nodeInternals.get(e);s&&n(r,{...s})}}function zx({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",bs.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 LB(){const e=jt();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 Dp(e){return(t,n,r)=>e==null?void 0:e(t,r)}function n$({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:s,isSelectable:o,selectNodesOnDrag:l}){const c=jt(),[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=LB();return y.useEffect(()=>{if(e!=null&&e.current){const E=Un(e.current),R=({x:q,y:I})=>{const{nodeInternals:B,onNodeDrag:L,onSelectionDrag:M,updateNodePositions:F,nodeExtent:C,snapGrid:$,snapToGrid:P,nodeOrigin:K,onError:G}=c.getState();p.current={x:q,y:I};let U=!1,W={x:0,y:0,x2:0,y2:0};if(f.current.length>1&&C){const H=rh(f.current,K);W=Zl(H)}if(f.current=f.current.map(H=>{const J={x:q-H.distance.x,y:I-H.distance.y};P&&(J.x=$[0]*Math.round(J.x/$[0]),J.y=$[1]*Math.round(J.y/$[1]));const V=[[C[0][0],C[0][1]],[C[1][0],C[1][1]]];f.current.length>1&&C&&!H.extent&&(V[0][0]=H.positionAbsolute.x-W.x+C[0][0],V[1][0]=H.positionAbsolute.x+(H.width??0)-W.x2+C[1][0],V[0][1]=H.positionAbsolute.y-W.y+C[0][1],V[1][1]=H.positionAbsolute.y+(H.height??0)-W.y2+C[1][1]);const Z=t$(H,J,B,V,K,G);return U=U||H.position.x!==Z.position.x||H.position.y!==Z.position.y,H.position=Z.position,H.positionAbsolute=Z.positionAbsolute,H}),!U)return;F(f.current,!0,!0),h(!0);const D=s?L:Dp(M);if(D&&k.current){const[H,J]=Pp({nodeId:s,dragItems:f.current,nodeInternals:B});D(k.current,H,J)}},O=()=>{if(!v.current)return;const[q,I]=S2(j.current,v.current);if(q!==0||I!==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)-I/B[2],L({x:q,y:I})&&R(p.current)}g.current=requestAnimationFrame(O)},A=q=>{var K;const{nodeInternals:I,multiSelectionActive:B,nodesDraggable:L,unselectNodesAndEdges:M,onNodeDragStart:F,onSelectionDragStart:C}=c.getState();N.current=!0;const $=s?F:Dp(C);(!l||!o)&&!B&&s&&((K=I.get(s))!=null&&K.selected||M()),s&&o&&l&&zx({id:s,store:c,nodeRef:e});const P=S(q);if(p.current=P,f.current=IB(I,L,P,s),$&&f.current){const[G,U]=Pp({nodeId:s,dragItems:f.current,nodeInternals:I});$(q.sourceEvent,G,U)}};if(t)E.on(".drag",null);else{const q=VF().on("start",I=>{const{domNode:B,nodeDragThreshold:L}=c.getState();L===0&&A(I),b.current=!1;const M=S(I);p.current=M,v.current=(B==null?void 0:B.getBoundingClientRect())||null,j.current=ua(I.sourceEvent,v.current)}).on("drag",I=>{var F,C;const B=S(I),{autoPanOnNodeDrag:L,nodeDragThreshold:M}=c.getState();if(I.sourceEvent.type==="touchmove"&&I.sourceEvent.touches.length>1&&(b.current=!0),!b.current){if(!x.current&&N.current&&L&&(x.current=!0,O()),!N.current){const $=B.xSnapped-(((F=p==null?void 0:p.current)==null?void 0:F.x)??0),P=B.ySnapped-(((C=p==null?void 0:p.current)==null?void 0:C.y)??0);Math.sqrt($*$+P*P)>M&&A(I)}(p.current.x!==B.xSnapped||p.current.y!==B.ySnapped)&&f.current&&N.current&&(k.current=I.sourceEvent,j.current=ua(I.sourceEvent,v.current),R(B))}}).on("end",I=>{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(),C=s?M:Dp(F);if(B(f.current,!1,!1),C){const[$,P]=Pp({nodeId:s,dragItems:f.current,nodeInternals:L});C(I.sourceEvent,$,P)}}}).filter(I=>{const B=I.target;return!I.button&&(!n||!kj(B,`.${n}`,e))&&(!r||kj(B,r,e))});return E.call(q),()=>{E.on(".drag",null)}}}},[e,t,n,r,o,c,s,l,S]),d}function r$(){const e=jt();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}=t$(b,S,r,s,void 0,h);b.position=R,b.positionAbsolute=E}return b});o(N,!0,!1)},[])}const ui={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var Sl=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:O,sourcePosition:A,targetPosition:q,hidden:I,resizeObserver:B,dragHandle:L,zIndex:M,isParent:F,noDragClassName:C,noPanClassName:$,initialized:P,disableKeyboardA11y:K,ariaLabel:G,rfId:U,hasHandleBounds:W})=>{const D=jt(),H=y.useRef(null),J=y.useRef(null),V=y.useRef(A),Z=y.useRef(q),Y=y.useRef(r),X=S||b||f||p||g||v,ee=r$(),ae=jl(n,D.getState,p),ue=jl(n,D.getState,g),ge=jl(n,D.getState,v),ye=jl(n,D.getState,j),se=jl(n,D.getState,k),me=fe=>{const{nodeDragThreshold:ne}=D.getState();if(S&&(!O||!b||ne>0)&&zx({id:n,store:D,nodeRef:H}),f){const oe=D.getState().nodeInternals.get(n);oe&&f(fe,{...oe})}},pe=fe=>{if(!Dx(fe)&&!K)if(C2.includes(fe.key)&&S){const ne=fe.key==="Escape";zx({id:n,store:D,unselect:ne,nodeRef:H})}else b&&h&&Object.prototype.hasOwnProperty.call(ui,fe.key)&&(D.setState({ariaLiveMessage:`Moved selected node ${fe.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~o}, y: ${~~l}`}),ee({x:ui[fe.key].x,y:ui[fe.key].y,isShiftPressed:fe.shiftKey}))};y.useEffect(()=>()=>{J.current&&(B==null||B.unobserve(J.current),J.current=null)},[]),y.useEffect(()=>{if(H.current&&!I){const fe=H.current;(!P||!W||J.current!==fe)&&(J.current&&(B==null||B.unobserve(J.current)),B==null||B.observe(fe),J.current=fe)}},[I,P,W]),y.useEffect(()=>{const fe=Y.current!==r,ne=V.current!==A,oe=Z.current!==q;H.current&&(fe||ne||oe)&&(fe&&(Y.current=r),ne&&(V.current=A),oe&&(Z.current=q),D.getState().updateNodeDimensions([{id:n,nodeElement:H.current,forceUpdate:!0}]))},[n,r,A,q]);const de=n$({nodeRef:H,disabled:I||!b,noDragClassName:C,handleSelector:L,nodeId:n,isSelectable:S,selectNodesOnDrag:O});return I?null:he.createElement("div",{className:zt(["react-flow__node",`react-flow__node-${r}`,{[$]:b},N,{selected:h,selectable:S,parent:F,dragging:de}]),ref:H,style:{zIndex:M,transform:`translate(${c}px,${d}px)`,pointerEvents:X?"all":"none",visibility:P?"visible":"hidden",...x},"data-id":n,"data-testid":`rf__node-${n}`,onMouseEnter:ae,onMouseMove:ue,onMouseLeave:ge,onContextMenu:ye,onClick:me,onDoubleClick:se,onKeyDown:R?pe:void 0,tabIndex:R?0:void 0,role:R?"button":void 0,"aria-describedby":K?void 0:`${K2}-${U}`,"aria-label":G},he.createElement(Y6,{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 PB=e=>{const t=e.getNodes().filter(n=>n.selected);return{...rh(t,e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive}};function DB({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=jt(),{width:s,height:o,x:l,y:c,transformString:d,userSelectionActive:h}=Ue(PB,Rt),f=r$(),p=y.useRef(null);if(y.useEffect(()=>{var j;n||(j=p.current)==null||j.focus({preventScroll:!0})},[n]),n$({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(ui,j.key)&&f({x:ui[j.key].x,y:ui[j.key].y,isShiftPressed:j.shiftKey})};return he.createElement("div",{className:zt(["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 FB=y.memo(DB);const BB=e=>e.nodesSelectionActive,s$=({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:O,panOnScrollSpeed:A,panOnScrollMode:q,zoomOnDoubleClick:I,panOnDrag:B,defaultViewport:L,translateExtent:M,minZoom:F,maxZoom:C,preventScrolling:$,onSelectionContextMenu:P,noWheelClassName:K,noPanClassName:G,disableKeyboardA11y:U})=>{const W=Ue(BB),D=Ql(p),H=Ql(N),J=H||B,V=H||O,Z=D||g&&J!==!0;return jB({deleteKeyCode:c,multiSelectionKeyCode:x}),he.createElement(TB,{onMove:d,onMoveStart:h,onMoveEnd:f,onPaneContextMenu:o,elementsSelectable:S,zoomOnScroll:E,zoomOnPinch:R,panOnScroll:V,panOnScrollSpeed:A,panOnScrollMode:q,zoomOnDoubleClick:I,panOnDrag:!D&&J,defaultViewport:L,translateExtent:M,minZoom:F,maxZoom:C,zoomActivationKeyCode:b,preventScrolling:$,noWheelClassName:K,noPanClassName:G},he.createElement(Q2,{onSelectionStart:j,onSelectionEnd:k,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:o,onPaneScroll:l,panOnDrag:J,isSelecting:!!Z,selectionMode:v},e,W&&he.createElement(FB,{onSelectionContextMenu:P,noPanClassName:G,disableKeyboardA11y:U})))};s$.displayName="FlowRenderer";var qB=y.memo(s$);function UB(e){return Ue(y.useCallback(n=>e?O2(n.nodeInternals,{x:0,y:0,width:n.width,height:n.height},n.transform,!0):n.getNodes(),[e]))}function zB(e){const t={input:Sl(e.input||W2),default:Sl(e.default||Ux),output:Sl(e.output||V2),group:Sl(e.group||s0)},n={},r=Object.keys(e).filter(s=>!["input","default","output","group"].includes(s)).reduce((s,o)=>(s[o]=Sl(e[o]||Ux),s),n);return{...t,...r}}const WB=({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]},HB=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),a$=e=>{const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:s,updateNodeDimensions:o,onError:l}=Ue(HB,Rt),c=UB(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:a0},c.map(f=>{var R,O,A;let p=f.type||"default";e.nodeTypes[p]||(l==null||l("003",bs.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?Zb(f.positionAbsolute,e.nodeExtent):f.positionAbsolute,b=(N==null?void 0:N.x)??0,S=(N==null?void 0:N.y)??0,E=WB({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[mt])==null?void 0:R.z)??0,isParent:!!((O=f[mt])!=null&&O.isParent),noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,initialized:!!f.width&&!!f.height,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,ariaLabel:f.ariaLabel,hasHandleBounds:!!((A=f[mt])!=null&&A.handleBounds)})}))};a$.displayName="NodeRenderer";var VB=y.memo(a$);const GB=(e,t,n)=>n===Ae.Left?e-t:n===Ae.Right?e+t:e,KB=(e,t,n)=>n===Ae.Top?e-t:n===Ae.Bottom?e+t:e,jj="react-flow__edgeupdater",Sj=({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:zt([jj,`${jj}-${c}`]),cx:GB(t,r,e),cy:KB(n,r,e),r,stroke:"transparent",fill:"transparent"}),YB=()=>!0;var Ho=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:O,sourcePosition:A,targetPosition:q,elementsSelectable:I,hidden:B,sourceHandleId:L,targetHandleId:M,onContextMenu:F,onMouseEnter:C,onMouseMove:$,onMouseLeave:P,reconnectRadius:K,onReconnect:G,onReconnectStart:U,onReconnectEnd:W,markerEnd:D,markerStart:H,rfId:J,ariaLabel:V,isFocusable:Z,isReconnectable:Y,pathOptions:X,interactionWidth:ee,disableKeyboardA11y:ae})=>{const ue=y.useRef(null),[ge,ye]=y.useState(!1),[se,me]=y.useState(!1),pe=jt(),de=y.useMemo(()=>`url('#${Bx(H,J)}')`,[H,J]),fe=y.useMemo(()=>`url('#${Bx(D,J)}')`,[D,J]);if(B)return null;const ne=Ze=>{var lt;const{edges:yt,addSelectedEdges:ze,unselectNodesAndEdges:ht,multiSelectionActive:mn}=pe.getState(),Mt=yt.find(wt=>wt.id===n);Mt&&(I&&(pe.setState({nodesSelectionActive:!1}),Mt.selected&&mn?(ht({nodes:[],edges:[Mt]}),(lt=ue.current)==null||lt.blur()):ze([n])),l&&l(Ze,Mt))},oe=Nl(n,pe.getState,c),Ne=Nl(n,pe.getState,F),we=Nl(n,pe.getState,C),Ie=Nl(n,pe.getState,$),Pe=Nl(n,pe.getState,P),Be=(Ze,yt)=>{if(Ze.button!==0)return;const{edges:ze,isValidConnection:ht}=pe.getState(),mn=yt?b:N,Mt=(yt?M:L)||null,lt=yt?"target":"source",wt=ht||YB,tn=yt,Ft=ze.find(Wt=>Wt.id===n);me(!0),U==null||U(Ze,Ft,lt);const ft=Wt=>{me(!1),W==null||W(Wt,Ft,lt)};B2({event:Ze,handleId:Mt,nodeId:mn,onConnect:Wt=>G==null?void 0:G(Ft,Wt),isTarget:tn,getState:pe.getState,setState:pe.setState,isValidConnection:wt,edgeUpdaterType:lt,onReconnectEnd:ft})},Oe=Ze=>Be(Ze,!0),Qe=Ze=>Be(Ze,!1),Ye=()=>ye(!0),Xe=()=>ye(!1),ot=!I&&!l,it=Ze=>{var yt;if(!ae&&C2.includes(Ze.key)&&I){const{unselectNodesAndEdges:ze,addSelectedEdges:ht,edges:mn}=pe.getState();Ze.key==="Escape"?((yt=ue.current)==null||yt.blur(),ze({edges:[mn.find(lt=>lt.id===n)]})):ht([n])}};return he.createElement("g",{className:zt(["react-flow__edge",`react-flow__edge-${s}`,r,{selected:d,animated:h,inactive:ot,updating:ge}]),onClick:ne,onDoubleClick:oe,onContextMenu:Ne,onMouseEnter:we,onMouseMove:Ie,onMouseLeave:Pe,onKeyDown:Z?it:void 0,tabIndex:Z?0:void 0,role:Z?"button":"img","data-testid":`rf__edge-${n}`,"aria-label":V===null?void 0:V||`Edge from ${N} to ${b}`,"aria-describedby":Z?`${Y2}-${J}`:void 0,ref:ue},!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:O,sourcePosition:A,targetPosition:q,sourceHandleId:L,targetHandleId:M,markerStart:de,markerEnd:fe,pathOptions:X,interactionWidth:ee}),Y&&he.createElement(he.Fragment,null,(Y==="source"||Y===!0)&&he.createElement(Sj,{position:A,centerX:S,centerY:E,radius:K,onMouseDown:Oe,onMouseEnter:Ye,onMouseOut:Xe,type:"source"}),(Y==="target"||Y===!0)&&he.createElement(Sj,{position:q,centerX:R,centerY:O,radius:K,onMouseDown:Qe,onMouseEnter:Ye,onMouseOut:Xe,type:"target"})))};return t.displayName="EdgeWrapper",y.memo(t)};function XB(e){const t={default:Ho(e.default||Nd),straight:Ho(e.bezier||e0),step:Ho(e.step||Qb),smoothstep:Ho(e.step||nh),simplebezier:Ho(e.simplebezier||Jb)},n={},r=Object.keys(e).filter(s=>!["default","bezier"].includes(s)).reduce((s,o)=>(s[o]=Ho(e[o]||Nd),s),n);return{...t,...r}}function _j(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 Ej(e,t){return e?e.length===1||!t?e[0]:t&&e.find(n=>n.id===t)||null:null}const ZB=(e,t,n,r,s,o)=>{const l=_j(n,e,t),c=_j(o,r,s);return{sourceX:l.x,sourceY:l.y,targetX:c.x,targetY:c.y}};function JB({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=Zl({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 Tj(e){var r,s,o,l,c;const t=((r=e==null?void 0:e[mt])==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 QB=[{level:0,isMaxLevel:!0,edges:[]}];function e8(e,t,n=!1){let r=-1;const s=e.reduce((l,c)=>{var f,p;const d=zn(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[mt])==null?void 0:f.z)||0,((p=g==null?void 0:g[mt])==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?QB:o}function t8(e,t,n){const r=Ue(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)&&JB({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 e8(r,t,n)}const n8=({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"}),r8=({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"}),Cj={[kd.Arrow]:n8,[kd.ArrowClosed]:r8};function s8(e){const t=jt();return y.useMemo(()=>{var s,o;return Object.prototype.hasOwnProperty.call(Cj,e)?Cj[e]:((o=(s=t.getState()).onError)==null||o.call(s,"009",bs.error009(e)),null)},[e])}const a8=({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=s8(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},o8=({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=Bx(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))},o$=({defaultColor:e,rfId:t})=>{const n=Ue(y.useCallback(o8({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(a8,{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})))};o$.displayName="MarkerDefinitions";var i8=y.memo(o$);const l8=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}),i$=({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:O,connectionMode:A,nodeInternals:q,onError:I}=Ue(l8,Rt),B=t8(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:O,className:"react-flow__edges react-flow__container"},F&&he.createElement(i8,{defaultColor:e,rfId:r}),he.createElement("g",null,M.map(C=>{const[$,P,K]=Tj(q.get(C.source)),[G,U,W]=Tj(q.get(C.target));if(!K||!W)return null;let D=C.type||"default";s[D]||(I==null||I("011",bs.error011(D)),D="default");const H=s[D]||s.default,J=A===eo.Strict?U.target:(U.target??[]).concat(U.source??[]),V=Ej(P.source,C.sourceHandle),Z=Ej(J,C.targetHandle),Y=(V==null?void 0:V.position)||Ae.Bottom,X=(Z==null?void 0:Z.position)||Ae.Top,ee=!!(C.focusable||b&&typeof C.focusable>"u"),ae=C.reconnectable||C.updatable,ue=typeof g<"u"&&(ae||S&&typeof ae>"u");if(!V||!Z)return I==null||I("008",bs.error008(V,C)),null;const{sourceX:ge,sourceY:ye,targetX:se,targetY:me}=ZB($,V,Y,G,Z,X);return he.createElement(H,{key:C.id,id:C.id,className:zt([C.className,o]),type:D,data:C.data,selected:!!C.selected,animated:!!C.animated,hidden:!!C.hidden,label:C.label,labelStyle:C.labelStyle,labelShowBg:C.labelShowBg,labelBgStyle:C.labelBgStyle,labelBgPadding:C.labelBgPadding,labelBgBorderRadius:C.labelBgBorderRadius,style:C.style,source:C.source,target:C.target,sourceHandleId:C.sourceHandle,targetHandleId:C.targetHandle,markerEnd:C.markerEnd,markerStart:C.markerStart,sourceX:ge,sourceY:ye,targetX:se,targetY:me,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:C.ariaLabel,isFocusable:ee,isReconnectable:ue,pathOptions:"pathOptions"in C?C.pathOptions:void 0,interactionWidth:C.interactionWidth,disableKeyboardA11y:N})})))),x):null};i$.displayName="EdgeRenderer";var c8=y.memo(i$);const u8=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function d8({children:e}){const t=Ue(u8);return he.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:t}},e)}function h8(e){const t=Ti(),n=y.useRef(!1);y.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const f8={[Ae.Left]:Ae.Right,[Ae.Right]:Ae.Left,[Ae.Top]:Ae.Bottom,[Ae.Bottom]:Ae.Top},l$=({nodeId:e,handleType:t,style:n,type:r=aa.Bezier,CustomComponent:s,connectionStatus:o})=>{var O,A,q;const{fromNode:l,handleId:c,toX:d,toY:h,connectionMode:f}=Ue(y.useCallback(I=>({fromNode:I.nodeInternals.get(e),handleId:I.connectionHandleId,toX:(I.connectionPosition.x-I.transform[0])/I.transform[2],toY:(I.connectionPosition.y-I.transform[1])/I.transform[2],connectionMode:I.connectionMode}),[e]),Rt),p=(O=l==null?void 0:l[mt])==null?void 0:O.handleBounds;let g=p==null?void 0:p[t];if(f===eo.Loose&&(g=g||(p==null?void 0:p[t==="source"?"target":"source"])),!l||!g)return null;const v=c?g.find(I=>I.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?f8[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===aa.Bezier?[E]=t0(R):r===aa.Step?[E]=Fx({...R,borderRadius:0}):r===aa.SmoothStep?[E]=Fx(R):r===aa.SimpleBezier?[E]=$2(R):E=`M${x},${N} ${d},${h}`,he.createElement("path",{d:E,fill:"none",className:"react-flow__connection-path",style:n})};l$.displayName="ConnectionLine";const p8=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function m8({containerStyle:e,style:t,type:n,component:r}){const{nodeId:s,handleType:o,nodesConnectable:l,width:c,height:d,connectionStatus:h}=Ue(p8,Rt);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:zt(["react-flow__connection",h])},he.createElement(l$,{nodeId:s,handleType:o,style:t,type:n,CustomComponent:r,connectionStatus:h})))}function Aj(e,t){return y.useRef(null),jt(),y.useMemo(()=>t(e),[e])}const c$=({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:O,selectionMode:A,multiSelectionKeyCode:q,panActivationKeyCode:I,zoomActivationKeyCode:B,deleteKeyCode:L,onlyRenderVisibleElements:M,elementsSelectable:F,selectNodesOnDrag:C,defaultViewport:$,translateExtent:P,minZoom:K,maxZoom:G,preventScrolling:U,defaultMarkerColor:W,zoomOnScroll:D,zoomOnPinch:H,panOnScroll:J,panOnScrollSpeed:V,panOnScrollMode:Z,zoomOnDoubleClick:Y,panOnDrag:X,onPaneClick:ee,onPaneMouseEnter:ae,onPaneMouseMove:ue,onPaneMouseLeave:ge,onPaneScroll:ye,onPaneContextMenu:se,onEdgeContextMenu:me,onEdgeMouseEnter:pe,onEdgeMouseMove:de,onEdgeMouseLeave:fe,onReconnect:ne,onReconnectStart:oe,onReconnectEnd:Ne,reconnectRadius:we,noDragClassName:Ie,noWheelClassName:Pe,noPanClassName:Be,elevateEdgesOnSelect:Oe,disableKeyboardA11y:Qe,nodeOrigin:Ye,nodeExtent:Xe,rfId:ot})=>{const it=Aj(e,zB),Ze=Aj(t,XB);return h8(o),he.createElement(qB,{onPaneClick:ee,onPaneMouseEnter:ae,onPaneMouseMove:ue,onPaneMouseLeave:ge,onPaneContextMenu:se,onPaneScroll:ye,deleteKeyCode:L,selectionKeyCode:R,selectionOnDrag:O,selectionMode:A,onSelectionStart:k,onSelectionEnd:x,multiSelectionKeyCode:q,panActivationKeyCode:I,zoomActivationKeyCode:B,elementsSelectable:F,onMove:n,onMoveStart:r,onMoveEnd:s,zoomOnScroll:D,zoomOnPinch:H,zoomOnDoubleClick:Y,panOnScroll:J,panOnScrollSpeed:V,panOnScrollMode:Z,panOnDrag:X,defaultViewport:$,translateExtent:P,minZoom:K,maxZoom:G,onSelectionContextMenu:j,preventScrolling:U,noDragClassName:Ie,noWheelClassName:Pe,noPanClassName:Be,disableKeyboardA11y:Qe},he.createElement(d8,null,he.createElement(c8,{edgeTypes:Ze,onEdgeClick:c,onEdgeDoubleClick:h,onlyRenderVisibleElements:M,onEdgeContextMenu:me,onEdgeMouseEnter:pe,onEdgeMouseMove:de,onEdgeMouseLeave:fe,onReconnect:ne,onReconnectStart:oe,onReconnectEnd:Ne,reconnectRadius:we,defaultMarkerColor:W,noPanClassName:Be,elevateEdgesOnSelect:!!Oe,disableKeyboardA11y:Qe,rfId:ot},he.createElement(m8,{style:b,type:N,component:S,containerStyle:E})),he.createElement("div",{className:"react-flow__edgelabel-renderer"}),he.createElement(VB,{nodeTypes:it,onNodeClick:l,onNodeDoubleClick:d,onNodeMouseEnter:f,onNodeMouseMove:p,onNodeMouseLeave:g,onNodeContextMenu:v,selectNodesOnDrag:C,onlyRenderVisibleElements:M,noPanClassName:Be,noDragClassName:Ie,disableKeyboardA11y:Qe,nodeOrigin:Ye,nodeExtent:Xe,rfId:ot})))};c$.displayName="GraphView";var g8=y.memo(c$);const Wx=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],ta={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:Wx,nodeExtent:Wx,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:eo.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:z6,isValidConnection:void 0},y8=()=>sD((e,t)=>({...ta,setNodes:n=>{const{nodeInternals:r,nodeOrigin:s,elevateNodesOnSelect:o}=t();e({nodeInternals:Op(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?Op(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,[mt]:{...N[mt],handleBounds:void 0}});else if(N){const b=Xb(x.nodeElement);!!(b.width&&b.height&&(N.width!==b.width||N.height!==b.height||x.forceUpdate))&&(s.set(N.id,{...N,[mt]:{...N[mt],handleBounds:{source:Nj(".source",x.nodeElement,g,h),target:Nj(".target",x.nodeElement,g,h)}},...b}),k.push({id:N.id,type:"dimensions",dimensions:b}))}return k},[]);Z2(s,h);const j=l||o&&!l&&J2(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=MB(n,c()),f=Op(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=>sa(d,!0)):(l=si(o(),n),c=si(s,[])),Lu({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=>sa(d,!0)):(l=si(s,n),c=si(o(),[])),Lu({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,sa(f.id,!1))),h=c.map(f=>sa(f.id,!1));Lu({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=>sa(c.id,!1)),l=n.filter(c=>c.selected).map(c=>sa(c.id,!1));Lu({changedNodes:o,changedEdges:l,get:t,set:e})},setNodeExtent:n=>{const{nodeInternals:r}=t();r.forEach(s=>{s.positionAbsolute=Zb(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:ta.connectionNodeId,connectionHandleId:ta.connectionHandleId,connectionHandleType:ta.connectionHandleType,connectionStatus:ta.connectionStatus,connectionStartHandle:ta.connectionStartHandle,connectionEndHandle:ta.connectionEndHandle}),reset:()=>e({...ta})}),Object.is),o0=({children:e})=>{const t=y.useRef(null);return t.current||(t.current=y8()),he.createElement(L6,{value:t.current},e)};o0.displayName="ReactFlowProvider";const u$=({children:e})=>y.useContext(th)?he.createElement(he.Fragment,null,e):he.createElement(o0,null,e);u$.displayName="ReactFlowWrapper";const w8={input:W2,default:Ux,output:V2,group:s0},v8={default:Nd,straight:e0,step:Qb,smoothstep:nh,simplebezier:Jb},x8=[0,0],b8=[15,15],k8={x:0,y:0,zoom:1},N8={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},d$=y.forwardRef(({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:s,nodeTypes:o=w8,edgeTypes:l=v8,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:O,onNodeDragStart:A,onNodeDrag:q,onNodeDragStop:I,onNodesDelete:B,onEdgesDelete:L,onSelectionChange:M,onSelectionDragStart:F,onSelectionDrag:C,onSelectionDragStop:$,onSelectionContextMenu:P,onSelectionStart:K,onSelectionEnd:G,connectionMode:U=eo.Strict,connectionLineType:W=aa.Bezier,connectionLineStyle:D,connectionLineComponent:H,connectionLineContainerStyle:J,deleteKeyCode:V="Backspace",selectionKeyCode:Z="Shift",selectionOnDrag:Y=!1,selectionMode:X=Jl.Full,panActivationKeyCode:ee="Space",multiSelectionKeyCode:ae=bd()?"Meta":"Control",zoomActivationKeyCode:ue=bd()?"Meta":"Control",snapToGrid:ge=!1,snapGrid:ye=b8,onlyRenderVisibleElements:se=!1,selectNodesOnDrag:me=!0,nodesDraggable:pe,nodesConnectable:de,nodesFocusable:fe,nodeOrigin:ne=x8,edgesFocusable:oe,edgesUpdatable:Ne,elementsSelectable:we,defaultViewport:Ie=k8,minZoom:Pe=.5,maxZoom:Be=2,translateExtent:Oe=Wx,preventScrolling:Qe=!0,nodeExtent:Ye,defaultMarkerColor:Xe="#b1b1b7",zoomOnScroll:ot=!0,zoomOnPinch:it=!0,panOnScroll:Ze=!1,panOnScrollSpeed:yt=.5,panOnScrollMode:ze=Ha.Free,zoomOnDoubleClick:ht=!0,panOnDrag:mn=!0,onPaneClick:Mt,onPaneMouseEnter:lt,onPaneMouseMove:wt,onPaneMouseLeave:tn,onPaneScroll:Ft,onPaneContextMenu:ft,children:nn,onEdgeContextMenu:Wt,onEdgeDoubleClick:xt,onEdgeMouseEnter:Tn,onEdgeMouseMove:Yn,onEdgeMouseLeave:br,onEdgeUpdate:gn,onEdgeUpdateStart:Xn,onEdgeUpdateEnd:Zn,onReconnect:Jn,onReconnectStart:Cn,onReconnectEnd:Vr,reconnectRadius:An=10,edgeUpdaterRadius:kr=10,onNodesChange:bt,onEdgesChange:Gr,noDragClassName:Nr="nodrag",noWheelClassName:Es="nowheel",noPanClassName:Qn="nopan",fitView:Rn=!1,fitViewOptions:Ts,connectOnClick:er=!0,attributionPosition:Cs,proOptions:As,defaultEdgeOptions:jr,elevateNodesOnSelect:Sr=!0,elevateEdgesOnSelect:Kr=!1,disableKeyboardA11y:Yr=!1,autoPanOnConnect:ve=!0,autoPanOnNodeDrag:Re=!0,connectionRadius:He=20,isValidConnection:$t,onError:tr,style:Yt,id:Rs,nodeDragThreshold:Ms,...yn},Xt)=>{const ya=Rs||"1";return he.createElement("div",{...yn,style:{...Yt,...N8},ref:Xt,className:zt(["react-flow",s]),"data-testid":"rf__wrapper",id:Rs},he.createElement(u$,null,he.createElement(g8,{onInit:h,onMove:f,onMoveStart:p,onMoveEnd:g,onNodeClick:c,onEdgeClick:d,onNodeMouseEnter:b,onNodeMouseMove:S,onNodeMouseLeave:E,onNodeContextMenu:R,onNodeDoubleClick:O,nodeTypes:o,edgeTypes:l,connectionLineType:W,connectionLineStyle:D,connectionLineComponent:H,connectionLineContainerStyle:J,selectionKeyCode:Z,selectionOnDrag:Y,selectionMode:X,deleteKeyCode:V,multiSelectionKeyCode:ae,panActivationKeyCode:ee,zoomActivationKeyCode:ue,onlyRenderVisibleElements:se,selectNodesOnDrag:me,defaultViewport:Ie,translateExtent:Oe,minZoom:Pe,maxZoom:Be,preventScrolling:Qe,zoomOnScroll:ot,zoomOnPinch:it,zoomOnDoubleClick:ht,panOnScroll:Ze,panOnScrollSpeed:yt,panOnScrollMode:ze,panOnDrag:mn,onPaneClick:Mt,onPaneMouseEnter:lt,onPaneMouseMove:wt,onPaneMouseLeave:tn,onPaneScroll:Ft,onPaneContextMenu:ft,onSelectionContextMenu:P,onSelectionStart:K,onSelectionEnd:G,onEdgeContextMenu:Wt,onEdgeDoubleClick:xt,onEdgeMouseEnter:Tn,onEdgeMouseMove:Yn,onEdgeMouseLeave:br,onReconnect:Jn??gn,onReconnectStart:Cn??Xn,onReconnectEnd:Vr??Zn,reconnectRadius:An??kr,defaultMarkerColor:Xe,noDragClassName:Nr,noWheelClassName:Es,noPanClassName:Qn,elevateEdgesOnSelect:Kr,rfId:ya,disableKeyboardA11y:Yr,nodeOrigin:ne,nodeExtent:Ye}),he.createElement(hB,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:v,onConnectStart:j,onConnectEnd:k,onClickConnectStart:x,onClickConnectEnd:N,nodesDraggable:pe,nodesConnectable:de,nodesFocusable:fe,edgesFocusable:oe,edgesUpdatable:Ne,elementsSelectable:we,elevateNodesOnSelect:Sr,minZoom:Pe,maxZoom:Be,nodeExtent:Ye,onNodesChange:bt,onEdgesChange:Gr,snapToGrid:ge,snapGrid:ye,connectionMode:U,translateExtent:Oe,connectOnClick:er,defaultEdgeOptions:jr,fitView:Rn,fitViewOptions:Ts,onNodesDelete:B,onEdgesDelete:L,onNodeDragStart:A,onNodeDrag:q,onNodeDragStop:I,onSelectionDrag:C,onSelectionDragStart:F,onSelectionDragStop:$,noPanClassName:Qn,nodeOrigin:ne,rfId:ya,autoPanOnConnect:ve,autoPanOnNodeDrag:Re,onError:tr,connectionRadius:He,isValidConnection:$t,nodeDragThreshold:Ms}),he.createElement(uB,{onSelectionChange:M}),nn,he.createElement(D6,{proOptions:As,position:Cs}),he.createElement(yB,{rfId:ya,disableKeyboardA11y:Yr})))});d$.displayName="ReactFlow";const j8=e=>({x:e.transform[0],y:e.transform[1],zoom:e.transform[2]});function h$(){return Ue(j8,Rt)}const f$=({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:zt(["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})};f$.displayName="MiniMapNode";var S8=y.memo(f$);const _8=e=>e.nodeOrigin,E8=e=>e.getNodes().filter(t=>!t.hidden&&t.width&&t.height),Fp=e=>e instanceof Function?e:()=>e;function T8({nodeStrokeColor:e="transparent",nodeColor:t="#e2e2e2",nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:s=2,nodeComponent:o=S8,onClick:l}){const c=Ue(E8,Rt),d=Ue(_8),h=Fp(t),f=Fp(e),p=Fp(n),g=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return he.createElement(he.Fragment,null,c.map(v=>{const{x:j,y:k}=Ya(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 C8=y.memo(T8);const A8=200,R8=150,M8=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?q6(rh(t,e.nodeOrigin),n):n,rfId:e.rfId}},$8="react-flow__minimap-desc";function p$({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=jt(),R=y.useRef(null),{boundingRect:O,viewBB:A,rfId:q}=Ue(M8,Rt),I=(e==null?void 0:e.width)??A8,B=(e==null?void 0:e.height)??R8,L=O.width/I,M=O.height/B,F=Math.max(L,M),C=F*I,$=F*B,P=S*F,K=O.x-(C-O.width)/2-P,G=O.y-($-O.height)/2-P,U=C+P*2,W=$+P*2,D=`${$8}-${q}`,H=y.useRef(0);H.current=F,y.useEffect(()=>{if(R.current){const Z=Un(R.current),Y=ae=>{const{transform:ue,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,me=ue[2]*Math.pow(2,se);ye.scaleTo(ge,me)},X=ae=>{const{transform:ue,d3Selection:ge,d3Zoom:ye,translateExtent:se,width:me,height:pe}=E.getState();if(ae.sourceEvent.type!=="mousemove"||!ge||!ye)return;const de=H.current*Math.max(1,ue[2])*(N?-1:1),fe={x:ue[0]-ae.sourceEvent.movementX*de,y:ue[1]-ae.sourceEvent.movementY*de},ne=[[0,0],[me,pe]],oe=ys.translate(fe.x,fe.y).scale(ue[2]),Ne=ye.constrain()(oe,ne,se);ye.transform(ge,Ne)},ee=N2().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=dr(Z);g(Z,{x:Y[0],y:Y[1]})}:void 0,V=v?(Z,Y)=>{const X=E.getState().nodeInternals.get(Y);v(Z,X)}:void 0;return he.createElement(Yb,{position:p,style:e,className:zt(["react-flow__minimap",t]),"data-testid":"rf__minimap"},he.createElement("svg",{width:I,height:B,viewBox:`${K} ${G} ${U} ${W}`,role:"img","aria-labelledby":D,ref:R,onClick:J},x&&he.createElement("title",{id:D},x),he.createElement(C8,{onClick:V,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:o,nodeClassName:s,nodeStrokeWidth:l,nodeComponent:c}),he.createElement("path",{className:"react-flow__minimap-mask",d:`M${K-P},${G-P}h${U+P*2}v${W+P*2}h${-U-P*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"})))}p$.displayName="MiniMap";var I8=y.memo(p$);function O8(){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 L8(){return he.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},he.createElement("path",{d:"M0 0h32v4.2H0z"}))}function P8(){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 D8(){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 F8(){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 Bn=({children:e,className:t,...n})=>he.createElement("button",{type:"button",className:zt(["react-flow__controls-button",t]),...n},e);Bn.displayName="ControlButton";const B8=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),m$=({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=jt(),[v,j]=y.useState(!1),{isInteractive:k,minZoomReached:x,maxZoomReached:N}=Ue(B8,Rt),{zoomIn:b,zoomOut:S,fitView:E}=Ti();if(y.useEffect(()=>{j(!0)},[]),!v)return null;const R=()=>{b(),o==null||o()},O=()=>{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(Yb,{className:zt(["react-flow__controls",h]),position:p,style:e,"data-testid":"rf__controls"},t&&he.createElement(he.Fragment,null,he.createElement(Bn,{onClick:R,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:N},he.createElement(O8,null)),he.createElement(Bn,{onClick:O,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:x},he.createElement(L8,null))),n&&he.createElement(Bn,{className:"react-flow__controls-fitview",onClick:A,title:"fit view","aria-label":"fit view"},he.createElement(P8,null)),r&&he.createElement(Bn,{className:"react-flow__controls-interactive",onClick:q,title:"toggle interactivity","aria-label":"toggle interactivity"},k?he.createElement(F8,null):he.createElement(D8,null)),f)};m$.displayName="Controls";var q8=y.memo(m$),mr;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(mr||(mr={}));function U8({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 z8({color:e,radius:t}){return he.createElement("circle",{cx:t,cy:t,r:t,fill:e})}const W8={[mr.Dots]:"#91919a",[mr.Lines]:"#eee",[mr.Cross]:"#e2e2e2"},H8={[mr.Dots]:1,[mr.Lines]:1,[mr.Cross]:6},V8=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function g$({id:e,variant:t=mr.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}=Ue(V8,Rt),g=l||W8[t],v=r||H8[t],j=t===mr.Dots,k=t===mr.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:zt(["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(z8,{color:g,radius:b/o}):he.createElement(U8,{dimensions:S,color:g,lineWidth:s})),he.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${p+e})`}))}g$.displayName="Background";var G8=y.memo(g$);function K8(e,t){return e?t==="gone"?"entering":t==="leaving"?"here":t:t==="gone"?"gone":"leaving"}function Ba(e){return e!=="gone"}function od(e,t){const[n,r]=y.useState(()=>e?"here":"gone"),s=y.useRef(null);return y.useEffect(()=>{r(o=>K8(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 Rj="agent-dag.fm-custom-stations",Mj="agent-dag.fm-muted",Hx="custom:",Y8=/^UC[A-Za-z0-9_-]{22}$/,X8=/^[A-Za-z0-9_-]{11}$/,i0=/^[A-Za-z0-9_-]{1,80}$/,Z8=/\.(mp3|aac|ogg)$/i,J8=/\.m3u8$/i,y$=2048,ec=80;function no(e){return`${Hx}${e}`}function yi(e){if(!e.startsWith(Hx))return null;const t=e.slice(Hx.length);return i0.test(t)?t:null}function $j(e){return yi(e)??e}function Q8(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 l0(e){var l,c;const t=e.trim();if(t.length>y$)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&&Y8.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(X8.test(f))return{kind:"youtube-video",url:r,video:f}}return null}return J8.test(n.pathname)?{kind:"direct-audio",url:r,format:"hls"}:Z8.test(n.pathname)?{kind:"direct-audio",url:r,format:"audio"}:null}function eq(e){return e==="1"}function tq(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=l0(c);!i0.test(o)||n.has(o)||!l||l.length>ec||!d||(n.add(o),r.push({id:o,name:l,url:d.url}))}return r}function nq(e,t,n){const r=yi(e??"");return r&&t.some(s=>s.id===r)?no(r):n(e)}function rq(e,t){return e===no(t)?"claude-fm":e}function sq(){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 aq(e,t,n=sq()){const r=e.trim(),s=l0(t);return!r||r.length>ec||!i0.test(n)||!s?null:{id:n,name:r,url:s.url}}const w$=.2,v$=1.6;function oq(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<w$||s>v$?null:{x:n,y:r,zoom:s}}function Vx({durationMs:e,documentHidden:t,reducedMotion:n=c0()}){return t||n?!1:Number.isFinite(e)&&e>0}function c0(){return typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches}const iq=["us-gov","global","apac","us","eu","jp","au"],lq=new RegExp(`^(?:(?:${iq.join("|")})\\.)?anthropic\\.`,"i");function gs(e){return e.replace(lq,"")}const cq=/^(?:claude[-_]|gpt[-_]|o\d|codex[-_])/i,uq=new Set(["tool_input","tool_response"]);function x$(e,t=0){if(!e||typeof e!="object"||t>6)return null;const n=e;if(typeof n.model=="string"&&cq.test(gs(n.model)))return n.model;for(const[r,s]of Object.entries(n)){if(uq.has(r))continue;const o=x$(s,t+1);if(o)return o}return null}function u0(){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 js(e,t){return`${e}::${t}`}function Ci(e,t){return`${e}\0${t}`}const dq=/[0-9a-f]{16,}/i,hq=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function b$(e){return dq.test(e)||hq.test(e)}function fq(e){if(!e)return;const t=e.replace(/\\/g,"/").split("/").filter(Boolean);for(let n=t.length-1;n>=0;n--)if(!b$(t[n]))return t[n];return t[t.length-1]}function k$(){return{inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0}}function N$(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 d0(e){const t=N$(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 pq(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]=d0(s);const o=mq(s.speeds);o&&(t[n].bySpeed=o)}return Object.keys(t).length?t:void 0}function mq(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,d0(r)]);return t.length?Object.fromEntries(t):void 0}function j$(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$(n)};for(const r of Object.values(n)){const s=j$(r,t+1);if(s)return s}return null}function h0(e){return fq(e)}function f0(e){const t=e.agent_type??e.subagent_type;return t&&!b$(t)?t:"subagent"}function Ai(e){return e.agent_id?e.agent_id:e.parent_tool_use_id?e.parent_tool_use_id:null}function tc(e,t){!e.cwd&&t.cwd&&(e.cwd=t.cwd,e.cwdBasename=h0(t.cwd))}function S$(e,t){e.label==="session"&&t.cwd&&(e.label=h0(t.cwd)??"session")}function _$(e,t){const n=f0(t);n&&(e.label==="subagent"||!e.label)&&(e.label=n)}function Ri(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:k$()},e.agents.set(s,o),o)}function E$(e,t,n,r){const s=js(t,n),o=e.agents.get(s);return o?(tc(o,r),_$(o,r),o):null}function gq(e,t,n){var h;const r=t.session_id??"unknown",s=Ai(t);if(s){const f=E$(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(js(r,c));if(f)return tc(f,t),f}const d=Ri(e,r,n,t.hook_event_name!=="SessionStart");return tc(d,t),S$(d,t),d}function yq(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 wq(e,t,n,r,s){const o=js(t,n),l=Ri(e,t,s,!0);let c=e.agents.get(o);if(c)return tc(c,r),_$(c,r),c;c={id:o,sessionId:t,label:f0(r),kind:"subagent",parentId:l.id,state:"active",startedAt:s,tools:[],prompts:[],cwd:r.cwd,cwdBasename:h0(r.cwd),toolCount:0,childCount:0,usage:k$()},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 vq(e,t,n){const r=e.activeSubagentStack.get(t)??[];r.includes(n)||(r.push(n),e.activeSubagentStack.set(t,r))}function T$(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 C$(){return{msgsUser:0,msgsAssistant:0,toolUses:0,toolResults:0,systemReminders:0,currentContextTokens:0,memoryFiles:[]}}function A$(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??C$(),currentContextTokens:t.context_tokens})}}const xq=6e4,Ij=64;function R$(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=js(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 M$(e,t,n){const r=t.context??null;if(r){const s=e.agents.get(n);if(s){const o=s.context??C$(),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 $$(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 bq(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 I$(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 kq=new Set(["working","blocked","done","failed","stopped"]);function O$(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"||!kq.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 Nq(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<xq);c.push(o),l.outputs=c.length>Ij?c.slice(-Ij):c}e.revision+=1}}function L$(e,t,n){const r=t.usage??null;if(r){const s=e.agents.get(n);s&&(Object.assign(s.usage,d0(r)),s.usageByModel=pq(t.usageByModel))}}const jq=256,id={ModelObserved:R$,UsageObserved:L$,ContextObserved:M$,SessionNamed:$$,ActivityObserved:I$,JobObserved:O$},fs=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Du=e=>typeof e=="string"&&e.trim()!=="",Sq=[["model_context_window",e=>typeof e=="number"&&e>0],["approval_policy",e=>typeof e=="string"&&e!==""],["context_tokens",e=>typeof e=="number"&&e>=0]],_q=new Set(["working","blocked","done","failed","stopped"]),Oj=e=>fs(e)&&typeof e.text=="string"&&e.text.trim()!==""&&Number.isFinite(e.at);function Eq(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 Sq)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=Du(t.sessionName)?t.sessionName:e.sessionName??null;let o=Du(t.sessionTitle)?t.sessionTitle:e.sessionTitle??null;Du(s)&&Du(o)&&o.trim().toLowerCase()===s.trim().toLowerCase()&&(o=null),n.sessionName=s,n.sessionTitle=o;break}case"ActivityObserved":(!Oj(t.activity)||Oj(e.activity)&&t.activity.at<e.activity.at)&&r("activity");break;case"JobObserved":t.job===null||fs(t.job)&&_q.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 Tq(e,t,n,r){if(!(t in id)||e.agents.has(r))return!1;const s=e.parkedEnrichment.get(r)??new Map,o=Eq(s.get(t),n);for(s.delete(t),s.set(t,o),e.parkedEnrichment.delete(r),e.parkedEnrichment.set(r,s);e.parkedEnrichment.size>jq;){const l=e.parkedEnrichment.keys().next().value;if(l===void 0)break;e.parkedEnrichment.delete(l)}return!0}function Cq(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)A$(e,o,t),(r=id[s])==null||r.call(id,e,o,t)}}function P$(e,t){e.parkedEnrichment.delete(t)}function Pt(e,t){return Object.hasOwn(e,t)?e[t]:void 0}const Aq=/^\s*<task-notification>([\s\S]*?)<\/task-notification>/;function Lj(e,t){var n;return((n=new RegExp(`<${t}>([\\s\\S]*?)</${t}>`).exec(e))==null?void 0:n[1].trim())||void 0}const Rq={completed:"background task finished",failed:"background task failed",killed:"background task stopped"};function sh(e){const t=Aq.exec(e);if(!t)return null;const n=Lj(t[1],"status");return{label:(n?Pt(Rq,n):void 0)??"background task update",detail:Lj(t[1],"summary")}}function D$(e){return e.filter(t=>!sh(t.text))}const Pj=2e3;function Mq(e,t,n){for(let r=e.length-1;r>=0;r--){const s=e[r];if(s.at<t-Pj)return!1;if(s.text===n&&s.at<=t+Pj)return!0}return!1}function $q(e,t,n){if(Mq(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 jd=2e3;function Iq(e){const t=e.prompts[e.prompts.length-1];return t&&t.at>e.startedAt?t.at:e.startedAt}const Dj=["B","KB","MB","GB","TB"];function oa(e){if(e==null||!Number.isFinite(e)||e<0)return"—";if(e===0)return"0 B";let t=e,n=0;for(;n<Dj.length-1&&Number(t.toFixed(1))>=1024;)t/=1024,n++;return`${t.toFixed(1)} ${Dj[n]}`}const Oq=60,Lq=6e3,Wn=e=>e!=null&&typeof e=="object"&&!Array.isArray(e),bn=e=>typeof e=="string"?e:null;function Pq(e){return Wn(e)&&e.ccdeck_truncated===!0&&typeof e.chars=="number"&&Object.keys(e).length===2?e.chars:null}function wi(e){const t=Pq(e);if(t!=null)return`(too large to show — ${oa(t)}, cut by the hook)`;if(Array.isArray(e)){const n=e.map(wi);return n.some((r,s)=>r!==e[s])?n:e}if(Wn(e)){let n=!1;const r={};for(const[s,o]of Object.entries(e))r[s]=wi(o),r[s]!==o&&(n=!0);return n?r:e}return e}function ro(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=ro(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 Dq(e){return e.lines??e.text.split(`
61
- `).map(t=>({text:t}))}function F$(e,t){if(t)return{shown:e,cut:!1};const n=[];let r=0;for(const s of e){if(n.length===Oq)return{shown:n,cut:!0};const o=Lq-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 Fq(e,t){return F$(e,!1).cut?t?{label:"show less",expanded:!0}:{label:"show all",expanded:!1}:null}const en=(e,t,n=!1)=>({...e?{label:e}:{},text:t,...n?{err:!0}:{}}),kn=(e,t)=>({label:e,text:t,inline:!0}),B$=(e,t)=>({label:e,text:t.map(n=>n.text).join(`
62
- `),lines:t});function Bq(e,t){return[...e.split(`
63
- `).map(n=>({text:`- ${n}`,tone:"del"})),...t.split(`
64
- `).map(n=>({text:`+ ${n}`,tone:"add"}))]}function qq(e){if(!Array.isArray(e)||e.length===0)return null;const t=[];for(const n of e){if(!Wn(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 Fj(e){if(typeof e=="string")return[en(void 0,e)];if(!Wn(e))return[en(void 0,ro(e))];const t=[],n=bn(e.type);n==="create"&&t.push(kn("result","created the file"));const r=qq(e.structuredPatch);return r&&t.push(B$("applied",r)),e.userModified===!0&&t.push(kn("note","the user changed it before it was applied")),t.length?t:[kn("result",n==="update"?"updated the file":"done")]}function Uq(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 zq(e){if(typeof e=="string")return[en(void 0,e)];const t=Wn(e)&&Wn(e.file)?e.file:null,n=bn(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(kn("lines",o>=l?`all ${l}`:Number.isFinite(c)?`${c}–${c+o-1} of ${l}`:`${o} of ${l}`)),s.push(en("content",n)),s}const r=Wn(e)?bn(e.type):null;return r&&r!=="text"?[kn("result",`${/^[aeiou]/i.test(r)?"an":"a"} ${r} file`)]:[en(void 0,ro(e))]}function Wq(e){if(typeof e=="string")return[en("output",e)];if(!Wn(e))return[en(void 0,ro(e))];const t=bn(e.stdout),n=bn(e.stderr);if(t==null&&n==null)return[en(void 0,ro(e))];const r=[];return t&&r.push(en("output",t.replace(/\n$/,""))),n&&r.push(en("errors",n.replace(/\n$/,""),!0)),e.interrupted===!0&&r.push(kn("note","interrupted before it finished")),r.length?r:[kn("output","none")]}function Hq(e,t,n){const r=wi(t),s=wi(n),o=Wn(r)?r:null;if(o&&(e==="Edit"||e==="MultiEdit")){const l=bn(o.file_path),c=(e==="MultiEdit"?Array.isArray(o.edits)?o.edits:[]:[o]).filter(Wn).filter(d=>bn(d.old_string)!=null&&bn(d.new_string)!=null);if(l&&c.length){const d=[kn("file",l)];return c.forEach((h,f)=>{const p=h.replace_all===!0?", every occurrence":"";d.push(B$(c.length>1?`change ${f+1}${p}`:`change${p}`,Bq(h.old_string,h.new_string)))}),{input:d,response:Fj(s)}}}if(o&&e==="Write"){const l=bn(o.file_path),c=bn(o.content);if(l&&c!=null)return{input:[kn("file",l),en("content",c)],response:Fj(s)}}if(o&&e==="Read"){const l=bn(o.file_path);if(l){const c=Uq(o);return{input:c?[kn("file",l),kn("lines",c)]:[kn("file",l)],response:zq(s)}}}if(o&&e==="Bash"){const l=bn(o.command);if(l!=null){const c=bn(o.description);return{input:c?[en("command",l),kn("why",c)]:[en("command",l)],response:Wq(s)}}}return{input:[en(void 0,ro(r))],response:[en(void 0,ro(s))]}}function Bj(e,t,n){const r=wi(n);if(r==null)return"";if(typeof r=="string")return r;if(Wn(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"&&Wn(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 Sd(e,t=80){const n=wi(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 qj=200;function q$(e,t,n){const r=t.ok===!1;t.ok=n,e&&r===n&&(e.toolErrorCount=(e.toolErrorCount??0)+(n?-1:1))}function U$(e,t){return t.agentId==null?void 0:e.agents.get(t.agentId)}function Dl(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 Vq(e,t,n){var r;return((r=e.get(t))==null?void 0:r.tools.find(s=>s.id===n))??null}const z$=25;function W$(e,t){const n=t.tools;if(n.length>qj){const r=n.splice(0,n.length-qj);for(const s of r)V$(e,t,s)}for(let r=n.length-z$-1;r>=0;r--){const s=n[r];if(s.trimmed)break;s.input=void 0,s.response=void 0,s.trimmed=!0}}function Gq(e,t,n){const r=e.toolIndex.get(Ci(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 H$(e,t){for(const n of t.tools)V$(e,t,n)}function V$(e,t,n){const r=Ci(t.sessionId,n.id);e.toolIndex.get(r)===n&&e.toolIndex.delete(r)}function Kq(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,Dl(s,l.name,-1),l.ok===!1&&(s.toolErrorCount=(s.toolErrorCount??0)-1),l.agentId=n.id,n.tools.push(l),n.toolCount+=1,Dl(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),W$(e,n);for(let s=0;s<n.tools.length-z$;s++){const o=n.tools[s];o.trimmed||(o.input=void 0,o.response=void 0,o.trimmed=!0)}}}const Yq="no result reached the deck — events were dropped while the deck was paused";function G$(e,t,n,r,s){n.endedAt=r,q$(t,n,!1),n.errorPreview=n.outcomeGap?Yq:s,e.toolIndex.delete(Ci(t.sessionId,n.id))}function Xq(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(Ci((n==null?void 0:n.session_id)??"unknown",s))}function Zq(e,t,n,r,s){const o=t.tool_use_id?Gq(e,r,t.tool_use_id):null;if(o){if(t.tool_name&&o.name==="?"){o.name=t.tool_name;const h=U$(e,o);h&&(Dl(h,"?",-1),Dl(h,o.name,1))}o.endedAt==null&&!o.trimmed&&t.tool_input!==void 0&&(o.input=t.tool_input,o.inputPreview=Sd(t.tool_input));return}const l=t.tool_use_id??`${r.id}:${r.toolCount}`,c=Ai(t),d={id:l,name:t.tool_name??"?",input:t.tool_input,inputPreview:Sd(t.tool_input),agentId:r.id,explicitSubagentId:c?js(n,c):void 0,startedAt:s};r.tools.push(d),r.toolCount+=1,Dl(r,d.name,1),r.state="active",e.toolIndex.set(Ci(r.sessionId,l),d),W$(e,r)}function Jq(e,t,n,r,s){const o=t.tool_use_id;if(!o)return;const l=Ci(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,q$(U$(e,c),c,n==="PostToolUse"),c.trimmed||(c.response=t.tool_response),n==="PostToolUseFailure"?c.errorPreview=Sd(t.tool_response):d&&(c.errorPreview=void 0);const h=j$(t.tool_response);h&&(c.usage=h),e.toolIndex.delete(l)}function Qq(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 eU(e,t,n,r){const s=Ri(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),tc(s,t),S$(s,t)}function tU(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=Ri(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&&$q(s.prompts,r,o)&&!s.firstPrompt&&!sh(o)&&(s.firstPrompt=Sd(o,120))}function nU(e,t,n,r){const s=Ri(e,n,r,!1),o=Iq(s);if(r<o)return;const l=s.lastTurnEndAt;if(!(l!=null&&o>l&&r<=l+jd)){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&&G$(e,c,d,r,"the turn ended before this call returned");t==="SessionEnd"&&(s.closedAt=r),e.activeSubagentStack.delete(n)}}function rU(e,t,n,r){const s=Ai(t);if(!s)return;const o=wq(e,n,s,t,r),l=f0(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<=jd,h=c!=null&&r-c<=jd;if(d||h){const f=h?c:o.endedAt;o.state="done",o.endedAt=f,o.startedAt=Math.min(o.startedAt,f),T$(e,n,s);return}o.state="active",o.startedAt=o.startedAt||r,o.exitAt=void 0,o.endedAt=void 0,vq(e,n,s)}function sU(e,t,n,r){const s=Ai(t);if(!s)return;const o=E$(e,n,s,t);if(!o){for(const[l,c]of e.subagentTombstones)r-c>jd&&e.subagentTombstones.delete(l);e.subagentTombstones.set(js(n,s),r);return}o.state="done",o.endedAt=Math.min(o.endedAt??r,r),T$(e,n,s)}const aU=["command","cmd","file_path","path","url","pattern","notebook_path"],Uj=120,Bp=e=>e.length>Uj?`${e.slice(0,Uj-1)}…`:e;function oU(e){if(typeof e=="string")return e.trim()?Bp(e.trim()):null;if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e;for(const n of aU){const r=t[n];if(typeof r=="string"&&r.trim())return Bp(r.trim());if(Array.isArray(r)&&r.length>0&&r.every(s=>typeof s=="string")){const s=r.join(" ").trim();if(s)return Bp(s)}}return null}function iU(e){return e==="permission_prompt"?"permission":e==="agent_needs_input"?"asked":e==="idle_prompt"?"idle":null}const lU=new Set(["Notification","ModelObserved","ContextObserved","UsageObserved","SessionNamed","SessionRecapped","OutputObserved","ActivityObserved","JobObserved"]);function cU(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 uU=3e4;function dU(e,t){if(!(!e||!e.name)&&!(t-e.startedAt>uU)&&!(e.startedAt>t))return{name:e.name,preview:oU(e.input)??""}}function hU(e,t,n,r,s){if(n!=="permission")return{kind:n,message:r,since:s};const o=cU(e,t),l={kind:n,message:r,since:s};o!=null&&o.explicitSubagentId&&(l.subagentId=o.explicitSubagentId);const c=dU(o,s);return c&&(l.tool=c),l}function fU(e,t,n){if(e.kind==="idle")return!0;const r=Ai(t);return r==null?!0:e.subagentId!=null&&js(n,r)===e.subagentId}function pU(e,t,n,r){if(!lU.has(t)){const s=e.agents.get(r);s!=null&&s.waiting&&fU(s.waiting,n,r)&&(s.waiting=null)}}function mU(e,t,n,r){const s=iU(t.notification_type);if(!s)return;const o=Ri(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)}:hU(e,n,s,l,r)}function vc(e,t){return t&&(e.revision+=1),t}function gU(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&&(H$(e,g),e.agents.delete(p),g.kind==="root"&&P$(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 vc(e,d>0)}function yU(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&&H$(e,j),e.agents.delete(v)}P$(e,f);const g=js(f,"");for(const v of e.pendingSubagentModels.keys())v.startsWith(g)&&e.pendingSubagentModels.delete(v);s==null||s(f),d--,h=!0}return vc(e,h)}function wU(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 vc(e,t)}function vU(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&&(G$(e,s,c,d,"session ended before this call returned"),r=!0)}}return vc(e,r)}const zj=90*6e4;function xU(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 vc(e,r)}function nc(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 K$(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{...u0(),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(pU(e,o,r,l),o!=="JobObserved"&&Qq(e,l,s),A$(e,r,l),Tq(e,o,r,l))return e;switch(o){case"ModelObserved":return R$(e,r,l),e;case"ContextObserved":return M$(e,r,l),e;case"SessionNamed":return $$(e,r,l),e;case"SessionRecapped":return bq(e,r,l),e;case"ActivityObserved":return I$(e,r,l),e;case"JobObserved":return O$(e,r,l),e;case"OutputObserved":return Nq(e,r,l,s),e;case"UsageObserved":return L$(e,r,l),e}const c=gq(e,r,s);Cq(e,l),yq(e,o,r,l)&&Kq(e,l),c.provider||(c.provider=r.provider==="codex"?"codex":"claude");const d=x$(r),h=Ai(r),f=h?js(l,h):l;switch(d&&c.id===f&&(c.model=d),o){case"SessionStart":eU(e,r,l,s);break;case"UserPromptSubmit":tU(e,r,l,s);break;case"PreToolUse":Zq(e,r,l,c,s);break;case"PostToolUse":case"PostToolUseFailure":Jq(e,r,o,l,s);break;case"SubagentStart":rU(e,r,l,s);break;case"SubagentStop":sU(e,r,l,s);break;case"Stop":case"SessionEnd":nU(e,o,l,s);break;case"Notification":mU(e,r,l,s);break}return e}const bU={input:2,output:10,cacheRead:.2,cacheWrite:2.5,cacheWrite1h:4},kU=[{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:bU},{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}}],NU=[{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 jU(e){return e?/^(?:gpt[-_]|codex[-_]|o\d)/i.test(e):!1}function ma(e,t=Date.now(),n=ha){if(!e)return null;const r=SU.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 ha="standard",SU=new Map([[ha,kU],["fast",NU]]);function Fl(e,t){return e*t/1e6}function Y$(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:Fl(o,t.cacheWrite),usd1h:Fl(n,l)}}function X$(e,t,n=Date.now()){if(!jU(t))return e.inputTokens;const r=ma(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 ah(e,t,n=Date.now()){const r={input:0,output:0,cacheRead:0,cacheWrite:0,total:0};for(const s of oh(e)){const o=_d(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 _d(e,t,n,r=Date.now()){const s=ma(t,r,n);if(!s)return{input:0,output:0,cacheRead:0,cacheWrite:0,total:0};const o=Fl(X$(e,t,r),s.input),l=Fl(e.outputTokens,s.output),c=Fl(e.cacheReadTokens,s.cacheRead),d=Y$(e,s),h=d.usd5m+d.usd1h;return{input:o,output:l,cacheRead:c,cacheWrite:h,total:o+l+c+h}}function oh(e){const t=e.bySpeed?Object.entries(e.bySpeed):[];return t.length===0?[{speed:ha,usage:e}]:[{speed:ha,usage:_U(e,t.map(([,n])=>n))},...t.map(([n,r])=>({speed:n,usage:r}))]}function _U(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 ks="not priced";function Bl(e,t,n){const r=e.toFixed(t);return Number(r)<n?r:null}function qe(e){if(e<=0)return"—";if(e<.005)return"<1¢";if(e<1){const t=Bl(e*100,e<.1?1:0,100);if(t!==null)return`${t}¢`}if(e<100){const t=Bl(e,2,100);if(t!==null)return`$${t}`}if(e<1e4){const t=Bl(e,0,1e4);if(t!==null)return`$${t}`}return`$${(e/1e3).toFixed(1)}k`}function p0(e,t){if(e<=0||t<10)return null;const n=e/t,r=n*60;return r>=.01?`${qe(r)}/min`:`${qe(n*3600)}/hr`}function Z$(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?Z$(l,o):o)}n.bySpeed=Object.fromEntries(r)}return n}function EU(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 xc(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=EU(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:Z$(r[o].usage,s)}:r.push({model:e.model,usage:s})}return r}function pn(e,t=Date.now()){const n={input:0,output:0,cacheRead:0,cacheWrite:0,total:0};for(const r of xc(e)){const s=ah(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 rc(e,t=Date.now()){let n=0;for(const r of xc(e))for(const s of oh(r.usage))ma(r.model,t,s.speed)==null&&(n+=s.usage.inputTokens+s.usage.outputTokens);return n}function J$(e){const t=[];for(const n of xc(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 m0(e){return J$(e).filter(t=>t!==e.model)}function Wj(e,t){if(!e.bySpeed)return qp(e,t,ha);const n=oh(e).filter(r=>r.speed!==ha||TU(r.usage));return n.length===1?qp(n[0].usage,t,n[0].speed):[...n.map(r=>qp(r.usage,t,r.speed)),"═════════════════════════════════════════",`all speeds = ${qe(ah(e,t).total)}`].join(`
66
- `)}function TU(e){return e.inputTokens+e.outputTokens+e.cacheReadTokens+e.cacheCreateTokens>0}function qp(e,t,n){const r=ma(t,Date.now(),n),s=n===ha?`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=_d(e,t,n),d=Y$(e,r),h=d.tokens1h>0?[`cache w5m${o(d.tokens5m).padStart(14)} × ${l(r.cacheWrite).padEnd(11)} = ${qe(d.usd5m)}`,`cache w1h${o(d.tokens1h).padStart(14)} × ${l(r.cacheWrite1h??r.cacheWrite).padEnd(11)} = ${qe(d.usd1h)}`]:[`cache w ${o(d.tokens5m).padStart(14)} × ${l(r.cacheWrite).padEnd(11)} = ${qe(d.usd5m)}`],f=X$(e,t),p=f===e.inputTokens?"input":"uncached";return[s,`${p.padEnd(9)}${o(f).padStart(14)} × ${l(r.input).padEnd(11)} = ${qe(c.input)}`,`output ${o(e.outputTokens).padStart(14)} × ${l(r.output).padEnd(11)} = ${qe(c.output)}`,`cache r ${o(e.cacheReadTokens).padStart(14)} × ${l(r.cacheRead).padEnd(11)} = ${qe(c.cacheRead)}`,...h,"─────────────────────────────────────────",`total = ${qe(c.total)}`].join(`
68
- `)}function Hj(e){const t=xc(e),[n]=t;return t.length<=1?Wj(n.usage,n.model):[...t.map(r=>Wj(r.usage,r.model)),"═════════════════════════════════════════",`all models = ${qe(pn(e).total)}`].join(`
69
- `)}function CU(e){if(!e.model)return null;const t=ma(e.model),n=pn(e),r=rc(e);if(!t&&n.total<=0)return e.usage.inputTokens+e.usage.outputTokens<=0?null:{kind:"unpriced",tt:Hj(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?p0(n.total,s):null,l=Hj(e)+(o?`
70
- burn: ${o}`:"");return{kind:"spent",total:n.total,floor:r>0,tt:l}}const AU=new Set(["untrusted","on-request","on-failure"]);function RU(e){return typeof e!="string"||!e?null:AU.has(e)?!0:e==="never"?!1:null}function Q$(e){if(e.provider!=="codex"||e.kind!=="root"||e.waiting||e.state!=="active")return null;const t=RU(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 Vj(e){return e[0].toUpperCase()+e.slice(1).toLowerCase()}function Ns(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=Vj(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(Vj);return[`GPT-${s}`,...o].join(" ")}return e}function ih(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 jn(e){return(e==null?void 0:e.kind)==="permission"||(e==null?void 0:e.kind)==="asked"}function Gx(e){const t=[];for(const n of e)n.kind==="root"&&jn(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 MU(e,t){if(e.length===0)return null;const n=e.findIndex(r=>r.id===t);return e[(n+1)%e.length]}function $U(e){const t=new Set;for(const n of e)n.state==="active"&&t.add(n.sessionId);return t.size}function lh(e,t){return`${e}@${t.since}`}function eI(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 IU(e){const t=e.message||"Needs your permission",n=eI(e,t);return n?`${t}
73
- Likely on: ${n}`:t}function OU(e,t,n,r=!0){if(!r)return[];if(n)return[];const s=[];for(const o of e){if(!jn(o.waiting))continue;const l=lh(o.id,o.waiting);t.has(l)||s.push({key:l,title:o.label,body:IU(o.waiting),sessionId:o.id})}return s}function LU(e,t,n){const r=new Set;for(const o of e)r.add(lh(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 Fu(e){return new Set(e.map(t=>lh(t.id,t.waiting)))}function PU(e,t){return e!==t}function DU(e,t){return!e&&t!=null}function FU(e,t){return e!==null&&t!=null}function vi(e){return e==="active"?"live":e==="done"?"done":"err"}function xi(e){return e.message?e.message:e.kind==="permission"?"Needs your permission":"Waiting for your input"}function BU(e){return`${e} subagent${e===1?"":"s"} spawned`}function qU(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=m0(e).length;t.push(`${Ns(e.model)}${n>0?` +${n}`:""}`)}else e.provider==="codex"&&t.push("Codex");return t.join(" · ")}function UU(e,t=Date.now(),n=!1){const r=e.toolErrorCount??0,s=pn(e,t).total;return[e.label,e.kind==="root"?"session":"subagent",vi(e.state),jn(e.waiting)?xi(e.waiting):null,e.model?Ns(e.model):null,`${e.toolCount} ${e.toolCount===1?"tool":"tools"}`,r>0?`${r} failed`:null,s>0?`${qe(s)}${rc(e,t)>0?"+":""}`:null,n?"selected":null].filter(Boolean).join(", ")}function zU(e,t){const n=eI(e,t);return n?`Likely on: ${n}`:null}function Ed(e){return e.kind==="idle"?"Your turn":xi(e)}function rt(e){const t=Math.round(e);if(t<1e3)return`${t}`;if(t<1e6){const n=Bl(t/1e3,1,1e3);if(n!==null)return`${n}k`}if(t<1e9){const n=Bl(t/1e6,2,1e3);if(n!==null)return`${n}M`}return`${(t/1e9).toFixed(2)}B`}function bi(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 tI(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 g0(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 Gj=2e5,WU=1e6,HU=[/\[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],VU=[{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 GU(e){if(!e)return Gj;const t=gs(e);for(const n of HU)if(n.test(t))return WU;for(const n of VU)if(n.match.test(t))return n.window;return Gj}function nI(e,t){return typeof e=="number"&&e>0?e:GU(t)}const KU=1;function YU(){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 Fr=YU(),rI=e=>e==="Escape";function XU(e){return e.overlayOpen?"dismiss":e.typing?"blur":"clear-selection"}function Kj(e){return String(e.tagName??"").toUpperCase()==="BODY"}function ZU(e,t){return!e||!e.isConnected||Kj(e)?!1:t==null||Kj(t)}const Yj="a[href], button, input, select, textarea, summary, [tabindex]";function JU(e){return!e||e.disabled||e.rendered===!1?!1:(e.tabIndex??0)>=0}function QU(e){if(!e||!e.overflowing||e.hasFocusable)return!1;const t=String(e.overflow??"").toLowerCase();return t==="auto"||t==="scroll"}function ez({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 ch(e){return e.ctrlKey||e.metaKey||e.altKey}const tz=new Set(["button","checkbox","color","file","image","radio","range","reset","submit"]),nz=new Set(["INPUT","TEXTAREA","SELECT","OPTION","BUTTON","SUMMARY","A"]),rz=new Set(["button","checkbox","combobox","link","listbox","menu","menubar","menuitem","menuitemcheckbox","menuitemradio","option","radio","searchbox","slider","spinbutton","switch","tab","textbox","treeitem"]);function y0(e){return typeof e.tagName=="string"?e.tagName.toUpperCase():""}function sz(e){return y0(e)==="BUTTON"?!0:(typeof e.role=="string"?e.role.trim().toLowerCase():"").split(/\s+/).includes("button")}function ki(e){if(!e)return!1;if(e.isContentEditable)return!0;const t=y0(e);return t==="TEXTAREA"?!0:t!=="INPUT"?!1:!tz.has(String(e.type??"text").toLowerCase())}function az(e,t){if(!e)return!1;if(ki(e))return!0;if(t!=null&&(t.length===1||t==="Delete")&&t!==" "&&e.pointerFocused&&sz(e))return!1;if(nz.has(y0(e)))return!0;const n=typeof e.role=="string"?e.role.trim().toLowerCase():"";return n!==""&&n.split(/\s+/).some(r=>rz.has(r))}function oz({key:e,modalOpen:t,sheetOpen:n}){return t?!(e==="?"&&n):!1}function iz({key:e,sheetOpen:t,target:n}){return t&&e==="?"&&!ki(n)}function Kx({appModal:e,dialogDepth:t}){return e||t>0}function sI(e){return e?Array.from(e.querySelectorAll("*")).filter(t=>{if(t.matches(Yj))return JU({disabled:t.disabled,tabIndex:t.tabIndex,rendered:t.checkVisibility?t.checkVisibility():t.getClientRects().length>0});const n=t.scrollHeight>t.clientHeight;return n&&QU({overflowing:n,overflow:getComputedStyle(t).overflowY,hasFocusable:t.querySelector(Yj)!=null})}):[]}function lz(e,t){const n=sI(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 dt(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(()=>Fr.push(h,r,o),[h,r,o]),y.useEffect(()=>{var p;const f=document.activeElement;return(p=(n==null?void 0:n.current)??sI(l.current)[0])==null||p.focus(),()=>{ZU(f,document.activeElement)&&f.focus()}},[]),y.useEffect(()=>{const f=p=>{var N;if(p.key!=="Tab"||ch(p))return;const g=l.current;if(!g)return;const v=document.activeElement;if(!(v!=null&&g.contains(v))&&!Fr.isTop(h))return;const k=lz(g,v),x=ez({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 gt(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 cz(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 Fn(e){return e.toLocaleString()}const uz=60;function dz(e,t=uz){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 hz({agent:e,onClose:t}){var v;const n=y.useRef(null),r=dt(t,{focusRef:n}),s=gt(t),o=e.context,l=e.usage,c=(o==null?void 0:o.currentContextTokens)??0,d=nI(e.contextWindow,e.model),h=Math.min(100,c/d*100),f=pn(e),p=e.provider==="codex"?l.inputTokens+l.outputTokens:l.inputTokens+l.outputTokens+l.cacheReadTokens+l.cacheCreateTokens,g=cz(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:[Fn(c)," / ",Fn(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(lr,{label:"input tokens",val:Fn(l.inputTokens)}),a.jsx(lr,{label:"output tokens",val:Fn(l.outputTokens)}),a.jsx(lr,{label:"cache reads",val:Fn(l.cacheReadTokens)}),a.jsx(lr,{label:"cache writes",val:Fn(l.cacheCreateTokens)}),a.jsx(lr,{label:"cumulative total",val:Fn(p)}),a.jsx(lr,{label:"estimated cost",val:qe(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(lr,{label:"user messages",val:Fn((o==null?void 0:o.msgsUser)??0)}),a.jsx(lr,{label:"assistant messages",val:Fn((o==null?void 0:o.msgsAssistant)??0)}),a.jsx(lr,{label:"tool uses",val:Fn((o==null?void 0:o.toolUses)??0)}),a.jsx(lr,{label:"tool results",val:Fn((o==null?void 0:o.toolResults)??0)}),a.jsx(lr,{label:"system-reminders",val:Fn((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:dz(j.path)}),a.jsx("span",{className:"ctx-md-size",children:oa(j.bytes)})]},j.path))})]})})}function lr({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 fz({currentContextTokens:e,modelId:t,contextWindow:n,size:r=26,onClick:s}){const o=nI(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 Xj=new Map;function aI(e){let t=Xj.get(e);return t||(t={now:Date.now(),listeners:new Set,timer:null},Xj.set(e,t)),t}function pz(e,t){const n=aI(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 mz(e){return aI(e).now}const Zj=new Map,Jj=new Map;function Mi(e=1e3){let t=Zj.get(e);t||(t=r=>pz(e,r),Zj.set(e,t));let n=Jj.get(e);return n||(n=()=>mz(e),Jj.set(e,n)),y.useSyncExternalStore(t,n,n)}function gz(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 yz="1",Qj="agent-dag.schema",wz=["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 Ke(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 ql(){if(typeof window>"u")return null;try{return window.localStorage}catch{return null}}function vz(e,t=yz){let n=null;try{n=e.getItem(Qj)}catch{return[]}if(n===t)return[];const r=[];if(n!==null)for(const s of wz)try{e.getItem(s)!==null&&(e.removeItem(s),r.push(s))}catch{}try{e.setItem(Qj,t)}catch{}return r}const oI="agent-dag.recapsDismissed",eS=200;function xz(){const e=Je(oI);if(!e)return[];try{const t=JSON.parse(e);return Array.isArray(t)?t.filter(n=>typeof n=="string"):[]}catch{return[]}}let Ni=new Set(xz());const Yx=new Set;let iI=0;function lI(e){return Yx.add(e),()=>{Yx.delete(e)}}function cI(e){Ni=e,iI++;const t=Array.from(e);Ke(oI,JSON.stringify(t.length>eS?t.slice(-eS):t));for(const n of Yx)n()}function bz(e,t){return`${e}@${t}`}function kz(e){return Ni.has(e)}function Nz(e){if(Ni.has(e))return;const t=new Set(Ni);t.add(e),cI(t)}function jz(e){const t=new Set(Ni);t.delete(e)||t.add(e),cI(t)}function Sz(e){return y.useSyncExternalStore(lI,()=>e!=null&&Ni.has(e),()=>!1)}function w0(e){return`recap:${e}`}function _z(e){return e.startsWith("recap:")}function Ez(){return y.useSyncExternalStore(lI,()=>iI,()=>0)}function da(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 Tz(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 Cz(e){let t=null;for(const n of e.prompts)(!t||n.at>t.at)&&(t=n);return t}const tS=160;function Az(e){const t=sh(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>tS?r.slice(0,tS-1).trimEnd()+"…":r}function Rz(e){const t=Cz(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?Tz(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=Az(t.text);if(l)return r({kind:"now",text:l,at:t.at,source:"prompt"})}return null}function uh(e){if(e.kind!=="root"||e.closedAt!=null)return null;const t=Rz(e),n=gz(e),r=n?{kind:"recap",text:n.text,at:n.at,source:"recap",key:bz(e.sessionId,n.at)}:null;return t&&r?r.at>t.at?r:t:t??r}function dh(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 Mz(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 uI(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 dI(e){return e.live>0?`→ ${e.total} · ${e.live} live`:`→ ${e.total} · done`}function $z(e,t,n){const r=e.kind==="root"?e.waiting:null;if(r&&jn(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:uI(t),short:dI(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 Iz(e,t){return t?t.includes(e)?t:`${e}
75
- ${t}`:e}function Xx(e){return e==="active"?"live":e==="done"?"done":"err"}const hh={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"}},Oz=Object.fromEntries(Object.entries(hh).map(([e,t])=>[e,t.category])),Lz=Object.fromEntries(Object.entries(hh).map(([e,t])=>[e,t.emoji])),Pz=Object.fromEntries(Object.entries(hh).map(([e,t])=>[e,t.label])),Dz=new Set(Object.entries(hh).filter(([,e])=>e.shell).map(([e])=>e)),Fz={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",...Oz};function hI(e){return e.startsWith("mcp__")?"mcp":Pt(Fz,e)??"other"}const Bz=/\btools\.exec_command\s*\(\s*\{[^{}]*?\bcmd\s*:\s*(["'`])((?:\\.|(?!\1)[^\\])*)\1/,qz=/\btools\.([A-Za-z_$][\w$]*)\s*\(/;function Uz(e){if(typeof e!="string"||!e)return null;const t=Bz.exec(e);if(t){const r=zz(t[2]);if(r.trim())return r}const n=qz.exec(e);return n?n[1]:null}function zz(e){return e.replace(/\\(["'`\\nrt])/g,(t,n)=>n==="n"?`
76
- `:n==="r"?"\r":n==="t"?" ":n)}const Wz={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:"📡",...Lz};function nS(e){return e.startsWith("mcp__")?"🔌":Pt(Wz,e)??"✨"}const Hz={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 fI(e){return/^-(?:Command|c)$/i.test(e)||/^-[a-z]+c$/.test(e)}function pI(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=>fI(o)||/^-(?:NoProfile|NonInteractive)$/i.test(o)))return pI(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 Vz(e){if(typeof e=="string")return e;if(!e||typeof e!="object")return null;const t=e;if(typeof t.script=="string"){const n=Uz(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(fI);if(r>=0&&r+1<n.length)return n[r+1]}return n.join(" ")}return typeof t.script=="string"?t.script:null}const Gz=new Set(["Bash","PowerShell",...Dz]);function Kz(e,t){if(!Gz.has(e))return null;const n=Vz(t);if(!n)return null;const r=pI(n);return r?{emoji:Pt(Hz,r)??"⚙️",label:r,category:"shell",detail:n}:null}const Yz=new Set(["Read","Write","Edit","MultiEdit","NotebookEdit","LS","Glob","apply_patch"]),Xz={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:"🗄️"},Zz={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 Jz(e){const n=e.replace(/\\/g,"/").replace(/\/+$/,""),r=n.lastIndexOf("/");return r>=0?n.slice(r+1):n}function Qz(e){const t=e.toLowerCase(),n=Pt(Zz,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=Pt(Xz,t.slice(r+1));if(s!==void 0)return s}return"📄"}function eW(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 tW(e,t){if(!Yz.has(e))return null;const n=eW(e,t);if(!n)return null;const r=Jz(n);return r?{emoji:e==="LS"?"📂":Qz(r),label:r,category:"file",detail:n}:null}const nW={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 v0(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 rW(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 mI(e){return Pt(nW,e.toLowerCase())}function sW(e,t){const n=v0(e);if(!n)return null;const{server:r,method:s}=n;if(!s)return null;const o=mI(r);return{emoji:(o==null?void 0:o.emoji)??"🔌",label:s,category:"mcp",detail:o?`${o.name} · ${s}`:`${r} · ${s}`}}function gI(e,t){return Kz(e,t)??tW(e,t)??sW(e)}function aW(e,t){var n;return((n=gI(e,t))==null?void 0:n.label)??null}const oW=Pz,rS=18;function Bu(e){const t=[...e];return t.length<=rS?e:t.slice(0,rS-1).join("")+"…"}const Up=13,iW=6;function lW(e,t){const n=[...e];if(n.length<=Up)return e;const r=n.lastIndexOf("."),s=r>0?n.slice(r):[];return t==="file"&&s.length>1&&s.length<=iW?n.slice(0,Up-1-s.length).join("")+"…"+s.join(""):n.slice(0,Up-1).join("")+"…"}function x0(e){const t=v0(e);if(t){const r=mI(t.server);return r?{emoji:r.emoji,label:Bu(r.name)}:{emoji:"🔌",label:Bu(t.server),hue:rW(t.server)}}const n=Pt(oW,e)??"";return n?{emoji:nS(e),label:Bu(n)}:{emoji:nS(e),label:Bu(e)}}function cW(e){let t=null,n="";for(const r of e){const s=v0(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:x0(n)}const Zx=6e4,di=24,sS=Zx/di,zp=132,ld=14;function uW(e,t,n){const r=new Array(di).fill(0);let s=0;const o=g=>{const v=n-g;if(v<0||v>=Zx)return;const j=di-1-Math.floor(v/sS);j>=0&&j<di&&(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)/(sS/1e3),d=e.filter(g=>n-g.startedAt>=0&&n-g.startedAt<Zx).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 dW=2;function hW(e){return e===0?1.5:Math.max(1.5,Math.min(1,e/dW)*ld)}function yI({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 b0(){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 wI(){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 Td({recap:e}){return e?a.jsx(wI,{}):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 fW({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=nc(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=m0(e),h=d.length>0?`${e.model}
78
- spend on this card also covers:
79
- ${d.join(`
80
- `)}`:e.model,f=g0(e.sessionName,e.sessionTitle),p=uh(e),g=p?p.key:null,v=Sz(g),j=p!=null&&!v,k=(p==null?void 0:p.kind)==="recap",x=CU(e);return a.jsxs("div",{className:t,style:{"--session-hue":s},children:[a.jsx("span",{className:"accent-stripe"}),a.jsx(to,{type:"target",position:Ae.Left,style:{background:"transparent",border:"none"}}),a.jsxs("div",{className:"head",children:[a.jsxs("div",{className:"title",children:[a.jsx(yW,{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: ${da(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(),jz(g)},children:a.jsx(Td,{recap:k})})]}),a.jsxs("div",{className:"head-right",children:[l&&e.onOpenContext&&a.jsx(fz,{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(gW,{start:e.startedAt,end:e.endedAt})]})]})]}),a.jsxs("div",{className:"sub",title:qU(e),children:[e.kind==="root"?"session":"subagent",e.childCount>0&&a.jsxs("span",{className:"spawn-badge",title:BU(e.childCount),children:["→ ",e.childCount]}),e.cwdBasename&&e.kind==="subagent"?` · ${e.cwdBasename}`:"",e.model?a.jsxs("span",{className:"model-chip","data-family":ih(e.model),title:h,children:[Ns(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(wW,{waiting:e.waiting}),(()=>{const S=Q$(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(vW,{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:rt(e.usage.inputTokens+e.usage.outputTokens)})," tok"]}),(x==null?void 0:x.kind)==="unpriced"&&a.jsx("span",{className:"cost-unpriced",title:x.tt,children:ks}),(x==null?void 0:x.kind)==="spent"&&a.jsx("span",{className:"cost-meta",title:x.tt,children:a.jsxs("b",{children:[qe(x.total),x.floor?"+":""]})})]}),a.jsx(mW,{data:e,title:e.kind==="root"?f.face:void 0}),a.jsx(to,{type:"source",position:Ae.Right,style:{background:"transparent",border:"none"}})]})}const pW=y.memo(fW);function mW({data:e,title:t}){const n=e.kind==="root"&&jn(e.waiting),r=$z(e,e.branch,{sayWaiting:Ed,describeCall:s=>({name:x0(s.name).label,subject:aW(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(yI,{kind:Xx(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(b0,{})]}),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 gW({start:e,end:t}){const n=Mi(1e3);return a.jsx(a.Fragment,{children:bi(e,t,n)})}function yW({state:e}){return a.jsx("span",{className:`state-pill state-${e}`,children:vi(e)})}function wW({waiting:e}){const t=Mi(1e3),n=jn(e),r=xi(e);return a.jsxs("div",{className:n?"waiting-row permission":"waiting-row idle",title:`${r}
81
- Blocked for ${bi(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:Ed(e)}),a.jsx("b",{children:bi(e.since,void 0,t)})]})}function vW({tools:e,outputs:t}){const n=Mi(1e3),{counts:r,title:s}=uW(e,t,n),o=zp/di;return a.jsxs("div",{className:"tool-spark-row",title:s,children:[a.jsx("svg",{className:"tool-spark",width:zp,height:ld,viewBox:`0 0 ${zp} ${ld}`,"aria-hidden":!0,children:r.map((l,c)=>{const d=hW(l),h=c===di-1&&l>0,p=`tool-spark-bar${l>0?" active":""}${h?" latest":""}`;return a.jsx("rect",{x:c*o+.4,y:ld-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 xW({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 Cd(e){const t=Math.max(0,Math.floor(e));return`${t} event${t===1?"":"s"}`}const aS=99;function bW(e){const t=Math.max(0,Math.floor(e));return t>aS?`${aS}+`:String(t)}const kW="Pause the canvas";function NW(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 — ${Cd(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)":`${Cd(e.held)} arrived while paused and will be applied in order when you resume (Space)`}function jW(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 vI="paused · full",SW=(e,t)=>t>0?vI:e>0?`paused · ${bW(e)}`:"paused";function _W(e){const t=Math.max(0,Math.floor(e.dropped??0));return e.connected?e.paused?{tone:"paused",resting:!1,label:SW(e.held,t),widest:vI,title:t>0?`Connected — the pause is full at ${Cd(e.held)}; the oldest are being dropped as new ones arrive. Resume to catch up (Space)`:e.held>0?`Connected — ${Cd(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 EW=e=>e.transform[2]>=e.maxZoom,TW=e=>e.transform[2]<=e.minZoom;function CW({autoFitDisabled:e,enableAutoFitAndRefit:t,paused:n,pauseGate:r,togglePause:s,handleRelayout:o,requestClear:l,setKeyHelpOpen:c}){const d=Ti(),h=Ue(EW),f=Ue(TW);return a.jsxs(q8,{showInteractive:!1,showFitView:!1,showZoom:!1,children:[a.jsx(Bn,{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(Bn,{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(Bn,{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(Bn,{"data-group-start":"",onClick:s,title:NW({paused:n,held:r.size,dropped:r.dropped}),"aria-label":kW,"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(Bn,{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(Bn,{"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(Bn,{"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 Xa=148,oS=6e3,AW=16e3,xI=46,la=34;function RW(e,t,n=Xa){let r=-Math.round(t()*n);if(Math.abs(r-e)<la){const s=e-la>=-n?-la:la;r=Math.max(-n,Math.min(0,Math.round(e+s)))}return{to:r,ms:Math.round(Math.abs(r-e)*xI)}}function MW(e){return Math.round(oS+e()*(AW-oS))}const iS=[{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 $W(e){const t=iS.reduce((r,s)=>r+s.weight,0);let n=e()*t;for(const r of iS)if(n-=r.weight,n<0)return r.kind;return"stroll"}const IW=720,OW=260,LW=620,PW=220,lS=520,bI=1600,cS=7e3,DW=15e3,uS=6e3,FW=14e3;function Vo(e,t,n=Xa){let r=-Math.round(t()*n);if(Math.abs(r-e)<la){const s=e-la>=-n?-la:la;r=Math.max(-n,Math.min(0,Math.round(e+s)))}return r}const At=(e,t)=>Math.round(Math.abs(t-e)*xI),BW=120,qu=0;function qW(e,t){const n=r=>({kind:"litter",at:t,...r});return[{x:t,prop:n({}),act:"walk",ms:At(e,t)},{x:t,prop:n({}),act:"stoop",ms:IW},{x:qu,prop:n({held:!0}),act:"carry",ms:At(t,qu)},{x:qu,prop:n({held:!0}),act:"windup",ms:OW},{x:qu,prop:n({held:!0,leaving:!0}),act:"toss",ms:LW}]}function UW(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:At(e,r)},{x:r,prop:s(),act:"windup",ms:PW,facing:n>0?"right":"left"},{x:r,prop:s({leaving:!0}),act:"kick",ms:lS,facing:n>0?"right":"left"},{x:r,prop:s({leaving:!0}),act:"stand",ms:bI-lS}]}const kI=640;function zW(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:At(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:At(r,0)}]}function WW(e,t,n){const r=Math.max(-110,Math.min(-30,t)),s={x:r,prop:null};return[{...s,act:"walk",ms:At(e,r)},{...s,act:"skip-ready",ms:500},{...s,act:"skip",ms:kI*(6+Math.floor(n()*5))},{...s,act:"skip-rest",ms:600},{...s,act:"stand",ms:350},{x:0,prop:null,act:"walk",ms:At(r,0)}]}function HW(e,t,n){return[{x:t,prop:null,act:"walk",ms:At(e,t)},{x:t,prop:null,act:"sit",ms:Math.round(uS+n()*(FW-uS))},{x:t,prop:null,act:"stand",ms:400}]}function VW(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:At(e,t)},{x:t,prop:r(),act:"watch",ms:Math.round(cS+n()*(DW-cS))},{x:t,prop:r(),act:"scope-pack",ms:480},{x:t,prop:null,act:"stand",ms:240}]}function Wp(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 GW=1500,KW=e=>Math.round(1e3*Math.sqrt(2*e/GW)),YW=115,XW=e=>Math.round(e/YW*1e3),ZW=620,JW=200,QW=760,eH=600,tH=240;function nH(e,t,n){const s=-(t.ledgeSpan??Xa),o=KW(t.ledgeH),l=XW(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:At(e,s)},{x:s,act:"peer",prop:null,ms:ZW},{x:s,act:"fall",prop:null,ms:o,place:"floor"},{x:s,act:"land",prop:null,ms:JW,place:"floor"},{x:h,act:"walk",prop:null,ms:At(s,h),place:"floor",floorFrac:c},{x:f,act:"walk",prop:null,ms:At(h,f),place:"floor",floorFrac:d},{x:s,act:"walk",prop:null,ms:At(f,s),place:"floor"},{x:s,act:"lasso",prop:null,ms:QW,place:"floor"},{x:s,act:"rope-throw",prop:null,ms:eH,place:"floor"},{x:s,act:"rope-catch",prop:null,ms:tH,place:"floor"},{x:s,act:"climb",prop:null,ms:l},{x:s,act:"pull-up",prop:null,ms:480}]}function rH(e,t,n){const r=(n==null?void 0:n.ledgeSpan)??Xa;switch($W(t)){case"tidy":return qW(e,Vo(e,t,r));case"kick":return UW(e,Vo(e,t,r));case"sit":return HW(e,Vo(e,t,r),t);case"watch":return VW(e,Vo(e,t,r),t);case"fish":return zW(e,Vo(e,t,r),t);case"skip":return WW(e,Vo(e,t,r),t);case"leave":{if(!n||!(n.ledgeH>0)||!(n.floorSpan>0))break;return nH(e,n,t)}}const o=RW(e,t,r);return[{x:o.to,prop:null,act:"walk",ms:o.ms}]}const sH=420;function aH(e,t,n){const r=t==="right"?n-e-18:e-18;return(t==="right"?1:-1)*Math.min(sH,Math.max(0,r))}const oH=260,iH=200;function lH(e,t,n){const r=(f,p=At(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,At(e,c)),{...h,x:c,act:"mount",ms:oH},{...h,x:d,act:"walk",ms:At(c,d)},{x:d,prop:null,act:"dismount",ms:iH,place:"floor"},{x:t,prop:null,act:"walk",ms:At(d,t),place:"floor"}]}const NI=["bob","sway","groove"],dS=9e3,cH=16e3,jI=1e3,uH=.08;function dH(e,t){const n=NI.filter(o=>o!==e),r=n[Math.min(n.length-1,Math.floor(t()*n.length))],s=(t()*2-1)*uH;return{dance:r,beatMs:Math.round(jI*(1+s))}}function hH(e){return Math.round(dS+e()*(cH-dS))}const SI=["......aaaaaa......","....aa......aa....","...a..bbbbbs..a...","...cpcbbbbbscpc...","...cpcbebbescpc...","...cpcbbbbbscpc...","...cpcbbbbbscpc...","....ccbbbbbscc....","....bbbbbbbbbs....","....bbbbbbbbbs....","......bbbbbs......","......bb..bs......","......bb..bs......","......bb..bs......"],hS=18,fH=SI.length,_I=new Set(["a","c","p"]);function fh(e=SI){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 pH=[".xx.","xxxx",".xx."],mH=["..xx..",".xsxx.","xssxxx","xxxxsx",".xxxx.","..xx.."],gH=["...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."],Hp={litter:pH,ball:mH,scope:gH},yH=["...hhhhhh...","...hhhhhh...","...kkkkkk...","hhhhhhhhhhhh"],wH=3,vH=-1,Jx=11,fS=9,Qx="https://www.youtube-nocookie.com";function xH(e,t,n){const r=new URLSearchParams({...n?{}:{channel:e},enablejsapi:"1",autoplay:"1",playsinline:"1",rel:"0",modestbranding:"1",origin:t});return`${Qx}/embed/${n?encodeURIComponent(n):"live_stream"}?${r.toString()}`}function Go(e,t=[]){return JSON.stringify({event:"command",func:e,args:t})}function bH(e="claude-fm"){return JSON.stringify({event:"listening",id:e,channel:"widget"})}const kH=[1,3],NH=[0,2],jH=[2,5,100,101,150];function SH(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:kH.includes(s)?{kind:"playing",playing:!0}:NH.includes(s)?{kind:"playing",playing:!1}:null}return null}const _H="modulepreload",EH=function(e){return"/"+e},pS={},k0=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=EH(h),h in pS)return;pS[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":_H,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)})},_l=new Set;let mS="";function gS(e){const t=new Date().toISOString().slice(0,10);if(t!==mS&&(_l.clear(),mS=t),!_l.has(e)){_l.add(e);try{const n=typeof navigator>"u"?void 0:navigator;(!n||typeof n.sendBeacon!="function"||!n.sendBeacon("/api/feature",JSON.stringify({name:e})))&&_l.delete(e)}catch{_l.delete(e)}}}const yS=864e5,TH=6e4;function Ut(e,t=!0){y.useEffect(()=>{if(!t)return;gS(e);let n;const r=()=>{n=setTimeout(()=>{gS(e),r()},yS-Date.now()%yS+TH)};return r(),()=>clearTimeout(n)},[e,t])}const CH={"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 AH({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);Ut("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 I=x.current;I&&(I.pause(),I.removeAttribute("src"),I.load(),x.current=null)},[]),E=y.useCallback(I=>{var B,L;(L=(B=b.current)==null?void 0:B.contentWindow)==null||L.postMessage(I,Qx)},[]),R=y.useRef(t);R.current=t;const O=y.useRef(n);O.current=n;const A=y.useCallback((I,B,L)=>{S();const M=new Audio;M.preload="none",M.volume=R.current/100,M.muted=O.current,x.current=M,g(!0),j(!0);const F=()=>x.current===M,C=()=>{S(),g(!1),j(!1)},$=()=>{F()&&(C(),f(!0),l==null||l(L,!0))},P=K=>{if(F()){if(K instanceof DOMException&&K.name==="NotAllowedError"){C();return}$()}};M.addEventListener("playing",()=>{F()&&(j(!0),l==null||l(L,!1))}),M.addEventListener("ended",()=>{F()&&C()}),M.addEventListener("error",$,{once:!0}),B&&!M.canPlayType("application/vnd.apple.mpegurl")?k0(async()=>{const{default:K}=await import("./hls-BFpXDghs.js");return{default:K}},[]).then(({default:K})=>{if(!F())return;if(!K.isSupported()){$();return}const G=new K;N.current=G,G.on(K.Events.ERROR,(U,W)=>{W.fatal&&$()}),G.on(K.Events.MEDIA_ATTACHED,()=>G.loadSource(I)),G.on(K.Events.MANIFEST_PARSED,()=>{M.play().catch(P)}),G.attachMedia(M)},$):(M.src=I,M.play().catch(P))},[l,S]);return y.useEffect(()=>{p&&(E(Go("setVolume",[t])),E(Go(n?"mute":"unMute")),x.current&&(x.current.volume=t/100,x.current.muted=n))},[t,n,p,E]),y.useEffect(()=>{let I=!0;const B=e??fetch,L=k.current!==s;k.current=s,d(null),f(!1),g(L),j(L),S();const M=o&&no(o.id)===r?l0(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),()=>{I=!1}):(B(`/api/fm-station?url=${encodeURIComponent(M.url)}`).then($=>$.ok?$.json():null).then($=>{I&&($!=null&&$.channel||$!=null&&$.video?(d({live:!0,channel:$.channel??"",video:$.video??void 0}),l==null||l(r,!1)):(f(!0),l==null||l(r,!0)))}).catch(()=>{I&&(f(!0),l==null||l(r,!0))}),()=>{I=!1});if(yi(r))return f(!0),l==null||l(r,!0),()=>{I=!1};const F=r,C=CH[F];if(C)B(C).then($=>$.ok?$.json():null).then($=>{I&&($!=null&&$.video&&d({live:!0,channel:"",video:$.video}),l==null||l(r,!($!=null&&$.video)))}).catch(()=>{I&&(l==null||l(r,!0))});else if(F!=="claude-fm"){const $=F.replace("lofi-","");B(`/api/lofi-girl?station=${encodeURIComponent($)}`).then(P=>P.ok?P.json():null).then(P=>{I&&(P!=null&&P.video&&d({live:!0,channel:"",video:P.video}),l==null||l(r,!(P!=null&&P.video)))}).catch(()=>{I&&(l==null||l(r,!0))})}else B("/api/claude-fm").then($=>$.ok?$.json():null).then($=>{if(!I)return;const P=!!($!=null&&$.live&&($!=null&&$.channel));P&&d({live:!0,channel:$.channel}),l==null||l(r,!P)}).catch(()=>{I&&(l==null||l(r,!0))});return()=>{I=!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 I=B=>{var M;if(B.origin!==Qx||B.source!==((M=b.current)==null?void 0:M.contentWindow))return;const L=SH(B.data);if(L){if(L.kind==="ready"){E(Go("setVolume",[R.current])),E(Go(n?"mute":"unMute")),E(Go("playVideo"));return}if(L.kind==="playing"){j(L.playing);return}jH.includes(L.code)&&(g(!1),j(!1),f(!0),l==null||l(r,!0))}};return window.addEventListener("message",I),()=>window.removeEventListener("message",I)},[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 I=!v;j(I),E(Go(I?"playVideo":"pauseVideo")),I||g(!1)}}}function wS(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 RH(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 C;if(document.hidden){for(const $ of((C=S.current)==null?void 0:C.getAnimations({subtree:!0}))??[])if($.playState==="running"||$.pending){const P=$.currentTime;$.pause(),P!==null&&($.currentTime=P),M.add($)}}else{for(const $ of M)$.playState==="paused"&&$.play();M.clear()}R(document.hidden)};return F(),document.addEventListener("visibilitychange",F),()=>document.removeEventListener("visibilitychange",F)},[e,t]);const[O,A]=y.useState(null),[q,I]=y.useState(jI),[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 C;const M=(C=window.matchMedia)==null?void 0:C.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=wS(document);let F=0;s(X=>F=X);let C=null,$=0,P=0;const K=X=>{var ye,se;const[ee,...ae]=X;if(!ee){C=null,d(null),f(null),J();return}d(ee.act),f(ee.prop),j(ee.place??"ledge"),b(ee.riser??0);const ue=F,ge=D(ee);if(ee.act==="kick"){const me=(se=(ye=S.current)==null?void 0:ye.querySelector('.fm-prop[data-prop="ball"]'))==null?void 0:se.getBoundingClientRect();me&&g({x:aH(me.x,Wp(ee,ue,"left"),window.innerWidth),drop:Math.max(48,window.innerHeight-me.y+24)})}P=ee.act==="walk"?Math.max(At(ue,ge),BW):ee.ms,ee.act==="carry"&&(P=At(ue,ge)),l(P),x(me=>Wp({...ee,x:ge},ue,me)),s(ge),F=ge,C=ee,$=Date.now(),M.schedule(()=>K(ae),P)},G=()=>{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 ue=X.getBoundingClientRect(),ge=ae.getBoundingClientRect(),ye=ge.right-ue.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=G();if(!X||!ee||ae==null)return;const ue=X.getBoundingClientRect().bottom-ee.getBoundingClientRect().bottom;if(ue>0)return{ledgeH:ue,floorSpan:ae}},W=()=>{const X=S.current,ee=document.querySelector(".autofit-chip");if(!X||!ee)return null;const ae=X.getBoundingClientRect(),ue=ee.getBoundingClientRect();return ue.width<=0||ue.height<=0?null:{left:ue.left-ae.right,right:ue.right-ae.right,height:ue.height}},D=X=>{const ee=(X.place??"ledge")==="floor",ae=ee?G()??Xa:Xa,ue=ee&&X.floorFrac!=null?-Math.round(X.floorFrac*ae):X.x;return Math.max(-ae,Math.min(0,ue))},H=()=>{if(!C)return;const X=D(C);X!==F&&(l(Math.max(0,$+P-Date.now())),x(ee=>Wp({...C,x:X},F,ee)),s(X),F=X)},J=()=>{M.schedule(()=>{const X=rH(F,Math.random,U()),ee=X.some(ge=>ge.place==="floor")?W():null;let ae=F;const ue=X.flatMap(ge=>{const ye=ae;if(ae=ge.x,!(ge.place==="floor"&&ge.act==="walk"))return[ge];const se=lH(ye,ge.x,ee),me=se.length-1;return ge.floorFrac==null?se:se.map((pe,de)=>de===me?{...pe,floorFrac:ge.floorFrac}:pe)});K(ue)},MW(Math.random))},V=(Y=S.current)==null?void 0:Y.parentElement,Z=typeof ResizeObserver>"u"?null:new ResizeObserver(H);return V&&Z&&Z.observe(V),J(),()=>{M.dispose(),Z==null||Z.disconnect(),j("ledge"),s(X=>Math.max(-Xa,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=wS(document),F=C=>{const $=dH(C,Math.random);A($.dance),I($.beatMs),M.schedule(()=>F($.dance),hH(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:O,beatMs:q}}const Vp={e:"fm-eye",s:"fm-shade",p:"fm-pad"},Ad=fh().filter(e=>!_I.has(e.cell)),MH=fh().filter(e=>_I.has(e.cell)),vS=Ad.filter(e=>e.cell==="e"),$H=fh(yH),IH=Ad.filter(e=>e.y<Jx&&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),OH={left:Ad.filter(e=>e.y>=Jx&&e.x<fS),right:Ad.filter(e=>e.y>=Jx&&e.x>=fS)},LH=y.memo(function({act:t,facing:n}){return a.jsxs("svg",{viewBox:`0 0 ${hS} ${fH}`,shapeRendering:"crispEdges","aria-hidden":!0,children:[a.jsx("g",{className:"fm-gear",children:a.jsx("g",{className:"fm-gear-motion",children:MH.map(r=>a.jsx("rect",{x:r.x,y:r.y,width:r.w,height:1,className:Vp[r.cell]},`g${r.y}-${r.x}`))})}),a.jsxs("g",{className:"fm-body",children:[vS.map(r=>a.jsx("rect",{x:r.x,y:r.y,width:r.w,height:1,fill:"var(--accent)"},`eye-bed-${r.x}`)),IH.map(r=>a.jsx("rect",{x:r.x,y:r.y,width:r.w,height:1,className:Vp[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"})]}),vS.map(r=>a.jsx("rect",{x:r.x-(r.x>=hS/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:$H.map(r=>a.jsx("rect",{x:wH+r.x,y:vH+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:OH[r].map(s=>a.jsx("rect",{x:s.x,y:s.y,width:s.w,height:1,className:Vp[s.cell]},`${r}${s.y}-${s.x}`))},r))]})}),PH={"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 DH(e,t){return t&&no(t.id)===e?t.name:yi(e)?"Custom FM":PH[e]}function Gp(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:fh(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 xS={litter:Gp(Hp.litter,"litter"),ball:Gp(Hp.ball,"ball"),scope:Gp(Hp.scope,"scope")};function FH(e){try{return new URL(e).host}catch{return"the station's server"}}const BH=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}=AH({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:O,facing:A,riser:q,dance:I,beatMs:B}=RH(d,h,p);if(!d||h)return null;const L=DH(s,l),M=d.audio?FH(d.audio):"YouTube";return a.jsxs("div",{ref:k,className:"fm","data-suspended":x?"":void 0,"data-place":O,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":`${bI}ms`,"--fm-ball-turn":A==="right"?"1080deg":"-1080deg"},children:xS[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":O,"data-facing":A,style:{"--fm-x":`${N}px`,"--fm-walk-ms":`${b}ms`,"--fm-riser":`${q}px`,"--fm-skip-beat":`${kI}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:xS[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??NI[0]:void 0,onClick:j,title:p?`Stop ${L}`:`Play ${L} — streams from ${M}`,"aria-label":p?`Stop ${L}`:`Play ${L}`,children:a.jsx(LH,{act:S,facing:A})})]}),f&&!d.audio&&(d.channel||d.video)&&a.jsx("iframe",{ref:g,className:"fm-frame",title:L,src:xH(d.channel,window.location.origin,d.video),onLoad:()=>v(bH()),allow:"autoplay; encrypted-media",sandbox:"allow-scripts allow-same-origin allow-presentation"})]})});function EI(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 Rd(e){return EI(Math.floor(e/1e3))}function ph(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 qH(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function Md(e,t,n){const r=new Date(e),s=Rd(t-e);return{label:qH(r,new Date(t))?s:`${s} · ${r.toLocaleDateString(n,{month:"short",day:"numeric"})}`,title:r.toLocaleString(n,{dateStyle:"medium",timeStyle:"medium"})}}function UH({data:e}){const t=Mi(3e4),n=e.note,r=n.kind==="recap",s=Md(n.at,t),o=r?"recap-note":`recap-note is-status status-${n.kind}`,l=r?void 0:dh(n);return a.jsxs("div",{className:o,role:"note","aria-label":r?"Claude Code's recap":`Session note: ${da(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(Td,{recap:r}),da(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(),Nz(e.noteKey)},children:"×"})]}),a.jsx("p",{className:"recap-note-text",title:Iz(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(Td,{recap:r}),da(n.kind)]}),a.jsx("span",{className:"recap-face-age",children:s.label})]}),a.jsx("p",{className:"recap-face-text",children:n.text})]}),a.jsx(to,{type:"source",position:Ae.Right,style:{background:"transparent",border:"none"}})]})}function zH({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:s,targetPosition:o,style:l}){const[c]=t0({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 eb(e){return e.replace(/[^a-zA-Z0-9]/g,"")}function N0(e,t){const n=eb(e);return n?n.slice(-t):e.slice(-t)}function TI(e,t,n=4){const r=eb(e);if(!r)return N0(e,n);let s=n;for(const o of t){if(o===e)continue;const l=eb(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 Ul=" · ",WH=32,HH=/[\u1100-\u115F\u2E80-\u303E\u3041-\u33FF\u3400-\u4DBF\u4E00-\u9FFF\uA000-\uA4CF\uAC00-\uD7A3\uF900-\uFAFF\uFE30-\uFE6F\uFF00-\uFF60\uFFE0-\uFFE6]/;function bS(e){return HH.test(e)?2:1}function kS(e,t=WH){const n=[...e];let r=0;for(const l of n)r+=bS(l);if(r<=t)return e;const s=[];let o=0;for(const l of n){const c=bS(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 VH(e,t,n,r,s=[],{branch:o,alarm:l=!1}={}){const c=(t==null?void 0:t.trim())??"",d=r?TI(n,s):void 0,h=[e,c||void 0,d].filter(Boolean),f=[e,o,c||void 0,d].filter(Boolean).join(Ul);return{label:kS(e),name:c?kS(c):void 0,shortId:d,fullLabel:h.join(Ul),title:`${l?"waiting on you: ":""}${f}
82
- Zoom to this session
83
- drag the wrapper to move the whole session`}}const Va=18,tb=26,j0=12,GH=240,CI=16;function AI(e,t){return(e+GH)*(t||1)}function KH(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 YH(e,t,n,r){return{position:"absolute",left:e.x+CI,top:e.y-j0/(t||1),transform:`scale(${1/(t||1)})`,transformOrigin:"left top",maxWidth:r??AI(e.w,t),"--session-hue":n}}function XH(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=ZH(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,...VH(o.label,o.name,s,c,l,{branch:o.branch,alarm:o.alarm}),x:o.minX-Va,y:o.minY-Va-tb,w:o.maxX-o.minX+Va*2,h:o.maxY-o.minY+Va*2+tb,...o.alarm?{alarm:!0}:null,...o.branch?{branch:o.branch}:null})}return r}function ZH(e){if(e.kind!=="root")return null;const t=e.branch;return{label:e.label,name:g0(e.sessionName,e.sessionTitle).face,alarm:jn(e.waiting),branch:t&&t.total>0?dI(t):void 0}}function JH(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 QH=20,hs=4,e7=64,t7=".cat-filter-bar, .react-flow__panel, .autofit-chip, .usage-panel, .sysdetail, .detail";function n7(e,t,n,r){const s=t.zoom||1,o=AI(e.w,s);if(n.width<=0||n.height<=0)return{maxWidth:o,hidden:!1};const l=(e.x+CI)*s+t.x,c=e.y*s+t.y-j0,d=c+QH;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<e7&&(f=!0),{maxWidth:Math.max(0,h),hidden:f}}function r7(e){const t=e.getBoundingClientRect(),n=[];for(const r of e.ownerDocument.querySelectorAll(t7)){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 s7(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 a7=500;function RI({focus:e,setTimeout:t,clearTimeout:n,ms:r=a7}){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 o7(e){return XH(e.nodeInternals.values())}const i7=e=>e.width,l7=e=>e.height,c7=e=>{var t;return((t=e.domNode)==null?void 0:t.querySelector(".react-flow__viewport"))??null};function u7({onFocusSession:e}){const{x:t,y:n,zoom:r}=h$(),s=Ue(o7,JH),o=Ue(i7),l=Ue(l7),c={width:o,height:l},d=y.useRef(null),h=Ue(c7),[f,p]=y.useState([]);y.useLayoutEffect(()=>{var R;const S=(R=d.current)==null?void 0:R.parentElement;if(!S)return;const E=r7(S);p(O=>s7(O,E)?O:E)});const g=y.useRef(e);g.current=e;const[v]=y.useState(()=>RI({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&&c0()?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=nc(S.sessionId),R=KH(S,E);return a.jsx("div",{className:"cluster-card",style:R,"aria-hidden":!0},S.sessionId)})}),b=h&&Dt.createPortal(a.jsx("div",{className:"cluster-labels nopan",children:s.map(S=>{const E=nc(S.sessionId),R=n7(S,{x:t,y:n,zoom:r},c,f),O=YH(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:O,title:S.title,onClick:A=>k(A,S.sessionId),children:[S.alarm?a.jsxs(a.Fragment,{children:[a.jsx(b0,{}),a.jsx("span",{className:"cluster-label-said",children:"waiting on you: "})]}):null,S.label,S.branch?a.jsx("span",{className:"cluster-label-branch",children:Ul+S.branch}):null,S.name?a.jsx("span",{className:"cluster-label-name",children:Ul+S.name}):null,S.shortId?a.jsx("span",{className:"cluster-label-id",children:Ul+S.shortId}):null]},S.sessionId)})}),h);return a.jsxs(a.Fragment,{children:[N,b]})}function d7({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 MI=600,h7=4,f7=36,nb=16,p7=60,m7=6,NS=220,g7=96,y7=28;function w7(e,t){return Math.max(g7,61+[...t].length*6.8)}function v7(e){return e.endedAt==null?"inflight":e.ok===!1?"err":"done"}function x7(e,t){if(t==null)return 1;const n=e-t;return n<0?1:Math.max(0,1-n/MI)}function b7(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 k7(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>MI)continue;const d=r.get(c.id)??n.get(c.id);if(!d)continue;const h=b7(c.tools,h7);if(h.length===0)continue;const f=c.exitAt??null,p=s.get(c.id),g=Math.max((p==null?void 0:p.width)??NS,NS),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*f7,R=j+g+p7,O=k+m7+E,A=x7(o,f),q=b.inputPreview??"",I=v7(b),B=A<.999,L=x0(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:I,category:hI(b.name),mcpHue:L.hue,inputPreview:q,fade:A,fading:B,worldX:R,worldY:O,anchorX:x,anchorY:N,spawnDx:x-R,spawnDy:N-(O+nb)});const M=gI(b.name,b.input);if(M){const F=w7(b.name,L.label),C=R+F+y7,$=O,P=R+F,K=O+nb;l.push({id:`sub:${c.id}::${b.id}`,toolId:b.id,agentId:c.id,toolName:b.name,name:lW(M.label,M.category),fullName:M.label,emoji:M.emoji,isSub:!0,status:I,category:M.category,inputPreview:M.detail??q,fade:A,fading:B,worldX:C,worldY:$,anchorX:P,anchorY:K,spawnDx:P-C,spawnDy:0})}})}return l}function N7({agents:e,visibleAgentIds:t,positions:n,pinned:r,measured:s,spotlight:o,hiddenCategories:l,now:c,onOpenTool:d}){const h=k7(e,t,n,r,s,c),f=l&&l.size>0?h.filter(p=>!l.has(p.category)):h;return a.jsx(j7,{bursts:f,spotlight:o,onOpenTool:d})}function j7({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+nb,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(E7,{b:o,dim:t!=null&&!t.has(o.agentId),onOpenTool:n},o.id));return a.jsx(S7,{connectors:r,bubbles:s})}function S7({connectors:e,bubbles:t}){const{x:n,y:r,zoom:s}=h$();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 _7(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 E7=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:"×"})]})})},_7),T7={agent:pW,sessionGroup:d7,recapNote:UH},C7={recapTie:zH},jS=400;function A7({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:O,handleRelayout:A}=t,{restoredViewport:q,onMoveStart:I,onMove:B}=n,{onNodeClick:L,onPaneClick:M,onNodeDoubleClick:F,onNodeMouseEnter:C,onNodeMouseLeave:$}=r,{onNodeDragStart:P,onNodeDrag:K,onNodeDragStop:G}=s,{palette:U,minimapNodeFill:W,characterEnabled:D}=o,{fmVolume:H,fmMuted:J,fmSource:V,fmPlayRequest:Z,customFmStations:Y,markFmStationAvailability:X}=l,{autoFitDisabled:ee,enableAutoFitAndRefit:ae}=c,{paused:ue,pauseGate:ge,togglePause:ye}=d;return a.jsxs(d$,{nodes:N,edges:b,nodeTypes:T7,edgesFocusable:!1,edgeTypes:C7,fitView:!q,fitViewOptions:{padding:.25,duration:Vx({durationMs:jS,documentHidden:document.hidden})?jS:0},minZoom:w$,maxZoom:v$,panOnScroll:!0,panActivationKeyCode:null,nodesDraggable:!0,nodesConnectable:!1,selectionOnDrag:!1,nodeDragThreshold:5,disableKeyboardA11y:!0,deleteKeyCode:null,onNodeClick:L,onPaneClick:M,onNodeDoubleClick:F,onNodeMouseEnter:C,onNodeMouseLeave:$,onMoveStart:I,onMove:B,onNodeDragStart:P,onNodeDrag:K,onNodeDragStop:G,children:[a.jsx(G8,{gap:28,size:1,color:U["--grid-line"]}),a.jsx(u7,{onFocusSession:j}),a.jsx(N7,{agents:h.current.agents,visibleAgentIds:S,positions:R.current,pinned:O.current,measured:f.current,spotlight:E,hiddenCategories:p,now:g,onOpenTool:v}),ee&&a.jsx(xW,{enableAutoFitAndRefit:ae}),a.jsx(CW,{autoFitDisabled:ee,enableAutoFitAndRefit:ae,paused:ue,pauseGate:ge,togglePause:ye,handleRelayout:A,requestClear:k,setKeyHelpOpen:x}),a.jsx(I8,{zoomable:!0,pannable:!0,nodeColor:W,nodeStrokeWidth:2,maskColor:U["--minimap-mask"],maskStrokeColor:U["--line"]}),D&&a.jsx(BH,{volume:H,muted:J,source:V,playRequest:Z,customStation:Y.find(se=>no(se.id)===V),onAvailabilityChange:X})]})}function R7(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=pn(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 M7="spend on this board",$7="on this board",SS=`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.`,$I="session spend",rb="__unknown__",I7=12;function O7(e,t=Date.now()){const n=new Map;for(const r of e)for(const s of xc(r)){const o=s.model??rb,l=ah(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:ma(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 L7(e,t=Date.now()){const n=[...e],r=[];for(const s of n){if(s.kind!=="root")continue;let o=pn(s,t).total,l=s.usage.inputTokens,c=s.usage.outputTokens,d=rc(s,t);for(const h of n)h.sessionId!==s.sessionId||h.kind==="root"||(o+=pn(h,t).total,l+=h.usage.inputTokens,c+=h.usage.outputTokens,d+=rc(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,I7)}const P7=600;function mh(e,t){return!(e.exitAt!=null&&t-e.exitAt>P7||e.kind==="root"&&e.state==="done"&&e.tools.length===0&&e.endedAt!=null&&e.endedAt-e.startedAt<3e3)}function D7(e,t){const n=new Set;for(const r of e.agents.values())mh(r,t)&&n.add(r.id);return n}function F7(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 B7(e,t,n=0){if(!e)return!1;for(const r of t)if(F7(e,r,n))return!0;return!1}function _S(e){return e.waiting?jn(e.waiting)?0:1:e.state==="active"?2:3}function q7(e,t){const n=[];for(const r of e.agents.values()){if(r.kind!=="root")continue;let s=r.toolCount,o=pn(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+=pn(f).total;const p=f.endedAt??f.startedAt;p>l&&(l=p)}const c=uh(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=_S(r),l=_S(s);return o!==l?o-l:r.waiting&&s.waiting?r.waiting.since-s.waiting.since:s.lastActivity-r.lastActivity}),n}function U7(e){return[e.text,e.reply?`Suggested reply: ${e.reply}`:"",dh(e)].filter(Boolean).join(`
86
- `)}function ES(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 z7({state:e,now:t,selectedIds:n,onSelect:r,onClose:s,removedIds:o,onBringBackAll:l}){const c=y.useMemo(()=>q7(e),[e,e.revision,t]),d=c.filter(f=>f.state==="active").length,h=c.filter(f=>jn(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:vi(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":ih(f.modelId),title:f.modelId,children:Ns(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:$I,children:a.jsx("b",{children:qe(f.cost)})}),f.waiting?a.jsxs("span",{className:"sl-waiting",title:[xi(f.waiting),zU(f.waiting,xi(f.waiting)),`${jn(f.waiting)?"Blocked":"Your turn"} since ${new Date(f.waiting.since).toLocaleTimeString()} · started ${new Date(f.startedAt).toLocaleString()}`].filter(Boolean).join(`
87
- `),children:[jn(f.waiting)?"waiting":"your turn"," ",ES(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:ES(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(wI,{}),f.recap.text]}),f.status&&a.jsxs("span",{className:`sl-status status-${f.status.kind}`,title:U7(f.status),children:[a.jsx("span",{className:"sl-status-tag",children:da(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&&mh(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 sb={cost:0,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0,sessions:0};function W7(e){if(!e.synthetic)return!1;const t=e.usage;return t.inputTokens+t.outputTokens+t.cacheReadTokens+t.cacheCreateTokens<=0}function ab(e,t){const n=new Map;for(const r of e){if(r.kind!=="root"||!r.sessionId||W7(r))continue;const s=pn(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 H7(e,t){if(!e)return sb;const n={...sb};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 ob(e,t=new Date){return new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate()-(e-1))).toISOString().slice(0,10).replace(/-/g,"")}const gh=[{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 V7(e,t,n=gh.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 II(e,t=new Date){return e==="today"?ob(1,t):e==="month"?ob(t.getDate(),t):"20200101"}const dn=e=>typeof e=="number"&&Number.isFinite(e)?e:0,cd=e=>typeof e=="string"?e:"";function OI(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=cd(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+=dn(o==null?void 0:o.cost),c.inputTokens+=dn(o==null?void 0:o.inputTokens),c.outputTokens+=dn(o==null?void 0:o.outputTokens),c.cacheReadTokens+=dn(o==null?void 0:o.cacheReadTokens),c.cacheCreateTokens+=dn(o==null?void 0:o.cacheCreationTokens)}}return[...n.values()].sort((r,s)=>s.cost-r.cost||s.tokens-r.tokens)}const G7=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function K7(e){var t;return((t=G7.exec(e))==null?void 0:t[0])??e}function Y7(e,t=new Map){const n=Array.isArray(e==null?void 0:e.sessions)?e.sessions:[],r=[];for(const s of n){const o=cd(s==null?void 0:s.period);if(!o)continue;const l=K7(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:cd(s==null?void 0:s.agent)||"claude",cost:dn(s==null?void 0:s.totalCost),tokens:dn(s==null?void 0:s.totalTokens),models:Array.isArray(s==null?void 0:s.modelsUsed)?s.modelsUsed.map(cd).filter(Boolean):[],lastActivityMs:Number.isFinite(d)?d:null})}return r.sort((s,o)=>o.cost-s.cost||o.tokens-s.tokens)}function X7(e,t=yh(e).cost){const r=(Array.isArray(e==null?void 0:e.sessions)?e.sessions:[]).reduce((o,l)=>o+dn(l==null?void 0:l.totalCost),0),s=Math.max(.01,t*.01);return{sum:r,total:t,over:r>t+s}}function Z7(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 yh(e){const t=e==null?void 0:e.totals;if(t&&typeof t=="object"){const d=dn(t.cacheReadTokens),h=dn(t.cacheCreationTokens),f=dn(t.inputTokens),p=dn(t.outputTokens);return{cost:dn(t.totalCost),inputTokens:f,outputTokens:p,cacheReadTokens:d,cacheCreateTokens:h,tokens:dn(t.totalTokens)||f+p+d+h}}const n=OI(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 J7(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 LI(e,t){var n;return((n=gh.find(r=>r.key===(e??t)))==null?void 0:n.noun)??"today"}function Q7(e,t,n){const r=e!=null,s=yh(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 PI="agent-dag.usagePeriod";function e9(){const e=Je(PI);return gh.some(t=>t.key===e)?e:"today"}function t9(e){Ke(PI,e)}const DI="agent-dag.usageSessionsOpen";function n9(){return Je(DI)==="1"}function r9(e){Ke(DI,e?"1":"0")}function S0({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}: ${qe(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 Uu="https://ccdeck.dev/guides",s9={localNetwork:{href:`${Uu}/local-network/#film`,subject:"Local network"},claudeAccounts:{href:`${Uu}/claude-accounts/#film`,subject:"Claude accounts"},usage:{href:`${Uu}/cost-and-quota/#film`,subject:"cost and quota"},tour:{href:`${Uu}/first-run/#film`,subject:"first run"}};function sc({film:e}){const{href:t,subject:n}=s9[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 Nt="ccdeck",a9="/brand/ccdeck-mark-gradient-small-optical.svg",o9="/brand/ccdeck-mark-mono-dark-small-optical.svg";function FI(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 i9({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 BI({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 l9(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 ia({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?ph(r,l):null,x=d&&r&&s?l9(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 qI(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 c9(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 u9(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 d9(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 h9({quota:e,quotaLoading:t,nowSec:n,incident:r}){const s=qI(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:c9(e==null?void 0:e.source),children:[s,(e==null?void 0:e.stale)&&" · no newer reading"]})]}),a.jsx(BI,{incident:r}),e!=null&&e.ok?a.jsxs("div",{className:"up-quota-bars",children:[e.session5hPct!=null&&a.jsx(ia,{label:"5-hour window",pct:e.session5hPct,reset:e.session5hReset,resetAt:e.session5hResetAt,windowSec:e.session5hWindowSec,nowSec:n}),a.jsx(ia,{label:"7-day window",pct:e.week7dPct??null,reset:e.week7dReset,resetAt:e.week7dResetAt,windowSec:e.week7dWindowSec,nowSec:n}),e.weekSonnetPct!=null&&a.jsx(ia,{label:"Sonnet (7d)",pct:e.weekSonnetPct,nowSec:n}),e.weekOpusPct!=null&&a.jsx(ia,{label:"Opus (7d)",pct:e.weekOpusPct,nowSec:n}),e.extraEnabled&&e.extraUsedCredits!=null&&e.extraMonthlyLimit?a.jsx(ia,{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 — ${Nt} only reports them`,children:FI("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:u9(e.reason)})]}):a.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]})}function f9({codexQuota:e,codexLoading:t,codexUsage:n,nowSec:r,incident:s}){var l,c;const o=qI(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(BI,{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(ia,{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(ia,{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(ia,{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 — ${Nt} only reports them`,children:FI("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:d9(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: ${rt(n.window5h.totalTokens)} tokens · ${n.window5h.sessionCount} session${n.window5h.sessionCount!==1?"s":""}`:""}`,children:[rt(n.window7d.totalTokens)," tokens · ",n.window7d.sessionCount," session",n.window7d.sessionCount!==1?"s":""," (7d)"]})]})}function p9({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:Ns(r.model)}),a.jsx("td",{className:"up-num",children:rt(r.tokens)}),r.cost>0?a.jsx("td",{className:"up-num up-cost-val",children:qe(r.cost)}):a.jsx("td",{className:"up-num up-unpriced",children:ks})]},r.model)):n.map(r=>a.jsxs("tr",{children:[a.jsx("td",{className:"up-model-name",title:r.model===rb?"no model reported yet":r.model,children:r.model===rb?"unknown":Ns(r.model)}),a.jsx("td",{className:"up-num",children:rt(r.inputTokens+r.outputTokens)}),r.priced?a.jsx("td",{className:"up-num up-cost-val",children:qe(r.cost.total)}):a.jsx("td",{className:"up-num up-unpriced",children:ks})]},r.model))})]})]})}function m9({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=V7(s.key,o);l!==null&&(s.preventDefault(),(c=r.current[l])==null||c.focus())},children:gh.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 ${LI(e,e)}…`:""})]})}function g9({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:Z7(l,c,qe),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:vi(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??N0(h.sessionId,8)}),a.jsx("span",{className:"up-session-tokens",children:rt(h.tokens)}),h.cost>0?a.jsx("span",{className:"up-session-cost",title:h.models.join(", ")||void 0,children:qe(h.cost)}):a.jsx("span",{className:"up-session-cost up-unpriced",children:ks})]},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:vi(h.state)}),a.jsx("span",{className:"up-session-label",children:h.label}),a.jsx("span",{className:"up-session-tokens",children:rt(h.inputTokens+h.outputTokens)}),h.cost>0?a.jsxs("span",{className:"up-session-cost",title:h.unpricedTokens>0?`${rt(h.unpricedTokens)} tokens in this session are on an unpriced model, so this is a floor`:void 0,children:[qe(h.cost),h.unpricedTokens>0?"+":""]}):a.jsx("span",{className:"up-session-cost up-unpriced",children:ks})]},h.sessionId))]})]})}function fa(e,t){return{disabled:e!=null&&e!==t,busy:e===t}}function wh(e){return e==null}const ib="self";function vs(e,t=!1){const n=fa(e?ib:null,ib);return{disabled:t||n.disabled,"aria-busy":n.busy}}function pr(e){return wh(e?ib:null)}const so=400;function ao({armedFor:e,target:t,armedAt:n,now:r,gapMs:s}){return e!==t?"arm":r-n<s?"ignore":"fire"}function UI(e){return[...e==null?[]:[`#ap-more-${e}`],".accounts-panel .ap-refresh"]}function En(e){return e==null||e==="BODY"||e==="HTML"}const y9=6e4,w9=2e4;function v9(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&&!pr(l.current))){h&&(l.current=!0,s(!0));try{const p=await fetch(h?"/api/quota?refresh=1":"/api/quota",{signal:AbortSignal.timeout(w9)});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),y9),()=>{o.current!=null&&window.clearInterval(o.current)}},[e]),{quota:t,loading:r,refresh:()=>{e&&c(!0)}}}const zI=6e4;function x9(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&&!pr(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),zI),()=>{o.current!=null&&window.clearInterval(o.current)}},[e]),{data:t,loading:r,refresh:()=>{e&&c(!0)}}}function b9(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,zI),()=>{r.current!=null&&window.clearInterval(r.current)}},[e]),{data:t}}const TS=6e4;function k9(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,TS),j=()=>{p()&&Date.now()-h.current>=TS&&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=II(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]),{...J7(r,e),loading:o}}const N9=e=>1-Math.pow(1-e,5),WI=420;function j9(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 S9(e,t,n,r=WI){return n>=r?t:n<=0?e:e+(t-e)*N9(n/r)}function HI(){return typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches}function CS(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??HI,d=r.hidden??(()=>typeof document=="object"&&document.hidden===!0);if(c()||d()||!j9(e,t))return n(t),()=>{};const h=s();let f=0,p=!0;const g=()=>{if(!p)return;const v=s()-h;n(S9(e,t,v)),v<WI&&(f=o(g))};return f=o(g),()=>{p=!1,f&&l(f)}}const _9=typeof window>"u"?y.useEffect:y.useLayoutEffect;function Ua(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]),_9(()=>{!t||HI()||(s.current=0,r(0))},[]),y.useEffect(()=>{if(o.current){if(o.current=!1,t)return CS(0,e,c=>{s.current=c,r(c)});s.current=e,r(e);return}return CS(s.current,e,c=>{s.current=c,r(c)})},[e]),n}function VI(e,t,n){const r=T9*Math.max(1,n/KI);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 AS={samples:[],last:new Map,watched:0},GI=10*6e4,E9=6e4,KI=5e3,T9=20;function C9(e,t,n){const r=e.samples[e.samples.length-1];if(r&&t-r.t<KI)return e;const s=e.watched+VI(e.last,n,r?t-r.t:0),o=e.samples.filter(l=>t-l.t<=GI);return o.push({t,watched:s}),{samples:o,last:n,watched:s}}function A9(e,t,n){const r=e.samples[0];if(!r)return null;const s=t-r.t;if(s<E9)return null;const o=e.samples[e.samples.length-1].t,l=e.watched+VI(e.last,n,t-o)-r.watched;return l>0?{spent:l,spanSec:s/1e3,spanMin:Math.min(GI/6e4,Math.ceil(s/6e4))}:null}function R9(e,t,n){const r=y.useRef(AS),s=y.useRef(null);return y.useMemo(()=>{const o=O7(e.agents.values()),l=R7(e.agents.values());s.current!==n&&(s.current=n,r.current=AS);const c=ab(e.agents.values(),t);n!=null&&(r.current=C9(r.current,t,c));const d=n==null?null:A9(r.current,t,c),h=d?{label:p0(d.spent,d.spanSec),spanMin:d.spanMin}:null;return{byModel:o,totalCost:l.cost,totalTokens:l,burnRate:h}},[e,e.revision,t,n])}const M9=3e4;function YI(){const[e,t]=y.useState(()=>Math.floor(Date.now()/1e3));return y.useEffect(()=>{const n=window.setInterval(()=>t(Math.floor(Date.now()/1e3)),M9);return()=>window.clearInterval(n)},[]),e}function RS(e){return(typeof e.cost=="number"?e.cost:e.cost.total)>0||e.inputTokens+e.outputTokens>0}function $9(e,t,n){return e?t.some(r=>r.cost<=0&&r.tokens>0):n.some(r=>!r.priced)}function I9(e){return e.claude&&e.codex?"Refresh Claude + Codex quota":e.codex?"Refresh Codex quota":"Refresh Claude quota"}function O9(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 L9(e){const t=new Map;for(const n of e)n.kind!=="root"||!n.sessionId||t.set(n.sessionId,n.state);return t}function P9(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} ${TI(n.sessionId,r)}`}:n})}function D9({state:e,now:t,providers:n,incidents:r=[],leaving:s,onClose:o,liveSince:l=null}){const{quota:c,loading:d,refresh:h}=v9(n.claude),{data:f,loading:p,refresh:g}=x9(n.codex),{data:v}=b9(n.codex),j=YI(),{byModel:k,totalCost:x,totalTokens:N,burnRate:b}=R9(e,t,l),S=y.useMemo(()=>L7(e.agents.values()),[e,e.revision]),[E,R]=y.useState(e9);y.useEffect(()=>{t9(E)},[E]);const[O,A]=y.useState(n9);y.useEffect(()=>{r9(O)},[O]);const[q,I]=y.useState(0),B=y.useRef(()=>new Map);B.current=()=>l==null?null:ab(e.agents.values(),t);const L=y.useCallback(()=>B.current(),[]),{data:M,shown:F,stale:C,loading:$,baseline:P}=k9(E,q,L),K=M!=null,G=$&&C,U=y.useMemo(()=>O9(e.agents.values()),[e,e.revision]),W=y.useMemo(()=>L9(e.agents.values()),[e,e.revision]),D=y.useMemo(()=>K?OI(M):[],[M,K]),H=y.useMemo(()=>K?P9(Y7(M,U).slice(0,12)):[],[M,K,U]),J=y.useMemo(()=>yh(M),[M]),V=y.useMemo(()=>X7(M,J.cost),[M,J.cost]),Z=LI(F,E),Y=y.useMemo(()=>K?H7(P,ab(e.agents.values(),t)):sb,[e,e.revision,P,K,t]),X=Q7(M,{...N,cost:x},Y),ee=X.hasCost,ae=X.tokenSum,ue=Ua(X.cost),ge=Ua(X.inputTokens),ye=Ua(X.outputTokens),se=Ua(X.cacheReadTokens),me=Ua(X.cacheCreateTokens),pe=k.filter(RS),de=S.filter(RS),fe=$9(K,D,pe),ne=d||p,oe=()=>{h(),g(),I(we=>we+1)},Ne=I9(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,...vs(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(h9,{quota:c,quotaLoading:d,nowSec:j,incident:r.find(we=>we.provider==="claude")}),n.codex&&a.jsx(f9,{codexQuota:f,codexLoading:p,codexUsage:v,nowSec:j,incident:r.find(we=>we.provider==="codex")}),K&&a.jsx(m9,{period:E,rangePending:G,setPeriod:R}),ae>0?a.jsxs(a.Fragment,{children:[ee&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"up-total",title:K?void 0:SS,children:[a.jsx("span",{className:"up-total-value",children:qe(ue)}),a.jsx("span",{className:"up-total-label",children:K?Z:M7})]}),X.showCostBar&&a.jsx(S0,{cost:x})]}),a.jsxs("div",{className:"up-tokens-row",title:K?void 0:SS,children:[a.jsxs("span",{className:"up-tok",children:[a.jsx("span",{className:"up-k",children:"in"}),rt(ge)]}),a.jsxs("span",{className:"up-tok",children:[a.jsx("span",{className:"up-k",children:"out"}),rt(ye)]}),X.cacheReadTokens>0&&a.jsxs("span",{className:"up-tok",children:[a.jsx("span",{className:"up-k",children:"cache r"}),rt(se)]}),X.cacheCreateTokens>0&&a.jsxs("span",{className:"up-tok",children:[a.jsx("span",{className:"up-k",children:"cache c"}),rt(me)]}),!ee&&a.jsx("span",{className:"up-tok up-scope",children:$7})]}),(K?D.length:pe.length)>0&&a.jsx(p9,{fromRange:K,rangeModelRows:D,boardModelRows:pe}),K&&H.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."]})]}),(K?H.length:de.length)>0&&a.jsx(g9,{fromRange:K,rangeSessionRows:H,boardSessionRows:de,boardStates:W,sessionsOpen:O,setSessionsOpen:A,periodNoun:Z,sessionScale:V}),fe&&a.jsxs("div",{className:"up-hint",children:["“",ks,"” 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:K?(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(sc,{film:"usage"})})]})}function Kp(e){return e<9.95?e.toFixed(1):String(Math.round(e))}function _0(e){const t=Number.isFinite(e)?Math.max(0,e):0;return t<50?{value:"0",unit:"KB/s"}:t<999500?{value:Kp(t/1e3),unit:"KB/s"}:t<9995e5?{value:Kp(t/1e6),unit:"MB/s"}:{value:Kp(t/1e9),unit:"GB/s"}}function vh(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 ac(e){return e.unit?e.unit==="%"||e.unit==="°C"?`${e.value}${e.unit}`:`${e.value} ${e.unit}`:e.value}const F9="thermal:Throttling";function E0(e){const t="timeHeld"in e?e.timeHeld:100-e.speedLimit;return Math.max(0,Math.min(100,t))}function B9(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[F9]=E0(e.thermal.throttle)),t}function zl(e,t){return t==="B/s"?ac(_0(e)):t==="ms"?ac(vh(e)):t==="C"?`${Math.round(e)}°`:t==="%"?`${Math.round(e)}%`:e.toFixed(2)}function zu(e,t){return t==="B/s"||t==="ms"||!Number.isInteger(e)?zl(e,t):t==="C"?`${e}°`:t==="%"?`${e}%`:`${e}`}function q9(e,t,n){return e>=n?"hot":e>=t?"warn":"calm"}function U9(e,t,n=Date.now()){const r=E0(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 ${MS(t.lastMs,n)}`:`at full speed · held to ${100-t.peak}% ${MS(t.lastMs,n)}`:"running at full speed, and never held back"}}function MS(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 z9(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 W9(e){var r,s;const t=(r=e.thermal)==null?void 0:r.throttle,n=t?E0(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 H9(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 V9=3e3;function G9(){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,V9))},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 K9(e,t){return!e||e.key!==t?"none":e.dir==="asc"?"ascending":"descending"}function $l({col:e,label:t,note:n,sort:r,next:s,onSort:o,className:l}){const c=K9(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 Yp(e,t){return t==="B/s"?_0(e):t==="ms"?vh(e):{value:String(e),unit:t==="C"?"°C":t}}const Tt={l:30,r:6,t:6,b:2},na={l:0,r:0,t:2,b:1},xh=104,Y9=64;function fr(e,t=100,n=xh,r=Tt){const s=n-r.t-r.b;return r.t+s*(1-Math.max(0,Math.min(t,e))/t)}function XI(e,t){return t??[e[0].t,e[e.length-1].t]}function T0(e,[t,n],r,s=Tt){const o=r-s.l-s.r,l=n-t;return s.l+(l>0?o*(e-t)/l:o/2)}function ZI(e,t,n,r=100,s=xh,o=Tt,l){if(!e.length)return"";const c=XI(e,l),d=p=>T0(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)} ${fr(p.v,r,s,o).toFixed(1)}`,f=p}return h}function JI(e,t,n,r=100,s=xh,o=Tt,l){if(e.length<2)return"";const c=s-o.b,d=XI(e,l),h=v=>T0(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)} ${fr(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 X9(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 QI(e,t,n){return n!=null&&e>=n?"hot":t!=null&&e>=t?"warn":""}function Z9(e,t,n=r=>za(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 za(e){const t=new Date(e);return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}function C0(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 J9({group:e,title:t,onClose:n}){const r=dt(n),s=gt(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 Dt.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 ",za(d)," · ",C0(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(Q9,{series:p,stepMs:o.stepMs,domain:f},p.label))})]})}),document.body)}function Q9({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?Y9:xh,{now:N,peak:b}=X9(d),S=N!=null?Yp(N,h):null,E=b!=null?Yp(b,h):null,R=g==="Throttling"?Z9(d,t):null,O=l!=null?d[l]:null,[A,q]=n??(d.length?[d[0].t,d[d.length-1].t]:[0,0]),I=L=>T0(L,[A,q],s),B=L=>{if(d.length<2)return;const M=L.currentTarget.getBoundingClientRect(),F=(L.clientX-M.left-Tt.l)/Math.max(1,M.width-Tt.l-Tt.r),C=A+(q-A)*Math.max(0,Math.min(1,F));let $=0;for(let P=1;P<d.length;P++)Math.abs(d[P].t-C)<Math.abs(d[$].t-C)&&($=P);c($)};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:QI(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}: ${ac(S)} now, peak ${ac(E)}, over ${C0(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:Tt.l,x2:s-Tt.r,y1:fr(M,v,x),y2:fr(M,v,x)}),a.jsx("text",{className:`hist-rule-tag ${L}`,x:2,y:fr(M,v,x)+3,children:M})]},L)),a.jsx("line",{className:"hist-floor",x1:Tt.l,x2:s-Tt.r,y1:x-Tt.b,y2:x-Tt.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:I(L.t),x2:I(L.t),y1:Tt.t,y2:x-Tt.b},L.t)),a.jsx("path",{className:"hist-area",d:JI(d,s,t,v,x,Tt,[A,q])}),a.jsx("path",{className:"hist-line",d:ZI(d,s,t,v,x,Tt,[A,q])}),d.length===1&&a.jsx("circle",{className:"hist-dot",cx:I(d[0].t),cy:fr(d[0].v,v,x),r:3}),O&&a.jsxs("g",{children:[a.jsx("line",{className:"hist-cross",x1:I(O.t),x2:I(O.t),y1:Tt.t,y2:x-Tt.b}),a.jsx("circle",{className:"hist-dot",cx:I(O.t),cy:fr(O.v,v,x),r:3})]})]})}),a.jsx("div",{className:"hist-axis",children:O?a.jsxs("span",{className:"hist-at",children:[za(O.t)," — ",(()=>{const L=Yp(O.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?za(A):""}),a.jsx("span",{children:d.length?za(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 ${za(L.t)} — ${L.label}`:`${za(L.t)} — ${L.label.charAt(0).toUpperCase()+L.label.slice(1)}`},L.t))]})}const $S=["cores","memory","load","thermal"],Da=116,Pr=24,eV=60,tV=6e4;function nV(e){return e.points.length?e.restsAtZero?e.points.some(t=>t.v>0):!0:!1}function rV(e){return e.unit==="C"?`${e.label} temp`:e.key==="mem:physical"?"Physical RAM":e.key==="mem:swap"?`${e.label} memory`:e.label}function sV(e,t=eV){return e.points.length<=t?e:{...e,points:e.points.slice(-t)}}function aV({sys:e}){const[t,n]=y.useState({});y.useEffect(()=>{let l=!0;const c=async()=>{const h=await Promise.all($S.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(),tV);return()=>{l=!1,clearInterval(d)}},[]);const r=y.useMemo(()=>B9(e),[e]),s=y.useMemo(()=>$S.flatMap(l=>{const c=t[l];return c?c.series.filter(nV).map(d=>({series:sV(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)?C0(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(oV,{series:l,stepMs:c,now:r[l.key],span:o},l.key))}):null}function oV({series:e,stepMs:t,now:n,span:r}){var v;const{points:s,top:o,unit:l,warnAt:c,critAt:d}=e,h=rV(e),f=n??((v=s[s.length-1])==null?void 0:v.v),p=f==null?"":QI(f,c,d),g=Math.max(...s.map(j=>j.v));return a.jsxs("div",{className:`pl-cell${p?` ${p}`:""}`,title:[`${h} · peak ${zl(g,l)} over the last ${r}`,c!=null?`over ${zu(c,l)} is uncomfortable`:"",d!=null?`over ${zu(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?"—":zl(f,l)})]}),a.jsxs("svg",{className:"pl-spark",width:Da,height:Pr,viewBox:`0 0 ${Da} ${Pr}`,preserveAspectRatio:"none","aria-hidden":!0,children:[a.jsx("line",{className:"pl-spark-floor",x1:0,x2:Da,y1:Pr-na.b,y2:Pr-na.b}),a.jsx("path",{className:"pl-spark-area",d:JI(s,Da,t,o,Pr,na)}),c!=null&&a.jsx("line",{className:"pl-rule warn",x1:0,x2:Da,y1:fr(c,o,Pr,na),y2:fr(c,o,Pr,na)}),d!=null&&a.jsx("line",{className:"pl-rule hot",x1:0,x2:Da,y1:fr(d,o,Pr,na),y2:fr(d,o,Pr,na)}),a.jsx("path",{className:"pl-spark-line",d:ZI(s,Da,t,o,Pr,na)})]}),a.jsxs("span",{className:"vis-hidden",children:["peak ",zl(g,l)," over the last ",r,c!=null&&`, uncomfortable over ${zu(c,l)}`,d!=null&&`, the machine acts over ${zu(d,l)}`]})]})}const eO={key:"cpu",dir:"desc"};function iV(e,t){return e.key===t?{...e,dir:e.dir==="asc"?"desc":"asc"}:{key:t,dir:t==="name"||t==="user"?"asc":"desc"}}function lV(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 cV=4e3;function uV(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 dV(){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=>uV(c,l))}catch{}};r();const s=window.setInterval(r,cV);return()=>{n=!1,window.clearInterval(s)}},[]),e}function hV(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 fV({sys:e,onClose:t}){Ut("process-list");const n=dt(t),r=gt(t),[s,o]=y.useState(eO),l=dV();return Dt.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(pV,{read:l,sort:s,onSort:o,sys:e,onClose:t})})}),document.body)}function pV({read:e,sort:t,onSort:n,sys:r,onClose:s}){const o=e?lV(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(Ko,{col:"cpu",label:"cpu",sort:t,onSort:n}),a.jsx(Ko,{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(Ko,{col:"threads",label:"threads",sort:t,onSort:n}),a.jsx(Ko,{col:"uptime",label:"up",sort:t,onSort:n}),a.jsx(Ko,{col:"user",label:"user",sort:t,onSort:n}),a.jsx("th",{scope:"col",className:"pl-pid-h",children:"pid"}),a.jsx(Ko,{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:oa(l.rssBytes)}),a.jsx("td",{className:"sd-num sd-dim",children:l.threads??"—"}),a.jsx("td",{className:"sd-num sd-dim",children:hV(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(aV,{sys:r})]})]})}function Ko(e){return a.jsx($l,{...e,next:(t,n)=>iV(t??eO,n)})}function lb({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 mV=300;function oc({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))},mV))};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(J9,{group:e,title:t,onClose:()=>d(!1)})]})}function $d({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 gV(e,t,n){if(n<=0||ch(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 ca=4,qn=8;function A0(e,t,n){const r=n.width-qn-(e.right+ca),s=e.left-ca-qn,o=t.width<=r||r>=s?"right":"left",l=o==="right"?e.right+ca:e.left-ca-t.width,c=n.height-qn*2,d=t.height<=c,h=d?t.height:Math.max(0,c),f=Math.max(qn,Math.min(e.top,n.height-qn-h)),p=Math.max(qn,Math.min(l,n.width-qn-t.width));return{top:f,left:p,side:o,maxHeight:d?null:h}}function yV(e,t,n){const r=n.height-qn-(e.bottom+ca),s=e.top-ca-qn,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+ca:e.top-ca-d,f=Math.max(qn,Math.min(e.right-t.width,n.width-qn-t.width));return{top:Math.max(qn,h),left:f,side:o,maxHeight:c?null:d}}function wV(e,t,n){return!(!e||t!=null&&t.contains(e)||n!=null&&n.contains(e))}function vV(e,t,n){const r=y.useRef(t);r.current=t;const s=y.useRef(n);s.current=n,y.useEffect(()=>{const o=l=>{wV(l.target,e.current,r.current())&&s.current()};return window.addEventListener("pointerdown",o,!0),()=>window.removeEventListener("pointerdown",o,!0)},[e])}const tO='[role="menuitem"]';function IS(e){return e?Array.from(e.querySelectorAll(tO)).filter(t=>!t.disabled):[]}function bh({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=dt(()=>{var b;(b=document.getElementById(e))==null||b.focus(),p.current()},{popover:!0,focusRef:c}),j=y.useCallback(()=>{var A,q,I;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?(I=document.getElementById(t))==null?void 0:I.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 O=yV(E,{width:b.offsetWidth,height:b.offsetHeight},{width:window.innerWidth,height:window.innerHeight});b.style.top=`${O.top}px`,b.style.left=`${O.left}px`,b.style.maxHeight=O.maxHeight==null?"":`${O.maxHeight}px`,b.dataset.side=O.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]),vV(v,()=>document.getElementById(e),h),y.useEffect(()=>{var S;if(s!=="menu")return;const b=IS(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=IS(v.current),R=gV(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(tO);S&&!S.disabled&&document.activeElement!==S&&S.focus({preventScroll:!0})};return Dt.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 xV({network:e}){const{down:t,up:n,api:r,route:s}=e,[o,l]=y.useState(!1),c=r&&r.ms!=null?vh(r.ms):null,d=t!=null&&n!=null;return a.jsxs("div",{className:"sd-section",role:"group","aria-label":"Network",children:[a.jsxs(oc,{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=_0(f);return a.jsx(lb,{value:p.value,unit:p.unit,cap:h},h)}),c&&a.jsx(lb,{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(bV,{route:s,api:r,onClose:()=>l(!1)})]})]})}function bV({route:e,api:t,onClose:n}){return a.jsxs(bh,{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 ",H9(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`:`${ac(vh(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 OS({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 kV({usageOpen:e,leaving:t,onClose:n}){const r=G9();if(!r||r.cpu==null||!r.memory)return a.jsx(OS,{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(OS,{usageOpen:e,leaving:t,sub:`up ${z9(h)} · ${d} cores`,flag:W9(r),onClose:n,children:[a.jsx(NV,{cpu:v,perCore:l,loadavg:c,cores:d}),a.jsx(jV,{memory:s,swap:o,platform:f}),g&&a.jsx(xV,{network:g}),a.jsx(SV,{thermal:p}),a.jsx(_V,{sys:r})]})}function NV({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(oc,{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(oc,{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(lb,{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 jV({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(oc,{group:"memory",title:"Memory history",action:"Show memory history",label:"Memory",children:[a.jsx($d,{label:"Physical",value:a.jsxs(a.Fragment,{children:[a.jsx("b",{children:oa(r)})," of ",oa(e.total)]}),pct:e.usedPct,tone:e.usedPct>=90?"warn":"calm",note:`${oa(e.available)} available`}),t&&t.total>0&&a.jsx($d,{label:s,value:a.jsxs(a.Fragment,{children:[a.jsx("b",{children:oa(t.used)})," of ",oa(t.total)]}),pct:o,tone:o>=90?"warn":"calm"})]})})}function SV({thermal:e}){if(!e)return null;const t=e.throttle?U9(e.throttle,e.heldBack):null;return a.jsx("div",{className:"sd-section",role:"group","aria-label":"Thermal",children:a.jsxs(oc,{group:"thermal",title:"Thermal history",action:"Show thermal history",label:"Thermal",children:[e.celsius.map(n=>a.jsx($d,{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:q9(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($d,{label:"Throttling",value:a.jsx("b",{children:t.value}),pct:t.pct,tone:t.tone,note:t.note})]})})}function _V({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(fV,{sys:e,onClose:()=>n(!1)})]})}function R0(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,R0(s)]))),t}function LS(e){const t=r=>({...r,cacheCreate1hTokens:0,cacheCreate5mTokens:0}),n=t(R0(e));return n.bySpeed&&(n.bySpeed=Object.fromEntries(Object.entries(n.bySpeed).map(([r,s])=>[r,t(s)]))),n}function nO(e){return e.i+e.o+e.cr+e.cc}function rO(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??{}))rO((n=e.s??(e.s={}))[r]??(n[r]={i:0,o:0,cr:0,cc:0,c1h:0,c5m:0}),s);return e}function PS(e,t,n){let r=0,s=0,o=0;const l=[];for(const c of oh(e)){if(!ma(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+=_d(c.usage,t,c.speed,n).total,s+=_d(c.usage,t,ha,n).total}return{atSpeed:r,atStandard:s,unpriced:o,unpricedSpeeds:l}}function DS(e){let t=0;for(const n of Object.values(e))t+=nO(n);return t}function EV(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 TV(e,t,n,r=Date.now()){const s=new Map;for(const A of e){const q={},I=B=>{for(const[L,M]of Object.entries(B))rO(q[L]??(q[L]={i:0,o:0,cr:0,cc:0,c1h:0,c5m:0}),M)};for(const B of A.projects)I(B.models);A.unattributed&&I(A.unattributed);for(const[B,L]of Object.entries(q)){if(!L.s)continue;const{atSpeed:M,atStandard:F}=PS(LS(L),B,r);if(!(M>0&&F>0))continue;let C=s.get(A.day);C||(C=new Map,s.set(A.day,C)),C.set(B,M/F),C.has(gs(B))||C.set(gs(B),M/F)}}const o=(A,q)=>{const I=s.get(A);return(I==null?void 0:I.get(q))??(I==null?void 0:I.get(gs(q)))??1},l=new Map;let c=0,d=0;for(const[A,q]of n){const I=A.indexOf("|"),B=A.slice(0,I),L=A.slice(I+1),M=ah(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 I=l.get(A);return(I==null?void 0:I.get(q))??(I==null?void 0:I.get(gs(q)))??null},p=new Set,g=(A,q)=>{let I=0,B=0;for(const[L,M]of Object.entries(A)){if(ma(L,r)){const C=q(L),$=PS(C===null?R0(M):LS(M),L,r);I+=C===null?$.atSpeed:$.atSpeed*C,B+=$.unpriced;for(const P of $.unpricedSpeeds)p.add(`${L} (${P})`);continue}const F=nO(M);F>0&&(B+=F,p.add(L))}return{cost:I,unpriced:B}},v=new Map,j=[];for(const A of e){const q=new Map,I=new Map;let B=0;for(const L of A.projects){const{cost:M,unpriced:F}=g(L.models,$=>f(A.day,$));q.set(L.path,(q.get(L.path)??0)+M),F>0&&I.set(L.path,(I.get(L.path)??0)+F),B+=M;let C=v.get(L.path);C||(C={path:L.path,cost:0,tokens:0,unpricedTokens:0},v.set(L.path,C)),C.cost+=M,C.tokens+=DS(L.models),C.unpricedTokens+=F}j.push({day:A.day,total:B,byPath:q,unpricedByPath:I})}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?DS(t):0,R=t?g(t,()=>S):{cost:0,unpriced:0},O=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:O,unpricedModels:[...p].sort(),calibrated:h,reconciled:h&&b===0}}function Dr(e,t,n=qe){return t>0?e>0?`${n(e)}+`:ks:n(e)}function Yo(e){return e>0?`${rt(e)} of these tokens are on an unpriced model, so this is a floor`:void 0}function CV(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 ${ks}: this build holds no published rate for it, so its tokens are counted and its dollars are not.`:`${n} are ${ks}: this build holds no published rate for them, so their tokens are counted and their dollars are not.`}const AV={phase:"running"},RV={phase:"failed"},MV={gen:0,report:null,error:null,early:null};function $V(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:AV;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 IV(e){var t;return((t=e.report)==null?void 0:t.gen)!==e.gen&&e.error===null}function OV(e){const t=e;return t&&t.ok!==!1?{phase:"ready",range:t}:RV}function LV(e){return`${e.getFullYear()}${String(e.getMonth()+1).padStart(2,"0")}${String(e.getDate()).padStart(2,"0")}`}function PV(e,t,n=Date.now()){const r=t===0?60:t,s=new Date(n),o=ob(r,s),l=LV(s);return{report:`/api/account-projects?num=${e}&days=${t}`,ccusage:`/api/ccusage?since=${o}&until=${l}`}}function DV({num:e,days:t,gen:n,dispatch:r,get:s=(l,c)=>fetch(l,c),now:o=Date.now()}){const l=PV(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:OV(d)}))}async function io(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 sO(e){return/^[A-Za-z]:[\\/]$/.test(e)?e:e.replace(/[\\/]+$/,"")}function Xp(e){const t=sO(e).replace(/\\/g,"/");return/^[A-Za-z]:\//.test(t)?t.toLowerCase():t}function FS(e){if(!e)return e;const t=sO(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 FV(e,t){const n=Xp(e);let r;for(const s of t){const o=Xp(s.path);!o||o===n||!n.startsWith(`${o}/`)||(!r||Xp(r.path).length<o.length)&&(r=s)}return r==null?void 0:r.label}function cb(e){return e===0?"all time":e===1?"today":`the last ${e} days`}function BV(e){return e===1?"No work attributed to this account yet today.":`No work attributed to this account in ${cb(e)}.`}function qV(e){return e===1?7:e===7?30:e===30?0:null}function UV(e,t){return e!==1&&t>0}const zV=[{days:1,label:"Today"},{days:7,label:"7d"},{days:30,label:"30d"},{days:0,label:"All"}],Xo=["var(--usage-blue)","var(--usage-teal)","var(--usage-lime)","var(--usage-purple)","var(--usage-indigo)","var(--usage-pink)","var(--usage-orange)","var(--usage-zinc)"],WV="var(--usage-zinc)",Zp=6,HV=1600;function VV(e){const t=qe(e),n=/^\$(\d{4,})$/.exec(t);return n?`$${Number(n[1]).toLocaleString("en-US")}`:t}function Wu(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 GV(e){const t=/^\d{4}-(\d{2})-(\d{2})$/.exec(e);return t?`${Number(t[1])}/${Number(t[2])}`:e}function KV(e){const t=Math.max(1,Math.ceil(e/6));return n=>n===0||n===e-1||n%t===0}function Jp(e){if(!e)return"";try{return new Date(e).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return""}}function YV({num:e,name:t,onClose:n}){var P,K,G,U;Ut("account-projects");const[r,s]=y.useState(1),[o,l]=y.useReducer($V,MV),c=((P=o.report)==null?void 0:P.data)??null,d=((K=o.report)==null?void 0:K.days)??r,h=((G=o.report)==null?void 0:G.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=IV(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),O=dt(n,{focusRef:R}),A=gt(n),q=y.useRef(0);y.useEffect(()=>{const W=++q.current;l({type:"start",gen:W}),g(null),j(new Set),DV({num:e,days:r,gen:W,dispatch:l})},[e,r]);const I=y.useMemo(()=>{const W=Date.now();if(!c)return null;const D=TV(c.daily??[],c.unattributed,EV(h),W),H=oe=>oe.replace(/[\\/]+$/,"").split(/[\\/]/).pop()||oe||"(unknown)",J=new Map;for(const oe of D.projects)J.set(H(oe.path),(J.get(H(oe.path))??0)+1);const V=oe=>{const Ne=H(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:V(oe.path)})),Y=oe=>({path:oe.path,label:V(oe.path),parentLabel:FV(oe.path,Z),cost:oe.cost,tokens:oe.tokens,unpricedTokens:oe.unpricedTokens}),X=Xo[Zp%Xo.length],ee=new Map,ae=[],ue=D.projects.slice(0,Zp),ge=D.projects.slice(Zp);ue.forEach((oe,Ne)=>{ee.set(oe.path,Xo[Ne%Xo.length]),ae.push({key:oe.path,...Y(oe),color:Xo[Ne%Xo.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,me=ye>0&&D.unpricedTokens===0?"cost":"tokens",pe=me==="cost"?ye:se,de=ae.map(oe=>oe.color),fe=D.perDay.map(oe=>{const Ne=new Map;for(const[Pe,Be]of oe.byPath){const Oe=ee.get(Pe)??X;Ne.set(Oe,(Ne.get(Oe)??0)+Be)}const we=new Map;let Ie=0;for(const[Pe,Be]of oe.unpricedByPath){const Oe=ee.get(Pe)??X;we.set(Oe,(we.get(Oe)??0)+Be),Ie+=Be}return{day:oe.day,total:oe.total,costByColor:Ne,unpricedByColor:we,unpriced:Ie}}),ne=fe.reduce((oe,Ne)=>Math.max(oe,Ne.total),0);return{projectCount:D.projects.length,rows:ae,totalCost:ye,totalTokens:se,basis:me,denom:pe,un:D.unattributed,chart:fe,maxDay:ne,colorOrder:de,unpricedTokens:D.unpricedTokens,unpricedNote:CV(D.unpricedModels),calibrated:D.calibrated,reconciled:D.reconciled}},[c,h]),B=(W,D)=>{io(W).then(H=>{E.current&&(window.clearTimeout(S.current),b({path:W,label:D,ok:H}),S.current=window.setTimeout(()=>{E.current&&b(null)},HV))})},L=W=>N!=null&&N.ok&&N.path===W?"Copied":"Copy",M=c!=null&&c.trackedSince?`Tracked since ${Jp(c.trackedSince)}`:"Tracking starts with this version",F=cb(d),C=qV(d),$=k&&!!c;return Dt.createPortal(a.jsx("div",{className:"modal-backdrop",...A,role:"presentation",children:a.jsxs("div",{ref:O,className:"modal ap-proj-modal",onClick:W=>W.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:zV.map(W=>a.jsx("button",{type:"button",className:"uh-range-btn","aria-pressed":r===W.days,onClick:()=>s(W.days),children:W.label},W.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${$?" 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&&I&&a.jsx(a.Fragment,{children:I.rows.length===0?a.jsxs("div",{className:"ap-proj-state",children:[$?"Updating…":BV(d),C!=null&&a.jsx("div",{className:"ap-proj-widen-wrap",children:a.jsxs("button",{type:"button",className:"ap-proj-copy",onClick:()=>s(C),children:["Show ",cb(C)]})}),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 ${I.basis==="cost"?qe(I.totalCost):`${rt(I.totalTokens)} tokens`} across ${I.projectCount} project${I.projectCount>1?"s":""}`,children:I.rows.map(W=>{const D=I.basis==="cost"?W.cost:W.tokens,H=I.denom>0?D/I.denom*100:0;if(H<=0)return null;const J=I.basis==="cost"?Wu(W.cost,I.totalCost):`${Wu(W.tokens,I.totalTokens)} of tokens`;return a.jsx("span",{className:"ap-proj-seg",style:{width:`${H}%`,background:W.color},title:`${W.label} · ${Dr(W.cost,W.unpricedTokens)} · ${J}${W.tokens?` · ${rt(W.tokens)} tokens`:""}`},W.key)})}),a.jsxs("div",{className:"ap-proj-totals",children:[a.jsx("span",{className:"ap-proj-total-cost",title:Yo(I.unpricedTokens),children:Dr(I.totalCost,I.unpricedTokens)}),a.jsxs("span",{className:"ap-proj-total-tok",children:[rt(I.totalTokens)," tokens"]}),a.jsxs("span",{className:"ap-proj-total-win",children:["· ",$?"updating…":F]}),f&&a.jsx("span",{className:"ap-proj-total-pending",children:"Reconciling cost…"})]}),I.unpricedNote&&a.jsx("div",{className:"ap-proj-note",children:I.unpricedNote}),UV(d,I.chart.length)&&a.jsxs("div",{className:"ap-proj-days",children:[a.jsxs("div",{className:"ap-proj-days-cap",children:["By day",I.chart.length>1?" · click a bar":""]}),a.jsx("div",{className:"ap-proj-days-plot",role:"group","aria-label":`Spend across ${I.chart.length} day${I.chart.length>1?"s":""}`,children:I.chart.map(W=>{const D=I.maxDay>0?W.total/I.maxDay*100:0,H=p===W.day,J=I.rows.map(Z=>({label:Z.label,c:W.costByColor.get(Z.color)??0,u:W.unpricedByColor.get(Z.color)??0})).filter(Z=>Z.c>0||Z.u>0),V=`${Jp(Date.parse(`${W.day}T00:00:00`))}, ${Dr(W.total,W.unpriced)}. ${J.map(Z=>`${Z.label} ${Dr(Z.c,Z.u)}`).join(", ")}`;return a.jsx("button",{type:"button",className:`ap-proj-day${H?" selected":""}`,"aria-pressed":H,"aria-label":V,title:`${W.day} · ${Dr(W.total,W.unpriced)}`,onClick:()=>g(Z=>Z===W.day?null:W.day),children:a.jsx("span",{className:"ap-proj-col",style:{height:`${D}%`},children:I.colorOrder.map((Z,Y)=>{const X=W.costByColor.get(Z)??0;return X<=0||W.total<=0?null:a.jsx("span",{className:"ap-proj-colseg",style:{height:`${X/W.total*100}%`,background:Z}},Y)})})},W.day)})}),(()=>{const W=KV(I.chart.length);return a.jsx("div",{className:"ap-proj-days-axis","aria-hidden":"true",children:I.chart.map((D,H)=>a.jsx("div",{className:"ap-proj-axis-cell",children:W(H)?GV(D.day):""},D.day))})})(),(()=>{const W=p?I.chart.find(H=>H.day===p):null;if(!W)return null;const D=I.rows.map(H=>({r:H,c:W.costByColor.get(H.color)??0,u:W.unpricedByColor.get(H.color)??0})).filter(H=>H.c>0||H.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:Jp(Date.parse(`${W.day}T00:00:00`))}),a.jsx("span",{className:"ap-proj-day-detail-total",title:Yo(W.unpriced),children:Dr(W.total,W.unpriced)})]}),D.map(({r:H,c:J,u:V})=>a.jsxs("div",{className:"ap-proj-day-detail-row",children:[a.jsx("span",{className:"ap-proj-dot",style:{background:H.color},"aria-hidden":"true"}),a.jsx("span",{className:"ap-proj-day-detail-name",children:H.label}),a.jsx("span",{className:"ap-proj-day-detail-cost",title:Yo(V),children:Dr(J,V)})]},H.key))]})})()]}),a.jsx("ul",{className:"ap-proj-list",children:I.rows.map((W,D)=>{const H=I.basis==="cost"?W.cost:W.tokens,J=I.denom>0?H/I.denom*100:0,V=v.has(W.key),Z=`ap-proj-details-${D}`,Y=V&&(!!W.path||!!W.members),X=W.members?`${V?"Hide":"Show"} the ${W.members.length} project${W.members.length>1?"s":""} folded into Other`:`${V?"Hide":"Show"} location for ${W.label}`;return a.jsxs("li",{className:`ap-proj-row${W.muted?" muted":""}${V?" expanded":""}`,children:[a.jsx("span",{className:"ap-proj-dot",style:{background:W.color},"aria-hidden":"true"}),a.jsxs("span",{className:"ap-proj-name",children:[W.label,W.parentLabel&&a.jsxs("span",{className:"ap-proj-parent",children:[" · in ",W.parentLabel]})]}),a.jsx("span",{className:"ap-proj-track",title:I.basis==="cost"?`${Wu(W.cost,I.totalCost)} of tracked cost`:`${Wu(W.tokens,I.totalTokens)} of tracked tokens`,children:a.jsx("span",{className:"ap-proj-fill",style:{width:`${J}%`,background:W.color}})}),a.jsx("span",{className:"ap-proj-cost",title:Yo(W.unpricedTokens),children:Dr(W.cost,W.unpricedTokens)}),a.jsx("span",{className:"ap-proj-tok",children:rt(W.tokens)}),a.jsx("button",{type:"button",className:"glyph-btn ap-proj-info","aria-expanded":V,"aria-controls":Y?Z:void 0,"aria-label":X,onClick:()=>j(ee=>{const ae=new Set(ee);return ae.has(W.key)?ae.delete(W.key):ae.add(W.key),ae}),children:"ⓘ"}),V&&W.path&&a.jsxs("div",{className:"ap-proj-details",id:Z,children:[a.jsx("code",{className:"ap-proj-path",children:FS(W.path)}),a.jsx("button",{type:"button",className:"ap-proj-copy","aria-label":`${L(W.path)} location for ${W.label}`,onClick:()=>B(W.path,W.label),children:L(W.path)})]}),V&&W.members&&a.jsx("div",{className:"ap-proj-details ap-proj-other-members",id:Z,children:W.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:FS(ee.path)}),a.jsx("span",{className:"ap-proj-cost",title:Yo(ee.unpricedTokens),children:Dr(ee.cost,ee.unpricedTokens)}),a.jsx("span",{className:"ap-proj-tok",children:rt(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))})]},W.key)})}),I.un&&a.jsxs("div",{className:"ap-proj-unattributed",children:[a.jsx("span",{className:"ap-proj-dot",style:{background:WV},"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:Yo(I.un.unpricedTokens),children:Dr(I.un.cost,I.un.unpricedTokens,VV)}),a.jsx("span",{className:"ap-proj-un-tok",children:rt(I.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":I.reconciled?"Dollars from ccusage · split by activity":I.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 ji(e,t){return EI(t-Math.floor(e/1e3))}function XV(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 M0(){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 ZV({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(bh,{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(M0,{}),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 ${ji(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 Il(e){return e.charAt(0).toUpperCase()+e.slice(1)}function JV(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 QV(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 eG(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 BS={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 Si(e,t,n){const r=nG(e,t);return!r||!(n!=null&&n.noCopyWorksNearby)||!tG(e)?r:{...r,text:BS.text,hint:BS.hint}}function tG(e){return e.staleCopy?!1:e.stopped?e.collector==="relogin_required":e.error==="invalid_grant"||e.error==="no_refresh_token"}function nG(e,t){if(e.staleCopy){const n=JV(e.repair??null,t);return{text:Il(n.text),hint:n.hint,fix:null,tone:"quiet",blocksSwitch:!1}}if(e.stopped){const n=eG(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:Il(n.text),hint:n.hint,fix:n.fix?Il(n.fix):null,tone:r||e.collector==="keychain_unavailable"?"warn":"quiet",blocksSwitch:r}}if(e.error){const n=QV(e.error);return{text:Il(n.text),hint:n.hint,fix:n.fixable?"Sign in again":null,tone:n.fixable?"warn":"quiet",blocksSwitch:n.fixable}}return null}function qS(e){return typeof e.id=="string"&&e.id.startsWith("scoped-")}function US(e){const t=e.filter(c=>!qS(c)),n=e.filter(c=>qS(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 ic(e,t){return!!e.resetAt&&e.resetAt<=t}function $0(e,t){const n=e.lanes??[],r=n.filter(s=>!ic(s,t));return r.length===n.length?e.headroom:r.length?Math.max(0,100-Math.max(...r.map(s=>s.pct))):null}const rG="\0";function Br(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}${rG}${n}`}function sG(e,t,n=Br){const r=n(t);return e.includes(r)?e.filter(s=>s!==r):[...e,r]}const kh="slot",I0=[{lane:"five_hour",name:"5h"},{lane:"seven_day",name:"7d"}],aO=e=>e.id.startsWith("scoped-");function aG(e){var t;return((t=I0.find(n=>n.lane===e.id))==null?void 0:t.name)??e.label}function oG(e){if(e==="room")return"room";const t=/^(.+):(full|empty)$/.exec(e);return t?t[1]:null}function oO(e){const t=[...new Set(e.flatMap(r=>(r.lanes??[]).filter(aO).map(s=>s.label)))].sort((r,s)=>r.localeCompare(s)),n=[...I0.map(r=>r.name),...t];return[{id:kh,label:"Slot"},...n.flatMap(r=>[{id:`${r}:full`,label:`${r} · fullest`},{id:`${r}:empty`,label:`${r} · emptiest`}]),{id:"room",label:"Most room"}]}function zS(e,t,n){const r=I0.find(o=>o.name===t),s=(e.lanes??[]).find(o=>r?o.id===r.lane:aO(o)&&o.label===t);return s&&n!=null&&ic(s,n)?null:s&&Number.isFinite(s.pct)?s.pct:null}function iG(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:$0(p,r);return o(WS(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=>zS(f,c,r)!=null))return s;const h=WS(s,f=>zS(f,c,r),d==="full"?"desc":"asc");return d==="empty"?o(h):h}function WS(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 lG(e,t){return oO(t).some(n=>n.id===e)?e:kh}function ub(e,t){if(!t)return[...e];const n=new Map(t.map((o,l)=>[o,l])),r=e.filter(o=>n.has(Br(o))).sort((o,l)=>n.get(Br(o))-n.get(Br(l))),s=e.filter(o=>!n.has(Br(o)));return[...r,...s]}function O0(e){const t=Br(e);return t.startsWith("slot:")?t:`h:${cG(t)}`}function cG(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 db={mode:"some",keys:[]};function iO(e,t){const n=e.keys.includes(O0(t));return e.mode==="all"?!n:n}function uG(e,t){return{mode:e.mode,keys:sG(e.keys,t,O0)}}function lO(e,t){return t.length>0&&t.every(n=>iO(e,n))}function dG(e,t){return lO(e,t)?db:{mode:"all",keys:[]}}function hG(e,t){if(!Array.isArray(t))return e;const n=new Set(t.map(O0)),r=e.keys.filter(s=>n.has(s));return r.length===e.keys.length?e:{mode:e.mode,keys:r}}function fG(e){return e>=90?"hi":e>=70?"mid":void 0}function pG({lane:e,nowSec:t,frozen:n,sortedBy:r}){const s=Math.min(100,Math.max(0,e.pct)),o=ic(e,t),l=n||o,c=l?"var(--muted)":s>=90?"var(--err)":s>=70?"var(--warn)":"var(--accent)",d=e.resetAt&&!l?ph(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 mG({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(C=>!ic(C,t)),{shown:E}=US(e.lanes),{fuller:R}=US(S),O=b==="room"?S.reduce((C,$)=>C&&C.pct>=$.pct?C:$,null):b?e.lanes.find(C=>aG(C)===b)??null:null,A=Si(e,t,n),q=e.active||r,I=e.alias??e.email??`account ${e.num}`,B=e.alias&&e.email?`${e.alias} · ${e.email}`:I,L=e.stale||(A==null?void 0:A.blocksSwitch)===!0,M=R?[...E,R]:E,F=e.fetchedAt?ji(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:[I,", ",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,I),"aria-label":`Switch to ${I}`,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:C=>{C.key!=="ArrowDown"&&C.key!=="ArrowUp"||(C.preventDefault(),h(e.num,C.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 C=(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: ${C} 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(M0,{}),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(C=>a.jsxs("span",{className:"ap-q","data-sort-key":C.id===(O==null?void 0:O.id)?"":void 0,children:[a.jsx("span",{className:"ap-q-label",children:C.label})," ",ic(C,t)?a.jsx("span",{className:"ap-q-pct",title:`${C.label} has reset since this reading`,children:"reset"}):a.jsxs("span",{className:"ap-q-pct","data-level":L?void 0:fG(C.pct),children:[Math.round(C.pct),"%"]})]},C.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(C=>a.jsx(pG,{lane:C,nowSec:t,frozen:L,sortedBy:C.id===(O==null?void 0:O.id)},C.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 ",ji(e.fetchedAt,t),A!=null&&A.blocksSwitch?"":XV(e.nextAt,t)]}):a.jsx("span",{className:"ap-age ap-stale",title:"claude-swap has not read this account yet",children:"never collected"})})]})]})}function gG({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 yG({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 ${Nt} 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 Za=[{id:"five_hour",label:"5h",long:"5-hour"},{id:"seven_day",label:"7d",long:"7-day"}];function HS(e){return e.counted?e.pct:e.why==="login"?null:e.estimate}function wG(e){const t=HS(e.five_hour),n=HS(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 vG(e,t){const n=Za.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:ji(e.updatedAt,t),old:!0}}const xG=15*6e4,bG=e=>e.alias??e.email??`account ${e.num}`;function VS(e,t,n){const r=Za.find(f=>f.id===t).label,s=(e.lanes??[]).find(f=>f.id===t),o=s&&Number.isFinite(s.pct)?kG(s.pct):null,l=Si(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>xG?d("stale",e.fetchedAt?`Updated ${ji(e.fetchedAt,n)}`:"Never read"):c?d("reset",`Reset ${ji(s.resetAt*1e3,n)}, not updated`):{counted:!0,pct:o,resetAt:s.resetAt}}const kG=e=>Math.min(100,Math.max(0,e));function NG(e,t){const n=Za.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 cO(e,t){const n=e.map(s=>{const o={five_hour:VS(s,"five_hour",t),seven_day:VS(s,"seven_day",t)};return{num:s.num,key:Br(s),name:bG(s),active:s.active,heldOut:s.disabled===!0,cells:o,status:wG(o),updatedAt:s.fetchedAt??null}}),r=n.filter(s=>s.status==="ready").length;return{rows:n,windows:Za.map(s=>NG(n,s.id)),roomInBoth:r}}function Hu(e,t){return(e==null?void 0:e.key)===t?{key:t,dir:e.dir==="asc"?"desc":"asc"}:{key:t,dir:"asc"}}const jG={ready:0,limited:1,exhausted:2,stale:3};function SG(e){return e.counted?e.pct:e.last}function GS(e,t){return t==="status"?jG[e.status]:t==="updated"?e.updatedAt==null?null:-e.updatedAt:SG(e.cells[t])}function _G(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=GS(o,t.key),d=GS(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 Id(e){return e>=100?100:Math.min(99,Math.round(e))}function EG(e){const t=Id(e);return{used:t,available:100-t}}function TG(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 uO(e){return e>=90?"hi":e>=70?"mid":void 0}const dO=(e,t,n)=>`${e} ${e===1?t:n}`;function KS(e){const t=e.more>0?`, and ${dO(e.more,"more account","more accounts")} in the same minute`:"";return`First: ${e.name} (${Id(e.pct)}% used)${t}`}function CG({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}=EG(e.used??0),c=Math.round(Ua(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?ph(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":uO(o),"aria-hidden":!0,children:a.jsx("i",{style:{"--left":l/100}})}),d&&e.nextReset&&a.jsxs("p",{className:"ap-report-reset",title:KS(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:[". ",KS(e.nextReset)]})]}),s]})}function AG({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"})]}):`${Id(e.last)}%`}),a.jsx("span",{className:"vis-hidden",children:", not counted"})]});const n=e.resetAt!=null?ph(e.resetAt,t):null;return a.jsxs("td",{className:"ap-report-cell",children:[a.jsxs("span",{className:"ap-report-pct","data-level":uO(e.pct),children:[Id(e.pct),"%"]}),n&&a.jsxs("span",{className:"ap-report-in",children:[a.jsx("span",{className:"vis-hidden",children:"resets in "}),n]})]})}const RG={ready:"Ready",limited:"Limited",exhausted:"Exhausted",stale:"Stale"};function MG({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}),RG[e.status]]})})}function $G({row:e,nowSec:t}){const n=vG(e,t);return a.jsx("td",{className:"ap-report-upd","data-old":n.old?"":void 0,children:n.text})}function IG(){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 OG({accounts:e,nowSec:t,held:n,sort:r=null,onSort:s=()=>{}}){const o=cO(e,t),l=o.rows.length,c=Math.round(Ua(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 ",dO(l,"Claude account","Claude accounts")," ready"]}),a.jsx("div",{className:"ap-report-sums",children:o.windows.map(d=>a.jsx(CG,{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",{}),Za.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($l,{col:"account",label:"Account",sort:r,next:Hu,onSort:s}),Za.map(d=>a.jsx($l,{col:d.id,label:`${d.label} used`,sort:r,next:Hu,onSort:s},d.id)),a.jsx($l,{col:"status",label:"Status",sort:r,next:Hu,onSort:s}),a.jsx($l,{col:"updated",label:"Updated",className:"ap-report-upd-h",sort:r,next:Hu,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"})]})}),Za.map(f=>a.jsx(AG,{cell:d.cells[f.id],nowSec:t},f.id)),a.jsx(MG,{row:d}),a.jsx($G,{row:d,nowSec:t})]},d.num))})]}),a.jsxs("details",{className:"ap-report-how",children:[a.jsxs("summary",{children:[a.jsx(IG,{}),"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 LG({accounts:e,order:t,failed:n,nowSec:r,onClose:s}){const o=y.useRef(null),l=dt(s,{focusRef:o}),c=gt(s),[d,h]=y.useState(e??[]);y.useEffect(()=>{e&&e.length>0&&h(e)},[e]);const f=TG(n,!e||e.length===0,d.length>0),[p,g]=y.useState(null),v=ub(d,(p==null?void 0:p.order)??t),j=k=>{const x=cO(ub(d,t),r).rows;g({sort:k,order:_G(x,k).map(N=>N.key)})};return Dt.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(OG,{accounts:v,nowSec:r,held:f,sort:(p==null?void 0:p.sort)??null,onSort:j})]})}),document.body)}const Qp=[70,80,85,90,95],hO="custom",ni=50,ri=99,PG=`A whole percent from ${ni} to ${ri}.`;function DG(e){const t=Number(e);return[...Number.isFinite(t)&&t>0&&!Qp.includes(t)?[...Qp,t]:Qp].sort((r,s)=>r-s)}function FG(e){const t=e.trim().replace(/\s*%$/,"");if(t==="")return{ok:!1,reason:"empty",message:`Enter a number from ${ni} to ${ri}.`};if(!/^\d+(\.\d*)?$|^\.\d+$/.test(t))return{ok:!1,reason:"not_a_number",message:`Enter a number from ${ni} to ${ri}.`};const n=Number(t);return Number.isInteger(n)?n<ni?{ok:!1,reason:"too_low",message:`The lowest is ${ni}%.`}:n>ri?{ok:!1,reason:"too_high",message:`The highest is ${ri}%.`}:{ok:!0,value:String(n)}:{ok:!1,reason:"not_whole",message:`Use a whole number from ${ni} to ${ri}.`}}const hb={pick:null,custom:null,refusal:null};function BG(e,t){switch(t.kind){case"pick":return t.pick===hO?{...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 hb;case"leave":return e.custom&&(e.pick??t.stored)===t.stored?hb:e}}async function qG(e,t,n){if(!t.sends)return{kind:"unchanged"};const r=FG(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 UG({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:[DG(t).map(S=>a.jsxs("option",{value:S,children:[S,"%"]},S)),a.jsx("option",{value:hO,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:PG},"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 YS=18,zG=1100,Zo=(e,t)=>{const n=Math.sin(e*12.9898+t*78.233)*43758.5453;return n-Math.floor(n)},WG=Array.from({length:YS},(e,t)=>{const n=-72+144*t/(YS-1)+(Zo(t,1)-.5)*9,r=(n-90)*(Math.PI/180),s=(54+32*Math.cos(n*Math.PI/180))*(.74+Zo(t,2)*.52);return{dx:Math.cos(r)*s,dy:Math.sin(r)*s,rot:(t%2?1:-1)*(100+Zo(t,3)*260),delay:Math.round(Zo(t,4)*90),dur:760+Math.round(Zo(t,5)*260),scale:.8+Zo(t,6)*.45,hue:t%4,round:t%3===0}});function XS({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),zG);return()=>window.clearTimeout(c)},[e,r]),r||!t?null:Dt.createPortal(a.jsx("div",{className:"confetti",style:{left:`${t.x}px`,top:`${t.y}px`},"aria-hidden":!0,children:WG.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 Od=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"})]}));Od.displayName="SuccessMark";const fO=new Set(["awaiting_url","awaiting_code","registering"]);function pO(e){return e!=null&&fO.has(e)}function mO(e){return e!=null&&e!=="done"&&!fO.has(e)}const HG="the sign-in ended before it finished — the deck restarted, or it was cancelled in another tab",VG="the sign-in did not complete";function GG({state:e,serverError:t,localError:n}){const r=e==="idle";return{title:r?"Sign-in ended":"Sign-in failed",message:n||t||(r?HG:VG)}}function KG({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 YG({started:e,state:t}){return!e||t==="done"?null:{action:"login-cancel"}}function XG({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":mO(e==null?void 0:e.state)||n&&t&&!r?"ended":r||pO(e==null?void 0:e.state)?"asking":"primer"}const ZG="done";function JG(){let e=!1;return{shouldAnnounce(t){return t!==ZG?(e=!1,!1):e?!1:(e=!0,!0)}}}function L0(e,t){return t?Pt(e,t):void 0}const QG={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 ${Nt}`,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"},eK={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"},P0=`claude-swap could not read the login keychain — start ${Nt} from a Terminal window rather than a background service`,tK={unreadable_here:{short:"Keychain locked on this Mac",long:`${P0}.`},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 Ld(e){return e?Pt(tK,e)??null:null}const gO={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 fb(e,t,n){const r=n==null?null:gO[n];if(r)return r;if((e==null?void 0:e.reason)!=="no_cswap"&&/keychain/i.test(lc(e)))return P0;const s=L0(eK,e==null?void 0:e.reason);return s||(e==null?void 0:e.reason)||t}function lc(e){return((e==null?void 0:e.output)||(e==null?void 0:e.detail)||(e==null?void 0:e.error)||"").trim()}const nK={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"},rK="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 sK(e){return/\bnpx\b/i.test(e)&&/(command not found|not found|not recognized|ENOENT)/i.test(e)}const aK="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",oK="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",iK=e=>/\b(?:ERR_)?MODULE_NOT_FOUND\b|cannot find (?:module|package)/i.test(e),lK=/node_modules[\\/]npm[\\/]bin[\\/]|\bnpm-prefix\.js\b|\bnp[mx][-.][\w.-]*cli\.js\b/i,cK=/[\\/]_npx[\\/]/i,uK=`the copy of ccusage ${Nt} installed for itself`;function dK(e){const t=String((e==null?void 0:e.install)??"").replace(/\s+/g," ").trim();return t.length>240?`${t.slice(0,239)}…`:t}function jue(e,t){const n=hK(e,t),r=dK(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 ${El(n)}`:`there is no managed copy of ccusage on this machine, and the npx fallback failed: ${El(n)}`;case"managed":return`${uK} failed to run: ${El(n)}`;case"path":return e.bin?`the ccusage this deck found at ${e.bin} failed to run: ${El(n)}`:`the ccusage this deck found on your PATH failed to run: ${El(n)}`;default:return n}}const El=e=>/^[A-Z][a-z]/.test(e)?e[0].toLowerCase()+e.slice(1):e;function hK(e,t){const n=lc(e);if(iK(n)){if(cK.test(n))return oK;if(lK.test(n))return aK}if(sK(n))return rK;const r=L0(nK,e==null?void 0:e.reason);return r||(e==null?void 0:e.reason)||t}function ai(e,t,n){const r=n==null?null:gO[n];if(r)return r;if(e!=null&&e.detail)return e.detail;if(e!=null&&e.error&&mO(e.state))return e.error;const s=L0(QG,e==null?void 0:e.reason);return s||(e!=null&&e.error?e.error:(e==null?void 0:e.reason)||t)}function yO(e,t,n,r="horizontal"){if(n<=0||ch(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 wO(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 fK(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 pK(e,t){return e.filter(n=>!t.includes(n.num)).map(n=>n.num)}function mK(e,t){return e.includes(t)?e.filter(n=>n!==t):[...e,t]}function gK(e){return e.length?{action:"share",accounts:[...e]}:null}function yK(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 pb(e){return`${e.email}|${e.org??""}`}function wK(e,t,n){return e&&e.map(r=>pb(r)===t?n:r)}function vK(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 xK(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=Ld(f.check))==null?void 0:p.short}).filter(f=>!!f))];return`${r.join(", ")}${h.length?`, ${h.join(", ")}`:""}.`}const bK=1500,Vu=[{id:"login",label:"Sign in"},{id:"paste",label:"Paste a share"}],ZS="aa-panel",JS=e=>`aa-tab-${e}`;async function Jo(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}function vO({onClose:e,onChanged:t,email:n=null,onSignedIn:r}){Ut("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,O]=y.useState(null),[A,q]=y.useState(null),[I,B]=y.useState(null),L=y.useRef(""),M=y.useRef(!1),F=y.useRef(!1),C=y.useRef(null),$=y.useRef(null),P=y.useRef(null),K=y.useRef(null),G=y.useRef([]),U=y.useRef(!1),W=y.useCallback(()=>{const de=YG({started:M.current,state:l==null?void 0:l.state});de&&Jo(de).catch(()=>{}),e()},[e,l==null?void 0:l.state]),D=dt(W,{focusRef:P}),H=gt(W),J=y.useCallback(async()=>{if(!pr(F.current))return;F.current=!0,v(!0),N(null),M.current=!0;let de=await Jo(n?{action:"login",email:n}:{action:"login"}).catch(()=>null);if(n&&(de==null?void 0:de.reason)==="bad_email"&&(de=await Jo({action:"login"}).catch(()=>null)),F.current=!1,v(!1),!(de!=null&&de.ok)){N(ai(de,"could not start the sign-in"));return}c(de)},[n]);y.useEffect(()=>{if(!pO(l==null?void 0:l.state))return;const de=window.setInterval(async()=>{try{const fe=await fetch("/api/claude-accounts/login");fe.ok&&c(await fe.json())}catch{}},bK);return()=>window.clearInterval(de)},[l]);const V=y.useRef(t);V.current=t;const Z=y.useState(JG)[0];y.useEffect(()=>{var de;(l==null?void 0:l.state)==="awaiting_code"&&((de=C.current)==null||de.focus()),Z.shouldAnnounce(l==null?void 0:l.state)&&V.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,fe=de?`${de.num??""}|${de.email}`:null;!de||X.current===fe||(X.current=fe,(ne=Y.current)==null||ne.call(Y,de))},[l]),y.useEffect(()=>{var de;s==="paste"&&!U.current&&((de=$.current)==null||de.focus()),U.current=!1},[s]);const ee=y.useCallback(de=>{var ne;const fe=yO(de,Vu.findIndex(oe=>oe.id===s),Vu.length);fe.kind!=="pass"&&(de.preventDefault(),U.current=!0,o(Vu[fe.index].id),(ne=G.current[fe.index])==null||ne.focus())},[s]),ae=y.useCallback(async()=>{var fe;if(!pr(F.current))return;F.current=!0,v(!0),N(null);const de=await Jo({action:"login-code",code:d}).catch(()=>null);if(F.current=!1,v(!1),!(de!=null&&de.ok)){N(ai(de,"the code was not accepted")),de!=null&&de.state&&c(de),(fe=C.current)==null||fe.select();return}h(""),c(de)},[d,l]),ue=y.useCallback(async()=>{if(!pr(F.current))return;F.current=!0,k(!0),S(null);const de=await Jo({action:"import",blob:f}).catch(()=>null);if(F.current=!1,k(!1),!(de!=null&&de.ok)){S(ai(de,"the import failed"));return}L.current=f,p(""),B(null),O(de.results??[]),t()},[f,t]),ge=y.useCallback(async de=>{const fe=pb(de);if(!pr(F.current)||!L.current)return;F.current=!0,k(!0),q(fe),B(null);const ne=await Jo({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:fe,text:ai(ne,"that account could not be updated")});return}const oe=(ne.results??[])[0];oe&&O(Ne=>wK(Ne,fe,oe)),t()},[t]),ye=(l==null?void 0:l.state)==="done"?l.account:null,se=KG({restored:l==null?void 0:l.restored,activeAccount:l==null?void 0:l.activeAccount}),me=XG({login:l,started:M.current,loginError:x,loginBusy:g}),pe=GG({state:l==null?void 0:l.state,serverError:l==null?void 0:l.error,localError:x});return Dt.createPortal(a.jsx("div",{className:"modal-backdrop",...H,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:Vu.map((de,fe)=>a.jsx("button",{type:"button",role:"tab",id:JS(de.id),ref:ne=>{G.current[fe]=ne},"aria-selected":s===de.id,"aria-controls":ZS,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:W,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsx("section",{className:"modal-body aa-body",id:ZS,role:"tabpanel","aria-labelledby":JS(s),children:s==="login"?me==="done"&&ye?a.jsxs("div",{className:"aa-done",children:[a.jsx(Od,{ref:K}),a.jsx(XS,{anchor:K}),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:W,children:"Done"})]}):me==="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:C,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",...vs(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."})]})]}):me==="ended"?a.jsxs("div",{className:"aa-step",children:[a.jsx("h4",{children:pe.title}),a.jsx("p",{className:"aa-err",children:pe.message}),a.jsx("button",{type:"button",className:"btn",onClick:()=>{M.current=!1,c(null),N(null),J()},children:"Try again"})]}):me==="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:P,className:"btn primary",...vs(E),onClick:J,children:"Open the sign-in page"})})]}):R?(()=>{const de=R.filter(ne=>ne.state==="imported").length,fe=R.some(ne=>Ld(ne.check));return a.jsxs("div",{className:"aa-done",children:[!fe&&a.jsx(Od,{ref:K}),de>0&&!fe&&a.jsx(XS,{anchor:K}),a.jsx("h4",{children:xK(R)}),R.length>0&&a.jsx("ul",{className:"aa-results",children:R.map(ne=>{const oe=pb(ne),Ne=Ld(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:vK(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}),(I==null?void 0:I.key)===oe&&a.jsx("span",{className:"aa-result-err",children:I.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:W,children:"Done"}),a.jsx("button",{type:"button",className:"btn",onClick:()=>{L.current="",B(null),O(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:$,type:"text",value:f,onChange:de=>p(de.target.value),onKeyDown:de=>{de.key==="Enter"&&f.trim()&&!E&&ue()},placeholder:"ccdeck2:…",spellCheck:!1,autoComplete:"off","aria-label":"Shared account"}),a.jsx("button",{type:"button",className:"btn primary",...vs(E,!f.trim()),onClick:ue,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 kK(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 NK(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 jK=64;function SK(e,t){const n=e.trim();return{alias:n,commit:n!==(t??"").trim()}}function _K(e,t,n){return t!=null&&e.some(r=>r.slot===t)?t:n}function EK(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 TK(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 CK({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:O,pickSlot:A,doSlot:q,makeShare:I,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(bh,{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:()=>O(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 ${Nt}. 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:()=>I(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:C=>{C.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:C=>E(C.target.value),maxLength:jK,placeholder:"e.g. work",spellCheck:!1,autoComplete:"off",autoFocus:!0,onFocus:C=>C.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 C=kK(t,e.num),$=_K(C,x,e.num),P=EK(C,$,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($),...l(`move-${e.num}`),onChange:K=>A(Number(K.target.value)),autoFocus:!0,children:C.map(K=>a.jsx("option",{value:K.slot,children:K.label},K.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:P.title,onClick:()=>q(e.num,$,P),children:o===`move-${e.num}`?"…":Il(P.label)})]})]})})(),f.view==="share"&&(j==null?void 0:j.num)===e.num&&(()=>{const C=wO(j.expiresAt,n),$=C.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 ${C.tone}`,children:C.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($){await I(e.num);return}await B(j.blob)},children:$?"Make a new share":k?"Copied":"Copy"})]})]})})()]})}const AK=6;function RK(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?MK(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 MK(e){const t=e.map(n=>n.headroom).filter(n=>typeof n=="number");return t.length?Math.round(Math.max(...t)):null}function $K(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,AK),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 Ur(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 IK={keychain_unavailable:{short:"Keychain locked on the other Mac",long:`the other Mac could not export it. On that Mac: ${P0}. The next round brings it.`}};function mb(e){return e.why?Pt(IK,e.why)??Ld(e.why):null}const D0={"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"}},OK={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 QS(e){var r;const t=LK[e];if(t)return t;const n=(r=/\b(E[A-Z]{3,})\b/.exec(e))==null?void 0:r[1];return n&&OK[n]||e}const LK={"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 Nh(e,t){var f;if(!e)return null;if(e.error&&((f=e.done)!=null&&f.length)){const p=Nh({...e,error:void 0},t),g=` · ${Ur(e.at,t)}`;return{...p,text:`${p.text.slice(0,-g.length)}, then ${QS(e.error)}${g}`,tone:"bad"}}if(e.error)return D0[e.error]??{text:QS(e.error),tone:"bad"};const n=e.done??[];if(!n.length)return{text:`all logins fine · ${Ur(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:mb(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=Ur(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 PK=9e4;function DK({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<PK);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 jh(e,t){var n,r;return(n=e.last)!=null&&n.error&&!D0[e.last.error]?!1:!!((r=e.last)!=null&&r.at&&t-e.last.at<gb||e.lastSeen!=null&&t-e.lastSeen<gb)}const gb=95e3;function FK(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?xO(p.lastSeen,t):jh(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 kO(r,g=>bO(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 BK(e,t,n){if(n)return"checking…";if(e==null)return"not checked yet";const r=Ur(e,t);return r==="now"?"checked just now":`checked ${r}`}function F0(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 xO(e,t){return e!=null&&t-e<gb}function qK(e,t){if(e==null)return{text:"one-way · has not called yet",here:!1};const n=xO(e,t);return{text:n?"online · one-way, it calls in":`one-way · last online ${Ur(e,t)}`,here:n}}function e_(e,t,n){return t?"online":e.lastSeen!=null?`last online ${Ur(e.lastSeen,n)}`:e.waiting?"has not called yet":"never reached"}function UK(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(zK(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(WK(p,g,t)):l.push(HK(p,g,o,t)))}n.push(...KK(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(VK(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(GK(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 zK(e,t,n){const r=Sh(t,e.fp,e.name||e.fp);return{fp:e.fp,...r,addr:e.addr??"",kind:"asks",state:`wants to pair · ${F0(e.at,n)}`,tone:"wait",here:!0,hint:`${r.name} at ${e.addr}${e.via==="tailscale"?", over Tailscale,":""} is waiting for an answer.`,..._h(e.via)}}function WK(e,t,n){var o;const r=Nh(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?yb(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.`,..._h(e.via)}}function HK(e,t,n,r){var v,j,k,x;const s=Nh(e.last,r),o=jh(e,r),l=e.addr?`${e.addr}:${e.port}`:"",c=e.waiting?qK(e.lastSeen,r):null,d=c?c.here:o,h=!c&&s?d?`online · ${yb(s)}`:`${yb(s)} · ${e_(e,d,r)}`:c?c.text:e_(e,d,r),f=(v=e.last)!=null&&v.error?D0[e.last.error]:null,p=!c&&d&&!((j=e.last)!=null&&j.error)&&!(((k=e.last)==null?void 0:k.done)??[]).length,g=bO(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,..._h(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 ${Ur(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 bO(e,t,n){return e.manual&&!e.met?{name:e.addr?`${e.addr}:${e.port}`:""}:Sh(n,t,e.name||t)}function VK(e,t,n){const r=Sh(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.`,..._h(e.via)}}function GK(e,t){const n=Sh(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 Sh(e,t,n){const r=t?e[t]:void 0;return r&&r!==n?{name:r,self:n}:{name:n}}function _h(e){return e==="tailscale"?{via:"tailscale"}:{}}function yb(e){return e.text.replace(/ · .*$/,"")}function KK(e){return kO(e,t=>t.name,t=>t.addr).map(YK)}function kO(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 YK(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 t_(e,t){return t?e.map(n=>t[n.fp]?{...n,name:t[n.fp]}:n):e}function cc(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 XK(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 ZK(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 n_(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 JK(e,t,n){if(!(t!=null&&t.enabled))return!1;const r=(t.peers??[]).filter(s=>s.paired&&jh(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 QK(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||!jh(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 NO=160,jO=140;function eY(){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),jO)},holdPeek:()=>window.clearTimeout(n.current),dropPeek:()=>{window.clearTimeout(n.current),t(!1)}}}function tY(e){var t;return((t=e==null?void 0:e.detail)==null?void 0:t.fix)==="give_back"}function ur(e,t){return{text:e,giveBack:tY(t),done:!1}}async function nY(){try{return await(await fetch("/api/prefs/give-back",{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"})).json().catch(()=>null)}catch{return null}}const rY={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 sY(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?rY[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 wb=5e3,SO=6e4;function Ct(e,t){if(t==null)return`Could not ${e} — the deck did not answer.`;const n=t.reason?iY(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 aY={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."},oY=new Set(["EACCES","EPERM"]);function iY(e,t){const n=aY[e];if(!n)return;const r=e==="prefs_unreadable"&&t?lY(t):void 0,s=t!=null&&t.code&&t.code!=="BADJSON"?` Error code: ${t.code}.`:"";return(r??n)+s}function lY({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&&!oY.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 Qo(e,t){return(await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).json().catch(()=>null)}function cY(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=>wh(f.current)?(f.current=L,c(L),!0):!1,[]),g=y.useCallback(()=>{f.current=null,x.current&&c(null)},[]),v=L=>{const M=fa(l,L);return{disabled:M.disabled,"aria-busy":M.busy}},[j,k]=y.useState(()=>Date.now()),x=y.useRef(!0),N=y.useRef(wb),b=y.useCallback(async()=>{var L,M;try{const[F,C]=await Promise.all([fetch("/api/lan").then($=>$.json()),fetch("/api/prefs").then($=>$.json())]);if(!x.current)return;F!=null&&F.ok&&r(F),C!=null&&C.ok&&o(Array.isArray((M=(L=C.prefs)==null?void 0:L.lan)==null?void 0:M.manual)?C.prefs.lan.manual:[]),N.current=(F==null?void 0:F.enabled)===!0?wb:SO}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 Qo("/api/prefs",{lan:{enabled:!L}});if(!x.current)return;M!=null&&M.ok?(h(null),L||t()):h(ur(Ct(L?"turn this off":"turn this on",M),M)),await b()}catch{x.current&&h(ur(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 C=null;try{const $=await Qo("/api/lan/peer",{action:L,fp:M});if(!x.current)return null;$!=null&&$.ok?(r($),h(null)):(C=Ct(F,$),h(ur(C,$))),await b()}catch{C=Ct(F,null),x.current&&h(ur(C))}finally{g()}return C},[b,p,g]),R=y.useCallback(async L=>{if(!p(`drop:${L}`))return null;let M=null;try{const F=await Qo("/api/prefs",{lan:{manual:s.filter(C=>C!==L)}});if(!x.current)return null;F!=null&&F.ok?(h(null),e()):(M=Ct("stop dialling that address",F),h(ur(M,F))),await b()}catch{M=Ct("stop dialling that address",null),x.current&&h(ur(M))}finally{g()}return M},[s,b,e,p,g]),O=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 Qo("/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 Qo("/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 Qo("/api/lan/sync",{});if(!x.current)return;L!=null&&L.ok?(r(L),h(null)):h(ur(Ct("check the other decks",L),L)),e()}catch{x.current&&h(ur(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:O,checkOne:A,checkNow:q}}function uY(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=ao({armedFor:t,target:o.fp,armedAt:r.current,now:l,gapMs:so});if(c==="arm"){n(o.fp),r.current=l;return}c!=="ignore"&&(n(null),e("unpair",o.fp,"unpair that deck"))}}}function _O({title:e,steps:t,finish:n,aside:r,onClose:s}){const o=y.useRef(null),l=dt(s,{focusRef:o}),c=gt(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;En(((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 Dt.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 vb={ok:"ga-ok",warn:"ga-warn",accent:"ga-accent",flight:"ga-flight"};function Vn({children:e}){return a.jsx("svg",{className:"guide-art",viewBox:"0 0 440 200","aria-hidden":!0,focusable:"false",children:e})}function Hn({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 gr({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:vb[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 ${vb[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 EO({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 Gu({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 r_({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 s_({x:e,y:t,d:n}){return a.jsx("path",{d:n,transform:`translate(${e} ${t})`,className:"ga-glyph"})}function B0({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 q0(){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 oi({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:vb[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 hi({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 Pd({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(EO,{x:e+118,y:t-13,on:!0})]})}function dY(){return a.jsxs(Vn,{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 hY(){return a.jsxs(Vn,{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(oi,{x:20,y:80,w:116,title:"main",sub:"Opus 5 · 9 tools",tone:"accent"}),a.jsx(oi,{x:196,y:18,w:112,title:"explore",sub:"Haiku · 14 tools",tone:"flight"}),a.jsx(oi,{x:196,y:80,w:112,title:"tests",sub:"Sonnet · 6 tools",tone:"flight"}),a.jsx(oi,{x:196,y:142,w:112,title:"review",sub:"done · 38s",tone:"ok"}),a.jsx(hi,{x:326,y:28,label:"Read"}),a.jsx(hi,{x:380,y:28,label:"Grep",live:!0}),a.jsx(hi,{x:326,y:90,label:"Bash",live:!0})]})}function a_({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 fY(){return a.jsxs(Vn,{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(a_,{x:216,y:80,label:"5-hour window",pct:24,note:"resets in 53m"}),a.jsx(a_,{x:216,y:124,label:"7-day window",pct:61,note:"resets in 4d"})]})}function pY(){return a.jsxs(Vn,{children:[a.jsx("rect",{x:14,y:40,width:172,height:120,rx:10,className:"ga-canvas"}),a.jsx(oi,{x:30,y:80,w:140,title:"tests",sub:"Sonnet 5 · 6 tools",tone:"flight"}),a.jsx(B0,{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(Hn,{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(hi,{x:214,y:122,label:"Read"}),a.jsx(hi,{x:266,y:122,label:"Edit"}),a.jsx(hi,{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 mY(){const e=[18,24,28,14,22,26,30,16,24,28,20,26];return a.jsxs(Vn,{children:[a.jsx(Hn,{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 gY(){return a.jsxs(Vn,{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(oi,{x:278,y:80,w:120,title:"my-project",sub:"Opus 5 · live",tone:"accent"})})]})}function yY(){return a.jsxs(Vn,{children:[a.jsx(Hn,{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(s_,{x:196,y:33,d:"M7 2.2v9.6M2.2 7h9.6"}),a.jsx(s_,{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(gr,{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(gr,{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(B0,{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(Hn,{x:282,y:62,w:144,h:64,label:"ANOTHER MACHINE"}),a.jsx("g",{className:"ga-pop",children:a.jsx(gr,{x:296,y:92,email:"work@team.dev",state:"shared here",tone:"ok"})})]})}function wY(){return a.jsxs(Vn,{children:[a.jsx(Hn,{x:14,label:"THIS MACHINE"}),a.jsx(Pd,{x:28,y:60}),a.jsx("g",{className:"ga-swap-out",children:a.jsx(gr,{x:28,y:98,email:"work@team.dev",state:"login expired",tone:"warn"})}),a.jsx("g",{className:"ga-swap-in",children:a.jsx(gr,{x:28,y:98,email:"work@team.dev",state:"working again",tone:"ok",bars:[24,61]})}),a.jsx(Hn,{x:250,label:"ANOTHER MACHINE"}),a.jsx(Pd,{x:264,y:60}),a.jsx(gr,{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(q0,{})})]})}const vY=[{art:a.jsx(dY,{}),line:"Sessions waiting on you top the session list, longest wait first.",tip:"A tone and a system notification when one stops to ask. Both behind the topbar gear."},{art:a.jsx(hY,{}),line:"Every agent and subagent is a node. Tool calls light up as they run."},{art:a.jsx(pY,{}),line:"Double-click any node: its prompt, every tool call, tokens and timing."},{art:a.jsx(fY,{}),line:"What each session costs, and how much quota is left."},{art:a.jsx(mY,{}),line:"Cores, memory and heat while the agents run, and what is hogging them."},{art:a.jsx(yY,{}),line:"Several Claude accounts: switch, add one, share one to another machine."},{art:a.jsx(wY,{}),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(gY,{}),line:"Run claude or codex in any folder. It shows up here on its own."}];function xY(){return a.jsxs(Vn,{children:[a.jsx(Hn,{x:14,label:"THIS MACHINE"}),a.jsx(gr,{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(Hn,{x:250,label:"ANOTHER MACHINE"}),a.jsx(gr,{x:264,y:64,email:"work@team.dev",state:"working",tone:"ok",bars:[24,61]})]})}function bY(){return a.jsxs(Vn,{children:[a.jsx(Hn,{x:14,label:"THIS MACHINE"}),a.jsx(Pd,{x:28,y:60}),a.jsx(Gu,{x:28,y:92,name:"Ana's MacBook"}),a.jsx(Gu,{x:28,y:114,name:"Dorin's PC"}),a.jsx(Hn,{x:250,label:"ANOTHER MACHINE"}),a.jsx(Pd,{x:264,y:60}),a.jsx(Gu,{x:264,y:92,name:"Your MacBook"}),a.jsx(Gu,{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 kY(){return a.jsxs(Vn,{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(r_,{x:106,y:88,on:!0}),a.jsx("text",{x:126,y:98,className:"ga-t ga-mono",children:"work@team.dev"}),a.jsx(r_,{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(EO,{x:304,y:157,on:!0}),a.jsx(B0,{x:115,y:97})]})}function NY(){return a.jsxs(Vn,{children:[a.jsx(Hn,{x:14,label:"THIS MACHINE"}),a.jsx("g",{className:"ga-swap-out",children:a.jsx(gr,{x:28,y:64,email:"work@team.dev",state:"login expired",tone:"warn"})}),a.jsx("g",{className:"ga-swap-in",children:a.jsx(gr,{x:28,y:64,email:"work@team.dev",state:"working again",tone:"ok",bars:[24,61]})}),a.jsx(Hn,{x:250,label:"ANOTHER MACHINE"}),a.jsx(gr,{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(q0,{})})]})}const jY=[{art:a.jsx(xY,{}),line:"A login can expire on one machine while it still works on another."},{art:a.jsx(bY,{}),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(kY,{}),line:"Tick which logins this machine may hand out. Nothing is shared until you do."},{art:a.jsx(NY,{}),line:"An expired login is copied from a paired machine within a minute."}];function SY(){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(q0,{})})]})}const _Y={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."},EY=1600;function TO({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 io(o.join(`
93
- `))&&s.current&&(r(!0),window.setTimeout(()=>{s.current&&r(!1)},EY))},[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:_Y[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 TY(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 CY(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 em(e,t){return(await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).json().catch(()=>null)}const AY={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."},RY={not_running:"This deck is not on the network yet. Turn Local network on, then make one."};function o_(e,t,n){return(t==null?void 0:t.reason)&&e[t.reason]||Ct(n,t)}function MY({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=dt(r,{focusRef:h?l:o}),p=gt(r),[g,v]=y.useState(""),[j,k]=y.useState(""),[x,N]=y.useState(null),[b,S]=y.useState(null),[E,R]=y.useState(null),[O,A]=y.useState(null),[q,I]=y.useState(()=>Date.now());y.useEffect(()=>{const Y=window.setInterval(()=>I(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=>wh(L.current)?(L.current=Y,R(Y),!0):!1,[]),C=y.useCallback(()=>{L.current=null,B.current&&R(null)},[]),$=Y=>{const X=fa(E,Y);return{disabled:X.disabled,"aria-busy":X.busy}},P=Y=>(x==null?void 0:x.field)===Y?{"aria-invalid":!0,"aria-describedby":"lan-add-failure"}:{},K=Y=>N(X=>X&&X.field===Y?null:X),G=y.useCallback(async()=>{if(h)return;const Y=TY(g);if(!Y){N({text:$Y(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 em("/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{C()}},[g,h,t,e.peers,s,r,F,C]),U=y.useCallback(async Y=>{if(!F(`invite:${Y}`))return;const X=Y==="make"?"make an invite":"cancel that invite";try{const ee=await em("/api/lan/invite",{action:Y});if(!B.current)return;ee!=null&&ee.ok?(M.current=Y,N(null),S(null),s()):N({text:o_(RY,ee,X)})}catch{B.current&&N({text:Ct(X,null)})}finally{C()}},[s,F,C]),W=y.useCallback(async()=>{const Y=j.trim();if(!(!Y||!F("join"))){A(null);try{const X=await em("/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:o_(AY,X,"use that invite"),field:"join"}))}catch{B.current&&N({text:Ct("use that invite",null),field:"join"})}finally{C()}}},[j,s,r,F,C]),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."})}},[]),H=e.invite&&e.invite.expiresAt>q?e.invite:null,J=y.useRef(!1);y.useEffect(()=>{n!=="invite"||J.current||H||(J.current=!0,U("make"))},[n,H,U]);const V=y.useRef(!1);y.useEffect(()=>{var Y;n!=="invite"||V.current||!H||(V.current=!0,(Y=c.current)==null||Y.focus())},[n,H]),y.useEffect(()=>{var X,ee;const Y=M.current;!Y||Y==="make"!=!!H||(M.current=null,En(((X=document.activeElement)==null?void 0:X.tagName)??null)&&((ee=(Y==="make"?c:d).current)==null||ee.focus()))},[H]);const Z=e.port!=null?(e.addrs??[]).map(Y=>`${Y}:${e.port}`):[];return Dt.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(TO,{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,...P("addr"),onChange:Y=>{v(Y.target.value),K("addr")},onKeyDown:Y=>{Y.key==="Enter"&&G()}}),g.trim()!==""&&a.jsx("button",{type:"button",className:"ap-manage-btn",...$("add"),onClick:()=>void G(),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",...$("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",!H&&a.jsx("button",{type:"button",className:"ap-lan-word lan-h-act",ref:d,...$("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,...P("join"),onChange:Y=>{k(Y.target.value),A(null),K("join")},onKeyDown:Y=>{Y.key==="Enter"&&W()}}),j.trim()!==""&&a.jsx("button",{type:"button",className:"ap-manage-btn",...$("join"),onClick:()=>void W(),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."}),O&&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."}),O.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))]}),H&&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:[CY(H.expiresAt,q)," left"]})]}),a.jsx("code",{className:"ap-lan-token",children:H.token}),a.jsxs("div",{className:"ap-lan-acts",children:[a.jsx("button",{type:"button",className:"ap-manage-btn",ref:c,...$("copy:invite"),"aria-label":b==="invite"?"Invite copied":"Copy invite","aria-describedby":"lan-invite-left",onClick:()=>void D(H.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",...$("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 $Y(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 IY({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 OY({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 LY(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 PY({on:e,status:t}){return a.jsxs(a.Fragment,{children:[e&&a.jsx(TO,{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:LY(t)})]})}const i_=["online","offline","loose"],DY={online:0,offline:1,loose:2};function FY(e){return e.kind==="declined"?null:e.kind==="paired"?e.here?"online":"offline":"loose"}const BY=76,qY=62,Dd=96,UY={1:[.62],2:[.58,1],3:[.42,.72,1]},zY=.2,WY=.16,HY=.05,VY=20,GY=17,Ku=7,KY=30,YY=116,XY=6.6,ZY=6,JY=e=>U0(e,null),QY=1.5,eX=80,tX=.45,l_=40,nX=64,rX=150,c_=.3,u_=84,d_=8,sX=1.3,Fd=6,aX=5.94,h_=7,f_=16,Tl=4,p_=.16;function xb(e,t){return Math.PI*(3*(e+t)-Math.sqrt((3*e+t)*(e+3*t)))}function CO(e,t){return t<-Math.abs(e)*.6?"top":"bottom"}function oX(e,t){if(e<=2)return t%2===0?0:90;const n=360/e;return-90+(t%2===0?0:n/2)}function iX(e){return e.map((t,n)=>({...t,i:n})).sort((t,n)=>i_.indexOf(t.tier)-i_.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 m_(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 lX(e,t,n){const r=[...UY[e.length]??[]];for(let s=0;s<r.length;s++){const o=e[s];if(o<2)continue;const l=xb(t*r[s],n*r[s])/o;if(!(l>0)||l>=Dd)continue;const c=s+1<r.length?r[s+1]-zY:1;r[s]=Math.max(r[s],Math.min(c,r[s]*(Dd/l)*1.02))}return r}const qa=(e,t)=>e.x0<t.x1&&t.x0<e.x1&&e.y0<t.y1&&t.y0<e.y1,tm={h:16,ch:6.1,maxW:100};function cX(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 AO(e,t,n,r,s,o){const l=t==="loose"?GY:VY,c=!s||e.kind==="asks",d=c?KY:tm.h,h=s?tm.ch:XY,f=c?o.length:0,p=Math.min(s?tm.maxW:YY,Math.max(2*l,MO(e).length*h,f*ZY)),g={x0:n-l,y0:r-l,x1:n+l,y1:r+l},v=CO(n,r)==="top"?{x0:n-p/2,y0:r-l-Ku-d,x1:n+p/2,y1:r-l-Ku}:{x0:n-p/2,y0:r+l+Ku,x1:n+p/2,y1:r+l+Ku+d};return[g,v]}const bb=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]},Yu=(e,t)=>((e-t)%360+540)%360-180;function g_(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]=bb(f);return AO(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*QY,j=r.get(f.ring),k=(f.count>2?360/f.count:f.turn)*tX,x=j[(f.index+1)%f.count],N=j[(f.index-1+f.count)%f.count];return!(x===f||(p>0?Yu(x.theta,v)>=k:Yu(v,N.theta)>=k))||v<f.lo||v>f.hi?!1:(f.theta=v,!0)},l=([f,p],[g,v])=>qa(p,g)||qa(v,f)||qa(p,v)||qa(f,g),c=([f,p])=>qa(f,n)||qa(p,n);for(let f=0;f<eX;f++){const p=s();let g=!1;for(let v=0;v<e.length;v++){c(p[v])&&(g=o(e[v],Yu(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=Yu(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 uX={online:0,offline:1,loose:1};function dX(e,t,n,r="",s=JY){const o=[];for(const l of[!0,!1]){const c=y_(e,t,n,r,DY,s,l);if(c.clashes===0)return c.named();if(o.push(c),c.layout.rings.length===3){const d=y_(e,t,n,r,uX,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 y_(e,t,n,r,s,o,l=!0){const c=new Map;for(const F of e){const C=FY(F);if(!C)continue;const $=s[C];c.has($)||c.set($,[]),c.get($).push({row:F,tier:C})}const d=[...c.keys()].sort((F,C)=>F-C),h=Math.max(0,t/2-BY),f=Math.max(0,n/2-qY),p=lX(d.map(F=>c.get(F).length),h,f),g=d.map((F,C)=>({ring:F,rx:h*p[C],ry:f*p[C],count:c.get(F).length})),v=g.reduce((F,C)=>F+C.count,0),j=F=>F.row.via==="tailscale",k=[...c.values()].flat().filter(j).length,x=Math.max(0,...g.map(F=>{const C=c.get(F.ring).filter(j).length,$=xb(F.rx,F.ry);return C>0&&$>0?C*Dd*sX/$*360:0})),N=l&&k>0&&k<v?Math.min(rX,Math.max(nX,k/v*360,x)):0,b=l_-N/2,S=l_+N/2,E=[];let R=!1;g.forEach((F,C)=>{const $=iX(c.get(F.ring)),P=$.length,K=P>1&&xb(F.rx,F.ry)/P<Dd;K&&(R=!0);const G=C===g.length-1,U=G?-p_*(p[C]-(p[C-1]??0)):p_*(p[C+1]-p[C]),W=N>0?[{members:$.filter(H=>H.row.via!=="tailscale"),from:S,width:360-N},{members:$.filter(H=>H.row.via==="tailscale"),from:b+360,width:N}]:[{members:$,from:null,width:360}];let D=0;for(const H of W){const J=H.members.length;if(J===0)continue;const V=H.width/J,Z=J>2;H.members.forEach(({row:Y,tier:X},ee)=>{const ae=cr(Y),ue=H.from==null?oX(J,C)+V*ee:H.from+V*(ee+.5),ge=Z?m_(ae,1)*WY*V:0,ye=K&&D%2===1?1+U/p[C]:1,se=Z?m_(ae,2)*HY:0,me=V*.3;E.push({row:Y,tier:X,ring:F,index:D,count:P,theta:ue+ge,reach:ye*(1+(G?-Math.abs(se):se)),lo:H.from==null?-1/0:H.from+me,hi:H.from==null?1/0:H.from+H.width-me,turn:V,caption:o(Y)}),D++})}});const O=cX(r);let A=g_(E,R,O);A>0&&!R&&(R=!0,A=g_(E,!0,O));const q=E.map((F,C)=>{const[$,P]=bb(F);return{row:F.row,tier:F.tier,ring:F.ring.ring,x:$,y:P,angle:hX(Math.atan2(P,$)*180/Math.PI),dist:Math.hypot($,P),side:CO($,P),order:C}}),I=g.reduce((F,C,$)=>c.get(C.ring).some(j)?Math.max(F,p[$]):F,0),B=F=>({from:b,to:S,inner:{rx:h*c_,ry:f*c_},outer:{rx:Math.min(t/2-8,h*I+F),ry:Math.min(n/2-8,f*I+F)},count:k}),L={nodes:q,rings:g,dense:R,zone:N>0?{...B(u_),labelAt:null}:null};return{layout:L,clashes:A,named:()=>{if(!L.zone)return L;const F=E.flatMap(P=>{const[K,G]=bb(P);return AO(P.row,P.tier,K,G,R,P.caption)});let C={...L.zone,labelAt:w_(L.zone,F)},$=C.outer;for(let P=u_+d_;C.labelAt==null;P+=d_){const K=B(P);if(K.outer.rx===$.rx&&K.outer.ry===$.ry)break;$=K.outer;const G=w_(K,F);G!=null&&(C={...K,labelAt:G})}return{...L,zone:C}}}}function RO(e){return`Tailscale · ${e} deck${e===1?"":"s"}`}function w_(e,t){const n={rx:e.outer.rx-Fd,ry:e.outer.ry-Fd};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=h_+Tl,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-Tl,y0:b.y0-Tl,x1:b.x1+Tl,y1:b.y1+Tl})).filter(b=>qa(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 O=!1;for(let A=0;A<=h_&&!O;A+=1.75)O=d(b-b/R*A,S-S/R*A);h.push(p),f.push((f.at(-1)??0)+(O?1:0))});const g=RO(e.count).length*aX/2,v=g+f_,j=p-g-f_;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 hX(e){return(e%360+360)%360}function fX(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 pX(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 U0(e,t){switch(e.kind){case"asks":return"wants to pair";case"nearby":return e.state;case"dialling":return $O(e)?`${e.name.slice(e.addr.length)} · dialling`:"dialling";case"declined":return"declined";case"paired":{if(e.here)return t?mX(t):"online";const n=OO(e);return n?n==="now"?"away · just now":`away · ${n}`:e.state.startsWith("one-way")?"has not called yet":"away"}}}function MO(e){return $O(e)?e.addr:e.name}function $O(e){return e.kind==="dialling"&&!!e.addr&&e.name.startsWith(`${e.addr}:`)}function IO(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=OO(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 OO(e){var t;return((t=/last online (.+)$/.exec(e.state))==null?void 0:t[1])??null}function mX(e){return e.trim().split(/\s+/).slice(0,2).join(" ")}function gX(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 cr(e){let t=e.fp;for(const n of e.twins??[])n.fp<t&&(t=n.fp);return t}function yX(e,t){if(e==null)return t;const n=((t-e)%360+540)%360-180;return e+n}function wX(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} ${LO}`:e.nearby===1?`${n} Open it to ask to pair.`:`${n} Open one to ask to pair.`}return null}const LO="This deck pairs by invite only. Send one from Add a deck.";function vX(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"?LO:"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 xX(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 bX(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 kX(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 NX(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=kX(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 jX=1e3;function SX(e,t){const n=new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),r=Ur(e,t);return`${n} · ${r==="now"?"just now":r}`}function kb(e){return e&&[e.version,e.os,e.arch].filter(Boolean).join(" · ")||null}const PO={works:"works here",expired:"expired here",missing:"not on this deck",unavailable:"cannot share here"},DO={works:"works there",broken:"broken there",unavailable:"cannot share there",unknown:"not offered by that deck"};function FO(e){const t=e.in&&e.out?"offered both ways":e.in?"offered by that deck":"offered by this deck";return`${PO[e.here]}, ${DO[e.there]}, ${t}${e.usedThere?", in use there":""}.`}function BO({row:e,source:t,status:n,accounts:r,now:s}){var X,ee,ae,ue,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=kb(n.about),x=kb(g),N=g!=null&&g.version&&v?bX(g.version,v):null,b=o?Nh(o.last,s):null,S=o&&((ee=o.last)!=null&&ee.error)?DK({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=((ue=o==null?void 0:o.last)==null?void 0:ue.done)??[],O=!!b&&!!E&&!e.quiet&&e.state.startsWith(b.text),A=c||e.kind==="dialling",q=((o==null?void 0:o.via)??e.via)==="tailscale",I=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,C=!!M&&"hidden"in M,$=!!M&&"other"in M,P=(n.shared??[]).filter(ye=>{var se;return!((se=o==null?void 0:o.notOffered)!=null&&se.includes(ye))}),K=c?NX((L==null?void 0:L.accounts)??null,r,P,F):[],G=K.filter(ye=>ye.in==null&&ye.out==="cut"),U=K.some(ye=>ye.in!=null),W=K.some(ye=>ye.out!=null),D=new Set((n.peers??[]).filter(ye=>ye.paired).flatMap(ye=>ye.notOffered??[])),H=K.some(ye=>ye.out!=null&&D.has(ye.key))?"decks you chose":"every paired deck",J=new Map(R.map(ye=>[ye.email,ye])),V=R.filter(ye=>!K.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>jX?Ur(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:O,showRound:A,how:I,link:B,hiddenThere:C,otherThere:$,lanes:K,spent:G,taking:U,giving:W,givenTo:H,told:J,unplaced:V,unknown:Z,stale:Y}}function Nb(){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 Xu({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 _X({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:O,lanes:A,spent:q,taking:I,giving:B,givenTo:L,told:M,unplaced:F,unknown:C,stale:$}=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"}),O&&a.jsx("span",{className:"lan-end-note",children:"on another account"})]})]}),a.jsxs("div",{className:"lan-link",children:[a.jsx(Nb,{}),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(Nb,{}),(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(P=>{const K=mb(P);return a.jsxs("li",{"data-ok":P.ok&&!K,children:[P.email," ",a.jsxs("span",{className:"lan-done-what",children:[P.ok?"arrived":"did not arrive",K&&` — ${K.long}`]})]},`${P.email}:${P.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((P,K)=>{const G=M.get(P.email),U=G?mb(G):null,W=P.out==="live"||P.in!=null&&P.in!=="cut";return a.jsxs("li",{role:"listitem",className:"lan-lane","data-tone":P.tone,"data-draw":P.in&&P.out?"both":P.in?"in":"out","data-used-there":P.usedThere||void 0,style:{"--i":K},children:[a.jsx("i",{className:"lan-pip","data-end":"here","data-state":P.here,"aria-hidden":!0}),a.jsxs("span",{className:"lan-track",children:[a.jsxs("span",{className:"lan-wire","data-flow":W?"live":"cut","aria-hidden":!0,children:[(P.in==="live"||P.in==="wait")&&a.jsx("i",{className:"lan-glint","data-dir":"in","data-tone":P.in}),P.out==="live"&&a.jsx("i",{className:"lan-glint","data-dir":"out"})]}),P.in&&P.in!=="cut"&&a.jsx(Xu,{dir:"in"}),P.out==="live"&&a.jsx(Xu,{dir:"out"}),a.jsx("span",{className:"lan-lane-email",children:P.email})]}),a.jsx("i",{className:"lan-pip","data-end":"there","data-state":P.there,"aria-hidden":!0}),a.jsx("span",{className:"vis-hidden",children:FO(P)}),(P.caption||G)&&a.jsxs("span",{className:"lan-lane-note",children:[P.caption,P.caption&&G&&" · ",G&&a.jsxs("span",{className:"lan-lane-done","data-ok":G.ok&&!U,children:[G.ok?"arrived last round":"did not arrive last round",U&&` — ${U.long}`]})]})]},P.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."]}),C&&a.jsx("p",{className:"lan-empty",children:C}),$&&a.jsxs("p",{className:"lan-stale",children:["As of ",$==="now"?"just now":$,", when it last answered."]}),a.jsxs("div",{className:"lan-legend",children:[I&&a.jsxs("span",{className:"lan-key",children:[a.jsx("span",{className:"lan-key-wire","data-dir":"in","aria-hidden":!0,children:a.jsx(Xu,{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(Xu,{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 EX=20,TX=17,v_=34,CX=160,AX=80,RX=200,MX=8,$X=14,IX=10,OX=.61803398875;function LX({status:e,rows:t,accounts:n,now:r,covered:s,onOpenDeck:o,onClose:l}){const c=y.useRef(null),d=dt(l,{focusRef:c}),h=gt(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 me=null;const pe=()=>{const fe=Math.round(se.clientWidth),ne=Math.round(se.clientHeight);me&&me.w===fe&&me.h===ne||(me&&(j(!0),k.current!=null&&window.clearTimeout(k.current),k.current=window.setTimeout(()=>j(!1),RX)),me={w:fe,h:ne},g(me))};if(pe(),typeof ResizeObserver>"u")return;const de=new ResizeObserver(pe);return de.observe(se),()=>{de.disconnect(),k.current!=null&&window.clearTimeout(k.current)}},[]);const x=y.useMemo(()=>p?dX(t,p.w,p.h,(e==null?void 0:e.name)??"",se=>{var me,pe;return U0(se,(pe=(me=cc(e,se).peer)==null?void 0:me.about)==null?void 0:pe.os)}):null,[t,p,e]),N=y.useMemo(()=>fX(t),[t]),b=(x==null?void 0:x.nodes)??[],S=y.useRef(new Map),E=y.useMemo(()=>{const se=new Map;for(const me of b){const pe=cr(me.row);se.set(pe,yX(S.current.get(pe),me.angle))}return S.current=se,se},[b]),[R,O]=y.useState(null),[A,q]=y.useState(null),[I,B]=y.useState("none"),L=y.useRef(null),M=y.useCallback((se,me)=>{L.current!==se&&(L.current=se,B(me),q(se))},[]),F=y.useRef(null),C=y.useRef(null),$=y.useCallback(()=>{C.current!=null&&window.clearTimeout(C.current),C.current=null},[]),P=y.useCallback((se,me)=>{if(F.current!=null&&window.clearTimeout(F.current),F.current=null,$(),O(se),me==="keyboard"){M(se,"none");return}C.current=window.setTimeout(()=>M(se,L.current?"swap":"full"),AX)},[M,$]),K=y.useCallback(()=>{F.current!=null&&window.clearTimeout(F.current),$(),F.current=window.setTimeout(()=>O(null),CX)},[$]);y.useEffect(()=>()=>{F.current!=null&&window.clearTimeout(F.current),$()},[$]);const G=R&&b.some(se=>cr(se.row)===R)?R:null,U=A?t.find(se=>cr(se)===A)??null:null;y.useEffect(()=>{A&&!U&&M(null,"swap")},[A,U,M]);const[W,D]=y.useState(null),H=y.useRef(new Map),J=b.findIndex(se=>cr(se.row)===W),V=J<0?0:J,Z=se=>{var fe;if(b.length===0)return;const me=se.key==="ArrowRight"||se.key==="ArrowDown"?1:se.key==="ArrowLeft"||se.key==="ArrowUp"?-1:0,pe=se.key==="Home"?0:se.key==="End"?b.length-1:me?(V+me+b.length)%b.length:null;if(pe==null)return;se.preventDefault();const de=cr(b[pe].row);D(de),(fe=H.current.get(de))==null||fe.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?pX(N):"Local network is off":"checking…",ue=()=>{$(),M(null,"swap"),O(null)},ge=G?b.find(se=>cr(se.row)===G)??null:null,ye=()=>{var se;A&&((se=H.current.get(A))==null||se.focus()),ue()};return Dt.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":G?"":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&&ue()},children:p&&x&&a.jsxs(a.Fragment,{children:[a.jsx(PX,{layout:x,w:p.w,h:p.h}),b.map(se=>{const me=cr(se.row);return a.jsx(BX,{node:se,angle:E.get(me)??se.angle,lit:G===me},me)}),a.jsx(qX,{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,me)=>{var de,fe;const pe=cr(se.row);return a.jsx(UX,{node:se,angle:E.get(pe)??se.angle,os:(fe=(de=cc(e,se.row).peer)==null?void 0:de.about)==null?void 0:fe.os,lit:G===pe,shown:A===pe,tabbable:me===V,register:ne=>{ne?H.current.set(pe,ne):H.current.delete(pe)},onHold:ne=>{D(pe),P(pe,ne)},onRelease:K,onOpen:()=>o(se.row.fp)},pe)})}),b.length===0&&a.jsx(zX,{status:e})]})}),a.jsx(WX,{slice:(x==null?void 0:x.zone)!=null})]}),a.jsx("aside",{className:"nm-side","aria-label":"Details",children:U&&e?a.jsx(VX,{row:U,status:e,accounts:n,now:r,entrance:I,onOpen:()=>o(U.fp),onBack:ye},cr(U)):a.jsx(HX,{status:e,summary:N,entrance:I,slice:(x==null?void 0:x.zone)!=null})})]})]})}),document.body)}function qO(){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 PX({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:FX(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:DX(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:RO(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 x_(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 DX(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=IX,h=$X,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 FX(e,t,n){const r={rx:e.outer.rx-Fd,ry:e.outer.ry-Fd},s=e.to-e.from>180?1:0;return`M${x_(r,t,n,e.to)} A${r.rx.toFixed(1)},${r.ry.toFixed(1)} 0 ${s} 0 ${x_(r,t,n,e.from)}`}function BX({node:e,angle:t,lit:n}){const r=e.row.kind==="paired"&&e.row.here,s=e.order*OX%1*MX;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":`${v_}px`,"--gap":`${v_+(e.tier==="loose"?TX:EX)}px`,"--i":e.order,"--phase":`${s.toFixed(2)}s`},children:r&&a.jsx("i",{className:"nm-glint"})})}function qX({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 UX({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-${GX(cr(f))}`,g=e.angle*Math.PI/180,v=U0(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}: ${IO(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(Nb,{}),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:MO(f)}),a.jsx("span",{className:"nm-cap",children:v})]}),e.tier==="online"&&a.jsx("span",{id:p,className:"vis-hidden",children:v})]})}function zX({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 WX({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 UO({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 HX({status:e,summary:t,entrance:n,slice:r}){const s=gX(e),o=kb(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=wX(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(UO,{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 VX({row:e,status:t,accounts:n,now:r,entrance:s,onOpen:o,onBack:l}){var x;const c=BO({row:e,source:cc(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=vX(e,t.pairingMode),p=xX(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:IO(e)}),f&&a.jsx("p",{className:"nm-next",children:f}),d.length>0&&a.jsx(UO,{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}),b_(N)&&a.jsx("span",{className:"nm-lane-said","aria-hidden":!0,children:b_(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,": ",FO(N)]})]},N.key))}),k&&a.jsx("p",{className:"nm-panel-hint",children:k})]})]})}function b_(e){return e.caption?e.caption:e.tone==="ok"?null:`${PO[e.here]} · ${DO[e.there]}`}function GX(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 KX=6;function YX({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,KX),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=A0(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]),Dt.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 XX({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(NO)},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(qO,{})}),s&&a.jsx(YX,{anchorId:"ap-lan-entry",id:"ap-lan-peek",rows:t,onHold:c,onLet:l})]})}function ZX({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=ao({armedFor:s?e.fp:null,target:e.fp,armedAt:l.current,now:p,gapMs:so});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=ao({armedFor:c,target:p,armedAt:l.current,now:g,gapMs:so});if(v==="arm"){d(p),o(!1),l.current=g;return}v!=="ignore"&&(d(null),t(()=>r(p)))}}}function JX({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 QX({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?Ur(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 eZ(){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 tZ({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=dt(l,{focusRef:j}),x=gt(l),[N,b]=y.useState(null),[S,E]=y.useState(null),[R,O]=y.useState(!1),[A,q]=y.useState(0),I=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=I.current)==null||se.select())},[M]);const F=y.useRef(!1);y.useEffect(()=>{var se,me;F.current&&!M&&En(((se=document.activeElement)==null?void 0:se.tagName)??null)&&((me=B.current)==null||me.focus()),F.current=M},[M]);const C=se=>{const me=fa(o,se);return{disabled:me.disabled,"aria-busy":me.busy}},$=async se=>{const me=await se();return L.current&&E(me),me==null},{armed:P,armedTwin:K,pressOwn:G,pressTwin:U}=ZX({row:e,run:$,onVerb:h,onUnpair:v}),W=BO({row:e,source:t,status:n,accounts:r,now:s}),{peer:D,stranger:H,paired:J,own:V,canRename:Z,fp:Y}=W,X=o===`check:${e.fp}`,ee=async se=>{const me=se.trim()===V?"":se;await $(()=>c(me))&&b(null)},ae=()=>void $(d).then(se=>{se&&L.current&&q(me=>me+1)}),ue=async()=>{if(Y)try{if(await navigator.clipboard.writeText(Y),!L.current)return;O(!0),window.setTimeout(()=>{L.current&&O(!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:SX(D.pairedAt,s),tone:"meta"}):e.kind==="declined"&&H&&ge.push({label:"Paired",value:`no · you said no ${F0(H.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 ue(),"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 Dt.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:I,className:"ap-manage-input lan-peer-input",value:N??"",maxLength:48,placeholder:V,"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",...C(`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(eZ,{})})]}),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",...C(`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(_X,{view:W,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(QX,{instances:ye,now:s,busy:o,press:C,armedTwin:K,pressTwin:U,onUnpair:v})]}),a.jsx(JX,{row:e,paired:J,peer:D,status:n,busy:o,press:C,checkNow:ae,armed:P,pressOwn:G,run:$,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,En(((r=document.activeElement)==null?void 0:r.tagName)??null)&&(typeof t=="function"?t():(s=t.current)==null||s.focus()))},[e]),()=>{n.current=!0}}function nZ(e,t){if(e.length!==t.length)return!1;const n=new Set(e);return t.every(r=>n.has(r))}function rZ(e,t,n,r){const s=new Set(e??t);return r?s.add(n):s.delete(n),[...s]}function k_(e,t,n){return e==null||n!=null&&!n.ok||nZ(e,t)?null:e}function zO({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 nY();o.current=!1,l.current&&(s(!1),h.current=document.activeElement===c.current,n(sY(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 sZ(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 Zu="Paused while this deck pairs only by invite. Turn that off above to use it.";function aZ({status:e,accounts:t,onClose:n,onChanged:r}){Ut("lan-setup");const s=dt(n),o=gt(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 W=fa(g,U);return{disabled:W.disabled,"aria-busy":W.busy}},x=y.useRef(null),N=y.useRef(!0);y.useEffect(()=>()=>{N.current=!1},[]),y.useEffect(()=>{x.current=k_(x.current,e.shared??[],null)},[e.shared]);const b=y.useCallback(async(U,W,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(ur(Ct(W,J),J)),r(),(J==null?void 0:J.ok)===!0):!1}catch{return N.current&&h(ur(Ct(W,null))),!1}finally{j.current=null,N.current&&v(null)}},[r]),S=y.useCallback(async U=>{const W=await b({name:U},"save the name","name");return W&&N.current&&c(D=>D===U?null:D),W},[b]),E=y.useRef(null),R=l!=null&&l!==(e.name??""),O=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 io(e.fp);if(N.current){if(!U){h(ur("Could not copy it — select the fingerprint and copy it by hand."));return}p(!0),window.setTimeout(()=>{N.current&&p(!1)},1600)}},I=new Set(x.current??e.shared??[]),B=e.autoAsk!==!1,L=e.autoAccept!==!1,M=e.pairingMode==="invite",F=U=>{const W=k(U);return{...W,disabled:W.disabled||M}},C=e.shareActive!==!1,$=e.tailscale??null,P=!!($!=null&&$.on),K=($==null?void 0:$.ask)!==!1,G=($==null?void 0:$.accept)!==!1;return Dt.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(zO,{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:()=>{O(),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:I.has(U.key),onChange:W=>{const D=rZ(x.current,e.shared??[],U.key,W.target.checked);x.current=D,b({shared:D},W.target.checked?"share that account":"stop sharing that account").then(H=>{x.current===D&&(x.current=k_(D,e.shared??[],{ok:H}))})}}),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":C,"aria-label":"Show paired decks which of these this deck is using",...k("current"),onClick:()=>void b({shareActive:!C},C?"stop showing which account this deck is using":"show which account this deck is using","current"),title:C?"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?Zu: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?Zu: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"})})]})]})]})]}),($==null?void 0:$.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:sZ($)})]}),a.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":P,"aria-label":"Look for my devices over Tailscale","aria-describedby":"lan-ts-detail",...k("tailscale"),onClick:()=>void b({tailscale:!P},P?"stop looking over Tailscale":"look for your devices over Tailscale","tailscale"),title:P?"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"})})]}),P&&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":K,"aria-label":"Ask each of my devices it finds over Tailscale",...F("tailscale-ask"),onClick:()=>void b({tailscaleAsk:!K},K?"stop asking your devices automatically":"ask your devices automatically","tailscale-ask"),title:M?Zu:K?"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":G,"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:!G},G?"stop accepting your devices automatically":"accept your devices automatically","tailscale-accept"),title:M?Zu:G?"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 oZ({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(qO,{})}),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 iZ({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=eY(),[j,k]=y.useState(!1),{status:x,manual:N,now:b,busy:S,failure:E,dismissFailure:R,answerGiveBack:O,pressProps:A,load:q,toggle:I,answer:B,dropAddress:L,rename:M,checkOne:F,checkNow:C}=cY(t,()=>d(!0)),{armed:$,pressUnpair:P}=uY(B),[K,G]=y.useState(null),[U,W]=y.useState(!1),D=y.useMemo(()=>e.filter(pe=>JK(pe.key,x??null,b)).map(pe=>pe.key).sort().join(`
95
- `),[e,x,b]);y.useEffect(()=>{n==null||n(D?D.split(`
96
- `):[])},[D,n]);const H=(x==null?void 0:x.enabled)===!0,J=y.useMemo(()=>UK((x==null?void 0:x.pairingMode)==="invite"&&x?{...x,pending:[]}:x,b),[x,b]),V=K?J.find(pe=>{var de;return pe.fp===K||((de=pe.twins)==null?void 0:de.some(fe=>fe.fp===K))})??null:null;y.useEffect(()=>{K&&x&&!V&&G(null)},[K,x,V]);const{asks:Z,rest:Y,live:X,folded:ee,troubled:ae,shown:ue,paired:ge}=ZK(J,j),ye=FK(x,b),se=XK(x,J),me=a.jsxs(a.Fragment,{children:[h&&x&&a.jsx(MY,{status:x,manual:N,startWith:h==="invite"?"invite":void 0,onClose:()=>f(!1),onChanged:()=>{q(),t()}}),p&&a.jsx(_O,{title:"How Local network works",steps:jY,finish:H?void 0:{label:"Turn it on",act:()=>{g(!1),I()}},onClose:()=>g(!1)}),c&&x&&a.jsx(aZ,{status:{...x,manualRows:N},accounts:e,manual:N,onClose:()=>d(!1),onChanged:()=>{q(),t()}}),U&&a.jsx(LX,{status:x,rows:J,accounts:e,now:b,covered:!!V||c||!!h||p,onOpenDeck:G,onClose:()=>W(!1)}),V&&x&&a.jsx(tZ,{row:V,source:cc(x,V),status:x,accounts:e,now:b,busy:S,onClose:()=>G(null),onRename:pe=>M(V.fp,pe),onCheck:()=>F(V.fp),onVerb:()=>{switch(V.kind){case"paired":return B("unpair",V.fp,"unpair that deck");case"nearby":return B("accept",V.fp,"reach that deck");case"declined":return B("allow",V.fp,"let that deck ask again");case"dialling":return L(V.fp);default:return Promise.resolve(null)}},onSettings:()=>{G(null),d(!0)},onInvite:()=>{G(null),f("invite")},twins:(V.twins??[]).map(pe=>({row:pe,peer:cc(x,pe).peer??null})),onUnpair:pe=>B("unpair",pe,"unpair that deck")})]});return r?a.jsxs("div",{className:"ap-lan-view",children:[a.jsx(oZ,{on:H,status:x,paired:ge,busy:S,pressProps:A,checkNow:C,setAddOpen:f,setSetupOpen:d,setMapOpen:W,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":H,"aria-label":"Sync with paired decks",...A("switch"),onClick:()=>void I(),title:H?"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(PY,{on:H,status:x}),!H&&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(SY,{}),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(sc,{film:"localNetwork"})]}),a.jsx("p",{className:`ap-lan-status ${ye.tone}`,role:"status",children:ye.tone==="ok"?"":ye.text}),a.jsx(zO,{line:E,onDismiss:R,onAnswer:O}),H&&a.jsxs(a.Fragment,{children:[Z.length>0&&a.jsx(IY,{asks:Z,pressProps:A,answer:B}),ue.length>0&&a.jsx(OY,{rows:ue,pairingMode:x==null?void 0:x.pairingMode,armed:$,pressProps:A,answer:B,dropAddress:L,onUnpair:P,onOpenPeer:G,onInvite:()=>f("invite")}),(X.length>0&&ee.length>0||H&&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(pe=>!pe),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"]})]}),H&&ge>0&&a.jsx("span",{className:"ap-lan-checked",children:BK(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(sc,{film:"localNetwork"})]})]})]})}),me]}):a.jsxs("div",{className:"ap-foot",children:[a.jsx(XX,{entry:se,rows:J,onOpen:s,onMap:H?()=>W(!0):void 0,...v}),a.jsx("p",{className:"vis-hidden",role:"status",children:ye.tone==="ok"?"":ye.text}),me]})}function lZ({anchorId:e,id:t,peers:n,onHold:r,onLet:s}){const o=y.useRef(null),{title:l,shown:c,rest:d}=$K(n),h=y.useCallback(()=>{const f=o.current,p=document.getElementById(e);if(!f||!p)return;f.style.maxHeight="";const g=A0(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]),Dt.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 cZ({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),jO)},N=()=>window.clearTimeout(j.current),b=()=>{window.clearTimeout(j.current),v(!1)},S=RK(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(NO)},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(lZ,{anchorId:"ap-rest-entry",id:"ap-rest-peek",peers:e,onHold:N,onLet:x}),s&&a.jsx(uZ,{order:l,choices:c,onOrder:d,allOpen:h,onToggleAll:f,held:p})]})}function uZ({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===kh?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 dZ(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}const hZ=1800;function fZ({accounts:e,onClose:t,copyText:n}){Ut("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=dt(t,{focusRef:k}),b=gt(t),S=ps(o!=null,k),E=ps(o==null,k);y.useEffect(()=>{if(!o)return;j(Math.floor(Date.now()/1e3));const P=window.setInterval(()=>j(Math.floor(Date.now()/1e3)),1e3);return()=>window.clearInterval(P)},[o]);const R=fK(e),O=pK(e,r),A=O.length===e.length,q=P=>s(K=>mK(K,P)),I=y.useCallback(async()=>{const P=gK(O);if(!pr(x.current)||!P)return;x.current=!0,d(!0),f(null),g(!1);const K=await dZ(P).catch(()=>null);if(x.current=!1,d(!1),!(K!=null&&K.ok)){f(ai(K,"the share could not be made"));return}l({blob:K.blob,expiresAt:K.expiresAt,shared:K.shared??[],failed:K.failed??[]})},[e,O]),B=o?wO(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`,C=M===1?"this is the password":`this is ${M} passwords`,$=o?L?F:`${F} — ${C}`:"";return Dt.createPortal(a.jsx("div",{className:"modal-backdrop",...b,role:"presentation",children:a.jsxs("div",{ref:N,className:"modal sa-modal",onClick:P=>P.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:$}),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),I();return}await n(o.blob)&&(g(!0),window.setTimeout(()=>g(!1),hZ))},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:C})," · ",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(P=>{var G;const K=!!(P.email&&((G=P.detail)!=null&&G.includes(P.email)));return a.jsxs("li",{children:[!K&&a.jsx("span",{className:"sa-who",children:P.email||`account ${P.num}`}),a.jsx("span",{className:"sa-why",children:P.detail||"could not be exported"})]},`${P.num}-${P.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 ",Nt,"?"]}),a.jsx("p",{className:`sa-count${O.length?"":" empty"}`,children:yK(O.length)}),a.jsx("ul",{className:"sa-list sa-pick",children:R.map(P=>a.jsx("li",{children:a.jsxs("label",{className:"sa-row",children:[a.jsx("input",{type:"checkbox",checked:O.includes(P.num),onChange:()=>q(P.num)}),a.jsx("span",{className:"sa-who",children:P.label}),P.sub&&a.jsx("span",{className:"sa-sub",children:P.sub})]})},P.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(P=>P.num):[]),children:A?"Clear all":"Select all"}),a.jsx("button",{type:"button",className:"btn primary",ref:k,...vs(c,!O.length),onClick:()=>{S(),I()},children:c?"making the share…":O.length===0?"Share":O.length===1?"Share 1 account":`Share ${O.length} accounts`})]})]})]})]})}),document.body)}function WO(e,t){var n;return!e.disabled&&!((n=Si(e,t))!=null&&n.blocksSwitch)}function pZ(e,t,n){return e.map(r=>{const s=Si(r,t,n==null?void 0:n(r));return{key:Br(r),name:r.alias??r.email??`account ${r.num}`,ready:WO(r,t),why:r.disabled?"held out":s!=null&&s.blocksSwitch?s.text:null,warn:(s==null?void 0:s.tone)==="warn",headroom:$0(r,t)}})}function mZ(e,t,n){const r=Number(t),s=e&&(n==null?e.headroom:$0(e,n));return s!=null&&Number.isFinite(r)&&100-s>=r}function gZ(e){return(e==null?void 0:e.ok)===!0&&(e.enabled||e.external)}const HO="agent-dag.otherAccountsOrder",VO="agent-dag.otherAccountsOpen";function yZ(){const e=Je(HO);return typeof e=="string"&&e.length>0&&e.length<=64?e:kh}function wZ(e){Ke(HO,e)}function vZ(){const e=Je(VO);if(!e)return db;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 db}function xZ(e){Ke(VO,JSON.stringify({mode:e.mode,keys:e.keys.filter(t=>!t.startsWith("slot:"))}))}function bZ(){const[e,t]=y.useState(null),n=y.useRef(null),r=y.useCallback(l=>wh(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=fa(e,l);return{disabled:d.disabled,"aria-busy":d.busy||c}}}}const kZ=8e3,NZ=1800,jZ=4e3;function SZ({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),jZ);return()=>window.clearTimeout(J)},[v]);const[x,N]=y.useState(null),[b,S]=y.useState(!1),[E,R]=y.useState(null),[O,A]=y.useState(null),q=y.useCallback(async(J,V)=>{if(!e(V))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:ai(Y,"command failed",Z.status)}),Y}catch{return f({text:"server unreachable"}),null}finally{t()}},[e,t,r]),I=y.useCallback(()=>{l(null),f(null),j(null),N(null),S(!1)},[]),B=(J,V="first")=>{I(),A(null),l({num:J,view:"menu",start:V})},L=y.useCallback(J=>{var Y,X;const V=d.current;if(!V||J!=null&&V.num!==J)return;const Z=document.getElementById(`ap-menu-${V.num}`);(Z!=null&&Z.contains(document.activeElement)||En(((Y=document.activeElement)==null?void 0:Y.tagName)??null))&&((X=document.getElementById(`ap-more-${V.num}`))==null||X.focus()),I()},[I]),M=y.useCallback(J=>f(J),[]),F=(J,V)=>{g(V??""),f(null),l({num:J,view:"rename"})},C=J=>g(J),$=J=>{A(null),f(null),l({num:J,view:"move"})},P=J=>A(J),K=async J=>{var Z;S(!1);const V=await q({action:"share",account:J},`share-${J}`);!(V!=null&&V.ok)||((Z=d.current)==null?void 0:Z.num)!==J||(N({num:J,blob:V.blob,expiresAt:V.expiresAt}),l({num:J,view:"share"}))},G=async J=>{await io(J)&&(S(!0),window.setTimeout(()=>S(!1),NZ))},U=async(J,V)=>{const{commit:Z,alias:Y}=SK(p,V);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)},W=async(J,V)=>{var X,ee,ae;const Z=await q({action:"move",account:J,slot:V},`move-${J}`),Y=NK({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)||En(((ee=document.activeElement)==null?void 0:ee.tagName)??null))&&ye.focus()}((ae=d.current)==null?void 0:ae.num)===J&&I(),j(Y.confirmRemove),Y.shareFor==null&&(N(null),S(!1)),R(Y.swapNote);const ue=Y.swapNote;ue&&window.setTimeout(()=>R(ge=>ge===ue?null:ge),kZ),A(null),s(Y.menuFor)}return Z};return{menu:o,menuFor:c,menuError:h,aliasDraft:p,confirmRemove:v,share:x,shareCopied:b,slotDraft:O,swapNote:E,showMenu:B,dropMenu:I,closeMenu:L,sayInMenu:M,startRename:F,typeAlias:C,doAlias:U,startMove:$,pickSlot:P,doSlot:async(J,V,Z)=>{if(!Z.sends){L(J);return}await W(J,V)},makeShare:K,copyShare:G,pressRemove:J=>{const V=Date.now(),Z=ao({armedFor:v,target:J,armedAt:k.current,now:V,gapMs:so});if(Z==="arm"){j(J),k.current=V;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&&I(),s(null))}))}}}function _Z(e,t){return!e||!t||t.some(n=>n.num===e.num&&n.active)?e:null}function EZ({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:fb(N,"command failed",x.status),raw:lc(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=>_Z(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:fb(k,"the switch failed"),raw:lc(k),row:g}),await r(!0)}catch{s({text:"server unreachable",row:g})}finally{n(),c(g)}}}}}const TZ=1800;function CZ({auto:e,post:t,load:n}){var O;const[r,s]=y.useReducer(BG,hb),[o,l]=y.useState(!1),c=y.useRef(null),d=y.useRef(null),h=y.useRef(null),f=y.useRef(!1),p=((O=e==null?void 0:e.settings["autoswitch.threshold"])==null?void 0:O.value)??"90",g=r.pick??p,v=TK(g,p),j=r.custom!=null,k=r.refusal,x=y.useRef(j);return y.useEffect(()=>{var A,q,I;x.current!==j&&(x.current=j,j?((A=h.current)==null||A.focus(),(q=h.current)==null||q.select()):f.current&&((I=c.current)==null||I.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 I=await qG(A,q,t);if(I.kind==="refused"){s({kind:"refuse",message:I.message});return}I.kind==="sent"&&(await n(!0),!I.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)},TZ))}}}const AZ=Object.freeze({text:"couldn't reach the deck server",reload:!0}),RZ=Object.freeze({text:"still waiting on the deck server — claude-swap can be slow to answer",reload:!0});async function N_(e){return e.ok?{ok:!0,status:e.status,body:null}:{ok:!1,status:e.status,body:await e.json().catch(()=>null)}}function MZ(e){const t=e.find(r=>!r.ok);if(!t)return null;const n=lc(t.body);return{text:fb(t.body,`the deck server answered ${t.status}`),...n?{raw:n}:{},reload:!0}}function j_(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 GO=15e3,$Z=3e4;function IZ(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(),$Z);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=MZ([await N_(x),await N_(N)]);d(S=>j_(S,b))}catch{d(x=>j_(x,j.signal.aborted?RZ:AZ))}finally{window.clearTimeout(k),v&&l(!1)}},[e]);y.useEffect(()=>(f(!0),h.current=window.setInterval(()=>f(!1),GO),()=>{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 OZ="#ap-rest-entry";function LZ(e){return[`#${e}`,OZ,...UI(null)]}function PZ(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||!En(((o=document.activeElement)==null?void 0:o.tagName)??null)))for(const l of LZ(s)){const c=document.querySelector(l);if(c){c.focus();return}}},[e]),{onFocus:n,onBlur:r}}function DZ({onClose:e,leaving:t,onReport:n,onRoster:r}){var Sr,Kr,Yr;Ut("accounts-panel");const{busy:s,claim:o,release:l,pressProps:c}=bZ(),[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,O]=y.useState(!1),[A,q]=y.useState(null),[I,B]=y.useState(vZ),[L,M]=y.useState(yZ),[F,C]=y.useState(null),[$,P]=y.useState(!1),K=y.useRef(r);K.current=r;const G=y.useCallback(ve=>{var Re;B(He=>hG(He,ve.accounts)),(Re=K.current)==null||Re.call(K,ve)},[]),{data:U,auto:W,reloading:D,failure:H,load:J,sayFailure:V,clearFailure:Z}=IZ(G),Y=PZ(U),X=y.useCallback(ve=>{window.requestAnimationFrame(()=>{var Re;if(En(((Re=document.activeElement)==null?void 0:Re.tagName)??null))for(const He of UI(ve)){const $t=document.querySelector(He);if($t){$t.focus();return}}})},[]),ee=SZ({claim:o,release:l,load:J,clearFailure:Z,rescueFocus:X}),{menu:ae,menuFor:ue,swapNote:ge,showMenu:ye,dropMenu:se,closeMenu:me,sayInMenu:pe}=ee,{switched:de,post:fe,doSwitch:ne}=EZ({data:U,claim:o,release:l,load:J,sayFailure:V,clearFailure:Z,sayInMenu:pe,rescueFocus:X}),{threshold:oe,thresholdPick:Ne,thresholdCtl:we,thresholdSaved:Ie,thresholdRef:Pe,thresholdSaveRef:Be,thresholdCustom:Oe,thresholdRefusal:Qe,thresholdFieldRef:Ye,proposeThreshold:Xe,typeThreshold:ot,cancelThreshold:it,leaveThreshold:Ze,doThreshold:yt}=CZ({auto:W,post:fe,load:J}),ze=YI();y.useEffect(()=>{xZ(I)},[I]),y.useEffect(()=>{wZ(L)},[L]);const[ht,mn]=y.useState(()=>new Set),Mt=y.useCallback(ve=>mn(new Set(ve)),[]),lt=ve=>({noCopyWorksNearby:ht.has(n_([ve])[0].key)}),wt=(Sr=U==null?void 0:U.accounts)==null?void 0:Sr.find(ve=>ve.active),tn=wt?Si(wt,ze,lt(wt)):null,Ft=(U==null?void 0:U.accounts)??[],ft=wt?Ft.filter(ve=>!ve.active):[],nn=oO(ft),Wt=lG(L,ft),xt=ub(iG(ft,Wt,ve=>WO(ve,ze),ze),F),Tn=y.useRef(!1),Yn=y.useRef(!1),br=y.useRef(!1),gn=y.useCallback(()=>{!Tn.current&&!Yn.current&&!br.current&&C(null)},[]),Xn=()=>C(ve=>ve??xt.map(Br)),Zn={onPointerEnter:()=>{Tn.current=!0,Xn()},onPointerLeave:()=>{Tn.current=!1,gn()},onFocus:ve=>{ve.target.matches(":focus-visible")&&(Yn.current=!0,Xn())},onBlur:ve=>{ve.currentTarget.contains(ve.relatedTarget)||(Yn.current=!1,gn())}},Jn=ue!=null&&ft.some(ve=>ve.num===ue)||g!=null&&ft.some(ve=>ve.num===g.num);y.useEffect(()=>{br.current=Jn,Jn||gn()},[Jn,gn]);const Cn=$&&ft.length>0;y.useEffect(()=>{Cn||(Tn.current=Yn.current=br.current=!1,C(null))},[Cn]);const Vr=y.useRef(!1);y.useEffect(()=>{Vr.current&&ft.length===0&&X(null),Vr.current=ft.length>0},[ft.length,X]);const An=xt.length?Ft.filter(ve=>ve.active):Ft,kr=pZ(xt,ze,lt),bt=mZ(wt,oe,ze),Gr=gZ(W),Nr=ve=>$&&xt.some(Re=>Re.num===ve)?"ap-rest-list":"ap-scroll",Es=(ve,Re="first")=>{ye(ve,Re),v(null)},Qn=(ve,Re)=>{se(),v(He=>(He==null?void 0:He.anchor)===Re?null:{num:ve,anchor:Re})},Rn=y.useCallback((ve=!1)=>{var He;const Re=j.current;ve&&Re&&((He=document.getElementById(Re.anchor))==null||He.focus()),v(null)},[]),Ts=()=>{se(),v(null),h("lan")},er=y.useRef(d);y.useEffect(()=>{er.current!==d&&(er.current=d,window.requestAnimationFrame(()=>{var ve;(ve=document.getElementById(d==="lan"?"ap-lan-back":"ap-lan-entry"))==null||ve.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(ve=>ve.num===ae.num)&&se(),g&&(U!=null&&U.accounts)&&!U.accounts.some(ve=>ve.num===g.num)&&v(null)},[U,ae,g,se]),y.useEffect(()=>{A==null||!(U!=null&&U.accounts)||U.accounts.some(ve=>ve.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"})})}),As=ve=>{const Re=iO(I,ve),He=ue===ve.num,$t=(H==null?void 0:H.row)===ve.num?H:null,tr=(de==null?void 0:de.num)===ve.num,Yt=(ge==null?void 0:ge.at)===ve.num?ge:null,Rs=Yt?Ft.find(yn=>yn.num===Yt.displaced):void 0,Ms=(g==null?void 0:g.anchor)===`ap-issue-${ve.num}`;return a.jsx(mG,{a:ve,nowSec:ze,lan:lt(ve),opened:Re,onToggleLanes:()=>B(yn=>uG(yn,ve)),busy:s,pressProps:c,onSwitch:ne,menuOpen:He,onOpenMenu:Es,onCloseMenu:me,refusal:$t,onDismissRefusal:()=>Z(),switchedHere:tr,swapped:Yt,displaced:Rs,issueExpanded:Ms,onOpenIssue:Qn,sortKey:ve.active?null:oG(Wt)},ve.num)},jr=U!=null&&U.ok&&(W!=null&&W.ok)?a.jsx(UG,{auto:W,threshold:oe,thresholdPick:Ne,thresholdCtl:we,thresholdSaved:Ie,thresholdRef:Pe,thresholdSaveRef:Be,thresholdCustom:Oe,thresholdRefusal:Qe,thresholdFieldRef:Ye,proposeThreshold:Xe,typeThreshold:ot,cancelThreshold:it,leaveThreshold:Ze,doThreshold:yt,pressProps:c,post:fe,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(yG,{canShare:(((Kr=U==null?void 0:U.accounts)==null?void 0:Kr.length)??0)>0,canReport:(((Yr=U==null?void 0:U.accounts)==null?void 0:Yr.length)??0)>1||N,onAdd:()=>x(!0),onReport:()=>{E([...An,...xt].map(Br)),b(!0)},onShareSet:()=>O(!0),onReload:()=>J(!0),pressProps:c,reloading:D,closeButton:Cs}),d==="accounts"&&a.jsxs("div",{className:"ap-scroll",id:"ap-scroll",children:[U==null?H?a.jsxs("div",{className:"ap-empty",role:"alert",children:[a.jsx("span",{title:H.raw||void 0,children:H.text}),a.jsxs("span",{className:"ap-hint",children:["No accounts have arrived, so there is nothing to show yet. The panel keeps trying every ",GO/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&&(tn==null?void 0:tn.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:()=>Qn(wt.num,"ap-notice"),children:[a.jsx(M0,{}),a.jsx("span",{className:"ap-issue-text",children:"Current account needs attention"})]}),tn.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:An.map(As)}),xt.length>0&&a.jsx(cZ,{peers:kr,strained:bt,armed:Gr,threshold:W!=null&&W.ok?oe:null,open:$,onToggle:()=>P(ve=>!ve),order:Wt,choices:nn,onOrder:M,allOpen:lO(I,xt),onToggleAll:()=>B(ve=>dG(ve,xt)),held:F!=null}),xt.length>0&&$&&a.jsxs("div",{className:"ap-rest-panel",id:"ap-rest-panel",children:[a.jsx("ul",{className:"ap-list ap-others",id:"ap-rest-list",...Zn,children:xt.map(As)}),jr]}),xt.length===0&&jr,H&&H.row==null&&a.jsxs("div",{className:"ap-failure",role:"alert",children:[a.jsx("span",{className:"ap-failure-text",title:H.raw||void 0,children:H.text}),a.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>Z(),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),ae&&(()=>{var Re;const ve=(Re=U.accounts)==null?void 0:Re.find(He=>He.num===ae.num);return ve?a.jsx(CK,{a:ve,accountMenu:ee,slots:(U.accounts??[]).map(He=>He.num),boundaryId:Nr(ve.num),nowSec:ze,busy:s,pressProps:c,rotating:!!(W!=null&&W.enabled||W!=null&&W.external),onProjects:()=>{q({num:ve.num,name:ve.alias??ve.email??`account ${ve.num}`}),me(ve.num)},onRotation:()=>fe({action:"account",account:ve.num,enabled:ve.disabled},`rot-${ve.num}`,"menu").then(He=>{J(!0),He!=null&&He.ok&&me(ve.num)})}):null})(),g&&(()=>{var He;const ve=(He=U.accounts)==null?void 0:He.find($t=>$t.num===g.num),Re=ve?Si(ve,ze,lt(ve)):null;return!ve||!Re?null:a.jsx(ZV,{anchorId:g.anchor,boundaryId:g.anchor==="ap-notice"?"ap-scroll":Nr(ve.num),issue:Re,who:ve.alias??ve.email??`account ${ve.num}`,fetchedAt:ve.fetchedAt,nowSec:ze,onClose:Rn,onSignIn:()=>x(!0),onReport:n&&(()=>n({initialKind:Re.tone==="warn"?"bug":"other",initialBody:`Account issue: ${Re.text}. ${Re.hint}`}))})})()]}):a.jsx(gG,{data:U}),a.jsx("div",{className:"film-foot",children:a.jsx(sc,{film:"claudeAccounts"})})]}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:de?`Now active: ${de.name}`:""}),f&&a.jsx(iZ,{accounts:n_((U==null?void 0:U.accounts)??[]),onChanged:()=>J(!0),onNoCopy:Mt,view:d==="lan",onOpen:Ts,onBack:()=>h("accounts"),closeButton:Cs}),k&&a.jsx(vO,{onClose:()=>x(!1),onChanged:()=>J(!0)}),R&&a.jsx(fZ,{accounts:((U==null?void 0:U.accounts)??[]).map(ve=>({num:ve.num,email:ve.email,alias:ve.alias,org:ve.org})),onClose:()=>O(!1),copyText:io}),A!=null&&(()=>{var Re;const ve=(Re=U==null?void 0:U.accounts)==null?void 0:Re.find(He=>He.num===A.num);return U!=null&&U.accounts&&!ve?null:a.jsx(YV,{num:A.num,name:ve?ve.alias??ve.email??`account ${ve.num}`:A.name,onClose:()=>q(null)})})(),N&&a.jsx(LG,{accounts:(U==null?void 0:U.accounts)??null,order:S,failed:H!=null&&H.reload?H.text:null,nowSec:ze,onClose:()=>b(!1)})]})}const FZ=16,BZ=120;function qZ(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 UZ(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 zZ(e,t){return qZ(e,t,FZ)?"over":UZ(e,t)<=BZ?"near":"far"}function WZ(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 HZ(){const[e,t]=y.useState(!1),[n,r]=y.useState(""),[s,o]=y.useState("far"),l=y.useRef(null),c=od(e,140),d=y.useCallback(g=>{var k;const v=(k=l.current)==null?void 0:k.getBoundingClientRect(),j=WZ(g);return v&&j?zZ(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 VZ=420;function GZ(){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),VZ+80)})},[]);return y.useEffect(()=>()=>{n.current&&window.clearTimeout(n.current)},[]),{bubbling:e,endBubble:r,onBubble:s}}const z0=11,KO=7.2,YO=6.6,KZ={width:104,height:48},S_={width:96,height:44},XO={width:220,height:103};function YZ(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)?XO:{width:Math.max(160,t),height:Math.max(72,n)}}function nm(e,t,n){return e.width*t>=n.width&&e.height*t>=n.height}function XZ(e,t,n=XO){if(!Number.isFinite(t)||t<=0)return e??"detail";const r=z0*t;return e==="detail"?r>=YO?"detail":nm(n,t,S_)?"compact":"overview":r>=KO?"detail":e==="compact"?nm(n,t,S_)?"compact":"overview":nm(n,t,KZ)?"compact":"overview"}const ZZ=KO/z0,JZ=YO/z0;function QZ(e,t){return e>=ZZ?e:Math.max(e,Math.min(t,JZ-.001))}const eJ=.8,tJ=1;function nJ({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=YZ(p);return c.current={version:f,card:g},g},[]),h=y.useCallback(f=>{var g;const p=XZ(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 rJ=40,sJ=120;function aJ(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=rJ){const h=t.now(),f=Math.max(s+d,h);if(f<=h){l(),o();return}c(f,h,d)},replay(d=sJ){l(),r=t.now()+d,n=t.setTimeout(o,d)},flush(){l(),o()},cancel(){l()}}}const oJ=1024*1024,__=5,ZO=.8,jb=24,iJ="agent-dag.soundCustom.done",lJ="agent-dag.soundCustom.needs-input",Wl={done:iJ,"needs-input":lJ};function uc(e){if(e.kind!=="audio")return e;const{bytes:t,...n}=e;return n}function E_(e){return!e||!/^[a-zA-Z0-9._-]{1,96}$/.test(e)?null:e}function cJ(e){return{done:E_(e(Wl.done)),"needs-input":E_(e(Wl["needs-input"]))}}function uJ(e,t){return{done:e.done===t?null:e.done,"needs-input":e["needs-input"]===t?null:e["needs-input"]}}function dJ(e){return e.done&&e.done===e["needs-input"]?e.done:null}const hJ={wav:"audio/wav",wave:"audio/wav",mp3:"audio/mpeg",ogg:"audio/ogg",oga:"audio/ogg",webm:"audio/webm",m4a:"audio/mp4",mp4:"audio/mp4"},JO=new Set(["audio/wav","audio/x-wav","audio/mpeg","audio/mp3","audio/ogg","audio/webm","audio/mp4"]);function QO(e,t){const n=t.toLowerCase().split(";")[0].trim();if(JO.has(n))return n;const r=e.toLowerCase().split(".").pop()??"";return hJ[r]??n}function T_(e,t){const n=QO(e.name,e.type);if(!JO.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>oJ)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>__)return`Audio must be ${__} seconds or shorter.`}return null}function Sb(e){return e>=jb?`There are already ${jb} custom sounds. Delete one first.`:null}function fJ(e,t){const n=e.indexOf(t);return n<0?null:e[n+1]??e[n-1]??null}function pJ(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,ZO/t)}function eL(){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 mJ(e,t,n=eL()){var h;const r=((h=e.name)==null?void 0:h.trim())||"Custom sound",s=T_({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=T_({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:QO(r,e.type),duration:l.duration,normalizationGain:pJ(d),bytes:o}}function gJ(e,t=eL()){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 yJ="ccdeck-notification-audio",wJ=2,yr="assets",zr="summaries";function bc(){return typeof window<"u"?window.ccdeckNotificationAudio??null:null}function vJ(){return new Promise((e,t)=>{const n=indexedDB.open(yJ,wJ);n.onupgradeneeded=r=>{const s=n.result,o=s.objectStoreNames.contains(yr)?n.transaction.objectStore(yr):s.createObjectStore(yr,{keyPath:"id"});if(s.objectStoreNames.contains(zr))return;const l=s.createObjectStore(zr,{keyPath:"id"});if(r.oldVersion<1)return;const c=o.openCursor();c.onsuccess=()=>{const d=c.result;d&&(l.put(uc(d.value)),d.continue())}},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error??new Error("Could not open local audio storage."))})}async function kc(e,t,n){const r=await vJ();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 xJ(){const e=bc();return e?e.list():typeof indexedDB>"u"?[]:await kc([zr],"readonly",t=>t.objectStore(zr).getAll())??[]}async function bJ(e){const t=bc();return t?t.get(e):typeof indexedDB>"u"?null:await kc([yr],"readonly",n=>n.objectStore(yr).get(e))??null}async function C_(e){const t=bc();if(t){await t.put(e);return}if(typeof indexedDB>"u")throw new Error("Local audio storage is unavailable in this browser.");await kc([yr,zr],"readwrite",n=>{n.objectStore(yr).put(e),n.objectStore(zr).put(uc(e))})}async function kJ(e,t){const n=bc();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 kc([yr,zr],"readwrite",r=>{const s=r.objectStore(yr),o=s.get(e);o.onsuccess=()=>{const l=o.result;if(!l)return;const c={...l,name:t};s.put(c),r.objectStore(zr).put(uc(c))}})}async function NJ(e){const t=bc();if(t){await t.remove(e);return}typeof indexedDB>"u"||await kc([yr,zr],"readwrite",n=>{n.objectStore(yr).delete(e),n.objectStore(zr).delete(e)})}const ud=["done","needs-input"],jJ=[{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}]}],SJ=[{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}]}],W0={done:jJ,"needs-input":SJ},Nn="two";function _b(e,t){const n=W0[e];return n.find(r=>r.id===t)??n.find(r=>r.id===Nn)??n[0]}function tL(e,t){return W0[e].some(r=>r.id===t)?t:Nn}_b("done",Nn).notes,_b("needs-input",Nn).notes;const A_=.04,nL=.24,dd=0,Bd=100,Eb=5,oo=50;function Eh(e){if(!Number.isFinite(e))return oo;const t=Math.round(e/Eb)*Eb;return Math.min(Bd,Math.max(dd,t))}function rL(e){if(e==null)return oo;const t=e.trim();return/^-?\d+(\.\d+)?$/.test(t)?Eh(Number(t)):oo}function H0(e){const t=Eh(e),n=A_+(nL-A_)*(t/Bd);return Math.round(n*1e4)/1e4}function _J(e,t){const n=t.trim,r=typeof n=="number"&&Number.isFinite(n)&&n>0&&n<=1?n:1;return Math.round(H0(e)*r*1e4)/1e4}const EJ=.012,R_=1e-4;function TJ(e){return Math.min(1,H0(e)/nL)}function CJ(e,t){const n=e*(H0(t)/ZO);return Math.max(1e-4,n)}const AJ=160,RJ="agent-dag.soundLevel.done",MJ="agent-dag.soundLevel.needs-input",$J="agent-dag.soundFigure.done",IJ="agent-dag.soundFigure.needs-input",sL={done:RJ,"needs-input":MJ},qd={done:$J,"needs-input":IJ},M_={done:{level:oo,figure:Nn},"needs-input":{level:oo,figure:Nn}};function OJ(e){const t=n=>({level:rL(e(sL[n])),figure:tL(n,e(qd[n]))});return{done:t("done"),"needs-input":t("needs-input")}}function LJ(e,t){return(e??M_)[t]??M_[t]}const PJ={Stop:"done",Notification:"needs-input"};function DJ(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:Pt(PJ,n)??null}const FJ=6,BJ="ccdeck-tabs";function qJ(e){return e>=FJ}function UJ(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 zJ({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=aJ(t,{now:()=>Date.now(),setTimeout:(S,E)=>window.setTimeout(S,E),clearTimeout:S=>window.clearTimeout(S)});let x=!1;const N=typeof BroadcastChannel=="function"?UJ(new BroadcastChannel(BJ),Math.random().toString(36).slice(2),()=>x):null,b=window.setInterval(()=>{x||!N||N.ask(600).then(S=>{x||d(qJ(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=K$(e.current,R);const O=R.replay===!0||p.current||Date.now()-R.receivedAt>3e4;O?k.replay():k.live();const A=DJ(R,O);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 WJ=200,HJ=5*6e4,VJ=6,GJ=2*6e4;function Ju(e,t){if(t.size!==0)for(const n of Array.from(e.keys()))t.has(n)||e.delete(n)}function KJ(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 YJ(e){const t=new Set;for(const n of e)t.add(n.id),t.add(`group:${n.sessionId}`),n.kind==="root"&&t.add(w0(n.id));return t}function XJ(e){const t=new Set;for(const n of e)t.add(n.id),n.kind==="root"&&t.add(w0(n.id));return t}function ZJ(e,t){let n=vU(e,t,zj);xU(e,t,zj)&&(n=!0);const r=[],s=o=>{r.push(o)};return gU(e,t,WJ,HJ,s)&&(n=!0),yU(e,t,VJ,GJ,s)&&(n=!0),{changed:n,forgotten:r}}function JJ(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 QJ(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=>JJ(g,h,f)),!f&&p&&t(!0)},[]),c=y.useCallback(()=>{r({ids:new Set,primary:null})},[]),d=y.useCallback(()=>{r(h=>{const f=KJ(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 eQ({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}=ZJ(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 V0(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 rm,$_;function tQ(){if($_)return rm;$_=1;function e(){this.__data__=[],this.size=0}return rm=e,rm}var sm,I_;function $i(){if(I_)return sm;I_=1;function e(t,n){return t===n||t!==t&&n!==n}return sm=e,sm}var am,O_;function Th(){if(O_)return am;O_=1;var e=$i();function t(n,r){for(var s=n.length;s--;)if(e(n[s][0],r))return s;return-1}return am=t,am}var om,L_;function nQ(){if(L_)return om;L_=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 om=r,om}var im,P_;function rQ(){if(P_)return im;P_=1;var e=Th();function t(n){var r=this.__data__,s=e(r,n);return s<0?void 0:r[s][1]}return im=t,im}var lm,D_;function sQ(){if(D_)return lm;D_=1;var e=Th();function t(n){return e(this.__data__,n)>-1}return lm=t,lm}var cm,F_;function aQ(){if(F_)return cm;F_=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 cm=t,cm}var um,B_;function Ch(){if(B_)return um;B_=1;var e=tQ(),t=nQ(),n=rQ(),r=sQ(),s=aQ();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,um=o,um}var dm,q_;function oQ(){if(q_)return dm;q_=1;var e=Ch();function t(){this.__data__=new e,this.size=0}return dm=t,dm}var hm,U_;function iQ(){if(U_)return hm;U_=1;function e(t){var n=this.__data__,r=n.delete(t);return this.size=n.size,r}return hm=e,hm}var fm,z_;function lQ(){if(z_)return fm;z_=1;function e(t){return this.__data__.get(t)}return fm=e,fm}var pm,W_;function cQ(){if(W_)return pm;W_=1;function e(t){return this.__data__.has(t)}return pm=e,pm}var mm,H_;function aL(){if(H_)return mm;H_=1;var e=typeof Eu=="object"&&Eu&&Eu.Object===Object&&Eu;return mm=e,mm}var gm,V_;function xr(){if(V_)return gm;V_=1;var e=aL(),t=typeof self=="object"&&self&&self.Object===Object&&self,n=e||t||Function("return this")();return gm=n,gm}var ym,G_;function Ii(){if(G_)return ym;G_=1;var e=xr(),t=e.Symbol;return ym=t,ym}var wm,K_;function uQ(){if(K_)return wm;K_=1;var e=Ii(),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 wm=o,wm}var vm,Y_;function dQ(){if(Y_)return vm;Y_=1;var e=Object.prototype,t=e.toString;function n(r){return t.call(r)}return vm=n,vm}var xm,X_;function lo(){if(X_)return xm;X_=1;var e=Ii(),t=uQ(),n=dQ(),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 xm=l,xm}var bm,Z_;function Gn(){if(Z_)return bm;Z_=1;function e(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}return bm=e,bm}var km,J_;function Nc(){if(J_)return km;J_=1;var e=lo(),t=Gn(),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 km=l,km}var Nm,Q_;function hQ(){if(Q_)return Nm;Q_=1;var e=xr(),t=e["__core-js_shared__"];return Nm=t,Nm}var jm,eE;function fQ(){if(eE)return jm;eE=1;var e=hQ(),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 jm=n,jm}var Sm,tE;function oL(){if(tE)return Sm;tE=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 Sm=n,Sm}var _m,nE;function pQ(){if(nE)return _m;nE=1;var e=Nc(),t=fQ(),n=Gn(),r=oL(),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 _m=p,_m}var Em,rE;function mQ(){if(rE)return Em;rE=1;function e(t,n){return t==null?void 0:t[n]}return Em=e,Em}var Tm,sE;function co(){if(sE)return Tm;sE=1;var e=pQ(),t=mQ();function n(r,s){var o=t(r,s);return e(o)?o:void 0}return Tm=n,Tm}var Cm,aE;function G0(){if(aE)return Cm;aE=1;var e=co(),t=xr(),n=e(t,"Map");return Cm=n,Cm}var Am,oE;function Ah(){if(oE)return Am;oE=1;var e=co(),t=e(Object,"create");return Am=t,Am}var Rm,iE;function gQ(){if(iE)return Rm;iE=1;var e=Ah();function t(){this.__data__=e?e(null):{},this.size=0}return Rm=t,Rm}var Mm,lE;function yQ(){if(lE)return Mm;lE=1;function e(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n}return Mm=e,Mm}var $m,cE;function wQ(){if(cE)return $m;cE=1;var e=Ah(),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 $m=s,$m}var Im,uE;function vQ(){if(uE)return Im;uE=1;var e=Ah(),t=Object.prototype,n=t.hasOwnProperty;function r(s){var o=this.__data__;return e?o[s]!==void 0:n.call(o,s)}return Im=r,Im}var Om,dE;function xQ(){if(dE)return Om;dE=1;var e=Ah(),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 Om=n,Om}var Lm,hE;function bQ(){if(hE)return Lm;hE=1;var e=gQ(),t=yQ(),n=wQ(),r=vQ(),s=xQ();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,Lm=o,Lm}var Pm,fE;function kQ(){if(fE)return Pm;fE=1;var e=bQ(),t=Ch(),n=G0();function r(){this.size=0,this.__data__={hash:new e,map:new(n||t),string:new e}}return Pm=r,Pm}var Dm,pE;function NQ(){if(pE)return Dm;pE=1;function e(t){var n=typeof t;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?t!=="__proto__":t===null}return Dm=e,Dm}var Fm,mE;function Rh(){if(mE)return Fm;mE=1;var e=NQ();function t(n,r){var s=n.__data__;return e(r)?s[typeof r=="string"?"string":"hash"]:s.map}return Fm=t,Fm}var Bm,gE;function jQ(){if(gE)return Bm;gE=1;var e=Rh();function t(n){var r=e(this,n).delete(n);return this.size-=r?1:0,r}return Bm=t,Bm}var qm,yE;function SQ(){if(yE)return qm;yE=1;var e=Rh();function t(n){return e(this,n).get(n)}return qm=t,qm}var Um,wE;function _Q(){if(wE)return Um;wE=1;var e=Rh();function t(n){return e(this,n).has(n)}return Um=t,Um}var zm,vE;function EQ(){if(vE)return zm;vE=1;var e=Rh();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 zm=t,zm}var Wm,xE;function K0(){if(xE)return Wm;xE=1;var e=kQ(),t=jQ(),n=SQ(),r=_Q(),s=EQ();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,Wm=o,Wm}var Hm,bE;function TQ(){if(bE)return Hm;bE=1;var e=Ch(),t=G0(),n=K0(),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 Hm=s,Hm}var Vm,kE;function Mh(){if(kE)return Vm;kE=1;var e=Ch(),t=oQ(),n=iQ(),r=lQ(),s=cQ(),o=TQ();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,Vm=l,Vm}var Gm,NE;function Y0(){if(NE)return Gm;NE=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 Gm=e,Gm}var Km,jE;function iL(){if(jE)return Km;jE=1;var e=co(),t=(function(){try{var n=e(Object,"defineProperty");return n({},"",{}),n}catch{}})();return Km=t,Km}var Ym,SE;function $h(){if(SE)return Ym;SE=1;var e=iL();function t(n,r,s){r=="__proto__"&&e?e(n,r,{configurable:!0,enumerable:!0,value:s,writable:!0}):n[r]=s}return Ym=t,Ym}var Xm,_E;function Ih(){if(_E)return Xm;_E=1;var e=$h(),t=$i(),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 Xm=s,Xm}var Zm,EE;function jc(){if(EE)return Zm;EE=1;var e=Ih(),t=$h();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 Zm=n,Zm}var Jm,TE;function CQ(){if(TE)return Jm;TE=1;function e(t,n){for(var r=-1,s=Array(t);++r<t;)s[r]=n(r);return s}return Jm=e,Jm}var Qm,CE;function Hr(){if(CE)return Qm;CE=1;function e(t){return t!=null&&typeof t=="object"}return Qm=e,Qm}var eg,AE;function AQ(){if(AE)return eg;AE=1;var e=lo(),t=Hr(),n="[object Arguments]";function r(s){return t(s)&&e(s)==n}return eg=r,eg}var tg,RE;function Sc(){if(RE)return tg;RE=1;var e=AQ(),t=Hr(),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 tg=o,tg}var ng,ME;function St(){if(ME)return ng;ME=1;var e=Array.isArray;return ng=e,ng}var Ol={exports:{}},rg,$E;function RQ(){if($E)return rg;$E=1;function e(){return!1}return rg=e,rg}Ol.exports;var IE;function Oi(){return IE||(IE=1,(function(e,t){var n=xr(),r=RQ(),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})(Ol,Ol.exports)),Ol.exports}var sg,OE;function Oh(){if(OE)return sg;OE=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 sg=n,sg}var ag,LE;function X0(){if(LE)return ag;LE=1;var e=9007199254740991;function t(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=e}return ag=t,ag}var og,PE;function MQ(){if(PE)return og;PE=1;var e=lo(),t=X0(),n=Hr(),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]",O="[object Int32Array]",A="[object Uint8Array]",q="[object Uint8ClampedArray]",I="[object Uint16Array]",B="[object Uint32Array]",L={};L[b]=L[S]=L[E]=L[R]=L[O]=L[A]=L[q]=L[I]=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 og=M,og}var ig,DE;function Lh(){if(DE)return ig;DE=1;function e(t){return function(n){return t(n)}}return ig=e,ig}var Ll={exports:{}};Ll.exports;var FE;function Z0(){return FE||(FE=1,(function(e,t){var n=aL(),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})(Ll,Ll.exports)),Ll.exports}var lg,BE;function _c(){if(BE)return lg;BE=1;var e=MQ(),t=Lh(),n=Z0(),r=n&&n.isTypedArray,s=r?t(r):e;return lg=s,lg}var cg,qE;function lL(){if(qE)return cg;qE=1;var e=CQ(),t=Sc(),n=St(),r=Oi(),s=Oh(),o=_c(),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 cg=d,cg}var ug,UE;function Ph(){if(UE)return ug;UE=1;var e=Object.prototype;function t(n){var r=n&&n.constructor,s=typeof r=="function"&&r.prototype||e;return n===s}return ug=t,ug}var dg,zE;function cL(){if(zE)return dg;zE=1;function e(t,n){return function(r){return t(n(r))}}return dg=e,dg}var hg,WE;function $Q(){if(WE)return hg;WE=1;var e=cL(),t=e(Object.keys,Object);return hg=t,hg}var fg,HE;function J0(){if(HE)return fg;HE=1;var e=Ph(),t=$Q(),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 fg=s,fg}var pg,VE;function Ss(){if(VE)return pg;VE=1;var e=Nc(),t=X0();function n(r){return r!=null&&t(r.length)&&!e(r)}return pg=n,pg}var mg,GE;function ga(){if(GE)return mg;GE=1;var e=lL(),t=J0(),n=Ss();function r(s){return n(s)?e(s):t(s)}return mg=r,mg}var gg,KE;function IQ(){if(KE)return gg;KE=1;var e=jc(),t=ga();function n(r,s){return r&&e(s,t(s),r)}return gg=n,gg}var yg,YE;function OQ(){if(YE)return yg;YE=1;function e(t){var n=[];if(t!=null)for(var r in Object(t))n.push(r);return n}return yg=e,yg}var wg,XE;function LQ(){if(XE)return wg;XE=1;var e=Gn(),t=Ph(),n=OQ(),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 wg=o,wg}var vg,ZE;function uo(){if(ZE)return vg;ZE=1;var e=lL(),t=LQ(),n=Ss();function r(s){return n(s)?e(s,!0):t(s)}return vg=r,vg}var xg,JE;function PQ(){if(JE)return xg;JE=1;var e=jc(),t=uo();function n(r,s){return r&&e(s,t(s),r)}return xg=n,xg}var Pl={exports:{}};Pl.exports;var QE;function uL(){return QE||(QE=1,(function(e,t){var n=xr(),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})(Pl,Pl.exports)),Pl.exports}var bg,eT;function dL(){if(eT)return bg;eT=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 bg=e,bg}var kg,tT;function hL(){if(tT)return kg;tT=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 kg=e,kg}var Ng,nT;function fL(){if(nT)return Ng;nT=1;function e(){return[]}return Ng=e,Ng}var jg,rT;function Q0(){if(rT)return jg;rT=1;var e=hL(),t=fL(),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 jg=o,jg}var Sg,sT;function DQ(){if(sT)return Sg;sT=1;var e=jc(),t=Q0();function n(r,s){return e(r,t(r),s)}return Sg=n,Sg}var _g,aT;function ek(){if(aT)return _g;aT=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 _g=e,_g}var Eg,oT;function Dh(){if(oT)return Eg;oT=1;var e=cL(),t=e(Object.getPrototypeOf,Object);return Eg=t,Eg}var Tg,iT;function pL(){if(iT)return Tg;iT=1;var e=ek(),t=Dh(),n=Q0(),r=fL(),s=Object.getOwnPropertySymbols,o=s?function(l){for(var c=[];l;)e(c,n(l)),l=t(l);return c}:r;return Tg=o,Tg}var Cg,lT;function FQ(){if(lT)return Cg;lT=1;var e=jc(),t=pL();function n(r,s){return e(r,t(r),s)}return Cg=n,Cg}var Ag,cT;function mL(){if(cT)return Ag;cT=1;var e=ek(),t=St();function n(r,s,o){var l=s(r);return t(r)?l:e(l,o(r))}return Ag=n,Ag}var Rg,uT;function gL(){if(uT)return Rg;uT=1;var e=mL(),t=Q0(),n=ga();function r(s){return e(s,n,t)}return Rg=r,Rg}var Mg,dT;function BQ(){if(dT)return Mg;dT=1;var e=mL(),t=pL(),n=uo();function r(s){return e(s,n,t)}return Mg=r,Mg}var $g,hT;function qQ(){if(hT)return $g;hT=1;var e=co(),t=xr(),n=e(t,"DataView");return $g=n,$g}var Ig,fT;function UQ(){if(fT)return Ig;fT=1;var e=co(),t=xr(),n=e(t,"Promise");return Ig=n,Ig}var Og,pT;function yL(){if(pT)return Og;pT=1;var e=co(),t=xr(),n=e(t,"Set");return Og=n,Og}var Lg,mT;function zQ(){if(mT)return Lg;mT=1;var e=co(),t=xr(),n=e(t,"WeakMap");return Lg=n,Lg}var Pg,gT;function Li(){if(gT)return Pg;gT=1;var e=qQ(),t=G0(),n=UQ(),r=yL(),s=zQ(),o=lo(),l=oL(),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,O=R?l(R):"";if(O)switch(O){case v:return g;case j:return c;case k:return h;case x:return f;case N:return p}return E}),Pg=b,Pg}var Dg,yT;function WQ(){if(yT)return Dg;yT=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 Dg=n,Dg}var Fg,wT;function wL(){if(wT)return Fg;wT=1;var e=xr(),t=e.Uint8Array;return Fg=t,Fg}var Bg,vT;function tk(){if(vT)return Bg;vT=1;var e=wL();function t(n){var r=new n.constructor(n.byteLength);return new e(r).set(new e(n)),r}return Bg=t,Bg}var qg,xT;function HQ(){if(xT)return qg;xT=1;var e=tk();function t(n,r){var s=r?e(n.buffer):n.buffer;return new n.constructor(s,n.byteOffset,n.byteLength)}return qg=t,qg}var Ug,bT;function VQ(){if(bT)return Ug;bT=1;var e=/\w*$/;function t(n){var r=new n.constructor(n.source,e.exec(n));return r.lastIndex=n.lastIndex,r}return Ug=t,Ug}var zg,kT;function GQ(){if(kT)return zg;kT=1;var e=Ii(),t=e?e.prototype:void 0,n=t?t.valueOf:void 0;function r(s){return n?Object(n.call(s)):{}}return zg=r,zg}var Wg,NT;function vL(){if(NT)return Wg;NT=1;var e=tk();function t(n,r){var s=r?e(n.buffer):n.buffer;return new n.constructor(s,n.byteOffset,n.length)}return Wg=t,Wg}var Hg,jT;function KQ(){if(jT)return Hg;jT=1;var e=tk(),t=HQ(),n=VQ(),r=GQ(),s=vL(),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]",O="[object Uint16Array]",A="[object Uint32Array]";function q(I,B,L){var M=I.constructor;switch(B){case v:return e(I);case o:case l:return new M(+I);case j:return t(I,L);case k:case x:case N:case b:case S:case E:case R:case O:case A:return s(I,L);case c:return new M;case d:case p:return new M(I);case h:return n(I);case f:return new M;case g:return r(I)}}return Hg=q,Hg}var Vg,ST;function xL(){if(ST)return Vg;ST=1;var e=Gn(),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 Vg=n,Vg}var Gg,_T;function bL(){if(_T)return Gg;_T=1;var e=xL(),t=Dh(),n=Ph();function r(s){return typeof s.constructor=="function"&&!n(s)?e(t(s)):{}}return Gg=r,Gg}var Kg,ET;function YQ(){if(ET)return Kg;ET=1;var e=Li(),t=Hr(),n="[object Map]";function r(s){return t(s)&&e(s)==n}return Kg=r,Kg}var Yg,TT;function XQ(){if(TT)return Yg;TT=1;var e=YQ(),t=Lh(),n=Z0(),r=n&&n.isMap,s=r?t(r):e;return Yg=s,Yg}var Xg,CT;function ZQ(){if(CT)return Xg;CT=1;var e=Li(),t=Hr(),n="[object Set]";function r(s){return t(s)&&e(s)==n}return Xg=r,Xg}var Zg,AT;function JQ(){if(AT)return Zg;AT=1;var e=ZQ(),t=Lh(),n=Z0(),r=n&&n.isSet,s=r?t(r):e;return Zg=s,Zg}var Jg,RT;function kL(){if(RT)return Jg;RT=1;var e=Mh(),t=Y0(),n=Ih(),r=IQ(),s=PQ(),o=uL(),l=dL(),c=DQ(),d=FQ(),h=gL(),f=BQ(),p=Li(),g=WQ(),v=KQ(),j=bL(),k=St(),x=Oi(),N=XQ(),b=Gn(),S=JQ(),E=ga(),R=uo(),O=1,A=2,q=4,I="[object Arguments]",B="[object Array]",L="[object Boolean]",M="[object Date]",F="[object Error]",C="[object Function]",$="[object GeneratorFunction]",P="[object Map]",K="[object Number]",G="[object Object]",U="[object RegExp]",W="[object Set]",D="[object String]",H="[object Symbol]",J="[object WeakMap]",V="[object ArrayBuffer]",Z="[object DataView]",Y="[object Float32Array]",X="[object Float64Array]",ee="[object Int8Array]",ae="[object Int16Array]",ue="[object Int32Array]",ge="[object Uint8Array]",ye="[object Uint8ClampedArray]",se="[object Uint16Array]",me="[object Uint32Array]",pe={};pe[I]=pe[B]=pe[V]=pe[Z]=pe[L]=pe[M]=pe[Y]=pe[X]=pe[ee]=pe[ae]=pe[ue]=pe[P]=pe[K]=pe[G]=pe[U]=pe[W]=pe[D]=pe[H]=pe[ge]=pe[ye]=pe[se]=pe[me]=!0,pe[F]=pe[C]=pe[J]=!1;function de(fe,ne,oe,Ne,we,Ie){var Pe,Be=ne&O,Oe=ne&A,Qe=ne&q;if(oe&&(Pe=we?oe(fe,Ne,we,Ie):oe(fe)),Pe!==void 0)return Pe;if(!b(fe))return fe;var Ye=k(fe);if(Ye){if(Pe=g(fe),!Be)return l(fe,Pe)}else{var Xe=p(fe),ot=Xe==C||Xe==$;if(x(fe))return o(fe,Be);if(Xe==G||Xe==I||ot&&!we){if(Pe=Oe||ot?{}:j(fe),!Be)return Oe?d(fe,s(Pe,fe)):c(fe,r(Pe,fe))}else{if(!pe[Xe])return we?fe:{};Pe=v(fe,Xe,Be)}}Ie||(Ie=new e);var it=Ie.get(fe);if(it)return it;Ie.set(fe,Pe),S(fe)?fe.forEach(function(ze){Pe.add(de(ze,ne,oe,ze,fe,Ie))}):N(fe)&&fe.forEach(function(ze,ht){Pe.set(ht,de(ze,ne,oe,ht,fe,Ie))});var Ze=Qe?Oe?f:h:Oe?R:E,yt=Ye?void 0:Ze(fe);return t(yt||fe,function(ze,ht){yt&&(ht=ze,ze=fe[ht]),n(Pe,ht,de(ze,ne,oe,ht,fe,Ie))}),Pe}return Jg=de,Jg}var Qg,MT;function QQ(){if(MT)return Qg;MT=1;var e=kL(),t=4;function n(r){return e(r,t)}return Qg=n,Qg}var ey,$T;function nk(){if($T)return ey;$T=1;function e(t){return function(){return t}}return ey=e,ey}var ty,IT;function eee(){if(IT)return ty;IT=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 ty=e,ty}var ny,OT;function rk(){if(OT)return ny;OT=1;var e=eee(),t=e();return ny=t,ny}var ry,LT;function sk(){if(LT)return ry;LT=1;var e=rk(),t=ga();function n(r,s){return r&&e(r,s,t)}return ry=n,ry}var sy,PT;function tee(){if(PT)return sy;PT=1;var e=Ss();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 sy=t,sy}var ay,DT;function Fh(){if(DT)return ay;DT=1;var e=sk(),t=tee(),n=t(e);return ay=n,ay}var oy,FT;function ho(){if(FT)return oy;FT=1;function e(t){return t}return oy=e,oy}var iy,BT;function NL(){if(BT)return iy;BT=1;var e=ho();function t(n){return typeof n=="function"?n:e}return iy=t,iy}var ly,qT;function jL(){if(qT)return ly;qT=1;var e=Y0(),t=Fh(),n=NL(),r=St();function s(o,l){var c=r(o)?e:t;return c(o,n(l))}return ly=s,ly}var cy,UT;function SL(){return UT||(UT=1,cy=jL()),cy}var uy,zT;function nee(){if(zT)return uy;zT=1;var e=Fh();function t(n,r){var s=[];return e(n,function(o,l,c){r(o,l,c)&&s.push(o)}),s}return uy=t,uy}var dy,WT;function ree(){if(WT)return dy;WT=1;var e="__lodash_hash_undefined__";function t(n){return this.__data__.set(n,e),this}return dy=t,dy}var hy,HT;function see(){if(HT)return hy;HT=1;function e(t){return this.__data__.has(t)}return hy=e,hy}var fy,VT;function _L(){if(VT)return fy;VT=1;var e=K0(),t=ree(),n=see();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,fy=r,fy}var py,GT;function aee(){if(GT)return py;GT=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 py=e,py}var my,KT;function EL(){if(KT)return my;KT=1;function e(t,n){return t.has(n)}return my=e,my}var gy,YT;function TL(){if(YT)return gy;YT=1;var e=_L(),t=aee(),n=EL(),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 O=g?h(R,E,N,c,l,p):h(E,R,N,l,c,p);if(O!==void 0){if(O)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 gy=o,gy}var yy,XT;function oee(){if(XT)return yy;XT=1;function e(t){var n=-1,r=Array(t.size);return t.forEach(function(s,o){r[++n]=[o,s]}),r}return yy=e,yy}var wy,ZT;function ak(){if(ZT)return wy;ZT=1;function e(t){var n=-1,r=Array(t.size);return t.forEach(function(s){r[++n]=s}),r}return wy=e,wy}var vy,JT;function iee(){if(JT)return vy;JT=1;var e=Ii(),t=wL(),n=$i(),r=TL(),s=oee(),o=ak(),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(O,A,q,I,B,L,M){switch(q){case b:if(O.byteLength!=A.byteLength||O.byteOffset!=A.byteOffset)return!1;O=O.buffer,A=A.buffer;case N:return!(O.byteLength!=A.byteLength||!L(new t(O),new t(A)));case d:case h:case g:return n(+O,+A);case f:return O.name==A.name&&O.message==A.message;case v:case k:return O==A+"";case p:var F=s;case j:var C=I&l;if(F||(F=o),O.size!=A.size&&!C)return!1;var $=M.get(O);if($)return $==A;I|=c,M.set(O,A);var P=r(F(O),F(A),I,B,L,M);return M.delete(O),P;case x:if(E)return E.call(O)==E.call(A)}return!1}return vy=R,vy}var xy,QT;function lee(){if(QT)return xy;QT=1;var e=gL(),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 O=o[N],A=l[N];if(d)var q=p?d(A,O,N,l,o,f):d(O,A,N,o,l,f);if(!(q===void 0?O===A||h(O,A,c,d,f):q)){E=!1;break}R||(R=N=="constructor")}if(E&&!R){var I=o.constructor,B=l.constructor;I!=B&&"constructor"in o&&"constructor"in l&&!(typeof I=="function"&&I instanceof I&&typeof B=="function"&&B instanceof B)&&(E=!1)}return f.delete(o),f.delete(l),E}return xy=s,xy}var by,eC;function cee(){if(eC)return by;eC=1;var e=Mh(),t=TL(),n=iee(),r=lee(),s=Li(),o=St(),l=Oi(),c=_c(),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),O=o(x),A=R?f:s(k),q=O?f:s(x);A=A==h?p:A,q=q==h?p:q;var I=A==p,B=q==p,L=A==q;if(L&&l(k)){if(!l(x))return!1;R=!0,I=!1}if(L&&!I)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=I&&v.call(k,"__wrapped__"),F=B&&v.call(x,"__wrapped__");if(M||F){var C=M?k.value():k,$=F?x.value():x;return E||(E=new e),S(C,$,N,b,E)}}return L?(E||(E=new e),r(k,x,N,b,S,E)):!1}return by=j,by}var ky,tC;function CL(){if(tC)return ky;tC=1;var e=cee(),t=Hr();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 ky=n,ky}var Ny,nC;function uee(){if(nC)return Ny;nC=1;var e=Mh(),t=CL(),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 Ny=s,Ny}var jy,rC;function AL(){if(rC)return jy;rC=1;var e=Gn();function t(n){return n===n&&!e(n)}return jy=t,jy}var Sy,sC;function dee(){if(sC)return Sy;sC=1;var e=AL(),t=ga();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 Sy=n,Sy}var _y,aC;function RL(){if(aC)return _y;aC=1;function e(t,n){return function(r){return r==null?!1:r[t]===n&&(n!==void 0||t in Object(r))}}return _y=e,_y}var Ey,oC;function hee(){if(oC)return Ey;oC=1;var e=uee(),t=dee(),n=RL();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 Ey=r,Ey}var Ty,iC;function Pi(){if(iC)return Ty;iC=1;var e=lo(),t=Hr(),n="[object Symbol]";function r(s){return typeof s=="symbol"||t(s)&&e(s)==n}return Ty=r,Ty}var Cy,lC;function ok(){if(lC)return Cy;lC=1;var e=St(),t=Pi(),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 Cy=s,Cy}var Ay,cC;function fee(){if(cC)return Ay;cC=1;var e=K0(),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,Ay=n,Ay}var Ry,uC;function pee(){if(uC)return Ry;uC=1;var e=fee(),t=500;function n(r){var s=e(r,function(l){return o.size===t&&o.clear(),l}),o=s.cache;return s}return Ry=n,Ry}var My,dC;function mee(){if(dC)return My;dC=1;var e=pee(),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 My=r,My}var $y,hC;function Bh(){if(hC)return $y;hC=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 $y=e,$y}var Iy,fC;function gee(){if(fC)return Iy;fC=1;var e=Ii(),t=Bh(),n=St(),r=Pi(),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 Iy=l,Iy}var Oy,pC;function ML(){if(pC)return Oy;pC=1;var e=gee();function t(n){return n==null?"":e(n)}return Oy=t,Oy}var Ly,mC;function qh(){if(mC)return Ly;mC=1;var e=St(),t=ok(),n=mee(),r=ML();function s(o,l){return e(o)?o:t(o,l)?[o]:n(r(o))}return Ly=s,Ly}var Py,gC;function Ec(){if(gC)return Py;gC=1;var e=Pi();function t(n){if(typeof n=="string"||e(n))return n;var r=n+"";return r=="0"&&1/n==-1/0?"-0":r}return Py=t,Py}var Dy,yC;function Uh(){if(yC)return Dy;yC=1;var e=qh(),t=Ec();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 Dy=n,Dy}var Fy,wC;function yee(){if(wC)return Fy;wC=1;var e=Uh();function t(n,r,s){var o=n==null?void 0:e(n,r);return o===void 0?s:o}return Fy=t,Fy}var By,vC;function wee(){if(vC)return By;vC=1;function e(t,n){return t!=null&&n in Object(t)}return By=e,By}var qy,xC;function $L(){if(xC)return qy;xC=1;var e=qh(),t=Sc(),n=St(),r=Oh(),s=X0(),o=Ec();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 qy=l,qy}var Uy,bC;function IL(){if(bC)return Uy;bC=1;var e=wee(),t=$L();function n(r,s){return r!=null&&t(r,s,e)}return Uy=n,Uy}var zy,kC;function vee(){if(kC)return zy;kC=1;var e=CL(),t=yee(),n=IL(),r=ok(),s=AL(),o=RL(),l=Ec(),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 zy=h,zy}var Wy,NC;function OL(){if(NC)return Wy;NC=1;function e(t){return function(n){return n==null?void 0:n[t]}}return Wy=e,Wy}var Hy,jC;function xee(){if(jC)return Hy;jC=1;var e=Uh();function t(n){return function(r){return e(r,n)}}return Hy=t,Hy}var Vy,SC;function bee(){if(SC)return Vy;SC=1;var e=OL(),t=xee(),n=ok(),r=Ec();function s(o){return n(o)?e(r(o)):t(o)}return Vy=s,Vy}var Gy,_C;function _s(){if(_C)return Gy;_C=1;var e=hee(),t=vee(),n=ho(),r=St(),s=bee();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 Gy=o,Gy}var Ky,EC;function LL(){if(EC)return Ky;EC=1;var e=hL(),t=nee(),n=_s(),r=St();function s(o,l){var c=r(o)?e:t;return c(o,n(l,3))}return Ky=s,Ky}var Yy,TC;function kee(){if(TC)return Yy;TC=1;var e=Object.prototype,t=e.hasOwnProperty;function n(r,s){return r!=null&&t.call(r,s)}return Yy=n,Yy}var Xy,CC;function PL(){if(CC)return Xy;CC=1;var e=kee(),t=$L();function n(r,s){return r!=null&&t(r,s,e)}return Xy=n,Xy}var Zy,AC;function Nee(){if(AC)return Zy;AC=1;var e=J0(),t=Li(),n=Sc(),r=St(),s=Ss(),o=Oi(),l=Ph(),c=_c(),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 Zy=g,Zy}var Jy,RC;function DL(){if(RC)return Jy;RC=1;function e(t){return t===void 0}return Jy=e,Jy}var Qy,MC;function FL(){if(MC)return Qy;MC=1;var e=Fh(),t=Ss();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 Qy=n,Qy}var ew,$C;function BL(){if($C)return ew;$C=1;var e=Bh(),t=_s(),n=FL(),r=St();function s(o,l){var c=r(o)?e:n;return c(o,t(l,3))}return ew=s,ew}var tw,IC;function jee(){if(IC)return tw;IC=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 tw=e,tw}var nw,OC;function See(){if(OC)return nw;OC=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 nw=e,nw}var rw,LC;function qL(){if(LC)return rw;LC=1;var e=jee(),t=Fh(),n=_s(),r=See(),s=St();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 rw=o,rw}var sw,PC;function _ee(){if(PC)return sw;PC=1;var e=lo(),t=St(),n=Hr(),r="[object String]";function s(o){return typeof o=="string"||!t(o)&&n(o)&&e(o)==r}return sw=s,sw}var aw,DC;function Eee(){if(DC)return aw;DC=1;var e=OL(),t=e("length");return aw=t,aw}var ow,FC;function Tee(){if(FC)return ow;FC=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 ow=d,ow}var iw,BC;function Cee(){if(BC)return iw;BC=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 O=S.lastIndex=0;S.test(R);)++O;return O}return iw=E,iw}var lw,qC;function Aee(){if(qC)return lw;qC=1;var e=Eee(),t=Tee(),n=Cee();function r(s){return t(s)?n(s):e(s)}return lw=r,lw}var cw,UC;function Ree(){if(UC)return cw;UC=1;var e=J0(),t=Li(),n=Ss(),r=_ee(),s=Aee(),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 cw=c,cw}var uw,zC;function Mee(){if(zC)return uw;zC=1;var e=Y0(),t=xL(),n=sk(),r=_s(),s=Dh(),o=St(),l=Oi(),c=Nc(),d=Gn(),h=_c();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 uw=f,uw}var dw,WC;function $ee(){if(WC)return dw;WC=1;var e=Ii(),t=Sc(),n=St(),r=e?e.isConcatSpreadable:void 0;function s(o){return n(o)||t(o)||!!(r&&o&&o[r])}return dw=s,dw}var hw,HC;function ik(){if(HC)return hw;HC=1;var e=ek(),t=$ee();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 hw=n,hw}var fw,VC;function Iee(){if(VC)return fw;VC=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 fw=e,fw}var pw,GC;function UL(){if(GC)return pw;GC=1;var e=Iee(),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 pw=n,pw}var mw,KC;function Oee(){if(KC)return mw;KC=1;var e=nk(),t=iL(),n=ho(),r=t?function(s,o){return t(s,"toString",{configurable:!0,enumerable:!1,value:e(o),writable:!0})}:n;return mw=r,mw}var gw,YC;function Lee(){if(YC)return gw;YC=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 gw=r,gw}var yw,XC;function zL(){if(XC)return yw;XC=1;var e=Oee(),t=Lee(),n=t(e);return yw=n,yw}var ww,ZC;function zh(){if(ZC)return ww;ZC=1;var e=ho(),t=UL(),n=zL();function r(s,o){return n(t(s,o,e),s+"")}return ww=r,ww}var vw,JC;function WL(){if(JC)return vw;JC=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 vw=e,vw}var xw,QC;function Pee(){if(QC)return xw;QC=1;function e(t){return t!==t}return xw=e,xw}var bw,eA;function Dee(){if(eA)return bw;eA=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 bw=e,bw}var kw,tA;function Fee(){if(tA)return kw;tA=1;var e=WL(),t=Pee(),n=Dee();function r(s,o,l){return o===o?n(s,o,l):e(s,t,l)}return kw=r,kw}var Nw,nA;function Bee(){if(nA)return Nw;nA=1;var e=Fee();function t(n,r){var s=n==null?0:n.length;return!!s&&e(n,r,0)>-1}return Nw=t,Nw}var jw,rA;function qee(){if(rA)return jw;rA=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 jw=e,jw}var Sw,sA;function Uee(){if(sA)return Sw;sA=1;function e(){}return Sw=e,Sw}var _w,aA;function zee(){if(aA)return _w;aA=1;var e=yL(),t=Uee(),n=ak(),r=1/0,s=e&&1/n(new e([,-0]))[1]==r?function(o){return new e(o)}:t;return _w=s,_w}var Ew,oA;function Wee(){if(oA)return Ew;oA=1;var e=_L(),t=Bee(),n=qee(),r=EL(),s=zee(),o=ak(),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 Ew=c,Ew}var Tw,iA;function HL(){if(iA)return Tw;iA=1;var e=Ss(),t=Hr();function n(r){return t(r)&&e(r)}return Tw=n,Tw}var Cw,lA;function Hee(){if(lA)return Cw;lA=1;var e=ik(),t=zh(),n=Wee(),r=HL(),s=t(function(o){return n(e(o,1,r,!0))});return Cw=s,Cw}var Aw,cA;function Vee(){if(cA)return Aw;cA=1;var e=Bh();function t(n,r){return e(r,function(s){return n[s]})}return Aw=t,Aw}var Rw,uA;function VL(){if(uA)return Rw;uA=1;var e=Vee(),t=ga();function n(r){return r==null?[]:e(r,t(r))}return Rw=n,Rw}var Mw,dA;function Kn(){if(dA)return Mw;dA=1;var e;if(typeof V0=="function")try{e={clone:QQ(),constant:nk(),each:SL(),filter:LL(),has:PL(),isArray:St(),isEmpty:Nee(),isFunction:Nc(),isUndefined:DL(),keys:ga(),map:BL(),reduce:qL(),size:Ree(),transform:Mee(),union:Hee(),values:VL()}}catch{}return e||(e=window._),Mw=e,Mw}var $w,hA;function lk(){if(hA)return $w;hA=1;var e=Kn();$w=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 $w}var Iw,fA;function Gee(){return fA||(fA=1,Iw="2.1.8"),Iw}var Ow,pA;function Kee(){return pA||(pA=1,Ow={Graph:lk(),version:Gee()}),Ow}var Lw,mA;function Yee(){if(mA)return Lw;mA=1;var e=Kn(),t=lk();Lw={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 Lw}var Pw,gA;function Xee(){if(gA)return Pw;gA=1;var e=Kn();Pw=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 Pw}var Dw,yA;function GL(){if(yA)return Dw;yA=1;var e=Kn();Dw=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},Dw}var Fw,wA;function KL(){if(wA)return Fw;wA=1;var e=Kn(),t=GL();Fw=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 Fw}var Bw,vA;function Zee(){if(vA)return Bw;vA=1;var e=KL(),t=Kn();Bw=n;function n(r,s,o){return t.transform(r.nodes(),function(l,c){l[c]=e(r,c,s,o)},{})}return Bw}var qw,xA;function YL(){if(xA)return qw;xA=1;var e=Kn();qw=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 qw}var Uw,bA;function Jee(){if(bA)return Uw;bA=1;var e=Kn(),t=YL();Uw=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 Uw}var zw,kA;function Qee(){if(kA)return zw;kA=1;var e=Kn();zw=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 zw}var Ww,NA;function XL(){if(NA)return Ww;NA=1;var e=Kn();Ww=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,Ww}var Hw,jA;function ete(){if(jA)return Hw;jA=1;var e=XL();Hw=t;function t(n){try{e(n)}catch(r){if(r instanceof e.CycleException)return!1;throw r}return!0}return Hw}var Vw,SA;function ZL(){if(SA)return Vw;SA=1;var e=Kn();Vw=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 Vw}var Gw,_A;function tte(){if(_A)return Gw;_A=1;var e=ZL();Gw=t;function t(n,r){return e(n,r,"post")}return Gw}var Kw,EA;function nte(){if(EA)return Kw;EA=1;var e=ZL();Kw=t;function t(n,r){return e(n,r,"pre")}return Kw}var Yw,TA;function rte(){if(TA)return Yw;TA=1;var e=Kn(),t=lk(),n=GL();Yw=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 Yw}var Xw,CA;function ste(){return CA||(CA=1,Xw={components:Xee(),dijkstra:KL(),dijkstraAll:Zee(),findCycles:Jee(),floydWarshall:Qee(),isAcyclic:ete(),postorder:tte(),preorder:nte(),prim:rte(),tarjan:YL(),topsort:XL()}),Xw}var Zw,AA;function ate(){if(AA)return Zw;AA=1;var e=Kee();return Zw={Graph:e.Graph,json:Yee(),alg:ste(),version:e.version},Zw}var Jw,RA;function wr(){if(RA)return Jw;RA=1;var e;if(typeof V0=="function")try{e=ate()}catch{}return e||(e=window.graphlib),Jw=e,Jw}var Qw,MA;function ote(){if(MA)return Qw;MA=1;var e=kL(),t=1,n=4;function r(s){return e(s,t|n)}return Qw=r,Qw}var ev,$A;function Wh(){if($A)return ev;$A=1;var e=$i(),t=Ss(),n=Oh(),r=Gn();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 ev=s,ev}var tv,IA;function ite(){if(IA)return tv;IA=1;var e=zh(),t=$i(),n=Wh(),r=uo(),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 tv=l,tv}var nv,OA;function lte(){if(OA)return nv;OA=1;var e=_s(),t=Ss(),n=ga();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 nv=r,nv}var rv,LA;function cte(){if(LA)return rv;LA=1;var e=/\s/;function t(n){for(var r=n.length;r--&&e.test(n.charAt(r)););return r}return rv=t,rv}var sv,PA;function ute(){if(PA)return sv;PA=1;var e=cte(),t=/^\s+/;function n(r){return r&&r.slice(0,e(r)+1).replace(t,"")}return sv=n,sv}var av,DA;function dte(){if(DA)return av;DA=1;var e=ute(),t=Gn(),n=Pi(),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 av=d,av}var ov,FA;function JL(){if(FA)return ov;FA=1;var e=dte(),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 ov=r,ov}var iv,BA;function hte(){if(BA)return iv;BA=1;var e=JL();function t(n){var r=e(n),s=r%1;return r===r?s?r-s:r:0}return iv=t,iv}var lv,qA;function fte(){if(qA)return lv;qA=1;var e=WL(),t=_s(),n=hte(),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 lv=s,lv}var cv,UA;function pte(){if(UA)return cv;UA=1;var e=lte(),t=fte(),n=e(t);return cv=n,cv}var uv,zA;function QL(){if(zA)return uv;zA=1;var e=ik();function t(n){var r=n==null?0:n.length;return r?e(n,1):[]}return uv=t,uv}var dv,WA;function mte(){if(WA)return dv;WA=1;var e=rk(),t=NL(),n=uo();function r(s,o){return s==null?s:e(s,t(o),n)}return dv=r,dv}var hv,HA;function gte(){if(HA)return hv;HA=1;function e(t){var n=t==null?0:t.length;return n?t[n-1]:void 0}return hv=e,hv}var fv,VA;function yte(){if(VA)return fv;VA=1;var e=$h(),t=sk(),n=_s();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 fv=r,fv}var pv,GA;function ck(){if(GA)return pv;GA=1;var e=Pi();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 pv=t,pv}var mv,KA;function wte(){if(KA)return mv;KA=1;function e(t,n){return t>n}return mv=e,mv}var gv,YA;function vte(){if(YA)return gv;YA=1;var e=ck(),t=wte(),n=ho();function r(s){return s&&s.length?e(s,n,t):void 0}return gv=r,gv}var yv,XA;function eP(){if(XA)return yv;XA=1;var e=$h(),t=$i();function n(r,s,o){(o!==void 0&&!t(r[s],o)||o===void 0&&!(s in r))&&e(r,s,o)}return yv=n,yv}var wv,ZA;function xte(){if(ZA)return wv;ZA=1;var e=lo(),t=Dh(),n=Hr(),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 wv=h,wv}var vv,JA;function tP(){if(JA)return vv;JA=1;function e(t,n){if(!(n==="constructor"&&typeof t[n]=="function")&&n!="__proto__")return t[n]}return vv=e,vv}var xv,QA;function bte(){if(QA)return xv;QA=1;var e=jc(),t=uo();function n(r){return e(r,t(r))}return xv=n,xv}var bv,eR;function kte(){if(eR)return bv;eR=1;var e=eP(),t=uL(),n=vL(),r=dL(),s=bL(),o=Sc(),l=St(),c=HL(),d=Oi(),h=Nc(),f=Gn(),p=xte(),g=_c(),v=tP(),j=bte();function k(x,N,b,S,E,R,O){var A=v(x,b),q=v(N,b),I=O.get(q);if(I){e(x,b,I);return}var B=R?R(A,q,b+"",x,N,O):void 0,L=B===void 0;if(L){var M=l(q),F=!M&&d(q),C=!M&&!F&&g(q);B=q,M||F||C?l(A)?B=A:c(A)?B=r(A):F?(L=!1,B=t(q,!0)):C?(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&&(O.set(q,B),E(B,q,S,R,O),O.delete(q)),e(x,b,B)}return bv=k,bv}var kv,tR;function Nte(){if(tR)return kv;tR=1;var e=Mh(),t=eP(),n=rk(),r=kte(),s=Gn(),o=uo(),l=tP();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 kv=c,kv}var Nv,nR;function jte(){if(nR)return Nv;nR=1;var e=zh(),t=Wh();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 Nv=n,Nv}var jv,rR;function Ste(){if(rR)return jv;rR=1;var e=Nte(),t=jte(),n=t(function(r,s,o){e(r,s,o)});return jv=n,jv}var Sv,sR;function nP(){if(sR)return Sv;sR=1;function e(t,n){return t<n}return Sv=e,Sv}var _v,aR;function _te(){if(aR)return _v;aR=1;var e=ck(),t=nP(),n=ho();function r(s){return s&&s.length?e(s,n,t):void 0}return _v=r,_v}var Ev,oR;function Ete(){if(oR)return Ev;oR=1;var e=ck(),t=_s(),n=nP();function r(s,o){return s&&s.length?e(s,t(o,2),n):void 0}return Ev=r,Ev}var Tv,iR;function Tte(){if(iR)return Tv;iR=1;var e=xr(),t=function(){return e.Date.now()};return Tv=t,Tv}var Cv,lR;function Cte(){if(lR)return Cv;lR=1;var e=Ih(),t=qh(),n=Oh(),r=Gn(),s=Ec();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 Cv=o,Cv}var Av,cR;function Ate(){if(cR)return Av;cR=1;var e=Uh(),t=Cte(),n=qh();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 Av=r,Av}var Rv,uR;function Rte(){if(uR)return Rv;uR=1;var e=Ate(),t=IL();function n(r,s){return e(r,s,function(o,l){return t(r,l)})}return Rv=n,Rv}var Mv,dR;function Mte(){if(dR)return Mv;dR=1;var e=QL(),t=UL(),n=zL();function r(s){return n(t(s,void 0,e),s+"")}return Mv=r,Mv}var $v,hR;function $te(){if(hR)return $v;hR=1;var e=Rte(),t=Mte(),n=t(function(r,s){return r==null?{}:e(r,s)});return $v=n,$v}var Iv,fR;function Ite(){if(fR)return Iv;fR=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 Iv=n,Iv}var Ov,pR;function Ote(){if(pR)return Ov;pR=1;var e=Ite(),t=Wh(),n=JL();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 Ov=r,Ov}var Lv,mR;function Lte(){if(mR)return Lv;mR=1;var e=Ote(),t=e();return Lv=t,Lv}var Pv,gR;function Pte(){if(gR)return Pv;gR=1;function e(t,n){var r=t.length;for(t.sort(n);r--;)t[r]=t[r].value;return t}return Pv=e,Pv}var Dv,yR;function Dte(){if(yR)return Dv;yR=1;var e=Pi();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 Dv=t,Dv}var Fv,wR;function Fte(){if(wR)return Fv;wR=1;var e=Dte();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 Fv=t,Fv}var Bv,vR;function Bte(){if(vR)return Bv;vR=1;var e=Bh(),t=Uh(),n=_s(),r=FL(),s=Pte(),o=Lh(),l=Fte(),c=ho(),d=St();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 Bv=h,Bv}var qv,xR;function qte(){if(xR)return qv;xR=1;var e=ik(),t=Bte(),n=zh(),r=Wh(),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 qv=s,qv}var Uv,bR;function Ute(){if(bR)return Uv;bR=1;var e=ML(),t=0;function n(r){var s=++t;return e(r)+s}return Uv=n,Uv}var zv,kR;function zte(){if(kR)return zv;kR=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 zv=e,zv}var Wv,NR;function Wte(){if(NR)return Wv;NR=1;var e=Ih(),t=zte();function n(r,s){return t(r||[],s||[],e)}return Wv=n,Wv}var Hv,jR;function at(){if(jR)return Hv;jR=1;var e;if(typeof V0=="function")try{e={cloneDeep:ote(),constant:nk(),defaults:ite(),each:SL(),filter:LL(),find:pte(),flatten:QL(),forEach:jL(),forIn:mte(),has:PL(),isUndefined:DL(),last:gte(),map:BL(),mapValues:yte(),max:vte(),merge:Ste(),min:_te(),minBy:Ete(),now:Tte(),pick:$te(),range:Lte(),reduce:qL(),sortBy:qte(),uniqueId:Ute(),values:VL(),zipObject:Wte()}}catch{}return e||(e=window._),Hv=e,Hv}var Vv,SR;function Hte(){if(SR)return Vv;SR=1,Vv=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 Vv}var Gv,_R;function Vte(){if(_R)return Gv;_R=1;var e=at(),t=wr().Graph,n=Hte();Gv=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 Gv}var Kv,ER;function Gte(){if(ER)return Kv;ER=1;var e=at(),t=Vte();Kv={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 Kv}var Yv,TR;function fn(){if(TR)return Yv;TR=1;var e=at(),t=wr().Graph;Yv={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,O=x.width/2,A=x.height/2;if(!E&&!R)throw new Error("Not possible to find intersection inside of the rectangle");var q,I;return Math.abs(R)*O>Math.abs(E)*A?(R<0&&(A=-A),q=A*E/R,I=A):(E<0&&(O=-O),q=O,I=O*R/E),{x:b+q,y:S+I}}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 O=x.node(R).rank-N;b[O]||(b[O]=[]),b[O].push(R)});var S=0,E=x.graph().nodeRankFactor;e.forEach(b,function(R,O){e.isUndefined(R)&&O%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 Yv}var Xv,CR;function Kte(){if(CR)return Xv;CR=1;var e=at(),t=fn();Xv={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 Xv}var Zv,AR;function Ud(){if(AR)return Zv;AR=1;var e=at();Zv={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 Zv}var Jv,RR;function rP(){if(RR)return Jv;RR=1;var e=at(),t=wr().Graph,n=Ud().slack;Jv=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 Jv}var Qv,MR;function Yte(){if(MR)return Qv;MR=1;var e=at(),t=rP(),n=Ud().slack,r=Ud().longestPath,s=wr().alg.preorder,o=wr().alg.postorder,l=fn().simplify;Qv=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,O;R=v(E);)O=j(E,S,R),k(E,S,R,O)}function d(S,E){var R=o(S,S.nodes());R=R.slice(0,R.length-1),e.forEach(R,function(O){h(S,E,O)})}function h(S,E,R){var O=S.node(R),A=O.parent;S.edge(R,A).cutvalue=f(S,E,R)}function f(S,E,R){var O=S.node(R),A=O.parent,q=!0,I=E.edge(R,A),B=0;return I||(q=!1,I=E.edge(A,R)),B=I.weight,e.forEach(E.nodeEdges(R),function(L){var M=L.v===R,F=M?L.w:L.v;if(F!==A){var C=M===q,$=E.edge(L).weight;if(B+=C?$:-$,N(S,R,F)){var P=S.edge(R,F).cutvalue;B+=C?-P:P}}}),B}function p(S,E){arguments.length<2&&(E=S.nodes()[0]),g(S,{},1,E)}function g(S,E,R,O,A){var q=R,I=S.node(O);return E[O]=!0,e.forEach(S.neighbors(O),function(B){e.has(E,B)||(R=g(S,E,R,B,O))}),I.low=q,I.lim=R++,A?I.parent=A:delete I.parent,R}function v(S){return e.find(S.edges(),function(E){return S.edge(E).cutvalue<0})}function j(S,E,R){var O=R.v,A=R.w;E.hasEdge(O,A)||(O=R.w,A=R.v);var q=S.node(O),I=S.node(A),B=q,L=!1;q.lim>I.lim&&(B=I,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,O){var A=R.v,q=R.w;S.removeEdge(A,q),S.setEdge(O.v,O.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}),O=s(S,R);O=O.slice(1),e.forEach(O,function(A){var q=S.node(A).parent,I=E.edge(A,q),B=!1;I||(I=E.edge(q,A),B=!0),E.node(A).rank=E.node(q).rank+(B?I.minlen:-I.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 Qv}var ex,$R;function Xte(){if($R)return ex;$R=1;var e=Ud(),t=e.longestPath,n=rP(),r=Yte();ex=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 ex}var tx,IR;function Zte(){if(IR)return tx;IR=1;var e=at();tx=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 tx}var nx,OR;function Jte(){if(OR)return nx;OR=1;var e=at(),t=fn();nx={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,O=S.borderTop?f:2*f,A=E!==R?1:p-g[v]+1;c.setEdge(k,E,{weight:O,minlen:A,nestingEdge:!0}),c.setEdge(R,x,{weight:O,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 nx}var rx,LR;function Qte(){if(LR)return rx;LR=1;var e=at(),t=fn();rx=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 rx}var sx,PR;function ene(){if(PR)return sx;PR=1;var e=at();sx={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 sx}var ax,DR;function tne(){if(DR)return ax;DR=1;var e=at();ax=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 ax}var ox,FR;function nne(){if(FR)return ox;FR=1;var e=at();ox=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 ox}var ix,BR;function rne(){if(BR)return ix;BR=1;var e=at();ix=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 ix}var lx,qR;function sne(){if(qR)return lx;qR=1;var e=at();lx=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 lx}var cx,UR;function ane(){if(UR)return cx;UR=1;var e=at(),t=fn();cx=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 cx}var ux,zR;function one(){if(zR)return ux;zR=1;var e=at(),t=rne(),n=sne(),r=ane();ux=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 O=s(c,R.v,h,f);k[R.v]=O,e.has(O,"barycenter")&&l(R,O)}});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 ux}var dx,WR;function ine(){if(WR)return dx;WR=1;var e=at(),t=wr().Graph;dx=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 dx}var hx,HR;function lne(){if(HR)return hx;HR=1;var e=at();hx=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 hx}var fx,VR;function cne(){if(VR)return fx;VR=1;var e=at(),t=tne(),n=nne(),r=one(),s=ine(),o=lne(),l=wr().Graph,c=fn();fx=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 fx}var px,GR;function une(){if(GR)return px;GR=1;var e=at(),t=wr().Graph,n=fn();px={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,O){var A=0,q=0,I=R.length,B=e.last(O);return e.forEach(O,function(L,M){var F=o(N,L),C=F?N.node(F).order:I;(F||L===B)&&(e.forEach(O.slice(q,M+1),function($){e.forEach(N.predecessors($),function(P){var K=N.node(P),G=K.order;(G<A||C<G)&&!(K.dummy&&N.node($).dummy)&&l(S,P,$)})}),q=M+1,A=C)}),O}return e.reduce(b,E),S}function s(N,b){var S={};function E(O,A,q,I,B){var L;e.forEach(e.range(A,q),function(M){L=O[M],N.node(L).dummy&&e.forEach(N.predecessors(L),function(F){var C=N.node(F);C.dummy&&(C.order<I||C.order>B)&&l(S,F,L)})})}function R(O,A){var q=-1,I,B=0;return e.forEach(A,function(L,M){if(N.node(L).dummy==="border"){var F=N.predecessors(L);F.length&&(I=N.node(F[0]).order,E(A,B,M,q,I),B=M,q=I)}E(A,B,A.length,I,O.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={},O={},A={};return e.forEach(b,function(q){e.forEach(q,function(I,B){R[I]=I,O[I]=I,A[I]=B})}),e.forEach(b,function(q){var I=-1;e.forEach(q,function(B){var L=E(B);if(L.length){L=e.sortBy(L,function(P){return A[P]});for(var M=(L.length-1)/2,F=Math.floor(M),C=Math.ceil(M);F<=C;++F){var $=L[F];O[B]===B&&I<A[$]&&!c(S,B,$)&&(O[$]=B,O[B]=R[B]=R[$],I=A[$])}}})}),{root:R,align:O}}function h(N,b,S,E,R){var O={},A=f(N,b,S,R),q=R?"borderLeft":"borderRight";function I(M,F){for(var C=A.nodes(),$=C.pop(),P={};$;)P[$]?M($):(P[$]=!0,C.push($),C=C.concat(F($))),$=C.pop()}function B(M){O[M]=A.inEdges(M).reduce(function(F,C){return Math.max(F,O[C.v]+A.edge(C))},0)}function L(M){var F=A.outEdges(M).reduce(function($,P){return Math.min($,O[P.w]-A.edge(P))},Number.POSITIVE_INFINITY),C=N.node(M);F!==Number.POSITIVE_INFINITY&&C.borderType!==q&&(O[M]=Math.max(O[M],F))}return I(B,A.predecessors.bind(A)),I(L,A.successors.bind(A)),e.forEach(E,function(M){O[M]=O[S[M]]}),O}function f(N,b,S,E){var R=new t,O=N.graph(),A=k(O.nodesep,O.edgesep,E);return e.forEach(b,function(q){var I;e.forEach(q,function(B){var L=S[B];if(R.setNode(L),I){var M=S[I],F=R.edge(M,L);R.setEdge(M,L,Math.max(A(N,B,I),F||0))}I=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(O,A){var q=x(N,A)/2;E=Math.max(O+q,E),R=Math.min(O-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(O){e.forEach(["l","r"],function(A){var q=O+A,I=N[q],B;if(I!==b){var L=e.values(I);B=A==="l"?E-e.min(L):R-e.max(L),B&&(N[q]=e.mapValues(I,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 I=(A==="u"?N.predecessors:N.successors).bind(N),B=d(N,R,S,I),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 O=p(N,E);return g(E,O),v(E,N.graph().align)}function k(N,b,S){return function(E,R,O){var A=E.node(R),q=E.node(O),I=0,B;if(I+=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&&(I+=S?B:-B),B=0,I+=(A.dummy?b:N)/2,I+=(q.dummy?b:N)/2,I+=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&&(I+=S?B:-B),B=0,I}}function x(N,b){return N.node(b).width}return px}var mx,KR;function dne(){if(KR)return mx;KR=1;var e=at(),t=fn(),n=une().positionX;mx=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 mx}var gx,YR;function hne(){if(YR)return gx;YR=1;var e=at(),t=Gte(),n=Kte(),r=Xte(),s=fn().normalizeRanks,o=Zte(),l=fn().removeEmptyRanks,c=Jte(),d=Qte(),h=ene(),f=cne(),p=dne(),g=fn(),v=wr().Graph;gx=j;function j(V,Z){var Y=Z&&Z.debugTiming?g.time:g.notime;Y("layout",function(){var X=Y(" buildLayoutGraph",function(){return I(V)});Y(" runLayout",function(){k(X,Y)}),Y(" updateInputGraph",function(){x(V,X)})})}function k(V,Z){Z(" makeSpaceForEdgeLabels",function(){B(V)}),Z(" removeSelfEdges",function(){U(V)}),Z(" acyclic",function(){t.run(V)}),Z(" nestingGraph.run",function(){c.run(V)}),Z(" rank",function(){r(g.asNonCompoundGraph(V))}),Z(" injectEdgeLabelProxies",function(){L(V)}),Z(" removeEmptyRanks",function(){l(V)}),Z(" nestingGraph.cleanup",function(){c.cleanup(V)}),Z(" normalizeRanks",function(){s(V)}),Z(" assignRankMinMax",function(){M(V)}),Z(" removeEdgeLabelProxies",function(){F(V)}),Z(" normalize.run",function(){n.run(V)}),Z(" parentDummyChains",function(){o(V)}),Z(" addBorderSegments",function(){d(V)}),Z(" order",function(){f(V)}),Z(" insertSelfEdges",function(){W(V)}),Z(" adjustCoordinateSystem",function(){h.adjust(V)}),Z(" position",function(){p(V)}),Z(" positionSelfEdges",function(){D(V)}),Z(" removeBorderNodes",function(){G(V)}),Z(" normalize.undo",function(){n.undo(V)}),Z(" fixupEdgeLabelCoords",function(){P(V)}),Z(" undoCoordinateSystem",function(){h.undo(V)}),Z(" translateGraph",function(){C(V)}),Z(" assignNodeIntersects",function(){$(V)}),Z(" reversePoints",function(){K(V)}),Z(" acyclic.undo",function(){t.undo(V)})}function x(V,Z){e.forEach(V.nodes(),function(Y){var X=V.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(V.edges(),function(Y){var X=V.edge(Y),ee=Z.edge(Y);X.points=ee.points,e.has(ee,"x")&&(X.x=ee.x,X.y=ee.y)}),V.graph().width=Z.graph().width,V.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},O=["minlen","weight","width","height","labeloffset"],A={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},q=["labelpos"];function I(V){var Z=new v({multigraph:!0,compound:!0}),Y=J(V.graph());return Z.setGraph(e.merge({},b,H(Y,N),e.pick(Y,S))),e.forEach(V.nodes(),function(X){var ee=J(V.node(X));Z.setNode(X,e.defaults(H(ee,E),R)),Z.setParent(X,V.parent(X))}),e.forEach(V.edges(),function(X){var ee=J(V.edge(X));Z.setEdge(X,e.merge({},A,H(ee,O),e.pick(ee,q)))}),Z}function B(V){var Z=V.graph();Z.ranksep/=2,e.forEach(V.edges(),function(Y){var X=V.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(V){e.forEach(V.edges(),function(Z){var Y=V.edge(Z);if(Y.width&&Y.height){var X=V.node(Z.v),ee=V.node(Z.w),ae={rank:(ee.rank-X.rank)/2+X.rank,e:Z};g.addDummyNode(V,"edge-proxy",ae,"_ep")}})}function M(V){var Z=0;e.forEach(V.nodes(),function(Y){var X=V.node(Y);X.borderTop&&(X.minRank=V.node(X.borderTop).rank,X.maxRank=V.node(X.borderBottom).rank,Z=e.max(Z,X.maxRank))}),V.graph().maxRank=Z}function F(V){e.forEach(V.nodes(),function(Z){var Y=V.node(Z);Y.dummy==="edge-proxy"&&(V.edge(Y.e).labelRank=Y.rank,V.removeNode(Z))})}function C(V){var Z=Number.POSITIVE_INFINITY,Y=0,X=Number.POSITIVE_INFINITY,ee=0,ae=V.graph(),ue=ae.marginx||0,ge=ae.marginy||0;function ye(se){var me=se.x,pe=se.y,de=se.width,fe=se.height;Z=Math.min(Z,me-de/2),Y=Math.max(Y,me+de/2),X=Math.min(X,pe-fe/2),ee=Math.max(ee,pe+fe/2)}e.forEach(V.nodes(),function(se){ye(V.node(se))}),e.forEach(V.edges(),function(se){var me=V.edge(se);e.has(me,"x")&&ye(me)}),Z-=ue,X-=ge,e.forEach(V.nodes(),function(se){var me=V.node(se);me.x-=Z,me.y-=X}),e.forEach(V.edges(),function(se){var me=V.edge(se);e.forEach(me.points,function(pe){pe.x-=Z,pe.y-=X}),e.has(me,"x")&&(me.x-=Z),e.has(me,"y")&&(me.y-=X)}),ae.width=Y-Z+ue,ae.height=ee-X+ge}function $(V){e.forEach(V.edges(),function(Z){var Y=V.edge(Z),X=V.node(Z.v),ee=V.node(Z.w),ae,ue;Y.points?(ae=Y.points[0],ue=Y.points[Y.points.length-1]):(Y.points=[],ae=ee,ue=X),Y.points.unshift(g.intersectRect(X,ae)),Y.points.push(g.intersectRect(ee,ue))})}function P(V){e.forEach(V.edges(),function(Z){var Y=V.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 K(V){e.forEach(V.edges(),function(Z){var Y=V.edge(Z);Y.reversed&&Y.points.reverse()})}function G(V){e.forEach(V.nodes(),function(Z){if(V.children(Z).length){var Y=V.node(Z),X=V.node(Y.borderTop),ee=V.node(Y.borderBottom),ae=V.node(e.last(Y.borderLeft)),ue=V.node(e.last(Y.borderRight));Y.width=Math.abs(ue.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(V.nodes(),function(Z){V.node(Z).dummy==="border"&&V.removeNode(Z)})}function U(V){e.forEach(V.edges(),function(Z){if(Z.v===Z.w){var Y=V.node(Z.v);Y.selfEdges||(Y.selfEdges=[]),Y.selfEdges.push({e:Z,label:V.edge(Z)}),V.removeEdge(Z)}})}function W(V){var Z=g.buildLayerMatrix(V);e.forEach(Z,function(Y){var X=0;e.forEach(Y,function(ee,ae){var ue=V.node(ee);ue.order=ae+X,e.forEach(ue.selfEdges,function(ge){g.addDummyNode(V,"selfedge",{width:ge.label.width,height:ge.label.height,rank:ue.rank,order:ae+ ++X,e:ge.e,label:ge.label},"_se")}),delete ue.selfEdges})})}function D(V){e.forEach(V.nodes(),function(Z){var Y=V.node(Z);if(Y.dummy==="selfedge"){var X=V.node(Y.e.v),ee=X.x+X.width/2,ae=X.y,ue=Y.x-ee,ge=X.height/2;V.setEdge(Y.e,Y.label),V.removeNode(Z),Y.label.points=[{x:ee+2*ue/3,y:ae-ge},{x:ee+5*ue/6,y:ae-ge},{x:ee+ue,y:ae},{x:ee+5*ue/6,y:ae+ge},{x:ee+2*ue/3,y:ae+ge}],Y.label.x=Y.x,Y.label.y=Y.y}})}function H(V,Z){return e.mapValues(e.pick(V,Z),Number)}function J(V){var Z={};return e.forEach(V,function(Y,X){Z[X.toLowerCase()]=Y}),Z}return gx}var yx,XR;function fne(){if(XR)return yx;XR=1;var e=at(),t=fn(),n=wr().Graph;yx={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 yx}var wx,ZR;function pne(){return ZR||(ZR=1,wx="0.8.5"),wx}var vx,JR;function mne(){return JR||(JR=1,vx={graphlib:wr(),layout:hne(),debug:fne(),util:{time:fn().time,notime:fn().notime},version:pne()}),vx}var gne=mne();const QR=Ub(gne),dc=240,sP=130,Tb=Va*2+tb+j0,yne=72,fi=Tb+yne,hd=24,aP=Va*2+hd,zd=fi;function oP(e,t){var r;let n=dc;for(const s of e)n=Math.max(n,((r=t.get(s.id))==null?void 0:r.width)??dc);return n}const Wd=420,iP=1;function wne(e,t,n,r){return Math.min(iP,n/Math.max(1,e),r/Math.max(1,t))}function Hh(e){var n;return((n=e.data)==null?void 0:n.sessionId)??"_default"}function Vh(e,t=()=>!0){const n=new Map;for(const r of e){if(!t(r))continue;const s=Hh(r),o=n.get(s);o?o.push(r):n.set(s,[r])}return n}function vne(e,t){return((t==null?void 0:t.get(e))??0)>0?Wd:0}function xne(e,t){const n=(t==null?void 0:t.get(e))??0;return n>0?6+n*36:0}function Hd(e,t){const n=t.get(e);return{w:(n==null?void 0:n.width)??dc,h:(n==null?void 0:n.height)??sP}}function hc(e,t,n){const r=Hd(e,t);return{w:r.w+vne(e,n),h:Math.max(r.h,xne(e,n))}}function bne(e){return[...e.keys()].sort().map(t=>`${t}:${e.get(t)}`).join("|")}function kne(e,t,n){const r=Vh(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(Hh(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 Nne(e,t,n,r,s,o,l){const c=S=>hc(S,r,o),d=S=>n.get(S)??t.get(S),h=S=>{const{w:E,h:R}=Hd(S,r);return{cw:E,ch:R}},f=l!=null&&l.width>0&&l.height>0,p=Vh(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:O}=c(S.id),A=Hh(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:O,...h(S.id)})}if(v.size===0||f&&j.length===0)return[];const k=zd,x=(S,E,R,O)=>j.some(A=>S<A.x+A.w+Tb&&A.x<S+R+Tb&&E<A.y+A.h+k&&A.y<E+O+k),N=oP(e,r),b=[];for(const S of[...v.keys()].sort()){const E=v.get(S);let R=1/0,O=1/0,A=-1/0,q=-1/0,I=-1/0,B=-1/0;for(const K of E){const G=d(K.id),{w:U,h:W}=c(K.id),{cw:D,ch:H}=h(K.id);R=Math.min(R,G.x),O=Math.min(O,G.y),A=Math.max(A,G.x+U),q=Math.max(q,G.y+W),I=Math.max(I,G.x+D),B=Math.max(B,G.y+H)}const L=A-R,M=q-O,F=[...new Set(j.map(K=>Math.round(K.x)))].sort((K,G)=>K-G),C=F.length?F:[R],$=[0,...j.map(K=>K.y+K.h+k)].sort((K,G)=>K-G);let P=null;if(f){let K=1/0,G=1/0,U=-1/0,W=-1/0;for(const Y of j)K=Math.min(K,Y.x),G=Math.min(G,Y.y),U=Math.max(U,Y.x+Y.cw),W=Math.max(W,Y.y+Y.ch);const D=(Y,X)=>{const ee=l.width/(Math.max(U,Y+I-R)-Math.min(K,Y)+Wd),ae=l.height/(Math.max(W,X+B-O)-Math.min(G,X));return[Math.min(iP,ee,ae),Math.min(ee,ae),Math.max(ee,ae)]},H=(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+Wd+N),V=[...new Set([...$,G])].sort((Y,X)=>Y-X);let Z=null;for(const Y of[...C,J])for(const X of V){if(x(Y,X,L,M))continue;const ee=D(Y,X);(Z===null||H(ee,Z))&&(Z=ee,P={x:Y,y:X})}P&&P.x===R&&P.y===O&&(P=null)}else e:for(const K of C)for(const G of $){if(G>=O)break;if(!x(K,G,L,M)){P={x:K,y:G};break e}}if(P){const K=P.x-R,G=P.y-O;for(const U of E){const W=d(U.id);t.set(U.id,{x:W.x+K,y:W.y+G})}b.push(S)}for(const K of E){const G=d(K.id),{w:U,h:W}=c(K.id);j.push({x:G.x,y:G.y,w:U,h:W,...h(K.id)})}}return b}function jne(e,t,n,r,s,o){const l=g=>hc(g,r,s),c=new Map(e.map(g=>[g.id,Hh(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?hd:aP,O=E.sid===x?hd:zd;return v.x<E.x+E.w+R&&E.x<v.x+j+R&&N<E.y+E.h+O&&E.y<N+k+O});if(!S)break;N=S.y+S.h+(S.sid===x?hd:zd)}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 Sne(e,t,n,r,s,o=!1,l){const d=aP+1,h=zd+1,f=8,p=1.75,g=200,v=.7,j=.01,k=M=>hc(M,r,l),x=M=>n.get(M)??t.get(M),N=Vh(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 C=1/0,$=1/0,P=-1/0,K=-1/0,G=!1;for(const H of F){const J=x(H.id),{w:V,h:Z}=k(H.id);C=Math.min(C,J.x),$=Math.min($,J.y),P=Math.max(P,J.x+V),K=Math.max(K,J.y+Z),n.has(H.id)&&(G=!0)}const U=P-C,W=K-$;E.add(M);const D=s.get(M);D&&(U>D.w+f||W>D.h+f)&&S.add(M),s.set(M,{w:U,h:W}),b.push({sid:M,members:F.map(H=>H.id),x:C,y:$,w:U,h:W,anchored:G,mass:1})}for(const M of[...s.keys()])E.has(M)||s.delete(M);if(o||R)return[];let O=!1;for(let M=0;M<b.length&&!O;M++)for(let F=M+1;F<b.length;F++){const C=b[M],$=b[F];if(!(C.anchored&&$.anchored)&&Math.abs(C.x+C.w/2-($.x+$.w/2))<(C.w+$.w)/2+d&&Math.abs(C.y+C.h/2-($.y+$.h/2))<(C.h+$.h)/2+h){O=!0;break}}if(S.size===0&&!O)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/(dc*sP));const A=new Map(b.map(M=>[M.sid,M.x])),q=new Map(b.map(M=>[M.sid,M.y])),I=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,C=new Map;let $=0;for(let P=0;P<b.length;P++)for(let K=P+1;K<b.length;K++){const G=b[P],U=b[K];if(G.anchored&&U.anchored)continue;const W=G.x+G.w/2,D=G.y+G.h/2,H=U.x+U.w/2,J=U.y+U.h/2,V=(G.w+U.w)/2+d-Math.abs(W-H),Z=(G.h+U.h)/2+h-Math.abs(D-J);if(V<=0||Z<=0)continue;const Y=(Oe,Qe)=>!Oe.anchored&&!(Qe<0&&Oe.x<=I.get(Oe.sid)),X=(Oe,Qe)=>!Oe.anchored&&!(Qe<0&&Oe.y<=B.get(Oe.sid)),ee=(Oe,Qe,Ye)=>{const Xe=Oe===Qe,ot=Xe?G.sid<U.sid?-1:1:Math.sign(Oe-Qe);return Ye(G,ot)||Ye(U,-ot)?ot:Xe&&(Ye(G,-ot)||Ye(U,ot))?-ot:0},ae=ee(W,H,Y),ue=ee(D,J,X),ge=ae!==0,ye=ue!==0;if(!ge&&!ye)continue;const se=ge&&(!ye||V*p<Z),[me,pe,de,fe]=se?[ae,V,F,Y]:[ue,Z,C,X],ne=fe(G,me),oe=fe(U,-me),Ne=G.mass,we=U.mass,Ie=ne?oe?we/(Ne+we):1:0,Pe=oe?ne?Ne/(Ne+we):1:0,Be=pe*v;de.set(G.sid,(de.get(G.sid)??0)+me*Be*Ie),de.set(U.sid,(de.get(U.sid)??0)-me*Be*Pe),$+=Be}for(const P of b)P.anchored||(P.x=Math.max(I.get(P.sid),P.x+(F.get(P.sid)??0)),P.y=Math.max(B.get(P.sid),P.y+(C.get(P.sid)??0)));if($<j)break}const L=[];for(const M of b){const F=M.x-A.get(M.sid),C=M.y-q.get(M.sid);if(!(Math.abs(F)<1&&Math.abs(C)<1)){for(const $ of M.members){if(n.has($))continue;const P=t.get($);P&&t.set($,{x:P.x+F,y:P.y+C})}L.push(M.sid)}}return L}function _ne(e,t,n,r,s,o){const l=new QR.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}=hc(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);QR.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}=Hd(N,r),R=hc(N,r,o),O=b.x-R.w/2,A=b.y-R.h/2;h.set(N,{x:O,y:A}),O<f&&(f=O),A<p&&(p=A),O+S>g&&(g=O+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}=Hd(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 lP(e,t,n){const r=n.direction??"LR",s=n.pinned??new Map,o=n.measured??new Map,l=n.lanes,c=Vh(e);return{laid:Array.from(c.keys()).sort().map(f=>({sid:f,..._ne(c.get(f).map(p=>p.id),t,r,o,s,l)})),gap:oP(e,o)}}const cP=e=>e.reduce((t,n)=>Math.max(t,n.width),0)+Wd,Ene=e=>e.reduce((t,n)=>t+n.height,0)+fi*Math.max(0,e.length-1);function Cb(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+fi;return h},o=[];for(let d=0;d<e.length;d++){let h=-fi;for(let f=d;f<e.length;f++)o.push(h+=e[f].height+fi)}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=>wne(f.reduce((p,g)=>p+cP(g),0)+t*(f.length-1),Math.max(...f.map(Ene)),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 Tne(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}=lP(e,t,n);return o.length<2?!1:Cb(o,l,r.width,r.height).length!==Cb(o,l,s.width,s.height).length}function Cne(e,t,n={}){const r=n.pinned??new Map,{laid:s,gap:o}=lP(e,t,n),l=Cb(s,o,n.availableWidth??0,n.availableHeight??0),c=new Map;let d=0;for(const h of l){const f=cP(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+fi}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 fd(e,t,n){return!t.has(e)||n.has(e)}function Ane(e,t,n,r){return!t.has(e)&&fd(e,n,r)}function Rne(e,t,n){const r={x:0,y:0};return t.set(e,r),n.add(e),r}function eM(e,t,n,r){n.set(e,t),r.delete(e)}const Mne=300,tM=130,$ne=160,nM=new WeakMap;function Ine(e,t){let n=nM.get(e);(!n||n.revision!==e.revision||n.open!==t)&&(n={revision:e.revision,open:t,byId:new Map,branches:Mz(e.agents.values())},nM.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 uk(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 One(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??dc),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 Lne(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 Pne(e,t,n,r,s,o,l,c,d,h,f,p,g,v,j,k,x,N,b,S){var K,G,U,W;const E=[],R=[],O=Ine(e,N);for(const D of e.agents.values()){if(!x.has(D.id))continue;const H=D.exitAt!=null,J=k!=null&&!k.has(D.id),V=[H?"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:O(D),className:V,ariaLabel:UU(D,t,j.has(D.id)),...Z?{width:Z.width,height:Z.height}:null}),D.parentId&&x.has(D.parentId)){const ee=nc(D.sessionId),ae=H,ue=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=ue?ye+1.5:ye,me=ae?.2:ge?.12:1,pe=["sess-edge",D.state==="active"?"sess-live":"sess-idle",ae?"rf-edge-exiting":"",ue?"rf-edge-selected":""].filter(Boolean).join(" ");R.push({id:`e:${D.parentId}->${D.id}`,source:D.parentId,target:D.id,animated:(D.state==="active"||ue)&&!ae,type:"smoothstep",style:{"--session-hue":ee,strokeWidth:`calc(${se}px * var(--edge-k, 1))`,opacity:me,transition:"var(--edge-transition)"},className:pe})}const Y=D.kind==="root"?uh(D):null,X=Y?Y.key:null;if(Y&&X&&!kz(X)){const ee=w0(D.id),ae=nc(D.sessionId),ue=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}: ${da(Y.kind)}`,...ue?{width:ue.width,height:ue.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=uk(e),q=S.size>0&&!(d&&b);q||S.clear();const I=`${g}#lanes:${bne(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&&_z(D)&&!B.has(D)&&!s.has(D)&&(f.delete(D),p.delete(D));const L=E.filter(D=>Ane(D.id,s,f,p));if(L.length>0||I!==v.current){if(L.length>0){for(const H of L)S.delete(H.id);const D=kne(Cne(E,R,{direction:"LR",pinned:s,measured:o,availableWidth:n,availableHeight:r,lanes:A}),s,H=>fd(H,f,p)?void 0:f.get(H));for(const H of D)fd(H.id,f,p)&&eM(H.id,H.position,f,p);Nne(E,f,s,o,new Set(L.filter(H=>H.type!=="recapNote").map(H=>H.id)),A,{width:n,height:r});for(const H of L){if(H.type!=="recapNote")continue;const J=(K=H.data)==null?void 0:K.parentId;if(!J)continue;const V=s.get(J)??(fd(J,f,p)?void 0:f.get(J));if(!V)continue;const Z=((G=o.get(H.id))==null?void 0:G.width)??Mne,Y=((U=o.get(H.id))==null?void 0:U.height)??tM,X=((W=o.get(J))==null?void 0:W.height)??tM;eM(H.id,{x:V.x-$ne-Z,y:V.y+(X-Y)/2},f,p)}}jne(E,f,s,o,A,q?S:void 0),v.current=I}const M=Sne(E,f,s,o,l,!d||h,A);M.length>0&&c(M);const F=XJ(e.agents.values());b&&Ju(f,F),Ju(p,F),b&&Ju(s,F),Ju(o,YJ(e.agents.values()));const C=[];let $=!1;for(const D of E){let H=s.get(D.id)??f.get(D.id);H||(H=Rne(D.id,f,p),$=!0),C.push({...D,position:H})}return $&&(v.current=""),{nodes:One(C,D=>{if(D.type==="recapNote")return-1;const H=e.agents.get(D.id);return H?Lne(e,H):0}),edges:R}}function Dne(e){return e.slice().sort((t,n)=>t.y-n.y||t.x-n.x)}function Fne(e,t,n){var l;if(e.length===0)return null;const r=Dne(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 Bne=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Escape","Backspace"]);function qne(e,t){return t==null?{kind:"deck",nodeId:null}:e.key==="Enter"||e.key===" "?{kind:"activate",nodeId:t,additive:e.shiftKey}:Bne.has(e.key)?{kind:"node",nodeId:t}:{kind:"deck",nodeId:t}}const Une=new Set(["","BODY","HTML","#DOCUMENT"]);function zne(e){return!e||ki(e)?!1:!Une.has(String(e.tagName??"").toUpperCase())}const uP="react-flow__node";function dk(e){var t,n;return!!e&&((n=(t=e.classList)==null?void 0:t.contains)==null?void 0:n.call(t,uP))===!0}function dP(e){try{const t=document.querySelector(`.${uP}[data-id="${CSS.escape(e)}"]`);t==null||t.focus({preventScroll:!0})}catch{}}let Ja=null,ii=null;const Ab=new Set,Rb=()=>{for(const e of Ab)e()},Wne=e=>(Ab.add(e),()=>{Ab.delete(e)}),rM=()=>Ja,Hne=90;function hP(e){!ii||e!=null&&ii.at.id!==e||(clearTimeout(ii.timer),ii=null)}function fP(e,t,n="pointer"){hP();const r={id:e,anchor:t,by:n};if(Ja||n==="focus"){Ja=r,Rb();return}ii={at:r,timer:setTimeout(()=>{ii=null,Ja=r,Rb()},Hne)}}function pa(e){hP(e),!(!Ja||e!=null&&Ja.id!==e)&&(Ja=null,Rb())}function Vne({agentFor:e,recapFor:t,labelFor:n,bounds:r}){const s=y.useSyncExternalStore(Wne,rM,rM),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&&pa(s.id)},[c,s]),!s||c?null:o?a.jsx(Kne,{a:o,anchor:s.anchor,parentLabel:o.parentId?n(o.parentId):void 0,bounds:r},s.id):l?a.jsx(Gne,{r:l,anchor:s.anchor,bounds:r},s.id):null}function pP(e,t){const n=y.useRef(null),r=y.useCallback(()=>{const s=n.current;if(!s||!e.isConnected)return;s.style.maxHeight="";const o=A0(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 Gne({r:e,anchor:t,bounds:n}){const r=pP(t,n),s=Mi(3e4),o=e.note,l=o.kind==="recap",c=Md(o.at,s);return Dt.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(Td,{recap:l}),da(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:[dh(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 Kne({a:e,anchor:t,parentLabel:n,bounds:r}){const s=pP(t,r),o=Mi(1e3),l=g0(e.sessionName,e.sessionTitle),c=e.toolErrorCount??0,d=e.tools.filter(k=>!k.endedAt).length,h=pn(e,o).total,f=e.usage.inputTokens+e.usage.outputTokens,p=e.kind==="root"&&jn(e.waiting),g=Q$(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?`${rt(f)} tok`:null,h>0?`${qe(h)}${rc(e,o)>0?"+":""}`:null].filter(Boolean).join(" · ");return Dt.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?"≥ ":"",bi(e.startedAt,e.endedAt,o)]})]}),a.jsxs("div",{className:"node-peek-kind",children:[a.jsxs("span",{className:"node-peek-state","data-kind":Xx(e.state),children:[a.jsx(yI,{kind:Xx(e.state)}),vi(e.state)]}),a.jsx("span",{children:v}),e.model?a.jsx("span",{children:Ns(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(b0,{}),a.jsxs("span",{className:"node-peek-said",title:Ed(e.waiting),children:[a.jsx("span",{className:"node-peek-since",children:a.jsx("b",{children:bi(e.waiting.since,void 0,o)})}),Ed(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:uI(e.branch)}),a.jsx("p",{className:"node-peek-hint",children:"Click to go to the session · double-click for details"})]}),document.body)}function Yne(e){const t=e.minZoom??eJ,n=e.maxZoom??tJ,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 Xne(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 Sn(e){const t=y.useRef(e);return t.current=e,t}const Mb=80,$b=.86;function mP(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 Zne({canvasRef:e,canvasSize:t,machinePhase:n,usagePhase:r,usagePanelOpen:s,detailShown:o}){const[l,c]=y.useState(0);y.useEffect(()=>{const p=mP(e.current);c(g=>Math.abs(g-p)>40?p:g)},[n,r,s,o,t.w]);const d=Sn(l),h=t.w>0?Math.max(0,(t.w-l-Mb*2)*$b):0,f=t.h>0?Math.max(0,(t.h-Mb*2)*$b):0;return{railInsetRef:d,availableWidth:h,availableHeight:f}}const sM=1e-6;function Hl(e){return Number.isFinite(e[0])&&Number.isFinite(e[1])&&Number.isFinite(e[2])&&e[2]>0}function aM(e,t,n){return Math.abs(e[2]-t[2])<=sM*t[2]&&Math.hypot(e[0]-t[0],e[1]-t[1])<=sM*n}function Jne(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 Qne(e,t,n){const r=e(0),s=e(.5),o=e(1);if(!Hl(r)||!Hl(s)||!Hl(o))return!1;const l=Math.max(t[2],n[2]);return aM(r,t,l)&&aM(o,n,l)}function ere(e){return(t,n)=>{const r=e(t,n),s=Qne(r,t,n)?r:Jne(t,n);let o=Hl(t)?t:n;return l=>{const c=s(l);return Hl(c)&&(o=c),o}}}function tre(e){return Number.isFinite(e.x)&&Number.isFinite(e.y)&&Number.isFinite(e.zoom)&&e.zoom>0}const oM=new WeakSet,gP=420;function nre(){const e=Ti(),t=jt(),n=y.useCallback((d,h)=>{if(!tre(d))return;if(Vx({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||oM.has(h)||(oM.add(h),h.interpolate(ere(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=Vx({durationMs:h,documentHidden:document.hidden})?{target:d,until:Date.now()+h+60}:null,f},[n]),c=y.useCallback((d=500)=>{const h=Mb,f=1,p=.2,g=$b;try{const v=document.querySelector(".canvas-wrap"),j=Array.from(document.querySelectorAll(".react-flow__node")).filter($=>$.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=$=>($-k.left-x.x)/x.zoom,b=$=>($-k.top-x.y)/x.zoom,S=j.map($=>$.getBoundingClientRect()),E=Math.min(...S.map($=>N($.left))),R=Math.max(...S.map($=>N($.right))),O=Math.min(...S.map($=>b($.top))),A=Math.max(...S.map($=>b($.bottom))),q=R-E,I=A-O;if(!(q>0&&I>0))return;const B=mP(v),L=$=>Math.max(p,Math.min(f,(k.width-B-h*2)/(q+$)*g,(k.height-h*2)/I*g)),M=QZ(L(gP),L(0)),F={x:h-E*M,y:Math.max(h,(k.height-I*M)/2)-O*M,zoom:M},C=l(F,d);window.setTimeout(()=>{var $;try{if((($=r.current)==null?void 0:$.target)===F&&(r.current=null),s.current!==C)return;const P=e.getViewport();(Math.abs(P.zoom-M)>.01||Math.abs(P.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 rre=450;function sre({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=uk(t.current),b=(I,B)=>{const L=n.current.get(I.id);if(!L)return null;const M=B&&N.has(I.id)?gP:0;return{x:I.position.x,y:I.position.y,width:L.width+M,height:L.height}},S=r.current.find(I=>I.id===j),E=S?b(S,!1):null;if(!E)return;const R=[];for(const I of r.current){if(I.type!=="agent"&&I.type!=="recapNote"||((q=I.data)==null?void 0:q.sessionId)!==x.sessionId)continue;const B=b(I,I.type==="agent");B&&R.push(B)}const O=k.getBoundingClientRect(),A=Yne({pane:{width:O.width,height:O.height},insets:{top:56,left:72,bottom:32,right:s.current+32},context:Xne(R)??E,anchor:E});pa(),l(),c.current={id:j,at:Date.now()},o(A,rre)},[o,l]);d.current=p;const g=y.useCallback(j=>{const k=r.current.filter(S=>S.type==="agent"),x=Fne(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=dk(document.activeElement);h(N.id,!1),window.setTimeout(()=>{try{p(N.id)}catch{}b&&dP(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 are({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 ore(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 iM(e){return Object.entries(e??{}).filter(([,t])=>t&&typeof t.x=="number"&&typeof t.y=="number")}function ire(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=iM(n);return{positions:s,pins:s.map(([o])=>o)}}const r=n;return{positions:iM(r.positions),pins:Array.isArray(r.pins)?r.pins:[]}}function lre(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 cre(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 hk="agent-dag.layout",fk="agent-dag.layoutFrame",pk="agent-dag.viewport";function ure(){return ire(Je(hk))}function fc(e,t){Ke(hk,lre(e,t))}function dre(){return cre(Je(fk))}function yP(e){Ke(fk,JSON.stringify(e))}function hre(){return oq(Je(pk))}function fre(e){Ke(pk,JSON.stringify(e))}function wP(){ws(hk),ws(pk),ws(fk)}function pre(e){const t=y.useState(()=>ore(ure()))[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(dre)[0],h=y.useRef(d),f=y.useCallback(()=>{n.current.clear(),r.current.clear(),o.current="",wP(),c(p=>p+1),window.setTimeout(()=>{fc(r.current,n.current),h.current&&yP(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 mre(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(()=>{fc(n.current,r.current)},1500),()=>{s.current!=null&&window.clearTimeout(s.current)}),[e])}function gre({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:O,cameraEpochRef:A,lastFitTimeRef:q}=c;y.useEffect(()=>{if(!n||r)return;const I={width:s,height:o};if(!(I.width>0&&I.height>0))return;const B=k.current;if(k.current=I,yP(I),!B||B.width===I.width&&B.height===I.height)return;const L={direction:"LR",pinned:x.current,measured:h.current,lanes:uk(f.current)};if(!Tne(e,t,L,B,I))return;const M=p.current&&Date.now()-p.current.at<1500?p.current.id:null,F=M??g.current,C=F?x.current.get(F)??N.current.get(F):void 0;for(const $ of Array.from(N.current.keys()))x.current.has($)||N.current.delete($);b.current.clear(),S.current="",E($=>$+1),window.setTimeout(()=>{if(fc(N.current,x.current),j.current){if(M){v.current(M);return}const $=F?x.current.get(F)??N.current.get(F):void 0;if(C&&$&&($.x!==C.x||$.y!==C.y)){const P=d.getViewport();A.current+=1,R({x:P.x-($.x-C.x)*P.zoom,y:P.y-($.y-C.y)*P.zoom,zoom:P.zoom},0),q.current=Date.now()}return}O(500)},80)},[s,o,n,r,O,d,R])}function yre(e,t,n,r,s){const o=[];for(const l of e)!mh(l,t)||n.has(l.id)||o.push(l.id+(l.parentId?`>${l.parentId}`:""));return o.sort(),`${o.join("|")}#sv${r}.${s}`}const mk="agent-dag.removedNodes";function wre(e){try{const t=JSON.parse((e==null?void 0:e.getItem(mk))??"[]");return new Set(Array.isArray(t)?t.filter(n=>typeof n=="string"):[])}catch{return new Set}}function lM(e,t){try{e==null||e.setItem(mk,JSON.stringify([...t]))}catch{}}function vP(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 vre(e,t){if(t.size===0)return new Set;const n=[...e],r=vP(n,t);return new Set(n.filter(r).map(s=>s.id))}function xre(e,t,n){const r=c=>({id:c.id,parentId:c.data.parentId,sessionId:c.data.sessionId}),s=vP(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 bre(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 kre(e,t){return t.size===0?[]:[...e].filter(n=>t.has(n.id)).map(n=>n.id)}function Nre(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 jre(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 Sre(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=Nre(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 xP="sessionGroup";function _re(e,t){var r,s;if(e.type===xP)return"transparent";if(jn((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 Qu=Va;function Ere(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+Qu*2,l=s.maxY-s.minY+Qu*2;n.push({id:`group:${r}`,type:xP,position:{x:s.minX-Qu,y:s.minY-Qu},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 Tre(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 Cre(e,t){const n=new Set;for(const r of t){const s=Tre(e,r);if(s)for(const o of s)n.add(o)}return n.size>0?n:null}function Are({stateRef:e,now:t,removedAgentIds:n,sizeVersion:r,domSizeVersion:s}){return y.useMemo(()=>yre(e.current.agents.values(),t,n,r,s),[e.current,e.current.revision,t,r,s,n])}function Rre({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:O,layoutEpoch:A}=s,q=y.useMemo(()=>Cre(e.current,f),[e.current,e.current.revision,f]),I=y.useMemo(()=>{const P=D7(e.current,t);for(const K of j)P.delete(K);return P},[e.current,e.current.revision,t,j]),B=y.useRef(new Map),L=Ez(),{nodes:M,edges:F}=y.useMemo(()=>{const P=Pne(e.current,t,n,r,b.current,o.current,B.current,l,c,d,S.current,E.current,h,R,f,q,I,p,g,O.restored);return xre(P.nodes,P.edges,v)},[e.current,e.current.revision,t,n,r,c,d,h,f,q,I,p,k,L,v,A,g]),C=y.useMemo(()=>Ere(M),[M]),$=y.useMemo(()=>{const P=[...C,...M],K=x.current;return!K||K.size===0?P:P.map(G=>{const U=K.get(G.id);return U?{...G,position:U}:G})},[C,M,N]);return{spotlightSet:q,visibleAgentIds:I,nodes:M,edges:F,allNodes:$}}function Mre(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 $re({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,Mre(s,t,e))return!1;return r}function Ire({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())mh(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})}$re({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 Ore({stateRef:e,pinnedRef:t,positionsRef:n,canvasRef:r,clearSelection:s,primarySelectedId:o}){const[l,c]=y.useState(()=>wre(ql())),[d,h]=y.useState(null),f=y.useMemo(()=>vre(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),lM(ql(),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=bre(S,b);return E!==S&&lM(ql(),E),E})},[]),k=y.useCallback(()=>{j([...l]),h(null)},[j,l]),x=y.useCallback(()=>{c(new Set),h(null),ws(mk)},[]);return{removedNodes:l,lastRemoval:d,removedAgentIds:f,removeNode:p,removeSelectedNode:g,removalNotice:v,bringBack:j,bringBackAll:k,forgetRemovals:x}}function Lre({stateRef:e,waitingSessions:t,removedAgentIds:n,removedNodes:r,bringBack:s}){const o=y.useRef(new Map);y.useEffect(()=>{o.current=jre(o.current,r,Date.now());const l=[...kre(t,n),...Sre(e.current.agents,n,r,o.current)];l.length>0&&s(l)},[t,n,r,s])}function Pre({waiting:e,running:t,connected:n=!0}){return{title:e>0?`(${e}) ${Nt}`:Nt,icon:n?e>0?"waiting":t>0?"running":"idle":"offline"}}const bP=Object.freeze({offline:"/state/favicon-error.svg",waiting:"/state/favicon-waiting.svg",running:"/state/favicon-syncing.svg",idle:"/favicon.svg"}),kP=Object.freeze({offline:"/state/favicon-error-32.png",waiting:"/state/favicon-waiting-32.png",running:"/state/favicon-syncing-32.png",idle:"/favicon.ico"}),Dre=Object.freeze([...new Set([...Object.values(bP),...Object.values(kP)])]),Ib=new Map;function cM(e){return Ib.get(e)??e}async function Fre(e,t=n=>fetch(n)){await Promise.all(e.map(async n=>{if(!Ib.has(n))try{const r=await t(n),s=(r.headers.get("Content-Type")??"").split(";")[0].trim();if(!r.ok||!s.startsWith("image/"))return;Ib.set(n,`data:${s};base64,${Bre(new Uint8Array(await r.arrayBuffer()))}`)}catch{}}))}function Bre(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function qre({stateRef:e,waitingSessions:t,live:n}){const r=y.useMemo(()=>$U(e.current.agents.values()),[e.current,e.current.revision]),s=y.useRef(null);y.useEffect(()=>{n&&Fre(Dre)},[n]),y.useEffect(()=>{const o=Pre({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&&NP(o.icon)},[t.length,r,n])}function NP(e){const t=document.querySelector('link[rel="icon"][type="image/svg+xml"]');t&&(t.href=cM(bP[e]));const n=document.querySelector('link[rel="icon"][sizes="32x32"]');n&&(n.href=cM(kP[e]))}const Ure=1200,zre=1e3;function xx(e){return e.lastDeckFitAt>0&&e.at-e.lastDeckFitAt<Ure?!1:e.hasSourceEvent?!0:e.lastCanvasInputAt>0&&e.at-e.lastCanvasInputAt<zre}function Wre({applyViewport:e,lastFitTimeRef:t,cameraEpochRef:n,disableAutoFit:r,markInteract:s,canvasRef:o,applyZoom:l}){const c=y.useState(()=>hre())[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=>{pa(),xx(p(j))&&(n.current+=1),xx(p(j))&&r()},onMove:(j,k)=>{var x;s(),xx(p(j))&&r(),(x=o.current)==null||x.style.setProperty("--zoom",String(k.zoom)),l(k.zoom)==="detail"&&pa(),d.current&&window.clearTimeout(d.current),d.current=window.setTimeout(()=>fre(k),250)}}}function Hre({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(()=>RI({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),c0()?h.hold(N):s?window.setTimeout(()=>{try{o(N)}catch{}},80):o(N))},onPaneClick:()=>{h.cancel(),pa(),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"||fP(x.id,k.currentTarget)},onNodeMouseLeave:(k,x)=>pa(x.id)}}function Vre(){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 Gre(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=Ue(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 Kre(){const[e,t]=y.useState(!1);return y.useEffect(()=>{const n=window.setTimeout(()=>t(!0),2500);return()=>window.clearTimeout(n)},[]),e}function Yre(){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 gk(){var t;return typeof navigator>"u"?"":((t=navigator.userAgentData)==null?void 0:t.platform)||navigator.platform||""}function yk(e){return/mac|iphone|ipad/i.test(e)}const pd=[{id:"general",label:"General"},{id:"notifications",label:"Notifications"},{id:"sounds",label:"Sounds"},{id:"music",label:"Music & character"}];function Xre(e){return Math.max(0,pd.findIndex(t=>t.id===e))}const uM="settings-tab-";function Zre(e,t){return e!=null&&e.startsWith(uM)?e===`${uM}${t}`?null:t:null}const Jre={open:!1,section:"general"};function Qre(e,t){return{open:!0,section:t??e.section}}function ese(e){return e.key===","&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey}function tse(e){return yk(e)?"⌘,":"Ctrl+,"}function nse({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:O,setUsageHistoryOpen:A,setUsagePanelOpen:q,setMachinePanelOpen:I,setBrowserWatchOpen:B,setKeyHelpOpen:L,setTheme:M,openSettings:F}){y.useEffect(()=>{const C=$=>{var D,H;const P=$.target,K={tagName:P==null?void 0:P.tagName,isContentEditable:P==null?void 0:P.isContentEditable,role:(D=P==null?void 0:P.getAttribute)==null?void 0:D.call(P,"role"),type:P==null?void 0:P.type,pointerFocused:P!=null&&P===e.current};if($.key==="Escape"){const J=XU({overlayOpen:Fr.depth()>0,typing:ki(K)});J==="dismiss"?Fr.dismissTop():J==="blur"?P==null||P.blur():(zne(K)&&(P==null||P.blur()),p());return}if($.key===","&&ese($)){if(ki(K)||Kx({appModal:c.current,dialogDepth:Fr.dialogDepth()}))return;$.preventDefault(),$.repeat||F();return}if(ch($))return;const G=dk(P)?(H=P==null?void 0:P.getAttribute)==null?void 0:H.call(P,"data-id"):null,U=G&&t.current.some(J=>J.id===G)?G:null,W=qne($,U);if(W.kind==="activate"){$.preventDefault(),g(W.nodeId,W.additive);return}if(W.kind!=="node"){if(iz({key:$.key,sheetOpen:l.current,target:K})){$.repeat||L(!1);return}if(!(W.nodeId==null&&az(K,$.key))&&!oz({key:$.key,modalOpen:Kx({appModal:c.current,dialogDepth:Fr.dialogDepth()}),sheetOpen:l.current})&&!($.repeat&&!/^[ jkJK]$/.test($.key))){if($.key===" "&&($.preventDefault(),$.repeat||S()),($.key==="c"||$.key==="C")&&x("shortcut"),($.key==="r"||$.key==="R")&&N(),($.key==="f"||$.key==="F")&&b(),($.key==="z"||$.key==="Z")&&r.current&&v(r.current),$.key==="Delete"&&h.current(),($.key==="l"||$.key==="L")&&E(),$.key==="d"||$.key==="D")if(r.current)O(J=>!J);else{const J=Gx(n.current.agents.values());J.length>0?k(J[0].id):j(1)}if(($.key==="h"||$.key==="H")&&A(J=>!J),($.key==="u"||$.key==="U")&&q(J=>!J),($.key==="a"||$.key==="A")&&s.current.claude&&R(),($.key==="j"||$.key==="J")&&j(1),($.key==="k"||$.key==="K")&&j(-1),$.key==="w"||$.key==="W"){const J=MU(Gx(n.current.agents.values()),d.current);J&&(d.current=J.id,k(J.id))}($.key==="t"||$.key==="T")&&M(J=>J==="dark"?"light":"dark"),($.key==="m"||$.key==="M")&&o.current!==null&&f.current($.shiftKey),($.key==="s"||$.key==="S")&&I(J=>!J),($.key==="b"||$.key==="B")&&B(J=>!J),($.key==="v"||$.key==="V")&&F("sounds"),$.key==="?"&&L(J=>!J)}}};return window.addEventListener("keydown",C),()=>window.removeEventListener("keydown",C)},[x,N,b,p,g,j,k,v,S])}function rse(){var e,t;return((t=(e=document.activeElement)==null?void 0:e.matches)==null?void 0:t.call(e,":focus-visible"))===!0}function sse({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=>()=>{rse()&&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&&dP(o),En(((h=document.activeElement)==null?void 0:h.tagName)??null)&&((f=l.current)==null||f.focus({preventScroll:!0}))}))}}function ase({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 O,A;if(pa(),h(),s.current=!0,o.current=new Map,l(!0),g(R.type==="agent"?((O=t.current.agents.get(R.id))==null?void 0:O.label)??"":null),f(),p(),R.type==="sessionGroup"){const q=(A=R.data)==null?void 0:A.sessionId,I=new Map;if(q)for(const B of e){const L=B.data;(L==null?void 0:L.sessionId)===q&&I.set(B.id,{x:B.position.x,y:B.position.y})}x.current={start:{x:R.position.x,y:R.position.y},members:I};return}n.current.set(R.id,{x:R.position.x,y:R.position.y})},onNodeDrag:(E,R)=>{var O;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,I=R.position.y-A.start.y;for(const[L,M]of A.members){const F={x:M.x+q,y:M.y+I};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+I});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}),(O=o.current)==null||O.set(R.id,{x:R.position.x,y:R.position.y}),c(A=>A+1)},onNodeDragStop:(E,R)=>{f();const O=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,I=R.position.y-A.start.y;for(const[B,L]of A.members){const M={x:L.x+q,y:L.y+I};n.current.set(B,M),r.current.set(B,M)}}x.current=null,fc(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}),O){k(R.id);return}fc(r.current,n.current)}}}function ose(e){return e.claude&&e.codex?"Claude Code and Codex":e.claude?"Claude Code":e.codex?"Codex":null}const ise={claude:"Claude Code",codex:"Codex",opencode:"OpenCode",openclaw:"OpenClaw",copilot:"GitHub Copilot",pi:"pi-agent",zcode:"ZCode"};function lse(e){const t=e.toLowerCase(),n=Pt(ise,t);return n!==void 0?n:t?t[0].toUpperCase()+t.slice(1):""}function cse(e){return e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function Sue(e,t=[]){const n=t.length?cse(t.map(lse)):ose(e);return n?`via ccusage · local ${n} logs`:"via ccusage · local agent logs"}function use(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 dse(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 hse(){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 ",Nt," tabs are open"]}),a.jsxs("p",{children:["This browser keeps at most six live connections to one address, and other ",a.jsx("code",{children:Nt})," tabs are holding them. Close one and this tab connects on its own."]})]})}function fse({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:Nt}),". Check that it is still running in your terminal — the page picks up again on its own."]})]}):pse(n,r),!o&&a.jsx("button",{type:"button",className:"btn empty-tour",onClick:s,children:"Take the tour"}),!o&&a.jsx(sc,{film:"tour"})]})}function pse(e,t){const n=dse(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."]}),use(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 mse=1;function gse(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 yse(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:mse,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(gse)}))}}function wse(e,t){const n=(e||"session").replace(/[^a-z0-9._-]/gi,"_");return`${Nt}-${n}-${N0(t,8)}.json`}const jP={file:"📁",shell:"⚡",web:"🌐",agent:"🤖",task:"📋",plan:"🧭",mcp:"🔌",other:"✨"},vse={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 xse({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:vse[e]})})}const Vd={file:"file",shell:"shell",web:"web",agent:"agent",task:"task",plan:"plan",mcp:"mcp",other:"other"},SP=hI;function bse({agent:e,now:t,onOpenTool:n,onShowSummary:r,onExportSession:s,onRemove:o}){var k;const l=`${e.synthetic?"≥ ":""}${bi(e.startedAt,e.endedAt,t)}`,c=pn(e),d=c.total>0,h=e.usage.inputTokens+e.usage.outputTokens,f=new Map;for(const[x,N]of e.toolCountByName??[]){const b=SP(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")?cW(((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=m0(e);return a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"hero-sep",children:"·"}),a.jsxs("span",{className:"model-chip","data-family":ih(e.model),title:x.length>0?`${e.model}
97
- spend on this panel also covers:
98
- ${x.join(`
99
- `)}`:e.model,children:[Ns(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:qe(c.total)}),a.jsx("span",{className:"hero-cost-label",children:"spend"})]}),a.jsx(S0,{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=uh(e);if(!x)return null;const N=Md(x.at,t),b=x.kind==="recap"?"Recap":da(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:dh(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} ${Vd[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:jP[x]}),a.jsx("span",{className:"cat-name",children:Vd[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:rt(e.usage.inputTokens)})]}),a.jsxs("div",{children:[a.jsx("span",{className:"k",children:"out"}),a.jsx("b",{title:e.usage.outputTokens.toLocaleString(),children:rt(e.usage.outputTokens)})]}),a.jsxs("div",{children:[a.jsx("span",{className:"k",children:"cache r"}),a.jsx("b",{title:e.usage.cacheReadTokens.toLocaleString(),children:rt(e.usage.cacheReadTokens)})]}),a.jsxs("div",{children:[a.jsx("span",{className:"k",children:"cache c"}),a.jsx("b",{title:e.usage.cacheCreateTokens.toLocaleString(),children:rt(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:D$(e.prompts).length})]}),a.jsx("div",{className:"prompts",children:kse(e.prompts).reverse().map(({pr:x,key:N})=>{const b=Md(x.at,t),S=sh(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(jse,{t:x,onClick:()=>n(e.id,x.id)},x.id))})]})]})}function kse(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 Nse={inflight:"in-flight",done:"done",err:"error"};function jse({t:e,onClick:t}){const n=e.endedAt==null?"inflight":e.ok===!1?"err":"done",r=tI(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:Nse[n]}),e.name]}),a.jsx("span",{style:{color:"var(--muted)"},children:r})]})}function Sse(e,t){const n=yse(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=wse(n.label,t),document.body.appendChild(l),l.click(),document.body.removeChild(l),setTimeout(()=>URL.revokeObjectURL(o),1e3)}function _se({selected:e,now:t,openTool:n,setSummaryFor:r,onClose:s,stateRef:o,removeSelectedNode:l}){return Ut("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(bse,{agent:e,now:t,onOpenTool:n,onShowSummary:r,onExportSession:c=>Sse(o.current,c),onRemove:l})]})}const ed="tb-more",Ob="tb-more-menu";function Ese(){const e=Array.from(document.querySelectorAll(`#${Ob} [role="menuitem"]`));return document.querySelectorAll(".topbar .tb-fold")[Math.max(0,e.indexOf(document.activeElement))]??null}function Tse({watchUnseen:e,setUsageHistoryOpen:t,setBrowserWatchOpen:n,onFeedback:r}){const[s,o]=y.useState(null),l=s!==null,c=d=>()=>{var h;(h=document.getElementById(ed))==null||h.focus(),o(null),d()};return a.jsxs(a.Fragment,{children:[a.jsxs("button",{id:ed,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?Ob: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(bh,{anchorId:ed,id:Ob,className:"ap-pop",role:"menu",labelledBy:ed,start:s,fallbackFocus:Ese,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 Cse({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 Ase({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 Rse({openSettings:e,onFeedback:t,watchUnseen:n,setUsageHistoryOpen:r,setBrowserWatchOpen:s}){const o=`Settings (${tse(gk())})`;return a.jsxs("div",{className:"action-run action-run-utility",children:[a.jsxs("button",{className:"btn icon-btn",onClick:()=>e(),title:o,"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:t,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(Tse,{watchUnseen:n,setUsageHistoryOpen:r,setBrowserWatchOpen:s,onFeedback:t})]})}const Mse=5*6e4,$se=6e4;function Ise({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>=Mse}function dM(e=new Date){return II("month",e)}function Ose(e){const t=yh(e);return{cost:t.cost,tokens:t.tokens}}function hM(e){return e>0?qe(e):"$0.00"}const Lse=new Set(["idle","checking","current","downloading","ready","error"]);function fM(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.status!="string"||!Lse.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 Pse(e){return(e==null?void 0:e.status)==="ready"&&e.version?{version:e.version}:null}function Dse(e=typeof navigator>"u"?"":navigator.userAgent){var t;return((t=/\bccdeck-desktop\/(\d[^\s]*)/.exec(e))==null?void 0:t[1])??null}const Gd="Restart to update",_P=3e4;function Fse(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 Bse(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 ${Gd} comes first`}}function qse(e){const t=e==null?void 0:e.reason;return t==="app_disconnected"||t==="update_not_ready"?t:"refused"}function Use(e,t,n=typeof navigator>"u"?"":navigator.userAgent){const r=Fse(n),s=`Use ${Gd} 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, ${Gd} is in ${r}.`;case"timeout":return`ccdeck has not restarted after ${_P/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 zse="Update checks are off (AGENTS_DECK_NO_UPDATE_CHECK=1)",bx="click for what's new";function Wse(e){if(e.checkDisabled)return`${zse} · ${bx}`;if(e.checking)return`Asking npm for the newest release… · ${bx}`;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 · ${bx}, and to check npm now`}function Hse(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 Vse(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 EP(e){return e?`${e.kind}:${e.to}`:""}function Gse(e,t){return e!=null&&t!==EP(e)}function Kse({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=Bse(Dse()??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":Vse({...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?Rd(l-r.checkedAt):null,checkFailedAgo:r!=null&&r.checkFailedAt&&r.checkFailedAt>(r.checkedAt??0)?Rd(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":Hse(f),title:Wse(f),children:["v",f.running]})})()})}function Yse({live:e,paused:t,pauseGate:n,monthUsageRef:r,monthlyUsage:s,monthlyUsageUnavailable:o}){return a.jsxs("span",{className:"status",children:[(()=>{const l=_W({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 · ${hM(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:rt(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:hM(s.cost)})]}):a.jsx("span",{className:"month-usage-pending",children:o?"unavailable":"…"})]})]})}function Xse({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:
100
- ${e.map(s=>` ${s.label}: ${xi(s.waiting)} (${Rd(r-s.waiting.since)})`).join(`
101
- `)}`,"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 Lb={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 Zse(e){return e==="on"?`Notifications on. ${Lb.on}.`:e==="blocked"?`${Lb.blocked}.`:""}function Jse({notifySaid:e}){return a.jsx("span",{className:e==="on"?"notify-said":"notify-said notify-said-blocked","aria-hidden":!0,title:Lb[e],children:e==="on"?"notifications on":"notifications blocked"})}function Qse({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:O,pauseGate:A}=r,{monthlyUsage:q,monthlyUsageUnavailable:I,monthUsageRef:B}=s,{blockedSaid:L,watchSaid:M,incidentSaid:F}=o,{notifySaid:C}=l;return a.jsxs("div",{className:"readout",children:[a.jsxs("div",{className:"brand",children:[a.jsx("img",{className:"logo logo-on-dark",src:a9,width:19,height:16,alt:""}),a.jsx("img",{className:"logo logo-on-light",src:o9,width:19,height:16,alt:""}),a.jsx("h1",{children:Nt}),a.jsx(Kse,{readyAppUpdate:R,notice:j,noticeOpen:k,version:v,chipVersion:S,versionChecking:N,now:p,openReleaseNotes:E,showNotice:x,loadVersion:b})]}),a.jsx(Yse,{live:f,paused:O,pauseGate:A,monthUsageRef:B,monthlyUsage:q,monthlyUsageUnavailable:I}),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:Zse(C)}),a.jsx(i9,{incidents:g}),c.length>0&&a.jsx(Xse,{waitingSessions:c,waitingCursorRef:d,focusSession:h,now:p}),C&&a.jsx(Jse,{notifySaid:C})]})}function eae({selected:e,now:t,selectedIds:n,focusAgent:r,clearSelection:s}){const o=pn(e),l=Math.max(0,((e.endedAt??t)-e.startedAt)/1e3),c=e.state==="active"&&!e.synthetic?p0(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?`
102
- ${qe(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:[qe(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 tae({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"} ${Vd[o]} tools`,children:[a.jsx(xse,{cat:o}),a.jsx("span",{className:"cat-name",children:Vd[o]})]},o)})})}const nae=["a[href]","button:not(:disabled)","input:not(:disabled)","select:not(:disabled)","textarea:not(:disabled)","summary","[tabindex]"].join(",");function rae(e){var n,r;const t=e.target;!(t!=null&&t.closest)||t.closest(nae)!==e.currentTarget||(e.preventDefault(),(r=(n=document.activeElement)==null?void 0:n.blur)==null||r.call(n))}function sae({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 aae({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:rae,onPointerDownCapture:x,onPointerUpCapture:x,onWheelCapture:x,onFocusCapture:R=>{const O=R.target;if(!dk(O)||k.current==null||k.current==="detail")return;const A=O.getAttribute("data-id");A&&l.current.agents.has(A)&&O.matches(":focus-visible")&&fP(A,O,"focus")},onBlurCapture:R=>{var A,q;const O=(q=(A=R.target).getAttribute)==null?void 0:q.call(A,"data-id");O&&pa(O)},children:[d,Ba(p)&&a.jsx(sae,{trashZoneRef:g,trashState:f,trashPhase:p,trashLabel:v}),a.jsx(Vne,{agentFor:N,recapFor:S,labelFor:b,bounds:E})]})}function oae({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 ${Nt}…`:(()=>{const s=jW({connected:n,paused:r});return a.jsxs(a.Fragment,{children:[`Lost connection to the ${Nt} server. Reconnecting…`,s&&a.jsx("span",{className:"conn-sub",children:s})]})})()]})}function iae({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 ",Nt," 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 TP="Thanks — that helps.",lae=Array.from({length:11},(e,t)=>t);function cae(e){return e===0?"0 out of 10, not useful":e===10?"10 out of 10, extremely useful":`${e} out of 10`}const uae=6;function dae(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 hae(){var e;(e=document.getElementById("canvas"))==null||e.focus()}function fae({phase:e,score:t,onAnswer:n,onLater:r,onClose:s,onFeedback:o,onHold:l}){const c=dae(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,En(((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)&&hae(),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:TP}),t!==null&&t<=uae?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:lae.map(g=>a.jsx("button",{type:"button",className:"rating-pick","aria-label":cae(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 pae=3e4;function mae({bundle:e,running:t,lastTried:n}){return!t||e===t?!1:n!==t}function gae({bundle:e,running:t,pending:n,lastTried:r}){return t?mae({bundle:e,running:t,lastTried:r})?"reload":n==null||n&&n!==t?"wait":"confirm":"wait"}function yae(e){return!e||e.state!=="failed"?null:`${typeof e.at=="number"?e.at:0}:${e.error??""}`}function wae({asked:e,reported:t}){return t?t!==e:!1}function CP(e){const t=e.thresholdMs??pae;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 vae(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 xae(e,t){return e?t==null?"auto when idle":`auto in ${vae(t)}`:"auto-restart off"}function pM(e){let t=0;for(const n of e)n.state==="active"&&t++;return t}function bae(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 kae(e){const t=CP(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 mM={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 Nae({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(),...vs(g),title:`Stop this process and bring it back on the same port. The canvas replays from the event log.
103
-
104
- 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:xae(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:[Nt," 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,...vs(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}),...vs(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:":mM.npx}):t!=null&&t.upgradeBlocked?a.jsx("span",{className:"ver-sub",children:Pt(mM,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 jae({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:O,copyCommand:A,cmdCopied:q}=n,{oldName:I,oldNameOpen:B,dismissOldName:L}=r,{ratingPhase:M,ratingScore:F,answerRating:C,rateLater:$,closeRating:P,holdThanks:K}=s,G=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(oae,{restarting:p,restartMode:g,live:c,paused:d}):S&&b?a.jsx(Nae,{notice:b,version:N,dismissNotice:E,upgradeState:R,startUpgrade:O,copyCommand:A,cmdCopied:q,autoRestart:h,toggleAutoRestart:f,askRestart:j,restartCopy:k,restartFuseMs:x,restarting:p}):B&&I?a.jsx(iae,{oldName:I,version:N,dismissOldName:L}):M!=="hidden"?a.jsx(fae,{phase:M,score:F,onAnswer:C,onLater:$,onClose:P,onFeedback:o,onHold:K}):null;return a.jsxs(a.Fragment,{children:[G,a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:M==="thanks"?TP:""})]})}function Sae(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 Eae(e){return e<=0?null:e===1?"the one agent":`all ${e} agents`}function Tae(e,t){const n=Eae(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 Cae({agentCount:e,onConfirm:t,onCancel:n}){const r=y.useRef(null),s=dt(n,{focusRef:r,layer:KU}),o=gt(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}=Tae(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 Kd=[{value:"bug",label:"Bug",question:"What happened?",placeholder:`I was trying to…
105
- 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 AP(e){return Kd.find(t=>t.value===e)??Kd[0]}const Pb=3,kx=120,RP=1e4,MP=200,Aae="Write something first.";function gM(e){return e.trim()!==""}function Rae(e){var o;const t=e.trim();if(t==="")return"";const n=yM(t.split(/\r?\n/,1)[0]),r=((o=/^(.+?[.!?])(?=\s|$)/.exec(n))==null?void 0:o[1])??n,s=Nx(r).length>=Pb?Nx(r):Nx(n);return $ae(s.length>=Pb?s:yM(t))}function Mae(e,t){const n=Rae(t);return n.length>=Pb?n:`${AP(e).label}: ${n}`}function yM(e){return e.replace(/\s+/g," ").trim()}function Nx(e){return/[^.]\.$/.test(e)?e.slice(0,-1):e}function $ae(e){if(e.length<=kx)return e;const t=e.slice(0,kx-1),n=t.lastIndexOf(" ");return`${(n>=kx/2?t.slice(0,n):t).replace(/[\uD800-\uDBFF]$/,"").replace(/[\s,;:.\-–—]+$/,"")}…`}function Iae({kind:e,body:t,contact:n}){const r={kind:e,title:Mae(e,t),body:t.trim()};return n.trim()!==""&&(r.contact=n.trim()),r}function Oae(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 Lae={darwin:"macOS",win32:"Windows",linux:"Linux"};function Pae(e){const t=e.indexOf("-"),n=t===-1?e:e.slice(0,t),r=t===-1?"":e.slice(t+1),s=Lae[n]??n;return r?`${s} · ${r}`:s}function Dae(e){return e?`ccdeck ${e.appVersion} · ${Pae(e.platform)}`:null}const Fae="sent with it",Bae="Your ccdeck version and system are sent with it.",qae="Add details",Uae="How to reach you",zae="Email or GitHub @name",Wae="Only if you would like an answer.",Hae=["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 Vae(e){return e.key==="Enter"&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey&&!e.isComposing}function $P(e){return e.key==="Enter"&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey&&!e.isComposing}function Gae(e){return yk(e)?["⌘","Enter"]:["Ctrl","Enter"]}function Kae(e){return[...e].length===1}const IP="Thanks — feedback sent.";function wM(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 Yae(e){return e==="sending"?"Sending…":e==="sent"?IP:""}const vM=1400,Xae=160;function Zae({kind:e,onChange:t}){return a.jsxs("fieldset",{className:"fb-kinds",children:[a.jsx("legend",{className:"vis-hidden",children:"Kind of feedback"}),Kd.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=>{$P(r.nativeEvent)&&r.preventDefault()}}),n.label]},n.value))]})}const OP="fb-details";function Jae({open:e,onToggle:t}){return a.jsxs("button",{type:"button",className:"fb-tool fb-more","aria-expanded":e,"aria-controls":OP,onClick:t,children:[qae,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 Qae({open:e,contact:t,onContact:n}){const r=y.useId();return a.jsx("div",{id:OP,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:[Uae,a.jsx("span",{className:"fb-optional",children:"optional"})]}),a.jsx("input",{id:"fb-contact",className:"ap-manage-input",type:"text",value:t,maxLength:MP,autoComplete:"email",placeholder:zae,"aria-describedby":r,onChange:s=>n(s.target.value),onKeyDown:s=>{$P(s.nativeEvent)&&s.preventDefault()}}),a.jsx("p",{id:r,className:"fb-hint",children:Wae})]}),a.jsx("div",{className:"fb-where",children:Hae.map(s=>a.jsx("p",{children:s},s))})]})})})}const Ga=3,eoe=5*1024*1024,toe=12*1024*1024,Db=8192,noe=64*1024,roe=256*1024,soe=.92,aoe=640,LP=.9,ooe=.85,ioe=6,loe=512*1024,Yd={png:"image/png",jpeg:"image/jpeg"},coe={png:"png",jpeg:"jpg"},uoe=[137,80,78,71,13,10,26,10],doe=[255,216,255];function PP(e){const t=n=>e.length>=n.length&&n.every((r,s)=>e[s]===r);return t(uoe)?"png":t(doe)?"jpeg":null}function hoe(e){const t=PP(e);return t==="png"?foe(e):t==="jpeg"?moe(e):null}function foe(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 poe(e){return e>=192&&e<=207&&e!==196&&e!==200&&e!==204}function moe(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(poe(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 xM(e,t){return e.bytes>t||e.width>Db||e.height>Db}function goe(e){return Math.min(eoe,toe-noe-e)}function DP(e,t){return{width:Math.max(1,Math.floor(e.width*t)),height:Math.max(1,Math.floor(e.height*t))}}function yoe(e,t){const n=Db/Math.max(e.width,e.height),r=e.bytes>t?Math.sqrt(t/e.bytes)*LP:1;return DP(e,Math.min(1,n,r))}async function woe(e,t,n){let r=yoe(e,t),s=e.format;for(let o=0;o<ioe;o++){const l=await n(r,s,s==="jpeg"?soe:void 0);if(!l)return null;if(l.size<=t)return{...r,blob:l,format:s};if(s==="png"){s="jpeg";continue}if(r=DP(r,Math.min(ooe,Math.sqrt(t/l.size)*LP)),Math.max(r.width,r.height)<aoe)return null}return null}async function voe(e,t,n){const r=new Uint8Array(await e.slice(0,loe).arrayBuffer()),s=PP(r);if(!s)return{ok:!1,problem:"type"};if(t<roe)return{ok:!1,problem:"no_room"};const o=e.type===Yd[s]?e:new Blob([e],{type:Yd[s]}),l=hoe(r);if(l&&!xM({...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(!xM(d,t))return{ok:!0,blob:o,resized:null};const h=await woe(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 xoe(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)},Yd[r],s)})}const boe=async e=>{const t=await createImageBitmap(e);return{width:t.width,height:t.height,encoder:xoe(t),release:()=>t.close()}};function koe(e){return e.includes("Files")}function Noe({files:e,hasText:t,intoTextField:n}){return e>0&&(!t||!n)}function joe(e,t){const n=e.indexOf(t);return e[n+1]??e[n-1]??null}function Soe(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===Yd.jpeg?"jpeg":"png";n.append("images",r,`image-${s+1}.${coe[o]}`)}),{method:"POST",body:n}}const _oe="Add screenshot",bM="PNG or JPEG, up to three. You can also paste one, or drop it on this dialog.",Eoe="A screenshot can show emails, costs and paths. Crop out what should not be seen.",kM="Three images at most. Remove one to add another.",Toe="An image could not be attached, so nothing was sent. Check the images and send again; your text is still here.";function Coe(e,t,n){const r=n?`, resized to ${n.width} × ${n.height} to fit`:"";return`Replace image ${e+1}: ${t}${r}`}function Aoe(e,t){const n=`${e} of ${Ga}`;return t>0?`${n} · ${t} resized to fit`:n}function Roe(e){return`Three images at most, so ${e===1?"one was":`${e} were`} left out.`}function Moe(e){return`“${e.length>40?`${e.slice(0,30)}…${e.slice(-9)}`:e}”`}function $oe(e,t){const n=Moe(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 FP="image/png,image/jpeg";function BP({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 Ioe({images:e,buttonRef:t}){const n=y.useRef(null),r=e.shots.length>=Ga;return a.jsxs(a.Fragment,{children:[a.jsxs("button",{ref:t,type:"button",className:"fb-tool",title:bM,"aria-describedby":"fb-attach-hint",onClick:()=>{var s;return r?e.sayFull():(s=n.current)==null?void 0:s.click()},children:[a.jsx(BP,{}),_oe]}),a.jsx("span",{id:"fb-attach-hint",hidden:!0,children:bM}),a.jsx("input",{ref:n,type:"file",accept:FP,multiple:!0,hidden:!0,onChange:s=>{e.add(Array.from(s.target.files??[])),s.target.value=""}})]})}function Ooe({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=Aoe(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(joe(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:FP,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":Coe(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:Eoe})]}),e.problem&&a.jsx("p",{ref:r,className:"fb-error",role:"alert",children:e.problem},e.problemId)]})}function Loe(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 Poe(e,t,n){return n?e.map(r=>r.id===t.id?t:r):[...e,t]}function Doe(e,t,n){return n?e.map(r=>r.id===t?n:r):e.filter(r=>r.id!==t)}function Foe(e){const[t,n]=y.useState(()=>Loe((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 C=h.current.reduce((J,V)=>{var Z;return J+(V.id===(F==null?void 0:F.id)?0:((Z=V.blob)==null?void 0:Z.size)??0)},0),$=(F==null?void 0:F.id)??++p.current,P=URL.createObjectURL(M),K={id:$,name:M.name||"image",url:P,blob:null,resized:null},G=k.current;v.current.set($,M);let U=!1;const W=()=>{U||(U=!0,x(J=>Poe(J,K,F!==void 0)))},D=await voe(M,goe(C),async J=>(W(),boe(J))).catch(()=>({ok:!1,problem:"unreadable"})),H=h.current.some(J=>J.id===$);return!g.current||k.current!==G||!H&&(U||F)?(URL.revokeObjectURL(P),F&&URL.revokeObjectURL(F.url),g.current&&v.current.delete($),""):(v.current.delete($),D.ok?(W(),F&&URL.revokeObjectURL(F.url),x(J=>J.map(V=>V.id===$?{...V,blob:D.blob,resized:D.resized}:V)),""):(URL.revokeObjectURL(P),U&&x(J=>Doe(J,$,F)),$oe(D.problem,M.name||"image")))},[x]),b=y.useCallback(async M=>{l("");const F=k.current,C=[];let $=0,P=0;for(const G of M){if(!g.current||k.current!==F)return;const U=j.current.indexOf(G);if(U!==-1&&j.current.splice(U,1),h.current.length>=Ga){$++;continue}const W=h.current.length,D=await N(G);D&&C.push(D),h.current.length>W&&P++}if(!g.current||k.current!==F)return;$>0&&C.push(P===0&&C.length===0?kM:Roe($)),l(C.join(" "));const K=h.current.length;P>0&&d(`${P===1?"Image":`${P} images`} added, ${K} of ${Ga}.`)},[N,l]),S=y.useCallback(async(M,F)=>{l("");const C=h.current.find(K=>K.id===M);if(!C)return b([F]);const $=await N(F,C);if(!g.current)return;l($);const P=h.current.findIndex(K=>K.id===M);!$&&P!==-1&&d(`Image ${P+1} replaced, ${h.current.length} of ${Ga}.`)},[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 O=y.useCallback((M,F)=>{const C=F[0];C&&E(()=>S(M,C))},[E,S]),A=y.useCallback(M=>{const F=h.current.find(C=>C.id===M);F&&(URL.revokeObjectURL(F.url),v.current.delete(M),x(C=>C.filter($=>$.id!==M)),l(""),d(`Image removed, ${h.current.length} of ${Ga}.`))},[x,l]),q=y.useCallback(()=>l(kM),[l]),I=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:O,remove:A,sayFull:q,ready:I,kept:B,clear:L}}function Boe(){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(Oae(r))}).catch(()=>{}),()=>{n=!1}},[]),e}function qoe(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(!pr(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:Toe});return}const f=await fetch("/api/feedback",{...Soe(Iae(c),h),signal:d}),p=await f.json().catch(()=>null);n(f.ok&&(p!=null&&p.ok)?{state:"sent"}:{state:"failed",message:wM(f.status,p==null?void 0:p.reason,p==null?void 0:p.errors)})}catch{d.aborted||n({state:"failed",message:wM(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 Uoe(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),vM),l=window.setTimeout(()=>s.current(),vM+Xae);return()=>{window.clearTimeout(o),window.clearTimeout(l)}},[e]),n}const jx="agent-dag.feedbackDrafts",NM=4;function zoe({initialKind:e,initialBody:t}){return{kind:e??"bug",body:t??""}}function Woe(e){return JSON.stringify([e.kind,e.body])}function Hoe(e){return e.ready.length+e.waiting.length}function qP(e,t){return e.body.trim()!==t.body.trim()||e.contact.trim()!==""||e.images>0}function Voe(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 Goe="Discard",Koe="Confirm discard",Yoe="Clear the message, the screenshots and the contact",jM="Press again to clear this draft. It cannot be brought back.",Xoe={ready:[],waiting:[]};function Zoe(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!Kd.some(l=>l.value===n)||typeof r!="string"||r.length>RP||typeof s!="string"||s.length>MP||typeof o!="number"||!Number.isInteger(o)||o<0||o>Ga?null:[e[0],{kind:n,body:r,contact:s,images:o}]}function Joe(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(jx),c=l?JSON.parse(l):[];if(Array.isArray(c))for(const d of c.slice(-NM)){const h=Zoe(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(jx):o.setItem(jx,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??Xoe,imagesLost:l.images?0:l.imageCount}:null},keep(o,l,c){const d=Hoe(l.images);if(!qP({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<=NM)break;h.delete(f)}r()},forget:s}}function Qoe(){try{return typeof window>"u"?null:window.sessionStorage}catch{return null}}const Fb=Joe(Qoe),eie=4e3;function tie(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||Fb.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&&Fb.forget(e)},[s,e])}const SM="draft";function nie(e){const[t,n]=y.useState(!1),r=y.useRef(0);y.useEffect(()=>{if(!t)return;const o=window.setTimeout(()=>n(!1),eie);return()=>window.clearTimeout(o)},[t]);function s(){const o=Date.now(),l=ao({armedFor:t?SM:null,target:SM,armedAt:r.current,now:o,gapMs:so});if(l==="arm"){n(!0),r.current=o;return}l!=="ignore"&&(n(!1),e())}return{armed:t,press:s}}function UP({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=dt(e,{focusRef:r}),v=gt(e),j=zoe({initialKind:t,initialBody:n}),k=Woe(j),[x]=y.useState(()=>Fb.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,O]=y.useState((x==null?void 0:x.contact)??""),[A,q]=y.useState((x==null?void 0:x.imagesLost)??0),[I,B]=y.useState(!1),[L,M]=y.useState(!1),[F,C]=y.useState(!1),$=Foe(x==null?void 0:x.images),P=Dae(Boe()),{outcome:K,sending:G,send:U,clearFailure:W}=qoe($),D=K.state==="sent",H=Uoe(D,e);tie(k,j,{kind:N,body:S,contact:R},$,D);const J=qP({body:S,contact:R,images:$.shots.length},j),V=nie(()=>{var we;b(j.kind),E(j.body),O(""),q(0),M(!1),$.clear(),W(),(we=r.current)==null||we.focus()}),Z=AP(N),Y=L&&!gM(S),X=A>0&&$.shots.length===0,ee=[Y&&"fb-body-error",X&&"fb-images-lost"].filter(Boolean).join(" ")||void 0,[ae,ue]=Gae(gk());y.useEffect(()=>{var Pe,Be;const we=l.current;if(!we)return;const Ie=we.contains(document.activeElement)||En(((Pe=document.activeElement)==null?void 0:Pe.tagName)??null);we.inert=D,D&&Ie&&((Be=s.current)==null||Be.focus())},[D]),y.useEffect(()=>{var Oe,Qe;const we=c.current;if(!we)return;const Ie=h.current;if(G){const Ye=document.activeElement,Xe=Ye!=null&&(we.contains(Ye)||Ye===Ie);f.current=Xe?Ye:null,we.inert=!0,Ie&&(Ie.inert=!0),f.current&&((Oe=d.current)==null||Oe.focus());return}we.inert=!1,Ie&&(Ie.inert=!1);const Pe=f.current;f.current=null;const Be=document.activeElement===d.current||En(((Qe=document.activeElement)==null?void 0:Qe.tagName)??null);!D&&Pe&&Be&&Pe.focus()},[G,D]);function ge(we){var Ie;if(we.preventDefault(),!gM(S)){M(!0),(Ie=r.current)==null||Ie.focus();return}U({kind:N,body:S,contact:R})}const ye=!D&&!G,se=we=>koe(Array.from(we.dataTransfer.types));function me(we){!se(we)||!ye||(we.preventDefault(),p.current++,C(!0))}function pe(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&&C(!1))}function fe(we){se(we)&&(we.preventDefault(),p.current=0,C(!1),ye&&$.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 Ie=Array.from(we.clipboardData.files),Pe=we.target,Be=Pe instanceof HTMLTextAreaElement||Pe instanceof HTMLInputElement,Oe=Array.from(we.clipboardData.types).includes("text/plain");Noe({files:Ie.length,hasText:Oe,intoTextField:Be})&&(we.preventDefault(),$.add(Ie))}return a.jsx("div",{className:"modal-backdrop",...v,role:"presentation",onDragOver:ne,onDrop:oe,"data-leaving":H||void 0,children:a.jsxs("div",{ref:g,className:"modal feedback-dialog",onClick:we=>we.stopPropagation(),onDragEnter:me,onDragOver:pe,onDragLeave:de,onDrop:fe,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:V.armed?jM:Yae(K.state)}),a.jsxs("div",{className:"fb-stage",children:[a.jsxs("form",{ref:l,className:"fb-form",onSubmit:ge,onKeyDown:we=>{Vae(we.nativeEvent)&&(we.preventDefault(),we.currentTarget.requestSubmit())},noValidate:!0,children:[a.jsxs("section",{ref:c,className:"modal-body fb-body",children:[a.jsx(Zae,{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:RP,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:Aae}),a.jsx(Ooe,{images:$,addRef:o}),X&&a.jsx("p",{id:"fb-images-lost",className:"fb-hint",children:Voe(A)}),a.jsxs("div",{className:"fb-tools",children:[a.jsx(Ioe,{images:$,buttonRef:o}),a.jsx(Jae,{open:I,onToggle:()=>B(we=>!we)})]}),a.jsx(Qae,{open:I,contact:R,onContact:O})]}),a.jsx("p",{className:"fb-facts",children:P?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"fb-facts-value",children:P})," — ",Fae]}):Bae}),K.state==="failed"&&a.jsx("p",{className:"fb-error",role:"alert",children:K.message})]}),a.jsxs("div",{className:"fb-foot",children:[J&&a.jsx("button",{ref:h,type:"button",className:`btn danger fb-discard${V.armed?" armed":""}`,onKeyDown:we=>{we.repeat&&we.preventDefault()},onClick:V.press,title:V.armed?jM:Yoe,children:V.armed?Koe:Goe}),a.jsxs("span",{className:"fb-shortcut","aria-hidden":"true",children:[a.jsx("kbd",{"data-symbol":Kae(ae)||void 0,children:ae}),a.jsx("kbd",{children:ue})," 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",...vs(G),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(Od,{}),a.jsx("p",{className:"fb-done-line",children:IP})]})]}),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(BP,{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 rie="Press Esc first if a key does nothing.",sie=[{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:"?",action:"this sheet",binds:["?"]}]},{title:"Settings",rows:[{cap:"Ctrl + ,",macCap:"⌘ ,",action:"all settings",binds:[","]},{cap:"V",action:"sound settings — the switch, and each tone's volume and sound",binds:["v","V"]},{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:[]}]}];function aie({onClose:e,onTour:t}){const n=dt(e),r=gt(e),s=yk(gk());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:sie.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:rie})]})]})})}function zP(e,t){return y.lazy(()=>e().catch(n=>(console.warn(`ccdeck could not load ${t}`,n),{default:({onClose:r})=>a.jsx(oie,{name:t,onClose:r})})))}function oie({name:e,onClose:t}){const n=y.useRef(null),r=dt(t,{focusRef:n}),s=gt(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 iie(e,t){return`${e}#${t}`}function lie(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=iie(l.key,l.since);if(r.has(c)||QK(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 cie(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 WP({rows:e,ours:t,dialogs:n}){return e===0?!1:t||n===0}function uie(e){return e===1?"Account needs your attention":"Accounts need your attention"}function die(e){return`${e===1?"One Claude account needs":`${e} Claude accounts need`} you to sign in again.`}const hie="Login expired",fie="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.",pie="The account stays marked in the Accounts panel. This will not ask again until it has worked and stopped again.";function mie(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 gie({request:e,waiting:t,busy:n,now:r,onAccept:s,onDecline:o,onLater:l}){const c=y.useRef(null),d=dt(l,{focusRef:c}),h=gt(l),f=fa(n,"accept"),p=fa(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 ",F0(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 yie(e){const t=y.useRef(!1),n=wie(e),r=WP({rows:n?1:0,ours:t.current,dialogs:Fr.dialogDepth()});return t.current=r,r?n:null}function wie({lanPending:e,lanDeferred:t,lanBusy:n,answerLanPair:r,deferLanPair:s}){const{request:o,waiting:l}=mie(e,t.current);return o?a.jsx(gie,{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 vie({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:fie})]}):a.jsxs(a.Fragment,{children:[a.jsx("p",{id:"reauth-lead",className:"reauth-lead",children:die(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:hie}),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:pie,onClick:n,children:"Not now"}),s&&a.jsx("button",{type:"button",className:"btn primary",ref:r,onClick:()=>t(s),children:"Sign in again"})]})]})}function xie({rows:e,onSignIn:t,onLater:n}){const r=y.useRef(null),s=dt(n,{focusRef:r}),o=gt(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:uie(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(vie,{rows:e,onSignIn:t,onLater:n,firstRef:r})]})})}function bie({rows:e,signingIn:t,signIn:n,signedIn:r,refresh:s,closeSignIn:o,later:l,pairing:c=!1}){const d=y.useRef(!1),h=Fr.dialogDepth()+(c?1:0),f=t!=null||WP({rows:e.length,ours:d.current,dialogs:h});return d.current=f,t?a.jsx(vO,{email:t.email||null,onClose:o,onChanged:s,onSignedIn:r}):f?a.jsx(xie,{rows:e,onSignIn:n,onLater:l},e.length===1?"one":"many"):null}const kie={"//":["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.6"],"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.
106
-
107
- 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.
108
-
109
- 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.
110
-
111
- 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.
112
-
113
- 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.
114
-
115
- 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".
116
-
117
- **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.
118
-
119
- \`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.
120
-
121
- **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.
122
-
123
- 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.
124
-
125
- 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.
126
-
127
- 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.
128
-
129
- 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.
130
-
131
- 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.
132
-
133
- 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.
134
-
135
- What you are reading is the first version that does not.
136
-
137
- 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.
138
-
139
- 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.
140
-
141
- 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.
142
-
143
- 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.
144
-
145
- 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.
146
-
147
- The count of what is behind it is on the heading's tooltip, so collapsing it does not hide how much there is.
148
-
149
- **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.
150
-
151
- 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.
152
-
153
- \`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.
154
-
155
- 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.
156
-
157
- **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.
158
-
159
- **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.
160
-
161
- **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.
162
-
163
- **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.
164
-
165
- **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.
166
-
167
- **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.
168
-
169
- 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.
170
-
171
- 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.
172
-
173
- 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.
174
-
175
- 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.
176
-
177
- 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.
178
-
179
- 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.
180
-
181
- 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.
182
-
183
- 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.
184
-
185
- 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.
186
-
187
- 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.
188
-
189
- 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.
190
-
191
- 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.
192
-
193
- 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.
194
-
195
- 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.
196
-
197
- 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.
198
-
199
- 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.
200
-
201
- 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.
202
-
203
- 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.
204
-
205
- 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.
206
-
207
- 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.
208
-
209
- 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.
210
-
211
- 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.
212
-
213
- 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.
214
-
215
- 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.
216
-
217
- 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.
218
-
219
- 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.
220
-
221
- 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.
222
-
223
- 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.
224
-
225
- 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.
226
-
227
- 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.
228
-
229
- 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.
230
-
231
- 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.
232
-
233
- 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.
234
-
235
- 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.
236
-
237
- 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.
238
-
239
- 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.
240
-
241
- 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.
242
-
243
- 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.
244
-
245
- 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.
246
-
247
- 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".
248
-
249
- 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.
250
-
251
- 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.
252
-
253
- 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.
254
-
255
- 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.
256
-
257
- 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.
258
-
259
- 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.
260
-
261
- 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.
262
-
263
- 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.
264
-
265
- 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.
266
-
267
- 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.
268
-
269
- 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.
270
-
271
- 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.
272
-
273
- 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.
274
-
275
- 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.
276
-
277
- 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.
278
-
279
- 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.
280
-
281
- 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.
282
-
283
- 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.
284
-
285
- 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.
286
-
287
- 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.
288
-
289
- 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.
290
-
291
- 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.
292
-
293
- 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.
294
-
295
- 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.
296
-
297
- 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.`}]},wk="agent-dag.releaseNotesSeen";function _M(e){return e.split(/[.\-+]/).map(t=>parseInt(t,10)).map(t=>Number.isNaN(t)?0:t)}function _i(e,t){const n=_M(e),r=_M(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 Ei(e){return typeof e=="string"&&/^\d+\.\d+\.\d+/.test(e)}function Nie(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 jie(e){if(!e||typeof e!="object")return[];const t=[];for(const[n,r]of Object.entries(e)){if(!Ei(n)||!Array.isArray(r))continue;const s=r.filter(Nie);s.length&&t.push({version:n,notes:s})}return t.sort((n,r)=>_i(r.version,n.version))}const EM=jie(kie);function HP(e,t,n){return e.filter(r=>_i(r.version,n)<=0&&(t===null||_i(r.version,t)>0))}function Sie(e,t){return e.filter(n=>_i(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 Eie({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&&Ei(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(!Ei(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=_i(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 Tie=new RegExp("^(?:\\p{Extended_Pictographic}|\\p{Emoji_Modifier}|\\p{Regional_Indicator}|[\\u200D\\uFE0F])+(?= \\S)","u");function Cie(e){const t=Tie.exec(e);return t?{icon:t[0],rest:e.slice(t[0].length)}:{icon:null,rest:e}}function Aie(e){if(!e)return null;let t=null;try{t=e.getItem(wk)}catch{return null}return Ei(t)?t:null}function Rie(e){if(!e)return!1;try{return e.getItem(wk),!0}catch{return!1}}function Mie(e,t){if(!e)return!1;try{return e.setItem(wk,t),!0}catch{return!1}}const VP="agent-dag.tourSeen";function $ie(e){if(!e)return!1;try{return e.getItem(VP)==="1"}catch{return!1}}function Iie(e){if(!e)return!1;try{return e.setItem(VP,"1"),!0}catch{return!1}}function Oie({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 Lie({stored:e,running:t,notes:n,remembers:r=!0}){if(!Ei(t))return{show:[],record:null,reason:"no-version"};if(!Ei(e)){if(!r)return{show:[],record:t,reason:"cannot-remember"};const l=Sie(n,t);return l.length?{show:l,record:t,reason:"welcome"}:{show:[],record:t,reason:"first-run"}}const s=_i(e,t);if(s===0)return{show:[],record:null,reason:"seen"};if(s>0)return{show:[],record:null,reason:"ahead"};const o=HP(n,e,t);return o.length?{show:o,record:t,reason:"new-notes"}:{show:[],record:t,reason:"nothing-new"}}function Pie(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 GP(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=Pie(e,o);if(l>0){s(),n.push({kind:"bold",kids:GP(e.slice(o+2,l),!1)}),o=l+2;continue}}r+=e[o],o+=1}return s(),n}function Die({entries:e,since:t,running:n,firstRun:r,onClose:s,onTour:o,updateVersion:l,updateBusy:c,onUpdateRestart:d,updateFailure:h,onRestart:f}){const p=dt(s),g=gt(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…":Gd})]}),a.jsx("p",{className:"rn-update-said",role:"status",children:h})]}),a.jsx("p",{className:"modal-note",children:Eie({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}=Cie(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:KP(GP(k.body))})]},x)})})]},j.version))]})]})})}function KP(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:KP(t.kids)},n))}function Fie({state:e,sessionId:t,onClose:n}){const r=y.useMemo(()=>Bie(e,t),[e,e.revision,t]),s=y.useRef(null),o=dt(n,{focusRef:s}),l=gt(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:$I}),a.jsx("div",{className:"ss-cost",children:qe(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":ih(c),title:c,children:Ns(c)},c))})]}),a.jsx("div",{className:"ss-hero-right",children:r.cost.total>0&&a.jsxs(a.Fragment,{children:[a.jsx(S0,{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:qe(r.cost.input)})]}),a.jsxs("span",{className:"ssl ssl-out",children:["output ",a.jsx("b",{children:qe(r.cost.output)})]}),a.jsxs("span",{className:"ssl ssl-cr",children:["cache r ",a.jsx("b",{children:qe(r.cost.cacheRead)})]}),a.jsxs("span",{className:"ssl ssl-cw",children:["cache w ",a.jsx("b",{children:qe(r.cost.cacheWrite)})]})]})]})})]}),a.jsxs("section",{className:"ss-stats",children:[a.jsx(ei,{label:"agents",value:r.agentCount}),a.jsx(ei,{label:"subagents",value:r.subagentCount}),a.jsx(ei,{label:"tool calls",value:r.toolCount}),a.jsx(ei,{label:"prompts",value:r.promptCount}),a.jsx(ei,{label:"tokens",value:r.tokensSum.toLocaleString()}),r.errCount>0&&a.jsx(ei,{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 ei({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 Bie(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=pn(S);s.input+=E.input,s.output+=E.output,s.cacheRead+=E.cacheRead,s.cacheWrite+=E.cacheWrite,s.total+=E.total;for(const O of J$(S))o.add(O);S.model&&o.add(S.model),S.kind==="subagent"&&p++;const R=D$(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[O,A]of S.toolCountByName??[])l.set(O,(l.get(O)??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}}function YP({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:dd,max:Bd,step:Eb,value:n,"aria-describedby":s,onChange:o=>r(Number(o.target.value)),style:{"--sm-level":`${(n-dd)/(Bd-dd)*100}%`}}),a.jsxs("span",{className:"sm-read",children:[n,"%"]})]})}const XP="agent-dag.character-enabled",ZP="agent-dag.fm-volume",TM="agent-dag.fm-source",qie=[{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 Uie(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 zie(e){return e!=="0"}function Wie(){return zie(Je(XP))}function Hie(e){return rL(e)}function Vie(){return Hie(Je(ZP))}const CM=qie,ti="Give the station a name.",Gie="Use an https YouTube live or channel link, or a .mp3, .aac, .ogg or .m3u8 stream.";function Kie({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 fe;const v=[...CM.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:no(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),[O,A]=y.useState(""),[q,I]=y.useState(""),[B,L]=y.useState(""),[M,F]=y.useState(!1),[C,$]=y.useState(""),[P,K]=y.useState(""),[G,U]=y.useState(null),W=y.useRef(0),D=y.useRef(null),H=y.useRef(null),J=y.useRef(null),V=y.useRef(null),Z=y.useRef(null),Y=yi(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),$((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,Ie;const Ne=oe.target;!((we=D.current)!=null&&we.contains(Ne))&&!((Ie=Z.current)!=null&&Ie.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())},ue=ne=>{if(rI(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(!G)return;const ne=window.setTimeout(()=>U(null),4e3);return()=>window.clearTimeout(ne)},[G]);const ye=()=>{if(!X)return;const ne=Date.now(),oe=ao({armedFor:G,target:X.id,armedAt:W.current,now:ne,gapMs:so});if(oe==="arm"){U(X.id),W.current=ne;return}oe!=="ignore"&&(U(null),g(X.id),ge())},se=X!==void 0&&G===X.id,me=ne=>{var Ne,we;if(ne.preventDefault(),!O.trim()){L(ti),(Ne=H.current)==null||Ne.focus();return}const oe=aq(O,q);if(!oe){L(Gie),(we=J.current)==null||we.focus();return}f(oe),c(no(oe.id)),A(""),I(""),L(""),R(!1),ge()},pe=ne=>{var oe;if(ne.preventDefault(),!!Y){if(!C.trim()){K(ti),(oe=V.current)==null||oe.focus();return}p(Y,C),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:ue,children:[a.jsx("span",{children:((fe=v.find(ne=>ne.value===l))==null?void 0:fe.label)??CM[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?Q8(yi(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:()=>{$(X.name),K(""),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:me,noValidate:!0,children:[a.jsxs("label",{className:"appearance-station-field",children:[a.jsx("span",{children:"Station name"}),a.jsx("input",{ref:H,className:"ap-manage-input",value:O,onChange:ne=>A(ne.target.value),"aria-invalid":B===ti||void 0,"aria-describedby":B===ti?"appearance-station-error":void 0,maxLength:ec,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=>I(ne.target.value),placeholder:"https://…","aria-invalid":B!==""&&B!==ti||void 0,"aria-describedby":B&&B!==ti?"appearance-station-error":void 0,inputMode:"url",autoComplete:"off",spellCheck:!1,maxLength:y$})]}),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: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:C,onChange:ne=>$(ne.target.value),"aria-invalid":P!==""||void 0,"aria-describedby":P?"appearance-rename-error":void 0,maxLength:ec,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"}),P&&a.jsx("p",{id:"appearance-rename-error",className:"appearance-station-error",role:"alert",children:P})]}),a.jsx(YP,{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 Yie="With no deck tab open, get a notification wherever a sound would have played.",Xie="With the ccdeck window closed, get a notification wherever a sound would have played.";function Zie(e){return e?Xie:Yie}const Jie="Held off for this run — the deck was started with alerts disabled. Your choice is saved for the next start.",Qie=[{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"}],ele="For the Claude and Codex accounts you're on, whether or not the deck is open.",tle="Held off for this run too.",AM="Get notified when you're away from this tab.";function nle(e){switch(e){case"granted":return{status:"Enabled",ask:!1,ok:!0,note:AM};case"default":return{status:null,ask:!0,ok:!1,note:AM};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 pc(e=typeof navigator>"u"?"":navigator.userAgent){return/\bccdeck-desktop\/\d/.test(e)}function rle({notifyOn:e,onToggleNotify:t,notifyVetoed:n,notifyPermission:r,onAskNotify:s,accountNotify:o,onToggleAccountNotify:l}){const c=nle(r),d=pc(),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?Jie:Zie(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?tle:ele}),Qie.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 sle({section: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:[e==="sounds"&&a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M3.2 5.2h2L7.8 3v8L5.2 8.8h-2z"}),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"})]}),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 ale=["audio/webm;codecs=opus","audio/ogg;codecs=opus","audio/mp4"];function ole(e){return ale.find(t=>e(t))}const ile=4400;function lle(e){const t=e.split(";")[0];return{name:`Recorded voice.${t==="audio/mp4"?"m4a":t==="audio/ogg"?"ogg":"webm"}`,type:t}}function cle({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=ole(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=lle(j.mimeType),b=new File(k,N.name,{type:N.type});n(()=>r(b))},j.start(200),o(!0),c.current=setTimeout(h,ile)}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 ule({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 dle({customAssets:e,onImportCustom:t,onCreateVoice:n,onRenameCustom:r,onPreviewCustom:s,onDeleteCustom:o}){const[l,c]=y.useState(""),d=e.length,h=Sb(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 I=Date.now(),B=ao({armedFor:g,target:A,armedAt:j.current,now:I,gapMs:so});if(B==="arm"){v(A),j.current=I;return}if(B==="ignore")return;v(null);const L=fJ(e.map(M=>M.id),A);b(async()=>{var F;await o(A);const M=document.activeElement;M!==q&&!En((M==null?void 0:M.tagName)??null)||(F=L?k.current.get(L):x.current)==null||F.focus()})},{recording:E,startRecording:R,stopRecording:O}=cle({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 ",jb,", 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 I;const q=(I=A.target.files)==null?void 0:I[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:O,children:"Stop & save"}):a.jsx("button",{type:"button",className:"btn sm-custom-action",...p,onClick:()=>void R(),children:"Record"})]})]}),a.jsx(ule,{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})]})}function hle({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 Bb="custom:";function RM(e){return`${Bb}${e}`}function fle(e){return e.startsWith(Bb)?e.slice(Bb.length):null}const MM={done:"Turn finished","needs-input":"Claude is asking"},ple={done:"Plays when Claude or Codex finishes a turn.","needs-input":"Available in Claude Code only."};function mle({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:MM[e]}),a.jsxs("button",{type:"button",className:"btn sm-hear",onClick:()=>c(e),"aria-label":`Hear the ${MM[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(YP,{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?RM(g):t.figure,onChange:v=>{const j=v.target.value,k=fle(j);k!==null?h(e,k):(d(e),l(e,j))},children:[W0[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:RM(v.id),children:v.name},v.id))})]})]}),a.jsx("p",{className:"sm-note",children:ple[e]})]})}const gle="Claude Code isn't on this machine, so only Turn finished plays here — for Codex turns.";function yle({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=dJ(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(hle,{soundOn:e,onToggleSound:t}),!r&&a.jsx("p",{className:"sm-note",children:gle}),!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:ud.map(E=>a.jsx(mle,{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(dle,{customAssets:c,onImportCustom:p,onCreateVoice:g,onRenameCustom:v,onPreviewCustom:j,onDeleteCustom:k})]})}const Cl=["light","dark"],wle={light:"Light",dark:"Dark"};function vle({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 xle({theme:e,onTheme:t}){const n=r=>{var l;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(r.key))return;r.preventDefault();const o=(Cl.indexOf(e)+(r.key==="ArrowLeft"||r.key==="ArrowUp"?-1:1)+Cl.length)%Cl.length;t(Cl[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:Cl.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(vle,{theme:r}),a.jsxs("span",{className:"appearance-theme-name",children:[wle[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 ble({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=dt(n,{focusRef:f}),g=gt(n),v=y.useRef([]),j=Xre(e);y.useEffect(()=>{var oe,Ne;Zre((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=yO(oe,j,pd.length,"vertical");Ne.kind!=="pass"&&(oe.preventDefault(),t(pd[Ne.index].id),(we=v.current[Ne.index])==null||we.focus())},E=oe=>{var Ie;if(oe.key===" "){oe.stopPropagation();return}const Ne=oe.target;if(ki(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"&&((Ie=oe.currentTarget.querySelector('[role="radio"][aria-checked="false"]'))==null||Ie.focus())},{soundOn:R,toggleSound:O}=s,{tonePrefs:A,previewTone:q,changeTone:I}=o,{customSelections:B,customAssets:L,clearCustomOnly:M,selectCustomTone:F,importNotificationAudio:C,createNotificationVoice:$,renameCustomAsset:P,deleteCustomAsset:K,previewCustomAsset:G}=l,{notifyPermission:U,notifyOn:W,notifyVetoed:D,toggleNotify:H,notifySupported:J,askForNotifications:V,accountNotify:Z,toggleAccountNotify:Y}=c,{fmVolume:X,setFmVolume:ee,fmMuted:ae,setFmMuted:ue,fmSource:ge,customFmStations:ye,unavailableFmStations:se,addFmStation:me,renameFmStation:pe,removeFmStation:de,pickFmSource:fe}=h,ne=(()=>{switch(e){case"notifications":return a.jsx(rle,{notifyOn:W,onToggleNotify:H,notifyVetoed:D,notifyPermission:J?U:"unsupported",onAskNotify:V,accountNotify:Z,onToggleAccountNotify:Y});case"sounds":return a.jsx(yle,{soundOn:R===!0,onToggleSound:O,prefs:A,claudeHere:r.claude,onLevel:(oe,Ne)=>I(oe,{level:Ne}),onFigure:(oe,Ne)=>I(oe,{figure:Ne}),onPreview:oe=>q(oe),customAssets:L,customSelections:B,onBuiltInSelected:M,onCustomSelected:F,onImportCustom:C,onCreateVoice:$,onRenameCustom:P,onPreviewCustom:G,onDeleteCustom:K});case"music":return a.jsx(Kie,{characterEnabled:N,onToggleCharacter:()=>b(oe=>!oe),fmVolume:X,onFmVolume:ee,fmMuted:ae,onFmMuted:()=>ue(oe=>!oe),fmSource:ge,onFmSource:fe,customFmStations:ye,unavailableFmStations:se,onAddFmStation:me,onRenameFmStation:pe,onRemoveFmStation:de});default:return a.jsx(xle,{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:pd.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(sle,{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 kle({tool:e,onClose:t}){const n=dt(t),r=gt(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=Hq(e.name,l,c);return{input:f.input.map((p,g)=>a.jsx($M,{block:p},g)),response:f.response.map((p,g)=>a.jsx($M,{block:p},g)),copyInput:Bj(e.name,"input",l),copyResponse:Bj(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:tI(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(IM,{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(IM,{text:h.copyResponse,what:"response"})]}),e.endedAt==null?a.jsx("pre",{children:"(waiting…)"}):h.response]})]})]})})}const Nle={del:"tm-del",add:"tm-add",ctx:"tm-ctx"};function $M({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(()=>Dq(e),[e]),{shown:s}=F$(r,t),o=Fq(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?Nle[l.tone]:void 0,children:[l.text,c<s.length-1?`
298
- `:""]},c)):s.map(l=>l.text).join(`
299
- `)}),o&&a.jsx("button",{type:"button",className:"btn tm-more","aria-expanded":o.expanded,onClick:()=>n(l=>!l),children:o.label})]})}function IM({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 io(e).then(o=>{!o||!s.current||(r(!0),window.setTimeout(()=>{s.current&&r(!1)},1600))}),children:n?"copied":"copy"})}const jle=zP(()=>k0(()=>import("./UsageHistoryModal-C775SS_q.js"),[]),"Usage history"),Sle=zP(()=>k0(()=>import("./BrowserWatchModal-FsBjYpPs.js"),[]),"Browser Watch");function _le({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:O,setUsageHistoryOpen:A,browserWatchOpen:q,setBrowserWatchOpen:I,contextAgent:B,setContextFor:L,summaryFor:M,setSummaryFor:F,keyHelpOpen:C,setKeyHelpOpen:$,feedbackOpen:P,setFeedbackOpen:K,feedbackPrefill:G,setFeedbackPrefill:U}=e,{tourOpen:W,openTour:D,closeTour:H,releaseNotes:J,closeReleaseNotes:V,chipVersion:Z}=t,{desktopUpdateRestarting:Y,desktopUpdateFailure:X,readyAppUpdate:ee,askDesktopUpdateRestart:ae}=n,{version:ue}=r,{askRestart:ge}=s,{clearConfirmOpen:ye,setClearConfirmOpen:se,requestClear:me}=c,{setWatchOn:pe,markWatchSeen:de}=d,{setWatchSaid:fe}=h,{palette:ne}=f,{settingsOpen:oe,settingsSection:Ne,showSection:we,closeSettings:Ie}=j;return a.jsxs(a.Fragment,{children:[E&&a.jsx(kle,{tool:E,onClose:()=>R(null)}),O&&a.jsx(y.Suspense,{fallback:null,children:a.jsx(jle,{providers:p,onClose:()=>A(!1)})}),q&&a.jsx(y.Suspense,{fallback:null,children:a.jsx(Sle,{onClose:()=>I(!1),onSeen:Pe=>{fe(""),de(Pe)},onWatching:pe,palette:ne})}),B&&a.jsx(hz,{agent:B,onClose:()=>L(null)}),P&&a.jsx(UP,{initialKind:G==null?void 0:G.initialKind,initialBody:G==null?void 0:G.initialBody,onClose:()=>{K(!1),U(null)}}),M&&a.jsx(Fie,{state:g.current,sessionId:M,onClose:()=>F(null)}),oe&&a.jsx(ble,{section:Ne,onSection:we,onClose:Ie,providers:p,sound:k,tones:x,customTones:N,notify:b,appearance:f,fm:S}),J&&a.jsx(Die,{entries:J.entries,since:J.since,firstRun:J.firstRun,running:Z,onClose:V,onTour:()=>{V(),D()},updateVersion:ee==null?void 0:ee.version,updateBusy:Y,updateFailure:X&&(!ee||ee.version===X.version)?Use(X.failure,X.version):void 0,onUpdateRestart:ee?()=>{ae(ee.version)}:void 0,onRestart:!ee&&(ue!=null&&ue.canRestart)?()=>{V(),ge()}:void 0}),a.jsx(Ele,{lanPairs:o,attention:l}),C&&a.jsx(aie,{onClose:()=>$(!1),onTour:()=>{$(!1),D()}}),W&&a.jsx(_O,{title:"What the deck shows you",steps:vY,onClose:H}),ye&&a.jsx(Cae,{agentCount:v,onConfirm:()=>me("confirmation"),onCancel:()=>se(!1)})]})}function Ele({lanPairs:e,attention:t}){const n=yie(e);return a.jsxs(a.Fragment,{children:[n,a.jsx(bie,{...t,pairing:n!=null})]})}const Tle=10,JP=500,QP=4e3,Cle=[/ResizeObserver loop/i,/^Script error\.?$/i],Xd=String.raw`[^\s\\/:'"\`<>|?*;,]`,Ale=String.raw`${Xd}(?:[^\\/\r\n:'"\`<>|?*;,]*${Xd})?[\\/]`,Rle=String.raw`[^\s\\/:'"\`<>|?*;,()]+`,Al=String.raw`(?:${Ale})*(?:${Rle})?`,Mle=String.raw`(?<![\w.~/\\\]-]|<(?:deck|host)>)(?:file://(?:/[A-Za-z]:)?[^\s:'"\`<>()]*|~[\\/]${Al}|[A-Za-z]:[\\/]${Al}|\\\\(?:[?.]\\)?(?:[A-Za-z]:\\)?${Al}|/(?=${Xd})${Al}|(?<!:)//(?=${Xd})${Al})`,$le=String.raw`(?<![\w-])(?:[A-Za-z]--|-[A-Za-z0-9][\w.]*-)[\w.-]*`,Ile=new Set([".claude",".codex"]);function Ole(e){if(!e.startsWith("~"))return"<path>";const t=e[1],[n,...r]=e.slice(2).split(/[\\/]/);return n?Ile.has(n)?r.join("")?`~${t}${n}${t}<path>`:e:`~${t}<path>`:e}const Lle=String.raw`\b(https?|wss?)://[^\s/?#\\'"\x60<>(),;]+(?=(/assets/)?)`;function Ple(e,t,n){return n?"<deck>":`${t}://<host>`}const OM=String.raw`(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)`,e3=String.raw`${OM}(?:\.${OM}){3}`,Sx=String.raw`[0-9A-Fa-f]{1,4}`,LM=String.raw`(?=[0-9A-Fa-f:]*\d)(?=[0-9A-Fa-f:]*::|(?:${Sx}:){7})(?:(?:${Sx})?:)+(?:${e3}|${Sx})?`,PM=String.raw`%[\w-]+(?:\.[\w-]+)*`,DM=String.raw`(?:::1?|::ffff:(?:127(?:\.\d{1,3}){3}|0\.0\.0\.0))`,Dle=String.raw`(?<![\w:.%-])(?:\[(?!${DM}\])${LM}(?:${PM})?\]|(?!${DM}(?::\d{1,5})?(?![\w:%]|\.\d))${LM}(?:${PM})?(?![\w%]|\.\d))|(?<![\w./-])(?!127\.|0\.0\.0\.0\b)${e3}(?![\w-]|\.\d)`,_x=String.raw`(?=[\w.-]*[A-Za-z])[A-Za-z0-9][\w-]*(?:\.[\w-]+)*`,Fle=String.raw`(?<![\w.@/\\%-])(?!localhost(?![\w-]|\.\w))(?:(?<=\b(?:(?:getaddrinfo|connect) E[A-Z_]+|ENOTFOUND|EAI_AGAIN) )${_x}|${_x}(?=:\d{1,5}(?![\w:-]|\.\w))|${_x}\.(?:local|lan|home|internal|ts\.net)(?![\w-]|\.\w))`;function FM(e){return String(e??"").replace(/\/(?:home|Users)\/[^/\s:'"]+/g,"~").replace(/[A-Za-z]:\\(?:Users|Documents and Settings)\\[^\\\r\n:'"]+/gi,"~").replace(new RegExp(Mle,"g"),Ole).replace(new RegExp($le,"g"),"<project>").replace(new RegExp(Lle,"g"),Ple).replace(new RegExp(Dle,"g"),"<host>").replace(new RegExp(Fle,"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 t3=e=>{fetch("/api/client-error",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e),keepalive:!0}).catch(()=>{})};function Ble(e,t,n=t3){const r=String(e??"").slice(0,JP).trim();r&&n({message:r,stack:typeof t=="string"?t.slice(0,QP):void 0})}function qle(e,t=window,n=t3){let r=0;const s=new Set,o=(d,h)=>{const f=String(d??"").slice(0,JP).trim();!e()||!f||r>=Tle||s.has(f)||Cle.some(p=>p.test(f))||(s.add(f),r++,n({message:f,stack:typeof h=="string"?h.slice(0,QP):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 Ule=12;function zle(e,t){const n=[FM(e).trim()||"The deck threw an error with no message."],r=t==null?void 0:t.trim();if(r){const s=r.split(`
300
- `).slice(0,Ule).join(`
301
- `);n.push("",FM(s).trim())}return n.join(`
302
- `)}class Wle extends y.Component{constructor(){super(...arguments);xp(this,"state",{error:null,componentStack:null,reportOpen:!1});xp(this,"onKey",n=>{rI(n.key)&&Fr.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}),Ble(n.message,n.stack),NP("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(UP,{initialKind:"bug",initialBody:zle(n.message,r),onClose:()=>this.setState({reportOpen:!1})})]}):this.props.children}}const Hle=1e3;function Vle(e={}){const t=Math.max(1,Math.floor(e.limit??Hle)),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 Gle(e){const t=y.useState(()=>Vle({protect:o=>Xq(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&&wU(e.current);for(const c of l)e.current=K$(e.current,c);r(t.paused)},[t,e]);return{pauseGate:t,paused:n,togglePause:s}}const qb={kind:"assumed",claude:!0,codex:!0};function Kle(e){if(!e||typeof e!="object")return qb;const t=e.providers;if(!t||typeof t!="object")return qb;const n=t;return{kind:"reported",claude:n.claude!==!1,codex:n.codex!==!1}}function Yle(e){const[t,n]=y.useState(null),[r,s]=y.useState(qb);y.useEffect(()=>{let l=!1;return fetch("/api/health").then(c=>c.ok?c.json():null).then(c=>{l||(s(Kle(c)),!(!c||typeof c.workspace!="string")&&n(c.workspace))}).catch(()=>{}),()=>{l=!0}},[e]);const o=Sn(r);return{workspace:t,providers:r,providersRef:o}}const n3=3*6e4,Xle=2e4;function Zle({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>=n3&&await l()},stop:()=>{o=!1}}}async function Jle(){try{const e=await fetch("/api/provider-status",{signal:AbortSignal.timeout(Xle)});return e.ok?await e.json():null}catch{return null}}function Qle(e){const[t,n]=y.useState(null);return y.useEffect(()=>{if(!e){n(null);return}const r=Zle({fetchReport:Jle,visible:()=>document.visibilityState==="visible",now:()=>Date.now(),onReport:n});r.tick();const s=window.setInterval(r.tick,n3),o=()=>{r.wake()};return document.addEventListener("visibilitychange",o),()=>{r.stop(),window.clearInterval(s),document.removeEventListener("visibilitychange",o)}},[e]),t}const ece={degraded:"degraded performance",partial_outage:"partial outage",major_outage:"major outage",maintenance:"maintenance"},tce={degraded:"degraded",partial_outage:"partial outage",major_outage:"major outage",maintenance:"maintenance"},nce={degraded:"degraded",partial_outage:"outage",major_outage:"outage",maintenance:"maint."},rce={claude:"Claude",codex:"Codex"},sce=new Set(["status.claude.com","status.openai.com"]),ace=30*6e4,oce=10*6e4;function ice(e){if(typeof e!="string")return null;try{const t=new URL(e);return t.protocol==="https:"&&sce.has(t.hostname)?t:null}catch{return null}}function BM(e){return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hourCycle:"h23"})}function lce(e){const t=Math.floor(e/6e4);return t<1?"just now":t<60?`${t} min ago`:`${Math.floor(t/60)} h ago`}function cce(e,t){if(!e||typeof e!="object")return null;const n=Pt(ece,e.state),r=Pt(rce,e.provider);if(!n||!r||typeof e.checkedAt!="number"||t-e.checkedAt>ace)return null;const s=ice(e.statusPageUrl);if(!s)return null;const o=Array.isArray(e.components)?e.components:[],l=e.stale===!0||t-e.checkedAt>oce,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 ${BM(e.checkedAt)}; this is the last thing it said`:`Reported by ${s.hostname}, checked ${lce(t-e.checkedAt)}`,"Opens the status page"],d=l?BM(e.checkedAt):null;return{provider:e.provider,state:e.state,name:r,label:`${r} · ${n}${d?` · as of ${d}`:""}`,words:n,chipWords:Pt(tce,e.state)??n,shortWords:Pt(nce,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(`
303
- `)}}function uce(e,t){return!(e!=null&&e.ok)||e.disabled||!Array.isArray(e.providers)?[]:e.providers.map(n=>cce(n,t)).filter(n=>n!==null)}function dce(e){return e.map(t=>`${t.name}'s status page reports ${t.state.endsWith("outage")?`a ${t.words}`:t.words}.`).join(" ")}const hce="The providers' status pages report no incident.";function fce({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=yae(e==null?void 0:e.upgrade),l=y.useRef(!1),c=y.useCallback(async()=>{if(pr(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 io(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 qM="agent-dag.browserWatch.seenMs";function pce(e,t){return e.filter(n=>n.startMs>t)}function mce(){const[e,t]=y.useState(()=>Number(Je(qM))||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(()=>pce(n,e).length,[n,e]),c=y.useCallback(d=>{t(d),Ke(qM,String(d))},[]);return{watchOn:s,setWatchOn:o,watchUnseen:l,markWatchSeen:c}}const r3=["--err","--inflight","--ok","--grid-line","--minimap-mask","--panel","--line","--accent","--text-dim","--bg"];function UM(e){const t={};for(const n of r3)t[n]=e(n);return t}function gce(e){return t=>e[t]??""}function yce(e,t){return r3.every(n=>e[n]===t[n])}const s3="agent-dag.theme";function wce(e,t=!1){return e==="light"||e==="dark"?e:t?"light":"dark"}function vce(){try{return window.matchMedia("(prefers-color-scheme: light)").matches}catch{return!1}}function xce(){return wce(Je(s3),vce())}function zM(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}function bce(){const[e,t]=y.useState(xce),[n,r]=y.useState(Wie),[s,o]=y.useState(()=>UM(zM)),l=y.useMemo(()=>gce(s),[s]),c=y.useCallback(d=>_re(d,l),[l]);return y.useEffect(()=>{document.documentElement.dataset.theme=e,Ke(s3,e),o(d=>{const h=UM(zM);return yce(d,h)?d:h})},[e]),y.useEffect(()=>{Ke(XP,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 kce(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(SP(f.name));return Object.keys(jP).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=B7(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 Nce(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=_b(g,j),x=_J(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,O=R+b.ms/1e3;E.gain.setValueAtTime(R_,R),E.gain.exponentialRampToValueAtTime(x,R+EJ),E.gain.exponentialRampToValueAtTime(R_,O),S.connect(E).connect(n.destination),S.start(R),S.stop(O+.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=TJ(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(CJ(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=LJ((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:Nn},Nn))}),!0):!n||n.state!=="running"?!1:c(g,j)}function f(g,v=oo){return d(g,{level:Eh(v),figure:Nn}),!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 jce({chimesRef:e,soundOnRef:t,tonePrefsRef:n,customSelectionsRef:r,fallbackCustomRef:s}){y.useEffect(()=>{const o=Nce({enabled:()=>t.current===!0,prefs:()=>n.current,customSelection:()=>r.current,loadCustom:bJ,onCustomFailure:(h,f)=>s.current(h,f)});e.current=o;const l=["pointerdown","pointerup","keydown"],c=()=>{for(const h of l)window.removeEventListener(h,d,{capture:!0})},d=()=>{var h;o.unlock(),((h=o.context)==null?void 0:h.state)==="running"&&c()};for(const h of l)window.addEventListener(h,d,{capture:!0});return c},[])}function Sce(){const[e,t]=y.useState(Vie),[n,r]=y.useState(()=>tq(Je(Rj))),[s,o]=y.useState(()=>eq(Je(Mj))),[l,c]=y.useState(()=>nq(Je(TM),n,Uie)),[d,h]=y.useState(()=>new Set),[f,p]=y.useState(0);y.useEffect(()=>{Ke(ZP,String(e))},[e]),y.useEffect(()=>{Ke(Mj,s?"1":"0")},[s]),y.useEffect(()=>{Ke(Rj,JSON.stringify(n))},[n]),y.useEffect(()=>{Ke(TM,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>ec||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=>rq(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=$j(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=$j(N);h(E=>{if(E.has(S)===b)return E;const O=new Set(E);return b?O.add(S):O.delete(S),O})},[]);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 _ce(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||!pc())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=fM(x);N&&n(N)}).catch(()=>{}),()=>{j=!0}},[e]);const d=Pse(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(!pr(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(qse(await N.json().catch(()=>null)))}catch{return x("unreachable")}k===p.current&&(f.current=window.setTimeout(()=>x("timeout"),_P))},[]),v=y.useCallback(j=>{if(pc())try{const k=fM(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 td="agent-dag.autoRestart",WM="agent-dag.bundleReloadedFor";function Ece({now:e,stateRef:t,version:n,notice:r,noticeOpen:s,upgradeFailure:o,paused:l}){const[c,d]=y.useState(()=>Je(td)!=="0"),h=y.useRef(!1),f=y.useCallback(()=>{const B=!c;h.current=!0,ws(td),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(!pr(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,C=()=>{j(L?"npx":"restart"),g(!0)};M||C();try{window.sessionStorage.setItem("agent-dag.restartPending",(r==null?void 0:r.to)??"")}catch{}let $=!1;try{const P=await fetch("/api/restart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(M?{upgrade:L,whenIdle:M}:{upgrade:L})});$=M&&P.status===409}catch{}if($){N.current=!1,E.current=null;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}return}M&&C(),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=pM(t.current.agents.values())>0,L=kae({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 O=pM(t.current.agents.values()),A=bae(O,l),q=CP({enabled:c,kind:r==null?void 0:r.kind,canRestart:(n==null?void 0:n.canRestart)===!0,noticeOpen:s,visible:document.visibilityState==="visible",busy:O>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(WM)}catch{return}const F=gae({bundle:"3.38.6",running:B,pending:L,lastTried:M});if(F==="reload"){try{window.sessionStorage.setItem(WM,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 C=window.setTimeout(()=>x(null),6e3);return()=>window.clearTimeout(C)},[n==null?void 0:n.running]),y.useEffect(()=>{if(p&&wae({asked:b.current,reported:o})){try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}N.current=!1,g(!1)}},[p,o]);const I=y.useCallback(B=>{var L,M;if(!h.current){const F=Je(td)==="0";ws(td),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:I}}function Tce(){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(t_(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?wb:SO))})};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(t_(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 Cce=6e4;function Ace({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<Cce||(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?lie(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(cie(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 a3="agent-dag.sessionListOpen",o3="agent-dag.accountsPanelOpen";function Rce(){return Je(a3)==="1"}function Mce(e){Ke(a3,e?"1":"0")}function $ce(){const e=Je(o3);return e===null?!0:e==="1"}function Ice(){const[e,t]=y.useState(Rce);y.useEffect(()=>{Mce(e)},[e]);const n=y.useRef(!1),[r,s]=y.useState(()=>{const h=$ce();return h&&e?(n.current=!0,!1):h});y.useEffect(()=>{!r&&n.current||Ke(o3,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 i3="agent-dag.detailOpen",l3="agent-dag.usagePanelOpen",c3="agent-dag.systemPanelOpen";function Oce(){return Je(i3)==="1"}function Lce(e){Ke(i3,e?"1":"0")}function Pce(){const e=Je(l3);return e===null?!0:e==="1"}function Dce(e){Ke(l3,e?"1":"0")}function Fce(){const e=Je(c3);return e===null?!0:e==="1"}function Bce(e){Ke(c3,e?"1":"0")}function qce(){const[e,t]=y.useState(Oce);y.useEffect(()=>{Lce(e)},[e]);const[n,r]=y.useState(Pce);y.useEffect(()=>{Dce(n)},[n]);const[s,o]=y.useState(Fce);return y.useEffect(()=>{Bce(s)},[s]),Ut("usage-panel",n),Ut("machine-panel",s),{detailOpen:e,setDetailOpen:t,usagePanelOpen:n,setUsagePanelOpen:r,machinePanelOpen:s,setMachinePanelOpen:o}}const Uce={permission:"your permission",asked:"your answer"},zce="No sessions are waiting for you.";function Wce(e){if(e.length===0)return"";const[t,...n]=e,r=t.waiting.kind,s=n.every(l=>l.waiting.kind===r)?Uce[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 Ex(e,t,n=zce){return t!==""?t:e===""?"":n}function Hce({waitingSessions:e,watchUnseen:t,incidents:n=[]}){const[r,s]=y.useState(""),o=Wce(e);y.useEffect(()=>{s(g=>Ex(g,o))},[o]);const[l,c]=y.useState(""),d=t>0?`Browser watch has ${t} unread ${t===1?"finding":"findings"}.`:"";y.useEffect(()=>{c(g=>Ex(g,d,"Browser watch has no unread findings."))},[d]);const[h,f]=y.useState(""),p=dce(n);return y.useEffect(()=>{f(g=>Ex(g,p,hce))},[p]),{blockedSaid:r,watchSaid:l,setWatchSaid:c,incidentSaid:h}}const Vce="/icon-192.png",u3=Object.freeze({notifySwap:!0,notifyQuota:!1,notifyReset:!1});function HM(e){const t=n=>typeof(e==null?void 0:e[n])=="boolean"?e[n]:u3[n];return{notifySwap:t("notifySwap"),notifyQuota:t("notifyQuota"),notifyReset:t("notifyReset")}}function Gce({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(u3),v=y.useCallback(q=>{const I=!p[q];g(B=>({...B,[q]:I})),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({[q]:I})}).then(B=>B.ok?B.json():null).then(B=>{B!=null&&B.ok&&g(HM(B.prefs))}).catch(()=>{})},[p]),j=y.useRef(()=>{}),k=y.useRef(new Set),x=Sn(e),N=y.useCallback(()=>{const q=!c;d(q),q&&(k.current=Fu(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(I=>I.ok?I.json():null).then(I=>{var B;I!=null&&I.ok&&(d(((B=I.prefs)==null?void 0:B.notifications)===!0),f(I.notificationsVetoed===!0))}).catch(()=>{})},[c]),b=typeof Notification<"u";y.useEffect(()=>{if(!o)return;const I=setTimeout(()=>l(null),o==="blocked"?8e3:4e3);return()=>clearTimeout(I)},[o]);const S=y.useCallback(()=>{typeof Notification>"u"||Notification.requestPermission().then(q=>{const I=q;s(I),I==="granted"?l("on"):I==="denied"&&l("blocked")})},[]);j.current=S;const E=y.useRef(null),R=e.map(q=>lh(q.id,q.waiting)).join("|");y.useEffect(()=>{PU(E.current,r)&&(E.current=r,k.current=Fu(e))},[r]);const O=y.useRef(!1);y.useEffect(()=>{DU(O.current,t)&&(O.current=!0,k.current=Fu(e))},[t]),y.useEffect(()=>{if(typeof Notification>"u"||Notification.permission!=="granted"||!FU(E.current,t))return;const q=typeof document>"u"||!document.hidden,I=OU(e,k.current,q,c);for(const B of I)try{const L=new Notification(B.title,{body:B.body,tag:B.key,icon:Vce});L.onclick=()=>{window.focus(),n(B.sessionId),L.close()}}catch{}k.current=q?Fu(e):LU(e,I,k.current)},[R,t]);const A=y.useCallback(q=>{var I;d(((I=q.prefs)==null?void 0:I.notifications)===!0),f(q.notificationsVetoed===!0),g(HM(q.prefs))},[]);return{notifyPermission:r,notifySaid:o,notifyOn:c,notifyVetoed:h,toggleNotify:N,notifySupported:b,askForNotifications:S,loadNotifyPrefs:A,accountNotify:p,toggleAccountNotify:v}}function Kce({openedTool:e,usageHistoryOpen:t,contextFor:n,tourOpen:r,summaryFor:s,browserWatchOpen:o,keyHelpOpen:l,releaseNotes:c,feedbackOpen:d}){const h=Sn(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 Yce({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)},[]);Ut("tool-detail",r!==null),Ut("session-summary",l!==null),Ut("context-window",d!==null),Ut("keyboard-help",p),Ut("usage-history",v),Ut("browser-watch",k),Ut("feedback",N);const O=r?Vq(e.current.agents,r.agentId,r.toolId):null,A=d?e.current.agents.get(d):void 0,{keyHelpOpenRef:q,modalOpenRef:I}=Kce({openedTool:O,usageHistoryOpen:v,contextFor:d,tourOpen:t,summaryFor:l,browserWatchOpen:k,keyHelpOpen:p,releaseNotes:n,feedbackOpen:N});return{setOpenedToolKey:s,openTool:o,openedTool:O,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:I}}function Xce({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=u0(),t.current.clear(),n.current.clear(),r.current.clear(),s.current="",wP(),o(),l(),c()},[c,l,o]),g=Sn(h),v=y.useCallback(j=>{const k=Sae(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 VM="agent-dag.oldNameNoticeDismissed";function Zce(e){const[t,n]=y.useState(()=>Je(VM)??""),r=e!=null&&e.invokedAs&&e.invokedAs!==Nt?e.invokedAs:null,s=r!=null&&t!==r,o=y.useCallback(()=>{r&&(n(r),Ke(VM,r))},[r]);return{oldName:r,oldNameOpen:s,dismissOldName:o}}const Jce=300*1e3,Qce=1800*1e3,eue=8e3,tue=3e4;function GM(e){return fetch("/api/rating",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)}).catch(()=>null)}function nue({modalOpenRef:e}){const t=y.useCallback(()=>Kx({appModal:e.current,dialogDepth:Fr.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,Jce),x=window.setInterval(j,Qce);return()=>{v=!0,window.clearTimeout(k),window.clearInterval(x)}},[t]),y.useEffect(()=>{if(n!=="thanks"||l)return;const v=s!==null&&s<=6?tue:eue;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"),GM({score:v})},[]),f=y.useCallback(v=>c(v),[]),p=y.useCallback(()=>{r("hidden"),GM({later:!0})},[]),g=y.useCallback(()=>r("hidden"),[]);return{ratingPhase:n,ratingScore:s,answerRating:h,rateLater:p,closeRating:g,holdThanks:f}}function rue({chimesRef:e,setTonePrefs:t,tonePrefsRef:n,previewTone:r}){const[s,o]=y.useState(()=>cJ(Je)),l=Sn(s),[c,d]=y.useState([]),h=y.useCallback(b=>{o(S=>{const E={...S,[b]:null};return l.current=E,E}),ws(Wl[b])},[]),f=y.useCallback((b,S)=>{const E=l.current[b];S&&E!==S||(h(b),t(R=>{const O={...R,[b]:{...R[b],figure:Nn}};return n.current=O,O}),Ke(qd[b],Nn))},[h]),p=Sn(f);y.useEffect(()=>{let b=!0;return xJ().then(S=>{if(!b)return;d(S);const E=new Set(S.map(R=>R.id));for(const R of ud){const O=l.current[R];O&&!E.has(O)&&p.current(R,O)}},()=>{}),()=>{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),Ke(Wl[b],S),r(b,!0)},[c,r]),v=y.useCallback(async b=>{var O;const S=Sb(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 mJ(b,I=>R.decodeAudioData(I));await C_(A);const q=uc(A);d(I=>[...I.filter(B=>B.id!==q.id),q])}finally{(O=R.close)==null||O.call(R)}},[c.length]),j=y.useCallback(async b=>{const S=Sb(c.length);if(S)throw new Error(S);const E=gJ(b);await C_(E);const R=uc(E);d(O=>[...O.filter(A=>A.id!==R.id),R])},[c.length]),k=y.useCallback(async(b,S)=>{const E=c.find(O=>O.id===b),R=S.trim().slice(0,80);!E||!R||R===E.name||(await kJ(b,R),d(O=>O.map(A=>A.id===b?{...A,name:R}:A)))},[c]),x=y.useCallback(async b=>{await NJ(b),d(O=>O.filter(A=>A.id!==b));const S=l.current,E=uJ(S,b);l.current=E,o(E);const R=ud.filter(O=>S[O]===b);for(const O of R)ws(Wl[O]),Ke(qd[O],Nn);R.length>0&&t(O=>{const A={...O};for(const q of R)A[q]={...A[q],figure:Nn};return n.current=A,A})},[]),N=y.useCallback(b=>{var R,O;const S=ud.find(A=>l.current[A]===b),E=S?n.current[S].level:oo;(R=e.current)==null||R.unlock(),(O=e.current)==null||O.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 sue(e){const[t,n]=y.useState(()=>OJ(Je)),r=Sn(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)},AJ)},[]),l=y.useCallback((c,d)=>{n(h=>{const f={level:Eh(d.level??h[c].level),figure:tL(c,d.figure??h[c].figure)};return Ke(sL[c],String(f.level)),Ke(qd[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 aue=15e3;function oue(e){return e.visibilityState==="visible"&&e.hasFocus()}function iue(e,t){return t||e===!0}function lue(){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 cue(){y.useEffect(()=>{const e=lue();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=oue(document);iue(t,l)&&n(l),t=l},s=()=>{t&&n(!1),t=!1};r();const o=window.setInterval(r,aue);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 uue({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 Tx="agent-dag.versionNoticeDismissed",due=15*6e4;function hue(e){const[t,n]=y.useState(null),[r,s]=y.useState(()=>Je(Tx)??""),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>=due)},[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=EP(f),g=Gse(f,r),v=y.useCallback(()=>{s(""),Ke(Tx,"")},[]),j=y.useCallback(()=>{f&&(s(p),Ke(Tx,p))},[f,p]);return{version:t,notice:f,noticeOpen:g,showNotice:v,dismissNotice:j,versionChecking:l,loadVersion:d}}function fue({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=ql(),N=Aie(x),b=Lie({stored:N,running:(e==null?void 0:e.running)??null,notes:EM,remembers:Rie(x)});if(b.reason==="no-version")return;h.current=!0,b.record&&Mie(x,b.record);let S=!0;return(async()=>{var q;let R=$ie(x);if(pc())try{const I=await fetch("/api/prefs");if(!I.ok)throw new Error("desktop tour preferences unavailable");const B=await I.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 O=Oie({tourSeen:R,decision:b}),A=b.show.length?{entries:b.show,since:N,firstRun:!1}:null;O.tour&&r(!0),O.notes==="now"?l(A):O.notes==="after"&&(s.current=A)})(),()=>{S=!1}},[e==null?void 0:e.running]);const f=(e==null?void 0:e.running)??"3.38.6",p=y.useMemo(()=>HP(EM,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),Iie(ql()),pc()&&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 pue(){const[e,t]=y.useState(void 0),[n,r]=y.useState(!1),s=y.useRef(!1);return s.current=e===!0&&!n,y.useEffect(()=>qle(()=>s.current),[]),{loadReportsPrefs:y.useCallback(l=>{var c;t(((c=l.prefs)==null?void 0:c.reports)!==!1),r(l.reportsVetoed===!0)},[])}}function mue(){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=dM();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(Ose(x)),r(!1)}}).catch(()=>f(k)).finally(()=>{l=!1})},g=()=>{const k=s.current;Ise({shown:!!k&&k.getClientRects().length>0,tabVisible:document.visibilityState==="visible",lastSince:d,since:dM(),lastReadAt:c,now:Date.now()})&&p()};g();const v=window.setInterval(g,$se);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 gue(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 Ke("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=Sn(s),l=Sn(t);return{soundOn:t,toggleSound:r,activateSoundRef:o,soundOnRef:l}}function yue(){const[e,t]=y.useState(Jre),n=y.useCallback(o=>{t(l=>Qre(l,o))},[]),r=y.useCallback(()=>t(o=>({...o,open:!1})),[]),s=y.useCallback(o=>t(l=>({...l,section:o})),[]);return{settingsOpen:e.open,settingsSection:e.section,openSettings:n,closeSettings:r,showSection:s}}const wue="agent-dag.autoFitDisabled";function vue(e){const t=y.useRef(!1),[n,r]=y.useState(!1);y.useEffect(()=>{ws(wue)},[]);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 xue(){return a.jsx(o0,{children:a.jsx(Wle,{children:a.jsx(bue,{})})})}function bue(){const e=Ti(),t=y.useState(u0)[0],n=y.useRef(t),[,r]=y.useState(0),s=y.useCallback(()=>r(Bs=>Bs+1),[]),{detailOpen:o,setDetailOpen:l,usagePanelOpen:c,setUsagePanelOpen:d,machinePanelOpen:h,setMachinePanelOpen:f}=qce(),{selectedIds:p,primarySelectedId:g,selectAgent:v,clearSelection:j,pruneSelectionToBoard:k}=QJ(n,l),{sessionListOpen:x,accountsPanelOpen:N,toggleSessionList:b,toggleAccountsPanel:S,closeSessionList:E,closeAccountsPanel:R}=Ice(),O=mue(),A=od(N,200),q=od(c,130),I=od(h,130),B=y.useRef(null),L=gue(B),{activateSoundRef:M,soundOnRef:F}=L,C=sue(B),{setTonePrefs:$,tonePrefsRef:P,previewTone:K}=C,G=rue({chimesRef:B,setTonePrefs:$,tonePrefsRef:P,previewTone:K}),{customSelectionsRef:U,fallbackCustomRef:W}=G,D=yue(),{openSettings:H}=D;jce({chimesRef:B,soundOnRef:F,tonePrefsRef:P,customSelectionsRef:U,fallbackCustomRef:W});const J=Gle(n),{pauseGate:V,paused:Z,togglePause:Y}=J,X=y.useRef(()=>{}),{live:ee,tabCapped:ae,everConnected:ue,liveSince:ge}=zJ({stateRef:n,rerender:s,pauseGate:V,chimesRef:B,desktopUpdateRef:X}),ye=hue(ee),{version:se,notice:me,noticeOpen:pe,loadVersion:de}=ye,fe=_ce(ee),{readyAppUpdate:ne,onDesktopUpdateEvent:oe}=fe;X.current=oe,cue();const Ne=fue({version:se,readyAppUpdate:ne}),{tourOpen:we,openTour:Ie,releaseNotes:Pe}=Ne,{workspace:Be,providers:Oe,providersRef:Qe}=Yle(ee),Ye=Zce(se),Xe=fce({version:se,loadVersion:de}),{upgradeFailure:ot}=Xe,it=Yce({stateRef:n,tourOpen:we,releaseNotes:Pe}),Ze=nue({modalOpenRef:it.modalOpenRef}),{openTool:yt,setSummaryFor:ze,setContextFor:ht,openContext:mn,setKeyHelpOpen:Mt,setUsageHistoryOpen:lt,setBrowserWatchOpen:wt,keyHelpOpenRef:tn,modalOpenRef:Ft}=it,ft=pue(),nn=mce(),{watchOn:Wt,watchUnseen:xt}=nn,Tn=Tce(),[Yn,br]=y.useState(0),{presentCats:gn,hiddenCats:Xn,toggleCat:Zn,catBarRef:Jn,catBarOccluded:Cn}=kce(n),Vr=y.useRef(null),[An,kr]=y.useState(0),bt=eQ({stateRef:n,rerender:s,pruneSelectionToBoard:k,setContextFor:ht,setSummaryFor:ze}),Gr=Qle(Oe.claude||Oe.codex),Nr=uce(Gr,bt),Es=Ace({enabled:Oe.claude,lanStatus:Tn.lanStatus,now:bt}),Qn=Ece({now:bt,stateRef:n,version:se,notice:me,noticeOpen:pe,upgradeFailure:ot,paused:J.paused}),{askRestart:Rn,loadAutoRestartPrefs:Ts}=Qn,er=bce(),{setTheme:Cs,palette:As}=er,jr=Sce(),Sr=nre(),{applyViewport:Kr,moveCamera:Yr,fitLeft:ve,cameraEpochRef:Re,lastFitTimeRef:He}=Sr,$t=pre(ve),{pinnedRef:tr,positionsRef:Yt,lastLayoutSigRef:Rs,handleRelayout:Ms}=$t,yn=y.useRef(null),Xt=y.useRef(()=>{}),ya=ge!==null,rn=y.useRef(0),Tc=y.useCallback(()=>{rn.current=Date.now()},[]),{canvasRef:_r,canvasSize:Gh,paneSizeRef:fo}=Vre(),wa=vue(ve),{autoFitDisabledRef:$s,disableAutoFit:Is}=wa,Di=y.useRef(!1),{measuredRef:Xr,measuredVersionRef:Fi,sizeVersion:Cc,domSizeVersion:Bi}=Gre(Di),{removedNodes:Os,removedAgentIds:Ls,removeNode:qi,removeSelectedNode:Ve,removalNotice:Ui,bringBack:po,bringBackAll:zi,forgetRemovals:Ac}=Ore({stateRef:n,pinnedRef:tr,positionsRef:Yt,canvasRef:_r,clearSelection:j,primarySelectedId:g}),mo=Are({stateRef:n,now:bt,removedAgentIds:Ls,sizeVersion:Cc,domSizeVersion:Bi});mre(mo,$t),Ire({layoutSig:mo,rf:e,stateRef:n,measuredRef:Xr,pinnedRef:tr,positionsRef:Yt,paneSizeRef:fo,lastInteractRef:rn,autoFitDisabledRef:$s,lastFitTimeRef:He,fitLeft:ve});const Wi=Kre(),{bubbling:Hi,endBubble:go,onBubble:Er}=GZ(),[Mn,Tr]=y.useState(!1),Ps=HZ(),{beginTrashDrag:va,trackTrashDrag:Cr,endTrashDrag:Kh}=Ps,Vi=nJ({stateRef:n,measuredRef:Xr,measuredVersionRef:Fi,canvasRef:_r}),{lodRef:xa,applyZoom:Yh}=Vi,Gi=Wre({applyViewport:Kr,lastFitTimeRef:He,cameraEpochRef:Re,disableAutoFit:Is,markInteract:Tc,canvasRef:_r,applyZoom:Yh}),Ar=g?n.current.agents.get(g):null,yo=o&&Ar!=null,Zr=sse({sessionListShown:x,usageShown:Ba(q),machineShown:Ba(I),accountsShown:Ba(A)&&Oe.claude,detailShown:yo,primarySelectedId:g,canvasRef:_r}),{railInsetRef:Ds,availableWidth:Fs,availableHeight:Jr}=Zne({canvasRef:_r,canvasSize:Gh,machinePhase:I,usagePhase:q,usagePanelOpen:c,detailShown:yo}),ba=Rre({stateRef:n,now:bt,availableWidth:Fs,availableHeight:Jr,layout:$t,measuredRef:Xr,onBubble:Er,settled:Wi,dragging:Mn,layoutSig:mo,selectedIds:p,openContext:mn,historyReplayed:ya,removedNodes:Os,removedAgentIds:Ls,dragTick:Yn,dragPatchRef:Vr,dragMoveTick:An}),{nodes:Ki,edges:Xh}=ba,ka=Sn(g);gre({nodes:Ki,edges:Xh,settled:Wi,dragging:Mn,availableWidth:Fs,availableHeight:Jr,layout:$t,camera:Sr,rf:e,measuredRef:Xr,stateRef:n,lastFocusRef:yn,primarySelectedIdRef:ka,focusAgentRef:Xt,autoFitDisabledRef:$s});const Na=Xce({stateRef:n,pinnedRef:tr,measuredRef:Xr,positionsRef:Yt,lastLayoutSigRef:Rs,forgetRemovals:Ac,clearSelection:j,rerender:s,modalOpenRef:Ft}),{requestClear:wo}=Na,Rc=ase({nodes:Ki,stateRef:n,pinnedRef:tr,positionsRef:Yt,draggingRef:Di,dragPatchRef:Vr,setDragging:Tr,setDragMoveTick:kr,setDragTick:br,endBubble:go,markInteract:Tc,disableAutoFit:Is,beginTrashDrag:va,trackTrashDrag:Cr,endTrashDrag:Kh,removeNode:qi}),Rr=y.useCallback(()=>ve(500),[ve]),ja=Sn(Ki),{focusAgent:Qr,stepAgent:Mc,focusSession:Mr}=sre({canvasRef:_r,stateRef:n,measuredRef:Xr,nodesRef:ja,railInsetRef:Ds,moveCamera:Yr,disableAutoFit:Is,lastFocusRef:yn,focusAgentRef:Xt,selectAgent:v,primarySelectedIdRef:ka}),vo=Hre({clearSelection:j,selectAgent:v,detailOpen:o,setDetailOpen:l,detailShown:yo,focusAgent:Qr,draggingRef:Di,lodRef:xa}),$c=are({nodesRef:ja,stateRef:n,canvasRef:_r,railInsetRef:Ds}),Zt=Sn(Ve),es=y.useRef(null),Yi=y.useCallback(Bs=>{Ls.has(Bs)&&po([Bs]),Mr(Bs)},[Ls,po,Mr]),Sa=Yre();nse({pointerFocusRef:Sa,nodesRef:ja,stateRef:n,primarySelectedIdRef:ka,providersRef:Qe,soundOnRef:F,keyHelpOpenRef:tn,modalOpenRef:Ft,waitingCursorRef:es,removeSelectedRef:Zt,activateSoundRef:M,clearSelection:j,selectAgent:v,focusAgent:Qr,stepAgent:Mc,focusSession:Mr,requestClear:wo,handleRelayout:Ms,handleFit:Rr,togglePause:Y,toggleSessionList:b,toggleAccountsPanel:S,setDetailOpen:l,setUsageHistoryOpen:lt,setUsagePanelOpen:d,setMachinePanelOpen:f,setBrowserWatchOpen:wt,setKeyHelpOpen:Mt,setTheme:Cs,openSettings:H});const Ic=n.current.agents.size,ts=y.useMemo(()=>Gx(n.current.agents.values()),[n.current,n.current.revision]);Lre({stateRef:n,waitingSessions:ts,removedAgentIds:Ls,removedNodes:Os,bringBack:po}),qre({stateRef:n,waitingSessions:ts,live:ee});const xo=Hce({waitingSessions:ts,watchUnseen:xt,incidents:Nr}),ns=Gce({waitingSessions:ts,liveSince:ge,focusSession:Mr}),{loadNotifyPrefs:bo}=ns;return uue({loadAutoRestartPrefs:Ts,loadNotifyPrefs:bo,loadReportsPrefs:ft.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(Qse,{versionCheck:ye,welcome:Ne,desktopUpdate:fe,pause:J,monthly:O,announcements:xo,notify:ns,waitingSessions:ts,waitingCursorRef:es,focusSession:Mr,live:ee,now:bt,incidents:Nr}),Ar&&a.jsx(eae,{selected:Ar,now:bt,selectedIds:p,focusAgent:Qr,clearSelection:j}),a.jsxs("div",{className:"actions",children:[a.jsx(Cse,{sessionListOpen:x,toggleSessionList:b,usagePanelOpen:c,setUsagePanelOpen:d,setUsageHistoryOpen:lt,toggles:Zr.toggles}),a.jsx(Ase,{providers:Oe,accountsPanelOpen:N,toggleAccountsPanel:S,machinePanelOpen:h,setMachinePanelOpen:f,watchOn:Wt,watchUnseen:xt,setBrowserWatchOpen:wt,toggles:Zr.toggles}),a.jsx(Rse,{openSettings:H,onFeedback:()=>it.openFeedback(),watchUnseen:xt,setUsageHistoryOpen:lt,setBrowserWatchOpen:wt})]})]}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:Ui?`${Ui.label} removed from the board.`:""}),a.jsx(jae,{restart:Qn,versionCheck:ye,upgrade:Xe,oldNameNotice:Ye,rating:Ze,onFeedback:it.openFeedback,everConnected:ue,live:ee,paused:Z}),Ba(A)&&Oe.claude&&a.jsx(DZ,{leaving:A==="leaving",onReport:it.openFeedback,onRoster:Es.observe,onClose:()=>{Zr.accounts(),R()}}),x&&a.jsx(z7,{state:n.current,now:bt,selectedIds:p,onSelect:Yi,onClose:()=>{Zr.sessionList(),E()},removedIds:Ls,onBringBackAll:zi}),a.jsxs(aae,{canvasRef:_r,bubbling:Hi,dragging:Mn,trash:Ps,zoom:Vi,viewport:Gi,stateRef:n,peek:$c,children:[Ic===0&&(!ee&&ae?a.jsx(hse,{}):a.jsx(fse,{live:ee,everConnected:ue,providers:Oe,workspace:Be,onTour:Ie})),(gn.length>1||Xn.size>0)&&a.jsx(tae,{catBarRef:Jn,catBarOccluded:Cn,presentCats:gn,hiddenCats:Xn,toggleCat:Zn}),a.jsx(A7,{graph:ba,layout:$t,viewport:Gi,clicks:vo,drag:Rc,appearance:er,fm:jr,autoFit:wa,pause:J,stateRef:n,measuredRef:Xr,hiddenCats:Xn,now:bt,openTool:yt,focusAgent:Qr,requestClear:wo,setKeyHelpOpen:Mt})]}),Ba(q)&&a.jsx(D9,{state:n.current,now:bt,providers:Oe,incidents:Nr,liveSince:ge,leaving:q==="leaving",onClose:()=>{Zr.usage(),d(!1)}}),Ba(I)&&a.jsx(kV,{usageOpen:c,leaving:I==="leaving",onClose:()=>{Zr.machine(),f(!1)}}),o&&Ar?a.jsx(_se,{selected:Ar,now:bt,openTool:yt,setSummaryFor:ze,stateRef:n,removeSelectedNode:Ve,onClose:()=>{Zr.detail(),l(!1)}}):null,a.jsx(_le,{dialogs:it,welcome:Ne,desktopUpdate:fe,versionCheck:ye,restart:Qn,lanPairs:Tn,attention:Es,clearFlow:Na,watchBadge:nn,announcements:xo,appearance:er,providers:Oe,stateRef:n,agentCount:Ic,menus:D,sound:L,tones:C,customTones:G,notify:ns,fm:jr})]})}try{vz(window.localStorage)}catch{}const kue=V4.createRoot(document.getElementById("root"));kue.render(a.jsx(xue,{}));export{lse as a,rt as b,Ns as c,gt as d,ps as e,qe as f,Sue as g,vs as h,jue as i,a as j,lc as k,En as l,fJ as m,oa as n,io as o,ob as p,y as r,pr as s,dt as u};