ccdeck 3.28.1 → 3.29.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,298 @@
1
+ (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 l of s)if(l.type==="childList")for(const c of l.addedNodes)c.tagName==="LINK"&&c.rel==="modulepreload"&&r(c)}).observe(document,{childList:!0,subtree:!0});function n(s){const l={};return s.integrity&&(l.integrity=s.integrity),s.referrerPolicy&&(l.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?l.credentials="include":s.crossOrigin==="anonymous"?l.credentials="omit":l.credentials="same-origin",l}function r(s){if(s.ep)return;s.ep=!0;const l=n(s);fetch(s.href,l)}})();var th=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function tb(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Jp={exports:{}},Xc={},em={exports:{}},pt={};/**
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 A1;function kO(){if(A1)return pt;A1=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"),l=Symbol.for("react.provider"),c=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),f=Symbol.for("react.suspense"),p=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),m=Symbol.iterator;function y(F){return F===null||typeof F!="object"?null:(F=m&&F[m]||F["@@iterator"],typeof F=="function"?F:null)}var v={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},S=Object.assign,b={};function _(F,G,re){this.props=F,this.context=G,this.refs=b,this.updater=re||v}_.prototype.isReactComponent={},_.prototype.setState=function(F,G){if(typeof F!="object"&&typeof F!="function"&&F!=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,F,G,"setState")},_.prototype.forceUpdate=function(F){this.updater.enqueueForceUpdate(this,F,"forceUpdate")};function k(){}k.prototype=_.prototype;function j(F,G,re){this.props=F,this.context=G,this.refs=b,this.updater=re||v}var E=j.prototype=new k;E.constructor=j,S(E,_.prototype),E.isPureReactComponent=!0;var C=Array.isArray,R=Object.prototype.hasOwnProperty,I={current:null},O={key:!0,ref:!0,__self:!0,__source:!0};function H(F,G,re){var U,Y={},z=null,ie=null;if(G!=null)for(U in G.ref!==void 0&&(ie=G.ref),G.key!==void 0&&(z=""+G.key),G)R.call(G,U)&&!O.hasOwnProperty(U)&&(Y[U]=G[U]);var le=arguments.length-2;if(le===1)Y.children=re;else if(1<le){for(var ge=Array(le),Ne=0;Ne<le;Ne++)ge[Ne]=arguments[Ne+2];Y.children=ge}if(F&&F.defaultProps)for(U in le=F.defaultProps,le)Y[U]===void 0&&(Y[U]=le[U]);return{$$typeof:e,type:F,key:z,ref:ie,props:Y,_owner:I.current}}function q(F,G){return{$$typeof:e,type:F.type,key:G,ref:F.ref,props:F.props,_owner:F._owner}}function $(F){return typeof F=="object"&&F!==null&&F.$$typeof===e}function V(F){var G={"=":"=0",":":"=2"};return"$"+F.replace(/[=:]/g,function(re){return G[re]})}var ne=/\/+/g;function ee(F,G){return typeof F=="object"&&F!==null&&F.key!=null?V(""+F.key):G.toString(36)}function M(F,G,re,U,Y){var z=typeof F;(z==="undefined"||z==="boolean")&&(F=null);var ie=!1;if(F===null)ie=!0;else switch(z){case"string":case"number":ie=!0;break;case"object":switch(F.$$typeof){case e:case t:ie=!0}}if(ie)return ie=F,Y=Y(ie),F=U===""?"."+ee(ie,0):U,C(Y)?(re="",F!=null&&(re=F.replace(ne,"$&/")+"/"),M(Y,G,re,"",function(Ne){return Ne})):Y!=null&&($(Y)&&(Y=q(Y,re+(!Y.key||ie&&ie.key===Y.key?"":(""+Y.key).replace(ne,"$&/")+"/")+F)),G.push(Y)),1;if(ie=0,U=U===""?".":U+":",C(F))for(var le=0;le<F.length;le++){z=F[le];var ge=U+ee(z,le);ie+=M(z,G,re,ge,Y)}else if(ge=y(F),typeof ge=="function")for(F=ge.call(F),le=0;!(z=F.next()).done;)z=z.value,ge=U+ee(z,le++),ie+=M(z,G,re,ge,Y);else if(z==="object")throw G=String(F),Error("Objects are not valid as a React child (found: "+(G==="[object Object]"?"object with keys {"+Object.keys(F).join(", ")+"}":G)+"). If you meant to render a collection of children, use an array instead.");return ie}function Z(F,G,re){if(F==null)return F;var U=[],Y=0;return M(F,U,"","",function(z){return G.call(re,z,Y++)}),U}function K(F){if(F._status===-1){var G=F._result;G=G(),G.then(function(re){(F._status===0||F._status===-1)&&(F._status=1,F._result=re)},function(re){(F._status===0||F._status===-1)&&(F._status=2,F._result=re)}),F._status===-1&&(F._status=0,F._result=G)}if(F._status===1)return F._result.default;throw F._result}var D={current:null},P={transition:null},B={ReactCurrentDispatcher:D,ReactCurrentBatchConfig:P,ReactCurrentOwner:I};function W(){throw Error("act(...) is not supported in production builds of React.")}return pt.Children={map:Z,forEach:function(F,G,re){Z(F,function(){G.apply(this,arguments)},re)},count:function(F){var G=0;return Z(F,function(){G++}),G},toArray:function(F){return Z(F,function(G){return G})||[]},only:function(F){if(!$(F))throw Error("React.Children.only expected to receive a single React element child.");return F}},pt.Component=_,pt.Fragment=n,pt.Profiler=s,pt.PureComponent=j,pt.StrictMode=r,pt.Suspense=f,pt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=B,pt.act=W,pt.cloneElement=function(F,G,re){if(F==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+F+".");var U=S({},F.props),Y=F.key,z=F.ref,ie=F._owner;if(G!=null){if(G.ref!==void 0&&(z=G.ref,ie=I.current),G.key!==void 0&&(Y=""+G.key),F.type&&F.type.defaultProps)var le=F.type.defaultProps;for(ge in G)R.call(G,ge)&&!O.hasOwnProperty(ge)&&(U[ge]=G[ge]===void 0&&le!==void 0?le[ge]:G[ge])}var ge=arguments.length-2;if(ge===1)U.children=re;else if(1<ge){le=Array(ge);for(var Ne=0;Ne<ge;Ne++)le[Ne]=arguments[Ne+2];U.children=le}return{$$typeof:e,type:F.type,key:Y,ref:z,props:U,_owner:ie}},pt.createContext=function(F){return F={$$typeof:c,_currentValue:F,_currentValue2:F,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},F.Provider={$$typeof:l,_context:F},F.Consumer=F},pt.createElement=H,pt.createFactory=function(F){var G=H.bind(null,F);return G.type=F,G},pt.createRef=function(){return{current:null}},pt.forwardRef=function(F){return{$$typeof:u,render:F}},pt.isValidElement=$,pt.lazy=function(F){return{$$typeof:h,_payload:{_status:-1,_result:F},_init:K}},pt.memo=function(F,G){return{$$typeof:p,type:F,compare:G===void 0?null:G}},pt.startTransition=function(F){var G=P.transition;P.transition={};try{F()}finally{P.transition=G}},pt.unstable_act=W,pt.useCallback=function(F,G){return D.current.useCallback(F,G)},pt.useContext=function(F){return D.current.useContext(F)},pt.useDebugValue=function(){},pt.useDeferredValue=function(F){return D.current.useDeferredValue(F)},pt.useEffect=function(F,G){return D.current.useEffect(F,G)},pt.useId=function(){return D.current.useId()},pt.useImperativeHandle=function(F,G,re){return D.current.useImperativeHandle(F,G,re)},pt.useInsertionEffect=function(F,G){return D.current.useInsertionEffect(F,G)},pt.useLayoutEffect=function(F,G){return D.current.useLayoutEffect(F,G)},pt.useMemo=function(F,G){return D.current.useMemo(F,G)},pt.useReducer=function(F,G,re){return D.current.useReducer(F,G,re)},pt.useRef=function(F){return D.current.useRef(F)},pt.useState=function(F){return D.current.useState(F)},pt.useSyncExternalStore=function(F,G,re){return D.current.useSyncExternalStore(F,G,re)},pt.useTransition=function(){return D.current.useTransition()},pt.version="18.3.1",pt}var M1;function Pu(){return M1||(M1=1,em.exports=kO()),em.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 I1;function NO(){if(I1)return Xc;I1=1;var e=Pu(),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,l={key:!0,ref:!0,__self:!0,__source:!0};function c(u,f,p){var h,m={},y=null,v=null;p!==void 0&&(y=""+p),f.key!==void 0&&(y=""+f.key),f.ref!==void 0&&(v=f.ref);for(h in f)r.call(f,h)&&!l.hasOwnProperty(h)&&(m[h]=f[h]);if(u&&u.defaultProps)for(h in f=u.defaultProps,f)m[h]===void 0&&(m[h]=f[h]);return{$$typeof:t,type:u,key:y,ref:v,props:m,_owner:s.current}}return Xc.Fragment=n,Xc.jsx=c,Xc.jsxs=c,Xc}var $1;function SO(){return $1||($1=1,Jp.exports=NO()),Jp.exports}var o=SO(),nh={},tm={exports:{}},rr={},nm={exports:{}},rm={};/**
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 O1;function jO(){return O1||(O1=1,(function(e){function t(P,B){var W=P.length;P.push(B);e:for(;0<W;){var F=W-1>>>1,G=P[F];if(0<s(G,B))P[F]=B,P[W]=G,W=F;else break e}}function n(P){return P.length===0?null:P[0]}function r(P){if(P.length===0)return null;var B=P[0],W=P.pop();if(W!==B){P[0]=W;e:for(var F=0,G=P.length,re=G>>>1;F<re;){var U=2*(F+1)-1,Y=P[U],z=U+1,ie=P[z];if(0>s(Y,W))z<G&&0>s(ie,Y)?(P[F]=ie,P[z]=W,F=z):(P[F]=Y,P[U]=W,F=U);else if(z<G&&0>s(ie,W))P[F]=ie,P[z]=W,F=z;else break e}}return B}function s(P,B){var W=P.sortIndex-B.sortIndex;return W!==0?W:P.id-B.id}if(typeof performance=="object"&&typeof performance.now=="function"){var l=performance;e.unstable_now=function(){return l.now()}}else{var c=Date,u=c.now();e.unstable_now=function(){return c.now()-u}}var f=[],p=[],h=1,m=null,y=3,v=!1,S=!1,b=!1,_=typeof setTimeout=="function"?setTimeout:null,k=typeof clearTimeout=="function"?clearTimeout:null,j=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function E(P){for(var B=n(p);B!==null;){if(B.callback===null)r(p);else if(B.startTime<=P)r(p),B.sortIndex=B.expirationTime,t(f,B);else break;B=n(p)}}function C(P){if(b=!1,E(P),!S)if(n(f)!==null)S=!0,K(R);else{var B=n(p);B!==null&&D(C,B.startTime-P)}}function R(P,B){S=!1,b&&(b=!1,k(H),H=-1),v=!0;var W=y;try{for(E(B),m=n(f);m!==null&&(!(m.expirationTime>B)||P&&!V());){var F=m.callback;if(typeof F=="function"){m.callback=null,y=m.priorityLevel;var G=F(m.expirationTime<=B);B=e.unstable_now(),typeof G=="function"?m.callback=G:m===n(f)&&r(f),E(B)}else r(f);m=n(f)}if(m!==null)var re=!0;else{var U=n(p);U!==null&&D(C,U.startTime-B),re=!1}return re}finally{m=null,y=W,v=!1}}var I=!1,O=null,H=-1,q=5,$=-1;function V(){return!(e.unstable_now()-$<q)}function ne(){if(O!==null){var P=e.unstable_now();$=P;var B=!0;try{B=O(!0,P)}finally{B?ee():(I=!1,O=null)}}else I=!1}var ee;if(typeof j=="function")ee=function(){j(ne)};else if(typeof MessageChannel<"u"){var M=new MessageChannel,Z=M.port2;M.port1.onmessage=ne,ee=function(){Z.postMessage(null)}}else ee=function(){_(ne,0)};function K(P){O=P,I||(I=!0,ee())}function D(P,B){H=_(function(){P(e.unstable_now())},B)}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(P){P.callback=null},e.unstable_continueExecution=function(){S||v||(S=!0,K(R))},e.unstable_forceFrameRate=function(P){0>P||125<P?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):q=0<P?Math.floor(1e3/P):5},e.unstable_getCurrentPriorityLevel=function(){return y},e.unstable_getFirstCallbackNode=function(){return n(f)},e.unstable_next=function(P){switch(y){case 1:case 2:case 3:var B=3;break;default:B=y}var W=y;y=B;try{return P()}finally{y=W}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(P,B){switch(P){case 1:case 2:case 3:case 4:case 5:break;default:P=3}var W=y;y=P;try{return B()}finally{y=W}},e.unstable_scheduleCallback=function(P,B,W){var F=e.unstable_now();switch(typeof W=="object"&&W!==null?(W=W.delay,W=typeof W=="number"&&0<W?F+W:F):W=F,P){case 1:var G=-1;break;case 2:G=250;break;case 5:G=1073741823;break;case 4:G=1e4;break;default:G=5e3}return G=W+G,P={id:h++,callback:B,priorityLevel:P,startTime:W,expirationTime:G,sortIndex:-1},W>F?(P.sortIndex=W,t(p,P),n(f)===null&&P===n(p)&&(b?(k(H),H=-1):b=!0,D(C,W-F))):(P.sortIndex=G,t(f,P),S||v||(S=!0,K(R))),P},e.unstable_shouldYield=V,e.unstable_wrapCallback=function(P){var B=y;return function(){var W=y;y=B;try{return P.apply(this,arguments)}finally{y=W}}}})(rm)),rm}var L1;function _O(){return L1||(L1=1,nm.exports=jO()),nm.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 P1;function EO(){if(P1)return rr;P1=1;var e=Pu(),t=_O();function n(a){for(var i="https://reactjs.org/docs/error-decoder.html?invariant="+a,d=1;d<arguments.length;d++)i+="&args[]="+encodeURIComponent(arguments[d]);return"Minified React error #"+a+"; visit "+i+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,s={};function l(a,i){c(a,i),c(a+"Capture",i)}function c(a,i){for(s[a]=i,a=0;a<i.length;a++)r.add(i[a])}var u=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),f=Object.prototype.hasOwnProperty,p=/^[: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]*$/,h={},m={};function y(a){return f.call(m,a)?!0:f.call(h,a)?!1:p.test(a)?m[a]=!0:(h[a]=!0,!1)}function v(a,i,d,g){if(d!==null&&d.type===0)return!1;switch(typeof i){case"function":case"symbol":return!0;case"boolean":return g?!1:d!==null?!d.acceptsBooleans:(a=a.toLowerCase().slice(0,5),a!=="data-"&&a!=="aria-");default:return!1}}function S(a,i,d,g){if(i===null||typeof i>"u"||v(a,i,d,g))return!0;if(g)return!1;if(d!==null)switch(d.type){case 3:return!i;case 4:return i===!1;case 5:return isNaN(i);case 6:return isNaN(i)||1>i}return!1}function b(a,i,d,g,x,N,L){this.acceptsBooleans=i===2||i===3||i===4,this.attributeName=g,this.attributeNamespace=x,this.mustUseProperty=d,this.propertyName=a,this.type=i,this.sanitizeURL=N,this.removeEmptyString=L}var _={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(a){_[a]=new b(a,0,!1,a,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(a){var i=a[0];_[i]=new b(i,1,!1,a[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(a){_[a]=new b(a,2,!1,a.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(a){_[a]=new b(a,2,!1,a,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(a){_[a]=new b(a,3,!1,a.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(a){_[a]=new b(a,3,!0,a,null,!1,!1)}),["capture","download"].forEach(function(a){_[a]=new b(a,4,!1,a,null,!1,!1)}),["cols","rows","size","span"].forEach(function(a){_[a]=new b(a,6,!1,a,null,!1,!1)}),["rowSpan","start"].forEach(function(a){_[a]=new b(a,5,!1,a.toLowerCase(),null,!1,!1)});var k=/[\-:]([a-z])/g;function j(a){return a[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(a){var i=a.replace(k,j);_[i]=new b(i,1,!1,a,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(a){var i=a.replace(k,j);_[i]=new b(i,1,!1,a,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(a){var i=a.replace(k,j);_[i]=new b(i,1,!1,a,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(a){_[a]=new b(a,1,!1,a.toLowerCase(),null,!1,!1)}),_.xlinkHref=new b("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(a){_[a]=new b(a,1,!1,a.toLowerCase(),null,!0,!0)});function E(a,i,d,g){var x=_.hasOwnProperty(i)?_[i]:null;(x!==null?x.type!==0:g||!(2<i.length)||i[0]!=="o"&&i[0]!=="O"||i[1]!=="n"&&i[1]!=="N")&&(S(i,d,x,g)&&(d=null),g||x===null?y(i)&&(d===null?a.removeAttribute(i):a.setAttribute(i,""+d)):x.mustUseProperty?a[x.propertyName]=d===null?x.type===3?!1:"":d:(i=x.attributeName,g=x.attributeNamespace,d===null?a.removeAttribute(i):(x=x.type,d=x===3||x===4&&d===!0?"":""+d,g?a.setAttributeNS(g,i,d):a.setAttribute(i,d))))}var C=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,R=Symbol.for("react.element"),I=Symbol.for("react.portal"),O=Symbol.for("react.fragment"),H=Symbol.for("react.strict_mode"),q=Symbol.for("react.profiler"),$=Symbol.for("react.provider"),V=Symbol.for("react.context"),ne=Symbol.for("react.forward_ref"),ee=Symbol.for("react.suspense"),M=Symbol.for("react.suspense_list"),Z=Symbol.for("react.memo"),K=Symbol.for("react.lazy"),D=Symbol.for("react.offscreen"),P=Symbol.iterator;function B(a){return a===null||typeof a!="object"?null:(a=P&&a[P]||a["@@iterator"],typeof a=="function"?a:null)}var W=Object.assign,F;function G(a){if(F===void 0)try{throw Error()}catch(d){var i=d.stack.trim().match(/\n( *(at )?)/);F=i&&i[1]||""}return`
34
+ `+F+a}var re=!1;function U(a,i){if(!a||re)return"";re=!0;var d=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(i)if(i=function(){throw Error()},Object.defineProperty(i.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(i,[])}catch(we){var g=we}Reflect.construct(a,[],i)}else{try{i.call()}catch(we){g=we}a.call(i.prototype)}else{try{throw Error()}catch(we){g=we}a()}}catch(we){if(we&&g&&typeof we.stack=="string"){for(var x=we.stack.split(`
35
+ `),N=g.stack.split(`
36
+ `),L=x.length-1,J=N.length-1;1<=L&&0<=J&&x[L]!==N[J];)J--;for(;1<=L&&0<=J;L--,J--)if(x[L]!==N[J]){if(L!==1||J!==1)do if(L--,J--,0>J||x[L]!==N[J]){var ae=`
37
+ `+x[L].replace(" at new "," at ");return a.displayName&&ae.includes("<anonymous>")&&(ae=ae.replace("<anonymous>",a.displayName)),ae}while(1<=L&&0<=J);break}}}finally{re=!1,Error.prepareStackTrace=d}return(a=a?a.displayName||a.name:"")?G(a):""}function Y(a){switch(a.tag){case 5:return G(a.type);case 16:return G("Lazy");case 13:return G("Suspense");case 19:return G("SuspenseList");case 0:case 2:case 15:return a=U(a.type,!1),a;case 11:return a=U(a.type.render,!1),a;case 1:return a=U(a.type,!0),a;default:return""}}function z(a){if(a==null)return null;if(typeof a=="function")return a.displayName||a.name||null;if(typeof a=="string")return a;switch(a){case O:return"Fragment";case I:return"Portal";case q:return"Profiler";case H:return"StrictMode";case ee:return"Suspense";case M:return"SuspenseList"}if(typeof a=="object")switch(a.$$typeof){case V:return(a.displayName||"Context")+".Consumer";case $:return(a._context.displayName||"Context")+".Provider";case ne:var i=a.render;return a=a.displayName,a||(a=i.displayName||i.name||"",a=a!==""?"ForwardRef("+a+")":"ForwardRef"),a;case Z:return i=a.displayName||null,i!==null?i:z(a.type)||"Memo";case K:i=a._payload,a=a._init;try{return z(a(i))}catch{}}return null}function ie(a){var i=a.type;switch(a.tag){case 24:return"Cache";case 9:return(i.displayName||"Context")+".Consumer";case 10:return(i._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return a=i.render,a=a.displayName||a.name||"",i.displayName||(a!==""?"ForwardRef("+a+")":"ForwardRef");case 7:return"Fragment";case 5:return i;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return z(i);case 8:return i===H?"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 i=="function")return i.displayName||i.name||null;if(typeof i=="string")return i}return null}function le(a){switch(typeof a){case"boolean":case"number":case"string":case"undefined":return a;case"object":return a;default:return""}}function ge(a){var i=a.type;return(a=a.nodeName)&&a.toLowerCase()==="input"&&(i==="checkbox"||i==="radio")}function Ne(a){var i=ge(a)?"checked":"value",d=Object.getOwnPropertyDescriptor(a.constructor.prototype,i),g=""+a[i];if(!a.hasOwnProperty(i)&&typeof d<"u"&&typeof d.get=="function"&&typeof d.set=="function"){var x=d.get,N=d.set;return Object.defineProperty(a,i,{configurable:!0,get:function(){return x.call(this)},set:function(L){g=""+L,N.call(this,L)}}),Object.defineProperty(a,i,{enumerable:d.enumerable}),{getValue:function(){return g},setValue:function(L){g=""+L},stopTracking:function(){a._valueTracker=null,delete a[i]}}}}function Ie(a){a._valueTracker||(a._valueTracker=Ne(a))}function Ge(a){if(!a)return!1;var i=a._valueTracker;if(!i)return!0;var d=i.getValue(),g="";return a&&(g=ge(a)?a.checked?"true":"false":a.value),a=g,a!==d?(i.setValue(a),!0):!1}function Pe(a){if(a=a||(typeof document<"u"?document:void 0),typeof a>"u")return null;try{return a.activeElement||a.body}catch{return a.body}}function Be(a,i){var d=i.checked;return W({},i,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:d??a._wrapperState.initialChecked})}function Te(a,i){var d=i.defaultValue==null?"":i.defaultValue,g=i.checked!=null?i.checked:i.defaultChecked;d=le(i.value!=null?i.value:d),a._wrapperState={initialChecked:g,initialValue:d,controlled:i.type==="checkbox"||i.type==="radio"?i.checked!=null:i.value!=null}}function st(a,i){i=i.checked,i!=null&&E(a,"checked",i,!1)}function de(a,i){st(a,i);var d=le(i.value),g=i.type;if(d!=null)g==="number"?(d===0&&a.value===""||a.value!=d)&&(a.value=""+d):a.value!==""+d&&(a.value=""+d);else if(g==="submit"||g==="reset"){a.removeAttribute("value");return}i.hasOwnProperty("value")?se(a,i.type,d):i.hasOwnProperty("defaultValue")&&se(a,i.type,le(i.defaultValue)),i.checked==null&&i.defaultChecked!=null&&(a.defaultChecked=!!i.defaultChecked)}function ue(a,i,d){if(i.hasOwnProperty("value")||i.hasOwnProperty("defaultValue")){var g=i.type;if(!(g!=="submit"&&g!=="reset"||i.value!==void 0&&i.value!==null))return;i=""+a._wrapperState.initialValue,d||i===a.value||(a.value=i),a.defaultValue=i}d=a.name,d!==""&&(a.name=""),a.defaultChecked=!!a._wrapperState.initialChecked,d!==""&&(a.name=d)}function se(a,i,d){(i!=="number"||Pe(a.ownerDocument)!==a)&&(d==null?a.defaultValue=""+a._wrapperState.initialValue:a.defaultValue!==""+d&&(a.defaultValue=""+d))}var be=Array.isArray;function Le(a,i,d,g){if(a=a.options,i){i={};for(var x=0;x<d.length;x++)i["$"+d[x]]=!0;for(d=0;d<a.length;d++)x=i.hasOwnProperty("$"+a[d].value),a[d].selected!==x&&(a[d].selected=x),x&&g&&(a[d].defaultSelected=!0)}else{for(d=""+le(d),i=null,x=0;x<a.length;x++){if(a[x].value===d){a[x].selected=!0,g&&(a[x].defaultSelected=!0);return}i!==null||a[x].disabled||(i=a[x])}i!==null&&(i.selected=!0)}}function ce(a,i){if(i.dangerouslySetInnerHTML!=null)throw Error(n(91));return W({},i,{value:void 0,defaultValue:void 0,children:""+a._wrapperState.initialValue})}function pe(a,i){var d=i.value;if(d==null){if(d=i.children,i=i.defaultValue,d!=null){if(i!=null)throw Error(n(92));if(be(d)){if(1<d.length)throw Error(n(93));d=d[0]}i=d}i==null&&(i=""),d=i}a._wrapperState={initialValue:le(d)}}function Ae(a,i){var d=le(i.value),g=le(i.defaultValue);d!=null&&(d=""+d,d!==a.value&&(a.value=d),i.defaultValue==null&&a.defaultValue!==d&&(a.defaultValue=d)),g!=null&&(a.defaultValue=""+g)}function fe(a){var i=a.textContent;i===a._wrapperState.initialValue&&i!==""&&i!==null&&(a.value=i)}function Se(a){switch(a){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(a,i){return a==null||a==="http://www.w3.org/1999/xhtml"?Se(i):a==="http://www.w3.org/2000/svg"&&i==="foreignObject"?"http://www.w3.org/1999/xhtml":a}var qe,ke=(function(a){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(i,d,g,x){MSApp.execUnsafeLocalFunction(function(){return a(i,d,g,x)})}:a})(function(a,i){if(a.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in a)a.innerHTML=i;else{for(qe=qe||document.createElement("div"),qe.innerHTML="<svg>"+i.valueOf().toString()+"</svg>",i=qe.firstChild;a.firstChild;)a.removeChild(a.firstChild);for(;i.firstChild;)a.appendChild(i.firstChild)}});function Re(a,i){if(i){var d=a.firstChild;if(d&&d===a.lastChild&&d.nodeType===3){d.nodeValue=i;return}}a.textContent=i}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},Fe=["Webkit","ms","Moz","O"];Object.keys(ze).forEach(function(a){Fe.forEach(function(i){i=i+a.charAt(0).toUpperCase()+a.substring(1),ze[i]=ze[a]})});function We(a,i,d){return i==null||typeof i=="boolean"||i===""?"":d||typeof i!="number"||i===0||ze.hasOwnProperty(a)&&ze[a]?(""+i).trim():i+"px"}function rt(a,i){a=a.style;for(var d in i)if(i.hasOwnProperty(d)){var g=d.indexOf("--")===0,x=We(d,i[d],g);d==="float"&&(d="cssFloat"),g?a.setProperty(d,x):a[d]=x}}var dt=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 ct(a,i){if(i){if(dt[a]&&(i.children!=null||i.dangerouslySetInnerHTML!=null))throw Error(n(137,a));if(i.dangerouslySetInnerHTML!=null){if(i.children!=null)throw Error(n(60));if(typeof i.dangerouslySetInnerHTML!="object"||!("__html"in i.dangerouslySetInnerHTML))throw Error(n(61))}if(i.style!=null&&typeof i.style!="object")throw Error(n(62))}}function yt(a,i){if(a.indexOf("-")===-1)return typeof i.is=="string";switch(a){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 Ot=null;function zt(a){return a=a.target||a.srcElement||window,a.correspondingUseElement&&(a=a.correspondingUseElement),a.nodeType===3?a.parentNode:a}var Xt=null,Dt=null,rn=null;function je(a){if(a=Lo(a)){if(typeof Xt!="function")throw Error(n(280));var i=a.stateNode;i&&(i=Ji(i),Xt(a.stateNode,a.type,i))}}function xt(a){Dt?rn?rn.push(a):rn=[a]:Dt=a}function bt(){if(Dt){var a=Dt,i=rn;if(rn=Dt=null,je(a),i)for(a=0;a<i.length;a++)je(i[a])}}function _n(a,i){return a(i)}function Ut(){}var Vn=!1;function Vt(a,i,d){if(Vn)return a(i,d);Vn=!0;try{return _n(a,i,d)}finally{Vn=!1,(Dt!==null||rn!==null)&&(Ut(),bt())}}function Lt(a,i){var d=a.stateNode;if(d===null)return null;var g=Ji(d);if(g===null)return null;d=g[i];e:switch(i){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(g=!g.disabled)||(a=a.type,g=!(a==="button"||a==="input"||a==="select"||a==="textarea")),a=!g;break e;default:a=!1}if(a)return null;if(d&&typeof d!="function")throw Error(n(231,i,typeof d));return d}var Zt=!1;if(u)try{var In={};Object.defineProperty(In,"passive",{get:function(){Zt=!0}}),window.addEventListener("test",In,In),window.removeEventListener("test",In,In)}catch{Zt=!1}function Hr(a,i,d,g,x,N,L,J,ae){var we=Array.prototype.slice.call(arguments,3);try{i.apply(d,we)}catch(Ce){this.onError(Ce)}}var xe=!1,lr=null,ks=!1,Wr=null,fa={onError:function(a){xe=!0,lr=a}};function Ns(a,i,d,g,x,N,L,J,ae){xe=!1,lr=null,Hr.apply(fa,arguments)}function xr(a,i,d,g,x,N,L,J,ae){if(Ns.apply(this,arguments),xe){if(xe){var we=lr;xe=!1,lr=null}else throw Error(n(198));ks||(ks=!0,Wr=we)}}function $n(a){var i=a,d=a;if(a.alternate)for(;i.return;)i=i.return;else{a=i;do i=a,(i.flags&4098)!==0&&(d=i.return),a=i.return;while(a)}return i.tag===3?d:null}function Hs(a){if(a.tag===13){var i=a.memoizedState;if(i===null&&(a=a.alternate,a!==null&&(i=a.memoizedState)),i!==null)return i.dehydrated}return null}function Q(a){if($n(a)!==a)throw Error(n(188))}function De(a){var i=a.alternate;if(!i){if(i=$n(a),i===null)throw Error(n(188));return i!==a?null:a}for(var d=a,g=i;;){var x=d.return;if(x===null)break;var N=x.alternate;if(N===null){if(g=x.return,g!==null){d=g;continue}break}if(x.child===N.child){for(N=x.child;N;){if(N===d)return Q(x),a;if(N===g)return Q(x),i;N=N.sibling}throw Error(n(188))}if(d.return!==g.return)d=x,g=N;else{for(var L=!1,J=x.child;J;){if(J===d){L=!0,d=x,g=N;break}if(J===g){L=!0,g=x,d=N;break}J=J.sibling}if(!L){for(J=N.child;J;){if(J===d){L=!0,d=N,g=x;break}if(J===g){L=!0,g=N,d=x;break}J=J.sibling}if(!L)throw Error(n(189))}}if(d.alternate!==g)throw Error(n(190))}if(d.tag!==3)throw Error(n(188));return d.stateNode.current===d?a:i}function et(a){return a=De(a),a!==null?Ue(a):null}function Ue(a){if(a.tag===5||a.tag===6)return a;for(a=a.child;a!==null;){var i=Ue(a);if(i!==null)return i;a=a.sibling}return null}var tt=t.unstable_scheduleCallback,wt=t.unstable_cancelCallback,gt=t.unstable_shouldYield,It=t.unstable_requestPaint,Rt=t.unstable_now,Qt=t.unstable_getCurrentPriorityLevel,Nt=t.unstable_ImmediatePriority,br=t.unstable_UserBlockingPriority,cr=t.unstable_NormalPriority,ki=t.unstable_LowPriority,ht=t.unstable_IdlePriority,ur=null,sn=null;function Vr(a){if(sn&&typeof sn.onCommitFiberRoot=="function")try{sn.onCommitFiberRoot(ur,a,void 0,(a.current.flags&128)===128)}catch{}}var Gn=Math.clz32?Math.clz32:Zu,Xu=Math.log,io=Math.LN2;function Zu(a){return a>>>=0,a===0?32:31-(Xu(a)/io|0)|0}var pa=64,Ni=4194304;function lo(a){switch(a&-a){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 a&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return a&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return a}}function Kn(a,i){var d=a.pendingLanes;if(d===0)return 0;var g=0,x=a.suspendedLanes,N=a.pingedLanes,L=d&268435455;if(L!==0){var J=L&~x;J!==0?g=lo(J):(N&=L,N!==0&&(g=lo(N)))}else L=d&~x,L!==0?g=lo(L):N!==0&&(g=lo(N));if(g===0)return 0;if(i!==0&&i!==g&&(i&x)===0&&(x=g&-g,N=i&-i,x>=N||x===16&&(N&4194240)!==0))return i;if((g&4)!==0&&(g|=d&16),i=a.entangledLanes,i!==0)for(a=a.entanglements,i&=g;0<i;)d=31-Gn(i),x=1<<d,g|=a[d],i&=~x;return g}function Zf(a,i){switch(a){case 1:case 2:case 4:return i+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 i+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 Si(a,i){for(var d=a.suspendedLanes,g=a.pingedLanes,x=a.expirationTimes,N=a.pendingLanes;0<N;){var L=31-Gn(N),J=1<<L,ae=x[L];ae===-1?((J&d)===0||(J&g)!==0)&&(x[L]=Zf(J,i)):ae<=i&&(a.expiredLanes|=J),N&=~J}}function co(a){return a=a.pendingLanes&-1073741825,a!==0?a:a&1073741824?1073741824:0}function ma(){var a=pa;return pa<<=1,(pa&4194240)===0&&(pa=64),a}function oc(a){for(var i=[],d=0;31>d;d++)i.push(a);return i}function uo(a,i,d){a.pendingLanes|=i,i!==536870912&&(a.suspendedLanes=0,a.pingedLanes=0),a=a.eventTimes,i=31-Gn(i),a[i]=d}function Qf(a,i){var d=a.pendingLanes&~i;a.pendingLanes=i,a.suspendedLanes=0,a.pingedLanes=0,a.expiredLanes&=i,a.mutableReadLanes&=i,a.entangledLanes&=i,i=a.entanglements;var g=a.eventTimes;for(a=a.expirationTimes;0<d;){var x=31-Gn(d),N=1<<x;i[x]=0,g[x]=-1,a[x]=-1,d&=~N}}function ic(a,i){var d=a.entangledLanes|=i;for(a=a.entanglements;d;){var g=31-Gn(d),x=1<<g;x&i|a[g]&i&&(a[g]|=i),d&=~x}}var ft=0;function Qu(a){return a&=-a,1<a?4<a?(a&268435455)!==0?16:536870912:4:1}var Ju,On,ho,ji,ed,lc=!1,fo=[],Gr=null,Kr=null,kr=null,ga=new Map,Ws=new Map,Yr=[],Jf="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 cc(a,i){switch(a){case"focusin":case"focusout":Gr=null;break;case"dragenter":case"dragleave":Kr=null;break;case"mouseover":case"mouseout":kr=null;break;case"pointerover":case"pointerout":ga.delete(i.pointerId);break;case"gotpointercapture":case"lostpointercapture":Ws.delete(i.pointerId)}}function po(a,i,d,g,x,N){return a===null||a.nativeEvent!==N?(a={blockedOn:i,domEventName:d,eventSystemFlags:g,nativeEvent:N,targetContainers:[x]},i!==null&&(i=Lo(i),i!==null&&On(i)),a):(a.eventSystemFlags|=g,i=a.targetContainers,x!==null&&i.indexOf(x)===-1&&i.push(x),a)}function uc(a,i,d,g,x){switch(i){case"focusin":return Gr=po(Gr,a,i,d,g,x),!0;case"dragenter":return Kr=po(Kr,a,i,d,g,x),!0;case"mouseover":return kr=po(kr,a,i,d,g,x),!0;case"pointerover":var N=x.pointerId;return ga.set(N,po(ga.get(N)||null,a,i,d,g,x)),!0;case"gotpointercapture":return N=x.pointerId,Ws.set(N,po(Ws.get(N)||null,a,i,d,g,x)),!0}return!1}function dc(a){var i=Cs(a.target);if(i!==null){var d=$n(i);if(d!==null){if(i=d.tag,i===13){if(i=Hs(d),i!==null){a.blockedOn=i,ed(a.priority,function(){ho(d)});return}}else if(i===3&&d.stateNode.current.memoizedState.isDehydrated){a.blockedOn=d.tag===3?d.stateNode.containerInfo:null;return}}}a.blockedOn=null}function _i(a){if(a.blockedOn!==null)return!1;for(var i=a.targetContainers;0<i.length;){var d=Ti(a.domEventName,a.eventSystemFlags,i[0],a.nativeEvent);if(d===null){d=a.nativeEvent;var g=new d.constructor(d.type,d);Ot=g,d.target.dispatchEvent(g),Ot=null}else return i=Lo(d),i!==null&&On(i),a.blockedOn=d,!1;i.shift()}return!0}function mo(a,i,d){_i(a)&&d.delete(i)}function td(){lc=!1,Gr!==null&&_i(Gr)&&(Gr=null),Kr!==null&&_i(Kr)&&(Kr=null),kr!==null&&_i(kr)&&(kr=null),ga.forEach(mo),Ws.forEach(mo)}function Ss(a,i){a.blockedOn===i&&(a.blockedOn=null,lc||(lc=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,td)))}function ya(a){function i(x){return Ss(x,a)}if(0<fo.length){Ss(fo[0],a);for(var d=1;d<fo.length;d++){var g=fo[d];g.blockedOn===a&&(g.blockedOn=null)}}for(Gr!==null&&Ss(Gr,a),Kr!==null&&Ss(Kr,a),kr!==null&&Ss(kr,a),ga.forEach(i),Ws.forEach(i),d=0;d<Yr.length;d++)g=Yr[d],g.blockedOn===a&&(g.blockedOn=null);for(;0<Yr.length&&(d=Yr[0],d.blockedOn===null);)dc(d),d.blockedOn===null&&Yr.shift()}var Vs=C.ReactCurrentBatchConfig,dr=!0;function ep(a,i,d,g){var x=ft,N=Vs.transition;Vs.transition=null;try{ft=1,Ei(a,i,d,g)}finally{ft=x,Vs.transition=N}}function nd(a,i,d,g){var x=ft,N=Vs.transition;Vs.transition=null;try{ft=4,Ei(a,i,d,g)}finally{ft=x,Vs.transition=N}}function Ei(a,i,d,g){if(dr){var x=Ti(a,i,d,g);if(x===null)Ki(a,i,g,Ci,d),cc(a,g);else if(uc(x,a,i,d,g))g.stopPropagation();else if(cc(a,g),i&4&&-1<Jf.indexOf(a)){for(;x!==null;){var N=Lo(x);if(N!==null&&Ju(N),N=Ti(a,i,d,g),N===null&&Ki(a,i,g,Ci,d),N===x)break;x=N}x!==null&&g.stopPropagation()}else Ki(a,i,g,null,d)}}var Ci=null;function Ti(a,i,d,g){if(Ci=null,a=zt(g),a=Cs(a),a!==null)if(i=$n(a),i===null)a=null;else if(d=i.tag,d===13){if(a=Hs(i),a!==null)return a;a=null}else if(d===3){if(i.stateNode.current.memoizedState.isDehydrated)return i.tag===3?i.stateNode.containerInfo:null;a=null}else i!==a&&(a=null);return Ci=a,null}function wa(a){switch(a){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(Qt()){case Nt:return 1;case br:return 4;case cr:case ki:return 16;case ht:return 536870912;default:return 16}default:return 16}}var js=null,Ri=null,En=null;function go(){if(En)return En;var a,i=Ri,d=i.length,g,x="value"in js?js.value:js.textContent,N=x.length;for(a=0;a<d&&i[a]===x[a];a++);var L=d-a;for(g=1;g<=L&&i[d-g]===x[N-g];g++);return En=x.slice(a,1<g?1-g:void 0)}function Ai(a){var i=a.keyCode;return"charCode"in a?(a=a.charCode,a===0&&i===13&&(a=13)):a=i,a===10&&(a=13),32<=a||a===13?a:0}function va(){return!0}function Jt(){return!1}function Ln(a){function i(d,g,x,N,L){this._reactName=d,this._targetInst=x,this.type=g,this.nativeEvent=N,this.target=L,this.currentTarget=null;for(var J in a)a.hasOwnProperty(J)&&(d=a[J],this[J]=d?d(N):N[J]);return this.isDefaultPrevented=(N.defaultPrevented!=null?N.defaultPrevented:N.returnValue===!1)?va:Jt,this.isPropagationStopped=Jt,this}return W(i.prototype,{preventDefault:function(){this.defaultPrevented=!0;var d=this.nativeEvent;d&&(d.preventDefault?d.preventDefault():typeof d.returnValue!="unknown"&&(d.returnValue=!1),this.isDefaultPrevented=va)},stopPropagation:function(){var d=this.nativeEvent;d&&(d.stopPropagation?d.stopPropagation():typeof d.cancelBubble!="unknown"&&(d.cancelBubble=!0),this.isPropagationStopped=va)},persist:function(){},isPersistent:va}),i}var Pn={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(a){return a.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},xa=Ln(Pn),ba=W({},Pn,{view:0,detail:0}),tp=Ln(ba),Nr,ka,yo,Mi=W({},ba,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:gc,button:0,buttons:0,relatedTarget:function(a){return a.relatedTarget===void 0?a.fromElement===a.srcElement?a.toElement:a.fromElement:a.relatedTarget},movementX:function(a){return"movementX"in a?a.movementX:(a!==yo&&(yo&&a.type==="mousemove"?(Nr=a.screenX-yo.screenX,ka=a.screenY-yo.screenY):ka=Nr=0,yo=a),Nr)},movementY:function(a){return"movementY"in a?a.movementY:ka}}),hc=Ln(Mi),rd=W({},Mi,{dataTransfer:0}),Na=Ln(rd),sd=W({},ba,{relatedTarget:0}),Ii=Ln(sd),wo=W({},Pn,{animationName:0,elapsedTime:0,pseudoElement:0}),fc=Ln(wo),ad=W({},Pn,{clipboardData:function(a){return"clipboardData"in a?a.clipboardData:window.clipboardData}}),od=Ln(ad),id=W({},Pn,{data:0}),pc=Ln(id),Gt={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},$i={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"},Oi={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function mc(a){var i=this.nativeEvent;return i.getModifierState?i.getModifierState(a):(a=Oi[a])?!!i[a]:!1}function gc(){return mc}var Sa=W({},ba,{key:function(a){if(a.key){var i=Gt[a.key]||a.key;if(i!=="Unidentified")return i}return a.type==="keypress"?(a=Ai(a),a===13?"Enter":String.fromCharCode(a)):a.type==="keydown"||a.type==="keyup"?$i[a.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:gc,charCode:function(a){return a.type==="keypress"?Ai(a):0},keyCode:function(a){return a.type==="keydown"||a.type==="keyup"?a.keyCode:0},which:function(a){return a.type==="keypress"?Ai(a):a.type==="keydown"||a.type==="keyup"?a.keyCode:0}}),ld=Ln(Sa),vo=W({},Mi,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),cd=Ln(vo),Li=W({},ba,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:gc}),np=Ln(Li),xo=W({},Pn,{propertyName:0,elapsedTime:0,pseudoElement:0}),yc=Ln(xo),Pi=W({},Mi,{deltaX:function(a){return"deltaX"in a?a.deltaX:"wheelDeltaX"in a?-a.wheelDeltaX:0},deltaY:function(a){return"deltaY"in a?a.deltaY:"wheelDeltaY"in a?-a.wheelDeltaY:"wheelDelta"in a?-a.wheelDelta:0},deltaZ:0,deltaMode:0}),rp=Ln(Pi),Gs=[9,13,27,32],Di=u&&"CompositionEvent"in window,Ks=null;u&&"documentMode"in document&&(Ks=document.documentMode);var Fi=u&&"TextEvent"in window&&!Ks,ud=u&&(!Di||Ks&&8<Ks&&11>=Ks),dd=" ",Xr=!1;function hd(a,i){switch(a){case"keyup":return Gs.indexOf(i.keyCode)!==-1;case"keydown":return i.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function wc(a){return a=a.detail,typeof a=="object"&&"data"in a?a.data:null}var ja=!1;function fd(a,i){switch(a){case"compositionend":return wc(i);case"keypress":return i.which!==32?null:(Xr=!0,dd);case"textInput":return a=i.data,a===dd&&Xr?null:a;default:return null}}function sp(a,i){if(ja)return a==="compositionend"||!Di&&hd(a,i)?(a=go(),En=Ri=js=null,ja=!1,a):null;switch(a){case"paste":return null;case"keypress":if(!(i.ctrlKey||i.altKey||i.metaKey)||i.ctrlKey&&i.altKey){if(i.char&&1<i.char.length)return i.char;if(i.which)return String.fromCharCode(i.which)}return null;case"compositionend":return ud&&i.locale!=="ko"?null:i.data;default:return null}}var ap={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 pd(a){var i=a&&a.nodeName&&a.nodeName.toLowerCase();return i==="input"?!!ap[a.type]:i==="textarea"}function md(a,i,d,g){xt(g),i=Yi(i,"onChange"),0<i.length&&(d=new xa("onChange","change",null,d,g),a.push({event:d,listeners:i}))}var bo=null,ko=null;function hr(a){wd(a,0)}function Zr(a){var i=ts(a);if(Ge(i))return a}function No(a,i){if(a==="change")return i}var So=!1;if(u){var qi;if(u){var Bi="oninput"in document;if(!Bi){var _a=document.createElement("div");_a.setAttribute("oninput","return;"),Bi=typeof _a.oninput=="function"}qi=Bi}else qi=!1;So=qi&&(!document.documentMode||9<document.documentMode)}function vc(){bo&&(bo.detachEvent("onpropertychange",zi),ko=bo=null)}function zi(a){if(a.propertyName==="value"&&Zr(ko)){var i=[];md(i,ko,a,zt(a)),Vt(hr,i)}}function Ys(a,i,d){a==="focusin"?(vc(),bo=i,ko=d,bo.attachEvent("onpropertychange",zi)):a==="focusout"&&vc()}function gd(a){if(a==="selectionchange"||a==="keyup"||a==="keydown")return Zr(ko)}function Yn(a,i){if(a==="click")return Zr(i)}function xc(a,i){if(a==="input"||a==="change")return Zr(i)}function bc(a,i){return a===i&&(a!==0||1/a===1/i)||a!==a&&i!==i}var Xn=typeof Object.is=="function"?Object.is:bc;function _s(a,i){if(Xn(a,i))return!0;if(typeof a!="object"||a===null||typeof i!="object"||i===null)return!1;var d=Object.keys(a),g=Object.keys(i);if(d.length!==g.length)return!1;for(g=0;g<d.length;g++){var x=d[g];if(!f.call(i,x)||!Xn(a[x],i[x]))return!1}return!0}function Ui(a){for(;a&&a.firstChild;)a=a.firstChild;return a}function kc(a,i){var d=Ui(a);a=0;for(var g;d;){if(d.nodeType===3){if(g=a+d.textContent.length,a<=i&&g>=i)return{node:d,offset:i-a};a=g}e:{for(;d;){if(d.nextSibling){d=d.nextSibling;break e}d=d.parentNode}d=void 0}d=Ui(d)}}function Hi(a,i){return a&&i?a===i?!0:a&&a.nodeType===3?!1:i&&i.nodeType===3?Hi(a,i.parentNode):"contains"in a?a.contains(i):a.compareDocumentPosition?!!(a.compareDocumentPosition(i)&16):!1:!1}function Wi(){for(var a=window,i=Pe();i instanceof a.HTMLIFrameElement;){try{var d=typeof i.contentWindow.location.href=="string"}catch{d=!1}if(d)a=i.contentWindow;else break;i=Pe(a.document)}return i}function Nc(a){var i=a&&a.nodeName&&a.nodeName.toLowerCase();return i&&(i==="input"&&(a.type==="text"||a.type==="search"||a.type==="tel"||a.type==="url"||a.type==="password")||i==="textarea"||a.contentEditable==="true")}function Xs(a){var i=Wi(),d=a.focusedElem,g=a.selectionRange;if(i!==d&&d&&d.ownerDocument&&Hi(d.ownerDocument.documentElement,d)){if(g!==null&&Nc(d)){if(i=g.start,a=g.end,a===void 0&&(a=i),"selectionStart"in d)d.selectionStart=i,d.selectionEnd=Math.min(a,d.value.length);else if(a=(i=d.ownerDocument||document)&&i.defaultView||window,a.getSelection){a=a.getSelection();var x=d.textContent.length,N=Math.min(g.start,x);g=g.end===void 0?N:Math.min(g.end,x),!a.extend&&N>g&&(x=g,g=N,N=x),x=kc(d,N);var L=kc(d,g);x&&L&&(a.rangeCount!==1||a.anchorNode!==x.node||a.anchorOffset!==x.offset||a.focusNode!==L.node||a.focusOffset!==L.offset)&&(i=i.createRange(),i.setStart(x.node,x.offset),a.removeAllRanges(),N>g?(a.addRange(i),a.extend(L.node,L.offset)):(i.setEnd(L.node,L.offset),a.addRange(i)))}}for(i=[],a=d;a=a.parentNode;)a.nodeType===1&&i.push({element:a,left:a.scrollLeft,top:a.scrollTop});for(typeof d.focus=="function"&&d.focus(),d=0;d<i.length;d++)a=i[d],a.element.scrollLeft=a.left,a.element.scrollTop=a.top}}var Sc=u&&"documentMode"in document&&11>=document.documentMode,Zs=null,Qs=null,Ea=null,Ca=!1;function Sr(a,i,d){var g=d.window===d?d.document:d.nodeType===9?d:d.ownerDocument;Ca||Zs==null||Zs!==Pe(g)||(g=Zs,"selectionStart"in g&&Nc(g)?g={start:g.selectionStart,end:g.selectionEnd}:(g=(g.ownerDocument&&g.ownerDocument.defaultView||window).getSelection(),g={anchorNode:g.anchorNode,anchorOffset:g.anchorOffset,focusNode:g.focusNode,focusOffset:g.focusOffset}),Ea&&_s(Ea,g)||(Ea=g,g=Yi(Qs,"onSelect"),0<g.length&&(i=new xa("onSelect","select",null,i,d),a.push({event:i,listeners:g}),i.target=Zs)))}function Ta(a,i){var d={};return d[a.toLowerCase()]=i.toLowerCase(),d["Webkit"+a]="webkit"+i,d["Moz"+a]="moz"+i,d}var Ra={animationend:Ta("Animation","AnimationEnd"),animationiteration:Ta("Animation","AnimationIteration"),animationstart:Ta("Animation","AnimationStart"),transitionend:Ta("Transition","TransitionEnd")},Vi={},jc={};u&&(jc=document.createElement("div").style,"AnimationEvent"in window||(delete Ra.animationend.animation,delete Ra.animationiteration.animation,delete Ra.animationstart.animation),"TransitionEvent"in window||delete Ra.transitionend.transition);function Gi(a){if(Vi[a])return Vi[a];if(!Ra[a])return a;var i=Ra[a],d;for(d in i)if(i.hasOwnProperty(d)&&d in jc)return Vi[a]=i[d];return a}var Kt=Gi("animationend"),_c=Gi("animationiteration"),jo=Gi("animationstart"),jr=Gi("transitionend"),Js=new Map,Aa="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 _r(a,i){Js.set(a,i),l(i,[a])}for(var _o=0;_o<Aa.length;_o++){var Er=Aa[_o],Eo=Er.toLowerCase(),yd=Er[0].toUpperCase()+Er.slice(1);_r(Eo,"on"+yd)}_r(Kt,"onAnimationEnd"),_r(_c,"onAnimationIteration"),_r(jo,"onAnimationStart"),_r("dblclick","onDoubleClick"),_r("focusin","onFocus"),_r("focusout","onBlur"),_r(jr,"onTransitionEnd"),c("onMouseEnter",["mouseout","mouseover"]),c("onMouseLeave",["mouseout","mouseover"]),c("onPointerEnter",["pointerout","pointerover"]),c("onPointerLeave",["pointerout","pointerover"]),l("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),l("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),l("onBeforeInput",["compositionend","keypress","textInput","paste"]),l("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),l("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),l("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var Co="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(" "),op=new Set("cancel close invalid load scroll toggle".split(" ").concat(Co));function To(a,i,d){var g=a.type||"unknown-event";a.currentTarget=d,xr(g,i,void 0,a),a.currentTarget=null}function wd(a,i){i=(i&4)!==0;for(var d=0;d<a.length;d++){var g=a[d],x=g.event;g=g.listeners;e:{var N=void 0;if(i)for(var L=g.length-1;0<=L;L--){var J=g[L],ae=J.instance,we=J.currentTarget;if(J=J.listener,ae!==N&&x.isPropagationStopped())break e;To(x,J,we),N=ae}else for(L=0;L<g.length;L++){if(J=g[L],ae=J.instance,we=J.currentTarget,J=J.listener,ae!==N&&x.isPropagationStopped())break e;To(x,J,we),N=ae}}}if(ks)throw a=Wr,ks=!1,Wr=null,a}function $t(a,i){var d=i[Qi];d===void 0&&(d=i[Qi]=new Set);var g=a+"__bubble";d.has(g)||(Ec(i,a,2,!1),d.add(g))}function Ro(a,i,d){var g=0;i&&(g|=4),Ec(d,a,g,i)}var fr="_reactListening"+Math.random().toString(36).slice(2);function Qr(a){if(!a[fr]){a[fr]=!0,r.forEach(function(d){d!=="selectionchange"&&(op.has(d)||Ro(d,!1,a),Ro(d,!0,a))});var i=a.nodeType===9?a:a.ownerDocument;i===null||i[fr]||(i[fr]=!0,Ro("selectionchange",!1,i))}}function Ec(a,i,d,g){switch(wa(i)){case 1:var x=ep;break;case 4:x=nd;break;default:x=Ei}d=x.bind(null,i,d,a),x=void 0,!Zt||i!=="touchstart"&&i!=="touchmove"&&i!=="wheel"||(x=!0),g?x!==void 0?a.addEventListener(i,d,{capture:!0,passive:x}):a.addEventListener(i,d,!0):x!==void 0?a.addEventListener(i,d,{passive:x}):a.addEventListener(i,d,!1)}function Ki(a,i,d,g,x){var N=g;if((i&1)===0&&(i&2)===0&&g!==null)e:for(;;){if(g===null)return;var L=g.tag;if(L===3||L===4){var J=g.stateNode.containerInfo;if(J===x||J.nodeType===8&&J.parentNode===x)break;if(L===4)for(L=g.return;L!==null;){var ae=L.tag;if((ae===3||ae===4)&&(ae=L.stateNode.containerInfo,ae===x||ae.nodeType===8&&ae.parentNode===x))return;L=L.return}for(;J!==null;){if(L=Cs(J),L===null)return;if(ae=L.tag,ae===5||ae===6){g=N=L;continue e}J=J.parentNode}}g=g.return}Vt(function(){var we=N,Ce=zt(d),Me=[];e:{var Ee=Js.get(a);if(Ee!==void 0){var He=xa,Xe=a;switch(a){case"keypress":if(Ai(d)===0)break e;case"keydown":case"keyup":He=ld;break;case"focusin":Xe="focus",He=Ii;break;case"focusout":Xe="blur",He=Ii;break;case"beforeblur":case"afterblur":He=Ii;break;case"click":if(d.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":He=hc;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":He=Na;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":He=np;break;case Kt:case _c:case jo:He=fc;break;case jr:He=yc;break;case"scroll":He=tp;break;case"wheel":He=rp;break;case"copy":case"cut":case"paste":He=od;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":He=cd}var Qe=(i&4)!==0,Yt=!Qe&&a==="scroll",he=Qe?Ee!==null?Ee+"Capture":null:Ee;Qe=[];for(var oe=we,me;oe!==null;){me=oe;var $e=me.stateNode;if(me.tag===5&&$e!==null&&(me=$e,he!==null&&($e=Lt(oe,he),$e!=null&&Qe.push(Ma(oe,$e,me)))),Yt)break;oe=oe.return}0<Qe.length&&(Ee=new He(Ee,Xe,null,d,Ce),Me.push({event:Ee,listeners:Qe}))}}if((i&7)===0){e:{if(Ee=a==="mouseover"||a==="pointerover",He=a==="mouseout"||a==="pointerout",Ee&&d!==Ot&&(Xe=d.relatedTarget||d.fromElement)&&(Cs(Xe)||Xe[mn]))break e;if((He||Ee)&&(Ee=Ce.window===Ce?Ce:(Ee=Ce.ownerDocument)?Ee.defaultView||Ee.parentWindow:window,He?(Xe=d.relatedTarget||d.toElement,He=we,Xe=Xe?Cs(Xe):null,Xe!==null&&(Yt=$n(Xe),Xe!==Yt||Xe.tag!==5&&Xe.tag!==6)&&(Xe=null)):(He=null,Xe=we),He!==Xe)){if(Qe=hc,$e="onMouseLeave",he="onMouseEnter",oe="mouse",(a==="pointerout"||a==="pointerover")&&(Qe=cd,$e="onPointerLeave",he="onPointerEnter",oe="pointer"),Yt=He==null?Ee:ts(He),me=Xe==null?Ee:ts(Xe),Ee=new Qe($e,oe+"leave",He,d,Ce),Ee.target=Yt,Ee.relatedTarget=me,$e=null,Cs(Ce)===we&&(Qe=new Qe(he,oe+"enter",Xe,d,Ce),Qe.target=me,Qe.relatedTarget=Yt,$e=Qe),Yt=$e,He&&Xe)t:{for(Qe=He,he=Xe,oe=0,me=Qe;me;me=Ia(me))oe++;for(me=0,$e=he;$e;$e=Ia($e))me++;for(;0<oe-me;)Qe=Ia(Qe),oe--;for(;0<me-oe;)he=Ia(he),me--;for(;oe--;){if(Qe===he||he!==null&&Qe===he.alternate)break t;Qe=Ia(Qe),he=Ia(he)}Qe=null}else Qe=null;He!==null&&Ao(Me,Ee,He,Qe,!1),Xe!==null&&Yt!==null&&Ao(Me,Yt,Xe,Qe,!0)}}e:{if(Ee=we?ts(we):window,He=Ee.nodeName&&Ee.nodeName.toLowerCase(),He==="select"||He==="input"&&Ee.type==="file")var Je=No;else if(pd(Ee))if(So)Je=xc;else{Je=gd;var at=Ys}else(He=Ee.nodeName)&&He.toLowerCase()==="input"&&(Ee.type==="checkbox"||Ee.type==="radio")&&(Je=Yn);if(Je&&(Je=Je(a,we))){md(Me,Je,d,Ce);break e}at&&at(a,Ee,we),a==="focusout"&&(at=Ee._wrapperState)&&at.controlled&&Ee.type==="number"&&se(Ee,"number",Ee.value)}switch(at=we?ts(we):window,a){case"focusin":(pd(at)||at.contentEditable==="true")&&(Zs=at,Qs=we,Ea=null);break;case"focusout":Ea=Qs=Zs=null;break;case"mousedown":Ca=!0;break;case"contextmenu":case"mouseup":case"dragend":Ca=!1,Sr(Me,d,Ce);break;case"selectionchange":if(Sc)break;case"keydown":case"keyup":Sr(Me,d,Ce)}var ot;if(Di)e:{switch(a){case"compositionstart":var lt="onCompositionStart";break e;case"compositionend":lt="onCompositionEnd";break e;case"compositionupdate":lt="onCompositionUpdate";break e}lt=void 0}else ja?hd(a,d)&&(lt="onCompositionEnd"):a==="keydown"&&d.keyCode===229&&(lt="onCompositionStart");lt&&(ud&&d.locale!=="ko"&&(ja||lt!=="onCompositionStart"?lt==="onCompositionEnd"&&ja&&(ot=go()):(js=Ce,Ri="value"in js?js.value:js.textContent,ja=!0)),at=Yi(we,lt),0<at.length&&(lt=new pc(lt,a,null,d,Ce),Me.push({event:lt,listeners:at}),ot?lt.data=ot:(ot=wc(d),ot!==null&&(lt.data=ot)))),(ot=Fi?fd(a,d):sp(a,d))&&(we=Yi(we,"onBeforeInput"),0<we.length&&(Ce=new pc("onBeforeInput","beforeinput",null,d,Ce),Me.push({event:Ce,listeners:we}),Ce.data=ot))}wd(Me,i)})}function Ma(a,i,d){return{instance:a,listener:i,currentTarget:d}}function Yi(a,i){for(var d=i+"Capture",g=[];a!==null;){var x=a,N=x.stateNode;x.tag===5&&N!==null&&(x=N,N=Lt(a,d),N!=null&&g.unshift(Ma(a,N,x)),N=Lt(a,i),N!=null&&g.push(Ma(a,N,x))),a=a.return}return g}function Ia(a){if(a===null)return null;do a=a.return;while(a&&a.tag!==5);return a||null}function Ao(a,i,d,g,x){for(var N=i._reactName,L=[];d!==null&&d!==g;){var J=d,ae=J.alternate,we=J.stateNode;if(ae!==null&&ae===g)break;J.tag===5&&we!==null&&(J=we,x?(ae=Lt(d,N),ae!=null&&L.unshift(Ma(d,ae,J))):x||(ae=Lt(d,N),ae!=null&&L.push(Ma(d,ae,J)))),d=d.return}L.length!==0&&a.push({event:i,listeners:L})}var vd=/\r\n?/g,xd=/\u0000|\uFFFD/g;function Cc(a){return(typeof a=="string"?a:""+a).replace(vd,`
38
+ `).replace(xd,"")}function Mo(a,i,d){if(i=Cc(i),Cc(a)!==i&&d)throw Error(n(425))}function Xi(){}var Tc=null,Jr=null;function Io(a,i){return a==="textarea"||a==="noscript"||typeof i.children=="string"||typeof i.children=="number"||typeof i.dangerouslySetInnerHTML=="object"&&i.dangerouslySetInnerHTML!==null&&i.dangerouslySetInnerHTML.__html!=null}var Rc=typeof setTimeout=="function"?setTimeout:void 0,ip=typeof clearTimeout=="function"?clearTimeout:void 0,bd=typeof Promise=="function"?Promise:void 0,Cn=typeof queueMicrotask=="function"?queueMicrotask:typeof bd<"u"?function(a){return bd.resolve(null).then(a).catch(kd)}:Rc;function kd(a){setTimeout(function(){throw a})}function $o(a,i){var d=i,g=0;do{var x=d.nextSibling;if(a.removeChild(d),x&&x.nodeType===8)if(d=x.data,d==="/$"){if(g===0){a.removeChild(x),ya(i);return}g--}else d!=="$"&&d!=="$?"&&d!=="$!"||g++;d=x}while(d);ya(i)}function Es(a){for(;a!=null;a=a.nextSibling){var i=a.nodeType;if(i===1||i===3)break;if(i===8){if(i=a.data,i==="$"||i==="$!"||i==="$?")break;if(i==="/$")return null}}return a}function Zi(a){a=a.previousSibling;for(var i=0;a;){if(a.nodeType===8){var d=a.data;if(d==="$"||d==="$!"||d==="$?"){if(i===0)return a;i--}else d==="/$"&&i++}a=a.previousSibling}return null}var es=Math.random().toString(36).slice(2),Dn="__reactFiber$"+es,Oo="__reactProps$"+es,mn="__reactContainer$"+es,Qi="__reactEvents$"+es,lp="__reactListeners$"+es,Nd="__reactHandles$"+es;function Cs(a){var i=a[Dn];if(i)return i;for(var d=a.parentNode;d;){if(i=d[mn]||d[Dn]){if(d=i.alternate,i.child!==null||d!==null&&d.child!==null)for(a=Zi(a);a!==null;){if(d=a[Dn])return d;a=Zi(a)}return i}a=d,d=a.parentNode}return null}function Lo(a){return a=a[Dn]||a[mn],!a||a.tag!==5&&a.tag!==6&&a.tag!==13&&a.tag!==3?null:a}function ts(a){if(a.tag===5||a.tag===6)return a.stateNode;throw Error(n(33))}function Ji(a){return a[Oo]||null}var Po=[],ea=-1;function Cr(a){return{current:a}}function At(a){0>ea||(a.current=Po[ea],Po[ea]=null,ea--)}function Mt(a,i){ea++,Po[ea]=a.current,a.current=i}var Zn={},an=Cr(Zn),bn=Cr(!1),ns=Zn;function rs(a,i){var d=a.type.contextTypes;if(!d)return Zn;var g=a.stateNode;if(g&&g.__reactInternalMemoizedUnmaskedChildContext===i)return g.__reactInternalMemoizedMaskedChildContext;var x={},N;for(N in d)x[N]=i[N];return g&&(a=a.stateNode,a.__reactInternalMemoizedUnmaskedChildContext=i,a.__reactInternalMemoizedMaskedChildContext=x),x}function gn(a){return a=a.childContextTypes,a!=null}function Do(){At(bn),At(an)}function Ts(a,i,d){if(an.current!==Zn)throw Error(n(168));Mt(an,i),Mt(bn,d)}function Fn(a,i,d){var g=a.stateNode;if(i=i.childContextTypes,typeof g.getChildContext!="function")return d;g=g.getChildContext();for(var x in g)if(!(x in i))throw Error(n(108,ie(a)||"Unknown",x));return W({},d,g)}function el(a){return a=(a=a.stateNode)&&a.__reactInternalMemoizedMergedChildContext||Zn,ns=an.current,Mt(an,a),Mt(bn,bn.current),!0}function Sd(a,i,d){var g=a.stateNode;if(!g)throw Error(n(169));d?(a=Fn(a,i,ns),g.__reactInternalMemoizedMergedChildContext=a,At(bn),At(an),Mt(an,a)):At(bn),Mt(bn,d)}var ss=null,tl=!1,Rs=!1;function Ac(a){ss===null?ss=[a]:ss.push(a)}function nl(a){tl=!0,Ac(a)}function Tr(){if(!Rs&&ss!==null){Rs=!0;var a=0,i=ft;try{var d=ss;for(ft=1;a<d.length;a++){var g=d[a];do g=g(!0);while(g!==null)}ss=null,tl=!1}catch(x){throw ss!==null&&(ss=ss.slice(a+1)),tt(Nt,Tr),x}finally{ft=i,Rs=!1}}return null}var Qn=[],$a=0,Fo=null,qo=0,_t=[],qn=0,As=null,as=1,os="";function Ms(a,i){Qn[$a++]=qo,Qn[$a++]=Fo,Fo=a,qo=i}function jd(a,i,d){_t[qn++]=as,_t[qn++]=os,_t[qn++]=As,As=a;var g=as;a=os;var x=32-Gn(g)-1;g&=~(1<<x),d+=1;var N=32-Gn(i)+x;if(30<N){var L=x-x%5;N=(g&(1<<L)-1).toString(32),g>>=L,x-=L,as=1<<32-Gn(i)+x|d<<x|g,os=N+a}else as=1<<N|d<<x|g,os=a}function rl(a){a.return!==null&&(Ms(a,1),jd(a,1,0))}function sl(a){for(;a===Fo;)Fo=Qn[--$a],Qn[$a]=null,qo=Qn[--$a],Qn[$a]=null;for(;a===As;)As=_t[--qn],_t[qn]=null,os=_t[--qn],_t[qn]=null,as=_t[--qn],_t[qn]=null}var yn=null,Bn=null,St=!1,zn=null;function Bo(a,i){var d=$r(5,null,null,0);d.elementType="DELETED",d.stateNode=i,d.return=a,i=a.deletions,i===null?(a.deletions=[d],a.flags|=16):i.push(d)}function al(a,i){switch(a.tag){case 5:var d=a.type;return i=i.nodeType!==1||d.toLowerCase()!==i.nodeName.toLowerCase()?null:i,i!==null?(a.stateNode=i,yn=a,Bn=Es(i.firstChild),!0):!1;case 6:return i=a.pendingProps===""||i.nodeType!==3?null:i,i!==null?(a.stateNode=i,yn=a,Bn=null,!0):!1;case 13:return i=i.nodeType!==8?null:i,i!==null?(d=As!==null?{id:as,overflow:os}:null,a.memoizedState={dehydrated:i,treeContext:d,retryLane:1073741824},d=$r(18,null,null,0),d.stateNode=i,d.return=a,a.child=d,yn=a,Bn=null,!0):!1;default:return!1}}function Mc(a){return(a.mode&1)!==0&&(a.flags&128)===0}function ol(a){if(St){var i=Bn;if(i){var d=i;if(!al(a,i)){if(Mc(a))throw Error(n(418));i=Es(d.nextSibling);var g=yn;i&&al(a,i)?Bo(g,d):(a.flags=a.flags&-4097|2,St=!1,yn=a)}}else{if(Mc(a))throw Error(n(418));a.flags=a.flags&-4097|2,St=!1,yn=a}}}function Ic(a){for(a=a.return;a!==null&&a.tag!==5&&a.tag!==3&&a.tag!==13;)a=a.return;yn=a}function il(a){if(a!==yn)return!1;if(!St)return Ic(a),St=!0,!1;var i;if((i=a.tag!==3)&&!(i=a.tag!==5)&&(i=a.type,i=i!=="head"&&i!=="body"&&!Io(a.type,a.memoizedProps)),i&&(i=Bn)){if(Mc(a))throw _d(),Error(n(418));for(;i;)Bo(a,i),i=Es(i.nextSibling)}if(Ic(a),a.tag===13){if(a=a.memoizedState,a=a!==null?a.dehydrated:null,!a)throw Error(n(317));e:{for(a=a.nextSibling,i=0;a;){if(a.nodeType===8){var d=a.data;if(d==="/$"){if(i===0){Bn=Es(a.nextSibling);break e}i--}else d!=="$"&&d!=="$!"&&d!=="$?"||i++}a=a.nextSibling}Bn=null}}else Bn=yn?Es(a.stateNode.nextSibling):null;return!0}function _d(){for(var a=Bn;a;)a=Es(a.nextSibling)}function ta(){Bn=yn=null,St=!1}function na(a){zn===null?zn=[a]:zn.push(a)}var $c=C.ReactCurrentBatchConfig;function zo(a,i,d){if(a=d.ref,a!==null&&typeof a!="function"&&typeof a!="object"){if(d._owner){if(d=d._owner,d){if(d.tag!==1)throw Error(n(309));var g=d.stateNode}if(!g)throw Error(n(147,a));var x=g,N=""+a;return i!==null&&i.ref!==null&&typeof i.ref=="function"&&i.ref._stringRef===N?i.ref:(i=function(L){var J=x.refs;L===null?delete J[N]:J[N]=L},i._stringRef=N,i)}if(typeof a!="string")throw Error(n(284));if(!d._owner)throw Error(n(290,a))}return a}function Uo(a,i){throw a=Object.prototype.toString.call(i),Error(n(31,a==="[object Object]"?"object with keys {"+Object.keys(i).join(", ")+"}":a))}function Oc(a){var i=a._init;return i(a._payload)}function Lc(a){function i(he,oe){if(a){var me=he.deletions;me===null?(he.deletions=[oe],he.flags|=16):me.push(oe)}}function d(he,oe){if(!a)return null;for(;oe!==null;)i(he,oe),oe=oe.sibling;return null}function g(he,oe){for(he=new Map;oe!==null;)oe.key!==null?he.set(oe.key,oe):he.set(oe.index,oe),oe=oe.sibling;return he}function x(he,oe){return he=Ua(he,oe),he.index=0,he.sibling=null,he}function N(he,oe,me){return he.index=me,a?(me=he.alternate,me!==null?(me=me.index,me<oe?(he.flags|=2,oe):me):(he.flags|=2,oe)):(he.flags|=1048576,oe)}function L(he){return a&&he.alternate===null&&(he.flags|=2),he}function J(he,oe,me,$e){return oe===null||oe.tag!==6?(oe=Gp(me,he.mode,$e),oe.return=he,oe):(oe=x(oe,me),oe.return=he,oe)}function ae(he,oe,me,$e){var Je=me.type;return Je===O?Ce(he,oe,me.props.children,$e,me.key):oe!==null&&(oe.elementType===Je||typeof Je=="object"&&Je!==null&&Je.$$typeof===K&&Oc(Je)===oe.type)?($e=x(oe,me.props),$e.ref=zo(he,oe,me),$e.return=he,$e):($e=Gd(me.type,me.key,me.props,null,he.mode,$e),$e.ref=zo(he,oe,me),$e.return=he,$e)}function we(he,oe,me,$e){return oe===null||oe.tag!==4||oe.stateNode.containerInfo!==me.containerInfo||oe.stateNode.implementation!==me.implementation?(oe=Kp(me,he.mode,$e),oe.return=he,oe):(oe=x(oe,me.children||[]),oe.return=he,oe)}function Ce(he,oe,me,$e,Je){return oe===null||oe.tag!==7?(oe=Zo(me,he.mode,$e,Je),oe.return=he,oe):(oe=x(oe,me),oe.return=he,oe)}function Me(he,oe,me){if(typeof oe=="string"&&oe!==""||typeof oe=="number")return oe=Gp(""+oe,he.mode,me),oe.return=he,oe;if(typeof oe=="object"&&oe!==null){switch(oe.$$typeof){case R:return me=Gd(oe.type,oe.key,oe.props,null,he.mode,me),me.ref=zo(he,null,oe),me.return=he,me;case I:return oe=Kp(oe,he.mode,me),oe.return=he,oe;case K:var $e=oe._init;return Me(he,$e(oe._payload),me)}if(be(oe)||B(oe))return oe=Zo(oe,he.mode,me,null),oe.return=he,oe;Uo(he,oe)}return null}function Ee(he,oe,me,$e){var Je=oe!==null?oe.key:null;if(typeof me=="string"&&me!==""||typeof me=="number")return Je!==null?null:J(he,oe,""+me,$e);if(typeof me=="object"&&me!==null){switch(me.$$typeof){case R:return me.key===Je?ae(he,oe,me,$e):null;case I:return me.key===Je?we(he,oe,me,$e):null;case K:return Je=me._init,Ee(he,oe,Je(me._payload),$e)}if(be(me)||B(me))return Je!==null?null:Ce(he,oe,me,$e,null);Uo(he,me)}return null}function He(he,oe,me,$e,Je){if(typeof $e=="string"&&$e!==""||typeof $e=="number")return he=he.get(me)||null,J(oe,he,""+$e,Je);if(typeof $e=="object"&&$e!==null){switch($e.$$typeof){case R:return he=he.get($e.key===null?me:$e.key)||null,ae(oe,he,$e,Je);case I:return he=he.get($e.key===null?me:$e.key)||null,we(oe,he,$e,Je);case K:var at=$e._init;return He(he,oe,me,at($e._payload),Je)}if(be($e)||B($e))return he=he.get(me)||null,Ce(oe,he,$e,Je,null);Uo(oe,$e)}return null}function Xe(he,oe,me,$e){for(var Je=null,at=null,ot=oe,lt=oe=0,xn=null;ot!==null&&lt<me.length;lt++){ot.index>lt?(xn=ot,ot=null):xn=ot.sibling;var jt=Ee(he,ot,me[lt],$e);if(jt===null){ot===null&&(ot=xn);break}a&&ot&&jt.alternate===null&&i(he,ot),oe=N(jt,oe,lt),at===null?Je=jt:at.sibling=jt,at=jt,ot=xn}if(lt===me.length)return d(he,ot),St&&Ms(he,lt),Je;if(ot===null){for(;lt<me.length;lt++)ot=Me(he,me[lt],$e),ot!==null&&(oe=N(ot,oe,lt),at===null?Je=ot:at.sibling=ot,at=ot);return St&&Ms(he,lt),Je}for(ot=g(he,ot);lt<me.length;lt++)xn=He(ot,he,lt,me[lt],$e),xn!==null&&(a&&xn.alternate!==null&&ot.delete(xn.key===null?lt:xn.key),oe=N(xn,oe,lt),at===null?Je=xn:at.sibling=xn,at=xn);return a&&ot.forEach(function(Ha){return i(he,Ha)}),St&&Ms(he,lt),Je}function Qe(he,oe,me,$e){var Je=B(me);if(typeof Je!="function")throw Error(n(150));if(me=Je.call(me),me==null)throw Error(n(151));for(var at=Je=null,ot=oe,lt=oe=0,xn=null,jt=me.next();ot!==null&&!jt.done;lt++,jt=me.next()){ot.index>lt?(xn=ot,ot=null):xn=ot.sibling;var Ha=Ee(he,ot,jt.value,$e);if(Ha===null){ot===null&&(ot=xn);break}a&&ot&&Ha.alternate===null&&i(he,ot),oe=N(Ha,oe,lt),at===null?Je=Ha:at.sibling=Ha,at=Ha,ot=xn}if(jt.done)return d(he,ot),St&&Ms(he,lt),Je;if(ot===null){for(;!jt.done;lt++,jt=me.next())jt=Me(he,jt.value,$e),jt!==null&&(oe=N(jt,oe,lt),at===null?Je=jt:at.sibling=jt,at=jt);return St&&Ms(he,lt),Je}for(ot=g(he,ot);!jt.done;lt++,jt=me.next())jt=He(ot,he,lt,jt.value,$e),jt!==null&&(a&&jt.alternate!==null&&ot.delete(jt.key===null?lt:jt.key),oe=N(jt,oe,lt),at===null?Je=jt:at.sibling=jt,at=jt);return a&&ot.forEach(function(bO){return i(he,bO)}),St&&Ms(he,lt),Je}function Yt(he,oe,me,$e){if(typeof me=="object"&&me!==null&&me.type===O&&me.key===null&&(me=me.props.children),typeof me=="object"&&me!==null){switch(me.$$typeof){case R:e:{for(var Je=me.key,at=oe;at!==null;){if(at.key===Je){if(Je=me.type,Je===O){if(at.tag===7){d(he,at.sibling),oe=x(at,me.props.children),oe.return=he,he=oe;break e}}else if(at.elementType===Je||typeof Je=="object"&&Je!==null&&Je.$$typeof===K&&Oc(Je)===at.type){d(he,at.sibling),oe=x(at,me.props),oe.ref=zo(he,at,me),oe.return=he,he=oe;break e}d(he,at);break}else i(he,at);at=at.sibling}me.type===O?(oe=Zo(me.props.children,he.mode,$e,me.key),oe.return=he,he=oe):($e=Gd(me.type,me.key,me.props,null,he.mode,$e),$e.ref=zo(he,oe,me),$e.return=he,he=$e)}return L(he);case I:e:{for(at=me.key;oe!==null;){if(oe.key===at)if(oe.tag===4&&oe.stateNode.containerInfo===me.containerInfo&&oe.stateNode.implementation===me.implementation){d(he,oe.sibling),oe=x(oe,me.children||[]),oe.return=he,he=oe;break e}else{d(he,oe);break}else i(he,oe);oe=oe.sibling}oe=Kp(me,he.mode,$e),oe.return=he,he=oe}return L(he);case K:return at=me._init,Yt(he,oe,at(me._payload),$e)}if(be(me))return Xe(he,oe,me,$e);if(B(me))return Qe(he,oe,me,$e);Uo(he,me)}return typeof me=="string"&&me!==""||typeof me=="number"?(me=""+me,oe!==null&&oe.tag===6?(d(he,oe.sibling),oe=x(oe,me),oe.return=he,he=oe):(d(he,oe),oe=Gp(me,he.mode,$e),oe.return=he,he=oe),L(he)):d(he,oe)}return Yt}var ra=Lc(!0),Pc=Lc(!1),T=Cr(null),A=null,X=null,te=null;function ye(){te=X=A=null}function _e(a){var i=T.current;At(T),a._currentValue=i}function Oe(a,i,d){for(;a!==null;){var g=a.alternate;if((a.childLanes&i)!==i?(a.childLanes|=i,g!==null&&(g.childLanes|=i)):g!==null&&(g.childLanes&i)!==i&&(g.childLanes|=i),a===d)break;a=a.return}}function Ve(a,i){A=a,te=X=null,a=a.dependencies,a!==null&&a.firstContext!==null&&((a.lanes&i)!==0&&(er=!0),a.firstContext=null)}function it(a){var i=a._currentValue;if(te!==a)if(a={context:a,memoizedValue:i,next:null},X===null){if(A===null)throw Error(n(308));X=a,A.dependencies={lanes:0,firstContext:a}}else X=X.next=a;return i}var Ze=null;function vt(a){Ze===null?Ze=[a]:Ze.push(a)}function Et(a,i,d,g){var x=i.interleaved;return x===null?(d.next=d,vt(i)):(d.next=x.next,x.next=d),i.interleaved=d,kn(a,g)}function kn(a,i){a.lanes|=i;var d=a.alternate;for(d!==null&&(d.lanes|=i),d=a,a=a.return;a!==null;)a.childLanes|=i,d=a.alternate,d!==null&&(d.childLanes|=i),d=a,a=a.return;return d.tag===3?d.stateNode:null}var Jn=!1;function Oa(a){a.updateQueue={baseState:a.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Ed(a,i){a=a.updateQueue,i.updateQueue===a&&(i.updateQueue={baseState:a.baseState,firstBaseUpdate:a.firstBaseUpdate,lastBaseUpdate:a.lastBaseUpdate,shared:a.shared,effects:a.effects})}function Rr(a,i){return{eventTime:a,lane:i,tag:0,payload:null,callback:null,next:null}}function Ar(a,i,d){var g=a.updateQueue;if(g===null)return null;if(g=g.shared,(kt&2)!==0){var x=g.pending;return x===null?i.next=i:(i.next=x.next,x.next=i),g.pending=i,kn(a,d)}return x=g.interleaved,x===null?(i.next=i,vt(g)):(i.next=x.next,x.next=i),g.interleaved=i,kn(a,d)}function ll(a,i,d){if(i=i.updateQueue,i!==null&&(i=i.shared,(d&4194240)!==0)){var g=i.lanes;g&=a.pendingLanes,d|=g,i.lanes=d,ic(a,d)}}function Dc(a,i){var d=a.updateQueue,g=a.alternate;if(g!==null&&(g=g.updateQueue,d===g)){var x=null,N=null;if(d=d.firstBaseUpdate,d!==null){do{var L={eventTime:d.eventTime,lane:d.lane,tag:d.tag,payload:d.payload,callback:d.callback,next:null};N===null?x=N=L:N=N.next=L,d=d.next}while(d!==null);N===null?x=N=i:N=N.next=i}else x=N=i;d={baseState:g.baseState,firstBaseUpdate:x,lastBaseUpdate:N,shared:g.shared,effects:g.effects},a.updateQueue=d;return}a=d.lastBaseUpdate,a===null?d.firstBaseUpdate=i:a.next=i,d.lastBaseUpdate=i}function Is(a,i,d,g){var x=a.updateQueue;Jn=!1;var N=x.firstBaseUpdate,L=x.lastBaseUpdate,J=x.shared.pending;if(J!==null){x.shared.pending=null;var ae=J,we=ae.next;ae.next=null,L===null?N=we:L.next=we,L=ae;var Ce=a.alternate;Ce!==null&&(Ce=Ce.updateQueue,J=Ce.lastBaseUpdate,J!==L&&(J===null?Ce.firstBaseUpdate=we:J.next=we,Ce.lastBaseUpdate=ae))}if(N!==null){var Me=x.baseState;L=0,Ce=we=ae=null,J=N;do{var Ee=J.lane,He=J.eventTime;if((g&Ee)===Ee){Ce!==null&&(Ce=Ce.next={eventTime:He,lane:0,tag:J.tag,payload:J.payload,callback:J.callback,next:null});e:{var Xe=a,Qe=J;switch(Ee=i,He=d,Qe.tag){case 1:if(Xe=Qe.payload,typeof Xe=="function"){Me=Xe.call(He,Me,Ee);break e}Me=Xe;break e;case 3:Xe.flags=Xe.flags&-65537|128;case 0:if(Xe=Qe.payload,Ee=typeof Xe=="function"?Xe.call(He,Me,Ee):Xe,Ee==null)break e;Me=W({},Me,Ee);break e;case 2:Jn=!0}}J.callback!==null&&J.lane!==0&&(a.flags|=64,Ee=x.effects,Ee===null?x.effects=[J]:Ee.push(J))}else He={eventTime:He,lane:Ee,tag:J.tag,payload:J.payload,callback:J.callback,next:null},Ce===null?(we=Ce=He,ae=Me):Ce=Ce.next=He,L|=Ee;if(J=J.next,J===null){if(J=x.shared.pending,J===null)break;Ee=J,J=Ee.next,Ee.next=null,x.lastBaseUpdate=Ee,x.shared.pending=null}}while(!0);if(Ce===null&&(ae=Me),x.baseState=ae,x.firstBaseUpdate=we,x.lastBaseUpdate=Ce,i=x.shared.interleaved,i!==null){x=i;do L|=x.lane,x=x.next;while(x!==i)}else N===null&&(x.shared.lanes=0);Go|=L,a.lanes=L,a.memoizedState=Me}}function La(a,i,d){if(a=i.effects,i.effects=null,a!==null)for(i=0;i<a.length;i++){var g=a[i],x=g.callback;if(x!==null){if(g.callback=null,g=d,typeof x!="function")throw Error(n(191,x));x.call(g)}}}var Ho={},Ct=Cr(Ho),Pa=Cr(Ho),Fc=Cr(Ho);function Wo(a){if(a===Ho)throw Error(n(174));return a}function cp(a,i){switch(Mt(Fc,i),Mt(Pa,a),Mt(Ct,Ho),a=i.nodeType,a){case 9:case 11:i=(i=i.documentElement)?i.namespaceURI:Ye(null,"");break;default:a=a===8?i.parentNode:i,i=a.namespaceURI||null,a=a.tagName,i=Ye(i,a)}At(Ct),Mt(Ct,i)}function cl(){At(Ct),At(Pa),At(Fc)}function mk(a){Wo(Fc.current);var i=Wo(Ct.current),d=Ye(i,a.type);i!==d&&(Mt(Pa,a),Mt(Ct,d))}function up(a){Pa.current===a&&(At(Ct),At(Pa))}var Ft=Cr(0);function Cd(a){for(var i=a;i!==null;){if(i.tag===13){var d=i.memoizedState;if(d!==null&&(d=d.dehydrated,d===null||d.data==="$?"||d.data==="$!"))return i}else if(i.tag===19&&i.memoizedProps.revealOrder!==void 0){if((i.flags&128)!==0)return i}else if(i.child!==null){i.child.return=i,i=i.child;continue}if(i===a)break;for(;i.sibling===null;){if(i.return===null||i.return===a)return null;i=i.return}i.sibling.return=i.return,i=i.sibling}return null}var dp=[];function hp(){for(var a=0;a<dp.length;a++)dp[a]._workInProgressVersionPrimary=null;dp.length=0}var Td=C.ReactCurrentDispatcher,fp=C.ReactCurrentBatchConfig,Vo=0,qt=null,on=null,wn=null,Rd=!1,qc=!1,Bc=0,U$=0;function Tn(){throw Error(n(321))}function pp(a,i){if(i===null)return!1;for(var d=0;d<i.length&&d<a.length;d++)if(!Xn(a[d],i[d]))return!1;return!0}function mp(a,i,d,g,x,N){if(Vo=N,qt=i,i.memoizedState=null,i.updateQueue=null,i.lanes=0,Td.current=a===null||a.memoizedState===null?G$:K$,a=d(g,x),qc){N=0;do{if(qc=!1,Bc=0,25<=N)throw Error(n(301));N+=1,wn=on=null,i.updateQueue=null,Td.current=Y$,a=d(g,x)}while(qc)}if(Td.current=Id,i=on!==null&&on.next!==null,Vo=0,wn=on=qt=null,Rd=!1,i)throw Error(n(300));return a}function gp(){var a=Bc!==0;return Bc=0,a}function $s(){var a={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return wn===null?qt.memoizedState=wn=a:wn=wn.next=a,wn}function Mr(){if(on===null){var a=qt.alternate;a=a!==null?a.memoizedState:null}else a=on.next;var i=wn===null?qt.memoizedState:wn.next;if(i!==null)wn=i,on=a;else{if(a===null)throw Error(n(310));on=a,a={memoizedState:on.memoizedState,baseState:on.baseState,baseQueue:on.baseQueue,queue:on.queue,next:null},wn===null?qt.memoizedState=wn=a:wn=wn.next=a}return wn}function zc(a,i){return typeof i=="function"?i(a):i}function yp(a){var i=Mr(),d=i.queue;if(d===null)throw Error(n(311));d.lastRenderedReducer=a;var g=on,x=g.baseQueue,N=d.pending;if(N!==null){if(x!==null){var L=x.next;x.next=N.next,N.next=L}g.baseQueue=x=N,d.pending=null}if(x!==null){N=x.next,g=g.baseState;var J=L=null,ae=null,we=N;do{var Ce=we.lane;if((Vo&Ce)===Ce)ae!==null&&(ae=ae.next={lane:0,action:we.action,hasEagerState:we.hasEagerState,eagerState:we.eagerState,next:null}),g=we.hasEagerState?we.eagerState:a(g,we.action);else{var Me={lane:Ce,action:we.action,hasEagerState:we.hasEagerState,eagerState:we.eagerState,next:null};ae===null?(J=ae=Me,L=g):ae=ae.next=Me,qt.lanes|=Ce,Go|=Ce}we=we.next}while(we!==null&&we!==N);ae===null?L=g:ae.next=J,Xn(g,i.memoizedState)||(er=!0),i.memoizedState=g,i.baseState=L,i.baseQueue=ae,d.lastRenderedState=g}if(a=d.interleaved,a!==null){x=a;do N=x.lane,qt.lanes|=N,Go|=N,x=x.next;while(x!==a)}else x===null&&(d.lanes=0);return[i.memoizedState,d.dispatch]}function wp(a){var i=Mr(),d=i.queue;if(d===null)throw Error(n(311));d.lastRenderedReducer=a;var g=d.dispatch,x=d.pending,N=i.memoizedState;if(x!==null){d.pending=null;var L=x=x.next;do N=a(N,L.action),L=L.next;while(L!==x);Xn(N,i.memoizedState)||(er=!0),i.memoizedState=N,i.baseQueue===null&&(i.baseState=N),d.lastRenderedState=N}return[N,g]}function gk(){}function yk(a,i){var d=qt,g=Mr(),x=i(),N=!Xn(g.memoizedState,x);if(N&&(g.memoizedState=x,er=!0),g=g.queue,vp(xk.bind(null,d,g,a),[a]),g.getSnapshot!==i||N||wn!==null&&wn.memoizedState.tag&1){if(d.flags|=2048,Uc(9,vk.bind(null,d,g,x,i),void 0,null),vn===null)throw Error(n(349));(Vo&30)!==0||wk(d,i,x)}return x}function wk(a,i,d){a.flags|=16384,a={getSnapshot:i,value:d},i=qt.updateQueue,i===null?(i={lastEffect:null,stores:null},qt.updateQueue=i,i.stores=[a]):(d=i.stores,d===null?i.stores=[a]:d.push(a))}function vk(a,i,d,g){i.value=d,i.getSnapshot=g,bk(i)&&kk(a)}function xk(a,i,d){return d(function(){bk(i)&&kk(a)})}function bk(a){var i=a.getSnapshot;a=a.value;try{var d=i();return!Xn(a,d)}catch{return!0}}function kk(a){var i=kn(a,1);i!==null&&us(i,a,1,-1)}function Nk(a){var i=$s();return typeof a=="function"&&(a=a()),i.memoizedState=i.baseState=a,a={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:zc,lastRenderedState:a},i.queue=a,a=a.dispatch=V$.bind(null,qt,a),[i.memoizedState,a]}function Uc(a,i,d,g){return a={tag:a,create:i,destroy:d,deps:g,next:null},i=qt.updateQueue,i===null?(i={lastEffect:null,stores:null},qt.updateQueue=i,i.lastEffect=a.next=a):(d=i.lastEffect,d===null?i.lastEffect=a.next=a:(g=d.next,d.next=a,a.next=g,i.lastEffect=a)),a}function Sk(){return Mr().memoizedState}function Ad(a,i,d,g){var x=$s();qt.flags|=a,x.memoizedState=Uc(1|i,d,void 0,g===void 0?null:g)}function Md(a,i,d,g){var x=Mr();g=g===void 0?null:g;var N=void 0;if(on!==null){var L=on.memoizedState;if(N=L.destroy,g!==null&&pp(g,L.deps)){x.memoizedState=Uc(i,d,N,g);return}}qt.flags|=a,x.memoizedState=Uc(1|i,d,N,g)}function jk(a,i){return Ad(8390656,8,a,i)}function vp(a,i){return Md(2048,8,a,i)}function _k(a,i){return Md(4,2,a,i)}function Ek(a,i){return Md(4,4,a,i)}function Ck(a,i){if(typeof i=="function")return a=a(),i(a),function(){i(null)};if(i!=null)return a=a(),i.current=a,function(){i.current=null}}function Tk(a,i,d){return d=d!=null?d.concat([a]):null,Md(4,4,Ck.bind(null,i,a),d)}function xp(){}function Rk(a,i){var d=Mr();i=i===void 0?null:i;var g=d.memoizedState;return g!==null&&i!==null&&pp(i,g[1])?g[0]:(d.memoizedState=[a,i],a)}function Ak(a,i){var d=Mr();i=i===void 0?null:i;var g=d.memoizedState;return g!==null&&i!==null&&pp(i,g[1])?g[0]:(a=a(),d.memoizedState=[a,i],a)}function Mk(a,i,d){return(Vo&21)===0?(a.baseState&&(a.baseState=!1,er=!0),a.memoizedState=d):(Xn(d,i)||(d=ma(),qt.lanes|=d,Go|=d,a.baseState=!0),i)}function H$(a,i){var d=ft;ft=d!==0&&4>d?d:4,a(!0);var g=fp.transition;fp.transition={};try{a(!1),i()}finally{ft=d,fp.transition=g}}function Ik(){return Mr().memoizedState}function W$(a,i,d){var g=Ba(a);if(d={lane:g,action:d,hasEagerState:!1,eagerState:null,next:null},$k(a))Ok(i,d);else if(d=Et(a,i,d,g),d!==null){var x=Hn();us(d,a,g,x),Lk(d,i,g)}}function V$(a,i,d){var g=Ba(a),x={lane:g,action:d,hasEagerState:!1,eagerState:null,next:null};if($k(a))Ok(i,x);else{var N=a.alternate;if(a.lanes===0&&(N===null||N.lanes===0)&&(N=i.lastRenderedReducer,N!==null))try{var L=i.lastRenderedState,J=N(L,d);if(x.hasEagerState=!0,x.eagerState=J,Xn(J,L)){var ae=i.interleaved;ae===null?(x.next=x,vt(i)):(x.next=ae.next,ae.next=x),i.interleaved=x;return}}catch{}finally{}d=Et(a,i,x,g),d!==null&&(x=Hn(),us(d,a,g,x),Lk(d,i,g))}}function $k(a){var i=a.alternate;return a===qt||i!==null&&i===qt}function Ok(a,i){qc=Rd=!0;var d=a.pending;d===null?i.next=i:(i.next=d.next,d.next=i),a.pending=i}function Lk(a,i,d){if((d&4194240)!==0){var g=i.lanes;g&=a.pendingLanes,d|=g,i.lanes=d,ic(a,d)}}var Id={readContext:it,useCallback:Tn,useContext:Tn,useEffect:Tn,useImperativeHandle:Tn,useInsertionEffect:Tn,useLayoutEffect:Tn,useMemo:Tn,useReducer:Tn,useRef:Tn,useState:Tn,useDebugValue:Tn,useDeferredValue:Tn,useTransition:Tn,useMutableSource:Tn,useSyncExternalStore:Tn,useId:Tn,unstable_isNewReconciler:!1},G$={readContext:it,useCallback:function(a,i){return $s().memoizedState=[a,i===void 0?null:i],a},useContext:it,useEffect:jk,useImperativeHandle:function(a,i,d){return d=d!=null?d.concat([a]):null,Ad(4194308,4,Ck.bind(null,i,a),d)},useLayoutEffect:function(a,i){return Ad(4194308,4,a,i)},useInsertionEffect:function(a,i){return Ad(4,2,a,i)},useMemo:function(a,i){var d=$s();return i=i===void 0?null:i,a=a(),d.memoizedState=[a,i],a},useReducer:function(a,i,d){var g=$s();return i=d!==void 0?d(i):i,g.memoizedState=g.baseState=i,a={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:a,lastRenderedState:i},g.queue=a,a=a.dispatch=W$.bind(null,qt,a),[g.memoizedState,a]},useRef:function(a){var i=$s();return a={current:a},i.memoizedState=a},useState:Nk,useDebugValue:xp,useDeferredValue:function(a){return $s().memoizedState=a},useTransition:function(){var a=Nk(!1),i=a[0];return a=H$.bind(null,a[1]),$s().memoizedState=a,[i,a]},useMutableSource:function(){},useSyncExternalStore:function(a,i,d){var g=qt,x=$s();if(St){if(d===void 0)throw Error(n(407));d=d()}else{if(d=i(),vn===null)throw Error(n(349));(Vo&30)!==0||wk(g,i,d)}x.memoizedState=d;var N={value:d,getSnapshot:i};return x.queue=N,jk(xk.bind(null,g,N,a),[a]),g.flags|=2048,Uc(9,vk.bind(null,g,N,d,i),void 0,null),d},useId:function(){var a=$s(),i=vn.identifierPrefix;if(St){var d=os,g=as;d=(g&~(1<<32-Gn(g)-1)).toString(32)+d,i=":"+i+"R"+d,d=Bc++,0<d&&(i+="H"+d.toString(32)),i+=":"}else d=U$++,i=":"+i+"r"+d.toString(32)+":";return a.memoizedState=i},unstable_isNewReconciler:!1},K$={readContext:it,useCallback:Rk,useContext:it,useEffect:vp,useImperativeHandle:Tk,useInsertionEffect:_k,useLayoutEffect:Ek,useMemo:Ak,useReducer:yp,useRef:Sk,useState:function(){return yp(zc)},useDebugValue:xp,useDeferredValue:function(a){var i=Mr();return Mk(i,on.memoizedState,a)},useTransition:function(){var a=yp(zc)[0],i=Mr().memoizedState;return[a,i]},useMutableSource:gk,useSyncExternalStore:yk,useId:Ik,unstable_isNewReconciler:!1},Y$={readContext:it,useCallback:Rk,useContext:it,useEffect:vp,useImperativeHandle:Tk,useInsertionEffect:_k,useLayoutEffect:Ek,useMemo:Ak,useReducer:wp,useRef:Sk,useState:function(){return wp(zc)},useDebugValue:xp,useDeferredValue:function(a){var i=Mr();return on===null?i.memoizedState=a:Mk(i,on.memoizedState,a)},useTransition:function(){var a=wp(zc)[0],i=Mr().memoizedState;return[a,i]},useMutableSource:gk,useSyncExternalStore:yk,useId:Ik,unstable_isNewReconciler:!1};function is(a,i){if(a&&a.defaultProps){i=W({},i),a=a.defaultProps;for(var d in a)i[d]===void 0&&(i[d]=a[d]);return i}return i}function bp(a,i,d,g){i=a.memoizedState,d=d(g,i),d=d==null?i:W({},i,d),a.memoizedState=d,a.lanes===0&&(a.updateQueue.baseState=d)}var $d={isMounted:function(a){return(a=a._reactInternals)?$n(a)===a:!1},enqueueSetState:function(a,i,d){a=a._reactInternals;var g=Hn(),x=Ba(a),N=Rr(g,x);N.payload=i,d!=null&&(N.callback=d),i=Ar(a,N,x),i!==null&&(us(i,a,x,g),ll(i,a,x))},enqueueReplaceState:function(a,i,d){a=a._reactInternals;var g=Hn(),x=Ba(a),N=Rr(g,x);N.tag=1,N.payload=i,d!=null&&(N.callback=d),i=Ar(a,N,x),i!==null&&(us(i,a,x,g),ll(i,a,x))},enqueueForceUpdate:function(a,i){a=a._reactInternals;var d=Hn(),g=Ba(a),x=Rr(d,g);x.tag=2,i!=null&&(x.callback=i),i=Ar(a,x,g),i!==null&&(us(i,a,g,d),ll(i,a,g))}};function Pk(a,i,d,g,x,N,L){return a=a.stateNode,typeof a.shouldComponentUpdate=="function"?a.shouldComponentUpdate(g,N,L):i.prototype&&i.prototype.isPureReactComponent?!_s(d,g)||!_s(x,N):!0}function Dk(a,i,d){var g=!1,x=Zn,N=i.contextType;return typeof N=="object"&&N!==null?N=it(N):(x=gn(i)?ns:an.current,g=i.contextTypes,N=(g=g!=null)?rs(a,x):Zn),i=new i(d,N),a.memoizedState=i.state!==null&&i.state!==void 0?i.state:null,i.updater=$d,a.stateNode=i,i._reactInternals=a,g&&(a=a.stateNode,a.__reactInternalMemoizedUnmaskedChildContext=x,a.__reactInternalMemoizedMaskedChildContext=N),i}function Fk(a,i,d,g){a=i.state,typeof i.componentWillReceiveProps=="function"&&i.componentWillReceiveProps(d,g),typeof i.UNSAFE_componentWillReceiveProps=="function"&&i.UNSAFE_componentWillReceiveProps(d,g),i.state!==a&&$d.enqueueReplaceState(i,i.state,null)}function kp(a,i,d,g){var x=a.stateNode;x.props=d,x.state=a.memoizedState,x.refs={},Oa(a);var N=i.contextType;typeof N=="object"&&N!==null?x.context=it(N):(N=gn(i)?ns:an.current,x.context=rs(a,N)),x.state=a.memoizedState,N=i.getDerivedStateFromProps,typeof N=="function"&&(bp(a,i,N,d),x.state=a.memoizedState),typeof i.getDerivedStateFromProps=="function"||typeof x.getSnapshotBeforeUpdate=="function"||typeof x.UNSAFE_componentWillMount!="function"&&typeof x.componentWillMount!="function"||(i=x.state,typeof x.componentWillMount=="function"&&x.componentWillMount(),typeof x.UNSAFE_componentWillMount=="function"&&x.UNSAFE_componentWillMount(),i!==x.state&&$d.enqueueReplaceState(x,x.state,null),Is(a,d,x,g),x.state=a.memoizedState),typeof x.componentDidMount=="function"&&(a.flags|=4194308)}function ul(a,i){try{var d="",g=i;do d+=Y(g),g=g.return;while(g);var x=d}catch(N){x=`
39
+ Error generating stack: `+N.message+`
40
+ `+N.stack}return{value:a,source:i,stack:x,digest:null}}function Np(a,i,d){return{value:a,source:null,stack:d??null,digest:i??null}}function Sp(a,i){try{console.error(i.value)}catch(d){setTimeout(function(){throw d})}}var X$=typeof WeakMap=="function"?WeakMap:Map;function qk(a,i,d){d=Rr(-1,d),d.tag=3,d.payload={element:null};var g=i.value;return d.callback=function(){Bd||(Bd=!0,Fp=g),Sp(a,i)},d}function Bk(a,i,d){d=Rr(-1,d),d.tag=3;var g=a.type.getDerivedStateFromError;if(typeof g=="function"){var x=i.value;d.payload=function(){return g(x)},d.callback=function(){Sp(a,i)}}var N=a.stateNode;return N!==null&&typeof N.componentDidCatch=="function"&&(d.callback=function(){Sp(a,i),typeof g!="function"&&(Fa===null?Fa=new Set([this]):Fa.add(this));var L=i.stack;this.componentDidCatch(i.value,{componentStack:L!==null?L:""})}),d}function zk(a,i,d){var g=a.pingCache;if(g===null){g=a.pingCache=new X$;var x=new Set;g.set(i,x)}else x=g.get(i),x===void 0&&(x=new Set,g.set(i,x));x.has(d)||(x.add(d),a=uO.bind(null,a,i,d),i.then(a,a))}function Uk(a){do{var i;if((i=a.tag===13)&&(i=a.memoizedState,i=i!==null?i.dehydrated!==null:!0),i)return a;a=a.return}while(a!==null);return null}function Hk(a,i,d,g,x){return(a.mode&1)===0?(a===i?a.flags|=65536:(a.flags|=128,d.flags|=131072,d.flags&=-52805,d.tag===1&&(d.alternate===null?d.tag=17:(i=Rr(-1,1),i.tag=2,Ar(d,i,1))),d.lanes|=1),a):(a.flags|=65536,a.lanes=x,a)}var Z$=C.ReactCurrentOwner,er=!1;function Un(a,i,d,g){i.child=a===null?Pc(i,null,d,g):ra(i,a.child,d,g)}function Wk(a,i,d,g,x){d=d.render;var N=i.ref;return Ve(i,x),g=mp(a,i,d,g,N,x),d=gp(),a!==null&&!er?(i.updateQueue=a.updateQueue,i.flags&=-2053,a.lanes&=~x,sa(a,i,x)):(St&&d&&rl(i),i.flags|=1,Un(a,i,g,x),i.child)}function Vk(a,i,d,g,x){if(a===null){var N=d.type;return typeof N=="function"&&!Vp(N)&&N.defaultProps===void 0&&d.compare===null&&d.defaultProps===void 0?(i.tag=15,i.type=N,Gk(a,i,N,g,x)):(a=Gd(d.type,null,g,i,i.mode,x),a.ref=i.ref,a.return=i,i.child=a)}if(N=a.child,(a.lanes&x)===0){var L=N.memoizedProps;if(d=d.compare,d=d!==null?d:_s,d(L,g)&&a.ref===i.ref)return sa(a,i,x)}return i.flags|=1,a=Ua(N,g),a.ref=i.ref,a.return=i,i.child=a}function Gk(a,i,d,g,x){if(a!==null){var N=a.memoizedProps;if(_s(N,g)&&a.ref===i.ref)if(er=!1,i.pendingProps=g=N,(a.lanes&x)!==0)(a.flags&131072)!==0&&(er=!0);else return i.lanes=a.lanes,sa(a,i,x)}return jp(a,i,d,g,x)}function Kk(a,i,d){var g=i.pendingProps,x=g.children,N=a!==null?a.memoizedState:null;if(g.mode==="hidden")if((i.mode&1)===0)i.memoizedState={baseLanes:0,cachePool:null,transitions:null},Mt(hl,pr),pr|=d;else{if((d&1073741824)===0)return a=N!==null?N.baseLanes|d:d,i.lanes=i.childLanes=1073741824,i.memoizedState={baseLanes:a,cachePool:null,transitions:null},i.updateQueue=null,Mt(hl,pr),pr|=a,null;i.memoizedState={baseLanes:0,cachePool:null,transitions:null},g=N!==null?N.baseLanes:d,Mt(hl,pr),pr|=g}else N!==null?(g=N.baseLanes|d,i.memoizedState=null):g=d,Mt(hl,pr),pr|=g;return Un(a,i,x,d),i.child}function Yk(a,i){var d=i.ref;(a===null&&d!==null||a!==null&&a.ref!==d)&&(i.flags|=512,i.flags|=2097152)}function jp(a,i,d,g,x){var N=gn(d)?ns:an.current;return N=rs(i,N),Ve(i,x),d=mp(a,i,d,g,N,x),g=gp(),a!==null&&!er?(i.updateQueue=a.updateQueue,i.flags&=-2053,a.lanes&=~x,sa(a,i,x)):(St&&g&&rl(i),i.flags|=1,Un(a,i,d,x),i.child)}function Xk(a,i,d,g,x){if(gn(d)){var N=!0;el(i)}else N=!1;if(Ve(i,x),i.stateNode===null)Ld(a,i),Dk(i,d,g),kp(i,d,g,x),g=!0;else if(a===null){var L=i.stateNode,J=i.memoizedProps;L.props=J;var ae=L.context,we=d.contextType;typeof we=="object"&&we!==null?we=it(we):(we=gn(d)?ns:an.current,we=rs(i,we));var Ce=d.getDerivedStateFromProps,Me=typeof Ce=="function"||typeof L.getSnapshotBeforeUpdate=="function";Me||typeof L.UNSAFE_componentWillReceiveProps!="function"&&typeof L.componentWillReceiveProps!="function"||(J!==g||ae!==we)&&Fk(i,L,g,we),Jn=!1;var Ee=i.memoizedState;L.state=Ee,Is(i,g,L,x),ae=i.memoizedState,J!==g||Ee!==ae||bn.current||Jn?(typeof Ce=="function"&&(bp(i,d,Ce,g),ae=i.memoizedState),(J=Jn||Pk(i,d,J,g,Ee,ae,we))?(Me||typeof L.UNSAFE_componentWillMount!="function"&&typeof L.componentWillMount!="function"||(typeof L.componentWillMount=="function"&&L.componentWillMount(),typeof L.UNSAFE_componentWillMount=="function"&&L.UNSAFE_componentWillMount()),typeof L.componentDidMount=="function"&&(i.flags|=4194308)):(typeof L.componentDidMount=="function"&&(i.flags|=4194308),i.memoizedProps=g,i.memoizedState=ae),L.props=g,L.state=ae,L.context=we,g=J):(typeof L.componentDidMount=="function"&&(i.flags|=4194308),g=!1)}else{L=i.stateNode,Ed(a,i),J=i.memoizedProps,we=i.type===i.elementType?J:is(i.type,J),L.props=we,Me=i.pendingProps,Ee=L.context,ae=d.contextType,typeof ae=="object"&&ae!==null?ae=it(ae):(ae=gn(d)?ns:an.current,ae=rs(i,ae));var He=d.getDerivedStateFromProps;(Ce=typeof He=="function"||typeof L.getSnapshotBeforeUpdate=="function")||typeof L.UNSAFE_componentWillReceiveProps!="function"&&typeof L.componentWillReceiveProps!="function"||(J!==Me||Ee!==ae)&&Fk(i,L,g,ae),Jn=!1,Ee=i.memoizedState,L.state=Ee,Is(i,g,L,x);var Xe=i.memoizedState;J!==Me||Ee!==Xe||bn.current||Jn?(typeof He=="function"&&(bp(i,d,He,g),Xe=i.memoizedState),(we=Jn||Pk(i,d,we,g,Ee,Xe,ae)||!1)?(Ce||typeof L.UNSAFE_componentWillUpdate!="function"&&typeof L.componentWillUpdate!="function"||(typeof L.componentWillUpdate=="function"&&L.componentWillUpdate(g,Xe,ae),typeof L.UNSAFE_componentWillUpdate=="function"&&L.UNSAFE_componentWillUpdate(g,Xe,ae)),typeof L.componentDidUpdate=="function"&&(i.flags|=4),typeof L.getSnapshotBeforeUpdate=="function"&&(i.flags|=1024)):(typeof L.componentDidUpdate!="function"||J===a.memoizedProps&&Ee===a.memoizedState||(i.flags|=4),typeof L.getSnapshotBeforeUpdate!="function"||J===a.memoizedProps&&Ee===a.memoizedState||(i.flags|=1024),i.memoizedProps=g,i.memoizedState=Xe),L.props=g,L.state=Xe,L.context=ae,g=we):(typeof L.componentDidUpdate!="function"||J===a.memoizedProps&&Ee===a.memoizedState||(i.flags|=4),typeof L.getSnapshotBeforeUpdate!="function"||J===a.memoizedProps&&Ee===a.memoizedState||(i.flags|=1024),g=!1)}return _p(a,i,d,g,N,x)}function _p(a,i,d,g,x,N){Yk(a,i);var L=(i.flags&128)!==0;if(!g&&!L)return x&&Sd(i,d,!1),sa(a,i,N);g=i.stateNode,Z$.current=i;var J=L&&typeof d.getDerivedStateFromError!="function"?null:g.render();return i.flags|=1,a!==null&&L?(i.child=ra(i,a.child,null,N),i.child=ra(i,null,J,N)):Un(a,i,J,N),i.memoizedState=g.state,x&&Sd(i,d,!0),i.child}function Zk(a){var i=a.stateNode;i.pendingContext?Ts(a,i.pendingContext,i.pendingContext!==i.context):i.context&&Ts(a,i.context,!1),cp(a,i.containerInfo)}function Qk(a,i,d,g,x){return ta(),na(x),i.flags|=256,Un(a,i,d,g),i.child}var Ep={dehydrated:null,treeContext:null,retryLane:0};function Cp(a){return{baseLanes:a,cachePool:null,transitions:null}}function Jk(a,i,d){var g=i.pendingProps,x=Ft.current,N=!1,L=(i.flags&128)!==0,J;if((J=L)||(J=a!==null&&a.memoizedState===null?!1:(x&2)!==0),J?(N=!0,i.flags&=-129):(a===null||a.memoizedState!==null)&&(x|=1),Mt(Ft,x&1),a===null)return ol(i),a=i.memoizedState,a!==null&&(a=a.dehydrated,a!==null)?((i.mode&1)===0?i.lanes=1:a.data==="$!"?i.lanes=8:i.lanes=1073741824,null):(L=g.children,a=g.fallback,N?(g=i.mode,N=i.child,L={mode:"hidden",children:L},(g&1)===0&&N!==null?(N.childLanes=0,N.pendingProps=L):N=Kd(L,g,0,null),a=Zo(a,g,d,null),N.return=i,a.return=i,N.sibling=a,i.child=N,i.child.memoizedState=Cp(d),i.memoizedState=Ep,a):Tp(i,L));if(x=a.memoizedState,x!==null&&(J=x.dehydrated,J!==null))return Q$(a,i,L,g,J,x,d);if(N){N=g.fallback,L=i.mode,x=a.child,J=x.sibling;var ae={mode:"hidden",children:g.children};return(L&1)===0&&i.child!==x?(g=i.child,g.childLanes=0,g.pendingProps=ae,i.deletions=null):(g=Ua(x,ae),g.subtreeFlags=x.subtreeFlags&14680064),J!==null?N=Ua(J,N):(N=Zo(N,L,d,null),N.flags|=2),N.return=i,g.return=i,g.sibling=N,i.child=g,g=N,N=i.child,L=a.child.memoizedState,L=L===null?Cp(d):{baseLanes:L.baseLanes|d,cachePool:null,transitions:L.transitions},N.memoizedState=L,N.childLanes=a.childLanes&~d,i.memoizedState=Ep,g}return N=a.child,a=N.sibling,g=Ua(N,{mode:"visible",children:g.children}),(i.mode&1)===0&&(g.lanes=d),g.return=i,g.sibling=null,a!==null&&(d=i.deletions,d===null?(i.deletions=[a],i.flags|=16):d.push(a)),i.child=g,i.memoizedState=null,g}function Tp(a,i){return i=Kd({mode:"visible",children:i},a.mode,0,null),i.return=a,a.child=i}function Od(a,i,d,g){return g!==null&&na(g),ra(i,a.child,null,d),a=Tp(i,i.pendingProps.children),a.flags|=2,i.memoizedState=null,a}function Q$(a,i,d,g,x,N,L){if(d)return i.flags&256?(i.flags&=-257,g=Np(Error(n(422))),Od(a,i,L,g)):i.memoizedState!==null?(i.child=a.child,i.flags|=128,null):(N=g.fallback,x=i.mode,g=Kd({mode:"visible",children:g.children},x,0,null),N=Zo(N,x,L,null),N.flags|=2,g.return=i,N.return=i,g.sibling=N,i.child=g,(i.mode&1)!==0&&ra(i,a.child,null,L),i.child.memoizedState=Cp(L),i.memoizedState=Ep,N);if((i.mode&1)===0)return Od(a,i,L,null);if(x.data==="$!"){if(g=x.nextSibling&&x.nextSibling.dataset,g)var J=g.dgst;return g=J,N=Error(n(419)),g=Np(N,g,void 0),Od(a,i,L,g)}if(J=(L&a.childLanes)!==0,er||J){if(g=vn,g!==null){switch(L&-L){case 4:x=2;break;case 16:x=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:x=32;break;case 536870912:x=268435456;break;default:x=0}x=(x&(g.suspendedLanes|L))!==0?0:x,x!==0&&x!==N.retryLane&&(N.retryLane=x,kn(a,x),us(g,a,x,-1))}return Wp(),g=Np(Error(n(421))),Od(a,i,L,g)}return x.data==="$?"?(i.flags|=128,i.child=a.child,i=dO.bind(null,a),x._reactRetry=i,null):(a=N.treeContext,Bn=Es(x.nextSibling),yn=i,St=!0,zn=null,a!==null&&(_t[qn++]=as,_t[qn++]=os,_t[qn++]=As,as=a.id,os=a.overflow,As=i),i=Tp(i,g.children),i.flags|=4096,i)}function e1(a,i,d){a.lanes|=i;var g=a.alternate;g!==null&&(g.lanes|=i),Oe(a.return,i,d)}function Rp(a,i,d,g,x){var N=a.memoizedState;N===null?a.memoizedState={isBackwards:i,rendering:null,renderingStartTime:0,last:g,tail:d,tailMode:x}:(N.isBackwards=i,N.rendering=null,N.renderingStartTime=0,N.last=g,N.tail=d,N.tailMode=x)}function t1(a,i,d){var g=i.pendingProps,x=g.revealOrder,N=g.tail;if(Un(a,i,g.children,d),g=Ft.current,(g&2)!==0)g=g&1|2,i.flags|=128;else{if(a!==null&&(a.flags&128)!==0)e:for(a=i.child;a!==null;){if(a.tag===13)a.memoizedState!==null&&e1(a,d,i);else if(a.tag===19)e1(a,d,i);else if(a.child!==null){a.child.return=a,a=a.child;continue}if(a===i)break e;for(;a.sibling===null;){if(a.return===null||a.return===i)break e;a=a.return}a.sibling.return=a.return,a=a.sibling}g&=1}if(Mt(Ft,g),(i.mode&1)===0)i.memoizedState=null;else switch(x){case"forwards":for(d=i.child,x=null;d!==null;)a=d.alternate,a!==null&&Cd(a)===null&&(x=d),d=d.sibling;d=x,d===null?(x=i.child,i.child=null):(x=d.sibling,d.sibling=null),Rp(i,!1,x,d,N);break;case"backwards":for(d=null,x=i.child,i.child=null;x!==null;){if(a=x.alternate,a!==null&&Cd(a)===null){i.child=x;break}a=x.sibling,x.sibling=d,d=x,x=a}Rp(i,!0,d,null,N);break;case"together":Rp(i,!1,null,null,void 0);break;default:i.memoizedState=null}return i.child}function Ld(a,i){(i.mode&1)===0&&a!==null&&(a.alternate=null,i.alternate=null,i.flags|=2)}function sa(a,i,d){if(a!==null&&(i.dependencies=a.dependencies),Go|=i.lanes,(d&i.childLanes)===0)return null;if(a!==null&&i.child!==a.child)throw Error(n(153));if(i.child!==null){for(a=i.child,d=Ua(a,a.pendingProps),i.child=d,d.return=i;a.sibling!==null;)a=a.sibling,d=d.sibling=Ua(a,a.pendingProps),d.return=i;d.sibling=null}return i.child}function J$(a,i,d){switch(i.tag){case 3:Zk(i),ta();break;case 5:mk(i);break;case 1:gn(i.type)&&el(i);break;case 4:cp(i,i.stateNode.containerInfo);break;case 10:var g=i.type._context,x=i.memoizedProps.value;Mt(T,g._currentValue),g._currentValue=x;break;case 13:if(g=i.memoizedState,g!==null)return g.dehydrated!==null?(Mt(Ft,Ft.current&1),i.flags|=128,null):(d&i.child.childLanes)!==0?Jk(a,i,d):(Mt(Ft,Ft.current&1),a=sa(a,i,d),a!==null?a.sibling:null);Mt(Ft,Ft.current&1);break;case 19:if(g=(d&i.childLanes)!==0,(a.flags&128)!==0){if(g)return t1(a,i,d);i.flags|=128}if(x=i.memoizedState,x!==null&&(x.rendering=null,x.tail=null,x.lastEffect=null),Mt(Ft,Ft.current),g)break;return null;case 22:case 23:return i.lanes=0,Kk(a,i,d)}return sa(a,i,d)}var n1,Ap,r1,s1;n1=function(a,i){for(var d=i.child;d!==null;){if(d.tag===5||d.tag===6)a.appendChild(d.stateNode);else if(d.tag!==4&&d.child!==null){d.child.return=d,d=d.child;continue}if(d===i)break;for(;d.sibling===null;){if(d.return===null||d.return===i)return;d=d.return}d.sibling.return=d.return,d=d.sibling}},Ap=function(){},r1=function(a,i,d,g){var x=a.memoizedProps;if(x!==g){a=i.stateNode,Wo(Ct.current);var N=null;switch(d){case"input":x=Be(a,x),g=Be(a,g),N=[];break;case"select":x=W({},x,{value:void 0}),g=W({},g,{value:void 0}),N=[];break;case"textarea":x=ce(a,x),g=ce(a,g),N=[];break;default:typeof x.onClick!="function"&&typeof g.onClick=="function"&&(a.onclick=Xi)}ct(d,g);var L;d=null;for(we in x)if(!g.hasOwnProperty(we)&&x.hasOwnProperty(we)&&x[we]!=null)if(we==="style"){var J=x[we];for(L in J)J.hasOwnProperty(L)&&(d||(d={}),d[L]="")}else we!=="dangerouslySetInnerHTML"&&we!=="children"&&we!=="suppressContentEditableWarning"&&we!=="suppressHydrationWarning"&&we!=="autoFocus"&&(s.hasOwnProperty(we)?N||(N=[]):(N=N||[]).push(we,null));for(we in g){var ae=g[we];if(J=x!=null?x[we]:void 0,g.hasOwnProperty(we)&&ae!==J&&(ae!=null||J!=null))if(we==="style")if(J){for(L in J)!J.hasOwnProperty(L)||ae&&ae.hasOwnProperty(L)||(d||(d={}),d[L]="");for(L in ae)ae.hasOwnProperty(L)&&J[L]!==ae[L]&&(d||(d={}),d[L]=ae[L])}else d||(N||(N=[]),N.push(we,d)),d=ae;else we==="dangerouslySetInnerHTML"?(ae=ae?ae.__html:void 0,J=J?J.__html:void 0,ae!=null&&J!==ae&&(N=N||[]).push(we,ae)):we==="children"?typeof ae!="string"&&typeof ae!="number"||(N=N||[]).push(we,""+ae):we!=="suppressContentEditableWarning"&&we!=="suppressHydrationWarning"&&(s.hasOwnProperty(we)?(ae!=null&&we==="onScroll"&&$t("scroll",a),N||J===ae||(N=[])):(N=N||[]).push(we,ae))}d&&(N=N||[]).push("style",d);var we=N;(i.updateQueue=we)&&(i.flags|=4)}},s1=function(a,i,d,g){d!==g&&(i.flags|=4)};function Hc(a,i){if(!St)switch(a.tailMode){case"hidden":i=a.tail;for(var d=null;i!==null;)i.alternate!==null&&(d=i),i=i.sibling;d===null?a.tail=null:d.sibling=null;break;case"collapsed":d=a.tail;for(var g=null;d!==null;)d.alternate!==null&&(g=d),d=d.sibling;g===null?i||a.tail===null?a.tail=null:a.tail.sibling=null:g.sibling=null}}function Rn(a){var i=a.alternate!==null&&a.alternate.child===a.child,d=0,g=0;if(i)for(var x=a.child;x!==null;)d|=x.lanes|x.childLanes,g|=x.subtreeFlags&14680064,g|=x.flags&14680064,x.return=a,x=x.sibling;else for(x=a.child;x!==null;)d|=x.lanes|x.childLanes,g|=x.subtreeFlags,g|=x.flags,x.return=a,x=x.sibling;return a.subtreeFlags|=g,a.childLanes=d,i}function eO(a,i,d){var g=i.pendingProps;switch(sl(i),i.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return Rn(i),null;case 1:return gn(i.type)&&Do(),Rn(i),null;case 3:return g=i.stateNode,cl(),At(bn),At(an),hp(),g.pendingContext&&(g.context=g.pendingContext,g.pendingContext=null),(a===null||a.child===null)&&(il(i)?i.flags|=4:a===null||a.memoizedState.isDehydrated&&(i.flags&256)===0||(i.flags|=1024,zn!==null&&(zp(zn),zn=null))),Ap(a,i),Rn(i),null;case 5:up(i);var x=Wo(Fc.current);if(d=i.type,a!==null&&i.stateNode!=null)r1(a,i,d,g,x),a.ref!==i.ref&&(i.flags|=512,i.flags|=2097152);else{if(!g){if(i.stateNode===null)throw Error(n(166));return Rn(i),null}if(a=Wo(Ct.current),il(i)){g=i.stateNode,d=i.type;var N=i.memoizedProps;switch(g[Dn]=i,g[Oo]=N,a=(i.mode&1)!==0,d){case"dialog":$t("cancel",g),$t("close",g);break;case"iframe":case"object":case"embed":$t("load",g);break;case"video":case"audio":for(x=0;x<Co.length;x++)$t(Co[x],g);break;case"source":$t("error",g);break;case"img":case"image":case"link":$t("error",g),$t("load",g);break;case"details":$t("toggle",g);break;case"input":Te(g,N),$t("invalid",g);break;case"select":g._wrapperState={wasMultiple:!!N.multiple},$t("invalid",g);break;case"textarea":pe(g,N),$t("invalid",g)}ct(d,N),x=null;for(var L in N)if(N.hasOwnProperty(L)){var J=N[L];L==="children"?typeof J=="string"?g.textContent!==J&&(N.suppressHydrationWarning!==!0&&Mo(g.textContent,J,a),x=["children",J]):typeof J=="number"&&g.textContent!==""+J&&(N.suppressHydrationWarning!==!0&&Mo(g.textContent,J,a),x=["children",""+J]):s.hasOwnProperty(L)&&J!=null&&L==="onScroll"&&$t("scroll",g)}switch(d){case"input":Ie(g),ue(g,N,!0);break;case"textarea":Ie(g),fe(g);break;case"select":case"option":break;default:typeof N.onClick=="function"&&(g.onclick=Xi)}g=x,i.updateQueue=g,g!==null&&(i.flags|=4)}else{L=x.nodeType===9?x:x.ownerDocument,a==="http://www.w3.org/1999/xhtml"&&(a=Se(d)),a==="http://www.w3.org/1999/xhtml"?d==="script"?(a=L.createElement("div"),a.innerHTML="<script><\/script>",a=a.removeChild(a.firstChild)):typeof g.is=="string"?a=L.createElement(d,{is:g.is}):(a=L.createElement(d),d==="select"&&(L=a,g.multiple?L.multiple=!0:g.size&&(L.size=g.size))):a=L.createElementNS(a,d),a[Dn]=i,a[Oo]=g,n1(a,i,!1,!1),i.stateNode=a;e:{switch(L=yt(d,g),d){case"dialog":$t("cancel",a),$t("close",a),x=g;break;case"iframe":case"object":case"embed":$t("load",a),x=g;break;case"video":case"audio":for(x=0;x<Co.length;x++)$t(Co[x],a);x=g;break;case"source":$t("error",a),x=g;break;case"img":case"image":case"link":$t("error",a),$t("load",a),x=g;break;case"details":$t("toggle",a),x=g;break;case"input":Te(a,g),x=Be(a,g),$t("invalid",a);break;case"option":x=g;break;case"select":a._wrapperState={wasMultiple:!!g.multiple},x=W({},g,{value:void 0}),$t("invalid",a);break;case"textarea":pe(a,g),x=ce(a,g),$t("invalid",a);break;default:x=g}ct(d,x),J=x;for(N in J)if(J.hasOwnProperty(N)){var ae=J[N];N==="style"?rt(a,ae):N==="dangerouslySetInnerHTML"?(ae=ae?ae.__html:void 0,ae!=null&&ke(a,ae)):N==="children"?typeof ae=="string"?(d!=="textarea"||ae!=="")&&Re(a,ae):typeof ae=="number"&&Re(a,""+ae):N!=="suppressContentEditableWarning"&&N!=="suppressHydrationWarning"&&N!=="autoFocus"&&(s.hasOwnProperty(N)?ae!=null&&N==="onScroll"&&$t("scroll",a):ae!=null&&E(a,N,ae,L))}switch(d){case"input":Ie(a),ue(a,g,!1);break;case"textarea":Ie(a),fe(a);break;case"option":g.value!=null&&a.setAttribute("value",""+le(g.value));break;case"select":a.multiple=!!g.multiple,N=g.value,N!=null?Le(a,!!g.multiple,N,!1):g.defaultValue!=null&&Le(a,!!g.multiple,g.defaultValue,!0);break;default:typeof x.onClick=="function"&&(a.onclick=Xi)}switch(d){case"button":case"input":case"select":case"textarea":g=!!g.autoFocus;break e;case"img":g=!0;break e;default:g=!1}}g&&(i.flags|=4)}i.ref!==null&&(i.flags|=512,i.flags|=2097152)}return Rn(i),null;case 6:if(a&&i.stateNode!=null)s1(a,i,a.memoizedProps,g);else{if(typeof g!="string"&&i.stateNode===null)throw Error(n(166));if(d=Wo(Fc.current),Wo(Ct.current),il(i)){if(g=i.stateNode,d=i.memoizedProps,g[Dn]=i,(N=g.nodeValue!==d)&&(a=yn,a!==null))switch(a.tag){case 3:Mo(g.nodeValue,d,(a.mode&1)!==0);break;case 5:a.memoizedProps.suppressHydrationWarning!==!0&&Mo(g.nodeValue,d,(a.mode&1)!==0)}N&&(i.flags|=4)}else g=(d.nodeType===9?d:d.ownerDocument).createTextNode(g),g[Dn]=i,i.stateNode=g}return Rn(i),null;case 13:if(At(Ft),g=i.memoizedState,a===null||a.memoizedState!==null&&a.memoizedState.dehydrated!==null){if(St&&Bn!==null&&(i.mode&1)!==0&&(i.flags&128)===0)_d(),ta(),i.flags|=98560,N=!1;else if(N=il(i),g!==null&&g.dehydrated!==null){if(a===null){if(!N)throw Error(n(318));if(N=i.memoizedState,N=N!==null?N.dehydrated:null,!N)throw Error(n(317));N[Dn]=i}else ta(),(i.flags&128)===0&&(i.memoizedState=null),i.flags|=4;Rn(i),N=!1}else zn!==null&&(zp(zn),zn=null),N=!0;if(!N)return i.flags&65536?i:null}return(i.flags&128)!==0?(i.lanes=d,i):(g=g!==null,g!==(a!==null&&a.memoizedState!==null)&&g&&(i.child.flags|=8192,(i.mode&1)!==0&&(a===null||(Ft.current&1)!==0?ln===0&&(ln=3):Wp())),i.updateQueue!==null&&(i.flags|=4),Rn(i),null);case 4:return cl(),Ap(a,i),a===null&&Qr(i.stateNode.containerInfo),Rn(i),null;case 10:return _e(i.type._context),Rn(i),null;case 17:return gn(i.type)&&Do(),Rn(i),null;case 19:if(At(Ft),N=i.memoizedState,N===null)return Rn(i),null;if(g=(i.flags&128)!==0,L=N.rendering,L===null)if(g)Hc(N,!1);else{if(ln!==0||a!==null&&(a.flags&128)!==0)for(a=i.child;a!==null;){if(L=Cd(a),L!==null){for(i.flags|=128,Hc(N,!1),g=L.updateQueue,g!==null&&(i.updateQueue=g,i.flags|=4),i.subtreeFlags=0,g=d,d=i.child;d!==null;)N=d,a=g,N.flags&=14680066,L=N.alternate,L===null?(N.childLanes=0,N.lanes=a,N.child=null,N.subtreeFlags=0,N.memoizedProps=null,N.memoizedState=null,N.updateQueue=null,N.dependencies=null,N.stateNode=null):(N.childLanes=L.childLanes,N.lanes=L.lanes,N.child=L.child,N.subtreeFlags=0,N.deletions=null,N.memoizedProps=L.memoizedProps,N.memoizedState=L.memoizedState,N.updateQueue=L.updateQueue,N.type=L.type,a=L.dependencies,N.dependencies=a===null?null:{lanes:a.lanes,firstContext:a.firstContext}),d=d.sibling;return Mt(Ft,Ft.current&1|2),i.child}a=a.sibling}N.tail!==null&&Rt()>fl&&(i.flags|=128,g=!0,Hc(N,!1),i.lanes=4194304)}else{if(!g)if(a=Cd(L),a!==null){if(i.flags|=128,g=!0,d=a.updateQueue,d!==null&&(i.updateQueue=d,i.flags|=4),Hc(N,!0),N.tail===null&&N.tailMode==="hidden"&&!L.alternate&&!St)return Rn(i),null}else 2*Rt()-N.renderingStartTime>fl&&d!==1073741824&&(i.flags|=128,g=!0,Hc(N,!1),i.lanes=4194304);N.isBackwards?(L.sibling=i.child,i.child=L):(d=N.last,d!==null?d.sibling=L:i.child=L,N.last=L)}return N.tail!==null?(i=N.tail,N.rendering=i,N.tail=i.sibling,N.renderingStartTime=Rt(),i.sibling=null,d=Ft.current,Mt(Ft,g?d&1|2:d&1),i):(Rn(i),null);case 22:case 23:return Hp(),g=i.memoizedState!==null,a!==null&&a.memoizedState!==null!==g&&(i.flags|=8192),g&&(i.mode&1)!==0?(pr&1073741824)!==0&&(Rn(i),i.subtreeFlags&6&&(i.flags|=8192)):Rn(i),null;case 24:return null;case 25:return null}throw Error(n(156,i.tag))}function tO(a,i){switch(sl(i),i.tag){case 1:return gn(i.type)&&Do(),a=i.flags,a&65536?(i.flags=a&-65537|128,i):null;case 3:return cl(),At(bn),At(an),hp(),a=i.flags,(a&65536)!==0&&(a&128)===0?(i.flags=a&-65537|128,i):null;case 5:return up(i),null;case 13:if(At(Ft),a=i.memoizedState,a!==null&&a.dehydrated!==null){if(i.alternate===null)throw Error(n(340));ta()}return a=i.flags,a&65536?(i.flags=a&-65537|128,i):null;case 19:return At(Ft),null;case 4:return cl(),null;case 10:return _e(i.type._context),null;case 22:case 23:return Hp(),null;case 24:return null;default:return null}}var Pd=!1,An=!1,nO=typeof WeakSet=="function"?WeakSet:Set,Ke=null;function dl(a,i){var d=a.ref;if(d!==null)if(typeof d=="function")try{d(null)}catch(g){Ht(a,i,g)}else d.current=null}function Mp(a,i,d){try{d()}catch(g){Ht(a,i,g)}}var a1=!1;function rO(a,i){if(Tc=dr,a=Wi(),Nc(a)){if("selectionStart"in a)var d={start:a.selectionStart,end:a.selectionEnd};else e:{d=(d=a.ownerDocument)&&d.defaultView||window;var g=d.getSelection&&d.getSelection();if(g&&g.rangeCount!==0){d=g.anchorNode;var x=g.anchorOffset,N=g.focusNode;g=g.focusOffset;try{d.nodeType,N.nodeType}catch{d=null;break e}var L=0,J=-1,ae=-1,we=0,Ce=0,Me=a,Ee=null;t:for(;;){for(var He;Me!==d||x!==0&&Me.nodeType!==3||(J=L+x),Me!==N||g!==0&&Me.nodeType!==3||(ae=L+g),Me.nodeType===3&&(L+=Me.nodeValue.length),(He=Me.firstChild)!==null;)Ee=Me,Me=He;for(;;){if(Me===a)break t;if(Ee===d&&++we===x&&(J=L),Ee===N&&++Ce===g&&(ae=L),(He=Me.nextSibling)!==null)break;Me=Ee,Ee=Me.parentNode}Me=He}d=J===-1||ae===-1?null:{start:J,end:ae}}else d=null}d=d||{start:0,end:0}}else d=null;for(Jr={focusedElem:a,selectionRange:d},dr=!1,Ke=i;Ke!==null;)if(i=Ke,a=i.child,(i.subtreeFlags&1028)!==0&&a!==null)a.return=i,Ke=a;else for(;Ke!==null;){i=Ke;try{var Xe=i.alternate;if((i.flags&1024)!==0)switch(i.tag){case 0:case 11:case 15:break;case 1:if(Xe!==null){var Qe=Xe.memoizedProps,Yt=Xe.memoizedState,he=i.stateNode,oe=he.getSnapshotBeforeUpdate(i.elementType===i.type?Qe:is(i.type,Qe),Yt);he.__reactInternalSnapshotBeforeUpdate=oe}break;case 3:var me=i.stateNode.containerInfo;me.nodeType===1?me.textContent="":me.nodeType===9&&me.documentElement&&me.removeChild(me.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch($e){Ht(i,i.return,$e)}if(a=i.sibling,a!==null){a.return=i.return,Ke=a;break}Ke=i.return}return Xe=a1,a1=!1,Xe}function Wc(a,i,d){var g=i.updateQueue;if(g=g!==null?g.lastEffect:null,g!==null){var x=g=g.next;do{if((x.tag&a)===a){var N=x.destroy;x.destroy=void 0,N!==void 0&&Mp(i,d,N)}x=x.next}while(x!==g)}}function Dd(a,i){if(i=i.updateQueue,i=i!==null?i.lastEffect:null,i!==null){var d=i=i.next;do{if((d.tag&a)===a){var g=d.create;d.destroy=g()}d=d.next}while(d!==i)}}function Ip(a){var i=a.ref;if(i!==null){var d=a.stateNode;switch(a.tag){case 5:a=d;break;default:a=d}typeof i=="function"?i(a):i.current=a}}function o1(a){var i=a.alternate;i!==null&&(a.alternate=null,o1(i)),a.child=null,a.deletions=null,a.sibling=null,a.tag===5&&(i=a.stateNode,i!==null&&(delete i[Dn],delete i[Oo],delete i[Qi],delete i[lp],delete i[Nd])),a.stateNode=null,a.return=null,a.dependencies=null,a.memoizedProps=null,a.memoizedState=null,a.pendingProps=null,a.stateNode=null,a.updateQueue=null}function i1(a){return a.tag===5||a.tag===3||a.tag===4}function l1(a){e:for(;;){for(;a.sibling===null;){if(a.return===null||i1(a.return))return null;a=a.return}for(a.sibling.return=a.return,a=a.sibling;a.tag!==5&&a.tag!==6&&a.tag!==18;){if(a.flags&2||a.child===null||a.tag===4)continue e;a.child.return=a,a=a.child}if(!(a.flags&2))return a.stateNode}}function $p(a,i,d){var g=a.tag;if(g===5||g===6)a=a.stateNode,i?d.nodeType===8?d.parentNode.insertBefore(a,i):d.insertBefore(a,i):(d.nodeType===8?(i=d.parentNode,i.insertBefore(a,d)):(i=d,i.appendChild(a)),d=d._reactRootContainer,d!=null||i.onclick!==null||(i.onclick=Xi));else if(g!==4&&(a=a.child,a!==null))for($p(a,i,d),a=a.sibling;a!==null;)$p(a,i,d),a=a.sibling}function Op(a,i,d){var g=a.tag;if(g===5||g===6)a=a.stateNode,i?d.insertBefore(a,i):d.appendChild(a);else if(g!==4&&(a=a.child,a!==null))for(Op(a,i,d),a=a.sibling;a!==null;)Op(a,i,d),a=a.sibling}var Nn=null,ls=!1;function Da(a,i,d){for(d=d.child;d!==null;)c1(a,i,d),d=d.sibling}function c1(a,i,d){if(sn&&typeof sn.onCommitFiberUnmount=="function")try{sn.onCommitFiberUnmount(ur,d)}catch{}switch(d.tag){case 5:An||dl(d,i);case 6:var g=Nn,x=ls;Nn=null,Da(a,i,d),Nn=g,ls=x,Nn!==null&&(ls?(a=Nn,d=d.stateNode,a.nodeType===8?a.parentNode.removeChild(d):a.removeChild(d)):Nn.removeChild(d.stateNode));break;case 18:Nn!==null&&(ls?(a=Nn,d=d.stateNode,a.nodeType===8?$o(a.parentNode,d):a.nodeType===1&&$o(a,d),ya(a)):$o(Nn,d.stateNode));break;case 4:g=Nn,x=ls,Nn=d.stateNode.containerInfo,ls=!0,Da(a,i,d),Nn=g,ls=x;break;case 0:case 11:case 14:case 15:if(!An&&(g=d.updateQueue,g!==null&&(g=g.lastEffect,g!==null))){x=g=g.next;do{var N=x,L=N.destroy;N=N.tag,L!==void 0&&((N&2)!==0||(N&4)!==0)&&Mp(d,i,L),x=x.next}while(x!==g)}Da(a,i,d);break;case 1:if(!An&&(dl(d,i),g=d.stateNode,typeof g.componentWillUnmount=="function"))try{g.props=d.memoizedProps,g.state=d.memoizedState,g.componentWillUnmount()}catch(J){Ht(d,i,J)}Da(a,i,d);break;case 21:Da(a,i,d);break;case 22:d.mode&1?(An=(g=An)||d.memoizedState!==null,Da(a,i,d),An=g):Da(a,i,d);break;default:Da(a,i,d)}}function u1(a){var i=a.updateQueue;if(i!==null){a.updateQueue=null;var d=a.stateNode;d===null&&(d=a.stateNode=new nO),i.forEach(function(g){var x=hO.bind(null,a,g);d.has(g)||(d.add(g),g.then(x,x))})}}function cs(a,i){var d=i.deletions;if(d!==null)for(var g=0;g<d.length;g++){var x=d[g];try{var N=a,L=i,J=L;e:for(;J!==null;){switch(J.tag){case 5:Nn=J.stateNode,ls=!1;break e;case 3:Nn=J.stateNode.containerInfo,ls=!0;break e;case 4:Nn=J.stateNode.containerInfo,ls=!0;break e}J=J.return}if(Nn===null)throw Error(n(160));c1(N,L,x),Nn=null,ls=!1;var ae=x.alternate;ae!==null&&(ae.return=null),x.return=null}catch(we){Ht(x,i,we)}}if(i.subtreeFlags&12854)for(i=i.child;i!==null;)d1(i,a),i=i.sibling}function d1(a,i){var d=a.alternate,g=a.flags;switch(a.tag){case 0:case 11:case 14:case 15:if(cs(i,a),Os(a),g&4){try{Wc(3,a,a.return),Dd(3,a)}catch(Qe){Ht(a,a.return,Qe)}try{Wc(5,a,a.return)}catch(Qe){Ht(a,a.return,Qe)}}break;case 1:cs(i,a),Os(a),g&512&&d!==null&&dl(d,d.return);break;case 5:if(cs(i,a),Os(a),g&512&&d!==null&&dl(d,d.return),a.flags&32){var x=a.stateNode;try{Re(x,"")}catch(Qe){Ht(a,a.return,Qe)}}if(g&4&&(x=a.stateNode,x!=null)){var N=a.memoizedProps,L=d!==null?d.memoizedProps:N,J=a.type,ae=a.updateQueue;if(a.updateQueue=null,ae!==null)try{J==="input"&&N.type==="radio"&&N.name!=null&&st(x,N),yt(J,L);var we=yt(J,N);for(L=0;L<ae.length;L+=2){var Ce=ae[L],Me=ae[L+1];Ce==="style"?rt(x,Me):Ce==="dangerouslySetInnerHTML"?ke(x,Me):Ce==="children"?Re(x,Me):E(x,Ce,Me,we)}switch(J){case"input":de(x,N);break;case"textarea":Ae(x,N);break;case"select":var Ee=x._wrapperState.wasMultiple;x._wrapperState.wasMultiple=!!N.multiple;var He=N.value;He!=null?Le(x,!!N.multiple,He,!1):Ee!==!!N.multiple&&(N.defaultValue!=null?Le(x,!!N.multiple,N.defaultValue,!0):Le(x,!!N.multiple,N.multiple?[]:"",!1))}x[Oo]=N}catch(Qe){Ht(a,a.return,Qe)}}break;case 6:if(cs(i,a),Os(a),g&4){if(a.stateNode===null)throw Error(n(162));x=a.stateNode,N=a.memoizedProps;try{x.nodeValue=N}catch(Qe){Ht(a,a.return,Qe)}}break;case 3:if(cs(i,a),Os(a),g&4&&d!==null&&d.memoizedState.isDehydrated)try{ya(i.containerInfo)}catch(Qe){Ht(a,a.return,Qe)}break;case 4:cs(i,a),Os(a);break;case 13:cs(i,a),Os(a),x=a.child,x.flags&8192&&(N=x.memoizedState!==null,x.stateNode.isHidden=N,!N||x.alternate!==null&&x.alternate.memoizedState!==null||(Dp=Rt())),g&4&&u1(a);break;case 22:if(Ce=d!==null&&d.memoizedState!==null,a.mode&1?(An=(we=An)||Ce,cs(i,a),An=we):cs(i,a),Os(a),g&8192){if(we=a.memoizedState!==null,(a.stateNode.isHidden=we)&&!Ce&&(a.mode&1)!==0)for(Ke=a,Ce=a.child;Ce!==null;){for(Me=Ke=Ce;Ke!==null;){switch(Ee=Ke,He=Ee.child,Ee.tag){case 0:case 11:case 14:case 15:Wc(4,Ee,Ee.return);break;case 1:dl(Ee,Ee.return);var Xe=Ee.stateNode;if(typeof Xe.componentWillUnmount=="function"){g=Ee,d=Ee.return;try{i=g,Xe.props=i.memoizedProps,Xe.state=i.memoizedState,Xe.componentWillUnmount()}catch(Qe){Ht(g,d,Qe)}}break;case 5:dl(Ee,Ee.return);break;case 22:if(Ee.memoizedState!==null){p1(Me);continue}}He!==null?(He.return=Ee,Ke=He):p1(Me)}Ce=Ce.sibling}e:for(Ce=null,Me=a;;){if(Me.tag===5){if(Ce===null){Ce=Me;try{x=Me.stateNode,we?(N=x.style,typeof N.setProperty=="function"?N.setProperty("display","none","important"):N.display="none"):(J=Me.stateNode,ae=Me.memoizedProps.style,L=ae!=null&&ae.hasOwnProperty("display")?ae.display:null,J.style.display=We("display",L))}catch(Qe){Ht(a,a.return,Qe)}}}else if(Me.tag===6){if(Ce===null)try{Me.stateNode.nodeValue=we?"":Me.memoizedProps}catch(Qe){Ht(a,a.return,Qe)}}else if((Me.tag!==22&&Me.tag!==23||Me.memoizedState===null||Me===a)&&Me.child!==null){Me.child.return=Me,Me=Me.child;continue}if(Me===a)break e;for(;Me.sibling===null;){if(Me.return===null||Me.return===a)break e;Ce===Me&&(Ce=null),Me=Me.return}Ce===Me&&(Ce=null),Me.sibling.return=Me.return,Me=Me.sibling}}break;case 19:cs(i,a),Os(a),g&4&&u1(a);break;case 21:break;default:cs(i,a),Os(a)}}function Os(a){var i=a.flags;if(i&2){try{e:{for(var d=a.return;d!==null;){if(i1(d)){var g=d;break e}d=d.return}throw Error(n(160))}switch(g.tag){case 5:var x=g.stateNode;g.flags&32&&(Re(x,""),g.flags&=-33);var N=l1(a);Op(a,N,x);break;case 3:case 4:var L=g.stateNode.containerInfo,J=l1(a);$p(a,J,L);break;default:throw Error(n(161))}}catch(ae){Ht(a,a.return,ae)}a.flags&=-3}i&4096&&(a.flags&=-4097)}function sO(a,i,d){Ke=a,h1(a)}function h1(a,i,d){for(var g=(a.mode&1)!==0;Ke!==null;){var x=Ke,N=x.child;if(x.tag===22&&g){var L=x.memoizedState!==null||Pd;if(!L){var J=x.alternate,ae=J!==null&&J.memoizedState!==null||An;J=Pd;var we=An;if(Pd=L,(An=ae)&&!we)for(Ke=x;Ke!==null;)L=Ke,ae=L.child,L.tag===22&&L.memoizedState!==null?m1(x):ae!==null?(ae.return=L,Ke=ae):m1(x);for(;N!==null;)Ke=N,h1(N),N=N.sibling;Ke=x,Pd=J,An=we}f1(a)}else(x.subtreeFlags&8772)!==0&&N!==null?(N.return=x,Ke=N):f1(a)}}function f1(a){for(;Ke!==null;){var i=Ke;if((i.flags&8772)!==0){var d=i.alternate;try{if((i.flags&8772)!==0)switch(i.tag){case 0:case 11:case 15:An||Dd(5,i);break;case 1:var g=i.stateNode;if(i.flags&4&&!An)if(d===null)g.componentDidMount();else{var x=i.elementType===i.type?d.memoizedProps:is(i.type,d.memoizedProps);g.componentDidUpdate(x,d.memoizedState,g.__reactInternalSnapshotBeforeUpdate)}var N=i.updateQueue;N!==null&&La(i,N,g);break;case 3:var L=i.updateQueue;if(L!==null){if(d=null,i.child!==null)switch(i.child.tag){case 5:d=i.child.stateNode;break;case 1:d=i.child.stateNode}La(i,L,d)}break;case 5:var J=i.stateNode;if(d===null&&i.flags&4){d=J;var ae=i.memoizedProps;switch(i.type){case"button":case"input":case"select":case"textarea":ae.autoFocus&&d.focus();break;case"img":ae.src&&(d.src=ae.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(i.memoizedState===null){var we=i.alternate;if(we!==null){var Ce=we.memoizedState;if(Ce!==null){var Me=Ce.dehydrated;Me!==null&&ya(Me)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}An||i.flags&512&&Ip(i)}catch(Ee){Ht(i,i.return,Ee)}}if(i===a){Ke=null;break}if(d=i.sibling,d!==null){d.return=i.return,Ke=d;break}Ke=i.return}}function p1(a){for(;Ke!==null;){var i=Ke;if(i===a){Ke=null;break}var d=i.sibling;if(d!==null){d.return=i.return,Ke=d;break}Ke=i.return}}function m1(a){for(;Ke!==null;){var i=Ke;try{switch(i.tag){case 0:case 11:case 15:var d=i.return;try{Dd(4,i)}catch(ae){Ht(i,d,ae)}break;case 1:var g=i.stateNode;if(typeof g.componentDidMount=="function"){var x=i.return;try{g.componentDidMount()}catch(ae){Ht(i,x,ae)}}var N=i.return;try{Ip(i)}catch(ae){Ht(i,N,ae)}break;case 5:var L=i.return;try{Ip(i)}catch(ae){Ht(i,L,ae)}}}catch(ae){Ht(i,i.return,ae)}if(i===a){Ke=null;break}var J=i.sibling;if(J!==null){J.return=i.return,Ke=J;break}Ke=i.return}}var aO=Math.ceil,Fd=C.ReactCurrentDispatcher,Lp=C.ReactCurrentOwner,Ir=C.ReactCurrentBatchConfig,kt=0,vn=null,en=null,Sn=0,pr=0,hl=Cr(0),ln=0,Vc=null,Go=0,qd=0,Pp=0,Gc=null,tr=null,Dp=0,fl=1/0,aa=null,Bd=!1,Fp=null,Fa=null,zd=!1,qa=null,Ud=0,Kc=0,qp=null,Hd=-1,Wd=0;function Hn(){return(kt&6)!==0?Rt():Hd!==-1?Hd:Hd=Rt()}function Ba(a){return(a.mode&1)===0?1:(kt&2)!==0&&Sn!==0?Sn&-Sn:$c.transition!==null?(Wd===0&&(Wd=ma()),Wd):(a=ft,a!==0||(a=window.event,a=a===void 0?16:wa(a.type)),a)}function us(a,i,d,g){if(50<Kc)throw Kc=0,qp=null,Error(n(185));uo(a,d,g),((kt&2)===0||a!==vn)&&(a===vn&&((kt&2)===0&&(qd|=d),ln===4&&za(a,Sn)),nr(a,g),d===1&&kt===0&&(i.mode&1)===0&&(fl=Rt()+500,tl&&Tr()))}function nr(a,i){var d=a.callbackNode;Si(a,i);var g=Kn(a,a===vn?Sn:0);if(g===0)d!==null&&wt(d),a.callbackNode=null,a.callbackPriority=0;else if(i=g&-g,a.callbackPriority!==i){if(d!=null&&wt(d),i===1)a.tag===0?nl(y1.bind(null,a)):Ac(y1.bind(null,a)),Cn(function(){(kt&6)===0&&Tr()}),d=null;else{switch(Qu(g)){case 1:d=Nt;break;case 4:d=br;break;case 16:d=cr;break;case 536870912:d=ht;break;default:d=cr}d=j1(d,g1.bind(null,a))}a.callbackPriority=i,a.callbackNode=d}}function g1(a,i){if(Hd=-1,Wd=0,(kt&6)!==0)throw Error(n(327));var d=a.callbackNode;if(pl()&&a.callbackNode!==d)return null;var g=Kn(a,a===vn?Sn:0);if(g===0)return null;if((g&30)!==0||(g&a.expiredLanes)!==0||i)i=Vd(a,g);else{i=g;var x=kt;kt|=2;var N=v1();(vn!==a||Sn!==i)&&(aa=null,fl=Rt()+500,Yo(a,i));do try{lO();break}catch(J){w1(a,J)}while(!0);ye(),Fd.current=N,kt=x,en!==null?i=0:(vn=null,Sn=0,i=ln)}if(i!==0){if(i===2&&(x=co(a),x!==0&&(g=x,i=Bp(a,x))),i===1)throw d=Vc,Yo(a,0),za(a,g),nr(a,Rt()),d;if(i===6)za(a,g);else{if(x=a.current.alternate,(g&30)===0&&!oO(x)&&(i=Vd(a,g),i===2&&(N=co(a),N!==0&&(g=N,i=Bp(a,N))),i===1))throw d=Vc,Yo(a,0),za(a,g),nr(a,Rt()),d;switch(a.finishedWork=x,a.finishedLanes=g,i){case 0:case 1:throw Error(n(345));case 2:Xo(a,tr,aa);break;case 3:if(za(a,g),(g&130023424)===g&&(i=Dp+500-Rt(),10<i)){if(Kn(a,0)!==0)break;if(x=a.suspendedLanes,(x&g)!==g){Hn(),a.pingedLanes|=a.suspendedLanes&x;break}a.timeoutHandle=Rc(Xo.bind(null,a,tr,aa),i);break}Xo(a,tr,aa);break;case 4:if(za(a,g),(g&4194240)===g)break;for(i=a.eventTimes,x=-1;0<g;){var L=31-Gn(g);N=1<<L,L=i[L],L>x&&(x=L),g&=~N}if(g=x,g=Rt()-g,g=(120>g?120:480>g?480:1080>g?1080:1920>g?1920:3e3>g?3e3:4320>g?4320:1960*aO(g/1960))-g,10<g){a.timeoutHandle=Rc(Xo.bind(null,a,tr,aa),g);break}Xo(a,tr,aa);break;case 5:Xo(a,tr,aa);break;default:throw Error(n(329))}}}return nr(a,Rt()),a.callbackNode===d?g1.bind(null,a):null}function Bp(a,i){var d=Gc;return a.current.memoizedState.isDehydrated&&(Yo(a,i).flags|=256),a=Vd(a,i),a!==2&&(i=tr,tr=d,i!==null&&zp(i)),a}function zp(a){tr===null?tr=a:tr.push.apply(tr,a)}function oO(a){for(var i=a;;){if(i.flags&16384){var d=i.updateQueue;if(d!==null&&(d=d.stores,d!==null))for(var g=0;g<d.length;g++){var x=d[g],N=x.getSnapshot;x=x.value;try{if(!Xn(N(),x))return!1}catch{return!1}}}if(d=i.child,i.subtreeFlags&16384&&d!==null)d.return=i,i=d;else{if(i===a)break;for(;i.sibling===null;){if(i.return===null||i.return===a)return!0;i=i.return}i.sibling.return=i.return,i=i.sibling}}return!0}function za(a,i){for(i&=~Pp,i&=~qd,a.suspendedLanes|=i,a.pingedLanes&=~i,a=a.expirationTimes;0<i;){var d=31-Gn(i),g=1<<d;a[d]=-1,i&=~g}}function y1(a){if((kt&6)!==0)throw Error(n(327));pl();var i=Kn(a,0);if((i&1)===0)return nr(a,Rt()),null;var d=Vd(a,i);if(a.tag!==0&&d===2){var g=co(a);g!==0&&(i=g,d=Bp(a,g))}if(d===1)throw d=Vc,Yo(a,0),za(a,i),nr(a,Rt()),d;if(d===6)throw Error(n(345));return a.finishedWork=a.current.alternate,a.finishedLanes=i,Xo(a,tr,aa),nr(a,Rt()),null}function Up(a,i){var d=kt;kt|=1;try{return a(i)}finally{kt=d,kt===0&&(fl=Rt()+500,tl&&Tr())}}function Ko(a){qa!==null&&qa.tag===0&&(kt&6)===0&&pl();var i=kt;kt|=1;var d=Ir.transition,g=ft;try{if(Ir.transition=null,ft=1,a)return a()}finally{ft=g,Ir.transition=d,kt=i,(kt&6)===0&&Tr()}}function Hp(){pr=hl.current,At(hl)}function Yo(a,i){a.finishedWork=null,a.finishedLanes=0;var d=a.timeoutHandle;if(d!==-1&&(a.timeoutHandle=-1,ip(d)),en!==null)for(d=en.return;d!==null;){var g=d;switch(sl(g),g.tag){case 1:g=g.type.childContextTypes,g!=null&&Do();break;case 3:cl(),At(bn),At(an),hp();break;case 5:up(g);break;case 4:cl();break;case 13:At(Ft);break;case 19:At(Ft);break;case 10:_e(g.type._context);break;case 22:case 23:Hp()}d=d.return}if(vn=a,en=a=Ua(a.current,null),Sn=pr=i,ln=0,Vc=null,Pp=qd=Go=0,tr=Gc=null,Ze!==null){for(i=0;i<Ze.length;i++)if(d=Ze[i],g=d.interleaved,g!==null){d.interleaved=null;var x=g.next,N=d.pending;if(N!==null){var L=N.next;N.next=x,g.next=L}d.pending=g}Ze=null}return a}function w1(a,i){do{var d=en;try{if(ye(),Td.current=Id,Rd){for(var g=qt.memoizedState;g!==null;){var x=g.queue;x!==null&&(x.pending=null),g=g.next}Rd=!1}if(Vo=0,wn=on=qt=null,qc=!1,Bc=0,Lp.current=null,d===null||d.return===null){ln=1,Vc=i,en=null;break}e:{var N=a,L=d.return,J=d,ae=i;if(i=Sn,J.flags|=32768,ae!==null&&typeof ae=="object"&&typeof ae.then=="function"){var we=ae,Ce=J,Me=Ce.tag;if((Ce.mode&1)===0&&(Me===0||Me===11||Me===15)){var Ee=Ce.alternate;Ee?(Ce.updateQueue=Ee.updateQueue,Ce.memoizedState=Ee.memoizedState,Ce.lanes=Ee.lanes):(Ce.updateQueue=null,Ce.memoizedState=null)}var He=Uk(L);if(He!==null){He.flags&=-257,Hk(He,L,J,N,i),He.mode&1&&zk(N,we,i),i=He,ae=we;var Xe=i.updateQueue;if(Xe===null){var Qe=new Set;Qe.add(ae),i.updateQueue=Qe}else Xe.add(ae);break e}else{if((i&1)===0){zk(N,we,i),Wp();break e}ae=Error(n(426))}}else if(St&&J.mode&1){var Yt=Uk(L);if(Yt!==null){(Yt.flags&65536)===0&&(Yt.flags|=256),Hk(Yt,L,J,N,i),na(ul(ae,J));break e}}N=ae=ul(ae,J),ln!==4&&(ln=2),Gc===null?Gc=[N]:Gc.push(N),N=L;do{switch(N.tag){case 3:N.flags|=65536,i&=-i,N.lanes|=i;var he=qk(N,ae,i);Dc(N,he);break e;case 1:J=ae;var oe=N.type,me=N.stateNode;if((N.flags&128)===0&&(typeof oe.getDerivedStateFromError=="function"||me!==null&&typeof me.componentDidCatch=="function"&&(Fa===null||!Fa.has(me)))){N.flags|=65536,i&=-i,N.lanes|=i;var $e=Bk(N,J,i);Dc(N,$e);break e}}N=N.return}while(N!==null)}b1(d)}catch(Je){i=Je,en===d&&d!==null&&(en=d=d.return);continue}break}while(!0)}function v1(){var a=Fd.current;return Fd.current=Id,a===null?Id:a}function Wp(){(ln===0||ln===3||ln===2)&&(ln=4),vn===null||(Go&268435455)===0&&(qd&268435455)===0||za(vn,Sn)}function Vd(a,i){var d=kt;kt|=2;var g=v1();(vn!==a||Sn!==i)&&(aa=null,Yo(a,i));do try{iO();break}catch(x){w1(a,x)}while(!0);if(ye(),kt=d,Fd.current=g,en!==null)throw Error(n(261));return vn=null,Sn=0,ln}function iO(){for(;en!==null;)x1(en)}function lO(){for(;en!==null&&!gt();)x1(en)}function x1(a){var i=S1(a.alternate,a,pr);a.memoizedProps=a.pendingProps,i===null?b1(a):en=i,Lp.current=null}function b1(a){var i=a;do{var d=i.alternate;if(a=i.return,(i.flags&32768)===0){if(d=eO(d,i,pr),d!==null){en=d;return}}else{if(d=tO(d,i),d!==null){d.flags&=32767,en=d;return}if(a!==null)a.flags|=32768,a.subtreeFlags=0,a.deletions=null;else{ln=6,en=null;return}}if(i=i.sibling,i!==null){en=i;return}en=i=a}while(i!==null);ln===0&&(ln=5)}function Xo(a,i,d){var g=ft,x=Ir.transition;try{Ir.transition=null,ft=1,cO(a,i,d,g)}finally{Ir.transition=x,ft=g}return null}function cO(a,i,d,g){do pl();while(qa!==null);if((kt&6)!==0)throw Error(n(327));d=a.finishedWork;var x=a.finishedLanes;if(d===null)return null;if(a.finishedWork=null,a.finishedLanes=0,d===a.current)throw Error(n(177));a.callbackNode=null,a.callbackPriority=0;var N=d.lanes|d.childLanes;if(Qf(a,N),a===vn&&(en=vn=null,Sn=0),(d.subtreeFlags&2064)===0&&(d.flags&2064)===0||zd||(zd=!0,j1(cr,function(){return pl(),null})),N=(d.flags&15990)!==0,(d.subtreeFlags&15990)!==0||N){N=Ir.transition,Ir.transition=null;var L=ft;ft=1;var J=kt;kt|=4,Lp.current=null,rO(a,d),d1(d,a),Xs(Jr),dr=!!Tc,Jr=Tc=null,a.current=d,sO(d),It(),kt=J,ft=L,Ir.transition=N}else a.current=d;if(zd&&(zd=!1,qa=a,Ud=x),N=a.pendingLanes,N===0&&(Fa=null),Vr(d.stateNode),nr(a,Rt()),i!==null)for(g=a.onRecoverableError,d=0;d<i.length;d++)x=i[d],g(x.value,{componentStack:x.stack,digest:x.digest});if(Bd)throw Bd=!1,a=Fp,Fp=null,a;return(Ud&1)!==0&&a.tag!==0&&pl(),N=a.pendingLanes,(N&1)!==0?a===qp?Kc++:(Kc=0,qp=a):Kc=0,Tr(),null}function pl(){if(qa!==null){var a=Qu(Ud),i=Ir.transition,d=ft;try{if(Ir.transition=null,ft=16>a?16:a,qa===null)var g=!1;else{if(a=qa,qa=null,Ud=0,(kt&6)!==0)throw Error(n(331));var x=kt;for(kt|=4,Ke=a.current;Ke!==null;){var N=Ke,L=N.child;if((Ke.flags&16)!==0){var J=N.deletions;if(J!==null){for(var ae=0;ae<J.length;ae++){var we=J[ae];for(Ke=we;Ke!==null;){var Ce=Ke;switch(Ce.tag){case 0:case 11:case 15:Wc(8,Ce,N)}var Me=Ce.child;if(Me!==null)Me.return=Ce,Ke=Me;else for(;Ke!==null;){Ce=Ke;var Ee=Ce.sibling,He=Ce.return;if(o1(Ce),Ce===we){Ke=null;break}if(Ee!==null){Ee.return=He,Ke=Ee;break}Ke=He}}}var Xe=N.alternate;if(Xe!==null){var Qe=Xe.child;if(Qe!==null){Xe.child=null;do{var Yt=Qe.sibling;Qe.sibling=null,Qe=Yt}while(Qe!==null)}}Ke=N}}if((N.subtreeFlags&2064)!==0&&L!==null)L.return=N,Ke=L;else e:for(;Ke!==null;){if(N=Ke,(N.flags&2048)!==0)switch(N.tag){case 0:case 11:case 15:Wc(9,N,N.return)}var he=N.sibling;if(he!==null){he.return=N.return,Ke=he;break e}Ke=N.return}}var oe=a.current;for(Ke=oe;Ke!==null;){L=Ke;var me=L.child;if((L.subtreeFlags&2064)!==0&&me!==null)me.return=L,Ke=me;else e:for(L=oe;Ke!==null;){if(J=Ke,(J.flags&2048)!==0)try{switch(J.tag){case 0:case 11:case 15:Dd(9,J)}}catch(Je){Ht(J,J.return,Je)}if(J===L){Ke=null;break e}var $e=J.sibling;if($e!==null){$e.return=J.return,Ke=$e;break e}Ke=J.return}}if(kt=x,Tr(),sn&&typeof sn.onPostCommitFiberRoot=="function")try{sn.onPostCommitFiberRoot(ur,a)}catch{}g=!0}return g}finally{ft=d,Ir.transition=i}}return!1}function k1(a,i,d){i=ul(d,i),i=qk(a,i,1),a=Ar(a,i,1),i=Hn(),a!==null&&(uo(a,1,i),nr(a,i))}function Ht(a,i,d){if(a.tag===3)k1(a,a,d);else for(;i!==null;){if(i.tag===3){k1(i,a,d);break}else if(i.tag===1){var g=i.stateNode;if(typeof i.type.getDerivedStateFromError=="function"||typeof g.componentDidCatch=="function"&&(Fa===null||!Fa.has(g))){a=ul(d,a),a=Bk(i,a,1),i=Ar(i,a,1),a=Hn(),i!==null&&(uo(i,1,a),nr(i,a));break}}i=i.return}}function uO(a,i,d){var g=a.pingCache;g!==null&&g.delete(i),i=Hn(),a.pingedLanes|=a.suspendedLanes&d,vn===a&&(Sn&d)===d&&(ln===4||ln===3&&(Sn&130023424)===Sn&&500>Rt()-Dp?Yo(a,0):Pp|=d),nr(a,i)}function N1(a,i){i===0&&((a.mode&1)===0?i=1:(i=Ni,Ni<<=1,(Ni&130023424)===0&&(Ni=4194304)));var d=Hn();a=kn(a,i),a!==null&&(uo(a,i,d),nr(a,d))}function dO(a){var i=a.memoizedState,d=0;i!==null&&(d=i.retryLane),N1(a,d)}function hO(a,i){var d=0;switch(a.tag){case 13:var g=a.stateNode,x=a.memoizedState;x!==null&&(d=x.retryLane);break;case 19:g=a.stateNode;break;default:throw Error(n(314))}g!==null&&g.delete(i),N1(a,d)}var S1;S1=function(a,i,d){if(a!==null)if(a.memoizedProps!==i.pendingProps||bn.current)er=!0;else{if((a.lanes&d)===0&&(i.flags&128)===0)return er=!1,J$(a,i,d);er=(a.flags&131072)!==0}else er=!1,St&&(i.flags&1048576)!==0&&jd(i,qo,i.index);switch(i.lanes=0,i.tag){case 2:var g=i.type;Ld(a,i),a=i.pendingProps;var x=rs(i,an.current);Ve(i,d),x=mp(null,i,g,a,x,d);var N=gp();return i.flags|=1,typeof x=="object"&&x!==null&&typeof x.render=="function"&&x.$$typeof===void 0?(i.tag=1,i.memoizedState=null,i.updateQueue=null,gn(g)?(N=!0,el(i)):N=!1,i.memoizedState=x.state!==null&&x.state!==void 0?x.state:null,Oa(i),x.updater=$d,i.stateNode=x,x._reactInternals=i,kp(i,g,a,d),i=_p(null,i,g,!0,N,d)):(i.tag=0,St&&N&&rl(i),Un(null,i,x,d),i=i.child),i;case 16:g=i.elementType;e:{switch(Ld(a,i),a=i.pendingProps,x=g._init,g=x(g._payload),i.type=g,x=i.tag=pO(g),a=is(g,a),x){case 0:i=jp(null,i,g,a,d);break e;case 1:i=Xk(null,i,g,a,d);break e;case 11:i=Wk(null,i,g,a,d);break e;case 14:i=Vk(null,i,g,is(g.type,a),d);break e}throw Error(n(306,g,""))}return i;case 0:return g=i.type,x=i.pendingProps,x=i.elementType===g?x:is(g,x),jp(a,i,g,x,d);case 1:return g=i.type,x=i.pendingProps,x=i.elementType===g?x:is(g,x),Xk(a,i,g,x,d);case 3:e:{if(Zk(i),a===null)throw Error(n(387));g=i.pendingProps,N=i.memoizedState,x=N.element,Ed(a,i),Is(i,g,null,d);var L=i.memoizedState;if(g=L.element,N.isDehydrated)if(N={element:g,isDehydrated:!1,cache:L.cache,pendingSuspenseBoundaries:L.pendingSuspenseBoundaries,transitions:L.transitions},i.updateQueue.baseState=N,i.memoizedState=N,i.flags&256){x=ul(Error(n(423)),i),i=Qk(a,i,g,d,x);break e}else if(g!==x){x=ul(Error(n(424)),i),i=Qk(a,i,g,d,x);break e}else for(Bn=Es(i.stateNode.containerInfo.firstChild),yn=i,St=!0,zn=null,d=Pc(i,null,g,d),i.child=d;d;)d.flags=d.flags&-3|4096,d=d.sibling;else{if(ta(),g===x){i=sa(a,i,d);break e}Un(a,i,g,d)}i=i.child}return i;case 5:return mk(i),a===null&&ol(i),g=i.type,x=i.pendingProps,N=a!==null?a.memoizedProps:null,L=x.children,Io(g,x)?L=null:N!==null&&Io(g,N)&&(i.flags|=32),Yk(a,i),Un(a,i,L,d),i.child;case 6:return a===null&&ol(i),null;case 13:return Jk(a,i,d);case 4:return cp(i,i.stateNode.containerInfo),g=i.pendingProps,a===null?i.child=ra(i,null,g,d):Un(a,i,g,d),i.child;case 11:return g=i.type,x=i.pendingProps,x=i.elementType===g?x:is(g,x),Wk(a,i,g,x,d);case 7:return Un(a,i,i.pendingProps,d),i.child;case 8:return Un(a,i,i.pendingProps.children,d),i.child;case 12:return Un(a,i,i.pendingProps.children,d),i.child;case 10:e:{if(g=i.type._context,x=i.pendingProps,N=i.memoizedProps,L=x.value,Mt(T,g._currentValue),g._currentValue=L,N!==null)if(Xn(N.value,L)){if(N.children===x.children&&!bn.current){i=sa(a,i,d);break e}}else for(N=i.child,N!==null&&(N.return=i);N!==null;){var J=N.dependencies;if(J!==null){L=N.child;for(var ae=J.firstContext;ae!==null;){if(ae.context===g){if(N.tag===1){ae=Rr(-1,d&-d),ae.tag=2;var we=N.updateQueue;if(we!==null){we=we.shared;var Ce=we.pending;Ce===null?ae.next=ae:(ae.next=Ce.next,Ce.next=ae),we.pending=ae}}N.lanes|=d,ae=N.alternate,ae!==null&&(ae.lanes|=d),Oe(N.return,d,i),J.lanes|=d;break}ae=ae.next}}else if(N.tag===10)L=N.type===i.type?null:N.child;else if(N.tag===18){if(L=N.return,L===null)throw Error(n(341));L.lanes|=d,J=L.alternate,J!==null&&(J.lanes|=d),Oe(L,d,i),L=N.sibling}else L=N.child;if(L!==null)L.return=N;else for(L=N;L!==null;){if(L===i){L=null;break}if(N=L.sibling,N!==null){N.return=L.return,L=N;break}L=L.return}N=L}Un(a,i,x.children,d),i=i.child}return i;case 9:return x=i.type,g=i.pendingProps.children,Ve(i,d),x=it(x),g=g(x),i.flags|=1,Un(a,i,g,d),i.child;case 14:return g=i.type,x=is(g,i.pendingProps),x=is(g.type,x),Vk(a,i,g,x,d);case 15:return Gk(a,i,i.type,i.pendingProps,d);case 17:return g=i.type,x=i.pendingProps,x=i.elementType===g?x:is(g,x),Ld(a,i),i.tag=1,gn(g)?(a=!0,el(i)):a=!1,Ve(i,d),Dk(i,g,x),kp(i,g,x,d),_p(null,i,g,!0,a,d);case 19:return t1(a,i,d);case 22:return Kk(a,i,d)}throw Error(n(156,i.tag))};function j1(a,i){return tt(a,i)}function fO(a,i,d,g){this.tag=a,this.key=d,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=i,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=g,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function $r(a,i,d,g){return new fO(a,i,d,g)}function Vp(a){return a=a.prototype,!(!a||!a.isReactComponent)}function pO(a){if(typeof a=="function")return Vp(a)?1:0;if(a!=null){if(a=a.$$typeof,a===ne)return 11;if(a===Z)return 14}return 2}function Ua(a,i){var d=a.alternate;return d===null?(d=$r(a.tag,i,a.key,a.mode),d.elementType=a.elementType,d.type=a.type,d.stateNode=a.stateNode,d.alternate=a,a.alternate=d):(d.pendingProps=i,d.type=a.type,d.flags=0,d.subtreeFlags=0,d.deletions=null),d.flags=a.flags&14680064,d.childLanes=a.childLanes,d.lanes=a.lanes,d.child=a.child,d.memoizedProps=a.memoizedProps,d.memoizedState=a.memoizedState,d.updateQueue=a.updateQueue,i=a.dependencies,d.dependencies=i===null?null:{lanes:i.lanes,firstContext:i.firstContext},d.sibling=a.sibling,d.index=a.index,d.ref=a.ref,d}function Gd(a,i,d,g,x,N){var L=2;if(g=a,typeof a=="function")Vp(a)&&(L=1);else if(typeof a=="string")L=5;else e:switch(a){case O:return Zo(d.children,x,N,i);case H:L=8,x|=8;break;case q:return a=$r(12,d,i,x|2),a.elementType=q,a.lanes=N,a;case ee:return a=$r(13,d,i,x),a.elementType=ee,a.lanes=N,a;case M:return a=$r(19,d,i,x),a.elementType=M,a.lanes=N,a;case D:return Kd(d,x,N,i);default:if(typeof a=="object"&&a!==null)switch(a.$$typeof){case $:L=10;break e;case V:L=9;break e;case ne:L=11;break e;case Z:L=14;break e;case K:L=16,g=null;break e}throw Error(n(130,a==null?a:typeof a,""))}return i=$r(L,d,i,x),i.elementType=a,i.type=g,i.lanes=N,i}function Zo(a,i,d,g){return a=$r(7,a,g,i),a.lanes=d,a}function Kd(a,i,d,g){return a=$r(22,a,g,i),a.elementType=D,a.lanes=d,a.stateNode={isHidden:!1},a}function Gp(a,i,d){return a=$r(6,a,null,i),a.lanes=d,a}function Kp(a,i,d){return i=$r(4,a.children!==null?a.children:[],a.key,i),i.lanes=d,i.stateNode={containerInfo:a.containerInfo,pendingChildren:null,implementation:a.implementation},i}function mO(a,i,d,g,x){this.tag=i,this.containerInfo=a,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=oc(0),this.expirationTimes=oc(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=oc(0),this.identifierPrefix=g,this.onRecoverableError=x,this.mutableSourceEagerHydrationData=null}function Yp(a,i,d,g,x,N,L,J,ae){return a=new mO(a,i,d,J,ae),i===1?(i=1,N===!0&&(i|=8)):i=0,N=$r(3,null,null,i),a.current=N,N.stateNode=a,N.memoizedState={element:g,isDehydrated:d,cache:null,transitions:null,pendingSuspenseBoundaries:null},Oa(N),a}function gO(a,i,d){var g=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:I,key:g==null?null:""+g,children:a,containerInfo:i,implementation:d}}function _1(a){if(!a)return Zn;a=a._reactInternals;e:{if($n(a)!==a||a.tag!==1)throw Error(n(170));var i=a;do{switch(i.tag){case 3:i=i.stateNode.context;break e;case 1:if(gn(i.type)){i=i.stateNode.__reactInternalMemoizedMergedChildContext;break e}}i=i.return}while(i!==null);throw Error(n(171))}if(a.tag===1){var d=a.type;if(gn(d))return Fn(a,d,i)}return i}function E1(a,i,d,g,x,N,L,J,ae){return a=Yp(d,g,!0,a,x,N,L,J,ae),a.context=_1(null),d=a.current,g=Hn(),x=Ba(d),N=Rr(g,x),N.callback=i??null,Ar(d,N,x),a.current.lanes=x,uo(a,x,g),nr(a,g),a}function Yd(a,i,d,g){var x=i.current,N=Hn(),L=Ba(x);return d=_1(d),i.context===null?i.context=d:i.pendingContext=d,i=Rr(N,L),i.payload={element:a},g=g===void 0?null:g,g!==null&&(i.callback=g),a=Ar(x,i,L),a!==null&&(us(a,x,L,N),ll(a,x,L)),L}function Xd(a){if(a=a.current,!a.child)return null;switch(a.child.tag){case 5:return a.child.stateNode;default:return a.child.stateNode}}function C1(a,i){if(a=a.memoizedState,a!==null&&a.dehydrated!==null){var d=a.retryLane;a.retryLane=d!==0&&d<i?d:i}}function Xp(a,i){C1(a,i),(a=a.alternate)&&C1(a,i)}function yO(){return null}var T1=typeof reportError=="function"?reportError:function(a){console.error(a)};function Zp(a){this._internalRoot=a}Zd.prototype.render=Zp.prototype.render=function(a){var i=this._internalRoot;if(i===null)throw Error(n(409));Yd(a,i,null,null)},Zd.prototype.unmount=Zp.prototype.unmount=function(){var a=this._internalRoot;if(a!==null){this._internalRoot=null;var i=a.containerInfo;Ko(function(){Yd(null,a,null,null)}),i[mn]=null}};function Zd(a){this._internalRoot=a}Zd.prototype.unstable_scheduleHydration=function(a){if(a){var i=ji();a={blockedOn:null,target:a,priority:i};for(var d=0;d<Yr.length&&i!==0&&i<Yr[d].priority;d++);Yr.splice(d,0,a),d===0&&dc(a)}};function Qp(a){return!(!a||a.nodeType!==1&&a.nodeType!==9&&a.nodeType!==11)}function Qd(a){return!(!a||a.nodeType!==1&&a.nodeType!==9&&a.nodeType!==11&&(a.nodeType!==8||a.nodeValue!==" react-mount-point-unstable "))}function R1(){}function wO(a,i,d,g,x){if(x){if(typeof g=="function"){var N=g;g=function(){var we=Xd(L);N.call(we)}}var L=E1(i,g,a,0,null,!1,!1,"",R1);return a._reactRootContainer=L,a[mn]=L.current,Qr(a.nodeType===8?a.parentNode:a),Ko(),L}for(;x=a.lastChild;)a.removeChild(x);if(typeof g=="function"){var J=g;g=function(){var we=Xd(ae);J.call(we)}}var ae=Yp(a,0,!1,null,null,!1,!1,"",R1);return a._reactRootContainer=ae,a[mn]=ae.current,Qr(a.nodeType===8?a.parentNode:a),Ko(function(){Yd(i,ae,d,g)}),ae}function Jd(a,i,d,g,x){var N=d._reactRootContainer;if(N){var L=N;if(typeof x=="function"){var J=x;x=function(){var ae=Xd(L);J.call(ae)}}Yd(i,L,a,x)}else L=wO(d,i,a,x,g);return Xd(L)}Ju=function(a){switch(a.tag){case 3:var i=a.stateNode;if(i.current.memoizedState.isDehydrated){var d=lo(i.pendingLanes);d!==0&&(ic(i,d|1),nr(i,Rt()),(kt&6)===0&&(fl=Rt()+500,Tr()))}break;case 13:Ko(function(){var g=kn(a,1);if(g!==null){var x=Hn();us(g,a,1,x)}}),Xp(a,1)}},On=function(a){if(a.tag===13){var i=kn(a,134217728);if(i!==null){var d=Hn();us(i,a,134217728,d)}Xp(a,134217728)}},ho=function(a){if(a.tag===13){var i=Ba(a),d=kn(a,i);if(d!==null){var g=Hn();us(d,a,i,g)}Xp(a,i)}},ji=function(){return ft},ed=function(a,i){var d=ft;try{return ft=a,i()}finally{ft=d}},Xt=function(a,i,d){switch(i){case"input":if(de(a,d),i=d.name,d.type==="radio"&&i!=null){for(d=a;d.parentNode;)d=d.parentNode;for(d=d.querySelectorAll("input[name="+JSON.stringify(""+i)+'][type="radio"]'),i=0;i<d.length;i++){var g=d[i];if(g!==a&&g.form===a.form){var x=Ji(g);if(!x)throw Error(n(90));Ge(g),de(g,x)}}}break;case"textarea":Ae(a,d);break;case"select":i=d.value,i!=null&&Le(a,!!d.multiple,i,!1)}},_n=Up,Ut=Ko;var vO={usingClientEntryPoint:!1,Events:[Lo,ts,Ji,xt,bt,Up]},Yc={findFiberByHostInstance:Cs,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},xO={bundleType:Yc.bundleType,version:Yc.version,rendererPackageName:Yc.rendererPackageName,rendererConfig:Yc.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:C.ReactCurrentDispatcher,findHostInstanceByFiber:function(a){return a=et(a),a===null?null:a.stateNode},findFiberByHostInstance:Yc.findFiberByHostInstance||yO,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 eh=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!eh.isDisabled&&eh.supportsFiber)try{ur=eh.inject(xO),sn=eh}catch{}}return rr.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=vO,rr.createPortal=function(a,i){var d=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Qp(i))throw Error(n(200));return gO(a,i,null,d)},rr.createRoot=function(a,i){if(!Qp(a))throw Error(n(299));var d=!1,g="",x=T1;return i!=null&&(i.unstable_strictMode===!0&&(d=!0),i.identifierPrefix!==void 0&&(g=i.identifierPrefix),i.onRecoverableError!==void 0&&(x=i.onRecoverableError)),i=Yp(a,1,!1,null,null,d,!1,g,x),a[mn]=i.current,Qr(a.nodeType===8?a.parentNode:a),new Zp(i)},rr.findDOMNode=function(a){if(a==null)return null;if(a.nodeType===1)return a;var i=a._reactInternals;if(i===void 0)throw typeof a.render=="function"?Error(n(188)):(a=Object.keys(a).join(","),Error(n(268,a)));return a=et(i),a=a===null?null:a.stateNode,a},rr.flushSync=function(a){return Ko(a)},rr.hydrate=function(a,i,d){if(!Qd(i))throw Error(n(200));return Jd(null,a,i,!0,d)},rr.hydrateRoot=function(a,i,d){if(!Qp(a))throw Error(n(405));var g=d!=null&&d.hydratedSources||null,x=!1,N="",L=T1;if(d!=null&&(d.unstable_strictMode===!0&&(x=!0),d.identifierPrefix!==void 0&&(N=d.identifierPrefix),d.onRecoverableError!==void 0&&(L=d.onRecoverableError)),i=E1(i,null,a,1,d??null,x,!1,N,L),a[mn]=i.current,Qr(a),g)for(a=0;a<g.length;a++)d=g[a],x=d._getVersion,x=x(d._source),i.mutableSourceEagerHydrationData==null?i.mutableSourceEagerHydrationData=[d,x]:i.mutableSourceEagerHydrationData.push(d,x);return new Zd(i)},rr.render=function(a,i,d){if(!Qd(i))throw Error(n(200));return Jd(null,a,i,!1,d)},rr.unmountComponentAtNode=function(a){if(!Qd(a))throw Error(n(40));return a._reactRootContainer?(Ko(function(){Jd(null,null,a,!1,function(){a._reactRootContainer=null,a[mn]=null})}),!0):!1},rr.unstable_batchedUpdates=Up,rr.unstable_renderSubtreeIntoContainer=function(a,i,d,g){if(!Qd(d))throw Error(n(200));if(a==null||a._reactInternals===void 0)throw Error(n(38));return Jd(a,i,d,!1,g)},rr.version="18.3.1-next-f1338f8080-20240426",rr}var D1;function NR(){if(D1)return tm.exports;D1=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(),tm.exports=EO(),tm.exports}var F1;function CO(){if(F1)return nh;F1=1;var e=NR();return nh.createRoot=e.createRoot,nh.hydrateRoot=e.hydrateRoot,nh}var TO=CO();const RO="modulepreload",AO=function(e){return"/"+e},q1={},nb=function(t,n,r){let s=Promise.resolve();if(n&&n.length>0){let c=function(p){return Promise.all(p.map(h=>Promise.resolve(h).then(m=>({status:"fulfilled",value:m}),m=>({status:"rejected",reason:m}))))};document.getElementsByTagName("link");const u=document.querySelector("meta[property=csp-nonce]"),f=(u==null?void 0:u.nonce)||(u==null?void 0:u.getAttribute("nonce"));s=c(n.map(p=>{if(p=AO(p),p in q1)return;q1[p]=!0;const h=p.endsWith(".css"),m=h?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${p}"]${m}`))return;const y=document.createElement("link");if(y.rel=h?"stylesheet":RO,h||(y.as="script"),y.crossOrigin="",y.href=p,f&&y.setAttribute("nonce",f),document.head.appendChild(y),h)return new Promise((v,S)=>{y.addEventListener("load",v),y.addEventListener("error",()=>S(new Error(`Unable to preload CSS for ${p}`)))})}))}function l(c){const u=new Event("vite:preloadError",{cancelable:!0});if(u.payload=c,window.dispatchEvent(u),!u.defaultPrevented)throw c}return s.then(c=>{for(const u of c||[])u.status==="rejected"&&l(u.reason);return t().catch(l)})};var w=Pu();const ve=tb(w);function jn(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=jn(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var sm={exports:{}},am={},om={exports:{}},im={};/**
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 B1;function MO(){if(B1)return im;B1=1;var e=Pu();function t(m,y){return m===y&&(m!==0||1/m===1/y)||m!==m&&y!==y}var n=typeof Object.is=="function"?Object.is:t,r=e.useState,s=e.useEffect,l=e.useLayoutEffect,c=e.useDebugValue;function u(m,y){var v=y(),S=r({inst:{value:v,getSnapshot:y}}),b=S[0].inst,_=S[1];return l(function(){b.value=v,b.getSnapshot=y,f(b)&&_({inst:b})},[m,v,y]),s(function(){return f(b)&&_({inst:b}),m(function(){f(b)&&_({inst:b})})},[m]),c(v),v}function f(m){var y=m.getSnapshot;m=m.value;try{var v=y();return!n(m,v)}catch{return!0}}function p(m,y){return y()}var h=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?p:u;return im.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:h,im}var z1;function IO(){return z1||(z1=1,om.exports=MO()),om.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 U1;function $O(){if(U1)return am;U1=1;var e=Pu(),t=IO();function n(p,h){return p===h&&(p!==0||1/p===1/h)||p!==p&&h!==h}var r=typeof Object.is=="function"?Object.is:n,s=t.useSyncExternalStore,l=e.useRef,c=e.useEffect,u=e.useMemo,f=e.useDebugValue;return am.useSyncExternalStoreWithSelector=function(p,h,m,y,v){var S=l(null);if(S.current===null){var b={hasValue:!1,value:null};S.current=b}else b=S.current;S=u(function(){function k(I){if(!j){if(j=!0,E=I,I=y(I),v!==void 0&&b.hasValue){var O=b.value;if(v(O,I))return C=O}return C=I}if(O=C,r(E,I))return O;var H=y(I);return v!==void 0&&v(O,H)?(E=I,O):(E=I,C=H)}var j=!1,E,C,R=m===void 0?null:m;return[function(){return k(h())},R===null?void 0:function(){return k(R())}]},[h,m,y,v]);var _=s(p,S[0],S[1]);return c(function(){b.hasValue=!0,b.value=_},[_]),f(_),_},am}var H1;function OO(){return H1||(H1=1,sm.exports=$O()),sm.exports}var LO=OO();const PO=tb(LO),DO={},W1=e=>{let t;const n=new Set,r=(h,m)=>{const y=typeof h=="function"?h(t):h;if(!Object.is(y,t)){const v=t;t=m??(typeof y!="object"||y===null)?y:Object.assign({},t,y),n.forEach(S=>S(t,v))}},s=()=>t,f={setState:r,getState:s,getInitialState:()=>p,subscribe:h=>(n.add(h),()=>n.delete(h)),destroy:()=>{(DO?"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()}},p=t=e(r,s,f);return f},FO=e=>e?W1(e):W1,{useDebugValue:qO}=ve,{useSyncExternalStoreWithSelector:BO}=PO,zO=e=>e;function SR(e,t=zO,n){const r=BO(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return qO(r),r}const V1=(e,t)=>{const n=FO(e),r=(s,l=t)=>SR(n,s,l);return Object.assign(r,n),r},UO=(e,t)=>e?V1(e,t):V1;function fn(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 HO={value:()=>{}};function ff(){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 Mh(n)}function Mh(e){this._=e}function WO(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}})}Mh.prototype=ff.prototype={constructor:Mh,on:function(e,t){var n=this._,r=WO(e+"",n),s,l=-1,c=r.length;if(arguments.length<2){for(;++l<c;)if((s=(e=r[l]).type)&&(s=VO(n[s],e.name)))return s;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++l<c;)if(s=(e=r[l]).type)n[s]=G1(n[s],e.name,t);else if(t==null)for(s in n)n[s]=G1(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 Mh(e)},call:function(e,t){if((s=arguments.length-2)>0)for(var n=new Array(s),r=0,s,l;r<s;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(l=this._[e],r=0,s=l.length;r<s;++r)l[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,l=r.length;s<l;++s)r[s].value.apply(t,n)}};function VO(e,t){for(var n=0,r=e.length,s;n<r;++n)if((s=e[n]).name===t)return s.value}function G1(e,t,n){for(var r=0,s=e.length;r<s;++r)if(e[r].name===t){e[r]=HO,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var l0="http://www.w3.org/1999/xhtml";const K1={svg:"http://www.w3.org/2000/svg",xhtml:l0,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function pf(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),K1.hasOwnProperty(t)?{space:K1[t],local:e}:e}function GO(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===l0&&t.documentElement.namespaceURI===l0?t.createElement(e):t.createElementNS(n,e)}}function KO(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function jR(e){var t=pf(e);return(t.local?KO:GO)(t)}function YO(){}function rb(e){return e==null?YO:function(){return this.querySelector(e)}}function XO(e){typeof e!="function"&&(e=rb(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var l=t[s],c=l.length,u=r[s]=new Array(c),f,p,h=0;h<c;++h)(f=l[h])&&(p=e.call(f,f.__data__,h,l))&&("__data__"in f&&(p.__data__=f.__data__),u[h]=p);return new vr(r,this._parents)}function ZO(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function QO(){return[]}function _R(e){return e==null?QO:function(){return this.querySelectorAll(e)}}function JO(e){return function(){return ZO(e.apply(this,arguments))}}function eL(e){typeof e=="function"?e=JO(e):e=_R(e);for(var t=this._groups,n=t.length,r=[],s=[],l=0;l<n;++l)for(var c=t[l],u=c.length,f,p=0;p<u;++p)(f=c[p])&&(r.push(e.call(f,f.__data__,p,c)),s.push(f));return new vr(r,s)}function ER(e){return function(){return this.matches(e)}}function CR(e){return function(t){return t.matches(e)}}var tL=Array.prototype.find;function nL(e){return function(){return tL.call(this.children,e)}}function rL(){return this.firstElementChild}function sL(e){return this.select(e==null?rL:nL(typeof e=="function"?e:CR(e)))}var aL=Array.prototype.filter;function oL(){return Array.from(this.children)}function iL(e){return function(){return aL.call(this.children,e)}}function lL(e){return this.selectAll(e==null?oL:iL(typeof e=="function"?e:CR(e)))}function cL(e){typeof e!="function"&&(e=ER(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var l=t[s],c=l.length,u=r[s]=[],f,p=0;p<c;++p)(f=l[p])&&e.call(f,f.__data__,p,l)&&u.push(f);return new vr(r,this._parents)}function TR(e){return new Array(e.length)}function uL(){return new vr(this._enter||this._groups.map(TR),this._parents)}function zh(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}zh.prototype={constructor:zh,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 dL(e){return function(){return e}}function hL(e,t,n,r,s,l){for(var c=0,u,f=t.length,p=l.length;c<p;++c)(u=t[c])?(u.__data__=l[c],r[c]=u):n[c]=new zh(e,l[c]);for(;c<f;++c)(u=t[c])&&(s[c]=u)}function fL(e,t,n,r,s,l,c){var u,f,p=new Map,h=t.length,m=l.length,y=new Array(h),v;for(u=0;u<h;++u)(f=t[u])&&(y[u]=v=c.call(f,f.__data__,u,t)+"",p.has(v)?s[u]=f:p.set(v,f));for(u=0;u<m;++u)v=c.call(e,l[u],u,l)+"",(f=p.get(v))?(r[u]=f,f.__data__=l[u],p.delete(v)):n[u]=new zh(e,l[u]);for(u=0;u<h;++u)(f=t[u])&&p.get(y[u])===f&&(s[u]=f)}function pL(e){return e.__data__}function mL(e,t){if(!arguments.length)return Array.from(this,pL);var n=t?fL:hL,r=this._parents,s=this._groups;typeof e!="function"&&(e=dL(e));for(var l=s.length,c=new Array(l),u=new Array(l),f=new Array(l),p=0;p<l;++p){var h=r[p],m=s[p],y=m.length,v=gL(e.call(h,h&&h.__data__,p,r)),S=v.length,b=u[p]=new Array(S),_=c[p]=new Array(S),k=f[p]=new Array(y);n(h,m,b,_,k,v,t);for(var j=0,E=0,C,R;j<S;++j)if(C=b[j]){for(j>=E&&(E=j+1);!(R=_[E])&&++E<S;);C._next=R||null}}return c=new vr(c,r),c._enter=u,c._exit=f,c}function gL(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function yL(){return new vr(this._exit||this._groups.map(TR),this._parents)}function wL(e,t,n){var r=this.enter(),s=this,l=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?l.remove():n(l),r&&s?r.merge(s).order():s}function vL(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,s=n.length,l=r.length,c=Math.min(s,l),u=new Array(s),f=0;f<c;++f)for(var p=n[f],h=r[f],m=p.length,y=u[f]=new Array(m),v,S=0;S<m;++S)(v=p[S]||h[S])&&(y[S]=v);for(;f<s;++f)u[f]=n[f];return new vr(u,this._parents)}function xL(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],s=r.length-1,l=r[s],c;--s>=0;)(c=r[s])&&(l&&c.compareDocumentPosition(l)^4&&l.parentNode.insertBefore(c,l),l=c);return this}function bL(e){e||(e=kL);function t(m,y){return m&&y?e(m.__data__,y.__data__):!m-!y}for(var n=this._groups,r=n.length,s=new Array(r),l=0;l<r;++l){for(var c=n[l],u=c.length,f=s[l]=new Array(u),p,h=0;h<u;++h)(p=c[h])&&(f[h]=p);f.sort(t)}return new vr(s,this._parents).order()}function kL(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function NL(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function SL(){return Array.from(this)}function jL(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],s=0,l=r.length;s<l;++s){var c=r[s];if(c)return c}return null}function _L(){let e=0;for(const t of this)++e;return e}function EL(){return!this.node()}function CL(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var s=t[n],l=0,c=s.length,u;l<c;++l)(u=s[l])&&e.call(u,u.__data__,l,s);return this}function TL(e){return function(){this.removeAttribute(e)}}function RL(e){return function(){this.removeAttributeNS(e.space,e.local)}}function AL(e,t){return function(){this.setAttribute(e,t)}}function ML(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function IL(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function $L(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 OL(e,t){var n=pf(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?RL:TL:typeof t=="function"?n.local?$L:IL:n.local?ML:AL)(n,t))}function RR(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function LL(e){return function(){this.style.removeProperty(e)}}function PL(e,t,n){return function(){this.style.setProperty(e,t,n)}}function DL(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function FL(e,t,n){return arguments.length>1?this.each((t==null?LL:typeof t=="function"?DL:PL)(e,t,n??"")):Fl(this.node(),e)}function Fl(e,t){return e.style.getPropertyValue(t)||RR(e).getComputedStyle(e,null).getPropertyValue(t)}function qL(e){return function(){delete this[e]}}function BL(e,t){return function(){this[e]=t}}function zL(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function UL(e,t){return arguments.length>1?this.each((t==null?qL:typeof t=="function"?zL:BL)(e,t)):this.node()[e]}function AR(e){return e.trim().split(/^|\s+/)}function sb(e){return e.classList||new MR(e)}function MR(e){this._node=e,this._names=AR(e.getAttribute("class")||"")}MR.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 IR(e,t){for(var n=sb(e),r=-1,s=t.length;++r<s;)n.add(t[r])}function $R(e,t){for(var n=sb(e),r=-1,s=t.length;++r<s;)n.remove(t[r])}function HL(e){return function(){IR(this,e)}}function WL(e){return function(){$R(this,e)}}function VL(e,t){return function(){(t.apply(this,arguments)?IR:$R)(this,e)}}function GL(e,t){var n=AR(e+"");if(arguments.length<2){for(var r=sb(this.node()),s=-1,l=n.length;++s<l;)if(!r.contains(n[s]))return!1;return!0}return this.each((typeof t=="function"?VL:t?HL:WL)(n,t))}function KL(){this.textContent=""}function YL(e){return function(){this.textContent=e}}function XL(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function ZL(e){return arguments.length?this.each(e==null?KL:(typeof e=="function"?XL:YL)(e)):this.node().textContent}function QL(){this.innerHTML=""}function JL(e){return function(){this.innerHTML=e}}function e3(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function t3(e){return arguments.length?this.each(e==null?QL:(typeof e=="function"?e3:JL)(e)):this.node().innerHTML}function n3(){this.nextSibling&&this.parentNode.appendChild(this)}function r3(){return this.each(n3)}function s3(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function a3(){return this.each(s3)}function o3(e){var t=typeof e=="function"?e:jR(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function i3(){return null}function l3(e,t){var n=typeof e=="function"?e:jR(e),r=t==null?i3:typeof t=="function"?t:rb(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function c3(){var e=this.parentNode;e&&e.removeChild(this)}function u3(){return this.each(c3)}function d3(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function h3(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function f3(e){return this.select(e?h3:d3)}function p3(e){return arguments.length?this.property("__data__",e):this.node().__data__}function m3(e){return function(t){e.call(this,t,this.__data__)}}function g3(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 y3(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,s=t.length,l;n<s;++n)l=t[n],(!e.type||l.type===e.type)&&l.name===e.name?this.removeEventListener(l.type,l.listener,l.options):t[++r]=l;++r?t.length=r:delete this.__on}}}function w3(e,t,n){return function(){var r=this.__on,s,l=m3(t);if(r){for(var c=0,u=r.length;c<u;++c)if((s=r[c]).type===e.type&&s.name===e.name){this.removeEventListener(s.type,s.listener,s.options),this.addEventListener(s.type,s.listener=l,s.options=n),s.value=t;return}}this.addEventListener(e.type,l,n),s={type:e.type,name:e.name,value:t,listener:l,options:n},r?r.push(s):this.__on=[s]}}function v3(e,t,n){var r=g3(e+""),s,l=r.length,c;if(arguments.length<2){var u=this.node().__on;if(u){for(var f=0,p=u.length,h;f<p;++f)for(s=0,h=u[f];s<l;++s)if((c=r[s]).type===h.type&&c.name===h.name)return h.value}return}for(u=t?w3:y3,s=0;s<l;++s)this.each(u(r[s],t,n));return this}function OR(e,t,n){var r=RR(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 x3(e,t){return function(){return OR(this,e,t)}}function b3(e,t){return function(){return OR(this,e,t.apply(this,arguments))}}function k3(e,t){return this.each((typeof t=="function"?b3:x3)(e,t))}function*N3(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],s=0,l=r.length,c;s<l;++s)(c=r[s])&&(yield c)}var LR=[null];function vr(e,t){this._groups=e,this._parents=t}function Du(){return new vr([[document.documentElement]],LR)}function S3(){return this}vr.prototype=Du.prototype={constructor:vr,select:XO,selectAll:eL,selectChild:sL,selectChildren:lL,filter:cL,data:mL,enter:uL,exit:yL,join:wL,merge:vL,selection:S3,order:xL,sort:bL,call:NL,nodes:SL,node:jL,size:_L,empty:EL,each:CL,attr:OL,style:FL,property:UL,classed:GL,text:ZL,html:t3,raise:r3,lower:a3,append:o3,insert:l3,remove:u3,clone:f3,datum:p3,on:v3,dispatch:k3,[Symbol.iterator]:N3};function Pr(e){return typeof e=="string"?new vr([[document.querySelector(e)]],[document.documentElement]):new vr([[e]],LR)}function j3(e){let t;for(;t=e.sourceEvent;)e=t;return e}function hs(e,t){if(e=j3(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 _3={passive:!1},wu={capture:!0,passive:!1};function lm(e){e.stopImmediatePropagation()}function $l(e){e.preventDefault(),e.stopImmediatePropagation()}function PR(e){var t=e.document.documentElement,n=Pr(e).on("dragstart.drag",$l,wu);"onselectstart"in t?n.on("selectstart.drag",$l,wu):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function DR(e,t){var n=e.document.documentElement,r=Pr(e).on("dragstart.drag",null);t&&(r.on("click.drag",$l,wu),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 rh=e=>()=>e;function c0(e,{sourceEvent:t,subject:n,target:r,identifier:s,active:l,x:c,y:u,dx:f,dy:p,dispatch:h}){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:l,enumerable:!0,configurable:!0},x:{value:c,enumerable:!0,configurable:!0},y:{value:u,enumerable:!0,configurable:!0},dx:{value:f,enumerable:!0,configurable:!0},dy:{value:p,enumerable:!0,configurable:!0},_:{value:h}})}c0.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function E3(e){return!e.ctrlKey&&!e.button}function C3(){return this.parentNode}function T3(e,t){return t??{x:e.x,y:e.y}}function R3(){return navigator.maxTouchPoints||"ontouchstart"in this}function A3(){var e=E3,t=C3,n=T3,r=R3,s={},l=ff("start","drag","end"),c=0,u,f,p,h,m=0;function y(C){C.on("mousedown.drag",v).filter(r).on("touchstart.drag",_).on("touchmove.drag",k,_3).on("touchend.drag touchcancel.drag",j).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function v(C,R){if(!(h||!e.call(this,C,R))){var I=E(this,t.call(this,C,R),C,R,"mouse");I&&(Pr(C.view).on("mousemove.drag",S,wu).on("mouseup.drag",b,wu),PR(C.view),lm(C),p=!1,u=C.clientX,f=C.clientY,I("start",C))}}function S(C){if($l(C),!p){var R=C.clientX-u,I=C.clientY-f;p=R*R+I*I>m}s.mouse("drag",C)}function b(C){Pr(C.view).on("mousemove.drag mouseup.drag",null),DR(C.view,p),$l(C),s.mouse("end",C)}function _(C,R){if(e.call(this,C,R)){var I=C.changedTouches,O=t.call(this,C,R),H=I.length,q,$;for(q=0;q<H;++q)($=E(this,O,C,R,I[q].identifier,I[q]))&&(lm(C),$("start",C,I[q]))}}function k(C){var R=C.changedTouches,I=R.length,O,H;for(O=0;O<I;++O)(H=s[R[O].identifier])&&($l(C),H("drag",C,R[O]))}function j(C){var R=C.changedTouches,I=R.length,O,H;for(h&&clearTimeout(h),h=setTimeout(function(){h=null},500),O=0;O<I;++O)(H=s[R[O].identifier])&&(lm(C),H("end",C,R[O]))}function E(C,R,I,O,H,q){var $=l.copy(),V=hs(q||I,R),ne,ee,M;if((M=n.call(C,new c0("beforestart",{sourceEvent:I,target:y,identifier:H,active:c,x:V[0],y:V[1],dx:0,dy:0,dispatch:$}),O))!=null)return ne=M.x-V[0]||0,ee=M.y-V[1]||0,function Z(K,D,P){var B=V,W;switch(K){case"start":s[H]=Z,W=c++;break;case"end":delete s[H],--c;case"drag":V=hs(P||D,R),W=c;break}$.call(K,C,new c0(K,{sourceEvent:D,subject:M,target:y,identifier:H,active:W,x:V[0]+ne,y:V[1]+ee,dx:V[0]-B[0],dy:V[1]-B[1],dispatch:$}),O)}}return y.filter=function(C){return arguments.length?(e=typeof C=="function"?C:rh(!!C),y):e},y.container=function(C){return arguments.length?(t=typeof C=="function"?C:rh(C),y):t},y.subject=function(C){return arguments.length?(n=typeof C=="function"?C:rh(C),y):n},y.touchable=function(C){return arguments.length?(r=typeof C=="function"?C:rh(!!C),y):r},y.on=function(){var C=l.on.apply(l,arguments);return C===l?y:C},y.clickDistance=function(C){return arguments.length?(m=(C=+C)*C,y):Math.sqrt(m)},y}function ab(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function FR(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function Fu(){}var vu=.7,Uh=1/vu,Ol="\\s*([+-]?\\d+)\\s*",xu="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Ds="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",M3=/^#([0-9a-f]{3,8})$/,I3=new RegExp(`^rgb\\(${Ol},${Ol},${Ol}\\)$`),$3=new RegExp(`^rgb\\(${Ds},${Ds},${Ds}\\)$`),O3=new RegExp(`^rgba\\(${Ol},${Ol},${Ol},${xu}\\)$`),L3=new RegExp(`^rgba\\(${Ds},${Ds},${Ds},${xu}\\)$`),P3=new RegExp(`^hsl\\(${xu},${Ds},${Ds}\\)$`),D3=new RegExp(`^hsla\\(${xu},${Ds},${Ds},${xu}\\)$`),Y1={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};ab(Fu,bu,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:X1,formatHex:X1,formatHex8:F3,formatHsl:q3,formatRgb:Z1,toString:Z1});function X1(){return this.rgb().formatHex()}function F3(){return this.rgb().formatHex8()}function q3(){return qR(this).formatHsl()}function Z1(){return this.rgb().formatRgb()}function bu(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=M3.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?Q1(t):n===3?new ar(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?sh(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?sh(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=I3.exec(e))?new ar(t[1],t[2],t[3],1):(t=$3.exec(e))?new ar(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=O3.exec(e))?sh(t[1],t[2],t[3],t[4]):(t=L3.exec(e))?sh(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=P3.exec(e))?tN(t[1],t[2]/100,t[3]/100,1):(t=D3.exec(e))?tN(t[1],t[2]/100,t[3]/100,t[4]):Y1.hasOwnProperty(e)?Q1(Y1[e]):e==="transparent"?new ar(NaN,NaN,NaN,0):null}function Q1(e){return new ar(e>>16&255,e>>8&255,e&255,1)}function sh(e,t,n,r){return r<=0&&(e=t=n=NaN),new ar(e,t,n,r)}function B3(e){return e instanceof Fu||(e=bu(e)),e?(e=e.rgb(),new ar(e.r,e.g,e.b,e.opacity)):new ar}function u0(e,t,n,r){return arguments.length===1?B3(e):new ar(e,t,n,r??1)}function ar(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}ab(ar,u0,FR(Fu,{brighter(e){return e=e==null?Uh:Math.pow(Uh,e),new ar(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?vu:Math.pow(vu,e),new ar(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new ar(si(this.r),si(this.g),si(this.b),Hh(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:J1,formatHex:J1,formatHex8:z3,formatRgb:eN,toString:eN}));function J1(){return`#${ti(this.r)}${ti(this.g)}${ti(this.b)}`}function z3(){return`#${ti(this.r)}${ti(this.g)}${ti(this.b)}${ti((isNaN(this.opacity)?1:this.opacity)*255)}`}function eN(){const e=Hh(this.opacity);return`${e===1?"rgb(":"rgba("}${si(this.r)}, ${si(this.g)}, ${si(this.b)}${e===1?")":`, ${e})`}`}function Hh(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function si(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function ti(e){return e=si(e),(e<16?"0":"")+e.toString(16)}function tN(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new ps(e,t,n,r)}function qR(e){if(e instanceof ps)return new ps(e.h,e.s,e.l,e.opacity);if(e instanceof Fu||(e=bu(e)),!e)return new ps;if(e instanceof ps)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,s=Math.min(t,n,r),l=Math.max(t,n,r),c=NaN,u=l-s,f=(l+s)/2;return u?(t===l?c=(n-r)/u+(n<r)*6:n===l?c=(r-t)/u+2:c=(t-n)/u+4,u/=f<.5?l+s:2-l-s,c*=60):u=f>0&&f<1?0:c,new ps(c,u,f,e.opacity)}function U3(e,t,n,r){return arguments.length===1?qR(e):new ps(e,t,n,r??1)}function ps(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}ab(ps,U3,FR(Fu,{brighter(e){return e=e==null?Uh:Math.pow(Uh,e),new ps(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?vu:Math.pow(vu,e),new ps(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 ar(cm(e>=240?e-240:e+120,s,r),cm(e,s,r),cm(e<120?e+240:e-120,s,r),this.opacity)},clamp(){return new ps(nN(this.h),ah(this.s),ah(this.l),Hh(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=Hh(this.opacity);return`${e===1?"hsl(":"hsla("}${nN(this.h)}, ${ah(this.s)*100}%, ${ah(this.l)*100}%${e===1?")":`, ${e})`}`}}));function nN(e){return e=(e||0)%360,e<0?e+360:e}function ah(e){return Math.max(0,Math.min(1,e||0))}function cm(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 BR=e=>()=>e;function H3(e,t){return function(n){return e+n*t}}function W3(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 V3(e){return(e=+e)==1?zR:function(t,n){return n-t?W3(t,n,e):BR(isNaN(t)?n:t)}}function zR(e,t){var n=t-e;return n?H3(e,n):BR(isNaN(e)?t:e)}const rN=(function e(t){var n=V3(t);function r(s,l){var c=n((s=u0(s)).r,(l=u0(l)).r),u=n(s.g,l.g),f=n(s.b,l.b),p=zR(s.opacity,l.opacity);return function(h){return s.r=c(h),s.g=u(h),s.b=f(h),s.opacity=p(h),s+""}}return r.gamma=e,r})(1);function Ya(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var d0=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,um=new RegExp(d0.source,"g");function G3(e){return function(){return e}}function K3(e){return function(t){return e(t)+""}}function Y3(e,t){var n=d0.lastIndex=um.lastIndex=0,r,s,l,c=-1,u=[],f=[];for(e=e+"",t=t+"";(r=d0.exec(e))&&(s=um.exec(t));)(l=s.index)>n&&(l=t.slice(n,l),u[c]?u[c]+=l:u[++c]=l),(r=r[0])===(s=s[0])?u[c]?u[c]+=s:u[++c]=s:(u[++c]=null,f.push({i:c,x:Ya(r,s)})),n=um.lastIndex;return n<t.length&&(l=t.slice(n),u[c]?u[c]+=l:u[++c]=l),u.length<2?f[0]?K3(f[0].x):G3(t):(t=f.length,function(p){for(var h=0,m;h<t;++h)u[(m=f[h]).i]=m.x(p);return u.join("")})}var sN=180/Math.PI,h0={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function UR(e,t,n,r,s,l){var c,u,f;return(c=Math.sqrt(e*e+t*t))&&(e/=c,t/=c),(f=e*n+t*r)&&(n-=e*f,r-=t*f),(u=Math.sqrt(n*n+r*r))&&(n/=u,r/=u,f/=u),e*r<t*n&&(e=-e,t=-t,f=-f,c=-c),{translateX:s,translateY:l,rotate:Math.atan2(t,e)*sN,skewX:Math.atan(f)*sN,scaleX:c,scaleY:u}}var oh;function X3(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?h0:UR(t.a,t.b,t.c,t.d,t.e,t.f)}function Z3(e){return e==null||(oh||(oh=document.createElementNS("http://www.w3.org/2000/svg","g")),oh.setAttribute("transform",e),!(e=oh.transform.baseVal.consolidate()))?h0:(e=e.matrix,UR(e.a,e.b,e.c,e.d,e.e,e.f))}function HR(e,t,n,r){function s(p){return p.length?p.pop()+" ":""}function l(p,h,m,y,v,S){if(p!==m||h!==y){var b=v.push("translate(",null,t,null,n);S.push({i:b-4,x:Ya(p,m)},{i:b-2,x:Ya(h,y)})}else(m||y)&&v.push("translate("+m+t+y+n)}function c(p,h,m,y){p!==h?(p-h>180?h+=360:h-p>180&&(p+=360),y.push({i:m.push(s(m)+"rotate(",null,r)-2,x:Ya(p,h)})):h&&m.push(s(m)+"rotate("+h+r)}function u(p,h,m,y){p!==h?y.push({i:m.push(s(m)+"skewX(",null,r)-2,x:Ya(p,h)}):h&&m.push(s(m)+"skewX("+h+r)}function f(p,h,m,y,v,S){if(p!==m||h!==y){var b=v.push(s(v)+"scale(",null,",",null,")");S.push({i:b-4,x:Ya(p,m)},{i:b-2,x:Ya(h,y)})}else(m!==1||y!==1)&&v.push(s(v)+"scale("+m+","+y+")")}return function(p,h){var m=[],y=[];return p=e(p),h=e(h),l(p.translateX,p.translateY,h.translateX,h.translateY,m,y),c(p.rotate,h.rotate,m,y),u(p.skewX,h.skewX,m,y),f(p.scaleX,p.scaleY,h.scaleX,h.scaleY,m,y),p=h=null,function(v){for(var S=-1,b=y.length,_;++S<b;)m[(_=y[S]).i]=_.x(v);return m.join("")}}}var Q3=HR(X3,"px, ","px)","deg)"),J3=HR(Z3,", ",")",")"),eP=1e-12;function aN(e){return((e=Math.exp(e))+1/e)/2}function tP(e){return((e=Math.exp(e))-1/e)/2}function nP(e){return((e=Math.exp(2*e))-1)/(e+1)}const rP=(function e(t,n,r){function s(l,c){var u=l[0],f=l[1],p=l[2],h=c[0],m=c[1],y=c[2],v=h-u,S=m-f,b=v*v+S*S,_,k;if(b<eP)k=Math.log(y/p)/t,_=function(O){return[u+O*v,f+O*S,p*Math.exp(t*O*k)]};else{var j=Math.sqrt(b),E=(y*y-p*p+r*b)/(2*p*n*j),C=(y*y-p*p-r*b)/(2*y*n*j),R=Math.log(Math.sqrt(E*E+1)-E),I=Math.log(Math.sqrt(C*C+1)-C);k=(I-R)/t,_=function(O){var H=O*k,q=aN(R),$=p/(n*j)*(q*nP(t*H+R)-tP(R));return[u+$*v,f+$*S,p*q/aN(t*H+R)]}}return _.duration=k*1e3*t/Math.SQRT2,_}return s.rho=function(l){var c=Math.max(.001,+l),u=c*c,f=u*u;return e(c,u,f)},s})(Math.SQRT2,2,4);var ql=0,ou=0,Zc=0,WR=1e3,Wh,iu,Vh=0,ci=0,mf=0,ku=typeof performance=="object"&&performance.now?performance:Date,VR=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function ob(){return ci||(VR(sP),ci=ku.now()+mf)}function sP(){ci=0}function Gh(){this._call=this._time=this._next=null}Gh.prototype=GR.prototype={constructor:Gh,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?ob():+n)+(t==null?0:+t),!this._next&&iu!==this&&(iu?iu._next=this:Wh=this,iu=this),this._call=e,this._time=n,f0()},stop:function(){this._call&&(this._call=null,this._time=1/0,f0())}};function GR(e,t,n){var r=new Gh;return r.restart(e,t,n),r}function aP(){ob(),++ql;for(var e=Wh,t;e;)(t=ci-e._time)>=0&&e._call.call(void 0,t),e=e._next;--ql}function oN(){ci=(Vh=ku.now())+mf,ql=ou=0;try{aP()}finally{ql=0,iP(),ci=0}}function oP(){var e=ku.now(),t=e-Vh;t>WR&&(mf-=t,Vh=e)}function iP(){for(var e,t=Wh,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:Wh=n);iu=e,f0(r)}function f0(e){if(!ql){ou&&(ou=clearTimeout(ou));var t=e-ci;t>24?(e<1/0&&(ou=setTimeout(oN,e-ku.now()-mf)),Zc&&(Zc=clearInterval(Zc))):(Zc||(Vh=ku.now(),Zc=setInterval(oP,WR)),ql=1,VR(oN))}}function iN(e,t,n){var r=new Gh;return t=t==null?0:+t,r.restart(s=>{r.stop(),e(s+t)},t,n),r}var lP=ff("start","end","cancel","interrupt"),cP=[],KR=0,lN=1,p0=2,Ih=3,cN=4,m0=5,$h=6;function gf(e,t,n,r,s,l){var c=e.__transition;if(!c)e.__transition={};else if(n in c)return;uP(e,n,{name:t,index:r,group:s,on:lP,tween:cP,time:l.time,delay:l.delay,duration:l.duration,ease:l.ease,timer:null,state:KR})}function ib(e,t){var n=xs(e,t);if(n.state>KR)throw new Error("too late; already scheduled");return n}function zs(e,t){var n=xs(e,t);if(n.state>Ih)throw new Error("too late; already running");return n}function xs(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function uP(e,t,n){var r=e.__transition,s;r[t]=n,n.timer=GR(l,0,n.time);function l(p){n.state=lN,n.timer.restart(c,n.delay,n.time),n.delay<=p&&c(p-n.delay)}function c(p){var h,m,y,v;if(n.state!==lN)return f();for(h in r)if(v=r[h],v.name===n.name){if(v.state===Ih)return iN(c);v.state===cN?(v.state=$h,v.timer.stop(),v.on.call("interrupt",e,e.__data__,v.index,v.group),delete r[h]):+h<t&&(v.state=$h,v.timer.stop(),v.on.call("cancel",e,e.__data__,v.index,v.group),delete r[h])}if(iN(function(){n.state===Ih&&(n.state=cN,n.timer.restart(u,n.delay,n.time),u(p))}),n.state=p0,n.on.call("start",e,e.__data__,n.index,n.group),n.state===p0){for(n.state=Ih,s=new Array(y=n.tween.length),h=0,m=-1;h<y;++h)(v=n.tween[h].value.call(e,e.__data__,n.index,n.group))&&(s[++m]=v);s.length=m+1}}function u(p){for(var h=p<n.duration?n.ease.call(null,p/n.duration):(n.timer.restart(f),n.state=m0,1),m=-1,y=s.length;++m<y;)s[m].call(e,h);n.state===m0&&(n.on.call("end",e,e.__data__,n.index,n.group),f())}function f(){n.state=$h,n.timer.stop(),delete r[t];for(var p in r)return;delete e.__transition}}function Oh(e,t){var n=e.__transition,r,s,l=!0,c;if(n){t=t==null?null:t+"";for(c in n){if((r=n[c]).name!==t){l=!1;continue}s=r.state>p0&&r.state<m0,r.state=$h,r.timer.stop(),r.on.call(s?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[c]}l&&delete e.__transition}}function dP(e){return this.each(function(){Oh(this,e)})}function hP(e,t){var n,r;return function(){var s=zs(this,e),l=s.tween;if(l!==n){r=n=l;for(var c=0,u=r.length;c<u;++c)if(r[c].name===t){r=r.slice(),r.splice(c,1);break}}s.tween=r}}function fP(e,t,n){var r,s;if(typeof n!="function")throw new Error;return function(){var l=zs(this,e),c=l.tween;if(c!==r){s=(r=c).slice();for(var u={name:t,value:n},f=0,p=s.length;f<p;++f)if(s[f].name===t){s[f]=u;break}f===p&&s.push(u)}l.tween=s}}function pP(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=xs(this.node(),n).tween,s=0,l=r.length,c;s<l;++s)if((c=r[s]).name===e)return c.value;return null}return this.each((t==null?hP:fP)(n,e,t))}function lb(e,t,n){var r=e._id;return e.each(function(){var s=zs(this,r);(s.value||(s.value={}))[t]=n.apply(this,arguments)}),function(s){return xs(s,r).value[t]}}function YR(e,t){var n;return(typeof t=="number"?Ya:t instanceof bu?rN:(n=bu(t))?(t=n,rN):Y3)(e,t)}function mP(e){return function(){this.removeAttribute(e)}}function gP(e){return function(){this.removeAttributeNS(e.space,e.local)}}function yP(e,t,n){var r,s=n+"",l;return function(){var c=this.getAttribute(e);return c===s?null:c===r?l:l=t(r=c,n)}}function wP(e,t,n){var r,s=n+"",l;return function(){var c=this.getAttributeNS(e.space,e.local);return c===s?null:c===r?l:l=t(r=c,n)}}function vP(e,t,n){var r,s,l;return function(){var c,u=n(this),f;return u==null?void this.removeAttribute(e):(c=this.getAttribute(e),f=u+"",c===f?null:c===r&&f===s?l:(s=f,l=t(r=c,u)))}}function xP(e,t,n){var r,s,l;return function(){var c,u=n(this),f;return u==null?void this.removeAttributeNS(e.space,e.local):(c=this.getAttributeNS(e.space,e.local),f=u+"",c===f?null:c===r&&f===s?l:(s=f,l=t(r=c,u)))}}function bP(e,t){var n=pf(e),r=n==="transform"?J3:YR;return this.attrTween(e,typeof t=="function"?(n.local?xP:vP)(n,r,lb(this,"attr."+e,t)):t==null?(n.local?gP:mP)(n):(n.local?wP:yP)(n,r,t))}function kP(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function NP(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function SP(e,t){var n,r;function s(){var l=t.apply(this,arguments);return l!==r&&(n=(r=l)&&NP(e,l)),n}return s._value=t,s}function jP(e,t){var n,r;function s(){var l=t.apply(this,arguments);return l!==r&&(n=(r=l)&&kP(e,l)),n}return s._value=t,s}function _P(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=pf(e);return this.tween(n,(r.local?SP:jP)(r,t))}function EP(e,t){return function(){ib(this,e).delay=+t.apply(this,arguments)}}function CP(e,t){return t=+t,function(){ib(this,e).delay=t}}function TP(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?EP:CP)(t,e)):xs(this.node(),t).delay}function RP(e,t){return function(){zs(this,e).duration=+t.apply(this,arguments)}}function AP(e,t){return t=+t,function(){zs(this,e).duration=t}}function MP(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?RP:AP)(t,e)):xs(this.node(),t).duration}function IP(e,t){if(typeof t!="function")throw new Error;return function(){zs(this,e).ease=t}}function $P(e){var t=this._id;return arguments.length?this.each(IP(t,e)):xs(this.node(),t).ease}function OP(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;zs(this,e).ease=n}}function LP(e){if(typeof e!="function")throw new Error;return this.each(OP(this._id,e))}function PP(e){typeof e!="function"&&(e=ER(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var l=t[s],c=l.length,u=r[s]=[],f,p=0;p<c;++p)(f=l[p])&&e.call(f,f.__data__,p,l)&&u.push(f);return new ca(r,this._parents,this._name,this._id)}function DP(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,s=n.length,l=Math.min(r,s),c=new Array(r),u=0;u<l;++u)for(var f=t[u],p=n[u],h=f.length,m=c[u]=new Array(h),y,v=0;v<h;++v)(y=f[v]||p[v])&&(m[v]=y);for(;u<r;++u)c[u]=t[u];return new ca(c,this._parents,this._name,this._id)}function FP(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 qP(e,t,n){var r,s,l=FP(t)?ib:zs;return function(){var c=l(this,e),u=c.on;u!==r&&(s=(r=u).copy()).on(t,n),c.on=s}}function BP(e,t){var n=this._id;return arguments.length<2?xs(this.node(),n).on.on(e):this.each(qP(n,e,t))}function zP(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function UP(){return this.on("end.remove",zP(this._id))}function HP(e){var t=this._name,n=this._id;typeof e!="function"&&(e=rb(e));for(var r=this._groups,s=r.length,l=new Array(s),c=0;c<s;++c)for(var u=r[c],f=u.length,p=l[c]=new Array(f),h,m,y=0;y<f;++y)(h=u[y])&&(m=e.call(h,h.__data__,y,u))&&("__data__"in h&&(m.__data__=h.__data__),p[y]=m,gf(p[y],t,n,y,p,xs(h,n)));return new ca(l,this._parents,t,n)}function WP(e){var t=this._name,n=this._id;typeof e!="function"&&(e=_R(e));for(var r=this._groups,s=r.length,l=[],c=[],u=0;u<s;++u)for(var f=r[u],p=f.length,h,m=0;m<p;++m)if(h=f[m]){for(var y=e.call(h,h.__data__,m,f),v,S=xs(h,n),b=0,_=y.length;b<_;++b)(v=y[b])&&gf(v,t,n,b,y,S);l.push(y),c.push(h)}return new ca(l,c,t,n)}var VP=Du.prototype.constructor;function GP(){return new VP(this._groups,this._parents)}function KP(e,t){var n,r,s;return function(){var l=Fl(this,e),c=(this.style.removeProperty(e),Fl(this,e));return l===c?null:l===n&&c===r?s:s=t(n=l,r=c)}}function XR(e){return function(){this.style.removeProperty(e)}}function YP(e,t,n){var r,s=n+"",l;return function(){var c=Fl(this,e);return c===s?null:c===r?l:l=t(r=c,n)}}function XP(e,t,n){var r,s,l;return function(){var c=Fl(this,e),u=n(this),f=u+"";return u==null&&(f=u=(this.style.removeProperty(e),Fl(this,e))),c===f?null:c===r&&f===s?l:(s=f,l=t(r=c,u))}}function ZP(e,t){var n,r,s,l="style."+t,c="end."+l,u;return function(){var f=zs(this,e),p=f.on,h=f.value[l]==null?u||(u=XR(t)):void 0;(p!==n||s!==h)&&(r=(n=p).copy()).on(c,s=h),f.on=r}}function QP(e,t,n){var r=(e+="")=="transform"?Q3:YR;return t==null?this.styleTween(e,KP(e,r)).on("end.style."+e,XR(e)):typeof t=="function"?this.styleTween(e,XP(e,r,lb(this,"style."+e,t))).each(ZP(this._id,e)):this.styleTween(e,YP(e,r,t),n).on("end.style."+e,null)}function JP(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function e4(e,t,n){var r,s;function l(){var c=t.apply(this,arguments);return c!==s&&(r=(s=c)&&JP(e,c,n)),r}return l._value=t,l}function t4(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,e4(e,t,n??""))}function n4(e){return function(){this.textContent=e}}function r4(e){return function(){var t=e(this);this.textContent=t??""}}function s4(e){return this.tween("text",typeof e=="function"?r4(lb(this,"text",e)):n4(e==null?"":e+""))}function a4(e){return function(t){this.textContent=e.call(this,t)}}function o4(e){var t,n;function r(){var s=e.apply(this,arguments);return s!==n&&(t=(n=s)&&a4(s)),t}return r._value=e,r}function i4(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,o4(e))}function l4(){for(var e=this._name,t=this._id,n=ZR(),r=this._groups,s=r.length,l=0;l<s;++l)for(var c=r[l],u=c.length,f,p=0;p<u;++p)if(f=c[p]){var h=xs(f,t);gf(f,e,n,p,c,{time:h.time+h.delay+h.duration,delay:0,duration:h.duration,ease:h.ease})}return new ca(r,this._parents,e,n)}function c4(){var e,t,n=this,r=n._id,s=n.size();return new Promise(function(l,c){var u={value:c},f={value:function(){--s===0&&l()}};n.each(function(){var p=zs(this,r),h=p.on;h!==e&&(t=(e=h).copy(),t._.cancel.push(u),t._.interrupt.push(u),t._.end.push(f)),p.on=t}),s===0&&l()})}var u4=0;function ca(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function ZR(){return++u4}var oa=Du.prototype;ca.prototype={constructor:ca,select:HP,selectAll:WP,selectChild:oa.selectChild,selectChildren:oa.selectChildren,filter:PP,merge:DP,selection:GP,transition:l4,call:oa.call,nodes:oa.nodes,node:oa.node,size:oa.size,empty:oa.empty,each:oa.each,on:BP,attr:bP,attrTween:_P,style:QP,styleTween:t4,text:s4,textTween:i4,remove:UP,tween:pP,delay:TP,duration:MP,ease:$P,easeVarying:LP,end:c4,[Symbol.iterator]:oa[Symbol.iterator]};function d4(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var h4={time:null,delay:0,duration:250,ease:d4};function f4(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 p4(e){var t,n;e instanceof ca?(t=e._id,e=e._name):(t=ZR(),(n=h4).time=ob(),e=e==null?null:e+"");for(var r=this._groups,s=r.length,l=0;l<s;++l)for(var c=r[l],u=c.length,f,p=0;p<u;++p)(f=c[p])&&gf(f,e,t,p,c,n||f4(f,t));return new ca(r,this._parents,e,t)}Du.prototype.interrupt=dP;Du.prototype.transition=p4;const ih=e=>()=>e;function m4(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 ia(e,t,n){this.k=e,this.x=t,this.y=n}ia.prototype={constructor:ia,scale:function(e){return e===1?this:new ia(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new ia(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 la=new ia(1,0,0);ia.prototype;function dm(e){e.stopImmediatePropagation()}function Qc(e){e.preventDefault(),e.stopImmediatePropagation()}function g4(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function y4(){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 uN(){return this.__zoom||la}function w4(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function v4(){return navigator.maxTouchPoints||"ontouchstart"in this}function x4(e,t,n){var r=e.invertX(t[0][0])-n[0][0],s=e.invertX(t[1][0])-n[1][0],l=e.invertY(t[0][1])-n[0][1],c=e.invertY(t[1][1])-n[1][1];return e.translate(s>r?(r+s)/2:Math.min(0,r)||Math.max(0,s),c>l?(l+c)/2:Math.min(0,l)||Math.max(0,c))}function QR(){var e=g4,t=y4,n=x4,r=w4,s=v4,l=[0,1/0],c=[[-1/0,-1/0],[1/0,1/0]],u=250,f=rP,p=ff("start","zoom","end"),h,m,y,v=500,S=150,b=0,_=10;function k(M){M.property("__zoom",uN).on("wheel.zoom",H,{passive:!1}).on("mousedown.zoom",q).on("dblclick.zoom",$).filter(s).on("touchstart.zoom",V).on("touchmove.zoom",ne).on("touchend.zoom touchcancel.zoom",ee).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}k.transform=function(M,Z,K,D){var P=M.selection?M.selection():M;P.property("__zoom",uN),M!==P?R(M,Z,K,D):P.interrupt().each(function(){I(this,arguments).event(D).start().zoom(null,typeof Z=="function"?Z.apply(this,arguments):Z).end()})},k.scaleBy=function(M,Z,K,D){k.scaleTo(M,function(){var P=this.__zoom.k,B=typeof Z=="function"?Z.apply(this,arguments):Z;return P*B},K,D)},k.scaleTo=function(M,Z,K,D){k.transform(M,function(){var P=t.apply(this,arguments),B=this.__zoom,W=K==null?C(P):typeof K=="function"?K.apply(this,arguments):K,F=B.invert(W),G=typeof Z=="function"?Z.apply(this,arguments):Z;return n(E(j(B,G),W,F),P,c)},K,D)},k.translateBy=function(M,Z,K,D){k.transform(M,function(){return n(this.__zoom.translate(typeof Z=="function"?Z.apply(this,arguments):Z,typeof K=="function"?K.apply(this,arguments):K),t.apply(this,arguments),c)},null,D)},k.translateTo=function(M,Z,K,D,P){k.transform(M,function(){var B=t.apply(this,arguments),W=this.__zoom,F=D==null?C(B):typeof D=="function"?D.apply(this,arguments):D;return n(la.translate(F[0],F[1]).scale(W.k).translate(typeof Z=="function"?-Z.apply(this,arguments):-Z,typeof K=="function"?-K.apply(this,arguments):-K),B,c)},D,P)};function j(M,Z){return Z=Math.max(l[0],Math.min(l[1],Z)),Z===M.k?M:new ia(Z,M.x,M.y)}function E(M,Z,K){var D=Z[0]-K[0]*M.k,P=Z[1]-K[1]*M.k;return D===M.x&&P===M.y?M:new ia(M.k,D,P)}function C(M){return[(+M[0][0]+ +M[1][0])/2,(+M[0][1]+ +M[1][1])/2]}function R(M,Z,K,D){M.on("start.zoom",function(){I(this,arguments).event(D).start()}).on("interrupt.zoom end.zoom",function(){I(this,arguments).event(D).end()}).tween("zoom",function(){var P=this,B=arguments,W=I(P,B).event(D),F=t.apply(P,B),G=K==null?C(F):typeof K=="function"?K.apply(P,B):K,re=Math.max(F[1][0]-F[0][0],F[1][1]-F[0][1]),U=P.__zoom,Y=typeof Z=="function"?Z.apply(P,B):Z,z=f(U.invert(G).concat(re/U.k),Y.invert(G).concat(re/Y.k));return function(ie){if(ie===1)ie=Y;else{var le=z(ie),ge=re/le[2];ie=new ia(ge,G[0]-le[0]*ge,G[1]-le[1]*ge)}W.zoom(null,ie)}})}function I(M,Z,K){return!K&&M.__zooming||new O(M,Z)}function O(M,Z){this.that=M,this.args=Z,this.active=0,this.sourceEvent=null,this.extent=t.apply(M,Z),this.taps=0}O.prototype={event:function(M){return M&&(this.sourceEvent=M),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(M,Z){return this.mouse&&M!=="mouse"&&(this.mouse[1]=Z.invert(this.mouse[0])),this.touch0&&M!=="touch"&&(this.touch0[1]=Z.invert(this.touch0[0])),this.touch1&&M!=="touch"&&(this.touch1[1]=Z.invert(this.touch1[0])),this.that.__zoom=Z,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(M){var Z=Pr(this.that).datum();p.call(M,this.that,new m4(M,{sourceEvent:this.sourceEvent,target:k,transform:this.that.__zoom,dispatch:p}),Z)}};function H(M,...Z){if(!e.apply(this,arguments))return;var K=I(this,Z).event(M),D=this.__zoom,P=Math.max(l[0],Math.min(l[1],D.k*Math.pow(2,r.apply(this,arguments)))),B=hs(M);if(K.wheel)(K.mouse[0][0]!==B[0]||K.mouse[0][1]!==B[1])&&(K.mouse[1]=D.invert(K.mouse[0]=B)),clearTimeout(K.wheel);else{if(D.k===P)return;K.mouse=[B,D.invert(B)],Oh(this),K.start()}Qc(M),K.wheel=setTimeout(W,S),K.zoom("mouse",n(E(j(D,P),K.mouse[0],K.mouse[1]),K.extent,c));function W(){K.wheel=null,K.end()}}function q(M,...Z){if(y||!e.apply(this,arguments))return;var K=M.currentTarget,D=I(this,Z,!0).event(M),P=Pr(M.view).on("mousemove.zoom",G,!0).on("mouseup.zoom",re,!0),B=hs(M,K),W=M.clientX,F=M.clientY;PR(M.view),dm(M),D.mouse=[B,this.__zoom.invert(B)],Oh(this),D.start();function G(U){if(Qc(U),!D.moved){var Y=U.clientX-W,z=U.clientY-F;D.moved=Y*Y+z*z>b}D.event(U).zoom("mouse",n(E(D.that.__zoom,D.mouse[0]=hs(U,K),D.mouse[1]),D.extent,c))}function re(U){P.on("mousemove.zoom mouseup.zoom",null),DR(U.view,D.moved),Qc(U),D.event(U).end()}}function $(M,...Z){if(e.apply(this,arguments)){var K=this.__zoom,D=hs(M.changedTouches?M.changedTouches[0]:M,this),P=K.invert(D),B=K.k*(M.shiftKey?.5:2),W=n(E(j(K,B),D,P),t.apply(this,Z),c);Qc(M),u>0?Pr(this).transition().duration(u).call(R,W,D,M):Pr(this).call(k.transform,W,D,M)}}function V(M,...Z){if(e.apply(this,arguments)){var K=M.touches,D=K.length,P=I(this,Z,M.changedTouches.length===D).event(M),B,W,F,G;for(dm(M),W=0;W<D;++W)F=K[W],G=hs(F,this),G=[G,this.__zoom.invert(G),F.identifier],P.touch0?!P.touch1&&P.touch0[2]!==G[2]&&(P.touch1=G,P.taps=0):(P.touch0=G,B=!0,P.taps=1+!!h);h&&(h=clearTimeout(h)),B&&(P.taps<2&&(m=G[0],h=setTimeout(function(){h=null},v)),Oh(this),P.start())}}function ne(M,...Z){if(this.__zooming){var K=I(this,Z).event(M),D=M.changedTouches,P=D.length,B,W,F,G;for(Qc(M),B=0;B<P;++B)W=D[B],F=hs(W,this),K.touch0&&K.touch0[2]===W.identifier?K.touch0[0]=F:K.touch1&&K.touch1[2]===W.identifier&&(K.touch1[0]=F);if(W=K.that.__zoom,K.touch1){var re=K.touch0[0],U=K.touch0[1],Y=K.touch1[0],z=K.touch1[1],ie=(ie=Y[0]-re[0])*ie+(ie=Y[1]-re[1])*ie,le=(le=z[0]-U[0])*le+(le=z[1]-U[1])*le;W=j(W,Math.sqrt(ie/le)),F=[(re[0]+Y[0])/2,(re[1]+Y[1])/2],G=[(U[0]+z[0])/2,(U[1]+z[1])/2]}else if(K.touch0)F=K.touch0[0],G=K.touch0[1];else return;K.zoom("touch",n(E(W,F,G),K.extent,c))}}function ee(M,...Z){if(this.__zooming){var K=I(this,Z).event(M),D=M.changedTouches,P=D.length,B,W;for(dm(M),y&&clearTimeout(y),y=setTimeout(function(){y=null},v),B=0;B<P;++B)W=D[B],K.touch0&&K.touch0[2]===W.identifier?delete K.touch0:K.touch1&&K.touch1[2]===W.identifier&&delete K.touch1;if(K.touch1&&!K.touch0&&(K.touch0=K.touch1,delete K.touch1),K.touch0)K.touch0[1]=this.__zoom.invert(K.touch0[0]);else if(K.end(),K.taps===2&&(W=hs(W,this),Math.hypot(m[0]-W[0],m[1]-W[1])<_)){var F=Pr(this).on("dblclick.zoom");F&&F.apply(this,arguments)}}}return k.wheelDelta=function(M){return arguments.length?(r=typeof M=="function"?M:ih(+M),k):r},k.filter=function(M){return arguments.length?(e=typeof M=="function"?M:ih(!!M),k):e},k.touchable=function(M){return arguments.length?(s=typeof M=="function"?M:ih(!!M),k):s},k.extent=function(M){return arguments.length?(t=typeof M=="function"?M:ih([[+M[0][0],+M[0][1]],[+M[1][0],+M[1][1]]]),k):t},k.scaleExtent=function(M){return arguments.length?(l[0]=+M[0],l[1]=+M[1],k):[l[0],l[1]]},k.translateExtent=function(M){return arguments.length?(c[0][0]=+M[0][0],c[1][0]=+M[1][0],c[0][1]=+M[0][1],c[1][1]=+M[1][1],k):[[c[0][0],c[0][1]],[c[1][0],c[1][1]]]},k.constrain=function(M){return arguments.length?(n=M,k):n},k.duration=function(M){return arguments.length?(u=+M,k):u},k.interpolate=function(M){return arguments.length?(f=M,k):f},k.on=function(){var M=p.on.apply(p,arguments);return M===p?k:M},k.clickDistance=function(M){return arguments.length?(b=(M=+M)*M,k):Math.sqrt(b)},k.tapDistance=function(M){return arguments.length?(_=+M,k):_},k}var Mn=NR();const yf=w.createContext(null),b4=yf.Provider,ua={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.`},JR=ua.error001();function Tt(e,t){const n=w.useContext(yf);if(n===null)throw new Error(JR);return SR(n,e,t)}const tn=()=>{const e=w.useContext(yf);if(e===null)throw new Error(JR);return w.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy}),[e])},k4=e=>e.userSelectionActive?"none":"all";function cb({position:e,children:t,className:n,style:r,...s}){const l=Tt(k4),c=`${e}`.split("-");return ve.createElement("div",{className:jn(["react-flow__panel",n,...c]),style:{...r,pointerEvents:l},...s},t)}function N4({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:ve.createElement(cb,{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"},ve.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}const S4=({x:e,y:t,label:n,labelStyle:r={},labelShowBg:s=!0,labelBgStyle:l={},labelBgPadding:c=[2,4],labelBgBorderRadius:u=2,children:f,className:p,...h})=>{const m=w.useRef(null),[y,v]=w.useState({x:0,y:0,width:0,height:0}),S=jn(["react-flow__edge-textwrapper",p]);return w.useEffect(()=>{if(m.current){const b=m.current.getBBox();v({x:b.x,y:b.y,width:b.width,height:b.height})}},[n]),typeof n>"u"||!n?null:ve.createElement("g",{transform:`translate(${e-y.width/2} ${t-y.height/2})`,className:S,visibility:y.width?"visible":"hidden",...h},s&&ve.createElement("rect",{width:y.width+2*c[0],x:-c[0],y:-c[1],height:y.height+2*c[1],className:"react-flow__edge-textbg",style:l,rx:u,ry:u}),ve.createElement("text",{className:"react-flow__edge-text",y:y.height/2,dy:"0.3em",ref:m,style:r},n),f)};var j4=w.memo(S4);const ub=e=>({width:e.offsetWidth,height:e.offsetHeight}),Bl=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),db=(e={x:0,y:0},t)=>({x:Bl(e.x,t[0][0],t[1][0]),y:Bl(e.y,t[0][1],t[1][1])}),dN=(e,t,n)=>e<t?Bl(Math.abs(e-t),1,50)/50:e>n?-Bl(Math.abs(e-n),1,50)/50:0,eA=(e,t)=>{const n=dN(e.x,35,t.width-35)*20,r=dN(e.y,35,t.height-35)*20;return[n,r]},tA=e=>{var t;return((t=e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},nA=(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)}),Nu=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),rA=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),hN=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),_4=(e,t)=>rA(nA(Nu(e),Nu(t))),g0=(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)},E4=e=>Dr(e.width)&&Dr(e.height)&&Dr(e.x)&&Dr(e.y),Dr=e=>!isNaN(e)&&isFinite(e),Wt=Symbol.for("internals"),sA=["Enter"," ","Escape"],C4=(e,t)=>{},T4=e=>"nativeEvent"in e;function y0(e){var s,l;const t=T4(e)?e.nativeEvent:e,n=((l=(s=t.composedPath)==null?void 0:s.call(t))==null?void 0:l[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 aA=e=>"clientX"in e,to=(e,t)=>{var l,c;const n=aA(e),r=n?e.clientX:(l=e.touches)==null?void 0:l[0].clientX,s=n?e.clientY:(c=e.touches)==null?void 0:c[0].clientY;return{x:r-((t==null?void 0:t.left)??0),y:s-((t==null?void 0:t.top)??0)}},Kh=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0},qu=({id:e,path:t,labelX:n,labelY:r,label:s,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:p,style:h,markerEnd:m,markerStart:y,interactionWidth:v=20})=>ve.createElement(ve.Fragment,null,ve.createElement("path",{id:e,style:h,d:t,fill:"none",className:"react-flow__edge-path",markerEnd:m,markerStart:y}),v&&ve.createElement("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:v,className:"react-flow__edge-interaction"}),s&&Dr(n)&&Dr(r)?ve.createElement(j4,{x:n,y:r,label:s,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:p}):null);qu.displayName="BaseEdge";function Jc(e,t,n){return n===void 0?n:r=>{const s=t().edges.find(l=>l.id===e);s&&n(r,{...s})}}function oA({sourceX:e,sourceY:t,targetX:n,targetY:r}){const s=Math.abs(n-e)/2,l=n<e?n+s:n-s,c=Math.abs(r-t)/2,u=r<t?r+c:r-c;return[l,u,s,c]}function iA({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:s,sourceControlY:l,targetControlX:c,targetControlY:u}){const f=e*.125+s*.375+c*.375+n*.125,p=t*.125+l*.375+u*.375+r*.125,h=Math.abs(f-e),m=Math.abs(p-t);return[f,p,h,m]}var ui;(function(e){e.Strict="strict",e.Loose="loose"})(ui||(ui={}));var ni;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(ni||(ni={}));var Su;(function(e){e.Partial="partial",e.Full="full"})(Su||(Su={}));var Za;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Za||(Za={}));var Yh;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Yh||(Yh={}));var nt;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(nt||(nt={}));function fN({pos:e,x1:t,y1:n,x2:r,y2:s}){return e===nt.Left||e===nt.Right?[.5*(t+r),n]:[t,.5*(n+s)]}function lA({sourceX:e,sourceY:t,sourcePosition:n=nt.Bottom,targetX:r,targetY:s,targetPosition:l=nt.Top}){const[c,u]=fN({pos:n,x1:e,y1:t,x2:r,y2:s}),[f,p]=fN({pos:l,x1:r,y1:s,x2:e,y2:t}),[h,m,y,v]=iA({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:c,sourceControlY:u,targetControlX:f,targetControlY:p});return[`M${e},${t} C${c},${u} ${f},${p} ${r},${s}`,h,m,y,v]}const hb=w.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:s=nt.Bottom,targetPosition:l=nt.Top,label:c,labelStyle:u,labelShowBg:f,labelBgStyle:p,labelBgPadding:h,labelBgBorderRadius:m,style:y,markerEnd:v,markerStart:S,interactionWidth:b})=>{const[_,k,j]=lA({sourceX:e,sourceY:t,sourcePosition:s,targetX:n,targetY:r,targetPosition:l});return ve.createElement(qu,{path:_,labelX:k,labelY:j,label:c,labelStyle:u,labelShowBg:f,labelBgStyle:p,labelBgPadding:h,labelBgBorderRadius:m,style:y,markerEnd:v,markerStart:S,interactionWidth:b})});hb.displayName="SimpleBezierEdge";const pN={[nt.Left]:{x:-1,y:0},[nt.Right]:{x:1,y:0},[nt.Top]:{x:0,y:-1},[nt.Bottom]:{x:0,y:1}},R4=({source:e,sourcePosition:t=nt.Bottom,target:n})=>t===nt.Left||t===nt.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},mN=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function A4({source:e,sourcePosition:t=nt.Bottom,target:n,targetPosition:r=nt.Top,center:s,offset:l}){const c=pN[t],u=pN[r],f={x:e.x+c.x*l,y:e.y+c.y*l},p={x:n.x+u.x*l,y:n.y+u.y*l},h=R4({source:f,sourcePosition:t,target:p}),m=h.x!==0?"x":"y",y=h[m];let v=[],S,b;const _={x:0,y:0},k={x:0,y:0},[j,E,C,R]=oA({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(c[m]*u[m]===-1){S=s.x??j,b=s.y??E;const O=[{x:S,y:f.y},{x:S,y:p.y}],H=[{x:f.x,y:b},{x:p.x,y:b}];c[m]===y?v=m==="x"?O:H:v=m==="x"?H:O}else{const O=[{x:f.x,y:p.y}],H=[{x:p.x,y:f.y}];if(m==="x"?v=c.x===y?H:O:v=c.y===y?O:H,t===r){const ee=Math.abs(e[m]-n[m]);if(ee<=l){const M=Math.min(l-1,l-ee);c[m]===y?_[m]=(f[m]>e[m]?-1:1)*M:k[m]=(p[m]>n[m]?-1:1)*M}}if(t!==r){const ee=m==="x"?"y":"x",M=c[m]===u[ee],Z=f[ee]>p[ee],K=f[ee]<p[ee];(c[m]===1&&(!M&&Z||M&&K)||c[m]!==1&&(!M&&K||M&&Z))&&(v=m==="x"?O:H)}const q={x:f.x+_.x,y:f.y+_.y},$={x:p.x+k.x,y:p.y+k.y},V=Math.max(Math.abs(q.x-v[0].x),Math.abs($.x-v[0].x)),ne=Math.max(Math.abs(q.y-v[0].y),Math.abs($.y-v[0].y));V>=ne?(S=(q.x+$.x)/2,b=v[0].y):(S=v[0].x,b=(q.y+$.y)/2)}return[[e,{x:f.x+_.x,y:f.y+_.y},...v,{x:p.x+k.x,y:p.y+k.y},n],S,b,C,R]}function M4(e,t,n,r){const s=Math.min(mN(e,t)/2,mN(t,n)/2,r),{x:l,y:c}=t;if(e.x===l&&l===n.x||e.y===c&&c===n.y)return`L${l} ${c}`;if(e.y===c){const p=e.x<n.x?-1:1,h=e.y<n.y?1:-1;return`L ${l+s*p},${c}Q ${l},${c} ${l},${c+s*h}`}const u=e.x<n.x?1:-1,f=e.y<n.y?-1:1;return`L ${l},${c+s*f}Q ${l},${c} ${l+s*u},${c}`}function w0({sourceX:e,sourceY:t,sourcePosition:n=nt.Bottom,targetX:r,targetY:s,targetPosition:l=nt.Top,borderRadius:c=5,centerX:u,centerY:f,offset:p=20}){const[h,m,y,v,S]=A4({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:s},targetPosition:l,center:{x:u,y:f},offset:p});return[h.reduce((_,k,j)=>{let E="";return j>0&&j<h.length-1?E=M4(h[j-1],k,h[j+1],c):E=`${j===0?"M":"L"}${k.x} ${k.y}`,_+=E,_},""),m,y,v,S]}const wf=w.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,label:s,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:p,style:h,sourcePosition:m=nt.Bottom,targetPosition:y=nt.Top,markerEnd:v,markerStart:S,pathOptions:b,interactionWidth:_})=>{const[k,j,E]=w0({sourceX:e,sourceY:t,sourcePosition:m,targetX:n,targetY:r,targetPosition:y,borderRadius:b==null?void 0:b.borderRadius,offset:b==null?void 0:b.offset});return ve.createElement(qu,{path:k,labelX:j,labelY:E,label:s,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:p,style:h,markerEnd:v,markerStart:S,interactionWidth:_})});wf.displayName="SmoothStepEdge";const fb=w.memo(e=>{var t;return ve.createElement(wf,{...e,pathOptions:w.useMemo(()=>{var n;return{borderRadius:0,offset:(n=e.pathOptions)==null?void 0:n.offset}},[(t=e.pathOptions)==null?void 0:t.offset])})});fb.displayName="StepEdge";function I4({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[s,l,c,u]=oA({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,s,l,c,u]}const pb=w.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,label:s,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:p,style:h,markerEnd:m,markerStart:y,interactionWidth:v})=>{const[S,b,_]=I4({sourceX:e,sourceY:t,targetX:n,targetY:r});return ve.createElement(qu,{path:S,labelX:b,labelY:_,label:s,labelStyle:l,labelShowBg:c,labelBgStyle:u,labelBgPadding:f,labelBgBorderRadius:p,style:h,markerEnd:m,markerStart:y,interactionWidth:v})});pb.displayName="StraightEdge";function lh(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function gN({pos:e,x1:t,y1:n,x2:r,y2:s,c:l}){switch(e){case nt.Left:return[t-lh(t-r,l),n];case nt.Right:return[t+lh(r-t,l),n];case nt.Top:return[t,n-lh(n-s,l)];case nt.Bottom:return[t,n+lh(s-n,l)]}}function mb({sourceX:e,sourceY:t,sourcePosition:n=nt.Bottom,targetX:r,targetY:s,targetPosition:l=nt.Top,curvature:c=.25}){const[u,f]=gN({pos:n,x1:e,y1:t,x2:r,y2:s,c}),[p,h]=gN({pos:l,x1:r,y1:s,x2:e,y2:t,c}),[m,y,v,S]=iA({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:u,sourceControlY:f,targetControlX:p,targetControlY:h});return[`M${e},${t} C${u},${f} ${p},${h} ${r},${s}`,m,y,v,S]}const Xh=w.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:s=nt.Bottom,targetPosition:l=nt.Top,label:c,labelStyle:u,labelShowBg:f,labelBgStyle:p,labelBgPadding:h,labelBgBorderRadius:m,style:y,markerEnd:v,markerStart:S,pathOptions:b,interactionWidth:_})=>{const[k,j,E]=mb({sourceX:e,sourceY:t,sourcePosition:s,targetX:n,targetY:r,targetPosition:l,curvature:b==null?void 0:b.curvature});return ve.createElement(qu,{path:k,labelX:j,labelY:E,label:c,labelStyle:u,labelShowBg:f,labelBgStyle:p,labelBgPadding:h,labelBgBorderRadius:m,style:y,markerEnd:v,markerStart:S,interactionWidth:_})});Xh.displayName="BezierEdge";const gb=w.createContext(null),$4=gb.Provider;gb.Consumer;const O4=()=>w.useContext(gb),L4=e=>"id"in e&&"source"in e&&"target"in e,P4=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`reactflow__edge-${e}${t||""}-${n}${r||""}`,v0=(e,t)=>typeof e>"u"?"":typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`,D4=(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)),F4=(e,t)=>{if(!e.source||!e.target)return t;let n;return L4(e)?n={...e}:n={...e,id:P4(e)},D4(n,t)?t:t.concat(n)},x0=({x:e,y:t},[n,r,s],l,[c,u])=>{const f={x:(e-n)/s,y:(t-r)/s};return l?{x:c*Math.round(f.x/c),y:u*Math.round(f.y/u)}:f},cA=({x:e,y:t},[n,r,s])=>({x:e*s+n,y:t*s+r}),ai=(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}},vf=(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:l,y:c}=ai(s,t).positionAbsolute;return nA(r,Nu({x:l,y:c,width:s.width||0,height:s.height||0}))},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return rA(n)},uA=(e,t,[n,r,s]=[0,0,1],l=!1,c=!1,u=[0,0])=>{const f={x:(t.x-n)/s,y:(t.y-r)/s,width:t.width/s,height:t.height/s},p=[];return e.forEach(h=>{const{width:m,height:y,selectable:v=!0,hidden:S=!1}=h;if(c&&!v||S)return!1;const{positionAbsolute:b}=ai(h,u),_={x:b.x,y:b.y,width:m||0,height:y||0},k=g0(f,_),j=typeof m>"u"||typeof y>"u"||m===null||y===null,E=l&&k>0,C=(m||0)*(y||0);(j||E||k>=C||h.dragging)&&p.push(h)}),p},dA=(e,t)=>{const n=e.map(r=>r.id);return t.filter(r=>n.includes(r.source)||n.includes(r.target))},hA=(e,t,n,r,s,l=.1)=>{const c=t/(e.width*(1+l)),u=n/(e.height*(1+l)),f=Math.min(c,u),p=Bl(f,r,s),h=e.x+e.width/2,m=e.y+e.height/2,y=t/2-h*p,v=n/2-m*p;return{x:y,y:v,zoom:p}},Jo=(e,t=0)=>e.transition().duration(t);function yN(e,t,n,r){return(t[n]||[]).reduce((s,l)=>{var c,u;return`${e.id}-${l.id}-${n}`!==r&&s.push({id:l.id||null,type:n,nodeId:e.id,x:(((c=e.positionAbsolute)==null?void 0:c.x)??0)+l.x+l.width/2,y:(((u=e.positionAbsolute)==null?void 0:u.y)??0)+l.y+l.height/2}),s},[])}function q4(e,t,n,r,s,l){const{x:c,y:u}=to(e),p=t.elementsFromPoint(c,u).find(S=>S.classList.contains("react-flow__handle"));if(p){const S=p.getAttribute("data-nodeid");if(S){const b=yb(void 0,p),_=p.getAttribute("data-handleid"),k=l({nodeId:S,id:_,type:b});if(k){const j=s.find(E=>E.nodeId===S&&E.type===b&&E.id===_);return{handle:{id:_,type:b,nodeId:S,x:(j==null?void 0:j.x)||n.x,y:(j==null?void 0:j.y)||n.y},validHandleResult:k}}}}let h=[],m=1/0;if(s.forEach(S=>{const b=Math.sqrt((S.x-n.x)**2+(S.y-n.y)**2);if(b<=r){const _=l(S);b<=m&&(b<m?h=[{handle:S,validHandleResult:_}]:b===m&&h.push({handle:S,validHandleResult:_}),m=b)}}),!h.length)return{handle:null,validHandleResult:fA()};if(h.length===1)return h[0];const y=h.some(({validHandleResult:S})=>S.isValid),v=h.some(({handle:S})=>S.type==="target");return h.find(({handle:S,validHandleResult:b})=>v?S.type==="target":y?b.isValid:!0)||h[0]}const B4={source:null,target:null,sourceHandle:null,targetHandle:null},fA=()=>({handleDomNode:null,isValid:!1,connection:B4,endHandle:null});function pA(e,t,n,r,s,l,c){const u=s==="target",f=c.querySelector(`.react-flow__handle[data-id="${e==null?void 0:e.nodeId}-${e==null?void 0:e.id}-${e==null?void 0:e.type}"]`),p={...fA(),handleDomNode:f};if(f){const h=yb(void 0,f),m=f.getAttribute("data-nodeid"),y=f.getAttribute("data-handleid"),v=f.classList.contains("connectable"),S=f.classList.contains("connectableend"),b={source:u?m:n,sourceHandle:u?y:r,target:u?n:m,targetHandle:u?r:y};p.connection=b,v&&S&&(t===ui.Strict?u&&h==="source"||!u&&h==="target":m!==n||y!==r)&&(p.endHandle={nodeId:m,handleId:y,type:h},p.isValid=l(b))}return p}function z4({nodes:e,nodeId:t,handleId:n,handleType:r}){return e.reduce((s,l)=>{if(l[Wt]){const{handleBounds:c}=l[Wt];let u=[],f=[];c&&(u=yN(l,c,"source",`${t}-${n}-${r}`),f=yN(l,c,"target",`${t}-${n}-${r}`)),s.push(...u,...f)}return s},[])}function yb(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function hm(e){e==null||e.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function U4(e,t){let n=null;return t?n="valid":e&&!t&&(n="invalid"),n}function mA({event:e,handleId:t,nodeId:n,onConnect:r,isTarget:s,getState:l,setState:c,isValidConnection:u,edgeUpdaterType:f,onReconnectEnd:p}){const h=tA(e.target),{connectionMode:m,domNode:y,autoPanOnConnect:v,connectionRadius:S,onConnectStart:b,panBy:_,getNodes:k,cancelConnection:j}=l();let E=0,C;const{x:R,y:I}=to(e),O=h==null?void 0:h.elementFromPoint(R,I),H=yb(f,O),q=y==null?void 0:y.getBoundingClientRect();if(!q||!H)return;let $,V=to(e,q),ne=!1,ee=null,M=!1,Z=null;const K=z4({nodes:k(),nodeId:n,handleId:t,handleType:H}),D=()=>{if(!v)return;const[W,F]=eA(V,q);_({x:W,y:F}),E=requestAnimationFrame(D)};c({connectionPosition:V,connectionStatus:null,connectionNodeId:n,connectionHandleId:t,connectionHandleType:H,connectionStartHandle:{nodeId:n,handleId:t,type:H},connectionEndHandle:null}),b==null||b(e,{nodeId:n,handleId:t,handleType:H});function P(W){const{transform:F}=l();V=to(W,q);const{handle:G,validHandleResult:re}=q4(W,h,x0(V,F,!1,[1,1]),S,K,U=>pA(U,m,n,t,s?"target":"source",u,h));if(C=G,ne||(D(),ne=!0),Z=re.handleDomNode,ee=re.connection,M=re.isValid,c({connectionPosition:C&&M?cA({x:C.x,y:C.y},F):V,connectionStatus:U4(!!C,M),connectionEndHandle:re.endHandle}),!C&&!M&&!Z)return hm($);ee.source!==ee.target&&Z&&(hm($),$=Z,Z.classList.add("connecting","react-flow__handle-connecting"),Z.classList.toggle("valid",M),Z.classList.toggle("react-flow__handle-valid",M))}function B(W){var F,G;(C||Z)&&ee&&M&&(r==null||r(ee)),(G=(F=l()).onConnectEnd)==null||G.call(F,W),f&&(p==null||p(W)),hm($),j(),cancelAnimationFrame(E),ne=!1,M=!1,ee=null,Z=null,h.removeEventListener("mousemove",P),h.removeEventListener("mouseup",B),h.removeEventListener("touchmove",P),h.removeEventListener("touchend",B)}h.addEventListener("mousemove",P),h.addEventListener("mouseup",B),h.addEventListener("touchmove",P),h.addEventListener("touchend",B)}const wN=()=>!0,H4=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),W4=(e,t,n)=>r=>{const{connectionStartHandle:s,connectionEndHandle:l,connectionClickStartHandle:c}=r;return{connecting:(s==null?void 0:s.nodeId)===e&&(s==null?void 0:s.handleId)===t&&(s==null?void 0:s.type)===n||(l==null?void 0:l.nodeId)===e&&(l==null?void 0:l.handleId)===t&&(l==null?void 0:l.type)===n,clickConnecting:(c==null?void 0:c.nodeId)===e&&(c==null?void 0:c.handleId)===t&&(c==null?void 0:c.type)===n}},gA=w.forwardRef(({type:e="source",position:t=nt.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:s=!0,isConnectableEnd:l=!0,id:c,onConnect:u,children:f,className:p,onMouseDown:h,onTouchStart:m,...y},v)=>{var q,$;const S=c||null,b=e==="target",_=tn(),k=O4(),{connectOnClick:j,noPanClassName:E}=Tt(H4,fn),{connecting:C,clickConnecting:R}=Tt(W4(k,S,e),fn);k||($=(q=_.getState()).onError)==null||$.call(q,"010",ua.error010());const I=V=>{const{defaultEdgeOptions:ne,onConnect:ee,hasDefaultEdges:M}=_.getState(),Z={...ne,...V};if(M){const{edges:K,setEdges:D}=_.getState();D(F4(Z,K))}ee==null||ee(Z),u==null||u(Z)},O=V=>{if(!k)return;const ne=aA(V);s&&(ne&&V.button===0||!ne)&&mA({event:V,handleId:S,nodeId:k,onConnect:I,isTarget:b,getState:_.getState,setState:_.setState,isValidConnection:n||_.getState().isValidConnection||wN}),ne?h==null||h(V):m==null||m(V)},H=V=>{const{onClickConnectStart:ne,onClickConnectEnd:ee,connectionClickStartHandle:M,connectionMode:Z,isValidConnection:K}=_.getState();if(!k||!M&&!s)return;if(!M){ne==null||ne(V,{nodeId:k,handleId:S,handleType:e}),_.setState({connectionClickStartHandle:{nodeId:k,type:e,handleId:S}});return}const D=tA(V.target),P=n||K||wN,{connection:B,isValid:W}=pA({nodeId:k,id:S,type:e},Z,M.nodeId,M.handleId||null,M.type,P,D);W&&I(B),ee==null||ee(V),_.setState({connectionClickStartHandle:null})};return ve.createElement("div",{"data-handleid":S,"data-nodeid":k,"data-handlepos":t,"data-id":`${k}-${S}-${e}`,className:jn(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",E,p,{source:!b,target:b,connectable:r,connectablestart:s,connectableend:l,connecting:R,connectionindicator:r&&(s&&!C||l&&C)}]),onMouseDown:O,onTouchStart:O,onClick:j?H:void 0,ref:v,...y},f)});gA.displayName="Handle";var di=w.memo(gA);const yA=({data:e,isConnectable:t,targetPosition:n=nt.Top,sourcePosition:r=nt.Bottom})=>ve.createElement(ve.Fragment,null,ve.createElement(di,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,ve.createElement(di,{type:"source",position:r,isConnectable:t}));yA.displayName="DefaultNode";var b0=w.memo(yA);const wA=({data:e,isConnectable:t,sourcePosition:n=nt.Bottom})=>ve.createElement(ve.Fragment,null,e==null?void 0:e.label,ve.createElement(di,{type:"source",position:n,isConnectable:t}));wA.displayName="InputNode";var vA=w.memo(wA);const xA=({data:e,isConnectable:t,targetPosition:n=nt.Top})=>ve.createElement(ve.Fragment,null,ve.createElement(di,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label);xA.displayName="OutputNode";var bA=w.memo(xA);const wb=()=>null;wb.displayName="GroupNode";const V4=e=>({selectedNodes:e.getNodes().filter(t=>t.selected),selectedEdges:e.edges.filter(t=>t.selected).map(t=>({...t}))}),ch=e=>e.id;function G4(e,t){return fn(e.selectedNodes.map(ch),t.selectedNodes.map(ch))&&fn(e.selectedEdges.map(ch),t.selectedEdges.map(ch))}const kA=w.memo(({onSelectionChange:e})=>{const t=tn(),{selectedNodes:n,selectedEdges:r}=Tt(V4,G4);return w.useEffect(()=>{const s={nodes:n,edges:r};e==null||e(s),t.getState().onSelectionChange.forEach(l=>l(s))},[n,r,e]),null});kA.displayName="SelectionListener";const K4=e=>!!e.onSelectionChange;function Y4({onSelectionChange:e}){const t=Tt(K4);return e||t?ve.createElement(kA,{onSelectionChange:e}):null}const X4=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 ml(e,t){w.useEffect(()=>{typeof e<"u"&&t(e)},[e])}function mt(e,t,n){w.useEffect(()=>{typeof t<"u"&&n({[e]:t})},[t])}const Z4=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:s,onConnectStart:l,onConnectEnd:c,onClickConnectStart:u,onClickConnectEnd:f,nodesDraggable:p,nodesConnectable:h,nodesFocusable:m,edgesFocusable:y,edgesUpdatable:v,elevateNodesOnSelect:S,minZoom:b,maxZoom:_,nodeExtent:k,onNodesChange:j,onEdgesChange:E,elementsSelectable:C,connectionMode:R,snapGrid:I,snapToGrid:O,translateExtent:H,connectOnClick:q,defaultEdgeOptions:$,fitView:V,fitViewOptions:ne,onNodesDelete:ee,onEdgesDelete:M,onNodeDrag:Z,onNodeDragStart:K,onNodeDragStop:D,onSelectionDrag:P,onSelectionDragStart:B,onSelectionDragStop:W,noPanClassName:F,nodeOrigin:G,rfId:re,autoPanOnConnect:U,autoPanOnNodeDrag:Y,onError:z,connectionRadius:ie,isValidConnection:le,nodeDragThreshold:ge})=>{const{setNodes:Ne,setEdges:Ie,setDefaultNodesAndEdges:Ge,setMinZoom:Pe,setMaxZoom:Be,setTranslateExtent:Te,setNodeExtent:st,reset:de}=Tt(X4,fn),ue=tn();return w.useEffect(()=>{const se=r==null?void 0:r.map(be=>({...be,...$}));return Ge(n,se),()=>{de()}},[]),mt("defaultEdgeOptions",$,ue.setState),mt("connectionMode",R,ue.setState),mt("onConnect",s,ue.setState),mt("onConnectStart",l,ue.setState),mt("onConnectEnd",c,ue.setState),mt("onClickConnectStart",u,ue.setState),mt("onClickConnectEnd",f,ue.setState),mt("nodesDraggable",p,ue.setState),mt("nodesConnectable",h,ue.setState),mt("nodesFocusable",m,ue.setState),mt("edgesFocusable",y,ue.setState),mt("edgesUpdatable",v,ue.setState),mt("elementsSelectable",C,ue.setState),mt("elevateNodesOnSelect",S,ue.setState),mt("snapToGrid",O,ue.setState),mt("snapGrid",I,ue.setState),mt("onNodesChange",j,ue.setState),mt("onEdgesChange",E,ue.setState),mt("connectOnClick",q,ue.setState),mt("fitViewOnInit",V,ue.setState),mt("fitViewOnInitOptions",ne,ue.setState),mt("onNodesDelete",ee,ue.setState),mt("onEdgesDelete",M,ue.setState),mt("onNodeDrag",Z,ue.setState),mt("onNodeDragStart",K,ue.setState),mt("onNodeDragStop",D,ue.setState),mt("onSelectionDrag",P,ue.setState),mt("onSelectionDragStart",B,ue.setState),mt("onSelectionDragStop",W,ue.setState),mt("noPanClassName",F,ue.setState),mt("nodeOrigin",G,ue.setState),mt("rfId",re,ue.setState),mt("autoPanOnConnect",U,ue.setState),mt("autoPanOnNodeDrag",Y,ue.setState),mt("onError",z,ue.setState),mt("connectionRadius",ie,ue.setState),mt("isValidConnection",le,ue.setState),mt("nodeDragThreshold",ge,ue.setState),ml(e,Ne),ml(t,Ie),ml(b,Pe),ml(_,Be),ml(H,Te),ml(k,st),null},vN={display:"none"},Q4={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},NA="react-flow__node-desc",SA="react-flow__edge-desc",J4="react-flow__aria-live",eD=e=>e.ariaLiveMessage;function tD({rfId:e}){const t=Tt(eD);return ve.createElement("div",{id:`${J4}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:Q4},t)}function nD({rfId:e,disableKeyboardA11y:t}){return ve.createElement(ve.Fragment,null,ve.createElement("div",{id:`${NA}-${e}`,style:vN},"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."," "),ve.createElement("div",{id:`${SA}-${e}`,style:vN},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!t&&ve.createElement(tD,{rfId:e}))}var ju=(e=null,t={actInsideInputWithModifier:!0})=>{const[n,r]=w.useState(!1),s=w.useRef(!1),l=w.useRef(new Set([])),[c,u]=w.useMemo(()=>{if(e!==null){const p=(Array.isArray(e)?e:[e]).filter(m=>typeof m=="string").map(m=>m.split("+")),h=p.reduce((m,y)=>m.concat(...y),[]);return[p,h]}return[[],[]]},[e]);return w.useEffect(()=>{const f=typeof document<"u"?document:null,p=(t==null?void 0:t.target)||f;if(e!==null){const h=v=>{if(s.current=v.ctrlKey||v.metaKey||v.shiftKey,(!s.current||s.current&&!t.actInsideInputWithModifier)&&y0(v))return!1;const b=bN(v.code,u);l.current.add(v[b]),xN(c,l.current,!1)&&(v.preventDefault(),r(!0))},m=v=>{if((!s.current||s.current&&!t.actInsideInputWithModifier)&&y0(v))return!1;const b=bN(v.code,u);xN(c,l.current,!0)?(r(!1),l.current.clear()):l.current.delete(v[b]),v.key==="Meta"&&l.current.clear(),s.current=!1},y=()=>{l.current.clear(),r(!1)};return p==null||p.addEventListener("keydown",h),p==null||p.addEventListener("keyup",m),window.addEventListener("blur",y),()=>{p==null||p.removeEventListener("keydown",h),p==null||p.removeEventListener("keyup",m),window.removeEventListener("blur",y)}}},[e,r]),n};function xN(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(s=>t.has(s)))}function bN(e,t){return t.includes(e)?"code":"key"}function jA(e,t,n,r){var u,f;const s=e.parentNode||e.parentId;if(!s)return n;const l=t.get(s),c=ai(l,r);return jA(l,t,{x:(n.x??0)+c.x,y:(n.y??0)+c.y,z:(((u=l[Wt])==null?void 0:u.z)??0)>(n.z??0)?((f=l[Wt])==null?void 0:f.z)??0:n.z??0},r)}function _A(e,t,n){e.forEach(r=>{var l;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:c,y:u,z:f}=jA(r,e,{...r.position,z:((l=r[Wt])==null?void 0:l.z)??0},t);r.positionAbsolute={x:c,y:u},r[Wt].z=f,n!=null&&n[r.id]&&(r[Wt].isParent=!0)}})}function fm(e,t,n,r){const s=new Map,l={},c=r?1e3:0;return e.forEach(u=>{var v;const f=(Dr(u.zIndex)?u.zIndex:0)+(u.selected?c:0),p=t.get(u.id),h={...u,positionAbsolute:{x:u.position.x,y:u.position.y}},m=u.parentNode||u.parentId;m&&(l[m]=!0);const y=(p==null?void 0:p.type)&&(p==null?void 0:p.type)!==u.type;Object.defineProperty(h,Wt,{enumerable:!1,value:{handleBounds:y||(v=p==null?void 0:p[Wt])==null?void 0:v.handleBounds,z:f}}),s.set(u.id,h)}),_A(s,n,l),s}function EA(e,t={}){const{getNodes:n,width:r,height:s,minZoom:l,maxZoom:c,d3Zoom:u,d3Selection:f,fitViewOnInitDone:p,fitViewOnInit:h,nodeOrigin:m}=e(),y=t.initial&&!p&&h;if(u&&f&&(y||!t.initial)){const S=n().filter(_=>{var j;const k=t.includeHiddenNodes?_.width&&_.height:!_.hidden;return(j=t.nodes)!=null&&j.length?k&&t.nodes.some(E=>E.id===_.id):k}),b=S.every(_=>_.width&&_.height);if(S.length>0&&b){const _=vf(S,m),{x:k,y:j,zoom:E}=hA(_,r,s,t.minZoom??l,t.maxZoom??c,t.padding??.1),C=la.translate(k,j).scale(E);return typeof t.duration=="number"&&t.duration>0?u.transform(Jo(f,t.duration),C):u.transform(f,C),!0}}return!1}function rD(e,t){return e.forEach(n=>{const r=t.get(n.id);r&&t.set(r.id,{...r,[Wt]:r[Wt],selected:n.selected})}),new Map(t)}function sD(e,t){return t.map(n=>{const r=e.find(s=>s.id===n.id);return r&&(n.selected=r.selected),n})}function uh({changedNodes:e,changedEdges:t,get:n,set:r}){const{nodeInternals:s,edges:l,onNodesChange:c,onEdgesChange:u,hasDefaultNodes:f,hasDefaultEdges:p}=n();e!=null&&e.length&&(f&&r({nodeInternals:rD(e,s)}),c==null||c(e)),t!=null&&t.length&&(p&&r({edges:sD(t,l)}),u==null||u(t))}const gl=()=>{},aD={zoomIn:gl,zoomOut:gl,zoomTo:gl,getZoom:()=>1,setViewport:gl,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:gl,fitBounds:gl,project:e=>e,screenToFlowPosition:e=>e,flowToScreenPosition:e=>e,viewportInitialized:!1},oD=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection}),iD=()=>{const e=tn(),{d3Zoom:t,d3Selection:n}=Tt(oD,fn);return w.useMemo(()=>n&&t?{zoomIn:s=>t.scaleBy(Jo(n,s==null?void 0:s.duration),1.2),zoomOut:s=>t.scaleBy(Jo(n,s==null?void 0:s.duration),1/1.2),zoomTo:(s,l)=>t.scaleTo(Jo(n,l==null?void 0:l.duration),s),getZoom:()=>e.getState().transform[2],setViewport:(s,l)=>{const[c,u,f]=e.getState().transform,p=la.translate(s.x??c,s.y??u).scale(s.zoom??f);t.transform(Jo(n,l==null?void 0:l.duration),p)},getViewport:()=>{const[s,l,c]=e.getState().transform;return{x:s,y:l,zoom:c}},fitView:s=>EA(e.getState,s),setCenter:(s,l,c)=>{const{width:u,height:f,maxZoom:p}=e.getState(),h=typeof(c==null?void 0:c.zoom)<"u"?c.zoom:p,m=u/2-s*h,y=f/2-l*h,v=la.translate(m,y).scale(h);t.transform(Jo(n,c==null?void 0:c.duration),v)},fitBounds:(s,l)=>{const{width:c,height:u,minZoom:f,maxZoom:p}=e.getState(),{x:h,y:m,zoom:y}=hA(s,c,u,f,p,(l==null?void 0:l.padding)??.1),v=la.translate(h,m).scale(y);t.transform(Jo(n,l==null?void 0:l.duration),v)},project:s=>{const{transform:l,snapToGrid:c,snapGrid:u}=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"),x0(s,l,c,u)},screenToFlowPosition:s=>{const{transform:l,snapToGrid:c,snapGrid:u,domNode:f}=e.getState();if(!f)return s;const{x:p,y:h}=f.getBoundingClientRect(),m={x:s.x-p,y:s.y-h};return x0(m,l,c,u)},flowToScreenPosition:s=>{const{transform:l,domNode:c}=e.getState();if(!c)return s;const{x:u,y:f}=c.getBoundingClientRect(),p=cA(s,l);return{x:p.x+u,y:p.y+f}},viewportInitialized:!0}:aD,[t,n])};function xf(){const e=iD(),t=tn(),n=w.useCallback(()=>t.getState().getNodes().map(b=>({...b})),[]),r=w.useCallback(b=>t.getState().nodeInternals.get(b),[]),s=w.useCallback(()=>{const{edges:b=[]}=t.getState();return b.map(_=>({..._}))},[]),l=w.useCallback(b=>{const{edges:_=[]}=t.getState();return _.find(k=>k.id===b)},[]),c=w.useCallback(b=>{const{getNodes:_,setNodes:k,hasDefaultNodes:j,onNodesChange:E}=t.getState(),C=_(),R=typeof b=="function"?b(C):b;if(j)k(R);else if(E){const I=R.length===0?C.map(O=>({type:"remove",id:O.id})):R.map(O=>({item:O,type:"reset"}));E(I)}},[]),u=w.useCallback(b=>{const{edges:_=[],setEdges:k,hasDefaultEdges:j,onEdgesChange:E}=t.getState(),C=typeof b=="function"?b(_):b;if(j)k(C);else if(E){const R=C.length===0?_.map(I=>({type:"remove",id:I.id})):C.map(I=>({item:I,type:"reset"}));E(R)}},[]),f=w.useCallback(b=>{const _=Array.isArray(b)?b:[b],{getNodes:k,setNodes:j,hasDefaultNodes:E,onNodesChange:C}=t.getState();if(E){const I=[...k(),..._];j(I)}else if(C){const R=_.map(I=>({item:I,type:"add"}));C(R)}},[]),p=w.useCallback(b=>{const _=Array.isArray(b)?b:[b],{edges:k=[],setEdges:j,hasDefaultEdges:E,onEdgesChange:C}=t.getState();if(E)j([...k,..._]);else if(C){const R=_.map(I=>({item:I,type:"add"}));C(R)}},[]),h=w.useCallback(()=>{const{getNodes:b,edges:_=[],transform:k}=t.getState(),[j,E,C]=k;return{nodes:b().map(R=>({...R})),edges:_.map(R=>({...R})),viewport:{x:j,y:E,zoom:C}}},[]),m=w.useCallback(({nodes:b,edges:_})=>{const{nodeInternals:k,getNodes:j,edges:E,hasDefaultNodes:C,hasDefaultEdges:R,onNodesDelete:I,onEdgesDelete:O,onNodesChange:H,onEdgesChange:q}=t.getState(),$=(b||[]).map(Z=>Z.id),V=(_||[]).map(Z=>Z.id),ne=j().reduce((Z,K)=>{const D=K.parentNode||K.parentId,P=!$.includes(K.id)&&D&&Z.find(W=>W.id===D);return(typeof K.deletable=="boolean"?K.deletable:!0)&&($.includes(K.id)||P)&&Z.push(K),Z},[]),ee=E.filter(Z=>typeof Z.deletable=="boolean"?Z.deletable:!0),M=ee.filter(Z=>V.includes(Z.id));if(ne||M){const Z=dA(ne,ee),K=[...M,...Z],D=K.reduce((P,B)=>(P.includes(B.id)||P.push(B.id),P),[]);if((R||C)&&(R&&t.setState({edges:E.filter(P=>!D.includes(P.id))}),C&&(ne.forEach(P=>{k.delete(P.id)}),t.setState({nodeInternals:new Map(k)}))),D.length>0&&(O==null||O(K),q&&q(D.map(P=>({id:P,type:"remove"})))),ne.length>0&&(I==null||I(ne),H)){const P=ne.map(B=>({id:B.id,type:"remove"}));H(P)}}},[]),y=w.useCallback(b=>{const _=E4(b),k=_?null:t.getState().nodeInternals.get(b.id);return!_&&!k?[null,null,_]:[_?b:hN(k),k,_]},[]),v=w.useCallback((b,_=!0,k)=>{const[j,E,C]=y(b);return j?(k||t.getState().getNodes()).filter(R=>{if(!C&&(R.id===E.id||!R.positionAbsolute))return!1;const I=hN(R),O=g0(I,j);return _&&O>0||O>=j.width*j.height}):[]},[]),S=w.useCallback((b,_,k=!0)=>{const[j]=y(b);if(!j)return!1;const E=g0(j,_);return k&&E>0||E>=j.width*j.height},[]);return w.useMemo(()=>({...e,getNodes:n,getNode:r,getEdges:s,getEdge:l,setNodes:c,setEdges:u,addNodes:f,addEdges:p,toObject:h,deleteElements:m,getIntersectingNodes:v,isNodeIntersecting:S}),[e,n,r,s,l,c,u,f,p,h,m,v,S])}const lD={actInsideInputWithModifier:!1};var cD=({deleteKeyCode:e,multiSelectionKeyCode:t})=>{const n=tn(),{deleteElements:r}=xf(),s=ju(e,lD),l=ju(t);w.useEffect(()=>{if(s){const{edges:c,getNodes:u}=n.getState(),f=u().filter(h=>h.selected),p=c.filter(h=>h.selected);r({nodes:f,edges:p}),n.setState({nodesSelectionActive:!1})}},[s]),w.useEffect(()=>{n.setState({multiSelectionActive:l})},[l])};function uD(e){const t=tn();w.useEffect(()=>{let n;const r=()=>{var l,c;if(!e.current)return;const s=ub(e.current);(s.height===0||s.width===0)&&((c=(l=t.getState()).onError)==null||c.call(l,"004",ua.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 vb={position:"absolute",width:"100%",height:"100%",top:0,left:0},dD=(e,t)=>e.x!==t.x||e.y!==t.y||e.zoom!==t.k,dh=e=>({x:e.x,y:e.y,zoom:e.k}),yl=(e,t)=>e.target.closest(`.${t}`),kN=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),NN=e=>{const t=e.ctrlKey&&Kh()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t},hD=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),fD=({onMove:e,onMoveStart:t,onMoveEnd:n,onPaneContextMenu:r,zoomOnScroll:s=!0,zoomOnPinch:l=!0,panOnScroll:c=!1,panOnScrollSpeed:u=.5,panOnScrollMode:f=ni.Free,zoomOnDoubleClick:p=!0,elementsSelectable:h,panOnDrag:m=!0,defaultViewport:y,translateExtent:v,minZoom:S,maxZoom:b,zoomActivationKeyCode:_,preventScrolling:k=!0,children:j,noWheelClassName:E,noPanClassName:C})=>{const R=w.useRef(),I=tn(),O=w.useRef(!1),H=w.useRef(!1),q=w.useRef(null),$=w.useRef({x:0,y:0,zoom:0}),{d3Zoom:V,d3Selection:ne,d3ZoomHandler:ee,userSelectionActive:M}=Tt(hD,fn),Z=ju(_),K=w.useRef(0),D=w.useRef(!1),P=w.useRef();return uD(q),w.useEffect(()=>{if(q.current){const B=q.current.getBoundingClientRect(),W=QR().scaleExtent([S,b]).translateExtent(v),F=Pr(q.current).call(W),G=la.translate(y.x,y.y).scale(Bl(y.zoom,S,b)),re=[[0,0],[B.width,B.height]],U=W.constrain()(G,re,v);W.transform(F,U),W.wheelDelta(NN),I.setState({d3Zoom:W,d3Selection:F,d3ZoomHandler:F.on("wheel.zoom"),transform:[U.x,U.y,U.k],domNode:q.current.closest(".react-flow")})}},[]),w.useEffect(()=>{ne&&V&&(c&&!Z&&!M?ne.on("wheel.zoom",B=>{if(yl(B,E))return!1;B.preventDefault(),B.stopImmediatePropagation();const W=ne.property("__zoom").k||1;if(B.ctrlKey&&l){const le=hs(B),ge=NN(B),Ne=W*Math.pow(2,ge);V.scaleTo(ne,Ne,le,B);return}const F=B.deltaMode===1?20:1;let G=f===ni.Vertical?0:B.deltaX*F,re=f===ni.Horizontal?0:B.deltaY*F;!Kh()&&B.shiftKey&&f!==ni.Vertical&&(G=B.deltaY*F,re=0),V.translateBy(ne,-(G/W)*u,-(re/W)*u,{internal:!0});const U=dh(ne.property("__zoom")),{onViewportChangeStart:Y,onViewportChange:z,onViewportChangeEnd:ie}=I.getState();clearTimeout(P.current),D.current||(D.current=!0,t==null||t(B,U),Y==null||Y(U)),D.current&&(e==null||e(B,U),z==null||z(U),P.current=setTimeout(()=>{n==null||n(B,U),ie==null||ie(U),D.current=!1},150))},{passive:!1}):typeof ee<"u"&&ne.on("wheel.zoom",function(B,W){if(!k&&B.type==="wheel"&&!B.ctrlKey||yl(B,E))return null;B.preventDefault(),ee.call(this,B,W)},{passive:!1}))},[M,c,f,ne,V,ee,Z,l,k,E,t,e,n]),w.useEffect(()=>{V&&V.on("start",B=>{var G,re;if(!B.sourceEvent||B.sourceEvent.internal)return null;K.current=(G=B.sourceEvent)==null?void 0:G.button;const{onViewportChangeStart:W}=I.getState(),F=dh(B.transform);O.current=!0,$.current=F,((re=B.sourceEvent)==null?void 0:re.type)==="mousedown"&&I.setState({paneDragging:!0}),W==null||W(F),t==null||t(B.sourceEvent,F)})},[V,t]),w.useEffect(()=>{V&&(M&&!O.current?V.on("zoom",null):M||V.on("zoom",B=>{var F;const{onViewportChange:W}=I.getState();if(I.setState({transform:[B.transform.x,B.transform.y,B.transform.k]}),H.current=!!(r&&kN(m,K.current??0)),(e||W)&&!((F=B.sourceEvent)!=null&&F.internal)){const G=dh(B.transform);W==null||W(G),e==null||e(B.sourceEvent,G)}}))},[M,V,e,m,r]),w.useEffect(()=>{V&&V.on("end",B=>{if(!B.sourceEvent||B.sourceEvent.internal)return null;const{onViewportChangeEnd:W}=I.getState();if(O.current=!1,I.setState({paneDragging:!1}),r&&kN(m,K.current??0)&&!H.current&&r(B.sourceEvent),H.current=!1,(n||W)&&dD($.current,B.transform)){const F=dh(B.transform);$.current=F,clearTimeout(R.current),R.current=setTimeout(()=>{W==null||W(F),n==null||n(B.sourceEvent,F)},c?150:0)}})},[V,c,m,n,r]),w.useEffect(()=>{V&&V.filter(B=>{const W=Z||s,F=l&&B.ctrlKey;if((m===!0||Array.isArray(m)&&m.includes(1))&&B.button===1&&B.type==="mousedown"&&(yl(B,"react-flow__node")||yl(B,"react-flow__edge")))return!0;if(!m&&!W&&!c&&!p&&!l||M||!p&&B.type==="dblclick"||yl(B,E)&&B.type==="wheel"||yl(B,C)&&(B.type!=="wheel"||c&&B.type==="wheel"&&!Z)||!l&&B.ctrlKey&&B.type==="wheel"||!W&&!c&&!F&&B.type==="wheel"||!m&&(B.type==="mousedown"||B.type==="touchstart")||Array.isArray(m)&&!m.includes(B.button)&&B.type==="mousedown")return!1;const G=Array.isArray(m)&&m.includes(B.button)||!B.button||B.button<=1;return(!B.ctrlKey||B.type==="wheel")&&G})},[M,V,s,l,c,p,m,h,Z]),ve.createElement("div",{className:"react-flow__renderer",ref:q,style:vb},j)},pD=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function mD(){const{userSelectionActive:e,userSelectionRect:t}=Tt(pD,fn);return e&&t?ve.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 SN(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,l=t.position.y+t.height-r.height;if(s>0||l>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),l>0&&(r.style.height+=l),t.position.x<0){const c=Math.abs(t.position.x);r.position.x=r.position.x-c,r.style.width+=c,t.position.x=0}if(t.position.y<0){const c=Math.abs(t.position.y);r.position.y=r.position.y-c,r.style.height+=c,t.position.y=0}r.width=r.style.width,r.height=r.style.height}}}function gD(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 l=e.filter(u=>u.id===s.id);if(l.length===0)return r.push(s),r;const c={...s};for(const u of l)if(u)switch(u.type){case"select":{c.selected=u.selected;break}case"position":{typeof u.position<"u"&&(c.position=u.position),typeof u.positionAbsolute<"u"&&(c.positionAbsolute=u.positionAbsolute),typeof u.dragging<"u"&&(c.dragging=u.dragging),c.expandParent&&SN(r,c);break}case"dimensions":{typeof u.dimensions<"u"&&(c.width=u.dimensions.width,c.height=u.dimensions.height),typeof u.updateStyle<"u"&&(c.style={...c.style||{},...u.dimensions}),typeof u.resizing=="boolean"&&(c.resizing=u.resizing),c.expandParent&&SN(r,c);break}case"remove":return r}return r.push(c),r},n)}function yD(e,t){return gD(e,t)}const Xa=(e,t)=>({id:e,type:"select",selected:t});function Tl(e,t){return e.reduce((n,r)=>{const s=t.includes(r.id);return!r.selected&&s?(r.selected=!0,n.push(Xa(r.id,!0))):r.selected&&!s&&(r.selected=!1,n.push(Xa(r.id,!1))),n},[])}const pm=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},wD=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),CA=w.memo(({isSelecting:e,selectionMode:t=Su.Full,panOnDrag:n,onSelectionStart:r,onSelectionEnd:s,onPaneClick:l,onPaneContextMenu:c,onPaneScroll:u,onPaneMouseEnter:f,onPaneMouseMove:p,onPaneMouseLeave:h,children:m})=>{const y=w.useRef(null),v=tn(),S=w.useRef(0),b=w.useRef(0),_=w.useRef(),{userSelectionActive:k,elementsSelectable:j,dragging:E}=Tt(wD,fn),C=()=>{v.setState({userSelectionActive:!1,userSelectionRect:null}),S.current=0,b.current=0},R=ee=>{l==null||l(ee),v.getState().resetSelectedElements(),v.setState({nodesSelectionActive:!1})},I=ee=>{if(Array.isArray(n)&&(n!=null&&n.includes(2))){ee.preventDefault();return}c==null||c(ee)},O=u?ee=>u(ee):void 0,H=ee=>{const{resetSelectedElements:M,domNode:Z}=v.getState();if(_.current=Z==null?void 0:Z.getBoundingClientRect(),!j||!e||ee.button!==0||ee.target!==y.current||!_.current)return;const{x:K,y:D}=to(ee,_.current);M(),v.setState({userSelectionRect:{width:0,height:0,startX:K,startY:D,x:K,y:D}}),r==null||r(ee)},q=ee=>{const{userSelectionRect:M,nodeInternals:Z,edges:K,transform:D,onNodesChange:P,onEdgesChange:B,nodeOrigin:W,getNodes:F}=v.getState();if(!e||!_.current||!M)return;v.setState({userSelectionActive:!0,nodesSelectionActive:!1});const G=to(ee,_.current),re=M.startX??0,U=M.startY??0,Y={...M,x:G.x<re?G.x:re,y:G.y<U?G.y:U,width:Math.abs(G.x-re),height:Math.abs(G.y-U)},z=F(),ie=uA(Z,Y,D,t===Su.Partial,!0,W),le=dA(ie,K).map(Ne=>Ne.id),ge=ie.map(Ne=>Ne.id);if(S.current!==ge.length){S.current=ge.length;const Ne=Tl(z,ge);Ne.length&&(P==null||P(Ne))}if(b.current!==le.length){b.current=le.length;const Ne=Tl(K,le);Ne.length&&(B==null||B(Ne))}v.setState({userSelectionRect:Y})},$=ee=>{if(ee.button!==0)return;const{userSelectionRect:M}=v.getState();!k&&M&&ee.target===y.current&&(R==null||R(ee)),v.setState({nodesSelectionActive:S.current>0}),C(),s==null||s(ee)},V=ee=>{k&&(v.setState({nodesSelectionActive:S.current>0}),s==null||s(ee)),C()},ne=j&&(e||k);return ve.createElement("div",{className:jn(["react-flow__pane",{dragging:E,selection:e}]),onClick:ne?void 0:pm(R,y),onContextMenu:pm(I,y),onWheel:pm(O,y),onMouseEnter:ne?void 0:f,onMouseDown:ne?H:void 0,onMouseMove:ne?q:p,onMouseUp:ne?$:void 0,onMouseLeave:ne?V:h,ref:y,style:vb},m,ve.createElement(mD,null))});CA.displayName="Pane";function TA(e,t){const n=e.parentNode||e.parentId;if(!n)return!1;const r=t.get(n);return r?r.selected?!0:TA(r,t):!1}function jN(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 vD(e,t,n,r){return Array.from(e.values()).filter(s=>(s.selected||s.id===r)&&(!s.parentNode||s.parentId||!TA(s,e))&&(s.draggable||t&&typeof s.draggable>"u")).map(s=>{var l,c;return{id:s.id,position:s.position||{x:0,y:0},positionAbsolute:s.positionAbsolute||{x:0,y:0},distance:{x:n.x-(((l=s.positionAbsolute)==null?void 0:l.x)??0),y:n.y-(((c=s.positionAbsolute)==null?void 0:c.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 xD(e,t){return!t||t==="parent"?t:[t[0],[t[1][0]-(e.width||0),t[1][1]-(e.height||0)]]}function RA(e,t,n,r,s=[0,0],l){const c=xD(e,e.extent||r);let u=c;const f=e.parentNode||e.parentId;if(e.extent==="parent"&&!e.expandParent)if(f&&e.width&&e.height){const m=n.get(f),{x:y,y:v}=ai(m,s).positionAbsolute;u=m&&Dr(y)&&Dr(v)&&Dr(m.width)&&Dr(m.height)?[[y+e.width*s[0],v+e.height*s[1]],[y+m.width-e.width+e.width*s[0],v+m.height-e.height+e.height*s[1]]]:u}else l==null||l("005",ua.error005()),u=c;else if(e.extent&&f&&e.extent!=="parent"){const m=n.get(f),{x:y,y:v}=ai(m,s).positionAbsolute;u=[[e.extent[0][0]+y,e.extent[0][1]+v],[e.extent[1][0]+y,e.extent[1][1]+v]]}let p={x:0,y:0};if(f){const m=n.get(f);p=ai(m,s).positionAbsolute}const h=u&&u!=="parent"?db(t,u):t;return{position:{x:h.x-p.x,y:h.y-p.y},positionAbsolute:h}}function mm({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 _N=(e,t,n,r)=>{const s=t.querySelectorAll(e);if(!s||!s.length)return null;const l=Array.from(s),c=t.getBoundingClientRect(),u={x:c.width*r[0],y:c.height*r[1]};return l.map(f=>{const p=f.getBoundingClientRect();return{id:f.getAttribute("data-handleid"),position:f.getAttribute("data-handlepos"),x:(p.left-c.left-u.x)/n,y:(p.top-c.top-u.y)/n,...ub(f)}})};function eu(e,t,n){return n===void 0?n:r=>{const s=t().nodeInternals.get(e);s&&n(r,{...s})}}function k0({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:s,unselectNodesAndEdges:l,multiSelectionActive:c,nodeInternals:u,onError:f}=t.getState(),p=u.get(e);if(!p){f==null||f("012",ua.error012(e));return}t.setState({nodesSelectionActive:!1}),p.selected?(n||p.selected&&c)&&(l({nodes:[p],edges:[]}),requestAnimationFrame(()=>{var h;return(h=r==null?void 0:r.current)==null?void 0:h.blur()})):s([e])}function bD(){const e=tn();return w.useCallback(({sourceEvent:n})=>{const{transform:r,snapGrid:s,snapToGrid:l}=e.getState(),c=n.touches?n.touches[0].clientX:n.clientX,u=n.touches?n.touches[0].clientY:n.clientY,f={x:(c-r[0])/r[2],y:(u-r[1])/r[2]};return{xSnapped:l?s[0]*Math.round(f.x/s[0]):f.x,ySnapped:l?s[1]*Math.round(f.y/s[1]):f.y,...f}},[])}function gm(e){return(t,n,r)=>e==null?void 0:e(t,r)}function AA({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:s,isSelectable:l,selectNodesOnDrag:c}){const u=tn(),[f,p]=w.useState(!1),h=w.useRef([]),m=w.useRef({x:null,y:null}),y=w.useRef(0),v=w.useRef(null),S=w.useRef({x:0,y:0}),b=w.useRef(null),_=w.useRef(!1),k=w.useRef(!1),j=w.useRef(!1),E=bD();return w.useEffect(()=>{if(e!=null&&e.current){const C=Pr(e.current),R=({x:H,y:q})=>{const{nodeInternals:$,onNodeDrag:V,onSelectionDrag:ne,updateNodePositions:ee,nodeExtent:M,snapGrid:Z,snapToGrid:K,nodeOrigin:D,onError:P}=u.getState();m.current={x:H,y:q};let B=!1,W={x:0,y:0,x2:0,y2:0};if(h.current.length>1&&M){const G=vf(h.current,D);W=Nu(G)}if(h.current=h.current.map(G=>{const re={x:H-G.distance.x,y:q-G.distance.y};K&&(re.x=Z[0]*Math.round(re.x/Z[0]),re.y=Z[1]*Math.round(re.y/Z[1]));const U=[[M[0][0],M[0][1]],[M[1][0],M[1][1]]];h.current.length>1&&M&&!G.extent&&(U[0][0]=G.positionAbsolute.x-W.x+M[0][0],U[1][0]=G.positionAbsolute.x+(G.width??0)-W.x2+M[1][0],U[0][1]=G.positionAbsolute.y-W.y+M[0][1],U[1][1]=G.positionAbsolute.y+(G.height??0)-W.y2+M[1][1]);const Y=RA(G,re,$,U,D,P);return B=B||G.position.x!==Y.position.x||G.position.y!==Y.position.y,G.position=Y.position,G.positionAbsolute=Y.positionAbsolute,G}),!B)return;ee(h.current,!0,!0),p(!0);const F=s?V:gm(ne);if(F&&b.current){const[G,re]=mm({nodeId:s,dragItems:h.current,nodeInternals:$});F(b.current,G,re)}},I=()=>{if(!v.current)return;const[H,q]=eA(S.current,v.current);if(H!==0||q!==0){const{transform:$,panBy:V}=u.getState();m.current.x=(m.current.x??0)-H/$[2],m.current.y=(m.current.y??0)-q/$[2],V({x:H,y:q})&&R(m.current)}y.current=requestAnimationFrame(I)},O=H=>{var D;const{nodeInternals:q,multiSelectionActive:$,nodesDraggable:V,unselectNodesAndEdges:ne,onNodeDragStart:ee,onSelectionDragStart:M}=u.getState();k.current=!0;const Z=s?ee:gm(M);(!c||!l)&&!$&&s&&((D=q.get(s))!=null&&D.selected||ne()),s&&l&&c&&k0({id:s,store:u,nodeRef:e});const K=E(H);if(m.current=K,h.current=vD(q,V,K,s),Z&&h.current){const[P,B]=mm({nodeId:s,dragItems:h.current,nodeInternals:q});Z(H.sourceEvent,P,B)}};if(t)C.on(".drag",null);else{const H=A3().on("start",q=>{const{domNode:$,nodeDragThreshold:V}=u.getState();V===0&&O(q),j.current=!1;const ne=E(q);m.current=ne,v.current=($==null?void 0:$.getBoundingClientRect())||null,S.current=to(q.sourceEvent,v.current)}).on("drag",q=>{var ee,M;const $=E(q),{autoPanOnNodeDrag:V,nodeDragThreshold:ne}=u.getState();if(q.sourceEvent.type==="touchmove"&&q.sourceEvent.touches.length>1&&(j.current=!0),!j.current){if(!_.current&&k.current&&V&&(_.current=!0,I()),!k.current){const Z=$.xSnapped-(((ee=m==null?void 0:m.current)==null?void 0:ee.x)??0),K=$.ySnapped-(((M=m==null?void 0:m.current)==null?void 0:M.y)??0);Math.sqrt(Z*Z+K*K)>ne&&O(q)}(m.current.x!==$.xSnapped||m.current.y!==$.ySnapped)&&h.current&&k.current&&(b.current=q.sourceEvent,S.current=to(q.sourceEvent,v.current),R($))}}).on("end",q=>{if(!(!k.current||j.current)&&(p(!1),_.current=!1,k.current=!1,cancelAnimationFrame(y.current),h.current)){const{updateNodePositions:$,nodeInternals:V,onNodeDragStop:ne,onSelectionDragStop:ee}=u.getState(),M=s?ne:gm(ee);if($(h.current,!1,!1),M){const[Z,K]=mm({nodeId:s,dragItems:h.current,nodeInternals:V});M(q.sourceEvent,Z,K)}}}).filter(q=>{const $=q.target;return!q.button&&(!n||!jN($,`.${n}`,e))&&(!r||jN($,r,e))});return C.call(H),()=>{C.on(".drag",null)}}}},[e,t,n,r,l,u,s,c,E]),f}function MA(){const e=tn();return w.useCallback(n=>{const{nodeInternals:r,nodeExtent:s,updateNodePositions:l,getNodes:c,snapToGrid:u,snapGrid:f,onError:p,nodesDraggable:h}=e.getState(),m=c().filter(j=>j.selected&&(j.draggable||h&&typeof j.draggable>"u")),y=u?f[0]:5,v=u?f[1]:5,S=n.isShiftPressed?4:1,b=n.x*y*S,_=n.y*v*S,k=m.map(j=>{if(j.positionAbsolute){const E={x:j.positionAbsolute.x+b,y:j.positionAbsolute.y+_};u&&(E.x=f[0]*Math.round(E.x/f[0]),E.y=f[1]*Math.round(E.y/f[1]));const{positionAbsolute:C,position:R}=RA(j,E,r,s,void 0,p);j.position=R,j.positionAbsolute=C}return j});l(k,!0,!1)},[])}const Ll={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var tu=e=>{const t=({id:n,type:r,data:s,xPos:l,yPos:c,xPosOrigin:u,yPosOrigin:f,selected:p,onClick:h,onMouseEnter:m,onMouseMove:y,onMouseLeave:v,onContextMenu:S,onDoubleClick:b,style:_,className:k,isDraggable:j,isSelectable:E,isConnectable:C,isFocusable:R,selectNodesOnDrag:I,sourcePosition:O,targetPosition:H,hidden:q,resizeObserver:$,dragHandle:V,zIndex:ne,isParent:ee,noDragClassName:M,noPanClassName:Z,initialized:K,disableKeyboardA11y:D,ariaLabel:P,rfId:B,hasHandleBounds:W})=>{const F=tn(),G=w.useRef(null),re=w.useRef(null),U=w.useRef(O),Y=w.useRef(H),z=w.useRef(r),ie=E||j||h||m||y||v,le=MA(),ge=eu(n,F.getState,m),Ne=eu(n,F.getState,y),Ie=eu(n,F.getState,v),Ge=eu(n,F.getState,S),Pe=eu(n,F.getState,b),Be=de=>{const{nodeDragThreshold:ue}=F.getState();if(E&&(!I||!j||ue>0)&&k0({id:n,store:F,nodeRef:G}),h){const se=F.getState().nodeInternals.get(n);se&&h(de,{...se})}},Te=de=>{if(!y0(de)&&!D)if(sA.includes(de.key)&&E){const ue=de.key==="Escape";k0({id:n,store:F,unselect:ue,nodeRef:G})}else j&&p&&Object.prototype.hasOwnProperty.call(Ll,de.key)&&(F.setState({ariaLiveMessage:`Moved selected node ${de.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~l}, y: ${~~c}`}),le({x:Ll[de.key].x,y:Ll[de.key].y,isShiftPressed:de.shiftKey}))};w.useEffect(()=>()=>{re.current&&($==null||$.unobserve(re.current),re.current=null)},[]),w.useEffect(()=>{if(G.current&&!q){const de=G.current;(!K||!W||re.current!==de)&&(re.current&&($==null||$.unobserve(re.current)),$==null||$.observe(de),re.current=de)}},[q,K,W]),w.useEffect(()=>{const de=z.current!==r,ue=U.current!==O,se=Y.current!==H;G.current&&(de||ue||se)&&(de&&(z.current=r),ue&&(U.current=O),se&&(Y.current=H),F.getState().updateNodeDimensions([{id:n,nodeElement:G.current,forceUpdate:!0}]))},[n,r,O,H]);const st=AA({nodeRef:G,disabled:q||!j,noDragClassName:M,handleSelector:V,nodeId:n,isSelectable:E,selectNodesOnDrag:I});return q?null:ve.createElement("div",{className:jn(["react-flow__node",`react-flow__node-${r}`,{[Z]:j},k,{selected:p,selectable:E,parent:ee,dragging:st}]),ref:G,style:{zIndex:ne,transform:`translate(${u}px,${f}px)`,pointerEvents:ie?"all":"none",visibility:K?"visible":"hidden",..._},"data-id":n,"data-testid":`rf__node-${n}`,onMouseEnter:ge,onMouseMove:Ne,onMouseLeave:Ie,onContextMenu:Ge,onClick:Be,onDoubleClick:Pe,onKeyDown:R?Te:void 0,tabIndex:R?0:void 0,role:R?"button":void 0,"aria-describedby":D?void 0:`${NA}-${B}`,"aria-label":P},ve.createElement($4,{value:n},ve.createElement(e,{id:n,data:s,type:r,xPos:l,yPos:c,selected:p,isConnectable:C,sourcePosition:O,targetPosition:H,dragging:st,dragHandle:V,zIndex:ne})))};return t.displayName="NodeWrapper",w.memo(t)};const kD=e=>{const t=e.getNodes().filter(n=>n.selected);return{...vf(t,e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive}};function ND({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=tn(),{width:s,height:l,x:c,y:u,transformString:f,userSelectionActive:p}=Tt(kD,fn),h=MA(),m=w.useRef(null);if(w.useEffect(()=>{var S;n||(S=m.current)==null||S.focus({preventScroll:!0})},[n]),AA({nodeRef:m}),p||!s||!l)return null;const y=e?S=>{const b=r.getState().getNodes().filter(_=>_.selected);e(S,b)}:void 0,v=S=>{Object.prototype.hasOwnProperty.call(Ll,S.key)&&h({x:Ll[S.key].x,y:Ll[S.key].y,isShiftPressed:S.shiftKey})};return ve.createElement("div",{className:jn(["react-flow__nodesselection","react-flow__container",t]),style:{transform:f}},ve.createElement("div",{ref:m,className:"react-flow__nodesselection-rect",onContextMenu:y,tabIndex:n?void 0:-1,onKeyDown:n?void 0:v,style:{width:s,height:l,top:u,left:c}}))}var SD=w.memo(ND);const jD=e=>e.nodesSelectionActive,IA=({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:l,onPaneScroll:c,deleteKeyCode:u,onMove:f,onMoveStart:p,onMoveEnd:h,selectionKeyCode:m,selectionOnDrag:y,selectionMode:v,onSelectionStart:S,onSelectionEnd:b,multiSelectionKeyCode:_,panActivationKeyCode:k,zoomActivationKeyCode:j,elementsSelectable:E,zoomOnScroll:C,zoomOnPinch:R,panOnScroll:I,panOnScrollSpeed:O,panOnScrollMode:H,zoomOnDoubleClick:q,panOnDrag:$,defaultViewport:V,translateExtent:ne,minZoom:ee,maxZoom:M,preventScrolling:Z,onSelectionContextMenu:K,noWheelClassName:D,noPanClassName:P,disableKeyboardA11y:B})=>{const W=Tt(jD),F=ju(m),G=ju(k),re=G||$,U=G||I,Y=F||y&&re!==!0;return cD({deleteKeyCode:u,multiSelectionKeyCode:_}),ve.createElement(fD,{onMove:f,onMoveStart:p,onMoveEnd:h,onPaneContextMenu:l,elementsSelectable:E,zoomOnScroll:C,zoomOnPinch:R,panOnScroll:U,panOnScrollSpeed:O,panOnScrollMode:H,zoomOnDoubleClick:q,panOnDrag:!F&&re,defaultViewport:V,translateExtent:ne,minZoom:ee,maxZoom:M,zoomActivationKeyCode:j,preventScrolling:Z,noWheelClassName:D,noPanClassName:P},ve.createElement(CA,{onSelectionStart:S,onSelectionEnd:b,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:l,onPaneScroll:c,panOnDrag:re,isSelecting:!!Y,selectionMode:v},e,W&&ve.createElement(SD,{onSelectionContextMenu:K,noPanClassName:P,disableKeyboardA11y:B})))};IA.displayName="FlowRenderer";var _D=w.memo(IA);function ED(e){return Tt(w.useCallback(n=>e?uA(n.nodeInternals,{x:0,y:0,width:n.width,height:n.height},n.transform,!0):n.getNodes(),[e]))}function CD(e){const t={input:tu(e.input||vA),default:tu(e.default||b0),output:tu(e.output||bA),group:tu(e.group||wb)},n={},r=Object.keys(e).filter(s=>!["input","default","output","group"].includes(s)).reduce((s,l)=>(s[l]=tu(e[l]||b0),s),n);return{...t,...r}}const TD=({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]},RD=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:l,onError:c}=Tt(RD,fn),u=ED(e.onlyRenderVisibleElements),f=w.useRef(),p=w.useMemo(()=>{if(typeof ResizeObserver>"u")return null;const h=new ResizeObserver(m=>{const y=m.map(v=>({id:v.target.getAttribute("data-id"),nodeElement:v.target,forceUpdate:!0}));l(y)});return f.current=h,h},[]);return w.useEffect(()=>()=>{var h;(h=f==null?void 0:f.current)==null||h.disconnect()},[]),ve.createElement("div",{className:"react-flow__nodes",style:vb},u.map(h=>{var R,I,O;let m=h.type||"default";e.nodeTypes[m]||(c==null||c("003",ua.error003(m)),m="default");const y=e.nodeTypes[m]||e.nodeTypes.default,v=!!(h.draggable||t&&typeof h.draggable>"u"),S=!!(h.selectable||s&&typeof h.selectable>"u"),b=!!(h.connectable||n&&typeof h.connectable>"u"),_=!!(h.focusable||r&&typeof h.focusable>"u"),k=e.nodeExtent?db(h.positionAbsolute,e.nodeExtent):h.positionAbsolute,j=(k==null?void 0:k.x)??0,E=(k==null?void 0:k.y)??0,C=TD({x:j,y:E,width:h.width??0,height:h.height??0,origin:e.nodeOrigin});return ve.createElement(y,{key:h.id,id:h.id,className:h.className,style:h.style,type:m,data:h.data,sourcePosition:h.sourcePosition||nt.Bottom,targetPosition:h.targetPosition||nt.Top,hidden:h.hidden,xPos:j,yPos:E,xPosOrigin:C.x,yPosOrigin:C.y,selectNodesOnDrag:e.selectNodesOnDrag,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,selected:!!h.selected,isDraggable:v,isSelectable:S,isConnectable:b,isFocusable:_,resizeObserver:p,dragHandle:h.dragHandle,zIndex:((R=h[Wt])==null?void 0:R.z)??0,isParent:!!((I=h[Wt])!=null&&I.isParent),noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,initialized:!!h.width&&!!h.height,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,ariaLabel:h.ariaLabel,hasHandleBounds:!!((O=h[Wt])!=null&&O.handleBounds)})}))};$A.displayName="NodeRenderer";var AD=w.memo($A);const MD=(e,t,n)=>n===nt.Left?e-t:n===nt.Right?e+t:e,ID=(e,t,n)=>n===nt.Top?e-t:n===nt.Bottom?e+t:e,EN="react-flow__edgeupdater",CN=({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:s,onMouseEnter:l,onMouseOut:c,type:u})=>ve.createElement("circle",{onMouseDown:s,onMouseEnter:l,onMouseOut:c,className:jn([EN,`${EN}-${u}`]),cx:MD(t,r,e),cy:ID(n,r,e),r,stroke:"transparent",fill:"transparent"}),$D=()=>!0;var wl=e=>{const t=({id:n,className:r,type:s,data:l,onClick:c,onEdgeDoubleClick:u,selected:f,animated:p,label:h,labelStyle:m,labelShowBg:y,labelBgStyle:v,labelBgPadding:S,labelBgBorderRadius:b,style:_,source:k,target:j,sourceX:E,sourceY:C,targetX:R,targetY:I,sourcePosition:O,targetPosition:H,elementsSelectable:q,hidden:$,sourceHandleId:V,targetHandleId:ne,onContextMenu:ee,onMouseEnter:M,onMouseMove:Z,onMouseLeave:K,reconnectRadius:D,onReconnect:P,onReconnectStart:B,onReconnectEnd:W,markerEnd:F,markerStart:G,rfId:re,ariaLabel:U,isFocusable:Y,isReconnectable:z,pathOptions:ie,interactionWidth:le,disableKeyboardA11y:ge})=>{const Ne=w.useRef(null),[Ie,Ge]=w.useState(!1),[Pe,Be]=w.useState(!1),Te=tn(),st=w.useMemo(()=>`url('#${v0(G,re)}')`,[G,re]),de=w.useMemo(()=>`url('#${v0(F,re)}')`,[F,re]);if($)return null;const ue=ze=>{var yt;const{edges:Fe,addSelectedEdges:We,unselectNodesAndEdges:rt,multiSelectionActive:dt}=Te.getState(),ct=Fe.find(Ot=>Ot.id===n);ct&&(q&&(Te.setState({nodesSelectionActive:!1}),ct.selected&&dt?(rt({nodes:[],edges:[ct]}),(yt=Ne.current)==null||yt.blur()):We([n])),c&&c(ze,ct))},se=Jc(n,Te.getState,u),be=Jc(n,Te.getState,ee),Le=Jc(n,Te.getState,M),ce=Jc(n,Te.getState,Z),pe=Jc(n,Te.getState,K),Ae=(ze,Fe)=>{if(ze.button!==0)return;const{edges:We,isValidConnection:rt}=Te.getState(),dt=Fe?j:k,ct=(Fe?ne:V)||null,yt=Fe?"target":"source",Ot=rt||$D,zt=Fe,Xt=We.find(je=>je.id===n);Be(!0),B==null||B(ze,Xt,yt);const Dt=je=>{Be(!1),W==null||W(je,Xt,yt)};mA({event:ze,handleId:ct,nodeId:dt,onConnect:je=>P==null?void 0:P(Xt,je),isTarget:zt,getState:Te.getState,setState:Te.setState,isValidConnection:Ot,edgeUpdaterType:yt,onReconnectEnd:Dt})},fe=ze=>Ae(ze,!0),Se=ze=>Ae(ze,!1),Ye=()=>Ge(!0),qe=()=>Ge(!1),ke=!q&&!c,Re=ze=>{var Fe;if(!ge&&sA.includes(ze.key)&&q){const{unselectNodesAndEdges:We,addSelectedEdges:rt,edges:dt}=Te.getState();ze.key==="Escape"?((Fe=Ne.current)==null||Fe.blur(),We({edges:[dt.find(yt=>yt.id===n)]})):rt([n])}};return ve.createElement("g",{className:jn(["react-flow__edge",`react-flow__edge-${s}`,r,{selected:f,animated:p,inactive:ke,updating:Ie}]),onClick:ue,onDoubleClick:se,onContextMenu:be,onMouseEnter:Le,onMouseMove:ce,onMouseLeave:pe,onKeyDown:Y?Re:void 0,tabIndex:Y?0:void 0,role:Y?"button":"img","data-testid":`rf__edge-${n}`,"aria-label":U===null?void 0:U||`Edge from ${k} to ${j}`,"aria-describedby":Y?`${SA}-${re}`:void 0,ref:Ne},!Pe&&ve.createElement(e,{id:n,source:k,target:j,selected:f,animated:p,label:h,labelStyle:m,labelShowBg:y,labelBgStyle:v,labelBgPadding:S,labelBgBorderRadius:b,data:l,style:_,sourceX:E,sourceY:C,targetX:R,targetY:I,sourcePosition:O,targetPosition:H,sourceHandleId:V,targetHandleId:ne,markerStart:st,markerEnd:de,pathOptions:ie,interactionWidth:le}),z&&ve.createElement(ve.Fragment,null,(z==="source"||z===!0)&&ve.createElement(CN,{position:O,centerX:E,centerY:C,radius:D,onMouseDown:fe,onMouseEnter:Ye,onMouseOut:qe,type:"source"}),(z==="target"||z===!0)&&ve.createElement(CN,{position:H,centerX:R,centerY:I,radius:D,onMouseDown:Se,onMouseEnter:Ye,onMouseOut:qe,type:"target"})))};return t.displayName="EdgeWrapper",w.memo(t)};function OD(e){const t={default:wl(e.default||Xh),straight:wl(e.bezier||pb),step:wl(e.step||fb),smoothstep:wl(e.step||wf),simplebezier:wl(e.simplebezier||hb)},n={},r=Object.keys(e).filter(s=>!["default","bezier"].includes(s)).reduce((s,l)=>(s[l]=wl(e[l]||Xh),s),n);return{...t,...r}}function TN(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,l=(n==null?void 0:n.width)||t.width,c=(n==null?void 0:n.height)||t.height;switch(e){case nt.Top:return{x:r+l/2,y:s};case nt.Right:return{x:r+l,y:s+c/2};case nt.Bottom:return{x:r+l/2,y:s+c};case nt.Left:return{x:r,y:s+c/2}}}function RN(e,t){return e?e.length===1||!t?e[0]:t&&e.find(n=>n.id===t)||null:null}const LD=(e,t,n,r,s,l)=>{const c=TN(n,e,t),u=TN(l,r,s);return{sourceX:c.x,sourceY:c.y,targetX:u.x,targetY:u.y}};function PD({sourcePos:e,targetPos:t,sourceWidth:n,sourceHeight:r,targetWidth:s,targetHeight:l,width:c,height:u,transform:f}){const p={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+l)};p.x===p.x2&&(p.x2+=1),p.y===p.y2&&(p.y2+=1);const h=Nu({x:(0-f[0])/f[2],y:(0-f[1])/f[2],width:c/f[2],height:u/f[2]}),m=Math.max(0,Math.min(h.x2,p.x2)-Math.max(h.x,p.x)),y=Math.max(0,Math.min(h.y2,p.y2)-Math.max(h.y,p.y));return Math.ceil(m*y)>0}function AN(e){var r,s,l,c,u;const t=((r=e==null?void 0:e[Wt])==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((l=e==null?void 0:e.positionAbsolute)==null?void 0:l.y)<"u";return[{x:((c=e==null?void 0:e.positionAbsolute)==null?void 0:c.x)||0,y:((u=e==null?void 0:e.positionAbsolute)==null?void 0:u.y)||0,width:(e==null?void 0:e.width)||0,height:(e==null?void 0:e.height)||0},t,!!n]}const DD=[{level:0,isMaxLevel:!0,edges:[]}];function FD(e,t,n=!1){let r=-1;const s=e.reduce((c,u)=>{var h,m;const f=Dr(u.zIndex);let p=f?u.zIndex:0;if(n){const y=t.get(u.target),v=t.get(u.source),S=u.selected||(y==null?void 0:y.selected)||(v==null?void 0:v.selected),b=Math.max(((h=v==null?void 0:v[Wt])==null?void 0:h.z)||0,((m=y==null?void 0:y[Wt])==null?void 0:m.z)||0,1e3);p=(f?u.zIndex:0)+(S?b:0)}return c[p]?c[p].push(u):c[p]=[u],r=p>r?p:r,c},{}),l=Object.entries(s).map(([c,u])=>{const f=+c;return{edges:u,level:f,isMaxLevel:f===r}});return l.length===0?DD:l}function qD(e,t,n){const r=Tt(w.useCallback(s=>e?s.edges.filter(l=>{const c=t.get(l.source),u=t.get(l.target);return(c==null?void 0:c.width)&&(c==null?void 0:c.height)&&(u==null?void 0:u.width)&&(u==null?void 0:u.height)&&PD({sourcePos:c.positionAbsolute||{x:0,y:0},targetPos:u.positionAbsolute||{x:0,y:0},sourceWidth:c.width,sourceHeight:c.height,targetWidth:u.width,targetHeight:u.height,width:s.width,height:s.height,transform:s.transform})}):s.edges,[e,t]));return FD(r,t,n)}const BD=({color:e="none",strokeWidth:t=1})=>ve.createElement("polyline",{style:{stroke:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),zD=({color:e="none",strokeWidth:t=1})=>ve.createElement("polyline",{style:{stroke:e,fill:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"}),MN={[Yh.Arrow]:BD,[Yh.ArrowClosed]:zD};function UD(e){const t=tn();return w.useMemo(()=>{var s,l;return Object.prototype.hasOwnProperty.call(MN,e)?MN[e]:((l=(s=t.getState()).onError)==null||l.call(s,"009",ua.error009(e)),null)},[e])}const HD=({id:e,type:t,color:n,width:r=12.5,height:s=12.5,markerUnits:l="strokeWidth",strokeWidth:c,orient:u="auto-start-reverse"})=>{const f=UD(t);return f?ve.createElement("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${s}`,viewBox:"-10 -10 20 20",markerUnits:l,orient:u,refX:"0",refY:"0"},ve.createElement(f,{color:n,strokeWidth:c})):null},WD=({defaultColor:e,rfId:t})=>n=>{const r=[];return n.edges.reduce((s,l)=>([l.markerStart,l.markerEnd].forEach(c=>{if(c&&typeof c=="object"){const u=v0(c,t);r.includes(u)||(s.push({id:u,color:c.color||e,...c}),r.push(u))}}),s),[]).sort((s,l)=>s.id.localeCompare(l.id))},OA=({defaultColor:e,rfId:t})=>{const n=Tt(w.useCallback(WD({defaultColor:e,rfId:t}),[e,t]),(r,s)=>!(r.length!==s.length||r.some((l,c)=>l.id!==s[c].id)));return ve.createElement("defs",null,n.map(r=>ve.createElement(HD,{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})))};OA.displayName="MarkerDefinitions";var VD=w.memo(OA);const GD=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}),LA=({defaultMarkerColor:e,onlyRenderVisibleElements:t,elevateEdgesOnSelect:n,rfId:r,edgeTypes:s,noPanClassName:l,onEdgeContextMenu:c,onEdgeMouseEnter:u,onEdgeMouseMove:f,onEdgeMouseLeave:p,onEdgeClick:h,onEdgeDoubleClick:m,onReconnect:y,onReconnectStart:v,onReconnectEnd:S,reconnectRadius:b,children:_,disableKeyboardA11y:k})=>{const{edgesFocusable:j,edgesUpdatable:E,elementsSelectable:C,width:R,height:I,connectionMode:O,nodeInternals:H,onError:q}=Tt(GD,fn),$=qD(t,H,n);return R?ve.createElement(ve.Fragment,null,$.map(({level:V,edges:ne,isMaxLevel:ee})=>ve.createElement("svg",{key:V,style:{zIndex:V},width:R,height:I,className:"react-flow__edges react-flow__container"},ee&&ve.createElement(VD,{defaultColor:e,rfId:r}),ve.createElement("g",null,ne.map(M=>{const[Z,K,D]=AN(H.get(M.source)),[P,B,W]=AN(H.get(M.target));if(!D||!W)return null;let F=M.type||"default";s[F]||(q==null||q("011",ua.error011(F)),F="default");const G=s[F]||s.default,re=O===ui.Strict?B.target:(B.target??[]).concat(B.source??[]),U=RN(K.source,M.sourceHandle),Y=RN(re,M.targetHandle),z=(U==null?void 0:U.position)||nt.Bottom,ie=(Y==null?void 0:Y.position)||nt.Top,le=!!(M.focusable||j&&typeof M.focusable>"u"),ge=M.reconnectable||M.updatable,Ne=typeof y<"u"&&(ge||E&&typeof ge>"u");if(!U||!Y)return q==null||q("008",ua.error008(U,M)),null;const{sourceX:Ie,sourceY:Ge,targetX:Pe,targetY:Be}=LD(Z,U,z,P,Y,ie);return ve.createElement(G,{key:M.id,id:M.id,className:jn([M.className,l]),type:F,data:M.data,selected:!!M.selected,animated:!!M.animated,hidden:!!M.hidden,label:M.label,labelStyle:M.labelStyle,labelShowBg:M.labelShowBg,labelBgStyle:M.labelBgStyle,labelBgPadding:M.labelBgPadding,labelBgBorderRadius:M.labelBgBorderRadius,style:M.style,source:M.source,target:M.target,sourceHandleId:M.sourceHandle,targetHandleId:M.targetHandle,markerEnd:M.markerEnd,markerStart:M.markerStart,sourceX:Ie,sourceY:Ge,targetX:Pe,targetY:Be,sourcePosition:z,targetPosition:ie,elementsSelectable:C,onContextMenu:c,onMouseEnter:u,onMouseMove:f,onMouseLeave:p,onClick:h,onEdgeDoubleClick:m,onReconnect:y,onReconnectStart:v,onReconnectEnd:S,reconnectRadius:b,rfId:r,ariaLabel:M.ariaLabel,isFocusable:le,isReconnectable:Ne,pathOptions:"pathOptions"in M?M.pathOptions:void 0,interactionWidth:M.interactionWidth,disableKeyboardA11y:k})})))),_):null};LA.displayName="EdgeRenderer";var KD=w.memo(LA);const YD=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function XD({children:e}){const t=Tt(YD);return ve.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:t}},e)}function ZD(e){const t=xf(),n=w.useRef(!1);w.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const QD={[nt.Left]:nt.Right,[nt.Right]:nt.Left,[nt.Top]:nt.Bottom,[nt.Bottom]:nt.Top},PA=({nodeId:e,handleType:t,style:n,type:r=Za.Bezier,CustomComponent:s,connectionStatus:l})=>{var I,O,H;const{fromNode:c,handleId:u,toX:f,toY:p,connectionMode:h}=Tt(w.useCallback(q=>({fromNode:q.nodeInternals.get(e),handleId:q.connectionHandleId,toX:(q.connectionPosition.x-q.transform[0])/q.transform[2],toY:(q.connectionPosition.y-q.transform[1])/q.transform[2],connectionMode:q.connectionMode}),[e]),fn),m=(I=c==null?void 0:c[Wt])==null?void 0:I.handleBounds;let y=m==null?void 0:m[t];if(h===ui.Loose&&(y=y||(m==null?void 0:m[t==="source"?"target":"source"])),!c||!y)return null;const v=u?y.find(q=>q.id===u):y[0],S=v?v.x+v.width/2:(c.width??0)/2,b=v?v.y+v.height/2:c.height??0,_=(((O=c.positionAbsolute)==null?void 0:O.x)??0)+S,k=(((H=c.positionAbsolute)==null?void 0:H.y)??0)+b,j=v==null?void 0:v.position,E=j?QD[j]:null;if(!j||!E)return null;if(s)return ve.createElement(s,{connectionLineType:r,connectionLineStyle:n,fromNode:c,fromHandle:v,fromX:_,fromY:k,toX:f,toY:p,fromPosition:j,toPosition:E,connectionStatus:l});let C="";const R={sourceX:_,sourceY:k,sourcePosition:j,targetX:f,targetY:p,targetPosition:E};return r===Za.Bezier?[C]=mb(R):r===Za.Step?[C]=w0({...R,borderRadius:0}):r===Za.SmoothStep?[C]=w0(R):r===Za.SimpleBezier?[C]=lA(R):C=`M${_},${k} ${f},${p}`,ve.createElement("path",{d:C,fill:"none",className:"react-flow__connection-path",style:n})};PA.displayName="ConnectionLine";const JD=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function e5({containerStyle:e,style:t,type:n,component:r}){const{nodeId:s,handleType:l,nodesConnectable:c,width:u,height:f,connectionStatus:p}=Tt(JD,fn);return!(s&&l&&u&&c)?null:ve.createElement("svg",{style:e,width:u,height:f,className:"react-flow__edges react-flow__connectionline react-flow__container"},ve.createElement("g",{className:jn(["react-flow__connection",p])},ve.createElement(PA,{nodeId:s,handleType:l,style:t,type:n,CustomComponent:r,connectionStatus:p})))}function IN(e,t){return w.useRef(null),tn(),w.useMemo(()=>t(e),[e])}const DA=({nodeTypes:e,edgeTypes:t,onMove:n,onMoveStart:r,onMoveEnd:s,onInit:l,onNodeClick:c,onEdgeClick:u,onNodeDoubleClick:f,onEdgeDoubleClick:p,onNodeMouseEnter:h,onNodeMouseMove:m,onNodeMouseLeave:y,onNodeContextMenu:v,onSelectionContextMenu:S,onSelectionStart:b,onSelectionEnd:_,connectionLineType:k,connectionLineStyle:j,connectionLineComponent:E,connectionLineContainerStyle:C,selectionKeyCode:R,selectionOnDrag:I,selectionMode:O,multiSelectionKeyCode:H,panActivationKeyCode:q,zoomActivationKeyCode:$,deleteKeyCode:V,onlyRenderVisibleElements:ne,elementsSelectable:ee,selectNodesOnDrag:M,defaultViewport:Z,translateExtent:K,minZoom:D,maxZoom:P,preventScrolling:B,defaultMarkerColor:W,zoomOnScroll:F,zoomOnPinch:G,panOnScroll:re,panOnScrollSpeed:U,panOnScrollMode:Y,zoomOnDoubleClick:z,panOnDrag:ie,onPaneClick:le,onPaneMouseEnter:ge,onPaneMouseMove:Ne,onPaneMouseLeave:Ie,onPaneScroll:Ge,onPaneContextMenu:Pe,onEdgeContextMenu:Be,onEdgeMouseEnter:Te,onEdgeMouseMove:st,onEdgeMouseLeave:de,onReconnect:ue,onReconnectStart:se,onReconnectEnd:be,reconnectRadius:Le,noDragClassName:ce,noWheelClassName:pe,noPanClassName:Ae,elevateEdgesOnSelect:fe,disableKeyboardA11y:Se,nodeOrigin:Ye,nodeExtent:qe,rfId:ke})=>{const Re=IN(e,CD),ze=IN(t,OD);return ZD(l),ve.createElement(_D,{onPaneClick:le,onPaneMouseEnter:ge,onPaneMouseMove:Ne,onPaneMouseLeave:Ie,onPaneContextMenu:Pe,onPaneScroll:Ge,deleteKeyCode:V,selectionKeyCode:R,selectionOnDrag:I,selectionMode:O,onSelectionStart:b,onSelectionEnd:_,multiSelectionKeyCode:H,panActivationKeyCode:q,zoomActivationKeyCode:$,elementsSelectable:ee,onMove:n,onMoveStart:r,onMoveEnd:s,zoomOnScroll:F,zoomOnPinch:G,zoomOnDoubleClick:z,panOnScroll:re,panOnScrollSpeed:U,panOnScrollMode:Y,panOnDrag:ie,defaultViewport:Z,translateExtent:K,minZoom:D,maxZoom:P,onSelectionContextMenu:S,preventScrolling:B,noDragClassName:ce,noWheelClassName:pe,noPanClassName:Ae,disableKeyboardA11y:Se},ve.createElement(XD,null,ve.createElement(KD,{edgeTypes:ze,onEdgeClick:u,onEdgeDoubleClick:p,onlyRenderVisibleElements:ne,onEdgeContextMenu:Be,onEdgeMouseEnter:Te,onEdgeMouseMove:st,onEdgeMouseLeave:de,onReconnect:ue,onReconnectStart:se,onReconnectEnd:be,reconnectRadius:Le,defaultMarkerColor:W,noPanClassName:Ae,elevateEdgesOnSelect:!!fe,disableKeyboardA11y:Se,rfId:ke},ve.createElement(e5,{style:j,type:k,component:E,containerStyle:C})),ve.createElement("div",{className:"react-flow__edgelabel-renderer"}),ve.createElement(AD,{nodeTypes:Re,onNodeClick:c,onNodeDoubleClick:f,onNodeMouseEnter:h,onNodeMouseMove:m,onNodeMouseLeave:y,onNodeContextMenu:v,selectNodesOnDrag:M,onlyRenderVisibleElements:ne,noPanClassName:Ae,noDragClassName:ce,disableKeyboardA11y:Se,nodeOrigin:Ye,nodeExtent:qe,rfId:ke})))};DA.displayName="GraphView";var t5=w.memo(DA);const N0=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Wa={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:N0,nodeExtent:N0,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:ui.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:C4,isValidConnection:void 0},n5=()=>UO((e,t)=>({...Wa,setNodes:n=>{const{nodeInternals:r,nodeOrigin:s,elevateNodesOnSelect:l}=t();e({nodeInternals:fm(n,r,s,l)})},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",l=typeof r<"u",c=s?fm(n,new Map,t().nodeOrigin,t().elevateNodesOnSelect):new Map;e({nodeInternals:c,edges:l?r:[],hasDefaultNodes:s,hasDefaultEdges:l})},updateNodeDimensions:n=>{const{onNodesChange:r,nodeInternals:s,fitViewOnInit:l,fitViewOnInitDone:c,fitViewOnInitOptions:u,domNode:f,nodeOrigin:p}=t(),h=f==null?void 0:f.querySelector(".react-flow__viewport");if(!h)return;const m=window.getComputedStyle(h),{m22:y}=new window.DOMMatrixReadOnly(m.transform),v=n.reduce((b,_)=>{const k=s.get(_.id);if(k!=null&&k.hidden)s.set(k.id,{...k,[Wt]:{...k[Wt],handleBounds:void 0}});else if(k){const j=ub(_.nodeElement);!!(j.width&&j.height&&(k.width!==j.width||k.height!==j.height||_.forceUpdate))&&(s.set(k.id,{...k,[Wt]:{...k[Wt],handleBounds:{source:_N(".source",_.nodeElement,y,p),target:_N(".target",_.nodeElement,y,p)}},...j}),b.push({id:k.id,type:"dimensions",dimensions:j}))}return b},[]);_A(s,p);const S=c||l&&!c&&EA(t,{initial:!0,...u});e({nodeInternals:new Map(s),fitViewOnInitDone:S}),(v==null?void 0:v.length)>0&&(r==null||r(v))},updateNodePositions:(n,r=!0,s=!1)=>{const{triggerNodeChanges:l}=t(),c=n.map(u=>{const f={id:u.id,type:"position",dragging:s};return r&&(f.positionAbsolute=u.positionAbsolute,f.position=u.position),f});l(c)},triggerNodeChanges:n=>{const{onNodesChange:r,nodeInternals:s,hasDefaultNodes:l,nodeOrigin:c,getNodes:u,elevateNodesOnSelect:f}=t();if(n!=null&&n.length){if(l){const p=yD(n,u()),h=fm(p,s,c,f);e({nodeInternals:h})}r==null||r(n)}},addSelectedNodes:n=>{const{multiSelectionActive:r,edges:s,getNodes:l}=t();let c,u=null;r?c=n.map(f=>Xa(f,!0)):(c=Tl(l(),n),u=Tl(s,[])),uh({changedNodes:c,changedEdges:u,get:t,set:e})},addSelectedEdges:n=>{const{multiSelectionActive:r,edges:s,getNodes:l}=t();let c,u=null;r?c=n.map(f=>Xa(f,!0)):(c=Tl(s,n),u=Tl(l(),[])),uh({changedNodes:u,changedEdges:c,get:t,set:e})},unselectNodesAndEdges:({nodes:n,edges:r}={})=>{const{edges:s,getNodes:l}=t(),c=n||l(),u=r||s,f=c.map(h=>(h.selected=!1,Xa(h.id,!1))),p=u.map(h=>Xa(h.id,!1));uh({changedNodes:f,changedEdges:p,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(),l=r().filter(u=>u.selected).map(u=>Xa(u.id,!1)),c=n.filter(u=>u.selected).map(u=>Xa(u.id,!1));uh({changedNodes:l,changedEdges:c,get:t,set:e})},setNodeExtent:n=>{const{nodeInternals:r}=t();r.forEach(s=>{s.positionAbsolute=db(s.position,n)}),e({nodeExtent:n,nodeInternals:new Map(r)})},panBy:n=>{const{transform:r,width:s,height:l,d3Zoom:c,d3Selection:u,translateExtent:f}=t();if(!c||!u||!n.x&&!n.y)return!1;const p=la.translate(r[0]+n.x,r[1]+n.y).scale(r[2]),h=[[0,0],[s,l]],m=c==null?void 0:c.constrain()(p,h,f);return c.transform(u,m),r[0]!==m.x||r[1]!==m.y||r[2]!==m.k},cancelConnection:()=>e({connectionNodeId:Wa.connectionNodeId,connectionHandleId:Wa.connectionHandleId,connectionHandleType:Wa.connectionHandleType,connectionStatus:Wa.connectionStatus,connectionStartHandle:Wa.connectionStartHandle,connectionEndHandle:Wa.connectionEndHandle}),reset:()=>e({...Wa})}),Object.is),xb=({children:e})=>{const t=w.useRef(null);return t.current||(t.current=n5()),ve.createElement(b4,{value:t.current},e)};xb.displayName="ReactFlowProvider";const FA=({children:e})=>w.useContext(yf)?ve.createElement(ve.Fragment,null,e):ve.createElement(xb,null,e);FA.displayName="ReactFlowWrapper";const r5={input:vA,default:b0,output:bA,group:wb},s5={default:Xh,straight:pb,step:fb,smoothstep:wf,simplebezier:hb},a5=[0,0],o5=[15,15],i5={x:0,y:0,zoom:1},l5={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},qA=w.forwardRef(({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:s,nodeTypes:l=r5,edgeTypes:c=s5,onNodeClick:u,onEdgeClick:f,onInit:p,onMove:h,onMoveStart:m,onMoveEnd:y,onConnect:v,onConnectStart:S,onConnectEnd:b,onClickConnectStart:_,onClickConnectEnd:k,onNodeMouseEnter:j,onNodeMouseMove:E,onNodeMouseLeave:C,onNodeContextMenu:R,onNodeDoubleClick:I,onNodeDragStart:O,onNodeDrag:H,onNodeDragStop:q,onNodesDelete:$,onEdgesDelete:V,onSelectionChange:ne,onSelectionDragStart:ee,onSelectionDrag:M,onSelectionDragStop:Z,onSelectionContextMenu:K,onSelectionStart:D,onSelectionEnd:P,connectionMode:B=ui.Strict,connectionLineType:W=Za.Bezier,connectionLineStyle:F,connectionLineComponent:G,connectionLineContainerStyle:re,deleteKeyCode:U="Backspace",selectionKeyCode:Y="Shift",selectionOnDrag:z=!1,selectionMode:ie=Su.Full,panActivationKeyCode:le="Space",multiSelectionKeyCode:ge=Kh()?"Meta":"Control",zoomActivationKeyCode:Ne=Kh()?"Meta":"Control",snapToGrid:Ie=!1,snapGrid:Ge=o5,onlyRenderVisibleElements:Pe=!1,selectNodesOnDrag:Be=!0,nodesDraggable:Te,nodesConnectable:st,nodesFocusable:de,nodeOrigin:ue=a5,edgesFocusable:se,edgesUpdatable:be,elementsSelectable:Le,defaultViewport:ce=i5,minZoom:pe=.5,maxZoom:Ae=2,translateExtent:fe=N0,preventScrolling:Se=!0,nodeExtent:Ye,defaultMarkerColor:qe="#b1b1b7",zoomOnScroll:ke=!0,zoomOnPinch:Re=!0,panOnScroll:ze=!1,panOnScrollSpeed:Fe=.5,panOnScrollMode:We=ni.Free,zoomOnDoubleClick:rt=!0,panOnDrag:dt=!0,onPaneClick:ct,onPaneMouseEnter:yt,onPaneMouseMove:Ot,onPaneMouseLeave:zt,onPaneScroll:Xt,onPaneContextMenu:Dt,children:rn,onEdgeContextMenu:je,onEdgeDoubleClick:xt,onEdgeMouseEnter:bt,onEdgeMouseMove:_n,onEdgeMouseLeave:Ut,onEdgeUpdate:Vn,onEdgeUpdateStart:Vt,onEdgeUpdateEnd:Lt,onReconnect:Zt,onReconnectStart:In,onReconnectEnd:Hr,reconnectRadius:xe=10,edgeUpdaterRadius:lr=10,onNodesChange:ks,onEdgesChange:Wr,noDragClassName:fa="nodrag",noWheelClassName:Ns="nowheel",noPanClassName:xr="nopan",fitView:$n=!1,fitViewOptions:Hs,connectOnClick:Q=!0,attributionPosition:De,proOptions:et,defaultEdgeOptions:Ue,elevateNodesOnSelect:tt=!0,elevateEdgesOnSelect:wt=!1,disableKeyboardA11y:gt=!1,autoPanOnConnect:It=!0,autoPanOnNodeDrag:Rt=!0,connectionRadius:Qt=20,isValidConnection:Nt,onError:br,style:cr,id:ki,nodeDragThreshold:ht,...ur},sn)=>{const Vr=ki||"1";return ve.createElement("div",{...ur,style:{...cr,...l5},ref:sn,className:jn(["react-flow",s]),"data-testid":"rf__wrapper",id:ki},ve.createElement(FA,null,ve.createElement(t5,{onInit:p,onMove:h,onMoveStart:m,onMoveEnd:y,onNodeClick:u,onEdgeClick:f,onNodeMouseEnter:j,onNodeMouseMove:E,onNodeMouseLeave:C,onNodeContextMenu:R,onNodeDoubleClick:I,nodeTypes:l,edgeTypes:c,connectionLineType:W,connectionLineStyle:F,connectionLineComponent:G,connectionLineContainerStyle:re,selectionKeyCode:Y,selectionOnDrag:z,selectionMode:ie,deleteKeyCode:U,multiSelectionKeyCode:ge,panActivationKeyCode:le,zoomActivationKeyCode:Ne,onlyRenderVisibleElements:Pe,selectNodesOnDrag:Be,defaultViewport:ce,translateExtent:fe,minZoom:pe,maxZoom:Ae,preventScrolling:Se,zoomOnScroll:ke,zoomOnPinch:Re,zoomOnDoubleClick:rt,panOnScroll:ze,panOnScrollSpeed:Fe,panOnScrollMode:We,panOnDrag:dt,onPaneClick:ct,onPaneMouseEnter:yt,onPaneMouseMove:Ot,onPaneMouseLeave:zt,onPaneScroll:Xt,onPaneContextMenu:Dt,onSelectionContextMenu:K,onSelectionStart:D,onSelectionEnd:P,onEdgeContextMenu:je,onEdgeDoubleClick:xt,onEdgeMouseEnter:bt,onEdgeMouseMove:_n,onEdgeMouseLeave:Ut,onReconnect:Zt??Vn,onReconnectStart:In??Vt,onReconnectEnd:Hr??Lt,reconnectRadius:xe??lr,defaultMarkerColor:qe,noDragClassName:fa,noWheelClassName:Ns,noPanClassName:xr,elevateEdgesOnSelect:wt,rfId:Vr,disableKeyboardA11y:gt,nodeOrigin:ue,nodeExtent:Ye}),ve.createElement(Z4,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:v,onConnectStart:S,onConnectEnd:b,onClickConnectStart:_,onClickConnectEnd:k,nodesDraggable:Te,nodesConnectable:st,nodesFocusable:de,edgesFocusable:se,edgesUpdatable:be,elementsSelectable:Le,elevateNodesOnSelect:tt,minZoom:pe,maxZoom:Ae,nodeExtent:Ye,onNodesChange:ks,onEdgesChange:Wr,snapToGrid:Ie,snapGrid:Ge,connectionMode:B,translateExtent:fe,connectOnClick:Q,defaultEdgeOptions:Ue,fitView:$n,fitViewOptions:Hs,onNodesDelete:$,onEdgesDelete:V,onNodeDragStart:O,onNodeDrag:H,onNodeDragStop:q,onSelectionDrag:M,onSelectionDragStart:ee,onSelectionDragStop:Z,noPanClassName:xr,nodeOrigin:ue,rfId:Vr,autoPanOnConnect:It,autoPanOnNodeDrag:Rt,onError:br,connectionRadius:Qt,isValidConnection:Nt,nodeDragThreshold:ht}),ve.createElement(Y4,{onSelectionChange:ne}),rn,ve.createElement(N4,{proOptions:et,position:De}),ve.createElement(nD,{rfId:Vr,disableKeyboardA11y:gt})))});qA.displayName="ReactFlow";const c5=e=>({x:e.transform[0],y:e.transform[1],zoom:e.transform[2]});function BA(){return Tt(c5,fn)}const zA=({id:e,x:t,y:n,width:r,height:s,style:l,color:c,strokeColor:u,strokeWidth:f,className:p,borderRadius:h,shapeRendering:m,onClick:y,selected:v})=>{const{background:S,backgroundColor:b}=l||{},_=c||S||b;return ve.createElement("rect",{className:jn(["react-flow__minimap-node",{selected:v},p]),x:t,y:n,rx:h,ry:h,width:r,height:s,fill:_,stroke:u,strokeWidth:f,shapeRendering:m,onClick:y?k=>y(k,e):void 0})};zA.displayName="MiniMapNode";var u5=w.memo(zA);const d5=e=>e.nodeOrigin,h5=e=>e.getNodes().filter(t=>!t.hidden&&t.width&&t.height),ym=e=>e instanceof Function?e:()=>e;function f5({nodeStrokeColor:e="transparent",nodeColor:t="#e2e2e2",nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:s=2,nodeComponent:l=u5,onClick:c}){const u=Tt(h5,fn),f=Tt(d5),p=ym(t),h=ym(e),m=ym(n),y=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return ve.createElement(ve.Fragment,null,u.map(v=>{const{x:S,y:b}=ai(v,f).positionAbsolute;return ve.createElement(l,{key:v.id,x:S,y:b,width:v.width,height:v.height,style:v.style,selected:v.selected,className:m(v),color:p(v),borderRadius:r,strokeColor:h(v),strokeWidth:s,shapeRendering:y,onClick:c,id:v.id})}))}var p5=w.memo(f5);const m5=200,g5=150,y5=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?_4(vf(t,e.nodeOrigin),n):n,rfId:e.rfId}},w5="react-flow__minimap-desc";function UA({style:e,className:t,nodeStrokeColor:n="transparent",nodeColor:r="#e2e2e2",nodeClassName:s="",nodeBorderRadius:l=5,nodeStrokeWidth:c=2,nodeComponent:u,maskColor:f="rgb(240, 240, 240, 0.6)",maskStrokeColor:p="none",maskStrokeWidth:h=1,position:m="bottom-right",onClick:y,onNodeClick:v,pannable:S=!1,zoomable:b=!1,ariaLabel:_="React Flow mini map",inversePan:k=!1,zoomStep:j=10,offsetScale:E=5}){const C=tn(),R=w.useRef(null),{boundingRect:I,viewBB:O,rfId:H}=Tt(y5,fn),q=(e==null?void 0:e.width)??m5,$=(e==null?void 0:e.height)??g5,V=I.width/q,ne=I.height/$,ee=Math.max(V,ne),M=ee*q,Z=ee*$,K=E*ee,D=I.x-(M-I.width)/2-K,P=I.y-(Z-I.height)/2-K,B=M+K*2,W=Z+K*2,F=`${w5}-${H}`,G=w.useRef(0);G.current=ee,w.useEffect(()=>{if(R.current){const Y=Pr(R.current),z=ge=>{const{transform:Ne,d3Selection:Ie,d3Zoom:Ge}=C.getState();if(ge.sourceEvent.type!=="wheel"||!Ie||!Ge)return;const Pe=-ge.sourceEvent.deltaY*(ge.sourceEvent.deltaMode===1?.05:ge.sourceEvent.deltaMode?1:.002)*j,Be=Ne[2]*Math.pow(2,Pe);Ge.scaleTo(Ie,Be)},ie=ge=>{const{transform:Ne,d3Selection:Ie,d3Zoom:Ge,translateExtent:Pe,width:Be,height:Te}=C.getState();if(ge.sourceEvent.type!=="mousemove"||!Ie||!Ge)return;const st=G.current*Math.max(1,Ne[2])*(k?-1:1),de={x:Ne[0]-ge.sourceEvent.movementX*st,y:Ne[1]-ge.sourceEvent.movementY*st},ue=[[0,0],[Be,Te]],se=la.translate(de.x,de.y).scale(Ne[2]),be=Ge.constrain()(se,ue,Pe);Ge.transform(Ie,be)},le=QR().on("zoom",S?ie:null).on("zoom.wheel",b?z:null);return Y.call(le),()=>{Y.on("zoom",null)}}},[S,b,k,j]);const re=y?Y=>{const z=hs(Y);y(Y,{x:z[0],y:z[1]})}:void 0,U=v?(Y,z)=>{const ie=C.getState().nodeInternals.get(z);v(Y,ie)}:void 0;return ve.createElement(cb,{position:m,style:e,className:jn(["react-flow__minimap",t]),"data-testid":"rf__minimap"},ve.createElement("svg",{width:q,height:$,viewBox:`${D} ${P} ${B} ${W}`,role:"img","aria-labelledby":F,ref:R,onClick:re},_&&ve.createElement("title",{id:F},_),ve.createElement(p5,{onClick:U,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:l,nodeClassName:s,nodeStrokeWidth:c,nodeComponent:u}),ve.createElement("path",{className:"react-flow__minimap-mask",d:`M${D-K},${P-K}h${B+K*2}v${W+K*2}h${-B-K*2}z
57
+ M${O.x},${O.y}h${O.width}v${O.height}h${-O.width}z`,fill:f,fillRule:"evenodd",stroke:p,strokeWidth:h,pointerEvents:"none"})))}UA.displayName="MiniMap";var v5=w.memo(UA);function x5(){return ve.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},ve.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function b5(){return ve.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},ve.createElement("path",{d:"M0 0h32v4.2H0z"}))}function k5(){return ve.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},ve.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 N5(){return ve.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},ve.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 S5(){return ve.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},ve.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 Lr=({children:e,className:t,...n})=>ve.createElement("button",{type:"button",className:jn(["react-flow__controls-button",t]),...n},e);Lr.displayName="ControlButton";const j5=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),HA=({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:s,onZoomIn:l,onZoomOut:c,onFitView:u,onInteractiveChange:f,className:p,children:h,position:m="bottom-left"})=>{const y=tn(),[v,S]=w.useState(!1),{isInteractive:b,minZoomReached:_,maxZoomReached:k}=Tt(j5,fn),{zoomIn:j,zoomOut:E,fitView:C}=xf();if(w.useEffect(()=>{S(!0)},[]),!v)return null;const R=()=>{j(),l==null||l()},I=()=>{E(),c==null||c()},O=()=>{C(s),u==null||u()},H=()=>{y.setState({nodesDraggable:!b,nodesConnectable:!b,elementsSelectable:!b}),f==null||f(!b)};return ve.createElement(cb,{className:jn(["react-flow__controls",p]),position:m,style:e,"data-testid":"rf__controls"},t&&ve.createElement(ve.Fragment,null,ve.createElement(Lr,{onClick:R,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:k},ve.createElement(x5,null)),ve.createElement(Lr,{onClick:I,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:_},ve.createElement(b5,null))),n&&ve.createElement(Lr,{className:"react-flow__controls-fitview",onClick:O,title:"fit view","aria-label":"fit view"},ve.createElement(k5,null)),r&&ve.createElement(Lr,{className:"react-flow__controls-interactive",onClick:H,title:"toggle interactivity","aria-label":"toggle interactivity"},b?ve.createElement(S5,null):ve.createElement(N5,null)),h)};HA.displayName="Controls";var _5=w.memo(HA),gs;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(gs||(gs={}));function E5({color:e,dimensions:t,lineWidth:n}){return ve.createElement("path",{stroke:e,strokeWidth:n,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`})}function C5({color:e,radius:t}){return ve.createElement("circle",{cx:t,cy:t,r:t,fill:e})}const T5={[gs.Dots]:"#91919a",[gs.Lines]:"#eee",[gs.Cross]:"#e2e2e2"},R5={[gs.Dots]:1,[gs.Lines]:1,[gs.Cross]:6},A5=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function WA({id:e,variant:t=gs.Dots,gap:n=20,size:r,lineWidth:s=1,offset:l=2,color:c,style:u,className:f}){const p=w.useRef(null),{transform:h,patternId:m}=Tt(A5,fn),y=c||T5[t],v=r||R5[t],S=t===gs.Dots,b=t===gs.Cross,_=Array.isArray(n)?n:[n,n],k=[_[0]*h[2]||1,_[1]*h[2]||1],j=v*h[2],E=b?[j,j]:k,C=S?[j/l,j/l]:[E[0]/l,E[1]/l];return ve.createElement("svg",{className:jn(["react-flow__background",f]),style:{...u,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:p,"data-testid":"rf__background"},ve.createElement("pattern",{id:m+e,x:h[0]%k[0],y:h[1]%k[1],width:k[0],height:k[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${C[0]},-${C[1]})`},S?ve.createElement(C5,{color:y,radius:j/l}):ve.createElement(E5,{dimensions:E,color:y,lineWidth:s})),ve.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${m+e})`}))}WA.displayName="Background";var M5=w.memo(WA);const I5=["us-gov","global","apac","us","eu","jp","au"],$5=new RegExp(`^(?:(?:${I5.join("|")})\\.)?anthropic\\.`,"i");function Ql(e){return e.replace($5,"")}const O5=["command","cmd","file_path","path","url","pattern","notebook_path"],$N=120,wm=e=>e.length>$N?`${e.slice(0,$N-1)}…`:e;function L5(e){if(typeof e=="string")return e.trim()?wm(e.trim()):null;if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e;for(const n of O5){const r=t[n];if(typeof r=="string"&&r.trim())return wm(r.trim());if(Array.isArray(r)&&r.length>0&&r.every(s=>typeof s=="string")){const s=r.join(" ").trim();if(s)return wm(s)}}return null}const P5=/^\s*<task-notification>([\s\S]*?)<\/task-notification>/;function ON(e,t){var n;return((n=new RegExp(`<${t}>([\\s\\S]*?)</${t}>`).exec(e))==null?void 0:n[1].trim())||void 0}const LN={completed:"background task finished",failed:"background task failed",killed:"background task stopped"};function bb(e){const t=P5.exec(e);if(!t)return null;const n=ON(t[1],"status");return{label:(n&&Object.hasOwn(LN,n)?LN[n]:void 0)??"background task update",detail:ON(t[1],"summary")}}function VA(e){return e.filter(t=>!bb(t.text))}const D5=/[0-9a-f]{16,}/i,F5=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function GA(e){return D5.test(e)||F5.test(e)}function q5(e){if(!e)return;const t=e.replace(/\\/g,"/").split("/").filter(Boolean);for(let n=t.length-1;n>=0;n--)if(!GA(t[n]))return t[n];return t[t.length-1]}function KA(){return{inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0}}function kb(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 B5(e){const t=kb(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 z5(e){if(!e||typeof e!="object"||Array.isArray(e))return;const t={};for(const[n,r]of Object.entries(e))!n||!r||typeof r!="object"||(t[n]=B5(r));return Object.keys(t).length?t:void 0}function YA(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),...kb(n)};for(const r of Object.values(n)){const s=YA(r,t+1);if(s)return s}return null}const U5=/^(?:claude[-_]|gpt[-_]|o\d|codex[-_])/i,H5=new Set(["tool_input","tool_response"]);function XA(e,t=0){if(!e||typeof e!="object"||t>6)return null;const n=e;if(typeof n.model=="string"&&U5.test(Ql(n.model)))return n.model;for(const[r,s]of Object.entries(n)){if(H5.has(r))continue;const l=XA(s,t+1);if(l)return l}return null}function S0(){return{agents:new Map,toolIndex:new Map,activeSubagentStack:new Map,subagentTombstones:new Map,pendingSubagentModels:new Map,lastSeq:0,seqEpoch:null,totalEvents:0,revision:0}}function no(e){return q5(e)}function PN(){return{msgsUser:0,msgsAssistant:0,toolUses:0,toolResults:0,systemReminders:0,currentContextTokens:0,memoryFiles:[]}}function zl(e,t){return`${e}::${t}`}function ro(e,t){return`${e}\0${t}`}function Zh(e){const t=e.agent_type??e.subagent_type;return t&&!GA(t)?t:"subagent"}function fu(e){return e.agent_id?e.agent_id:e.parent_tool_use_id?e.parent_tool_use_id:null}function Rl(e,t,n,r){const s=t;let l=e.agents.get(s);return l||(l={id:s,sessionId:t,label:"session",kind:"root",state:"active",startedAt:n,lastEventAt:n,tools:[],prompts:[],toolCount:0,childCount:0,synthetic:r,usage:KA()},e.agents.set(s,l),l)}function ZA(e,t,n,r){const s=zl(t,n),l=e.agents.get(s);if(!l)return null;!l.cwd&&r.cwd&&(l.cwd=r.cwd,l.cwdBasename=no(r.cwd));const c=Zh(r);return c&&(l.label==="subagent"||!l.label)&&(l.label=c),l}function W5(e,t,n){const r=t.session_id??"unknown",s=fu(t);if(s){const f=ZA(e,r,s,t);if(f)return f}const l=e.activeSubagentStack.get(r),c=l&&l.length>0?l[l.length-1]:null;if(c){const f=e.agents.get(zl(r,c));if(f)return!f.cwd&&t.cwd&&(f.cwd=t.cwd,f.cwdBasename=no(t.cwd)),f}const u=Rl(e,r,n,t.hook_event_name!=="SessionStart");return!u.cwd&&t.cwd&&(u.cwd=t.cwd,u.cwdBasename=no(t.cwd)),u.label==="session"&&t.cwd&&(u.label=no(t.cwd)??"session"),u}function V5(e,t,n,r,s){const l=zl(t,n),c=Rl(e,t,s,!0);let u=e.agents.get(l);if(u){!u.cwd&&r.cwd&&(u.cwd=r.cwd,u.cwdBasename=no(r.cwd));const p=Zh(r);return p&&(u.label==="subagent"||!u.label)&&(u.label=p),u}u={id:l,sessionId:t,label:Zh(r),kind:"subagent",parentId:c.id,state:"active",startedAt:s,tools:[],prompts:[],cwd:r.cwd,cwdBasename:no(r.cwd),toolCount:0,childCount:0,usage:KA()},e.agents.set(l,u);const f=e.pendingSubagentModels.get(l);return f&&(u.model=f,e.pendingSubagentModels.delete(l)),c.childCount+=1,u}function G5(e,t,n){const r=e.activeSubagentStack.get(t)??[];r.includes(n)||(r.push(n),e.activeSubagentStack.set(t,r))}function DN(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 hh(e,t=80){if(e==null)return"";if(typeof e=="string")return e.length>t?e.slice(0,t-1)+"…":e;try{const n=JSON.stringify(e);return n.length>t?n.slice(0,t-1)+"…":n}catch{return String(e)}}const FN=200;function K5(e,t){for(const n of e.values()){const r=n.tools.find(s=>s.id===t);if(r)return r}return null}const Y5=25;function X5(e,t){const n=t.tools;if(n.length>FN){const r=n.splice(0,n.length-FN);for(const s of r){const l=ro(t.sessionId,s.id);e.toolIndex.get(l)===s&&e.toolIndex.delete(l)}}for(let r=n.length-Y5-1;r>=0;r--){const s=n[r];if(s.trimmed)break;s.input=void 0,s.response=void 0,s.trimmed=!0}}function Z5(e,t,n){const r=e.toolIndex.get(ro(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}const qN=2e3;function Q5(e,t,n){for(let r=e.prompts.length-1;r>=0;r--){const s=e.prompts[r];if(s.at<t-qN)return!1;if(s.text===n&&s.at<=t+qN)return!0}return!1}const fh=2e3;function J5(e){let t=e.startedAt;for(const n of e.prompts)n.at>t&&(t=n.at);return t}function QA(e,t){for(const n of t.tools){const r=ro(t.sessionId,n.id);e.toolIndex.get(r)===n&&e.toolIndex.delete(r)}}function Bu(e,t){return t&&(e.revision+=1),t}function e6(e,t,n,r,s){if(e.agents.size<=n)return!1;const l=m=>m.state==="done"&&m.endedAt!=null&&t-m.endedAt>r,c=[],u=new Map;for(const[m,y]of e.agents){if(y.parentId!=null){const v=u.get(y.parentId);v?v.push(m):u.set(y.parentId,[m])}l(y)&&c.push({id:m,endedAt:y.endedAt})}if(c.length===0)return!1;c.sort((m,y)=>m.endedAt-y.endedAt);let f=0;const p=new Set,h=m=>{const y=e.agents.get(m);y&&(QA(e,y),e.agents.delete(m),p.add(y.sessionId),f++)};for(const m of c){if(e.agents.size<=n)break;if(!e.agents.has(m.id))continue;const y=(u.get(m.id)??[]).map(v=>e.agents.get(v)).filter(v=>v!=null);if(!y.some(v=>!l(v))){for(const v of y)h(v.id);h(m.id)}}if(s&&p.size>0){const m=new Set;for(const y of e.agents.values())m.add(y.sessionId);for(const y of p)m.has(y)||s(y)}return Bu(e,f>0)}function t6(e,t,n,r,s){const l=new Map;for(const[h,m]of e.agents){let y=l.get(m.sessionId);y||(y={ids:[],endedAt:0,live:!1,closed:!1},l.set(m.sessionId,y)),y.ids.push(h),m.kind==="root"&&m.closedAt!=null&&(y.closed=!0),m.state==="done"&&m.endedAt!=null?y.endedAt=Math.max(y.endedAt,m.endedAt):y.live=!0}const c=[...l].filter(([,h])=>!h.live&&h.endedAt>0&&t-h.endedAt>r).sort(([,h],[,m])=>h.closed===m.closed?h.endedAt-m.endedAt:h.closed?-1:1);let f=[...l.values()].filter(h=>!h.live).length-n;if(f<=0)return!1;let p=!1;for(const[h,m]of c){if(f<=0)break;for(const y of m.ids){const v=e.agents.get(y);v&&QA(e,v),e.agents.delete(y)}for(const y of e.pendingSubagentModels.keys())y.startsWith(`${h}::`)&&e.pendingSubagentModels.delete(y);s==null||s(h),f--,p=!0}return Bu(e,p)}function n6(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(ro((n==null?void 0:n.session_id)??"unknown",s))}function r6(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 Bu(e,t)}function s6(e,t,n){let r=!1;for(const s of e.agents.values()){if(s.provider==="codex")continue;const l=e.agents.get(s.sessionId),c=(l==null?void 0:l.lastEventAt)??(l==null?void 0:l.startedAt);for(const u of s.tools){const f=Math.max(u.startedAt,c??u.startedAt);u.endedAt==null&&t-f>n&&(u.endedAt=f,u.ok=!1,u.errorPreview=u.outcomeGap?"no result reached the deck — events were dropped while the deck was paused":"session ended before this call returned",e.toolIndex.delete(ro(s.sessionId,u.id)),r=!0)}}return Bu(e,r)}const BN=90*6e4;function a6(e,t,n){let r=!1;for(const s of e.agents.values()){if(s.kind!=="root")continue;const l=s.lastEventAt??s.startedAt;if(!(t-l<=n)){s.waiting&&(s.waiting=null,r=!0),s.closedAt==null&&(s.closedAt=l),s.state==="active"&&(s.state="done",s.endedAt=l,s.reaped=!0,r=!0);for(const c of e.agents.values())c.sessionId!==s.sessionId||c.kind==="root"||c.state!=="active"||(c.state="done",c.endedAt=l,r=!0);e.activeSubagentStack.delete(s.sessionId)}}return Bu(e,r)}function o6(e){return e==="permission_prompt"?"permission":e==="agent_needs_input"?"asked":e==="idle_prompt"?"idle":null}const i6=new Set(["Notification","ModelObserved","ContextObserved","UsageObserved","SessionNamed","SessionRecapped"]);function l6(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 c6=3e4;function u6(e,t){if(!(!e||!e.name)&&!(t-e.startedAt>c6)&&!(e.startedAt>t))return{name:e.name,preview:L5(e.input)??""}}function d6(e,t,n,r,s){if(n!=="permission")return{kind:n,message:r,since:s};const l=l6(e,t),c={kind:n,message:r,since:s};l!=null&&l.explicitSubagentId&&(c.subagentId=l.explicitSubagentId);const u=u6(l,s);return u&&(c.tool=u),c}function h6(e,t,n){if(e.kind==="idle")return!0;const r=fu(t);return r==null?!0:e.subagentId!=null&&zl(n,r)===e.subagentId}function zN(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,l=r.hook_event_name??"Unknown";if(l==="__clear")return{...S0(),lastSeq:t.seq,seqEpoch:e.seqEpoch,revision:e.revision+1};e.totalEvents+=1,e.lastSeq=t.seq,e.revision+=1;const c=r.session_id??"unknown";if(!i6.has(l)){const h=e.agents.get(c);h!=null&&h.waiting&&h6(h.waiting,r,c)&&(h.waiting=null)}const u=e.agents.get(c);if(u&&s>(u.lastEventAt??0)&&(u.lastEventAt=s,u.reaped&&(u.reaped=!1,u.state="active",u.endedAt=void 0,u.closedAt=void 0)),typeof r.model_context_window=="number"&&r.model_context_window>0){const h=e.agents.get(c);h&&(h.contextWindow=r.model_context_window)}if(typeof r.approval_policy=="string"&&r.approval_policy){const h=e.agents.get(c);h&&(h.approvalPolicy=r.approval_policy)}if(typeof r.context_tokens=="number"&&r.context_tokens>=0){const h=e.agents.get(c);h&&(h.context={...h.context??PN(),currentContextTokens:r.context_tokens})}if(l==="ModelObserved"){const h=typeof r.model=="string"?r.model:null;if(h){const y=e.agents.get(c);y&&(y.model=h)}const m=r.subagentModels;if(m&&typeof m=="object")for(const[y,v]of Object.entries(m)){if(typeof v!="string")continue;const S=`${c}::${y}`,b=e.agents.get(S);if(b)b.model=v,e.pendingSubagentModels.delete(S);else if(e.pendingSubagentModels.delete(S),e.pendingSubagentModels.set(S,v),e.pendingSubagentModels.size>256){const _=e.pendingSubagentModels.keys().next().value;_!==void 0&&e.pendingSubagentModels.delete(_)}}return e}if(l==="ContextObserved"){const h=r.context??null;if(h){const m=e.agents.get(c);if(m){const y=m.context??PN(),v=(b,_)=>typeof h[b]=="number"?h[b]:_,S=Array.isArray(h.memoryFiles)?h.memoryFiles:Array.isArray(h.claudeMdFiles)?h.claudeMdFiles:null;m.context={msgsUser:v("msgsUser",y.msgsUser),msgsAssistant:v("msgsAssistant",y.msgsAssistant),toolUses:v("toolUses",y.toolUses),toolResults:v("toolResults",y.toolResults),systemReminders:v("systemReminders",y.systemReminders),currentContextTokens:v("currentContextTokens",y.currentContextTokens),memoryFiles:S??y.memoryFiles}}}return e}if(l==="SessionNamed"){const h=e.agents.get(c);if(h){const m=typeof r.sessionName=="string"?r.sessionName.trim():"",y=typeof r.sessionTitle=="string"?r.sessionTitle.trim():"";m&&(h.sessionName=m),y&&(h.sessionTitle=y);const v=h.sessionName??"";h.sessionTitle&&v&&h.sessionTitle.toLowerCase()===v.toLowerCase()&&(h.sessionTitle=void 0)}return e}if(l==="SessionRecapped"){const h=e.agents.get(c);if(h){const m=r.recap;m===null?h.recap=void 0:m&&typeof m.text=="string"&&m.text.trim()&&Number.isFinite(m.at)&&(h.recap={text:m.text.trim(),at:m.at})}return e}if(l==="OutputObserved"){const h=r.kind==="thinking"||r.kind==="text"||r.kind==="tool_use"?r.kind:null,m=typeof r.at=="number"&&Number.isFinite(r.at)?r.at:s;if(!h)return e;const y=e.agents.get(c);if(!y||y.lastOutputAt!=null&&m<=y.lastOutputAt)return e;if(y.lastOutputAt=m,h!=="tool_use"){const v=(y.outputs??[]).filter(S=>m-S<f6);v.push(m),y.outputs=v.length>UN?v.slice(-UN):v}return e.revision+=1,e}if(l==="UsageObserved"){const h=r.usage??null;if(h){const m=e.agents.get(c);if(m){m.usage.inputTokens=Number(h.input_tokens??0),m.usage.outputTokens=Number(h.output_tokens??0),m.usage.cacheReadTokens=Number(h.cache_read_input_tokens??h.cached_input_tokens??0),m.usage.cacheCreateTokens=Number(h.cache_creation_input_tokens??h.cache_write_input_tokens??0);const y=kb(h);m.usage.cacheCreate1hTokens=y.cacheCreate1hTokens,m.usage.cacheCreate5mTokens=y.cacheCreate5mTokens,typeof h.reasoning_output_tokens=="number"&&(m.usage.reasoningOutputTokens=Number(h.reasoning_output_tokens)),m.usageByModel=z5(r.usageByModel)}}return e}const f=W5(e,r,s);f.provider||(f.provider=r.provider==="codex"?"codex":"claude");const p=XA(r);switch(p&&(f.model=p),l){case"SessionStart":{const h=Rl(e,c,s,!1);h.synthetic=!1,h.state="active",h.closedAt=void 0,h.endedAt=void 0,h.startedAt=Math.min(h.startedAt??s,s),!h.cwd&&r.cwd&&(h.cwd=r.cwd,h.cwdBasename=no(r.cwd)),h.label==="session"&&r.cwd&&(h.label=no(r.cwd)??"session");break}case"UserPromptSubmit":{for(const y of e.agents.values())y.sessionId===c&&y.kind==="subagent"&&y.state==="done"&&y.exitAt==null&&y.endedAt!=null&&y.endedAt<s&&(y.exitAt=s);const h=Rl(e,c,s,!1);h.state="active",h.endedAt=void 0,h.closedAt=void 0,h.exitAt=void 0;const m=(typeof r.prompt=="string"?r.prompt:typeof r.message=="string"?r.message:"")??"";m&&!Q5(h,s,m)&&(h.prompts.push({at:s,text:m}),!h.firstPrompt&&!bb(m)&&(h.firstPrompt=hh(m,120)));break}case"PreToolUse":{const h=r.tool_use_id?Z5(e,f,r.tool_use_id):null;if(h){r.tool_name&&h.name==="?"&&(h.name=r.tool_name),h.endedAt==null&&!h.trimmed&&r.tool_input!==void 0&&(h.input=r.tool_input,h.inputPreview=hh(r.tool_input));break}const m=r.tool_use_id??`${f.id}:${f.toolCount}`,y=fu(r),v={id:m,name:r.tool_name??"?",input:r.tool_input,inputPreview:hh(r.tool_input),agentId:f.id,explicitSubagentId:y?zl(c,y):void 0,startedAt:s};f.tools.push(v),f.toolCount+=1,f.state="active",e.toolIndex.set(ro(f.sessionId,m),v),X5(e,f);break}case"PostToolUse":case"PostToolUseFailure":{const h=r.tool_use_id;if(!h)break;const m=ro(c,h);let y=e.toolIndex.get(m),v=!1;if(!y)for(const b of e.agents.values()){if(b.sessionId!==c)continue;const _=b.tools.find(k=>k.id===h);if(_){y=_,v=!0;break}}if(!y||y.outcomeApplied)break;y.outcomeApplied=!0,y.outcomeGap=void 0,y.endedAt=s,y.ok=l==="PostToolUse",y.trimmed||(y.response=r.tool_response),l==="PostToolUseFailure"?y.errorPreview=hh(r.tool_response):v&&(y.errorPreview=void 0);const S=YA(r.tool_response);S&&(y.usage=S),e.toolIndex.delete(m);break}case"SubagentStart":{const h=fu(r);if(!h)break;const m=V5(e,c,h,r,s),y=Zh(r);y&&(m.label=y);const v=e.subagentTombstones.get(m.id);v!=null&&e.subagentTombstones.delete(m.id);const S=m.endedAt!=null&&s-m.endedAt<=fh,b=v!=null&&s-v<=fh;if(S||b){const _=b?v:m.endedAt;m.state="done",m.endedAt=_,m.startedAt=Math.min(m.startedAt,_),DN(e,c,h);break}m.state="active",m.startedAt=m.startedAt||s,m.exitAt=void 0,m.endedAt=void 0,G5(e,c,h);break}case"SubagentStop":{const h=fu(r);if(!h)break;const m=ZA(e,c,h,r);if(!m){for(const[y,v]of e.subagentTombstones)s-v>fh&&e.subagentTombstones.delete(y);e.subagentTombstones.set(zl(c,h),s);break}m.state="done",m.endedAt=Math.min(m.endedAt??s,s),DN(e,c,h);break}case"Stop":case"SessionEnd":{const h=Rl(e,c,s,!1),m=J5(h);if(s<m)break;const y=h.lastTurnEndAt;if(y!=null&&m>y&&s<=y+fh)break;h.state="done",h.endedAt=s,h.lastTurnEndAt=s;for(const v of h.provider==="codex"?[]:e.agents.values())if(v.sessionId===c)for(const S of v.tools)S.endedAt==null&&S.explicitSubagentId==null&&(S.endedAt=s,S.ok=!1,S.errorPreview=S.outcomeGap?"no result reached the deck — events were dropped while the deck was paused":"the turn ended before this call returned",e.toolIndex.delete(ro(v.sessionId,S.id)));l==="SessionEnd"&&(h.closedAt=s),e.activeSubagentStack.delete(c);break}case"Notification":{const h=o6(r.notification_type);if(!h)break;const m=Rl(e,c,s,!1),y=typeof r.message=="string"?r.message:"",v=m.waiting;m.waiting=v&&v.kind===h&&v.message===y?{...v,since:Math.min(v.since,s)}:d6(e,c,h,y,s);break}}return e}const f6=6e4,UN=64;function Qh(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n);return Math.abs(t)%360}const p6={input:2,output:10,cacheRead:.2,cacheWrite:2.5,cacheWrite1h:4},m6=[{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\b(?![-_.]\d{1,7}(?!\d))/i,rates:{input:5,output:25,cacheRead:.5,cacheWrite:6.25,cacheWrite1h:10}},{match:/^claude[-_]sonnet[-_]5\b(?![-_.]\d{1,7}(?!\d))/i,rates:p6},{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[-_]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}}];function g6(e){return e?/^(?:gpt[-_]|codex[-_]|o\d)/i.test(e):!1}function Jl(e,t=Date.now()){if(!e)return null;const n=Ql(e);for(const r of m6)if(r.match.test(n))return typeof r.rates=="function"?r.rates(t):r.rates;return null}function JA(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),l=r+s,c=t.cacheWrite1h??t.cacheWrite;return{tokens5m:l,tokens1h:n,usd5m:l*t.cacheWrite/1e6,usd1h:n*c/1e6}}function eM(e,t,n=Date.now()){if(!g6(t))return e.inputTokens;const r=Jl(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 ri(e,t,n=Date.now()){const r=Jl(t,n);if(!r)return{input:0,output:0,cacheRead:0,cacheWrite:0,total:0};const s=eM(e,t,n)*r.input/1e6,l=e.outputTokens*r.output/1e6,c=e.cacheReadTokens*r.cacheRead/1e6,u=JA(e,r),f=u.usd5m+u.usd1h;return{input:s,output:l,cacheRead:c,cacheWrite:f,total:s+l+c+f}}const HN=2e5,y6=1e6,w6=[/\[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],v6=[{match:/^gpt[-_]6[-_]astra/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 x6(e){if(!e)return HN;const t=Ql(e);for(const n of w6)if(n.test(t))return y6;for(const n of v6)if(n.match.test(t))return n.window;return HN}function tM(e,t){return typeof e=="number"&&e>0?e:x6(t)}const Cl="not priced";function ut(e){if(e<=0)return"—";if(e<.005)return"<1¢";if(e<1){const t=(e*100).toFixed(e<.1?1:0);if(Number(t)<100)return`${t}¢`}if(e<100){const t=e.toFixed(2);if(Number(t)<100)return`$${t}`}if(e<1e4){const t=e.toFixed(0);if(Number(t)<1e4)return`$${t}`}return`$${(e/1e3).toFixed(1)}k`}function Nb(e,t){if(e<=0||t<10)return null;const n=e/t,r=n*60;return r>=.01?`${ut(r)}/min`:`${ut(n*3600)}/hr`}function b6(e,t){const n={inputTokens:e.inputTokens+t.inputTokens,outputTokens:e.outputTokens+t.outputTokens,cacheReadTokens:e.cacheReadTokens+t.cacheReadTokens,cacheCreateTokens:e.cacheCreateTokens+t.cacheCreateTokens};return(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)),n}function k6(e,t){let n=0,r=0,s=0,l=0,c=0,u=0;for(const m of t)n+=m.inputTokens,r+=m.outputTokens,s+=m.cacheReadTokens,l+=m.cacheCreateTokens,c+=m.cacheCreate1hTokens??0,u+=m.cacheCreate5mTokens??0;const f=(m,y)=>Math.max(0,m-y),p={inputTokens:f(e.inputTokens,n),outputTokens:f(e.outputTokens,r),cacheReadTokens:f(e.cacheReadTokens,s),cacheCreateTokens:f(e.cacheCreateTokens,l)};return(e.cacheCreate1hTokens!==void 0||e.cacheCreate5mTokens!==void 0)&&(p.cacheCreate1hTokens=f(e.cacheCreate1hTokens??0,c),p.cacheCreate5mTokens=f(e.cacheCreate5mTokens??0,u)),p.inputTokens+p.outputTokens+p.cacheReadTokens+p.cacheCreateTokens>0?p:null}function zu(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(l=>({model:l,usage:t[l]})),s=k6(e.usage,r.map(l=>l.usage));if(s){const l=r.findIndex(c=>c.model===e.model);l>=0?r[l]={model:r[l].model,usage:b6(r[l].usage,s)}:r.push({model:e.model,usage:s})}return r}function ir(e,t=Date.now()){const n={input:0,output:0,cacheRead:0,cacheWrite:0,total:0};for(const r of zu(e)){const s=ri(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 _u(e,t=Date.now()){let n=0;for(const r of zu(e))Jl(r.model,t)==null&&(n+=r.usage.inputTokens+r.usage.outputTokens);return n}function nM(e){const t=[];for(const n of zu(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 rM(e){return nM(e).filter(t=>t!==e.model)}const N6=new Set(["untrusted","on-request","on-failure"]);function S6(e){return typeof e!="string"||!e?null:N6.has(e)?!0:e==="never"?!1:null}function j6(e){if(e.provider!=="codex"||e.kind!=="root"||e.waiting||e.state!=="active")return null;const t=S6(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."}
58
+
59
+ 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 WN(e){return e[0].toUpperCase()+e.slice(1).toLowerCase()}function so(e){const t=Ql(e).replace(/[-_]\d{8}(?!\d)/,""),n=t.match(/^claude[-_](opus|sonnet|haiku|fable|mythos)[-_](\d+(?:[-_.]\d+)*)/i);if(n){const s=WN(n[1]),l=n[2].replace(/[-_]/g,".");return`${s} ${l}`}const r=t.match(/^gpt[-_](\d+(?:[-_.]\d+)*)((?:[-_][A-Za-z0-9.]+)*)$/i);if(r){const s=r[1].replace(/[-_]/g,"."),l=r[2].split(/[-_]/).filter(Boolean).map(WN);return[`GPT-${s}`,...l].join(" ")}return e}function bf(e){const t=Ql(e??""),n=t.match(/^claude[-_](opus|sonnet|haiku|fable|mythos)[-_]/i);return n?n[1].toLowerCase():/^gpt[-_]/i.test(t)?"gpt":""}function Fr(e){return(e==null?void 0:e.kind)==="permission"||(e==null?void 0:e.kind)==="asked"}function vm(e){const t=[];for(const n of e)n.kind==="root"&&Fr(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 _6(e,t){if(e.length===0)return null;const n=e.findIndex(r=>r.id===t);return e[(n+1)%e.length]}function E6(e){const t=new Set;for(const n of e)n.state==="active"&&t.add(n.sessionId);return t.size}function kf(e,t){return`${e}@${t.since}`}function sM(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 C6(e){const t=e.message||"Needs your permission",n=sM(e,t);return n?`${t}
60
+ Likely on: ${n}`:t}function T6(e,t,n,r=!0){if(!r)return[];if(n)return[];const s=[];for(const l of e){if(!Fr(l.waiting))continue;const c=kf(l.id,l.waiting);t.has(c)||s.push({key:c,title:l.label,body:C6(l.waiting),sessionId:l.id})}return s}function R6(e,t,n){const r=new Set;for(const l of e)r.add(kf(l.id,l.waiting));const s=new Set;for(const l of n)r.has(l)&&s.add(l);for(const l of t)s.add(l.key);return s}function xm(e){return new Set(e.map(t=>kf(t.id,t.waiting)))}function A6(e,t){return e!==t}function M6(e,t){return!e&&t!=null}function I6(e,t){return e!==null&&t!=null}function Bt(e){const t=Math.round(e);return t<1e3?`${t}`:t<1e6?`${(t/1e3).toFixed(1)}k`:t<1e9?`${(t/1e6).toFixed(2)}M`:`${(t/1e9).toFixed(2)}B`}function Ul(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 l=Math.floor(s/60),c=s%60;return`${l}m ${String(c).padStart(2,"0")}s`}function aM(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 Sb(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 $6=1;function O6(){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,l="dialog"){const c={dismiss:r,layer:s,kind:l,seq:t++};return e.push(c),()=>{const u=e.indexOf(c);u!==-1&&e.splice(u,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 pu=O6(),L6=e=>e==="Escape";function P6(e){return e.overlayOpen?"dismiss":e.typing?"blur":"clear-selection"}function VN(e){return String(e.tagName??"").toUpperCase()==="BODY"}function D6(e,t){return!e||!e.isConnected||VN(e)?!1:t==null||VN(t)}const GN="a[href], button, input, select, textarea, [tabindex]";function F6(e){return!e||e.disabled||e.rendered===!1?!1:(e.tabIndex??0)>=0}function q6(e){if(!e||!e.overflowing||e.hasFocusable)return!1;const t=String(e.overflow??"").toLowerCase();return t==="auto"||t==="scroll"}function B6({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 Nf(e){return e.ctrlKey||e.metaKey||e.altKey}const z6=new Set(["button","checkbox","color","file","image","radio","range","reset","submit"]),U6=new Set(["INPUT","TEXTAREA","SELECT","OPTION","BUTTON","SUMMARY","A"]),H6=new Set(["button","checkbox","combobox","link","listbox","menu","menubar","menuitem","menuitemcheckbox","menuitemradio","option","radio","searchbox","slider","spinbutton","switch","tab","textbox","treeitem"]);function jb(e){return typeof e.tagName=="string"?e.tagName.toUpperCase():""}function W6(e){return jb(e)==="BUTTON"?!0:(typeof e.role=="string"?e.role.trim().toLowerCase():"").split(/\s+/).includes("button")}function Sf(e){if(!e)return!1;if(e.isContentEditable)return!0;const t=jb(e);return t==="TEXTAREA"?!0:t!=="INPUT"?!1:!z6.has(String(e.type??"text").toLowerCase())}function V6(e,t){if(!e)return!1;if(Sf(e))return!0;if(t!=null&&t.length===1&&t!==" "&&e.pointerFocused&&W6(e))return!1;if(U6.has(jb(e)))return!0;const n=typeof e.role=="string"?e.role.trim().toLowerCase():"";return n!==""&&n.split(/\s+/).some(r=>H6.has(r))}function G6({key:e,modalOpen:t,sheetOpen:n}){return t?!(e==="?"&&n):!1}function K6({appModal:e,dialogDepth:t}){return e||t>0}function oM(e){return e?Array.from(e.querySelectorAll("*")).filter(t=>{if(t.matches(GN))return F6({disabled:t.disabled,tabIndex:t.tabIndex,rendered:t.getClientRects().length>0});const n=t.scrollHeight>t.clientHeight;return n&&q6({overflowing:n,overflow:getComputedStyle(t).overflowY,hasFocusable:t.querySelector(GN)!=null})}):[]}function Y6(e,t){const n=oM(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 pn(e,t={}){const{focusRef:n,layer:r,popover:s}=t,l=s?"popover":"dialog",c=w.useRef(null),u=w.useRef(e);u.current=e;const f=w.useRef(null);f.current===null&&(f.current=()=>u.current());const p=f.current;return w.useEffect(()=>pu.push(p,r,l),[p,r,l]),w.useEffect(()=>{var m;const h=document.activeElement;return(m=(n==null?void 0:n.current)??oM(c.current)[0])==null||m.focus(),()=>{D6(h,document.activeElement)&&h.focus()}},[]),w.useEffect(()=>{const h=m=>{var k;if(m.key!=="Tab"||Nf(m))return;const y=c.current;if(!y)return;const v=document.activeElement;if(!(v!=null&&y.contains(v))&&!pu.isTop(p))return;const b=Y6(y,v),_=B6({count:b.length,index:v?b.indexOf(v):-1,shiftKey:m.shiftKey});_.kind!=="allow"&&(m.preventDefault(),_.kind==="focus"&&((k=b[_.index])==null||k.focus()))};return window.addEventListener("keydown",h),()=>window.removeEventListener("keydown",h)},[p]),c}function X6(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 Or(e){return e.toLocaleString()}function Z6(e){return e<1024?`${e} B`:e<1024*1024?`${(e/1024).toFixed(1)} KB`:`${(e/1024/1024).toFixed(2)} MB`}const Q6=60;function J6(e,t=Q6){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 eF({agent:e,onClose:t}){var y;const n=w.useRef(null),r=pn(t,{focusRef:n}),s=e.context,l=e.usage,c=(s==null?void 0:s.currentContextTokens)??0,u=tM(e.contextWindow,e.model),f=Math.min(100,c/u*100),p=ir(e),h=e.provider==="codex"?l.inputTokens+l.outputTokens:l.inputTokens+l.outputTokens+l.cacheReadTokens+l.cacheCreateTokens,m=X6(e.provider);return o.jsx("div",{className:"modal-backdrop",onClick:t,role:"presentation",children:o.jsxs("div",{ref:r,className:"modal ctx-modal",onClick:v=>v.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Context breakdown",children:[o.jsxs("header",{className:"ctx-modal-head",children:[o.jsxs("div",{children:[o.jsxs("div",{className:"ctx-modal-title",children:["Context · ",e.label]}),o.jsx("div",{className:"ctx-modal-sub",children:m.subtitle})]}),o.jsx("button",{type:"button",ref:n,className:"glyph-btn ctx-modal-close",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]}),o.jsxs("section",{className:"ctx-window-row",children:[o.jsx("div",{className:"ctx-window-bar",role:"progressbar","aria-label":"Context window used","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(f),children:o.jsx("div",{className:"ctx-window-fill",style:{transform:`scaleX(${Math.min(100,Math.max(0,f))/100})`}})}),o.jsxs("div",{className:"ctx-window-meta",children:[o.jsxs("span",{className:"ctx-window-pct",children:[f.toFixed(1),"%"]}),o.jsxs("span",{children:[Or(c)," / ",Or(u)," tok (",m.windowScope,")"]})]})]}),o.jsx("h3",{className:"ctx-section-title",children:"Cumulative usage · whole session"}),o.jsxs("div",{className:"ctx-grid",children:[o.jsx(ds,{label:"input tokens",val:Or(l.inputTokens)}),o.jsx(ds,{label:"output tokens",val:Or(l.outputTokens)}),o.jsx(ds,{label:"cache reads",val:Or(l.cacheReadTokens)}),o.jsx(ds,{label:"cache writes",val:Or(l.cacheCreateTokens)}),o.jsx(ds,{label:"cumulative total",val:Or(h)}),o.jsx(ds,{label:"estimated cost",val:ut(p.total),accent:!0})]}),o.jsx("h3",{className:"ctx-section-title",children:"Transcript composition"}),m.compositionCounted?o.jsxs("div",{className:"ctx-grid",children:[o.jsx(ds,{label:"user messages",val:Or((s==null?void 0:s.msgsUser)??0)}),o.jsx(ds,{label:"assistant messages",val:Or((s==null?void 0:s.msgsAssistant)??0)}),o.jsx(ds,{label:"tool uses",val:Or((s==null?void 0:s.toolUses)??0)}),o.jsx(ds,{label:"tool results",val:Or((s==null?void 0:s.toolResults)??0)}),o.jsx(ds,{label:"system-reminders",val:Or((s==null?void 0:s.systemReminders)??0)})]}):o.jsx("div",{className:"ctx-empty",children:m.compositionUncounted}),o.jsx("h3",{className:"ctx-section-title",children:m.memoryHeading}),(((y=s==null?void 0:s.memoryFiles)==null?void 0:y.length)??0)===0?o.jsx("div",{className:"ctx-empty",children:m.memoryEmpty}):o.jsx("ul",{className:"ctx-md-list",children:s.memoryFiles.map(v=>o.jsxs("li",{children:[o.jsx("span",{className:"ctx-md-path",title:v.path,children:J6(v.path)}),o.jsx("span",{className:"ctx-md-size",children:Z6(v.bytes)})]},v.path))})]})})}function ds({label:e,val:t,accent:n}){return o.jsxs("div",{className:`ctx-row${n?" accent":""}`,children:[o.jsx("span",{className:"ctx-row-label",children:e}),o.jsx("span",{className:"ctx-row-val",children:t})]})}function tF({currentContextTokens:e,modelId:t,contextWindow:n,size:r=26,onClick:s}){const l=tM(n,t),c=Math.min(1,e/l),u=r/2-3,f=r/2,p=2*Math.PI*u,h=p*c,m=c>.9?"var(--err)":c>.7?"var(--inflight)":"var(--accent)";return o.jsx("button",{type:"button",className:"ctx-donut",onClick:s,title:`context: ${e.toLocaleString()} / ${l.toLocaleString()} (${(c*100).toFixed(1)}%)`,"aria-label":`Context ${Math.round(c*100)}% of ${l.toLocaleString()} tokens — show breakdown`,children:o.jsxs("svg",{width:r,height:r,viewBox:`0 0 ${r} ${r}`,"aria-hidden":"true",children:[o.jsx("circle",{cx:f,cy:f,r:u,stroke:"var(--line)",strokeWidth:"2.5",fill:"none"}),o.jsx("circle",{cx:f,cy:f,r:u,stroke:m,strokeWidth:"2.5",fill:"none",strokeDasharray:`${h} ${p-h}`,strokeDashoffset:p/4,strokeLinecap:"round",style:{transition:"var(--ctx-arc-transition)"}}),o.jsx("text",{x:f,y:f+3,textAnchor:"middle",fontSize:"8",fill:"var(--text)",fontWeight:"600",children:Math.round(c*100)})]})})}const KN=new Map;function iM(e){let t=KN.get(e);return t||(t={now:Date.now(),listeners:new Set,timer:null},KN.set(e,t)),t}function nF(e,t){const n=iM(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 rF(e){return iM(e).now}const YN=new Map,XN=new Map;function ec(e=1e3){let t=YN.get(e);t||(t=r=>nF(e,r),YN.set(e,t));let n=XN.get(e);return n||(n=()=>rF(e),XN.set(e,n)),w.useSyncExternalStore(t,n,n)}function jf(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 sF="1",ZN="agent-dag.schema",aF=["agent-dag.layout","agent-dag.viewport"];function yr(e){if(typeof window>"u")return null;try{return window.localStorage.getItem(e)}catch{return null}}function oF(e,t=sF){let n=null;try{n=e.getItem(ZN)}catch{return[]}if(n===t)return[];const r=[];if(n!==null)for(const s of aF)try{e.getItem(s)!==null&&(e.removeItem(s),r.push(s))}catch{}try{e.setItem(ZN,t)}catch{}return r}const lM="agent-dag.recapsDismissed",QN=200;function iF(){const e=yr(lM);if(!e)return[];try{const t=JSON.parse(e);return Array.isArray(t)?t.filter(n=>typeof n=="string"):[]}catch{return[]}}let Hl=new Set(iF());const j0=new Set;let cM=0;function uM(e){return j0.add(e),()=>{j0.delete(e)}}function dM(e){if(Hl=e,cM++,typeof window<"u")try{const t=Array.from(e);window.localStorage.setItem(lM,JSON.stringify(t.length>QN?t.slice(-QN):t))}catch{}for(const t of j0)t()}function hM(e,t){return`${e}@${t}`}function lF(e){return Hl.has(e)}function cF(e){if(Hl.has(e))return;const t=new Set(Hl);t.add(e),dM(t)}function uF(e){const t=new Set(Hl);t.delete(e)||t.add(e),dM(t)}function dF(e){return w.useSyncExternalStore(uM,()=>e!=null&&Hl.has(e),()=>!1)}function _b(e){return`recap:${e}`}function hF(e){return e.startsWith("recap:")}function fF(){return w.useSyncExternalStore(uM,()=>cM,()=>0)}function pF(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;for(const s of n.tools)s.ok===!1&&(r.failed+=1)}return t}function fM(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 pM(e){return e.live>0?`→ ${e.total} · ${e.live} live`:`→ ${e.total} · done`}function mF(e,t,n){const r=e.kind==="root"?e.waiting:null;if(r&&Fr(r))return{tone:"warn",long:n.sayWaiting(r),short:r.kind==="permission"?"Needs you":"Asked you"};if(r&&r.kind==="idle"){const l=n.sayWaiting(r);return{tone:"idle",long:l,short:l}}const s=e.tools.filter(l=>l.ok===!1).length;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:fM(t),short:pM(t)};if(e.state==="active")for(let l=e.tools.length-1;l>=0;l--){const c=e.tools[l];if(c.endedAt!=null)continue;const{name:u,subject:f}=n.describeCall(c);return{tone:"muted",long:f?`${u} · ${f}`:u,short:u}}return null}function _0(e){return e==="active"?"live":e==="done"?"done":"err"}const _f={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"}},gF=Object.fromEntries(Object.entries(_f).map(([e,t])=>[e,t.category])),yF=Object.fromEntries(Object.entries(_f).map(([e,t])=>[e,t.emoji])),wF=Object.fromEntries(Object.entries(_f).map(([e,t])=>[e,t.label])),vF=new Set(Object.entries(_f).filter(([,e])=>e.shell).map(([e])=>e)),JN={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",...gF};function mM(e){return e.startsWith("mcp__")?"mcp":Object.hasOwn(JN,e)?JN[e]:"other"}const xF=/\btools\.exec_command\s*\(\s*\{[^{}]*?\bcmd\s*:\s*(["'`])((?:\\.|(?!\1)[^\\])*)\1/,bF=/\btools\.([A-Za-z_$][\w$]*)\s*\(/;function kF(e){if(typeof e!="string"||!e)return null;const t=xF.exec(e);if(t){const r=NF(t[2]);if(r.trim())return r}const n=bF.exec(e);return n?n[1]:null}function NF(e){return e.replace(/\\(["'`\\nrt])/g,(t,n)=>n==="n"?`
61
+ `:n==="r"?"\r":n==="t"?" ":n)}const gM=600,SF=4,jF=36,E0=16,_F=60,EF=6,eS=220,CF=96,TF=28,tS={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:"📡",...yF};function nS(e){return e.startsWith("mcp__")?"🔌":Object.hasOwn(tS,e)?tS[e]:"✨"}const rS={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 yM(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+(?:-c|-Command|-NoProfile|-NonInteractive|\s)+["']([^"']+)["']/i);if(n)return yM(n[1]);for(;;){const l=t.match(/^([A-Z_][A-Z0-9_]*=\S*)\s+/);if(!l)break;t=t.slice(l[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 RF(e){if(typeof e=="string")return e;if(!e||typeof e!="object")return null;const t=e;if(typeof t.script=="string"){const n=kF(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(s=>/^(-Command|-c)$/i.test(s));if(r>=0&&r+1<n.length)return n[r+1]}return n.join(" ")}return typeof t.script=="string"?t.script:null}const AF=new Set(["Bash","PowerShell",...vF]);function MF(e,t){return Math.max(CF,61+[...t].length*6.8)}function IF(e,t){if(!AF.has(e))return null;const n=RF(t);if(!n)return null;const r=yM(n);return r?{emoji:Object.hasOwn(rS,r)?rS[r]:"⚙️",label:r,category:"shell",detail:n}:null}const $F=new Set(["Read","Write","Edit","MultiEdit","NotebookEdit","LS","Glob","apply_patch"]),sS={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:"🗄️"},aS={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 OF(e){const n=e.replace(/\\/g,"/").replace(/\/+$/,""),r=n.lastIndexOf("/");return r>=0?n.slice(r+1):n}function LF(e){const t=e.toLowerCase();if(Object.hasOwn(aS,t))return aS[t];if(t.startsWith("dockerfile."))return"🐳";if(/\.(test|spec)\.[a-z]+$/.test(t))return"🧪";const n=t.lastIndexOf(".");if(n>0&&n<t.length-1){const r=t.slice(n+1);if(Object.hasOwn(sS,r))return sS[r]}return"📄"}function PF(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 DF(e,t){if(!$F.has(e))return null;const n=PF(e,t);if(!n)return null;const r=OF(n);return r?{emoji:e==="LS"?"📂":LF(r),label:r,category:"file",detail:n}:null}const oS={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 Eb(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 FF(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 wM(e){const t=e.toLowerCase();return Object.hasOwn(oS,t)?oS[t]:void 0}function qF(e,t){const n=Eb(e);if(!n)return null;const{server:r,method:s}=n;if(!s)return null;const l=wM(r);return{emoji:(l==null?void 0:l.emoji)??"🔌",label:s,category:"mcp",detail:l?`${l.name} · ${s}`:`${r} · ${s}`}}function vM(e,t){return IF(e,t)??DF(e,t)??qF(e)}function BF(e,t){var n;return((n=vM(e,t))==null?void 0:n.label)??null}const iS=wF,lS=18;function ph(e){const t=[...e];return t.length<=lS?e:t.slice(0,lS-1).join("")+"…"}const bm=13,zF=6;function UF(e,t){const n=[...e];if(n.length<=bm)return e;const r=n.lastIndexOf("."),s=r>0?n.slice(r):[];return t==="file"&&s.length>1&&s.length<=zF?n.slice(0,bm-1-s.length).join("")+"…"+s.join(""):n.slice(0,bm-1).join("")+"…"}function Cb(e){const t=Eb(e);if(t){const r=wM(t.server);return r?{emoji:r.emoji,label:ph(r.name)}:{emoji:"🔌",label:ph(t.server),hue:FF(t.server)}}const n=Object.hasOwn(iS,e)?iS[e]:"";return n?{emoji:nS(e),label:ph(n)}:{emoji:nS(e),label:ph(e)}}function HF(e){let t=null,n="";for(const r of e){const s=Eb(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:Cb(n)}function WF(e){return e.endedAt==null?"inflight":e.ok===!1?"err":"done"}function VF(e,t){if(t==null)return 1;const n=e-t;return n<0?1:Math.max(0,1-n/gM)}function GF(e,t){const n=[],r=new Set;for(let s=e.length-1;s>=0&&n.length<t;s--){const l=e[s];r.has(l.id)||(r.add(l.id),n.push(l))}return n.reverse()}function KF(e,t,n,r,s,l){const c=[];for(const u of e.values()){if(!t.has(u.id)||u.exitAt!=null&&l-u.exitAt>gM)continue;const f=r.get(u.id)??n.get(u.id);if(!f)continue;const p=GF(u.tools,SF);if(p.length===0)continue;const h=u.exitAt??null,m=s.get(u.id),y=Math.max((m==null?void 0:m.width)??eS,eS),v=(m==null?void 0:m.height)??130,S=f.x,b=f.y,_=S+y,k=b+v/2;p.forEach((j,E)=>{const C=E*jF,R=S+y+_F,I=b+EF+C,O=VF(l,h),H=j.inputPreview??"",q=WF(j),$=O<.999,V=Cb(j.name);c.push({id:`${u.id}::${j.id}`,toolId:j.id,agentId:u.id,toolName:j.name,name:V.label,emoji:V.emoji,status:q,category:mM(j.name),mcpHue:V.hue,inputPreview:H,fade:O,fading:$,worldX:R,worldY:I,anchorX:_,anchorY:k,spawnDx:_-R,spawnDy:k-(I+E0)});const ne=vM(j.name,j.input);if(ne){const ee=MF(j.name,V.label),M=R+ee+TF,Z=I,K=R+ee,D=I+E0;c.push({id:`sub:${u.id}::${j.id}`,toolId:j.id,agentId:u.id,toolName:j.name,name:UF(ne.label,ne.category),fullName:ne.label,emoji:ne.emoji,isSub:!0,status:q,category:ne.category,inputPreview:ne.detail??H,fade:O,fading:$,worldX:M,worldY:Z,anchorX:K,anchorY:D,spawnDx:K-M,spawnDy:0})}})}return c}function YF({agents:e,visibleAgentIds:t,positions:n,pinned:r,measured:s,spotlight:l,hiddenCategories:c,now:u,onOpenTool:f}){const p=KF(e,t,n,r,s,u),h=c&&c.size>0?p.filter(m=>!c.has(m.category)):p;return o.jsx(XF,{bursts:h,spotlight:l,onOpenTool:f})}function XF({bursts:e,spotlight:t,onOpenTool:n}){const{x:r,y:s,zoom:l}=BA();return o.jsxs("div",{className:"tool-bursts-layer","aria-hidden":!0,children:[o.jsx("svg",{className:"tool-bursts-svg",children:e.map(c=>{const u=c.anchorX*l+r,f=c.anchorY*l+s,p=(c.worldX+6)*l+r,h=(c.worldY+E0)*l+s,m=Math.max(1,p-u),y=Math.min(1,Math.abs(h-f)/m),v=u+m*(.55-.22*y),S=t!=null&&!t.has(c.agentId),b=c.fade*(S?.14:1);return o.jsx("path",{d:`M ${u} ${f} Q ${v} ${f}, ${p} ${h}`,className:`tool-conn status-${c.status}${c.fading?" fading":""}`,opacity:b},`l:${c.id}`)})}),e.map(c=>o.jsx(QF,{b:c,x:r,y:s,zoom:l,dim:t!=null&&!t.has(c.agentId),onOpenTool:n},c.id))]})}function ZF(e,t){const n=e.b,r=t.b;return e.x===t.x&&e.y===t.y&&e.zoom===t.zoom&&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 QF=w.memo(function({b:t,x:n,y:r,zoom:s,dim:l,onOpenTool:c}){const u=t.worldX*s+n,f=t.worldY*s+r,p={left:`${u}px`,top:`${f}px`,transform:`scale(${s})`,transformOrigin:"left top","--spawn-dx":`${t.spawnDx}px`,"--spawn-dy":`${t.spawnDy}px`},h=t.isSub?`${t.toolName} · ${t.fullName??t.name}`:t.toolName,m=t.inputPreview?`${h} · ${t.inputPreview}`:h,y=c!=null,v=t.mcpHue!=null?{"--mcp-hue":t.mcpHue}:{},S=l?" dim":"";return o.jsx("div",{className:"tool-burst-wrap",style:p,children:o.jsxs("div",{className:`tool-burst cat-${t.category}${t.mcpHue!=null?" mcp-hue":""} status-${t.status}${t.fading?" fading":""}${y?" clickable":""}${t.isSub?" sub":""}${S}`,style:v,title:m,onClick:y?()=>c(t.toolId):void 0,children:[o.jsx("span",{className:"tb-emoji",children:t.emoji}),o.jsx("span",{className:"tb-name",children:t.name}),t.status==="inflight"&&o.jsx("span",{className:"tb-spin"}),t.status==="done"&&o.jsx("span",{className:"tb-mark done",children:"✓"}),t.status==="err"&&o.jsx("span",{className:"tb-mark err",children:"×"})]})})},ZF);function xM({kind:e}){return o.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"&&o.jsx("circle",{cx:"5",cy:"5",r:"3.2",fill:"currentColor"}),e==="done"&&o.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"&&o.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 Tb(){return o.jsxs("svg",{className:"alert-mark",viewBox:"0 0 12 12",width:"12",height:"12","aria-hidden":"true",focusable:"false",children:[o.jsx("path",{d:"M6 1.4l4.7 8.3H1.3z",stroke:"currentColor",strokeWidth:"1.3",strokeLinejoin:"round",fill:"none"}),o.jsx("path",{d:"M6 4.6v2.4",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round"}),o.jsx("circle",{cx:"6",cy:"8.35",r:"0.72",fill:"currentColor"})]})}function cS(e,t){const n=Jl(t);if(!n)return`model: ${t}
62
+ no published rate in this build — the tokens are counted, the dollars are not`;const r=h=>h.toLocaleString(),s=h=>`$${h}/MTok`,l=ri(e,t),c=JA(e,n),u=c.tokens1h>0?[`cache w5m${r(c.tokens5m).padStart(14)} × ${s(n.cacheWrite).padEnd(11)} = ${ut(c.usd5m)}`,`cache w1h${r(c.tokens1h).padStart(14)} × ${s(n.cacheWrite1h??n.cacheWrite).padEnd(11)} = ${ut(c.usd1h)}`]:[`cache w ${r(c.tokens5m).padStart(14)} × ${s(n.cacheWrite).padEnd(11)} = ${ut(c.usd5m)}`],f=eM(e,t),p=f===e.inputTokens?"input":"uncached";return[`model: ${t}`,`${p.padEnd(9)}${r(f).padStart(14)} × ${s(n.input).padEnd(11)} = ${ut(l.input)}`,`output ${r(e.outputTokens).padStart(14)} × ${s(n.output).padEnd(11)} = ${ut(l.output)}`,`cache r ${r(e.cacheReadTokens).padStart(14)} × ${s(n.cacheRead).padEnd(11)} = ${ut(l.cacheRead)}`,...u,"─────────────────────────────────────────",`total = ${ut(l.total)}`].join(`
63
+ `)}function uS(e){const t=zu(e);return t.length<=1?cS(e.usage,e.model):[...t.map(n=>cS(n.usage,n.model)),"═════════════════════════════════════════",`all models = ${ut(ir(e).total)}`].join(`
64
+ `)}function JF({data:e,selected:t}){var _,k;const n=["agent-node",`state-${e.state}`,e.synthetic?"synthetic":"",t?"selected":""].filter(Boolean).join(" "),r=e.tools.filter(j=>!j.endedAt).length,s=e.tools.filter(j=>j.ok===!1).length,l=Qh(e.sessionId),c=((_=e.context)==null?void 0:_.currentContextTokens)??0,u=e.kind==="root"&&c>0,f=e.sessionTitle?e.cwd?`${e.cwd}
65
+ ${e.sessionTitle}`:e.sessionTitle:e.cwd,p=rM(e),h=p.length>0?`${e.model}
66
+ spend on this card also covers:
67
+ ${p.join(`
68
+ `)}`:e.model,m=Sb(e.sessionName,e.sessionTitle),y=jf(e),v=y?hM(e.sessionId,y.at):null,S=dF(v),b=y!=null&&!S;return o.jsxs("div",{className:n,style:{"--session-hue":l},children:[o.jsx("span",{className:"accent-stripe"}),o.jsx(di,{type:"target",position:nt.Left,style:{background:"transparent",border:"none"}}),o.jsxs("div",{className:"head",children:[o.jsxs("div",{className:"title",children:[o.jsx(rq,{state:e.state}),o.jsx("span",{className:"label",title:f,children:e.label}),e.synthetic&&o.jsx("span",{className:"synth-tag",title:"No SessionStart captured — synthesised",children:"?"}),y&&v&&o.jsx("button",{type:"button",className:"glyph-btn recap-pin","aria-label":"Claude Code's recap","aria-expanded":b,title:b?"Hide the recap":"Show Claude Code's recap",onClick:j=>{j.stopPropagation(),uF(v)},children:o.jsx(Eu,{})})]}),o.jsxs("div",{className:"head-right",children:[u&&e.onOpenContext&&o.jsx(tF,{currentContextTokens:c,modelId:e.model,contextWindow:e.contextWindow,onClick:()=>e.onOpenContext(e.sessionId)}),o.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?"≥ ":"",o.jsx(nq,{start:e.startedAt,end:e.endedAt})]})]})]}),o.jsxs("div",{className:"sub",children:[e.kind==="root"?"session":"subagent",e.childCount>0&&o.jsxs("span",{className:"spawn-badge",title:`${e.childCount} subagents spawned`,children:["→ ",e.childCount]}),e.cwdBasename&&e.kind==="subagent"?` · ${e.cwdBasename}`:"",e.model?o.jsxs("span",{className:"model-chip","data-family":bf(e.model),title:h,children:[so(e.model),p.length>0?` +${p.length}`:""]}):e.provider==="codex"?o.jsx("span",{className:"model-chip",title:"OpenAI Codex — no model reported yet",children:"Codex"}):null]}),e.kind==="root"&&m.face&&o.jsx("div",{className:"session-name",title:m.tooltip,children:m.face}),e.waiting&&o.jsx(oq,{waiting:e.waiting}),(()=>{const j=j6(e);return j?o.jsxs("div",{className:"approval-blind-row",title:j.detail,children:[o.jsx("span",{className:"approval-blind-dot","aria-hidden":!0}),o.jsx("span",{className:"approval-blind-said",children:j.label})]}):null})(),(e.tools.length>0||(((k=e.outputs)==null?void 0:k.length)??0)>0)&&o.jsx(iq,{tools:e.tools,outputs:e.outputs}),o.jsxs("div",{className:"meta",children:[o.jsxs("span",{children:[o.jsx("b",{children:e.toolCount})," tools"]}),s>0&&o.jsxs("span",{className:"failed-meta",title:`${s} tool ${s===1?"call":"calls"} returned an error`,children:[o.jsx("b",{children:s})," err"]}),r>0&&o.jsxs("span",{className:"inflight-meta",children:[o.jsx("b",{children:r})," in-flight"]}),e.usage.inputTokens+e.usage.outputTokens>0&&o.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:[o.jsx("b",{children:Bt(e.usage.inputTokens+e.usage.outputTokens)})," tok"]}),e.model&&(()=>{const j=Jl(e.model),E=ir(e),C=_u(e);if(!j&&E.total<=0)return e.usage.inputTokens+e.usage.outputTokens<=0?null:o.jsx("span",{className:"cost-unpriced",title:uS(e),children:Cl});if(E.total<=0)return null;const R=Math.max(0,((e.endedAt??Date.now())-e.startedAt)/1e3),I=e.state==="active"&&!e.synthetic?Nb(E.total,R):null,O=uS(e)+(I?`
69
+ burn: ${I}`:"");return o.jsx("span",{className:"cost-meta",title:O,children:o.jsxs("b",{children:[ut(E.total),C>0?"+":""]})})})()]}),o.jsx(tq,{data:e,title:e.kind==="root"?m.face:void 0}),o.jsx(di,{type:"source",position:nt.Right,style:{background:"transparent",border:"none"}})]})}const eq=w.memo(JF);function tq({data:e,title:t}){const n=e.kind==="root"&&Fr(e.waiting),r=mF(e,e.branch,{sayWaiting:Rb,describeCall:s=>({name:Cb(s.name).label,subject:BF(s.name,s.input)})});return o.jsxs("div",{className:"lod-face","data-kind":e.kind,"data-alarm":n?"":void 0,"data-signal":r?"":void 0,"aria-hidden":!0,children:[o.jsxs("div",{className:"lod-id",children:[o.jsx(xM,{kind:_0(e.state)}),o.jsx("span",{className:"lod-name",children:e.label}),r&&o.jsx("span",{className:"lod-inline","data-tone":r.tone,children:r.short}),n&&o.jsx(Tb,{})]}),t&&o.jsx("div",{className:"lod-title",children:t}),r&&o.jsxs("div",{className:"lod-signal","data-tone":r.tone,children:[o.jsx("span",{className:"lod-long",children:r.long}),o.jsx("span",{className:"lod-short",children:r.short})]})]})}function nq({start:e,end:t}){const n=ec(1e3);return o.jsx(o.Fragment,{children:Ul(e,t,n)})}function Wl(e){return e==="active"?"live":e==="done"?"done":"err"}function rq({state:e}){return o.jsx("span",{className:`state-pill state-${e}`,children:Wl(e)})}function Vl(e){return e.message?e.message:e.kind==="permission"?"Needs your permission":"Waiting for your input"}function sq(e,t=Date.now(),n=!1){const r=e.tools.filter(l=>l.ok===!1).length,s=ir(e,t).total;return[e.label,e.kind==="root"?"session":"subagent",Wl(e.state),Fr(e.waiting)?Vl(e.waiting):null,e.model?so(e.model):null,`${e.toolCount} ${e.toolCount===1?"tool":"tools"}`,r>0?`${r} failed`:null,s>0?`${ut(s)}${_u(e,t)>0?"+":""}`:null,n?"selected":null].filter(Boolean).join(", ")}function aq(e,t){const n=sM(e,t);return n?`Likely on: ${n}`:null}function Rb(e){return e.kind==="idle"?"Your turn":Vl(e)}function oq({waiting:e}){const t=ec(1e3),n=Fr(e),r=Vl(e);return o.jsxs("div",{className:n?"waiting-row permission":"waiting-row idle",title:`${r}
70
+ Blocked for ${Ul(e.since,void 0,t)} — the answer goes in the terminal, not here.`,children:[n?o.jsx("span",{className:"ap-pulse","aria-hidden":!0}):o.jsx("span",{className:"waiting-dot","aria-hidden":!0}),o.jsx("span",{className:"waiting-said",children:Rb(e)}),o.jsx("b",{children:Ul(e.since,void 0,t)})]})}function Eu(){return o.jsxs("svg",{className:"recap-glyph",viewBox:"0 0 12 12",width:"10",height:"10","aria-hidden":"true",focusable:"false",children:[o.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"}),o.jsx("circle",{cx:"6",cy:"1.2",r:"1.05",fill:"currentColor"}),o.jsx("circle",{cx:"6",cy:"10.8",r:"1.05",fill:"currentColor"}),o.jsx("circle",{cx:"1.2",cy:"6",r:"1.05",fill:"currentColor"}),o.jsx("circle",{cx:"10.8",cy:"6",r:"1.05",fill:"currentColor"})]})}function iq({tools:e,outputs:t}){const n=ec(1e3),r=6e4,s=24,l=r/s,c=new Array(s).fill(0);let u=0;const f=E=>{const C=n-E;if(C<0||C>=r)return;const R=s-1-Math.floor(C/l);R>=0&&R<s&&(c[R]+=1,u+=1)};for(const E of e)f(E.startedAt);for(const E of t??[])f(E);const p=2,h=Math.max(0,...c),m=132,y=14,v=m/s,S=h/(l/1e3),b=e.filter(E=>n-E.startedAt>=0&&n-E.startedAt<r).length,_=u-b,k=[b>0?`${b} tool ${b===1?"call":"calls"}`:"",_>0?`${_} ${_===1?"block":"blocks"} of thinking and writing`:""].filter(Boolean),j=u===0?"nothing in the last 60s":`${k.join(" · ")} in last 60s · peak ${S.toFixed(1)}/s`;return o.jsxs("div",{className:"tool-spark-row",title:j,children:[o.jsx("svg",{className:"tool-spark",width:m,height:y,viewBox:`0 0 ${m} ${y}`,"aria-hidden":!0,children:c.map((E,C)=>{const R=E===0?1.5:Math.max(1.5,Math.min(1,E/p)*y),I=C===s-1&&E>0,H=`tool-spark-bar${E>0?" active":""}${I?" latest":""}`;return o.jsx("rect",{x:C*v+.4,y:y-R,width:Math.max(.5,v-1),height:R,rx:.8,className:H},I?`landed:${E}`:C)})}),o.jsx("span",{className:"tool-spark-label",children:"60s"})]})}function lq(e,t){return e?t==="gone"?"entering":t==="leaving"?"here":t:t==="gone"?"gone":"leaving"}function mh(e){return e!=="gone"}function gh(e,t){const[n,r]=w.useState(()=>e?"here":"gone"),s=w.useRef(null);return w.useEffect(()=>{r(l=>lq(e,l))},[e]),w.useEffect(()=>{if(n==="leaving")return s.current=window.setTimeout(()=>r("gone"),t),()=>{s.current!=null&&window.clearTimeout(s.current)}},[n,t]),w.useEffect(()=>{n==="entering"&&r("here")},[n]),n}async function hi(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}const cq=60,uq=6e3,Fs=e=>e!=null&&typeof e=="object"&&!Array.isArray(e),mr=e=>typeof e=="string"?e:null;function fi(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((l,c)=>[String(c),l]):Object.entries(e);if(r.length===0)return n?"[]":"{}";const s=[];for(const[l,c]of r){const u=n?`${t}-`:`${t}${l}:`;if(typeof c=="string"&&c.includes(`
71
+ `)){s.push(u);for(const f of c.split(`
72
+ `))s.push(`${t} ${f}`)}else if(c!==null&&typeof c=="object"){const f=fi(c,`${t} `);f==="[]"||f==="{}"?s.push(`${u} ${f}`):s.push(u,f)}else s.push(`${u} ${c===void 0?"(none)":String(c)}`)}return s.join(`
73
+ `)}function dq(e){return e.lines??e.text.split(`
74
+ `).map(t=>({text:t}))}function hq(e,t){if(t)return{shown:e,cut:!1};const n=[];let r=0;for(const s of e){if(n.length===cq)return{shown:n,cut:!0};const l=uq-r;if(s.text.length>l)return n.push({...s,text:`${s.text.slice(0,Math.max(l,0))}…`}),{shown:n,cut:!0};n.push(s),r+=s.text.length+1}return{shown:n,cut:!1}}const Wn=(e,t,n=!1)=>({...e?{label:e}:{},text:t,...n?{err:!0}:{}}),gr=(e,t)=>({label:e,text:t,inline:!0}),bM=(e,t)=>({label:e,text:t.map(n=>n.text).join(`
75
+ `),lines:t});function fq(e,t){return[...e.split(`
76
+ `).map(n=>({text:`- ${n}`,tone:"del"})),...t.split(`
77
+ `).map(n=>({text:`+ ${n}`,tone:"add"}))]}function pq(e){if(!Array.isArray(e)||e.length===0)return null;const t=[];for(const n of e){if(!Fs(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 dS(e){if(typeof e=="string")return[Wn(void 0,e)];if(!Fs(e))return[Wn(void 0,fi(e))];const t=[],n=mr(e.type);n==="create"&&t.push(gr("result","created the file"));const r=pq(e.structuredPatch);return r&&t.push(bM("applied",r)),e.userModified===!0&&t.push(gr("note","the user changed it before it was applied")),t.length?t:[gr("result",n==="update"?"updated the file":"done")]}function mq(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 gq(e){if(typeof e=="string")return[Wn(void 0,e)];const t=Fs(e)&&Fs(e.file)?e.file:null,n=mr(t==null?void 0:t.content);if(t&&n!=null){const s=[],l=Number(t.numLines),c=Number(t.totalLines),u=Number(t.startLine);return Number.isFinite(l)&&Number.isFinite(c)&&c>0&&s.push(gr("lines",l>=c?`all ${c}`:Number.isFinite(u)?`${u}–${u+l-1} of ${c}`:`${l} of ${c}`)),s.push(Wn("content",n)),s}const r=Fs(e)?mr(e.type):null;return r&&r!=="text"?[gr("result",`${/^[aeiou]/i.test(r)?"an":"a"} ${r} file`)]:[Wn(void 0,fi(e))]}function yq(e){if(typeof e=="string")return[Wn("output",e)];if(!Fs(e))return[Wn(void 0,fi(e))];const t=mr(e.stdout),n=mr(e.stderr);if(t==null&&n==null)return[Wn(void 0,fi(e))];const r=[];return t&&r.push(Wn("output",t.replace(/\n$/,""))),n&&r.push(Wn("errors",n.replace(/\n$/,""),!0)),e.interrupted===!0&&r.push(gr("note","interrupted before it finished")),r.length?r:[gr("output","none")]}function wq(e,t,n){const r=Fs(t)?t:null;if(r&&(e==="Edit"||e==="MultiEdit")){const s=mr(r.file_path),l=(e==="MultiEdit"?Array.isArray(r.edits)?r.edits:[]:[r]).filter(Fs).filter(c=>mr(c.old_string)!=null&&mr(c.new_string)!=null);if(s&&l.length){const c=[gr("file",s)];return l.forEach((u,f)=>{const p=u.replace_all===!0?", every occurrence":"";c.push(bM(l.length>1?`change ${f+1}${p}`:`change${p}`,fq(u.old_string,u.new_string)))}),{input:c,response:dS(n)}}}if(r&&e==="Write"){const s=mr(r.file_path),l=mr(r.content);if(s&&l!=null)return{input:[gr("file",s),Wn("content",l)],response:dS(n)}}if(r&&e==="Read"){const s=mr(r.file_path);if(s){const l=mq(r);return{input:l?[gr("file",s),gr("lines",l)]:[gr("file",s)],response:gq(n)}}}if(r&&e==="Bash"){const s=mr(r.command);if(s!=null){const l=mr(r.description);return{input:l?[Wn("command",s),gr("why",l)]:[Wn("command",s)],response:yq(n)}}}return{input:[Wn(void 0,fi(t))],response:[Wn(void 0,fi(n))]}}function hS(e,t,n){if(n==null)return"";if(typeof n=="string")return n;if(Fs(n)){if(e==="Bash"&&t==="input"&&typeof n.command=="string")return n.command;if(e==="Bash"&&t==="response"&&(typeof n.stdout=="string"||typeof n.stderr=="string"))return[n.stdout,n.stderr].filter(r=>typeof r=="string"&&r!=="").join(`
78
+ `);if(e==="Read"&&t==="response"&&Fs(n.file)&&typeof n.file.content=="string")return n.file.content}try{return JSON.stringify(n,null,2)??String(n)}catch{return String(n)}}function vq({tool:e,onClose:t}){const n=pn(t),r=e.endedAt==null?"inflight":e.ok===!1?"err":"done",s=e.input??e.inputPreview,l=e.response??e.errorPreview,c=wq(e.name,s,l);return o.jsx("div",{className:"modal-backdrop",onClick:t,role:"presentation",children:o.jsxs("div",{ref:n,className:"modal",onClick:u=>u.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"tool-modal-title",children:[o.jsxs("header",{className:"modal-head",children:[o.jsxs("div",{className:"modal-title",children:[o.jsx("span",{className:`status-dot ${r}`,"aria-hidden":!0}),o.jsx("span",{id:"tool-modal-title",className:"modal-tool-name",children:e.name}),o.jsxs("span",{className:"modal-tool-id",title:e.id,children:[e.id.slice(0,12),"…"]})]}),o.jsxs("div",{className:"modal-actions",children:[o.jsx("span",{className:"modal-dur",children:aM(e,"in-flight…")}),o.jsx("button",{className:"glyph-btn",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),o.jsxs("section",{className:"modal-body",children:[e.trimmed&&o.jsx("div",{className:"modal-section",children:o.jsx("p",{className:"modal-note",children:"Full payloads for this call were released to keep memory bounded — only the previews below are still held."})}),o.jsxs("div",{className:"modal-section",children:[o.jsxs("div",{className:"tm-head",children:[o.jsx("h4",{children:"Input"}),o.jsx(pS,{text:hS(e.name,"input",s),what:"input"})]}),c.input.map((u,f)=>o.jsx(fS,{block:u},f))]}),o.jsxs("div",{className:"modal-section",children:[o.jsxs("div",{className:"tm-head",children:[o.jsxs("h4",{children:["Response ",r==="err"&&o.jsx("span",{className:"err-tag",children:"error"})]}),e.endedAt!=null&&o.jsx(pS,{text:hS(e.name,"response",l),what:"response"})]}),e.endedAt==null?o.jsx("pre",{children:"(waiting…)"}):c.response.map((u,f)=>o.jsx(fS,{block:u},f))]})]})]})})}const xq={del:"tm-del",add:"tm-add",ctx:"tm-ctx"};function fS({block:e}){const[t,n]=w.useState(!1);if(e.inline)return o.jsxs("p",{className:"tm-inline",children:[e.label&&o.jsx("span",{className:"tm-label",children:e.label}),o.jsx("code",{children:e.text})]});const{shown:r,cut:s}=hq(dq(e),t);return o.jsxs("div",{className:"tm-block",children:[e.label&&o.jsx("span",{className:"tm-label",children:e.label}),o.jsx("pre",{className:e.err?"tm-err":void 0,children:e.lines?r.map((l,c)=>o.jsxs("span",{className:l.tone?xq[l.tone]:void 0,children:[l.text,c<r.length-1?`
79
+ `:""]},c)):r.map(l=>l.text).join(`
80
+ `)}),s&&o.jsx("button",{type:"button",className:"btn tm-more",onClick:()=>n(!0),children:"show all"})]})}function pS({text:e,what:t}){const[n,r]=w.useState(!1),s=w.useRef(!0);return w.useEffect(()=>()=>{s.current=!1},[]),o.jsx("button",{type:"button",className:"btn tm-copy",disabled:!e,"aria-label":n?`The ${t} was copied`:`Copy the ${t}`,onClick:()=>void hi(e).then(l=>{!l||!s.current||(r(!0),window.setTimeout(()=>{s.current&&r(!1)},1600))}),children:n?"copied":"copy"})}const yh=18,mS=26,bq=12,kq=240;function Nq(e,t){return(e+kq)*(t||1)}function Sq(e){return jq(e.nodeInternals.values())}function jq(e){const t=new Map;for(const s of e){if(s.type!=="agent"&&s.type!=="recapNote")continue;const l=s.data;if(!(l!=null&&l.sessionId)||l.exitAt!=null||s.width==null||s.height==null)continue;const c=s.position.x,u=s.position.y,f=c+s.width,p=u+s.height,h=t.get(l.sessionId);h?(h.minX=Math.min(h.minX,c),h.minY=Math.min(h.minY,u),h.maxX=Math.max(h.maxX,f),h.maxY=Math.max(h.maxY,p),l.kind==="root"&&(h.label=vS(l)??h.label),l.kind==="root"&&(h.name=xS(l)),l.kind==="root"&&(h.alarm=Fr(l.waiting)),l.kind==="root"&&(h.branch=wS(l))):t.set(l.sessionId,{minX:c,minY:u,maxX:f,maxY:p,label:vS(l)??l.sessionId,name:xS(l),alarm:l.kind==="root"&&Fr(l.waiting),branch:wS(l)})}const n=new Map;for(const s of t.values())n.set(s.label,(n.get(s.label)??0)+1);const r=[];for(const[s,l]of t){const c=(n.get(l.label)??0)>1;r.push({sessionId:s,...Cq(l.label,l.name,s,c),x:l.minX-yh,y:l.minY-yh-mS,w:l.maxX-l.minX+yh*2,h:l.maxY-l.minY+yh*2+mS,...l.alarm?{alarm:!0}:null,...l.branch?{branch:l.branch}:null})}return r}const Lh=" · ",_q=32,Eq=/[\u1100-\u115F\u2E80-\u303E\u3041-\u33FF\u3400-\u4DBF\u4E00-\u9FFF\uA000-\uA4CF\uAC00-\uD7A3\uF900-\uFAFF\uFE30-\uFE6F\uFF00-\uFF60\uFFE0-\uFFE6]/;function gS(e){return Eq.test(e)?2:1}function yS(e,t=_q){const n=[...e];let r=0;for(const c of n)r+=gS(c);if(r<=t)return e;const s=[];let l=0;for(const c of n){const u=gS(c);if(l+u>t-1)break;s.push(c),l+=u}for(;s.length&&/[\s\-_.:/]/.test(s[s.length-1]);)s.pop();return`${s.join("")}…`}function Cq(e,t,n,r){const s=(t==null?void 0:t.trim())??"",l=r?Tq(n):void 0,c=[e,s||void 0,l].filter(Boolean);return{label:yS(e),name:s?yS(s):void 0,shortId:l,fullLabel:c.join(Lh)}}function Tq(e){const t=e.match(/[a-zA-Z0-9]{4}/);return t?t[0]:e.slice(0,4)}function wS(e){if(e.kind!=="root")return;const t=e.branch;return t&&t.total>0?pM(t):void 0}function vS(e){if(e.kind==="root")return e.label}function xS(e){if(e.kind==="root")return Sb(e.sessionName,e.sessionTitle).face}function Rq({onFocusSession:e}){const{x:t,y:n,zoom:r}=BA(),s=Tt(Sq,Aq);if(s.length<=1)return null;const l=u=>{try{e==null||e(u)}catch{}},c={transform:`translate(${t}px, ${n}px) scale(${r})`};return o.jsx("div",{className:"session-clusters",style:c,children:s.map(u=>{const f=Qh(u.sessionId),p={position:"absolute",left:0,top:0,transform:`translate(${u.x}px, ${u.y}px)`,width:u.w,height:u.h,"--session-hue":f},h={position:"absolute",left:u.x+16,top:u.y-bq/(r||1),transform:`scale(${1/(r||1)})`,transformOrigin:"left top",maxWidth:Nq(u.w,r),"--session-hue":f};return o.jsxs(ve.Fragment,{children:[o.jsx("div",{className:"cluster-card",style:p,"aria-hidden":!0}),o.jsxs("button",{type:"button",className:"cluster-label","data-alarm":u.alarm?"":void 0,style:h,title:`${u.alarm?`Waiting on you
81
+ `:""}Zoom to ${u.fullLabel}
82
+ drag the wrapper to move the whole session`,onClick:()=>l(u.sessionId),children:[u.alarm?o.jsxs(o.Fragment,{children:[o.jsx(Tb,{}),o.jsx("span",{className:"cluster-label-said",children:"waiting on you: "})]}):null,u.label,u.branch?o.jsx("span",{className:"cluster-label-branch",children:Lh+u.branch}):null,u.name?o.jsx("span",{className:"cluster-label-name",children:Lh+u.name}):null,u.shortId?o.jsx("span",{className:"cluster-label-id",children:Lh+u.shortId}):null]})]},u.sessionId)})})}function Aq(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.x!==s.x||r.y!==s.y||r.w!==s.w||r.h!==s.h)return!1}return!0}function Mq({data:e}){return o.jsx("div",{className:"session-group-handle",style:{width:(e==null?void 0:e.w)??0,height:(e==null?void 0:e.h)??0}})}function kM(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 Ph(e){return kM(Math.floor(e/1e3))}function NM(e,t){const n=e-t;if(n<=0)return null;const r=Math.floor(n/86400),s=Math.floor(n%86400/3600),l=Math.floor(n%3600/60);return r>0?`${r}d ${s}h`:s>0?`${s}h ${l}m`:`${l}m`}function Iq(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function Jh(e,t,n){const r=new Date(e),s=Ph(t-e);return{label:Iq(r,new Date(t))?s:`${s} · ${r.toLocaleDateString(n,{month:"short",day:"numeric"})}`,title:r.toLocaleString(n,{dateStyle:"medium",timeStyle:"medium"})}}function $q({data:e}){const t=ec(3e4),n=Jh(e.recap.at,t);return o.jsxs("div",{className:"recap-note",role:"note","aria-label":"Claude Code's recap",style:{"--session-hue":e.hue},children:[o.jsxs("div",{className:"recap-note-head",children:[o.jsxs("span",{className:"recap-note-mark",children:[o.jsx(Eu,{}),"recap"]}),o.jsx("span",{className:"recap-note-age",title:n.title,children:n.label}),o.jsx("button",{type:"button",className:"glyph-btn recap-note-close","aria-label":"Hide the recap",title:"Hide — the ※ on the card brings it back",onClick:r=>{r.stopPropagation(),cF(e.noteKey)},children:"×"})]}),o.jsx("p",{className:"recap-note-text",children:e.recap.text}),o.jsxs("div",{className:"lod-face recap-face","aria-hidden":!0,children:[o.jsxs("div",{className:"lod-id",children:[o.jsxs("span",{className:"recap-note-mark",children:[o.jsx(Eu,{}),"recap"]}),o.jsx("span",{className:"recap-face-age",children:n.label})]}),o.jsx("p",{className:"recap-face-text",children:e.recap.text})]}),o.jsx(di,{type:"source",position:nt.Right,style:{background:"transparent",border:"none"}})]})}function Oq({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:s,targetPosition:l,style:c}){const[u]=mb({sourceX:e,sourceY:t,sourcePosition:s,targetX:n,targetY:r,targetPosition:l,curvature:.35});return o.jsxs("g",{className:"recap-tie",style:c,children:[o.jsx("path",{className:"recap-tie-thread",d:u}),o.jsx("path",{className:"recap-tie-beads",d:u}),o.jsx("circle",{className:"recap-tie-end",cx:e,cy:t,r:3.5}),o.jsx("circle",{className:"recap-tie-end",cx:n,cy:r,r:3.5})]})}function Lq(e){const t={input:0,output:0,cacheRead:0,cacheWrite:0,total:0};let n=0,r=0,s=0,l=0;for(const c of e){const u=ir(c);t.input+=u.input,t.output+=u.output,t.cacheRead+=u.cacheRead,t.cacheWrite+=u.cacheWrite,t.total+=u.total,n+=c.usage.inputTokens,r+=c.usage.outputTokens,s+=c.usage.cacheReadTokens,l+=c.usage.cacheCreateTokens}return{cost:t,inputTokens:n,outputTokens:r,cacheReadTokens:s,cacheCreateTokens:l,sum:n+r}}const Pq="spend on this board",Dq="on this board",bS=`Everything on the board right now, and only that.
83
+ 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.
84
+ Press H for the totals ccusage reads off the logs on disk, which do not forget.`,SM="session spend",C0="__unknown__",Fq=12;function qq(e,t=Date.now()){const n=new Map;for(const r of e)for(const s of zu(r)){const l=s.model??C0,c=ri(s.usage,s.model,t),u=n.get(l);u?(u.inputTokens+=s.usage.inputTokens,u.outputTokens+=s.usage.outputTokens,u.cacheReadTokens+=s.usage.cacheReadTokens,u.cacheCreateTokens+=s.usage.cacheCreateTokens,u.cost.total+=c.total,u.cost.input+=c.input,u.cost.output+=c.output,u.cost.cacheRead+=c.cacheRead,u.cost.cacheWrite+=c.cacheWrite,u.agentCount++):n.set(l,{model:l,inputTokens:s.usage.inputTokens,outputTokens:s.usage.outputTokens,cacheReadTokens:s.usage.cacheReadTokens,cacheCreateTokens:s.usage.cacheCreateTokens,cost:{...c},agentCount:1,priced:Jl(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 Bq(e,t=Date.now()){const n=[...e],r=[];for(const s of n){if(s.kind!=="root")continue;let l=ir(s,t).total,c=s.usage.inputTokens,u=s.usage.outputTokens,f=_u(s,t);for(const p of n)p.sessionId!==s.sessionId||p.kind==="root"||(l+=ir(p,t).total,c+=p.usage.inputTokens,u+=p.usage.outputTokens,f+=_u(p,t));r.push({sessionId:s.sessionId,label:s.label||s.cwdBasename||"session",state:s.state,cost:l,inputTokens:c,outputTokens:u,unpricedTokens:f})}return r.sort((s,l)=>l.cost-s.cost||l.inputTokens+l.outputTokens-(s.inputTokens+s.outputTokens)).slice(0,Fq)}function Ab({cost:e,size:t="md"}){const n=e.total;if(n<=0)return null;const r=(l,c,u)=>{if(l<=0)return null;const f=l/n*100;return o.jsx("span",{className:`cb-seg ${c}`,style:{width:`${f}%`},title:`${u}: ${ut(l)} (${f.toFixed(0)}%)`},c)},s=t==="lg";return o.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")]})}function zq({state:e,sessionId:t,onClose:n}){const r=w.useMemo(()=>Uq(e,t),[e,t]),s=w.useRef(null),l=pn(n,{focusRef:s});return r?o.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:o.jsxs("div",{ref:l,className:"modal session-summary",onClick:c=>c.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ss-title",children:[o.jsxs("div",{className:"modal-head",children:[o.jsxs("div",{className:"modal-title",children:[o.jsx("span",{className:"state-pill state-done","aria-hidden":!0,children:"done"}),o.jsx("span",{id:"ss-title",className:"modal-tool-name",title:r.cwd??r.sessionId,children:r.label}),o.jsxs("span",{className:"modal-tool-id",children:["· ",r.sessionId.slice(0,8)]})]}),o.jsxs("div",{className:"modal-actions",children:[o.jsx("span",{className:"modal-dur",title:"Total wall time",children:r.durationLabel}),o.jsx("button",{type:"button",ref:s,className:"glyph-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),o.jsxs("div",{className:"modal-body",children:[o.jsxs("section",{className:"ss-hero",children:[o.jsxs("div",{className:"ss-hero-left",children:[o.jsx("div",{className:"ss-cost-label",children:SM}),o.jsx("div",{className:"ss-cost",children:ut(r.cost.total)}),r.modelChips.length>0&&o.jsx("div",{className:"ss-models",children:r.modelChips.map(c=>o.jsx("span",{className:"model-chip","data-family":bf(c),title:c,children:so(c)},c))})]}),o.jsx("div",{className:"ss-hero-right",children:r.cost.total>0&&o.jsxs(o.Fragment,{children:[o.jsx(Ab,{cost:r.cost,size:"lg"}),o.jsxs("div",{className:"ss-cost-legend",children:[o.jsxs("span",{className:"ssl ssl-in",children:["input ",o.jsx("b",{children:ut(r.cost.input)})]}),o.jsxs("span",{className:"ssl ssl-out",children:["output ",o.jsx("b",{children:ut(r.cost.output)})]}),o.jsxs("span",{className:"ssl ssl-cr",children:["cache r ",o.jsx("b",{children:ut(r.cost.cacheRead)})]}),o.jsxs("span",{className:"ssl ssl-cw",children:["cache w ",o.jsx("b",{children:ut(r.cost.cacheWrite)})]})]})]})})]}),o.jsxs("section",{className:"ss-stats",children:[o.jsx(vl,{label:"agents",value:r.agentCount}),o.jsx(vl,{label:"subagents",value:r.subagentCount}),o.jsx(vl,{label:"tool calls",value:r.toolCount}),o.jsx(vl,{label:"prompts",value:r.promptCount}),o.jsx(vl,{label:"tokens",value:r.tokensSum.toLocaleString()}),r.errCount>0&&o.jsx(vl,{label:"errors",value:r.errCount,tone:"err"})]}),r.topTools.length>0&&o.jsxs("section",{className:"modal-section",children:[o.jsx("h4",{children:"Most-used tools"}),o.jsx("div",{className:"ss-top-tools",children:r.topTools.map(([c,u])=>o.jsxs("div",{className:"ss-tt",children:[o.jsx("span",{className:"ss-tt-name",children:c}),o.jsx("span",{className:"ss-tt-bar",children:o.jsx("span",{className:"ss-tt-bar-fill",style:{width:`${u/r.topTools[0][1]*100}%`}})}),o.jsx("span",{className:"ss-tt-count",children:u})]},c))})]}),r.firstPrompt&&o.jsxs("section",{className:"modal-section",children:[o.jsx("h4",{children:"Opening prompt"}),o.jsx("div",{className:"ss-prompt",children:r.firstPrompt})]})]})]})}):null}function vl({label:e,value:t,tone:n}){return o.jsxs("div",{className:`ss-stat${n?` tone-${n}`:""}`,children:[o.jsx("div",{className:"ss-stat-value",children:t}),o.jsx("div",{className:"ss-stat-label",children:e})]})}function Uq(e,t){const n=e.agents.get(t);if(!n)return null;const r=[];for(const E of e.agents.values())E.sessionId===t&&r.push(E);if(r.length===0)return null;const s={input:0,output:0,cacheRead:0,cacheWrite:0,total:0},l=new Set,c=new Map;let u=0,f=0,p=0,h=0,m=0,y,v=1/0,S=0;for(const E of r){const C=ir(E);s.input+=C.input,s.output+=C.output,s.cacheRead+=C.cacheRead,s.cacheWrite+=C.cacheWrite,s.total+=C.total;for(const I of nM(E))l.add(I);E.model&&l.add(E.model),E.kind==="subagent"&&m++;const R=VA(E.prompts);f+=R.length,!y&&R.length>0&&(y=R[0].text),p+=E.usage.inputTokens+E.usage.outputTokens,u+=E.toolCount,v=Math.min(v,E.startedAt),S=Math.max(S,E.endedAt??Date.now());for(const I of E.tools)c.set(I.name,(c.get(I.name)??0)+1),I.ok===!1&&h++}const b=Math.max(0,S-v),_=Math.floor(b/1e3),k=_<60?`${_}s`:_<3600?`${Math.floor(_/60)}m ${String(_%60).padStart(2,"0")}s`:`${Math.floor(_/3600)}h ${Math.floor(_%3600/60)}m`,j=Array.from(c.entries()).sort((E,C)=>C[1]-E[1]).slice(0,5);return{sessionId:t,label:n.label||n.cwdBasename||"session",cwd:n.cwd,durationLabel:k,cost:s,modelChips:Array.from(l),agentCount:r.length,subagentCount:m,toolCount:u,promptCount:f,tokensSum:p,errCount:h,topTools:j,firstPrompt:y}}function kS(e){return e.waiting?Fr(e.waiting)?0:1:e.state==="active"?2:3}function Hq(e,t){const n=[];for(const r of e.agents.values()){if(r.kind!=="root")continue;let s=r.toolCount,l=ir(r).total,c=r.endedAt??r.startedAt;for(const u of e.agents.values()){if(u.sessionId!==r.sessionId||u.kind==="root")continue;s+=u.toolCount,l+=ir(u).total;const f=u.endedAt??u.startedAt;f>c&&(c=f)}n.push({sessionId:r.sessionId,label:r.label||r.cwdBasename||"session",cwdBasename:r.cwdBasename,state:r.state,waiting:r.waiting,recap:jf(r),modelId:r.model,toolCount:s,cost:l,startedAt:r.startedAt,lastActivity:c})}return n.sort((r,s)=>{const l=kS(r),c=kS(s);return l!==c?l-c:r.waiting&&s.waiting?r.waiting.since-s.waiting.since:s.lastActivity-r.lastActivity}),n}function NS(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 l=Math.floor(s/60);return l<60?`${l}m`:`${Math.floor(l/60)}h ${l%60}m`}function Wq({state:e,now:t,selectedIds:n,onSelect:r,onClose:s,removedIds:l,onBringBackAll:c}){const u=w.useMemo(()=>Hq(e),[e,e.revision,t]),f=u.filter(h=>h.state==="active").length,p=u.filter(h=>Fr(h.waiting)).length;return o.jsxs("aside",{className:"session-list",id:"session-list","aria-label":"Sessions",children:[o.jsxs("div",{className:"sl-header",children:[o.jsxs("h2",{children:["Sessions ",o.jsx("span",{className:"sl-count",children:u.length})]}),p>0&&o.jsxs("span",{className:"sl-waiting-count",children:[p," waiting"]}),f>0&&o.jsxs("span",{className:"sl-live-count",children:[f," live"]}),o.jsx("button",{className:"glyph-btn sl-close",onClick:s,title:"Hide sidebar (L)","aria-label":"Hide session list",children:"‹"})]}),o.jsxs("ul",{className:"sl-rows",children:[u.length===0&&o.jsx("li",{className:"sl-empty",children:"No sessions yet."}),u.map(h=>{const m=n.has(h.sessionId),y=(l==null?void 0:l.has(h.sessionId))??!1;return o.jsx("li",{className:"sl-row-item",children:o.jsxs("button",{type:"button",className:`sl-row state-${h.state}${m?" selected":""}${y?" removed":""}`,"aria-current":m?"true":void 0,onClick:()=>r(h.sessionId),title:y?`Bring ${h.label} back to the board`:`Focus ${h.label}`,children:[o.jsx("span",{className:`sl-dot state-${h.state}`,"aria-hidden":!0}),o.jsx("span",{className:"vis-hidden",children:Wl(h.state)}),o.jsxs("div",{className:"sl-row-body",children:[o.jsxs("div",{className:"sl-row-head",children:[o.jsx("span",{className:"sl-label",children:h.label}),y&&o.jsx("span",{className:"sl-removed",children:"off the board"}),h.modelId&&o.jsx("span",{className:"model-chip","data-family":bf(h.modelId),title:h.modelId,children:so(h.modelId)})]}),o.jsxs("div",{className:"sl-row-meta",children:[o.jsxs("span",{title:"tool calls",children:[o.jsx("b",{children:h.toolCount})," tools"]}),h.cost>0&&o.jsx("span",{className:"sl-cost",title:SM,children:o.jsx("b",{children:ut(h.cost)})}),h.waiting?o.jsxs("span",{className:"sl-waiting",title:[Vl(h.waiting),aq(h.waiting,Vl(h.waiting)),`Blocked since ${new Date(h.waiting.since).toLocaleTimeString()} · started ${new Date(h.startedAt).toLocaleString()}`].filter(Boolean).join(`
85
+ `),children:["waiting ",NS(h.waiting.since,void 0,t),h.waiting.tool&&o.jsxs("span",{className:"sl-waiting-tool",children:[" · ",h.waiting.tool.name]})]}):o.jsx("span",{className:"sl-elapsed",title:`Started ${new Date(h.startedAt).toLocaleString()}`,children:NS(h.startedAt,h.state==="active"?void 0:h.lastActivity,t)})]}),h.recap&&o.jsxs("span",{className:"sl-recap",title:h.recap.text,children:[o.jsx(Eu,{}),h.recap.text]})]})]})},h.sessionId)})]}),(()=>{const h=(l==null?void 0:l.size)??0;return h===0||!c?null:o.jsx("div",{className:"sl-foot",children:o.jsxs("button",{type:"button",className:"btn sl-bring-back",onClick:m=>{const y=m.currentTarget.closest(".session-list");c(),requestAnimationFrame(()=>{var v;return(v=y==null?void 0:y.querySelector(".sl-row"))==null?void 0:v.focus()})},children:["Bring back ",h," removed ",h===1?"card":"cards"]})})})()]})}const Vq=e=>1-Math.pow(1-e,5),jM=420;function Gq(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 Kq(e,t,n,r=jM){return n>=r?t:n<=0?e:e+(t-e)*Vq(n/r)}function Yq(e,t,n,r={}){const s=r.now??(()=>performance.now()),l=r.raf??(v=>requestAnimationFrame(v)),c=r.cancel??(v=>cancelAnimationFrame(v)),u=r.reducedMotion??(()=>typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches),f=r.hidden??(()=>typeof document=="object"&&document.hidden===!0);if(u()||f()||!Gq(e,t))return n(t),()=>{};const p=s();let h=0,m=!0;const y=()=>{if(!m)return;const v=s()-p;n(Kq(e,t,v)),v<jM&&(h=l(y))};return h=l(y),()=>{m=!1,h&&c(h)}}const T0={cost:0,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0,sessions:0};function Xq(e){if(!e.synthetic)return!1;const t=e.usage;return t.inputTokens+t.outputTokens+t.cacheReadTokens+t.cacheCreateTokens<=0}function km(e,t){const n=new Map;for(const r of e){if(r.kind!=="root"||!r.sessionId||Xq(r))continue;const s=ir(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 Zq(e,t){if(!e)return T0;const n={...T0};for(const[r,s]of t){const l=e.get(r);if(!l)continue;const c={cost:s.cost-l.cost,inputTokens:s.inputTokens-l.inputTokens,outputTokens:s.outputTokens-l.outputTokens,cacheReadTokens:s.cacheReadTokens-l.cacheReadTokens,cacheCreateTokens:s.cacheCreateTokens-l.cacheCreateTokens};c.cost<0||c.inputTokens<0||c.outputTokens<0||c.cost===0&&c.inputTokens===0&&c.outputTokens===0&&c.cacheReadTokens===0&&c.cacheCreateTokens===0||(n.cost+=c.cost,n.inputTokens+=Math.max(0,c.inputTokens),n.outputTokens+=Math.max(0,c.outputTokens),n.cacheReadTokens+=Math.max(0,c.cacheReadTokens),n.cacheCreateTokens+=Math.max(0,c.cacheCreateTokens),n.sessions+=1)}return n}function _M(e,t,n){const r=Jq*Math.max(1,n/CM);let s=0;for(const[l,c]of t){const u=e.get(l);if(u===void 0)continue;const f=c.cost-u.cost;f>0&&f<=r&&(s+=f)}return s}const SS={samples:[],last:new Map,watched:0},EM=10*6e4,Qq=6e4,CM=5e3,Jq=20;function e8(e,t,n){const r=e.samples[e.samples.length-1];if(r&&t-r.t<CM)return e;const s=e.watched+_M(e.last,n,r?t-r.t:0),l=e.samples.filter(c=>t-c.t<=EM);return l.push({t,watched:s}),{samples:l,last:n,watched:s}}function t8(e,t,n){const r=e.samples[0];if(!r)return null;const s=t-r.t;if(s<Qq)return null;const l=e.samples[e.samples.length-1].t,c=e.watched+_M(e.last,n,t-l)-r.watched;return c>0?{spent:c,spanSec:s/1e3,spanMin:Math.min(EM/6e4,Math.ceil(s/6e4))}:null}function jS(e,t=new Date){return new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate()-(e-1))).toISOString().slice(0,10).replace(/-/g,"")}const Ef=[{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 n8(e,t,n=Ef.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 TM(e,t=new Date){return e==="today"?jS(1,t):e==="month"?jS(t.getDate(),t):"20200101"}const sr=e=>typeof e=="number"&&Number.isFinite(e)?e:0,Dh=e=>typeof e=="string"?e:"";function RM(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 l of s){const c=Dh(l==null?void 0:l.modelName);if(!c)continue;let u=n.get(c);u||(u={model:c,cost:0,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0,get tokens(){return this.inputTokens+this.outputTokens+this.cacheReadTokens+this.cacheCreateTokens}},n.set(c,u)),u.cost+=sr(l==null?void 0:l.cost),u.inputTokens+=sr(l==null?void 0:l.inputTokens),u.outputTokens+=sr(l==null?void 0:l.outputTokens),u.cacheReadTokens+=sr(l==null?void 0:l.cacheReadTokens),u.cacheCreateTokens+=sr(l==null?void 0:l.cacheCreationTokens)}}return[...n.values()].sort((r,s)=>s.cost-r.cost||s.tokens-r.tokens)}const r8=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function s8(e){var t;return((t=r8.exec(e))==null?void 0:t[0])??e}function a8(e,t=new Map){const n=Array.isArray(e==null?void 0:e.sessions)?e.sessions:[],r=[];for(const s of n){const l=Dh(s==null?void 0:s.period);if(!l)continue;const c=s8(l),u=s==null?void 0:s.metadata,f=typeof(u==null?void 0:u.lastActivity)=="string"?Date.parse(u.lastActivity):NaN;r.push({sessionId:c,label:t.get(c)??null,agent:Dh(s==null?void 0:s.agent)||"claude",cost:sr(s==null?void 0:s.totalCost),tokens:sr(s==null?void 0:s.totalTokens),models:Array.isArray(s==null?void 0:s.modelsUsed)?s.modelsUsed.map(Dh).filter(Boolean):[],lastActivityMs:Number.isFinite(f)?f:null})}return r.sort((s,l)=>l.cost-s.cost||l.tokens-s.tokens)}function o8(e,t=Cf(e).cost){const r=(Array.isArray(e==null?void 0:e.sessions)?e.sessions:[]).reduce((l,c)=>l+sr(c==null?void 0:c.totalCost),0),s=Math.max(.01,t*.01);return{sum:r,total:t,over:r>t+s}}function i8(e,t,n){const r=`Sessions with activity ${e}, and what ccusage puts against each one.`;return t.over?`${r}
86
+ 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 Cf(e){const t=e==null?void 0:e.totals;if(t&&typeof t=="object"){const f=sr(t.cacheReadTokens),p=sr(t.cacheCreationTokens),h=sr(t.inputTokens),m=sr(t.outputTokens);return{cost:sr(t.totalCost),inputTokens:h,outputTokens:m,cacheReadTokens:f,cacheCreateTokens:p,tokens:sr(t.totalTokens)||h+m+f+p}}const n=RM(e),r=f=>n.reduce((p,h)=>p+f(h),0),s=r(f=>f.inputTokens),l=r(f=>f.outputTokens),c=r(f=>f.cacheReadTokens),u=r(f=>f.cacheCreateTokens);return{cost:r(f=>f.cost),inputTokens:s,outputTokens:l,cacheReadTokens:c,cacheCreateTokens:u,tokens:s+l+c+u}}function l8(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 _S(e,t){var n;return((n=Ef.find(r=>r.key===(e??t)))==null?void 0:n.noun)??"today"}function c8(e,t,n){const r=e!=null,s=Cf(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 dn="ccdeck";function ao(e,t){return{disabled:e!=null&&e!==t,busy:e===t}}function Tf(e){return e==null}const R0="self";function Qa(e,t=!1){const n=ao(e?R0:null,R0);return{disabled:t||n.disabled,"aria-busy":n.busy}}function Ps(e){return Tf(e?R0:null)}function Cu({armedFor:e,target:t,armedAt:n,now:r,gapMs:s}){return e!==t?"arm":r-n<s?"ignore":"fire"}function u8(e){return[...e==null?[]:[`#ap-more-${e}`],".accounts-panel .ap-refresh"]}function A0(e){return e==null||e==="BODY"||e==="HTML"}const AM="agent-dag.usagePeriod";function d8(){const e=yr(AM);return Ef.some(t=>t.key===e)?e:"today"}function h8(e){if(!(typeof window>"u"))try{window.localStorage.setItem(AM,e)}catch{}}const MM="agent-dag.usageSessionsOpen";function f8(){return yr(MM)==="1"}function p8(e){if(!(typeof window>"u"))try{window.localStorage.setItem(MM,e?"1":"0")}catch{}}function ES(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 m8(e){return e==="claude-swap"?"Read from claude-swap's last collection — costs no request against your usage-endpoint budget":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 g8(e,t,n,r){const s=Math.max(0,t-r),l=Math.max(0,n-s);if(l<120)return null;const c=Math.min(100,l/n*100),u=e-c;if(Math.abs(u)<3)return{label:"on pace",color:"var(--ok)",expectedPct:c,isDeficit:!1};if(u>0){const f=100-e,p=l>0?e/l:0,h=p>0?f/p:1/0,m={label:`${Math.round(u)}% over pace`,color:"var(--warn)",expectedPct:c,isDeficit:!0};if(h<s&&h<86400){const y=Math.floor(h/3600),v=Math.floor(h%3600/60);m.runsOutIn=y>0?`${y}h ${v}m`:`${v}m`}return m}return{label:`${Math.round(-u)}% under pace`,color:"var(--ok)",expectedPct:c,isDeficit:!1}}function Va({pct:e,label:t,reset:n,resetAt:r,windowSec:s,limitReached:l,nowSec:c}){const u=Math.min(100,Math.max(0,e)),p=l||u>=90?"var(--err)":u>=70?"var(--warn)":"var(--accent)",h=u===0?"< 1%":`${u}%`,m=u===0?2:u,y=r?NM(r,c):null,v=r&&s?g8(u,r,s,c):null,[S,b]=w.useState(!1),_=w.useId();return o.jsxs("div",{className:"qb-row",children:[o.jsxs("div",{className:"qb-meta",children:[o.jsxs("span",{className:"qb-label",children:[t,l&&o.jsx("span",{className:"qb-limit-badge",title:"Rate limit reached",children:"⛔"})]}),o.jsx("span",{className:"qb-pct",style:{color:p},children:h})]}),o.jsxs("div",{className:"qb-track",children:[o.jsx("div",{className:"qb-fill",style:{transform:`scaleX(${m/100})`,background:p,opacity:u===0?.4:1}}),v&&o.jsx("div",{className:"qb-pace-rail",style:{transform:`translateX(${v.expectedPct}%)`},children:o.jsx("div",{"aria-hidden":!0,className:"qb-pace-marker",style:{background:v.isDeficit?"var(--err)":"var(--ok)"},title:`To last until reset, stay near ${Math.round(v.expectedPct)}% by now`})})]}),o.jsxs("div",{className:"qb-reset-row",children:[y?o.jsxs("span",{className:"qb-reset",children:["resets in ",y]}):n?o.jsxs("span",{className:"qb-reset",children:["resets ",n]}):null,v&&o.jsxs("button",{type:"button",className:"qb-pace",style:{color:v.color},"aria-expanded":S,"aria-controls":S?_:void 0,onClick:()=>b(k=>!k),children:[o.jsx("i",{className:"qb-pace-key","aria-hidden":!0,style:{background:v.isDeficit?"var(--err)":"var(--ok)"}}),v.runsOutIn?`runs out in ${v.runsOutIn}`:v.label]})]}),S&&v&&o.jsxs("div",{id:_,className:"qb-why",children:["To last until reset, stay near ",Math.round(v.expectedPct),"% by now."]})]})}const y8=6e4,w8=2e4;function v8(e){const[t,n]=w.useState(null),[r,s]=w.useState(!1),l=w.useRef(null),c=w.useRef(!1),u=async(p=!1)=>{if(!(p&&!Ps(c.current))){p&&(c.current=!0,s(!0));try{const m=await fetch(p?"/api/quota?refresh=1":"/api/quota",{signal:AbortSignal.timeout(w8)});m.ok&&n(await m.json())}catch{}finally{p&&(c.current=!1,s(!1))}}};return w.useEffect(()=>{if(e)return u(!0),l.current=window.setInterval(()=>u(!1),y8),()=>{l.current!=null&&window.clearInterval(l.current)}},[e]),{quota:t,loading:r,refresh:()=>{e&&u(!0)}}}function x8(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 b8(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.";default:return"ChatGPT API unreachable — click ↻ to retry."}}const IM=6e4,CS=6e4;function k8(e){const[t,n]=w.useState(null),[r,s]=w.useState(!1),l=w.useRef(null),c=w.useRef(!1),u=async(p=!1)=>{if(!(p&&!Ps(c.current))){p&&(c.current=!0,s(!0));try{const m=await fetch(p?"/api/codex-quota?refresh=1":"/api/codex-quota");m.ok&&n(await m.json())}catch{}finally{p&&(c.current=!1,s(!1))}}};return w.useEffect(()=>{if(e)return u(!0),l.current=window.setInterval(()=>u(!1),IM),()=>{l.current!=null&&window.clearInterval(l.current)}},[e]),{data:t,loading:r,refresh:()=>{e&&u(!0)}}}function N8(e){const[t,n]=w.useState(null),r=w.useRef(null),s=async()=>{try{const l=await fetch("/api/codex-usage");l.ok&&n(await l.json())}catch{}};return w.useEffect(()=>{if(e)return s(),r.current=window.setInterval(s,IM),()=>{r.current!=null&&window.clearInterval(r.current)}},[e]),{data:t}}function S8(e,t,n){const[r,s]=w.useState(null),[l,c]=w.useState(!1),[u,f]=w.useState(0),p=w.useRef(0);w.useEffect(()=>{const m=()=>document.visibilityState==="visible",y=()=>{m()&&f(b=>b+1)},v=window.setInterval(y,CS),S=()=>{m()&&Date.now()-p.current>=CS&&f(b=>b+1)};return document.addEventListener("visibilitychange",S),()=>{window.clearInterval(v),document.removeEventListener("visibilitychange",S)}},[]);const h=w.useRef(t);return w.useEffect(()=>{let m=!0;const y=t!==h.current;h.current=t;const v=e,S=TM(v);return c(!0),fetch(`/api/ccusage?since=${S}${y?"&refresh=1":""}`).then(b=>b.ok?b.json():null).then(b=>{!m||!(b!=null&&b.ok)||(p.current=Date.now(),s({period:v,data:b,baseline:n()}))}).catch(()=>{}).finally(()=>{m&&c(!1)}),()=>{m=!1}},[e,t,u]),{...l8(r,e),loading:l}}function nu(e){const[t,n]=w.useState(e),r=w.useRef(e),s=w.useRef(!0);return w.useEffect(()=>{r.current=t},[t]),w.useEffect(()=>{if(s.current){s.current=!1,r.current=e,n(e);return}return Yq(r.current,e,c=>{r.current=c,n(c)})},[e]),t}function j8({state:e,now:t,providers:n,leaving:r,onClose:s,liveSince:l=null}){var Ye,qe;const{quota:c,loading:u,refresh:f}=v8(n.claude),{data:p,loading:h,refresh:m}=k8(n.codex),{data:y}=N8(n.codex),[v,S]=w.useState(()=>Math.floor(Date.now()/1e3));w.useEffect(()=>{const ke=window.setInterval(()=>S(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(ke)},[]);const b=w.useRef(SS),_=w.useRef(null),{byModel:k,totalCost:j,totalTokens:E,burnRate:C}=w.useMemo(()=>{const ke=qq(e.agents.values()),Re=Lq(e.agents.values());_.current!==l&&(_.current=l,b.current=SS);const ze=km(e.agents.values(),t);l!=null&&(b.current=e8(b.current,t,ze));const Fe=l==null?null:t8(b.current,t,ze),We=Fe?{label:Nb(Fe.spent,Fe.spanSec),spanMin:Fe.spanMin}:null;return{byModel:ke,totalCost:Re.cost,totalTokens:Re,burnRate:We}},[e,e.revision,t,l]),R=w.useMemo(()=>Bq(e.agents.values()),[e,e.revision]),[I,O]=w.useState(d8);w.useEffect(()=>{h8(I)},[I]);const[H,q]=w.useState(f8);w.useEffect(()=>{p8(H)},[H]);const $=w.useRef([]),[V,ne]=w.useState(0),ee=w.useRef(()=>new Map);ee.current=()=>km(e.agents.values(),t);const M=w.useCallback(()=>ee.current(),[]),{data:Z,shown:K,stale:D,loading:P,baseline:B}=S8(I,V,M),W=Z!=null,F=P&&D,G=w.useMemo(()=>{const ke=new Map;for(const Re of e.agents.values()){if(Re.kind!=="root"||!Re.sessionId)continue;const ze=Re.label||Re.cwdBasename;ze&&ke.set(Re.sessionId,ze)}return ke},[e,e.revision]),re=w.useMemo(()=>{const ke=new Map;for(const Re of e.agents.values())Re.kind!=="root"||!Re.sessionId||ke.set(Re.sessionId,Re.state);return ke},[e,e.revision]),U=w.useMemo(()=>W?RM(Z):[],[Z,W]),Y=w.useMemo(()=>{if(!W)return[];const ke=a8(Z,G).slice(0,12),Re=new Map;for(const ze of ke)ze.label&&Re.set(ze.label,(Re.get(ze.label)??0)+1);return ke.map(ze=>ze.label&&(Re.get(ze.label)??0)>1?{...ze,label:`${ze.label} ${ze.sessionId.slice(0,4)}`}:ze)},[Z,W,G]),z=w.useMemo(()=>Cf(Z),[Z]),ie=w.useMemo(()=>o8(Z,z.cost),[Z,z.cost]),le=_S(K,I),ge=D?" up-stale":"",Ne=w.useMemo(()=>W?Zq(B,km(e.agents.values(),t)):T0,[e,e.revision,B,W,t]),Ie=c8(Z,{...E,cost:j},Ne),Ge=Ie.hasCost,Pe=Ie.tokenSum,Be=nu(Ie.cost),Te=nu(Ie.inputTokens),st=nu(Ie.outputTokens),de=nu(Ie.cacheReadTokens),ue=nu(Ie.cacheCreateTokens),se=k.filter(ke=>ke.cost.total>0||ke.inputTokens+ke.outputTokens>0),be=R.filter(ke=>ke.cost>0||ke.inputTokens+ke.outputTokens>0),Le=W?U.some(ke=>ke.cost<=0&&ke.tokens>0):se.some(ke=>!ke.priced),ce=u||h,pe=ES(c==null?void 0:c.fetchedAt,v),Ae=ES(p==null?void 0:p.fetchedAt,v),fe=()=>{f(),m(),ne(ke=>ke+1)},Se=n.claude&&n.codex?"Refresh Claude + Codex quota":n.codex?"Refresh Codex quota":"Refresh Claude quota";return o.jsxs("aside",{className:`usage-panel${r?" leaving":""}`,id:"usage-panel","aria-label":"Usage",children:[o.jsxs("div",{className:"up-header",children:[o.jsx("h2",{children:"Usage"}),C&&o.jsxs("span",{className:"up-rate",title:`Spend on this board over the last ${C.spanMin} min`,children:[C.label,o.jsxs("span",{className:"up-rate-span",children:[" · ",C.spanMin," min"]})]}),o.jsxs("div",{className:"up-header-right",children:[(n.claude||n.codex)&&o.jsx("button",{type:"button",className:"glyph-btn up-refresh-btn",onClick:fe,...Qa(ce),"aria-label":Se,title:Se,children:ce?"…":"↻"}),o.jsx("button",{type:"button",className:"glyph-btn up-close",onClick:s,"aria-label":"Close usage panel",title:"Close (U)",children:"×"})]})]}),n.claude&&o.jsxs("section",{className:"up-section up-quota-section",children:[o.jsxs("h3",{className:"up-section-title",children:["Claude quota",pe&&!u&&o.jsx("span",{className:"up-section-age",title:m8(c==null?void 0:c.source),children:pe})]}),c!=null&&c.ok?o.jsxs("div",{className:"up-quota-bars",children:[c.session5hPct!=null&&o.jsx(Va,{label:"5-hour window",pct:c.session5hPct,reset:c.session5hReset,resetAt:c.session5hResetAt,windowSec:c.session5hWindowSec,nowSec:v}),c.week7dPct!=null&&o.jsx(Va,{label:"7-day window",pct:c.week7dPct,reset:c.week7dReset,resetAt:c.week7dResetAt,windowSec:c.week7dWindowSec,nowSec:v}),c.weekSonnetPct!=null&&o.jsx(Va,{label:"Sonnet (7d)",pct:c.weekSonnetPct,nowSec:v}),c.weekOpusPct!=null&&o.jsx(Va,{label:"Opus (7d)",pct:c.weekOpusPct,nowSec:v}),c.extraEnabled&&c.extraUsedCredits!=null&&c.extraMonthlyLimit?o.jsx(Va,{label:`Extra credits (month${c.extraCurrency?`, ${c.extraCurrency}`:""})`,pct:Math.min(100,Math.round(c.extraUsedCredits/c.extraMonthlyLimit*100)),nowSec:v}):c.extraEnabled&&o.jsx("div",{className:"up-quota-sub up-credits",children:"extra usage credits: on"})]}):(c==null?void 0:c.ok)===!1?o.jsxs("div",{className:"up-quota-na",children:[o.jsx("span",{children:c.reason==="no_subscription"?"No quota to show.":"Quota unavailable."}),o.jsx("span",{className:"up-quota-hint",children:x8(c.reason)})]}):o.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]}),n.codex&&o.jsxs("section",{className:"up-section up-quota-section",children:[o.jsxs("h3",{className:"up-section-title",children:["Codex quota",(p==null?void 0:p.ok)&&p.planLabel&&o.jsx("span",{className:"up-plan-badge",children:p.planLabel}),Ae&&!h&&o.jsx("span",{className:"up-section-age",title:"Fetched from the Codex usage endpoint",children:Ae})]}),p!=null&&p.ok?o.jsxs("div",{className:"up-quota-bars",children:[(Ye=p.windows)==null?void 0:Ye.map(ke=>o.jsx(Va,{label:ke.label,pct:ke.pct,reset:ke.reset??void 0,resetAt:ke.resetAt??void 0,windowSec:ke.windowSec??void 0,limitReached:p.limitReached&&ke.pct>=100,nowSec:v},ke.id)),(qe=p.extraWindows)==null?void 0:qe.map(ke=>o.jsx(Va,{label:ke.label,pct:ke.pct,reset:ke.reset??void 0,resetAt:ke.resetAt??void 0,windowSec:ke.windowSec??void 0,nowSec:v},ke.id)),p.creditLimit&&o.jsx(Va,{label:`spend cap · $${Math.round(p.creditLimit.used)} of $${Math.round(p.creditLimit.limit)}`,pct:p.creditLimit.usedPct,reset:p.creditLimit.reset??void 0,resetAt:p.creditLimit.resetAt??void 0,limitReached:p.spendControlReached,nowSec:v}),p.creditsBalance&&!p.creditsUnlimited&&o.jsxs("div",{className:"up-quota-sub up-credits",children:["credits: $",p.creditsBalance,p.overageReached&&" · overage limit reached"]}),p.creditsUnlimited&&o.jsx("div",{className:"up-quota-sub up-credits",children:"credits: unlimited"}),p.resetCredits&&p.resetCredits.availableCount>0&&o.jsxs("div",{className:"up-quota-sub up-reset-credits",title:`Redeem in the Codex CLI or ChatGPT — ${dn} only reports them`,children:[p.resetCredits.availableCount," rate-limit reset",p.resetCredits.availableCount!==1?"s":""," available",p.resetCredits.nextExpiryAt&&` · expires ${new Date(p.resetCredits.nextExpiryAt).toLocaleDateString("en-US",{month:"short",day:"numeric"})}`]}),p.promo&&o.jsx("div",{className:"up-quota-sub",children:p.promo}),p.partial&&o.jsx("div",{className:"up-quota-sub up-quota-hint",children:"Partial data — OpenAI returned limits this build doesn't recognise."})]}):(p==null?void 0:p.ok)===!1?o.jsxs("div",{className:"up-quota-na",children:[o.jsx("span",{children:"Quota unavailable."}),o.jsx("span",{className:"up-quota-hint",children:b8(p.reason)})]}):o.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"}),(y==null?void 0:y.ok)&&y.window7d&&y.window7d.sessionCount>0&&o.jsxs("div",{className:"up-quota-sub",title:`Counted from the rollout files under CODEX_HOME — no network, no account${y.window5h?`
87
+ last 5h: ${Bt(y.window5h.totalTokens)} tokens · ${y.window5h.sessionCount} session${y.window5h.sessionCount!==1?"s":""}`:""}`,children:[Bt(y.window7d.totalTokens)," tokens · ",y.window7d.sessionCount," session",y.window7d.sessionCount!==1?"s":""," (7d)"]})]}),W&&o.jsx("div",{className:"uh-range up-period",role:"toolbar","aria-orientation":"horizontal","aria-label":"Period","aria-busy":F||void 0,onKeyDown:ke=>{var Fe;const Re=$.current.indexOf(ke.target);if(Re<0)return;const ze=n8(ke.key,Re);ze!==null&&(ke.preventDefault(),(Fe=$.current[ze])==null||Fe.focus())},children:Ef.map((ke,Re)=>o.jsx("button",{type:"button",ref:ze=>{$.current[Re]=ze},tabIndex:I===ke.key?0:-1,"aria-pressed":I===ke.key,"data-pending":I===ke.key&&F?"":void 0,title:I===ke.key&&F?`Reading ${ke.noun} from the transcripts on this machine…`:ke.hint,className:"uh-range-btn",onClick:()=>O(ke.key),children:ke.label},ke.key))}),W&&o.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:F?`Reading ${_S(I,I)}…`:""}),Pe>0?o.jsxs(o.Fragment,{children:[Ge&&o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:`up-total${ge}`,title:W?void 0:bS,children:[o.jsx("span",{className:"up-total-value",children:ut(Be)}),o.jsx("span",{className:"up-total-label",children:W?le:Pq})]}),Ie.showCostBar&&o.jsx(Ab,{cost:j})]}),o.jsxs("div",{className:`up-tokens-row${ge}`,title:W?void 0:bS,children:[o.jsxs("span",{className:"up-tok",children:[o.jsx("span",{className:"up-k",children:"in"}),Bt(Te)]}),o.jsxs("span",{className:"up-tok",children:[o.jsx("span",{className:"up-k",children:"out"}),Bt(st)]}),Ie.cacheReadTokens>0&&o.jsxs("span",{className:"up-tok",children:[o.jsx("span",{className:"up-k",children:"cache r"}),Bt(de)]}),Ie.cacheCreateTokens>0&&o.jsxs("span",{className:"up-tok",children:[o.jsx("span",{className:"up-k",children:"cache c"}),Bt(ue)]}),!Ge&&o.jsx("span",{className:"up-tok up-scope",children:Dq})]}),(W?U.length:se.length)>0&&o.jsxs("section",{className:`up-section${ge}`,children:[o.jsx("h3",{className:"up-section-title",children:"By model"}),o.jsxs("table",{className:"up-table",children:[o.jsx("thead",{children:o.jsxs("tr",{children:[o.jsx("th",{children:"Model"}),o.jsx("th",{children:"Tokens"}),o.jsx("th",{children:"Cost"})]})}),o.jsx("tbody",{children:W?U.map(ke=>o.jsxs("tr",{children:[o.jsx("td",{className:"up-model-name",title:ke.model,children:so(ke.model)}),o.jsx("td",{className:"up-num",children:Bt(ke.tokens)}),ke.cost>0?o.jsx("td",{className:"up-num up-cost-val",children:ut(ke.cost)}):o.jsx("td",{className:"up-num up-unpriced",children:Cl})]},ke.model)):se.map(ke=>o.jsxs("tr",{children:[o.jsx("td",{className:"up-model-name",title:ke.model===C0?"no model reported yet":ke.model,children:ke.model===C0?"unknown":so(ke.model)}),o.jsx("td",{className:"up-num",children:Bt(ke.inputTokens+ke.outputTokens)}),ke.priced?o.jsx("td",{className:"up-num up-cost-val",children:ut(ke.cost.total)}):o.jsx("td",{className:"up-num up-unpriced",children:Cl})]},ke.model))})]})]}),W&&Y.length===0&&z.tokens>0&&o.jsxs("section",{className:"up-section",children:[o.jsx("h3",{className:"up-section-title",children:"By session"}),o.jsxs("div",{className:"up-hint",children:["No session is dated ",le," yet — ccusage dates sessions in UTC, and the totals above are your local day."]})]}),(W?Y.length:be.length)>0&&(()=>{const ke=W?Y.length:be.length;return o.jsxs("section",{className:`up-section${ge}`,children:[o.jsx("h3",{className:"up-section-title",children:o.jsxs("button",{type:"button",className:"up-disclose","aria-expanded":H,"aria-controls":"up-sessions",title:H?"Hide the per-session breakdown":`Show the per-session breakdown — ${ke} session${ke===1?"":"s"}`,onClick:()=>q(Re=>!Re),children:["By session",W&&o.jsxs("span",{className:"up-section-age",title:i8(le,ie,ut),children:["active ",le]}),o.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:o.jsx("path",{d:"M2.2 3.6 5 6.4 7.8 3.6"})})]})}),o.jsxs("div",{className:"up-sessions",id:"up-sessions",hidden:!H,children:[W&&Y.map(Re=>{const ze=re.get(Re.sessionId);return o.jsxs("div",{className:"up-session-row",children:[ze?o.jsxs(o.Fragment,{children:[o.jsx("span",{className:`sl-dot state-${ze}`,"aria-hidden":!0}),o.jsx("span",{className:"vis-hidden",children:Wl(ze)})]}):o.jsx("span",{className:"sl-dot up-dot-past","aria-hidden":!0}),o.jsx("span",{className:`up-session-label${Re.label?"":" up-session-id"}`,title:Re.label?`${Re.label}
88
+ ${Re.sessionId}`:Re.sessionId,children:Re.label??Re.sessionId.slice(0,8)}),o.jsx("span",{className:"up-session-tokens",children:Bt(Re.tokens)}),Re.cost>0?o.jsx("span",{className:"up-session-cost",title:Re.models.join(", ")||void 0,children:ut(Re.cost)}):o.jsx("span",{className:"up-session-cost up-unpriced",children:Cl})]},Re.sessionId)}),!W&&be.map(Re=>o.jsxs("div",{className:"up-session-row",children:[o.jsx("span",{className:`sl-dot state-${Re.state}`,"aria-hidden":!0}),o.jsx("span",{className:"vis-hidden",children:Wl(Re.state)}),o.jsx("span",{className:"up-session-label",children:Re.label}),o.jsx("span",{className:"up-session-tokens",children:Bt(Re.inputTokens+Re.outputTokens)}),Re.cost>0?o.jsxs("span",{className:"up-session-cost",title:Re.unpricedTokens>0?`${Bt(Re.unpricedTokens)} tokens in this session are on an unpriced model, so this is a floor`:void 0,children:[ut(Re.cost),Re.unpricedTokens>0?"+":""]}):o.jsx("span",{className:"up-session-cost up-unpriced",children:Cl})]},Re.sessionId))]})]})})(),Le&&o.jsxs("div",{className:"up-hint",children:["“",Cl,"” means this build holds no published rate for that model — those tokens are counted above and their dollars are not."]})]}):o.jsx("div",{className:"up-empty",children:W?o.jsxs(o.Fragment,{children:["No usage ",le,".",o.jsx("br",{}),"Try a longer period."]}):o.jsxs(o.Fragment,{children:["No usage data yet.",o.jsx("br",{}),"Start a Claude Code or Codex session."]})})]})}function Nm(e){return e<9.95?e.toFixed(1):String(Math.round(e))}function Mb(e){const t=Number.isFinite(e)?Math.max(0,e):0;return t<50?{value:"0",unit:"KB/s"}:t<999500?{value:Nm(t/1e3),unit:"KB/s"}:t<9995e5?{value:Nm(t/1e6),unit:"MB/s"}:{value:Nm(t/1e9),unit:"GB/s"}}function Rf(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 Tu(e){return e.unit?e.unit==="%"||e.unit==="°C"?`${e.value}${e.unit}`:`${e.value} ${e.unit}`:e.value}function Sm(e,t){return t==="B/s"?Mb(e):t==="ms"?Rf(e):{value:String(e),unit:t==="C"?"°C":t}}const cn={l:30,r:6,t:6,b:2},Ga={l:0,r:0,t:2,b:1},Af=104,_8=64;function ms(e,t=100,n=Af,r=cn){const s=n-r.t-r.b;return r.t+s*(1-Math.max(0,Math.min(t,e))/t)}function $M(e,t,n,r=100,s=Af,l=cn){if(!e.length)return"";const c=e[e.length-1].t-e[0].t,u=h=>{const m=t-l.l-l.r;return l.l+(c>0?m*(h-e[0].t)/c:m/2)};let f="",p=null;for(const h of e){const m=p&&h.t-p.t<=n*2?"L":"M";f+=`${m}${u(h.t).toFixed(1)} ${ms(h.v,r,s,l).toFixed(1)}`,p=h}return f}function OM(e,t,n,r=100,s=Af,l=cn){if(e.length<2)return"";const c=s-l.b,u=e[e.length-1].t-e[0].t,f=t-l.l-l.r,p=v=>l.l+(u>0?f*(v-e[0].t)/u:f/2);let h="",m=[];const y=()=>{if(m.length>=2){let v=`M${p(m[0].t).toFixed(1)} ${c}`;for(const S of m)v+=`L${p(S.t).toFixed(1)} ${ms(S.v,r,s,l).toFixed(1)}`;h+=`${v}L${p(m[m.length-1].t).toFixed(1)} ${c}Z`}m=[]};for(const v of e)m.length&&v.t-m[m.length-1].t>n*2&&y(),m.push(v);return y(),h}function E8(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 LM(e,t,n){return n!=null&&e>=n?"hot":t!=null&&e>=t?"warn":""}function C8(e,t,n=r=>ei(r)){const r=e.filter(c=>c.v>0);if(!e.length)return null;if(!r.length)return"never held back";const s=r.length*(t/6e4),l=r[r.length-1];return`held back for ${s===1?"1 minute":`${s} minutes`}, last at ${n(l.t)}`}function ei(e){const t=new Date(e);return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}function Ib(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 T8({group:e,title:t,onClose:n}){const r=pn(n),[s,l]=w.useState(null);w.useEffect(()=>{let p=!0;const h=async()=>{try{const y=await fetch(`/api/system/history?group=${e}`);if(!y.ok)return;const v=await y.json();p&&(v!=null&&v.ok)&&l(v)}catch{}};h();const m=window.setInterval(h,2e4);return()=>{p=!1,window.clearInterval(m)}},[e]);const c=(s==null?void 0:s.series)??[],[u,f]=w.useMemo(()=>{let p=1/0,h=0;for(const m of c)m.points.length&&(p=Math.min(p,m.points[0].t),h=Math.max(h,m.points[m.points.length-1].t));return[Number.isFinite(p)?Math.max(p,(s==null?void 0:s.sinceMs)??0):(s==null?void 0:s.sinceMs)??0,h]},[c,s==null?void 0:s.sinceMs]);return Mn.createPortal(o.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:o.jsxs("div",{ref:r,className:"modal hist-modal",onClick:p=>p.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"hist-modal-title",children:[o.jsxs("div",{className:"modal-head",children:[o.jsx("span",{className:"modal-title",id:"hist-modal-title",children:t}),s&&u>0&&o.jsxs("span",{className:"hist-since",children:["since ",ei(u)," · ",Ib(u,f||Date.now())]}),o.jsx("button",{type:"button",className:"glyph-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]}),o.jsx("div",{className:"hist-body",children:s==null?o.jsx("p",{className:"hist-empty",children:"Reading…"}):c.length===0?o.jsx("p",{className:"hist-empty",children:"Nothing has been measured yet."}):c.map(p=>o.jsx(R8,{series:p,stepMs:s.stepMs},p.label))})]})}),document.body)}function R8({series:e,stepMs:t}){const n=w.useRef(null),[r,s]=w.useState(560),[l,c]=w.useState(null);w.useEffect(()=>{const q=n.current;if(!q||typeof ResizeObserver>"u")return;const $=new ResizeObserver(([V])=>s(Math.max(160,V.contentRect.width)));return $.observe(q),()=>$.disconnect()},[]);const{points:u,unit:f,warnAt:p,critAt:h,label:m,top:y,restsAtZero:v,changes:S}=e,b=v?_8:Af,{now:_,peak:k}=E8(u),j=_!=null?Sm(_,f):null,E=k!=null?Sm(k,f):null,C=m==="Throttling"?C8(u,t):null,R=l!=null?u[l]:null,I=u.length>1?u[u.length-1].t-u[0].t:0,O=q=>{const $=r-cn.l-cn.r;return cn.l+(I>0?$*(q-u[0].t)/I:$/2)},H=q=>{if(u.length<2)return;const $=q.currentTarget.getBoundingClientRect(),V=(q.clientX-$.left-cn.l)/Math.max(1,$.width-cn.l-cn.r),ne=u[0].t+I*Math.max(0,Math.min(1,V));let ee=0;for(let M=1;M<u.length;M++)Math.abs(u[M].t-ne)<Math.abs(u[ee].t-ne)&&(ee=M);c(ee)};return o.jsxs("section",{className:"hist-series","aria-label":`${m} history`,children:[o.jsxs("div",{className:"hist-head",children:[o.jsx("span",{className:"hist-label",children:m}),o.jsxs("span",{className:"hist-stats",children:[j&&o.jsxs(o.Fragment,{children:[o.jsx("b",{children:j.value}),o.jsxs("span",{children:[j.unit," now"]})]}),k!=null&&E&&o.jsxs(o.Fragment,{children:[o.jsx("b",{className:LM(k,p,h),children:E.value}),o.jsxs("span",{children:[E.unit," peak"]})]})]})]}),o.jsx("div",{className:"hist-plot",ref:n,children:o.jsxs("svg",{className:"hist-chart",width:"100%",height:b,viewBox:`0 0 ${r} ${b}`,preserveAspectRatio:"none",role:"img","aria-label":j==null||E==null?`${m}: nothing measured yet`:`${m}: ${Tu(j)} now, peak ${Tu(E)}, over ${Ib(u[0].t,u[u.length-1].t)}`,onPointerMove:H,onPointerLeave:()=>c(null),children:[[["warn",p],["hot",h]].map(([q,$])=>$==null||$>y?null:o.jsxs("g",{children:[o.jsx("line",{className:`hist-rule ${q}`,x1:cn.l,x2:r-cn.r,y1:ms($,y,b),y2:ms($,y,b)}),o.jsx("text",{className:`hist-rule-tag ${q}`,x:2,y:ms($,y,b)+3,children:$})]},q)),o.jsx("line",{className:"hist-floor",x1:cn.l,x2:r-cn.r,y1:b-cn.b,y2:b-cn.b}),(S??[]).filter(q=>q.from!=null&&u.length>1&&q.t>=u[0].t&&q.t<=u[u.length-1].t).map(q=>o.jsx("line",{className:"hist-mark",x1:O(q.t),x2:O(q.t),y1:cn.t,y2:b-cn.b},q.t)),o.jsx("path",{className:"hist-area",d:OM(u,r,t,y,b)}),o.jsx("path",{className:"hist-line",d:$M(u,r,t,y,b)}),u.length===1&&o.jsx("circle",{className:"hist-dot",cx:O(u[0].t),cy:ms(u[0].v,y,b),r:3}),R&&o.jsxs("g",{children:[o.jsx("line",{className:"hist-cross",x1:O(R.t),x2:O(R.t),y1:cn.t,y2:b-cn.b}),o.jsx("circle",{className:"hist-dot",cx:O(R.t),cy:ms(R.v,y,b),r:3})]})]})}),o.jsx("div",{className:"hist-axis",children:R?o.jsxs("span",{className:"hist-at",children:[ei(R.t)," — ",(()=>{const q=Sm(R.v,f);return o.jsxs(o.Fragment,{children:[o.jsx("b",{children:q.value}),q.unit==="%"||q.unit==="°C"||!q.unit?q.unit:` ${q.unit}`]})})()]}):o.jsxs(o.Fragment,{children:[o.jsx("span",{children:u.length?ei(u[0].t):""}),o.jsx("span",{children:u.length?ei(u[u.length-1].t):""})]})}),C&&o.jsx("div",{className:"hist-note",children:C}),S==null?void 0:S.slice(-3).map(q=>o.jsx("div",{className:"hist-note hist-route",children:q.from==null?`Since ${ei(q.t)} — ${q.label}`:`${ei(q.t)} — ${q.label.charAt(0).toUpperCase()+q.label.slice(1)}`},q.t))]})}function A8(e,t,n){if(n<=0||Nf(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 Ja=4,fs=8;function $b(e,t,n){const r=n.width-fs-(e.right+Ja),s=e.left-Ja-fs,l=t.width<=r||r>=s?"right":"left",c=l==="right"?e.right+Ja:e.left-Ja-t.width,u=n.height-fs*2,f=t.height<=u,p=f?t.height:Math.max(0,u);return{top:Math.max(fs,Math.min(e.top,n.height-fs-p)),left:Math.max(fs,c),side:l,maxHeight:f?null:p}}function M8(e,t,n){const r=n.height-fs-(e.bottom+Ja),s=e.top-Ja-fs,l=t.height<=r||r>=s?"below":"above",c=l==="below"?r:s,u=t.height<=c,f=u?t.height:Math.max(0,c),p=l==="below"?e.bottom+Ja:e.top-Ja-f,h=Math.max(fs,Math.min(e.right-t.width,n.width-fs-t.width));return{top:Math.max(fs,p),left:h,side:l,maxHeight:u?null:f}}const PM='[role="menuitem"]';function TS(e){return e?Array.from(e.querySelectorAll(PM)).filter(t=>!t.disabled):[]}function M0({anchorId:e,boundaryId:t,id:n,className:r,role:s,labelledBy:l,start:c="first",onClose:u,children:f}){const p=w.useRef(u);p.current=u;const h=pn(()=>{var b;(b=document.getElementById(e))==null||b.focus(),p.current()},{popover:!0}),m=w.useCallback(()=>{var C;const b=h.current;if(!b)return;const _=document.getElementById(e);if(!_){p.current();return}const k=_.getBoundingClientRect(),j=t?(C=document.getElementById(t))==null?void 0:C.getBoundingClientRect():null;if(j&&(k.bottom<=j.top||k.top>=j.bottom)){b.contains(document.activeElement)&&_.focus({preventScroll:!0}),p.current();return}b.style.maxHeight="";const E=M8(k,{width:b.offsetWidth,height:b.offsetHeight},{width:window.innerWidth,height:window.innerHeight});b.style.top=`${E.top}px`,b.style.left=`${E.left}px`,b.style.maxHeight=E.maxHeight==null?"":`${E.maxHeight}px`,b.dataset.side=E.side},[e,t,h]);w.useLayoutEffect(()=>{m()}),w.useEffect(()=>{const b=_=>{var k;(k=h.current)!=null&&k.contains(_.target)||m()};return window.addEventListener("scroll",b,!0),window.addEventListener("resize",m),()=>{window.removeEventListener("scroll",b,!0),window.removeEventListener("resize",m)}},[m,h]),w.useEffect(()=>{const b=_=>{var j,E;const k=_.target;!k||(j=h.current)!=null&&j.contains(k)||(E=document.getElementById(e))!=null&&E.contains(k)||p.current()};return window.addEventListener("pointerdown",b,!0),()=>window.removeEventListener("pointerdown",b,!0)},[e,h]),w.useEffect(()=>{var _;if(s!=="menu")return;const b=TS(h.current);(_=c==="last"?b[b.length-1]:b[0])==null||_.focus()},[]);const y=b=>{var _;if(s==="menu"&&b.key==="Tab"){b.stopPropagation(),(_=document.getElementById(e))==null||_.focus(),b.shiftKey&&b.preventDefault(),p.current();return}if(s==="menu"){const k=TS(h.current),j=A8(b,k.indexOf(document.activeElement),k.length);j.kind==="focus"&&(b.preventDefault(),k[j.index].focus())}b.key.length===1&&b.stopPropagation()},v=b=>{b.target.closest("button, input, select, textarea, code")||b.preventDefault()},S=b=>{if(s!=="menu"||b.pointerType==="touch")return;const _=b.target.closest(PM);_&&!_.disabled&&document.activeElement!==_&&_.focus({preventScroll:!0})};return Mn.createPortal(o.jsx("div",{ref:h,id:n,className:`anchored-popover${r?` ${r}`:""}`,role:s,"aria-labelledby":l,onKeyDown:y,onMouseDown:v,onPointerMove:S,children:f}),document.body)}const I8="thermal:Throttling";function $8(e){var n,r,s,l;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 c of((s=e.thermal)==null?void 0:s.celsius)??[])t[`thermal:${c.label}`]=c.celsius;return(l=e.thermal)!=null&&l.throttle&&(t[I8]=Math.max(0,100-e.thermal.throttle.speedLimit)),t}function mu(e,t){return t==="B/s"?Tu(Mb(e)):t==="ms"?Tu(Rf(e)):t==="C"?`${Math.round(e)}°`:t==="%"?`${Math.round(e)}%`:e.toFixed(2)}function wh(e,t){return t==="B/s"||t==="ms"||!Number.isInteger(e)?mu(e,t):t==="C"?`${e}°`:t==="%"?`${e}%`:`${e}`}const RS=["cores","memory","load","thermal"],Qo=116,Ls=24,O8=60,L8=6e4;function P8(e){return e.points.length?e.restsAtZero?e.points.some(t=>t.v>0):!0:!1}function D8(e){return e.unit==="C"?`${e.label} temp`:e.key==="mem:physical"?"Physical RAM":e.key==="mem:swap"?`${e.label} memory`:e.label}function F8(e,t=O8){return e.points.length<=t?e:{...e,points:e.points.slice(-t)}}function q8({sys:e}){const[t,n]=w.useState({});w.useEffect(()=>{let c=!0;const u=async()=>{const p=await Promise.all(RS.map(async h=>{try{const m=await fetch(`/api/system/history?group=${h}`);return m.ok?[h,await m.json()]:[h,null]}catch{return[h,null]}}));c&&n(h=>{const m={...h};for(const[y,v]of p)v!=null&&v.ok&&(m[y]=v);return m})};u();const f=setInterval(()=>void u(),L8);return()=>{c=!1,clearInterval(f)}},[]);const r=w.useMemo(()=>$8(e),[e]),s=w.useMemo(()=>RS.flatMap(c=>{const u=t[c];return u?u.series.filter(P8).map(f=>({series:F8(f),stepMs:u.stepMs})):[]}),[t]),l=w.useMemo(()=>{let c=1/0,u=-1/0;for(const{series:f}of s){const p=f.points;p.length&&(c=Math.min(c,p[0].t),u=Math.max(u,p[p.length-1].t))}return Number.isFinite(c)?Ib(c,u):"less than a minute"},[s]);return Object.keys(r).length?o.jsx("div",{className:"pl-strip",role:"group","aria-label":`This machine, over the last ${l}`,children:s.map(({series:c,stepMs:u})=>o.jsx(B8,{series:c,stepMs:u,now:r[c.key],span:l},c.key))}):null}function B8({series:e,stepMs:t,now:n,span:r}){var v;const{points:s,top:l,unit:c,warnAt:u,critAt:f}=e,p=D8(e),h=n??((v=s[s.length-1])==null?void 0:v.v),m=h==null?"":LM(h,u,f),y=Math.max(...s.map(S=>S.v));return o.jsxs("div",{className:`pl-cell${m?` ${m}`:""}`,title:[`${p} · peak ${mu(y,c)} over the last ${r}`,u!=null?`over ${wh(u,c)} is uncomfortable`:"",f!=null?`over ${wh(f,c)} the machine acts`:""].filter(Boolean).join(" · "),children:[o.jsxs("div",{className:"pl-cell-head",children:[o.jsx("span",{className:"pl-cell-label",children:p}),o.jsx("span",{className:"pl-cell-now",children:h==null?"—":mu(h,c)})]}),o.jsxs("svg",{className:"pl-spark",width:Qo,height:Ls,viewBox:`0 0 ${Qo} ${Ls}`,preserveAspectRatio:"none","aria-hidden":!0,children:[o.jsx("line",{className:"pl-spark-floor",x1:0,x2:Qo,y1:Ls-Ga.b,y2:Ls-Ga.b}),o.jsx("path",{className:"pl-spark-area",d:OM(s,Qo,t,l,Ls,Ga)}),u!=null&&o.jsx("line",{className:"pl-rule warn",x1:0,x2:Qo,y1:ms(u,l,Ls,Ga),y2:ms(u,l,Ls,Ga)}),f!=null&&o.jsx("line",{className:"pl-rule hot",x1:0,x2:Qo,y1:ms(f,l,Ls,Ga),y2:ms(f,l,Ls,Ga)}),o.jsx("path",{className:"pl-spark-line",d:$M(s,Qo,t,l,Ls,Ga)})]}),o.jsxs("span",{className:"vis-hidden",children:["peak ",mu(y,c)," over the last ",r,u!=null&&`, uncomfortable over ${wh(u,c)}`,f!=null&&`, the machine acts over ${wh(f,c)}`]})]})}const z8={key:"cpu",dir:"desc"};function U8(e,t){return e.key===t?{...e,dir:e.dir==="asc"?"desc":"asc"}:{key:t,dir:t==="name"||t==="user"?"asc":"desc"}}function H8(e,t){const n=t.dir==="asc"?1:-1,r=l=>t.key==="cpu"?l.cpu:t.key==="mem"?l.mem:t.key==="rss"?l.rssBytes:t.key==="threads"?l.threads:l.uptimeSec,s=(l,c)=>{if(t.key==="name")return n*l.name.localeCompare(c.name,void 0,{sensitivity:"base"});if(t.key==="user"){const p=l.user??"",h=c.user??"";return!p||!h?p===h?0:p?-1:1:n*p.localeCompare(h,void 0,{sensitivity:"base"})}const u=r(l),f=r(c);return u==null||f==null?u==null?f==null?0:1:-1:n*(u-f)};return[...e].sort((l,c)=>s(l,c)||(c.cpu??-1)-(l.cpu??-1)||c.mem-l.mem||l.pid-c.pid)}function W8(e,t){return e.key!==t?"none":e.dir==="asc"?"ascending":"descending"}const V8=4e3;function G8(){const[e,t]=w.useState(null);return w.useEffect(()=>{let n=!0;const r=async()=>{if(document.visibilityState!=="hidden")try{const l=await fetch("/api/system/processes?detail=1");if(!l.ok)return;const c=await l.json();n&&(c!=null&&c.ok)&&t({procs:c.procs??[],total:c.total??0})}catch{}};r();const s=window.setInterval(r,V8);return()=>{n=!1,window.clearInterval(s)}},[]),e}function K8(e){if(e==null||!Number.isFinite(e)||e<0)return"—";if(e<1024)return`${Math.round(e)} B`;const t=["KB","MB","GB","TB"];let n=e/1024,r=0;for(;n>=1024&&r<t.length-1;)n/=1024,r++;return`${n>=100?n.toFixed(0):n.toFixed(1)} ${t[r]}`}function Y8(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 X8({sys:e,onClose:t}){const n=pn(t),[r,s]=w.useState(z8),l=G8(),c=l?H8(l.procs,r):null;return Mn.createPortal(o.jsx("div",{className:"modal-backdrop",onClick:t,role:"presentation",children:o.jsxs("div",{ref:n,className:"modal pl-modal",onClick:u=>u.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"pl-modal-title",children:[o.jsxs("div",{className:"modal-head",children:[o.jsx("span",{className:"modal-title",id:"pl-modal-title",children:"Busiest processes"}),l&&o.jsxs("span",{className:"pl-count",children:[c.length," of ",l.total," running"]}),o.jsx("button",{type:"button",className:"glyph-btn",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]}),o.jsxs("div",{className:"pl-split",children:[o.jsx("div",{className:"pl-body",children:c==null?o.jsx("p",{className:"pl-empty",children:"Reading the process list…"}):c.length===0?o.jsx("p",{className:"pl-empty",children:"Could not read the process list on this platform."}):o.jsxs("table",{className:"sd-procs pl-table",children:[o.jsx("thead",{children:o.jsxs("tr",{children:[o.jsx(xl,{col:"cpu",label:"cpu",sort:r,onSort:s}),o.jsx(xl,{col:"rss",label:"memory",note:"Resident set size, which is what ps and Task Manager report; macOS Activity Monitor shows a different figure.",sort:r,onSort:s}),o.jsx(xl,{col:"threads",label:"threads",sort:r,onSort:s}),o.jsx(xl,{col:"uptime",label:"up",sort:r,onSort:s}),o.jsx(xl,{col:"user",label:"user",sort:r,onSort:s}),o.jsx("th",{scope:"col",className:"pl-pid-h",children:"pid"}),o.jsx(xl,{col:"name",label:"process",note:"Command lines have anything secret-shaped removed, which is a filter and not a guarantee.",sort:r,onSort:s})]})}),o.jsx("tbody",{children:c.map(u=>o.jsxs("tr",{children:[o.jsx("td",{className:"sd-num",children:u.cpu==null?"—":u.cpu.toFixed(0)}),o.jsx("td",{className:"sd-num sd-dim",title:`${u.mem.toFixed(1)}% of installed memory`,children:K8(u.rssBytes)}),o.jsx("td",{className:"sd-num sd-dim",children:u.threads??"—"}),o.jsx("td",{className:"sd-num sd-dim",children:Y8(u.uptimeSec)}),o.jsx("td",{className:"sd-dim pl-user",children:u.user??"—"}),o.jsx("td",{className:"sd-num sd-dim pl-pid",children:u.pid}),o.jsxs("td",{className:"pl-name",children:[u.name,u.cmd&&o.jsxs("span",{className:"pl-cmd",title:u.cmd,children:[" ",u.cmd]})]})]},u.pid))})]})}),o.jsx(q8,{sys:e})]})]})}),document.body)}function xl({col:e,label:t,note:n,sort:r,onSort:s}){const l=W8(r,e);return o.jsx("th",{scope:"col","aria-sort":l,children:o.jsxs("button",{type:"button",className:"sd-sort",title:n?`Sort by ${t}
89
+
90
+ ${n}`:`Sort by ${t}`,onClick:()=>s(U8(r,e)),children:[t,o.jsx("span",{className:"sd-sort-dir","aria-hidden":!0,children:l==="none"?"":l==="ascending"?"↑":"↓"})]})})}const Z8=3e3;function Q8(e,t,n){return e>=n?"hot":e>=t?"warn":"calm"}function J8(e,t,n=Date.now()){const r=Math.max(0,Math.min(100,100-e));return{pct:r,value:`${r}%`,tone:r===0?"calm":r>=30?"hot":"warn",note:r>0?`CPU held to ${e}% of full speed to cool down`:t?`at full speed · held to ${100-t.peak}% ${eB(t.lastMs,n)}`:"running at full speed, and never held back"}}function eB(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 ru(e){return e>=1024**3?`${(e/1024**3).toFixed(1)} GB`:e>=1024**2?`${Math.round(e/1024**2)} MB`:`${Math.round(e/1024)} KB`}function tB(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 nB(e){var n,r,s;const t=(r=(n=e.thermal)==null?void 0:n.throttle)==null?void 0:r.speedLimit;return t!=null&&t<100?`throttled to ${t}% 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 rB(){const[e,t]=w.useState(null),n=w.useRef(null);return w.useEffect(()=>{let r=!0;const s=async()=>{if(document.visibilityState!=="hidden")try{const f=await fetch("/api/system");if(!f.ok)return;const p=await f.json();r&&(p!=null&&p.ok)&&t(p)}catch{}},l=()=>{n.current==null&&(s(),n.current=window.setInterval(s,Z8))},c=()=>{n.current!=null&&(window.clearInterval(n.current),n.current=null)},u=()=>{if(document.visibilityState==="hidden"){c();return}l(),s()};return l(),document.addEventListener("visibilitychange",u),()=>{r=!1,c(),document.removeEventListener("visibilitychange",u)}},[]),e}function AS({usageOpen:e,leaving:t,sub:n,flag:r,onClose:s,children:l}){return o.jsxs("aside",{className:`sysdetail${e?" shifted":""}${t?" leaving":""}`,id:"system-panel","aria-labelledby":"sd-title",children:[o.jsxs("div",{className:"sd-top",children:[o.jsxs("div",{className:"sd-head",children:[o.jsx("h2",{className:"sd-title",id:"sd-title",children:"This machine"}),n&&o.jsx("span",{className:"sd-sub",children:n}),o.jsx("button",{type:"button",className:"glyph-btn sd-close",onClick:s,"aria-label":"Close",title:"Close",children:"×"})]}),r&&o.jsx("p",{className:"sd-flag",children:r})]}),l]})}function sB({usageOpen:e,leaving:t,onClose:n}){const r=rB();if(!r||r.cpu==null||!r.memory)return o.jsx(AS,{usageOpen:e,leaving:t,onClose:n,children:o.jsx("div",{className:"sd-note",children:"reading this machine…"})});const{memory:s,swap:l,perCore:c,loadavg:u,cores:f,uptimeSec:p,platform:h,thermal:m,network:y,cpu:v}=r;return o.jsxs(AS,{usageOpen:e,leaving:t,sub:`up ${tB(p)} · ${f} cores`,flag:nB(r),onClose:n,children:[o.jsx(aB,{cpu:v,perCore:c,loadavg:u,cores:f}),o.jsx(oB,{memory:s,swap:l,platform:h}),y&&o.jsx(iB,{network:y}),o.jsx(uB,{thermal:m}),o.jsx(dB,{sys:r})]})}function aB({cpu:e,perCore:t,loadavg:n,cores:r}){const s=!!t&&t.length>0;return!s&&!n?null:o.jsxs("div",{className:"sd-section sd-cpu",role:"group","aria-label":"CPU",children:[s&&o.jsx(Ru,{group:"cores",title:"Core history",action:"Show core history",label:"CPU",value:e==null?null:`${Math.round(e)}%`,children:o.jsx("div",{className:"sd-cores",role:"img","aria-label":`${t.length} logical cores, busiest at ${Math.round(Math.max(...t))}%`,children:t.map((l,c)=>o.jsx("span",{className:"sd-core",title:`logical core ${c+1} · ${l}% busy`,children:o.jsx("span",{className:"sd-core-fill",style:{transform:`scaleY(${Math.max(2,l)/100})`}})},c))})}),n&&o.jsxs(Ru,{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:[o.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((l,c)=>o.jsx(I0,{value:l.toFixed(2),cap:["1m","5m","15m"][c]},c))}),n[0]>r&&o.jsx("div",{className:"sd-note",children:`${(n[0]/r).toFixed(1)}× more work queued than cores to run it`})]})]})}function oB({memory:e,swap:t,platform:n}){const r=e.total-e.available,s=n==="win32"?"Commit":"Swap",l=t&&t.total>0?t.used/t.total*100:0;return o.jsx("div",{className:"sd-section",role:"group","aria-label":"Memory",children:o.jsxs(Ru,{group:"memory",title:"Memory history",action:"Show memory history",label:"Memory",children:[o.jsx(ef,{label:"Physical",value:o.jsxs(o.Fragment,{children:[o.jsx("b",{children:ru(r)})," of ",ru(e.total)]}),pct:e.usedPct,tone:e.usedPct>=90?"warn":"calm",note:`${ru(e.available)} available`}),t&&t.total>0&&o.jsx(ef,{label:s,value:o.jsxs(o.Fragment,{children:[o.jsx("b",{children:ru(t.used)})," of ",ru(t.total)]}),pct:l,tone:l>=90?"warn":"calm"})]})})}function iB({network:e}){const{down:t,up:n,api:r,route:s}=e,[l,c]=w.useState(!1),u=r&&r.ms!=null?Rf(r.ms):null,f=t!=null&&n!=null;return o.jsxs("div",{className:"sd-section",role:"group","aria-label":"Network",children:[o.jsxs(Ru,{group:"network",title:"Network history",action:"Show network history",label:"Network",children:[(f||u)&&o.jsxs("div",{className:"sd-figs sd-figs-named",children:[f&&[["Download",t],["Upload",n]].map(([p,h])=>{const m=Mb(h);return o.jsx(I0,{value:m.value,unit:m.unit,cap:p},p)}),u&&o.jsx(I0,{value:u.value,unit:u.unit,cap:"Claude API"})]}),!f&&o.jsx("div",{className:"sd-note",children:"measuring…"}),r&&r.ms==null&&o.jsx("div",{className:"sd-note sd-note-warn",children:"Can’t reach Claude"})]}),s&&o.jsxs(o.Fragment,{children:[o.jsxs("button",{type:"button",className:"sd-detail",id:"sd-conn","aria-expanded":l,"aria-haspopup":"dialog",onClick:()=>c(p=>!p),children:["Connection details",s.relay&&o.jsx("span",{className:"sd-route-relay",children:" · relayed"}),o.jsx("i",{className:"sd-row-more","aria-hidden":!0,children:"›"})]}),l&&o.jsx(cB,{route:s,api:r,onClose:()=>c(!1)})]})]})}function I0({value:e,unit:t,cap:n}){return t?o.jsxs("span",{className:"sd-fig",children:[o.jsx("span",{className:"sd-fig-cap",children:n}),o.jsxs("span",{className:"sd-fig-read",children:[o.jsx("b",{children:e})," ",o.jsx("span",{className:"sd-fig-unit",children:t})]})]}):o.jsxs("span",{className:"sd-fig",children:[o.jsx("b",{children:e}),o.jsx("span",{className:"sd-fig-cap",children:n})]})}function lB(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})`:""}`}function cB({route:e,api:t,onClose:n}){return o.jsxs(M0,{anchorId:"sd-conn",boundaryId:"system-panel",id:"sd-conn-pop",className:"sd-pop",role:"dialog",labelledBy:"sd-conn-title",onClose:n,children:[o.jsx("p",{className:"sd-pop-title",id:"sd-conn-title",children:"Connection"}),o.jsxs("dl",{className:"sd-pop-rows",children:[o.jsxs("div",{className:"sd-pop-row",children:[o.jsx("dt",{children:e.to==="claude"?"Traffic to Claude":"Internet traffic"}),o.jsxs("dd",{children:["through ",lB(e)]})]}),e.relay&&o.jsxs("div",{className:"sd-pop-row",children:[o.jsx("dt",{children:"Relay"}),o.jsxs("dd",{children:[o.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&&o.jsxs("div",{className:"sd-pop-row",children:[o.jsx("dt",{children:"Round trip"}),o.jsx("dd",{children:t.ms==null?`${t.host} did not answer`:`${Tu(Rf(t.ms))} to open a connection to ${t.host}`})]}),o.jsxs("div",{className:"sd-pop-row",children:[o.jsx("dt",{children:"Throughput"}),o.jsx("dd",{children:"every interface on this machine, not this path alone"})]})]})]})}function Ru({group:e,title:t,action:n,label:r,value:s,hint:l,children:c}){const[u,f]=w.useState(!1);return o.jsxs(o.Fragment,{children:[o.jsxs("button",{type:"button",className:"sd-open",onClick:()=>f(!0),title:n,"aria-label":s==null?n:`${n}, now ${s}`,"aria-describedby":l?`sd-hint-${e}`:void 0,children:[o.jsxs("div",{className:"sd-h","aria-hidden":!0,children:[r," ",o.jsx("i",{className:"sd-row-more",children:"›"}),s!=null&&o.jsx("span",{className:"sd-h-val",children:s})]}),c]}),l&&o.jsx("span",{id:`sd-hint-${e}`,className:"vis-hidden",children:l}),u&&o.jsx(T8,{group:e,title:t,onClose:()=>f(!1)})]})}function uB({thermal:e}){if(!e)return null;const t=e.throttle?J8(e.throttle.speedLimit,e.heldBack):null;return o.jsx("div",{className:"sd-section",role:"group","aria-label":"Thermal",children:o.jsxs(Ru,{group:"thermal",title:"Thermal history",action:"Show thermal history",label:"Thermal",children:[e.celsius.map(n=>o.jsx(ef,{label:n.label,value:o.jsxs(o.Fragment,{children:[o.jsx("b",{children:n.celsius})," °C"]}),pct:n.celsius/n.critAt*100,mark:n.warnAt/n.critAt*100,tone:Q8(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&&o.jsx(ef,{label:"Throttling",value:o.jsx("b",{children:t.value}),pct:t.pct,tone:t.tone,note:t.note})]})})}function dB({sys:e}){const[t,n]=w.useState(!1);return o.jsxs("div",{className:"sd-section sd-door-section",children:[o.jsx("button",{type:"button",className:"sd-open sd-door",onClick:()=>n(!0),"aria-label":"Show every process the deck is watching",children:o.jsxs("span",{className:"sd-door-plate",children:[o.jsxs("span",{className:"sd-door-name",children:["Busiest processes",o.jsx("i",{className:"sd-row-more","aria-hidden":!0,children:"›"})]}),o.jsx("span",{className:"sd-door-sub",children:"every process, with its command line"})]})}),t&&o.jsx(X8,{sys:e,onClose:()=>n(!1)})]})}function ef({label:e,value:t,pct:n,tone:r="calm",note:s,mark:l,title:c,trackLabel:u}){return o.jsxs("div",{className:"sd-row",title:c,children:[o.jsxs("div",{className:"sd-row-head",children:[o.jsx("span",{className:"sd-row-label",children:e}),o.jsx("span",{className:"sd-row-val",children:t})]}),o.jsxs("span",{className:"sd-track",role:u?"img":void 0,"aria-label":u,children:[o.jsx("span",{className:`sd-fill${r==="calm"?"":` ${r}`}`,style:{transform:`scaleX(${n<=0?0:Math.max(1,Math.min(100,n))/100})`}}),l!=null&&l>0&&l<100&&o.jsx("span",{className:"sd-mark",style:{left:`${l}%`},"aria-hidden":!0})]}),s&&o.jsx("div",{className:"sd-note",children:s})]})}function MS(e){return{inputTokens:e.i,outputTokens:e.o,cacheReadTokens:e.cr,cacheCreateTokens:e.cc,cacheCreate1hTokens:e.c1h,cacheCreate5mTokens:e.c5m}}function IS(e){let t=0;for(const n of Object.values(e))t+=n.i+n.o+n.cr+n.cc;return t}function hB(e,t,n,r=Date.now()){const s=n.size>0,l=new Map;for(const[E,C]of n){const R=E.indexOf("|"),I=E.slice(0,R),O=E.slice(R+1),H=ri(C.usage,O,r).total,q=H>0?C.cost/H:1;let $=l.get(I);$||($=new Map,l.set(I,$)),$.set(O,q)}const c=(E,C)=>{const R=l.get(E);return(R==null?void 0:R.get(C))??(R==null?void 0:R.get(Ql(C)))??1},u=(E,C)=>{let R=0;for(const[I,O]of Object.entries(E))R+=ri(MS(O),I,r).total*c(C,I);return R},f=new Map,p=[];for(const E of e){const C=new Map;let R=0;for(const I of E.projects){const O=u(I.models,E.day);C.set(I.path,(C.get(I.path)??0)+O),R+=O;let H=f.get(I.path);H||(H={path:I.path,cost:0,tokens:0},f.set(I.path,H)),H.cost+=O,H.tokens+=IS(I.models)}p.push({day:E.day,total:R,byPath:C})}const h=[...f.values()].sort((E,C)=>C.cost-E.cost||C.tokens-E.tokens),m=h.reduce((E,C)=>E+C.cost,0),y=h.reduce((E,C)=>E+C.tokens,0);let v=0,S=0;for(const E of n.values())v+=E.cost;for(const[E,C]of n)S+=ri(C.usage,E.slice(E.indexOf("|")+1),r).total;const b=S>0?v/S:1,_=t?IS(t):0;let k=0;if(t)for(const[E,C]of Object.entries(t))k+=ri(MS(C),E,r).total*b;const j=k>0||_>0?{cost:k,tokens:_}:null;return{projects:h,totalCost:m,totalTokens:y,perDay:p,unattributed:j,reconciled:s}}function DM(e){return/^[A-Za-z]:[\\/]$/.test(e)?e:e.replace(/[\\/]+$/,"")}function jm(e){const t=DM(e).replace(/\\/g,"/");return/^[A-Za-z]:\//.test(t)?t.toLowerCase():t}function $S(e){if(!e)return e;const t=DM(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 fB(e,t){const n=jm(e);let r;for(const s of t){const l=jm(s.path);!l||l===n||!n.startsWith(`${l}/`)||(!r||jm(r.path).length<l.length)&&(r=s)}return r==null?void 0:r.label}function $0(e){return e===0?"all time":e===1?"today":`the last ${e} days`}function pB(e){return e===1?"No work attributed to this account yet today.":`No work attributed to this account in ${$0(e)}.`}function mB(e){return e===1?7:e===7?30:e===30?0:null}function gB(e,t){return e!==1&&t>0}const yB=[{days:1,label:"Today"},{days:7,label:"7d"},{days:30,label:"30d"},{days:0,label:"All"}],bl=["var(--usage-blue)","var(--usage-green)","var(--usage-amber)","var(--usage-purple)","var(--usage-indigo)","var(--usage-red)","var(--usage-orange)","var(--usage-zinc)"],wB="var(--usage-zinc)",_m=6,vB=1600;function OS(e){return`${e.getFullYear()}${String(e.getMonth()+1).padStart(2,"0")}${String(e.getDate()).padStart(2,"0")}`}function xB(e){const t=ut(e),n=/^\$(\d{4,})$/.exec(t);return n?`$${Number(n[1]).toLocaleString("en-US")}`:t}function LS(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 bB(e){const t=/^\d{4}-(\d{2})-(\d{2})$/.exec(e);return t?`${Number(t[1])}/${Number(t[2])}`:e}function kB(e){const t=Math.max(1,Math.ceil(e/6));return n=>n===0||n===e-1||n%t===0}function Em(e){if(!e)return"";try{return new Date(e).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return""}}function NB({num:e,name:t,onClose:n}){const[r,s]=w.useState(1),[l,c]=w.useState(null),[u,f]=w.useState(r),[p,h]=w.useState(null),[m,y]=w.useState(null),[v,S]=w.useState(()=>new Set),[b,_]=w.useState(!0),[k,j]=w.useState(null),[E,C]=w.useState(null),R=w.useRef(void 0),I=w.useRef(!0);w.useEffect(()=>()=>{I.current=!1,window.clearTimeout(R.current)},[]);const O=w.useRef(null),H=pn(n,{focusRef:O}),q=w.useRef(0);w.useEffect(()=>{const D=++q.current;_(!0),j(null),y(null),S(new Set);const P=r===0?60:r,B=OS(new Date(Date.now()-(P-1)*864e5)),W=OS(new Date),F=fetch(`/api/account-projects?num=${e}&days=${r}`,{credentials:"same-origin"}).then(re=>re.ok?re.json():Promise.reject(new Error(`HTTP ${re.status}`))),G=fetch(`/api/ccusage?since=${B}&until=${W}`,{credentials:"same-origin"}).then(re=>re.ok?re.json():null).catch(()=>null);Promise.all([F,G]).then(([re,U])=>{if(D!==q.current)return;c(re),f(r);const Y=U;h(Y&&Y.ok!==!1?Y:null),_(!1)}).catch(re=>{D===q.current&&(j(re.message||"Could not load"),c(null),_(!1))})},[e,r]);const $=w.useMemo(()=>{const D=Date.now();if(!l)return null;const P=ue=>typeof ue=="number"&&Number.isFinite(ue)?ue:0,B=new Map;if(p){const ue=Array.isArray(p.days)?p.days:[];for(const se of ue){const be=typeof se.period=="string"?se.period:"",Le=Array.isArray(se.modelBreakdowns)?se.modelBreakdowns:[];for(const ce of Le){const pe=typeof ce.modelName=="string"?ce.modelName:"";if(!be||!/claude/i.test(pe))continue;const Ae=`${be}|${pe}`,fe=B.get(Ae),Se=fe?fe.usage:{inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0,cacheCreate1hTokens:0,cacheCreate5mTokens:0};Se.inputTokens+=P(ce.inputTokens),Se.outputTokens+=P(ce.outputTokens),Se.cacheReadTokens+=P(ce.cacheReadTokens),Se.cacheCreateTokens+=P(ce.cacheCreationTokens),fe?fe.cost+=P(ce.cost):B.set(Ae,{cost:P(ce.cost),usage:Se})}}}const W=hB(l.daily??[],l.unattributed,B,D),F=ue=>ue.replace(/[\\/]+$/,"").split(/[\\/]/).pop()||ue||"(unknown)",G=new Map;for(const ue of W.projects)G.set(F(ue.path),(G.get(F(ue.path))??0)+1);const re=ue=>{const se=F(ue);if((G.get(se)??0)<=1)return se;const be=ue.replace(/[\\/]+$/,"").split(/[\\/]/).slice(-2,-1)[0];return be?`${be}/${se}`:se},U=W.projects.map(ue=>({path:ue.path,label:re(ue.path)})),Y=ue=>({path:ue.path,label:re(ue.path),parentLabel:fB(ue.path,U),cost:ue.cost,tokens:ue.tokens}),z=bl[_m%bl.length],ie=new Map,le=[],ge=W.projects.slice(0,_m),Ne=W.projects.slice(_m);ge.forEach((ue,se)=>{ie.set(ue.path,bl[se%bl.length]),le.push({key:ue.path,...Y(ue),color:bl[se%bl.length]})}),Ne.length&&le.push({key:"__other__",label:`Other · ${Ne.length} project${Ne.length>1?"s":""}`,cost:Ne.reduce((ue,se)=>ue+se.cost,0),tokens:Ne.reduce((ue,se)=>ue+se.tokens,0),color:z,muted:!0,members:Ne.map(Y)});const Ie=W.totalCost,Ge=W.totalTokens,Pe=Ie>0?"cost":"tokens",Be=Pe==="cost"?Ie:Ge,Te=le.map(ue=>ue.color),st=W.perDay.map(ue=>{const se=new Map;for(const[be,Le]of ue.byPath){const ce=ie.get(be)??z;se.set(ce,(se.get(ce)??0)+Le)}return{day:ue.day,total:ue.total,costByColor:se}}),de=st.reduce((ue,se)=>Math.max(ue,se.total),0);return{rows:le,totalCost:Ie,totalTokens:Ge,basis:Pe,denom:Be,un:W.unattributed,reconciled:W.reconciled,chart:st,maxDay:de,colorOrder:Te}},[l,p]),V=(D,P)=>{hi(D).then(B=>{I.current&&(window.clearTimeout(R.current),C({path:D,label:P,ok:B}),R.current=window.setTimeout(()=>{I.current&&C(null)},vB))})},ne=D=>E!=null&&E.ok&&E.path===D?"Copied":"Copy",ee=l!=null&&l.trackedSince?`Tracked since ${Em(l.trackedSince)}`:"Tracking starts with this version",M=$0(u),Z=mB(u),K=b&&!!l;return Mn.createPortal(o.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:o.jsxs("div",{ref:H,className:"modal ap-proj-modal",onClick:D=>D.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ap-proj-title ap-proj-sub",children:[o.jsxs("header",{className:"ap-proj-head",children:[o.jsxs("div",{className:"ap-proj-titlewrap",children:[o.jsx("div",{className:"ap-proj-title",id:"ap-proj-title",children:"Projects"}),o.jsx("div",{className:"ap-proj-sub",id:"ap-proj-sub",title:t,children:t})]}),o.jsx("div",{className:"uh-range",role:"group","aria-label":"Range",children:yB.map(D=>o.jsx("button",{type:"button",className:"uh-range-btn","aria-pressed":r===D.days,onClick:()=>s(D.days),children:D.label},D.days))}),o.jsx("button",{ref:O,className:"glyph-btn ap-proj-close",onClick:n,"aria-label":"Close",children:"×"})]}),o.jsxs("div",{className:`ap-proj-body${K?" refreshing":""}`,"aria-busy":b,children:[b&&!l&&o.jsx("div",{className:"ap-proj-state",children:"Loading…"}),!b&&k&&o.jsxs("div",{className:"ap-proj-state ap-proj-error",children:["Couldn’t load this report: ",k]}),!k&&$&&o.jsx(o.Fragment,{children:$.rows.length===0?o.jsxs("div",{className:"ap-proj-state",children:[pB(u),Z!=null&&o.jsx("div",{className:"ap-proj-widen-wrap",children:o.jsxs("button",{type:"button",className:"ap-proj-copy",onClick:()=>s(Z),children:["Show ",$0(Z)]})}),o.jsxs("div",{className:"ap-proj-note",children:[ee,". Only work from this version onward can be tied to an account."]})]}):o.jsxs(o.Fragment,{children:[o.jsx("div",{className:"ap-proj-bar",role:"img","aria-label":`Share of ${ut($.totalCost)} across ${$.rows.length} projects`,children:$.rows.map(D=>{const P=$.basis==="cost"?D.cost:D.tokens,B=$.denom>0?P/$.denom*100:0;return B<=0?null:o.jsx("span",{className:"ap-proj-seg",style:{width:`${B}%`,background:D.color},title:`${D.label} · ${ut(D.cost)} · ${LS(D.cost,$.totalCost)}${D.tokens?` · ${Bt(D.tokens)} tokens`:""}`},D.key)})}),o.jsxs("div",{className:"ap-proj-totals",children:[o.jsx("span",{className:"ap-proj-total-cost",children:ut($.totalCost)}),o.jsxs("span",{className:"ap-proj-total-tok",children:[Bt($.totalTokens)," tokens"]}),o.jsxs("span",{className:"ap-proj-total-win",children:["· ",M]})]}),gB(u,$.chart.length)&&o.jsxs("div",{className:"ap-proj-days",children:[o.jsxs("div",{className:"ap-proj-days-cap",children:["By day",$.chart.length>1?" · click a bar":""]}),o.jsx("div",{className:"ap-proj-days-plot",role:"img","aria-label":`Spend across ${$.chart.length} day${$.chart.length>1?"s":""}`,children:$.chart.map(D=>{const P=$.maxDay>0?D.total/$.maxDay*100:0,B=m===D.day,W=$.rows.map(G=>({label:G.label,c:D.costByColor.get(G.color)??0})).filter(G=>G.c>0),F=`${Em(Date.parse(`${D.day}T00:00:00`))}, ${ut(D.total)}. ${W.map(G=>`${G.label} ${ut(G.c)}`).join(", ")}`;return o.jsx("button",{type:"button",className:`ap-proj-day${B?" selected":""}`,"aria-pressed":B,"aria-label":F,title:`${D.day} · ${ut(D.total)}`,onClick:()=>y(G=>G===D.day?null:D.day),children:o.jsx("span",{className:"ap-proj-col",style:{height:`${P}%`},children:$.colorOrder.map((G,re)=>{const U=D.costByColor.get(G)??0;return U<=0||D.total<=0?null:o.jsx("span",{className:"ap-proj-colseg",style:{height:`${U/D.total*100}%`,background:G}},re)})})},D.day)})}),(()=>{const D=kB($.chart.length);return o.jsx("div",{className:"ap-proj-days-axis","aria-hidden":"true",children:$.chart.map((P,B)=>o.jsx("div",{className:"ap-proj-axis-cell",children:D(B)?bB(P.day):""},P.day))})})(),(()=>{const D=m?$.chart.find(B=>B.day===m):null;if(!D)return null;const P=$.rows.map(B=>({r:B,c:D.costByColor.get(B.color)??0})).filter(B=>B.c>0);return o.jsxs("div",{className:"ap-proj-day-detail",children:[o.jsxs("div",{className:"ap-proj-day-detail-head",children:[o.jsx("span",{children:Em(Date.parse(`${D.day}T00:00:00`))}),o.jsx("span",{className:"ap-proj-day-detail-total",children:ut(D.total)})]}),P.map(({r:B,c:W})=>o.jsxs("div",{className:"ap-proj-day-detail-row",children:[o.jsx("span",{className:"ap-proj-dot",style:{background:B.color},"aria-hidden":"true"}),o.jsx("span",{className:"ap-proj-day-detail-name",children:B.label}),o.jsx("span",{className:"ap-proj-day-detail-cost",children:ut(W)})]},B.key))]})})()]}),o.jsx("ul",{className:"ap-proj-list",children:$.rows.map((D,P)=>{const B=$.basis==="cost"?D.cost:D.tokens,W=$.denom>0?B/$.denom*100:0,F=v.has(D.key),G=`ap-proj-details-${P}`,re=F&&(!!D.path||!!D.members),U=D.members?`${F?"Hide":"Show"} the ${D.members.length} project${D.members.length>1?"s":""} folded into Other`:`${F?"Hide":"Show"} location for ${D.label}`;return o.jsxs("li",{className:`ap-proj-row${D.muted?" muted":""}${F?" expanded":""}`,children:[o.jsx("span",{className:"ap-proj-dot",style:{background:D.color},"aria-hidden":"true"}),o.jsxs("span",{className:"ap-proj-name",children:[D.label,D.parentLabel&&o.jsxs("span",{className:"ap-proj-parent",children:[" · in ",D.parentLabel]})]}),o.jsx("span",{className:"ap-proj-track",title:`${LS(D.cost,$.totalCost)} of tracked cost`,children:o.jsx("span",{className:"ap-proj-fill",style:{width:`${W}%`,background:D.color}})}),o.jsx("span",{className:"ap-proj-cost",children:ut(D.cost)}),o.jsx("span",{className:"ap-proj-tok",children:Bt(D.tokens)}),o.jsx("button",{type:"button",className:"glyph-btn ap-proj-info","aria-expanded":F,"aria-controls":re?G:void 0,"aria-label":U,onClick:()=>S(Y=>{const z=new Set(Y);return z.has(D.key)?z.delete(D.key):z.add(D.key),z}),children:"ⓘ"}),F&&D.path&&o.jsxs("div",{className:"ap-proj-details",id:G,children:[o.jsx("code",{className:"ap-proj-path",children:$S(D.path)}),o.jsx("button",{type:"button",className:"ap-proj-copy","aria-label":`${ne(D.path)} location for ${D.label}`,onClick:()=>V(D.path,D.label),children:ne(D.path)})]}),F&&D.members&&o.jsx("div",{className:"ap-proj-details ap-proj-other-members",id:G,children:D.members.map(Y=>o.jsxs("div",{className:"ap-proj-other-member",children:[o.jsxs("div",{className:"ap-proj-other-name",children:[Y.label,Y.parentLabel&&o.jsxs("span",{className:"ap-proj-parent",children:[" · in ",Y.parentLabel]})]}),o.jsx("code",{className:"ap-proj-path",children:$S(Y.path)}),o.jsx("span",{className:"ap-proj-cost",children:ut(Y.cost)}),o.jsx("span",{className:"ap-proj-tok",children:Bt(Y.tokens)}),o.jsx("button",{type:"button",className:"ap-proj-copy","aria-label":`${ne(Y.path)} location for ${Y.label}`,onClick:()=>V(Y.path,Y.label),children:ne(Y.path)})]},Y.path))})]},D.key)})}),$.un&&o.jsxs("div",{className:"ap-proj-unattributed",children:[o.jsx("span",{className:"ap-proj-dot",style:{background:wB},"aria-hidden":"true"}),o.jsxs("div",{className:"ap-proj-un-labels",children:[o.jsx("span",{className:"ap-proj-un-title",children:"Unattributed usage"}),o.jsx("span",{className:"ap-proj-un-tag",children:"Excluded from the project totals"})]}),o.jsx("span",{className:"ap-proj-un-cost",children:xB($.un.cost)}),o.jsx("span",{className:"ap-proj-un-tok",children:Bt($.un.tokens)}),o.jsx("div",{className:"ap-proj-note",children:"Work no account could be tied to — from before tracking, or a gap."})]}),o.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:E&&(E.ok?`Copied the location of ${E.label}`:`Could not copy the location of ${E.label} — select it and copy it by hand`)}),o.jsxs("div",{className:"ap-proj-foot",children:[$.reconciled?"Dollars from ccusage · split by activity":"Dollars estimated · ccusage unavailable"," · ",ee]})]})})]})]})}),document.body)}const PS=18,SB=1100,kl=(e,t)=>{const n=Math.sin(e*12.9898+t*78.233)*43758.5453;return n-Math.floor(n)},jB=Array.from({length:PS},(e,t)=>{const n=-72+144*t/(PS-1)+(kl(t,1)-.5)*9,r=(n-90)*(Math.PI/180),s=(54+32*Math.cos(n*Math.PI/180))*(.74+kl(t,2)*.52);return{dx:Math.cos(r)*s,dy:Math.sin(r)*s,rot:(t%2?1:-1)*(100+kl(t,3)*260),delay:Math.round(kl(t,4)*90),dur:760+Math.round(kl(t,5)*260),scale:.8+kl(t,6)*.45,hue:t%4,round:t%3===0}});function DS({anchor:e}){var s;const[t,n]=w.useState(null),r=typeof window<"u"&&((s=window.matchMedia)==null?void 0:s.call(window,"(prefers-reduced-motion: reduce)").matches);return w.useEffect(()=>{if(r)return;const l=e.current;if(!l)return;const c=l.getBoundingClientRect();n({x:c.left+c.width/2,y:c.top+c.height/2});const u=window.setTimeout(()=>n(null),SB);return()=>window.clearTimeout(u)},[e,r]),r||!t?null:Mn.createPortal(o.jsx("div",{className:"confetti",style:{left:`${t.x}px`,top:`${t.y}px`},"aria-hidden":!0,children:jB.map((l,c)=>o.jsx("span",{className:`confetti-bit${l.round?" round":""}`,"data-hue":l.hue,style:{"--dx":`${l.dx.toFixed(1)}px`,"--dy":`${l.dy.toFixed(1)}px`,"--rot":`${l.rot}deg`,"--s":l.scale.toFixed(2),animationDelay:`${l.delay}ms`,animationDuration:`${l.dur}ms, ${l.dur}ms`}},c))}),document.body)}const FM=new Set(["awaiting_url","awaiting_code","registering"]);function _B(e){return e!=null&&FM.has(e)}function qM(e){return e!=null&&e!=="done"&&!FM.has(e)}const EB="the sign-in ended before it finished — the deck restarted, or it was cancelled in another tab",CB="the sign-in did not complete";function TB({state:e,serverError:t,localError:n}){const r=e==="idle";return{title:r?"Sign-in ended":"Sign-in failed",message:n||t||(r?EB:CB)}}function RB({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 AB({started:e,state:t}){return!e||t==="done"?null:{action:"login-cancel"}}const MB="done";function IB(){let e=!1;return{shouldAnnounce(t){return t!==MB?(e=!1,!1):e?!1:(e=!0,!0)}}}function Ob(e,t){return t&&Object.hasOwn(e,t)?e[t]:void 0}const $B={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 ${dn}`,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"},OB={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"},Lb=`claude-swap could not read the login keychain — start ${dn} from a Terminal window rather than a background service`,FS={unreadable_here:{short:"Keychain locked on this Mac",long:`${Lb}.`},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 tf(e){return e&&Object.hasOwn(FS,e)?FS[e]:null}const BM={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 O0(e,t,n){const r=n==null?null:BM[n];if(r)return r;if((e==null?void 0:e.reason)!=="no_cswap"&&/keychain/i.test(Au(e)))return Lb;const s=Ob(OB,e==null?void 0:e.reason);return s||(e==null?void 0:e.reason)||t}function Au(e){return((e==null?void 0:e.output)||(e==null?void 0:e.detail)||(e==null?void 0:e.error)||"").trim()}const LB={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"},PB="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 DB(e){return/\bnpx\b/i.test(e)&&/(command not found|not found|not recognized|ENOENT)/i.test(e)}const FB="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",qB="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",BB=e=>/\b(?:ERR_)?MODULE_NOT_FOUND\b|cannot find (?:module|package)/i.test(e),zB=/node_modules[\\/]npm[\\/]bin[\\/]|\bnpm-prefix\.js\b|\bnp[mx][-.][\w.-]*cli\.js\b/i,UB=/[\\/]_npx[\\/]/i,HB=`the copy of ccusage ${dn} installed for itself`;function WB(e){const t=String((e==null?void 0:e.install)??"").replace(/\s+/g," ").trim();return t.length>240?`${t.slice(0,239)}…`:t}function GX(e,t){const n=VB(e,t),r=WB(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 ${su(n)}`:`there is no managed copy of ccusage on this machine, and the npx fallback failed: ${su(n)}`;case"managed":return`${HB} failed to run: ${su(n)}`;case"path":return e.bin?`the ccusage this deck found at ${e.bin} failed to run: ${su(n)}`:`the ccusage this deck found on your PATH failed to run: ${su(n)}`;default:return n}}const su=e=>/^[A-Z][a-z]/.test(e)?e[0].toLowerCase()+e.slice(1):e;function VB(e,t){const n=Au(e);if(BB(n)){if(UB.test(n))return qB;if(zB.test(n))return FB}if(DB(n))return PB;const r=Ob(LB,e==null?void 0:e.reason);return r||(e==null?void 0:e.reason)||t}function Al(e,t,n){const r=n==null?null:BM[n];if(r)return r;if(e!=null&&e.detail)return e.detail;if(e!=null&&e.error&&qM(e.state))return e.error;const s=Ob($B,e==null?void 0:e.reason);return s||(e!=null&&e.error?e.error:(e==null?void 0:e.reason)||t)}function GB(e,t,n){if(n<=0||Nf(e))return{kind:"pass"};const r=t>=0&&t<n?t:-1;switch(e.key){case"ArrowRight":return{kind:"select",index:r===-1?0:(r+1)%n};case"ArrowLeft":return{kind:"select",index:r===-1?n-1:(r-1+n)%n};case"Home":return{kind:"select",index:0};case"End":return{kind:"select",index:n-1};default:return{kind:"pass"}}}function zM(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 KB(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}`,l=[];return n.alias&&r&&l.push(r),r&&(t.get(r.toLowerCase())??0)>1&&l.push(n.org||`slot ${n.num}`),{num:n.num,label:s,sub:l.length?l.join(" · "):null}})}function YB(e,t){return e.filter(n=>!t.includes(n.num)).map(n=>n.num)}function XB(e,t){return e.includes(t)?e.filter(n=>n!==t):[...e,t]}function ZB(e){return e.length?{action:"share",accounts:[...e]}:null}function QB(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 L0(e){return`${e.email}|${e.org??""}`}function JB(e,t,n){return e&&e.map(r=>L0(r)===t?n:r)}function ez(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 tz(e){const t=e.length;if(!t)return"Nothing to import.";const n=h=>e.filter(m=>m.state===h).length,r=[],s=n("imported");s&&r.push(`${s} of ${t} imported`);const l=n("healed");l&&r.push(`${l} had a dead token replaced`);const c=n("updated");c&&r.push(`${c} updated`);const u=n("present");u&&r.push(`${u} already here`);const f=n("failed");f&&r.push(`${f} did not arrive`);const p=[...new Set(e.map(h=>{var m;return(m=tf(h.check))==null?void 0:m.short}).filter(h=>!!h))];return`${r.join(", ")}${p.length?`, ${p.join(", ")}`:""}.`}const nz=1500,vh=[{id:"login",label:"Sign in"},{id:"paste",label:"Paste a share"}],qS="aa-panel",BS=e=>`aa-tab-${e}`;async function au(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}const P0=ve.forwardRef((e,t)=>o.jsxs("svg",{className:"aa-mark",viewBox:"0 0 44 44","aria-hidden":!0,ref:t,children:[o.jsx("circle",{className:"aa-mark-ring",cx:"22",cy:"22",r:"20"}),o.jsx("path",{className:"aa-mark-tick",d:"M13.5 22.5 L19.5 28.5 L31 17"})]}));P0.displayName="SuccessMark";function rz({onClose:e,onChanged:t}){const[n,r]=w.useState("login"),[s,l]=w.useState(null),[c,u]=w.useState(""),[f,p]=w.useState(""),[h,m]=w.useState(!1),[y,v]=w.useState(null),[S,b]=w.useState(null),[_,k]=w.useState(null),[j,E]=w.useState(null),C=w.useRef(""),R=w.useRef(!1),I=w.useRef(!1),O=w.useRef(null),H=w.useRef(null),q=w.useRef(null),$=w.useRef(null),V=w.useRef([]),ne=w.useRef(!1),ee=w.useCallback(()=>{const z=AB({started:R.current,state:s==null?void 0:s.state});z&&au(z).catch(()=>{}),e()},[e,s==null?void 0:s.state]),M=pn(ee,{focusRef:q}),Z=w.useCallback(async()=>{if(!Ps(I.current))return;I.current=!0,m(!0),v(null),R.current=!0;const z=await au({action:"login"}).catch(()=>null);if(I.current=!1,m(!1),!(z!=null&&z.ok)){v(Al(z,"could not start the sign-in"));return}l(z)},[]);w.useEffect(()=>{if(!_B(s==null?void 0:s.state))return;const z=window.setInterval(async()=>{try{const ie=await fetch("/api/claude-accounts/login");ie.ok&&l(await ie.json())}catch{}},nz);return()=>window.clearInterval(z)},[s]);const K=w.useRef(t);K.current=t;const D=w.useState(IB)[0];w.useEffect(()=>{var z;(s==null?void 0:s.state)==="awaiting_code"&&((z=O.current)==null||z.focus()),D.shouldAnnounce(s==null?void 0:s.state)&&K.current()},[s==null?void 0:s.state,D]),w.useEffect(()=>{var z;n==="paste"&&!ne.current&&((z=H.current)==null||z.focus()),ne.current=!1},[n]);const P=w.useCallback(z=>{var le;const ie=GB(z,vh.findIndex(ge=>ge.id===n),vh.length);ie.kind!=="pass"&&(z.preventDefault(),ne.current=!0,r(vh[ie.index].id),(le=V.current[ie.index])==null||le.focus())},[n]),B=w.useCallback(async()=>{var ie;if(!Ps(I.current))return;I.current=!0,m(!0),v(null);const z=await au({action:"login-code",code:c}).catch(()=>null);if(I.current=!1,m(!1),!(z!=null&&z.ok)){v(Al(z,"the code was not accepted")),z!=null&&z.state&&l(z),(ie=O.current)==null||ie.select();return}u(""),l(z)},[c,s]),W=w.useCallback(async()=>{if(!Ps(I.current))return;I.current=!0,m(!0),v(null);const z=await au({action:"import",blob:f}).catch(()=>null);if(I.current=!1,m(!1),!(z!=null&&z.ok)){v(Al(z,"the import failed"));return}C.current=f,p(""),E(null),b(z.results??[]),t()},[f,t]),F=w.useCallback(async z=>{const ie=L0(z);if(!Ps(I.current)||!C.current)return;I.current=!0,m(!0),k(ie),E(null);const le=await au({action:"import",blob:C.current,force:!0,only:{email:z.email,org:z.org??""}}).catch(()=>null);if(I.current=!1,m(!1),k(null),!(le!=null&&le.ok)){E({key:ie,text:Al(le,"that account could not be updated")});return}const ge=(le.results??[])[0];ge&&b(Ne=>JB(Ne,ie,ge)),t()},[t]),G=(s==null?void 0:s.state)==="done"?s.account:null,re=RB({restored:s==null?void 0:s.restored,activeAccount:s==null?void 0:s.activeAccount}),U=qM(s==null?void 0:s.state)||!!(y&&R.current&&!h),Y=TB({state:s==null?void 0:s.state,serverError:s==null?void 0:s.error,localError:y});return Mn.createPortal(o.jsx("div",{className:"modal-backdrop",onClick:ee,role:"presentation",children:o.jsxs("div",{ref:M,className:"modal aa-modal",onClick:z=>z.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Add a Claude account",children:[o.jsxs("header",{className:"modal-head",children:[o.jsx("div",{className:"modal-title",children:o.jsx("span",{className:"aa-tabs",role:"tablist","aria-label":"How to add the account",onKeyDown:P,children:vh.map((z,ie)=>o.jsx("button",{type:"button",role:"tab",id:BS(z.id),ref:le=>{V.current[ie]=le},"aria-selected":n===z.id,"aria-controls":qS,tabIndex:n===z.id?0:-1,className:`aa-tab${n===z.id?" on":""}`,onClick:()=>{ne.current=!1,r(z.id)},children:z.label},z.id))})}),o.jsx("div",{className:"modal-actions",children:o.jsx("button",{type:"button",className:"glyph-btn",onClick:ee,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),o.jsx("section",{className:"modal-body aa-body",id:qS,role:"tabpanel","aria-labelledby":BS(n),children:n==="login"?G?o.jsxs("div",{className:"aa-done",children:[o.jsx(P0,{ref:$}),o.jsx(DS,{anchor:$}),o.jsx("h4",{children:G.added?`Account ${G.num} added`:"Credentials refreshed"}),o.jsxs("p",{className:"aa-note",children:[o.jsx("strong",{children:G.email}),G.added?re?" 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."]}),re?o.jsx("p",{className:"aa-note aa-warn",role:"status",children:re}):null,o.jsx("button",{type:"button",className:"btn primary",onClick:ee,children:"Done"})]}):(s==null?void 0:s.state)==="awaiting_code"||(s==null?void 0:s.state)==="registering"?o.jsxs(o.Fragment,{children:[o.jsxs("div",{className:"aa-step",children:[o.jsx("h4",{children:"1 · Approve in the browser"}),o.jsx("p",{className:"aa-note",children:"A tab should have opened. If not, use this link:"}),o.jsx("a",{className:"aa-link",href:s.url??"#",target:"_blank",rel:"noreferrer noopener",children:s.url})]}),o.jsxs("div",{className:"aa-step",children:[o.jsx("h4",{children:"2 · Paste a code, if the page shows one"}),o.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."}),o.jsxs("div",{className:"aa-field",children:[o.jsx("input",{ref:O,type:"text",value:c,onChange:z=>u(z.target.value),onKeyDown:z=>{z.key==="Enter"&&c.trim()&&!h&&B()},placeholder:"paste the code here",spellCheck:!1,autoComplete:"off","aria-label":"Sign-in code",disabled:s.state==="registering"}),o.jsx("button",{type:"button",className:"btn primary",...Qa(h,!c.trim()||s.state==="registering"),onClick:B,children:s.state==="registering"?"registering…":"Continue"})]}),(y||s.error)&&o.jsx("p",{className:"aa-err",children:y??s.error}),o.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."})]})]}):U?o.jsxs("div",{className:"aa-step",children:[o.jsx("h4",{children:Y.title}),o.jsx("p",{className:"aa-err",children:Y.message}),o.jsx("button",{type:"button",className:"btn",onClick:()=>{R.current=!1,l(null),v(null),Z()},children:"Try again"})]}):h||R.current?o.jsx("div",{className:"aa-step",children:o.jsx("p",{className:"aa-note",children:"Asking the claude CLI for a sign-in link…"})}):o.jsxs("div",{className:"aa-step aa-primer",children:[o.jsx("h4",{children:"Sign in to Anthropic"}),o.jsx("p",{className:"aa-note",children:"Opens a browser tab where you approve the sign-in. It normally completes by itself; only if the page hands you a code does it need pasting back here. claude-swap records the account when it completes, and the account you are using now stays active."}),o.jsx("div",{className:"aa-actions",children:o.jsx("button",{type:"button",ref:q,className:"btn primary",onClick:Z,children:"Open the sign-in page"})})]}):S?(()=>{const z=S.filter(le=>le.state==="imported").length,ie=S.some(le=>tf(le.check));return o.jsxs("div",{className:"aa-done",children:[!ie&&o.jsx(P0,{ref:$}),z>0&&!ie&&o.jsx(DS,{anchor:$}),o.jsx("h4",{children:tz(S)}),S.length>0&&o.jsx("ul",{className:"aa-results",children:S.map(le=>{const ge=L0(le),Ne=tf(le.check);return o.jsxs("li",{className:`aa-result ${le.state}`,children:[o.jsx("span",{className:"aa-result-who",children:le.email||(le.num?`slot ${le.num}`:"an account")}),o.jsx("span",{className:"aa-result-what",children:ez(le.state)}),le.state==="present"&&o.jsx("button",{type:"button",className:"aa-result-fix","aria-busy":_===ge,title:`Overwrite the stored login for ${le.email} with the one in this share. Do this when that account has stopped working here; if it works, leave it.`,onClick:()=>F(le),children:_===ge?"updating…":"update anyway"}),Ne&&o.jsx("span",{className:"aa-result-err",children:Ne.long}),(j==null?void 0:j.key)===ge&&o.jsx("span",{className:"aa-result-err",children:j.text})]},ge)})}),o.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",o.jsx("strong",{children:" update anyway"}),"."]}),o.jsxs("div",{className:"aa-actions",children:[o.jsx("button",{type:"button",className:"btn primary",onClick:ee,children:"Done"}),o.jsx("button",{type:"button",className:"btn",onClick:()=>{C.current="",E(null),b(null)},children:"Import another"})]})]})})():o.jsxs("div",{className:"aa-step",children:[o.jsx("h4",{children:"Paste an account shared from another deck"}),o.jsxs("div",{className:"aa-field",children:[o.jsx("input",{ref:H,type:"text",value:f,onChange:z=>p(z.target.value),onKeyDown:z=>{z.key==="Enter"&&f.trim()&&!h&&W()},placeholder:"ccdeck2:…",spellCheck:!1,autoComplete:"off","aria-label":"Shared account"}),o.jsx("button",{type:"button",className:"btn primary",...Qa(h,!f.trim()),onClick:W,children:h?"importing…":"Import"})]}),y&&o.jsx("p",{className:"aa-err",children:y}),o.jsxs("p",{className:"aa-note",children:["Use ",o.jsx("strong",{children:"share"})," on one account in the other deck, or ",o.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)}const sz=6;function az(e,t){const n=e.filter(u=>u.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",l=t.strained&&!t.armed?oz(n):null,c=[r];return l!=null&&c.push(`${l}% free`),c.push(t.armed?`auto ${t.threshold??"on"}${t.threshold?"%":""}`:"auto off"),{text:c.join(" · "),tone:s,free:l}}function oz(e){const t=e.map(n=>n.headroom).filter(n=>typeof n=="number");return t.length?Math.max(...t):null}function iz(e){const t=[...e].sort((s,l)=>{if(s.ready!==l.ready)return s.ready?-1:1;if(!s.ready)return s.name.localeCompare(l.name);const c=s.headroom,u=l.headroom;return c==null&&u==null?s.name.localeCompare(l.name):c==null?1:u==null?-1:u-c}),n=t.slice(0,sz),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 UM({title:e,steps:t,finish:n,aside:r,onClose:s}){const l=w.useRef(null),c=pn(s,{focusRef:l}),[u,f]=w.useState(0),p=u===t.length-1,h=t[u],m=S=>f(Math.max(0,Math.min(t.length-1,S))),y=S=>{S.key!=="ArrowRight"&&S.key!=="ArrowLeft"||(S.preventDefault(),S.stopPropagation(),m(S.key==="ArrowRight"?u+1:u-1))},v=()=>{if(!p){m(u+1);return}n?n.act():s()};return Mn.createPortal(o.jsx("div",{className:"modal-backdrop",onClick:s,role:"presentation",children:o.jsxs("div",{ref:c,className:"modal guide",onClick:S=>S.stopPropagation(),onKeyDown:y,role:"dialog","aria-modal":"true","aria-labelledby":"guide-title",children:[o.jsxs("header",{className:"modal-head",children:[o.jsxs("div",{className:"modal-title",children:[o.jsx("span",{id:"guide-title",className:"modal-tool-name",children:e}),o.jsxs("span",{className:"modal-tool-id",children:[u+1," / ",t.length]})]}),o.jsx("div",{className:"modal-actions",children:o.jsx("button",{type:"button",className:"glyph-btn",onClick:s,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),o.jsxs("section",{className:"modal-body",children:[o.jsx("div",{className:"guide-stage",children:h.art},u),o.jsx("p",{className:"guide-line","aria-live":"polite",children:h.line}),o.jsx("p",{className:"guide-tip",children:h.tip??""}),o.jsxs("div",{className:"guide-foot",children:[o.jsx("div",{className:"guide-dots",children:t.map((S,b)=>o.jsx("button",{type:"button",className:"glyph-btn guide-dot","aria-label":`Step ${b+1} of ${t.length}`,"aria-current":b===u?"step":void 0,onClick:()=>m(b)},b))}),p&&r&&o.jsx("button",{type:"button",className:"ap-lan-word guide-aside",onClick:r.act,children:r.label}),u>0&&o.jsx("button",{type:"button",className:"btn",onClick:()=>m(u-1),children:"Back"}),o.jsx("button",{ref:l,type:"button",className:"btn primary",onClick:v,children:p?(n==null?void 0:n.label)??"Done":"Next"})]})]})]})}),document.body)}const D0={ok:"ga-ok",warn:"ga-warn",accent:"ga-accent",flight:"ga-flight"};function Br({children:e}){return o.jsx("svg",{className:"guide-art",viewBox:"0 0 440 200","aria-hidden":!0,focusable:"false",children:e})}function qr({x:e,y:t=34,w:n=176,h:r=132,label:s}){return o.jsxs(o.Fragment,{children:[s&&o.jsx("text",{x:e+2,y:t-9,className:"ga-cap",children:s}),o.jsx("rect",{x:e,y:t,width:n,height:r,rx:10,className:"ga-screen"})]})}function ys({x:e,y:t,email:n,state:r,tone:s,bars:l}){return o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:e+3,cy:t-4,r:3,className:D0[s]}),o.jsx("text",{x:e+12,y:t,className:"ga-t ga-mono",children:n}),o.jsx("text",{x:e+12,y:t+16,className:`ga-s ${D0[s]}`,children:r}),l==null?void 0:l.map((c,u)=>o.jsxs("g",{children:[o.jsx("text",{x:e,y:t+40+u*18,className:"ga-s",children:u?"7d":"5h"}),o.jsx("rect",{x:e+22,y:t+35+u*18,width:96,height:4,rx:2,className:"ga-track"}),o.jsx("rect",{x:e+22,y:t+35+u*18,width:96*c/100,height:4,rx:2,className:"ga-accent"}),o.jsxs("text",{x:e+148,y:t+40+u*18,className:"ga-s ga-accent",textAnchor:"end",children:[c,"%"]})]},u))]})}function HM({x:e,y:t,on:n}){return o.jsxs(o.Fragment,{children:[o.jsx("rect",{x:e,y:t,width:30,height:18,rx:9,className:n?"ga-switch-on":"ga-switch"}),o.jsx("circle",{cx:n?e+21:e+9,cy:t+9,r:6,className:n?"ga-knob-on":"ga-knob"})]})}function xh({x:e,y:t,name:n,here:r=!0}){return o.jsxs(o.Fragment,{children:[o.jsx("circle",{cx:e+3,cy:t-4,r:3,className:r?"ga-ok":"ga-dim"}),o.jsx("text",{x:e+12,y:t,className:r?"ga-t":"ga-s",children:n})]})}function zS({x:e,y:t,on:n}){return n?o.jsxs(o.Fragment,{children:[o.jsx("rect",{x:e,y:t,width:12,height:12,rx:3,className:"ga-accent"}),o.jsx("path",{d:`M${e+3} ${t+6.2}l2.3 2.3 4-4.6`,className:"ga-tick"})]}):o.jsx("rect",{x:e+.5,y:t+.5,width:11,height:11,rx:3,className:"ga-box"})}function US({x:e,y:t,d:n}){return o.jsx("path",{d:n,transform:`translate(${e} ${t})`,className:"ga-glyph"})}function Pb({x:e,y:t}){return o.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 Db(){return o.jsxs(o.Fragment,{children:[o.jsx("circle",{r:9,className:"ga-key-bed"}),o.jsxs("g",{transform:"translate(-6 -6) scale(0.857)",className:"ga-key",children:[o.jsx("circle",{cx:4.6,cy:7,r:2.6}),o.jsx("path",{d:"M7.2 7h5.2M10.6 7v2.2M12.4 7v1.6"})]})]})}function Ml({x:e,y:t,w:n,title:r,sub:s,tone:l}){return o.jsxs(o.Fragment,{children:[o.jsx("rect",{x:e,y:t,width:n,height:40,rx:8,className:"ga-screen"}),o.jsx("rect",{x:e+6,y:t+10,width:3,height:20,rx:1.5,className:D0[l]}),o.jsx("text",{x:e+16,y:t+17,className:"ga-t ga-strong",children:r}),o.jsx("text",{x:e+16,y:t+31,className:"ga-s",children:s})]})}function Pl({x:e,y:t,label:n,live:r}){return o.jsxs(o.Fragment,{children:[o.jsx("rect",{x:e,y:t,width:46,height:20,rx:10,className:r?"ga-chip-live":"ga-chip"}),o.jsx("text",{x:e+23,y:t+14,className:"ga-s ga-mono",textAnchor:"middle",children:n})]})}function nf({x:e,y:t}){return o.jsxs(o.Fragment,{children:[o.jsx("text",{x:e,y:t,className:"ga-cap",children:"LOCAL NETWORK"}),o.jsx(HM,{x:e+118,y:t-13,on:!0})]})}function lz(){return o.jsxs(Br,{children:[o.jsx("rect",{x:14,y:14,width:206,height:172,rx:10,className:"ga-screen"}),o.jsx("text",{x:28,y:38,className:"ga-t ga-strong",children:"Sessions"}),o.jsx("text",{x:206,y:38,className:"ga-s ga-warn",textAnchor:"end",children:"1 waiting"}),o.jsx("rect",{x:20,y:50,width:194,height:42,rx:6,className:"ga-bed-warn"}),o.jsx("circle",{cx:33,cy:64,r:7,className:"ga-ring-warn ga-ping"}),o.jsx("circle",{cx:33,cy:64,r:3.5,className:"ga-warn"}),o.jsx("text",{x:44,y:68,className:"ga-t",children:"api-server"}),o.jsx("text",{x:44,y:83,className:"ga-s ga-warn",children:"waiting 6m · Bash"}),o.jsx("circle",{cx:33,cy:108,r:3.5,className:"ga-flight"}),o.jsx("text",{x:44,y:112,className:"ga-t",children:"docs-site"}),o.jsx("text",{x:44,y:127,className:"ga-s",children:"running · 12 tools"}),o.jsx("circle",{cx:33,cy:150,r:3.5,className:"ga-ok"}),o.jsx("text",{x:44,y:154,className:"ga-t",children:"billing"}),o.jsx("text",{x:44,y:169,className:"ga-s",children:"done · $0.84"}),o.jsx("path",{d:"M216 71C234 71 230 100 244 100",className:"ga-arc"}),o.jsx("path",{d:"M239 96l5 4-5 4",className:"ga-arrow"}),o.jsx("rect",{x:248,y:44,width:178,height:112,rx:10,className:"ga-screen"}),o.jsx("text",{x:262,y:64,className:"ga-cap",children:"API-SERVER"}),o.jsx("line",{x1:248,y1:74,x2:426,y2:74,className:"ga-line"}),o.jsx("text",{x:262,y:96,className:"ga-s ga-mono",children:"Bash(npm test)"}),o.jsx("text",{x:262,y:116,className:"ga-t ga-mono ga-warn",children:"Allow this command?"}),o.jsx("text",{x:262,y:136,className:"ga-s ga-mono",children:"> 1. Yes 2. No"})]})}function cz(){return o.jsxs(Br,{children:[o.jsx("path",{d:"M136 100C166 100 166 38 196 38",className:"ga-edge ga-flow"}),o.jsx("path",{d:"M136 100H196",className:"ga-edge ga-flow"}),o.jsx("path",{d:"M136 100C166 100 166 162 196 162",className:"ga-edge-done"}),o.jsx("path",{d:"M308 38H326M308 100H326",className:"ga-edge"}),o.jsx(Ml,{x:20,y:80,w:116,title:"main",sub:"Opus 5 · 9 tools",tone:"accent"}),o.jsx(Ml,{x:196,y:18,w:112,title:"explore",sub:"Haiku · 14 tools",tone:"flight"}),o.jsx(Ml,{x:196,y:80,w:112,title:"tests",sub:"Sonnet · 6 tools",tone:"flight"}),o.jsx(Ml,{x:196,y:142,w:112,title:"review",sub:"done · 38s",tone:"ok"}),o.jsx(Pl,{x:326,y:28,label:"Read"}),o.jsx(Pl,{x:380,y:28,label:"Grep",live:!0}),o.jsx(Pl,{x:326,y:90,label:"Bash",live:!0})]})}function HS({x:e,y:t,label:n,pct:r,note:s}){return o.jsxs(o.Fragment,{children:[o.jsx("text",{x:e,y:t,className:"ga-s",children:n}),o.jsxs("text",{x:e+194,y:t,className:"ga-s ga-accent",textAnchor:"end",children:[r,"%"]}),o.jsx("rect",{x:e,y:t+7,width:194,height:5,rx:2.5,className:"ga-track"}),o.jsx("rect",{x:e,y:t+7,width:194*r/100,height:5,rx:2.5,className:"ga-accent"}),o.jsx("text",{x:e,y:t+26,className:"ga-s",children:s})]})}function uz(){return o.jsxs(Br,{children:[o.jsx("rect",{x:14,y:30,width:172,height:140,rx:10,className:"ga-screen"}),o.jsx("text",{x:30,y:56,className:"ga-cap",children:"THIS SESSION"}),o.jsx("text",{x:30,y:98,className:"ga-big",children:"$3.66"}),o.jsx("text",{x:30,y:122,className:"ga-s",children:"Opus 5 · 1.2M tokens"}),o.jsx("text",{x:30,y:150,className:"ga-s",children:"$21.40 today"}),o.jsx("rect",{x:200,y:30,width:226,height:140,rx:10,className:"ga-screen"}),o.jsx("text",{x:216,y:56,className:"ga-cap",children:"CLAUDE QUOTA"}),o.jsx(HS,{x:216,y:80,label:"5-hour window",pct:24,note:"resets in 53m"}),o.jsx(HS,{x:216,y:124,label:"7-day window",pct:61,note:"resets in 4d"})]})}function dz(){return o.jsxs(Br,{children:[o.jsx("rect",{x:14,y:40,width:172,height:120,rx:10,className:"ga-canvas"}),o.jsx(Ml,{x:30,y:80,w:140,title:"tests",sub:"Sonnet 5 · 6 tools",tone:"flight"}),o.jsx(Pb,{x:156,y:106}),o.jsx("path",{d:"M170 92C186 92 184 60 200 60",className:"ga-arc"}),o.jsx("path",{d:"M195 56l5 4-5 4",className:"ga-arrow"}),o.jsx(qr,{x:200,y:22,w:226,h:160}),o.jsx("text",{x:214,y:46,className:"ga-t ga-strong",children:"tests"}),o.jsx("text",{x:412,y:46,className:"ga-s",textAnchor:"end",children:"Sonnet 5 · 38s"}),o.jsx("line",{x1:200,y1:56,x2:426,y2:56,className:"ga-line"}),o.jsx("text",{x:214,y:76,className:"ga-cap",children:"PROMPT"}),o.jsx("text",{x:214,y:92,className:"ga-t",children:"Run the suite and fix what fails"}),o.jsx("text",{x:214,y:116,className:"ga-cap",children:"TOOLS · 6"}),o.jsx(Pl,{x:214,y:122,label:"Read"}),o.jsx(Pl,{x:266,y:122,label:"Edit"}),o.jsx(Pl,{x:318,y:122,label:"Bash",live:!0}),o.jsx("text",{x:214,y:164,className:"ga-cap",children:"TOKENS"}),o.jsx("text",{x:214,y:178,className:"ga-s ga-mono",children:"41k in · 2.1k out · $0.12"})]})}function hz(){const e=[18,24,28,14,22,26,30,16,24,28,20,26];return o.jsxs(Br,{children:[o.jsx(qr,{x:14,y:20,w:412,h:160}),o.jsx("text",{x:28,y:44,className:"ga-t ga-strong",children:"This machine"}),o.jsx("text",{x:412,y:44,className:"ga-s",textAnchor:"end",children:"12 cores · up 10d"}),o.jsx("line",{x1:14,y1:56,x2:426,y2:56,className:"ga-line"}),o.jsx("text",{x:28,y:76,className:"ga-cap",children:"CORES"}),e.map((t,n)=>o.jsxs("g",{children:[o.jsx("rect",{x:28+n*15,y:82,width:10,height:30,rx:2,className:"ga-track"}),o.jsx("rect",{x:28+n*15,y:112-t,width:10,height:t,rx:2,className:"ga-accent"})]},n)),o.jsx("text",{x:28,y:136,className:"ga-cap",children:"MEMORY"}),o.jsx("rect",{x:28,y:143,width:178,height:5,rx:2.5,className:"ga-track"}),o.jsx("rect",{x:28,y:143,width:105,height:5,rx:2.5,className:"ga-accent"}),o.jsx("text",{x:28,y:165,className:"ga-s",children:"18.9 GB of 32.0 GB"}),o.jsx("text",{x:240,y:76,className:"ga-cap",children:"THERMAL"}),o.jsx("text",{x:240,y:100,className:"ga-big",children:"66 °C"}),o.jsx("text",{x:240,y:118,className:"ga-s ga-ok",children:"running at full speed"}),o.jsx("text",{x:240,y:142,className:"ga-cap",children:"BUSIEST PROCESSES"}),o.jsx("text",{x:240,y:160,className:"ga-s ga-mono",children:"node · claude"}),o.jsx("text",{x:412,y:160,className:"ga-s ga-mono",textAnchor:"end",children:"38%"}),o.jsx("text",{x:240,y:176,className:"ga-s ga-mono",children:"esbuild"}),o.jsx("text",{x:412,y:176,className:"ga-s ga-mono",textAnchor:"end",children:"21%"})]})}function fz(){return o.jsxs(Br,{children:[o.jsx("rect",{x:14,y:40,width:188,height:120,rx:10,className:"ga-screen"}),o.jsx("text",{x:28,y:60,className:"ga-cap",children:"~/MY-PROJECT"}),o.jsx("line",{x1:14,y1:70,x2:202,y2:70,className:"ga-line"}),o.jsxs("text",{x:28,y:100,className:"ga-t ga-mono",children:[o.jsx("tspan",{className:"ga-accent",children:"$"})," claude"]}),o.jsx("rect",{x:86,y:90,width:7,height:13,className:"ga-caret ga-blink"}),o.jsx("text",{x:28,y:130,className:"ga-s ga-mono",children:"or: codex"}),o.jsx("path",{d:"M210 100H238",className:"ga-arc"}),o.jsx("path",{d:"M233 95l6 5-6 5",className:"ga-arrow"}),o.jsx("rect",{x:250,y:40,width:176,height:120,rx:10,className:"ga-canvas"}),o.jsx("g",{className:"ga-pop",children:o.jsx(Ml,{x:278,y:80,w:120,title:"my-project",sub:"Opus 5 · live",tone:"accent"})})]})}function pz(){return o.jsxs(Br,{children:[o.jsx(qr,{x:14,y:16,w:232,h:170}),o.jsx("text",{x:28,y:40,className:"ga-t ga-strong",children:"Claude accounts"}),o.jsx(US,{x:196,y:33,d:"M7 2.2v9.6M2.2 7h9.6"}),o.jsx(US,{x:220,y:33,d:"M3.3 10.7L10.7 3.3M5.2 3.3h5.5v5.5"}),o.jsx("line",{x1:14,y1:52,x2:246,y2:52,className:"ga-line"}),o.jsx(ys,{x:28,y:74,email:"work@team.dev",state:"working",tone:"ok",bars:[24,61]}),o.jsx("rect",{x:190,y:62,width:44,height:18,rx:9,className:"ga-accent"}),o.jsx("text",{x:212,y:74,className:"ga-s ga-on-accent",textAnchor:"middle",children:"active"}),o.jsx("line",{x1:14,y1:140,x2:246,y2:140,className:"ga-line"}),o.jsx(ys,{x:28,y:160,email:"personal@me.dev",state:"signed in",tone:"ok"}),o.jsx("rect",{x:188,y:148,width:46,height:18,rx:9,className:"ga-chip"}),o.jsx("text",{x:211,y:160,className:"ga-s",textAnchor:"middle",children:"switch"}),o.jsx(Pb,{x:221,y:161}),o.jsx("path",{d:"M250 40C270 40 262 78 282 78",className:"ga-arc"}),o.jsx("path",{d:"M277 74l5 4-5 4",className:"ga-arrow"}),o.jsx(qr,{x:282,y:62,w:144,h:64,label:"ANOTHER MACHINE"}),o.jsx("g",{className:"ga-pop",children:o.jsx(ys,{x:296,y:92,email:"work@team.dev",state:"shared here",tone:"ok"})})]})}function mz(){return o.jsxs(Br,{children:[o.jsx(qr,{x:14,label:"THIS MACHINE"}),o.jsx(nf,{x:28,y:60}),o.jsx("g",{className:"ga-swap-out",children:o.jsx(ys,{x:28,y:98,email:"work@team.dev",state:"login expired",tone:"warn"})}),o.jsx("g",{className:"ga-swap-in",children:o.jsx(ys,{x:28,y:98,email:"work@team.dev",state:"working again",tone:"ok",bars:[24,61]})}),o.jsx(qr,{x:250,label:"ANOTHER MACHINE"}),o.jsx(nf,{x:264,y:60}),o.jsx(ys,{x:264,y:98,email:"work@team.dev",state:"working",tone:"ok",bars:[24,61]}),o.jsx("path",{d:"M246 120C234 80 206 80 194 120",className:"ga-arc"}),o.jsx("g",{className:"ga-travel ga-travel-low",transform:"translate(220 90)",children:o.jsx(Db,{})})]})}const gz=[{art:o.jsx(lz,{}),line:"Sessions waiting on you top the session list, longest wait first.",tip:"A tone and a system notification when one stops to ask. The speaker in the topbar."},{art:o.jsx(cz,{}),line:"Every agent and subagent is a node. Tool calls light up as they run."},{art:o.jsx(dz,{}),line:"Double-click any node: its prompt, every tool call, tokens and timing."},{art:o.jsx(uz,{}),line:"What each session costs, and how much quota is left."},{art:o.jsx(hz,{}),line:"Cores, memory and heat while the agents run, and what is hogging them."},{art:o.jsx(pz,{}),line:"Several Claude accounts: switch, add one, share one to another machine."},{art:o.jsx(mz,{}),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:o.jsx(fz,{}),line:"Run claude or codex in any folder. It shows up here on its own."}];function yz(){return o.jsxs(Br,{children:[o.jsx(qr,{x:14,label:"THIS MACHINE"}),o.jsx(ys,{x:28,y:64,email:"work@team.dev",state:"login expired",tone:"warn"}),o.jsx("rect",{x:40,y:94,width:86,height:20,rx:10,className:"ga-pill-warn"}),o.jsx("text",{x:83,y:108,className:"ga-s ga-warn",textAnchor:"middle",children:"sign in again"}),o.jsx("line",{x1:198,y1:100,x2:242,y2:100,className:"ga-off"}),o.jsx(qr,{x:250,label:"ANOTHER MACHINE"}),o.jsx(ys,{x:264,y:64,email:"work@team.dev",state:"working",tone:"ok",bars:[24,61]})]})}function wz(){return o.jsxs(Br,{children:[o.jsx(qr,{x:14,label:"THIS MACHINE"}),o.jsx(nf,{x:28,y:60}),o.jsx(xh,{x:28,y:92,name:"Ana's MacBook"}),o.jsx(xh,{x:28,y:114,name:"Dorin's PC"}),o.jsx(qr,{x:250,label:"ANOTHER MACHINE"}),o.jsx(nf,{x:264,y:60}),o.jsx(xh,{x:264,y:92,name:"Your MacBook"}),o.jsx(xh,{x:264,y:114,name:"Dorin's PC"}),o.jsx("line",{x1:196,y1:100,x2:244,y2:100,className:"ga-arc"}),o.jsx("circle",{cx:220,cy:100,r:10,className:"ga-ring ga-ping"}),o.jsx("circle",{cx:220,cy:100,r:10,className:"ga-ring ga-ping ga-ping-2"}),o.jsx("circle",{cx:220,cy:100,r:3,className:"ga-accent"})]})}function vz(){return o.jsxs(Br,{children:[o.jsx("rect",{x:90,y:18,width:260,height:164,rx:10,className:"ga-screen"}),o.jsx("text",{x:106,y:42,className:"ga-t ga-strong",children:"This deck on the network"}),o.jsx("line",{x1:90,y1:54,x2:350,y2:54,className:"ga-line"}),o.jsx("text",{x:106,y:76,className:"ga-cap",children:"SHARE THESE ACCOUNTS"}),o.jsx(zS,{x:106,y:88,on:!0}),o.jsx("text",{x:126,y:98,className:"ga-t ga-mono",children:"work@team.dev"}),o.jsx(zS,{x:106,y:112}),o.jsx("text",{x:126,y:122,className:"ga-s ga-mono",children:"personal@me.dev"}),o.jsx("text",{x:106,y:150,className:"ga-cap",children:"PAIRING"}),o.jsx("text",{x:106,y:168,className:"ga-s",children:"Say yes to every deck that asks"}),o.jsx(HM,{x:304,y:157,on:!0}),o.jsx(Pb,{x:115,y:97})]})}function xz(){return o.jsxs(Br,{children:[o.jsx(qr,{x:14,label:"THIS MACHINE"}),o.jsx("g",{className:"ga-swap-out",children:o.jsx(ys,{x:28,y:64,email:"work@team.dev",state:"login expired",tone:"warn"})}),o.jsx("g",{className:"ga-swap-in",children:o.jsx(ys,{x:28,y:64,email:"work@team.dev",state:"working again",tone:"ok",bars:[24,61]})}),o.jsx(qr,{x:250,label:"ANOTHER MACHINE"}),o.jsx(ys,{x:264,y:64,email:"work@team.dev",state:"working",tone:"ok",bars:[24,61]}),o.jsx("path",{d:"M246 96C234 56 206 56 194 96",className:"ga-arc"}),o.jsx("g",{className:"ga-travel",transform:"translate(220 66)",children:o.jsx(Db,{})})]})}const bz=[{art:o.jsx(yz,{}),line:"A login can expire on one machine while it still works on another."},{art:o.jsx(wz,{}),line:"Both decks are on. They find each other and ask to pair.",tip:"Not showing up? The + in the section reaches a machine by address or invite."},{art:o.jsx(vz,{}),line:"Tick which logins this machine may hand out. Nothing is shared until you do."},{art:o.jsx(xz,{}),line:"An expired login is copied from a paired machine within a minute."}];function kz(){return o.jsxs("svg",{className:"guide-art",viewBox:"0 0 232 60","aria-hidden":!0,focusable:"false",children:[o.jsx("rect",{x:1,y:14,width:78,height:42,rx:7,className:"ga-screen"}),o.jsx("circle",{cx:13,cy:29,r:3,className:"ga-warn"}),o.jsx("rect",{x:21,y:27,width:46,height:4,rx:2,className:"ga-track"}),o.jsx("rect",{x:13,y:39,width:40,height:3,rx:1.5,className:"ga-track"}),o.jsx("rect",{x:153,y:14,width:78,height:42,rx:7,className:"ga-screen"}),o.jsx("circle",{cx:165,cy:29,r:3,className:"ga-ok"}),o.jsx("rect",{x:173,y:27,width:46,height:4,rx:2,className:"ga-track"}),o.jsx("rect",{x:165,y:39,width:40,height:3,rx:1.5,className:"ga-accent"}),o.jsx("path",{d:"M150 36C138 6 94 6 82 36",className:"ga-arc"}),o.jsx("g",{transform:"translate(116 13)",children:o.jsx(Db,{})})]})}const Nz={panel:"Nothing here is stuck: whoever pastes an invite is the one dialling out. Ask them for one and paste it behind the + 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."},Sz=1600;function WM({reach:e,where:t}){const[n,r]=w.useState(!1),s=w.useRef(!0);w.useEffect(()=>()=>{s.current=!1},[]);const l=(e==null?void 0:e.steps)??[],c=w.useCallback(async()=>{await hi(l.join(`
91
+ `))&&s.current&&(r(!0),window.setTimeout(()=>{s.current&&r(!1)},Sz))},[l]);if(!(e!=null&&e.blocked))return null;const u=e.shell==="sh";return o.jsxs("div",{className:"ap-lan-reach",children:[o.jsx("p",{className:"lan-warn",children:e.text}),o.jsx("p",{className:"lan-note",children:Nz[t]}),l.length>0&&o.jsxs("details",{className:"ap-lan-reach-fix",children:[o.jsx("summary",{children:"or let them find this deck on their own"}),o.jsxs("p",{className:"lan-note",children:[u?o.jsx(o.Fragment,{children:"Run this in a terminal on this machine, then restart the deck."}):o.jsxs(o.Fragment,{children:["Run this in PowerShell ",o.jsx("strong",{children:"as Administrator"}),", then restart the deck."]}),e.category==="Public"&&o.jsx(o.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&&o.jsxs(o.Fragment,{children:[" ",e.unsure]})]}),o.jsx("pre",{className:"ap-lan-cmd",children:o.jsx("code",{children:l.join(`
92
+ `)})}),o.jsx("button",{type:"button",className:"ap-manage-btn",onClick:()=>void c(),title:u?"Copy these lines, then paste them into a terminal":"Copy these lines, then paste them into an elevated PowerShell",children:n?"copied":"copy command"})]})]})}async function Cm(e,t){return(await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).json().catch(()=>null)}const jz={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."},_z={not_running:"This deck is not on the network yet. Turn Local network on, then make one."};function WS(e,t,n){return(t==null?void 0:t.reason)&&e[t.reason]||un(n,t)}function Ez({status:e,manual:t,startWith:n,onClose:r,onChanged:s}){const l=w.useRef(null),c=w.useRef(null),u=w.useRef(null),f=e.pairingMode==="invite",p=pn(r,{focusRef:f?c:l}),[h,m]=w.useState(""),[y,v]=w.useState(""),[S,b]=w.useState(null),[_,k]=w.useState(null),[j,E]=w.useState(null),[C,R]=w.useState(null),[I,O]=w.useState(()=>Date.now());w.useEffect(()=>{const re=window.setInterval(()=>O(Date.now()),1e3);return()=>window.clearInterval(re)},[]);const H=w.useRef(!0);w.useEffect(()=>()=>{H.current=!1},[]);const q=w.useRef(null),$=w.useCallback(re=>Tf(q.current)?(q.current=re,E(re),!0):!1,[]),V=w.useCallback(()=>{q.current=null,H.current&&E(null)},[]),ne=re=>{const U=ao(j,re);return{disabled:U.disabled,"aria-busy":U.busy}},ee=re=>(S==null?void 0:S.field)===re?{"aria-invalid":!0,"aria-describedby":"lan-add-failure"}:{},M=re=>b(U=>U&&U.field===re?null:U),Z=w.useCallback(async()=>{if(f)return;const re=zz(h);if(!re){b({text:Cz(h),field:"addr"});return}const U=`${re.addr}:${re.port}`,Y=e.peers.find(z=>z.addr===re.addr&&z.port===re.port&&z.paired);if(Y){b({text:`Already paired with ${Y.name} at that address.`,field:"addr"});return}if(t.includes(U)){b({text:"This deck already calls that address.",field:"addr"});return}if($("add"))try{const z=await Cm("/api/prefs",{lan:{manual:[...t,U]}});if(!H.current)return;z!=null&&z.ok?(b(null),m(""),s(),r()):b({text:un("add that address",z),field:"addr"})}catch{H.current&&b({text:un("add that address",null),field:"addr"})}finally{V()}},[h,f,t,e.peers,s,r,$,V]),K=w.useCallback(async re=>{if(!$(`invite:${re}`))return;const U=re==="make"?"make an invite":"cancel that invite";try{const Y=await Cm("/api/lan/invite",{action:re});if(!H.current)return;Y!=null&&Y.ok?(b(null),k(null),s()):b({text:WS(_z,Y,U)})}catch{H.current&&b({text:un(U,null)})}finally{V()}},[s,$,V]),D=w.useCallback(async()=>{const re=y.trim();if(!(!re||!$("join"))){R(null);try{const U=await Cm("/api/lan/invite",{action:"join",token:re});if(!H.current)return;U!=null&&U.ok?(v(""),b(null),s(),r()):(U==null?void 0:U.reason)==="unreachable"&&Array.isArray(U.tried)&&U.tried.length?(R(U.tried),b(null)):(R(null),b({text:WS(jz,U,"use that invite"),field:"join"}))}catch{H.current&&b({text:un("use that invite",null),field:"join"})}finally{V()}}},[y,s,r,$,V]),P=w.useCallback(async(re,U)=>{try{await navigator.clipboard.writeText(re),k(U),window.setTimeout(()=>{H.current&&k(Y=>Y===U?null:Y)},1600)}catch{b({text:"Could not copy it — select the text and copy it by hand."})}},[]),B=e.invite&&e.invite.expiresAt>I?e.invite:null,W=w.useRef(!1);w.useEffect(()=>{n!=="invite"||W.current||B||(W.current=!0,K("make"))},[n,B,K]);const F=w.useRef(!1);w.useEffect(()=>{var re;n!=="invite"||F.current||!B||(F.current=!0,(re=u.current)==null||re.focus())},[n,B]);const G=e.port!=null?(e.addrs??[]).map(re=>`${re}:${e.port}`):[];return Mn.createPortal(o.jsx("div",{className:"modal-backdrop",onClick:r,role:"presentation",children:o.jsxs("div",{ref:p,className:"modal lan-add",onClick:re=>re.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-add-title",children:[o.jsxs("header",{className:"modal-head",children:[o.jsx("div",{className:"modal-title",children:o.jsx("span",{id:"lan-add-title",className:"modal-tool-name",children:"Add a deck"})}),o.jsx("div",{className:"modal-actions",children:o.jsx("button",{className:"glyph-btn",onClick:r,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),o.jsxs("section",{className:"modal-body",children:[S&&o.jsxs("div",{className:"ap-failure",role:"alert",children:[o.jsx("span",{id:"lan-add-failure",className:"ap-failure-text",children:S.text}),o.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>b(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),o.jsx(WM,{reach:e.reach,where:"dialog"}),f&&o.jsx("div",{className:"modal-section",children:o.jsx("p",{className:"lan-note",children:"Adding by address is off while this deck pairs only by invite."})}),!f&&o.jsxs("div",{className:"modal-section",children:[o.jsx("h3",{className:"lan-h",children:"By address"}),o.jsxs("div",{className:"ap-lan-row",children:[o.jsx("input",{ref:l,className:"ap-manage-input ap-lan-input","aria-label":"Another deck's address",value:h,placeholder:"192.168.1.5:54340",spellCheck:!1,...ee("addr"),onChange:re=>{m(re.target.value),M("addr")},onKeyDown:re=>{re.key==="Enter"&&Z()}}),h.trim()!==""&&o.jsx("button",{type:"button",className:"ap-manage-btn",...ne("add"),onClick:()=>void Z(),title:"Add it to the decks this one calls, starting now.",children:"add"})]}),o.jsx("p",{className:"lan-note",children:"This deck calls that address until somebody there accepts."}),e.port!=null&&G.length>0&&o.jsxs("p",{className:"lan-note",children:["They type this deck’s own address into the same field on theirs:"," ",G.map((re,U)=>o.jsxs("span",{children:[U>0&&" or ",o.jsx("code",{className:"ap-lan-code",children:re})]},re)),o.jsx("button",{type:"button",className:"ap-lan-word lan-copy",...ne("copy:mine"),onClick:()=>void P(G.join(" "),"mine"),title:"Copy this deck's address, to send to whoever is adding it",children:_==="mine"?"copied":"copy"})]})]}),o.jsxs("div",{className:"modal-section",children:[o.jsxs("h3",{className:"lan-h",children:["With an invite",!B&&o.jsx("button",{type:"button",className:"ap-lan-word lan-h-act",...ne("invite:make"),onClick:()=>void K("make"),title:"One piece of text you send them. They paste it, and the two decks pair — nobody has to press anything here.",children:j==="invite:make"?"making…":"make one to send"})]}),o.jsxs("div",{className:"ap-lan-row",children:[o.jsx("input",{ref:c,className:"ap-manage-input ap-lan-input","aria-label":"An invite you were sent",value:y,placeholder:"paste one you were sent",spellCheck:!1,...ee("join"),onChange:re=>{v(re.target.value),R(null),M("join")},onKeyDown:re=>{re.key==="Enter"&&D()}}),y.trim()!==""&&o.jsx("button",{type:"button",className:"ap-manage-btn",...ne("join"),onClick:()=>void D(),title:"Reach that deck and pair with it. Nobody has to press anything there.",children:j==="join"?"joining…":"join"})]}),o.jsx("p",{className:"lan-note",children:"Pasting one pairs both decks on the spot — nobody has to accept."}),C&&o.jsxs("div",{className:"ap-lan-tried",children:[o.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."}),C.map(re=>o.jsxs("span",{className:"ap-lan-tried-row",children:[o.jsx("code",{className:"ap-lan-code",children:re.addr}),o.jsx("span",{className:"ap-lan-bad",children:re.why})]},re.addr))]}),B&&o.jsxs("div",{className:"ap-lan-invite",children:[o.jsxs("div",{className:"ap-lan-invite-head",children:[o.jsx("span",{className:"ap-lan-invite-title",children:"Send this to them"}),o.jsxs("span",{className:"ap-lan-invite-left",id:"lan-invite-left",children:[Wz(B.expiresAt,I)," left"]})]}),o.jsx("code",{className:"ap-lan-token",children:B.token}),o.jsxs("div",{className:"ap-lan-acts",children:[o.jsx("button",{type:"button",className:"ap-manage-btn",ref:u,...ne("copy:invite"),"aria-label":_==="invite"?"Invite copied":"Copy invite","aria-describedby":"lan-invite-left",onClick:()=>void P(B.token,"invite"),title:"Copy it, and send it however you already talk to them",children:_==="invite"?"copied":"copy"}),o.jsx("button",{type:"button",className:"ap-manage-btn",...ne("invite:withdraw"),onClick:()=>void K("withdraw"),title:"Cancel it. Anybody already holding the text can no longer use it.",children:"cancel"})]}),o.jsx("p",{className:"lan-warn",children:"Anyone who gets this text can pair with this deck until it runs out."})]})]})]})]})}),document.body)}function Cz(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}".`}const Tz=1e3;function Rz(e,t){const n=new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),r=qs(e,t);return`${n} · ${r==="now"?"just now":r}`}function VS(e){return e&&[e.version,e.os,e.arch].filter(Boolean).join(" · ")||null}function Az(){return o.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:[o.jsx("path",{d:"M9.6 2.4l2 2L5 11l-2.6.6L3 9z"}),o.jsx("path",{d:"M8.4 3.6l2 2"})]})}function GS(){return o.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:[o.jsx("rect",{x:"2.5",y:"3",width:"11",height:"7.5",rx:"1.2"}),o.jsx("path",{d:"M1 13h14"})]})}function bh({dir:e,gate:t=!1}){const n=t?12:8;return o.jsx("svg",{className:"lan-chev","data-dir":e,"data-gate":t||void 0,width:n,height:"8",viewBox:`0 0 ${n} 8`,fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:o.jsx("path",{d:e==="out"?"M2.8 1L6 4 2.8 7":t?"M1 1v6M9.6 1L6.4 4l3.2 3":"M5.2 1L2 4l3.2 3"})})}const Mz={works:"works here",expired:"expired here",missing:"not on this deck",unavailable:"cannot share here"},Iz={works:"works there",broken:"broken there",unavailable:"cannot share there",unknown:"not offered by that deck"};function $z(e){const t=e.in&&e.out?"offered both ways":e.in?"offered by that deck":"offered by this deck";return`${Mz[e.here]}, ${Iz[e.there]}, ${t}${e.usedThere?", in use there":""}.`}function Oz({row:e,source:t,status:n,accounts:r,now:s,busy:l,onClose:c,onRename:u,onCheck:f,onVerb:p,onSettings:h,onInvite:m,twins:y=[],onUnpair:v}){var Ot,zt,Xt,Dt,rn;const S=w.useRef(null),b=pn(c,{focusRef:S}),[_,k]=w.useState(null),[j,E]=w.useState(null),[C,R]=w.useState(!1),I=w.useRef(0),[O,H]=w.useState(null),[q,$]=w.useState(!1),[V,ne]=w.useState(0),ee=w.useRef(null),M=w.useRef(!0);w.useEffect(()=>()=>{M.current=!1},[]);const Z=_!=null;w.useEffect(()=>{var je;Z&&((je=ee.current)==null||je.select())},[Z]),w.useEffect(()=>{if(!C)return;const je=window.setTimeout(()=>R(!1),4e3);return()=>window.clearTimeout(je)},[C]),w.useEffect(()=>{if(!O)return;const je=window.setTimeout(()=>H(null),4e3);return()=>window.clearTimeout(je)},[O]);const K=je=>{const xt=ao(l,je);return{disabled:xt.disabled,"aria-busy":xt.busy}},D=async je=>{const xt=await je();return M.current&&E(xt),xt==null},{peer:P,stranger:B}=t,W=e.kind==="paired",F=e.self??e.name,G=e.kind!=="dialling",re=e.kind==="dialling"?null:e.fp,U=P?P.addr?`${P.addr}:${P.port}`:"":B?B.port?`${B.addr}:${B.port}`:B.addr:e.addr,Y=(P==null?void 0:P.about)??null,z=((Ot=n.about)==null?void 0:Ot.version)??null,ie=async je=>{const xt=je.trim()===F?"":je;await D(()=>u(xt))&&k(null)},le=async()=>{if(re)try{if(await navigator.clipboard.writeText(re),!M.current)return;$(!0),window.setTimeout(()=>{M.current&&$(!1)},1600)}catch{M.current&&E("Could not copy it — select the fingerprint and copy it by hand.")}},ge=W?P!=null&&P.waiting?P.lastSeen!=null?"not said — it runs an older version":"not said yet — it says when it next calls":P!=null&&P.offers?"not said — it runs an older version":"not reached yet":"shown once paired",Ne=VS(n.about),Ie=VS(Y),Ge=Y!=null&&Y.version&&z?eU(Y.version,z):null,Pe=P?qb(P.last,s):null,Be=P&&((zt=P.last)!=null&&zt.error)?Bz({error:P.last.error,host:P.addr,port:P.port},[...n.strangers??[],...n.pending??[],...(n.peers??[]).filter(je=>!je.manual&&je.addr).map(je=>({fp:je.fp,name:je.name,addr:je.addr,port:je.port,at:je.lastSeen??0}))],s):null,Te=(Xt=P==null?void 0:P.last)!=null&&Xt.error&&Pe&&Pe.text!==P.last.error?P.last.error:null,st=((Dt=P==null?void 0:P.last)==null?void 0:Dt.done)??[],de=!!Pe&&!!Te&&!e.quiet&&e.state.startsWith(Pe.text),ue=W||e.kind==="dialling",se=((P==null?void 0:P.via)??e.via)==="tailscale",be=P?P.waiting?null:P.manual?se?"added by its Tailscale address":"added by address":se?"over Tailscale":"on this network":e.kind==="nearby"?se?"heard over Tailscale":"heard on this network":se?"asked this deck to pair, over Tailscale":"asked this deck to pair",Le=e.tone==="bad"?"bad":W?e.here?"up":"down":"loose",ce=l===`check:${e.fp}`,pe=(P==null?void 0:P.offers)??null,Ae=Le==="up"?(pe==null?void 0:pe.current)??null:null,fe=Ae&&"key"in Ae?Ae.key:null,Se=!!Ae&&"hidden"in Ae,Ye=!!Ae&&"other"in Ae,qe=W?nU((pe==null?void 0:pe.accounts)??null,r,n.shared??[],fe):[],ke=qe.filter(je=>je.in==null&&je.out==="cut"),Re=qe.some(je=>je.in!=null),ze=qe.some(je=>je.out!=null),Fe=new Map(st.map(je=>[je.email,je])),We=st.filter(je=>!qe.some(xt=>xt.email===je.email)),rt=W?pe?pe.accounts.length===0?"That deck offers nothing. Nobody there has chosen a login to share.":null:P!=null&&P.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.":(rn=P==null?void 0:P.last)!=null&&rn.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,dt=pe&&(P!=null&&P.last)&&P.last.at-pe.at>Tz?qs(pe.at,s):null,ct=[];W&&(P!=null&&P.pairedAt)?ct.push({label:"Paired",value:Rz(P.pairedAt,s),tone:"meta"}):e.kind==="declined"&&B&&ct.push({label:"Paired",value:`no · you said no ${Bb(B.at,s)}`,tone:"meta"}),ct.push({label:"Fingerprint",value:re?o.jsxs("span",{className:"lan-fp",children:[o.jsx("code",{className:"ap-lan-code",children:re}),o.jsx("button",{type:"button",className:"ap-lan-word lan-copy",onClick:()=>void le(),"aria-label":q?"Fingerprint copied":"Copy the fingerprint",children:q?"copied":"copy"})]}):"not known — nothing has answered there",tone:re?void 0:"quiet"});const yt=y.length?[{row:e,peer:P??null},...y]:[];return Mn.createPortal(o.jsx("div",{className:"modal-backdrop",onClick:c,role:"presentation",children:o.jsxs("div",{ref:b,className:"modal lan-peer","data-tone":e.tone,onClick:je=>je.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-peer-title","aria-describedby":"lan-peer-sub",children:[o.jsxs("header",{className:"modal-head lan-peer-head",children:[o.jsx("i",{className:e.here?"ap-pulse":"ap-dot","aria-hidden":!0}),o.jsxs("div",{className:"lan-peer-id",children:[Z?o.jsxs("form",{className:"lan-peer-edit",onSubmit:je=>{je.preventDefault(),ie(_??"")},children:[o.jsx("span",{id:"lan-peer-title",className:"vis-hidden",children:e.name}),o.jsx("input",{ref:ee,className:"ap-manage-input lan-peer-input",value:_??"",maxLength:48,placeholder:F,"aria-label":"Name for this deck, shown on this deck only",onChange:je=>k(je.target.value)}),o.jsx("button",{type:"submit",className:"ap-manage-btn",...K(`alias:${e.fp}`),children:"save"}),o.jsx("button",{type:"button",className:"ap-manage-btn",onClick:()=>k(null),children:"cancel"})]}):o.jsxs("span",{className:"lan-peer-title",children:[o.jsx("span",{id:"lan-peer-title",className:"lan-peer-name",children:e.name}),G&&o.jsx("button",{type:"button",className:"glyph-btn lan-peer-rename",onClick:()=>{E(null),k(e.name)},"aria-label":`Rename ${e.name} on this deck`,title:"Give it a name of your own. Only this deck sees it.",children:o.jsx(Az,{})})]}),o.jsxs("p",{id:"lan-peer-sub",className:"lan-peer-sub",children:[e.self&&o.jsxs(o.Fragment,{children:["calls itself ",o.jsx("span",{className:"lan-peer-self",children:e.self}),Z&&o.jsx("button",{type:"button",className:"ap-lan-word lan-peer-restore",...K(`alias:${e.fp}`),onClick:()=>void ie(""),children:"use this name"}),o.jsx("span",{className:"vis-hidden",children:". "}),!e.quiet&&o.jsx("span",{"aria-hidden":!0,children:" · "})]}),o.jsx("span",{className:e.quiet?"vis-hidden":"lan-peer-state",children:e.state})]})]}),o.jsx("div",{className:"modal-actions",children:o.jsx("button",{ref:S,type:"button",className:"glyph-btn",onClick:c,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),o.jsxs("section",{className:"modal-body lan-peer-body",children:[j&&o.jsxs("div",{className:"ap-failure",role:"alert",children:[o.jsx("span",{className:"ap-failure-text",children:j}),o.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>E(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),o.jsxs("div",{className:"lan-map","data-link":Le,"data-asking":ce||void 0,"data-bus":qe.length>0||void 0,children:[o.jsxs("div",{className:"lan-ends",children:[o.jsxs("p",{className:"lan-end",children:[o.jsx("span",{className:"lan-end-name",children:"This deck"}),Ne&&o.jsx("span",{className:"lan-end-runs",children:Ne}),W&&n.shareActive===!1&&o.jsx("span",{className:"lan-end-note",children:"current account hidden"})]}),o.jsxs("p",{className:"lan-end","data-side":"there",children:[o.jsx("span",{className:"lan-end-name",children:e.name}),e.kind!=="dialling"&&o.jsxs("span",{className:"lan-end-runs",children:[Ie??(Y?"not said":ge),Ge?` · ${Ge<0?"older":"newer"}`:null]}),Se&&o.jsx("span",{className:"lan-end-note",children:"current account hidden"}),Ye&&o.jsx("span",{className:"lan-end-note",children:"on another account"})]})]}),o.jsxs("div",{className:"lan-link",children:[o.jsx(GS,{}),o.jsxs("span",{className:"lan-span",children:[o.jsxs("span",{className:"lan-wire","aria-hidden":!0,children:[o.jsx("i",{className:"lan-glint","data-dir":"out"}),o.jsx("i",{className:"lan-glint","data-dir":"in"})]}),o.jsx("span",{className:"lan-link-label",children:U?o.jsx("code",{className:"ap-lan-code",children:U}):"none here — it calls this deck"})]}),o.jsx(GS,{}),(U&&be||ue)&&o.jsxs("p",{className:"lan-link-sub",children:[U&&be,U&&be&&ue&&" · ",ue&&(Pe?de?o.jsx("code",{className:"ap-lan-code",children:Te}):o.jsx("span",{className:"lan-round","data-tone":Pe.tone,children:Pe.text.replace(/ · now$/," · just now")}):"not asked yet"),ue&&Te&&!de&&o.jsx("code",{className:"lan-fact-raw",children:Te})]}),We.length>0&&o.jsx("ul",{className:"lan-done",children:We.map(je=>{const xt=F0(je);return o.jsxs("li",{"data-ok":je.ok&&!xt,children:[je.email," ",o.jsxs("span",{className:"lan-done-what",children:[je.ok?"arrived":"did not arrive",xt&&` — ${xt.long}`]})]},`${je.email}:${je.action}`)})}),Be&&o.jsx("p",{className:"lan-note lan-link-note",children:Be}),(P==null?void 0:P.waiting)&&o.jsx("p",{className:"lan-note lan-link-note",children:e.hint}),(Pe==null?void 0:Pe.hint)&&o.jsx("p",{className:"lan-note lan-link-note",children:Pe.hint})]}),qe.length>0&&o.jsx("ul",{className:"lan-lanes",role:"list","aria-label":`Logins between this deck and ${e.name}`,children:qe.map((je,xt)=>{const bt=Fe.get(je.email),_n=bt?F0(bt):null,Ut=je.out==="live"||je.in!=null&&je.in!=="cut";return o.jsxs("li",{role:"listitem",className:"lan-lane","data-tone":je.tone,"data-draw":je.in&&je.out?"both":je.in?"in":"out","data-used-there":je.usedThere||void 0,style:{"--i":xt},children:[o.jsx("i",{className:"lan-pip","data-end":"here","data-state":je.here,"aria-hidden":!0}),o.jsxs("span",{className:"lan-track",children:[o.jsxs("span",{className:"lan-wire","data-flow":Ut?"live":"cut","aria-hidden":!0,children:[(je.in==="live"||je.in==="wait")&&o.jsx("i",{className:"lan-glint","data-dir":"in","data-tone":je.in}),je.out==="live"&&o.jsx("i",{className:"lan-glint","data-dir":"out"})]}),je.in&&je.in!=="cut"&&o.jsx(bh,{dir:"in",gate:je.in==="blocked"}),je.out==="live"&&o.jsx(bh,{dir:"out"}),o.jsx("span",{className:"lan-lane-email",children:je.email})]}),o.jsx("i",{className:"lan-pip","data-end":"there","data-state":je.there,"aria-hidden":!0}),o.jsx("span",{className:"vis-hidden",children:$z(je)}),(je.caption||bt)&&o.jsxs("span",{className:"lan-lane-note",children:[je.caption,je.caption&&bt&&" · ",bt&&o.jsxs("span",{className:"lan-lane-done","data-ok":bt.ok&&!_n,children:[bt.ok?"arrived last round":"did not arrive last round",_n&&` — ${_n.long}`]})]})]},je.key)})},V),W&&o.jsxs(o.Fragment,{children:[ke.length>0&&o.jsxs("p",{className:"lan-spent",children:["Paired decks get nothing from ",ke.length===1?ke[0].email:"the expired ones"," until you sign in again here."]}),rt&&o.jsx("p",{className:"lan-empty",children:rt}),dt&&o.jsxs("p",{className:"lan-stale",children:["As of ",dt==="now"?"just now":dt,", when it last answered."]}),o.jsxs("div",{className:"lan-legend",children:[Re&&o.jsxs("span",{className:"lan-key",children:[o.jsx("span",{className:"lan-key-wire","data-dir":"in","aria-hidden":!0,children:o.jsx(bh,{dir:"in"})}),"from ",e.name]}),ze?o.jsxs("span",{className:"lan-key",children:[o.jsx("span",{className:"lan-key-wire","data-dir":"out","aria-hidden":!0,children:o.jsx(bh,{dir:"out"})}),"from this deck, to every paired deck"]}):o.jsx("span",{className:"lan-key",children:"This deck offers nothing yet."}),o.jsx("button",{type:"button",className:"ap-lan-word lan-legend-act",onClick:h,"aria-label":"Change what this deck offers",children:"change"})]})]})]}),o.jsx("dl",{className:"lan-facts",children:ct.map(je=>o.jsxs("div",{className:"lan-fact","data-tone":je.tone,children:[o.jsx("dt",{children:je.label}),o.jsx("dd",{children:je.value})]},je.label))}),yt.length>1&&o.jsxs("div",{className:"modal-section",children:[o.jsxs("h3",{className:"lan-h",children:[yt.length," decks on this machine"]}),o.jsx("ul",{className:"lan-twins",role:"list",children:yt.map((je,xt)=>{var Lt,Zt,In,Hr;const bt=(Lt=je.peer)!=null&&Lt.addr?`${je.peer.addr}:${je.peer.port}`:je.row.addr,_n=bt||je.row.fp,Ut=(Zt=je.peer)!=null&&Zt.pairedAt?qs(je.peer.pairedAt,s):null,Vn=[(Hr=(In=je.peer)==null?void 0:In.about)!=null&&Hr.version?`runs ${je.peer.about.version}`:null,Ut?`paired ${Ut==="now"?"just now":Ut}`:null,je.row.state].filter(Boolean).join(" · "),Vt=je.row.fp;return o.jsxs("li",{role:"listitem",className:"lan-twin","data-tone":je.row.tone,children:[o.jsx("i",{className:je.row.here?"ap-pulse":"ap-dot","aria-hidden":!0}),bt?o.jsx("code",{className:"ap-lan-code lan-twin-at",children:bt}):o.jsx("span",{className:"lan-twin-at lan-twin-none",children:"no address here"}),o.jsx("code",{className:"ap-lan-code lan-twin-fp",children:Vt}),xt>0&&v&&o.jsx("button",{type:"button",className:`ap-manage-btn danger lan-twin-do${O===Vt?" armed":""}`,...K(`unpair:${Vt}`),onKeyDown:xe=>{xe.repeat&&xe.preventDefault()},onClick:()=>{const xe=Date.now(),lr=Cu({armedFor:O,target:Vt,armedAt:I.current,now:xe,gapMs:Mu});if(lr==="arm"){H(Vt),I.current=xe;return}lr!=="ignore"&&(H(null),D(()=>v(Vt)))},"aria-label":O===Vt?`Confirm unpairing ${_n}`:`Unpair ${_n}`,title:O===Vt?"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:l===`unpair:${Vt}`?"unpairing…":O===Vt?"confirm":"unpair"}),o.jsx("span",{className:"lan-twin-meta",children:xt===0?`${Vn} · shown above`:Vn})]},Vt)})})]})]}),o.jsxs("footer",{className:"lan-peer-foot",children:[e.kind==="asks"&&o.jsx("p",{className:"lan-foot-note",children:"This deck is now asking to pair. Answer it from the panel behind this."}),W&&!(P!=null&&P.waiting)&&o.jsx("button",{type:"button",className:"btn",...K(`check:${e.fp}`),onClick:()=>void D(f).then(je=>{je&&M.current&&ne(xt=>xt+1)}),title:"Ask this deck now instead of waiting for the next round",children:l===`check:${e.fp}`?"Checking…":"Check now"}),e.kind==="paired"&&o.jsx("button",{type:"button",className:`btn danger lan-peer-verb${C?" armed":""}`,...K(`unpair:${e.fp}`),onKeyDown:je=>{je.repeat&&je.preventDefault()},onClick:()=>{const je=Date.now(),xt=Cu({armedFor:C?e.fp:null,target:e.fp,armedAt:I.current,now:je,gapMs:Mu});if(xt==="arm"){R(!0),I.current=je;return}xt!=="ignore"&&(R(!1),D(p))},"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:l===`unpair:${e.fp}`?"Unpairing…":C?"Confirm unpair":"Unpair"}),e.kind==="nearby"&&n.pairingMode!=="invite"&&o.jsx("button",{type:"button",className:"btn primary lan-peer-verb",...K(`accept:${e.fp}`),onClick:()=>void D(p),title:"Send it a request. Somebody at that machine has to accept it before anything is shared.",children:l===`accept:${e.fp}`?"Asking…":"Ask to pair"}),e.kind==="dialling"&&o.jsx("button",{type:"button",className:"btn lan-peer-verb",...K(`drop:${e.fp}`),onClick:()=>void D(p),title:"Stop trying this address. Nothing was ever paired here.",children:l===`drop:${e.fp}`?"Stopping…":"Stop dialling"}),e.kind==="declined"&&n.pairingMode!=="invite"&&o.jsx("button",{type:"button",className:"btn lan-peer-verb",...K(`allow:${e.fp}`),onClick:()=>void D(p),title:"Take the no back. That deck is still trying, so its request comes round again on its own.",children:l===`allow:${e.fp}`?"Allowing…":"Let it ask again"}),(e.kind==="nearby"||e.kind==="declined")&&n.pairingMode==="invite"&&m&&o.jsx("button",{type:"button",className:"btn primary lan-peer-verb",onClick:m,title:"This deck pairs only by invite. Make one and send it to whoever is at that machine.",children:"Invite to pair"})]})]})}),document.body)}function Lz(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 kh="Paused while this deck pairs only by invite. Turn that off above to use it.";function Pz({status:e,accounts:t,onClose:n,onChanged:r}){const s=pn(n),[l,c]=w.useState(null),[u,f]=w.useState(null),[p,h]=w.useState(!1),[m,y]=w.useState(null),v=w.useRef(null),S=M=>{const Z=ao(m,M);return{disabled:Z.disabled,"aria-busy":Z.busy}},b=w.useRef(null),_=w.useRef(!0);w.useEffect(()=>()=>{_.current=!1},[]),w.useEffect(()=>{b.current=XS(b.current,e.shared??[],null)},[e.shared]);const k=w.useCallback(async(M,Z,K="write")=>{v.current=K,y(K);try{const P=await(await fetch("/api/prefs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({lan:M})})).json().catch(()=>null);return _.current?(P!=null&&P.ok?f(null):f(un(Z,P)),r(),(P==null?void 0:P.ok)===!0):!1}catch{return _.current&&f(un(Z,null)),!1}finally{v.current=null,_.current&&y(null)}},[r]),j=w.useCallback(async()=>{if(l!=null&&l!==(e.name??"")){if(!await k({name:l},"save the name","name"))return;_.current&&c(null)}n()},[l,e.name,k,n]),E=async()=>{if(!e.fp)return;const M=await hi(e.fp);if(_.current){if(!M){f("Could not copy it — select the fingerprint and copy it by hand.");return}h(!0),window.setTimeout(()=>{_.current&&h(!1)},1600)}},C=new Set(b.current??e.shared??[]),R=e.autoAsk!==!1,I=e.autoAccept!==!1,O=e.pairingMode==="invite",H=M=>{const Z=S(M);return{...Z,disabled:Z.disabled||O}},q=e.shareActive!==!1,$=e.tailscale??null,V=!!($!=null&&$.on),ne=($==null?void 0:$.ask)!==!1,ee=($==null?void 0:$.accept)!==!1;return Mn.createPortal(o.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:o.jsxs("div",{ref:s,className:"modal lan-modal",onClick:M=>M.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-modal-title",children:[o.jsxs("header",{className:"modal-head",children:[o.jsx("div",{className:"modal-title",children:o.jsx("span",{id:"lan-modal-title",className:"modal-tool-name",children:"This deck on the network"})}),o.jsx("div",{className:"modal-actions",children:o.jsx("button",{className:"glyph-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),o.jsxs("section",{className:"modal-body",children:[u&&o.jsxs("div",{className:"ap-failure",role:"alert",children:[o.jsx("span",{className:"ap-failure-text",children:u}),o.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>f(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),o.jsxs("div",{className:"modal-section",children:[o.jsx("h3",{className:"lan-h",children:"Name"}),o.jsxs("div",{className:"ap-lan-row",children:[o.jsx("span",{className:"ap-lan-label",children:"appear as"}),o.jsx("input",{className:"ap-manage-input ap-lan-input","aria-label":"This deck's name on the network",value:l??e.name??"",placeholder:"this machine",onChange:M=>c(M.target.value),onKeyDown:M=>{M.key!=="Enter"||l==null||(k({name:l},"save the name","name"),c(null))}}),l!=null&&l!==(e.name??"")&&o.jsx("button",{type:"button",className:"ap-manage-btn",...S("name"),onClick:()=>{k({name:l},"save the name","name"),c(null)},title:"Save it. This is the name other decks show for this one.",children:"save"})]}),o.jsxs("div",{className:"ap-lan-row",children:[o.jsx("span",{className:"ap-lan-label",children:"fingerprint"}),e.fp?o.jsxs("span",{className:"lan-fp",children:[o.jsx("code",{className:"ap-lan-code",children:e.fp}),o.jsx("button",{type:"button",className:"ap-lan-word lan-copy",onClick:()=>void E(),"aria-label":p?"Fingerprint copied":"Copy this deck's fingerprint",children:p?"copied":"copy"})]}):o.jsx("span",{className:"ap-lan-label",children:"not known yet"})]})]}),o.jsxs("div",{className:"modal-section",children:[o.jsx("h3",{className:"lan-h",children:"Share these accounts"}),o.jsxs("div",{className:"ap-lan-picks",children:[t.length===0&&o.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(M=>o.jsxs("label",{className:"ap-lan-pick",title:M.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:[o.jsx("input",{type:"checkbox",checked:C.has(M.key),onChange:Z=>{const K=Hz(b.current,e.shared??[],M.key,Z.target.checked);b.current=K,k({shared:K},Z.target.checked?"share that account":"stop sharing that account").then(D=>{b.current===K&&(b.current=XS(K,e.shared??[],{ok:D}))})}}),o.jsx("span",{className:"ap-lan-pick-name",children:M.email}),!M.alive&&o.jsx("span",{className:"ap-lan-dead",children:"not working here"})]},M.key))]}),t.length>0&&o.jsxs("div",{className:"lan-switch",children:[o.jsx("span",{className:"lan-switch-what",children:"Show paired decks which of these this deck is using"}),o.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":q,"aria-label":"Show paired decks which of these this deck is using",...S("current"),onClick:()=>void k({shareActive:!q},q?"stop showing which account this deck is using":"show which account this deck is using","current"),title:q?"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:o.jsx("span",{className:"switch-knob"})})]})]}),o.jsxs("div",{className:"modal-section",children:[o.jsx("h3",{className:"lan-h",id:"lan-pairing-h",children:"Pairing"}),o.jsx("div",{className:"lan-switches lan-switches-lead",role:"group","aria-labelledby":"lan-pairing-h",children:o.jsxs("div",{className:"lan-switch",children:[o.jsxs("span",{className:"lan-switch-what",children:["Pair new decks only by invite",O&&o.jsx("span",{id:"lan-invite-only-detail",className:"lan-switch-detail",children:"A new deck needs an invite from + in the panel. Paired decks stay paired."})]}),o.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":O,"aria-label":"Pair new decks only by invite","aria-describedby":O?"lan-invite-only-detail":void 0,...S("mode"),onKeyDown:M=>{M.repeat&&M.preventDefault()},onClick:()=>void k({pairingMode:O?"automatic":"invite"},O?"let decks pair on their own again":"pair new decks only by invite","mode"),title:O?"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:o.jsx("span",{className:"switch-knob"})})]})}),o.jsxs("div",{className:"lan-auto",role:"group","aria-labelledby":"lan-auto-h",children:[o.jsxs("p",{className:"lan-sub",id:"lan-auto-h",children:["Automatic pairing",O&&o.jsx("span",{className:"lan-sub-state",children:" · paused while pairing is invite-only"})]}),o.jsxs("div",{className:"lan-switches","data-paused":O||void 0,children:[o.jsxs("div",{className:"lan-switch",children:[o.jsx("span",{className:"lan-switch-what",children:"Ask every deck this one finds"}),o.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":R,"aria-label":"Ask every deck this one finds",...H("ask"),onClick:()=>void k({autoAsk:!R},R?"stop asking automatically":"ask every deck this one finds","ask"),title:O?kh:R?"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:o.jsx("span",{className:"switch-knob"})})]}),o.jsxs("div",{className:"lan-switch",children:[o.jsx("span",{className:"lan-switch-what",children:"Say yes to every deck that asks"}),o.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":I,"aria-label":"Say yes to every deck that asks","data-tone":"warn",...H("accept"),onKeyDown:M=>{M.repeat&&M.preventDefault()},onClick:()=>void k({autoAccept:!I},I?"stop accepting automatically":"accept every deck that asks","accept"),title:O?kh:I?"Stop saying yes for you. A deck that asks waits in the panel again.":"Say yes for you. Every deck on this network that asks is paired without anybody being asked here.",children:o.jsx("span",{className:"switch-knob"})})]})]})]})]}),($==null?void 0:$.found)&&o.jsxs("div",{className:"modal-section",children:[o.jsx("h3",{className:"lan-h",children:"Tailscale"}),o.jsxs("div",{className:"lan-switches",children:[o.jsxs("div",{className:"lan-switch",children:[o.jsxs("span",{className:"lan-switch-what",children:["Look for my devices",o.jsx("span",{id:"lan-ts-detail",className:"lan-switch-detail",children:Lz($)})]}),o.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":V,"aria-label":"Look for my devices over Tailscale","aria-describedby":"lan-ts-detail",...S("tailscale"),onClick:()=>void k({tailscale:!V},V?"stop looking over Tailscale":"look for your devices over Tailscale","tailscale"),title:V?"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:o.jsx("span",{className:"switch-knob"})})]}),V&&o.jsxs("div",{className:"lan-auto",role:"group","aria-labelledby":"lan-ts-auto-h",children:[o.jsxs("p",{className:"lan-sub",id:"lan-ts-auto-h",children:["Automatic pairing with my devices",O&&o.jsx("span",{className:"lan-sub-state",children:" · paused while pairing is invite-only"})]}),o.jsxs("div",{className:"lan-switches",children:[o.jsxs("div",{className:"lan-switch","data-paused":O||void 0,children:[o.jsx("span",{className:"lan-switch-what",children:"Ask each device it finds"}),o.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":ne,"aria-label":"Ask each of my devices it finds over Tailscale",...H("tailscale-ask"),onClick:()=>void k({tailscaleAsk:!ne},ne?"stop asking your devices automatically":"ask your devices automatically","tailscale-ask"),title:O?kh:ne?"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:o.jsx("span",{className:"switch-knob"})})]}),o.jsxs("div",{className:"lan-switch","data-paused":O||void 0,children:[o.jsx("span",{className:"lan-switch-what",children:"Say yes to each device that asks"}),o.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":ee,"aria-label":"Say yes to my devices when they ask over Tailscale","data-tone":"warn",...H("tailscale-accept"),onKeyDown:M=>{M.repeat&&M.preventDefault()},onClick:()=>void k({tailscaleAccept:!ee},ee?"stop accepting your devices automatically":"accept your devices automatically","tailscale-accept"),title:O?kh:ee?"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:o.jsx("span",{className:"switch-knob"})})]})]})]})]})]})]}),o.jsxs("footer",{className:"lan-setup-foot",children:[o.jsx("span",{className:"lan-foot-note",children:"Changes are saved as you make them."}),o.jsx("button",{type:"button",className:"btn primary",...S("name"),onClick:()=>void j(),children:"Done"})]})]})}),document.body)}function qs(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 KS={keychain_unavailable:{short:"Keychain locked on the other Mac",long:`the other Mac could not export it. On that Mac: ${Lb}. The next round brings it.`}};function F0(e){return e.why?Object.hasOwn(KS,e.why)?KS[e.why]:tf(e.why):null}const Fb={"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"}},Dz={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 YS(e){var r;const t=Fz[e];if(t)return t;const n=(r=/\b(E[A-Z]{3,})\b/.exec(e))==null?void 0:r[1];return n&&Dz[n]||e}const Fz={"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 qb(e,t){var h;if(!e)return null;if(e.error&&((h=e.done)!=null&&h.length)){const m=qb({...e,error:void 0},t),y=` · ${qs(e.at,t)}`;return{...m,text:`${m.text.slice(0,-y.length)}, then ${YS(e.error)}${y}`,tone:"bad"}}if(e.error)return Fb[e.error]??{text:YS(e.error),tone:"bad"};const n=e.done??[];if(!n.length)return{text:`all logins fine · ${qs(e.at,t)}`,tone:"idle"};const r=n.filter(m=>m.ok),s=r.length===1?"login":"logins",l=n.map(m=>({d:m,why:F0(m)})).filter(m=>m.why),c=[...new Set(l.map(m=>m.why.short))],u=c.length?`, ${c.join(", ")}`:"",f=l.length?l.map(m=>`${m.d.email}: ${m.why.long}`).join(" "):void 0,p=qs(e.at,t);return r.length===n.length?{text:`${r.length} ${s} arrived${u} · ${p}`,tone:l.length?"warn":"ok",...f?{hint:f}:{}}:{text:`${r.length} of ${n.length} logins arrived${u} · ${p}`,tone:"bad",...f?{hint:f}:{}}}const qz=9e4;function Bz({error:e,host:t,port:n},r,s,l=45317){if(e!=="handshake timed out")return null;const c=(t??"").trim();if(!c)return null;const u=r.filter(p=>p.addr===c&&p.port&&p.at>0&&s-p.at<qz);if(!u.length)return null;const f=[...new Set(u.map(p=>p.port))];if(n!=null&&!f.includes(n)){const p=f.length===1?`port ${f[0]}`:`ports ${f.join(" and ")}`;return`A deck at ${c} is announcing itself on ${p}, 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 ${c}, not a network fault. Whoever uses it can allow two ports: UDP ${l} and TCP ${n??f[0]}.`}const q0=5e3,VM=6e4,Mu=400;function zz(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 un(e,t){return t==null?`Could not ${e} — the deck did not answer.`:t.reason?`Could not ${e} — the deck refused it (${t.reason}).`:`Could not ${e}.`}function Uz(e,t){if(e.length!==t.length)return!1;const n=new Set(e);return t.every(r=>n.has(r))}function Hz(e,t,n,r){const s=new Set(e??t);return r?s.add(n):s.delete(n),[...s]}function XS(e,t,n){return e==null||n!=null&&!n.ok||Uz(e,t)?null:e}function Wz(e,t){const n=Math.max(0,Math.round((e-t)/1e3));return`${Math.floor(n/60)}:${String(n%60).padStart(2,"0")}`}function GM(e,t){var n,r;return(n=e.last)!=null&&n.error&&!Fb[e.last.error]?!1:!!((r=e.last)!=null&&r.at&&t-e.last.at<rf||e.lastSeen!=null&&t-e.lastSeen<rf)}const rf=95e3,KM=160,Vz=6,YM=140;function Gz(e,t){const n=[],r=[];for(const s of e??[])(GM(s,t)?n:r).push(s);return{online:n,offline:r}}function Kz(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 Yz(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(v=>v.paired!==!1||v.met);if(!r.length)return{text:"no deck paired yet",tone:"idle"};const s=r.filter(v=>v.waiting),l=r.filter(v=>!v.waiting),c=s.filter(v=>{var S;return!((S=v.last)!=null&&S.error)&&v.lastSeen!=null&&t-v.lastSeen<rf}),{online:u,offline:f}=Gz(l,t),p=[...f,...s.filter(v=>!c.includes(v))],h=u.length+c.length,m=u.filter(v=>{var S;return((S=v.last)==null?void 0:S.error)==="waiting for the other deck to accept this one"});if(h&&m.length===h)return{text:h===1?"1 deck found · waiting for them to accept":`${h} decks found · waiting for them to accept`,tone:"wait"};if(!h)return{text:p.length===1?"this deck cannot reach the one it is paired with":`this deck cannot reach any of its ${p.length} decks`,tone:"bad"};const y=h===1?"1 deck ready":`${h} decks ready`;return{text:p.length?`${y} · ${p.length} away`:y,tone:"ok"}}function Xz(e,t,n){if(n)return"checking…";if(e==null)return"not checked yet";const r=qs(e,t);return r==="now"?"checked just now":`checked ${r}`}function Bb(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 Zz(e,t){if(e==null)return{text:"one-way · has not called yet",here:!1};const n=t-e<rf;return{text:n?"online · one-way, it calls in":`one-way · last online ${qs(e,t)}`,here:n}}function ZS(e,t,n){return t?"online":e.lastSeen!=null?`last online ${qs(e.lastSeen,n)}`:e.waiting?"has not called yet":"never reached"}function Qz(e,t){var y,v,S,b,_;if(!e)return[];const n=[],r=new Set,s=(k,j)=>k.name.localeCompare(j.name,void 0,{numeric:!0}),l=e.aliases??{},c=(k,j)=>{const E=k?l[k]:void 0;return E&&E!==j?{name:E,self:j}:{name:j}};for(const k of e.pending??[]){if(!(k!=null&&k.fp)||r.has(k.fp))continue;r.add(k.fp);const j=c(k.fp,k.name||k.fp);n.push({fp:k.fp,name:j.name,...j.self?{self:j.self}:{},addr:k.addr??"",kind:"asks",state:`wants to pair · ${Bb(k.at,t)}`,tone:"wait",here:!0,hint:`${j.name} at ${k.addr}${k.via==="tailscale"?", over Tailscale,":""} is waiting for an answer.`,...k.via==="tailscale"?{via:"tailscale"}:{}})}const u=[],f=[];for(const k of e.peers??[]){const j=k.peerFp??k.fp;if(!j||r.has(j))continue;r.add(j);const E=qb(k.last,t),C=GM(k,t),R=k.addr?`${k.addr}:${k.port}`:"";if(!k.paired&&k.manual&&!k.met){f.push({fp:R,name:R||k.name||j,addr:k.addr??"",kind:"dialling",state:E?E.text.replace(/ · .*$/,""):"trying…",tone:E?E.tone:"idle",here:!1,hint:(y=k.last)!=null&&y.error?`Nothing has answered at ${R} yet — ${k.last.error}.`:`Dialling ${R} until something answers.`,...k.via==="tailscale"?{via:"tailscale"}:{}});continue}const I=k.waiting?Zz(k.lastSeen,t):null,O=I?I.here:C,H=!I&&E?O?`online · ${E.text.replace(/ · .*$/,"")}`:`${E.text.replace(/ · .*$/,"")} · ${ZS(k,O,t)}`:I?I.text:ZS(k,O,t),q=(v=k.last)!=null&&v.error?Fb[k.last.error]:null,$=!I&&O&&!((S=k.last)!=null&&S.error)&&!(((b=k.last)==null?void 0:b.done)??[]).length,V=k.manual&&!k.met?{name:R}:c(j,k.name||j);u.push({fp:j,name:V.name,...V.self?{self:V.self}:{},addr:k.addr??"",kind:"paired",state:H,quiet:$,tone:q?q.tone==="bad"?"bad":"wait":E?E.tone:O?"ok":"idle",here:I?I.here:C,...k.via==="tailscale"?{via:"tailscale"}:{},hint:I?`${V.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. ${k.lastSeen==null?"It has not called since this deck started.":`It last called ${qs(k.lastSeen,t)}.`} Add its address with the + at the top of this section to reach it either way.`:`${V.name}${R?` at ${R}`:""}${(_=k.last)!=null&&_.error?` — ${k.last.error}`:""}${E!=null&&E.hint?` — ${E.hint}`:""}`})}n.push(...Jz(u).sort(s),...f.sort(s));const p=[];for(const k of e.strangers??[]){if(!(k!=null&&k.fp)||r.has(k.fp))continue;r.add(k.fp);const j=c(k.fp,k.name||k.fp);p.push({fp:k.fp,name:j.name,...j.self?{self:j.self}:{},addr:k.addr??"",kind:"nearby",state:e.pairingMode==="invite"?"needs an invite":"not paired yet",tone:"idle",here:!0,hint:k.via==="tailscale"?`${j.name} at ${k.addr} is on your tailnet and nothing is shared with it.`:`${j.name} at ${k.addr} is on this network and nothing is shared with it.`,...k.via==="tailscale"?{via:"tailscale"}:{}})}n.push(...p.sort(s));const h=[];for(const k of e.declined??[]){if(!(k!=null&&k.fp)||r.has(k.fp))continue;r.add(k.fp);const j=c(k.fp,k.name||k.fp);h.push({fp:k.fp,name:j.name,...j.self?{self:j.self}:{},addr:k.addr??"",kind:"declined",state:"you said no",tone:"idle",here:!1,hint:`${j.name} asked and was turned away. It is not asking any more.`})}n.push(...h.sort(s));const m=new Map;for(const k of n)m.set(k.name,(m.get(k.name)??0)+1);for(const k of n)(m.get(k.name)??0)<2||!k.addr||(k.state=k.quiet||!k.state?k.addr:`${k.addr} · ${k.state}`,k.quiet=!1);return n}function Jz(e){const t=new Map;for(const r of e){const s=t.get(r.name);s?s.push(r):t.set(r.name,[r])}const n=[];for(const r of t.values()){const s=[...new Set(r.filter(l=>l.addr).map(l=>l.addr))];if(s.length>1){for(const l of s)n.push(QS(r.filter(c=>c.addr===l)));n.push(...r.filter(l=>!l.addr))}else n.push(QS(r))}return n}function QS(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 JS(e,t){return t?e.map(n=>t[n.fp]?{...n,name:t[n.fp]}:n):e}function ej(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 eU(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 l=Number(n[s])-Number(r[s]);if(l)return Math.sign(l)}return 0}function tU(e,t,n){const r=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:r,note:null,tone:"idle"};if(!e.alive){const s=t&&!t.alive?"neither copy works — sign in again here":null;return{there:"broken there",here:r,note:s,tone:s?"bad":"idle"}}return t?t.alive?{there:"works there",here:r,note:null,tone:t.shareable===!1?"idle":"ok"}:n?{there:"works there",here:r,note:"repairs next round",tone:"wait"}:{there:"works there",here:r,note:"share it to repair",tone:"bad"}:{there:"works there",here:r,note:"arrives next round",tone:"wait"}}function nU(e,t,n,r=null){var f;const s=new Map;for(const p of t)(f=s.get(p.key))!=null&&f.alive||s.set(p.key,p);const l=new Set(n),c=[],u=new Set;for(const p of e??[]){if(u.has(p.key))continue;u.add(p.key);const h=s.get(p.key)??null,m=l.has(p.key),y=tU(p,h,m),v=h?h.alive?h.shareable===!1?"unavailable":"works":"expired":"missing",S=!p.alive&&h&&!h.alive?y.note:[v==="works"?null:y.here,p.alive&&p.shareable!==!1?null:y.there,y.note].filter(Boolean).join(" · ")||null;c.push({key:p.key,email:p.email,here:v,there:p.alive?p.shareable===!1?"unavailable":"works":"broken",in:!p.alive||p.shareable===!1?"cut":y.tone==="wait"?"wait":y.tone==="bad"?"blocked":"live",out:m&&h?h.alive&&h.shareable!==!1?"live":"cut":null,caption:S,tone:y.tone,usedThere:r===p.key})}for(const p of n){const h=s.get(p);!h||u.has(p)||(u.add(p),c.push({key:p,email:h.email,here:h.alive?h.shareable===!1?"unavailable":"works":"expired",there:"unknown",in:null,out:h.alive&&h.shareable!==!1?"live":"cut",caption:h.alive?h.shareable===!1?"cannot share here":null:"expired here",tone:h.alive?h.shareable===!1?"idle":"ok":"bad",usedThere:!1}))}return c}async function Nl(e,t){return(await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).json().catch(()=>null)}function rU({anchorId:e,id:t,rows:n,onHold:r,onLet:s}){const l=w.useRef(null),c=n.filter(y=>y.kind==="paired"),u=c.filter(y=>y.here),f=u.slice(0,Vz),p=c.length-u.length,h=u.length>f.length?`and ${u.length-f.length} more`:p>0?`${p} not on right now`:null,m=w.useCallback(()=>{const y=l.current,v=document.getElementById(e);if(!y||!v)return;const S=$b(v.getBoundingClientRect(),{width:y.offsetWidth,height:y.offsetHeight},{width:window.innerWidth,height:window.innerHeight});y.style.top=`${S.top}px`,y.style.left=`${S.left}px`,y.style.maxHeight=S.maxHeight==null?"":`${S.maxHeight}px`,y.dataset.side=S.side},[e]);return w.useLayoutEffect(()=>{m()}),w.useEffect(()=>(window.addEventListener("scroll",m,!0),window.addEventListener("resize",m),()=>{window.removeEventListener("scroll",m,!0),window.removeEventListener("resize",m)}),[m]),Mn.createPortal(o.jsxs("div",{ref:l,id:t,className:"ap-peek",role:"tooltip",onPointerEnter:r,onPointerLeave:s,children:[o.jsx("p",{className:"ap-peek-title",children:u.length?"On the network now":"Nobody on the network"}),f.length>0&&o.jsx("div",{className:"ap-peek-list",children:f.map(y=>o.jsxs("span",{className:"ap-peek-who",children:[o.jsx("i",{className:"ap-nav-live","aria-hidden":!0}),o.jsxs("span",{children:[y.name,y.via==="tailscale"&&o.jsx("span",{className:"ap-lan-via",children:" · Tailscale"})]})]},`${y.kind}:${y.fp}`))}),h&&o.jsx("p",{className:"ap-peek-rest",children:h})]}),document.body)}function sU(e,t){var l;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(c=>c.kind==="asks").length;if(n)return{text:n===1?"1 deck wants to pair":`${n} decks want to pair`,tone:"wait",live:!1};if((l=e.reach)!=null&&l.blocked)return{text:"nothing can get in",tone:"bad",live:!1};const r=t.filter(c=>c.kind==="paired");if(!r.length)return{text:"On · none paired yet",tone:"idle",live:!1};const s=r.filter(c=>c.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 aU({accounts:e,onChanged:t,view:n,onOpen:r,onBack:s,closeButton:l}){const[c,u]=w.useState(null),[f,p]=w.useState([]),[h,m]=w.useState(null),[y,v]=w.useState(!1),[S,b]=w.useState(null),_=w.useRef(0),[k,j]=w.useState(!1),[E,C]=w.useState(!1),[R,I]=w.useState(!1),O=w.useRef(0);w.useEffect(()=>()=>window.clearTimeout(O.current),[]);const[H,q]=w.useState(!1),[$,V]=w.useState(null),ne=w.useRef(null),ee=w.useCallback(ce=>Tf(ne.current)?(ne.current=ce,m(ce),!0):!1,[]),M=w.useCallback(()=>{ne.current=null,P.current&&m(null)},[]),Z=ce=>{const pe=ao(h,ce);return{disabled:pe.disabled,"aria-busy":pe.busy}},[K,D]=w.useState(()=>Date.now()),P=w.useRef(!0),B=w.useRef(q0),W=w.useCallback(async()=>{var ce,pe;try{const[Ae,fe]=await Promise.all([fetch("/api/lan").then(Se=>Se.json()),fetch("/api/prefs").then(Se=>Se.json())]);if(!P.current)return;Ae!=null&&Ae.ok&&u(Ae),fe!=null&&fe.ok&&p(Array.isArray((pe=(ce=fe.prefs)==null?void 0:ce.lan)==null?void 0:pe.manual)?fe.prefs.lan.manual:[]),B.current=(Ae==null?void 0:Ae.enabled)===!0?q0:VM}catch{}},[]);w.useEffect(()=>{P.current=!0;let ce=0;const pe=async()=>{D(Date.now()),await W(),P.current&&(ce=window.setTimeout(pe,B.current))};return pe(),()=>{P.current=!1,window.clearTimeout(ce)}},[W]);const F=w.useCallback(async()=>{const ce=(c==null?void 0:c.enabled)===!0;if(ee("switch"))try{const pe=await Nl("/api/prefs",{lan:{enabled:!ce}});if(!P.current)return;pe!=null&&pe.ok?(V(null),ce||v(!0)):V(un(ce?"turn this off":"turn this on",pe)),await W()}catch{P.current&&V(un(ce?"turn this off":"turn this on",null))}finally{M()}},[c==null?void 0:c.enabled,W,ee,M]),G=w.useCallback(async(ce,pe,Ae)=>{if(!ee(`${ce}:${pe}`))return null;let fe=null;try{const Se=await Nl("/api/lan/peer",{action:ce,fp:pe});if(!P.current)return null;Se!=null&&Se.ok?(u(Se),V(null)):(fe=un(Ae,Se),V(fe)),await W()}catch{fe=un(Ae,null),P.current&&V(fe)}finally{M()}return fe},[W,ee,M]),re=w.useCallback(async ce=>{if(!ee(`drop:${ce}`))return null;let pe=null;try{const Ae=await Nl("/api/prefs",{lan:{manual:f.filter(fe=>fe!==ce)}});if(!P.current)return null;Ae!=null&&Ae.ok?(V(null),t()):(pe=un("stop dialling that address",Ae),V(pe)),await W()}catch{pe=un("stop dialling that address",null),P.current&&V(pe)}finally{M()}return pe},[f,W,t,ee,M]),[U,Y]=w.useState(null),z=w.useCallback(async(ce,pe)=>{if(!ee(`alias:${ce}`))return"Something else is still being saved. Try again in a moment.";try{const Ae=await Nl("/api/lan/peer",{action:"alias",fp:ce,name:pe});return P.current?Ae!=null&&Ae.ok?(u(Ae),null):un("rename that deck",Ae):null}catch{return un("rename that deck",null)}finally{M()}},[ee,M]),ie=w.useCallback(async ce=>{if(!ee(`check:${ce}`))return null;try{const pe=await Nl("/api/lan/sync",{fp:ce});return P.current?pe!=null&&pe.ok?(u(pe),t(),null):(pe==null?void 0:pe.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.":un("check that deck",pe):null}catch{return un("check that deck",null)}finally{M()}},[ee,M,t]),le=w.useCallback(async()=>{if(ee("check"))try{const ce=await Nl("/api/lan/sync",{});if(!P.current)return;ce!=null&&ce.ok?(u(ce),V(null)):V(un("check the other decks",ce)),t()}catch{P.current&&V(un("check the other decks",null))}finally{M()}},[ee,M,t]),ge=(c==null?void 0:c.enabled)===!0,Ne=Qz((c==null?void 0:c.pairingMode)==="invite"&&c?{...c,pending:[]}:c,K),Ie=U?Ne.find(ce=>{var pe;return ce.fp===U||((pe=ce.twins)==null?void 0:pe.some(Ae=>Ae.fp===U))})??null:null;w.useEffect(()=>{U&&c&&!Ie&&Y(null)},[U,c,Ie]);const Ge=Ne.filter(ce=>ce.kind==="asks"),Pe=Ne.filter(ce=>ce.kind!=="asks"),Be=Pe.filter(ce=>ce.here),Te=Pe.filter(ce=>!ce.here),st=Te.filter(ce=>ce.tone==="bad").length,de=H||Be.length===0,ue=Yz(c,K),se=Pe.filter(ce=>ce.kind==="paired").length,be=sU(c,Ne),Le=o.jsxs(o.Fragment,{children:[k&&c&&o.jsx(Ez,{status:c,manual:f,startWith:k==="invite"?"invite":void 0,onClose:()=>j(!1),onChanged:()=>{W(),t()}}),E&&o.jsx(UM,{title:"How Local network works",steps:bz,finish:ge?void 0:{label:"Turn it on",act:()=>{C(!1),F()}},onClose:()=>C(!1)}),y&&c&&o.jsx(Pz,{status:{...c,manualRows:f},accounts:e,manual:f,onClose:()=>v(!1),onChanged:()=>{W(),t()}}),Ie&&c&&o.jsx(Oz,{row:Ie,source:ej(c,Ie),status:c,accounts:e,now:K,busy:h,onClose:()=>Y(null),onRename:ce=>z(Ie.fp,ce),onCheck:()=>ie(Ie.fp),onVerb:()=>{switch(Ie.kind){case"paired":return G("unpair",Ie.fp,"unpair that deck");case"nearby":return G("accept",Ie.fp,"reach that deck");case"declined":return G("allow",Ie.fp,"let that deck ask again");case"dialling":return re(Ie.fp);default:return Promise.resolve(null)}},onSettings:()=>{Y(null),v(!0)},onInvite:()=>{Y(null),j("invite")},twins:(Ie.twins??[]).map(ce=>({row:ce,peer:ej(c,ce).peer??null})),onUnpair:ce=>G("unpair",ce,"unpair that deck")})]});if(!n){const ce=Se=>{window.clearTimeout(O.current),O.current=window.setTimeout(()=>I(!0),Se)},pe=()=>{window.clearTimeout(O.current),O.current=window.setTimeout(()=>I(!1),YM)},Ae=()=>window.clearTimeout(O.current),fe=()=>{window.clearTimeout(O.current),I(!1)};return o.jsxs("div",{className:"ap-foot",children:[o.jsxs("button",{type:"button",id:"ap-lan-entry",className:"ap-nav",onClick:()=>{fe(),r()},"aria-describedby":R?"ap-lan-peek":void 0,onPointerEnter:Se=>{Se.pointerType==="mouse"&&ce(KM)},onPointerLeave:pe,onFocus:Se=>{Se.target.matches(":focus-visible")&&ce(0)},onBlur:pe,children:[o.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:[o.jsx("rect",{x:"1.8",y:"2.3",width:"10.4",height:"7.2",rx:"1.2"}),o.jsx("path",{d:"M5 11.9h4M7 9.5v2.4"})]}),o.jsxs("span",{className:"ap-nav-text",children:[o.jsx("span",{className:"ap-nav-name",children:"Local network"}),o.jsxs("span",{className:"ap-nav-state","data-tone":be.tone,children:[be.live&&o.jsx("i",{className:"ap-nav-live","aria-hidden":!0}),be.text]})]}),o.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:o.jsx("path",{d:"M5.6 3.4 9.2 7l-3.6 3.6"})})]}),R&&o.jsx(rU,{anchorId:"ap-lan-entry",id:"ap-lan-peek",rows:Ne,onHold:Ae,onLet:pe}),o.jsx("p",{className:"vis-hidden",role:"status",children:ue.tone==="ok"?"":ue.text}),Le]})}return o.jsxs("div",{className:"ap-lan-view",children:[o.jsxs("div",{className:"ap-header",children:[o.jsx("button",{type:"button",id:"ap-lan-back",className:"glyph-btn ap-back",onClick:s,"aria-label":"Back to Claude accounts",title:"Back to Claude accounts",children:o.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:o.jsx("path",{d:"M8.4 3.4 4.8 7l3.6 3.6"})})}),o.jsx("h2",{id:"ap-lan-title",children:"Local network"}),o.jsxs("div",{className:"ap-header-right",children:[ge&&o.jsx("button",{type:"button",className:"glyph-btn ap-lan-plus",onClick:()=>j("add"),"aria-label":"Add a deck",title:(c==null?void 0:c.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:o.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:[o.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"}),o.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"})]})}),ge&&se>0&&o.jsx("button",{type:"button",className:"glyph-btn ap-lan-check",...Z("check"),onClick:()=>void le(),"aria-label":h==="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:o.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:[o.jsx("circle",{cx:"7",cy:"7",r:"1.1",fill:"currentColor",stroke:"none"}),o.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"}),o.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"})]})}),ge&&o.jsx("button",{type:"button",className:"glyph-btn ap-lan-set",...Z("setup"),onClick:()=>v(!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:o.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":!0,children:[o.jsx("path",{d:"M1.8 4.7h10.4M1.8 9.3h10.4"}),o.jsx("circle",{cx:"9.1",cy:"4.7",r:"1.6",fill:"var(--panel)"}),o.jsx("circle",{cx:"4.9",cy:"9.3",r:"1.6",fill:"var(--panel)"})]})}),l]})]}),o.jsx("div",{className:"ap-scroll",id:"ap-lan-scroll",children:o.jsxs("div",{className:"ap-lan",children:[o.jsxs("div",{className:"ap-policy",children:[o.jsx("h3",{className:"ap-auto-title",children:"Sync with paired decks"}),o.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":ge,"aria-label":"Sync with paired decks",...Z("switch"),onClick:()=>void F(),title:ge?"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:o.jsx("span",{className:"switch-knob"})})]}),ge&&o.jsx(WM,{reach:c==null?void 0:c.reach,where:"panel"}),ge&&(c==null?void 0:c.deaf)&&o.jsx("p",{className:"ap-lan-fine",children:c.deaf}),ge&&(c==null?void 0:c.lanTunneled)&&o.jsx("p",{className:"ap-lan-fine",children:Kz(c)}),!ge&&o.jsxs("button",{type:"button",className:"ap-lan-intro",onClick:()=>C(!0),title:"Four pictures: what this does, and what to do on each machine",children:[o.jsx(kz,{}),o.jsx("span",{className:"ap-lan-intro-text",children:"Paired machines repair each other's expired logins."}),o.jsx("span",{className:"ap-lan-intro-go",children:"See how it works"})]}),o.jsx("p",{className:`ap-lan-status ${ue.tone}`,role:"status",children:ue.tone==="ok"?"":ue.text}),$&&o.jsxs("div",{className:"ap-failure",role:"alert",children:[o.jsx("span",{className:"ap-failure-text",children:$}),o.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>V(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),ge&&o.jsxs(o.Fragment,{children:[Ge.length>0&&o.jsx("div",{className:"ap-lan-asks",role:"alert",children:Ge.map(ce=>o.jsxs("div",{className:"ap-lan-ask",children:[o.jsxs("span",{className:"ap-lan-ask-what",children:[o.jsx("strong",{className:"ap-lan-peer-name",children:ce.name})," at ",o.jsx("code",{className:"ap-lan-code",children:ce.addr})," wants to pair"]}),o.jsxs("span",{className:"ap-lan-ask-fp",children:["fingerprint ",o.jsx("code",{className:"ap-lan-code",children:ce.fp})]}),o.jsxs("span",{className:"ap-lan-ask-acts",children:[o.jsx("button",{type:"button",className:"ap-manage-btn",...Z(`accept:${ce.fp}`),onClick:()=>void G("accept",ce.fp,"accept that deck"),title:`Talk to this deck from now on. Its fingerprint is ${ce.fp} — check it matches the one on their screen before you accept.`,children:"accept"}),o.jsx("button",{type:"button",className:"ap-manage-btn",...Z(`dismiss:${ce.fp}`),onClick:()=>void G("dismiss",ce.fp,"decline that request"),title:"Say no. Nothing is shared, and that deck is told rather than left waiting.",children:"decline"})]})]},ce.fp))}),(de?[...Be,...Te]:Be).length>0&&o.jsx("ul",{className:"ap-lan-here",children:(de?[...Be,...Te]:Be).map((ce,pe)=>o.jsxs("li",{className:"ap-lan-who","data-tone":ce.tone,children:[o.jsx("i",{className:ce.here?"ap-pulse":"ap-dot","aria-hidden":!0}),o.jsxs("span",{className:"ap-lan-who-name","aria-hidden":!0,children:[ce.name,ce.via==="tailscale"&&o.jsx("span",{className:"ap-lan-via",children:" · Tailscale"})]}),o.jsx("button",{type:"button",className:"ap-lan-who-open","aria-haspopup":"dialog","aria-describedby":`lan-who-state-${pe}`,onClick:()=>Y(ce.fp),children:o.jsxs("span",{className:"vis-hidden",children:[ce.name,ce.via==="tailscale"?", over Tailscale":"",", details"]})}),o.jsx("span",{id:`lan-who-state-${pe}`,className:ce.quiet?"vis-hidden":"ap-lan-who-when",children:ce.state}),ce.kind==="nearby"&&(c==null?void 0:c.pairingMode)!=="invite"&&o.jsx("button",{type:"button",className:"ap-manage-btn ap-lan-do",...Z(`accept:${ce.fp}`),onClick:()=>void G("accept",ce.fp,"reach that deck"),"aria-label":`Ask ${ce.name} to pair`,title:`Send ${ce.name} a request. Somebody at that machine has to accept it before anything is shared. Its fingerprint is ${ce.fp}.`,children:"ask"}),(ce.kind==="nearby"||ce.kind==="declined")&&(c==null?void 0:c.pairingMode)==="invite"&&o.jsx("button",{type:"button",className:"ap-manage-btn ap-lan-do","aria-haspopup":"dialog",onClick:()=>j("invite"),"aria-label":`Invite ${ce.name} to pair`,title:`This deck pairs only by invite. Make one and send it to whoever is at ${ce.name}.`,children:"invite"}),ce.kind==="paired"&&o.jsx("button",{type:"button",className:`ap-manage-btn ap-lan-do danger${S===ce.fp?" armed":""}`,...Z(`unpair:${ce.fp}`),onClick:()=>{const Ae=Date.now(),fe=Cu({armedFor:S,target:ce.fp,armedAt:_.current,now:Ae,gapMs:Mu});if(fe==="arm"){b(ce.fp),_.current=Ae,window.setTimeout(()=>b(Se=>Se===ce.fp?null:Se),4e3);return}fe!=="ignore"&&(b(null),G("unpair",ce.fp,"unpair that deck"))},"aria-label":S===ce.fp?`Confirm unpairing ${ce.name}`:`Unpair ${ce.name}`,title:S===ce.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:S===ce.fp?"confirm":"unpair"}),ce.kind==="dialling"&&o.jsx("button",{type:"button",className:"ap-manage-btn ap-lan-do",...Z(`drop:${ce.fp}`),onClick:()=>void re(ce.fp),"aria-label":`Stop dialling ${ce.name}`,title:"Stop trying this address. Nothing was ever paired here.",children:"stop"}),ce.kind==="declined"&&(c==null?void 0:c.pairingMode)!=="invite"&&o.jsx("button",{type:"button",className:"ap-manage-btn ap-lan-do",...Z(`allow:${ce.fp}`),onClick:()=>void G("allow",ce.fp,"let that deck ask again"),"aria-label":`Let ${ce.name} ask again`,title:"Take the no back. That deck is still trying, so the request comes round again on its own.",children:"allow"})]},`${ce.kind}:${ce.fp}`))}),(Be.length>0&&Te.length>0||ge&&se>0)&&o.jsxs("div",{className:"ap-lan-tail",children:[Be.length>0&&Te.length>0&&o.jsxs("button",{type:"button",className:"ap-lan-word ap-lan-more","aria-expanded":H,onClick:()=>q(ce=>!ce),title:H?"Show only the decks that are on":`Show the ${Te.length} deck${Te.length===1?"":"s"} that are not responding right now`,children:[o.jsx("span",{className:`ap-lan-chev${H?" open":""}`,"aria-hidden":!0,children:"›"}),H?"fewer":`${Te.length} more`,!H&&st>0&&o.jsxs("span",{className:"ap-lan-more-bad",children:[" · ",st," not responding"]})]}),ge&&se>0&&o.jsx("span",{className:"ap-lan-checked",children:Xz(c==null?void 0:c.checkedAt,K,h==="check")})]}),Pe.length===0&&Ge.length===0&&!(c!=null&&c.stalled)&&!(c!=null&&c.deaf)&&!(c!=null&&c.lanTunneled)&&o.jsxs(o.Fragment,{children:[o.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."}),o.jsx("button",{type:"button",className:"ap-lan-word ap-lan-how",onClick:()=>C(!0),children:"How it works"})]})]})]})}),Le]})}function oU({anchorId:e,id:t,peers:n,onHold:r,onLet:s}){const l=w.useRef(null),{title:c,shown:u,rest:f}=iz(n),p=w.useCallback(()=>{const h=l.current,m=document.getElementById(e);if(!h||!m)return;const y=$b(m.getBoundingClientRect(),{width:h.offsetWidth,height:h.offsetHeight},{width:window.innerWidth,height:window.innerHeight});h.style.top=`${y.top}px`,h.style.left=`${y.left}px`,h.style.maxHeight=y.maxHeight==null?"":`${y.maxHeight}px`,h.dataset.side=y.side},[e]);return w.useLayoutEffect(()=>{p()}),w.useEffect(()=>(window.addEventListener("scroll",p,!0),window.addEventListener("resize",p),()=>{window.removeEventListener("scroll",p,!0),window.removeEventListener("resize",p)}),[p]),Mn.createPortal(o.jsxs("div",{ref:l,id:t,className:"ap-peek ap-fold-peek",role:"tooltip",onPointerEnter:r,onPointerLeave:s,children:[o.jsx("p",{className:"ap-peek-title",children:c}),o.jsx("div",{className:"ap-peek-list",children:u.map(h=>o.jsxs("span",{className:"ap-peek-who ap-fold-who",children:[o.jsx("span",{className:"ap-fold-name",children:h.name}),o.jsx("span",{className:"ap-fold-state","data-tone":h.ready?"ok":h.warn?"warn":"idle",children:h.ready?h.headroom==null?"not read yet":`${h.headroom}% free`:h.why})]},h.key))}),f&&o.jsx("p",{className:"ap-peek-rest",children:f})]}),document.body)}function iU({peers:e,strained:t,armed:n,threshold:r,open:s,onToggle:l}){const[c,u]=w.useState(!1),f=w.useRef(0);w.useEffect(()=>()=>window.clearTimeout(f.current),[]),w.useEffect(()=>{s&&(window.clearTimeout(f.current),u(!1))},[s]);const p=S=>{s||(window.clearTimeout(f.current),f.current=window.setTimeout(()=>u(!0),S))},h=()=>{window.clearTimeout(f.current),f.current=window.setTimeout(()=>u(!1),YM)},m=()=>window.clearTimeout(f.current),y=()=>{window.clearTimeout(f.current),u(!1)},v=az(e,{strained:t&&!s,armed:n,threshold:r});return o.jsxs("div",{className:"ap-rest",children:[o.jsxs("button",{type:"button",id:"ap-rest-entry",className:"ap-nav","aria-expanded":s,"aria-controls":s?"ap-rest-panel":void 0,"aria-describedby":c?"ap-rest-peek":void 0,onClick:()=>{y(),l()},onPointerEnter:S=>{S.pointerType==="mouse"&&p(KM)},onPointerLeave:h,onFocus:S=>{S.target.matches(":focus-visible")&&p(0)},onBlur:h,children:[o.jsxs("span",{className:"ap-nav-text",children:[o.jsx("span",{className:"ap-nav-name",children:"Other accounts"}),o.jsx("span",{className:"ap-nav-state","data-tone":v.tone,children:v.text})]}),o.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:o.jsx("path",{d:"M5.6 3.4 9.2 7l-3.6 3.6"})})]}),c&&o.jsx(oU,{anchorId:"ap-rest-entry",id:"ap-rest-peek",peers:e,onHold:m,onLet:h})]})}async function lU(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}const cU=1800;function uU({accounts:e,onClose:t,copyText:n}){const[r,s]=w.useState([]),[l,c]=w.useState(null),[u,f]=w.useState(!1),[p,h]=w.useState(null),[m,y]=w.useState(!1),[v,S]=w.useState(()=>Math.floor(Date.now()/1e3)),b=w.useRef(null),_=w.useRef(!1),k=pn(t,{focusRef:b});w.useEffect(()=>{if(!l)return;S(Math.floor(Date.now()/1e3));const $=window.setInterval(()=>S(Math.floor(Date.now()/1e3)),1e3);return()=>window.clearInterval($)},[l]);const j=KB(e),E=YB(e,r),C=E.length===e.length,R=$=>s(V=>XB(V,$)),I=w.useCallback(async()=>{const $=ZB(E);if(!Ps(_.current)||!$)return;_.current=!0,f(!0),h(null),y(!1);const V=await lU($).catch(()=>null);if(_.current=!1,f(!1),!(V!=null&&V.ok)){h(Al(V,"the share could not be made"));return}c({blob:V.blob,expiresAt:V.expiresAt,shared:V.shared??[],failed:V.failed??[]})},[e,E]),O=l?zM(l.expiresAt,v):null,H=(O==null?void 0:O.tone)==="gone",q=(l==null?void 0:l.shared.length)??0;return Mn.createPortal(o.jsx("div",{className:"modal-backdrop",onClick:t,role:"presentation",children:o.jsxs("div",{ref:k,className:"modal sa-modal",onClick:$=>$.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Share accounts with another deck",children:[o.jsxs("header",{className:"modal-head",children:[o.jsx("div",{className:"modal-title",children:o.jsx("h3",{children:"Share accounts"})}),o.jsx("div",{className:"modal-actions",children:o.jsx("button",{type:"button",className:"glyph-btn",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),o.jsx("section",{className:"modal-body sa-body",children:l?o.jsxs("div",{className:"sa-step",children:[o.jsx("h4",{children:H?"This share has expired":q===1?"1 account, ready to paste":`${q} accounts, ready to paste`}),o.jsx("code",{className:`ap-share-blob${H?" sa-dead":""}`,children:l.blob}),o.jsxs("div",{className:"ap-share-foot",children:[o.jsx("button",{type:"button",className:"ap-manage-btn",ref:b,onClick:async()=>{if(H){c(null),I();return}await n(l.blob)&&(y(!0),window.setTimeout(()=>y(!1),cU))},children:H?"make a new share":m?"copied":`copy ${q===1?"the share":"all "+q}`}),o.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:[o.jsx("span",{className:"ap-share-warn",children:q===1?"this is the password":`this is ${q} passwords`})," · ",o.jsx("span",{className:`ap-share-expiry ${O==null?void 0:O.tone}`,children:O==null?void 0:O.text})]})]}),l.failed.length>0&&o.jsxs("div",{className:"sa-failed",role:"alert",children:[o.jsx("p",{className:"sa-failed-head",children:l.failed.length===1?"One account is not in this bundle:":`${l.failed.length} accounts are not in this bundle:`}),o.jsx("ul",{className:"sa-list",children:l.failed.map($=>{var ne;const V=!!($.email&&((ne=$.detail)!=null&&ne.includes($.email)));return o.jsxs("li",{children:[!V&&o.jsx("span",{className:"sa-who",children:$.email||`account ${$.num}`}),o.jsx("span",{className:"sa-why",children:$.detail||"could not be exported"})]},`${$.num}-${$.email}`)})})]}),o.jsx("p",{className:"sa-note",children:H?o.jsx(o.Fragment,{children:"Another deck will refuse this text now. Make a new one — the same accounts are still picked."}):o.jsxs(o.Fragment,{children:["Paste it into the other deck with ",o.jsx("strong",{children:"+"})," → ",o.jsx("strong",{children:"Paste a share"}),". Accounts it already holds are left exactly as they are."]})}),o.jsxs("div",{className:"sa-actions",children:[o.jsx("button",{type:"button",className:"btn",onClick:()=>{c(null),y(!1)},children:"Pick again"}),o.jsx("button",{type:"button",className:"btn primary",onClick:t,children:"Done"})]})]}):e.length===0?o.jsxs("div",{className:"sa-step",children:[o.jsx("h4",{children:"Nothing to share"}),o.jsxs("p",{className:"sa-note",children:["This deck is not holding any accounts right now. Sign one in with ",o.jsx("strong",{children:"+"}),", or wait — the panel is still reading the store."]}),o.jsx("div",{className:"sa-actions",children:o.jsx("button",{type:"button",className:"btn primary",ref:b,onClick:t,children:"Close"})})]}):o.jsxs("div",{className:"sa-step",children:[o.jsxs("h4",{children:["Which accounts go to the other ",dn,"?"]}),o.jsx("p",{className:`sa-count${E.length?"":" empty"}`,children:QB(E.length)}),o.jsx("ul",{className:"sa-list sa-pick",children:j.map($=>o.jsx("li",{children:o.jsxs("label",{className:"sa-row",children:[o.jsx("input",{type:"checkbox",checked:E.includes($.num),onChange:()=>R($.num)}),o.jsx("span",{className:"sa-who",children:$.label}),$.sub&&o.jsx("span",{className:"sa-sub",children:$.sub})]})},$.num))}),p&&o.jsx("p",{className:"aa-err",children:p}),o.jsxs("div",{className:"sa-actions",children:[o.jsx("button",{type:"button",className:"btn",onClick:()=>s(C?e.map($=>$.num):[]),children:C?"Clear all":"Select all"}),o.jsx("button",{type:"button",className:"btn primary",ref:b,...Qa(u,!E.length),onClick:I,children:u?"making the share…":E.length===0?"Share":E.length===1?"Share 1 account":`Share ${E.length} accounts`})]})]})})]})}),document.body)}function dU(e,t){const n=new Set(e),r=e.length?Math.max(...e):0;return[...new Set([...e,r+1])].sort((s,l)=>s-l).map(s=>{const l=s===t?"here":n.has(s)?"swap":"free";return{slot:s,kind:l,label:l==="here"?`slot ${s}`:`slot ${s} · ${l}`}})}function hU(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}}function fU(e,t,n){return t!=null&&e.some(r=>r.slot===t)?t:n}function pU(e,t,n){var s;const r=((s=e.find(l=>l.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 mU(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 tj(e){return typeof e.id=="string"&&e.id.startsWith("scoped-")}function gU(e){const t=e.filter(u=>!tj(u)),n=e.filter(u=>tj(u)),r=t.length?t:n,s=t.length?n:[],l=r.reduce((u,f)=>u&&u.pct>=f.pct?u:f,null);let c=null;for(const u of s)l&&u.pct<=l.pct||(!c||u.pct>c.pct)&&(c=u);return{shown:r,rest:s,fuller:c,peak:c??l}}const yU="\0";function sf(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}${yU}${n}`}function wU(e,t){const n=sf(t);return e.includes(n)?e.filter(r=>r!==n):[...e,n]}function vU(e,t){if(!Array.isArray(t))return e;const n=new Set(t.map(sf)),r=e.filter(s=>n.has(s));return r.length===e.length?e:r}const xU=64;function bU(e,t){const n=e.trim();return{alias:n,commit:n!==(t??"").trim()}}function kU(e,t){return!e||!t||t.some(n=>n.num===e.num&&n.active)?e:null}const NU=Object.freeze({text:"couldn't reach the deck server",reload:!0}),SU=Object.freeze({text:"still waiting on the deck server — claude-swap can be slow to answer",reload:!0});async function nj(e){return e.ok?{ok:!0,status:e.status,body:null}:{ok:!1,status:e.status,body:await e.json().catch(()=>null)}}function jU(e){const t=e.find(r=>!r.ok);if(!t)return null;const n=Au(t.body);return{text:O0(t.body,`the deck server answered ${t.status}`),...n?{raw:n}:{},reload:!0}}function rj(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 sj=15e3,_U=8e3,EU=1800,CU=3e4,Tm=[70,80,85,90,95];function Rm(e,t){return kM(t-Math.floor(e/1e3))}function TU(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 lu(e){return e.charAt(0).toUpperCase()+e.slice(1)}function RU(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 AU(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 MU(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.`}}}function Nh(e,t){if(e.staleCopy){const n=RU(e.repair??null,t);return{text:lu(n.text),hint:n.hint,fix:null,tone:"quiet",blocksSwitch:!1}}if(e.stopped){const n=MU(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:lu(n.text),hint:n.hint,fix:n.fix?lu(n.fix):null,tone:r||e.collector==="keychain_unavailable"?"warn":"quiet",blocksSwitch:r}}if(e.error){const n=AU(e.error);return{text:lu(n.text),hint:n.hint,fix:n.fixable?"Sign in again":null,tone:n.fixable?"warn":"quiet",blocksSwitch:n.fixable}}return null}function Am(){return o.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:[o.jsx("path",{d:"M7 1.9 12.9 12H1.1Z"}),o.jsx("path",{d:"M7 5.6v2.9"}),o.jsx("path",{d:"M7 10.3v.05"})]})}function IU(e){return e>=90?"hi":e>=70?"mid":void 0}function $U(e){const t=Number(e);return[...Number.isFinite(t)&&t>0&&!Tm.includes(t)?[...Tm,t]:Tm].sort((r,s)=>r-s)}function OU({lane:e,nowSec:t,frozen:n}){const r=Math.min(100,Math.max(0,e.pct)),s=n?"var(--muted)":r>=90?"var(--err)":r>=70?"var(--warn)":"var(--accent)",l=e.resetAt&&!n?NM(e.resetAt,t):null;return o.jsxs("div",{className:"ap-lane",children:[o.jsx("span",{className:"ap-lane-label",title:e.label,children:e.label}),o.jsx("div",{className:"ap-lane-track",children:o.jsx("div",{className:"ap-lane-fill",style:{width:`${r===0?1.5:r}%`,background:s,opacity:r===0||n?.4:1}})}),o.jsxs("span",{className:"ap-lane-pct",style:{color:s},children:[r,"%"]}),o.jsx("span",{className:"ap-lane-reset",title:l?`${e.label} resets in ${l}`:void 0,children:l&&o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"vis-hidden",children:"resets in "}),l]})})]})}function LU({onClose:e,leaving:t}){var xr,$n,Hs;const[n,r]=w.useState(null),[s,l]=w.useState(null),[c,u]=w.useState(null),[f,p]=w.useState(!1),[h,m]=w.useState(null),[y,v]=w.useState(null),[S,b]=w.useState("accounts"),[_,k]=w.useState(!1),[j,E]=w.useState(null),C=w.useRef(j);C.current=j;const[R,I]=w.useState(()=>Math.floor(Date.now()/1e3)),O=w.useRef(null),[H,q]=w.useState(null),$=(H==null?void 0:H.num)??null,V=w.useRef(H);V.current=H;const[ne,ee]=w.useState(null),[M,Z]=w.useState(!1),[K,D]=w.useState(""),[P,B]=w.useState(null),W=w.useRef(0),[F,G]=w.useState(null),[re,U]=w.useState(!1),[Y,z]=w.useState(!1),[ie,le]=w.useState(null),[ge,Ne]=w.useState(null),[Ie,Ge]=w.useState(null),[Pe,Be]=w.useState(null),[Te,st]=w.useState(!1),de=w.useRef(null),ue=w.useRef(null),[se,be]=w.useState([]),[Le,ce]=w.useState(!1),pe=w.useRef(null),Ae=w.useCallback(Q=>Tf(pe.current)?(pe.current=Q,u(Q),!0):!1,[]),fe=w.useCallback(()=>{pe.current=null,u(null)},[]),Se=(Q,De=!1)=>{const et=ao(c,Q);return{disabled:et.disabled,"aria-busy":et.busy||De}},Ye=w.useCallback(Q=>{window.requestAnimationFrame(()=>{var De;if(A0(((De=document.activeElement)==null?void 0:De.tagName)??null))for(const et of u8(Q)){const Ue=document.querySelector(et);if(Ue){Ue.focus();return}}})},[]),qe=w.useCallback(async(Q=!1)=>{Q&&p(!0);const De=new AbortController,et=window.setTimeout(()=>De.abort(),CU);try{const[Ue,tt]=await Promise.all([fetch(`/api/claude-accounts${Q?"?refresh=1":""}`,{signal:De.signal}),fetch("/api/cswap-auto",{signal:De.signal})]);if(Ue.ok){const gt=await Ue.json();r(gt),be(It=>vU(It,gt.accounts))}tt.ok&&l(await tt.json());const wt=jU([await nj(Ue),await nj(tt)]);m(gt=>rj(gt,wt))}catch{m(Ue=>rj(Ue,De.signal.aborted?SU:NU))}finally{window.clearTimeout(et),Q&&p(!1)}},[]),ke=w.useCallback(async(Q,De,et="panel")=>{if(!Ae(De))return null;const Ue=et==="menu"?ee:m;Ue(null);try{const tt=await fetch("/api/cswap-auto",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Q)}),wt=await tt.json().catch(()=>null);return wt!=null&&wt.ok||Ue({text:O0(wt,"command failed",tt.status),raw:Au(wt)}),wt}catch{return Ue({text:"server unreachable"}),null}finally{fe()}},[Ae,fe]),Re=w.useCallback(async(Q,De)=>{if(!Ae(De))return null;m(null),ee(null);try{const et=await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Q)}),Ue=await et.json().catch(()=>null);return Ue!=null&&Ue.ok||ee({text:Al(Ue,"command failed",et.status)}),Ue}catch{return ee({text:"server unreachable"}),null}finally{fe()}},[Ae,fe]);w.useEffect(()=>(qe(!0),O.current=window.setInterval(()=>qe(!1),sj),()=>{O.current!=null&&window.clearInterval(O.current)}),[qe]),w.useEffect(()=>{!(n!=null&&n.ok)||!n.accounts||v(Q=>kU(Q,n.accounts))},[n]),w.useEffect(()=>{const Q=window.setInterval(()=>I(Math.floor(Date.now()/1e3)),3e4);return()=>window.clearInterval(Q)},[]);const ze=((xr=s==null?void 0:s.settings["autoswitch.threshold"])==null?void 0:xr.value)??"90",Fe=Pe??ze,We=mU(Fe,ze),rt=($n=n==null?void 0:n.accounts)==null?void 0:$n.find(Q=>Q.active),dt=rt?Nh(rt,R):null,ct=(n==null?void 0:n.accounts)??[],yt=rt?ct.filter(Q=>!Q.active):[],Ot=yt.length?ct.filter(Q=>Q.active):ct,zt=yt.map(Q=>{const De=Nh(Q,R);return{key:sf(Q),name:Q.alias??Q.email??`account ${Q.num}`,ready:!Q.disabled&&!(De!=null&&De.blocksSwitch),why:Q.disabled?"held out":De!=null&&De.blocksSwitch?De.text:null,warn:(De==null?void 0:De.tone)==="warn",headroom:Q.headroom}}),Xt=Number(ze),Dt=(rt==null?void 0:rt.headroom)!=null&&Number.isFinite(Xt)&&100-rt.headroom>=Xt,rn=(s==null?void 0:s.ok)===!0&&(s.enabled||s.external),je=Q=>Le&&yt.some(De=>De.num===Q)?"ap-rest-list":"ap-scroll",xt=async(Q,De)=>{if(Ae(`switch-${Q}`)){m(null),v(null);try{const Ue=await(await fetch("/api/claude-accounts/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({account:Q})})).json().catch(()=>null);Ue!=null&&Ue.ok?v({num:Q,name:De}):m({text:O0(Ue,"the switch failed"),raw:Au(Ue),row:Q}),await qe(!0)}catch{m({text:"server unreachable",row:Q})}finally{fe(),Ye(Q)}}},bt=w.useCallback(()=>{q(null),ee(null),B(null),G(null),z(!1)},[]),_n=(Q,De="first")=>{bt(),E(null),Ge(null),q({num:Q,view:"menu",start:De})},Ut=(Q,De)=>{bt(),E(et=>(et==null?void 0:et.anchor)===De?null:{num:Q,anchor:De})},Vn=w.useCallback((Q=!1)=>{var et;const De=C.current;Q&&De&&((et=document.getElementById(De.anchor))==null||et.focus()),E(null)},[]),Vt=()=>{bt(),E(null),b("lan")},Lt=w.useRef(S);w.useEffect(()=>{Lt.current!==S&&(Lt.current=S,window.requestAnimationFrame(()=>{var Q;(Q=document.getElementById(S==="lan"?"ap-lan-back":"ap-lan-entry"))==null||Q.focus()}))},[S]),w.useEffect(()=>{n!=null&&n.ok&&k(!0)},[n==null?void 0:n.ok]);const Zt=w.useCallback(Q=>{var Ue,tt;const De=V.current;if(!De||Q!=null&&De.num!==Q)return;const et=document.getElementById(`ap-menu-${De.num}`);(et!=null&&et.contains(document.activeElement)||A0(((Ue=document.activeElement)==null?void 0:Ue.tagName)??null))&&((tt=document.getElementById(`ap-more-${De.num}`))==null||tt.focus()),bt()},[bt]);w.useEffect(()=>{t&&(bt(),E(null))},[t,bt]),w.useEffect(()=>{H&&(n!=null&&n.accounts)&&!n.accounts.some(Q=>Q.num===H.num)&&bt(),j&&(n!=null&&n.accounts)&&!n.accounts.some(Q=>Q.num===j.num)&&E(null)},[n,H,j,bt]);const In=async Q=>{var et;z(!1);const De=await Re({action:"share",account:Q},`share-${Q}`);!(De!=null&&De.ok)||((et=V.current)==null?void 0:et.num)!==Q||(G({num:Q,blob:De.blob,expiresAt:De.expiresAt}),q({num:Q,view:"share"}))},Hr=async(Q,De)=>{const{commit:et,alias:Ue}=bU(K,De);if(et){const tt=await Re({action:"alias",account:Q,alias:Ue},`alias-${Q}`);if(await qe(!0),!(tt!=null&&tt.ok))return}Zt(Q)},xe=async(Q,De)=>{var tt,wt;const et=await Re({action:"move",account:Q,slot:De},`move-${Q}`),Ue=hU({menuFor:((tt=V.current)==null?void 0:tt.num)??null,shareFor:(F==null?void 0:F.num)??null},Q,et);if(await qe(!0),Ue){((wt=V.current)==null?void 0:wt.num)===Q&&bt(),B(Ue.confirmRemove),Ue.shareFor==null&&(G(null),z(!1)),Ne(Ue.swapNote);const gt=Ue.swapNote;gt&&window.setTimeout(()=>Ne(It=>It===gt?null:It),_U),Ge(null),Ye(Ue.menuFor)}return et},lr=async(Q,De,et)=>{if(!et.sends){Zt(Q);return}await xe(Q,De)},ks=async(Q,De)=>{if(De.sends){const et=await ke({action:"setting",key:"autoswitch.threshold",value:Q},"threshold");if(await qe(!0),!(et!=null&&et.ok))return;Be(null)}st(!0),window.setTimeout(()=>{var et;document.activeElement===ue.current&&((et=de.current)==null||et.focus()),st(!1)},EU)},Wr=o.jsx("button",{type:"button",className:"glyph-btn",onClick:e,"aria-label":"Close accounts panel",title:"Close (A)",children:o.jsx("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":!0,children:o.jsx("path",{d:"M3.4 3.4l7.2 7.2M10.6 3.4l-7.2 7.2"})})}),fa=Q=>{const{shown:De,fuller:et}=gU(Q.lanes),Ue=Nh(Q,R),tt=Q.active||se.includes(sf(Q)),wt=Q.alias??Q.email??`account ${Q.num}`,gt=Q.alias&&Q.email?`${Q.alias} · ${Q.email}`:wt,It=Q.stale||(Ue==null?void 0:Ue.blocksSwitch)===!0,Rt=et?[...De,et]:De,Qt=Q.fetchedAt?Rm(Q.fetchedAt,R):null;return o.jsxs("li",{className:`ap-account${Q.active?" active":""}`,"aria-current":Q.active?"true":void 0,"data-open":tt?"":void 0,"data-frozen":It?"":void 0,children:[!Q.active&&o.jsx("button",{type:"button",className:"ap-row-open",id:`ap-row-${Q.num}`,title:gt,"aria-expanded":tt,"aria-controls":tt?`ap-detail-${Q.num}`:void 0,"aria-describedby":[Q.alias&&Q.email?`ap-email-${Q.num}`:null,!tt&&!(Ue!=null&&Ue.blocksSwitch)?`ap-quota-${Q.num}`:null].filter(Boolean).join(" ")||void 0,onClick:()=>be(Nt=>wU(Nt,Q)),children:o.jsxs("span",{className:"vis-hidden",children:[wt,", ",tt?"hide details":"details"]})}),o.jsxs("div",{className:"ap-account-head",children:[Q.active?o.jsx("span",{className:"ap-live",title:`Active account · slot ${Q.num}`,children:o.jsxs("span",{className:"vis-hidden",children:["Active account, slot ",Q.num,":"]})}):o.jsx("span",{className:"ap-num",children:Q.num}),Q.alias&&o.jsx("span",{className:"ap-alias",title:Q.alias,children:Q.alias}),o.jsx("span",{className:"ap-email",id:`ap-email-${Q.num}`,title:Q.email??void 0,children:Q.email}),Q.disabled&&o.jsx("span",{className:"ap-held",children:"held out"}),!Q.active&&!Q.disabled&&!(Ue!=null&&Ue.blocksSwitch)&&o.jsx("button",{type:"button",className:"ap-switch",...Se(`switch-${Q.num}`),onClick:()=>xt(Q.num,wt),"aria-label":`Switch to ${wt}`,title:`Switch to ${Q.alias??Q.email}`,children:c===`switch-${Q.num}`?"…":"Switch"}),o.jsx("button",{type:"button",id:`ap-more-${Q.num}`,className:"ap-more","aria-label":`More actions for ${Q.email??Q.alias??`account ${Q.num}`}`,"aria-haspopup":"menu","aria-expanded":$===Q.num,"aria-controls":$===Q.num?`ap-menu-${Q.num}`:void 0,title:"More actions",onClick:()=>$===Q.num?Zt():_n(Q.num),onKeyDown:Nt=>{Nt.key!=="ArrowDown"&&Nt.key!=="ArrowUp"||(Nt.preventDefault(),_n(Q.num,Nt.key==="ArrowUp"?"last":"first"))},children:o.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"currentColor","aria-hidden":!0,children:[o.jsx("circle",{cx:"2.8",cy:"7",r:"1.15"}),o.jsx("circle",{cx:"7",cy:"7",r:"1.15"}),o.jsx("circle",{cx:"11.2",cy:"7",r:"1.15"})]})})]}),(h==null?void 0:h.row)===Q.num&&o.jsxs("div",{className:"ap-failure ap-row-failure",role:"alert",children:[o.jsx("span",{className:"ap-failure-text",title:h.raw||void 0,children:h.text}),o.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>m(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),Q.active&&(y==null?void 0:y.num)===Q.num&&o.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."}),(ge==null?void 0:ge.at)===Q.num&&(()=>{const Nt=ct.find(cr=>cr.num===ge.displaced),br=(Nt==null?void 0:Nt.alias)??(Nt==null?void 0:Nt.email)??"the account that was there";return o.jsxs("p",{className:"ap-note ap-swap-note",title:`Slot ${ge.at} was taken, so the two accounts traded places: ${br} now holds slot ${ge.displaced}.`,children:["swapped with slot ",ge.displaced]})})(),Ue&&o.jsxs("div",{className:"ap-issue-line",children:[o.jsxs("button",{type:"button",id:`ap-issue-${Q.num}`,className:"ap-issue","data-tone":Ue.tone,"aria-haspopup":"dialog","aria-expanded":(j==null?void 0:j.anchor)===`ap-issue-${Q.num}`,"aria-controls":(j==null?void 0:j.anchor)===`ap-issue-${Q.num}`?"ap-issue-pop":void 0,onClick:()=>Ut(Q.num,`ap-issue-${Q.num}`),children:[Ue.tone==="warn"&&o.jsx(Am,{}),o.jsx("span",{className:"ap-issue-text",children:Ue.text})]}),!tt&&o.jsx("span",{className:"ap-issue-age",title:"When claude-swap last read this account's usage",children:Qt??"never collected"})]}),!tt&&!(Ue!=null&&Ue.blocksSwitch)&&o.jsxs("p",{className:"ap-quota",id:`ap-quota-${Q.num}`,children:[Rt.length?Rt.map(Nt=>o.jsxs("span",{className:"ap-q",children:[o.jsx("span",{className:"ap-q-label",children:Nt.label})," ",o.jsxs("span",{className:"ap-q-pct","data-level":It?void 0:IU(Nt.pct),children:[Math.round(Nt.pct),"%"]})]},Nt.id)):o.jsx("span",{className:"ap-q-label",children:"no usage recorded yet"}),Q.stale&&!Ue&&o.jsx("span",{className:"ap-q-age","data-never":Qt?void 0:"",title:"When claude-swap last read this account's usage",children:Qt??"never collected"})]}),tt&&o.jsxs("div",{className:"ap-detail",id:`ap-detail-${Q.num}`,children:[o.jsx("div",{className:"ap-lanes",children:Q.lanes.length?Q.lanes.map(Nt=>o.jsx(OU,{lane:Nt,nowSec:R,frozen:It},Nt.id)):o.jsx("div",{className:"ap-hint",children:"No usage recorded yet."})}),o.jsx("div",{className:"ap-meta",children:Q.fetchedAt?o.jsxs("span",{className:`ap-age${Q.stale&&!Ue?" 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 ",Rm(Q.fetchedAt,R),Ue!=null&&Ue.blocksSwitch?"":TU(Q.nextAt,R)]}):o.jsx("span",{className:"ap-age ap-stale",title:"claude-swap has not read this account yet",children:"never collected"})})]})]},Q.num)},Ns=n!=null&&n.ok&&(s!=null&&s.ok)?o.jsxs("div",{className:"ap-policy-block",children:[o.jsxs("div",{className:"ap-policy",children:[o.jsx("h3",{className:"ap-auto-title",children:"Auto-switch"}),o.jsx("span",{className:"ap-field",title:"Switch once the active account passes this much of its limit",children:o.jsx("select",{ref:de,"aria-label":"Switch threshold",value:Fe,...Se("threshold"),onChange:Q=>Be(Q.target.value),children:$U(ze).map(Q=>o.jsxs("option",{value:Q,children:[Q,"%"]},Q))})}),(We.sends||Te)&&o.jsx("button",{ref:ue,type:"button",className:"ap-manage-btn",...Se("threshold"),title:We.title,onClick:()=>ks(Fe,We),children:Te&&!We.sends?We.done:We.label}),o.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":s.enabled,"aria-label":"Auto-switch",...Se("enable"),onClick:()=>ke({action:"enable",enabled:!s.enabled},"enable").then(()=>qe(!0)),title:s.enabled?"Stop switching accounts automatically":"Switch accounts automatically when the active one nears its limit",children:o.jsx("span",{className:"switch-knob"})})]}),s.external&&o.jsxs("p",{className:"ap-auto-note",children:[o.jsx("i",{className:"ap-pulse","aria-hidden":!0})," A ",o.jsx("code",{children:"cswap auto"})," loop in your terminal is doing the switching. The deck stands down while it runs",s.enabled?" — this toggle takes over when you stop it.":"."]})]}):null;return o.jsxs("aside",{className:`accounts-panel${t?" leaving":""}`,id:"accounts-panel","aria-label":"Claude accounts",children:[S==="accounts"&&o.jsxs("div",{className:"ap-header",children:[o.jsx("h2",{children:"Claude accounts"}),o.jsxs("div",{className:"ap-header-right",children:[o.jsx("button",{type:"button",className:"glyph-btn ap-add",onClick:()=>Z(!0),"aria-label":"Add an account",title:"Sign in to another Claude account, or paste one shared from another deck",children:o.jsx("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":!0,children:o.jsx("path",{d:"M7 2.2v9.6M2.2 7h9.6"})})}),(((Hs=n==null?void 0:n.accounts)==null?void 0:Hs.length)??0)>0&&o.jsx("button",{type:"button",className:"glyph-btn",onClick:()=>U(!0),"aria-label":"Share accounts with another deck",title:`Copy several accounts to another ${dn} in one paste. The text carries a live login for each one — treat it as those passwords.`,children:o.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:[o.jsx("path",{d:"M3.3 10.7L10.7 3.3"}),o.jsx("path",{d:"M5.5 3.3h5.2v5.2"})]})}),o.jsx("button",{type:"button",className:"glyph-btn ap-refresh",onClick:()=>qe(!0),...Se("reload",f),"aria-label":"Reload accounts",title:"Reload from claude-swap",children:o.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:[o.jsx("path",{d:"M11.6 6.2A4.8 4.8 0 1 0 11 9.6"}),o.jsx("path",{d:"M11.9 2.6v3.7h-3.6"})]})}),Wr]})]}),S==="accounts"&&o.jsx("div",{className:"ap-scroll",id:"ap-scroll",children:n==null?h?o.jsxs("div",{className:"ap-empty",role:"alert",children:[o.jsx("span",{title:h.raw||void 0,children:h.text}),o.jsxs("span",{className:"ap-hint",children:["No accounts have arrived, so there is nothing to show yet. The panel keeps trying every ",sj/1e3," seconds."]}),o.jsx("button",{type:"button",className:"ap-fix",disabled:f,onClick:()=>qe(!0),children:f?"trying…":"try again"})]}):o.jsx("div",{className:"ap-empty",children:"Checking…"}):n.ok?o.jsxs(o.Fragment,{children:[rt&&(dt==null?void 0:dt.tone)==="warn"&&o.jsxs("div",{className:"ap-notice",children:[o.jsxs("button",{type:"button",id:"ap-notice",className:"ap-issue","data-tone":"warn","aria-haspopup":"dialog","aria-expanded":(j==null?void 0:j.anchor)==="ap-notice","aria-controls":(j==null?void 0:j.anchor)==="ap-notice"?"ap-issue-pop":void 0,onClick:()=>Ut(rt.num,"ap-notice"),children:[o.jsx(Am,{}),o.jsx("span",{className:"ap-issue-text",children:"Current account needs attention"})]}),dt.fix&&o.jsx("button",{type:"button",className:"ap-notice-fix",onClick:()=>Z(!0),title:"Open the sign-in dialog. Signing in as this account replaces its stored login in place.",children:"Sign in"})]}),o.jsx("ul",{className:"ap-list",children:Ot.map(fa)}),yt.length>0&&o.jsx(iU,{peers:zt,strained:Dt,armed:rn,threshold:s!=null&&s.ok?ze:null,open:Le,onToggle:()=>ce(Q=>!Q)}),yt.length>0&&Le&&o.jsxs("div",{className:"ap-rest-panel",id:"ap-rest-panel",children:[o.jsx("ul",{className:"ap-list ap-others",id:"ap-rest-list",children:yt.map(fa)}),Ns]}),yt.length===0&&Ns,h&&h.row==null&&o.jsxs("div",{className:"ap-failure",role:"alert",children:[o.jsx("span",{className:"ap-failure-text",title:h.raw||void 0,children:h.text}),o.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>m(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),H&&(()=>{var Ue;const Q=(Ue=n.accounts)==null?void 0:Ue.find(tt=>tt.num===H.num);if(!Q)return null;const De=`ap-pop-title-${Q.num}`,et=ne&&o.jsx("p",{className:"ap-pop-error",role:"alert",title:ne.raw||void 0,children:ne.text});return o.jsxs(M0,{anchorId:`ap-more-${Q.num}`,boundaryId:je(Q.num),id:`ap-menu-${Q.num}`,className:"ap-pop",role:H.view==="menu"?"menu":"dialog",labelledBy:H.view==="menu"?`ap-more-${Q.num}`:De,start:H.start,onClose:bt,children:[H.view==="menu"&&o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",onClick:()=>{D(Q.alias??""),ee(null),q({num:Q.num,view:"rename"})},children:"Rename"}),o.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",onClick:()=>{Ge(null),ee(null),q({num:Q.num,view:"move"})},children:"Move to slot…"}),o.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",...Se(`share-${Q.num}`),title:`Copy this account to another ${dn}. 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:()=>In(Q.num),children:c===`share-${Q.num}`?"Sharing…":"Share"}),o.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",title:"See how much this account worked in each project",onClick:()=>{le(Q.num),Zt(Q.num)},children:"Projects"}),(((s==null?void 0:s.enabled)||(s==null?void 0:s.external))&&!Q.active||Q.disabled)&&o.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",...Se(`rot-${Q.num}`),title:Q.disabled?"Return this account to auto-rotation":"Hold this account out of auto-rotation",onClick:()=>ke({action:"account",account:Q.num,enabled:Q.disabled},`rot-${Q.num}`,"menu").then(tt=>{qe(!0),tt!=null&&tt.ok&&Zt(Q.num)}),children:Q.disabled?"Put back in rotation":"Hold out of rotation"}),o.jsx("div",{role:"separator",className:"ap-menu-sep"}),o.jsx("button",{type:"button",role:"menuitem",className:`ap-menu-item danger${P===Q.num?" armed":""}`,...Se(`rm-${Q.num}`),"aria-label":P===Q.num?"Confirm remove":void 0,title:P===Q.num?"This deletes the stored credentials for this account":"Remove this account from claude-swap",onClick:()=>{const tt=Date.now(),wt=Cu({armedFor:P,target:Q.num,armedAt:W.current,now:tt,gapMs:Mu});if(wt==="arm"){B(Q.num),W.current=tt,window.setTimeout(()=>B(gt=>gt===Q.num?null:gt),4e3);return}wt!=="ignore"&&(B(null),Re({action:"remove",account:Q.num},`rm-${Q.num}`).then(gt=>{var It;qe(!0),gt!=null&&gt.ok&&(((It=V.current)==null?void 0:It.num)===Q.num&&bt(),Ye(null))}))},children:c===`rm-${Q.num}`?"Removing…":P===Q.num?"Confirm":"Remove"}),et]}),H.view==="rename"&&o.jsxs("form",{className:"ap-pop-form",onSubmit:tt=>{tt.preventDefault(),Hr(Q.num,Q.alias)},children:[o.jsx("label",{className:"ap-pop-title",id:De,htmlFor:`ap-alias-${Q.num}`,children:"Rename account"}),o.jsx("input",{id:`ap-alias-${Q.num}`,className:"ap-manage-input",type:"text",value:K,onChange:tt=>D(tt.target.value),maxLength:xU,placeholder:"e.g. work",spellCheck:!1,autoComplete:"off",autoFocus:!0,onFocus:tt=>tt.currentTarget.select()}),et,o.jsxs("div",{className:"ap-pop-actions",children:[o.jsx("button",{type:"button",className:"btn",onClick:()=>Zt(),children:"Cancel"}),o.jsx("button",{type:"submit",className:"btn primary",...Se(`alias-${Q.num}`),title:"A short name to show instead of the email",children:c===`alias-${Q.num}`?"…":"Save"})]})]}),H.view==="move"&&(()=>{const tt=dU((n.accounts??[]).map(It=>It.num),Q.num),wt=fU(tt,Ie,Q.num),gt=pU(tt,wt,Q.num);return o.jsxs("div",{className:"ap-pop-form",children:[o.jsx("label",{className:"ap-pop-title",id:De,htmlFor:`ap-slot-${Q.num}`,children:"Move to slot"}),o.jsx("span",{className:"ap-field",children:o.jsx("select",{id:`ap-slot-${Q.num}`,value:String(wt),...Se(`move-${Q.num}`),onChange:It=>Ge(Number(It.target.value)),autoFocus:!0,children:tt.map(It=>o.jsx("option",{value:It.slot,children:It.label},It.slot))})}),et,o.jsxs("div",{className:"ap-pop-actions",children:[o.jsx("button",{type:"button",className:"btn",onClick:()=>Zt(),children:"Cancel"}),o.jsx("button",{type:"button",className:"btn primary",...Se(`move-${Q.num}`),title:gt.title,onClick:()=>lr(Q.num,wt,gt),children:c===`move-${Q.num}`?"…":lu(gt.label)})]})]})})(),H.view==="share"&&(F==null?void 0:F.num)===Q.num&&(()=>{const tt=zM(F.expiresAt,R),wt=tt.tone==="gone";return o.jsxs("div",{className:`ap-pop-form ap-share${wt?" expired":""}`,children:[o.jsx("p",{className:"ap-pop-title",id:De,children:"Share account"}),o.jsx("code",{className:"ap-share-blob",children:F.blob}),o.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:[o.jsx("span",{className:"ap-share-warn",children:"This is the password"})," · ",o.jsx("span",{className:`ap-share-expiry ${tt.tone}`,children:tt.text})]}),et,o.jsxs("div",{className:"ap-pop-actions",children:[o.jsx("button",{type:"button",className:"btn",onClick:()=>Zt(),children:"Done"}),o.jsx("button",{type:"button",className:"btn primary",...Se(`share-${Q.num}`),autoFocus:!0,onClick:async()=>{if(wt){await In(Q.num);return}await hi(F.blob)&&(z(!0),window.setTimeout(()=>z(!1),1800))},children:wt?"Make a new share":Y?"Copied":"Copy"})]})]})})()]})})(),j&&(()=>{var et;const Q=(et=n.accounts)==null?void 0:et.find(Ue=>Ue.num===j.num),De=Q?Nh(Q,R):null;return!Q||!De?null:o.jsx(M0,{anchorId:j.anchor,boundaryId:j.anchor==="ap-notice"?"ap-scroll":je(Q.num),id:"ap-issue-pop",className:"ap-pop ap-issue-pop",role:"dialog",labelledBy:"ap-issue-title",onClose:()=>Vn(),children:o.jsxs("div",{className:"ap-pop-form",children:[o.jsxs("p",{className:"ap-pop-title ap-issue-title",id:"ap-issue-title","data-tone":De.tone,children:[De.tone==="warn"&&o.jsx(Am,{}),De.text]}),o.jsx("p",{className:"ap-pop-note ap-issue-hint",children:De.hint}),o.jsxs("p",{className:"ap-pop-note ap-issue-when",children:[o.jsx("span",{className:"ap-issue-who",children:Q.alias??Q.email??`account ${Q.num}`})," · ",Q.fetchedAt?`last collected ${Rm(Q.fetchedAt,R)}`:"never collected"]}),o.jsxs("div",{className:"ap-pop-actions",children:[o.jsx("button",{type:"button",className:"btn",onClick:()=>Vn(!0),children:"Done"}),De.fix&&o.jsx("button",{type:"button",className:"btn primary",onClick:()=>{Vn(!0),Z(!0)},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:De.fix})]})]})})})()]}):o.jsx("div",{className:"ap-empty",children:n.reason==="no_cswap"?o.jsxs(o.Fragment,{children:[o.jsx("span",{children:"claude-swap isn't installed."}),o.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."}),n.hint&&o.jsx("code",{className:"ap-cmd",children:n.hint}),o.jsxs("span",{className:"ap-hint",children:["Then add an account with the ",o.jsx("strong",{children:"+"})," button above."]})]}):n.reason==="no_accounts"?o.jsxs(o.Fragment,{children:[o.jsx("span",{children:"No accounts added yet."}),o.jsxs("span",{className:"ap-hint",children:["claude-swap is installed but has nothing in its store. Use the ",o.jsx("strong",{children:"+"})," above to sign one in, or to paste one shared from another deck."]})]}):o.jsxs(o.Fragment,{children:[o.jsx("span",{children:"Couldn't read the account store."}),o.jsxs("span",{className:"ap-hint",children:["claude-swap is installed, but its store could not be read",n.reason?` (${n.reason})`:"","."]})]})})}),o.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:y?`Now active: ${y.name}`:""}),_&&o.jsx(aU,{accounts:((n==null?void 0:n.accounts)??[]).map(Q=>({key:`${String(Q.email??"").trim().toLowerCase()}@@${Q.orgUuid??""}`,email:Q.email??"",alive:Q.alive===!0,shareable:Q.collector==="ok"||Q.collector==null&&!Q.active})),onChanged:()=>qe(!0),view:S==="lan",onOpen:Vt,onBack:()=>b("accounts"),closeButton:Wr}),M&&o.jsx(rz,{onClose:()=>Z(!1),onChanged:()=>qe(!0)}),re&&o.jsx(uU,{accounts:((n==null?void 0:n.accounts)??[]).map(Q=>({num:Q.num,email:Q.email,alias:Q.alias,org:Q.org})),onClose:()=>U(!1),copyText:hi}),ie!=null&&(()=>{const Q=((n==null?void 0:n.accounts)??[]).find(De=>De.num===ie);return Q?o.jsx(NB,{num:Q.num,name:Q.alias??Q.email??`account ${Q.num}`,onClose:()=>le(null)}):(le(null),null)})()]})}const PU=3e4;function DU({bundle:e,running:t,lastTried:n}){return!t||e===t?!1:n!==t}function FU({bundle:e,running:t,pending:n,lastTried:r}){return t?DU({bundle:e,running:t,lastTried:r})?"reload":n==null||n&&n!==t?"wait":"confirm":"wait"}function qU(e){return!e||e.state!=="failed"?null:`${typeof e.at=="number"?e.at:0}:${e.error??""}`}function BU({asked:e,reported:t}){return t?t!==e:!1}function XM(e){const t=e.thresholdMs??PU;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 zU(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 UU(e,t){return e?t==null?"auto when idle":`auto in ${zU(t)}`:"auto-restart off"}function aj(e){let t=0;for(const n of e)n.state==="active"&&t++;return t}function HU(e){return 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 WU(e){const t=XM(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}}function zb(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 Mm,oj;function VU(){if(oj)return Mm;oj=1;function e(){this.__data__=[],this.size=0}return Mm=e,Mm}var Im,ij;function tc(){if(ij)return Im;ij=1;function e(t,n){return t===n||t!==t&&n!==n}return Im=e,Im}var $m,lj;function Mf(){if(lj)return $m;lj=1;var e=tc();function t(n,r){for(var s=n.length;s--;)if(e(n[s][0],r))return s;return-1}return $m=t,$m}var Om,cj;function GU(){if(cj)return Om;cj=1;var e=Mf(),t=Array.prototype,n=t.splice;function r(s){var l=this.__data__,c=e(l,s);if(c<0)return!1;var u=l.length-1;return c==u?l.pop():n.call(l,c,1),--this.size,!0}return Om=r,Om}var Lm,uj;function KU(){if(uj)return Lm;uj=1;var e=Mf();function t(n){var r=this.__data__,s=e(r,n);return s<0?void 0:r[s][1]}return Lm=t,Lm}var Pm,dj;function YU(){if(dj)return Pm;dj=1;var e=Mf();function t(n){return e(this.__data__,n)>-1}return Pm=t,Pm}var Dm,hj;function XU(){if(hj)return Dm;hj=1;var e=Mf();function t(n,r){var s=this.__data__,l=e(s,n);return l<0?(++this.size,s.push([n,r])):s[l][1]=r,this}return Dm=t,Dm}var Fm,fj;function If(){if(fj)return Fm;fj=1;var e=VU(),t=GU(),n=KU(),r=YU(),s=XU();function l(c){var u=-1,f=c==null?0:c.length;for(this.clear();++u<f;){var p=c[u];this.set(p[0],p[1])}}return l.prototype.clear=e,l.prototype.delete=t,l.prototype.get=n,l.prototype.has=r,l.prototype.set=s,Fm=l,Fm}var qm,pj;function ZU(){if(pj)return qm;pj=1;var e=If();function t(){this.__data__=new e,this.size=0}return qm=t,qm}var Bm,mj;function QU(){if(mj)return Bm;mj=1;function e(t){var n=this.__data__,r=n.delete(t);return this.size=n.size,r}return Bm=e,Bm}var zm,gj;function JU(){if(gj)return zm;gj=1;function e(t){return this.__data__.get(t)}return zm=e,zm}var Um,yj;function eH(){if(yj)return Um;yj=1;function e(t){return this.__data__.has(t)}return Um=e,Um}var Hm,wj;function ZM(){if(wj)return Hm;wj=1;var e=typeof th=="object"&&th&&th.Object===Object&&th;return Hm=e,Hm}var Wm,vj;function bs(){if(vj)return Wm;vj=1;var e=ZM(),t=typeof self=="object"&&self&&self.Object===Object&&self,n=e||t||Function("return this")();return Wm=n,Wm}var Vm,xj;function nc(){if(xj)return Vm;xj=1;var e=bs(),t=e.Symbol;return Vm=t,Vm}var Gm,bj;function tH(){if(bj)return Gm;bj=1;var e=nc(),t=Object.prototype,n=t.hasOwnProperty,r=t.toString,s=e?e.toStringTag:void 0;function l(c){var u=n.call(c,s),f=c[s];try{c[s]=void 0;var p=!0}catch{}var h=r.call(c);return p&&(u?c[s]=f:delete c[s]),h}return Gm=l,Gm}var Km,kj;function nH(){if(kj)return Km;kj=1;var e=Object.prototype,t=e.toString;function n(r){return t.call(r)}return Km=n,Km}var Ym,Nj;function wi(){if(Nj)return Ym;Nj=1;var e=nc(),t=tH(),n=nH(),r="[object Null]",s="[object Undefined]",l=e?e.toStringTag:void 0;function c(u){return u==null?u===void 0?s:r:l&&l in Object(u)?t(u):n(u)}return Ym=c,Ym}var Xm,Sj;function zr(){if(Sj)return Xm;Sj=1;function e(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}return Xm=e,Xm}var Zm,jj;function Uu(){if(jj)return Zm;jj=1;var e=wi(),t=zr(),n="[object AsyncFunction]",r="[object Function]",s="[object GeneratorFunction]",l="[object Proxy]";function c(u){if(!t(u))return!1;var f=e(u);return f==r||f==s||f==n||f==l}return Zm=c,Zm}var Qm,_j;function rH(){if(_j)return Qm;_j=1;var e=bs(),t=e["__core-js_shared__"];return Qm=t,Qm}var Jm,Ej;function sH(){if(Ej)return Jm;Ej=1;var e=rH(),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 eg,Cj;function QM(){if(Cj)return eg;Cj=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 eg=n,eg}var tg,Tj;function aH(){if(Tj)return tg;Tj=1;var e=Uu(),t=sH(),n=zr(),r=QM(),s=/[\\^$.*+?()[\]{}|]/g,l=/^\[object .+?Constructor\]$/,c=Function.prototype,u=Object.prototype,f=c.toString,p=u.hasOwnProperty,h=RegExp("^"+f.call(p).replace(s,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function m(y){if(!n(y)||t(y))return!1;var v=e(y)?h:l;return v.test(r(y))}return tg=m,tg}var ng,Rj;function oH(){if(Rj)return ng;Rj=1;function e(t,n){return t==null?void 0:t[n]}return ng=e,ng}var rg,Aj;function vi(){if(Aj)return rg;Aj=1;var e=aH(),t=oH();function n(r,s){var l=t(r,s);return e(l)?l:void 0}return rg=n,rg}var sg,Mj;function Ub(){if(Mj)return sg;Mj=1;var e=vi(),t=bs(),n=e(t,"Map");return sg=n,sg}var ag,Ij;function $f(){if(Ij)return ag;Ij=1;var e=vi(),t=e(Object,"create");return ag=t,ag}var og,$j;function iH(){if($j)return og;$j=1;var e=$f();function t(){this.__data__=e?e(null):{},this.size=0}return og=t,og}var ig,Oj;function lH(){if(Oj)return ig;Oj=1;function e(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n}return ig=e,ig}var lg,Lj;function cH(){if(Lj)return lg;Lj=1;var e=$f(),t="__lodash_hash_undefined__",n=Object.prototype,r=n.hasOwnProperty;function s(l){var c=this.__data__;if(e){var u=c[l];return u===t?void 0:u}return r.call(c,l)?c[l]:void 0}return lg=s,lg}var cg,Pj;function uH(){if(Pj)return cg;Pj=1;var e=$f(),t=Object.prototype,n=t.hasOwnProperty;function r(s){var l=this.__data__;return e?l[s]!==void 0:n.call(l,s)}return cg=r,cg}var ug,Dj;function dH(){if(Dj)return ug;Dj=1;var e=$f(),t="__lodash_hash_undefined__";function n(r,s){var l=this.__data__;return this.size+=this.has(r)?0:1,l[r]=e&&s===void 0?t:s,this}return ug=n,ug}var dg,Fj;function hH(){if(Fj)return dg;Fj=1;var e=iH(),t=lH(),n=cH(),r=uH(),s=dH();function l(c){var u=-1,f=c==null?0:c.length;for(this.clear();++u<f;){var p=c[u];this.set(p[0],p[1])}}return l.prototype.clear=e,l.prototype.delete=t,l.prototype.get=n,l.prototype.has=r,l.prototype.set=s,dg=l,dg}var hg,qj;function fH(){if(qj)return hg;qj=1;var e=hH(),t=If(),n=Ub();function r(){this.size=0,this.__data__={hash:new e,map:new(n||t),string:new e}}return hg=r,hg}var fg,Bj;function pH(){if(Bj)return fg;Bj=1;function e(t){var n=typeof t;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?t!=="__proto__":t===null}return fg=e,fg}var pg,zj;function Of(){if(zj)return pg;zj=1;var e=pH();function t(n,r){var s=n.__data__;return e(r)?s[typeof r=="string"?"string":"hash"]:s.map}return pg=t,pg}var mg,Uj;function mH(){if(Uj)return mg;Uj=1;var e=Of();function t(n){var r=e(this,n).delete(n);return this.size-=r?1:0,r}return mg=t,mg}var gg,Hj;function gH(){if(Hj)return gg;Hj=1;var e=Of();function t(n){return e(this,n).get(n)}return gg=t,gg}var yg,Wj;function yH(){if(Wj)return yg;Wj=1;var e=Of();function t(n){return e(this,n).has(n)}return yg=t,yg}var wg,Vj;function wH(){if(Vj)return wg;Vj=1;var e=Of();function t(n,r){var s=e(this,n),l=s.size;return s.set(n,r),this.size+=s.size==l?0:1,this}return wg=t,wg}var vg,Gj;function Hb(){if(Gj)return vg;Gj=1;var e=fH(),t=mH(),n=gH(),r=yH(),s=wH();function l(c){var u=-1,f=c==null?0:c.length;for(this.clear();++u<f;){var p=c[u];this.set(p[0],p[1])}}return l.prototype.clear=e,l.prototype.delete=t,l.prototype.get=n,l.prototype.has=r,l.prototype.set=s,vg=l,vg}var xg,Kj;function vH(){if(Kj)return xg;Kj=1;var e=If(),t=Ub(),n=Hb(),r=200;function s(l,c){var u=this.__data__;if(u instanceof e){var f=u.__data__;if(!t||f.length<r-1)return f.push([l,c]),this.size=++u.size,this;u=this.__data__=new n(f)}return u.set(l,c),this.size=u.size,this}return xg=s,xg}var bg,Yj;function Lf(){if(Yj)return bg;Yj=1;var e=If(),t=ZU(),n=QU(),r=JU(),s=eH(),l=vH();function c(u){var f=this.__data__=new e(u);this.size=f.size}return c.prototype.clear=t,c.prototype.delete=n,c.prototype.get=r,c.prototype.has=s,c.prototype.set=l,bg=c,bg}var kg,Xj;function Wb(){if(Xj)return kg;Xj=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 kg=e,kg}var Ng,Zj;function JM(){if(Zj)return Ng;Zj=1;var e=vi(),t=(function(){try{var n=e(Object,"defineProperty");return n({},"",{}),n}catch{}})();return Ng=t,Ng}var Sg,Qj;function Pf(){if(Qj)return Sg;Qj=1;var e=JM();function t(n,r,s){r=="__proto__"&&e?e(n,r,{configurable:!0,enumerable:!0,value:s,writable:!0}):n[r]=s}return Sg=t,Sg}var jg,Jj;function Df(){if(Jj)return jg;Jj=1;var e=Pf(),t=tc(),n=Object.prototype,r=n.hasOwnProperty;function s(l,c,u){var f=l[c];(!(r.call(l,c)&&t(f,u))||u===void 0&&!(c in l))&&e(l,c,u)}return jg=s,jg}var _g,e_;function Hu(){if(e_)return _g;e_=1;var e=Df(),t=Pf();function n(r,s,l,c){var u=!l;l||(l={});for(var f=-1,p=s.length;++f<p;){var h=s[f],m=c?c(l[h],r[h],h,l,r):void 0;m===void 0&&(m=r[h]),u?t(l,h,m):e(l,h,m)}return l}return _g=n,_g}var Eg,t_;function xH(){if(t_)return Eg;t_=1;function e(t,n){for(var r=-1,s=Array(t);++r<t;)s[r]=n(r);return s}return Eg=e,Eg}var Cg,n_;function Us(){if(n_)return Cg;n_=1;function e(t){return t!=null&&typeof t=="object"}return Cg=e,Cg}var Tg,r_;function bH(){if(r_)return Tg;r_=1;var e=wi(),t=Us(),n="[object Arguments]";function r(s){return t(s)&&e(s)==n}return Tg=r,Tg}var Rg,s_;function Wu(){if(s_)return Rg;s_=1;var e=bH(),t=Us(),n=Object.prototype,r=n.hasOwnProperty,s=n.propertyIsEnumerable,l=e((function(){return arguments})())?e:function(c){return t(c)&&r.call(c,"callee")&&!s.call(c,"callee")};return Rg=l,Rg}var Ag,a_;function nn(){if(a_)return Ag;a_=1;var e=Array.isArray;return Ag=e,Ag}var cu={exports:{}},Mg,o_;function kH(){if(o_)return Mg;o_=1;function e(){return!1}return Mg=e,Mg}cu.exports;var i_;function rc(){return i_||(i_=1,(function(e,t){var n=bs(),r=kH(),s=t&&!t.nodeType&&t,l=s&&!0&&e&&!e.nodeType&&e,c=l&&l.exports===s,u=c?n.Buffer:void 0,f=u?u.isBuffer:void 0,p=f||r;e.exports=p})(cu,cu.exports)),cu.exports}var Ig,l_;function Ff(){if(l_)return Ig;l_=1;var e=9007199254740991,t=/^(?:0|[1-9]\d*)$/;function n(r,s){var l=typeof r;return s=s??e,!!s&&(l=="number"||l!="symbol"&&t.test(r))&&r>-1&&r%1==0&&r<s}return Ig=n,Ig}var $g,c_;function Vb(){if(c_)return $g;c_=1;var e=9007199254740991;function t(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=e}return $g=t,$g}var Og,u_;function NH(){if(u_)return Og;u_=1;var e=wi(),t=Vb(),n=Us(),r="[object Arguments]",s="[object Array]",l="[object Boolean]",c="[object Date]",u="[object Error]",f="[object Function]",p="[object Map]",h="[object Number]",m="[object Object]",y="[object RegExp]",v="[object Set]",S="[object String]",b="[object WeakMap]",_="[object ArrayBuffer]",k="[object DataView]",j="[object Float32Array]",E="[object Float64Array]",C="[object Int8Array]",R="[object Int16Array]",I="[object Int32Array]",O="[object Uint8Array]",H="[object Uint8ClampedArray]",q="[object Uint16Array]",$="[object Uint32Array]",V={};V[j]=V[E]=V[C]=V[R]=V[I]=V[O]=V[H]=V[q]=V[$]=!0,V[r]=V[s]=V[_]=V[l]=V[k]=V[c]=V[u]=V[f]=V[p]=V[h]=V[m]=V[y]=V[v]=V[S]=V[b]=!1;function ne(ee){return n(ee)&&t(ee.length)&&!!V[e(ee)]}return Og=ne,Og}var Lg,d_;function qf(){if(d_)return Lg;d_=1;function e(t){return function(n){return t(n)}}return Lg=e,Lg}var uu={exports:{}};uu.exports;var h_;function Gb(){return h_||(h_=1,(function(e,t){var n=ZM(),r=t&&!t.nodeType&&t,s=r&&!0&&e&&!e.nodeType&&e,l=s&&s.exports===r,c=l&&n.process,u=(function(){try{var f=s&&s.require&&s.require("util").types;return f||c&&c.binding&&c.binding("util")}catch{}})();e.exports=u})(uu,uu.exports)),uu.exports}var Pg,f_;function Vu(){if(f_)return Pg;f_=1;var e=NH(),t=qf(),n=Gb(),r=n&&n.isTypedArray,s=r?t(r):e;return Pg=s,Pg}var Dg,p_;function eI(){if(p_)return Dg;p_=1;var e=xH(),t=Wu(),n=nn(),r=rc(),s=Ff(),l=Vu(),c=Object.prototype,u=c.hasOwnProperty;function f(p,h){var m=n(p),y=!m&&t(p),v=!m&&!y&&r(p),S=!m&&!y&&!v&&l(p),b=m||y||v||S,_=b?e(p.length,String):[],k=_.length;for(var j in p)(h||u.call(p,j))&&!(b&&(j=="length"||v&&(j=="offset"||j=="parent")||S&&(j=="buffer"||j=="byteLength"||j=="byteOffset")||s(j,k)))&&_.push(j);return _}return Dg=f,Dg}var Fg,m_;function Bf(){if(m_)return Fg;m_=1;var e=Object.prototype;function t(n){var r=n&&n.constructor,s=typeof r=="function"&&r.prototype||e;return n===s}return Fg=t,Fg}var qg,g_;function tI(){if(g_)return qg;g_=1;function e(t,n){return function(r){return t(n(r))}}return qg=e,qg}var Bg,y_;function SH(){if(y_)return Bg;y_=1;var e=tI(),t=e(Object.keys,Object);return Bg=t,Bg}var zg,w_;function Kb(){if(w_)return zg;w_=1;var e=Bf(),t=SH(),n=Object.prototype,r=n.hasOwnProperty;function s(l){if(!e(l))return t(l);var c=[];for(var u in Object(l))r.call(l,u)&&u!="constructor"&&c.push(u);return c}return zg=s,zg}var Ug,v_;function da(){if(v_)return Ug;v_=1;var e=Uu(),t=Vb();function n(r){return r!=null&&t(r.length)&&!e(r)}return Ug=n,Ug}var Hg,x_;function oo(){if(x_)return Hg;x_=1;var e=eI(),t=Kb(),n=da();function r(s){return n(s)?e(s):t(s)}return Hg=r,Hg}var Wg,b_;function jH(){if(b_)return Wg;b_=1;var e=Hu(),t=oo();function n(r,s){return r&&e(s,t(s),r)}return Wg=n,Wg}var Vg,k_;function _H(){if(k_)return Vg;k_=1;function e(t){var n=[];if(t!=null)for(var r in Object(t))n.push(r);return n}return Vg=e,Vg}var Gg,N_;function EH(){if(N_)return Gg;N_=1;var e=zr(),t=Bf(),n=_H(),r=Object.prototype,s=r.hasOwnProperty;function l(c){if(!e(c))return n(c);var u=t(c),f=[];for(var p in c)p=="constructor"&&(u||!s.call(c,p))||f.push(p);return f}return Gg=l,Gg}var Kg,S_;function xi(){if(S_)return Kg;S_=1;var e=eI(),t=EH(),n=da();function r(s){return n(s)?e(s,!0):t(s)}return Kg=r,Kg}var Yg,j_;function CH(){if(j_)return Yg;j_=1;var e=Hu(),t=xi();function n(r,s){return r&&e(s,t(s),r)}return Yg=n,Yg}var du={exports:{}};du.exports;var __;function nI(){return __||(__=1,(function(e,t){var n=bs(),r=t&&!t.nodeType&&t,s=r&&!0&&e&&!e.nodeType&&e,l=s&&s.exports===r,c=l?n.Buffer:void 0,u=c?c.allocUnsafe:void 0;function f(p,h){if(h)return p.slice();var m=p.length,y=u?u(m):new p.constructor(m);return p.copy(y),y}e.exports=f})(du,du.exports)),du.exports}var Xg,E_;function rI(){if(E_)return Xg;E_=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 Xg=e,Xg}var Zg,C_;function sI(){if(C_)return Zg;C_=1;function e(t,n){for(var r=-1,s=t==null?0:t.length,l=0,c=[];++r<s;){var u=t[r];n(u,r,t)&&(c[l++]=u)}return c}return Zg=e,Zg}var Qg,T_;function aI(){if(T_)return Qg;T_=1;function e(){return[]}return Qg=e,Qg}var Jg,R_;function Yb(){if(R_)return Jg;R_=1;var e=sI(),t=aI(),n=Object.prototype,r=n.propertyIsEnumerable,s=Object.getOwnPropertySymbols,l=s?function(c){return c==null?[]:(c=Object(c),e(s(c),function(u){return r.call(c,u)}))}:t;return Jg=l,Jg}var ey,A_;function TH(){if(A_)return ey;A_=1;var e=Hu(),t=Yb();function n(r,s){return e(r,t(r),s)}return ey=n,ey}var ty,M_;function Xb(){if(M_)return ty;M_=1;function e(t,n){for(var r=-1,s=n.length,l=t.length;++r<s;)t[l+r]=n[r];return t}return ty=e,ty}var ny,I_;function zf(){if(I_)return ny;I_=1;var e=tI(),t=e(Object.getPrototypeOf,Object);return ny=t,ny}var ry,$_;function oI(){if($_)return ry;$_=1;var e=Xb(),t=zf(),n=Yb(),r=aI(),s=Object.getOwnPropertySymbols,l=s?function(c){for(var u=[];c;)e(u,n(c)),c=t(c);return u}:r;return ry=l,ry}var sy,O_;function RH(){if(O_)return sy;O_=1;var e=Hu(),t=oI();function n(r,s){return e(r,t(r),s)}return sy=n,sy}var ay,L_;function iI(){if(L_)return ay;L_=1;var e=Xb(),t=nn();function n(r,s,l){var c=s(r);return t(r)?c:e(c,l(r))}return ay=n,ay}var oy,P_;function lI(){if(P_)return oy;P_=1;var e=iI(),t=Yb(),n=oo();function r(s){return e(s,n,t)}return oy=r,oy}var iy,D_;function AH(){if(D_)return iy;D_=1;var e=iI(),t=oI(),n=xi();function r(s){return e(s,n,t)}return iy=r,iy}var ly,F_;function MH(){if(F_)return ly;F_=1;var e=vi(),t=bs(),n=e(t,"DataView");return ly=n,ly}var cy,q_;function IH(){if(q_)return cy;q_=1;var e=vi(),t=bs(),n=e(t,"Promise");return cy=n,cy}var uy,B_;function cI(){if(B_)return uy;B_=1;var e=vi(),t=bs(),n=e(t,"Set");return uy=n,uy}var dy,z_;function $H(){if(z_)return dy;z_=1;var e=vi(),t=bs(),n=e(t,"WeakMap");return dy=n,dy}var hy,U_;function sc(){if(U_)return hy;U_=1;var e=MH(),t=Ub(),n=IH(),r=cI(),s=$H(),l=wi(),c=QM(),u="[object Map]",f="[object Object]",p="[object Promise]",h="[object Set]",m="[object WeakMap]",y="[object DataView]",v=c(e),S=c(t),b=c(n),_=c(r),k=c(s),j=l;return(e&&j(new e(new ArrayBuffer(1)))!=y||t&&j(new t)!=u||n&&j(n.resolve())!=p||r&&j(new r)!=h||s&&j(new s)!=m)&&(j=function(E){var C=l(E),R=C==f?E.constructor:void 0,I=R?c(R):"";if(I)switch(I){case v:return y;case S:return u;case b:return p;case _:return h;case k:return m}return C}),hy=j,hy}var fy,H_;function OH(){if(H_)return fy;H_=1;var e=Object.prototype,t=e.hasOwnProperty;function n(r){var s=r.length,l=new r.constructor(s);return s&&typeof r[0]=="string"&&t.call(r,"index")&&(l.index=r.index,l.input=r.input),l}return fy=n,fy}var py,W_;function uI(){if(W_)return py;W_=1;var e=bs(),t=e.Uint8Array;return py=t,py}var my,V_;function Zb(){if(V_)return my;V_=1;var e=uI();function t(n){var r=new n.constructor(n.byteLength);return new e(r).set(new e(n)),r}return my=t,my}var gy,G_;function LH(){if(G_)return gy;G_=1;var e=Zb();function t(n,r){var s=r?e(n.buffer):n.buffer;return new n.constructor(s,n.byteOffset,n.byteLength)}return gy=t,gy}var yy,K_;function PH(){if(K_)return yy;K_=1;var e=/\w*$/;function t(n){var r=new n.constructor(n.source,e.exec(n));return r.lastIndex=n.lastIndex,r}return yy=t,yy}var wy,Y_;function DH(){if(Y_)return wy;Y_=1;var e=nc(),t=e?e.prototype:void 0,n=t?t.valueOf:void 0;function r(s){return n?Object(n.call(s)):{}}return wy=r,wy}var vy,X_;function dI(){if(X_)return vy;X_=1;var e=Zb();function t(n,r){var s=r?e(n.buffer):n.buffer;return new n.constructor(s,n.byteOffset,n.length)}return vy=t,vy}var xy,Z_;function FH(){if(Z_)return xy;Z_=1;var e=Zb(),t=LH(),n=PH(),r=DH(),s=dI(),l="[object Boolean]",c="[object Date]",u="[object Map]",f="[object Number]",p="[object RegExp]",h="[object Set]",m="[object String]",y="[object Symbol]",v="[object ArrayBuffer]",S="[object DataView]",b="[object Float32Array]",_="[object Float64Array]",k="[object Int8Array]",j="[object Int16Array]",E="[object Int32Array]",C="[object Uint8Array]",R="[object Uint8ClampedArray]",I="[object Uint16Array]",O="[object Uint32Array]";function H(q,$,V){var ne=q.constructor;switch($){case v:return e(q);case l:case c:return new ne(+q);case S:return t(q,V);case b:case _:case k:case j:case E:case C:case R:case I:case O:return s(q,V);case u:return new ne;case f:case m:return new ne(q);case p:return n(q);case h:return new ne;case y:return r(q)}}return xy=H,xy}var by,Q_;function hI(){if(Q_)return by;Q_=1;var e=zr(),t=Object.create,n=(function(){function r(){}return function(s){if(!e(s))return{};if(t)return t(s);r.prototype=s;var l=new r;return r.prototype=void 0,l}})();return by=n,by}var ky,J_;function fI(){if(J_)return ky;J_=1;var e=hI(),t=zf(),n=Bf();function r(s){return typeof s.constructor=="function"&&!n(s)?e(t(s)):{}}return ky=r,ky}var Ny,eE;function qH(){if(eE)return Ny;eE=1;var e=sc(),t=Us(),n="[object Map]";function r(s){return t(s)&&e(s)==n}return Ny=r,Ny}var Sy,tE;function BH(){if(tE)return Sy;tE=1;var e=qH(),t=qf(),n=Gb(),r=n&&n.isMap,s=r?t(r):e;return Sy=s,Sy}var jy,nE;function zH(){if(nE)return jy;nE=1;var e=sc(),t=Us(),n="[object Set]";function r(s){return t(s)&&e(s)==n}return jy=r,jy}var _y,rE;function UH(){if(rE)return _y;rE=1;var e=zH(),t=qf(),n=Gb(),r=n&&n.isSet,s=r?t(r):e;return _y=s,_y}var Ey,sE;function pI(){if(sE)return Ey;sE=1;var e=Lf(),t=Wb(),n=Df(),r=jH(),s=CH(),l=nI(),c=rI(),u=TH(),f=RH(),p=lI(),h=AH(),m=sc(),y=OH(),v=FH(),S=fI(),b=nn(),_=rc(),k=BH(),j=zr(),E=UH(),C=oo(),R=xi(),I=1,O=2,H=4,q="[object Arguments]",$="[object Array]",V="[object Boolean]",ne="[object Date]",ee="[object Error]",M="[object Function]",Z="[object GeneratorFunction]",K="[object Map]",D="[object Number]",P="[object Object]",B="[object RegExp]",W="[object Set]",F="[object String]",G="[object Symbol]",re="[object WeakMap]",U="[object ArrayBuffer]",Y="[object DataView]",z="[object Float32Array]",ie="[object Float64Array]",le="[object Int8Array]",ge="[object Int16Array]",Ne="[object Int32Array]",Ie="[object Uint8Array]",Ge="[object Uint8ClampedArray]",Pe="[object Uint16Array]",Be="[object Uint32Array]",Te={};Te[q]=Te[$]=Te[U]=Te[Y]=Te[V]=Te[ne]=Te[z]=Te[ie]=Te[le]=Te[ge]=Te[Ne]=Te[K]=Te[D]=Te[P]=Te[B]=Te[W]=Te[F]=Te[G]=Te[Ie]=Te[Ge]=Te[Pe]=Te[Be]=!0,Te[ee]=Te[M]=Te[re]=!1;function st(de,ue,se,be,Le,ce){var pe,Ae=ue&I,fe=ue&O,Se=ue&H;if(se&&(pe=Le?se(de,be,Le,ce):se(de)),pe!==void 0)return pe;if(!j(de))return de;var Ye=b(de);if(Ye){if(pe=y(de),!Ae)return c(de,pe)}else{var qe=m(de),ke=qe==M||qe==Z;if(_(de))return l(de,Ae);if(qe==P||qe==q||ke&&!Le){if(pe=fe||ke?{}:S(de),!Ae)return fe?f(de,s(pe,de)):u(de,r(pe,de))}else{if(!Te[qe])return Le?de:{};pe=v(de,qe,Ae)}}ce||(ce=new e);var Re=ce.get(de);if(Re)return Re;ce.set(de,pe),E(de)?de.forEach(function(We){pe.add(st(We,ue,se,We,de,ce))}):k(de)&&de.forEach(function(We,rt){pe.set(rt,st(We,ue,se,rt,de,ce))});var ze=Se?fe?h:p:fe?R:C,Fe=Ye?void 0:ze(de);return t(Fe||de,function(We,rt){Fe&&(rt=We,We=de[rt]),n(pe,rt,st(We,ue,se,rt,de,ce))}),pe}return Ey=st,Ey}var Cy,aE;function HH(){if(aE)return Cy;aE=1;var e=pI(),t=4;function n(r){return e(r,t)}return Cy=n,Cy}var Ty,oE;function Qb(){if(oE)return Ty;oE=1;function e(t){return function(){return t}}return Ty=e,Ty}var Ry,iE;function WH(){if(iE)return Ry;iE=1;function e(t){return function(n,r,s){for(var l=-1,c=Object(n),u=s(n),f=u.length;f--;){var p=u[t?f:++l];if(r(c[p],p,c)===!1)break}return n}}return Ry=e,Ry}var Ay,lE;function Jb(){if(lE)return Ay;lE=1;var e=WH(),t=e();return Ay=t,Ay}var My,cE;function ek(){if(cE)return My;cE=1;var e=Jb(),t=oo();function n(r,s){return r&&e(r,s,t)}return My=n,My}var Iy,uE;function VH(){if(uE)return Iy;uE=1;var e=da();function t(n,r){return function(s,l){if(s==null)return s;if(!e(s))return n(s,l);for(var c=s.length,u=r?c:-1,f=Object(s);(r?u--:++u<c)&&l(f[u],u,f)!==!1;);return s}}return Iy=t,Iy}var $y,dE;function Uf(){if(dE)return $y;dE=1;var e=ek(),t=VH(),n=t(e);return $y=n,$y}var Oy,hE;function bi(){if(hE)return Oy;hE=1;function e(t){return t}return Oy=e,Oy}var Ly,fE;function mI(){if(fE)return Ly;fE=1;var e=bi();function t(n){return typeof n=="function"?n:e}return Ly=t,Ly}var Py,pE;function gI(){if(pE)return Py;pE=1;var e=Wb(),t=Uf(),n=mI(),r=nn();function s(l,c){var u=r(l)?e:t;return u(l,n(c))}return Py=s,Py}var Dy,mE;function yI(){return mE||(mE=1,Dy=gI()),Dy}var Fy,gE;function GH(){if(gE)return Fy;gE=1;var e=Uf();function t(n,r){var s=[];return e(n,function(l,c,u){r(l,c,u)&&s.push(l)}),s}return Fy=t,Fy}var qy,yE;function KH(){if(yE)return qy;yE=1;var e="__lodash_hash_undefined__";function t(n){return this.__data__.set(n,e),this}return qy=t,qy}var By,wE;function YH(){if(wE)return By;wE=1;function e(t){return this.__data__.has(t)}return By=e,By}var zy,vE;function wI(){if(vE)return zy;vE=1;var e=Hb(),t=KH(),n=YH();function r(s){var l=-1,c=s==null?0:s.length;for(this.__data__=new e;++l<c;)this.add(s[l])}return r.prototype.add=r.prototype.push=t,r.prototype.has=n,zy=r,zy}var Uy,xE;function XH(){if(xE)return Uy;xE=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 Uy=e,Uy}var Hy,bE;function vI(){if(bE)return Hy;bE=1;function e(t,n){return t.has(n)}return Hy=e,Hy}var Wy,kE;function xI(){if(kE)return Wy;kE=1;var e=wI(),t=XH(),n=vI(),r=1,s=2;function l(c,u,f,p,h,m){var y=f&r,v=c.length,S=u.length;if(v!=S&&!(y&&S>v))return!1;var b=m.get(c),_=m.get(u);if(b&&_)return b==u&&_==c;var k=-1,j=!0,E=f&s?new e:void 0;for(m.set(c,u),m.set(u,c);++k<v;){var C=c[k],R=u[k];if(p)var I=y?p(R,C,k,u,c,m):p(C,R,k,c,u,m);if(I!==void 0){if(I)continue;j=!1;break}if(E){if(!t(u,function(O,H){if(!n(E,H)&&(C===O||h(C,O,f,p,m)))return E.push(H)})){j=!1;break}}else if(!(C===R||h(C,R,f,p,m))){j=!1;break}}return m.delete(c),m.delete(u),j}return Wy=l,Wy}var Vy,NE;function ZH(){if(NE)return Vy;NE=1;function e(t){var n=-1,r=Array(t.size);return t.forEach(function(s,l){r[++n]=[l,s]}),r}return Vy=e,Vy}var Gy,SE;function tk(){if(SE)return Gy;SE=1;function e(t){var n=-1,r=Array(t.size);return t.forEach(function(s){r[++n]=s}),r}return Gy=e,Gy}var Ky,jE;function QH(){if(jE)return Ky;jE=1;var e=nc(),t=uI(),n=tc(),r=xI(),s=ZH(),l=tk(),c=1,u=2,f="[object Boolean]",p="[object Date]",h="[object Error]",m="[object Map]",y="[object Number]",v="[object RegExp]",S="[object Set]",b="[object String]",_="[object Symbol]",k="[object ArrayBuffer]",j="[object DataView]",E=e?e.prototype:void 0,C=E?E.valueOf:void 0;function R(I,O,H,q,$,V,ne){switch(H){case j:if(I.byteLength!=O.byteLength||I.byteOffset!=O.byteOffset)return!1;I=I.buffer,O=O.buffer;case k:return!(I.byteLength!=O.byteLength||!V(new t(I),new t(O)));case f:case p:case y:return n(+I,+O);case h:return I.name==O.name&&I.message==O.message;case v:case b:return I==O+"";case m:var ee=s;case S:var M=q&c;if(ee||(ee=l),I.size!=O.size&&!M)return!1;var Z=ne.get(I);if(Z)return Z==O;q|=u,ne.set(I,O);var K=r(ee(I),ee(O),q,$,V,ne);return ne.delete(I),K;case _:if(C)return C.call(I)==C.call(O)}return!1}return Ky=R,Ky}var Yy,_E;function JH(){if(_E)return Yy;_E=1;var e=lI(),t=1,n=Object.prototype,r=n.hasOwnProperty;function s(l,c,u,f,p,h){var m=u&t,y=e(l),v=y.length,S=e(c),b=S.length;if(v!=b&&!m)return!1;for(var _=v;_--;){var k=y[_];if(!(m?k in c:r.call(c,k)))return!1}var j=h.get(l),E=h.get(c);if(j&&E)return j==c&&E==l;var C=!0;h.set(l,c),h.set(c,l);for(var R=m;++_<v;){k=y[_];var I=l[k],O=c[k];if(f)var H=m?f(O,I,k,c,l,h):f(I,O,k,l,c,h);if(!(H===void 0?I===O||p(I,O,u,f,h):H)){C=!1;break}R||(R=k=="constructor")}if(C&&!R){var q=l.constructor,$=c.constructor;q!=$&&"constructor"in l&&"constructor"in c&&!(typeof q=="function"&&q instanceof q&&typeof $=="function"&&$ instanceof $)&&(C=!1)}return h.delete(l),h.delete(c),C}return Yy=s,Yy}var Xy,EE;function eW(){if(EE)return Xy;EE=1;var e=Lf(),t=xI(),n=QH(),r=JH(),s=sc(),l=nn(),c=rc(),u=Vu(),f=1,p="[object Arguments]",h="[object Array]",m="[object Object]",y=Object.prototype,v=y.hasOwnProperty;function S(b,_,k,j,E,C){var R=l(b),I=l(_),O=R?h:s(b),H=I?h:s(_);O=O==p?m:O,H=H==p?m:H;var q=O==m,$=H==m,V=O==H;if(V&&c(b)){if(!c(_))return!1;R=!0,q=!1}if(V&&!q)return C||(C=new e),R||u(b)?t(b,_,k,j,E,C):n(b,_,O,k,j,E,C);if(!(k&f)){var ne=q&&v.call(b,"__wrapped__"),ee=$&&v.call(_,"__wrapped__");if(ne||ee){var M=ne?b.value():b,Z=ee?_.value():_;return C||(C=new e),E(M,Z,k,j,C)}}return V?(C||(C=new e),r(b,_,k,j,E,C)):!1}return Xy=S,Xy}var Zy,CE;function bI(){if(CE)return Zy;CE=1;var e=eW(),t=Us();function n(r,s,l,c,u){return r===s?!0:r==null||s==null||!t(r)&&!t(s)?r!==r&&s!==s:e(r,s,l,c,n,u)}return Zy=n,Zy}var Qy,TE;function tW(){if(TE)return Qy;TE=1;var e=Lf(),t=bI(),n=1,r=2;function s(l,c,u,f){var p=u.length,h=p,m=!f;if(l==null)return!h;for(l=Object(l);p--;){var y=u[p];if(m&&y[2]?y[1]!==l[y[0]]:!(y[0]in l))return!1}for(;++p<h;){y=u[p];var v=y[0],S=l[v],b=y[1];if(m&&y[2]){if(S===void 0&&!(v in l))return!1}else{var _=new e;if(f)var k=f(S,b,v,l,c,_);if(!(k===void 0?t(b,S,n|r,f,_):k))return!1}}return!0}return Qy=s,Qy}var Jy,RE;function kI(){if(RE)return Jy;RE=1;var e=zr();function t(n){return n===n&&!e(n)}return Jy=t,Jy}var ew,AE;function nW(){if(AE)return ew;AE=1;var e=kI(),t=oo();function n(r){for(var s=t(r),l=s.length;l--;){var c=s[l],u=r[c];s[l]=[c,u,e(u)]}return s}return ew=n,ew}var tw,ME;function NI(){if(ME)return tw;ME=1;function e(t,n){return function(r){return r==null?!1:r[t]===n&&(n!==void 0||t in Object(r))}}return tw=e,tw}var nw,IE;function rW(){if(IE)return nw;IE=1;var e=tW(),t=nW(),n=NI();function r(s){var l=t(s);return l.length==1&&l[0][2]?n(l[0][0],l[0][1]):function(c){return c===s||e(c,s,l)}}return nw=r,nw}var rw,$E;function ac(){if($E)return rw;$E=1;var e=wi(),t=Us(),n="[object Symbol]";function r(s){return typeof s=="symbol"||t(s)&&e(s)==n}return rw=r,rw}var sw,OE;function nk(){if(OE)return sw;OE=1;var e=nn(),t=ac(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;function s(l,c){if(e(l))return!1;var u=typeof l;return u=="number"||u=="symbol"||u=="boolean"||l==null||t(l)?!0:r.test(l)||!n.test(l)||c!=null&&l in Object(c)}return sw=s,sw}var aw,LE;function sW(){if(LE)return aw;LE=1;var e=Hb(),t="Expected a function";function n(r,s){if(typeof r!="function"||s!=null&&typeof s!="function")throw new TypeError(t);var l=function(){var c=arguments,u=s?s.apply(this,c):c[0],f=l.cache;if(f.has(u))return f.get(u);var p=r.apply(this,c);return l.cache=f.set(u,p)||f,p};return l.cache=new(n.Cache||e),l}return n.Cache=e,aw=n,aw}var ow,PE;function aW(){if(PE)return ow;PE=1;var e=sW(),t=500;function n(r){var s=e(r,function(c){return l.size===t&&l.clear(),c}),l=s.cache;return s}return ow=n,ow}var iw,DE;function oW(){if(DE)return iw;DE=1;var e=aW(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,n=/\\(\\)?/g,r=e(function(s){var l=[];return s.charCodeAt(0)===46&&l.push(""),s.replace(t,function(c,u,f,p){l.push(f?p.replace(n,"$1"):u||c)}),l});return iw=r,iw}var lw,FE;function Hf(){if(FE)return lw;FE=1;function e(t,n){for(var r=-1,s=t==null?0:t.length,l=Array(s);++r<s;)l[r]=n(t[r],r,t);return l}return lw=e,lw}var cw,qE;function iW(){if(qE)return cw;qE=1;var e=nc(),t=Hf(),n=nn(),r=ac(),s=e?e.prototype:void 0,l=s?s.toString:void 0;function c(u){if(typeof u=="string")return u;if(n(u))return t(u,c)+"";if(r(u))return l?l.call(u):"";var f=u+"";return f=="0"&&1/u==-1/0?"-0":f}return cw=c,cw}var uw,BE;function SI(){if(BE)return uw;BE=1;var e=iW();function t(n){return n==null?"":e(n)}return uw=t,uw}var dw,zE;function Wf(){if(zE)return dw;zE=1;var e=nn(),t=nk(),n=oW(),r=SI();function s(l,c){return e(l)?l:t(l,c)?[l]:n(r(l))}return dw=s,dw}var hw,UE;function Gu(){if(UE)return hw;UE=1;var e=ac();function t(n){if(typeof n=="string"||e(n))return n;var r=n+"";return r=="0"&&1/n==-1/0?"-0":r}return hw=t,hw}var fw,HE;function Vf(){if(HE)return fw;HE=1;var e=Wf(),t=Gu();function n(r,s){s=e(s,r);for(var l=0,c=s.length;r!=null&&l<c;)r=r[t(s[l++])];return l&&l==c?r:void 0}return fw=n,fw}var pw,WE;function lW(){if(WE)return pw;WE=1;var e=Vf();function t(n,r,s){var l=n==null?void 0:e(n,r);return l===void 0?s:l}return pw=t,pw}var mw,VE;function cW(){if(VE)return mw;VE=1;function e(t,n){return t!=null&&n in Object(t)}return mw=e,mw}var gw,GE;function jI(){if(GE)return gw;GE=1;var e=Wf(),t=Wu(),n=nn(),r=Ff(),s=Vb(),l=Gu();function c(u,f,p){f=e(f,u);for(var h=-1,m=f.length,y=!1;++h<m;){var v=l(f[h]);if(!(y=u!=null&&p(u,v)))break;u=u[v]}return y||++h!=m?y:(m=u==null?0:u.length,!!m&&s(m)&&r(v,m)&&(n(u)||t(u)))}return gw=c,gw}var yw,KE;function _I(){if(KE)return yw;KE=1;var e=cW(),t=jI();function n(r,s){return r!=null&&t(r,s,e)}return yw=n,yw}var ww,YE;function uW(){if(YE)return ww;YE=1;var e=bI(),t=lW(),n=_I(),r=nk(),s=kI(),l=NI(),c=Gu(),u=1,f=2;function p(h,m){return r(h)&&s(m)?l(c(h),m):function(y){var v=t(y,h);return v===void 0&&v===m?n(y,h):e(m,v,u|f)}}return ww=p,ww}var vw,XE;function EI(){if(XE)return vw;XE=1;function e(t){return function(n){return n==null?void 0:n[t]}}return vw=e,vw}var xw,ZE;function dW(){if(ZE)return xw;ZE=1;var e=Vf();function t(n){return function(r){return e(r,n)}}return xw=t,xw}var bw,QE;function hW(){if(QE)return bw;QE=1;var e=EI(),t=dW(),n=nk(),r=Gu();function s(l){return n(l)?e(r(l)):t(l)}return bw=s,bw}var kw,JE;function ha(){if(JE)return kw;JE=1;var e=rW(),t=uW(),n=bi(),r=nn(),s=hW();function l(c){return typeof c=="function"?c:c==null?n:typeof c=="object"?r(c)?t(c[0],c[1]):e(c):s(c)}return kw=l,kw}var Nw,eC;function CI(){if(eC)return Nw;eC=1;var e=sI(),t=GH(),n=ha(),r=nn();function s(l,c){var u=r(l)?e:t;return u(l,n(c,3))}return Nw=s,Nw}var Sw,tC;function fW(){if(tC)return Sw;tC=1;var e=Object.prototype,t=e.hasOwnProperty;function n(r,s){return r!=null&&t.call(r,s)}return Sw=n,Sw}var jw,nC;function TI(){if(nC)return jw;nC=1;var e=fW(),t=jI();function n(r,s){return r!=null&&t(r,s,e)}return jw=n,jw}var _w,rC;function pW(){if(rC)return _w;rC=1;var e=Kb(),t=sc(),n=Wu(),r=nn(),s=da(),l=rc(),c=Bf(),u=Vu(),f="[object Map]",p="[object Set]",h=Object.prototype,m=h.hasOwnProperty;function y(v){if(v==null)return!0;if(s(v)&&(r(v)||typeof v=="string"||typeof v.splice=="function"||l(v)||u(v)||n(v)))return!v.length;var S=t(v);if(S==f||S==p)return!v.size;if(c(v))return!e(v).length;for(var b in v)if(m.call(v,b))return!1;return!0}return _w=y,_w}var Ew,sC;function RI(){if(sC)return Ew;sC=1;function e(t){return t===void 0}return Ew=e,Ew}var Cw,aC;function AI(){if(aC)return Cw;aC=1;var e=Uf(),t=da();function n(r,s){var l=-1,c=t(r)?Array(r.length):[];return e(r,function(u,f,p){c[++l]=s(u,f,p)}),c}return Cw=n,Cw}var Tw,oC;function MI(){if(oC)return Tw;oC=1;var e=Hf(),t=ha(),n=AI(),r=nn();function s(l,c){var u=r(l)?e:n;return u(l,t(c,3))}return Tw=s,Tw}var Rw,iC;function mW(){if(iC)return Rw;iC=1;function e(t,n,r,s){var l=-1,c=t==null?0:t.length;for(s&&c&&(r=t[++l]);++l<c;)r=n(r,t[l],l,t);return r}return Rw=e,Rw}var Aw,lC;function gW(){if(lC)return Aw;lC=1;function e(t,n,r,s,l){return l(t,function(c,u,f){r=s?(s=!1,c):n(r,c,u,f)}),r}return Aw=e,Aw}var Mw,cC;function II(){if(cC)return Mw;cC=1;var e=mW(),t=Uf(),n=ha(),r=gW(),s=nn();function l(c,u,f){var p=s(c)?e:r,h=arguments.length<3;return p(c,n(u,4),f,h,t)}return Mw=l,Mw}var Iw,uC;function yW(){if(uC)return Iw;uC=1;var e=wi(),t=nn(),n=Us(),r="[object String]";function s(l){return typeof l=="string"||!t(l)&&n(l)&&e(l)==r}return Iw=s,Iw}var $w,dC;function wW(){if(dC)return $w;dC=1;var e=EI(),t=e("length");return $w=t,$w}var Ow,hC;function vW(){if(hC)return Ow;hC=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",r="\\u20d0-\\u20ff",s=t+n+r,l="\\ufe0e\\ufe0f",c="\\u200d",u=RegExp("["+c+e+s+l+"]");function f(p){return u.test(p)}return Ow=f,Ow}var Lw,fC;function xW(){if(fC)return Lw;fC=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",r="\\u20d0-\\u20ff",s=t+n+r,l="\\ufe0e\\ufe0f",c="["+e+"]",u="["+s+"]",f="\\ud83c[\\udffb-\\udfff]",p="(?:"+u+"|"+f+")",h="[^"+e+"]",m="(?:\\ud83c[\\udde6-\\uddff]){2}",y="[\\ud800-\\udbff][\\udc00-\\udfff]",v="\\u200d",S=p+"?",b="["+l+"]?",_="(?:"+v+"(?:"+[h,m,y].join("|")+")"+b+S+")*",k=b+S+_,j="(?:"+[h+u+"?",u,m,y,c].join("|")+")",E=RegExp(f+"(?="+f+")|"+j+k,"g");function C(R){for(var I=E.lastIndex=0;E.test(R);)++I;return I}return Lw=C,Lw}var Pw,pC;function bW(){if(pC)return Pw;pC=1;var e=wW(),t=vW(),n=xW();function r(s){return t(s)?n(s):e(s)}return Pw=r,Pw}var Dw,mC;function kW(){if(mC)return Dw;mC=1;var e=Kb(),t=sc(),n=da(),r=yW(),s=bW(),l="[object Map]",c="[object Set]";function u(f){if(f==null)return 0;if(n(f))return r(f)?s(f):f.length;var p=t(f);return p==l||p==c?f.size:e(f).length}return Dw=u,Dw}var Fw,gC;function NW(){if(gC)return Fw;gC=1;var e=Wb(),t=hI(),n=ek(),r=ha(),s=zf(),l=nn(),c=rc(),u=Uu(),f=zr(),p=Vu();function h(m,y,v){var S=l(m),b=S||c(m)||p(m);if(y=r(y,4),v==null){var _=m&&m.constructor;b?v=S?new _:[]:f(m)?v=u(_)?t(s(m)):{}:v={}}return(b?e:n)(m,function(k,j,E){return y(v,k,j,E)}),v}return Fw=h,Fw}var qw,yC;function SW(){if(yC)return qw;yC=1;var e=nc(),t=Wu(),n=nn(),r=e?e.isConcatSpreadable:void 0;function s(l){return n(l)||t(l)||!!(r&&l&&l[r])}return qw=s,qw}var Bw,wC;function rk(){if(wC)return Bw;wC=1;var e=Xb(),t=SW();function n(r,s,l,c,u){var f=-1,p=r.length;for(l||(l=t),u||(u=[]);++f<p;){var h=r[f];s>0&&l(h)?s>1?n(h,s-1,l,c,u):e(u,h):c||(u[u.length]=h)}return u}return Bw=n,Bw}var zw,vC;function jW(){if(vC)return zw;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 zw=e,zw}var Uw,xC;function $I(){if(xC)return Uw;xC=1;var e=jW(),t=Math.max;function n(r,s,l){return s=t(s===void 0?r.length-1:s,0),function(){for(var c=arguments,u=-1,f=t(c.length-s,0),p=Array(f);++u<f;)p[u]=c[s+u];u=-1;for(var h=Array(s+1);++u<s;)h[u]=c[u];return h[s]=l(p),e(r,this,h)}}return Uw=n,Uw}var Hw,bC;function _W(){if(bC)return Hw;bC=1;var e=Qb(),t=JM(),n=bi(),r=t?function(s,l){return t(s,"toString",{configurable:!0,enumerable:!1,value:e(l),writable:!0})}:n;return Hw=r,Hw}var Ww,kC;function EW(){if(kC)return Ww;kC=1;var e=800,t=16,n=Date.now;function r(s){var l=0,c=0;return function(){var u=n(),f=t-(u-c);if(c=u,f>0){if(++l>=e)return arguments[0]}else l=0;return s.apply(void 0,arguments)}}return Ww=r,Ww}var Vw,NC;function OI(){if(NC)return Vw;NC=1;var e=_W(),t=EW(),n=t(e);return Vw=n,Vw}var Gw,SC;function Gf(){if(SC)return Gw;SC=1;var e=bi(),t=$I(),n=OI();function r(s,l){return n(t(s,l,e),s+"")}return Gw=r,Gw}var Kw,jC;function LI(){if(jC)return Kw;jC=1;function e(t,n,r,s){for(var l=t.length,c=r+(s?1:-1);s?c--:++c<l;)if(n(t[c],c,t))return c;return-1}return Kw=e,Kw}var Yw,_C;function CW(){if(_C)return Yw;_C=1;function e(t){return t!==t}return Yw=e,Yw}var Xw,EC;function TW(){if(EC)return Xw;EC=1;function e(t,n,r){for(var s=r-1,l=t.length;++s<l;)if(t[s]===n)return s;return-1}return Xw=e,Xw}var Zw,CC;function RW(){if(CC)return Zw;CC=1;var e=LI(),t=CW(),n=TW();function r(s,l,c){return l===l?n(s,l,c):e(s,t,c)}return Zw=r,Zw}var Qw,TC;function AW(){if(TC)return Qw;TC=1;var e=RW();function t(n,r){var s=n==null?0:n.length;return!!s&&e(n,r,0)>-1}return Qw=t,Qw}var Jw,RC;function MW(){if(RC)return Jw;RC=1;function e(t,n,r){for(var s=-1,l=t==null?0:t.length;++s<l;)if(r(n,t[s]))return!0;return!1}return Jw=e,Jw}var ev,AC;function IW(){if(AC)return ev;AC=1;function e(){}return ev=e,ev}var tv,MC;function $W(){if(MC)return tv;MC=1;var e=cI(),t=IW(),n=tk(),r=1/0,s=e&&1/n(new e([,-0]))[1]==r?function(l){return new e(l)}:t;return tv=s,tv}var nv,IC;function OW(){if(IC)return nv;IC=1;var e=wI(),t=AW(),n=MW(),r=vI(),s=$W(),l=tk(),c=200;function u(f,p,h){var m=-1,y=t,v=f.length,S=!0,b=[],_=b;if(h)S=!1,y=n;else if(v>=c){var k=p?null:s(f);if(k)return l(k);S=!1,y=r,_=new e}else _=p?[]:b;e:for(;++m<v;){var j=f[m],E=p?p(j):j;if(j=h||j!==0?j:0,S&&E===E){for(var C=_.length;C--;)if(_[C]===E)continue e;p&&_.push(E),b.push(j)}else y(_,E,h)||(_!==b&&_.push(E),b.push(j))}return b}return nv=u,nv}var rv,$C;function PI(){if($C)return rv;$C=1;var e=da(),t=Us();function n(r){return t(r)&&e(r)}return rv=n,rv}var sv,OC;function LW(){if(OC)return sv;OC=1;var e=rk(),t=Gf(),n=OW(),r=PI(),s=t(function(l){return n(e(l,1,r,!0))});return sv=s,sv}var av,LC;function PW(){if(LC)return av;LC=1;var e=Hf();function t(n,r){return e(r,function(s){return n[s]})}return av=t,av}var ov,PC;function DI(){if(PC)return ov;PC=1;var e=PW(),t=oo();function n(r){return r==null?[]:e(r,t(r))}return ov=n,ov}var iv,DC;function Ur(){if(DC)return iv;DC=1;var e;if(typeof zb=="function")try{e={clone:HH(),constant:Qb(),each:yI(),filter:CI(),has:TI(),isArray:nn(),isEmpty:pW(),isFunction:Uu(),isUndefined:RI(),keys:oo(),map:MI(),reduce:II(),size:kW(),transform:NW(),union:LW(),values:DI()}}catch{}return e||(e=window._),iv=e,iv}var lv,FC;function sk(){if(FC)return lv;FC=1;var e=Ur();lv=s;var t="\0",n="\0",r="";function s(h){this._isDirected=e.has(h,"directed")?h.directed:!0,this._isMultigraph=e.has(h,"multigraph")?h.multigraph:!1,this._isCompound=e.has(h,"compound")?h.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(h){return this._label=h,this},s.prototype.graph=function(){return this._label},s.prototype.setDefaultNodeLabel=function(h){return e.isFunction(h)||(h=e.constant(h)),this._defaultNodeLabelFn=h,this},s.prototype.nodeCount=function(){return this._nodeCount},s.prototype.nodes=function(){return e.keys(this._nodes)},s.prototype.sources=function(){var h=this;return e.filter(this.nodes(),function(m){return e.isEmpty(h._in[m])})},s.prototype.sinks=function(){var h=this;return e.filter(this.nodes(),function(m){return e.isEmpty(h._out[m])})},s.prototype.setNodes=function(h,m){var y=arguments,v=this;return e.each(h,function(S){y.length>1?v.setNode(S,m):v.setNode(S)}),this},s.prototype.setNode=function(h,m){return e.has(this._nodes,h)?(arguments.length>1&&(this._nodes[h]=m),this):(this._nodes[h]=arguments.length>1?m:this._defaultNodeLabelFn(h),this._isCompound&&(this._parent[h]=n,this._children[h]={},this._children[n][h]=!0),this._in[h]={},this._preds[h]={},this._out[h]={},this._sucs[h]={},++this._nodeCount,this)},s.prototype.node=function(h){return this._nodes[h]},s.prototype.hasNode=function(h){return e.has(this._nodes,h)},s.prototype.removeNode=function(h){var m=this;if(e.has(this._nodes,h)){var y=function(v){m.removeEdge(m._edgeObjs[v])};delete this._nodes[h],this._isCompound&&(this._removeFromParentsChildList(h),delete this._parent[h],e.each(this.children(h),function(v){m.setParent(v)}),delete this._children[h]),e.each(e.keys(this._in[h]),y),delete this._in[h],delete this._preds[h],e.each(e.keys(this._out[h]),y),delete this._out[h],delete this._sucs[h],--this._nodeCount}return this},s.prototype.setParent=function(h,m){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(m))m=n;else{m+="";for(var y=m;!e.isUndefined(y);y=this.parent(y))if(y===h)throw new Error("Setting "+m+" as parent of "+h+" would create a cycle");this.setNode(m)}return this.setNode(h),this._removeFromParentsChildList(h),this._parent[h]=m,this._children[m][h]=!0,this},s.prototype._removeFromParentsChildList=function(h){delete this._children[this._parent[h]][h]},s.prototype.parent=function(h){if(this._isCompound){var m=this._parent[h];if(m!==n)return m}},s.prototype.children=function(h){if(e.isUndefined(h)&&(h=n),this._isCompound){var m=this._children[h];if(m)return e.keys(m)}else{if(h===n)return this.nodes();if(this.hasNode(h))return[]}},s.prototype.predecessors=function(h){var m=this._preds[h];if(m)return e.keys(m)},s.prototype.successors=function(h){var m=this._sucs[h];if(m)return e.keys(m)},s.prototype.neighbors=function(h){var m=this.predecessors(h);if(m)return e.union(m,this.successors(h))},s.prototype.isLeaf=function(h){var m;return this.isDirected()?m=this.successors(h):m=this.neighbors(h),m.length===0},s.prototype.filterNodes=function(h){var m=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});m.setGraph(this.graph());var y=this;e.each(this._nodes,function(b,_){h(_)&&m.setNode(_,b)}),e.each(this._edgeObjs,function(b){m.hasNode(b.v)&&m.hasNode(b.w)&&m.setEdge(b,y.edge(b))});var v={};function S(b){var _=y.parent(b);return _===void 0||m.hasNode(_)?(v[b]=_,_):_ in v?v[_]:S(_)}return this._isCompound&&e.each(m.nodes(),function(b){m.setParent(b,S(b))}),m},s.prototype.setDefaultEdgeLabel=function(h){return e.isFunction(h)||(h=e.constant(h)),this._defaultEdgeLabelFn=h,this},s.prototype.edgeCount=function(){return this._edgeCount},s.prototype.edges=function(){return e.values(this._edgeObjs)},s.prototype.setPath=function(h,m){var y=this,v=arguments;return e.reduce(h,function(S,b){return v.length>1?y.setEdge(S,b,m):y.setEdge(S,b),b}),this},s.prototype.setEdge=function(){var h,m,y,v,S=!1,b=arguments[0];typeof b=="object"&&b!==null&&"v"in b?(h=b.v,m=b.w,y=b.name,arguments.length===2&&(v=arguments[1],S=!0)):(h=b,m=arguments[1],y=arguments[3],arguments.length>2&&(v=arguments[2],S=!0)),h=""+h,m=""+m,e.isUndefined(y)||(y=""+y);var _=u(this._isDirected,h,m,y);if(e.has(this._edgeLabels,_))return S&&(this._edgeLabels[_]=v),this;if(!e.isUndefined(y)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(h),this.setNode(m),this._edgeLabels[_]=S?v:this._defaultEdgeLabelFn(h,m,y);var k=f(this._isDirected,h,m,y);return h=k.v,m=k.w,Object.freeze(k),this._edgeObjs[_]=k,l(this._preds[m],h),l(this._sucs[h],m),this._in[m][_]=k,this._out[h][_]=k,this._edgeCount++,this},s.prototype.edge=function(h,m,y){var v=arguments.length===1?p(this._isDirected,arguments[0]):u(this._isDirected,h,m,y);return this._edgeLabels[v]},s.prototype.hasEdge=function(h,m,y){var v=arguments.length===1?p(this._isDirected,arguments[0]):u(this._isDirected,h,m,y);return e.has(this._edgeLabels,v)},s.prototype.removeEdge=function(h,m,y){var v=arguments.length===1?p(this._isDirected,arguments[0]):u(this._isDirected,h,m,y),S=this._edgeObjs[v];return S&&(h=S.v,m=S.w,delete this._edgeLabels[v],delete this._edgeObjs[v],c(this._preds[m],h),c(this._sucs[h],m),delete this._in[m][v],delete this._out[h][v],this._edgeCount--),this},s.prototype.inEdges=function(h,m){var y=this._in[h];if(y){var v=e.values(y);return m?e.filter(v,function(S){return S.v===m}):v}},s.prototype.outEdges=function(h,m){var y=this._out[h];if(y){var v=e.values(y);return m?e.filter(v,function(S){return S.w===m}):v}},s.prototype.nodeEdges=function(h,m){var y=this.inEdges(h,m);if(y)return y.concat(this.outEdges(h,m))};function l(h,m){h[m]?h[m]++:h[m]=1}function c(h,m){--h[m]||delete h[m]}function u(h,m,y,v){var S=""+m,b=""+y;if(!h&&S>b){var _=S;S=b,b=_}return S+r+b+r+(e.isUndefined(v)?t:v)}function f(h,m,y,v){var S=""+m,b=""+y;if(!h&&S>b){var _=S;S=b,b=_}var k={v:S,w:b};return v&&(k.name=v),k}function p(h,m){return u(h,m.v,m.w,m.name)}return lv}var cv,qC;function DW(){return qC||(qC=1,cv="2.1.8"),cv}var uv,BC;function FW(){return BC||(BC=1,uv={Graph:sk(),version:DW()}),uv}var dv,zC;function qW(){if(zC)return dv;zC=1;var e=Ur(),t=sk();dv={write:n,read:l};function n(c){var u={options:{directed:c.isDirected(),multigraph:c.isMultigraph(),compound:c.isCompound()},nodes:r(c),edges:s(c)};return e.isUndefined(c.graph())||(u.value=e.clone(c.graph())),u}function r(c){return e.map(c.nodes(),function(u){var f=c.node(u),p=c.parent(u),h={v:u};return e.isUndefined(f)||(h.value=f),e.isUndefined(p)||(h.parent=p),h})}function s(c){return e.map(c.edges(),function(u){var f=c.edge(u),p={v:u.v,w:u.w};return e.isUndefined(u.name)||(p.name=u.name),e.isUndefined(f)||(p.value=f),p})}function l(c){var u=new t(c.options).setGraph(c.value);return e.each(c.nodes,function(f){u.setNode(f.v,f.value),f.parent&&u.setParent(f.v,f.parent)}),e.each(c.edges,function(f){u.setEdge({v:f.v,w:f.w,name:f.name},f.value)}),u}return dv}var hv,UC;function BW(){if(UC)return hv;UC=1;var e=Ur();hv=t;function t(n){var r={},s=[],l;function c(u){e.has(r,u)||(r[u]=!0,l.push(u),e.each(n.successors(u),c),e.each(n.predecessors(u),c))}return e.each(n.nodes(),function(u){l=[],c(u),l.length&&s.push(l)}),s}return hv}var fv,HC;function FI(){if(HC)return fv;HC=1;var e=Ur();fv=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 l=this._arr,c=l.length;return s[n]=c,l.push({key:n,priority:r}),this._decrease(c),!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,l=s+1,c=n;s<r.length&&(c=r[s].priority<r[c].priority?s:c,l<r.length&&(c=r[l].priority<r[c].priority?l:c),c!==n&&(this._swap(n,c),this._heapify(c)))},t.prototype._decrease=function(n){for(var r=this._arr,s=r[n].priority,l;n!==0&&(l=n>>1,!(r[l].priority<s));)this._swap(n,l),n=l},t.prototype._swap=function(n,r){var s=this._arr,l=this._keyIndices,c=s[n],u=s[r];s[n]=u,s[r]=c,l[u.key]=n,l[c.key]=r},fv}var pv,WC;function qI(){if(WC)return pv;WC=1;var e=Ur(),t=FI();pv=r;var n=e.constant(1);function r(l,c,u,f){return s(l,String(c),u||n,f||function(p){return l.outEdges(p)})}function s(l,c,u,f){var p={},h=new t,m,y,v=function(S){var b=S.v!==m?S.v:S.w,_=p[b],k=u(S),j=y.distance+k;if(k<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+S+" Weight: "+k);j<_.distance&&(_.distance=j,_.predecessor=m,h.decrease(b,j))};for(l.nodes().forEach(function(S){var b=S===c?0:Number.POSITIVE_INFINITY;p[S]={distance:b},h.add(S,b)});h.size()>0&&(m=h.removeMin(),y=p[m],y.distance!==Number.POSITIVE_INFINITY);)f(m).forEach(v);return p}return pv}var mv,VC;function zW(){if(VC)return mv;VC=1;var e=qI(),t=Ur();mv=n;function n(r,s,l){return t.transform(r.nodes(),function(c,u){c[u]=e(r,u,s,l)},{})}return mv}var gv,GC;function BI(){if(GC)return gv;GC=1;var e=Ur();gv=t;function t(n){var r=0,s=[],l={},c=[];function u(f){var p=l[f]={onStack:!0,lowlink:r,index:r++};if(s.push(f),n.successors(f).forEach(function(y){e.has(l,y)?l[y].onStack&&(p.lowlink=Math.min(p.lowlink,l[y].index)):(u(y),p.lowlink=Math.min(p.lowlink,l[y].lowlink))}),p.lowlink===p.index){var h=[],m;do m=s.pop(),l[m].onStack=!1,h.push(m);while(f!==m);c.push(h)}}return n.nodes().forEach(function(f){e.has(l,f)||u(f)}),c}return gv}var yv,KC;function UW(){if(KC)return yv;KC=1;var e=Ur(),t=BI();yv=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 yv}var wv,YC;function HW(){if(YC)return wv;YC=1;var e=Ur();wv=n;var t=e.constant(1);function n(s,l,c){return r(s,l||t,c||function(u){return s.outEdges(u)})}function r(s,l,c){var u={},f=s.nodes();return f.forEach(function(p){u[p]={},u[p][p]={distance:0},f.forEach(function(h){p!==h&&(u[p][h]={distance:Number.POSITIVE_INFINITY})}),c(p).forEach(function(h){var m=h.v===p?h.w:h.v,y=l(h);u[p][m]={distance:y,predecessor:p}})}),f.forEach(function(p){var h=u[p];f.forEach(function(m){var y=u[m];f.forEach(function(v){var S=y[p],b=h[v],_=y[v],k=S.distance+b.distance;k<_.distance&&(_.distance=k,_.predecessor=b.predecessor)})})}),u}return wv}var vv,XC;function zI(){if(XC)return vv;XC=1;var e=Ur();vv=t,t.CycleException=n;function t(r){var s={},l={},c=[];function u(f){if(e.has(l,f))throw new n;e.has(s,f)||(l[f]=!0,s[f]=!0,e.each(r.predecessors(f),u),delete l[f],c.push(f))}if(e.each(r.sinks(),u),e.size(s)!==r.nodeCount())throw new n;return c}function n(){}return n.prototype=new Error,vv}var xv,ZC;function WW(){if(ZC)return xv;ZC=1;var e=zI();xv=t;function t(n){try{e(n)}catch(r){if(r instanceof e.CycleException)return!1;throw r}return!0}return xv}var bv,QC;function UI(){if(QC)return bv;QC=1;var e=Ur();bv=t;function t(r,s,l){e.isArray(s)||(s=[s]);var c=(r.isDirected()?r.successors:r.neighbors).bind(r),u=[],f={};return e.each(s,function(p){if(!r.hasNode(p))throw new Error("Graph does not have node: "+p);n(r,p,l==="post",f,c,u)}),u}function n(r,s,l,c,u,f){e.has(c,s)||(c[s]=!0,l||f.push(s),e.each(u(s),function(p){n(r,p,l,c,u,f)}),l&&f.push(s))}return bv}var kv,JC;function VW(){if(JC)return kv;JC=1;var e=UI();kv=t;function t(n,r){return e(n,r,"post")}return kv}var Nv,eT;function GW(){if(eT)return Nv;eT=1;var e=UI();Nv=t;function t(n,r){return e(n,r,"pre")}return Nv}var Sv,tT;function KW(){if(tT)return Sv;tT=1;var e=Ur(),t=sk(),n=FI();Sv=r;function r(s,l){var c=new t,u={},f=new n,p;function h(y){var v=y.v===p?y.w:y.v,S=f.priority(v);if(S!==void 0){var b=l(y);b<S&&(u[v]=p,f.decrease(v,b))}}if(s.nodeCount()===0)return c;e.each(s.nodes(),function(y){f.add(y,Number.POSITIVE_INFINITY),c.setNode(y)}),f.decrease(s.nodes()[0],0);for(var m=!1;f.size()>0;){if(p=f.removeMin(),e.has(u,p))c.setEdge(p,u[p]);else{if(m)throw new Error("Input graph is not connected: "+s);m=!0}s.nodeEdges(p).forEach(h)}return c}return Sv}var jv,nT;function YW(){return nT||(nT=1,jv={components:BW(),dijkstra:qI(),dijkstraAll:zW(),findCycles:UW(),floydWarshall:HW(),isAcyclic:WW(),postorder:VW(),preorder:GW(),prim:KW(),tarjan:BI(),topsort:zI()}),jv}var _v,rT;function XW(){if(rT)return _v;rT=1;var e=FW();return _v={Graph:e.Graph,json:qW(),alg:YW(),version:e.version},_v}var Ev,sT;function vs(){if(sT)return Ev;sT=1;var e;if(typeof zb=="function")try{e=XW()}catch{}return e||(e=window.graphlib),Ev=e,Ev}var Cv,aT;function ZW(){if(aT)return Cv;aT=1;var e=pI(),t=1,n=4;function r(s){return e(s,t|n)}return Cv=r,Cv}var Tv,oT;function Kf(){if(oT)return Tv;oT=1;var e=tc(),t=da(),n=Ff(),r=zr();function s(l,c,u){if(!r(u))return!1;var f=typeof c;return(f=="number"?t(u)&&n(c,u.length):f=="string"&&c in u)?e(u[c],l):!1}return Tv=s,Tv}var Rv,iT;function QW(){if(iT)return Rv;iT=1;var e=Gf(),t=tc(),n=Kf(),r=xi(),s=Object.prototype,l=s.hasOwnProperty,c=e(function(u,f){u=Object(u);var p=-1,h=f.length,m=h>2?f[2]:void 0;for(m&&n(f[0],f[1],m)&&(h=1);++p<h;)for(var y=f[p],v=r(y),S=-1,b=v.length;++S<b;){var _=v[S],k=u[_];(k===void 0||t(k,s[_])&&!l.call(u,_))&&(u[_]=y[_])}return u});return Rv=c,Rv}var Av,lT;function JW(){if(lT)return Av;lT=1;var e=ha(),t=da(),n=oo();function r(s){return function(l,c,u){var f=Object(l);if(!t(l)){var p=e(c,3);l=n(l),c=function(m){return p(f[m],m,f)}}var h=s(l,c,u);return h>-1?f[p?l[h]:h]:void 0}}return Av=r,Av}var Mv,cT;function e7(){if(cT)return Mv;cT=1;var e=/\s/;function t(n){for(var r=n.length;r--&&e.test(n.charAt(r)););return r}return Mv=t,Mv}var Iv,uT;function t7(){if(uT)return Iv;uT=1;var e=e7(),t=/^\s+/;function n(r){return r&&r.slice(0,e(r)+1).replace(t,"")}return Iv=n,Iv}var $v,dT;function n7(){if(dT)return $v;dT=1;var e=t7(),t=zr(),n=ac(),r=NaN,s=/^[-+]0x[0-9a-f]+$/i,l=/^0b[01]+$/i,c=/^0o[0-7]+$/i,u=parseInt;function f(p){if(typeof p=="number")return p;if(n(p))return r;if(t(p)){var h=typeof p.valueOf=="function"?p.valueOf():p;p=t(h)?h+"":h}if(typeof p!="string")return p===0?p:+p;p=e(p);var m=l.test(p);return m||c.test(p)?u(p.slice(2),m?2:8):s.test(p)?r:+p}return $v=f,$v}var Ov,hT;function HI(){if(hT)return Ov;hT=1;var e=n7(),t=1/0,n=17976931348623157e292;function r(s){if(!s)return s===0?s:0;if(s=e(s),s===t||s===-t){var l=s<0?-1:1;return l*n}return s===s?s:0}return Ov=r,Ov}var Lv,fT;function r7(){if(fT)return Lv;fT=1;var e=HI();function t(n){var r=e(n),s=r%1;return r===r?s?r-s:r:0}return Lv=t,Lv}var Pv,pT;function s7(){if(pT)return Pv;pT=1;var e=LI(),t=ha(),n=r7(),r=Math.max;function s(l,c,u){var f=l==null?0:l.length;if(!f)return-1;var p=u==null?0:n(u);return p<0&&(p=r(f+p,0)),e(l,t(c,3),p)}return Pv=s,Pv}var Dv,mT;function a7(){if(mT)return Dv;mT=1;var e=JW(),t=s7(),n=e(t);return Dv=n,Dv}var Fv,gT;function WI(){if(gT)return Fv;gT=1;var e=rk();function t(n){var r=n==null?0:n.length;return r?e(n,1):[]}return Fv=t,Fv}var qv,yT;function o7(){if(yT)return qv;yT=1;var e=Jb(),t=mI(),n=xi();function r(s,l){return s==null?s:e(s,t(l),n)}return qv=r,qv}var Bv,wT;function i7(){if(wT)return Bv;wT=1;function e(t){var n=t==null?0:t.length;return n?t[n-1]:void 0}return Bv=e,Bv}var zv,vT;function l7(){if(vT)return zv;vT=1;var e=Pf(),t=ek(),n=ha();function r(s,l){var c={};return l=n(l,3),t(s,function(u,f,p){e(c,f,l(u,f,p))}),c}return zv=r,zv}var Uv,xT;function ak(){if(xT)return Uv;xT=1;var e=ac();function t(n,r,s){for(var l=-1,c=n.length;++l<c;){var u=n[l],f=r(u);if(f!=null&&(p===void 0?f===f&&!e(f):s(f,p)))var p=f,h=u}return h}return Uv=t,Uv}var Hv,bT;function c7(){if(bT)return Hv;bT=1;function e(t,n){return t>n}return Hv=e,Hv}var Wv,kT;function u7(){if(kT)return Wv;kT=1;var e=ak(),t=c7(),n=bi();function r(s){return s&&s.length?e(s,n,t):void 0}return Wv=r,Wv}var Vv,NT;function VI(){if(NT)return Vv;NT=1;var e=Pf(),t=tc();function n(r,s,l){(l!==void 0&&!t(r[s],l)||l===void 0&&!(s in r))&&e(r,s,l)}return Vv=n,Vv}var Gv,ST;function d7(){if(ST)return Gv;ST=1;var e=wi(),t=zf(),n=Us(),r="[object Object]",s=Function.prototype,l=Object.prototype,c=s.toString,u=l.hasOwnProperty,f=c.call(Object);function p(h){if(!n(h)||e(h)!=r)return!1;var m=t(h);if(m===null)return!0;var y=u.call(m,"constructor")&&m.constructor;return typeof y=="function"&&y instanceof y&&c.call(y)==f}return Gv=p,Gv}var Kv,jT;function GI(){if(jT)return Kv;jT=1;function e(t,n){if(!(n==="constructor"&&typeof t[n]=="function")&&n!="__proto__")return t[n]}return Kv=e,Kv}var Yv,_T;function h7(){if(_T)return Yv;_T=1;var e=Hu(),t=xi();function n(r){return e(r,t(r))}return Yv=n,Yv}var Xv,ET;function f7(){if(ET)return Xv;ET=1;var e=VI(),t=nI(),n=dI(),r=rI(),s=fI(),l=Wu(),c=nn(),u=PI(),f=rc(),p=Uu(),h=zr(),m=d7(),y=Vu(),v=GI(),S=h7();function b(_,k,j,E,C,R,I){var O=v(_,j),H=v(k,j),q=I.get(H);if(q){e(_,j,q);return}var $=R?R(O,H,j+"",_,k,I):void 0,V=$===void 0;if(V){var ne=c(H),ee=!ne&&f(H),M=!ne&&!ee&&y(H);$=H,ne||ee||M?c(O)?$=O:u(O)?$=r(O):ee?(V=!1,$=t(H,!0)):M?(V=!1,$=n(H,!0)):$=[]:m(H)||l(H)?($=O,l(O)?$=S(O):(!h(O)||p(O))&&($=s(H))):V=!1}V&&(I.set(H,$),C($,H,E,R,I),I.delete(H)),e(_,j,$)}return Xv=b,Xv}var Zv,CT;function p7(){if(CT)return Zv;CT=1;var e=Lf(),t=VI(),n=Jb(),r=f7(),s=zr(),l=xi(),c=GI();function u(f,p,h,m,y){f!==p&&n(p,function(v,S){if(y||(y=new e),s(v))r(f,p,S,h,u,m,y);else{var b=m?m(c(f,S),v,S+"",f,p,y):void 0;b===void 0&&(b=v),t(f,S,b)}},l)}return Zv=u,Zv}var Qv,TT;function m7(){if(TT)return Qv;TT=1;var e=Gf(),t=Kf();function n(r){return e(function(s,l){var c=-1,u=l.length,f=u>1?l[u-1]:void 0,p=u>2?l[2]:void 0;for(f=r.length>3&&typeof f=="function"?(u--,f):void 0,p&&t(l[0],l[1],p)&&(f=u<3?void 0:f,u=1),s=Object(s);++c<u;){var h=l[c];h&&r(s,h,c,f)}return s})}return Qv=n,Qv}var Jv,RT;function g7(){if(RT)return Jv;RT=1;var e=p7(),t=m7(),n=t(function(r,s,l){e(r,s,l)});return Jv=n,Jv}var ex,AT;function KI(){if(AT)return ex;AT=1;function e(t,n){return t<n}return ex=e,ex}var tx,MT;function y7(){if(MT)return tx;MT=1;var e=ak(),t=KI(),n=bi();function r(s){return s&&s.length?e(s,n,t):void 0}return tx=r,tx}var nx,IT;function w7(){if(IT)return nx;IT=1;var e=ak(),t=ha(),n=KI();function r(s,l){return s&&s.length?e(s,t(l,2),n):void 0}return nx=r,nx}var rx,$T;function v7(){if($T)return rx;$T=1;var e=bs(),t=function(){return e.Date.now()};return rx=t,rx}var sx,OT;function x7(){if(OT)return sx;OT=1;var e=Df(),t=Wf(),n=Ff(),r=zr(),s=Gu();function l(c,u,f,p){if(!r(c))return c;u=t(u,c);for(var h=-1,m=u.length,y=m-1,v=c;v!=null&&++h<m;){var S=s(u[h]),b=f;if(S==="__proto__"||S==="constructor"||S==="prototype")return c;if(h!=y){var _=v[S];b=p?p(_,S,v):void 0,b===void 0&&(b=r(_)?_:n(u[h+1])?[]:{})}e(v,S,b),v=v[S]}return c}return sx=l,sx}var ax,LT;function b7(){if(LT)return ax;LT=1;var e=Vf(),t=x7(),n=Wf();function r(s,l,c){for(var u=-1,f=l.length,p={};++u<f;){var h=l[u],m=e(s,h);c(m,h)&&t(p,n(h,s),m)}return p}return ax=r,ax}var ox,PT;function k7(){if(PT)return ox;PT=1;var e=b7(),t=_I();function n(r,s){return e(r,s,function(l,c){return t(r,c)})}return ox=n,ox}var ix,DT;function N7(){if(DT)return ix;DT=1;var e=WI(),t=$I(),n=OI();function r(s){return n(t(s,void 0,e),s+"")}return ix=r,ix}var lx,FT;function S7(){if(FT)return lx;FT=1;var e=k7(),t=N7(),n=t(function(r,s){return r==null?{}:e(r,s)});return lx=n,lx}var cx,qT;function j7(){if(qT)return cx;qT=1;var e=Math.ceil,t=Math.max;function n(r,s,l,c){for(var u=-1,f=t(e((s-r)/(l||1)),0),p=Array(f);f--;)p[c?f:++u]=r,r+=l;return p}return cx=n,cx}var ux,BT;function _7(){if(BT)return ux;BT=1;var e=j7(),t=Kf(),n=HI();function r(s){return function(l,c,u){return u&&typeof u!="number"&&t(l,c,u)&&(c=u=void 0),l=n(l),c===void 0?(c=l,l=0):c=n(c),u=u===void 0?l<c?1:-1:n(u),e(l,c,u,s)}}return ux=r,ux}var dx,zT;function E7(){if(zT)return dx;zT=1;var e=_7(),t=e();return dx=t,dx}var hx,UT;function C7(){if(UT)return hx;UT=1;function e(t,n){var r=t.length;for(t.sort(n);r--;)t[r]=t[r].value;return t}return hx=e,hx}var fx,HT;function T7(){if(HT)return fx;HT=1;var e=ac();function t(n,r){if(n!==r){var s=n!==void 0,l=n===null,c=n===n,u=e(n),f=r!==void 0,p=r===null,h=r===r,m=e(r);if(!p&&!m&&!u&&n>r||u&&f&&h&&!p&&!m||l&&f&&h||!s&&h||!c)return 1;if(!l&&!u&&!m&&n<r||m&&s&&c&&!l&&!u||p&&s&&c||!f&&c||!h)return-1}return 0}return fx=t,fx}var px,WT;function R7(){if(WT)return px;WT=1;var e=T7();function t(n,r,s){for(var l=-1,c=n.criteria,u=r.criteria,f=c.length,p=s.length;++l<f;){var h=e(c[l],u[l]);if(h){if(l>=p)return h;var m=s[l];return h*(m=="desc"?-1:1)}}return n.index-r.index}return px=t,px}var mx,VT;function A7(){if(VT)return mx;VT=1;var e=Hf(),t=Vf(),n=ha(),r=AI(),s=C7(),l=qf(),c=R7(),u=bi(),f=nn();function p(h,m,y){m.length?m=e(m,function(b){return f(b)?function(_){return t(_,b.length===1?b[0]:b)}:b}):m=[u];var v=-1;m=e(m,l(n));var S=r(h,function(b,_,k){var j=e(m,function(E){return E(b)});return{criteria:j,index:++v,value:b}});return s(S,function(b,_){return c(b,_,y)})}return mx=p,mx}var gx,GT;function M7(){if(GT)return gx;GT=1;var e=rk(),t=A7(),n=Gf(),r=Kf(),s=n(function(l,c){if(l==null)return[];var u=c.length;return u>1&&r(l,c[0],c[1])?c=[]:u>2&&r(c[0],c[1],c[2])&&(c=[c[0]]),t(l,e(c,1),[])});return gx=s,gx}var yx,KT;function I7(){if(KT)return yx;KT=1;var e=SI(),t=0;function n(r){var s=++t;return e(r)+s}return yx=n,yx}var wx,YT;function $7(){if(YT)return wx;YT=1;function e(t,n,r){for(var s=-1,l=t.length,c=n.length,u={};++s<l;){var f=s<c?n[s]:void 0;r(u,t[s],f)}return u}return wx=e,wx}var vx,XT;function O7(){if(XT)return vx;XT=1;var e=Df(),t=$7();function n(r,s){return t(r||[],s||[],e)}return vx=n,vx}var xx,ZT;function Pt(){if(ZT)return xx;ZT=1;var e;if(typeof zb=="function")try{e={cloneDeep:ZW(),constant:Qb(),defaults:QW(),each:yI(),filter:CI(),find:a7(),flatten:WI(),forEach:gI(),forIn:o7(),has:TI(),isUndefined:RI(),last:i7(),map:MI(),mapValues:l7(),max:u7(),merge:g7(),min:y7(),minBy:w7(),now:v7(),pick:S7(),range:E7(),reduce:II(),sortBy:M7(),uniqueId:I7(),values:DI(),zipObject:O7()}}catch{}return e||(e=window._),xx=e,xx}var bx,QT;function L7(){if(QT)return bx;QT=1,bx=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,l=s._prev;l!==s;)r.push(JSON.stringify(l,n)),l=l._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 bx}var kx,JT;function P7(){if(JT)return kx;JT=1;var e=Pt(),t=vs().Graph,n=L7();kx=s;var r=e.constant(1);function s(p,h){if(p.nodeCount()<=1)return[];var m=u(p,h||r),y=l(m.graph,m.buckets,m.zeroIdx);return e.flatten(e.map(y,function(v){return p.outEdges(v.v,v.w)}),!0)}function l(p,h,m){for(var y=[],v=h[h.length-1],S=h[0],b;p.nodeCount();){for(;b=S.dequeue();)c(p,h,m,b);for(;b=v.dequeue();)c(p,h,m,b);if(p.nodeCount()){for(var _=h.length-2;_>0;--_)if(b=h[_].dequeue(),b){y=y.concat(c(p,h,m,b,!0));break}}}return y}function c(p,h,m,y,v){var S=v?[]:void 0;return e.forEach(p.inEdges(y.v),function(b){var _=p.edge(b),k=p.node(b.v);v&&S.push({v:b.v,w:b.w}),k.out-=_,f(h,m,k)}),e.forEach(p.outEdges(y.v),function(b){var _=p.edge(b),k=b.w,j=p.node(k);j.in-=_,f(h,m,j)}),p.removeNode(y.v),S}function u(p,h){var m=new t,y=0,v=0;e.forEach(p.nodes(),function(_){m.setNode(_,{v:_,in:0,out:0})}),e.forEach(p.edges(),function(_){var k=m.edge(_.v,_.w)||0,j=h(_),E=k+j;m.setEdge(_.v,_.w,E),v=Math.max(v,m.node(_.v).out+=j),y=Math.max(y,m.node(_.w).in+=j)});var S=e.range(v+y+3).map(function(){return new n}),b=y+1;return e.forEach(m.nodes(),function(_){f(S,b,m.node(_))}),{graph:m,buckets:S,zeroIdx:b}}function f(p,h,m){m.out?m.in?p[m.out-m.in+h].enqueue(m):p[p.length-1].enqueue(m):p[0].enqueue(m)}return kx}var Nx,e2;function D7(){if(e2)return Nx;e2=1;var e=Pt(),t=P7();Nx={run:n,undo:s};function n(l){var c=l.graph().acyclicer==="greedy"?t(l,u(l)):r(l);e.forEach(c,function(f){var p=l.edge(f);l.removeEdge(f),p.forwardName=f.name,p.reversed=!0,l.setEdge(f.w,f.v,p,e.uniqueId("rev"))});function u(f){return function(p){return f.edge(p).weight}}}function r(l){var c=[],u={},f={};function p(h){e.has(f,h)||(f[h]=!0,u[h]=!0,e.forEach(l.outEdges(h),function(m){e.has(u,m.w)?c.push(m):p(m.w)}),delete u[h])}return e.forEach(l.nodes(),p),c}function s(l){e.forEach(l.edges(),function(c){var u=l.edge(c);if(u.reversed){l.removeEdge(c);var f=u.forwardName;delete u.reversed,delete u.forwardName,l.setEdge(c.w,c.v,u,f)}})}return Nx}var Sx,t2;function or(){if(t2)return Sx;t2=1;var e=Pt(),t=vs().Graph;Sx={addDummyNode:n,simplify:r,asNonCompoundGraph:s,successorWeights:l,predecessorWeights:c,intersectRect:u,buildLayerMatrix:f,normalizeRanks:p,removeEmptyRanks:h,addBorderNode:m,maxRank:y,partition:v,time:S,notime:b};function n(_,k,j,E){var C;do C=e.uniqueId(E);while(_.hasNode(C));return j.dummy=k,_.setNode(C,j),C}function r(_){var k=new t().setGraph(_.graph());return e.forEach(_.nodes(),function(j){k.setNode(j,_.node(j))}),e.forEach(_.edges(),function(j){var E=k.edge(j.v,j.w)||{weight:0,minlen:1},C=_.edge(j);k.setEdge(j.v,j.w,{weight:E.weight+C.weight,minlen:Math.max(E.minlen,C.minlen)})}),k}function s(_){var k=new t({multigraph:_.isMultigraph()}).setGraph(_.graph());return e.forEach(_.nodes(),function(j){_.children(j).length||k.setNode(j,_.node(j))}),e.forEach(_.edges(),function(j){k.setEdge(j,_.edge(j))}),k}function l(_){var k=e.map(_.nodes(),function(j){var E={};return e.forEach(_.outEdges(j),function(C){E[C.w]=(E[C.w]||0)+_.edge(C).weight}),E});return e.zipObject(_.nodes(),k)}function c(_){var k=e.map(_.nodes(),function(j){var E={};return e.forEach(_.inEdges(j),function(C){E[C.v]=(E[C.v]||0)+_.edge(C).weight}),E});return e.zipObject(_.nodes(),k)}function u(_,k){var j=_.x,E=_.y,C=k.x-j,R=k.y-E,I=_.width/2,O=_.height/2;if(!C&&!R)throw new Error("Not possible to find intersection inside of the rectangle");var H,q;return Math.abs(R)*I>Math.abs(C)*O?(R<0&&(O=-O),H=O*C/R,q=O):(C<0&&(I=-I),H=I,q=I*R/C),{x:j+H,y:E+q}}function f(_){var k=e.map(e.range(y(_)+1),function(){return[]});return e.forEach(_.nodes(),function(j){var E=_.node(j),C=E.rank;e.isUndefined(C)||(k[C][E.order]=j)}),k}function p(_){var k=e.min(e.map(_.nodes(),function(j){return _.node(j).rank}));e.forEach(_.nodes(),function(j){var E=_.node(j);e.has(E,"rank")&&(E.rank-=k)})}function h(_){var k=e.min(e.map(_.nodes(),function(R){return _.node(R).rank})),j=[];e.forEach(_.nodes(),function(R){var I=_.node(R).rank-k;j[I]||(j[I]=[]),j[I].push(R)});var E=0,C=_.graph().nodeRankFactor;e.forEach(j,function(R,I){e.isUndefined(R)&&I%C!==0?--E:E&&e.forEach(R,function(O){_.node(O).rank+=E})})}function m(_,k,j,E){var C={width:0,height:0};return arguments.length>=4&&(C.rank=j,C.order=E),n(_,"border",C,k)}function y(_){return e.max(e.map(_.nodes(),function(k){var j=_.node(k).rank;if(!e.isUndefined(j))return j}))}function v(_,k){var j={lhs:[],rhs:[]};return e.forEach(_,function(E){k(E)?j.lhs.push(E):j.rhs.push(E)}),j}function S(_,k){var j=e.now();try{return k()}finally{console.log(_+" time: "+(e.now()-j)+"ms")}}function b(_,k){return k()}return Sx}var jx,n2;function F7(){if(n2)return jx;n2=1;var e=Pt(),t=or();jx={run:n,undo:s};function n(l){l.graph().dummyChains=[],e.forEach(l.edges(),function(c){r(l,c)})}function r(l,c){var u=c.v,f=l.node(u).rank,p=c.w,h=l.node(p).rank,m=c.name,y=l.edge(c),v=y.labelRank;if(h!==f+1){l.removeEdge(c);var S,b,_;for(_=0,++f;f<h;++_,++f)y.points=[],b={width:0,height:0,edgeLabel:y,edgeObj:c,rank:f},S=t.addDummyNode(l,"edge",b,"_d"),f===v&&(b.width=y.width,b.height=y.height,b.dummy="edge-label",b.labelpos=y.labelpos),l.setEdge(u,S,{weight:y.weight},m),_===0&&l.graph().dummyChains.push(S),u=S;l.setEdge(u,p,{weight:y.weight},m)}}function s(l){e.forEach(l.graph().dummyChains,function(c){var u=l.node(c),f=u.edgeLabel,p;for(l.setEdge(u.edgeObj,f);u.dummy;)p=l.successors(c)[0],l.removeNode(c),f.points.push({x:u.x,y:u.y}),u.dummy==="edge-label"&&(f.x=u.x,f.y=u.y,f.width=u.width,f.height=u.height),c=p,u=l.node(c)})}return jx}var _x,r2;function af(){if(r2)return _x;r2=1;var e=Pt();_x={longestPath:t,slack:n};function t(r){var s={};function l(c){var u=r.node(c);if(e.has(s,c))return u.rank;s[c]=!0;var f=e.min(e.map(r.outEdges(c),function(p){return l(p.w)-r.edge(p).minlen}));return(f===Number.POSITIVE_INFINITY||f===void 0||f===null)&&(f=0),u.rank=f}e.forEach(r.sources(),l)}function n(r,s){return r.node(s.w).rank-r.node(s.v).rank-r.edge(s).minlen}return _x}var Ex,s2;function YI(){if(s2)return Ex;s2=1;var e=Pt(),t=vs().Graph,n=af().slack;Ex=r;function r(u){var f=new t({directed:!1}),p=u.nodes()[0],h=u.nodeCount();f.setNode(p,{});for(var m,y;s(f,u)<h;)m=l(f,u),y=f.hasNode(m.v)?n(u,m):-n(u,m),c(f,u,y);return f}function s(u,f){function p(h){e.forEach(f.nodeEdges(h),function(m){var y=m.v,v=h===y?m.w:y;!u.hasNode(v)&&!n(f,m)&&(u.setNode(v,{}),u.setEdge(h,v,{}),p(v))})}return e.forEach(u.nodes(),p),u.nodeCount()}function l(u,f){return e.minBy(f.edges(),function(p){if(u.hasNode(p.v)!==u.hasNode(p.w))return n(f,p)})}function c(u,f,p){e.forEach(u.nodes(),function(h){f.node(h).rank+=p})}return Ex}var Cx,a2;function q7(){if(a2)return Cx;a2=1;var e=Pt(),t=YI(),n=af().slack,r=af().longestPath,s=vs().alg.preorder,l=vs().alg.postorder,c=or().simplify;Cx=u,u.initLowLimValues=m,u.initCutValues=f,u.calcCutValue=h,u.leaveEdge=v,u.enterEdge=S,u.exchangeEdges=b;function u(E){E=c(E),r(E);var C=t(E);m(C),f(C,E);for(var R,I;R=v(C);)I=S(C,E,R),b(C,E,R,I)}function f(E,C){var R=l(E,E.nodes());R=R.slice(0,R.length-1),e.forEach(R,function(I){p(E,C,I)})}function p(E,C,R){var I=E.node(R),O=I.parent;E.edge(R,O).cutvalue=h(E,C,R)}function h(E,C,R){var I=E.node(R),O=I.parent,H=!0,q=C.edge(R,O),$=0;return q||(H=!1,q=C.edge(O,R)),$=q.weight,e.forEach(C.nodeEdges(R),function(V){var ne=V.v===R,ee=ne?V.w:V.v;if(ee!==O){var M=ne===H,Z=C.edge(V).weight;if($+=M?Z:-Z,k(E,R,ee)){var K=E.edge(R,ee).cutvalue;$+=M?-K:K}}}),$}function m(E,C){arguments.length<2&&(C=E.nodes()[0]),y(E,{},1,C)}function y(E,C,R,I,O){var H=R,q=E.node(I);return C[I]=!0,e.forEach(E.neighbors(I),function($){e.has(C,$)||(R=y(E,C,R,$,I))}),q.low=H,q.lim=R++,O?q.parent=O:delete q.parent,R}function v(E){return e.find(E.edges(),function(C){return E.edge(C).cutvalue<0})}function S(E,C,R){var I=R.v,O=R.w;C.hasEdge(I,O)||(I=R.w,O=R.v);var H=E.node(I),q=E.node(O),$=H,V=!1;H.lim>q.lim&&($=q,V=!0);var ne=e.filter(C.edges(),function(ee){return V===j(E,E.node(ee.v),$)&&V!==j(E,E.node(ee.w),$)});return e.minBy(ne,function(ee){return n(C,ee)})}function b(E,C,R,I){var O=R.v,H=R.w;E.removeEdge(O,H),E.setEdge(I.v,I.w,{}),m(E),f(E,C),_(E,C)}function _(E,C){var R=e.find(E.nodes(),function(O){return!C.node(O).parent}),I=s(E,R);I=I.slice(1),e.forEach(I,function(O){var H=E.node(O).parent,q=C.edge(O,H),$=!1;q||(q=C.edge(H,O),$=!0),C.node(O).rank=C.node(H).rank+($?q.minlen:-q.minlen)})}function k(E,C,R){return E.hasEdge(C,R)}function j(E,C,R){return R.low<=C.lim&&C.lim<=R.lim}return Cx}var Tx,o2;function B7(){if(o2)return Tx;o2=1;var e=af(),t=e.longestPath,n=YI(),r=q7();Tx=s;function s(f){switch(f.graph().ranker){case"network-simplex":u(f);break;case"tight-tree":c(f);break;case"longest-path":l(f);break;default:u(f)}}var l=t;function c(f){t(f),n(f)}function u(f){r(f)}return Tx}var Rx,i2;function z7(){if(i2)return Rx;i2=1;var e=Pt();Rx=t;function t(s){var l=r(s);e.forEach(s.graph().dummyChains,function(c){for(var u=s.node(c),f=u.edgeObj,p=n(s,l,f.v,f.w),h=p.path,m=p.lca,y=0,v=h[y],S=!0;c!==f.w;){if(u=s.node(c),S){for(;(v=h[y])!==m&&s.node(v).maxRank<u.rank;)y++;v===m&&(S=!1)}if(!S){for(;y<h.length-1&&s.node(v=h[y+1]).minRank<=u.rank;)y++;v=h[y]}s.setParent(c,v),c=s.successors(c)[0]}})}function n(s,l,c,u){var f=[],p=[],h=Math.min(l[c].low,l[u].low),m=Math.max(l[c].lim,l[u].lim),y,v;y=c;do y=s.parent(y),f.push(y);while(y&&(l[y].low>h||m>l[y].lim));for(v=y,y=u;(y=s.parent(y))!==v;)p.push(y);return{path:f.concat(p.reverse()),lca:v}}function r(s){var l={},c=0;function u(f){var p=c;e.forEach(s.children(f),u),l[f]={low:p,lim:c++}}return e.forEach(s.children(),u),l}return Rx}var Ax,l2;function U7(){if(l2)return Ax;l2=1;var e=Pt(),t=or();Ax={run:n,cleanup:c};function n(u){var f=t.addDummyNode(u,"root",{},"_root"),p=s(u),h=e.max(e.values(p))-1,m=2*h+1;u.graph().nestingRoot=f,e.forEach(u.edges(),function(v){u.edge(v).minlen*=m});var y=l(u)+1;e.forEach(u.children(),function(v){r(u,f,m,y,h,p,v)}),u.graph().nodeRankFactor=m}function r(u,f,p,h,m,y,v){var S=u.children(v);if(!S.length){v!==f&&u.setEdge(f,v,{weight:0,minlen:p});return}var b=t.addBorderNode(u,"_bt"),_=t.addBorderNode(u,"_bb"),k=u.node(v);u.setParent(b,v),k.borderTop=b,u.setParent(_,v),k.borderBottom=_,e.forEach(S,function(j){r(u,f,p,h,m,y,j);var E=u.node(j),C=E.borderTop?E.borderTop:j,R=E.borderBottom?E.borderBottom:j,I=E.borderTop?h:2*h,O=C!==R?1:m-y[v]+1;u.setEdge(b,C,{weight:I,minlen:O,nestingEdge:!0}),u.setEdge(R,_,{weight:I,minlen:O,nestingEdge:!0})}),u.parent(v)||u.setEdge(f,b,{weight:0,minlen:m+y[v]})}function s(u){var f={};function p(h,m){var y=u.children(h);y&&y.length&&e.forEach(y,function(v){p(v,m+1)}),f[h]=m}return e.forEach(u.children(),function(h){p(h,1)}),f}function l(u){return e.reduce(u.edges(),function(f,p){return f+u.edge(p).weight},0)}function c(u){var f=u.graph();u.removeNode(f.nestingRoot),delete f.nestingRoot,e.forEach(u.edges(),function(p){var h=u.edge(p);h.nestingEdge&&u.removeEdge(p)})}return Ax}var Mx,c2;function H7(){if(c2)return Mx;c2=1;var e=Pt(),t=or();Mx=n;function n(s){function l(c){var u=s.children(c),f=s.node(c);if(u.length&&e.forEach(u,l),e.has(f,"minRank")){f.borderLeft=[],f.borderRight=[];for(var p=f.minRank,h=f.maxRank+1;p<h;++p)r(s,"borderLeft","_bl",c,f,p),r(s,"borderRight","_br",c,f,p)}}e.forEach(s.children(),l)}function r(s,l,c,u,f,p){var h={width:0,height:0,rank:p,borderType:l},m=f[l][p-1],y=t.addDummyNode(s,"border",h,c);f[l][p]=y,s.setParent(y,u),m&&s.setEdge(m,y,{weight:1})}return Mx}var Ix,u2;function W7(){if(u2)return Ix;u2=1;var e=Pt();Ix={adjust:t,undo:n};function t(p){var h=p.graph().rankdir.toLowerCase();(h==="lr"||h==="rl")&&r(p)}function n(p){var h=p.graph().rankdir.toLowerCase();(h==="bt"||h==="rl")&&l(p),(h==="lr"||h==="rl")&&(u(p),r(p))}function r(p){e.forEach(p.nodes(),function(h){s(p.node(h))}),e.forEach(p.edges(),function(h){s(p.edge(h))})}function s(p){var h=p.width;p.width=p.height,p.height=h}function l(p){e.forEach(p.nodes(),function(h){c(p.node(h))}),e.forEach(p.edges(),function(h){var m=p.edge(h);e.forEach(m.points,c),e.has(m,"y")&&c(m)})}function c(p){p.y=-p.y}function u(p){e.forEach(p.nodes(),function(h){f(p.node(h))}),e.forEach(p.edges(),function(h){var m=p.edge(h);e.forEach(m.points,f),e.has(m,"x")&&f(m)})}function f(p){var h=p.x;p.x=p.y,p.y=h}return Ix}var $x,d2;function V7(){if(d2)return $x;d2=1;var e=Pt();$x=t;function t(n){var r={},s=e.filter(n.nodes(),function(p){return!n.children(p).length}),l=e.max(e.map(s,function(p){return n.node(p).rank})),c=e.map(e.range(l+1),function(){return[]});function u(p){if(!e.has(r,p)){r[p]=!0;var h=n.node(p);c[h.rank].push(p),e.forEach(n.successors(p),u)}}var f=e.sortBy(s,function(p){return n.node(p).rank});return e.forEach(f,u),c}return $x}var Ox,h2;function G7(){if(h2)return Ox;h2=1;var e=Pt();Ox=t;function t(r,s){for(var l=0,c=1;c<s.length;++c)l+=n(r,s[c-1],s[c]);return l}function n(r,s,l){for(var c=e.zipObject(l,e.map(l,function(y,v){return v})),u=e.flatten(e.map(s,function(y){return e.sortBy(e.map(r.outEdges(y),function(v){return{pos:c[v.w],weight:r.edge(v).weight}}),"pos")}),!0),f=1;f<l.length;)f<<=1;var p=2*f-1;f-=1;var h=e.map(new Array(p),function(){return 0}),m=0;return e.forEach(u.forEach(function(y){var v=y.pos+f;h[v]+=y.weight;for(var S=0;v>0;)v%2&&(S+=h[v+1]),v=v-1>>1,h[v]+=y.weight;m+=y.weight*S})),m}return Ox}var Lx,f2;function K7(){if(f2)return Lx;f2=1;var e=Pt();Lx=t;function t(n,r){return e.map(r,function(s){var l=n.inEdges(s);if(l.length){var c=e.reduce(l,function(u,f){var p=n.edge(f),h=n.node(f.v);return{sum:u.sum+p.weight*h.order,weight:u.weight+p.weight}},{sum:0,weight:0});return{v:s,barycenter:c.sum/c.weight,weight:c.weight}}else return{v:s}})}return Lx}var Px,p2;function Y7(){if(p2)return Px;p2=1;var e=Pt();Px=t;function t(s,l){var c={};e.forEach(s,function(f,p){var h=c[f.v]={indegree:0,in:[],out:[],vs:[f.v],i:p};e.isUndefined(f.barycenter)||(h.barycenter=f.barycenter,h.weight=f.weight)}),e.forEach(l.edges(),function(f){var p=c[f.v],h=c[f.w];!e.isUndefined(p)&&!e.isUndefined(h)&&(h.indegree++,p.out.push(c[f.w]))});var u=e.filter(c,function(f){return!f.indegree});return n(u)}function n(s){var l=[];function c(p){return function(h){h.merged||(e.isUndefined(h.barycenter)||e.isUndefined(p.barycenter)||h.barycenter>=p.barycenter)&&r(p,h)}}function u(p){return function(h){h.in.push(p),--h.indegree===0&&s.push(h)}}for(;s.length;){var f=s.pop();l.push(f),e.forEach(f.in.reverse(),c(f)),e.forEach(f.out,u(f))}return e.map(e.filter(l,function(p){return!p.merged}),function(p){return e.pick(p,["vs","i","barycenter","weight"])})}function r(s,l){var c=0,u=0;s.weight&&(c+=s.barycenter*s.weight,u+=s.weight),l.weight&&(c+=l.barycenter*l.weight,u+=l.weight),s.vs=l.vs.concat(s.vs),s.barycenter=c/u,s.weight=u,s.i=Math.min(l.i,s.i),l.merged=!0}return Px}var Dx,m2;function X7(){if(m2)return Dx;m2=1;var e=Pt(),t=or();Dx=n;function n(l,c){var u=t.partition(l,function(b){return e.has(b,"barycenter")}),f=u.lhs,p=e.sortBy(u.rhs,function(b){return-b.i}),h=[],m=0,y=0,v=0;f.sort(s(!!c)),v=r(h,p,v),e.forEach(f,function(b){v+=b.vs.length,h.push(b.vs),m+=b.barycenter*b.weight,y+=b.weight,v=r(h,p,v)});var S={vs:e.flatten(h,!0)};return y&&(S.barycenter=m/y,S.weight=y),S}function r(l,c,u){for(var f;c.length&&(f=e.last(c)).i<=u;)c.pop(),l.push(f.vs),u++;return u}function s(l){return function(c,u){return c.barycenter<u.barycenter?-1:c.barycenter>u.barycenter?1:l?u.i-c.i:c.i-u.i}}return Dx}var Fx,g2;function Z7(){if(g2)return Fx;g2=1;var e=Pt(),t=K7(),n=Y7(),r=X7();Fx=s;function s(u,f,p,h){var m=u.children(f),y=u.node(f),v=y?y.borderLeft:void 0,S=y?y.borderRight:void 0,b={};v&&(m=e.filter(m,function(R){return R!==v&&R!==S}));var _=t(u,m);e.forEach(_,function(R){if(u.children(R.v).length){var I=s(u,R.v,p,h);b[R.v]=I,e.has(I,"barycenter")&&c(R,I)}});var k=n(_,p);l(k,b);var j=r(k,h);if(v&&(j.vs=e.flatten([v,j.vs,S],!0),u.predecessors(v).length)){var E=u.node(u.predecessors(v)[0]),C=u.node(u.predecessors(S)[0]);e.has(j,"barycenter")||(j.barycenter=0,j.weight=0),j.barycenter=(j.barycenter*j.weight+E.order+C.order)/(j.weight+2),j.weight+=2}return j}function l(u,f){e.forEach(u,function(p){p.vs=e.flatten(p.vs.map(function(h){return f[h]?f[h].vs:h}),!0)})}function c(u,f){e.isUndefined(u.barycenter)?(u.barycenter=f.barycenter,u.weight=f.weight):(u.barycenter=(u.barycenter*u.weight+f.barycenter*f.weight)/(u.weight+f.weight),u.weight+=f.weight)}return Fx}var qx,y2;function Q7(){if(y2)return qx;y2=1;var e=Pt(),t=vs().Graph;qx=n;function n(s,l,c){var u=r(s),f=new t({compound:!0}).setGraph({root:u}).setDefaultNodeLabel(function(p){return s.node(p)});return e.forEach(s.nodes(),function(p){var h=s.node(p),m=s.parent(p);(h.rank===l||h.minRank<=l&&l<=h.maxRank)&&(f.setNode(p),f.setParent(p,m||u),e.forEach(s[c](p),function(y){var v=y.v===p?y.w:y.v,S=f.edge(v,p),b=e.isUndefined(S)?0:S.weight;f.setEdge(v,p,{weight:s.edge(y).weight+b})}),e.has(h,"minRank")&&f.setNode(p,{borderLeft:h.borderLeft[l],borderRight:h.borderRight[l]}))}),f}function r(s){for(var l;s.hasNode(l=e.uniqueId("_root")););return l}return qx}var Bx,w2;function J7(){if(w2)return Bx;w2=1;var e=Pt();Bx=t;function t(n,r,s){var l={},c;e.forEach(s,function(u){for(var f=n.parent(u),p,h;f;){if(p=n.parent(f),p?(h=l[p],l[p]=f):(h=c,c=f),h&&h!==f){r.setEdge(h,f);return}f=p}})}return Bx}var zx,v2;function e9(){if(v2)return zx;v2=1;var e=Pt(),t=V7(),n=G7(),r=Z7(),s=Q7(),l=J7(),c=vs().Graph,u=or();zx=f;function f(y){var v=u.maxRank(y),S=p(y,e.range(1,v+1),"inEdges"),b=p(y,e.range(v-1,-1,-1),"outEdges"),_=t(y);m(y,_);for(var k=Number.POSITIVE_INFINITY,j,E=0,C=0;C<4;++E,++C){h(E%2?S:b,E%4>=2),_=u.buildLayerMatrix(y);var R=n(y,_);R<k&&(C=0,j=e.cloneDeep(_),k=R)}m(y,j)}function p(y,v,S){return e.map(v,function(b){return s(y,b,S)})}function h(y,v){var S=new c;e.forEach(y,function(b){var _=b.graph().root,k=r(b,_,S,v);e.forEach(k.vs,function(j,E){b.node(j).order=E}),l(b,S,k.vs)})}function m(y,v){e.forEach(v,function(S){e.forEach(S,function(b,_){y.node(b).order=_})})}return zx}var Ux,x2;function t9(){if(x2)return Ux;x2=1;var e=Pt(),t=vs().Graph,n=or();Ux={positionX:S,findType1Conflicts:r,findType2Conflicts:s,addConflict:c,hasConflict:u,verticalAlignment:f,horizontalCompaction:p,alignCoordinates:y,findSmallestWidthAlignment:m,balance:v};function r(k,j){var E={};function C(R,I){var O=0,H=0,q=R.length,$=e.last(I);return e.forEach(I,function(V,ne){var ee=l(k,V),M=ee?k.node(ee).order:q;(ee||V===$)&&(e.forEach(I.slice(H,ne+1),function(Z){e.forEach(k.predecessors(Z),function(K){var D=k.node(K),P=D.order;(P<O||M<P)&&!(D.dummy&&k.node(Z).dummy)&&c(E,K,Z)})}),H=ne+1,O=M)}),I}return e.reduce(j,C),E}function s(k,j){var E={};function C(I,O,H,q,$){var V;e.forEach(e.range(O,H),function(ne){V=I[ne],k.node(V).dummy&&e.forEach(k.predecessors(V),function(ee){var M=k.node(ee);M.dummy&&(M.order<q||M.order>$)&&c(E,ee,V)})})}function R(I,O){var H=-1,q,$=0;return e.forEach(O,function(V,ne){if(k.node(V).dummy==="border"){var ee=k.predecessors(V);ee.length&&(q=k.node(ee[0]).order,C(O,$,ne,H,q),$=ne,H=q)}C(O,$,O.length,q,I.length)}),O}return e.reduce(j,R),E}function l(k,j){if(k.node(j).dummy)return e.find(k.predecessors(j),function(E){return k.node(E).dummy})}function c(k,j,E){if(j>E){var C=j;j=E,E=C}var R=k[j];R||(k[j]=R={}),R[E]=!0}function u(k,j,E){if(j>E){var C=j;j=E,E=C}return e.has(k[j],E)}function f(k,j,E,C){var R={},I={},O={};return e.forEach(j,function(H){e.forEach(H,function(q,$){R[q]=q,I[q]=q,O[q]=$})}),e.forEach(j,function(H){var q=-1;e.forEach(H,function($){var V=C($);if(V.length){V=e.sortBy(V,function(K){return O[K]});for(var ne=(V.length-1)/2,ee=Math.floor(ne),M=Math.ceil(ne);ee<=M;++ee){var Z=V[ee];I[$]===$&&q<O[Z]&&!u(E,$,Z)&&(I[Z]=$,I[$]=R[$]=R[Z],q=O[Z])}}})}),{root:R,align:I}}function p(k,j,E,C,R){var I={},O=h(k,j,E,R),H=R?"borderLeft":"borderRight";function q(ne,ee){for(var M=O.nodes(),Z=M.pop(),K={};Z;)K[Z]?ne(Z):(K[Z]=!0,M.push(Z),M=M.concat(ee(Z))),Z=M.pop()}function $(ne){I[ne]=O.inEdges(ne).reduce(function(ee,M){return Math.max(ee,I[M.v]+O.edge(M))},0)}function V(ne){var ee=O.outEdges(ne).reduce(function(Z,K){return Math.min(Z,I[K.w]-O.edge(K))},Number.POSITIVE_INFINITY),M=k.node(ne);ee!==Number.POSITIVE_INFINITY&&M.borderType!==H&&(I[ne]=Math.max(I[ne],ee))}return q($,O.predecessors.bind(O)),q(V,O.successors.bind(O)),e.forEach(C,function(ne){I[ne]=I[E[ne]]}),I}function h(k,j,E,C){var R=new t,I=k.graph(),O=b(I.nodesep,I.edgesep,C);return e.forEach(j,function(H){var q;e.forEach(H,function($){var V=E[$];if(R.setNode(V),q){var ne=E[q],ee=R.edge(ne,V);R.setEdge(ne,V,Math.max(O(k,$,q),ee||0))}q=$})}),R}function m(k,j){return e.minBy(e.values(j),function(E){var C=Number.NEGATIVE_INFINITY,R=Number.POSITIVE_INFINITY;return e.forIn(E,function(I,O){var H=_(k,O)/2;C=Math.max(I+H,C),R=Math.min(I-H,R)}),C-R})}function y(k,j){var E=e.values(j),C=e.min(E),R=e.max(E);e.forEach(["u","d"],function(I){e.forEach(["l","r"],function(O){var H=I+O,q=k[H],$;if(q!==j){var V=e.values(q);$=O==="l"?C-e.min(V):R-e.max(V),$&&(k[H]=e.mapValues(q,function(ne){return ne+$}))}})})}function v(k,j){return e.mapValues(k.ul,function(E,C){if(j)return k[j.toLowerCase()][C];var R=e.sortBy(e.map(k,C));return(R[1]+R[2])/2})}function S(k){var j=n.buildLayerMatrix(k),E=e.merge(r(k,j),s(k,j)),C={},R;e.forEach(["u","d"],function(O){R=O==="u"?j:e.values(j).reverse(),e.forEach(["l","r"],function(H){H==="r"&&(R=e.map(R,function(ne){return e.values(ne).reverse()}));var q=(O==="u"?k.predecessors:k.successors).bind(k),$=f(k,R,E,q),V=p(k,R,$.root,$.align,H==="r");H==="r"&&(V=e.mapValues(V,function(ne){return-ne})),C[O+H]=V})});var I=m(k,C);return y(C,I),v(C,k.graph().align)}function b(k,j,E){return function(C,R,I){var O=C.node(R),H=C.node(I),q=0,$;if(q+=O.width/2,e.has(O,"labelpos"))switch(O.labelpos.toLowerCase()){case"l":$=-O.width/2;break;case"r":$=O.width/2;break}if($&&(q+=E?$:-$),$=0,q+=(O.dummy?j:k)/2,q+=(H.dummy?j:k)/2,q+=H.width/2,e.has(H,"labelpos"))switch(H.labelpos.toLowerCase()){case"l":$=H.width/2;break;case"r":$=-H.width/2;break}return $&&(q+=E?$:-$),$=0,q}}function _(k,j){return k.node(j).width}return Ux}var Hx,b2;function n9(){if(b2)return Hx;b2=1;var e=Pt(),t=or(),n=t9().positionX;Hx=r;function r(l){l=t.asNonCompoundGraph(l),s(l),e.forEach(n(l),function(c,u){l.node(u).x=c})}function s(l){var c=t.buildLayerMatrix(l),u=l.graph().ranksep,f=0;e.forEach(c,function(p){var h=e.max(e.map(p,function(m){return l.node(m).height}));e.forEach(p,function(m){l.node(m).y=f+h/2}),f+=h+u})}return Hx}var Wx,k2;function r9(){if(k2)return Wx;k2=1;var e=Pt(),t=D7(),n=F7(),r=B7(),s=or().normalizeRanks,l=z7(),c=or().removeEmptyRanks,u=U7(),f=H7(),p=W7(),h=e9(),m=n9(),y=or(),v=vs().Graph;Wx=S;function S(U,Y){var z=Y&&Y.debugTiming?y.time:y.notime;z("layout",function(){var ie=z(" buildLayoutGraph",function(){return q(U)});z(" runLayout",function(){b(ie,z)}),z(" updateInputGraph",function(){_(U,ie)})})}function b(U,Y){Y(" makeSpaceForEdgeLabels",function(){$(U)}),Y(" removeSelfEdges",function(){B(U)}),Y(" acyclic",function(){t.run(U)}),Y(" nestingGraph.run",function(){u.run(U)}),Y(" rank",function(){r(y.asNonCompoundGraph(U))}),Y(" injectEdgeLabelProxies",function(){V(U)}),Y(" removeEmptyRanks",function(){c(U)}),Y(" nestingGraph.cleanup",function(){u.cleanup(U)}),Y(" normalizeRanks",function(){s(U)}),Y(" assignRankMinMax",function(){ne(U)}),Y(" removeEdgeLabelProxies",function(){ee(U)}),Y(" normalize.run",function(){n.run(U)}),Y(" parentDummyChains",function(){l(U)}),Y(" addBorderSegments",function(){f(U)}),Y(" order",function(){h(U)}),Y(" insertSelfEdges",function(){W(U)}),Y(" adjustCoordinateSystem",function(){p.adjust(U)}),Y(" position",function(){m(U)}),Y(" positionSelfEdges",function(){F(U)}),Y(" removeBorderNodes",function(){P(U)}),Y(" normalize.undo",function(){n.undo(U)}),Y(" fixupEdgeLabelCoords",function(){K(U)}),Y(" undoCoordinateSystem",function(){p.undo(U)}),Y(" translateGraph",function(){M(U)}),Y(" assignNodeIntersects",function(){Z(U)}),Y(" reversePoints",function(){D(U)}),Y(" acyclic.undo",function(){t.undo(U)})}function _(U,Y){e.forEach(U.nodes(),function(z){var ie=U.node(z),le=Y.node(z);ie&&(ie.x=le.x,ie.y=le.y,Y.children(z).length&&(ie.width=le.width,ie.height=le.height))}),e.forEach(U.edges(),function(z){var ie=U.edge(z),le=Y.edge(z);ie.points=le.points,e.has(le,"x")&&(ie.x=le.x,ie.y=le.y)}),U.graph().width=Y.graph().width,U.graph().height=Y.graph().height}var k=["nodesep","edgesep","ranksep","marginx","marginy"],j={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},E=["acyclicer","ranker","rankdir","align"],C=["width","height"],R={width:0,height:0},I=["minlen","weight","width","height","labeloffset"],O={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},H=["labelpos"];function q(U){var Y=new v({multigraph:!0,compound:!0}),z=re(U.graph());return Y.setGraph(e.merge({},j,G(z,k),e.pick(z,E))),e.forEach(U.nodes(),function(ie){var le=re(U.node(ie));Y.setNode(ie,e.defaults(G(le,C),R)),Y.setParent(ie,U.parent(ie))}),e.forEach(U.edges(),function(ie){var le=re(U.edge(ie));Y.setEdge(ie,e.merge({},O,G(le,I),e.pick(le,H)))}),Y}function $(U){var Y=U.graph();Y.ranksep/=2,e.forEach(U.edges(),function(z){var ie=U.edge(z);ie.minlen*=2,ie.labelpos.toLowerCase()!=="c"&&(Y.rankdir==="TB"||Y.rankdir==="BT"?ie.width+=ie.labeloffset:ie.height+=ie.labeloffset)})}function V(U){e.forEach(U.edges(),function(Y){var z=U.edge(Y);if(z.width&&z.height){var ie=U.node(Y.v),le=U.node(Y.w),ge={rank:(le.rank-ie.rank)/2+ie.rank,e:Y};y.addDummyNode(U,"edge-proxy",ge,"_ep")}})}function ne(U){var Y=0;e.forEach(U.nodes(),function(z){var ie=U.node(z);ie.borderTop&&(ie.minRank=U.node(ie.borderTop).rank,ie.maxRank=U.node(ie.borderBottom).rank,Y=e.max(Y,ie.maxRank))}),U.graph().maxRank=Y}function ee(U){e.forEach(U.nodes(),function(Y){var z=U.node(Y);z.dummy==="edge-proxy"&&(U.edge(z.e).labelRank=z.rank,U.removeNode(Y))})}function M(U){var Y=Number.POSITIVE_INFINITY,z=0,ie=Number.POSITIVE_INFINITY,le=0,ge=U.graph(),Ne=ge.marginx||0,Ie=ge.marginy||0;function Ge(Pe){var Be=Pe.x,Te=Pe.y,st=Pe.width,de=Pe.height;Y=Math.min(Y,Be-st/2),z=Math.max(z,Be+st/2),ie=Math.min(ie,Te-de/2),le=Math.max(le,Te+de/2)}e.forEach(U.nodes(),function(Pe){Ge(U.node(Pe))}),e.forEach(U.edges(),function(Pe){var Be=U.edge(Pe);e.has(Be,"x")&&Ge(Be)}),Y-=Ne,ie-=Ie,e.forEach(U.nodes(),function(Pe){var Be=U.node(Pe);Be.x-=Y,Be.y-=ie}),e.forEach(U.edges(),function(Pe){var Be=U.edge(Pe);e.forEach(Be.points,function(Te){Te.x-=Y,Te.y-=ie}),e.has(Be,"x")&&(Be.x-=Y),e.has(Be,"y")&&(Be.y-=ie)}),ge.width=z-Y+Ne,ge.height=le-ie+Ie}function Z(U){e.forEach(U.edges(),function(Y){var z=U.edge(Y),ie=U.node(Y.v),le=U.node(Y.w),ge,Ne;z.points?(ge=z.points[0],Ne=z.points[z.points.length-1]):(z.points=[],ge=le,Ne=ie),z.points.unshift(y.intersectRect(ie,ge)),z.points.push(y.intersectRect(le,Ne))})}function K(U){e.forEach(U.edges(),function(Y){var z=U.edge(Y);if(e.has(z,"x"))switch((z.labelpos==="l"||z.labelpos==="r")&&(z.width-=z.labeloffset),z.labelpos){case"l":z.x-=z.width/2+z.labeloffset;break;case"r":z.x+=z.width/2+z.labeloffset;break}})}function D(U){e.forEach(U.edges(),function(Y){var z=U.edge(Y);z.reversed&&z.points.reverse()})}function P(U){e.forEach(U.nodes(),function(Y){if(U.children(Y).length){var z=U.node(Y),ie=U.node(z.borderTop),le=U.node(z.borderBottom),ge=U.node(e.last(z.borderLeft)),Ne=U.node(e.last(z.borderRight));z.width=Math.abs(Ne.x-ge.x),z.height=Math.abs(le.y-ie.y),z.x=ge.x+z.width/2,z.y=ie.y+z.height/2}}),e.forEach(U.nodes(),function(Y){U.node(Y).dummy==="border"&&U.removeNode(Y)})}function B(U){e.forEach(U.edges(),function(Y){if(Y.v===Y.w){var z=U.node(Y.v);z.selfEdges||(z.selfEdges=[]),z.selfEdges.push({e:Y,label:U.edge(Y)}),U.removeEdge(Y)}})}function W(U){var Y=y.buildLayerMatrix(U);e.forEach(Y,function(z){var ie=0;e.forEach(z,function(le,ge){var Ne=U.node(le);Ne.order=ge+ie,e.forEach(Ne.selfEdges,function(Ie){y.addDummyNode(U,"selfedge",{width:Ie.label.width,height:Ie.label.height,rank:Ne.rank,order:ge+ ++ie,e:Ie.e,label:Ie.label},"_se")}),delete Ne.selfEdges})})}function F(U){e.forEach(U.nodes(),function(Y){var z=U.node(Y);if(z.dummy==="selfedge"){var ie=U.node(z.e.v),le=ie.x+ie.width/2,ge=ie.y,Ne=z.x-le,Ie=ie.height/2;U.setEdge(z.e,z.label),U.removeNode(Y),z.label.points=[{x:le+2*Ne/3,y:ge-Ie},{x:le+5*Ne/6,y:ge-Ie},{x:le+Ne,y:ge},{x:le+5*Ne/6,y:ge+Ie},{x:le+2*Ne/3,y:ge+Ie}],z.label.x=z.x,z.label.y=z.y}})}function G(U,Y){return e.mapValues(e.pick(U,Y),Number)}function re(U){var Y={};return e.forEach(U,function(z,ie){Y[ie.toLowerCase()]=z}),Y}return Wx}var Vx,N2;function s9(){if(N2)return Vx;N2=1;var e=Pt(),t=or(),n=vs().Graph;Vx={debugOrdering:r};function r(s){var l=t.buildLayerMatrix(s),c=new n({compound:!0,multigraph:!0}).setGraph({});return e.forEach(s.nodes(),function(u){c.setNode(u,{label:u}),c.setParent(u,"layer"+s.node(u).rank)}),e.forEach(s.edges(),function(u){c.setEdge(u.v,u.w,{},u.name)}),e.forEach(l,function(u,f){var p="layer"+f;c.setNode(p,{rank:"same"}),e.reduce(u,function(h,m){return c.setEdge(h,m,{style:"invis"}),m})}),c}return Vx}var Gx,S2;function a9(){return S2||(S2=1,Gx="0.8.5"),Gx}var Kx,j2;function o9(){return j2||(j2=1,Kx={graphlib:vs(),layout:r9(),debug:s9(),util:{time:or().time,notime:or().notime},version:a9()}),Kx}var i9=o9();const _2=tb(i9),pi=240,Iu=130,Dl=74,Yf=72,gu=Dl+Yf;function XI(e,t){var r;let n=pi;for(const s of e)n=Math.max(n,((r=t.get(s.id))==null?void 0:r.width)??pi);return n}const of=420,ZI=1;function l9(e,t,n,r){return Math.min(ZI,n/Math.max(1,e),r/Math.max(1,t))}function mi(e){var n;return((n=e.data)==null?void 0:n.sessionId)??"_default"}function c9(e,t){return((t==null?void 0:t.get(e))??0)>0?of:0}function u9(e,t){const n=(t==null?void 0:t.get(e))??0;return n>0?6+n*36:0}function $u(e,t,n){const r=t.get(e);return{w:((r==null?void 0:r.width)??pi)+c9(e,n),h:Math.max((r==null?void 0:r.height)??Iu,u9(e,n))}}function d9(e){return[...e.keys()].sort().map(t=>`${t}:${e.get(t)}`).join("|")}function h9(e,t,n,r,s,l){const c=new _2.graphlib.Graph;c.setDefaultEdgeLabel(()=>({})),c.setGraph({rankdir:n,marginx:0,marginy:0,nodesep:70,ranksep:160,edgesep:30});const u=e.filter(k=>!s.has(k)),f=new Set(u);for(const k of u){const{w:j,h:E}=$u(k,r,l);c.setNode(k,{width:j,height:E})}for(const k of t)f.has(k.source)&&f.has(k.target)&&c.setEdge(k.source,k.target);_2.layout(c);const p=new Map;let h=1/0,m=1/0,y=-1/0,v=-1/0;for(const k of u){const j=c.node(k);if(!j)continue;const E=r.get(k),C=(E==null?void 0:E.width)??pi,R=(E==null?void 0:E.height)??Iu,I=$u(k,r,l),O=j.x-I.w/2,H=j.y-I.h/2;p.set(k,{x:O,y:H}),O<h&&(h=O),H<m&&(m=H),O+C>y&&(y=O+C),H+R>v&&(v=H+R)}if(Number.isFinite(h)&&Number.isFinite(m))for(const[k,j]of p)p.set(k,{x:j.x-h,y:j.y-m});const S=Number.isFinite(y)?y-h:0,b=Number.isFinite(v)?v-m:0;let _=null;for(const k of e){const j=s.get(k);if(!j)continue;const E=r.get(k),C=(E==null?void 0:E.width)??pi,R=(E==null?void 0:E.height)??Iu;_=_===null?{minX:j.x,minY:j.y,maxX:j.x+C,maxY:j.y+R}:{minX:Math.min(_.minX,j.x),minY:Math.min(_.minY,j.y),maxX:Math.max(_.maxX,j.x+C),maxY:Math.max(_.maxY,j.y+R)}}return{positions:p,width:S,height:b,pinnedBox:_}}function QI(e,t,n){const r=n.direction??"LR",s=n.pinned??new Map,l=n.measured??new Map,c=n.lanes,u=new Map;for(const h of e){const m=mi(h),y=u.get(m);y?y.push(h.id):u.set(m,[h.id])}return{laid:Array.from(u.keys()).sort().map(h=>({sid:h,...h9(u.get(h),t,r,l,s,c)})),gap:XI(e,l)}}const JI=e=>e.reduce((t,n)=>Math.max(t,n.width),0)+of,f9=e=>e.reduce((t,n)=>t+n.height,0)+gu*Math.max(0,e.length-1);function B0(e,t,n,r){const s=f=>{const p=[[]];let h=0;for(const m of e)h>0&&h+m.height>f&&(p.push([]),h=0),p[p.length-1].push(m),h+=m.height+gu;return p},l=[];for(let f=0;f<e.length;f++){let p=-gu;for(let h=f;h<e.length;h++)l.push(p+=e[h].height+gu)}l.sort((f,p)=>f-p);const c=f=>{let p=0,h=l.length-1;for(;p<h;){const m=p+h>>1;s(l[m]).length<=f?h=m:p=m+1}return s(l[p])};let u=[e];if(n>0&&r>0){const f=h=>l9(h.reduce((m,y)=>m+JI(y),0)+t*(h.length-1),Math.max(...h.map(f9)),n,r);let p=f(u);for(let h=2;h<=e.length;h++){const m=c(h),y=f(m);y>p+1e-9&&(p=y,u=m)}}return u}function p9(e,t,n,r,s){if(!(r.width>0&&r.height>0&&s.width>0&&s.height>0))return!1;const{laid:l,gap:c}=QI(e,t,n);return l.length<2?!1:B0(l,c,r.width,r.height).length!==B0(l,c,s.width,s.height).length}function m9(e,t,n={}){const r=n.pinned??new Map,{laid:s,gap:l}=QI(e,t,n),c=B0(s,l,n.availableWidth??0,n.availableHeight??0),u=new Map;let f=0;for(const p of c){const h=JI(p);let m=0;for(const{positions:y,height:v,pinnedBox:S}of p){for(const[_,k]of y)u.set(_,{x:k.x+f,y:k.y+m});let b=m+v;S&&S.maxY>b&&S.minX<f+h&&f<S.maxX&&(b=S.maxY),m=b+gu}f+=h+l}return e.map(p=>{const h=r.get(p.id);if(h)return{...p,position:h};const m=u.get(p.id);return m?{...p,position:m}:p})}function g9(e,t,n,r,s){const c=Dl+Yf,u=60,f=v=>$u(v,r,s),p=new Map(e.map(v=>[v.id,mi(v)])),h=[],m=e.map(v=>({id:v.id,pos:n.get(v.id)??t.get(v.id)})).filter(v=>v.pos!=null).sort((v,S)=>v.pos.y-S.pos.y||v.pos.x-S.pos.x||v.id.localeCompare(S.id)),y=[];for(const{id:v,pos:S}of m){const{w:b,h:_}=f(v),k=p.get(v)??"_default";if(n.has(v)){h.push({x:S.x,y:S.y,w:b,h:_,sid:k});continue}let j=S.y;for(let E=0;E<h.length+1;E++){const C=h.find(R=>{const I=R.sid===k?24:u,O=R.sid===k?24:c;return S.x<R.x+R.w+I&&R.x<S.x+b+I&&j<R.y+R.h+O&&R.y<j+_+O});if(!C)break;j=C.y+C.h+(C.sid===k?24:c)}j!==S.y&&(t.set(v,{x:S.x,y:j}),y.push(v)),h.push({x:S.x,y:j,w:b,h:_,sid:k})}return y}function y9(e,t,n,r,s,l,c){const u=E=>$u(E,r,l),f=E=>n.get(E)??t.get(E),p=E=>{const C=r.get(E);return{cw:(C==null?void 0:C.width)??pi,ch:(C==null?void 0:C.height)??Iu}},h=c!=null&&c.width>0&&c.height>0,m=new Map;for(const E of e){if(!f(E.id))continue;const C=mi(E),R=m.get(C);R?R.push(E):m.set(C,[E])}const y=new Set;for(const[E,C]of m)C.every(R=>s.has(R.id)&&!n.has(R.id))&&y.add(E);const v=new Map,S=[];for(const E of e){const C=f(E.id);if(!C)continue;const{w:R,h:I}=u(E.id),O=mi(E);y.has(O)?(v.get(O)??v.set(O,[]).get(O)).push(E):S.push({x:C.x,y:C.y,w:R,h:I,...p(E.id)})}if(v.size===0||h&&S.length===0)return[];const b=Dl+Yf,_=(E,C,R,I)=>S.some(O=>E<O.x+O.w+Dl&&O.x<E+R+Dl&&C<O.y+O.h+b&&O.y<C+I+b),k=XI(e,r),j=[];for(const E of[...v.keys()].sort()){const C=v.get(E);let R=1/0,I=1/0,O=-1/0,H=-1/0,q=-1/0,$=-1/0;for(const D of C){const P=f(D.id),{w:B,h:W}=u(D.id),{cw:F,ch:G}=p(D.id);R=Math.min(R,P.x),I=Math.min(I,P.y),O=Math.max(O,P.x+B),H=Math.max(H,P.y+W),q=Math.max(q,P.x+F),$=Math.max($,P.y+G)}const V=O-R,ne=H-I,ee=[...new Set(S.map(D=>Math.round(D.x)))].sort((D,P)=>D-P),M=ee.length?ee:[R],Z=[0,...S.map(D=>D.y+D.h+b)].sort((D,P)=>D-P);let K=null;if(h){let D=1/0,P=1/0,B=-1/0,W=-1/0;for(const z of S)D=Math.min(D,z.x),P=Math.min(P,z.y),B=Math.max(B,z.x+z.cw),W=Math.max(W,z.y+z.ch);const F=(z,ie)=>{const le=c.width/(Math.max(B,z+q-R)-Math.min(D,z)+of),ge=c.height/(Math.max(W,ie+$-I)-Math.min(P,ie));return[Math.min(ZI,le,ge),Math.min(le,ge),Math.max(le,ge)]},G=(z,ie)=>{for(let le=0;le<z.length;le++){if(z[le]>ie[le]+1e-9)return!0;if(z[le]<ie[le]-1e-9)return!1}return!1},re=Math.round(B+of+k),U=[...new Set([...Z,P])].sort((z,ie)=>z-ie);let Y=null;for(const z of[...M,re])for(const ie of U){if(_(z,ie,V,ne))continue;const le=F(z,ie);(Y===null||G(le,Y))&&(Y=le,K={x:z,y:ie})}K&&K.x===R&&K.y===I&&(K=null)}else e:for(const D of M)for(const P of Z){if(P>=I)break;if(!_(D,P,V,ne)){K={x:D,y:P};break e}}if(K){const D=K.x-R,P=K.y-I;for(const B of C){const W=f(B.id);t.set(B.id,{x:W.x+D,y:W.y+P})}j.push(E)}for(const D of C){const P=f(D.id),{w:B,h:W}=u(D.id);S.push({x:P.x,y:P.y,w:B,h:W,...p(D.id)})}}return j}function w9(e,t,n){const r=new Map;for(const s of e){if(t.has(s.id)||!n(s.id))continue;const l=mi(s);(r.get(l)??r.set(l,[]).get(l)).push(s)}if(r.size===0)return e;for(const s of r.values())s.sort((l,c)=>l.id.localeCompare(c.id));return e.map(s=>{var p;if(t.has(s.id)||n(s.id))return s;const l=r.get(mi(s));if(!l)return s;const c=(p=s.data)==null?void 0:p.parentId,u=l.find(h=>h.id===c)??l[0],f=n(u.id);return{...s,position:{x:s.position.x+f.x-u.position.x,y:s.position.y+f.y-u.position.y}}})}function v9(e,t,n,r,s,l=!1,c){const p=Dl+Yf+1,h=8,m=1.75,y=200,v=.7,S=.01,b=$=>$u($,r,c),_=$=>n.get($)??t.get($),k=new Map;for(const $ of e){if(!_($.id))continue;const V=mi($),ne=k.get(V);ne?ne.push($):k.set(V,[$])}const j=[],E=new Set,C=new Set,R=s.size===0;for(const $ of[...k.keys()].sort()){const V=k.get($);let ne=1/0,ee=1/0,M=-1/0,Z=-1/0,K=!1;for(const W of V){const F=_(W.id),{w:G,h:re}=b(W.id);ne=Math.min(ne,F.x),ee=Math.min(ee,F.y),M=Math.max(M,F.x+G),Z=Math.max(Z,F.y+re),n.has(W.id)&&(K=!0)}const D=M-ne,P=Z-ee;C.add($);const B=s.get($);B&&(D>B.w+h||P>B.h+h)&&E.add($),s.set($,{w:D,h:P}),j.push({sid:$,members:V.map(W=>W.id),x:ne,y:ee,w:D,h:P,anchored:K,mass:1})}for(const $ of[...s.keys()])C.has($)||s.delete($);if(l||R)return[];let I=!1;for(let $=0;$<j.length&&!I;$++)for(let V=$+1;V<j.length;V++){const ne=j[$],ee=j[V];if(!(ne.anchored&&ee.anchored)&&Math.abs(ne.x+ne.w/2-(ee.x+ee.w/2))<(ne.w+ee.w)/2+61&&Math.abs(ne.y+ne.h/2-(ee.y+ee.h/2))<(ne.h+ee.h)/2+p){I=!0;break}}if(E.size===0&&!I)return[];if(E.size>0)for(const $ of j)E.has($.sid)&&($.mass=8);else for(const $ of j)$.mass=Math.max(1,$.w*$.h/(pi*Iu));const O=new Map(j.map($=>[$.sid,$.x])),H=new Map(j.map($=>[$.sid,$.y]));for(let $=0;$<y;$++){const V=new Map,ne=new Map;let ee=0;for(let M=0;M<j.length;M++)for(let Z=M+1;Z<j.length;Z++){const K=j[M],D=j[Z];if(K.anchored&&D.anchored)continue;const P=K.x+K.w/2,B=K.y+K.h/2,W=D.x+D.w/2,F=D.y+D.h/2,G=(K.w+D.w)/2+61-Math.abs(P-W),re=(K.h+D.h)/2+p-Math.abs(B-F);if(G<=0||re<=0)continue;const U=(pe,Ae)=>!pe.anchored&&!(Ae<0&&pe.x<=0),Y=(pe,Ae)=>!pe.anchored&&!(Ae<0&&pe.y<=0),z=(pe,Ae,fe)=>{const Se=pe===Ae,Ye=Se?K.sid<D.sid?-1:1:Math.sign(pe-Ae);return fe(K,Ye)||fe(D,-Ye)?Ye:Se&&(fe(K,-Ye)||fe(D,Ye))?-Ye:0},ie=z(P,W,U),le=z(B,F,Y),ge=ie!==0,Ne=le!==0;if(!ge&&!Ne)continue;const Ie=ge&&(!Ne||G*m<re),[Ge,Pe,Be,Te]=Ie?[ie,G,V,U]:[le,re,ne,Y],st=Te(K,Ge),de=Te(D,-Ge),ue=K.mass,se=D.mass,be=st?de?se/(ue+se):1:0,Le=de?st?ue/(ue+se):1:0,ce=Pe*v;Be.set(K.sid,(Be.get(K.sid)??0)+Ge*ce*be),Be.set(D.sid,(Be.get(D.sid)??0)-Ge*ce*Le),ee+=ce}for(const M of j)M.anchored||(M.x=Math.max(0,M.x+(V.get(M.sid)??0)),M.y=Math.max(0,M.y+(ne.get(M.sid)??0)));if(ee<S)break}const q=[];for(const $ of j){const V=$.x-O.get($.sid),ne=$.y-H.get($.sid);if(!(Math.abs(V)<1&&Math.abs(ne)<1)){for(const ee of $.members){if(n.has(ee))continue;const M=t.get(ee);M&&t.set(ee,{x:M.x+V,y:M.y+ne})}q.push($.sid)}}return q}function Fh(e,t,n){return!t.has(e)||n.has(e)}function x9(e,t,n,r){return!t.has(e)&&Fh(e,n,r)}function b9(e,t,n){const r={x:0,y:0};return t.set(e,r),n.add(e),r}function E2(e,t,n,r){n.set(e,t),r.delete(e)}const k9=200,N9=5*6e4,S9=6,j9=2*6e4;function Sh(e,t){if(t.size!==0)for(const n of Array.from(e.keys()))t.has(n)||e.delete(n)}function _9(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 E9(e){const t=new Set;for(const n of e)t.add(n.id),t.add(`group:${n.sessionId}`),n.kind==="root"&&t.add(_b(n.id));return t}function C9(e){const t=new Set;for(const n of e)t.add(n.id),n.kind==="root"&&t.add(_b(n.id));return t}function T9(e,t){let n=s6(e,t,BN);a6(e,t,BN)&&(n=!0);const r=[],s=l=>{r.push(l)};return e6(e,t,k9,N9,s)&&(n=!0),t6(e,t,S9,j9,s)&&(n=!0),{changed:n,forgotten:r}}const R9=300,C2=130,A9=160,T2=new WeakMap;function M9(e,t){let n=T2.get(e);(!n||n.revision!==e.revision||n.open!==t)&&(n={revision:e.revision,open:t,byId:new Map,branches:pF(e.agents.values())},T2.set(e,n));const{byId:r,branches:s}=n;return l=>{let c=r.get(l.id);if(!c){const u=l.kind==="root"?s.get(l.sessionId):void 0;c=u?{...l,onOpenContext:t,branch:u}:{...l,onOpenContext:t},r.set(l.id,c)}return c}}function z0(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 I9(e,t,n,r,s,l,c,u,f,p,h,m,y,v,S,b,_,k){var ee,M,Z,K;const j=[],E=[],C=M9(e,k);for(const D of e.agents.values()){if(!_.has(D.id))continue;const P=D.exitAt!=null,B=b!=null&&!b.has(D.id),W=[P?"rf-exiting":"",B?"rf-spotlit-out":""].filter(Boolean).join(" ")||void 0,F=l.get(D.id);if(j.push({id:D.id,type:"agent",position:{x:0,y:0},data:C(D),className:W,ariaLabel:sq(D,t,S.has(D.id)),...F?{width:F.width,height:F.height}:null}),D.parentId&&_.has(D.parentId)){const U=Qh(D.sessionId),Y=P,z=S.size>0&&(S.has(D.id)||S.has(D.parentId)),ie=b!=null&&!b.has(D.id)&&!b.has(D.parentId),le=D.state==="active"?2:1.5,ge=z?le+1.5:le,Ne=Y?.2:ie?.12:1,Ie=["sess-edge",D.state==="active"?"sess-live":"sess-idle",Y?"rf-edge-exiting":"",z?"rf-edge-selected":""].filter(Boolean).join(" ");E.push({id:`e:${D.parentId}->${D.id}`,source:D.parentId,target:D.id,animated:(D.state==="active"||z)&&!Y,type:"smoothstep",style:{"--session-hue":U,strokeWidth:`calc(${ge}px * var(--edge-k, 1))`,opacity:Ne,transition:"var(--edge-transition)"},className:Ie})}const G=D.kind==="root"?jf(D):null,re=G?hM(D.sessionId,G.at):null;if(G&&re&&!lF(re)){const U=_b(D.id),Y=Qh(D.sessionId),z=l.get(U);j.push({id:U,type:"recapNote",position:{x:0,y:0},data:{sessionId:D.sessionId,parentId:D.id,recap:G,noteKey:re,hue:Y},className:B?"rf-spotlit-out":void 0,selectable:!1,focusable:!1,ariaLabel:`Claude Code's recap for ${D.label}`,...z?{width:z.width,height:z.height}:null}),E.push({id:`e:recap:${D.id}`,source:U,target:D.id,type:"recapTie",className:"recap-edge",focusable:!1,style:{"--session-hue":Y}})}}const R=z0(e),I=`${y}#lanes:${d9(R)}`,O=new Set(j.filter(D=>D.type==="recapNote").map(D=>D.id));for(const D of Array.from(h.keys()))hF(D)&&!O.has(D)&&!s.has(D)&&(h.delete(D),m.delete(D));const H=j.filter(D=>x9(D.id,s,h,m));if(H.length>0||I!==v.current){if(H.length>0){const D=w9(m9(j,E,{direction:"LR",pinned:s,measured:l,availableWidth:n,availableHeight:r,lanes:R}),s,P=>Fh(P,h,m)?void 0:h.get(P));for(const P of D)Fh(P.id,h,m)&&E2(P.id,P.position,h,m);y9(j,h,s,l,new Set(H.filter(P=>P.type!=="recapNote").map(P=>P.id)),R,{width:n,height:r});for(const P of H){if(P.type!=="recapNote")continue;const B=(ee=P.data)==null?void 0:ee.parentId;if(!B)continue;const W=s.get(B)??(Fh(B,h,m)?void 0:h.get(B));if(!W)continue;const F=((M=l.get(P.id))==null?void 0:M.width)??R9,G=((Z=l.get(P.id))==null?void 0:Z.height)??C2,re=((K=l.get(B))==null?void 0:K.height)??C2;E2(P.id,{x:W.x-A9-F,y:W.y+(re-G)/2},h,m)}}g9(j,h,s,l,R),v.current=I}const q=v9(j,h,s,l,c,!f||p,R);q.length>0&&u(q);const $=C9(e.agents.values());Sh(h,$),Sh(m,$),Sh(s,$),Sh(l,E9(e.agents.values()));const V=[];let ne=!1;for(const D of j){let P=s.get(D.id)??h.get(D.id);P||(P=b9(D.id,h,m),ne=!0),V.push({...D,position:P})}return ne&&(v.current=""),{nodes:V,edges:E}}const $9=1;function O9(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 L9(e,t,n){const r=e.agents.get(t);if(!r)return null;const s=[];for(const l of e.agents.values())l.sessionId===t&&s.push(l);return{schemaVersion:$9,exportedAt:n,sessionId:t,label:r.label,cwd:r.cwd,startedAt:r.startedAt,endedAt:r.endedAt,model:r.model,agents:s.map(l=>({id:l.id,kind:l.kind,label:l.label,parentId:l.parentId,state:l.state,startedAt:l.startedAt,endedAt:l.endedAt,model:l.model,cwd:l.cwd,usage:l.usage,prompts:l.prompts,tools:l.tools.map(O9)}))}}function P9(e,t){const n=(e||"session").replace(/[^a-z0-9._-]/gi,"_");return`${dn}-${n}-${t.slice(0,8)}.json`}function D9(e,t){return e==="confirmation"?t.confirmOpen?"clear":"ignore":t.modalOpen||t.confirmOpen?"ignore":"confirm"}function F9(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 q9(e){return e<=0?null:e===1?"the one agent":`all ${e} agents`}function B9(e,t){const n=q9(e),r=(...c)=>[n?`${n} on the canvas`:null,...c,"layout, pins and selection"].filter(u=>u!==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 c=t.ownerPort===null?"another running deck owns that file":`the deck on port ${t.ownerPort} owns that file`,u=t.decks>2?`, one of ${t.decks} decks sharing it`:"";return{goes:r(),stays:[`the event log — ${c}${u}`,"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 l=t.decks-1;return{goes:r(`the event log ${l===1?"1 other running deck shares":`${l} other running decks share`} with this one — every session recorded in it, not just the ones drawn here`),stays:[l===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 z9({agentCount:e,onConfirm:t,onCancel:n}){const r=w.useRef(null),s=pn(n,{focusRef:r,layer:$6}),[l,c]=w.useState(null);w.useEffect(()=>{let m=!1;return fetch("/api/clear").then(y=>y.ok?y.json():null).then(y=>{m||c(F9(y))}).catch(()=>{}),()=>{m=!0}},[]);const{goes:u,stays:f,final:p,confirm:h}=B9(e,l);return o.jsx("div",{className:"modal-backdrop",onClick:n,role:"presentation",children:o.jsxs("div",{ref:s,className:"modal clear-confirm",onClick:m=>m.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"clear-confirm-title",children:[o.jsxs("header",{className:"modal-head",children:[o.jsxs("div",{className:"modal-title",children:[o.jsx("span",{className:"status-dot err","aria-hidden":!0}),o.jsx("span",{id:"clear-confirm-title",className:"modal-tool-name",children:"Clear the deck?"})]}),o.jsx("div",{className:"modal-actions",children:o.jsx("button",{type:"button",className:"glyph-btn",onClick:n,"aria-label":"Cancel (Esc)",title:"Cancel (Esc)",children:"×"})})]}),o.jsxs("section",{className:"modal-body",children:[o.jsxs("dl",{className:"cc-plan",children:[o.jsx("dt",{children:"Goes"}),o.jsx("dd",{children:u.map(m=>o.jsx("span",{children:m},m))}),o.jsx("dt",{children:"Stays"}),o.jsx("dd",{children:f.length>0?f.map(m=>o.jsx("span",{children:m},m)):o.jsx("span",{children:"nothing"})})]}),p&&o.jsx("p",{className:"cc-final",children:p}),o.jsxs("div",{className:"cc-actions",children:[o.jsx("button",{type:"button",ref:r,className:"btn",onClick:n,children:"Cancel"}),o.jsx("button",{type:"button",className:"btn danger",onClick:t,children:h})]})]})]})})}const U9="Press Esc first if a key does nothing.",H9=[{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 — Undo brings it back",binds:["Delete"]},{cap:"R",action:"re-arrange the canvas and drop the pins",binds:["r","R"]},{cap:"C",action:"clear the canvas and the event log — asks first",binds:["c","C"]}]},{title:"Panels and dialogs",rows:[{cap:"U",action:"usage panel",binds:["u","U"]},{cap:"L",action:"session list",binds:["l","L"]},{cap:"D",action:"detail panel",binds:["d","D"]},{cap:"H",action:"usage history",binds:["h","H"]},{cap:"A",action:"Claude accounts, where Claude Code is installed",binds:["a","A"]},{cap:"S",action:"this machine — cores, memory, temperature",binds:["s","S"]},{cap:"B",action:"Browser Watch",binds:["b","B"]},{cap:"V",action:"the sound menu — volume, tones, notifications",binds:["v","V"]},{cap:"?",action:"this sheet",binds:["?"]}]},{title:"Settings",rows:[{cap:"M",action:"sound on or off",binds:["m","M"]},{cap:"T",action:"light or dark theme",binds:["t","T"]}]},{title:"Focus and selection",rows:[{cap:"Tab",action:"reach the agent cards",binds:[]},{cap:"Enter",action:"select the focused card",binds:["Enter"]},{cap:"Shift + Enter",action:"add the focused card to the selection",binds:["Enter"]},{cap:"Esc",action:"close what is open, deselect, release focus",binds:["Escape"]}]},{title:"Mouse",rows:[{cap:"drag",action:"move a node, and pin it where you dropped it",binds:[]},{cap:"shift-click",action:"add an agent to the selection",binds:[]},{cap:"click",action:"a card: go to it and its session",binds:[]},{cap:"double-click",action:"a card: its prompt, every tool call, tokens and timing",binds:[]},{cap:"hover",action:"zoomed out, a card's name, state and numbers",binds:[]},{cap:"click",action:"the topbar speaker opens volume and sound settings",binds:[]}]}];function W9({onClose:e,onTour:t}){const n=pn(e);return o.jsx("div",{className:"modal-backdrop",onClick:e,role:"presentation",children:o.jsxs("div",{ref:n,className:"modal key-help",onClick:r=>r.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"key-help-title",children:[o.jsxs("header",{className:"modal-head",children:[o.jsx("div",{className:"modal-title",children:o.jsx("span",{id:"key-help-title",className:"modal-tool-name",children:"Keyboard shortcuts"})}),o.jsx("div",{className:"modal-actions",children:o.jsx("button",{type:"button",className:"glyph-btn",onClick:e,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),o.jsxs("section",{className:"modal-body",children:[t&&o.jsxs("div",{className:"guide-door",children:[o.jsx("span",{children:"Eight pictures of what the deck shows."}),o.jsx("button",{type:"button",className:"btn",onClick:t,children:"Take the tour"})]}),o.jsx("div",{className:"shortcuts",children:H9.map(r=>o.jsxs(w.Fragment,{children:[o.jsx("h3",{className:"kh-group",children:r.title}),r.rows.map(s=>o.jsxs("div",{className:"sc",children:[o.jsx("kbd",{children:s.cap}),o.jsx("span",{children:s.action})]},`${r.title}:${s.cap}:${s.action}`))]},r.title))}),o.jsx("p",{className:"kh-foot",children:U9})]})]})})}const V9=1024*1024,R2=5,e$=.8,U0=24,G9="agent-dag.soundCustom.done",K9="agent-dag.soundCustom.needs-input",yu={done:G9,"needs-input":K9};function Ou(e){if(e.kind!=="audio")return e;const{bytes:t,...n}=e;return n}function A2(e){return!e||!/^[a-zA-Z0-9._-]{1,96}$/.test(e)?null:e}function Y9(e){return{done:A2(e(yu.done)),"needs-input":A2(e(yu["needs-input"]))}}function X9(e,t){return{done:e.done===t?null:e.done,"needs-input":e["needs-input"]===t?null:e["needs-input"]}}function Z9(e){return e.done&&e.done===e["needs-input"]?e.done:null}const Q9={wav:"audio/wav",wave:"audio/wav",mp3:"audio/mpeg",ogg:"audio/ogg",oga:"audio/ogg",webm:"audio/webm",m4a:"audio/mp4",mp4:"audio/mp4"},t$=new Set(["audio/wav","audio/x-wav","audio/mpeg","audio/mp3","audio/ogg","audio/webm","audio/mp4"]);function n$(e,t){const n=t.toLowerCase().split(";")[0].trim();if(t$.has(n))return n;const r=e.toLowerCase().split(".").pop()??"";return Q9[r]??n}function M2(e,t){const n=n$(e.name,e.type);if(!t$.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>V9)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>R2)return`Audio must be ${R2} seconds or shorter.`}return null}function H0(e){return e>=U0?`There are already ${U0} custom sounds. Delete one first.`:null}function J9(e,t){const n=e.indexOf(t);return n<0?null:e[n+1]??e[n-1]??null}function eV(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,e$/t)}function r$(){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 tV(e,t,n=r$()){var p;const r=((p=e.name)==null?void 0:p.trim())||"Custom sound",s=M2({name:r,type:e.type,size:e.size});if(s)throw new Error(s);const l=await e.arrayBuffer();let c;try{c=await t(l.slice(0))}catch{throw new Error("The audio file could not be decoded.")}const u=M2({name:r,type:e.type,size:e.size},c.duration);if(u)throw new Error(u);const f=Array.from({length:c.numberOfChannels},(h,m)=>c.getChannelData(m));return{id:n,name:r.replace(/\.(wav|wave|mp3|ogg|oga|webm|m4a|mp4)$/i,"")||"Custom sound",kind:"audio",mime:n$(r,e.type),duration:c.duration,normalizationGain:eV(f),bytes:l}}function nV(e,t=r$()){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,l=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,l))}}const rV="ccdeck-notification-audio",sV=2,ws="assets",Bs="summaries";function Ku(){return typeof window<"u"?window.ccdeckNotificationAudio??null:null}function aV(){return new Promise((e,t)=>{const n=indexedDB.open(rV,sV);n.onupgradeneeded=r=>{const s=n.result,l=s.objectStoreNames.contains(ws)?n.transaction.objectStore(ws):s.createObjectStore(ws,{keyPath:"id"});if(s.objectStoreNames.contains(Bs))return;const c=s.createObjectStore(Bs,{keyPath:"id"});if(r.oldVersion<1)return;const u=l.openCursor();u.onsuccess=()=>{const f=u.result;f&&(c.put(Ou(f.value)),f.continue())}},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error??new Error("Could not open local audio storage."))})}async function Yu(e,t,n){const r=await aV();try{return await new Promise((s,l)=>{const c=r.transaction(e,t),u=n(c),f=()=>l(c.error??new Error("Local audio storage failed."));c.oncomplete=()=>s(u?u.result:void 0),c.onerror=f,c.onabort=f})}finally{r.close()}}async function oV(){const e=Ku();return e?e.list():typeof indexedDB>"u"?[]:await Yu([Bs],"readonly",t=>t.objectStore(Bs).getAll())??[]}async function iV(e){const t=Ku();return t?t.get(e):typeof indexedDB>"u"?null:await Yu([ws],"readonly",n=>n.objectStore(ws).get(e))??null}async function I2(e){const t=Ku();if(t){await t.put(e);return}if(typeof indexedDB>"u")throw new Error("Local audio storage is unavailable in this browser.");await Yu([ws,Bs],"readwrite",n=>{n.objectStore(ws).put(e),n.objectStore(Bs).put(Ou(e))})}async function lV(e,t){const n=Ku();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 Yu([ws,Bs],"readwrite",r=>{const s=r.objectStore(ws),l=s.get(e);l.onsuccess=()=>{const c=l.result;if(!c)return;const u={...c,name:t};s.put(u),r.objectStore(Bs).put(Ou(u))}})}async function cV(e){const t=Ku();if(t){await t.remove(e);return}typeof indexedDB>"u"||await Yu([ws,Bs],"readwrite",n=>{n.objectStore(ws).delete(e),n.objectStore(Bs).delete(e)})}const qh=["done","needs-input"],uV=[{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}]}],dV=[{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}]}],ok={done:uV,"needs-input":dV},wr="two";function W0(e,t){const n=ok[e];return n.find(r=>r.id===t)??n.find(r=>r.id===wr)??n[0]}function s$(e,t){return ok[e].some(r=>r.id===t)?t:wr}W0("done",wr).notes,W0("needs-input",wr).notes;const $2=.04,a$=.24,oi=0,Gl=100,lf=5,gi=50;function Kl(e){if(!Number.isFinite(e))return gi;const t=Math.round(e/lf)*lf;return Math.min(Gl,Math.max(oi,t))}function o$(e){if(e==null)return gi;const t=e.trim();return/^-?\d+(\.\d+)?$/.test(t)?Kl(Number(t)):gi}function V0(e){const t=Kl(e),n=$2+(a$-$2)*(t/Gl);return Math.round(n*1e4)/1e4}function hV(e,t){const n=t.trim,r=typeof n=="number"&&Number.isFinite(n)&&n>0&&n<=1?n:1;return Math.round(V0(e)*r*1e4)/1e4}const fV=160,pV="agent-dag.soundLevel.done",mV="agent-dag.soundLevel.needs-input",gV="agent-dag.soundFigure.done",yV="agent-dag.soundFigure.needs-input",i$={done:pV,"needs-input":mV},Bh={done:gV,"needs-input":yV},G0={done:{level:gi,figure:wr},"needs-input":{level:gi,figure:wr}};function wV(e){const t=n=>({level:o$(e(i$[n])),figure:s$(n,e(Bh[n]))});return{done:t("done"),"needs-input":t("needs-input")}}const O2={Stop:"done",Notification:"needs-input"};function vV(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:Object.hasOwn(O2,n)?O2[n]:null}function xV(e={enabled:()=>!0}){const t=e.ctor??(typeof window<"u"?window.AudioContext??window.webkitAudioContext??null:null);let n=null,r=!1;const s=()=>e.enabled()?r&&(n==null?void 0:n.state)==="running"?"ready":"locked":"off",l=()=>{var m;return(m=e.onState)==null?void 0:m.call(e,s())};function c(){var m;if(!(!t||r))try{n=n??new t,(m=n.resume)==null||m.call(n).then(l,()=>{}),r=!0,l()}catch{}}function u(m,y,v=y.figure){if(!n||n.state!=="running")return!1;const S=W0(m,v),b=hV(y.level,S),_=n.currentTime;for(const k of S.notes){const j=n.createOscillator(),E=n.createGain();j.type=S.type??"sine",j.frequency.value=k.hz;const C=_+k.at,R=C+k.ms/1e3;E.gain.setValueAtTime(1e-4,C),E.gain.exponentialRampToValueAtTime(b,C+.012),E.gain.exponentialRampToValueAtTime(1e-4,R),j.connect(E).connect(n.destination),j.start(C),j.stop(R+.02)}return!0}async function f(m,y){if(!e.loadCustom)return"unavailable";let v;try{v=await e.loadCustom(m)}catch{return"unavailable"}if(!v)return"missing";if(v.kind==="tts"){if(typeof window>"u"||!("speechSynthesis"in window)||typeof SpeechSynthesisUtterance>"u")return"unavailable";const b=new SpeechSynthesisUtterance(v.text),_=window.speechSynthesis.getVoices();b.voice=_.find(k=>k.voiceURI===v.voiceURI)??null,b.rate=v.rate,b.pitch=v.pitch,b.volume=Math.min(1,V0(y.level)/a$);try{return window.speechSynthesis.cancel(),window.speechSynthesis.speak(b),"played"}catch{return"unavailable"}}if(!n||n.state!=="running")return"locked";let S;try{S=await n.decodeAudioData(v.bytes.slice(0))}catch{return"broken"}try{const b=n.createBufferSource(),_=n.createGain();b.buffer=S;const k=v.normalizationGain*(V0(y.level)/e$);return _.gain.setValueAtTime(Math.max(1e-4,k),n.currentTime),b.connect(_).connect(n.destination),b.start(n.currentTime),"played"}catch{return"unavailable"}}function p(m,y=!1){var b,_;if(!y&&!e.enabled())return!1;const v=(((b=e.prefs)==null?void 0:b.call(e))??G0)[m]??G0[m],S=((_=e.customSelection)==null?void 0:_.call(e)[m])??null;return S&&e.loadCustom?(f(S,v).then(k=>{var j;k==="played"||k==="locked"||((k==="missing"||k==="broken")&&((j=e.onCustomFailure)==null||j.call(e,m,S)),u(m,{...v,figure:wr},wr))}),!0):!n||n.state!=="running"?!1:u(m,v)}function h(m,y=gi){return f(m,{level:Kl(y),figure:wr}),!0}return{unlock:c,play:p,previewCustom:h,state:s,get context(){return n}}}const bV="With no deck tab open, get a notification wherever a sound would have played.",kV="With the ccdeck window closed, get a notification wherever a sound would have played.";function NV(e){return e?kV:bV}const SV="Held off for this run — the deck was started with alerts disabled. Your choice is saved for the next start.",L2="Get notified when you're away from this tab.";function jV(e){switch(e){case"granted":return{status:"Enabled",ask:!1,ok:!0,note:L2};case"default":return{status:null,ask:!0,ok:!1,note:L2};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 hu(e=typeof navigator>"u"?"":navigator.userAgent){return/\bccdeck-desktop\/\d/.test(e)}const P2={done:"Turn finished","needs-input":"Claude is asking"},_V={done:"Plays when Claude or Codex finishes a turn.","needs-input":"Available in Claude Code only."};function EV({onClose:e,soundOn:t,onToggleSound:n,prefs:r,onLevel:s,onFigure:l,onPreview:c,openerRef:u,customAssets:f,customSelections:p,onBuiltInSelected:h,onCustomSelected:m,onImportCustom:y,onCreateVoice:v,onRenameCustom:S,onPreviewCustom:b,onDeleteCustom:_,notifyOn:k,onToggleNotify:j,notifyVetoed:E,notifyPermission:C,onAskNotify:R}){var Ae;const I=jV(C),O=hu(),H=k&&!E&&!O,[q,$]=w.useState(""),[V,ne]=w.useState("Custom voice"),[ee,M]=w.useState("Your turn"),[Z,K]=w.useState(""),[D,P]=w.useState("1"),[B,W]=w.useState("1"),[F,G]=w.useState([]),[re,U]=w.useState(!1),Y=w.useRef(null),z=w.useRef(null),ie=Z9(p),le=((Ae=f.find(fe=>fe.id===ie))==null?void 0:Ae.name)??"the same custom sound",ge=f.length,Ne=H0(ge),Ie=Ne!==null,Ge=Ie?{"aria-disabled":!0,"aria-describedby":"sm-custom-full"}:{},[Pe,Be]=w.useState(null),Te=w.useRef(0),st=w.useRef(new Map),de=w.useRef(null);w.useEffect(()=>{if(!Pe)return;const fe=window.setTimeout(()=>Be(null),4e3);return()=>window.clearTimeout(fe)},[Pe]),w.useEffect(()=>{if(typeof window>"u"||!("speechSynthesis"in window))return;const fe=()=>{const Se=window.speechSynthesis.getVoices();G(Se),K(Ye=>{var qe;return Ye||((qe=Se[0])==null?void 0:qe.voiceURI)||""})};return fe(),window.speechSynthesis.addEventListener("voiceschanged",fe),()=>window.speechSynthesis.removeEventListener("voiceschanged",fe)},[]);const ue=async fe=>{$("");try{await fe()}catch(Se){$(Se instanceof Error?Se.message:"Custom audio could not be saved.")}},se=(fe,Se)=>{const Ye=Date.now(),qe=Cu({armedFor:Pe,target:fe,armedAt:Te.current,now:Ye,gapMs:Mu});if(qe==="arm"){Be(fe),Te.current=Ye;return}if(qe==="ignore")return;Be(null);const ke=J9(f.map(Re=>Re.id),fe);ue(async()=>{var ze;await _(fe);const Re=document.activeElement;Re!==Se&&!A0((Re==null?void 0:Re.tagName)??null)||(ze=ke?st.current.get(ke):de.current)==null||ze.focus()})},be=()=>{var fe;z.current!==null&&clearTimeout(z.current),z.current=null,((fe=Y.current)==null?void 0:fe.state)==="recording"&&Y.current.stop()},Le=async()=>{var Se;if(Ie)return;if($(""),!((Se=navigator.mediaDevices)!=null&&Se.getUserMedia)||typeof MediaRecorder>"u"){$("Microphone recording is unavailable in this browser.");return}let fe;try{fe=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{$("Microphone access was denied or unavailable.");return}if(Y.current){fe.getTracks().forEach(Ye=>Ye.stop());return}try{const Ye=["audio/webm;codecs=opus","audio/ogg;codecs=opus","audio/mp4"].find(Re=>MediaRecorder.isTypeSupported(Re)),qe=new MediaRecorder(fe,Ye?{mimeType:Ye}:void 0),ke=[];Y.current=qe,qe.ondataavailable=Re=>{Re.data.size&&ke.push(Re.data)},qe.onerror=()=>$("Recording failed. Please try again."),qe.onstop=()=>{fe.getTracks().forEach(rt=>rt.stop()),z.current!==null&&clearTimeout(z.current),z.current=null;const Re=Y.current===qe;if(Re&&(Y.current=null),U(!1),!Re||!ke.length)return;const ze=qe.mimeType.split(";")[0],Fe=ze==="audio/mp4"?"m4a":ze==="audio/ogg"?"ogg":"webm",We=new File(ke,`Recorded voice.${Fe}`,{type:ze});ue(()=>y(We))},qe.start(200),U(!0),z.current=setTimeout(be,4400)}catch{Y.current=null,fe.getTracks().forEach(Ye=>Ye.stop()),$("This browser cannot record a supported audio format.")}};w.useEffect(()=>()=>{z.current!==null&&clearTimeout(z.current);const fe=Y.current;Y.current=null,(fe==null?void 0:fe.state)==="recording"&&fe.stop()},[]);const ce=pn(e,{popover:!0}),pe=w.useRef(e);return pe.current=e,w.useEffect(()=>{const fe=Se=>{var qe,ke;const Ye=Se.target;Ye&&((qe=ce.current)!=null&&qe.contains(Ye)||(ke=u.current)!=null&&ke.contains(Ye)||pe.current())};return window.addEventListener("pointerdown",fe,!0),()=>window.removeEventListener("pointerdown",fe,!0)},[ce,u]),o.jsxs("div",{ref:ce,id:"sound-menu",className:"sound-menu",role:"dialog","aria-label":"Sound settings",children:[o.jsxs("div",{className:"sm-switches",children:[o.jsxs("label",{className:"sm-switch",children:[o.jsx("span",{className:"sm-switch-label",id:"sm-sound-label",children:"Sounds"}),o.jsx("button",{type:"button",role:"switch","aria-checked":t,"aria-labelledby":"sm-sound-label",className:"switch",onClick:n,title:"A tone when a turn finishes, and when Claude asks for something",children:o.jsx("span",{className:"switch-knob"})})]}),o.jsxs("div",{className:"sm-setting",children:[o.jsxs("label",{className:"sm-switch",children:[o.jsx("span",{className:"sm-switch-label",id:"sm-notify-label",children:"Notifications while closed"}),o.jsx("button",{type:"button",role:"switch","aria-checked":k,"aria-labelledby":"sm-notify-label",className:"switch",onClick:j,title:"With no deck tab open, a notification wherever a sound would play",children:o.jsx("span",{className:"switch-knob"})})]}),o.jsx("p",{className:"sm-note",children:E?SV:NV(O)})]})]}),H&&o.jsxs("section",{className:"sm-channel","aria-labelledby":"sm-channel-name",children:[o.jsxs("div",{className:"sm-channel-head",children:[o.jsx("h3",{className:"sm-channel-name",id:"sm-channel-name",children:"Browser notifications"}),I.ask?o.jsx("button",{type:"button",className:"btn sm-channel-action",onClick:R,children:"Enable"}):o.jsxs("span",{className:"sm-channel-state","data-ok":I.ok||void 0,children:[I.ok&&o.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:o.jsx("path",{d:"M1.5 5.2 3.9 7.6 8.5 2.4"})}),I.status]})]}),o.jsx("p",{className:"sm-note",children:I.note})]}),!t&&o.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."}),o.jsx("div",{className:"sm-tones",children:qh.map(fe=>{const Se=r[fe],Ye=`sm-level-${fe}`,qe=`sm-figure-${fe}`;return o.jsxs("section",{className:"sm-tone","aria-labelledby":`sm-name-${fe}`,children:[o.jsxs("div",{className:"sm-tone-head",children:[o.jsx("h3",{className:"sm-tone-name",id:`sm-name-${fe}`,children:P2[fe]}),o.jsxs("button",{type:"button",className:"btn sm-hear",onClick:()=>c(fe),"aria-label":`Hear the ${P2[fe].toLowerCase()} tone`,title:t?"Play this tone now, at what it is set to":"Plays even when Sounds is off","aria-describedby":t?void 0:"sm-preview-note",children:[o.jsx("svg",{width:"11",height:"11",viewBox:"0 0 12 12",fill:"currentColor","aria-hidden":!0,children:o.jsx("path",{d:"M3 1.6v8.8l7-4.4z"})}),"Hear it"]})]}),o.jsxs("div",{className:"sm-row",children:[o.jsx("label",{htmlFor:Ye,children:"Volume"}),o.jsx("input",{id:Ye,type:"range",min:oi,max:Gl,step:lf,value:Se.level,onChange:ke=>s(fe,Number(ke.target.value)),style:{"--sm-level":`${(Se.level-oi)/(Gl-oi)*100}%`}}),o.jsxs("span",{className:"sm-read",children:[Se.level,"%"]})]}),o.jsxs("div",{className:"sm-row",children:[o.jsx("label",{htmlFor:qe,children:"Tone"}),o.jsxs("select",{id:qe,className:"sm-select",value:p[fe]?`custom:${p[fe]}`:Se.figure,onChange:ke=>{const Re=ke.target.value;Re.startsWith("custom:")?m(fe,Re.slice(7)):(h(fe),l(fe,Re))},children:[ok[fe].map(ke=>o.jsx("option",{value:ke.id,children:ke.label},ke.id)),f.length>0&&o.jsx("optgroup",{label:"Custom",children:f.map(ke=>o.jsx("option",{value:`custom:${ke.id}`,children:ke.name},ke.id))})]})]}),o.jsx("p",{className:"sm-note",children:_V[fe]})]},fe)})}),ie&&o.jsxs("p",{className:"sm-note",role:"status",children:["Both tones use “",le,"”. They may be harder to tell apart."]}),o.jsxs("section",{className:"sm-custom","aria-labelledby":"sm-custom-title",children:[o.jsxs("div",{className:"sm-custom-head",children:[o.jsx("h3",{className:"sm-tone-name",id:"sm-custom-title",children:"Custom sounds"}),o.jsxs("span",{children:[ge," of ",U0,", kept on this machine"]})]}),Ie&&o.jsx("p",{className:"sm-note",id:"sm-custom-full",children:Ne}),o.jsxs("label",{className:"sm-file",children:[o.jsx("span",{children:"Import WAV, MP3 or OGG"}),o.jsx("input",{ref:de,type:"file",accept:"audio/wav,audio/x-wav,audio/mpeg,audio/mp3,audio/ogg,.wav,.mp3,.ogg",...Ge,onClick:fe=>{Ie&&fe.preventDefault()},onChange:fe=>{var Ye;const Se=(Ye=fe.target.files)==null?void 0:Ye[0];fe.currentTarget.value="",Se&&!Ie&&ue(()=>y(Se))}})]}),o.jsxs("div",{className:"sm-record",children:[o.jsx("span",{children:"Record a voice (up to 5 seconds)"}),re?o.jsx("button",{type:"button",className:"btn sm-custom-action",onClick:be,children:"Stop & save"}):o.jsx("button",{type:"button",className:"btn sm-custom-action",...Ge,onClick:()=>void Le(),children:"Record with microphone"})]}),o.jsxs("details",{className:"sm-voice",children:[o.jsx("summary",{...Ge,onClick:fe=>{const Se=fe.currentTarget.parentElement;Ie&&Se&&!Se.open&&fe.preventDefault()},children:"Add spoken voice"}),o.jsxs("div",{className:"sm-voice-fields",children:[o.jsxs("label",{children:["Name",o.jsx("input",{className:"ap-manage-input",value:V,maxLength:80,onChange:fe=>ne(fe.target.value)})]}),o.jsxs("label",{children:["Text",o.jsx("input",{className:"ap-manage-input",value:ee,maxLength:180,onChange:fe=>M(fe.target.value)})]}),o.jsxs("label",{children:["Voice",o.jsxs("select",{className:"sm-select",value:Z,onChange:fe=>K(fe.target.value),children:[o.jsx("option",{value:"",children:"System default"}),F.map(fe=>o.jsx("option",{value:fe.voiceURI,children:fe.name},fe.voiceURI))]})]}),o.jsxs("div",{className:"sm-voice-pair",children:[o.jsxs("label",{children:["Rate",o.jsx("input",{className:"ap-manage-input",type:"number",min:"0.5",max:"2",step:"0.1",value:D,onChange:fe=>P(fe.target.value)})]}),o.jsxs("label",{children:["Pitch",o.jsx("input",{className:"ap-manage-input",type:"number",min:"0.5",max:"2",step:"0.1",value:B,onChange:fe=>W(fe.target.value)})]})]}),o.jsx("button",{type:"button",className:"btn sm-custom-action",...Ge,onClick:()=>{Ie||ue(async()=>{await v({name:V,text:ee,voiceURI:Z,rate:parseFloat(D),pitch:parseFloat(B)}),M("Your turn")})},children:"Add voice"})]})]}),f.length>0&&o.jsx("div",{className:"sm-custom-list",children:f.map(fe=>o.jsxs("div",{className:"sm-custom-item",children:[o.jsx("input",{className:"ap-manage-input","aria-label":`Rename ${fe.name}`,defaultValue:fe.name,maxLength:80,onBlur:Se=>{if(!Se.target.value.trim()){Se.target.value=fe.name;return}ue(()=>S(fe.id,Se.target.value))},onKeyDown:Se=>{Se.key==="Enter"&&Se.currentTarget.blur()}}),o.jsx("span",{children:fe.kind==="audio"?`${fe.duration.toFixed(1)}s`:"Voice"}),o.jsx("button",{type:"button",className:"btn sm-custom-icon","aria-label":`Play ${fe.name}`,onClick:()=>b(fe.id),children:"Play"}),o.jsx("button",{type:"button",ref:Se=>{Se?st.current.set(fe.id,Se):st.current.delete(fe.id)},className:`btn sm-custom-icon${Pe===fe.id?" armed":""}`,onKeyDown:Se=>{Se.repeat&&Se.preventDefault()},onClick:Se=>se(fe.id,Se.currentTarget),"aria-label":Pe===fe.id?`Confirm deleting ${fe.name}`:`Delete ${fe.name}`,title:Pe===fe.id?"Press again to delete this sound. It cannot be brought back.":"Delete this sound",children:Pe===fe.id?"Confirm":"Delete"})]},fe.id))}),q&&o.jsx("p",{className:"sm-custom-error",role:"alert",children:q})]}),o.jsxs("p",{className:"sm-foot",children:[o.jsx("kbd",{children:"M"}),"Mute or unmute sounds anywhere."]})]})}const l$="agent-dag.character-enabled",c$="agent-dag.fm-volume",D2="agent-dag.fm-source",CV=[{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 TV(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 RV(e){return e!=="0"}function AV(){return RV(yr(l$))}function MV(e){return o$(e)}function IV(){return MV(yr(c$))}const F2="agent-dag.fm-custom-stations",q2="agent-dag.fm-muted",K0="custom:",$V=/^UC[A-Za-z0-9_-]{22}$/,OV=/^[A-Za-z0-9_-]{11}$/,ik=/^[A-Za-z0-9_-]{1,80}$/,LV=/\.(mp3|aac|ogg)$/i,PV=/\.m3u8$/i,u$=2048,Lu=80;function yi(e){return`${K0}${e}`}function Yl(e){if(!e.startsWith(K0))return null;const t=e.slice(K0.length);return ik.test(t)?t:null}function B2(e){return Yl(e)??e}function DV(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 lk(e){var c,u;const t=e.trim();if(t.length>u$)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 f=(c=/^\/channel\/([^/]+)(?:\/live)?\/?$/.exec(n.pathname))==null?void 0:c[1];if(f&&$V.test(f))return{kind:"youtube-channel",url:r,channel:f};const p=(u=/^\/@([^/]+)\/live\/?$/.exec(n.pathname))==null?void 0:u[1];if(p&&/^[A-Za-z0-9._-]{1,64}$/.test(p))return{kind:"youtube-handle",url:r,handle:p};if(n.pathname==="/watch"){const h=n.searchParams.get("v")??"";if(OV.test(h))return{kind:"youtube-video",url:r,video:h}}return null}return PV.test(n.pathname)?{kind:"direct-audio",url:r,format:"hls"}:LV.test(n.pathname)?{kind:"direct-audio",url:r,format:"audio"}:null}function FV(e){return e==="1"}function qV(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 l=typeof s.id=="string"?s.id:"",c=typeof s.name=="string"?s.name.trim():"",u=typeof s.url=="string"?s.url.trim():"",f=lk(u);!ik.test(l)||n.has(l)||!c||c.length>Lu||!f||(n.add(l),r.push({id:l,name:c,url:f.url}))}return r}function BV(e,t,n){const r=Yl(e??"");return r&&t.some(s=>s.id===r)?yi(r):n(e)}function zV(e,t){return e===yi(t)?"claude-fm":e}function UV(){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 HV(e,t,n=UV()){const r=e.trim(),s=lk(t);return!r||r.length>Lu||!ik.test(n)||!s?null:{id:n,name:r,url:s.url}}const Sl=["light","dark"],WV={light:"Light",dark:"Dark"},z2=CV,jl="Give the station a name.",VV="Use an https YouTube live or channel link, or a .mp3, .aac, .ogg or .m3u8 stream.";function GV({theme:e}){return o.jsx("span",{className:"appearance-preview","data-swatch":e,children:o.jsxs("svg",{viewBox:"0 0 112 56","aria-hidden":!0,focusable:"false",children:[o.jsx("rect",{className:"tp-canvas",width:"112",height:"56"}),o.jsx("rect",{className:"tp-surface",width:"112",height:"7"}),o.jsx("rect",{className:"tp-rule",y:"7",width:"112",height:"1"}),o.jsx("rect",{className:"tp-surface",y:"8",width:"25",height:"48"}),o.jsx("rect",{className:"tp-rule",x:"25",y:"8",width:"1",height:"48"}),o.jsx("rect",{className:"tp-card",x:"36.5",y:"27.5",width:"28",height:"14",rx:"2.5"}),o.jsx("rect",{className:"tp-tag",x:"39.5",y:"25.5",width:"13",height:"4",rx:"2"}),o.jsx("rect",{className:"tp-card",x:"76.5",y:"14.5",width:"29",height:"20",rx:"2.5"}),o.jsx("rect",{className:"tp-rule",x:"81",y:"23",width:"20",height:"2",rx:"1"}),o.jsx("rect",{className:"tp-accent",x:"81",y:"23",width:"12",height:"2",rx:"1"})]})})}function KV({theme:e,onTheme:t,characterEnabled:n,onToggleCharacter:r,fmVolume:s,onFmVolume:l,fmMuted:c,onFmMuted:u,fmSource:f,onFmSource:p,customFmStations:h,unavailableFmStations:m,onAddFmStation:y,onRenameFmStation:v,onRemoveFmStation:S,onClose:b}){var ue;const _=pn(b),k=[...z2.map(se=>({...se,label:m.has(se.value)?`${se.label} · not live`:se.label,unavailable:m.has(se.value)})),...h.map(se=>({group:"🎵 Your stations",value:yi(se.id),label:m.has(se.id)?`${se.name} · unavailable`:se.name,unavailable:m.has(se.id)}))],j=k.some(se=>se.value===f&&se.unavailable),E=[];k.forEach((se,be)=>{const Le=E[E.length-1];Le&&Le.group===se.group?Le.indexes.push(be):E.push({group:se.group,indexes:[be]})});const[C,R]=w.useState(!1),[I,O]=w.useState(()=>Math.max(0,k.findIndex(se=>se.value===f))),[H,q]=w.useState(!1),[$,V]=w.useState(""),[ne,ee]=w.useState(""),[M,Z]=w.useState(""),[K,D]=w.useState(!1),[P,B]=w.useState(""),[W,F]=w.useState(""),G=w.useRef(null),re=w.useRef(null),U=w.useRef(null),Y=w.useRef(null),z=w.useRef(null),ie=Yl(f),le=ie?h.find(se=>se.id===ie):void 0;w.useEffect(()=>{const se=k.findIndex(be=>be.value===f);O(se<0?0:se)},[f,h,m]),w.useEffect(()=>{D(!1),B((le==null?void 0:le.name)??"")},[le==null?void 0:le.id,le==null?void 0:le.name]),w.useEffect(()=>{var se;C&&((se=document.getElementById(`appearance-fm-option-${I}`))==null||se.scrollIntoView({block:"nearest"}))},[I,C]),w.useEffect(()=>{if(!C)return;const se=be=>{var ce,pe;const Le=be.target;!((ce=G.current)!=null&&ce.contains(Le))&&!((pe=z.current)!=null&&pe.contains(Le))&&R(!1)};return document.addEventListener("pointerdown",se),()=>document.removeEventListener("pointerdown",se)},[C]);const ge=se=>{const be=se.relatedTarget;be&&!se.currentTarget.contains(be)&&R(!1)},Ne=se=>{var Le;const be=k[se];be&&(O(se),p(be.value),R(!1),(Le=G.current)==null||Le.focus())},Ie=se=>{if(L6(se.key)){if(!C)return;se.preventDefault(),se.stopPropagation(),R(!1);return}if(se.key==="Tab"){R(!1);return}if(se.key==="Enter"||se.key===" "){se.preventDefault(),C?Ne(I):R(!0);return}se.key!=="ArrowDown"&&se.key!=="ArrowUp"&&se.key!=="Home"&&se.key!=="End"||(se.preventDefault(),R(!0),O(be=>se.key==="Home"?0:se.key==="End"?k.length-1:Math.min(k.length-1,Math.max(0,be+(se.key==="ArrowDown"?1:-1)))))},Ge=()=>{var se;return(se=G.current)==null?void 0:se.focus()},Pe=se=>{var Le,ce;if(se.preventDefault(),!$.trim()){Z(jl),(Le=re.current)==null||Le.focus();return}const be=HV($,ne);if(!be){Z(VV),(ce=U.current)==null||ce.focus();return}y(be),p(yi(be.id)),V(""),ee(""),Z(""),q(!1),Ge()},Be=se=>{var be;if(se.preventDefault(),!!ie){if(!P.trim()){F(jl),(be=Y.current)==null||be.focus();return}v(ie,P),D(!1),Ge()}},Te=se=>{var ce;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(se.key))return;se.preventDefault();const Le=(Sl.indexOf(e)+(se.key==="ArrowLeft"||se.key==="ArrowUp"?-1:1)+Sl.length)%Sl.length;t(Sl[Le]),(ce=se.currentTarget.querySelectorAll('[role="radio"]')[Le])==null||ce.focus()},st=se=>{var Le;if(se.key===" "){se.stopPropagation();return}if(Sf(se.target)||se.key!=="t"&&se.key!=="T"||se.ctrlKey||se.metaKey||se.altKey)return;se.preventDefault(),se.stopPropagation();const be=e==="dark"?"light":"dark";t(be),se.target.getAttribute("role")==="radio"&&((Le=se.currentTarget.querySelectorAll('[role="radio"]')[Sl.indexOf(be)])==null||Le.focus())},de=se=>{const be=k[se],Le="unavailable"in be&&be.unavailable;return o.jsxs("div",{className:"appearance-source-option",role:"option",id:`appearance-fm-option-${se}`,"aria-selected":f===be.value,"data-highlighted":I===se||void 0,"data-unavailable":Le||void 0,onMouseEnter:()=>O(se),onClick:()=>Ne(se),children:[o.jsx("span",{children:be.label}),f===be.value&&o.jsx("span",{"aria-hidden":!0,children:"✓"})]},be.value)};return Mn.createPortal(o.jsx("div",{className:"modal-backdrop appearance-backdrop",onClick:b,role:"presentation",children:o.jsxs("div",{ref:_,id:"appearance-menu",className:"modal appearance-menu appearance-modal",role:"dialog","aria-modal":"true","aria-labelledby":"appearance-title",onClick:se=>se.stopPropagation(),onKeyDown:st,children:[o.jsxs("div",{className:"appearance-head",children:[o.jsxs("div",{className:"appearance-heading",children:[o.jsx("h2",{id:"appearance-title",className:"appearance-title",children:"Appearance"}),o.jsx("p",{className:"appearance-subtitle",children:"Tune the deck to your workspace."})]}),o.jsx("button",{type:"button",className:"glyph-btn appearance-close",onClick:b,"aria-label":"Close appearance settings",title:"Close (Esc)",children:"×"})]}),o.jsxs("section",{className:"appearance-section","aria-labelledby":"appearance-theme-caption",children:[o.jsxs("div",{className:"appearance-caption",children:[o.jsxs("div",{children:[o.jsx("h3",{id:"appearance-theme-caption",children:"Color theme"}),o.jsx("p",{className:"appearance-section-note",children:"Choose how the dashboard looks."})]}),o.jsx("kbd",{className:"appearance-key","aria-hidden":!0,title:"Press T anywhere to switch themes",children:"T"})]}),o.jsx("div",{className:"appearance-themes",role:"radiogroup","aria-labelledby":"appearance-theme-caption","aria-keyshortcuts":"T",onKeyDown:Te,children:Sl.map(se=>o.jsxs("button",{type:"button",className:"appearance-theme",role:"radio","aria-checked":e===se,tabIndex:e===se?0:-1,onClick:()=>t(se),children:[o.jsx(GV,{theme:se}),o.jsxs("span",{className:"appearance-theme-name",children:[WV[se],o.jsx("svg",{className:"appearance-check",viewBox:"0 0 12 12","aria-hidden":!0,focusable:"false",children:o.jsx("path",{d:"M2.5 6.4 4.9 8.7 9.5 3.6"})})]})]},se))})]}),o.jsxs("section",{className:"appearance-section","aria-labelledby":"appearance-fm-caption",children:[o.jsx("div",{className:"appearance-caption",children:o.jsx("h3",{id:"appearance-fm-caption",children:"Music source"})}),o.jsxs("div",{className:"appearance-controls",children:[o.jsxs("div",{className:"appearance-source-row",children:[o.jsx("label",{htmlFor:"appearance-fm-source",children:"Station"}),o.jsxs("div",{className:`appearance-source-picker${C?" is-open":""}`,onBlur:ge,children:[o.jsxs("button",{ref:G,type:"button",id:"appearance-fm-source",className:"appearance-source-trigger",role:"combobox","aria-haspopup":"listbox","aria-expanded":C,"aria-controls":C?"appearance-fm-source-list":void 0,"aria-activedescendant":C?`appearance-fm-option-${I}`:void 0,"aria-describedby":"appearance-fm-source-note",onClick:()=>R(se=>!se),onKeyDown:Ie,children:[o.jsx("span",{children:((ue=k.find(se=>se.value===f))==null?void 0:ue.label)??z2[0].label}),o.jsx("svg",{viewBox:"0 0 12 12","aria-hidden":!0,focusable:"false",children:o.jsx("path",{d:"m2.5 4.5 3.5 3 3.5-3"})})]}),C&&o.jsx("div",{ref:z,id:"appearance-fm-source-list",className:"appearance-source-list",role:"listbox","aria-label":"Music stations",children:E.map((se,be)=>se.group?o.jsxs("div",{role:"group","aria-labelledby":`appearance-fm-group-${be}`,children:[o.jsx("div",{id:`appearance-fm-group-${be}`,className:"appearance-source-group",role:"presentation",children:se.group}),se.indexes.map(de)]},`group-${be}`):se.indexes.map(de))})]})]}),o.jsx("span",{id:"appearance-fm-source-note",className:"vis-hidden",children:"Changing station starts live playback automatically."}),o.jsx("p",{className:"appearance-fm-status",role:"status",children:j?DV(Yl(f)!==null):""}),o.jsxs("div",{className:"appearance-station-manage",children:[o.jsx("button",{type:"button",className:"btn appearance-station-action","aria-expanded":H,onClick:()=>{q(se=>!se),Z("")},children:H?"Cancel":"+ Add station"}),le&&!K&&o.jsxs("span",{className:"appearance-station-edit",children:[o.jsx("button",{type:"button",className:"btn appearance-station-action",onClick:()=>{B(le.name),F(""),D(!0)},children:"Rename"}),o.jsx("button",{type:"button",className:"btn danger appearance-station-action",onClick:()=>{S(le.id),Ge()},children:"Remove"})]})]}),H&&o.jsxs("form",{className:"appearance-station-form",onSubmit:Pe,noValidate:!0,children:[o.jsxs("label",{className:"appearance-station-field",children:[o.jsx("span",{children:"Station name"}),o.jsx("input",{ref:re,className:"ap-manage-input",value:$,onChange:se=>V(se.target.value),"aria-invalid":M===jl||void 0,"aria-describedby":M===jl?"appearance-station-error":void 0,maxLength:Lu,autoFocus:!0})]}),o.jsxs("label",{className:"appearance-station-field",children:[o.jsx("span",{children:"Link"}),o.jsx("input",{ref:U,className:"ap-manage-input",value:ne,onChange:se=>ee(se.target.value),placeholder:"https://…","aria-invalid":M!==""&&M!==jl||void 0,"aria-describedby":M&&M!==jl?"appearance-station-error":void 0,inputMode:"url",autoComplete:"off",spellCheck:!1,maxLength:u$})]}),o.jsx("button",{type:"submit",className:"btn primary",children:"Add"}),M&&o.jsx("p",{id:"appearance-station-error",className:"appearance-station-error",role:"alert",children:M})]}),le&&K&&o.jsxs("form",{className:"appearance-station-form is-rename",onSubmit:Be,noValidate:!0,children:[o.jsxs("label",{className:"appearance-station-field",children:[o.jsx("span",{children:"Station name"}),o.jsx("input",{ref:Y,className:"ap-manage-input",value:P,onChange:se=>B(se.target.value),"aria-invalid":W!==""||void 0,"aria-describedby":W?"appearance-rename-error":void 0,maxLength:Lu,autoFocus:!0})]}),o.jsx("button",{type:"submit",className:"btn primary",children:"Save"}),o.jsx("button",{type:"button",className:"btn",onClick:()=>{D(!1),Ge()},children:"Cancel"}),W&&o.jsx("p",{id:"appearance-rename-error",className:"appearance-station-error",role:"alert",children:W})]}),o.jsxs("label",{className:"appearance-row",children:[o.jsx("span",{className:"appearance-row-label",id:"appearance-character-label",children:"Show character on minimap"}),o.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":n,"aria-labelledby":"appearance-character-label","aria-describedby":"appearance-character-note",onClick:r,children:o.jsx("span",{className:"switch-knob"})}),o.jsx("span",{id:"appearance-character-note",className:"vis-hidden",children:"Shows the animated minimap character and enables music playback."})]}),o.jsxs("div",{className:"sm-row",children:[o.jsx("label",{htmlFor:"appearance-fm-volume",children:"Volume"}),o.jsx("input",{id:"appearance-fm-volume",type:"range",min:oi,max:Gl,step:lf,value:s,"aria-describedby":"appearance-fm-volume-note",onChange:se=>l(Number(se.target.value)),style:{"--sm-level":`${(s-oi)/(Gl-oi)*100}%`}}),o.jsxs("span",{className:"sm-read",children:[s,"%"]})]}),o.jsxs("label",{className:"appearance-row",children:[o.jsx("span",{className:"appearance-row-label",id:"appearance-fm-mute-label",children:"Mute music"}),o.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":c,"aria-labelledby":"appearance-fm-mute-label",onClick:u,children:o.jsx("span",{className:"switch-knob"})})]})]}),o.jsx("span",{id:"appearance-fm-volume-note",className:"vis-hidden",children:"Controls live music volume."})]})]})}),document.body)}const Y0="https://www.youtube-nocookie.com";function YV(e,t,n){const r=new URLSearchParams({...n?{}:{channel:e},enablejsapi:"1",autoplay:"1",playsinline:"1",rel:"0",modestbranding:"1",origin:t});return`${Y0}/embed/${n?encodeURIComponent(n):"live_stream"}?${r.toString()}`}function _l(e,t=[]){return JSON.stringify({event:"command",func:e,args:t})}function XV(e="claude-fm"){return JSON.stringify({event:"listening",id:e,channel:"widget"})}const ZV=[1,3],QV=[0,2],JV=[2,5,100,101,150];function eG(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:ZV.includes(s)?{kind:"playing",playing:!0}:QV.includes(s)?{kind:"playing",playing:!1}:null}return null}const d$=["......aaaaaa......","....aa......aa....","...a..bbbbbs..a...","...cpcbbbbbscpc...","...cpcbebbescpc...","...cpcbbbbbscpc...","...cpcbbbbbscpc...","....ccbbbbbscc....","....bbbbbbbbbs....","....bbbbbbbbbs....","......bbbbbs......","......bb..bs......","......bb..bs......","......bb..bs......"],U2=18,tG=d$.length,h$=new Set(["a","c","p"]);function Xf(e=d$){const t=[];return e.forEach((n,r)=>{let s=0;for(;s<n.length;){const l=n[s];if(l==="."){s+=1;continue}let c=1;for(;s+c<n.length&&n[s+c]===l;)c+=1;t.push({x:s,y:r,w:c,cell:l}),s+=c}}),t}const ii=148,H2=6e3,nG=16e3,f$=46,eo=34;function rG(e,t,n=ii){let r=-Math.round(t()*n);if(Math.abs(r-e)<eo){const s=e-eo>=-n?-eo:eo;r=Math.max(-n,Math.min(0,Math.round(e+s)))}return{to:r,ms:Math.round(Math.abs(r-e)*f$)}}function sG(e){return Math.round(H2+e()*(nG-H2))}const W2=[{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 aG(e){const t=W2.reduce((r,s)=>r+s.weight,0);let n=e()*t;for(const r of W2)if(n-=r.weight,n<0)return r.kind;return"stroll"}const oG=720,iG=260,lG=620,cG=220,V2=520,p$=1600,G2=7e3,uG=15e3,K2=6e3,dG=14e3;function El(e,t,n=ii){let r=-Math.round(t()*n);if(Math.abs(r-e)<eo){const s=e-eo>=-n?-eo:eo;r=Math.max(-n,Math.min(0,Math.round(e+s)))}return r}const hn=(e,t)=>Math.round(Math.abs(t-e)*f$),hG=120,jh=0;function fG(e,t){const n=r=>({kind:"litter",at:t,...r});return[{x:t,prop:n({}),act:"walk",ms:hn(e,t)},{x:t,prop:n({}),act:"stoop",ms:oG},{x:jh,prop:n({held:!0}),act:"carry",ms:hn(t,jh)},{x:jh,prop:n({held:!0}),act:"windup",ms:iG},{x:jh,prop:n({held:!0,leaving:!0}),act:"toss",ms:lG}]}function pG(e,t){const n=t>e?1:-1,r=t-n*Math.min(15,Math.abs(t-e)),s=(l={})=>({kind:"ball",at:t,...l});return[{x:r,prop:s(),act:"walk",ms:hn(e,r)},{x:r,prop:s(),act:"windup",ms:cG,facing:n>0?"right":"left"},{x:r,prop:s({leaving:!0}),act:"kick",ms:V2,facing:n>0?"right":"left"},{x:r,prop:s({leaving:!0}),act:"stand",ms:p$-V2}]}const m$=640;function mG(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:hn(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:hn(r,0)}]}function gG(e,t,n){const r=Math.max(-110,Math.min(-30,t)),s={x:r,prop:null};return[{...s,act:"walk",ms:hn(e,r)},{...s,act:"skip-ready",ms:500},{...s,act:"skip",ms:m$*(6+Math.floor(n()*5))},{...s,act:"skip-rest",ms:600},{...s,act:"stand",ms:350},{x:0,prop:null,act:"walk",ms:hn(r,0)}]}function yG(e,t,n){return[{x:t,prop:null,act:"walk",ms:hn(e,t)},{x:t,prop:null,act:"sit",ms:Math.round(K2+n()*(dG-K2))},{x:t,prop:null,act:"stand",ms:400}]}function wG(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:hn(e,t)},{x:t,prop:r(),act:"watch",ms:Math.round(G2+n()*(uG-G2))},{x:t,prop:r(),act:"scope-pack",ms:480},{x:t,prop:null,act:"stand",ms:240}]}function Yx(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 vG=1500,xG=e=>Math.round(1e3*Math.sqrt(2*e/vG)),bG=115,kG=e=>Math.round(e/bG*1e3),NG=620,SG=200,jG=760,_G=600,EG=240;function CG(e,t,n){const s=-(t.ledgeSpan??ii),l=xG(t.ledgeH),c=kG(t.ledgeH),u=n(),f=n(),p=-Math.round(u*t.floorSpan),h=-Math.round(f*t.floorSpan);return[{x:s,act:"walk",prop:null,ms:hn(e,s)},{x:s,act:"peer",prop:null,ms:NG},{x:s,act:"fall",prop:null,ms:l,place:"floor"},{x:s,act:"land",prop:null,ms:SG,place:"floor"},{x:p,act:"walk",prop:null,ms:hn(s,p),place:"floor",floorFrac:u},{x:h,act:"walk",prop:null,ms:hn(p,h),place:"floor",floorFrac:f},{x:s,act:"walk",prop:null,ms:hn(h,s),place:"floor"},{x:s,act:"lasso",prop:null,ms:jG,place:"floor"},{x:s,act:"rope-throw",prop:null,ms:_G,place:"floor"},{x:s,act:"rope-catch",prop:null,ms:EG,place:"floor"},{x:s,act:"climb",prop:null,ms:c},{x:s,act:"pull-up",prop:null,ms:480}]}function TG(e,t,n){const r=(n==null?void 0:n.ledgeSpan)??ii;switch(aG(t)){case"tidy":return fG(e,El(e,t,r));case"kick":return pG(e,El(e,t,r));case"sit":return yG(e,El(e,t,r),t);case"watch":return wG(e,El(e,t,r),t);case"fish":return mG(e,El(e,t,r),t);case"skip":return gG(e,El(e,t,r),t);case"leave":{if(!n||!(n.ledgeH>0)||!(n.floorSpan>0))break;return CG(e,n,t)}}const l=rG(e,t,r);return[{x:l.to,prop:null,act:"walk",ms:l.ms}]}const RG=[".xx.","xxxx",".xx."],AG=["..xx..",".xsxx.","xssxxx","xxxxsx",".xxxx.","..xx.."],MG=["...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."],Xx={litter:RG,ball:AG,scope:MG},g$=["bob","sway","groove"],Y2=9e3,IG=16e3,y$=1e3,$G=.08;function OG(e,t){const n=g$.filter(l=>l!==e),r=n[Math.min(n.length-1,Math.floor(t()*n.length))],s=(t()*2-1)*$G;return{dance:r,beatMs:Math.round(y$*(1+s))}}function LG(e){return Math.round(Y2+e()*(IG-Y2))}const PG=["...hhhhhh...","...hhhhhh...","...kkkkkk...","hhhhhhhhhhhh"],DG=3,FG=-1,X0=11,X2=9,qG=420;function BG(e,t,n){const r=t==="right"?n-e-18:e-18;return(t==="right"?1:-1)*Math.min(qG,Math.max(0,r))}const zG=260,UG=200;function HG(e,t,n){const r=(h,m=hn(e,h))=>({x:h,prop:null,act:"walk",ms:m,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 c=t>e,u=c?n.left:n.right,f=c?n.right:n.left,p={place:"floor",riser:n.height,prop:null};return[r(u,hn(e,u)),{...p,x:u,act:"mount",ms:zG},{...p,x:f,act:"walk",ms:hn(u,f)},{x:f,prop:null,act:"dismount",ms:UG,place:"floor"},{x:t,prop:null,act:"walk",ms:hn(f,t),place:"floor"}]}function Z2(e){let t=null,n=null,r=0,s=0,l=!1;const c=()=>{t!==null&&clearTimeout(t),t=null},u=()=>{l||e.hidden||!n||t!==null||(s=performance.now(),t=setTimeout(()=>{t=null;const p=n;n=null,p==null||p()},r))},f=()=>{e.hidden&&t!==null?(r=Math.max(0,r-(performance.now()-s)),c()):e.hidden||u()};return e.addEventListener("visibilitychange",f),{schedule(p,h){l||(c(),n=p,r=Math.max(0,h),u())},dispose(){l=!0,c(),n=null,e.removeEventListener("visibilitychange",f)}}}const WG={"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 VG(e,t){return t&&yi(t.id)===e?t.name:Yl(e)?"Custom FM":WG[e]}const GG={"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 Zx(e,t){var r;const n=((r=e[0])==null?void 0:r.length)??0;return o.jsx("svg",{viewBox:`0 0 ${n} ${e.length}`,shapeRendering:"crispEdges","aria-hidden":!0,children:Xf(e).map(s=>o.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 Qx={e:"fm-eye",s:"fm-shade",p:"fm-pad"},cf=Xf().filter(e=>!h$.has(e.cell)),KG=Xf().filter(e=>h$.has(e.cell)),Q2=cf.filter(e=>e.cell==="e"),YG=Xf(PG),XG=cf.filter(e=>e.y<X0&&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),ZG={left:cf.filter(e=>e.y>=X0&&e.x<X2),right:cf.filter(e=>e.y>=X0&&e.x>=X2)},J2={litter:Zx(Xx.litter,"litter"),ball:Zx(Xx.ball,"ball"),scope:Zx(Xx.scope,"scope")};function QG(e){try{return new URL(e).host}catch{return"the station's server"}}const JG=w.memo(function({fetchImpl:t,volume:n,muted:r=!1,source:s="claude-fm",playRequest:l=0,customStation:c,onAvailabilityChange:u}){const[f,p]=w.useState(null),[h,m]=w.useState(!1),[y,v]=w.useState(!1),[S,b]=w.useState(!1),_=w.useRef(l),k=w.useRef(null),j=w.useRef(null),[E,C]=w.useState(0),[R,I]=w.useState(0),[O,H]=w.useState(null),[q,$]=w.useState(null),[V,ne]=w.useState({x:0,drop:0}),[ee,M]=w.useState("ledge"),[Z,K]=w.useState("left"),[D,P]=w.useState(0),B=w.useRef(null),[W,F]=w.useState(()=>document.hidden);w.useEffect(()=>{const de=new Set,ue=()=>{var se;if(document.hidden){for(const be of((se=B.current)==null?void 0:se.getAnimations({subtree:!0}))??[])if(be.playState==="running"||be.pending){const Le=be.currentTime;be.pause(),Le!==null&&(be.currentTime=Le),de.add(be)}}else{for(const be of de)be.playState==="paused"&&be.play();de.clear()}F(document.hidden)};return ue(),document.addEventListener("visibilitychange",ue),()=>document.removeEventListener("visibilitychange",ue)},[f,h]);const[G,re]=w.useState(null),[U,Y]=w.useState(y$),[z,ie]=w.useState(()=>{var de;return((de=window.matchMedia)==null?void 0:de.call(window,"(prefers-reduced-motion: reduce)").matches)??!1});w.useEffect(()=>{var se;const de=(se=window.matchMedia)==null?void 0:se.call(window,"(prefers-reduced-motion: reduce)");if(!de)return;const ue=()=>ie(de.matches);return ue(),de.addEventListener("change",ue),()=>de.removeEventListener("change",ue)},[]);const le=w.useRef(null),ge=w.useCallback(()=>{var ue;(ue=j.current)==null||ue.destroy(),j.current=null;const de=k.current;de&&(de.pause(),de.removeAttribute("src"),de.load(),k.current=null)},[]),Ne=w.useCallback(de=>{var ue,se;(se=(ue=le.current)==null?void 0:ue.contentWindow)==null||se.postMessage(de,Y0)},[]),Ie=w.useRef(n);Ie.current=n;const Ge=w.useRef(r);Ge.current=r;const Pe=w.useCallback((de,ue,se)=>{ge();const be=new Audio;be.preload="none",be.volume=Ie.current/100,be.muted=Ge.current,k.current=be,v(!0),b(!0);const Le=()=>k.current===be,ce=()=>{ge(),v(!1),b(!1)},pe=()=>{Le()&&(ce(),m(!0),u==null||u(se,!0))},Ae=fe=>{if(Le()){if(fe instanceof DOMException&&fe.name==="NotAllowedError"){ce();return}pe()}};be.addEventListener("playing",()=>{Le()&&(b(!0),u==null||u(se,!1))}),be.addEventListener("ended",()=>{Le()&&ce()}),be.addEventListener("error",pe,{once:!0}),ue&&!be.canPlayType("application/vnd.apple.mpegurl")?nb(async()=>{const{default:fe}=await import("./hls-BFpXDghs.js");return{default:fe}},[]).then(({default:fe})=>{if(!Le())return;if(!fe.isSupported()){pe();return}const Se=new fe;j.current=Se,Se.on(fe.Events.ERROR,(Ye,qe)=>{qe.fatal&&pe()}),Se.on(fe.Events.MEDIA_ATTACHED,()=>Se.loadSource(de)),Se.on(fe.Events.MANIFEST_PARSED,()=>{be.play().catch(Ae)}),Se.attachMedia(be)},pe):(be.src=de,be.play().catch(Ae))},[u,ge]);if(w.useEffect(()=>{y&&(Ne(_l("setVolume",[n])),Ne(_l(r?"mute":"unMute")),k.current&&(k.current.volume=n/100,k.current.muted=r))},[n,r,y,Ne]),w.useEffect(()=>{let de=!0;const ue=t??fetch,se=_.current!==l;_.current=l,p(null),m(!1),v(se),b(se),ge();const be=c&&yi(c.id)===s?lk(c.url):null;if(be)return be.kind==="direct-audio"?(p({live:!0,channel:"",audio:be.url,hls:be.format==="hls"}),u==null||u(s,!1),se&&Pe(be.url,be.format==="hls",s),()=>{de=!1}):(ue(`/api/fm-station?url=${encodeURIComponent(be.url)}`).then(pe=>pe.ok?pe.json():null).then(pe=>{de&&(pe!=null&&pe.channel||pe!=null&&pe.video?(p({live:!0,channel:pe.channel??"",video:pe.video??void 0}),u==null||u(s,!1)):(m(!0),u==null||u(s,!0)))}).catch(()=>{de&&(m(!0),u==null||u(s,!0))}),()=>{de=!1});if(Yl(s))return m(!0),u==null||u(s,!0),()=>{de=!1};const Le=s,ce=GG[Le];if(ce)ue(ce).then(pe=>pe.ok?pe.json():null).then(pe=>{de&&(pe!=null&&pe.video&&p({live:!0,channel:"",video:pe.video}),u==null||u(s,!(pe!=null&&pe.video)))}).catch(()=>{de&&(u==null||u(s,!0))});else if(Le!=="claude-fm"){const pe=Le.replace("lofi-","");ue(`/api/lofi-girl?station=${encodeURIComponent(pe)}`).then(Ae=>Ae.ok?Ae.json():null).then(Ae=>{de&&(Ae!=null&&Ae.video&&p({live:!0,channel:"",video:Ae.video}),u==null||u(s,!(Ae!=null&&Ae.video)))}).catch(()=>{de&&(u==null||u(s,!0))})}else ue("/api/claude-fm").then(pe=>pe.ok?pe.json():null).then(pe=>{if(!de)return;const Ae=!!(pe!=null&&pe.live&&(pe!=null&&pe.channel));Ae&&p({live:!0,channel:pe.channel}),u==null||u(s,!Ae)}).catch(()=>{de&&(u==null||u(s,!0))});return()=>{de=!1}},[c==null?void 0:c.id,c==null?void 0:c.url,t,u,l,s,Pe,ge]),w.useEffect(()=>()=>ge(),[ge]),w.useEffect(()=>{if(!y)return;const de=ue=>{var be;if(ue.origin!==Y0||ue.source!==((be=le.current)==null?void 0:be.contentWindow))return;const se=eG(ue.data);if(se){if(se.kind==="ready"){Ne(_l("setVolume",[Ie.current])),Ne(_l(r?"mute":"unMute")),Ne(_l("playVideo"));return}if(se.kind==="playing"){b(se.playing);return}JV.includes(se.code)&&(v(!1),b(!1),m(!0),u==null||u(s,!0))}};return window.addEventListener("message",de),()=>window.removeEventListener("message",de)},[y,r,u,Ne,s]),w.useEffect(()=>{var ze;if(!f||h||z)return;const de=Z2(document);let ue=0;C(Fe=>ue=Fe);let se=null,be=0,Le=0;const ce=Fe=>{var yt,Ot;const[We,...rt]=Fe;if(!We){se=null,H(null),$(null),qe();return}H(We.act),$(We.prop),M(We.place??"ledge"),P(We.riser??0);const dt=ue,ct=Se(We);if(We.act==="kick"){const zt=(Ot=(yt=B.current)==null?void 0:yt.querySelector('.fm-prop[data-prop="ball"]'))==null?void 0:Ot.getBoundingClientRect();zt&&ne({x:BG(zt.x,Yx(We,dt,"left"),window.innerWidth),drop:Math.max(48,window.innerHeight-zt.y+24)})}Le=We.act==="walk"?Math.max(hn(dt,ct),hG):We.ms,We.act==="carry"&&(Le=hn(dt,ct)),I(Le),K(zt=>Yx({...We,x:ct},dt,zt)),C(ct),ue=ct,se=We,be=Date.now(),de.schedule(()=>ce(rt),Le)},pe=()=>{const Fe=B.current,We=Fe==null?void 0:Fe.querySelector(".fm-sprite"),rt=Fe==null?void 0:Fe.parentElement;if(!Fe||!We||!rt)return null;const dt=Fe.getBoundingClientRect(),ct=rt.getBoundingClientRect(),yt=ct.right-dt.right,Ot=ct.width-yt*2-We.offsetWidth;return Ot>0?Ot:null},Ae=()=>{const Fe=B.current,We=Fe==null?void 0:Fe.querySelector(".fm-walker"),rt=pe();if(!Fe||!We||rt==null)return;const dt=Fe.getBoundingClientRect().bottom-We.getBoundingClientRect().bottom;if(dt>0)return{ledgeH:dt,floorSpan:rt}},fe=()=>{const Fe=B.current,We=document.querySelector(".autofit-chip");if(!Fe||!We)return null;const rt=Fe.getBoundingClientRect(),dt=We.getBoundingClientRect();return dt.width<=0||dt.height<=0?null:{left:dt.left-rt.right,right:dt.right-rt.right,height:dt.height}},Se=Fe=>{const We=(Fe.place??"ledge")==="floor",rt=We?pe()??ii:ii,dt=We&&Fe.floorFrac!=null?-Math.round(Fe.floorFrac*rt):Fe.x;return Math.max(-rt,Math.min(0,dt))},Ye=()=>{if(!se)return;const Fe=Se(se);Fe!==ue&&(I(Math.max(0,be+Le-Date.now())),K(We=>Yx({...se,x:Fe},ue,We)),C(Fe),ue=Fe)},qe=()=>{de.schedule(()=>{const Fe=TG(ue,Math.random,Ae()),We=Fe.some(ct=>ct.place==="floor")?fe():null;let rt=ue;const dt=Fe.flatMap(ct=>{const yt=rt;if(rt=ct.x,!(ct.place==="floor"&&ct.act==="walk"))return[ct];const Ot=HG(yt,ct.x,We),zt=Ot.length-1;return ct.floorFrac==null?Ot:Ot.map((Xt,Dt)=>Dt===zt?{...Xt,floorFrac:ct.floorFrac}:Xt)});ce(dt)},sG(Math.random))},ke=(ze=B.current)==null?void 0:ze.parentElement,Re=typeof ResizeObserver>"u"?null:new ResizeObserver(Ye);return ke&&Re&&Re.observe(ke),qe(),()=>{de.dispose(),Re==null||Re.disconnect(),M("ledge"),C(Fe=>Math.max(-ii,Math.min(0,Fe))),I(0),H(null),$(null),P(0)}},[f,h,z]),w.useEffect(()=>{if(!S||z){re(null);return}const de=Z2(document),ue=se=>{const be=OG(se,Math.random);re(be.dance),Y(be.beatMs),de.schedule(()=>ue(be.dance),LG(Math.random))};return ue(null),()=>de.dispose()},[S,z]),!f||h)return null;const Be=()=>{if(f.audio){if(y){ge(),v(!1),b(!1);return}Pe(f.audio,f.hls===!0,s);return}if(!y){v(!0),b(!0);return}const de=!S;b(de),Ne(_l(de?"playVideo":"pauseVideo")),de||v(!1)},Te=VG(s,c),st=f.audio?QG(f.audio):"YouTube";return o.jsxs("div",{ref:B,className:"fm","data-suspended":W?"":void 0,"data-place":ee,style:{"--fm-beat":`${U}ms`},children:[q&&!q.held&&o.jsx("div",{className:"fm-prop","data-prop":q.kind,"data-leaving":q.leaving?"":void 0,style:{"--fm-prop-x":`${q.at}px`,"--fm-roll-to":`${V.x}px`,"--fm-ball-drop":`${V.drop}px`,"--fm-ball-flight-ms":`${p$}ms`,"--fm-ball-turn":Z==="right"?"1080deg":"-1080deg"},children:J2[q.kind]}),(O==="lasso"||O==="rope-throw"||O==="rope-catch"||O==="climb"||O==="pull-up")&&o.jsxs("div",{className:"fm-rope","data-act":O,style:{"--fm-rope-x":`${E}px`,"--fm-rope-ms":`${R}ms`},children:[o.jsx("div",{className:"fm-rope-line"}),o.jsxs("svg",{className:"fm-rope-hook",viewBox:"0 0 9 9",shapeRendering:"crispEdges","aria-hidden":!0,children:[o.jsx("path",{d:"M4 8V3H3V1H1V3H0V5H2V4H3V6H5V4H6V5H8V3H7V1H5V3H4"}),o.jsx("rect",{className:"fm-rope-knot",x:"3",y:"6",width:"3",height:"2"})]})]}),o.jsxs("div",{className:"fm-walker","data-act":O??void 0,"data-place":ee,"data-facing":Z,style:{"--fm-x":`${E}px`,"--fm-walk-ms":`${R}ms`,"--fm-riser":`${D}px`,"--fm-skip-beat":`${m$}ms`},children:[(q==null?void 0:q.held)&&o.jsx("div",{className:"fm-held","data-prop":q.kind,"data-toss":q.leaving?"":void 0,children:J2[q.kind]}),["cast","fish","reel","stow"].includes(O)&&o.jsxs("svg",{className:"fm-fishing",viewBox:"0 0 24 32",shapeRendering:"crispEdges","aria-hidden":!0,children:[o.jsxs("g",{children:[o.jsx("path",{d:"M24 11H22V9H20V7H18V5H16V3H13V2H8"}),o.jsx("rect",{className:"fm-fishing-grip",x:"21",y:"9",width:"3",height:"3"})]}),o.jsxs("g",{className:"fm-fishing-line",children:[o.jsx("path",{d:"M8 2V26"}),o.jsxs("g",{className:"fm-float",children:[o.jsx("rect",{x:"7",y:"25",width:"3",height:"2"}),o.jsx("rect",{x:"8",y:"24",width:"1",height:"1"})]})]}),o.jsx("path",{className:"fm-ripple",d:"M3 28H6M10 28H14M5 30H12"})]}),["skip-ready","skip","skip-rest"].includes(O)&&o.jsxs("svg",{className:"fm-skipping-rope",viewBox:"0 0 26 26",shapeRendering:"crispEdges","aria-hidden":!0,children:[o.jsx("path",{className:"fm-skip-back",d:"M5 18H3V8H5V5H8V2H18V5H21V8H23V18H21"}),o.jsx("path",{className:"fm-skip-forward",d:"M5 18H3V14H5V11H8V9H18V11H21V14H23V18H21"}),o.jsx("path",{className:"fm-skip-front",d:"M5 18H3V21H5V23H8V25H18V23H21V21H23V18H21"}),o.jsx("path",{className:"fm-skip-return",d:"M5 18H3V19H8V20H18V19H23V18H21"}),o.jsx("path",{className:"fm-skip-handles",d:"M5 17V19M21 17V19"})]}),o.jsx("button",{type:"button",className:"fm-sprite","data-playing":S?"":void 0,"data-dance":S?G??g$[0]:void 0,onClick:Be,title:S?`Stop ${Te}`:`Play ${Te} — streams from ${st}`,"aria-label":S?`Stop ${Te}`:`Play ${Te}`,children:o.jsxs("svg",{viewBox:`0 0 ${U2} ${tG}`,shapeRendering:"crispEdges","aria-hidden":!0,children:[o.jsx("g",{className:"fm-gear",children:o.jsx("g",{className:"fm-gear-motion",children:KG.map(de=>o.jsx("rect",{x:de.x,y:de.y,width:de.w,height:1,className:Qx[de.cell]},`g${de.y}-${de.x}`))})}),o.jsxs("g",{className:"fm-body",children:[Q2.map(de=>o.jsx("rect",{x:de.x,y:de.y,width:de.w,height:1,fill:"var(--accent)"},`eye-bed-${de.x}`)),XG.map(de=>o.jsx("rect",{x:de.x,y:de.y,width:de.w,height:1,className:Qx[de.cell]},`b${de.y}-${de.x}`)),o.jsxs("g",{className:"fm-arms",children:[o.jsx("rect",{x:4,y:8,width:2,height:2}),o.jsx("rect",{x:12,y:8,width:1,height:2}),o.jsx("rect",{x:13,y:8,width:1,height:2,className:"fm-shade"})]}),Q2.map(de=>o.jsx("rect",{x:de.x-(de.x>=U2/2?1:0)+(Z==="right"?1:0),y:de.y,width:de.w,height:1,className:"fm-eye"},`eye-${de.x}`))]}),o.jsx("g",{className:"fm-hat",children:YG.map(de=>o.jsx("rect",{x:DG+de.x,y:FG+de.y,width:de.w,height:1,className:de.cell==="k"?"fm-hatband":void 0},`h${de.y}-${de.x}`))}),(O==="climb"||O==="rope-throw"||O==="rope-catch"||O==="pull-up")&&o.jsxs("g",{className:"fm-grip",children:[o.jsx("path",{className:"fm-grip-left",d:"M5 9H4V4H7V3H9V5H6V9Z"}),o.jsx("path",{className:"fm-grip-right",d:"M12 9H14V6H11V5H9V7H12Z"})]}),(O==="land"||O==="dismount")&&o.jsxs("g",{className:"fm-crouch-legs",children:[o.jsx("path",{d:"M6 11H8V13H6Z"}),o.jsx("path",{d:"M10 11H12V13H10Z"})]}),["sit","cast","fish","reel","stow"].includes(O)&&o.jsxs("g",{className:"fm-seated-legs",children:[o.jsx("path",{className:"fm-seated-far",d:"M10 10H12V11H11V14H8V13H9V11H10Z"}),o.jsx("path",{d:"M6 10H9V11H7V15H4V14H5V11H6Z"})]}),["left","right"].map(de=>o.jsx("g",{className:"fm-leg","data-side":de,children:ZG[de].map(ue=>o.jsx("rect",{x:ue.x,y:ue.y,width:ue.w,height:1,className:Qx[ue.cell]},`${de}${ue.y}-${ue.x}`))},de))]})})]}),y&&!f.audio&&(f.channel||f.video)&&o.jsx("iframe",{ref:le,className:"fm-frame",title:Te,src:YV(f.channel,window.location.origin,f.video),onLoad:()=>Ne(XV()),allow:"autoplay; encrypted-media",sandbox:"allow-scripts allow-same-origin allow-presentation"})]})}),eK=15e3;function tK(e){return e.visibilityState==="visible"&&e.hasFocus()}function nK(e,t){return t||e===!0}function rK(){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)}`}const sK={"//":["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.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.
93
+
94
+ 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.
95
+
96
+ 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.
97
+
98
+ 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.
99
+
100
+ 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.
101
+
102
+ 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".
103
+
104
+ **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.
105
+
106
+ \`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.
107
+
108
+ **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.
109
+
110
+ 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.
111
+
112
+ 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.
113
+
114
+ 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.
115
+
116
+ 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.
117
+
118
+ 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.
119
+
120
+ 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.
121
+
122
+ What you are reading is the first version that does not.
123
+
124
+ 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.
125
+
126
+ 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.
127
+
128
+ 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.
129
+
130
+ 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.
131
+
132
+ 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.
133
+
134
+ The count of what is behind it is on the heading's tooltip, so collapsing it does not hide how much there is.
135
+
136
+ **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.
137
+
138
+ 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.
139
+
140
+ \`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.
141
+
142
+ 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.
143
+
144
+ **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.
145
+
146
+ **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.
147
+
148
+ **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.
149
+
150
+ **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.
151
+
152
+ **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.
153
+
154
+ **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.
155
+
156
+ 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.
157
+
158
+ 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.
159
+
160
+ 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.
161
+
162
+ 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.
163
+
164
+ 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.
165
+
166
+ 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.
167
+
168
+ 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.
169
+
170
+ 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.
171
+
172
+ 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.
173
+
174
+ 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.
175
+
176
+ 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.
177
+
178
+ 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.
179
+
180
+ 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.
181
+
182
+ 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.
183
+
184
+ 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.
185
+
186
+ 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.
187
+
188
+ 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.
189
+
190
+ 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.
191
+
192
+ 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.
193
+
194
+ 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.
195
+
196
+ 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.
197
+
198
+ 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.
199
+
200
+ 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.
201
+
202
+ 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.
203
+
204
+ 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.
205
+
206
+ 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.
207
+
208
+ 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.
209
+
210
+ 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.
211
+
212
+ 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.
213
+
214
+ 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.
215
+
216
+ 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.
217
+
218
+ 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.
219
+
220
+ 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.
221
+
222
+ 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.
223
+
224
+ 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.
225
+
226
+ 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.
227
+
228
+ 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.
229
+
230
+ 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.
231
+
232
+ 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.
233
+
234
+ 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".
235
+
236
+ 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.
237
+
238
+ 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.
239
+
240
+ 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.
241
+
242
+ 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.
243
+
244
+ 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.
245
+
246
+ 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.
247
+
248
+ 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.
249
+
250
+ 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.
251
+
252
+ 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.
253
+
254
+ 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.
255
+
256
+ 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.
257
+
258
+ 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.
259
+
260
+ 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.
261
+
262
+ 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.
263
+
264
+ 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.
265
+
266
+ 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.
267
+
268
+ 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.
269
+
270
+ 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.
271
+
272
+ 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.
273
+
274
+ 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.
275
+
276
+ 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.
277
+
278
+ 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.
279
+
280
+ 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.
281
+
282
+ 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.
283
+
284
+ 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.`}]},ck="agent-dag.releaseNotesSeen";function eR(e){return e.split(/[.\-+]/).map(t=>parseInt(t,10)).map(t=>Number.isNaN(t)?0:t)}function Xl(e,t){const n=eR(e),r=eR(t);for(let s=0;s<Math.max(n.length,r.length);s++){const l=(n[s]??0)-(r[s]??0);if(l!==0)return l<0?-1:1}return 0}function Zl(e){return typeof e=="string"&&/^\d+\.\d+\.\d+/.test(e)}function aK(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 oK(e){if(!e||typeof e!="object")return[];const t=[];for(const[n,r]of Object.entries(e)){if(!Zl(n)||!Array.isArray(r))continue;const s=r.filter(aK);s.length&&t.push({version:n,notes:s})}return t.sort((n,r)=>Xl(r.version,n.version))}const tR=oK(sK);function w$(e,t,n){return e.filter(r=>Xl(r.version,n)<=0&&(t===null||Xl(r.version,t)>0))}function iK(e,t){return e.filter(n=>Xl(n.version,t)===0)}function lK(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 cK({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 c=n.length===1?"one release":`${n.length} releases`;return`You were last caught up at v${e}. Since then ${c} changed something you would notice. Clicking the version in the topbar brings this back.`}if(r&&Zl(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(!Zl(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 l=Xl(s,t);return l<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.`:l>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 uK=new RegExp("^(?:\\p{Extended_Pictographic}|\\p{Emoji_Modifier}|\\p{Regional_Indicator}|[\\u200D\\uFE0F])+(?= \\S)","u");function dK(e){const t=uK.exec(e);return t?{icon:t[0],rest:e.slice(t[0].length)}:{icon:null,rest:e}}function nR(){if(typeof window>"u")return null;try{return window.localStorage}catch{return null}}function hK(e){if(!e)return null;let t=null;try{t=e.getItem(ck)}catch{return null}return Zl(t)?t:null}function fK(e){if(!e)return!1;try{return e.getItem(ck),!0}catch{return!1}}function pK(e,t){if(!e)return!1;try{return e.setItem(ck,t),!0}catch{return!1}}const v$="agent-dag.tourSeen";function mK(e){if(!e)return!1;try{return e.getItem(v$)==="1"}catch{return!1}}function gK(e){if(!e)return!1;try{return e.setItem(v$,"1"),!0}catch{return!1}}function yK({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 wK({stored:e,running:t,notes:n,remembers:r=!0}){if(!Zl(t))return{show:[],record:null,reason:"no-version"};if(!Zl(e)){if(!r)return{show:[],record:t,reason:"cannot-remember"};const c=iK(n,t);return c.length?{show:c,record:t,reason:"welcome"}:{show:[],record:t,reason:"first-run"}}const s=Xl(e,t);if(s===0)return{show:[],record:null,reason:"seen"};if(s>0)return{show:[],record:null,reason:"ahead"};const l=w$(n,e,t);return l.length?{show:l,record:t,reason:"new-notes"}:{show:[],record:t,reason:"nothing-new"}}function vK(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 x$(e,t=!0){const n=[];let r="";const s=()=>{r&&(n.push({kind:"text",text:r}),r="")};let l=0;for(;l<e.length;){if(e[l]==="`"){const c=e.indexOf("`",l+1);if(c>l+1){s(),n.push({kind:"code",text:e.slice(l+1,c)}),l=c+1;continue}}else if(t&&e.startsWith("**",l)){const c=vK(e,l);if(c>0){s(),n.push({kind:"bold",kids:x$(e.slice(l+2,c),!1)}),l=c+2;continue}}r+=e[l],l+=1}return s(),n}const xK=new Set(["idle","checking","current","downloading","ready","error"]);function rR(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.status!="string"||!xK.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 bK(e){return(e==null?void 0:e.status)==="ready"&&e.version?{version:e.version}:null}function kK(e=typeof navigator>"u"?"":navigator.userAgent){var t;return((t=/\bccdeck-desktop\/(\d[^\s]*)/.exec(e))==null?void 0:t[1])??null}const uf="Restart to update",b$=3e4;function NK(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 SK(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 ${uf} comes first`}}function jK(e){const t=e==null?void 0:e.reason;return t==="app_disconnected"||t==="update_not_ready"?t:"refused"}function _K(e,t,n=typeof navigator>"u"?"":navigator.userAgent){const r=NK(n),s=`Use ${uf} 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, ${uf} is in ${r}.`;case"timeout":return`ccdeck has not restarted after ${b$/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}`}}function EK({entries:e,since:t,running:n,firstRun:r,onClose:s,onTour:l,updateVersion:c,updateBusy:u,onUpdateRestart:f,updateFailure:p,onRestart:h}){const m=pn(s),y=lK(e);return o.jsx("div",{className:"modal-backdrop",onClick:s,role:"presentation",children:o.jsxs("div",{ref:m,className:"modal release-notes",onClick:v=>v.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"release-notes-title",children:[o.jsxs("header",{className:"modal-head",children:[o.jsxs("div",{className:"modal-title",children:[o.jsx("span",{id:"release-notes-title",className:"modal-tool-name",children:"What's new"}),y&&o.jsx("span",{className:"modal-tool-id",children:y})]}),o.jsx("div",{className:"modal-actions",children:o.jsx("button",{type:"button",className:"glyph-btn",onClick:s,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),o.jsxs("section",{className:"modal-body",children:[(c||p)&&o.jsxs("div",{className:"rn-update",children:[c&&f&&o.jsxs("div",{className:"guide-door",children:[o.jsxs("span",{children:["ccdeck v",c," is downloaded and verified."]}),o.jsx("button",{type:"button",className:"btn",onClick:f,"aria-busy":u||void 0,children:u?"Restarting…":uf})]}),o.jsx("p",{className:"rn-update-said",role:"status",children:p})]}),o.jsx("p",{className:"modal-note",children:cK({since:t,running:n,firstRun:r,entries:e})}),l&&!c&&o.jsxs("div",{className:"guide-door",children:[o.jsx("span",{children:"Eight pictures of what the deck shows."}),o.jsx("button",{type:"button",className:"btn",onClick:l,children:"Take the tour"})]}),h&&o.jsxs("div",{className:"guide-door",children:[o.jsx("span",{children:"Restart the deck. Sessions, settings and pairings come back as they were."}),o.jsx("button",{type:"button",className:"btn",onClick:h,children:"Restart"})]}),e.map(v=>o.jsxs("section",{className:"modal-section",children:[o.jsxs("h3",{className:"rn-version",children:["v",v.version]}),o.jsx("ul",{className:"rn-notes",children:v.notes.map((S,b)=>{const{icon:_,rest:k}=dK(S.title);return o.jsxs("li",{className:"rn-note",children:[o.jsxs("p",{className:"rn-note-title",children:[_&&o.jsx("span",{className:"rn-note-icon",children:_}),k]}),o.jsx("p",{className:"rn-note-body",children:k$(x$(S.body))})]},b)})})]},v.version))]})]})})}function k$(e){return e.map((t,n)=>t.kind==="text"?t.text:t.kind==="code"?o.jsx("code",{className:"rn-code",children:t.text},n):o.jsx("strong",{className:"rn-strong",children:k$(t.kids)},n))}function CK(e){return e.slice().sort((t,n)=>t.y-n.y||t.x-n.x)}function TK(e,t,n){var c;if(e.length===0)return null;const r=CK(e),s=t?r.findIndex(u=>u.id===t):-1,l=s===-1?n===1?0:r.length-1:(s+n+r.length)%r.length;return((c=r[l])==null?void 0:c.id)??null}const RK=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Escape","Delete","Backspace"]);function AK(e,t){return t==null?{kind:"deck",nodeId:null}:e.key==="Enter"||e.key===" "?{kind:"activate",nodeId:t,additive:e.shiftKey}:RK.has(e.key)?{kind:"node",nodeId:t}:{kind:"deck",nodeId:t}}const MK=new Set(["","BODY","HTML","#DOCUMENT"]);function IK(e){return!e||Sf(e)?!1:!MK.has(String(e.tagName??"").toUpperCase())}const uk="agent-dag.removedNodes";function $K(e){try{const t=JSON.parse((e==null?void 0:e.getItem(uk))??"[]");return new Set(Array.isArray(t)?t.filter(n=>typeof n=="string"):[])}catch{return new Set}}function sR(e,t){try{e==null||e.setItem(uk,JSON.stringify([...t]))}catch{}}function N$(e,t){const n=new Map(e.map(l=>[l.id,l.parentId])),r=new Set(t),s=l=>{if(r.has(l))return!0;const c=new Set([l]);let u=n.get(l);for(;u&&!c.has(u);){if(r.has(u))return r.add(l),!0;c.add(u),u=n.get(u)}return!1};return l=>s(l.id)||s(l.sessionId??l.id)}function OK(e,t){if(t.size===0)return new Set;const n=[...e],r=N$(n,t);return new Set(n.filter(r).map(s=>s.id))}function LK(e,t,n){const r=u=>({id:u.id,parentId:u.data.parentId,sessionId:u.data.sessionId}),s=N$(e.map(r),n),l=e.filter(u=>!s(r(u))),c=new Set(l.map(u=>u.id));return{nodes:l,edges:t.filter(u=>c.has(u.source)&&c.has(u.target))}}function PK(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 DK(e,t){return t.size===0?[]:[...e].filter(n=>t.has(n.id)).map(n=>n.id)}const FK=16,qK=120;function BK(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 zK(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 UK(e,t){return BK(e,t,FK)?"over":zK(e,t)<=qK?"near":"far"}function HK(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 WK(e,t){if(!t||!e.agents.get(t))return null;const r=new Set([t]);let s=t;for(;s;){const c=e.agents.get(s);if(!(c!=null&&c.parentId)||r.has(c.parentId))break;r.add(c.parentId),s=c.parentId}let l=!0;for(;l;){l=!1;for(const c of e.agents.values())c.parentId&&r.has(c.parentId)&&!r.has(c.id)&&(r.add(c.id),l=!0)}return r}function VK(e,t){const n=new Set;for(const r of t){const s=WK(e,r);if(s)for(const l of s)n.add(l)}return n.size>0?n:null}const GK=40,KK=120;function YK(e,t){let n=null,r=0,s=Number.NEGATIVE_INFINITY;const l=()=>{n=null,s=t.now(),e()},c=()=>{n!=null&&(t.clearTimeout(n),n=null)},u=(f,p,h)=>{if(n!=null){if(r<=f)return;c()}const m=Math.min(h,Math.max(0,f-p));r=f,n=t.setTimeout(l,m)};return{live(f=GK){const p=t.now(),h=Math.max(s+f,p);if(h<=p){c(),l();return}u(h,p,f)},replay(f=KK){c(),r=t.now()+f,n=t.setTimeout(l,f)},flush(){c(),l()},cancel(){c()}}}const XK=1e3;function ZK(e={}){const t=Math.max(1,Math.floor(e.limit??XK)),n=e.protect;let r=!1,s=[],l=new Set,c=0,u=0,f=null;return{get paused(){return r},get size(){return s.length},get dropped(){return c},get overflowed(){return c>0},get through(){return u},accept(p){const h=typeof(p==null?void 0:p.seq)=="number"?p.seq:null,m=(p==null?void 0:p.epoch)??null,y=m!==null&&m!==f;y&&(f=m,u=0);const v=h!==null&&!y&&h<=u;if(h!==null&&h>u&&(u=h),!r)return!0;if(v)return!1;if(s.push(p),n!=null&&n(p)&&l.add(p),s.length>t){let S=0;if(l.size<s.length)for(;l.has(s[S]);)S++;const[b]=s.splice(S,1);l.delete(b),c++}return!1},setPaused(p){if(r=p,p)return[];const h=s;return s=[],l=new Set,c=0,h}}}const S$="agent-dag.theme";function QK(e,t=!1){return e==="light"||e==="dark"?e:t?"light":"dark"}function JK(){try{return window.matchMedia("(prefers-color-scheme: light)").matches}catch{return!1}}function eY(){return QK(yr(S$),JK())}const tY=6,nY="ccdeck-tabs";function rY(e){return e>=tY}function sY(e,t,n){const r=s=>{const l=s.data;(l==null?void 0:l.kind)==="who"&&l.from!==t&&e.postMessage({kind:"here",from:t,to:l.from,streaming:n()})};return e.addEventListener("message",r),{ask(s,l=(c,u)=>setTimeout(c,u)){return new Promise(c=>{const u=new Set,f=p=>{const h=p.data;(h==null?void 0:h.kind)==="here"&&h.to===t&&h.streaming&&u.add(h.from)};e.addEventListener("message",f),e.postMessage({kind:"who",from:t}),l(()=>{e.removeEventListener("message",f),c(u.size)},s)})},leave(){var s;e.removeEventListener("message",r),(s=e.close)==null||s.call(e)}}}function aY({waiting:e,running:t,connected:n=!0}){return{title:e>0?`(${e}) ${dn}`:dn,icon:n?e>0?"waiting":t>0?"running":"idle":"offline"}}const _h={offline:"#e05252",waiting:"#c97d12",running:"#2a90d4",idle:"#7e828c"};function Eh(e,t){const s=c=>`<circle cx="16" cy="16" r="12" fill="none" stroke="${e}" stroke-width="5"${c}/>`;return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32">${t==="waiting"?`<circle cx="16" cy="16" r="14.5" fill="${e}"/>`:t==="offline"?s(` stroke-dasharray="${56.5485.toFixed(2)} ${18.8495.toFixed(2)}" transform="rotate(-58 16 16)"`):s("")+(t==="running"?`<circle cx="16" cy="16" r="5" fill="${e}"/>`:"")}</svg>`}const oY=Object.freeze({offline:`data:image/svg+xml,${encodeURIComponent(Eh(_h.offline,"offline"))}`,waiting:`data:image/svg+xml,${encodeURIComponent(Eh(_h.waiting,"waiting"))}`,running:`data:image/svg+xml,${encodeURIComponent(Eh(_h.running,"running"))}`,idle:`data:image/svg+xml,${encodeURIComponent(Eh(_h.idle,"idle"))}`}),iY="No sessions are waiting for you.";function lY(e){if(e.length===0)return"";const[t,...n]=e;if(n.length===0)return`${t.label} is waiting for your permission.`;const r=`${n.length} more session${n.length===1?"":"s"}`;return`${t.label} and ${r} are waiting for your permission.`}function aR(e,t,n=iY){return t!==""?t:e===""?"":n}const oR="agent-dag.browserWatch.seenMs";function cY(e,t){return e.filter(n=>n.startMs>t)}function uY(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,l)=>(s.at??0)-(l.at??0));return{request:r[0],waiting:r.length-1}}function dY({request:e,waiting:t,busy:n,now:r,onAccept:s,onDecline:l,onLater:c}){const u=w.useRef(null),f=pn(c,{focusRef:u}),p=ao(n,"accept"),h=ao(n,"dismiss");return o.jsx("div",{className:"modal-backdrop",onClick:c,role:"presentation",children:o.jsxs("div",{ref:f,className:"modal lan-ask",onClick:m=>m.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-ask-title",children:[o.jsxs("header",{className:"modal-head",children:[o.jsxs("div",{className:"modal-title",children:[o.jsx("i",{className:"ap-pulse","aria-hidden":!0}),o.jsx("span",{id:"lan-ask-title",className:"modal-tool-name",children:"A deck wants to pair"})]}),o.jsx("div",{className:"modal-actions",children:o.jsx("button",{type:"button",className:"glyph-btn",onClick:c,"aria-label":"Answer later (Esc)",title:"Answer later (Esc)",children:"×"})})]}),o.jsxs("section",{className:"modal-body",children:[o.jsxs("p",{className:"lan-ask-who",children:[o.jsx("strong",{className:"lan-ask-name",children:e.name})," at ",o.jsx("code",{className:"ap-lan-code",children:e.addr})," · asked ",Bb(e.at,r)]}),o.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."}),o.jsxs("p",{className:"lan-ask-fp",children:["Its fingerprint is ",o.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&&o.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.`}),o.jsxs("div",{className:"lan-ask-acts",children:[o.jsx("button",{type:"button",ref:u,className:"btn",disabled:h.disabled,"aria-busy":h.busy,onClick:l,title:"Nothing is shared. If that deck asks again, this comes back.",children:n==="dismiss"?"declining…":"Decline"}),o.jsx("button",{type:"button",className:"btn primary",disabled:p.disabled,"aria-busy":p.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"})]})]})]})})}const hY=600;function Z0(e,t){return!(e.exitAt!=null&&t-e.exitAt>hY||e.kind==="root"&&e.state==="done"&&e.tools.length===0&&e.endedAt!=null&&e.endedAt-e.startedAt<3e3)}function fY(e,t){const n=new Set;for(const r of e.agents.values())Z0(r,t)&&n.add(r.id);return n}function pY(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 mY(e,t,n=0){if(!e)return!1;for(const r of t)if(pY(e,r,n))return!0;return!1}const j$="sessionGroup";function gY(e,t){var r,s;if(e.type===j$)return"transparent";if(Fr((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 _$=["--err","--inflight","--ok","--grid-line","--minimap-mask","--panel","--line","--accent","--text-dim","--bg"];function iR(e){const t={};for(const n of _$)t[n]=e(n);return t}function yY(e){return t=>e[t]??""}function wY(e,t){return _$.every(n=>e[n]===t[n])}function vY(e){const t=new Set(e.pins),n=new Map,r=new Map;for(const[s,l]of e.positions)n.set(s,l),t.has(s)&&r.set(s,l);return{positions:n,pinned:r}}function lR(e){return Object.entries(e??{}).filter(([,t])=>t&&typeof t.x=="number"&&typeof t.y=="number")}function xY(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=lR(n);return{positions:s,pins:s.map(([l])=>l)}}const r=n;return{positions:lR(r.positions),pins:Array.isArray(r.pins)?r.pins:[]}}function bY(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 kY(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 E$=.2,C$=1.6;function NY(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<E$||s>C$?null:{x:n,y:r,zoom:s}}const SY=1200,jY=1e3;function Jx(e){return e.lastDeckFitAt>0&&e.at-e.lastDeckFitAt<SY?!1:e.hasSourceEvent?!0:e.lastCanvasInputAt>0&&e.at-e.lastCanvasInputAt<jY}function Ch({durationMs:e,documentHidden:t,reducedMotion:n=_Y()}){return t||n?!1:Number.isFinite(e)&&e>0}function _Y(){return typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches}function EY(e,t,n){const r=e.x*t.zoom+t.x,s=e.y*t.zoom+t.y,l=(e.x+e.width)*t.zoom+t.x,c=(e.y+e.height)*t.zoom+t.y;return l>0&&r<n.width&&c>0&&s<n.height}function CY({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,EY(s,t,e))return!1;return r}const dk=11,T$=7.2,R$=6.6,TY={width:104,height:48},cR={width:96,height:44},A$={width:220,height:103};function RY(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)?A$:{width:Math.max(160,t),height:Math.max(72,n)}}function e0(e,t,n){return e.width*t>=n.width&&e.height*t>=n.height}function AY(e,t,n=A$){if(!Number.isFinite(t)||t<=0)return e??"detail";const r=dk*t;return e==="detail"?r>=R$?"detail":e0(n,t,cR)?"compact":"overview":r>=T$?"detail":e==="compact"?e0(n,t,cR)?"compact":"overview":e0(n,t,TY)?"compact":"overview"}const MY=T$/dk,IY=R$/dk;function $Y(e,t){return e>=MY?e:Math.max(e,Math.min(t,IY-.001))}const OY=.8,LY=1;function PY(e){const t=e.minZoom??OY,n=e.maxZoom??LY,r=e.fill??.9,s=e.insets.left,l=e.insets.top,c=Math.max(1,e.pane.width-e.insets.left-e.insets.right),u=Math.max(1,e.pane.height-e.insets.top-e.insets.bottom),f=e.context,p=e.anchor,h=Math.min(c/Math.max(1,f.width),u/Math.max(1,f.height))*r,m=Math.max(t,Math.min(n,h)),y=(v,S,b,_,k,j)=>{let E=v+(S-_*m)/2-b*m;const C=k*m+E,R=(k+j)*m+E;return j*m<=S?C<v?E+=v-C:R>v+S&&(E-=R-(v+S)):E+=v-C,E};return{x:y(s,c,f.x,f.width,p.x,p.width),y:y(l,u,f.y,f.height,p.y,p.height),zoom:m}}function DY(e){let t=1/0,n=1/0,r=-1/0,s=-1/0;for(const l of e)t=Math.min(t,l.x),n=Math.min(n,l.y),r=Math.max(r,l.x+l.width),s=Math.max(s,l.y+l.height);return Number.isFinite(t)?{x:t,y:n,width:r-t,height:s-n}:null}let li=null,Il=null;const Q0=new Set,J0=()=>{for(const e of Q0)e()},FY=e=>(Q0.add(e),()=>{Q0.delete(e)}),uR=()=>li,qY=90;function M$(e){!Il||e!=null&&Il.at.id!==e||(clearTimeout(Il.timer),Il=null)}function dR(e,t,n="pointer"){M$();const r={id:e,anchor:t,by:n};if(li||n==="focus"){li=r,J0();return}Il={at:r,timer:setTimeout(()=>{Il=null,li=r,J0()},qY)}}function Ka(e){M$(e),!(!li||e!=null&&li.id!==e)&&(li=null,J0())}function BY({agentFor:e,recapFor:t,labelFor:n,bounds:r}){const s=w.useSyncExternalStore(FY,uR,uR),l=s?e(s.id):void 0,c=s&&!l?t(s.id):void 0,u=s!=null&&(!l&&!c||!s.anchor.isConnected);return w.useEffect(()=>{u&&s&&Ka(s.id)},[u,s]),!s||u?null:l?o.jsx(UY,{a:l,anchor:s.anchor,parentLabel:l.parentId?n(l.parentId):void 0,bounds:r},s.id):c?o.jsx(zY,{r:c,anchor:s.anchor,bounds:r},s.id):null}function I$(e,t){const n=w.useRef(null),r=w.useCallback(()=>{const s=n.current;if(!s||!e.isConnected)return;const l=$b(e.getBoundingClientRect(),{width:s.offsetWidth,height:s.offsetHeight},t());s.style.top=`${l.top}px`,s.style.left=`${l.left}px`,s.style.maxHeight=l.maxHeight==null?"":`${l.maxHeight}px`,s.dataset.side=l.side},[e,t]);return w.useLayoutEffect(()=>{r()}),n}function zY({r:e,anchor:t,bounds:n}){const r=I$(t,n),s=ec(3e4),l=Jh(e.recap.at,s);return Mn.createPortal(o.jsxs("div",{ref:r,className:"ap-peek node-peek recap-peek",role:"tooltip",id:"node-peek",style:{"--session-hue":e.hue},children:[o.jsxs("div",{className:"node-peek-head",children:[o.jsxs("span",{className:"recap-peek-mark",children:[o.jsx(Eu,{}),"recap"]}),o.jsx("span",{className:"node-peek-time",title:l.title,children:l.label})]}),e.sessionLabel&&o.jsx("div",{className:"node-peek-kind",children:o.jsxs("span",{children:["Claude Code's recap of ",e.sessionLabel]})}),o.jsx("p",{className:"recap-peek-text",children:e.recap.text}),o.jsx("p",{className:"node-peek-hint",children:"Click to go to the session · double-click for its details"})]}),document.body)}function UY({a:e,anchor:t,parentLabel:n,bounds:r}){const s=I$(t,r),l=ec(1e3),c=Sb(e.sessionName,e.sessionTitle),u=e.tools.filter(S=>S.ok===!1).length,f=e.tools.filter(S=>!S.endedAt).length,p=ir(e,l).total,h=e.usage.inputTokens+e.usage.outputTokens,m=e.kind==="root"&&Fr(e.waiting),y=e.kind==="root"?"session":n?`subagent of ${n}`:"subagent",v=[`${e.toolCount} ${e.toolCount===1?"tool":"tools"}`,f>0?`${f} in-flight`:null,h>0?`${Bt(h)} tok`:null,p>0?`${ut(p)}${_u(e,l)>0?"+":""}`:null].filter(Boolean).join(" · ");return Mn.createPortal(o.jsxs("div",{ref:s,className:"ap-peek node-peek",role:"tooltip",id:"node-peek",children:[o.jsxs("div",{className:"node-peek-head",children:[o.jsx("span",{className:"node-peek-name",children:e.label}),o.jsxs("span",{className:"node-peek-time",children:[e.synthetic?"≥ ":"",Ul(e.startedAt,e.endedAt,l)]})]}),o.jsxs("div",{className:"node-peek-kind",children:[o.jsxs("span",{className:"node-peek-state","data-kind":_0(e.state),children:[o.jsx(xM,{kind:_0(e.state)}),Wl(e.state)]}),o.jsx("span",{children:y}),e.model?o.jsx("span",{children:so(e.model)}):null]}),e.kind==="root"&&c.face&&o.jsx("p",{className:"node-peek-title",children:c.face}),e.kind==="root"&&e.waiting&&o.jsxs("p",{className:`node-peek-wait${m?" warn":""}`,children:[m&&o.jsx(Tb,{}),o.jsx("span",{children:Rb(e.waiting)}),o.jsx("b",{children:Ul(e.waiting.since,void 0,l)})]}),o.jsxs("p",{className:"node-peek-facts",children:[v,u>0&&o.jsxs("span",{className:"node-peek-failed",children:[" · ",u," failed"]})]}),e.branch&&e.branch.total>0&&o.jsx("p",{className:"node-peek-branch",children:fM(e.branch)}),o.jsx("p",{className:"node-peek-hint",children:"Click to go to the session · double-click for details"})]}),document.body)}const HY=5*6e4,WY=6e4;function VY({shown:e,tabVisible:t,lastReadAt:n,now:r,lastSince:s,since:l}){return!e||!t?!1:s&&l&&s!==l?!0:n===null||r-n>=HY}function hR(e=new Date){return TM("month",e)}function GY(e){const t=Cf(e);return{cost:t.cost,tokens:t.tokens}}function fR(e){return e>0?ut(e):"$0.00"}const KY="Update checks are off (AGENTS_DECK_NO_UPDATE_CHECK=1)",t0="click for what's new";function YY(e){if(e.checkDisabled)return`${KY} · ${t0}`;if(e.checking)return`Asking npm for the newest release… · ${t0}`;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 · ${t0}, and to check npm now`}function XY(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 ZY(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 $$(e){return e?`${e.kind}:${e.to}`:""}function QY(e,t){return e!=null&&t!==$$(e)}function JY(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."}}const eb={kind:"assumed",claude:!0,codex:!0};function eX(e){if(!e||typeof e!="object")return eb;const t=e.providers;if(!t||typeof t!="object")return eb;const n=t;return{kind:"reported",claude:n.claude!==!1,codex:n.codex!==!1}}function tX(e){return e.claude&&e.codex?"Claude Code and Codex":e.claude?"Claude Code":e.codex?"Codex":null}const pR={claude:"Claude Code",codex:"Codex",opencode:"OpenCode",openclaw:"OpenClaw",copilot:"GitHub Copilot",pi:"pi-agent",zcode:"ZCode"};function nX(e){const t=e.toLowerCase();return Object.hasOwn(pR,t)?pR[t]:t?t[0].toUpperCase()+t.slice(1):""}function rX(e){return e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function KX(e,t=[]){const n=t.length?rX(t.map(nX)):tX(e);return n?`via ccusage · local ${n} logs`:"via ccusage · local agent logs"}function sX(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 aX(e,t){const n=t.prefs??G0,r=Kl(n.done.level),s=Kl(n["needs-input"].level),l=r===s?`${r}%`:`${r}% and ${s}%`,c=t.on?`Sound: on at ${l} — a tone when a turn finishes, another when Claude asks for you (M)`:"Sound: off — press M, or use the switch in here, for a tone when a turn finishes (M)",u=e.codex?`
285
+
286
+ Both CLIs get the finish tone. The second tone — Claude is waiting for you — has no Codex equivalent to fire on, so it only ever plays for Claude Code.`:"",f=t.on&&t.locked?`
287
+
288
+ Waiting for a click: this browser plays no sound until the page has been used at least once. Anything you press unlocks it.`:"";return c+u+f+`
289
+
290
+ Click to set the volume and the sound of each tone, and to hear either one.`}function df(e){const t=Math.max(0,Math.floor(e));return`${t} event${t===1?"":"s"}`}const mR=99;function oX(e){const t=Math.max(0,Math.floor(e));return t>mR?`${mR}+`:String(t)}const iX="Pause the canvas";function lX(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 — ${df(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)":`${df(e.held)} arrived while paused and will be applied in order when you resume (Space)`}function cX(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 O$="paused · full",uX=(e,t)=>t>0?O$:e>0?`paused · ${oX(e)}`:"paused";function dX(e){const t=Math.max(0,Math.floor(e.dropped??0));return e.connected?e.paused?{tone:"paused",resting:!1,label:uX(e.held,t),widest:O$,title:t>0?`Connected — the pause is full at ${df(e.held)}; the oldest are being dropped as new ones arrive. Resume to catch up (Space)`:e.held>0?`Connected — ${df(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 hX=w.lazy(()=>nb(()=>import("./UsageHistoryModal-D-XRttte.js"),[])),fX=w.lazy(()=>nb(()=>import("./BrowserWatchModal-CxfWHmjb.js"),[]));function gR(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}const pX={agent:eq,sessionGroup:Mq,recapNote:$q},mX={recapTie:Oq},L$="react-flow__node";function n0(e){var t,n;return!!e&&((n=(t=e.classList)==null?void 0:t.contains)==null?void 0:n.call(t,L$))===!0}const r0=80,s0=.86;function yR(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 gX(e){try{const t=document.querySelector(`.${L$}[data-id="${CSS.escape(e)}"]`);t==null||t.focus({preventScroll:!0})}catch{}}const yX=["a[href]","button:not(:disabled)","input:not(:disabled)","select:not(:disabled)","textarea:not(:disabled)","summary","[tabindex]"].join(","),wX=420,Th=18,wR=400,a0=450,hk="agent-dag.layout",fk="agent-dag.layoutFrame",pk="agent-dag.viewport",P$="agent-dag.sessionListOpen",D$="agent-dag.detailOpen",F$="agent-dag.usagePanelOpen",q$="agent-dag.systemPanelOpen",vR="agent-dag.accountsPanelOpen",o0="agent-dag.versionNoticeDismissed",xR="agent-dag.oldNameNoticeDismissed",vX=15*6e4,i0={git_checkout:"this deck runs from a git checkout — pull instead:",npx:"npx runs from a cache that cannot be upgraded in place — 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:"},Rh="agent-dag.autoRestart",bR="agent-dag.bundleReloadedFor";function xX(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(P$)==="1"}catch{return!1}}function bX(e){if(!(typeof window>"u"))try{window.localStorage.setItem(P$,e?"1":"0")}catch{}}function kX(){if(typeof window>"u")return!1;try{return window.localStorage.getItem(D$)==="1"}catch{return!1}}function NX(e){if(!(typeof window>"u"))try{window.localStorage.setItem(D$,e?"1":"0")}catch{}}function SX(){const e=yr(F$);return e===null?!0:e==="1"}function jX(e){if(!(typeof window>"u"))try{window.localStorage.setItem(F$,e?"1":"0")}catch{}}function _X(){const e=yr(q$);return e===null?!0:e==="1"}function EX(e){if(!(typeof window>"u"))try{window.localStorage.setItem(q$,e?"1":"0")}catch{}}function CX(){if(typeof window>"u")return{positions:[],pins:[]};try{return xY(window.localStorage.getItem(hk))}catch{return{positions:[],pins:[]}}}function Ah(e,t){if(!(typeof window>"u"))try{window.localStorage.setItem(hk,bY(e,t))}catch{}}function TX(){if(typeof window>"u")return null;try{return kY(window.localStorage.getItem(fk))}catch{return null}}function RX(e){if(!(typeof window>"u"))try{window.localStorage.setItem(fk,JSON.stringify(e))}catch{}}function AX(){if(typeof window>"u")return null;try{return NY(window.localStorage.getItem(pk))}catch{return null}}function MX(e){if(!(typeof window>"u"))try{window.localStorage.setItem(pk,JSON.stringify(e))}catch{}}function kR(){if(!(typeof window>"u")){try{window.localStorage.removeItem(hk)}catch{}try{window.localStorage.removeItem(pk)}catch{}try{window.localStorage.removeItem(fk)}catch{}}}function IX(e,t){const n=L9(e,t,new Date().toISOString());if(!n)return;const r=JSON.stringify(n,null,2),s=new Blob([r],{type:"application/json"}),l=URL.createObjectURL(s),c=document.createElement("a");c.href=l,c.download=P9(n.label,t),document.body.appendChild(c),c.click(),document.body.removeChild(c),setTimeout(()=>URL.revokeObjectURL(l),1e3)}const B$={file:"📁",shell:"⚡",web:"🌐",agent:"🤖",task:"📋",plan:"🧭",mcp:"🔌",other:"✨"},$X={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 OX({cat:e}){return o.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:o.jsx("path",{d:$X[e]})})}const hf={file:"file",shell:"shell",web:"web",agent:"agent",task:"task",plan:"plan",mcp:"mcp",other:"other"},z$=mM;function LX(){return o.jsx(xb,{children:o.jsx(FX,{})})}const PX=e=>e.transform[2]>=e.maxZoom,DX=e=>e.transform[2]<=e.minZoom;function FX(){var Oc,Lc,ra,Pc;const e=xf(),t=Tt(PX),n=Tt(DX),r=tn(),s=w.useState(S0)[0],l=w.useRef(s),[c,u]=w.useState(()=>$K(typeof window>"u"?null:window.localStorage)),[f,p]=w.useState(null),[,h]=w.useState(0),m=w.useCallback(()=>h(T=>T+1),[]),[y,v]=w.useState(kX);w.useEffect(()=>{NX(y)},[y]);const[S,b]=w.useState(()=>new Set),[_,k]=w.useState(null),[j,E]=w.useState(null),C=w.useCallback((T,A,X=!A)=>{b(te=>{if(!A)return new Set([T]);const ye=new Set(te);return ye.has(T)?ye.delete(T):ye.add(T),ye}),k(te=>A&&te===T?te:T),!A&&X&&v(!0)},[]),R=w.useCallback(()=>{b(new Set),k(null)},[]),[I,O]=w.useState(null),[H,q]=w.useState(null),$=w.useCallback(T=>q(T),[]),[V,ne]=w.useState(!1),[ee,M]=w.useState(!1),[Z,K]=w.useState(!1),D=w.useRef(null),[P,B]=w.useState(xX);w.useEffect(()=>{bX(P)},[P]);const[W,F]=w.useState(SX);w.useEffect(()=>{jX(W)},[W]);const[G,re]=w.useState(null),[U,Y]=w.useState(!1),z=w.useRef(null);w.useEffect(()=>{let T=!0,A=!1,X=null,te=null,ye="";const _e=vt=>{T&&(Y(!0),vt!==ye&&re(null))},Oe=()=>{if(A)return;A=!0,X=Date.now();const vt=hR();te=vt,fetch(`/api/ccusage?since=${vt}`).then(Et=>Et.ok?Et.json():null).then(Et=>{if(T){if(!(Et!=null&&Et.ok)){_e(vt);return}ye=vt,re(GY(Et)),Y(!1)}}).catch(()=>_e(vt)).finally(()=>{A=!1})},Ve=()=>{const vt=z.current;VY({shown:!!vt&&vt.getClientRects().length>0,tabVisible:document.visibilityState==="visible",lastSince:te,since:hR(),lastReadAt:X,now:Date.now()})&&Oe()};Ve();const it=window.setInterval(Ve,WY);document.addEventListener("visibilitychange",Ve);let Ze=null;return z.current&&typeof ResizeObserver<"u"&&(Ze=new ResizeObserver(Ve),Ze.observe(z.current)),()=>{T=!1,window.clearInterval(it),document.removeEventListener("visibilitychange",Ve),Ze==null||Ze.disconnect()}},[]);const[ie,le]=w.useState(_X);w.useEffect(()=>{EX(ie)},[ie]);const ge=w.useRef(!1),[Ne,Ie]=w.useState(()=>{const T=(()=>{try{const A=window.localStorage.getItem(vR);return A===null?!0:A==="1"}catch{return!0}})();return T&&P?(ge.current=!0,!1):T});w.useEffect(()=>{if(!(!Ne&&ge.current))try{window.localStorage.setItem(vR,Ne?"1":"0")}catch{}},[Ne]),w.useEffect(()=>{!P&&ge.current&&(ge.current=!1,Ie(!0))},[P]);const Ge=gh(Ne,200),Pe=gh(W,130),Be=gh(ie,130),[Te,st]=w.useState(null);w.useEffect(()=>{let T=null;try{T=localStorage.getItem("agent-dag.sound")}catch{}st(T===null?!0:T==="on")},[]);const de=w.useCallback(()=>{st(T=>{var X;const A=T!==!0;try{localStorage.setItem("agent-dag.sound",A?"on":"off")}catch{}return A&&((X=Ut.current)==null||X.unlock()),A})},[]),ue=w.useCallback(T=>{de()},[de]),se=w.useRef(ue);se.current=ue;const be=w.useRef(Te);be.current=Te;const[Le,ce]=w.useState(()=>wV(yr)),pe=w.useRef(Le);pe.current=Le;const[Ae,fe]=w.useState(()=>Y9(yr)),Se=w.useRef(Ae);Se.current=Ae;const[Ye,qe]=w.useState([]),ke=w.useCallback(T=>{fe(A=>{const X={...A,[T]:null};return Se.current=X,X});try{localStorage.removeItem(yu[T])}catch{}},[]),Re=w.useCallback((T,A)=>{const X=Se.current[T];if(!(A&&X!==A)){ke(T),ce(te=>{const ye={...te,[T]:{...te[T],figure:wr}};return pe.current=ye,ye});try{localStorage.setItem(Bh[T],wr)}catch{}}},[ke]),ze=w.useRef(Re);ze.current=Re,w.useEffect(()=>{let T=!0;return oV().then(A=>{if(!T)return;qe(A);const X=new Set(A.map(te=>te.id));for(const te of qh){const ye=Se.current[te];ye&&!X.has(ye)&&ze.current(te,ye)}},()=>{}),()=>{T=!1}},[]);const Fe=w.useRef(null),We=w.useCallback((T,A=!1)=>{var X,te;if((X=Ut.current)==null||X.unlock(),Fe.current!==null&&clearTimeout(Fe.current),Fe.current=null,!A){(te=Ut.current)==null||te.play(T,!0);return}Fe.current=setTimeout(()=>{var ye;Fe.current=null,(ye=Ut.current)==null||ye.play(T,!0)},fV)},[]),rt=w.useCallback((T,A)=>{ce(X=>{const te={level:Kl(A.level??X[T].level),figure:s$(T,A.figure??X[T].figure)};try{localStorage.setItem(i$[T],String(te.level)),localStorage.setItem(Bh[T],te.figure)}catch{}return{...X,[T]:te}}),We(T,!0)},[We]),dt=w.useCallback((T,A)=>{if(!Ye.some(te=>te.id===A))return;const X={...Se.current,[T]:A};Se.current=X,fe(X);try{localStorage.setItem(yu[T],A)}catch{}We(T,!0)},[Ye,We]),ct=w.useCallback(async T=>{var ye;const A=H0(Ye.length);if(A)throw new Error(A);const X=window.AudioContext??window.webkitAudioContext;if(!X)throw new Error("This browser cannot decode audio files.");const te=new X;try{const _e=await tV(T,Ve=>te.decodeAudioData(Ve));await I2(_e);const Oe=Ou(_e);qe(Ve=>[...Ve.filter(it=>it.id!==Oe.id),Oe])}finally{(ye=te.close)==null||ye.call(te)}},[Ye.length]),yt=w.useCallback(async T=>{const A=H0(Ye.length);if(A)throw new Error(A);const X=nV(T);await I2(X);const te=Ou(X);qe(ye=>[...ye.filter(_e=>_e.id!==te.id),te])},[Ye.length]),Ot=w.useCallback(async(T,A)=>{const X=Ye.find(ye=>ye.id===T),te=A.trim().slice(0,80);!X||!te||te===X.name||(await lV(T,te),qe(ye=>ye.map(_e=>_e.id===T?{..._e,name:te}:_e)))},[Ye]),zt=w.useCallback(async T=>{await cV(T),qe(ye=>ye.filter(_e=>_e.id!==T));const A=Se.current,X=X9(A,T);Se.current=X,fe(X);const te=qh.filter(ye=>A[ye]===T);for(const ye of te)try{localStorage.removeItem(yu[ye]),localStorage.setItem(Bh[ye],wr)}catch{}te.length>0&&ce(ye=>{const _e={...ye};for(const Oe of te)_e[Oe]={..._e[Oe],figure:wr};return pe.current=_e,_e})},[]),Xt=w.useCallback(T=>{var te,ye;const A=qh.find(_e=>Se.current[_e]===T),X=A?pe.current[A].level:gi;(te=Ut.current)==null||te.unlock(),(ye=Ut.current)==null||ye.previewCustom(T,X)},[]);w.useEffect(()=>()=>{Fe.current!==null&&clearTimeout(Fe.current)},[]);const[Dt,rn]=w.useState(!1),je=w.useRef(null),[xt,bt]=w.useState(!1),_n=w.useRef(null);w.useEffect(()=>{Dt&&bt(!1)},[Dt]);const Ut=w.useRef(null),[Vn,Vt]=w.useState("locked");w.useEffect(()=>{const T=xV({enabled:()=>be.current===!0,prefs:()=>pe.current,customSelection:()=>Se.current,loadCustom:iV,onCustomFailure:(X,te)=>ze.current(X,te),onState:Vt});Ut.current=T,Vt(T.state());const A=()=>T.unlock();return window.addEventListener("pointerdown",A,{once:!0,capture:!0}),window.addEventListener("keydown",A,{once:!0,capture:!0}),()=>{window.removeEventListener("pointerdown",A,{capture:!0}),window.removeEventListener("keydown",A,{capture:!0})}},[]);const[Lt,Zt]=w.useState(!1),[In,Hr]=w.useState(!1),[xe,lr]=w.useState(null),[ks,Wr]=w.useState(null),[fa,Ns]=w.useState(!1),[xr,$n]=w.useState(null),[Hs,Q]=w.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem(o0)??""}catch{return""}}),[De,et]=w.useState(!1),Ue=w.useRef(0),[tt,wt]=w.useState(!1),gt=w.useCallback((T=!1)=>(T&&(Ue.current=Date.now(),wt(!0)),fetch(T?"/api/version?refresh=1":"/api/version").then(A=>A.ok?A.json():null).then(A=>{A&&lr(A)}).catch(()=>{}).finally(()=>{T&&wt(!1)})),[]),It=w.useCallback(()=>{gt(Date.now()-Ue.current>=vX)},[gt]);w.useEffect(()=>{gt();const T=window.setInterval(It,5*6e4),A=()=>{document.visibilityState==="visible"&&It()};return document.addEventListener("visibilitychange",A),()=>{window.clearInterval(T),document.removeEventListener("visibilitychange",A)}},[gt,It]),w.useEffect(()=>{Lt&&gt()},[Lt,gt]);const Rt=w.useRef(0);w.useEffect(()=>{if(!Lt||!hu())return;let T=!1;const A=Rt.current;return fetch("/api/desktop-update").then(X=>X.ok?X.json():null).then(X=>{if(T||Rt.current!==A)return;const te=rR(X);te&&Wr(te)}).catch(()=>{}),()=>{T=!0}},[Lt]);const Qt=bK(ks),Nt=w.useRef(!1),br=w.useRef(0),cr=w.useRef(0);w.useEffect(()=>()=>window.clearTimeout(br.current),[]);const ki=w.useCallback(async T=>{if(!Ps(Nt.current))return;const A=++cr.current;window.clearTimeout(br.current),Nt.current=!0,Ns(!0),$n(null);const X=te=>{A===cr.current&&(window.clearTimeout(br.current),Nt.current=!1,Ns(!1),$n({failure:te,version:T}))};try{const te=await fetch("/api/desktop-update/restart",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({version:T})});if(!te.ok)return X(jK(await te.json().catch(()=>null)))}catch{return X("unreachable")}A===cr.current&&(br.current=window.setTimeout(()=>X("timeout"),b$))},[]);w.useEffect(()=>{const T=rK();let A=null;const X=Oe=>{fetch("/api/presence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tab:T,looking:Oe}),keepalive:!0}).catch(()=>{})},te=()=>{const Oe=tK(document);nK(A,Oe)&&X(Oe),A=Oe},ye=()=>{A&&X(!1),A=!1};te();const _e=window.setInterval(te,eK);return window.addEventListener("focus",te),window.addEventListener("blur",te),document.addEventListener("visibilitychange",te),window.addEventListener("pagehide",ye),()=>{window.clearInterval(_e),window.removeEventListener("focus",te),window.removeEventListener("blur",te),document.removeEventListener("visibilitychange",te),window.removeEventListener("pagehide",ye),ye()}},[]);const ht=(xe==null?void 0:xe.notice)??null,[ur,sn]=w.useState(null),Vr=ur&&Qt?Qt.version:null,Gn=w.useRef(null);w.useEffect(()=>{!Vr||Gn.current===Vr||(Gn.current=Vr,fetch("/api/desktop-update/seen",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({version:Vr})}).catch(()=>{}))},[Vr]);const Xu=w.useRef(!1);w.useEffect(()=>{if(Xu.current)return;const T=nR(),A=hK(T),X=wK({stored:A,running:(xe==null?void 0:xe.running)??null,notes:tR,remembers:fK(T)});if(X.reason==="no-version")return;Xu.current=!0,X.record&&pK(T,X.record);let te=!0;return(async()=>{var it;let _e=mK(T);if(hu())try{const Ze=await fetch("/api/prefs");if(!Ze.ok)throw new Error("desktop tour preferences unavailable");const vt=await Ze.json();if(!(vt!=null&&vt.ok))throw new Error("desktop tour preferences unavailable");const Et=((it=vt.prefs)==null?void 0:it.tourSeen)===!0;_e&&!Et&&fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tourSeen:!0}),keepalive:!0}).catch(()=>{}),_e=_e||Et}catch{_e=!0}if(!te)return;const Oe=yK({tourSeen:_e,decision:X}),Ve=X.show.length?{entries:X.show,since:A,firstRun:!1}:null;Oe.tour&&K(!0),Oe.notes==="now"?sn(Ve):Oe.notes==="after"&&(D.current=Ve)})(),()=>{te=!1}},[xe==null?void 0:xe.running]);const io=(xe==null?void 0:xe.running)??"3.29.0",Zu=w.useMemo(()=>w$(tR,null,io),[io]),pa=w.useCallback(()=>{sn({entries:Zu,since:null,firstRun:!1})},[Zu]),[Ni,lo]=w.useState(null),[Kn,Zf]=w.useState(eb);w.useEffect(()=>{let T=!1;return fetch("/api/health").then(A=>A.ok?A.json():null).then(A=>{T||(Zf(eX(A)),!(!A||typeof A.workspace!="string")&&lo(A.workspace))}).catch(()=>{}),()=>{T=!0}},[Lt]);const Si=w.useRef(Kn);Si.current=Kn;const co=$$(ht),ma=QY(ht,Hs),oc=w.useCallback(()=>{Q("");try{window.localStorage.setItem(o0,"")}catch{}},[]),uo=w.useCallback(()=>{if(ht){Q(co);try{window.localStorage.setItem(o0,co)}catch{}}},[ht,co]),[Qf,ic]=w.useState(()=>{if(typeof window>"u")return"";try{return window.localStorage.getItem(xR)??""}catch{return""}}),ft=xe!=null&&xe.invokedAs&&xe.invokedAs!==dn?xe.invokedAs:null,Qu=ft!=null&&Qf!==ft,Ju=w.useCallback(()=>{if(ft){ic(ft);try{window.localStorage.setItem(xR,ft)}catch{}}},[ft]),On=((Oc=xe==null?void 0:xe.upgrade)==null?void 0:Oc.state)??"idle",ho=qU(xe==null?void 0:xe.upgrade),ji=w.useRef(!1),ed=w.useCallback(async()=>{if(Ps(ji.current||On==="running")){ji.current=!0;try{await fetch("/api/upgrade",{method:"POST"})}catch{}await gt(),ji.current=!1}},[On,gt]);w.useEffect(()=>{if(On!=="running")return;const T=window.setInterval(gt,3e3);return()=>window.clearInterval(T)},[On,gt]);const lc=w.useCallback(async()=>{const T=xe==null?void 0:xe.command;!T||!await hi(T)||(et(!0),window.setTimeout(()=>et(!1),1600))},[xe==null?void 0:xe.command]),fo=w.useCallback(()=>{B(T=>(T||Ie(A=>(A&&(ge.current=!0),!1)),!T))},[]),Gr=w.useCallback(()=>{ge.current=!1,Ie(T=>(T||B(!1),!T))},[]),[Kr,kr]=w.useState(!1),[ga,Ws]=w.useState(!1),[Yr,Jf]=w.useState(()=>{try{return Number(localStorage.getItem(oR))||0}catch{return 0}}),[cc,po]=w.useState([]),[uc,dc]=w.useState(!1);w.useEffect(()=>{let T=!0;const A=()=>{fetch("/api/browser-watch?live=0").then(te=>te.ok?te.json():null).then(te=>{var ye;!T||!(te!=null&&te.ok)||(po(te.episodes??[]),dc(((ye=te.settings)==null?void 0:ye.enabled)===!0))}).catch(()=>{})};A();const X=setInterval(A,5*6e4);return()=>{T=!1,clearInterval(X)}},[]);const[_i,mo]=w.useState([]),td=w.useRef(new Set),[Ss,ya]=w.useState(null);w.useEffect(()=>{let T=!0,A=0;const X=()=>{fetch("/api/lan").then(te=>te.ok?te.json():null).then(te=>T?(te!=null&&te.ok&&mo(JS(Array.isArray(te.pending)?te.pending:[],te.aliases)),te):null).catch(()=>null).then(te=>{T&&(A=window.setTimeout(X,(te==null?void 0:te.enabled)===!0?q0:VM))})};return X(),()=>{T=!1,window.clearTimeout(A)}},[]);const Vs=w.useCallback(async(T,A)=>{if(!Ss){ya(T);try{const te=await(await fetch("/api/lan/peer",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:T,fp:A})})).json().catch(()=>null);te&&Array.isArray(te.pending)?mo(JS(te.pending,te.aliases)):mo(ye=>ye.filter(_e=>_e.fp!==A))}catch{}finally{ya(null)}}},[Ss]),dr=w.useMemo(()=>cY(cc,Yr).length,[cc,Yr]),[ep,nd]=w.useState(0),Ei=w.useRef(null),[Ci,Ti]=w.useState(!1),wa=w.useRef(null),[js,Ri]=w.useState(0),En=w.useState(()=>ZK({protect:T=>n6(l.current,T)}))[0],[go,Ai]=w.useState(!1),va=w.useCallback(()=>{const T=En.paused&&En.dropped>0,A=En.setPaused(!En.paused);T&&r6(l.current);for(const X of A)l.current=zN(l.current,X);Ai(En.paused)},[En]),[Jt,Ln]=w.useState(Date.now()),[Pn,xa]=w.useState(()=>{if(typeof window>"u")return!0;try{return window.localStorage.getItem(Rh)!=="0"}catch{return!0}}),ba=w.useRef(!1),tp=w.useCallback(()=>{const T=!Pn;ba.current=!0;try{window.localStorage.removeItem(Rh)}catch{}xa(T),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:T})}).then(A=>A.ok?A.json():null).then(A=>{var X;A!=null&&A.ok&&xa(((X=A.prefs)==null?void 0:X.autoUpdate)!==!1)}).catch(()=>{})},[Pn]),[Nr,ka]=w.useState(!1),[yo,Mi]=w.useState("restart"),[hc,rd]=w.useState(null),Na=w.useRef(!1),sd=w.useRef(null),Ii=w.useRef(0),wo=w.useCallback(async T=>{if(!Ps(Na.current))return;const A=(T==null?void 0:T.upgrade)===!0;Na.current=!0,sd.current=ho;const X=++Ii.current;Mi(A?"npx":"restart"),ka(!0);try{window.sessionStorage.setItem("agent-dag.restartPending",(ht==null?void 0:ht.to)??"")}catch{}try{await fetch("/api/restart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({upgrade:A})})}catch{}window.setTimeout(()=>{if(Ii.current===X&&Na.current){Na.current=!1,ka(!1);try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}}},A?18e4:3e4)},[ht==null?void 0:ht.to,ho]),fc=w.useRef(null);w.useEffect(()=>{const T=aj(l.current.agents.values())>0,A=WU({enabled:Pn,kind:ht==null?void 0:ht.kind,canRestart:(xe==null?void 0:xe.canRestart)===!0,noticeOpen:ma,visible:document.visibilityState==="visible",busy:T,idleSince:fc.current,now:Jt});fc.current=A.idleSince,A.restart&&wo()},[Pn,ht==null?void 0:ht.kind,xe==null?void 0:xe.canRestart,ma,Jt,wo]);const ad=aj(l.current.agents.values()),od=HU(ad),id=XM({enabled:Pn,kind:ht==null?void 0:ht.kind,canRestart:(xe==null?void 0:xe.canRestart)===!0,noticeOpen:ma,visible:document.visibilityState==="visible",busy:ad>0,idleSince:fc.current,now:Jt});w.useEffect(()=>{const T=xe==null?void 0:xe.running;let A=null,X=null;try{A=window.sessionStorage.getItem("agent-dag.restartPending"),X=window.sessionStorage.getItem(bR)}catch{return}const te=FU({bundle:"3.29.0",running:T,pending:A,lastTried:X});if(te==="reload"){try{window.sessionStorage.setItem(bR,T??"")}catch{return}window.location.reload();return}if(te!=="confirm")return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}Na.current=!1,ka(!1),rd(T??null);const ye=window.setTimeout(()=>rd(null),6e3);return()=>window.clearTimeout(ye)},[xe==null?void 0:xe.running]),w.useEffect(()=>{if(Nr&&BU({asked:sd.current,reported:ho})){try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}Na.current=!1,ka(!1)}},[Nr,ho]);const pc=w.useState(()=>vY(CX()))[0],Gt=w.useRef(pc.pinned),$i=w.useRef(null),Oi=w.useState(()=>AX())[0],[mc,gc]=w.useState(()=>new Set),[Sa,ld]=w.useState(eY),[vo,cd]=w.useState(AV),[Li,np]=w.useState(IV),[xo,yc]=w.useState(()=>qV(yr(F2))),[Pi,rp]=w.useState(()=>FV(yr(q2))),[Gs,Di]=w.useState(()=>BV(yr(D2),xo,TV)),[Ks,Fi]=w.useState(()=>new Set),[ud,dd]=w.useState(0),[Xr,hd]=w.useState(()=>iR(gR)),wc=w.useMemo(()=>yY(Xr),[Xr]),ja=w.useCallback(T=>gY(T,wc),[wc]),[fd,sp]=w.useState(!1);w.useEffect(()=>{document.documentElement.dataset.theme=Sa;try{window.localStorage.setItem(S$,Sa)}catch{}hd(T=>{const A=iR(gR);return wY(T,A)?T:A})},[Sa]),w.useEffect(()=>{try{window.localStorage.setItem(l$,vo?"1":"0")}catch{}},[vo]),w.useEffect(()=>{try{window.localStorage.setItem(c$,String(Li))}catch{}},[Li]),w.useEffect(()=>{try{window.localStorage.setItem(q2,Pi?"1":"0")}catch{}},[Pi]),w.useEffect(()=>{try{window.localStorage.setItem(F2,JSON.stringify(xo))}catch{}},[xo]),w.useEffect(()=>{try{window.localStorage.setItem(D2,Gs)}catch{}},[Gs]);const ap=w.useCallback(T=>{yc(A=>A.some(X=>X.id===T.id)?A:[...A,T]),Fi(A=>{if(!A.has(T.id))return A;const X=new Set(A);return X.delete(T.id),X})},[]),pd=w.useCallback((T,A)=>{const X=A.trim();!X||X.length>Lu||yc(te=>te.map(ye=>ye.id===T?{...ye,name:X}:ye))},[]),md=w.useCallback(T=>{yc(A=>A.filter(X=>X.id!==T)),Di(A=>zV(A,T)),Fi(A=>{if(!A.has(T))return A;const X=new Set(A);return X.delete(T),X})},[]),bo=w.useCallback(T=>{const A=B2(T),X=Ks.has(A);T===Gs&&!X||(X&&Fi(te=>{const ye=new Set(te);return ye.delete(A),ye}),Di(T),dd(te=>te+1))},[Gs,Ks]),ko=w.useCallback((T,A)=>{const X=B2(T);Fi(te=>{if(te.has(X)===A)return te;const _e=new Set(te);return A?_e.add(X):_e.delete(X),_e})},[]);w.useEffect(()=>{const T=document.querySelector('meta[name="theme-color"]'),A=Xr["--panel"];T&&A&&T.setAttribute("content",A)},[Xr]);const hr=w.useCallback((T,A)=>{if(Ch({durationMs:A,documentHidden:document.hidden})){e.setViewport(T,{duration:A});return}const{d3Zoom:X,d3Selection:te}=r.getState(),ye=te==null?void 0:te.property("__zoom");if(X&&te&&ye&&ye.k>0&&T.zoom>0){X.transform(te,ye.scale(T.zoom/ye.k).translate((T.x-ye.x)/T.zoom,(T.y-ye.y)/T.zoom));return}e.setViewport(T,{duration:0})},[e,r]),Zr=w.useRef(null),No=w.useRef(0),So=w.useRef(null),qi=w.useRef(()=>{});w.useEffect(()=>{if(!Oi)return;const T=window.setTimeout(()=>{try{hr(Oi,0)}catch{}Ys.current=Date.now()},60);return()=>window.clearTimeout(T)},[hr,Oi]);const Bi=w.useRef(!0),[_a,vc]=w.useState(null);w.useEffect(()=>{const T=new EventSource("/events"),A=YK(m,{now:()=>Date.now(),setTimeout:(_e,Oe)=>window.setTimeout(_e,Oe),clearTimeout:_e=>window.clearTimeout(_e)});let X=!1;const te=typeof BroadcastChannel=="function"?sY(new BroadcastChannel(nY),Math.random().toString(36).slice(2),()=>X):null,ye=window.setInterval(()=>{X||!te||te.ask(600).then(_e=>{X||Hr(rY(_e))})},3e3);return T.addEventListener("open",()=>{Zt(!0),sp(!0)}),T.addEventListener("error",()=>{Zt(!1),vc(null)}),T.addEventListener("open",()=>{X=!0,Hr(!1)}),T.addEventListener("error",()=>{X=!1}),T.addEventListener("replay-end",()=>{Bi.current=!1,A.flush(),vc(Date.now())}),T.addEventListener("desktop-update",_e=>{if(hu())try{const Oe=rR(JSON.parse(_e.data));Oe&&(Rt.current++,Wr(Oe),Oe.status!=="ready"&&(cr.current++,window.clearTimeout(br.current),Nt.current=!1,Ns(!1)))}catch{}}),T.addEventListener("hook",_e=>{var Oe;try{const Ve=JSON.parse(_e.data);if(!En.accept(Ve))return;l.current=zN(l.current,Ve);const it=Ve.replay===!0||Bi.current||Date.now()-Ve.receivedAt>3e4;it?A.replay():A.live();const Ze=vV(Ve,it);Ze&&((Oe=Ut.current)==null||Oe.play(Ze))}catch{}}),()=>{T.close(),A.cancel(),window.clearInterval(ye),te==null||te.leave()}},[m]),w.useEffect(()=>{const T=setInterval(()=>{const A=Date.now();Ln(A);const{changed:X,forgotten:te}=T9(l.current,A);te.length>0&&fetch("/api/forget",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({ids:te})}).catch(()=>{}),b(ye=>_9(ye,l.current.agents)),k(ye=>ye!=null&&!l.current.agents.has(ye)?null:ye),q(ye=>ye!=null&&!l.current.agents.has(ye)?null:ye),O(ye=>ye!=null&&!l.current.agents.has(ye)?null:ye),X&&m()},250);return()=>clearInterval(T)},[m]);const zi=w.useRef(null),Ys=w.useRef(0),gd=420,Yn=w.useCallback((T=500)=>{const A=r0,X=1,te=.2,ye=s0;try{const _e=document.querySelector(".canvas-wrap"),Oe=Array.from(document.querySelectorAll(".react-flow__node")).filter(Ct=>Ct.offsetWidth>0);if(!_e||Oe.length===0)return;const Ve=_e.getBoundingClientRect(),it=e.getViewport();if(!Number.isFinite(it.zoom)||it.zoom<=0)return;const Ze=Ct=>(Ct-Ve.left-it.x)/it.zoom,vt=Ct=>(Ct-Ve.top-it.y)/it.zoom,Et=Oe.map(Ct=>Ct.getBoundingClientRect()),kn=Math.min(...Et.map(Ct=>Ze(Ct.left))),Jn=Math.max(...Et.map(Ct=>Ze(Ct.right))),Oa=Math.min(...Et.map(Ct=>vt(Ct.top))),Ed=Math.max(...Et.map(Ct=>vt(Ct.bottom))),Rr=Jn-kn,Ar=Ed-Oa;if(!(Rr>0&&Ar>0))return;const ll=yR(_e),Dc=Ct=>Math.max(te,Math.min(X,(Ve.width-ll-A*2)/(Rr+Ct)*ye,(Ve.height-A*2)/Ar*ye)),Is=$Y(Dc(gd),Dc(0)),La={x:A-kn*Is,y:Math.max(A,(Ve.height-Ar*Is)/2)-Oa*Is,zoom:Is},Ho=++No.current;hr(La,T),Ys.current=Date.now(),Zr.current=Ch({durationMs:T,documentHidden:document.hidden})?{target:La,until:Date.now()+T+60}:null,window.setTimeout(()=>{var Ct;try{if(((Ct=Zr.current)==null?void 0:Ct.target)===La&&(Zr.current=null),No.current!==Ho)return;const Pa=e.getViewport();(Math.abs(Pa.zoom-Is)>.01||Math.abs(Pa.x-La.x)>2)&&hr(La,0)}catch{}},T+60)}catch{}},[e,hr]);w.useEffect(()=>{const T=()=>{if(!document.hidden)return;const A=Zr.current;if(Zr.current=null,!(!A||Date.now()>A.until)){try{hr(A.target,0)}catch{}Ys.current=Date.now()}};return document.addEventListener("visibilitychange",T),()=>document.removeEventListener("visibilitychange",T)},[hr]);const xc=w.useRef(""),bc=w.useRef(null),Xn=w.useRef(0),_s=w.useCallback(()=>{Xn.current=Date.now()},[]),Ui=w.useRef(null),kc=w.useRef(0),Hi=w.useCallback(()=>{kc.current=Date.now()},[]),Wi=w.useCallback(T=>({hasSourceEvent:!!T,at:Date.now(),lastDeckFitAt:Ys.current,lastCanvasInputAt:kc.current}),[]),Nc="agent-dag.autoFitDisabled",Xs=w.useRef(!1),[Sc,Zs]=w.useState(!1);w.useEffect(()=>{try{window.localStorage.removeItem(Nc)}catch{}},[]);const Qs=w.useCallback(()=>{Xs.current||(Xs.current=!0,Zs(!0))},[]),Ea=w.useCallback(()=>{Xs.current=!1,Zs(!1),Yn(400)},[e,Yn]);w.useEffect(()=>{const T=setInterval(()=>{if(Xs.current||Date.now()-Xn.current<800)return;const A=l.current,X=Date.now(),te=[];for(const _e of A.agents.values())Z0(_e,X)&&te.push({id:_e.id});if(te.length===0)return;const ye=[];for(const{id:_e}of te){const Oe=Sr.current.get(_e),Ve=Gt.current.get(_e)??Kt.current.get(_e);!Oe||!Ve||ye.push({x:Ve.x,y:Ve.y,width:Oe.width,height:Oe.height})}CY({pane:Ui.current,viewport:e.getViewport(),boxes:ye})&&Yn(600)},1500);return()=>clearInterval(T)},[e]);const Ca=w.useRef(!1),Sr=w.useRef(new Map),Ta=w.useRef(0),Ra=w.useCallback(T=>{const A=Sr.current;let X=!1;for(const te of T.nodeInternals.values()){const ye=te.width,_e=te.height;if(ye==null||_e==null)continue;const Oe=A.get(te.id);Oe?(Math.abs(Oe.height-_e)>4||Math.abs(Oe.width-ye)>4)&&(A.set(te.id,{width:ye,height:_e}),X=!0):(A.set(te.id,{width:ye,height:_e}),X=!0)}return X&&(Ta.current+=1),Ta.current},[]),Vi=Tt(Ra),[jc,Gi]=w.useState(0);w.useEffect(()=>{let T=0;const A=()=>{const te=Sr.current;let ye=!1;for(const _e of document.querySelectorAll(".react-flow__node[data-id]")){const Oe=_e.getAttribute("data-id");if(!Oe)continue;const Ve=_e.offsetWidth,it=_e.offsetHeight;if(!Ve||!it)continue;const Ze=te.get(Oe);(!Ze||Math.abs(Ze.width-Ve)>4||Math.abs(Ze.height-it)>4)&&(te.set(Oe,{width:Ve,height:it}),ye=!0)}ye&&Gi(_e=>_e+1)};if(Ca.current)return;let X=0;return document.visibilityState==="hidden"?X=window.setTimeout(A,32):T=requestAnimationFrame(A),()=>{cancelAnimationFrame(T),window.clearTimeout(X)}});const Kt=w.useRef(pc.positions),_c=w.useRef(new Set),jo=w.useRef(""),jr=w.useMemo(()=>OK(l.current.agents.values(),c),[l.current,l.current.revision,c]),Js=w.useMemo(()=>{const T=[];for(const A of l.current.agents.values())!Z0(A,Jt)||jr.has(A.id)||T.push(A.id+(A.parentId?`>${A.parentId}`:""));return T.sort(),`${T.join("|")}#sv${Vi}.${jc}`},[l.current,l.current.revision,Jt,Vi,jc,jr]),Aa=w.useRef(null);w.useEffect(()=>(Aa.current!=null&&window.clearTimeout(Aa.current),Aa.current=window.setTimeout(()=>{Ah(Kt.current,Gt.current)},1500),()=>{Aa.current!=null&&window.clearTimeout(Aa.current)}),[Js]),w.useEffect(()=>{if(xc.current===Js)return;const T=xc.current;if(xc.current=Js,!T||Xs.current)return;Date.now()-Ys.current>1200&&Yn(400),zi.current&&window.clearTimeout(zi.current),zi.current=window.setTimeout(()=>{Xs.current||Yn(500)},280)},[Js,e,Yn]);const _r=w.useMemo(()=>VK(l.current,S),[l.current,l.current.revision,S]),_o=w.useMemo(()=>{const T=fY(l.current,Jt);for(const A of jr)T.delete(A);return T},[l.current,l.current.revision,Jt,jr]),Er=w.useRef(null),[Eo,yd]=w.useState({w:0,h:0});w.useEffect(()=>{const T=Er.current;if(!T||typeof ResizeObserver>"u")return;const A=new ResizeObserver(X=>{var ye;const te=(ye=X[0])==null?void 0:ye.contentRect;te&&(Ui.current={width:te.width,height:te.height},yd(_e=>Math.abs(_e.w-te.width)>40||Math.abs(_e.h-te.height)>40?{w:te.width,h:te.height}:_e))});return A.observe(T),Ui.current={width:T.clientWidth,height:T.clientHeight},yd({w:T.clientWidth,h:T.clientHeight}),()=>A.disconnect()},[]);const Co=w.useCallback(T=>{var X,te;const A=T.target;!(A!=null&&A.closest)||A.closest(yX)!==T.currentTarget||(T.preventDefault(),(te=(X=document.activeElement)==null?void 0:X.blur)==null||te.call(X))},[]),op=w.useRef(new Map),[To,wd]=w.useState(!1);w.useEffect(()=>{const T=window.setTimeout(()=>wd(!0),2500);return()=>window.clearTimeout(T)},[]);const[$t,Ro]=w.useState(!1),fr=w.useRef(null),[Qr,Ec]=w.useState(!1),[Ki,Ma]=w.useState(!1),[Yi,Ia]=w.useState(""),[Ao,vd]=w.useState("far"),xd=w.useRef(null),Cc=gh(Ki,140),Mo=w.useCallback(T=>{var te;const A=(te=xd.current)==null?void 0:te.getBoundingClientRect(),X=HK(T);return A&&X?UK(X,A):"far"},[]),[Xi,Tc]=w.useState("detail"),Jr=w.useRef(null),Io=w.useRef(null),Rc=w.useCallback(()=>{var te;const T=Ta.current;if(((te=Io.current)==null?void 0:te.version)===T)return Io.current.card;const A=[];for(const ye of l.current.agents.keys()){const _e=Sr.current.get(ye);_e&&A.push(_e)}const X=RY(A);return Io.current={version:T,card:X},X},[]),ip=w.useCallback(()=>{fr.current&&(window.clearTimeout(fr.current),fr.current=null),Ro(!1)},[]),bd=w.useCallback(T=>{T.length!==0&&queueMicrotask(()=>{Ro(!0),fr.current&&window.clearTimeout(fr.current),fr.current=window.setTimeout(()=>Ro(!1),wX+80)})},[]);w.useEffect(()=>()=>{fr.current&&window.clearTimeout(fr.current)},[]);const Cn=_?l.current.agents.get(_):null,kd=y&&Cn!=null,[$o,Es]=w.useState(0);w.useEffect(()=>{const T=yR(Er.current);Es(A=>Math.abs(A-T)>40?T:A)},[Be,Pe,W,kd,Eo.w]);const Zi=w.useRef($o);Zi.current=$o;const es=Eo.w>0?Math.max(0,(Eo.w-$o-r0*2)*s0):0,Dn=Eo.h>0?Math.max(0,(Eo.h-r0*2)*s0):0,Oo=fF(),{nodes:mn,edges:Qi}=w.useMemo(()=>{const T=I9(l.current,Jt,es,Dn,Gt.current,Sr.current,op.current,bd,To,Qr,Kt.current,_c.current,Js,jo,S,_r,_o,$);return LK(T.nodes,T.edges,c)},[l.current,l.current.revision,Jt,es,Dn,To,Qr,Js,S,_r,_o,$,ep,Oo,c]),lp=w.useState(TX)[0],Nd=w.useRef(lp);w.useEffect(()=>{if(!To||Qr)return;const T={width:es,height:Dn};if(!(T.width>0&&T.height>0))return;const A=Nd.current;if(Nd.current=T,RX(T),!A||A.width===T.width&&A.height===T.height)return;const X={direction:"LR",pinned:Gt.current,measured:Sr.current,lanes:z0(l.current)};if(!p9(mn,Qi,X,A,T))return;const te=So.current&&Date.now()-So.current.at<1500?So.current.id:null,ye=te??Rs.current,_e=ye?Gt.current.get(ye)??Kt.current.get(ye):void 0;for(const Oe of Array.from(Kt.current.keys()))Gt.current.has(Oe)||Kt.current.delete(Oe);_c.current.clear(),jo.current="",m(),window.setTimeout(()=>{if(Ah(Kt.current,Gt.current),Xs.current){if(te){qi.current(te);return}const Oe=ye?Gt.current.get(ye)??Kt.current.get(ye):void 0;if(_e&&Oe&&(Oe.x!==_e.x||Oe.y!==_e.y)){const Ve=e.getViewport();No.current+=1,hr({x:Ve.x-(Oe.x-_e.x)*Ve.zoom,y:Ve.y-(Oe.y-_e.y)*Ve.zoom,zoom:Ve.zoom},0),Ys.current=Date.now()}return}Yn(500)},80)},[es,Dn,To,Qr,m,Yn,e,hr]);const Cs=w.useMemo(()=>{const T=new Map;for(const X of mn){const te=X.data;if(!(te!=null&&te.sessionId)||te.exitAt!=null)continue;const ye=X.width,_e=X.height;if(ye==null||_e==null)continue;const Oe=X.position.x,Ve=X.position.y,it=Oe+ye,Ze=Ve+_e,vt=T.get(te.sessionId);vt?(vt.minX=Math.min(vt.minX,Oe),vt.minY=Math.min(vt.minY,Ve),vt.maxX=Math.max(vt.maxX,it),vt.maxY=Math.max(vt.maxY,Ze)):T.set(te.sessionId,{minX:Oe,minY:Ve,maxX:it,maxY:Ze})}const A=[];for(const[X,te]of T){const ye=te.maxX-te.minX+Th*2,_e=te.maxY-te.minY+Th*2;A.push({id:`group:${X}`,type:j$,position:{x:te.minX-Th,y:te.minY-Th},data:{sessionId:X,w:ye,h:_e},width:ye,height:_e,style:{width:ye,height:_e},zIndex:-1,draggable:!0,selectable:!1,focusable:!1,deletable:!1,connectable:!1})}return A},[mn]),Lo=w.useMemo(()=>{const T=[...Cs,...mn],A=wa.current;return!A||A.size===0?T:T.map(X=>{const te=A.get(X.id);return te?{...X,position:te}:X})},[Cs,mn,js]),ts=w.useMemo(()=>{const T=new Set;for(const A of l.current.agents.values())for(const X of A.tools)T.add(z$(X.name));return Object.keys(B$).filter(A=>T.has(A))},[l.current,l.current.revision]);w.useEffect(()=>{if(ts.length<=1){Ti(!1);return}let T=0;const A=()=>{const X=Ei.current;if(X&&!document.hidden){const te=X.getBoundingClientRect(),ye=Array.from(document.querySelectorAll(".react-flow__node, .tool-burst")).map(Oe=>Oe.getBoundingClientRect()),_e=mY(te,ye,8);Ti(Oe=>Oe===_e?Oe:_e)}T=window.setTimeout(A,300)};return A(),()=>window.clearTimeout(T)},[ts.length]);const Ji=w.useCallback(T=>{gc(A=>{const X=new Set(A);return X.has(T)?X.delete(T):X.add(T),X})},[]),Po=j?K5(l.current.agents,j):null,ea=w.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}l.current=S0(),Gt.current.clear(),Sr.current.clear(),Kt.current.clear(),jo.current="",kR(),u(new Set),p(null);try{window.localStorage.removeItem(uk)}catch{}R(),m()},[m,R]),Cr=w.useCallback(T=>{const A=l.current.agents.get(T);A&&(u(X=>{const te=new Set(X);return te.add(T),sR(window.localStorage,te),te}),p({id:T,label:A.label}),Gt.current.delete(T),Kt.current.delete(T),R())},[R]),At=w.useCallback(()=>{_&&Cr(_)},[_,Cr]),Mt=f&&c.has(f.id)?f:null;w.useEffect(()=>{var T;f&&((T=Er.current)==null||T.focus())},[f]);const Zn=w.useCallback(T=>{const A=[...T];u(X=>{const te=PK(X,A);return te!==X&&sR(window.localStorage,te),te})},[]),an=w.useRef(V);an.current=V;const bn=w.useRef(ee);bn.current=ee;const ns=w.useRef(!1);ns.current=Po!=null||Kr||H!=null||Z||I!=null||ga||ee||ur!=null;const rs=w.useCallback(T=>{const A=D9(T,{confirmOpen:an.current,modalOpen:ns.current});A==="confirm"?ne(!0):A==="clear"&&(ne(!1),ea())},[ea]),gn=w.useCallback(()=>{Gt.current.clear(),Kt.current.clear(),jo.current="",kR(),m(),window.setTimeout(()=>Yn(500),80)},[m,e,Yn]),Do=w.useCallback(()=>Yn(500),[Yn]),Ts=w.useRef(mn);Ts.current=mn;const Fn=w.useCallback(T=>{var vt;const A=Er.current,X=l.current.agents.get(T);if(!A||!X)return;const te=z0(l.current),ye=(Et,kn)=>{const Jn=Sr.current.get(Et.id);if(!Jn)return null;const Oa=kn&&te.has(Et.id)?gd:0;return{x:Et.position.x,y:Et.position.y,width:Jn.width+Oa,height:Jn.height}},_e=Ts.current.find(Et=>Et.id===T),Oe=_e?ye(_e,!1):null;if(!Oe)return;const Ve=[];for(const Et of Ts.current){if(Et.type!=="agent"&&Et.type!=="recapNote"||((vt=Et.data)==null?void 0:vt.sessionId)!==X.sessionId)continue;const kn=ye(Et,Et.type==="agent");kn&&Ve.push(kn)}const it=A.getBoundingClientRect(),Ze=PY({pane:{width:it.width,height:it.height},insets:{top:56,left:72,bottom:32,right:Zi.current+32},context:DY(Ve)??Oe,anchor:Oe});Ka(),Qs(),So.current={id:T,at:Date.now()},No.current+=1,hr(Ze,a0),Ys.current=Date.now(),Zr.current=Ch({durationMs:a0,documentHidden:document.hidden})?{target:Ze,until:Date.now()+a0+60}:null},[hr,Qs]);qi.current=Fn;const el=w.useCallback(T=>{const A=Ts.current.find(X=>X.id===T&&X.type==="agent");return A?A.data:void 0},[]),Sd=w.useCallback(T=>{var A;return(A=l.current.agents.get(T))==null?void 0:A.label},[]),ss=w.useCallback(T=>{var te;const A=Ts.current.find(ye=>ye.id===T&&ye.type==="recapNote");if(!A)return;const X=A.data;return{recap:X.recap,hue:X.hue,sessionLabel:(te=l.current.agents.get(X.parentId))==null?void 0:te.label}},[]),tl=w.useCallback(()=>{var X;const T=(X=Er.current)==null?void 0:X.getBoundingClientRect(),A=document.documentElement;return T?{width:T.right-Zi.current,height:T.bottom}:{width:A.clientWidth,height:A.clientHeight}},[]),Rs=w.useRef(_);Rs.current=_;const Ac=w.useRef(At);Ac.current=At;const nl=w.useCallback(T=>{const A=Ts.current.filter(_e=>_e.type==="agent"),X=TK(A.map(_e=>({id:_e.id,x:_e.position.x,y:_e.position.y})),Rs.current,T),te=X?A.find(_e=>_e.id===X):void 0;if(!te)return;const ye=n0(document.activeElement);C(te.id,!1),window.setTimeout(()=>{try{Fn(te.id)}catch{}ye&&gX(te.id)},30)},[C,Fn]),Tr=w.useRef(null),Qn=w.useCallback(T=>{C(T,!1),window.setTimeout(()=>{try{Fn(T)}catch{}},60)},[C,Fn]),$a=w.useCallback(T=>{jr.has(T)&&Zn([T]),Qn(T)},[jr,Zn,Qn]),Fo=w.useRef(null);w.useEffect(()=>{let T=-1/0;const A=()=>{T=performance.now()},X=te=>{Fo.current=performance.now()-T<250?te.target:null};return window.addEventListener("pointerdown",A,!0),window.addEventListener("focusin",X,!0),()=>{window.removeEventListener("pointerdown",A,!0),window.removeEventListener("focusin",X,!0)}},[]),w.useEffect(()=>{const T=A=>{var Ve,it;const X=A.target,te={tagName:X==null?void 0:X.tagName,isContentEditable:X==null?void 0:X.isContentEditable,role:(Ve=X==null?void 0:X.getAttribute)==null?void 0:Ve.call(X,"role"),type:X==null?void 0:X.type,pointerFocused:X!=null&&X===Fo.current};if(A.key==="Escape"){const Ze=P6({overlayOpen:pu.depth()>0,typing:Sf(te)});Ze==="dismiss"?pu.dismissTop():Ze==="blur"?X==null||X.blur():(IK(te)&&(X==null||X.blur()),R());return}if(Nf(A))return;const ye=n0(X)?(it=X==null?void 0:X.getAttribute)==null?void 0:it.call(X,"data-id"):null,_e=ye&&Ts.current.some(Ze=>Ze.id===ye)?ye:null,Oe=AK(A,_e);if(Oe.kind==="activate"){A.preventDefault(),C(Oe.nodeId,Oe.additive);return}if(Oe.kind!=="node"&&!(Oe.nodeId==null&&V6(te,A.key))&&!G6({key:A.key,modalOpen:K6({appModal:ns.current,dialogDepth:pu.dialogDepth()}),sheetOpen:bn.current})){if(A.key===" "&&(A.preventDefault(),va()),(A.key==="c"||A.key==="C")&&rs("shortcut"),(A.key==="r"||A.key==="R")&&gn(),(A.key==="f"||A.key==="F")&&Do(),(A.key==="z"||A.key==="Z")&&Rs.current&&Fn(Rs.current),A.key==="Delete"&&Ac.current(),(A.key==="l"||A.key==="L")&&fo(),A.key==="d"||A.key==="D")if(Rs.current)v(Ze=>!Ze);else{const Ze=vm(l.current.agents.values());Ze.length>0?Qn(Ze[0].id):nl(1)}if((A.key==="h"||A.key==="H")&&kr(Ze=>!Ze),(A.key==="u"||A.key==="U")&&F(Ze=>!Ze),(A.key==="a"||A.key==="A")&&Si.current.claude&&Gr(),(A.key==="j"||A.key==="J")&&nl(1),(A.key==="k"||A.key==="K")&&nl(-1),A.key==="w"||A.key==="W"){const Ze=_6(vm(l.current.agents.values()),Tr.current);Ze&&(Tr.current=Ze.id,Qn(Ze.id))}(A.key==="t"||A.key==="T")&&ld(Ze=>Ze==="dark"?"light":"dark"),(A.key==="m"||A.key==="M")&&Si.current.claude&&be.current!==null&&se.current(A.shiftKey),(A.key==="s"||A.key==="S")&&le(Ze=>!Ze),(A.key==="b"||A.key==="B")&&Ws(Ze=>!Ze),(A.key==="v"||A.key==="V")&&Si.current.claude&&be.current!==null&&rn(Ze=>!Ze),A.key==="?"&&M(Ze=>!Ze)}};return window.addEventListener("keydown",T),()=>window.removeEventListener("keydown",T)},[rs,gn,Do,R,C,nl,Qn,Fn,va]);const qo=l.current.agents.size,_t=w.useMemo(()=>vm(l.current.agents.values()),[l.current,l.current.revision]);w.useEffect(()=>{const T=DK(_t,jr);T.length>0&&Zn(T)},[_t,jr,Zn]);const qn=w.useMemo(()=>E6(l.current.agents.values()),[l.current,l.current.revision]),As=w.useRef(null);w.useEffect(()=>{const T=aY({waiting:_t.length,running:qn,connected:Lt}),A=As.current;if(As.current=T,(A==null?void 0:A.title)!==T.title&&(document.title=T.title),(A==null?void 0:A.icon)!==T.icon){const X=document.querySelector('link[rel="icon"]');X&&(X.href=oY[T.icon])}},[_t.length,qn,Lt]);const[as,os]=w.useState(""),Ms=lY(_t);w.useEffect(()=>{os(T=>aR(T,Ms))},[Ms]);const[jd,rl]=w.useState(""),sl=dr>0?`Browser watch has ${dr} unread ${dr===1?"finding":"findings"}.`:"";w.useEffect(()=>{rl(T=>aR(T,sl,"Browser watch has no unread findings."))},[sl]);const[yn,Bn]=w.useState(()=>typeof Notification>"u"?"denied":Notification.permission),[St,zn]=w.useState(null),[Bo,al]=w.useState(!1),[Mc,ol]=w.useState(!1);w.useEffect(()=>{let T=!0;return fetch("/api/prefs").then(A=>A.ok?A.json():null).then(A=>{var X,te,ye;if(!(!T||!(A!=null&&A.ok))){if(!ba.current){let _e=!1;try{_e=window.localStorage.getItem(Rh)==="0",window.localStorage.removeItem(Rh)}catch{}_e&&((X=A.prefs)==null?void 0:X.autoUpdate)!==!1?(xa(!1),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:!1})}).catch(()=>{})):xa(((te=A.prefs)==null?void 0:te.autoUpdate)!==!1)}al(((ye=A.prefs)==null?void 0:ye.notifications)===!0),ol(A.notificationsVetoed===!0)}}).catch(()=>{}),()=>{T=!1}},[]);const Ic=w.useRef(()=>{}),il=w.useCallback(()=>{const T=!Bo;al(T),T&&typeof Notification<"u"&&Notification.permission==="default"&&Ic.current(),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({notifications:T})}).then(A=>A.ok?A.json():null).then(A=>{var X;A!=null&&A.ok&&(al(((X=A.prefs)==null?void 0:X.notifications)===!0),ol(A.notificationsVetoed===!0))}).catch(()=>{})},[Bo]),_d=typeof Notification<"u";w.useEffect(()=>{if(!St)return;const A=setTimeout(()=>zn(null),St==="blocked"?8e3:4e3);return()=>clearTimeout(A)},[St]);const ta=w.useCallback(()=>{typeof Notification>"u"||Notification.requestPermission().then(T=>{const A=T;Bn(A),A==="granted"?zn("on"):A==="denied"&&zn("blocked")})},[]);Ic.current=ta;const na=w.useRef(new Set),$c=w.useRef(null),zo=_t.map(T=>kf(T.id,T.waiting)).join("|");w.useEffect(()=>{A6($c.current,yn)&&($c.current=yn,na.current=xm(_t))},[yn]);const Uo=w.useRef(!1);return w.useEffect(()=>{M6(Uo.current,_a)&&(Uo.current=!0,na.current=xm(_t))},[_a]),w.useEffect(()=>{if(typeof Notification>"u"||Notification.permission!=="granted"||!I6($c.current,_a))return;const T=typeof document>"u"||!document.hidden,A=T6(_t,na.current,T,Bo);for(const X of A)try{const te=new Notification(X.title,{body:X.body,tag:X.key});te.onclick=()=>{window.focus(),Qn(X.sessionId),te.close()}}catch{}na.current=T?xm(_t):R6(_t,A,na.current)},[zo,_a]),o.jsxs("div",{className:"app",children:[o.jsx("a",{className:"skip-link",href:"#canvas",children:"Skip to the canvas"}),o.jsxs("header",{className:"topbar",children:[o.jsxs("div",{className:"readout",children:[o.jsxs("div",{className:"brand",children:[o.jsx("span",{className:"logo"}),o.jsx("h1",{children:dn}),Qt?(()=>{const T=SK(kK()??io,Qt.version);return o.jsxs("button",{type:"button",className:"v ready",onClick:pa,"aria-haspopup":"dialog","aria-label":T.label,title:T.title,children:[T.text,o.jsx("span",{className:"v-dot","aria-hidden":!0})]})})():ht?o.jsxs("button",{type:"button",className:"v stale",onClick:()=>{pa(),oc()},"aria-haspopup":"dialog","aria-label":ZY({...ht,open:ma}),title:ht.kind==="restart"?`Running v${ht.from}; v${ht.to} is installed on disk. Restart to pick it up · click for what's new`:`Running v${ht.from}; v${ht.to} is on npm · click for what's new`,children:["v",ht.from,o.jsx("span",{className:"v-dot","aria-hidden":!0})]}):(()=>{const T={running:io,latest:xe==null?void 0:xe.latest,latestPending:xe==null?void 0:xe.latestPending,checkedAgo:xe!=null&&xe.checkedAt?Ph(Jt-xe.checkedAt):null,checkFailedAgo:xe!=null&&xe.checkFailedAt&&xe.checkFailedAt>(xe.checkedAt??0)?Ph(Jt-xe.checkFailedAt):null,checkDisabled:xe==null?void 0:xe.checkDisabled,checking:tt};return o.jsxs("button",{type:"button",className:tt?"v checking":"v",onClick:()=>{pa(),gt(!0)},"aria-busy":tt||void 0,"aria-haspopup":"dialog","aria-label":XY(T),title:YY(T),children:["v",T.running]})})()]}),o.jsxs("span",{className:"status",children:[(()=>{const T=dX({connected:Lt,paused:go,held:En.size,dropped:En.dropped});return T.resting?null:o.jsx("span",{className:`pill ${T.tone}`,title:T.title,children:o.jsxs("span",{className:"pill-box",children:[o.jsx("span",{className:"pill-widest","aria-hidden":!0,children:T.widest}),o.jsx("span",{className:"pill-label",children:T.label})]})})})(),o.jsxs("span",{ref:z,className:"month-usage",title:G?`${G.tokens.toLocaleString()} tokens · ${fR(G.cost)} spent since the 1st of this local calendar month`:U?"Monthly usage is unavailable — ccusage could not be read":"Loading usage since the 1st of this local calendar month",children:[o.jsx("span",{className:"month-usage-label",children:"this month"}),G?o.jsxs(o.Fragment,{children:[o.jsx("b",{children:Bt(G.tokens)}),o.jsx("span",{className:"month-usage-unit",children:"tokens"}),o.jsx("span",{className:"month-usage-sep","aria-hidden":!0,children:"·"}),o.jsx("b",{children:fR(G.cost)})]}):o.jsx("span",{className:"month-usage-pending",children:U?"unavailable":"…"})]})]}),o.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:as}),o.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:jd}),_t.length>0&&o.jsxs("button",{type:"button",className:"waiting-stat",onClick:()=>{Tr.current=_t[0].id,Qn(_t[0].id)},title:`Blocked waiting for you — click, or press W, to go to the one that has been stuck longest:
291
+ ${_t.map(T=>` ${T.label}: ${Vl(T.waiting)} (${Ph(Jt-T.waiting.since)})`).join(`
292
+ `)}`,"aria-label":`${_t.length} session${_t.length===1?"":"s"} waiting for you`,children:[o.jsx("span",{className:"ap-pulse","aria-hidden":!0}),o.jsx("b",{children:_t.length})," ",o.jsx("span",{className:"ws-word",children:"waiting"})]}),St&&o.jsx("span",{className:St==="on"?"notify-said":"notify-said notify-said-blocked",role:"status",title:St==="on"?"The deck will raise a system notification when a session blocks on you and this tab is in the background":"Notifications are blocked for this page. Only your browser can undo that — its site settings for this address",children:St==="on"?"notifications on":"notifications blocked"})]}),Cn&&(()=>{const T=ir(Cn),A=Math.max(0,((Cn.endedAt??Jt)-Cn.startedAt)/1e3),X=Cn.state==="active"?Nb(T.total,A):null,te=S.size-1;return o.jsxs("button",{type:"button",className:"selected-ribbon",title:`Zoom to ${Cn.label} and its session (Z)${T.total>0?`
293
+ ${ut(T.total)} spent${X?` · ${X}`:""}`:""}`,onClick:()=>{try{Fn(Cn.id)}catch{}},children:[o.jsx("span",{className:`state-pill state-${Cn.state}`,children:Cn.state==="active"?"live":Cn.state}),o.jsx("span",{className:"selected-label",children:Cn.label}),T.total>0&&o.jsxs("span",{className:"selected-cost",children:[ut(T.total),X?o.jsxs("span",{className:"selected-rate",children:[" · ",X]}):null]}),te>0&&o.jsxs("span",{className:"selected-extra",children:["+",te]}),o.jsx("span",{"aria-hidden":!0,className:"selected-close",onClick:ye=>{ye.stopPropagation(),R()},children:"×"})]})})(),o.jsxs("div",{className:"actions",children:[o.jsxs("div",{className:"action-run",children:[o.jsxs("button",{className:"btn icon-btn",onClick:fo,title:`${P?"Hide":"Show"} session list (L)`,"aria-label":"Toggle session list","aria-expanded":P,"aria-controls":P?"session-list":void 0,children:[o.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:[o.jsx("path",{d:"M5.4 3.6h6.6M5.4 7h6.6M5.4 10.4h6.6"}),o.jsx("path",{d:"M2.2 3.6h.2M2.2 7h.2M2.2 10.4h.2"})]}),o.jsx("span",{className:"tb-word",children:"Session list"})]}),o.jsxs("button",{className:"btn icon-btn",onClick:()=>F(T=>!T),title:`${W?"Hide":"Show"} usage panel (U)`,"aria-label":"Toggle usage panel","aria-expanded":W,"aria-controls":W?"usage-panel":void 0,children:[o.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:[o.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"}),o.jsx("path",{d:"M7 1.6v1.5M7 10.9v1.5"})]}),o.jsx("span",{className:"tb-word",children:"Usage"})]}),o.jsxs("button",{className:"btn icon-btn",onClick:()=>kr(T=>!T),title:"Usage history — ccusage (H)","aria-label":"Open usage history","aria-haspopup":"dialog",children:[o.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:[o.jsx("line",{x1:"3",y1:"11.5",x2:"3",y2:"7"}),o.jsx("line",{x1:"7",y1:"11.5",x2:"7",y2:"3"}),o.jsx("line",{x1:"11",y1:"11.5",x2:"11",y2:"8.5"})]}),o.jsx("span",{className:"tb-word",children:"History"})]})]}),o.jsxs("div",{className:"action-run",children:[Kn.claude&&o.jsxs("button",{className:"btn icon-btn",onClick:Gr,title:`${Ne?"Hide":"Show"} accounts (A)`,"aria-label":"Toggle accounts panel","aria-expanded":Ne,"aria-controls":Ne?"accounts-panel":void 0,children:[o.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:[o.jsx("circle",{cx:"7",cy:"4.6",r:"2.4"}),o.jsx("path",{d:"M2.4 12c0-2.3 2.1-3.7 4.6-3.7s4.6 1.4 4.6 3.7"})]}),o.jsx("span",{className:"tb-word",children:"Accounts"})]}),o.jsxs("button",{className:"btn icon-btn",onClick:()=>le(T=>!T),title:`${ie?"Hide":"Show"} this machine — cores, memory, temperature (S)`,"aria-label":"Toggle machine detail","aria-expanded":ie,"aria-controls":ie?"system-panel":void 0,children:[o.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:[o.jsx("rect",{x:"3.6",y:"3.6",width:"6.8",height:"6.8",rx:"1.2"}),o.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"})]}),o.jsx("span",{className:"tb-word",children:"Machine"})]}),o.jsxs("button",{className:"btn icon-btn bw-btn",onClick:()=>Ws(T=>!T),title:uc?"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, ${uc?"watching":"not watching"}`+(dr>0?`, ${dr} unread`:""),"aria-haspopup":"dialog",children:[o.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:[o.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"}),uc||dr>0?o.jsx("circle",{cx:"7",cy:"7",r:"1.8",fill:"currentColor",stroke:"none"}):o.jsx("line",{x1:"2.4",y1:"11.6",x2:"11.6",y2:"2.4"})]}),o.jsx("span",{className:"tb-word",children:"Browser watch"}),dr>0&&o.jsx("span",{className:"bw-badge","aria-hidden":!0,children:dr})]})]}),o.jsxs("div",{className:"action-run action-run-utility",children:[Kn.claude&&Te!==null&&o.jsxs("div",{className:"sound-slot",children:[o.jsxs("button",{ref:je,className:"btn icon-btn",onClick:()=>rn(T=>!T),...Qa(!1),title:aX(Kn,{on:Te===!0,locked:Vn==="locked",prefs:Le}),"aria-label":`Sound settings, ${Te?"on":"off"}`,"aria-haspopup":"dialog","aria-expanded":Dt,"aria-controls":Dt?"sound-menu":void 0,children:[o.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:[o.jsx("path",{d:"M3.2 5.2h2L7.8 3v8L5.2 8.8h-2z"}),Te?o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M9.8 5.4a2.4 2.4 0 0 1 0 3.2"}),o.jsx("path",{d:"M11.3 3.9a4.6 4.6 0 0 1 0 6.2"})]}):o.jsxs(o.Fragment,{children:[o.jsx("path",{d:"M10 5.6l2.6 2.8"}),o.jsx("path",{d:"M12.6 5.6L10 8.4"})]})]}),o.jsx("span",{className:"tb-word",children:"Sound"})]}),Dt&&o.jsx(EV,{onClose:()=>rn(!1),soundOn:Te===!0,onToggleSound:de,prefs:Le,onLevel:(T,A)=>rt(T,{level:A}),onFigure:(T,A)=>rt(T,{figure:A}),onPreview:T=>We(T),customAssets:Ye,customSelections:Ae,onBuiltInSelected:ke,onCustomSelected:dt,onImportCustom:ct,onCreateVoice:yt,onRenameCustom:Ot,onPreviewCustom:Xt,onDeleteCustom:zt,notifyOn:Bo,onToggleNotify:il,notifyVetoed:Mc,notifyPermission:_d?yn:"unsupported",onAskNotify:ta,openerRef:je})]}),o.jsxs("div",{className:"appearance-slot",children:[o.jsx("button",{ref:_n,className:"btn icon-btn",onClick:()=>{rn(!1),bt(T=>!T)},title:"Appearance settings","aria-label":`Appearance settings, ${Sa} theme, character ${vo?"shown":"hidden"}`,"aria-haspopup":"dialog","aria-expanded":xt,"aria-controls":xt?"appearance-menu":void 0,children:Sa==="dark"?o.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:[o.jsx("circle",{cx:"7",cy:"7",r:"2.5"}),o.jsx("path",{d:"M7 1.5v1.2M7 11.3v1.2M1.5 7h1.2M11.3 7h1.2M3.1 3.1l.85.85M10.05 10.05l.85.85M3.1 10.9l.85-.85M10.05 3.95l.85-.85"})]}):o.jsx("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:o.jsx("path",{d:"M11.8 8.4A5 5 0 1 1 5.6 2.2a4 4 0 0 0 6.2 6.2Z"})})}),xt&&o.jsx(KV,{theme:Sa,onTheme:ld,characterEnabled:vo,onToggleCharacter:()=>cd(T=>!T),fmVolume:Li,onFmVolume:np,fmMuted:Pi,onFmMuted:()=>rp(T=>!T),fmSource:Gs,onFmSource:bo,customFmStations:xo,unavailableFmStations:Ks,onAddFmStation:ap,onRenameFmStation:pd,onRemoveFmStation:md,onClose:()=>bt(!1)})]})]})]})]}),o.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:Mt?`${Mt.label} removed from the board.`:""}),hc?o.jsxs("div",{className:"ver-banner done",role:"status",children:[o.jsx("span",{className:"ver-dot"}),o.jsxs("strong",{children:["Restarted — now running v",hc,"."]}),o.jsx("span",{className:"ver-sub",children:"The canvas replayed from the event log."})]}):fd&&!Lt?o.jsxs("div",{className:"conn-banner",role:"alert",children:[o.jsx("span",{className:"conn-dot"}),Nr?yo==="npx"?"Fetching the new version with npx — this can take a minute…":`Restarting ${dn}…`:(()=>{const T=cX({connected:Lt,paused:go});return o.jsxs(o.Fragment,{children:[`Lost connection to the ${dn} server. Reconnecting…`,T&&o.jsx("span",{className:"conn-sub",children:T})]})})()]}):ma&&ht?o.jsxs("div",{className:`ver-banner ${ht.kind}`,role:"status",children:[o.jsx("span",{className:`ver-dot${id==null?"":" armed"}`}),ht.kind==="restart"?o.jsxs(o.Fragment,{children:[o.jsxs("strong",{children:["v",ht.to," is installed — this deck still runs v",ht.from,"."]}),xe!=null&&xe.canRestart?o.jsxs(o.Fragment,{children:[o.jsx("button",{type:"button",className:"ver-act",onClick:()=>wo(),...Qa(Nr),title:`Stop this process and bring it back on the same port. The canvas replays from the event log.
294
+
295
+ 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:Nr?"restarting…":od.label}),!Nr&&o.jsx("span",{className:"ver-sub",children:od.clause}),o.jsxs("label",{className:"ver-auto",children:[o.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":Pn,onClick:tp,"aria-label":"Auto-restart when idle",title:Pn?"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:o.jsx("span",{className:"switch-knob"})}),o.jsx("span",{"aria-hidden":!0,children:UU(Pn,id)})]})]}):o.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."})]}):o.jsxs(o.Fragment,{children:[o.jsxs("strong",{children:[dn," v",ht.to," is out — you are on v",ht.from,"."]}),(xe==null?void 0:xe.upgradeMode)==="install"&&On!=="failed"&&o.jsx("button",{type:"button",className:"ver-act",onClick:ed,...Qa(On==="running",On==="done"),title:`Runs ${((Lc=xe==null?void 0:xe.upgrade)==null?void 0:Lc.command)??(xe==null?void 0:xe.command)??"npm i -g"} here, then restarts once nothing is running.`,children:On==="running"?"installing…":On==="done"?"installed":"Update now"}),(xe==null?void 0:xe.upgradeMode)==="npx"&&(xe==null?void 0:xe.canRestart)&&o.jsx("button",{type:"button",className:"ver-act",onClick:()=>wo({upgrade:!0}),...Qa(Nr),title:`Runs ${xe==null?void 0:xe.command} and hands it this port. Nothing is installed globally — npx unpacks its own copy.`,children:Nr?"fetching…":On==="failed"?"Retry update":"Update & restart"}),On==="failed"?o.jsxs("span",{className:"ver-sub fail",title:((ra=xe==null?void 0:xe.upgrade)==null?void 0:ra.error)??"",children:[(xe==null?void 0:xe.upgradeMode)==="npx"?"update failed":"install failed",": ",((Pc=xe==null?void 0:xe.upgrade)==null?void 0:Pc.error)??"unknown error"," — run it yourself:"]}):(xe==null?void 0:xe.upgradeMode)==="npx"?o.jsx("span",{className:"ver-sub",children:xe!=null&&xe.canRestart?"npx cannot upgrade in place, so the deck re-runs:":i0.npx}):xe!=null&&xe.upgradeBlocked?o.jsx("span",{className:"ver-sub",children:Object.hasOwn(i0,xe.upgradeBlocked)?i0[xe.upgradeBlocked]:"cannot install from here"}):null,o.jsxs("button",{type:"button",className:"ver-cmd",onClick:lc,title:"Copy to clipboard",children:[o.jsx("code",{children:xe==null?void 0:xe.command}),o.jsx("span",{className:"ver-cmd-hint",children:De?"copied":"copy"})]})]}),o.jsx("button",{type:"button","aria-label":"Dismiss",className:"ver-close",onClick:uo,children:"×"})]}):Qu&&ft?o.jsxs("div",{className:"ver-banner",role:"status",children:[o.jsx("span",{className:"ver-dot"}),o.jsxs("strong",{children:[ft," still works — the deck is called ",dn," now."]}),xe!=null&&xe.renameFix?o.jsx("span",{className:"ver-sub",children:xe.renameFix}):null,o.jsx("button",{type:"button","aria-label":"Dismiss",className:"ver-close",onClick:Ju,children:"×"})]}):null,mh(Ge)&&Kn.claude&&o.jsx(LU,{leaving:Ge==="leaving",onClose:()=>Ie(!1)}),P&&o.jsx(Wq,{state:l.current,now:Jt,selectedIds:S,onSelect:$a,onClose:()=>B(!1),removedIds:jr,onBringBackAll:()=>{Zn([...c]),p(null)}}),o.jsxs("main",{id:"canvas",tabIndex:-1,className:`canvas-wrap${$t?" bubbling":""}${Qr?" dragging-any":""}${Ki&&Ao==="over"?" trash-hover":""}`,"data-lod":Xi,ref:Er,onMouseDownCapture:Co,onPointerDownCapture:Hi,onPointerUpCapture:Hi,onWheelCapture:Hi,onFocusCapture:T=>{const A=T.target;if(!n0(A)||Jr.current==null||Jr.current==="detail")return;const X=A.getAttribute("data-id");X&&l.current.agents.has(X)&&A.matches(":focus-visible")&&dR(X,A,"focus")},onBlurCapture:T=>{var X,te;const A=(te=(X=T.target).getAttribute)==null?void 0:te.call(X,"data-id");A&&Ka(A)},children:[qo===0&&(!Lt&&In?o.jsx(qX,{}):o.jsx(BX,{live:Lt,everConnected:fd,providers:Kn,workspace:Ni,onTour:()=>K(!0)})),(ts.length>1||mc.size>0)&&o.jsx("div",{ref:Ei,className:`cat-filter-bar${Ci?" occluded":""}`,role:"group","aria-label":"Filter tools by category",children:ts.map(T=>{const A=mc.has(T);return o.jsxs("button",{type:"button",className:`cat-filter${A?" off":""}`,onClick:()=>Ji(T),"aria-pressed":!A,title:`${A?"Show":"Hide"} ${hf[T]} tools`,children:[o.jsx(OX,{cat:T}),o.jsx("span",{className:"cat-name",children:hf[T]})]},T)})}),o.jsxs(qA,{nodes:Lo,edges:Qi,nodeTypes:pX,edgesFocusable:!1,edgeTypes:mX,fitView:!Oi,fitViewOptions:{padding:.25,duration:Ch({durationMs:wR,documentHidden:document.hidden})?wR:0},minZoom:E$,maxZoom:C$,panOnScroll:!0,nodesDraggable:!0,nodesConnectable:!1,selectionOnDrag:!1,nodeDragThreshold:5,disableKeyboardA11y:!0,deleteKeyCode:null,onNodeClick:(T,A)=>{if(A.type==="sessionGroup"){R();return}const X=A.type==="recapNote"?A.data.parentId:A.id;C(X,T.shiftKey,!1),!T.shiftKey&&(y&&v(!1),kd?window.setTimeout(()=>{try{Fn(X)}catch{}},80):Fn(X))},onPaneClick:()=>{Ka(),R()},onNodeDoubleClick:(T,A)=>{if(A.type!=="agent"&&A.type!=="recapNote")return;const X=A.type==="recapNote"?A.data.parentId:A.id;C(X,!1),window.setTimeout(()=>{try{Fn(X)}catch{}},80)},onNodeMouseEnter:(T,A)=>{A.type!=="agent"&&A.type!=="recapNote"||Ca.current||Jr.current==null||Jr.current==="detail"||dR(A.id,T.currentTarget)},onNodeMouseLeave:(T,A)=>Ka(A.id),onMoveStart:T=>{Ka(),Jx(Wi(T))&&(No.current+=1),Jx(Wi(T))&&Qs()},onMove:(T,A)=>{var te,ye;_s(),Jx(Wi(T))&&Qs(),(te=Er.current)==null||te.style.setProperty("--zoom",String(A.zoom));const X=AY(Jr.current,A.zoom,Rc());X!==Jr.current&&(Jr.current=X,(ye=Er.current)==null||ye.setAttribute("data-lod",X),Tc(X),X==="detail"&&Ka()),bc.current&&window.clearTimeout(bc.current),bc.current=window.setTimeout(()=>MX(A),250)},onNodeDragStart:(T,A)=>{var X,te;if(Ka(),ip(),Ca.current=!0,wa.current=new Map,Ec(!0),A.type==="agent"&&(Ia(((X=l.current.agents.get(A.id))==null?void 0:X.label)??""),Ma(!0)),vd("far"),_s(),Qs(),A.type==="sessionGroup"){const ye=(te=A.data)==null?void 0:te.sessionId,_e=new Map;if(ye)for(const Oe of mn){const Ve=Oe.data;(Ve==null?void 0:Ve.sessionId)===ye&&_e.set(Oe.id,{x:Oe.position.x,y:Oe.position.y})}$i.current={start:{x:A.position.x,y:A.position.y},members:_e};return}Gt.current.set(A.id,{x:A.position.x,y:A.position.y})},onNodeDrag:(T,A)=>{var X;if(_s(),A.type==="agent"&&vd(Mo(T)),A.type==="sessionGroup"){const te=$i.current;if(!te)return;const ye=A.position.x-te.start.x,_e=A.position.y-te.start.y;for(const[Ve,it]of te.members){const Ze={x:it.x+ye,y:it.y+_e};Gt.current.set(Ve,Ze),Kt.current.set(Ve,Ze)}const Oe=wa.current;if(Oe){for(const[Ve,it]of te.members)Oe.set(Ve,{x:it.x+ye,y:it.y+_e});Oe.set(A.id,{x:A.position.x,y:A.position.y})}Ri(Ve=>Ve+1);return}Gt.current.set(A.id,{x:A.position.x,y:A.position.y}),Kt.current.set(A.id,{x:A.position.x,y:A.position.y}),(X=wa.current)==null||X.set(A.id,{x:A.position.x,y:A.position.y}),Ri(te=>te+1)},onNodeDragStop:(T,A)=>{_s();const X=A.type==="agent"&&Mo(T)==="over";if(Ca.current=!1,wa.current=null,Ec(!1),Ma(!1),nd(te=>te+1),A.type==="sessionGroup"){const te=$i.current;if(te){const ye=A.position.x-te.start.x,_e=A.position.y-te.start.y;for(const[Oe,Ve]of te.members){const it={x:Ve.x+ye,y:Ve.y+_e};Gt.current.set(Oe,it),Kt.current.set(Oe,it)}}$i.current=null,Ah(Kt.current,Gt.current),nd(ye=>ye+1);return}if(Gt.current.set(A.id,{x:A.position.x,y:A.position.y}),Kt.current.set(A.id,{x:A.position.x,y:A.position.y}),X){Cr(A.id);return}Ah(Kt.current,Gt.current)},children:[o.jsx(M5,{gap:28,size:1,color:Xr["--grid-line"]}),o.jsx(Rq,{onFocusSession:Fn}),o.jsx(YF,{agents:l.current.agents,visibleAgentIds:_o,positions:Kt.current,pinned:Gt.current,measured:Sr.current,spotlight:_r,hiddenCategories:mc,now:Jt,onOpenTool:E}),Sc&&o.jsxs("div",{className:"autofit-chip",children:[o.jsx("span",{className:"autofit-state",title:"New sessions are not brought into view while you are moving it yourself",children:"Auto-fit off"}),o.jsx("button",{type:"button",className:"autofit-resume",onClick:Ea,title:"Bring new sessions into view again","aria-label":"Resume auto-fit",children:"Resume"})]}),o.jsxs(_5,{showInteractive:!1,showFitView:!1,showZoom:!1,children:[o.jsx(Lr,{onClick:()=>e.zoomIn(),title:"Zoom in","aria-label":"Zoom in",disabled:t,children:o.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:o.jsx("path",{d:"M12 5v14M5 12h14",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})})}),o.jsx(Lr,{onClick:()=>e.zoomOut(),title:"Zoom out","aria-label":"Zoom out",disabled:n,children:o.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:o.jsx("path",{d:"M5 12h14",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})})}),o.jsx(Lr,{onClick:Ea,title:Sc?"Recenter view + re-enable autofit":"Recenter view (autofit already on)","aria-label":"Recenter view","data-nudge":Sc?"":void 0,children:o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[o.jsx("circle",{cx:"12",cy:"12",r:"3.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),o.jsx("path",{d:"M12 2v4M12 18v4M2 12h4M18 12h4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})]})}),o.jsx(Lr,{"data-group-start":"",onClick:va,title:lX({paused:go,held:En.size,dropped:En.dropped}),"aria-label":iX,"aria-pressed":go,children:o.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:o.jsx("path",{d:"M9 5.5v13M15 5.5v13",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})})}),o.jsx(Lr,{onClick:gn,title:"Auto-arrange — clear pins (R)","aria-label":"Re-arrange the canvas",children:o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[o.jsx("rect",{x:"8.5",y:"2",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),o.jsx("rect",{x:"1.5",y:"17",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),o.jsx("rect",{x:"15.5",y:"17",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),o.jsx("path",{d:"M12 7v6.5M5 17v-3.5h14V17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]})}),o.jsx(Lr,{"data-group-start":"","data-danger":"",onClick:()=>rs("button"),title:"Clear the canvas and the server's event log — asks first (C)","aria-label":"Clear the canvas",children:o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[o.jsx("path",{d:"M4 6.2h16",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"}),o.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"}),o.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"}),o.jsx("path",{d:"M10.3 10.6v6.8M13.7 10.6v6.8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})]})}),o.jsx(Lr,{"data-group-start":"",onClick:()=>M(T=>!T),title:"Keyboard shortcuts (?)","aria-label":"Open the keyboard shortcuts","aria-haspopup":"dialog",children:o.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[o.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"}),o.jsx("path",{d:"M12 18.4v.2",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",fill:"none"})]})})]}),o.jsx(v5,{zoomable:!0,pannable:!0,nodeColor:ja,nodeStrokeWidth:2,maskColor:Xr["--minimap-mask"],maskStrokeColor:Xr["--line"]}),vo&&o.jsx(JG,{volume:Li,muted:Pi,source:Gs,playRequest:ud,customStation:xo.find(T=>yi(T.id)===Gs),onAvailabilityChange:ko})]}),mh(Cc)&&o.jsxs("div",{ref:xd,className:`drag-trash-zone ${Ao}${Cc==="leaving"?" leaving":""}`,role:"status",children:[o.jsx("svg",{className:"drag-trash-icon",viewBox:"0 0 24 24","aria-hidden":"true",children:o.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"})}),o.jsxs("span",{className:"drag-trash-copy",children:[o.jsx("span",{className:"drag-trash-text",children:Ao==="over"?o.jsxs(o.Fragment,{children:["Release to remove ",o.jsx("strong",{className:"drag-trash-name",children:Yi||"this card"})]}):"Drop here to remove from the board"}),o.jsx("span",{className:"drag-trash-hint",children:Ao==="over"?"The session list (L) brings it back":"The session keeps running"})]})]}),o.jsx(BY,{agentFor:el,recapFor:ss,labelFor:Sd,bounds:tl})]}),mh(Pe)&&o.jsx(j8,{state:l.current,now:Jt,providers:Kn,liveSince:_a,leaving:Pe==="leaving",onClose:()=>F(!1)}),mh(Be)&&o.jsx(sB,{usageOpen:W,leaving:Be==="leaving",onClose:()=>le(!1)}),y&&Cn?o.jsxs("aside",{className:"detail","aria-label":"Detail",children:[o.jsx("button",{type:"button",className:"glyph-btn detail-close",title:"Close panel","aria-label":"Close detail panel",onClick:()=>v(!1),children:"×"}),o.jsx(UX,{agent:Cn,now:Jt,onOpenTool:E,onShowSummary:O,onExportSession:T=>IX(l.current,T),onRemove:At})]}):null,Po&&o.jsx(vq,{tool:Po,onClose:()=>E(null)}),Kr&&o.jsx(w.Suspense,{fallback:null,children:o.jsx(hX,{providers:Kn,onClose:()=>kr(!1)})}),ga&&o.jsx(w.Suspense,{fallback:null,children:o.jsx(fX,{onClose:()=>Ws(!1),onSeen:T=>{rl(""),Jf(T);try{localStorage.setItem(oR,String(T))}catch{}},onWatching:dc,palette:Xr})}),H&&(()=>{const T=l.current.agents.get(H);return T?o.jsx(eF,{agent:T,onClose:()=>q(null)}):null})(),I&&o.jsx(zq,{state:l.current,sessionId:I,onClose:()=>O(null)}),ur&&o.jsx(EK,{entries:ur.entries,since:ur.since,firstRun:ur.firstRun,running:io,onClose:()=>sn(null),onTour:()=>{sn(null),K(!0)},updateVersion:Qt==null?void 0:Qt.version,updateBusy:fa,updateFailure:xr&&(!Qt||Qt.version===xr.version)?_K(xr.failure,xr.version):void 0,onUpdateRestart:Qt?()=>{ki(Qt.version)}:void 0,onRestart:!Qt&&(xe!=null&&xe.canRestart)?()=>{sn(null),wo()}:void 0}),(()=>{const{request:T,waiting:A}=uY(_i,td.current);return T?o.jsx(dY,{request:T,waiting:A,busy:Ss,now:Date.now(),onAccept:()=>void Vs("accept",T.fp),onDecline:()=>void Vs("dismiss",T.fp),onLater:()=>{Ss||(td.current.add(T.fp),mo(X=>[...X]))}}):null})(),ee&&o.jsx(W9,{onClose:()=>M(!1),onTour:()=>{M(!1),K(!0)}}),Z&&o.jsx(UM,{title:"What the deck shows you",steps:gz,onClose:()=>{K(!1),gK(nR()),hu()&&fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tourSeen:!0}),keepalive:!0}).catch(()=>{});const T=D.current;D.current=null,T&&sn(T)}}),V&&o.jsx(z9,{agentCount:qo,onConfirm:()=>rs("confirmation"),onCancel:()=>ne(!1)})]})}function qX(){return o.jsxs("div",{className:"empty-hero",children:[o.jsxs("div",{className:"orbit-stack","aria-hidden":!0,children:[o.jsx("div",{className:"core"}),o.jsxs("div",{className:"orbit r1",children:[o.jsx("span",{className:"dot"}),o.jsx("span",{className:"dot b"})]}),o.jsxs("div",{className:"orbit r2",children:[o.jsx("span",{className:"dot"}),o.jsx("span",{className:"dot b"})]}),o.jsxs("div",{className:"orbit r3",children:[o.jsx("span",{className:"dot"}),o.jsx("span",{className:"dot b"})]})]}),o.jsxs("h2",{children:["Too many ",dn," tabs are open"]}),o.jsxs("p",{children:["This browser keeps at most six live connections to one address, and other ",o.jsx("code",{children:dn})," tabs are holding them. Close one and this tab connects on its own."]})]})}function BX({live:e,everConnected:t,providers:n,workspace:r,onTour:s}){const l=!e;return o.jsxs("div",{className:"empty-hero",children:[o.jsxs("div",{className:"orbit-stack","aria-hidden":!0,children:[o.jsx("div",{className:"core"}),o.jsxs("div",{className:"orbit r1",children:[o.jsx("span",{className:"dot"}),o.jsx("span",{className:"dot b"})]}),o.jsxs("div",{className:"orbit r2",children:[o.jsx("span",{className:"dot"}),o.jsx("span",{className:"dot b"})]}),o.jsxs("div",{className:"orbit r3",children:[o.jsx("span",{className:"dot"}),o.jsx("span",{className:"dot b"})]})]}),l?o.jsxs(o.Fragment,{children:[o.jsx("h2",{children:t?"Disconnected from server":"Server unreachable"}),o.jsxs("p",{children:[t?"This page lost its connection to ":"This page cannot reach ",o.jsx("code",{children:dn}),". Check that it is still running in your terminal — the page picks up again on its own."]})]}):zX(n,r),!l&&o.jsx("button",{type:"button",className:"btn empty-tour",onClick:s,children:"Take the tour"})]})}function zX(e,t){const n=JY(t);return o.jsxs(o.Fragment,{children:[o.jsx("h2",{children:"Waiting for Claude Code or Codex"}),n.kind==="scoped"?o.jsxs("p",{children:[n.lead," ",o.jsx("code",{children:n.workspace}),n.tail]}):o.jsxs("p",{children:["Run ",o.jsx("code",{children:"claude"})," or ",o.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."]}),sX(e).map(r=>o.jsx("p",{className:"hint-row",children:r.spans.map((s,l)=>s.code?o.jsx("code",{children:s.text},l):o.jsx("span",{children:s.text},l))},r.provider))]})}function UX({agent:e,now:t,onOpenTool:n,onShowSummary:r,onExportSession:s,onRemove:l}){const c=`${e.synthetic?"≥ ":""}${Ul(e.startedAt,e.endedAt,t)}`,u=ir(e),f=u.total>0,p=e.usage.inputTokens+e.usage.outputTokens,h=new Map;for(const b of e.tools){const _=z$(b.name);h.set(_,(h.get(_)??0)+1)}const m=e.tools.filter(b=>b.ok===!1).length,y=e.tools.filter(b=>!b.endedAt).length,v=Array.from(h.entries()).sort((b,_)=>_[1]-b[1]),S=h.has("mcp")?HF(e.tools.map(b=>b.name)):null;return o.jsxs(o.Fragment,{children:[o.jsxs("header",{className:"detail-hero",children:[o.jsxs("div",{className:"hero-line",children:[o.jsx("span",{className:`state-pill state-${e.state}`,children:e.state==="active"?"live":e.state}),o.jsx("h2",{className:"hero-title",title:e.cwd??e.label,children:e.label})]}),o.jsxs("div",{className:"hero-meta",children:[o.jsx("span",{className:"hero-meta-item",children:e.kind==="root"?"session":"subagent"}),o.jsx("span",{className:"hero-sep",children:"·"}),o.jsx("span",{className:"hero-meta-item",title:`started ${new Date(e.startedAt).toLocaleString()}`,children:c}),e.model&&(()=>{const b=rM(e);return o.jsxs(o.Fragment,{children:[o.jsx("span",{className:"hero-sep",children:"·"}),o.jsxs("span",{className:"model-chip","data-family":bf(e.model),title:b.length>0?`${e.model}
296
+ spend on this panel also covers:
297
+ ${b.join(`
298
+ `)}`:e.model,children:[so(e.model),b.length>0?` +${b.length}`:""]})]})})()]}),f&&o.jsxs("div",{className:"hero-cost",children:[o.jsxs("div",{className:"hero-cost-headline",children:[o.jsx("span",{className:"hero-cost-value",children:ut(u.total)}),o.jsx("span",{className:"hero-cost-label",children:"spend"})]}),o.jsx(Ab,{cost:u})]}),o.jsxs("div",{className:"hero-actions",children:[e.kind==="root"&&e.state==="done"&&r&&o.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&&o.jsx("button",{type:"button",className:"btn hero-action-btn",onClick:()=>s(e.sessionId),title:"Download this session as JSON",children:"Export JSON"}),l&&o.jsx("button",{type:"button",className:"btn hero-action-btn",onClick:l,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 b=jf(e);if(!b)return null;const _=Jh(b.at,t);return o.jsxs("section",{className:"detail-section",children:[o.jsxs("h3",{children:["Recap ",o.jsx("span",{className:"section-count",title:_.title,children:_.label})]}),o.jsx("p",{className:"detail-recap",children:b.text})]})})(),e.tools.length>0&&o.jsxs("section",{className:"detail-section",children:[o.jsx("h3",{children:"Activity"}),o.jsxs("div",{className:"activity-row",children:[o.jsxs("div",{className:"activity-counters",children:[o.jsxs("span",{className:"ac-item",children:[o.jsx("b",{children:e.toolCount})," calls"]}),y>0&&o.jsxs("span",{className:"ac-item ac-live",children:[o.jsx("b",{children:y})," live"]}),m>0&&o.jsxs("span",{className:"ac-item ac-err",children:[o.jsx("b",{children:m})," err"]})]}),o.jsx("div",{className:"cat-strip",children:v.map(([b,_])=>{const k=b==="mcp"?S:null,j=k==null?void 0:k.hue,E=`${_} ${hf[b]} call${_===1?"":"s"}`;return o.jsxs("span",{className:`cat-chip cat-${b}${j!=null?" mcp-hue":""}`,style:j!=null?{"--mcp-hue":j}:void 0,title:k?`${E}, all to ${k.label}`:E,children:[o.jsx("span",{className:"cat-emoji","aria-hidden":!0,children:B$[b]}),o.jsx("span",{className:"cat-name",children:hf[b]}),o.jsx("span",{className:"cat-count",children:_}),k&&o.jsx("span",{className:"cat-server",children:k.label})]},b)})})]})]}),p>0&&o.jsxs("section",{className:"detail-section",children:[o.jsx("h3",{children:"Tokens"}),o.jsxs("div",{className:"tokens-grid",children:[o.jsxs("div",{children:[o.jsx("span",{className:"k",children:"in"}),o.jsx("b",{title:e.usage.inputTokens.toLocaleString(),children:Bt(e.usage.inputTokens)})]}),o.jsxs("div",{children:[o.jsx("span",{className:"k",children:"out"}),o.jsx("b",{title:e.usage.outputTokens.toLocaleString(),children:Bt(e.usage.outputTokens)})]}),o.jsxs("div",{children:[o.jsx("span",{className:"k",children:"cache r"}),o.jsx("b",{title:e.usage.cacheReadTokens.toLocaleString(),children:Bt(e.usage.cacheReadTokens)})]}),o.jsxs("div",{children:[o.jsx("span",{className:"k",children:"cache c"}),o.jsx("b",{title:e.usage.cacheCreateTokens.toLocaleString(),children:Bt(e.usage.cacheCreateTokens)})]})]})]}),o.jsxs("section",{className:"detail-section",children:[o.jsx("h3",{children:"Identity"}),o.jsxs("div",{children:[e.cwd&&o.jsxs("div",{className:"row",children:[o.jsx("span",{className:"k",children:"cwd"}),o.jsx("span",{className:"v",title:e.cwd,children:e.cwd})]}),o.jsxs("div",{className:"row",children:[o.jsx("span",{className:"k",children:"session"}),o.jsxs("span",{className:"v",children:[e.sessionId.slice(0,12),"…"]})]}),e.parentId&&o.jsxs("div",{className:"row",children:[o.jsx("span",{className:"k",children:"parent"}),o.jsxs("span",{className:"v",children:[e.parentId.slice(0,12),"…"]})]})]})]}),e.prompts.length>0&&o.jsxs("section",{className:"detail-section",children:[o.jsxs("h3",{children:["Prompts ",o.jsx("span",{className:"section-count",children:VA(e.prompts).length})]}),o.jsx("div",{className:"prompts",children:e.prompts.slice().reverse().map((b,_)=>{const k=Jh(b.at,t),j=bb(b.text);return j?o.jsxs("details",{className:"prompt-entry prompt-injected",children:[o.jsxs("summary",{children:[o.jsx("span",{className:"prompt-time",title:k.title,children:k.label}),o.jsx("span",{className:"prompt-injected-label",children:j.label})]}),j.detail&&o.jsx("div",{className:"prompt-injected-detail",children:j.detail})]},_):o.jsxs("div",{className:"prompt-entry",children:[o.jsx("div",{className:"prompt-time",title:k.title,children:k.label}),o.jsx("div",{className:"prompt-text",children:b.text})]},_)})})]}),o.jsxs("section",{className:"detail-section",children:[o.jsxs("h3",{children:["Tool calls ",o.jsx("span",{className:"section-count",children:e.tools.length})]}),e.tools.length===0&&o.jsx("div",{className:"empty",children:"No tool calls yet."}),o.jsx("div",{children:e.tools.slice().reverse().map(b=>o.jsx(WX,{t:b,onClick:()=>n(b.id)},b.id))})]})]})}const HX={inflight:"in-flight",done:"done",err:"error"};function WX({t:e,onClick:t}){const n=e.endedAt==null?"inflight":e.ok===!1?"err":"done",r=aM(e,"…");return o.jsxs("button",{className:"tool clickable",title:e.inputPreview||e.name,onClick:t,children:[o.jsxs("span",{className:"name",children:[o.jsx("span",{className:`status-dot ${n}`,"aria-hidden":!0}),o.jsx("span",{className:"vis-hidden",children:HX[n]}),e.name]}),o.jsx("span",{style:{color:"var(--muted)"},children:r})]})}try{oF(window.localStorage)}catch{}const VX=TO.createRoot(document.getElementById("root"));VX.render(o.jsx(LX,{}));export{oR as S,nX as a,KX as b,Au as c,Bt as d,GX as e,ut as f,so as g,Ps as h,hi as i,o as j,cY as k,jS as p,w as r,Qa as s,pn as u};