ccdeck 3.42.0 → 3.43.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.
- package/README.md +35 -17
- package/dist/web/assets/BrowserWatchModal-BPws0psH.js +1 -0
- package/dist/web/assets/RadioPanel-CDl7ZImm.js +1 -0
- package/dist/web/assets/TrafficRadar-D1hp6BgZ.js +1 -0
- package/dist/web/assets/UsageHistoryModal-DPcdpBpI.js +1 -0
- package/dist/web/assets/app-9p127oSR.js +310 -0
- package/dist/web/assets/app-DsHSufBt.css +1 -0
- package/dist/web/assets/index-Bkx27-wy.js +1 -0
- package/dist/web/index.html +5 -2
- package/package.json +1 -1
- package/release-notes.json +22 -0
- package/src/server/account-choice.mjs +198 -0
- package/src/server/account-notify.mjs +15 -8
- package/src/server/account-routes.mjs +6 -0
- package/src/server/activity.mjs +11 -3
- package/src/server/claude-recovery.mjs +150 -0
- package/src/server/codex-enrichment.mjs +11 -3
- package/src/server/codex-lineage.mjs +29 -0
- package/src/server/codex-recovery.mjs +83 -0
- package/src/server/codex-translate.mjs +24 -0
- package/src/server/codex-watch.mjs +113 -9
- package/src/server/cswap-auto-choice.mjs +296 -0
- package/src/server/cswap-auto-loop.mjs +18 -2
- package/src/server/cswap-auto-readers.mjs +5 -2
- package/src/server/cswap-auto.mjs +7 -1
- package/src/server/deck-prefs.mjs +5 -1
- package/src/server/event-pipeline.mjs +4 -3
- package/src/server/evicted-enrichment.mjs +2 -0
- package/src/server/index.mjs +9 -0
- package/src/server/pinned-build.mjs +4 -0
- package/src/server/traffic-radar-config.mjs +8 -1
- package/dist/web/assets/BrowserWatchModal-TdSBv7_T.js +0 -1
- package/dist/web/assets/RadioPanel-bJc004IK.js +0 -1
- package/dist/web/assets/TrafficRadar-pRTWTOpJ.js +0 -1
- package/dist/web/assets/UsageHistoryModal-BBAEDRj9.js +0 -1
- package/dist/web/assets/index-BPLXy9SO.css +0 -1
- package/dist/web/assets/index-DzDnLqDX.js +0 -307
|
@@ -1,307 +0,0 @@
|
|
|
1
|
-
var u6=Object.defineProperty;var d6=(e,t,n)=>t in e?u6(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Mm=(e,t,n)=>d6(e,typeof t!="symbol"?t+"":t,n);(function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))r(s);new MutationObserver(s=>{for(const o of s)if(o.type==="childList")for(const i of o.addedNodes)i.tagName==="LINK"&&i.rel==="modulepreload"&&r(i)}).observe(document,{childList:!0,subtree:!0});function n(s){const o={};return s.integrity&&(o.integrity=s.integrity),s.referrerPolicy&&(o.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?o.credentials="include":s.crossOrigin==="anonymous"?o.credentials="omit":o.credentials="same-origin",o}function r(s){if(s.ep)return;s.ep=!0;const o=n(s);fetch(s.href,o)}})();var md=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function fk(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var $m={exports:{}},zl={},Lm={exports:{}},We={};/**
|
|
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 sS;function h6(){if(sS)return We;sS=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),r=Symbol.for("react.strict_mode"),s=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),i=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),d=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),p=Symbol.iterator;function g(M){return M===null||typeof M!="object"?null:(M=p&&M[p]||M["@@iterator"],typeof M=="function"?M:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},k=Object.assign,j={};function v(M,V,Z){this.props=M,this.context=V,this.refs=j,this.updater=Z||w}v.prototype.isReactComponent={},v.prototype.setState=function(M,V){if(typeof M!="object"&&typeof M!="function"&&M!=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,M,V,"setState")},v.prototype.forceUpdate=function(M){this.updater.enqueueForceUpdate(this,M,"forceUpdate")};function b(){}b.prototype=v.prototype;function N(M,V,Z){this.props=M,this.context=V,this.refs=j,this.updater=Z||w}var S=N.prototype=new b;S.constructor=N,k(S,v.prototype),S.isPureReactComponent=!0;var E=Array.isArray,C=Object.prototype.hasOwnProperty,$={current:null},T={key:!0,ref:!0,__self:!0,__source:!0};function I(M,V,Z){var W,X={},Y=null,J=null;if(V!=null)for(W in V.ref!==void 0&&(J=V.ref),V.key!==void 0&&(Y=""+V.key),V)C.call(V,W)&&!T.hasOwnProperty(W)&&(X[W]=V[W]);var ee=arguments.length-2;if(ee===1)X.children=Z;else if(1<ee){for(var ne=Array(ee),se=0;se<ee;se++)ne[se]=arguments[se+2];X.children=ne}if(M&&M.defaultProps)for(W in ee=M.defaultProps,ee)X[W]===void 0&&(X[W]=ee[W]);return{$$typeof:e,type:M,key:Y,ref:J,props:X,_owner:$.current}}function O(M,V){return{$$typeof:e,type:M.type,key:V,ref:M.ref,props:M.props,_owner:M._owner}}function U(M){return typeof M=="object"&&M!==null&&M.$$typeof===e}function P(M){var V={"=":"=0",":":"=2"};return"$"+M.replace(/[=:]/g,function(Z){return V[Z]})}var L=/\/+/g;function F(M,V){return typeof M=="object"&&M!==null&&M.key!=null?P(""+M.key):V.toString(36)}function A(M,V,Z,W,X){var Y=typeof M;(Y==="undefined"||Y==="boolean")&&(M=null);var J=!1;if(M===null)J=!0;else switch(Y){case"string":case"number":J=!0;break;case"object":switch(M.$$typeof){case e:case t:J=!0}}if(J)return J=M,X=X(J),M=W===""?"."+F(J,0):W,E(X)?(Z="",M!=null&&(Z=M.replace(L,"$&/")+"/"),A(X,V,Z,"",function(se){return se})):X!=null&&(U(X)&&(X=O(X,Z+(!X.key||J&&J.key===X.key?"":(""+X.key).replace(L,"$&/")+"/")+M)),V.push(X)),1;if(J=0,W=W===""?".":W+":",E(M))for(var ee=0;ee<M.length;ee++){Y=M[ee];var ne=W+F(Y,ee);J+=A(Y,V,Z,ne,X)}else if(ne=g(M),typeof ne=="function")for(M=ne.call(M),ee=0;!(Y=M.next()).done;)Y=Y.value,ne=W+F(Y,ee++),J+=A(Y,V,Z,ne,X);else if(Y==="object")throw V=String(M),Error("Objects are not valid as a React child (found: "+(V==="[object Object]"?"object with keys {"+Object.keys(M).join(", ")+"}":V)+"). If you meant to render a collection of children, use an array instead.");return J}function B(M,V,Z){if(M==null)return M;var W=[],X=0;return A(M,W,"","",function(Y){return V.call(Z,Y,X++)}),W}function D(M){if(M._status===-1){var V=M._result;V=V(),V.then(function(Z){(M._status===0||M._status===-1)&&(M._status=1,M._result=Z)},function(Z){(M._status===0||M._status===-1)&&(M._status=2,M._result=Z)}),M._status===-1&&(M._status=0,M._result=V)}if(M._status===1)return M._result.default;throw M._result}var K={current:null},G={transition:null},H={ReactCurrentDispatcher:K,ReactCurrentBatchConfig:G,ReactCurrentOwner:$};function q(){throw Error("act(...) is not supported in production builds of React.")}return We.Children={map:B,forEach:function(M,V,Z){B(M,function(){V.apply(this,arguments)},Z)},count:function(M){var V=0;return B(M,function(){V++}),V},toArray:function(M){return B(M,function(V){return V})||[]},only:function(M){if(!U(M))throw Error("React.Children.only expected to receive a single React element child.");return M}},We.Component=v,We.Fragment=n,We.Profiler=s,We.PureComponent=N,We.StrictMode=r,We.Suspense=d,We.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=H,We.act=q,We.cloneElement=function(M,V,Z){if(M==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+M+".");var W=k({},M.props),X=M.key,Y=M.ref,J=M._owner;if(V!=null){if(V.ref!==void 0&&(Y=V.ref,J=$.current),V.key!==void 0&&(X=""+V.key),M.type&&M.type.defaultProps)var ee=M.type.defaultProps;for(ne in V)C.call(V,ne)&&!T.hasOwnProperty(ne)&&(W[ne]=V[ne]===void 0&&ee!==void 0?ee[ne]:V[ne])}var ne=arguments.length-2;if(ne===1)W.children=Z;else if(1<ne){ee=Array(ne);for(var se=0;se<ne;se++)ee[se]=arguments[se+2];W.children=ee}return{$$typeof:e,type:M.type,key:X,ref:Y,props:W,_owner:J}},We.createContext=function(M){return M={$$typeof:i,_currentValue:M,_currentValue2:M,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},M.Provider={$$typeof:o,_context:M},M.Consumer=M},We.createElement=I,We.createFactory=function(M){var V=I.bind(null,M);return V.type=M,V},We.createRef=function(){return{current:null}},We.forwardRef=function(M){return{$$typeof:c,render:M}},We.isValidElement=U,We.lazy=function(M){return{$$typeof:f,_payload:{_status:-1,_result:M},_init:D}},We.memo=function(M,V){return{$$typeof:h,type:M,compare:V===void 0?null:V}},We.startTransition=function(M){var V=G.transition;G.transition={};try{M()}finally{G.transition=V}},We.unstable_act=q,We.useCallback=function(M,V){return K.current.useCallback(M,V)},We.useContext=function(M){return K.current.useContext(M)},We.useDebugValue=function(){},We.useDeferredValue=function(M){return K.current.useDeferredValue(M)},We.useEffect=function(M,V){return K.current.useEffect(M,V)},We.useId=function(){return K.current.useId()},We.useImperativeHandle=function(M,V,Z){return K.current.useImperativeHandle(M,V,Z)},We.useInsertionEffect=function(M,V){return K.current.useInsertionEffect(M,V)},We.useLayoutEffect=function(M,V){return K.current.useLayoutEffect(M,V)},We.useMemo=function(M,V){return K.current.useMemo(M,V)},We.useReducer=function(M,V,Z){return K.current.useReducer(M,V,Z)},We.useRef=function(M){return K.current.useRef(M)},We.useState=function(M){return K.current.useState(M)},We.useSyncExternalStore=function(M,V,Z){return K.current.useSyncExternalStore(M,V,Z)},We.useTransition=function(){return K.current.useTransition()},We.version="18.3.1",We}var aS;function zc(){return aS||(aS=1,Lm.exports=h6()),Lm.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 oS;function f6(){if(oS)return zl;oS=1;var e=zc(),t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),r=Object.prototype.hasOwnProperty,s=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,o={key:!0,ref:!0,__self:!0,__source:!0};function i(c,d,h){var f,p={},g=null,w=null;h!==void 0&&(g=""+h),d.key!==void 0&&(g=""+d.key),d.ref!==void 0&&(w=d.ref);for(f in d)r.call(d,f)&&!o.hasOwnProperty(f)&&(p[f]=d[f]);if(c&&c.defaultProps)for(f in d=c.defaultProps,d)p[f]===void 0&&(p[f]=d[f]);return{$$typeof:t,type:c,key:g,ref:w,props:p,_owner:s.current}}return zl.Fragment=n,zl.jsx=i,zl.jsxs=i,zl}var iS;function p6(){return iS||(iS=1,$m.exports=f6()),$m.exports}var a=p6(),gd={},Om={exports:{}},bn={},Im={exports:{}},Pm={};/**
|
|
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 lS;function m6(){return lS||(lS=1,(function(e){function t(G,H){var q=G.length;G.push(H);e:for(;0<q;){var M=q-1>>>1,V=G[M];if(0<s(V,H))G[M]=H,G[q]=V,q=M;else break e}}function n(G){return G.length===0?null:G[0]}function r(G){if(G.length===0)return null;var H=G[0],q=G.pop();if(q!==H){G[0]=q;e:for(var M=0,V=G.length,Z=V>>>1;M<Z;){var W=2*(M+1)-1,X=G[W],Y=W+1,J=G[Y];if(0>s(X,q))Y<V&&0>s(J,X)?(G[M]=J,G[Y]=q,M=Y):(G[M]=X,G[W]=q,M=W);else if(Y<V&&0>s(J,q))G[M]=J,G[Y]=q,M=Y;else break e}}return H}function s(G,H){var q=G.sortIndex-H.sortIndex;return q!==0?q:G.id-H.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var i=Date,c=i.now();e.unstable_now=function(){return i.now()-c}}var d=[],h=[],f=1,p=null,g=3,w=!1,k=!1,j=!1,v=typeof setTimeout=="function"?setTimeout:null,b=typeof clearTimeout=="function"?clearTimeout:null,N=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function S(G){for(var H=n(h);H!==null;){if(H.callback===null)r(h);else if(H.startTime<=G)r(h),H.sortIndex=H.expirationTime,t(d,H);else break;H=n(h)}}function E(G){if(j=!1,S(G),!k)if(n(d)!==null)k=!0,D(C);else{var H=n(h);H!==null&&K(E,H.startTime-G)}}function C(G,H){k=!1,j&&(j=!1,b(I),I=-1),w=!0;var q=g;try{for(S(H),p=n(d);p!==null&&(!(p.expirationTime>H)||G&&!P());){var M=p.callback;if(typeof M=="function"){p.callback=null,g=p.priorityLevel;var V=M(p.expirationTime<=H);H=e.unstable_now(),typeof V=="function"?p.callback=V:p===n(d)&&r(d),S(H)}else r(d);p=n(d)}if(p!==null)var Z=!0;else{var W=n(h);W!==null&&K(E,W.startTime-H),Z=!1}return Z}finally{p=null,g=q,w=!1}}var $=!1,T=null,I=-1,O=5,U=-1;function P(){return!(e.unstable_now()-U<O)}function L(){if(T!==null){var G=e.unstable_now();U=G;var H=!0;try{H=T(!0,G)}finally{H?F():($=!1,T=null)}}else $=!1}var F;if(typeof N=="function")F=function(){N(L)};else if(typeof MessageChannel<"u"){var A=new MessageChannel,B=A.port2;A.port1.onmessage=L,F=function(){B.postMessage(null)}}else F=function(){v(L,0)};function D(G){T=G,$||($=!0,F())}function K(G,H){I=v(function(){G(e.unstable_now())},H)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(G){G.callback=null},e.unstable_continueExecution=function(){k||w||(k=!0,D(C))},e.unstable_forceFrameRate=function(G){0>G||125<G?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):O=0<G?Math.floor(1e3/G):5},e.unstable_getCurrentPriorityLevel=function(){return g},e.unstable_getFirstCallbackNode=function(){return n(d)},e.unstable_next=function(G){switch(g){case 1:case 2:case 3:var H=3;break;default:H=g}var q=g;g=H;try{return G()}finally{g=q}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(G,H){switch(G){case 1:case 2:case 3:case 4:case 5:break;default:G=3}var q=g;g=G;try{return H()}finally{g=q}},e.unstable_scheduleCallback=function(G,H,q){var M=e.unstable_now();switch(typeof q=="object"&&q!==null?(q=q.delay,q=typeof q=="number"&&0<q?M+q:M):q=M,G){case 1:var V=-1;break;case 2:V=250;break;case 5:V=1073741823;break;case 4:V=1e4;break;default:V=5e3}return V=q+V,G={id:f++,callback:H,priorityLevel:G,startTime:q,expirationTime:V,sortIndex:-1},q>M?(G.sortIndex=q,t(h,G),n(d)===null&&G===n(h)&&(j?(b(I),I=-1):j=!0,K(E,q-M))):(G.sortIndex=V,t(d,G),k||w||(k=!0,D(C))),G},e.unstable_shouldYield=P,e.unstable_wrapCallback=function(G){var H=g;return function(){var q=g;g=H;try{return G.apply(this,arguments)}finally{g=q}}}})(Pm)),Pm}var cS;function g6(){return cS||(cS=1,Im.exports=m6()),Im.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 uS;function y6(){if(uS)return bn;uS=1;var e=zc(),t=g6();function n(l){for(var u="https://reactjs.org/docs/error-decoder.html?invariant="+l,m=1;m<arguments.length;m++)u+="&args[]="+encodeURIComponent(arguments[m]);return"Minified React error #"+l+"; visit "+u+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}var r=new Set,s={};function o(l,u){i(l,u),i(l+"Capture",u)}function i(l,u){for(s[l]=u,l=0;l<u.length;l++)r.add(u[l])}var c=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),d=Object.prototype.hasOwnProperty,h=/^[:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][:A-Z_a-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\-.0-9\u00B7\u0300-\u036F\u203F-\u2040]*$/,f={},p={};function g(l){return d.call(p,l)?!0:d.call(f,l)?!1:h.test(l)?p[l]=!0:(f[l]=!0,!1)}function w(l,u,m,x){if(m!==null&&m.type===0)return!1;switch(typeof u){case"function":case"symbol":return!0;case"boolean":return x?!1:m!==null?!m.acceptsBooleans:(l=l.toLowerCase().slice(0,5),l!=="data-"&&l!=="aria-");default:return!1}}function k(l,u,m,x){if(u===null||typeof u>"u"||w(l,u,m,x))return!0;if(x)return!1;if(m!==null)switch(m.type){case 3:return!u;case 4:return u===!1;case 5:return isNaN(u);case 6:return isNaN(u)||1>u}return!1}function j(l,u,m,x,_,R,z){this.acceptsBooleans=u===2||u===3||u===4,this.attributeName=x,this.attributeNamespace=_,this.mustUseProperty=m,this.propertyName=l,this.type=u,this.sanitizeURL=R,this.removeEmptyString=z}var v={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(l){v[l]=new j(l,0,!1,l,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(l){var u=l[0];v[u]=new j(u,1,!1,l[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(l){v[l]=new j(l,2,!1,l.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(l){v[l]=new j(l,2,!1,l,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(l){v[l]=new j(l,3,!1,l.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(l){v[l]=new j(l,3,!0,l,null,!1,!1)}),["capture","download"].forEach(function(l){v[l]=new j(l,4,!1,l,null,!1,!1)}),["cols","rows","size","span"].forEach(function(l){v[l]=new j(l,6,!1,l,null,!1,!1)}),["rowSpan","start"].forEach(function(l){v[l]=new j(l,5,!1,l.toLowerCase(),null,!1,!1)});var b=/[\-:]([a-z])/g;function N(l){return l[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(l){var u=l.replace(b,N);v[u]=new j(u,1,!1,l,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(l){var u=l.replace(b,N);v[u]=new j(u,1,!1,l,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(l){var u=l.replace(b,N);v[u]=new j(u,1,!1,l,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(l){v[l]=new j(l,1,!1,l.toLowerCase(),null,!1,!1)}),v.xlinkHref=new j("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(l){v[l]=new j(l,1,!1,l.toLowerCase(),null,!0,!0)});function S(l,u,m,x){var _=v.hasOwnProperty(u)?v[u]:null;(_!==null?_.type!==0:x||!(2<u.length)||u[0]!=="o"&&u[0]!=="O"||u[1]!=="n"&&u[1]!=="N")&&(k(u,m,_,x)&&(m=null),x||_===null?g(u)&&(m===null?l.removeAttribute(u):l.setAttribute(u,""+m)):_.mustUseProperty?l[_.propertyName]=m===null?_.type===3?!1:"":m:(u=_.attributeName,x=_.attributeNamespace,m===null?l.removeAttribute(u):(_=_.type,m=_===3||_===4&&m===!0?"":""+m,x?l.setAttributeNS(x,u,m):l.setAttribute(u,m))))}var E=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,C=Symbol.for("react.element"),$=Symbol.for("react.portal"),T=Symbol.for("react.fragment"),I=Symbol.for("react.strict_mode"),O=Symbol.for("react.profiler"),U=Symbol.for("react.provider"),P=Symbol.for("react.context"),L=Symbol.for("react.forward_ref"),F=Symbol.for("react.suspense"),A=Symbol.for("react.suspense_list"),B=Symbol.for("react.memo"),D=Symbol.for("react.lazy"),K=Symbol.for("react.offscreen"),G=Symbol.iterator;function H(l){return l===null||typeof l!="object"?null:(l=G&&l[G]||l["@@iterator"],typeof l=="function"?l:null)}var q=Object.assign,M;function V(l){if(M===void 0)try{throw Error()}catch(m){var u=m.stack.trim().match(/\n( *(at )?)/);M=u&&u[1]||""}return`
|
|
34
|
-
`+M+l}var Z=!1;function W(l,u){if(!l||Z)return"";Z=!0;var m=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(u)if(u=function(){throw Error()},Object.defineProperty(u.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(u,[])}catch(ue){var x=ue}Reflect.construct(l,[],u)}else{try{u.call()}catch(ue){x=ue}l.call(u.prototype)}else{try{throw Error()}catch(ue){x=ue}l()}}catch(ue){if(ue&&x&&typeof ue.stack=="string"){for(var _=ue.stack.split(`
|
|
35
|
-
`),R=x.stack.split(`
|
|
36
|
-
`),z=_.length-1,Q=R.length-1;1<=z&&0<=Q&&_[z]!==R[Q];)Q--;for(;1<=z&&0<=Q;z--,Q--)if(_[z]!==R[Q]){if(z!==1||Q!==1)do if(z--,Q--,0>Q||_[z]!==R[Q]){var te=`
|
|
37
|
-
`+_[z].replace(" at new "," at ");return l.displayName&&te.includes("<anonymous>")&&(te=te.replace("<anonymous>",l.displayName)),te}while(1<=z&&0<=Q);break}}}finally{Z=!1,Error.prepareStackTrace=m}return(l=l?l.displayName||l.name:"")?V(l):""}function X(l){switch(l.tag){case 5:return V(l.type);case 16:return V("Lazy");case 13:return V("Suspense");case 19:return V("SuspenseList");case 0:case 2:case 15:return l=W(l.type,!1),l;case 11:return l=W(l.type.render,!1),l;case 1:return l=W(l.type,!0),l;default:return""}}function Y(l){if(l==null)return null;if(typeof l=="function")return l.displayName||l.name||null;if(typeof l=="string")return l;switch(l){case T:return"Fragment";case $:return"Portal";case O:return"Profiler";case I:return"StrictMode";case F:return"Suspense";case A:return"SuspenseList"}if(typeof l=="object")switch(l.$$typeof){case P:return(l.displayName||"Context")+".Consumer";case U:return(l._context.displayName||"Context")+".Provider";case L:var u=l.render;return l=l.displayName,l||(l=u.displayName||u.name||"",l=l!==""?"ForwardRef("+l+")":"ForwardRef"),l;case B:return u=l.displayName||null,u!==null?u:Y(l.type)||"Memo";case D:u=l._payload,l=l._init;try{return Y(l(u))}catch{}}return null}function J(l){var u=l.type;switch(l.tag){case 24:return"Cache";case 9:return(u.displayName||"Context")+".Consumer";case 10:return(u._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return l=u.render,l=l.displayName||l.name||"",u.displayName||(l!==""?"ForwardRef("+l+")":"ForwardRef");case 7:return"Fragment";case 5:return u;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Y(u);case 8:return u===I?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof u=="function")return u.displayName||u.name||null;if(typeof u=="string")return u}return null}function ee(l){switch(typeof l){case"boolean":case"number":case"string":case"undefined":return l;case"object":return l;default:return""}}function ne(l){var u=l.type;return(l=l.nodeName)&&l.toLowerCase()==="input"&&(u==="checkbox"||u==="radio")}function se(l){var u=ne(l)?"checked":"value",m=Object.getOwnPropertyDescriptor(l.constructor.prototype,u),x=""+l[u];if(!l.hasOwnProperty(u)&&typeof m<"u"&&typeof m.get=="function"&&typeof m.set=="function"){var _=m.get,R=m.set;return Object.defineProperty(l,u,{configurable:!0,get:function(){return _.call(this)},set:function(z){x=""+z,R.call(this,z)}}),Object.defineProperty(l,u,{enumerable:m.enumerable}),{getValue:function(){return x},setValue:function(z){x=""+z},stopTracking:function(){l._valueTracker=null,delete l[u]}}}}function ce(l){l._valueTracker||(l._valueTracker=se(l))}function de(l){if(!l)return!1;var u=l._valueTracker;if(!u)return!0;var m=u.getValue(),x="";return l&&(x=ne(l)?l.checked?"true":"false":l.value),l=x,l!==m?(u.setValue(l),!0):!1}function ae(l){if(l=l||(typeof document<"u"?document:void 0),typeof l>"u")return null;try{return l.activeElement||l.body}catch{return l.body}}function pe(l,u){var m=u.checked;return q({},u,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:m??l._wrapperState.initialChecked})}function fe(l,u){var m=u.defaultValue==null?"":u.defaultValue,x=u.checked!=null?u.checked:u.defaultChecked;m=ee(u.value!=null?u.value:m),l._wrapperState={initialChecked:x,initialValue:m,controlled:u.type==="checkbox"||u.type==="radio"?u.checked!=null:u.value!=null}}function Ee(l,u){u=u.checked,u!=null&&S(l,"checked",u,!1)}function ye(l,u){Ee(l,u);var m=ee(u.value),x=u.type;if(m!=null)x==="number"?(m===0&&l.value===""||l.value!=m)&&(l.value=""+m):l.value!==""+m&&(l.value=""+m);else if(x==="submit"||x==="reset"){l.removeAttribute("value");return}u.hasOwnProperty("value")?we(l,u.type,m):u.hasOwnProperty("defaultValue")&&we(l,u.type,ee(u.defaultValue)),u.checked==null&&u.defaultChecked!=null&&(l.defaultChecked=!!u.defaultChecked)}function oe(l,u,m){if(u.hasOwnProperty("value")||u.hasOwnProperty("defaultValue")){var x=u.type;if(!(x!=="submit"&&x!=="reset"||u.value!==void 0&&u.value!==null))return;u=""+l._wrapperState.initialValue,m||u===l.value||(l.value=u),l.defaultValue=u}m=l.name,m!==""&&(l.name=""),l.defaultChecked=!!l._wrapperState.initialChecked,m!==""&&(l.name=m)}function we(l,u,m){(u!=="number"||ae(l.ownerDocument)!==l)&&(m==null?l.defaultValue=""+l._wrapperState.initialValue:l.defaultValue!==""+m&&(l.defaultValue=""+m))}var Ne=Array.isArray;function ge(l,u,m,x){if(l=l.options,u){u={};for(var _=0;_<m.length;_++)u["$"+m[_]]=!0;for(m=0;m<l.length;m++)_=u.hasOwnProperty("$"+l[m].value),l[m].selected!==_&&(l[m].selected=_),_&&x&&(l[m].defaultSelected=!0)}else{for(m=""+ee(m),u=null,_=0;_<l.length;_++){if(l[_].value===m){l[_].selected=!0,x&&(l[_].defaultSelected=!0);return}u!==null||l[_].disabled||(u=l[_])}u!==null&&(u.selected=!0)}}function Ae(l,u){if(u.dangerouslySetInnerHTML!=null)throw Error(n(91));return q({},u,{value:void 0,defaultValue:void 0,children:""+l._wrapperState.initialValue})}function Oe(l,u){var m=u.value;if(m==null){if(m=u.children,u=u.defaultValue,m!=null){if(u!=null)throw Error(n(92));if(Ne(m)){if(1<m.length)throw Error(n(93));m=m[0]}u=m}u==null&&(u=""),m=u}l._wrapperState={initialValue:ee(m)}}function qe(l,u){var m=ee(u.value),x=ee(u.defaultValue);m!=null&&(m=""+m,m!==l.value&&(l.value=m),u.defaultValue==null&&l.defaultValue!==m&&(l.defaultValue=m)),x!=null&&(l.defaultValue=""+x)}function Me(l){var u=l.textContent;u===l._wrapperState.initialValue&&u!==""&&u!==null&&(l.value=u)}function He(l){switch(l){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 rt(l,u){return l==null||l==="http://www.w3.org/1999/xhtml"?He(u):l==="http://www.w3.org/2000/svg"&&u==="foreignObject"?"http://www.w3.org/1999/xhtml":l}var Ue,it=(function(l){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(u,m,x,_){MSApp.execUnsafeLocalFunction(function(){return l(u,m,x,_)})}:l})(function(l,u){if(l.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in l)l.innerHTML=u;else{for(Ue=Ue||document.createElement("div"),Ue.innerHTML="<svg>"+u.valueOf().toString()+"</svg>",u=Ue.firstChild;l.firstChild;)l.removeChild(l.firstChild);for(;u.firstChild;)l.appendChild(u.firstChild)}});function Et(l,u){if(u){var m=l.firstChild;if(m&&m===l.lastChild&&m.nodeType===3){m.nodeValue=u;return}}l.textContent=u}var st={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},ht=["Webkit","ms","Moz","O"];Object.keys(st).forEach(function(l){ht.forEach(function(u){u=u+l.charAt(0).toUpperCase()+l.substring(1),st[u]=st[l]})});function ft(l,u,m){return u==null||typeof u=="boolean"||u===""?"":m||typeof u!="number"||u===0||st.hasOwnProperty(l)&&st[l]?(""+u).trim():u+"px"}function Be(l,u){l=l.style;for(var m in u)if(u.hasOwnProperty(m)){var x=m.indexOf("--")===0,_=ft(m,u[m],x);m==="float"&&(m="cssFloat"),x?l.setProperty(m,_):l[m]=_}}var Kt=q({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 at(l,u){if(u){if(Kt[l]&&(u.children!=null||u.dangerouslySetInnerHTML!=null))throw Error(n(137,l));if(u.dangerouslySetInnerHTML!=null){if(u.children!=null)throw Error(n(60));if(typeof u.dangerouslySetInnerHTML!="object"||!("__html"in u.dangerouslySetInnerHTML))throw Error(n(61))}if(u.style!=null&&typeof u.style!="object")throw Error(n(62))}}function At(l,u){if(l.indexOf("-")===-1)return typeof u.is=="string";switch(l){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 et=null;function pt(l){return l=l.target||l.srcElement||window,l.correspondingUseElement&&(l=l.correspondingUseElement),l.nodeType===3?l.parentNode:l}var jt=null,wt=null,tt=null;function Ct(l){if(l=Rl(l)){if(typeof jt!="function")throw Error(n(280));var u=l.stateNode;u&&(u=Ru(u),jt(l.stateNode,l.type,u))}}function Tn(l){wt?tt?tt.push(l):tt=[l]:wt=l}function Mt(){if(wt){var l=wt,u=tt;if(tt=wt=null,Ct(l),u)for(l=0;l<u.length;l++)Ct(u[l])}}function an(l,u){return l(u)}function fn(){}var pn=!1;function Rn(l,u,m){if(pn)return l(u,m);pn=!0;try{return an(l,u,m)}finally{pn=!1,(wt!==null||tt!==null)&&(fn(),Mt())}}function Yt(l,u){var m=l.stateNode;if(m===null)return null;var x=Ru(m);if(x===null)return null;m=x[u];e:switch(u){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(x=!x.disabled)||(l=l.type,x=!(l==="button"||l==="input"||l==="select"||l==="textarea")),l=!x;break e;default:l=!1}if(l)return null;if(m&&typeof m!="function")throw Error(n(231,u,typeof m));return m}var An=!1;if(c)try{var je={};Object.defineProperty(je,"passive",{get:function(){An=!0}}),window.addEventListener("test",je,je),window.removeEventListener("test",je,je)}catch{An=!1}function $e(l,u,m,x,_,R,z,Q,te){var ue=Array.prototype.slice.call(arguments,3);try{u.apply(m,ue)}catch(ve){this.onError(ve)}}var De=!1,lt=null,Wt=!1,is=null,Ma={onError:function(l){De=!0,lt=l}};function ls(l,u,m,x,_,R,z,Q,te){De=!1,lt=null,$e.apply(Ma,arguments)}function Ds(l,u,m,x,_,R,z,Q,te){if(ls.apply(this,arguments),De){if(De){var ue=lt;De=!1,lt=null}else throw Error(n(198));Wt||(Wt=!0,is=ue)}}function mn(l){var u=l,m=l;if(l.alternate)for(;u.return;)u=u.return;else{l=u;do u=l,(u.flags&4098)!==0&&(m=u.return),l=u.return;while(l)}return u.tag===3?m:null}function It(l){if(l.tag===13){var u=l.memoizedState;if(u===null&&(l=l.alternate,l!==null&&(u=l.memoizedState)),u!==null)return u.dehydrated}return null}function Fs(l){if(mn(l)!==l)throw Error(n(188))}function $r(l){var u=l.alternate;if(!u){if(u=mn(l),u===null)throw Error(n(188));return u!==l?null:l}for(var m=l,x=u;;){var _=m.return;if(_===null)break;var R=_.alternate;if(R===null){if(x=_.return,x!==null){m=x;continue}break}if(_.child===R.child){for(R=_.child;R;){if(R===m)return Fs(_),l;if(R===x)return Fs(_),u;R=R.sibling}throw Error(n(188))}if(m.return!==x.return)m=_,x=R;else{for(var z=!1,Q=_.child;Q;){if(Q===m){z=!0,m=_,x=R;break}if(Q===x){z=!0,x=_,m=R;break}Q=Q.sibling}if(!z){for(Q=R.child;Q;){if(Q===m){z=!0,m=R,x=_;break}if(Q===x){z=!0,x=R,m=_;break}Q=Q.sibling}if(!z)throw Error(n(189))}}if(m.alternate!==x)throw Error(n(190))}if(m.tag!==3)throw Error(n(188));return m.stateNode.current===m?l:u}function Lr(l){return l=$r(l),l!==null?ur(l):null}function ur(l){if(l.tag===5||l.tag===6)return l;for(l=l.child;l!==null;){var u=ur(l);if(u!==null)return u;l=l.sibling}return null}var Bs=t.unstable_scheduleCallback,cs=t.unstable_cancelCallback,dr=t.unstable_shouldYield,qs=t.unstable_requestPaint,me=t.unstable_now,Xe=t.unstable_getCurrentPriorityLevel,Ze=t.unstable_ImmediatePriority,Mn=t.unstable_UserBlockingPriority,Or=t.unstable_NormalPriority,$n=t.unstable_LowPriority,Us=t.unstable_IdlePriority,hr=null,Nt=null;function Ir(l){if(Nt&&typeof Nt.onCommitFiberRoot=="function")try{Nt.onCommitFiberRoot(hr,l,void 0,(l.current.flags&128)===128)}catch{}}var en=Math.clz32?Math.clz32:tp,Qf=Math.log,ep=Math.LN2;function tp(l){return l>>>=0,l===0?32:31-(Qf(l)/ep|0)|0}var $a=64,La=4194304;function Oa(l){switch(l&-l){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 l&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return l&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return l}}function Ia(l,u){var m=l.pendingLanes;if(m===0)return 0;var x=0,_=l.suspendedLanes,R=l.pingedLanes,z=m&268435455;if(z!==0){var Q=z&~_;Q!==0?x=Oa(Q):(R&=z,R!==0&&(x=Oa(R)))}else z=m&~_,z!==0?x=Oa(z):R!==0&&(x=Oa(R));if(x===0)return 0;if(u!==0&&u!==x&&(u&_)===0&&(_=x&-x,R=u&-u,_>=R||_===16&&(R&4194240)!==0))return u;if((x&4)!==0&&(x|=m&16),u=l.entangledLanes,u!==0)for(l=l.entanglements,u&=x;0<u;)m=31-en(u),_=1<<m,x|=l[m],u&=~_;return x}function uu(l,u){switch(l){case 1:case 2:case 4:return u+250;case 8:case 16:case 32:case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:return u+5e3;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return-1;case 134217728:case 268435456:case 536870912:case 1073741824:return-1;default:return-1}}function Pr(l,u){for(var m=l.suspendedLanes,x=l.pingedLanes,_=l.expirationTimes,R=l.pendingLanes;0<R;){var z=31-en(R),Q=1<<z,te=_[z];te===-1?((Q&m)===0||(Q&x)!==0)&&(_[z]=uu(Q,u)):te<=u&&(l.expiredLanes|=Q),R&=~Q}}function cl(l){return l=l.pendingLanes&-1073741825,l!==0?l:l&1073741824?1073741824:0}function du(){var l=$a;return $a<<=1,($a&4194240)===0&&($a=64),l}function Po(l){for(var u=[],m=0;31>m;m++)u.push(l);return u}function Hs(l,u,m){l.pendingLanes|=u,u!==536870912&&(l.suspendedLanes=0,l.pingedLanes=0),l=l.eventTimes,u=31-en(u),l[u]=m}function ul(l,u){var m=l.pendingLanes&~u;l.pendingLanes=u,l.suspendedLanes=0,l.pingedLanes=0,l.expiredLanes&=u,l.mutableReadLanes&=u,l.entangledLanes&=u,u=l.entanglements;var x=l.eventTimes;for(l=l.expirationTimes;0<m;){var _=31-en(m),R=1<<_;u[_]=0,x[_]=-1,l[_]=-1,m&=~R}}function Pa(l,u){var m=l.entangledLanes|=u;for(l=l.entanglements;m;){var x=31-en(m),_=1<<x;_&u|l[x]&u&&(l[x]|=u),m&=~_}}var Ke=0;function hu(l){return l&=-l,1<l?4<l?(l&268435455)!==0?16:536870912:4:1}var fu,dl,hl,us,pu,Do=!1,Da=[],Gn=null,Dr=null,Fr=null,ds=new Map,Ws=new Map,Br=[],np="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 mu(l,u){switch(l){case"focusin":case"focusout":Gn=null;break;case"dragenter":case"dragleave":Dr=null;break;case"mouseover":case"mouseout":Fr=null;break;case"pointerover":case"pointerout":ds.delete(u.pointerId);break;case"gotpointercapture":case"lostpointercapture":Ws.delete(u.pointerId)}}function hs(l,u,m,x,_,R){return l===null||l.nativeEvent!==R?(l={blockedOn:u,domEventName:m,eventSystemFlags:x,nativeEvent:R,targetContainers:[_]},u!==null&&(u=Rl(u),u!==null&&dl(u)),l):(l.eventSystemFlags|=x,u=l.targetContainers,_!==null&&u.indexOf(_)===-1&&u.push(_),l)}function rp(l,u,m,x,_){switch(u){case"focusin":return Gn=hs(Gn,l,u,m,x,_),!0;case"dragenter":return Dr=hs(Dr,l,u,m,x,_),!0;case"mouseover":return Fr=hs(Fr,l,u,m,x,_),!0;case"pointerover":var R=_.pointerId;return ds.set(R,hs(ds.get(R)||null,l,u,m,x,_)),!0;case"gotpointercapture":return R=_.pointerId,Ws.set(R,hs(Ws.get(R)||null,l,u,m,x,_)),!0}return!1}function fl(l){var u=Ga(l.target);if(u!==null){var m=mn(u);if(m!==null){if(u=m.tag,u===13){if(u=It(m),u!==null){l.blockedOn=u,pu(l.priority,function(){hl(m)});return}}else if(u===3&&m.stateNode.current.memoizedState.isDehydrated){l.blockedOn=m.tag===3?m.stateNode.containerInfo:null;return}}}l.blockedOn=null}function Fo(l){if(l.blockedOn!==null)return!1;for(var u=l.targetContainers;0<u.length;){var m=Bo(l.domEventName,l.eventSystemFlags,u[0],l.nativeEvent);if(m===null){m=l.nativeEvent;var x=new m.constructor(m.type,m);et=x,m.target.dispatchEvent(x),et=null}else return u=Rl(m),u!==null&&dl(u),l.blockedOn=m,!1;u.shift()}return!0}function gu(l,u,m){Fo(l)&&m.delete(u)}function sp(){Do=!1,Gn!==null&&Fo(Gn)&&(Gn=null),Dr!==null&&Fo(Dr)&&(Dr=null),Fr!==null&&Fo(Fr)&&(Fr=null),ds.forEach(gu),Ws.forEach(gu)}function zs(l,u){l.blockedOn===u&&(l.blockedOn=null,Do||(Do=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,sp)))}function Fa(l){function u(_){return zs(_,l)}if(0<Da.length){zs(Da[0],l);for(var m=1;m<Da.length;m++){var x=Da[m];x.blockedOn===l&&(x.blockedOn=null)}}for(Gn!==null&&zs(Gn,l),Dr!==null&&zs(Dr,l),Fr!==null&&zs(Fr,l),ds.forEach(u),Ws.forEach(u),m=0;m<Br.length;m++)x=Br[m],x.blockedOn===l&&(x.blockedOn=null);for(;0<Br.length&&(m=Br[0],m.blockedOn===null);)fl(m),m.blockedOn===null&&Br.shift()}var Vs=E.ReactCurrentBatchConfig,Ba=!0;function qa(l,u,m,x){var _=Ke,R=Vs.transition;Vs.transition=null;try{Ke=1,qr(l,u,m,x)}finally{Ke=_,Vs.transition=R}}function pl(l,u,m,x){var _=Ke,R=Vs.transition;Vs.transition=null;try{Ke=4,qr(l,u,m,x)}finally{Ke=_,Vs.transition=R}}function qr(l,u,m,x){if(Ba){var _=Bo(l,u,m,x);if(_===null)kp(l,u,x,fs,m),mu(l,x);else if(rp(_,l,u,m,x))x.stopPropagation();else if(mu(l,x),u&4&&-1<np.indexOf(l)){for(;_!==null;){var R=Rl(_);if(R!==null&&fu(R),R=Bo(l,u,m,x),R===null&&kp(l,u,x,fs,m),R===_)break;_=R}_!==null&&x.stopPropagation()}else kp(l,u,x,null,m)}}var fs=null;function Bo(l,u,m,x){if(fs=null,l=pt(x),l=Ga(l),l!==null)if(u=mn(l),u===null)l=null;else if(m=u.tag,m===13){if(l=It(u),l!==null)return l;l=null}else if(m===3){if(u.stateNode.current.memoizedState.isDehydrated)return u.tag===3?u.stateNode.containerInfo:null;l=null}else u!==l&&(l=null);return fs=l,null}function ml(l){switch(l){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(Xe()){case Ze:return 1;case Mn:return 4;case Or:case $n:return 16;case Us:return 536870912;default:return 16}default:return 16}}var fr=null,Ua=null,qo=null;function Uo(){if(qo)return qo;var l,u=Ua,m=u.length,x,_="value"in fr?fr.value:fr.textContent,R=_.length;for(l=0;l<m&&u[l]===_[l];l++);var z=m-l;for(x=1;x<=z&&u[m-x]===_[R-x];x++);return qo=_.slice(l,1<x?1-x:void 0)}function Ha(l){var u=l.keyCode;return"charCode"in l?(l=l.charCode,l===0&&u===13&&(l=13)):l=u,l===10&&(l=13),32<=l||l===13?l:0}function Wa(){return!0}function yu(){return!1}function on(l){function u(m,x,_,R,z){this._reactName=m,this._targetInst=_,this.type=x,this.nativeEvent=R,this.target=z,this.currentTarget=null;for(var Q in l)l.hasOwnProperty(Q)&&(m=l[Q],this[Q]=m?m(R):R[Q]);return this.isDefaultPrevented=(R.defaultPrevented!=null?R.defaultPrevented:R.returnValue===!1)?Wa:yu,this.isPropagationStopped=yu,this}return q(u.prototype,{preventDefault:function(){this.defaultPrevented=!0;var m=this.nativeEvent;m&&(m.preventDefault?m.preventDefault():typeof m.returnValue!="unknown"&&(m.returnValue=!1),this.isDefaultPrevented=Wa)},stopPropagation:function(){var m=this.nativeEvent;m&&(m.stopPropagation?m.stopPropagation():typeof m.cancelBubble!="unknown"&&(m.cancelBubble=!0),this.isPropagationStopped=Wa)},persist:function(){},isPersistent:Wa}),u}var Ur={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(l){return l.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Gs=on(Ur),za=q({},Ur,{view:0,detail:0}),Ks=on(za),gl,yl,Va,Ys=q({},za,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:vl,button:0,buttons:0,relatedTarget:function(l){return l.relatedTarget===void 0?l.fromElement===l.srcElement?l.toElement:l.fromElement:l.relatedTarget},movementX:function(l){return"movementX"in l?l.movementX:(l!==Va&&(Va&&l.type==="mousemove"?(gl=l.screenX-Va.screenX,yl=l.screenY-Va.screenY):yl=gl=0,Va=l),gl)},movementY:function(l){return"movementY"in l?l.movementY:yl}}),wl=on(Ys),ap=q({},Ys,{dataTransfer:0}),wu=on(ap),Xs=q({},za,{relatedTarget:0}),Ho=on(Xs),xl=q({},Ur,{animationName:0,elapsedTime:0,pseudoElement:0}),op=on(xl),ps=q({},Ur,{clipboardData:function(l){return"clipboardData"in l?l.clipboardData:window.clipboardData}}),xu=on(ps),vu=q({},Ur,{data:0}),bu=on(vu),ku={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},ip={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"},lp={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Hr(l){var u=this.nativeEvent;return u.getModifierState?u.getModifierState(l):(l=lp[l])?!!u[l]:!1}function vl(){return Hr}var cp=q({},za,{key:function(l){if(l.key){var u=ku[l.key]||l.key;if(u!=="Unidentified")return u}return l.type==="keypress"?(l=Ha(l),l===13?"Enter":String.fromCharCode(l)):l.type==="keydown"||l.type==="keyup"?ip[l.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:vl,charCode:function(l){return l.type==="keypress"?Ha(l):0},keyCode:function(l){return l.type==="keydown"||l.type==="keyup"?l.keyCode:0},which:function(l){return l.type==="keypress"?Ha(l):l.type==="keydown"||l.type==="keyup"?l.keyCode:0}}),up=on(cp),dp=q({},Ys,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),Ln=on(dp),QD=q({},za,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:vl}),e5=on(QD),t5=q({},Ur,{propertyName:0,elapsedTime:0,pseudoElement:0}),n5=on(t5),r5=q({},Ys,{deltaX:function(l){return"deltaX"in l?l.deltaX:"wheelDeltaX"in l?-l.wheelDeltaX:0},deltaY:function(l){return"deltaY"in l?l.deltaY:"wheelDeltaY"in l?-l.wheelDeltaY:"wheelDelta"in l?-l.wheelDelta:0},deltaZ:0,deltaMode:0}),s5=on(r5),a5=[9,13,27,32],hp=c&&"CompositionEvent"in window,bl=null;c&&"documentMode"in document&&(bl=document.documentMode);var o5=c&&"TextEvent"in window&&!bl,X1=c&&(!hp||bl&&8<bl&&11>=bl),Z1=" ",J1=!1;function Q1(l,u){switch(l){case"keyup":return a5.indexOf(u.keyCode)!==-1;case"keydown":return u.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function ej(l){return l=l.detail,typeof l=="object"&&"data"in l?l.data:null}var Wo=!1;function i5(l,u){switch(l){case"compositionend":return ej(u);case"keypress":return u.which!==32?null:(J1=!0,Z1);case"textInput":return l=u.data,l===Z1&&J1?null:l;default:return null}}function l5(l,u){if(Wo)return l==="compositionend"||!hp&&Q1(l,u)?(l=Uo(),qo=Ua=fr=null,Wo=!1,l):null;switch(l){case"paste":return null;case"keypress":if(!(u.ctrlKey||u.altKey||u.metaKey)||u.ctrlKey&&u.altKey){if(u.char&&1<u.char.length)return u.char;if(u.which)return String.fromCharCode(u.which)}return null;case"compositionend":return X1&&u.locale!=="ko"?null:u.data;default:return null}}var c5={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 tj(l){var u=l&&l.nodeName&&l.nodeName.toLowerCase();return u==="input"?!!c5[l.type]:u==="textarea"}function nj(l,u,m,x){Tn(x),u=Eu(u,"onChange"),0<u.length&&(m=new Gs("onChange","change",null,m,x),l.push({event:m,listeners:u}))}var kl=null,jl=null;function u5(l){vj(l,0)}function ju(l){var u=Yo(l);if(de(u))return l}function d5(l,u){if(l==="change")return u}var rj=!1;if(c){var fp;if(c){var pp="oninput"in document;if(!pp){var sj=document.createElement("div");sj.setAttribute("oninput","return;"),pp=typeof sj.oninput=="function"}fp=pp}else fp=!1;rj=fp&&(!document.documentMode||9<document.documentMode)}function aj(){kl&&(kl.detachEvent("onpropertychange",oj),jl=kl=null)}function oj(l){if(l.propertyName==="value"&&ju(jl)){var u=[];nj(u,jl,l,pt(l)),Rn(u5,u)}}function h5(l,u,m){l==="focusin"?(aj(),kl=u,jl=m,kl.attachEvent("onpropertychange",oj)):l==="focusout"&&aj()}function f5(l){if(l==="selectionchange"||l==="keyup"||l==="keydown")return ju(jl)}function p5(l,u){if(l==="click")return ju(u)}function m5(l,u){if(l==="input"||l==="change")return ju(u)}function g5(l,u){return l===u&&(l!==0||1/l===1/u)||l!==l&&u!==u}var pr=typeof Object.is=="function"?Object.is:g5;function Nl(l,u){if(pr(l,u))return!0;if(typeof l!="object"||l===null||typeof u!="object"||u===null)return!1;var m=Object.keys(l),x=Object.keys(u);if(m.length!==x.length)return!1;for(x=0;x<m.length;x++){var _=m[x];if(!d.call(u,_)||!pr(l[_],u[_]))return!1}return!0}function ij(l){for(;l&&l.firstChild;)l=l.firstChild;return l}function lj(l,u){var m=ij(l);l=0;for(var x;m;){if(m.nodeType===3){if(x=l+m.textContent.length,l<=u&&x>=u)return{node:m,offset:u-l};l=x}e:{for(;m;){if(m.nextSibling){m=m.nextSibling;break e}m=m.parentNode}m=void 0}m=ij(m)}}function cj(l,u){return l&&u?l===u?!0:l&&l.nodeType===3?!1:u&&u.nodeType===3?cj(l,u.parentNode):"contains"in l?l.contains(u):l.compareDocumentPosition?!!(l.compareDocumentPosition(u)&16):!1:!1}function uj(){for(var l=window,u=ae();u instanceof l.HTMLIFrameElement;){try{var m=typeof u.contentWindow.location.href=="string"}catch{m=!1}if(m)l=u.contentWindow;else break;u=ae(l.document)}return u}function mp(l){var u=l&&l.nodeName&&l.nodeName.toLowerCase();return u&&(u==="input"&&(l.type==="text"||l.type==="search"||l.type==="tel"||l.type==="url"||l.type==="password")||u==="textarea"||l.contentEditable==="true")}function y5(l){var u=uj(),m=l.focusedElem,x=l.selectionRange;if(u!==m&&m&&m.ownerDocument&&cj(m.ownerDocument.documentElement,m)){if(x!==null&&mp(m)){if(u=x.start,l=x.end,l===void 0&&(l=u),"selectionStart"in m)m.selectionStart=u,m.selectionEnd=Math.min(l,m.value.length);else if(l=(u=m.ownerDocument||document)&&u.defaultView||window,l.getSelection){l=l.getSelection();var _=m.textContent.length,R=Math.min(x.start,_);x=x.end===void 0?R:Math.min(x.end,_),!l.extend&&R>x&&(_=x,x=R,R=_),_=lj(m,R);var z=lj(m,x);_&&z&&(l.rangeCount!==1||l.anchorNode!==_.node||l.anchorOffset!==_.offset||l.focusNode!==z.node||l.focusOffset!==z.offset)&&(u=u.createRange(),u.setStart(_.node,_.offset),l.removeAllRanges(),R>x?(l.addRange(u),l.extend(z.node,z.offset)):(u.setEnd(z.node,z.offset),l.addRange(u)))}}for(u=[],l=m;l=l.parentNode;)l.nodeType===1&&u.push({element:l,left:l.scrollLeft,top:l.scrollTop});for(typeof m.focus=="function"&&m.focus(),m=0;m<u.length;m++)l=u[m],l.element.scrollLeft=l.left,l.element.scrollTop=l.top}}var w5=c&&"documentMode"in document&&11>=document.documentMode,zo=null,gp=null,Sl=null,yp=!1;function dj(l,u,m){var x=m.window===m?m.document:m.nodeType===9?m:m.ownerDocument;yp||zo==null||zo!==ae(x)||(x=zo,"selectionStart"in x&&mp(x)?x={start:x.selectionStart,end:x.selectionEnd}:(x=(x.ownerDocument&&x.ownerDocument.defaultView||window).getSelection(),x={anchorNode:x.anchorNode,anchorOffset:x.anchorOffset,focusNode:x.focusNode,focusOffset:x.focusOffset}),Sl&&Nl(Sl,x)||(Sl=x,x=Eu(gp,"onSelect"),0<x.length&&(u=new Gs("onSelect","select",null,u,m),l.push({event:u,listeners:x}),u.target=zo)))}function Nu(l,u){var m={};return m[l.toLowerCase()]=u.toLowerCase(),m["Webkit"+l]="webkit"+u,m["Moz"+l]="moz"+u,m}var Vo={animationend:Nu("Animation","AnimationEnd"),animationiteration:Nu("Animation","AnimationIteration"),animationstart:Nu("Animation","AnimationStart"),transitionend:Nu("Transition","TransitionEnd")},wp={},hj={};c&&(hj=document.createElement("div").style,"AnimationEvent"in window||(delete Vo.animationend.animation,delete Vo.animationiteration.animation,delete Vo.animationstart.animation),"TransitionEvent"in window||delete Vo.transitionend.transition);function Su(l){if(wp[l])return wp[l];if(!Vo[l])return l;var u=Vo[l],m;for(m in u)if(u.hasOwnProperty(m)&&m in hj)return wp[l]=u[m];return l}var fj=Su("animationend"),pj=Su("animationiteration"),mj=Su("animationstart"),gj=Su("transitionend"),yj=new Map,wj="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 Zs(l,u){yj.set(l,u),o(u,[l])}for(var xp=0;xp<wj.length;xp++){var vp=wj[xp],x5=vp.toLowerCase(),v5=vp[0].toUpperCase()+vp.slice(1);Zs(x5,"on"+v5)}Zs(fj,"onAnimationEnd"),Zs(pj,"onAnimationIteration"),Zs(mj,"onAnimationStart"),Zs("dblclick","onDoubleClick"),Zs("focusin","onFocus"),Zs("focusout","onBlur"),Zs(gj,"onTransitionEnd"),i("onMouseEnter",["mouseout","mouseover"]),i("onMouseLeave",["mouseout","mouseover"]),i("onPointerEnter",["pointerout","pointerover"]),i("onPointerLeave",["pointerout","pointerover"]),o("onChange","change click focusin focusout input keydown keyup selectionchange".split(" ")),o("onSelect","focusout contextmenu dragend focusin keydown keyup mousedown mouseup selectionchange".split(" ")),o("onBeforeInput",["compositionend","keypress","textInput","paste"]),o("onCompositionEnd","compositionend focusout keydown keypress keyup mousedown".split(" ")),o("onCompositionStart","compositionstart focusout keydown keypress keyup mousedown".split(" ")),o("onCompositionUpdate","compositionupdate focusout keydown keypress keyup mousedown".split(" "));var _l="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(" "),b5=new Set("cancel close invalid load scroll toggle".split(" ").concat(_l));function xj(l,u,m){var x=l.type||"unknown-event";l.currentTarget=m,Ds(x,u,void 0,l),l.currentTarget=null}function vj(l,u){u=(u&4)!==0;for(var m=0;m<l.length;m++){var x=l[m],_=x.event;x=x.listeners;e:{var R=void 0;if(u)for(var z=x.length-1;0<=z;z--){var Q=x[z],te=Q.instance,ue=Q.currentTarget;if(Q=Q.listener,te!==R&&_.isPropagationStopped())break e;xj(_,Q,ue),R=te}else for(z=0;z<x.length;z++){if(Q=x[z],te=Q.instance,ue=Q.currentTarget,Q=Q.listener,te!==R&&_.isPropagationStopped())break e;xj(_,Q,ue),R=te}}}if(Wt)throw l=is,Wt=!1,is=null,l}function mt(l,u){var m=u[Cp];m===void 0&&(m=u[Cp]=new Set);var x=l+"__bubble";m.has(x)||(bj(u,l,2,!1),m.add(x))}function bp(l,u,m){var x=0;u&&(x|=4),bj(m,l,x,u)}var _u="_reactListening"+Math.random().toString(36).slice(2);function El(l){if(!l[_u]){l[_u]=!0,r.forEach(function(m){m!=="selectionchange"&&(b5.has(m)||bp(m,!1,l),bp(m,!0,l))});var u=l.nodeType===9?l:l.ownerDocument;u===null||u[_u]||(u[_u]=!0,bp("selectionchange",!1,u))}}function bj(l,u,m,x){switch(ml(u)){case 1:var _=qa;break;case 4:_=pl;break;default:_=qr}m=_.bind(null,u,m,l),_=void 0,!An||u!=="touchstart"&&u!=="touchmove"&&u!=="wheel"||(_=!0),x?_!==void 0?l.addEventListener(u,m,{capture:!0,passive:_}):l.addEventListener(u,m,!0):_!==void 0?l.addEventListener(u,m,{passive:_}):l.addEventListener(u,m,!1)}function kp(l,u,m,x,_){var R=x;if((u&1)===0&&(u&2)===0&&x!==null)e:for(;;){if(x===null)return;var z=x.tag;if(z===3||z===4){var Q=x.stateNode.containerInfo;if(Q===_||Q.nodeType===8&&Q.parentNode===_)break;if(z===4)for(z=x.return;z!==null;){var te=z.tag;if((te===3||te===4)&&(te=z.stateNode.containerInfo,te===_||te.nodeType===8&&te.parentNode===_))return;z=z.return}for(;Q!==null;){if(z=Ga(Q),z===null)return;if(te=z.tag,te===5||te===6){x=R=z;continue e}Q=Q.parentNode}}x=x.return}Rn(function(){var ue=R,ve=pt(m),be=[];e:{var xe=yj.get(l);if(xe!==void 0){var Se=Gs,Ce=l;switch(l){case"keypress":if(Ha(m)===0)break e;case"keydown":case"keyup":Se=up;break;case"focusin":Ce="focus",Se=Ho;break;case"focusout":Ce="blur",Se=Ho;break;case"beforeblur":case"afterblur":Se=Ho;break;case"click":if(m.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Se=wl;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Se=wu;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Se=e5;break;case fj:case pj:case mj:Se=op;break;case gj:Se=n5;break;case"scroll":Se=Ks;break;case"wheel":Se=s5;break;case"copy":case"cut":case"paste":Se=xu;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Se=Ln}var Te=(u&4)!==0,Tt=!Te&&l==="scroll",ie=Te?xe!==null?xe+"Capture":null:xe;Te=[];for(var re=ue,le;re!==null;){le=re;var ke=le.stateNode;if(le.tag===5&&ke!==null&&(le=ke,ie!==null&&(ke=Yt(re,ie),ke!=null&&Te.push(Cl(re,ke,le)))),Tt)break;re=re.return}0<Te.length&&(xe=new Se(xe,Ce,null,m,ve),be.push({event:xe,listeners:Te}))}}if((u&7)===0){e:{if(xe=l==="mouseover"||l==="pointerover",Se=l==="mouseout"||l==="pointerout",xe&&m!==et&&(Ce=m.relatedTarget||m.fromElement)&&(Ga(Ce)||Ce[ms]))break e;if((Se||xe)&&(xe=ve.window===ve?ve:(xe=ve.ownerDocument)?xe.defaultView||xe.parentWindow:window,Se?(Ce=m.relatedTarget||m.toElement,Se=ue,Ce=Ce?Ga(Ce):null,Ce!==null&&(Tt=mn(Ce),Ce!==Tt||Ce.tag!==5&&Ce.tag!==6)&&(Ce=null)):(Se=null,Ce=ue),Se!==Ce)){if(Te=wl,ke="onMouseLeave",ie="onMouseEnter",re="mouse",(l==="pointerout"||l==="pointerover")&&(Te=Ln,ke="onPointerLeave",ie="onPointerEnter",re="pointer"),Tt=Se==null?xe:Yo(Se),le=Ce==null?xe:Yo(Ce),xe=new Te(ke,re+"leave",Se,m,ve),xe.target=Tt,xe.relatedTarget=le,ke=null,Ga(ve)===ue&&(Te=new Te(ie,re+"enter",Ce,m,ve),Te.target=le,Te.relatedTarget=Tt,ke=Te),Tt=ke,Se&&Ce)t:{for(Te=Se,ie=Ce,re=0,le=Te;le;le=Go(le))re++;for(le=0,ke=ie;ke;ke=Go(ke))le++;for(;0<re-le;)Te=Go(Te),re--;for(;0<le-re;)ie=Go(ie),le--;for(;re--;){if(Te===ie||ie!==null&&Te===ie.alternate)break t;Te=Go(Te),ie=Go(ie)}Te=null}else Te=null;Se!==null&&kj(be,xe,Se,Te,!1),Ce!==null&&Tt!==null&&kj(be,Tt,Ce,Te,!0)}}e:{if(xe=ue?Yo(ue):window,Se=xe.nodeName&&xe.nodeName.toLowerCase(),Se==="select"||Se==="input"&&xe.type==="file")var Re=d5;else if(tj(xe))if(rj)Re=m5;else{Re=f5;var Ie=h5}else(Se=xe.nodeName)&&Se.toLowerCase()==="input"&&(xe.type==="checkbox"||xe.type==="radio")&&(Re=p5);if(Re&&(Re=Re(l,ue))){nj(be,Re,m,ve);break e}Ie&&Ie(l,xe,ue),l==="focusout"&&(Ie=xe._wrapperState)&&Ie.controlled&&xe.type==="number"&&we(xe,"number",xe.value)}switch(Ie=ue?Yo(ue):window,l){case"focusin":(tj(Ie)||Ie.contentEditable==="true")&&(zo=Ie,gp=ue,Sl=null);break;case"focusout":Sl=gp=zo=null;break;case"mousedown":yp=!0;break;case"contextmenu":case"mouseup":case"dragend":yp=!1,dj(be,m,ve);break;case"selectionchange":if(w5)break;case"keydown":case"keyup":dj(be,m,ve)}var Pe;if(hp)e:{switch(l){case"compositionstart":var Fe="onCompositionStart";break e;case"compositionend":Fe="onCompositionEnd";break e;case"compositionupdate":Fe="onCompositionUpdate";break e}Fe=void 0}else Wo?Q1(l,m)&&(Fe="onCompositionEnd"):l==="keydown"&&m.keyCode===229&&(Fe="onCompositionStart");Fe&&(X1&&m.locale!=="ko"&&(Wo||Fe!=="onCompositionStart"?Fe==="onCompositionEnd"&&Wo&&(Pe=Uo()):(fr=ve,Ua="value"in fr?fr.value:fr.textContent,Wo=!0)),Ie=Eu(ue,Fe),0<Ie.length&&(Fe=new bu(Fe,l,null,m,ve),be.push({event:Fe,listeners:Ie}),Pe?Fe.data=Pe:(Pe=ej(m),Pe!==null&&(Fe.data=Pe)))),(Pe=o5?i5(l,m):l5(l,m))&&(ue=Eu(ue,"onBeforeInput"),0<ue.length&&(ve=new bu("onBeforeInput","beforeinput",null,m,ve),be.push({event:ve,listeners:ue}),ve.data=Pe))}vj(be,u)})}function Cl(l,u,m){return{instance:l,listener:u,currentTarget:m}}function Eu(l,u){for(var m=u+"Capture",x=[];l!==null;){var _=l,R=_.stateNode;_.tag===5&&R!==null&&(_=R,R=Yt(l,m),R!=null&&x.unshift(Cl(l,R,_)),R=Yt(l,u),R!=null&&x.push(Cl(l,R,_))),l=l.return}return x}function Go(l){if(l===null)return null;do l=l.return;while(l&&l.tag!==5);return l||null}function kj(l,u,m,x,_){for(var R=u._reactName,z=[];m!==null&&m!==x;){var Q=m,te=Q.alternate,ue=Q.stateNode;if(te!==null&&te===x)break;Q.tag===5&&ue!==null&&(Q=ue,_?(te=Yt(m,R),te!=null&&z.unshift(Cl(m,te,Q))):_||(te=Yt(m,R),te!=null&&z.push(Cl(m,te,Q)))),m=m.return}z.length!==0&&l.push({event:u,listeners:z})}var k5=/\r\n?/g,j5=/\u0000|\uFFFD/g;function jj(l){return(typeof l=="string"?l:""+l).replace(k5,`
|
|
38
|
-
`).replace(j5,"")}function Cu(l,u,m){if(u=jj(u),jj(l)!==u&&m)throw Error(n(425))}function Tu(){}var jp=null,Np=null;function Sp(l,u){return l==="textarea"||l==="noscript"||typeof u.children=="string"||typeof u.children=="number"||typeof u.dangerouslySetInnerHTML=="object"&&u.dangerouslySetInnerHTML!==null&&u.dangerouslySetInnerHTML.__html!=null}var _p=typeof setTimeout=="function"?setTimeout:void 0,N5=typeof clearTimeout=="function"?clearTimeout:void 0,Nj=typeof Promise=="function"?Promise:void 0,S5=typeof queueMicrotask=="function"?queueMicrotask:typeof Nj<"u"?function(l){return Nj.resolve(null).then(l).catch(_5)}:_p;function _5(l){setTimeout(function(){throw l})}function Ep(l,u){var m=u,x=0;do{var _=m.nextSibling;if(l.removeChild(m),_&&_.nodeType===8)if(m=_.data,m==="/$"){if(x===0){l.removeChild(_),Fa(u);return}x--}else m!=="$"&&m!=="$?"&&m!=="$!"||x++;m=_}while(m);Fa(u)}function Js(l){for(;l!=null;l=l.nextSibling){var u=l.nodeType;if(u===1||u===3)break;if(u===8){if(u=l.data,u==="$"||u==="$!"||u==="$?")break;if(u==="/$")return null}}return l}function Sj(l){l=l.previousSibling;for(var u=0;l;){if(l.nodeType===8){var m=l.data;if(m==="$"||m==="$!"||m==="$?"){if(u===0)return l;u--}else m==="/$"&&u++}l=l.previousSibling}return null}var Ko=Math.random().toString(36).slice(2),Wr="__reactFiber$"+Ko,Tl="__reactProps$"+Ko,ms="__reactContainer$"+Ko,Cp="__reactEvents$"+Ko,E5="__reactListeners$"+Ko,C5="__reactHandles$"+Ko;function Ga(l){var u=l[Wr];if(u)return u;for(var m=l.parentNode;m;){if(u=m[ms]||m[Wr]){if(m=u.alternate,u.child!==null||m!==null&&m.child!==null)for(l=Sj(l);l!==null;){if(m=l[Wr])return m;l=Sj(l)}return u}l=m,m=l.parentNode}return null}function Rl(l){return l=l[Wr]||l[ms],!l||l.tag!==5&&l.tag!==6&&l.tag!==13&&l.tag!==3?null:l}function Yo(l){if(l.tag===5||l.tag===6)return l.stateNode;throw Error(n(33))}function Ru(l){return l[Tl]||null}var Tp=[],Xo=-1;function Qs(l){return{current:l}}function gt(l){0>Xo||(l.current=Tp[Xo],Tp[Xo]=null,Xo--)}function ct(l,u){Xo++,Tp[Xo]=l.current,l.current=u}var ea={},tn=Qs(ea),gn=Qs(!1),Ka=ea;function Zo(l,u){var m=l.type.contextTypes;if(!m)return ea;var x=l.stateNode;if(x&&x.__reactInternalMemoizedUnmaskedChildContext===u)return x.__reactInternalMemoizedMaskedChildContext;var _={},R;for(R in m)_[R]=u[R];return x&&(l=l.stateNode,l.__reactInternalMemoizedUnmaskedChildContext=u,l.__reactInternalMemoizedMaskedChildContext=_),_}function yn(l){return l=l.childContextTypes,l!=null}function Au(){gt(gn),gt(tn)}function _j(l,u,m){if(tn.current!==ea)throw Error(n(168));ct(tn,u),ct(gn,m)}function Ej(l,u,m){var x=l.stateNode;if(u=u.childContextTypes,typeof x.getChildContext!="function")return m;x=x.getChildContext();for(var _ in x)if(!(_ in u))throw Error(n(108,J(l)||"Unknown",_));return q({},m,x)}function Mu(l){return l=(l=l.stateNode)&&l.__reactInternalMemoizedMergedChildContext||ea,Ka=tn.current,ct(tn,l),ct(gn,gn.current),!0}function Cj(l,u,m){var x=l.stateNode;if(!x)throw Error(n(169));m?(l=Ej(l,u,Ka),x.__reactInternalMemoizedMergedChildContext=l,gt(gn),gt(tn),ct(tn,l)):gt(gn),ct(gn,m)}var gs=null,$u=!1,Rp=!1;function Tj(l){gs===null?gs=[l]:gs.push(l)}function T5(l){$u=!0,Tj(l)}function ta(){if(!Rp&&gs!==null){Rp=!0;var l=0,u=Ke;try{var m=gs;for(Ke=1;l<m.length;l++){var x=m[l];do x=x(!0);while(x!==null)}gs=null,$u=!1}catch(_){throw gs!==null&&(gs=gs.slice(l+1)),Bs(Ze,ta),_}finally{Ke=u,Rp=!1}}return null}var Jo=[],Qo=0,Lu=null,Ou=0,Kn=[],Yn=0,Ya=null,ys=1,ws="";function Xa(l,u){Jo[Qo++]=Ou,Jo[Qo++]=Lu,Lu=l,Ou=u}function Rj(l,u,m){Kn[Yn++]=ys,Kn[Yn++]=ws,Kn[Yn++]=Ya,Ya=l;var x=ys;l=ws;var _=32-en(x)-1;x&=~(1<<_),m+=1;var R=32-en(u)+_;if(30<R){var z=_-_%5;R=(x&(1<<z)-1).toString(32),x>>=z,_-=z,ys=1<<32-en(u)+_|m<<_|x,ws=R+l}else ys=1<<R|m<<_|x,ws=l}function Ap(l){l.return!==null&&(Xa(l,1),Rj(l,1,0))}function Mp(l){for(;l===Lu;)Lu=Jo[--Qo],Jo[Qo]=null,Ou=Jo[--Qo],Jo[Qo]=null;for(;l===Ya;)Ya=Kn[--Yn],Kn[Yn]=null,ws=Kn[--Yn],Kn[Yn]=null,ys=Kn[--Yn],Kn[Yn]=null}var On=null,In=null,xt=!1,mr=null;function Aj(l,u){var m=Qn(5,null,null,0);m.elementType="DELETED",m.stateNode=u,m.return=l,u=l.deletions,u===null?(l.deletions=[m],l.flags|=16):u.push(m)}function Mj(l,u){switch(l.tag){case 5:var m=l.type;return u=u.nodeType!==1||m.toLowerCase()!==u.nodeName.toLowerCase()?null:u,u!==null?(l.stateNode=u,On=l,In=Js(u.firstChild),!0):!1;case 6:return u=l.pendingProps===""||u.nodeType!==3?null:u,u!==null?(l.stateNode=u,On=l,In=null,!0):!1;case 13:return u=u.nodeType!==8?null:u,u!==null?(m=Ya!==null?{id:ys,overflow:ws}:null,l.memoizedState={dehydrated:u,treeContext:m,retryLane:1073741824},m=Qn(18,null,null,0),m.stateNode=u,m.return=l,l.child=m,On=l,In=null,!0):!1;default:return!1}}function $p(l){return(l.mode&1)!==0&&(l.flags&128)===0}function Lp(l){if(xt){var u=In;if(u){var m=u;if(!Mj(l,u)){if($p(l))throw Error(n(418));u=Js(m.nextSibling);var x=On;u&&Mj(l,u)?Aj(x,m):(l.flags=l.flags&-4097|2,xt=!1,On=l)}}else{if($p(l))throw Error(n(418));l.flags=l.flags&-4097|2,xt=!1,On=l}}}function $j(l){for(l=l.return;l!==null&&l.tag!==5&&l.tag!==3&&l.tag!==13;)l=l.return;On=l}function Iu(l){if(l!==On)return!1;if(!xt)return $j(l),xt=!0,!1;var u;if((u=l.tag!==3)&&!(u=l.tag!==5)&&(u=l.type,u=u!=="head"&&u!=="body"&&!Sp(l.type,l.memoizedProps)),u&&(u=In)){if($p(l))throw Lj(),Error(n(418));for(;u;)Aj(l,u),u=Js(u.nextSibling)}if($j(l),l.tag===13){if(l=l.memoizedState,l=l!==null?l.dehydrated:null,!l)throw Error(n(317));e:{for(l=l.nextSibling,u=0;l;){if(l.nodeType===8){var m=l.data;if(m==="/$"){if(u===0){In=Js(l.nextSibling);break e}u--}else m!=="$"&&m!=="$!"&&m!=="$?"||u++}l=l.nextSibling}In=null}}else In=On?Js(l.stateNode.nextSibling):null;return!0}function Lj(){for(var l=In;l;)l=Js(l.nextSibling)}function ei(){In=On=null,xt=!1}function Op(l){mr===null?mr=[l]:mr.push(l)}var R5=E.ReactCurrentBatchConfig;function Al(l,u,m){if(l=m.ref,l!==null&&typeof l!="function"&&typeof l!="object"){if(m._owner){if(m=m._owner,m){if(m.tag!==1)throw Error(n(309));var x=m.stateNode}if(!x)throw Error(n(147,l));var _=x,R=""+l;return u!==null&&u.ref!==null&&typeof u.ref=="function"&&u.ref._stringRef===R?u.ref:(u=function(z){var Q=_.refs;z===null?delete Q[R]:Q[R]=z},u._stringRef=R,u)}if(typeof l!="string")throw Error(n(284));if(!m._owner)throw Error(n(290,l))}return l}function Pu(l,u){throw l=Object.prototype.toString.call(u),Error(n(31,l==="[object Object]"?"object with keys {"+Object.keys(u).join(", ")+"}":l))}function Oj(l){var u=l._init;return u(l._payload)}function Ij(l){function u(ie,re){if(l){var le=ie.deletions;le===null?(ie.deletions=[re],ie.flags|=16):le.push(re)}}function m(ie,re){if(!l)return null;for(;re!==null;)u(ie,re),re=re.sibling;return null}function x(ie,re){for(ie=new Map;re!==null;)re.key!==null?ie.set(re.key,re):ie.set(re.index,re),re=re.sibling;return ie}function _(ie,re){return ie=ca(ie,re),ie.index=0,ie.sibling=null,ie}function R(ie,re,le){return ie.index=le,l?(le=ie.alternate,le!==null?(le=le.index,le<re?(ie.flags|=2,re):le):(ie.flags|=2,re)):(ie.flags|=1048576,re)}function z(ie){return l&&ie.alternate===null&&(ie.flags|=2),ie}function Q(ie,re,le,ke){return re===null||re.tag!==6?(re=_m(le,ie.mode,ke),re.return=ie,re):(re=_(re,le),re.return=ie,re)}function te(ie,re,le,ke){var Re=le.type;return Re===T?ve(ie,re,le.props.children,ke,le.key):re!==null&&(re.elementType===Re||typeof Re=="object"&&Re!==null&&Re.$$typeof===D&&Oj(Re)===re.type)?(ke=_(re,le.props),ke.ref=Al(ie,re,le),ke.return=ie,ke):(ke=id(le.type,le.key,le.props,null,ie.mode,ke),ke.ref=Al(ie,re,le),ke.return=ie,ke)}function ue(ie,re,le,ke){return re===null||re.tag!==4||re.stateNode.containerInfo!==le.containerInfo||re.stateNode.implementation!==le.implementation?(re=Em(le,ie.mode,ke),re.return=ie,re):(re=_(re,le.children||[]),re.return=ie,re)}function ve(ie,re,le,ke,Re){return re===null||re.tag!==7?(re=so(le,ie.mode,ke,Re),re.return=ie,re):(re=_(re,le),re.return=ie,re)}function be(ie,re,le){if(typeof re=="string"&&re!==""||typeof re=="number")return re=_m(""+re,ie.mode,le),re.return=ie,re;if(typeof re=="object"&&re!==null){switch(re.$$typeof){case C:return le=id(re.type,re.key,re.props,null,ie.mode,le),le.ref=Al(ie,null,re),le.return=ie,le;case $:return re=Em(re,ie.mode,le),re.return=ie,re;case D:var ke=re._init;return be(ie,ke(re._payload),le)}if(Ne(re)||H(re))return re=so(re,ie.mode,le,null),re.return=ie,re;Pu(ie,re)}return null}function xe(ie,re,le,ke){var Re=re!==null?re.key:null;if(typeof le=="string"&&le!==""||typeof le=="number")return Re!==null?null:Q(ie,re,""+le,ke);if(typeof le=="object"&&le!==null){switch(le.$$typeof){case C:return le.key===Re?te(ie,re,le,ke):null;case $:return le.key===Re?ue(ie,re,le,ke):null;case D:return Re=le._init,xe(ie,re,Re(le._payload),ke)}if(Ne(le)||H(le))return Re!==null?null:ve(ie,re,le,ke,null);Pu(ie,le)}return null}function Se(ie,re,le,ke,Re){if(typeof ke=="string"&&ke!==""||typeof ke=="number")return ie=ie.get(le)||null,Q(re,ie,""+ke,Re);if(typeof ke=="object"&&ke!==null){switch(ke.$$typeof){case C:return ie=ie.get(ke.key===null?le:ke.key)||null,te(re,ie,ke,Re);case $:return ie=ie.get(ke.key===null?le:ke.key)||null,ue(re,ie,ke,Re);case D:var Ie=ke._init;return Se(ie,re,le,Ie(ke._payload),Re)}if(Ne(ke)||H(ke))return ie=ie.get(le)||null,ve(re,ie,ke,Re,null);Pu(re,ke)}return null}function Ce(ie,re,le,ke){for(var Re=null,Ie=null,Pe=re,Fe=re=0,Gt=null;Pe!==null&&Fe<le.length;Fe++){Pe.index>Fe?(Gt=Pe,Pe=null):Gt=Pe.sibling;var nt=xe(ie,Pe,le[Fe],ke);if(nt===null){Pe===null&&(Pe=Gt);break}l&&Pe&&nt.alternate===null&&u(ie,Pe),re=R(nt,re,Fe),Ie===null?Re=nt:Ie.sibling=nt,Ie=nt,Pe=Gt}if(Fe===le.length)return m(ie,Pe),xt&&Xa(ie,Fe),Re;if(Pe===null){for(;Fe<le.length;Fe++)Pe=be(ie,le[Fe],ke),Pe!==null&&(re=R(Pe,re,Fe),Ie===null?Re=Pe:Ie.sibling=Pe,Ie=Pe);return xt&&Xa(ie,Fe),Re}for(Pe=x(ie,Pe);Fe<le.length;Fe++)Gt=Se(Pe,ie,Fe,le[Fe],ke),Gt!==null&&(l&&Gt.alternate!==null&&Pe.delete(Gt.key===null?Fe:Gt.key),re=R(Gt,re,Fe),Ie===null?Re=Gt:Ie.sibling=Gt,Ie=Gt);return l&&Pe.forEach(function(ua){return u(ie,ua)}),xt&&Xa(ie,Fe),Re}function Te(ie,re,le,ke){var Re=H(le);if(typeof Re!="function")throw Error(n(150));if(le=Re.call(le),le==null)throw Error(n(151));for(var Ie=Re=null,Pe=re,Fe=re=0,Gt=null,nt=le.next();Pe!==null&&!nt.done;Fe++,nt=le.next()){Pe.index>Fe?(Gt=Pe,Pe=null):Gt=Pe.sibling;var ua=xe(ie,Pe,nt.value,ke);if(ua===null){Pe===null&&(Pe=Gt);break}l&&Pe&&ua.alternate===null&&u(ie,Pe),re=R(ua,re,Fe),Ie===null?Re=ua:Ie.sibling=ua,Ie=ua,Pe=Gt}if(nt.done)return m(ie,Pe),xt&&Xa(ie,Fe),Re;if(Pe===null){for(;!nt.done;Fe++,nt=le.next())nt=be(ie,nt.value,ke),nt!==null&&(re=R(nt,re,Fe),Ie===null?Re=nt:Ie.sibling=nt,Ie=nt);return xt&&Xa(ie,Fe),Re}for(Pe=x(ie,Pe);!nt.done;Fe++,nt=le.next())nt=Se(Pe,ie,Fe,nt.value,ke),nt!==null&&(l&&nt.alternate!==null&&Pe.delete(nt.key===null?Fe:nt.key),re=R(nt,re,Fe),Ie===null?Re=nt:Ie.sibling=nt,Ie=nt);return l&&Pe.forEach(function(c6){return u(ie,c6)}),xt&&Xa(ie,Fe),Re}function Tt(ie,re,le,ke){if(typeof le=="object"&&le!==null&&le.type===T&&le.key===null&&(le=le.props.children),typeof le=="object"&&le!==null){switch(le.$$typeof){case C:e:{for(var Re=le.key,Ie=re;Ie!==null;){if(Ie.key===Re){if(Re=le.type,Re===T){if(Ie.tag===7){m(ie,Ie.sibling),re=_(Ie,le.props.children),re.return=ie,ie=re;break e}}else if(Ie.elementType===Re||typeof Re=="object"&&Re!==null&&Re.$$typeof===D&&Oj(Re)===Ie.type){m(ie,Ie.sibling),re=_(Ie,le.props),re.ref=Al(ie,Ie,le),re.return=ie,ie=re;break e}m(ie,Ie);break}else u(ie,Ie);Ie=Ie.sibling}le.type===T?(re=so(le.props.children,ie.mode,ke,le.key),re.return=ie,ie=re):(ke=id(le.type,le.key,le.props,null,ie.mode,ke),ke.ref=Al(ie,re,le),ke.return=ie,ie=ke)}return z(ie);case $:e:{for(Ie=le.key;re!==null;){if(re.key===Ie)if(re.tag===4&&re.stateNode.containerInfo===le.containerInfo&&re.stateNode.implementation===le.implementation){m(ie,re.sibling),re=_(re,le.children||[]),re.return=ie,ie=re;break e}else{m(ie,re);break}else u(ie,re);re=re.sibling}re=Em(le,ie.mode,ke),re.return=ie,ie=re}return z(ie);case D:return Ie=le._init,Tt(ie,re,Ie(le._payload),ke)}if(Ne(le))return Ce(ie,re,le,ke);if(H(le))return Te(ie,re,le,ke);Pu(ie,le)}return typeof le=="string"&&le!==""||typeof le=="number"?(le=""+le,re!==null&&re.tag===6?(m(ie,re.sibling),re=_(re,le),re.return=ie,ie=re):(m(ie,re),re=_m(le,ie.mode,ke),re.return=ie,ie=re),z(ie)):m(ie,re)}return Tt}var ti=Ij(!0),Pj=Ij(!1),Du=Qs(null),Fu=null,ni=null,Ip=null;function Pp(){Ip=ni=Fu=null}function Dp(l){var u=Du.current;gt(Du),l._currentValue=u}function Fp(l,u,m){for(;l!==null;){var x=l.alternate;if((l.childLanes&u)!==u?(l.childLanes|=u,x!==null&&(x.childLanes|=u)):x!==null&&(x.childLanes&u)!==u&&(x.childLanes|=u),l===m)break;l=l.return}}function ri(l,u){Fu=l,Ip=ni=null,l=l.dependencies,l!==null&&l.firstContext!==null&&((l.lanes&u)!==0&&(wn=!0),l.firstContext=null)}function Xn(l){var u=l._currentValue;if(Ip!==l)if(l={context:l,memoizedValue:u,next:null},ni===null){if(Fu===null)throw Error(n(308));ni=l,Fu.dependencies={lanes:0,firstContext:l}}else ni=ni.next=l;return u}var Za=null;function Bp(l){Za===null?Za=[l]:Za.push(l)}function Dj(l,u,m,x){var _=u.interleaved;return _===null?(m.next=m,Bp(u)):(m.next=_.next,_.next=m),u.interleaved=m,xs(l,x)}function xs(l,u){l.lanes|=u;var m=l.alternate;for(m!==null&&(m.lanes|=u),m=l,l=l.return;l!==null;)l.childLanes|=u,m=l.alternate,m!==null&&(m.childLanes|=u),m=l,l=l.return;return m.tag===3?m.stateNode:null}var na=!1;function qp(l){l.updateQueue={baseState:l.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function Fj(l,u){l=l.updateQueue,u.updateQueue===l&&(u.updateQueue={baseState:l.baseState,firstBaseUpdate:l.firstBaseUpdate,lastBaseUpdate:l.lastBaseUpdate,shared:l.shared,effects:l.effects})}function vs(l,u){return{eventTime:l,lane:u,tag:0,payload:null,callback:null,next:null}}function ra(l,u,m){var x=l.updateQueue;if(x===null)return null;if(x=x.shared,(Je&2)!==0){var _=x.pending;return _===null?u.next=u:(u.next=_.next,_.next=u),x.pending=u,xs(l,m)}return _=x.interleaved,_===null?(u.next=u,Bp(x)):(u.next=_.next,_.next=u),x.interleaved=u,xs(l,m)}function Bu(l,u,m){if(u=u.updateQueue,u!==null&&(u=u.shared,(m&4194240)!==0)){var x=u.lanes;x&=l.pendingLanes,m|=x,u.lanes=m,Pa(l,m)}}function Bj(l,u){var m=l.updateQueue,x=l.alternate;if(x!==null&&(x=x.updateQueue,m===x)){var _=null,R=null;if(m=m.firstBaseUpdate,m!==null){do{var z={eventTime:m.eventTime,lane:m.lane,tag:m.tag,payload:m.payload,callback:m.callback,next:null};R===null?_=R=z:R=R.next=z,m=m.next}while(m!==null);R===null?_=R=u:R=R.next=u}else _=R=u;m={baseState:x.baseState,firstBaseUpdate:_,lastBaseUpdate:R,shared:x.shared,effects:x.effects},l.updateQueue=m;return}l=m.lastBaseUpdate,l===null?m.firstBaseUpdate=u:l.next=u,m.lastBaseUpdate=u}function qu(l,u,m,x){var _=l.updateQueue;na=!1;var R=_.firstBaseUpdate,z=_.lastBaseUpdate,Q=_.shared.pending;if(Q!==null){_.shared.pending=null;var te=Q,ue=te.next;te.next=null,z===null?R=ue:z.next=ue,z=te;var ve=l.alternate;ve!==null&&(ve=ve.updateQueue,Q=ve.lastBaseUpdate,Q!==z&&(Q===null?ve.firstBaseUpdate=ue:Q.next=ue,ve.lastBaseUpdate=te))}if(R!==null){var be=_.baseState;z=0,ve=ue=te=null,Q=R;do{var xe=Q.lane,Se=Q.eventTime;if((x&xe)===xe){ve!==null&&(ve=ve.next={eventTime:Se,lane:0,tag:Q.tag,payload:Q.payload,callback:Q.callback,next:null});e:{var Ce=l,Te=Q;switch(xe=u,Se=m,Te.tag){case 1:if(Ce=Te.payload,typeof Ce=="function"){be=Ce.call(Se,be,xe);break e}be=Ce;break e;case 3:Ce.flags=Ce.flags&-65537|128;case 0:if(Ce=Te.payload,xe=typeof Ce=="function"?Ce.call(Se,be,xe):Ce,xe==null)break e;be=q({},be,xe);break e;case 2:na=!0}}Q.callback!==null&&Q.lane!==0&&(l.flags|=64,xe=_.effects,xe===null?_.effects=[Q]:xe.push(Q))}else Se={eventTime:Se,lane:xe,tag:Q.tag,payload:Q.payload,callback:Q.callback,next:null},ve===null?(ue=ve=Se,te=be):ve=ve.next=Se,z|=xe;if(Q=Q.next,Q===null){if(Q=_.shared.pending,Q===null)break;xe=Q,Q=xe.next,xe.next=null,_.lastBaseUpdate=xe,_.shared.pending=null}}while(!0);if(ve===null&&(te=be),_.baseState=te,_.firstBaseUpdate=ue,_.lastBaseUpdate=ve,u=_.shared.interleaved,u!==null){_=u;do z|=_.lane,_=_.next;while(_!==u)}else R===null&&(_.shared.lanes=0);eo|=z,l.lanes=z,l.memoizedState=be}}function qj(l,u,m){if(l=u.effects,u.effects=null,l!==null)for(u=0;u<l.length;u++){var x=l[u],_=x.callback;if(_!==null){if(x.callback=null,x=m,typeof _!="function")throw Error(n(191,_));_.call(x)}}}var Ml={},zr=Qs(Ml),$l=Qs(Ml),Ll=Qs(Ml);function Ja(l){if(l===Ml)throw Error(n(174));return l}function Up(l,u){switch(ct(Ll,u),ct($l,l),ct(zr,Ml),l=u.nodeType,l){case 9:case 11:u=(u=u.documentElement)?u.namespaceURI:rt(null,"");break;default:l=l===8?u.parentNode:u,u=l.namespaceURI||null,l=l.tagName,u=rt(u,l)}gt(zr),ct(zr,u)}function si(){gt(zr),gt($l),gt(Ll)}function Uj(l){Ja(Ll.current);var u=Ja(zr.current),m=rt(u,l.type);u!==m&&(ct($l,l),ct(zr,m))}function Hp(l){$l.current===l&&(gt(zr),gt($l))}var bt=Qs(0);function Uu(l){for(var u=l;u!==null;){if(u.tag===13){var m=u.memoizedState;if(m!==null&&(m=m.dehydrated,m===null||m.data==="$?"||m.data==="$!"))return u}else if(u.tag===19&&u.memoizedProps.revealOrder!==void 0){if((u.flags&128)!==0)return u}else if(u.child!==null){u.child.return=u,u=u.child;continue}if(u===l)break;for(;u.sibling===null;){if(u.return===null||u.return===l)return null;u=u.return}u.sibling.return=u.return,u=u.sibling}return null}var Wp=[];function zp(){for(var l=0;l<Wp.length;l++)Wp[l]._workInProgressVersionPrimary=null;Wp.length=0}var Hu=E.ReactCurrentDispatcher,Vp=E.ReactCurrentBatchConfig,Qa=0,kt=null,Pt=null,zt=null,Wu=!1,Ol=!1,Il=0,A5=0;function nn(){throw Error(n(321))}function Gp(l,u){if(u===null)return!1;for(var m=0;m<u.length&&m<l.length;m++)if(!pr(l[m],u[m]))return!1;return!0}function Kp(l,u,m,x,_,R){if(Qa=R,kt=u,u.memoizedState=null,u.updateQueue=null,u.lanes=0,Hu.current=l===null||l.memoizedState===null?O5:I5,l=m(x,_),Ol){R=0;do{if(Ol=!1,Il=0,25<=R)throw Error(n(301));R+=1,zt=Pt=null,u.updateQueue=null,Hu.current=P5,l=m(x,_)}while(Ol)}if(Hu.current=Gu,u=Pt!==null&&Pt.next!==null,Qa=0,zt=Pt=kt=null,Wu=!1,u)throw Error(n(300));return l}function Yp(){var l=Il!==0;return Il=0,l}function Vr(){var l={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return zt===null?kt.memoizedState=zt=l:zt=zt.next=l,zt}function Zn(){if(Pt===null){var l=kt.alternate;l=l!==null?l.memoizedState:null}else l=Pt.next;var u=zt===null?kt.memoizedState:zt.next;if(u!==null)zt=u,Pt=l;else{if(l===null)throw Error(n(310));Pt=l,l={memoizedState:Pt.memoizedState,baseState:Pt.baseState,baseQueue:Pt.baseQueue,queue:Pt.queue,next:null},zt===null?kt.memoizedState=zt=l:zt=zt.next=l}return zt}function Pl(l,u){return typeof u=="function"?u(l):u}function Xp(l){var u=Zn(),m=u.queue;if(m===null)throw Error(n(311));m.lastRenderedReducer=l;var x=Pt,_=x.baseQueue,R=m.pending;if(R!==null){if(_!==null){var z=_.next;_.next=R.next,R.next=z}x.baseQueue=_=R,m.pending=null}if(_!==null){R=_.next,x=x.baseState;var Q=z=null,te=null,ue=R;do{var ve=ue.lane;if((Qa&ve)===ve)te!==null&&(te=te.next={lane:0,action:ue.action,hasEagerState:ue.hasEagerState,eagerState:ue.eagerState,next:null}),x=ue.hasEagerState?ue.eagerState:l(x,ue.action);else{var be={lane:ve,action:ue.action,hasEagerState:ue.hasEagerState,eagerState:ue.eagerState,next:null};te===null?(Q=te=be,z=x):te=te.next=be,kt.lanes|=ve,eo|=ve}ue=ue.next}while(ue!==null&&ue!==R);te===null?z=x:te.next=Q,pr(x,u.memoizedState)||(wn=!0),u.memoizedState=x,u.baseState=z,u.baseQueue=te,m.lastRenderedState=x}if(l=m.interleaved,l!==null){_=l;do R=_.lane,kt.lanes|=R,eo|=R,_=_.next;while(_!==l)}else _===null&&(m.lanes=0);return[u.memoizedState,m.dispatch]}function Zp(l){var u=Zn(),m=u.queue;if(m===null)throw Error(n(311));m.lastRenderedReducer=l;var x=m.dispatch,_=m.pending,R=u.memoizedState;if(_!==null){m.pending=null;var z=_=_.next;do R=l(R,z.action),z=z.next;while(z!==_);pr(R,u.memoizedState)||(wn=!0),u.memoizedState=R,u.baseQueue===null&&(u.baseState=R),m.lastRenderedState=R}return[R,x]}function Hj(){}function Wj(l,u){var m=kt,x=Zn(),_=u(),R=!pr(x.memoizedState,_);if(R&&(x.memoizedState=_,wn=!0),x=x.queue,Jp(Gj.bind(null,m,x,l),[l]),x.getSnapshot!==u||R||zt!==null&&zt.memoizedState.tag&1){if(m.flags|=2048,Dl(9,Vj.bind(null,m,x,_,u),void 0,null),Vt===null)throw Error(n(349));(Qa&30)!==0||zj(m,u,_)}return _}function zj(l,u,m){l.flags|=16384,l={getSnapshot:u,value:m},u=kt.updateQueue,u===null?(u={lastEffect:null,stores:null},kt.updateQueue=u,u.stores=[l]):(m=u.stores,m===null?u.stores=[l]:m.push(l))}function Vj(l,u,m,x){u.value=m,u.getSnapshot=x,Kj(u)&&Yj(l)}function Gj(l,u,m){return m(function(){Kj(u)&&Yj(l)})}function Kj(l){var u=l.getSnapshot;l=l.value;try{var m=u();return!pr(l,m)}catch{return!0}}function Yj(l){var u=xs(l,1);u!==null&&xr(u,l,1,-1)}function Xj(l){var u=Vr();return typeof l=="function"&&(l=l()),u.memoizedState=u.baseState=l,l={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Pl,lastRenderedState:l},u.queue=l,l=l.dispatch=L5.bind(null,kt,l),[u.memoizedState,l]}function Dl(l,u,m,x){return l={tag:l,create:u,destroy:m,deps:x,next:null},u=kt.updateQueue,u===null?(u={lastEffect:null,stores:null},kt.updateQueue=u,u.lastEffect=l.next=l):(m=u.lastEffect,m===null?u.lastEffect=l.next=l:(x=m.next,m.next=l,l.next=x,u.lastEffect=l)),l}function Zj(){return Zn().memoizedState}function zu(l,u,m,x){var _=Vr();kt.flags|=l,_.memoizedState=Dl(1|u,m,void 0,x===void 0?null:x)}function Vu(l,u,m,x){var _=Zn();x=x===void 0?null:x;var R=void 0;if(Pt!==null){var z=Pt.memoizedState;if(R=z.destroy,x!==null&&Gp(x,z.deps)){_.memoizedState=Dl(u,m,R,x);return}}kt.flags|=l,_.memoizedState=Dl(1|u,m,R,x)}function Jj(l,u){return zu(8390656,8,l,u)}function Jp(l,u){return Vu(2048,8,l,u)}function Qj(l,u){return Vu(4,2,l,u)}function eN(l,u){return Vu(4,4,l,u)}function tN(l,u){if(typeof u=="function")return l=l(),u(l),function(){u(null)};if(u!=null)return l=l(),u.current=l,function(){u.current=null}}function nN(l,u,m){return m=m!=null?m.concat([l]):null,Vu(4,4,tN.bind(null,u,l),m)}function Qp(){}function rN(l,u){var m=Zn();u=u===void 0?null:u;var x=m.memoizedState;return x!==null&&u!==null&&Gp(u,x[1])?x[0]:(m.memoizedState=[l,u],l)}function sN(l,u){var m=Zn();u=u===void 0?null:u;var x=m.memoizedState;return x!==null&&u!==null&&Gp(u,x[1])?x[0]:(l=l(),m.memoizedState=[l,u],l)}function aN(l,u,m){return(Qa&21)===0?(l.baseState&&(l.baseState=!1,wn=!0),l.memoizedState=m):(pr(m,u)||(m=du(),kt.lanes|=m,eo|=m,l.baseState=!0),u)}function M5(l,u){var m=Ke;Ke=m!==0&&4>m?m:4,l(!0);var x=Vp.transition;Vp.transition={};try{l(!1),u()}finally{Ke=m,Vp.transition=x}}function oN(){return Zn().memoizedState}function $5(l,u,m){var x=ia(l);if(m={lane:x,action:m,hasEagerState:!1,eagerState:null,next:null},iN(l))lN(u,m);else if(m=Dj(l,u,m,x),m!==null){var _=cn();xr(m,l,x,_),cN(m,u,x)}}function L5(l,u,m){var x=ia(l),_={lane:x,action:m,hasEagerState:!1,eagerState:null,next:null};if(iN(l))lN(u,_);else{var R=l.alternate;if(l.lanes===0&&(R===null||R.lanes===0)&&(R=u.lastRenderedReducer,R!==null))try{var z=u.lastRenderedState,Q=R(z,m);if(_.hasEagerState=!0,_.eagerState=Q,pr(Q,z)){var te=u.interleaved;te===null?(_.next=_,Bp(u)):(_.next=te.next,te.next=_),u.interleaved=_;return}}catch{}finally{}m=Dj(l,u,_,x),m!==null&&(_=cn(),xr(m,l,x,_),cN(m,u,x))}}function iN(l){var u=l.alternate;return l===kt||u!==null&&u===kt}function lN(l,u){Ol=Wu=!0;var m=l.pending;m===null?u.next=u:(u.next=m.next,m.next=u),l.pending=u}function cN(l,u,m){if((m&4194240)!==0){var x=u.lanes;x&=l.pendingLanes,m|=x,u.lanes=m,Pa(l,m)}}var Gu={readContext:Xn,useCallback:nn,useContext:nn,useEffect:nn,useImperativeHandle:nn,useInsertionEffect:nn,useLayoutEffect:nn,useMemo:nn,useReducer:nn,useRef:nn,useState:nn,useDebugValue:nn,useDeferredValue:nn,useTransition:nn,useMutableSource:nn,useSyncExternalStore:nn,useId:nn,unstable_isNewReconciler:!1},O5={readContext:Xn,useCallback:function(l,u){return Vr().memoizedState=[l,u===void 0?null:u],l},useContext:Xn,useEffect:Jj,useImperativeHandle:function(l,u,m){return m=m!=null?m.concat([l]):null,zu(4194308,4,tN.bind(null,u,l),m)},useLayoutEffect:function(l,u){return zu(4194308,4,l,u)},useInsertionEffect:function(l,u){return zu(4,2,l,u)},useMemo:function(l,u){var m=Vr();return u=u===void 0?null:u,l=l(),m.memoizedState=[l,u],l},useReducer:function(l,u,m){var x=Vr();return u=m!==void 0?m(u):u,x.memoizedState=x.baseState=u,l={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:l,lastRenderedState:u},x.queue=l,l=l.dispatch=$5.bind(null,kt,l),[x.memoizedState,l]},useRef:function(l){var u=Vr();return l={current:l},u.memoizedState=l},useState:Xj,useDebugValue:Qp,useDeferredValue:function(l){return Vr().memoizedState=l},useTransition:function(){var l=Xj(!1),u=l[0];return l=M5.bind(null,l[1]),Vr().memoizedState=l,[u,l]},useMutableSource:function(){},useSyncExternalStore:function(l,u,m){var x=kt,_=Vr();if(xt){if(m===void 0)throw Error(n(407));m=m()}else{if(m=u(),Vt===null)throw Error(n(349));(Qa&30)!==0||zj(x,u,m)}_.memoizedState=m;var R={value:m,getSnapshot:u};return _.queue=R,Jj(Gj.bind(null,x,R,l),[l]),x.flags|=2048,Dl(9,Vj.bind(null,x,R,m,u),void 0,null),m},useId:function(){var l=Vr(),u=Vt.identifierPrefix;if(xt){var m=ws,x=ys;m=(x&~(1<<32-en(x)-1)).toString(32)+m,u=":"+u+"R"+m,m=Il++,0<m&&(u+="H"+m.toString(32)),u+=":"}else m=A5++,u=":"+u+"r"+m.toString(32)+":";return l.memoizedState=u},unstable_isNewReconciler:!1},I5={readContext:Xn,useCallback:rN,useContext:Xn,useEffect:Jp,useImperativeHandle:nN,useInsertionEffect:Qj,useLayoutEffect:eN,useMemo:sN,useReducer:Xp,useRef:Zj,useState:function(){return Xp(Pl)},useDebugValue:Qp,useDeferredValue:function(l){var u=Zn();return aN(u,Pt.memoizedState,l)},useTransition:function(){var l=Xp(Pl)[0],u=Zn().memoizedState;return[l,u]},useMutableSource:Hj,useSyncExternalStore:Wj,useId:oN,unstable_isNewReconciler:!1},P5={readContext:Xn,useCallback:rN,useContext:Xn,useEffect:Jp,useImperativeHandle:nN,useInsertionEffect:Qj,useLayoutEffect:eN,useMemo:sN,useReducer:Zp,useRef:Zj,useState:function(){return Zp(Pl)},useDebugValue:Qp,useDeferredValue:function(l){var u=Zn();return Pt===null?u.memoizedState=l:aN(u,Pt.memoizedState,l)},useTransition:function(){var l=Zp(Pl)[0],u=Zn().memoizedState;return[l,u]},useMutableSource:Hj,useSyncExternalStore:Wj,useId:oN,unstable_isNewReconciler:!1};function gr(l,u){if(l&&l.defaultProps){u=q({},u),l=l.defaultProps;for(var m in l)u[m]===void 0&&(u[m]=l[m]);return u}return u}function em(l,u,m,x){u=l.memoizedState,m=m(x,u),m=m==null?u:q({},u,m),l.memoizedState=m,l.lanes===0&&(l.updateQueue.baseState=m)}var Ku={isMounted:function(l){return(l=l._reactInternals)?mn(l)===l:!1},enqueueSetState:function(l,u,m){l=l._reactInternals;var x=cn(),_=ia(l),R=vs(x,_);R.payload=u,m!=null&&(R.callback=m),u=ra(l,R,_),u!==null&&(xr(u,l,_,x),Bu(u,l,_))},enqueueReplaceState:function(l,u,m){l=l._reactInternals;var x=cn(),_=ia(l),R=vs(x,_);R.tag=1,R.payload=u,m!=null&&(R.callback=m),u=ra(l,R,_),u!==null&&(xr(u,l,_,x),Bu(u,l,_))},enqueueForceUpdate:function(l,u){l=l._reactInternals;var m=cn(),x=ia(l),_=vs(m,x);_.tag=2,u!=null&&(_.callback=u),u=ra(l,_,x),u!==null&&(xr(u,l,x,m),Bu(u,l,x))}};function uN(l,u,m,x,_,R,z){return l=l.stateNode,typeof l.shouldComponentUpdate=="function"?l.shouldComponentUpdate(x,R,z):u.prototype&&u.prototype.isPureReactComponent?!Nl(m,x)||!Nl(_,R):!0}function dN(l,u,m){var x=!1,_=ea,R=u.contextType;return typeof R=="object"&&R!==null?R=Xn(R):(_=yn(u)?Ka:tn.current,x=u.contextTypes,R=(x=x!=null)?Zo(l,_):ea),u=new u(m,R),l.memoizedState=u.state!==null&&u.state!==void 0?u.state:null,u.updater=Ku,l.stateNode=u,u._reactInternals=l,x&&(l=l.stateNode,l.__reactInternalMemoizedUnmaskedChildContext=_,l.__reactInternalMemoizedMaskedChildContext=R),u}function hN(l,u,m,x){l=u.state,typeof u.componentWillReceiveProps=="function"&&u.componentWillReceiveProps(m,x),typeof u.UNSAFE_componentWillReceiveProps=="function"&&u.UNSAFE_componentWillReceiveProps(m,x),u.state!==l&&Ku.enqueueReplaceState(u,u.state,null)}function tm(l,u,m,x){var _=l.stateNode;_.props=m,_.state=l.memoizedState,_.refs={},qp(l);var R=u.contextType;typeof R=="object"&&R!==null?_.context=Xn(R):(R=yn(u)?Ka:tn.current,_.context=Zo(l,R)),_.state=l.memoizedState,R=u.getDerivedStateFromProps,typeof R=="function"&&(em(l,u,R,m),_.state=l.memoizedState),typeof u.getDerivedStateFromProps=="function"||typeof _.getSnapshotBeforeUpdate=="function"||typeof _.UNSAFE_componentWillMount!="function"&&typeof _.componentWillMount!="function"||(u=_.state,typeof _.componentWillMount=="function"&&_.componentWillMount(),typeof _.UNSAFE_componentWillMount=="function"&&_.UNSAFE_componentWillMount(),u!==_.state&&Ku.enqueueReplaceState(_,_.state,null),qu(l,m,_,x),_.state=l.memoizedState),typeof _.componentDidMount=="function"&&(l.flags|=4194308)}function ai(l,u){try{var m="",x=u;do m+=X(x),x=x.return;while(x);var _=m}catch(R){_=`
|
|
39
|
-
Error generating stack: `+R.message+`
|
|
40
|
-
`+R.stack}return{value:l,source:u,stack:_,digest:null}}function nm(l,u,m){return{value:l,source:null,stack:m??null,digest:u??null}}function rm(l,u){try{console.error(u.value)}catch(m){setTimeout(function(){throw m})}}var D5=typeof WeakMap=="function"?WeakMap:Map;function fN(l,u,m){m=vs(-1,m),m.tag=3,m.payload={element:null};var x=u.value;return m.callback=function(){td||(td=!0,wm=x),rm(l,u)},m}function pN(l,u,m){m=vs(-1,m),m.tag=3;var x=l.type.getDerivedStateFromError;if(typeof x=="function"){var _=u.value;m.payload=function(){return x(_)},m.callback=function(){rm(l,u)}}var R=l.stateNode;return R!==null&&typeof R.componentDidCatch=="function"&&(m.callback=function(){rm(l,u),typeof x!="function"&&(aa===null?aa=new Set([this]):aa.add(this));var z=u.stack;this.componentDidCatch(u.value,{componentStack:z!==null?z:""})}),m}function mN(l,u,m){var x=l.pingCache;if(x===null){x=l.pingCache=new D5;var _=new Set;x.set(u,_)}else _=x.get(u),_===void 0&&(_=new Set,x.set(u,_));_.has(m)||(_.add(m),l=J5.bind(null,l,u,m),u.then(l,l))}function gN(l){do{var u;if((u=l.tag===13)&&(u=l.memoizedState,u=u!==null?u.dehydrated!==null:!0),u)return l;l=l.return}while(l!==null);return null}function yN(l,u,m,x,_){return(l.mode&1)===0?(l===u?l.flags|=65536:(l.flags|=128,m.flags|=131072,m.flags&=-52805,m.tag===1&&(m.alternate===null?m.tag=17:(u=vs(-1,1),u.tag=2,ra(m,u,1))),m.lanes|=1),l):(l.flags|=65536,l.lanes=_,l)}var F5=E.ReactCurrentOwner,wn=!1;function ln(l,u,m,x){u.child=l===null?Pj(u,null,m,x):ti(u,l.child,m,x)}function wN(l,u,m,x,_){m=m.render;var R=u.ref;return ri(u,_),x=Kp(l,u,m,x,R,_),m=Yp(),l!==null&&!wn?(u.updateQueue=l.updateQueue,u.flags&=-2053,l.lanes&=~_,bs(l,u,_)):(xt&&m&&Ap(u),u.flags|=1,ln(l,u,x,_),u.child)}function xN(l,u,m,x,_){if(l===null){var R=m.type;return typeof R=="function"&&!Sm(R)&&R.defaultProps===void 0&&m.compare===null&&m.defaultProps===void 0?(u.tag=15,u.type=R,vN(l,u,R,x,_)):(l=id(m.type,null,x,u,u.mode,_),l.ref=u.ref,l.return=u,u.child=l)}if(R=l.child,(l.lanes&_)===0){var z=R.memoizedProps;if(m=m.compare,m=m!==null?m:Nl,m(z,x)&&l.ref===u.ref)return bs(l,u,_)}return u.flags|=1,l=ca(R,x),l.ref=u.ref,l.return=u,u.child=l}function vN(l,u,m,x,_){if(l!==null){var R=l.memoizedProps;if(Nl(R,x)&&l.ref===u.ref)if(wn=!1,u.pendingProps=x=R,(l.lanes&_)!==0)(l.flags&131072)!==0&&(wn=!0);else return u.lanes=l.lanes,bs(l,u,_)}return sm(l,u,m,x,_)}function bN(l,u,m){var x=u.pendingProps,_=x.children,R=l!==null?l.memoizedState:null;if(x.mode==="hidden")if((u.mode&1)===0)u.memoizedState={baseLanes:0,cachePool:null,transitions:null},ct(ii,Pn),Pn|=m;else{if((m&1073741824)===0)return l=R!==null?R.baseLanes|m:m,u.lanes=u.childLanes=1073741824,u.memoizedState={baseLanes:l,cachePool:null,transitions:null},u.updateQueue=null,ct(ii,Pn),Pn|=l,null;u.memoizedState={baseLanes:0,cachePool:null,transitions:null},x=R!==null?R.baseLanes:m,ct(ii,Pn),Pn|=x}else R!==null?(x=R.baseLanes|m,u.memoizedState=null):x=m,ct(ii,Pn),Pn|=x;return ln(l,u,_,m),u.child}function kN(l,u){var m=u.ref;(l===null&&m!==null||l!==null&&l.ref!==m)&&(u.flags|=512,u.flags|=2097152)}function sm(l,u,m,x,_){var R=yn(m)?Ka:tn.current;return R=Zo(u,R),ri(u,_),m=Kp(l,u,m,x,R,_),x=Yp(),l!==null&&!wn?(u.updateQueue=l.updateQueue,u.flags&=-2053,l.lanes&=~_,bs(l,u,_)):(xt&&x&&Ap(u),u.flags|=1,ln(l,u,m,_),u.child)}function jN(l,u,m,x,_){if(yn(m)){var R=!0;Mu(u)}else R=!1;if(ri(u,_),u.stateNode===null)Xu(l,u),dN(u,m,x),tm(u,m,x,_),x=!0;else if(l===null){var z=u.stateNode,Q=u.memoizedProps;z.props=Q;var te=z.context,ue=m.contextType;typeof ue=="object"&&ue!==null?ue=Xn(ue):(ue=yn(m)?Ka:tn.current,ue=Zo(u,ue));var ve=m.getDerivedStateFromProps,be=typeof ve=="function"||typeof z.getSnapshotBeforeUpdate=="function";be||typeof z.UNSAFE_componentWillReceiveProps!="function"&&typeof z.componentWillReceiveProps!="function"||(Q!==x||te!==ue)&&hN(u,z,x,ue),na=!1;var xe=u.memoizedState;z.state=xe,qu(u,x,z,_),te=u.memoizedState,Q!==x||xe!==te||gn.current||na?(typeof ve=="function"&&(em(u,m,ve,x),te=u.memoizedState),(Q=na||uN(u,m,Q,x,xe,te,ue))?(be||typeof z.UNSAFE_componentWillMount!="function"&&typeof z.componentWillMount!="function"||(typeof z.componentWillMount=="function"&&z.componentWillMount(),typeof z.UNSAFE_componentWillMount=="function"&&z.UNSAFE_componentWillMount()),typeof z.componentDidMount=="function"&&(u.flags|=4194308)):(typeof z.componentDidMount=="function"&&(u.flags|=4194308),u.memoizedProps=x,u.memoizedState=te),z.props=x,z.state=te,z.context=ue,x=Q):(typeof z.componentDidMount=="function"&&(u.flags|=4194308),x=!1)}else{z=u.stateNode,Fj(l,u),Q=u.memoizedProps,ue=u.type===u.elementType?Q:gr(u.type,Q),z.props=ue,be=u.pendingProps,xe=z.context,te=m.contextType,typeof te=="object"&&te!==null?te=Xn(te):(te=yn(m)?Ka:tn.current,te=Zo(u,te));var Se=m.getDerivedStateFromProps;(ve=typeof Se=="function"||typeof z.getSnapshotBeforeUpdate=="function")||typeof z.UNSAFE_componentWillReceiveProps!="function"&&typeof z.componentWillReceiveProps!="function"||(Q!==be||xe!==te)&&hN(u,z,x,te),na=!1,xe=u.memoizedState,z.state=xe,qu(u,x,z,_);var Ce=u.memoizedState;Q!==be||xe!==Ce||gn.current||na?(typeof Se=="function"&&(em(u,m,Se,x),Ce=u.memoizedState),(ue=na||uN(u,m,ue,x,xe,Ce,te)||!1)?(ve||typeof z.UNSAFE_componentWillUpdate!="function"&&typeof z.componentWillUpdate!="function"||(typeof z.componentWillUpdate=="function"&&z.componentWillUpdate(x,Ce,te),typeof z.UNSAFE_componentWillUpdate=="function"&&z.UNSAFE_componentWillUpdate(x,Ce,te)),typeof z.componentDidUpdate=="function"&&(u.flags|=4),typeof z.getSnapshotBeforeUpdate=="function"&&(u.flags|=1024)):(typeof z.componentDidUpdate!="function"||Q===l.memoizedProps&&xe===l.memoizedState||(u.flags|=4),typeof z.getSnapshotBeforeUpdate!="function"||Q===l.memoizedProps&&xe===l.memoizedState||(u.flags|=1024),u.memoizedProps=x,u.memoizedState=Ce),z.props=x,z.state=Ce,z.context=te,x=ue):(typeof z.componentDidUpdate!="function"||Q===l.memoizedProps&&xe===l.memoizedState||(u.flags|=4),typeof z.getSnapshotBeforeUpdate!="function"||Q===l.memoizedProps&&xe===l.memoizedState||(u.flags|=1024),x=!1)}return am(l,u,m,x,R,_)}function am(l,u,m,x,_,R){kN(l,u);var z=(u.flags&128)!==0;if(!x&&!z)return _&&Cj(u,m,!1),bs(l,u,R);x=u.stateNode,F5.current=u;var Q=z&&typeof m.getDerivedStateFromError!="function"?null:x.render();return u.flags|=1,l!==null&&z?(u.child=ti(u,l.child,null,R),u.child=ti(u,null,Q,R)):ln(l,u,Q,R),u.memoizedState=x.state,_&&Cj(u,m,!0),u.child}function NN(l){var u=l.stateNode;u.pendingContext?_j(l,u.pendingContext,u.pendingContext!==u.context):u.context&&_j(l,u.context,!1),Up(l,u.containerInfo)}function SN(l,u,m,x,_){return ei(),Op(_),u.flags|=256,ln(l,u,m,x),u.child}var om={dehydrated:null,treeContext:null,retryLane:0};function im(l){return{baseLanes:l,cachePool:null,transitions:null}}function _N(l,u,m){var x=u.pendingProps,_=bt.current,R=!1,z=(u.flags&128)!==0,Q;if((Q=z)||(Q=l!==null&&l.memoizedState===null?!1:(_&2)!==0),Q?(R=!0,u.flags&=-129):(l===null||l.memoizedState!==null)&&(_|=1),ct(bt,_&1),l===null)return Lp(u),l=u.memoizedState,l!==null&&(l=l.dehydrated,l!==null)?((u.mode&1)===0?u.lanes=1:l.data==="$!"?u.lanes=8:u.lanes=1073741824,null):(z=x.children,l=x.fallback,R?(x=u.mode,R=u.child,z={mode:"hidden",children:z},(x&1)===0&&R!==null?(R.childLanes=0,R.pendingProps=z):R=ld(z,x,0,null),l=so(l,x,m,null),R.return=u,l.return=u,R.sibling=l,u.child=R,u.child.memoizedState=im(m),u.memoizedState=om,l):lm(u,z));if(_=l.memoizedState,_!==null&&(Q=_.dehydrated,Q!==null))return B5(l,u,z,x,Q,_,m);if(R){R=x.fallback,z=u.mode,_=l.child,Q=_.sibling;var te={mode:"hidden",children:x.children};return(z&1)===0&&u.child!==_?(x=u.child,x.childLanes=0,x.pendingProps=te,u.deletions=null):(x=ca(_,te),x.subtreeFlags=_.subtreeFlags&14680064),Q!==null?R=ca(Q,R):(R=so(R,z,m,null),R.flags|=2),R.return=u,x.return=u,x.sibling=R,u.child=x,x=R,R=u.child,z=l.child.memoizedState,z=z===null?im(m):{baseLanes:z.baseLanes|m,cachePool:null,transitions:z.transitions},R.memoizedState=z,R.childLanes=l.childLanes&~m,u.memoizedState=om,x}return R=l.child,l=R.sibling,x=ca(R,{mode:"visible",children:x.children}),(u.mode&1)===0&&(x.lanes=m),x.return=u,x.sibling=null,l!==null&&(m=u.deletions,m===null?(u.deletions=[l],u.flags|=16):m.push(l)),u.child=x,u.memoizedState=null,x}function lm(l,u){return u=ld({mode:"visible",children:u},l.mode,0,null),u.return=l,l.child=u}function Yu(l,u,m,x){return x!==null&&Op(x),ti(u,l.child,null,m),l=lm(u,u.pendingProps.children),l.flags|=2,u.memoizedState=null,l}function B5(l,u,m,x,_,R,z){if(m)return u.flags&256?(u.flags&=-257,x=nm(Error(n(422))),Yu(l,u,z,x)):u.memoizedState!==null?(u.child=l.child,u.flags|=128,null):(R=x.fallback,_=u.mode,x=ld({mode:"visible",children:x.children},_,0,null),R=so(R,_,z,null),R.flags|=2,x.return=u,R.return=u,x.sibling=R,u.child=x,(u.mode&1)!==0&&ti(u,l.child,null,z),u.child.memoizedState=im(z),u.memoizedState=om,R);if((u.mode&1)===0)return Yu(l,u,z,null);if(_.data==="$!"){if(x=_.nextSibling&&_.nextSibling.dataset,x)var Q=x.dgst;return x=Q,R=Error(n(419)),x=nm(R,x,void 0),Yu(l,u,z,x)}if(Q=(z&l.childLanes)!==0,wn||Q){if(x=Vt,x!==null){switch(z&-z){case 4:_=2;break;case 16:_=8;break;case 64:case 128:case 256:case 512:case 1024:case 2048:case 4096:case 8192:case 16384:case 32768:case 65536:case 131072:case 262144:case 524288:case 1048576:case 2097152:case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:_=32;break;case 536870912:_=268435456;break;default:_=0}_=(_&(x.suspendedLanes|z))!==0?0:_,_!==0&&_!==R.retryLane&&(R.retryLane=_,xs(l,_),xr(x,l,_,-1))}return Nm(),x=nm(Error(n(421))),Yu(l,u,z,x)}return _.data==="$?"?(u.flags|=128,u.child=l.child,u=Q5.bind(null,l),_._reactRetry=u,null):(l=R.treeContext,In=Js(_.nextSibling),On=u,xt=!0,mr=null,l!==null&&(Kn[Yn++]=ys,Kn[Yn++]=ws,Kn[Yn++]=Ya,ys=l.id,ws=l.overflow,Ya=u),u=lm(u,x.children),u.flags|=4096,u)}function EN(l,u,m){l.lanes|=u;var x=l.alternate;x!==null&&(x.lanes|=u),Fp(l.return,u,m)}function cm(l,u,m,x,_){var R=l.memoizedState;R===null?l.memoizedState={isBackwards:u,rendering:null,renderingStartTime:0,last:x,tail:m,tailMode:_}:(R.isBackwards=u,R.rendering=null,R.renderingStartTime=0,R.last=x,R.tail=m,R.tailMode=_)}function CN(l,u,m){var x=u.pendingProps,_=x.revealOrder,R=x.tail;if(ln(l,u,x.children,m),x=bt.current,(x&2)!==0)x=x&1|2,u.flags|=128;else{if(l!==null&&(l.flags&128)!==0)e:for(l=u.child;l!==null;){if(l.tag===13)l.memoizedState!==null&&EN(l,m,u);else if(l.tag===19)EN(l,m,u);else if(l.child!==null){l.child.return=l,l=l.child;continue}if(l===u)break e;for(;l.sibling===null;){if(l.return===null||l.return===u)break e;l=l.return}l.sibling.return=l.return,l=l.sibling}x&=1}if(ct(bt,x),(u.mode&1)===0)u.memoizedState=null;else switch(_){case"forwards":for(m=u.child,_=null;m!==null;)l=m.alternate,l!==null&&Uu(l)===null&&(_=m),m=m.sibling;m=_,m===null?(_=u.child,u.child=null):(_=m.sibling,m.sibling=null),cm(u,!1,_,m,R);break;case"backwards":for(m=null,_=u.child,u.child=null;_!==null;){if(l=_.alternate,l!==null&&Uu(l)===null){u.child=_;break}l=_.sibling,_.sibling=m,m=_,_=l}cm(u,!0,m,null,R);break;case"together":cm(u,!1,null,null,void 0);break;default:u.memoizedState=null}return u.child}function Xu(l,u){(u.mode&1)===0&&l!==null&&(l.alternate=null,u.alternate=null,u.flags|=2)}function bs(l,u,m){if(l!==null&&(u.dependencies=l.dependencies),eo|=u.lanes,(m&u.childLanes)===0)return null;if(l!==null&&u.child!==l.child)throw Error(n(153));if(u.child!==null){for(l=u.child,m=ca(l,l.pendingProps),u.child=m,m.return=u;l.sibling!==null;)l=l.sibling,m=m.sibling=ca(l,l.pendingProps),m.return=u;m.sibling=null}return u.child}function q5(l,u,m){switch(u.tag){case 3:NN(u),ei();break;case 5:Uj(u);break;case 1:yn(u.type)&&Mu(u);break;case 4:Up(u,u.stateNode.containerInfo);break;case 10:var x=u.type._context,_=u.memoizedProps.value;ct(Du,x._currentValue),x._currentValue=_;break;case 13:if(x=u.memoizedState,x!==null)return x.dehydrated!==null?(ct(bt,bt.current&1),u.flags|=128,null):(m&u.child.childLanes)!==0?_N(l,u,m):(ct(bt,bt.current&1),l=bs(l,u,m),l!==null?l.sibling:null);ct(bt,bt.current&1);break;case 19:if(x=(m&u.childLanes)!==0,(l.flags&128)!==0){if(x)return CN(l,u,m);u.flags|=128}if(_=u.memoizedState,_!==null&&(_.rendering=null,_.tail=null,_.lastEffect=null),ct(bt,bt.current),x)break;return null;case 22:case 23:return u.lanes=0,bN(l,u,m)}return bs(l,u,m)}var TN,um,RN,AN;TN=function(l,u){for(var m=u.child;m!==null;){if(m.tag===5||m.tag===6)l.appendChild(m.stateNode);else if(m.tag!==4&&m.child!==null){m.child.return=m,m=m.child;continue}if(m===u)break;for(;m.sibling===null;){if(m.return===null||m.return===u)return;m=m.return}m.sibling.return=m.return,m=m.sibling}},um=function(){},RN=function(l,u,m,x){var _=l.memoizedProps;if(_!==x){l=u.stateNode,Ja(zr.current);var R=null;switch(m){case"input":_=pe(l,_),x=pe(l,x),R=[];break;case"select":_=q({},_,{value:void 0}),x=q({},x,{value:void 0}),R=[];break;case"textarea":_=Ae(l,_),x=Ae(l,x),R=[];break;default:typeof _.onClick!="function"&&typeof x.onClick=="function"&&(l.onclick=Tu)}at(m,x);var z;m=null;for(ue in _)if(!x.hasOwnProperty(ue)&&_.hasOwnProperty(ue)&&_[ue]!=null)if(ue==="style"){var Q=_[ue];for(z in Q)Q.hasOwnProperty(z)&&(m||(m={}),m[z]="")}else ue!=="dangerouslySetInnerHTML"&&ue!=="children"&&ue!=="suppressContentEditableWarning"&&ue!=="suppressHydrationWarning"&&ue!=="autoFocus"&&(s.hasOwnProperty(ue)?R||(R=[]):(R=R||[]).push(ue,null));for(ue in x){var te=x[ue];if(Q=_!=null?_[ue]:void 0,x.hasOwnProperty(ue)&&te!==Q&&(te!=null||Q!=null))if(ue==="style")if(Q){for(z in Q)!Q.hasOwnProperty(z)||te&&te.hasOwnProperty(z)||(m||(m={}),m[z]="");for(z in te)te.hasOwnProperty(z)&&Q[z]!==te[z]&&(m||(m={}),m[z]=te[z])}else m||(R||(R=[]),R.push(ue,m)),m=te;else ue==="dangerouslySetInnerHTML"?(te=te?te.__html:void 0,Q=Q?Q.__html:void 0,te!=null&&Q!==te&&(R=R||[]).push(ue,te)):ue==="children"?typeof te!="string"&&typeof te!="number"||(R=R||[]).push(ue,""+te):ue!=="suppressContentEditableWarning"&&ue!=="suppressHydrationWarning"&&(s.hasOwnProperty(ue)?(te!=null&&ue==="onScroll"&&mt("scroll",l),R||Q===te||(R=[])):(R=R||[]).push(ue,te))}m&&(R=R||[]).push("style",m);var ue=R;(u.updateQueue=ue)&&(u.flags|=4)}},AN=function(l,u,m,x){m!==x&&(u.flags|=4)};function Fl(l,u){if(!xt)switch(l.tailMode){case"hidden":u=l.tail;for(var m=null;u!==null;)u.alternate!==null&&(m=u),u=u.sibling;m===null?l.tail=null:m.sibling=null;break;case"collapsed":m=l.tail;for(var x=null;m!==null;)m.alternate!==null&&(x=m),m=m.sibling;x===null?u||l.tail===null?l.tail=null:l.tail.sibling=null:x.sibling=null}}function rn(l){var u=l.alternate!==null&&l.alternate.child===l.child,m=0,x=0;if(u)for(var _=l.child;_!==null;)m|=_.lanes|_.childLanes,x|=_.subtreeFlags&14680064,x|=_.flags&14680064,_.return=l,_=_.sibling;else for(_=l.child;_!==null;)m|=_.lanes|_.childLanes,x|=_.subtreeFlags,x|=_.flags,_.return=l,_=_.sibling;return l.subtreeFlags|=x,l.childLanes=m,u}function U5(l,u,m){var x=u.pendingProps;switch(Mp(u),u.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return rn(u),null;case 1:return yn(u.type)&&Au(),rn(u),null;case 3:return x=u.stateNode,si(),gt(gn),gt(tn),zp(),x.pendingContext&&(x.context=x.pendingContext,x.pendingContext=null),(l===null||l.child===null)&&(Iu(u)?u.flags|=4:l===null||l.memoizedState.isDehydrated&&(u.flags&256)===0||(u.flags|=1024,mr!==null&&(bm(mr),mr=null))),um(l,u),rn(u),null;case 5:Hp(u);var _=Ja(Ll.current);if(m=u.type,l!==null&&u.stateNode!=null)RN(l,u,m,x,_),l.ref!==u.ref&&(u.flags|=512,u.flags|=2097152);else{if(!x){if(u.stateNode===null)throw Error(n(166));return rn(u),null}if(l=Ja(zr.current),Iu(u)){x=u.stateNode,m=u.type;var R=u.memoizedProps;switch(x[Wr]=u,x[Tl]=R,l=(u.mode&1)!==0,m){case"dialog":mt("cancel",x),mt("close",x);break;case"iframe":case"object":case"embed":mt("load",x);break;case"video":case"audio":for(_=0;_<_l.length;_++)mt(_l[_],x);break;case"source":mt("error",x);break;case"img":case"image":case"link":mt("error",x),mt("load",x);break;case"details":mt("toggle",x);break;case"input":fe(x,R),mt("invalid",x);break;case"select":x._wrapperState={wasMultiple:!!R.multiple},mt("invalid",x);break;case"textarea":Oe(x,R),mt("invalid",x)}at(m,R),_=null;for(var z in R)if(R.hasOwnProperty(z)){var Q=R[z];z==="children"?typeof Q=="string"?x.textContent!==Q&&(R.suppressHydrationWarning!==!0&&Cu(x.textContent,Q,l),_=["children",Q]):typeof Q=="number"&&x.textContent!==""+Q&&(R.suppressHydrationWarning!==!0&&Cu(x.textContent,Q,l),_=["children",""+Q]):s.hasOwnProperty(z)&&Q!=null&&z==="onScroll"&&mt("scroll",x)}switch(m){case"input":ce(x),oe(x,R,!0);break;case"textarea":ce(x),Me(x);break;case"select":case"option":break;default:typeof R.onClick=="function"&&(x.onclick=Tu)}x=_,u.updateQueue=x,x!==null&&(u.flags|=4)}else{z=_.nodeType===9?_:_.ownerDocument,l==="http://www.w3.org/1999/xhtml"&&(l=He(m)),l==="http://www.w3.org/1999/xhtml"?m==="script"?(l=z.createElement("div"),l.innerHTML="<script><\/script>",l=l.removeChild(l.firstChild)):typeof x.is=="string"?l=z.createElement(m,{is:x.is}):(l=z.createElement(m),m==="select"&&(z=l,x.multiple?z.multiple=!0:x.size&&(z.size=x.size))):l=z.createElementNS(l,m),l[Wr]=u,l[Tl]=x,TN(l,u,!1,!1),u.stateNode=l;e:{switch(z=At(m,x),m){case"dialog":mt("cancel",l),mt("close",l),_=x;break;case"iframe":case"object":case"embed":mt("load",l),_=x;break;case"video":case"audio":for(_=0;_<_l.length;_++)mt(_l[_],l);_=x;break;case"source":mt("error",l),_=x;break;case"img":case"image":case"link":mt("error",l),mt("load",l),_=x;break;case"details":mt("toggle",l),_=x;break;case"input":fe(l,x),_=pe(l,x),mt("invalid",l);break;case"option":_=x;break;case"select":l._wrapperState={wasMultiple:!!x.multiple},_=q({},x,{value:void 0}),mt("invalid",l);break;case"textarea":Oe(l,x),_=Ae(l,x),mt("invalid",l);break;default:_=x}at(m,_),Q=_;for(R in Q)if(Q.hasOwnProperty(R)){var te=Q[R];R==="style"?Be(l,te):R==="dangerouslySetInnerHTML"?(te=te?te.__html:void 0,te!=null&&it(l,te)):R==="children"?typeof te=="string"?(m!=="textarea"||te!=="")&&Et(l,te):typeof te=="number"&&Et(l,""+te):R!=="suppressContentEditableWarning"&&R!=="suppressHydrationWarning"&&R!=="autoFocus"&&(s.hasOwnProperty(R)?te!=null&&R==="onScroll"&&mt("scroll",l):te!=null&&S(l,R,te,z))}switch(m){case"input":ce(l),oe(l,x,!1);break;case"textarea":ce(l),Me(l);break;case"option":x.value!=null&&l.setAttribute("value",""+ee(x.value));break;case"select":l.multiple=!!x.multiple,R=x.value,R!=null?ge(l,!!x.multiple,R,!1):x.defaultValue!=null&&ge(l,!!x.multiple,x.defaultValue,!0);break;default:typeof _.onClick=="function"&&(l.onclick=Tu)}switch(m){case"button":case"input":case"select":case"textarea":x=!!x.autoFocus;break e;case"img":x=!0;break e;default:x=!1}}x&&(u.flags|=4)}u.ref!==null&&(u.flags|=512,u.flags|=2097152)}return rn(u),null;case 6:if(l&&u.stateNode!=null)AN(l,u,l.memoizedProps,x);else{if(typeof x!="string"&&u.stateNode===null)throw Error(n(166));if(m=Ja(Ll.current),Ja(zr.current),Iu(u)){if(x=u.stateNode,m=u.memoizedProps,x[Wr]=u,(R=x.nodeValue!==m)&&(l=On,l!==null))switch(l.tag){case 3:Cu(x.nodeValue,m,(l.mode&1)!==0);break;case 5:l.memoizedProps.suppressHydrationWarning!==!0&&Cu(x.nodeValue,m,(l.mode&1)!==0)}R&&(u.flags|=4)}else x=(m.nodeType===9?m:m.ownerDocument).createTextNode(x),x[Wr]=u,u.stateNode=x}return rn(u),null;case 13:if(gt(bt),x=u.memoizedState,l===null||l.memoizedState!==null&&l.memoizedState.dehydrated!==null){if(xt&&In!==null&&(u.mode&1)!==0&&(u.flags&128)===0)Lj(),ei(),u.flags|=98560,R=!1;else if(R=Iu(u),x!==null&&x.dehydrated!==null){if(l===null){if(!R)throw Error(n(318));if(R=u.memoizedState,R=R!==null?R.dehydrated:null,!R)throw Error(n(317));R[Wr]=u}else ei(),(u.flags&128)===0&&(u.memoizedState=null),u.flags|=4;rn(u),R=!1}else mr!==null&&(bm(mr),mr=null),R=!0;if(!R)return u.flags&65536?u:null}return(u.flags&128)!==0?(u.lanes=m,u):(x=x!==null,x!==(l!==null&&l.memoizedState!==null)&&x&&(u.child.flags|=8192,(u.mode&1)!==0&&(l===null||(bt.current&1)!==0?Dt===0&&(Dt=3):Nm())),u.updateQueue!==null&&(u.flags|=4),rn(u),null);case 4:return si(),um(l,u),l===null&&El(u.stateNode.containerInfo),rn(u),null;case 10:return Dp(u.type._context),rn(u),null;case 17:return yn(u.type)&&Au(),rn(u),null;case 19:if(gt(bt),R=u.memoizedState,R===null)return rn(u),null;if(x=(u.flags&128)!==0,z=R.rendering,z===null)if(x)Fl(R,!1);else{if(Dt!==0||l!==null&&(l.flags&128)!==0)for(l=u.child;l!==null;){if(z=Uu(l),z!==null){for(u.flags|=128,Fl(R,!1),x=z.updateQueue,x!==null&&(u.updateQueue=x,u.flags|=4),u.subtreeFlags=0,x=m,m=u.child;m!==null;)R=m,l=x,R.flags&=14680066,z=R.alternate,z===null?(R.childLanes=0,R.lanes=l,R.child=null,R.subtreeFlags=0,R.memoizedProps=null,R.memoizedState=null,R.updateQueue=null,R.dependencies=null,R.stateNode=null):(R.childLanes=z.childLanes,R.lanes=z.lanes,R.child=z.child,R.subtreeFlags=0,R.deletions=null,R.memoizedProps=z.memoizedProps,R.memoizedState=z.memoizedState,R.updateQueue=z.updateQueue,R.type=z.type,l=z.dependencies,R.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext}),m=m.sibling;return ct(bt,bt.current&1|2),u.child}l=l.sibling}R.tail!==null&&me()>li&&(u.flags|=128,x=!0,Fl(R,!1),u.lanes=4194304)}else{if(!x)if(l=Uu(z),l!==null){if(u.flags|=128,x=!0,m=l.updateQueue,m!==null&&(u.updateQueue=m,u.flags|=4),Fl(R,!0),R.tail===null&&R.tailMode==="hidden"&&!z.alternate&&!xt)return rn(u),null}else 2*me()-R.renderingStartTime>li&&m!==1073741824&&(u.flags|=128,x=!0,Fl(R,!1),u.lanes=4194304);R.isBackwards?(z.sibling=u.child,u.child=z):(m=R.last,m!==null?m.sibling=z:u.child=z,R.last=z)}return R.tail!==null?(u=R.tail,R.rendering=u,R.tail=u.sibling,R.renderingStartTime=me(),u.sibling=null,m=bt.current,ct(bt,x?m&1|2:m&1),u):(rn(u),null);case 22:case 23:return jm(),x=u.memoizedState!==null,l!==null&&l.memoizedState!==null!==x&&(u.flags|=8192),x&&(u.mode&1)!==0?(Pn&1073741824)!==0&&(rn(u),u.subtreeFlags&6&&(u.flags|=8192)):rn(u),null;case 24:return null;case 25:return null}throw Error(n(156,u.tag))}function H5(l,u){switch(Mp(u),u.tag){case 1:return yn(u.type)&&Au(),l=u.flags,l&65536?(u.flags=l&-65537|128,u):null;case 3:return si(),gt(gn),gt(tn),zp(),l=u.flags,(l&65536)!==0&&(l&128)===0?(u.flags=l&-65537|128,u):null;case 5:return Hp(u),null;case 13:if(gt(bt),l=u.memoizedState,l!==null&&l.dehydrated!==null){if(u.alternate===null)throw Error(n(340));ei()}return l=u.flags,l&65536?(u.flags=l&-65537|128,u):null;case 19:return gt(bt),null;case 4:return si(),null;case 10:return Dp(u.type._context),null;case 22:case 23:return jm(),null;case 24:return null;default:return null}}var Zu=!1,sn=!1,W5=typeof WeakSet=="function"?WeakSet:Set,_e=null;function oi(l,u){var m=l.ref;if(m!==null)if(typeof m=="function")try{m(null)}catch(x){St(l,u,x)}else m.current=null}function dm(l,u,m){try{m()}catch(x){St(l,u,x)}}var MN=!1;function z5(l,u){if(jp=Ba,l=uj(),mp(l)){if("selectionStart"in l)var m={start:l.selectionStart,end:l.selectionEnd};else e:{m=(m=l.ownerDocument)&&m.defaultView||window;var x=m.getSelection&&m.getSelection();if(x&&x.rangeCount!==0){m=x.anchorNode;var _=x.anchorOffset,R=x.focusNode;x=x.focusOffset;try{m.nodeType,R.nodeType}catch{m=null;break e}var z=0,Q=-1,te=-1,ue=0,ve=0,be=l,xe=null;t:for(;;){for(var Se;be!==m||_!==0&&be.nodeType!==3||(Q=z+_),be!==R||x!==0&&be.nodeType!==3||(te=z+x),be.nodeType===3&&(z+=be.nodeValue.length),(Se=be.firstChild)!==null;)xe=be,be=Se;for(;;){if(be===l)break t;if(xe===m&&++ue===_&&(Q=z),xe===R&&++ve===x&&(te=z),(Se=be.nextSibling)!==null)break;be=xe,xe=be.parentNode}be=Se}m=Q===-1||te===-1?null:{start:Q,end:te}}else m=null}m=m||{start:0,end:0}}else m=null;for(Np={focusedElem:l,selectionRange:m},Ba=!1,_e=u;_e!==null;)if(u=_e,l=u.child,(u.subtreeFlags&1028)!==0&&l!==null)l.return=u,_e=l;else for(;_e!==null;){u=_e;try{var Ce=u.alternate;if((u.flags&1024)!==0)switch(u.tag){case 0:case 11:case 15:break;case 1:if(Ce!==null){var Te=Ce.memoizedProps,Tt=Ce.memoizedState,ie=u.stateNode,re=ie.getSnapshotBeforeUpdate(u.elementType===u.type?Te:gr(u.type,Te),Tt);ie.__reactInternalSnapshotBeforeUpdate=re}break;case 3:var le=u.stateNode.containerInfo;le.nodeType===1?le.textContent="":le.nodeType===9&&le.documentElement&&le.removeChild(le.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(ke){St(u,u.return,ke)}if(l=u.sibling,l!==null){l.return=u.return,_e=l;break}_e=u.return}return Ce=MN,MN=!1,Ce}function Bl(l,u,m){var x=u.updateQueue;if(x=x!==null?x.lastEffect:null,x!==null){var _=x=x.next;do{if((_.tag&l)===l){var R=_.destroy;_.destroy=void 0,R!==void 0&&dm(u,m,R)}_=_.next}while(_!==x)}}function Ju(l,u){if(u=u.updateQueue,u=u!==null?u.lastEffect:null,u!==null){var m=u=u.next;do{if((m.tag&l)===l){var x=m.create;m.destroy=x()}m=m.next}while(m!==u)}}function hm(l){var u=l.ref;if(u!==null){var m=l.stateNode;switch(l.tag){case 5:l=m;break;default:l=m}typeof u=="function"?u(l):u.current=l}}function $N(l){var u=l.alternate;u!==null&&(l.alternate=null,$N(u)),l.child=null,l.deletions=null,l.sibling=null,l.tag===5&&(u=l.stateNode,u!==null&&(delete u[Wr],delete u[Tl],delete u[Cp],delete u[E5],delete u[C5])),l.stateNode=null,l.return=null,l.dependencies=null,l.memoizedProps=null,l.memoizedState=null,l.pendingProps=null,l.stateNode=null,l.updateQueue=null}function LN(l){return l.tag===5||l.tag===3||l.tag===4}function ON(l){e:for(;;){for(;l.sibling===null;){if(l.return===null||LN(l.return))return null;l=l.return}for(l.sibling.return=l.return,l=l.sibling;l.tag!==5&&l.tag!==6&&l.tag!==18;){if(l.flags&2||l.child===null||l.tag===4)continue e;l.child.return=l,l=l.child}if(!(l.flags&2))return l.stateNode}}function fm(l,u,m){var x=l.tag;if(x===5||x===6)l=l.stateNode,u?m.nodeType===8?m.parentNode.insertBefore(l,u):m.insertBefore(l,u):(m.nodeType===8?(u=m.parentNode,u.insertBefore(l,m)):(u=m,u.appendChild(l)),m=m._reactRootContainer,m!=null||u.onclick!==null||(u.onclick=Tu));else if(x!==4&&(l=l.child,l!==null))for(fm(l,u,m),l=l.sibling;l!==null;)fm(l,u,m),l=l.sibling}function pm(l,u,m){var x=l.tag;if(x===5||x===6)l=l.stateNode,u?m.insertBefore(l,u):m.appendChild(l);else if(x!==4&&(l=l.child,l!==null))for(pm(l,u,m),l=l.sibling;l!==null;)pm(l,u,m),l=l.sibling}var Xt=null,yr=!1;function sa(l,u,m){for(m=m.child;m!==null;)IN(l,u,m),m=m.sibling}function IN(l,u,m){if(Nt&&typeof Nt.onCommitFiberUnmount=="function")try{Nt.onCommitFiberUnmount(hr,m)}catch{}switch(m.tag){case 5:sn||oi(m,u);case 6:var x=Xt,_=yr;Xt=null,sa(l,u,m),Xt=x,yr=_,Xt!==null&&(yr?(l=Xt,m=m.stateNode,l.nodeType===8?l.parentNode.removeChild(m):l.removeChild(m)):Xt.removeChild(m.stateNode));break;case 18:Xt!==null&&(yr?(l=Xt,m=m.stateNode,l.nodeType===8?Ep(l.parentNode,m):l.nodeType===1&&Ep(l,m),Fa(l)):Ep(Xt,m.stateNode));break;case 4:x=Xt,_=yr,Xt=m.stateNode.containerInfo,yr=!0,sa(l,u,m),Xt=x,yr=_;break;case 0:case 11:case 14:case 15:if(!sn&&(x=m.updateQueue,x!==null&&(x=x.lastEffect,x!==null))){_=x=x.next;do{var R=_,z=R.destroy;R=R.tag,z!==void 0&&((R&2)!==0||(R&4)!==0)&&dm(m,u,z),_=_.next}while(_!==x)}sa(l,u,m);break;case 1:if(!sn&&(oi(m,u),x=m.stateNode,typeof x.componentWillUnmount=="function"))try{x.props=m.memoizedProps,x.state=m.memoizedState,x.componentWillUnmount()}catch(Q){St(m,u,Q)}sa(l,u,m);break;case 21:sa(l,u,m);break;case 22:m.mode&1?(sn=(x=sn)||m.memoizedState!==null,sa(l,u,m),sn=x):sa(l,u,m);break;default:sa(l,u,m)}}function PN(l){var u=l.updateQueue;if(u!==null){l.updateQueue=null;var m=l.stateNode;m===null&&(m=l.stateNode=new W5),u.forEach(function(x){var _=e6.bind(null,l,x);m.has(x)||(m.add(x),x.then(_,_))})}}function wr(l,u){var m=u.deletions;if(m!==null)for(var x=0;x<m.length;x++){var _=m[x];try{var R=l,z=u,Q=z;e:for(;Q!==null;){switch(Q.tag){case 5:Xt=Q.stateNode,yr=!1;break e;case 3:Xt=Q.stateNode.containerInfo,yr=!0;break e;case 4:Xt=Q.stateNode.containerInfo,yr=!0;break e}Q=Q.return}if(Xt===null)throw Error(n(160));IN(R,z,_),Xt=null,yr=!1;var te=_.alternate;te!==null&&(te.return=null),_.return=null}catch(ue){St(_,u,ue)}}if(u.subtreeFlags&12854)for(u=u.child;u!==null;)DN(u,l),u=u.sibling}function DN(l,u){var m=l.alternate,x=l.flags;switch(l.tag){case 0:case 11:case 14:case 15:if(wr(u,l),Gr(l),x&4){try{Bl(3,l,l.return),Ju(3,l)}catch(Te){St(l,l.return,Te)}try{Bl(5,l,l.return)}catch(Te){St(l,l.return,Te)}}break;case 1:wr(u,l),Gr(l),x&512&&m!==null&&oi(m,m.return);break;case 5:if(wr(u,l),Gr(l),x&512&&m!==null&&oi(m,m.return),l.flags&32){var _=l.stateNode;try{Et(_,"")}catch(Te){St(l,l.return,Te)}}if(x&4&&(_=l.stateNode,_!=null)){var R=l.memoizedProps,z=m!==null?m.memoizedProps:R,Q=l.type,te=l.updateQueue;if(l.updateQueue=null,te!==null)try{Q==="input"&&R.type==="radio"&&R.name!=null&&Ee(_,R),At(Q,z);var ue=At(Q,R);for(z=0;z<te.length;z+=2){var ve=te[z],be=te[z+1];ve==="style"?Be(_,be):ve==="dangerouslySetInnerHTML"?it(_,be):ve==="children"?Et(_,be):S(_,ve,be,ue)}switch(Q){case"input":ye(_,R);break;case"textarea":qe(_,R);break;case"select":var xe=_._wrapperState.wasMultiple;_._wrapperState.wasMultiple=!!R.multiple;var Se=R.value;Se!=null?ge(_,!!R.multiple,Se,!1):xe!==!!R.multiple&&(R.defaultValue!=null?ge(_,!!R.multiple,R.defaultValue,!0):ge(_,!!R.multiple,R.multiple?[]:"",!1))}_[Tl]=R}catch(Te){St(l,l.return,Te)}}break;case 6:if(wr(u,l),Gr(l),x&4){if(l.stateNode===null)throw Error(n(162));_=l.stateNode,R=l.memoizedProps;try{_.nodeValue=R}catch(Te){St(l,l.return,Te)}}break;case 3:if(wr(u,l),Gr(l),x&4&&m!==null&&m.memoizedState.isDehydrated)try{Fa(u.containerInfo)}catch(Te){St(l,l.return,Te)}break;case 4:wr(u,l),Gr(l);break;case 13:wr(u,l),Gr(l),_=l.child,_.flags&8192&&(R=_.memoizedState!==null,_.stateNode.isHidden=R,!R||_.alternate!==null&&_.alternate.memoizedState!==null||(ym=me())),x&4&&PN(l);break;case 22:if(ve=m!==null&&m.memoizedState!==null,l.mode&1?(sn=(ue=sn)||ve,wr(u,l),sn=ue):wr(u,l),Gr(l),x&8192){if(ue=l.memoizedState!==null,(l.stateNode.isHidden=ue)&&!ve&&(l.mode&1)!==0)for(_e=l,ve=l.child;ve!==null;){for(be=_e=ve;_e!==null;){switch(xe=_e,Se=xe.child,xe.tag){case 0:case 11:case 14:case 15:Bl(4,xe,xe.return);break;case 1:oi(xe,xe.return);var Ce=xe.stateNode;if(typeof Ce.componentWillUnmount=="function"){x=xe,m=xe.return;try{u=x,Ce.props=u.memoizedProps,Ce.state=u.memoizedState,Ce.componentWillUnmount()}catch(Te){St(x,m,Te)}}break;case 5:oi(xe,xe.return);break;case 22:if(xe.memoizedState!==null){qN(be);continue}}Se!==null?(Se.return=xe,_e=Se):qN(be)}ve=ve.sibling}e:for(ve=null,be=l;;){if(be.tag===5){if(ve===null){ve=be;try{_=be.stateNode,ue?(R=_.style,typeof R.setProperty=="function"?R.setProperty("display","none","important"):R.display="none"):(Q=be.stateNode,te=be.memoizedProps.style,z=te!=null&&te.hasOwnProperty("display")?te.display:null,Q.style.display=ft("display",z))}catch(Te){St(l,l.return,Te)}}}else if(be.tag===6){if(ve===null)try{be.stateNode.nodeValue=ue?"":be.memoizedProps}catch(Te){St(l,l.return,Te)}}else if((be.tag!==22&&be.tag!==23||be.memoizedState===null||be===l)&&be.child!==null){be.child.return=be,be=be.child;continue}if(be===l)break e;for(;be.sibling===null;){if(be.return===null||be.return===l)break e;ve===be&&(ve=null),be=be.return}ve===be&&(ve=null),be.sibling.return=be.return,be=be.sibling}}break;case 19:wr(u,l),Gr(l),x&4&&PN(l);break;case 21:break;default:wr(u,l),Gr(l)}}function Gr(l){var u=l.flags;if(u&2){try{e:{for(var m=l.return;m!==null;){if(LN(m)){var x=m;break e}m=m.return}throw Error(n(160))}switch(x.tag){case 5:var _=x.stateNode;x.flags&32&&(Et(_,""),x.flags&=-33);var R=ON(l);pm(l,R,_);break;case 3:case 4:var z=x.stateNode.containerInfo,Q=ON(l);fm(l,Q,z);break;default:throw Error(n(161))}}catch(te){St(l,l.return,te)}l.flags&=-3}u&4096&&(l.flags&=-4097)}function V5(l,u,m){_e=l,FN(l)}function FN(l,u,m){for(var x=(l.mode&1)!==0;_e!==null;){var _=_e,R=_.child;if(_.tag===22&&x){var z=_.memoizedState!==null||Zu;if(!z){var Q=_.alternate,te=Q!==null&&Q.memoizedState!==null||sn;Q=Zu;var ue=sn;if(Zu=z,(sn=te)&&!ue)for(_e=_;_e!==null;)z=_e,te=z.child,z.tag===22&&z.memoizedState!==null?UN(_):te!==null?(te.return=z,_e=te):UN(_);for(;R!==null;)_e=R,FN(R),R=R.sibling;_e=_,Zu=Q,sn=ue}BN(l)}else(_.subtreeFlags&8772)!==0&&R!==null?(R.return=_,_e=R):BN(l)}}function BN(l){for(;_e!==null;){var u=_e;if((u.flags&8772)!==0){var m=u.alternate;try{if((u.flags&8772)!==0)switch(u.tag){case 0:case 11:case 15:sn||Ju(5,u);break;case 1:var x=u.stateNode;if(u.flags&4&&!sn)if(m===null)x.componentDidMount();else{var _=u.elementType===u.type?m.memoizedProps:gr(u.type,m.memoizedProps);x.componentDidUpdate(_,m.memoizedState,x.__reactInternalSnapshotBeforeUpdate)}var R=u.updateQueue;R!==null&&qj(u,R,x);break;case 3:var z=u.updateQueue;if(z!==null){if(m=null,u.child!==null)switch(u.child.tag){case 5:m=u.child.stateNode;break;case 1:m=u.child.stateNode}qj(u,z,m)}break;case 5:var Q=u.stateNode;if(m===null&&u.flags&4){m=Q;var te=u.memoizedProps;switch(u.type){case"button":case"input":case"select":case"textarea":te.autoFocus&&m.focus();break;case"img":te.src&&(m.src=te.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(u.memoizedState===null){var ue=u.alternate;if(ue!==null){var ve=ue.memoizedState;if(ve!==null){var be=ve.dehydrated;be!==null&&Fa(be)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}sn||u.flags&512&&hm(u)}catch(xe){St(u,u.return,xe)}}if(u===l){_e=null;break}if(m=u.sibling,m!==null){m.return=u.return,_e=m;break}_e=u.return}}function qN(l){for(;_e!==null;){var u=_e;if(u===l){_e=null;break}var m=u.sibling;if(m!==null){m.return=u.return,_e=m;break}_e=u.return}}function UN(l){for(;_e!==null;){var u=_e;try{switch(u.tag){case 0:case 11:case 15:var m=u.return;try{Ju(4,u)}catch(te){St(u,m,te)}break;case 1:var x=u.stateNode;if(typeof x.componentDidMount=="function"){var _=u.return;try{x.componentDidMount()}catch(te){St(u,_,te)}}var R=u.return;try{hm(u)}catch(te){St(u,R,te)}break;case 5:var z=u.return;try{hm(u)}catch(te){St(u,z,te)}}}catch(te){St(u,u.return,te)}if(u===l){_e=null;break}var Q=u.sibling;if(Q!==null){Q.return=u.return,_e=Q;break}_e=u.return}}var G5=Math.ceil,Qu=E.ReactCurrentDispatcher,mm=E.ReactCurrentOwner,Jn=E.ReactCurrentBatchConfig,Je=0,Vt=null,$t=null,Zt=0,Pn=0,ii=Qs(0),Dt=0,ql=null,eo=0,ed=0,gm=0,Ul=null,xn=null,ym=0,li=1/0,ks=null,td=!1,wm=null,aa=null,nd=!1,oa=null,rd=0,Hl=0,xm=null,sd=-1,ad=0;function cn(){return(Je&6)!==0?me():sd!==-1?sd:sd=me()}function ia(l){return(l.mode&1)===0?1:(Je&2)!==0&&Zt!==0?Zt&-Zt:R5.transition!==null?(ad===0&&(ad=du()),ad):(l=Ke,l!==0||(l=window.event,l=l===void 0?16:ml(l.type)),l)}function xr(l,u,m,x){if(50<Hl)throw Hl=0,xm=null,Error(n(185));Hs(l,m,x),((Je&2)===0||l!==Vt)&&(l===Vt&&((Je&2)===0&&(ed|=m),Dt===4&&la(l,Zt)),vn(l,x),m===1&&Je===0&&(u.mode&1)===0&&(li=me()+500,$u&&ta()))}function vn(l,u){var m=l.callbackNode;Pr(l,u);var x=Ia(l,l===Vt?Zt:0);if(x===0)m!==null&&cs(m),l.callbackNode=null,l.callbackPriority=0;else if(u=x&-x,l.callbackPriority!==u){if(m!=null&&cs(m),u===1)l.tag===0?T5(WN.bind(null,l)):Tj(WN.bind(null,l)),S5(function(){(Je&6)===0&&ta()}),m=null;else{switch(hu(x)){case 1:m=Ze;break;case 4:m=Mn;break;case 16:m=Or;break;case 536870912:m=Us;break;default:m=Or}m=JN(m,HN.bind(null,l))}l.callbackPriority=u,l.callbackNode=m}}function HN(l,u){if(sd=-1,ad=0,(Je&6)!==0)throw Error(n(327));var m=l.callbackNode;if(ci()&&l.callbackNode!==m)return null;var x=Ia(l,l===Vt?Zt:0);if(x===0)return null;if((x&30)!==0||(x&l.expiredLanes)!==0||u)u=od(l,x);else{u=x;var _=Je;Je|=2;var R=VN();(Vt!==l||Zt!==u)&&(ks=null,li=me()+500,no(l,u));do try{X5();break}catch(Q){zN(l,Q)}while(!0);Pp(),Qu.current=R,Je=_,$t!==null?u=0:(Vt=null,Zt=0,u=Dt)}if(u!==0){if(u===2&&(_=cl(l),_!==0&&(x=_,u=vm(l,_))),u===1)throw m=ql,no(l,0),la(l,x),vn(l,me()),m;if(u===6)la(l,x);else{if(_=l.current.alternate,(x&30)===0&&!K5(_)&&(u=od(l,x),u===2&&(R=cl(l),R!==0&&(x=R,u=vm(l,R))),u===1))throw m=ql,no(l,0),la(l,x),vn(l,me()),m;switch(l.finishedWork=_,l.finishedLanes=x,u){case 0:case 1:throw Error(n(345));case 2:ro(l,xn,ks);break;case 3:if(la(l,x),(x&130023424)===x&&(u=ym+500-me(),10<u)){if(Ia(l,0)!==0)break;if(_=l.suspendedLanes,(_&x)!==x){cn(),l.pingedLanes|=l.suspendedLanes&_;break}l.timeoutHandle=_p(ro.bind(null,l,xn,ks),u);break}ro(l,xn,ks);break;case 4:if(la(l,x),(x&4194240)===x)break;for(u=l.eventTimes,_=-1;0<x;){var z=31-en(x);R=1<<z,z=u[z],z>_&&(_=z),x&=~R}if(x=_,x=me()-x,x=(120>x?120:480>x?480:1080>x?1080:1920>x?1920:3e3>x?3e3:4320>x?4320:1960*G5(x/1960))-x,10<x){l.timeoutHandle=_p(ro.bind(null,l,xn,ks),x);break}ro(l,xn,ks);break;case 5:ro(l,xn,ks);break;default:throw Error(n(329))}}}return vn(l,me()),l.callbackNode===m?HN.bind(null,l):null}function vm(l,u){var m=Ul;return l.current.memoizedState.isDehydrated&&(no(l,u).flags|=256),l=od(l,u),l!==2&&(u=xn,xn=m,u!==null&&bm(u)),l}function bm(l){xn===null?xn=l:xn.push.apply(xn,l)}function K5(l){for(var u=l;;){if(u.flags&16384){var m=u.updateQueue;if(m!==null&&(m=m.stores,m!==null))for(var x=0;x<m.length;x++){var _=m[x],R=_.getSnapshot;_=_.value;try{if(!pr(R(),_))return!1}catch{return!1}}}if(m=u.child,u.subtreeFlags&16384&&m!==null)m.return=u,u=m;else{if(u===l)break;for(;u.sibling===null;){if(u.return===null||u.return===l)return!0;u=u.return}u.sibling.return=u.return,u=u.sibling}}return!0}function la(l,u){for(u&=~gm,u&=~ed,l.suspendedLanes|=u,l.pingedLanes&=~u,l=l.expirationTimes;0<u;){var m=31-en(u),x=1<<m;l[m]=-1,u&=~x}}function WN(l){if((Je&6)!==0)throw Error(n(327));ci();var u=Ia(l,0);if((u&1)===0)return vn(l,me()),null;var m=od(l,u);if(l.tag!==0&&m===2){var x=cl(l);x!==0&&(u=x,m=vm(l,x))}if(m===1)throw m=ql,no(l,0),la(l,u),vn(l,me()),m;if(m===6)throw Error(n(345));return l.finishedWork=l.current.alternate,l.finishedLanes=u,ro(l,xn,ks),vn(l,me()),null}function km(l,u){var m=Je;Je|=1;try{return l(u)}finally{Je=m,Je===0&&(li=me()+500,$u&&ta())}}function to(l){oa!==null&&oa.tag===0&&(Je&6)===0&&ci();var u=Je;Je|=1;var m=Jn.transition,x=Ke;try{if(Jn.transition=null,Ke=1,l)return l()}finally{Ke=x,Jn.transition=m,Je=u,(Je&6)===0&&ta()}}function jm(){Pn=ii.current,gt(ii)}function no(l,u){l.finishedWork=null,l.finishedLanes=0;var m=l.timeoutHandle;if(m!==-1&&(l.timeoutHandle=-1,N5(m)),$t!==null)for(m=$t.return;m!==null;){var x=m;switch(Mp(x),x.tag){case 1:x=x.type.childContextTypes,x!=null&&Au();break;case 3:si(),gt(gn),gt(tn),zp();break;case 5:Hp(x);break;case 4:si();break;case 13:gt(bt);break;case 19:gt(bt);break;case 10:Dp(x.type._context);break;case 22:case 23:jm()}m=m.return}if(Vt=l,$t=l=ca(l.current,null),Zt=Pn=u,Dt=0,ql=null,gm=ed=eo=0,xn=Ul=null,Za!==null){for(u=0;u<Za.length;u++)if(m=Za[u],x=m.interleaved,x!==null){m.interleaved=null;var _=x.next,R=m.pending;if(R!==null){var z=R.next;R.next=_,x.next=z}m.pending=x}Za=null}return l}function zN(l,u){do{var m=$t;try{if(Pp(),Hu.current=Gu,Wu){for(var x=kt.memoizedState;x!==null;){var _=x.queue;_!==null&&(_.pending=null),x=x.next}Wu=!1}if(Qa=0,zt=Pt=kt=null,Ol=!1,Il=0,mm.current=null,m===null||m.return===null){Dt=1,ql=u,$t=null;break}e:{var R=l,z=m.return,Q=m,te=u;if(u=Zt,Q.flags|=32768,te!==null&&typeof te=="object"&&typeof te.then=="function"){var ue=te,ve=Q,be=ve.tag;if((ve.mode&1)===0&&(be===0||be===11||be===15)){var xe=ve.alternate;xe?(ve.updateQueue=xe.updateQueue,ve.memoizedState=xe.memoizedState,ve.lanes=xe.lanes):(ve.updateQueue=null,ve.memoizedState=null)}var Se=gN(z);if(Se!==null){Se.flags&=-257,yN(Se,z,Q,R,u),Se.mode&1&&mN(R,ue,u),u=Se,te=ue;var Ce=u.updateQueue;if(Ce===null){var Te=new Set;Te.add(te),u.updateQueue=Te}else Ce.add(te);break e}else{if((u&1)===0){mN(R,ue,u),Nm();break e}te=Error(n(426))}}else if(xt&&Q.mode&1){var Tt=gN(z);if(Tt!==null){(Tt.flags&65536)===0&&(Tt.flags|=256),yN(Tt,z,Q,R,u),Op(ai(te,Q));break e}}R=te=ai(te,Q),Dt!==4&&(Dt=2),Ul===null?Ul=[R]:Ul.push(R),R=z;do{switch(R.tag){case 3:R.flags|=65536,u&=-u,R.lanes|=u;var ie=fN(R,te,u);Bj(R,ie);break e;case 1:Q=te;var re=R.type,le=R.stateNode;if((R.flags&128)===0&&(typeof re.getDerivedStateFromError=="function"||le!==null&&typeof le.componentDidCatch=="function"&&(aa===null||!aa.has(le)))){R.flags|=65536,u&=-u,R.lanes|=u;var ke=pN(R,Q,u);Bj(R,ke);break e}}R=R.return}while(R!==null)}KN(m)}catch(Re){u=Re,$t===m&&m!==null&&($t=m=m.return);continue}break}while(!0)}function VN(){var l=Qu.current;return Qu.current=Gu,l===null?Gu:l}function Nm(){(Dt===0||Dt===3||Dt===2)&&(Dt=4),Vt===null||(eo&268435455)===0&&(ed&268435455)===0||la(Vt,Zt)}function od(l,u){var m=Je;Je|=2;var x=VN();(Vt!==l||Zt!==u)&&(ks=null,no(l,u));do try{Y5();break}catch(_){zN(l,_)}while(!0);if(Pp(),Je=m,Qu.current=x,$t!==null)throw Error(n(261));return Vt=null,Zt=0,Dt}function Y5(){for(;$t!==null;)GN($t)}function X5(){for(;$t!==null&&!dr();)GN($t)}function GN(l){var u=ZN(l.alternate,l,Pn);l.memoizedProps=l.pendingProps,u===null?KN(l):$t=u,mm.current=null}function KN(l){var u=l;do{var m=u.alternate;if(l=u.return,(u.flags&32768)===0){if(m=U5(m,u,Pn),m!==null){$t=m;return}}else{if(m=H5(m,u),m!==null){m.flags&=32767,$t=m;return}if(l!==null)l.flags|=32768,l.subtreeFlags=0,l.deletions=null;else{Dt=6,$t=null;return}}if(u=u.sibling,u!==null){$t=u;return}$t=u=l}while(u!==null);Dt===0&&(Dt=5)}function ro(l,u,m){var x=Ke,_=Jn.transition;try{Jn.transition=null,Ke=1,Z5(l,u,m,x)}finally{Jn.transition=_,Ke=x}return null}function Z5(l,u,m,x){do ci();while(oa!==null);if((Je&6)!==0)throw Error(n(327));m=l.finishedWork;var _=l.finishedLanes;if(m===null)return null;if(l.finishedWork=null,l.finishedLanes=0,m===l.current)throw Error(n(177));l.callbackNode=null,l.callbackPriority=0;var R=m.lanes|m.childLanes;if(ul(l,R),l===Vt&&($t=Vt=null,Zt=0),(m.subtreeFlags&2064)===0&&(m.flags&2064)===0||nd||(nd=!0,JN(Or,function(){return ci(),null})),R=(m.flags&15990)!==0,(m.subtreeFlags&15990)!==0||R){R=Jn.transition,Jn.transition=null;var z=Ke;Ke=1;var Q=Je;Je|=4,mm.current=null,z5(l,m),DN(m,l),y5(Np),Ba=!!jp,Np=jp=null,l.current=m,V5(m),qs(),Je=Q,Ke=z,Jn.transition=R}else l.current=m;if(nd&&(nd=!1,oa=l,rd=_),R=l.pendingLanes,R===0&&(aa=null),Ir(m.stateNode),vn(l,me()),u!==null)for(x=l.onRecoverableError,m=0;m<u.length;m++)_=u[m],x(_.value,{componentStack:_.stack,digest:_.digest});if(td)throw td=!1,l=wm,wm=null,l;return(rd&1)!==0&&l.tag!==0&&ci(),R=l.pendingLanes,(R&1)!==0?l===xm?Hl++:(Hl=0,xm=l):Hl=0,ta(),null}function ci(){if(oa!==null){var l=hu(rd),u=Jn.transition,m=Ke;try{if(Jn.transition=null,Ke=16>l?16:l,oa===null)var x=!1;else{if(l=oa,oa=null,rd=0,(Je&6)!==0)throw Error(n(331));var _=Je;for(Je|=4,_e=l.current;_e!==null;){var R=_e,z=R.child;if((_e.flags&16)!==0){var Q=R.deletions;if(Q!==null){for(var te=0;te<Q.length;te++){var ue=Q[te];for(_e=ue;_e!==null;){var ve=_e;switch(ve.tag){case 0:case 11:case 15:Bl(8,ve,R)}var be=ve.child;if(be!==null)be.return=ve,_e=be;else for(;_e!==null;){ve=_e;var xe=ve.sibling,Se=ve.return;if($N(ve),ve===ue){_e=null;break}if(xe!==null){xe.return=Se,_e=xe;break}_e=Se}}}var Ce=R.alternate;if(Ce!==null){var Te=Ce.child;if(Te!==null){Ce.child=null;do{var Tt=Te.sibling;Te.sibling=null,Te=Tt}while(Te!==null)}}_e=R}}if((R.subtreeFlags&2064)!==0&&z!==null)z.return=R,_e=z;else e:for(;_e!==null;){if(R=_e,(R.flags&2048)!==0)switch(R.tag){case 0:case 11:case 15:Bl(9,R,R.return)}var ie=R.sibling;if(ie!==null){ie.return=R.return,_e=ie;break e}_e=R.return}}var re=l.current;for(_e=re;_e!==null;){z=_e;var le=z.child;if((z.subtreeFlags&2064)!==0&&le!==null)le.return=z,_e=le;else e:for(z=re;_e!==null;){if(Q=_e,(Q.flags&2048)!==0)try{switch(Q.tag){case 0:case 11:case 15:Ju(9,Q)}}catch(Re){St(Q,Q.return,Re)}if(Q===z){_e=null;break e}var ke=Q.sibling;if(ke!==null){ke.return=Q.return,_e=ke;break e}_e=Q.return}}if(Je=_,ta(),Nt&&typeof Nt.onPostCommitFiberRoot=="function")try{Nt.onPostCommitFiberRoot(hr,l)}catch{}x=!0}return x}finally{Ke=m,Jn.transition=u}}return!1}function YN(l,u,m){u=ai(m,u),u=fN(l,u,1),l=ra(l,u,1),u=cn(),l!==null&&(Hs(l,1,u),vn(l,u))}function St(l,u,m){if(l.tag===3)YN(l,l,m);else for(;u!==null;){if(u.tag===3){YN(u,l,m);break}else if(u.tag===1){var x=u.stateNode;if(typeof u.type.getDerivedStateFromError=="function"||typeof x.componentDidCatch=="function"&&(aa===null||!aa.has(x))){l=ai(m,l),l=pN(u,l,1),u=ra(u,l,1),l=cn(),u!==null&&(Hs(u,1,l),vn(u,l));break}}u=u.return}}function J5(l,u,m){var x=l.pingCache;x!==null&&x.delete(u),u=cn(),l.pingedLanes|=l.suspendedLanes&m,Vt===l&&(Zt&m)===m&&(Dt===4||Dt===3&&(Zt&130023424)===Zt&&500>me()-ym?no(l,0):gm|=m),vn(l,u)}function XN(l,u){u===0&&((l.mode&1)===0?u=1:(u=La,La<<=1,(La&130023424)===0&&(La=4194304)));var m=cn();l=xs(l,u),l!==null&&(Hs(l,u,m),vn(l,m))}function Q5(l){var u=l.memoizedState,m=0;u!==null&&(m=u.retryLane),XN(l,m)}function e6(l,u){var m=0;switch(l.tag){case 13:var x=l.stateNode,_=l.memoizedState;_!==null&&(m=_.retryLane);break;case 19:x=l.stateNode;break;default:throw Error(n(314))}x!==null&&x.delete(u),XN(l,m)}var ZN;ZN=function(l,u,m){if(l!==null)if(l.memoizedProps!==u.pendingProps||gn.current)wn=!0;else{if((l.lanes&m)===0&&(u.flags&128)===0)return wn=!1,q5(l,u,m);wn=(l.flags&131072)!==0}else wn=!1,xt&&(u.flags&1048576)!==0&&Rj(u,Ou,u.index);switch(u.lanes=0,u.tag){case 2:var x=u.type;Xu(l,u),l=u.pendingProps;var _=Zo(u,tn.current);ri(u,m),_=Kp(null,u,x,l,_,m);var R=Yp();return u.flags|=1,typeof _=="object"&&_!==null&&typeof _.render=="function"&&_.$$typeof===void 0?(u.tag=1,u.memoizedState=null,u.updateQueue=null,yn(x)?(R=!0,Mu(u)):R=!1,u.memoizedState=_.state!==null&&_.state!==void 0?_.state:null,qp(u),_.updater=Ku,u.stateNode=_,_._reactInternals=u,tm(u,x,l,m),u=am(null,u,x,!0,R,m)):(u.tag=0,xt&&R&&Ap(u),ln(null,u,_,m),u=u.child),u;case 16:x=u.elementType;e:{switch(Xu(l,u),l=u.pendingProps,_=x._init,x=_(x._payload),u.type=x,_=u.tag=n6(x),l=gr(x,l),_){case 0:u=sm(null,u,x,l,m);break e;case 1:u=jN(null,u,x,l,m);break e;case 11:u=wN(null,u,x,l,m);break e;case 14:u=xN(null,u,x,gr(x.type,l),m);break e}throw Error(n(306,x,""))}return u;case 0:return x=u.type,_=u.pendingProps,_=u.elementType===x?_:gr(x,_),sm(l,u,x,_,m);case 1:return x=u.type,_=u.pendingProps,_=u.elementType===x?_:gr(x,_),jN(l,u,x,_,m);case 3:e:{if(NN(u),l===null)throw Error(n(387));x=u.pendingProps,R=u.memoizedState,_=R.element,Fj(l,u),qu(u,x,null,m);var z=u.memoizedState;if(x=z.element,R.isDehydrated)if(R={element:x,isDehydrated:!1,cache:z.cache,pendingSuspenseBoundaries:z.pendingSuspenseBoundaries,transitions:z.transitions},u.updateQueue.baseState=R,u.memoizedState=R,u.flags&256){_=ai(Error(n(423)),u),u=SN(l,u,x,m,_);break e}else if(x!==_){_=ai(Error(n(424)),u),u=SN(l,u,x,m,_);break e}else for(In=Js(u.stateNode.containerInfo.firstChild),On=u,xt=!0,mr=null,m=Pj(u,null,x,m),u.child=m;m;)m.flags=m.flags&-3|4096,m=m.sibling;else{if(ei(),x===_){u=bs(l,u,m);break e}ln(l,u,x,m)}u=u.child}return u;case 5:return Uj(u),l===null&&Lp(u),x=u.type,_=u.pendingProps,R=l!==null?l.memoizedProps:null,z=_.children,Sp(x,_)?z=null:R!==null&&Sp(x,R)&&(u.flags|=32),kN(l,u),ln(l,u,z,m),u.child;case 6:return l===null&&Lp(u),null;case 13:return _N(l,u,m);case 4:return Up(u,u.stateNode.containerInfo),x=u.pendingProps,l===null?u.child=ti(u,null,x,m):ln(l,u,x,m),u.child;case 11:return x=u.type,_=u.pendingProps,_=u.elementType===x?_:gr(x,_),wN(l,u,x,_,m);case 7:return ln(l,u,u.pendingProps,m),u.child;case 8:return ln(l,u,u.pendingProps.children,m),u.child;case 12:return ln(l,u,u.pendingProps.children,m),u.child;case 10:e:{if(x=u.type._context,_=u.pendingProps,R=u.memoizedProps,z=_.value,ct(Du,x._currentValue),x._currentValue=z,R!==null)if(pr(R.value,z)){if(R.children===_.children&&!gn.current){u=bs(l,u,m);break e}}else for(R=u.child,R!==null&&(R.return=u);R!==null;){var Q=R.dependencies;if(Q!==null){z=R.child;for(var te=Q.firstContext;te!==null;){if(te.context===x){if(R.tag===1){te=vs(-1,m&-m),te.tag=2;var ue=R.updateQueue;if(ue!==null){ue=ue.shared;var ve=ue.pending;ve===null?te.next=te:(te.next=ve.next,ve.next=te),ue.pending=te}}R.lanes|=m,te=R.alternate,te!==null&&(te.lanes|=m),Fp(R.return,m,u),Q.lanes|=m;break}te=te.next}}else if(R.tag===10)z=R.type===u.type?null:R.child;else if(R.tag===18){if(z=R.return,z===null)throw Error(n(341));z.lanes|=m,Q=z.alternate,Q!==null&&(Q.lanes|=m),Fp(z,m,u),z=R.sibling}else z=R.child;if(z!==null)z.return=R;else for(z=R;z!==null;){if(z===u){z=null;break}if(R=z.sibling,R!==null){R.return=z.return,z=R;break}z=z.return}R=z}ln(l,u,_.children,m),u=u.child}return u;case 9:return _=u.type,x=u.pendingProps.children,ri(u,m),_=Xn(_),x=x(_),u.flags|=1,ln(l,u,x,m),u.child;case 14:return x=u.type,_=gr(x,u.pendingProps),_=gr(x.type,_),xN(l,u,x,_,m);case 15:return vN(l,u,u.type,u.pendingProps,m);case 17:return x=u.type,_=u.pendingProps,_=u.elementType===x?_:gr(x,_),Xu(l,u),u.tag=1,yn(x)?(l=!0,Mu(u)):l=!1,ri(u,m),dN(u,x,_),tm(u,x,_,m),am(null,u,x,!0,l,m);case 19:return CN(l,u,m);case 22:return bN(l,u,m)}throw Error(n(156,u.tag))};function JN(l,u){return Bs(l,u)}function t6(l,u,m,x){this.tag=l,this.key=m,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=u,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=x,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function Qn(l,u,m,x){return new t6(l,u,m,x)}function Sm(l){return l=l.prototype,!(!l||!l.isReactComponent)}function n6(l){if(typeof l=="function")return Sm(l)?1:0;if(l!=null){if(l=l.$$typeof,l===L)return 11;if(l===B)return 14}return 2}function ca(l,u){var m=l.alternate;return m===null?(m=Qn(l.tag,u,l.key,l.mode),m.elementType=l.elementType,m.type=l.type,m.stateNode=l.stateNode,m.alternate=l,l.alternate=m):(m.pendingProps=u,m.type=l.type,m.flags=0,m.subtreeFlags=0,m.deletions=null),m.flags=l.flags&14680064,m.childLanes=l.childLanes,m.lanes=l.lanes,m.child=l.child,m.memoizedProps=l.memoizedProps,m.memoizedState=l.memoizedState,m.updateQueue=l.updateQueue,u=l.dependencies,m.dependencies=u===null?null:{lanes:u.lanes,firstContext:u.firstContext},m.sibling=l.sibling,m.index=l.index,m.ref=l.ref,m}function id(l,u,m,x,_,R){var z=2;if(x=l,typeof l=="function")Sm(l)&&(z=1);else if(typeof l=="string")z=5;else e:switch(l){case T:return so(m.children,_,R,u);case I:z=8,_|=8;break;case O:return l=Qn(12,m,u,_|2),l.elementType=O,l.lanes=R,l;case F:return l=Qn(13,m,u,_),l.elementType=F,l.lanes=R,l;case A:return l=Qn(19,m,u,_),l.elementType=A,l.lanes=R,l;case K:return ld(m,_,R,u);default:if(typeof l=="object"&&l!==null)switch(l.$$typeof){case U:z=10;break e;case P:z=9;break e;case L:z=11;break e;case B:z=14;break e;case D:z=16,x=null;break e}throw Error(n(130,l==null?l:typeof l,""))}return u=Qn(z,m,u,_),u.elementType=l,u.type=x,u.lanes=R,u}function so(l,u,m,x){return l=Qn(7,l,x,u),l.lanes=m,l}function ld(l,u,m,x){return l=Qn(22,l,x,u),l.elementType=K,l.lanes=m,l.stateNode={isHidden:!1},l}function _m(l,u,m){return l=Qn(6,l,null,u),l.lanes=m,l}function Em(l,u,m){return u=Qn(4,l.children!==null?l.children:[],l.key,u),u.lanes=m,u.stateNode={containerInfo:l.containerInfo,pendingChildren:null,implementation:l.implementation},u}function r6(l,u,m,x,_){this.tag=u,this.containerInfo=l,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Po(0),this.expirationTimes=Po(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Po(0),this.identifierPrefix=x,this.onRecoverableError=_,this.mutableSourceEagerHydrationData=null}function Cm(l,u,m,x,_,R,z,Q,te){return l=new r6(l,u,m,Q,te),u===1?(u=1,R===!0&&(u|=8)):u=0,R=Qn(3,null,null,u),l.current=R,R.stateNode=l,R.memoizedState={element:x,isDehydrated:m,cache:null,transitions:null,pendingSuspenseBoundaries:null},qp(R),l}function s6(l,u,m){var x=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:$,key:x==null?null:""+x,children:l,containerInfo:u,implementation:m}}function QN(l){if(!l)return ea;l=l._reactInternals;e:{if(mn(l)!==l||l.tag!==1)throw Error(n(170));var u=l;do{switch(u.tag){case 3:u=u.stateNode.context;break e;case 1:if(yn(u.type)){u=u.stateNode.__reactInternalMemoizedMergedChildContext;break e}}u=u.return}while(u!==null);throw Error(n(171))}if(l.tag===1){var m=l.type;if(yn(m))return Ej(l,m,u)}return u}function eS(l,u,m,x,_,R,z,Q,te){return l=Cm(m,x,!0,l,_,R,z,Q,te),l.context=QN(null),m=l.current,x=cn(),_=ia(m),R=vs(x,_),R.callback=u??null,ra(m,R,_),l.current.lanes=_,Hs(l,_,x),vn(l,x),l}function cd(l,u,m,x){var _=u.current,R=cn(),z=ia(_);return m=QN(m),u.context===null?u.context=m:u.pendingContext=m,u=vs(R,z),u.payload={element:l},x=x===void 0?null:x,x!==null&&(u.callback=x),l=ra(_,u,z),l!==null&&(xr(l,_,z,R),Bu(l,_,z)),z}function ud(l){if(l=l.current,!l.child)return null;switch(l.child.tag){case 5:return l.child.stateNode;default:return l.child.stateNode}}function tS(l,u){if(l=l.memoizedState,l!==null&&l.dehydrated!==null){var m=l.retryLane;l.retryLane=m!==0&&m<u?m:u}}function Tm(l,u){tS(l,u),(l=l.alternate)&&tS(l,u)}function a6(){return null}var nS=typeof reportError=="function"?reportError:function(l){console.error(l)};function Rm(l){this._internalRoot=l}dd.prototype.render=Rm.prototype.render=function(l){var u=this._internalRoot;if(u===null)throw Error(n(409));cd(l,u,null,null)},dd.prototype.unmount=Rm.prototype.unmount=function(){var l=this._internalRoot;if(l!==null){this._internalRoot=null;var u=l.containerInfo;to(function(){cd(null,l,null,null)}),u[ms]=null}};function dd(l){this._internalRoot=l}dd.prototype.unstable_scheduleHydration=function(l){if(l){var u=us();l={blockedOn:null,target:l,priority:u};for(var m=0;m<Br.length&&u!==0&&u<Br[m].priority;m++);Br.splice(m,0,l),m===0&&fl(l)}};function Am(l){return!(!l||l.nodeType!==1&&l.nodeType!==9&&l.nodeType!==11)}function hd(l){return!(!l||l.nodeType!==1&&l.nodeType!==9&&l.nodeType!==11&&(l.nodeType!==8||l.nodeValue!==" react-mount-point-unstable "))}function rS(){}function o6(l,u,m,x,_){if(_){if(typeof x=="function"){var R=x;x=function(){var ue=ud(z);R.call(ue)}}var z=eS(u,x,l,0,null,!1,!1,"",rS);return l._reactRootContainer=z,l[ms]=z.current,El(l.nodeType===8?l.parentNode:l),to(),z}for(;_=l.lastChild;)l.removeChild(_);if(typeof x=="function"){var Q=x;x=function(){var ue=ud(te);Q.call(ue)}}var te=Cm(l,0,!1,null,null,!1,!1,"",rS);return l._reactRootContainer=te,l[ms]=te.current,El(l.nodeType===8?l.parentNode:l),to(function(){cd(u,te,m,x)}),te}function fd(l,u,m,x,_){var R=m._reactRootContainer;if(R){var z=R;if(typeof _=="function"){var Q=_;_=function(){var te=ud(z);Q.call(te)}}cd(u,z,l,_)}else z=o6(m,u,l,_,x);return ud(z)}fu=function(l){switch(l.tag){case 3:var u=l.stateNode;if(u.current.memoizedState.isDehydrated){var m=Oa(u.pendingLanes);m!==0&&(Pa(u,m|1),vn(u,me()),(Je&6)===0&&(li=me()+500,ta()))}break;case 13:to(function(){var x=xs(l,1);if(x!==null){var _=cn();xr(x,l,1,_)}}),Tm(l,1)}},dl=function(l){if(l.tag===13){var u=xs(l,134217728);if(u!==null){var m=cn();xr(u,l,134217728,m)}Tm(l,134217728)}},hl=function(l){if(l.tag===13){var u=ia(l),m=xs(l,u);if(m!==null){var x=cn();xr(m,l,u,x)}Tm(l,u)}},us=function(){return Ke},pu=function(l,u){var m=Ke;try{return Ke=l,u()}finally{Ke=m}},jt=function(l,u,m){switch(u){case"input":if(ye(l,m),u=m.name,m.type==="radio"&&u!=null){for(m=l;m.parentNode;)m=m.parentNode;for(m=m.querySelectorAll("input[name="+JSON.stringify(""+u)+'][type="radio"]'),u=0;u<m.length;u++){var x=m[u];if(x!==l&&x.form===l.form){var _=Ru(x);if(!_)throw Error(n(90));de(x),ye(x,_)}}}break;case"textarea":qe(l,m);break;case"select":u=m.value,u!=null&&ge(l,!!m.multiple,u,!1)}},an=km,fn=to;var i6={usingClientEntryPoint:!1,Events:[Rl,Yo,Ru,Tn,Mt,km]},Wl={findFiberByHostInstance:Ga,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},l6={bundleType:Wl.bundleType,version:Wl.version,rendererPackageName:Wl.rendererPackageName,rendererConfig:Wl.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:E.ReactCurrentDispatcher,findHostInstanceByFiber:function(l){return l=Lr(l),l===null?null:l.stateNode},findFiberByHostInstance:Wl.findFiberByHostInstance||a6,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 pd=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!pd.isDisabled&&pd.supportsFiber)try{hr=pd.inject(l6),Nt=pd}catch{}}return bn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=i6,bn.createPortal=function(l,u){var m=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Am(u))throw Error(n(200));return s6(l,u,null,m)},bn.createRoot=function(l,u){if(!Am(l))throw Error(n(299));var m=!1,x="",_=nS;return u!=null&&(u.unstable_strictMode===!0&&(m=!0),u.identifierPrefix!==void 0&&(x=u.identifierPrefix),u.onRecoverableError!==void 0&&(_=u.onRecoverableError)),u=Cm(l,1,!1,null,null,m,!1,x,_),l[ms]=u.current,El(l.nodeType===8?l.parentNode:l),new Rm(u)},bn.findDOMNode=function(l){if(l==null)return null;if(l.nodeType===1)return l;var u=l._reactInternals;if(u===void 0)throw typeof l.render=="function"?Error(n(188)):(l=Object.keys(l).join(","),Error(n(268,l)));return l=Lr(u),l=l===null?null:l.stateNode,l},bn.flushSync=function(l){return to(l)},bn.hydrate=function(l,u,m){if(!hd(u))throw Error(n(200));return fd(null,l,u,!0,m)},bn.hydrateRoot=function(l,u,m){if(!Am(l))throw Error(n(405));var x=m!=null&&m.hydratedSources||null,_=!1,R="",z=nS;if(m!=null&&(m.unstable_strictMode===!0&&(_=!0),m.identifierPrefix!==void 0&&(R=m.identifierPrefix),m.onRecoverableError!==void 0&&(z=m.onRecoverableError)),u=eS(u,null,l,1,m??null,_,!1,R,z),l[ms]=u.current,El(l),x)for(l=0;l<x.length;l++)m=x[l],_=m._getVersion,_=_(m._source),u.mutableSourceEagerHydrationData==null?u.mutableSourceEagerHydrationData=[m,_]:u.mutableSourceEagerHydrationData.push(m,_);return new dd(u)},bn.render=function(l,u,m){if(!hd(u))throw Error(n(200));return fd(null,l,u,!1,m)},bn.unmountComponentAtNode=function(l){if(!hd(l))throw Error(n(40));return l._reactRootContainer?(to(function(){fd(null,null,l,!1,function(){l._reactRootContainer=null,l[ms]=null})}),!0):!1},bn.unstable_batchedUpdates=km,bn.unstable_renderSubtreeIntoContainer=function(l,u,m,x){if(!hd(m))throw Error(n(200));if(l==null||l._reactInternals===void 0)throw Error(n(38));return fd(l,u,m,!1,x)},bn.version="18.3.1-next-f1338f8080-20240426",bn}var dS;function tL(){if(dS)return Om.exports;dS=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(),Om.exports=y6(),Om.exports}var hS;function w6(){if(hS)return gd;hS=1;var e=tL();return gd.createRoot=e.createRoot,gd.hydrateRoot=e.hydrateRoot,gd}var x6=w6(),y=zc();const he=fk(y);function Qt(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=Qt(e[n]))!==""&&(t+=(t&&" ")+r);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var Dm={exports:{}},Fm={},Bm={exports:{}},qm={};/**
|
|
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 fS;function v6(){if(fS)return qm;fS=1;var e=zc();function t(p,g){return p===g&&(p!==0||1/p===1/g)||p!==p&&g!==g}var n=typeof Object.is=="function"?Object.is:t,r=e.useState,s=e.useEffect,o=e.useLayoutEffect,i=e.useDebugValue;function c(p,g){var w=g(),k=r({inst:{value:w,getSnapshot:g}}),j=k[0].inst,v=k[1];return o(function(){j.value=w,j.getSnapshot=g,d(j)&&v({inst:j})},[p,w,g]),s(function(){return d(j)&&v({inst:j}),p(function(){d(j)&&v({inst:j})})},[p]),i(w),w}function d(p){var g=p.getSnapshot;p=p.value;try{var w=g();return!n(p,w)}catch{return!0}}function h(p,g){return g()}var f=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h:c;return qm.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:f,qm}var pS;function b6(){return pS||(pS=1,Bm.exports=v6()),Bm.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 mS;function k6(){if(mS)return Fm;mS=1;var e=zc(),t=b6();function n(h,f){return h===f&&(h!==0||1/h===1/f)||h!==h&&f!==f}var r=typeof Object.is=="function"?Object.is:n,s=t.useSyncExternalStore,o=e.useRef,i=e.useEffect,c=e.useMemo,d=e.useDebugValue;return Fm.useSyncExternalStoreWithSelector=function(h,f,p,g,w){var k=o(null);if(k.current===null){var j={hasValue:!1,value:null};k.current=j}else j=k.current;k=c(function(){function b($){if(!N){if(N=!0,S=$,$=g($),w!==void 0&&j.hasValue){var T=j.value;if(w(T,$))return E=T}return E=$}if(T=E,r(S,$))return T;var I=g($);return w!==void 0&&w(T,I)?(S=$,T):(S=$,E=I)}var N=!1,S,E,C=p===void 0?null:p;return[function(){return b(f())},C===null?void 0:function(){return b(C())}]},[f,p,g,w]);var v=s(h,k[0],k[1]);return i(function(){j.hasValue=!0,j.value=v},[v]),d(v),v},Fm}var gS;function j6(){return gS||(gS=1,Dm.exports=k6()),Dm.exports}var N6=j6();const S6=fk(N6),_6={},yS=e=>{let t;const n=new Set,r=(f,p)=>{const g=typeof f=="function"?f(t):f;if(!Object.is(g,t)){const w=t;t=p??(typeof g!="object"||g===null)?g:Object.assign({},t,g),n.forEach(k=>k(t,w))}},s=()=>t,d={setState:r,getState:s,getInitialState:()=>h,subscribe:f=>(n.add(f),()=>n.delete(f)),destroy:()=>{(_6?"production":void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),n.clear()}},h=t=e(r,s,d);return d},E6=e=>e?yS(e):yS,{useDebugValue:C6}=he,{useSyncExternalStoreWithSelector:T6}=S6,R6=e=>e;function nL(e,t=R6,n){const r=T6(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return C6(r),r}const wS=(e,t)=>{const n=E6(e),r=(s,o=t)=>nL(n,s,o);return Object.assign(r,n),r},A6=(e,t)=>e?wS(e,t):wS;function Ht(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 M6={value:()=>{}};function Xh(){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 Vd(n)}function Vd(e){this._=e}function $6(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}})}Vd.prototype=Xh.prototype={constructor:Vd,on:function(e,t){var n=this._,r=$6(e+"",n),s,o=-1,i=r.length;if(arguments.length<2){for(;++o<i;)if((s=(e=r[o]).type)&&(s=L6(n[s],e.name)))return s;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++o<i;)if(s=(e=r[o]).type)n[s]=xS(n[s],e.name,t);else if(t==null)for(s in n)n[s]=xS(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 Vd(e)},call:function(e,t){if((s=arguments.length-2)>0)for(var n=new Array(s),r=0,s,o;r<s;++r)n[r]=arguments[r+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(o=this._[e],r=0,s=o.length;r<s;++r)o[r].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var r=this._[e],s=0,o=r.length;s<o;++s)r[s].value.apply(t,n)}};function L6(e,t){for(var n=0,r=e.length,s;n<r;++n)if((s=e[n]).name===t)return s.value}function xS(e,t,n){for(var r=0,s=e.length;r<s;++r)if(e[r].name===t){e[r]=M6,e=e.slice(0,r).concat(e.slice(r+1));break}return n!=null&&e.push({name:t,value:n}),e}var Gb="http://www.w3.org/1999/xhtml";const vS={svg:"http://www.w3.org/2000/svg",xhtml:Gb,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Zh(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),vS.hasOwnProperty(t)?{space:vS[t],local:e}:e}function O6(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Gb&&t.documentElement.namespaceURI===Gb?t.createElement(e):t.createElementNS(n,e)}}function I6(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function rL(e){var t=Zh(e);return(t.local?I6:O6)(t)}function P6(){}function pk(e){return e==null?P6:function(){return this.querySelector(e)}}function D6(e){typeof e!="function"&&(e=pk(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var o=t[s],i=o.length,c=r[s]=new Array(i),d,h,f=0;f<i;++f)(d=o[f])&&(h=e.call(d,d.__data__,f,o))&&("__data__"in d&&(h.__data__=d.__data__),c[f]=h);return new zn(r,this._parents)}function F6(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function B6(){return[]}function sL(e){return e==null?B6:function(){return this.querySelectorAll(e)}}function q6(e){return function(){return F6(e.apply(this,arguments))}}function U6(e){typeof e=="function"?e=q6(e):e=sL(e);for(var t=this._groups,n=t.length,r=[],s=[],o=0;o<n;++o)for(var i=t[o],c=i.length,d,h=0;h<c;++h)(d=i[h])&&(r.push(e.call(d,d.__data__,h,i)),s.push(d));return new zn(r,s)}function aL(e){return function(){return this.matches(e)}}function oL(e){return function(t){return t.matches(e)}}var H6=Array.prototype.find;function W6(e){return function(){return H6.call(this.children,e)}}function z6(){return this.firstElementChild}function V6(e){return this.select(e==null?z6:W6(typeof e=="function"?e:oL(e)))}var G6=Array.prototype.filter;function K6(){return Array.from(this.children)}function Y6(e){return function(){return G6.call(this.children,e)}}function X6(e){return this.selectAll(e==null?K6:Y6(typeof e=="function"?e:oL(e)))}function Z6(e){typeof e!="function"&&(e=aL(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var o=t[s],i=o.length,c=r[s]=[],d,h=0;h<i;++h)(d=o[h])&&e.call(d,d.__data__,h,o)&&c.push(d);return new zn(r,this._parents)}function iL(e){return new Array(e.length)}function J6(){return new zn(this._enter||this._groups.map(iL),this._parents)}function ih(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}ih.prototype={constructor:ih,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 Q6(e){return function(){return e}}function eF(e,t,n,r,s,o){for(var i=0,c,d=t.length,h=o.length;i<h;++i)(c=t[i])?(c.__data__=o[i],r[i]=c):n[i]=new ih(e,o[i]);for(;i<d;++i)(c=t[i])&&(s[i]=c)}function tF(e,t,n,r,s,o,i){var c,d,h=new Map,f=t.length,p=o.length,g=new Array(f),w;for(c=0;c<f;++c)(d=t[c])&&(g[c]=w=i.call(d,d.__data__,c,t)+"",h.has(w)?s[c]=d:h.set(w,d));for(c=0;c<p;++c)w=i.call(e,o[c],c,o)+"",(d=h.get(w))?(r[c]=d,d.__data__=o[c],h.delete(w)):n[c]=new ih(e,o[c]);for(c=0;c<f;++c)(d=t[c])&&h.get(g[c])===d&&(s[c]=d)}function nF(e){return e.__data__}function rF(e,t){if(!arguments.length)return Array.from(this,nF);var n=t?tF:eF,r=this._parents,s=this._groups;typeof e!="function"&&(e=Q6(e));for(var o=s.length,i=new Array(o),c=new Array(o),d=new Array(o),h=0;h<o;++h){var f=r[h],p=s[h],g=p.length,w=sF(e.call(f,f&&f.__data__,h,r)),k=w.length,j=c[h]=new Array(k),v=i[h]=new Array(k),b=d[h]=new Array(g);n(f,p,j,v,b,w,t);for(var N=0,S=0,E,C;N<k;++N)if(E=j[N]){for(N>=S&&(S=N+1);!(C=v[S])&&++S<k;);E._next=C||null}}return i=new zn(i,r),i._enter=c,i._exit=d,i}function sF(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function aF(){return new zn(this._exit||this._groups.map(iL),this._parents)}function oF(e,t,n){var r=this.enter(),s=this,o=this.exit();return typeof e=="function"?(r=e(r),r&&(r=r.selection())):r=r.append(e+""),t!=null&&(s=t(s),s&&(s=s.selection())),n==null?o.remove():n(o),r&&s?r.merge(s).order():s}function iF(e){for(var t=e.selection?e.selection():e,n=this._groups,r=t._groups,s=n.length,o=r.length,i=Math.min(s,o),c=new Array(s),d=0;d<i;++d)for(var h=n[d],f=r[d],p=h.length,g=c[d]=new Array(p),w,k=0;k<p;++k)(w=h[k]||f[k])&&(g[k]=w);for(;d<s;++d)c[d]=n[d];return new zn(c,this._parents)}function lF(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var r=e[t],s=r.length-1,o=r[s],i;--s>=0;)(i=r[s])&&(o&&i.compareDocumentPosition(o)^4&&o.parentNode.insertBefore(i,o),o=i);return this}function cF(e){e||(e=uF);function t(p,g){return p&&g?e(p.__data__,g.__data__):!p-!g}for(var n=this._groups,r=n.length,s=new Array(r),o=0;o<r;++o){for(var i=n[o],c=i.length,d=s[o]=new Array(c),h,f=0;f<c;++f)(h=i[f])&&(d[f]=h);d.sort(t)}return new zn(s,this._parents).order()}function uF(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function dF(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function hF(){return Array.from(this)}function fF(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],s=0,o=r.length;s<o;++s){var i=r[s];if(i)return i}return null}function pF(){let e=0;for(const t of this)++e;return e}function mF(){return!this.node()}function gF(e){for(var t=this._groups,n=0,r=t.length;n<r;++n)for(var s=t[n],o=0,i=s.length,c;o<i;++o)(c=s[o])&&e.call(c,c.__data__,o,s);return this}function yF(e){return function(){this.removeAttribute(e)}}function wF(e){return function(){this.removeAttributeNS(e.space,e.local)}}function xF(e,t){return function(){this.setAttribute(e,t)}}function vF(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function bF(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function kF(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 jF(e,t){var n=Zh(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?wF:yF:typeof t=="function"?n.local?kF:bF:n.local?vF:xF)(n,t))}function lL(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function NF(e){return function(){this.style.removeProperty(e)}}function SF(e,t,n){return function(){this.style.setProperty(e,t,n)}}function _F(e,t,n){return function(){var r=t.apply(this,arguments);r==null?this.style.removeProperty(e):this.style.setProperty(e,r,n)}}function EF(e,t,n){return arguments.length>1?this.each((t==null?NF:typeof t=="function"?_F:SF)(e,t,n??"")):Bi(this.node(),e)}function Bi(e,t){return e.style.getPropertyValue(t)||lL(e).getComputedStyle(e,null).getPropertyValue(t)}function CF(e){return function(){delete this[e]}}function TF(e,t){return function(){this[e]=t}}function RF(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function AF(e,t){return arguments.length>1?this.each((t==null?CF:typeof t=="function"?RF:TF)(e,t)):this.node()[e]}function cL(e){return e.trim().split(/^|\s+/)}function mk(e){return e.classList||new uL(e)}function uL(e){this._node=e,this._names=cL(e.getAttribute("class")||"")}uL.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 dL(e,t){for(var n=mk(e),r=-1,s=t.length;++r<s;)n.add(t[r])}function hL(e,t){for(var n=mk(e),r=-1,s=t.length;++r<s;)n.remove(t[r])}function MF(e){return function(){dL(this,e)}}function $F(e){return function(){hL(this,e)}}function LF(e,t){return function(){(t.apply(this,arguments)?dL:hL)(this,e)}}function OF(e,t){var n=cL(e+"");if(arguments.length<2){for(var r=mk(this.node()),s=-1,o=n.length;++s<o;)if(!r.contains(n[s]))return!1;return!0}return this.each((typeof t=="function"?LF:t?MF:$F)(n,t))}function IF(){this.textContent=""}function PF(e){return function(){this.textContent=e}}function DF(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function FF(e){return arguments.length?this.each(e==null?IF:(typeof e=="function"?DF:PF)(e)):this.node().textContent}function BF(){this.innerHTML=""}function qF(e){return function(){this.innerHTML=e}}function UF(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function HF(e){return arguments.length?this.each(e==null?BF:(typeof e=="function"?UF:qF)(e)):this.node().innerHTML}function WF(){this.nextSibling&&this.parentNode.appendChild(this)}function zF(){return this.each(WF)}function VF(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function GF(){return this.each(VF)}function KF(e){var t=typeof e=="function"?e:rL(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function YF(){return null}function XF(e,t){var n=typeof e=="function"?e:rL(e),r=t==null?YF:typeof t=="function"?t:pk(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),r.apply(this,arguments)||null)})}function ZF(){var e=this.parentNode;e&&e.removeChild(this)}function JF(){return this.each(ZF)}function QF(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function e8(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function t8(e){return this.select(e?e8:QF)}function n8(e){return arguments.length?this.property("__data__",e):this.node().__data__}function r8(e){return function(t){e.call(this,t,this.__data__)}}function s8(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 a8(e){return function(){var t=this.__on;if(t){for(var n=0,r=-1,s=t.length,o;n<s;++n)o=t[n],(!e.type||o.type===e.type)&&o.name===e.name?this.removeEventListener(o.type,o.listener,o.options):t[++r]=o;++r?t.length=r:delete this.__on}}}function o8(e,t,n){return function(){var r=this.__on,s,o=r8(t);if(r){for(var i=0,c=r.length;i<c;++i)if((s=r[i]).type===e.type&&s.name===e.name){this.removeEventListener(s.type,s.listener,s.options),this.addEventListener(s.type,s.listener=o,s.options=n),s.value=t;return}}this.addEventListener(e.type,o,n),s={type:e.type,name:e.name,value:t,listener:o,options:n},r?r.push(s):this.__on=[s]}}function i8(e,t,n){var r=s8(e+""),s,o=r.length,i;if(arguments.length<2){var c=this.node().__on;if(c){for(var d=0,h=c.length,f;d<h;++d)for(s=0,f=c[d];s<o;++s)if((i=r[s]).type===f.type&&i.name===f.name)return f.value}return}for(c=t?o8:a8,s=0;s<o;++s)this.each(c(r[s],t,n));return this}function fL(e,t,n){var r=lL(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 l8(e,t){return function(){return fL(this,e,t)}}function c8(e,t){return function(){return fL(this,e,t.apply(this,arguments))}}function u8(e,t){return this.each((typeof t=="function"?c8:l8)(e,t))}function*d8(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var r=e[t],s=0,o=r.length,i;s<o;++s)(i=r[s])&&(yield i)}var pL=[null];function zn(e,t){this._groups=e,this._parents=t}function Vc(){return new zn([[document.documentElement]],pL)}function h8(){return this}zn.prototype=Vc.prototype={constructor:zn,select:D6,selectAll:U6,selectChild:V6,selectChildren:X6,filter:Z6,data:rF,enter:J6,exit:aF,join:oF,merge:iF,selection:h8,order:lF,sort:cF,call:dF,nodes:hF,node:fF,size:pF,empty:mF,each:gF,attr:jF,style:EF,property:AF,classed:OF,text:FF,html:HF,raise:zF,lower:GF,append:KF,insert:XF,remove:JF,clone:t8,datum:n8,on:i8,dispatch:u8,[Symbol.iterator]:d8};function rr(e){return typeof e=="string"?new zn([[document.querySelector(e)]],[document.documentElement]):new zn([[e]],pL)}function f8(e){let t;for(;t=e.sourceEvent;)e=t;return e}function jr(e,t){if(e=f8(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 p8={passive:!1},bc={capture:!0,passive:!1};function Um(e){e.stopImmediatePropagation()}function Ai(e){e.preventDefault(),e.stopImmediatePropagation()}function mL(e){var t=e.document.documentElement,n=rr(e).on("dragstart.drag",Ai,bc);"onselectstart"in t?n.on("selectstart.drag",Ai,bc):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function gL(e,t){var n=e.document.documentElement,r=rr(e).on("dragstart.drag",null);t&&(r.on("click.drag",Ai,bc),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 yd=e=>()=>e;function Kb(e,{sourceEvent:t,subject:n,target:r,identifier:s,active:o,x:i,y:c,dx:d,dy:h,dispatch:f}){Object.defineProperties(this,{type:{value:e,enumerable:!0,configurable:!0},sourceEvent:{value:t,enumerable:!0,configurable:!0},subject:{value:n,enumerable:!0,configurable:!0},target:{value:r,enumerable:!0,configurable:!0},identifier:{value:s,enumerable:!0,configurable:!0},active:{value:o,enumerable:!0,configurable:!0},x:{value:i,enumerable:!0,configurable:!0},y:{value:c,enumerable:!0,configurable:!0},dx:{value:d,enumerable:!0,configurable:!0},dy:{value:h,enumerable:!0,configurable:!0},_:{value:f}})}Kb.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function m8(e){return!e.ctrlKey&&!e.button}function g8(){return this.parentNode}function y8(e,t){return t??{x:e.x,y:e.y}}function w8(){return navigator.maxTouchPoints||"ontouchstart"in this}function x8(){var e=m8,t=g8,n=y8,r=w8,s={},o=Xh("start","drag","end"),i=0,c,d,h,f,p=0;function g(E){E.on("mousedown.drag",w).filter(r).on("touchstart.drag",v).on("touchmove.drag",b,p8).on("touchend.drag touchcancel.drag",N).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function w(E,C){if(!(f||!e.call(this,E,C))){var $=S(this,t.call(this,E,C),E,C,"mouse");$&&(rr(E.view).on("mousemove.drag",k,bc).on("mouseup.drag",j,bc),mL(E.view),Um(E),h=!1,c=E.clientX,d=E.clientY,$("start",E))}}function k(E){if(Ai(E),!h){var C=E.clientX-c,$=E.clientY-d;h=C*C+$*$>p}s.mouse("drag",E)}function j(E){rr(E.view).on("mousemove.drag mouseup.drag",null),gL(E.view,h),Ai(E),s.mouse("end",E)}function v(E,C){if(e.call(this,E,C)){var $=E.changedTouches,T=t.call(this,E,C),I=$.length,O,U;for(O=0;O<I;++O)(U=S(this,T,E,C,$[O].identifier,$[O]))&&(Um(E),U("start",E,$[O]))}}function b(E){var C=E.changedTouches,$=C.length,T,I;for(T=0;T<$;++T)(I=s[C[T].identifier])&&(Ai(E),I("drag",E,C[T]))}function N(E){var C=E.changedTouches,$=C.length,T,I;for(f&&clearTimeout(f),f=setTimeout(function(){f=null},500),T=0;T<$;++T)(I=s[C[T].identifier])&&(Um(E),I("end",E,C[T]))}function S(E,C,$,T,I,O){var U=o.copy(),P=jr(O||$,C),L,F,A;if((A=n.call(E,new Kb("beforestart",{sourceEvent:$,target:g,identifier:I,active:i,x:P[0],y:P[1],dx:0,dy:0,dispatch:U}),T))!=null)return L=A.x-P[0]||0,F=A.y-P[1]||0,function B(D,K,G){var H=P,q;switch(D){case"start":s[I]=B,q=i++;break;case"end":delete s[I],--i;case"drag":P=jr(G||K,C),q=i;break}U.call(D,E,new Kb(D,{sourceEvent:K,subject:A,target:g,identifier:I,active:q,x:P[0]+L,y:P[1]+F,dx:P[0]-H[0],dy:P[1]-H[1],dispatch:U}),T)}}return g.filter=function(E){return arguments.length?(e=typeof E=="function"?E:yd(!!E),g):e},g.container=function(E){return arguments.length?(t=typeof E=="function"?E:yd(E),g):t},g.subject=function(E){return arguments.length?(n=typeof E=="function"?E:yd(E),g):n},g.touchable=function(E){return arguments.length?(r=typeof E=="function"?E:yd(!!E),g):r},g.on=function(){var E=o.on.apply(o,arguments);return E===o?g:E},g.clickDistance=function(E){return arguments.length?(p=(E=+E)*E,g):Math.sqrt(p)},g}function gk(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function yL(e,t){var n=Object.create(e.prototype);for(var r in t)n[r]=t[r];return n}function Gc(){}var kc=.7,lh=1/kc,Mi="\\s*([+-]?\\d+)\\s*",jc="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Qr="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",v8=/^#([0-9a-f]{3,8})$/,b8=new RegExp(`^rgb\\(${Mi},${Mi},${Mi}\\)$`),k8=new RegExp(`^rgb\\(${Qr},${Qr},${Qr}\\)$`),j8=new RegExp(`^rgba\\(${Mi},${Mi},${Mi},${jc}\\)$`),N8=new RegExp(`^rgba\\(${Qr},${Qr},${Qr},${jc}\\)$`),S8=new RegExp(`^hsl\\(${jc},${Qr},${Qr}\\)$`),_8=new RegExp(`^hsla\\(${jc},${Qr},${Qr},${jc}\\)$`),bS={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};gk(Gc,Nc,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:kS,formatHex:kS,formatHex8:E8,formatHsl:C8,formatRgb:jS,toString:jS});function kS(){return this.rgb().formatHex()}function E8(){return this.rgb().formatHex8()}function C8(){return wL(this).formatHsl()}function jS(){return this.rgb().formatRgb()}function Nc(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=v8.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?NS(t):n===3?new Sn(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?wd(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?wd(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=b8.exec(e))?new Sn(t[1],t[2],t[3],1):(t=k8.exec(e))?new Sn(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=j8.exec(e))?wd(t[1],t[2],t[3],t[4]):(t=N8.exec(e))?wd(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=S8.exec(e))?ES(t[1],t[2]/100,t[3]/100,1):(t=_8.exec(e))?ES(t[1],t[2]/100,t[3]/100,t[4]):bS.hasOwnProperty(e)?NS(bS[e]):e==="transparent"?new Sn(NaN,NaN,NaN,0):null}function NS(e){return new Sn(e>>16&255,e>>8&255,e&255,1)}function wd(e,t,n,r){return r<=0&&(e=t=n=NaN),new Sn(e,t,n,r)}function T8(e){return e instanceof Gc||(e=Nc(e)),e?(e=e.rgb(),new Sn(e.r,e.g,e.b,e.opacity)):new Sn}function Yb(e,t,n,r){return arguments.length===1?T8(e):new Sn(e,t,n,r??1)}function Sn(e,t,n,r){this.r=+e,this.g=+t,this.b=+n,this.opacity=+r}gk(Sn,Yb,yL(Gc,{brighter(e){return e=e==null?lh:Math.pow(lh,e),new Sn(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?kc:Math.pow(kc,e),new Sn(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Sn(yo(this.r),yo(this.g),yo(this.b),ch(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:SS,formatHex:SS,formatHex8:R8,formatRgb:_S,toString:_S}));function SS(){return`#${fo(this.r)}${fo(this.g)}${fo(this.b)}`}function R8(){return`#${fo(this.r)}${fo(this.g)}${fo(this.b)}${fo((isNaN(this.opacity)?1:this.opacity)*255)}`}function _S(){const e=ch(this.opacity);return`${e===1?"rgb(":"rgba("}${yo(this.r)}, ${yo(this.g)}, ${yo(this.b)}${e===1?")":`, ${e})`}`}function ch(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function yo(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function fo(e){return e=yo(e),(e<16?"0":"")+e.toString(16)}function ES(e,t,n,r){return r<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Nr(e,t,n,r)}function wL(e){if(e instanceof Nr)return new Nr(e.h,e.s,e.l,e.opacity);if(e instanceof Gc||(e=Nc(e)),!e)return new Nr;if(e instanceof Nr)return e;e=e.rgb();var t=e.r/255,n=e.g/255,r=e.b/255,s=Math.min(t,n,r),o=Math.max(t,n,r),i=NaN,c=o-s,d=(o+s)/2;return c?(t===o?i=(n-r)/c+(n<r)*6:n===o?i=(r-t)/c+2:i=(t-n)/c+4,c/=d<.5?o+s:2-o-s,i*=60):c=d>0&&d<1?0:i,new Nr(i,c,d,e.opacity)}function A8(e,t,n,r){return arguments.length===1?wL(e):new Nr(e,t,n,r??1)}function Nr(e,t,n,r){this.h=+e,this.s=+t,this.l=+n,this.opacity=+r}gk(Nr,A8,yL(Gc,{brighter(e){return e=e==null?lh:Math.pow(lh,e),new Nr(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?kc:Math.pow(kc,e),new Nr(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 Sn(Hm(e>=240?e-240:e+120,s,r),Hm(e,s,r),Hm(e<120?e+240:e-120,s,r),this.opacity)},clamp(){return new Nr(CS(this.h),xd(this.s),xd(this.l),ch(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=ch(this.opacity);return`${e===1?"hsl(":"hsla("}${CS(this.h)}, ${xd(this.s)*100}%, ${xd(this.l)*100}%${e===1?")":`, ${e})`}`}}));function CS(e){return e=(e||0)%360,e<0?e+360:e}function xd(e){return Math.max(0,Math.min(1,e||0))}function Hm(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 xL=e=>()=>e;function M8(e,t){return function(n){return e+n*t}}function $8(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 L8(e){return(e=+e)==1?vL:function(t,n){return n-t?$8(t,n,e):xL(isNaN(t)?n:t)}}function vL(e,t){var n=t-e;return n?M8(e,n):xL(isNaN(e)?t:e)}const TS=(function e(t){var n=L8(t);function r(s,o){var i=n((s=Yb(s)).r,(o=Yb(o)).r),c=n(s.g,o.g),d=n(s.b,o.b),h=vL(s.opacity,o.opacity);return function(f){return s.r=i(f),s.g=c(f),s.b=d(f),s.opacity=h(f),s+""}}return r.gamma=e,r})(1);function fa(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var Xb=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Wm=new RegExp(Xb.source,"g");function O8(e){return function(){return e}}function I8(e){return function(t){return e(t)+""}}function P8(e,t){var n=Xb.lastIndex=Wm.lastIndex=0,r,s,o,i=-1,c=[],d=[];for(e=e+"",t=t+"";(r=Xb.exec(e))&&(s=Wm.exec(t));)(o=s.index)>n&&(o=t.slice(n,o),c[i]?c[i]+=o:c[++i]=o),(r=r[0])===(s=s[0])?c[i]?c[i]+=s:c[++i]=s:(c[++i]=null,d.push({i,x:fa(r,s)})),n=Wm.lastIndex;return n<t.length&&(o=t.slice(n),c[i]?c[i]+=o:c[++i]=o),c.length<2?d[0]?I8(d[0].x):O8(t):(t=d.length,function(h){for(var f=0,p;f<t;++f)c[(p=d[f]).i]=p.x(h);return c.join("")})}var RS=180/Math.PI,Zb={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function bL(e,t,n,r,s,o){var i,c,d;return(i=Math.sqrt(e*e+t*t))&&(e/=i,t/=i),(d=e*n+t*r)&&(n-=e*d,r-=t*d),(c=Math.sqrt(n*n+r*r))&&(n/=c,r/=c,d/=c),e*r<t*n&&(e=-e,t=-t,d=-d,i=-i),{translateX:s,translateY:o,rotate:Math.atan2(t,e)*RS,skewX:Math.atan(d)*RS,scaleX:i,scaleY:c}}var vd;function D8(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Zb:bL(t.a,t.b,t.c,t.d,t.e,t.f)}function F8(e){return e==null||(vd||(vd=document.createElementNS("http://www.w3.org/2000/svg","g")),vd.setAttribute("transform",e),!(e=vd.transform.baseVal.consolidate()))?Zb:(e=e.matrix,bL(e.a,e.b,e.c,e.d,e.e,e.f))}function kL(e,t,n,r){function s(h){return h.length?h.pop()+" ":""}function o(h,f,p,g,w,k){if(h!==p||f!==g){var j=w.push("translate(",null,t,null,n);k.push({i:j-4,x:fa(h,p)},{i:j-2,x:fa(f,g)})}else(p||g)&&w.push("translate("+p+t+g+n)}function i(h,f,p,g){h!==f?(h-f>180?f+=360:f-h>180&&(h+=360),g.push({i:p.push(s(p)+"rotate(",null,r)-2,x:fa(h,f)})):f&&p.push(s(p)+"rotate("+f+r)}function c(h,f,p,g){h!==f?g.push({i:p.push(s(p)+"skewX(",null,r)-2,x:fa(h,f)}):f&&p.push(s(p)+"skewX("+f+r)}function d(h,f,p,g,w,k){if(h!==p||f!==g){var j=w.push(s(w)+"scale(",null,",",null,")");k.push({i:j-4,x:fa(h,p)},{i:j-2,x:fa(f,g)})}else(p!==1||g!==1)&&w.push(s(w)+"scale("+p+","+g+")")}return function(h,f){var p=[],g=[];return h=e(h),f=e(f),o(h.translateX,h.translateY,f.translateX,f.translateY,p,g),i(h.rotate,f.rotate,p,g),c(h.skewX,f.skewX,p,g),d(h.scaleX,h.scaleY,f.scaleX,f.scaleY,p,g),h=f=null,function(w){for(var k=-1,j=g.length,v;++k<j;)p[(v=g[k]).i]=v.x(w);return p.join("")}}}var B8=kL(D8,"px, ","px)","deg)"),q8=kL(F8,", ",")",")"),U8=1e-12;function AS(e){return((e=Math.exp(e))+1/e)/2}function H8(e){return((e=Math.exp(e))-1/e)/2}function W8(e){return((e=Math.exp(2*e))-1)/(e+1)}const z8=(function e(t,n,r){function s(o,i){var c=o[0],d=o[1],h=o[2],f=i[0],p=i[1],g=i[2],w=f-c,k=p-d,j=w*w+k*k,v,b;if(j<U8)b=Math.log(g/h)/t,v=function(T){return[c+T*w,d+T*k,h*Math.exp(t*T*b)]};else{var N=Math.sqrt(j),S=(g*g-h*h+r*j)/(2*h*n*N),E=(g*g-h*h-r*j)/(2*g*n*N),C=Math.log(Math.sqrt(S*S+1)-S),$=Math.log(Math.sqrt(E*E+1)-E);b=($-C)/t,v=function(T){var I=T*b,O=AS(C),U=h/(n*N)*(O*W8(t*I+C)-H8(C));return[c+U*w,d+U*k,h*O/AS(t*I+C)]}}return v.duration=b*1e3*t/Math.SQRT2,v}return s.rho=function(o){var i=Math.max(.001,+o),c=i*i,d=c*c;return e(i,c,d)},s})(Math.SQRT2,2,4);var qi=0,sc=0,Vl=0,jL=1e3,uh,ac,dh=0,jo=0,Jh=0,Sc=typeof performance=="object"&&performance.now?performance:Date,NL=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function yk(){return jo||(NL(V8),jo=Sc.now()+Jh)}function V8(){jo=0}function hh(){this._call=this._time=this._next=null}hh.prototype=SL.prototype={constructor:hh,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?yk():+n)+(t==null?0:+t),!this._next&&ac!==this&&(ac?ac._next=this:uh=this,ac=this),this._call=e,this._time=n,Jb()},stop:function(){this._call&&(this._call=null,this._time=1/0,Jb())}};function SL(e,t,n){var r=new hh;return r.restart(e,t,n),r}function G8(){yk(),++qi;for(var e=uh,t;e;)(t=jo-e._time)>=0&&e._call.call(void 0,t),e=e._next;--qi}function MS(){jo=(dh=Sc.now())+Jh,qi=sc=0;try{G8()}finally{qi=0,Y8(),jo=0}}function K8(){var e=Sc.now(),t=e-dh;t>jL&&(Jh-=t,dh=e)}function Y8(){for(var e,t=uh,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:uh=n);ac=e,Jb(r)}function Jb(e){if(!qi){sc&&(sc=clearTimeout(sc));var t=e-jo;t>24?(e<1/0&&(sc=setTimeout(MS,e-Sc.now()-Jh)),Vl&&(Vl=clearInterval(Vl))):(Vl||(dh=Sc.now(),Vl=setInterval(K8,jL)),qi=1,NL(MS))}}function $S(e,t,n){var r=new hh;return t=t==null?0:+t,r.restart(s=>{r.stop(),e(s+t)},t,n),r}var X8=Xh("start","end","cancel","interrupt"),Z8=[],_L=0,LS=1,Qb=2,Gd=3,OS=4,e0=5,Kd=6;function Qh(e,t,n,r,s,o){var i=e.__transition;if(!i)e.__transition={};else if(n in i)return;J8(e,n,{name:t,index:r,group:s,on:X8,tween:Z8,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:_L})}function wk(e,t){var n=Ar(e,t);if(n.state>_L)throw new Error("too late; already scheduled");return n}function as(e,t){var n=Ar(e,t);if(n.state>Gd)throw new Error("too late; already running");return n}function Ar(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function J8(e,t,n){var r=e.__transition,s;r[t]=n,n.timer=SL(o,0,n.time);function o(h){n.state=LS,n.timer.restart(i,n.delay,n.time),n.delay<=h&&i(h-n.delay)}function i(h){var f,p,g,w;if(n.state!==LS)return d();for(f in r)if(w=r[f],w.name===n.name){if(w.state===Gd)return $S(i);w.state===OS?(w.state=Kd,w.timer.stop(),w.on.call("interrupt",e,e.__data__,w.index,w.group),delete r[f]):+f<t&&(w.state=Kd,w.timer.stop(),w.on.call("cancel",e,e.__data__,w.index,w.group),delete r[f])}if($S(function(){n.state===Gd&&(n.state=OS,n.timer.restart(c,n.delay,n.time),c(h))}),n.state=Qb,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Qb){for(n.state=Gd,s=new Array(g=n.tween.length),f=0,p=-1;f<g;++f)(w=n.tween[f].value.call(e,e.__data__,n.index,n.group))&&(s[++p]=w);s.length=p+1}}function c(h){for(var f=h<n.duration?n.ease.call(null,h/n.duration):(n.timer.restart(d),n.state=e0,1),p=-1,g=s.length;++p<g;)s[p].call(e,f);n.state===e0&&(n.on.call("end",e,e.__data__,n.index,n.group),d())}function d(){n.state=Kd,n.timer.stop(),delete r[t];for(var h in r)return;delete e.__transition}}function Yd(e,t){var n=e.__transition,r,s,o=!0,i;if(n){t=t==null?null:t+"";for(i in n){if((r=n[i]).name!==t){o=!1;continue}s=r.state>Qb&&r.state<e0,r.state=Kd,r.timer.stop(),r.on.call(s?"interrupt":"cancel",e,e.__data__,r.index,r.group),delete n[i]}o&&delete e.__transition}}function Q8(e){return this.each(function(){Yd(this,e)})}function eB(e,t){var n,r;return function(){var s=as(this,e),o=s.tween;if(o!==n){r=n=o;for(var i=0,c=r.length;i<c;++i)if(r[i].name===t){r=r.slice(),r.splice(i,1);break}}s.tween=r}}function tB(e,t,n){var r,s;if(typeof n!="function")throw new Error;return function(){var o=as(this,e),i=o.tween;if(i!==r){s=(r=i).slice();for(var c={name:t,value:n},d=0,h=s.length;d<h;++d)if(s[d].name===t){s[d]=c;break}d===h&&s.push(c)}o.tween=s}}function nB(e,t){var n=this._id;if(e+="",arguments.length<2){for(var r=Ar(this.node(),n).tween,s=0,o=r.length,i;s<o;++s)if((i=r[s]).name===e)return i.value;return null}return this.each((t==null?eB:tB)(n,e,t))}function xk(e,t,n){var r=e._id;return e.each(function(){var s=as(this,r);(s.value||(s.value={}))[t]=n.apply(this,arguments)}),function(s){return Ar(s,r).value[t]}}function EL(e,t){var n;return(typeof t=="number"?fa:t instanceof Nc?TS:(n=Nc(t))?(t=n,TS):P8)(e,t)}function rB(e){return function(){this.removeAttribute(e)}}function sB(e){return function(){this.removeAttributeNS(e.space,e.local)}}function aB(e,t,n){var r,s=n+"",o;return function(){var i=this.getAttribute(e);return i===s?null:i===r?o:o=t(r=i,n)}}function oB(e,t,n){var r,s=n+"",o;return function(){var i=this.getAttributeNS(e.space,e.local);return i===s?null:i===r?o:o=t(r=i,n)}}function iB(e,t,n){var r,s,o;return function(){var i,c=n(this),d;return c==null?void this.removeAttribute(e):(i=this.getAttribute(e),d=c+"",i===d?null:i===r&&d===s?o:(s=d,o=t(r=i,c)))}}function lB(e,t,n){var r,s,o;return function(){var i,c=n(this),d;return c==null?void this.removeAttributeNS(e.space,e.local):(i=this.getAttributeNS(e.space,e.local),d=c+"",i===d?null:i===r&&d===s?o:(s=d,o=t(r=i,c)))}}function cB(e,t){var n=Zh(e),r=n==="transform"?q8:EL;return this.attrTween(e,typeof t=="function"?(n.local?lB:iB)(n,r,xk(this,"attr."+e,t)):t==null?(n.local?sB:rB)(n):(n.local?oB:aB)(n,r,t))}function uB(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function dB(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function hB(e,t){var n,r;function s(){var o=t.apply(this,arguments);return o!==r&&(n=(r=o)&&dB(e,o)),n}return s._value=t,s}function fB(e,t){var n,r;function s(){var o=t.apply(this,arguments);return o!==r&&(n=(r=o)&&uB(e,o)),n}return s._value=t,s}function pB(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=Zh(e);return this.tween(n,(r.local?hB:fB)(r,t))}function mB(e,t){return function(){wk(this,e).delay=+t.apply(this,arguments)}}function gB(e,t){return t=+t,function(){wk(this,e).delay=t}}function yB(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?mB:gB)(t,e)):Ar(this.node(),t).delay}function wB(e,t){return function(){as(this,e).duration=+t.apply(this,arguments)}}function xB(e,t){return t=+t,function(){as(this,e).duration=t}}function vB(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?wB:xB)(t,e)):Ar(this.node(),t).duration}function bB(e,t){if(typeof t!="function")throw new Error;return function(){as(this,e).ease=t}}function kB(e){var t=this._id;return arguments.length?this.each(bB(t,e)):Ar(this.node(),t).ease}function jB(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;as(this,e).ease=n}}function NB(e){if(typeof e!="function")throw new Error;return this.each(jB(this._id,e))}function SB(e){typeof e!="function"&&(e=aL(e));for(var t=this._groups,n=t.length,r=new Array(n),s=0;s<n;++s)for(var o=t[s],i=o.length,c=r[s]=[],d,h=0;h<i;++h)(d=o[h])&&e.call(d,d.__data__,h,o)&&c.push(d);return new Ms(r,this._parents,this._name,this._id)}function _B(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,r=t.length,s=n.length,o=Math.min(r,s),i=new Array(r),c=0;c<o;++c)for(var d=t[c],h=n[c],f=d.length,p=i[c]=new Array(f),g,w=0;w<f;++w)(g=d[w]||h[w])&&(p[w]=g);for(;c<r;++c)i[c]=t[c];return new Ms(i,this._parents,this._name,this._id)}function EB(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 CB(e,t,n){var r,s,o=EB(t)?wk:as;return function(){var i=o(this,e),c=i.on;c!==r&&(s=(r=c).copy()).on(t,n),i.on=s}}function TB(e,t){var n=this._id;return arguments.length<2?Ar(this.node(),n).on.on(e):this.each(CB(n,e,t))}function RB(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function AB(){return this.on("end.remove",RB(this._id))}function MB(e){var t=this._name,n=this._id;typeof e!="function"&&(e=pk(e));for(var r=this._groups,s=r.length,o=new Array(s),i=0;i<s;++i)for(var c=r[i],d=c.length,h=o[i]=new Array(d),f,p,g=0;g<d;++g)(f=c[g])&&(p=e.call(f,f.__data__,g,c))&&("__data__"in f&&(p.__data__=f.__data__),h[g]=p,Qh(h[g],t,n,g,h,Ar(f,n)));return new Ms(o,this._parents,t,n)}function $B(e){var t=this._name,n=this._id;typeof e!="function"&&(e=sL(e));for(var r=this._groups,s=r.length,o=[],i=[],c=0;c<s;++c)for(var d=r[c],h=d.length,f,p=0;p<h;++p)if(f=d[p]){for(var g=e.call(f,f.__data__,p,d),w,k=Ar(f,n),j=0,v=g.length;j<v;++j)(w=g[j])&&Qh(w,t,n,j,g,k);o.push(g),i.push(f)}return new Ms(o,i,t,n)}var LB=Vc.prototype.constructor;function OB(){return new LB(this._groups,this._parents)}function IB(e,t){var n,r,s;return function(){var o=Bi(this,e),i=(this.style.removeProperty(e),Bi(this,e));return o===i?null:o===n&&i===r?s:s=t(n=o,r=i)}}function CL(e){return function(){this.style.removeProperty(e)}}function PB(e,t,n){var r,s=n+"",o;return function(){var i=Bi(this,e);return i===s?null:i===r?o:o=t(r=i,n)}}function DB(e,t,n){var r,s,o;return function(){var i=Bi(this,e),c=n(this),d=c+"";return c==null&&(d=c=(this.style.removeProperty(e),Bi(this,e))),i===d?null:i===r&&d===s?o:(s=d,o=t(r=i,c))}}function FB(e,t){var n,r,s,o="style."+t,i="end."+o,c;return function(){var d=as(this,e),h=d.on,f=d.value[o]==null?c||(c=CL(t)):void 0;(h!==n||s!==f)&&(r=(n=h).copy()).on(i,s=f),d.on=r}}function BB(e,t,n){var r=(e+="")=="transform"?B8:EL;return t==null?this.styleTween(e,IB(e,r)).on("end.style."+e,CL(e)):typeof t=="function"?this.styleTween(e,DB(e,r,xk(this,"style."+e,t))).each(FB(this._id,e)):this.styleTween(e,PB(e,r,t),n).on("end.style."+e,null)}function qB(e,t,n){return function(r){this.style.setProperty(e,t.call(this,r),n)}}function UB(e,t,n){var r,s;function o(){var i=t.apply(this,arguments);return i!==s&&(r=(s=i)&&qB(e,i,n)),r}return o._value=t,o}function HB(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,UB(e,t,n??""))}function WB(e){return function(){this.textContent=e}}function zB(e){return function(){var t=e(this);this.textContent=t??""}}function VB(e){return this.tween("text",typeof e=="function"?zB(xk(this,"text",e)):WB(e==null?"":e+""))}function GB(e){return function(t){this.textContent=e.call(this,t)}}function KB(e){var t,n;function r(){var s=e.apply(this,arguments);return s!==n&&(t=(n=s)&&GB(s)),t}return r._value=e,r}function YB(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,KB(e))}function XB(){for(var e=this._name,t=this._id,n=TL(),r=this._groups,s=r.length,o=0;o<s;++o)for(var i=r[o],c=i.length,d,h=0;h<c;++h)if(d=i[h]){var f=Ar(d,t);Qh(d,e,n,h,i,{time:f.time+f.delay+f.duration,delay:0,duration:f.duration,ease:f.ease})}return new Ms(r,this._parents,e,n)}function ZB(){var e,t,n=this,r=n._id,s=n.size();return new Promise(function(o,i){var c={value:i},d={value:function(){--s===0&&o()}};n.each(function(){var h=as(this,r),f=h.on;f!==e&&(t=(e=f).copy(),t._.cancel.push(c),t._.interrupt.push(c),t._.end.push(d)),h.on=t}),s===0&&o()})}var JB=0;function Ms(e,t,n,r){this._groups=e,this._parents=t,this._name=n,this._id=r}function TL(){return++JB}var js=Vc.prototype;Ms.prototype={constructor:Ms,select:MB,selectAll:$B,selectChild:js.selectChild,selectChildren:js.selectChildren,filter:SB,merge:_B,selection:OB,transition:XB,call:js.call,nodes:js.nodes,node:js.node,size:js.size,empty:js.empty,each:js.each,on:TB,attr:cB,attrTween:pB,style:BB,styleTween:HB,text:VB,textTween:YB,remove:AB,tween:nB,delay:yB,duration:vB,ease:kB,easeVarying:NB,end:ZB,[Symbol.iterator]:js[Symbol.iterator]};function QB(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var eq={time:null,delay:0,duration:250,ease:QB};function tq(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 nq(e){var t,n;e instanceof Ms?(t=e._id,e=e._name):(t=TL(),(n=eq).time=yk(),e=e==null?null:e+"");for(var r=this._groups,s=r.length,o=0;o<s;++o)for(var i=r[o],c=i.length,d,h=0;h<c;++h)(d=i[h])&&Qh(d,e,t,h,i,n||tq(d,t));return new Ms(r,this._parents,e,t)}Vc.prototype.interrupt=Q8;Vc.prototype.transition=nq;const bd=e=>()=>e;function rq(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 Rs(e,t,n){this.k=e,this.x=t,this.y=n}Rs.prototype={constructor:Rs,scale:function(e){return e===1?this:new Rs(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Rs(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 As=new Rs(1,0,0);Rs.prototype;function zm(e){e.stopImmediatePropagation()}function Gl(e){e.preventDefault(),e.stopImmediatePropagation()}function sq(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function aq(){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 IS(){return this.__zoom||As}function oq(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function iq(){return navigator.maxTouchPoints||"ontouchstart"in this}function lq(e,t,n){var r=e.invertX(t[0][0])-n[0][0],s=e.invertX(t[1][0])-n[1][0],o=e.invertY(t[0][1])-n[0][1],i=e.invertY(t[1][1])-n[1][1];return e.translate(s>r?(r+s)/2:Math.min(0,r)||Math.max(0,s),i>o?(o+i)/2:Math.min(0,o)||Math.max(0,i))}function RL(){var e=sq,t=aq,n=lq,r=oq,s=iq,o=[0,1/0],i=[[-1/0,-1/0],[1/0,1/0]],c=250,d=z8,h=Xh("start","zoom","end"),f,p,g,w=500,k=150,j=0,v=10;function b(A){A.property("__zoom",IS).on("wheel.zoom",I,{passive:!1}).on("mousedown.zoom",O).on("dblclick.zoom",U).filter(s).on("touchstart.zoom",P).on("touchmove.zoom",L).on("touchend.zoom touchcancel.zoom",F).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}b.transform=function(A,B,D,K){var G=A.selection?A.selection():A;G.property("__zoom",IS),A!==G?C(A,B,D,K):G.interrupt().each(function(){$(this,arguments).event(K).start().zoom(null,typeof B=="function"?B.apply(this,arguments):B).end()})},b.scaleBy=function(A,B,D,K){b.scaleTo(A,function(){var G=this.__zoom.k,H=typeof B=="function"?B.apply(this,arguments):B;return G*H},D,K)},b.scaleTo=function(A,B,D,K){b.transform(A,function(){var G=t.apply(this,arguments),H=this.__zoom,q=D==null?E(G):typeof D=="function"?D.apply(this,arguments):D,M=H.invert(q),V=typeof B=="function"?B.apply(this,arguments):B;return n(S(N(H,V),q,M),G,i)},D,K)},b.translateBy=function(A,B,D,K){b.transform(A,function(){return n(this.__zoom.translate(typeof B=="function"?B.apply(this,arguments):B,typeof D=="function"?D.apply(this,arguments):D),t.apply(this,arguments),i)},null,K)},b.translateTo=function(A,B,D,K,G){b.transform(A,function(){var H=t.apply(this,arguments),q=this.__zoom,M=K==null?E(H):typeof K=="function"?K.apply(this,arguments):K;return n(As.translate(M[0],M[1]).scale(q.k).translate(typeof B=="function"?-B.apply(this,arguments):-B,typeof D=="function"?-D.apply(this,arguments):-D),H,i)},K,G)};function N(A,B){return B=Math.max(o[0],Math.min(o[1],B)),B===A.k?A:new Rs(B,A.x,A.y)}function S(A,B,D){var K=B[0]-D[0]*A.k,G=B[1]-D[1]*A.k;return K===A.x&&G===A.y?A:new Rs(A.k,K,G)}function E(A){return[(+A[0][0]+ +A[1][0])/2,(+A[0][1]+ +A[1][1])/2]}function C(A,B,D,K){A.on("start.zoom",function(){$(this,arguments).event(K).start()}).on("interrupt.zoom end.zoom",function(){$(this,arguments).event(K).end()}).tween("zoom",function(){var G=this,H=arguments,q=$(G,H).event(K),M=t.apply(G,H),V=D==null?E(M):typeof D=="function"?D.apply(G,H):D,Z=Math.max(M[1][0]-M[0][0],M[1][1]-M[0][1]),W=G.__zoom,X=typeof B=="function"?B.apply(G,H):B,Y=d(W.invert(V).concat(Z/W.k),X.invert(V).concat(Z/X.k));return function(J){if(J===1)J=X;else{var ee=Y(J),ne=Z/ee[2];J=new Rs(ne,V[0]-ee[0]*ne,V[1]-ee[1]*ne)}q.zoom(null,J)}})}function $(A,B,D){return!D&&A.__zooming||new T(A,B)}function T(A,B){this.that=A,this.args=B,this.active=0,this.sourceEvent=null,this.extent=t.apply(A,B),this.taps=0}T.prototype={event:function(A){return A&&(this.sourceEvent=A),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(A,B){return this.mouse&&A!=="mouse"&&(this.mouse[1]=B.invert(this.mouse[0])),this.touch0&&A!=="touch"&&(this.touch0[1]=B.invert(this.touch0[0])),this.touch1&&A!=="touch"&&(this.touch1[1]=B.invert(this.touch1[0])),this.that.__zoom=B,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(A){var B=rr(this.that).datum();h.call(A,this.that,new rq(A,{sourceEvent:this.sourceEvent,target:b,transform:this.that.__zoom,dispatch:h}),B)}};function I(A,...B){if(!e.apply(this,arguments))return;var D=$(this,B).event(A),K=this.__zoom,G=Math.max(o[0],Math.min(o[1],K.k*Math.pow(2,r.apply(this,arguments)))),H=jr(A);if(D.wheel)(D.mouse[0][0]!==H[0]||D.mouse[0][1]!==H[1])&&(D.mouse[1]=K.invert(D.mouse[0]=H)),clearTimeout(D.wheel);else{if(K.k===G)return;D.mouse=[H,K.invert(H)],Yd(this),D.start()}Gl(A),D.wheel=setTimeout(q,k),D.zoom("mouse",n(S(N(K,G),D.mouse[0],D.mouse[1]),D.extent,i));function q(){D.wheel=null,D.end()}}function O(A,...B){if(g||!e.apply(this,arguments))return;var D=A.currentTarget,K=$(this,B,!0).event(A),G=rr(A.view).on("mousemove.zoom",V,!0).on("mouseup.zoom",Z,!0),H=jr(A,D),q=A.clientX,M=A.clientY;mL(A.view),zm(A),K.mouse=[H,this.__zoom.invert(H)],Yd(this),K.start();function V(W){if(Gl(W),!K.moved){var X=W.clientX-q,Y=W.clientY-M;K.moved=X*X+Y*Y>j}K.event(W).zoom("mouse",n(S(K.that.__zoom,K.mouse[0]=jr(W,D),K.mouse[1]),K.extent,i))}function Z(W){G.on("mousemove.zoom mouseup.zoom",null),gL(W.view,K.moved),Gl(W),K.event(W).end()}}function U(A,...B){if(e.apply(this,arguments)){var D=this.__zoom,K=jr(A.changedTouches?A.changedTouches[0]:A,this),G=D.invert(K),H=D.k*(A.shiftKey?.5:2),q=n(S(N(D,H),K,G),t.apply(this,B),i);Gl(A),c>0?rr(this).transition().duration(c).call(C,q,K,A):rr(this).call(b.transform,q,K,A)}}function P(A,...B){if(e.apply(this,arguments)){var D=A.touches,K=D.length,G=$(this,B,A.changedTouches.length===K).event(A),H,q,M,V;for(zm(A),q=0;q<K;++q)M=D[q],V=jr(M,this),V=[V,this.__zoom.invert(V),M.identifier],G.touch0?!G.touch1&&G.touch0[2]!==V[2]&&(G.touch1=V,G.taps=0):(G.touch0=V,H=!0,G.taps=1+!!f);f&&(f=clearTimeout(f)),H&&(G.taps<2&&(p=V[0],f=setTimeout(function(){f=null},w)),Yd(this),G.start())}}function L(A,...B){if(this.__zooming){var D=$(this,B).event(A),K=A.changedTouches,G=K.length,H,q,M,V;for(Gl(A),H=0;H<G;++H)q=K[H],M=jr(q,this),D.touch0&&D.touch0[2]===q.identifier?D.touch0[0]=M:D.touch1&&D.touch1[2]===q.identifier&&(D.touch1[0]=M);if(q=D.that.__zoom,D.touch1){var Z=D.touch0[0],W=D.touch0[1],X=D.touch1[0],Y=D.touch1[1],J=(J=X[0]-Z[0])*J+(J=X[1]-Z[1])*J,ee=(ee=Y[0]-W[0])*ee+(ee=Y[1]-W[1])*ee;q=N(q,Math.sqrt(J/ee)),M=[(Z[0]+X[0])/2,(Z[1]+X[1])/2],V=[(W[0]+Y[0])/2,(W[1]+Y[1])/2]}else if(D.touch0)M=D.touch0[0],V=D.touch0[1];else return;D.zoom("touch",n(S(q,M,V),D.extent,i))}}function F(A,...B){if(this.__zooming){var D=$(this,B).event(A),K=A.changedTouches,G=K.length,H,q;for(zm(A),g&&clearTimeout(g),g=setTimeout(function(){g=null},w),H=0;H<G;++H)q=K[H],D.touch0&&D.touch0[2]===q.identifier?delete D.touch0:D.touch1&&D.touch1[2]===q.identifier&&delete D.touch1;if(D.touch1&&!D.touch0&&(D.touch0=D.touch1,delete D.touch1),D.touch0)D.touch0[1]=this.__zoom.invert(D.touch0[0]);else if(D.end(),D.taps===2&&(q=jr(q,this),Math.hypot(p[0]-q[0],p[1]-q[1])<v)){var M=rr(this).on("dblclick.zoom");M&&M.apply(this,arguments)}}}return b.wheelDelta=function(A){return arguments.length?(r=typeof A=="function"?A:bd(+A),b):r},b.filter=function(A){return arguments.length?(e=typeof A=="function"?A:bd(!!A),b):e},b.touchable=function(A){return arguments.length?(s=typeof A=="function"?A:bd(!!A),b):s},b.extent=function(A){return arguments.length?(t=typeof A=="function"?A:bd([[+A[0][0],+A[0][1]],[+A[1][0],+A[1][1]]]),b):t},b.scaleExtent=function(A){return arguments.length?(o[0]=+A[0],o[1]=+A[1],b):[o[0],o[1]]},b.translateExtent=function(A){return arguments.length?(i[0][0]=+A[0][0],i[1][0]=+A[1][0],i[0][1]=+A[0][1],i[1][1]=+A[1][1],b):[[i[0][0],i[0][1]],[i[1][0],i[1][1]]]},b.constrain=function(A){return arguments.length?(n=A,b):n},b.duration=function(A){return arguments.length?(c=+A,b):c},b.interpolate=function(A){return arguments.length?(d=A,b):d},b.on=function(){var A=h.on.apply(h,arguments);return A===h?b:A},b.clickDistance=function(A){return arguments.length?(j=(A=+A)*A,b):Math.sqrt(j)},b.tapDistance=function(A){return arguments.length?(v=+A,b):v},b}var yt=tL();const ef=y.createContext(null),cq=ef.Provider,$s={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.`},AL=$s.error001();function Qe(e,t){const n=y.useContext(ef);if(n===null)throw new Error(AL);return nL(n,e,t)}const Rt=()=>{const e=y.useContext(ef);if(e===null)throw new Error(AL);return y.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy}),[e])},uq=e=>e.userSelectionActive?"none":"all";function vk({position:e,children:t,className:n,style:r,...s}){const o=Qe(uq),i=`${e}`.split("-");return he.createElement("div",{className:Qt(["react-flow__panel",n,...i]),style:{...r,pointerEvents:o},...s},t)}function dq({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:he.createElement(vk,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://reactflow.dev/pro"},he.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}const hq=({x:e,y:t,label:n,labelStyle:r={},labelShowBg:s=!0,labelBgStyle:o={},labelBgPadding:i=[2,4],labelBgBorderRadius:c=2,children:d,className:h,...f})=>{const p=y.useRef(null),[g,w]=y.useState({x:0,y:0,width:0,height:0}),k=Qt(["react-flow__edge-textwrapper",h]);return y.useEffect(()=>{if(p.current){const j=p.current.getBBox();w({x:j.x,y:j.y,width:j.width,height:j.height})}},[n]),typeof n>"u"||!n?null:he.createElement("g",{transform:`translate(${e-g.width/2} ${t-g.height/2})`,className:k,visibility:g.width?"visible":"hidden",...f},s&&he.createElement("rect",{width:g.width+2*i[0],x:-i[0],y:-i[1],height:g.height+2*i[1],className:"react-flow__edge-textbg",style:o,rx:c,ry:c}),he.createElement("text",{className:"react-flow__edge-text",y:g.height/2,dy:"0.3em",ref:p,style:r},n),d)};var fq=y.memo(hq);const bk=e=>({width:e.offsetWidth,height:e.offsetHeight}),Ui=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),kk=(e={x:0,y:0},t)=>({x:Ui(e.x,t[0][0],t[1][0]),y:Ui(e.y,t[0][1],t[1][1])}),PS=(e,t,n)=>e<t?Ui(Math.abs(e-t),1,50)/50:e>n?-Ui(Math.abs(e-n),1,50)/50:0,ML=(e,t)=>{const n=PS(e.x,35,t.width-35)*20,r=PS(e.y,35,t.height-35)*20;return[n,r]},$L=e=>{var t;return((t=e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},LL=(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)}),_c=({x:e,y:t,width:n,height:r})=>({x:e,y:t,x2:e+n,y2:t+r}),OL=({x:e,y:t,x2:n,y2:r})=>({x:e,y:t,width:n-e,height:r-t}),DS=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),pq=(e,t)=>OL(LL(_c(e),_c(t))),t0=(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)},mq=e=>sr(e.width)&&sr(e.height)&&sr(e.x)&&sr(e.y),sr=e=>!isNaN(e)&&isFinite(e),_t=Symbol.for("internals"),IL=["Enter"," ","Escape"],gq=(e,t)=>{},yq=e=>"nativeEvent"in e;function n0(e){var s,o;const t=yq(e)?e.nativeEvent:e,n=((o=(s=t.composedPath)==null?void 0:s.call(t))==null?void 0:o[0])||e.target;return["INPUT","SELECT","TEXTAREA"].includes(n==null?void 0:n.nodeName)||(n==null?void 0:n.hasAttribute("contenteditable"))||!!(n!=null&&n.closest(".nokey"))}const PL=e=>"clientX"in e,ka=(e,t)=>{var o,i;const n=PL(e),r=n?e.clientX:(o=e.touches)==null?void 0:o[0].clientX,s=n?e.clientY:(i=e.touches)==null?void 0:i[0].clientY;return{x:r-((t==null?void 0:t.left)??0),y:s-((t==null?void 0:t.top)??0)}},fh=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0},Kc=({id:e,path:t,labelX:n,labelY:r,label:s,labelStyle:o,labelShowBg:i,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:p,markerStart:g,interactionWidth:w=20})=>he.createElement(he.Fragment,null,he.createElement("path",{id:e,style:f,d:t,fill:"none",className:"react-flow__edge-path",markerEnd:p,markerStart:g}),w&&he.createElement("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:w,className:"react-flow__edge-interaction"}),s&&sr(n)&&sr(r)?he.createElement(fq,{x:n,y:r,label:s,labelStyle:o,labelShowBg:i,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h}):null);Kc.displayName="BaseEdge";function Kl(e,t,n){return n===void 0?n:r=>{const s=t().edges.find(o=>o.id===e);s&&n(r,{...s})}}function DL({sourceX:e,sourceY:t,targetX:n,targetY:r}){const s=Math.abs(n-e)/2,o=n<e?n+s:n-s,i=Math.abs(r-t)/2,c=r<t?r+i:r-i;return[o,c,s,i]}function FL({sourceX:e,sourceY:t,targetX:n,targetY:r,sourceControlX:s,sourceControlY:o,targetControlX:i,targetControlY:c}){const d=e*.125+s*.375+i*.375+n*.125,h=t*.125+o*.375+c*.375+r*.125,f=Math.abs(d-e),p=Math.abs(h-t);return[d,h,f,p]}var No;(function(e){e.Strict="strict",e.Loose="loose"})(No||(No={}));var po;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(po||(po={}));var Ec;(function(e){e.Partial="partial",e.Full="full"})(Ec||(Ec={}));var ma;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(ma||(ma={}));var ph;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(ph||(ph={}));var Le;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Le||(Le={}));function FS({pos:e,x1:t,y1:n,x2:r,y2:s}){return e===Le.Left||e===Le.Right?[.5*(t+r),n]:[t,.5*(n+s)]}function BL({sourceX:e,sourceY:t,sourcePosition:n=Le.Bottom,targetX:r,targetY:s,targetPosition:o=Le.Top}){const[i,c]=FS({pos:n,x1:e,y1:t,x2:r,y2:s}),[d,h]=FS({pos:o,x1:r,y1:s,x2:e,y2:t}),[f,p,g,w]=FL({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:i,sourceControlY:c,targetControlX:d,targetControlY:h});return[`M${e},${t} C${i},${c} ${d},${h} ${r},${s}`,f,p,g,w]}const jk=y.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:s=Le.Bottom,targetPosition:o=Le.Top,label:i,labelStyle:c,labelShowBg:d,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:g,markerEnd:w,markerStart:k,interactionWidth:j})=>{const[v,b,N]=BL({sourceX:e,sourceY:t,sourcePosition:s,targetX:n,targetY:r,targetPosition:o});return he.createElement(Kc,{path:v,labelX:b,labelY:N,label:i,labelStyle:c,labelShowBg:d,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:g,markerEnd:w,markerStart:k,interactionWidth:j})});jk.displayName="SimpleBezierEdge";const BS={[Le.Left]:{x:-1,y:0},[Le.Right]:{x:1,y:0},[Le.Top]:{x:0,y:-1},[Le.Bottom]:{x:0,y:1}},wq=({source:e,sourcePosition:t=Le.Bottom,target:n})=>t===Le.Left||t===Le.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},qS=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function xq({source:e,sourcePosition:t=Le.Bottom,target:n,targetPosition:r=Le.Top,center:s,offset:o}){const i=BS[t],c=BS[r],d={x:e.x+i.x*o,y:e.y+i.y*o},h={x:n.x+c.x*o,y:n.y+c.y*o},f=wq({source:d,sourcePosition:t,target:h}),p=f.x!==0?"x":"y",g=f[p];let w=[],k,j;const v={x:0,y:0},b={x:0,y:0},[N,S,E,C]=DL({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(i[p]*c[p]===-1){k=s.x??N,j=s.y??S;const T=[{x:k,y:d.y},{x:k,y:h.y}],I=[{x:d.x,y:j},{x:h.x,y:j}];i[p]===g?w=p==="x"?T:I:w=p==="x"?I:T}else{const T=[{x:d.x,y:h.y}],I=[{x:h.x,y:d.y}];if(p==="x"?w=i.x===g?I:T:w=i.y===g?T:I,t===r){const F=Math.abs(e[p]-n[p]);if(F<=o){const A=Math.min(o-1,o-F);i[p]===g?v[p]=(d[p]>e[p]?-1:1)*A:b[p]=(h[p]>n[p]?-1:1)*A}}if(t!==r){const F=p==="x"?"y":"x",A=i[p]===c[F],B=d[F]>h[F],D=d[F]<h[F];(i[p]===1&&(!A&&B||A&&D)||i[p]!==1&&(!A&&D||A&&B))&&(w=p==="x"?T:I)}const O={x:d.x+v.x,y:d.y+v.y},U={x:h.x+b.x,y:h.y+b.y},P=Math.max(Math.abs(O.x-w[0].x),Math.abs(U.x-w[0].x)),L=Math.max(Math.abs(O.y-w[0].y),Math.abs(U.y-w[0].y));P>=L?(k=(O.x+U.x)/2,j=w[0].y):(k=w[0].x,j=(O.y+U.y)/2)}return[[e,{x:d.x+v.x,y:d.y+v.y},...w,{x:h.x+b.x,y:h.y+b.y},n],k,j,E,C]}function vq(e,t,n,r){const s=Math.min(qS(e,t)/2,qS(t,n)/2,r),{x:o,y:i}=t;if(e.x===o&&o===n.x||e.y===i&&i===n.y)return`L${o} ${i}`;if(e.y===i){const h=e.x<n.x?-1:1,f=e.y<n.y?1:-1;return`L ${o+s*h},${i}Q ${o},${i} ${o},${i+s*f}`}const c=e.x<n.x?1:-1,d=e.y<n.y?-1:1;return`L ${o},${i+s*d}Q ${o},${i} ${o+s*c},${i}`}function r0({sourceX:e,sourceY:t,sourcePosition:n=Le.Bottom,targetX:r,targetY:s,targetPosition:o=Le.Top,borderRadius:i=5,centerX:c,centerY:d,offset:h=20}){const[f,p,g,w,k]=xq({source:{x:e,y:t},sourcePosition:n,target:{x:r,y:s},targetPosition:o,center:{x:c,y:d},offset:h});return[f.reduce((v,b,N)=>{let S="";return N>0&&N<f.length-1?S=vq(f[N-1],b,f[N+1],i):S=`${N===0?"M":"L"}${b.x} ${b.y}`,v+=S,v},""),p,g,w,k]}const tf=y.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,label:s,labelStyle:o,labelShowBg:i,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:f,sourcePosition:p=Le.Bottom,targetPosition:g=Le.Top,markerEnd:w,markerStart:k,pathOptions:j,interactionWidth:v})=>{const[b,N,S]=r0({sourceX:e,sourceY:t,sourcePosition:p,targetX:n,targetY:r,targetPosition:g,borderRadius:j==null?void 0:j.borderRadius,offset:j==null?void 0:j.offset});return he.createElement(Kc,{path:b,labelX:N,labelY:S,label:s,labelStyle:o,labelShowBg:i,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:w,markerStart:k,interactionWidth:v})});tf.displayName="SmoothStepEdge";const Nk=y.memo(e=>{var t;return he.createElement(tf,{...e,pathOptions:y.useMemo(()=>{var n;return{borderRadius:0,offset:(n=e.pathOptions)==null?void 0:n.offset}},[(t=e.pathOptions)==null?void 0:t.offset])})});Nk.displayName="StepEdge";function bq({sourceX:e,sourceY:t,targetX:n,targetY:r}){const[s,o,i,c]=DL({sourceX:e,sourceY:t,targetX:n,targetY:r});return[`M ${e},${t}L ${n},${r}`,s,o,i,c]}const Sk=y.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,label:s,labelStyle:o,labelShowBg:i,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:p,markerStart:g,interactionWidth:w})=>{const[k,j,v]=bq({sourceX:e,sourceY:t,targetX:n,targetY:r});return he.createElement(Kc,{path:k,labelX:j,labelY:v,label:s,labelStyle:o,labelShowBg:i,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:p,markerStart:g,interactionWidth:w})});Sk.displayName="StraightEdge";function kd(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function US({pos:e,x1:t,y1:n,x2:r,y2:s,c:o}){switch(e){case Le.Left:return[t-kd(t-r,o),n];case Le.Right:return[t+kd(r-t,o),n];case Le.Top:return[t,n-kd(n-s,o)];case Le.Bottom:return[t,n+kd(s-n,o)]}}function _k({sourceX:e,sourceY:t,sourcePosition:n=Le.Bottom,targetX:r,targetY:s,targetPosition:o=Le.Top,curvature:i=.25}){const[c,d]=US({pos:n,x1:e,y1:t,x2:r,y2:s,c:i}),[h,f]=US({pos:o,x1:r,y1:s,x2:e,y2:t,c:i}),[p,g,w,k]=FL({sourceX:e,sourceY:t,targetX:r,targetY:s,sourceControlX:c,sourceControlY:d,targetControlX:h,targetControlY:f});return[`M${e},${t} C${c},${d} ${h},${f} ${r},${s}`,p,g,w,k]}const mh=y.memo(({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:s=Le.Bottom,targetPosition:o=Le.Top,label:i,labelStyle:c,labelShowBg:d,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:g,markerEnd:w,markerStart:k,pathOptions:j,interactionWidth:v})=>{const[b,N,S]=_k({sourceX:e,sourceY:t,sourcePosition:s,targetX:n,targetY:r,targetPosition:o,curvature:j==null?void 0:j.curvature});return he.createElement(Kc,{path:b,labelX:N,labelY:S,label:i,labelStyle:c,labelShowBg:d,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:g,markerEnd:w,markerStart:k,interactionWidth:v})});mh.displayName="BezierEdge";const Ek=y.createContext(null),kq=Ek.Provider;Ek.Consumer;const jq=()=>y.useContext(Ek),Nq=e=>"id"in e&&"source"in e&&"target"in e,Sq=({source:e,sourceHandle:t,target:n,targetHandle:r})=>`reactflow__edge-${e}${t||""}-${n}${r||""}`,s0=(e,t)=>typeof e>"u"?"":typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(r=>`${r}=${e[r]}`).join("&")}`,_q=(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)),Eq=(e,t)=>{if(!e.source||!e.target)return t;let n;return Nq(e)?n={...e}:n={...e,id:Sq(e)},_q(n,t)?t:t.concat(n)},a0=({x:e,y:t},[n,r,s],o,[i,c])=>{const d={x:(e-n)/s,y:(t-r)/s};return o?{x:i*Math.round(d.x/i),y:c*Math.round(d.y/c)}:d},qL=({x:e,y:t},[n,r,s])=>({x:e*s+n,y:t*s+r}),wo=(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}},nf=(e,t=[0,0])=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((r,s)=>{const{x:o,y:i}=wo(s,t).positionAbsolute;return LL(r,_c({x:o,y:i,width:s.width||0,height:s.height||0}))},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return OL(n)},UL=(e,t,[n,r,s]=[0,0,1],o=!1,i=!1,c=[0,0])=>{const d={x:(t.x-n)/s,y:(t.y-r)/s,width:t.width/s,height:t.height/s},h=[];return e.forEach(f=>{const{width:p,height:g,selectable:w=!0,hidden:k=!1}=f;if(i&&!w||k)return!1;const{positionAbsolute:j}=wo(f,c),v={x:j.x,y:j.y,width:p||0,height:g||0},b=t0(d,v),N=typeof p>"u"||typeof g>"u"||p===null||g===null,S=o&&b>0,E=(p||0)*(g||0);(N||S||b>=E||f.dragging)&&h.push(f)}),h},HL=(e,t)=>{const n=e.map(r=>r.id);return t.filter(r=>n.includes(r.source)||n.includes(r.target))},WL=(e,t,n,r,s,o=.1)=>{const i=t/(e.width*(1+o)),c=n/(e.height*(1+o)),d=Math.min(i,c),h=Ui(d,r,s),f=e.x+e.width/2,p=e.y+e.height/2,g=t/2-f*h,w=n/2-p*h;return{x:g,y:w,zoom:h}},io=(e,t=0)=>e.transition().duration(t);function HS(e,t,n,r){return(t[n]||[]).reduce((s,o)=>{var i,c;return`${e.id}-${o.id}-${n}`!==r&&s.push({id:o.id||null,type:n,nodeId:e.id,x:(((i=e.positionAbsolute)==null?void 0:i.x)??0)+o.x+o.width/2,y:(((c=e.positionAbsolute)==null?void 0:c.y)??0)+o.y+o.height/2}),s},[])}function Cq(e,t,n,r,s,o){const{x:i,y:c}=ka(e),h=t.elementsFromPoint(i,c).find(k=>k.classList.contains("react-flow__handle"));if(h){const k=h.getAttribute("data-nodeid");if(k){const j=Ck(void 0,h),v=h.getAttribute("data-handleid"),b=o({nodeId:k,id:v,type:j});if(b){const N=s.find(S=>S.nodeId===k&&S.type===j&&S.id===v);return{handle:{id:v,type:j,nodeId:k,x:(N==null?void 0:N.x)||n.x,y:(N==null?void 0:N.y)||n.y},validHandleResult:b}}}}let f=[],p=1/0;if(s.forEach(k=>{const j=Math.sqrt((k.x-n.x)**2+(k.y-n.y)**2);if(j<=r){const v=o(k);j<=p&&(j<p?f=[{handle:k,validHandleResult:v}]:j===p&&f.push({handle:k,validHandleResult:v}),p=j)}}),!f.length)return{handle:null,validHandleResult:zL()};if(f.length===1)return f[0];const g=f.some(({validHandleResult:k})=>k.isValid),w=f.some(({handle:k})=>k.type==="target");return f.find(({handle:k,validHandleResult:j})=>w?k.type==="target":g?j.isValid:!0)||f[0]}const Tq={source:null,target:null,sourceHandle:null,targetHandle:null},zL=()=>({handleDomNode:null,isValid:!1,connection:Tq,endHandle:null});function VL(e,t,n,r,s,o,i){const c=s==="target",d=i.querySelector(`.react-flow__handle[data-id="${e==null?void 0:e.nodeId}-${e==null?void 0:e.id}-${e==null?void 0:e.type}"]`),h={...zL(),handleDomNode:d};if(d){const f=Ck(void 0,d),p=d.getAttribute("data-nodeid"),g=d.getAttribute("data-handleid"),w=d.classList.contains("connectable"),k=d.classList.contains("connectableend"),j={source:c?p:n,sourceHandle:c?g:r,target:c?n:p,targetHandle:c?r:g};h.connection=j,w&&k&&(t===No.Strict?c&&f==="source"||!c&&f==="target":p!==n||g!==r)&&(h.endHandle={nodeId:p,handleId:g,type:f},h.isValid=o(j))}return h}function Rq({nodes:e,nodeId:t,handleId:n,handleType:r}){return e.reduce((s,o)=>{if(o[_t]){const{handleBounds:i}=o[_t];let c=[],d=[];i&&(c=HS(o,i,"source",`${t}-${n}-${r}`),d=HS(o,i,"target",`${t}-${n}-${r}`)),s.push(...c,...d)}return s},[])}function Ck(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function Vm(e){e==null||e.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function Aq(e,t){let n=null;return t?n="valid":e&&!t&&(n="invalid"),n}function GL({event:e,handleId:t,nodeId:n,onConnect:r,isTarget:s,getState:o,setState:i,isValidConnection:c,edgeUpdaterType:d,onReconnectEnd:h}){const f=$L(e.target),{connectionMode:p,domNode:g,autoPanOnConnect:w,connectionRadius:k,onConnectStart:j,panBy:v,getNodes:b,cancelConnection:N}=o();let S=0,E;const{x:C,y:$}=ka(e),T=f==null?void 0:f.elementFromPoint(C,$),I=Ck(d,T),O=g==null?void 0:g.getBoundingClientRect();if(!O||!I)return;let U,P=ka(e,O),L=!1,F=null,A=!1,B=null;const D=Rq({nodes:b(),nodeId:n,handleId:t,handleType:I}),K=()=>{if(!w)return;const[q,M]=ML(P,O);v({x:q,y:M}),S=requestAnimationFrame(K)};i({connectionPosition:P,connectionStatus:null,connectionNodeId:n,connectionHandleId:t,connectionHandleType:I,connectionStartHandle:{nodeId:n,handleId:t,type:I},connectionEndHandle:null}),j==null||j(e,{nodeId:n,handleId:t,handleType:I});function G(q){const{transform:M}=o();P=ka(q,O);const{handle:V,validHandleResult:Z}=Cq(q,f,a0(P,M,!1,[1,1]),k,D,W=>VL(W,p,n,t,s?"target":"source",c,f));if(E=V,L||(K(),L=!0),B=Z.handleDomNode,F=Z.connection,A=Z.isValid,i({connectionPosition:E&&A?qL({x:E.x,y:E.y},M):P,connectionStatus:Aq(!!E,A),connectionEndHandle:Z.endHandle}),!E&&!A&&!B)return Vm(U);F.source!==F.target&&B&&(Vm(U),U=B,B.classList.add("connecting","react-flow__handle-connecting"),B.classList.toggle("valid",A),B.classList.toggle("react-flow__handle-valid",A))}function H(q){var M,V;(E||B)&&F&&A&&(r==null||r(F)),(V=(M=o()).onConnectEnd)==null||V.call(M,q),d&&(h==null||h(q)),Vm(U),N(),cancelAnimationFrame(S),L=!1,A=!1,F=null,B=null,f.removeEventListener("mousemove",G),f.removeEventListener("mouseup",H),f.removeEventListener("touchmove",G),f.removeEventListener("touchend",H)}f.addEventListener("mousemove",G),f.addEventListener("mouseup",H),f.addEventListener("touchmove",G),f.addEventListener("touchend",H)}const WS=()=>!0,Mq=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),$q=(e,t,n)=>r=>{const{connectionStartHandle:s,connectionEndHandle:o,connectionClickStartHandle:i}=r;return{connecting:(s==null?void 0:s.nodeId)===e&&(s==null?void 0:s.handleId)===t&&(s==null?void 0:s.type)===n||(o==null?void 0:o.nodeId)===e&&(o==null?void 0:o.handleId)===t&&(o==null?void 0:o.type)===n,clickConnecting:(i==null?void 0:i.nodeId)===e&&(i==null?void 0:i.handleId)===t&&(i==null?void 0:i.type)===n}},KL=y.forwardRef(({type:e="source",position:t=Le.Top,isValidConnection:n,isConnectable:r=!0,isConnectableStart:s=!0,isConnectableEnd:o=!0,id:i,onConnect:c,children:d,className:h,onMouseDown:f,onTouchStart:p,...g},w)=>{var O,U;const k=i||null,j=e==="target",v=Rt(),b=jq(),{connectOnClick:N,noPanClassName:S}=Qe(Mq,Ht),{connecting:E,clickConnecting:C}=Qe($q(b,k,e),Ht);b||(U=(O=v.getState()).onError)==null||U.call(O,"010",$s.error010());const $=P=>{const{defaultEdgeOptions:L,onConnect:F,hasDefaultEdges:A}=v.getState(),B={...L,...P};if(A){const{edges:D,setEdges:K}=v.getState();K(Eq(B,D))}F==null||F(B),c==null||c(B)},T=P=>{if(!b)return;const L=PL(P);s&&(L&&P.button===0||!L)&&GL({event:P,handleId:k,nodeId:b,onConnect:$,isTarget:j,getState:v.getState,setState:v.setState,isValidConnection:n||v.getState().isValidConnection||WS}),L?f==null||f(P):p==null||p(P)},I=P=>{const{onClickConnectStart:L,onClickConnectEnd:F,connectionClickStartHandle:A,connectionMode:B,isValidConnection:D}=v.getState();if(!b||!A&&!s)return;if(!A){L==null||L(P,{nodeId:b,handleId:k,handleType:e}),v.setState({connectionClickStartHandle:{nodeId:b,type:e,handleId:k}});return}const K=$L(P.target),G=n||D||WS,{connection:H,isValid:q}=VL({nodeId:b,id:k,type:e},B,A.nodeId,A.handleId||null,A.type,G,K);q&&$(H),F==null||F(P),v.setState({connectionClickStartHandle:null})};return he.createElement("div",{"data-handleid":k,"data-nodeid":b,"data-handlepos":t,"data-id":`${b}-${k}-${e}`,className:Qt(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",S,h,{source:!j,target:j,connectable:r,connectablestart:s,connectableend:o,connecting:C,connectionindicator:r&&(s&&!E||o&&E)}]),onMouseDown:T,onTouchStart:T,onClick:N?I:void 0,ref:w,...g},d)});KL.displayName="Handle";var So=y.memo(KL);const YL=({data:e,isConnectable:t,targetPosition:n=Le.Top,sourcePosition:r=Le.Bottom})=>he.createElement(he.Fragment,null,he.createElement(So,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,he.createElement(So,{type:"source",position:r,isConnectable:t}));YL.displayName="DefaultNode";var o0=y.memo(YL);const XL=({data:e,isConnectable:t,sourcePosition:n=Le.Bottom})=>he.createElement(he.Fragment,null,e==null?void 0:e.label,he.createElement(So,{type:"source",position:n,isConnectable:t}));XL.displayName="InputNode";var ZL=y.memo(XL);const JL=({data:e,isConnectable:t,targetPosition:n=Le.Top})=>he.createElement(he.Fragment,null,he.createElement(So,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label);JL.displayName="OutputNode";var QL=y.memo(JL);const Tk=()=>null;Tk.displayName="GroupNode";const Lq=e=>({selectedNodes:e.getNodes().filter(t=>t.selected),selectedEdges:e.edges.filter(t=>t.selected).map(t=>({...t}))}),jd=e=>e.id;function Oq(e,t){return Ht(e.selectedNodes.map(jd),t.selectedNodes.map(jd))&&Ht(e.selectedEdges.map(jd),t.selectedEdges.map(jd))}const eO=y.memo(({onSelectionChange:e})=>{const t=Rt(),{selectedNodes:n,selectedEdges:r}=Qe(Lq,Oq);return y.useEffect(()=>{const s={nodes:n,edges:r};e==null||e(s),t.getState().onSelectionChange.forEach(o=>o(s))},[n,r,e]),null});eO.displayName="SelectionListener";const Iq=e=>!!e.onSelectionChange;function Pq({onSelectionChange:e}){const t=Qe(Iq);return e||t?he.createElement(eO,{onSelectionChange:e}):null}const Dq=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 ui(e,t){y.useEffect(()=>{typeof e<"u"&&t(e)},[e])}function ze(e,t,n){y.useEffect(()=>{typeof t<"u"&&n({[e]:t})},[t])}const Fq=({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:s,onConnectStart:o,onConnectEnd:i,onClickConnectStart:c,onClickConnectEnd:d,nodesDraggable:h,nodesConnectable:f,nodesFocusable:p,edgesFocusable:g,edgesUpdatable:w,elevateNodesOnSelect:k,minZoom:j,maxZoom:v,nodeExtent:b,onNodesChange:N,onEdgesChange:S,elementsSelectable:E,connectionMode:C,snapGrid:$,snapToGrid:T,translateExtent:I,connectOnClick:O,defaultEdgeOptions:U,fitView:P,fitViewOptions:L,onNodesDelete:F,onEdgesDelete:A,onNodeDrag:B,onNodeDragStart:D,onNodeDragStop:K,onSelectionDrag:G,onSelectionDragStart:H,onSelectionDragStop:q,noPanClassName:M,nodeOrigin:V,rfId:Z,autoPanOnConnect:W,autoPanOnNodeDrag:X,onError:Y,connectionRadius:J,isValidConnection:ee,nodeDragThreshold:ne})=>{const{setNodes:se,setEdges:ce,setDefaultNodesAndEdges:de,setMinZoom:ae,setMaxZoom:pe,setTranslateExtent:fe,setNodeExtent:Ee,reset:ye}=Qe(Dq,Ht),oe=Rt();return y.useEffect(()=>{const we=r==null?void 0:r.map(Ne=>({...Ne,...U}));return de(n,we),()=>{ye()}},[]),ze("defaultEdgeOptions",U,oe.setState),ze("connectionMode",C,oe.setState),ze("onConnect",s,oe.setState),ze("onConnectStart",o,oe.setState),ze("onConnectEnd",i,oe.setState),ze("onClickConnectStart",c,oe.setState),ze("onClickConnectEnd",d,oe.setState),ze("nodesDraggable",h,oe.setState),ze("nodesConnectable",f,oe.setState),ze("nodesFocusable",p,oe.setState),ze("edgesFocusable",g,oe.setState),ze("edgesUpdatable",w,oe.setState),ze("elementsSelectable",E,oe.setState),ze("elevateNodesOnSelect",k,oe.setState),ze("snapToGrid",T,oe.setState),ze("snapGrid",$,oe.setState),ze("onNodesChange",N,oe.setState),ze("onEdgesChange",S,oe.setState),ze("connectOnClick",O,oe.setState),ze("fitViewOnInit",P,oe.setState),ze("fitViewOnInitOptions",L,oe.setState),ze("onNodesDelete",F,oe.setState),ze("onEdgesDelete",A,oe.setState),ze("onNodeDrag",B,oe.setState),ze("onNodeDragStart",D,oe.setState),ze("onNodeDragStop",K,oe.setState),ze("onSelectionDrag",G,oe.setState),ze("onSelectionDragStart",H,oe.setState),ze("onSelectionDragStop",q,oe.setState),ze("noPanClassName",M,oe.setState),ze("nodeOrigin",V,oe.setState),ze("rfId",Z,oe.setState),ze("autoPanOnConnect",W,oe.setState),ze("autoPanOnNodeDrag",X,oe.setState),ze("onError",Y,oe.setState),ze("connectionRadius",J,oe.setState),ze("isValidConnection",ee,oe.setState),ze("nodeDragThreshold",ne,oe.setState),ui(e,se),ui(t,ce),ui(j,ae),ui(v,pe),ui(I,fe),ui(b,Ee),null},zS={display:"none"},Bq={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},tO="react-flow__node-desc",nO="react-flow__edge-desc",qq="react-flow__aria-live",Uq=e=>e.ariaLiveMessage;function Hq({rfId:e}){const t=Qe(Uq);return he.createElement("div",{id:`${qq}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:Bq},t)}function Wq({rfId:e,disableKeyboardA11y:t}){return he.createElement(he.Fragment,null,he.createElement("div",{id:`${tO}-${e}`,style:zS},"Press enter or space to select a node.",!t&&"You can then use the arrow keys to move the node around."," Press delete to remove it and escape to cancel."," "),he.createElement("div",{id:`${nO}-${e}`,style:zS},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!t&&he.createElement(Hq,{rfId:e}))}var Cc=(e=null,t={actInsideInputWithModifier:!0})=>{const[n,r]=y.useState(!1),s=y.useRef(!1),o=y.useRef(new Set([])),[i,c]=y.useMemo(()=>{if(e!==null){const h=(Array.isArray(e)?e:[e]).filter(p=>typeof p=="string").map(p=>p.split("+")),f=h.reduce((p,g)=>p.concat(...g),[]);return[h,f]}return[[],[]]},[e]);return y.useEffect(()=>{const d=typeof document<"u"?document:null,h=(t==null?void 0:t.target)||d;if(e!==null){const f=w=>{if(s.current=w.ctrlKey||w.metaKey||w.shiftKey,(!s.current||s.current&&!t.actInsideInputWithModifier)&&n0(w))return!1;const j=GS(w.code,c);o.current.add(w[j]),VS(i,o.current,!1)&&(w.preventDefault(),r(!0))},p=w=>{if((!s.current||s.current&&!t.actInsideInputWithModifier)&&n0(w))return!1;const j=GS(w.code,c);VS(i,o.current,!0)?(r(!1),o.current.clear()):o.current.delete(w[j]),w.key==="Meta"&&o.current.clear(),s.current=!1},g=()=>{o.current.clear(),r(!1)};return h==null||h.addEventListener("keydown",f),h==null||h.addEventListener("keyup",p),window.addEventListener("blur",g),()=>{h==null||h.removeEventListener("keydown",f),h==null||h.removeEventListener("keyup",p),window.removeEventListener("blur",g)}}},[e,r]),n};function VS(e,t,n){return e.filter(r=>n||r.length===t.size).some(r=>r.every(s=>t.has(s)))}function GS(e,t){return t.includes(e)?"code":"key"}function rO(e,t,n,r){var c,d;const s=e.parentNode||e.parentId;if(!s)return n;const o=t.get(s),i=wo(o,r);return rO(o,t,{x:(n.x??0)+i.x,y:(n.y??0)+i.y,z:(((c=o[_t])==null?void 0:c.z)??0)>(n.z??0)?((d=o[_t])==null?void 0:d.z)??0:n.z??0},r)}function sO(e,t,n){e.forEach(r=>{var o;const s=r.parentNode||r.parentId;if(s&&!e.has(s))throw new Error(`Parent node ${s} not found`);if(s||n!=null&&n[r.id]){const{x:i,y:c,z:d}=rO(r,e,{...r.position,z:((o=r[_t])==null?void 0:o.z)??0},t);r.positionAbsolute={x:i,y:c},r[_t].z=d,n!=null&&n[r.id]&&(r[_t].isParent=!0)}})}function Gm(e,t,n,r){const s=new Map,o={},i=r?1e3:0;return e.forEach(c=>{var w;const d=(sr(c.zIndex)?c.zIndex:0)+(c.selected?i:0),h=t.get(c.id),f={...c,positionAbsolute:{x:c.position.x,y:c.position.y}},p=c.parentNode||c.parentId;p&&(o[p]=!0);const g=(h==null?void 0:h.type)&&(h==null?void 0:h.type)!==c.type;Object.defineProperty(f,_t,{enumerable:!1,value:{handleBounds:g||(w=h==null?void 0:h[_t])==null?void 0:w.handleBounds,z:d}}),s.set(c.id,f)}),sO(s,n,o),s}function aO(e,t={}){const{getNodes:n,width:r,height:s,minZoom:o,maxZoom:i,d3Zoom:c,d3Selection:d,fitViewOnInitDone:h,fitViewOnInit:f,nodeOrigin:p}=e(),g=t.initial&&!h&&f;if(c&&d&&(g||!t.initial)){const k=n().filter(v=>{var N;const b=t.includeHiddenNodes?v.width&&v.height:!v.hidden;return(N=t.nodes)!=null&&N.length?b&&t.nodes.some(S=>S.id===v.id):b}),j=k.every(v=>v.width&&v.height);if(k.length>0&&j){const v=nf(k,p),{x:b,y:N,zoom:S}=WL(v,r,s,t.minZoom??o,t.maxZoom??i,t.padding??.1),E=As.translate(b,N).scale(S);return typeof t.duration=="number"&&t.duration>0?c.transform(io(d,t.duration),E):c.transform(d,E),!0}}return!1}function zq(e,t){return e.forEach(n=>{const r=t.get(n.id);r&&t.set(r.id,{...r,[_t]:r[_t],selected:n.selected})}),new Map(t)}function Vq(e,t){return t.map(n=>{const r=e.find(s=>s.id===n.id);return r&&(n.selected=r.selected),n})}function Nd({changedNodes:e,changedEdges:t,get:n,set:r}){const{nodeInternals:s,edges:o,onNodesChange:i,onEdgesChange:c,hasDefaultNodes:d,hasDefaultEdges:h}=n();e!=null&&e.length&&(d&&r({nodeInternals:zq(e,s)}),i==null||i(e)),t!=null&&t.length&&(h&&r({edges:Vq(t,o)}),c==null||c(t))}const di=()=>{},Gq={zoomIn:di,zoomOut:di,zoomTo:di,getZoom:()=>1,setViewport:di,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:di,fitBounds:di,project:e=>e,screenToFlowPosition:e=>e,flowToScreenPosition:e=>e,viewportInitialized:!1},Kq=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection}),Yq=()=>{const e=Rt(),{d3Zoom:t,d3Selection:n}=Qe(Kq,Ht);return y.useMemo(()=>n&&t?{zoomIn:s=>t.scaleBy(io(n,s==null?void 0:s.duration),1.2),zoomOut:s=>t.scaleBy(io(n,s==null?void 0:s.duration),1/1.2),zoomTo:(s,o)=>t.scaleTo(io(n,o==null?void 0:o.duration),s),getZoom:()=>e.getState().transform[2],setViewport:(s,o)=>{const[i,c,d]=e.getState().transform,h=As.translate(s.x??i,s.y??c).scale(s.zoom??d);t.transform(io(n,o==null?void 0:o.duration),h)},getViewport:()=>{const[s,o,i]=e.getState().transform;return{x:s,y:o,zoom:i}},fitView:s=>aO(e.getState,s),setCenter:(s,o,i)=>{const{width:c,height:d,maxZoom:h}=e.getState(),f=typeof(i==null?void 0:i.zoom)<"u"?i.zoom:h,p=c/2-s*f,g=d/2-o*f,w=As.translate(p,g).scale(f);t.transform(io(n,i==null?void 0:i.duration),w)},fitBounds:(s,o)=>{const{width:i,height:c,minZoom:d,maxZoom:h}=e.getState(),{x:f,y:p,zoom:g}=WL(s,i,c,d,h,(o==null?void 0:o.padding)??.1),w=As.translate(f,p).scale(g);t.transform(io(n,o==null?void 0:o.duration),w)},project:s=>{const{transform:o,snapToGrid:i,snapGrid:c}=e.getState();return console.warn("[DEPRECATED] `project` is deprecated. Instead use `screenToFlowPosition`. There is no need to subtract the react flow bounds anymore! https://reactflow.dev/api-reference/types/react-flow-instance#screen-to-flow-position"),a0(s,o,i,c)},screenToFlowPosition:s=>{const{transform:o,snapToGrid:i,snapGrid:c,domNode:d}=e.getState();if(!d)return s;const{x:h,y:f}=d.getBoundingClientRect(),p={x:s.x-h,y:s.y-f};return a0(p,o,i,c)},flowToScreenPosition:s=>{const{transform:o,domNode:i}=e.getState();if(!i)return s;const{x:c,y:d}=i.getBoundingClientRect(),h=qL(s,o);return{x:h.x+c,y:h.y+d}},viewportInitialized:!0}:Gq,[t,n])};function Qi(){const e=Yq(),t=Rt(),n=y.useCallback(()=>t.getState().getNodes().map(j=>({...j})),[]),r=y.useCallback(j=>t.getState().nodeInternals.get(j),[]),s=y.useCallback(()=>{const{edges:j=[]}=t.getState();return j.map(v=>({...v}))},[]),o=y.useCallback(j=>{const{edges:v=[]}=t.getState();return v.find(b=>b.id===j)},[]),i=y.useCallback(j=>{const{getNodes:v,setNodes:b,hasDefaultNodes:N,onNodesChange:S}=t.getState(),E=v(),C=typeof j=="function"?j(E):j;if(N)b(C);else if(S){const $=C.length===0?E.map(T=>({type:"remove",id:T.id})):C.map(T=>({item:T,type:"reset"}));S($)}},[]),c=y.useCallback(j=>{const{edges:v=[],setEdges:b,hasDefaultEdges:N,onEdgesChange:S}=t.getState(),E=typeof j=="function"?j(v):j;if(N)b(E);else if(S){const C=E.length===0?v.map($=>({type:"remove",id:$.id})):E.map($=>({item:$,type:"reset"}));S(C)}},[]),d=y.useCallback(j=>{const v=Array.isArray(j)?j:[j],{getNodes:b,setNodes:N,hasDefaultNodes:S,onNodesChange:E}=t.getState();if(S){const $=[...b(),...v];N($)}else if(E){const C=v.map($=>({item:$,type:"add"}));E(C)}},[]),h=y.useCallback(j=>{const v=Array.isArray(j)?j:[j],{edges:b=[],setEdges:N,hasDefaultEdges:S,onEdgesChange:E}=t.getState();if(S)N([...b,...v]);else if(E){const C=v.map($=>({item:$,type:"add"}));E(C)}},[]),f=y.useCallback(()=>{const{getNodes:j,edges:v=[],transform:b}=t.getState(),[N,S,E]=b;return{nodes:j().map(C=>({...C})),edges:v.map(C=>({...C})),viewport:{x:N,y:S,zoom:E}}},[]),p=y.useCallback(({nodes:j,edges:v})=>{const{nodeInternals:b,getNodes:N,edges:S,hasDefaultNodes:E,hasDefaultEdges:C,onNodesDelete:$,onEdgesDelete:T,onNodesChange:I,onEdgesChange:O}=t.getState(),U=(j||[]).map(B=>B.id),P=(v||[]).map(B=>B.id),L=N().reduce((B,D)=>{const K=D.parentNode||D.parentId,G=!U.includes(D.id)&&K&&B.find(q=>q.id===K);return(typeof D.deletable=="boolean"?D.deletable:!0)&&(U.includes(D.id)||G)&&B.push(D),B},[]),F=S.filter(B=>typeof B.deletable=="boolean"?B.deletable:!0),A=F.filter(B=>P.includes(B.id));if(L||A){const B=HL(L,F),D=[...A,...B],K=D.reduce((G,H)=>(G.includes(H.id)||G.push(H.id),G),[]);if((C||E)&&(C&&t.setState({edges:S.filter(G=>!K.includes(G.id))}),E&&(L.forEach(G=>{b.delete(G.id)}),t.setState({nodeInternals:new Map(b)}))),K.length>0&&(T==null||T(D),O&&O(K.map(G=>({id:G,type:"remove"})))),L.length>0&&($==null||$(L),I)){const G=L.map(H=>({id:H.id,type:"remove"}));I(G)}}},[]),g=y.useCallback(j=>{const v=mq(j),b=v?null:t.getState().nodeInternals.get(j.id);return!v&&!b?[null,null,v]:[v?j:DS(b),b,v]},[]),w=y.useCallback((j,v=!0,b)=>{const[N,S,E]=g(j);return N?(b||t.getState().getNodes()).filter(C=>{if(!E&&(C.id===S.id||!C.positionAbsolute))return!1;const $=DS(C),T=t0($,N);return v&&T>0||T>=N.width*N.height}):[]},[]),k=y.useCallback((j,v,b=!0)=>{const[N]=g(j);if(!N)return!1;const S=t0(N,v);return b&&S>0||S>=N.width*N.height},[]);return y.useMemo(()=>({...e,getNodes:n,getNode:r,getEdges:s,getEdge:o,setNodes:i,setEdges:c,addNodes:d,addEdges:h,toObject:f,deleteElements:p,getIntersectingNodes:w,isNodeIntersecting:k}),[e,n,r,s,o,i,c,d,h,f,p,w,k])}const Xq={actInsideInputWithModifier:!1};var Zq=({deleteKeyCode:e,multiSelectionKeyCode:t})=>{const n=Rt(),{deleteElements:r}=Qi(),s=Cc(e,Xq),o=Cc(t);y.useEffect(()=>{if(s){const{edges:i,getNodes:c}=n.getState(),d=c().filter(f=>f.selected),h=i.filter(f=>f.selected);r({nodes:d,edges:h}),n.setState({nodesSelectionActive:!1})}},[s]),y.useEffect(()=>{n.setState({multiSelectionActive:o})},[o])};function Jq(e){const t=Rt();y.useEffect(()=>{let n;const r=()=>{var o,i;if(!e.current)return;const s=bk(e.current);(s.height===0||s.width===0)&&((i=(o=t.getState()).onError)==null||i.call(o,"004",$s.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 Rk={position:"absolute",width:"100%",height:"100%",top:0,left:0},Qq=(e,t)=>e.x!==t.x||e.y!==t.y||e.zoom!==t.k,Sd=e=>({x:e.x,y:e.y,zoom:e.k}),hi=(e,t)=>e.target.closest(`.${t}`),KS=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),YS=e=>{const t=e.ctrlKey&&fh()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t},eU=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),tU=({onMove:e,onMoveStart:t,onMoveEnd:n,onPaneContextMenu:r,zoomOnScroll:s=!0,zoomOnPinch:o=!0,panOnScroll:i=!1,panOnScrollSpeed:c=.5,panOnScrollMode:d=po.Free,zoomOnDoubleClick:h=!0,elementsSelectable:f,panOnDrag:p=!0,defaultViewport:g,translateExtent:w,minZoom:k,maxZoom:j,zoomActivationKeyCode:v,preventScrolling:b=!0,children:N,noWheelClassName:S,noPanClassName:E})=>{const C=y.useRef(),$=Rt(),T=y.useRef(!1),I=y.useRef(!1),O=y.useRef(null),U=y.useRef({x:0,y:0,zoom:0}),{d3Zoom:P,d3Selection:L,d3ZoomHandler:F,userSelectionActive:A}=Qe(eU,Ht),B=Cc(v),D=y.useRef(0),K=y.useRef(!1),G=y.useRef();return Jq(O),y.useEffect(()=>{if(O.current){const H=O.current.getBoundingClientRect(),q=RL().scaleExtent([k,j]).translateExtent(w),M=rr(O.current).call(q),V=As.translate(g.x,g.y).scale(Ui(g.zoom,k,j)),Z=[[0,0],[H.width,H.height]],W=q.constrain()(V,Z,w);q.transform(M,W),q.wheelDelta(YS),$.setState({d3Zoom:q,d3Selection:M,d3ZoomHandler:M.on("wheel.zoom"),transform:[W.x,W.y,W.k],domNode:O.current.closest(".react-flow")})}},[]),y.useEffect(()=>{L&&P&&(i&&!B&&!A?L.on("wheel.zoom",H=>{if(hi(H,S))return!1;H.preventDefault(),H.stopImmediatePropagation();const q=L.property("__zoom").k||1;if(H.ctrlKey&&o){const ee=jr(H),ne=YS(H),se=q*Math.pow(2,ne);P.scaleTo(L,se,ee,H);return}const M=H.deltaMode===1?20:1;let V=d===po.Vertical?0:H.deltaX*M,Z=d===po.Horizontal?0:H.deltaY*M;!fh()&&H.shiftKey&&d!==po.Vertical&&(V=H.deltaY*M,Z=0),P.translateBy(L,-(V/q)*c,-(Z/q)*c,{internal:!0});const W=Sd(L.property("__zoom")),{onViewportChangeStart:X,onViewportChange:Y,onViewportChangeEnd:J}=$.getState();clearTimeout(G.current),K.current||(K.current=!0,t==null||t(H,W),X==null||X(W)),K.current&&(e==null||e(H,W),Y==null||Y(W),G.current=setTimeout(()=>{n==null||n(H,W),J==null||J(W),K.current=!1},150))},{passive:!1}):typeof F<"u"&&L.on("wheel.zoom",function(H,q){if(!b&&H.type==="wheel"&&!H.ctrlKey||hi(H,S))return null;H.preventDefault(),F.call(this,H,q)},{passive:!1}))},[A,i,d,L,P,F,B,o,b,S,t,e,n]),y.useEffect(()=>{P&&P.on("start",H=>{var V,Z;if(!H.sourceEvent||H.sourceEvent.internal)return null;D.current=(V=H.sourceEvent)==null?void 0:V.button;const{onViewportChangeStart:q}=$.getState(),M=Sd(H.transform);T.current=!0,U.current=M,((Z=H.sourceEvent)==null?void 0:Z.type)==="mousedown"&&$.setState({paneDragging:!0}),q==null||q(M),t==null||t(H.sourceEvent,M)})},[P,t]),y.useEffect(()=>{P&&(A&&!T.current?P.on("zoom",null):A||P.on("zoom",H=>{var M;const{onViewportChange:q}=$.getState();if($.setState({transform:[H.transform.x,H.transform.y,H.transform.k]}),I.current=!!(r&&KS(p,D.current??0)),(e||q)&&!((M=H.sourceEvent)!=null&&M.internal)){const V=Sd(H.transform);q==null||q(V),e==null||e(H.sourceEvent,V)}}))},[A,P,e,p,r]),y.useEffect(()=>{P&&P.on("end",H=>{if(!H.sourceEvent||H.sourceEvent.internal)return null;const{onViewportChangeEnd:q}=$.getState();if(T.current=!1,$.setState({paneDragging:!1}),r&&KS(p,D.current??0)&&!I.current&&r(H.sourceEvent),I.current=!1,(n||q)&&Qq(U.current,H.transform)){const M=Sd(H.transform);U.current=M,clearTimeout(C.current),C.current=setTimeout(()=>{q==null||q(M),n==null||n(H.sourceEvent,M)},i?150:0)}})},[P,i,p,n,r]),y.useEffect(()=>{P&&P.filter(H=>{const q=B||s,M=o&&H.ctrlKey;if((p===!0||Array.isArray(p)&&p.includes(1))&&H.button===1&&H.type==="mousedown"&&(hi(H,"react-flow__node")||hi(H,"react-flow__edge")))return!0;if(!p&&!q&&!i&&!h&&!o||A||!h&&H.type==="dblclick"||hi(H,S)&&H.type==="wheel"||hi(H,E)&&(H.type!=="wheel"||i&&H.type==="wheel"&&!B)||!o&&H.ctrlKey&&H.type==="wheel"||!q&&!i&&!M&&H.type==="wheel"||!p&&(H.type==="mousedown"||H.type==="touchstart")||Array.isArray(p)&&!p.includes(H.button)&&H.type==="mousedown")return!1;const V=Array.isArray(p)&&p.includes(H.button)||!H.button||H.button<=1;return(!H.ctrlKey||H.type==="wheel")&&V})},[A,P,s,o,i,h,p,f,B]),he.createElement("div",{className:"react-flow__renderer",ref:O,style:Rk},N)},nU=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function rU(){const{userSelectionActive:e,userSelectionRect:t}=Qe(nU,Ht);return e&&t?he.createElement("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}function XS(e,t){const n=t.parentNode||t.parentId,r=e.find(s=>s.id===n);if(r){const s=t.position.x+t.width-r.width,o=t.position.y+t.height-r.height;if(s>0||o>0||t.position.x<0||t.position.y<0){if(r.style={...r.style},r.style.width=r.style.width??r.width,r.style.height=r.style.height??r.height,s>0&&(r.style.width+=s),o>0&&(r.style.height+=o),t.position.x<0){const i=Math.abs(t.position.x);r.position.x=r.position.x-i,r.style.width+=i,t.position.x=0}if(t.position.y<0){const i=Math.abs(t.position.y);r.position.y=r.position.y-i,r.style.height+=i,t.position.y=0}r.width=r.style.width,r.height=r.style.height}}}function sU(e,t){if(e.some(r=>r.type==="reset"))return e.filter(r=>r.type==="reset").map(r=>r.item);const n=e.filter(r=>r.type==="add").map(r=>r.item);return t.reduce((r,s)=>{const o=e.filter(c=>c.id===s.id);if(o.length===0)return r.push(s),r;const i={...s};for(const c of o)if(c)switch(c.type){case"select":{i.selected=c.selected;break}case"position":{typeof c.position<"u"&&(i.position=c.position),typeof c.positionAbsolute<"u"&&(i.positionAbsolute=c.positionAbsolute),typeof c.dragging<"u"&&(i.dragging=c.dragging),i.expandParent&&XS(r,i);break}case"dimensions":{typeof c.dimensions<"u"&&(i.width=c.dimensions.width,i.height=c.dimensions.height),typeof c.updateStyle<"u"&&(i.style={...i.style||{},...c.dimensions}),typeof c.resizing=="boolean"&&(i.resizing=c.resizing),i.expandParent&&XS(r,i);break}case"remove":return r}return r.push(i),r},n)}function aU(e,t){return sU(e,t)}const pa=(e,t)=>({id:e,type:"select",selected:t});function _i(e,t){return e.reduce((n,r)=>{const s=t.includes(r.id);return!r.selected&&s?(r.selected=!0,n.push(pa(r.id,!0))):r.selected&&!s&&(r.selected=!1,n.push(pa(r.id,!1))),n},[])}const Km=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},oU=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),oO=y.memo(({isSelecting:e,selectionMode:t=Ec.Full,panOnDrag:n,onSelectionStart:r,onSelectionEnd:s,onPaneClick:o,onPaneContextMenu:i,onPaneScroll:c,onPaneMouseEnter:d,onPaneMouseMove:h,onPaneMouseLeave:f,children:p})=>{const g=y.useRef(null),w=Rt(),k=y.useRef(0),j=y.useRef(0),v=y.useRef(),{userSelectionActive:b,elementsSelectable:N,dragging:S}=Qe(oU,Ht),E=()=>{w.setState({userSelectionActive:!1,userSelectionRect:null}),k.current=0,j.current=0},C=F=>{o==null||o(F),w.getState().resetSelectedElements(),w.setState({nodesSelectionActive:!1})},$=F=>{if(Array.isArray(n)&&(n!=null&&n.includes(2))){F.preventDefault();return}i==null||i(F)},T=c?F=>c(F):void 0,I=F=>{const{resetSelectedElements:A,domNode:B}=w.getState();if(v.current=B==null?void 0:B.getBoundingClientRect(),!N||!e||F.button!==0||F.target!==g.current||!v.current)return;const{x:D,y:K}=ka(F,v.current);A(),w.setState({userSelectionRect:{width:0,height:0,startX:D,startY:K,x:D,y:K}}),r==null||r(F)},O=F=>{const{userSelectionRect:A,nodeInternals:B,edges:D,transform:K,onNodesChange:G,onEdgesChange:H,nodeOrigin:q,getNodes:M}=w.getState();if(!e||!v.current||!A)return;w.setState({userSelectionActive:!0,nodesSelectionActive:!1});const V=ka(F,v.current),Z=A.startX??0,W=A.startY??0,X={...A,x:V.x<Z?V.x:Z,y:V.y<W?V.y:W,width:Math.abs(V.x-Z),height:Math.abs(V.y-W)},Y=M(),J=UL(B,X,K,t===Ec.Partial,!0,q),ee=HL(J,D).map(se=>se.id),ne=J.map(se=>se.id);if(k.current!==ne.length){k.current=ne.length;const se=_i(Y,ne);se.length&&(G==null||G(se))}if(j.current!==ee.length){j.current=ee.length;const se=_i(D,ee);se.length&&(H==null||H(se))}w.setState({userSelectionRect:X})},U=F=>{if(F.button!==0)return;const{userSelectionRect:A}=w.getState();!b&&A&&F.target===g.current&&(C==null||C(F)),w.setState({nodesSelectionActive:k.current>0}),E(),s==null||s(F)},P=F=>{b&&(w.setState({nodesSelectionActive:k.current>0}),s==null||s(F)),E()},L=N&&(e||b);return he.createElement("div",{className:Qt(["react-flow__pane",{dragging:S,selection:e}]),onClick:L?void 0:Km(C,g),onContextMenu:Km($,g),onWheel:Km(T,g),onMouseEnter:L?void 0:d,onMouseDown:L?I:void 0,onMouseMove:L?O:h,onMouseUp:L?U:void 0,onMouseLeave:L?P:f,ref:g,style:Rk},p,he.createElement(rU,null))});oO.displayName="Pane";function iO(e,t){const n=e.parentNode||e.parentId;if(!n)return!1;const r=t.get(n);return r?r.selected?!0:iO(r,t):!1}function ZS(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 iU(e,t,n,r){return Array.from(e.values()).filter(s=>(s.selected||s.id===r)&&(!s.parentNode||s.parentId||!iO(s,e))&&(s.draggable||t&&typeof s.draggable>"u")).map(s=>{var o,i;return{id:s.id,position:s.position||{x:0,y:0},positionAbsolute:s.positionAbsolute||{x:0,y:0},distance:{x:n.x-(((o=s.positionAbsolute)==null?void 0:o.x)??0),y:n.y-(((i=s.positionAbsolute)==null?void 0:i.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 lU(e,t){return!t||t==="parent"?t:[t[0],[t[1][0]-(e.width||0),t[1][1]-(e.height||0)]]}function lO(e,t,n,r,s=[0,0],o){const i=lU(e,e.extent||r);let c=i;const d=e.parentNode||e.parentId;if(e.extent==="parent"&&!e.expandParent)if(d&&e.width&&e.height){const p=n.get(d),{x:g,y:w}=wo(p,s).positionAbsolute;c=p&&sr(g)&&sr(w)&&sr(p.width)&&sr(p.height)?[[g+e.width*s[0],w+e.height*s[1]],[g+p.width-e.width+e.width*s[0],w+p.height-e.height+e.height*s[1]]]:c}else o==null||o("005",$s.error005()),c=i;else if(e.extent&&d&&e.extent!=="parent"){const p=n.get(d),{x:g,y:w}=wo(p,s).positionAbsolute;c=[[e.extent[0][0]+g,e.extent[0][1]+w],[e.extent[1][0]+g,e.extent[1][1]+w]]}let h={x:0,y:0};if(d){const p=n.get(d);h=wo(p,s).positionAbsolute}const f=c&&c!=="parent"?kk(t,c):t;return{position:{x:f.x-h.x,y:f.y-h.y},positionAbsolute:f}}function Ym({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 JS=(e,t,n,r)=>{const s=t.querySelectorAll(e);if(!s||!s.length)return null;const o=Array.from(s),i=t.getBoundingClientRect(),c={x:i.width*r[0],y:i.height*r[1]};return o.map(d=>{const h=d.getBoundingClientRect();return{id:d.getAttribute("data-handleid"),position:d.getAttribute("data-handlepos"),x:(h.left-i.left-c.x)/n,y:(h.top-i.top-c.y)/n,...bk(d)}})};function Yl(e,t,n){return n===void 0?n:r=>{const s=t().nodeInternals.get(e);s&&n(r,{...s})}}function i0({id:e,store:t,unselect:n=!1,nodeRef:r}){const{addSelectedNodes:s,unselectNodesAndEdges:o,multiSelectionActive:i,nodeInternals:c,onError:d}=t.getState(),h=c.get(e);if(!h){d==null||d("012",$s.error012(e));return}t.setState({nodesSelectionActive:!1}),h.selected?(n||h.selected&&i)&&(o({nodes:[h],edges:[]}),requestAnimationFrame(()=>{var f;return(f=r==null?void 0:r.current)==null?void 0:f.blur()})):s([e])}function cU(){const e=Rt();return y.useCallback(({sourceEvent:n})=>{const{transform:r,snapGrid:s,snapToGrid:o}=e.getState(),i=n.touches?n.touches[0].clientX:n.clientX,c=n.touches?n.touches[0].clientY:n.clientY,d={x:(i-r[0])/r[2],y:(c-r[1])/r[2]};return{xSnapped:o?s[0]*Math.round(d.x/s[0]):d.x,ySnapped:o?s[1]*Math.round(d.y/s[1]):d.y,...d}},[])}function Xm(e){return(t,n,r)=>e==null?void 0:e(t,r)}function cO({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:r,nodeId:s,isSelectable:o,selectNodesOnDrag:i}){const c=Rt(),[d,h]=y.useState(!1),f=y.useRef([]),p=y.useRef({x:null,y:null}),g=y.useRef(0),w=y.useRef(null),k=y.useRef({x:0,y:0}),j=y.useRef(null),v=y.useRef(!1),b=y.useRef(!1),N=y.useRef(!1),S=cU();return y.useEffect(()=>{if(e!=null&&e.current){const E=rr(e.current),C=({x:I,y:O})=>{const{nodeInternals:U,onNodeDrag:P,onSelectionDrag:L,updateNodePositions:F,nodeExtent:A,snapGrid:B,snapToGrid:D,nodeOrigin:K,onError:G}=c.getState();p.current={x:I,y:O};let H=!1,q={x:0,y:0,x2:0,y2:0};if(f.current.length>1&&A){const V=nf(f.current,K);q=_c(V)}if(f.current=f.current.map(V=>{const Z={x:I-V.distance.x,y:O-V.distance.y};D&&(Z.x=B[0]*Math.round(Z.x/B[0]),Z.y=B[1]*Math.round(Z.y/B[1]));const W=[[A[0][0],A[0][1]],[A[1][0],A[1][1]]];f.current.length>1&&A&&!V.extent&&(W[0][0]=V.positionAbsolute.x-q.x+A[0][0],W[1][0]=V.positionAbsolute.x+(V.width??0)-q.x2+A[1][0],W[0][1]=V.positionAbsolute.y-q.y+A[0][1],W[1][1]=V.positionAbsolute.y+(V.height??0)-q.y2+A[1][1]);const X=lO(V,Z,U,W,K,G);return H=H||V.position.x!==X.position.x||V.position.y!==X.position.y,V.position=X.position,V.positionAbsolute=X.positionAbsolute,V}),!H)return;F(f.current,!0,!0),h(!0);const M=s?P:Xm(L);if(M&&j.current){const[V,Z]=Ym({nodeId:s,dragItems:f.current,nodeInternals:U});M(j.current,V,Z)}},$=()=>{if(!w.current)return;const[I,O]=ML(k.current,w.current);if(I!==0||O!==0){const{transform:U,panBy:P}=c.getState();p.current.x=(p.current.x??0)-I/U[2],p.current.y=(p.current.y??0)-O/U[2],P({x:I,y:O})&&C(p.current)}g.current=requestAnimationFrame($)},T=I=>{var K;const{nodeInternals:O,multiSelectionActive:U,nodesDraggable:P,unselectNodesAndEdges:L,onNodeDragStart:F,onSelectionDragStart:A}=c.getState();b.current=!0;const B=s?F:Xm(A);(!i||!o)&&!U&&s&&((K=O.get(s))!=null&&K.selected||L()),s&&o&&i&&i0({id:s,store:c,nodeRef:e});const D=S(I);if(p.current=D,f.current=iU(O,P,D,s),B&&f.current){const[G,H]=Ym({nodeId:s,dragItems:f.current,nodeInternals:O});B(I.sourceEvent,G,H)}};if(t)E.on(".drag",null);else{const I=x8().on("start",O=>{const{domNode:U,nodeDragThreshold:P}=c.getState();P===0&&T(O),N.current=!1;const L=S(O);p.current=L,w.current=(U==null?void 0:U.getBoundingClientRect())||null,k.current=ka(O.sourceEvent,w.current)}).on("drag",O=>{var F,A;const U=S(O),{autoPanOnNodeDrag:P,nodeDragThreshold:L}=c.getState();if(O.sourceEvent.type==="touchmove"&&O.sourceEvent.touches.length>1&&(N.current=!0),!N.current){if(!v.current&&b.current&&P&&(v.current=!0,$()),!b.current){const B=U.xSnapped-(((F=p==null?void 0:p.current)==null?void 0:F.x)??0),D=U.ySnapped-(((A=p==null?void 0:p.current)==null?void 0:A.y)??0);Math.sqrt(B*B+D*D)>L&&T(O)}(p.current.x!==U.xSnapped||p.current.y!==U.ySnapped)&&f.current&&b.current&&(j.current=O.sourceEvent,k.current=ka(O.sourceEvent,w.current),C(U))}}).on("end",O=>{if(!(!b.current||N.current)&&(h(!1),v.current=!1,b.current=!1,cancelAnimationFrame(g.current),f.current)){const{updateNodePositions:U,nodeInternals:P,onNodeDragStop:L,onSelectionDragStop:F}=c.getState(),A=s?L:Xm(F);if(U(f.current,!1,!1),A){const[B,D]=Ym({nodeId:s,dragItems:f.current,nodeInternals:P});A(O.sourceEvent,B,D)}}}).filter(O=>{const U=O.target;return!O.button&&(!n||!ZS(U,`.${n}`,e))&&(!r||ZS(U,r,e))});return E.call(I),()=>{E.on(".drag",null)}}}},[e,t,n,r,o,c,s,i,S]),d}function uO(){const e=Rt();return y.useCallback(n=>{const{nodeInternals:r,nodeExtent:s,updateNodePositions:o,getNodes:i,snapToGrid:c,snapGrid:d,onError:h,nodesDraggable:f}=e.getState(),p=i().filter(N=>N.selected&&(N.draggable||f&&typeof N.draggable>"u")),g=c?d[0]:5,w=c?d[1]:5,k=n.isShiftPressed?4:1,j=n.x*g*k,v=n.y*w*k,b=p.map(N=>{if(N.positionAbsolute){const S={x:N.positionAbsolute.x+j,y:N.positionAbsolute.y+v};c&&(S.x=d[0]*Math.round(S.x/d[0]),S.y=d[1]*Math.round(S.y/d[1]));const{positionAbsolute:E,position:C}=lO(N,S,r,s,void 0,h);N.position=C,N.positionAbsolute=E}return N});o(b,!0,!1)},[])}const $i={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var Xl=e=>{const t=({id:n,type:r,data:s,xPos:o,yPos:i,xPosOrigin:c,yPosOrigin:d,selected:h,onClick:f,onMouseEnter:p,onMouseMove:g,onMouseLeave:w,onContextMenu:k,onDoubleClick:j,style:v,className:b,isDraggable:N,isSelectable:S,isConnectable:E,isFocusable:C,selectNodesOnDrag:$,sourcePosition:T,targetPosition:I,hidden:O,resizeObserver:U,dragHandle:P,zIndex:L,isParent:F,noDragClassName:A,noPanClassName:B,initialized:D,disableKeyboardA11y:K,ariaLabel:G,rfId:H,hasHandleBounds:q})=>{const M=Rt(),V=y.useRef(null),Z=y.useRef(null),W=y.useRef(T),X=y.useRef(I),Y=y.useRef(r),J=S||N||f||p||g||w,ee=uO(),ne=Yl(n,M.getState,p),se=Yl(n,M.getState,g),ce=Yl(n,M.getState,w),de=Yl(n,M.getState,k),ae=Yl(n,M.getState,j),pe=ye=>{const{nodeDragThreshold:oe}=M.getState();if(S&&(!$||!N||oe>0)&&i0({id:n,store:M,nodeRef:V}),f){const we=M.getState().nodeInternals.get(n);we&&f(ye,{...we})}},fe=ye=>{if(!n0(ye)&&!K)if(IL.includes(ye.key)&&S){const oe=ye.key==="Escape";i0({id:n,store:M,unselect:oe,nodeRef:V})}else N&&h&&Object.prototype.hasOwnProperty.call($i,ye.key)&&(M.setState({ariaLiveMessage:`Moved selected node ${ye.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~o}, y: ${~~i}`}),ee({x:$i[ye.key].x,y:$i[ye.key].y,isShiftPressed:ye.shiftKey}))};y.useEffect(()=>()=>{Z.current&&(U==null||U.unobserve(Z.current),Z.current=null)},[]),y.useEffect(()=>{if(V.current&&!O){const ye=V.current;(!D||!q||Z.current!==ye)&&(Z.current&&(U==null||U.unobserve(Z.current)),U==null||U.observe(ye),Z.current=ye)}},[O,D,q]),y.useEffect(()=>{const ye=Y.current!==r,oe=W.current!==T,we=X.current!==I;V.current&&(ye||oe||we)&&(ye&&(Y.current=r),oe&&(W.current=T),we&&(X.current=I),M.getState().updateNodeDimensions([{id:n,nodeElement:V.current,forceUpdate:!0}]))},[n,r,T,I]);const Ee=cO({nodeRef:V,disabled:O||!N,noDragClassName:A,handleSelector:P,nodeId:n,isSelectable:S,selectNodesOnDrag:$});return O?null:he.createElement("div",{className:Qt(["react-flow__node",`react-flow__node-${r}`,{[B]:N},b,{selected:h,selectable:S,parent:F,dragging:Ee}]),ref:V,style:{zIndex:L,transform:`translate(${c}px,${d}px)`,pointerEvents:J?"all":"none",visibility:D?"visible":"hidden",...v},"data-id":n,"data-testid":`rf__node-${n}`,onMouseEnter:ne,onMouseMove:se,onMouseLeave:ce,onContextMenu:de,onClick:pe,onDoubleClick:ae,onKeyDown:C?fe:void 0,tabIndex:C?0:void 0,role:C?"button":void 0,"aria-describedby":K?void 0:`${tO}-${H}`,"aria-label":G},he.createElement(kq,{value:n},he.createElement(e,{id:n,data:s,type:r,xPos:o,yPos:i,selected:h,isConnectable:E,sourcePosition:T,targetPosition:I,dragging:Ee,dragHandle:P,zIndex:L})))};return t.displayName="NodeWrapper",y.memo(t)};const uU=e=>{const t=e.getNodes().filter(n=>n.selected);return{...nf(t,e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive}};function dU({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const r=Rt(),{width:s,height:o,x:i,y:c,transformString:d,userSelectionActive:h}=Qe(uU,Ht),f=uO(),p=y.useRef(null);if(y.useEffect(()=>{var k;n||(k=p.current)==null||k.focus({preventScroll:!0})},[n]),cO({nodeRef:p}),h||!s||!o)return null;const g=e?k=>{const j=r.getState().getNodes().filter(v=>v.selected);e(k,j)}:void 0,w=k=>{Object.prototype.hasOwnProperty.call($i,k.key)&&f({x:$i[k.key].x,y:$i[k.key].y,isShiftPressed:k.shiftKey})};return he.createElement("div",{className:Qt(["react-flow__nodesselection","react-flow__container",t]),style:{transform:d}},he.createElement("div",{ref:p,className:"react-flow__nodesselection-rect",onContextMenu:g,tabIndex:n?void 0:-1,onKeyDown:n?void 0:w,style:{width:s,height:o,top:c,left:i}}))}var hU=y.memo(dU);const fU=e=>e.nodesSelectionActive,dO=({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:o,onPaneScroll:i,deleteKeyCode:c,onMove:d,onMoveStart:h,onMoveEnd:f,selectionKeyCode:p,selectionOnDrag:g,selectionMode:w,onSelectionStart:k,onSelectionEnd:j,multiSelectionKeyCode:v,panActivationKeyCode:b,zoomActivationKeyCode:N,elementsSelectable:S,zoomOnScroll:E,zoomOnPinch:C,panOnScroll:$,panOnScrollSpeed:T,panOnScrollMode:I,zoomOnDoubleClick:O,panOnDrag:U,defaultViewport:P,translateExtent:L,minZoom:F,maxZoom:A,preventScrolling:B,onSelectionContextMenu:D,noWheelClassName:K,noPanClassName:G,disableKeyboardA11y:H})=>{const q=Qe(fU),M=Cc(p),V=Cc(b),Z=V||U,W=V||$,X=M||g&&Z!==!0;return Zq({deleteKeyCode:c,multiSelectionKeyCode:v}),he.createElement(tU,{onMove:d,onMoveStart:h,onMoveEnd:f,onPaneContextMenu:o,elementsSelectable:S,zoomOnScroll:E,zoomOnPinch:C,panOnScroll:W,panOnScrollSpeed:T,panOnScrollMode:I,zoomOnDoubleClick:O,panOnDrag:!M&&Z,defaultViewport:P,translateExtent:L,minZoom:F,maxZoom:A,zoomActivationKeyCode:N,preventScrolling:B,noWheelClassName:K,noPanClassName:G},he.createElement(oO,{onSelectionStart:k,onSelectionEnd:j,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:r,onPaneMouseLeave:s,onPaneContextMenu:o,onPaneScroll:i,panOnDrag:Z,isSelecting:!!X,selectionMode:w},e,q&&he.createElement(hU,{onSelectionContextMenu:D,noPanClassName:G,disableKeyboardA11y:H})))};dO.displayName="FlowRenderer";var pU=y.memo(dO);function mU(e){return Qe(y.useCallback(n=>e?UL(n.nodeInternals,{x:0,y:0,width:n.width,height:n.height},n.transform,!0):n.getNodes(),[e]))}function gU(e){const t={input:Xl(e.input||ZL),default:Xl(e.default||o0),output:Xl(e.output||QL),group:Xl(e.group||Tk)},n={},r=Object.keys(e).filter(s=>!["input","default","output","group"].includes(s)).reduce((s,o)=>(s[o]=Xl(e[o]||o0),s),n);return{...t,...r}}const yU=({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]},wU=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),hO=e=>{const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:r,elementsSelectable:s,updateNodeDimensions:o,onError:i}=Qe(wU,Ht),c=mU(e.onlyRenderVisibleElements),d=y.useRef(),h=y.useMemo(()=>{if(typeof ResizeObserver>"u")return null;const f=new ResizeObserver(p=>{const g=p.map(w=>({id:w.target.getAttribute("data-id"),nodeElement:w.target,forceUpdate:!0}));o(g)});return d.current=f,f},[]);return y.useEffect(()=>()=>{var f;(f=d==null?void 0:d.current)==null||f.disconnect()},[]),he.createElement("div",{className:"react-flow__nodes",style:Rk},c.map(f=>{var C,$,T;let p=f.type||"default";e.nodeTypes[p]||(i==null||i("003",$s.error003(p)),p="default");const g=e.nodeTypes[p]||e.nodeTypes.default,w=!!(f.draggable||t&&typeof f.draggable>"u"),k=!!(f.selectable||s&&typeof f.selectable>"u"),j=!!(f.connectable||n&&typeof f.connectable>"u"),v=!!(f.focusable||r&&typeof f.focusable>"u"),b=e.nodeExtent?kk(f.positionAbsolute,e.nodeExtent):f.positionAbsolute,N=(b==null?void 0:b.x)??0,S=(b==null?void 0:b.y)??0,E=yU({x:N,y:S,width:f.width??0,height:f.height??0,origin:e.nodeOrigin});return he.createElement(g,{key:f.id,id:f.id,className:f.className,style:f.style,type:p,data:f.data,sourcePosition:f.sourcePosition||Le.Bottom,targetPosition:f.targetPosition||Le.Top,hidden:f.hidden,xPos:N,yPos:S,xPosOrigin:E.x,yPosOrigin:E.y,selectNodesOnDrag:e.selectNodesOnDrag,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,selected:!!f.selected,isDraggable:w,isSelectable:k,isConnectable:j,isFocusable:v,resizeObserver:h,dragHandle:f.dragHandle,zIndex:((C=f[_t])==null?void 0:C.z)??0,isParent:!!(($=f[_t])!=null&&$.isParent),noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,initialized:!!f.width&&!!f.height,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,ariaLabel:f.ariaLabel,hasHandleBounds:!!((T=f[_t])!=null&&T.handleBounds)})}))};hO.displayName="NodeRenderer";var xU=y.memo(hO);const vU=(e,t,n)=>n===Le.Left?e-t:n===Le.Right?e+t:e,bU=(e,t,n)=>n===Le.Top?e-t:n===Le.Bottom?e+t:e,QS="react-flow__edgeupdater",e_=({position:e,centerX:t,centerY:n,radius:r=10,onMouseDown:s,onMouseEnter:o,onMouseOut:i,type:c})=>he.createElement("circle",{onMouseDown:s,onMouseEnter:o,onMouseOut:i,className:Qt([QS,`${QS}-${c}`]),cx:vU(t,r,e),cy:bU(n,r,e),r,stroke:"transparent",fill:"transparent"}),kU=()=>!0;var fi=e=>{const t=({id:n,className:r,type:s,data:o,onClick:i,onEdgeDoubleClick:c,selected:d,animated:h,label:f,labelStyle:p,labelShowBg:g,labelBgStyle:w,labelBgPadding:k,labelBgBorderRadius:j,style:v,source:b,target:N,sourceX:S,sourceY:E,targetX:C,targetY:$,sourcePosition:T,targetPosition:I,elementsSelectable:O,hidden:U,sourceHandleId:P,targetHandleId:L,onContextMenu:F,onMouseEnter:A,onMouseMove:B,onMouseLeave:D,reconnectRadius:K,onReconnect:G,onReconnectStart:H,onReconnectEnd:q,markerEnd:M,markerStart:V,rfId:Z,ariaLabel:W,isFocusable:X,isReconnectable:Y,pathOptions:J,interactionWidth:ee,disableKeyboardA11y:ne})=>{const se=y.useRef(null),[ce,de]=y.useState(!1),[ae,pe]=y.useState(!1),fe=Rt(),Ee=y.useMemo(()=>`url('#${s0(V,Z)}')`,[V,Z]),ye=y.useMemo(()=>`url('#${s0(M,Z)}')`,[M,Z]);if(U)return null;const oe=st=>{var At;const{edges:ht,addSelectedEdges:ft,unselectNodesAndEdges:Be,multiSelectionActive:Kt}=fe.getState(),at=ht.find(et=>et.id===n);at&&(O&&(fe.setState({nodesSelectionActive:!1}),at.selected&&Kt?(Be({nodes:[],edges:[at]}),(At=se.current)==null||At.blur()):ft([n])),i&&i(st,at))},we=Kl(n,fe.getState,c),Ne=Kl(n,fe.getState,F),ge=Kl(n,fe.getState,A),Ae=Kl(n,fe.getState,B),Oe=Kl(n,fe.getState,D),qe=(st,ht)=>{if(st.button!==0)return;const{edges:ft,isValidConnection:Be}=fe.getState(),Kt=ht?N:b,at=(ht?L:P)||null,At=ht?"target":"source",et=Be||kU,pt=ht,jt=ft.find(Ct=>Ct.id===n);pe(!0),H==null||H(st,jt,At);const wt=Ct=>{pe(!1),q==null||q(Ct,jt,At)};GL({event:st,handleId:at,nodeId:Kt,onConnect:Ct=>G==null?void 0:G(jt,Ct),isTarget:pt,getState:fe.getState,setState:fe.setState,isValidConnection:et,edgeUpdaterType:At,onReconnectEnd:wt})},Me=st=>qe(st,!0),He=st=>qe(st,!1),rt=()=>de(!0),Ue=()=>de(!1),it=!O&&!i,Et=st=>{var ht;if(!ne&&IL.includes(st.key)&&O){const{unselectNodesAndEdges:ft,addSelectedEdges:Be,edges:Kt}=fe.getState();st.key==="Escape"?((ht=se.current)==null||ht.blur(),ft({edges:[Kt.find(At=>At.id===n)]})):Be([n])}};return he.createElement("g",{className:Qt(["react-flow__edge",`react-flow__edge-${s}`,r,{selected:d,animated:h,inactive:it,updating:ce}]),onClick:oe,onDoubleClick:we,onContextMenu:Ne,onMouseEnter:ge,onMouseMove:Ae,onMouseLeave:Oe,onKeyDown:X?Et:void 0,tabIndex:X?0:void 0,role:X?"button":"img","data-testid":`rf__edge-${n}`,"aria-label":W===null?void 0:W||`Edge from ${b} to ${N}`,"aria-describedby":X?`${nO}-${Z}`:void 0,ref:se},!ae&&he.createElement(e,{id:n,source:b,target:N,selected:d,animated:h,label:f,labelStyle:p,labelShowBg:g,labelBgStyle:w,labelBgPadding:k,labelBgBorderRadius:j,data:o,style:v,sourceX:S,sourceY:E,targetX:C,targetY:$,sourcePosition:T,targetPosition:I,sourceHandleId:P,targetHandleId:L,markerStart:Ee,markerEnd:ye,pathOptions:J,interactionWidth:ee}),Y&&he.createElement(he.Fragment,null,(Y==="source"||Y===!0)&&he.createElement(e_,{position:T,centerX:S,centerY:E,radius:K,onMouseDown:Me,onMouseEnter:rt,onMouseOut:Ue,type:"source"}),(Y==="target"||Y===!0)&&he.createElement(e_,{position:I,centerX:C,centerY:$,radius:K,onMouseDown:He,onMouseEnter:rt,onMouseOut:Ue,type:"target"})))};return t.displayName="EdgeWrapper",y.memo(t)};function jU(e){const t={default:fi(e.default||mh),straight:fi(e.bezier||Sk),step:fi(e.step||Nk),smoothstep:fi(e.step||tf),simplebezier:fi(e.simplebezier||jk)},n={},r=Object.keys(e).filter(s=>!["default","bezier"].includes(s)).reduce((s,o)=>(s[o]=fi(e[o]||mh),s),n);return{...t,...r}}function t_(e,t,n=null){const r=((n==null?void 0:n.x)||0)+t.x,s=((n==null?void 0:n.y)||0)+t.y,o=(n==null?void 0:n.width)||t.width,i=(n==null?void 0:n.height)||t.height;switch(e){case Le.Top:return{x:r+o/2,y:s};case Le.Right:return{x:r+o,y:s+i/2};case Le.Bottom:return{x:r+o/2,y:s+i};case Le.Left:return{x:r,y:s+i/2}}}function n_(e,t){return e?e.length===1||!t?e[0]:t&&e.find(n=>n.id===t)||null:null}const NU=(e,t,n,r,s,o)=>{const i=t_(n,e,t),c=t_(o,r,s);return{sourceX:i.x,sourceY:i.y,targetX:c.x,targetY:c.y}};function SU({sourcePos:e,targetPos:t,sourceWidth:n,sourceHeight:r,targetWidth:s,targetHeight:o,width:i,height:c,transform:d}){const h={x:Math.min(e.x,t.x),y:Math.min(e.y,t.y),x2:Math.max(e.x+n,t.x+s),y2:Math.max(e.y+r,t.y+o)};h.x===h.x2&&(h.x2+=1),h.y===h.y2&&(h.y2+=1);const f=_c({x:(0-d[0])/d[2],y:(0-d[1])/d[2],width:i/d[2],height:c/d[2]}),p=Math.max(0,Math.min(f.x2,h.x2)-Math.max(f.x,h.x)),g=Math.max(0,Math.min(f.y2,h.y2)-Math.max(f.y,h.y));return Math.ceil(p*g)>0}function r_(e){var r,s,o,i,c;const t=((r=e==null?void 0:e[_t])==null?void 0:r.handleBounds)||null,n=t&&(e==null?void 0:e.width)&&(e==null?void 0:e.height)&&typeof((s=e==null?void 0:e.positionAbsolute)==null?void 0:s.x)<"u"&&typeof((o=e==null?void 0:e.positionAbsolute)==null?void 0:o.y)<"u";return[{x:((i=e==null?void 0:e.positionAbsolute)==null?void 0:i.x)||0,y:((c=e==null?void 0:e.positionAbsolute)==null?void 0:c.y)||0,width:(e==null?void 0:e.width)||0,height:(e==null?void 0:e.height)||0},t,!!n]}const _U=[{level:0,isMaxLevel:!0,edges:[]}];function EU(e,t,n=!1){let r=-1;const s=e.reduce((i,c)=>{var f,p;const d=sr(c.zIndex);let h=d?c.zIndex:0;if(n){const g=t.get(c.target),w=t.get(c.source),k=c.selected||(g==null?void 0:g.selected)||(w==null?void 0:w.selected),j=Math.max(((f=w==null?void 0:w[_t])==null?void 0:f.z)||0,((p=g==null?void 0:g[_t])==null?void 0:p.z)||0,1e3);h=(d?c.zIndex:0)+(k?j:0)}return i[h]?i[h].push(c):i[h]=[c],r=h>r?h:r,i},{}),o=Object.entries(s).map(([i,c])=>{const d=+i;return{edges:c,level:d,isMaxLevel:d===r}});return o.length===0?_U:o}function CU(e,t,n){const r=Qe(y.useCallback(s=>e?s.edges.filter(o=>{const i=t.get(o.source),c=t.get(o.target);return(i==null?void 0:i.width)&&(i==null?void 0:i.height)&&(c==null?void 0:c.width)&&(c==null?void 0:c.height)&&SU({sourcePos:i.positionAbsolute||{x:0,y:0},targetPos:c.positionAbsolute||{x:0,y:0},sourceWidth:i.width,sourceHeight:i.height,targetWidth:c.width,targetHeight:c.height,width:s.width,height:s.height,transform:s.transform})}):s.edges,[e,t]));return EU(r,t,n)}const TU=({color:e="none",strokeWidth:t=1})=>he.createElement("polyline",{style:{stroke:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),RU=({color:e="none",strokeWidth:t=1})=>he.createElement("polyline",{style:{stroke:e,fill:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"}),s_={[ph.Arrow]:TU,[ph.ArrowClosed]:RU};function AU(e){const t=Rt();return y.useMemo(()=>{var s,o;return Object.prototype.hasOwnProperty.call(s_,e)?s_[e]:((o=(s=t.getState()).onError)==null||o.call(s,"009",$s.error009(e)),null)},[e])}const MU=({id:e,type:t,color:n,width:r=12.5,height:s=12.5,markerUnits:o="strokeWidth",strokeWidth:i,orient:c="auto-start-reverse"})=>{const d=AU(t);return d?he.createElement("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${r}`,markerHeight:`${s}`,viewBox:"-10 -10 20 20",markerUnits:o,orient:c,refX:"0",refY:"0"},he.createElement(d,{color:n,strokeWidth:i})):null},$U=({defaultColor:e,rfId:t})=>n=>{const r=[];return n.edges.reduce((s,o)=>([o.markerStart,o.markerEnd].forEach(i=>{if(i&&typeof i=="object"){const c=s0(i,t);r.includes(c)||(s.push({id:c,color:i.color||e,...i}),r.push(c))}}),s),[]).sort((s,o)=>s.id.localeCompare(o.id))},fO=({defaultColor:e,rfId:t})=>{const n=Qe(y.useCallback($U({defaultColor:e,rfId:t}),[e,t]),(r,s)=>!(r.length!==s.length||r.some((o,i)=>o.id!==s[i].id)));return he.createElement("defs",null,n.map(r=>he.createElement(MU,{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})))};fO.displayName="MarkerDefinitions";var LU=y.memo(fO);const OU=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}),pO=({defaultMarkerColor:e,onlyRenderVisibleElements:t,elevateEdgesOnSelect:n,rfId:r,edgeTypes:s,noPanClassName:o,onEdgeContextMenu:i,onEdgeMouseEnter:c,onEdgeMouseMove:d,onEdgeMouseLeave:h,onEdgeClick:f,onEdgeDoubleClick:p,onReconnect:g,onReconnectStart:w,onReconnectEnd:k,reconnectRadius:j,children:v,disableKeyboardA11y:b})=>{const{edgesFocusable:N,edgesUpdatable:S,elementsSelectable:E,width:C,height:$,connectionMode:T,nodeInternals:I,onError:O}=Qe(OU,Ht),U=CU(t,I,n);return C?he.createElement(he.Fragment,null,U.map(({level:P,edges:L,isMaxLevel:F})=>he.createElement("svg",{key:P,style:{zIndex:P},width:C,height:$,className:"react-flow__edges react-flow__container"},F&&he.createElement(LU,{defaultColor:e,rfId:r}),he.createElement("g",null,L.map(A=>{const[B,D,K]=r_(I.get(A.source)),[G,H,q]=r_(I.get(A.target));if(!K||!q)return null;let M=A.type||"default";s[M]||(O==null||O("011",$s.error011(M)),M="default");const V=s[M]||s.default,Z=T===No.Strict?H.target:(H.target??[]).concat(H.source??[]),W=n_(D.source,A.sourceHandle),X=n_(Z,A.targetHandle),Y=(W==null?void 0:W.position)||Le.Bottom,J=(X==null?void 0:X.position)||Le.Top,ee=!!(A.focusable||N&&typeof A.focusable>"u"),ne=A.reconnectable||A.updatable,se=typeof g<"u"&&(ne||S&&typeof ne>"u");if(!W||!X)return O==null||O("008",$s.error008(W,A)),null;const{sourceX:ce,sourceY:de,targetX:ae,targetY:pe}=NU(B,W,Y,G,X,J);return he.createElement(V,{key:A.id,id:A.id,className:Qt([A.className,o]),type:M,data:A.data,selected:!!A.selected,animated:!!A.animated,hidden:!!A.hidden,label:A.label,labelStyle:A.labelStyle,labelShowBg:A.labelShowBg,labelBgStyle:A.labelBgStyle,labelBgPadding:A.labelBgPadding,labelBgBorderRadius:A.labelBgBorderRadius,style:A.style,source:A.source,target:A.target,sourceHandleId:A.sourceHandle,targetHandleId:A.targetHandle,markerEnd:A.markerEnd,markerStart:A.markerStart,sourceX:ce,sourceY:de,targetX:ae,targetY:pe,sourcePosition:Y,targetPosition:J,elementsSelectable:E,onContextMenu:i,onMouseEnter:c,onMouseMove:d,onMouseLeave:h,onClick:f,onEdgeDoubleClick:p,onReconnect:g,onReconnectStart:w,onReconnectEnd:k,reconnectRadius:j,rfId:r,ariaLabel:A.ariaLabel,isFocusable:ee,isReconnectable:se,pathOptions:"pathOptions"in A?A.pathOptions:void 0,interactionWidth:A.interactionWidth,disableKeyboardA11y:b})})))),v):null};pO.displayName="EdgeRenderer";var IU=y.memo(pO);const PU=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function DU({children:e}){const t=Qe(PU);return he.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:t}},e)}function FU(e){const t=Qi(),n=y.useRef(!1);y.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const BU={[Le.Left]:Le.Right,[Le.Right]:Le.Left,[Le.Top]:Le.Bottom,[Le.Bottom]:Le.Top},mO=({nodeId:e,handleType:t,style:n,type:r=ma.Bezier,CustomComponent:s,connectionStatus:o})=>{var $,T,I;const{fromNode:i,handleId:c,toX:d,toY:h,connectionMode:f}=Qe(y.useCallback(O=>({fromNode:O.nodeInternals.get(e),handleId:O.connectionHandleId,toX:(O.connectionPosition.x-O.transform[0])/O.transform[2],toY:(O.connectionPosition.y-O.transform[1])/O.transform[2],connectionMode:O.connectionMode}),[e]),Ht),p=($=i==null?void 0:i[_t])==null?void 0:$.handleBounds;let g=p==null?void 0:p[t];if(f===No.Loose&&(g=g||(p==null?void 0:p[t==="source"?"target":"source"])),!i||!g)return null;const w=c?g.find(O=>O.id===c):g[0],k=w?w.x+w.width/2:(i.width??0)/2,j=w?w.y+w.height/2:i.height??0,v=(((T=i.positionAbsolute)==null?void 0:T.x)??0)+k,b=(((I=i.positionAbsolute)==null?void 0:I.y)??0)+j,N=w==null?void 0:w.position,S=N?BU[N]:null;if(!N||!S)return null;if(s)return he.createElement(s,{connectionLineType:r,connectionLineStyle:n,fromNode:i,fromHandle:w,fromX:v,fromY:b,toX:d,toY:h,fromPosition:N,toPosition:S,connectionStatus:o});let E="";const C={sourceX:v,sourceY:b,sourcePosition:N,targetX:d,targetY:h,targetPosition:S};return r===ma.Bezier?[E]=_k(C):r===ma.Step?[E]=r0({...C,borderRadius:0}):r===ma.SmoothStep?[E]=r0(C):r===ma.SimpleBezier?[E]=BL(C):E=`M${v},${b} ${d},${h}`,he.createElement("path",{d:E,fill:"none",className:"react-flow__connection-path",style:n})};mO.displayName="ConnectionLine";const qU=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function UU({containerStyle:e,style:t,type:n,component:r}){const{nodeId:s,handleType:o,nodesConnectable:i,width:c,height:d,connectionStatus:h}=Qe(qU,Ht);return!(s&&o&&c&&i)?null:he.createElement("svg",{style:e,width:c,height:d,className:"react-flow__edges react-flow__connectionline react-flow__container"},he.createElement("g",{className:Qt(["react-flow__connection",h])},he.createElement(mO,{nodeId:s,handleType:o,style:t,type:n,CustomComponent:r,connectionStatus:h})))}function a_(e,t){return y.useRef(null),Rt(),y.useMemo(()=>t(e),[e])}const gO=({nodeTypes:e,edgeTypes:t,onMove:n,onMoveStart:r,onMoveEnd:s,onInit:o,onNodeClick:i,onEdgeClick:c,onNodeDoubleClick:d,onEdgeDoubleClick:h,onNodeMouseEnter:f,onNodeMouseMove:p,onNodeMouseLeave:g,onNodeContextMenu:w,onSelectionContextMenu:k,onSelectionStart:j,onSelectionEnd:v,connectionLineType:b,connectionLineStyle:N,connectionLineComponent:S,connectionLineContainerStyle:E,selectionKeyCode:C,selectionOnDrag:$,selectionMode:T,multiSelectionKeyCode:I,panActivationKeyCode:O,zoomActivationKeyCode:U,deleteKeyCode:P,onlyRenderVisibleElements:L,elementsSelectable:F,selectNodesOnDrag:A,defaultViewport:B,translateExtent:D,minZoom:K,maxZoom:G,preventScrolling:H,defaultMarkerColor:q,zoomOnScroll:M,zoomOnPinch:V,panOnScroll:Z,panOnScrollSpeed:W,panOnScrollMode:X,zoomOnDoubleClick:Y,panOnDrag:J,onPaneClick:ee,onPaneMouseEnter:ne,onPaneMouseMove:se,onPaneMouseLeave:ce,onPaneScroll:de,onPaneContextMenu:ae,onEdgeContextMenu:pe,onEdgeMouseEnter:fe,onEdgeMouseMove:Ee,onEdgeMouseLeave:ye,onReconnect:oe,onReconnectStart:we,onReconnectEnd:Ne,reconnectRadius:ge,noDragClassName:Ae,noWheelClassName:Oe,noPanClassName:qe,elevateEdgesOnSelect:Me,disableKeyboardA11y:He,nodeOrigin:rt,nodeExtent:Ue,rfId:it})=>{const Et=a_(e,gU),st=a_(t,jU);return FU(o),he.createElement(pU,{onPaneClick:ee,onPaneMouseEnter:ne,onPaneMouseMove:se,onPaneMouseLeave:ce,onPaneContextMenu:ae,onPaneScroll:de,deleteKeyCode:P,selectionKeyCode:C,selectionOnDrag:$,selectionMode:T,onSelectionStart:j,onSelectionEnd:v,multiSelectionKeyCode:I,panActivationKeyCode:O,zoomActivationKeyCode:U,elementsSelectable:F,onMove:n,onMoveStart:r,onMoveEnd:s,zoomOnScroll:M,zoomOnPinch:V,zoomOnDoubleClick:Y,panOnScroll:Z,panOnScrollSpeed:W,panOnScrollMode:X,panOnDrag:J,defaultViewport:B,translateExtent:D,minZoom:K,maxZoom:G,onSelectionContextMenu:k,preventScrolling:H,noDragClassName:Ae,noWheelClassName:Oe,noPanClassName:qe,disableKeyboardA11y:He},he.createElement(DU,null,he.createElement(IU,{edgeTypes:st,onEdgeClick:c,onEdgeDoubleClick:h,onlyRenderVisibleElements:L,onEdgeContextMenu:pe,onEdgeMouseEnter:fe,onEdgeMouseMove:Ee,onEdgeMouseLeave:ye,onReconnect:oe,onReconnectStart:we,onReconnectEnd:Ne,reconnectRadius:ge,defaultMarkerColor:q,noPanClassName:qe,elevateEdgesOnSelect:!!Me,disableKeyboardA11y:He,rfId:it},he.createElement(UU,{style:N,type:b,component:S,containerStyle:E})),he.createElement("div",{className:"react-flow__edgelabel-renderer"}),he.createElement(xU,{nodeTypes:Et,onNodeClick:i,onNodeDoubleClick:d,onNodeMouseEnter:f,onNodeMouseMove:p,onNodeMouseLeave:g,onNodeContextMenu:w,selectNodesOnDrag:A,onlyRenderVisibleElements:L,noPanClassName:qe,noDragClassName:Ae,disableKeyboardA11y:He,nodeOrigin:rt,nodeExtent:Ue,rfId:it})))};gO.displayName="GraphView";var HU=y.memo(gO);const l0=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],da={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:l0,nodeExtent:l0,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:No.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:gq,isValidConnection:void 0},WU=()=>A6((e,t)=>({...da,setNodes:n=>{const{nodeInternals:r,nodeOrigin:s,elevateNodesOnSelect:o}=t();e({nodeInternals:Gm(n,r,s,o)})},getNodes:()=>Array.from(t().nodeInternals.values()),setEdges:n=>{const{defaultEdgeOptions:r={}}=t();e({edges:n.map(s=>({...r,...s}))})},setDefaultNodesAndEdges:(n,r)=>{const s=typeof n<"u",o=typeof r<"u",i=s?Gm(n,new Map,t().nodeOrigin,t().elevateNodesOnSelect):new Map;e({nodeInternals:i,edges:o?r:[],hasDefaultNodes:s,hasDefaultEdges:o})},updateNodeDimensions:n=>{const{onNodesChange:r,nodeInternals:s,fitViewOnInit:o,fitViewOnInitDone:i,fitViewOnInitOptions:c,domNode:d,nodeOrigin:h}=t(),f=d==null?void 0:d.querySelector(".react-flow__viewport");if(!f)return;const p=window.getComputedStyle(f),{m22:g}=new window.DOMMatrixReadOnly(p.transform),w=n.reduce((j,v)=>{const b=s.get(v.id);if(b!=null&&b.hidden)s.set(b.id,{...b,[_t]:{...b[_t],handleBounds:void 0}});else if(b){const N=bk(v.nodeElement);!!(N.width&&N.height&&(b.width!==N.width||b.height!==N.height||v.forceUpdate))&&(s.set(b.id,{...b,[_t]:{...b[_t],handleBounds:{source:JS(".source",v.nodeElement,g,h),target:JS(".target",v.nodeElement,g,h)}},...N}),j.push({id:b.id,type:"dimensions",dimensions:N}))}return j},[]);sO(s,h);const k=i||o&&!i&&aO(t,{initial:!0,...c});e({nodeInternals:new Map(s),fitViewOnInitDone:k}),(w==null?void 0:w.length)>0&&(r==null||r(w))},updateNodePositions:(n,r=!0,s=!1)=>{const{triggerNodeChanges:o}=t(),i=n.map(c=>{const d={id:c.id,type:"position",dragging:s};return r&&(d.positionAbsolute=c.positionAbsolute,d.position=c.position),d});o(i)},triggerNodeChanges:n=>{const{onNodesChange:r,nodeInternals:s,hasDefaultNodes:o,nodeOrigin:i,getNodes:c,elevateNodesOnSelect:d}=t();if(n!=null&&n.length){if(o){const h=aU(n,c()),f=Gm(h,s,i,d);e({nodeInternals:f})}r==null||r(n)}},addSelectedNodes:n=>{const{multiSelectionActive:r,edges:s,getNodes:o}=t();let i,c=null;r?i=n.map(d=>pa(d,!0)):(i=_i(o(),n),c=_i(s,[])),Nd({changedNodes:i,changedEdges:c,get:t,set:e})},addSelectedEdges:n=>{const{multiSelectionActive:r,edges:s,getNodes:o}=t();let i,c=null;r?i=n.map(d=>pa(d,!0)):(i=_i(s,n),c=_i(o(),[])),Nd({changedNodes:c,changedEdges:i,get:t,set:e})},unselectNodesAndEdges:({nodes:n,edges:r}={})=>{const{edges:s,getNodes:o}=t(),i=n||o(),c=r||s,d=i.map(f=>(f.selected=!1,pa(f.id,!1))),h=c.map(f=>pa(f.id,!1));Nd({changedNodes:d,changedEdges:h,get:t,set:e})},setMinZoom:n=>{const{d3Zoom:r,maxZoom:s}=t();r==null||r.scaleExtent([n,s]),e({minZoom:n})},setMaxZoom:n=>{const{d3Zoom:r,minZoom:s}=t();r==null||r.scaleExtent([s,n]),e({maxZoom:n})},setTranslateExtent:n=>{var r;(r=t().d3Zoom)==null||r.translateExtent(n),e({translateExtent:n})},resetSelectedElements:()=>{const{edges:n,getNodes:r}=t(),o=r().filter(c=>c.selected).map(c=>pa(c.id,!1)),i=n.filter(c=>c.selected).map(c=>pa(c.id,!1));Nd({changedNodes:o,changedEdges:i,get:t,set:e})},setNodeExtent:n=>{const{nodeInternals:r}=t();r.forEach(s=>{s.positionAbsolute=kk(s.position,n)}),e({nodeExtent:n,nodeInternals:new Map(r)})},panBy:n=>{const{transform:r,width:s,height:o,d3Zoom:i,d3Selection:c,translateExtent:d}=t();if(!i||!c||!n.x&&!n.y)return!1;const h=As.translate(r[0]+n.x,r[1]+n.y).scale(r[2]),f=[[0,0],[s,o]],p=i==null?void 0:i.constrain()(h,f,d);return i.transform(c,p),r[0]!==p.x||r[1]!==p.y||r[2]!==p.k},cancelConnection:()=>e({connectionNodeId:da.connectionNodeId,connectionHandleId:da.connectionHandleId,connectionHandleType:da.connectionHandleType,connectionStatus:da.connectionStatus,connectionStartHandle:da.connectionStartHandle,connectionEndHandle:da.connectionEndHandle}),reset:()=>e({...da})}),Object.is),Ak=({children:e})=>{const t=y.useRef(null);return t.current||(t.current=WU()),he.createElement(cq,{value:t.current},e)};Ak.displayName="ReactFlowProvider";const yO=({children:e})=>y.useContext(ef)?he.createElement(he.Fragment,null,e):he.createElement(Ak,null,e);yO.displayName="ReactFlowWrapper";const zU={input:ZL,default:o0,output:QL,group:Tk},VU={default:mh,straight:Sk,step:Nk,smoothstep:tf,simplebezier:jk},GU=[0,0],KU=[15,15],YU={x:0,y:0,zoom:1},XU={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},wO=y.forwardRef(({nodes:e,edges:t,defaultNodes:n,defaultEdges:r,className:s,nodeTypes:o=zU,edgeTypes:i=VU,onNodeClick:c,onEdgeClick:d,onInit:h,onMove:f,onMoveStart:p,onMoveEnd:g,onConnect:w,onConnectStart:k,onConnectEnd:j,onClickConnectStart:v,onClickConnectEnd:b,onNodeMouseEnter:N,onNodeMouseMove:S,onNodeMouseLeave:E,onNodeContextMenu:C,onNodeDoubleClick:$,onNodeDragStart:T,onNodeDrag:I,onNodeDragStop:O,onNodesDelete:U,onEdgesDelete:P,onSelectionChange:L,onSelectionDragStart:F,onSelectionDrag:A,onSelectionDragStop:B,onSelectionContextMenu:D,onSelectionStart:K,onSelectionEnd:G,connectionMode:H=No.Strict,connectionLineType:q=ma.Bezier,connectionLineStyle:M,connectionLineComponent:V,connectionLineContainerStyle:Z,deleteKeyCode:W="Backspace",selectionKeyCode:X="Shift",selectionOnDrag:Y=!1,selectionMode:J=Ec.Full,panActivationKeyCode:ee="Space",multiSelectionKeyCode:ne=fh()?"Meta":"Control",zoomActivationKeyCode:se=fh()?"Meta":"Control",snapToGrid:ce=!1,snapGrid:de=KU,onlyRenderVisibleElements:ae=!1,selectNodesOnDrag:pe=!0,nodesDraggable:fe,nodesConnectable:Ee,nodesFocusable:ye,nodeOrigin:oe=GU,edgesFocusable:we,edgesUpdatable:Ne,elementsSelectable:ge,defaultViewport:Ae=YU,minZoom:Oe=.5,maxZoom:qe=2,translateExtent:Me=l0,preventScrolling:He=!0,nodeExtent:rt,defaultMarkerColor:Ue="#b1b1b7",zoomOnScroll:it=!0,zoomOnPinch:Et=!0,panOnScroll:st=!1,panOnScrollSpeed:ht=.5,panOnScrollMode:ft=po.Free,zoomOnDoubleClick:Be=!0,panOnDrag:Kt=!0,onPaneClick:at,onPaneMouseEnter:At,onPaneMouseMove:et,onPaneMouseLeave:pt,onPaneScroll:jt,onPaneContextMenu:wt,children:tt,onEdgeContextMenu:Ct,onEdgeDoubleClick:Tn,onEdgeMouseEnter:Mt,onEdgeMouseMove:an,onEdgeMouseLeave:fn,onEdgeUpdate:pn,onEdgeUpdateStart:Rn,onEdgeUpdateEnd:Yt,onReconnect:An,onReconnectStart:je,onReconnectEnd:$e,reconnectRadius:De=10,edgeUpdaterRadius:lt=10,onNodesChange:Wt,onEdgesChange:is,noDragClassName:Ma="nodrag",noWheelClassName:ls="nowheel",noPanClassName:Ds="nopan",fitView:mn=!1,fitViewOptions:It,connectOnClick:Fs=!0,attributionPosition:$r,proOptions:Lr,defaultEdgeOptions:ur,elevateNodesOnSelect:Bs=!0,elevateEdgesOnSelect:cs=!1,disableKeyboardA11y:dr=!1,autoPanOnConnect:qs=!0,autoPanOnNodeDrag:me=!0,connectionRadius:Xe=20,isValidConnection:Ze,onError:Mn,style:Or,id:$n,nodeDragThreshold:Us,...hr},Nt)=>{const Ir=$n||"1";return he.createElement("div",{...hr,style:{...Or,...XU},ref:Nt,className:Qt(["react-flow",s]),"data-testid":"rf__wrapper",id:$n},he.createElement(yO,null,he.createElement(HU,{onInit:h,onMove:f,onMoveStart:p,onMoveEnd:g,onNodeClick:c,onEdgeClick:d,onNodeMouseEnter:N,onNodeMouseMove:S,onNodeMouseLeave:E,onNodeContextMenu:C,onNodeDoubleClick:$,nodeTypes:o,edgeTypes:i,connectionLineType:q,connectionLineStyle:M,connectionLineComponent:V,connectionLineContainerStyle:Z,selectionKeyCode:X,selectionOnDrag:Y,selectionMode:J,deleteKeyCode:W,multiSelectionKeyCode:ne,panActivationKeyCode:ee,zoomActivationKeyCode:se,onlyRenderVisibleElements:ae,selectNodesOnDrag:pe,defaultViewport:Ae,translateExtent:Me,minZoom:Oe,maxZoom:qe,preventScrolling:He,zoomOnScroll:it,zoomOnPinch:Et,zoomOnDoubleClick:Be,panOnScroll:st,panOnScrollSpeed:ht,panOnScrollMode:ft,panOnDrag:Kt,onPaneClick:at,onPaneMouseEnter:At,onPaneMouseMove:et,onPaneMouseLeave:pt,onPaneScroll:jt,onPaneContextMenu:wt,onSelectionContextMenu:D,onSelectionStart:K,onSelectionEnd:G,onEdgeContextMenu:Ct,onEdgeDoubleClick:Tn,onEdgeMouseEnter:Mt,onEdgeMouseMove:an,onEdgeMouseLeave:fn,onReconnect:An??pn,onReconnectStart:je??Rn,onReconnectEnd:$e??Yt,reconnectRadius:De??lt,defaultMarkerColor:Ue,noDragClassName:Ma,noWheelClassName:ls,noPanClassName:Ds,elevateEdgesOnSelect:cs,rfId:Ir,disableKeyboardA11y:dr,nodeOrigin:oe,nodeExtent:rt}),he.createElement(Fq,{nodes:e,edges:t,defaultNodes:n,defaultEdges:r,onConnect:w,onConnectStart:k,onConnectEnd:j,onClickConnectStart:v,onClickConnectEnd:b,nodesDraggable:fe,nodesConnectable:Ee,nodesFocusable:ye,edgesFocusable:we,edgesUpdatable:Ne,elementsSelectable:ge,elevateNodesOnSelect:Bs,minZoom:Oe,maxZoom:qe,nodeExtent:rt,onNodesChange:Wt,onEdgesChange:is,snapToGrid:ce,snapGrid:de,connectionMode:H,translateExtent:Me,connectOnClick:Fs,defaultEdgeOptions:ur,fitView:mn,fitViewOptions:It,onNodesDelete:U,onEdgesDelete:P,onNodeDragStart:T,onNodeDrag:I,onNodeDragStop:O,onSelectionDrag:A,onSelectionDragStart:F,onSelectionDragStop:B,noPanClassName:Ds,nodeOrigin:oe,rfId:Ir,autoPanOnConnect:qs,autoPanOnNodeDrag:me,onError:Mn,connectionRadius:Xe,isValidConnection:Ze,nodeDragThreshold:Us}),he.createElement(Pq,{onSelectionChange:L}),tt,he.createElement(dq,{proOptions:Lr,position:$r}),he.createElement(Wq,{rfId:Ir,disableKeyboardA11y:dr})))});wO.displayName="ReactFlow";const ZU=e=>({x:e.transform[0],y:e.transform[1],zoom:e.transform[2]});function xO(){return Qe(ZU,Ht)}const vO=({id:e,x:t,y:n,width:r,height:s,style:o,color:i,strokeColor:c,strokeWidth:d,className:h,borderRadius:f,shapeRendering:p,onClick:g,selected:w})=>{const{background:k,backgroundColor:j}=o||{},v=i||k||j;return he.createElement("rect",{className:Qt(["react-flow__minimap-node",{selected:w},h]),x:t,y:n,rx:f,ry:f,width:r,height:s,fill:v,stroke:c,strokeWidth:d,shapeRendering:p,onClick:g?b=>g(b,e):void 0})};vO.displayName="MiniMapNode";var JU=y.memo(vO);const QU=e=>e.nodeOrigin,eH=e=>e.getNodes().filter(t=>!t.hidden&&t.width&&t.height),Zm=e=>e instanceof Function?e:()=>e;function tH({nodeStrokeColor:e="transparent",nodeColor:t="#e2e2e2",nodeClassName:n="",nodeBorderRadius:r=5,nodeStrokeWidth:s=2,nodeComponent:o=JU,onClick:i}){const c=Qe(eH,Ht),d=Qe(QU),h=Zm(t),f=Zm(e),p=Zm(n),g=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return he.createElement(he.Fragment,null,c.map(w=>{const{x:k,y:j}=wo(w,d).positionAbsolute;return he.createElement(o,{key:w.id,x:k,y:j,width:w.width,height:w.height,style:w.style,selected:w.selected,className:p(w),color:h(w),borderRadius:r,strokeColor:f(w),strokeWidth:s,shapeRendering:g,onClick:i,id:w.id})}))}var nH=y.memo(tH);const rH=200,sH=150,aH=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?pq(nf(t,e.nodeOrigin),n):n,rfId:e.rfId}},oH="react-flow__minimap-desc";function bO({style:e,className:t,nodeStrokeColor:n="transparent",nodeColor:r="#e2e2e2",nodeClassName:s="",nodeBorderRadius:o=5,nodeStrokeWidth:i=2,nodeComponent:c,maskColor:d="rgb(240, 240, 240, 0.6)",maskStrokeColor:h="none",maskStrokeWidth:f=1,position:p="bottom-right",onClick:g,onNodeClick:w,pannable:k=!1,zoomable:j=!1,ariaLabel:v="React Flow mini map",inversePan:b=!1,zoomStep:N=10,offsetScale:S=5}){const E=Rt(),C=y.useRef(null),{boundingRect:$,viewBB:T,rfId:I}=Qe(aH,Ht),O=(e==null?void 0:e.width)??rH,U=(e==null?void 0:e.height)??sH,P=$.width/O,L=$.height/U,F=Math.max(P,L),A=F*O,B=F*U,D=S*F,K=$.x-(A-$.width)/2-D,G=$.y-(B-$.height)/2-D,H=A+D*2,q=B+D*2,M=`${oH}-${I}`,V=y.useRef(0);V.current=F,y.useEffect(()=>{if(C.current){const X=rr(C.current),Y=ne=>{const{transform:se,d3Selection:ce,d3Zoom:de}=E.getState();if(ne.sourceEvent.type!=="wheel"||!ce||!de)return;const ae=-ne.sourceEvent.deltaY*(ne.sourceEvent.deltaMode===1?.05:ne.sourceEvent.deltaMode?1:.002)*N,pe=se[2]*Math.pow(2,ae);de.scaleTo(ce,pe)},J=ne=>{const{transform:se,d3Selection:ce,d3Zoom:de,translateExtent:ae,width:pe,height:fe}=E.getState();if(ne.sourceEvent.type!=="mousemove"||!ce||!de)return;const Ee=V.current*Math.max(1,se[2])*(b?-1:1),ye={x:se[0]-ne.sourceEvent.movementX*Ee,y:se[1]-ne.sourceEvent.movementY*Ee},oe=[[0,0],[pe,fe]],we=As.translate(ye.x,ye.y).scale(se[2]),Ne=de.constrain()(we,oe,ae);de.transform(ce,Ne)},ee=RL().on("zoom",k?J:null).on("zoom.wheel",j?Y:null);return X.call(ee),()=>{X.on("zoom",null)}}},[k,j,b,N]);const Z=g?X=>{const Y=jr(X);g(X,{x:Y[0],y:Y[1]})}:void 0,W=w?(X,Y)=>{const J=E.getState().nodeInternals.get(Y);w(X,J)}:void 0;return he.createElement(vk,{position:p,style:e,className:Qt(["react-flow__minimap",t]),"data-testid":"rf__minimap"},he.createElement("svg",{width:O,height:U,viewBox:`${K} ${G} ${H} ${q}`,role:"img","aria-labelledby":M,ref:C,onClick:Z},v&&he.createElement("title",{id:M},v),he.createElement(nH,{onClick:W,nodeColor:r,nodeStrokeColor:n,nodeBorderRadius:o,nodeClassName:s,nodeStrokeWidth:i,nodeComponent:c}),he.createElement("path",{className:"react-flow__minimap-mask",d:`M${K-D},${G-D}h${H+D*2}v${q+D*2}h${-H-D*2}z
|
|
57
|
-
M${T.x},${T.y}h${T.width}v${T.height}h${-T.width}z`,fill:d,fillRule:"evenodd",stroke:h,strokeWidth:f,pointerEvents:"none"})))}bO.displayName="MiniMap";var iH=y.memo(bO);function lH(){return he.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},he.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function cH(){return he.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},he.createElement("path",{d:"M0 0h32v4.2H0z"}))}function uH(){return he.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},he.createElement("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"}))}function dH(){return he.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},he.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"}))}function hH(){return he.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},he.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"}))}const tr=({children:e,className:t,...n})=>he.createElement("button",{type:"button",className:Qt(["react-flow__controls-button",t]),...n},e);tr.displayName="ControlButton";const fH=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),kO=({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:r=!0,fitViewOptions:s,onZoomIn:o,onZoomOut:i,onFitView:c,onInteractiveChange:d,className:h,children:f,position:p="bottom-left"})=>{const g=Rt(),[w,k]=y.useState(!1),{isInteractive:j,minZoomReached:v,maxZoomReached:b}=Qe(fH,Ht),{zoomIn:N,zoomOut:S,fitView:E}=Qi();if(y.useEffect(()=>{k(!0)},[]),!w)return null;const C=()=>{N(),o==null||o()},$=()=>{S(),i==null||i()},T=()=>{E(s),c==null||c()},I=()=>{g.setState({nodesDraggable:!j,nodesConnectable:!j,elementsSelectable:!j}),d==null||d(!j)};return he.createElement(vk,{className:Qt(["react-flow__controls",h]),position:p,style:e,"data-testid":"rf__controls"},t&&he.createElement(he.Fragment,null,he.createElement(tr,{onClick:C,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:b},he.createElement(lH,null)),he.createElement(tr,{onClick:$,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:v},he.createElement(cH,null))),n&&he.createElement(tr,{className:"react-flow__controls-fitview",onClick:T,title:"fit view","aria-label":"fit view"},he.createElement(uH,null)),r&&he.createElement(tr,{className:"react-flow__controls-interactive",onClick:I,title:"toggle interactivity","aria-label":"toggle interactivity"},j?he.createElement(hH,null):he.createElement(dH,null)),f)};kO.displayName="Controls";var pH=y.memo(kO),Er;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Er||(Er={}));function mH({color:e,dimensions:t,lineWidth:n}){return he.createElement("path",{stroke:e,strokeWidth:n,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`})}function gH({color:e,radius:t}){return he.createElement("circle",{cx:t,cy:t,r:t,fill:e})}const yH={[Er.Dots]:"#91919a",[Er.Lines]:"#eee",[Er.Cross]:"#e2e2e2"},wH={[Er.Dots]:1,[Er.Lines]:1,[Er.Cross]:6},xH=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function jO({id:e,variant:t=Er.Dots,gap:n=20,size:r,lineWidth:s=1,offset:o=2,color:i,style:c,className:d}){const h=y.useRef(null),{transform:f,patternId:p}=Qe(xH,Ht),g=i||yH[t],w=r||wH[t],k=t===Er.Dots,j=t===Er.Cross,v=Array.isArray(n)?n:[n,n],b=[v[0]*f[2]||1,v[1]*f[2]||1],N=w*f[2],S=j?[N,N]:b,E=k?[N/o,N/o]:[S[0]/o,S[1]/o];return he.createElement("svg",{className:Qt(["react-flow__background",d]),style:{...c,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:h,"data-testid":"rf__background"},he.createElement("pattern",{id:p+e,x:f[0]%b[0],y:f[1]%b[1],width:b[0],height:b[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${E[0]},-${E[1]})`},k?he.createElement(gH,{color:g,radius:N/o}):he.createElement(mH,{dimensions:S,color:g,lineWidth:s})),he.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${p+e})`}))}jO.displayName="Background";var vH=y.memo(jO);function bH(e,t){return e?t==="gone"?"entering":t==="leaving"?"here":t:t==="gone"?"gone":"leaving"}function xa(e){return e!=="gone"}function o_(e,t){return e||xa(t)}function i_(e,t){return!e&&xa(t)}function Ei(e,t){const[n,r]=y.useState(()=>e?"here":"gone"),s=y.useRef(null);return y.useEffect(()=>{r(o=>bH(e,o))},[e]),y.useEffect(()=>{if(n==="leaving")return s.current=window.setTimeout(()=>r("gone"),t),()=>{s.current!=null&&window.clearTimeout(s.current)}},[n,t]),y.useEffect(()=>{n==="entering"&&r("here")},[n]),n}const NO=.2,SO=1.6;function kH(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<NO||s>SO?null:{x:n,y:r,zoom:s}}function c0({durationMs:e,documentHidden:t,reducedMotion:n=Yc()}){return t||n?!1:Number.isFinite(e)&&e>0}function Yc(){return typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches}const jH=["us-gov","global","apac","us","eu","jp","au"],NH=new RegExp(`^(?:(?:${jH.join("|")})\\.)?anthropic\\.`,"i");function Zr(e){return e.replace(NH,"")}const SH=/^(?:claude[-_]|gpt[-_]|o\d|codex[-_])/i,_H=new Set(["tool_input","tool_response"]);function _O(e,t=0){if(!e||typeof e!="object"||t>6)return null;const n=e;if(typeof n.model=="string"&&SH.test(Zr(n.model)))return n.model;for(const[r,s]of Object.entries(n)){if(_H.has(r))continue;const o=_O(s,t+1);if(o)return o}return null}function Mk(){return{agents:new Map,toolIndex:new Map,activeSubagentStack:new Map,subagentTombstones:new Map,parkedEnrichment:new Map,pendingSubagentModels:new Map,lastSeq:0,seqEpoch:null,totalEvents:0,revision:0}}function Os(e,t){return`${e}::${t}`}function el(e,t){return`${e}\0${t}`}const EH=/[0-9a-f]{16,}/i,CH=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function EO(e){return EH.test(e)||CH.test(e)}function TH(e){if(!e)return;const t=e.replace(/\\/g,"/").split("/").filter(Boolean);for(let n=t.length-1;n>=0;n--)if(!EO(t[n]))return t[n];return t[t.length-1]}function CO(){return{inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0}}function TO(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 rf(e){const t=TO(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)),e.longContext&&typeof e.longContext=="object"&&!Array.isArray(e.longContext)&&(n.longContext=rf({...e.longContext,longContext:void 0})),n}function RH(e){if(!e||typeof e!="object"||Array.isArray(e))return;const t={};for(const[n,r]of Object.entries(e)){if(!n||!r||typeof r!="object")continue;const s=r;t[n]=rf(s);const o=AH(s.speeds);o&&(t[n].bySpeed=o)}return Object.keys(t).length?t:void 0}function AH(e){if(!e||typeof e!="object"||Array.isArray(e))return;const t=Object.entries(e).filter(([n,r])=>n&&r&&typeof r=="object").map(([n,r])=>[n,rf(r)]);return t.length?Object.fromEntries(t):void 0}function RO(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),...TO(n)};for(const r of Object.values(n)){const s=RO(r,t+1);if(s)return s}return null}function $k(e){return TH(e)}function Lk(e){const t=e.agent_type??e.subagent_type;return t&&!EO(t)?t:"subagent"}function tl(e){return e.agent_id?e.agent_id:e.parent_tool_use_id?e.parent_tool_use_id:null}function Tc(e,t){!e.cwd&&t.cwd&&(e.cwd=t.cwd,e.cwdBasename=$k(t.cwd))}function AO(e,t){e.label==="session"&&t.cwd&&(e.label=$k(t.cwd)??"session")}function MO(e,t){const n=Lk(t);n&&(e.label==="subagent"||!e.label)&&(e.label=n)}function nl(e,t,n,r){const s=t;let o=e.agents.get(s);return o||(o={id:s,sessionId:t,label:"session",kind:"root",state:"active",startedAt:n,lastEventAt:n,tools:[],prompts:[],toolCount:0,childCount:0,synthetic:r,usage:CO()},e.agents.set(s,o),o)}function $O(e,t,n,r){const s=Os(t,n),o=e.agents.get(s);return o?(Tc(o,r),MO(o,r),o):null}function MH(e,t,n){var h;const r=t.session_id??"unknown",s=tl(t);if(s){const f=$O(e,r,s,t);if(f)return f}const i=((h=e.agents.get(r))==null?void 0:h.keyedSubagents)===!0?void 0:e.activeSubagentStack.get(r),c=i&&i.length>0?i[i.length-1]:null;if(c){const f=e.agents.get(Os(r,c));if(f)return Tc(f,t),f}const d=nl(e,r,n,t.hook_event_name!=="SessionStart");return Tc(d,t),AO(d,t),d}function $H(e,t,n,r){if(t==="SubagentStart"||t==="SubagentStop"||typeof n.agent_id!="string"||n.agent_id==="")return!1;const s=e.agents.get(r);return!s||s.keyedSubagents?!1:(s.keyedSubagents=!0,!0)}function LH(e,t,n,r,s){const o=Os(t,n),i=nl(e,t,s,!0);let c=e.agents.get(o);if(c)return Tc(c,r),MO(c,r),c;c={id:o,sessionId:t,label:Lk(r),kind:"subagent",parentId:i.id,state:"active",startedAt:s,tools:[],prompts:[],cwd:r.cwd,cwdBasename:$k(r.cwd),toolCount:0,childCount:0,usage:CO()},e.agents.set(o,c);const d=e.pendingSubagentModels.get(o);return d&&(c.model=d,e.pendingSubagentModels.delete(o)),i.childCount+=1,c}function OH(e,t,n){const r=e.activeSubagentStack.get(t)??[];r.includes(n)||(r.push(n),e.activeSubagentStack.set(t,r))}function LO(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 OO(){return{msgsUser:0,msgsAssistant:0,toolUses:0,toolResults:0,systemReminders:0,currentContextTokens:0,memoryFiles:[]}}function IO(e,t,n){if(typeof t.model_context_window=="number"&&t.model_context_window>0){const r=e.agents.get(n);r&&(r.contextWindow=t.model_context_window)}if(typeof t.approval_policy=="string"&&t.approval_policy){const r=e.agents.get(n);r&&(r.approvalPolicy=t.approval_policy)}if(typeof t.context_tokens=="number"&&t.context_tokens>=0){const r=e.agents.get(n);r&&(r.context={...r.context??OO(),currentContextTokens:t.context_tokens})}}const IH=6e4,l_=64;function PO(e,t,n){const r=typeof t.model=="string"?t.model:null;if(r){const o=e.agents.get(n);o&&(o.model=r)}const s=t.subagentModels;if(s&&typeof s=="object")for(const[o,i]of Object.entries(s)){if(typeof i!="string")continue;const c=Os(n,o),d=e.agents.get(c);if(d)d.model=i,e.pendingSubagentModels.delete(c);else if(e.pendingSubagentModels.delete(c),e.pendingSubagentModels.set(c,i),e.pendingSubagentModels.size>256){const h=e.pendingSubagentModels.keys().next().value;h!==void 0&&e.pendingSubagentModels.delete(h)}}}function DO(e,t,n){const r=t.context??null;if(r){const s=e.agents.get(n);if(s){const o=s.context??OO(),i=(d,h)=>typeof r[d]=="number"?r[d]:h,c=Array.isArray(r.memoryFiles)?r.memoryFiles:Array.isArray(r.claudeMdFiles)?r.claudeMdFiles:null;s.context={msgsUser:i("msgsUser",o.msgsUser),msgsAssistant:i("msgsAssistant",o.msgsAssistant),toolUses:i("toolUses",o.toolUses),toolResults:i("toolResults",o.toolResults),systemReminders:i("systemReminders",o.systemReminders),currentContextTokens:i("currentContextTokens",o.currentContextTokens),memoryFiles:c??o.memoryFiles}}}}function FO(e,t,n){const r=e.agents.get(n);if(r){const s=typeof t.sessionName=="string"?t.sessionName.trim():"",o=typeof t.sessionTitle=="string"?t.sessionTitle.trim():"";s&&(r.sessionName=s),o&&(r.sessionTitle=o);const i=r.sessionName??"";r.sessionTitle&&i&&r.sessionTitle.toLowerCase()===i.toLowerCase()&&(r.sessionTitle=void 0)}}function PH(e,t,n){const r=e.agents.get(n);if(r){const s=t.recap;s===null?r.recap=void 0:s&&typeof s.text=="string"&&s.text.trim()&&Number.isFinite(s.at)&&(r.recap={text:s.text.trim(),at:s.at})}}function BO(e,t,n){const r=e.agents.get(n),s=t.activity;!r||!s||typeof s.text!="string"||!s.text.trim()||!Number.isFinite(s.at)||r.activity&&s.at<r.activity.at||(r.activity={text:s.text.trim(),source:s.source==="said"?"said":"tool",at:s.at})}const DH=new Set(["working","blocked","done","failed","stopped"]);function qO(e,t,n){const r=e.agents.get(n);if(!r)return;const s=t.job;if(s===null){r.job=void 0;return}if(!s||typeof s!="object"||!DH.has(s.state))return;const o=i=>typeof i=="string"&&i.trim()?i.trim():void 0;r.job={id:o(s.id)??"",state:s.state,detail:o(s.detail)??"",needs:o(s.needs),suggestedReply:o(s.suggestedReply),result:o(s.result),updatedAt:Number.isFinite(s.updatedAt)?s.updatedAt:0}}function FH(e,t,n,r){const s=t.kind==="thinking"||t.kind==="text"||t.kind==="tool_use"?t.kind:null,o=typeof t.at=="number"&&Number.isFinite(t.at)?t.at:r;if(!s)return;const i=e.agents.get(n);if(i&&!(i.lastOutputAt!=null&&o<=i.lastOutputAt)){if(i.lastOutputAt=o,s!=="tool_use"){const c=(i.outputs??[]).filter(d=>o-d<IH);c.push(o),i.outputs=c.length>l_?c.slice(-l_):c}e.revision+=1}}function UO(e,t,n){const r=t.usage??null;if(r){const s=e.agents.get(n);s&&(Object.assign(s.usage,rf(r)),s.usageByModel=RH(t.usageByModel))}}const BH=256,Xd={ModelObserved:PO,UsageObserved:UO,ContextObserved:DO,SessionNamed:FO,ActivityObserved:BO,JobObserved:qO},Es=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),_d=e=>typeof e=="string"&&e.trim()!=="",qH=[["model_context_window",e=>typeof e=="number"&&e>0],["approval_policy",e=>typeof e=="string"&&e!==""],["context_tokens",e=>typeof e=="number"&&e>=0]],UH=new Set(["working","blocked","done","failed","stopped"]),c_=e=>Es(e)&&typeof e.text=="string"&&e.text.trim()!==""&&Number.isFinite(e.at);function HH(e,t){if(!e)return t;const n={...e};for(const[s,o]of Object.entries(t))o!==void 0&&(n[s]=o);const r=s=>{s in e?n[s]=e[s]:delete n[s]};for(const[s,o]of qH)o(t[s])||r(s);switch(t.hook_event_name){case"ModelObserved":typeof t.model=="string"&&t.model!==""||r("model"),(Es(e.subagentModels)||Es(t.subagentModels))&&(n.subagentModels={...Es(e.subagentModels)?e.subagentModels:{},...Es(t.subagentModels)?t.subagentModels:{}});break;case"ContextObserved":{if(!Es(t.context)){r("context");break}const s=Es(e.context)?{...e.context}:{};for(const[o,i]of Object.entries(t.context))(typeof i=="number"||Array.isArray(i))&&(s[o]=i);n.context=s;break}case"SessionNamed":{const s=_d(t.sessionName)?t.sessionName:e.sessionName??null;let o=_d(t.sessionTitle)?t.sessionTitle:e.sessionTitle??null;_d(s)&&_d(o)&&o.trim().toLowerCase()===s.trim().toLowerCase()&&(o=null),n.sessionName=s,n.sessionTitle=o;break}case"ActivityObserved":(!c_(t.activity)||c_(e.activity)&&t.activity.at<e.activity.at)&&r("activity");break;case"JobObserved":t.job===null||Es(t.job)&&UH.has(t.job.state)||r("job");break;case"UsageObserved":Es(t.usage)?t.usageByModel===void 0&&delete n.usageByModel:(r("usage"),r("usageByModel"));break}return n}function WH(e,t,n,r){if(!(t in Xd)||e.agents.has(r))return!1;const s=e.parkedEnrichment.get(r)??new Map,o=HH(s.get(t),n);for(s.delete(t),s.set(t,o),e.parkedEnrichment.delete(r),e.parkedEnrichment.set(r,s);e.parkedEnrichment.size>BH;){const i=e.parkedEnrichment.keys().next().value;if(i===void 0)break;e.parkedEnrichment.delete(i)}return!0}function zH(e,t){var r;const n=e.parkedEnrichment.get(t);if(!(!n||!e.agents.has(t))){e.parkedEnrichment.delete(t);for(const[s,o]of n)IO(e,o,t),(r=Xd[s])==null||r.call(Xd,e,o,t)}}function HO(e,t){e.parkedEnrichment.delete(t)}function qt(e,t){return Object.hasOwn(e,t)?e[t]:void 0}const VH=/^\s*<task-notification>([\s\S]*?)<\/task-notification>/;function u_(e,t){var n;return((n=new RegExp(`<${t}>([\\s\\S]*?)</${t}>`).exec(e))==null?void 0:n[1].trim())||void 0}const GH={completed:"background task finished",failed:"background task failed",killed:"background task stopped"};function sf(e){const t=VH.exec(e);if(!t)return null;const n=u_(t[1],"status");return{label:(n?qt(GH,n):void 0)??"background task update",detail:u_(t[1],"summary")}}function WO(e){return e.filter(t=>!sf(t.text))}const d_=2e3;function KH(e,t,n){for(let r=e.length-1;r>=0;r--){const s=e[r];if(s.at<t-d_)return!1;if(s.text===n&&s.at<=t+d_)return!0}return!1}function YH(e,t,n){if(KH(e,t,n))return!1;let r=e.length;for(;r>0&&e[r-1].at>t;)r--;return e.splice(r,0,{at:t,text:n}),!0}const gh=2e3;function XH(e){const t=e.prompts[e.prompts.length-1];return t&&t.at>e.startedAt?t.at:e.startedAt}const h_=["B","KB","MB","GB","TB"];function Cs(e){if(e==null||!Number.isFinite(e)||e<0)return"—";if(e===0)return"0 B";let t=e,n=0;for(;n<h_.length-1&&Number(t.toFixed(1))>=1024;)t/=1024,n++;return`${t.toFixed(1)} ${h_[n]}`}const ZH=60,JH=6e3,ar=e=>e!=null&&typeof e=="object"&&!Array.isArray(e),Dn=e=>typeof e=="string"?e:null;function QH(e){return ar(e)&&e.ccdeck_truncated===!0&&typeof e.chars=="number"&&Object.keys(e).length===2?e.chars:null}function Hi(e){const t=QH(e);if(t!=null)return`(too large to show — ${Cs(t)}, cut by the hook)`;if(Array.isArray(e)){const n=e.map(Hi);return n.some((r,s)=>r!==e[s])?n:e}if(ar(e)){let n=!1;const r={};for(const[s,o]of Object.entries(e))r[s]=Hi(o),r[s]!==o&&(n=!0);return n?r:e}return e}function _o(e,t=""){if(e==null)return"(none)";if(typeof e=="string")return e;if(typeof e!="object")return String(e);const n=Array.isArray(e),r=n?e.map((o,i)=>[String(i),o]):Object.entries(e);if(r.length===0)return n?"[]":"{}";const s=[];for(const[o,i]of r){const c=n?`${t}-`:`${t}${o}:`;if(typeof i=="string"&&i.includes(`
|
|
58
|
-
`)){s.push(c);for(const d of i.split(`
|
|
59
|
-
`))s.push(`${t} ${d}`)}else if(i!==null&&typeof i=="object"){const d=_o(i,`${t} `);d==="[]"||d==="{}"?s.push(`${c} ${d}`):s.push(c,d)}else s.push(`${c} ${i===void 0?"(none)":String(i)}`)}return s.join(`
|
|
60
|
-
`)}function eW(e){return e.lines??e.text.split(`
|
|
61
|
-
`).map(t=>({text:t}))}function zO(e,t){if(t)return{shown:e,cut:!1};const n=[];let r=0;for(const s of e){if(n.length===ZH)return{shown:n,cut:!0};const o=JH-r;if(s.text.length>o)return n.push({...s,text:`${s.text.slice(0,Math.max(o,0))}…`}),{shown:n,cut:!0};n.push(s),r+=s.text.length+1}return{shown:n,cut:!1}}function tW(e,t){return zO(e,!1).cut?t?{label:"show less",expanded:!0}:{label:"show all",expanded:!1}:null}const un=(e,t,n=!1)=>({...e?{label:e}:{},text:t,...n?{err:!0}:{}}),Fn=(e,t)=>({label:e,text:t,inline:!0}),VO=(e,t)=>({label:e,text:t.map(n=>n.text).join(`
|
|
62
|
-
`),lines:t});function nW(e,t){return[...e.split(`
|
|
63
|
-
`).map(n=>({text:`- ${n}`,tone:"del"})),...t.split(`
|
|
64
|
-
`).map(n=>({text:`+ ${n}`,tone:"add"}))]}function rW(e){if(!Array.isArray(e)||e.length===0)return null;const t=[];for(const n of e){if(!ar(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 f_(e){if(typeof e=="string")return[un(void 0,e)];if(!ar(e))return[un(void 0,_o(e))];const t=[],n=Dn(e.type);n==="create"&&t.push(Fn("result","created the file"));const r=rW(e.structuredPatch);return r&&t.push(VO("applied",r)),e.userModified===!0&&t.push(Fn("note","the user changed it before it was applied")),t.length?t:[Fn("result",n==="update"?"updated the file":"done")]}function sW(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 aW(e){if(typeof e=="string")return[un(void 0,e)];const t=ar(e)&&ar(e.file)?e.file:null,n=Dn(t==null?void 0:t.content);if(t&&n!=null){const s=[],o=Number(t.numLines),i=Number(t.totalLines),c=Number(t.startLine);return Number.isFinite(o)&&Number.isFinite(i)&&i>0&&s.push(Fn("lines",o>=i?`all ${i}`:Number.isFinite(c)?`${c}–${c+o-1} of ${i}`:`${o} of ${i}`)),s.push(un("content",n)),s}const r=ar(e)?Dn(e.type):null;return r&&r!=="text"?[Fn("result",`${/^[aeiou]/i.test(r)?"an":"a"} ${r} file`)]:[un(void 0,_o(e))]}function oW(e){if(typeof e=="string")return[un("output",e)];if(!ar(e))return[un(void 0,_o(e))];const t=Dn(e.stdout),n=Dn(e.stderr);if(t==null&&n==null)return[un(void 0,_o(e))];const r=[];return t&&r.push(un("output",t.replace(/\n$/,""))),n&&r.push(un("errors",n.replace(/\n$/,""),!0)),e.interrupted===!0&&r.push(Fn("note","interrupted before it finished")),r.length?r:[Fn("output","none")]}function iW(e,t,n){const r=Hi(t),s=Hi(n),o=ar(r)?r:null;if(o&&(e==="Edit"||e==="MultiEdit")){const i=Dn(o.file_path),c=(e==="MultiEdit"?Array.isArray(o.edits)?o.edits:[]:[o]).filter(ar).filter(d=>Dn(d.old_string)!=null&&Dn(d.new_string)!=null);if(i&&c.length){const d=[Fn("file",i)];return c.forEach((h,f)=>{const p=h.replace_all===!0?", every occurrence":"";d.push(VO(c.length>1?`change ${f+1}${p}`:`change${p}`,nW(h.old_string,h.new_string)))}),{input:d,response:f_(s)}}}if(o&&e==="Write"){const i=Dn(o.file_path),c=Dn(o.content);if(i&&c!=null)return{input:[Fn("file",i),un("content",c)],response:f_(s)}}if(o&&e==="Read"){const i=Dn(o.file_path);if(i){const c=sW(o);return{input:c?[Fn("file",i),Fn("lines",c)]:[Fn("file",i)],response:aW(s)}}}if(o&&e==="Bash"){const i=Dn(o.command);if(i!=null){const c=Dn(o.description);return{input:c?[un("command",i),Fn("why",c)]:[un("command",i)],response:oW(s)}}}return{input:[un(void 0,_o(r))],response:[un(void 0,_o(s))]}}function p_(e,t,n){const r=Hi(n);if(r==null)return"";if(typeof r=="string")return r;if(ar(r)){if(e==="Bash"&&t==="input"&&typeof r.command=="string")return r.command;if(e==="Bash"&&t==="response"&&(typeof r.stdout=="string"||typeof r.stderr=="string"))return[r.stdout,r.stderr].filter(s=>typeof s=="string"&&s!=="").join(`
|
|
65
|
-
`);if(e==="Read"&&t==="response"&&ar(r.file)&&typeof r.file.content=="string")return r.file.content}try{return JSON.stringify(r,null,2)??String(r)}catch{return String(r)}}function yh(e,t=80){const n=Hi(e);if(n==null)return"";if(typeof n=="string")return n.length>t?n.slice(0,t-1)+"…":n;try{const r=JSON.stringify(n);return r.length>t?r.slice(0,t-1)+"…":r}catch{return String(n)}}const m_=200;function GO(e,t,n){const r=t.ok===!1;t.ok=n,e&&r===n&&(e.toolErrorCount=(e.toolErrorCount??0)+(n?-1:1))}function KO(e,t){return t.agentId==null?void 0:e.agents.get(t.agentId)}function hc(e,t,n){const r=e.toolCountByName??(e.toolCountByName=new Map),s=(r.get(t)??0)+n;s>0?r.set(t,s):r.delete(t)}function lW(e,t,n){var r;return((r=e.get(t))==null?void 0:r.tools.find(s=>s.id===n))??null}const YO=25;function XO(e,t){const n=t.tools;if(n.length>m_){const r=n.splice(0,n.length-m_);for(const s of r)JO(e,t,s)}for(let r=n.length-YO-1;r>=0;r--){const s=n[r];if(s.trimmed)break;s.input=void 0,s.response=void 0,s.trimmed=!0}}function cW(e,t,n){const r=e.toolIndex.get(el(t.sessionId,n));if(r)return r;for(let s=t.tools.length-1;s>=0;s--)if(t.tools[s].id===n)return t.tools[s];return null}function ZO(e,t){for(const n of t.tools)JO(e,t,n)}function JO(e,t,n){const r=el(t.sessionId,n.id);e.toolIndex.get(r)===n&&e.toolIndex.delete(r)}function uW(e,t){const n=e.agents.get(t);if(!n)return;let r=!1;for(const s of e.agents.values()){if(s===n||s.sessionId!==t)continue;const o=s.tools.filter(i=>i.explicitSubagentId==null);if(o.length!==0){for(const i of o)s.toolCount-=1,hc(s,i.name,-1),i.ok===!1&&(s.toolErrorCount=(s.toolErrorCount??0)-1),i.agentId=n.id,n.tools.push(i),n.toolCount+=1,hc(n,i.name,1),i.ok===!1&&(n.toolErrorCount=(n.toolErrorCount??0)+1);s.tools=s.tools.filter(i=>i.explicitSubagentId!=null),r=!0}}if(r){n.tools.sort((s,o)=>s.startedAt-o.startedAt),XO(e,n);for(let s=0;s<n.tools.length-YO;s++){const o=n.tools[s];o.trimmed||(o.input=void 0,o.response=void 0,o.trimmed=!0)}}}const dW="no result reached the deck — events were dropped while the deck was paused";function QO(e,t,n,r,s){n.endedAt=r,GO(t,n,!1),n.errorPreview=n.outcomeGap?dW:s,e.toolIndex.delete(el(t.sessionId,n.id))}function hW(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(el((n==null?void 0:n.session_id)??"unknown",s))}function fW(e,t,n,r,s){const o=t.tool_use_id?cW(e,r,t.tool_use_id):null;if(o){if(t.tool_name&&o.name==="?"){o.name=t.tool_name;const h=KO(e,o);h&&(hc(h,"?",-1),hc(h,o.name,1))}o.endedAt==null&&!o.trimmed&&t.tool_input!==void 0&&(o.input=t.tool_input,o.inputPreview=yh(t.tool_input));return}const i=t.tool_use_id??`${r.id}:${r.toolCount}`,c=tl(t),d={id:i,name:t.tool_name??"?",input:t.tool_input,inputPreview:yh(t.tool_input),agentId:r.id,explicitSubagentId:c?Os(n,c):void 0,startedAt:s};r.tools.push(d),r.toolCount+=1,hc(r,d.name,1),r.state="active",e.toolIndex.set(el(r.sessionId,i),d),XO(e,r)}function pW(e,t,n,r,s){const o=t.tool_use_id;if(!o)return;const i=el(r,o);let c=e.toolIndex.get(i),d=!1;if(!c)for(const f of e.agents.values()){if(f.sessionId!==r)continue;const p=f.tools.find(g=>g.id===o);if(p){c=p,d=!0;break}}if(!c||c.outcomeApplied)return;c.outcomeApplied=!0,c.outcomeGap=void 0,c.endedAt=s,GO(KO(e,c),c,n==="PostToolUse"),c.trimmed||(c.response=t.tool_response),n==="PostToolUseFailure"?c.errorPreview=yh(t.tool_response):d&&(c.errorPreview=void 0);const h=RO(t.tool_response);h&&(c.usage=h),e.toolIndex.delete(i)}function mW(e,t,n){const r=e.agents.get(t);r&&n>(r.lastEventAt??0)&&(r.lastEventAt=n,r.reaped&&(r.reaped=!1,r.state="active",r.endedAt=void 0,r.closedAt=void 0))}function gW(e,t,n,r){const s=nl(e,n,r,!1);s.synthetic=!1,s.state="active",s.closedAt=void 0,s.endedAt=void 0,s.startedAt=Math.min(s.startedAt??r,r),Tc(s,t),AO(s,t)}function yW(e,t,n,r){for(const i of e.agents.values())i.sessionId===n&&i.kind==="subagent"&&i.state==="done"&&i.exitAt==null&&i.endedAt!=null&&i.endedAt<r&&(i.exitAt=r);const s=nl(e,n,r,!1);s.state="active",s.endedAt=void 0,s.closedAt=void 0,s.exitAt=void 0;const o=(typeof t.prompt=="string"?t.prompt:typeof t.message=="string"?t.message:"")??"";o&&YH(s.prompts,r,o)&&!s.firstPrompt&&!sf(o)&&(s.firstPrompt=yh(o,120))}function wW(e,t,n,r){const s=nl(e,n,r,!1),o=XH(s);if(r<o)return;const i=s.lastTurnEndAt;if(!(i!=null&&o>i&&r<=i+gh)){s.state="done",s.endedAt=r,s.lastTurnEndAt=r;for(const c of s.provider==="codex"?[]:e.agents.values())if(c.sessionId===n)for(const d of c.tools)d.endedAt==null&&d.explicitSubagentId==null&&QO(e,c,d,r,"the turn ended before this call returned");t==="SessionEnd"&&(s.closedAt=r),e.activeSubagentStack.delete(n)}}function xW(e,t,n,r){const s=tl(t);if(!s)return;const o=LH(e,n,s,t,r),i=Lk(t);i&&(o.label=i);const c=e.subagentTombstones.get(o.id);c!=null&&e.subagentTombstones.delete(o.id);const d=o.endedAt!=null&&r-o.endedAt<=gh,h=c!=null&&r-c<=gh;if(d||h){const f=h?c:o.endedAt;o.state="done",o.endedAt=f,o.startedAt=Math.min(o.startedAt,f),LO(e,n,s);return}o.state="active",o.startedAt=o.startedAt||r,o.exitAt=void 0,o.endedAt=void 0,OH(e,n,s)}function vW(e,t,n,r){const s=tl(t);if(!s)return;const o=$O(e,n,s,t);if(!o){for(const[i,c]of e.subagentTombstones)r-c>gh&&e.subagentTombstones.delete(i);e.subagentTombstones.set(Os(n,s),r);return}o.state="done",o.endedAt=Math.min(o.endedAt??r,r),LO(e,n,s)}const bW=["command","cmd","file_path","path","url","pattern","notebook_path"],g_=120,Jm=e=>e.length>g_?`${e.slice(0,g_-1)}…`:e;function kW(e){if(typeof e=="string")return e.trim()?Jm(e.trim()):null;if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e;for(const n of bW){const r=t[n];if(typeof r=="string"&&r.trim())return Jm(r.trim());if(Array.isArray(r)&&r.length>0&&r.every(s=>typeof s=="string")){const s=r.join(" ").trim();if(s)return Jm(s)}}return null}function jW(e){return e==="permission_prompt"?"permission":e==="agent_needs_input"?"asked":e==="idle_prompt"?"idle":null}const NW=new Set(["Notification","ModelObserved","ContextObserved","UsageObserved","SessionNamed","SessionRecapped","OutputObserved","ActivityObserved","JobObserved"]);function SW(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 _W=3e4;function EW(e,t){if(!(!e||!e.name)&&!(t-e.startedAt>_W)&&!(e.startedAt>t))return{name:e.name,preview:kW(e.input)??""}}function CW(e,t,n,r,s){if(n!=="permission")return{kind:n,message:r,since:s};const o=SW(e,t),i={kind:n,message:r,since:s};o!=null&&o.explicitSubagentId&&(i.subagentId=o.explicitSubagentId);const c=EW(o,s);return c&&(i.tool=c),i}function TW(e,t,n){if(e.kind==="idle")return!0;const r=tl(t);return r==null?!0:e.subagentId!=null&&Os(n,r)===e.subagentId}function RW(e,t,n,r){if(!NW.has(t)){const s=e.agents.get(r);s!=null&&s.waiting&&TW(s.waiting,n,r)&&(s.waiting=null)}}function AW(e,t,n,r){const s=jW(t.notification_type);if(!s)return;const o=nl(e,n,r,!1),i=typeof t.message=="string"?t.message:"",c=o.waiting;o.waiting=c&&c.kind===s&&c.message===i?{...c,since:Math.min(c.since,r)}:CW(e,n,s,i,r)}function Xc(e,t){return t&&(e.revision+=1),t}function MW(e,t,n,r,s){if(e.agents.size<=n)return!1;const o=p=>p.state==="done"&&p.endedAt!=null&&t-p.endedAt>r,i=[],c=new Map;for(const[p,g]of e.agents){if(g.parentId!=null){const w=c.get(g.parentId);w?w.push(p):c.set(g.parentId,[p])}o(g)&&i.push({id:p,endedAt:g.endedAt})}if(i.length===0)return!1;i.sort((p,g)=>p.endedAt-g.endedAt);let d=0;const h=new Set,f=p=>{const g=e.agents.get(p);g&&(ZO(e,g),e.agents.delete(p),g.kind==="root"&&HO(e,g.sessionId),h.add(g.sessionId),d++)};for(const p of i){if(e.agents.size<=n)break;if(!e.agents.has(p.id))continue;const g=(c.get(p.id)??[]).map(w=>e.agents.get(w)).filter(w=>w!=null);if(!g.some(w=>!o(w))){for(const w of g)f(w.id);f(p.id)}}if(s&&h.size>0){const p=new Set;for(const g of e.agents.values())p.add(g.sessionId);for(const g of h)p.has(g)||s(g)}return Xc(e,d>0)}function $W(e,t,n,r,s){const o=new Map;for(const[f,p]of e.agents){let g=o.get(p.sessionId);g||(g={ids:[],endedAt:0,live:!1,closed:!1},o.set(p.sessionId,g)),g.ids.push(f),p.kind==="root"&&p.closedAt!=null&&(g.closed=!0),p.state==="done"&&p.endedAt!=null?g.endedAt=Math.max(g.endedAt,p.endedAt):g.live=!0}const i=[...o].filter(([,f])=>!f.live&&f.endedAt>0&&t-f.endedAt>r).sort(([,f],[,p])=>f.closed===p.closed?f.endedAt-p.endedAt:f.closed?-1:1);let d=[...o.values()].filter(f=>!f.live).length-n;if(d<=0)return!1;let h=!1;for(const[f,p]of i){if(d<=0)break;for(const w of p.ids){const k=e.agents.get(w);k&&ZO(e,k),e.agents.delete(w)}HO(e,f);const g=Os(f,"");for(const w of e.pendingSubagentModels.keys())w.startsWith(g)&&e.pendingSubagentModels.delete(w);s==null||s(f),d--,h=!0}return Xc(e,h)}function LW(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 Xc(e,t)}function OW(e,t,n){let r=!1;for(const s of e.agents.values()){if(s.provider==="codex")continue;const o=e.agents.get(s.sessionId),i=(o==null?void 0:o.lastEventAt)??(o==null?void 0:o.startedAt);for(const c of s.tools){const d=Math.max(c.startedAt,i??c.startedAt);c.endedAt==null&&t-d>n&&(QO(e,s,c,d,"session ended before this call returned"),r=!0)}}return Xc(e,r)}const y_=90*6e4;function IW(e,t,n){let r=!1;for(const s of e.agents.values()){if(s.kind!=="root")continue;const o=s.lastEventAt??s.startedAt;if(!(t-o<=n)){s.waiting&&(s.waiting=null,r=!0),s.closedAt==null&&(s.closedAt=o),s.state==="active"&&(s.state="done",s.endedAt=o,s.reaped=!0,r=!0);for(const i of e.agents.values())i.sessionId!==s.sessionId||i.kind==="root"||i.state!=="active"||(i.state="done",i.endedAt=o,r=!0);e.activeSubagentStack.delete(s.sessionId)}}return Xc(e,r)}function Rc(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 eI(e,t){const n=t.epoch??null;if(n!==null&&n!==e.seqEpoch)e.seqEpoch=n,e.lastSeq=0;else if(t.seq<=e.lastSeq)return e;const r=t.payload??{},s=t.receivedAt,o=r.hook_event_name??"Unknown";if(o==="__clear")return{...Mk(),lastSeq:t.seq,seqEpoch:e.seqEpoch,revision:e.revision+1};e.totalEvents+=1,e.lastSeq=t.seq,e.revision+=1;const i=r.session_id??"unknown";if(RW(e,o,r,i),o!=="JobObserved"&&mW(e,i,s),IO(e,r,i),WH(e,o,r,i))return e;switch(o){case"ModelObserved":return PO(e,r,i),e;case"ContextObserved":return DO(e,r,i),e;case"SessionNamed":return FO(e,r,i),e;case"SessionRecapped":return PH(e,r,i),e;case"ActivityObserved":return BO(e,r,i),e;case"JobObserved":return qO(e,r,i),e;case"OutputObserved":return FH(e,r,i,s),e;case"UsageObserved":return UO(e,r,i),e}const c=MH(e,r,s);zH(e,i),$H(e,o,r,i)&&uW(e,i),c.provider||(c.provider=r.provider==="codex"?"codex":"claude");const d=_O(r),h=tl(r),f=h?Os(i,h):i;switch(d&&c.id===f&&(c.model=d),o){case"SessionStart":gW(e,r,i,s);break;case"UserPromptSubmit":yW(e,r,i,s);break;case"PreToolUse":fW(e,r,i,c,s);break;case"PostToolUse":case"PostToolUseFailure":pW(e,r,o,i,s);break;case"SubagentStart":xW(e,r,i,s);break;case"SubagentStop":vW(e,r,i,s);break;case"Stop":case"SessionEnd":wW(e,o,i,s);break;case"Notification":AW(e,r,i,s);break}return e}const PW={input:2,output:10,cacheRead:.2,cacheWrite:2.5,cacheWrite1h:4},DW=[{match:/^claude[-_](fable|mythos)[-_]5[-_.]1\b(?![-_.]\d{1,7}(?!\d))/i,rates:{input:10,output:50,cacheRead:.25,cacheWrite:12.5,cacheWrite1h:20}},{match:/^claude[-_](fable|mythos)[-_]5\b(?![-_.]\d{1,7}(?!\d))/i,rates:{input:10,output:50,cacheRead:1,cacheWrite:12.5,cacheWrite1h:20}},{match:/^claude[-_]opus[-_]5[-_.]5\b(?![-_.]\d{1,7}(?!\d))/i,rates:{input:4,output:20,cacheRead:.2,cacheWrite:5,cacheWrite1h:8}},{match:/^claude[-_]opus[-_]5\b(?![-_.]\d{1,7}(?!\d))/i,rates:{input:5,output:25,cacheRead:.5,cacheWrite:6.25,cacheWrite1h:10}},{match:/^claude[-_]sonnet[-_]5[-_.]5\b(?![-_.]\d{1,7}(?!\d))/i,rates:{input:2,output:10,cacheRead:.1,cacheWrite:2.5,cacheWrite1h:4}},{match:/^claude[-_]haiku[-_]5[-_.]5\b(?![-_.]\d{1,7}(?!\d))/i,rates:{input:.1,output:.5,cacheRead:.01,cacheWrite:.125,cacheWrite1h:.2}},{match:/^claude[-_]sonnet[-_]5\b(?![-_.]\d{1,7}(?!\d))/i,rates:PW},{match:/^claude[-_]opus[-_]4[-_.](?:5|6|7|8)\b(?![-_.]\d{1,7}(?!\d))/i,rates:{input:5,output:25,cacheRead:.5,cacheWrite:6.25,cacheWrite1h:10}},{match:/^claude[-_]opus[-_]4(?:[-_.]1)?\b(?![-_.]\d{1,7}(?!\d))/i,rates:{input:15,output:75,cacheRead:1.5,cacheWrite:18.75,cacheWrite1h:30}},{match:/^claude[-_]sonnet[-_]4[-_.](?:5|6)\b(?![-_.]\d{1,7}(?!\d))/i,rates:{input:3,output:15,cacheRead:.3,cacheWrite:3.75,cacheWrite1h:6}},{match:/^claude[-_]sonnet[-_]4\b(?![-_.]\d{1,7}(?!\d))/i,rates:{input:3,output:15,cacheRead:.3,cacheWrite:3.75,cacheWrite1h:6}},{match:/^claude[-_]haiku[-_]4[-_.]5\b(?![-_.]\d{1,7}(?!\d))/i,rates:{input:1,output:5,cacheRead:.1,cacheWrite:1.25,cacheWrite1h:2}},{match:/^claude[-_]haiku[-_]3[-_.]5\b(?![-_.]\d{1,7}(?!\d))/i,rates:{input:.8,output:4,cacheRead:.08,cacheWrite:1,cacheWrite1h:1.6}},{match:/^gpt[-_]6[-_]astra\b(?![-_][A-Za-z])/i,rates:{input:10,output:50,cacheRead:1,cacheWrite:12.5}},{match:/^gpt[-_]6[-_.]1[-_]sol\b(?![-_][A-Za-z])/i,rates:{input:2,output:10,cacheRead:.1,cacheWrite:2.5}},{match:/^gpt[-_]6[-_]sol\b(?![-_][A-Za-z])/i,rates:{input:2,output:10,cacheRead:.2,cacheWrite:2.5}},{match:/^gpt[-_]6[-_]luna\b(?![-_][A-Za-z])/i,rates:{input:.1,output:.5,cacheRead:.01,cacheWrite:.125}},{match:/^gpt[-_]5[-_.]6[-_]cyber\b(?![-_][A-Za-z])/i,rates:{input:12.5,output:75,cacheRead:1.25,cacheWrite:15.625}},{match:/^gpt[-_]5[-_.]6[-_]luna\b(?![-_][A-Za-z])/i,rates:{input:.2,output:1.2,cacheRead:.02,cacheWrite:.25}},{match:/^gpt[-_]5[-_.]6[-_]terra\b(?![-_][A-Za-z])/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[-_]chat[-_]latest$/i,rates:{input:1.75,output:14,cacheRead:.175,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}}],FW=[{match:/^claude[-_]opus[-_]5[-_.]5\b(?![-_.]\d{1,7}(?!\d))/i,rates:{input:8,output:40,cacheRead:.4,cacheWrite:10,cacheWrite1h:16}},{match:/^claude[-_]opus[-_]5\b(?![-_.]\d{1,7}(?!\d))/i,rates:{input:10,output:50,cacheRead:1,cacheWrite:12.5,cacheWrite1h:20}},{match:/^claude[-_]opus[-_]4[-_.]8\b(?![-_.]\d{1,7}(?!\d))/i,rates:{input:10,output:50,cacheRead:1,cacheWrite:12.5,cacheWrite1h:20}}];function BW(e){return e?/^(?:gpt[-_]|codex[-_]|o\d)/i.test(e):!1}function Ta(e,t=Date.now(),n=Na){if(!e)return null;const r=qW.get(n);if(!r)return null;const s=Zr(e);for(const o of r)if(o.match.test(s))return typeof o.rates=="function"?o.rates(t):o.rates;return null}const Na="standard",qW=new Map([[Na,DW],["fast",FW]]);function fc(e,t){return e*t/1e6}function tI(e,t){const n=Math.max(0,e.cacheCreate1hTokens??0),r=Math.max(0,e.cacheCreate5mTokens??0),s=Math.max(0,e.cacheCreateTokens-n-r),o=r+s,i=t.cacheWrite1h??t.cacheWrite;return{tokens5m:o,tokens1h:n,usd5m:fc(o,t.cacheWrite),usd1h:fc(n,i)}}function nI(e,t,n=Date.now()){if(!BW(t))return e.inputTokens;const r=Ta(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 af(e,t,n=Date.now()){const r={input:0,output:0,cacheRead:0,cacheWrite:0,total:0};for(const s of of(e)){const o=Ac(s.usage,t,s.speed,n);r.input+=o.input,r.output+=o.output,r.cacheRead+=o.cacheRead,r.cacheWrite+=o.cacheWrite,r.total+=o.total}return r}function Ac(e,t,n,r=Date.now()){const s=Ta(t,r,n);if(!s)return{input:0,output:0,cacheRead:0,cacheWrite:0,total:0};const o={input:0,output:0,cacheRead:0,cacheWrite:0,total:0};for(const i of rI(e,t)){const c=i.usage,d=sI(s,i.long);o.input+=fc(nI(c,t,r),d.input),o.output+=fc(c.outputTokens,d.output),o.cacheRead+=fc(c.cacheReadTokens,d.cacheRead);const h=tI(c,d);o.cacheWrite+=h.usd5m+h.usd1h}return o.total=o.input+o.output+o.cacheRead+o.cacheWrite,o}function rI(e,t){if(!e.longContext||!/^claude[-_]haiku[-_]5[-_.]5\b(?![-_.]\d{1,7}(?!\d))/i.test(Zr(t??"")))return[{usage:e,long:!1}];const n=e.longContext;return[{usage:Ok(e,[n]),long:!1},{usage:n,long:!0}]}function sI(e,t){return t?{input:e.input*5,output:e.output*5,cacheRead:e.cacheRead*5,cacheWrite:e.cacheWrite*5,...e.cacheWrite1h===void 0?{}:{cacheWrite1h:e.cacheWrite1h*5}}:e}function of(e){const t=e.bySpeed?Object.entries(e.bySpeed):[];return t.length===0?[{speed:Na,usage:e}]:[{speed:Na,usage:Ok(e,t.map(([,n])=>n))},...t.map(([n,r])=>({speed:n,usage:r}))]}function Ok(e,t){const n=o=>t.reduce((i,c)=>i+(o(c)??0),0),r=o=>Math.max(0,(o(e)??0)-n(o)),s={inputTokens:r(o=>o.inputTokens),outputTokens:r(o=>o.outputTokens),cacheReadTokens:r(o=>o.cacheReadTokens),cacheCreateTokens:r(o=>o.cacheCreateTokens)};return(e.cacheCreate1hTokens!==void 0||e.cacheCreate5mTokens!==void 0)&&(s.cacheCreate1hTokens=r(o=>o.cacheCreate1hTokens),s.cacheCreate5mTokens=r(o=>o.cacheCreate5mTokens)),e.reasoningOutputTokens!==void 0&&(s.reasoningOutputTokens=e.reasoningOutputTokens),e.longContext&&(s.longContext=Ok(e.longContext,t.flatMap(o=>o.longContext?[o.longContext]:[]))),s}const Ls="not priced";function pc(e,t,n){const r=e.toFixed(t);return Number(r)<n?r:null}function Ye(e){if(e<=0)return"—";if(e<.005)return"<1¢";if(e<1){const t=pc(e*100,e<.1?1:0,100);if(t!==null)return`${t}¢`}if(e<100){const t=pc(e,2,100);if(t!==null)return`$${t}`}if(e<1e4){const t=pc(e,0,1e4);if(t!==null)return`$${t}`}return`$${(e/1e3).toFixed(1)}k`}function Ik(e,t){if(e<=0||t<10)return null;const n=e/t,r=n*60;return r>=.01?`${Ye(r)}/min`:`${Ye(n*3600)}/hr`}function u0(e,t){const n={inputTokens:e.inputTokens+t.inputTokens,outputTokens:e.outputTokens+t.outputTokens,cacheReadTokens:e.cacheReadTokens+t.cacheReadTokens,cacheCreateTokens:e.cacheCreateTokens+t.cacheCreateTokens};if((e.cacheCreate1hTokens!==void 0||e.cacheCreate5mTokens!==void 0||t.cacheCreate1hTokens!==void 0||t.cacheCreate5mTokens!==void 0)&&(n.cacheCreate1hTokens=(e.cacheCreate1hTokens??0)+(t.cacheCreate1hTokens??0),n.cacheCreate5mTokens=(e.cacheCreate5mTokens??0)+(t.cacheCreate5mTokens??0)),(e.reasoningOutputTokens!==void 0||t.reasoningOutputTokens!==void 0)&&(n.reasoningOutputTokens=(e.reasoningOutputTokens??0)+(t.reasoningOutputTokens??0)),e.longContext||t.longContext){const r={inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0};n.longContext=u0(e.longContext??r,t.longContext??r)}if(e.bySpeed||t.bySpeed){const r=new Map(Object.entries(e.bySpeed??{}));for(const[s,o]of Object.entries(t.bySpeed??{})){const i=r.get(s);r.set(s,i?u0(i,o):o)}n.bySpeed=Object.fromEntries(r)}return n}function UW(e,t){let n=0,r=0,s=0,o=0,i=0,c=0;for(const p of t)n+=p.inputTokens,r+=p.outputTokens,s+=p.cacheReadTokens,o+=p.cacheCreateTokens,i+=p.cacheCreate1hTokens??0,c+=p.cacheCreate5mTokens??0;const d=(p,g)=>Math.max(0,p-g),h={inputTokens:d(e.inputTokens,n),outputTokens:d(e.outputTokens,r),cacheReadTokens:d(e.cacheReadTokens,s),cacheCreateTokens:d(e.cacheCreateTokens,o)};return(e.cacheCreate1hTokens!==void 0||e.cacheCreate5mTokens!==void 0)&&(h.cacheCreate1hTokens=d(e.cacheCreate1hTokens??0,i),h.cacheCreate5mTokens=d(e.cacheCreate5mTokens??0,c)),h.inputTokens+h.outputTokens+h.cacheReadTokens+h.cacheCreateTokens>0?h:null}function Zc(e){const t=e.usageByModel,n=t?Object.keys(t):[];if(!t||n.length===0)return[{model:e.model,usage:e.usage}];const r=n.map(o=>({model:o,usage:t[o]})),s=UW(e.usage,r.map(o=>o.usage));if(s){const o=r.findIndex(i=>i.model===e.model);o>=0?r[o]={model:r[o].model,usage:u0(r[o].usage,s)}:r.push({model:e.model,usage:s})}return r}function En(e,t=Date.now()){const n={input:0,output:0,cacheRead:0,cacheWrite:0,total:0};for(const r of Zc(e)){const s=af(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 Mc(e,t=Date.now()){let n=0;for(const r of Zc(e))for(const s of of(r.usage))Ta(r.model,t,s.speed)==null&&(n+=s.usage.inputTokens+s.usage.outputTokens);return n}function aI(e){const t=[];for(const n of Zc(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 Pk(e){return aI(e).filter(t=>t!==e.model)}function w_(e,t){if(!e.bySpeed)return Qm(e,t,Na);const n=of(e).filter(r=>r.speed!==Na||oI(r.usage));return n.length===1?Qm(n[0].usage,t,n[0].speed):[...n.map(r=>Qm(r.usage,t,r.speed)),"═════════════════════════════════════════",`all speeds = ${Ye(af(e,t).total)}`].join(`
|
|
66
|
-
`)}function oI(e){return e.inputTokens+e.outputTokens+e.cacheReadTokens+e.cacheCreateTokens>0}function Qm(e,t,n){const r=rI(e,t).filter(s=>oI(s.usage));return e.longContext&&r.some(s=>s.long)?[...r.map(s=>x_(s.usage,t,n,s.long)),`all context tiers = ${Ye(Ac(e,t,n).total)}`].join(`
|
|
67
|
-
`):x_(e,t,n,!1)}function x_(e,t,n,r){const s=Ta(t,Date.now(),n),o=s?sI(s,r):null,i=r?" · prompt >100K":"",c=(n===Na?`model: ${t}`:`model: ${t} · ${n}`)+i;if(!o)return`${c}
|
|
68
|
-
no published rate in this build — the tokens are counted, the dollars are not`;const d=j=>j.toLocaleString(),h=j=>`$${j}/MTok`,f=Ac(r?{...e,longContext:e}:{...e,longContext:void 0},t,n),p=tI(e,o),g=p.tokens1h>0?[`cache w5m${d(p.tokens5m).padStart(14)} × ${h(o.cacheWrite).padEnd(11)} = ${Ye(p.usd5m)}`,`cache w1h${d(p.tokens1h).padStart(14)} × ${h(o.cacheWrite1h??o.cacheWrite).padEnd(11)} = ${Ye(p.usd1h)}`]:[`cache w ${d(p.tokens5m).padStart(14)} × ${h(o.cacheWrite).padEnd(11)} = ${Ye(p.usd5m)}`],w=nI(e,t),k=w===e.inputTokens?"input":"uncached";return[c,`${k.padEnd(9)}${d(w).padStart(14)} × ${h(o.input).padEnd(11)} = ${Ye(f.input)}`,`output ${d(e.outputTokens).padStart(14)} × ${h(o.output).padEnd(11)} = ${Ye(f.output)}`,`cache r ${d(e.cacheReadTokens).padStart(14)} × ${h(o.cacheRead).padEnd(11)} = ${Ye(f.cacheRead)}`,...g,"─────────────────────────────────────────",`total = ${Ye(f.total)}`].join(`
|
|
69
|
-
`)}function v_(e){const t=Zc(e),[n]=t;return t.length<=1?w_(n.usage,n.model):[...t.map(r=>w_(r.usage,r.model)),"═════════════════════════════════════════",`all models = ${Ye(En(e).total)}`].join(`
|
|
70
|
-
`)}function HW(e){if(!e.model)return null;const t=Ta(e.model),n=En(e),r=Mc(e);if(!t&&n.total<=0)return e.usage.inputTokens+e.usage.outputTokens<=0?null:{kind:"unpriced",tt:v_(e)};if(n.total<=0)return null;const s=Math.max(0,((e.endedAt??Date.now())-e.startedAt)/1e3),o=e.state==="active"&&!e.synthetic?Ik(n.total,s):null,i=v_(e)+(o?`
|
|
71
|
-
burn: ${o}`:"");return{kind:"spent",total:n.total,floor:r>0,tt:i}}const WW=new Set(["untrusted","on-request","on-failure"]);function zW(e){return typeof e!="string"||!e?null:WW.has(e)?!0:e==="never"?!1:null}function iI(e){if(e.provider!=="codex"||e.kind!=="root"||e.waiting||e.state!=="active")return null;const t=zW(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."}
|
|
72
|
-
|
|
73
|
-
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 b_(e){return e[0].toUpperCase()+e.slice(1).toLowerCase()}function rs(e){const t=Zr(e).replace(/[-_]\d{8}(?!\d)/,""),n=t.match(/^claude[-_](opus|sonnet|haiku|fable|mythos)[-_](\d+(?:[-_.]\d+)*)/i);if(n){const s=b_(n[1]),o=n[2].replace(/[-_]/g,".");return`${s} ${o}`}const r=t.match(/^gpt[-_](\d+(?:[-_.]\d+)*)((?:[-_][A-Za-z0-9.]+)*)$/i);if(r){const s=r[1].replace(/[-_]/g,"."),o=r[2].split(/[-_]/).filter(Boolean).map(b_);return[`GPT-${s}`,...o].join(" ")}return e}function lf(e){const t=Zr(e??""),n=t.match(/^claude[-_](opus|sonnet|haiku|fable|mythos)[-_]/i);return n?n[1].toLowerCase():/^gpt[-_]/i.test(t)?"gpt":""}function Hn(e){return(e==null?void 0:e.kind)==="permission"||(e==null?void 0:e.kind)==="asked"}function d0(e){const t=[];for(const n of e)n.kind==="root"&&Hn(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 VW(e,t){if(e.length===0)return null;const n=e.findIndex(r=>r.id===t);return e[(n+1)%e.length]}function GW(e){const t=new Set;for(const n of e)n.state==="active"&&t.add(n.sessionId);return t.size}function cf(e,t){return`${e}@${t.since}`}function lI(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 KW(e){const t=e.message||"Needs your permission",n=lI(e,t);return n?`${t}
|
|
74
|
-
Likely on: ${n}`:t}function YW(e,t,n,r=!0){if(!r)return[];if(n)return[];const s=[];for(const o of e){if(!Hn(o.waiting))continue;const i=cf(o.id,o.waiting);t.has(i)||s.push({key:i,title:o.label,body:KW(o.waiting),sessionId:o.id})}return s}function XW(e,t,n){const r=new Set;for(const o of e)r.add(cf(o.id,o.waiting));const s=new Set;for(const o of n)r.has(o)&&s.add(o);for(const o of t)s.add(o.key);return s}function Ed(e){return new Set(e.map(t=>cf(t.id,t.waiting)))}function ZW(e,t){return e!==t}function JW(e,t){return!e&&t!=null}function QW(e,t){return e!==null&&t!=null}function Wi(e){return e==="active"?"live":e==="done"?"done":"err"}function zi(e){return e.message?e.message:e.kind==="permission"?"Needs your permission":"Waiting for your input"}function ez(e){return`${e} subagent${e===1?"":"s"} spawned`}function tz(e){const t=[e.kind==="root"?"session":"subagent"];if(e.childCount>0&&t.push(`→ ${e.childCount}`),e.kind==="subagent"&&e.cwdBasename&&t.push(e.cwdBasename),e.model){const n=Pk(e).length;t.push(`${rs(e.model)}${n>0?` +${n}`:""}`)}else e.provider==="codex"&&t.push("Codex");return t.join(" · ")}function nz(e,t=Date.now(),n=!1){const r=e.toolErrorCount??0,s=En(e,t).total;return[e.label,e.kind==="root"?"session":"subagent",Wi(e.state),Hn(e.waiting)?zi(e.waiting):null,e.model?rs(e.model):null,`${e.toolCount} ${e.toolCount===1?"tool":"tools"}`,r>0?`${r} failed`:null,s>0?`${Ye(s)}${Mc(e,t)>0?"+":""}`:null,n?"selected":null].filter(Boolean).join(", ")}function cI(e,t){const n=lI(e,t);return n?`Likely on: ${n}`:null}function wh(e){return e.kind==="idle"?"Your turn":zi(e)}function ut(e){const t=Math.round(e);if(t<1e3)return`${t}`;if(t<1e6){const n=pc(t/1e3,1,1e3);if(n!==null)return`${n}k`}if(t<1e9){const n=pc(t/1e6,2,1e3);if(n!==null)return`${n}M`}return`${(t/1e9).toFixed(2)}B`}function Vi(e,t,n){const r=(t??n)-e;if(r<1e3)return`${Math.max(0,r)}ms`;const s=Math.floor(r/1e3);if(s<60)return`${s}s`;const o=Math.floor(s/60);if(o>=100)return`${Math.floor(o/60)}h ${o%60}m`;const i=s%60;return`${o}m ${String(i).padStart(2,"0")}s`}function uI(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 Dk(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 k_=2e5,rz=1e6,sz=[/\[1m\]/i,/^claude[-_]opus[-_]5\b/i,/^claude[-_]haiku[-_]5[-_.]5\b(?![-_.]\d{1,7}(?!\d))/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],az=[{match:/^gpt[-_]6[-_]astra/i,window:105e4},{match:/^gpt[-_]6[-_.]1[-_]sol/i,window:105e4},{match:/^gpt[-_]6[-_](?:sol|luna)/i,window:105e4},{match:/^gpt[-_]5[-_.]6[-_]cyber/i,window:4e5},{match:/^gpt[-_]5[-_.]6/i,window:105e4},{match:/^gpt[-_]5[-_.]5/i,window:105e4},{match:/^gpt[-_]5[-_.]4[-_](?:mini|nano)/i,window:4e5},{match:/^gpt[-_]5[-_.]4/i,window:105e4},{match:/^gpt[-_]5[-_.]3[-_]chat[-_]latest$/i,window:128e3},{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 oz(e){if(!e)return k_;const t=Zr(e);for(const n of sz)if(n.test(t))return rz;for(const n of az)if(n.match.test(t))return n.window;return k_}function dI(e,t){return typeof e=="number"&&e>0?e:oz(t)}const iz=1;function lz(){const e=[];let t=0;function n(){let r;for(const s of e)(!r||s.layer>r.layer||s.layer===r.layer&&s.seq>r.seq)&&(r=s);return r}return{push(r,s=0,o="dialog"){const i={dismiss:r,layer:s,kind:o,seq:t++};return e.push(i),()=>{const c=e.indexOf(i);c!==-1&&e.splice(c,1)}},dismissTop(){const r=n();return r?(r.dismiss(),!0):!1},isTop(r){const s=n();return s!=null&&s.dismiss===r},depth(){return e.length},dialogDepth(){return e.filter(r=>r.kind==="dialog").length}}}const jn=lz(),cz=e=>e==="Escape";function uz(e){return e.overlayOpen?"dismiss":e.typing?"blur":"clear-selection"}function j_(e){return String(e.tagName??"").toUpperCase()==="BODY"}function N_(e,t){return!e||!e.isConnected||j_(e)?!1:t==null||j_(t)}const S_="a[href], button, input, select, textarea, summary, [tabindex]";function dz(e){return!e||e.disabled||e.rendered===!1?!1:(e.tabIndex??0)>=0}function hz(e){if(!e||!e.overflowing||e.hasFocusable)return!1;const t=String(e.overflow??"").toLowerCase();return t==="auto"||t==="scroll"}function fz({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 uf(e){return e.ctrlKey||e.metaKey||e.altKey}function pz(e){e.key!=="Escape"&&e.key!=="Tab"&&e.stopPropagation()}const mz=new Set(["button","checkbox","color","file","image","radio","range","reset","submit"]),gz=new Set(["INPUT","TEXTAREA","SELECT","OPTION","BUTTON","SUMMARY","A"]),yz=new Set(["button","checkbox","combobox","link","listbox","menu","menubar","menuitem","menuitemcheckbox","menuitemradio","option","radio","searchbox","slider","spinbutton","switch","tab","textbox","treeitem"]);function Fk(e){return typeof e.tagName=="string"?e.tagName.toUpperCase():""}function wz(e){return Fk(e)==="BUTTON"?!0:(typeof e.role=="string"?e.role.trim().toLowerCase():"").split(/\s+/).includes("button")}function xo(e){if(!e)return!1;if(e.isContentEditable)return!0;const t=Fk(e);return t==="TEXTAREA"?!0:t!=="INPUT"?!1:!mz.has(String(e.type??"text").toLowerCase())}function xz(e,t){if(!e)return!1;if(xo(e))return!0;if(t!=null&&(t.length===1||t==="Delete")&&t!==" "&&e.pointerFocused&&wz(e))return!1;if(gz.has(Fk(e)))return!0;const n=typeof e.role=="string"?e.role.trim().toLowerCase():"";return n!==""&&n.split(/\s+/).some(r=>yz.has(r))}function vz({key:e,modalOpen:t,sheetOpen:n}){return t?!(e==="?"&&n):!1}function bz({key:e,sheetOpen:t,target:n}){return t&&e==="?"&&!xo(n)}function Zd({appModal:e,dialogDepth:t}){return e||t>0}function hI(e){return e?Array.from(e.querySelectorAll("*")).filter(t=>{if(t.matches(S_))return dz({disabled:t.disabled,tabIndex:t.tabIndex,rendered:t.checkVisibility?t.checkVisibility():t.getClientRects().length>0});const n=t.scrollHeight>t.clientHeight;return n?(t.checkVisibility?t.checkVisibility():t.getClientRects().length>0)&&hz({overflowing:n,overflow:getComputedStyle(t).overflowY,hasFocusable:t.querySelector(S_)!=null}):!1}):[]}function kz(e,t){const n=hI(e);if(!t||!e.contains(t)||n.includes(t))return n;const r=n.findIndex(s=>(t.compareDocumentPosition(s)&Node.DOCUMENT_POSITION_FOLLOWING)!==0);return r===-1?[...n,t]:[...n.slice(0,r),t,...n.slice(r)]}function ot(e,t={}){const{focusRef:n,restoreFocusFallback:r,layer:s,popover:o}=t,i=o?"popover":"dialog",c=y.useRef(null),d=y.useRef(e);d.current=e;const h=y.useRef(null);h.current===null&&(h.current=()=>d.current());const f=h.current;return y.useEffect(()=>jn.push(f,s,i),[f,s,i]),y.useEffect(()=>{var g;const p=document.activeElement;return(g=(n==null?void 0:n.current)??hI(c.current)[0])==null||g.focus(),()=>{if(N_(p,document.activeElement)&&p.focus(),r&&document.activeElement===document.body){const w=r();N_(w,document.activeElement)&&w.focus()}}},[]),y.useEffect(()=>{const p=g=>{var N;if(g.key!=="Tab"||uf(g))return;const w=c.current;if(!w)return;const k=document.activeElement;if(!(k!=null&&w.contains(k))&&!jn.isTop(f))return;const v=kz(w,k),b=fz({count:v.length,index:k?v.indexOf(k):-1,shiftKey:g.shiftKey});b.kind!=="allow"&&(g.preventDefault(),b.kind==="focus"&&((N=v[b.index])==null||N.focus()))};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[f]),c}function dt(e){const t=y.useRef(!1);return{onPointerDown:n=>{t.current=n.target===n.currentTarget},onPointerUp:n=>{n.target!==n.currentTarget&&(t.current=!1)},onClick:n=>{const r=t.current&&n.target===n.currentTarget;t.current=!1,r&&e()}}}function jz(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 er(e){return e.toLocaleString()}const Nz=60;function Sz(e,t=Nz){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 _z({agent:e,onClose:t}){var w;const n=y.useRef(null),r=ot(t,{focusRef:n}),s=dt(t),o=e.context,i=e.usage,c=(o==null?void 0:o.currentContextTokens)??0,d=dI(e.contextWindow,e.model),h=Math.min(100,c/d*100),f=En(e),p=e.provider==="codex"?i.inputTokens+i.outputTokens:i.inputTokens+i.outputTokens+i.cacheReadTokens+i.cacheCreateTokens,g=jz(e.provider);return a.jsx("div",{className:"modal-backdrop",...s,role:"presentation",children:a.jsxs("div",{ref:r,className:"modal ctx-modal",onClick:k=>k.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Context breakdown",children:[a.jsxs("header",{className:"ctx-modal-head",children:[a.jsxs("div",{children:[a.jsxs("div",{className:"ctx-modal-title",children:["Context · ",e.label]}),a.jsx("div",{className:"ctx-modal-sub",children:g.subtitle})]}),a.jsx("button",{type:"button",ref:n,className:"glyph-btn ctx-modal-close",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]}),a.jsxs("section",{className:"ctx-window-row",children:[a.jsx("div",{className:"ctx-window-bar",role:"progressbar","aria-label":"Context window used","aria-valuemin":0,"aria-valuemax":100,"aria-valuenow":Math.round(h),children:a.jsx("div",{className:"ctx-window-fill",style:{transform:`scaleX(${Math.min(100,Math.max(0,h))/100})`}})}),a.jsxs("div",{className:"ctx-window-meta",children:[a.jsxs("span",{className:"ctx-window-pct",children:[h.toFixed(1),"%"]}),a.jsxs("span",{children:[er(c)," / ",er(d)," tok (",g.windowScope,")"]})]})]}),a.jsx("h3",{className:"ctx-section-title",children:"Cumulative usage · whole session"}),a.jsxs("div",{className:"ctx-grid",children:[a.jsx(vr,{label:"input tokens",val:er(i.inputTokens)}),a.jsx(vr,{label:"output tokens",val:er(i.outputTokens)}),a.jsx(vr,{label:"cache reads",val:er(i.cacheReadTokens)}),a.jsx(vr,{label:"cache writes",val:er(i.cacheCreateTokens)}),a.jsx(vr,{label:"cumulative total",val:er(p)}),a.jsx(vr,{label:"estimated cost",val:Ye(f.total),accent:!0})]}),a.jsx("h3",{className:"ctx-section-title",children:"Transcript composition"}),g.compositionCounted?a.jsxs("div",{className:"ctx-grid",children:[a.jsx(vr,{label:"user messages",val:er((o==null?void 0:o.msgsUser)??0)}),a.jsx(vr,{label:"assistant messages",val:er((o==null?void 0:o.msgsAssistant)??0)}),a.jsx(vr,{label:"tool uses",val:er((o==null?void 0:o.toolUses)??0)}),a.jsx(vr,{label:"tool results",val:er((o==null?void 0:o.toolResults)??0)}),a.jsx(vr,{label:"system-reminders",val:er((o==null?void 0:o.systemReminders)??0)})]}):a.jsx("div",{className:"ctx-empty",children:g.compositionUncounted}),a.jsx("h3",{className:"ctx-section-title",children:g.memoryHeading}),(((w=o==null?void 0:o.memoryFiles)==null?void 0:w.length)??0)===0?a.jsx("div",{className:"ctx-empty",children:g.memoryEmpty}):a.jsx("ul",{className:"ctx-md-list",children:o.memoryFiles.map(k=>a.jsxs("li",{children:[a.jsx("span",{className:"ctx-md-path",title:k.path,children:Sz(k.path)}),a.jsx("span",{className:"ctx-md-size",children:Cs(k.bytes)})]},k.path))})]})})}function vr({label:e,val:t,accent:n}){return a.jsxs("div",{className:`ctx-row${n?" accent":""}`,children:[a.jsx("span",{className:"ctx-row-label",children:e}),a.jsx("span",{className:"ctx-row-val",children:t})]})}function Ez({currentContextTokens:e,modelId:t,contextWindow:n,size:r=26,onClick:s}){const o=dI(n,t),i=Math.min(1,e/o),c=r/2-3,d=r/2,h=2*Math.PI*c,f=h*i,p=i>.9?"var(--err)":i>.7?"var(--warn)":"var(--accent)";return a.jsx("button",{type:"button",className:"ctx-donut",onClick:g=>{g.stopPropagation(),s==null||s()},title:`context: ${e.toLocaleString()} / ${o.toLocaleString()} (${(i*100).toFixed(1)}%)`,"aria-label":`Context ${Math.round(i*100)}% of ${o.toLocaleString()} tokens — show breakdown`,children:a.jsxs("svg",{width:r,height:r,viewBox:`0 0 ${r} ${r}`,"aria-hidden":"true",children:[a.jsx("circle",{cx:d,cy:d,r:c,stroke:"var(--line)",strokeWidth:"2.5",fill:"none"}),a.jsx("circle",{cx:d,cy:d,r:c,stroke:p,strokeWidth:"2.5",fill:"none",strokeDasharray:`${f} ${h-f}`,strokeDashoffset:h/4,strokeLinecap:"round",style:{transition:"var(--ctx-arc-transition)"}}),a.jsx("text",{x:d,y:d+3,textAnchor:"middle",fontSize:"8",fill:"var(--text)",fontWeight:"600",children:Math.round(i*100)})]})})}const __=new Map;function fI(e){let t=__.get(e);return t||(t={now:Date.now(),listeners:new Set,timer:null},__.set(e,t)),t}function Cz(e,t){const n=fI(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 Tz(e){return fI(e).now}const E_=new Map,C_=new Map;function Ao(e=1e3){let t=E_.get(e);t||(t=r=>Cz(e,r),E_.set(e,t));let n=C_.get(e);return n||(n=()=>Tz(e),C_.set(e,n)),y.useSyncExternalStore(t,n,n)}function Rz(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 Az="1",T_="agent-dag.schema",Mz=["agent-dag.layout","agent-dag.viewport"];function Ge(e){if(typeof window>"u")return null;try{return window.localStorage.getItem(e)}catch{return null}}function Ve(e,t){if(!(typeof window>"u"))try{window.localStorage.setItem(e,t)}catch{}}function es(e){if(!(typeof window>"u"))try{window.localStorage.removeItem(e)}catch{}}function Li(){if(typeof window>"u")return null;try{return window.localStorage}catch{return null}}function $z(e,t=Az){let n=null;try{n=e.getItem(T_)}catch{return[]}if(n===t)return[];const r=[];if(n!==null)for(const s of Mz)try{e.getItem(s)!==null&&(e.removeItem(s),r.push(s))}catch{}try{e.setItem(T_,t)}catch{}return r}const pI="agent-dag.recapsDismissed",R_=200;function Lz(){const e=Ge(pI);if(!e)return[];try{const t=JSON.parse(e);return Array.isArray(t)?t.filter(n=>typeof n=="string"):[]}catch{return[]}}let Gi=new Set(Lz());const h0=new Set;let mI=0;function gI(e){return h0.add(e),()=>{h0.delete(e)}}function yI(e){Gi=e,mI++;const t=Array.from(e);Ve(pI,JSON.stringify(t.length>R_?t.slice(-R_):t));for(const n of h0)n()}function Oz(e,t){return`${e}@${t}`}function Iz(e){return Gi.has(e)}function Pz(e){if(Gi.has(e))return;const t=new Set(Gi);t.add(e),yI(t)}function Dz(e){const t=new Set(Gi);t.delete(e)||t.add(e),yI(t)}function Fz(e){return y.useSyncExternalStore(gI,()=>e!=null&&Gi.has(e),()=>!1)}function Bk(e){return`recap:${e}`}function Bz(e){return e.startsWith("recap:")}function qz(){return y.useSyncExternalStore(gI,()=>mI,()=>0)}function ja(e){switch(e){case"recap":return"recap";case"needs":return"needs you";case"done":return"done";case"failed":return"failed";case"last":return"last";default:return"now"}}function Uz(e){let t,n;switch(e.state){case"blocked":t="needs",n=e.needs||e.detail;break;case"done":t="done",n=e.result||e.detail;break;case"failed":t="failed",n=e.detail||e.result||"";break;case"working":t="now",n=e.detail;break;default:return null}if(!n)return null;const r={kind:t,text:n,at:e.updatedAt,source:"job"};return t==="needs"&&e.suggestedReply&&(r.reply=e.suggestedReply),r}function Hz(e){let t=null;for(const n of e.prompts)(!t||n.at>t.at)&&(t=n);return t}const A_=160;function Wz(e){const t=sf(e);if(t)return t.detail?`${t.label}: ${t.detail}`:t.label;const r=(e.split(`
|
|
75
|
-
`).map(s=>s.trim()).find(Boolean)??"").replace(/\s+/g," ");return r.length>A_?r.slice(0,A_-1).trimEnd()+"…":r}function zz(e){const t=Hz(e),n=(t==null?void 0:t.at)??e.startedAt,r=i=>({...i,key:`${e.sessionId}@${i.kind==="last"?"now":i.kind}:${n}`}),s=e.job?Uz(e.job):null;if(s)return r(s);const o=e.activity;if(o&&(!t||t.at<=o.at))return r({kind:e.state==="active"?"now":"last",text:o.text,at:o.at,source:"activity"});if(t&&e.state==="active"){const i=Wz(t.text);if(i){const c={kind:"now",text:i,at:t.at,source:"prompt"};return e.provider==="codex"&&(c.codex=!0),r(c)}}return null}function df(e){if(e.kind!=="root"||e.closedAt!=null)return null;const t=zz(e),n=Rz(e),r=n?{kind:"recap",text:n.text,at:n.at,source:"recap",key:Oz(e.sessionId,n.at)}:null;return t&&r?r.at>t.at?r:t:t??r}function hf(e){switch(e.source){case"recap":return"Claude Code's recap";case"job":return"Claude Code's own line for this background session";case"prompt":return e.codex?"The prompt this turn began with — the deck takes no line from a Codex reply":"The prompt this turn began with — the model has not answered yet";default:return e.kind==="last"?"What the session did last, until Claude Code's recap":"From the session's newest reply"}}function Vz(e){const t=new Map;for(const n of e){if(n.kind!=="subagent"||n.exitAt!=null)continue;let r=t.get(n.sessionId);r||(r={total:0,live:0,done:0,err:0,failed:0},t.set(n.sessionId,r)),r.total+=1,n.state==="active"?r.live+=1:n.state==="err"?r.err+=1:r.done+=1,r.failed+=n.toolErrorCount??0}return t}function wI(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 xI(e){return e.live>0?`→ ${e.total} · ${e.live} live`:`→ ${e.total} · done`}function Gz(e,t,n){const r=e.kind==="root"?e.waiting:null;if(r&&Hn(r))return{tone:"warn",long:n.sayWaiting(r),short:r.kind==="permission"?"Needs you":"Asked you"};if(r&&r.kind==="idle"){const o=n.sayWaiting(r);return{tone:"idle",long:o,short:o}}const s=e.toolErrorCount??0;if(s>0)return{tone:"err",long:`${s} tool ${s===1?"call":"calls"} failed`,short:`${s} failed`};if(t&&t.total>0)return{tone:"muted",long:wI(t),short:xI(t)};if(e.state==="active")for(let o=e.tools.length-1;o>=0;o--){const i=e.tools[o];if(i.endedAt!=null)continue;const{name:c,subject:d}=n.describeCall(i);return{tone:"muted",long:d?`${c} · ${d}`:c,short:c}}return null}function Kz(e,t){return t?t.includes(e)?t:`${e}
|
|
76
|
-
${t}`:e}function f0(e){return e==="active"?"live":e==="done"?"done":"err"}const ff={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"}},Yz=Object.fromEntries(Object.entries(ff).map(([e,t])=>[e,t.category])),Xz=Object.fromEntries(Object.entries(ff).map(([e,t])=>[e,t.emoji])),Zz=Object.fromEntries(Object.entries(ff).map(([e,t])=>[e,t.label])),Jz=new Set(Object.entries(ff).filter(([,e])=>e.shell).map(([e])=>e)),Qz={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",...Yz};function vI(e){return e.startsWith("mcp__")?"mcp":qt(Qz,e)??"other"}const e7=/\btools\.exec_command\s*\(\s*\{[^{}]*?\bcmd\s*:\s*(["'`])((?:\\.|(?!\1)[^\\])*)\1/,t7=/\btools\.([A-Za-z_$][\w$]*)\s*\(/;function n7(e){if(typeof e!="string"||!e)return null;const t=e7.exec(e);if(t){const r=r7(t[2]);if(r.trim())return r}const n=t7.exec(e);return n?n[1]:null}function r7(e){return e.replace(/\\(["'`\\nrt])/g,(t,n)=>n==="n"?`
|
|
77
|
-
`:n==="r"?"\r":n==="t"?" ":n)}const s7={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:"📡",...Xz};function M_(e){return e.startsWith("mcp__")?"🔌":qt(s7,e)??"✨"}const a7={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 bI(e){return/^-(?:Command|c)$/i.test(e)||/^-[a-z]+c$/.test(e)}function kI(e){if(!e)return null;let t=e.trim();if(!t)return null;const n=t.match(/^(?:bash|sh|zsh|fish|powershell|pwsh)(?:\.exe)?((?:\s+-[A-Za-z]+)+)\s*["']([^"']+)["']/i);if(n&&n[1].trim().split(/\s+/).every(o=>bI(o)||/^-(?:NoProfile|NonInteractive)$/i.test(o)))return kI(n[2]);for(;;){const o=t.match(/^([A-Z_][A-Z0-9_]*=\S*)\s+/);if(!o)break;t=t.slice(o[0].length)}t=t.replace(/^sudo(?:\s+-\S+)*\s+/,""),t=t.replace(/^(?:time|nohup|xargs)\s+/,"");const r=t.match(/^([^\s|;&<>(]+)/);if(!r)return null;let s=r[1];return/^[A-Za-z0-9_][\w.+-]*$/.test(s.replace(/^.*[/\\]/,""))?(s=s.replace(/^.*[/\\]/,""),s=s.replace(/\.(exe|cmd|bat|ps1)$/i,""),s||null):null}function o7(e){if(typeof e=="string")return e;if(!e||typeof e!="object")return null;const t=e;if(typeof t.script=="string"){const n=n7(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(bI);if(r>=0&&r+1<n.length)return n[r+1]}return n.join(" ")}return typeof t.script=="string"?t.script:null}const i7=new Set(["Bash","PowerShell",...Jz]);function l7(e,t){if(!i7.has(e))return null;const n=o7(t);if(!n)return null;const r=kI(n);return r?{emoji:qt(a7,r)??"⚙️",label:r,category:"shell",detail:n}:null}const c7=new Set(["Read","Write","Edit","MultiEdit","NotebookEdit","LS","Glob","apply_patch"]),u7={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:"🗄️"},d7={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 h7(e){const n=e.replace(/\\/g,"/").replace(/\/+$/,""),r=n.lastIndexOf("/");return r>=0?n.slice(r+1):n}function f7(e){const t=e.toLowerCase(),n=qt(d7,t);if(n!==void 0)return n;if(t.startsWith("dockerfile."))return"🐳";if(/\.(test|spec)\.[a-z]+$/.test(t))return"🧪";const r=t.lastIndexOf(".");if(r>0&&r<t.length-1){const s=qt(u7,t.slice(r+1));if(s!==void 0)return s}return"📄"}function p7(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 m7(e,t){if(!c7.has(e))return null;const n=p7(e,t);if(!n)return null;const r=h7(n);return r?{emoji:e==="LS"?"📂":f7(r),label:r,category:"file",detail:n}:null}const g7={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 qk(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 y7(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 jI(e){return qt(g7,e.toLowerCase())}function w7(e,t){const n=qk(e);if(!n)return null;const{server:r,method:s}=n;if(!s)return null;const o=jI(r);return{emoji:(o==null?void 0:o.emoji)??"🔌",label:s,category:"mcp",detail:o?`${o.name} · ${s}`:`${r} · ${s}`}}function NI(e,t){return l7(e,t)??m7(e,t)??w7(e)}function x7(e,t){var n;return((n=NI(e,t))==null?void 0:n.label)??null}const v7=Zz,$_=18;function Cd(e){const t=[...e];return t.length<=$_?e:t.slice(0,$_-1).join("")+"…"}const eg=13,b7=6;function k7(e,t){const n=[...e];if(n.length<=eg)return e;const r=n.lastIndexOf("."),s=r>0?n.slice(r):[];return t==="file"&&s.length>1&&s.length<=b7?n.slice(0,eg-1-s.length).join("")+"…"+s.join(""):n.slice(0,eg-1).join("")+"…"}function Uk(e){const t=qk(e);if(t){const r=jI(t.server);return r?{emoji:r.emoji,label:Cd(r.name)}:{emoji:"🔌",label:Cd(t.server),hue:y7(t.server)}}const n=qt(v7,e)??"";return n?{emoji:M_(e),label:Cd(n)}:{emoji:M_(e),label:Cd(e)}}function j7(e){let t=null,n="";for(const r of e){const s=qk(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:Uk(n)}const p0=6e4,Oi=24,L_=p0/Oi,tg=132,Jd=14;function N7(e,t,n){const r=new Array(Oi).fill(0);let s=0;const o=g=>{const w=n-g;if(w<0||w>=p0)return;const k=Oi-1-Math.floor(w/L_);k>=0&&k<Oi&&(r[k]+=1,s+=1)};for(const g of e)o(g.startedAt);for(const g of t??[])o(g);const c=Math.max(0,...r)/(L_/1e3),d=e.filter(g=>n-g.startedAt>=0&&n-g.startedAt<p0).length,h=s-d,f=[d>0?`${d} tool ${d===1?"call":"calls"}`:"",h>0?`${h} ${h===1?"block":"blocks"} of thinking and writing`:""].filter(Boolean),p=s===0?"nothing in the last 60s":`${f.join(" · ")} in last 60s · peak ${c.toFixed(1)}/s`;return{counts:r,title:p}}const S7=2;function _7(e){return e===0?1.5:Math.max(1.5,Math.min(1,e/S7)*Jd)}function SI({kind:e}){return a.jsxs("svg",{className:"state-mark","data-kind":e,viewBox:"0 0 10 10",width:"10",height:"10","aria-hidden":"true",focusable:"false",children:[e==="live"&&a.jsx("circle",{cx:"5",cy:"5",r:"3.2",fill:"currentColor"}),e==="done"&&a.jsx("path",{d:"M2.2 5.3l1.9 1.9 3.8-4.4",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),e==="err"&&a.jsx("path",{d:"M2.8 2.8l4.4 4.4M7.2 2.8l-4.4 4.4",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",fill:"none"})]})}function Hk(){return a.jsxs("svg",{className:"alert-mark",viewBox:"0 0 12 12",width:"12",height:"12","aria-hidden":"true",focusable:"false",children:[a.jsx("path",{d:"M6 1.4l4.7 8.3H1.3z",stroke:"currentColor",strokeWidth:"1.3",strokeLinejoin:"round",fill:"none"}),a.jsx("path",{d:"M6 4.6v2.4",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round"}),a.jsx("circle",{cx:"6",cy:"8.35",r:"0.72",fill:"currentColor"})]})}function _I(){return a.jsxs("svg",{className:"recap-glyph",viewBox:"0 0 12 12",width:"10",height:"10","aria-hidden":"true",focusable:"false",children:[a.jsx("path",{d:"M3.3 3.3l5.4 5.4M8.7 3.3l-5.4 5.4",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",fill:"none"}),a.jsx("circle",{cx:"6",cy:"1.2",r:"1.05",fill:"currentColor"}),a.jsx("circle",{cx:"6",cy:"10.8",r:"1.05",fill:"currentColor"}),a.jsx("circle",{cx:"1.2",cy:"6",r:"1.05",fill:"currentColor"}),a.jsx("circle",{cx:"10.8",cy:"6",r:"1.05",fill:"currentColor"})]})}function xh({recap:e}){return e?a.jsx(_I,{}):a.jsx("svg",{className:"recap-glyph note-glyph",viewBox:"0 0 12 12",width:"10",height:"10","aria-hidden":"true",focusable:"false",children:a.jsx("circle",{cx:"6",cy:"6",r:"3",fill:"currentColor"})})}function E7({data:e}){var b,N;const t=["agent-node",`state-${e.state}`,e.synthetic?"synthetic":""].filter(Boolean).join(" "),n=e.tools.filter(S=>!S.endedAt).length,r=e.toolErrorCount??0,s=Rc(e.sessionId),o=((b=e.context)==null?void 0:b.currentContextTokens)??0,i=e.kind==="root"&&o>0,c=e.sessionTitle?e.cwd?`${e.cwd}
|
|
78
|
-
${e.sessionTitle}`:e.sessionTitle:e.cwd,d=Pk(e),h=d.length>0?`${e.model}
|
|
79
|
-
spend on this card also covers:
|
|
80
|
-
${d.join(`
|
|
81
|
-
`)}`:e.model,f=Dk(e.sessionName,e.sessionTitle),p=df(e),g=p?p.key:null,w=Fz(g),k=p!=null&&!w,j=(p==null?void 0:p.kind)==="recap",v=HW(e);return a.jsxs("div",{className:t,style:{"--session-hue":s},children:[a.jsx("span",{className:"accent-stripe"}),a.jsx(So,{type:"target",position:Le.Left,style:{background:"transparent",border:"none"}}),a.jsxs("div",{className:"head",children:[a.jsxs("div",{className:"title",children:[a.jsx(A7,{state:e.state}),a.jsx("span",{className:"label",title:c,children:e.label}),e.synthetic&&a.jsx("span",{className:"synth-tag",title:"No SessionStart captured — synthesised",children:"?"}),p&&g&&a.jsx("button",{type:"button",className:"glyph-btn recap-pin","aria-label":j?"Claude Code's recap":`Session note: ${ja(p.kind)}`,"aria-expanded":k,title:j?k?"Hide the recap":"Show Claude Code's recap":k?"Hide this note":"Show what this session is doing",onClick:S=>{S.stopPropagation(),Dz(g)},children:a.jsx(xh,{recap:j})})]}),a.jsx("div",{className:"head-right",children:i&&e.onOpenContext&&a.jsx(Ez,{currentContextTokens:o,modelId:e.model,contextWindow:e.contextWindow,onClick:()=>e.onOpenContext(e.sessionId)})})]}),a.jsxs("div",{className:"sub",title:tz(e),children:[a.jsxs("span",{className:"sub-details",children:[e.kind==="root"?"session":"subagent",e.childCount>0&&a.jsxs("span",{className:"spawn-badge",title:ez(e.childCount),children:["→ ",e.childCount]}),e.cwdBasename&&e.kind==="subagent"?` · ${e.cwdBasename}`:"",e.model?a.jsxs("span",{className:"model-chip","data-family":lf(e.model),title:h,children:[rs(e.model),d.length>0?` +${d.length}`:""]}):e.provider==="codex"?a.jsx("span",{className:"model-chip",title:"OpenAI Codex — no model reported yet",children:"Codex"}):null]}),a.jsxs("span",{className:"time",title:e.synthetic?`The deck joined this session after it began, so it has run at least this long — first seen ${new Date(e.startedAt).toLocaleTimeString()}`:`Started ${new Date(e.startedAt).toLocaleTimeString()}`,children:[e.synthetic?"≥ ":"",a.jsx(R7,{start:e.startedAt,end:e.endedAt})]})]}),e.kind==="root"&&f.face&&a.jsx("div",{className:"session-name",title:f.tooltip,children:f.face}),e.waiting&&a.jsx(M7,{waiting:e.waiting}),(()=>{const S=iI(e);return S?a.jsxs("div",{className:"approval-blind-row",title:S.detail,children:[a.jsx("span",{className:"approval-blind-dot","aria-hidden":!0}),a.jsx("span",{className:"approval-blind-said",children:S.label})]}):null})(),(e.tools.length>0||(((N=e.outputs)==null?void 0:N.length)??0)>0)&&a.jsx($7,{tools:e.tools,outputs:e.outputs}),a.jsxs("div",{className:"meta",children:[a.jsxs("span",{children:[a.jsx("b",{children:e.toolCount})," ",e.toolCount===1?"tool":"tools"]}),r>0&&a.jsxs("span",{className:"failed-meta",title:`${r} tool ${r===1?"call":"calls"} returned an error`,children:[a.jsx("b",{children:r})," err"]}),n>0&&a.jsxs("span",{className:"inflight-meta",children:[a.jsx("b",{children:n})," in-flight"]}),e.usage.inputTokens+e.usage.outputTokens>0&&a.jsxs("span",{className:"tokens-meta",title:`in:${e.usage.inputTokens} out:${e.usage.outputTokens} cache-r:${e.usage.cacheReadTokens} cache-c:${e.usage.cacheCreateTokens}${(e.usage.reasoningOutputTokens??0)>0?` reasoning:${e.usage.reasoningOutputTokens}`:""}`,children:[a.jsx("b",{children:ut(e.usage.inputTokens+e.usage.outputTokens)})," tok"]}),(v==null?void 0:v.kind)==="unpriced"&&a.jsx("span",{className:"cost-unpriced",title:v.tt,children:Ls}),(v==null?void 0:v.kind)==="spent"&&a.jsx("span",{className:"cost-meta",title:v.tt,children:a.jsxs("b",{children:[Ye(v.total),v.floor?"+":""]})})]}),a.jsx(T7,{data:e,title:e.kind==="root"?f.face:void 0}),a.jsx(So,{type:"source",position:Le.Right,style:{background:"transparent",border:"none"}})]})}const C7=y.memo(E7);function T7({data:e,title:t}){const n=e.kind==="root"&&Hn(e.waiting),r=Gz(e,e.branch,{sayWaiting:wh,describeCall:s=>({name:Uk(s.name).label,subject:x7(s.name,s.input)})});return a.jsxs("div",{className:"lod-face","data-kind":e.kind,"data-alarm":n?"":void 0,"data-signal":r?"":void 0,"aria-hidden":!0,children:[a.jsxs("div",{className:"lod-id",children:[a.jsx(SI,{kind:f0(e.state)}),a.jsx("span",{className:"lod-name",children:e.label}),r&&a.jsx("span",{className:"lod-inline","data-tone":r.tone,children:r.short}),n&&a.jsx(Hk,{})]}),t&&a.jsx("div",{className:"lod-title",children:t}),r&&a.jsxs("div",{className:"lod-signal","data-tone":r.tone,children:[a.jsx("span",{className:"lod-long",children:r.long}),a.jsx("span",{className:"lod-short",children:r.short})]})]})}function R7({start:e,end:t}){const n=Ao(1e3);return a.jsx(a.Fragment,{children:Vi(e,t,n)})}function A7({state:e}){return a.jsx("span",{className:`state-pill state-${e}`,children:Wi(e)})}function M7({waiting:e}){const t=Ao(1e3),n=Hn(e),r=zi(e);return a.jsxs("div",{className:n?"waiting-row permission":"waiting-row idle",title:`${r}
|
|
82
|
-
Blocked for ${Vi(e.since,void 0,t)} — the answer goes in the terminal, not here.`,children:[n?a.jsx("span",{className:"ap-pulse","aria-hidden":!0}):a.jsx("span",{className:"waiting-dot","aria-hidden":!0}),a.jsx("span",{className:"waiting-said",children:wh(e)}),a.jsx("b",{children:Vi(e.since,void 0,t)})]})}function $7({tools:e,outputs:t}){const n=Ao(1e3),{counts:r,title:s}=N7(e,t,n),o=tg/Oi;return a.jsxs("div",{className:"tool-spark-row",title:s,children:[a.jsx("svg",{className:"tool-spark",width:tg,height:Jd,viewBox:`0 0 ${tg} ${Jd}`,"aria-hidden":!0,children:r.map((i,c)=>{const d=_7(i),h=c===Oi-1&&i>0,p=`tool-spark-bar${i>0?" active":""}${h?" latest":""}`;return a.jsx("rect",{x:c*o+.4,y:Jd-d,width:Math.max(.5,o-1),height:d,rx:.8,className:p},h?`landed:${i}`:c)})}),a.jsx("span",{className:"tool-spark-label",children:"60s"})]})}function L7({enableAutoFitAndRefit:e}){return a.jsxs("div",{className:"autofit-chip",children:[a.jsx("span",{className:"autofit-state",title:"New sessions are not brought into view while you are moving it yourself",children:"Auto-fit off"}),a.jsx("button",{type:"button",className:"autofit-resume",onClick:e,title:"Bring new sessions into view again","aria-label":"Resume auto-fit",children:"Resume"})]})}const Wk="agent-dag.single-key-shortcuts";function EI(e){return e!=="0"}function CI(e){return e.length===1}function TI(e,t){return!t&&CI(e)}function dn(e,t,n){return n?`${e} (${t})`:e}let vo=null;const oc=new Set;function RI(){for(const e of oc)e()}function m0(){return vo===null&&(vo=EI(Ge(Wk))),vo}function O7(e){vo!==e&&(vo=e,Ve(Wk,e?"1":"0"),RI())}function O_(e){if(e.key!==Wk)return;const t=EI(e.newValue);t!==vo&&(vo=t,RI())}function I7(e){var t;return oc.add(e),oc.size===1&&typeof window<"u"&&((t=window.addEventListener)==null||t.call(window,"storage",O_)),()=>{var n;oc.delete(e),oc.size===0&&typeof window<"u"&&((n=window.removeEventListener)==null||n.call(window,"storage",O_))}}function vh(e){const t=Math.max(0,Math.floor(e));return`${t} event${t===1?"":"s"}`}const I_=99;function P7(e){const t=Math.max(0,Math.floor(e));return t>I_?`${I_}+`:String(t)}const D7="Pause the canvas";function F7(e){const t=e.singleKeys??!0;if(!e.paused)return dn("Pause live updates — events keep arriving and are applied when you resume","Space",t);const n=Math.max(0,Math.floor(e.dropped??0));return n>0?dn(`The pause is full — ${vh(e.held)} held and ${n} older ${n===1?"one":"ones"} already dropped. Resume to follow the canvas again`,"Space",t):e.held<=0?dn("Nothing has arrived since you paused. Resume to follow the canvas again","Space",t):dn(`${vh(e.held)} arrived while paused and will be applied in order when you resume`,"Space",t)}function B7(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 AI="paused · full",q7=(e,t)=>t>0?AI:e>0?`paused · ${P7(e)}`:"paused";function U7(e){const t=Math.max(0,Math.floor(e.dropped??0)),n=e.singleKeys??!0;return e.connected?e.paused?{tone:"paused",resting:!1,label:q7(e.held,t),widest:AI,title:dn(t>0?`Connected — the pause is full at ${vh(e.held)}; the oldest are being dropped as new ones arrive. Resume to catch up`:e.held>0?`Connected — ${vh(e.held)} held until you resume`:"Connected — updates held until you resume","Space",n)}:{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"}}function Cn(){return y.useSyncExternalStore(I7,m0,m0)}const H7=e=>e.transform[2]>=e.maxZoom,W7=e=>e.transform[2]<=e.minZoom;function z7({autoFitDisabled:e,enableAutoFitAndRefit:t,paused:n,pauseGate:r,togglePause:s,handleRelayout:o,requestClear:i,setKeyHelpOpen:c}){const d=Qi(),h=Qe(H7),f=Qe(W7),p=Cn();return a.jsxs(pH,{showInteractive:!1,showFitView:!1,showZoom:!1,children:[a.jsx(tr,{onClick:()=>{h||d.zoomIn()},title:"Zoom in","aria-label":"Zoom in","aria-disabled":h||void 0,children:a.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:a.jsx("path",{d:"M12 5v14M5 12h14",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})})}),a.jsx(tr,{onClick:()=>{f||d.zoomOut()},title:"Zoom out","aria-label":"Zoom out","aria-disabled":f||void 0,children:a.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:a.jsx("path",{d:"M5 12h14",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})})}),a.jsx(tr,{onClick:t,title:e?"Recenter view + re-enable autofit":"Recenter view (autofit already on)","aria-label":"Recenter view","data-nudge":e?"":void 0,children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[a.jsx("circle",{cx:"12",cy:"12",r:"3.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),a.jsx("path",{d:"M12 2v4M12 18v4M2 12h4M18 12h4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})]})}),a.jsx(tr,{"data-group-start":"",onClick:s,title:F7({paused:n,held:r.size,dropped:r.dropped,singleKeys:p}),"aria-label":D7,"aria-pressed":n,children:a.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:a.jsx("path",{d:"M9 5.5v13M15 5.5v13",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})})}),a.jsx(tr,{onClick:o,title:dn("Auto-arrange — clear pins","R",p),"aria-label":"Re-arrange the canvas",children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[a.jsx("rect",{x:"8.5",y:"2",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),a.jsx("rect",{x:"1.5",y:"17",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),a.jsx("rect",{x:"15.5",y:"17",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),a.jsx("path",{d:"M12 7v6.5M5 17v-3.5h14V17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]})}),a.jsx(tr,{"data-group-start":"","data-danger":"",onClick:()=>i("button"),title:dn("Clear the canvas and the server's event log — asks first","C",p),"aria-label":"Clear the canvas",children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[a.jsx("path",{d:"M4 6.2h16",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"}),a.jsx("path",{d:"M9 6.2V4.4a1.6 1.6 0 0 1 1.6-1.6h2.8a1.6 1.6 0 0 1 1.6 1.6v1.8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),a.jsx("path",{d:"M17.4 6.4 16.7 20a2 2 0 0 1-2 1.9H9.3a2 2 0 0 1-2-1.9L6.6 6.4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),a.jsx("path",{d:"M10.3 10.6v6.8M13.7 10.6v6.8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})]})}),a.jsx(tr,{"data-group-start":"",onClick:()=>c(g=>!g),title:p?dn("Keyboard shortcuts","?",!0):"Keyboard shortcuts — the single-key ones are off","aria-label":"Open the keyboard shortcuts","aria-haspopup":"dialog",children:a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[a.jsx("path",{d:"M8.6 8.4a3.5 3.5 0 1 1 4.6 3.35c-.85.3-1.2 1-1.2 1.85v1",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),a.jsx("path",{d:"M12 18.4v.2",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",fill:"none"})]})})]})}const V7="modulepreload",G7=function(e){return"/"+e},P_={},Jc=function(t,n,r){let s=Promise.resolve();if(n&&n.length>0){let i=function(h){return Promise.all(h.map(f=>Promise.resolve(f).then(p=>({status:"fulfilled",value:p}),p=>({status:"rejected",reason:p}))))};document.getElementsByTagName("link");const c=document.querySelector("meta[property=csp-nonce]"),d=(c==null?void 0:c.nonce)||(c==null?void 0:c.getAttribute("nonce"));s=i(n.map(h=>{if(h=G7(h),h in P_)return;P_[h]=!0;const f=h.endsWith(".css"),p=f?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${p}`))return;const g=document.createElement("link");if(g.rel=f?"stylesheet":V7,f||(g.as="script"),g.crossOrigin="",g.href=h,d&&g.setAttribute("nonce",d),document.head.appendChild(g),f)return new Promise((w,k)=>{g.addEventListener("load",w),g.addEventListener("error",()=>k(new Error(`Unable to preload CSS for ${h}`)))})}))}function o(i){const c=new Event("vite:preloadError",{cancelable:!0});if(c.payload=i,window.dispatchEvent(c),!c.defaultPrevented)throw i}return s.then(i=>{for(const c of i||[])c.status==="rejected"&&o(c.reason);return t().catch(o)})},D_="agent-dag.fm-custom-stations",F_="agent-dag.fm-muted",g0="custom:",K7=/^UC[A-Za-z0-9_-]{22}$/,Y7=/^[A-Za-z0-9_-]{11}$/,MI=/^[A-Za-z0-9_-]{1,80}$/,X7=/\.(mp3|aac|ogg)$/i,Z7=/\.m3u8$/i,J7=2048,$I=80;function Ki(e){return`${g0}${e}`}function pf(e){if(!e.startsWith(g0))return null;const t=e.slice(g0.length);return MI.test(t)?t:null}function B_(e){return pf(e)??e}function zk(e){var i,c;const t=e.trim();if(t.length>J7)return null;let n;try{n=new URL(t)}catch{return null}if(n.protocol!=="https:"||n.username||n.password)return null;const r=n.toString(),s=n.hostname.toLowerCase();if(s==="youtube.com"||s==="www.youtube.com"||s==="m.youtube.com"){if(n.port)return null;const d=(i=/^\/channel\/([^/]+)(?:\/live)?\/?$/.exec(n.pathname))==null?void 0:i[1];if(d&&K7.test(d))return{kind:"youtube-channel",url:r,channel:d};const h=(c=/^\/@([^/]+)\/live\/?$/.exec(n.pathname))==null?void 0:c[1];if(h&&/^[A-Za-z0-9._-]{1,64}$/.test(h))return{kind:"youtube-handle",url:r,handle:h};if(n.pathname==="/watch"){const f=n.searchParams.get("v")??"";if(Y7.test(f))return{kind:"youtube-video",url:r,video:f}}return null}return Z7.test(n.pathname)?{kind:"direct-audio",url:r,format:"hls"}:X7.test(n.pathname)?{kind:"direct-audio",url:r,format:"audio"}:/\.(html?|pls|m3u)$/i.test(n.pathname)?null:{kind:"direct-audio",url:r,format:"audio"}}function Q7(e){return e==="1"}function e9(e){if(!e)return[];let t;try{t=JSON.parse(e)}catch{return[]}if(!Array.isArray(t))return[];const n=new Set,r=[];for(const s of t){if(!s||typeof s!="object")continue;const o=typeof s.id=="string"?s.id:"",i=typeof s.name=="string"?s.name.trim():"",c=typeof s.url=="string"?s.url.trim():"",d=zk(c);if(!MI.test(o)||n.has(o)||!i||i.length>$I||!d)continue;n.add(o);const h=LI(s.radio);r.push({id:o,name:i,url:d.url,...h?{radio:h}:{}})}return r}function t9(e,t,n){const r=pf(e??"");return r&&t.some(s=>s.id===r)?Ki(r):n(e)}function n9(e,t){return e===Ki(t)?"claude-fm":e}function LI(e){if(!e||typeof e!="object")return null;const t=e,n=(s,o)=>typeof t[s]=="string"?t[s].slice(0,o):"",r=(s,o)=>typeof t[s]=="number"&&Number.isFinite(t[s])&&Math.abs(t[s])<=o?t[s]:null;return{...t.hls===!0?{hls:!0}:{},country:n("country",80),countryCode:n("countryCode",2),region:n("region",80),tags:n("tags",180),language:n("language",80),codec:n("codec",12),bitrate:typeof t.bitrate=="number"&&Number.isFinite(t.bitrate)?Math.max(0,Math.min(1e3,t.bitrate)):0,lat:r("lat",90),lon:r("lon",180)}}const y0="https://www.youtube-nocookie.com";function r9(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 pi(e,t=[]){return JSON.stringify({event:"command",func:e,args:t})}function s9(e="claude-fm"){return JSON.stringify({event:"listening",id:e,channel:"widget"})}const a9=[1],o9=[0,2],i9=[2,5,100,101,150,153];function l9(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==="onAutoplayBlocked")return{kind:"blocked"};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:a9.includes(s)?{kind:"playing",playing:!0}:s===3?{kind:"buffering"}:o9.includes(s)?{kind:"playing",playing:!1}:null}return null}const Zl=new Set;let q_="";function U_(e){const t=new Date().toISOString().slice(0,10);if(t!==q_&&(Zl.clear(),q_=t),!Zl.has(e)){Zl.add(e);try{const n=typeof navigator>"u"?void 0:navigator;(!n||typeof n.sendBeacon!="function"||!n.sendBeacon("/api/feature",JSON.stringify({name:e})))&&Zl.delete(e)}catch{Zl.delete(e)}}}const H_=864e5,c9=6e4;function Jt(e,t=!0){y.useEffect(()=>{if(!t)return;U_(e);let n;const r=()=>{n=setTimeout(()=>{U_(e),r()},H_-Date.now()%H_+c9)};return r(),()=>clearTimeout(n)},[e,t])}const u9={"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 d9({fetchImpl:e,enabled:t=!0,volume:n,muted:r,source:s,playRequest:o,customStation:i,onAvailabilityChange:c}){var F;const[d,h]=y.useState(null),[f,p]=y.useState(!1),[g,w]=y.useState(!1),[k,j]=y.useState(!1),[v,b]=y.useState(!1);Jt("claude-fm",k);const N=y.useRef(o),S=y.useRef(null),E=y.useRef(null),C=y.useRef(void 0),$=y.useRef(null),T=y.useCallback(()=>{var B;clearTimeout(C.current),(B=E.current)==null||B.destroy(),E.current=null;const A=S.current;A&&(A.pause(),A.removeAttribute("src"),A.load(),S.current=null)},[]),I=y.useCallback(A=>{var B,D;(D=(B=$.current)==null?void 0:B.contentWindow)==null||D.postMessage(A,y0)},[]),O=y.useRef(n);O.current=n;const U=y.useRef(r);U.current=r;const P=y.useCallback((A,B,D)=>{T();const K=new Audio;K.preload="none",K.volume=O.current/100,K.muted=U.current,S.current=K,w(!0),j(!1),b(!1);let G=!1;const H=()=>S.current===K,q=()=>{clearTimeout(C.current),T(),w(!1),j(!1),b(!1)},M=()=>{H()&&(q(),p(!0),c==null||c(D,!0))},V=W=>{if(H()){if(W instanceof DOMException&&W.name==="NotAllowedError"){q();return}M()}};C.current=setTimeout(()=>{H()&&!G&&M()},15e3),K.addEventListener("playing",()=>{H()&&(clearTimeout(C.current),G=!0,j(!0),b(!1),c==null||c(D,!1))});const Z=()=>{H()&&(j(!1),b(G),clearTimeout(C.current),C.current=setTimeout(()=>{H()&&M()},15e3))};K.addEventListener("waiting",Z),K.addEventListener("stalled",Z),K.addEventListener("ended",()=>{H()&&q()}),K.addEventListener("error",M,{once:!0}),B&&!K.canPlayType("application/vnd.apple.mpegurl")?Jc(async()=>{const{default:W}=await import("./hls-BFpXDghs.js");return{default:W}},[]).then(({default:W})=>{if(!H())return;if(!W.isSupported()){M();return}const X=new W;E.current=X,X.on(W.Events.ERROR,(Y,J)=>{J.fatal&&M()}),X.on(W.Events.MEDIA_ATTACHED,()=>X.loadSource(A)),X.on(W.Events.MANIFEST_PARSED,()=>{K.play().catch(V)}),X.attachMedia(K)},M):(K.src=A,K.play().catch(V))},[c,T]);y.useEffect(()=>{g&&(I(pi("setVolume",[n])),I(pi(r?"mute":"unMute")),S.current&&(S.current.volume=n/100,S.current.muted=r))},[n,r,g,I]),y.useEffect(()=>{var q;let A=!0;const B=e??fetch,D=N.current!==o;if(N.current=o,h(null),p(!1),b(!1),w(D),j(!1),T(),!t){w(!1),j(!1);return}const K=i&&Ki(i.id)===s?zk(i.url):null;if(K){if(K.kind==="direct-audio"){const M=K.format==="hls"||((q=i==null?void 0:i.radio)==null?void 0:q.hls)===!0;return h({live:!0,channel:"",audio:K.url,hls:M}),c==null||c(s,!1),D&&P(K.url,M,s),()=>{A=!1}}return B(`/api/fm-station?url=${encodeURIComponent(K.url)}`).then(M=>M.ok?M.json():null).then(M=>{A&&(M!=null&&M.channel||M!=null&&M.video?(h({live:!0,channel:M.channel??"",video:M.video??void 0}),c==null||c(s,!1)):(p(!0),w(!1),j(!1),b(!1),c==null||c(s,!0)))}).catch(()=>{A&&(p(!0),w(!1),j(!1),b(!1),c==null||c(s,!0))}),()=>{A=!1}}if(pf(s))return p(!0),c==null||c(s,!0),()=>{A=!1};const G=s,H=u9[G];if(H)B(H).then(M=>M.ok?M.json():null).then(M=>{A&&(M!=null&&M.video&&h({live:!0,channel:"",video:M.video}),M!=null&&M.video||(p(!0),w(!1),j(!1)),c==null||c(s,!(M!=null&&M.video)))}).catch(()=>{A&&(p(!0),w(!1),j(!1),c==null||c(s,!0))});else if(G!=="claude-fm"){const M=G.replace("lofi-","");B(`/api/lofi-girl?station=${encodeURIComponent(M)}`).then(V=>V.ok?V.json():null).then(V=>{A&&(V!=null&&V.video&&h({live:!0,channel:"",video:V.video}),V!=null&&V.video||(p(!0),w(!1),j(!1)),c==null||c(s,!(V!=null&&V.video)))}).catch(()=>{A&&(p(!0),w(!1),j(!1),c==null||c(s,!0))})}else B("/api/claude-fm").then(M=>M.ok?M.json():null).then(M=>{if(!A)return;const V=!!(M!=null&&M.live&&(M!=null&&M.channel));V&&h({live:!0,channel:M.channel}),V||(p(!0),w(!1),j(!1)),c==null||c(s,!V)}).catch(()=>{A&&(p(!0),w(!1),j(!1),c==null||c(s,!0))});return()=>{A=!1}},[i==null?void 0:i.id,i==null?void 0:i.url,(F=i==null?void 0:i.radio)==null?void 0:F.hls,t,e,c,o,s,P,T]),y.useEffect(()=>()=>T(),[T]),y.useEffect(()=>{if(!g||d!=null&&d.audio)return;let A;const B=()=>{clearTimeout(A),A=void 0,w(!1),j(!1),b(!1),p(!0),c==null||c(s,!0)},D=()=>{A??(A=setTimeout(B,15e3))};D();const K=G=>{var q;if(G.origin!==y0||G.source!==((q=$.current)==null?void 0:q.contentWindow))return;const H=l9(G.data);if(H){if(H.kind==="ready"){I(pi("setVolume",[O.current])),I(pi(U.current?"mute":"unMute")),I(pi("playVideo"));return}if(H.kind==="blocked"){clearTimeout(A),A=void 0,w(!1),j(!1),b(!1);return}if(H.kind==="buffering"){j(!1),b(!0),D();return}if(H.kind==="playing"){clearTimeout(A),A=void 0,j(H.playing),b(!1),H.playing||w(!1);return}i9.includes(H.code)&&B()}};return window.addEventListener("message",K),()=>{clearTimeout(A),window.removeEventListener("message",K)}},[g,d==null?void 0:d.audio,o,c,I,s]);const L=y.useCallback(()=>{if(d){if(d.audio){if(g){T(),w(!1),j(!1),b(!1);return}P(d.audio,d.hls===!0,s);return}if(!g){w(!0),j(!1),b(!1);return}I(pi("pauseVideo")),w(!1),j(!1),b(!1)}},[d,g,k,s,I,P,T]);return y.useMemo(()=>({probe:d,dead:f,armed:g,playing:k,buffering:v,frame:$,say:I,press:L}),[d,f,g,k,v,I,L])}const W_="agent-dag.radio-favorites",z_="agent-dag.radio-recent",V_="agent-dag.radio-catalogue";function h9(e){if(!Array.isArray(e))return[];const t=new Set;return e.slice(0,300).flatMap(n=>{if(!n||typeof n!="object")return[];const r=n,s=typeof r.id=="string"?r.id:"",o=typeof r.name=="string"?r.name.trim().slice(0,80):"",i=typeof r.url=="string"?zk(r.url):null,c=LI(r.radio??r);return!/^radio-[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/i.test(s)||!o||!c||!i||i.kind!=="direct-audio"||t.has(s)?[]:(t.add(s),[{id:s,name:o,url:i.url,radio:c}])})}function G_(e){try{const t=JSON.parse(e??"[]");return Array.isArray(t)?[...new Set(t.filter(n=>typeof n=="string"&&/^[A-Za-z0-9_-]{1,80}$/.test(n)))].slice(0,100):[]}catch{return[]}}function f9(e,t){return[t,...e.filter(n=>n!==t)].slice(0,50)}function ege(e,t,n=Math.random){const r=e.filter(s=>s.id!==t);return r.length?r[Math.min(r.length-1,Math.floor(Math.max(0,n())*r.length))]:null}function tge(e,t,n){if(!e.length)return null;const r=e.findIndex(o=>o.id===t),s=e[r<0?n===1?0:e.length-1:(r+n+e.length)%e.length];return s.id===t?null:s}function OI(e,t,n){const r=e.findIndex(s=>s.id===t);for(let s=1;s<=e.length;s++){const o=e[(r+s)%e.length];if(o.id!==t&&!n.has(o.id))return o}return null}function nge(e,t){if(!e.length)return null;const n=[...e].sort((s,o)=>s.id.localeCompare(o.id));let r=0;for(const s of t)r=Math.imul(r,31)+s.charCodeAt(0)>>>0;return n[r%n.length]}function rge(e,t,n,r,s){return(!t||`${e.name} ${e.radio.country} ${e.radio.region} ${e.radio.tags}`.toLowerCase().includes(t.toLowerCase()))&&(!n||e.radio.countryCode===n)&&(!r||e.radio.tags.toLowerCase().includes(r.toLowerCase()))&&(!s||e.radio.language.toLowerCase().includes(s.toLowerCase()))}function p9(){const[e,t]=y.useState(()=>G_(Ge(W_))),[n,r]=y.useState(()=>G_(Ge(z_))),[s,o]=y.useState(()=>{try{return h9(JSON.parse(Ge(V_)??"[]"))}catch{return[]}});y.useEffect(()=>{Ve(W_,JSON.stringify(e))},[e]),y.useEffect(()=>{Ve(z_,JSON.stringify(n))},[n]);const i=y.useCallback(h=>r(f=>f9(f,h)),[]),c=y.useCallback(h=>t(f=>f.includes(h)?f.filter(p=>p!==h):[...f,h].slice(-100)),[]),d=y.useCallback(h=>{o(h),Ve(V_,JSON.stringify(h))},[]);return{favorites:e,recent:n,catalogue:s,remember:i,toggleFavorite:c,updateCatalogue:d}}function m9(e,t,n,r){const s=OI(e,t,n);if(!s)return()=>{};const o=setTimeout(()=>{n.add(t),r(s)},1e3);return()=>clearTimeout(o)}const mf=148,K_=6e3,g9=16e3,II=46,va=34;function y9(e,t,n=mf){let r=-Math.round(t()*n);if(Math.abs(r-e)<va){const s=e-va>=-n?-va:va;r=Math.max(-n,Math.min(0,Math.round(e+s)))}return{to:r,ms:Math.round(Math.abs(r-e)*II)}}function w9(e){return Math.round(K_+e()*(g9-K_))}const Y_=[{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 x9(e){const t=Y_.reduce((r,s)=>r+s.weight,0);let n=e()*t;for(const r of Y_)if(n-=r.weight,n<0)return r.kind;return"stroll"}const v9=720,b9=260,k9=620,j9=220,X_=520,PI=1600,Z_=7e3,N9=15e3,J_=6e3,S9=14e3;function mi(e,t,n=mf){let r=-Math.round(t()*n);if(Math.abs(r-e)<va){const s=e-va>=-n?-va:va;r=Math.max(-n,Math.min(0,Math.round(e+s)))}return r}const Ut=(e,t)=>Math.round(Math.abs(t-e)*II),_9=120,Td=0;function E9(e,t){const n=r=>({kind:"litter",at:t,...r});return[{x:t,prop:n({}),act:"walk",ms:Ut(e,t)},{x:t,prop:n({}),act:"stoop",ms:v9},{x:Td,prop:n({held:!0}),act:"carry",ms:Ut(t,Td)},{x:Td,prop:n({held:!0}),act:"windup",ms:b9},{x:Td,prop:n({held:!0,leaving:!0}),act:"toss",ms:k9}]}function C9(e,t){const n=t>e?1:-1,r=t-n*Math.min(15,Math.abs(t-e)),s=(o={})=>({kind:"ball",at:t,...o});return[{x:r,prop:s(),act:"walk",ms:Ut(e,r)},{x:r,prop:s(),act:"windup",ms:j9,facing:n>0?"right":"left"},{x:r,prop:s({leaving:!0}),act:"kick",ms:X_,facing:n>0?"right":"left"},{x:r,prop:s({leaving:!0}),act:"stand",ms:PI-X_}]}const DI=640;function T9(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:Ut(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:Ut(r,0)}]}function R9(e,t,n){const r=Math.max(-110,Math.min(-30,t)),s={x:r,prop:null};return[{...s,act:"walk",ms:Ut(e,r)},{...s,act:"skip-ready",ms:500},{...s,act:"skip",ms:DI*(6+Math.floor(n()*5))},{...s,act:"skip-rest",ms:600},{...s,act:"stand",ms:350},{x:0,prop:null,act:"walk",ms:Ut(r,0)}]}function A9(e,t,n){return[{x:t,prop:null,act:"walk",ms:Ut(e,t)},{x:t,prop:null,act:"sit",ms:Math.round(J_+n()*(S9-J_))},{x:t,prop:null,act:"stand",ms:400}]}function M9(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:Ut(e,t)},{x:t,prop:r(),act:"watch",ms:Math.round(Z_+n()*(N9-Z_))},{x:t,prop:r(),act:"scope-pack",ms:480},{x:t,prop:null,act:"stand",ms:240}]}function ng(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 $9=1500,L9=e=>Math.round(1e3*Math.sqrt(2*e/$9)),O9=115,I9=e=>Math.round(e/O9*1e3),P9=620,D9=200,F9=760,B9=600,q9=240;function U9(e,t,n){const s=-(t.ledgeSpan??mf),o=L9(t.ledgeH),i=I9(t.ledgeH),c=n(),d=n(),h=-Math.round(c*t.floorSpan),f=-Math.round(d*t.floorSpan);return[{x:s,act:"walk",prop:null,ms:Ut(e,s)},{x:s,act:"peer",prop:null,ms:P9},{x:s,act:"fall",prop:null,ms:o,place:"floor"},{x:s,act:"land",prop:null,ms:D9,place:"floor"},{x:h,act:"walk",prop:null,ms:Ut(s,h),place:"floor",floorFrac:c},{x:f,act:"walk",prop:null,ms:Ut(h,f),place:"floor",floorFrac:d},{x:s,act:"walk",prop:null,ms:Ut(f,s),place:"floor"},{x:s,act:"lasso",prop:null,ms:F9,place:"floor"},{x:s,act:"rope-throw",prop:null,ms:B9,place:"floor"},{x:s,act:"rope-catch",prop:null,ms:q9,place:"floor"},{x:s,act:"climb",prop:null,ms:i},{x:s,act:"pull-up",prop:null,ms:480}]}function H9(e,t,n){const r=(n==null?void 0:n.ledgeSpan)??mf;switch(x9(t)){case"tidy":return E9(e,mi(e,t,r));case"kick":return C9(e,mi(e,t,r));case"sit":return A9(e,mi(e,t,r),t);case"watch":return M9(e,mi(e,t,r),t);case"fish":return T9(e,mi(e,t,r),t);case"skip":return R9(e,mi(e,t,r),t);case"leave":{if(!n||!(n.ledgeH>0)||!(n.floorSpan>0))break;return U9(e,n,t)}}const o=y9(e,t,r);return[{x:o.to,prop:null,act:"walk",ms:o.ms}]}const W9=420;function z9(e,t,n){const r=t==="right"?n-e-18:e-18;return(t==="right"?1:-1)*Math.min(W9,Math.max(0,r))}const V9=260,G9=200;function K9(e,t,n){const r=(f,p=Ut(e,f))=>({x:f,prop:null,act:"walk",ms:p,place:"floor"});if(!n||n.height<=0)return[r(t)];const s=Math.min(e,t);if(Math.max(e,t)<=n.left||s>=n.right)return[r(t)];const i=t>e,c=i?n.left:n.right,d=i?n.right:n.left,h={place:"floor",riser:n.height,prop:null};return[r(c,Ut(e,c)),{...h,x:c,act:"mount",ms:V9},{...h,x:d,act:"walk",ms:Ut(c,d)},{x:d,prop:null,act:"dismount",ms:G9,place:"floor"},{x:t,prop:null,act:"walk",ms:Ut(d,t),place:"floor"}]}const FI=["bob","sway","groove"],Q_=9e3,Y9=16e3,BI=1e3,X9=.08;function Z9(e,t){const n=FI.filter(o=>o!==e),r=n[Math.min(n.length-1,Math.floor(t()*n.length))],s=(t()*2-1)*X9;return{dance:r,beatMs:Math.round(BI*(1+s))}}function J9(e){return Math.round(Q_+e()*(Y9-Q_))}const Vk=["......aaaaaa......","....aa......aa....","...a..bbbbbs..a...","...cpcbbbbbscpc...","...cpcbebbescpc...","...cpcbbbbbscpc...","...cpcbbbbbscpc...","....ccbbbbbscc....","....bbbbbbbbbs....","....bbbbbbbbbs....","......bbbbbs......","......bb..bs......","......bb..bs......","......bb..bs......"],eE=18,Q9=Vk.length,qI="M6 9H4V1H5V0H7V-1H9V1H7V2H5V7H6V8H7V9Z",UI="M12 9H14V6H13V3H11V2H9V4H12Z",Gk=new Set(["a","c","p"]);function Ra(e=Vk){const t=[];return e.forEach((n,r)=>{let s=0;for(;s<n.length;){const o=n[s];if(o==="."){s+=1;continue}let i=1;for(;s+i<n.length&&n[s+i]===o;)i+=1;t.push({x:s,y:r,w:i,cell:o}),s+=i}}),t}const eV=[".xx.","xxxx",".xx."],tV=["..xx..",".xsxx.","xssxxx","xxxxsx",".xxxx.","..xx.."],nV=["...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."],rg={litter:eV,ball:tV,scope:nV},rV=["...hhhhhh...","...hhhhhh...","...kkkkkk...","hhhhhhhhhhhh"],sV=3,aV=-1,w0=11,tE=9;function nE(e){let t=null,n=null,r=0,s=0,o=!1;const i=()=>{t!==null&&clearTimeout(t),t=null},c=()=>{o||e.hidden||!n||t!==null||(s=performance.now(),t=setTimeout(()=>{t=null;const h=n;n=null,h==null||h()},r))},d=()=>{e.hidden&&t!==null?(r=Math.max(0,r-(performance.now()-s)),i()):e.hidden||c()};return e.addEventListener("visibilitychange",d),{schedule(h,f){o||(i(),n=h,r=Math.max(0,f),c())},dispose(){o=!0,i(),n=null,e.removeEventListener("visibilitychange",d)}}}function oV(e,t,n){const[r,s]=y.useState(0),[o,i]=y.useState(0),[c,d]=y.useState(null),[h,f]=y.useState(null),[p,g]=y.useState({x:0,drop:0}),[w,k]=y.useState("ledge"),[j,v]=y.useState("left"),[b,N]=y.useState(0),S=y.useRef(null),[E,C]=y.useState(()=>document.hidden);y.useEffect(()=>{const L=new Set,F=()=>{var A;if(document.hidden){for(const B of((A=S.current)==null?void 0:A.getAnimations({subtree:!0}))??[])if(B.playState==="running"||B.pending){const D=B.currentTime;B.pause(),D!==null&&(B.currentTime=D),L.add(B)}}else{for(const B of L)B.playState==="paused"&&B.play();L.clear()}C(document.hidden)};return F(),document.addEventListener("visibilitychange",F),()=>document.removeEventListener("visibilitychange",F)},[e,t]);const[$,T]=y.useState(null),[I,O]=y.useState(BI),[U,P]=y.useState(()=>{var L;return((L=window.matchMedia)==null?void 0:L.call(window,"(prefers-reduced-motion: reduce)").matches)??!1});return y.useEffect(()=>{var A;const L=(A=window.matchMedia)==null?void 0:A.call(window,"(prefers-reduced-motion: reduce)");if(!L)return;const F=()=>P(L.matches);return F(),L.addEventListener("change",F),()=>L.removeEventListener("change",F)},[]),y.useEffect(()=>{var J;if(!e||t||U)return;const L=nE(document);let F=0;s(ee=>F=ee);let A=null,B=0,D=0;const K=ee=>{var ae,pe;const[ne,...se]=ee;if(!ne){A=null,d(null),f(null),W();return}d(ne.act),f(ne.prop),k(ne.place??"ledge"),N(ne.riser??0);const ce=F,de=V(ne);if(ne.act==="kick"){const fe=(pe=(ae=S.current)==null?void 0:ae.querySelector('.fm-prop[data-prop="ball"]'))==null?void 0:pe.getBoundingClientRect();fe&&g({x:z9(fe.x,ng(ne,ce,"left"),window.innerWidth),drop:Math.max(48,window.innerHeight-fe.y+24)})}D=ne.act==="walk"?Math.max(Ut(ce,de),_9):ne.ms,ne.act==="carry"&&(D=Ut(ce,de)),i(D),v(fe=>ng({...ne,x:de},ce,fe)),s(de),F=de,A=ne,B=Date.now(),L.schedule(()=>K(se),D)},G=()=>{const ee=S.current,ne=ee==null?void 0:ee.querySelector(".fm-sprite"),se=ee==null?void 0:ee.parentElement;if(!ee||!ne||!se)return null;const ce=ee.getBoundingClientRect(),de=se.getBoundingClientRect(),ae=de.right-ce.right,pe=de.width-ae*2-ne.offsetWidth;return pe>0?pe:null},H=()=>{const ee=S.current,ne=ee==null?void 0:ee.querySelector(".fm-sprite");return!ee||!ne?0:Math.max(0,ee.getBoundingClientRect().width-ne.offsetWidth)},q=()=>{const ee=S.current,ne=ee==null?void 0:ee.querySelector(".fm-walker"),se=G();if(!ee||!ne||se==null)return;const ce=ee.getBoundingClientRect().bottom-ne.getBoundingClientRect().bottom;if(ce>0)return{ledgeH:ce,floorSpan:se,ledgeSpan:H()}},M=()=>{const ee=S.current,ne=document.querySelector(".canvas-notices");if(!ee||!ne)return null;const se=ee.getBoundingClientRect(),ce=ne.getBoundingClientRect();return ce.width<=0||ce.height<=0?null:{left:ce.left-se.right,right:ce.right-se.right,height:ce.height}},V=ee=>{const ne=(ee.place??"ledge")==="floor",se=ne?G()??H():H(),ce=ne&&ee.floorFrac!=null?-Math.round(ee.floorFrac*se):ee.x;return Math.max(-se,Math.min(0,ce))},Z=()=>{if(!A)return;const ee=V(A);ee!==F&&(i(Math.max(0,B+D-Date.now())),v(ne=>ng({...A,x:ee},F,ne)),s(ee),F=ee)},W=()=>{L.schedule(()=>{const ee=H9(F,Math.random,q()),ne=ee.some(de=>de.place==="floor")?M():null;let se=F;const ce=ee.flatMap(de=>{const ae=se;if(se=de.x,!(de.place==="floor"&&de.act==="walk"))return[de];const pe=K9(ae,de.x,ne),fe=pe.length-1;return de.floorFrac==null?pe:pe.map((Ee,ye)=>ye===fe?{...Ee,floorFrac:de.floorFrac}:Ee)});K(ce)},w9(Math.random))},X=(J=S.current)==null?void 0:J.parentElement,Y=typeof ResizeObserver>"u"?null:new ResizeObserver(Z);return X&&Y&&Y.observe(X),W(),()=>{L.dispose(),Y==null||Y.disconnect(),k("ledge"),s(ee=>Math.max(-H(),Math.min(0,ee))),i(0),d(null),f(null),N(0)}},[e,t,U]),y.useEffect(()=>{if(!n||U){T(null);return}const L=nE(document),F=A=>{const B=Z9(A,Math.random);T(B.dance),O(B.beatMs),L.schedule(()=>F(B.dance),J9(Math.random))};return F(null),()=>L.dispose()},[n,U]),{scene:S,suspended:E,x:r,walkMs:o,act:c,prop:h,ballFlight:p,place:w,facing:j,riser:b,dance:$,beatMs:I}}const sg={e:"fm-eye",s:"fm-shade",p:"fm-pad"},bh=Ra().filter(e=>!Gk.has(e.cell)),iV=Ra().filter(e=>Gk.has(e.cell)),rE=bh.filter(e=>e.cell==="e"),lV=Ra(rV),cV=bh.filter(e=>e.y<w0&&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),uV={left:bh.filter(e=>e.y>=w0&&e.x<tE),right:bh.filter(e=>e.y>=w0&&e.x>=tE)},dV=y.memo(function({act:t,facing:n}){return a.jsxs("svg",{viewBox:`0 0 ${eE} ${Q9}`,shapeRendering:"crispEdges","aria-hidden":!0,children:[a.jsx("g",{className:"fm-gear",children:a.jsx("g",{className:"fm-gear-motion",children:iV.map(r=>a.jsx("rect",{x:r.x,y:r.y,width:r.w,height:1,className:sg[r.cell]},`g${r.y}-${r.x}`))})}),a.jsxs("g",{className:"fm-body",children:[rE.map(r=>a.jsx("rect",{x:r.x,y:r.y,width:r.w,height:1,fill:"var(--accent)"},`eye-bed-${r.x}`)),cV.map(r=>a.jsx("rect",{x:r.x,y:r.y,width:r.w,height:1,className:sg[r.cell]},`b${r.y}-${r.x}`)),a.jsxs("g",{className:"fm-arms",children:[a.jsx("rect",{x:4,y:8,width:2,height:2}),a.jsx("rect",{x:12,y:8,width:1,height:2}),a.jsx("rect",{x:13,y:8,width:1,height:2,className:"fm-shade"})]}),rE.map(r=>a.jsx("rect",{x:r.x-(r.x>=eE/2?1:0)+(n==="right"?1:0),y:r.y,width:r.w,height:1,className:"fm-eye"},`eye-${r.x}`))]}),a.jsx("g",{className:"fm-hat",children:lV.map(r=>a.jsx("rect",{x:sV+r.x,y:aV+r.y,width:r.w,height:1,className:r.cell==="k"?"fm-hatband":void 0},`h${r.y}-${r.x}`))}),(t==="climb"||t==="rope-throw"||t==="rope-catch"||t==="pull-up")&&a.jsxs("g",{className:"fm-grip",children:[a.jsx("path",{className:"fm-grip-left",d:qI}),a.jsx("path",{className:"fm-grip-right",d:UI})]}),(t==="land"||t==="dismount")&&a.jsxs("g",{className:"fm-crouch-legs",children:[a.jsx("path",{d:"M6 11H8V13H6Z"}),a.jsx("path",{d:"M10 11H12V13H10Z"})]}),["sit","cast","fish","reel","stow"].includes(t)&&a.jsxs("g",{className:"fm-seated-legs",children:[a.jsx("path",{className:"fm-seated-far",d:"M10 10H12V11H11V14H8V13H9V11H10Z"}),a.jsx("path",{d:"M6 10H9V11H7V15H4V14H5V11H6Z"})]}),["left","right"].map(r=>a.jsx("g",{className:"fm-leg","data-side":r,children:uV[r].map(s=>a.jsx("rect",{x:s.x,y:s.y,width:s.w,height:1,className:sg[s.cell]},`${r}${s.y}-${s.x}`))},r))]})}),hV=["...o........o.....","...of......fo.....","...owffffffwo.....","...offfffffso.....","...ofefffefso.....","....owwnwwso......",".....wwwww........",".....fwwwfs.......","....ffwwwffs...ww.","....ffwwwffs..wfs.","......fwwfssfffs..","......ff..fsffs...","......ff..fs......","......oo..oo......"],fV=[".....aaaaaaa......","...aa.......aa....","..a...........a...","..cp.........pc...","..cp.........pc...","..cp.........pc...","..c...........c..."],Kr={f:"#d88735",s:"#a55b24",o:"#63351e",w:"#ffe2aa",n:"#372821"},pV={p:"fm-pad"},$c=Ra(hV),mV=Ra(fV);function x0(e,t,n){return e.map(r=>({...r,x:Math.max(t,r.x),w:Math.max(0,Math.min(n,r.x+r.w)-Math.max(t,r.x))})).filter(r=>r.w>0)}const gV=x0($c.filter(e=>e.y>=8),12,18),yV=$c.filter(e=>e.y<11&&e.cell!=="e").map(e=>e.y===8||e.y===9?{...e,x:Math.max(6,e.x),w:Math.max(0,Math.min(12,e.x+e.w)-Math.max(6,e.x))}:e.y===10?{...e,w:Math.max(0,Math.min(12,e.x+e.w)-e.x)}:e).filter(e=>e.w>0),sE=$c.filter(e=>e.cell==="e"),wV={left:x0($c.filter(e=>e.y>=11),0,9),right:x0($c.filter(e=>e.y>=11),9,12)},xV=y.memo(function({act:t,facing:n}){const r=t==="climb"||t==="rope-throw"||t==="rope-catch"||t==="pull-up",s=t==="land"||t==="dismount",o=t==="sit"||t==="cast"||t==="fish"||t==="reel"||t==="stow";return a.jsxs("svg",{"data-character":"fox",viewBox:"0 0 18 14",shapeRendering:"crispEdges","aria-hidden":!0,focusable:"false",children:[a.jsx("g",{className:"fm-body","data-part":"tail",children:gV.map(i=>a.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,fill:Kr[i.cell]},`t${i.y}-${i.x}`))}),a.jsx("g",{className:"fm-gear",children:a.jsx("g",{className:"fm-gear-motion",children:mV.map(i=>a.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,className:pV[i.cell]},`g${i.y}-${i.x}`))})}),a.jsxs("g",{className:"fm-body",children:[yV.map(i=>a.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,fill:Kr[i.cell]},`b${i.y}-${i.x}`)),sE.map(i=>a.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,fill:Kr.f},`bed${i.x}`)),a.jsxs("g",{className:"fm-arms",fill:Kr.f,children:[a.jsx("rect",{x:4,y:8,width:2,height:2}),a.jsx("rect",{x:12,y:8,width:1,height:2})]}),sE.map(i=>a.jsx("rect",{x:i.x+(n==="right"?1:0)-(i.x>=9?1:0),y:i.y,width:i.w,height:1,className:"fm-eye",style:{fill:Kr.n}},`e${i.x}`))]}),r&&a.jsxs("g",{className:"fm-grip",style:{fill:Kr.f},children:[a.jsx("path",{className:"fm-grip-left",d:qI}),a.jsx("path",{className:"fm-grip-right",d:UI})]}),s&&a.jsxs("g",{className:"fm-crouch-legs",style:{fill:Kr.f},children:[a.jsx("path",{d:"M6 11H8V13H6Z"}),a.jsx("path",{d:"M10 11H12V13H10Z"})]}),o&&a.jsxs("g",{className:"fm-seated-legs",style:{fill:Kr.f},children:[a.jsx("path",{className:"fm-seated-far",style:{fill:Kr.s},d:"M10 10H12V11H11V14H8V13H9V11H10Z"}),a.jsx("path",{d:"M6 10H9V11H7V15H4V14H5V11H6Z"})]}),["left","right"].map(i=>a.jsx("g",{className:"fm-leg","data-side":i,children:wV[i].map(c=>a.jsx("rect",{x:c.x,y:c.y,width:c.w,height:1,fill:Kr[c.cell]},`${c.y}-${c.x}`))},i))]})}),vV=[".......dddd.......","......dhhhhd......",".....dhhhhhhd.....","....dhwwhhwwhd....","....dhwewwewhd....","....dhwwbbwwhd....","....dhwwwwwwhd....","....dhwwwwwwhd....","....dhwwwwwwhd....",".....dhwwwwhd.....",".....dhwwwwhd.....","......dhhhhd......","......bb..bb......",".....bbb..bbb....."],Ns={d:"#3b4855",h:"#657b8b",w:"#f4f0df",e:"#19242b",b:"#f0b44b",s:"#c88736"},bV={p:"fm-pad"},kh=Ra(vV),kV=Ra(Vk).filter(e=>Gk.has(e.cell)),aE=kh.filter(e=>e.cell==="e"),jV=kh.filter(e=>e.y<12&&e.cell!=="e"),NV={left:kh.filter(e=>e.y>=12&&e.x<9),right:kh.filter(e=>e.y>=12&&e.x>=9)},SV=y.memo(function({act:t}){const n=t==="climb"||t==="rope-throw"||t==="rope-catch"||t==="pull-up",r=t==="land"||t==="dismount",s=t==="sit"||t==="cast"||t==="fish"||t==="reel"||t==="stow";return a.jsxs("svg",{"data-character":"penguin",viewBox:"0 0 18 14",shapeRendering:"crispEdges","aria-hidden":!0,focusable:"false",children:[a.jsx("g",{className:"fm-gear",children:a.jsx("g",{className:"fm-gear-motion",children:kV.map(o=>a.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,className:bV[o.cell]},`g${o.y}-${o.x}`))})}),a.jsxs("g",{className:"fm-body",children:[jV.map(o=>a.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,fill:Ns[o.cell]},`b${o.y}-${o.x}`)),aE.map(o=>a.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,fill:Ns.w},`bed${o.x}`)),a.jsxs("g",{className:"fm-arms",fill:Ns.d,children:[a.jsx("path",{d:"M4 8H6V10H5V11H4Z"}),a.jsx("path",{d:"M12 8H14V11H13V10H12Z"})]}),aE.map(o=>a.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,className:"fm-eye",style:{fill:Ns.e}},`e${o.x}`))]}),n&&a.jsxs("g",{className:"fm-grip",style:{fill:Ns.h},children:[a.jsx("path",{className:"fm-grip-left",d:"M5 10H4V4H5V2H6V1H7V0H9V2H7V3H6V10Z"}),a.jsx("path",{className:"fm-grip-right",d:"M12 10H14V6H13V3H11V2H9V4H12Z"})]}),r&&a.jsxs("g",{className:"fm-crouch-legs",style:{fill:Ns.b},children:[a.jsx("path",{d:"M5 12H8V13H5Z"}),a.jsx("path",{d:"M10 12H13V13H10Z"})]}),s&&a.jsxs("g",{className:"fm-seated-legs",style:{fill:Ns.b},children:[a.jsx("path",{className:"fm-seated-far",style:{fill:Ns.s},d:"M10 11H12V12H13V14H10V13H11V12H10Z"}),a.jsx("path",{d:"M6 11H8V12H7V13H8V14H4V13H5V12H6Z"})]}),["left","right"].map(o=>a.jsx("g",{className:"fm-leg","data-side":o,children:NV[o].map(i=>a.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,fill:Ns.b},`${i.y}-${i.x}`))},o))]})});function HI({character:e,act:t,facing:n}){return e==="penguin"?a.jsx(SV,{act:t,facing:n}):e==="fox"?a.jsx(xV,{act:t,facing:n}):a.jsx(dV,{act:t,facing:n})}const _V={"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 WI(e,t){return t&&Ki(t.id)===e?t.name:pf(e)?"Custom FM":_V[e]}function ag(e,t){var r;const n=((r=e[0])==null?void 0:r.length)??0;return a.jsx("svg",{viewBox:`0 0 ${n} ${e.length}`,shapeRendering:"crispEdges","aria-hidden":!0,children:Ra(e).map(s=>a.jsx("rect",{x:s.x,y:s.y,width:s.w,height:1,fill:s.cell==="s"?"var(--fm-prop-shadow, var(--bg))":s.cell==="l"?"var(--fm-prop-light, var(--text))":s.cell==="a"?"var(--accent)":void 0},`${t}${s.y}-${s.x}`))})}const oE={litter:ag(rg.litter,"litter"),ball:ag(rg.ball,"ball"),scope:ag(rg.scope,"scope")};function EV(e){try{return new URL(e).host}catch{return"the station's server"}}const CV=y.memo(function({player:t,source:n,customStation:r,character:s="deck"}){const{probe:o,dead:i,playing:c,press:d}=t,{scene:h,suspended:f,x:p,walkMs:g,act:w,prop:k,ballFlight:j,place:v,facing:b,riser:N,dance:S,beatMs:E}=oV(o,i,c);if(!o||i)return null;const C=WI(n,r),$=o.audio?EV(o.audio):"YouTube";return a.jsxs("div",{ref:h,className:"fm","data-suspended":f?"":void 0,"data-place":v,style:{"--fm-beat":`${E}ms`},children:[k&&!k.held&&a.jsx("div",{className:"fm-prop","data-prop":k.kind,"data-leaving":k.leaving?"":void 0,style:{"--fm-prop-x":`${k.at}px`,"--fm-roll-to":`${j.x}px`,"--fm-ball-drop":`${j.drop}px`,"--fm-ball-flight-ms":`${PI}ms`,"--fm-ball-turn":b==="right"?"1080deg":"-1080deg"},children:oE[k.kind]}),(w==="lasso"||w==="rope-throw"||w==="rope-catch"||w==="climb"||w==="pull-up")&&a.jsxs("div",{className:"fm-rope","data-act":w,style:{"--fm-rope-x":`${p}px`,"--fm-rope-ms":`${g}ms`},children:[a.jsx("div",{className:"fm-rope-line"}),a.jsxs("svg",{className:"fm-rope-hook",viewBox:"0 0 9 9",shapeRendering:"crispEdges","aria-hidden":!0,children:[a.jsx("path",{d:"M4 8V3H3V1H1V3H0V5H2V4H3V6H5V4H6V5H8V3H7V1H5V3H4"}),a.jsx("rect",{className:"fm-rope-knot",x:"3",y:"6",width:"3",height:"2"})]})]}),a.jsxs("div",{className:"fm-walker","data-act":w??void 0,"data-place":v,"data-facing":b,style:{"--fm-x":`${p}px`,"--fm-walk-ms":`${g}ms`,"--fm-riser":`${N}px`,"--fm-skip-beat":`${DI}ms`},children:[(k==null?void 0:k.held)&&a.jsx("div",{className:"fm-held","data-prop":k.kind,"data-toss":k.leaving?"":void 0,children:oE[k.kind]}),["cast","fish","reel","stow"].includes(w)&&a.jsxs("svg",{className:"fm-fishing",viewBox:"0 0 24 32",shapeRendering:"crispEdges","aria-hidden":!0,children:[a.jsxs("g",{children:[a.jsx("path",{d:"M24 11H22V9H20V7H18V5H16V3H13V2H8"}),a.jsx("rect",{className:"fm-fishing-grip",x:"21",y:"9",width:"3",height:"3"})]}),a.jsxs("g",{className:"fm-fishing-line",children:[a.jsx("path",{d:"M8 2V26"}),a.jsxs("g",{className:"fm-float",children:[a.jsx("rect",{x:"7",y:"25",width:"3",height:"2"}),a.jsx("rect",{x:"8",y:"24",width:"1",height:"1"})]})]}),a.jsx("path",{className:"fm-ripple",d:"M3 28H6M10 28H14M5 30H12"})]}),["skip-ready","skip","skip-rest"].includes(w)&&a.jsxs("svg",{className:"fm-skipping-rope",viewBox:"0 0 26 26",shapeRendering:"crispEdges","aria-hidden":!0,children:[a.jsx("path",{className:"fm-skip-back",d:"M5 18H3V8H5V5H8V2H18V5H21V8H23V18H21"}),a.jsx("path",{className:"fm-skip-forward",d:"M5 18H3V14H5V11H8V9H18V11H21V14H23V18H21"}),a.jsx("path",{className:"fm-skip-front",d:"M5 18H3V21H5V23H8V25H18V23H21V21H23V18H21"}),a.jsx("path",{className:"fm-skip-return",d:"M5 18H3V19H8V20H18V19H23V18H21"}),a.jsx("path",{className:"fm-skip-handles",d:"M5 17V19M21 17V19"})]}),a.jsx("button",{type:"button",className:"fm-sprite","data-playing":c?"":void 0,"data-dance":c?S??FI[0]:void 0,onClick:d,title:c?`Stop ${C}`:`Play ${C} — streams from ${$}`,"aria-label":c?`Stop ${C}`:`Play ${C}`,children:a.jsx(HI,{character:s,act:w,facing:b})})]})]})});function TV({player:e,label:t}){const{probe:n,armed:r,frame:s,say:o}=e;return n?a.jsx(a.Fragment,{children:r&&!n.audio&&(n.channel||n.video)&&a.jsx("iframe",{ref:s,className:"fm-frame",title:t,src:r9(n.channel,window.location.origin,n.video),onLoad:()=>o(s9()),allow:"autoplay; encrypted-media",sandbox:"allow-scripts allow-same-origin allow-presentation"})}):null}const RV={radio:"M4 8h16v12H4z M7 8l10-5 M7 12h5 M15 12h2 M7 16h2 M13 16h4",play:"M8 5l11 7-11 7z",pause:"M8 5v14 M16 5v14",shuffle:"M3 6h3c5 0 7 12 12 12h3 M17 14l4 4-4 4 M3 18h3c2 0 4-3 6-6s4-6 6-6h3 M17 2l4 4-4 4",heart:"M20.8 4.6a5.5 5.5 0 0 0-7.8 0L12 5.7l-1.1-1.1a5.5 5.5 0 0 0-7.8 7.8L12 21l8.8-8.6a5.5 5.5 0 0 0 0-7.8z",close:"M6 6l12 12 M6 18L18 6",search:"M10.5 3a7.5 7.5 0 1 0 0 15 7.5 7.5 0 0 0 0-15 M16 16l5 5",globe:"M12 2a10 10 0 1 0 0 20 10 10 0 0 0 0-20 M2 12h20 M12 2c-6 6-6 14 0 20 M12 2c6 6 6 14 0 20",back:"M16 5l-7 7 7 7",previous:"M5 5v14 M19 5l-10 7 10 7z",next:"M19 5v14 M5 5l10 7-10 7z",volume:"M11 4L6 8H3v8h3l5 4z M15 8a6 6 0 0 1 0 8 M18 5a10 10 0 0 1 0 14",muted:"M11 4L6 8H3v8h3l5 4z M16 9l6 6 M16 15l6-6",headphones:"M4 14v-3a8 8 0 0 1 16 0v3 M4 12h3v8H5a2 2 0 0 1-2-2v-4a2 2 0 0 1 1-2 M20 12h-3v8h2a2 2 0 0 0 2-2v-4a2 2 0 0 0-1-2",book:"M12 6v15 M12 6C9 4 6 3 3 4v15c3-1 6 0 9 2 3-2 6-3 9-2V4c-3-1-6 0-9 2",gamepad:"M8 7h8c3 0 4 2 5 8 1 5-2 6-5 2H8c-3 4-6 3-5-2 1-6 2-8 5-8z M6 11h4 M8 9v4 M16 10h.01 M18 13h.01",sunset:"M3 17h18 M5 21h14 M7 17a5 5 0 0 1 10 0 M12 3v3 M4 8l2 2 M20 8l-2 2",moon:"M20 14A9 9 0 0 1 10 3a9 9 0 1 0 10 11z",cassette:"M5 4h14a2 2 0 0 1 2 2v12a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2z M7 8h10v5H7z M7 20l2-4h6l2 4 M9 10.5h.01 M15 10.5h.01",palm:"M12 8c2 4 3 8 2 13 M12 8C8 3 4 4 2 8c4-1 7-1 10 0 M12 8c1-6 6-7 10-2-4-1-7 0-10 2 M12 8c-5 0-7 3-7 7 2-3 4-5 7-7 M12 8c4 0 7 3 7 7-2-3-4-5-7-7 M10 21h8",coffee:"M4 8h12v8a4 4 0 0 1-4 4H8a4 4 0 0 1-4-4z M16 9h2a3 3 0 0 1 0 6h-2 M7 3v2 M11 3v2 M3 22h15",check:"M5 12l4 4L19 6",filters:"M4 6h4 M12 6h8 M4 12h10 M18 12h2 M4 18h2 M10 18h10 M8 4v4 M14 10v4 M6 16v4"};function AV({name:e}){return a.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:a.jsx("path",{d:RV[e]})})}function MV({opening:e=!1}){const[t,n]=y.useState(()=>document.hidden);return y.useEffect(()=>{const r=()=>n(document.hidden);return document.addEventListener("visibilitychange",r),()=>document.removeEventListener("visibilitychange",r)},[]),a.jsxs("div",{className:"radio-tuning",role:"status","data-paused":t||void 0,children:[a.jsxs("svg",{className:"radio-tuning-art",viewBox:"0 0 240 112",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[a.jsxs("g",{className:"radio-tuning-tower",children:[a.jsx("circle",{cx:"40",cy:"24",r:"4"}),a.jsx("path",{d:"M40 28v60 M40 36L24 88h32L40 36 M31 66h18 M28 77h24 M20 92h40"}),a.jsx("path",{d:"M29 17a15 15 0 0 0 0 14 M51 17a15 15 0 0 1 0 14"})]}),a.jsxs("g",{className:"radio-tuning-send",children:[a.jsx("path",{d:"M75 26q7 8 0 16"}),a.jsx("path",{d:"M102 26q7 8 0 16"}),a.jsx("path",{d:"M129 26q7 8 0 16"})]}),a.jsxs("g",{className:"radio-tuning-receiver",children:[a.jsx("path",{d:"M165 49l30-22"}),a.jsx("rect",{x:"154",y:"49",width:"66",height:"43",rx:"7"}),a.jsx("path",{d:"M161 92v3 M213 92v3 M163 60h17 M163 66h17 M163 72h17 M163 78h17"}),a.jsx("circle",{cx:"202",cy:"65",r:"7"}),a.jsx("path",{d:"M202 62v3l3 2 M197 81h10"})]})]}),a.jsx("strong",{children:e?"Opening Radio":"Tuning into the world"}),a.jsx("span",{children:e?"Getting your explorer ready…":"Finding stations…"})]})}function $V({onClose:e}){const[t]=y.useState(()=>{var r;return((r=document.activeElement)==null?void 0:r.matches(":focus-visible"))??!1}),n=ot(e);return a.jsxs("div",{ref:n,className:"radio-loading nodrag nopan",role:"dialog","aria-modal":"true","aria-label":"Opening Radio","data-keyboard-interaction":t||void 0,onKeyDown:pz,children:[a.jsx("button",{type:"button",className:"icon-btn","aria-label":"Close radio",onClick:e,children:a.jsx(AV,{name:"close"})}),a.jsx(MV,{opening:!0})]})}const LV=y.lazy(()=>Jc(()=>import("./RadioPanel-bJc004IK.js"),[]));function OV({fm:e,characterEnabled:t,character:n,open:r,onClose:s}){const[o,i]=y.useState(!1),[c,d]=y.useState("Connecting to the deck…"),h=p9(),[f,p]=y.useState(null),g=y.useRef(new Set);y.useEffect(()=>{const T=new AbortController;return fetch("/api/music-config",{signal:T.signal}).then(I=>I.ok?I.json():null).then(I=>{T.signal.aborted||(i((I==null?void 0:I.enabled)===!0),d(I?"Music is turned off on this deck.":"Cannot reach the deck. Reopen Radio when it reconnects."))}).catch(()=>{T.signal.aborted||d("Cannot reach the deck. Reopen Radio when it reconnects.")}),()=>T.abort()},[r]);const w=e.customFmStations.find(T=>Ki(T.id)===e.fmSource),k=w!=null&&w.radio?w:void 0,j=d9({volume:e.fmVolume,muted:e.fmMuted,source:e.fmSource,playRequest:e.fmPlayRequest,customStation:w,enabled:o,onAvailabilityChange:e.markFmStationAvailability}),v=WI(e.fmSource,w),b=o&&k&&j.dead&&e.fmPlayRequest>0?OI(f??h.catalogue,k.id,g.current):null,{remember:N}=h,S=(w==null?void 0:w.id)??e.fmSource;y.useEffect(()=>{j.playing&&N(S)},[S,j.playing,N]);const E=s,C=dt(s),$=y.useCallback((T,I=!1)=>{var L;if(!o)return;I||g.current.clear();const O=Ki(T.id),U=O===e.fmSource;if(U&&j.armed&&!j.dead){j.press();return}const P=U&&!!w&&(w.url!==T.url||((L=w.radio)==null?void 0:L.hls)!==T.radio.hls);e.addFmStation(T,!0),U&&!j.dead&&!P?j.press():e.pickFmSource(O,P),fetch(`/api/radio-click?id=${encodeURIComponent(T.id)}`).catch(()=>{})},[o,w,e.addFmStation,e.fmSource,e.pickFmSource,j.armed,j.dead,j.press]);return y.useEffect(()=>{j.playing&&!j.dead&&g.current.clear()},[j.playing,j.dead]),y.useEffect(()=>{if(!(!o||!k||!j.dead||e.fmPlayRequest===0))return m9(f??h.catalogue,k.id,g.current,T=>$(T,!0))},[o,k==null?void 0:k.id,j.dead,e.fmPlayRequest,f,h.catalogue,$]),a.jsxs(a.Fragment,{children:[t&&a.jsx(CV,{character:n,player:j,source:e.fmSource,customStation:w}),a.jsx(TV,{player:j,label:v}),r&&yt.createPortal(a.jsx("div",{className:"modal-backdrop radio-backdrop",...C,children:a.jsx(y.Suspense,{fallback:a.jsx($V,{onClose:E}),children:a.jsx(LV,{fm:e,player:j,library:h,selected:k,label:v,enabled:o,disabledReason:c,autoNext:b==null?void 0:b.name,onPick:$,onQueueChange:p,onClose:E})})}),document.body)]})}function zI(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 v0(e){return zI(Math.floor(e/1e3))}function Qc(e,t){const n=e-t;if(n<=0)return null;const r=Math.floor(n/86400),s=Math.floor(n%86400/3600),o=Math.floor(n%3600/60);return r>0?`${r}d ${s}h`:s>0?`${s}h ${o}m`:`${o}m`}function IV(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=v0(t-e);return{label:IV(r,new Date(t))?s:`${s} · ${r.toLocaleDateString(n,{month:"short",day:"numeric"})}`,title:r.toLocaleString(n,{dateStyle:"medium",timeStyle:"medium"})}}function PV({data:e}){const t=Ao(3e4),n=e.note,r=n.kind==="recap",s=jh(n.at,t),o=r?"recap-note":`recap-note is-status status-${n.kind}`,i=r?void 0:hf(n);return a.jsxs("div",{className:o,role:"note","aria-label":r?"Claude Code's recap":`Session note: ${ja(n.kind)}`,"aria-description":i,style:{"--session-hue":e.hue},children:[a.jsxs("div",{className:"recap-note-head",title:i,children:[a.jsxs("span",{className:"recap-note-mark",children:[a.jsx(xh,{recap:r}),ja(n.kind)]}),a.jsx("span",{className:"recap-note-age",title:s.title,children:s.label}),a.jsx("button",{type:"button",className:"glyph-btn recap-note-close","aria-label":r?"Hide the recap":"Hide this note",title:"Hide — the mark on the card brings it back",onClick:c=>{c.stopPropagation(),Pz(e.noteKey)},children:"×"})]}),a.jsx("p",{className:"recap-note-text",title:Kz(n.text,i),children:n.text}),n.reply&&a.jsxs("p",{className:"recap-note-reply",title:`suggested reply “${n.reply}”`,children:["suggested reply “",n.reply,"”"]}),a.jsxs("div",{className:"lod-face recap-face","aria-hidden":!0,children:[a.jsxs("div",{className:"lod-id",children:[a.jsxs("span",{className:"recap-note-mark",children:[a.jsx(xh,{recap:r}),ja(n.kind)]}),a.jsx("span",{className:"recap-face-age",children:s.label})]}),a.jsx("p",{className:"recap-face-text",children:n.text})]}),a.jsx(So,{type:"source",position:Le.Right,style:{background:"transparent",border:"none"}})]})}function gf(){var t;return typeof navigator>"u"?"":((t=navigator.userAgentData)==null?void 0:t.platform)||navigator.platform||""}function yf(e){return/mac|iphone|ipad/i.test(e)}const Nh=e=>new Map([...e].map(([t,n])=>[t,{x:n.x,y:n.y}]));function DV(e,t,n){return{positions:Nh(e.positions),pinned:Nh(e.pinned),provisional:new Set(e.provisional),layoutSig:e.layoutSig.current,stored:{...t},viewport:n?{...n}:null}}function FV(e,t){t.positions.clear();for(const[n,r]of Nh(e.positions))t.positions.set(n,r);t.pinned.clear();for(const[n,r]of Nh(e.pinned))t.pinned.set(n,r);t.provisional.clear();for(const n of e.provisional)t.provisional.add(n);t.layoutSig.current=e.layoutSig}const iE=7e3,BV=2e3,qV=140,UV="Layout re-arranged",HV="Layout re-arranged. Undo available.",lE="Layout restored.",WV={set:(e,t)=>setTimeout(e,t),clear:e=>clearTimeout(e),now:()=>Date.now()};function zV(e,t=WV){let n=null,r=null,s=0,o=iE;const i=new Set,c=()=>{r!==null&&t.clear(r),r=null},d=()=>{c(),!(n===null||i.size>0)&&(s=t.now()+o,r=t.set(()=>{r=null,h()},o))};function h(){c(),i.clear(),n!==null&&(n=null,e(!1))}return{open(f){const p=n===null;n=f,o=iE,d(),p&&e(!0)},take(){const f=n;return h(),f},close:h,hold(f){n!==null&&(i.size===0&&r!==null&&(o=Math.max(0,s-t.now()),c()),i.add(f))},release(f){!i.delete(f)||i.size>0||n===null||(o=Math.max(o,BV),d())},get isOpen(){return n!==null},get snapshot(){return n}}}function VV(e){return(e.key==="z"||e.key==="Z")&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey}function GV(e){return yf(e)?"⌘Z":"Ctrl+Z"}function KV({undo:e}){const{open:t,said:n,undo:r,dismiss:s,hold:o,release:i}=e,c=Ei(t,qV),d=y.useRef(null);return y.useEffect(()=>t?jn.push(s,0,"popover"):void 0,[t,s]),y.useEffect(()=>{var f;if(t)return;const h=d.current;h&&h.contains(document.activeElement)&&((f=h.closest("main"))==null||f.focus({preventScroll:!0}))},[t]),a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:n}),xa(c)&&a.jsxs("div",{ref:d,className:c==="leaving"?"rearrange-undo leaving":"rearrange-undo",onPointerEnter:()=>o("hover"),onPointerLeave:()=>i("hover"),onFocus:()=>o("focus"),onBlur:h=>{h.currentTarget.contains(h.relatedTarget)||i("focus")},children:[a.jsx("span",{id:"rearrange-undo-state",className:"rearrange-undo-state",children:UV}),a.jsxs("button",{type:"button",className:"rearrange-undo-act",onClick:r,"aria-describedby":"rearrange-undo-state","aria-keyshortcuts":"Meta+Z Control+Z",children:["Undo",a.jsx("span",{className:"rearrange-undo-key","aria-hidden":"true",children:GV(gf())})]})]})]})}function YV({sourceX:e,sourceY:t,targetX:n,targetY:r,sourcePosition:s,targetPosition:o,style:i}){const[c]=_k({sourceX:e,sourceY:t,sourcePosition:s,targetX:n,targetY:r,targetPosition:o,curvature:.35});return a.jsxs("g",{className:"recap-tie",style:i,children:[a.jsx("path",{className:"recap-tie-thread",d:c,vectorEffect:"non-scaling-stroke"}),a.jsx("path",{className:"recap-tie-beads",d:c,vectorEffect:"non-scaling-stroke"}),a.jsx("circle",{className:"recap-tie-end",cx:e,cy:t,r:3.5}),a.jsx("circle",{className:"recap-tie-end",cx:n,cy:r,r:3.5})]})}function b0(e){return e.replace(/[^a-zA-Z0-9]/g,"")}function Sh(e,t){const n=b0(e);return n?n.slice(-t):e.slice(-t)}function VI(e,t,n=4){const r=b0(e);if(!r)return Sh(e,n);let s=n;for(const o of t){if(o===e)continue;const i=b0(o);let c=0;for(;c<r.length&&c<i.length&&r[r.length-1-c]===i[i.length-1-c];)c++;s=Math.max(s,c+1)}return r.slice(-s)}const mc=" · ",XV=32,ZV=/[\u1100-\u115F\u2E80-\u303E\u3041-\u33FF\u3400-\u4DBF\u4E00-\u9FFF\uA000-\uA4CF\uAC00-\uD7A3\uF900-\uFAFF\uFE30-\uFE6F\uFF00-\uFF60\uFFE0-\uFFE6]/;function cE(e){return ZV.test(e)?2:1}function uE(e,t=XV){const n=[...e];let r=0;for(const i of n)r+=cE(i);if(r<=t)return e;const s=[];let o=0;for(const i of n){const c=cE(i);if(o+c>t-1)break;s.push(i),o+=c}for(;s.length&&/[\s\-_.:/]/.test(s[s.length-1]);)s.pop();return`${s.join("")}…`}function JV(e,t,n,r,s=[],{branch:o,alarm:i=!1}={}){const c=(t==null?void 0:t.trim())??"",d=r?VI(n,s):void 0,h=[e,c||void 0,d].filter(Boolean),f=[e,o,c||void 0,d].filter(Boolean).join(mc);return{label:uE(e),name:c?uE(c):void 0,shortId:d,fullLabel:h.join(mc),title:`${i?"waiting on you: ":""}${f}
|
|
83
|
-
Zoom to this session
|
|
84
|
-
drag the wrapper to move the whole session`}}const mo=18,k0=26,Kk=12,QV=240,GI=16;function KI(e,t){return(e+QV)*(t||1)}function eG(e,t){return{position:"absolute",left:0,top:0,transform:`translate(${e.x}px, ${e.y}px)`,width:e.w,height:e.h,"--session-hue":t}}function tG(e,t,n,r){return{position:"absolute",left:e.x+GI,top:e.y-Kk/(t||1),transform:`scale(${1/(t||1)})`,transformOrigin:"left top",maxWidth:r??KI(e.w,t),"--session-hue":n}}function nG(e){const t=new Map;for(const s of e){if(s.type!=="agent"&&s.type!=="recapNote")continue;const o=s.data;if(!(o!=null&&o.sessionId)||o.exitAt!=null||s.width==null||s.height==null)continue;const i=s.position.x,c=s.position.y,d=i+s.width,h=c+s.height,f=t.get(o.sessionId),p=rG(o);f?(f.minX=Math.min(f.minX,i),f.minY=Math.min(f.minY,c),f.maxX=Math.max(f.maxX,d),f.maxY=Math.max(f.maxY,h),p&&(f.label=p.label??f.label,f.name=p.name,f.alarm=p.alarm,f.branch=p.branch)):t.set(o.sessionId,{minX:i,minY:c,maxX:d,maxY:h,label:(p==null?void 0:p.label)??o.sessionId,name:p==null?void 0:p.name,alarm:(p==null?void 0:p.alarm)??!1,branch:p==null?void 0:p.branch})}const n=new Map;for(const[s,o]of t){const i=n.get(o.label);i?i.push(s):n.set(o.label,[s])}const r=[];for(const[s,o]of t){const i=n.get(o.label)??[],c=i.length>1;r.push({sessionId:s,...JV(o.label,o.name,s,c,i,{branch:o.branch,alarm:o.alarm}),x:o.minX-mo,y:o.minY-mo-k0,w:o.maxX-o.minX+mo*2,h:o.maxY-o.minY+mo*2+k0,...o.alarm?{alarm:!0}:null,...o.branch?{branch:o.branch}:null})}return r}function rG(e){if(e.kind!=="root")return null;const t=e.branch;return{label:e.label,name:Dk(e.sessionName,e.sessionTitle).face,alarm:Hn(e.waiting),branch:t&&t.total>0?xI(t):void 0}}function sG(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){const r=e[n],s=t[n];if(r.sessionId!==s.sessionId||r.label!==s.label||r.name!==s.name||r.shortId!==s.shortId||r.alarm!==s.alarm||r.branch!==s.branch||r.fullLabel!==s.fullLabel||r.title!==s.title||r.x!==s.x||r.y!==s.y||r.w!==s.w||r.h!==s.h)return!1}return!0}const aG=20,Ss=4,oG=64,iG=".cat-filter-bar, .react-flow__panel, .autofit-chip, .rearrange-undo, .usage-panel, .sysdetail, .detail";function lG(e,t,n,r){const s=t.zoom||1,o=KI(e.w,s);if(n.width<=0||n.height<=0)return{maxWidth:o,hidden:!1};const i=(e.x+GI)*s+t.x,c=e.y*s+t.y-Kk,d=c+aG;let h=Math.min(o,n.width-Ss-i),f=i<Ss||c<Ss||d>n.height-Ss;for(const p of r)if(!(p.top-Ss>=d||p.bottom+Ss<=c)&&!(p.right+Ss<=i)){if(p.left-Ss<=i){f=!0;break}h=Math.min(h,p.left-Ss-i)}return h<oG&&(f=!0),{maxWidth:Math.max(0,h),hidden:f}}function cG(e){const t=e.getBoundingClientRect(),n=[];for(const r of e.ownerDocument.querySelectorAll(iG)){const s=r.getBoundingClientRect(),o=Math.max(s.left,t.left)-t.left,i=Math.max(s.top,t.top)-t.top,c=Math.min(s.right,t.right)-t.left,d=Math.min(s.bottom,t.bottom)-t.top;c-o<1||d-i<1||n.push({left:Math.round(o),top:Math.round(i),right:Math.round(c),bottom:Math.round(d)})}return n}function uG(e,t){return e.length===t.length&&e.every((n,r)=>{const s=t[r];return n.left===s.left&&n.top===s.top&&n.right===s.right&&n.bottom===s.bottom})}const dG=500;function YI({focus:e,setTimeout:t,clearTimeout:n,ms:r=dG}){let s=null;const o=()=>{s!==null&&(n(s),s=null)};return{hold(i){o(),s=t(()=>{s=null;try{e(i)}catch{}},r)},cancel:o}}function hG(e){return nG(e.nodeInternals.values())}const fG=e=>e.width,pG=e=>e.height,mG=e=>{var t;return((t=e.domNode)==null?void 0:t.querySelector(".react-flow__viewport"))??null};function gG({onFocusSession:e}){const{x:t,y:n,zoom:r}=xO(),s=Qe(hG,sG),o=Qe(fG),i=Qe(pG),c={width:o,height:i},d=y.useRef(null),h=Qe(mG),[f,p]=y.useState([]);y.useLayoutEffect(()=>{var $;const S=($=d.current)==null?void 0:$.parentElement;if(!S)return;const E=cG(S),C=requestAnimationFrame(()=>{p(T=>uG(T,E)?T:E)});return()=>cancelAnimationFrame(C)});const g=y.useRef(e);g.current=e;const[w]=y.useState(()=>YI({focus:S=>{var E;return(E=g.current)==null?void 0:E.call(g,S)},setTimeout:(S,E)=>window.setTimeout(S,E),clearTimeout:S=>window.clearTimeout(S)}));if(y.useEffect(()=>()=>w.cancel(),[w]),s.length<=1)return null;const k=S=>{try{e==null||e(S)}catch{}},j=(S,E)=>{S.detail>0&&Yc()?w.hold(E):k(E)},v={transform:`translate(${t}px, ${n}px) scale(${r})`},b=a.jsx("div",{className:"session-clusters",style:v,ref:d,children:s.map(S=>{const E=Rc(S.sessionId),C=eG(S,E);return a.jsx("div",{className:"cluster-card",style:C,"aria-hidden":!0},S.sessionId)})}),N=h&&yt.createPortal(a.jsx("div",{className:"cluster-labels nopan",children:s.map(S=>{const E=Rc(S.sessionId),C=lG(S,{x:t,y:n,zoom:r},c,f),$=tG(S,r,E,C.maxWidth);return a.jsxs("button",{type:"button",className:"cluster-label","data-alarm":S.alarm?"":void 0,"data-offpane":C.hidden?"":void 0,style:$,title:S.title,onClick:T=>j(T,S.sessionId),children:[S.alarm?a.jsxs(a.Fragment,{children:[a.jsx(Hk,{}),a.jsx("span",{className:"cluster-label-said",children:"waiting on you: "})]}):null,S.label,S.branch?a.jsx("span",{className:"cluster-label-branch",children:mc+S.branch}):null,S.name?a.jsx("span",{className:"cluster-label-name",children:mc+S.name}):null,S.shortId?a.jsx("span",{className:"cluster-label-id",children:mc+S.shortId}):null]},S.sessionId)})}),h);return a.jsxs(a.Fragment,{children:[b,N]})}function yG({data:e}){return a.jsx("div",{className:"session-group-handle",style:{width:(e==null?void 0:e.w)??0,height:(e==null?void 0:e.h)??0}})}const XI=600,wG=4,xG=36,_h=14,vG=60,bG=6,dE=220,kG=96,jG=28;function NG(e,t){return Math.max(kG,61+[...t].length*6.8)}function SG(e){return e.endedAt==null?"inflight":e.ok===!1?"err":"done"}function _G(e,t){if(t==null)return 1;const n=e-t;return n<0?1:Math.max(0,1-n/XI)}function EG(e,t){const n=[],r=new Set;for(let s=e.length-1;s>=0&&n.length<t;s--){const o=e[s];r.has(o.id)||(r.add(o.id),n.push(o))}return n.reverse()}function CG(e,t,n,r,s,o){const i=[];for(const c of e.values()){if(!t.has(c.id)||c.exitAt!=null&&o-c.exitAt>XI)continue;const d=r.get(c.id)??n.get(c.id);if(!d)continue;const h=EG(c.tools,wG);if(h.length===0)continue;const f=c.exitAt??null,p=s.get(c.id),g=Math.max((p==null?void 0:p.width)??dE,dE),w=(p==null?void 0:p.height)??130,k=d.x,j=d.y,v=k+g,b=j+w/2;h.forEach((N,S)=>{const E=S*xG,C=k+g+vG,$=j+bG+E,T=_G(o,f),I=N.inputPreview??"",O=SG(N),U=T<.999,P=Uk(N.name);i.push({id:`${c.id}::${N.id}`,toolId:N.id,agentId:c.id,toolName:N.name,name:P.label,emoji:P.emoji,status:O,category:vI(N.name),mcpHue:P.hue,inputPreview:I,fade:T,fading:U,worldX:C,worldY:$,anchorX:v,anchorY:b,spawnDx:v-C,spawnDy:b-($+_h)});const L=NI(N.name,N.input);if(L){const F=NG(N.name,P.label),A=C+F+jG,B=$,D=C+F,K=$+_h;i.push({id:`sub:${c.id}::${N.id}`,toolId:N.id,agentId:c.id,toolName:N.name,name:k7(L.label,L.category),fullName:L.label,emoji:L.emoji,isSub:!0,status:O,category:L.category,inputPreview:L.detail??I,fade:T,fading:U,worldX:A,worldY:B,anchorX:D,anchorY:K,spawnDx:D-A,spawnDy:0})}})}return i}function TG({agents:e,visibleAgentIds:t,positions:n,pinned:r,measured:s,spotlight:o,hiddenCategories:i,now:c,onOpenTool:d}){const h=CG(e,t,n,r,s,c),f=i&&i.size>0?h.filter(p=>!i.has(p.category)):h;return a.jsx(RG,{bursts:f,spotlight:o,onOpenTool:d})}function RG({bursts:e,spotlight:t,onOpenTool:n}){const r=e.map(o=>{const i=o.anchorX,c=o.anchorY,d=o.worldX+6,h=o.worldY+_h,f=Math.max(1,d-i),p=Math.min(1,Math.abs(h-c)/f),g=i+f*(.55-.22*p),w=c+(h-c)*.12,k=d-f*.25,j=t!=null&&!t.has(o.agentId),v=o.fade*(j?.14:1);return a.jsx("path",{d:`M ${i} ${c} C ${g} ${w}, ${k} ${h}, ${d} ${h}`,className:`tool-conn status-${o.status}${o.fading?" fading":""}`,opacity:v,vectorEffect:"non-scaling-stroke"},`l:${o.id}`)}),s=e.map(o=>a.jsx($G,{b:o,dim:t!=null&&!t.has(o.agentId),onOpenTool:n},o.id));return a.jsx(AG,{connectors:r,bubbles:s})}function AG({connectors:e,bubbles:t}){const{x:n,y:r,zoom:s}=xO();return a.jsxs("div",{className:"tool-bursts-layer","aria-hidden":!0,style:{"--tool-burst-height":`${2*_h}px`},children:[a.jsx("svg",{className:"tool-bursts-svg",children:a.jsx("g",{transform:`translate(${n} ${r}) scale(${s})`,children:e})}),a.jsx("div",{className:"tool-bursts-world",style:{transform:`translate(${n}px, ${r}px) scale(${s})`},children:t})]})}function MG(e,t){const n=e.b,r=t.b;return e.dim===t.dim&&e.onOpenTool===t.onOpenTool&&n.id===r.id&&n.toolId===r.toolId&&n.worldX===r.worldX&&n.worldY===r.worldY&&n.spawnDx===r.spawnDx&&n.spawnDy===r.spawnDy&&n.status===r.status&&n.fading===r.fading&&n.category===r.category&&n.mcpHue===r.mcpHue&&n.isSub===r.isSub&&n.emoji===r.emoji&&n.name===r.name&&n.fullName===r.fullName&&n.toolName===r.toolName&&n.inputPreview===r.inputPreview}const $G=y.memo(function({b:t,dim:n,onOpenTool:r}){const s={left:`${t.worldX}px`,top:`${t.worldY}px`,"--spawn-dx":`${t.spawnDx}px`,"--spawn-dy":`${t.spawnDy}px`},o=t.isSub?`${t.toolName} · ${t.fullName??t.name}`:t.toolName,i=t.inputPreview?`${o} · ${t.inputPreview}`:o,c=r!=null,d=t.mcpHue!=null?{"--mcp-hue":t.mcpHue}:{},h=n?" dim":"";return a.jsx("div",{className:"tool-burst-wrap",style:s,children:a.jsxs("div",{className:`tool-burst cat-${t.category}${t.mcpHue!=null?" mcp-hue":""} status-${t.status}${t.fading?" fading":""}${c?" clickable":""}${t.isSub?" sub":""}${h}`,style:d,title:i,onClick:c?()=>r(t.agentId,t.toolId):void 0,children:[a.jsx("span",{className:"tb-emoji",children:t.emoji}),a.jsx("span",{className:"tb-name",children:t.name}),t.status==="inflight"&&a.jsx("span",{className:"tb-spin"}),t.status==="done"&&a.jsx("span",{className:"tb-mark done",children:"✓"}),t.status==="err"&&a.jsx("span",{className:"tb-mark err",children:"×"})]})})},MG),LG={width:140,height:105},OG={agent:C7,sessionGroup:yG,recapNote:PV},IG={recapTie:YV},hE=400;function PG({graph:e,layout:t,viewport:n,clicks:r,drag:s,appearance:o,fm:i,radioOpen:c,onRadioClose:d,autoFit:h,pause:f,stateRef:p,measuredRef:g,hiddenCats:w,now:k,openTool:j,focusAgent:v,requestClear:b,setKeyHelpOpen:N}){const{allNodes:S,edges:E,visibleAgentIds:C,spotlightSet:$}=e,{positionsRef:T,pinnedRef:I,handleRelayout:O,rearrangeUndo:U}=t,{restoredViewport:P,onMoveStart:L,onMove:F}=n,{onNodeClick:A,onPaneClick:B,onNodeDoubleClick:D,onNodeMouseEnter:K,onNodeMouseLeave:G}=r,{onNodeDragStart:H,onNodeDrag:q,onNodeDragStop:M}=s,{palette:V,minimapNodeFill:Z,characterEnabled:W}=o,{autoFitDisabled:X,enableAutoFitAndRefit:Y}=h,{paused:J,pauseGate:ee,togglePause:ne}=f;return a.jsxs(wO,{nodes:S,edges:E,nodeTypes:OG,edgesFocusable:!1,edgeTypes:IG,fitView:!P,fitViewOptions:{padding:.25,duration:c0({durationMs:hE,documentHidden:document.hidden})?hE:0},minZoom:NO,maxZoom:SO,panOnScroll:!0,panActivationKeyCode:null,nodesDraggable:!0,nodesConnectable:!1,selectionOnDrag:!1,nodeDragThreshold:5,disableKeyboardA11y:!0,deleteKeyCode:null,onNodeClick:A,onPaneClick:B,onNodeDoubleClick:D,onNodeMouseEnter:K,onNodeMouseLeave:G,onMoveStart:L,onMove:F,onNodeDragStart:(se,ce,de)=>{U.dismiss(),H(se,ce,de)},onNodeDrag:q,onNodeDragStop:M,children:[a.jsx(vH,{gap:28,size:1,color:V["--grid-line"]}),a.jsx(gG,{onFocusSession:v}),a.jsx(TG,{agents:p.current.agents,visibleAgentIds:C,positions:T.current,pinned:I.current,measured:g.current,spotlight:$,hiddenCategories:w,now:k,onOpenTool:j}),a.jsxs("div",{className:"canvas-notices",children:[X&&a.jsx(L7,{enableAutoFitAndRefit:Y}),a.jsx(KV,{undo:U})]}),a.jsx(z7,{autoFitDisabled:X,enableAutoFitAndRefit:Y,paused:J,pauseGate:ee,togglePause:ne,handleRelayout:O,requestClear:b,setKeyHelpOpen:N}),a.jsx(iH,{style:LG,zoomable:!0,pannable:!0,nodeColor:Z,nodeStrokeWidth:2,maskColor:V["--minimap-mask"],maskStrokeColor:V["--line"]}),a.jsx(OV,{fm:i,character:o.character,characterEnabled:W,open:c,onClose:d})]})}function DG(){const e=window.ccdeckWindow;return y.useEffect(()=>{if(!e)return;const t=()=>{const r=document.querySelector(".topbar");if(!r)return;const s=getComputedStyle(r),o=i=>{var d;const c=(d=i.match(/\d+/g))==null?void 0:d.slice(0,3);return(c==null?void 0:c.length)===3?`#${c.map(h=>Number(h).toString(16).padStart(2,"0")).join("")}`:"#191a1c"};e.colors({color:o(s.backgroundColor),symbolColor:o(s.color)}).catch(()=>{})};t();const n=new MutationObserver(t);return n.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme","data-color-scheme"]}),()=>n.disconnect()},[e]),!e||e.platform==="darwin"?null:a.jsx("button",{type:"button",className:"desktop-menu btn","aria-label":"Application menu",title:"Application menu","aria-haspopup":"menu",onClick:()=>{e.menu().catch(()=>{})},children:a.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:a.jsx("path",{d:"M3 4h10M3 8h10M3 12h10",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round"})})})}function FG(e){const t={input:0,output:0,cacheRead:0,cacheWrite:0,total:0};let n=0,r=0,s=0,o=0;for(const i of e){const c=En(i);t.input+=c.input,t.output+=c.output,t.cacheRead+=c.cacheRead,t.cacheWrite+=c.cacheWrite,t.total+=c.total,n+=i.usage.inputTokens,r+=i.usage.outputTokens,s+=i.usage.cacheReadTokens,o+=i.usage.cacheCreateTokens}return{cost:t,inputTokens:n,outputTokens:r,cacheReadTokens:s,cacheCreateTokens:o,sum:n+r}}const BG="spend on this board",qG="on this board",ZI=`Everything on the board right now, and only that.
|
|
85
|
-
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.
|
|
86
|
-
`,UG=ZI+"Press H for the totals ccusage reads off the logs on disk, which do not forget.";function fE(e){return e?UG:ZI+"Usage history has the totals ccusage reads off the logs on disk, which do not forget."}const JI="session spend",j0="__unknown__",HG=12;function WG(e,t=Date.now()){const n=new Map;for(const r of e)for(const s of Zc(r)){const o=s.model??j0,i=af(s.usage,s.model,t),c=n.get(o);c?(c.inputTokens+=s.usage.inputTokens,c.outputTokens+=s.usage.outputTokens,c.cacheReadTokens+=s.usage.cacheReadTokens,c.cacheCreateTokens+=s.usage.cacheCreateTokens,c.cost.total+=i.total,c.cost.input+=i.input,c.cost.output+=i.output,c.cost.cacheRead+=i.cacheRead,c.cost.cacheWrite+=i.cacheWrite,c.agentCount++):n.set(o,{model:o,inputTokens:s.usage.inputTokens,outputTokens:s.usage.outputTokens,cacheReadTokens:s.usage.cacheReadTokens,cacheCreateTokens:s.usage.cacheCreateTokens,cost:{...i},agentCount:1,priced:Ta(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 zG(e,t=Date.now()){const n=[...e],r=[];for(const s of n){if(s.kind!=="root")continue;let o=En(s,t).total,i=s.usage.inputTokens,c=s.usage.outputTokens,d=Mc(s,t);for(const h of n)h.sessionId!==s.sessionId||h.kind==="root"||(o+=En(h,t).total,i+=h.usage.inputTokens,c+=h.usage.outputTokens,d+=Mc(h,t));r.push({sessionId:s.sessionId,label:s.label||s.cwdBasename||"session",state:s.state,cost:o,inputTokens:i,outputTokens:c,unpricedTokens:d})}return r.sort((s,o)=>o.cost-s.cost||o.inputTokens+o.outputTokens-(s.inputTokens+s.outputTokens)).slice(0,HG)}const VG=600;function wf(e,t){return!(e.exitAt!=null&&t-e.exitAt>VG||e.kind==="root"&&e.state==="done"&&e.tools.length===0&&e.endedAt!=null&&e.endedAt-e.startedAt<3e3)}function GG(e,t){const n=new Set;for(const r of e.agents.values())wf(r,t)&&n.add(r.id);return n}function KG(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 YG(e,t,n=0){if(!e)return!1;for(const r of t)if(KG(e,r,n))return!0;return!1}function pE(e){return e.waiting?Hn(e.waiting)?0:1:e.state==="active"?2:3}function XG(e,t){const n=[];for(const r of e.agents.values()){if(r.kind!=="root")continue;let s=r.toolCount,o=En(r).total,i=r.endedAt??r.startedAt;for(const f of e.agents.values()){if(f.sessionId!==r.sessionId||f.kind==="root")continue;s+=f.toolCount,o+=En(f).total;const p=f.endedAt??f.startedAt;p>i&&(i=p)}const c=df(r),d=(c==null?void 0:c.kind)==="recap"?{text:c.text,at:c.at}:null,h=c&&c.kind!=="recap"?c:null;n.push({sessionId:r.sessionId,label:r.label||r.cwdBasename||"session",cwdBasename:r.cwdBasename,state:r.state,waiting:r.waiting,recap:d,status:h,modelId:r.model,toolCount:s,cost:o,startedAt:r.startedAt,lastActivity:i})}return n.sort((r,s)=>{const o=pE(r),i=pE(s);return o!==i?o-i:r.waiting&&s.waiting?r.waiting.since-s.waiting.since:s.lastActivity-r.lastActivity}),n}function ZG(e){return[e.text,e.reply?`Suggested reply: ${e.reply}`:"",hf(e)].filter(Boolean).join(`
|
|
87
|
-
`)}function Eh(e,t,n){const r=(t??n)-e;if(r<1e3)return"<1s";const s=Math.floor(r/1e3);if(s<60)return`${s}s`;const o=Math.floor(s/60);return o<60?`${o}m`:`${Math.floor(o/60)}h ${o%60}m`}function JG({state:e,now:t,selectedIds:n,onSelect:r,onClose:s,removedIds:o,onBringBackAll:i,leaving:c=!1}){const d=Cn(),h=y.useMemo(()=>XG(e),[e,e.revision,t]),f=h.filter(g=>g.state==="active").length,p=h.filter(g=>Hn(g.waiting)).length;return a.jsxs("aside",{className:`session-list${c?" leaving":""}`,id:"session-list","aria-label":"Sessions",children:[a.jsxs("div",{className:"sl-header",children:[a.jsxs("h2",{children:["Sessions ",a.jsx("span",{className:"sl-count",children:h.length})]}),p>0&&a.jsxs("span",{className:"sl-waiting-count",children:[p," waiting"]}),f>0&&a.jsxs("span",{className:"sl-live-count",children:[f," live"]}),a.jsx("button",{className:"glyph-btn sl-close",onClick:s,title:dn("Hide sidebar","L",d),"aria-label":"Hide session list",children:"‹"})]}),a.jsxs("ul",{className:"sl-rows",children:[h.length===0&&a.jsx("li",{className:"sl-empty",children:"No sessions yet."}),h.map(g=>{var j;const w=n.has(g.sessionId),k=(o==null?void 0:o.has(g.sessionId))??!1;return a.jsx("li",{className:"sl-row-item",children:a.jsxs("button",{type:"button",className:`sl-row state-${g.state}${w?" selected":""}${k?" removed":""}`,"aria-current":w?"true":void 0,onClick:()=>r(g.sessionId),title:k?`Bring ${g.label} back to the board`:`Focus ${g.label}`,children:[a.jsx("span",{className:`sl-dot state-${g.state}`,"aria-hidden":!0}),a.jsx("span",{className:"vis-hidden",children:Wi(g.state)}),a.jsxs("div",{className:"sl-row-body",children:[a.jsxs("div",{className:"sl-row-head",children:[a.jsx("span",{className:"sl-label",children:g.label}),k&&a.jsx("span",{className:"sl-removed",children:"off the board"}),g.modelId&&a.jsx("span",{className:"model-chip","data-family":lf(g.modelId),title:g.modelId,children:rs(g.modelId)})]}),a.jsxs("div",{className:"sl-row-meta",children:[a.jsxs("span",{title:"tool calls",children:[a.jsx("b",{children:g.toolCount})," ",g.toolCount===1?"tool":"tools"]}),g.cost>0&&a.jsx("span",{className:"sl-cost",title:JI,children:a.jsx("b",{children:Ye(g.cost)})}),g.waiting?a.jsxs("span",{className:"sl-waiting",title:[zi(g.waiting),cI(g.waiting,zi(g.waiting)),`${Hn(g.waiting)?"Blocked":"Your turn"} since ${new Date(g.waiting.since).toLocaleTimeString()} · started ${new Date(g.startedAt).toLocaleString()}`].filter(Boolean).join(`
|
|
88
|
-
`),children:[Hn(g.waiting)?"waiting":"your turn"," ",Eh(g.waiting.since,void 0,t),g.waiting.tool&&a.jsxs("span",{className:"sl-waiting-tool",children:[" · ",g.waiting.tool.name]})]}):a.jsx("span",{className:"sl-elapsed",title:`Started ${new Date(g.startedAt).toLocaleString()}`,children:Eh(g.startedAt,g.state==="active"?void 0:g.lastActivity,t)})]}),g.recap&&a.jsxs("span",{className:"sl-recap",title:g.recap.text,children:[a.jsx(_I,{}),g.recap.text]}),g.status&&a.jsxs("span",{className:`sl-status status-${g.status.kind}`,title:ZG(g.status),children:[a.jsx("span",{className:"sl-status-tag",children:ja(g.status.kind)})," ",g.status.text]}),((j=g.status)==null?void 0:j.reply)&&a.jsxs("span",{className:"sl-status-reply",title:`suggested reply “${g.status.reply}”`,children:["suggested reply “",g.status.reply,"”"]})]})]})},g.sessionId)})]}),(()=>{let g=0;for(const w of o??[]){const k=e.agents.get(w);k&&wf(k,t)&&g++}return g===0||!i?null:a.jsx("div",{className:"sl-foot",children:a.jsxs("button",{type:"button",className:"btn sl-bring-back",onClick:w=>{const k=w.currentTarget.closest(".session-list");i(),requestAnimationFrame(()=>{var j;return(j=k==null?void 0:k.querySelector(".sl-row"))==null?void 0:j.focus()})},children:["Bring back ",g," removed ",g===1?"card":"cards"]})})})()]})}const Bn=e=>{if(e===null)return"—";if(e<1e3)return`${Math.round(e)} ms`;if(e<6e4)return`${(e/1e3).toLocaleString(void 0,{maximumFractionDigits:1})} s`;if(e<36e5)return`${(e/6e4).toLocaleString(void 0,{maximumFractionDigits:1})} min`;const t=Math.round(e/6e4),n=Math.floor(t/60),r=t%60;return`${n.toLocaleString()} h${r?` ${r} min`:""}`},QG=e=>e<1024?`${e} B`:e<1048576?`${(e/1024).toLocaleString(void 0,{maximumFractionDigits:1})} KB`:`${(e/1048576).toLocaleString(void 0,{maximumFractionDigits:1})} MB`,eK=e=>new Date(e).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});async function mE(e,t){for(let n=0;n<4;n++){const r=await fetch(`/api/tool-audit?${e}`,{signal:t}),s=await r.json();if(r.status===409&&s.reason==="busy"&&n<3){await new Promise((o,i)=>{const c=()=>{window.clearTimeout(d),i(new DOMException("Cancelled","AbortError"))},d=window.setTimeout(()=>{t.removeEventListener("abort",c),o()},300);t.addEventListener("abort",c,{once:!0}),t.aborted&&c()});continue}if(!r.ok||!s.ok||!Array.isArray(s.rows))throw new Error("Could not build the tool report. Try Refresh or reduce history retention in Settings.");return s}throw new Error("A tool report is already running. Try Refresh in a moment.")}const gE={Read:"Reads a file",Edit:"Changes part of a file",MultiEdit:"Makes several changes to one file",Write:"Creates or overwrites a file",NotebookEdit:"Changes a Jupyter notebook cell",Grep:"Searches file contents",Glob:"Finds files by name",LS:"Lists a folder",WebFetch:"Opens a web page",WebSearch:"Searches the web",Agent:"Hands work to a subagent",Task:"Hands work to a subagent",TodoWrite:"Updates the agent’s to-do list",Skill:"Loads a skill",ToolSearch:"Looks up another tool",apply_patch:"Changes files",update_plan:"Updates the agent’s plan",view_image:"Looks at an image file",write_stdin:"Talks to a running command",multi_agent_v1__wait_agent:"Waits for other agents to finish",rg:"Searches file contents",grep:"Searches text",ls:"Lists a folder",cat:"Prints a file",sed:"Prints or edits text",head:"Shows the start of a file",tail:"Shows the end of a file",find:"Finds files",wc:"Counts lines or words",cut:"Picks columns out of text",sort:"Sorts lines",jq:"Reads JSON",curl:"Makes a web request",sleep:"Waits",node:"Runs a Node.js script",python:"Runs a Python script",python3:"Runs a Python script",git:"Runs Git","git status":"Shows what changed","git diff":"Shows the exact changes","git log":"Shows the commit history","git show":"Shows one commit","git add":"Stages changes","git commit":"Saves a commit","git push":"Uploads commits","git pull":"Downloads and merges commits","git fetch":"Downloads commits","git checkout":"Switches branch or restores files","git switch":"Switches branch","git branch":"Lists or changes branches","git merge":"Merges a branch","git rebase":"Replays commits on another base","git stash":"Puts changes aside","git restore":"Restores files","git reset":"Moves the branch or unstages changes","git worktree":"Manages worktrees","npm test":"Runs the project’s tests","npm install":"Installs packages","npm ci":"Installs packages from the lock file","gh pr":"Works with GitHub pull requests","gh issue":"Works with GitHub issues","gh run":"Works with GitHub Actions runs","gh api":"Calls the GitHub API","shell (unclassified)":"A shell command ccdeck could not name","exec (unclassified)":"A Codex script ccdeck could not name","tool (unclassified)":"A tool with an unreadable name"};function Lc(e){if(Object.hasOwn(gE,e))return gE[e];const t=/^(npm|pnpm|yarn|bun) run (.+)$/.exec(e);if(t)return`Runs the “${t[2]}” script`;const n=QI(e);return n?`From the ${n.server} MCP server`:null}function QI(e){const t=/^mcp__(.+?)__(.+)$/.exec(e);return t?{server:t[1],tool:t[2]}:null}const Oc=e=>{var t;return((t=QI(e))==null?void 0:t.tool)??e},tK=[{id:"calls",label:"Most used"},{id:"time",label:"Most time"},{id:"slowest",label:"Slowest"},{id:"failed",label:"Failures"}];function Ch(e,t){return t==="calls"?e.calls:t==="time"?e.totalMs:t==="slowest"?e.medianMs:e.failed}const nK=(e,t)=>{const n=t.trim().toLowerCase();return!n||e.operation.toLowerCase().includes(n)||(Lc(e.operation)??"").toLowerCase().includes(n)};function rK(e,t,n=""){return e.filter(r=>nK(r,n)).sort((r,s)=>{const o=Ch(r,t),i=Ch(s,t);return o!==i?o===null?1:i===null?-1:i-o:s.calls-r.calls||r.operation.localeCompare(s.operation)})}const Yk=(e,t)=>{const n=e/t*100;return`${n>0&&n<1?"<1":Math.round(n)}%`},xf=e=>e.failed>0&&e.completed>0?Yk(e.failed,e.completed):null;function sK(e,t){const n=[],s=e.filter(c=>c.totalMs!==null&&c.measured>=2).slice().sort((c,d)=>d.totalMs-c.totalMs)[0];s&&t&&s.totalMs>=t*.2&&n.push({kind:"time",operation:s.operation,title:"takes the most time",detail:`${Bn(s.totalMs)} over ${Eo(s.calls,"call")}, ${Yk(s.totalMs,t)} of all tool time.`});const o=e.filter(c=>c.completed>=5&&c.failed>=2&&c.failed/c.completed>=.1).sort((c,d)=>d.failed/d.completed-c.failed/c.completed||d.failed-c.failed)[0];o&&n.push({kind:"failing",operation:o.operation,title:"fails often",detail:`${o.failed.toLocaleString()} of ${Eo(o.completed,"call")} failed (${xf(o)}).`});const i=e.filter(c=>c.medianMs!==null&&c.measured>=3&&c.medianMs>=1e4&&c.operation!==(s==null?void 0:s.operation)).sort((c,d)=>d.medianMs-c.medianMs)[0];return i&&n.push({kind:"slow",operation:i.operation,title:"is the slowest",detail:`Usually ${Bn(i.medianMs)} per call; the longest took ${Bn(i.maxMs)}.`}),n}const Eo=(e,t)=>`${e.toLocaleString()} ${t}${e===1?"":"s"}`,N0={1:"24 hours",7:"7 days",30:"30 days",90:"90 days"},aK={all:"your agents",claude:"Claude",codex:"Codex"};function oK(e,t,n){return{lead:`In the last ${N0[n]??`${n} days`}, ${aK[t]} made`,calls:Eo(e.total,"tool call"),time:e.totalMs?Bn(e.totalMs):null,failed:e.failed,failedShare:e.failed&&e.completed?Yk(e.failed,e.completed):null}}const yE=e=>new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric"});function iK(e,t=Date.now()){const n=s=>new Date(s).toDateString(),r=new Date(e).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"});return n(e)===n(t)?`Today ${r}`:n(e)===n(t-864e5)?`Yesterday ${r}`:`${new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric"})}, ${r}`}const ga=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString(void 0,{timeZone:"UTC",month:"short",day:"numeric"});function lK(e){return e.status==="outside-history"?`${ga(e.date)} · before recording started`:e.calls?`${ga(e.date)} · ${Eo(e.calls,"call")}${e.medianMs!==null?` · usually ${Bn(e.medianMs)}`:""}`:`${ga(e.date)} · no calls`}function cK({history:e}){const t=e.days,n=[...t].reverse().find(d=>d.calls>0)??t.at(-1),[r,s]=y.useState(null);if(t.length<3||!n)return null;const o=t.find(d=>d.date===r)??n,i=t.reduce((d,h)=>h.calls>d.calls?h:d,t[0]),c=Math.max(1,i.calls);return a.jsxs("section",{className:"ta-history","aria-labelledby":"ta-history-title",children:[a.jsx("h4",{id:"ta-history-title",children:"Calls per day"}),a.jsx("div",{className:"ta-history-bars",role:"img","aria-label":`Calls per day from ${ga(t[0].date)} to ${ga(t.at(-1).date)}. The busiest day was ${ga(i.date)} with ${Eo(i.calls,"call")}.`,onPointerLeave:()=>s(null),style:{"--ta-days":t.length},children:t.map(d=>a.jsx("span",{"data-shown":d.date===o.date||void 0,"data-outside":d.status==="outside-history"||void 0,onPointerEnter:()=>s(d.date),children:a.jsx("i",{style:{"--ta-height":d.calls/c}})},d.date))}),a.jsxs("div",{className:"ta-history-axis","aria-hidden":"true",children:[a.jsx("span",{children:ga(t[0].date)}),a.jsx("span",{children:ga(t.at(-1).date)})]}),a.jsx("p",{className:"ta-note ta-history-day","aria-live":"polite",children:lK(o)})]})}function uK(){return a.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round","aria-hidden":"true",children:a.jsx("path",{d:"m6 6 12 12M18 6 6 18"})})}const dK={success:"Done",failed:"Failed",unmatched:"No result"},hK=({state:e})=>a.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round","aria-hidden":"true",children:a.jsx("path",{d:e==="failed"?"m4 4 8 8m0-8-8 8":e==="success"?"m3 8.5 3 3 7-7":"M4 8h8"})});function fK(e){const{claude:t,codex:n}=e.providers;return t&&n?`${t.toLocaleString()} by Claude, ${n.toLocaleString()} by Codex`:t?"All by Claude":"All by Codex"}function e3({row:e,details:t,loading:n,error:r,kind:s,setKind:o,onClose:i}){const c=Lc(e.operation),d=(t==null?void 0:t[s])??[],h=Date.now(),f=xf(e);return a.jsxs("section",{className:"ta-inspector","aria-label":`${Oc(e.operation)} details`,id:"tool-operation-inspector",children:[a.jsxs("header",{className:"ta-inspector-head",children:[a.jsxs("div",{children:[a.jsx("h3",{tabIndex:-1,id:"tool-operation-heading",children:Oc(e.operation)}),c&&a.jsx("p",{children:c})]}),a.jsx("button",{type:"button",className:"glyph-btn","aria-label":"Close details",onClick:i,children:a.jsx(uK,{})})]}),a.jsxs("dl",{className:"ta-facts",children:[a.jsxs("div",{children:[a.jsx("dt",{children:"Calls"}),a.jsx("dd",{children:e.calls.toLocaleString()})]}),a.jsxs("div",{children:[a.jsx("dt",{children:"Total time"}),a.jsx("dd",{children:Bn(e.totalMs)})]}),a.jsxs("div",{children:[a.jsx("dt",{children:"Usually"}),a.jsx("dd",{children:Bn(e.medianMs)})]}),a.jsxs("div",{children:[a.jsx("dt",{children:"Failed"}),a.jsxs("dd",{"data-bad":e.failed>0||void 0,children:[e.failed.toLocaleString(),f&&a.jsx("small",{children:f})]})]})]}),a.jsxs("p",{className:"ta-note",children:[fK(e),e.maxMs!==null&&e.measured>1&&a.jsxs(a.Fragment,{children:[" · longest ",Bn(e.maxMs)]}),e.unmatched>0&&a.jsxs(a.Fragment,{children:[" · ",Eo(e.unmatched,"call")," without a result yet"]})]}),r&&a.jsx("p",{className:"ta-message",role:"alert",children:r}),(t==null?void 0:t.history)&&a.jsx(cK,{history:t.history},e.operation),a.jsxs("section",{className:"ta-calls-section","aria-labelledby":"ta-calls-title",children:[a.jsxs("div",{className:"ta-calls-head",children:[a.jsx("h4",{id:"ta-calls-title",children:"Calls"}),a.jsxs("div",{className:"uh-range",role:"group","aria-label":"Show calls",children:[a.jsx("button",{type:"button",className:"uh-range-btn","aria-pressed":s==="recent",onClick:()=>o("recent"),children:"Latest"}),a.jsx("button",{type:"button",className:"uh-range-btn","aria-pressed":s==="slowest",onClick:()=>o("slowest"),children:"Slowest"})]})]}),n&&!t&&a.jsx("p",{className:"ta-note",role:"status",children:"Reading calls…"}),t&&a.jsxs(a.Fragment,{children:[a.jsx("ul",{className:"ta-calls",children:d.map(p=>a.jsxs("li",{"data-state":p.state,children:[a.jsx("span",{className:"ta-call-when",children:iK(p.capturedAt,h)}),a.jsx("span",{className:"ta-call-who",children:p.provider==="claude"?"Claude":"Codex"}),a.jsx("span",{className:"ta-call-took",children:Bn(p.durationMs)}),a.jsxs("span",{className:"ta-call-state",children:[a.jsx(hK,{state:p.state}),dK[p.state]]})]},p.id))}),!d.length&&a.jsx("p",{className:"ta-note",children:s==="slowest"?"None of these calls was timed.":"No calls in this period."}),t.total>d.length&&d.length>0&&a.jsxs("p",{className:"ta-note",children:["The ",s==="recent"?"latest":"slowest"," ",d.length," of ",t.total.toLocaleString(),"."]})]})]}),a.jsx("p",{className:"ta-note ta-inspector-foot",children:"Times include any wait for your approval."})]})}function Xk(e){const[t,n]=y.useState(()=>typeof window.matchMedia=="function"&&window.matchMedia(e).matches);return y.useEffect(()=>{if(typeof window.matchMedia!="function")return;const r=window.matchMedia(e),s=()=>n(r.matches);return s(),r.addEventListener("change",s),()=>r.removeEventListener("change",s)},[e]),t}function pK({keyboard:e,...t}){const n=y.useRef(null),r=ot(t.onClose,{focusRef:n}),s=dt(t.onClose);return y.useEffect(()=>{var o,i;n.current=((o=r.current)==null?void 0:o.querySelector("#tool-operation-heading"))??null,(i=n.current)==null||i.focus({preventScroll:!0})},[r]),yt.createPortal(a.jsx("div",{className:"ta-drawer-backdrop",role:"presentation",...s,children:a.jsx("div",{className:"ta-drawer","data-keyboard":e||void 0,ref:r,role:"dialog","aria-modal":"true","aria-labelledby":"tool-operation-heading",children:a.jsx(e3,{...t})})}),document.body)}function mK({keyboard:e,...t}){const n=y.useRef(null),r=y.useRef(t.onClose);return r.current=t.onClose,y.useEffect(()=>jn.push(()=>r.current(),0,"popover"),[]),y.useLayoutEffect(()=>{var s,o;n.current&&(n.current.scrollTop=0),(document.activeElement===document.body||e&&document.activeElement instanceof HTMLElement&&document.activeElement.dataset.operation===t.row.operation)&&((o=(s=n.current)==null?void 0:s.querySelector("#tool-operation-heading"))==null||o.focus({preventScroll:!0}))},[t.row.operation,e]),a.jsx("aside",{ref:n,className:"ta-drawer ta-integrated-inspector","data-keyboard":e||void 0,"aria-labelledby":"tool-operation-heading",children:a.jsx(e3,{...t})})}function gK(e){return Xk("(max-width: 700px)")?a.jsx(pK,{...e}):a.jsx(mK,{...e})}const S0="agent-dag.text-size",_0="agent-dag.density",wE=["smallest","smaller","default","larger","largest"],xE=["tightest","tighter","compact","default","comfortable"],Zk={smallest:-2,smaller:-1,default:0,larger:2,largest:4};function Jk(){var e,t;return Qk(typeof document>"u"?null:(t=(e=document.documentElement)==null?void 0:e.dataset)==null?void 0:t.textSize)}function Qk(e){return e==="smallest"||e==="smaller"||e==="larger"||e==="largest"?e:"default"}function t3(e){return e==="tightest"||e==="tighter"||e==="compact"||e==="comfortable"?e:"default"}const yK=()=>Qk(Ge(S0)),wK=()=>t3(Ge(_0)),Jr={min:320,standard:380,max:1600},xK=420,vK=8,n3="agent-dag.tool-activity.details-width";function Jl(e,t){const n=Math.max(Jr.min,Math.min(Jr.max,t-xK-vK));return Math.round(Math.min(n,Math.max(Jr.min,Number.isFinite(e)?e:Th())))}function Th(){return Jr.standard+12*Math.max(0,Zk[Jk()])}function bK(){const e=Number(Ge(n3));return Number.isFinite(e)&&e>=Jr.min&&e<=Jr.max?Math.round(e):Th()}function kK(e){Ve(n3,String(Math.round(e)))}function jK({width:e,workspace:t,onCommit:n}){const r=y.useRef(null),s=y.useRef(null),o=()=>{var w;return((w=t.current)==null?void 0:w.clientWidth)??window.innerWidth},i=Jl(e,o()),c=w=>{var k,j;(k=t.current)==null||k.style.setProperty("--ta-details-w",`${w}px`),(j=r.current)==null||j.setAttribute("aria-valuenow",String(w))},d=w=>{c(w),n(w)},h=w=>{var k;w.button===0&&(w.preventDefault(),w.currentTarget.setPointerCapture(w.pointerId),s.current={x:w.clientX,width:i,room:o(),last:i},(k=t.current)==null||k.setAttribute("data-resizing",""))},f=w=>{const k=s.current;k&&(k.last=Jl(k.width+k.x-w.clientX,k.room),c(k.last))},p=()=>{var k;const w=s.current;w&&(s.current=null,(k=t.current)==null||k.removeAttribute("data-resizing"),d(w.last))},g=w=>{const k=w.shiftKey?64:16,j=w.key==="ArrowLeft"?i+k:w.key==="ArrowRight"?i-k:w.key==="Home"?Jr.min:w.key==="End"?Jr.max:w.key==="Enter"?Th():null;j!==null&&(w.preventDefault(),d(Jl(j,o())))};return a.jsx("div",{ref:r,className:"ta-splitter",role:"separator","aria-orientation":"vertical","aria-label":"Details width","aria-controls":"tool-operation-inspector","aria-valuemin":Jr.min,"aria-valuemax":Jl(Jr.max,o()),"aria-valuenow":i,tabIndex:0,title:"Drag to resize · double-click for the standard width",onPointerDown:h,onPointerMove:f,onPointerUp:p,onPointerCancel:p,onLostPointerCapture:p,onDoubleClick:()=>d(Jl(Th(),o())),onKeyDown:g})}const vE=12,NK=[{id:"all",label:"All agents"},{id:"claude",label:"Claude"},{id:"codex",label:"Codex"}],SK=()=>a.jsx("svg",{width:"18",height:"18",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round","aria-hidden":"true",children:a.jsx("path",{d:"m10 5-7 7 7 7M3 12h18"})}),_K=()=>a.jsx("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round","aria-hidden":"true",children:a.jsx("path",{d:"M20 7v5h-5M20 12a8 8 0 1 0-2 5"})}),EK=()=>a.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round","aria-hidden":"true",children:[a.jsx("circle",{cx:"11",cy:"11",r:"6.5"}),a.jsx("path",{d:"m16 16 4.5 4.5"})]}),CK={time:a.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round","aria-hidden":"true",children:[a.jsx("circle",{cx:"12",cy:"13",r:"8"}),a.jsx("path",{d:"M12 9v4l2.5 2M9.5 2.5h5"})]}),failing:a.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round","aria-hidden":"true",children:[a.jsx("circle",{cx:"12",cy:"12",r:"9"}),a.jsx("path",{d:"m9 9 6 6m0-6-6 6"})]}),slow:a.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round","aria-hidden":"true",children:a.jsx("path",{d:"M3 17h18M6 17a6 6 0 0 1 12 0M12 17l3.5-4.5"})})};function TK(e){const t=e.failed?`${e.failed.toLocaleString()} failed (${xf(e)})`:"none failed",n=e.totalMs===null?"not timed":`${Bn(e.totalMs)} in total, usually ${Bn(e.medianMs)}`;return`${Oc(e.operation)}${Lc(e.operation)?`, ${Lc(e.operation)}`:""}: ${Eo(e.calls,"call")}, ${n}, ${t}`}function RK({onClose:e}){const[t,n]=y.useState("all"),[r,s]=y.useState("7"),[o,i]=y.useState("calls"),[c,d]=y.useState(""),[h,f]=y.useState(!1),[p,g]=y.useState(null),[w,k]=y.useState(!1),j=y.useRef(p);j.current=p;const v=y.useRef(null),[b,N]=y.useState(null),[S,E]=y.useState(null),[C,$]=y.useState("recent"),[T,I]=y.useState(!0),[O,U]=y.useState(!1),[P,L]=y.useState(""),[F,A]=y.useState(""),[B,D]=y.useState(0),K=y.useRef(!1),G=y.useRef(null),H=y.useRef(null),q=y.useRef(null),M=Xk("(min-width: 960px)"),[V,Z]=y.useState(bK),W=oe=>{Z(oe),kK(oe)},[X]=y.useState(()=>document.activeElement instanceof HTMLElement?document.activeElement:null),Y=()=>{e(),requestAnimationFrame(()=>{var Ne;const oe=X,we=Array.from(document.querySelectorAll('[data-rail-item="tool-activity"], [data-rail-item="more"]')).find(ge=>ge.checkVisibility());(Ne=oe&&oe!==document.body&&oe.isConnected&&oe.checkVisibility()?oe:we)==null||Ne.focus({preventScroll:!0})})},J=ot(Y,{focusRef:H}),ee=new URLSearchParams({provider:t,days:r}).toString();y.useEffect(()=>{const oe=new AbortController;let we=!0;const Ne=window.setTimeout(()=>oe.abort(),65e3);return L(""),G.current!==ee&&(N(null),E(null),f(!1)),K.current=!0,I(!0),(async()=>{try{const ge=await mE(ee,oe.signal);we&&(G.current=ee,N(ge),j.current&&!ge.rows.some(Ae=>Ae.operation===j.current)&&g(null))}catch(ge){we&&L(ge instanceof Error&&ge.name!=="AbortError"?ge.message:"Reading the history took too long. Try again, or keep less history in Settings.")}finally{window.clearTimeout(Ne),we&&(K.current=!1,I(!1))}})(),()=>{we=!1,oe.abort(),window.clearTimeout(Ne)}},[ee,B]),y.useEffect(()=>{if(E(ge=>(ge==null?void 0:ge.operation)===p&&G.current===ee?ge:null),A(""),!p||!b||T){U(!1);return}let oe=!0;const we=new AbortController,Ne=window.setTimeout(()=>we.abort(),65e3);return U(!0),(async()=>{var ge;try{const Ae=await mE(`${ee}&operation=${encodeURIComponent(p)}&history=1&timeZone=${encodeURIComponent(Intl.DateTimeFormat().resolvedOptions().timeZone)}`,we.signal);oe&&(((ge=Ae.details)==null?void 0:ge.measurements)===null?g(null):E(Ae.details))}catch{oe&&A("Could not read the calls for this tool. Close it and open it again to retry.")}finally{window.clearTimeout(Ne),oe&&U(!1)}})(),()=>{oe=!1,we.abort(),window.clearTimeout(Ne)}},[p,b,T,ee]);const ne=y.useMemo(()=>rK((b==null?void 0:b.rows)??[],o,c),[b,o,c]),se=y.useMemo(()=>b?sK(b.rows,b.totalMs):[],[b]),ce=h||c?ne:ne.slice(0,vE),de=ne.length?Ch(ne[0],o)??0:0,ae=b==null?void 0:b.rows.find(oe=>oe.operation===p),pe=oe=>we=>{v.current=we.currentTarget,k(we.detail===0),$("recent"),g(Ne=>Ne===oe?null:oe)},fe=()=>{const oe=p;g(null),requestAnimationFrame(()=>{var ge,Ae;const we=v.current,Ne=Array.from(((ge=J.current)==null?void 0:ge.querySelectorAll(".ta-row[data-operation]"))??[]).find(Oe=>Oe.dataset.operation===oe);(Ae=we!=null&&we.isConnected&&we.checkVisibility()?we:Ne??H.current)==null||Ae.focus({preventScroll:!0})})},Ee=()=>{K.current||O||(K.current=!0,D(oe=>oe+1))},ye=b&&oK(b,t,r);return yt.createPortal(a.jsx("div",{className:"ta-report-backdrop",role:"presentation",children:a.jsxs("div",{className:"ta-report",ref:J,role:"dialog","aria-modal":"true","aria-labelledby":"tool-audit-title",children:[a.jsxs("header",{className:"ta-report-header",children:[a.jsxs("button",{type:"button",ref:H,className:"ta-back",onClick:Y,"aria-label":"Close tool activity",children:[a.jsx(SK,{}),a.jsx("span",{children:"Back to workspace"})]}),a.jsx("h2",{id:"tool-audit-title",children:"Tool activity"}),a.jsxs("div",{className:"ta-actions",children:[a.jsx("span",{className:"ta-freshness",role:"status",children:T?b?"Updating…":"Reading history…":b?`Updated ${new Date(b.capturedAt).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})}`:""}),a.jsx("button",{type:"button",className:"glyph-btn","aria-label":"Refresh tool activity",title:"Refresh","data-loading":T||void 0,"aria-busy":T||O,onClick:Ee,children:a.jsx(_K,{})})]})]}),a.jsxs("div",{className:"ta-workspace",ref:q,"data-inspecting":!!ae||void 0,style:{"--ta-details-w":`${V}px`},children:[a.jsx("div",{className:"ta-body",children:a.jsxs("div",{className:"ta-report-content",children:[a.jsxs("div",{className:"ta-filters",children:[a.jsx("div",{className:"uh-range",role:"group","aria-label":"Period",children:Object.entries(N0).map(([oe,we])=>a.jsx("button",{type:"button",className:"uh-range-btn","aria-pressed":r===oe,onClick:()=>s(oe),children:we},oe))}),a.jsx("div",{className:"uh-range",role:"group","aria-label":"Agent",children:NK.map(oe=>a.jsx("button",{type:"button",className:"uh-range-btn","aria-pressed":t===oe.id,onClick:()=>n(oe.id),children:oe.label},oe.id))})]}),T&&!b&&a.jsxs("div",{className:"ta-loading",role:"status","aria-label":"Reading tool history",children:[a.jsx("i",{}),a.jsx("i",{}),a.jsx("i",{}),a.jsx("i",{}),a.jsx("i",{})]}),P&&a.jsxs("div",{className:"ta-message",role:"alert",children:[a.jsxs("p",{children:[b&&"Showing the last numbers. ",P]}),a.jsx("button",{type:"button",className:"btn",onClick:Ee,children:"Try again"})]}),b&&ye&&(b.total===0?a.jsxs("div",{className:"ta-empty",children:[a.jsxs("h3",{children:["No tool calls in the last ",N0[r]]}),a.jsxs("p",{children:["ccdeck records each tool ",t==="all"?"Claude Code and Codex use":t==="claude"?"Claude Code uses":"Codex uses"," on this device, starting ",yE(b.startedAt),". Run a session and the calls show up here."]}),r!=="90"&&a.jsx("button",{type:"button",className:"btn",onClick:()=>s("90"),children:"Show the last 90 days"})]}):a.jsxs(a.Fragment,{children:[a.jsxs("p",{className:"ta-summary",children:[ye.lead," ",a.jsx("strong",{children:ye.calls}),ye.time&&a.jsxs(a.Fragment,{children:[" and spent ",a.jsx("strong",{children:ye.time})," running them"]}),"."," ",ye.failed?a.jsxs(a.Fragment,{children:[a.jsxs("strong",{className:"ta-bad",children:[ye.failed.toLocaleString()," failed"]})," (",ye.failedShare,")."]}):"None failed."]}),(!b.storageOk||b.dropped>0||b.corrupt>0)&&a.jsxs("p",{className:"ta-warning",role:"status",children:["Some calls could not be saved or read, so these numbers may be a little low.",!b.storageOk&&" Check free disk space."]}),se.length>0&&a.jsxs("section",{className:"ta-highlights","aria-labelledby":"ta-highlights-title",children:[a.jsx("h3",{id:"ta-highlights-title",children:"Worth a look"}),a.jsx("ul",{children:se.map(oe=>a.jsx("li",{children:a.jsxs("button",{type:"button",className:"ta-highlight","data-kind":oe.kind,"data-operation":oe.operation,"aria-expanded":p===oe.operation,"aria-controls":p===oe.operation?"tool-operation-inspector":void 0,onClick:pe(oe.operation),children:[a.jsx("span",{className:"ta-highlight-glyph",children:CK[oe.kind]}),a.jsxs("span",{className:"ta-highlight-text",children:[a.jsxs("span",{children:[a.jsx("code",{children:Oc(oe.operation)})," ",oe.title]}),a.jsx("small",{children:oe.detail})]})]})},oe.kind))})]}),a.jsxs("section",{className:"ta-tools","aria-labelledby":"ta-tools-title",children:[a.jsxs("div",{className:"ta-tools-head",children:[a.jsxs("h3",{id:"ta-tools-title",children:["Tools and commands ",a.jsx("span",{className:"ta-count",children:b.rows.length.toLocaleString()})]}),a.jsxs("label",{className:"ta-search",children:[a.jsx(EK,{}),a.jsx("input",{type:"search","aria-label":"Find a tool or command",placeholder:"Find a tool or command",value:c,onChange:oe=>d(oe.target.value)})]})]}),a.jsx("div",{className:"uh-range ta-sorts",role:"group","aria-label":"Sort by",children:tK.map(oe=>a.jsx("button",{type:"button",className:"uh-range-btn","aria-pressed":o===oe.id,onClick:()=>i(oe.id),children:oe.label},oe.id))}),a.jsxs("div",{className:"ta-list-head","aria-hidden":"true","data-sort":o,children:[a.jsx("span",{children:"Name"}),a.jsx("span",{"data-col":"calls",children:"Calls"}),a.jsx("span",{"data-col":"time",children:"Total time"}),a.jsx("span",{"data-col":"slowest",children:"Usually"}),a.jsx("span",{"data-col":"failed",children:"Failed"})]}),a.jsx("ul",{className:"ta-list","data-sort":o,children:ce.map(oe=>{const we=Ch(oe,o),Ne=Lc(oe.operation);return a.jsx("li",{children:a.jsxs("button",{type:"button",className:"ta-row","data-operation":oe.operation,"data-selected":p===oe.operation||void 0,"aria-expanded":p===oe.operation,"aria-controls":p===oe.operation?"tool-operation-inspector":void 0,"aria-label":TK(oe),onClick:pe(oe.operation),children:[a.jsxs("span",{className:"ta-row-name",children:[a.jsx("span",{className:"ta-op",children:Oc(oe.operation)}),Ne&&a.jsx("span",{className:"ta-desc",children:Ne}),a.jsx("span",{className:"ta-bar","aria-hidden":"true",style:{"--ta-share":de&&we?Math.max(.015,we/de):0}})]}),a.jsxs("span",{className:"ta-cell","data-col":"calls",children:[oe.calls.toLocaleString(),a.jsxs("span",{className:"ta-unit",children:[" ",oe.calls===1?"call":"calls"]})]}),a.jsxs("span",{className:"ta-cell","data-col":"time",children:[Bn(oe.totalMs),a.jsx("span",{className:"ta-unit",children:" total"})]}),a.jsxs("span",{className:"ta-cell","data-col":"slowest",children:[a.jsx("span",{className:"ta-unit",children:"usually "}),Bn(oe.medianMs)]}),a.jsx("span",{className:"ta-cell","data-col":"failed","data-bad":oe.failed>0||void 0,children:oe.failed?a.jsxs(a.Fragment,{children:[oe.failed.toLocaleString(),a.jsx("span",{className:"ta-unit",children:" failed"}),a.jsx("small",{children:xf(oe)})]}):a.jsxs("span",{className:"ta-zero",children:["0",a.jsx("span",{className:"ta-unit",children:" failed"})]})})]})},oe.operation)})}),!ne.length&&a.jsxs("p",{className:"ta-note ta-no-match",children:["No tool or command matches “",c.trim(),"”."]}),!c&&!h&&ne.length>vE&&a.jsxs("button",{type:"button",className:"btn ta-more",onClick:()=>f(!0),children:["Show all ",ne.length.toLocaleString()]})]}),a.jsxs("details",{className:"ta-explain",children:[a.jsx("summary",{children:"How this is counted"}),a.jsxs("ul",{children:[a.jsx("li",{children:"A call’s time runs from when the agent starts the tool until it reports back, so it can include waiting for your approval."}),a.jsx("li",{children:"Total time adds every call together. Calls that ran at the same time each count, so it can be more than the time that actually passed."}),a.jsx("li",{children:"“Usually” is the middle value: half of the calls were quicker, half took longer."}),a.jsxs("li",{children:["A command line such as ",a.jsx("code",{children:"git add . && git commit"})," counts once for each command in it, and shares its time and result with both."]}),a.jsx("li",{children:"Claude and Codex report times in different ways, so do not compare one with the other."}),a.jsxs("li",{children:["Recorded on this device since ",yE(b.startedAt)," and kept for ",b.retentionDays," days. Commands are grouped by name; their arguments and output are never saved. Change this in Settings."]})]})]})]}))]})}),ae&&M&&a.jsx(jK,{width:V,workspace:q,onCommit:W}),ae&&a.jsx(gK,{keyboard:w,row:(S==null?void 0:S.operation)===p&&S.measurements?S.measurements:ae,details:(S==null?void 0:S.operation)===p?S:null,loading:O,error:F,kind:C,setKind:$,onClose:fe})]})]})}),document.body)}const E0={cost:0,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0,sessions:0};function AK(e){if(!e.synthetic)return!1;const t=e.usage;return t.inputTokens+t.outputTokens+t.cacheReadTokens+t.cacheCreateTokens<=0}function C0(e,t){const n=new Map;for(const r of e){if(r.kind!=="root"||!r.sessionId||AK(r))continue;const s=En(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 MK(e,t){if(!e)return E0;const n={...E0};for(const[r,s]of t){const o=e.get(r);if(!o)continue;const i={cost:s.cost-o.cost,inputTokens:s.inputTokens-o.inputTokens,outputTokens:s.outputTokens-o.outputTokens,cacheReadTokens:s.cacheReadTokens-o.cacheReadTokens,cacheCreateTokens:s.cacheCreateTokens-o.cacheCreateTokens};i.cost<0||i.inputTokens<0||i.outputTokens<0||i.cost===0&&i.inputTokens===0&&i.outputTokens===0&&i.cacheReadTokens===0&&i.cacheCreateTokens===0||(n.cost+=i.cost,n.inputTokens+=Math.max(0,i.inputTokens),n.outputTokens+=Math.max(0,i.outputTokens),n.cacheReadTokens+=Math.max(0,i.cacheReadTokens),n.cacheCreateTokens+=Math.max(0,i.cacheCreateTokens),n.sessions+=1)}return n}function T0(e,t=new Date){return new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate()-(e-1))).toISOString().slice(0,10).replace(/-/g,"")}const vf=[{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 $K(e,t,n=vf.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 LK(e,t=new Date){return e==="today"?T0(1,t):e==="month"?T0(t.getDate(),t):"20200101"}const kn=e=>typeof e=="number"&&Number.isFinite(e)?e:0,Qd=e=>typeof e=="string"?e:"";function r3(e){const t=Array.isArray(e==null?void 0:e.days)?e.days:[],n=new Map;for(const r of t){const s=Array.isArray(r==null?void 0:r.modelBreakdowns)?r.modelBreakdowns:[];for(const o of s){const i=Qd(o==null?void 0:o.modelName);if(!i)continue;let c=n.get(i);c||(c={model:i,cost:0,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0,get tokens(){return this.inputTokens+this.outputTokens+this.cacheReadTokens+this.cacheCreateTokens}},n.set(i,c)),c.cost+=kn(o==null?void 0:o.cost),c.inputTokens+=kn(o==null?void 0:o.inputTokens),c.outputTokens+=kn(o==null?void 0:o.outputTokens),c.cacheReadTokens+=kn(o==null?void 0:o.cacheReadTokens),c.cacheCreateTokens+=kn(o==null?void 0:o.cacheCreationTokens)}}return[...n.values()].sort((r,s)=>s.cost-r.cost||s.tokens-r.tokens)}const OK=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function IK(e){var t;return((t=OK.exec(e))==null?void 0:t[0])??e}function PK(e,t=new Map){const n=Array.isArray(e==null?void 0:e.sessions)?e.sessions:[],r=[];for(const s of n){const o=Qd(s==null?void 0:s.period);if(!o)continue;const i=IK(o),c=s==null?void 0:s.metadata,d=typeof(c==null?void 0:c.lastActivity)=="string"?Date.parse(c.lastActivity):NaN;r.push({sessionId:i,label:t.get(i)??null,agent:Qd(s==null?void 0:s.agent)||"claude",cost:kn(s==null?void 0:s.totalCost),tokens:kn(s==null?void 0:s.totalTokens),models:Array.isArray(s==null?void 0:s.modelsUsed)?s.modelsUsed.map(Qd).filter(Boolean):[],lastActivityMs:Number.isFinite(d)?d:null})}return r.sort((s,o)=>o.cost-s.cost||o.tokens-s.tokens)}function DK(e,t=e1(e).cost){const r=(Array.isArray(e==null?void 0:e.sessions)?e.sessions:[]).reduce((o,i)=>o+kn(i==null?void 0:i.totalCost),0),s=Math.max(.01,t*.01);return{sum:r,total:t,over:r>t+s}}function FK(e,t,n){const r=`Sessions with activity ${e}, and what ccusage puts against each one.`;return t.over?`${r}
|
|
89
|
-
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 e1(e){const t=e==null?void 0:e.totals;if(t&&typeof t=="object"){const d=kn(t.cacheReadTokens),h=kn(t.cacheCreationTokens),f=kn(t.inputTokens),p=kn(t.outputTokens);return{cost:kn(t.totalCost),inputTokens:f,outputTokens:p,cacheReadTokens:d,cacheCreateTokens:h,tokens:kn(t.totalTokens)||f+p+d+h}}const n=r3(e),r=d=>n.reduce((h,f)=>h+d(f),0),s=r(d=>d.inputTokens),o=r(d=>d.outputTokens),i=r(d=>d.cacheReadTokens),c=r(d=>d.cacheCreateTokens);return{cost:r(d=>d.cost),inputTokens:s,outputTokens:o,cacheReadTokens:i,cacheCreateTokens:c,tokens:s+o+i+c}}function BK(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 s3(e,t){var n;return((n=vf.find(r=>r.key===(e??t)))==null?void 0:n.noun)??"today"}function qK(e,t,n){const r=e!=null,s=e1(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 a3="agent-dag.usagePeriod";function UK(){const e=Ge(a3);return vf.some(t=>t.key===e)?e:"today"}function HK(e){Ve(a3,e)}const o3="agent-dag.usageSessionsOpen";function WK(){return Ge(o3)==="1"}function zK(e){Ve(o3,e?"1":"0")}function t1({cost:e,size:t="md"}){const n=e.total;if(n<=0)return null;const r=(o,i,c)=>{if(o<=0)return null;const d=o/n*100;return a.jsx("span",{className:`cb-seg ${i}`,style:{width:`${d}%`},title:`${c}: ${Ye(o)} (${d.toFixed(0)}%)`},i)},s=t==="lg";return a.jsxs("div",{className:s?"cost-bar cost-bar-lg":"cost-bar",role:"img","aria-label":"Cost breakdown",children:[r(e.input,"cb-input","input"),r(e.output,"cb-output","output"),r(e.cacheRead,"cb-cache-r","cache read"),r(e.cacheWrite,"cb-cache-w","cache write")]})}const Rd="https://ccdeck.dev/guides",VK={localNetwork:{href:`${Rd}/local-network/#film`,subject:"Local network"},claudeAccounts:{href:`${Rd}/claude-accounts/#film`,subject:"Claude accounts"},usage:{href:`${Rd}/cost-and-quota/#film`,subject:"cost and quota"},tour:{href:`${Rd}/first-run/#film`,subject:"first run"}};function Ic({film:e,action:t=!1}){const{href:n,subject:r}=VK[e];return a.jsxs("a",{className:t?"film-link film-action":"film-link",href:n,target:"_blank",rel:"noopener noreferrer",title:`The ${r} video on ccdeck.dev, 30 seconds — opens in your browser`,children:[t?a.jsxs(a.Fragment,{children:[a.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round","aria-hidden":"true",children:a.jsx("path",{d:"m8 5 11 7-11 7V5Z"})}),a.jsx("span",{children:"Watch video"}),a.jsx("span",{className:"film-duration",children:"30 s"})]}):"Watch · 30 s",a.jsxs("span",{className:"vis-hidden",children:[": the ",r," video on ccdeck.dev, opens in your browser"]})]})}const Lt="ccdeck",GK="/brand/ccdeck-mark-gradient-small-optical.svg",KK="/brand/ccdeck-mark-mono-dark-small-optical.svg";function i3(e,t){const n=t.nextExpiryAt!=null?` · expires ${new Date(t.nextExpiryAt).toLocaleDateString("en-US",{month:"short",day:"numeric"})}`:"";return`${t.availableCount} ${e}${t.availableCount!==1?"s":""} available${n}`}function l3(){return a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("path",{d:"M11.6 6.2A4.8 4.8 0 1 0 11 9.6"}),a.jsx("path",{d:"M11.9 2.6v3.7h-3.6"})]})}function c3(){return a.jsx("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:a.jsx("path",{d:"M3.3 10.7L10.7 3.3M5.5 3.3h5.2v5.2"})})}function YK({incidents:e}){return a.jsx(a.Fragment,{children:e.map(t=>a.jsxs("a",{className:t.stale?"provider-incident provider-incident-stale":"provider-incident","data-state":t.state,href:t.href,target:"_blank",rel:"noopener noreferrer",title:t.detail,children:[a.jsx("span",{className:"pi-dot","aria-hidden":!0}),a.jsx("span",{className:"pi-name",children:t.name}),a.jsxs("span",{className:"pi-words",children:["· ",t.chipWords]}),a.jsxs("span",{className:"pi-short",children:["· ",t.shortWords]}),t.asOf&&a.jsxs("span",{className:"pi-asof",children:["· as of ",t.asOf]}),a.jsx("span",{className:"pi-go","aria-hidden":!0,children:a.jsx(c3,{})}),a.jsxs("span",{className:"vis-hidden",children:[", on ",t.host,", opens in a new tab"]})]},t.provider))})}function u3({incident:e}){return e?a.jsxs("a",{className:e.stale?"up-incident up-incident-stale":"up-incident","data-state":e.state,href:e.href,target:"_blank",rel:"noopener noreferrer",title:e.detail,children:[a.jsx("span",{className:"pi-dot","aria-hidden":!0}),a.jsxs("span",{className:"up-incident-words",children:[a.jsxs("span",{className:"vis-hidden",children:[e.name,": "]}),e.words[0].toUpperCase()+e.words.slice(1),e.asOf?` · as of ${e.asOf}`:""]}),a.jsx("span",{className:"up-incident-go","aria-hidden":!0,children:a.jsx(c3,{})}),e.what&&a.jsx("span",{className:"up-incident-what",children:e.what}),a.jsxs("span",{className:"vis-hidden",children:[", on ",e.host,", opens in a new tab"]})]}):null}function XK(e,t,n,r,s=!1){const o=Math.max(0,t-r),i=Math.max(0,n-o);if(i<120)return null;const c=Math.min(100,i/n*100),d=e-c;if(s||e>=100)return{label:"used up",color:"var(--warn)",expectedPct:c,isDeficit:!0};if(Math.abs(d)<3)return{label:"on pace",color:"var(--ok)",expectedPct:c,isDeficit:!1};if(d>0){const h=100-e,f=i>0?e/i:0,p=f>0?h/f:1/0,g={label:`${Math.round(d)}% over pace`,color:"var(--warn)",expectedPct:c,isDeficit:!0};if(p<o&&p<86400){const w=Math.floor(p/3600),k=Math.floor(p%3600/60);g.runsOutIn=w>0?`${w}h ${k}m`:`${k}m`}return g}return{label:`${Math.round(-d)}% under pace`,color:"var(--ok)",expectedPct:c,isDeficit:!1}}function ya({pct:e,label:t,reset:n,resetAt:r,windowSec:s,limitReached:o,nowSec:i}){const c=!!r&&r<=i,d=e!=null&&!c,h=d?Math.min(100,Math.max(0,e)):0,p=o||h>=90?"var(--err)":h>=70?"var(--warn)":"var(--accent)",g=h<1,w=c?"reset":d?g?"< 1%":`${Math.round(h)}%`:"no reading",k=g?2:h,j=r&&!c?Qc(r,i):null,v=d&&r&&s?XK(h,r,s,i,o):null,[b,N]=y.useState(!1),S=y.useId();return a.jsxs("div",{className:"qb-row",children:[a.jsxs("div",{className:"qb-meta",children:[a.jsxs("span",{className:"qb-label",children:[t,o&&!c&&a.jsx("span",{className:"qb-limit-badge",title:"Rate limit reached",children:"⛔"})]}),a.jsx("span",{className:"qb-pct",style:{color:d?p:"var(--muted)"},children:w})]}),a.jsxs("div",{className:"qb-track",children:[d&&a.jsx("div",{className:"qb-fill",style:{transform:`scaleX(${k/100})`,background:p,opacity:g?.4:1}}),v&&a.jsx("div",{className:"qb-pace-rail",style:{transform:`translateX(${v.expectedPct}%)`},children:a.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`})})]}),a.jsxs("div",{className:"qb-reset-row",children:[c?a.jsx("span",{className:"qb-reset",children:"waiting for a new reading"}):j?a.jsxs("span",{className:"qb-reset",children:["resets in ",j]}):n?a.jsxs("span",{className:"qb-reset",children:["resets ",n]}):null,v&&a.jsxs("button",{type:"button",className:"qb-pace",style:{color:v.color},"aria-expanded":b,"aria-controls":b?S:void 0,onClick:()=>N(E=>!E),children:[a.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]})]}),b&&v&&a.jsxs("div",{id:S,className:"qb-why",children:["To last until reset, stay near ",Math.round(v.expectedPct),"% by now."]})]})}function d3(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 ZK(e){return e==="claude-swap"?"Read from claude-swap's last collection — costs no request against your usage-endpoint budget. Saved limit resets, which it does not collect, are read separately: every 30 minutes, or 5 on refresh":e==="api"?"Fetched from Anthropic's usage endpoint, at most once every 5 minutes":e==="cli"?"Parsed from `claude /usage`, at most once every 5 minutes":"Last update"}function JK(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 QK(e){switch(e){case"no_token":return"Run codex login to authenticate.";case"api_key_mode":return"API-key login — ChatGPT quota is only available for codex login.";case"refresh_rejected":return"Codex session expired — run codex login.";case"refresh_failed":return"Couldn't refresh the Codex token — click ↻ to retry.";case"untrusted_base_url":return"chatgpt_base_url in ~/.codex/config.toml is not an https OpenAI host, so the token was not sent.";case"rate_limited":return"OpenAI asked the deck to wait — it will retry on its own.";case"waiting":return"Waiting for the next allowed read — or click ↻.";default:return"ChatGPT API unreachable — click ↻ to retry."}}function eY({quota:e,quotaLoading:t,nowSec:n,incident:r}){const s=d3(e==null?void 0:e.fetchedAt,n);return a.jsxs("section",{className:"up-section up-quota-section",children:[a.jsxs("h3",{className:"up-section-title",children:["Claude quota",s&&!t&&a.jsxs("span",{className:"up-section-age",title:ZK(e==null?void 0:e.source),children:[s,(e==null?void 0:e.stale)&&" · no newer reading"]})]}),a.jsx(u3,{incident:r}),e!=null&&e.ok?a.jsxs("div",{className:"up-quota-bars",children:[e.session5hPct!=null&&a.jsx(ya,{label:"5-hour window",pct:e.session5hPct,reset:e.session5hReset,resetAt:e.session5hResetAt,windowSec:e.session5hWindowSec,nowSec:n}),a.jsx(ya,{label:"7-day window",pct:e.week7dPct??null,reset:e.week7dReset,resetAt:e.week7dResetAt,windowSec:e.week7dWindowSec,nowSec:n}),e.weekSonnetPct!=null&&a.jsx(ya,{label:"Sonnet (7d)",pct:e.weekSonnetPct,nowSec:n}),e.weekOpusPct!=null&&a.jsx(ya,{label:"Opus (7d)",pct:e.weekOpusPct,nowSec:n}),e.extraEnabled&&e.extraUsedCredits!=null&&e.extraMonthlyLimit?a.jsx(ya,{label:`Extra credits (month${e.extraCurrency?`, ${e.extraCurrency}`:""})`,pct:Math.min(100,Math.round(e.extraUsedCredits/e.extraMonthlyLimit*100)),nowSec:n}):e.extraEnabled&&a.jsx("div",{className:"up-quota-sub up-credits",children:"extra usage credits: on"}),e.resetCredits&&e.resetCredits.availableCount>0&&a.jsx("div",{className:"up-quota-sub up-reset-credits",title:`Saved in Claude as "Reset for free". Redeem one in Claude on the web or desktop — ${Lt} only reports them`,children:i3("limit reset",e.resetCredits)})]}):(e==null?void 0:e.ok)===!1?a.jsxs("div",{className:"up-quota-na",children:[a.jsx("span",{children:e.reason==="no_subscription"?"No quota to show.":"Quota unavailable."}),a.jsx("span",{className:"up-quota-hint",children:JK(e.reason)})]}):a.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]})}function tY({codexQuota:e,codexLoading:t,nowSec:n,incident:r}){var o,i;const s=d3(e==null?void 0:e.fetchedAt,n);return a.jsxs("section",{className:"up-section up-quota-section",children:[a.jsxs("h3",{className:"up-section-title",children:["Codex quota",(e==null?void 0:e.ok)&&e.planLabel&&a.jsx("span",{className:"up-plan-badge",children:e.planLabel}),s&&!t&&a.jsx("span",{className:"up-section-age",title:"Fetched from the Codex usage endpoint",children:s})]}),a.jsx(u3,{incident:r}),e!=null&&e.ok?a.jsxs("div",{className:"up-quota-bars",children:[(o=e.windows)==null?void 0:o.map(c=>a.jsx(ya,{label:c.label,pct:c.pct,reset:c.reset??void 0,resetAt:c.resetAt??void 0,windowSec:c.windowSec??void 0,limitReached:e.limitReached&&c.pct>=100,nowSec:n},c.id)),(i=e.extraWindows)==null?void 0:i.map(c=>a.jsx(ya,{label:c.label,pct:c.pct,reset:c.reset??void 0,resetAt:c.resetAt??void 0,windowSec:c.windowSec??void 0,nowSec:n},c.id)),e.creditLimit&&a.jsx(ya,{label:`spend cap · $${Math.round(e.creditLimit.used)} of $${Math.round(e.creditLimit.limit)}`,pct:e.creditLimit.usedPct,reset:e.creditLimit.reset??void 0,resetAt:e.creditLimit.resetAt??void 0,limitReached:e.spendControlReached,nowSec:n}),e.creditsBalance&&!e.creditsUnlimited&&a.jsxs("div",{className:"up-quota-sub up-credits",children:["credits: $",e.creditsBalance,e.overageReached&&" · overage limit reached"]}),e.creditsUnlimited&&a.jsx("div",{className:"up-quota-sub up-credits",children:"credits: unlimited"}),e.resetCredits&&e.resetCredits.availableCount>0&&a.jsx("div",{className:"up-quota-sub up-reset-credits",title:`Redeem in the Codex CLI or ChatGPT — ${Lt} only reports them`,children:i3("rate-limit reset",e.resetCredits)}),e.promo&&a.jsx("div",{className:"up-quota-sub",children:e.promo}),e.partial&&a.jsx("div",{className:"up-quota-sub up-quota-hint",children:"Partial data — OpenAI returned limits this build doesn't recognise."})]}):(e==null?void 0:e.ok)===!1?a.jsxs("div",{className:"up-quota-na",children:[a.jsx("span",{children:"Quota unavailable."}),a.jsx("span",{className:"up-quota-hint",children:QK(e.reason)})]}):a.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]})}function nY({fromRange:e,rangeModelRows:t,boardModelRows:n}){return a.jsxs("section",{className:"up-section",children:[a.jsx("h3",{className:"up-section-title",children:"By model"}),a.jsxs("table",{className:"up-table",children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx("th",{children:"Model"}),a.jsx("th",{children:"Tokens"}),a.jsx("th",{children:"Cost"})]})}),a.jsx("tbody",{children:e?t.map(r=>a.jsxs("tr",{children:[a.jsx("td",{className:"up-model-name",title:r.model,children:rs(r.model)}),a.jsx("td",{className:"up-num",children:ut(r.tokens)}),r.cost>0?a.jsx("td",{className:"up-num up-cost-val",children:Ye(r.cost)}):a.jsx("td",{className:"up-num up-unpriced",children:Ls})]},r.model)):n.map(r=>a.jsxs("tr",{children:[a.jsx("td",{className:"up-model-name",title:r.model===j0?"no model reported yet":r.model,children:r.model===j0?"unknown":rs(r.model)}),a.jsx("td",{className:"up-num",children:ut(r.inputTokens+r.outputTokens)}),r.priced?a.jsx("td",{className:"up-num up-cost-val",children:Ye(r.cost.total)}):a.jsx("td",{className:"up-num up-unpriced",children:Ls})]},r.model))})]})]})}function rY({period:e,rangePending:t,setPeriod:n}){const r=y.useRef([]);return a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"uh-range up-period",role:"toolbar","aria-orientation":"horizontal","aria-label":"Period","aria-busy":t||void 0,onKeyDown:s=>{var c;const o=r.current.indexOf(s.target);if(o<0)return;const i=$K(s.key,o);i!==null&&(s.preventDefault(),(c=r.current[i])==null||c.focus())},children:vf.map((s,o)=>a.jsx("button",{type:"button",ref:i=>{r.current[o]=i},tabIndex:e===s.key?0:-1,"aria-pressed":e===s.key,"data-pending":e===s.key&&t?"":void 0,title:e===s.key&&t?`Reading ${s.noun} from the transcripts on this machine…`:s.hint,className:"uh-range-btn",onClick:()=>n(s.key),children:s.label},s.key))}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:t?`Reading ${s3(e,e)}…`:""})]})}function sY(e,t){return t.includes("..")?!1:e==="codex"?/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/i.test(t):e==="claude"&&/^[a-z\d][a-z\d._:-]{0,255}$/i.test(t)}function aY(e){return e.reason==="not_found"?"No usage found in the local logs for this session.":e.reason==="ambiguous"?"More than one local log matches this session ID.":e.reason==="no_install"?"Install ccusage to read this session’s usage.":e.reason==="busy"?"Other usage reports are still loading. Try again in a moment.":e.reason==="timeout"?"The session report took too long. Try again.":/unknown|unrecognized|unexpected|unsupported/i.test(e.error??"")&&/speed|--id|session|claude/i.test(e.error??"")?"This copy of ccusage does not support the report. Update ccusage and try again.":"Could not read this session’s usage. Try again."}function bE({sessionId:e,agent:t,label:n,onOpen:r,children:s}){return r&&sY(t,e)?a.jsxs("button",{type:"button",className:"up-session-row up-session-open",title:`Inspect session usage · ${n}`,onClick:()=>r({sessionId:e,agent:t,label:n}),children:[s,a.jsx("svg",{className:"up-session-inspect",width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:a.jsx("path",{d:"m3.5 2 3 3-3 3"})}),a.jsx("span",{className:"vis-hidden",children:"Open session usage"})]}):a.jsx("div",{className:"up-session-row",children:s})}function oY({fromRange:e,rangeSessionRows:t,boardSessionRows:n,boardStates:r,sessionsOpen:s,setSessionsOpen:o,periodNoun:i,sessionScale:c,onOpenSession:d,boardProviders:h}){const f=e?t.length:n.length;return a.jsxs("section",{className:"up-section",children:[a.jsx("h3",{className:"up-section-title",children:a.jsxs("button",{type:"button",className:"up-disclose","aria-expanded":s,"aria-controls":"up-sessions",title:s?"Hide the per-session breakdown":`Show the per-session breakdown — ${f} session${f===1?"":"s"}`,onClick:()=>o(p=>!p),children:["By session",e&&a.jsxs("span",{className:"up-section-age",title:FK(i,c,Ye),children:["active ",i]}),a.jsx("svg",{className:"up-chev",width:"9",height:"9",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:a.jsx("path",{d:"M2.2 3.6 5 6.4 7.8 3.6"})})]})}),a.jsxs("div",{className:"up-sessions",id:"up-sessions",hidden:!s,children:[e&&t.map(p=>{const g=r.get(p.sessionId);return a.jsxs(bE,{sessionId:p.sessionId,agent:p.agent,label:p.label??Sh(p.sessionId,8),onOpen:d,children:[g?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:`sl-dot state-${g}`,"aria-hidden":!0}),a.jsx("span",{className:"vis-hidden",children:Wi(g)})]}):a.jsx("span",{className:"sl-dot up-dot-past","aria-hidden":!0}),a.jsx("span",{className:`up-session-label${p.label?"":" up-session-id"}`,title:p.label?`${p.label}
|
|
90
|
-
${p.sessionId}`:p.sessionId,children:p.label??Sh(p.sessionId,8)}),a.jsx("span",{className:"up-session-tokens",children:ut(p.tokens)}),p.cost>0?a.jsx("span",{className:"up-session-cost",title:p.models.join(", ")||void 0,children:Ye(p.cost)}):a.jsx("span",{className:"up-session-cost up-unpriced",children:Ls})]},`${p.agent}:${p.sessionId}`)}),!e&&n.map(p=>a.jsxs(bE,{sessionId:p.sessionId,agent:(h==null?void 0:h.get(p.sessionId))??"claude",label:p.label,onOpen:d,children:[a.jsx("span",{className:`sl-dot state-${p.state}`,"aria-hidden":!0}),a.jsx("span",{className:"vis-hidden",children:Wi(p.state)}),a.jsx("span",{className:"up-session-label",children:p.label}),a.jsx("span",{className:"up-session-tokens",children:ut(p.inputTokens+p.outputTokens)}),p.cost>0?a.jsxs("span",{className:"up-session-cost",title:p.unpricedTokens>0?`${ut(p.unpricedTokens)} tokens in this session are on an unpriced model, so this is a floor`:void 0,children:[Ye(p.cost),p.unpricedTokens>0?"+":""]}):a.jsx("span",{className:"up-session-cost up-unpriced",children:Ls})]},p.sessionId))]})]})}function iY(e){return e.claude&&e.codex?"Claude Code and Codex":e.claude?"Claude Code":e.codex?"Codex":null}const lY={claude:"Claude Code",codex:"Codex",opencode:"OpenCode",openclaw:"OpenClaw",copilot:"GitHub Copilot",pi:"pi-agent",zcode:"ZCode"};function h3(e){const t=e.toLowerCase(),n=qt(lY,t);return n!==void 0?n:t?t[0].toUpperCase()+t.slice(1):""}function cY(e){return e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function sge(e,t=[]){const n=t.length?cY(t.map(h3)):iY(e);return n?`via ccusage · local ${n} logs`:"via ccusage · local agent logs"}function uY(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]}const Ad=e=>e.toLocaleString(),kE=e=>new Date(e).toLocaleString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"});function dY({session:e,onClose:t}){var v,b;const[n,r]=y.useState("auto"),[s,o]=y.useState(0),[i,c]=y.useState(null),d=y.useRef(s),h=y.useRef(null),f=ot(t,{focusRef:h}),p=dt(t),g=i!=null&&i.ok&&((v=i.detail)==null?void 0:v.speed)===n?i.detail:void 0;y.useEffect(()=>{const N=new AbortController;c(null);const S=new URLSearchParams({agent:e.agent,id:e.sessionId,speed:n});return s!==d.current&&S.set("refresh","1"),d.current=s,fetch(`/api/ccusage/session?${S}`,{signal:N.signal}).then(async E=>{const C=await E.json();N.signal.aborted||c(C)}).catch(()=>{N.signal.aborted||c({ok:!1})}),()=>N.abort()},[e.agent,e.sessionId,n,s]);const w=(g==null?void 0:g.models.filter(N=>N.missingPricing))??[],k=g?[{name:"Input",n:g.inputTokens,color:"var(--usage-blue)"},{name:"Output",n:g.outputTokens,color:"var(--usage-purple)"},{name:"Cache read",n:g.cacheReadTokens,color:"var(--usage-teal)"},{name:"Cache write",n:g.cacheCreationTokens,color:"var(--usage-orange)"}]:[],j=k.reduce((N,S)=>N+S.n,0);return yt.createPortal(a.jsx("div",{className:"modal-backdrop",...p,role:"presentation",children:a.jsxs("div",{className:"modal su-modal",ref:f,role:"dialog","aria-modal":"true","aria-labelledby":"session-usage-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsxs("div",{className:"su-title",children:[a.jsx("h2",{id:"session-usage-title",children:"Session usage"}),a.jsx("span",{title:e.label,children:e.label})]}),a.jsxs("div",{className:"modal-actions",children:[a.jsx("button",{type:"button",className:"glyph-btn",onClick:()=>o(N=>N+1),disabled:!i,"aria-label":"Refresh session usage",title:"Refresh session usage",children:a.jsx(l3,{})}),a.jsx("button",{type:"button",className:"glyph-btn",ref:h,onClick:t,"aria-label":"Close session usage (Esc)",title:"Close (Esc)",children:"×"})]})]}),a.jsxs("div",{className:"modal-body su-body","aria-busy":!i,children:[a.jsxs("div",{className:"su-scope",children:[a.jsx("span",{children:h3(e.agent)}),a.jsx("span",{children:"Whole session"})]}),e.agent==="codex"&&a.jsxs("label",{className:"su-pricing",children:["Estimate using",a.jsxs("select",{value:n,disabled:!i,onChange:N=>{c(null),r(N.target.value)},children:[a.jsx("option",{value:"auto",children:"Session settings / config"}),a.jsx("option",{value:"standard",children:"Standard scenario"}),a.jsx("option",{value:"fast",children:"Fast scenario"}),a.jsx("option",{value:"flex",children:"Flex scenario"})]})]}),!i&&a.jsx("p",{className:"su-message",role:"status",children:"Reading local session usage…"}),i&&!i.ok&&a.jsxs("p",{className:"su-message",role:"status",title:i.error,children:[aY(i)," Use Refresh to try again."]}),g&&a.jsxs(a.Fragment,{children:[a.jsxs("dl",{className:"su-totals",children:[a.jsxs("div",{children:[a.jsxs("dt",{children:[n==="auto"?"Estimated cost":"Scenario estimate",w.length>0?" · partial":""]}),a.jsxs("dd",{children:[g.totalCost>0?Ye(g.totalCost):g.totalTokens>0?"No cost reported":"$0.00",w.length>0&&g.totalCost>0?"+":""]})]}),a.jsxs("div",{children:[a.jsx("dt",{children:"Total tokens"}),a.jsx("dd",{title:Ad(g.totalTokens),children:ut(g.totalTokens)})]})]}),a.jsxs("section",{"aria-labelledby":"session-tokens-title",children:[a.jsx("div",{className:"su-section-head",children:a.jsx("h3",{id:"session-tokens-title",children:"Token breakdown"})}),a.jsxs("div",{className:"su-cache-reuse",children:[a.jsx("span",{children:"Cached input reuse"}),a.jsx("strong",{children:((b=g.cacheReuse)==null?void 0:b.pct)!=null?`${g.cacheReuse.pct.toLocaleString(void 0,{maximumFractionDigits:1})}%`:"—"}),a.jsx("span",{className:"su-note",children:g.cacheReuse&&g.cacheReuse.measured>0?`${g.cacheReuse.measured} of ${g.cacheReuse.total} ${g.cacheReuse.unit} measured${g.cacheReuse.pct==null?" · no input tokens":""}`:"No cache measurements available"})]}),j>0&&a.jsx("div",{className:"su-composition","aria-hidden":"true",children:k.filter(N=>N.n>0).map(N=>a.jsx("span",{style:{width:`${N.n/j*100}%`,background:N.color}},N.name))}),a.jsx("dl",{className:"su-tokens",children:k.map(({name:N,n:S,color:E})=>a.jsxs("div",{children:[a.jsxs("dt",{children:[a.jsx("span",{className:"su-key",style:{background:E},"aria-hidden":"true"}),N]}),a.jsxs("dd",{title:Ad(S),children:[ut(S),a.jsx("span",{className:"su-share",children:j>0?`${(S/j*100).toLocaleString(void 0,{maximumFractionDigits:1})}%`:"—"})]})]},N))}),g.reasoningOutputTokens>0&&a.jsxs("p",{className:"su-note su-reasoning",children:[ut(g.reasoningOutputTokens)," reasoning tokens, included in output."]})]}),a.jsxs("section",{className:"su-models","aria-labelledby":"session-models-title",children:[a.jsxs("div",{className:"su-section-head",children:[a.jsx("h3",{id:"session-models-title",children:"Models"}),a.jsxs("span",{children:[g.models.length," used"]})]}),a.jsxs("table",{children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx("th",{scope:"col",children:"Model"}),a.jsx("th",{scope:"col",children:"Tokens"})]})}),a.jsx("tbody",{children:g.models.map(N=>a.jsxs("tr",{children:[a.jsxs("th",{scope:"row",title:N.model,children:[rs(N.model),N.missingPricing&&a.jsx("span",{className:"su-unpriced",children:" · not priced"})]}),a.jsx("td",{title:Ad(N.totalTokens),children:ut(N.totalTokens)})]},N.model))})]}),g.models.length===0&&a.jsx("p",{className:"su-note",children:"No model breakdown was reported."})]}),w.length>0&&a.jsx("p",{className:"su-note",children:"Tokens on unpriced models are included; their cost is missing from the estimate."}),a.jsxs("dl",{className:"su-dates",children:[g.firstActivity&&a.jsxs("div",{children:[a.jsx("dt",{children:"First activity"}),a.jsx("dd",{children:a.jsx("time",{dateTime:g.firstActivity,title:new Date(g.firstActivity).toLocaleString(),children:kE(g.firstActivity)})})]}),g.lastActivity&&a.jsxs("div",{children:[a.jsx("dt",{children:"Last activity"}),a.jsx("dd",{children:a.jsx("time",{dateTime:g.lastActivity,title:new Date(g.lastActivity).toLocaleString(),children:kE(g.lastActivity)})})]}),g.entries!=null&&a.jsxs("div",{children:[a.jsx("dt",{children:"Usage records"}),a.jsx("dd",{children:Ad(g.entries)})]})]})]}),a.jsxs("footer",{className:"su-footer",children:[a.jsxs("p",{className:"su-note",children:[n==="auto"?"Estimated from local logs, not an invoice.":"Pricing scenario · does not change settings or billing."," Includes the whole session."]}),a.jsxs("details",{className:"su-id su-assumptions",children:[a.jsx("summary",{children:"Estimate details"}),a.jsxs("p",{className:"su-note",children:[e.agent==="codex"?n==="auto"?"ccusage estimates from recorded Standard, Fast and Flex settings; unmarked usage can use your current Codex config. Requested modes do not confirm billed rates.":"This scenario applies one mode to the whole session. It does not change Codex or your billing. Models without a published multiplier keep standard pricing.":"Cost is the ccusage estimate from local logs, not an invoice."," The whole session can extend beyond the period selected in Usage."]})]}),a.jsxs("details",{className:"su-id",children:[a.jsx("summary",{children:"Session ID"}),a.jsx("code",{children:e.sessionId})]})]})]})]})}),document.body)}const Md=e=>`${e.id}:${e.windowSec}:${e.resetAt}`;function hY(e){var o;const t=(e.resetAt-e.windowSec)*1e3,n=i=>36+Math.max(0,Math.min(1,(i-t)/(e.windowSec*1e3)))*516,r=i=>12+Math.max(0,Math.min(100,i))/100*150,s=[];for(const i of e.points){if(!Number.isFinite(i.t)||!Number.isFinite(i.pct)||i.pct<0||i.pct>100)continue;const c=(o=s.at(-1))==null?void 0:o.at(-1);(!c||i.t-c.t>10*6e4||i.t<=c.t)&&s.push([]),s.at(-1).push({...i,x:n(i.t),y:r(i.pct)})}return s}function fY(e,t){const n=Math.max(0,Math.floor((t-e)/6e4));return n<1?"just now":n<60?`${n}m ago`:n<1440?`${Math.floor(n/60)}h ${n%60}m ago`:`${Math.floor(n/1440)}d ago`}function Sa(e,t){return{disabled:e!=null&&e!==t,busy:e===t}}function bf(e){return e==null}const R0="self";function ts(e,t=!1){const n=Sa(e?R0:null,R0);return{disabled:t||n.disabled,"aria-busy":n.busy}}function qn(e){return bf(e?R0:null)}const Yi=400;function Xi({armedFor:e,target:t,armedAt:n,now:r,gapMs:s}){return e!==t?"arm":r-n<s?"ignore":"fire"}function f3(e){return[...e==null?[]:[`#ap-more-${e}`],".accounts-panel .ap-refresh"]}function Vn(e){return e==null||e==="BODY"||e==="HTML"}const Ii=e=>new Date(e).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}),jE=e=>new Date(e).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"});function pY({series:e}){const t=hY(e),n=(e.resetAt-e.windowSec)*1e3,r=e.resetAt*1e3;return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"qh-chart-wrap",children:[a.jsxs("div",{className:"qh-axis","aria-hidden":"true",children:[a.jsx("span",{children:"100%"}),a.jsx("span",{children:"50%"}),a.jsx("span",{children:"0%"})]}),a.jsxs("svg",{className:"qh-chart",viewBox:"36 12 516 150",role:"img","aria-label":`${e.label}: observed remaining quota over time. Dashed line is an even-use guide, not a forecast.`,children:[[0,50,100].map(s=>a.jsx("g",{children:a.jsx("line",{className:"qh-grid",x1:"36",x2:"552",y1:12+s*1.5,y2:12+s*1.5})},s)),a.jsx("path",{className:"qh-guide",d:"M36 12 L552 162"}),t.map((s,o)=>a.jsxs("g",{children:[s.length>1&&a.jsx("path",{className:"qh-observed",d:s.map((i,c)=>`${c?"L":"M"}${i.x} ${i.y}`).join(" ")}),[s[0],...s.length>1?[s.at(-1)]:[]].map(i=>a.jsx("circle",{className:"qh-point",cx:i.x,cy:i.y,r:"2.5",children:a.jsxs("title",{children:[Ii(i.t)," · ",Math.round(100-i.pct),"% remaining"]})},i.t))]},o))]}),a.jsxs("div",{className:"qh-times","aria-hidden":"true",children:[a.jsx("span",{children:e.windowSec>86400?Ii(n):jE(n)}),a.jsx("span",{children:e.windowSec>86400?Ii(r):jE(r)})]})]}),a.jsxs("div",{className:"qh-legend",children:[a.jsxs("span",{children:[a.jsx("i",{className:"qh-key"}),"Observed remaining"]}),a.jsxs("span",{children:[a.jsx("i",{className:"qh-key qh-key-guide"}),"Even-use guide"]})]})]})}function mY({providers:e,accounts:t,onClose:n,instant:r=!1}){const[s,o]=y.useState(e.claude?"claude":"codex"),[i,c]=y.useState(null),[d,h]=y.useState(!0),[f,p]=y.useState(!1),[g,w]=y.useState(""),[k,j]=y.useState(0),[v,b]=y.useState(Date.now),N=y.useRef(!1),S=y.useRef(null),E=ot(n,{focusRef:S}),C=dt(n),$=t[s];y.useEffect(()=>{let P=!1,L=null;c(null),p(!1);const F=async()=>{if(L)return;if(!$){N.current=!1,h(!1);return}const B=new AbortController;L=B,N.current=!0;const D=window.setTimeout(()=>B.abort(),12e3);h(!0);try{const K=await fetch(`/api/quota/history?provider=${s}&account=${encodeURIComponent($)}`,{signal:B.signal}),G=await K.json();if(!K.ok||!G.ok||!Array.isArray(G.series))throw new Error("History unavailable");P||(c(G.account===$?G:{...G,series:[]}),p(!1))}catch{P||p(!0)}finally{window.clearTimeout(D),L=null,P||(N.current=!1,h(!1))}};F();const A=window.setInterval(()=>{b(Date.now()),document.visibilityState==="visible"&&F()},6e4);return()=>{P=!0,L==null||L.abort(),window.clearInterval(A)}},[s,$,k]);const T=((i==null?void 0:i.series)??[]).slice().sort((P,L)=>L.resetAt-P.resetAt||P.windowSec-L.windowSec),I=T.find(P=>Md(P)===g)??T.find(P=>P.resetAt*1e3>v&&P.windowSec<=6*3600)??T[0],O=I==null?void 0:I.points.at(-1),U=()=>{qn(N.current)&&(N.current=!0,j(P=>P+1))};return yt.createPortal(a.jsx("div",{className:"modal-backdrop",role:"presentation",...C,children:a.jsxs("div",{className:"modal qh-modal","data-keyboard-interaction":r||void 0,ref:E,role:"dialog","aria-modal":"true","aria-labelledby":"quota-history-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("h2",{id:"quota-history-title",children:"Quota history"}),a.jsxs("div",{className:"qh-header-actions",children:[a.jsx("button",{type:"button",className:"glyph-btn","aria-label":"Refresh quota history",title:"Read recorded quota history",...ts(d),onClick:U,children:d?"…":a.jsx(l3,{})}),a.jsx("button",{type:"button",ref:S,className:"glyph-btn",onClick:n,"aria-label":"Close quota history",children:"×"})]})]}),a.jsxs("div",{className:"modal-body qh-body","aria-busy":d,children:[a.jsxs("div",{className:"qh-controls",children:[a.jsx("div",{className:"qh-providers",role:"group","aria-label":"Quota provider",children:["claude","codex"].filter(P=>e[P]).map(P=>a.jsx("button",{type:"button",className:"qh-provider","aria-pressed":s===P,onClick:()=>{o(P),w("")},children:P==="claude"?"Claude":"Codex"},P))}),T.length>0&&a.jsxs("label",{className:"qh-window",children:["Window",a.jsx("select",{"aria-label":"Quota window",value:I?Md(I):"",onChange:P=>w(P.target.value),children:T.map(P=>a.jsxs("option",{value:Md(P),children:[P.label," · ",Ii(P.resetAt*1e3)]},Md(P)))})]})]}),f&&a.jsxs("p",{className:"qh-message",role:"status",children:["Could not read saved quota history. Use Refresh to try again.",i&&" Showing the last loaded history."]}),I&&O?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"qh-summary",children:[a.jsxs("strong",{children:[Math.round(100-O.pct),"% remaining"]}),a.jsxs("span",{title:Ii(O.t),children:["Captured ",fY(O.t,v),I.resetAt*1e3<=v&&" · window ended"]})]}),a.jsx(pY,{series:I}),a.jsx("p",{className:"qh-note",children:"Recorded quota readings. The dashed guide shows even use until reset; it is not a forecast. Gaps are left unconnected."}),a.jsxs("details",{className:"qh-readings",children:[a.jsxs("summary",{children:["Recorded readings (",I.points.length,")"]}),a.jsxs("table",{children:[a.jsx("caption",{children:I.points.length>50?"Latest 50 readings":"Recorded readings"}),a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx("th",{scope:"col",children:"Captured"}),a.jsx("th",{scope:"col",children:"Remaining"})]})}),a.jsx("tbody",{children:I.points.slice(-50).reverse().map(P=>a.jsxs("tr",{children:[a.jsx("td",{children:Ii(P.t)}),a.jsxs("td",{children:[(100-P.pct).toLocaleString(void 0,{maximumFractionDigits:1}),"%"]})]},P.t))})]})]})]}):!f&&a.jsx("p",{className:"qh-message",role:"status",children:d?"Reading quota history…":$?"No recorded readings yet. History fills in as ccdeck receives quota updates.":"History starts when a quota reading can be matched to your active account."}),(i==null?void 0:i.storageOk)===!1&&a.jsx("p",{className:"qh-note",role:"status",children:"History is available for this run, but could not be saved to disk."}),a.jsx("footer",{className:"qh-note qh-footer",children:"Recorded on this machine from existing quota reads. No extra provider requests. Account changes and resets are kept separate."})]})]})}),document.body)}const gY=6e4,yY=2e4;function wY(e){const[t,n]=y.useState(null),[r,s]=y.useState(!1),o=y.useRef(null),i=y.useRef(!1),c=async(h=!1)=>{if(!(h&&!qn(i.current))){h&&(i.current=!0,s(!0));try{const p=await fetch(h?"/api/quota?refresh=1":"/api/quota",{signal:AbortSignal.timeout(yY)});p.ok&&n(await p.json())}catch{}finally{h&&(i.current=!1,s(!1))}}};return y.useEffect(()=>{if(e)return c(!0),o.current=window.setInterval(()=>c(!1),gY),()=>{o.current!=null&&window.clearInterval(o.current)}},[e]),{quota:t,loading:r,refresh:()=>{e&&c(!0)}}}const xY=6e4;function vY(e){const[t,n]=y.useState(null),[r,s]=y.useState(!1),o=y.useRef(null),i=y.useRef(!1),c=async(h=!1)=>{if(!(h&&!qn(i.current))){h&&(i.current=!0,s(!0));try{const p=await fetch(h?"/api/codex-quota?refresh=1":"/api/codex-quota");p.ok&&n(await p.json())}catch{}finally{h&&(i.current=!1,s(!1))}}};return y.useEffect(()=>{if(e)return c(!0),o.current=window.setInterval(()=>c(!1),xY),()=>{o.current!=null&&window.clearInterval(o.current)}},[e]),{data:t,loading:r,refresh:()=>{e&&c(!0)}}}const NE=6e4;function bY(e,t,n){const[r,s]=y.useState(null),[o,i]=y.useState(!1),[c,d]=y.useState(0),h=y.useRef(0);y.useEffect(()=>{const p=()=>document.visibilityState==="visible",g=()=>{p()&&d(j=>j+1)},w=window.setInterval(g,NE),k=()=>{p()&&Date.now()-h.current>=NE&&d(j=>j+1)};return document.addEventListener("visibilitychange",k),()=>{window.clearInterval(w),document.removeEventListener("visibilitychange",k)}},[]);const f=y.useRef(t);return y.useEffect(()=>{let p=!0;const g=t!==f.current;f.current=t;const w=e,k=LK(w);return i(!0),fetch(`/api/ccusage?since=${k}${g?"&refresh=1":""}`).then(j=>j.ok?j.json():null).then(j=>{!p||!(j!=null&&j.ok)||(h.current=Date.now(),s({period:w,data:j,baseline:n()}))}).catch(()=>{}).finally(()=>{p&&i(!1)}),()=>{p=!1}},[e,t,c]),{...BK(r,e),loading:o}}const kY=e=>1-Math.pow(1-e,5),p3=420;function jY(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 NY(e,t,n,r=p3){return n>=r?t:n<=0?e:e+(t-e)*kY(n/r)}function m3(){return typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches}function SE(e,t,n,r={}){const s=r.now??(()=>performance.now()),o=r.raf??(w=>requestAnimationFrame(w)),i=r.cancel??(w=>cancelAnimationFrame(w)),c=r.reducedMotion??m3,d=r.hidden??(()=>typeof document=="object"&&document.hidden===!0);if(c()||d()||!jY(e,t))return n(t),()=>{};const h=s();let f=0,p=!0;const g=()=>{if(!p)return;const w=s()-h;n(NY(e,t,w)),w<p3&&(f=o(g))};return f=o(g),()=>{p=!1,f&&i(f)}}const SY=typeof window>"u"?y.useEffect:y.useLayoutEffect;function uo(e,{countIn:t=!1}={}){const[n,r]=y.useState(e),s=y.useRef(e),o=y.useRef(!0);return y.useEffect(()=>{s.current=n},[n]),SY(()=>{!t||m3()||(s.current=0,r(0))},[]),y.useEffect(()=>{if(o.current){if(o.current=!1,t)return SE(0,e,c=>{s.current=c,r(c)});s.current=e,r(e);return}return SE(s.current,e,c=>{s.current=c,r(c)})},[e]),n}function g3(e,t,n){const r=EY*Math.max(1,n/w3);let s=0;for(const[o,i]of t){const c=e.get(o);if(c===void 0)continue;const d=i.cost-c.cost;d>0&&d<=r&&(s+=d)}return s}const _E={samples:[],last:new Map,watched:0},y3=10*6e4,_Y=6e4,w3=5e3,EY=20;function CY(e,t,n){const r=e.samples[e.samples.length-1];if(r&&t-r.t<w3)return e;const s=e.watched+g3(e.last,n,r?t-r.t:0),o=e.samples.filter(i=>t-i.t<=y3);return o.push({t,watched:s}),{samples:o,last:n,watched:s}}function TY(e,t,n){const r=e.samples[0];if(!r)return null;const s=t-r.t;if(s<_Y)return null;const o=e.samples[e.samples.length-1].t,i=e.watched+g3(e.last,n,t-o)-r.watched;return i>0?{spent:i,spanSec:s/1e3,spanMin:Math.min(y3/6e4,Math.ceil(s/6e4))}:null}function RY(e,t,n){const r=y.useRef(_E),s=y.useRef(null);return y.useMemo(()=>{const o=WG(e.agents.values()),i=FG(e.agents.values());s.current!==n&&(s.current=n,r.current=_E);const c=C0(e.agents.values(),t);n!=null&&(r.current=CY(r.current,t,c));const d=n==null?null:TY(r.current,t,c),h=d?{label:Ik(d.spent,d.spanSec),spanMin:d.spanMin}:null;return{byModel:o,totalCost:i.cost,totalTokens:i,burnRate:h}},[e,e.revision,t,n])}const AY=3e4;function x3(){const[e,t]=y.useState(()=>Math.floor(Date.now()/1e3));return y.useEffect(()=>{const n=window.setInterval(()=>t(Math.floor(Date.now()/1e3)),AY);return()=>window.clearInterval(n)},[]),e}function EE(e){return(typeof e.cost=="number"?e.cost:e.cost.total)>0||e.inputTokens+e.outputTokens>0}function MY(e,t,n){return e?t.some(r=>r.cost<=0&&r.tokens>0):n.some(r=>!r.priced)}function $Y(e){return e.claude&&e.codex?"Refresh Claude + Codex quota":e.codex?"Refresh Codex quota":"Refresh Claude quota"}function LY(e){const t=new Map;for(const n of e){if(n.kind!=="root"||!n.sessionId)continue;const r=n.label||n.cwdBasename;r&&t.set(n.sessionId,r)}return t}function OY(e){const t=new Map;for(const n of e)n.kind!=="root"||!n.sessionId||t.set(n.sessionId,n.state);return t}function IY(e){const t=new Map;for(const n of e){if(!n.label)continue;const r=t.get(n.label);r?r.push(n.sessionId):t.set(n.label,[n.sessionId])}return e.map(n=>{const r=n.label?t.get(n.label)??[]:[];return r.length>1?{...n,label:`${n.label} ${VI(n.sessionId,r)}`}:n})}function PY({state:e,now:t,providers:n,incidents:r=[],leaving:s,onClose:o,liveSince:i=null}){const c=Cn(),[d,h]=y.useState(null),[f,p]=y.useState(null),g=y.useMemo(()=>new Map([...e.agents.values()].filter(Me=>Me.kind==="root").map(Me=>[Me.sessionId,Me.provider??"claude"])),[e,e.revision]),{quota:w,loading:k,refresh:j}=wY(n.claude),{data:v,loading:b,refresh:N}=vY(n.codex),S=x3(),{byModel:E,totalCost:C,totalTokens:$}=RY(e,t,i),T=y.useMemo(()=>zG(e.agents.values()),[e,e.revision]),[I,O]=y.useState(UK);y.useEffect(()=>{HK(I)},[I]);const[U,P]=y.useState(WK);y.useEffect(()=>{zK(U)},[U]);const[L,F]=y.useState(0),A=y.useRef(()=>new Map);A.current=()=>i==null?null:C0(e.agents.values(),t);const B=y.useCallback(()=>A.current(),[]),{data:D,shown:K,stale:G,loading:H,baseline:q}=bY(I,L,B),M=D!=null,V=H&&G,Z=y.useMemo(()=>LY(e.agents.values()),[e,e.revision]),W=y.useMemo(()=>OY(e.agents.values()),[e,e.revision]),X=y.useMemo(()=>M?r3(D):[],[D,M]),Y=y.useMemo(()=>M?IY(PK(D,Z).slice(0,12)):[],[D,M,Z]),J=y.useMemo(()=>e1(D),[D]),ee=y.useMemo(()=>DK(D,J.cost),[D,J.cost]),ne=s3(K,I),se=y.useMemo(()=>M?MK(q,C0(e.agents.values(),t)):E0,[e,e.revision,q,M,t]),ce=qK(D,{...$,cost:C},se),de=ce.hasCost,ae=ce.tokenSum,pe=uo(ce.cost),fe=uo(ce.inputTokens),Ee=uo(ce.outputTokens),ye=uo(ce.cacheReadTokens),oe=uo(ce.cacheCreateTokens),we=E.filter(EE),Ne=T.filter(EE),ge=MY(M,X,we),Ae=k||b,Oe=()=>{j(),N(),F(Me=>Me+1)},qe=$Y(n);return a.jsxs("aside",{className:`usage-panel${s?" leaving":""}`,id:"usage-panel","aria-label":"Usage",children:[a.jsxs("div",{className:"up-header",children:[a.jsx("h2",{children:"Usage"}),a.jsxs("div",{className:"up-header-right",children:[(n.claude||n.codex)&&a.jsx("button",{type:"button",className:"glyph-btn","aria-label":"Open quota history",title:"Quota history",onClick:Me=>p(Me.detail===0?"keyboard":"pointer"),children:a.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:a.jsx("path",{d:"M4 4v16h16M8 8l4 4 4-3 4 7"})})}),(n.claude||n.codex)&&a.jsx("button",{type:"button",className:"glyph-btn up-refresh-btn",onClick:Oe,...ts(Ae),"aria-label":qe,title:qe,children:Ae?"…":a.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:a.jsx("path",{d:"M20 7v5h-5M20 12a8 8 0 1 0-2 5"})})}),a.jsx("button",{type:"button",className:"glyph-btn up-close",onClick:o,"aria-label":"Close usage panel",title:dn("Close","U",c),children:a.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round","aria-hidden":!0,children:a.jsx("path",{d:"m6 6 12 12M18 6 6 18"})})})]})]}),n.claude&&a.jsx(eY,{quota:w,quotaLoading:k,nowSec:S,incident:r.find(Me=>Me.provider==="claude")}),n.codex&&a.jsx(tY,{codexQuota:v,codexLoading:b,nowSec:S,incident:r.find(Me=>Me.provider==="codex")}),M&&a.jsx(rY,{period:I,rangePending:V,setPeriod:O}),ae>0?a.jsxs(a.Fragment,{children:[de&&a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"up-total",title:M?void 0:fE(c),children:[a.jsx("span",{className:"up-total-value",children:Ye(pe)}),a.jsx("span",{className:"up-total-label",children:M?ne:BG})]}),a.jsxs("p",{className:"up-source",children:["Local estimate · ",M?"ccusage":"live sessions"]}),ce.showCostBar&&a.jsx(t1,{cost:C})]}),a.jsxs("div",{className:"up-tokens-row",title:M?void 0:fE(c),children:[a.jsxs("span",{className:"up-tok",children:[a.jsx("span",{className:"up-k",children:"in"}),ut(fe)]}),a.jsxs("span",{className:"up-tok",children:[a.jsx("span",{className:"up-k",children:"out"}),ut(Ee)]}),ce.cacheReadTokens>0&&a.jsxs("span",{className:"up-tok",children:[a.jsx("span",{className:"up-k",children:"cache r"}),ut(ye)]}),ce.cacheCreateTokens>0&&a.jsxs("span",{className:"up-tok",children:[a.jsx("span",{className:"up-k",children:"cache c"}),ut(oe)]}),!de&&a.jsx("span",{className:"up-tok up-scope",children:qG})]}),(M?X.length:we.length)>0&&a.jsx(nY,{fromRange:M,rangeModelRows:X,boardModelRows:we}),M&&Y.length===0&&J.tokens>0&&a.jsxs("section",{className:"up-section",children:[a.jsx("h3",{className:"up-section-title",children:"By session"}),a.jsxs("div",{className:"up-hint",children:["No session is dated ",ne," yet — ccusage dates sessions in UTC, and the totals above are your local day."]})]}),(M?Y.length:Ne.length)>0&&a.jsx(oY,{fromRange:M,rangeSessionRows:Y,boardSessionRows:Ne,boardStates:W,sessionsOpen:U,setSessionsOpen:P,periodNoun:ne,sessionScale:ee,onOpenSession:h,boardProviders:g}),ge&&a.jsxs("div",{className:"up-hint",children:["“",Ls,"” means this build holds no published rate for that model — those tokens are counted above and their dollars are not."]})]}):a.jsx("div",{className:"up-empty",children:M?(K??I)==="all"?a.jsx(a.Fragment,{children:"No usage in any transcript on this machine."}):a.jsxs(a.Fragment,{children:["No usage ",ne,".",a.jsx("br",{}),"Try a longer period."]}):a.jsxs(a.Fragment,{children:["No usage data yet.",a.jsx("br",{}),"Start a Claude Code or Codex session."]})}),a.jsx("div",{className:"film-foot",children:a.jsx(Ic,{film:"usage"})}),d&&a.jsx(dY,{session:d,onClose:()=>h(null)},`${d.agent}:${d.sessionId}`),f&&a.jsx(mY,{providers:n,instant:f==="keyboard",accounts:{claude:w==null?void 0:w.historyAccount,codex:v==null?void 0:v.historyAccount},onClose:()=>p(null)})]})}function og(e){return e<9.95?e.toFixed(1):String(Math.round(e))}function n1(e){const t=Number.isFinite(e)?Math.max(0,e):0;return t<50?{value:"0",unit:"KB/s"}:t<999500?{value:og(t/1e3),unit:"KB/s"}:t<9995e5?{value:og(t/1e6),unit:"MB/s"}:{value:og(t/1e9),unit:"GB/s"}}function kf(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 Pc(e){return e.unit?e.unit==="%"||e.unit==="°C"?`${e.value}${e.unit}`:`${e.value} ${e.unit}`:e.value}const DY="thermal:Throttling";function r1(e){const t="timeHeld"in e?e.timeHeld:100-e.speedLimit;return Math.max(0,Math.min(100,t))}function FY(e){var n,r,s,o;const t={};e.cpu!=null&&(t["cpu:all"]=e.cpu),(n=e.perCore)!=null&&n.length&&(t["cpu:busiest"]=Math.max(...e.perCore)),e.memory&&(t["mem:physical"]=e.memory.usedPct),e.swap&&e.swap.total>0&&(t["mem:swap"]=Math.round(e.swap.used/e.swap.total*1e3)/10),(r=e.loadavg)!=null&&r.length&&(t["load:1m"]=e.loadavg[0]);for(const i of((s=e.thermal)==null?void 0:s.celsius)??[])t[`thermal:${i.label}`]=i.celsius;return(o=e.thermal)!=null&&o.throttle&&(t[DY]=r1(e.thermal.throttle)),t}function gc(e,t){return t==="B/s"?Pc(n1(e)):t==="ms"?Pc(kf(e)):t==="C"?`${Math.round(e)}°`:t==="%"?`${Math.round(e)}%`:e.toFixed(2)}function $d(e,t){return t==="B/s"||t==="ms"||!Number.isInteger(e)?gc(e,t):t==="C"?`${e}°`:t==="%"?`${e}%`:`${e}`}function BY(e,t){return e==null||!Number.isFinite(e)||!Number.isFinite(t)||t<=0||e<=t?null:`${(e/t).toFixed(1)}× more work queued than cores to run it`}function qY(e,t,n){return e>=n?"hot":e>=t?"warn":"calm"}function UY(e,t,n=Date.now()){const r=r1(e),s="timeHeld"in e;return{pct:r,value:`${r}%`,tone:r===0?"calm":r>=30?"hot":"warn",note:r>0?s?`CPU throttled ${r}% of the time to cool down`:`CPU held to ${100-r}% of full speed to cool down`:t?s?`at full speed · ${t.peak}% throttled ${CE(t.lastMs,n)}`:`at full speed · held to ${100-t.peak}% ${CE(t.lastMs,n)}`:"running at full speed, and never held back"}}function CE(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 HY(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 WY(e){var r,s;const t=(r=e.thermal)==null?void 0:r.throttle,n=t?r1(t):0;return t&&n>0?"timeHeld"in t?`throttled ${n}% of the time`:`throttled to ${100-n}% of full speed`:e.memory&&e.memory.usedPct>=90?`physical memory ${Math.round(e.memory.usedPct)}% full`:(s=e.network)!=null&&s.api&&e.network.api.ms==null?"the Claude API is not answering":null}function zY(e){return e.kind==="tailscale-exit"?e.node?`Tailscale exit node ${e.node}`:"a Tailscale exit node":e.kind==="tailscale"?"Tailscale":`${e.name?`${e.name} `:""}VPN${e.iface?` (${e.iface})`:""}`}const VY=3e3;function GY(){const[e,t]=y.useState(null),n=y.useRef(null);return y.useEffect(()=>{let r=!0;const s=async()=>{if(document.visibilityState!=="hidden")try{const d=await fetch("/api/system");if(!d.ok)return;const h=await d.json();r&&(h!=null&&h.ok)&&t(h)}catch{}},o=()=>{n.current==null&&(s(),n.current=window.setInterval(s,VY))},i=()=>{n.current!=null&&(window.clearInterval(n.current),n.current=null)},c=()=>{if(document.visibilityState==="hidden"){i();return}o(),s()};return o(),document.addEventListener("visibilitychange",c),()=>{r=!1,i(),document.removeEventListener("visibilitychange",c)}},[]),e}function KY(e,t){return!e||e.key!==t?"none":e.dir==="asc"?"ascending":"descending"}function ki({col:e,label:t,note:n,sort:r,next:s,onSort:o,className:i}){const c=KY(r,e);return a.jsx("th",{scope:"col","aria-sort":c,className:i,children:a.jsxs("button",{type:"button",className:"sd-sort",title:n?`Sort by ${t}
|
|
91
|
-
|
|
92
|
-
${n}`:`Sort by ${t}`,onClick:()=>o(s(r,e)),children:[t,a.jsx("span",{className:"sd-sort-dir","aria-hidden":!0,children:c==="none"?"":c==="ascending"?"↑":"↓"})]})})}function ig(e,t){return t==="B/s"?n1(e):t==="ms"?kf(e):{value:String(e),unit:t==="C"?"°C":t}}const Ft={l:30,r:6,t:6,b:2},ha={l:0,r:0,t:2,b:1},jf=104,YY=64;function Sr(e,t=100,n=jf,r=Ft){const s=n-r.t-r.b;return r.t+s*(1-Math.max(0,Math.min(t,e))/t)}function v3(e,t){return t??[e[0].t,e[e.length-1].t]}function s1(e,[t,n],r,s=Ft){const o=r-s.l-s.r,i=n-t;return s.l+(i>0?o*(e-t)/i:o/2)}function b3(e,t,n,r=100,s=jf,o=Ft,i){if(!e.length)return"";const c=v3(e,i),d=p=>s1(p,c,t,o);let h="",f=null;for(const p of e){const g=f&&p.t-f.t<=n*2?"L":"M";h+=`${g}${d(p.t).toFixed(1)} ${Sr(p.v,r,s,o).toFixed(1)}`,f=p}return h}function k3(e,t,n,r=100,s=jf,o=Ft,i){if(e.length<2)return"";const c=s-o.b,d=v3(e,i),h=w=>s1(w,d,t,o);let f="",p=[];const g=()=>{if(p.length>=2){let w=`M${h(p[0].t).toFixed(1)} ${c}`;for(const k of p)w+=`L${h(k.t).toFixed(1)} ${Sr(k.v,r,s,o).toFixed(1)}`;f+=`${w}L${h(p[p.length-1].t).toFixed(1)} ${c}Z`}p=[]};for(const w of e)p.length&&w.t-p[p.length-1].t>n*2&&g(),p.push(w);return g(),f}function XY(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 j3(e,t,n){return n!=null&&e>=n?"hot":t!=null&&e>=t?"warn":""}function ZY(e,t,n=r=>ho(r)){const r=e.filter(i=>i.v>0);if(!e.length)return null;if(!r.length)return"never held back";const s=r.length*(t/6e4),o=r[r.length-1];return`held back for ${s===1?"1 minute":`${s} minutes`}, last at ${n(o.t)}`}function ho(e){const t=new Date(e);return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}function a1(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 JY({group:e,title:t,liveNote:n,onClose:r}){const s=ot(r),o=dt(r),[i,c]=y.useState(null);y.useEffect(()=>{let g=!0;const w=async()=>{try{const j=await fetch(`/api/system/history?group=${e}`);if(!j.ok)return;const v=await j.json();g&&(v!=null&&v.ok)&&c(v)}catch{}};w();const k=window.setInterval(w,2e4);return()=>{g=!1,window.clearInterval(k)}},[e]);const d=(i==null?void 0:i.series)??[],[h,f,p]=y.useMemo(()=>{let g=1/0,w=0;for(const k of d)k.points.length&&(g=Math.min(g,k.points[0].t),w=Math.max(w,k.points[k.points.length-1].t));return Number.isFinite(g)?[Math.max(g,(i==null?void 0:i.sinceMs)??0),w,[g,w]]:[(i==null?void 0:i.sinceMs)??0,w,void 0]},[d,i==null?void 0:i.sinceMs]);return yt.createPortal(a.jsx("div",{className:"modal-backdrop",...o,role:"presentation",children:a.jsxs("div",{ref:s,className:"modal hist-modal",onClick:g=>g.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"hist-modal-title",children:[a.jsxs("div",{className:"modal-head",children:[a.jsx("span",{className:"modal-title",id:"hist-modal-title",children:t}),i&&h>0&&a.jsxs("span",{className:"hist-since",children:["since ",ho(h)," · ",a1(h,f||Date.now())]}),a.jsx("button",{type:"button",className:"glyph-btn",onClick:r,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]}),a.jsxs("div",{className:"hist-body",children:[i==null?a.jsx("p",{className:"hist-empty",children:"Reading…"}):d.length===0?a.jsx("p",{className:"hist-empty",children:"Nothing has been measured yet."}):d.map(g=>a.jsx(QY,{series:g,stepMs:i.stepMs,domain:p},g.label)),e==="load"&&n&&a.jsxs("p",{className:"hist-note hist-load-summary",children:[a.jsx("span",{children:"Current 1-minute load"}),a.jsx("strong",{children:n})]})]})]})}),document.body)}function QY({series:e,stepMs:t,domain:n}){const r=y.useRef(null),[s,o]=y.useState(560),[i,c]=y.useState(null);y.useEffect(()=>{const P=r.current;if(!P||typeof ResizeObserver>"u")return;const L=new ResizeObserver(([F])=>o(Math.max(160,F.contentRect.width)));return L.observe(P),()=>L.disconnect()},[]);const{points:d,unit:h,warnAt:f,critAt:p,label:g,top:w,restsAtZero:k,changes:j}=e,v=k?YY:jf,{now:b,peak:N}=XY(d),S=b!=null?ig(b,h):null,E=N!=null?ig(N,h):null,C=g==="Throttling"?ZY(d,t):null,$=i!=null?d[i]:null,[T,I]=n??(d.length?[d[0].t,d[d.length-1].t]:[0,0]),O=P=>s1(P,[T,I],s),U=P=>{if(d.length<2)return;const L=P.currentTarget.getBoundingClientRect(),F=(P.clientX-L.left-Ft.l)/Math.max(1,L.width-Ft.l-Ft.r),A=T+(I-T)*Math.max(0,Math.min(1,F));let B=0;for(let D=1;D<d.length;D++)Math.abs(d[D].t-A)<Math.abs(d[B].t-A)&&(B=D);c(B)};return a.jsxs("section",{className:"hist-series","aria-label":`${g} history`,children:[a.jsxs("div",{className:"hist-head",children:[a.jsx("span",{className:"hist-label",children:g}),a.jsxs("span",{className:"hist-stats",children:[S&&a.jsxs(a.Fragment,{children:[a.jsx("b",{children:S.value}),a.jsxs("span",{children:[S.unit," now"]})]}),N!=null&&E&&a.jsxs(a.Fragment,{children:[a.jsx("b",{className:j3(N,f,p),children:E.value}),a.jsxs("span",{children:[E.unit," peak"]})]})]})]}),a.jsx("div",{className:"hist-plot",ref:r,children:a.jsxs("svg",{className:"hist-chart",width:"100%",height:v,viewBox:`0 0 ${s} ${v}`,preserveAspectRatio:"none",role:"img","aria-label":S==null||E==null?`${g}: nothing measured yet`:`${g}: ${Pc(S)} now, peak ${Pc(E)}, over ${a1(d[0].t,d[d.length-1].t)}`,onPointerMove:U,onPointerLeave:()=>c(null),children:[[["warn",f],["hot",p]].map(([P,L])=>L==null||L>w?null:a.jsxs("g",{children:[a.jsx("line",{className:`hist-rule ${P}`,x1:Ft.l,x2:s-Ft.r,y1:Sr(L,w,v),y2:Sr(L,w,v)}),a.jsx("text",{className:`hist-rule-tag ${P}`,x:2,y:Sr(L,w,v)+3,children:L})]},P)),a.jsx("line",{className:"hist-floor",x1:Ft.l,x2:s-Ft.r,y1:v-Ft.b,y2:v-Ft.b}),(j??[]).filter(P=>P.from!=null&&d.length>1&&P.t>=T&&P.t<=I).map(P=>a.jsx("line",{className:"hist-mark",x1:O(P.t),x2:O(P.t),y1:Ft.t,y2:v-Ft.b},P.t)),a.jsx("path",{className:"hist-area",d:k3(d,s,t,w,v,Ft,[T,I])}),a.jsx("path",{className:"hist-line",d:b3(d,s,t,w,v,Ft,[T,I])}),d.length===1&&a.jsx("circle",{className:"hist-dot",cx:O(d[0].t),cy:Sr(d[0].v,w,v),r:3}),$&&a.jsxs("g",{children:[a.jsx("line",{className:"hist-cross",x1:O($.t),x2:O($.t),y1:Ft.t,y2:v-Ft.b}),a.jsx("circle",{className:"hist-dot",cx:O($.t),cy:Sr($.v,w,v),r:3})]})]})}),a.jsx("div",{className:"hist-axis",children:$?a.jsxs("span",{className:"hist-at",children:[ho($.t)," — ",(()=>{const P=ig($.v,h);return a.jsxs(a.Fragment,{children:[a.jsx("b",{children:P.value}),P.unit==="%"||P.unit==="°C"||!P.unit?P.unit:` ${P.unit}`]})})()]}):a.jsxs(a.Fragment,{children:[a.jsx("span",{children:d.length?ho(T):""}),a.jsx("span",{children:d.length?ho(I):""})]})}),C&&a.jsx("div",{className:"hist-note",children:C}),j==null?void 0:j.slice(-3).map(P=>a.jsx("div",{className:"hist-note hist-route",children:P.from==null?`Since ${ho(P.t)} — ${P.label}`:`${ho(P.t)} — ${P.label.charAt(0).toUpperCase()+P.label.slice(1)}`},P.t))]})}const TE=["cores","memory","load","thermal"],ao=116,Yr=24,eX=60,tX=6e4;function nX(e){return e.points.length?e.restsAtZero?e.points.some(t=>t.v>0):!0:!1}function rX(e){return e.unit==="C"?`${e.label} temp`:e.key==="mem:physical"?"Physical RAM":e.key==="mem:swap"?`${e.label} memory`:e.label}function sX(e,t=eX){return e.points.length<=t?e:{...e,points:e.points.slice(-t)}}function aX({sys:e}){const[t,n]=y.useState({});y.useEffect(()=>{let i=!0;const c=async()=>{const h=await Promise.all(TE.map(async f=>{try{const p=await fetch(`/api/system/history?group=${f}`);return p.ok?[f,await p.json()]:[f,null]}catch{return[f,null]}}));i&&n(f=>{const p={...f};for(const[g,w]of h)w!=null&&w.ok&&(p[g]=w);return p})};c();const d=setInterval(()=>void c(),tX);return()=>{i=!1,clearInterval(d)}},[]);const r=y.useMemo(()=>FY(e),[e]),s=y.useMemo(()=>TE.flatMap(i=>{const c=t[i];return c?c.series.filter(nX).map(d=>({series:sX(d),stepMs:c.stepMs})):[]}),[t]),o=y.useMemo(()=>{let i=1/0,c=-1/0;for(const{series:d}of s){const h=d.points;h.length&&(i=Math.min(i,h[0].t),c=Math.max(c,h[h.length-1].t))}return Number.isFinite(i)?a1(i,c):"less than a minute"},[s]);return Object.keys(r).length?a.jsx("div",{className:"pl-strip",role:"group","aria-label":`This machine, over the last ${o}`,children:s.map(({series:i,stepMs:c})=>a.jsx(oX,{series:i,stepMs:c,now:r[i.key],span:o},i.key))}):null}function oX({series:e,stepMs:t,now:n,span:r}){var w;const{points:s,top:o,unit:i,warnAt:c,critAt:d}=e,h=rX(e),f=n??((w=s[s.length-1])==null?void 0:w.v),p=f==null?"":j3(f,c,d),g=Math.max(...s.map(k=>k.v));return a.jsxs("div",{className:`pl-cell${p?` ${p}`:""}`,title:[`${h} · peak ${gc(g,i)} over the last ${r}`,c!=null?`over ${$d(c,i)} is uncomfortable`:"",d!=null?`over ${$d(d,i)} the machine acts`:""].filter(Boolean).join(" · "),children:[a.jsxs("div",{className:"pl-cell-head",children:[a.jsx("span",{className:"pl-cell-label",children:h}),a.jsx("span",{className:"pl-cell-now",children:f==null?"—":gc(f,i)})]}),a.jsxs("svg",{className:"pl-spark",width:ao,height:Yr,viewBox:`0 0 ${ao} ${Yr}`,preserveAspectRatio:"none","aria-hidden":!0,children:[a.jsx("line",{className:"pl-spark-floor",x1:0,x2:ao,y1:Yr-ha.b,y2:Yr-ha.b}),a.jsx("path",{className:"pl-spark-area",d:k3(s,ao,t,o,Yr,ha)}),c!=null&&a.jsx("line",{className:"pl-rule warn",x1:0,x2:ao,y1:Sr(c,o,Yr,ha),y2:Sr(c,o,Yr,ha)}),d!=null&&a.jsx("line",{className:"pl-rule hot",x1:0,x2:ao,y1:Sr(d,o,Yr,ha),y2:Sr(d,o,Yr,ha)}),a.jsx("path",{className:"pl-spark-line",d:b3(s,ao,t,o,Yr,ha)})]}),a.jsxs("span",{className:"vis-hidden",children:["peak ",gc(g,i)," over the last ",r,c!=null&&`, uncomfortable over ${$d(c,i)}`,d!=null&&`, the machine acts over ${$d(d,i)}`]})]})}const N3={key:"cpu",dir:"desc"};function iX(e,t){return e.key===t?{...e,dir:e.dir==="asc"?"desc":"asc"}:{key:t,dir:t==="name"||t==="user"?"asc":"desc"}}function lX(e,t){const n=t.dir==="asc"?1:-1,r=o=>t.key==="cpu"?o.cpu:t.key==="mem"?o.mem:t.key==="rss"?o.rssBytes:t.key==="threads"?o.threads:o.uptimeSec,s=(o,i)=>{if(t.key==="name")return n*o.name.localeCompare(i.name,void 0,{sensitivity:"base"});if(t.key==="user"){const h=o.user??"",f=i.user??"";return!h||!f?h===f?0:h?-1:1:n*h.localeCompare(f,void 0,{sensitivity:"base"})}const c=r(o),d=r(i);return c==null||d==null?c==null?d==null?0:1:-1:n*(c-d)};return[...e].sort((o,i)=>s(o,i)||(i.cpu??-1)-(o.cpu??-1)||i.mem-o.mem||o.pid-i.pid)}const cX=4e3;function uX(e,t){const n=t!=null&&t.ok&&Array.isArray(t.procs)?t.procs:[];return n.length?{procs:n,total:t.total??0}:e??{procs:[],total:0}}function dX(){const[e,t]=y.useState(null);return y.useEffect(()=>{let n=!0;const r=async()=>{if(document.visibilityState!=="hidden")try{const o=await fetch("/api/system/processes?detail=1");if(!o.ok)return;const i=await o.json();n&&t(c=>uX(c,i))}catch{}};r();const s=window.setInterval(r,cX);return()=>{n=!1,window.clearInterval(s)}},[]),e}function hX(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 fX({sys:e,onClose:t}){Jt("process-list");const n=ot(t),r=dt(t),[s,o]=y.useState(N3),i=dX();return yt.createPortal(a.jsx("div",{className:"modal-backdrop",...r,role:"presentation",children:a.jsx("div",{ref:n,className:"modal pl-modal",onClick:c=>c.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"pl-modal-title",children:a.jsx(pX,{read:i,sort:s,onSort:o,sys:e,onClose:t})})}),document.body)}function pX({read:e,sort:t,onSort:n,sys:r,onClose:s}){const o=e?lX(e.procs,t):null;return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"modal-head",children:[a.jsx("span",{className:"modal-title",id:"pl-modal-title",children:"Busiest processes"}),o!=null&&o.length>0&&a.jsxs("span",{className:"pl-count",children:[o.length," of ",e.total," running"]}),a.jsx("button",{type:"button",className:"glyph-btn",onClick:s,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]}),a.jsxs("div",{className:"pl-split",children:[a.jsx("div",{className:"pl-body",children:o==null?a.jsx("p",{className:"pl-empty",children:"Reading the process list…"}):o.length===0?a.jsx("p",{className:"pl-empty",children:"Could not read the process list — retrying."}):a.jsxs("table",{className:"sd-procs pl-table",children:[a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx(gi,{col:"cpu",label:"cpu",sort:t,onSort:n}),a.jsx(gi,{col:"rss",label:"memory",note:"Resident set size, which is what ps and Task Manager report; macOS Activity Monitor shows a different figure.",sort:t,onSort:n}),a.jsx(gi,{col:"threads",label:"threads",sort:t,onSort:n}),a.jsx(gi,{col:"uptime",label:"up",sort:t,onSort:n}),a.jsx(gi,{col:"user",label:"user",sort:t,onSort:n}),a.jsx("th",{scope:"col",className:"pl-pid-h",children:"pid"}),a.jsx(gi,{col:"name",label:"process",note:"Command lines have anything secret-shaped removed, which is a filter and not a guarantee.",sort:t,onSort:n})]})}),a.jsx("tbody",{children:o.map(i=>a.jsxs("tr",{children:[a.jsx("td",{className:"sd-num",children:i.cpu==null?"—":i.cpu.toFixed(0)}),a.jsx("td",{className:"sd-num sd-dim",title:`${i.mem.toFixed(1)}% of installed memory`,children:Cs(i.rssBytes)}),a.jsx("td",{className:"sd-num sd-dim",children:i.threads??"—"}),a.jsx("td",{className:"sd-num sd-dim",children:hX(i.uptimeSec)}),a.jsx("td",{className:"sd-dim pl-user",children:i.user??"—"}),a.jsx("td",{className:"sd-num sd-dim pl-pid",children:i.pid}),a.jsxs("td",{className:"pl-name",children:[i.name,i.cmd&&a.jsxs("span",{className:"pl-cmd",title:i.cmd,children:[" ",i.cmd]})]})]},i.pid))})]})}),a.jsx(aX,{sys:r})]})]})}function gi(e){return a.jsx(ki,{...e,next:(t,n)=>iX(t??N3,n)})}function A0({value:e,unit:t,cap:n}){return t?a.jsxs("span",{className:"sd-fig",children:[a.jsx("span",{className:"sd-fig-cap",children:n}),a.jsxs("span",{className:"sd-fig-read",children:[a.jsx("b",{children:e})," ",a.jsx("span",{className:"sd-fig-unit",children:t})]})]}):a.jsxs("span",{className:"sd-fig",children:[a.jsx("b",{children:e}),a.jsx("span",{className:"sd-fig-cap",children:n})]})}const mX=300;function Dc({group:e,title:t,action:n,label:r,value:s,hint:o,liveNote:i,children:c}){const[d,h]=y.useState(!1),f=y.useRef(null),p=y.useRef(null),g=()=>{p.current!=null&&window.clearTimeout(p.current),p.current=null};y.useEffect(()=>g,[]);const w=k=>{var j;g(),!(k.detail>1||((j=window.getSelection())==null?void 0:j.isCollapsed)===!1)&&(p.current=window.setTimeout(()=>{var v,b;p.current=null,((v=window.getSelection())==null?void 0:v.isCollapsed)!==!1&&((b=f.current)==null||b.focus({preventScroll:!0}),h(!0))},mX))};return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"sd-reading",onClick:w,children:[a.jsx("button",{ref:f,type:"button",className:"sd-open",onClick:k=>{k.stopPropagation(),g(),h(!0)},title:n,"aria-label":s==null?`${r}: show history`:`${r}: show history, now ${s}`,"aria-describedby":o?`sd-hint-${e}`:void 0,children:a.jsxs("span",{className:"sd-h","aria-hidden":!0,children:[r," ",a.jsx("i",{className:"sd-row-more",children:"›"}),s!=null&&a.jsx("span",{className:"sd-h-val",children:s})]})}),c]}),o&&a.jsx("span",{id:`sd-hint-${e}`,className:"vis-hidden",children:o}),d&&a.jsx(JY,{group:e,title:t,liveNote:i,onClose:()=>h(!1)})]})}function Rh({label:e,value:t,pct:n,tone:r="calm",note:s,mark:o,title:i,trackLabel:c}){return a.jsxs("div",{className:"sd-row",title:i,children:[a.jsxs("div",{className:"sd-row-head",children:[a.jsx("span",{className:"sd-row-label",children:e}),a.jsx("span",{className:"sd-row-val",children:t})]}),a.jsxs("span",{className:"sd-track",role:c?"img":void 0,"aria-label":c,children:[a.jsx("span",{className:`sd-fill${r==="calm"?"":` ${r}`}`,style:{transform:`scaleX(${n<=0?0:Math.max(1,Math.min(100,n))/100})`}}),o!=null&&o>0&&o<100&&a.jsx("span",{className:"sd-mark",style:{left:`${o}%`},"aria-hidden":!0})]}),s&&a.jsx("div",{className:"sd-note",children:s})]})}function gX(e,t,n){if(n<=0||uf(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 ba=4,nr=8;function o1(e,t,n){const r=n.width-nr-(e.right+ba),s=e.left-ba-nr,o=t.width<=r||r>=s?"right":"left",i=o==="right"?e.right+ba:e.left-ba-t.width,c=n.height-nr*2,d=t.height<=c,h=d?t.height:Math.max(0,c),f=Math.max(nr,Math.min(e.top,n.height-nr-h)),p=Math.max(nr,Math.min(i,n.width-nr-t.width));return{top:f,left:p,side:o,maxHeight:d?null:h}}function yX(e,t,n){const r=n.height-nr-(e.bottom+ba),s=e.top-ba-nr,o=t.height<=r||r>=s?"below":"above",i=o==="below"?r:s,c=t.height<=i,d=c?t.height:Math.max(0,i),h=o==="below"?e.bottom+ba:e.top-ba-d,f=Math.max(nr,Math.min(e.right-t.width,n.width-nr-t.width));return{top:Math.max(nr,h),left:f,side:o,maxHeight:c?null:d}}function wX(e,t,n){return!(!e||t!=null&&t.contains(e)||n!=null&&n.contains(e))}function xX(e,t,n){const r=y.useRef(t);r.current=t;const s=y.useRef(n);s.current=n,y.useEffect(()=>{const o=i=>{wX(i.target,e.current,r.current())&&s.current()};return window.addEventListener("pointerdown",o,!0),()=>window.removeEventListener("pointerdown",o,!0)},[e])}const S3='[role="menuitem"]';function RE(e){return e?Array.from(e.querySelectorAll(S3)).filter(t=>!t.disabled):[]}function Nf({anchorId:e,boundaryId:t,portalRootId:n,id:r,className:s,role:o,labelledBy:i,start:c="first",focusRef:d,fallbackFocus:h,onClose:f,children:p}){const g=y.useRef(f);g.current=f;const w=y.useRef(h);w.current=h;const k=ot(()=>{var S;(S=document.getElementById(e))==null||S.focus(),g.current()},{popover:!0,focusRef:d}),j=y.useCallback(()=>{var I,O,U;const S=k.current;if(!S)return;const E=document.getElementById(e);if(!E){g.current();return}if(E.getClientRects().length===0){S.contains(document.activeElement)&&((O=(I=w.current)==null?void 0:I.call(w))==null||O.focus()),g.current();return}const C=E.getBoundingClientRect(),$=t?(U=document.getElementById(t))==null?void 0:U.getBoundingClientRect():null;if($&&(C.bottom<=$.top||C.top>=$.bottom)){S.contains(document.activeElement)&&E.focus({preventScroll:!0}),g.current();return}S.style.maxHeight="";const T=yX(C,{width:S.offsetWidth,height:S.offsetHeight},{width:window.innerWidth,height:window.innerHeight});S.style.top=`${T.top}px`,S.style.left=`${T.left}px`,S.style.maxHeight=T.maxHeight==null?"":`${T.maxHeight}px`,S.dataset.side=T.side},[e,t,k]);y.useLayoutEffect(()=>{j()}),y.useEffect(()=>{const S=E=>{var C;(C=k.current)!=null&&C.contains(E.target)||j()};return window.addEventListener("scroll",S,!0),window.addEventListener("resize",j),()=>{window.removeEventListener("scroll",S,!0),window.removeEventListener("resize",j)}},[j,k]),xX(k,()=>document.getElementById(e),f),y.useEffect(()=>{var E;if(o!=="menu")return;const S=RE(k.current);(E=c==="last"?S[S.length-1]:S[0])==null||E.focus()},[]);const v=S=>{var E;if(o==="menu"&&S.key==="Tab"){S.stopPropagation(),(E=document.getElementById(e))==null||E.focus(),S.shiftKey&&S.preventDefault(),g.current();return}if(o==="menu"){const C=RE(k.current),$=gX(S,C.indexOf(document.activeElement),C.length);$.kind==="focus"&&(S.preventDefault(),C[$.index].focus())}S.key.length===1&&S.stopPropagation()},b=S=>{S.target.closest("button, input, select, textarea, code")||S.preventDefault()},N=S=>{if(o!=="menu"||S.pointerType==="touch")return;const E=S.target.closest(S3);E&&!E.disabled&&document.activeElement!==E&&E.focus({preventScroll:!0})};return yt.createPortal(a.jsx("div",{ref:k,id:r,className:`anchored-popover${s?` ${s}`:""}`,role:o,"aria-labelledby":i,onKeyDown:v,onMouseDown:b,onPointerMove:N,children:p}),(n?document.getElementById(n):null)??document.body)}function vX({network:e}){const{down:t,up:n,api:r,route:s}=e,[o,i]=y.useState(!1),c=r&&r.ms!=null?kf(r.ms):null,d=t!=null&&n!=null;return a.jsxs("div",{className:"sd-section",role:"group","aria-label":"Network",children:[a.jsxs(Dc,{group:"network",title:"Network history",action:"Show network history",label:"Network",children:[(d||c)&&a.jsxs("div",{className:"sd-figs sd-figs-named",children:[d&&[["Download",t],["Upload",n]].map(([h,f])=>{const p=n1(f);return a.jsx(A0,{value:p.value,unit:p.unit,cap:h},h)}),c&&a.jsx(A0,{value:c.value,unit:c.unit,cap:"Claude API"})]}),!d&&a.jsx("div",{className:"sd-note",children:"measuring…"}),r&&r.ms==null&&a.jsx("div",{className:"sd-note sd-note-warn",children:"Can’t reach Claude"})]}),s&&a.jsxs(a.Fragment,{children:[a.jsxs("button",{type:"button",className:"sd-detail",id:"sd-conn","aria-expanded":o,"aria-haspopup":"dialog",onClick:()=>i(h=>!h),children:["Connection details",s.relay&&a.jsx("span",{className:"sd-route-relay",children:" · relayed"}),a.jsx("i",{className:"sd-row-more","aria-hidden":!0,children:"›"})]}),o&&a.jsx(bX,{route:s,api:r,onClose:()=>i(!1)})]})]})}function bX({route:e,api:t,onClose:n}){return a.jsxs(Nf,{anchorId:"sd-conn",boundaryId:"system-panel",id:"sd-conn-pop",className:"sd-pop",role:"dialog",labelledBy:"sd-conn-title",onClose:n,children:[a.jsx("p",{className:"sd-pop-title",id:"sd-conn-title",children:"Connection"}),a.jsxs("dl",{className:"sd-pop-rows",children:[a.jsxs("div",{className:"sd-pop-row",children:[a.jsx("dt",{children:e.to==="claude"?"Traffic to Claude":"Internet traffic"}),a.jsxs("dd",{children:["through ",zY(e)]})]}),e.relay&&a.jsxs("div",{className:"sd-pop-row",children:[a.jsx("dt",{children:"Relay"}),a.jsxs("dd",{children:[a.jsx("span",{className:"sd-route-relay",children:e.relay})," — not a direct path, so every packet carries one more round trip than it has to"]})]}),t&&a.jsxs("div",{className:"sd-pop-row",children:[a.jsx("dt",{children:"Round trip"}),a.jsx("dd",{children:t.ms==null?`${t.host} did not answer`:`${Pc(kf(t.ms))} to open a connection to ${t.host}`})]}),a.jsxs("div",{className:"sd-pop-row",children:[a.jsx("dt",{children:"Throughput"}),a.jsx("dd",{children:"every interface on this machine, not this path alone"})]})]})]})}function AE({usageOpen:e,leaving:t,sub:n,flag:r,onClose:s,children:o}){return a.jsxs("aside",{className:`sysdetail${e?" shifted":""}${t?" leaving":""}`,id:"system-panel","aria-labelledby":"sd-title",children:[a.jsxs("div",{className:"sd-top",children:[a.jsxs("div",{className:"sd-head",children:[a.jsx("h2",{className:"sd-title",id:"sd-title",children:"This machine"}),n&&a.jsx("span",{className:"sd-sub",children:n}),a.jsx("button",{type:"button",className:"glyph-btn sd-close",onClick:s,"aria-label":"Close",title:"Close",children:"×"})]}),r&&a.jsx("p",{className:"sd-flag",children:r})]}),o]})}function kX({usageOpen:e,leaving:t,onClose:n}){const r=GY();if(!r||r.cpu==null||!r.memory)return a.jsx(AE,{usageOpen:e,leaving:t,onClose:n,children:a.jsx("div",{className:"sd-note",children:"reading this machine…"})});const{memory:s,swap:o,perCore:i,loadavg:c,cores:d,uptimeSec:h,platform:f,thermal:p,network:g,cpu:w}=r;return a.jsxs(AE,{usageOpen:e,leaving:t,sub:`up ${HY(h)} · ${d} cores`,flag:WY(r),onClose:n,children:[a.jsx(jX,{cpu:w,perCore:i,loadavg:c,cores:d}),a.jsx(NX,{memory:s,swap:o,platform:f}),g&&a.jsx(vX,{network:g}),a.jsx(SX,{thermal:p}),a.jsx(_X,{sys:r})]})}function jX({cpu:e,perCore:t,loadavg:n,cores:r}){const s=BY(n==null?void 0:n[0],r),o=!!t&&t.length>0;return!o&&!n?null:a.jsxs("div",{className:"sd-section sd-cpu",role:"group","aria-label":"CPU",children:[o&&a.jsx(Dc,{group:"cores",title:"Core history",action:"Show core history",label:"CPU",value:e==null?null:`${Math.round(e)}%`,children:a.jsx("div",{className:"sd-cores",role:"img","aria-label":`${t.length} logical cores, busiest at ${Math.round(Math.max(...t))}%`,children:t.map((i,c)=>a.jsx("span",{className:"sd-core",title:`logical core ${c+1} · ${i}% busy`,children:a.jsx("span",{className:"sd-core-fill",style:{transform:`scaleY(${Math.max(2,i)/100})`}})},c))})}),n&&a.jsxs(Dc,{group:"load",title:"Load history",action:"Show load history",label:"Load average",liveNote:s,hint:"the queue for the cores, counted in tasks rather than as a share of them",children:[a.jsx("div",{className:"sd-figs",title:"The queue for this machine's cores, averaged over one, five and fifteen minutes. A count of tasks, not a share of the CPU.",children:n.map((i,c)=>a.jsx(A0,{value:i.toFixed(2),cap:["1m","5m","15m"][c]},c))}),s&&a.jsx("div",{className:"sd-note",children:s})]})]})}function NX({memory:e,swap:t,platform:n}){const r=e.total-e.available,s=n==="win32"?"Commit":"Swap",o=t&&t.total>0?t.used/t.total*100:0;return a.jsx("div",{className:"sd-section",role:"group","aria-label":"Memory",children:a.jsxs(Dc,{group:"memory",title:"Memory history",action:"Show memory history",label:"Memory",children:[a.jsx(Rh,{label:"Physical",value:a.jsxs(a.Fragment,{children:[a.jsx("b",{children:Cs(r)})," of ",Cs(e.total)]}),pct:e.usedPct,tone:e.usedPct>=90?"warn":"calm",note:`${Cs(e.available)} available`}),t&&t.total>0&&a.jsx(Rh,{label:s,value:a.jsxs(a.Fragment,{children:[a.jsx("b",{children:Cs(t.used)})," of ",Cs(t.total)]}),pct:o,tone:o>=90?"warn":"calm"})]})})}function SX({thermal:e}){if(!e)return null;const t=e.throttle?UY(e.throttle,e.heldBack):null;return a.jsx("div",{className:"sd-section",role:"group","aria-label":"Thermal",children:a.jsxs(Dc,{group:"thermal",title:"Thermal history",action:"Show thermal history",label:"Thermal",children:[e.celsius.map(n=>a.jsx(Rh,{label:n.label,value:a.jsxs(a.Fragment,{children:[a.jsx("b",{children:n.celsius})," °C"]}),pct:n.celsius/n.critAt*100,mark:n.warnAt/n.critAt*100,tone:qY(n.celsius,n.warnAt,n.critAt),title:`bar runs 0–${n.critAt} °C · amber from ${n.warnAt} °C, red at ${n.critAt} °C`,trackLabel:`${n.celsius} °C on a bar that runs to ${n.critAt} °C, amber from ${n.warnAt} °C`},n.label)),t&&a.jsx(Rh,{label:"Throttling",value:a.jsx("b",{children:t.value}),pct:t.pct,tone:t.tone,note:t.note})]})})}function _X({sys:e}){const[t,n]=y.useState(!1);return a.jsxs("div",{className:"sd-section sd-door-section",children:[a.jsx("button",{type:"button",className:"sd-open sd-door",onClick:()=>n(!0),"aria-label":"Busiest processes: show every process the deck is watching",children:a.jsxs("span",{className:"sd-door-plate",children:[a.jsxs("span",{className:"sd-door-name",children:["Busiest processes",a.jsx("i",{className:"sd-row-more","aria-hidden":!0,children:"›"})]}),a.jsx("span",{className:"sd-door-sub",children:"every process, with its command line"})]})}),t&&a.jsx(fX,{sys:e,onClose:()=>n(!1)})]})}function Ah(e){const t={inputTokens:e.i,outputTokens:e.o,cacheReadTokens:e.cr,cacheCreateTokens:e.cc,cacheCreate1hTokens:e.c1h,cacheCreate5mTokens:e.c5m};e.l&&(t.longContext=Ah(e.l));const n=e.s?Object.entries(e.s):[];return n.length>0&&(t.bySpeed=Object.fromEntries(n.map(([r,s])=>[r,Ah(s)]))),t}function ME(e){const t=r=>({...r,cacheCreate1hTokens:0,cacheCreate5mTokens:0,...r.longContext?{longContext:{...r.longContext,cacheCreate1hTokens:0,cacheCreate5mTokens:0}}:{}}),n=t(Ah(e));return n.bySpeed&&(n.bySpeed=Object.fromEntries(Object.entries(n.bySpeed).map(([r,s])=>[r,t(s)]))),n}function _3(e){return e.i+e.o+e.cr+e.cc}function M0(e,t){var n;e.i+=t.i,e.o+=t.o,e.cr+=t.cr,e.cc+=t.cc,e.c1h+=t.c1h,e.c5m+=t.c5m,t.l&&M0(e.l??(e.l={i:0,o:0,cr:0,cc:0,c1h:0,c5m:0}),t.l);for(const[r,s]of Object.entries(t.s??{}))M0((n=e.s??(e.s={}))[r]??(n[r]={i:0,o:0,cr:0,cc:0,c1h:0,c5m:0}),s);return e}function $E(e,t,n){let r=0,s=0,o=0;const i=[];for(const c of of(e)){if(!Ta(t,n,c.speed)){const d=c.usage,h=d.inputTokens+d.outputTokens+d.cacheReadTokens+d.cacheCreateTokens;h>0&&(o+=h,i.push(c.speed));continue}r+=Ac(c.usage,t,c.speed,n).total,s+=Ac({...c.usage,longContext:void 0},t,Na,n).total}return{atSpeed:r,atStandard:s,unpriced:o,unpricedSpeeds:i}}function LE(e){let t=0;for(const n of Object.values(e))t+=_3(n);return t}function EX(e){const t=s=>typeof s=="number"&&Number.isFinite(s)?s:0,n=new Map,r=e&&Array.isArray(e.days)?e.days:[];for(const s of r){const o=typeof s.period=="string"?s.period:"",i=Array.isArray(s.modelBreakdowns)?s.modelBreakdowns:[];for(const c of i){const d=typeof c.modelName=="string"?c.modelName:"";if(!o||!/claude/i.test(d)||c.missingPricing===!0)continue;const h=`${o}|${d}`,f=n.get(h),p=f?f.usage:{inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0,cacheCreate1hTokens:0,cacheCreate5mTokens:0};p.inputTokens+=t(c.inputTokens),p.outputTokens+=t(c.outputTokens),p.cacheReadTokens+=t(c.cacheReadTokens),p.cacheCreateTokens+=t(c.cacheCreationTokens),f?f.cost+=t(c.cost):n.set(h,{cost:t(c.cost),usage:p})}}return n}function CX(e,t,n,r=Date.now()){const s=new Map;for(const T of e){const I={},O=U=>{for(const[P,L]of Object.entries(U))M0(I[P]??(I[P]={i:0,o:0,cr:0,cc:0,c1h:0,c5m:0}),L)};for(const U of T.projects)O(U.models);T.unattributed&&O(T.unattributed);for(const[U,P]of Object.entries(I)){if(!P.s&&!P.l)continue;const{atSpeed:L,atStandard:F}=$E(ME(P),U,r);if(!(L>0&&F>0))continue;let A=s.get(T.day);A||(A=new Map,s.set(T.day,A)),A.set(U,L/F),A.has(Zr(U))||A.set(Zr(U),L/F)}}const o=(T,I)=>{const O=s.get(T);return(O==null?void 0:O.get(I))??(O==null?void 0:O.get(Zr(I)))??1},i=new Map;let c=0,d=0;for(const[T,I]of n){const O=T.indexOf("|"),U=T.slice(0,O),P=T.slice(O+1),L=af(I.usage,P,r).total*o(U,P);if(!(L>0&&I.cost>0))continue;c+=I.cost,d+=L;let F=i.get(U);F||(F=new Map,i.set(U,F)),F.set(P,I.cost/L)}const h=d>0,f=(T,I)=>{const O=i.get(T);return(O==null?void 0:O.get(I))??(O==null?void 0:O.get(Zr(I)))??null},p=new Set,g=(T,I)=>{let O=0,U=0;for(const[P,L]of Object.entries(T)){if(Ta(P,r)){const A=I(P),B=$E(A===null?Ah(L):ME(L),P,r);O+=A===null?B.atSpeed:B.atSpeed*A,U+=B.unpriced;for(const D of B.unpricedSpeeds)p.add(`${P} (${D})`);continue}const F=_3(L);F>0&&(U+=F,p.add(P))}return{cost:O,unpriced:U}},w=new Map,k=[];for(const T of e){const I=new Map,O=new Map;let U=0;for(const P of T.projects){const{cost:L,unpriced:F}=g(P.models,B=>f(T.day,B));I.set(P.path,(I.get(P.path)??0)+L),F>0&&O.set(P.path,(O.get(P.path)??0)+F),U+=L;let A=w.get(P.path);A||(A={path:P.path,cost:0,tokens:0,unpricedTokens:0},w.set(P.path,A)),A.cost+=L,A.tokens+=LE(P.models),A.unpricedTokens+=F}k.push({day:T.day,total:U,byPath:I,unpricedByPath:O})}const j=[...w.values()].sort((T,I)=>I.cost-T.cost||I.tokens-T.tokens),v=j.reduce((T,I)=>T+I.cost,0),b=j.reduce((T,I)=>T+I.tokens,0),N=j.reduce((T,I)=>T+I.unpricedTokens,0),S=h?c/d:null,E=t?LE(t):0,C=t?g(t,()=>S):{cost:0,unpriced:0},$=C.cost>0||E>0?{cost:C.cost,tokens:E,unpricedTokens:C.unpriced}:null;return{projects:j,totalCost:v,totalTokens:b,unpricedTokens:N,perDay:k,unattributed:$,unpricedModels:[...p].sort(),calibrated:h,reconciled:h&&N===0}}function Xr(e,t,n=Ye){return t>0?e>0?`${n(e)}+`:Ls:n(e)}function yi(e){return e>0?`${ut(e)} of these tokens are on an unpriced model, so this is a floor`:void 0}function TX(e){if(e.length===0)return null;const t=e.length===1,n=t?e[0]:`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`;return t?`${n} is ${Ls}: this build holds no published rate for it, so its tokens are counted and its dollars are not.`:`${n} are ${Ls}: this build holds no published rate for them, so their tokens are counted and their dollars are not.`}const RX={phase:"running"},AX={phase:"failed"},MX={gen:0,report:null,error:null,early:null};function $X(e,t){var n,r;if(t.type!=="start"&&t.gen!==e.gen)return e;switch(t.type){case"start":return{...e,gen:t.gen,error:null,early:null};case"report":{const s=((n=e.early)==null?void 0:n.gen)===t.gen?e.early.cost:RX;return{...e,report:{gen:t.gen,days:t.days,data:t.data,cost:s},early:null}}case"reportFailed":return{...e,report:null,error:t.message,early:null};case"cost":return((r=e.report)==null?void 0:r.gen)===t.gen?{...e,report:{...e.report,cost:t.cost}}:{...e,early:{gen:t.gen,cost:t.cost}}}}function LX(e){var t;return((t=e.report)==null?void 0:t.gen)!==e.gen&&e.error===null}function OX(e){const t=e;return t&&t.ok!==!1?{phase:"ready",range:t}:AX}function IX(e){return`${e.getFullYear()}${String(e.getMonth()+1).padStart(2,"0")}${String(e.getDate()).padStart(2,"0")}`}function PX(e,t,n=Date.now()){const r=t===0?60:t,s=new Date(n),o=T0(r,s),i=IX(s);return{report:`/api/account-projects?num=${e}&days=${t}`,ccusage:`/api/ccusage?since=${o}&until=${i}`}}function DX({num:e,days:t,gen:n,dispatch:r,get:s=(i,c)=>fetch(i,c),now:o=Date.now()}){const i=PX(e,t,o),c={credentials:"same-origin"};s(i.report,c).then(d=>d.ok?d.json():Promise.reject(new Error(`HTTP ${d.status}`))).then(d=>r({type:"report",gen:n,days:t,data:d}),d=>r({type:"reportFailed",gen:n,message:(d==null?void 0:d.message)||"Could not load"})),s(i.ccusage,c).then(d=>d.ok?d.json():null).catch(()=>null).then(d=>r({type:"cost",gen:n,cost:OX(d)}))}async function Mo(e,t=500){var r;if(!e)return!1;let n=!1;try{n=await Promise.race([((r=navigator.clipboard)==null?void 0:r.writeText(e).then(()=>!0))??Promise.resolve(!1),new Promise(s=>window.setTimeout(()=>s(!1),t))])}catch{n=!1}if(n)return!0;try{const s=document.createElement("textarea");s.value=e,s.setAttribute("readonly",""),s.style.cssText="position:fixed;top:0;left:0;opacity:0",document.body.appendChild(s),s.select(),n=document.execCommand("copy"),s.remove()}catch{n=!1}return n}function E3(e){return/^[A-Za-z]:[\\/]$/.test(e)?e:e.replace(/[\\/]+$/,"")}function lg(e){const t=E3(e).replace(/\\/g,"/");return/^[A-Za-z]:\//.test(t)?t.toLowerCase():t}function OE(e){if(!e)return e;const t=E3(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 FX(e,t){const n=lg(e);let r;for(const s of t){const o=lg(s.path);!o||o===n||!n.startsWith(`${o}/`)||(!r||lg(r.path).length<o.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 BX(e){return e===1?"No work attributed to this account yet today.":`No work attributed to this account in ${$0(e)}.`}function qX(e){return e===1?7:e===7?30:e===30?0:null}function UX(e,t){return e!==1&&t>0}const HX=[{days:1,label:"Today"},{days:7,label:"7d"},{days:30,label:"30d"},{days:0,label:"All"}],wi=["var(--usage-blue)","var(--usage-teal)","var(--usage-lime)","var(--usage-purple)","var(--usage-indigo)","var(--usage-pink)","var(--usage-orange)","var(--usage-zinc)"],WX="var(--usage-zinc)",cg=6,zX=1600;function VX(e){const t=Ye(e),n=/^\$(\d{4,})$/.exec(t);return n?`$${Number(n[1]).toLocaleString("en-US")}`:t}function Ld(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 GX(e){const t=/^\d{4}-(\d{2})-(\d{2})$/.exec(e);return t?`${Number(t[1])}/${Number(t[2])}`:e}function KX(e){const t=Math.max(1,Math.ceil(e/6));return n=>n===0||n===e-1||n%t===0}function ug(e){if(!e)return"";try{return new Date(e).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return""}}function YX({num:e,name:t,onClose:n}){var D,K,G,H;Jt("account-projects");const[r,s]=y.useState(1),[o,i]=y.useReducer($X,MX),c=((D=o.report)==null?void 0:D.data)??null,d=((K=o.report)==null?void 0:K.days)??r,h=((G=o.report)==null?void 0:G.cost.phase)==="ready"?o.report.cost.range:null,f=((H=o.report)==null?void 0:H.cost.phase)==="running",[p,g]=y.useState(null),[w,k]=y.useState(()=>new Set),j=LX(o),v=o.error,[b,N]=y.useState(null),S=y.useRef(void 0),E=y.useRef(!0);y.useEffect(()=>()=>{E.current=!1,window.clearTimeout(S.current)},[]);const C=y.useRef(null),$=ot(n,{focusRef:C}),T=dt(n),I=y.useRef(0);y.useEffect(()=>{const q=++I.current;i({type:"start",gen:q}),g(null),k(new Set),DX({num:e,days:r,gen:q,dispatch:i})},[e,r]);const O=y.useMemo(()=>{const q=Date.now();if(!c)return null;const M=CX(c.daily??[],c.unattributed,EX(h),q),V=we=>we.replace(/[\\/]+$/,"").split(/[\\/]/).pop()||we||"(unknown)",Z=new Map;for(const we of M.projects)Z.set(V(we.path),(Z.get(V(we.path))??0)+1);const W=we=>{const Ne=V(we);if((Z.get(Ne)??0)<=1)return Ne;const ge=we.replace(/[\\/]+$/,"").split(/[\\/]/).slice(-2,-1)[0];return ge?`${ge}/${Ne}`:Ne},X=M.projects.map(we=>({path:we.path,label:W(we.path)})),Y=we=>({path:we.path,label:W(we.path),parentLabel:FX(we.path,X),cost:we.cost,tokens:we.tokens,unpricedTokens:we.unpricedTokens}),J=wi[cg%wi.length],ee=new Map,ne=[],se=M.projects.slice(0,cg),ce=M.projects.slice(cg);se.forEach((we,Ne)=>{ee.set(we.path,wi[Ne%wi.length]),ne.push({key:we.path,...Y(we),color:wi[Ne%wi.length]})}),ce.length&&ne.push({key:"__other__",label:`Other · ${ce.length} project${ce.length>1?"s":""}`,cost:ce.reduce((we,Ne)=>we+Ne.cost,0),tokens:ce.reduce((we,Ne)=>we+Ne.tokens,0),unpricedTokens:ce.reduce((we,Ne)=>we+Ne.unpricedTokens,0),color:J,muted:!0,members:ce.map(Y)});const de=M.totalCost,ae=M.totalTokens,pe=de>0&&M.unpricedTokens===0?"cost":"tokens",fe=pe==="cost"?de:ae,Ee=ne.map(we=>we.color),ye=M.perDay.map(we=>{const Ne=new Map;for(const[Oe,qe]of we.byPath){const Me=ee.get(Oe)??J;Ne.set(Me,(Ne.get(Me)??0)+qe)}const ge=new Map;let Ae=0;for(const[Oe,qe]of we.unpricedByPath){const Me=ee.get(Oe)??J;ge.set(Me,(ge.get(Me)??0)+qe),Ae+=qe}return{day:we.day,total:we.total,costByColor:Ne,unpricedByColor:ge,unpriced:Ae}}),oe=ye.reduce((we,Ne)=>Math.max(we,Ne.total),0);return{projectCount:M.projects.length,rows:ne,totalCost:de,totalTokens:ae,basis:pe,denom:fe,un:M.unattributed,chart:ye,maxDay:oe,colorOrder:Ee,unpricedTokens:M.unpricedTokens,unpricedNote:TX(M.unpricedModels),calibrated:M.calibrated,reconciled:M.reconciled}},[c,h]),U=(q,M)=>{Mo(q).then(V=>{E.current&&(window.clearTimeout(S.current),N({path:q,label:M,ok:V}),S.current=window.setTimeout(()=>{E.current&&N(null)},zX))})},P=q=>b!=null&&b.ok&&b.path===q?"Copied":"Copy",L=c!=null&&c.trackedSince?`Tracked since ${ug(c.trackedSince)}`:"Tracking starts with this version",F=$0(d),A=qX(d),B=j&&!!c;return yt.createPortal(a.jsx("div",{className:"modal-backdrop",...T,role:"presentation",children:a.jsxs("div",{ref:$,className:"modal ap-proj-modal",onClick:q=>q.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ap-proj-title ap-proj-sub",children:[a.jsxs("header",{className:"ap-proj-head",children:[a.jsxs("div",{className:"ap-proj-titlewrap",children:[a.jsx("div",{className:"ap-proj-title",id:"ap-proj-title",children:"Projects"}),a.jsx("div",{className:"ap-proj-sub",id:"ap-proj-sub",title:t,children:t})]}),a.jsx("div",{className:"uh-range",role:"group","aria-label":"Range",children:HX.map(q=>a.jsx("button",{type:"button",className:"uh-range-btn","aria-pressed":r===q.days,onClick:()=>s(q.days),children:q.label},q.days))}),a.jsx("button",{ref:C,className:"glyph-btn ap-proj-close",onClick:n,"aria-label":"Close",children:"×"})]}),a.jsxs("div",{className:`ap-proj-body${B?" refreshing":""}`,"aria-busy":j,children:[j&&!c&&a.jsx("div",{className:"ap-proj-state",children:"Loading…"}),!j&&v&&a.jsxs("div",{className:"ap-proj-state ap-proj-error",children:["Couldn’t load this report: ",v]}),!v&&O&&a.jsx(a.Fragment,{children:O.rows.length===0?a.jsxs("div",{className:"ap-proj-state",children:[B?"Updating…":BX(d),A!=null&&a.jsx("div",{className:"ap-proj-widen-wrap",children:a.jsxs("button",{type:"button",className:"ap-proj-copy",onClick:()=>s(A),children:["Show ",$0(A)]})}),a.jsxs("div",{className:"ap-proj-note",children:[L,". Only work from this version onward can be tied to an account."]})]}):a.jsxs(a.Fragment,{children:[a.jsx("div",{className:"ap-proj-bar",role:"img","aria-label":`Share of ${O.basis==="cost"?Ye(O.totalCost):`${ut(O.totalTokens)} tokens`} across ${O.projectCount} project${O.projectCount>1?"s":""}`,children:O.rows.map(q=>{const M=O.basis==="cost"?q.cost:q.tokens,V=O.denom>0?M/O.denom*100:0;if(V<=0)return null;const Z=O.basis==="cost"?Ld(q.cost,O.totalCost):`${Ld(q.tokens,O.totalTokens)} of tokens`;return a.jsx("span",{className:"ap-proj-seg",style:{width:`${V}%`,background:q.color},title:`${q.label} · ${Xr(q.cost,q.unpricedTokens)} · ${Z}${q.tokens?` · ${ut(q.tokens)} tokens`:""}`},q.key)})}),a.jsxs("div",{className:"ap-proj-totals",children:[a.jsx("span",{className:"ap-proj-total-cost",title:yi(O.unpricedTokens),children:Xr(O.totalCost,O.unpricedTokens)}),a.jsxs("span",{className:"ap-proj-total-tok",children:[ut(O.totalTokens)," tokens"]}),a.jsxs("span",{className:"ap-proj-total-win",children:["· ",B?"updating…":F]}),f&&a.jsx("span",{className:"ap-proj-total-pending",children:"Reconciling cost…"})]}),O.unpricedNote&&a.jsx("div",{className:"ap-proj-note",children:O.unpricedNote}),UX(d,O.chart.length)&&a.jsxs("div",{className:"ap-proj-days",children:[a.jsxs("div",{className:"ap-proj-days-cap",children:["By day",O.chart.length>1?" · click a bar":""]}),a.jsx("div",{className:"ap-proj-days-plot",role:"group","aria-label":`Spend across ${O.chart.length} day${O.chart.length>1?"s":""}`,children:O.chart.map(q=>{const M=O.maxDay>0?q.total/O.maxDay*100:0,V=p===q.day,Z=O.rows.map(X=>({label:X.label,c:q.costByColor.get(X.color)??0,u:q.unpricedByColor.get(X.color)??0})).filter(X=>X.c>0||X.u>0),W=`${ug(Date.parse(`${q.day}T00:00:00`))}, ${Xr(q.total,q.unpriced)}. ${Z.map(X=>`${X.label} ${Xr(X.c,X.u)}`).join(", ")}`;return a.jsx("button",{type:"button",className:`ap-proj-day${V?" selected":""}`,"aria-pressed":V,"aria-label":W,title:`${q.day} · ${Xr(q.total,q.unpriced)}`,onClick:()=>g(X=>X===q.day?null:q.day),children:a.jsx("span",{className:"ap-proj-col",style:{height:`${M}%`},children:O.colorOrder.map((X,Y)=>{const J=q.costByColor.get(X)??0;return J<=0||q.total<=0?null:a.jsx("span",{className:"ap-proj-colseg",style:{height:`${J/q.total*100}%`,background:X}},Y)})})},q.day)})}),(()=>{const q=KX(O.chart.length);return a.jsx("div",{className:"ap-proj-days-axis","aria-hidden":"true",children:O.chart.map((M,V)=>a.jsx("div",{className:"ap-proj-axis-cell",children:q(V)?GX(M.day):""},M.day))})})(),(()=>{const q=p?O.chart.find(V=>V.day===p):null;if(!q)return null;const M=O.rows.map(V=>({r:V,c:q.costByColor.get(V.color)??0,u:q.unpricedByColor.get(V.color)??0})).filter(V=>V.c>0||V.u>0);return a.jsxs("div",{className:"ap-proj-day-detail",children:[a.jsxs("div",{className:"ap-proj-day-detail-head",children:[a.jsx("span",{children:ug(Date.parse(`${q.day}T00:00:00`))}),a.jsx("span",{className:"ap-proj-day-detail-total",title:yi(q.unpriced),children:Xr(q.total,q.unpriced)})]}),M.map(({r:V,c:Z,u:W})=>a.jsxs("div",{className:"ap-proj-day-detail-row",children:[a.jsx("span",{className:"ap-proj-dot",style:{background:V.color},"aria-hidden":"true"}),a.jsx("span",{className:"ap-proj-day-detail-name",children:V.label}),a.jsx("span",{className:"ap-proj-day-detail-cost",title:yi(W),children:Xr(Z,W)})]},V.key))]})})()]}),a.jsx("ul",{className:"ap-proj-list",children:O.rows.map((q,M)=>{const V=O.basis==="cost"?q.cost:q.tokens,Z=O.denom>0?V/O.denom*100:0,W=w.has(q.key),X=`ap-proj-details-${M}`,Y=W&&(!!q.path||!!q.members),J=q.members?`${W?"Hide":"Show"} the ${q.members.length} project${q.members.length>1?"s":""} folded into Other`:`${W?"Hide":"Show"} location for ${q.label}`;return a.jsxs("li",{className:`ap-proj-row${q.muted?" muted":""}${W?" expanded":""}`,children:[a.jsx("span",{className:"ap-proj-dot",style:{background:q.color},"aria-hidden":"true"}),a.jsxs("span",{className:"ap-proj-name",children:[q.label,q.parentLabel&&a.jsxs("span",{className:"ap-proj-parent",children:[" · in ",q.parentLabel]})]}),a.jsx("span",{className:"ap-proj-track",title:O.basis==="cost"?`${Ld(q.cost,O.totalCost)} of tracked cost`:`${Ld(q.tokens,O.totalTokens)} of tracked tokens`,children:a.jsx("span",{className:"ap-proj-fill",style:{width:`${Z}%`,background:q.color}})}),a.jsx("span",{className:"ap-proj-cost",title:yi(q.unpricedTokens),children:Xr(q.cost,q.unpricedTokens)}),a.jsx("span",{className:"ap-proj-tok",children:ut(q.tokens)}),a.jsx("button",{type:"button",className:"glyph-btn ap-proj-info","aria-expanded":W,"aria-controls":Y?X:void 0,"aria-label":J,onClick:()=>k(ee=>{const ne=new Set(ee);return ne.has(q.key)?ne.delete(q.key):ne.add(q.key),ne}),children:"ⓘ"}),W&&q.path&&a.jsxs("div",{className:"ap-proj-details",id:X,children:[a.jsx("code",{className:"ap-proj-path",children:OE(q.path)}),a.jsx("button",{type:"button",className:"ap-proj-copy","aria-label":`${P(q.path)} location for ${q.label}`,onClick:()=>U(q.path,q.label),children:P(q.path)})]}),W&&q.members&&a.jsx("div",{className:"ap-proj-details ap-proj-other-members",id:X,children:q.members.map(ee=>a.jsxs("div",{className:"ap-proj-other-member",children:[a.jsxs("div",{className:"ap-proj-other-name",children:[ee.label,ee.parentLabel&&a.jsxs("span",{className:"ap-proj-parent",children:[" · in ",ee.parentLabel]})]}),a.jsx("code",{className:"ap-proj-path",children:OE(ee.path)}),a.jsx("span",{className:"ap-proj-cost",title:yi(ee.unpricedTokens),children:Xr(ee.cost,ee.unpricedTokens)}),a.jsx("span",{className:"ap-proj-tok",children:ut(ee.tokens)}),a.jsx("button",{type:"button",className:"ap-proj-copy","aria-label":`${P(ee.path)} location for ${ee.label}`,onClick:()=>U(ee.path,ee.label),children:P(ee.path)})]},ee.path))})]},q.key)})}),O.un&&a.jsxs("div",{className:"ap-proj-unattributed",children:[a.jsx("span",{className:"ap-proj-dot",style:{background:WX},"aria-hidden":"true"}),a.jsxs("div",{className:"ap-proj-un-labels",children:[a.jsx("span",{className:"ap-proj-un-title",children:"Unattributed usage"}),a.jsx("span",{className:"ap-proj-un-tag",children:"Excluded from the project totals"})]}),a.jsx("span",{className:"ap-proj-un-cost",title:yi(O.un.unpricedTokens),children:Xr(O.un.cost,O.un.unpricedTokens,VX)}),a.jsx("span",{className:"ap-proj-un-tok",children:ut(O.un.tokens)}),a.jsx("div",{className:"ap-proj-note",children:"Work no account could be tied to — from before tracking, or a gap."})]}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:b&&(b.ok?`Copied the location of ${b.label}`:`Could not copy the location of ${b.label} — select it and copy it by hand`)}),a.jsxs("div",{className:"ap-proj-foot",children:[f?"Dollars estimated · ccusage still running":O.reconciled?"Dollars from ccusage · split by activity":O.calibrated?"Dollars from ccusage for the priced models · split by activity":h?"Dollars estimated · ccusage could not price this window":"Dollars estimated · ccusage unavailable"," · ",L]})]})})]})]})}),document.body)}function _a(e,t){return zI(t-Math.floor(e/1e3))}function XX(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 i1(){return a.jsxs("svg",{className:"ap-warn-glyph",width:"12",height:"12",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("path",{d:"M7 1.9 12.9 12H1.1Z"}),a.jsx("path",{d:"M7 5.6v2.9"}),a.jsx("path",{d:"M7 10.3v.05"})]})}function ZX({anchorId:e,boundaryId:t,issue:n,who:r,fetchedAt:s,nowSec:o,onClose:i,onSignIn:c,onReport:d}){const h=y.useRef(null);return a.jsx(Nf,{anchorId:e,boundaryId:t,id:"ap-issue-pop",className:"ap-pop ap-issue-pop",role:"dialog",labelledBy:"ap-issue-title",focusRef:h,onClose:()=>i(),children:a.jsxs("div",{className:"ap-pop-form",children:[a.jsxs("p",{className:"ap-pop-title ap-issue-title",id:"ap-issue-title","data-tone":n.tone,children:[n.tone==="warn"&&a.jsx(i1,{}),n.text]}),a.jsx("p",{className:"ap-pop-note ap-issue-hint",children:n.hint}),a.jsxs("p",{className:"ap-pop-note ap-issue-when",children:[a.jsx("span",{className:"ap-issue-who",children:r})," · ",s?`last collected ${_a(s,o)}`:"never collected"]}),a.jsxs("div",{className:"ap-pop-actions",children:[d&&a.jsx("button",{type:"button",className:"ap-issue-report",onClick:()=>{i(),d()},children:"Report this"}),a.jsx("button",{type:"button",ref:h,className:"btn",onClick:()=>i(!0),children:"Done"}),n.fix&&a.jsx("button",{type:"button",className:"btn primary",onClick:()=>{i(!0),c()},title:"Open the sign-in dialog. Signing in as this account puts its login back in this slot — it keeps its slot, its alias and its history.",children:n.fix})]})]})})}function ic(e){return e.charAt(0).toUpperCase()+e.slice(1)}function JX(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 QX(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 eZ(e){switch(e){case"no_credentials":return{text:"no stored login",hint:"claude-swap holds no credentials for this account, so there is nothing to read its usage with and nothing to switch to. A paired deck that has them sends them on its own; signing in as this account puts them there by hand.",fix:"sign in"};case"relogin_required":return{text:"login expired",hint:"claude-swap's stored login for this account was rejected and cannot be refreshed. Signing in again replaces it — the account keeps its slot, its alias and its history.",fix:"sign in again"};case"keychain_unavailable":return{text:"keychain unreadable",hint:"This is about the deck, not the account: claude-swap could not open your keychain, so it cannot read any account's stored login. A deck started from a background session cannot reach the keychain at all — start it from a terminal, or let it start at login, and this clears."};case"token_expired":return{text:"token expired",hint:"The access token ran out and the refresh was deferred. The next collection retries."};case"foreign_credential":return{text:"wrong credential",hint:"The live credential belongs to a different account. Switching to this one repairs it."};case null:case void 0:return null;default:return{text:e,hint:`claude-swap reported "${e}" for this account.`}}}const IE={text:"Login expired on all online decks",hint:"Every paired deck online right now that shares this account holds a copy that has expired too, so none of them can repair this one. Claude retires a login's other copies each time one machine refreshes it, which is how shared copies expire together. Sign in again on any one machine that shares it; the others repair from it on their next round."};function Co(e,t,n){const r=nZ(e,t);return!r||!(n!=null&&n.noCopyWorksNearby)||!tZ(e)?r:{...r,text:IE.text,hint:IE.hint}}function tZ(e){return e.staleCopy?!1:e.stopped?e.collector==="relogin_required":e.error==="invalid_grant"||e.error==="no_refresh_token"}function nZ(e,t){if(e.staleCopy){const n=JX(e.repair??null,t);return{text:ic(n.text),hint:n.hint,fix:null,tone:"quiet",blocksSwitch:!1}}if(e.stopped){const n=eZ(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:ic(n.text),hint:n.hint,fix:n.fix?ic(n.fix):null,tone:r||e.collector==="keychain_unavailable"?"warn":"quiet",blocksSwitch:r}}if(e.error){const n=QX(e.error);return{text:ic(n.text),hint:n.hint,fix:n.fixable?"Sign in again":null,tone:n.fixable?"warn":"quiet",blocksSwitch:n.fixable}}return null}function PE(e){return typeof e.id=="string"&&e.id.startsWith("scoped-")}function DE(e){const t=e.filter(c=>!PE(c)),n=e.filter(c=>PE(c)),r=t.length?t:n,s=t.length?n:[],o=r.reduce((c,d)=>c&&c.pct>=d.pct?c:d,null);let i=null;for(const c of s)o&&c.pct<=o.pct||(!i||c.pct>i.pct)&&(i=c);return{shown:r,rest:s,fuller:i,peak:i??o}}function Fc(e,t){return!!e.resetAt&&e.resetAt<=t}function l1(e,t){return(e.lanes??[]).some(r=>Fc(r,t))?null:e.headroom}const rZ="\0";function _r(e){const t=typeof e.email=="string"?e.email.trim():"";if(!t)return`slot:${e.num}`;const n=typeof e.orgUuid=="string"&&e.orgUuid.trim()?`uuid:${e.orgUuid.trim()}`:typeof e.org=="string"?e.org.trim():"";return`acct:${t}${rZ}${n}`}function sZ(e,t,n=_r){const r=n(t);return e.includes(r)?e.filter(s=>s!==r):[...e,r]}const Sf="slot",c1=[{lane:"five_hour",name:"5h"},{lane:"seven_day",name:"7d"}],C3=e=>e.id.startsWith("scoped-");function aZ(e){var t;return((t=c1.find(n=>n.lane===e.id))==null?void 0:t.name)??e.label}function oZ(e){if(e==="room")return"room";const t=/^(.+):(full|empty)$/.exec(e);return t?t[1]:null}function T3(e){const t=[...new Set(e.flatMap(r=>(r.lanes??[]).filter(C3).map(s=>s.label)))].sort((r,s)=>r.localeCompare(s)),n=[...c1.map(r=>r.name),...t];return[{id:Sf,label:"Slot"},...n.flatMap(r=>[{id:`${r}:full`,label:`${r} · fullest`},{id:`${r}:empty`,label:`${r} · emptiest`}]),{id:"room",label:"Most room"}]}function FE(e,t,n){const r=c1.find(o=>o.name===t),s=(e.lanes??[]).find(o=>r?o.id===r.lane:C3(o)&&o.label===t);return s&&n!=null&&Fc(s,n)?null:s&&Number.isFinite(s.pct)?s.pct:null}function iZ(e,t,n=()=>!0,r){const s=[...e],o=f=>[...f.filter(n),...f.filter(p=>!n(p))];if(t==="room"){const f=p=>r==null?p.headroom:l1(p,r);return o(BE(s,p=>{const g=f(p);return Number.isFinite(g)?g:null},"desc"))}const i=/^(.+):(full|empty)$/.exec(t);if(!i)return s;const[,c,d]=i;if(!s.some(f=>FE(f,c,r)!=null))return s;const h=BE(s,f=>FE(f,c,r),d==="full"?"desc":"asc");return d==="empty"?o(h):h}function BE(e,t,n){const r=e.filter(o=>t(o)!=null),s=e.filter(o=>t(o)==null);return r.sort((o,i)=>n==="desc"?t(i)-t(o):t(o)-t(i)),[...r,...s]}function lZ(e,t){return T3(t).some(n=>n.id===e)?e:Sf}function L0(e,t){if(!t)return[...e];const n=new Map(t.map((o,i)=>[o,i])),r=e.filter(o=>n.has(_r(o))).sort((o,i)=>n.get(_r(o))-n.get(_r(i))),s=e.filter(o=>!n.has(_r(o)));return[...r,...s]}function u1(e){const t=_r(e);return t.startsWith("slot:")?t:`h:${cZ(t)}`}function cZ(e){let t=3735928559,n=1103547991;for(let r=0;r<e.length;r++){const s=e.charCodeAt(r);t=Math.imul(t^s,2654435761),n=Math.imul(n^s,1597334677)}return t=Math.imul(t^t>>>16,2246822507)^Math.imul(n^n>>>13,3266489909),n=Math.imul(n^n>>>16,2246822507)^Math.imul(t^t>>>13,3266489909),(4294967296*(2097151&n)+(t>>>0)).toString(36)}const O0={mode:"some",keys:[]};function R3(e,t){const n=e.keys.includes(u1(t));return e.mode==="all"?!n:n}function uZ(e,t){return{mode:e.mode,keys:sZ(e.keys,t,u1)}}function A3(e,t){return t.length>0&&t.every(n=>R3(e,n))}function dZ(e,t){return A3(e,t)?O0:{mode:"all",keys:[]}}function hZ(e,t){if(!Array.isArray(t))return e;const n=new Set(t.map(u1)),r=e.keys.filter(s=>n.has(s));return r.length===e.keys.length?e:{mode:e.mode,keys:r}}const bo=[{id:"five_hour",label:"5h",long:"5-hour"},{id:"seven_day",label:"7d",long:"7-day"}];function qE(e){return e.counted?e.pct:e.why==="login"?null:e.estimate}function fZ(e){const t=qE(e.five_hour),n=qE(e.seven_day);if(t==null||n==null)return"stale";const r=+(t>=100)+ +(n>=100);return r===0?"ready":r===1?"limited":"exhausted"}function pZ(e,t){const n=bo.map(r=>e.cells[r.id]);for(const r of n)if(!r.counted&&(r.why==="login"||r.why==="none"))return{text:r.say,old:!0};return e.updatedAt==null?{text:"never read",old:!0}:n.every(r=>r.counted)?{text:"now",old:!1}:{text:_a(e.updatedAt,t),old:!0}}const M3=15*6e4;function _f(e){return e!=null&&e>0&&Number.isFinite(e)&&Number.isFinite(new Date(e).getTime())?e:null}const $3=e=>e.alias??e.email??`account ${e.num}`;function yc(e,t){var r,s;const n=(s=(r=e.lanes)==null?void 0:r.find(o=>o.id===t))==null?void 0:s.resetAt;return n!=null&&n>0&&Number.isFinite(n)&&Number.isFinite(new Date(n*1e3).getTime())?n:null}function I0(e,t,n){const r=bo.find(w=>w.id===t).label,s=(e.lanes??[]).find(w=>w.id===t),o=s&&Number.isFinite(s.pct)?L3(s.pct):null,i=Co(e,n),c=yc(e,t),d=c!=null&&c<=n,h=O3(s,e.fetchedAt,n),f=(w,k)=>({counted:!1,why:w,say:k,last:o,estimate:o,resetAt:d?null:yc(e,t),reset:h});if(i!=null&&i.blocksSwitch)return f("login",i.text);if(o==null)return f("none",`No ${r} reading`);if(h)return f("reset",h);const p=_f(e.fetchedAt);return e.stale||e.staleCopy===!0||e.stopped===!0||p==null||n*1e3-p>M3?f("stale",p!=null?`Updated ${_a(p,n)}`:"Never read"):{counted:!0,pct:o,resetAt:yc(e,t)}}const L3=e=>Math.min(100,Math.max(0,e));function O3(e,t,n){if((e==null?void 0:e.resetAt)==null||e.resetAt<=0||!Number.isFinite(e.resetAt)||!Number.isFinite(new Date(e.resetAt*1e3).getTime())||e.resetAt>n||!Number.isFinite(e.pct))return null;const r=_f(t),s=r!=null?`read ${_a(r,n)}`:"last read";return`Reported reset time passed ${_a(e.resetAt*1e3,n)}, ${Ea(L3(e.pct))}% when ${s}`}function mZ(e,t){const n=bo.find(h=>h.id===t);let r=0,s=0,o=0;const i=[];for(const h of e){const f=h.cells[t],p=f.counted?f.pct:f.estimate;p!=null&&(r+=p,o++,f.counted&&s++,f.resetAt!=null&&i.push({at:f.resetAt,name:h.name,pct:p}))}const c=i.reduce((h,f)=>!h||f.at<h.at?f:h,null),d=c&&{...c,more:i.filter(h=>h!==c&&h.at-c.at<60).length};return{id:t,label:n.label,long:n.long,reporting:s,included:o,total:e.length,used:o?r/o:null,nextReset:d}}function d1(e,t){const n=e.map(s=>{const o={five_hour:I0(s,"five_hour",t),seven_day:I0(s,"seven_day",t)};return{num:s.num,key:_r(s),name:$3(s),active:s.active,heldOut:s.disabled===!0,cells:o,resets:{five_hour:yc(s,"five_hour"),seven_day:yc(s,"seven_day")},status:fZ(o),updatedAt:_f(s.fetchedAt)}}),r=n.filter(s=>s.status==="ready").length;return{rows:n,windows:bo.map(s=>mZ(n,s.id)),roomInBoth:r}}function Ql(e,t){return(e==null?void 0:e.key)===t?{key:t,dir:e.dir==="asc"?"desc":"asc"}:{key:t,dir:"asc"}}const gZ={ready:0,limited:1,exhausted:2,stale:3};function yZ(e){return e.counted?e.pct:e.reset?e.estimate:e.last}function UE(e,t){return t==="status"?gZ[e.status]:t==="updated"?e.updatedAt==null?null:-e.updatedAt:t==="five_hour_reset"?e.resets.five_hour:t==="seven_day_reset"?e.resets.seven_day:yZ(e.cells[t])}function wZ(e,t){if(!t)return[...e];const n=t.dir==="asc"?1:-1,r=new Map(e.map((o,i)=>[o.num,i])),s=(o,i)=>{if(t.key==="account")return n*o.name.localeCompare(i.name,void 0,{sensitivity:"base"});const c=UE(o,t.key),d=UE(i,t.key);return c==null||d==null?c==null?d==null?0:1:-1:n*(c-d)};return[...e].sort((o,i)=>s(o,i)||r.get(o.num)-r.get(i.num))}function Ea(e){return e>=100?100:Math.min(99,Math.round(e))}function xZ(e){const t=Ea(e);return{used:t,available:100-t}}function vZ(e,t,n){return e?`${e} These are the last readings.`:t&&n?"The account store could not be read just now. These are the last readings.":null}function bZ(e){return e>=90?"hi":e>=70?"mid":void 0}function kZ({lane:e,nowSec:t,readAt:n,frozen:r,sortedBy:s}){const o=Math.min(100,Math.max(0,e.pct)),i=Fc(e,t),c=r||i,d=c?"var(--muted)":o>=90?"var(--err)":o>=70?"var(--warn)":"var(--accent)",h=e.resetAt&&!c?Qc(e.resetAt,t):null,f=i?O3(e,n,t):null;return a.jsxs("div",{className:"ap-lane","data-sort-key":s?"":void 0,children:[a.jsx("span",{className:"ap-lane-label",title:e.label,children:e.label}),a.jsx("div",{className:"ap-lane-track",children:!i&&a.jsx("div",{className:"ap-lane-fill",style:{width:`${o===0?1.5:o}%`,background:d,opacity:o===0||c?.4:1}})}),i?a.jsx("span",{className:"ap-lane-pct",style:{color:d},"data-reset":"",title:f??void 0,children:f?a.jsxs(a.Fragment,{children:[a.jsx("span",{"aria-hidden":!0,children:"reset"}),a.jsx("span",{className:"vis-hidden",children:f})]}):"reset"}):a.jsxs("span",{className:"ap-lane-pct",style:{color:d},children:[Math.round(o),"%"]}),a.jsx("span",{className:"ap-lane-reset",title:h?`${e.label} resets in ${h}`:void 0,children:h&&a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"vis-hidden",children:"resets in "}),h]})})]})}function jZ({a:e,nowSec:t,lan:n,opened:r,onToggleLanes:s,busy:o,pressProps:i,onSwitch:c,menuOpen:d,onOpenMenu:h,onCloseMenu:f,refusal:p,onDismissRefusal:g,switchedHere:w,swapped:k,displaced:j,issueExpanded:v,onOpenIssue:b,sortKey:N=null}){const S=e.lanes.filter(A=>!Fc(A,t)),{shown:E}=DE(e.lanes),{fuller:C}=DE(S),$=N==="room"?S.reduce((A,B)=>A&&A.pct>=B.pct?A:B,null):N?e.lanes.find(A=>aZ(A)===N)??null:null,T=Co(e,t,n),I=e.active||r,O=e.alias??e.email??`account ${e.num}`,U=e.alias&&e.email?`${e.alias} · ${e.email}`:O,P=e.stale||(T==null?void 0:T.blocksSwitch)===!0,L=C?[...E,C]:E,F=e.fetchedAt?_a(e.fetchedAt,t):null;return a.jsxs("li",{className:`ap-account${e.active?" active":""}`,"aria-current":e.active?"true":void 0,"data-open":I?"":void 0,"data-frozen":P?"":void 0,children:[!e.active&&a.jsx("button",{type:"button",className:"ap-row-open",id:`ap-row-${e.num}`,title:U,"aria-expanded":I,"aria-controls":I?`ap-detail-${e.num}`:void 0,"aria-describedby":[e.alias&&e.email?`ap-email-${e.num}`:null,!I&&!(T!=null&&T.blocksSwitch)?`ap-quota-${e.num}`:null].filter(Boolean).join(" ")||void 0,onClick:()=>s(),children:a.jsxs("span",{className:"vis-hidden",children:[O,", ",I?"hide details":"details"]})}),a.jsxs("div",{className:"ap-account-head",children:[e.active?a.jsx("span",{className:"ap-live",title:`Active account · slot ${e.num}`,children:a.jsxs("span",{className:"vis-hidden",children:["Active account, slot ",e.num,":"]})}):a.jsx("span",{className:"ap-num",children:e.num}),e.alias&&a.jsx("span",{className:"ap-alias",title:e.alias,children:e.alias}),a.jsx("span",{className:"ap-email",id:`ap-email-${e.num}`,title:e.email??void 0,children:e.email}),e.disabled&&a.jsx("span",{className:"ap-held",children:"held out"}),!e.active&&!e.disabled&&!(T!=null&&T.blocksSwitch)&&a.jsx("button",{type:"button",className:"ap-switch",...i(`switch-${e.num}`),onClick:()=>c(e.num,O),"aria-label":`Switch to ${O}`,title:`Switch to ${e.alias??e.email}`,children:o===`switch-${e.num}`?"…":"Switch"}),a.jsx("button",{type:"button",id:`ap-more-${e.num}`,className:"ap-more","aria-label":`More actions for ${e.email??e.alias??`account ${e.num}`}`,"aria-haspopup":"menu","aria-expanded":d,"aria-controls":d?`ap-menu-${e.num}`:void 0,title:"More actions",onClick:()=>d?f():h(e.num),onKeyDown:A=>{A.key!=="ArrowDown"&&A.key!=="ArrowUp"||(A.preventDefault(),h(e.num,A.key==="ArrowUp"?"last":"first"))},children:a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"currentColor","aria-hidden":!0,children:[a.jsx("circle",{cx:"2.8",cy:"7",r:"1.15"}),a.jsx("circle",{cx:"7",cy:"7",r:"1.15"}),a.jsx("circle",{cx:"11.2",cy:"7",r:"1.15"})]})})]}),p&&a.jsxs("div",{className:"ap-failure ap-row-failure",role:"alert",children:[a.jsx("span",{className:"ap-failure-text",title:p.raw||void 0,children:p.text}),a.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>g(),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),e.active&&w&&a.jsx("p",{className:"ap-switched",children:"Now active. New sessions start on it; ones already running pick it up on their next message, up to about 30 seconds later on macOS."}),k&&(()=>{const A=(j==null?void 0:j.alias)??(j==null?void 0:j.email)??"the account that was there";return a.jsxs("p",{className:"ap-note ap-swap-note",title:`Slot ${k.at} was taken, so the two accounts traded places: ${A} now holds slot ${k.displaced}.`,children:["swapped with slot ",k.displaced]})})(),T&&a.jsxs("div",{className:"ap-issue-line",children:[a.jsxs("button",{type:"button",id:`ap-issue-${e.num}`,className:"ap-issue","data-tone":T.tone,"aria-haspopup":"dialog","aria-expanded":v,"aria-controls":v?"ap-issue-pop":void 0,onClick:()=>b(e.num,`ap-issue-${e.num}`),children:[T.tone==="warn"&&a.jsx(i1,{}),a.jsx("span",{className:"ap-issue-text",children:T.text})]}),!I&&a.jsx("span",{className:"ap-issue-age",title:"When claude-swap last read this account's usage",children:F??"never collected"})]}),!I&&!(T!=null&&T.blocksSwitch)&&a.jsxs("p",{className:"ap-quota",id:`ap-quota-${e.num}`,children:[L.length?L.map(A=>a.jsxs("span",{className:"ap-q","data-sort-key":A.id===($==null?void 0:$.id)?"":void 0,children:[a.jsx("span",{className:"ap-q-label",children:A.label})," ",Fc(A,t)?a.jsx("span",{className:"ap-q-pct",title:`${A.label} has reset since this reading`,children:"reset"}):a.jsxs("span",{className:"ap-q-pct","data-level":P?void 0:bZ(A.pct),children:[Math.round(A.pct),"%"]})]},A.id)):a.jsx("span",{className:"ap-q-label",children:"no usage recorded yet"}),e.stale&&!T&&a.jsx("span",{className:"ap-q-age","data-never":F?void 0:"",title:"When claude-swap last read this account's usage",children:F??"never collected"})]}),I&&a.jsxs("div",{className:"ap-detail",id:`ap-detail-${e.num}`,children:[a.jsx("div",{className:"ap-lanes",children:e.lanes.length?e.lanes.map(A=>a.jsx(kZ,{lane:A,nowSec:t,readAt:e.fetchedAt,frozen:P,sortedBy:A.id===($==null?void 0:$.id)},A.id)):a.jsx("div",{className:"ap-hint",children:"No usage recorded yet."})}),a.jsx("div",{className:"ap-meta",children:e.fetchedAt?a.jsxs("span",{className:`ap-age${e.stale&&!T?" 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 ",_a(e.fetchedAt,t),T!=null&&T.blocksSwitch?"":XX(e.nextAt,t)]}):a.jsx("span",{className:"ap-age ap-stale",title:"claude-swap has not read this account yet",children:"never collected"})})]})]})}function NZ({data:e}){return a.jsx("div",{className:"ap-empty",children:e.reason==="cswap_installing"?a.jsxs(a.Fragment,{children:[a.jsx("span",{children:"Installing claude-swap…"}),a.jsx("span",{className:"ap-hint",children:"The deck is setting it up in the background, so there is nothing to do here. On a new machine this can take a few minutes; the panel fills in by itself when it is done."})]}):e.reason==="no_cswap"?a.jsxs(a.Fragment,{children:[a.jsx("span",{children:"claude-swap isn't installed."}),a.jsx("span",{className:"ap-hint",children:"This panel reads the account store claude-swap keeps — without it there is nothing to show. It is a separate tool, published on PyPI, so it does not come with this package."}),e.hint&&a.jsx("code",{className:"ap-cmd",children:e.hint}),a.jsxs("span",{className:"ap-hint",children:["Then add an account with the ",a.jsx("strong",{children:"+"})," button above."]})]}):e.reason==="cswap_refused"?a.jsxs(a.Fragment,{children:[a.jsx("span",{children:"claude-swap was installed, but not the version the deck asked for."}),a.jsxs("span",{className:"ap-hint",children:[e.version?`v${e.version} answered`:"A different version answered",e.want?` where ${e.want} was asked for`:"",", so the deck is not driving it. Install the version it asked for, or set AGENTS_DECK_CSWAP to a claude-swap you trust."]})]}):e.reason==="no_accounts"?a.jsxs(a.Fragment,{children:[a.jsx("span",{children:"No accounts added yet."}),a.jsxs("span",{className:"ap-hint",children:["claude-swap is installed but has nothing in its store. Use the ",a.jsx("strong",{children:"+"})," above to sign one in, or to paste one shared from another deck."]})]}):a.jsxs(a.Fragment,{children:[a.jsx("span",{children:"Couldn't read the account store."}),a.jsxs("span",{className:"ap-hint",children:["claude-swap is installed, but its store could not be read",e.reason?` (${e.reason})`:"","."]})]})})}function SZ({canShare:e,canReport:t,onAdd:n,onReport:r,onShareSet:s,onReload:o,pressProps:i,reloading:c,closeButton:d}){return a.jsxs("div",{className:"ap-header",children:[a.jsx("h2",{children:"Claude accounts"}),a.jsxs("div",{className:"ap-header-right",children:[a.jsx("button",{type:"button",className:"glyph-btn ap-add",onClick:()=>n(),"aria-label":"Add an account",title:"Sign in to another Claude account, or paste one shared from another deck",children:a.jsx("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":!0,children:a.jsx("path",{d:"M7 2.2v9.6M2.2 7h9.6"})})}),t&&a.jsx("button",{type:"button",className:"glyph-btn",onClick:()=>r(),"aria-label":"Account capacity","aria-haspopup":"dialog",title:"Account capacity — how many accounts are ready, and what the 5h and 7d windows have left",children:a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":!0,children:[a.jsx("path",{d:"M2.5 10.9A5.2 5.2 0 1 1 11.5 10.9"}),a.jsx("path",{d:"M7 8.3l2.1-2.1"})]})}),e&&a.jsx("button",{type:"button",className:"glyph-btn",onClick:()=>s(),"aria-label":"Share accounts with another deck",title:`Copy several accounts to another ${Lt} in one paste. The text carries a live login for each one — treat it as those passwords.`,children:a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("path",{d:"M3.3 10.7L10.7 3.3"}),a.jsx("path",{d:"M5.5 3.3h5.2v5.2"})]})}),a.jsx("button",{type:"button",className:"glyph-btn ap-refresh",onClick:()=>o(),...i("reload",c),"aria-label":"Reload accounts",title:"Reload from claude-swap",children:a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("path",{d:"M11.6 6.2A4.8 4.8 0 1 0 11 9.6"}),a.jsx("path",{d:"M11.9 2.6v3.7h-3.6"})]})}),d]})]})}function hn({children:e,narrow:t}){return a.jsx("svg",{className:t?"glyph glyph-narrow":"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:e})}const _Z=()=>a.jsxs(hn,{children:[a.jsx("path",{d:"M5.4 3.6h6.6M5.4 7h6.6M5.4 10.4h6.6"}),a.jsx("path",{d:"M2.2 3.6h.2M2.2 7h.2M2.2 10.4h.2"})]}),EZ=()=>a.jsxs(hn,{children:[a.jsx("circle",{cx:"7",cy:"4.6",r:"2.4"}),a.jsx("path",{d:"M2.4 12c0-2.3 2.1-3.7 4.6-3.7s4.6 1.4 4.6 3.7"})]}),CZ=()=>a.jsxs(hn,{narrow:!0,children:[a.jsx("path",{d:"M9.4 4.5C9 3.6 8.1 3.1 7 3.1c-1.4 0-2.4.8-2.4 1.9 0 1.2 1.2 1.6 2.4 2s2.4.8 2.4 2c0 1.1-1 1.9-2.4 1.9-1.1 0-2-.5-2.4-1.4"}),a.jsx("path",{d:"M7 1.6v1.5M7 10.9v1.5"})]}),TZ=()=>a.jsxs(hn,{children:[a.jsx("line",{x1:"3",y1:"11.5",x2:"3",y2:"7"}),a.jsx("line",{x1:"7",y1:"11.5",x2:"7",y2:"3"}),a.jsx("line",{x1:"11",y1:"11.5",x2:"11",y2:"8.5"})]}),RZ=()=>a.jsxs(hn,{children:[a.jsx("rect",{x:"3.6",y:"3.6",width:"6.8",height:"6.8",rx:"1.2"}),a.jsx("path",{d:"M5.8 1.4v2.2M8.2 1.4v2.2M5.8 10.4v2.2M8.2 10.4v2.2M1.4 5.8h2.2M1.4 8.2h2.2M10.4 5.8h2.2M10.4 8.2h2.2"})]}),AZ=()=>a.jsxs(hn,{children:[a.jsx("circle",{cx:"7",cy:"7",r:"5"}),a.jsx("path",{d:"M7 2v5l3.5-3.5"}),a.jsx("circle",{cx:"4.5",cy:"8.5",r:".7"})]}),MZ=({watching:e})=>a.jsxs(hn,{children:[a.jsx("path",{d:"M0.9 7s2.2-4 6.1-4 6.1 4 6.1 4-2.2 4-6.1 4S0.9 7 0.9 7Z"}),e?a.jsx("circle",{cx:"7",cy:"7",r:"1.8",fill:"currentColor",stroke:"none"}):a.jsx("line",{x1:"2.4",y1:"11.6",x2:"11.6",y2:"2.4"})]}),$Z=()=>a.jsxs(hn,{children:[a.jsx("path",{d:"M5.4 2.9L5.6 1.1L8.4 1.1L8.6 2.9L9.8 3.6L11.5 2.8L12.8 5.2L11.3 6.3L11.3 7.7L12.8 8.8L11.5 11.2L9.8 10.4L8.6 11.1L8.4 12.9L5.6 12.9L5.4 11.1L4.2 10.4L2.5 11.2L1.2 8.8L2.7 7.7L2.7 6.3L1.2 5.2L2.5 2.8L4.2 3.6Z"}),a.jsx("circle",{cx:"7",cy:"7",r:"1.9"})]}),LZ=()=>a.jsxs(hn,{children:[a.jsx("path",{d:"M2.2 3.3h9.6v5.3H6.1L3.5 10.8V8.6H2.2Z"}),a.jsx("path",{d:"M7 4.9v1.7"}),a.jsx("path",{d:"M7 7.7v.05"})]}),OZ=()=>a.jsx(hn,{children:a.jsx("path",{d:"M4.6 2.9v8.2L11.1 7Z"})}),IZ=()=>a.jsxs(hn,{children:[a.jsx("path",{d:"M11.6 6.2A4.8 4.8 0 1 0 11 9.6"}),a.jsx("path",{d:"M11.9 2.6v3.7h-3.6"})]}),PZ=()=>a.jsxs(hn,{children:[a.jsx("path",{d:"M7 1.6v5"}),a.jsx("path",{d:"M4.2 3.6a4.8 4.8 0 1 0 5.6 0"})]}),DZ=()=>a.jsx(hn,{children:a.jsx("path",{d:"M2 5h10v7H2z M4 5l6-3 M4 8h3 M9 8h1 M4 10h1 M8 10h2"})}),FZ=()=>a.jsx(hn,{children:a.jsx("path",{d:"M1.4 7.4h2.5l1.7-4 2.8 7.2 1.6-3.2h2.6"})}),BZ=()=>a.jsxs(hn,{children:[a.jsx("circle",{cx:"7",cy:"7",r:"5"}),a.jsx("path",{d:"M7 3.8V7l2.2 1.4"})]});function HE(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`}function qZ(e,t,n=!1){const r=new Date(t*1e3),s=Array.from({length:7},(c,d)=>{const h=new Date(r.getFullYear(),r.getMonth(),r.getDate()+d);return{key:HE(h),date:h,entries:[],scheduled:0,outdated:0}}),o=new Map(s.map(c=>[c.key,c])),i=[];for(const c of e){const d=c.lanes.find(N=>N.id==="seven_day"),h=d==null?void 0:d.resetAt,f=h!=null&&h>0&&Number.isFinite(h)&&Number.isFinite(new Date(h*1e3).getTime())?h:null,p=I0(c,"seven_day",t),g=Co(c,t),w=_f(c.fetchedAt),k=w==null,j=n||k||c.stale||c.staleCopy===!0||c.stopped===!0||(g==null?void 0:g.blocksSwitch)===!0||t*1e3-w>M3,v=n?"Last saved reading":g!=null&&g.blocksSwitch||c.staleCopy||c.stopped?(g==null?void 0:g.text)??"Not collecting":k?"Never read":j?`${c.stale?"Marked stale · ":""}Read ${_a(w,t)}`:null,b={key:_r(c),name:$3(c),active:c.active,heldOut:c.disabled,at:f,used:p.counted?p.pct:p.last,stale:j,note:v};if(f==null)i.push({...b,reason:"unknown"});else if(f<=t)i.push({...b,reason:"passed"});else{const N=o.get(HE(new Date(f*1e3)));N?(N.entries.push(b),j?N.outdated++:N.scheduled++):i.push({...b,reason:"outside"})}}for(const c of s)c.entries.sort((d,h)=>d.at-h.at);return{days:s,unscheduled:i}}const eh=e=>e.toLocaleDateString(void 0,{weekday:"short"}),Mh=e=>e.toLocaleDateString(void 0,{month:"short",day:"numeric"}),wc=e=>e.toLocaleDateString(void 0,{weekday:"long",month:"long",day:"numeric",year:"numeric"}),h1=(e,t)=>e-t<60?"less than 1m":Qc(e,t);function Ef({at:e}){const t=new Date(e*1e3);return a.jsx("time",{className:"ap-reset-time",dateTime:t.toISOString(),title:`${t.toLocaleString(void 0,{timeZoneName:"shortOffset"})} · ${t.toISOString()} (UTC)`,children:t.toLocaleTimeString(void 0,{hour:"numeric",minute:"2-digit"})})}function th({entry:e}){return a.jsxs("span",{className:"ap-reset-name",children:[a.jsx("span",{children:e.name}),e.active&&a.jsx("span",{className:"ap-report-current",children:"Current"}),e.heldOut&&a.jsx("span",{className:"ap-report-tag",children:"held out"})]})}function I3({entry:e,row:t,nowSec:n,withReading:r=!1,older:s=!1,context:o}){return a.jsxs("details",{className:"ap-reset-account",children:[a.jsxs("summary",{children:[o?a.jsxs("span",{className:"ap-reset-summary-other",children:[a.jsx(th,{entry:e}),o]}):r?a.jsxs("span",{className:"ap-reset-summary-content",children:[a.jsx(th,{entry:e}),a.jsx(P3,{entry:e,older:s})]}):a.jsx(th,{entry:e}),a.jsx("span",{className:"vis-hidden",children:" · Account details"})]}),a.jsxs("div",{className:"ap-reset-account-body",children:[t&&["five_hour","seven_day"].map(i=>{const c=t.cells[i],d=c.counted?c.pct:c.last,h=t.resets[i];return a.jsxs("p",{children:[a.jsx("strong",{children:i==="five_hour"?"5-hour":"7-day"}),a.jsx("span",{children:d==null?"No usage reading":`${e.stale||!c.counted?"Last read: ":""}${Ea(d)}% used`}),a.jsx("span",{children:h==null?"Reset time unknown":h<=n?"Reported time passed · awaiting a new reading":a.jsxs(a.Fragment,{children:[e.stale?"Last reported reset":`Reset in ${h1(h,n)}`," · ",a.jsx(Ef,{at:h})]})})]},i)}),a.jsx("p",{children:e.heldOut?"Excluded from automatic rotation.":"A weekly reset does not remove a separate 5-hour limit."})]})]})}function P3({entry:e,past:t=!1,older:n=!1}){return a.jsxs("span",{className:"ap-reset-reading","data-level":e.stale||t?"older":e.used!=null&&e.used>=70?"limited":void 0,children:[a.jsx("span",{className:"ap-reset-usage",children:e.used==null?"Usage unavailable":`${e.stale||t?"Last read: ":""}${Ea(e.used)}% used`}),e.used!=null&&!e.stale&&!t&&a.jsx("span",{className:"ap-reset-meter","data-level":e.used>=90?"hi":e.used>=70?"mid":void 0,"aria-hidden":"true",children:a.jsx("span",{style:{"--reset-used":Math.min(100,Math.max(0,e.used))/100}})}),e.stale&&a.jsxs("span",{className:"ap-reset-old",children:[!n&&"Needs a fresh reading · ",e.note]})]})}function UZ({entry:e,row:t,nowSec:n}){const r=e.reason==="unknown"?"Reset time unknown":e.reason==="passed"?"Reported time passed · awaiting a new reading":"Beyond these seven days";return a.jsx("li",{className:"ap-reset-unplaced-row",children:a.jsx(I3,{entry:e,row:t,nowSec:n,context:a.jsxs(a.Fragment,{children:[a.jsxs("span",{className:"ap-reset-unplaced-detail",children:[a.jsx("span",{children:r}),e.at!=null&&a.jsxs("span",{children:[Mh(new Date(e.at*1e3))," · ",a.jsx(Ef,{at:e.at})]})]}),a.jsx(P3,{entry:e,past:e.reason==="passed"})]})})})}function WE({days:e,rows:t,nowSec:n,outdated:r=!1}){return a.jsx("div",{className:"ap-reset-agenda",children:e.map(s=>{const o=s.entries.filter(i=>i.stale===r);return o.length?a.jsxs("section",{className:"ap-reset-day","aria-label":wc(s.date),children:[a.jsxs("h4",{className:"vis-hidden",children:[wc(s.date)," · ",o.length," ",o.length===1?"account":"accounts"]}),a.jsx("ul",{children:Array.from(new Set(o.map(i=>i.at))).map((i,c)=>a.jsxs("li",{className:"ap-reset-event",children:[a.jsxs("div",{className:"ap-reset-when","data-outdated":r?"":void 0,children:[r&&a.jsx("span",{className:"ap-reset-last-reported",children:"Last reported"}),c===0&&a.jsxs("time",{className:"ap-reset-day-label",dateTime:s.key,children:[eh(s.date)," · ",Mh(s.date)]}),a.jsx(Ef,{at:i}),!r&&a.jsxs("span",{children:["in ",h1(i,n)]})]}),a.jsx("ul",{children:o.filter(d=>d.at===i).map(d=>a.jsx("li",{className:"ap-reset-entry","data-outdated":d.stale?"":void 0,children:a.jsx(I3,{entry:d,row:t.get(d.key),nowSec:n,withReading:!0,older:r})},d.key))})]},i))})]},s.key):null})})}function HZ({accounts:e,nowSec:t,held:n,selectedDate:r=null,onSelect:s=()=>{},scope:o="upcoming",onScope:i=()=>{}}){const{days:c,unscheduled:d}=qZ(e,t,n!=null),h=c.find(I=>I.key===r)??null,f=h?[h]:c,p=c.reduce((I,O)=>I+O.scheduled,0),g=f.reduce((I,O)=>I+O.outdated,0),w=c.reduce((I,O)=>I+O.outdated,0),k=h?h.scheduled:p,j=c.flatMap(I=>I.entries).find(I=>!I.stale),v=j?c.flatMap(I=>I.entries).filter(I=>!I.stale&&I.at===j.at):[],b=y.useRef(null),N=y.useRef(null),S=y.useRef(null);y.useEffect(()=>{var O,U;const I=S.current;I&&!I.isConnected&&document.activeElement===document.body&&((U=(O=N.current)==null?void 0:O.querySelector('.ap-reset-coverage-link[aria-pressed="true"]'))==null||U.focus({preventScroll:!0}))});const E=()=>{b.current&&(b.current.scrollTop=0)},C=I=>{E(),s(null),i(I)},$=Intl.DateTimeFormat().resolvedOptions().timeZone,T=new Map(d1(e,t).rows.map(I=>[I.key,I]));return a.jsxs("div",{ref:N,onFocusCapture:I=>{S.current=I.target},className:"ap-proj-body ap-report-body ap-reset-body",role:"region","aria-label":"Weekly reset calendar",children:[n&&a.jsx("p",{className:"ap-report-held",children:n}),a.jsxs("div",{className:"ap-reset-overview",children:[a.jsxs("div",{className:"ap-reset-command",children:[a.jsx("section",{className:"ap-reset-next","aria-label":"Next weekly reset",children:j?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"ap-reset-next-identity",children:[a.jsxs("h3",{children:[a.jsx(BZ,{}),"Next reported reset ",a.jsx("span",{className:"ap-reset-global",children:"· all days"})]}),v.length>1?a.jsxs("span",{className:"ap-reset-name",children:[v.length," accounts"]}):a.jsxs("details",{className:"ap-reset-next-account",children:[a.jsxs("summary",{title:j.name,children:[a.jsx(th,{entry:j}),a.jsx("span",{className:"vis-hidden",children:" · Full account name"})]}),a.jsx("p",{className:"ap-reset-full-name",children:j.name})]}),a.jsxs("p",{children:[eh(new Date(j.at*1e3)),", ",Mh(new Date(j.at*1e3))," · ",a.jsx(Ef,{at:j.at})]}),a.jsxs("p",{className:"ap-reset-next-note",children:["Reported time · recent reading",v.length>1?"s":j.used!=null?` · ${Ea(j.used)}% weekly used`:""]})]}),a.jsxs("p",{className:"ap-reset-countdown",children:[a.jsx("strong",{children:h1(j.at,t)}),a.jsxs("span",{children:[a.jsx("span",{className:"vis-hidden",children:"until "}),"reported reset"]})]})]}):a.jsxs("div",{className:"ap-reset-next-identity",children:[a.jsx("h3",{children:"No upcoming weekly resets"}),a.jsx("p",{children:w?"Some schedules need a fresh reading. Check the last reported times below.":"No reported weekly resets in these seven days. Unknown and elapsed times remain below."})]})}),a.jsxs("div",{className:"ap-reset-coverage",role:"group","aria-label":"Schedule data",children:[a.jsxs("button",{type:"button",className:"ap-reset-coverage-link","data-scope":"upcoming","aria-pressed":o==="upcoming",onClick:()=>C("upcoming"),children:[a.jsx("b",{children:p}),a.jsxs("span",{children:["Upcoming",a.jsx("span",{children:"Recent readings"})]})]}),a.jsxs("button",{type:"button",className:"ap-reset-coverage-link",title:"Schedules in these seven days that need a fresh reading","data-scope":"older","data-attention":w>0?"":void 0,"aria-pressed":o==="older",onClick:()=>C("older"),children:[a.jsx("b",{children:w}),a.jsxs("span",{children:["Needs fresh data",a.jsx("span",{children:"This week · excluded"})]})]}),a.jsxs("button",{type:"button",className:"ap-reset-coverage-link","data-scope":"other","aria-pressed":o==="other",onClick:()=>C("other"),children:[a.jsx("b",{children:d.length}),a.jsxs("span",{children:["Other reset times",a.jsx("span",{children:"Unknown, elapsed or later"})]})]})]})]}),a.jsxs("section",{className:"ap-reset-navigation","aria-label":"Choose a calendar day",children:[a.jsxs("div",{className:"ap-reset-intro",children:[a.jsxs("h3",{children:["Next 7 days ",a.jsxs("span",{children:[p," weekly ",p===1?"reset":"resets"]})]}),a.jsx("p",{children:$})]}),a.jsx("ol",{className:"ap-reset-week",role:"list","aria-label":"Seven-day reset counts",children:c.map((I,O)=>a.jsx("li",{"data-today":O===0?"":void 0,children:a.jsxs("button",{type:"button",className:"ap-reset-day-button","aria-current":O===0?"date":void 0,"data-active":I.scheduled>0?"":void 0,"aria-pressed":(h==null?void 0:h.key)===I.key,"aria-label":`${wc(I.date)}: ${I.scheduled} scheduled resets${I.outdated?`, ${I.outdated} readings need updating`:""}`,onClick:()=>{E(),i("upcoming"),s((h==null?void 0:h.key)===I.key?null:I.key)},children:[a.jsxs("time",{dateTime:I.key,title:wc(I.date),children:[a.jsx("span",{className:"ap-reset-weekday",children:O===0?"Today":eh(I.date)}),a.jsx("span",{className:"ap-reset-date",children:I.date.getDate()})]}),a.jsxs("span",{className:"ap-reset-count",children:[a.jsx("b",{children:I.scheduled||"—"}),a.jsxs("span",{children:[" ",I.scheduled===1?"reset":"resets"]})]})]})},I.key))})]})]}),a.jsxs("div",{ref:b,className:"ap-reset-results",children:[a.jsxs("section",{className:"ap-reset-scheduled",hidden:o!=="upcoming","aria-label":"Scheduled weekly resets",children:[a.jsxs("div",{className:"ap-reset-list-head",children:[a.jsxs("h3",{children:[h?`${eh(h.date)}, ${Mh(h.date)}`:"All upcoming resets"," ",a.jsx("span",{children:k})]}),a.jsx("button",{className:"btn",type:"button","aria-pressed":!h,onClick:()=>{E(),s(null)},children:"All days"})]}),a.jsx("p",{className:"ap-reset-hint",role:"status",children:h?`Showing only ${wc(h.date)}.`:"All days · select a date to narrow the agenda."}),k>0?a.jsx(WE,{days:f,rows:T,nowSec:t}):a.jsx("p",{className:"ap-reset-empty",children:h?"No upcoming resets on this day. Choose another date or All days.":"The schedule updates with new account readings. No weekly recurrence is assumed."})]}),a.jsxs("section",{className:"ap-reset-disclosure",hidden:o!=="older","aria-label":"Accounts needing fresh readings",children:[a.jsxs("h3",{children:["Needs a fresh reading ",a.jsxs("span",{children:[g," ",g===1?"account":"accounts"," · excluded from counts"]})]}),a.jsx("p",{className:"ap-reset-explain",children:"These weekly schedules need a fresh reading. Other reset times may also contain stale readings. Last reported times and usage remain visible until updated."}),g>0?a.jsx(WE,{days:f,rows:T,nowSec:t,outdated:!0}):a.jsx("p",{className:"ap-reset-empty",children:"No older schedules in these seven days. Unknown or elapsed times are listed in Other reset times."})]}),a.jsxs("section",{className:"ap-reset-disclosure ap-reset-unplaced",hidden:o!=="other","aria-label":"Other reset times",children:[a.jsxs("h3",{children:["Other reset times ",a.jsxs("span",{children:[d.length," ",d.length===1?"account":"accounts"," · unknown, elapsed or later"]})]}),d.length>0?a.jsx("ul",{children:d.map(I=>a.jsx(UZ,{entry:I,row:T.get(I.key),nowSec:t},I.key))}):a.jsx("p",{className:"ap-reset-empty",children:"All reported reset times fall within the upcoming week."})]}),a.jsxs("details",{className:"ap-reset-about",children:[a.jsx("summary",{children:"How to read this schedule"}),a.jsxs("p",{className:"ap-reset-explain",children:["Counts are reported weekly account resets, not token amounts. Zero means no upcoming reset on that day, not zero usage. Held-out accounts still appear in the schedule. A timestamp passing does not confirm renewed capacity. Older readings are excluded from upcoming counts. Times use ",$,"; a separate 5-hour limit may still apply. Usage bars show reported capacity used. The warning tint at 70% or more indicates lower remaining capacity, not an account error."]})]})]})]})}function D3(e){return e>=90?"hi":e>=70?"mid":void 0}const F3=(e,t,n)=>`${e} ${e===1?t:n}`;function zE(e){const t=e.more>0?`, and ${F3(e.more,"more account","more accounts")} in the same minute`:"";return`First: ${e.name} (${Ea(e.pct)}% used)${t}`}function WZ({w:e,nowSec:t}){const n=`ap-report-${e.id}`,r=e.total-e.included,s=r>0&&a.jsxs("p",{className:"ap-report-basis",children:[r," never read"]}),{used:o,available:i}=xZ(e.used??0),c=Math.round(uo(i,{countIn:!0}));if(e.used==null)return a.jsxs("section",{className:"ap-report-sum","aria-labelledby":n,children:[a.jsxs("h3",{className:"ap-report-win",id:n,children:[e.long," window"]}),a.jsxs("p",{className:"ap-report-none",children:["No account has a ",e.long," reading yet."]}),s]});const d=e.nextReset?Qc(e.nextReset.at,t):null;return a.jsxs("section",{className:"ap-report-sum","aria-labelledby":n,children:[a.jsxs("h3",{className:"ap-report-win",id:n,children:[e.long," window"]}),a.jsxs("p",{className:"ap-report-left",children:[a.jsxs("b",{children:[c,"%"]})," average remaining"]}),a.jsx("div",{className:"ap-report-meter","data-level":D3(o),"aria-hidden":!0,children:a.jsx("i",{style:{"--left":i/100}})}),d&&e.nextReset&&a.jsxs("p",{className:"ap-report-reset",title:zE(e.nextReset),children:[a.jsxs("span",{children:["Next reported reset in ",a.jsx("span",{className:"ap-report-num",children:d})]}),a.jsx("span",{"aria-hidden":!0,children:"·"}),a.jsx("span",{className:"ap-report-who",children:e.nextReset.name}),e.nextReset.more>0&&a.jsxs("span",{className:"ap-report-more",children:["+",e.nextReset.more]}),a.jsxs("span",{className:"vis-hidden",children:[". ",zE(e.nextReset)]})]}),s]})}function zZ({cell:e,label:t}){if(!e.counted){const n=e.estimate==null?", not counted":", last reading, counted as is";return a.jsxs("td",{className:"ap-report-cell","data-uncounted":"",title:e.reset??void 0,children:[a.jsxs("span",{className:"ap-report-mobile-label","aria-hidden":"true",children:[t," used"]}),a.jsx("span",{className:"ap-report-pct",children:e.last==null?a.jsxs(a.Fragment,{children:[a.jsx("span",{"aria-hidden":!0,children:"—"}),a.jsx("span",{className:"vis-hidden",children:"no reading"})]}):`${Ea(e.last)}%`}),a.jsx("span",{className:"vis-hidden",children:e.reset?`. ${e.reset}. Awaiting a fresh reading${n}.`:n})]})}return a.jsxs("td",{className:"ap-report-cell",children:[a.jsxs("span",{className:"ap-report-mobile-label","aria-hidden":"true",children:[t," used"]}),a.jsxs("span",{className:"ap-report-pct","data-level":D3(e.pct),children:[Ea(e.pct),"%"]})]})}function VZ({at:e,nowSec:t,label:n}){if(e==null)return a.jsxs("td",{className:"ap-report-reset-cell",children:[a.jsxs("span",{className:"ap-report-mobile-label","aria-hidden":"true",children:[n," reset"]}),a.jsx("span",{"aria-hidden":!0,children:"—"}),a.jsx("span",{className:"vis-hidden",children:"No reset time"})]});const r=new Date(e*1e3),s=Qc(e,t);return a.jsxs("td",{className:"ap-report-reset-cell",title:`Recorded reset: ${r.toLocaleString()}`,children:[a.jsxs("span",{className:"ap-report-mobile-label","aria-hidden":"true",children:[n," reset"]}),a.jsxs("time",{dateTime:r.toISOString(),children:[a.jsx("span",{className:"vis-hidden",children:s?"reported reset in ":"reported reset "}),s??"due"]}),!s&&a.jsx("span",{className:"ap-report-state-note",children:"Awaiting read"}),a.jsxs("span",{className:"vis-hidden",children:[" · Recorded reset: ",r.toLocaleString()]})]})}const GZ={ready:"Ready",limited:"Limited",exhausted:"Exhausted",stale:"Stale"};function KZ({row:e}){return a.jsxs("td",{className:"ap-report-state","data-status":e.status,children:[a.jsx("span",{className:"ap-report-mobile-label","aria-hidden":"true",children:"Status"}),a.jsxs("span",{className:"ap-report-state-word",children:[a.jsx("i",{"aria-hidden":!0}),GZ[e.status]]}),Object.values(e.cells).some(t=>!t.counted&&t.reset)&&a.jsx("span",{className:"ap-report-state-note",children:"Awaiting read"})]})}function YZ({row:e,nowSec:t}){const n=pZ(e,t);return a.jsxs("td",{className:"ap-report-upd","data-old":n.old?"":void 0,children:[a.jsx("span",{className:"ap-report-mobile-label","aria-hidden":"true",children:"Updated"}),n.text]})}function XZ(){return a.jsxs("svg",{className:"ap-report-how-mark",viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":!0,focusable:"false",children:[a.jsx("circle",{cx:"8",cy:"8",r:"6.5",fill:"none",stroke:"currentColor",strokeWidth:"1.4"}),a.jsx("path",{d:"M8 7.2v4.1M8 4.8v.1",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})]})}function ZZ({accounts:e,nowSec:t,held:n,sort:r=null,onSort:s=()=>{}}){const o=d1(e,t),i=o.rows.length,c=Math.round(uo(o.roomInBoth,{countIn:!0}));return a.jsxs("div",{className:"ap-proj-body ap-report-body",role:"region","aria-label":"Report",children:[n&&a.jsx("p",{className:"ap-report-held",children:n}),a.jsxs("div",{className:"ap-report-overview",children:[a.jsxs("p",{className:"ap-report-lead",children:[a.jsx("b",{children:c})," of ",F3(i,"Claude account","Claude accounts")," ready"]}),a.jsxs("p",{className:"ap-report-confidence",children:["Based on last readings",o.rows.some(d=>Object.values(d.cells).some(h=>!h.counted&&h.reset))&&" · elapsed reset times need fresh readings",o.rows.some(d=>d.heldOut)&&` · ${o.rows.filter(d=>d.heldOut).length} held out of rotation`]})]}),a.jsx("div",{className:"ap-report-sums",children:o.windows.map(d=>a.jsx(WZ,{w:d,nowSec:t},d.id))}),a.jsx("div",{className:"ap-report-table-scroll",role:"region","aria-label":"Account capacity table",children:a.jsxs("table",{className:"ap-report-table",children:[a.jsx("caption",{className:"vis-hidden",children:"Each account's use and reset of each window, and what it can do now"}),a.jsxs("colgroup",{children:[a.jsx("col",{}),bo.map(d=>a.jsxs(y.Fragment,{children:[a.jsx("col",{className:"ap-report-col-win"}),a.jsx("col",{className:"ap-report-col-reset"})]},d.id)),a.jsx("col",{className:"ap-report-col-state"}),a.jsx("col",{className:"ap-report-col-upd"})]}),a.jsx("thead",{children:a.jsxs("tr",{children:[a.jsx(ki,{col:"account",label:"Account",sort:r,next:Ql,onSort:s}),bo.map(d=>a.jsxs(y.Fragment,{children:[a.jsx(ki,{col:d.id,label:`${d.label} used`,sort:r,next:Ql,onSort:s}),a.jsx(ki,{col:`${d.id}_reset`,label:`${d.label} reset`,sort:r,next:Ql,onSort:s})]},d.id)),a.jsx(ki,{col:"status",label:"Status",sort:r,next:Ql,onSort:s}),a.jsx(ki,{col:"updated",label:"Updated",className:"ap-report-upd-h",sort:r,next:Ql,onSort:s})]})}),a.jsx("tbody",{children:o.rows.map((d,h)=>a.jsxs("tr",{"data-active":d.active?"":void 0,style:{"--row":h},children:[a.jsx("th",{scope:"row",className:"ap-report-acct",children:a.jsxs("span",{className:"ap-report-acct-in",children:[a.jsx("span",{className:"ap-report-name",title:d.name,children:d.name}),d.active&&a.jsx("span",{className:"ap-report-current",children:"Current"}),d.heldOut&&a.jsx("span",{className:"ap-report-tag",children:"held out"})]})}),bo.map(f=>a.jsxs(y.Fragment,{children:[a.jsx(zZ,{cell:d.cells[f.id],label:f.label}),a.jsx(VZ,{at:d.resets[f.id],nowSec:t,label:f.label})]},f.id)),a.jsx(KZ,{row:d}),a.jsx(YZ,{row:d,nowSec:t})]},d.num))})]})}),a.jsxs("details",{className:"ap-report-how",children:[a.jsxs("summary",{children:[a.jsx(XZ,{}),"How usage is calculated"]}),a.jsxs("div",{className:"ap-report-how-body",children:[a.jsxs("p",{children:["Every account here, at its last reading: ",a.jsx("b",{children:"used"})," is their average, and ",a.jsx("b",{children:"remaining"})," is the rest, not pooled quota. A passed reported reset time does not confirm renewed capacity. Its last usage reading remains until refreshed."]}),a.jsxs("p",{children:[a.jsx("b",{children:"Ready"})," has room in both windows. ",a.jsx("b",{children:"Limited"})," is at the limit of one, and ",a.jsx("b",{children:"Exhausted"})," of both. ",a.jsx("b",{children:"Stale"})," was never read, or is signed out. Ready may be based on an older reading whose reset time has passed; held-out accounts remain included, but are excluded from automatic rotation."]})]})]})]})}function JZ({accounts:e,order:t,failed:n,nowSec:r,onClose:s}){const o=y.useRef(null),i=ot(s,{focusRef:o}),c=dt(s),[d,h]=y.useState("accounts"),[f,p]=y.useState("upcoming"),[g,w]=y.useState(null),[k,j]=y.useState(e??[]);y.useEffect(()=>{e!=null&&j(e)},[e]);const v=vZ(n,e==null,k.length>0),[b,N]=y.useState(null),S=L0(k,(b==null?void 0:b.order)??t),E=C=>{const $=d1(L0(k,t),r).rows;N({sort:C,order:wZ($,C).map(T=>T.key)})};return yt.createPortal(a.jsx("div",{className:"modal-backdrop",...c,role:"presentation",children:a.jsxs("div",{ref:i,className:"modal ap-report-modal","data-view":d,onClick:C=>C.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ap-report-title",children:[a.jsxs("header",{className:"ap-proj-head",children:[a.jsx("div",{className:"ap-proj-titlewrap",children:a.jsx("h2",{className:"ap-proj-title",id:"ap-report-title",children:"Account capacity"})}),a.jsxs("div",{className:"ap-report-views",role:"group","aria-label":"Capacity view",children:[a.jsx("button",{type:"button",className:"ap-report-view","aria-pressed":d==="accounts",onClick:()=>h("accounts"),children:"Accounts"}),a.jsx("button",{type:"button",className:"ap-report-view","aria-pressed":d==="calendar",onClick:()=>h("calendar"),children:"Reset calendar"})]}),a.jsx("button",{ref:o,type:"button",className:"glyph-btn ap-proj-close",onClick:s,"aria-label":"Close",children:"×"})]}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:v??""}),d==="accounts"?a.jsx(ZZ,{accounts:S,nowSec:r,held:v,sort:(b==null?void 0:b.sort)??null,onSort:E}):a.jsx(HZ,{accounts:S,nowSec:r,held:v,selectedDate:g,onSelect:w,scope:f,onScope:p})]})}),document.body)}const dg=[70,80,85,90,95],B3="custom",ji=50,Ni=99,QZ=`A whole percent from ${ji} to ${Ni}.`;function eJ(e){const t=Number(e);return[...Number.isFinite(t)&&t>0&&!dg.includes(t)?[...dg,t]:dg].sort((r,s)=>r-s)}function tJ(e){const t=e.trim().replace(/\s*%$/,"");if(t==="")return{ok:!1,reason:"empty",message:`Enter a number from ${ji} to ${Ni}.`};if(!/^\d+(\.\d*)?$|^\.\d+$/.test(t))return{ok:!1,reason:"not_a_number",message:`Enter a number from ${ji} to ${Ni}.`};const n=Number(t);return Number.isInteger(n)?n<ji?{ok:!1,reason:"too_low",message:`The lowest is ${ji}%.`}:n>Ni?{ok:!1,reason:"too_high",message:`The highest is ${Ni}%.`}:{ok:!0,value:String(n)}:{ok:!1,reason:"not_whole",message:`Use a whole number from ${ji} to ${Ni}.`}}const P0={pick:null,custom:null,refusal:null};function nJ(e,t){switch(t.kind){case"pick":return t.pick===B3?{...e,custom:{from:e.pick},refusal:null}:{pick:t.pick,custom:null,refusal:null};case"type":return{...e,pick:t.text,refusal:null};case"cancel":return e.custom?{pick:e.custom.from,custom:null,refusal:null}:e;case"refuse":return{...e,refusal:t.message};case"settle":return P0;case"leave":return e.custom&&(e.pick??t.stored)===t.stored?P0:e}}async function rJ(e,t,n){if(!t.sends)return{kind:"unchanged"};const r=tJ(e);if(!r.ok)return{kind:"refused",message:r.message};const s=await n({action:"setting",key:"autoswitch.threshold",value:r.value},"threshold");return{kind:"sent",ok:(s==null?void 0:s.ok)===!0}}function sJ({auto:e,threshold:t,thresholdPick:n,thresholdCtl:r,thresholdSaved:s,thresholdRef:o,thresholdSaveRef:i,thresholdCustom:c,thresholdRefusal:d,thresholdFieldRef:h,proposeThreshold:f,typeThreshold:p,cancelThreshold:g,leaveThreshold:w,doThreshold:k,pressProps:j,post:v,load:b}){const N=y.useId();return a.jsxs("div",{className:"ap-policy-block",children:[a.jsxs("div",{className:"ap-policy",onKeyDown:c?g:void 0,children:[a.jsx("h3",{className:"ap-auto-title",children:"Auto-switch"}),c?a.jsx("form",{className:"ap-threshold-form",noValidate:!0,onSubmit:S=>{S.preventDefault(),k(n,r)},children:a.jsxs("span",{className:"ap-threshold-field",title:"Switch once the active account passes this much of its limit",children:[a.jsx("input",{ref:h,className:"ap-manage-input ap-threshold-input",type:"text",inputMode:"numeric","aria-label":"Switch threshold","aria-describedby":N,"aria-invalid":d?!0:void 0,value:n,...j("threshold"),onChange:S=>p(S.target.value),onBlur:()=>w(),autoComplete:"off",spellCheck:!1}),a.jsx("span",{className:"ap-threshold-unit","aria-hidden":!0,children:"%"})]})}):a.jsx("span",{className:"ap-field",title:"Switch once the active account passes this much of its limit",children:a.jsxs("select",{ref:o,"aria-label":"Switch threshold",value:n,...j("threshold"),onChange:S=>f(S.target.value),children:[eJ(t).map(S=>a.jsxs("option",{value:S,children:[S,"%"]},S)),a.jsx("option",{value:B3,children:"Custom…"})]})}),(r.sends||s)&&a.jsx("button",{ref:i,type:"button",className:"ap-manage-btn",...j("threshold"),title:r.title,onClick:()=>k(n,r),children:s&&!r.sends?r.done:r.label}),a.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":e.enabled,"aria-label":"Auto-switch",...j("enable"),onClick:()=>v({action:"enable",enabled:!e.enabled},"enable").then(()=>b(!0)),title:e.enabled?"Stop switching accounts automatically":"Switch accounts automatically when the active one nears its limit",children:a.jsx("span",{className:"switch-knob"})})]}),d?a.jsx("p",{id:N,className:"ap-threshold-note",role:"alert","data-tone":"err",children:d},"refusal"):c?a.jsx("p",{id:N,className:"ap-threshold-note",children:QZ},"hint"):null,e.external&&a.jsxs("p",{className:"ap-auto-note",children:[a.jsx("i",{className:"ap-pulse","aria-hidden":!0})," A ",a.jsx("code",{children:"cswap auto"})," loop in your terminal is doing the switching. The deck stands down while it runs",e.enabled?" — this toggle takes over when you stop it.":"."]})]})}const VE=18,aJ=1100,xi=(e,t)=>{const n=Math.sin(e*12.9898+t*78.233)*43758.5453;return n-Math.floor(n)},oJ=Array.from({length:VE},(e,t)=>{const n=-72+144*t/(VE-1)+(xi(t,1)-.5)*9,r=(n-90)*(Math.PI/180),s=(54+32*Math.cos(n*Math.PI/180))*(.74+xi(t,2)*.52);return{dx:Math.cos(r)*s,dy:Math.sin(r)*s,rot:(t%2?1:-1)*(100+xi(t,3)*260),delay:Math.round(xi(t,4)*90),dur:760+Math.round(xi(t,5)*260),scale:.8+xi(t,6)*.45,hue:t%4,round:t%3===0}});function GE({anchor:e}){var s;const[t,n]=y.useState(null),r=typeof window<"u"&&((s=window.matchMedia)==null?void 0:s.call(window,"(prefers-reduced-motion: reduce)").matches);return y.useEffect(()=>{if(r)return;const o=e.current;if(!o)return;const i=o.getBoundingClientRect();n({x:i.left+i.width/2,y:i.top+i.height/2});const c=window.setTimeout(()=>n(null),aJ);return()=>window.clearTimeout(c)},[e,r]),r||!t?null:yt.createPortal(a.jsx("div",{className:"confetti",style:{left:`${t.x}px`,top:`${t.y}px`},"aria-hidden":!0,children:oJ.map((o,i)=>a.jsx("span",{className:`confetti-bit${o.round?" round":""}`,"data-hue":o.hue,style:{"--dx":`${o.dx.toFixed(1)}px`,"--dy":`${o.dy.toFixed(1)}px`,"--rot":`${o.rot}deg`,"--s":o.scale.toFixed(2),animationDelay:`${o.delay}ms`,animationDuration:`${o.dur}ms, ${o.dur}ms`}},i))}),document.body)}const $h=y.forwardRef((e,t)=>a.jsxs("svg",{className:"aa-mark",viewBox:"0 0 44 44","aria-hidden":!0,ref:t,children:[a.jsx("circle",{className:"aa-mark-ring",cx:"22",cy:"22",r:"20"}),a.jsx("path",{className:"aa-mark-tick",d:"M13.5 22.5 L19.5 28.5 L31 17"})]}));$h.displayName="SuccessMark";const iJ={done:", done",active:", in progress",failed:", failed",pending:""};function lJ({status:e}){return a.jsx("svg",{className:"aa-stage-icon",viewBox:"0 0 16 16","aria-hidden":!0,children:e==="done"?a.jsx("path",{className:"aa-stage-tick",d:"M4 8.5 L7 11.5 L12.5 5"}):e==="failed"?a.jsx("path",{className:"aa-stage-cross",d:"M5 5 L11 11 M11 5 L5 11"}):e==="active"?a.jsx("circle",{className:"aa-stage-now",cx:"8",cy:"8",r:"3.5"}):a.jsx("circle",{className:"aa-stage-later",cx:"8",cy:"8",r:"3"})})}function cJ({rows:e,phase:t,detail:n,actions:r}){var o;const s=(o=e.find(i=>i.status==="active"))==null?void 0:o.id;return a.jsxs("div",{className:`aa-progress ${t}`,"data-at":s,children:[a.jsxs("svg",{className:"aa-orbit",viewBox:"0 0 44 44","aria-hidden":!0,children:[a.jsx("circle",{className:"aa-orbit-track",cx:"22",cy:"22",r:"20"}),t==="live"||t==="resolving"?a.jsx("circle",{className:"aa-orbit-arc",cx:"22",cy:"22",r:"20"}):null,t==="resolving"?a.jsx("circle",{className:"aa-orbit-close",cx:"22",cy:"22",r:"20"}):null,t==="failed"?a.jsx("path",{className:"aa-orbit-cross",d:"M17 17 L27 27 M27 17 L17 27"}):null]}),a.jsx("ol",{className:"aa-stages",children:e.map(i=>{const c=i.status==="active"||i.status==="failed";return a.jsxs("li",{className:"aa-stage","data-status":i.status,"aria-current":i.status==="active"?"step":void 0,children:[a.jsx(lJ,{status:i.status}),a.jsxs("span",{className:"aa-stage-label",children:[i.label,a.jsx("span",{className:"vis-hidden",children:iJ[i.status]})]}),c&&n?a.jsx("div",{className:"aa-stage-more",children:n}):null]},i.id)})}),r?a.jsx("div",{className:"aa-actions aa-progress-actions",children:r}):null]})}const q3=new Set(["awaiting_url","awaiting_code","registering"]);function U3(e){return e!=null&&q3.has(e)}function H3(e){return e!=null&&e!=="done"&&!q3.has(e)}const W3="the sign-in ended before it finished — the deck restarted, or it was cancelled in another tab",uJ="the sign-in did not complete";function dJ({state:e,serverError:t,localError:n}){const r=e==="idle";return{title:r?"Sign-in ended":"Sign-in failed",message:n||t||(r?W3:uJ)}}function KE({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 YE({started:e,state:t}){return!e||t==="done"?null:{action:"login-cancel"}}function hJ({login:e,started:t,loginError:n,loginBusy:r}){return(e==null?void 0:e.state)==="done"&&e.account?"done":(e==null?void 0:e.state)==="awaiting_code"||(e==null?void 0:e.state)==="registering"?"code":H3(e==null?void 0:e.state)||n&&t&&!r?"ended":r||U3(e==null?void 0:e.state)?"asking":"primer"}const hg=["link","approve","confirm","save"],XE={confirm:"confirm",save:"save",restore:"save"};function z3(e){return e!=null&&Object.prototype.hasOwnProperty.call(XE,e)?XE[e]:null}function fJ({state:e,step:t,starting:n}){return e==="registering"?z3(t)??"confirm":e==="awaiting_code"?"approve":e==="awaiting_url"||e==null&&n?"link":null}function pJ({state:e,step:t,url:n,lastLive:r}){return e==="failed"?z3(t)??(n?"approve":"link"):e==="idle"?r??"link":"link"}const mJ={link:{pending:"Open the sign-in page",active:"Opening the sign-in page",done:"Sign-in page opened"},approve:{pending:"Approve in your browser",active:"Waiting for you to approve in the browser",done:"Approved in the browser"},confirm:{pending:"Confirm who signed in",active:"Confirming who signed in",done:"Sign-in confirmed"},save:{pending:"Save the credentials",active:"Saving the credentials",done:"Credentials saved"}};function gJ(e,t,n){return t==="failed"?V3(e,n):mJ[e][t]}function yJ({live:e=null,failed:t=null,done:n=!1,state:r=null}){const s=n?hg.length:hg.indexOf(t??e);return hg.map((o,i)=>{const c=n||i<s?"done":i>s||s<0?"pending":t?"failed":"active";return{id:o,status:c,label:gJ(o,c,r)}})}function wJ(e,t){switch(e){case"link":return"The claude CLI is preparing a sign-in link, and opens a browser tab with it.";case"approve":return"Approve the sign-in in the tab that opened. This finishes by itself.";case"confirm":return"Asking the claude CLI which account just signed in.";case"save":return t==="restore"?"Switching this machine back to the account you were using.":"claude-swap is recording the account."}}const xJ={link:"The sign-in page did not open",approve:"The sign-in did not finish in the browser",confirm:"The sign-in could not be confirmed",save:"claude-swap could not save the account"};function V3(e,t){return t==="idle"?"Sign-in ended":xJ[e]}const vJ=/^(?:claude|claude-swap|cswap|ccdeck|npm|uv)\b/;function nh(e){const t=String(e??"").trim();if(!t)return"";const n=vJ.test(t)?t:t[0].toUpperCase()+t.slice(1);return/[.!?…]$/.test(n)?n:`${n}.`}nh(W3);const bJ=1e4,kJ=1e4,jJ=5;function NJ({since:e,now:t,expiresAt:n}){if(e==null||t-e<bJ)return null;const r=n!=null?Math.ceil((n-t)/6e4):NaN,s="Still waiting for the browser. If no tab opened, or you closed it, use the link above";return r>=1&&r<=jJ?`${s} — the sign-in stays open ${r} more minute${r===1?"":"s"}.`:`${s}.`}function SJ({since:e,now:t}){return e==null||t-e<kJ?null:"Still importing. claude-swap stops by itself after a minute if it cannot finish."}function _J(e){return e==="registering"?400:1500}const G3=460;function EJ({fromStages:e,reducedMotion:t}){return e&&!t?G3:0}function CJ({added:e,reducedMotion:t}){return e&&!t}function ZE({num:e,added:t}){return t?e!=null&&e!==""?`Account ${e} added`:"Account added":"Credentials refreshed"}function TJ(e){switch(e){case"approve":return"Waiting for you to approve the sign-in in your browser.";case"confirm":return"Approved. Confirming who signed in.";case"save":return"Saving the credentials.";default:return null}}const RJ="done";function AJ(){let e=!1;return{shouldAnnounce(t){return t!==RJ?(e=!1,!1):e?!1:(e=!0,!0)}}}function f1(e,t){return t?qt(e,t):void 0}const MJ={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 ${Lt}`,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"},$J={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"},p1=`claude-swap could not read the login keychain — start ${Lt} from a Terminal window rather than a background service`,LJ={unreadable_here:{short:"Keychain locked on this Mac",long:`${p1}.`},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 Lh(e){return e?qt(LJ,e)??null:null}const K3={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 D0(e,t,n){const r=n==null?null:K3[n];if(r)return r;if((e==null?void 0:e.reason)!=="no_cswap"&&/keychain/i.test(Bc(e)))return p1;const s=f1($J,e==null?void 0:e.reason);return s||(e==null?void 0:e.reason)||t}function Bc(e){return((e==null?void 0:e.output)||(e==null?void 0:e.detail)||(e==null?void 0:e.error)||"").trim()}const OJ={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"},IJ="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 PJ(e){return/\bnpx\b/i.test(e)&&/(command not found|not found|not recognized|ENOENT)/i.test(e)}const DJ="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",FJ="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",BJ=e=>/\b(?:ERR_)?MODULE_NOT_FOUND\b|cannot find (?:module|package)/i.test(e),qJ=/node_modules[\\/]npm[\\/]bin[\\/]|\bnpm-prefix\.js\b|\bnp[mx][-.][\w.-]*cli\.js\b/i,UJ=/[\\/]_npx[\\/]/i,HJ=`the copy of ccusage ${Lt} installed for itself`;function WJ(e){const t=String((e==null?void 0:e.install)??"").replace(/\s+/g," ").trim();return t.length>240?`${t.slice(0,239)}…`:t}function age(e,t){const n=zJ(e,t),r=WJ(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 ${ec(n)}`:`there is no managed copy of ccusage on this machine, and the npx fallback failed: ${ec(n)}`;case"managed":return`${HJ} failed to run: ${ec(n)}`;case"path":return e.bin?`the ccusage this deck found at ${e.bin} failed to run: ${ec(n)}`:`the ccusage this deck found on your PATH failed to run: ${ec(n)}`;default:return n}}const ec=e=>/^[A-Z][a-z]/.test(e)?e[0].toLowerCase()+e.slice(1):e;function zJ(e,t){const n=Bc(e);if(BJ(n)){if(UJ.test(n))return FJ;if(qJ.test(n))return DJ}if(PJ(n))return IJ;const r=f1(OJ,e==null?void 0:e.reason);return r||(e==null?void 0:e.reason)||t}function Ci(e,t,n){const r=n==null?null:K3[n];if(r)return r;if(e!=null&&e.detail)return e.detail;if(e!=null&&e.error&&H3(e.state))return e.error;const s=f1(MJ,e==null?void 0:e.reason);return s||(e!=null&&e.error?e.error:(e==null?void 0:e.reason)||t)}function m1(e,t,n,r="horizontal"){if(n<=0||uf(e))return{kind:"pass"};const s=t>=0&&t<n?t:-1,o=r==="vertical",i=e.key==="ArrowRight"||o&&e.key==="ArrowDown",c=e.key==="ArrowLeft"||o&&e.key==="ArrowUp";if(i)return{kind:"select",index:s===-1?0:(s+1)%n};if(c)return{kind:"select",index:s===-1?n-1:(s-1+n)%n};switch(e.key){case"Home":return{kind:"select",index:0};case"End":return{kind:"select",index:n-1};default:return{kind:"pass"}}}function Y3(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 VJ(e){const t=new Map;for(const n of e){const r=(n.email??"").trim().toLowerCase();r&&t.set(r,(t.get(r)??0)+1)}return e.map(n=>{const r=(n.email??"").trim(),s=n.alias||r||`account ${n.num}`,o=[];return n.alias&&r&&o.push(r),r&&(t.get(r.toLowerCase())??0)>1&&o.push(n.org||`slot ${n.num}`),{num:n.num,label:s,sub:o.length?o.join(" · "):null}})}function GJ(e,t){return e.filter(n=>!t.includes(n.num)).map(n=>n.num)}function KJ(e,t){return e.includes(t)?e.filter(n=>n!==t):[...e,t]}function YJ(e){return e.length?{action:"share",accounts:[...e]}:null}function XJ(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 F0(e){return`${e.email}|${e.org??""}`}function ZJ(e,t,n){return e&&e.map(r=>F0(r)===t?n:r)}function JJ(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 JE(e){const t=e.length;if(!t)return"Nothing to import.";const n=f=>e.filter(p=>p.state===f).length,r=[],s=n("imported");s&&r.push(`${s} of ${t} imported`);const o=n("healed");o&&r.push(`${o} had a dead token replaced`);const i=n("updated");i&&r.push(`${i} updated`);const c=n("present");c&&r.push(`${c} already here`);const d=n("failed");d&&r.push(`${d} did not arrive`);const h=[...new Set(e.map(f=>{var p;return(p=Lh(f.check))==null?void 0:p.short}).filter(f=>!!f))];return`${r.join(", ")}${h.length?`, ${h.join(", ")}`:""}.`}function QJ(e){try{return e?new URL(e).host:""}catch{return""}}const Od=[{id:"login",label:"Sign in"},{id:"paste",label:"Paste a share"}],QE="aa-panel",eC=e=>`aa-tab-${e}`;async function oo(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}function X3({onClose:e,onChanged:t,email:n=null,onSignedIn:r}){Jt("add-account");const[s,o]=y.useState("login"),[i,c]=y.useState(null),[d,h]=y.useState(""),[f,p]=y.useState(""),[g,w]=y.useState(!1),[k,j]=y.useState(!1),[v,b]=y.useState(null),[N,S]=y.useState(null),E=g||k,[C,$]=y.useState(null),[T,I]=y.useState(null),[O,U]=y.useState(null),P=y.useRef(""),L=y.useRef(!1),F=y.useRef(!1),A=y.useRef(null),B=y.useRef(null),D=y.useRef(null),K=y.useRef(null),G=y.useRef([]),H=y.useRef(!1),q=y.useRef(0),M=y.useRef(null),V=y.useRef("primer"),Z=y.useRef(null),W=y.useRef(null),X=y.useRef(null),Y=y.useRef(!1),J=y.useState(Yc)[0],[ee,ne]=y.useState(null),[se,ce]=y.useState(!1),[de,ae]=y.useState(()=>Date.now()),[pe,fe]=y.useState(null),[Ee,ye]=y.useState(null),[oe,we]=y.useState(null),Ne=y.useCallback(()=>{const je=YE({started:L.current,state:i==null?void 0:i.state});je&&oo(je).catch(()=>{}),e()},[e,i==null?void 0:i.state]),ge=ot(Ne,{focusRef:D}),Ae=dt(Ne),Oe=y.useCallback(async()=>{if(!qn(F.current))return;const je=++q.current;F.current=!0,w(!0),b(null),we(null),L.current=!0;let $e=await oo(n?{action:"login",email:n}:{action:"login"}).catch(()=>null);if(n&&($e==null?void 0:$e.reason)==="bad_email"&&je===q.current&&($e=await oo({action:"login"}).catch(()=>null)),je===q.current){if(F.current=!1,w(!1),!($e!=null&&$e.ok)){b(Ci($e,"could not start the sign-in"));return}c($e)}},[n]);y.useEffect(()=>{if(!U3(i==null?void 0:i.state))return;const je=window.setInterval(async()=>{try{const $e=await fetch("/api/claude-accounts/login");$e.ok&&c(await $e.json())}catch{}},_J(i==null?void 0:i.state));return()=>window.clearInterval(je)},[i]);const qe=y.useCallback(async()=>{const je=YE({started:L.current,state:i==null?void 0:i.state});if(q.current+=1,L.current=!1,F.current=!1,w(!1),b(null),c(null),h(""),ce(!1),Y.current=!0,!je)return;const $e=await oo(je).catch(()=>null);we(KE({restored:$e==null?void 0:$e.restored,activeAccount:$e==null?void 0:$e.activeAccount}))},[i==null?void 0:i.state]),Me=y.useCallback(()=>{L.current=!1,c(null),b(null),h(""),ce(!1),Oe()},[Oe]),He=y.useRef(t);He.current=t;const rt=y.useState(AJ)[0];y.useEffect(()=>{rt.shouldAnnounce(i==null?void 0:i.state)&&He.current()},[i==null?void 0:i.state,rt]),y.useEffect(()=>{var je;se&&((je=A.current)==null||je.focus())},[se]);const Ue=y.useRef(r);Ue.current=r;const it=y.useRef(null);y.useEffect(()=>{var De;const je=(i==null?void 0:i.state)==="done"?i.account:null,$e=je?`${je.num??""}|${je.email}`:null;!je||it.current===$e||(it.current=$e,(De=Ue.current)==null||De.call(Ue,je))},[i]),y.useEffect(()=>{var je;s==="paste"&&!H.current&&((je=B.current)==null||je.focus()),H.current=!1},[s]);const Et=y.useCallback(je=>{var De;const $e=m1(je,Od.findIndex(lt=>lt.id===s),Od.length);$e.kind!=="pass"&&(je.preventDefault(),H.current=!0,o(Od[$e.index].id),(De=G.current[$e.index])==null||De.focus())},[s]),st=y.useCallback(async()=>{var De;if(!qn(F.current))return;const je=q.current;F.current=!0,w(!0),b(null);const $e=await oo({action:"login-code",code:d}).catch(()=>null);if(je===q.current){if(F.current=!1,w(!1),!($e!=null&&$e.ok)){b(Ci($e,"the code was not accepted")),$e!=null&&$e.state&&c($e),(De=A.current)==null||De.select();return}h(""),c($e)}},[d,i]),ht=y.useCallback(async()=>{if(!qn(F.current))return;F.current=!0,j(!0),S(null);const je=await oo({action:"import",blob:f}).catch(()=>null);if(F.current=!1,j(!1),!(je!=null&&je.ok)){S(Ci(je,"the import failed"));return}P.current=f,p(""),U(null),$(je.results??[]),t()},[f,t]),ft=y.useCallback(async je=>{const $e=F0(je);if(!qn(F.current)||!P.current)return;F.current=!0,j(!0),I($e),U(null);const De=await oo({action:"import",blob:P.current,force:!0,only:{email:je.email,org:je.org??""}}).catch(()=>null);if(F.current=!1,j(!1),I(null),!(De!=null&&De.ok)){U({key:$e,text:Ci(De,"that account could not be updated")});return}const lt=(De.results??[])[0];lt&&$(Wt=>ZJ(Wt,$e,lt)),t()},[t]),Be=(i==null?void 0:i.state)==="done"?i.account:null,Kt=KE({restored:i==null?void 0:i.restored,activeAccount:i==null?void 0:i.activeAccount}),at=hJ({login:i,started:L.current,loginError:v,loginBusy:g}),At=dJ({state:i==null?void 0:i.state,serverError:i==null?void 0:i.error,localError:v}),et=at==="asking"||at==="code"?fJ({state:i==null?void 0:i.state,step:i==null?void 0:i.step,starting:at==="asking"})??"link":null,pt=at==="ended"?pJ({state:i==null?void 0:i.state,step:i==null?void 0:i.step,url:i==null?void 0:i.url,lastLive:M.current}):null,jt=Be?`${Be.num??""}|${Be.email}`:null,wt=at==="done"&&jt!==ee&&EJ({fromStages:V.current==="progress",reducedMotion:J})>0,tt=at==="primer"?"primer":at==="done"&&Be&&!wt?"done":"progress",Ct=pt?"failed":wt?"resolving":"live",Tn=yJ(wt?{done:!0}:pt?{failed:pt,state:i==null?void 0:i.state}:{live:et}),Mt=pt?V3(pt,i==null?void 0:i.state):"",an=nh(At.message),fn=et==="approve"?NJ({since:pe,now:de,expiresAt:i==null?void 0:i.expiresAt}):null,pn=k?SJ({since:Ee,now:de}):null,Rn=s==="login"?tt==="done"&&Be?`${ZE(Be)}.`:Ct==="failed"?`${Mt}. ${an}`:tt==="progress"&&!wt?TJ(et)??"":"":k?"Importing the share.":N?nh(N):C?nh(JE(C)):"";y.useEffect(()=>{et&&(M.current=et)},[et]),y.useEffect(()=>{V.current=tt},[tt]),y.useEffect(()=>{if(!wt||!jt)return;const je=window.setTimeout(()=>ne(jt),G3);return()=>window.clearTimeout(je)},[wt,jt]);const Yt=et==="approve";y.useEffect(()=>{fe(Yt?Date.now():null)},[Yt]),y.useEffect(()=>{ye(k?Date.now():null)},[k]);const An=Yt||k;return y.useEffect(()=>{if(!An)return;ae(Date.now());const je=window.setInterval(()=>ae(Date.now()),1e3);return()=>window.clearInterval(je)},[An]),y.useEffect(()=>{var $e,De,lt,Wt;if(s!=="login")return;if(tt==="done"){($e=W.current)==null||$e.focus();return}if(tt==="primer"){Y.current&&((De=D.current)==null||De.focus()),Y.current=!1;return}if(Ct==="failed"){(lt=X.current)==null||lt.focus();return}const je=document.activeElement;et==="approve"&&(!je||je===document.body)&&((Wt=Z.current)==null||Wt.focus())},[s,tt,Ct,et]),yt.createPortal(a.jsx("div",{className:"modal-backdrop",...Ae,role:"presentation",children:a.jsxs("div",{ref:ge,className:"modal aa-modal",onClick:je=>je.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Add a Claude account",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{className:"aa-tabs",role:"tablist","aria-label":"How to add the account",onKeyDown:Et,children:Od.map((je,$e)=>a.jsx("button",{type:"button",role:"tab",id:eC(je.id),ref:De=>{G.current[$e]=De},"aria-selected":s===je.id,"aria-controls":QE,tabIndex:s===je.id?0:-1,className:`aa-tab${s===je.id?" on":""}`,onClick:()=>{H.current=!1,o(je.id)},children:je.label},je.id))})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:Ne,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body aa-body",id:QE,role:"tabpanel","aria-labelledby":eC(s),children:[s==="login"?tt==="done"&&Be?a.jsxs("div",{className:`aa-done${ee===jt?" from-orbit":""}`,children:[a.jsx($h,{ref:K}),CJ({added:Be.added,reducedMotion:J})&&a.jsx(GE,{anchor:K}),a.jsx("h4",{children:ZE(Be)}),a.jsxs("p",{className:"aa-note",children:[a.jsx("strong",{children:Be.email}),Be.added?Kt?" is in the rotation.":" is in the rotation. The account you were using is still active.":" was already in the rotation, so its stored login was replaced with this one."]}),Kt?a.jsx("p",{className:"aa-note aa-warn",role:"status",children:Kt}):null,a.jsx("button",{type:"button",ref:W,className:"btn primary",onClick:Ne,children:"Done"})]}):tt==="progress"?a.jsx(cJ,{rows:Tn,phase:Ct,detail:Ct==="failed"?a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"aa-note aa-reason",children:an}),a.jsx("div",{className:"aa-actions",children:a.jsx("button",{type:"button",ref:X,className:"btn primary",onClick:Me,children:pt==="link"?"Try again":"Start over"})})]}):et==="approve"&&i?a.jsxs(a.Fragment,{children:[a.jsxs("p",{className:"aa-note",children:["Approve the sign-in in the tab that opened",n?a.jsxs(a.Fragment,{children:[", with ",a.jsx("strong",{children:n})," filled in"]}):null,". This moves on by itself."]}),a.jsxs("a",{ref:Z,className:"aa-link",href:i.url??"#",target:"_blank",rel:"noreferrer noopener",children:[a.jsx("span",{children:"Open it in this browser"}),a.jsxs("span",{className:"aa-link-host",children:[QJ(i.url),a.jsx("svg",{width:"9",height:"9",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:a.jsx("path",{d:"M3 7 7 3M3.6 3H7v3.4"})})]})]}),fn?a.jsx("p",{className:"aa-note aa-arrive",children:fn}):null,a.jsxs("details",{className:"aa-code",open:se,onToggle:je=>ce(je.currentTarget.open),children:[a.jsxs("summary",{children:[a.jsx("svg",{className:"aa-code-chev",width:"9",height:"9",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:a.jsx("path",{d:"M3.6 2.2 6.4 5 3.6 7.8"})}),"Paste a code, if the page shows one"]}),a.jsx("p",{className:"aa-note",children:"It usually finishes on its own — if the page says you are all set, there is nothing to do here."}),a.jsxs("div",{className:"aa-field",children:[a.jsx("input",{ref:A,type:"text",value:d,onChange:je=>h(je.target.value),onKeyDown:je=>{je.key==="Enter"&&d.trim()&&!E&&st()},placeholder:"paste the code here",spellCheck:!1,autoComplete:"off","aria-label":"Sign-in code",disabled:i.state==="registering"}),a.jsx("button",{type:"button",className:"btn primary",...ts(E,!d.trim()||i.state==="registering"),onClick:st,children:"Continue"})]}),(v||i.error)&&a.jsx("p",{className:"aa-err",children:v??i.error}),a.jsx("p",{className:"aa-note",children:"The code goes straight to the claude CLI on this machine. It is never stored or sent anywhere else."})]})]}):et?a.jsx("p",{className:"aa-note",children:wJ(et,i==null?void 0:i.step)}):null,actions:et==="link"||et==="approve"?a.jsx("button",{type:"button",className:"btn",onClick:qe,children:"Cancel"}):null}):a.jsxs("div",{className:"aa-step aa-primer",children:[oe?a.jsx("p",{className:"aa-note aa-warn",role:"status",children:oe}):null,a.jsx("h4",{children:n?a.jsxs(a.Fragment,{children:["Sign in again as ",a.jsx("strong",{children:n})]}):"Sign in to Anthropic"}),a.jsxs("p",{className:"aa-note",children:["Opens a browser tab where you approve the sign-in",n?", with this address already filled in":"",". It normally completes by itself; only if the page hands you a code does it need pasting back here.",n?" claude-swap replaces the expired login in place — the account keeps its slot, its alias and its history — and the account you are using now stays active.":" claude-swap records the account when it completes, and the account you are using now stays active."]}),a.jsx("div",{className:"aa-actions",children:a.jsx("button",{type:"button",ref:D,className:"btn primary",...ts(E),onClick:Oe,children:"Open the sign-in page"})})]}):C?(()=>{const je=C.filter(De=>De.state==="imported").length,$e=C.some(De=>Lh(De.check));return a.jsxs("div",{className:"aa-done",children:[!$e&&a.jsx($h,{ref:K}),je>0&&!$e&&a.jsx(GE,{anchor:K}),a.jsx("h4",{children:JE(C)}),C.length>0&&a.jsx("ul",{className:"aa-results",children:C.map(De=>{const lt=F0(De),Wt=Lh(De.check);return a.jsxs("li",{className:`aa-result ${De.state}`,children:[a.jsx("span",{className:"aa-result-who",children:De.email||(De.num?`slot ${De.num}`:"an account")}),a.jsx("span",{className:"aa-result-what",children:JJ(De.state)}),De.state==="present"&&a.jsx("button",{type:"button",className:"aa-result-fix","aria-busy":T===lt,title:`Overwrite the stored login for ${De.email} with the one in this share. Do this when that account has stopped working here; if it works, leave it.`,onClick:()=>ft(De),children:T===lt?"updating…":"update anyway"}),Wt&&a.jsx("span",{className:"aa-result-err",children:Wt.long}),(O==null?void 0:O.key)===lt&&a.jsx("span",{className:"aa-result-err",children:O.text})]},lt)})}),a.jsxs("p",{className:"aa-note",children:["Nothing changed on the deck you copied this from. An account already here is left as it is, unless its stored login was dead or you pressed",a.jsx("strong",{children:" update anyway"}),"."]}),a.jsxs("div",{className:"aa-actions",children:[a.jsx("button",{type:"button",className:"btn primary",onClick:Ne,children:"Done"}),a.jsx("button",{type:"button",className:"btn",onClick:()=>{P.current="",U(null),$(null)},children:"Import another"})]})]})})():a.jsxs("div",{className:"aa-step",children:[a.jsx("h4",{children:"Paste an account shared from another deck"}),a.jsxs("div",{className:"aa-field",children:[a.jsx("input",{ref:B,type:"text",value:f,onChange:je=>p(je.target.value),onKeyDown:je=>{je.key==="Enter"&&f.trim()&&!E&&ht()},placeholder:"ccdeck2:…",spellCheck:!1,autoComplete:"off","aria-label":"Shared account"}),a.jsx("button",{type:"button",className:"btn primary",...ts(E,!f.trim()),onClick:ht,children:k?"importing…":"Import"})]}),N&&a.jsx("p",{className:"aa-err",children:N}),k?a.jsxs("p",{className:"aa-live-line",children:[a.jsxs("svg",{className:"aa-spin",viewBox:"0 0 16 16","aria-hidden":!0,children:[a.jsx("circle",{className:"aa-spin-track",cx:"8",cy:"8",r:"6"}),a.jsx("circle",{className:"aa-spin-arc",cx:"8",cy:"8",r:"6"})]}),a.jsx("span",{children:pn??"claude-swap is adding the accounts in this share. Any already here are left as they are."})]}):null,a.jsxs("p",{className:"aa-note",children:["Use ",a.jsx("strong",{children:"share"})," on one account in the other deck, or ",a.jsx("strong",{children:"↗"})," above its list to send several at once. A share carries a live login for every account in it and expires ten minutes after it is made."]})]}),a.jsx("p",{className:"vis-hidden",role:"status","aria-live":"polite",children:Rn})]})]})}),document.body)}function eQ(e,t){const n=new Set(e),r=e.length?Math.max(...e):0;return[...new Set([...e,r+1])].sort((s,o)=>s-o).map(s=>{const o=s===t?"here":n.has(s)?"swap":"free";return{slot:s,kind:o,label:o==="here"?`slot ${s}`:`slot ${s} · ${o}`}})}function tQ(e,t,n){if(!(n!=null&&n.ok))return null;const r=Number.isInteger(n.to)?n.to:null;if(r==null)return{menuFor:null,confirmRemove:null,shareFor:null,swapNote:null};const s=n.swapped===!0&&r!==t;return{menuFor:e.menuFor===t?r:s&&e.menuFor===r?t:e.menuFor,confirmRemove:null,shareFor:null,swapNote:s?{at:r,displaced:t}:null}}const nQ=64;function rQ(e,t){const n=e.trim();return{alias:n,commit:n!==(t??"").trim()}}function sQ(e,t,n){return t!=null&&e.some(r=>r.slot===t)?t:n}function aQ(e,t,n){var s;const r=((s=e.find(o=>o.slot===t))==null?void 0:s.kind)??"here";return r==="swap"?{label:"swap",done:"swapped",sends:!0,swaps:!0,title:`Send this account to slot ${t}. That slot is taken, so the two accounts trade places and the one standing there moves to slot ${n}.`}:r==="free"?{label:"move",done:"moved",sends:!0,swaps:!1,title:`Send this account to slot ${t}. That slot is empty, so no other account moves.`}:{label:"move",done:"here",sends:!1,swaps:!1,title:`This account already holds slot ${n}.`}}function oQ(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 iQ({a:e,slots:t,nowSec:n,boundaryId:r,accountMenu:s,busy:o,pressProps:i,rotating:c,onProjects:d,onRotation:h}){const{menu:f,menuError:p,aliasDraft:g,confirmRemove:w,share:k,shareCopied:j,slotDraft:v,dropMenu:b,closeMenu:N,startRename:S,typeAlias:E,doAlias:C,startMove:$,pickSlot:T,doSlot:I,makeShare:O,copyShare:U,pressRemove:P}=s;if(!f)return null;const L=`ap-pop-title-${e.num}`,F=p&&a.jsx("p",{className:"ap-pop-error",role:"alert",title:p.raw||void 0,children:p.text});return a.jsxs(Nf,{anchorId:`ap-more-${e.num}`,boundaryId:r,id:`ap-menu-${e.num}`,className:"ap-pop",role:f.view==="menu"?"menu":"dialog",labelledBy:f.view==="menu"?`ap-more-${e.num}`:L,start:f.start,onClose:b,children:[f.view==="menu"&&a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",onClick:()=>S(e.num,e.alias),children:"Rename"}),a.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",onClick:()=>$(e.num),children:"Move to slot…"}),a.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",...i(`share-${e.num}`),title:`Copy this account to another ${Lt}. 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:()=>O(e.num),children:o===`share-${e.num}`?"Sharing…":"Share"}),a.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",title:"See how much this account worked in each project",onClick:()=>d(),children:"Projects"}),(c&&!e.active||e.disabled)&&a.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",...i(`rot-${e.num}`),title:e.disabled?"Return this account to auto-rotation":"Hold this account out of auto-rotation",onClick:()=>h(),children:e.disabled?"Put back in rotation":"Hold out of rotation"}),a.jsx("div",{role:"separator",className:"ap-menu-sep"}),a.jsx("button",{type:"button",role:"menuitem",className:`ap-menu-item danger${w===e.num?" armed":""}`,...i(`rm-${e.num}`),"aria-label":w===e.num?"Confirm remove":void 0,title:w===e.num?"This deletes the stored credentials for this account":"Remove this account from claude-swap",onClick:()=>P(e.num),children:o===`rm-${e.num}`?"Removing…":w===e.num?"Confirm":"Remove"}),F]}),f.view==="rename"&&a.jsxs("form",{className:"ap-pop-form",onSubmit:A=>{A.preventDefault(),C(e.num,e.alias)},children:[a.jsx("label",{className:"ap-pop-title",id:L,htmlFor:`ap-alias-${e.num}`,children:"Rename account"}),a.jsx("input",{id:`ap-alias-${e.num}`,className:"ap-manage-input",type:"text",value:g,onChange:A=>E(A.target.value),maxLength:nQ,placeholder:"e.g. work",spellCheck:!1,autoComplete:"off",autoFocus:!0,onFocus:A=>A.currentTarget.select()}),F,a.jsxs("div",{className:"ap-pop-actions",children:[a.jsx("button",{type:"button",className:"btn",onClick:()=>N(),children:"Cancel"}),a.jsx("button",{type:"submit",className:"btn primary",...i(`alias-${e.num}`),title:"A short name to show instead of the email",children:o===`alias-${e.num}`?"…":"Save"})]})]}),f.view==="move"&&(()=>{const A=eQ(t,e.num),B=sQ(A,v,e.num),D=aQ(A,B,e.num);return a.jsxs("div",{className:"ap-pop-form",children:[a.jsx("label",{className:"ap-pop-title",id:L,htmlFor:`ap-slot-${e.num}`,children:"Move to slot"}),a.jsx("span",{className:"ap-field",children:a.jsx("select",{id:`ap-slot-${e.num}`,value:String(B),...i(`move-${e.num}`),onChange:K=>T(Number(K.target.value)),autoFocus:!0,children:A.map(K=>a.jsx("option",{value:K.slot,children:K.label},K.slot))})}),F,a.jsxs("div",{className:"ap-pop-actions",children:[a.jsx("button",{type:"button",className:"btn",onClick:()=>N(),children:"Cancel"}),a.jsx("button",{type:"button",className:"btn primary",...i(`move-${e.num}`),title:D.title,onClick:()=>I(e.num,B,D),children:o===`move-${e.num}`?"…":ic(D.label)})]})]})})(),f.view==="share"&&(k==null?void 0:k.num)===e.num&&(()=>{const A=Y3(k.expiresAt,n),B=A.tone==="gone";return a.jsxs("div",{className:"ap-pop-form",children:[a.jsx("p",{className:"ap-pop-title",id:L,children:"Share account"}),a.jsx("code",{className:"ap-share-blob",children:k.blob}),a.jsxs("p",{className:"ap-pop-note",title:"This text is the account's password. It is base64 of plain JSON — the expiry inside it is not signed, so anyone holding a copy can change it, and the login itself is in there in the clear either way. The countdown only says how long another deck's import dialog will still accept it. If a copy escapes, sign the account out and back in.",children:[a.jsx("span",{className:"ap-share-warn",children:"This is the password"})," · ",a.jsx("span",{className:`ap-share-expiry ${A.tone}`,children:A.text})]}),F,a.jsxs("div",{className:"ap-pop-actions",children:[a.jsx("button",{type:"button",className:"btn",onClick:()=>N(),children:"Done"}),a.jsx("button",{type:"button",className:"btn primary",...i(`share-${e.num}`),autoFocus:!0,onClick:async()=>{if(B){await O(e.num);return}await U(k.blob)},children:B?"Make a new share":j?"Copied":"Copy"})]})]})})()]})}const lQ=6;function cQ(e,t){const n=e.filter(c=>c.ready);if(t.armed&&e.length>0&&n.length===0)return{text:"Auto-switch has nowhere to go",tone:"bad",free:null};const r=n.length===e.length?`${e.length} ready`:n.length===0?e.length===1?"not ready":`none of ${e.length} ready`:`${n.length} of ${e.length} ready`,s=n.length?"ok":"idle",o=t.strained&&!t.armed?uQ(n):null,i=[r];return o!=null&&i.push(`${o}% free`),i.push(t.armed?`auto ${t.threshold??"on"}${t.threshold?"%":""}`:"auto off"),{text:i.join(" · "),tone:s,free:o}}function uQ(e){const t=e.map(n=>n.headroom).filter(n=>typeof n=="number");return t.length?Math.round(Math.max(...t)):null}function dQ(e){const t=[...e].sort((s,o)=>{if(s.ready!==o.ready)return s.ready?-1:1;if(!s.ready)return s.name.localeCompare(o.name);const i=s.headroom,c=o.headroom;return i==null&&c==null?s.name.localeCompare(o.name):i==null?1:c==null?-1:c-i}),n=t.slice(0,lQ),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 ns(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 hQ={keychain_unavailable:{short:"Keychain locked on the other Mac",long:`the other Mac could not export it. On that Mac: ${p1}. The next round brings it.`}};function B0(e){return e.why?qt(hQ,e.why)??Lh(e.why):null}const g1={"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"}},fQ={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 tC(e){var r;const t=pQ[e];if(t)return t;const n=(r=/\b(E[A-Z]{3,})\b/.exec(e))==null?void 0:r[1];return n&&fQ[n]||e}const pQ={"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 Cf(e,t){var f;if(!e)return null;if(e.error&&((f=e.done)!=null&&f.length)){const p=Cf({...e,error:void 0},t),g=` · ${ns(e.at,t)}`;return{...p,text:`${p.text.slice(0,-g.length)}, then ${tC(e.error)}${g}`,tone:"bad"}}if(e.error)return g1[e.error]??{text:tC(e.error),tone:"bad"};const n=e.done??[];if(!n.length)return{text:`all logins fine · ${ns(e.at,t)}`,tone:"idle"};const r=n.filter(p=>p.ok),s=r.length===1?"login":"logins",o=n.map(p=>({d:p,why:B0(p)})).filter(p=>p.why),i=[...new Set(o.map(p=>p.why.short))],c=i.length?`, ${i.join(", ")}`:"",d=o.length?o.map(p=>`${p.d.email}: ${p.why.long}`).join(" "):void 0,h=ns(e.at,t);return r.length===n.length?{text:`${r.length} ${s} arrived${c} · ${h}`,tone:o.length?"warn":"ok",...d?{hint:d}:{}}:{text:`${r.length} of ${n.length} logins arrived${c} · ${h}`,tone:"bad",...d?{hint:d}:{}}}const mQ=9e4;function gQ({error:e,host:t,port:n},r,s,o=45317){if(e!=="handshake timed out")return null;const i=(t??"").trim();if(!i)return null;const c=r.filter(h=>h.addr===i&&h.port&&h.at>0&&s-h.at<mQ);if(!c.length)return null;const d=[...new Set(c.map(h=>h.port))];if(n!=null&&!d.includes(n)){const h=d.length===1?`port ${d[0]}`:`ports ${d.join(" and ")}`;return`A deck at ${i} is announcing itself on ${h}, not on ${n}. This deck already hears it and dials it there, so this typed row has nothing to reach.`}return`That machine is running the deck — its beacon arrives here every half minute — and what this deck sends back never gets there. That is a firewall on ${i}, not a network fault. Whoever uses it can allow two ports: UDP ${o} and TCP ${n??d[0]}.`}function Tf(e,t){var n,r;return(n=e.last)!=null&&n.error&&!g1[e.last.error]?!1:!!((r=e.last)!=null&&r.at&&t-e.last.at<q0||e.lastSeen!=null&&t-e.lastSeen<q0)}const q0=95e3;function yQ(e,t){if(!e)return{text:"checking…",tone:"idle"};if(!e.enabled)return{text:"",tone:"idle"};if(e.stalled)return{text:`could not start — ${e.stalled}`,tone:"bad"};if(!e.running)return{text:"starting…",tone:"wait"};const n=(e.pending??[]).length;if(n)return{text:n===1?"1 deck is waiting for your answer":`${n} decks are waiting for your answer`,tone:"wait"};const r=(e.peers??[]).filter(p=>p.paired!==!1||p.met);if(!r.length)return{text:"no deck paired yet",tone:"idle"};const s=p=>p.waiting?Z3(p.lastSeen,t):Tf(p,t),o=p=>{var g;return!p.waiting&&((g=p.last)==null?void 0:g.error)==="waiting for the other deck to accept this one"},i=e.aliases??{};let c=0,d=0,h=0;for(const p of Q3(r,g=>J3(g,g.peerFp??g.fp,i).name,g=>g.addr??"")){const g=p.filter(s);if(!g.length){h++;continue}c++,g.every(o)&&d++}if(c&&d===c)return{text:c===1?"1 deck found · waiting for them to accept":`${c} decks found · waiting for them to accept`,tone:"wait"};if(!c)return{text:h===1?"this deck cannot reach the one it is paired with":`this deck cannot reach any of its ${h} decks`,tone:"bad"};const f=c===1?"1 deck ready":`${c} decks ready`;return{text:h?`${f} · ${h} away`:f,tone:"ok"}}function wQ(e,t,n){if(n)return"checking…";if(e==null)return"not checked yet";const r=ns(e,t);return r==="now"?"checked just now":`checked ${r}`}function y1(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 Z3(e,t){return e!=null&&t-e<q0}function xQ(e,t){if(e==null)return{text:"one-way · has not called yet",here:!1};const n=Z3(e,t);return{text:n?"online · one-way, it calls in":`one-way · last online ${ns(e,t)}`,here:n}}function nC(e,t,n){return t?"online":e.lastSeen!=null?`last online ${ns(e.lastSeen,n)}`:e.waiting?"has not called yet":"never reached"}function vQ(e,t){if(!e)return[];const n=[],r=new Set,s=(p,g)=>p.name.localeCompare(g.name,void 0,{numeric:!0}),o=e.aliases??{};for(const p of e.pending??[])!(p!=null&&p.fp)||r.has(p.fp)||(r.add(p.fp),n.push(bQ(p,o,t)));const i=[],c=[];for(const p of e.peers??[]){const g=p.peerFp??p.fp;!g||r.has(g)||(r.add(g),!p.paired&&p.manual&&!p.met?c.push(kQ(p,g,t)):i.push(jQ(p,g,o,t)))}n.push(..._Q(i).sort(s),...c.sort(s));const d=[];for(const p of e.strangers??[])!(p!=null&&p.fp)||r.has(p.fp)||(r.add(p.fp),d.push(NQ(p,o,e.pairingMode)));n.push(...d.sort(s));const h=[];for(const p of e.declined??[])!(p!=null&&p.fp)||r.has(p.fp)||(r.add(p.fp),h.push(SQ(p,o)));n.push(...h.sort(s));const f=new Map;for(const p of n)f.set(p.name,(f.get(p.name)??0)+1);for(const p of n)(f.get(p.name)??0)<2||!p.addr||(p.state=p.quiet||!p.state?p.addr:`${p.addr} · ${p.state}`,p.quiet=!1);return n}function bQ(e,t,n){const r=Rf(t,e.fp,e.name||e.fp);return{fp:e.fp,...r,addr:e.addr??"",kind:"asks",state:`wants to pair · ${y1(e.at,n)}`,tone:"wait",here:!0,hint:`${r.name} at ${e.addr}${e.via==="tailscale"?", over Tailscale,":""} is waiting for an answer.`,...Af(e.via)}}function kQ(e,t,n){var o;const r=Cf(e.last,n),s=e.addr?`${e.addr}:${e.port}`:"";return{fp:s,name:s||e.name||t,addr:e.addr??"",kind:"dialling",state:r?U0(r):"trying…",tone:r?r.tone:"idle",here:!1,hint:(o=e.last)!=null&&o.error?`Nothing has answered at ${s} yet — ${e.last.error}.`:`Dialling ${s} until something answers.`,...Af(e.via)}}function jQ(e,t,n,r){var w,k,j,v;const s=Cf(e.last,r),o=Tf(e,r),i=e.addr?`${e.addr}:${e.port}`:"",c=e.waiting?xQ(e.lastSeen,r):null,d=c?c.here:o,h=!c&&s?d?`online · ${U0(s)}`:`${U0(s)} · ${nC(e,d,r)}`:c?c.text:nC(e,d,r),f=(w=e.last)!=null&&w.error?g1[e.last.error]:null,p=!c&&d&&!((k=e.last)!=null&&k.error)&&!(((j=e.last)==null?void 0:j.done)??[]).length,g=J3(e,t,n);return{fp:t,...g,addr:e.addr??"",kind:"paired",state:h,quiet:p,tone:f?f.tone==="bad"?"bad":"wait":s?s.tone:d?"ok":"idle",here:c?c.here:o,...Af(e.via),hint:c?`${g.name} calls this deck, and this deck has no address to call back on — so it can repair its logins from here, and this deck cannot repair from it. ${e.lastSeen==null?"It has not called since this deck started.":`It last called ${ns(e.lastSeen,r)}.`} Add its address through Add a deck, the link at the top of this view, to reach it either way.`:`${g.name}${i?` at ${i}`:""}${(v=e.last)!=null&&v.error?` — ${e.last.error}`:""}${s!=null&&s.hint?` — ${s.hint}`:""}`}}function J3(e,t,n){return e.manual&&!e.met?{name:e.addr?`${e.addr}:${e.port}`:""}:Rf(n,t,e.name||t)}function NQ(e,t,n){const r=Rf(t,e.fp,e.name||e.fp);return{fp:e.fp,...r,addr:e.addr??"",kind:"nearby",state:n==="invite"?"needs an invite":"not paired yet",tone:"idle",here:!0,hint:e.via==="tailscale"?`${r.name} at ${e.addr} is on your tailnet and nothing is shared with it.`:`${r.name} at ${e.addr} is on this network and nothing is shared with it.`,...Af(e.via)}}function SQ(e,t){const n=Rf(t,e.fp,e.name||e.fp);return{fp:e.fp,...n,addr:e.addr??"",kind:"declined",state:"you said no",tone:"idle",here:!1,hint:`${n.name} asked and was turned away. It is not asking any more.`}}function Rf(e,t,n){const r=t?e[t]:void 0;return r&&r!==n?{name:r,self:n}:{name:n}}function Af(e){return e==="tailscale"?{via:"tailscale"}:{}}function U0(e){return e.text.replace(/ · .*$/,"")}function _Q(e){return Q3(e,t=>t.name,t=>t.addr).map(EQ)}function Q3(e,t,n){const r=new Map;for(const o of e){const i=r.get(t(o));i?i.push(o):r.set(t(o),[o])}const s=[];for(const o of r.values()){const i=[...new Set(o.map(n).filter(Boolean))];if(i.length>1){for(const c of i)s.push(o.filter(d=>n(d)===c));for(const c of o)n(c)||s.push([c])}else s.push(o)}return s}function EQ(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 rC(e,t){return t?e.map(n=>t[n.fp]?{...n,name:t[n.fp]}:n):e}function qc(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 CQ(e,t){var o;if(!e)return{text:"checking…",tone:"idle",live:!1};if(!e.enabled)return{text:"Off",tone:"idle",live:!1};if(e.stalled)return{text:"could not start",tone:"bad",live:!1};if(!e.running)return{text:"starting…",tone:"wait",live:!1};const n=t.filter(i=>i.kind==="asks").length;if(n)return{text:n===1?"1 deck wants to pair":`${n} decks want to pair`,tone:"wait",live:!1};if((o=e.reach)!=null&&o.blocked)return{text:"nothing can get in",tone:"bad",live:!1};const r=t.filter(i=>i.kind==="paired");if(!r.length)return{text:"On · none paired yet",tone:"idle",live:!1};const s=r.filter(i=>i.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 TQ(e,t){const n=e.filter(f=>f.kind==="asks"),r=e.filter(f=>f.kind!=="asks"),s=r.filter(f=>f.here),o=r.filter(f=>!f.here),i=o.filter(f=>f.tone==="bad").length,c=t||s.length===0,d=c?[...s,...o]:s,h=r.filter(f=>f.kind==="paired").length;return{asks:n,rest:r,live:s,folded:o,troubled:i,showFolded:c,shown:d,paired:h}}function sC(e){return e.map(t=>({key:`${String(t.email??"").trim().toLowerCase()}@@${t.orgUuid??""}`,email:t.email??"",alive:t.alive===!0,shareable:t.collector==="ok"||t.collector==null&&!t.active}))}function RQ(e,t,n){if(!(t!=null&&t.enabled))return!1;const r=(t.peers??[]).filter(s=>s.paired&&Tf(s,n)).map(s=>{var o,i;return(i=(o=s.offers)==null?void 0:o.accounts)==null?void 0:i.find(c=>c.key===e)}).filter(s=>s!=null);return r.length>0&&r.every(s=>!s.alive)}function AQ(e,t,n,r){if(!(n!=null&&n.enabled)||n.running===!1)return!1;const s=String(t??"").trim().toLowerCase();return(n.peers??[]).some(o=>{var c,d,h,f;if(!o.paired||!Tf(o,r))return!1;const i=(d=(c=o.offers)==null?void 0:c.accounts)==null?void 0:d.find(p=>p.key===e);return!(i!=null&&i.alive)||i.shareable===!1?!1:!((f=(h=o.last)==null?void 0:h.done)!=null&&f.some(p=>p.action==="heal"&&String(p.email??"").trim().toLowerCase()===s))})}const eP=160,tP=140;function MQ(){const[e,t]=y.useState(!1),n=y.useRef(0);return y.useEffect(()=>()=>window.clearTimeout(n.current),[]),{peek:e,openPeek:c=>{window.clearTimeout(n.current),n.current=window.setTimeout(()=>t(!0),c)},shutPeek:()=>{window.clearTimeout(n.current),n.current=window.setTimeout(()=>t(!1),tP)},holdPeek:()=>window.clearTimeout(n.current),dropPeek:()=>{window.clearTimeout(n.current),t(!1)}}}function $Q(e){var t;return((t=e==null?void 0:e.detail)==null?void 0:t.fix)==="give_back"}function kr(e,t){return{text:e,giveBack:$Q(t),done:!1}}async function LQ(){try{return await(await fetch("/api/prefs/give-back",{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"})).json().catch(()=>null)}catch{return null}}const OQ={cancelled:"Nothing changed — the password dialog was closed. The folder still belongs to another user.",timed_out:"Nothing changed — the password dialog was not answered in time.",busy:"The password dialog is already open. It may be behind this window."};function IQ(e){if(e!=null&&e.ok)return{text:e.changed===!1?"The settings folder is already yours, and the deck has read it again. Try that once more.":"Done — the settings folder is yours again, and the deck has read it again. Try that once more.",giveBack:!1,done:!0};if(e==null)return{text:"Could not give it back — the deck did not answer.",giveBack:!0,done:!1};const t=e.reason?OQ[e.reason]:void 0;return t?{text:t,giveBack:!0,done:!1}:{text:"macOS did not give the folder back. The deck's log has the command that does it by hand.",giveBack:!1,done:!1}}const H0=5e3,nP=6e4;function Bt(e,t){if(t==null)return`Could not ${e} — the deck did not answer.`;const n=t.reason?FQ(t.reason,t.detail):void 0;return n?`Could not ${e} — ${n}`:t.reason?`Could not ${e} — the deck refused it (${t.reason}).`:`Could not ${e}.`}const PQ={prefs_unreadable:"this deck cannot read its settings file, so it will not write over it. The file may belong to another user, for example after ccdeck was run with sudo. The deck's log names the file.",prefs_not_writable:"this deck is not allowed to save its settings. The settings folder may belong to another user, for example after ccdeck was run with sudo, or another program may be holding the file. The deck's log names the folder."},DQ=new Set(["EACCES","EPERM"]);function FQ(e,t){const n=PQ[e];if(!n)return;const r=e==="prefs_unreadable"&&t?BQ(t):void 0,s=t!=null&&t.code&&t.code!=="BADJSON"?` Error code: ${t.code}.`:"";return(r??n)+s}function BQ({code:e,owner:t,on:n}){if(e==="BADJSON")return"its settings file is damaged and could not be moved aside, so it will not write over it. The deck's log names the file.";if(n==="folder"&&t==="other")return"this deck cannot open its settings folder, which belongs to another user, for example after ccdeck was run with sudo. The deck's log has the command that gives it back.";if(n==="folder"&&t==="you")return"this deck cannot open its own settings folder, so it will not write over what is in it. The deck's log names the folder.";if(t==="other")return"its settings file belongs to another user and could not be moved aside, so it will not write over it. The deck's log names the file.";if(t==="you")return"this deck cannot read its settings file although the file is yours, so it will not write over it. Something on this machine is blocking the read; the deck's log names the file.";if(e&&!DQ.has(e))return"this deck cannot read its settings file, so it will not write over it. The deck's log names the file."}async function vi(e,t){return(await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).json().catch(()=>null)}function qQ(e,t){const[n,r]=y.useState(null),[s,o]=y.useState([]),[i,c]=y.useState(null),[d,h]=y.useState(null),f=y.useRef(null),p=y.useCallback(P=>bf(f.current)?(f.current=P,c(P),!0):!1,[]),g=y.useCallback(()=>{f.current=null,v.current&&c(null)},[]),w=P=>{const L=Sa(i,P);return{disabled:L.disabled,"aria-busy":L.busy}},[k,j]=y.useState(()=>Date.now()),v=y.useRef(!0),b=y.useRef(H0),N=y.useCallback(async()=>{var P,L;try{const[F,A]=await Promise.all([fetch("/api/lan").then(B=>B.json()),fetch("/api/prefs").then(B=>B.json())]);if(!v.current)return;F!=null&&F.ok&&r(F),A!=null&&A.ok&&o(Array.isArray((L=(P=A.prefs)==null?void 0:P.lan)==null?void 0:L.manual)?A.prefs.lan.manual:[]),b.current=(F==null?void 0:F.enabled)===!0?H0:nP}catch{}},[]);y.useEffect(()=>{v.current=!0;let P=0;const L=async()=>{j(Date.now()),await N(),v.current&&(P=window.setTimeout(L,b.current))};return L(),()=>{v.current=!1,window.clearTimeout(P)}},[N]);const S=y.useCallback(async()=>{const P=(n==null?void 0:n.enabled)===!0;if(p("switch"))try{const L=await vi("/api/prefs",{lan:{enabled:!P}});if(!v.current)return;L!=null&&L.ok?(h(null),P||t()):h(kr(Bt(P?"turn this off":"turn this on",L),L)),await N()}catch{v.current&&h(kr(Bt(P?"turn this off":"turn this on",null)))}finally{g()}},[n==null?void 0:n.enabled,N,p,g,t]),E=y.useCallback(async(P,L,F)=>{if(!p(`${P}:${L}`))return null;let A=null;try{const B=await vi("/api/lan/peer",{action:P,fp:L});if(!v.current)return null;B!=null&&B.ok?(r(B),h(null)):(A=Bt(F,B),h(kr(A,B))),await N()}catch{A=Bt(F,null),v.current&&h(kr(A))}finally{g()}return A},[N,p,g]),C=y.useCallback(async P=>{if(!p(`drop:${P}`))return null;let L=null;try{const F=await vi("/api/prefs",{lan:{manual:s.filter(A=>A!==P)}});if(!v.current)return null;F!=null&&F.ok?(h(null),e()):(L=Bt("stop dialling that address",F),h(kr(L,F))),await N()}catch{L=Bt("stop dialling that address",null),v.current&&h(kr(L))}finally{g()}return L},[s,N,e,p,g]),$=y.useCallback(async(P,L)=>{if(!p(`alias:${P}`))return"Something else is still being saved. Try again in a moment.";try{const F=await vi("/api/lan/peer",{action:"alias",fp:P,name:L});return v.current?F!=null&&F.ok?(r(F),null):Bt("rename that deck",F):null}catch{return Bt("rename that deck",null)}finally{g()}},[p,g]),T=y.useCallback(async P=>{if(!p(`check:${P}`))return null;try{const L=await vi("/api/lan/sync",{fp:P});return v.current?L!=null&&L.ok?(r(L),e(),null):(L==null?void 0:L.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.":Bt("check that deck",L):null}catch{return Bt("check that deck",null)}finally{g()}},[p,g,e]),I=y.useCallback(async()=>{if(p("check"))try{const P=await vi("/api/lan/sync",{});if(!v.current)return;P!=null&&P.ok?(r(P),h(null)):h(kr(Bt("check the other decks",P),P)),e()}catch{v.current&&h(kr(Bt("check the other decks",null)))}finally{g()}},[p,g,e]);return{status:n,manual:s,now:k,busy:i,failure:d,dismissFailure:()=>h(null),answerGiveBack:P=>{h(P),P.done&&(N(),e())},pressProps:w,load:N,toggle:S,answer:E,dropAddress:C,rename:$,checkOne:T,checkNow:I}}function UQ(e){const[t,n]=y.useState(null),r=y.useRef(0);return y.useEffect(()=>{if(t==null)return;const o=window.setTimeout(()=>n(null),4e3);return()=>window.clearTimeout(o)},[t]),{armed:t,pressUnpair:o=>{const i=Date.now(),c=Xi({armedFor:t,target:o.fp,armedAt:r.current,now:i,gapMs:Yi});if(c==="arm"){n(o.fp),r.current=i;return}c!=="ignore"&&(n(null),e("unpair",o.fp,"unpair that deck"))}}}function rP({title:e,steps:t,finish:n,aside:r,onClose:s}){const o=y.useRef(null),i=ot(s,{focusRef:o}),c=dt(s),[d,h]=y.useState(0),f=d===t.length-1,p=t[d],g=j=>h(Math.max(0,Math.min(t.length-1,j)));y.useEffect(()=>{var j,v;Vn(((j=document.activeElement)==null?void 0:j.tagName)??null)&&((v=o.current)==null||v.focus())},[d]);const w=j=>{j.key!=="ArrowRight"&&j.key!=="ArrowLeft"||(j.preventDefault(),j.stopPropagation(),g(j.key==="ArrowRight"?d+1:d-1))},k=()=>{if(!f){g(d+1);return}n?n.act():s()};return yt.createPortal(a.jsx("div",{className:"modal-backdrop",...c,role:"presentation",children:a.jsxs("div",{ref:i,className:"modal guide",onClick:j=>j.stopPropagation(),onKeyDown:w,role:"dialog","aria-modal":"true","aria-labelledby":"guide-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsxs("div",{className:"modal-title",children:[a.jsx("span",{id:"guide-title",className:"modal-tool-name",children:e}),a.jsxs("span",{className:"modal-tool-id",children:[d+1," / ",t.length]})]}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:s,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[a.jsx("div",{className:"guide-stage",children:p.art},d),a.jsx("p",{className:"guide-line","aria-live":"polite",children:p.line}),a.jsx("p",{className:"guide-tip",children:p.tip??""}),a.jsxs("div",{className:"guide-foot",children:[a.jsx("div",{className:"guide-dots",children:t.map((j,v)=>a.jsx("button",{type:"button",className:"glyph-btn guide-dot","aria-label":`Step ${v+1} of ${t.length}`,"aria-current":v===d?"step":void 0,onClick:()=>g(v)},v))}),f&&r&&a.jsx("button",{type:"button",className:"ap-lan-word guide-aside",onClick:r.act,children:r.label}),d>0&&a.jsx("button",{type:"button",className:"btn",onClick:()=>g(d-1),children:"Back"}),a.jsx("button",{ref:o,type:"button",className:"btn primary",onClick:k,children:f?(n==null?void 0:n.label)??"Done":"Next"})]})]})]})}),document.body)}const W0={ok:"ga-ok",warn:"ga-warn",accent:"ga-accent",flight:"ga-flight"};function ir({children:e}){return a.jsx("svg",{className:"guide-art",viewBox:"0 0 440 200","aria-hidden":!0,focusable:"false",children:e})}function or({x:e,y:t=34,w:n=176,h:r=132,label:s}){return a.jsxs(a.Fragment,{children:[s&&a.jsx("text",{x:e+2,y:t-9,className:"ga-cap",children:s}),a.jsx("rect",{x:e,y:t,width:n,height:r,rx:10,className:"ga-screen"})]})}function Cr({x:e,y:t,email:n,state:r,tone:s,bars:o}){return a.jsxs(a.Fragment,{children:[a.jsx("circle",{cx:e+3,cy:t-4,r:3,className:W0[s]}),a.jsx("text",{x:e+12,y:t,className:"ga-t ga-mono",children:n}),a.jsx("text",{x:e+12,y:t+16,className:`ga-s ${W0[s]}`,children:r}),o==null?void 0:o.map((i,c)=>a.jsxs("g",{children:[a.jsx("text",{x:e,y:t+40+c*18,className:"ga-s",children:c?"7d":"5h"}),a.jsx("rect",{x:e+22,y:t+35+c*18,width:96,height:4,rx:2,className:"ga-track"}),a.jsx("rect",{x:e+22,y:t+35+c*18,width:96*i/100,height:4,rx:2,className:"ga-accent"}),a.jsxs("text",{x:e+148,y:t+40+c*18,className:"ga-s ga-accent",textAnchor:"end",children:[i,"%"]})]},c))]})}function sP({x:e,y:t,on:n}){return a.jsxs(a.Fragment,{children:[a.jsx("rect",{x:e,y:t,width:30,height:18,rx:9,className:n?"ga-switch-on":"ga-switch"}),a.jsx("circle",{cx:n?e+21:e+9,cy:t+9,r:6,className:n?"ga-knob-on":"ga-knob"})]})}function Id({x:e,y:t,name:n,here:r=!0}){return a.jsxs(a.Fragment,{children:[a.jsx("circle",{cx:e+3,cy:t-4,r:3,className:r?"ga-ok":"ga-dim"}),a.jsx("text",{x:e+12,y:t,className:r?"ga-t":"ga-s",children:n})]})}function aC({x:e,y:t,on:n}){return n?a.jsxs(a.Fragment,{children:[a.jsx("rect",{x:e,y:t,width:12,height:12,rx:3,className:"ga-accent"}),a.jsx("path",{d:`M${e+3} ${t+6.2}l2.3 2.3 4-4.6`,className:"ga-tick"})]}):a.jsx("rect",{x:e+.5,y:t+.5,width:11,height:11,rx:3,className:"ga-box"})}function oC({x:e,y:t,d:n}){return a.jsx("path",{d:n,transform:`translate(${e} ${t})`,className:"ga-glyph"})}function w1({x:e,y:t}){return a.jsx("path",{d:`M${e} ${t}l0 13 3.4-3 2.4 5.2 2-.9-2.4-5.1 4.6-.2z`,className:"ga-pointer"})}function x1(){return a.jsxs(a.Fragment,{children:[a.jsx("circle",{r:9,className:"ga-key-bed"}),a.jsxs("g",{transform:"translate(-6 -6) scale(0.857)",className:"ga-key",children:[a.jsx("circle",{cx:4.6,cy:7,r:2.6}),a.jsx("path",{d:"M7.2 7h5.2M10.6 7v2.2M12.4 7v1.6"})]})]})}function Ti({x:e,y:t,w:n,title:r,sub:s,tone:o}){return a.jsxs(a.Fragment,{children:[a.jsx("rect",{x:e,y:t,width:n,height:40,rx:8,className:"ga-screen"}),a.jsx("rect",{x:e+6,y:t+10,width:3,height:20,rx:1.5,className:W0[o]}),a.jsx("text",{x:e+16,y:t+17,className:"ga-t ga-strong",children:r}),a.jsx("text",{x:e+16,y:t+31,className:"ga-s",children:s})]})}function Pi({x:e,y:t,label:n,live:r}){return a.jsxs(a.Fragment,{children:[a.jsx("rect",{x:e,y:t,width:46,height:20,rx:10,className:r?"ga-chip-live":"ga-chip"}),a.jsx("text",{x:e+23,y:t+14,className:"ga-s ga-mono",textAnchor:"middle",children:n})]})}function Oh({x:e,y:t}){return a.jsxs(a.Fragment,{children:[a.jsx("text",{x:e,y:t,className:"ga-cap",children:"LOCAL NETWORK"}),a.jsx(sP,{x:e+118,y:t-13,on:!0})]})}function HQ(){return a.jsxs(ir,{children:[a.jsx("rect",{x:14,y:14,width:206,height:172,rx:10,className:"ga-screen"}),a.jsx("text",{x:28,y:38,className:"ga-t ga-strong",children:"Sessions"}),a.jsx("text",{x:206,y:38,className:"ga-s ga-warn",textAnchor:"end",children:"1 waiting"}),a.jsx("rect",{x:20,y:50,width:194,height:42,rx:6,className:"ga-bed-warn"}),a.jsx("circle",{cx:33,cy:64,r:7,className:"ga-ring-warn ga-ping"}),a.jsx("circle",{cx:33,cy:64,r:3.5,className:"ga-warn"}),a.jsx("text",{x:44,y:68,className:"ga-t",children:"api-server"}),a.jsx("text",{x:44,y:83,className:"ga-s ga-warn",children:"waiting 6m · Bash"}),a.jsx("circle",{cx:33,cy:108,r:3.5,className:"ga-flight"}),a.jsx("text",{x:44,y:112,className:"ga-t",children:"docs-site"}),a.jsx("text",{x:44,y:127,className:"ga-s",children:"running · 12 tools"}),a.jsx("circle",{cx:33,cy:150,r:3.5,className:"ga-ok"}),a.jsx("text",{x:44,y:154,className:"ga-t",children:"billing"}),a.jsx("text",{x:44,y:169,className:"ga-s",children:"done · $0.84"}),a.jsx("path",{d:"M216 71C234 71 230 100 244 100",className:"ga-arc"}),a.jsx("path",{d:"M239 96l5 4-5 4",className:"ga-arrow"}),a.jsx("rect",{x:248,y:44,width:178,height:112,rx:10,className:"ga-screen"}),a.jsx("text",{x:262,y:64,className:"ga-cap",children:"API-SERVER"}),a.jsx("line",{x1:248,y1:74,x2:426,y2:74,className:"ga-line"}),a.jsx("text",{x:262,y:96,className:"ga-s ga-mono",children:"Bash(npm test)"}),a.jsx("text",{x:262,y:116,className:"ga-t ga-mono ga-warn",children:"Allow this command?"}),a.jsx("text",{x:262,y:136,className:"ga-s ga-mono",children:"> 1. Yes 2. No"})]})}function WQ(){return a.jsxs(ir,{children:[a.jsx("path",{d:"M136 100C166 100 166 38 196 38",className:"ga-edge ga-flow"}),a.jsx("path",{d:"M136 100H196",className:"ga-edge ga-flow"}),a.jsx("path",{d:"M136 100C166 100 166 162 196 162",className:"ga-edge-done"}),a.jsx("path",{d:"M308 38H326M308 100H326",className:"ga-edge"}),a.jsx(Ti,{x:20,y:80,w:116,title:"main",sub:"Opus 5 · 9 tools",tone:"accent"}),a.jsx(Ti,{x:196,y:18,w:112,title:"explore",sub:"Haiku · 14 tools",tone:"flight"}),a.jsx(Ti,{x:196,y:80,w:112,title:"tests",sub:"Sonnet · 6 tools",tone:"flight"}),a.jsx(Ti,{x:196,y:142,w:112,title:"review",sub:"done · 38s",tone:"ok"}),a.jsx(Pi,{x:326,y:28,label:"Read"}),a.jsx(Pi,{x:380,y:28,label:"Grep",live:!0}),a.jsx(Pi,{x:326,y:90,label:"Bash",live:!0})]})}function iC({x:e,y:t,label:n,pct:r,note:s}){return a.jsxs(a.Fragment,{children:[a.jsx("text",{x:e,y:t,className:"ga-s",children:n}),a.jsxs("text",{x:e+194,y:t,className:"ga-s ga-accent",textAnchor:"end",children:[r,"%"]}),a.jsx("rect",{x:e,y:t+7,width:194,height:5,rx:2.5,className:"ga-track"}),a.jsx("rect",{x:e,y:t+7,width:194*r/100,height:5,rx:2.5,className:"ga-accent"}),a.jsx("text",{x:e,y:t+26,className:"ga-s",children:s})]})}function zQ(){return a.jsxs(ir,{children:[a.jsx("rect",{x:14,y:30,width:172,height:140,rx:10,className:"ga-screen"}),a.jsx("text",{x:30,y:56,className:"ga-cap",children:"THIS SESSION"}),a.jsx("text",{x:30,y:98,className:"ga-big",children:"$3.66"}),a.jsx("text",{x:30,y:122,className:"ga-s",children:"Opus 5 · 1.2M tokens"}),a.jsx("text",{x:30,y:150,className:"ga-s",children:"$21.40 today"}),a.jsx("rect",{x:200,y:30,width:226,height:140,rx:10,className:"ga-screen"}),a.jsx("text",{x:216,y:56,className:"ga-cap",children:"CLAUDE QUOTA"}),a.jsx(iC,{x:216,y:80,label:"5-hour window",pct:24,note:"resets in 53m"}),a.jsx(iC,{x:216,y:124,label:"7-day window",pct:61,note:"resets in 4d"})]})}function VQ(){return a.jsxs(ir,{children:[a.jsx("rect",{x:14,y:40,width:172,height:120,rx:10,className:"ga-canvas"}),a.jsx(Ti,{x:30,y:80,w:140,title:"tests",sub:"Sonnet 5 · 6 tools",tone:"flight"}),a.jsx(w1,{x:156,y:106}),a.jsx("path",{d:"M170 92C186 92 184 60 200 60",className:"ga-arc"}),a.jsx("path",{d:"M195 56l5 4-5 4",className:"ga-arrow"}),a.jsx(or,{x:200,y:22,w:226,h:160}),a.jsx("text",{x:214,y:46,className:"ga-t ga-strong",children:"tests"}),a.jsx("text",{x:412,y:46,className:"ga-s",textAnchor:"end",children:"Sonnet 5 · 38s"}),a.jsx("line",{x1:200,y1:56,x2:426,y2:56,className:"ga-line"}),a.jsx("text",{x:214,y:76,className:"ga-cap",children:"PROMPT"}),a.jsx("text",{x:214,y:92,className:"ga-t",children:"Run the suite and fix what fails"}),a.jsx("text",{x:214,y:116,className:"ga-cap",children:"TOOLS · 6"}),a.jsx(Pi,{x:214,y:122,label:"Read"}),a.jsx(Pi,{x:266,y:122,label:"Edit"}),a.jsx(Pi,{x:318,y:122,label:"Bash",live:!0}),a.jsx("text",{x:214,y:164,className:"ga-cap",children:"TOKENS"}),a.jsx("text",{x:214,y:178,className:"ga-s ga-mono",children:"41k in · 2.1k out · $0.12"})]})}function GQ(){const e=[18,24,28,14,22,26,30,16,24,28,20,26];return a.jsxs(ir,{children:[a.jsx(or,{x:14,y:20,w:412,h:160}),a.jsx("text",{x:28,y:44,className:"ga-t ga-strong",children:"This machine"}),a.jsx("text",{x:412,y:44,className:"ga-s",textAnchor:"end",children:"12 cores · up 10d"}),a.jsx("line",{x1:14,y1:56,x2:426,y2:56,className:"ga-line"}),a.jsx("text",{x:28,y:76,className:"ga-cap",children:"CORES"}),e.map((t,n)=>a.jsxs("g",{children:[a.jsx("rect",{x:28+n*15,y:82,width:10,height:30,rx:2,className:"ga-track"}),a.jsx("rect",{x:28+n*15,y:112-t,width:10,height:t,rx:2,className:"ga-accent"})]},n)),a.jsx("text",{x:28,y:136,className:"ga-cap",children:"MEMORY"}),a.jsx("rect",{x:28,y:143,width:178,height:5,rx:2.5,className:"ga-track"}),a.jsx("rect",{x:28,y:143,width:105,height:5,rx:2.5,className:"ga-accent"}),a.jsx("text",{x:28,y:165,className:"ga-s",children:"18.9 GB of 32.0 GB"}),a.jsx("text",{x:240,y:76,className:"ga-cap",children:"THERMAL"}),a.jsx("text",{x:240,y:100,className:"ga-big",children:"66 °C"}),a.jsx("text",{x:240,y:118,className:"ga-s ga-ok",children:"running at full speed"}),a.jsx("text",{x:240,y:142,className:"ga-cap",children:"BUSIEST PROCESSES"}),a.jsx("text",{x:240,y:160,className:"ga-s ga-mono",children:"node · claude"}),a.jsx("text",{x:412,y:160,className:"ga-s ga-mono",textAnchor:"end",children:"38%"}),a.jsx("text",{x:240,y:176,className:"ga-s ga-mono",children:"esbuild"}),a.jsx("text",{x:412,y:176,className:"ga-s ga-mono",textAnchor:"end",children:"21%"})]})}function KQ(){return a.jsxs(ir,{children:[a.jsx("rect",{x:14,y:40,width:188,height:120,rx:10,className:"ga-screen"}),a.jsx("text",{x:28,y:60,className:"ga-cap",children:"~/MY-PROJECT"}),a.jsx("line",{x1:14,y1:70,x2:202,y2:70,className:"ga-line"}),a.jsxs("text",{x:28,y:100,className:"ga-t ga-mono",children:[a.jsx("tspan",{className:"ga-accent",children:"$"})," claude"]}),a.jsx("rect",{x:86,y:90,width:7,height:13,className:"ga-caret ga-blink"}),a.jsx("text",{x:28,y:130,className:"ga-s ga-mono",children:"or: codex"}),a.jsx("path",{d:"M210 100H238",className:"ga-arc"}),a.jsx("path",{d:"M233 95l6 5-6 5",className:"ga-arrow"}),a.jsx("rect",{x:250,y:40,width:176,height:120,rx:10,className:"ga-canvas"}),a.jsx("g",{className:"ga-pop",children:a.jsx(Ti,{x:278,y:80,w:120,title:"my-project",sub:"Opus 5 · live",tone:"accent"})})]})}function YQ(){return a.jsxs(ir,{children:[a.jsx(or,{x:14,y:16,w:232,h:170}),a.jsx("text",{x:28,y:40,className:"ga-t ga-strong",children:"Claude accounts"}),a.jsx(oC,{x:196,y:33,d:"M7 2.2v9.6M2.2 7h9.6"}),a.jsx(oC,{x:220,y:33,d:"M3.3 10.7L10.7 3.3M5.2 3.3h5.5v5.5"}),a.jsx("line",{x1:14,y1:52,x2:246,y2:52,className:"ga-line"}),a.jsx(Cr,{x:28,y:74,email:"work@team.dev",state:"working",tone:"ok",bars:[24,61]}),a.jsx("rect",{x:190,y:62,width:44,height:18,rx:9,className:"ga-accent"}),a.jsx("text",{x:212,y:74,className:"ga-s ga-on-accent",textAnchor:"middle",children:"active"}),a.jsx("line",{x1:14,y1:140,x2:246,y2:140,className:"ga-line"}),a.jsx(Cr,{x:28,y:160,email:"personal@me.dev",state:"signed in",tone:"ok"}),a.jsx("rect",{x:188,y:148,width:46,height:18,rx:9,className:"ga-chip"}),a.jsx("text",{x:211,y:160,className:"ga-s",textAnchor:"middle",children:"switch"}),a.jsx(w1,{x:221,y:161}),a.jsx("path",{d:"M250 40C270 40 262 78 282 78",className:"ga-arc"}),a.jsx("path",{d:"M277 74l5 4-5 4",className:"ga-arrow"}),a.jsx(or,{x:282,y:62,w:144,h:64,label:"ANOTHER MACHINE"}),a.jsx("g",{className:"ga-pop",children:a.jsx(Cr,{x:296,y:92,email:"work@team.dev",state:"shared here",tone:"ok"})})]})}function XQ(){return a.jsxs(ir,{children:[a.jsx(or,{x:14,label:"THIS MACHINE"}),a.jsx(Oh,{x:28,y:60}),a.jsx("g",{className:"ga-swap-out",children:a.jsx(Cr,{x:28,y:98,email:"work@team.dev",state:"login expired",tone:"warn"})}),a.jsx("g",{className:"ga-swap-in",children:a.jsx(Cr,{x:28,y:98,email:"work@team.dev",state:"working again",tone:"ok",bars:[24,61]})}),a.jsx(or,{x:250,label:"ANOTHER MACHINE"}),a.jsx(Oh,{x:264,y:60}),a.jsx(Cr,{x:264,y:98,email:"work@team.dev",state:"working",tone:"ok",bars:[24,61]}),a.jsx("path",{d:"M246 120C234 80 206 80 194 120",className:"ga-arc"}),a.jsx("g",{className:"ga-travel ga-travel-low",transform:"translate(220 90)",children:a.jsx(x1,{})})]})}const ZQ=[{art:a.jsx(HQ,{}),line:"Sessions waiting on you top the session list, longest wait first.",tip:"A tone and a system notification when one stops to ask. Both behind the topbar gear."},{art:a.jsx(WQ,{}),line:"Every agent and subagent is a node. Tool calls light up as they run."},{art:a.jsx(VQ,{}),line:"Double-click any node: its prompt, every tool call, tokens and timing."},{art:a.jsx(zQ,{}),line:"What each session costs, and how much quota is left."},{art:a.jsx(GQ,{}),line:"Cores, memory and heat while the agents run, and what is hogging them."},{art:a.jsx(YQ,{}),line:"Several Claude accounts: switch, add one, share one to another machine."},{art:a.jsx(XQ,{}),line:"Your machines repair each other's expired logins over the local network.",tip:"Open it from the row at the foot of the Claude accounts panel."},{art:a.jsx(KQ,{}),line:"Run claude or codex in any folder. It shows up here on its own."}];function JQ(){return a.jsxs(ir,{children:[a.jsx(or,{x:14,label:"THIS MACHINE"}),a.jsx(Cr,{x:28,y:64,email:"work@team.dev",state:"login expired",tone:"warn"}),a.jsx("rect",{x:40,y:94,width:86,height:20,rx:10,className:"ga-pill-warn"}),a.jsx("text",{x:83,y:108,className:"ga-s ga-warn",textAnchor:"middle",children:"sign in again"}),a.jsx("line",{x1:198,y1:100,x2:242,y2:100,className:"ga-off"}),a.jsx(or,{x:250,label:"ANOTHER MACHINE"}),a.jsx(Cr,{x:264,y:64,email:"work@team.dev",state:"working",tone:"ok",bars:[24,61]})]})}function QQ(){return a.jsxs(ir,{children:[a.jsx(or,{x:14,label:"THIS MACHINE"}),a.jsx(Oh,{x:28,y:60}),a.jsx(Id,{x:28,y:92,name:"Ana's MacBook"}),a.jsx(Id,{x:28,y:114,name:"Dorin's PC"}),a.jsx(or,{x:250,label:"ANOTHER MACHINE"}),a.jsx(Oh,{x:264,y:60}),a.jsx(Id,{x:264,y:92,name:"Your MacBook"}),a.jsx(Id,{x:264,y:114,name:"Dorin's PC"}),a.jsx("line",{x1:196,y1:100,x2:244,y2:100,className:"ga-arc"}),a.jsx("circle",{cx:220,cy:100,r:10,className:"ga-ring ga-ping"}),a.jsx("circle",{cx:220,cy:100,r:10,className:"ga-ring ga-ping ga-ping-2"}),a.jsx("circle",{cx:220,cy:100,r:3,className:"ga-accent"})]})}function eee(){return a.jsxs(ir,{children:[a.jsx("rect",{x:90,y:18,width:260,height:164,rx:10,className:"ga-screen"}),a.jsx("text",{x:106,y:42,className:"ga-t ga-strong",children:"This deck on the network"}),a.jsx("line",{x1:90,y1:54,x2:350,y2:54,className:"ga-line"}),a.jsx("text",{x:106,y:76,className:"ga-cap",children:"SHARE THESE ACCOUNTS"}),a.jsx(aC,{x:106,y:88,on:!0}),a.jsx("text",{x:126,y:98,className:"ga-t ga-mono",children:"work@team.dev"}),a.jsx(aC,{x:106,y:112}),a.jsx("text",{x:126,y:122,className:"ga-s ga-mono",children:"personal@me.dev"}),a.jsx("text",{x:106,y:150,className:"ga-cap",children:"PAIRING"}),a.jsx("text",{x:106,y:168,className:"ga-s",children:"Say yes to every deck that asks"}),a.jsx(sP,{x:304,y:157,on:!0}),a.jsx(w1,{x:115,y:97})]})}function tee(){return a.jsxs(ir,{children:[a.jsx(or,{x:14,label:"THIS MACHINE"}),a.jsx("g",{className:"ga-swap-out",children:a.jsx(Cr,{x:28,y:64,email:"work@team.dev",state:"login expired",tone:"warn"})}),a.jsx("g",{className:"ga-swap-in",children:a.jsx(Cr,{x:28,y:64,email:"work@team.dev",state:"working again",tone:"ok",bars:[24,61]})}),a.jsx(or,{x:250,label:"ANOTHER MACHINE"}),a.jsx(Cr,{x:264,y:64,email:"work@team.dev",state:"working",tone:"ok",bars:[24,61]}),a.jsx("path",{d:"M246 96C234 56 206 56 194 96",className:"ga-arc"}),a.jsx("g",{className:"ga-travel",transform:"translate(220 66)",children:a.jsx(x1,{})})]})}const nee=[{art:a.jsx(JQ,{}),line:"A login can expire on one machine while it still works on another."},{art:a.jsx(QQ,{}),line:"Both decks are on. They find each other and ask to pair.",tip:"Not showing up? Add a deck, the link at the top, takes an address or invite."},{art:a.jsx(eee,{}),line:"Tick which logins this machine may hand out. Nothing is shared until you do."},{art:a.jsx(tee,{}),line:"An expired login is copied from a paired machine within a minute."}];function ree(){return a.jsxs("svg",{className:"guide-art",viewBox:"0 0 232 60","aria-hidden":!0,focusable:"false",children:[a.jsx("rect",{x:1,y:14,width:78,height:42,rx:7,className:"ga-screen"}),a.jsx("circle",{cx:13,cy:29,r:3,className:"ga-warn"}),a.jsx("rect",{x:21,y:27,width:46,height:4,rx:2,className:"ga-track"}),a.jsx("rect",{x:13,y:39,width:40,height:3,rx:1.5,className:"ga-track"}),a.jsx("rect",{x:153,y:14,width:78,height:42,rx:7,className:"ga-screen"}),a.jsx("circle",{cx:165,cy:29,r:3,className:"ga-ok"}),a.jsx("rect",{x:173,y:27,width:46,height:4,rx:2,className:"ga-track"}),a.jsx("rect",{x:165,y:39,width:40,height:3,rx:1.5,className:"ga-accent"}),a.jsx("path",{d:"M150 36C138 6 94 6 82 36",className:"ga-arc"}),a.jsx("g",{transform:"translate(116 13)",children:a.jsx(x1,{})})]})}const see={panel:"Nothing here is stuck: whoever pastes an invite is the one dialling out. Ask them for one and paste it behind Add a deck, the link above, where an address can be typed too.",dialog:"Nothing here is stuck: whoever pastes an invite is the one dialling out. Ask them for one and paste it below, or type their address."},aee=1600;function aP({reach:e,where:t}){const[n,r]=y.useState(!1),s=y.useRef(!0);y.useEffect(()=>()=>{s.current=!1},[]);const o=(e==null?void 0:e.steps)??[],i=y.useCallback(async()=>{await Mo(o.join(`
|
|
93
|
-
`))&&s.current&&(r(!0),window.setTimeout(()=>{s.current&&r(!1)},aee))},[o]);if(!(e!=null&&e.blocked))return null;const c=e.shell==="sh",d=!!e.tool;return a.jsxs("div",{className:"ap-lan-reach",children:[a.jsx("p",{className:"lan-warn",children:e.text}),a.jsx("p",{className:"lan-note",children:see[t]}),o.length>0&&a.jsxs("details",{className:"ap-lan-reach-fix",children:[a.jsx("summary",{children:"or let them find this deck on their own"}),a.jsxs("p",{className:"lan-note",children:[d?a.jsx(a.Fragment,{children:"Run this in a terminal on this machine. It applies at once, and this note goes away when another deck connects."}):c?a.jsx(a.Fragment,{children:"Run this in a terminal on this machine, then restart the deck."}):a.jsxs(a.Fragment,{children:["Run this in PowerShell ",a.jsx("strong",{children:"as Administrator"}),", then restart the deck."]}),e.category==="Public"&&a.jsx(a.Fragment,{children:" The first line marks this network as a home or office one — leave it out on a network you do not trust."}),e.unsure&&a.jsxs(a.Fragment,{children:[" ",e.unsure]})]}),a.jsx("pre",{className:"ap-lan-cmd",children:a.jsx("code",{children:o.join(`
|
|
94
|
-
`)})}),a.jsx("button",{type:"button",className:"ap-manage-btn",onClick:()=>void i(),title:c?"Copy these lines, then paste them into a terminal":"Copy these lines, then paste them into an elevated PowerShell",children:n?"copied":"copy command"})]})]})}function oee(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 iee(e,t){const n=Math.max(0,Math.round((e-t)/1e3));return`${Math.floor(n/60)}:${String(n%60).padStart(2,"0")}`}async function fg(e,t){return(await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).json().catch(()=>null)}const lee={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."},cee={not_running:"This deck is not on the network yet. Turn Local network on, then make one."};function lC(e,t,n){return(t==null?void 0:t.reason)&&e[t.reason]||Bt(n,t)}function uee({status:e,manual:t,startWith:n,onClose:r,onChanged:s}){const o=y.useRef(null),i=y.useRef(null),c=y.useRef(null),d=y.useRef(null),h=e.pairingMode==="invite",f=ot(r,{focusRef:h?i:o}),p=dt(r),[g,w]=y.useState(""),[k,j]=y.useState(""),[v,b]=y.useState(null),[N,S]=y.useState(null),[E,C]=y.useState(null),[$,T]=y.useState(null),[I,O]=y.useState(()=>Date.now());y.useEffect(()=>{const Y=window.setInterval(()=>O(Date.now()),1e3);return()=>window.clearInterval(Y)},[]);const U=y.useRef(!0);y.useEffect(()=>()=>{U.current=!1},[]);const P=y.useRef(null),L=y.useRef(null),F=y.useCallback(Y=>bf(P.current)?(P.current=Y,C(Y),!0):!1,[]),A=y.useCallback(()=>{P.current=null,U.current&&C(null)},[]),B=Y=>{const J=Sa(E,Y);return{disabled:J.disabled,"aria-busy":J.busy}},D=Y=>(v==null?void 0:v.field)===Y?{"aria-invalid":!0,"aria-describedby":"lan-add-failure"}:{},K=Y=>b(J=>J&&J.field===Y?null:J),G=y.useCallback(async()=>{if(h)return;const Y=oee(g);if(!Y){b({text:dee(g),field:"addr"});return}const J=`${Y.addr}:${Y.port}`,ee=e.peers.find(ne=>ne.addr===Y.addr&&ne.port===Y.port&&ne.paired);if(ee){b({text:`Already paired with ${ee.name} at that address.`,field:"addr"});return}if(t.includes(J)){b({text:"This deck already calls that address.",field:"addr"});return}if(F("add"))try{const ne=await fg("/api/prefs",{lan:{manual:[...t,J]}});if(!U.current)return;ne!=null&&ne.ok?(b(null),w(""),s(),r()):b({text:Bt("add that address",ne),field:"addr"})}catch{U.current&&b({text:Bt("add that address",null),field:"addr"})}finally{A()}},[g,h,t,e.peers,s,r,F,A]),H=y.useCallback(async Y=>{if(!F(`invite:${Y}`))return;const J=Y==="make"?"make an invite":"cancel that invite";try{const ee=await fg("/api/lan/invite",{action:Y});if(!U.current)return;ee!=null&&ee.ok?(L.current=Y,b(null),S(null),s()):b({text:lC(cee,ee,J)})}catch{U.current&&b({text:Bt(J,null)})}finally{A()}},[s,F,A]),q=y.useCallback(async()=>{const Y=k.trim();if(!(!Y||!F("join"))){T(null);try{const J=await fg("/api/lan/invite",{action:"join",token:Y});if(!U.current)return;J!=null&&J.ok?(j(""),b(null),s(),r()):(J==null?void 0:J.reason)==="unreachable"&&Array.isArray(J.tried)&&J.tried.length?(T(J.tried),b(null)):(T(null),b({text:lC(lee,J,"use that invite"),field:"join"}))}catch{U.current&&b({text:Bt("use that invite",null),field:"join"})}finally{A()}}},[k,s,r,F,A]),M=y.useCallback(async(Y,J)=>{try{await navigator.clipboard.writeText(Y),S(J),window.setTimeout(()=>{U.current&&S(ee=>ee===J?null:ee)},1600)}catch{b({text:"Could not copy it — select the text and copy it by hand."})}},[]),V=e.invite&&e.invite.expiresAt>I?e.invite:null,Z=y.useRef(!1);y.useEffect(()=>{n!=="invite"||Z.current||V||(Z.current=!0,H("make"))},[n,V,H]);const W=y.useRef(!1);y.useEffect(()=>{var Y;n!=="invite"||W.current||!V||(W.current=!0,(Y=c.current)==null||Y.focus())},[n,V]),y.useEffect(()=>{var J,ee;const Y=L.current;!Y||Y==="make"!=!!V||(L.current=null,Vn(((J=document.activeElement)==null?void 0:J.tagName)??null)&&((ee=(Y==="make"?c:d).current)==null||ee.focus()))},[V]);const X=e.port!=null?(e.addrs??[]).map(Y=>`${Y}:${e.port}`):[];return yt.createPortal(a.jsx("div",{className:"modal-backdrop",...p,role:"presentation",children:a.jsxs("div",{ref:f,className:"modal lan-add",onClick:Y=>Y.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-add-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{id:"lan-add-title",className:"modal-tool-name",children:"Add a deck"})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{className:"glyph-btn",onClick:r,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[v&&a.jsxs("div",{className:"ap-failure",role:"alert",children:[a.jsx("span",{id:"lan-add-failure",className:"ap-failure-text",children:v.text}),a.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>b(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),a.jsx(aP,{reach:e.reach,where:"dialog"}),h&&a.jsx("div",{className:"modal-section",children:a.jsx("p",{className:"lan-note",children:"Adding by address is off while this deck pairs only by invite."})}),!h&&a.jsxs("div",{className:"modal-section",children:[a.jsx("h3",{className:"lan-h",children:"By address"}),a.jsxs("div",{className:"ap-lan-row",children:[a.jsx("input",{ref:o,className:"ap-manage-input ap-lan-input","aria-label":"Another deck's address",value:g,placeholder:"192.168.1.5:54340",spellCheck:!1,...D("addr"),onChange:Y=>{w(Y.target.value),K("addr")},onKeyDown:Y=>{Y.key==="Enter"&&G()}}),g.trim()!==""&&a.jsx("button",{type:"button",className:"ap-manage-btn",...B("add"),onClick:()=>void G(),title:"Add it to the decks this one calls, starting now.",children:"add"})]}),a.jsx("p",{className:"lan-note",children:"This deck calls that address until somebody there accepts."}),e.port!=null&&X.length>0&&a.jsxs("p",{className:"lan-note",children:["They type this deck’s own address into the same field on theirs:"," ",X.map((Y,J)=>a.jsxs("span",{children:[J>0&&" or ",a.jsx("code",{className:"ap-lan-code",children:Y})]},Y)),a.jsx("button",{type:"button",className:"ap-lan-word lan-copy",...B("copy:mine"),onClick:()=>void M(X.join(" "),"mine"),title:"Copy this deck's address, to send to whoever is adding it",children:N==="mine"?"copied":"copy"})]})]}),a.jsxs("div",{className:"modal-section",children:[a.jsxs("h3",{className:"lan-h",children:["With an invite",!V&&a.jsx("button",{type:"button",className:"ap-lan-word lan-h-act",ref:d,...B("invite:make"),onClick:()=>void H("make"),title:"One piece of text you send them. They paste it, and the two decks pair — nobody has to press anything here.",children:E==="invite:make"?"making…":"make one to send"})]}),a.jsxs("div",{className:"ap-lan-row",children:[a.jsx("input",{ref:i,className:"ap-manage-input ap-lan-input","aria-label":"An invite you were sent",value:k,placeholder:"paste one you were sent",spellCheck:!1,...D("join"),onChange:Y=>{j(Y.target.value),T(null),K("join")},onKeyDown:Y=>{Y.key==="Enter"&&q()}}),k.trim()!==""&&a.jsx("button",{type:"button",className:"ap-manage-btn",...B("join"),onClick:()=>void q(),title:"Reach that deck and pair with it. Nobody has to press anything there.",children:E==="join"?"joining…":"join"})]}),a.jsx("p",{className:"lan-note",children:"Pasting one pairs both decks on the spot — nobody has to accept."}),$&&a.jsxs("div",{className:"ap-lan-tried",children:[a.jsx("span",{className:"lan-note",children:"Nothing answered at any address in that invite. Check that deck is running with its Local network switch on."}),$.map(Y=>a.jsxs("span",{className:"ap-lan-tried-row",children:[a.jsx("code",{className:"ap-lan-code",children:Y.addr}),a.jsx("span",{className:"ap-lan-bad",children:Y.why})]},Y.addr))]}),V&&a.jsxs("div",{className:"ap-lan-invite",children:[a.jsxs("div",{className:"ap-lan-invite-head",children:[a.jsx("span",{className:"ap-lan-invite-title",children:"Send this to them"}),a.jsxs("span",{className:"ap-lan-invite-left",id:"lan-invite-left",children:[iee(V.expiresAt,I)," left"]})]}),a.jsx("code",{className:"ap-lan-token",children:V.token}),a.jsxs("div",{className:"ap-lan-acts",children:[a.jsx("button",{type:"button",className:"ap-manage-btn",ref:c,...B("copy:invite"),"aria-label":N==="invite"?"Invite copied":"Copy invite","aria-describedby":"lan-invite-left",onClick:()=>void M(V.token,"invite"),title:"Copy it, and send it however you already talk to them",children:N==="invite"?"copied":"copy"}),a.jsx("button",{type:"button",className:"ap-manage-btn",...B("invite:withdraw"),onClick:()=>void H("withdraw"),title:"Cancel it. Anybody already holding the text can no longer use it.",children:"cancel"})]}),a.jsx("p",{className:"lan-warn",children:"Anyone who gets this text can pair with this deck until it runs out."})]})]})]})]})}),document.body)}function dee(e){const t=(e??"").trim();if(t==="")return"Type an address and a port, like 192.168.1.5:54340.";if(!t.startsWith("[")&&(t.match(/:/g)??[]).length>1)return"Too many colons to split. Use that deck's IPv4 address or its name, like 192.168.1.5:54340.";if(!t.includes(":"))return`Add the port too, like ${t}:54340.`;const n=t.slice(t.lastIndexOf(":")+1).trim();return n===""?"That is missing its port — try 192.168.1.5:54340.":/^\d+$/.test(n)?`A port runs from 1 to 65535, and this one is ${n}.`:`A port is a number, and this one is "${n}".`}function hee({asks:e,pressProps:t,answer:n}){return a.jsx("div",{className:"ap-lan-asks",role:"alert",children:e.map(r=>a.jsxs("div",{className:"ap-lan-ask",children:[a.jsxs("span",{className:"ap-lan-ask-what",children:[a.jsx("strong",{className:"ap-lan-peer-name",children:r.name})," at ",a.jsx("code",{className:"ap-lan-code",children:r.addr})," wants to pair"]}),a.jsxs("span",{className:"ap-lan-ask-fp",id:`lan-ask-fp-${r.fp}`,children:["fingerprint ",a.jsx("code",{className:"ap-lan-code",children:r.fp})]}),a.jsxs("span",{className:"ap-lan-ask-acts",children:[a.jsx("button",{type:"button",className:"ap-manage-btn",...t(`accept:${r.fp}`),"aria-label":`Accept ${r.name}`,"aria-describedby":`lan-ask-fp-${r.fp}`,onClick:()=>void n("accept",r.fp,"accept that deck"),title:`Talk to this deck from now on. Its fingerprint is ${r.fp} — check it matches the one on their screen before you accept.`,children:"accept"}),a.jsx("button",{type:"button",className:"ap-manage-btn",...t(`dismiss:${r.fp}`),"aria-label":`Decline ${r.name}`,"aria-describedby":`lan-ask-fp-${r.fp}`,onClick:()=>void n("dismiss",r.fp,"decline that request"),title:"Say no. Nothing is shared, and that deck is told rather than left waiting.",children:"decline"})]})]},r.fp))})}function fee({rows:e,pairingMode:t,armed:n,pressProps:r,answer:s,dropAddress:o,onUnpair:i,onOpenPeer:c,onInvite:d}){return a.jsx("ul",{className:"ap-lan-here",children:e.map((h,f)=>a.jsxs("li",{className:"ap-lan-who","data-tone":h.tone,children:[a.jsx("i",{className:h.here?"ap-pulse":"ap-dot","aria-hidden":!0}),a.jsxs("span",{className:"ap-lan-who-name","aria-hidden":!0,children:[h.name,h.via==="tailscale"&&a.jsx("span",{className:"ap-lan-via",children:" · Tailscale"})]}),a.jsx("button",{type:"button",className:"ap-lan-who-open","aria-haspopup":"dialog","aria-describedby":`lan-who-state-${f}`,onClick:()=>c(h.fp),children:a.jsxs("span",{className:"vis-hidden",children:[h.name,h.via==="tailscale"?", over Tailscale":"",", details"]})}),a.jsx("span",{id:`lan-who-state-${f}`,className:h.quiet?"vis-hidden":"ap-lan-who-when",children:h.state}),h.kind==="nearby"&&t!=="invite"&&a.jsx("button",{type:"button",className:"ap-manage-btn ap-lan-do",...r(`accept:${h.fp}`),onClick:()=>void s("accept",h.fp,"reach that deck"),"aria-label":`Ask ${h.name} to pair`,title:`Send ${h.name} a request. Somebody at that machine has to accept it before anything is shared. Its fingerprint is ${h.fp}.`,children:"ask"}),(h.kind==="nearby"||h.kind==="declined")&&t==="invite"&&a.jsx("button",{type:"button",className:"ap-manage-btn ap-lan-do","aria-haspopup":"dialog",onClick:d,"aria-label":`Invite ${h.name} to pair`,title:`This deck pairs only by invite. Make one and send it to whoever is at ${h.name}.`,children:"invite"}),h.kind==="paired"&&a.jsx("button",{type:"button",className:`ap-manage-btn ap-lan-do danger${n===h.fp?" armed":""}`,...r(`unpair:${h.fp}`),onClick:()=>i(h),"aria-label":n===h.fp?`Confirm unpairing ${h.name}`:`Unpair ${h.name}`,title:n===h.fp?"Press again to stop talking to this deck. Logins it already has stay with it.":"Stop talking to this deck from now on",children:n===h.fp?"confirm":"unpair"}),h.kind==="dialling"&&a.jsx("button",{type:"button",className:"ap-manage-btn ap-lan-do",...r(`drop:${h.fp}`),onClick:()=>void o(h.fp),"aria-label":`Stop dialling ${h.name}`,title:"Stop trying this address. Nothing was ever paired here.",children:"stop"}),h.kind==="declined"&&t!=="invite"&&a.jsx("button",{type:"button",className:"ap-manage-btn ap-lan-do",...r(`allow:${h.fp}`),onClick:()=>void s("allow",h.fp,"let that deck ask again"),"aria-label":`Let ${h.name} ask again`,title:"Take the no back. That deck is still trying, so the request comes round again on its own.",children:"allow"})]},`${h.kind}:${h.fp}`))})}function pee(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 mee({on:e,status:t}){return a.jsxs(a.Fragment,{children:[e&&a.jsx(aP,{reach:t==null?void 0:t.reach,where:"panel"}),e&&(t==null?void 0:t.deaf)&&a.jsx("p",{className:"ap-lan-fine",children:t.deaf}),e&&(t==null?void 0:t.lanTunneled)&&a.jsx("p",{className:"ap-lan-fine",children:pee(t)})]})}const cC=["online","offline","loose"],gee={online:0,offline:1,loose:2};function yee(e){return e.kind==="declined"?null:e.kind==="paired"?e.here?"online":"offline":"loose"}const wee=76,xee=62,Ih=96,vee={1:[.62],2:[.58,1],3:[.42,.72,1]},bee=.2,kee=.16,jee=.05,Nee=20,See=17,Pd=7,_ee=30,Eee=116,Cee=6.6,Tee=6,Ree=e=>v1(e,null),Aee=1.5,Mee=80,$ee=.45,uC=40,Lee=64,Oee=150,dC=.3,hC=84,fC=8,Iee=1.3,Ph=6,Pee=5.94,pC=7,mC=16,tc=4,gC=.16;function z0(e,t){return Math.PI*(3*(e+t)-Math.sqrt((3*e+t)*(e+3*t)))}function oP(e,t){return t<-Math.abs(e)*.6?"top":"bottom"}function Dee(e,t){if(e<=2)return t%2===0?0:90;const n=360/e;return-90+(t%2===0?0:n/2)}function Fee(e){return e.map((t,n)=>({...t,i:n})).sort((t,n)=>cC.indexOf(t.tier)-cC.indexOf(n.tier)||+(t.row.via==="tailscale")-+(n.row.via==="tailscale")||t.i-n.i).map(({row:t,tier:n})=>({row:t,tier:n}))}function yC(e,t){let n=2166136261^t;for(let r=0;r<e.length;r++)n^=e.charCodeAt(r),n=Math.imul(n,16777619);return(n>>>0)%2e4/1e4-1}function Bee(e,t,n){const r=[...vee[e.length]??[]];for(let s=0;s<r.length;s++){const o=e[s];if(o<2)continue;const i=z0(t*r[s],n*r[s])/o;if(!(i>0)||i>=Ih)continue;const c=s+1<r.length?r[s+1]-bee:1;r[s]=Math.max(r[s],Math.min(c,r[s]*(Ih/i)*1.02))}return r}const lo=(e,t)=>e.x0<t.x1&&t.x0<e.x1&&e.y0<t.y1&&t.y0<e.y1,pg={h:16,ch:6.1,maxW:100};function qee(e){const t=e?Math.max(80,e.length*7.2+16):128;return{x0:-t/2,y0:32,x1:t/2,y1:66}}function iP(e,t,n,r,s,o){const i=t==="loose"?See:Nee,c=!s||e.kind==="asks",d=c?_ee:pg.h,h=s?pg.ch:Cee,f=c?o.length:0,p=Math.min(s?pg.maxW:Eee,Math.max(2*i,cP(e).length*h,f*Tee)),g={x0:n-i,y0:r-i,x1:n+i,y1:r+i},w=oP(n,r)==="top"?{x0:n-p/2,y0:r-i-Pd-d,x1:n+p/2,y1:r-i-Pd}:{x0:n-p/2,y0:r+i+Pd,x1:n+p/2,y1:r+i+Pd+d};return[g,w]}const V0=e=>{const t=e.theta*Math.PI/180;return[Math.cos(t)*e.ring.rx*e.reach,Math.sin(t)*e.ring.ry*e.reach]},Dd=(e,t)=>((e-t)%360+540)%360-180;function wC(e,t,n){const r=new Map;for(const f of e)r.has(f.ring)||r.set(f.ring,[]),r.get(f.ring).push(f);const s=()=>e.map(f=>{const[p,g]=V0(f);return iP(f.row,f.tier,p,g,t,f.caption)}),o=(f,p,g=!1)=>{if(f.count<=2&&!g)return!1;const w=f.theta+p*Aee,k=r.get(f.ring),j=(f.count>2?360/f.count:f.turn)*$ee,v=k[(f.index+1)%f.count],b=k[(f.index-1+f.count)%f.count];return!(v===f||(p>0?Dd(v.theta,w)>=j:Dd(w,b.theta)>=j))||w<f.lo||w>f.hi?!1:(f.theta=w,!0)},i=([f,p],[g,w])=>lo(p,g)||lo(w,f)||lo(p,w)||lo(f,g),c=([f,p])=>lo(f,n)||lo(p,n);for(let f=0;f<Mee;f++){const p=s();let g=!1;for(let w=0;w<e.length;w++){c(p[w])&&(g=o(e[w],Dd(e[w].theta,90)>=0?1:-1,!0)||g);for(let k=w+1;k<e.length;k++){if(!i(p[w],p[k]))continue;const j=e[w],v=e[k],b=v.ring.ring>j.ring.ring||v.ring===j.ring&&k>w?v:j,N=b===v?j:v,S=Dd(b.theta,N.theta)>=0?1:-1;g=o(b,S)||o(N,-S)||g}}if(!g)break}const d=s();let h=0;for(let f=0;f<d.length;f++){c(d[f])&&h++;for(let p=f+1;p<d.length;p++)i(d[f],d[p])&&h++}return h}const Uee={online:0,offline:1,loose:1};function Hee(e,t,n,r="",s=Ree){const o=[];for(const i of[!0,!1]){const c=xC(e,t,n,r,gee,s,i);if(c.clashes===0)return c.named();if(o.push(c),c.layout.rings.length===3){const d=xC(e,t,n,r,Uee,s,i),h={clashes:d.clashes,named:()=>({...d.named(),folded:!0})};if(h.clashes===0)return h.named();o.push(h)}if(!c.layout.zone)break}return o.reduce((i,c)=>c.clashes<i.clashes?c:i).named()}function xC(e,t,n,r,s,o,i=!0){const c=new Map;for(const F of e){const A=yee(F);if(!A)continue;const B=s[A];c.has(B)||c.set(B,[]),c.get(B).push({row:F,tier:A})}const d=[...c.keys()].sort((F,A)=>F-A),h=Math.max(0,t/2-wee),f=Math.max(0,n/2-xee),p=Bee(d.map(F=>c.get(F).length),h,f),g=d.map((F,A)=>({ring:F,rx:h*p[A],ry:f*p[A],count:c.get(F).length})),w=g.reduce((F,A)=>F+A.count,0),k=F=>F.row.via==="tailscale",j=[...c.values()].flat().filter(k).length,v=Math.max(0,...g.map(F=>{const A=c.get(F.ring).filter(k).length,B=z0(F.rx,F.ry);return A>0&&B>0?A*Ih*Iee/B*360:0})),b=i&&j>0&&j<w?Math.min(Oee,Math.max(Lee,j/w*360,v)):0,N=uC-b/2,S=uC+b/2,E=[];let C=!1;g.forEach((F,A)=>{const B=Fee(c.get(F.ring)),D=B.length,K=D>1&&z0(F.rx,F.ry)/D<Ih;K&&(C=!0);const G=A===g.length-1,H=G?-gC*(p[A]-(p[A-1]??0)):gC*(p[A+1]-p[A]),q=b>0?[{members:B.filter(V=>V.row.via!=="tailscale"),from:S,width:360-b},{members:B.filter(V=>V.row.via==="tailscale"),from:N+360,width:b}]:[{members:B,from:null,width:360}];let M=0;for(const V of q){const Z=V.members.length;if(Z===0)continue;const W=V.width/Z,X=Z>2;V.members.forEach(({row:Y,tier:J},ee)=>{const ne=br(Y),se=V.from==null?Dee(Z,A)+W*ee:V.from+W*(ee+.5),ce=X?yC(ne,1)*kee*W:0,de=K&&M%2===1?1+H/p[A]:1,ae=X?yC(ne,2)*jee:0,pe=W*.3;E.push({row:Y,tier:J,ring:F,index:M,count:D,theta:se+ce,reach:de*(1+(G?-Math.abs(ae):ae)),lo:V.from==null?-1/0:V.from+pe,hi:V.from==null?1/0:V.from+V.width-pe,turn:W,caption:o(Y)}),M++})}});const $=qee(r);let T=wC(E,C,$);T>0&&!C&&(C=!0,T=wC(E,!0,$));const I=E.map((F,A)=>{const[B,D]=V0(F);return{row:F.row,tier:F.tier,ring:F.ring.ring,x:B,y:D,angle:Wee(Math.atan2(D,B)*180/Math.PI),dist:Math.hypot(B,D),side:oP(B,D),order:A}}),O=g.reduce((F,A,B)=>c.get(A.ring).some(k)?Math.max(F,p[B]):F,0),U=F=>({from:N,to:S,inner:{rx:h*dC,ry:f*dC},outer:{rx:Math.min(t/2-8,h*O+F),ry:Math.min(n/2-8,f*O+F)},count:j}),P={nodes:I,rings:g,dense:C,zone:b>0?{...U(hC),labelAt:null}:null};return{layout:P,clashes:T,named:()=>{if(!P.zone)return P;const F=E.flatMap(D=>{const[K,G]=V0(D);return iP(D.row,D.tier,K,G,C,D.caption)});let A={...P.zone,labelAt:vC(P.zone,F)},B=A.outer;for(let D=hC+fC;A.labelAt==null;D+=fC){const K=U(D);if(K.outer.rx===B.rx&&K.outer.ry===B.ry)break;B=K.outer;const G=vC(K,F);G!=null&&(A={...K,labelAt:G})}return{...P,zone:A}}}}function lP(e){return`Tailscale · ${e} deck${e===1?"":"s"}`}function vC(e,t){const n={rx:e.outer.rx-Ph,ry:e.outer.ry-Ph};if(!(n.rx>0&&n.ry>0))return null;const r=Math.min(.5,2/Math.max(n.rx,n.ry)*(180/Math.PI)),s=[];for(let N=e.to;N>=e.from;N-=r){const S=N*Math.PI/180;s.push([Math.cos(S)*n.rx,Math.sin(S)*n.ry])}const o=pC+tc,i={x0:Math.min(...s.map(N=>N[0]))-o,x1:Math.max(...s.map(N=>N[0]))+o,y0:Math.min(...s.map(N=>N[1]))-o,y1:Math.max(...s.map(N=>N[1]))+o},c=t.map(N=>({x0:N.x0-tc,y0:N.y0-tc,x1:N.x1+tc,y1:N.y1+tc})).filter(N=>lo(N,i)),d=(N,S)=>c.some(E=>N>E.x0&&N<E.x1&&S>E.y0&&S<E.y1),h=[],f=[];let p=0;s.forEach(([N,S],E)=>{E>0&&(p+=Math.hypot(N-s[E-1][0],S-s[E-1][1]));const C=Math.hypot(N,S)||1;let $=!1;for(let T=0;T<=pC&&!$;T+=1.75)$=d(N-N/C*T,S-S/C*T);h.push(p),f.push((f.at(-1)??0)+($?1:0))});const g=lP(e.count).length*Pee/2,w=g+mC,k=p-g-mC;if(!(p>0)||k<w)return null;const j=N=>{let S=0,E=h.length;for(;S<E;){const C=S+E>>1;h[C]<N?S=C+1:E=C}return S},v=N=>{const S=j(N-g),E=j(N+g+1e-9)-1;return E<S||f[E]-(S>0?f[S-1]:0)===0},b=p/2;for(let N=0;b-N>=w;N+=2)for(const S of N===0?[b]:[b-N,b+N])if(v(S))return S/p;return null}function Wee(e){return(e%360+360)%360}function zee(e){const t=n=>e.filter(n).length;return{paired:t(n=>n.kind==="paired"),online:t(n=>n.kind==="paired"&&n.here),offline:t(n=>n.kind==="paired"&&!n.here),nearby:t(n=>n.kind==="nearby"),asks:t(n=>n.kind==="asks"),dialling:t(n=>n.kind==="dialling"),declined:t(n=>n.kind==="declined"),tailnet:t(n=>n.kind!=="declined"&&n.via==="tailscale"),oneWay:t(n=>n.kind==="paired"&&!n.here&&n.state.startsWith("one-way"))}}function Vee(e){const t=[];return e.asks&&t.push(e.asks===1?"1 deck wants to pair":`${e.asks} decks want to pair`),e.paired===0?t.push("no paired decks yet"):e.paired===1?t.push(e.online?"1 paired deck, online":"1 paired deck, away"):e.online===e.paired?t.push(`${e.paired} paired decks, all online`):t.push(`${e.online} of ${e.paired} paired decks online`),e.nearby&&t.push(`${e.nearby} nearby, not paired`),e.dialling&&t.push(`${e.dialling} still dialling`),t.join(" · ")}function v1(e,t){switch(e.kind){case"asks":return"wants to pair";case"nearby":return e.state;case"dialling":return uP(e)?`${e.name.slice(e.addr.length)} · dialling`:"dialling";case"declined":return"declined";case"paired":{if(e.here)return t?Gee(t):"online";const n=hP(e);return n?n==="now"?"away · just now":`away · ${n}`:e.state.startsWith("one-way")?"has not called yet":"away"}}}function cP(e){return uP(e)?e.addr:e.name}function uP(e){return e.kind==="dialling"&&!!e.addr&&e.name.startsWith(`${e.addr}:`)}function dP(e){if(e.kind!=="paired")return e.via==="tailscale"?`${e.state}, over Tailscale`:e.state;if(e.here)return e.via==="tailscale"?"online, over Tailscale":"online";const t=hP(e),n=t?t==="now"?"away · last online just now":`away · last online ${t}`:e.state.startsWith("one-way")?e.state:"away";return e.via==="tailscale"?`${n}, over Tailscale`:n}function hP(e){var t;return((t=/last online (.+)$/.exec(e.state))==null?void 0:t[1])??null}function Gee(e){return e.trim().split(/\s+/).slice(0,2).join(" ")}function Kee(e){var r;if(!e)return[];const t=(e.addrs??[]).map(s=>`${s}:${e.port}`),n=(r=e.tailscale)==null?void 0:r.addr;return n&&!(e.addrs??[]).includes(n)&&t.push(`${n}:${e.port}`),t}function br(e){let t=e.fp;for(const n of e.twins??[])n.fp<t&&(t=n.fp);return t}function Yee(e,t){if(e==null)return t;const n=((t-e)%360+540)%360-180;return e+n}function Xee(e,t){if(e.asks)return e.asks===1?"1 deck wants to pair. Answer it in the Local network list, behind this map.":`${e.asks} decks want to pair. Answer them in the Local network list, behind this map.`;if(e.oneWay)return`${e.oneWay} away deck${e.oneWay===1?" only calls":"s only call"} in, and this deck has no address to call ${e.oneWay===1?"it":"them"} on. Add ${e.oneWay===1?"its address":"their addresses"} through Add a deck to reach ${e.oneWay===1?"it":"them"} both ways.`;if(e.dialling)return e.dialling===1?"1 address has never answered. Open it to stop dialling it.":`${e.dialling} addresses have never answered. Open one to stop dialling it.`;if(e.nearby){const n=e.nearby===1?"1 deck nearby is not paired.":`${e.nearby} decks nearby are not paired.`;return t==="invite"?`${n} ${fP}`:e.nearby===1?`${n} Open it to ask to pair.`:`${n} Open one to ask to pair.`}return null}const fP="This deck pairs by invite only. Send one from Add a deck.";function Zee(e,t){switch(e.kind){case"asks":return"Waiting for your answer, in the Local network list behind this map.";case"dialling":return"Nothing has answered here yet. Its dialog can stop dialling it.";case"nearby":return t==="invite"?fP:"Not paired yet. Its dialog can ask to pair.";case"paired":return!e.here&&e.state.startsWith("one-way")?"It can reach this deck, not the other way. Add its address through Add a deck.":null;default:return null}}function Jee(e){const t={bad:0,wait:1,idle:2,ok:3};return e.map((n,r)=>({l:n,i:r})).sort((n,r)=>t[n.l.tone]-t[r.l.tone]||n.i-r.i).map(({l:n})=>n)}function Qee(e,t){const n=/^(\d+)\.(\d+)\.(\d+)/.exec(e??""),r=/^(\d+)\.(\d+)\.(\d+)/.exec(t??"");if(!n||!r)return null;for(let s=1;s<=3;s++){const o=Number(n[s])-Number(r[s]);if(o)return Math.sign(o)}return 0}function ete(e,t){const n=t?t.alive?t.shareable===!1?"cannot share here":"works here":"expired here":"not on this deck";if(e.alive&&e.shareable===!1)return{there:"cannot share there",here:n,note:null,tone:"idle"};if(!e.alive){const r=t&&!t.alive?"neither copy works — sign in again here":null;return{there:"broken there",here:n,note:r,tone:r?"bad":"idle"}}return t?t.alive?{there:"works there",here:n,note:null,tone:t.shareable===!1?"idle":"ok"}:{there:"works there",here:n,note:"repairs next round",tone:"wait"}:{there:"works there",here:n,note:"arrives next round",tone:"wait"}}function tte(e,t,n,r=null){var d;const s=new Map;for(const h of t)(d=s.get(h.key))!=null&&d.alive||s.set(h.key,h);const o=new Set(n),i=[],c=new Set;for(const h of e??[]){if(c.has(h.key))continue;c.add(h.key);const f=s.get(h.key)??null,p=o.has(h.key),g=ete(h,f),w=f?f.alive?f.shareable===!1?"unavailable":"works":"expired":"missing",k=!h.alive&&f&&!f.alive?g.note:[w==="works"?null:g.here,h.alive&&h.shareable!==!1?null:g.there,g.note].filter(Boolean).join(" · ")||null;i.push({key:h.key,email:h.email,here:w,there:h.alive?h.shareable===!1?"unavailable":"works":"broken",in:!h.alive||h.shareable===!1?"cut":g.tone==="wait"?"wait":"live",out:p&&f?f.alive&&f.shareable!==!1?"live":"cut":null,caption:k,tone:g.tone,usedThere:r===h.key})}for(const h of n){const f=s.get(h);!f||c.has(h)||(c.add(h),i.push({key:h,email:f.email,here:f.alive?f.shareable===!1?"unavailable":"works":"expired",there:"unknown",in:null,out:f.alive&&f.shareable!==!1?"live":"cut",caption:f.alive?f.shareable===!1?"cannot share here":null:"expired here",tone:f.alive?f.shareable===!1?"idle":"ok":"bad",usedThere:!1}))}return i}const nte=1e3;function rte(e,t){const n=new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),r=ns(e,t);return`${n} · ${r==="now"?"just now":r}`}function G0(e){return e&&[e.version,e.os,e.arch].filter(Boolean).join(" · ")||null}const pP={works:"works here",expired:"expired here",missing:"not on this deck",unavailable:"cannot share here"},mP={works:"works there",broken:"broken there",unavailable:"cannot share there",unknown:"not offered by that deck"};function gP(e){const t=e.in&&e.out?"offered both ways":e.in?"offered by that deck":"offered by this deck";return`${pP[e.here]}, ${mP[e.there]}, ${t}${e.usedThere?", in use there":""}.`}function yP({row:e,source:t,status:n,accounts:r,now:s}){var J,ee,ne,se,ce;const{peer:o,stranger:i}=t,c=e.kind==="paired",d=e.self??e.name,h=e.kind!=="dialling",f=e.kind==="dialling"?null:e.fp,p=o?o.addr?`${o.addr}:${o.port}`:"":i?i.port?`${i.addr}:${i.port}`:i.addr:e.addr,g=(o==null?void 0:o.about)??null,w=((J=n.about)==null?void 0:J.version)??null,k=c?o!=null&&o.waiting?o.lastSeen!=null?"not said — it runs an older version":"not said yet — it says when it next calls":o!=null&&o.offers?"not said — it runs an older version":"not reached yet":"shown once paired",j=G0(n.about),v=G0(g),b=g!=null&&g.version&&w?Qee(g.version,w):null,N=o?Cf(o.last,s):null,S=o&&((ee=o.last)!=null&&ee.error)?gQ({error:o.last.error,host:o.addr,port:o.port},[...n.strangers??[],...n.pending??[],...(n.peers??[]).filter(de=>!de.manual&&de.addr).map(de=>({fp:de.fp,name:de.name,addr:de.addr,port:de.port,at:de.lastSeen??0}))],s):null,E=(ne=o==null?void 0:o.last)!=null&&ne.error&&N&&N.text!==o.last.error?o.last.error:null,C=((se=o==null?void 0:o.last)==null?void 0:se.done)??[],$=!!N&&!!E&&!e.quiet&&e.state.startsWith(N.text),T=c||e.kind==="dialling",I=((o==null?void 0:o.via)??e.via)==="tailscale",O=o?o.waiting?null:o.manual?I?"added by its Tailscale address":"added by address":I?"over Tailscale":"on this network":e.kind==="nearby"?I?"heard over Tailscale":"heard on this network":I?"asked this deck to pair, over Tailscale":"asked this deck to pair",U=e.tone==="bad"?"bad":c?e.here?"up":"down":"loose",P=(o==null?void 0:o.offers)??null,L=U==="up"?(P==null?void 0:P.current)??null:null,F=L&&"key"in L?L.key:null,A=!!L&&"hidden"in L,B=!!L&&"other"in L,D=(n.shared??[]).filter(de=>{var ae;return!((ae=o==null?void 0:o.notOffered)!=null&&ae.includes(de))}),K=c?tte((P==null?void 0:P.accounts)??null,r,D,F):[],G=K.filter(de=>de.in==null&&de.out==="cut"),H=K.some(de=>de.in!=null),q=K.some(de=>de.out!=null),M=new Set((n.peers??[]).filter(de=>de.paired).flatMap(de=>de.notOffered??[])),V=K.some(de=>de.out!=null&&M.has(de.key))?"decks you chose":"every paired deck",Z=new Map(C.map(de=>[de.email,de])),W=C.filter(de=>!K.some(ae=>ae.email===de.email)),X=c?P?P.accounts.length===0?"That deck offers nothing. Nobody there has chosen a login to share.":null:o!=null&&o.waiting?"What that deck offers is not known yet. A deck that calls in says so each time it calls — one on an older version never does.":(ce=o==null?void 0:o.last)!=null&&ce.error?"What that deck offers is not known — the last attempt to ask it did not get through.":"Nobody has asked that deck what it offers yet. The next round asks it.":null,Y=P&&(o!=null&&o.last)&&o.last.at-P.at>nte?ns(P.at,s):null;return{peer:o,stranger:i,paired:c,own:d,canRename:h,fp:f,where:p,about:g,unsaid:k,hereRuns:j,thereRuns:v,order:b,line:N,silence:S,raw:E,echoed:$,showRound:T,how:O,link:U,hiddenThere:A,otherThere:B,lanes:K,spent:G,taking:H,giving:q,givenTo:V,told:Z,unplaced:W,unknown:X,stale:Y}}function K0(){return a.jsxs("svg",{className:"lan-machine",width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("rect",{x:"2.5",y:"3",width:"11",height:"7.5",rx:"1.2"}),a.jsx("path",{d:"M1 13h14"})]})}function Fd({dir:e}){return a.jsx("svg",{className:"lan-chev","data-dir":e,width:"8",height:"8",viewBox:"0 0 8 8",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:a.jsx("path",{d:e==="out"?"M2.8 1L6 4 2.8 7":"M5.2 1L2 4l3.2 3"})})}function ste({view:e,row:t,status:n,asking:r,drawn:s,onSettings:o}){const{peer:i,paired:c,where:d,about:h,unsaid:f,hereRuns:p,thereRuns:g,order:w,line:k,silence:j,raw:v,echoed:b,showRound:N,how:S,link:E,hiddenThere:C,otherThere:$,lanes:T,spent:I,taking:O,giving:U,givenTo:P,told:L,unplaced:F,unknown:A,stale:B}=e;return a.jsxs("div",{className:"lan-map","data-link":E,"data-asking":r||void 0,"data-bus":T.length>0||void 0,children:[a.jsxs("div",{className:"lan-ends",children:[a.jsxs("p",{className:"lan-end",children:[a.jsx("span",{className:"lan-end-name",children:"This deck"}),p&&a.jsx("span",{className:"lan-end-runs",children:p}),c&&n.shareActive===!1&&a.jsx("span",{className:"lan-end-note",children:"current account hidden"})]}),a.jsxs("p",{className:"lan-end","data-side":"there",children:[a.jsx("span",{className:"lan-end-name",children:t.name}),t.kind!=="dialling"&&a.jsxs("span",{className:"lan-end-runs",children:[g??(h?"not said":f),w?` · ${w<0?"older":"newer"}`:null]}),C&&a.jsx("span",{className:"lan-end-note",children:"current account hidden"}),$&&a.jsx("span",{className:"lan-end-note",children:"on another account"})]})]}),a.jsxs("div",{className:"lan-link",children:[a.jsx(K0,{}),a.jsxs("span",{className:"lan-span",children:[a.jsxs("span",{className:"lan-wire","aria-hidden":!0,children:[a.jsx("i",{className:"lan-glint","data-dir":"out"}),a.jsx("i",{className:"lan-glint","data-dir":"in"})]}),a.jsx("span",{className:"lan-link-label",children:d?a.jsx("code",{className:"ap-lan-code",children:d}):"none here — it calls this deck"})]}),a.jsx(K0,{}),(d&&S||N)&&a.jsxs("p",{className:"lan-link-sub",children:[d&&S,d&&S&&N&&" · ",N&&(k?b?a.jsx("code",{className:"ap-lan-code",children:v}):a.jsx("span",{className:"lan-round","data-tone":k.tone,children:k.text.replace(/ · now$/," · just now")}):"not asked yet"),N&&v&&!b&&a.jsx("code",{className:"lan-fact-raw",children:v})]}),F.length>0&&a.jsx("ul",{className:"lan-done",children:F.map(D=>{const K=B0(D);return a.jsxs("li",{"data-ok":D.ok&&!K,children:[D.email," ",a.jsxs("span",{className:"lan-done-what",children:[D.ok?"arrived":"did not arrive",K&&` — ${K.long}`]})]},`${D.email}:${D.action}`)})}),j&&a.jsx("p",{className:"lan-note lan-link-note",children:j}),(i==null?void 0:i.waiting)&&a.jsx("p",{className:"lan-note lan-link-note",children:t.hint}),(k==null?void 0:k.hint)&&a.jsx("p",{className:"lan-note lan-link-note",children:k.hint})]}),T.length>0&&a.jsx("ul",{className:"lan-lanes",role:"list","aria-label":`Logins between this deck and ${t.name}`,children:T.map((D,K)=>{const G=L.get(D.email),H=G?B0(G):null,q=D.out==="live"||D.in!=null&&D.in!=="cut";return a.jsxs("li",{role:"listitem",className:"lan-lane","data-tone":D.tone,"data-draw":D.in&&D.out?"both":D.in?"in":"out","data-used-there":D.usedThere||void 0,style:{"--i":K},children:[a.jsx("i",{className:"lan-pip","data-end":"here","data-state":D.here,"aria-hidden":!0}),a.jsxs("span",{className:"lan-track",children:[a.jsxs("span",{className:"lan-wire","data-flow":q?"live":"cut","aria-hidden":!0,children:[(D.in==="live"||D.in==="wait")&&a.jsx("i",{className:"lan-glint","data-dir":"in","data-tone":D.in}),D.out==="live"&&a.jsx("i",{className:"lan-glint","data-dir":"out"})]}),D.in&&D.in!=="cut"&&a.jsx(Fd,{dir:"in"}),D.out==="live"&&a.jsx(Fd,{dir:"out"}),a.jsx("span",{className:"lan-lane-email",children:D.email})]}),a.jsx("i",{className:"lan-pip","data-end":"there","data-state":D.there,"aria-hidden":!0}),a.jsx("span",{className:"vis-hidden",children:gP(D)}),(D.caption||G)&&a.jsxs("span",{className:"lan-lane-note",children:[D.caption,D.caption&&G&&" · ",G&&a.jsxs("span",{className:"lan-lane-done","data-ok":G.ok&&!H,children:[G.ok?"arrived last round":"did not arrive last round",H&&` — ${H.long}`]})]})]},D.key)})},s),c&&a.jsxs(a.Fragment,{children:[I.length>0&&a.jsxs("p",{className:"lan-spent",children:["Paired decks get nothing from ",I.length===1?I[0].email:"the expired ones"," until you sign in again here."]}),A&&a.jsx("p",{className:"lan-empty",children:A}),B&&a.jsxs("p",{className:"lan-stale",children:["As of ",B==="now"?"just now":B,", when it last answered."]}),a.jsxs("div",{className:"lan-legend",children:[O&&a.jsxs("span",{className:"lan-key",children:[a.jsx("span",{className:"lan-key-wire","data-dir":"in","aria-hidden":!0,children:a.jsx(Fd,{dir:"in"})}),"from ",t.name]}),U?a.jsxs("span",{className:"lan-key",children:[a.jsx("span",{className:"lan-key-wire","data-dir":"out","aria-hidden":!0,children:a.jsx(Fd,{dir:"out"})}),"from this deck, to ",P]}):a.jsx("span",{className:"lan-key",children:"This deck offers nothing yet."}),a.jsx("button",{type:"button",className:"ap-lan-word lan-legend-act",onClick:o,"aria-label":"Change what this deck offers",children:"change"})]})]})]})}const ate=20,ote=17,bC=34,ite=160,lte=80,cte=200,ute=8,dte=14,hte=10,fte=.61803398875;function pte({status:e,rows:t,accounts:n,now:r,covered:s,onOpenDeck:o,onClose:i}){const c=y.useRef(null),d=ot(i,{focusRef:c}),h=dt(i),f=y.useRef(null),[p,g]=y.useState(null),[w,k]=y.useState(!1),j=y.useRef(null);y.useLayoutEffect(()=>{const ae=f.current;if(!ae)return;let pe=null;const fe=()=>{const ye=Math.round(ae.clientWidth),oe=Math.round(ae.clientHeight);pe&&pe.w===ye&&pe.h===oe||(pe&&(k(!0),j.current!=null&&window.clearTimeout(j.current),j.current=window.setTimeout(()=>k(!1),cte)),pe={w:ye,h:oe},g(pe))};if(fe(),typeof ResizeObserver>"u")return;const Ee=new ResizeObserver(fe);return Ee.observe(ae),()=>{Ee.disconnect(),j.current!=null&&window.clearTimeout(j.current)}},[]);const v=y.useMemo(()=>p?Hee(t,p.w,p.h,(e==null?void 0:e.name)??"",ae=>{var pe,fe;return v1(ae,(fe=(pe=qc(e,ae).peer)==null?void 0:pe.about)==null?void 0:fe.os)}):null,[t,p,e]),b=y.useMemo(()=>zee(t),[t]),N=(v==null?void 0:v.nodes)??[],S=y.useRef(new Map),E=y.useMemo(()=>{const ae=new Map;for(const pe of N){const fe=br(pe.row);ae.set(fe,Yee(S.current.get(fe),pe.angle))}return S.current=ae,ae},[N]),[C,$]=y.useState(null),[T,I]=y.useState(null),[O,U]=y.useState("none"),P=y.useRef(null),L=y.useCallback((ae,pe)=>{P.current!==ae&&(P.current=ae,U(pe),I(ae))},[]),F=y.useRef(null),A=y.useRef(null),B=y.useCallback(()=>{A.current!=null&&window.clearTimeout(A.current),A.current=null},[]),D=y.useCallback((ae,pe)=>{if(F.current!=null&&window.clearTimeout(F.current),F.current=null,B(),$(ae),pe==="keyboard"){L(ae,"none");return}A.current=window.setTimeout(()=>L(ae,P.current?"swap":"full"),lte)},[L,B]),K=y.useCallback(()=>{F.current!=null&&window.clearTimeout(F.current),B(),F.current=window.setTimeout(()=>$(null),ite)},[B]);y.useEffect(()=>()=>{F.current!=null&&window.clearTimeout(F.current),B()},[B]);const G=C&&N.some(ae=>br(ae.row)===C)?C:null,H=T?t.find(ae=>br(ae)===T)??null:null;y.useEffect(()=>{T&&!H&&L(null,"swap")},[T,H,L]);const[q,M]=y.useState(null),V=y.useRef(new Map),Z=N.findIndex(ae=>br(ae.row)===q),W=Z<0?0:Z,X=ae=>{var ye;if(N.length===0)return;const pe=ae.key==="ArrowRight"||ae.key==="ArrowDown"?1:ae.key==="ArrowLeft"||ae.key==="ArrowUp"?-1:0,fe=ae.key==="Home"?0:ae.key==="End"?N.length-1:pe?(W+pe+N.length)%N.length:null;if(fe==null)return;ae.preventDefault();const Ee=br(N[fe].row);M(Ee),(ye=V.current.get(Ee))==null||ye.focus()},[Y,J]=y.useState(()=>typeof document<"u"&&document.hidden);y.useEffect(()=>{const ae=()=>J(document.hidden);return document.addEventListener("visibilitychange",ae),()=>document.removeEventListener("visibilitychange",ae)},[]);const ee=(e==null?void 0:e.enabled)===!0,ne=e?ee?Vee(b):"Local network is off":"checking…",se=()=>{B(),L(null,"swap"),$(null)},ce=G?N.find(ae=>br(ae.row)===G)??null:null,de=()=>{var ae;T&&((ae=V.current.get(T))==null||ae.focus()),se()};return yt.createPortal(a.jsx("div",{className:"modal-backdrop",...h,role:"presentation",children:a.jsxs("div",{ref:d,className:"modal nm-modal",onClick:ae=>ae.stopPropagation(),"data-paused":s||Y||void 0,role:"dialog","aria-modal":"true","aria-labelledby":"nm-title","aria-describedby":"nm-sub",children:[a.jsxs("header",{className:"modal-head nm-head",children:[a.jsxs("div",{className:"nm-heading",children:[a.jsx("h2",{id:"nm-title",className:"modal-title nm-title",children:"Network map"}),a.jsx("p",{id:"nm-sub",className:"nm-sub",children:ne})]}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{ref:c,type:"button",className:"glyph-btn",onClick:i,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("div",{className:"nm-body",children:[a.jsxs("div",{className:"nm-view",children:[a.jsx("div",{ref:f,className:"nm-stage","data-focus":G?"":void 0,"data-focus-via":ce==null?void 0:ce.row.via,"data-dense":(v==null?void 0:v.dense)||void 0,"data-still":w||void 0,onClick:ae=>{ae.target===ae.currentTarget&&se()},children:p&&v&&a.jsxs(a.Fragment,{children:[a.jsx(mte,{layout:v,w:p.w,h:p.h}),N.map(ae=>{const pe=br(ae.row);return a.jsx(wte,{node:ae,angle:E.get(pe)??ae.angle,lit:G===pe},pe)}),a.jsx(xte,{status:e}),a.jsx("span",{id:"nm-ring-hint",className:"vis-hidden",children:"Arrow keys move between decks. Enter opens the deck's own dialog."}),a.jsx("div",{className:"nm-ring",role:"group","aria-label":`Decks around this deck, ${N.length}`,"aria-describedby":"nm-ring-hint",onKeyDown:X,children:N.map((ae,pe)=>{var Ee,ye;const fe=br(ae.row);return a.jsx(vte,{node:ae,angle:E.get(fe)??ae.angle,os:(ye=(Ee=qc(e,ae.row).peer)==null?void 0:Ee.about)==null?void 0:ye.os,lit:G===fe,shown:T===fe,tabbable:pe===W,register:oe=>{oe?V.current.set(fe,oe):V.current.delete(fe)},onHold:oe=>{M(fe),D(fe,oe)},onRelease:K,onOpen:()=>o(ae.row.fp)},fe)})}),N.length===0&&a.jsx(bte,{status:e})]})}),a.jsx(kte,{slice:(v==null?void 0:v.zone)!=null})]}),a.jsx("aside",{className:"nm-side","aria-label":"Details",children:H&&e?a.jsx(Nte,{row:H,status:e,accounts:n,now:r,entrance:O,onOpen:()=>o(H.fp),onBack:de},br(H)):a.jsx(jte,{status:e,summary:b,entrance:O,slice:(v==null?void 0:v.zone)!=null})})]})]})}),document.body)}function wP(){return a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("circle",{cx:"7",cy:"7.4",r:"1.8"}),a.jsx("circle",{cx:"2.4",cy:"2.9",r:"1.2"}),a.jsx("circle",{cx:"11.6",cy:"2.9",r:"1.2"}),a.jsx("circle",{cx:"7",cy:"12.4",r:"1.1"}),a.jsx("path",{d:"M5.7 6.1 3.3 3.8M8.3 6.1l2.4-2.3M7 9.2v2.1"})]})}function mte({layout:e,w:t,h:n}){const{zone:r}=e;return a.jsxs("svg",{className:"nm-orbits",width:t,height:n,viewBox:`0 0 ${t} ${n}`,"aria-hidden":!0,children:[r&&a.jsxs(a.Fragment,{children:[a.jsxs("defs",{children:[a.jsx("path",{id:"nm-zone-arc",d:yte(r,t/2,n/2)}),a.jsxs("radialGradient",{id:"nm-zone-fill",gradientUnits:"userSpaceOnUse",cx:t/2,cy:n/2,r:Math.max(r.outer.rx,r.outer.ry),children:[a.jsx("stop",{className:"nm-zone-stop",offset:"0.2","data-at":"in"}),a.jsx("stop",{className:"nm-zone-stop",offset:"0.5","data-at":"mid"}),a.jsx("stop",{className:"nm-zone-stop",offset:"1","data-at":"out"})]})]}),a.jsx("path",{className:"nm-zone",d:gte(r,t/2,n/2),fill:"url(#nm-zone-fill)"}),r.labelAt!=null&&a.jsx("text",{className:"nm-zone-label",children:a.jsx("textPath",{href:"#nm-zone-arc",startOffset:`${(r.labelAt*100).toFixed(2)}%`,textAnchor:"middle",children:lP(r.count)})})]}),e.rings.map((s,o)=>a.jsx("ellipse",{className:"nm-orbit","data-ring":s.ring,"data-folded":e.folded&&s.ring===1||void 0,cx:t/2,cy:n/2,rx:s.rx,ry:s.ry,style:{"--ring":o}},s.ring))]})}function kC(e,t,n,r){const s=r*Math.PI/180;return`${(t+Math.cos(s)*e.rx).toFixed(1)},${(n+Math.sin(s)*e.ry).toFixed(1)}`}function gte(e,t,n){const r=e.to-e.from>180?1:0,s=(b,N)=>{const S=N*Math.PI/180;return[t+Math.cos(S)*b.rx,n+Math.sin(S)*b.ry]},o=(b,N)=>N/((b.rx+b.ry)/2)*(180/Math.PI),i=(b,N,S)=>{const E=Math.hypot(N[0]-b[0],N[1]-b[1])||1,C=Math.min(.5,S/E);return[b[0]+(N[0]-b[0])*C,b[1]+(N[1]-b[1])*C]},c=([b,N])=>`${b.toFixed(1)},${N.toFixed(1)}`,d=hte,h=dte,f=o(e.inner,d),p=o(e.outer,h),g=s(e.inner,e.from),w=s(e.outer,e.from),k=s(e.outer,e.to),j=s(e.inner,e.to),v=b=>`${b.rx.toFixed(1)},${b.ry.toFixed(1)}`;return[`M${c(s(e.inner,e.from+f))}`,`Q${c(g)} ${c(i(g,w,d))}`,`L${c(i(w,g,h))}`,`Q${c(w)} ${c(s(e.outer,e.from+p))}`,`A${v(e.outer)} 0 ${r} 1 ${c(s(e.outer,e.to-p))}`,`Q${c(k)} ${c(i(k,j,h))}`,`L${c(i(j,k,d))}`,`Q${c(j)} ${c(s(e.inner,e.to-f))}`,`A${v(e.inner)} 0 ${r} 0 ${c(s(e.inner,e.from+f))}`,"Z"].join(" ")}function yte(e,t,n){const r={rx:e.outer.rx-Ph,ry:e.outer.ry-Ph},s=e.to-e.from>180?1:0;return`M${kC(r,t,n,e.to)} A${r.rx.toFixed(1)},${r.ry.toFixed(1)} 0 ${s} 0 ${kC(r,t,n,e.from)}`}function wte({node:e,angle:t,lit:n}){const r=e.row.kind==="paired"&&e.row.here,s=e.order*fte%1*ute;return a.jsx("span",{className:"nm-wire","aria-hidden":!0,"data-tier":e.tier,"data-via":e.row.via,"data-on":n||void 0,style:{"--nm-a":`${t.toFixed(2)}deg`,"--nm-d":`${e.dist.toFixed(1)}px`,"--from":`${bC}px`,"--gap":`${bC+(e.tier==="loose"?ote:ate)}px`,"--i":e.order,"--phase":`${s.toFixed(2)}s`},children:r&&a.jsx("i",{className:"nm-glint"})})}function xte({status:e}){const t=(e==null?void 0:e.enabled)===!0&&e.running;return a.jsxs("div",{className:"nm-core","data-listening":t||void 0,children:[a.jsx("span",{className:"nm-core-orb","aria-hidden":!0}),a.jsxs("span",{className:"nm-core-label",children:[a.jsx("span",{className:"nm-core-name",children:(e==null?void 0:e.name)??"…"}),a.jsx("span",{className:"nm-core-what",children:"this deck"})]})]})}function vte({node:e,angle:t,os:n,lit:r,shown:s,tabbable:o,register:i,onHold:c,onRelease:d,onOpen:h}){const{row:f}=e,p=`nm-d-${Ste(br(f))}`,g=e.angle*Math.PI/180,w=v1(f,n);return a.jsxs("button",{ref:i,type:"button",className:"nm-node",tabIndex:o?0:-1,"data-tier":e.tier,"data-kind":f.kind,"data-side":e.side,"data-via":f.via,"data-on":r||void 0,"data-shown":s||void 0,"aria-label":`${f.name}: ${dP(f)}`,"aria-describedby":e.tier==="online"?p:void 0,style:{"--nm-a":`${t.toFixed(2)}deg`,"--nm-d":`${e.dist.toFixed(1)}px`,"--i":e.order,"--in-x":`${(-Math.cos(g)*14).toFixed(1)}px`,"--in-y":`${(-Math.sin(g)*14).toFixed(1)}px`},onPointerEnter:k=>{k.pointerType==="mouse"&&c("pointer")},onPointerLeave:d,onFocus:k=>c(k.currentTarget.matches(":focus-visible")?"keyboard":"pointer"),onBlur:d,onClick:h,children:[a.jsx("i",{className:"nm-halo","data-tier":e.tier,"aria-hidden":!0}),f.kind==="dialling"?a.jsx("i",{className:"nm-addr-dot","aria-hidden":!0}):a.jsx(K0,{}),e.tier!=="online"&&a.jsx("i",{className:"nm-mark","data-tier":e.tier,"data-kind":f.kind,"aria-hidden":!0}),a.jsxs("span",{className:"nm-label","aria-hidden":!0,children:[a.jsx("span",{className:"nm-name",children:cP(f)}),a.jsx("span",{className:"nm-cap",children:w})]}),e.tier==="online"&&a.jsx("span",{id:p,className:"vis-hidden",children:w})]})}function bte({status:e}){const t=(e==null?void 0:e.enabled)===!0;return a.jsx("p",{className:"nm-empty",children:e?t?"No other deck yet. Decks on one network usually find each other within a minute; one on another network needs its address, through Add a deck in Local network.":"Local network is off, so this deck is not looking for any other.":"Asking this deck about the network…"})}function kte({slice:e}){return a.jsxs("ul",{className:"nm-legend",children:[a.jsxs("li",{children:[a.jsxs("span",{className:"nm-key","aria-hidden":!0,children:[a.jsx("i",{className:"nm-key-wire","data-tier":"online"}),a.jsx("i",{className:"nm-key-mark","data-tier":"online"})]}),"online"]}),a.jsxs("li",{children:[a.jsxs("span",{className:"nm-key","aria-hidden":!0,children:[a.jsx("i",{className:"nm-key-wire","data-tier":"offline"}),a.jsx("i",{className:"nm-key-mark","data-tier":"offline"})]}),"away"]}),a.jsxs("li",{children:[a.jsxs("span",{className:"nm-key","aria-hidden":!0,children:[a.jsx("i",{className:"nm-key-wire","data-tier":"loose"}),a.jsx("i",{className:"nm-key-mark","data-tier":"loose"})]}),"not paired"]}),e&&a.jsxs("li",{children:[a.jsx("i",{className:"nm-key-zone","aria-hidden":!0}),"over Tailscale"]})]})}function xP({facts:e}){return a.jsx("dl",{className:"lan-facts nm-facts",children:e.map(t=>a.jsxs("div",{className:"lan-fact","data-tone":t.quiet?"quiet":void 0,children:[a.jsx("dt",{children:t.label}),a.jsx("dd",{children:t.value})]},t.label))})}function jte({status:e,summary:t,entrance:n,slice:r}){const s=Kee(e),o=G0(e==null?void 0:e.about),i=[];o&&i.push({label:"Runs",value:o}),i.push({label:s.length>1?"Addresses":"Address",value:s.length?a.jsx("span",{className:"nm-addrs",children:s.map(h=>a.jsx("code",{className:"ap-lan-code",children:h},h))}):"none yet",quiet:s.length===0}),e!=null&&e.pairingMode&&i.push({label:"Pairing",value:e.pairingMode==="invite"?"by invite only":"asks and answers"});const c=[{key:"online",n:t.online,words:"online",mark:a.jsx("i",{className:"nm-key-mark","data-tier":"online","aria-hidden":!0})},{key:"away",n:t.offline,words:"away",mark:a.jsx("i",{className:"nm-key-mark","data-tier":"offline","aria-hidden":!0})},{key:"asks",n:t.asks,words:"asking to pair",mark:a.jsx("i",{className:"nm-key-mark","data-tier":"loose","data-kind":"asks","aria-hidden":!0})},{key:"nearby",n:t.nearby,words:"nearby, not paired",mark:a.jsx("i",{className:"nm-key-mark","data-tier":"loose","aria-hidden":!0})},{key:"dialling",n:t.dialling,words:"still dialling",mark:a.jsx("i",{className:"nm-key-mark","data-tier":"loose","aria-hidden":!0})},{key:"declined",n:t.declined,words:"declined, not drawn",mark:a.jsx("i",{"aria-hidden":!0})}],d=Xee(t,e==null?void 0:e.pairingMode);return a.jsxs("div",{className:"nm-panel","data-view":"network","data-entrance":n,children:[a.jsx("h3",{className:"nm-panel-name",children:(e==null?void 0:e.name)??"…"}),a.jsx("p",{className:"nm-panel-self",children:"this deck, at the centre of the map"}),a.jsx("ul",{className:"nm-counts",children:c.filter(h=>h.n>0).map(h=>a.jsxs("li",{"data-count":h.key,children:[h.mark,a.jsx("span",{className:"nm-count-n",children:h.n}),a.jsx("span",{className:"nm-count-words",children:h.words})]},h.key))}),t.tailnet>0&&a.jsxs("p",{className:"nm-counts-note",children:[t.tailnet," reached over Tailscale",r?" — the shaded slice, lower right":""]}),d&&a.jsx("p",{className:"nm-next",children:d}),a.jsx(xP,{facts:i}),a.jsx("p",{className:"nm-panel-hint",children:"Point at a deck, or reach one with the arrow keys, to see it here. Press it to open its own dialog."})]})}function Nte({row:e,status:t,accounts:n,now:r,entrance:s,onOpen:o,onBack:i}){var v;const c=yP({row:e,source:qc(t,e),status:t,accounts:n,now:r}),d=[];c.where&&d.push({label:"Address",value:a.jsx("code",{className:"ap-lan-code",children:c.where})}),c.thereRuns&&d.push({label:"Runs",value:`${c.thereRuns}${c.order?` · ${c.order<0?"older than this deck":"newer than this deck"}`:""}`}),c.hiddenThere&&d.push({label:"Signed in to",value:"not said — its owner hides it",quiet:!0}),c.otherThere&&d.push({label:"Signed in to",value:"an account it does not share",quiet:!0});const h=e.kind==="paired"&&e.here||e.kind==="asks",f=Zee(e,t.pairingMode),p=Jee(c.lanes),g=p.length,w=p.filter(b=>b.tone==="ok").length,k=g===0?"No shared logins":w===g?`${g} shared login${g===1?", fine":"s, all fine"}`:`${g} shared login${g===1?"":"s"} · ${w} fine`,j=c.unknown&&((v=c.peer)!=null&&v.waiting)&&!c.peer.offers?"Its side is not known until it next calls.":c.unknown;return a.jsxs("div",{className:"nm-panel","data-view":"deck","data-entrance":s,"data-tier":e.kind==="paired"?e.here?"online":"offline":"loose",children:[a.jsxs("button",{type:"button",className:"ap-lan-word nm-back",onClick:i,children:[a.jsx("span",{"aria-hidden":!0,children:"‹ "}),"the whole network"]}),a.jsxs("div",{className:"nm-panel-head",children:[a.jsxs("h3",{className:"nm-panel-name",children:[a.jsx("i",{className:h?"ap-pulse":"ap-dot","data-kind":e.kind,"aria-hidden":!0}),a.jsx("span",{className:"nm-panel-title",children:e.name})]}),a.jsx("button",{type:"button",className:"btn nm-open",onClick:o,"aria-label":`Open ${e.name}`,children:"Open"})]}),e.self&&a.jsxs("p",{className:"nm-panel-self",children:["calls itself ",e.self]}),a.jsx("p",{className:"nm-panel-state","data-kind":e.kind,children:dP(e)}),f&&a.jsx("p",{className:"nm-next",children:f}),d.length>0&&a.jsx(xP,{facts:d}),c.paired&&a.jsxs("section",{className:"nm-logins","aria-label":"Logins the two decks share",children:[a.jsx("p",{className:"nm-logins-title",children:k}),g>0&&a.jsx("ul",{className:"nm-lanes",children:p.map((b,N)=>a.jsxs("li",{className:"nm-lane","data-tone":b.tone,style:{"--k":N},children:[a.jsx("i",{className:"nm-lane-dot","aria-hidden":!0}),a.jsx("span",{className:"nm-lane-email","aria-hidden":!0,children:b.email}),jC(b)&&a.jsx("span",{className:"nm-lane-said","aria-hidden":!0,children:jC(b)}),b.usedThere&&a.jsx("span",{className:"nm-lane-used","aria-hidden":!0,children:"in use there"}),a.jsxs("span",{className:"vis-hidden",children:[b.email,": ",gP(b)]})]},b.key))}),j&&a.jsx("p",{className:"nm-panel-hint",children:j})]})]})}function jC(e){return e.caption?e.caption:e.tone==="ok"?null:`${pP[e.here]} · ${mP[e.there]}`}function Ste(e){let t=2166136261;for(let n=0;n<e.length;n++)t^=e.charCodeAt(n),t=Math.imul(t,16777619);return(t>>>0).toString(36)}const _te=6;function Ete({anchorId:e,id:t,rows:n,onHold:r,onLet:s}){const o=y.useRef(null),i=n.filter(g=>g.kind==="paired"),c=i.filter(g=>g.here),d=c.slice(0,_te),h=i.length-c.length,f=c.length>d.length?`and ${c.length-d.length} more`:h>0?`${h} not on right now`:null,p=y.useCallback(()=>{const g=o.current,w=document.getElementById(e);if(!g||!w)return;g.style.maxHeight="";const k=o1(w.getBoundingClientRect(),{width:g.offsetWidth,height:g.offsetHeight},{width:window.innerWidth,height:window.innerHeight});g.style.top=`${k.top}px`,g.style.left=`${k.left}px`,g.style.maxHeight=k.maxHeight==null?"":`${k.maxHeight}px`,g.dataset.side=k.side},[e]);return y.useLayoutEffect(()=>{p()}),y.useEffect(()=>(window.addEventListener("scroll",p,!0),window.addEventListener("resize",p),()=>{window.removeEventListener("scroll",p,!0),window.removeEventListener("resize",p)}),[p]),yt.createPortal(a.jsxs("div",{ref:o,id:t,className:"ap-peek",role:"tooltip",onPointerEnter:r,onPointerLeave:s,children:[a.jsx("p",{className:"ap-peek-title",children:c.length?"On the network now":"Nobody on the network"}),d.length>0&&a.jsx("div",{className:"ap-peek-list",children:d.map(g=>a.jsxs("span",{className:"ap-peek-who",children:[a.jsx("i",{className:"ap-nav-live","aria-hidden":!0}),a.jsxs("span",{title:g.via==="tailscale"?`${g.name} · Tailscale`:g.name,children:[g.name,g.via==="tailscale"&&a.jsx("span",{className:"ap-lan-via",children:" · Tailscale"})]})]},`${g.kind}:${g.fp}`))}),f&&a.jsx("p",{className:"ap-peek-rest",children:f})]}),document.body)}function Cte({entry:e,rows:t,onOpen:n,onMap:r,peek:s,openPeek:o,shutPeek:i,holdPeek:c,dropPeek:d}){return a.jsxs(a.Fragment,{children:[a.jsxs("button",{type:"button",id:"ap-lan-entry",className:"ap-nav",onClick:()=>{d(),n()},"aria-describedby":s?"ap-lan-peek":void 0,onPointerEnter:h=>{h.pointerType==="mouse"&&o(eP)},onPointerLeave:i,onFocus:h=>{h.target.matches(":focus-visible")&&o(0)},onBlur:i,children:[a.jsxs("svg",{className:"ap-nav-glyph",width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("rect",{x:"1.8",y:"2.3",width:"10.4",height:"7.2",rx:"1.2"}),a.jsx("path",{d:"M5 11.9h4M7 9.5v2.4"})]}),a.jsxs("span",{className:"ap-nav-text",children:[a.jsx("span",{className:"ap-nav-name",children:"Local network"}),a.jsxs("span",{className:"ap-nav-state","data-tone":e.tone,children:[e.live&&a.jsx("i",{className:"ap-nav-live","aria-hidden":!0}),e.text]})]}),a.jsx("svg",{className:"ap-nav-chev",width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:a.jsx("path",{d:"M5.6 3.4 9.2 7l-3.6 3.6"})})]}),r&&a.jsx("button",{type:"button",className:"ap-lan-map",onClick:()=>{d(),r()},"aria-label":"Show the network map",title:"Network map — every deck this one knows, drawn around it",children:a.jsx(wP,{})}),s&&a.jsx(Ete,{anchorId:"ap-lan-entry",id:"ap-lan-peek",rows:t,onHold:c,onLet:i})]})}function Tte({row:e,run:t,onVerb:n,onUnpair:r}){const[s,o]=y.useState(!1),i=y.useRef(0),[c,d]=y.useState(null);return y.useEffect(()=>{if(!s)return;const p=window.setTimeout(()=>o(!1),4e3);return()=>window.clearTimeout(p)},[s]),y.useEffect(()=>{if(!c)return;const p=window.setTimeout(()=>d(null),4e3);return()=>window.clearTimeout(p)},[c]),{armed:s,armedTwin:c,pressOwn:()=>{const p=Date.now(),g=Xi({armedFor:s?e.fp:null,target:e.fp,armedAt:i.current,now:p,gapMs:Yi});if(g==="arm"){o(!0),d(null),i.current=p;return}g!=="ignore"&&(o(!1),t(n))},pressTwin:p=>{if(!r)return;const g=Date.now(),w=Xi({armedFor:c,target:p,armedAt:i.current,now:g,gapMs:Yi});if(w==="arm"){d(p),o(!1),i.current=g;return}w!=="ignore"&&(d(null),t(()=>r(p)))}}}function Rte({row:e,paired:t,peer:n,status:r,busy:s,press:o,checkNow:i,armed:c,pressOwn:d,run:h,onVerb:f,onInvite:p}){return a.jsxs("footer",{className:"lan-peer-foot",children:[e.kind==="asks"&&a.jsx("p",{className:"lan-foot-note",children:"This deck is now asking to pair. Answer it from the panel behind this."}),t&&!(n!=null&&n.waiting)&&a.jsx("button",{type:"button",className:"btn",...o(`check:${e.fp}`),onClick:i,title:"Ask this deck now instead of waiting for the next round",children:s===`check:${e.fp}`?"Checking…":"Check now"}),e.kind==="paired"&&a.jsx("button",{type:"button",className:`btn danger lan-peer-verb${c?" armed":""}`,...o(`unpair:${e.fp}`),onKeyDown:g=>{g.repeat&&g.preventDefault()},onClick:()=>d(),"aria-label":c?`Confirm unpairing ${e.name}`:`Unpair ${e.name}`,title:c?"Press again to stop talking to this deck. Logins it already has stay with it.":"Stop talking to this deck from now on",children:s===`unpair:${e.fp}`?"Unpairing…":c?"Confirm unpair":"Unpair"}),e.kind==="nearby"&&r.pairingMode!=="invite"&&a.jsx("button",{type:"button",className:"btn primary lan-peer-verb",...o(`accept:${e.fp}`),onClick:()=>void h(f),title:"Send it a request. Somebody at that machine has to accept it before anything is shared.",children:s===`accept:${e.fp}`?"Asking…":"Ask to pair"}),e.kind==="dialling"&&a.jsx("button",{type:"button",className:"btn lan-peer-verb",...o(`drop:${e.fp}`),onClick:()=>void h(f),title:"Stop trying this address. Nothing was ever paired here.",children:s===`drop:${e.fp}`?"Stopping…":"Stop dialling"}),e.kind==="declined"&&r.pairingMode!=="invite"&&a.jsx("button",{type:"button",className:"btn lan-peer-verb",...o(`allow:${e.fp}`),onClick:()=>void h(f),title:"Take the no back. That deck is still trying, so its request comes round again on its own.",children:s===`allow:${e.fp}`?"Allowing…":"Let it ask again"}),(e.kind==="nearby"||e.kind==="declined")&&r.pairingMode==="invite"&&p&&a.jsx("button",{type:"button",className:"btn primary lan-peer-verb",onClick:p,title:"This deck pairs only by invite. Make one and send it to whoever is at that machine.",children:"Invite to pair"})]})}function Ate({instances:e,now:t,busy:n,press:r,armedTwin:s,pressTwin:o,onUnpair:i}){return a.jsxs("div",{className:"modal-section",children:[a.jsxs("h3",{className:"lan-h",children:[e.length," decks on this machine"]}),a.jsx("ul",{className:"lan-twins",role:"list",children:e.map((c,d)=>{var k,j,v,b;const h=(k=c.peer)!=null&&k.addr?`${c.peer.addr}:${c.peer.port}`:c.row.addr,f=h||c.row.fp,p=(j=c.peer)!=null&&j.pairedAt?ns(c.peer.pairedAt,t):null,g=[(b=(v=c.peer)==null?void 0:v.about)!=null&&b.version?`runs ${c.peer.about.version}`:null,p?`paired ${p==="now"?"just now":p}`:null,c.row.state].filter(Boolean).join(" · "),w=c.row.fp;return a.jsxs("li",{role:"listitem",className:"lan-twin","data-tone":c.row.tone,children:[a.jsx("i",{className:c.row.here?"ap-pulse":"ap-dot","aria-hidden":!0}),h?a.jsx("code",{className:"ap-lan-code lan-twin-at",children:h}):a.jsx("span",{className:"lan-twin-at lan-twin-none",children:"no address here"}),a.jsx("code",{className:"ap-lan-code lan-twin-fp",children:w}),d>0&&i&&a.jsx("button",{type:"button",className:`ap-manage-btn danger lan-twin-do${s===w?" armed":""}`,...r(`unpair:${w}`),onKeyDown:N=>{N.repeat&&N.preventDefault()},onClick:()=>o(w),"aria-label":s===w?`Confirm unpairing ${f}`:`Unpair ${f}`,title:s===w?"Press again to stop talking to this deck. Logins it already has stay with it.":"Stop talking to this one of the machine's decks",children:n===`unpair:${w}`?"unpairing…":s===w?"confirm":"unpair"}),a.jsx("span",{className:"lan-twin-meta",children:d===0?`${g} · shown above`:g})]},w)})})]})}function Mte(){return a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("path",{d:"M9.6 2.4l2 2L5 11l-2.6.6L3 9z"}),a.jsx("path",{d:"M8.4 3.6l2 2"})]})}function $te({row:e,source:t,status:n,accounts:r,now:s,busy:o,onClose:i,onRename:c,onCheck:d,onVerb:h,onSettings:f,onInvite:p,twins:g=[],onUnpair:w}){const k=y.useRef(null),j=ot(i,{focusRef:k}),v=dt(i),[b,N]=y.useState(null),[S,E]=y.useState(null),[C,$]=y.useState(!1),[T,I]=y.useState(0),O=y.useRef(null),U=y.useRef(null),P=y.useRef(!0);y.useEffect(()=>()=>{P.current=!1},[]);const L=b!=null;y.useEffect(()=>{var ae;L&&((ae=O.current)==null||ae.select())},[L]);const F=y.useRef(!1);y.useEffect(()=>{var ae,pe;F.current&&!L&&Vn(((ae=document.activeElement)==null?void 0:ae.tagName)??null)&&((pe=U.current)==null||pe.focus()),F.current=L},[L]);const A=ae=>{const pe=Sa(o,ae);return{disabled:pe.disabled,"aria-busy":pe.busy}},B=async ae=>{const pe=await ae();return P.current&&E(pe),pe==null},{armed:D,armedTwin:K,pressOwn:G,pressTwin:H}=Tte({row:e,run:B,onVerb:h,onUnpair:w}),q=yP({row:e,source:t,status:n,accounts:r,now:s}),{peer:M,stranger:V,paired:Z,own:W,canRename:X,fp:Y}=q,J=o===`check:${e.fp}`,ee=async ae=>{const pe=ae.trim()===W?"":ae;await B(()=>c(pe))&&N(null)},ne=()=>void B(d).then(ae=>{ae&&P.current&&I(pe=>pe+1)}),se=async()=>{if(Y)try{if(await navigator.clipboard.writeText(Y),!P.current)return;$(!0),window.setTimeout(()=>{P.current&&$(!1)},1600)}catch{P.current&&E("Could not copy it — select the fingerprint and copy it by hand.")}},ce=[];Z&&(M!=null&&M.pairedAt)?ce.push({label:"Paired",value:rte(M.pairedAt,s),tone:"meta"}):e.kind==="declined"&&V&&ce.push({label:"Paired",value:`no · you said no ${y1(V.at,s)}`,tone:"meta"}),ce.push({label:"Fingerprint",value:Y?a.jsxs("span",{className:"lan-fp",children:[a.jsx("code",{className:"ap-lan-code",children:Y}),a.jsx("button",{type:"button",className:"ap-lan-word lan-copy",onClick:()=>void se(),"aria-label":C?"Fingerprint copied":"Copy the fingerprint",children:C?"copied":"copy"})]}):"not known — nothing has answered there",tone:Y?void 0:"quiet"});const de=g.length?[{row:e,peer:M??null},...g]:[];return yt.createPortal(a.jsx("div",{className:"modal-backdrop",...v,role:"presentation",children:a.jsxs("div",{ref:j,className:"modal lan-peer","data-tone":e.tone,onClick:ae=>ae.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-peer-title","aria-describedby":"lan-peer-sub",children:[a.jsxs("header",{className:"modal-head lan-peer-head",children:[a.jsx("i",{className:e.here?"ap-pulse":"ap-dot","aria-hidden":!0}),a.jsxs("div",{className:"lan-peer-id",children:[L?a.jsxs("form",{className:"lan-peer-edit",onSubmit:ae=>{ae.preventDefault(),ee(b??"")},children:[a.jsx("span",{id:"lan-peer-title",className:"vis-hidden",children:e.name}),a.jsx("input",{ref:O,className:"ap-manage-input lan-peer-input",value:b??"",maxLength:48,placeholder:W,"aria-label":"Name for this deck, shown on this deck only",onChange:ae=>N(ae.target.value)}),a.jsx("button",{type:"submit",className:"ap-manage-btn",...A(`alias:${e.fp}`),children:"save"}),a.jsx("button",{type:"button",className:"ap-manage-btn",onClick:()=>N(null),children:"cancel"})]}):a.jsxs("span",{className:"lan-peer-title",children:[a.jsx("span",{id:"lan-peer-title",className:"lan-peer-name",children:e.name}),X&&a.jsx("button",{type:"button",className:"glyph-btn lan-peer-rename",ref:U,onClick:()=>{E(null),N(e.name)},"aria-label":`Rename ${e.name} on this deck`,title:"Give it a name of your own. Only this deck sees it.",children:a.jsx(Mte,{})})]}),a.jsxs("p",{id:"lan-peer-sub",className:"lan-peer-sub",children:[e.self&&a.jsxs(a.Fragment,{children:["calls itself ",a.jsx("span",{className:"lan-peer-self",children:e.self}),L&&a.jsx("button",{type:"button",className:"ap-lan-word lan-peer-restore",...A(`alias:${e.fp}`),onClick:()=>void ee(""),children:"use this name"}),a.jsx("span",{className:"vis-hidden",children:". "}),!e.quiet&&a.jsx("span",{"aria-hidden":!0,children:" · "})]}),a.jsx("span",{className:e.quiet?"vis-hidden":"lan-peer-state",children:e.state})]})]}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{ref:k,type:"button",className:"glyph-btn",onClick:i,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body lan-peer-body",children:[S&&a.jsxs("div",{className:"ap-failure",role:"alert",children:[a.jsx("span",{className:"ap-failure-text",children:S}),a.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>E(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),a.jsx(ste,{view:q,row:e,status:n,asking:J,drawn:T,onSettings:f}),a.jsx("dl",{className:"lan-facts",children:ce.map(ae=>a.jsxs("div",{className:"lan-fact","data-tone":ae.tone,children:[a.jsx("dt",{children:ae.label}),a.jsx("dd",{children:ae.value})]},ae.label))}),de.length>1&&a.jsx(Ate,{instances:de,now:s,busy:o,press:A,armedTwin:K,pressTwin:H,onUnpair:w})]}),a.jsx(Rte,{row:e,paired:Z,peer:M,status:n,busy:o,press:A,checkNow:ne,armed:D,pressOwn:G,run:B,onVerb:h,onInvite:p})]})}),document.body)}function Ts(e,t){const n=y.useRef(!1);return y.useEffect(()=>{var r,s;!e||!n.current||(n.current=!1,Vn(((r=document.activeElement)==null?void 0:r.tagName)??null)&&(typeof t=="function"?t():(s=t.current)==null||s.focus()))},[e]),()=>{n.current=!0}}function Lte(e,t){if(e.length!==t.length)return!1;const n=new Set(e);return t.every(r=>n.has(r))}function Ote(e,t,n,r){const s=new Set(e??t);return r?s.add(n):s.delete(n),[...s]}function NC(e,t,n){return e==null||n!=null&&!n.ok||Lte(e,t)?null:e}function vP({line:e,onDismiss:t,onAnswer:n}){const[r,s]=y.useState(!1),o=y.useRef(!1),i=y.useRef(!0);y.useEffect(()=>(i.current=!0,()=>{i.current=!1}),[]);const c=y.useRef(null),d=y.useRef(null),h=y.useRef(!1);if(y.useEffect(()=>{var p;h.current&&(h.current=!1,e!=null&&e.giveBack||(p=d.current)==null||p.focus())},[e]),!e)return null;const f=async()=>{if(o.current)return;o.current=!0,s(!0);const p=await LQ();o.current=!1,i.current&&(s(!1),h.current=document.activeElement===c.current,n(IQ(p)))};return a.jsxs("div",{className:e.done?"ap-failure ap-failure-done":"ap-failure",role:"alert",children:[a.jsx("span",{className:"ap-failure-text",children:e.text}),e.giveBack&&a.jsx("button",{ref:c,type:"button",className:"ap-fix ap-give-back","aria-busy":r,onClick:f,title:"Opens macOS's password dialog to make the settings folder yours again",children:r?"waiting for macOS…":"give it back"}),a.jsx("button",{ref:d,type:"button",className:"ap-failure-x",onClick:t,"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]})}function Ite(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 Bd="Paused while this deck pairs only by invite. Turn that off above to use it.";function Pte({status:e,accounts:t,onClose:n,onChanged:r}){Jt("lan-setup");const s=ot(n),o=dt(n),[i,c]=y.useState(null),[d,h]=y.useState(null),[f,p]=y.useState(!1),[g,w]=y.useState(null),k=y.useRef(null),j=H=>{const q=Sa(g,H);return{disabled:q.disabled,"aria-busy":q.busy}},v=y.useRef(null),b=y.useRef(!0);y.useEffect(()=>()=>{b.current=!1},[]),y.useEffect(()=>{v.current=NC(v.current,e.shared??[],null)},[e.shared]);const N=y.useCallback(async(H,q,M="write")=>{k.current=M,w(M);try{const Z=await(await fetch("/api/prefs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({lan:H})})).json().catch(()=>null);return b.current?(Z!=null&&Z.ok?h(null):h(kr(Bt(q,Z),Z)),r(),(Z==null?void 0:Z.ok)===!0):!1}catch{return b.current&&h(kr(Bt(q,null))),!1}finally{k.current=null,b.current&&w(null)}},[r]),S=y.useCallback(async H=>{const q=await N({name:H},"save the name","name");return q&&b.current&&c(M=>M===H?null:M),q},[N]),E=y.useRef(null),C=i!=null&&i!==(e.name??""),$=Ts(!C,E),T=y.useCallback(async()=>{C&&!await S(i)||n()},[C,i,S,n]),I=async()=>{if(!e.fp)return;const H=await Mo(e.fp);if(b.current){if(!H){h(kr("Could not copy it — select the fingerprint and copy it by hand."));return}p(!0),window.setTimeout(()=>{b.current&&p(!1)},1600)}},O=new Set(v.current??e.shared??[]),U=e.autoAsk!==!1,P=e.autoAccept!==!1,L=e.pairingMode==="invite",F=H=>{const q=j(H);return{...q,disabled:q.disabled||L}},A=e.shareActive!==!1,B=e.tailscale??null,D=!!(B!=null&&B.on),K=(B==null?void 0:B.ask)!==!1,G=(B==null?void 0:B.accept)!==!1;return yt.createPortal(a.jsx("div",{className:"modal-backdrop",...o,role:"presentation",children:a.jsxs("div",{ref:s,className:"modal lan-modal",onClick:H=>H.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-modal-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{id:"lan-modal-title",className:"modal-tool-name",children:"This deck on the network"})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{className:"glyph-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[a.jsx(vP,{line:d,onDismiss:()=>h(null),onAnswer:H=>{h(H),H.done&&r()}}),a.jsxs("div",{className:"modal-section",children:[a.jsx("h3",{className:"lan-h",children:"Name"}),a.jsxs("div",{className:"ap-lan-row",children:[a.jsx("span",{className:"ap-lan-label",children:"appear as"}),a.jsx("input",{ref:E,className:"ap-manage-input ap-lan-input","aria-label":"This deck's name on the network",value:i??e.name??"",placeholder:"this machine",onChange:H=>c(H.target.value),onKeyDown:H=>{H.key!=="Enter"||i==null||S(i)}}),C&&a.jsx("button",{type:"button",className:"ap-manage-btn",...j("name"),onClick:()=>{$(),S(i)},title:"Save it. This is the name other decks show for this one.",children:"save"})]}),a.jsxs("div",{className:"ap-lan-row",children:[a.jsx("span",{className:"ap-lan-label",children:"fingerprint"}),e.fp?a.jsxs("span",{className:"lan-fp",children:[a.jsx("code",{className:"ap-lan-code",children:e.fp}),a.jsx("button",{type:"button",className:"ap-lan-word lan-copy",onClick:()=>void I(),"aria-label":f?"Fingerprint copied":"Copy this deck's fingerprint",children:f?"copied":"copy"})]}):a.jsx("span",{className:"ap-lan-label",children:"not known yet"})]})]}),a.jsxs("div",{className:"modal-section",children:[a.jsx("h3",{className:"lan-h",children:"Share these accounts"}),a.jsxs("div",{className:"ap-lan-picks",children:[t.length===0&&a.jsx("span",{className:"ap-lan-empty",children:"No Claude accounts on this deck yet — add one with + at the top of this panel."}),t.map(H=>a.jsxs("label",{className:"ap-lan-pick",title:H.alive?"Offer this account to the decks you have paired with, so one whose copy has died can heal from yours. Unticking stops it being offered from now on; it does not take back a copy somebody already has.":"This deck cannot use this login, so it has nothing to offer — a deck that can will heal it",children:[a.jsx("input",{type:"checkbox",checked:O.has(H.key),onChange:q=>{const M=Ote(v.current,e.shared??[],H.key,q.target.checked);v.current=M,N({shared:M},q.target.checked?"share that account":"stop sharing that account").then(V=>{v.current===M&&(v.current=NC(M,e.shared??[],{ok:V}))})}}),a.jsx("span",{className:"ap-lan-pick-name",children:H.email}),!H.alive&&a.jsx("span",{className:"ap-lan-dead",children:"not working here"})]},H.key))]}),t.length>0&&a.jsxs("div",{className:"lan-switch",children:[a.jsx("span",{className:"lan-switch-what",children:"Show paired decks which of these this deck is using"}),a.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":A,"aria-label":"Show paired decks which of these this deck is using",...j("current"),onClick:()=>void N({shareActive:!A},A?"stop showing which account this deck is using":"show which account this deck is using","current"),title:A?"Stop telling paired decks which account this one is on. They read “current account hidden” instead.":"Tell paired decks which of the ticked accounts this one is on. An unticked account is never named.",children:a.jsx("span",{className:"switch-knob"})})]})]}),a.jsxs("div",{className:"modal-section",children:[a.jsx("h3",{className:"lan-h",id:"lan-pairing-h",children:"Pairing"}),a.jsx("div",{className:"lan-switches lan-switches-lead",role:"group","aria-labelledby":"lan-pairing-h",children:a.jsxs("div",{className:"lan-switch",children:[a.jsxs("span",{className:"lan-switch-what",children:["Pair new decks only by invite",L&&a.jsx("span",{id:"lan-invite-only-detail",className:"lan-switch-detail",children:"A new deck needs an invite from Add a deck, the link at the top of Local network. Paired decks stay paired."})]}),a.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":L,"aria-label":"Pair new decks only by invite","aria-describedby":L?"lan-invite-only-detail":void 0,...j("mode"),onKeyDown:H=>{H.repeat&&H.preventDefault()},onClick:()=>void N({pairingMode:L?"automatic":"invite"},L?"let decks pair on their own again":"pair new decks only by invite","mode"),title:L?"Let decks on this network pair as the two switches below say again.":"Only a deck you send an invite to can pair with this one. Nearby decks can't ask, and requests waiting now are turned away.",children:a.jsx("span",{className:"switch-knob"})})]})}),a.jsxs("div",{className:"lan-auto",role:"group","aria-labelledby":"lan-auto-h",children:[a.jsxs("p",{className:"lan-sub",id:"lan-auto-h",children:["Automatic pairing",L&&a.jsx("span",{className:"lan-sub-state",children:" · paused while pairing is invite-only"})]}),a.jsxs("div",{className:"lan-switches","data-paused":L||void 0,children:[a.jsxs("div",{className:"lan-switch",children:[a.jsx("span",{className:"lan-switch-what",children:"Ask every deck this one finds"}),a.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":U,"aria-label":"Ask every deck this one finds",...F("ask"),onClick:()=>void N({autoAsk:!U},U?"stop asking automatically":"ask every deck this one finds","ask"),title:L?Bd:U?"Stop sending requests on their own. You press ask on the row instead.":"Send a pairing request to every deck heard on this network. Somebody over there still has to say yes.",children:a.jsx("span",{className:"switch-knob"})})]}),a.jsxs("div",{className:"lan-switch",children:[a.jsx("span",{className:"lan-switch-what",children:"Say yes to every deck that asks"}),a.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":P,"aria-label":"Say yes to every deck that asks","data-tone":"warn",...F("accept"),onKeyDown:H=>{H.repeat&&H.preventDefault()},onClick:()=>void N({autoAccept:!P},P?"stop accepting automatically":"accept every deck that asks","accept"),title:L?Bd:P?"Stop saying yes for you. A deck that asks waits in the panel again, and adds no login here until somebody here accepts it.":"Say yes for you. Every deck on this network that asks is paired without anybody being asked here. Each can then add the logins ticked on it to this deck.",children:a.jsx("span",{className:"switch-knob"})})]})]})]})]}),(B==null?void 0:B.found)&&a.jsxs("div",{className:"modal-section",children:[a.jsx("h3",{className:"lan-h",children:"Tailscale"}),a.jsxs("div",{className:"lan-switches",children:[a.jsxs("div",{className:"lan-switch",children:[a.jsxs("span",{className:"lan-switch-what",children:["Look for my devices",a.jsx("span",{id:"lan-ts-detail",className:"lan-switch-detail",children:Ite(B)})]}),a.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":D,"aria-label":"Look for my devices over Tailscale","aria-describedby":"lan-ts-detail",...j("tailscale"),onClick:()=>void N({tailscale:!D},D?"stop looking over Tailscale":"look for your devices over Tailscale","tailscale"),title:D?"Stop. Nothing is looked for or answered over the tailnet; decks already paired stay paired.":"Find the decks on your other machines on Tailscale, wherever they are. Only machines signed in to your Tailscale account are asked.",children:a.jsx("span",{className:"switch-knob"})})]}),D&&a.jsxs("div",{className:"lan-auto",role:"group","aria-labelledby":"lan-ts-auto-h",children:[a.jsxs("p",{className:"lan-sub",id:"lan-ts-auto-h",children:["Automatic pairing with my devices",L&&a.jsx("span",{className:"lan-sub-state",children:" · paused while pairing is invite-only"})]}),a.jsxs("div",{className:"lan-switches",children:[a.jsxs("div",{className:"lan-switch","data-paused":L||void 0,children:[a.jsx("span",{className:"lan-switch-what",children:"Ask each device it finds"}),a.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":K,"aria-label":"Ask each of my devices it finds over Tailscale",...F("tailscale-ask"),onClick:()=>void N({tailscaleAsk:!K},K?"stop asking your devices automatically":"ask your devices automatically","tailscale-ask"),title:L?Bd:K?"Stop sending requests on their own. You press ask on the row instead.":"Send a pairing request to every deck found on your devices over Tailscale.",children:a.jsx("span",{className:"switch-knob"})})]}),a.jsxs("div",{className:"lan-switch","data-paused":L||void 0,children:[a.jsx("span",{className:"lan-switch-what",children:"Say yes to each device that asks"}),a.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":G,"aria-label":"Say yes to my devices when they ask over Tailscale","data-tone":"warn",...F("tailscale-accept"),onKeyDown:H=>{H.repeat&&H.preventDefault()},onClick:()=>void N({tailscaleAccept:!G},G?"stop accepting your devices automatically":"accept your devices automatically","tailscale-accept"),title:L?Bd:G?"Stop saying yes for you. A device that asks waits in the panel again.":"Say yes for you when a deck on one of your own devices asks. Anybody else on the tailnet still waits for a press.",children:a.jsx("span",{className:"switch-knob"})})]})]})]})]})]})]}),a.jsxs("footer",{className:"lan-setup-foot",children:[a.jsx("span",{className:"lan-foot-note",children:"Changes are saved as you make them."}),a.jsx("button",{type:"button",className:"btn primary",...j("name"),onClick:()=>void T(),children:"Done"})]})]})}),document.body)}function Dte({on:e,status:t,paired:n,busy:r,pressProps:s,checkNow:o,setAddOpen:i,setSetupOpen:c,setMapOpen:d,onBack:h,closeButton:f}){return a.jsxs("div",{className:"ap-header",children:[a.jsx("button",{type:"button",id:"ap-lan-back",className:"glyph-btn ap-back",onClick:h,"aria-label":"Back to Claude accounts",title:"Back to Claude accounts",children:a.jsx("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:a.jsx("path",{d:"M8.4 3.4 4.8 7l3.6 3.6"})})}),a.jsx("h2",{id:"ap-lan-title",children:"Local network"}),a.jsxs("div",{className:"ap-header-right",children:[e&&a.jsx("button",{type:"button",className:"glyph-btn",onClick:()=>d(!0),"aria-label":"Show the network map",title:"Network map — every deck this one knows, drawn around it",children:a.jsx(wP,{})}),e&&a.jsx("button",{type:"button",className:"glyph-btn ap-lan-plus",onClick:()=>i("add"),"aria-label":"Add a deck",title:(t==null?void 0:t.pairingMode)==="invite"?"Send an invite, or use one you were sent. This deck pairs only by invite.":"Reach a deck that has not turned up on its own — by address, or with an invite",children:a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("path",{d:"M6.1 7.9a2.6 2.6 0 0 0 3.7 0l1.9-1.9a2.6 2.6 0 0 0-3.7-3.7l-.9.9"}),a.jsx("path",{d:"M7.9 6.1a2.6 2.6 0 0 0-3.7 0L2.3 8a2.6 2.6 0 0 0 3.7 3.7l.9-.9"})]})}),e&&n>0&&a.jsx("button",{type:"button",className:"glyph-btn ap-lan-check",...s("check"),onClick:()=>void o(),"aria-label":r==="check"?"Checking every paired deck":"Check every paired deck now",title:"Ask every paired deck now for anything this deck's expired logins need, instead of waiting for the next round",children:a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("circle",{cx:"7",cy:"7",r:"1.1",fill:"currentColor",stroke:"none"}),a.jsx("path",{d:"M4.6 4.6a3.4 3.4 0 0 0 0 4.8M9.4 4.6a3.4 3.4 0 0 1 0 4.8"}),a.jsx("path",{d:"M2.6 2.6a6.2 6.2 0 0 0 0 8.8M11.4 2.6a6.2 6.2 0 0 1 0 8.8"})]})}),e&&a.jsx("button",{type:"button",className:"glyph-btn ap-lan-set",...s("setup"),onClick:()=>c(!0),"aria-label":"This deck's name and shared logins",title:"This deck's name on the network, and which of its logins it offers",children:a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":!0,children:[a.jsx("path",{d:"M1.8 4.7h10.4M1.8 9.3h10.4"}),a.jsx("circle",{cx:"9.1",cy:"4.7",r:"1.6",fill:"var(--panel)"}),a.jsx("circle",{cx:"4.9",cy:"9.3",r:"1.6",fill:"var(--panel)"})]})}),f]})]})}function Fte({accounts:e,onChanged:t,onNoCopy:n,view:r,onOpen:s,onBack:o,closeButton:i}){const[c,d]=y.useState(!1),[h,f]=y.useState(!1),[p,g]=y.useState(!1),w=MQ(),[k,j]=y.useState(!1),{status:v,manual:b,now:N,busy:S,failure:E,dismissFailure:C,answerGiveBack:$,pressProps:T,load:I,toggle:O,answer:U,dropAddress:P,rename:L,checkOne:F,checkNow:A}=qQ(t,()=>d(!0)),{armed:B,pressUnpair:D}=UQ(U),[K,G]=y.useState(null),[H,q]=y.useState(!1),M=y.useMemo(()=>e.filter(fe=>RQ(fe.key,v??null,N)).map(fe=>fe.key).sort().join(`
|
|
95
|
-
`),[e,v,N]);y.useEffect(()=>{n==null||n(M?M.split(`
|
|
96
|
-
`):[])},[M,n]);const V=(v==null?void 0:v.enabled)===!0,Z=y.useMemo(()=>vQ((v==null?void 0:v.pairingMode)==="invite"&&v?{...v,pending:[]}:v,N),[v,N]),W=K?Z.find(fe=>{var Ee;return fe.fp===K||((Ee=fe.twins)==null?void 0:Ee.some(ye=>ye.fp===K))})??null:null;y.useEffect(()=>{K&&v&&!W&&G(null)},[K,v,W]);const{asks:X,rest:Y,live:J,folded:ee,troubled:ne,shown:se,paired:ce}=TQ(Z,k),de=yQ(v,N),ae=CQ(v,Z),pe=a.jsxs(a.Fragment,{children:[h&&v&&a.jsx(uee,{status:v,manual:b,startWith:h==="invite"?"invite":void 0,onClose:()=>f(!1),onChanged:()=>{I(),t()}}),p&&a.jsx(rP,{title:"How Local network works",steps:nee,finish:V?void 0:{label:"Turn it on",act:()=>{g(!1),O()}},onClose:()=>g(!1)}),c&&v&&a.jsx(Pte,{status:{...v,manualRows:b},accounts:e,manual:b,onClose:()=>d(!1),onChanged:()=>{I(),t()}}),H&&a.jsx(pte,{status:v,rows:Z,accounts:e,now:N,covered:!!W||c||!!h||p,onOpenDeck:G,onClose:()=>q(!1)}),W&&v&&a.jsx($te,{row:W,source:qc(v,W),status:v,accounts:e,now:N,busy:S,onClose:()=>G(null),onRename:fe=>L(W.fp,fe),onCheck:()=>F(W.fp),onVerb:()=>{switch(W.kind){case"paired":return U("unpair",W.fp,"unpair that deck");case"nearby":return U("accept",W.fp,"reach that deck");case"declined":return U("allow",W.fp,"let that deck ask again");case"dialling":return P(W.fp);default:return Promise.resolve(null)}},onSettings:()=>{G(null),d(!0)},onInvite:()=>{G(null),f("invite")},twins:(W.twins??[]).map(fe=>({row:fe,peer:qc(v,fe).peer??null})),onUnpair:fe=>U("unpair",fe,"unpair that deck")})]});return r?a.jsxs("div",{className:"ap-lan-view",children:[a.jsx(Dte,{on:V,status:v,paired:ce,busy:S,pressProps:T,checkNow:A,setAddOpen:f,setSetupOpen:d,setMapOpen:q,onBack:o,closeButton:i}),a.jsx("div",{className:"ap-scroll",id:"ap-lan-scroll",children:a.jsxs("div",{className:"ap-lan",children:[a.jsxs("div",{className:"ap-policy",children:[a.jsx("h3",{className:"ap-auto-title",children:"Sync with paired decks"}),a.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":V,"aria-label":"Sync with paired decks",...T("switch"),onClick:()=>void O(),title:V?"Stop talking to other decks. Nothing is shared while this is off.":"Let the decks you pair with repair this one's expired logins",children:a.jsx("span",{className:"switch-knob"})})]}),a.jsx(mee,{on:V,status:v}),!V&&a.jsxs("div",{className:"ap-lan-intro-row",children:[a.jsxs("button",{type:"button",className:"ap-lan-intro",onClick:()=>g(!0),title:"Four pictures: what this does, and what to do on each machine",children:[a.jsx(ree,{}),a.jsx("span",{className:"ap-lan-intro-text",children:"Paired machines repair each other's expired logins."}),a.jsx("span",{className:"ap-lan-intro-go",children:"See how it works"})]}),a.jsx(Ic,{film:"localNetwork"})]}),a.jsx("p",{className:`ap-lan-status ${de.tone}`,role:"status",children:de.tone==="ok"?"":de.text}),a.jsx(vP,{line:E,onDismiss:C,onAnswer:$}),V&&a.jsxs(a.Fragment,{children:[X.length>0&&a.jsx(hee,{asks:X,pressProps:T,answer:U}),se.length>0&&a.jsx(fee,{rows:se,pairingMode:v==null?void 0:v.pairingMode,armed:B,pressProps:T,answer:U,dropAddress:P,onUnpair:D,onOpenPeer:G,onInvite:()=>f("invite")}),(J.length>0&&ee.length>0||V&&ce>0)&&a.jsxs("div",{className:"ap-lan-tail",children:[J.length>0&&ee.length>0&&a.jsxs("button",{type:"button",className:"ap-lan-word ap-lan-more","aria-expanded":k,onClick:()=>j(fe=>!fe),title:k?"Show only the decks that are on":`Show the ${ee.length} deck${ee.length===1?"":"s"} that are not responding right now`,children:[a.jsx("span",{className:`ap-lan-chev${k?" open":""}`,"aria-hidden":!0,children:"›"}),k?"fewer":`${ee.length} more`,!k&&ne>0&&a.jsxs("span",{className:"ap-lan-more-bad",children:[" · ",ne," not responding"]})]}),V&&ce>0&&a.jsx("span",{className:"ap-lan-checked",children:wQ(v==null?void 0:v.checkedAt,N,S==="check")})]}),Y.length===0&&X.length===0&&!(v!=null&&v.stalled)&&!(v!=null&&v.deaf)&&!(v!=null&&v.lanTunneled)&&a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"ap-lan-fine",children:"No other deck yet. Decks on one network usually find each other on their own; when that has not happened, the link at the top of this view reaches one by address or by invite."}),a.jsx("button",{type:"button",className:"ap-lan-word ap-lan-how",onClick:()=>g(!0),children:"How it works"}),a.jsx(Ic,{film:"localNetwork"})]})]})]})}),pe]}):a.jsxs("div",{className:"ap-foot",children:[a.jsx(Cte,{entry:ae,rows:Z,onOpen:s,onMap:V?()=>q(!0):void 0,...w}),a.jsx("p",{className:"vis-hidden",role:"status",children:de.tone==="ok"?"":de.text}),pe]})}function Bte({anchorId:e,id:t,peers:n,onHold:r,onLet:s}){const o=y.useRef(null),{title:i,shown:c,rest:d}=dQ(n),h=y.useCallback(()=>{const f=o.current,p=document.getElementById(e);if(!f||!p)return;f.style.maxHeight="";const g=o1(p.getBoundingClientRect(),{width:f.offsetWidth,height:f.offsetHeight},{width:window.innerWidth,height:window.innerHeight});f.style.top=`${g.top}px`,f.style.left=`${g.left}px`,f.style.maxHeight=g.maxHeight==null?"":`${g.maxHeight}px`,f.dataset.side=g.side},[e]);return y.useLayoutEffect(()=>{h()}),y.useEffect(()=>(window.addEventListener("scroll",h,!0),window.addEventListener("resize",h),()=>{window.removeEventListener("scroll",h,!0),window.removeEventListener("resize",h)}),[h]),yt.createPortal(a.jsxs("div",{ref:o,id:t,className:"ap-peek ap-fold-peek",role:"tooltip",onPointerEnter:r,onPointerLeave:s,children:[a.jsx("p",{className:"ap-peek-title",children:i}),a.jsx("div",{className:"ap-peek-list",children:c.map(f=>a.jsxs("span",{className:"ap-peek-who ap-fold-who",children:[a.jsx("span",{className:"ap-fold-name",title:f.name,children:f.name}),a.jsx("span",{className:"ap-fold-state","data-tone":f.ready?"ok":f.warn?"warn":"idle",children:f.ready?f.headroom==null?"not read yet":`${Math.round(f.headroom)}% free`:f.why})]},f.key))}),d&&a.jsx("p",{className:"ap-peek-rest",children:d})]}),document.body)}function qte({peers:e,strained:t,armed:n,threshold:r,open:s,onToggle:o,order:i,choices:c,onOrder:d,allOpen:h,onToggleAll:f,held:p=!1}){const[g,w]=y.useState(!1),k=y.useRef(0);y.useEffect(()=>()=>window.clearTimeout(k.current),[]),y.useEffect(()=>{s&&(window.clearTimeout(k.current),w(!1))},[s]);const j=E=>{s||(window.clearTimeout(k.current),k.current=window.setTimeout(()=>w(!0),E))},v=()=>{window.clearTimeout(k.current),k.current=window.setTimeout(()=>w(!1),tP)},b=()=>window.clearTimeout(k.current),N=()=>{window.clearTimeout(k.current),w(!1)},S=cQ(e,{strained:t&&!s,armed:n,threshold:r});return a.jsxs("div",{className:"ap-rest",children:[a.jsxs("button",{type:"button",id:"ap-rest-entry",className:"ap-nav","aria-expanded":s,"aria-controls":s?"ap-rest-panel":void 0,"aria-describedby":g?"ap-rest-peek":void 0,onClick:()=>{N(),o()},onPointerEnter:E=>{E.pointerType==="mouse"&&j(eP)},onPointerLeave:v,onFocus:E=>{E.target.matches(":focus-visible")&&j(0)},onBlur:v,children:[a.jsxs("span",{className:"ap-nav-text",children:[a.jsx("span",{className:"ap-nav-name",children:"Other accounts"}),a.jsx("span",{className:"ap-nav-state","data-tone":S.tone,children:S.text})]}),a.jsx("svg",{className:"ap-nav-chev",width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:a.jsx("path",{d:"M5.6 3.4 9.2 7l-3.6 3.6"})})]}),g&&a.jsx(Bte,{anchorId:"ap-rest-entry",id:"ap-rest-peek",peers:e,onHold:b,onLet:v}),s&&a.jsx(Ute,{order:i,choices:c,onOrder:d,allOpen:h,onToggleAll:f,held:p})]})}function Ute({order:e,choices:t,onOrder:n,allOpen:r,onToggleAll:s,held:o}){var d;const i=y.useRef(null);y.useLayoutEffect(()=>{const h=i.current,f=h==null?void 0:h.parentElement;if(!h||!f)return;const p=()=>f.style.setProperty("--rest-tools-w",`${Math.ceil(h.offsetWidth)}px`);if(p(),typeof ResizeObserver>"u")return;const g=new ResizeObserver(p);return g.observe(h),()=>{g.disconnect(),f.style.removeProperty("--rest-tools-w")}},[]);const c=((d=t.find(h=>h.id===e))==null?void 0:d.label)??"Slot";return a.jsxs("div",{className:"ap-rest-tools",ref:i,children:[a.jsxs("span",{className:"ap-rest-sort",children:[a.jsx("select",{value:e,onChange:h=>n(h.target.value),"aria-label":"Order of the other accounts",title:o?`${c} — held where it was while you are in the list`:c,"data-sorted":e===Sf?void 0:"","data-held":o?"":void 0,children:t.map(h=>a.jsx("option",{value:h.id,children:h.label},h.id))}),a.jsx("svg",{width:"9",height:"9",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:a.jsx("path",{d:"M2.5 3.8 5 6.3l2.5-2.5"})})]}),a.jsx("button",{type:"button",className:"ap-rest-all","aria-label":"Expand every account","aria-pressed":r,"aria-controls":"ap-rest-list",title:r?"Collapse every account":"Expand every account",onClick:s,children:a.jsx("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:a.jsx("path",{d:r?"M2 7h10M7 1.5V5M5.2 3.2 7 5l1.8-1.8M7 12.5V9M5.2 10.8 7 9l1.8 1.8":"M2 7h10M7 1.5V5M5.2 3.3 7 1.5l1.8 1.8M7 12.5V9M5.2 10.7 7 12.5l1.8-1.8"})})})]})}async function Hte(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}const Wte=1800;function zte({accounts:e,onClose:t,copyText:n}){Jt("share-accounts");const[r,s]=y.useState([]),[o,i]=y.useState(null),[c,d]=y.useState(!1),[h,f]=y.useState(null),[p,g]=y.useState(!1),[w,k]=y.useState(()=>Math.floor(Date.now()/1e3)),j=y.useRef(null),v=y.useRef(!1),b=ot(t,{focusRef:j}),N=dt(t),S=Ts(o!=null,j),E=Ts(o==null,j);y.useEffect(()=>{if(!o)return;k(Math.floor(Date.now()/1e3));const D=window.setInterval(()=>k(Math.floor(Date.now()/1e3)),1e3);return()=>window.clearInterval(D)},[o]);const C=VJ(e),$=GJ(e,r),T=$.length===e.length,I=D=>s(K=>KJ(K,D)),O=y.useCallback(async()=>{const D=YJ($);if(!qn(v.current)||!D)return;v.current=!0,d(!0),f(null),g(!1);const K=await Hte(D).catch(()=>null);if(v.current=!1,d(!1),!(K!=null&&K.ok)){f(Ci(K,"the share could not be made"));return}i({blob:K.blob,expiresAt:K.expiresAt,shared:K.shared??[],failed:K.failed??[]})},[e,$]),U=o?Y3(o.expiresAt,w):null,P=(U==null?void 0:U.tone)==="gone",L=(o==null?void 0:o.shared.length)??0,F=P?"This share has expired":L===1?"1 account, ready to paste":`${L} accounts, ready to paste`,A=L===1?"this is the password":`this is ${L} passwords`,B=o?P?F:`${F} — ${A}`:"";return yt.createPortal(a.jsx("div",{className:"modal-backdrop",...N,role:"presentation",children:a.jsxs("div",{ref:b,className:"modal sa-modal",onClick:D=>D.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Share accounts with another deck",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("h3",{children:"Share accounts"})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body sa-body",children:[a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:B}),o?a.jsxs("div",{className:"sa-step",children:[a.jsx("h4",{children:F}),a.jsx("code",{className:"ap-share-blob",children:o.blob}),a.jsxs("div",{className:"ap-share-foot",children:[a.jsx("button",{type:"button",className:"ap-manage-btn",ref:j,onClick:async()=>{if(P){E(),S(),i(null),O();return}await n(o.blob)&&(g(!0),window.setTimeout(()=>g(!1),Wte))},children:P?"make a new share":p?"copied":`copy ${L===1?"the share":"all "+L}`}),a.jsxs("span",{className:"ap-manage-hint",title:"This text is the sign-in for every account in it. It is base64 of plain JSON — the expiry inside it is not signed, so anyone holding a copy can change it, and the logins themselves are in there in the clear either way. The countdown only says how long another deck's import dialog will still accept it. If a copy escapes, sign those accounts out and back in.",children:[a.jsx("span",{className:"ap-share-warn",children:A})," · ",a.jsx("span",{className:`ap-share-expiry ${U==null?void 0:U.tone}`,children:U==null?void 0:U.text})]})]}),o.failed.length>0&&a.jsxs("div",{className:"sa-failed",role:"alert",children:[a.jsx("p",{className:"sa-failed-head",children:o.failed.length===1?"One account is not in this bundle:":`${o.failed.length} accounts are not in this bundle:`}),a.jsx("ul",{className:"sa-list",children:o.failed.map(D=>{var G;const K=!!(D.email&&((G=D.detail)!=null&&G.includes(D.email)));return a.jsxs("li",{children:[!K&&a.jsx("span",{className:"sa-who",children:D.email||`account ${D.num}`}),a.jsx("span",{className:"sa-why",children:D.detail||"could not be exported"})]},`${D.num}-${D.email}`)})})]}),a.jsx("p",{className:"sa-note",children:P?a.jsx(a.Fragment,{children:"Another deck will refuse this text now. Make a new one — the same accounts are still picked."}):a.jsxs(a.Fragment,{children:["Paste it into the other deck with ",a.jsx("strong",{children:"+"})," → ",a.jsx("strong",{children:"Paste a share"}),". Accounts it already holds are left exactly as they are."]})}),a.jsxs("div",{className:"sa-actions",children:[a.jsx("button",{type:"button",className:"btn",onClick:()=>{E(),i(null),g(!1)},children:"Pick again"}),a.jsx("button",{type:"button",className:"btn primary",onClick:t,children:"Done"})]})]}):e.length===0?a.jsxs("div",{className:"sa-step",children:[a.jsx("h4",{children:"Nothing to share"}),a.jsxs("p",{className:"sa-note",children:["This deck is not holding any accounts right now. Sign one in with ",a.jsx("strong",{children:"+"}),", or wait — the panel is still reading the store."]}),a.jsx("div",{className:"sa-actions",children:a.jsx("button",{type:"button",className:"btn primary",ref:j,onClick:t,children:"Close"})})]}):a.jsxs("div",{className:"sa-step",children:[a.jsxs("h4",{children:["Which accounts go to the other ",Lt,"?"]}),a.jsx("p",{className:`sa-count${$.length?"":" empty"}`,children:XJ($.length)}),a.jsx("ul",{className:"sa-list sa-pick",children:C.map(D=>a.jsx("li",{children:a.jsxs("label",{className:"sa-row",children:[a.jsx("input",{type:"checkbox",checked:$.includes(D.num),onChange:()=>I(D.num)}),a.jsx("span",{className:"sa-who",children:D.label}),D.sub&&a.jsx("span",{className:"sa-sub",children:D.sub})]})},D.num))}),h&&a.jsx("p",{className:"aa-err",role:"alert",children:h}),a.jsxs("div",{className:"sa-actions",children:[a.jsx("button",{type:"button",className:"btn",onClick:()=>s(T?e.map(D=>D.num):[]),children:T?"Clear all":"Select all"}),a.jsx("button",{type:"button",className:"btn primary",ref:j,...ts(c,!$.length),onClick:()=>{S(),O()},children:c?"making the share…":$.length===0?"Share":$.length===1?"Share 1 account":`Share ${$.length} accounts`})]})]})]})]})}),document.body)}function bP(e,t){var n;return!e.disabled&&!((n=Co(e,t))!=null&&n.blocksSwitch)}function Vte(e,t,n){return e.map(r=>{const s=Co(r,t,n==null?void 0:n(r));return{key:_r(r),name:r.alias??r.email??`account ${r.num}`,ready:bP(r,t),why:r.disabled?"held out":s!=null&&s.blocksSwitch?s.text:null,warn:(s==null?void 0:s.tone)==="warn",headroom:l1(r,t)}})}function Gte(e,t,n){const r=Number(t),s=e&&(n==null?e.headroom:l1(e,n));return s!=null&&Number.isFinite(r)&&100-s>=r}function Kte(e){return(e==null?void 0:e.ok)===!0&&(e.enabled||e.external)}const kP="agent-dag.otherAccountsOrder",jP="agent-dag.otherAccountsOpen";function Yte(){const e=Ge(kP);return typeof e=="string"&&e.length>0&&e.length<=64?e:Sf}function Xte(e){Ve(kP,e)}function Zte(){const e=Ge(jP);if(!e)return O0;try{const t=JSON.parse(e);if(((t==null?void 0:t.mode)==="some"||(t==null?void 0:t.mode)==="all")&&Array.isArray(t.keys)&&t.keys.every(n=>typeof n=="string"))return{mode:t.mode,keys:t.keys.slice(0,200)}}catch{}return O0}function Jte(e){Ve(jP,JSON.stringify({mode:e.mode,keys:e.keys.filter(t=>!t.startsWith("slot:"))}))}function Qte(){const[e,t]=y.useState(null),n=y.useRef(null),r=y.useCallback(i=>bf(n.current)?(n.current=i,t(i),!0):!1,[]),s=y.useCallback(()=>{n.current=null,t(null)},[]);return{busy:e,claim:r,release:s,pressProps:(i,c=!1)=>{const d=Sa(e,i);return{disabled:d.disabled,"aria-busy":d.busy||c}}}}const ene=8e3,tne=1800,nne=4e3;function rne({claim:e,release:t,load:n,clearFailure:r,rescueFocus:s}){const[o,i]=y.useState(null),c=(o==null?void 0:o.num)??null,d=y.useRef(o);d.current=o;const[h,f]=y.useState(null),[p,g]=y.useState(""),[w,k]=y.useState(null),j=y.useRef(0);y.useEffect(()=>{if(w==null)return;const Z=window.setTimeout(()=>k(null),nne);return()=>window.clearTimeout(Z)},[w]);const[v,b]=y.useState(null),[N,S]=y.useState(!1),[E,C]=y.useState(null),[$,T]=y.useState(null),I=y.useCallback(async(Z,W)=>{if(!e(W))return null;r(),f(null);try{const X=await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(Z)}),Y=await X.json().catch(()=>null);return Y!=null&&Y.ok||f({text:Ci(Y,"command failed",X.status)}),Y}catch{return f({text:"server unreachable"}),null}finally{t()}},[e,t,r]),O=y.useCallback(()=>{i(null),f(null),k(null),b(null),S(!1)},[]),U=(Z,W="first")=>{O(),T(null),i({num:Z,view:"menu",start:W})},P=y.useCallback(Z=>{var Y,J;const W=d.current;if(!W||Z!=null&&W.num!==Z)return;const X=document.getElementById(`ap-menu-${W.num}`);(X!=null&&X.contains(document.activeElement)||Vn(((Y=document.activeElement)==null?void 0:Y.tagName)??null))&&((J=document.getElementById(`ap-more-${W.num}`))==null||J.focus()),O()},[O]),L=y.useCallback(Z=>f(Z),[]),F=(Z,W)=>{g(W??""),f(null),i({num:Z,view:"rename"})},A=Z=>g(Z),B=Z=>{T(null),f(null),i({num:Z,view:"move"})},D=Z=>T(Z),K=async Z=>{var X;S(!1);const W=await I({action:"share",account:Z},`share-${Z}`);!(W!=null&&W.ok)||((X=d.current)==null?void 0:X.num)!==Z||(b({num:Z,blob:W.blob,expiresAt:W.expiresAt}),i({num:Z,view:"share"}))},G=async Z=>{await Mo(Z)&&(S(!0),window.setTimeout(()=>S(!1),tne))},H=async(Z,W)=>{const{commit:X,alias:Y}=rQ(p,W);if(X){const J=await I({action:"alias",account:Z,alias:Y},`alias-${Z}`);if(await n(!0),!(J!=null&&J.ok))return}P(Z)},q=async(Z,W)=>{var J,ee,ne;const X=await I({action:"move",account:Z,slot:W},`move-${Z}`),Y=tQ({menuFor:((J=d.current)==null?void 0:J.num)??null,shareFor:(v==null?void 0:v.num)??null},Z,X);if(await n(!0),Y){if(Y.menuFor!=null){const ce=document.getElementById(`ap-menu-${Z}`),de=document.getElementById(`ap-more-${Y.menuFor}`);de&&(ce!=null&&ce.contains(document.activeElement)||Vn(((ee=document.activeElement)==null?void 0:ee.tagName)??null))&&de.focus()}((ne=d.current)==null?void 0:ne.num)===Z&&O(),k(Y.confirmRemove),Y.shareFor==null&&(b(null),S(!1)),C(Y.swapNote);const se=Y.swapNote;se&&window.setTimeout(()=>C(ce=>ce===se?null:ce),ene),T(null),s(Y.menuFor)}return X};return{menu:o,menuFor:c,menuError:h,aliasDraft:p,confirmRemove:w,share:v,shareCopied:N,slotDraft:$,swapNote:E,showMenu:U,dropMenu:O,closeMenu:P,sayInMenu:L,startRename:F,typeAlias:A,doAlias:H,startMove:B,pickSlot:D,doSlot:async(Z,W,X)=>{if(!X.sends){P(Z);return}await q(Z,W)},makeShare:K,copyShare:G,pressRemove:Z=>{const W=Date.now(),X=Xi({armedFor:w,target:Z,armedAt:j.current,now:W,gapMs:Yi});if(X==="arm"){k(Z),j.current=W;return}X!=="ignore"&&(k(null),I({action:"remove",account:Z},`rm-${Z}`).then(Y=>{var J;n(!0),Y!=null&&Y.ok&&(((J=d.current)==null?void 0:J.num)===Z&&O(),s(null))}))}}}function sne(e,t){return!e||!t||t.some(n=>n.num===e.num&&n.active)?e:null}function ane({data:e,claim:t,release:n,load:r,sayFailure:s,clearFailure:o,sayInMenu:i,rescueFocus:c}){const[d,h]=y.useState(null),f=y.useCallback(async(g,w,k="panel")=>{if(!t(w))return null;const j=k==="menu"?i:s;j(null);try{const v=await fetch("/api/cswap-auto",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(g)}),b=await v.json().catch(()=>null);return b!=null&&b.ok||j({text:D0(b,"command failed",v.status),raw:Bc(b)}),b}catch{return j({text:"server unreachable"}),null}finally{n()}},[t,n,i,s]);return y.useEffect(()=>{!(e!=null&&e.ok)||!e.accounts||h(g=>sne(g,e.accounts))},[e]),{switched:d,post:f,doSwitch:async(g,w)=>{if(t(`switch-${g}`)){o(),h(null);try{const j=await(await fetch("/api/claude-accounts/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({account:g})})).json().catch(()=>null);j!=null&&j.ok?h({num:g,name:w}):s({text:D0(j,"the switch failed"),raw:Bc(j),row:g}),await r(!0)}catch{s({text:"server unreachable",row:g})}finally{n(),c(g)}}}}}const one=1800;function ine({auto:e,post:t,load:n}){var $;const[r,s]=y.useReducer(nJ,P0),[o,i]=y.useState(!1),c=y.useRef(null),d=y.useRef(null),h=y.useRef(null),f=y.useRef(!1),p=(($=e==null?void 0:e.settings["autoswitch.threshold"])==null?void 0:$.value)??"90",g=r.pick??p,w=oQ(g,p),k=r.custom!=null,j=r.refusal,v=y.useRef(k);return y.useEffect(()=>{var T,I,O;v.current!==k&&(v.current=k,k?((T=h.current)==null||T.focus(),(I=h.current)==null||I.select()):f.current&&((O=c.current)==null||O.focus()),f.current=!1)},[k]),{threshold:p,thresholdPick:g,thresholdCtl:w,thresholdSaved:o,thresholdRef:c,thresholdSaveRef:d,thresholdCustom:k,thresholdRefusal:j,thresholdFieldRef:h,proposeThreshold:T=>s({kind:"pick",pick:T}),typeThreshold:T=>s({kind:"type",text:T}),cancelThreshold:T=>{T.key!=="Escape"||T.nativeEvent.isComposing||!r.custom||(T.preventDefault(),T.stopPropagation(),f.current=!0,s({kind:"cancel"}))},leaveThreshold:()=>s({kind:"leave",stored:p}),doThreshold:async(T,I)=>{const O=await rJ(T,I,t);if(O.kind==="refused"){s({kind:"refuse",message:O.message});return}O.kind==="sent"&&(await n(!0),!O.ok)||(f.current=document.activeElement===h.current,s({kind:"settle"}),i(!0),window.setTimeout(()=>{var U;document.activeElement===d.current&&((U=c.current)==null||U.focus()),i(!1)},one))}}}const lne=Object.freeze({text:"couldn't reach the deck server",reload:!0}),cne=Object.freeze({text:"still waiting on the deck server — claude-swap can be slow to answer",reload:!0});async function SC(e){return e.ok?{ok:!0,status:e.status,body:null}:{ok:!1,status:e.status,body:await e.json().catch(()=>null)}}function une(e){const t=e.find(r=>!r.ok);if(!t)return null;const n=Bc(t.body);return{text:D0(t.body,`the deck server answered ${t.status}`),...n?{raw:n}:{},reload:!0}}function mg(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 gg=e=>e!=null&&typeof e=="object"&&!Array.isArray(e),yg=e=>e==null||typeof e=="string",wg=e=>e==null||typeof e=="number"&&Number.isFinite(e)&&e>=0&&Number.isFinite(new Date(e).getTime());function dne(e){if(!gg(e)||typeof e.ok!="boolean")return!1;if(!e.ok)return yg(e.reason)&&yg(e.hint);if(!Array.isArray(e.accounts))return!1;const t=new Set;return e.accounts.every(n=>{if(!gg(n)||typeof n.num!="number"||!Number.isInteger(n.num)||n.num<1||t.has(n.num)||(t.add(n.num),![n.email,n.alias,n.org,n.orgUuid,n.error].every(yg)||![n.active,n.disabled,n.stale].every(s=>typeof s=="boolean")||!wg(n.fetchedAt)||!wg(n.nextAt)||!Array.isArray(n.lanes)))return!1;const r=new Set;return n.lanes.every(s=>!gg(s)||typeof s.id!="string"||!s.id||r.has(s.id)||typeof s.label!="string"||typeof s.pct!="number"||!Number.isFinite(s.pct)||s.pct<0||s.pct>100||!wg(s.resetAt==null?null:typeof s.resetAt=="number"?s.resetAt*1e3:NaN)?!1:(r.add(s.id),!0))})}const NP=15e3,hne=3e4;function fne(e){const[t,n]=y.useState(null),[r,s]=y.useState(null),[o,i]=y.useState(!1),[c,d]=y.useState(null),h=y.useRef(null),f=y.useRef(0),p=y.useRef(!1),g=y.useRef(new Set),w=y.useCallback(async(v=!1)=>{if(!p.current||!v&&g.current.size>0)return;const b=++f.current;v&&i(!0);const N=new AbortController;g.current.add(N);const S=window.setTimeout(()=>N.abort(),hne);try{const[E,C]=await Promise.all([fetch(`/api/claude-accounts${v?"?refresh=1":""}`,{signal:N.signal}),fetch("/api/cswap-auto",{signal:N.signal})]),[$,T]=await Promise.all([E.ok?E.json():null,C.ok?C.json():null]),I=une([await SC(E),await SC(C)]);if(!p.current||b!==f.current)return;if($&&!dne($)){d(O=>mg(O,{text:"the deck server returned unreadable account data",reload:!0}));return}$&&(n($),e($)),T&&s(T),d(O=>mg(O,I))}catch{p.current&&b===f.current&&d(E=>mg(E,N.signal.aborted?cne:lne))}finally{window.clearTimeout(S),g.current.delete(N),p.current&&b===f.current&&i(!1)}},[e]);y.useEffect(()=>(p.current=!0,w(!0),h.current=window.setInterval(()=>w(!1),NP),()=>{p.current=!1,f.current++,h.current!=null&&window.clearInterval(h.current);for(const v of g.current)v.abort()}),[w]);const k=y.useCallback(v=>d(v),[]),j=y.useCallback(()=>d(null),[]);return{data:t,auto:r,reloading:o,failure:c,load:w,sayFailure:k,clearFailure:j}}const pne="#ap-rest-entry";function mne(e){return[`#${e}`,pne,...f3(null)]}function gne(e){const t=y.useRef(null),n=s=>{t.current=s.target.id||null},r=s=>{s.target.isConnected&&(t.current=null)};return y.useLayoutEffect(()=>{var o;const s=t.current;if(!(!s||!Vn(((o=document.activeElement)==null?void 0:o.tagName)??null)))for(const i of mne(s)){const c=document.querySelector(i);if(c){c.focus();return}}},[e]),{onFocus:n,onBlur:r}}function yne({onClose:e,leaving:t,onReport:n,onRoster:r}){var cs,dr,qs;Jt("accounts-panel");const s=Cn(),{busy:o,claim:i,release:c,pressProps:d}=Qte(),[h,f]=y.useState("accounts"),[p,g]=y.useState(!1),[w,k]=y.useState(null),j=y.useRef(w);j.current=w;const[v,b]=y.useState(!1),[N,S]=y.useState(!1),[E,C]=y.useState([]),[$,T]=y.useState(!1),[I,O]=y.useState(null),[U,P]=y.useState(Zte),[L,F]=y.useState(Yte),[A,B]=y.useState(null),[D,K]=y.useState(!1),G=y.useRef(r);G.current=r;const H=y.useCallback(me=>{var Xe;P(Ze=>hZ(Ze,me.accounts)),(Xe=G.current)==null||Xe.call(G,me)},[]),{data:q,auto:M,reloading:V,failure:Z,load:W,sayFailure:X,clearFailure:Y}=fne(H),J=gne(q),ee=y.useCallback(me=>{window.requestAnimationFrame(()=>{var Xe;if(Vn(((Xe=document.activeElement)==null?void 0:Xe.tagName)??null))for(const Ze of f3(me)){const Mn=document.querySelector(Ze);if(Mn){Mn.focus();return}}})},[]),ne=rne({claim:i,release:c,load:W,clearFailure:Y,rescueFocus:ee}),{menu:se,menuFor:ce,swapNote:de,showMenu:ae,dropMenu:pe,closeMenu:fe,sayInMenu:Ee}=ne,{switched:ye,post:oe,doSwitch:we}=ane({data:q,claim:i,release:c,load:W,sayFailure:X,clearFailure:Y,sayInMenu:Ee,rescueFocus:ee}),{threshold:Ne,thresholdPick:ge,thresholdCtl:Ae,thresholdSaved:Oe,thresholdRef:qe,thresholdSaveRef:Me,thresholdCustom:He,thresholdRefusal:rt,thresholdFieldRef:Ue,proposeThreshold:it,typeThreshold:Et,cancelThreshold:st,leaveThreshold:ht,doThreshold:ft}=ine({auto:M,post:oe,load:W}),Be=x3();y.useEffect(()=>{Jte(U)},[U]),y.useEffect(()=>{Xte(L)},[L]);const[Kt,at]=y.useState(()=>new Set),At=y.useCallback(me=>at(new Set(me)),[]),et=me=>({noCopyWorksNearby:Kt.has(sC([me])[0].key)}),pt=(cs=q==null?void 0:q.accounts)==null?void 0:cs.find(me=>me.active),jt=pt?Co(pt,Be,et(pt)):null,wt=(q==null?void 0:q.accounts)??[],tt=pt?wt.filter(me=>!me.active):[],Ct=T3(tt),Tn=lZ(L,tt),Mt=L0(iZ(tt,Tn,me=>bP(me,Be),Be),A),an=y.useRef(!1),fn=y.useRef(!1),pn=y.useRef(!1),Rn=y.useCallback(()=>{!an.current&&!fn.current&&!pn.current&&B(null)},[]),Yt=()=>B(me=>me??Mt.map(_r)),An={onPointerEnter:()=>{an.current=!0,Yt()},onPointerLeave:()=>{an.current=!1,Rn()},onFocus:me=>{me.target.matches(":focus-visible")&&(fn.current=!0,Yt())},onBlur:me=>{me.currentTarget.contains(me.relatedTarget)||(fn.current=!1,Rn())}},je=ce!=null&&tt.some(me=>me.num===ce)||w!=null&&tt.some(me=>me.num===w.num);y.useEffect(()=>{pn.current=je,je||Rn()},[je,Rn]);const $e=D&&tt.length>0;y.useEffect(()=>{$e||(an.current=fn.current=pn.current=!1,B(null))},[$e]);const De=y.useRef(!1);y.useEffect(()=>{De.current&&tt.length===0&&ee(null),De.current=tt.length>0},[tt.length,ee]);const lt=Mt.length?wt.filter(me=>me.active):wt,Wt=Vte(Mt,Be,et),is=Gte(pt,Ne,Be),Ma=Kte(M),ls=me=>D&&Mt.some(Xe=>Xe.num===me)?"ap-rest-list":"ap-scroll",Ds=(me,Xe="first")=>{ae(me,Xe),k(null)},mn=(me,Xe)=>{pe(),k(Ze=>(Ze==null?void 0:Ze.anchor)===Xe?null:{num:me,anchor:Xe})},It=y.useCallback((me=!1)=>{var Ze;const Xe=j.current;me&&Xe&&((Ze=document.getElementById(Xe.anchor))==null||Ze.focus()),k(null)},[]),Fs=()=>{pe(),k(null),f("lan")},$r=y.useRef(h);y.useEffect(()=>{$r.current!==h&&($r.current=h,window.requestAnimationFrame(()=>{var me;(me=document.getElementById(h==="lan"?"ap-lan-back":"ap-lan-entry"))==null||me.focus()}))},[h]),y.useEffect(()=>{q!=null&&q.ok&&g(!0)},[q==null?void 0:q.ok]),y.useEffect(()=>{t&&(pe(),k(null))},[t,pe]),y.useEffect(()=>{se&&(q!=null&&q.accounts)&&!q.accounts.some(me=>me.num===se.num)&&pe(),w&&(q!=null&&q.accounts)&&!q.accounts.some(me=>me.num===w.num)&&k(null)},[q,se,w,pe]),y.useEffect(()=>{I==null||!(q!=null&&q.accounts)||q.accounts.some(me=>me.num===I.num)||(O(null),ee(null))},[q,I,ee]);const Lr=a.jsx("button",{type:"button",className:"glyph-btn",onClick:e,"aria-label":"Close accounts panel",title:dn("Close","A",s),children:a.jsx("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":!0,children:a.jsx("path",{d:"M3.4 3.4l7.2 7.2M10.6 3.4l-7.2 7.2"})})}),ur=me=>{const Xe=R3(U,me),Ze=ce===me.num,Mn=(Z==null?void 0:Z.row)===me.num?Z:null,Or=(ye==null?void 0:ye.num)===me.num,$n=(de==null?void 0:de.at)===me.num?de:null,Us=$n?wt.find(Nt=>Nt.num===$n.displaced):void 0,hr=(w==null?void 0:w.anchor)===`ap-issue-${me.num}`;return a.jsx(jZ,{a:me,nowSec:Be,lan:et(me),opened:Xe,onToggleLanes:()=>P(Nt=>uZ(Nt,me)),busy:o,pressProps:d,onSwitch:we,menuOpen:Ze,onOpenMenu:Ds,onCloseMenu:fe,refusal:Mn,onDismissRefusal:()=>Y(),switchedHere:Or,swapped:$n,displaced:Us,issueExpanded:hr,onOpenIssue:mn,sortKey:me.active?null:oZ(Tn)},me.num)},Bs=q!=null&&q.ok&&(M!=null&&M.ok)?a.jsx(sJ,{auto:M,threshold:Ne,thresholdPick:ge,thresholdCtl:Ae,thresholdSaved:Oe,thresholdRef:qe,thresholdSaveRef:Me,thresholdCustom:He,thresholdRefusal:rt,thresholdFieldRef:Ue,proposeThreshold:it,typeThreshold:Et,cancelThreshold:st,leaveThreshold:ht,doThreshold:ft,pressProps:d,post:oe,load:W}):null;return a.jsxs("aside",{className:`accounts-panel${t?" leaving":""}`,id:"accounts-panel","aria-label":"Claude accounts",onFocus:J.onFocus,onBlur:J.onBlur,children:[h==="accounts"&&a.jsx(SZ,{canShare:(((dr=q==null?void 0:q.accounts)==null?void 0:dr.length)??0)>0,canReport:(((qs=q==null?void 0:q.accounts)==null?void 0:qs.length)??0)>1||N,onAdd:()=>b(!0),onReport:()=>{C([...lt,...Mt].map(_r)),S(!0)},onShareSet:()=>T(!0),onReload:()=>W(!0),pressProps:d,reloading:V,closeButton:Lr}),h==="accounts"&&a.jsxs("div",{className:"ap-scroll",id:"ap-scroll",children:[q==null?Z?a.jsxs("div",{className:"ap-empty",role:"alert",children:[a.jsx("span",{title:Z.raw||void 0,children:Z.text}),a.jsxs("span",{className:"ap-hint",children:["No accounts have arrived, so there is nothing to show yet. The panel keeps trying every ",NP/1e3," seconds."]}),a.jsx("button",{type:"button",className:"ap-fix",...d("reload",V),onClick:()=>W(!0).then(()=>ee(null)),children:V?"trying…":"try again"})]}):a.jsx("div",{className:"ap-empty",children:"Checking…"}):q.ok?a.jsxs(a.Fragment,{children:[pt&&(jt==null?void 0:jt.tone)==="warn"&&a.jsxs("div",{className:"ap-notice",children:[a.jsxs("button",{type:"button",id:"ap-notice",className:"ap-issue","data-tone":"warn","aria-haspopup":"dialog","aria-expanded":(w==null?void 0:w.anchor)==="ap-notice","aria-controls":(w==null?void 0:w.anchor)==="ap-notice"?"ap-issue-pop":void 0,onClick:()=>mn(pt.num,"ap-notice"),children:[a.jsx(i1,{}),a.jsx("span",{className:"ap-issue-text",children:"Current account needs attention"})]}),jt.fix&&a.jsx("button",{type:"button",className:"ap-notice-fix",onClick:()=>b(!0),title:"Open the sign-in dialog. Signing in as this account replaces its stored login in place.",children:"Sign in"})]}),a.jsx("ul",{className:"ap-list",children:lt.map(ur)}),Mt.length>0&&a.jsx(qte,{peers:Wt,strained:is,armed:Ma,threshold:M!=null&&M.ok?Ne:null,open:D,onToggle:()=>K(me=>!me),order:Tn,choices:Ct,onOrder:F,allOpen:A3(U,Mt),onToggleAll:()=>P(me=>dZ(me,Mt)),held:A!=null}),Mt.length>0&&D&&a.jsxs("div",{className:"ap-rest-panel",id:"ap-rest-panel",children:[a.jsx("ul",{className:"ap-list ap-others",id:"ap-rest-list",...An,children:Mt.map(ur)}),Bs]}),Mt.length===0&&Bs,Z&&Z.row==null&&a.jsxs("div",{className:"ap-failure",role:"alert",children:[a.jsx("span",{className:"ap-failure-text",title:Z.raw||void 0,children:Z.text}),a.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>Y(),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),se&&(()=>{var Xe;const me=(Xe=q.accounts)==null?void 0:Xe.find(Ze=>Ze.num===se.num);return me?a.jsx(iQ,{a:me,accountMenu:ne,slots:(q.accounts??[]).map(Ze=>Ze.num),boundaryId:ls(me.num),nowSec:Be,busy:o,pressProps:d,rotating:!!(M!=null&&M.enabled||M!=null&&M.external),onProjects:()=>{O({num:me.num,name:me.alias??me.email??`account ${me.num}`}),fe(me.num)},onRotation:()=>oe({action:"account",account:me.num,enabled:me.disabled},`rot-${me.num}`,"menu").then(Ze=>{W(!0),Ze!=null&&Ze.ok&&fe(me.num)})}):null})(),w&&(()=>{var Ze;const me=(Ze=q.accounts)==null?void 0:Ze.find(Mn=>Mn.num===w.num),Xe=me?Co(me,Be,et(me)):null;return!me||!Xe?null:a.jsx(ZX,{anchorId:w.anchor,boundaryId:w.anchor==="ap-notice"?"ap-scroll":ls(me.num),issue:Xe,who:me.alias??me.email??`account ${me.num}`,fetchedAt:me.fetchedAt,nowSec:Be,onClose:It,onSignIn:()=>b(!0),onReport:n&&(()=>n({initialKind:Xe.tone==="warn"?"bug":"other",initialBody:`Account issue: ${Xe.text}. ${Xe.hint}`}))})})()]}):a.jsx(NZ,{data:q}),a.jsx("div",{className:"film-foot",children:a.jsx(Ic,{film:"claudeAccounts"})})]}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:ye?`Now active: ${ye.name}`:""}),p&&a.jsx(Fte,{accounts:sC((q==null?void 0:q.accounts)??[]),onChanged:()=>W(!0),onNoCopy:At,view:h==="lan",onOpen:Fs,onBack:()=>f("accounts"),closeButton:Lr}),v&&a.jsx(X3,{onClose:()=>b(!1),onChanged:()=>W(!0)}),$&&a.jsx(zte,{accounts:((q==null?void 0:q.accounts)??[]).map(me=>({num:me.num,email:me.email,alias:me.alias,org:me.org})),onClose:()=>T(!1),copyText:Mo}),I!=null&&(()=>{var Xe;const me=(Xe=q==null?void 0:q.accounts)==null?void 0:Xe.find(Ze=>Ze.num===I.num);return q!=null&&q.accounts&&!me?null:a.jsx(YX,{num:I.num,name:me?me.alias??me.email??`account ${me.num}`:I.name,onClose:()=>O(null)})})(),N&&a.jsx(JZ,{accounts:(q==null?void 0:q.accounts)??null,order:E,failed:Z!=null&&Z.reload?Z.text:null,nowSec:Be,onClose:()=>S(!1)})]})}function wne({width:e,children:t}){const n=y.useRef(null);return y.useLayoutEffect(()=>{var r;for(const s of Array.from(((r=n.current)==null?void 0:r.children)??[]))s.inert=s.classList.contains("leaving")}),a.jsx("div",{ref:n,className:`left-column${e===0?" closing":""}`,style:{"--left-col-w":e===0?"0px":`calc(${e}px + var(--ui-panel-increase, 0px))`},children:t})}const xne=16,vne=120;function bne(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 kne(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 jne(e,t){return bne(e,t,xne)?"over":kne(e,t)<=vne?"near":"far"}function Nne(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 Sne(){const[e,t]=y.useState(!1),[n,r]=y.useState(""),[s,o]=y.useState("far"),i=y.useRef(null),c=Ei(e,140),d=y.useCallback(g=>{var j;const w=(j=i.current)==null?void 0:j.getBoundingClientRect(),k=Nne(g);return w&&k?jne(k,w):"far"},[]),h=y.useCallback(g=>{g!==null&&(r(g),t(!0)),o("far")},[]),f=y.useCallback(g=>{o(d(g))},[d]),p=y.useCallback((g,w)=>{const k=w&&d(g)==="over";return t(!1),k},[d]);return{trashDragging:e,trashLabel:n,trashState:s,trashZoneRef:i,trashPhase:c,beginTrashDrag:h,trackTrashDrag:f,endTrashDrag:p}}const _ne=420;function Ene(){const[e,t]=y.useState(!1),n=y.useRef(null),r=y.useCallback(()=>{n.current&&(window.clearTimeout(n.current),n.current=null),t(!1)},[]),s=y.useCallback(o=>{o.length!==0&&queueMicrotask(()=>{t(!0),n.current&&window.clearTimeout(n.current),n.current=window.setTimeout(()=>t(!1),_ne+80)})},[]);return y.useEffect(()=>()=>{n.current&&window.clearTimeout(n.current)},[]),{bubbling:e,endBubble:r,onBubble:s}}const b1=11;function SP(e=0){return b1+Math.min(0,e)}const _P=7.2,EP=6.6,Cne={width:104,height:48},_C={width:96,height:44},CP={width:220,height:103};function Tne(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)?CP:{width:Math.max(160,t),height:Math.max(72,n)}}function xg(e,t,n){return e.width*t>=n.width&&e.height*t>=n.height}function Rne(e,t,n=CP,r=b1){if(!Number.isFinite(t)||t<=0)return e??"detail";const s=r*t;return e==="detail"?s>=EP?"detail":xg(n,t,_C)?"compact":"overview":s>=_P?"detail":e==="compact"?xg(n,t,_C)?"compact":"overview":xg(n,t,Cne)?"compact":"overview"}function Ane(e,t,n=b1){return e>=_P/n?e:Math.max(e,Math.min(t,EP/n-.001))}const Mne=.8,$ne=1;function Lne({stateRef:e,measuredRef:t,measuredVersionRef:n,canvasRef:r}){const[s,o]=y.useState("detail"),i=y.useRef(null),c=y.useRef(null),d=y.useCallback(()=>{var w;const f=n.current;if(((w=c.current)==null?void 0:w.version)===f)return c.current.card;const p=[];for(const k of e.current.agents.keys()){const j=t.current.get(k);j&&p.push(j)}const g=Tne(p);return c.current={version:f,card:g},g},[]),h=y.useCallback(f=>{var g;const p=Rne(i.current,f,d(),SP(Zk[Jk()]));return p===i.current?null:(i.current=p,(g=r.current)==null||g.setAttribute("data-lod",p),o(p),p)},[d,r]);return{lod:s,lodRef:i,applyZoom:h}}const One=40,Ine=120;function Pne(e,t){let n=null,r=0,s=Number.NEGATIVE_INFINITY;const o=()=>{n=null,s=t.now(),e()},i=()=>{n!=null&&(t.clearTimeout(n),n=null)},c=(d,h,f)=>{if(n!=null){if(r<=d)return;i()}const p=Math.min(f,Math.max(0,d-h));r=d,n=t.setTimeout(o,p)};return{live(d=One){const h=t.now(),f=Math.max(s+d,h);if(f<=h){i(),o();return}c(f,h,d)},replay(d=Ine){i(),r=t.now()+d,n=t.setTimeout(o,d)},flush(){i(),o()},cancel(){i()}}}const Dne=1024*1024,EC=5,TP=.8,Y0=24,Fne="agent-dag.soundCustom.done",Bne="agent-dag.soundCustom.needs-input",xc={done:Fne,"needs-input":Bne};function Uc(e){if(e.kind!=="audio")return e;const{bytes:t,...n}=e;return n}function CC(e){return!e||!/^[a-zA-Z0-9._-]{1,96}$/.test(e)?null:e}function qne(e){return{done:CC(e(xc.done)),"needs-input":CC(e(xc["needs-input"]))}}function Une(e,t){return{done:e.done===t?null:e.done,"needs-input":e["needs-input"]===t?null:e["needs-input"]}}function Hne(e){return e.done&&e.done===e["needs-input"]?e.done:null}const Wne={wav:"audio/wav",wave:"audio/wav",mp3:"audio/mpeg",ogg:"audio/ogg",oga:"audio/ogg",webm:"audio/webm",m4a:"audio/mp4",mp4:"audio/mp4"},RP=new Set(["audio/wav","audio/x-wav","audio/mpeg","audio/mp3","audio/ogg","audio/webm","audio/mp4"]);function AP(e,t){const n=t.toLowerCase().split(";")[0].trim();if(RP.has(n))return n;const r=e.toLowerCase().split(".").pop()??"";return Wne[r]??n}function TC(e,t){const n=AP(e.name,e.type);if(!RP.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>Dne)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>EC)return`Audio must be ${EC} seconds or shorter.`}return null}function X0(e){return e>=Y0?`There are already ${Y0} custom sounds. Delete one first.`:null}function zne(e,t){const n=e.indexOf(t);return n<0?null:e[n+1]??e[n-1]??null}function Vne(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,TP/t)}function MP(){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 Gne(e,t,n=MP()){var h;const r=((h=e.name)==null?void 0:h.trim())||"Custom sound",s=TC({name:r,type:e.type,size:e.size});if(s)throw new Error(s);const o=await e.arrayBuffer();let i;try{i=await t(o.slice(0))}catch{throw new Error("The audio file could not be decoded.")}const c=TC({name:r,type:e.type,size:e.size},i.duration);if(c)throw new Error(c);const d=Array.from({length:i.numberOfChannels},(f,p)=>i.getChannelData(p));return{id:n,name:r.replace(/\.(wav|wave|mp3|ogg|oga|webm|m4a|mp4)$/i,"")||"Custom sound",kind:"audio",mime:AP(r,e.type),duration:i.duration,normalizationGain:Vne(d),bytes:o}}function Kne(e,t=MP()){const n=e.name.trim()||"Custom voice",r=e.text.trim();if(!r)throw new Error("Enter the words this voice should say.");const s=Number.isFinite(e.rate)?e.rate:1,o=Number.isFinite(e.pitch)?e.pitch:1;return{id:t,name:n,kind:"tts",text:r.slice(0,180),voiceURI:e.voiceURI??"",rate:Math.min(2,Math.max(.5,s)),pitch:Math.min(2,Math.max(.5,o))}}const Yne="ccdeck-notification-audio",Xne=2,Tr="assets",ss="summaries";function eu(){return typeof window<"u"?window.ccdeckNotificationAudio??null:null}function Zne(){return new Promise((e,t)=>{const n=indexedDB.open(Yne,Xne);n.onupgradeneeded=r=>{const s=n.result,o=s.objectStoreNames.contains(Tr)?n.transaction.objectStore(Tr):s.createObjectStore(Tr,{keyPath:"id"});if(s.objectStoreNames.contains(ss))return;const i=s.createObjectStore(ss,{keyPath:"id"});if(r.oldVersion<1)return;const c=o.openCursor();c.onsuccess=()=>{const d=c.result;d&&(i.put(Uc(d.value)),d.continue())}},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error??new Error("Could not open local audio storage."))})}async function tu(e,t,n){const r=await Zne();try{return await new Promise((s,o)=>{const i=r.transaction(e,t),c=n(i),d=()=>o(i.error??new Error("Local audio storage failed."));i.oncomplete=()=>s(c?c.result:void 0),i.onerror=d,i.onabort=d})}finally{r.close()}}async function Jne(){const e=eu();return e?e.list():typeof indexedDB>"u"?[]:await tu([ss],"readonly",t=>t.objectStore(ss).getAll())??[]}async function Qne(e){const t=eu();return t?t.get(e):typeof indexedDB>"u"?null:await tu([Tr],"readonly",n=>n.objectStore(Tr).get(e))??null}async function RC(e){const t=eu();if(t){await t.put(e);return}if(typeof indexedDB>"u")throw new Error("Local audio storage is unavailable in this browser.");await tu([Tr,ss],"readwrite",n=>{n.objectStore(Tr).put(e),n.objectStore(ss).put(Uc(e))})}async function ere(e,t){const n=eu();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 tu([Tr,ss],"readwrite",r=>{const s=r.objectStore(Tr),o=s.get(e);o.onsuccess=()=>{const i=o.result;if(!i)return;const c={...i,name:t};s.put(c),r.objectStore(ss).put(Uc(c))}})}async function tre(e){const t=eu();if(t){await t.remove(e);return}typeof indexedDB>"u"||await tu([Tr,ss],"readwrite",n=>{n.objectStore(Tr).delete(e),n.objectStore(ss).delete(e)})}const rh=["done","needs-input"],nre=[{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}]}],rre=[{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}]}],k1={done:nre,"needs-input":rre},Un="two";function Z0(e,t){const n=k1[e];return n.find(r=>r.id===t)??n.find(r=>r.id===Un)??n[0]}function $P(e,t){return k1[e].some(r=>r.id===t)?t:Un}Z0("done",Un).notes,Z0("needs-input",Un).notes;const AC=.04,LP=.24,sh=0,Dh=100,j1=5,To=50;function Mf(e,t=j1){if(!Number.isFinite(e))return To;const n=Math.round(e/t)*t;return Math.min(Dh,Math.max(sh,n))}function OP(e,t=j1){if(e==null)return To;const n=e.trim();return/^-?\d+(\.\d+)?$/.test(n)?Mf(Number(n),t):To}function N1(e){const t=Mf(e),n=AC+(LP-AC)*(t/Dh);return Math.round(n*1e4)/1e4}function sre(e,t){const n=t.trim,r=typeof n=="number"&&Number.isFinite(n)&&n>0&&n<=1?n:1;return Math.round(N1(e)*r*1e4)/1e4}const are=.012,MC=1e-4;function ore(e){return Math.min(1,N1(e)/LP)}function ire(e,t){const n=e*(N1(t)/TP);return Math.max(1e-4,n)}const lre=160,cre="agent-dag.soundLevel.done",ure="agent-dag.soundLevel.needs-input",dre="agent-dag.soundFigure.done",hre="agent-dag.soundFigure.needs-input",IP={done:cre,"needs-input":ure},Fh={done:dre,"needs-input":hre},$C={done:{level:To,figure:Un},"needs-input":{level:To,figure:Un}};function fre(e){const t=n=>({level:OP(e(IP[n])),figure:$P(n,e(Fh[n]))});return{done:t("done"),"needs-input":t("needs-input")}}function pre(e,t){return(e??$C)[t]??$C[t]}const mre={Stop:"done",Notification:"needs-input"};function gre(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:qt(mre,n)??null}const yre=6,wre="ccdeck-tabs";function xre(e){return e>=yre}function vre(e,t,n){const r=s=>{const o=s.data;(o==null?void 0:o.kind)==="who"&&o.from!==t&&e.postMessage({kind:"here",from:t,to:o.from,streaming:n()})};return e.addEventListener("message",r),{ask(s,o=(i,c)=>setTimeout(i,c)){return new Promise(i=>{const c=new Set,d=h=>{const f=h.data;(f==null?void 0:f.kind)==="here"&&f.to===t&&f.streaming&&c.add(f.from)};e.addEventListener("message",d),e.postMessage({kind:"who",from:t}),o(()=>{e.removeEventListener("message",d),i(c.size)},s)})},leave(){var s;e.removeEventListener("message",r),(s=e.close)==null||s.call(e)}}}function bre({stateRef:e,rerender:t,pauseGate:n,chimesRef:r,desktopUpdateRef:s}){const[o,i]=y.useState(!1),[c,d]=y.useState(!1),[h,f]=y.useState(!1),p=y.useRef(!0),[g,w]=y.useState(null);return y.useEffect(()=>{const k=new EventSource("/events"),j=Pne(t,{now:()=>Date.now(),setTimeout:(S,E)=>window.setTimeout(S,E),clearTimeout:S=>window.clearTimeout(S)});let v=!1;const b=typeof BroadcastChannel=="function"?vre(new BroadcastChannel(wre),Math.random().toString(36).slice(2),()=>v):null,N=window.setInterval(()=>{v||!b||b.ask(600).then(S=>{v||d(xre(S))})},3e3);return k.addEventListener("open",()=>{i(!0),f(!0)}),k.addEventListener("error",()=>{i(!1),w(null)}),k.addEventListener("open",()=>{v=!0,d(!1)}),k.addEventListener("error",()=>{v=!1}),k.addEventListener("replay-end",()=>{p.current=!1,j.flush(),w(Date.now())}),k.addEventListener("desktop-update",S=>s.current(S.data)),k.addEventListener("hook",S=>{var E;try{const C=JSON.parse(S.data);if(!n.accept(C))return;e.current=eI(e.current,C);const $=C.replay===!0||p.current||Date.now()-C.receivedAt>3e4;$?j.replay():j.live();const T=gre(C,$);T&&((E=r.current)==null||E.play(T))}catch{}}),()=>{k.close(),j.cancel(),window.clearInterval(N),b==null||b.leave()}},[t]),{live:o,tabCapped:c,everConnected:h,liveSince:g}}const kre=200,jre=5*6e4,Nre=6,Sre=2*6e4;function qd(e,t){if(t.size!==0)for(const n of Array.from(e.keys()))t.has(n)||e.delete(n)}function _re(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 Ere(e){const t=new Set;for(const n of e)t.add(n.id),t.add(`group:${n.sessionId}`),n.kind==="root"&&t.add(Bk(n.id));return t}function Cre(e){const t=new Set;for(const n of e)t.add(n.id),n.kind==="root"&&t.add(Bk(n.id));return t}function Tre(e,t){let n=OW(e,t,y_);IW(e,t,y_)&&(n=!0);const r=[],s=o=>{r.push(o)};return MW(e,t,kre,jre,s)&&(n=!0),$W(e,t,Nre,Sre,s)&&(n=!0),{changed:n,forgotten:r}}function Rre(e,t,n){if(!n)return{ids:new Set([t]),primary:t};const r=new Set(e.ids);if(!r.has(t))return r.add(t),{ids:r,primary:t};if(r.delete(t),e.primary!==t)return{ids:r,primary:e.primary};let s=null;for(const o of r)s=o;return{ids:r,primary:s}}function Are(e,t){const[n,r]=y.useState(()=>({ids:new Set,primary:null})),{ids:s,primary:o}=n,i=y.useCallback((h,f,p=!f)=>{r(g=>Rre(g,h,f)),!f&&p&&t(!0)},[]),c=y.useCallback(()=>{r({ids:new Set,primary:null})},[]),d=y.useCallback(()=>{r(h=>{const f=_re(h.ids,e.current.agents),p=h.primary!=null&&!e.current.agents.has(h.primary)?null:h.primary;return f===h.ids&&p===h.primary?h:{ids:f,primary:p}})},[e]);return{selectedIds:s,primarySelectedId:o,selectAgent:i,clearSelection:c,pruneSelectionToBoard:d}}function Mre({stateRef:e,rerender:t,pruneSelectionToBoard:n,setContextFor:r,setSummaryFor:s}){const[o,i]=y.useState(Date.now());return y.useEffect(()=>{const c=setInterval(()=>{const d=Date.now();i(d);const{changed:h,forgotten:f}=Tre(e.current,d);f.length>0&&fetch("/api/forget",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({ids:f})}).catch(()=>{}),n(),r(p=>p!=null&&!e.current.agents.has(p)?null:p),s(p=>p!=null&&!e.current.agents.has(p)?null:p),h&&t()},250);return()=>clearInterval(c)},[t]),o}function S1(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 vg,LC;function $re(){if(LC)return vg;LC=1;function e(){this.__data__=[],this.size=0}return vg=e,vg}var bg,OC;function rl(){if(OC)return bg;OC=1;function e(t,n){return t===n||t!==t&&n!==n}return bg=e,bg}var kg,IC;function $f(){if(IC)return kg;IC=1;var e=rl();function t(n,r){for(var s=n.length;s--;)if(e(n[s][0],r))return s;return-1}return kg=t,kg}var jg,PC;function Lre(){if(PC)return jg;PC=1;var e=$f(),t=Array.prototype,n=t.splice;function r(s){var o=this.__data__,i=e(o,s);if(i<0)return!1;var c=o.length-1;return i==c?o.pop():n.call(o,i,1),--this.size,!0}return jg=r,jg}var Ng,DC;function Ore(){if(DC)return Ng;DC=1;var e=$f();function t(n){var r=this.__data__,s=e(r,n);return s<0?void 0:r[s][1]}return Ng=t,Ng}var Sg,FC;function Ire(){if(FC)return Sg;FC=1;var e=$f();function t(n){return e(this.__data__,n)>-1}return Sg=t,Sg}var _g,BC;function Pre(){if(BC)return _g;BC=1;var e=$f();function t(n,r){var s=this.__data__,o=e(s,n);return o<0?(++this.size,s.push([n,r])):s[o][1]=r,this}return _g=t,_g}var Eg,qC;function Lf(){if(qC)return Eg;qC=1;var e=$re(),t=Lre(),n=Ore(),r=Ire(),s=Pre();function o(i){var c=-1,d=i==null?0:i.length;for(this.clear();++c<d;){var h=i[c];this.set(h[0],h[1])}}return o.prototype.clear=e,o.prototype.delete=t,o.prototype.get=n,o.prototype.has=r,o.prototype.set=s,Eg=o,Eg}var Cg,UC;function Dre(){if(UC)return Cg;UC=1;var e=Lf();function t(){this.__data__=new e,this.size=0}return Cg=t,Cg}var Tg,HC;function Fre(){if(HC)return Tg;HC=1;function e(t){var n=this.__data__,r=n.delete(t);return this.size=n.size,r}return Tg=e,Tg}var Rg,WC;function Bre(){if(WC)return Rg;WC=1;function e(t){return this.__data__.get(t)}return Rg=e,Rg}var Ag,zC;function qre(){if(zC)return Ag;zC=1;function e(t){return this.__data__.has(t)}return Ag=e,Ag}var Mg,VC;function PP(){if(VC)return Mg;VC=1;var e=typeof md=="object"&&md&&md.Object===Object&&md;return Mg=e,Mg}var $g,GC;function Mr(){if(GC)return $g;GC=1;var e=PP(),t=typeof self=="object"&&self&&self.Object===Object&&self,n=e||t||Function("return this")();return $g=n,$g}var Lg,KC;function sl(){if(KC)return Lg;KC=1;var e=Mr(),t=e.Symbol;return Lg=t,Lg}var Og,YC;function Ure(){if(YC)return Og;YC=1;var e=sl(),t=Object.prototype,n=t.hasOwnProperty,r=t.toString,s=e?e.toStringTag:void 0;function o(i){var c=n.call(i,s),d=i[s];try{i[s]=void 0;var h=!0}catch{}var f=r.call(i);return h&&(c?i[s]=d:delete i[s]),f}return Og=o,Og}var Ig,XC;function Hre(){if(XC)return Ig;XC=1;var e=Object.prototype,t=e.toString;function n(r){return t.call(r)}return Ig=n,Ig}var Pg,ZC;function $o(){if(ZC)return Pg;ZC=1;var e=sl(),t=Ure(),n=Hre(),r="[object Null]",s="[object Undefined]",o=e?e.toStringTag:void 0;function i(c){return c==null?c===void 0?s:r:o&&o in Object(c)?t(c):n(c)}return Pg=i,Pg}var Dg,JC;function lr(){if(JC)return Dg;JC=1;function e(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}return Dg=e,Dg}var Fg,QC;function nu(){if(QC)return Fg;QC=1;var e=$o(),t=lr(),n="[object AsyncFunction]",r="[object Function]",s="[object GeneratorFunction]",o="[object Proxy]";function i(c){if(!t(c))return!1;var d=e(c);return d==r||d==s||d==n||d==o}return Fg=i,Fg}var Bg,eT;function Wre(){if(eT)return Bg;eT=1;var e=Mr(),t=e["__core-js_shared__"];return Bg=t,Bg}var qg,tT;function zre(){if(tT)return qg;tT=1;var e=Wre(),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 qg=n,qg}var Ug,nT;function DP(){if(nT)return Ug;nT=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 Ug=n,Ug}var Hg,rT;function Vre(){if(rT)return Hg;rT=1;var e=nu(),t=zre(),n=lr(),r=DP(),s=/[\\^$.*+?()[\]{}|]/g,o=/^\[object .+?Constructor\]$/,i=Function.prototype,c=Object.prototype,d=i.toString,h=c.hasOwnProperty,f=RegExp("^"+d.call(h).replace(s,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function p(g){if(!n(g)||t(g))return!1;var w=e(g)?f:o;return w.test(r(g))}return Hg=p,Hg}var Wg,sT;function Gre(){if(sT)return Wg;sT=1;function e(t,n){return t==null?void 0:t[n]}return Wg=e,Wg}var zg,aT;function Lo(){if(aT)return zg;aT=1;var e=Vre(),t=Gre();function n(r,s){var o=t(r,s);return e(o)?o:void 0}return zg=n,zg}var Vg,oT;function _1(){if(oT)return Vg;oT=1;var e=Lo(),t=Mr(),n=e(t,"Map");return Vg=n,Vg}var Gg,iT;function Of(){if(iT)return Gg;iT=1;var e=Lo(),t=e(Object,"create");return Gg=t,Gg}var Kg,lT;function Kre(){if(lT)return Kg;lT=1;var e=Of();function t(){this.__data__=e?e(null):{},this.size=0}return Kg=t,Kg}var Yg,cT;function Yre(){if(cT)return Yg;cT=1;function e(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n}return Yg=e,Yg}var Xg,uT;function Xre(){if(uT)return Xg;uT=1;var e=Of(),t="__lodash_hash_undefined__",n=Object.prototype,r=n.hasOwnProperty;function s(o){var i=this.__data__;if(e){var c=i[o];return c===t?void 0:c}return r.call(i,o)?i[o]:void 0}return Xg=s,Xg}var Zg,dT;function Zre(){if(dT)return Zg;dT=1;var e=Of(),t=Object.prototype,n=t.hasOwnProperty;function r(s){var o=this.__data__;return e?o[s]!==void 0:n.call(o,s)}return Zg=r,Zg}var Jg,hT;function Jre(){if(hT)return Jg;hT=1;var e=Of(),t="__lodash_hash_undefined__";function n(r,s){var o=this.__data__;return this.size+=this.has(r)?0:1,o[r]=e&&s===void 0?t:s,this}return Jg=n,Jg}var Qg,fT;function Qre(){if(fT)return Qg;fT=1;var e=Kre(),t=Yre(),n=Xre(),r=Zre(),s=Jre();function o(i){var c=-1,d=i==null?0:i.length;for(this.clear();++c<d;){var h=i[c];this.set(h[0],h[1])}}return o.prototype.clear=e,o.prototype.delete=t,o.prototype.get=n,o.prototype.has=r,o.prototype.set=s,Qg=o,Qg}var ey,pT;function ese(){if(pT)return ey;pT=1;var e=Qre(),t=Lf(),n=_1();function r(){this.size=0,this.__data__={hash:new e,map:new(n||t),string:new e}}return ey=r,ey}var ty,mT;function tse(){if(mT)return ty;mT=1;function e(t){var n=typeof t;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?t!=="__proto__":t===null}return ty=e,ty}var ny,gT;function If(){if(gT)return ny;gT=1;var e=tse();function t(n,r){var s=n.__data__;return e(r)?s[typeof r=="string"?"string":"hash"]:s.map}return ny=t,ny}var ry,yT;function nse(){if(yT)return ry;yT=1;var e=If();function t(n){var r=e(this,n).delete(n);return this.size-=r?1:0,r}return ry=t,ry}var sy,wT;function rse(){if(wT)return sy;wT=1;var e=If();function t(n){return e(this,n).get(n)}return sy=t,sy}var ay,xT;function sse(){if(xT)return ay;xT=1;var e=If();function t(n){return e(this,n).has(n)}return ay=t,ay}var oy,vT;function ase(){if(vT)return oy;vT=1;var e=If();function t(n,r){var s=e(this,n),o=s.size;return s.set(n,r),this.size+=s.size==o?0:1,this}return oy=t,oy}var iy,bT;function E1(){if(bT)return iy;bT=1;var e=ese(),t=nse(),n=rse(),r=sse(),s=ase();function o(i){var c=-1,d=i==null?0:i.length;for(this.clear();++c<d;){var h=i[c];this.set(h[0],h[1])}}return o.prototype.clear=e,o.prototype.delete=t,o.prototype.get=n,o.prototype.has=r,o.prototype.set=s,iy=o,iy}var ly,kT;function ose(){if(kT)return ly;kT=1;var e=Lf(),t=_1(),n=E1(),r=200;function s(o,i){var c=this.__data__;if(c instanceof e){var d=c.__data__;if(!t||d.length<r-1)return d.push([o,i]),this.size=++c.size,this;c=this.__data__=new n(d)}return c.set(o,i),this.size=c.size,this}return ly=s,ly}var cy,jT;function Pf(){if(jT)return cy;jT=1;var e=Lf(),t=Dre(),n=Fre(),r=Bre(),s=qre(),o=ose();function i(c){var d=this.__data__=new e(c);this.size=d.size}return i.prototype.clear=t,i.prototype.delete=n,i.prototype.get=r,i.prototype.has=s,i.prototype.set=o,cy=i,cy}var uy,NT;function C1(){if(NT)return uy;NT=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 uy=e,uy}var dy,ST;function FP(){if(ST)return dy;ST=1;var e=Lo(),t=(function(){try{var n=e(Object,"defineProperty");return n({},"",{}),n}catch{}})();return dy=t,dy}var hy,_T;function Df(){if(_T)return hy;_T=1;var e=FP();function t(n,r,s){r=="__proto__"&&e?e(n,r,{configurable:!0,enumerable:!0,value:s,writable:!0}):n[r]=s}return hy=t,hy}var fy,ET;function Ff(){if(ET)return fy;ET=1;var e=Df(),t=rl(),n=Object.prototype,r=n.hasOwnProperty;function s(o,i,c){var d=o[i];(!(r.call(o,i)&&t(d,c))||c===void 0&&!(i in o))&&e(o,i,c)}return fy=s,fy}var py,CT;function ru(){if(CT)return py;CT=1;var e=Ff(),t=Df();function n(r,s,o,i){var c=!o;o||(o={});for(var d=-1,h=s.length;++d<h;){var f=s[d],p=i?i(o[f],r[f],f,o,r):void 0;p===void 0&&(p=r[f]),c?t(o,f,p):e(o,f,p)}return o}return py=n,py}var my,TT;function ise(){if(TT)return my;TT=1;function e(t,n){for(var r=-1,s=Array(t);++r<t;)s[r]=n(r);return s}return my=e,my}var gy,RT;function os(){if(RT)return gy;RT=1;function e(t){return t!=null&&typeof t=="object"}return gy=e,gy}var yy,AT;function lse(){if(AT)return yy;AT=1;var e=$o(),t=os(),n="[object Arguments]";function r(s){return t(s)&&e(s)==n}return yy=r,yy}var wy,MT;function su(){if(MT)return wy;MT=1;var e=lse(),t=os(),n=Object.prototype,r=n.hasOwnProperty,s=n.propertyIsEnumerable,o=e((function(){return arguments})())?e:function(i){return t(i)&&r.call(i,"callee")&&!s.call(i,"callee")};return wy=o,wy}var xy,$T;function Ot(){if($T)return xy;$T=1;var e=Array.isArray;return xy=e,xy}var lc={exports:{}},vy,LT;function cse(){if(LT)return vy;LT=1;function e(){return!1}return vy=e,vy}lc.exports;var OT;function al(){return OT||(OT=1,(function(e,t){var n=Mr(),r=cse(),s=t&&!t.nodeType&&t,o=s&&!0&&e&&!e.nodeType&&e,i=o&&o.exports===s,c=i?n.Buffer:void 0,d=c?c.isBuffer:void 0,h=d||r;e.exports=h})(lc,lc.exports)),lc.exports}var by,IT;function Bf(){if(IT)return by;IT=1;var e=9007199254740991,t=/^(?:0|[1-9]\d*)$/;function n(r,s){var o=typeof r;return s=s??e,!!s&&(o=="number"||o!="symbol"&&t.test(r))&&r>-1&&r%1==0&&r<s}return by=n,by}var ky,PT;function T1(){if(PT)return ky;PT=1;var e=9007199254740991;function t(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=e}return ky=t,ky}var jy,DT;function use(){if(DT)return jy;DT=1;var e=$o(),t=T1(),n=os(),r="[object Arguments]",s="[object Array]",o="[object Boolean]",i="[object Date]",c="[object Error]",d="[object Function]",h="[object Map]",f="[object Number]",p="[object Object]",g="[object RegExp]",w="[object Set]",k="[object String]",j="[object WeakMap]",v="[object ArrayBuffer]",b="[object DataView]",N="[object Float32Array]",S="[object Float64Array]",E="[object Int8Array]",C="[object Int16Array]",$="[object Int32Array]",T="[object Uint8Array]",I="[object Uint8ClampedArray]",O="[object Uint16Array]",U="[object Uint32Array]",P={};P[N]=P[S]=P[E]=P[C]=P[$]=P[T]=P[I]=P[O]=P[U]=!0,P[r]=P[s]=P[v]=P[o]=P[b]=P[i]=P[c]=P[d]=P[h]=P[f]=P[p]=P[g]=P[w]=P[k]=P[j]=!1;function L(F){return n(F)&&t(F.length)&&!!P[e(F)]}return jy=L,jy}var Ny,FT;function qf(){if(FT)return Ny;FT=1;function e(t){return function(n){return t(n)}}return Ny=e,Ny}var cc={exports:{}};cc.exports;var BT;function R1(){return BT||(BT=1,(function(e,t){var n=PP(),r=t&&!t.nodeType&&t,s=r&&!0&&e&&!e.nodeType&&e,o=s&&s.exports===r,i=o&&n.process,c=(function(){try{var d=s&&s.require&&s.require("util").types;return d||i&&i.binding&&i.binding("util")}catch{}})();e.exports=c})(cc,cc.exports)),cc.exports}var Sy,qT;function au(){if(qT)return Sy;qT=1;var e=use(),t=qf(),n=R1(),r=n&&n.isTypedArray,s=r?t(r):e;return Sy=s,Sy}var _y,UT;function BP(){if(UT)return _y;UT=1;var e=ise(),t=su(),n=Ot(),r=al(),s=Bf(),o=au(),i=Object.prototype,c=i.hasOwnProperty;function d(h,f){var p=n(h),g=!p&&t(h),w=!p&&!g&&r(h),k=!p&&!g&&!w&&o(h),j=p||g||w||k,v=j?e(h.length,String):[],b=v.length;for(var N in h)(f||c.call(h,N))&&!(j&&(N=="length"||w&&(N=="offset"||N=="parent")||k&&(N=="buffer"||N=="byteLength"||N=="byteOffset")||s(N,b)))&&v.push(N);return v}return _y=d,_y}var Ey,HT;function Uf(){if(HT)return Ey;HT=1;var e=Object.prototype;function t(n){var r=n&&n.constructor,s=typeof r=="function"&&r.prototype||e;return n===s}return Ey=t,Ey}var Cy,WT;function qP(){if(WT)return Cy;WT=1;function e(t,n){return function(r){return t(n(r))}}return Cy=e,Cy}var Ty,zT;function dse(){if(zT)return Ty;zT=1;var e=qP(),t=e(Object.keys,Object);return Ty=t,Ty}var Ry,VT;function A1(){if(VT)return Ry;VT=1;var e=Uf(),t=dse(),n=Object.prototype,r=n.hasOwnProperty;function s(o){if(!e(o))return t(o);var i=[];for(var c in Object(o))r.call(o,c)&&c!="constructor"&&i.push(c);return i}return Ry=s,Ry}var Ay,GT;function Is(){if(GT)return Ay;GT=1;var e=nu(),t=T1();function n(r){return r!=null&&t(r.length)&&!e(r)}return Ay=n,Ay}var My,KT;function Aa(){if(KT)return My;KT=1;var e=BP(),t=A1(),n=Is();function r(s){return n(s)?e(s):t(s)}return My=r,My}var $y,YT;function hse(){if(YT)return $y;YT=1;var e=ru(),t=Aa();function n(r,s){return r&&e(s,t(s),r)}return $y=n,$y}var Ly,XT;function fse(){if(XT)return Ly;XT=1;function e(t){var n=[];if(t!=null)for(var r in Object(t))n.push(r);return n}return Ly=e,Ly}var Oy,ZT;function pse(){if(ZT)return Oy;ZT=1;var e=lr(),t=Uf(),n=fse(),r=Object.prototype,s=r.hasOwnProperty;function o(i){if(!e(i))return n(i);var c=t(i),d=[];for(var h in i)h=="constructor"&&(c||!s.call(i,h))||d.push(h);return d}return Oy=o,Oy}var Iy,JT;function Oo(){if(JT)return Iy;JT=1;var e=BP(),t=pse(),n=Is();function r(s){return n(s)?e(s,!0):t(s)}return Iy=r,Iy}var Py,QT;function mse(){if(QT)return Py;QT=1;var e=ru(),t=Oo();function n(r,s){return r&&e(s,t(s),r)}return Py=n,Py}var uc={exports:{}};uc.exports;var eR;function UP(){return eR||(eR=1,(function(e,t){var n=Mr(),r=t&&!t.nodeType&&t,s=r&&!0&&e&&!e.nodeType&&e,o=s&&s.exports===r,i=o?n.Buffer:void 0,c=i?i.allocUnsafe:void 0;function d(h,f){if(f)return h.slice();var p=h.length,g=c?c(p):new h.constructor(p);return h.copy(g),g}e.exports=d})(uc,uc.exports)),uc.exports}var Dy,tR;function HP(){if(tR)return Dy;tR=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 Dy=e,Dy}var Fy,nR;function WP(){if(nR)return Fy;nR=1;function e(t,n){for(var r=-1,s=t==null?0:t.length,o=0,i=[];++r<s;){var c=t[r];n(c,r,t)&&(i[o++]=c)}return i}return Fy=e,Fy}var By,rR;function zP(){if(rR)return By;rR=1;function e(){return[]}return By=e,By}var qy,sR;function M1(){if(sR)return qy;sR=1;var e=WP(),t=zP(),n=Object.prototype,r=n.propertyIsEnumerable,s=Object.getOwnPropertySymbols,o=s?function(i){return i==null?[]:(i=Object(i),e(s(i),function(c){return r.call(i,c)}))}:t;return qy=o,qy}var Uy,aR;function gse(){if(aR)return Uy;aR=1;var e=ru(),t=M1();function n(r,s){return e(r,t(r),s)}return Uy=n,Uy}var Hy,oR;function $1(){if(oR)return Hy;oR=1;function e(t,n){for(var r=-1,s=n.length,o=t.length;++r<s;)t[o+r]=n[r];return t}return Hy=e,Hy}var Wy,iR;function Hf(){if(iR)return Wy;iR=1;var e=qP(),t=e(Object.getPrototypeOf,Object);return Wy=t,Wy}var zy,lR;function VP(){if(lR)return zy;lR=1;var e=$1(),t=Hf(),n=M1(),r=zP(),s=Object.getOwnPropertySymbols,o=s?function(i){for(var c=[];i;)e(c,n(i)),i=t(i);return c}:r;return zy=o,zy}var Vy,cR;function yse(){if(cR)return Vy;cR=1;var e=ru(),t=VP();function n(r,s){return e(r,t(r),s)}return Vy=n,Vy}var Gy,uR;function GP(){if(uR)return Gy;uR=1;var e=$1(),t=Ot();function n(r,s,o){var i=s(r);return t(r)?i:e(i,o(r))}return Gy=n,Gy}var Ky,dR;function KP(){if(dR)return Ky;dR=1;var e=GP(),t=M1(),n=Aa();function r(s){return e(s,n,t)}return Ky=r,Ky}var Yy,hR;function wse(){if(hR)return Yy;hR=1;var e=GP(),t=VP(),n=Oo();function r(s){return e(s,n,t)}return Yy=r,Yy}var Xy,fR;function xse(){if(fR)return Xy;fR=1;var e=Lo(),t=Mr(),n=e(t,"DataView");return Xy=n,Xy}var Zy,pR;function vse(){if(pR)return Zy;pR=1;var e=Lo(),t=Mr(),n=e(t,"Promise");return Zy=n,Zy}var Jy,mR;function YP(){if(mR)return Jy;mR=1;var e=Lo(),t=Mr(),n=e(t,"Set");return Jy=n,Jy}var Qy,gR;function bse(){if(gR)return Qy;gR=1;var e=Lo(),t=Mr(),n=e(t,"WeakMap");return Qy=n,Qy}var ew,yR;function ol(){if(yR)return ew;yR=1;var e=xse(),t=_1(),n=vse(),r=YP(),s=bse(),o=$o(),i=DP(),c="[object Map]",d="[object Object]",h="[object Promise]",f="[object Set]",p="[object WeakMap]",g="[object DataView]",w=i(e),k=i(t),j=i(n),v=i(r),b=i(s),N=o;return(e&&N(new e(new ArrayBuffer(1)))!=g||t&&N(new t)!=c||n&&N(n.resolve())!=h||r&&N(new r)!=f||s&&N(new s)!=p)&&(N=function(S){var E=o(S),C=E==d?S.constructor:void 0,$=C?i(C):"";if($)switch($){case w:return g;case k:return c;case j:return h;case v:return f;case b:return p}return E}),ew=N,ew}var tw,wR;function kse(){if(wR)return tw;wR=1;var e=Object.prototype,t=e.hasOwnProperty;function n(r){var s=r.length,o=new r.constructor(s);return s&&typeof r[0]=="string"&&t.call(r,"index")&&(o.index=r.index,o.input=r.input),o}return tw=n,tw}var nw,xR;function XP(){if(xR)return nw;xR=1;var e=Mr(),t=e.Uint8Array;return nw=t,nw}var rw,vR;function L1(){if(vR)return rw;vR=1;var e=XP();function t(n){var r=new n.constructor(n.byteLength);return new e(r).set(new e(n)),r}return rw=t,rw}var sw,bR;function jse(){if(bR)return sw;bR=1;var e=L1();function t(n,r){var s=r?e(n.buffer):n.buffer;return new n.constructor(s,n.byteOffset,n.byteLength)}return sw=t,sw}var aw,kR;function Nse(){if(kR)return aw;kR=1;var e=/\w*$/;function t(n){var r=new n.constructor(n.source,e.exec(n));return r.lastIndex=n.lastIndex,r}return aw=t,aw}var ow,jR;function Sse(){if(jR)return ow;jR=1;var e=sl(),t=e?e.prototype:void 0,n=t?t.valueOf:void 0;function r(s){return n?Object(n.call(s)):{}}return ow=r,ow}var iw,NR;function ZP(){if(NR)return iw;NR=1;var e=L1();function t(n,r){var s=r?e(n.buffer):n.buffer;return new n.constructor(s,n.byteOffset,n.length)}return iw=t,iw}var lw,SR;function _se(){if(SR)return lw;SR=1;var e=L1(),t=jse(),n=Nse(),r=Sse(),s=ZP(),o="[object Boolean]",i="[object Date]",c="[object Map]",d="[object Number]",h="[object RegExp]",f="[object Set]",p="[object String]",g="[object Symbol]",w="[object ArrayBuffer]",k="[object DataView]",j="[object Float32Array]",v="[object Float64Array]",b="[object Int8Array]",N="[object Int16Array]",S="[object Int32Array]",E="[object Uint8Array]",C="[object Uint8ClampedArray]",$="[object Uint16Array]",T="[object Uint32Array]";function I(O,U,P){var L=O.constructor;switch(U){case w:return e(O);case o:case i:return new L(+O);case k:return t(O,P);case j:case v:case b:case N:case S:case E:case C:case $:case T:return s(O,P);case c:return new L;case d:case p:return new L(O);case h:return n(O);case f:return new L;case g:return r(O)}}return lw=I,lw}var cw,_R;function JP(){if(_R)return cw;_R=1;var e=lr(),t=Object.create,n=(function(){function r(){}return function(s){if(!e(s))return{};if(t)return t(s);r.prototype=s;var o=new r;return r.prototype=void 0,o}})();return cw=n,cw}var uw,ER;function QP(){if(ER)return uw;ER=1;var e=JP(),t=Hf(),n=Uf();function r(s){return typeof s.constructor=="function"&&!n(s)?e(t(s)):{}}return uw=r,uw}var dw,CR;function Ese(){if(CR)return dw;CR=1;var e=ol(),t=os(),n="[object Map]";function r(s){return t(s)&&e(s)==n}return dw=r,dw}var hw,TR;function Cse(){if(TR)return hw;TR=1;var e=Ese(),t=qf(),n=R1(),r=n&&n.isMap,s=r?t(r):e;return hw=s,hw}var fw,RR;function Tse(){if(RR)return fw;RR=1;var e=ol(),t=os(),n="[object Set]";function r(s){return t(s)&&e(s)==n}return fw=r,fw}var pw,AR;function Rse(){if(AR)return pw;AR=1;var e=Tse(),t=qf(),n=R1(),r=n&&n.isSet,s=r?t(r):e;return pw=s,pw}var mw,MR;function e4(){if(MR)return mw;MR=1;var e=Pf(),t=C1(),n=Ff(),r=hse(),s=mse(),o=UP(),i=HP(),c=gse(),d=yse(),h=KP(),f=wse(),p=ol(),g=kse(),w=_se(),k=QP(),j=Ot(),v=al(),b=Cse(),N=lr(),S=Rse(),E=Aa(),C=Oo(),$=1,T=2,I=4,O="[object Arguments]",U="[object Array]",P="[object Boolean]",L="[object Date]",F="[object Error]",A="[object Function]",B="[object GeneratorFunction]",D="[object Map]",K="[object Number]",G="[object Object]",H="[object RegExp]",q="[object Set]",M="[object String]",V="[object Symbol]",Z="[object WeakMap]",W="[object ArrayBuffer]",X="[object DataView]",Y="[object Float32Array]",J="[object Float64Array]",ee="[object Int8Array]",ne="[object Int16Array]",se="[object Int32Array]",ce="[object Uint8Array]",de="[object Uint8ClampedArray]",ae="[object Uint16Array]",pe="[object Uint32Array]",fe={};fe[O]=fe[U]=fe[W]=fe[X]=fe[P]=fe[L]=fe[Y]=fe[J]=fe[ee]=fe[ne]=fe[se]=fe[D]=fe[K]=fe[G]=fe[H]=fe[q]=fe[M]=fe[V]=fe[ce]=fe[de]=fe[ae]=fe[pe]=!0,fe[F]=fe[A]=fe[Z]=!1;function Ee(ye,oe,we,Ne,ge,Ae){var Oe,qe=oe&$,Me=oe&T,He=oe&I;if(we&&(Oe=ge?we(ye,Ne,ge,Ae):we(ye)),Oe!==void 0)return Oe;if(!N(ye))return ye;var rt=j(ye);if(rt){if(Oe=g(ye),!qe)return i(ye,Oe)}else{var Ue=p(ye),it=Ue==A||Ue==B;if(v(ye))return o(ye,qe);if(Ue==G||Ue==O||it&&!ge){if(Oe=Me||it?{}:k(ye),!qe)return Me?d(ye,s(Oe,ye)):c(ye,r(Oe,ye))}else{if(!fe[Ue])return ge?ye:{};Oe=w(ye,Ue,qe)}}Ae||(Ae=new e);var Et=Ae.get(ye);if(Et)return Et;Ae.set(ye,Oe),S(ye)?ye.forEach(function(ft){Oe.add(Ee(ft,oe,we,ft,ye,Ae))}):b(ye)&&ye.forEach(function(ft,Be){Oe.set(Be,Ee(ft,oe,we,Be,ye,Ae))});var st=He?Me?f:h:Me?C:E,ht=rt?void 0:st(ye);return t(ht||ye,function(ft,Be){ht&&(Be=ft,ft=ye[Be]),n(Oe,Be,Ee(ft,oe,we,Be,ye,Ae))}),Oe}return mw=Ee,mw}var gw,$R;function Ase(){if($R)return gw;$R=1;var e=e4(),t=4;function n(r){return e(r,t)}return gw=n,gw}var yw,LR;function O1(){if(LR)return yw;LR=1;function e(t){return function(){return t}}return yw=e,yw}var ww,OR;function Mse(){if(OR)return ww;OR=1;function e(t){return function(n,r,s){for(var o=-1,i=Object(n),c=s(n),d=c.length;d--;){var h=c[t?d:++o];if(r(i[h],h,i)===!1)break}return n}}return ww=e,ww}var xw,IR;function I1(){if(IR)return xw;IR=1;var e=Mse(),t=e();return xw=t,xw}var vw,PR;function P1(){if(PR)return vw;PR=1;var e=I1(),t=Aa();function n(r,s){return r&&e(r,s,t)}return vw=n,vw}var bw,DR;function $se(){if(DR)return bw;DR=1;var e=Is();function t(n,r){return function(s,o){if(s==null)return s;if(!e(s))return n(s,o);for(var i=s.length,c=r?i:-1,d=Object(s);(r?c--:++c<i)&&o(d[c],c,d)!==!1;);return s}}return bw=t,bw}var kw,FR;function Wf(){if(FR)return kw;FR=1;var e=P1(),t=$se(),n=t(e);return kw=n,kw}var jw,BR;function Io(){if(BR)return jw;BR=1;function e(t){return t}return jw=e,jw}var Nw,qR;function t4(){if(qR)return Nw;qR=1;var e=Io();function t(n){return typeof n=="function"?n:e}return Nw=t,Nw}var Sw,UR;function n4(){if(UR)return Sw;UR=1;var e=C1(),t=Wf(),n=t4(),r=Ot();function s(o,i){var c=r(o)?e:t;return c(o,n(i))}return Sw=s,Sw}var _w,HR;function r4(){return HR||(HR=1,_w=n4()),_w}var Ew,WR;function Lse(){if(WR)return Ew;WR=1;var e=Wf();function t(n,r){var s=[];return e(n,function(o,i,c){r(o,i,c)&&s.push(o)}),s}return Ew=t,Ew}var Cw,zR;function Ose(){if(zR)return Cw;zR=1;var e="__lodash_hash_undefined__";function t(n){return this.__data__.set(n,e),this}return Cw=t,Cw}var Tw,VR;function Ise(){if(VR)return Tw;VR=1;function e(t){return this.__data__.has(t)}return Tw=e,Tw}var Rw,GR;function s4(){if(GR)return Rw;GR=1;var e=E1(),t=Ose(),n=Ise();function r(s){var o=-1,i=s==null?0:s.length;for(this.__data__=new e;++o<i;)this.add(s[o])}return r.prototype.add=r.prototype.push=t,r.prototype.has=n,Rw=r,Rw}var Aw,KR;function Pse(){if(KR)return Aw;KR=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 Aw=e,Aw}var Mw,YR;function a4(){if(YR)return Mw;YR=1;function e(t,n){return t.has(n)}return Mw=e,Mw}var $w,XR;function o4(){if(XR)return $w;XR=1;var e=s4(),t=Pse(),n=a4(),r=1,s=2;function o(i,c,d,h,f,p){var g=d&r,w=i.length,k=c.length;if(w!=k&&!(g&&k>w))return!1;var j=p.get(i),v=p.get(c);if(j&&v)return j==c&&v==i;var b=-1,N=!0,S=d&s?new e:void 0;for(p.set(i,c),p.set(c,i);++b<w;){var E=i[b],C=c[b];if(h)var $=g?h(C,E,b,c,i,p):h(E,C,b,i,c,p);if($!==void 0){if($)continue;N=!1;break}if(S){if(!t(c,function(T,I){if(!n(S,I)&&(E===T||f(E,T,d,h,p)))return S.push(I)})){N=!1;break}}else if(!(E===C||f(E,C,d,h,p))){N=!1;break}}return p.delete(i),p.delete(c),N}return $w=o,$w}var Lw,ZR;function Dse(){if(ZR)return Lw;ZR=1;function e(t){var n=-1,r=Array(t.size);return t.forEach(function(s,o){r[++n]=[o,s]}),r}return Lw=e,Lw}var Ow,JR;function D1(){if(JR)return Ow;JR=1;function e(t){var n=-1,r=Array(t.size);return t.forEach(function(s){r[++n]=s}),r}return Ow=e,Ow}var Iw,QR;function Fse(){if(QR)return Iw;QR=1;var e=sl(),t=XP(),n=rl(),r=o4(),s=Dse(),o=D1(),i=1,c=2,d="[object Boolean]",h="[object Date]",f="[object Error]",p="[object Map]",g="[object Number]",w="[object RegExp]",k="[object Set]",j="[object String]",v="[object Symbol]",b="[object ArrayBuffer]",N="[object DataView]",S=e?e.prototype:void 0,E=S?S.valueOf:void 0;function C($,T,I,O,U,P,L){switch(I){case N:if($.byteLength!=T.byteLength||$.byteOffset!=T.byteOffset)return!1;$=$.buffer,T=T.buffer;case b:return!($.byteLength!=T.byteLength||!P(new t($),new t(T)));case d:case h:case g:return n(+$,+T);case f:return $.name==T.name&&$.message==T.message;case w:case j:return $==T+"";case p:var F=s;case k:var A=O&i;if(F||(F=o),$.size!=T.size&&!A)return!1;var B=L.get($);if(B)return B==T;O|=c,L.set($,T);var D=r(F($),F(T),O,U,P,L);return L.delete($),D;case v:if(E)return E.call($)==E.call(T)}return!1}return Iw=C,Iw}var Pw,eA;function Bse(){if(eA)return Pw;eA=1;var e=KP(),t=1,n=Object.prototype,r=n.hasOwnProperty;function s(o,i,c,d,h,f){var p=c&t,g=e(o),w=g.length,k=e(i),j=k.length;if(w!=j&&!p)return!1;for(var v=w;v--;){var b=g[v];if(!(p?b in i:r.call(i,b)))return!1}var N=f.get(o),S=f.get(i);if(N&&S)return N==i&&S==o;var E=!0;f.set(o,i),f.set(i,o);for(var C=p;++v<w;){b=g[v];var $=o[b],T=i[b];if(d)var I=p?d(T,$,b,i,o,f):d($,T,b,o,i,f);if(!(I===void 0?$===T||h($,T,c,d,f):I)){E=!1;break}C||(C=b=="constructor")}if(E&&!C){var O=o.constructor,U=i.constructor;O!=U&&"constructor"in o&&"constructor"in i&&!(typeof O=="function"&&O instanceof O&&typeof U=="function"&&U instanceof U)&&(E=!1)}return f.delete(o),f.delete(i),E}return Pw=s,Pw}var Dw,tA;function qse(){if(tA)return Dw;tA=1;var e=Pf(),t=o4(),n=Fse(),r=Bse(),s=ol(),o=Ot(),i=al(),c=au(),d=1,h="[object Arguments]",f="[object Array]",p="[object Object]",g=Object.prototype,w=g.hasOwnProperty;function k(j,v,b,N,S,E){var C=o(j),$=o(v),T=C?f:s(j),I=$?f:s(v);T=T==h?p:T,I=I==h?p:I;var O=T==p,U=I==p,P=T==I;if(P&&i(j)){if(!i(v))return!1;C=!0,O=!1}if(P&&!O)return E||(E=new e),C||c(j)?t(j,v,b,N,S,E):n(j,v,T,b,N,S,E);if(!(b&d)){var L=O&&w.call(j,"__wrapped__"),F=U&&w.call(v,"__wrapped__");if(L||F){var A=L?j.value():j,B=F?v.value():v;return E||(E=new e),S(A,B,b,N,E)}}return P?(E||(E=new e),r(j,v,b,N,S,E)):!1}return Dw=k,Dw}var Fw,nA;function i4(){if(nA)return Fw;nA=1;var e=qse(),t=os();function n(r,s,o,i,c){return r===s?!0:r==null||s==null||!t(r)&&!t(s)?r!==r&&s!==s:e(r,s,o,i,n,c)}return Fw=n,Fw}var Bw,rA;function Use(){if(rA)return Bw;rA=1;var e=Pf(),t=i4(),n=1,r=2;function s(o,i,c,d){var h=c.length,f=h,p=!d;if(o==null)return!f;for(o=Object(o);h--;){var g=c[h];if(p&&g[2]?g[1]!==o[g[0]]:!(g[0]in o))return!1}for(;++h<f;){g=c[h];var w=g[0],k=o[w],j=g[1];if(p&&g[2]){if(k===void 0&&!(w in o))return!1}else{var v=new e;if(d)var b=d(k,j,w,o,i,v);if(!(b===void 0?t(j,k,n|r,d,v):b))return!1}}return!0}return Bw=s,Bw}var qw,sA;function l4(){if(sA)return qw;sA=1;var e=lr();function t(n){return n===n&&!e(n)}return qw=t,qw}var Uw,aA;function Hse(){if(aA)return Uw;aA=1;var e=l4(),t=Aa();function n(r){for(var s=t(r),o=s.length;o--;){var i=s[o],c=r[i];s[o]=[i,c,e(c)]}return s}return Uw=n,Uw}var Hw,oA;function c4(){if(oA)return Hw;oA=1;function e(t,n){return function(r){return r==null?!1:r[t]===n&&(n!==void 0||t in Object(r))}}return Hw=e,Hw}var Ww,iA;function Wse(){if(iA)return Ww;iA=1;var e=Use(),t=Hse(),n=c4();function r(s){var o=t(s);return o.length==1&&o[0][2]?n(o[0][0],o[0][1]):function(i){return i===s||e(i,s,o)}}return Ww=r,Ww}var zw,lA;function il(){if(lA)return zw;lA=1;var e=$o(),t=os(),n="[object Symbol]";function r(s){return typeof s=="symbol"||t(s)&&e(s)==n}return zw=r,zw}var Vw,cA;function F1(){if(cA)return Vw;cA=1;var e=Ot(),t=il(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,r=/^\w*$/;function s(o,i){if(e(o))return!1;var c=typeof o;return c=="number"||c=="symbol"||c=="boolean"||o==null||t(o)?!0:r.test(o)||!n.test(o)||i!=null&&o in Object(i)}return Vw=s,Vw}var Gw,uA;function zse(){if(uA)return Gw;uA=1;var e=E1(),t="Expected a function";function n(r,s){if(typeof r!="function"||s!=null&&typeof s!="function")throw new TypeError(t);var o=function(){var i=arguments,c=s?s.apply(this,i):i[0],d=o.cache;if(d.has(c))return d.get(c);var h=r.apply(this,i);return o.cache=d.set(c,h)||d,h};return o.cache=new(n.Cache||e),o}return n.Cache=e,Gw=n,Gw}var Kw,dA;function Vse(){if(dA)return Kw;dA=1;var e=zse(),t=500;function n(r){var s=e(r,function(i){return o.size===t&&o.clear(),i}),o=s.cache;return s}return Kw=n,Kw}var Yw,hA;function Gse(){if(hA)return Yw;hA=1;var e=Vse(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,n=/\\(\\)?/g,r=e(function(s){var o=[];return s.charCodeAt(0)===46&&o.push(""),s.replace(t,function(i,c,d,h){o.push(d?h.replace(n,"$1"):c||i)}),o});return Yw=r,Yw}var Xw,fA;function zf(){if(fA)return Xw;fA=1;function e(t,n){for(var r=-1,s=t==null?0:t.length,o=Array(s);++r<s;)o[r]=n(t[r],r,t);return o}return Xw=e,Xw}var Zw,pA;function Kse(){if(pA)return Zw;pA=1;var e=sl(),t=zf(),n=Ot(),r=il(),s=e?e.prototype:void 0,o=s?s.toString:void 0;function i(c){if(typeof c=="string")return c;if(n(c))return t(c,i)+"";if(r(c))return o?o.call(c):"";var d=c+"";return d=="0"&&1/c==-1/0?"-0":d}return Zw=i,Zw}var Jw,mA;function u4(){if(mA)return Jw;mA=1;var e=Kse();function t(n){return n==null?"":e(n)}return Jw=t,Jw}var Qw,gA;function Vf(){if(gA)return Qw;gA=1;var e=Ot(),t=F1(),n=Gse(),r=u4();function s(o,i){return e(o)?o:t(o,i)?[o]:n(r(o))}return Qw=s,Qw}var ex,yA;function ou(){if(yA)return ex;yA=1;var e=il();function t(n){if(typeof n=="string"||e(n))return n;var r=n+"";return r=="0"&&1/n==-1/0?"-0":r}return ex=t,ex}var tx,wA;function Gf(){if(wA)return tx;wA=1;var e=Vf(),t=ou();function n(r,s){s=e(s,r);for(var o=0,i=s.length;r!=null&&o<i;)r=r[t(s[o++])];return o&&o==i?r:void 0}return tx=n,tx}var nx,xA;function Yse(){if(xA)return nx;xA=1;var e=Gf();function t(n,r,s){var o=n==null?void 0:e(n,r);return o===void 0?s:o}return nx=t,nx}var rx,vA;function Xse(){if(vA)return rx;vA=1;function e(t,n){return t!=null&&n in Object(t)}return rx=e,rx}var sx,bA;function d4(){if(bA)return sx;bA=1;var e=Vf(),t=su(),n=Ot(),r=Bf(),s=T1(),o=ou();function i(c,d,h){d=e(d,c);for(var f=-1,p=d.length,g=!1;++f<p;){var w=o(d[f]);if(!(g=c!=null&&h(c,w)))break;c=c[w]}return g||++f!=p?g:(p=c==null?0:c.length,!!p&&s(p)&&r(w,p)&&(n(c)||t(c)))}return sx=i,sx}var ax,kA;function h4(){if(kA)return ax;kA=1;var e=Xse(),t=d4();function n(r,s){return r!=null&&t(r,s,e)}return ax=n,ax}var ox,jA;function Zse(){if(jA)return ox;jA=1;var e=i4(),t=Yse(),n=h4(),r=F1(),s=l4(),o=c4(),i=ou(),c=1,d=2;function h(f,p){return r(f)&&s(p)?o(i(f),p):function(g){var w=t(g,f);return w===void 0&&w===p?n(g,f):e(p,w,c|d)}}return ox=h,ox}var ix,NA;function f4(){if(NA)return ix;NA=1;function e(t){return function(n){return n==null?void 0:n[t]}}return ix=e,ix}var lx,SA;function Jse(){if(SA)return lx;SA=1;var e=Gf();function t(n){return function(r){return e(r,n)}}return lx=t,lx}var cx,_A;function Qse(){if(_A)return cx;_A=1;var e=f4(),t=Jse(),n=F1(),r=ou();function s(o){return n(o)?e(r(o)):t(o)}return cx=s,cx}var ux,EA;function Ps(){if(EA)return ux;EA=1;var e=Wse(),t=Zse(),n=Io(),r=Ot(),s=Qse();function o(i){return typeof i=="function"?i:i==null?n:typeof i=="object"?r(i)?t(i[0],i[1]):e(i):s(i)}return ux=o,ux}var dx,CA;function p4(){if(CA)return dx;CA=1;var e=WP(),t=Lse(),n=Ps(),r=Ot();function s(o,i){var c=r(o)?e:t;return c(o,n(i,3))}return dx=s,dx}var hx,TA;function eae(){if(TA)return hx;TA=1;var e=Object.prototype,t=e.hasOwnProperty;function n(r,s){return r!=null&&t.call(r,s)}return hx=n,hx}var fx,RA;function m4(){if(RA)return fx;RA=1;var e=eae(),t=d4();function n(r,s){return r!=null&&t(r,s,e)}return fx=n,fx}var px,AA;function tae(){if(AA)return px;AA=1;var e=A1(),t=ol(),n=su(),r=Ot(),s=Is(),o=al(),i=Uf(),c=au(),d="[object Map]",h="[object Set]",f=Object.prototype,p=f.hasOwnProperty;function g(w){if(w==null)return!0;if(s(w)&&(r(w)||typeof w=="string"||typeof w.splice=="function"||o(w)||c(w)||n(w)))return!w.length;var k=t(w);if(k==d||k==h)return!w.size;if(i(w))return!e(w).length;for(var j in w)if(p.call(w,j))return!1;return!0}return px=g,px}var mx,MA;function g4(){if(MA)return mx;MA=1;function e(t){return t===void 0}return mx=e,mx}var gx,$A;function y4(){if($A)return gx;$A=1;var e=Wf(),t=Is();function n(r,s){var o=-1,i=t(r)?Array(r.length):[];return e(r,function(c,d,h){i[++o]=s(c,d,h)}),i}return gx=n,gx}var yx,LA;function w4(){if(LA)return yx;LA=1;var e=zf(),t=Ps(),n=y4(),r=Ot();function s(o,i){var c=r(o)?e:n;return c(o,t(i,3))}return yx=s,yx}var wx,OA;function nae(){if(OA)return wx;OA=1;function e(t,n,r,s){var o=-1,i=t==null?0:t.length;for(s&&i&&(r=t[++o]);++o<i;)r=n(r,t[o],o,t);return r}return wx=e,wx}var xx,IA;function rae(){if(IA)return xx;IA=1;function e(t,n,r,s,o){return o(t,function(i,c,d){r=s?(s=!1,i):n(r,i,c,d)}),r}return xx=e,xx}var vx,PA;function x4(){if(PA)return vx;PA=1;var e=nae(),t=Wf(),n=Ps(),r=rae(),s=Ot();function o(i,c,d){var h=s(i)?e:r,f=arguments.length<3;return h(i,n(c,4),d,f,t)}return vx=o,vx}var bx,DA;function sae(){if(DA)return bx;DA=1;var e=$o(),t=Ot(),n=os(),r="[object String]";function s(o){return typeof o=="string"||!t(o)&&n(o)&&e(o)==r}return bx=s,bx}var kx,FA;function aae(){if(FA)return kx;FA=1;var e=f4(),t=e("length");return kx=t,kx}var jx,BA;function oae(){if(BA)return jx;BA=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",r="\\u20d0-\\u20ff",s=t+n+r,o="\\ufe0e\\ufe0f",i="\\u200d",c=RegExp("["+i+e+s+o+"]");function d(h){return c.test(h)}return jx=d,jx}var Nx,qA;function iae(){if(qA)return Nx;qA=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",r="\\u20d0-\\u20ff",s=t+n+r,o="\\ufe0e\\ufe0f",i="["+e+"]",c="["+s+"]",d="\\ud83c[\\udffb-\\udfff]",h="(?:"+c+"|"+d+")",f="[^"+e+"]",p="(?:\\ud83c[\\udde6-\\uddff]){2}",g="[\\ud800-\\udbff][\\udc00-\\udfff]",w="\\u200d",k=h+"?",j="["+o+"]?",v="(?:"+w+"(?:"+[f,p,g].join("|")+")"+j+k+")*",b=j+k+v,N="(?:"+[f+c+"?",c,p,g,i].join("|")+")",S=RegExp(d+"(?="+d+")|"+N+b,"g");function E(C){for(var $=S.lastIndex=0;S.test(C);)++$;return $}return Nx=E,Nx}var Sx,UA;function lae(){if(UA)return Sx;UA=1;var e=aae(),t=oae(),n=iae();function r(s){return t(s)?n(s):e(s)}return Sx=r,Sx}var _x,HA;function cae(){if(HA)return _x;HA=1;var e=A1(),t=ol(),n=Is(),r=sae(),s=lae(),o="[object Map]",i="[object Set]";function c(d){if(d==null)return 0;if(n(d))return r(d)?s(d):d.length;var h=t(d);return h==o||h==i?d.size:e(d).length}return _x=c,_x}var Ex,WA;function uae(){if(WA)return Ex;WA=1;var e=C1(),t=JP(),n=P1(),r=Ps(),s=Hf(),o=Ot(),i=al(),c=nu(),d=lr(),h=au();function f(p,g,w){var k=o(p),j=k||i(p)||h(p);if(g=r(g,4),w==null){var v=p&&p.constructor;j?w=k?new v:[]:d(p)?w=c(v)?t(s(p)):{}:w={}}return(j?e:n)(p,function(b,N,S){return g(w,b,N,S)}),w}return Ex=f,Ex}var Cx,zA;function dae(){if(zA)return Cx;zA=1;var e=sl(),t=su(),n=Ot(),r=e?e.isConcatSpreadable:void 0;function s(o){return n(o)||t(o)||!!(r&&o&&o[r])}return Cx=s,Cx}var Tx,VA;function B1(){if(VA)return Tx;VA=1;var e=$1(),t=dae();function n(r,s,o,i,c){var d=-1,h=r.length;for(o||(o=t),c||(c=[]);++d<h;){var f=r[d];s>0&&o(f)?s>1?n(f,s-1,o,i,c):e(c,f):i||(c[c.length]=f)}return c}return Tx=n,Tx}var Rx,GA;function hae(){if(GA)return Rx;GA=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 Rx=e,Rx}var Ax,KA;function v4(){if(KA)return Ax;KA=1;var e=hae(),t=Math.max;function n(r,s,o){return s=t(s===void 0?r.length-1:s,0),function(){for(var i=arguments,c=-1,d=t(i.length-s,0),h=Array(d);++c<d;)h[c]=i[s+c];c=-1;for(var f=Array(s+1);++c<s;)f[c]=i[c];return f[s]=o(h),e(r,this,f)}}return Ax=n,Ax}var Mx,YA;function fae(){if(YA)return Mx;YA=1;var e=O1(),t=FP(),n=Io(),r=t?function(s,o){return t(s,"toString",{configurable:!0,enumerable:!1,value:e(o),writable:!0})}:n;return Mx=r,Mx}var $x,XA;function pae(){if(XA)return $x;XA=1;var e=800,t=16,n=Date.now;function r(s){var o=0,i=0;return function(){var c=n(),d=t-(c-i);if(i=c,d>0){if(++o>=e)return arguments[0]}else o=0;return s.apply(void 0,arguments)}}return $x=r,$x}var Lx,ZA;function b4(){if(ZA)return Lx;ZA=1;var e=fae(),t=pae(),n=t(e);return Lx=n,Lx}var Ox,JA;function Kf(){if(JA)return Ox;JA=1;var e=Io(),t=v4(),n=b4();function r(s,o){return n(t(s,o,e),s+"")}return Ox=r,Ox}var Ix,QA;function k4(){if(QA)return Ix;QA=1;function e(t,n,r,s){for(var o=t.length,i=r+(s?1:-1);s?i--:++i<o;)if(n(t[i],i,t))return i;return-1}return Ix=e,Ix}var Px,e2;function mae(){if(e2)return Px;e2=1;function e(t){return t!==t}return Px=e,Px}var Dx,t2;function gae(){if(t2)return Dx;t2=1;function e(t,n,r){for(var s=r-1,o=t.length;++s<o;)if(t[s]===n)return s;return-1}return Dx=e,Dx}var Fx,n2;function yae(){if(n2)return Fx;n2=1;var e=k4(),t=mae(),n=gae();function r(s,o,i){return o===o?n(s,o,i):e(s,t,i)}return Fx=r,Fx}var Bx,r2;function wae(){if(r2)return Bx;r2=1;var e=yae();function t(n,r){var s=n==null?0:n.length;return!!s&&e(n,r,0)>-1}return Bx=t,Bx}var qx,s2;function xae(){if(s2)return qx;s2=1;function e(t,n,r){for(var s=-1,o=t==null?0:t.length;++s<o;)if(r(n,t[s]))return!0;return!1}return qx=e,qx}var Ux,a2;function vae(){if(a2)return Ux;a2=1;function e(){}return Ux=e,Ux}var Hx,o2;function bae(){if(o2)return Hx;o2=1;var e=YP(),t=vae(),n=D1(),r=1/0,s=e&&1/n(new e([,-0]))[1]==r?function(o){return new e(o)}:t;return Hx=s,Hx}var Wx,i2;function kae(){if(i2)return Wx;i2=1;var e=s4(),t=wae(),n=xae(),r=a4(),s=bae(),o=D1(),i=200;function c(d,h,f){var p=-1,g=t,w=d.length,k=!0,j=[],v=j;if(f)k=!1,g=n;else if(w>=i){var b=h?null:s(d);if(b)return o(b);k=!1,g=r,v=new e}else v=h?[]:j;e:for(;++p<w;){var N=d[p],S=h?h(N):N;if(N=f||N!==0?N:0,k&&S===S){for(var E=v.length;E--;)if(v[E]===S)continue e;h&&v.push(S),j.push(N)}else g(v,S,f)||(v!==j&&v.push(S),j.push(N))}return j}return Wx=c,Wx}var zx,l2;function j4(){if(l2)return zx;l2=1;var e=Is(),t=os();function n(r){return t(r)&&e(r)}return zx=n,zx}var Vx,c2;function jae(){if(c2)return Vx;c2=1;var e=B1(),t=Kf(),n=kae(),r=j4(),s=t(function(o){return n(e(o,1,r,!0))});return Vx=s,Vx}var Gx,u2;function Nae(){if(u2)return Gx;u2=1;var e=zf();function t(n,r){return e(r,function(s){return n[s]})}return Gx=t,Gx}var Kx,d2;function N4(){if(d2)return Kx;d2=1;var e=Nae(),t=Aa();function n(r){return r==null?[]:e(r,t(r))}return Kx=n,Kx}var Yx,h2;function cr(){if(h2)return Yx;h2=1;var e;if(typeof S1=="function")try{e={clone:Ase(),constant:O1(),each:r4(),filter:p4(),has:m4(),isArray:Ot(),isEmpty:tae(),isFunction:nu(),isUndefined:g4(),keys:Aa(),map:w4(),reduce:x4(),size:cae(),transform:uae(),union:jae(),values:N4()}}catch{}return e||(e=window._),Yx=e,Yx}var Xx,f2;function q1(){if(f2)return Xx;f2=1;var e=cr();Xx=s;var t="\0",n="\0",r="";function s(f){this._isDirected=e.has(f,"directed")?f.directed:!0,this._isMultigraph=e.has(f,"multigraph")?f.multigraph:!1,this._isCompound=e.has(f,"compound")?f.compound:!1,this._label=void 0,this._defaultNodeLabelFn=e.constant(void 0),this._defaultEdgeLabelFn=e.constant(void 0),this._nodes={},this._isCompound&&(this._parent={},this._children={},this._children[n]={}),this._in={},this._preds={},this._out={},this._sucs={},this._edgeObjs={},this._edgeLabels={}}s.prototype._nodeCount=0,s.prototype._edgeCount=0,s.prototype.isDirected=function(){return this._isDirected},s.prototype.isMultigraph=function(){return this._isMultigraph},s.prototype.isCompound=function(){return this._isCompound},s.prototype.setGraph=function(f){return this._label=f,this},s.prototype.graph=function(){return this._label},s.prototype.setDefaultNodeLabel=function(f){return e.isFunction(f)||(f=e.constant(f)),this._defaultNodeLabelFn=f,this},s.prototype.nodeCount=function(){return this._nodeCount},s.prototype.nodes=function(){return e.keys(this._nodes)},s.prototype.sources=function(){var f=this;return e.filter(this.nodes(),function(p){return e.isEmpty(f._in[p])})},s.prototype.sinks=function(){var f=this;return e.filter(this.nodes(),function(p){return e.isEmpty(f._out[p])})},s.prototype.setNodes=function(f,p){var g=arguments,w=this;return e.each(f,function(k){g.length>1?w.setNode(k,p):w.setNode(k)}),this},s.prototype.setNode=function(f,p){return e.has(this._nodes,f)?(arguments.length>1&&(this._nodes[f]=p),this):(this._nodes[f]=arguments.length>1?p:this._defaultNodeLabelFn(f),this._isCompound&&(this._parent[f]=n,this._children[f]={},this._children[n][f]=!0),this._in[f]={},this._preds[f]={},this._out[f]={},this._sucs[f]={},++this._nodeCount,this)},s.prototype.node=function(f){return this._nodes[f]},s.prototype.hasNode=function(f){return e.has(this._nodes,f)},s.prototype.removeNode=function(f){var p=this;if(e.has(this._nodes,f)){var g=function(w){p.removeEdge(p._edgeObjs[w])};delete this._nodes[f],this._isCompound&&(this._removeFromParentsChildList(f),delete this._parent[f],e.each(this.children(f),function(w){p.setParent(w)}),delete this._children[f]),e.each(e.keys(this._in[f]),g),delete this._in[f],delete this._preds[f],e.each(e.keys(this._out[f]),g),delete this._out[f],delete this._sucs[f],--this._nodeCount}return this},s.prototype.setParent=function(f,p){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(p))p=n;else{p+="";for(var g=p;!e.isUndefined(g);g=this.parent(g))if(g===f)throw new Error("Setting "+p+" as parent of "+f+" would create a cycle");this.setNode(p)}return this.setNode(f),this._removeFromParentsChildList(f),this._parent[f]=p,this._children[p][f]=!0,this},s.prototype._removeFromParentsChildList=function(f){delete this._children[this._parent[f]][f]},s.prototype.parent=function(f){if(this._isCompound){var p=this._parent[f];if(p!==n)return p}},s.prototype.children=function(f){if(e.isUndefined(f)&&(f=n),this._isCompound){var p=this._children[f];if(p)return e.keys(p)}else{if(f===n)return this.nodes();if(this.hasNode(f))return[]}},s.prototype.predecessors=function(f){var p=this._preds[f];if(p)return e.keys(p)},s.prototype.successors=function(f){var p=this._sucs[f];if(p)return e.keys(p)},s.prototype.neighbors=function(f){var p=this.predecessors(f);if(p)return e.union(p,this.successors(f))},s.prototype.isLeaf=function(f){var p;return this.isDirected()?p=this.successors(f):p=this.neighbors(f),p.length===0},s.prototype.filterNodes=function(f){var p=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});p.setGraph(this.graph());var g=this;e.each(this._nodes,function(j,v){f(v)&&p.setNode(v,j)}),e.each(this._edgeObjs,function(j){p.hasNode(j.v)&&p.hasNode(j.w)&&p.setEdge(j,g.edge(j))});var w={};function k(j){var v=g.parent(j);return v===void 0||p.hasNode(v)?(w[j]=v,v):v in w?w[v]:k(v)}return this._isCompound&&e.each(p.nodes(),function(j){p.setParent(j,k(j))}),p},s.prototype.setDefaultEdgeLabel=function(f){return e.isFunction(f)||(f=e.constant(f)),this._defaultEdgeLabelFn=f,this},s.prototype.edgeCount=function(){return this._edgeCount},s.prototype.edges=function(){return e.values(this._edgeObjs)},s.prototype.setPath=function(f,p){var g=this,w=arguments;return e.reduce(f,function(k,j){return w.length>1?g.setEdge(k,j,p):g.setEdge(k,j),j}),this},s.prototype.setEdge=function(){var f,p,g,w,k=!1,j=arguments[0];typeof j=="object"&&j!==null&&"v"in j?(f=j.v,p=j.w,g=j.name,arguments.length===2&&(w=arguments[1],k=!0)):(f=j,p=arguments[1],g=arguments[3],arguments.length>2&&(w=arguments[2],k=!0)),f=""+f,p=""+p,e.isUndefined(g)||(g=""+g);var v=c(this._isDirected,f,p,g);if(e.has(this._edgeLabels,v))return k&&(this._edgeLabels[v]=w),this;if(!e.isUndefined(g)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(f),this.setNode(p),this._edgeLabels[v]=k?w:this._defaultEdgeLabelFn(f,p,g);var b=d(this._isDirected,f,p,g);return f=b.v,p=b.w,Object.freeze(b),this._edgeObjs[v]=b,o(this._preds[p],f),o(this._sucs[f],p),this._in[p][v]=b,this._out[f][v]=b,this._edgeCount++,this},s.prototype.edge=function(f,p,g){var w=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,f,p,g);return this._edgeLabels[w]},s.prototype.hasEdge=function(f,p,g){var w=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,f,p,g);return e.has(this._edgeLabels,w)},s.prototype.removeEdge=function(f,p,g){var w=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,f,p,g),k=this._edgeObjs[w];return k&&(f=k.v,p=k.w,delete this._edgeLabels[w],delete this._edgeObjs[w],i(this._preds[p],f),i(this._sucs[f],p),delete this._in[p][w],delete this._out[f][w],this._edgeCount--),this},s.prototype.inEdges=function(f,p){var g=this._in[f];if(g){var w=e.values(g);return p?e.filter(w,function(k){return k.v===p}):w}},s.prototype.outEdges=function(f,p){var g=this._out[f];if(g){var w=e.values(g);return p?e.filter(w,function(k){return k.w===p}):w}},s.prototype.nodeEdges=function(f,p){var g=this.inEdges(f,p);if(g)return g.concat(this.outEdges(f,p))};function o(f,p){f[p]?f[p]++:f[p]=1}function i(f,p){--f[p]||delete f[p]}function c(f,p,g,w){var k=""+p,j=""+g;if(!f&&k>j){var v=k;k=j,j=v}return k+r+j+r+(e.isUndefined(w)?t:w)}function d(f,p,g,w){var k=""+p,j=""+g;if(!f&&k>j){var v=k;k=j,j=v}var b={v:k,w:j};return w&&(b.name=w),b}function h(f,p){return c(f,p.v,p.w,p.name)}return Xx}var Zx,p2;function Sae(){return p2||(p2=1,Zx="2.1.8"),Zx}var Jx,m2;function _ae(){return m2||(m2=1,Jx={Graph:q1(),version:Sae()}),Jx}var Qx,g2;function Eae(){if(g2)return Qx;g2=1;var e=cr(),t=q1();Qx={write:n,read:o};function n(i){var c={options:{directed:i.isDirected(),multigraph:i.isMultigraph(),compound:i.isCompound()},nodes:r(i),edges:s(i)};return e.isUndefined(i.graph())||(c.value=e.clone(i.graph())),c}function r(i){return e.map(i.nodes(),function(c){var d=i.node(c),h=i.parent(c),f={v:c};return e.isUndefined(d)||(f.value=d),e.isUndefined(h)||(f.parent=h),f})}function s(i){return e.map(i.edges(),function(c){var d=i.edge(c),h={v:c.v,w:c.w};return e.isUndefined(c.name)||(h.name=c.name),e.isUndefined(d)||(h.value=d),h})}function o(i){var c=new t(i.options).setGraph(i.value);return e.each(i.nodes,function(d){c.setNode(d.v,d.value),d.parent&&c.setParent(d.v,d.parent)}),e.each(i.edges,function(d){c.setEdge({v:d.v,w:d.w,name:d.name},d.value)}),c}return Qx}var ev,y2;function Cae(){if(y2)return ev;y2=1;var e=cr();ev=t;function t(n){var r={},s=[],o;function i(c){e.has(r,c)||(r[c]=!0,o.push(c),e.each(n.successors(c),i),e.each(n.predecessors(c),i))}return e.each(n.nodes(),function(c){o=[],i(c),o.length&&s.push(o)}),s}return ev}var tv,w2;function S4(){if(w2)return tv;w2=1;var e=cr();tv=t;function t(){this._arr=[],this._keyIndices={}}return t.prototype.size=function(){return this._arr.length},t.prototype.keys=function(){return this._arr.map(function(n){return n.key})},t.prototype.has=function(n){return e.has(this._keyIndices,n)},t.prototype.priority=function(n){var r=this._keyIndices[n];if(r!==void 0)return this._arr[r].priority},t.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},t.prototype.add=function(n,r){var s=this._keyIndices;if(n=String(n),!e.has(s,n)){var o=this._arr,i=o.length;return s[n]=i,o.push({key:n,priority:r}),this._decrease(i),!0}return!1},t.prototype.removeMin=function(){this._swap(0,this._arr.length-1);var n=this._arr.pop();return delete this._keyIndices[n.key],this._heapify(0),n.key},t.prototype.decrease=function(n,r){var s=this._keyIndices[n];if(r>this._arr[s].priority)throw new Error("New priority is greater than current priority. Key: "+n+" Old: "+this._arr[s].priority+" New: "+r);this._arr[s].priority=r,this._decrease(s)},t.prototype._heapify=function(n){var r=this._arr,s=2*n,o=s+1,i=n;s<r.length&&(i=r[s].priority<r[i].priority?s:i,o<r.length&&(i=r[o].priority<r[i].priority?o:i),i!==n&&(this._swap(n,i),this._heapify(i)))},t.prototype._decrease=function(n){for(var r=this._arr,s=r[n].priority,o;n!==0&&(o=n>>1,!(r[o].priority<s));)this._swap(n,o),n=o},t.prototype._swap=function(n,r){var s=this._arr,o=this._keyIndices,i=s[n],c=s[r];s[n]=c,s[r]=i,o[c.key]=n,o[i.key]=r},tv}var nv,x2;function _4(){if(x2)return nv;x2=1;var e=cr(),t=S4();nv=r;var n=e.constant(1);function r(o,i,c,d){return s(o,String(i),c||n,d||function(h){return o.outEdges(h)})}function s(o,i,c,d){var h={},f=new t,p,g,w=function(k){var j=k.v!==p?k.v:k.w,v=h[j],b=c(k),N=g.distance+b;if(b<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+k+" Weight: "+b);N<v.distance&&(v.distance=N,v.predecessor=p,f.decrease(j,N))};for(o.nodes().forEach(function(k){var j=k===i?0:Number.POSITIVE_INFINITY;h[k]={distance:j},f.add(k,j)});f.size()>0&&(p=f.removeMin(),g=h[p],g.distance!==Number.POSITIVE_INFINITY);)d(p).forEach(w);return h}return nv}var rv,v2;function Tae(){if(v2)return rv;v2=1;var e=_4(),t=cr();rv=n;function n(r,s,o){return t.transform(r.nodes(),function(i,c){i[c]=e(r,c,s,o)},{})}return rv}var sv,b2;function E4(){if(b2)return sv;b2=1;var e=cr();sv=t;function t(n){var r=0,s=[],o={},i=[];function c(d){var h=o[d]={onStack:!0,lowlink:r,index:r++};if(s.push(d),n.successors(d).forEach(function(g){e.has(o,g)?o[g].onStack&&(h.lowlink=Math.min(h.lowlink,o[g].index)):(c(g),h.lowlink=Math.min(h.lowlink,o[g].lowlink))}),h.lowlink===h.index){var f=[],p;do p=s.pop(),o[p].onStack=!1,f.push(p);while(d!==p);i.push(f)}}return n.nodes().forEach(function(d){e.has(o,d)||c(d)}),i}return sv}var av,k2;function Rae(){if(k2)return av;k2=1;var e=cr(),t=E4();av=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 av}var ov,j2;function Aae(){if(j2)return ov;j2=1;var e=cr();ov=n;var t=e.constant(1);function n(s,o,i){return r(s,o||t,i||function(c){return s.outEdges(c)})}function r(s,o,i){var c={},d=s.nodes();return d.forEach(function(h){c[h]={},c[h][h]={distance:0},d.forEach(function(f){h!==f&&(c[h][f]={distance:Number.POSITIVE_INFINITY})}),i(h).forEach(function(f){var p=f.v===h?f.w:f.v,g=o(f);c[h][p]={distance:g,predecessor:h}})}),d.forEach(function(h){var f=c[h];d.forEach(function(p){var g=c[p];d.forEach(function(w){var k=g[h],j=f[w],v=g[w],b=k.distance+j.distance;b<v.distance&&(v.distance=b,v.predecessor=j.predecessor)})})}),c}return ov}var iv,N2;function C4(){if(N2)return iv;N2=1;var e=cr();iv=t,t.CycleException=n;function t(r){var s={},o={},i=[];function c(d){if(e.has(o,d))throw new n;e.has(s,d)||(o[d]=!0,s[d]=!0,e.each(r.predecessors(d),c),delete o[d],i.push(d))}if(e.each(r.sinks(),c),e.size(s)!==r.nodeCount())throw new n;return i}function n(){}return n.prototype=new Error,iv}var lv,S2;function Mae(){if(S2)return lv;S2=1;var e=C4();lv=t;function t(n){try{e(n)}catch(r){if(r instanceof e.CycleException)return!1;throw r}return!0}return lv}var cv,_2;function T4(){if(_2)return cv;_2=1;var e=cr();cv=t;function t(r,s,o){e.isArray(s)||(s=[s]);var i=(r.isDirected()?r.successors:r.neighbors).bind(r),c=[],d={};return e.each(s,function(h){if(!r.hasNode(h))throw new Error("Graph does not have node: "+h);n(r,h,o==="post",d,i,c)}),c}function n(r,s,o,i,c,d){e.has(i,s)||(i[s]=!0,o||d.push(s),e.each(c(s),function(h){n(r,h,o,i,c,d)}),o&&d.push(s))}return cv}var uv,E2;function $ae(){if(E2)return uv;E2=1;var e=T4();uv=t;function t(n,r){return e(n,r,"post")}return uv}var dv,C2;function Lae(){if(C2)return dv;C2=1;var e=T4();dv=t;function t(n,r){return e(n,r,"pre")}return dv}var hv,T2;function Oae(){if(T2)return hv;T2=1;var e=cr(),t=q1(),n=S4();hv=r;function r(s,o){var i=new t,c={},d=new n,h;function f(g){var w=g.v===h?g.w:g.v,k=d.priority(w);if(k!==void 0){var j=o(g);j<k&&(c[w]=h,d.decrease(w,j))}}if(s.nodeCount()===0)return i;e.each(s.nodes(),function(g){d.add(g,Number.POSITIVE_INFINITY),i.setNode(g)}),d.decrease(s.nodes()[0],0);for(var p=!1;d.size()>0;){if(h=d.removeMin(),e.has(c,h))i.setEdge(h,c[h]);else{if(p)throw new Error("Input graph is not connected: "+s);p=!0}s.nodeEdges(h).forEach(f)}return i}return hv}var fv,R2;function Iae(){return R2||(R2=1,fv={components:Cae(),dijkstra:_4(),dijkstraAll:Tae(),findCycles:Rae(),floydWarshall:Aae(),isAcyclic:Mae(),postorder:$ae(),preorder:Lae(),prim:Oae(),tarjan:E4(),topsort:C4()}),fv}var pv,A2;function Pae(){if(A2)return pv;A2=1;var e=_ae();return pv={Graph:e.Graph,json:Eae(),alg:Iae(),version:e.version},pv}var mv,M2;function Rr(){if(M2)return mv;M2=1;var e;if(typeof S1=="function")try{e=Pae()}catch{}return e||(e=window.graphlib),mv=e,mv}var gv,$2;function Dae(){if($2)return gv;$2=1;var e=e4(),t=1,n=4;function r(s){return e(s,t|n)}return gv=r,gv}var yv,L2;function Yf(){if(L2)return yv;L2=1;var e=rl(),t=Is(),n=Bf(),r=lr();function s(o,i,c){if(!r(c))return!1;var d=typeof i;return(d=="number"?t(c)&&n(i,c.length):d=="string"&&i in c)?e(c[i],o):!1}return yv=s,yv}var wv,O2;function Fae(){if(O2)return wv;O2=1;var e=Kf(),t=rl(),n=Yf(),r=Oo(),s=Object.prototype,o=s.hasOwnProperty,i=e(function(c,d){c=Object(c);var h=-1,f=d.length,p=f>2?d[2]:void 0;for(p&&n(d[0],d[1],p)&&(f=1);++h<f;)for(var g=d[h],w=r(g),k=-1,j=w.length;++k<j;){var v=w[k],b=c[v];(b===void 0||t(b,s[v])&&!o.call(c,v))&&(c[v]=g[v])}return c});return wv=i,wv}var xv,I2;function Bae(){if(I2)return xv;I2=1;var e=Ps(),t=Is(),n=Aa();function r(s){return function(o,i,c){var d=Object(o);if(!t(o)){var h=e(i,3);o=n(o),i=function(p){return h(d[p],p,d)}}var f=s(o,i,c);return f>-1?d[h?o[f]:f]:void 0}}return xv=r,xv}var vv,P2;function qae(){if(P2)return vv;P2=1;var e=/\s/;function t(n){for(var r=n.length;r--&&e.test(n.charAt(r)););return r}return vv=t,vv}var bv,D2;function Uae(){if(D2)return bv;D2=1;var e=qae(),t=/^\s+/;function n(r){return r&&r.slice(0,e(r)+1).replace(t,"")}return bv=n,bv}var kv,F2;function Hae(){if(F2)return kv;F2=1;var e=Uae(),t=lr(),n=il(),r=NaN,s=/^[-+]0x[0-9a-f]+$/i,o=/^0b[01]+$/i,i=/^0o[0-7]+$/i,c=parseInt;function d(h){if(typeof h=="number")return h;if(n(h))return r;if(t(h)){var f=typeof h.valueOf=="function"?h.valueOf():h;h=t(f)?f+"":f}if(typeof h!="string")return h===0?h:+h;h=e(h);var p=o.test(h);return p||i.test(h)?c(h.slice(2),p?2:8):s.test(h)?r:+h}return kv=d,kv}var jv,B2;function R4(){if(B2)return jv;B2=1;var e=Hae(),t=1/0,n=17976931348623157e292;function r(s){if(!s)return s===0?s:0;if(s=e(s),s===t||s===-t){var o=s<0?-1:1;return o*n}return s===s?s:0}return jv=r,jv}var Nv,q2;function Wae(){if(q2)return Nv;q2=1;var e=R4();function t(n){var r=e(n),s=r%1;return r===r?s?r-s:r:0}return Nv=t,Nv}var Sv,U2;function zae(){if(U2)return Sv;U2=1;var e=k4(),t=Ps(),n=Wae(),r=Math.max;function s(o,i,c){var d=o==null?0:o.length;if(!d)return-1;var h=c==null?0:n(c);return h<0&&(h=r(d+h,0)),e(o,t(i,3),h)}return Sv=s,Sv}var _v,H2;function Vae(){if(H2)return _v;H2=1;var e=Bae(),t=zae(),n=e(t);return _v=n,_v}var Ev,W2;function A4(){if(W2)return Ev;W2=1;var e=B1();function t(n){var r=n==null?0:n.length;return r?e(n,1):[]}return Ev=t,Ev}var Cv,z2;function Gae(){if(z2)return Cv;z2=1;var e=I1(),t=t4(),n=Oo();function r(s,o){return s==null?s:e(s,t(o),n)}return Cv=r,Cv}var Tv,V2;function Kae(){if(V2)return Tv;V2=1;function e(t){var n=t==null?0:t.length;return n?t[n-1]:void 0}return Tv=e,Tv}var Rv,G2;function Yae(){if(G2)return Rv;G2=1;var e=Df(),t=P1(),n=Ps();function r(s,o){var i={};return o=n(o,3),t(s,function(c,d,h){e(i,d,o(c,d,h))}),i}return Rv=r,Rv}var Av,K2;function U1(){if(K2)return Av;K2=1;var e=il();function t(n,r,s){for(var o=-1,i=n.length;++o<i;){var c=n[o],d=r(c);if(d!=null&&(h===void 0?d===d&&!e(d):s(d,h)))var h=d,f=c}return f}return Av=t,Av}var Mv,Y2;function Xae(){if(Y2)return Mv;Y2=1;function e(t,n){return t>n}return Mv=e,Mv}var $v,X2;function Zae(){if(X2)return $v;X2=1;var e=U1(),t=Xae(),n=Io();function r(s){return s&&s.length?e(s,n,t):void 0}return $v=r,$v}var Lv,Z2;function M4(){if(Z2)return Lv;Z2=1;var e=Df(),t=rl();function n(r,s,o){(o!==void 0&&!t(r[s],o)||o===void 0&&!(s in r))&&e(r,s,o)}return Lv=n,Lv}var Ov,J2;function Jae(){if(J2)return Ov;J2=1;var e=$o(),t=Hf(),n=os(),r="[object Object]",s=Function.prototype,o=Object.prototype,i=s.toString,c=o.hasOwnProperty,d=i.call(Object);function h(f){if(!n(f)||e(f)!=r)return!1;var p=t(f);if(p===null)return!0;var g=c.call(p,"constructor")&&p.constructor;return typeof g=="function"&&g instanceof g&&i.call(g)==d}return Ov=h,Ov}var Iv,Q2;function $4(){if(Q2)return Iv;Q2=1;function e(t,n){if(!(n==="constructor"&&typeof t[n]=="function")&&n!="__proto__")return t[n]}return Iv=e,Iv}var Pv,eM;function Qae(){if(eM)return Pv;eM=1;var e=ru(),t=Oo();function n(r){return e(r,t(r))}return Pv=n,Pv}var Dv,tM;function eoe(){if(tM)return Dv;tM=1;var e=M4(),t=UP(),n=ZP(),r=HP(),s=QP(),o=su(),i=Ot(),c=j4(),d=al(),h=nu(),f=lr(),p=Jae(),g=au(),w=$4(),k=Qae();function j(v,b,N,S,E,C,$){var T=w(v,N),I=w(b,N),O=$.get(I);if(O){e(v,N,O);return}var U=C?C(T,I,N+"",v,b,$):void 0,P=U===void 0;if(P){var L=i(I),F=!L&&d(I),A=!L&&!F&&g(I);U=I,L||F||A?i(T)?U=T:c(T)?U=r(T):F?(P=!1,U=t(I,!0)):A?(P=!1,U=n(I,!0)):U=[]:p(I)||o(I)?(U=T,o(T)?U=k(T):(!f(T)||h(T))&&(U=s(I))):P=!1}P&&($.set(I,U),E(U,I,S,C,$),$.delete(I)),e(v,N,U)}return Dv=j,Dv}var Fv,nM;function toe(){if(nM)return Fv;nM=1;var e=Pf(),t=M4(),n=I1(),r=eoe(),s=lr(),o=Oo(),i=$4();function c(d,h,f,p,g){d!==h&&n(h,function(w,k){if(g||(g=new e),s(w))r(d,h,k,f,c,p,g);else{var j=p?p(i(d,k),w,k+"",d,h,g):void 0;j===void 0&&(j=w),t(d,k,j)}},o)}return Fv=c,Fv}var Bv,rM;function noe(){if(rM)return Bv;rM=1;var e=Kf(),t=Yf();function n(r){return e(function(s,o){var i=-1,c=o.length,d=c>1?o[c-1]:void 0,h=c>2?o[2]:void 0;for(d=r.length>3&&typeof d=="function"?(c--,d):void 0,h&&t(o[0],o[1],h)&&(d=c<3?void 0:d,c=1),s=Object(s);++i<c;){var f=o[i];f&&r(s,f,i,d)}return s})}return Bv=n,Bv}var qv,sM;function roe(){if(sM)return qv;sM=1;var e=toe(),t=noe(),n=t(function(r,s,o){e(r,s,o)});return qv=n,qv}var Uv,aM;function L4(){if(aM)return Uv;aM=1;function e(t,n){return t<n}return Uv=e,Uv}var Hv,oM;function soe(){if(oM)return Hv;oM=1;var e=U1(),t=L4(),n=Io();function r(s){return s&&s.length?e(s,n,t):void 0}return Hv=r,Hv}var Wv,iM;function aoe(){if(iM)return Wv;iM=1;var e=U1(),t=Ps(),n=L4();function r(s,o){return s&&s.length?e(s,t(o,2),n):void 0}return Wv=r,Wv}var zv,lM;function ooe(){if(lM)return zv;lM=1;var e=Mr(),t=function(){return e.Date.now()};return zv=t,zv}var Vv,cM;function ioe(){if(cM)return Vv;cM=1;var e=Ff(),t=Vf(),n=Bf(),r=lr(),s=ou();function o(i,c,d,h){if(!r(i))return i;c=t(c,i);for(var f=-1,p=c.length,g=p-1,w=i;w!=null&&++f<p;){var k=s(c[f]),j=d;if(k==="__proto__"||k==="constructor"||k==="prototype")return i;if(f!=g){var v=w[k];j=h?h(v,k,w):void 0,j===void 0&&(j=r(v)?v:n(c[f+1])?[]:{})}e(w,k,j),w=w[k]}return i}return Vv=o,Vv}var Gv,uM;function loe(){if(uM)return Gv;uM=1;var e=Gf(),t=ioe(),n=Vf();function r(s,o,i){for(var c=-1,d=o.length,h={};++c<d;){var f=o[c],p=e(s,f);i(p,f)&&t(h,n(f,s),p)}return h}return Gv=r,Gv}var Kv,dM;function coe(){if(dM)return Kv;dM=1;var e=loe(),t=h4();function n(r,s){return e(r,s,function(o,i){return t(r,i)})}return Kv=n,Kv}var Yv,hM;function uoe(){if(hM)return Yv;hM=1;var e=A4(),t=v4(),n=b4();function r(s){return n(t(s,void 0,e),s+"")}return Yv=r,Yv}var Xv,fM;function doe(){if(fM)return Xv;fM=1;var e=coe(),t=uoe(),n=t(function(r,s){return r==null?{}:e(r,s)});return Xv=n,Xv}var Zv,pM;function hoe(){if(pM)return Zv;pM=1;var e=Math.ceil,t=Math.max;function n(r,s,o,i){for(var c=-1,d=t(e((s-r)/(o||1)),0),h=Array(d);d--;)h[i?d:++c]=r,r+=o;return h}return Zv=n,Zv}var Jv,mM;function foe(){if(mM)return Jv;mM=1;var e=hoe(),t=Yf(),n=R4();function r(s){return function(o,i,c){return c&&typeof c!="number"&&t(o,i,c)&&(i=c=void 0),o=n(o),i===void 0?(i=o,o=0):i=n(i),c=c===void 0?o<i?1:-1:n(c),e(o,i,c,s)}}return Jv=r,Jv}var Qv,gM;function poe(){if(gM)return Qv;gM=1;var e=foe(),t=e();return Qv=t,Qv}var eb,yM;function moe(){if(yM)return eb;yM=1;function e(t,n){var r=t.length;for(t.sort(n);r--;)t[r]=t[r].value;return t}return eb=e,eb}var tb,wM;function goe(){if(wM)return tb;wM=1;var e=il();function t(n,r){if(n!==r){var s=n!==void 0,o=n===null,i=n===n,c=e(n),d=r!==void 0,h=r===null,f=r===r,p=e(r);if(!h&&!p&&!c&&n>r||c&&d&&f&&!h&&!p||o&&d&&f||!s&&f||!i)return 1;if(!o&&!c&&!p&&n<r||p&&s&&i&&!o&&!c||h&&s&&i||!d&&i||!f)return-1}return 0}return tb=t,tb}var nb,xM;function yoe(){if(xM)return nb;xM=1;var e=goe();function t(n,r,s){for(var o=-1,i=n.criteria,c=r.criteria,d=i.length,h=s.length;++o<d;){var f=e(i[o],c[o]);if(f){if(o>=h)return f;var p=s[o];return f*(p=="desc"?-1:1)}}return n.index-r.index}return nb=t,nb}var rb,vM;function woe(){if(vM)return rb;vM=1;var e=zf(),t=Gf(),n=Ps(),r=y4(),s=moe(),o=qf(),i=yoe(),c=Io(),d=Ot();function h(f,p,g){p.length?p=e(p,function(j){return d(j)?function(v){return t(v,j.length===1?j[0]:j)}:j}):p=[c];var w=-1;p=e(p,o(n));var k=r(f,function(j,v,b){var N=e(p,function(S){return S(j)});return{criteria:N,index:++w,value:j}});return s(k,function(j,v){return i(j,v,g)})}return rb=h,rb}var sb,bM;function xoe(){if(bM)return sb;bM=1;var e=B1(),t=woe(),n=Kf(),r=Yf(),s=n(function(o,i){if(o==null)return[];var c=i.length;return c>1&&r(o,i[0],i[1])?i=[]:c>2&&r(i[0],i[1],i[2])&&(i=[i[0]]),t(o,e(i,1),[])});return sb=s,sb}var ab,kM;function voe(){if(kM)return ab;kM=1;var e=u4(),t=0;function n(r){var s=++t;return e(r)+s}return ab=n,ab}var ob,jM;function boe(){if(jM)return ob;jM=1;function e(t,n,r){for(var s=-1,o=t.length,i=n.length,c={};++s<o;){var d=s<i?n[s]:void 0;r(c,t[s],d)}return c}return ob=e,ob}var ib,NM;function koe(){if(NM)return ib;NM=1;var e=Ff(),t=boe();function n(r,s){return t(r||[],s||[],e)}return ib=n,ib}var lb,SM;function vt(){if(SM)return lb;SM=1;var e;if(typeof S1=="function")try{e={cloneDeep:Dae(),constant:O1(),defaults:Fae(),each:r4(),filter:p4(),find:Vae(),flatten:A4(),forEach:n4(),forIn:Gae(),has:m4(),isUndefined:g4(),last:Kae(),map:w4(),mapValues:Yae(),max:Zae(),merge:roe(),min:soe(),minBy:aoe(),now:ooe(),pick:doe(),range:poe(),reduce:x4(),sortBy:xoe(),uniqueId:voe(),values:N4(),zipObject:koe()}}catch{}return e||(e=window._),lb=e,lb}var cb,_M;function joe(){if(_M)return cb;_M=1,cb=e;function e(){var r={};r._next=r._prev=r,this._sentinel=r}e.prototype.dequeue=function(){var r=this._sentinel,s=r._prev;if(s!==r)return t(s),s},e.prototype.enqueue=function(r){var s=this._sentinel;r._prev&&r._next&&t(r),r._next=s._next,s._next._prev=r,s._next=r,r._prev=s},e.prototype.toString=function(){for(var r=[],s=this._sentinel,o=s._prev;o!==s;)r.push(JSON.stringify(o,n)),o=o._prev;return"["+r.join(", ")+"]"};function t(r){r._prev._next=r._next,r._next._prev=r._prev,delete r._next,delete r._prev}function n(r,s){if(r!=="_next"&&r!=="_prev")return s}return cb}var ub,EM;function Noe(){if(EM)return ub;EM=1;var e=vt(),t=Rr().Graph,n=joe();ub=s;var r=e.constant(1);function s(h,f){if(h.nodeCount()<=1)return[];var p=c(h,f||r),g=o(p.graph,p.buckets,p.zeroIdx);return e.flatten(e.map(g,function(w){return h.outEdges(w.v,w.w)}),!0)}function o(h,f,p){for(var g=[],w=f[f.length-1],k=f[0],j;h.nodeCount();){for(;j=k.dequeue();)i(h,f,p,j);for(;j=w.dequeue();)i(h,f,p,j);if(h.nodeCount()){for(var v=f.length-2;v>0;--v)if(j=f[v].dequeue(),j){g=g.concat(i(h,f,p,j,!0));break}}}return g}function i(h,f,p,g,w){var k=w?[]:void 0;return e.forEach(h.inEdges(g.v),function(j){var v=h.edge(j),b=h.node(j.v);w&&k.push({v:j.v,w:j.w}),b.out-=v,d(f,p,b)}),e.forEach(h.outEdges(g.v),function(j){var v=h.edge(j),b=j.w,N=h.node(b);N.in-=v,d(f,p,N)}),h.removeNode(g.v),k}function c(h,f){var p=new t,g=0,w=0;e.forEach(h.nodes(),function(v){p.setNode(v,{v,in:0,out:0})}),e.forEach(h.edges(),function(v){var b=p.edge(v.v,v.w)||0,N=f(v),S=b+N;p.setEdge(v.v,v.w,S),w=Math.max(w,p.node(v.v).out+=N),g=Math.max(g,p.node(v.w).in+=N)});var k=e.range(w+g+3).map(function(){return new n}),j=g+1;return e.forEach(p.nodes(),function(v){d(k,j,p.node(v))}),{graph:p,buckets:k,zeroIdx:j}}function d(h,f,p){p.out?p.in?h[p.out-p.in+f].enqueue(p):h[h.length-1].enqueue(p):h[0].enqueue(p)}return ub}var db,CM;function Soe(){if(CM)return db;CM=1;var e=vt(),t=Noe();db={run:n,undo:s};function n(o){var i=o.graph().acyclicer==="greedy"?t(o,c(o)):r(o);e.forEach(i,function(d){var h=o.edge(d);o.removeEdge(d),h.forwardName=d.name,h.reversed=!0,o.setEdge(d.w,d.v,h,e.uniqueId("rev"))});function c(d){return function(h){return d.edge(h).weight}}}function r(o){var i=[],c={},d={};function h(f){e.has(d,f)||(d[f]=!0,c[f]=!0,e.forEach(o.outEdges(f),function(p){e.has(c,p.w)?i.push(p):h(p.w)}),delete c[f])}return e.forEach(o.nodes(),h),i}function s(o){e.forEach(o.edges(),function(i){var c=o.edge(i);if(c.reversed){o.removeEdge(i);var d=c.forwardName;delete c.reversed,delete c.forwardName,o.setEdge(i.w,i.v,c,d)}})}return db}var hb,TM;function _n(){if(TM)return hb;TM=1;var e=vt(),t=Rr().Graph;hb={addDummyNode:n,simplify:r,asNonCompoundGraph:s,successorWeights:o,predecessorWeights:i,intersectRect:c,buildLayerMatrix:d,normalizeRanks:h,removeEmptyRanks:f,addBorderNode:p,maxRank:g,partition:w,time:k,notime:j};function n(v,b,N,S){var E;do E=e.uniqueId(S);while(v.hasNode(E));return N.dummy=b,v.setNode(E,N),E}function r(v){var b=new t().setGraph(v.graph());return e.forEach(v.nodes(),function(N){b.setNode(N,v.node(N))}),e.forEach(v.edges(),function(N){var S=b.edge(N.v,N.w)||{weight:0,minlen:1},E=v.edge(N);b.setEdge(N.v,N.w,{weight:S.weight+E.weight,minlen:Math.max(S.minlen,E.minlen)})}),b}function s(v){var b=new t({multigraph:v.isMultigraph()}).setGraph(v.graph());return e.forEach(v.nodes(),function(N){v.children(N).length||b.setNode(N,v.node(N))}),e.forEach(v.edges(),function(N){b.setEdge(N,v.edge(N))}),b}function o(v){var b=e.map(v.nodes(),function(N){var S={};return e.forEach(v.outEdges(N),function(E){S[E.w]=(S[E.w]||0)+v.edge(E).weight}),S});return e.zipObject(v.nodes(),b)}function i(v){var b=e.map(v.nodes(),function(N){var S={};return e.forEach(v.inEdges(N),function(E){S[E.v]=(S[E.v]||0)+v.edge(E).weight}),S});return e.zipObject(v.nodes(),b)}function c(v,b){var N=v.x,S=v.y,E=b.x-N,C=b.y-S,$=v.width/2,T=v.height/2;if(!E&&!C)throw new Error("Not possible to find intersection inside of the rectangle");var I,O;return Math.abs(C)*$>Math.abs(E)*T?(C<0&&(T=-T),I=T*E/C,O=T):(E<0&&($=-$),I=$,O=$*C/E),{x:N+I,y:S+O}}function d(v){var b=e.map(e.range(g(v)+1),function(){return[]});return e.forEach(v.nodes(),function(N){var S=v.node(N),E=S.rank;e.isUndefined(E)||(b[E][S.order]=N)}),b}function h(v){var b=e.min(e.map(v.nodes(),function(N){return v.node(N).rank}));e.forEach(v.nodes(),function(N){var S=v.node(N);e.has(S,"rank")&&(S.rank-=b)})}function f(v){var b=e.min(e.map(v.nodes(),function(C){return v.node(C).rank})),N=[];e.forEach(v.nodes(),function(C){var $=v.node(C).rank-b;N[$]||(N[$]=[]),N[$].push(C)});var S=0,E=v.graph().nodeRankFactor;e.forEach(N,function(C,$){e.isUndefined(C)&&$%E!==0?--S:S&&e.forEach(C,function(T){v.node(T).rank+=S})})}function p(v,b,N,S){var E={width:0,height:0};return arguments.length>=4&&(E.rank=N,E.order=S),n(v,"border",E,b)}function g(v){return e.max(e.map(v.nodes(),function(b){var N=v.node(b).rank;if(!e.isUndefined(N))return N}))}function w(v,b){var N={lhs:[],rhs:[]};return e.forEach(v,function(S){b(S)?N.lhs.push(S):N.rhs.push(S)}),N}function k(v,b){var N=e.now();try{return b()}finally{console.log(v+" time: "+(e.now()-N)+"ms")}}function j(v,b){return b()}return hb}var fb,RM;function _oe(){if(RM)return fb;RM=1;var e=vt(),t=_n();fb={run:n,undo:s};function n(o){o.graph().dummyChains=[],e.forEach(o.edges(),function(i){r(o,i)})}function r(o,i){var c=i.v,d=o.node(c).rank,h=i.w,f=o.node(h).rank,p=i.name,g=o.edge(i),w=g.labelRank;if(f!==d+1){o.removeEdge(i);var k,j,v;for(v=0,++d;d<f;++v,++d)g.points=[],j={width:0,height:0,edgeLabel:g,edgeObj:i,rank:d},k=t.addDummyNode(o,"edge",j,"_d"),d===w&&(j.width=g.width,j.height=g.height,j.dummy="edge-label",j.labelpos=g.labelpos),o.setEdge(c,k,{weight:g.weight},p),v===0&&o.graph().dummyChains.push(k),c=k;o.setEdge(c,h,{weight:g.weight},p)}}function s(o){e.forEach(o.graph().dummyChains,function(i){var c=o.node(i),d=c.edgeLabel,h;for(o.setEdge(c.edgeObj,d);c.dummy;)h=o.successors(i)[0],o.removeNode(i),d.points.push({x:c.x,y:c.y}),c.dummy==="edge-label"&&(d.x=c.x,d.y=c.y,d.width=c.width,d.height=c.height),i=h,c=o.node(i)})}return fb}var pb,AM;function Bh(){if(AM)return pb;AM=1;var e=vt();pb={longestPath:t,slack:n};function t(r){var s={};function o(i){var c=r.node(i);if(e.has(s,i))return c.rank;s[i]=!0;var d=e.min(e.map(r.outEdges(i),function(h){return o(h.w)-r.edge(h).minlen}));return(d===Number.POSITIVE_INFINITY||d===void 0||d===null)&&(d=0),c.rank=d}e.forEach(r.sources(),o)}function n(r,s){return r.node(s.w).rank-r.node(s.v).rank-r.edge(s).minlen}return pb}var mb,MM;function O4(){if(MM)return mb;MM=1;var e=vt(),t=Rr().Graph,n=Bh().slack;mb=r;function r(c){var d=new t({directed:!1}),h=c.nodes()[0],f=c.nodeCount();d.setNode(h,{});for(var p,g;s(d,c)<f;)p=o(d,c),g=d.hasNode(p.v)?n(c,p):-n(c,p),i(d,c,g);return d}function s(c,d){function h(f){e.forEach(d.nodeEdges(f),function(p){var g=p.v,w=f===g?p.w:g;!c.hasNode(w)&&!n(d,p)&&(c.setNode(w,{}),c.setEdge(f,w,{}),h(w))})}return e.forEach(c.nodes(),h),c.nodeCount()}function o(c,d){return e.minBy(d.edges(),function(h){if(c.hasNode(h.v)!==c.hasNode(h.w))return n(d,h)})}function i(c,d,h){e.forEach(c.nodes(),function(f){d.node(f).rank+=h})}return mb}var gb,$M;function Eoe(){if($M)return gb;$M=1;var e=vt(),t=O4(),n=Bh().slack,r=Bh().longestPath,s=Rr().alg.preorder,o=Rr().alg.postorder,i=_n().simplify;gb=c,c.initLowLimValues=p,c.initCutValues=d,c.calcCutValue=f,c.leaveEdge=w,c.enterEdge=k,c.exchangeEdges=j;function c(S){S=i(S),r(S);var E=t(S);p(E),d(E,S);for(var C,$;C=w(E);)$=k(E,S,C),j(E,S,C,$)}function d(S,E){var C=o(S,S.nodes());C=C.slice(0,C.length-1),e.forEach(C,function($){h(S,E,$)})}function h(S,E,C){var $=S.node(C),T=$.parent;S.edge(C,T).cutvalue=f(S,E,C)}function f(S,E,C){var $=S.node(C),T=$.parent,I=!0,O=E.edge(C,T),U=0;return O||(I=!1,O=E.edge(T,C)),U=O.weight,e.forEach(E.nodeEdges(C),function(P){var L=P.v===C,F=L?P.w:P.v;if(F!==T){var A=L===I,B=E.edge(P).weight;if(U+=A?B:-B,b(S,C,F)){var D=S.edge(C,F).cutvalue;U+=A?-D:D}}}),U}function p(S,E){arguments.length<2&&(E=S.nodes()[0]),g(S,{},1,E)}function g(S,E,C,$,T){var I=C,O=S.node($);return E[$]=!0,e.forEach(S.neighbors($),function(U){e.has(E,U)||(C=g(S,E,C,U,$))}),O.low=I,O.lim=C++,T?O.parent=T:delete O.parent,C}function w(S){return e.find(S.edges(),function(E){return S.edge(E).cutvalue<0})}function k(S,E,C){var $=C.v,T=C.w;E.hasEdge($,T)||($=C.w,T=C.v);var I=S.node($),O=S.node(T),U=I,P=!1;I.lim>O.lim&&(U=O,P=!0);var L=e.filter(E.edges(),function(F){return P===N(S,S.node(F.v),U)&&P!==N(S,S.node(F.w),U)});return e.minBy(L,function(F){return n(E,F)})}function j(S,E,C,$){var T=C.v,I=C.w;S.removeEdge(T,I),S.setEdge($.v,$.w,{}),p(S),d(S,E),v(S,E)}function v(S,E){var C=e.find(S.nodes(),function(T){return!E.node(T).parent}),$=s(S,C);$=$.slice(1),e.forEach($,function(T){var I=S.node(T).parent,O=E.edge(T,I),U=!1;O||(O=E.edge(I,T),U=!0),E.node(T).rank=E.node(I).rank+(U?O.minlen:-O.minlen)})}function b(S,E,C){return S.hasEdge(E,C)}function N(S,E,C){return C.low<=E.lim&&E.lim<=C.lim}return gb}var yb,LM;function Coe(){if(LM)return yb;LM=1;var e=Bh(),t=e.longestPath,n=O4(),r=Eoe();yb=s;function s(d){switch(d.graph().ranker){case"network-simplex":c(d);break;case"tight-tree":i(d);break;case"longest-path":o(d);break;default:c(d)}}var o=t;function i(d){t(d),n(d)}function c(d){r(d)}return yb}var wb,OM;function Toe(){if(OM)return wb;OM=1;var e=vt();wb=t;function t(s){var o=r(s);e.forEach(s.graph().dummyChains,function(i){for(var c=s.node(i),d=c.edgeObj,h=n(s,o,d.v,d.w),f=h.path,p=h.lca,g=0,w=f[g],k=!0;i!==d.w;){if(c=s.node(i),k){for(;(w=f[g])!==p&&s.node(w).maxRank<c.rank;)g++;w===p&&(k=!1)}if(!k){for(;g<f.length-1&&s.node(w=f[g+1]).minRank<=c.rank;)g++;w=f[g]}s.setParent(i,w),i=s.successors(i)[0]}})}function n(s,o,i,c){var d=[],h=[],f=Math.min(o[i].low,o[c].low),p=Math.max(o[i].lim,o[c].lim),g,w;g=i;do g=s.parent(g),d.push(g);while(g&&(o[g].low>f||p>o[g].lim));for(w=g,g=c;(g=s.parent(g))!==w;)h.push(g);return{path:d.concat(h.reverse()),lca:w}}function r(s){var o={},i=0;function c(d){var h=i;e.forEach(s.children(d),c),o[d]={low:h,lim:i++}}return e.forEach(s.children(),c),o}return wb}var xb,IM;function Roe(){if(IM)return xb;IM=1;var e=vt(),t=_n();xb={run:n,cleanup:i};function n(c){var d=t.addDummyNode(c,"root",{},"_root"),h=s(c),f=e.max(e.values(h))-1,p=2*f+1;c.graph().nestingRoot=d,e.forEach(c.edges(),function(w){c.edge(w).minlen*=p});var g=o(c)+1;e.forEach(c.children(),function(w){r(c,d,p,g,f,h,w)}),c.graph().nodeRankFactor=p}function r(c,d,h,f,p,g,w){var k=c.children(w);if(!k.length){w!==d&&c.setEdge(d,w,{weight:0,minlen:h});return}var j=t.addBorderNode(c,"_bt"),v=t.addBorderNode(c,"_bb"),b=c.node(w);c.setParent(j,w),b.borderTop=j,c.setParent(v,w),b.borderBottom=v,e.forEach(k,function(N){r(c,d,h,f,p,g,N);var S=c.node(N),E=S.borderTop?S.borderTop:N,C=S.borderBottom?S.borderBottom:N,$=S.borderTop?f:2*f,T=E!==C?1:p-g[w]+1;c.setEdge(j,E,{weight:$,minlen:T,nestingEdge:!0}),c.setEdge(C,v,{weight:$,minlen:T,nestingEdge:!0})}),c.parent(w)||c.setEdge(d,j,{weight:0,minlen:p+g[w]})}function s(c){var d={};function h(f,p){var g=c.children(f);g&&g.length&&e.forEach(g,function(w){h(w,p+1)}),d[f]=p}return e.forEach(c.children(),function(f){h(f,1)}),d}function o(c){return e.reduce(c.edges(),function(d,h){return d+c.edge(h).weight},0)}function i(c){var d=c.graph();c.removeNode(d.nestingRoot),delete d.nestingRoot,e.forEach(c.edges(),function(h){var f=c.edge(h);f.nestingEdge&&c.removeEdge(h)})}return xb}var vb,PM;function Aoe(){if(PM)return vb;PM=1;var e=vt(),t=_n();vb=n;function n(s){function o(i){var c=s.children(i),d=s.node(i);if(c.length&&e.forEach(c,o),e.has(d,"minRank")){d.borderLeft=[],d.borderRight=[];for(var h=d.minRank,f=d.maxRank+1;h<f;++h)r(s,"borderLeft","_bl",i,d,h),r(s,"borderRight","_br",i,d,h)}}e.forEach(s.children(),o)}function r(s,o,i,c,d,h){var f={width:0,height:0,rank:h,borderType:o},p=d[o][h-1],g=t.addDummyNode(s,"border",f,i);d[o][h]=g,s.setParent(g,c),p&&s.setEdge(p,g,{weight:1})}return vb}var bb,DM;function Moe(){if(DM)return bb;DM=1;var e=vt();bb={adjust:t,undo:n};function t(h){var f=h.graph().rankdir.toLowerCase();(f==="lr"||f==="rl")&&r(h)}function n(h){var f=h.graph().rankdir.toLowerCase();(f==="bt"||f==="rl")&&o(h),(f==="lr"||f==="rl")&&(c(h),r(h))}function r(h){e.forEach(h.nodes(),function(f){s(h.node(f))}),e.forEach(h.edges(),function(f){s(h.edge(f))})}function s(h){var f=h.width;h.width=h.height,h.height=f}function o(h){e.forEach(h.nodes(),function(f){i(h.node(f))}),e.forEach(h.edges(),function(f){var p=h.edge(f);e.forEach(p.points,i),e.has(p,"y")&&i(p)})}function i(h){h.y=-h.y}function c(h){e.forEach(h.nodes(),function(f){d(h.node(f))}),e.forEach(h.edges(),function(f){var p=h.edge(f);e.forEach(p.points,d),e.has(p,"x")&&d(p)})}function d(h){var f=h.x;h.x=h.y,h.y=f}return bb}var kb,FM;function $oe(){if(FM)return kb;FM=1;var e=vt();kb=t;function t(n){var r={},s=e.filter(n.nodes(),function(h){return!n.children(h).length}),o=e.max(e.map(s,function(h){return n.node(h).rank})),i=e.map(e.range(o+1),function(){return[]});function c(h){if(!e.has(r,h)){r[h]=!0;var f=n.node(h);i[f.rank].push(h),e.forEach(n.successors(h),c)}}var d=e.sortBy(s,function(h){return n.node(h).rank});return e.forEach(d,c),i}return kb}var jb,BM;function Loe(){if(BM)return jb;BM=1;var e=vt();jb=t;function t(r,s){for(var o=0,i=1;i<s.length;++i)o+=n(r,s[i-1],s[i]);return o}function n(r,s,o){for(var i=e.zipObject(o,e.map(o,function(g,w){return w})),c=e.flatten(e.map(s,function(g){return e.sortBy(e.map(r.outEdges(g),function(w){return{pos:i[w.w],weight:r.edge(w).weight}}),"pos")}),!0),d=1;d<o.length;)d<<=1;var h=2*d-1;d-=1;var f=e.map(new Array(h),function(){return 0}),p=0;return e.forEach(c.forEach(function(g){var w=g.pos+d;f[w]+=g.weight;for(var k=0;w>0;)w%2&&(k+=f[w+1]),w=w-1>>1,f[w]+=g.weight;p+=g.weight*k})),p}return jb}var Nb,qM;function Ooe(){if(qM)return Nb;qM=1;var e=vt();Nb=t;function t(n,r){return e.map(r,function(s){var o=n.inEdges(s);if(o.length){var i=e.reduce(o,function(c,d){var h=n.edge(d),f=n.node(d.v);return{sum:c.sum+h.weight*f.order,weight:c.weight+h.weight}},{sum:0,weight:0});return{v:s,barycenter:i.sum/i.weight,weight:i.weight}}else return{v:s}})}return Nb}var Sb,UM;function Ioe(){if(UM)return Sb;UM=1;var e=vt();Sb=t;function t(s,o){var i={};e.forEach(s,function(d,h){var f=i[d.v]={indegree:0,in:[],out:[],vs:[d.v],i:h};e.isUndefined(d.barycenter)||(f.barycenter=d.barycenter,f.weight=d.weight)}),e.forEach(o.edges(),function(d){var h=i[d.v],f=i[d.w];!e.isUndefined(h)&&!e.isUndefined(f)&&(f.indegree++,h.out.push(i[d.w]))});var c=e.filter(i,function(d){return!d.indegree});return n(c)}function n(s){var o=[];function i(h){return function(f){f.merged||(e.isUndefined(f.barycenter)||e.isUndefined(h.barycenter)||f.barycenter>=h.barycenter)&&r(h,f)}}function c(h){return function(f){f.in.push(h),--f.indegree===0&&s.push(f)}}for(;s.length;){var d=s.pop();o.push(d),e.forEach(d.in.reverse(),i(d)),e.forEach(d.out,c(d))}return e.map(e.filter(o,function(h){return!h.merged}),function(h){return e.pick(h,["vs","i","barycenter","weight"])})}function r(s,o){var i=0,c=0;s.weight&&(i+=s.barycenter*s.weight,c+=s.weight),o.weight&&(i+=o.barycenter*o.weight,c+=o.weight),s.vs=o.vs.concat(s.vs),s.barycenter=i/c,s.weight=c,s.i=Math.min(o.i,s.i),o.merged=!0}return Sb}var _b,HM;function Poe(){if(HM)return _b;HM=1;var e=vt(),t=_n();_b=n;function n(o,i){var c=t.partition(o,function(j){return e.has(j,"barycenter")}),d=c.lhs,h=e.sortBy(c.rhs,function(j){return-j.i}),f=[],p=0,g=0,w=0;d.sort(s(!!i)),w=r(f,h,w),e.forEach(d,function(j){w+=j.vs.length,f.push(j.vs),p+=j.barycenter*j.weight,g+=j.weight,w=r(f,h,w)});var k={vs:e.flatten(f,!0)};return g&&(k.barycenter=p/g,k.weight=g),k}function r(o,i,c){for(var d;i.length&&(d=e.last(i)).i<=c;)i.pop(),o.push(d.vs),c++;return c}function s(o){return function(i,c){return i.barycenter<c.barycenter?-1:i.barycenter>c.barycenter?1:o?c.i-i.i:i.i-c.i}}return _b}var Eb,WM;function Doe(){if(WM)return Eb;WM=1;var e=vt(),t=Ooe(),n=Ioe(),r=Poe();Eb=s;function s(c,d,h,f){var p=c.children(d),g=c.node(d),w=g?g.borderLeft:void 0,k=g?g.borderRight:void 0,j={};w&&(p=e.filter(p,function(C){return C!==w&&C!==k}));var v=t(c,p);e.forEach(v,function(C){if(c.children(C.v).length){var $=s(c,C.v,h,f);j[C.v]=$,e.has($,"barycenter")&&i(C,$)}});var b=n(v,h);o(b,j);var N=r(b,f);if(w&&(N.vs=e.flatten([w,N.vs,k],!0),c.predecessors(w).length)){var S=c.node(c.predecessors(w)[0]),E=c.node(c.predecessors(k)[0]);e.has(N,"barycenter")||(N.barycenter=0,N.weight=0),N.barycenter=(N.barycenter*N.weight+S.order+E.order)/(N.weight+2),N.weight+=2}return N}function o(c,d){e.forEach(c,function(h){h.vs=e.flatten(h.vs.map(function(f){return d[f]?d[f].vs:f}),!0)})}function i(c,d){e.isUndefined(c.barycenter)?(c.barycenter=d.barycenter,c.weight=d.weight):(c.barycenter=(c.barycenter*c.weight+d.barycenter*d.weight)/(c.weight+d.weight),c.weight+=d.weight)}return Eb}var Cb,zM;function Foe(){if(zM)return Cb;zM=1;var e=vt(),t=Rr().Graph;Cb=n;function n(s,o,i){var c=r(s),d=new t({compound:!0}).setGraph({root:c}).setDefaultNodeLabel(function(h){return s.node(h)});return e.forEach(s.nodes(),function(h){var f=s.node(h),p=s.parent(h);(f.rank===o||f.minRank<=o&&o<=f.maxRank)&&(d.setNode(h),d.setParent(h,p||c),e.forEach(s[i](h),function(g){var w=g.v===h?g.w:g.v,k=d.edge(w,h),j=e.isUndefined(k)?0:k.weight;d.setEdge(w,h,{weight:s.edge(g).weight+j})}),e.has(f,"minRank")&&d.setNode(h,{borderLeft:f.borderLeft[o],borderRight:f.borderRight[o]}))}),d}function r(s){for(var o;s.hasNode(o=e.uniqueId("_root")););return o}return Cb}var Tb,VM;function Boe(){if(VM)return Tb;VM=1;var e=vt();Tb=t;function t(n,r,s){var o={},i;e.forEach(s,function(c){for(var d=n.parent(c),h,f;d;){if(h=n.parent(d),h?(f=o[h],o[h]=d):(f=i,i=d),f&&f!==d){r.setEdge(f,d);return}d=h}})}return Tb}var Rb,GM;function qoe(){if(GM)return Rb;GM=1;var e=vt(),t=$oe(),n=Loe(),r=Doe(),s=Foe(),o=Boe(),i=Rr().Graph,c=_n();Rb=d;function d(g){var w=c.maxRank(g),k=h(g,e.range(1,w+1),"inEdges"),j=h(g,e.range(w-1,-1,-1),"outEdges"),v=t(g);p(g,v);for(var b=Number.POSITIVE_INFINITY,N,S=0,E=0;E<4;++S,++E){f(S%2?k:j,S%4>=2),v=c.buildLayerMatrix(g);var C=n(g,v);C<b&&(E=0,N=e.cloneDeep(v),b=C)}p(g,N)}function h(g,w,k){return e.map(w,function(j){return s(g,j,k)})}function f(g,w){var k=new i;e.forEach(g,function(j){var v=j.graph().root,b=r(j,v,k,w);e.forEach(b.vs,function(N,S){j.node(N).order=S}),o(j,k,b.vs)})}function p(g,w){e.forEach(w,function(k){e.forEach(k,function(j,v){g.node(j).order=v})})}return Rb}var Ab,KM;function Uoe(){if(KM)return Ab;KM=1;var e=vt(),t=Rr().Graph,n=_n();Ab={positionX:k,findType1Conflicts:r,findType2Conflicts:s,addConflict:i,hasConflict:c,verticalAlignment:d,horizontalCompaction:h,alignCoordinates:g,findSmallestWidthAlignment:p,balance:w};function r(b,N){var S={};function E(C,$){var T=0,I=0,O=C.length,U=e.last($);return e.forEach($,function(P,L){var F=o(b,P),A=F?b.node(F).order:O;(F||P===U)&&(e.forEach($.slice(I,L+1),function(B){e.forEach(b.predecessors(B),function(D){var K=b.node(D),G=K.order;(G<T||A<G)&&!(K.dummy&&b.node(B).dummy)&&i(S,D,B)})}),I=L+1,T=A)}),$}return e.reduce(N,E),S}function s(b,N){var S={};function E($,T,I,O,U){var P;e.forEach(e.range(T,I),function(L){P=$[L],b.node(P).dummy&&e.forEach(b.predecessors(P),function(F){var A=b.node(F);A.dummy&&(A.order<O||A.order>U)&&i(S,F,P)})})}function C($,T){var I=-1,O,U=0;return e.forEach(T,function(P,L){if(b.node(P).dummy==="border"){var F=b.predecessors(P);F.length&&(O=b.node(F[0]).order,E(T,U,L,I,O),U=L,I=O)}E(T,U,T.length,O,$.length)}),T}return e.reduce(N,C),S}function o(b,N){if(b.node(N).dummy)return e.find(b.predecessors(N),function(S){return b.node(S).dummy})}function i(b,N,S){if(N>S){var E=N;N=S,S=E}var C=b[N];C||(b[N]=C={}),C[S]=!0}function c(b,N,S){if(N>S){var E=N;N=S,S=E}return e.has(b[N],S)}function d(b,N,S,E){var C={},$={},T={};return e.forEach(N,function(I){e.forEach(I,function(O,U){C[O]=O,$[O]=O,T[O]=U})}),e.forEach(N,function(I){var O=-1;e.forEach(I,function(U){var P=E(U);if(P.length){P=e.sortBy(P,function(D){return T[D]});for(var L=(P.length-1)/2,F=Math.floor(L),A=Math.ceil(L);F<=A;++F){var B=P[F];$[U]===U&&O<T[B]&&!c(S,U,B)&&($[B]=U,$[U]=C[U]=C[B],O=T[B])}}})}),{root:C,align:$}}function h(b,N,S,E,C){var $={},T=f(b,N,S,C),I=C?"borderLeft":"borderRight";function O(L,F){for(var A=T.nodes(),B=A.pop(),D={};B;)D[B]?L(B):(D[B]=!0,A.push(B),A=A.concat(F(B))),B=A.pop()}function U(L){$[L]=T.inEdges(L).reduce(function(F,A){return Math.max(F,$[A.v]+T.edge(A))},0)}function P(L){var F=T.outEdges(L).reduce(function(B,D){return Math.min(B,$[D.w]-T.edge(D))},Number.POSITIVE_INFINITY),A=b.node(L);F!==Number.POSITIVE_INFINITY&&A.borderType!==I&&($[L]=Math.max($[L],F))}return O(U,T.predecessors.bind(T)),O(P,T.successors.bind(T)),e.forEach(E,function(L){$[L]=$[S[L]]}),$}function f(b,N,S,E){var C=new t,$=b.graph(),T=j($.nodesep,$.edgesep,E);return e.forEach(N,function(I){var O;e.forEach(I,function(U){var P=S[U];if(C.setNode(P),O){var L=S[O],F=C.edge(L,P);C.setEdge(L,P,Math.max(T(b,U,O),F||0))}O=U})}),C}function p(b,N){return e.minBy(e.values(N),function(S){var E=Number.NEGATIVE_INFINITY,C=Number.POSITIVE_INFINITY;return e.forIn(S,function($,T){var I=v(b,T)/2;E=Math.max($+I,E),C=Math.min($-I,C)}),E-C})}function g(b,N){var S=e.values(N),E=e.min(S),C=e.max(S);e.forEach(["u","d"],function($){e.forEach(["l","r"],function(T){var I=$+T,O=b[I],U;if(O!==N){var P=e.values(O);U=T==="l"?E-e.min(P):C-e.max(P),U&&(b[I]=e.mapValues(O,function(L){return L+U}))}})})}function w(b,N){return e.mapValues(b.ul,function(S,E){if(N)return b[N.toLowerCase()][E];var C=e.sortBy(e.map(b,E));return(C[1]+C[2])/2})}function k(b){var N=n.buildLayerMatrix(b),S=e.merge(r(b,N),s(b,N)),E={},C;e.forEach(["u","d"],function(T){C=T==="u"?N:e.values(N).reverse(),e.forEach(["l","r"],function(I){I==="r"&&(C=e.map(C,function(L){return e.values(L).reverse()}));var O=(T==="u"?b.predecessors:b.successors).bind(b),U=d(b,C,S,O),P=h(b,C,U.root,U.align,I==="r");I==="r"&&(P=e.mapValues(P,function(L){return-L})),E[T+I]=P})});var $=p(b,E);return g(E,$),w(E,b.graph().align)}function j(b,N,S){return function(E,C,$){var T=E.node(C),I=E.node($),O=0,U;if(O+=T.width/2,e.has(T,"labelpos"))switch(T.labelpos.toLowerCase()){case"l":U=-T.width/2;break;case"r":U=T.width/2;break}if(U&&(O+=S?U:-U),U=0,O+=(T.dummy?N:b)/2,O+=(I.dummy?N:b)/2,O+=I.width/2,e.has(I,"labelpos"))switch(I.labelpos.toLowerCase()){case"l":U=I.width/2;break;case"r":U=-I.width/2;break}return U&&(O+=S?U:-U),U=0,O}}function v(b,N){return b.node(N).width}return Ab}var Mb,YM;function Hoe(){if(YM)return Mb;YM=1;var e=vt(),t=_n(),n=Uoe().positionX;Mb=r;function r(o){o=t.asNonCompoundGraph(o),s(o),e.forEach(n(o),function(i,c){o.node(c).x=i})}function s(o){var i=t.buildLayerMatrix(o),c=o.graph().ranksep,d=0;e.forEach(i,function(h){var f=e.max(e.map(h,function(p){return o.node(p).height}));e.forEach(h,function(p){o.node(p).y=d+f/2}),d+=f+c})}return Mb}var $b,XM;function Woe(){if(XM)return $b;XM=1;var e=vt(),t=Soe(),n=_oe(),r=Coe(),s=_n().normalizeRanks,o=Toe(),i=_n().removeEmptyRanks,c=Roe(),d=Aoe(),h=Moe(),f=qoe(),p=Hoe(),g=_n(),w=Rr().Graph;$b=k;function k(W,X){var Y=X&&X.debugTiming?g.time:g.notime;Y("layout",function(){var J=Y(" buildLayoutGraph",function(){return O(W)});Y(" runLayout",function(){j(J,Y)}),Y(" updateInputGraph",function(){v(W,J)})})}function j(W,X){X(" makeSpaceForEdgeLabels",function(){U(W)}),X(" removeSelfEdges",function(){H(W)}),X(" acyclic",function(){t.run(W)}),X(" nestingGraph.run",function(){c.run(W)}),X(" rank",function(){r(g.asNonCompoundGraph(W))}),X(" injectEdgeLabelProxies",function(){P(W)}),X(" removeEmptyRanks",function(){i(W)}),X(" nestingGraph.cleanup",function(){c.cleanup(W)}),X(" normalizeRanks",function(){s(W)}),X(" assignRankMinMax",function(){L(W)}),X(" removeEdgeLabelProxies",function(){F(W)}),X(" normalize.run",function(){n.run(W)}),X(" parentDummyChains",function(){o(W)}),X(" addBorderSegments",function(){d(W)}),X(" order",function(){f(W)}),X(" insertSelfEdges",function(){q(W)}),X(" adjustCoordinateSystem",function(){h.adjust(W)}),X(" position",function(){p(W)}),X(" positionSelfEdges",function(){M(W)}),X(" removeBorderNodes",function(){G(W)}),X(" normalize.undo",function(){n.undo(W)}),X(" fixupEdgeLabelCoords",function(){D(W)}),X(" undoCoordinateSystem",function(){h.undo(W)}),X(" translateGraph",function(){A(W)}),X(" assignNodeIntersects",function(){B(W)}),X(" reversePoints",function(){K(W)}),X(" acyclic.undo",function(){t.undo(W)})}function v(W,X){e.forEach(W.nodes(),function(Y){var J=W.node(Y),ee=X.node(Y);J&&(J.x=ee.x,J.y=ee.y,X.children(Y).length&&(J.width=ee.width,J.height=ee.height))}),e.forEach(W.edges(),function(Y){var J=W.edge(Y),ee=X.edge(Y);J.points=ee.points,e.has(ee,"x")&&(J.x=ee.x,J.y=ee.y)}),W.graph().width=X.graph().width,W.graph().height=X.graph().height}var b=["nodesep","edgesep","ranksep","marginx","marginy"],N={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},S=["acyclicer","ranker","rankdir","align"],E=["width","height"],C={width:0,height:0},$=["minlen","weight","width","height","labeloffset"],T={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},I=["labelpos"];function O(W){var X=new w({multigraph:!0,compound:!0}),Y=Z(W.graph());return X.setGraph(e.merge({},N,V(Y,b),e.pick(Y,S))),e.forEach(W.nodes(),function(J){var ee=Z(W.node(J));X.setNode(J,e.defaults(V(ee,E),C)),X.setParent(J,W.parent(J))}),e.forEach(W.edges(),function(J){var ee=Z(W.edge(J));X.setEdge(J,e.merge({},T,V(ee,$),e.pick(ee,I)))}),X}function U(W){var X=W.graph();X.ranksep/=2,e.forEach(W.edges(),function(Y){var J=W.edge(Y);J.minlen*=2,J.labelpos.toLowerCase()!=="c"&&(X.rankdir==="TB"||X.rankdir==="BT"?J.width+=J.labeloffset:J.height+=J.labeloffset)})}function P(W){e.forEach(W.edges(),function(X){var Y=W.edge(X);if(Y.width&&Y.height){var J=W.node(X.v),ee=W.node(X.w),ne={rank:(ee.rank-J.rank)/2+J.rank,e:X};g.addDummyNode(W,"edge-proxy",ne,"_ep")}})}function L(W){var X=0;e.forEach(W.nodes(),function(Y){var J=W.node(Y);J.borderTop&&(J.minRank=W.node(J.borderTop).rank,J.maxRank=W.node(J.borderBottom).rank,X=e.max(X,J.maxRank))}),W.graph().maxRank=X}function F(W){e.forEach(W.nodes(),function(X){var Y=W.node(X);Y.dummy==="edge-proxy"&&(W.edge(Y.e).labelRank=Y.rank,W.removeNode(X))})}function A(W){var X=Number.POSITIVE_INFINITY,Y=0,J=Number.POSITIVE_INFINITY,ee=0,ne=W.graph(),se=ne.marginx||0,ce=ne.marginy||0;function de(ae){var pe=ae.x,fe=ae.y,Ee=ae.width,ye=ae.height;X=Math.min(X,pe-Ee/2),Y=Math.max(Y,pe+Ee/2),J=Math.min(J,fe-ye/2),ee=Math.max(ee,fe+ye/2)}e.forEach(W.nodes(),function(ae){de(W.node(ae))}),e.forEach(W.edges(),function(ae){var pe=W.edge(ae);e.has(pe,"x")&&de(pe)}),X-=se,J-=ce,e.forEach(W.nodes(),function(ae){var pe=W.node(ae);pe.x-=X,pe.y-=J}),e.forEach(W.edges(),function(ae){var pe=W.edge(ae);e.forEach(pe.points,function(fe){fe.x-=X,fe.y-=J}),e.has(pe,"x")&&(pe.x-=X),e.has(pe,"y")&&(pe.y-=J)}),ne.width=Y-X+se,ne.height=ee-J+ce}function B(W){e.forEach(W.edges(),function(X){var Y=W.edge(X),J=W.node(X.v),ee=W.node(X.w),ne,se;Y.points?(ne=Y.points[0],se=Y.points[Y.points.length-1]):(Y.points=[],ne=ee,se=J),Y.points.unshift(g.intersectRect(J,ne)),Y.points.push(g.intersectRect(ee,se))})}function D(W){e.forEach(W.edges(),function(X){var Y=W.edge(X);if(e.has(Y,"x"))switch((Y.labelpos==="l"||Y.labelpos==="r")&&(Y.width-=Y.labeloffset),Y.labelpos){case"l":Y.x-=Y.width/2+Y.labeloffset;break;case"r":Y.x+=Y.width/2+Y.labeloffset;break}})}function K(W){e.forEach(W.edges(),function(X){var Y=W.edge(X);Y.reversed&&Y.points.reverse()})}function G(W){e.forEach(W.nodes(),function(X){if(W.children(X).length){var Y=W.node(X),J=W.node(Y.borderTop),ee=W.node(Y.borderBottom),ne=W.node(e.last(Y.borderLeft)),se=W.node(e.last(Y.borderRight));Y.width=Math.abs(se.x-ne.x),Y.height=Math.abs(ee.y-J.y),Y.x=ne.x+Y.width/2,Y.y=J.y+Y.height/2}}),e.forEach(W.nodes(),function(X){W.node(X).dummy==="border"&&W.removeNode(X)})}function H(W){e.forEach(W.edges(),function(X){if(X.v===X.w){var Y=W.node(X.v);Y.selfEdges||(Y.selfEdges=[]),Y.selfEdges.push({e:X,label:W.edge(X)}),W.removeEdge(X)}})}function q(W){var X=g.buildLayerMatrix(W);e.forEach(X,function(Y){var J=0;e.forEach(Y,function(ee,ne){var se=W.node(ee);se.order=ne+J,e.forEach(se.selfEdges,function(ce){g.addDummyNode(W,"selfedge",{width:ce.label.width,height:ce.label.height,rank:se.rank,order:ne+ ++J,e:ce.e,label:ce.label},"_se")}),delete se.selfEdges})})}function M(W){e.forEach(W.nodes(),function(X){var Y=W.node(X);if(Y.dummy==="selfedge"){var J=W.node(Y.e.v),ee=J.x+J.width/2,ne=J.y,se=Y.x-ee,ce=J.height/2;W.setEdge(Y.e,Y.label),W.removeNode(X),Y.label.points=[{x:ee+2*se/3,y:ne-ce},{x:ee+5*se/6,y:ne-ce},{x:ee+se,y:ne},{x:ee+5*se/6,y:ne+ce},{x:ee+2*se/3,y:ne+ce}],Y.label.x=Y.x,Y.label.y=Y.y}})}function V(W,X){return e.mapValues(e.pick(W,X),Number)}function Z(W){var X={};return e.forEach(W,function(Y,J){X[J.toLowerCase()]=Y}),X}return $b}var Lb,ZM;function zoe(){if(ZM)return Lb;ZM=1;var e=vt(),t=_n(),n=Rr().Graph;Lb={debugOrdering:r};function r(s){var o=t.buildLayerMatrix(s),i=new n({compound:!0,multigraph:!0}).setGraph({});return e.forEach(s.nodes(),function(c){i.setNode(c,{label:c}),i.setParent(c,"layer"+s.node(c).rank)}),e.forEach(s.edges(),function(c){i.setEdge(c.v,c.w,{},c.name)}),e.forEach(o,function(c,d){var h="layer"+d;i.setNode(h,{rank:"same"}),e.reduce(c,function(f,p){return i.setEdge(f,p,{style:"invis"}),p})}),i}return Lb}var Ob,JM;function Voe(){return JM||(JM=1,Ob="0.8.5"),Ob}var Ib,QM;function Goe(){return QM||(QM=1,Ib={graphlib:Rr(),layout:Woe(),debug:zoe(),util:{time:_n().time,notime:_n().notime},version:Voe()}),Ib}var Koe=Goe();const e$=fk(Koe),Hc=240,I4=130,J0=mo*2+k0+Kk,Yoe=72,Di=J0+Yoe,ah=24,P4=mo*2+ah,qh=Di;function D4(e,t){var r;let n=Hc;for(const s of e)n=Math.max(n,((r=t.get(s.id))==null?void 0:r.width)??Hc);return n}const Uh=420,F4=1;function Xoe(e,t,n,r){return Math.min(F4,n/Math.max(1,e),r/Math.max(1,t))}function Xf(e){var n;return((n=e.data)==null?void 0:n.sessionId)??"_default"}function Zf(e,t=()=>!0){const n=new Map;for(const r of e){if(!t(r))continue;const s=Xf(r),o=n.get(s);o?o.push(r):n.set(s,[r])}return n}function Zoe(e,t){return((t==null?void 0:t.get(e))??0)>0?Uh:0}function Joe(e,t){const n=(t==null?void 0:t.get(e))??0;return n>0?6+n*36:0}function Hh(e,t){const n=t.get(e);return{w:(n==null?void 0:n.width)??Hc,h:(n==null?void 0:n.height)??I4}}function Wc(e,t,n){const r=Hh(e,t);return{w:r.w+Zoe(e,n),h:Math.max(r.h,Joe(e,n))}}function Qoe(e){return[...e.keys()].sort().map(t=>`${t}:${e.get(t)}`).join("|")}function eie(e,t,n){const r=Zf(e,s=>!t.has(s.id)&&n(s.id)!=null);if(r.size===0)return e;for(const s of r.values())s.sort((o,i)=>o.id.localeCompare(i.id));return e.map(s=>{var h;if(t.has(s.id)||n(s.id))return s;const o=r.get(Xf(s));if(!o)return s;const i=(h=s.data)==null?void 0:h.parentId,c=o.find(f=>f.id===i)??o[0],d=n(c.id);return{...s,position:{x:s.position.x+d.x-c.position.x,y:s.position.y+d.y-c.position.y}}})}function tie(e,t,n,r,s,o,i){const c=S=>Wc(S,r,o),d=S=>n.get(S)??t.get(S),h=S=>{const{w:E,h:C}=Hh(S,r);return{cw:E,ch:C}},f=i!=null&&i.width>0&&i.height>0,p=Zf(e,S=>d(S.id)!=null),g=new Set;for(const[S,E]of p)E.every(C=>s.has(C.id)&&!n.has(C.id))&&g.add(S);const w=new Map,k=[];for(const S of e){const E=d(S.id);if(!E)continue;const{w:C,h:$}=c(S.id),T=Xf(S);g.has(T)?(w.get(T)??w.set(T,[]).get(T)).push(S):k.push({sid:T,x:E.x,y:E.y,w:C,h:$,...h(S.id)})}if(w.size===0||f&&k.length===0)return[];const j=qh,v=(S,E,C,$)=>k.some(T=>S<T.x+T.w+J0&&T.x<S+C+J0&&E<T.y+T.h+j&&T.y<E+$+j),b=D4(e,r),N=[];for(const S of[...w.keys()].sort()){const E=w.get(S);let C=1/0,$=1/0,T=-1/0,I=-1/0,O=-1/0,U=-1/0;for(const G of E){const H=d(G.id),{w:q,h:M}=c(G.id),{cw:V,ch:Z}=h(G.id);C=Math.min(C,H.x),$=Math.min($,H.y),T=Math.max(T,H.x+q),I=Math.max(I,H.y+M),O=Math.max(O,H.x+V),U=Math.max(U,H.y+Z)}const P=T-C,L=I-$,F=new Map;for(const G of k)F.set(G.sid,Math.min(F.get(G.sid)??1/0,G.x));const A=[...new Set([...F.values()].map(G=>Math.round(G)))].sort((G,H)=>G-H),B=A.length?A:[C],D=[0,...k.map(G=>G.y+G.h+j)].sort((G,H)=>G-H);let K=null;if(f){let G=1/0,H=1/0,q=-1/0,M=-1/0;for(const J of k)G=Math.min(G,J.x),H=Math.min(H,J.y),q=Math.max(q,J.x+J.cw),M=Math.max(M,J.y+J.ch);const V=(J,ee)=>{const ne=i.width/(Math.max(q,J+O-C)-Math.min(G,J)+Uh),se=i.height/(Math.max(M,ee+U-$)-Math.min(H,ee));return[Math.min(F4,ne,se),Math.min(ne,se),Math.max(ne,se)]},Z=(J,ee)=>{for(let ne=0;ne<J.length;ne++){if(J[ne]>ee[ne]+1e-9)return!0;if(J[ne]<ee[ne]-1e-9)return!1}return!1},W=Math.round(q+Uh+b),X=[...new Set([...D,H])].sort((J,ee)=>J-ee);let Y=null;for(const J of[...B,W])for(const ee of X){if(v(J,ee,P,L))continue;const ne=V(J,ee);(Y===null||Z(ne,Y))&&(Y=ne,K={x:J,y:ee})}K&&K.x===C&&K.y===$&&(K=null)}else e:for(const G of B)for(const H of D){if(H>=$)break;if(!v(G,H,P,L)){K={x:G,y:H};break e}}if(K){const G=K.x-C,H=K.y-$;for(const q of E){const M=d(q.id);t.set(q.id,{x:M.x+G,y:M.y+H})}N.push(S)}for(const G of E){const H=d(G.id),{w:q,h:M}=c(G.id);k.push({sid:S,x:H.x,y:H.y,w:q,h:M,...h(G.id)})}}return N}function nie(e,t,n,r,s,o){const i=g=>Wc(g,r,s),c=new Map(e.map(g=>[g.id,Xf(g)])),d=[],h=e.map(g=>({id:g.id,pos:n.get(g.id)??t.get(g.id)})).filter(g=>g.pos!=null).sort((g,w)=>g.pos.y-w.pos.y||g.pos.x-w.pos.x||g.id.localeCompare(w.id)),f=g=>(o==null?void 0:o.has(g))===!0&&!n.has(g);for(const{id:g,pos:w}of h){if(!f(g))continue;const{w:k,h:j}=i(g);d.push({x:w.x,y:w.y,w:k,h:j,sid:c.get(g)??"_default"})}const p=[];for(const{id:g,pos:w}of h){if(f(g))continue;const{w:k,h:j}=i(g),v=c.get(g)??"_default";if(n.has(g)){d.push({x:w.x,y:w.y,w:k,h:j,sid:v});continue}let b=w.y;for(let N=0;N<d.length+1;N++){const S=d.find(E=>{const C=E.sid===v?ah:P4,$=E.sid===v?ah:qh;return w.x<E.x+E.w+C&&E.x<w.x+k+C&&b<E.y+E.h+$&&E.y<b+j+$});if(!S)break;b=S.y+S.h+(S.sid===v?ah:qh)}b!==w.y&&(t.set(g,{x:w.x,y:b}),p.push(g)),d.push({x:w.x,y:b,w:k,h:j,sid:v})}return p}function rie(e,t,n,r,s,o=!1,i){const d=P4+1,h=qh+1,f=8,p=1.75,g=200,w=.7,k=.01,j=L=>Wc(L,r,i),v=L=>n.get(L)??t.get(L),b=Zf(e,L=>v(L.id)!=null),N=[],S=new Set,E=new Set,C=s.size===0;for(const L of[...b.keys()].sort()){const F=b.get(L);let A=1/0,B=1/0,D=-1/0,K=-1/0,G=!1;for(const V of F){const Z=v(V.id),{w:W,h:X}=j(V.id);A=Math.min(A,Z.x),B=Math.min(B,Z.y),D=Math.max(D,Z.x+W),K=Math.max(K,Z.y+X),n.has(V.id)&&(G=!0)}const H=D-A,q=K-B;E.add(L);const M=s.get(L);M&&(H>M.w+f||q>M.h+f)&&S.add(L),s.set(L,{w:H,h:q}),N.push({sid:L,members:F.map(V=>V.id),x:A,y:B,w:H,h:q,anchored:G,mass:1})}for(const L of[...s.keys()])E.has(L)||s.delete(L);if(o||C)return[];let $=!1;for(let L=0;L<N.length&&!$;L++)for(let F=L+1;F<N.length;F++){const A=N[L],B=N[F];if(!(A.anchored&&B.anchored)&&Math.abs(A.x+A.w/2-(B.x+B.w/2))<(A.w+B.w)/2+d&&Math.abs(A.y+A.h/2-(B.y+B.h/2))<(A.h+B.h)/2+h){$=!0;break}}if(S.size===0&&!$)return[];if(S.size>0)for(const L of N)S.has(L.sid)&&(L.mass=8);else for(const L of N)L.mass=Math.max(1,L.w*L.h/(Hc*I4));const T=new Map(N.map(L=>[L.sid,L.x])),I=new Map(N.map(L=>[L.sid,L.y])),O=new Map(N.map(L=>[L.sid,Math.min(0,L.x)])),U=new Map(N.map(L=>[L.sid,Math.min(0,L.y)]));for(let L=0;L<g;L++){const F=new Map,A=new Map;let B=0;for(let D=0;D<N.length;D++)for(let K=D+1;K<N.length;K++){const G=N[D],H=N[K];if(G.anchored&&H.anchored)continue;const q=G.x+G.w/2,M=G.y+G.h/2,V=H.x+H.w/2,Z=H.y+H.h/2,W=(G.w+H.w)/2+d-Math.abs(q-V),X=(G.h+H.h)/2+h-Math.abs(M-Z);if(W<=0||X<=0)continue;const Y=(Me,He)=>!Me.anchored&&!(He<0&&Me.x<=O.get(Me.sid)),J=(Me,He)=>!Me.anchored&&!(He<0&&Me.y<=U.get(Me.sid)),ee=(Me,He,rt)=>{const Ue=Me===He,it=Ue?G.sid<H.sid?-1:1:Math.sign(Me-He);return rt(G,it)||rt(H,-it)?it:Ue&&(rt(G,-it)||rt(H,it))?-it:0},ne=ee(q,V,Y),se=ee(M,Z,J),ce=ne!==0,de=se!==0;if(!ce&&!de)continue;const ae=ce&&(!de||W*p<X),[pe,fe,Ee,ye]=ae?[ne,W,F,Y]:[se,X,A,J],oe=ye(G,pe),we=ye(H,-pe),Ne=G.mass,ge=H.mass,Ae=oe?we?ge/(Ne+ge):1:0,Oe=we?oe?Ne/(Ne+ge):1:0,qe=fe*w;Ee.set(G.sid,(Ee.get(G.sid)??0)+pe*qe*Ae),Ee.set(H.sid,(Ee.get(H.sid)??0)-pe*qe*Oe),B+=qe}for(const D of N)D.anchored||(D.x=Math.max(O.get(D.sid),D.x+(F.get(D.sid)??0)),D.y=Math.max(U.get(D.sid),D.y+(A.get(D.sid)??0)));if(B<k)break}const P=[];for(const L of N){const F=L.x-T.get(L.sid),A=L.y-I.get(L.sid);if(!(Math.abs(F)<1&&Math.abs(A)<1)){for(const B of L.members){if(n.has(B))continue;const D=t.get(B);D&&t.set(B,{x:D.x+F,y:D.y+A})}P.push(L.sid)}}return P}function sie(e,t,n,r,s,o){const i=new e$.graphlib.Graph;i.setDefaultEdgeLabel(()=>({})),i.setGraph({rankdir:n,marginx:0,marginy:0,nodesep:70,ranksep:160,edgesep:30});const c=e.filter(b=>!s.has(b)),d=new Set(c);for(const b of c){const{w:N,h:S}=Wc(b,r,o);i.setNode(b,{width:N,height:S})}for(const b of t)d.has(b.source)&&d.has(b.target)&&i.setEdge(b.source,b.target);e$.layout(i);const h=new Map;let f=1/0,p=1/0,g=-1/0,w=-1/0;for(const b of c){const N=i.node(b);if(!N)continue;const{w:S,h:E}=Hh(b,r),C=Wc(b,r,o),$=N.x-C.w/2,T=N.y-C.h/2;h.set(b,{x:$,y:T}),$<f&&(f=$),T<p&&(p=T),$+S>g&&(g=$+S),T+E>w&&(w=T+E)}if(Number.isFinite(f)&&Number.isFinite(p))for(const[b,N]of h)h.set(b,{x:N.x-f,y:N.y-p});const k=Number.isFinite(g)?g-f:0,j=Number.isFinite(w)?w-p:0;let v=null;for(const b of e){const N=s.get(b);if(!N)continue;const{w:S,h:E}=Hh(b,r);v=v===null?{minX:N.x,minY:N.y,maxX:N.x+S,maxY:N.y+E}:{minX:Math.min(v.minX,N.x),minY:Math.min(v.minY,N.y),maxX:Math.max(v.maxX,N.x+S),maxY:Math.max(v.maxY,N.y+E)}}return{positions:h,width:k,height:j,pinnedBox:v}}function B4(e,t,n){const r=n.direction??"LR",s=n.pinned??new Map,o=n.measured??new Map,i=n.lanes,c=Zf(e);return{laid:Array.from(c.keys()).sort().map(f=>({sid:f,...sie(c.get(f).map(p=>p.id),t,r,o,s,i)})),gap:D4(e,o)}}const q4=e=>e.reduce((t,n)=>Math.max(t,n.width),0)+Uh,aie=e=>e.reduce((t,n)=>t+n.height,0)+Di*Math.max(0,e.length-1);function Q0(e,t,n,r){const s=d=>{const h=[[]];let f=0;for(const p of e)f>0&&f+p.height>d&&(h.push([]),f=0),h[h.length-1].push(p),f+=p.height+Di;return h},o=[];for(let d=0;d<e.length;d++){let h=-Di;for(let f=d;f<e.length;f++)o.push(h+=e[f].height+Di)}o.sort((d,h)=>d-h);const i=d=>{let h=0,f=o.length-1;for(;h<f;){const p=h+f>>1;s(o[p]).length<=d?f=p:h=p+1}return s(o[h])};let c=[e];if(n>0&&r>0){const d=f=>Xoe(f.reduce((p,g)=>p+q4(g),0)+t*(f.length-1),Math.max(...f.map(aie)),n,r);let h=d(c);for(let f=2;f<=e.length;f++){const p=i(f),g=d(p);g>h+1e-9&&(h=g,c=p)}}return c}function oie(e,t,n,r,s){if(!(r.width>0&&r.height>0&&s.width>0&&s.height>0))return!1;const{laid:o,gap:i}=B4(e,t,n);return o.length<2?!1:Q0(o,i,r.width,r.height).length!==Q0(o,i,s.width,s.height).length}function iie(e,t,n={}){const r=n.pinned??new Map,{laid:s,gap:o}=B4(e,t,n),i=Q0(s,o,n.availableWidth??0,n.availableHeight??0),c=new Map;let d=0;for(const h of i){const f=q4(h);let p=0;for(const{positions:g,height:w,pinnedBox:k}of h){for(const[v,b]of g)c.set(v,{x:b.x+d,y:b.y+p});let j=p+w;k&&k.maxY>j&&k.minX<d+f&&d<k.maxX&&(j=k.maxY),p=j+Di}d+=f+o}return e.map(h=>{const f=r.get(h.id);if(f)return{...h,position:f};const p=c.get(h.id);return p?{...h,position:p}:h})}function oh(e,t,n){return!t.has(e)||n.has(e)}function lie(e,t,n,r){return!t.has(e)&&oh(e,n,r)}function cie(e,t,n){const r={x:0,y:0};return t.set(e,r),n.add(e),r}function t$(e,t,n,r){n.set(e,t),r.delete(e)}const uie=300,n$=130,die=160,r$=new WeakMap;function hie(e,t){let n=r$.get(e);(!n||n.revision!==e.revision||n.open!==t)&&(n={revision:e.revision,open:t,byId:new Map,branches:Vz(e.agents.values())},r$.set(e,n));const{byId:r,branches:s}=n;return o=>{let i=r.get(o.id);if(!i){const c=o.kind==="root"?s.get(o.sessionId):void 0;i=c?{...o,onOpenContext:t,branch:c}:{...o,onOpenContext:t},r.set(o.id,i)}return i}}function H1(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 fie(e,t){const n=i=>{var c;return((c=i.data)==null?void 0:c.sessionId)??i.id},r=new Map;for(const i of e){const c=n(i),d=i.position.x+(i.width??Hc),h=r.get(c);h?(h.minX=Math.min(h.minX,i.position.x),h.maxX=Math.max(h.maxX,d),h.minY=Math.min(h.minY,i.position.y)):r.set(c,{minX:i.position.x,maxX:d,minY:i.position.y})}const s=[];for(const[i,c]of[...r].sort((d,h)=>d[1].minX-h[1].minX)){const d=s[s.length-1];d&&c.minX<d.maxX?(d.maxX=Math.max(d.maxX,c.maxX),d.sessions.push({sid:i,top:c.minY})):s.push({maxX:c.maxX,sessions:[{sid:i,top:c.minY}]})}const o=new Map;for(const i of s)for(const{sid:c}of i.sessions.sort((d,h)=>d.top-h.top))o.set(c,o.size);return e.slice().sort((i,c)=>o.get(n(i))-o.get(n(c))||t(i)-t(c)||i.position.y-c.position.y||i.position.x-c.position.x)}function pie(e,t){var r;let n=0;for(let s=t.parentId;s!=null&&n<e.agents.size;s=(r=e.agents.get(s))==null?void 0:r.parentId)n++;return n}function mie(e,t,n,r,s,o,i,c,d,h,f,p,g,w,k,j,v,b,N,S){var K,G,H,q;const E=[],C=[],$=hie(e,b);for(const M of e.agents.values()){if(!v.has(M.id))continue;const V=M.exitAt!=null,Z=j!=null&&!j.has(M.id),W=[V?"rf-exiting":"",Z?"rf-spotlit-out":"",k.has(M.id)?"rf-selected":""].filter(Boolean).join(" ")||void 0,X=o.get(M.id);if(E.push({id:M.id,type:"agent",position:{x:0,y:0},data:$(M),className:W,ariaLabel:nz(M,t,k.has(M.id)),...X?{width:X.width,height:X.height}:null}),M.parentId&&v.has(M.parentId)){const ee=Rc(M.sessionId),ne=V,se=k.size>0&&(k.has(M.id)||k.has(M.parentId)),ce=j!=null&&!j.has(M.id)&&!j.has(M.parentId),de=M.state==="active"?2:1.5,ae=se?de+1.5:de,pe=ne?.2:ce?.12:1,fe=["sess-edge",M.state==="active"?"sess-live":"sess-idle",ne?"rf-edge-exiting":"",se?"rf-edge-selected":""].filter(Boolean).join(" ");C.push({id:`e:${M.parentId}->${M.id}`,source:M.parentId,target:M.id,animated:(M.state==="active"||se)&&!ne,type:"smoothstep",style:{"--session-hue":ee,strokeWidth:`calc(${ae}px * var(--edge-k, 1))`,opacity:pe,transition:"var(--edge-transition)"},className:fe})}const Y=M.kind==="root"?df(M):null,J=Y?Y.key:null;if(Y&&J&&!Iz(J)){const ee=Bk(M.id),ne=Rc(M.sessionId),se=o.get(ee);E.push({id:ee,type:"recapNote",position:{x:0,y:0},data:{sessionId:M.sessionId,parentId:M.id,note:Y,noteKey:J,hue:ne},className:Z?"rf-spotlit-out":void 0,selectable:!1,focusable:!1,ariaLabel:Y.kind==="recap"?`Claude Code's recap for ${M.label}`:`${M.label}: ${ja(Y.kind)}`,...se?{width:se.width,height:se.height}:null}),C.push({id:`e:recap:${M.id}`,source:ee,target:M.id,type:"recapTie",className:"recap-edge",focusable:!1,style:{"--session-hue":ne}})}}const T=H1(e),I=S.size>0&&!(d&&N);I||S.clear();const O=`${g}#lanes:${Qoe(T)}${I?"#held":""}`,U=new Set(E.filter(M=>M.type==="recapNote").map(M=>M.id));for(const M of Array.from(f.keys()))N&&Bz(M)&&!U.has(M)&&!s.has(M)&&(f.delete(M),p.delete(M));const P=E.filter(M=>lie(M.id,s,f,p));if(P.length>0||O!==w.current){if(P.length>0){for(const V of P)S.delete(V.id);const M=eie(iie(E,C,{direction:"LR",pinned:s,measured:o,availableWidth:n,availableHeight:r,lanes:T}),s,V=>oh(V,f,p)?void 0:f.get(V));for(const V of M)oh(V.id,f,p)&&t$(V.id,V.position,f,p);tie(E,f,s,o,new Set(P.filter(V=>V.type!=="recapNote").map(V=>V.id)),T,{width:n,height:r});for(const V of P){if(V.type!=="recapNote")continue;const Z=(K=V.data)==null?void 0:K.parentId;if(!Z)continue;const W=s.get(Z)??(oh(Z,f,p)?void 0:f.get(Z));if(!W)continue;const X=((G=o.get(V.id))==null?void 0:G.width)??uie,Y=((H=o.get(V.id))==null?void 0:H.height)??n$,J=((q=o.get(Z))==null?void 0:q.height)??n$;t$(V.id,{x:W.x-die-X,y:W.y+(J-Y)/2},f,p)}}nie(E,f,s,o,T,I?S:void 0),w.current=O}const L=rie(E,f,s,o,i,!d||h,T);L.length>0&&c(L);const F=Cre(e.agents.values());N&&qd(f,F),qd(p,F),N&&qd(s,F),qd(o,Ere(e.agents.values()));const A=[];let B=!1;for(const M of E){let V=s.get(M.id)??f.get(M.id);V||(V=cie(M.id,f,p),B=!0),A.push({...M,position:V})}return B&&(w.current=""),{nodes:fie(A,M=>{if(M.type==="recapNote")return-1;const V=e.agents.get(M.id);return V?pie(e,V):0}),edges:C}}function gie(e){return e.slice().sort((t,n)=>t.y-n.y||t.x-n.x)}function yie(e,t,n){var i;if(e.length===0)return null;const r=gie(e),s=t?r.findIndex(c=>c.id===t):-1,o=s===-1?n===1?0:r.length-1:(s+n+r.length)%r.length;return((i=r[o])==null?void 0:i.id)??null}const wie=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Escape","Backspace"]);function xie(e,t){return t==null?{kind:"deck",nodeId:null}:e.key==="Enter"||e.key===" "?{kind:"activate",nodeId:t,additive:e.shiftKey}:wie.has(e.key)?{kind:"node",nodeId:t}:{kind:"deck",nodeId:t}}const vie=new Set(["","BODY","HTML","#DOCUMENT"]);function bie(e){return!e||xo(e)?!1:!vie.has(String(e.tagName??"").toUpperCase())}const U4="react-flow__node";function W1(e){var t,n;return!!e&&((n=(t=e.classList)==null?void 0:t.contains)==null?void 0:n.call(t,U4))===!0}function H4(e){try{const t=document.querySelector(`.${U4}[data-id="${CSS.escape(e)}"]`);t==null||t.focus({preventScroll:!0})}catch{}}let ko=null,Ri=null;const ek=new Set,tk=()=>{for(const e of ek)e()},kie=e=>(ek.add(e),()=>{ek.delete(e)}),s$=()=>ko,jie=90;function W4(e){!Ri||e!=null&&Ri.at.id!==e||(clearTimeout(Ri.timer),Ri=null)}function z4(e,t,n="pointer"){W4();const r={id:e,anchor:t,by:n};if(ko||n==="focus"){ko=r,tk();return}Ri={at:r,timer:setTimeout(()=>{Ri=null,ko=r,tk()},jie)}}function Ca(e){W4(e),!(!ko||e!=null&&ko.id!==e)&&(ko=null,tk())}function Nie({agentFor:e,recapFor:t,labelFor:n,bounds:r}){const s=y.useSyncExternalStore(kie,s$,s$),o=s?e(s.id):void 0,i=s&&!o?t(s.id):void 0,c=s!=null&&(!o&&!i||!s.anchor.isConnected);return y.useEffect(()=>{c&&s&&Ca(s.id)},[c,s]),!s||c?null:o?a.jsx(_ie,{a:o,anchor:s.anchor,parentLabel:o.parentId?n(o.parentId):void 0,bounds:r},s.id):i?a.jsx(Sie,{r:i,anchor:s.anchor,bounds:r},s.id):null}function V4(e,t){const n=y.useRef(null),r=y.useCallback(()=>{const s=n.current;if(!s||!e.isConnected)return;s.style.maxHeight="";const o=o1(e.getBoundingClientRect(),{width:s.offsetWidth,height:s.offsetHeight},t());s.style.top=`${o.top}px`,s.style.left=`${o.left}px`,s.style.maxHeight=o.maxHeight==null?"":`${o.maxHeight}px`,s.dataset.side=o.side},[e,t]);return y.useLayoutEffect(()=>{r()}),n}function Sie({r:e,anchor:t,bounds:n}){const r=V4(t,n),s=Ao(3e4),o=e.note,i=o.kind==="recap",c=jh(o.at,s);return yt.createPortal(a.jsxs("div",{ref:r,className:"ap-peek node-peek recap-peek",role:"tooltip",id:"node-peek",style:{"--session-hue":e.hue},children:[a.jsxs("div",{className:"node-peek-head",children:[a.jsxs("span",{className:"recap-peek-mark",children:[a.jsx(xh,{recap:i}),ja(o.kind)]}),a.jsx("span",{className:"node-peek-time",title:c.title,children:c.label})]}),e.sessionLabel&&a.jsx("div",{className:"node-peek-kind",children:a.jsxs("span",{children:[hf(o)," · ",e.sessionLabel]})}),a.jsx("p",{className:"recap-peek-text",children:o.text}),o.reply&&a.jsxs("p",{className:"recap-peek-text",children:["Suggested reply: “",o.reply,"”"]}),a.jsx("p",{className:"node-peek-hint",children:"Click to go to the session · double-click for its details"})]}),document.body)}function _ie({a:e,anchor:t,parentLabel:n,bounds:r}){const s=V4(t,r),o=Ao(1e3),i=Dk(e.sessionName,e.sessionTitle),c=e.toolErrorCount??0,d=e.tools.filter(j=>!j.endedAt).length,h=En(e,o).total,f=e.usage.inputTokens+e.usage.outputTokens,p=e.kind==="root"&&Hn(e.waiting),g=iI(e),w=e.kind==="root"?"session":n?`subagent of ${n}`:"subagent",k=[`${e.toolCount} ${e.toolCount===1?"tool":"tools"}`,d>0?`${d} in-flight`:null,f>0?`${ut(f)} tok`:null,h>0?`${Ye(h)}${Mc(e,o)>0?"+":""}`:null].filter(Boolean).join(" · ");return yt.createPortal(a.jsxs("div",{ref:s,className:"ap-peek node-peek",role:"tooltip",id:"node-peek",children:[a.jsxs("div",{className:"node-peek-head",children:[a.jsx("span",{className:"node-peek-name",title:e.label,children:e.label}),a.jsxs("span",{className:"node-peek-time",children:[e.synthetic?"≥ ":"",Vi(e.startedAt,e.endedAt,o)]})]}),a.jsxs("div",{className:"node-peek-kind",children:[a.jsxs("span",{className:"node-peek-state","data-kind":f0(e.state),children:[a.jsx(SI,{kind:f0(e.state)}),Wi(e.state)]}),a.jsx("span",{children:w}),e.model?a.jsx("span",{children:rs(e.model)}):null]}),e.kind==="root"&&i.face&&a.jsx("p",{className:"node-peek-title",title:i.face,children:i.face}),e.kind==="root"&&e.waiting&&a.jsxs("p",{className:`node-peek-wait${p?" warn":""}`,children:[p&&a.jsx(Hk,{}),a.jsxs("span",{className:"node-peek-said",title:wh(e.waiting),children:[a.jsx("span",{className:"node-peek-since",children:a.jsx("b",{children:Vi(e.waiting.since,void 0,o)})}),wh(e.waiting)]})]}),g&&a.jsxs("p",{className:"node-peek-blind",children:[a.jsx("span",{className:"approval-blind-dot","aria-hidden":!0}),g.label]}),a.jsxs("p",{className:"node-peek-facts",children:[k,c>0&&a.jsxs("span",{className:"node-peek-failed",children:[" · ",c," failed"]})]}),e.branch&&e.branch.total>0&&a.jsx("p",{className:"node-peek-branch",children:wI(e.branch)}),a.jsx("p",{className:"node-peek-hint",children:"Click to go to the session · double-click for details"})]}),document.body)}function Eie(e){const t=e.minZoom??Mne,n=e.maxZoom??$ne,r=e.fill??.9,s=e.insets.left,o=e.insets.top,i=Math.max(1,e.pane.width-e.insets.left-e.insets.right),c=Math.max(1,e.pane.height-e.insets.top-e.insets.bottom),d=e.context,h=e.anchor,f=Math.min(i/Math.max(1,d.width),c/Math.max(1,d.height))*r,p=Math.max(t,Math.min(n,f)),g=(w,k,j,v,b,N)=>{let S=w+(k-v*p)/2-j*p;const E=b*p+S,C=(b+N)*p+S;return N*p<=k?E<w?S+=w-E:C>w+k&&(S-=C-(w+k)):S+=w-E,S};return{x:g(s,i,d.x,d.width,h.x,h.width),y:g(o,c,d.y,d.height,h.y,h.height),zoom:p}}function Cie(e){let t=1/0,n=1/0,r=-1/0,s=-1/0;for(const o of e)t=Math.min(t,o.x),n=Math.min(n,o.y),r=Math.max(r,o.x+o.width),s=Math.max(s,o.y+o.height);return Number.isFinite(t)?{x:t,y:n,width:r-t,height:s-n}:null}function Wn(e){const t=y.useRef(e);return t.current=e,t}const nk=80,rk=.86;function G4(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 Tie({canvasRef:e,canvasSize:t,machinePhase:n,usagePhase:r,usagePanelOpen:s,detailShown:o}){const[i,c]=y.useState(0);y.useEffect(()=>{const p=G4(e.current);c(g=>Math.abs(g-p)>40?p:g)},[n,r,s,o,t.w]);const d=Wn(i),h=t.w>0?Math.max(0,(t.w-i-nk*2)*rk):0,f=t.h>0?Math.max(0,(t.h-nk*2)*rk):0;return{railInsetRef:d,availableWidth:h,availableHeight:f}}const a$=1e-6;function vc(e){return Number.isFinite(e[0])&&Number.isFinite(e[1])&&Number.isFinite(e[2])&&e[2]>0}function o$(e,t,n){return Math.abs(e[2]-t[2])<=a$*t[2]&&Math.hypot(e[0]-t[0],e[1]-t[1])<=a$*n}function Rie(e,t){const n=t[2]/e[2];return r=>[e[0]+(t[0]-e[0])*r,e[1]+(t[1]-e[1])*r,e[2]*n**r]}function Aie(e,t,n){const r=e(0),s=e(.5),o=e(1);if(!vc(r)||!vc(s)||!vc(o))return!1;const i=Math.max(t[2],n[2]);return o$(r,t,i)&&o$(o,n,i)}function Mie(e){return(t,n)=>{const r=e(t,n),s=Aie(r,t,n)?r:Rie(t,n);let o=vc(t)?t:n;return i=>{const c=s(i);return vc(c)&&(o=c),o}}}function $ie(e){return Number.isFinite(e.x)&&Number.isFinite(e.y)&&Number.isFinite(e.zoom)&&e.zoom>0}const i$=new WeakSet,K4=420;function Lie(){const e=Qi(),t=Rt(),n=y.useCallback((h,f)=>{if(!$ie(h))return;if(c0({durationMs:f,documentHidden:document.hidden})){e.setViewport(h,{duration:f});return}const{d3Zoom:p,d3Selection:g}=t.getState(),w=g==null?void 0:g.property("__zoom");if(p&&g&&w&&w.k>0&&h.zoom>0){p.transform(g,w.scale(h.zoom/w.k).translate((h.x-w.x)/h.zoom,(h.y-w.y)/h.zoom));return}e.setViewport(h,{duration:0})},[e,t]);y.useEffect(()=>{const h=f=>{!f||i$.has(f)||(i$.add(f),f.interpolate(Mie(f.interpolate())))};return h(t.getState().d3Zoom),t.subscribe(f=>h(f.d3Zoom))},[t]);const r=y.useRef(null),s=y.useRef(0),o=y.useRef(0),i=y.useCallback((h,f)=>{const p=++s.current;return o.current=Date.now(),n(h,f),r.current=c0({durationMs:f,documentHidden:document.hidden})?{target:h,until:Date.now()+f+60}:null,p},[n]),c=y.useCallback((h=500)=>{const f=nk,p=1,g=.2,w=rk;try{const k=document.querySelector(".canvas-wrap"),j=Array.from(document.querySelectorAll(".react-flow__node")).filter(B=>B.offsetWidth>0);if(!k||j.length===0)return;const v=k.getBoundingClientRect(),b=e.getViewport();if(!Number.isFinite(b.zoom)||b.zoom<=0)return;const N=new Map(e.getNodes().map(B=>[B.id,B])),S=j.flatMap(B=>{const D=N.get(B.dataset.id??"");if(!D)return[];const K=D.positionAbsolute??D.position,G=D.width??B.offsetWidth,H=D.height??B.offsetHeight;return G>0&&H>0?[{left:K.x,right:K.x+G,top:K.y,bottom:K.y+H}]:[]});if(S.length===0)return;const E=Math.min(...S.map(B=>B.left)),C=Math.max(...S.map(B=>B.right)),$=Math.min(...S.map(B=>B.top)),T=Math.max(...S.map(B=>B.bottom)),I=C-E,O=T-$;if(!(I>0&&O>0))return;const U=G4(k),P=B=>Math.max(g,Math.min(p,(v.width-U-f*2)/(I+B)*w,(v.height-f*2)/O*w)),L=Ane(P(K4),P(0),SP(Zk[Jk()])),F={x:f-E*L,y:(v.height>v.width-U?f:Math.max(f,(v.height-O*L)/2))-$*L,zoom:L},A=i(F,h);window.setTimeout(()=>{var B;try{if(((B=r.current)==null?void 0:B.target)===F&&(r.current=null),s.current!==A)return;const D=e.getViewport();(Math.abs(D.zoom-L)>.01||Math.abs(D.x-F.x)>2||Math.abs(D.y-F.y)>2)&&n(F,0)}catch{}},h+60)}catch{}},[e,n,i]);y.useEffect(()=>{const h=()=>{if(!document.hidden)return;const f=r.current;if(r.current=null,!(!f||Date.now()>f.until)){try{n(f.target,0)}catch{}o.current=Date.now()}};return document.addEventListener("visibilitychange",h),()=>document.removeEventListener("visibilitychange",h)},[n]);const d=y.useCallback(()=>e.getViewport(),[e]);return{applyViewport:n,moveCamera:i,fitLeft:c,currentViewport:d,cameraEpochRef:s,lastFitTimeRef:o}}const Oie=450;function Iie({canvasRef:e,stateRef:t,measuredRef:n,nodesRef:r,railInsetRef:s,moveCamera:o,disableAutoFit:i,lastFocusRef:c,focusAgentRef:d,selectAgent:h,primarySelectedIdRef:f}){const p=y.useCallback(k=>{var I;const j=e.current,v=t.current.agents.get(k);if(!j||!v)return;const b=H1(t.current),N=(O,U)=>{const P=n.current.get(O.id);if(!P)return null;const L=U&&b.has(O.id)?K4:0;return{x:O.position.x,y:O.position.y,width:P.width+L,height:P.height}},S=r.current.find(O=>O.id===k),E=S?N(S,!1):null;if(!E)return;const C=[];for(const O of r.current){if(O.type!=="agent"&&O.type!=="recapNote"||((I=O.data)==null?void 0:I.sessionId)!==v.sessionId)continue;const U=N(O,O.type==="agent");U&&C.push(U)}const $=j.getBoundingClientRect(),T=Eie({pane:{width:$.width,height:$.height},insets:{top:56,left:72,bottom:32,right:s.current+32},context:Cie(C)??E,anchor:E});Ca(),i(),c.current={id:k,at:Date.now()},o(T,Oie)},[o,i]);d.current=p;const g=y.useCallback(k=>{const j=r.current.filter(S=>S.type==="agent"),v=yie(j.map(S=>({id:S.id,x:S.position.x,y:S.position.y})),f.current,k),b=v?j.find(S=>S.id===v):void 0;if(!b)return;const N=W1(document.activeElement);h(b.id,!1),window.setTimeout(()=>{try{p(b.id)}catch{}N&&H4(b.id)},30)},[h,p]),w=y.useCallback(k=>{h(k,!1),window.setTimeout(()=>{try{p(k)}catch{}},60)},[h,p]);return{focusAgent:p,stepAgent:g,focusSession:w}}function Pie({nodesRef:e,stateRef:t,canvasRef:n,railInsetRef:r}){const s=y.useCallback(d=>{const h=e.current.find(f=>f.id===d&&f.type==="agent");return h?h.data:void 0},[]),o=y.useCallback(d=>{var h;return(h=t.current.agents.get(d))==null?void 0:h.label},[]),i=y.useCallback(d=>{var p;const h=e.current.find(g=>g.id===d&&g.type==="recapNote");if(!h)return;const f=h.data;return{note:f.note,hue:f.hue,sessionLabel:(p=t.current.agents.get(f.parentId))==null?void 0:p.label}},[]),c=y.useCallback(()=>{var f;const d=(f=n.current)==null?void 0:f.getBoundingClientRect(),h=document.documentElement;return d?{width:d.right-r.current,height:d.bottom}:{width:h.clientWidth,height:h.clientHeight}},[]);return{peekAgent:s,peekLabel:o,peekRecap:i,peekBounds:c}}function Die(e){const t=new Set(e.pins),n=new Map,r=new Map;for(const[s,o]of e.positions)n.set(s,o),t.has(s)&&r.set(s,o);return{positions:n,pinned:r,restored:new Set(n.keys())}}function l$(e){return Object.entries(e??{}).filter(([,t])=>t&&typeof t.x=="number"&&typeof t.y=="number")}function Fie(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=l$(n);return{positions:s,pins:s.map(([o])=>o)}}const r=n;return{positions:l$(r.positions),pins:Array.isArray(r.pins)?r.pins:[]}}function Bie(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 qie(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 iu="agent-dag.layout",lu="agent-dag.layoutFrame",cu="agent-dag.viewport";function Uie(){return Fie(Ge(iu))}function Fi(e,t){Ve(iu,Bie(e,t))}function Hie(){return qie(Ge(lu))}function Y4(e){Ve(lu,JSON.stringify(e))}function Wie(){return kH(Ge(cu))}function zie(e){Ve(cu,JSON.stringify(e))}function Vie(){return{layout:Ge(iu),frame:Ge(lu),viewport:Ge(cu)}}function Gie(e){const t=(n,r)=>r===null?es(n):Ve(n,r);t(iu,e.layout),t(lu,e.frame),t(cu,e.viewport)}function X4(){es(iu),es(cu),es(lu)}function Kie({fitLeft:e,moveCamera:t,currentViewport:n}){const r=y.useState(()=>Die(Uie()))[0],s=y.useRef(r.pinned),o=y.useRef(r.positions),i=y.useRef(new Set),c=y.useRef(""),[d,h]=y.useState(0),f=y.useState(Hie)[0],p=y.useRef(f),[g,w]=y.useState(!1),[k,j]=y.useState(""),v=y.useState(()=>zV(O=>{w(O),O||j(U=>U===lE?U:"")}))[0];y.useEffect(()=>()=>v.close(),[v]),y.useEffect(()=>{if(typeof document>"u")return;const O=()=>document.hidden?v.hold("hidden"):v.release("hidden");return document.addEventListener("visibilitychange",O),()=>document.removeEventListener("visibilitychange",O)},[v]);const b=y.useRef(null),N=()=>({positions:o.current,pinned:s.current,provisional:i.current,layoutSig:c}),S=y.useCallback(()=>{v.open(v.snapshot??DV(N(),Vie(),n())),j(HV),s.current.clear(),o.current.clear(),c.current="",X4(),h(O=>O+1),b.current!=null&&window.clearTimeout(b.current),b.current=window.setTimeout(()=>{b.current=null,Fi(o.current,s.current),p.current&&Y4(p.current),e(500)},80)},[e,n,v]),E=y.useCallback(()=>{const O=v.take();return O?(b.current!=null&&window.clearTimeout(b.current),b.current=null,FV(O,N()),Gie(O.stored),h(U=>U+1),O.viewport&&t(O.viewport,500),j(lE),!0):!1},[t,v]),C=y.useCallback(()=>v.close(),[v]),$=y.useCallback(O=>v.hold(O),[v]),T=y.useCallback(O=>v.release(O),[v]);return{restoredLayout:r,pinnedRef:s,positionsRef:o,provisionalRef:i,lastLayoutSigRef:c,layoutEpoch:d,setLayoutEpoch:h,lastLayoutFrameRef:p,handleRelayout:S,rearrangeUndo:{open:g,said:k,undo:E,dismiss:C,hold:$,release:T}}}function Yie(e,t){const{positionsRef:n,pinnedRef:r}=t,s=y.useRef(null);y.useEffect(()=>(s.current!=null&&window.clearTimeout(s.current),s.current=window.setTimeout(()=>{Fi(n.current,r.current)},1500),()=>{s.current!=null&&window.clearTimeout(s.current)}),[e])}function Xie({nodes:e,edges:t,settled:n,dragging:r,availableWidth:s,availableHeight:o,layout:i,camera:c,rf:d,measuredRef:h,stateRef:f,lastFocusRef:p,primarySelectedIdRef:g,focusAgentRef:w,autoFitDisabledRef:k}){const{lastLayoutFrameRef:j,pinnedRef:v,positionsRef:b,provisionalRef:N,lastLayoutSigRef:S,setLayoutEpoch:E}=i,{applyViewport:C,fitLeft:$,cameraEpochRef:T,lastFitTimeRef:I}=c;y.useEffect(()=>{if(!n||r)return;const O={width:s,height:o};if(!(O.width>0&&O.height>0))return;const U=j.current;if(j.current=O,Y4(O),!U||U.width===O.width&&U.height===O.height)return;const P={direction:"LR",pinned:v.current,measured:h.current,lanes:H1(f.current)},L=p.current&&Date.now()-p.current.at<1500?p.current.id:null;if(!oie(e,t,P,U,O)){const B=T.current,D=window.setTimeout(()=>{var K;T.current===B&&(k.current?L&&((K=p.current)==null?void 0:K.id)===L&&w.current(L):$(500))},80);return()=>window.clearTimeout(D)}const F=L??g.current,A=F?v.current.get(F)??b.current.get(F):void 0;for(const B of Array.from(b.current.keys()))v.current.has(B)||b.current.delete(B);N.current.clear(),S.current="",E(B=>B+1),window.setTimeout(()=>{if(Fi(b.current,v.current),k.current){if(L){w.current(L);return}const B=F?v.current.get(F)??b.current.get(F):void 0;if(A&&B&&(B.x!==A.x||B.y!==A.y)){const D=d.getViewport();T.current+=1,C({x:D.x-(B.x-A.x)*D.zoom,y:D.y-(B.y-A.y)*D.zoom,zoom:D.zoom},0),I.current=Date.now()}return}$(500)},80)},[s,o,n,r,$,d,C])}function Zie(e,t,n,r,s){const o=[];for(const i of e)!wf(i,t)||n.has(i.id)||o.push(i.id+(i.parentId?`>${i.parentId}`:""));return o.sort(),`${o.join("|")}#sv${r}.${s}`}const z1="agent-dag.removedNodes";function Jie(e){try{const t=JSON.parse((e==null?void 0:e.getItem(z1))??"[]");return new Set(Array.isArray(t)?t.filter(n=>typeof n=="string"):[])}catch{return new Set}}function c$(e,t){try{e==null||e.setItem(z1,JSON.stringify([...t]))}catch{}}function Z4(e,t){const n=new Map(e.map(o=>[o.id,o.parentId])),r=new Set(t),s=o=>{if(r.has(o))return!0;const i=new Set([o]);let c=n.get(o);for(;c&&!i.has(c);){if(r.has(c))return r.add(o),!0;i.add(c),c=n.get(c)}return!1};return o=>s(o.id)||s(o.sessionId??o.id)}function Qie(e,t){if(t.size===0)return new Set;const n=[...e],r=Z4(n,t);return new Set(n.filter(r).map(s=>s.id))}function ele(e,t,n){const r=c=>({id:c.id,parentId:c.data.parentId,sessionId:c.data.sessionId}),s=Z4(e.map(r),n),o=e.filter(c=>!s(r(c))),i=new Set(o.map(c=>c.id));return{nodes:o,edges:t.filter(c=>i.has(c.source)&&i.has(c.target))}}function tle(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 nle(e,t){return t.size===0?[]:[...e].filter(n=>t.has(n.id)).map(n=>n.id)}function rle(e){let t=e.kind==="subagent"?e.startedAt:-1/0;const n=e.tools[e.tools.length-1];n&&n.startedAt>t&&(t=n.startedAt);const r=e.prompts[e.prompts.length-1];return r&&r.at>t&&(t=r.at),e.lastOutputAt!=null&&e.lastOutputAt>t&&(t=e.lastOutputAt),t}function sle(e,t,n){let r=null;for(const s of t)e.has(s)||(r??(r=new Map(e)),r.set(s,n));for(const s of e.keys())t.has(s)||(r??(r=new Map(e)),r.delete(s));return r??e}function ale(e,t,n,r){if(n.size===0)return[];let s=1/0;for(const i of r.values())i<s&&(s=i);const o=new Set;for(const i of t){const c=e.get(i);if(!c)continue;const d=rle(c);if(d<=s)continue;const h=[],f=new Set,p=w=>{var k;for(let j=w;j&&!f.has(j);j=(k=e.get(j))==null?void 0:k.parentId)f.add(j),n.has(j)&&h.push(j)};p(c.id),p(c.sessionId);let g=-1/0;for(const w of h)g=Math.max(g,r.get(w)??1/0);if(d>g)for(const w of h)o.add(w)}return[...o]}const Wh="sessionGroup";function ole(e,t){var r,s;if(e.type===Wh)return"transparent";if(Hn((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 Ud=mo;function ile(e){const t=new Map;for(const r of e){const s=r.data;if(!(s!=null&&s.sessionId)||s.exitAt!=null)continue;const o=r.width,i=r.height;if(o==null||i==null)continue;const c=r.position.x,d=r.position.y,h=c+o,f=d+i,p=t.get(s.sessionId);p?(p.minX=Math.min(p.minX,c),p.minY=Math.min(p.minY,d),p.maxX=Math.max(p.maxX,h),p.maxY=Math.max(p.maxY,f)):t.set(s.sessionId,{minX:c,minY:d,maxX:h,maxY:f})}const n=[];for(const[r,s]of t){const o=s.maxX-s.minX+Ud*2,i=s.maxY-s.minY+Ud*2;n.push({id:`group:${r}`,type:Wh,position:{x:s.minX-Ud,y:s.minY-Ud},data:{sessionId:r,w:o,h:i},width:o,height:i,style:{width:o,height:i},zIndex:-1,draggable:!0,selectable:!1,focusable:!1,deletable:!1,connectable:!1})}return n}function lle(e,t){if(!t||!e.agents.get(t))return null;const r=new Set([t]);let s=t;for(;s;){const i=e.agents.get(s);if(!(i!=null&&i.parentId)||r.has(i.parentId))break;r.add(i.parentId),s=i.parentId}let o=!0;for(;o;){o=!1;for(const i of e.agents.values())i.parentId&&r.has(i.parentId)&&!r.has(i.id)&&(r.add(i.id),o=!0)}return r}function cle(e,t){const n=new Set;for(const r of t){const s=lle(e,r);if(s)for(const o of s)n.add(o)}return n.size>0?n:null}function ule({stateRef:e,now:t,removedAgentIds:n,sizeVersion:r,domSizeVersion:s}){return y.useMemo(()=>Zie(e.current.agents.values(),t,n,r,s),[e.current,e.current.revision,t,r,s,n])}function dle({stateRef:e,now:t,availableWidth:n,availableHeight:r,layout:s,measuredRef:o,onBubble:i,settled:c,dragging:d,layoutSig:h,selectedIds:f,openContext:p,historyReplayed:g,removedNodes:w,removedAgentIds:k,dragTick:j,dragPatchRef:v,dragMoveTick:b}){const{pinnedRef:N,positionsRef:S,provisionalRef:E,lastLayoutSigRef:C,restoredLayout:$,layoutEpoch:T}=s,I=y.useMemo(()=>cle(e.current,f),[e.current,e.current.revision,f]),O=y.useMemo(()=>{const D=GG(e.current,t);for(const K of k)D.delete(K);return D},[e.current,e.current.revision,t,k]),U=y.useRef(new Map),P=qz(),{nodes:L,edges:F}=y.useMemo(()=>{const D=mie(e.current,t,n,r,N.current,o.current,U.current,i,c,d,S.current,E.current,h,C,f,I,O,p,g,$.restored);return ele(D.nodes,D.edges,w)},[e.current,e.current.revision,t,n,r,c,d,h,f,I,O,p,j,P,w,T,g]),A=y.useMemo(()=>ile(L),[L]),B=y.useMemo(()=>{const D=[...A,...L],K=v.current;return!K||K.size===0?D:D.map(G=>{const H=K.get(G.id);return H?{...G,position:H}:G})},[A,L,b]);return{spotlightSet:I,visibleAgentIds:O,nodes:L,edges:F,allNodes:B}}function hle(e,t,n){const r=e.x*t.zoom+t.x,s=e.y*t.zoom+t.y,o=(e.x+e.width)*t.zoom+t.x,i=(e.y+e.height)*t.zoom+t.y;return o>0&&r<n.width&&i>0&&s<n.height}function fle({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,hle(s,t,e))return!1;return r}function ple({layoutSig:e,rf:t,stateRef:n,measuredRef:r,pinnedRef:s,positionsRef:o,paneSizeRef:i,lastInteractRef:c,autoFitDisabledRef:d,lastFitTimeRef:h,fitLeft:f}){const p=y.useRef(null),g=y.useRef("");y.useEffect(()=>{const w=setInterval(()=>{if(d.current||Date.now()-c.current<800)return;const k=n.current,j=Date.now(),v=[];for(const N of k.agents.values())wf(N,j)&&v.push({id:N.id});if(v.length===0)return;const b=[];for(const{id:N}of v){const S=r.current.get(N),E=s.current.get(N)??o.current.get(N);!S||!E||b.push({x:E.x,y:E.y,width:S.width,height:S.height})}fle({pane:i.current,viewport:t.getViewport(),boxes:b})&&f(600)},1500);return()=>clearInterval(w)},[t]),y.useEffect(()=>{if(g.current===e)return;const w=g.current;if(g.current=e,!w||d.current)return;Date.now()-h.current>1200&&f(400),p.current&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>{d.current||f(500)},280)},[e,t,f])}function mle({stateRef:e,pinnedRef:t,positionsRef:n,canvasRef:r,clearSelection:s,primarySelectedId:o}){const[i,c]=y.useState(()=>Jie(Li())),[d,h]=y.useState(null),f=y.useMemo(()=>Qie(e.current.agents.values(),i),[e.current,e.current.revision,i]),p=y.useCallback(b=>{const N=e.current.agents.get(b);N&&(c(S=>{const E=new Set(S);return E.add(b),c$(Li(),E),E}),h({id:b,label:N.label}),t.current.delete(b),n.current.delete(b),s())},[s]),g=y.useCallback(()=>{o&&p(o)},[o,p]),w=d&&i.has(d.id)?d:null;y.useEffect(()=>{var b;d&&((b=r.current)==null||b.focus())},[d]);const k=y.useCallback(b=>{const N=[...b];c(S=>{const E=tle(S,N);return E!==S&&c$(Li(),E),E})},[]),j=y.useCallback(()=>{k([...i]),h(null)},[k,i]),v=y.useCallback(()=>{c(new Set),h(null),es(z1)},[]);return{removedNodes:i,lastRemoval:d,removedAgentIds:f,removeNode:p,removeSelectedNode:g,removalNotice:w,bringBack:k,bringBackAll:j,forgetRemovals:v}}function gle({stateRef:e,waitingSessions:t,removedAgentIds:n,removedNodes:r,bringBack:s}){const o=y.useRef(new Map);y.useEffect(()=>{o.current=sle(o.current,r,Date.now());const i=[...nle(t,n),...ale(e.current.agents,n,r,o.current)];i.length>0&&s(i)},[t,n,r,s])}function yle({waiting:e,running:t,connected:n=!0}){return{title:e>0?`(${e}) ${Lt}`:Lt,icon:n?e>0?"waiting":t>0?"running":"idle":"offline"}}const J4=Object.freeze({offline:"/state/favicon-error.svg",waiting:"/state/favicon-waiting.svg",running:"/state/favicon-syncing.svg",idle:"/favicon.svg"}),Q4=Object.freeze({offline:"/state/favicon-error-32.png",waiting:"/state/favicon-waiting-32.png",running:"/state/favicon-syncing-32.png",idle:"/favicon.ico"}),wle=Object.freeze([...new Set([...Object.values(J4),...Object.values(Q4)])]),sk=new Map;function u$(e){return sk.get(e)??e}async function xle(e,t=n=>fetch(n)){await Promise.all(e.map(async n=>{if(!sk.has(n))try{const r=await t(n),s=(r.headers.get("Content-Type")??"").split(";")[0].trim();if(!r.ok||!s.startsWith("image/"))return;sk.set(n,`data:${s};base64,${vle(new Uint8Array(await r.arrayBuffer()))}`)}catch{}}))}function vle(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function ble({stateRef:e,waitingSessions:t,live:n}){const r=y.useMemo(()=>GW(e.current.agents.values()),[e.current,e.current.revision]),s=y.useRef(null);y.useEffect(()=>{n&&xle(wle)},[n]),y.useEffect(()=>{const o=yle({waiting:t.length,running:r,connected:n}),i=s.current;s.current=o,(i==null?void 0:i.title)!==o.title&&(document.title=o.title),(i==null?void 0:i.icon)!==o.icon&&eD(o.icon)},[t.length,r,n])}function eD(e){const t=document.querySelector('link[rel="icon"][type="image/svg+xml"]');t&&(t.href=u$(J4[e]));const n=document.querySelector('link[rel="icon"][sizes="32x32"]');n&&(n.href=u$(Q4[e]))}const kle=1200,jle=1e3;function Pb(e){return e.lastDeckFitAt>0&&e.at-e.lastDeckFitAt<kle?!1:e.hasSourceEvent?!0:e.lastCanvasInputAt>0&&e.at-e.lastCanvasInputAt<jle}function Nle({applyViewport:e,lastFitTimeRef:t,cameraEpochRef:n,disableAutoFit:r,markInteract:s,canvasRef:o,applyZoom:i}){const c=y.useState(()=>Wie())[0];y.useEffect(()=>{if(!c)return;const k=window.setTimeout(()=>{try{e(c,0)}catch{}t.current=Date.now()},60);return()=>window.clearTimeout(k)},[e,c]);const d=y.useRef(null),h=y.useRef(0),f=y.useCallback(()=>{h.current=Date.now()},[]),p=y.useCallback(k=>({hasSourceEvent:!!k,at:Date.now(),lastDeckFitAt:t.current,lastCanvasInputAt:h.current}),[]);return{restoredViewport:c,markCanvasInput:f,onMoveStart:k=>{Ca(),Pb(p(k))&&(n.current+=1),Pb(p(k))&&r()},onMove:(k,j)=>{var v;s(),Pb(p(k))&&r(),(v=o.current)==null||v.style.setProperty("--zoom",String(j.zoom)),i(j.zoom)==="detail"&&Ca(),d.current&&window.clearTimeout(d.current),d.current=window.setTimeout(()=>zie(j),250)}}}function Sle({clearSelection:e,selectAgent:t,detailOpen:n,setDetailOpen:r,detailShown:s,focusAgent:o,draggingRef:i,lodRef:c}){const d=y.useRef(o);d.current=o;const[h]=y.useState(()=>YI({focus:j=>d.current(j),setTimeout:(j,v)=>window.setTimeout(j,v),clearTimeout:j=>window.clearTimeout(j)}));return y.useEffect(()=>()=>h.cancel(),[h]),{onNodeClick:(j,v)=>{if(v.type==="sessionGroup"){h.cancel(),e();return}const b=v.type==="recapNote"?v.data.parentId:v.id;t(b,j.shiftKey,!1),!j.shiftKey&&(n&&r(!1),Yc()?h.hold(b):s?window.setTimeout(()=>{try{o(b)}catch{}},80):o(b))},onPaneClick:()=>{h.cancel(),Ca(),e()},onNodeDoubleClick:(j,v)=>{if(v.type!=="agent"&&v.type!=="recapNote")return;h.cancel();const b=v.type==="recapNote"?v.data.parentId:v.id;t(b,!1),window.setTimeout(()=>{try{o(b)}catch{}},80)},onNodeMouseEnter:(j,v)=>{v.type!=="agent"&&v.type!=="recapNote"||i.current||c.current==null||c.current==="detail"||z4(v.id,j.currentTarget)},onNodeMouseLeave:(j,v)=>Ca(v.id)}}function _le({settleAt:e,now:t,take:n,schedule:r,cancel:s}){let o=null;const i=()=>{o!=null&&s(o),o=null};return{read(c,d){i();const h=e()-t();if(h>0){o=r(()=>{o=null,n(c,d)},h);return}n(c,d)},dispose:i}}function Ele(e){const t=y.useRef(null),n=y.useRef(null),[r,s]=y.useState({w:0,h:0});return y.useEffect(()=>{const o=n.current;if(!o||typeof ResizeObserver>"u")return;const i=_le({settleAt:()=>(e==null?void 0:e.current)??0,now:()=>performance.now(),take:(d,h)=>s(f=>Math.abs(f.w-d)>40||Math.abs(f.h-h)>40?{w:d,h}:f),schedule:(d,h)=>window.setTimeout(d,h),cancel:d=>window.clearTimeout(d)}),c=new ResizeObserver(d=>{var f;const h=(f=d[0])==null?void 0:f.contentRect;h&&(t.current={width:h.width,height:h.height},i.read(h.width,h.height))});return c.observe(o),t.current={width:o.clientWidth,height:o.clientHeight},s({w:o.clientWidth,h:o.clientHeight}),()=>{c.disconnect(),i.dispose()}},[]),{canvasRef:n,canvasSize:r,paneSizeRef:t}}function Cle(e){const t=Rt(),n=y.useRef(new Map),r=y.useRef(0),s=y.useRef(new Map),[o,i]=y.useState(0),[c,d]=y.useState(0),h=y.useRef(null),f=y.useCallback(()=>{h.current=null;let g=!1;for(const k of t.getState().nodeInternals.values()){if(k.type===Wh)continue;const j=k.width,v=k.height;if(j==null||v==null)continue;const b=s.current.get(k.id);(!b||Math.abs(b.width-j)>4||Math.abs(b.height-v)>4)&&(s.current.set(k.id,{width:j,height:v}),n.current.set(k.id,{width:j,height:v}),g=!0)}if(g&&(r.current+=1,i(r.current)),e.current)return;let w=!1;for(const k of document.querySelectorAll(".react-flow__node[data-id]")){if(k.classList.contains(`react-flow__node-${Wh}`))continue;const j=k.getAttribute("data-id");if(!j)continue;const v=k.offsetWidth,b=k.offsetHeight;if(!v||!b)continue;const N=n.current.get(j);(!N||Math.abs(N.width-v)>4||Math.abs(N.height-b)>4)&&(n.current.set(j,{width:v,height:b}),w=!0)}w&&d(k=>k+1)},[t,e]),p=y.useCallback(()=>{h.current||(h.current=document.visibilityState==="hidden"?{frame:0,timer:window.setTimeout(f,32)}:{frame:requestAnimationFrame(f),timer:0})},[f]);return y.useEffect(()=>{const g=t.subscribe(p);return p(),()=>{g();const w=h.current;w&&(cancelAnimationFrame(w.frame),window.clearTimeout(w.timer),h.current=null)}},[t,p]),y.useEffect(p),{measuredRef:n,measuredVersionRef:r,sizeVersion:o,domSizeVersion:c}}function Tle(){const[e,t]=y.useState(!1);return y.useEffect(()=>{const n=window.setTimeout(()=>t(!0),2500);return()=>window.clearTimeout(n)},[]),e}function Rle(){const e=y.useRef(null);return y.useEffect(()=>{let t=-1/0;const n=()=>{t=performance.now()},r=s=>{e.current=performance.now()-t<250?s.target:null};return window.addEventListener("pointerdown",n,!0),window.addEventListener("focusin",r,!0),()=>{window.removeEventListener("pointerdown",n,!0),window.removeEventListener("focusin",r,!0)}},[]),e}const dc=[{id:"general",label:"General"},{id:"reading",label:"Text & density"},{id:"notifications",label:"Notifications"},{id:"sounds",label:"Sounds"}];function Ale(e){return Math.max(0,dc.findIndex(t=>t.id===e))}const d$="settings-tab-";function Mle(e,t){return e!=null&&e.startsWith(d$)?e===`${d$}${t}`?null:t:null}const $le={open:!1,section:"general"};function Lle(e,t){return{open:!0,section:t??e.section}}function Ole(e){return e.key===","&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey}function Ile(e){return yf(e)?"⌘,":"Ctrl+,"}const Jf={light:{name:"Light",colorScheme:"light"},dark:{name:"Dark",colorScheme:"dark"},"rider-black":{name:"Rider Black",colorScheme:"dark"},"vscode-black":{name:"VS Code Black",colorScheme:"dark"},omarchy:{name:"Omarchy",colorScheme:"dark"},matrix:{name:"Matrix",colorScheme:"dark"},"black-contrast":{name:"Black Contrast",colorScheme:"dark"},"white-contrast":{name:"White Contrast",colorScheme:"light"},"catppuccin-mocha":{name:"Catppuccin Mocha",colorScheme:"dark"},"gruvbox-dark":{name:"Gruvbox Dark",colorScheme:"dark"},"gruvbox-light":{name:"Gruvbox Light",colorScheme:"light"},"gruvbox-material":{name:"Gruvbox Material",colorScheme:"dark"}},wa=Object.keys(Jf);function ak(e){return wa[(wa.indexOf(e)+1)%wa.length]}const tD="agent-dag.theme";function Ple(e,t=!1){return typeof e=="string"&&Object.hasOwn(Jf,e)?e:"rider-black"}function Dle(){return Ple(Ge(tD))}function Fle({pointerFocusRef:e,nodesRef:t,stateRef:n,primarySelectedIdRef:r,providersRef:s,soundOnRef:o,keyHelpOpenRef:i,modalOpenRef:c,waitingCursorRef:d,removeSelectedRef:h,activateSoundRef:f,clearSelection:p,selectAgent:g,focusAgent:w,stepAgent:k,focusSession:j,requestClear:v,handleRelayout:b,undoRearrange:N,handleFit:S,togglePause:E,toggleSessionList:C,toggleAccountsPanel:$,setDetailOpen:T,setUsageHistoryOpen:I,setUsagePanelOpen:O,setMachinePanelOpen:U,setBrowserWatchOpen:P,setKeyHelpOpen:L,setTheme:F,openSettings:A}){y.useEffect(()=>{const B=D=>{var V,Z;const K=D.target,G={tagName:K==null?void 0:K.tagName,isContentEditable:K==null?void 0:K.isContentEditable,role:(V=K==null?void 0:K.getAttribute)==null?void 0:V.call(K,"role"),type:K==null?void 0:K.type,pointerFocused:K!=null&&K===e.current};if(D.key==="Escape"){const W=uz({overlayOpen:jn.depth()>0,typing:xo(G)});W==="dismiss"?jn.dismissTop():W==="blur"?K==null||K.blur():(bie(G)&&(K==null||K.blur()),p());return}if(D.key===","&&Ole(D)){if(xo(G)||Zd({appModal:c.current,dialogDepth:jn.dialogDepth()}))return;D.preventDefault(),D.repeat||A();return}if(VV(D)){if(xo(G)||Zd({appModal:c.current,dialogDepth:jn.dialogDepth()}))return;!D.repeat&&N()&&D.preventDefault();return}if(uf(D))return;const H=W1(K)?(Z=K==null?void 0:K.getAttribute)==null?void 0:Z.call(K,"data-id"):null,q=H&&t.current.some(W=>W.id===H)?H:null,M=xie(D,q);if(M.kind==="activate"){D.preventDefault(),g(M.nodeId,M.additive);return}if(M.kind!=="node"&&!TI(D.key,m0())){if(bz({key:D.key,sheetOpen:i.current,target:G})){D.repeat||L(!1);return}if(!(M.nodeId==null&&xz(G,D.key))&&!vz({key:D.key,modalOpen:Zd({appModal:c.current,dialogDepth:jn.dialogDepth()}),sheetOpen:i.current})&&!(D.repeat&&!/^[ jkJK]$/.test(D.key))){if(D.key===" "&&(D.preventDefault(),D.repeat||E()),(D.key==="c"||D.key==="C")&&v("shortcut"),(D.key==="r"||D.key==="R")&&b(),(D.key==="f"||D.key==="F")&&S(),(D.key==="z"||D.key==="Z")&&r.current&&w(r.current),D.key==="Delete"&&h.current(),(D.key==="l"||D.key==="L")&&C(),D.key==="d"||D.key==="D")if(r.current)T(W=>!W);else{const W=d0(n.current.agents.values());W.length>0?j(W[0].id):k(1)}if((D.key==="h"||D.key==="H")&&I(W=>!W),(D.key==="u"||D.key==="U")&&O(W=>!W),(D.key==="a"||D.key==="A")&&s.current.claude&&$(),(D.key==="j"||D.key==="J")&&k(1),(D.key==="k"||D.key==="K")&&k(-1),D.key==="w"||D.key==="W"){const W=VW(d0(n.current.agents.values()),d.current);W&&(d.current=W.id,j(W.id))}(D.key==="t"||D.key==="T")&&F(ak),(D.key==="m"||D.key==="M")&&o.current!==null&&f.current(D.shiftKey),(D.key==="s"||D.key==="S")&&U(W=>!W),(D.key==="b"||D.key==="B")&&P(W=>!W),(D.key==="v"||D.key==="V")&&A("sounds"),D.key==="?"&&L(W=>!W)}}};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[v,b,N,S,p,g,k,j,w,E])}function Ble(){var e,t;return((t=(e=document.activeElement)==null?void 0:e.matches)==null?void 0:t.call(e,":focus-visible"))===!0}function qle({sessionListShown:e,usageShown:t,machineShown:n,accountsShown:r,detailShown:s,primarySelectedId:o,canvasRef:i}){const c={sessionList:y.useRef(null),usage:y.useRef(null),accounts:y.useRef(null),machine:y.useRef(null)},d=h=>()=>{Ble()&&h()};return{toggles:c,sessionList:d(Ts(!e,c.sessionList)),usage:d(Ts(!t,c.usage)),machine:d(Ts(!n,c.machine)),accounts:d(Ts(!r,c.accounts)),detail:d(Ts(!s,()=>{var h,f;o&&H4(o),Vn(((h=document.activeElement)==null?void 0:h.tagName)??null)&&((f=i.current)==null||f.focus({preventScroll:!0}))}))}}function Ule({nodes:e,stateRef:t,pinnedRef:n,positionsRef:r,draggingRef:s,dragPatchRef:o,setDragging:i,setDragMoveTick:c,setDragTick:d,endBubble:h,markInteract:f,disableAutoFit:p,beginTrashDrag:g,trackTrashDrag:w,endTrashDrag:k,removeNode:j}){const v=y.useRef(null);return{onNodeDragStart:(E,C)=>{var $,T;if(C){if(Ca(),h(),s.current=!0,o.current=new Map,i(!0),g(C.type==="agent"?(($=t.current.agents.get(C.id))==null?void 0:$.label)??"":null),f(),p(),C.type==="sessionGroup"){const I=(T=C.data)==null?void 0:T.sessionId,O=new Map;if(I)for(const U of e){const P=U.data;(P==null?void 0:P.sessionId)===I&&O.set(U.id,{x:U.position.x,y:U.position.y})}v.current={start:{x:C.position.x,y:C.position.y},members:O};return}n.current.set(C.id,{x:C.position.x,y:C.position.y})}},onNodeDrag:(E,C)=>{var $;if(C){if(f(),C.type==="agent"&&w(E),C.type==="sessionGroup"){const T=v.current;if(!T)return;const I=C.position.x-T.start.x,O=C.position.y-T.start.y;for(const[P,L]of T.members){const F={x:L.x+I,y:L.y+O};n.current.set(P,F),r.current.set(P,F)}const U=o.current;if(U){for(const[P,L]of T.members)U.set(P,{x:L.x+I,y:L.y+O});U.set(C.id,{x:C.position.x,y:C.position.y})}c(P=>P+1);return}n.current.set(C.id,{x:C.position.x,y:C.position.y}),r.current.set(C.id,{x:C.position.x,y:C.position.y}),($=o.current)==null||$.set(C.id,{x:C.position.x,y:C.position.y}),c(T=>T+1)}},onNodeDragStop:(E,C)=>{f();const $=k(E,(C==null?void 0:C.type)==="agent");if(s.current=!1,o.current=null,i(!1),d(T=>T+1),!C){v.current=null,Fi(r.current,n.current);return}if(C.type==="sessionGroup"){const T=v.current;if(T){const I=C.position.x-T.start.x,O=C.position.y-T.start.y;for(const[U,P]of T.members){const L={x:P.x+I,y:P.y+O};n.current.set(U,L),r.current.set(U,L)}}v.current=null,Fi(r.current,n.current),d(I=>I+1);return}if(n.current.set(C.id,{x:C.position.x,y:C.position.y}),r.current.set(C.id,{x:C.position.x,y:C.position.y}),$){j(C.id);return}Fi(r.current,n.current)}}}function Hle(e){if(e==null)return{kind:"unknown",lead:"No data yet. Start a Claude Code or Codex session — it appears here as soon as the deck sees its first event.",workspace:null,tail:""};const t=e.trim();return t===""?{kind:"machine",lead:"No data yet. Start a Claude Code or Codex session anywhere on this machine — this deck is unscoped and captures every workspace.",workspace:null,tail:""}:{kind:"scoped",lead:"No data yet. This deck only captures sessions running under",workspace:t,tail:" — start one there, or restart it without --workspace/--scope to watch the whole machine."}}function nD({active:e=!1}){const[t,n]=y.useState(()=>typeof document>"u"||!document.hidden);return y.useEffect(()=>{const r=()=>n(!document.hidden);return document.addEventListener("visibilitychange",r),()=>document.removeEventListener("visibilitychange",r)},[]),a.jsx("div",{className:"empty-symbol","aria-hidden":"true","data-active":e&&t,children:a.jsxs("svg",{width:"32",height:"32",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[a.jsx("path",{d:"m6 8 4 4-4 4"}),a.jsx("path",{className:"empty-cursor",d:"M13 16h5"})]})})}function Wle({reservedRight:e=0}){return a.jsx("div",{className:"empty-stage",style:{right:e},children:a.jsxs("div",{className:"empty-hero",children:[a.jsx(nD,{}),a.jsxs("h2",{children:["Too many ",Lt," tabs are open"]}),a.jsxs("p",{children:["This browser keeps at most six live connections to one address, and other ",a.jsx("code",{children:Lt})," tabs are holding them. Close one and this tab connects on its own."]})]})})}function zle({live:e,everConnected:t,providers:n,workspace:r,onTour:s,reservedRight:o=0}){const i=!e;return a.jsx("div",{className:"empty-stage",style:{right:o},children:a.jsxs("div",{className:"empty-hero",children:[a.jsx(nD,{active:e}),i?a.jsxs(a.Fragment,{children:[a.jsx("h2",{children:t?"Disconnected from server":"Server unreachable"}),a.jsxs("p",{children:[t?"This page lost its connection to ":"This page cannot reach ",a.jsx("code",{children:Lt}),". Check that it is still running in your terminal — the page picks up again on its own."]})]}):Vle(n,r),!i&&a.jsxs("div",{className:"empty-actions",role:"group","aria-label":"Explore ccdeck",children:[a.jsx("button",{type:"button",className:"btn empty-tour",onClick:s,children:"Take the tour"}),a.jsx(Ic,{film:"tour",action:!0})]})]})})}function Vle(e,t){const n=Hle(t);return a.jsxs(a.Fragment,{children:[a.jsx("h2",{children:"Waiting for Claude Code or Codex"}),n.kind==="scoped"?a.jsxs("p",{children:[n.lead," ",a.jsx("code",{children:n.workspace}),n.tail]}):a.jsxs("p",{children:["Run ",a.jsx("code",{children:"claude"})," or ",a.jsx("code",{children:"codex"})," in any folder. As soon as a session sends an event, a node appears here and grows as subagents fork and tools are called."]}),a.jsxs("details",{className:"empty-help",children:[a.jsx("summary",{children:"Session not showing up?"}),uY(e).map(r=>a.jsx("p",{className:"hint-row",children:r.spans.map((s,o)=>s.code?a.jsx("code",{children:s.text},o):a.jsx("span",{children:s.text},o))},r.provider))]})]})}const Gle=1;function Kle(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 Yle(e,t,n){const r=e.agents.get(t);if(!r)return null;const s=[];for(const o of e.agents.values())o.sessionId===t&&s.push(o);return{schemaVersion:Gle,exportedAt:n,sessionId:t,label:r.label,cwd:r.cwd,startedAt:r.startedAt,endedAt:r.endedAt,model:r.model,agents:s.map(o=>({id:o.id,kind:o.kind,label:o.label,parentId:o.parentId,state:o.state,startedAt:o.startedAt,endedAt:o.endedAt,model:o.model,cwd:o.cwd,usage:o.usage,prompts:o.prompts,tools:o.tools.map(Kle)}))}}function Xle(e,t){const n=(e||"session").replace(/[^a-z0-9._-]/gi,"_");return`${Lt}-${n}-${Sh(t,8)}.json`}const rD={file:"📁",shell:"⚡",web:"🌐",agent:"🤖",task:"📋",plan:"🧭",mcp:"🔌",other:"✨"},Zle={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 Jle({cat:e}){return a.jsx("svg",{className:"cat-glyph",width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:a.jsx("path",{d:Zle[e]})})}const zh={file:"file",shell:"shell",web:"web",agent:"agent",task:"task",plan:"plan",mcp:"mcp",other:"other"},sD=vI;function Qle({agent:e,now:t,onOpenTool:n,onShowSummary:r,onExportSession:s,onRemove:o,singleKeys:i=!0}){var v;const c=`${e.synthetic?"≥ ":""}${Vi(e.startedAt,e.endedAt,t)}`,d=En(e),h=d.total>0,f=e.usage.inputTokens+e.usage.outputTokens,p=new Map;for(const[b,N]of e.toolCountByName??[]){const S=sD(b);p.set(S,(p.get(S)??0)+N)}const g=e.toolErrorCount??0,w=e.tools.filter(b=>!b.endedAt).length,k=Array.from(p.entries()).sort((b,N)=>N[1]-b[1]),j=p.has("mcp")?j7(((v=e.toolCountByName)==null?void 0:v.keys())??[]):null;return a.jsxs(a.Fragment,{children:[a.jsxs("header",{className:"detail-hero",children:[a.jsxs("div",{className:"hero-line",children:[a.jsx("span",{className:`state-pill state-${e.state}`,children:e.state==="active"?"live":e.state}),a.jsx("h2",{className:"hero-title",title:e.cwd??e.label,children:e.label})]}),a.jsxs("div",{className:"hero-meta",children:[a.jsx("span",{className:"hero-meta-item",children:e.kind==="root"?"session":"subagent"}),a.jsx("span",{className:"hero-sep",children:"·"}),a.jsx("span",{className:"hero-meta-item",title:`started ${new Date(e.startedAt).toLocaleString()}`,children:c}),e.model&&(()=>{const b=Pk(e);return a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"hero-sep",children:"·"}),a.jsxs("span",{className:"model-chip","data-family":lf(e.model),title:b.length>0?`${e.model}
|
|
97
|
-
spend on this panel also covers:
|
|
98
|
-
${b.join(`
|
|
99
|
-
`)}`:e.model,children:[rs(e.model),b.length>0?` +${b.length}`:""]})]})})()]}),h&&a.jsxs("div",{className:"hero-cost",children:[a.jsxs("div",{className:"hero-cost-headline",children:[a.jsx("span",{className:"hero-cost-value",children:Ye(d.total)}),a.jsx("span",{className:"hero-cost-label",children:"spend"})]}),a.jsx(t1,{cost:d})]}),a.jsxs("div",{className:"hero-actions",children:[e.kind==="root"&&e.state==="done"&&r&&a.jsx("button",{type:"button",className:"btn hero-action-btn",onClick:()=>r(e.sessionId),title:"Reopen the end-of-session recap modal",children:"Show recap"}),s&&a.jsx("button",{type:"button",className:"btn hero-action-btn",onClick:()=>s(e.sessionId),title:"Download this session as JSON",children:"Export JSON"}),o&&a.jsx("button",{type:"button",className:"btn hero-action-btn",onClick:o,title:e.kind==="root"?`Take this session's cards off the board (Delete). The session carries on; ${dn("the session list","L",i)} brings it back`:`Take this card and the ones under it off the board (Delete). ${dn("The session list","L",i)} brings it back`,children:"Remove from board"})]})]}),(()=>{const b=df(e);if(!b)return null;const N=jh(b.at,t),S=b.kind==="recap"?"Recap":ja(b.kind).replace(/^./,E=>E.toUpperCase());return a.jsxs("section",{className:"detail-section",children:[a.jsxs("h3",{children:[S," ",a.jsx("span",{className:"section-count",title:N.title,children:N.label})]}),a.jsx("p",{className:"detail-recap",title:hf(b),children:b.text}),b.reply&&a.jsxs("p",{className:"detail-recap detail-note-reply",children:["Suggested reply: “",b.reply,"”"]})]})})(),e.tools.length>0&&a.jsxs("section",{className:"detail-section",children:[a.jsx("h3",{children:"Activity"}),a.jsxs("div",{className:"activity-row",children:[a.jsxs("div",{className:"activity-counters",children:[a.jsxs("span",{className:"ac-item",children:[a.jsx("b",{children:e.toolCount})," calls"]}),w>0&&a.jsxs("span",{className:"ac-item ac-live",children:[a.jsx("b",{children:w})," live"]}),g>0&&a.jsxs("span",{className:"ac-item ac-err",children:[a.jsx("b",{children:g})," err"]})]}),a.jsx("div",{className:"cat-strip",children:k.map(([b,N])=>{const S=b==="mcp"?j:null,E=S==null?void 0:S.hue,C=`${N} ${zh[b]} call${N===1?"":"s"}`;return a.jsxs("span",{className:`cat-chip cat-${b}${E!=null?" mcp-hue":""}`,style:E!=null?{"--mcp-hue":E}:void 0,title:S?`${C}, all to ${S.label}`:C,children:[a.jsx("span",{className:"cat-emoji","aria-hidden":!0,children:rD[b]}),a.jsx("span",{className:"cat-name",children:zh[b]}),a.jsx("span",{className:"cat-count",children:N}),S&&a.jsx("span",{className:"cat-server",children:S.label})]},b)})})]})]}),f>0&&a.jsxs("section",{className:"detail-section",children:[a.jsx("h3",{children:"Tokens"}),a.jsxs("div",{className:"tokens-grid",children:[a.jsxs("div",{children:[a.jsx("span",{className:"k",children:"in"}),a.jsx("b",{title:e.usage.inputTokens.toLocaleString(),children:ut(e.usage.inputTokens)})]}),a.jsxs("div",{children:[a.jsx("span",{className:"k",children:"out"}),a.jsx("b",{title:e.usage.outputTokens.toLocaleString(),children:ut(e.usage.outputTokens)})]}),a.jsxs("div",{children:[a.jsx("span",{className:"k",children:"cache r"}),a.jsx("b",{title:e.usage.cacheReadTokens.toLocaleString(),children:ut(e.usage.cacheReadTokens)})]}),a.jsxs("div",{children:[a.jsx("span",{className:"k",children:"cache c"}),a.jsx("b",{title:e.usage.cacheCreateTokens.toLocaleString(),children:ut(e.usage.cacheCreateTokens)})]})]})]}),a.jsxs("section",{className:"detail-section",children:[a.jsx("h3",{children:"Identity"}),a.jsxs("div",{children:[e.cwd&&a.jsxs("div",{className:"row",children:[a.jsx("span",{className:"k",children:"cwd"}),a.jsx("span",{className:"v",title:e.cwd,children:e.cwd})]}),a.jsxs("div",{className:"row",children:[a.jsx("span",{className:"k",children:"session"}),a.jsxs("span",{className:"v",children:[e.sessionId.slice(0,12),"…"]})]}),e.parentId&&a.jsxs("div",{className:"row",children:[a.jsx("span",{className:"k",children:"parent"}),a.jsxs("span",{className:"v",children:[e.parentId.slice(0,12),"…"]})]})]})]}),e.prompts.length>0&&a.jsxs("section",{className:"detail-section",children:[a.jsxs("h3",{children:["Prompts ",a.jsx("span",{className:"section-count",children:WO(e.prompts).length})]}),a.jsx("div",{className:"prompts",children:ece(e.prompts).reverse().map(({pr:b,key:N})=>{const S=jh(b.at,t),E=sf(b.text);return E?a.jsxs("details",{className:"prompt-entry prompt-injected",children:[a.jsxs("summary",{children:[a.jsx("span",{className:"prompt-time",title:S.title,children:S.label}),a.jsx("span",{className:"prompt-injected-label",children:E.label})]}),E.detail&&a.jsx("div",{className:"prompt-injected-detail",children:E.detail})]},N):a.jsxs("div",{className:"prompt-entry",children:[a.jsx("div",{className:"prompt-time",title:S.title,children:S.label}),a.jsx("div",{className:"prompt-text",children:b.text})]},N)})})]}),a.jsxs("section",{className:"detail-section",children:[a.jsxs("h3",{children:["Tool calls ",a.jsx("span",{className:"section-count",children:e.tools.length})]}),e.tools.length===0&&a.jsx("div",{className:"empty",children:"No tool calls yet."}),a.jsx("div",{children:e.tools.slice().reverse().map(b=>a.jsx(nce,{t:b,onClick:()=>n(e.id,b.id)},b.id))})]})]})}function ece(e){const t=new Map;return e.map(n=>{const r=t.get(n.at)??0;return t.set(n.at,r+1),{pr:n,key:r===0?String(n.at):`${n.at}:${r}`}})}const tce={inflight:"in-flight",done:"done",err:"error"};function nce({t:e,onClick:t}){const n=e.endedAt==null?"inflight":e.ok===!1?"err":"done",r=uI(e,"…");return a.jsxs("button",{className:"tool clickable",title:e.inputPreview||e.name,onClick:t,children:[a.jsxs("span",{className:"name",children:[a.jsx("span",{className:`status-dot ${n}`,"aria-hidden":!0}),a.jsx("span",{className:"vis-hidden",children:tce[n]}),e.name]}),a.jsx("span",{style:{color:"var(--muted)"},children:r})]})}function rce(e,t){const n=Yle(e,t,new Date().toISOString());if(!n)return;const r=JSON.stringify(n,null,2),s=new Blob([r],{type:"application/json"}),o=URL.createObjectURL(s),i=document.createElement("a");i.href=o,i.download=Xle(n.label,t),document.body.appendChild(i),i.click(),document.body.removeChild(i),setTimeout(()=>URL.revokeObjectURL(o),1e3)}function sce({selected:e,now:t,openTool:n,setSummaryFor:r,onClose:s,stateRef:o,removeSelectedNode:i}){Jt("detail-panel");const c=Cn();return a.jsxs("aside",{className:"detail","aria-label":"Detail",children:[a.jsx("button",{type:"button",className:"glyph-btn detail-close",title:"Close panel","aria-label":"Close detail panel",onClick:s,children:"×"}),a.jsx(Qle,{agent:e,now:t,onOpenTool:n,onShowSummary:r,onExportSession:d=>rce(o.current,d),onRemove:i,singleKeys:c})]})}const ace=450,oce=400,ice=100,Hd=8,lce={right:"hint hint-right",left:"hint hint-left",below:"hint hint-below",above:"hint hint-above"},nc=8;let _s=null,h$=-1/0;function cce(e,t,n){return n||e-t<oce}function uce(e,t,n,r,s=null){const o=Math.max(nc,((s==null?void 0:s.left)??0)+nc),i=Math.min(window.innerWidth,(s==null?void 0:s.right)??1/0)-n-nc,c=p=>Math.max(o,Math.min(p,i)),d=p=>Math.max(nc,Math.min(p,window.innerHeight-r-nc)),h=t.top+t.height/2-r/2,f=t.left+t.width/2-n/2;return e==="right"?{left:t.right+Hd,top:d(h)}:e==="left"?{left:t.left-Hd-n,top:d(h)}:e==="above"?{left:c(f),top:t.top-Hd-r}:{left:c(f),top:t.bottom+Hd}}const dce={chrome:"",dialog:" hint-over-dialog"};function ll(e,t="chrome"){const[n,r]=y.useState(null),s=y.useRef(void 0),o=y.useRef(void 0),i=y.useRef(null),c=y.useCallback(()=>{window.clearTimeout(s.current),window.clearTimeout(o.current),r(w=>(w&&(h$=performance.now()),null))},[]),d=y.useCallback((w,k,j)=>{window.clearTimeout(s.current),window.clearTimeout(o.current);const v=_s!==null,b=cce(performance.now(),h$,v),N=()=>{var E;_s&&_s!==c&&_s(),_s=c;const S=t==="dialog"?((E=w.closest('[role="dialog"]'))==null?void 0:E.getBoundingClientRect())??null:null;r({spec:k,box:w.getBoundingClientRect(),within:S,instant:b})};j||b?N():s.current=window.setTimeout(N,ace)},[c,t]),h=y.useCallback(()=>{window.clearTimeout(s.current),window.clearTimeout(o.current),o.current=window.setTimeout(c,ice)},[c]),f=n!==null;y.useEffect(()=>{if(!f)return;const w=jn.push(c,0,"popover");return window.addEventListener("resize",c),window.addEventListener("scroll",c,!0),()=>{w(),window.removeEventListener("resize",c),window.removeEventListener("scroll",c,!0),_s===c&&(_s=null)}},[f,c]),y.useEffect(()=>()=>{window.clearTimeout(s.current),window.clearTimeout(o.current),_s===c&&(_s=null)},[c]),y.useLayoutEffect(()=>{const w=i.current;if(!w||!n)return;const{width:k,height:j}=w.getBoundingClientRect(),v=uce(e,n.box,k,j,n.within);w.style.left=`${v.left}px`,w.style.top=`${v.top}px`,w.style.visibility="visible"},[n,e]);const p=y.useCallback(w=>({onPointerEnter:k=>{w&&k.pointerType==="mouse"&&d(k.currentTarget,w,!1)},onPointerLeave:h,onPointerDown:c,onFocus:k=>{w&&k.currentTarget.matches(":focus-visible")&&d(k.currentTarget,w,!0)},onBlur:c}),[d,h,c]),g=n&&yt.createPortal(a.jsxs("span",{ref:i,className:lce[e]+dce[t],"data-instant":n.instant||void 0,style:{left:0,top:0,visibility:"hidden"},"aria-hidden":!0,onPointerEnter:()=>window.clearTimeout(o.current),onPointerLeave:c,children:[a.jsxs("span",{className:"hint-head",children:[a.jsx("span",{className:"hint-label",children:n.spec.label}),n.spec.keys&&a.jsx("kbd",{className:"hint-key",children:n.spec.keys})]}),n.spec.detail&&a.jsx("span",{className:"hint-detail",children:n.spec.detail})]}),document.body);return{bind:p,node:g}}function aD(e,t){return e&&(t||!e.single)?e:void 0}function hce(e,t,n){var i;const r=(i=aD(e.key,t))==null?void 0:i.cap,s=e.hint??e.label;return r!=null||e.detail!=null||s!==e.label||!n?{label:s,keys:r,detail:e.detail}:null}const oD={stripe:"rail-btn rail-btn-stripe",dock:"rail-btn rail-btn-dock",bar:"rail-btn rail-btn-bar"},fce={left:"edge-rail edge-rail-left",right:"edge-rail edge-rail-right"},pce={vertical:"ArrowDown",horizontal:"ArrowRight"},mce={vertical:"ArrowUp",horizontal:"ArrowLeft"};function iD(e,t){const[n,r]=y.useState(0),s=Math.min(n,Math.max(0,e-1)),o=y.useCallback(i=>{const c=Array.from(i.currentTarget.querySelectorAll("button[data-rail-item]")),d=c.indexOf(document.activeElement);if(d<0)return;let h=-1;i.key===pce[t]?h=(d+1)%c.length:i.key===mce[t]?h=(d-1+c.length)%c.length:i.key==="Home"?h=0:i.key==="End"&&(h=c.length-1),!(h<0)&&(i.preventDefault(),i.stopPropagation(),r(h),c[h].focus())},[t]);return{active:s,setCurrent:r,onKeyDown:o}}let Si=null;function V1(e){y.useLayoutEffect(()=>{var s,o;Si&&document.activeElement===document.body&&((o=(s=e.current)==null?void 0:s.querySelector(`[data-rail-item="${Si}"]`))==null||o.focus()),Si=null;const t=i=>{var d;const c=(d=i.target.dataset)==null?void 0:d.railItem;c&&(Si=c)},n=i=>{var c;(c=e.current)!=null&&c.contains(i.relatedTarget)||(Si=null)},r=e.current;return r==null||r.addEventListener("focusin",t),r==null||r.addEventListener("focusout",n),()=>{r==null||r.removeEventListener("focusin",t),r==null||r.removeEventListener("focusout",n)}},[e])}function G1({item:e,index:t,tabbable:n,onFocusIndex:r,hint:s,variant:o}){var h;const i=Cn(),c=s.bind(hce(e,i,o!=="stripe")),d=e.kind==="panel";return a.jsxs("button",{ref:e.buttonRef,type:"button","data-rail-item":e.id,className:oD[o],tabIndex:o==="bar"?void 0:n?0:-1,"aria-label":e.ariaLabel,"aria-keyshortcuts":(h=aD(e.key,i))==null?void 0:h.aria,"aria-expanded":d?e.open===!0:void 0,"aria-controls":d&&e.open?e.controls:void 0,"aria-haspopup":d?void 0:"dialog",...c,onFocus:f=>{r(t),c.onFocus(f)},onClick:()=>e.onPress(),children:[e.glyph,o!=="stripe"&&a.jsx("span",{className:"rail-word",children:o==="dock"?e.short:e.label}),e.badge!=null&&e.badge>0&&a.jsx("span",{className:"rail-badge","aria-hidden":!0,children:e.badge})]})}function f$({side:e,label:t,groups:n}){const r=ll(e==="left"?"right":"left"),s=n.filter(d=>d.length>0),o=iD(s.flat().length,"vertical"),i=y.useRef(null);V1(i);let c=0;return a.jsxs("div",{ref:i,className:fce[e],role:"toolbar","aria-label":t,"aria-orientation":"vertical",onKeyDown:o.onKeyDown,children:[s.map((d,h)=>a.jsx("div",{className:"rail-group",children:d.map(f=>{const p=c++;return a.jsx(G1,{item:f,index:p,tabbable:p===o.active,onFocusIndex:o.setCurrent,hint:r,variant:"stripe"},f.id)})},h)),r.node]})}const Wd="dock-more",p$="dock-more-menu";function gce({items:e,tabbable:t,onFocusIndex:n,index:r}){const[s,o]=y.useState(null),i=s!==null,c=e.reduce((h,f)=>h+(f.badge??0),0),d=h=>()=>{var f;(f=document.getElementById(Wd))==null||f.focus(),o(null),h.onPress()};return a.jsxs(a.Fragment,{children:[a.jsxs("button",{id:Wd,type:"button","data-rail-item":"more",className:oD.dock,tabIndex:t?0:-1,"aria-label":`More: ${e.map(h=>h.ariaLabel).join(", ")}`,"aria-haspopup":"menu","aria-expanded":i,"aria-controls":i?p$:void 0,onFocus:()=>n(r),onKeyDown:h=>{h.key!=="ArrowDown"&&h.key!=="ArrowUp"||(h.preventDefault(),o(h.key==="ArrowUp"?"last":"first"))},onClick:()=>o(i?null:"first"),children:[a.jsxs("svg",{className:"glyph",width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[a.jsx("circle",{cx:"2.8",cy:"7",r:"0.7"}),a.jsx("circle",{cx:"7",cy:"7",r:"0.7"}),a.jsx("circle",{cx:"11.2",cy:"7",r:"0.7"})]}),a.jsx("span",{className:"rail-word",children:"More"}),c>0&&a.jsx("span",{className:"rail-badge","aria-hidden":!0,children:c})]}),i&&a.jsx(Nf,{anchorId:Wd,id:p$,className:"ap-pop",role:"menu",labelledBy:Wd,start:s,onClose:()=>o(null),children:e.map(h=>a.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item","data-rail-item":h.id,onFocus:()=>{Si=h.id},onClick:d(h),children:h.badge?`${h.menu??h.label} · ${h.badge} unread`:h.menu??h.label},h.id))})]})}function yce({items:e,more:t}){const n=ll("above"),r=iD(e.length+1,"horizontal"),s=y.useRef(null);return V1(s),a.jsxs("div",{ref:s,className:"edge-dock",role:"toolbar","aria-label":"Panels and tools",onKeyDown:r.onKeyDown,children:[e.map((o,i)=>a.jsx(G1,{item:o,index:i,tabbable:i===r.active,onFocusIndex:r.setCurrent,hint:n,variant:"dock"},o.id)),a.jsx(gce,{items:t,index:e.length,tabbable:r.active===e.length,onFocusIndex:r.setCurrent}),n.node]})}function wce({items:e,side:t="below"}){const n=ll(t),r=y.useRef(null);return V1(r),a.jsxs("div",{ref:r,className:"utility-run",children:[e.map((s,o)=>a.jsx(G1,{item:s,index:o,tabbable:!0,onFocusIndex:xce,hint:n,variant:"bar"},s.id)),n.node]})}function xce(){}const vce="(max-width: 640px)";function bce(e,t){const n=e?"Watching — the deck keeps its own copy of the history":"Not watching — reads the browser's history when opened";return t>0?`${n}
|
|
100
|
-
${t} unread`:n}function kce({providers:e,sessionListOpen:t,toggleSessionList:n,accountsPanelOpen:r,toggleAccountsPanel:s,usagePanelOpen:o,setUsagePanelOpen:i,machinePanelOpen:c,setMachinePanelOpen:d,setUsageHistoryOpen:h,watchOn:f,watchUnseen:p,setBrowserWatchOpen:g,setTrafficRadarOpen:w,radioOpen:k,setRadioOpen:j,openToolActivity:v,openSettings:b,onFeedback:N,toggles:S}){const E=Ile(gf()),C={id:"session-list",label:"Session list",short:"Sessions",key:{cap:"L",aria:"L",single:!0},ariaLabel:"Session list",glyph:a.jsx(_Z,{}),kind:"panel",open:t,controls:"session-list",onPress:n,buttonRef:S.sessionList},$={id:"accounts",label:"Accounts",short:"Accounts",key:{cap:"A",aria:"A",single:!0},ariaLabel:"Accounts",hint:"Claude accounts",glyph:a.jsx(EZ,{}),kind:"panel",open:r,controls:"accounts-panel",onPress:s,buttonRef:S.accounts},T={id:"usage",label:"Usage",short:"Usage",key:{cap:"U",aria:"U",single:!0},ariaLabel:"Usage",glyph:a.jsx(CZ,{}),kind:"panel",open:o,controls:"usage-panel",onPress:()=>i(F=>!F),buttonRef:S.usage},I={id:"machine",label:"Machine",short:"Machine",key:{cap:"S",aria:"S",single:!0},ariaLabel:"Machine",hint:"This machine",glyph:a.jsx(RZ,{}),kind:"panel",open:c,controls:"system-panel",onPress:()=>d(F=>!F),buttonRef:S.machine},O={id:"history",label:"Usage history",short:"History",key:{cap:"H",aria:"H",single:!0},ariaLabel:"Usage history",glyph:a.jsx(TZ,{}),kind:"dialog",onPress:()=>h(F=>!F)},U={id:"browser-watch",label:"Browser watch",short:"Watch",key:{cap:"B",aria:"B",single:!0},ariaLabel:`Browser watch, ${f?"watching":"not watching"}${p>0?`, ${p} unread`:""}`,detail:bce(f,p),glyph:a.jsx(MZ,{watching:f===!0||p>0}),kind:"dialog",onPress:()=>g(F=>!F),badge:p},P={id:"settings",label:"Settings",short:"Settings",key:{cap:E,aria:"Control+, Meta+,",single:!1},ariaLabel:"Settings",glyph:a.jsx($Z,{}),kind:"dialog",onPress:()=>b()},L={id:"feedback",label:"Feedback",short:"Feedback",menu:"Send feedback",ariaLabel:"Send feedback",glyph:a.jsx(LZ,{}),kind:"dialog",onPress:N};return{left:e.claude?[$,C]:[C],right:[[T,I],[O,...v?[{id:"tool-activity",label:"Tool activity",short:"Tools",ariaLabel:"Tool activity",glyph:a.jsx(FZ,{}),kind:"dialog",detail:"Which tools your agents run, how long they take and what fails",onPress:()=>v()}]:[],U,...w?[{id:"traffic-radar",label:"Telemetry Radar",short:"Radar",ariaLabel:"Telemetry Radar",glyph:a.jsx(AZ,{}),kind:"dialog",detail:"Claude telemetry configuration and observed connections",onPress:()=>w(!0)}]:[]],...j?[[{id:"radio",label:"Radio",short:"Radio",ariaLabel:"Radio",glyph:a.jsx(DZ,{}),kind:"panel",open:k,controls:"radio-panel",detail:"Explore stations around the world",onPress:()=>j(F=>!F)}]]:[]],utilities:[P,L]}}function jce({widths:e,room:t,gap:n,more:r}){let s=0,o=0;for(let i=0;i<e.length;i++){s+=(i>0?n:0)+e[i];const c=i+1<e.length?n+r:0;if(s+c>t)break;o=i+1}return o}function lD(e){return e.tool?e.tool.name:e.kind==="asked"?"question":"permission"}const Nce=20;function Sce(e,t=Nce){if(e.length<=t)return e;const n=Math.floor((t-1)*.4),r=t-1-n;return`${e.slice(0,r)}…${e.slice(e.length-n)}`}function _ce(e){const t=Math.floor(Math.max(0,e)/6e4);if(t<1)return"less than a minute";const n=(o,i)=>`${o} ${i}${o===1?"":"s"}`;if(t<60)return n(t,"minute");const r=Math.floor(t/60),s=t%60;return s===0?n(r,"hour"):`${n(r,"hour")} ${n(s,"minute")}`}function Ece(e,t,n){const r=t.tool?`on ${t.tool.name}`:t.kind==="asked"?"for an answer":"for permission";return`${e}, waiting ${_ce(n)} ${r}; go to session`}function Cce(e){const t=zi(e),n=cI(e,t);return n?`${t}
|
|
101
|
-
${n}`:t}const Tce=new Set(["idle","checking","current","downloading","ready","error"]);function m$(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.status!="string"||!Tce.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 Rce(e){return(e==null?void 0:e.status)==="ready"&&e.version?{version:e.version}:null}function cD(e=typeof navigator>"u"?"":navigator.userAgent){var t;return((t=/\bccdeck-desktop\/(\d[^\s]*)/.exec(e))==null?void 0:t[1])??null}const Vh="Restart to update",uD=3e4;function dD(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 Ace(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 ${Vh} comes first`}}function Mce(e){const t=e==null?void 0:e.reason;return t==="app_disconnected"||t==="update_not_ready"?t:"refused"}function $ce(e,t,n=typeof navigator>"u"?"":navigator.userAgent){const r=dD(n),s=`Use ${Vh} 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, ${Vh} is in ${r}.`;case"timeout":return`ccdeck has not restarted after ${uD/1e3} seconds. ${s}`;case"refused":return`Nothing restarted: the deck turned the request down. ${s}`;case"unreachable":return`Nothing restarted: the request did not reach the deck. ${s}`}}const Lce="Update checks are off (AGENTS_DECK_NO_UPDATE_CHECK=1)",Db="click for what's new";function Oce(e){if(e.checkDisabled)return`${Lce} · ${Db}`;if(e.checking)return`Asking npm for the newest release… · ${Db}`;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 · ${Db}, and to check npm now`}function Ice(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 Pce(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 hD(e){return e?`${e.kind}:${e.to}`:""}function Dce(e,t){return e!=null&&t!==hD(e)}function Fce({readyAppUpdate:e,notice:t,noticeOpen:n,version:r,chipVersion:s,versionChecking:o,now:i,openReleaseNotes:c,showNotice:d,loadVersion:h}){return a.jsx(a.Fragment,{children:e?(()=>{const f=Ace(cD()??s,e.version);return a.jsxs("button",{type:"button",className:"v ready",onClick:c,"aria-haspopup":"dialog","aria-label":f.label,title:f.title,children:[f.text,a.jsx("span",{className:"v-dot","aria-hidden":!0})]})})():t?a.jsxs("button",{type:"button",className:"v stale",onClick:()=>{c(),d()},"aria-haspopup":"dialog","aria-label":Pce({...t,open:n}),title:t.kind==="restart"?`Running v${t.from}; v${t.to} is installed on disk. Restart to pick it up · click for what's new`:`Running v${t.from}; v${t.to} is on npm · click for what's new`,children:["v",t.from,a.jsx("span",{className:"v-dot","aria-hidden":!0})]}):(()=>{const f={running:s,latest:r==null?void 0:r.latest,latestPending:r==null?void 0:r.latestPending,checkedAgo:r!=null&&r.checkedAt?v0(i-r.checkedAt):null,checkFailedAgo:r!=null&&r.checkFailedAt&&r.checkFailedAt>(r.checkedAt??0)?v0(i-r.checkFailedAt):null,checkDisabled:r==null?void 0:r.checkDisabled,checking:o};return a.jsxs("button",{type:"button",className:o?"v checking":"v",onClick:()=>{c(),h(!0)},"aria-busy":o||void 0,"aria-haspopup":"dialog","aria-label":Ice(f),title:Oce(f),children:["v",f.running]})})()})}function Bce({live:e,paused:t,pauseGate:n}){const r=Cn();return a.jsx("span",{className:"status",children:(()=>{const s=U7({connected:e,paused:t,held:n.size,dropped:n.dropped,singleKeys:r});return s.resting?null:a.jsx("span",{className:`pill ${s.tone}`,title:s.title,children:a.jsxs("span",{className:"pill-box",children:[a.jsx("span",{className:"pill-widest","aria-hidden":!0,children:s.widest}),a.jsx("span",{className:"pill-label",children:s.label})]})})})()})}function qce(e,t){return`${e.label} — ${lD(e.waiting)} · ${Eh(e.waiting.since,void 0,t)}`}function fD(e,t){const n=e.slice(0,6).map(r=>qce(r,t));return e.length>6&&n.push(`and ${e.length-6} more`),n.join(`
|
|
102
|
-
`)}function Uce({waitingSessions:e,waitingCursorRef:t,focusSession:n,now:r,named:s}){const o=Cn(),i=ll("below"),c=e.slice(s),d=e.length;return a.jsxs(a.Fragment,{children:[a.jsxs("button",{type:"button",className:"waiting-stat",onClick:()=>{t.current=e[0].id,n(e[0].id)},"aria-label":`${d} session${d===1?"":"s"} waiting for you`,"aria-keyshortcuts":o?"W":void 0,...i.bind({label:"Go to the longest wait",keys:o?"W":void 0,detail:c.length>0?fD(c,r):void 0}),children:[a.jsx("span",{className:"ap-pulse","aria-hidden":!0}),a.jsx("b",{children:d})," waiting"]}),i.node]})}function g$({w:e,now:t}){return a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"we-name",children:Sce(e.label)}),a.jsx("span",{className:"we-wait",children:Eh(e.waiting.since,void 0,t)}),a.jsxs("span",{className:"we-what",children:["· ",lD(e.waiting)]})]})}const Hce=12,Wce=2e3,zce=4;function Vce({waitingSessions:e,waitingCursorRef:t,focusSession:n,now:r,onFit:s,onMore:o}){const i=Cn(),c=ll("below"),d=y.useRef(null),h=y.useRef(null),[f,p]=y.useState(0),g=e.map(v=>v.id).join(`
|
|
103
|
-
`);y.useLayoutEffect(()=>{const v=d.current,b=h.current;if(!v||!b)return;const N=()=>{const E=Array.from(b.children),C=E.pop();p(jce({widths:E.map($=>$.getBoundingClientRect().width),room:v.clientWidth-Hce,gap:zce,more:(C==null?void 0:C.getBoundingClientRect().width)??0}))};if(N(),typeof ResizeObserver>"u")return;const S=new ResizeObserver(N);return S.observe(v),S.observe(b),()=>S.disconnect()},[g]);const w=e.slice(0,f),k=e.slice(f);y.useEffect(()=>{s(w.length)},[w.length,s]);const j=v=>{t.current=v,n(v)};return a.jsxs("div",{className:"wait-names",ref:d,children:[a.jsxs("ul",{className:"wait-list",children:[w.map(v=>a.jsx("li",{"data-fresh":r-v.waiting.since<Wce||void 0,children:a.jsx("button",{type:"button",className:"wait-entry",onClick:()=>j(v.id),"aria-label":Ece(v.label,v.waiting,r-v.waiting.since),...c.bind({label:v.label,detail:Cce(v.waiting)}),children:a.jsx(g$,{w:v,now:r})})},v.id)),w.length>0&&k.length>0&&a.jsx("li",{children:a.jsxs("button",{type:"button",className:"wait-more",onClick:o,"aria-label":`${k.length} more waiting; open the session list`,"aria-keyshortcuts":i?"L":void 0,...c.bind({label:"Open the session list",keys:i?"L":void 0,detail:fD(k,r)}),children:["+",k.length," more"]})})]}),e.length>0&&a.jsxs("span",{className:"wait-ruler",ref:h,"aria-hidden":!0,children:[e.map(v=>a.jsx("span",{className:"wait-entry",children:a.jsx(g$,{w:v,now:r})},v.id)),a.jsxs("span",{className:"wait-more",children:["+",e.length," more"]})]}),c.node]})}const ok={on:"The deck will raise a system notification when a session blocks on you and this tab is in the background",blocked:"Notifications are blocked for this page. Only your browser can undo that — its site settings for this address"};function Gce(e){return e==="on"?`Notifications on. ${ok.on}.`:e==="blocked"?`${ok.blocked}.`:""}function Kce({notifySaid:e}){return a.jsx("span",{className:e==="on"?"notify-said":"notify-said notify-said-blocked","aria-hidden":!0,title:ok[e],children:e==="on"?"notifications on":"notifications blocked"})}function Yce({versionCheck:e,welcome:t,desktopUpdate:n,pause:r,announcements:s,notify:o,waitingSessions:i,waitingCursorRef:c,focusSession:d,live:h,now:f,incidents:p,queueNamed:g}){const{version:w,notice:k,noticeOpen:j,showNotice:v,versionChecking:b,loadVersion:N}=e,{chipVersion:S,openReleaseNotes:E}=t,{readyAppUpdate:C}=n,{paused:$,pauseGate:T}=r,{blockedSaid:I,watchSaid:O,incidentSaid:U}=s,{notifySaid:P}=o;return a.jsxs("div",{className:"readout",children:[a.jsxs("div",{className:"brand",children:[a.jsx("img",{className:"logo logo-on-dark",src:GK,width:19,height:16,alt:""}),a.jsx("img",{className:"logo logo-on-light",src:KK,width:19,height:16,alt:""}),a.jsx("h1",{children:Lt}),a.jsx(Fce,{readyAppUpdate:C,notice:k,noticeOpen:j,version:w,chipVersion:S,versionChecking:b,now:f,openReleaseNotes:E,showNotice:v,loadVersion:N})]}),a.jsx(Bce,{live:h,paused:$,pauseGate:T}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:I}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:O}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:U}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:Gce(P)}),a.jsx(YK,{incidents:p}),i.length>0&&a.jsx(Uce,{waitingSessions:i,waitingCursorRef:c,focusSession:d,now:f,named:g}),P&&a.jsx(Kce,{notifySaid:P})]})}function Xce({selected:e,now:t,selectedIds:n,focusAgent:r,clearSelection:s}){const o=Cn(),i=En(e),c=Math.max(0,((e.endedAt??t)-e.startedAt)/1e3),d=e.state==="active"&&!e.synthetic?Ik(i.total,c):null,h=n.size-1;return a.jsxs("button",{type:"button",className:"selected-ribbon",title:`${dn(`Zoom to ${e.label} and its session`,"Z",o)}${i.total>0?`
|
|
104
|
-
${Ye(i.total)} spent${d?` · ${d}`:""}`:""}`,onClick:()=>{try{r(e.id)}catch{}},children:[a.jsx("span",{className:`state-pill state-${e.state}`,children:e.state==="active"?"live":e.state}),a.jsx("span",{className:"selected-label",children:e.label}),i.total>0&&a.jsxs("span",{className:"selected-cost",children:[Ye(i.total),d?a.jsxs("span",{className:"selected-rate",children:[" · ",d]}):null]}),h>0&&a.jsxs("span",{className:"selected-extra",children:["+",h]}),a.jsx("span",{"aria-hidden":!0,className:"selected-close",onClick:f=>{f.stopPropagation(),s()},children:"×"})]})}function Zce({catBarRef:e,catBarOccluded:t,presentCats:n,hiddenCats:r,toggleCat:s}){return a.jsx("div",{ref:e,className:`cat-filter-bar${t?" occluded":""}`,role:"group","aria-label":"Filter tools by category",children:n.map(o=>{const i=r.has(o);return a.jsxs("button",{type:"button",className:`cat-filter${i?" off":""}`,onClick:()=>s(o),"aria-pressed":!i,title:`${i?"Show":"Hide"} ${zh[o]} tools`,children:[a.jsx(Jle,{cat:o}),a.jsx("span",{className:"cat-name",children:zh[o]})]},o)})})}const Jce=["a[href]","button:not(:disabled)","input:not(:disabled)","select:not(:disabled)","textarea:not(:disabled)","summary","[tabindex]"].join(",");function Qce(e){var n,r;const t=e.target;!(t!=null&&t.closest)||t.closest(Jce)!==e.currentTarget||(e.preventDefault(),(r=(n=document.activeElement)==null?void 0:n.blur)==null||r.call(n))}function eue({trashZoneRef:e,trashState:t,trashPhase:n,trashLabel:r}){const s=Cn();return a.jsxs("div",{ref:e,className:`drag-trash-zone ${t}${n==="leaving"?" leaving":""}`,role:"status",children:[a.jsx("svg",{className:"drag-trash-icon",viewBox:"0 0 24 24","aria-hidden":"true",children:a.jsx("path",{d:"M8 7V5.8C8 4.8 8.8 4 9.8 4h4.4c1 0 1.8.8 1.8 1.8V7m-10 0h12M8 10v8m4-8v8m4-8v8M7 7l.7 13h8.6L17 7"})}),a.jsxs("span",{className:"drag-trash-copy",children:[a.jsx("span",{className:"drag-trash-text",children:t==="over"?a.jsxs(a.Fragment,{children:["Release to remove ",a.jsx("strong",{className:"drag-trash-name",children:r||"this card"})]}):"Drop here to remove from the board"}),a.jsx("span",{className:"drag-trash-hint",children:t==="over"?`${dn("The session list","L",s)} brings it back`:"The session keeps running"})]})]})}function tue({canvasRef:e,bubbling:t,dragging:n,trash:r,zoom:s,viewport:o,stateRef:i,peek:c,children:d}){const{trashDragging:h,trashState:f,trashPhase:p,trashZoneRef:g,trashLabel:w}=r,{lod:k,lodRef:j}=s,{markCanvasInput:v}=o,{peekAgent:b,peekLabel:N,peekRecap:S,peekBounds:E}=c;return a.jsxs("main",{id:"canvas",tabIndex:-1,className:`canvas-wrap${t?" bubbling":""}${n?" dragging-any":""}${h&&f==="over"?" trash-hover":""}`,"data-lod":k,ref:e,onMouseDownCapture:Qce,onPointerDownCapture:v,onPointerUpCapture:v,onWheelCapture:v,onFocusCapture:C=>{const $=C.target;if(!W1($)||j.current==null||j.current==="detail")return;const T=$.getAttribute("data-id");T&&i.current.agents.has(T)&&$.matches(":focus-visible")&&z4(T,$,"focus")},onBlurCapture:C=>{var T,I;const $=(I=(T=C.target).getAttribute)==null?void 0:I.call(T,"data-id");$&&Ca($)},children:[d,xa(p)&&a.jsx(eue,{trashZoneRef:g,trashState:f,trashPhase:p,trashLabel:w}),a.jsx(Nie,{agentFor:b,recapFor:S,labelFor:N,bounds:E})]})}function nue({restarting:e,restartMode:t,live:n,paused:r}){return a.jsxs("div",{className:"conn-banner",role:"alert",children:[a.jsx("span",{className:"conn-dot"}),e?t==="npx"?"Fetching the new version with npx — this can take a minute…":`Restarting ${Lt}…`:(()=>{const s=B7({connected:n,paused:r});return a.jsxs(a.Fragment,{children:[`Lost connection to the ${Lt} server. Reconnecting…`,s&&a.jsx("span",{className:"conn-sub",children:s})]})})()]})}function rue({oldName:e,version:t,dismissOldName:n}){return a.jsxs("div",{className:"ver-banner",role:"status",children:[a.jsx("span",{className:"ver-dot"}),a.jsxs("strong",{children:[e," still works — the deck is called ",Lt," now."]}),t!=null&&t.renameFix?a.jsx("span",{className:"ver-sub",children:t.renameFix}):null,a.jsx("button",{type:"button","aria-label":"Dismiss",className:"ver-close",onClick:n,children:"×"})]})}const pD="Thanks — that helps.",sue=Array.from({length:11},(e,t)=>t);function aue(e){return e===0?"0 out of 10, not useful":e===10?"10 out of 10, extremely useful":`${e} out of 10`}const oue=6;function iue(e){const t=y.useRef(null);return y.useLayoutEffect(()=>{const n=t.current,r=n==null?void 0:n.closest(".app");if(!n||!r)return;const s=()=>r.style.setProperty("--rating-h",`${Math.ceil(n.getBoundingClientRect().height)}px`);s();const o=typeof ResizeObserver>"u"?null:new ResizeObserver(s);return o==null||o.observe(n),()=>{o==null||o.disconnect(),r.style.removeProperty("--rating-h")}},[e]),t}function lue(){var e;(e=document.getElementById("canvas"))==null||e.focus()}function cue({phase:e,score:t,onAnswer:n,onLater:r,onClose:s,onFeedback:o,onHold:i}){const c=iue(e),d=y.useRef(null),h=y.useRef(null),f=y.useRef(!1);y.useEffect(()=>{var g,w;e!=="thanks"||!f.current||(f.current=!1,Vn(((g=document.activeElement)==null?void 0:g.tagName)??null)&&((w=d.current??h.current)==null||w.focus()))},[e]);const p=g=>{var w;(w=c.current)!=null&&w.contains(document.activeElement)&&lue(),g()};return e==="thanks"?a.jsxs("div",{ref:c,className:"ver-banner note rating-banner",onFocus:()=>i(!0),onBlur:g=>{g.currentTarget.contains(g.relatedTarget)||i(!1)},children:[a.jsx("span",{className:"ver-dot"}),a.jsx("strong",{children:pD}),t!==null&&t<=oue?a.jsx("button",{ref:d,type:"button",className:"ver-act",onClick:o,children:"Tell us what would make it better"}):null,a.jsx("button",{ref:h,type:"button","aria-label":"Dismiss",className:"ver-close",onClick:()=>p(s),children:"×"})]}):a.jsxs("div",{ref:c,className:"ver-banner note rating-banner",role:"group","aria-labelledby":"rating-question",children:[a.jsx("span",{className:"ver-dot"}),a.jsx("strong",{id:"rating-question",children:"How useful is ccdeck to you?"}),a.jsx("span",{className:"rating-scale",children:sue.map(g=>a.jsx("button",{type:"button",className:"rating-pick","aria-label":aue(g),onClick:w=>{f.current=w.detail===0||w.currentTarget.matches(":focus-visible"),n(g)},children:g},g))}),a.jsx("span",{className:"ver-sub rating-ends","aria-hidden":"true",children:"0 not at all · 10 extremely"}),a.jsx("button",{type:"button",className:"ver-act",onClick:()=>p(r),children:"Not now"})]})}const uue=3e4;function due({bundle:e,running:t,lastTried:n}){return!t||e===t?!1:n!==t}function hue({bundle:e,running:t,pending:n,lastTried:r}){return t?due({bundle:e,running:t,lastTried:r})?"reload":n==null||n&&n!==t?"wait":"confirm":"wait"}function fue(e){return!e||e.state!=="failed"?null:`${typeof e.at=="number"?e.at:0}:${e.error??""}`}function pue({asked:e,reported:t}){return t?t!==e:!1}function mD(e){const t=e.thresholdMs??uue;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 mue(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 gue(e,t){return e?t==null?"auto when idle":`auto in ${mue(t)}`:"auto-restart off"}function y$(e){let t=0;for(const n of e)n.state==="active"&&t++;return t}function yue(e,t=!1){return e<=0&&t?{label:"Restart anyway",clause:"the canvas is paused — running agents cannot be seen"}:e<=0?{label:"Restart now",clause:"nothing is running"}:{label:"Restart anyway",clause:`${e===1?"1 agent is running":`${e} agents are running`} — their events during the restart are lost`}}function wue(e){const t=mD(e);return t==null?{idleSince:null,restart:!1,remainingMs:null}:e.idleSince==null||e.now<e.idleSince?{idleSince:e.now,restart:!1,remainingMs:t}:{idleSince:e.idleSince,restart:t===0,remainingMs:t}}const ik={git_checkout:"this deck runs from a git checkout — pull instead:",npx:"npx runs from a cache that cannot be upgraded in place — run:",one_off:"this deck runs from a one-off pnpm dlx, bunx or yarn dlx copy that cannot be upgraded in place — to keep one, run:",not_writable:"the install directory is not writable by this user — run:",opted_out:"installs are off (AGENTS_DECK_NO_INSTALL=1) — run:",retired_name:"this install came from a name that is no longer published — run:"};function xue({notice:e,version:t,dismissNotice:n,upgradeState:r,startUpgrade:s,copyCommand:o,cmdCopied:i,autoRestart:c,toggleAutoRestart:d,askRestart:h,restartCopy:f,restartFuseMs:p,restarting:g}){var w,k,j;return a.jsxs("div",{className:`ver-banner ${e.kind}`,role:"status",children:[a.jsx("span",{className:`ver-dot${p==null?"":" armed"}`}),e.kind==="restart"?a.jsxs(a.Fragment,{children:[a.jsxs("strong",{children:["v",e.to," is installed — this deck still runs v",e.from,"."]}),t!=null&&t.canRestart?a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",className:"ver-act",onClick:()=>h(),...ts(g),title:`Stop this process and bring it back on the same port. The canvas replays from the event log.
|
|
105
|
-
|
|
106
|
-
Node loads every module once, at startup. An upgrade replaces the files on disk but not the code already in memory, so this process keeps running the old version until it is restarted.`,children:g?"restarting…":f.label}),!g&&a.jsx("span",{className:"ver-sub",children:f.clause}),a.jsxs("label",{className:"ver-auto",children:[a.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":c,onClick:d,"aria-label":"Auto-restart when idle",title:c?"Updates on its own. While you are here it restarts once nothing has been running for 30 seconds; while you are away it also installs the new version first. Click to require a click instead.":"Only updates when you click. Click to let it update itself when idle or while you are away.",children:a.jsx("span",{className:"switch-knob"})}),a.jsx("span",{"aria-hidden":!0,children:gue(c,p)})]})]}):a.jsx("span",{className:"ver-sub",title:"Node loads every module once, at startup. An upgrade replaces the files on disk but not the code already in memory, so this process keeps running the old version until it is restarted.",children:"Restart it to pick up the new code."})]}):a.jsxs(a.Fragment,{children:[a.jsxs("strong",{children:[Lt," v",e.to," is out — you are on v",e.from,"."]}),(t==null?void 0:t.upgradeMode)==="install"&&r!=="failed"&&a.jsx("button",{type:"button",className:"ver-act",onClick:s,...ts(r==="running",r==="done"),title:`Runs ${((w=t==null?void 0:t.upgrade)==null?void 0:w.command)??(t==null?void 0:t.command)??"npm i -g"} here, then restarts once nothing is running.`,children:r==="running"?"installing…":r==="done"?"installed":"Update now"}),(t==null?void 0:t.upgradeMode)==="npx"&&(t==null?void 0:t.canRestart)&&a.jsx("button",{type:"button",className:"ver-act",onClick:()=>h({upgrade:!0}),...ts(g),title:`Runs ${t==null?void 0:t.command} and hands it this port. Nothing is installed globally — npx unpacks its own copy.`,children:g?"fetching…":r==="failed"?"Retry update":"Update & restart"}),r==="failed"?a.jsxs("span",{className:"ver-sub fail",title:((k=t==null?void 0:t.upgrade)==null?void 0:k.error)??"",children:[(t==null?void 0:t.upgradeMode)==="npx"?"update failed":"install failed",": ",((j=t==null?void 0:t.upgrade)==null?void 0:j.error)??"unknown error"," — run it yourself:"]}):(t==null?void 0:t.upgradeMode)==="npx"?a.jsx("span",{className:"ver-sub",children:t!=null&&t.canRestart?"npx cannot upgrade in place, so the deck re-runs:":ik.npx}):t!=null&&t.upgradeBlocked?a.jsx("span",{className:"ver-sub",children:qt(ik,t.upgradeBlocked)??"cannot install from here"}):null,a.jsxs("button",{type:"button",className:"ver-cmd",onClick:o,title:"Copy to clipboard",children:[a.jsx("code",{children:t==null?void 0:t.command}),a.jsx("span",{className:"ver-cmd-hint",children:i?"copied":"copy"})]})]}),a.jsx("button",{type:"button","aria-label":"Dismiss",className:"ver-close",onClick:n,children:"×"})]})}function vue({restart:e,versionCheck:t,upgrade:n,oldNameNotice:r,rating:s,onFeedback:o,everConnected:i,live:c,paused:d}){const{autoRestart:h,toggleAutoRestart:f,restarting:p,restartMode:g,restartedTo:w,askRestart:k,restartCopy:j,restartFuseMs:v}=e,{version:b,notice:N,noticeOpen:S,dismissNotice:E}=t,{upgradeState:C,startUpgrade:$,copyCommand:T,cmdCopied:I}=n,{oldName:O,oldNameOpen:U,dismissOldName:P}=r,{ratingPhase:L,ratingScore:F,answerRating:A,rateLater:B,closeRating:D,holdThanks:K}=s,G=w?a.jsxs("div",{className:"ver-banner done",role:"status",children:[a.jsx("span",{className:"ver-dot"}),a.jsxs("strong",{children:["Restarted — now running v",w,"."]}),a.jsx("span",{className:"ver-sub",children:"The canvas replayed from the event log."})]}):i&&!c?a.jsx(nue,{restarting:p,restartMode:g,live:c,paused:d}):S&&N?a.jsx(xue,{notice:N,version:b,dismissNotice:E,upgradeState:C,startUpgrade:$,copyCommand:T,cmdCopied:I,autoRestart:h,toggleAutoRestart:f,askRestart:k,restartCopy:j,restartFuseMs:v,restarting:p}):U&&O?a.jsx(rue,{oldName:O,version:b,dismissOldName:P}):L!=="hidden"?a.jsx(cue,{phase:L,score:F,onAnswer:A,onLater:B,onClose:D,onFeedback:o,onHold:K}):null;return a.jsxs(a.Fragment,{children:[G,a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:L==="thanks"?pD:""})]})}function bue(e,t){return e==="confirmation"?t.confirmOpen?"clear":"ignore":t.modalOpen||t.confirmOpen?"ignore":"confirm"}function kue(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 jue(e){return e<=0?null:e===1?"the one agent":`all ${e} agents`}function Nue(e,t){const n=jue(e),r=(...i)=>[n?`${n} on the canvas`:null,...i,"layout, pins and selection"].filter(c=>c!==null),s="This cannot be undone.";if(!t)return{goes:r("the event log on disk — the file a restarted deck replays to rebuild what you see, and the file every deck on this machine shares unless one was told otherwise"),stays:[],final:s,confirm:"Clear everything"};if(!t.path)return{goes:r(),stays:[],final:`This deck keeps no event log, so nothing on disk changes — and nothing can bring the canvas back. ${s}`,confirm:"Clear everything"};if(!t.mine){const i=t.ownerPort===null?"another running deck owns that file":`the deck on port ${t.ownerPort} owns that file`,c=t.decks>2?`, one of ${t.decks} decks sharing it`:"";return{goes:r(),stays:[`the event log — ${i}${c}`,"restart this deck and the log replays back onto it"],final:null,confirm:"Clear this canvas"}}if(t.decks<=1)return{goes:r("this deck's event log — the file a restarted deck replays to rebuild what you see"),stays:[],final:s,confirm:"Clear everything"};const o=t.decks-1;return{goes:r(`the event log ${o===1?"1 other running deck shares":`${o} other running decks share`} with this one — every session recorded in it, not just the ones drawn here`),stays:[o===1?"what that deck shows, until it restarts — then it is gone there too":"what those decks show, until they restart — then it is gone there too"],final:s,confirm:"Clear everything"}}function Sue({agentCount:e,onConfirm:t,onCancel:n}){const r=y.useRef(null),s=ot(n,{focusRef:r,layer:iz}),o=dt(n),[i,c]=y.useState(null);y.useEffect(()=>{let g=!1;return fetch("/api/clear").then(w=>w.ok?w.json():null).then(w=>{g||c(kue(w))}).catch(()=>{}),()=>{g=!0}},[]);const{goes:d,stays:h,final:f,confirm:p}=Nue(e,i);return a.jsx("div",{className:"modal-backdrop",...o,role:"presentation",children:a.jsxs("div",{ref:s,className:"modal clear-confirm",onClick:g=>g.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"clear-confirm-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsxs("div",{className:"modal-title",children:[a.jsx("span",{className:"status-dot err","aria-hidden":!0}),a.jsx("span",{id:"clear-confirm-title",className:"modal-tool-name",children:"Clear the deck?"})]}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:n,"aria-label":"Cancel (Esc)",title:"Cancel (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[a.jsxs("dl",{className:"cc-plan",children:[a.jsx("dt",{children:"Goes"}),a.jsx("dd",{children:d.map(g=>a.jsx("span",{children:g},g))}),a.jsx("dt",{children:"Stays"}),a.jsx("dd",{children:h.length>0?h.map(g=>a.jsx("span",{children:g},g)):a.jsx("span",{children:"nothing"})})]}),f&&a.jsx("p",{className:"cc-final",children:f}),a.jsxs("div",{className:"cc-actions",children:[a.jsx("button",{type:"button",ref:r,className:"btn",onClick:n,children:"Cancel"}),a.jsx("button",{type:"button",className:"btn danger",onClick:t,children:p})]})]})]})})}const Gh=[{value:"bug",label:"Bug",question:"What happened?",placeholder:`I was trying to…
|
|
107
|
-
What did you expect to happen?`},{value:"idea",label:"Idea",question:"What would make ccdeck better?",placeholder:"It would be useful if…"},{value:"other",label:"Other",question:"What would you like to tell us?",placeholder:"Write anything…"}];function gD(e){return Gh.find(t=>t.value===e)??Gh[0]}const lk=3,Fb=120,yD=1e4,wD=200,_ue="Write something first.";function w$(e){return e.trim()!==""}function Eue(e){var o;const t=e.trim();if(t==="")return"";const n=x$(t.split(/\r?\n/,1)[0]),r=((o=/^(.+?[.!?])(?=\s|$)/.exec(n))==null?void 0:o[1])??n,s=Bb(r).length>=lk?Bb(r):Bb(n);return Tue(s.length>=lk?s:x$(t))}function Cue(e,t){const n=Eue(t);return n.length>=lk?n:`${gD(e).label}: ${n}`}function x$(e){return e.replace(/\s+/g," ").trim()}function Bb(e){return/[^.]\.$/.test(e)?e.slice(0,-1):e}function Tue(e){if(e.length<=Fb)return e;const t=e.slice(0,Fb-1),n=t.lastIndexOf(" ");return`${(n>=Fb/2?t.slice(0,n):t).replace(/[\uD800-\uDBFF]$/,"").replace(/[\s,;:.\-–—]+$/,"")}…`}function Rue({kind:e,body:t,contact:n}){const r={kind:e,title:Cue(e,t),body:t.trim()};return n.trim()!==""&&(r.contact=n.trim()),r}function Aue(e){const t=e;return(t==null?void 0:t.ok)!==!0||typeof t.appVersion!="string"||typeof t.platform!="string"||t.appVersion===""||t.platform===""?null:{appVersion:t.appVersion,platform:t.platform}}const Mue={darwin:"macOS",win32:"Windows",linux:"Linux"};function $ue(e){const t=e.indexOf("-"),n=t===-1?e:e.slice(0,t),r=t===-1?"":e.slice(t+1),s=Mue[n]??n;return r?`${s} · ${r}`:s}function Lue(e){return e?`ccdeck ${e.appVersion} · ${$ue(e.platform)}`:null}const Oue="sent with it",Iue="Your ccdeck version and system are sent with it.",Pue="Add details",Due="How to reach you",Fue="Email or GitHub @name",Bue="Only if you would like an answer.",que=["It all goes to the people who make ccdeck, with the version and system below.","Nothing becomes public by being sent. They may open a public GitHub issue from it, choosing its title and text; your contact and screenshots are never put on one."];function Uue(e){return e.key==="Enter"&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey&&!e.isComposing}function xD(e){return e.key==="Enter"&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey&&!e.isComposing}function Hue(e){return yf(e)?["⌘","Enter"]:["Ctrl","Enter"]}function Wue(e){return[...e].length===1}const vD="Thanks — feedback sent.";function v$(e,t,n){if(t==="vetoed")return"This deck was started with AGENTS_DECK_NO_INSTALL=1, which keeps it off the network, so nothing was sent.";if(e===429||t==="too_many")return"Too much feedback from this network in the last hour. Try again later; your text is still here.";if(e===413||t==="too_large")return"The images are too large to send together. Remove one and send again; your text is still here.";const r=n==null?void 0:n.images;return e===400&&Array.isArray(r)&&typeof r[0]=="string"?`The server did not accept an image. ${r[0]} Remove it and send again; your text is still here.`:e===400?"The server did not accept the message. It is still here; check it and send again.":"ccdeck's server could not be reached. Nothing was sent; your text is still here."}function zue(e){return e==="sending"?"Sending…":e==="sent"?vD:""}const b$=1400,Vue=160;function Gue({kind:e,onChange:t}){return a.jsxs("fieldset",{className:"fb-kinds",children:[a.jsx("legend",{className:"vis-hidden",children:"Kind of feedback"}),Gh.map(n=>a.jsxs("label",{className:"fb-kind",children:[a.jsx("input",{type:"radio",name:"feedback-kind",value:n.value,checked:e===n.value,onChange:()=>t(n.value),onKeyDown:r=>{xD(r.nativeEvent)&&r.preventDefault()}}),n.label]},n.value))]})}const bD="fb-details";function Kue({open:e,onToggle:t}){return a.jsxs("button",{type:"button",className:"fb-tool fb-more","aria-expanded":e,"aria-controls":bD,onClick:t,children:[Pue,a.jsx("svg",{className:"fb-chev",width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,focusable:"false",children:a.jsx("path",{d:"M2.5 3.75 5 6.25l2.5-2.5"})})]})}function Yue({open:e,contact:t,onContact:n}){const r=y.useId();return a.jsx("div",{id:bD,className:"fb-details","data-open":e||void 0,children:a.jsx("div",{className:"fb-details-clip",children:a.jsxs("div",{className:"fb-details-body",children:[a.jsxs("div",{className:"fb-field",children:[a.jsxs("label",{className:"fb-field-label",htmlFor:"fb-contact",children:[Due,a.jsx("span",{className:"fb-optional",children:"optional"})]}),a.jsx("input",{id:"fb-contact",className:"ap-manage-input",type:"text",value:t,maxLength:wD,autoComplete:"email",placeholder:Fue,"aria-describedby":r,onChange:s=>n(s.target.value),onKeyDown:s=>{xD(s.nativeEvent)&&s.preventDefault()}}),a.jsx("p",{id:r,className:"fb-hint",children:Bue})]}),a.jsx("div",{className:"fb-where",children:que.map(s=>a.jsx("p",{children:s},s))})]})})})}const go=3,Xue=5*1024*1024,Zue=12*1024*1024,ck=8192,Jue=64*1024,Que=256*1024,ede=.92,tde=640,kD=.9,nde=.85,rde=6,sde=512*1024,Kh={png:"image/png",jpeg:"image/jpeg"},ade={png:"png",jpeg:"jpg"},ode=[137,80,78,71,13,10,26,10],ide=[255,216,255];function jD(e){const t=n=>e.length>=n.length&&n.every((r,s)=>e[s]===r);return t(ode)?"png":t(ide)?"jpeg":null}function lde(e){const t=jD(e);return t==="png"?cde(e):t==="jpeg"?dde(e):null}function cde(e){const t=[73,72,68,82];if(e.length<24||!t.every((r,s)=>e[12+s]===r))return null;const n=new DataView(e.buffer,e.byteOffset,e.byteLength);return{width:n.getUint32(16),height:n.getUint32(20)}}function ude(e){return e>=192&&e<=207&&e!==196&&e!==200&&e!==204}function dde(e){let t=2;for(;t<e.length;){if(e[t]!==255)return null;for(;t<e.length&&e[t]===255;)t++;const n=e[t++];if(n===void 0||n===217||n===218)return null;if(n===1||n>=208&&n<=215)continue;if(t+2>e.length)return null;const r=e[t]<<8|e[t+1];if(r<2)return null;if(ude(n))return t+7>e.length?null:{height:e[t+3]<<8|e[t+4],width:e[t+5]<<8|e[t+6]};t+=r}return null}function k$(e,t){return e.bytes>t||e.width>ck||e.height>ck}function hde(e){return Math.min(Xue,Zue-Jue-e)}function ND(e,t){return{width:Math.max(1,Math.floor(e.width*t)),height:Math.max(1,Math.floor(e.height*t))}}function fde(e,t){const n=ck/Math.max(e.width,e.height),r=e.bytes>t?Math.sqrt(t/e.bytes)*kD:1;return ND(e,Math.min(1,n,r))}async function pde(e,t,n){let r=fde(e,t),s=e.format;for(let o=0;o<rde;o++){const i=await n(r,s,s==="jpeg"?ede:void 0);if(!i)return null;if(i.size<=t)return{...r,blob:i,format:s};if(s==="png"){s="jpeg";continue}if(r=ND(r,Math.min(nde,Math.sqrt(t/i.size)*kD)),Math.max(r.width,r.height)<tde)return null}return null}async function mde(e,t,n){const r=new Uint8Array(await e.slice(0,sde).arrayBuffer()),s=jD(r);if(!s)return{ok:!1,problem:"type"};if(t<Que)return{ok:!1,problem:"no_room"};const o=e.type===Kh[s]?e:new Blob([e],{type:Kh[s]}),i=lde(r);if(i&&!k$({...i,bytes:e.size},t))return{ok:!0,blob:o,resized:null};const c=await n(e).catch(()=>null);if(!c)return{ok:!1,problem:"unreadable"};try{const d={width:c.width,height:c.height,bytes:e.size,format:s};if(!k$(d,t))return{ok:!0,blob:o,resized:null};const h=await pde(d,t,c.encoder);return h?{ok:!0,blob:h.blob,resized:{width:h.width,height:h.height}}:{ok:!1,problem:"too_large"}}finally{c.release()}}function gde(e){return({width:t,height:n},r,s)=>new Promise(o=>{const i=document.createElement("canvas");i.width=t,i.height=n;const c=i.getContext("2d");if(!c)return o(null);r==="jpeg"&&(c.fillStyle="white",c.fillRect(0,0,t,n)),c.imageSmoothingQuality="high",c.drawImage(e,0,0,t,n),i.toBlob(d=>{i.width=0,i.height=0,o(d)},Kh[r],s)})}const yde=async e=>{const t=await createImageBitmap(e);return{width:t.width,height:t.height,encoder:gde(t),release:()=>t.close()}};function wde(e){return e.includes("Files")}function xde({files:e,hasText:t,intoTextField:n}){return e>0&&(!t||!n)}function vde(e,t){const n=e.indexOf(t);return e[n+1]??e[n-1]??null}function bde(e,t){if(t.length===0)return{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)};const n=new FormData;return n.append("kind",e.kind),n.append("title",e.title),n.append("body",e.body),e.contact!==void 0&&n.append("contact",e.contact),t.forEach((r,s)=>{const o=r.type===Kh.jpeg?"jpeg":"png";n.append("images",r,`image-${s+1}.${ade[o]}`)}),{method:"POST",body:n}}const kde="Add screenshot",j$="PNG or JPEG, up to three. You can also paste one, or drop it on this dialog.",jde="A screenshot can show emails, costs and paths. Crop out what should not be seen.",N$="Three images at most. Remove one to add another.",Nde="An image could not be attached, so nothing was sent. Check the images and send again; your text is still here.";function Sde(e,t,n){const r=n?`, resized to ${n.width} × ${n.height} to fit`:"";return`Replace image ${e+1}: ${t}${r}`}function _de(e,t){const n=`${e} of ${go}`;return t>0?`${n} · ${t} resized to fit`:n}function Ede(e){return`Three images at most, so ${e===1?"one was":`${e} were`} left out.`}function Cde(e){return`“${e.length>40?`${e.slice(0,30)}…${e.slice(-9)}`:e}”`}function Tde(e,t){const n=Cde(t);return e==="type"?`${n} is not a PNG or a JPEG, so it was not added. GIF, WebP and HEIC are not converted; save it as a PNG or a JPEG first.`:e==="no_room"?`There is no room left for ${n}: images go at up to 12 MB in all. Remove one to add it.`:e==="unreadable"?`${n} could not be read as an image.`:`${n} could not be made small enough to send: images go at up to 5 MB each.`}const SD="image/png,image/jpeg";function _D({className:e="fb-glyph"}){return a.jsxs("svg",{className:e,width:"14",height:"14",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,focusable:"false",children:[a.jsx("rect",{x:"1.8",y:"2.4",width:"10.4",height:"9.2",rx:"1.6"}),a.jsx("circle",{cx:"5",cy:"5.6",r:"1"}),a.jsx("path",{d:"M2.4 10.4 5.5 7.6l2.1 1.8 1.5-1.3 2.5 2.2"})]})}function Rde({images:e,buttonRef:t}){const n=y.useRef(null),r=e.shots.length>=go;return a.jsxs(a.Fragment,{children:[a.jsxs("button",{ref:t,type:"button",className:"fb-tool",title:j$,"aria-describedby":"fb-attach-hint",onClick:()=>{var s;return r?e.sayFull():(s=n.current)==null?void 0:s.click()},children:[a.jsx(_D,{}),kde]}),a.jsx("span",{id:"fb-attach-hint",hidden:!0,children:j$}),a.jsx("input",{ref:n,type:"file",accept:SD,multiple:!0,hidden:!0,onChange:s=>{e.add(Array.from(s.target.files??[])),s.target.value=""}})]})}function Ade({images:e,addRef:t}){const n=y.useRef(new Map),r=y.useRef(null),s=y.useRef(null),o=y.useRef(null),[i,c]=y.useState(null),{shots:d}=e,h=_de(d.length,d.filter(g=>g.resized).length);y.useLayoutEffect(()=>{var g;i!==null&&((g=i==="add"?t.current:n.current.get(i))==null||g.focus(),c(null))},[i,t]),y.useEffect(()=>{var g;e.problem&&((g=r.current)==null||g.scrollIntoView({block:"nearest"}))},[e.problem,e.problemId]);function f(g){c(vde(d.map(w=>w.id),g)??"add"),e.remove(g)}function p(g){var w;o.current=g,(w=s.current)==null||w.click()}return a.jsxs(a.Fragment,{children:[a.jsx("p",{className:"vis-hidden",role:"status",children:e.announcement}),a.jsx("input",{ref:s,type:"file",accept:SD,hidden:!0,onChange:g=>{const w=o.current;w!==null&&e.replace(w,Array.from(g.target.files??[])),o.current=null,g.target.value=""}}),d.length>0&&a.jsxs("div",{className:"fb-shots",children:[a.jsxs("div",{className:"fb-shots-row",children:[a.jsx("ul",{className:"fb-shots-list",children:d.map((g,w)=>a.jsxs("li",{className:"fb-shot","data-fitting":g.blob?void 0:!0,children:[a.jsxs("button",{type:"button",className:"fb-shot-pick","aria-label":Sde(w,g.name,g.resized),onClick:()=>p(g.id),children:[a.jsx("img",{className:"fb-shot-img",src:g.url,alt:""}),g.blob?a.jsx("span",{className:"fb-shot-cue","aria-hidden":"true",children:"Replace"}):a.jsx("span",{className:"fb-shot-busy","aria-hidden":"true",children:"Resizing…"})]}),a.jsx("button",{ref:k=>{k?n.current.set(g.id,k):n.current.delete(g.id)},type:"button",className:"glyph-btn fb-shot-remove","aria-label":`Remove image ${w+1}`,title:`Remove image ${w+1}`,onClick:()=>f(g.id),children:a.jsx("svg",{width:"10",height:"10",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round","aria-hidden":!0,focusable:"false",children:a.jsx("path",{d:"M2.5 2.5 7.5 7.5M7.5 2.5 2.5 7.5"})})})]},g.id))}),a.jsx("span",{className:"fb-shots-count",children:h})]}),a.jsx("p",{className:"fb-hint",children:jde})]}),e.problem&&a.jsx("p",{ref:r,className:"fb-error",role:"alert",children:e.problem},e.problemId)]})}function Mde(e,t){return e.map((n,r)=>({id:t+r,name:n.name,url:URL.createObjectURL(n.blob),blob:n.blob,resized:n.resized}))}function $de(e,t,n){return n?e.map(r=>r.id===t.id?t:r):[...e,t]}function Lde(e,t,n){return n?e.map(r=>r.id===t?n:r):e.filter(r=>r.id!==t)}function Ode(e){const[t,n]=y.useState(()=>Mde((e==null?void 0:e.ready)??[],1)),[r,s]=y.useState({problem:"",id:0}),o=y.useRef(0),i=y.useCallback(L=>{L&&o.current++,s(F=>L?{problem:L,id:F.id+1}:F.problem?{problem:"",id:F.id}:F)},[]),[c,d]=y.useState(""),h=y.useRef(t),f=y.useRef(null),p=y.useRef(t.length),g=y.useRef(!0),w=y.useRef(new Map),k=y.useRef([]),j=y.useRef(0),v=y.useCallback(L=>{h.current=L(h.current),n(h.current)},[]);y.useEffect(()=>(g.current=!0,()=>{g.current=!1;for(const L of h.current)URL.revokeObjectURL(L.url)}),[]);const b=y.useCallback(async(L,F)=>{const A=h.current.reduce((Z,W)=>{var X;return Z+(W.id===(F==null?void 0:F.id)?0:((X=W.blob)==null?void 0:X.size)??0)},0),B=(F==null?void 0:F.id)??++p.current,D=URL.createObjectURL(L),K={id:B,name:L.name||"image",url:D,blob:null,resized:null},G=j.current;w.current.set(B,L);let H=!1;const q=()=>{H||(H=!0,v(Z=>$de(Z,K,F!==void 0)))},M=await mde(L,hde(A),async Z=>(q(),yde(Z))).catch(()=>({ok:!1,problem:"unreadable"})),V=h.current.some(Z=>Z.id===B);return!g.current||j.current!==G||!V&&(H||F)?(URL.revokeObjectURL(D),F&&URL.revokeObjectURL(F.url),g.current&&w.current.delete(B),""):(w.current.delete(B),M.ok?(q(),F&&URL.revokeObjectURL(F.url),v(Z=>Z.map(W=>W.id===B?{...W,blob:M.blob,resized:M.resized}:W)),""):(URL.revokeObjectURL(D),H&&v(Z=>Lde(Z,B,F)),Tde(M.problem,L.name||"image")))},[v]),N=y.useCallback(async L=>{i("");const F=j.current,A=[];let B=0,D=0;for(const G of L){if(!g.current||j.current!==F)return;const H=k.current.indexOf(G);if(H!==-1&&k.current.splice(H,1),h.current.length>=go){B++;continue}const q=h.current.length,M=await b(G);M&&A.push(M),h.current.length>q&&D++}if(!g.current||j.current!==F)return;B>0&&A.push(D===0&&A.length===0?N$:Ede(B)),i(A.join(" "));const K=h.current.length;D>0&&d(`${D===1?"Image":`${D} images`} added, ${K} of ${go}.`)},[b,i]),S=y.useCallback(async(L,F)=>{i("");const A=h.current.find(K=>K.id===L);if(!A)return N([F]);const B=await b(F,A);if(!g.current)return;i(B);const D=h.current.findIndex(K=>K.id===L);!B&&D!==-1&&d(`Image ${D+1} replaced, ${h.current.length} of ${go}.`)},[N,b,i]),E=y.useCallback(L=>{const F=j.current;f.current=(f.current??Promise.resolve()).then(()=>j.current===F?L():void 0).catch(()=>{})},[]),C=y.useCallback(L=>{L.length!==0&&(k.current.push(...L),E(()=>N(L)))},[N,E]);y.useEffect(()=>{e&&e.waiting.length>0&&C(e.waiting)},[]);const $=y.useCallback((L,F)=>{const A=F[0];A&&E(()=>S(L,A))},[E,S]),T=y.useCallback(L=>{const F=h.current.find(A=>A.id===L);F&&(URL.revokeObjectURL(F.url),w.current.delete(L),v(A=>A.filter(B=>B.id!==L)),i(""),d(`Image removed, ${h.current.length} of ${go}.`))},[v,i]),I=y.useCallback(()=>i(N$),[i]),O=y.useCallback(async()=>{const L=o.current;return await f.current,o.current!==L?null:h.current.flatMap(F=>F.blob?[F.blob]:[])},[]),U=y.useCallback(()=>({ready:h.current.flatMap(L=>L.blob&&!w.current.has(L.id)?[{name:L.name,blob:L.blob,resized:L.resized}]:[]),waiting:[...w.current.values(),...k.current]}),[]),P=y.useCallback(()=>{j.current++;for(const L of h.current)URL.revokeObjectURL(L.url);w.current.clear(),k.current=[],v(()=>[]),i("")},[v,i]);return{shots:t,problem:r.problem,problemId:r.id,announcement:c,add:C,replace:$,remove:T,sayFull:I,ready:O,kept:U,clear:P}}function Ide(){const[e,t]=y.useState(null);return y.useEffect(()=>{let n=!0;return fetch("/api/feedback").then(r=>r.ok?r.json():null).then(r=>{n&&t(Aue(r))}).catch(()=>{}),()=>{n=!1}},[]),e}function Pde(e){const[t,n]=y.useState({state:"idle"}),r=y.useRef(!1),s=y.useRef(null);y.useEffect(()=>()=>{var c;return(c=s.current)==null?void 0:c.abort()},[]);async function o(c){if(!qn(r.current))return;r.current=!0;const{signal:d}=s.current=new AbortController;n({state:"sending"});try{const h=await e.ready();if(d.aborted)return;if(!h){n({state:"failed",message:Nde});return}const f=await fetch("/api/feedback",{...bde(Rue(c),h),signal:d}),p=await f.json().catch(()=>null);n(f.ok&&(p!=null&&p.ok)?{state:"sent"}:{state:"failed",message:v$(f.status,p==null?void 0:p.reason,p==null?void 0:p.errors)})}catch{d.aborted||n({state:"failed",message:v$(0,null)})}finally{r.current=!1}}const i=()=>n(c=>c.state==="failed"?{state:"idle"}:c);return{outcome:t,sending:t.state==="sending",send:o,clearFailure:i}}function Dde(e,t){const[n,r]=y.useState(!1),s=y.useRef(t);return s.current=t,y.useEffect(()=>{if(!e)return;const o=window.setTimeout(()=>r(!0),b$),i=window.setTimeout(()=>s.current(),b$+Vue);return()=>{window.clearTimeout(o),window.clearTimeout(i)}},[e]),n}const qb="agent-dag.feedbackDrafts",S$=4;function Fde({initialKind:e,initialBody:t}){return{kind:e??"bug",body:t??""}}function Bde(e){return JSON.stringify([e.kind,e.body])}function qde(e){return e.ready.length+e.waiting.length}function ED(e,t){return e.body.trim()!==t.body.trim()||e.contact.trim()!==""||e.images>0}function Ude(e){return e===1?"The screenshot was not kept through the page reload. Add it again to send it.":`The ${e} screenshots were not kept through the page reload. Add them again to send them.`}const Hde="Discard",Wde="Confirm discard",zde="Clear the message, the screenshots and the contact",_$="Press again to clear this draft. It cannot be brought back.",Vde={ready:[],waiting:[]};function Gde(e){if(!Array.isArray(e)||e.length!==2||typeof e[0]!="string")return null;const t=e[1];if(!t||typeof t!="object")return null;const{kind:n,body:r,contact:s,images:o}=t;return!Gh.some(i=>i.value===n)||typeof r!="string"||r.length>yD||typeof s!="string"||s.length>wD||typeof o!="number"||!Number.isInteger(o)||o<0||o>go?null:[e[0],{kind:n,body:r,contact:s,images:o}]}function Kde(e){let t=null;function n(){var o;if(t)return t;t=new Map;try{const i=(o=e())==null?void 0:o.getItem(qb),c=i?JSON.parse(i):[];if(Array.isArray(c))for(const d of c.slice(-S$)){const h=Gde(d);h&&t.set(h[0],{...h[1],images:null,imageCount:h[1].images})}}catch{}return t}function r(){try{const o=e();if(!o)return;const i=[...n()].map(([c,d])=>[c,{kind:d.kind,body:d.body,contact:d.contact,images:d.imageCount}]);i.length===0?o.removeItem(qb):o.setItem(qb,JSON.stringify(i))}catch{}}function s(o){n().delete(o)&&r()}return{read(o){const i=n().get(o);return i?{kind:i.kind,body:i.body,contact:i.contact,images:i.images??Vde,imagesLost:i.images?0:i.imageCount}:null},keep(o,i,c){const d=qde(i.images);if(!ED({body:i.body,contact:i.contact,images:d},c)){s(o);return}const h=n();h.delete(o),h.set(o,{kind:i.kind,body:i.body,contact:i.contact,images:i.images,imageCount:d});for(const f of h.keys()){if(h.size<=S$)break;h.delete(f)}r()},forget:s}}function Yde(){try{return typeof window>"u"?null:window.sessionStorage}catch{return null}}const uk=Kde(Yde),Xde=4e3;function Zde(e,t,n,r,s){const o=y.useRef(null);o.current={key:e,seed:t,words:n,images:r,sent:s};const i=y.useCallback(()=>{const c=o.current;!c||c.sent||uk.keep(c.key,{...c.words,images:c.images.kept()},c.seed)},[]);y.useEffect(i,[i,n.kind,n.body,n.contact,r.shots]),y.useEffect(()=>i,[i]),y.useEffect(()=>{s&&uk.forget(e)},[s,e])}const E$="draft";function Jde(e){const[t,n]=y.useState(!1),r=y.useRef(0);y.useEffect(()=>{if(!t)return;const o=window.setTimeout(()=>n(!1),Xde);return()=>window.clearTimeout(o)},[t]);function s(){const o=Date.now(),i=Xi({armedFor:t?E$:null,target:E$,armedAt:r.current,now:o,gapMs:Yi});if(i==="arm"){n(!0),r.current=o;return}i!=="ignore"&&(n(!1),e())}return{armed:t,press:s}}function CD({onClose:e,initialKind:t,initialBody:n}){const r=y.useRef(null),s=y.useRef(null),o=y.useRef(null),i=y.useRef(null),c=y.useRef(null),d=y.useRef(null),h=y.useRef(null),f=y.useRef(null),p=y.useRef(0),g=ot(e,{focusRef:r}),w=dt(e),k=Fde({initialKind:t,initialBody:n}),j=Bde(k),[v]=y.useState(()=>uk.read(j)),[b,N]=y.useState((v==null?void 0:v.kind)??k.kind),[S,E]=y.useState((v==null?void 0:v.body)??k.body),[C,$]=y.useState((v==null?void 0:v.contact)??""),[T,I]=y.useState((v==null?void 0:v.imagesLost)??0),[O,U]=y.useState(!1),[P,L]=y.useState(!1),[F,A]=y.useState(!1),B=Ode(v==null?void 0:v.images),D=Lue(Ide()),{outcome:K,sending:G,send:H,clearFailure:q}=Pde(B),M=K.state==="sent",V=Dde(M,e);Zde(j,k,{kind:b,body:S,contact:C},B,M);const Z=ED({body:S,contact:C,images:B.shots.length},k),W=Jde(()=>{var ge;N(k.kind),E(k.body),$(""),I(0),L(!1),B.clear(),q(),(ge=r.current)==null||ge.focus()}),X=gD(b),Y=P&&!w$(S),J=T>0&&B.shots.length===0,ee=[Y&&"fb-body-error",J&&"fb-images-lost"].filter(Boolean).join(" ")||void 0,[ne,se]=Hue(gf());y.useEffect(()=>{var Oe,qe;const ge=i.current;if(!ge)return;const Ae=ge.contains(document.activeElement)||Vn(((Oe=document.activeElement)==null?void 0:Oe.tagName)??null);ge.inert=M,M&&Ae&&((qe=s.current)==null||qe.focus())},[M]),y.useEffect(()=>{var Me,He;const ge=c.current;if(!ge)return;const Ae=h.current;if(G){const rt=document.activeElement,Ue=rt!=null&&(ge.contains(rt)||rt===Ae);f.current=Ue?rt:null,ge.inert=!0,Ae&&(Ae.inert=!0),f.current&&((Me=d.current)==null||Me.focus());return}ge.inert=!1,Ae&&(Ae.inert=!1);const Oe=f.current;f.current=null;const qe=document.activeElement===d.current||Vn(((He=document.activeElement)==null?void 0:He.tagName)??null);!M&&Oe&&qe&&Oe.focus()},[G,M]);function ce(ge){var Ae;if(ge.preventDefault(),!w$(S)){L(!0),(Ae=r.current)==null||Ae.focus();return}H({kind:b,body:S,contact:C})}const de=!M&&!G,ae=ge=>wde(Array.from(ge.dataTransfer.types));function pe(ge){!ae(ge)||!de||(ge.preventDefault(),p.current++,A(!0))}function fe(ge){ae(ge)&&(ge.preventDefault(),ge.dataTransfer.dropEffect=de?"copy":"none")}function Ee(ge){ae(ge)&&(p.current=Math.max(0,p.current-1),p.current===0&&A(!1))}function ye(ge){ae(ge)&&(ge.preventDefault(),p.current=0,A(!1),de&&B.add(Array.from(ge.dataTransfer.files)))}function oe(ge){ge.target!==ge.currentTarget||!ae(ge)||(ge.preventDefault(),ge.dataTransfer.dropEffect="none")}function we(ge){ae(ge)&&ge.preventDefault()}function Ne(ge){if(!de)return;const Ae=Array.from(ge.clipboardData.files),Oe=ge.target,qe=Oe instanceof HTMLTextAreaElement||Oe instanceof HTMLInputElement,Me=Array.from(ge.clipboardData.types).includes("text/plain");xde({files:Ae.length,hasText:Me,intoTextField:qe})&&(ge.preventDefault(),B.add(Ae))}return a.jsx("div",{className:"modal-backdrop",...w,role:"presentation",onDragOver:oe,onDrop:we,"data-leaving":V||void 0,children:a.jsxs("div",{ref:g,className:"modal feedback-dialog",onClick:ge=>ge.stopPropagation(),onDragEnter:pe,onDragOver:fe,onDragLeave:Ee,onDrop:ye,onPaste:Ne,role:"dialog","aria-modal":"true","aria-labelledby":"feedback-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{id:"feedback-title",className:"modal-tool-name",children:"Send feedback"})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{ref:s,type:"button",className:"glyph-btn",onClick:e,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsx("p",{className:"vis-hidden",role:"status",children:W.armed?_$:zue(K.state)}),a.jsxs("div",{className:"fb-stage",children:[a.jsxs("form",{ref:i,className:"fb-form",onSubmit:ce,onKeyDown:ge=>{Uue(ge.nativeEvent)&&(ge.preventDefault(),ge.currentTarget.requestSubmit())},noValidate:!0,children:[a.jsxs("section",{ref:c,className:"modal-body fb-body",children:[a.jsx(Gue,{kind:b,onChange:N}),a.jsxs("div",{className:"fb-compose",children:[a.jsx("label",{className:"fb-label",htmlFor:"fb-body",children:X.question}),a.jsx("textarea",{ref:r,id:"fb-body",className:"ap-manage-input fb-message",value:S,maxLength:yD,rows:5,placeholder:X.placeholder,onChange:ge=>E(ge.target.value),"aria-invalid":Y||void 0,"aria-describedby":ee,required:!0}),Y&&a.jsx("p",{id:"fb-body-error",className:"fb-error",children:_ue}),a.jsx(Ade,{images:B,addRef:o}),J&&a.jsx("p",{id:"fb-images-lost",className:"fb-hint",children:Ude(T)}),a.jsxs("div",{className:"fb-tools",children:[a.jsx(Rde,{images:B,buttonRef:o}),a.jsx(Kue,{open:O,onToggle:()=>U(ge=>!ge)})]}),a.jsx(Yue,{open:O,contact:C,onContact:$})]}),a.jsx("p",{className:"fb-facts",children:D?a.jsxs(a.Fragment,{children:[a.jsx("span",{className:"fb-facts-value",children:D})," — ",Oue]}):Iue}),K.state==="failed"&&a.jsx("p",{className:"fb-error",role:"alert",children:K.message})]}),a.jsxs("div",{className:"fb-foot",children:[Z&&a.jsx("button",{ref:h,type:"button",className:`btn danger fb-discard${W.armed?" armed":""}`,onKeyDown:ge=>{ge.repeat&&ge.preventDefault()},onClick:W.press,title:W.armed?_$:zde,children:W.armed?Wde:Hde}),a.jsxs("span",{className:"fb-shortcut","aria-hidden":"true",children:[a.jsx("kbd",{"data-symbol":Wue(ne)||void 0,children:ne}),a.jsx("kbd",{children:se})," to send"]}),a.jsx("button",{type:"button",className:"btn",onClick:e,children:"Cancel"}),a.jsx("button",{ref:d,type:"submit",className:"btn primary fb-send","aria-keyshortcuts":"Meta+Enter Control+Enter",...ts(G),children:a.jsxs("span",{className:"fb-send-label",children:[a.jsx("span",{className:"fb-send-idle",children:"Send feedback"}),a.jsx("span",{className:"fb-send-busy",children:"Sending…"})]})})]})]}),M&&a.jsxs("div",{className:"fb-done",children:[a.jsx($h,{}),a.jsx("p",{className:"fb-done-line",children:vD})]})]}),a.jsx("div",{className:"fb-drop","aria-hidden":"true","data-active":F||void 0,children:a.jsxs("div",{className:"fb-drop-frame",children:[a.jsx(_D,{className:"fb-drop-glyph"}),a.jsx("p",{className:"fb-drop-title",children:"Drop to attach"}),a.jsx("p",{className:"fb-drop-note",children:"PNG or JPEG, up to three"})]})})]})})}const Qde="Press Esc first if a key does nothing.",C$=[{title:"Canvas",rows:[{cap:"Space",action:"pause or resume the stream",binds:[" "]},{cap:"J",action:"next agent",binds:["j","J"]},{cap:"K",action:"previous agent",binds:["k","K"]},{cap:"W",action:"the session waiting on you — oldest first, again for the next",binds:["w","W"]},{cap:"F",action:"fit every agent on screen",binds:["f","F"]},{cap:"Z",action:"zoom to the selected agent and its session",binds:["z","Z"]},{cap:"Delete",action:"take the selected card off the board — the session list (L) brings it back",binds:["Delete"]},{cap:"R",action:"re-arrange the canvas and drop the pins",binds:["r","R"]},{cap:"Ctrl + Z",macCap:"⌘ Z",action:"undo a re-arrange, while the canvas offers it",binds:["z","Z"],chord:!0},{cap:"C",action:"clear the canvas and the event log — asks first",binds:["c","C"]}]},{title:"Panels and dialogs",rows:[{cap:"U",action:"usage panel",binds:["u","U"]},{cap:"L",action:"session list",binds:["l","L"]},{cap:"D",action:"detail panel",binds:["d","D"]},{cap:"H",action:"usage history",binds:["h","H"]},{cap:"A",action:"Claude accounts, where Claude Code is installed",binds:["a","A"]},{cap:"S",action:"this machine — cores, memory, temperature",binds:["s","S"]},{cap:"B",action:"Browser Watch",binds:["b","B"]},{cap:"?",action:"this sheet",binds:["?"]}]},{title:"Settings",rows:[{cap:"Ctrl + ,",macCap:"⌘ ,",action:"all settings",binds:[","],chord:!0},{cap:"V",action:"sound settings — the switch, and each tone's volume and sound",binds:["v","V"]},{cap:"M",action:"sound on or off",binds:["m","M"]},{cap:"T",action:"light or dark theme",binds:["t","T"]}]},{title:"Focus and selection",rows:[{cap:"Tab",action:"reach the agent cards",binds:[]},{cap:"Enter",action:"select the focused card",binds:["Enter"]},{cap:"Shift + Enter",action:"add the focused card to the selection",binds:["Enter"]},{cap:"Esc",action:"close what is open, deselect, release focus",binds:["Escape"]}]},{title:"Mouse",rows:[{cap:"drag",action:"move a node, and pin it where you dropped it",binds:[]},{cap:"shift-click",action:"add an agent to the selection",binds:[]},{cap:"click",action:"a card: go to it and its session",binds:[]},{cap:"double-click",action:"a card: its prompt, every tool call, tokens and timing",binds:[]},{cap:"hover",action:"zoomed out, a card's name, state and numbers",binds:[]}]}],ehe=/ \([A-Z?]\)/g;function the(e){return e?C$:C$.map(t=>({...t,rows:t.rows.filter(n=>n.chord||!n.binds.some(CI)).map(n=>({...n,action:n.action.replace(ehe,"")}))})).filter(t=>t.rows.length>0)}const nhe="Single-key shortcuts are off.",TD="Settings › General",rhe=`Single-key shortcuts can be turned off in ${TD}.`;function she({onClose:e,onTour:t,onSettings:n}){const r=ot(e),s=dt(e),o=yf(gf()),i=Cn(),c=the(i);return a.jsx("div",{className:"modal-backdrop",...s,role:"presentation",children:a.jsxs("div",{ref:r,className:"modal key-help",onClick:d=>d.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"key-help-title","aria-describedby":i?void 0:"key-help-off",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{id:"key-help-title",className:"modal-tool-name",children:"Keyboard shortcuts"})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:e,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[!i&&a.jsxs("div",{className:"kh-off",children:[a.jsxs("p",{className:"kh-off-text",id:"key-help-off",children:[a.jsx("strong",{children:nhe})," Turn them back on in"," ",a.jsx("span",{className:"kh-place",children:TD}),". Everything below still works."]}),n&&a.jsx("button",{type:"button",className:"btn",onClick:n,children:"Open Settings"})]}),t&&a.jsxs("div",{className:"guide-door",children:[a.jsx("span",{children:"Eight pictures of what the deck shows."}),a.jsx("button",{type:"button",className:"btn",onClick:t,children:"Take the tour"})]}),a.jsx("div",{className:"shortcuts",children:c.map(d=>a.jsxs(y.Fragment,{children:[a.jsx("h3",{className:"kh-group",children:d.title}),d.rows.map(h=>a.jsxs("div",{className:"sc",children:[a.jsx("kbd",{children:o&&h.macCap?h.macCap:h.cap}),a.jsx("span",{children:h.action})]},`${d.title}:${h.cap}:${h.action}`))]},d.title))}),i&&a.jsxs("p",{className:"kh-foot",children:[Qde," ",rhe]})]})]})})}function K1(e,t){return y.lazy(()=>e().catch(n=>(console.warn(`ccdeck could not load ${t}`,n),{default:({onClose:r})=>a.jsx(ahe,{name:t,onClose:r})})))}function ahe({name:e,onClose:t}){const n=y.useRef(null),r=ot(t,{focusRef:n}),s=dt(t);return a.jsx("div",{className:"modal-backdrop",...s,role:"presentation",children:a.jsxs("div",{ref:r,className:"modal dialog-missing",onClick:o=>o.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"dialog-missing-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{id:"dialog-missing-title",className:"modal-tool-name",children:e})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[a.jsxs("p",{className:"dm-note",children:[e," did not load. The deck has most likely been updated since this tab opened, and a reload picks up the new version."]}),a.jsxs("div",{className:"dm-actions",children:[a.jsx("button",{type:"button",className:"btn",onClick:t,children:"Close"}),a.jsx("button",{type:"button",ref:n,className:"btn primary",onClick:()=>window.location.reload(),children:"Reload"})]})]})]})})}function ohe(e,t){return`${e}#${t}`}function ihe(e,{lan:t,now:n,closed:r}){if(t===void 0)return[];const s=[];for(const o of e??[]){const i=o.reauth;if(!i||i.dismissed||o.origin!=="ccdeck_signin")continue;const c=ohe(i.key,i.since);if(r.has(c)||AQ(i.key,o.email,t,n))continue;const d=o.email??"";s.push({id:c,key:i.key,since:i.since,num:o.num,email:d,name:d||o.alias||`Account ${o.num}`,alias:d&&o.alias?o.alias:null})}return s}function lhe(e,t){const n=String((t==null?void 0:t.email)??"").trim().toLowerCase();return n?e.filter(r=>r.email.toLowerCase()===n&&((t==null?void 0:t.num)==null||String(r.num)===String(t.num))).map(r=>r.id):[]}function RD({rows:e,ours:t,dialogs:n}){return e===0?!1:t||n===0}function che(e){return e===1?"Account needs your attention":"Accounts need your attention"}function uhe(e){return`${e===1?"One Claude account needs":`${e} Claude accounts need`} you to sign in again.`}const dhe="Login expired",hhe="Until then the deck cannot read its usage or switch to it. Signing in again brings it back — it keeps its slot, its alias and its history.",fhe="The account stays marked in the Accounts panel. This will not ask again until it has worked and stopped again.";function phe(e,t){const n=(e??[]).filter(s=>s&&typeof s.fp=="string"&&!t.has(s.fp));if(!n.length)return{request:null,waiting:0};const r=[...n].sort((s,o)=>(s.at??0)-(o.at??0));return{request:r[0],waiting:r.length-1}}function mhe({request:e,waiting:t,busy:n,now:r,onAccept:s,onDecline:o,onLater:i}){const c=y.useRef(null),d=ot(i,{focusRef:c}),h=dt(i),f=Sa(n,"accept"),p=Sa(n,"dismiss");return a.jsx("div",{className:"modal-backdrop",...h,role:"presentation",children:a.jsxs("div",{ref:d,className:"modal lan-ask",onClick:g=>g.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-ask-title","aria-describedby":"lan-ask-who",children:[a.jsxs("header",{className:"modal-head",children:[a.jsxs("div",{className:"modal-title",children:[a.jsx("i",{className:"ap-pulse","aria-hidden":!0}),a.jsx("span",{id:"lan-ask-title",className:"modal-tool-name",children:"A deck wants to pair"})]}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:i,"aria-label":"Answer later (Esc)",title:"Answer later (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[a.jsxs("p",{id:"lan-ask-who",className:"lan-ask-who",children:[a.jsx("strong",{className:"lan-ask-name",children:e.name})," at ",a.jsx("code",{className:"ap-lan-code",children:e.addr})," · asked ",y1(e.at,r)]}),a.jsx("p",{className:"modal-note",children:"Paired decks repair each other's expired logins. Accept only if you know this machine — what it shares is an account, not a screen."}),a.jsxs("p",{className:"lan-ask-fp",children:["Its fingerprint is ",a.jsx("code",{className:"ap-lan-code",children:e.fp})," — that machine shows its own under This deck on the network; the two should match."]}),t>0&&a.jsx("p",{className:"lan-ask-more",children:t===1?"One more deck is waiting behind this one.":`${t} more decks are waiting behind this one.`}),a.jsxs("div",{className:"lan-ask-acts",children:[a.jsx("button",{type:"button",ref:c,className:"btn",disabled:p.disabled,"aria-busy":p.busy,onClick:o,title:"Nothing is shared. If that deck asks again, this comes back.",children:n==="dismiss"?"declining…":"Decline"}),a.jsx("button",{type:"button",className:"btn primary",disabled:f.disabled,"aria-busy":f.busy,onClick:s,title:"Talk to this deck from now on, and repair its expired logins with this deck's own.",children:n==="accept"?"accepting…":"Accept"})]})]})]})})}function ghe(e){const t=y.useRef(!1),n=yhe(e),r=RD({rows:n?1:0,ours:t.current,dialogs:jn.dialogDepth()});return t.current=r,r?n:null}function yhe({lanPending:e,lanDeferred:t,lanBusy:n,answerLanPair:r,deferLanPair:s}){const{request:o,waiting:i}=phe(e,t.current);return o?a.jsx(mhe,{request:o,waiting:i,busy:n,now:Date.now(),onAccept:()=>void r("accept",o.fp),onDecline:()=>void r("dismiss",o.fp),onLater:()=>s(o.fp)},o.fp):null}function whe({rows:e,onSignIn:t,onLater:n,firstRef:r}){const s=e.length===1?e[0]:null;return a.jsxs("section",{className:"modal-body",children:[s?a.jsxs(a.Fragment,{children:[a.jsxs("p",{id:"reauth-lead",className:"reauth-lead",children:["The Claude login for ",a.jsx("strong",{className:"reauth-name",children:s.name}),s.alias?a.jsxs("span",{className:"reauth-alias",children:[" (",s.alias,")"]}):null," ","has expired and needs a new sign","‑","in."]}),a.jsx("p",{className:"reauth-note",children:hhe})]}):a.jsxs(a.Fragment,{children:[a.jsx("p",{id:"reauth-lead",className:"reauth-lead",children:uhe(e.length)}),a.jsx("ul",{className:"reauth-list",children:e.map((o,i)=>a.jsxs("li",{className:"reauth-row",children:[a.jsxs("span",{className:"reauth-who",title:o.alias?`${o.alias} — ${o.name}`:o.name,children:[o.name,o.alias?a.jsxs("span",{className:"reauth-alias",children:[" ",o.alias]}):null]}),a.jsx("span",{className:"reauth-what",children:dhe}),a.jsx("button",{type:"button",className:"btn",ref:i===0?r:void 0,"aria-label":`Sign in again as ${o.name}`,onClick:()=>t(o),children:"Sign in again"})]},o.id))}),a.jsx("p",{className:"reauth-note",children:"Each keeps its slot, its alias and its history."})]}),a.jsxs("div",{className:"reauth-acts",children:[a.jsx("button",{type:"button",className:"btn",title:fhe,onClick:n,children:"Not now"}),s&&a.jsx("button",{type:"button",className:"btn primary",ref:r,onClick:()=>t(s),children:"Sign in again"})]})]})}function xhe({rows:e,onSignIn:t,onLater:n}){const r=y.useRef(null),s=ot(n,{focusRef:r}),o=dt(n);return a.jsx("div",{className:"modal-backdrop",...o,role:"presentation",children:a.jsxs("div",{ref:s,className:"modal reauth-ask",onClick:i=>i.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"reauth-title","aria-describedby":"reauth-lead",children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{id:"reauth-title",className:"modal-tool-name",children:che(e.length)})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:n,"aria-label":"Not now (Esc)",title:"Not now (Esc)",children:"×"})})]}),a.jsx(whe,{rows:e,onSignIn:t,onLater:n,firstRef:r})]})})}function vhe({rows:e,signingIn:t,signIn:n,signedIn:r,refresh:s,closeSignIn:o,later:i,pairing:c=!1}){const d=y.useRef(!1),h=jn.dialogDepth()+(c?1:0),f=t!=null||RD({rows:e.length,ours:d.current,dialogs:h});return d.current=f,t?a.jsx(X3,{email:t.email||null,onClose:o,onChanged:s,onSignedIn:r}):f?a.jsx(xhe,{rows:e,onSignIn:n,onLater:i},e.length===1?"one":"many"):null}const bhe={"//":["What a user would NOTICE. One key per version that has something to say,","and no key at all for a version that has nothing — which is most of them.","","The rule this file exists to serve: before every release, ask 'what would a","user notice?' and write the answer here. 'Nothing user-visible' is a valid","and expected answer, and it is spelled by adding no key. A release with no","key shows no modal, and that silence is what keeps the modal worth reading","on the day it is not silent.","","What belongs here: something that changed on the user's machine or under","their hands — a hook written to or removed from settings.json, a default","that flipped, a control that moved or went away, a stored preference that","changed meaning. What does not: bounds, races, assertions that could not","fire, anything that is invisible when it is correct.","","Write it for the person running the deck, not for the person reading the","diff. `title` is the sentence they scan; `body` is what they need in order","to act on it, or to stop worrying about it.","","Keys are versions exactly as package.json spells them. A key that is not a","version, or an entry missing either field, fails the suite rather than","being quietly dropped — see src/web/__tests__/release-notes-file.test.ts.","Ordering here is for humans; the deck sorts by version itself.","","A title may open with an emoji, and if it does, put exactly ONE space after","it. Not two: the dialog gives a leading emoji its own optical gap, because","a colour glyph is drawn edge to edge inside its advance and one word space","after one reads as none. A second space here would be a lie in the data","about a defect in the type, and the suite refuses both it and no space at","all.","","A release that genuinely has nothing to say is spelled TWICE: no key here,",'and its version written into "//nothing-to-say" below. One spelling on its',"own is ambiguous — a missing key reads the same whether it was a decision","or a forgotten step, and five releases in a row were once forgotten. The list","is what tells the two apart, and release-notes-current-version.test.ts fails","the release whose version is in neither place. Any key opening with // is a","note to the author and never a release."],"//nothing-to-say":["3.23.1","3.23.2","3.23.3","3.23.4","3.26.0","3.26.1","3.26.3","3.26.4","3.26.5","3.27.6","3.27.7","3.28.0","3.28.1","3.29.3","3.29.4","3.29.6","3.29.7","3.29.9","3.33.1","3.35.0","3.35.1","3.36.0","3.36.1","3.36.4","3.36.5","3.36.6","3.36.7","3.36.8","3.36.9","3.37.0","3.38.0","3.38.1","3.38.2","3.38.6","3.39.4","3.40.1","3.41.3"],"3.42.0":[{title:"🔠 Text size and density, in Settings",body:"Five text sizes and five spacing levels, under Settings › Text & density."},{title:"🛠️ Tool activity: which tools your agents use, how long they take and what fails",body:"A new page on the stripe on the right. Its history is kept on this device only."},{title:"🎨 Gruvbox Dark, Light and Material themes",body:"Pick one in Settings › General. Switching themes now fades instead of snapping."},{title:"✨ A session-list drawer on phones, whole dates in usage history, the waiting session in the minimap",body:"Smaller fixes for the phone layout, the usage history chart and the canvas minimap."}],"3.41.1":[{title:"🪟 More reliable Windows updates",body:"Restart to update stops the app’s background server before installation begins."},{title:"📊 More accurate account capacity",body:"Elapsed resets and older readings no longer imply newly available quota. Account refreshes keep the latest valid readings."},{title:"🖥️ Better layouts on portrait displays",body:"Sessions fill the right columns, and the canvas starts near the top. Usage history controls stay reachable in narrow windows."},{title:"✨ Clearer load history and consistent icons",body:"Load history includes the current core-capacity multiplier below the charts. Refresh and external-link icons look consistent across system fonts."}],"3.41.0":[{title:"📅 Plan account resets",body:"See the next seven days of resets, account capacity and which readings need refreshing."},{title:"📊 Follow quota history",body:"Inspect recorded Claude and Codex quota readings to see how remaining capacity changes over time."},{title:"♻️ See cached input reuse",body:"Session usage details now show the percentage of measured input reused from cache."},{title:"📻 A more polished Radio Explorer",body:"Find radio stations with compact search and filters, explore workspace streams separately, and save favorites from either source. Playback and keyboard navigation are more reliable."},{title:"🌍 Radio flags on Windows",body:"Country flags now display correctly in the radio station list on Windows."},{title:"🔧 Clearer Telemetry Radar controls",body:"Change individual telemetry flags and use a simpler Monitor view."}],"3.40.2":[{title:"📻 Music is in Radio now, not in Settings",body:"Settings no longer has a Music section. Claude FM, Lofi Girl and the streams you added are under Workspace streams in Radio, on the right sidebar, and Radio’s player has the volume and mute. Your station, volume and streams are kept. Adding, renaming or removing a stream link is no longer offered."}],"3.40.0":[{title:"📻 Explore radio around the world",body:"Open Radio from the right sidebar to discover stations on a world map, filter by country, sound or language, and save your favorites. Recent listening, a daily pick and Surprise me make it easier to find something to play. Music keeps playing when you close the explorer. Volume now adjusts in 1% steps, and an unavailable stream automatically advances to the next station after one second."},{title:"🦊 Choose your canvas companion",body:"Choose Deck companion, Fox or Penguin in Settings › General. Your companion shares the existing canvas movements and music controls, and your choice stays saved."},{title:"📊 See what each session used",body:"Open a session’s usage details to inspect tokens, models and estimated cost. For Codex, compare Automatic, Standard, Fast and Flex pricing estimates without changing your Codex settings or billing."},{title:"A clearer canvas",body:"Session cards, tool traces and connections are easier to scan. The canvas reframes more reliably when resizing to portrait or rearranging sessions, and model cost estimates use updated pricing."}],"3.39.3":[{title:"A cleaner desktop window",body:"The desktop app now has one compact toolbar that follows your theme, with native window controls and an application menu. Wider side rails give icons more room; the Local network footer and unread badges are more compact."},{title:"Clearer account usage and Telemetry Radar",body:"Account usage shows reset times together with capacity. Telemetry Radar has a clearer monitoring workspace and keeps history for up to 24 hours. Radar remains Beta."},{title:"🔎 Telemetry Radar on Linux and Windows, with no Terminal step",body:"Radar now works on macOS, Linux and Windows. Press Start monitoring and ccdeck runs the capture itself, with no command to paste into Terminal, and keeps listening until you stop it. Capture needs a one-time setup for your user: Wireshark’s ChmodBPF helper on macOS, tcpdump with capture permission on Linux, or Wireshark with Npcap on Windows. Radar says what is missing, and once permission is granted it starts listening by itself."}],"3.39.1":[{title:"🎨 More themes, with clearer contrast",body:"Choose Omarchy, Matrix, Black Contrast, White Contrast or Catppuccin Mocha in Settings › General. Fresh installations start with Rider Black; your saved theme choice is preserved."},{title:"A little more room on the canvas",body:"The minimap is smaller, leaving more room for the character and your sessions. Undo and Resume now sit beside each other at the bottom of the canvas. Telemetry Radar is marked Beta while it is being tested and improved."}],"3.39.0":[{title:"🔎 Inspect Claude Code telemetry on macOS",body:"Telemetry Radar shows Claude Code's configured telemetry and can inspect traffic at destinations you choose. When settings are absent, it can show observed connections separately; a connection alone does not prove telemetry or reveal message contents. Captured telemetry can contain prompt or response content, and other apps sending to the same destination may appear too. Captured messages stay in ccdeck's memory, and no capture file is written."},{title:"🧭 Open panels from the edges",body:"Open the session list, Claude accounts, Usage, This machine, Usage history and Browser Watch from the window edges. You can keep several panels open beside the canvas; on a phone, the same controls sit in a bottom dock."},{title:"More control while you work",body:"Turn off single-key shortcuts if typed letters should not control the deck, see each stage while adding a Claude account, and undo a recent rearrangement. The topbar also names the Claude Code session waiting on you."},{title:"🎨 Two new dark themes",body:"Choose Rider Black or VS Code Black in Settings › General. Both add a darker canvas with flatter panels and distinct focus accents; your existing Light or Dark choice stays as it was."}],"3.38.5":[{title:"🔧 Settings are in one place now",body:"The theme, the sounds, notifications and the minimap character are all in Settings, behind the gear at the right of the topbar, or Cmd+, (Ctrl+, on Windows and Linux). V opens it at Sounds, with each tone's volume and sound, and M turns sounds off or on from anywhere. Nothing you had set has changed, it has only moved, and T still switches the theme. The auto-switch threshold also takes a custom value now: pick Custom… and type a whole percent from 50 to 99."},{title:"Windows: no more temperature stuck at 28 °C",body:"On many Windows laptops the only temperature Windows offers is a thermal zone wired to nothing, which reads a fixed 28 °C however hot the CPU is, and the machine panel showed it as a reading. A thermal zone is now drawn only once its value has changed. Until then the panel shows LibreHardwareMonitor's readings if its web server is running, and otherwise no Thermal section at all: the deck never invents a reading."}],"3.38.4":[{title:"🔔 A notification when Auto-switch changes your account",body:'When Auto-switch moves Claude Code to another account, ccdeck now tells you once, with where it went and why, for example "Switched to work · personal@example.com reached 90%". You can turn it off in Settings › Notifications, where two more wait, off until you turn them on: one when a quota window of the Claude or Codex account you are on reaches 90% and again at 100%, and one when a window that had reached 90% is available again. Each is said once per window and a restart does not repeat it. With either quota notification on, the deck reads quota about every two minutes even while no page is open.'}],"3.38.3":[{title:"🧾 Subagent costs count their whole reply",body:"A subagent's request was counted from the first moment of its reply, before most of it had been written, so much of its output was left out of the deck's token and cost counts, and a subagent turn in fast mode was priced at the standard rate. Each request is now counted from its finished reply. Days with subagents will read higher than before: that is the part that was missing, not a new charge. Projects counts its history again once after the update, so past days come out right too. Codex sessions on GPT-6 Sol, GPT-6.1 Sol and GPT-6 Luna now show a cost instead of not priced."}],"3.37.1":[{title:"🔁 Expired logins repair from your other machines",body:"When a login stops working on this machine and a machine you paired with still has it working and ticked, Local network now copies it back on the next round, whether or not the account is ticked here. Before, it stayed marked expired until the account was ticked here as well, or deleted so that it arrived again. A machine that paired on its own, through Say yes to every deck that asks, still repairs only the accounts ticked here."}],"3.36.3":[{title:"🔑 An expired login asks to be signed in again",body:"When an account you added with + → Sign in stops working, the deck now tells you in one dialog, with every affected account together and Sign in again beside each. That opens the usual sign-in with the address already filled in, and the account keeps its slot, its alias and its history. Not now leaves it marked in the Accounts panel and does not ask again until it has worked and stopped again. A paired deck holding a working copy gets to repair it first, and accounts that came from a share or Local network are never asked about."}],"3.34.1":[{title:"🗂️ The tray menu stays open while you read it",body:"On Linux the menu behind the tray icon could close by itself while agents were working, often before the row you pressed took the click, so it had to be opened and pressed again. It now changes only when something it says has changed, and stays open while you choose."}],"3.34.0":[{title:"🗺️ The network map shows who you are connected to",body:"Paired decks that are on stand closest to this one, and a light runs along their wires. Paired decks that are away come next, in a colour of their own, with how long they have been gone, and machines that are not paired stand outside in grey. Decks reached over Tailscale sit together in their own shaded slice instead of on dashed wires. Pointing at a deck opens its details beside the map: whether it is there, what to do next if anything, its address and what it runs, and every login the two share, the ones that need a look first."},{title:"🔑 A login that expired everywhere says so",body:`When a shared login expired on this deck and every paired deck that is on held an expired copy too, the row said "Login expired" and waited for a repair that could never come. It now says "Login expired on all online decks". Claude retires a login's other copies each time one machine refreshes it, so shared copies expire together: sign in again on any one machine and the others repair from it on their next round.`},{title:"💬 Send feedback from inside the deck",body:"Feedback, beside Settings at the right of the topbar (under More on a phone), opens a short form: pick what kind it is, write a few lines, and add a way to reach you under Add details if you want an answer. It goes to the people who make ccdeck, who may open a public issue from it, never with your contact in it. If it cannot be sent, the form stays filled in and says why."}],"3.33.0":[{title:"🪝 Hooks you add in Claude Code are no longer removed",body:"Claude Code's hook editor often files a new hook into the same group as the deck's own. Starting the deck, or uninstalling it, then removed the whole group, and your hook went with it without a word. The deck now takes out only its own command and leaves yours where it was, and the same goes for the old finish-sound hook. `ccdeck --uninstall` also stops the decks that are running, so an update in the background cannot put the hooks back."},{title:"🧵 Resumed Codex sessions show up again",body:"A Codex session picked up with `codex resume`, or one that ran for days, could go dark on the canvas and drop out of the 5-hour and 7-day usage, because the deck only looked in the two newest day folders. It now follows those sessions and counts their tokens. Two Codex sessions in the same folder get different id suffixes, and a `bash -lc` call shows the command it runs."},{title:"🤝 A deck paired by the accept switch brings in less",body:'A deck that paired through the automatic accept switch, and not through an invite, now brings in only the logins you have ticked on this deck, and nothing from it is ticked for sharing onward. Its dialog says "paired automatically — pair by invite to take it". Pairing by invite works as before. A typed address is no longer dropped after one failed round, and the sync port stays the same after a rename.'},{title:"⬆️ Desktop updates install when you expect them",body:'On Windows and Linux a downloaded update now installs when you quit. On a Mac, Quit installs it and the app stays closed. The Linux .deb needs an administrator password to install, so it no longer does that by itself: it waits for "Restart to update" and says a password is coming. "Start at login" now works on Linux, and "Restart ccdeck" stops a deck that has hung.'},{title:"🕵️ Browser Watch waits before it acts, and quits only its own browser",body:"A program's visit is now logged and reacted to once its quiet window has closed, about 16 minutes after it, and not on the first poll, so a visit that is withdrawn no longer quits the browser. On Linux the quit reaction ends only the browser that holds the watched profile; other Chrome channels and headless browsers keep running. When it cannot tell which process that is, it does nothing and says so, which includes a Flatpak Brave."},{title:"🧮 Figures that were off are right",body:`Spend by labelled and workflow subagents counts toward a session's tokens and cost. The Projects report prices 1-hour cache writes the way ccusage does, so its dollars match the Usage panel. After a restart the deck rebuilds its whole event history, where it used to rebuild about a third. On Linux the process list shows what each process is using now, not its lifetime average. A count near a boundary reads "1.00M", and a full quota window says "used up".`},{title:"🔑 The Usage panel's reads answer the deck's own page only",body:"The routes behind the Usage panel (/api/quota, /api/ccusage, /api/codex-usage, /api/codex-quota and /api/cswap-auto) now answer the deck's own page, or a client that sends the deck's token. A script that read them with a plain request gets 401 from this version on. The hook, the desktop app and the `ccdeck` command are not affected."},{title:"🛠️ Smaller fixes you may notice",body:"With the canvas paused, an update no longer restarts the server while an agent is working: it waits until no turn is open. `ccdeck --stop -p4317` stops that one deck. A deck started at login can update itself on Homebrew and nvm setups. Dialogs keep keyboard focus after a button goes away, screen readers hear pairing requests by deck name and the machine panel's readings, dim text is readable in both themes, Windows High Contrast shows what is selected, and below 640px the detail panel opens over the canvas."}],"3.32.2":[{title:"🔒 Self-updates wait until your screen is unlocked",body:"On Linux with GNOME, the app installs an update by itself when you leave it alone, which is often while your screen is locked. GNOME switches the panel's tray off under the lock screen, and a version that started then never showed its icon. The app now waits until you are back before restarting by itself, so its icon comes back with it."}],"3.32.1":[{title:"🔔 The tray icon comes back on Linux",body:"On Linux the app could lose its icon in the panel, after it updated itself or when the panel restarted, and stay without it until it was quit. It now notices within a minute and restarts by itself the next time you are away from its window, the way it installs an update. It does this at most once every six hours, and not again if a restart did not help."},{title:"🔕 A window you closed stays closed after a self-update",body:"When the app restarted by itself to install an update, it opened its window again even if you had closed it, and while that window was open the deck held back its notifications. A window you closed now stays closed."},{title:"🪟 No empty icon when ccdeck is already open",body:'Opening ccdeck again while it was running flashed an empty "…" icon in the Linux panel before bringing the window forward. It now only brings the window forward.'}],"3.32.0":[{title:"🗺️ A map of your network",body:"A new button on the Local network row, and in its view's header, opens a map of every deck around this one. This deck is at the centre and the paired decks that are on stand around it. Further out are the quiet ones, the machines nearby and any deck asking to pair. Wires are solid on your local network and dashed over Tailscale. Pointing at a deck says how it is reached, what it runs and which logins the two share, and pressing it opens that deck's own dialog."}],"3.31.0":[{title:"📊 Account capacity",body:"A gauge button in the accounts panel's header opens Account capacity: how many of your Claude accounts are ready now, what the 5-hour and 7-day windows have left across all of them, and a row for each account with its use, its state (Ready, Limited, Exhausted or Stale) and when it was last read. Each window also says whose reset comes next."},{title:"🚦 Claude and Codex incidents",body:"When Anthropic's or OpenAI's status page reports an incident on something your sessions use, the deck says so in the topbar, the Usage panel and the tray, and every mark links to the status page. A provider with nothing wrong draws nothing."},{title:"↕️ Order your other accounts",body:"The Other accounts row can sort the list by slot, by how full a window is, or by most room, and open every account at once. Both stay as you left them after a reload."},{title:"🔐 A settings folder left by sudo can be given back",body:'On a Mac, running ccdeck once with sudo left its settings folder owned by another user, and every settings change was refused, sharing an account included. The message now offers "give it back": macOS asks for your password, the folder is yours again, and the deck reads its settings back without a restart.'}],"3.30.0":[{title:"🧮 Token counts and costs are no longer doubled",body:"Claude Code writes a reply that has thinking, text and tool calls as several transcript lines, each carrying the whole request's usage. The deck added up every line, so a session's tokens and cost on its card came out close to twice what it was billed, and the context panel counted each part of a reply as its own message. Each request is now counted once. Expect the totals on your cards to come down."},{title:"⏳ Claude's saved limit resets on the Usage panel",body:`When your Claude account has free limit resets to spend ("Reset for free" in Claude's Settings → Usage), the Claude card now says how many there are and when the first one expires, the way the Codex card already did. The deck only reports them; you spend them in Claude's own settings.`},{title:"🔑 LAN invites need the other deck updated",body:`An invite's code is now a long random secret instead of six digits, so nobody else on the network can work it out and pair in your place, and a wrong code is refused by name. An invite made on this version can only be joined from a deck on this version or later: an older deck answers "That is not an invite". Update that deck, or make the invite on the older one and join it here.`},{title:"🔕 AGENTS_DECK_NO_NOTIFY keeps Browser Watch quiet too",body:"A deck started with AGENTS_DECK_NO_NOTIFY=1 still raised a desktop notification for every new Browser Watch finding. It no longer does. The finding is still in the Browser Watch panel and its log, which says why no notification came."},{title:"🛠️ Smaller fixes",body:'Delete removes the card you just clicked. A LAN address you typed stays in the list when a round cannot reach it, and the status line under the LAN switch now agrees with the rows below it. In the desktop app, a dismissed "update is ready" notice stays dismissed after you answer the first-launch question. Sizes read the same in every panel ("1.1 KB"). Faded text stays readable, a keyboard can see the scrollbar, and numbers use a monospaced font on Windows and Linux as well.'}],"3.29.11":[{title:"💲 Claude Sonnet 5.5 has a price",body:`Sessions on Claude Sonnet 5.5 showed "not priced" on the board, and the Projects report could only show a minimum for them. They are now priced at Anthropic's published rate, the same as Sonnet 5: $2 per million input tokens and $10 per million output tokens.`}],"3.29.10":[{title:"💲 Claude Opus 5.5 has a price",body:`Sessions on Claude Opus 5.5 showed "not priced" on the board, and the Projects report counted them as costing nothing, so its totals read far too low. They are now priced at Anthropic's published rate. If a model still has no price, Projects shows its total as a minimum, like $11.19+, and names the model, instead of a total that looks complete.`}],"3.29.8":[{title:"🔁 Removed cards come back when their agent works again",body:"Remove from board is for finished work. If the agent behind a card you removed starts a tool call, gets a new prompt or starts a subagent, the card returns on its own, together with the card it hangs from, and it stays back after a reload. Cards whose agents stay idle stay removed."}],"3.29.1":[{title:"🗂️ One row per project in Projects",body:"The Projects report now counts a session's work under the folder you started it in, the same name its card has on the canvas, instead of adding a row for every folder the agent moved into. The first start after updating re-reads your transcripts once to regroup the report."},{title:"🔔 Tidier custom sounds",body:"Importing a sound, recording one and choosing a spoken voice now sit in compact cards that respond to clicks and focus like the rest of the deck."}],"3.29.0":[{title:"🎵 Your own stations in Claude FM",body:"Add any YouTube live link or radio stream as a station in Appearance, next to the built-in ones, and mute the music without losing your volume. When a station is not live, the picker now says so instead of staying silent."},{title:"🔔 Notification sounds and voices of your own",body:"Pick a local audio file or a spoken voice for each alert, so the sound that means an agent is waiting is one you will recognise."},{title:"🗑️ Drag a card off the board to remove it",body:"Drag a card to the target at the bottom of the canvas to take it off the board, or use Remove from board in the detail panel (Delete). The session keeps running, and the session list (L) brings it back."},{title:"🔐 Optional invite-only pairing",body:"Pairing works as before, with or without an invite. If you want, Local network can now be set to accept only decks that join with an invite you created, so a nearby machine cannot ask to pair on its own."},{title:"🌐 Account sharing between your machines is more reliable",body:"A locked macOS Keychain is explained instead of failing silently, a login that is broken or belongs to another account is never shared, and a sync that stops partway keeps what already arrived."},{title:"📅 Projects opens on Today",body:"The Projects report per account starts with today's work, and an empty window offers the next wider one. The desktop app can also 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:"Settings › General shows a small preview of the deck in each theme. 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.
|
|
108
|
-
|
|
109
|
-
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.
|
|
110
|
-
|
|
111
|
-
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.
|
|
112
|
-
|
|
113
|
-
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.
|
|
114
|
-
|
|
115
|
-
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.
|
|
116
|
-
|
|
117
|
-
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".
|
|
118
|
-
|
|
119
|
-
**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.
|
|
120
|
-
|
|
121
|
-
\`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.
|
|
122
|
-
|
|
123
|
-
**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.
|
|
124
|
-
|
|
125
|
-
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.
|
|
126
|
-
|
|
127
|
-
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.
|
|
128
|
-
|
|
129
|
-
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.
|
|
130
|
-
|
|
131
|
-
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.
|
|
132
|
-
|
|
133
|
-
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.
|
|
134
|
-
|
|
135
|
-
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.
|
|
136
|
-
|
|
137
|
-
What you are reading is the first version that does not.
|
|
138
|
-
|
|
139
|
-
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 ways it opens: its ×, its button on the window's right edge, and S. 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, on the window's right edge now, opens the same **This machine** panel — cores, memory, swap, load, temperature, busiest processes — and the bar stops moving in the corner of your eye.
|
|
140
|
-
|
|
141
|
-
It 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.
|
|
142
|
-
|
|
143
|
-
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.
|
|
144
|
-
|
|
145
|
-
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.
|
|
146
|
-
|
|
147
|
-
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.
|
|
148
|
-
|
|
149
|
-
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.
|
|
150
|
-
|
|
151
|
-
The count of what is behind it is on the heading's tooltip, so collapsing it does not hide how much there is.
|
|
152
|
-
|
|
153
|
-
**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.
|
|
154
|
-
|
|
155
|
-
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.
|
|
156
|
-
|
|
157
|
-
\`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.
|
|
158
|
-
|
|
159
|
-
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. Its button is on the window\'s left edge now.\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.
|
|
160
|
-
|
|
161
|
-
**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.
|
|
162
|
-
|
|
163
|
-
**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.
|
|
164
|
-
|
|
165
|
-
**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.
|
|
166
|
-
|
|
167
|
-
**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.
|
|
168
|
-
|
|
169
|
-
**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.
|
|
170
|
-
|
|
171
|
-
**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.
|
|
172
|
-
|
|
173
|
-
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.
|
|
174
|
-
|
|
175
|
-
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.
|
|
176
|
-
|
|
177
|
-
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.
|
|
178
|
-
|
|
179
|
-
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.
|
|
180
|
-
|
|
181
|
-
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 Settings › Notifications 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.
|
|
182
|
-
|
|
183
|
-
There is a **Notifications** switch in Settings › Notifications now. One switch governs both notifiers, it takes effect immediately without a restart, and it is remembered across restarts.
|
|
184
|
-
|
|
185
|
-
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 Settings 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.
|
|
186
|
-
|
|
187
|
-
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 appeared while something was actually blocked.
|
|
188
|
-
|
|
189
|
-
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.
|
|
190
|
-
|
|
191
|
-
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.
|
|
192
|
-
|
|
193
|
-
Now it reaches the desktop, two ways that never overlap. With the deck open behind something, the page raises the notification itself: the browser asks for permission when you turn notifications on in Settings › Notifications — nothing is requested before you do. 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.
|
|
194
|
-
|
|
195
|
-
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.
|
|
196
|
-
|
|
197
|
-
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.
|
|
198
|
-
|
|
199
|
-
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.
|
|
200
|
-
|
|
201
|
-
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.
|
|
202
|
-
|
|
203
|
-
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.
|
|
204
|
-
|
|
205
|
-
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.
|
|
206
|
-
|
|
207
|
-
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.
|
|
208
|
-
|
|
209
|
-
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.
|
|
210
|
-
|
|
211
|
-
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.
|
|
212
|
-
|
|
213
|
-
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.
|
|
214
|
-
|
|
215
|
-
It is gone. The panel still shows the board's tokens and cost 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.
|
|
216
|
-
|
|
217
|
-
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.
|
|
218
|
-
|
|
219
|
-
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.
|
|
220
|
-
|
|
221
|
-
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.
|
|
222
|
-
|
|
223
|
-
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 Browser Watch badge no longer counts findings while the watch is off; open the panel to see them.
|
|
224
|
-
|
|
225
|
-
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.
|
|
226
|
-
|
|
227
|
-
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.
|
|
228
|
-
|
|
229
|
-
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.
|
|
230
|
-
|
|
231
|
-
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.
|
|
232
|
-
|
|
233
|
-
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.
|
|
234
|
-
|
|
235
|
-
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.
|
|
236
|
-
|
|
237
|
-
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.
|
|
238
|
-
|
|
239
|
-
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.
|
|
240
|
-
|
|
241
|
-
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.
|
|
242
|
-
|
|
243
|
-
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.
|
|
244
|
-
|
|
245
|
-
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.
|
|
246
|
-
|
|
247
|
-
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.
|
|
248
|
-
|
|
249
|
-
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.
|
|
250
|
-
|
|
251
|
-
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".
|
|
252
|
-
|
|
253
|
-
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.
|
|
254
|
-
|
|
255
|
-
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.
|
|
256
|
-
|
|
257
|
-
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.
|
|
258
|
-
|
|
259
|
-
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.
|
|
260
|
-
|
|
261
|
-
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.
|
|
262
|
-
|
|
263
|
-
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.
|
|
264
|
-
|
|
265
|
-
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.
|
|
266
|
-
|
|
267
|
-
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:`Browser Watch is new, on the window's right edge (or press B). 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.
|
|
268
|
-
|
|
269
|
-
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.
|
|
270
|
-
|
|
271
|
-
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.
|
|
272
|
-
|
|
273
|
-
When it finds something, its button shows 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.
|
|
274
|
-
|
|
275
|
-
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.
|
|
276
|
-
|
|
277
|
-
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.
|
|
278
|
-
|
|
279
|
-
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.
|
|
280
|
-
|
|
281
|
-
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:`Open Settings › Sounds, or press V. 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.
|
|
282
|
-
|
|
283
|
-
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.
|
|
284
|
-
|
|
285
|
-
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.
|
|
286
|
-
|
|
287
|
-
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.
|
|
288
|
-
|
|
289
|
-
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.
|
|
290
|
-
|
|
291
|
-
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.
|
|
292
|
-
|
|
293
|
-
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.
|
|
294
|
-
|
|
295
|
-
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.
|
|
296
|
-
|
|
297
|
-
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.
|
|
298
|
-
|
|
299
|
-
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.
|
|
300
|
-
|
|
301
|
-
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.`}]},Y1="agent-dag.releaseNotesSeen";function T$(e){return e.split(/[.\-+]/).map(t=>parseInt(t,10)).map(t=>Number.isNaN(t)?0:t)}function Zi(e,t){const n=T$(e),r=T$(t);for(let s=0;s<Math.max(n.length,r.length);s++){const o=(n[s]??0)-(r[s]??0);if(o!==0)return o<0?-1:1}return 0}function Ji(e){return typeof e=="string"&&/^\d+\.\d+\.\d+/.test(e)}function khe(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 jhe(e){if(!e||typeof e!="object")return[];const t=[];for(const[n,r]of Object.entries(e)){if(!Ji(n)||!Array.isArray(r))continue;const s=r.filter(khe);s.length&&t.push({version:n,notes:s})}return t.sort((n,r)=>Zi(r.version,n.version))}const R$=jhe(bhe);function AD(e,t,n){return e.filter(r=>Zi(r.version,n)<=0&&(t===null||Zi(r.version,t)>0))}function Nhe(e,t){return e.filter(n=>Zi(n.version,t)===0)}function She(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 _he({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 i=n.length===1?"one release":`${n.length} releases`;return`You were last caught up at v${e}. Since then ${i} changed something you would notice. Clicking the version in the topbar brings this back.`}if(r&&Ji(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(!Ji(t))return"Everything this build has to say, newest first. Most releases have nothing here, which is why the deck stays quiet about them.";const o=Zi(s,t);return o<0?`v${t} · 🐛 Bug fixes and performance improvements. Earlier release notes are shown below.`:o>0?"Everything this build has to say, newest first. Most releases have nothing here, which is why the deck stays quiet about them.":`You are running v${t}, and this is what it changed — and everything before it, newest first. Most releases have nothing here, which is why the deck stays quiet about them.`}const Ehe=new RegExp("^(?:\\p{Extended_Pictographic}|\\p{Emoji_Modifier}|\\p{Regional_Indicator}|[\\u200D\\uFE0F])+(?= \\S)","u");function Che(e){const t=Ehe.exec(e);return t?{icon:t[0],rest:e.slice(t[0].length)}:{icon:null,rest:e}}function The(e){if(!e)return null;let t=null;try{t=e.getItem(Y1)}catch{return null}return Ji(t)?t:null}function Rhe(e){if(!e)return!1;try{return e.getItem(Y1),!0}catch{return!1}}function Ahe(e,t){if(!e)return!1;try{return e.setItem(Y1,t),!0}catch{return!1}}const MD="agent-dag.tourSeen";function Mhe(e){if(!e)return!1;try{return e.getItem(MD)==="1"}catch{return!1}}function $he(e){if(!e)return!1;try{return e.setItem(MD,"1"),!0}catch{return!1}}function Lhe({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 Ohe({stored:e,running:t,notes:n,remembers:r=!0}){if(!Ji(t))return{show:[],record:null,reason:"no-version"};if(!Ji(e)){if(!r)return{show:[],record:t,reason:"cannot-remember"};const i=Nhe(n,t);return i.length?{show:i,record:t,reason:"welcome"}:{show:[],record:t,reason:"first-run"}}const s=Zi(e,t);if(s===0)return{show:[],record:null,reason:"seen"};if(s>0)return{show:[],record:null,reason:"ahead"};const o=AD(n,e,t);return o.length?{show:o,record:t,reason:"new-notes"}:{show:[],record:t,reason:"nothing-new"}}function Ihe(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 $D(e,t=!0){const n=[];let r="";const s=()=>{r&&(n.push({kind:"text",text:r}),r="")};let o=0;for(;o<e.length;){if(e[o]==="`"){const i=e.indexOf("`",o+1);if(i>o+1){s(),n.push({kind:"code",text:e.slice(o+1,i)}),o=i+1;continue}}else if(t&&e.startsWith("**",o)){const i=Ihe(e,o);if(i>0){s(),n.push({kind:"bold",kids:$D(e.slice(o+2,i),!1)}),o=i+2;continue}}r+=e[o],o+=1}return s(),n}function Ro(e=typeof navigator>"u"?"":navigator.userAgent){return/\bccdeck-desktop\/\d/.test(e)}function oge(e,t,n){if(e===null)return null;const r=e+t-n;return r>0?r:null}function ige(e){const t=Math.ceil(e/1e3),n=Math.floor(t/60),r=t%60;return n>0?`${n}m ${r}s`:`${r}s`}function Phe(e){return(e??[]).filter(t=>t.installed&&t.profiles>0)}function lge(e){return!Number.isFinite(e)||e<=0?"empty":Cs(e)}function cge(e,t){return e.map(n=>({key:n.key,name:n.name,running:n.running,visits:t.filter(r=>r.browser===n.key).reduce((r,s)=>r+s.programVisits,0)}))}function Dhe(e,t){if(e===null)return null;const n=Math.max(0,Math.round((t-e)/1e3));if(n<5)return"just now";if(n<60)return`${n} sec ago`;const r=Math.round(n/60);return r<60?`${r} min ago`:`${Math.round(r/60)} hr ago`}function uge(e){const t=e.profiles.filter(r=>r.degraded);if(t.length>0){const r=t[0],s=t.length-1;return{kind:"unreadable",text:`${r.name}/${r.profile} could not be read — ${r.reason??"no reason given"}`+(s>0?`, and ${s} more`:"")+". The watch continues on the profiles it can read."}}const n=Phe(e.browsers);return n.length===0?{kind:"no-profiles",text:"No browser on this machine has a profile to read. Open one of the browsers below once and it will be watched from then on."}:n.some(r=>r.running)?null:{kind:"none-running",text:"No watched browser is running, so nothing can be navigated right now. Their history is still read, and anything found while they were open is still here."}}const Fhe="Check for updates",LD="Ask npm now whether a newer ccdeck is out.",A$="Checking…",Bhe="Couldn't reach npm. Try again.",qhe="Couldn't reach the deck. Try again.",Uhe="Update checks are off on this deck (AGENTS_DECK_NO_UPDATE_CHECK or AGENTS_DECK_NO_INSTALL).",Hhe="The deck looks again in five minutes.";function Whe(e,t,n,r){const s=r?t.npx:n?qt(t,n):void 0;return s?`${e} is out, but ${s}`:`${e} is out. Run:`}const Nn=(e,t={})=>({said:e,tone:"answer",age:null,command:null,action:null,...t}),co=e=>Nn(e,{tone:"note"});function M$(e,t){return Dhe(e,t)??"just now"}function zhe(e,t){const n=e.update;return(n==null?void 0:n.status)==="ready"?co(`${n.version} is ready. Restart to update.`):(n==null?void 0:n.status)==="checking"?co("The app is checking for updates…"):(n==null?void 0:n.status)==="downloading"?co(n.version?`${n.version} is out. The app is downloading it.`:"The app is downloading an update."):(n==null?void 0:n.status)==="current"?co(`You're on the latest, ${e.version??t}. You can check again here.`):(n==null?void 0:n.status)==="error"?co("The app's last update check failed. Try Check for updates again."):co("The app keeps itself up to date. Check for updates here.")}function Vhe(e,t,n){var i;const r=e.version;if((r==null?void 0:r.upgradeMode)==="install"&&e.upgradeState!=="failed"){if(e.upgradeState==="done")return Nn(`${t} is installed.`);const c=e.upgradeState==="running",d=`Runs ${((i=r.upgrade)==null?void 0:i.command)??r.command} here, then restarts once nothing is running.`;return Nn(c?`Installing ${t}…`:`${t} is out.`,{action:{kind:"install",label:"Update now",busy:c,why:d}})}if((r==null?void 0:r.upgradeMode)==="npx"&&r.canRestart){const c=e.upgradeState==="failed";return Nn(c?`The last update to ${t} came back on ${e.running}.`:`${t} is out.`,{action:{kind:"npx",label:c?"Retry update":"Update & restart",busy:e.restarting,why:`Runs ${r.command} and hands it this port. Nothing is installed globally — npx unpacks its own copy.`}})}const s=e.upgradeState==="failed"?`Installing ${t} failed. Run it yourself:`:Whe(t,n,r==null?void 0:r.upgradeBlocked,(r==null?void 0:r.upgradeMode)==="npx"),o=(r==null?void 0:r.command)??null;return Nn(s,{command:o,action:o?{kind:"copy",label:e.copied?"Copied":"Copy",busy:!1}:null})}function Ghe(e){const t=e.version;if(e.unreachable)return Nn(qhe,{tone:"warn"});const n=t!=null&&t.checkFailedAt&&t.checkFailedAt>(t.checkedAt??0)?t.checkFailedAt:null;if(n)return Nn(Bhe,{tone:"warn",age:e.answered?null:`Last tried ${M$(n,e.now)}.`});const r=t!=null&&t.latestPending&&t.latestPending!==e.running?t.latestPending:null;if(r)return Nn(`${r} is tagged on npm but can't be installed yet. ${Hhe}`);const s=t!=null&&t.checkedAt?M$(t.checkedAt,e.now):null;if(e.answered&&(t!=null&&t.latest)){const o=t.latest===e.running?`You're on the latest, ${e.running}.`:`You're on ${e.running}, ahead of npm's ${t.latest}.`;return Nn(o,{age:s?`Checked ${s}.`:null})}return Nn("",{age:s?`Last checked ${s}.`:null})}function Khe(e,t){var s,o;const n=e.version;if((s=e.app)!=null&&s.inApp&&(n!=null&&n.checkDisabled)){const i=zhe(e.app,e.running);return i&&{canCheck:!0,checking:e.checking||((o=e.app.update)==null?void 0:o.status)==="checking",line:e.unreachable?Nn("The desktop updater did not accept the check. Try the ccdeck menu or update the desktop app.",{tone:"warn"}):e.checking?Nn(A$):i}}if(n!=null&&n.checkDisabled)return{canCheck:!1,checking:!1,line:co(Uhe)};const r=(n==null?void 0:n.notice)??null;if((r==null?void 0:r.kind)==="upgrade")return{canCheck:!0,checking:e.checking,line:Vhe(e,r.to,t)};if((r==null?void 0:r.kind)==="restart"){const i=n!=null&&n.canRestart?`${r.to} is installed. Restart the deck to start running it.`:`${r.to} is installed. Restart ccdeck to start running it.`;return{canCheck:!0,checking:e.checking,line:Nn(i)}}return e.checking?{canCheck:!0,checking:!0,line:Nn(A$)}:{canCheck:!0,checking:!1,line:Ghe(e)}}const OD=450;async function Yhe(e,t=n=>new Promise(r=>setTimeout(r,n))){const[n]=await Promise.all([e(!0),t(OD)]);return n?"answered":"unreachable"}async function Xhe(e=fetch){try{const[t]=await Promise.all([e("/api/desktop-update/check",{method:"POST",signal:AbortSignal.timeout(8e3)}),new Promise(n=>setTimeout(n,OD))]);return t.ok?"answered":"unreachable"}catch{return"unreachable"}}const $$="Eight pictures of what the deck shows.",L$="Restart the deck. Sessions, settings and pairings come back as they were.";function Zhe(e){var $;const t=(e==null?void 0:e.versionCheck.versionChecking)??!1,n=Ao(3e4),[r,s]=y.useState(!1),o=y.useRef(!1),[i,c]=y.useState(!1),[d,h]=y.useState(!1),f=y.useRef(t);if(y.useEffect(()=>{f.current&&!t&&h(!0),f.current=t},[t]),!e)return null;const{versionCheck:p,upgrade:g,restart:w,desktopUpdate:k,running:j,onHandOff:v}=e,b=Khe({version:p.version,running:j,checking:r||t,answered:d,unreachable:i,now:n,upgradeState:g.upgradeState,copied:g.cmdCopied,restarting:w.restarting,app:{inApp:Ro(),update:k.appUpdate,version:cD(),menu:dD()}},ik);if(!b)return null;const N=Ro()&&(($=p.version)==null?void 0:$.checkDisabled);return{state:b,check:async()=>{var I;if(!qn(o.current||t)||N&&((I=k.appUpdate)==null?void 0:I.status)==="checking")return;o.current=!0,s(!0);const T=N?await Xhe():await Yhe(p.loadVersion);o.current=!1,s(!1),c(T==="unreachable"),h(!0)},act:T=>{if(T.kind==="copy")return void g.copyCommand();v(),p.showNotice(),T.kind==="install"?g.startUpgrade():w.askRestart({upgrade:!0})},checkWhy:N?"Ask the desktop app whether a newer ccdeck is out.":LD}}function Jhe({onTour:e,onRestart:t,updateCheck:n}){var h,f;const r=ll("above","dialog"),s=Zhe(n),o=y.useId(),i=(s==null?void 0:s.state.canCheck)??!1,d=((h=s==null?void 0:s.state.line.action)==null?void 0:h.kind)==="install"||((f=s==null?void 0:s.state.line.action)==null?void 0:f.kind)==="npx"?void 0:t;return!e&&!i&&!d&&!s?null:a.jsxs("div",{className:"rn-actions",children:[(e||i||d)&&a.jsxs("div",{className:"rn-acts",children:[e&&a.jsxs("button",{type:"button",className:"btn rn-act",onClick:e,"aria-describedby":`${o}-tour`,...r.bind({label:$$}),children:[a.jsx(OZ,{}),"Take the tour"]}),s&&i&&a.jsxs("button",{type:"button",className:"btn rn-act",onClick:()=>void s.check(),"aria-busy":s.state.checking||void 0,"aria-describedby":`${o}-check`,...r.bind({label:s.checkWhy}),children:[a.jsx(IZ,{}),Fhe]}),d&&a.jsxs("button",{type:"button",className:"btn rn-act rn-act-restart",onClick:d,"aria-describedby":`${o}-restart`,...r.bind({label:L$}),children:[a.jsx(PZ,{}),"Restart"]})]}),s&&a.jsx(Qhe,{line:s.state.line,onAct:s.act,bindHint:r.bind,whyId:`${o}-act`}),a.jsx("span",{hidden:!0,id:`${o}-tour`,children:$$}),a.jsx("span",{hidden:!0,id:`${o}-check`,children:(s==null?void 0:s.checkWhy)??LD}),a.jsx("span",{hidden:!0,id:`${o}-restart`,children:L$}),r.node]})}function Qhe({line:e,onAct:t,bindHint:n,whyId:r}){const{action:s}=e,o=s&&a.jsx(efe,{action:s,onAct:t,bindHint:n,whyId:r});return a.jsxs("p",{className:"rn-update-line","data-tone":e.tone,children:[a.jsx("span",{className:"rn-update-what",role:"status",children:e.said}),e.age&&a.jsx("span",{className:"rn-update-age",children:e.age}),e.command?a.jsxs("span",{className:"rn-update-cmd",children:[a.jsx("code",{className:"rn-code",children:e.command}),o]}):o]})}function efe({action:e,onAct:t,bindHint:n,whyId:r}){const s=e.kind==="copy"?null:e.why;return a.jsxs(a.Fragment,{children:[a.jsx("button",{type:"button",className:s?"btn primary rn-line-act":"btn rn-line-act",onClick:()=>t(e),"aria-busy":e.busy||void 0,"aria-describedby":s&&r?r:void 0,...s&&n?n({label:s}):{},children:e.label}),s&&r&&a.jsx("span",{hidden:!0,id:r,children:s})]})}function tfe({entries:e,since:t,running:n,firstRun:r,onClose:s,onTour:o,updateVersion:i,updateBusy:c,onUpdateRestart:d,updateFailure:h,onRestart:f,updateCheck:p}){const g=ot(s),w=dt(s),k=She(e);return a.jsx("div",{className:"modal-backdrop",...w,role:"presentation",children:a.jsxs("div",{ref:g,className:"modal release-notes",onClick:j=>j.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"release-notes-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsxs("div",{className:"modal-title",children:[a.jsx("span",{id:"release-notes-title",className:"modal-tool-name",children:"What's new"}),k&&a.jsx("span",{className:"modal-tool-id",children:k})]}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:s,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),a.jsxs("section",{className:"modal-body",children:[(i||h)&&a.jsxs("div",{className:"rn-update",children:[i&&d&&a.jsxs("div",{className:"guide-door",children:[a.jsxs("span",{children:["ccdeck v",i," is downloaded and verified."]}),a.jsx("button",{type:"button",className:"btn",onClick:d,"aria-busy":c||void 0,children:c?"Restarting…":Vh})]}),a.jsx("p",{className:"rn-update-said",role:"status",children:h})]}),a.jsx("p",{className:"modal-note",children:_he({since:t,running:n,firstRun:r,entries:e})}),a.jsx(Jhe,{onTour:i?void 0:o,onRestart:f,updateCheck:p}),e.map(j=>a.jsxs("section",{className:"modal-section",children:[a.jsxs("h3",{className:"rn-version",children:["v",j.version]}),a.jsx("ul",{className:"rn-notes",children:j.notes.map((v,b)=>{const{icon:N,rest:S}=Che(v.title);return a.jsxs("li",{className:"rn-note",children:[a.jsxs("p",{className:"rn-note-title",children:[N&&a.jsx("span",{className:"rn-note-icon",children:N}),S]}),a.jsx("p",{className:"rn-note-body",children:ID($D(v.body))})]},b)})})]},j.version))]})]})})}function ID(e){return e.map((t,n)=>t.kind==="text"?t.text:t.kind==="code"?a.jsx("code",{className:"rn-code",children:t.text},n):a.jsx("strong",{className:"rn-strong",children:ID(t.kids)},n))}function nfe({state:e,sessionId:t,onClose:n}){const r=y.useMemo(()=>rfe(e,t),[e,e.revision,t]),s=y.useRef(null),o=ot(n,{focusRef:s}),i=dt(n);return r?a.jsx("div",{className:"modal-backdrop",...i,role:"presentation",children:a.jsxs("div",{ref:o,className:"modal session-summary",onClick:c=>c.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ss-title",children:[a.jsxs("div",{className:"modal-head",children:[a.jsxs("div",{className:"modal-title",children:[a.jsx("span",{className:"state-pill state-done","aria-hidden":!0,children:"done"}),a.jsx("span",{id:"ss-title",className:"modal-tool-name",title:r.cwd??r.sessionId,children:r.label}),a.jsxs("span",{className:"modal-tool-id",children:["· ",r.sessionId.slice(0,8)]})]}),a.jsxs("div",{className:"modal-actions",children:[a.jsx("span",{className:"modal-dur",title:"Total wall time",children:r.durationLabel}),a.jsx("button",{type:"button",ref:s,className:"glyph-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),a.jsxs("div",{className:"modal-body",children:[a.jsxs("section",{className:"ss-hero",children:[a.jsxs("div",{className:"ss-hero-left",children:[a.jsx("div",{className:"ss-cost-label",children:JI}),a.jsx("div",{className:"ss-cost",children:Ye(r.cost.total)}),r.modelChips.length>0&&a.jsx("div",{className:"ss-models",children:r.modelChips.map(c=>a.jsx("span",{className:"model-chip","data-family":lf(c),title:c,children:rs(c)},c))})]}),a.jsx("div",{className:"ss-hero-right",children:r.cost.total>0&&a.jsxs(a.Fragment,{children:[a.jsx(t1,{cost:r.cost,size:"lg"}),a.jsxs("div",{className:"ss-cost-legend",children:[a.jsxs("span",{className:"ssl ssl-in",children:["input ",a.jsx("b",{children:Ye(r.cost.input)})]}),a.jsxs("span",{className:"ssl ssl-out",children:["output ",a.jsx("b",{children:Ye(r.cost.output)})]}),a.jsxs("span",{className:"ssl ssl-cr",children:["cache r ",a.jsx("b",{children:Ye(r.cost.cacheRead)})]}),a.jsxs("span",{className:"ssl ssl-cw",children:["cache w ",a.jsx("b",{children:Ye(r.cost.cacheWrite)})]})]})]})})]}),a.jsxs("section",{className:"ss-stats",children:[a.jsx(bi,{label:"agents",value:r.agentCount}),a.jsx(bi,{label:"subagents",value:r.subagentCount}),a.jsx(bi,{label:"tool calls",value:r.toolCount}),a.jsx(bi,{label:"prompts",value:r.promptCount}),a.jsx(bi,{label:"tokens",value:r.tokensSum.toLocaleString()}),r.errCount>0&&a.jsx(bi,{label:"errors",value:r.errCount,tone:"err"})]}),r.topTools.length>0&&a.jsxs("section",{className:"modal-section",children:[a.jsx("h4",{children:"Most-used tools"}),a.jsx("div",{className:"ss-top-tools",children:r.topTools.map(([c,d])=>a.jsxs("div",{className:"ss-tt",children:[a.jsx("span",{className:"ss-tt-name",children:c}),a.jsx("span",{className:"ss-tt-bar",children:a.jsx("span",{className:"ss-tt-bar-fill",style:{width:`${d/r.topTools[0][1]*100}%`}})}),a.jsx("span",{className:"ss-tt-count",children:d})]},c))})]}),r.firstPrompt&&a.jsxs("section",{className:"modal-section",children:[a.jsx("h4",{children:"Opening prompt"}),a.jsx("div",{className:"ss-prompt",children:r.firstPrompt})]})]})]})}):null}function bi({label:e,value:t,tone:n}){return a.jsxs("div",{className:`ss-stat${n?` tone-${n}`:""}`,children:[a.jsx("div",{className:"ss-stat-value",children:t}),a.jsx("div",{className:"ss-stat-label",children:e})]})}function rfe(e,t){const n=e.agents.get(t);if(!n)return null;const r=[];for(const S of e.agents.values())S.sessionId===t&&r.push(S);if(r.length===0)return null;const s={input:0,output:0,cacheRead:0,cacheWrite:0,total:0},o=new Set,i=new Map;let c=0,d=0,h=0,f=0,p=0,g,w=1/0,k=0;for(const S of r){const E=En(S);s.input+=E.input,s.output+=E.output,s.cacheRead+=E.cacheRead,s.cacheWrite+=E.cacheWrite,s.total+=E.total;for(const $ of aI(S))o.add($);S.model&&o.add(S.model),S.kind==="subagent"&&p++;const C=WO(S.prompts);d+=C.length,!g&&C.length>0&&(g=C[0].text),h+=S.usage.inputTokens+S.usage.outputTokens,c+=S.toolCount,f+=S.toolErrorCount??0;for(const[$,T]of S.toolCountByName??[])i.set($,(i.get($)??0)+T);w=Math.min(w,S.startedAt),k=Math.max(k,S.endedAt??Date.now())}const j=Math.max(0,k-w),v=Math.floor(j/1e3),b=v<60?`${v}s`:v<3600?`${Math.floor(v/60)}m ${String(v%60).padStart(2,"0")}s`:`${Math.floor(v/3600)}h ${Math.floor(v%3600/60)}m`,N=Array.from(i.entries()).sort((S,E)=>E[1]-S[1]).slice(0,5);return{sessionId:t,label:n.label||n.cwdBasename||"session",cwd:n.cwd,durationLabel:b,cost:s,modelChips:Array.from(o),agentCount:r.length,subagentCount:p,toolCount:c,promptCount:d,tokensSum:h,errCount:f,topTools:N,firstPrompt:g}}const sfe="Single-key shortcuts",afe="Keys like L, U, M, ? and Space open panels and toggle things. Turn this off if you use voice control or press them by accident.";function ofe({singleKeys:e,onToggleSingleKeys:t}){return a.jsxs("section",{className:"settings-group","aria-labelledby":"settings-keyboard-caption",children:[a.jsx("div",{className:"settings-caption",children:a.jsx("h3",{id:"settings-keyboard-caption",children:"Keyboard"})}),a.jsx("div",{className:"appearance-controls",children:a.jsxs("label",{className:"appearance-row",children:[a.jsx("span",{className:"appearance-row-label",id:"settings-single-keys-label",children:sfe}),a.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":e,"aria-labelledby":"settings-single-keys-label","aria-describedby":"settings-single-keys-note",onClick:t,children:a.jsx("span",{className:"switch-knob"})}),a.jsx("span",{id:"settings-single-keys-note",className:"appearance-row-note",children:afe})]})})]})}const ife="With no deck tab open, get a notification wherever a sound would have played.",lfe="With the ccdeck window closed, get a notification wherever a sound would have played.";function cfe(e){return e?lfe:ife}const ufe="Held off for this run — the deck was started with alerts disabled. Your choice is saved for the next start.",dfe=[{kind:"notifySwap",label:"Account auto-switched",title:"When auto-switch moves Claude Code to another account"},{kind:"notifyQuota",label:"Quota at 90% and 100%",title:"When a quota window of the account you're on reaches 90%, and again at 100%"},{kind:"notifyReset",label:"Quota reset",title:"When a quota window that reached 90% is available again"}],hfe="For the Claude and Codex accounts you're on, whether or not the deck is open.",ffe="Held off for this run too.",O$="Get notified when you're away from this tab.";function pfe(e){switch(e){case"granted":return{status:"Enabled",ask:!1,ok:!0,note:O$};case"default":return{status:null,ask:!0,ok:!1,note:O$};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 mfe({notifyOn:e,onToggleNotify:t,notifyVetoed:n,notifyPermission:r,onAskNotify:s,accountNotify:o,onToggleAccountNotify:i}){const c=pfe(r),d=Ro(),h=e&&!n&&!d,f=y.useRef(null),p=Ts(!c.ask,f);return a.jsxs("div",{className:"sm-switches",children:[a.jsxs("div",{className:"sm-setting",children:[a.jsxs("label",{className:"sm-switch",children:[a.jsx("span",{className:"sm-switch-label",id:"sm-notify-label",children:"Notifications while closed"}),a.jsx("button",{ref:f,type:"button",role:"switch","aria-checked":e,"aria-labelledby":"sm-notify-label",className:"switch",onClick:t,title:"With no deck tab open, a notification wherever a sound would play",children:a.jsx("span",{className:"switch-knob"})})]}),a.jsx("p",{className:"sm-note",children:n?ufe:cfe(d)})]}),h&&a.jsxs("section",{className:"sm-channel","aria-labelledby":"sm-channel-name",children:[a.jsxs("div",{className:"sm-channel-head",children:[a.jsx("h3",{className:"sm-channel-name",id:"sm-channel-name",children:"Browser notifications"}),c.ask?a.jsx("button",{type:"button",className:"btn sm-channel-action",onClick:()=>{p(),s()},children:"Enable"}):a.jsxs("span",{className:"sm-channel-state","data-ok":c.ok||void 0,children:[c.ok&&a.jsx("svg",{width:"9",height:"9",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:a.jsx("path",{d:"M1.5 5.2 3.9 7.6 8.5 2.4"})}),c.status]})]}),a.jsx("p",{className:"sm-note",children:c.note})]}),a.jsxs("div",{className:"sm-account-switches",children:[a.jsx("p",{className:"sm-note",children:n?ffe:hfe}),dfe.map(({kind:g,label:w,title:k})=>a.jsxs("label",{className:"sm-switch",children:[a.jsx("span",{className:"sm-switch-label",id:`sm-${g}-label`,children:w}),a.jsx("button",{type:"button",role:"switch","aria-checked":o[g],"aria-labelledby":`sm-${g}-label`,className:"switch",onClick:()=>i(g),title:k,children:a.jsx("span",{className:"switch-knob"})})]},g))]})]})}function gfe({section:e}){return a.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[e==="reading"&&a.jsx(a.Fragment,{children:a.jsx("path",{d:"M2 11 5.5 3 9 11M3.3 8h4.4M10.5 4h2M10.5 7h2M10.5 10h2"})}),e==="sounds"&&a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M3.2 5.2h2L7.8 3v8L5.2 8.8h-2z"}),a.jsx("path",{d:"M9.8 5.4a2.4 2.4 0 0 1 0 3.2"}),a.jsx("path",{d:"M11.3 3.9a4.6 4.6 0 0 1 0 6.2"})]}),e==="general"&&a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M1.5 3h4.3M9.2 3h3.3M1.5 7h1.3M6.2 7h6.3M1.5 11h6.3M11.2 11h1.3"}),a.jsx("circle",{cx:"7.5",cy:"3",r:"1.7"}),a.jsx("circle",{cx:"4.5",cy:"7",r:"1.7"}),a.jsx("circle",{cx:"9.5",cy:"11",r:"1.7"})]}),e==="notifications"&&a.jsxs(a.Fragment,{children:[a.jsx("path",{d:"M3.4 9.1c.6-.8.6-1.8.6-3V4.7a3 3 0 0 1 6 0v1.4c0 1.2 0 2.2.6 3"}),a.jsx("path",{d:"M2.2 9.1h9.6"}),a.jsx("path",{d:"M5.7 11.2a1.3 1.3 0 0 0 2.6 0"})]})]})}const yfe=["audio/webm;codecs=opus","audio/ogg;codecs=opus","audio/mp4"];function wfe(e){return yfe.find(t=>e(t))}const xfe=4400;function vfe(e){const t=e.split(";")[0];return{name:`Recorded voice.${t==="audio/mp4"?"m4a":t==="audio/ogg"?"ogg":"webm"}`,type:t}}function bfe({full:e,setCustomError:t,runCustom:n,onImportCustom:r}){const[s,o]=y.useState(!1),i=y.useRef(null),c=y.useRef(null),d=y.useRef(!1),h=()=>{var p;c.current!==null&&clearTimeout(c.current),c.current=null,((p=i.current)==null?void 0:p.state)==="recording"&&i.current.stop()},f=async()=>{var g;if(e)return;if(t(""),!((g=navigator.mediaDevices)!=null&&g.getUserMedia)||typeof MediaRecorder>"u"){t("Microphone recording is unavailable in this browser.");return}let p;try{p=await navigator.mediaDevices.getUserMedia({audio:!0})}catch{d.current||t("Microphone access was denied or unavailable.");return}if(d.current||i.current){p.getTracks().forEach(w=>w.stop());return}try{const w=wfe(v=>MediaRecorder.isTypeSupported(v)),k=new MediaRecorder(p,w?{mimeType:w}:void 0),j=[];i.current=k,k.ondataavailable=v=>{v.data.size&&j.push(v.data)},k.onerror=()=>t("Recording failed. Please try again."),k.onstop=()=>{p.getTracks().forEach(S=>S.stop()),c.current!==null&&clearTimeout(c.current),c.current=null;const v=i.current===k;if(v&&(i.current=null),o(!1),!v||!j.length)return;const b=vfe(k.mimeType),N=new File(j,b.name,{type:b.type});n(()=>r(N))},k.start(200),o(!0),c.current=setTimeout(h,xfe)}catch{i.current=null,p.getTracks().forEach(w=>w.stop()),t("This browser cannot record a supported audio format.")}};return y.useEffect(()=>(d.current=!1,()=>{d.current=!0,c.current!==null&&clearTimeout(c.current);const p=i.current;i.current=null,(p==null?void 0:p.state)==="recording"&&p.stop()}),[]),{recording:s,startRecording:f,stopRecording:h}}function kfe({full:e,fullProps:t,runCustom:n,onCreateVoice:r}){const[s,o]=y.useState("Custom voice"),[i,c]=y.useState("Your turn"),[d,h]=y.useState(""),[f,p]=y.useState("1"),[g,w]=y.useState("1"),[k,j]=y.useState([]);return y.useEffect(()=>{if(typeof window>"u"||!("speechSynthesis"in window))return;const v=()=>{j(window.speechSynthesis.getVoices())};return v(),window.speechSynthesis.addEventListener("voiceschanged",v),()=>window.speechSynthesis.removeEventListener("voiceschanged",v)},[]),a.jsxs("details",{className:"sm-voice",children:[a.jsxs("summary",{...t,onClick:v=>{const b=v.currentTarget.parentElement;e&&b&&!b.open&&v.preventDefault()},children:[a.jsx("span",{children:"Spoken voice"}),a.jsx("span",{children:"Create from text"})]}),a.jsxs("div",{className:"sm-voice-fields",children:[a.jsxs("label",{children:[a.jsx("span",{children:"Name"}),a.jsx("input",{className:"ap-manage-input",value:s,maxLength:80,onChange:v=>o(v.target.value)})]}),a.jsxs("label",{children:[a.jsx("span",{children:"Text"}),a.jsx("input",{className:"ap-manage-input",value:i,maxLength:180,onChange:v=>c(v.target.value)})]}),a.jsxs("label",{children:[a.jsx("span",{children:"Voice"}),a.jsxs("select",{className:"sm-select",value:d,onChange:v=>h(v.target.value),children:[a.jsx("option",{value:"",children:"System default"}),k.map(v=>a.jsx("option",{value:v.voiceURI,children:v.name},v.voiceURI))]})]}),a.jsxs("div",{className:"sm-voice-pair",children:[a.jsxs("label",{children:[a.jsx("span",{children:"Rate"}),a.jsx("input",{className:"ap-manage-input",type:"number",min:"0.5",max:"2",step:"0.1",value:f,onChange:v=>p(v.target.value)})]}),a.jsxs("label",{children:[a.jsx("span",{children:"Pitch"}),a.jsx("input",{className:"ap-manage-input",type:"number",min:"0.5",max:"2",step:"0.1",value:g,onChange:v=>w(v.target.value)})]})]}),a.jsx("button",{type:"button",className:"btn sm-custom-action",...t,onClick:()=>{e||n(async()=>{await r({name:s,text:i,voiceURI:d,rate:parseFloat(f),pitch:parseFloat(g)}),c("Your turn")})},children:"Add spoken voice"})]})]})}function jfe({customAssets:e,onImportCustom:t,onCreateVoice:n,onRenameCustom:r,onPreviewCustom:s,onDeleteCustom:o}){const[i,c]=y.useState(""),d=e.length,h=X0(d),f=h!==null,p=f?{"aria-disabled":!0,"aria-describedby":"sm-custom-full"}:{},[g,w]=y.useState(null),k=y.useRef(0),j=y.useRef(new Map),v=y.useRef(null),b=y.useRef(null);y.useEffect(()=>{if(!g)return;const T=window.setTimeout(()=>w(null),4e3);return()=>window.clearTimeout(T)},[g]);const N=async T=>{c("");try{await T()}catch(I){c(I instanceof Error?I.message:"Custom audio could not be saved.")}},S=(T,I)=>{const O=Date.now(),U=Xi({armedFor:g,target:T,armedAt:k.current,now:O,gapMs:Yi});if(U==="arm"){w(T),k.current=O;return}if(U==="ignore")return;w(null);const P=zne(e.map(L=>L.id),T);N(async()=>{var F;await o(T);const L=document.activeElement;L!==I&&!Vn((L==null?void 0:L.tagName)??null)||(F=P?j.current.get(P):v.current)==null||F.focus()})},{recording:E,startRecording:C,stopRecording:$}=bfe({full:f,setCustomError:c,runCustom:N,onImportCustom:t});return a.jsxs("section",{className:"sm-custom","aria-labelledby":"sm-custom-title",children:[a.jsxs("div",{className:"sm-custom-head",children:[a.jsx("h3",{className:"sm-tone-name",id:"sm-custom-title",children:"Custom sounds"}),a.jsxs("span",{children:[d," of ",Y0,", kept on this machine"]})]}),f&&a.jsx("p",{className:"sm-note",id:"sm-custom-full",children:h}),a.jsxs("div",{className:"sm-custom-actions",children:[a.jsxs("div",{className:"sm-custom-card",children:[a.jsxs("span",{className:"sm-custom-card-copy",children:[a.jsx("strong",{children:"Import audio"}),a.jsx("span",{children:"WAV, MP3 or OGG"})]}),a.jsx("button",{ref:v,type:"button",className:"btn sm-custom-action",...p,onClick:()=>{var T;f||(T=b.current)==null||T.click()},children:"Choose file"}),a.jsx("input",{ref:b,type:"file",hidden:!0,accept:"audio/wav,audio/x-wav,audio/mpeg,audio/mp3,audio/ogg,.wav,.mp3,.ogg",onChange:T=>{var O;const I=(O=T.target.files)==null?void 0:O[0];T.currentTarget.value="",I&&!f&&N(()=>t(I))}})]}),a.jsxs("div",{className:"sm-custom-card",children:[a.jsxs("span",{className:"sm-custom-card-copy",children:[a.jsx("strong",{children:"Record a clip"}),a.jsx("span",{children:E?"Recording…":"Up to 5 seconds"})]}),E?a.jsx("button",{type:"button",className:"btn sm-custom-action",onClick:$,children:"Stop & save"}):a.jsx("button",{type:"button",className:"btn sm-custom-action",...p,onClick:()=>void C(),children:"Record"})]})]}),a.jsx(kfe,{full:f,fullProps:p,runCustom:N,onCreateVoice:n}),e.length>0&&a.jsx("div",{className:"sm-custom-list",children:e.map(T=>a.jsxs("div",{className:"sm-custom-item",children:[a.jsx("input",{className:"ap-manage-input","aria-label":`Rename ${T.name}`,defaultValue:T.name,maxLength:80,onBlur:I=>{if(!I.target.value.trim()){I.target.value=T.name;return}N(()=>r(T.id,I.target.value))},onKeyDown:I=>{I.key==="Enter"&&I.currentTarget.blur()}}),a.jsx("span",{children:T.kind==="audio"?`${T.duration.toFixed(1)}s`:"Voice"}),a.jsx("button",{type:"button",className:"btn sm-custom-icon","aria-label":`Play ${T.name}`,onClick:()=>s(T.id),children:"Play"}),a.jsx("button",{type:"button",ref:I=>{I?j.current.set(T.id,I):j.current.delete(T.id)},className:`btn sm-custom-icon${g===T.id?" armed":""}`,onKeyDown:I=>{I.repeat&&I.preventDefault()},onClick:I=>S(T.id,I.currentTarget),"aria-label":g===T.id?`Confirm deleting ${T.name}`:`Delete ${T.name}`,title:g===T.id?"Press again to delete this sound. It cannot be brought back.":"Delete this sound",children:g===T.id?"Confirm":"Delete"})]},T.id))}),i&&a.jsx("p",{className:"sm-custom-error",role:"alert",children:i})]})}function Nfe({soundOn:e,onToggleSound:t}){const n=y.useId(),r=Cn();return a.jsxs("div",{className:"sm-setting",children:[a.jsxs("label",{className:"sm-switch",children:[a.jsx("span",{className:"sm-switch-label",id:n,children:"Play sounds"}),a.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-labelledby":n,className:"switch",onClick:t,title:"A tone when a turn finishes, and when Claude asks for something",children:a.jsx("span",{className:"switch-knob"})})]}),r&&a.jsxs("p",{className:"sm-note sm-key-note",children:[a.jsx("kbd",{children:"M"}),"Mute or unmute sounds anywhere."]})]})}const dk="custom:";function I$(e){return`${dk}${e}`}function Sfe(e){return e.startsWith(dk)?e.slice(dk.length):null}function _fe({id:e,label:t="Volume",value:n,step:r=j1,onLevel:s,"aria-describedby":o}){return a.jsxs("div",{className:"sm-row",children:[a.jsx("label",{htmlFor:e,children:t}),a.jsx("input",{id:e,type:"range",min:sh,max:Dh,step:r,value:n,"aria-describedby":o,onChange:i=>s(Number(i.target.value)),style:{"--sm-level":`${(n-sh)/(Dh-sh)*100}%`}}),a.jsxs("span",{className:"sm-read",children:[n,"%"]})]})}const P$={done:"Turn finished","needs-input":"Claude is asking"},Efe={done:"Plays when Claude or Codex finishes a turn.","needs-input":"Available in Claude Code only."};function Cfe({chime:e,tone:t,soundOn:n,customAssets:r,customSelections:s,onLevel:o,onFigure:i,onPreview:c,onBuiltInSelected:d,onCustomSelected:h}){const f=`sm-level-${e}`,p=`sm-figure-${e}`,g=s[e];return a.jsxs("section",{className:"sm-tone","aria-labelledby":`sm-name-${e}`,children:[a.jsxs("div",{className:"sm-tone-head",children:[a.jsx("h3",{className:"sm-tone-name",id:`sm-name-${e}`,children:P$[e]}),a.jsxs("button",{type:"button",className:"btn sm-hear",onClick:()=>c(e),"aria-label":`Hear the ${P$[e].toLowerCase()} tone`,title:n?"Play this tone now, at what it is set to":"Plays even when sounds are off","aria-describedby":n?void 0:"sm-preview-note",children:[a.jsx("svg",{width:"11",height:"11",viewBox:"0 0 12 12",fill:"currentColor","aria-hidden":!0,children:a.jsx("path",{d:"M3 1.6v8.8l7-4.4z"})}),"Hear it"]})]}),a.jsx(_fe,{id:f,value:t.level,onLevel:w=>o(e,w)}),a.jsxs("div",{className:"sm-row",children:[a.jsx("label",{htmlFor:p,children:"Tone"}),a.jsxs("select",{id:p,className:"sm-select",value:g?I$(g):t.figure,onChange:w=>{const k=w.target.value,j=Sfe(k);j!==null?h(e,j):(d(e),i(e,k))},children:[k1[e].map(w=>a.jsx("option",{value:w.id,children:w.label},w.id)),r.length>0&&a.jsx("optgroup",{label:"Custom",children:r.map(w=>a.jsx("option",{value:I$(w.id),children:w.name},w.id))})]})]}),a.jsx("p",{className:"sm-note",children:Efe[e]})]})}const Tfe="Claude Code isn't on this machine, so only Turn finished plays here — for Codex turns.";function Rfe({soundOn:e,onToggleSound:t,prefs:n,claudeHere:r,onLevel:s,onFigure:o,onPreview:i,customAssets:c,customSelections:d,onBuiltInSelected:h,onCustomSelected:f,onImportCustom:p,onCreateVoice:g,onRenameCustom:w,onPreviewCustom:k,onDeleteCustom:j}){var S;const v=Hne(d),b=((S=c.find(E=>E.id===v))==null?void 0:S.name)??"the same custom sound",N=v?`Both tones use “${b}”. They may be harder to tell apart.`:"";return a.jsxs("div",{className:"sm-sounds",children:[a.jsx(Nfe,{soundOn:e,onToggleSound:t}),!r&&a.jsx("p",{className:"sm-note",children:Tfe}),!e&&a.jsx("span",{id:"sm-preview-note",className:"vis-hidden",children:"Plays even when sounds are off, so you can set a tone before turning sounds back on."}),a.jsx("div",{className:"sm-tones",children:rh.map(E=>a.jsx(Cfe,{chime:E,tone:n[E],soundOn:e,customAssets:c,customSelections:d,onLevel:s,onFigure:o,onPreview:i,onBuiltInSelected:h,onCustomSelected:f},E))}),N&&a.jsx("p",{className:"sm-note","aria-hidden":!0,children:N}),a.jsx("p",{className:"vis-hidden",role:"status",children:N}),a.jsx(jfe,{customAssets:c,onImportCustom:p,onCreateVoice:g,onRenameCustom:w,onPreviewCustom:k,onDeleteCustom:j})]})}function Afe(){const[e,t]=y.useState(null),[n,r]=y.useState(""),[s,o]=y.useState(!1),[i,c]=y.useState(null),[d,h]=y.useState(""),f=y.useRef(!1),p=y.useRef(!0),g=async()=>{if(f.current)return;f.current=!0,o(!0),r("");const k=new AbortController,j=window.setTimeout(()=>k.abort(),12e3);try{const v=await fetch("/api/tool-audit/storage",{signal:k.signal}),b=await v.json();if(!v.ok||!b.ok)throw new Error;p.current&&t(b)}catch{p.current&&r("Could not read tool history storage. Try again.")}finally{window.clearTimeout(j),f.current=!1,p.current&&o(!1)}};y.useEffect(()=>(p.current=!0,g(),()=>{p.current=!1}),[]);const w=async(k,j)=>{if(f.current)return;f.current=!0,o(!0),r(""),h("");let v=!1;const b=new AbortController,N=window.setTimeout(()=>b.abort(),15e3);try{const S=await fetch("/api/tool-audit/storage",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(k==="clear"?{action:k,confirm:!0}:{action:k,days:j}),signal:b.signal}),E=await S.json();if(!S.ok||!E.ok)throw new Error;v=!0,p.current&&(c(null),h(k==="clear"?"Tool history cleared. New calls will continue to be recorded.":`Retention changed to ${j} days.`))}catch{p.current&&r("Could not update tool history. Check storage permissions and try again.")}finally{window.clearTimeout(N),f.current=!1,p.current&&(o(!1),v&&g())}};return a.jsxs("section",{className:"settings-group ta-settings","aria-labelledby":"tool-history-settings-title",children:[a.jsx("div",{className:"settings-caption",children:a.jsx("h3",{id:"tool-history-settings-title",children:"Tool history"})}),a.jsx("p",{className:"ta-note",children:"Local statistics for Claude and Codex on this device. Commands are grouped by operation; raw arguments and outputs are not saved."}),e?a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"ta-storage-row",children:[a.jsxs("label",{children:["Keep history",a.jsx("select",{className:"sm-select","aria-label":"Tool history retention",value:e.retentionDays,"aria-busy":s,onChange:k=>{if(f.current)return;const j=Number(k.target.value);j<e.retentionDays?c(j):w("retention",j)},children:[30,60,90].map(k=>a.jsxs("option",{value:k,children:[k," days"]},k))})]}),a.jsxs("span",{className:"ta-storage-size",children:[QG(e.bytes)," used",a.jsxs("small",{children:["Collection since ",eK(e.startedAt)]})]})]}),!e.storageOk&&a.jsx("p",{className:"ta-note",role:"status",children:"Some calls could not be saved. Check free space and storage permissions."}),a.jsxs("div",{className:"ta-storage-actions",children:[a.jsx("button",{type:"button",className:"btn","aria-busy":s,onClick:()=>{f.current||c("clear")},children:"Clear history…"}),a.jsx("button",{type:"button",className:"btn","aria-busy":s,onClick:()=>{g()},children:"Refresh size"})]}),i!==null&&a.jsxs("div",{className:"ta-confirm",children:[a.jsx("p",{children:i==="clear"?"Delete all recorded tool statistics on this device? This cannot be undone.":`Keep ${i} days? Older calls will be permanently deleted.`}),a.jsxs("div",{children:[a.jsx("button",{type:"button",className:"btn","aria-busy":s,onClick:()=>{w(i==="clear"?"clear":"retention",typeof i=="number"?i:void 0)},children:i==="clear"?"Delete tool history":"Apply retention"}),a.jsx("button",{type:"button",className:"btn","aria-busy":s,onClick:()=>{f.current||c(null)},children:"Cancel"})]})]})]}):a.jsx("p",{className:"ta-note",role:"status",children:s?"Reading storage…":"Storage size unavailable."}),n&&a.jsxs("p",{className:"ta-note",role:"alert",children:[n," ",a.jsx("button",{type:"button",className:"btn","aria-busy":s,onClick:()=>{g()},children:"Retry"})]}),d&&a.jsx("p",{className:"ta-note",role:"status",children:d})]})}function Mfe({theme:e}){return a.jsx("span",{className:"appearance-preview","data-swatch":e,children:a.jsxs("svg",{viewBox:"0 0 112 56","aria-hidden":!0,focusable:"false",children:[a.jsx("rect",{className:"tp-canvas",width:"112",height:"56"}),a.jsx("rect",{className:"tp-surface",width:"112",height:"7"}),a.jsx("rect",{className:"tp-rule",y:"7",width:"112",height:"1"}),a.jsx("rect",{className:"tp-surface",y:"8",width:"25",height:"48"}),a.jsx("rect",{className:"tp-rule",x:"25",y:"8",width:"1",height:"48"}),a.jsx("rect",{className:"tp-card",x:"36.5",y:"27.5",width:"28",height:"14",rx:"2.5"}),a.jsx("rect",{className:"tp-tag",x:"39.5",y:"25.5",width:"13",height:"4",rx:"2"}),a.jsx("rect",{className:"tp-card",x:"76.5",y:"14.5",width:"29",height:"20",rx:"2.5"}),a.jsx("rect",{className:"tp-rule",x:"81",y:"23",width:"20",height:"2",rx:"1"}),a.jsx("rect",{className:"tp-accent",x:"81",y:"23",width:"12",height:"2",rx:"1"})]})})}function $fe({theme:e,onTheme:t,singleKeys:n}){const r=s=>{var d,h;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(s.key))return;s.preventDefault();const o=(d=s.target.closest("[data-theme-choice]"))==null?void 0:d.dataset.themeChoice,c=(wa.indexOf(o??e)+(s.key==="ArrowLeft"||s.key==="ArrowUp"?-1:1)+wa.length)%wa.length;t(wa[c]),(h=s.currentTarget.querySelectorAll('[role="radio"]')[c])==null||h.focus()};return a.jsxs("section",{className:"settings-group","aria-labelledby":"appearance-theme-caption",children:[a.jsxs("div",{className:"settings-caption",children:[a.jsxs("div",{children:[a.jsx("h3",{id:"appearance-theme-caption",children:"Color theme"}),a.jsx("p",{className:"settings-caption-note",children:"Choose how the dashboard looks."})]}),n&&a.jsx("kbd",{className:"settings-key","aria-hidden":!0,title:"Press T anywhere to switch themes",children:"T"})]}),a.jsx("div",{className:"appearance-themes",role:"radiogroup","aria-labelledby":"appearance-theme-caption","aria-keyshortcuts":n?"T":void 0,onKeyDown:r,children:wa.map(s=>a.jsxs("button",{type:"button",className:"appearance-theme",role:"radio","data-theme-choice":s,"aria-checked":e===s,tabIndex:e===s?0:-1,onClick:()=>t(s),children:[a.jsx(Mfe,{theme:s}),a.jsxs("span",{className:"appearance-theme-name",children:[Jf[s].name,a.jsx("svg",{className:"appearance-check",viewBox:"0 0 12 12","aria-hidden":!0,focusable:"false",children:a.jsx("path",{d:"M2.5 6.4 4.9 8.7 9.5 3.6"})})]})]},s))})]})}const Lfe=[["smallest","Smallest","11 px"],["smaller","Smaller","12 px"],["default","Default","13 px"],["larger","Larger","15 px"],["largest","Largest","17 px"]],Ofe=[["tightest","Tightest","30%"],["tighter","Tighter","50%"],["compact","Compact","70%"],["default","Default","100%"],["comfortable","Comfortable","140%"]];function D$(){return a.jsx("svg",{className:"reading-selected-mark",viewBox:"0 0 12 12",width:"12",height:"12","aria-hidden":"true",children:a.jsx("path",{d:"m2.5 6 2.2 2.2 4.8-4.4",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}function Ife({textSize:e,density:t,onTextSize:n,onDensity:r}){const s=e!=="default"||t!=="default";return a.jsxs(a.Fragment,{children:[a.jsxs("div",{className:"reading-head",children:[a.jsx("p",{className:"reading-intro",children:"Make the deck comfortable to read. Changes apply immediately and stay separate from canvas zoom."}),a.jsx("button",{type:"button",className:"btn",disabled:!s,onClick:()=>{n("default"),r("default")},children:"Reset to defaults"})]}),a.jsxs("fieldset",{className:"reading-group",children:[a.jsx("legend",{children:"Text size"}),a.jsx("p",{id:"reading-size-help",children:"Adjust interface text without changing your browser zoom."}),a.jsx("div",{className:"reading-options reading-segmented","aria-describedby":"reading-size-help",style:{"--reading-count":wE.length,"--reading-selected":wE.indexOf(e)},children:Lfe.map(([o,i,c])=>a.jsxs("label",{className:"reading-choice","data-size":o,children:[a.jsx("input",{type:"radio",name:"text-size","aria-label":`${i} ${c}`,value:o,checked:e===o,onChange:()=>n(o)}),a.jsx("span",{className:"reading-type-sample","aria-hidden":"true",children:"Aa"}),a.jsxs("span",{className:"reading-label",children:[a.jsx("strong",{children:i}),a.jsx("small",{children:c})]}),a.jsx(D$,{})]},o))})]}),a.jsxs("fieldset",{className:"reading-group",children:[a.jsx("legend",{children:"Density"}),a.jsx("p",{id:"reading-density-help",children:"Choose the spacing in lists, panels and controls. Text size stays the same."}),a.jsx("div",{className:"reading-options reading-segmented","aria-describedby":"reading-density-help",style:{"--reading-count":xE.length,"--reading-selected":xE.indexOf(t)},children:Ofe.map(([o,i,c])=>a.jsxs("label",{className:"reading-choice",children:[a.jsx("input",{type:"radio",name:"density","aria-label":`${i} ${c} spacing`,value:o,checked:t===o,onChange:()=>r(o)}),a.jsxs("span",{className:"reading-density-sample","data-density":o,"aria-hidden":"true",children:[a.jsx("i",{}),a.jsx("i",{}),a.jsx("i",{})]}),a.jsxs("span",{className:"reading-label",children:[a.jsx("strong",{children:i}),a.jsx("small",{children:c})]}),a.jsx(D$,{})]},o))})]}),a.jsxs("section",{className:"reading-preview","aria-labelledby":"reading-preview-title",children:[a.jsx("h3",{id:"reading-preview-title",children:"Preview"}),a.jsxs("div",{className:"reading-preview-row",children:[a.jsxs("div",{children:[a.jsx("strong",{children:"Frontend session"}),a.jsx("span",{children:"Waiting for your review"})]}),a.jsx("span",{className:"reading-preview-time",children:"4m"})]}),a.jsxs("div",{className:"reading-preview-row",children:[a.jsxs("div",{children:[a.jsx("strong",{children:"API integration"}),a.jsx("span",{children:"Working · 3 tool calls"})]}),a.jsx("span",{className:"reading-preview-time",children:"12m"})]})]}),a.jsx("p",{className:"reading-footer",children:"Preferences stay in this browser when storage is available. Default restores the existing ccdeck appearance."})]})}const PD="agent-dag.character",Ub=[{id:"deck",name:"Deck companion"},{id:"fox",name:"Fox"},{id:"penguin",name:"Penguin"}];function Pfe(e){return e==="fox"||e==="penguin"?e:"deck"}function Dfe(){return Pfe(Ge(PD))}function Ffe({character:e,onCharacter:t}){const n=y.useRef([]);function r(s,o){var c;const i=m1(s,o,Ub.length,"vertical");i.kind==="select"&&(s.preventDefault(),t(Ub[i.index].id),(c=n.current[i.index])==null||c.focus())}return a.jsx("div",{className:"character-picker",role:"radiogroup","aria-label":"Choose character",children:Ub.map((s,o)=>a.jsxs("button",{type:"button",className:"character-choice",role:"radio","aria-checked":e===s.id,tabIndex:e===s.id?0:-1,ref:i=>{n.current[o]=i},onClick:()=>t(s.id),onKeyDown:i=>r(i,o),children:[a.jsx("span",{className:"character-preview",children:a.jsx(HI,{character:s.id,act:null,facing:"right"})}),a.jsx("span",{children:s.name}),a.jsx("svg",{className:"character-check",viewBox:"0 0 16 16","aria-hidden":!0,focusable:"false",children:a.jsx("path",{d:"m3 8 3 3 7-7",fill:"none",stroke:"currentColor",strokeWidth:"1.5"})})]},s.id))})}function Bfe({characterEnabled:e,onToggleCharacter:t,character:n="deck",onCharacter:r}){return a.jsxs("section",{className:"settings-group","aria-labelledby":"appearance-character-caption",children:[a.jsxs("div",{className:"settings-caption",children:[a.jsx("h3",{id:"appearance-character-caption",children:"Character"}),a.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":e,"aria-labelledby":"appearance-character-caption",onClick:t,children:a.jsx("span",{className:"switch-knob"})})]}),a.jsx(Ffe,{character:n,onCharacter:r})]})}function qfe({section:e,onSection:t,onClose:n,providers:r,sound:s,tones:o,customTones:i,notify:c,appearance:d}){const h=y.useRef(null),f=ot(n,{focusRef:h}),p=dt(n),g=y.useRef([]),w=Ale(e);y.useEffect(()=>{var se,ce;Mle((se=document.activeElement)==null?void 0:se.id,e)&&((ce=h.current)==null||ce.focus())},[e]);const{theme:k,setTheme:j,characterEnabled:v,setCharacterEnabled:b,character:N,setCharacter:S}=d,E=Cn(),C=se=>{var de;const ce=m1(se,w,dc.length,"vertical");ce.kind!=="pass"&&(se.preventDefault(),t(dc[ce.index].id),(de=g.current[ce.index])==null||de.focus())},$=se=>{var ae;if(se.key===" "){se.stopPropagation();return}if(TI(se.key,E))return;const ce=se.target;if(xo(ce)||ce.tagName==="SELECT"||se.key!=="t"&&se.key!=="T"||se.ctrlKey||se.metaKey||se.altKey)return;se.preventDefault(),se.stopPropagation();const de=ak(ce.dataset.themeChoice??k);j(ak),ce.getAttribute("role")==="radio"&&((ae=se.currentTarget.querySelector(`[role="radio"][data-theme-choice="${de}"]`))==null||ae.focus())},{soundOn:T,toggleSound:I}=s,{tonePrefs:O,previewTone:U,changeTone:P}=o,{customSelections:L,customAssets:F,clearCustomOnly:A,selectCustomTone:B,importNotificationAudio:D,createNotificationVoice:K,renameCustomAsset:G,deleteCustomAsset:H,previewCustomAsset:q}=i,{notifyPermission:M,notifyOn:V,notifyVetoed:Z,toggleNotify:W,notifySupported:X,askForNotifications:Y,accountNotify:J,toggleAccountNotify:ee}=c,ne=(()=>{switch(e){case"reading":return a.jsx(Ife,{textSize:d.textSize,density:d.density,onTextSize:d.setTextSize,onDensity:d.setDensity});case"notifications":return a.jsx(mfe,{notifyOn:V,onToggleNotify:W,notifyVetoed:Z,notifyPermission:X?M:"unsupported",onAskNotify:Y,accountNotify:J,onToggleAccountNotify:ee});case"sounds":return a.jsx(Rfe,{soundOn:T===!0,onToggleSound:I,prefs:O,claudeHere:r.claude,onLevel:(se,ce)=>P(se,{level:ce}),onFigure:(se,ce)=>P(se,{figure:ce}),onPreview:se=>U(se),customAssets:F,customSelections:L,onBuiltInSelected:A,onCustomSelected:B,onImportCustom:D,onCreateVoice:K,onRenameCustom:G,onPreviewCustom:q,onDeleteCustom:H});default:return a.jsxs(a.Fragment,{children:[a.jsx($fe,{theme:k,onTheme:j,singleKeys:E}),a.jsx(Bfe,{characterEnabled:v,character:N,onCharacter:S,onToggleCharacter:()=>b(se=>!se)}),a.jsx(ofe,{singleKeys:E,onToggleSingleKeys:()=>O7(!E)}),a.jsx(Afe,{})]})}})();return a.jsx("div",{className:"modal-backdrop",...p,role:"presentation",children:a.jsxs("div",{ref:f,id:"settings",className:"modal settings-modal",role:"dialog","aria-modal":"true","aria-labelledby":"settings-title",onClick:se=>se.stopPropagation(),onKeyDown:$,children:[a.jsxs("header",{className:"modal-head",children:[a.jsx("div",{className:"modal-title",children:a.jsx("span",{id:"settings-title",className:"modal-tool-name",children:"Settings"})}),a.jsx("div",{className:"modal-actions",children:a.jsx("button",{type:"button",className:"glyph-btn",onClick:n,"aria-label":"Close settings",title:"Close (Esc)",children:"×"})})]}),a.jsxs("div",{className:"settings-body",children:[a.jsx("div",{className:"settings-nav",role:"tablist","aria-label":"Settings sections","aria-orientation":"vertical",onKeyDown:C,children:dc.map((se,ce)=>a.jsxs("button",{ref:de=>{g.current[ce]=de,se.id===e&&(h.current=de)},type:"button",role:"tab",id:`settings-tab-${se.id}`,className:"settings-tab","aria-selected":se.id===e,"aria-controls":"settings-pane",tabIndex:se.id===e?0:-1,onClick:()=>t(se.id),children:[a.jsx(gfe,{section:se.id}),a.jsx("span",{className:"settings-tab-label",children:se.label})]},se.id))}),a.jsxs("div",{className:"settings-pane",role:"tabpanel",id:"settings-pane","aria-labelledby":`settings-tab-${e}`,children:[a.jsx("h2",{className:"settings-pane-title",children:dc[w].label}),ne]},e)]})]})})}function Ufe({tool:e,onClose:t}){const n=ot(t),r=dt(t),s=e.endedAt==null?"inflight":e.ok===!1?"err":"done",o=y.useRef({of:null});o.current.of!==e&&(o.current={of:e}),e.input!==void 0&&(o.current.input=e.input),e.response!==void 0&&(o.current.response=e.response);const i=o.current.input??e.inputPreview,c=o.current.response??e.errorPreview,d=e.trimmed===!0&&o.current.input===void 0&&o.current.response===void 0,h=y.useMemo(()=>{const f=iW(e.name,i,c);return{input:f.input.map((p,g)=>a.jsx(F$,{block:p},g)),response:f.response.map((p,g)=>a.jsx(F$,{block:p},g)),copyInput:p_(e.name,"input",i),copyResponse:p_(e.name,"response",c)}},[e.name,i,c]);return a.jsx("div",{className:"modal-backdrop",...r,role:"presentation",children:a.jsxs("div",{ref:n,className:"modal",onClick:f=>f.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"tool-modal-title",children:[a.jsxs("header",{className:"modal-head",children:[a.jsxs("div",{className:"modal-title",children:[a.jsx("span",{className:`status-dot ${s}`,"aria-hidden":!0}),a.jsx("span",{id:"tool-modal-title",className:"modal-tool-name",children:e.name}),a.jsxs("span",{className:"modal-tool-id",title:e.id,children:[e.id.slice(0,12),"…"]})]}),a.jsxs("div",{className:"modal-actions",children:[a.jsx("span",{className:"modal-dur",children:uI(e,"in-flight…")}),a.jsx("button",{className:"glyph-btn",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),a.jsxs("section",{className:"modal-body",children:[d&&a.jsx("div",{className:"modal-section",children:a.jsx("p",{className:"modal-note",children:"Full payloads for this call were released to keep memory bounded — only the previews below are still held."})}),a.jsxs("div",{className:"modal-section",children:[a.jsxs("div",{className:"tm-head",children:[a.jsx("h4",{children:"Input"}),a.jsx(B$,{text:h.copyInput,what:"input"})]}),h.input]}),a.jsxs("div",{className:"modal-section",children:[a.jsxs("div",{className:"tm-head",children:[a.jsxs("h4",{children:["Response ",s==="err"&&a.jsx("span",{className:"err-tag",children:"error"})]}),e.endedAt!=null&&a.jsx(B$,{text:h.copyResponse,what:"response"})]}),e.endedAt==null?a.jsx("pre",{children:"(waiting…)"}):h.response]})]})]})})}const Hfe={del:"tm-del",add:"tm-add",ctx:"tm-ctx"};function F$({block:e}){const[t,n]=y.useState(!1);if(e.inline)return a.jsxs("p",{className:"tm-inline",children:[e.label&&a.jsx("span",{className:"tm-label",children:e.label}),a.jsx("code",{children:e.text})]});const r=y.useMemo(()=>eW(e),[e]),{shown:s}=zO(r,t),o=tW(r,t);return a.jsxs("div",{className:"tm-block",children:[e.label&&a.jsx("span",{className:"tm-label",children:e.label}),a.jsx("pre",{className:e.err?"tm-err":void 0,children:e.lines?s.map((i,c)=>a.jsxs("span",{className:i.tone?Hfe[i.tone]:void 0,children:[i.text,c<s.length-1?`
|
|
302
|
-
`:""]},c)):s.map(i=>i.text).join(`
|
|
303
|
-
`)}),o&&a.jsx("button",{type:"button",className:"btn tm-more","aria-expanded":o.expanded,onClick:()=>n(i=>!i),children:o.label})]})}function B$({text:e,what:t}){const[n,r]=y.useState(!1),s=y.useRef(!0);return y.useEffect(()=>()=>{s.current=!1},[]),a.jsx("button",{type:"button",className:"btn tm-copy",disabled:!e,"aria-label":n?`The ${t} was copied`:`Copy the ${t}`,onClick:()=>void Mo(e).then(o=>{!o||!s.current||(r(!0),window.setTimeout(()=>{s.current&&r(!1)},1600))}),children:n?"copied":"copy"})}const Wfe=K1(()=>Jc(()=>import("./UsageHistoryModal-BBAEDRj9.js"),[]),"Usage history"),zfe=K1(()=>Jc(()=>import("./BrowserWatchModal-TdSBv7_T.js"),[]),"Browser Watch"),Vfe=K1(()=>Jc(()=>import("./TrafficRadar-pRTWTOpJ.js"),[]),"Telemetry Radar");function Gfe({dialogs:e,welcome:t,desktopUpdate:n,versionCheck:r,restart:s,upgrade:o,lanPairs:i,attention:c,clearFlow:d,watchBadge:h,announcements:f,appearance:p,providers:g,stateRef:w,agentCount:k,menus:j,sound:v,tones:b,customTones:N,notify:S}){const{openedTool:E,setOpenedToolKey:C,usageHistoryOpen:$,setUsageHistoryOpen:T,browserWatchOpen:I,setBrowserWatchOpen:O,contextAgent:U,setContextFor:P,summaryFor:L,setSummaryFor:F,keyHelpOpen:A,setKeyHelpOpen:B,feedbackOpen:D,setFeedbackOpen:K,feedbackPrefill:G,setFeedbackPrefill:H}=e,{trafficRadarOpen:q,setTrafficRadarOpen:M}=e,{tourOpen:V,openTour:Z,closeTour:W,releaseNotes:X,closeReleaseNotes:Y,chipVersion:J}=t,{desktopUpdateRestarting:ee,desktopUpdateFailure:ne,readyAppUpdate:se,askDesktopUpdateRestart:ce}=n,{version:de}=r,{askRestart:ae}=s,{clearConfirmOpen:pe,setClearConfirmOpen:fe,requestClear:Ee}=d,{setWatchOn:ye,markWatchSeen:oe}=h,{setWatchSaid:we}=f,{palette:Ne}=p,{settingsOpen:ge,settingsSection:Ae,showSection:Oe,closeSettings:qe,openSettings:Me}=j;return a.jsxs(a.Fragment,{children:[E&&a.jsx(Ufe,{tool:E,onClose:()=>C(null)}),$&&a.jsx(y.Suspense,{fallback:null,children:a.jsx(Wfe,{providers:g,onClose:()=>T(!1)})}),I&&a.jsx(y.Suspense,{fallback:null,children:a.jsx(zfe,{onClose:()=>O(!1),onSeen:He=>{we(""),oe(He)},onWatching:ye,palette:Ne})}),U&&a.jsx(_z,{agent:U,onClose:()=>P(null)}),q&&a.jsx(y.Suspense,{fallback:null,children:a.jsx(Vfe,{sessions:[...w.current.agents.values()].filter(He=>He.kind==="root"&&He.provider!=="codex").map(He=>({id:He.sessionId,label:He.cwdBasename??He.label})),onClose:()=>M(!1)})}),D&&a.jsx(CD,{initialKind:G==null?void 0:G.initialKind,initialBody:G==null?void 0:G.initialBody,onClose:()=>{K(!1),H(null)}}),L&&a.jsx(nfe,{state:w.current,sessionId:L,onClose:()=>F(null)}),ge&&a.jsx(qfe,{section:Ae,onSection:Oe,onClose:qe,providers:g,sound:v,tones:b,customTones:N,notify:S,appearance:p}),X&&a.jsx(tfe,{entries:X.entries,since:X.since,firstRun:X.firstRun,running:J,onClose:Y,onTour:()=>{Y(),Z()},updateVersion:se==null?void 0:se.version,updateBusy:ee,updateFailure:ne&&(!se||se.version===ne.version)?$ce(ne.failure,ne.version):void 0,onUpdateRestart:se?()=>{ce(se.version)}:void 0,onRestart:!se&&(de!=null&&de.canRestart)?()=>{Y(),ae()}:void 0,updateCheck:{versionCheck:r,upgrade:o,restart:s,desktopUpdate:n,running:J,onHandOff:Y}}),a.jsx(Kfe,{lanPairs:i,attention:c}),A&&a.jsx(she,{onClose:()=>B(!1),onTour:()=>{B(!1),Z()},onSettings:()=>{B(!1),Me("general")}}),V&&a.jsx(rP,{title:"What the deck shows you",steps:ZQ,onClose:W}),pe&&a.jsx(Sue,{agentCount:k,onConfirm:()=>Ee("confirmation"),onCancel:()=>fe(!1)})]})}function Kfe({lanPairs:e,attention:t}){const n=ghe(e);return a.jsxs(a.Fragment,{children:[n,a.jsx(vhe,{...t,pairing:n!=null})]})}const Yfe=10,DD=500,FD=4e3,Xfe=[/ResizeObserver loop/i,/^Script error\.?$/i],Yh=String.raw`[^\s\\/:'"\`<>|?*;,]`,Zfe=String.raw`${Yh}(?:[^\\/\r\n:'"\`<>|?*;,]*${Yh})?[\\/]`,Jfe=String.raw`[^\s\\/:'"\`<>|?*;,()]+`,rc=String.raw`(?:${Zfe})*(?:${Jfe})?`,Qfe=String.raw`(?<![\w.~/\\\]-]|<(?:deck|host)>)(?:file://(?:/[A-Za-z]:)?[^\s:'"\`<>()]*|~[\\/]${rc}|[A-Za-z]:[\\/]${rc}|\\\\(?:[?.]\\)?(?:[A-Za-z]:\\)?${rc}|/(?=${Yh})${rc}|(?<!:)//(?=${Yh})${rc})`,epe=String.raw`(?<![\w-])(?:[A-Za-z]--|-[A-Za-z0-9][\w.]*-)[\w.-]*`,tpe=new Set([".claude",".codex"]);function npe(e){if(!e.startsWith("~"))return"<path>";const t=e[1],[n,...r]=e.slice(2).split(/[\\/]/);return n?tpe.has(n)?r.join("")?`~${t}${n}${t}<path>`:e:`~${t}<path>`:e}const rpe=String.raw`\b(https?|wss?)://[^\s/?#\\'"\x60<>(),;]+(?=(/assets/)?)`;function spe(e,t,n){return n?"<deck>":`${t}://<host>`}const q$=String.raw`(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)`,BD=String.raw`${q$}(?:\.${q$}){3}`,Hb=String.raw`[0-9A-Fa-f]{1,4}`,U$=String.raw`(?=[0-9A-Fa-f:]*\d)(?=[0-9A-Fa-f:]*::|(?:${Hb}:){7})(?:(?:${Hb})?:)+(?:${BD}|${Hb})?`,H$=String.raw`%[\w-]+(?:\.[\w-]+)*`,W$=String.raw`(?:::1?|::ffff:(?:127(?:\.\d{1,3}){3}|0\.0\.0\.0))`,ape=String.raw`(?<![\w:.%-])(?:\[(?!${W$}\])${U$}(?:${H$})?\]|(?!${W$}(?::\d{1,5})?(?![\w:%]|\.\d))${U$}(?:${H$})?(?![\w%]|\.\d))|(?<![\w./-])(?!127\.|0\.0\.0\.0\b)${BD}(?![\w-]|\.\d)`,Wb=String.raw`(?=[\w.-]*[A-Za-z])[A-Za-z0-9][\w-]*(?:\.[\w-]+)*`,ope=String.raw`(?<![\w.@/\\%-])(?!localhost(?![\w-]|\.\w))(?:(?<=\b(?:(?:getaddrinfo|connect) E[A-Z_]+|ENOTFOUND|EAI_AGAIN) )${Wb}|${Wb}(?=:\d{1,5}(?![\w:-]|\.\w))|${Wb}\.(?:local|lan|home|internal|ts\.net)(?![\w-]|\.\w))`;function z$(e){return String(e??"").replace(/\/(?:home|Users)\/[^/\s:'"]+/g,"~").replace(/[A-Za-z]:\\(?:Users|Documents and Settings)\\[^\\\r\n:'"]+/gi,"~").replace(new RegExp(Qfe,"g"),npe).replace(new RegExp(epe,"g"),"<project>").replace(new RegExp(rpe,"g"),spe).replace(new RegExp(ape,"g"),"<host>").replace(new RegExp(ope,"g"),"<host>").replace(/[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Za-z]{2,}/g,"<email>").replace(/\b(?:sk-ant-[A-Za-z0-9_-]{8,}|sk-[A-Za-z0-9_-]{20,}|gh[pousr]_[A-Za-z0-9]{20,}|xox[abpr]-[A-Za-z0-9-]{10,}|eyJ[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}\.[A-Za-z0-9_-]{8,}|[A-Fa-f0-9]{40,}|[A-Za-z0-9+_=-]{48,})/g,"<secret>")}const qD=e=>{fetch("/api/client-error",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e),keepalive:!0}).catch(()=>{})};function ipe(e,t,n=qD){const r=String(e??"").slice(0,DD).trim();r&&n({message:r,stack:typeof t=="string"?t.slice(0,FD):void 0})}function lpe(e,t=window,n=qD){let r=0;const s=new Set,o=(d,h)=>{const f=String(d??"").slice(0,DD).trim();!e()||!f||r>=Yfe||s.has(f)||Xfe.some(p=>p.test(f))||(s.add(f),r++,n({message:f,stack:typeof h=="string"?h.slice(0,FD):void 0}))},i=d=>{var h,f;return o(((h=d.error)==null?void 0:h.message)??d.message,(f=d.error)==null?void 0:f.stack)},c=d=>typeof d.reason=="object"&&d.reason!==null?o(d.reason.message,d.reason.stack):o(d.reason,void 0);return t.addEventListener("error",i),t.addEventListener("unhandledrejection",c),()=>{t.removeEventListener("error",i),t.removeEventListener("unhandledrejection",c)}}const cpe=12;function upe(e,t){const n=[z$(e).trim()||"The deck threw an error with no message."],r=t==null?void 0:t.trim();if(r){const s=r.split(`
|
|
304
|
-
`).slice(0,cpe).join(`
|
|
305
|
-
`);n.push("",z$(s).trim())}return n.join(`
|
|
306
|
-
`)}class dpe extends y.Component{constructor(){super(...arguments);Mm(this,"state",{error:null,componentStack:null,reportOpen:!1});Mm(this,"onKey",n=>{cz(n.key)&&jn.dismissTop()})}static getDerivedStateFromError(n){return{error:n}}componentDidCatch(n,r){console.error("ccdeck hit a render error it could not draw past",n,r.componentStack),this.setState({componentStack:r.componentStack??null}),ipe(n.message,n.stack),eD("offline")}componentDidUpdate(n,r){this.state.reportOpen!==r.reportOpen&&(this.state.reportOpen?window.addEventListener("keydown",this.onKey):window.removeEventListener("keydown",this.onKey))}componentWillUnmount(){window.removeEventListener("keydown",this.onKey)}render(){const{error:n,componentStack:r,reportOpen:s}=this.state;return n?a.jsxs("div",{className:"error-fallback",children:[a.jsxs("div",{className:"error-fallback-card",role:"alert",children:[a.jsx("p",{className:"error-fallback-title",children:"Something went wrong"}),a.jsx("p",{className:"error-fallback-note",children:"The deck hit an error it could not draw past. Reloading usually clears it — and if it keeps happening, a report tells the people who make ccdeck what broke."}),a.jsxs("div",{className:"error-fallback-actions",children:[a.jsx("button",{type:"button",className:"btn primary",onClick:()=>window.location.reload(),children:"Reload"}),a.jsx("button",{type:"button",className:"btn",onClick:()=>this.setState({reportOpen:!0}),"aria-haspopup":"dialog",children:"Send report"})]})]}),s&&a.jsx(CD,{initialKind:"bug",initialBody:upe(n.message,r),onClose:()=>this.setState({reportOpen:!1})})]}):this.props.children}}const hpe=1e3;function fpe(e={}){const t=Math.max(1,Math.floor(e.limit??hpe)),n=e.protect;let r=!1,s=[],o=new Set,i=0,c=0,d=null;return{get paused(){return r},get size(){return s.length},get dropped(){return i},get overflowed(){return i>0},get through(){return c},accept(h){const f=typeof(h==null?void 0:h.seq)=="number"?h.seq:null,p=(h==null?void 0:h.epoch)??null,g=p!==null&&p!==d;g&&(d=p,c=0);const w=f!==null&&!g&&f<=c;if(f!==null&&f>c&&(c=f),!r)return!0;if(w)return!1;if(s.push(h),n!=null&&n(h)&&o.add(h),s.length>t){let k=0;if(o.size<s.length)for(;o.has(s[k]);)k++;const[j]=s.splice(k,1);o.delete(j),i++}return!1},setPaused(h){if(r=h,h)return[];const f=s;return s=[],o=new Set,i=0,f}}}function ppe(e){const t=y.useState(()=>fpe({protect:o=>hW(e.current,o)}))[0],[n,r]=y.useState(!1),s=y.useCallback(()=>{const o=t.paused&&t.dropped>0,i=t.setPaused(!t.paused);o&&LW(e.current);for(const c of i)e.current=eI(e.current,c);r(t.paused)},[t,e]);return{pauseGate:t,paused:n,togglePause:s}}const hk={kind:"assumed",claude:!0,codex:!0};function mpe(e){if(!e||typeof e!="object")return hk;const t=e.providers;if(!t||typeof t!="object")return hk;const n=t;return{kind:"reported",claude:n.claude!==!1,codex:n.codex!==!1}}function gpe(e){const[t,n]=y.useState(null),[r,s]=y.useState(hk);y.useEffect(()=>{let i=!1;return fetch("/api/health").then(c=>c.ok?c.json():null).then(c=>{i||(s(mpe(c)),!(!c||typeof c.workspace!="string")&&n(c.workspace))}).catch(()=>{}),()=>{i=!0}},[e]);const o=Wn(r);return{workspace:t,providers:r,providersRef:o}}const UD=3*6e4,ype=2e4;function wpe({fetchReport:e,visible:t,now:n,onReport:r}){let s=0,o=!0;const i=async()=>{if(!t())return;const c=await e();!o||!c||(s=n(),r(c))};return{tick:i,wake:async()=>{t()&&n()-s>=UD&&await i()},stop:()=>{o=!1}}}async function xpe(){try{const e=await fetch("/api/provider-status",{signal:AbortSignal.timeout(ype)});return e.ok?await e.json():null}catch{return null}}function vpe(e){const[t,n]=y.useState(null);return y.useEffect(()=>{if(!e){n(null);return}const r=wpe({fetchReport:xpe,visible:()=>document.visibilityState==="visible",now:()=>Date.now(),onReport:n});r.tick();const s=window.setInterval(r.tick,UD),o=()=>{r.wake()};return document.addEventListener("visibilitychange",o),()=>{r.stop(),window.clearInterval(s),document.removeEventListener("visibilitychange",o)}},[e]),t}const bpe={degraded:"degraded performance",partial_outage:"partial outage",major_outage:"major outage",maintenance:"maintenance"},kpe={degraded:"degraded",partial_outage:"partial outage",major_outage:"major outage",maintenance:"maintenance"},jpe={degraded:"degraded",partial_outage:"outage",major_outage:"outage",maintenance:"maint."},Npe={claude:"Claude",codex:"Codex"},Spe=new Set(["status.claude.com","status.openai.com"]),_pe=30*6e4,Epe=10*6e4;function Cpe(e){if(typeof e!="string")return null;try{const t=new URL(e);return t.protocol==="https:"&&Spe.has(t.hostname)?t:null}catch{return null}}function V$(e){return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hourCycle:"h23"})}function Tpe(e){const t=Math.floor(e/6e4);return t<1?"just now":t<60?`${t} min ago`:`${Math.floor(t/60)} h ago`}function Rpe(e,t){if(!e||typeof e!="object")return null;const n=qt(bpe,e.state),r=qt(Npe,e.provider);if(!n||!r||typeof e.checkedAt!="number"||t-e.checkedAt>_pe)return null;const s=Cpe(e.statusPageUrl);if(!s)return null;const o=Array.isArray(e.components)?e.components:[],i=e.stale===!0||t-e.checkedAt>Epe,c=[`${r}: ${n}${e.summary?` — ${e.summary}`:""}`,o.length>0?`Affected: ${o.join(", ")}`:null,e.scope==="page"?`The page's overall status: it names none of ${r}'s components`:null,i?`Last read from ${s.hostname} at ${V$(e.checkedAt)}; this is the last thing it said`:`Reported by ${s.hostname}, checked ${Tpe(t-e.checkedAt)}`,"Opens the status page"],d=i?V$(e.checkedAt):null;return{provider:e.provider,state:e.state,name:r,label:`${r} · ${n}${d?` · as of ${d}`:""}`,words:n,chipWords:qt(kpe,e.state)??n,shortWords:qt(jpe,e.state)??n,asOf:d,what:e.summary||(o.length>0?o.join(", "):null),href:s.href,host:s.hostname,stale:i,detail:c.filter(Boolean).join(`
|
|
307
|
-
`)}}function Ape(e,t){return!(e!=null&&e.ok)||e.disabled||!Array.isArray(e.providers)?[]:e.providers.map(n=>Rpe(n,t)).filter(n=>n!==null)}function Mpe(e){return e.map(t=>`${t.name}'s status page reports ${t.state.endsWith("outage")?`a ${t.words}`:t.words}.`).join(" ")}const $pe="The providers' status pages report no incident.";function Lpe({version:e,loadVersion:t}){var h;const[n,r]=y.useState(!1),s=((h=e==null?void 0:e.upgrade)==null?void 0:h.state)??"idle",o=fue(e==null?void 0:e.upgrade),i=y.useRef(!1),c=y.useCallback(async()=>{if(qn(i.current||s==="running")){i.current=!0;try{await fetch("/api/upgrade",{method:"POST"})}catch{}await t(),i.current=!1}},[s,t]);y.useEffect(()=>{if(s!=="running")return;const f=window.setInterval(t,3e3);return()=>window.clearInterval(f)},[s,t]);const d=y.useCallback(async()=>{const f=e==null?void 0:e.command;!f||!await Mo(f)||(r(!0),window.setTimeout(()=>r(!1),1600))},[e==null?void 0:e.command]);return{upgradeState:s,upgradeFailure:o,startUpgrade:c,copyCommand:d,cmdCopied:n}}const G$="agent-dag.browserWatch.seenMs";function Ope(e,t){return e.filter(n=>n.startMs>t)}function Ipe(){const[e,t]=y.useState(()=>Number(Ge(G$))||0),[n,r]=y.useState([]),[s,o]=y.useState(!1);y.useEffect(()=>{let d=!0;const h=()=>{fetch("/api/browser-watch?live=0").then(p=>p.ok?p.json():null).then(p=>{var g;!d||!(p!=null&&p.ok)||(r(p.episodes??[]),o(((g=p.settings)==null?void 0:g.enabled)===!0))}).catch(()=>{})};h();const f=setInterval(h,5*6e4);return()=>{d=!1,clearInterval(f)}},[]);const i=y.useMemo(()=>Ope(n,e).length,[n,e]),c=y.useCallback(d=>{t(d),Ve(G$,String(d))},[]);return{watchOn:s,setWatchOn:o,watchUnseen:i,markWatchSeen:c}}const HD="agent-dag.character-enabled",WD="agent-dag.fm-volume",Ppe=1,K$="agent-dag.fm-source",dge=[{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:"📻 The Good Life Radio",value:"good-life-radio",label:"🌴 The Good Life Radio"}];function Dpe(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 Fpe(e){return e!=="0"}function Bpe(){return Fpe(Ge(HD))}function qpe(e){return OP(e,Ppe)}function Upe(){return qpe(Ge(WD))}const zD=["--err","--inflight","--ok","--warn","--muted","--grid-line","--minimap-mask","--panel","--line","--accent","--text-dim","--bg"];function Y$(e){const t={};for(const n of zD)t[n]=e(n);return t}function Hpe(e){return t=>e[t]??""}function Wpe(e,t){return zD.every(n=>e[n]===t[n])}function zpe(e,t){let n=null,r=0;function s(){r++,n==null||n.skipTransition(),n=null,delete e.documentElement.dataset.themeTransition}return{cancel:s,run(o){s();const i=r;let c=!1;const d=()=>{i!==r||c||(c=!0,o())};if(!e.startViewTransition||e.hidden||t()){d();return}e.documentElement.dataset.themeTransition="true";try{const h=e.startViewTransition(d);n=h,h.ready.catch(()=>{}),h.updateCallbackDone.catch(()=>{d()}),h.finished.then(()=>{n===h&&(n=null,delete e.documentElement.dataset.themeTransition)},()=>{n===h&&(d(),n=null,delete e.documentElement.dataset.themeTransition)})}catch{delete e.documentElement.dataset.themeTransition,d()}}}}function X$(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}function Vpe(){const[e,t]=y.useState(yK),[n,r]=y.useState(wK),[s,o]=y.useState(Dle),i=y.useRef(s),[c]=y.useState(()=>zpe(document,()=>{try{return window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!0}})),d=y.useCallback(b=>{const N=typeof b=="function"?b(i.current):b;N!==i.current&&(i.current=N,c.run(()=>yt.flushSync(()=>o(N))))},[c]);y.useEffect(()=>()=>c.cancel(),[c]);const[h,f]=y.useState(Bpe),[p,g]=y.useState(Dfe),[w,k]=y.useState(()=>Y$(X$)),j=y.useMemo(()=>Hpe(w),[w]),v=y.useCallback(b=>ole(b,j),[j]);return y.useEffect(()=>{document.documentElement.dataset.textSize=e,Ve(S0,e)},[e]),y.useEffect(()=>{document.documentElement.dataset.density=n,Ve(_0,n)},[n]),y.useEffect(()=>{const b=N=>{N.storageArea===Li()&&((N.key===S0||N.key===null)&&t(Qk(N.newValue)),(N.key===_0||N.key===null)&&r(t3(N.newValue)))};return window.addEventListener("storage",b),()=>window.removeEventListener("storage",b)},[]),y.useLayoutEffect(()=>{document.documentElement.dataset.theme=s,document.documentElement.dataset.colorScheme=Jf[s].colorScheme,Ve(tD,s),k(b=>{const N=Y$(X$);return Wpe(b,N)?b:N})},[s]),y.useEffect(()=>{Ve(HD,h?"1":"0")},[h]),y.useEffect(()=>{Ve(PD,p)},[p]),y.useEffect(()=>{const b=document.querySelector('meta[name="theme-color"]'),N=w["--panel"];b&&N&&b.setAttribute("content",N)},[w]),{textSize:e,setTextSize:t,density:n,setDensity:r,theme:s,setTheme:d,characterEnabled:h,setCharacterEnabled:f,character:p,setCharacter:g,palette:w,minimapNodeFill:v}}function Gpe(e){const t=y.useRef(null),[n,r]=y.useState(!1),[s,o]=y.useState(()=>new Set),i=y.useMemo(()=>{const d=new Set;for(const h of e.current.agents.values())for(const f of h.tools)d.add(sD(f.name));return Object.keys(rD).filter(h=>d.has(h))},[e.current,e.current.revision]);y.useEffect(()=>{if(i.length<=1){r(!1);return}let d=0;const h=()=>{const f=t.current;if(f&&!document.hidden){const p=f.getBoundingClientRect(),g=Array.from(document.querySelectorAll(".react-flow__node, .tool-burst")).map(k=>k.getBoundingClientRect()),w=YG(p,g,8);r(k=>k===w?k:w)}d=window.setTimeout(h,300)};return h(),()=>window.clearTimeout(d)},[i.length]);const c=y.useCallback(d=>{o(h=>{const f=new Set(h);return f.has(d)?f.delete(d):f.add(d),f})},[]);return{presentCats:i,hiddenCats:s,toggleCat:c,catBarRef:t,catBarOccluded:n}}function Kpe(e={enabled:()=>!0}){const t=e.ctor??(typeof window<"u"?window.AudioContext??window.webkitAudioContext??null:null);let n=null;const r=new Set,s=()=>e.enabled()?(n==null?void 0:n.state)==="running"?"ready":"locked":"off",o=()=>{var g;return(g=e.onState)==null?void 0:g.call(e,s())};function i(){var g,w;if(!(!t||(n==null?void 0:n.state)==="running"))try{n||(n=new t,(g=n.addEventListener)==null||g.call(n,"statechange",o)),(w=n.resume)==null||w.call(n).then(o,()=>{}),o()}catch{}}function c(g,w,k=w.figure){if(!n||n.state!=="running")return!1;const j=Z0(g,k),v=sre(w.level,j),b=n.currentTime;for(const N of j.notes){const S=n.createOscillator(),E=n.createGain();S.type=j.type??"sine",S.frequency.value=N.hz;const C=b+N.at,$=C+N.ms/1e3;E.gain.setValueAtTime(MC,C),E.gain.exponentialRampToValueAtTime(v,C+are),E.gain.exponentialRampToValueAtTime(MC,$),S.connect(E).connect(n.destination),S.start(C),S.stop($+.02)}return!0}async function d(g,w){var v;if(!e.loadCustom)return"unavailable";let k;try{k=await e.loadCustom(g)}catch{return"unavailable"}if(!k)return"missing";if(k.kind==="tts"){if(typeof window>"u"||!("speechSynthesis"in window)||typeof SpeechSynthesisUtterance>"u")return"unavailable";const b=new SpeechSynthesisUtterance(k.text),N=window.speechSynthesis.getVoices();b.voice=N.find(S=>S.voiceURI===k.voiceURI)??null,b.rate=k.rate,b.pitch=k.pitch,b.volume=ore(w.level);try{return window.speechSynthesis.cancel(),window.speechSynthesis.speak(b),"played"}catch{return"unavailable"}}if(!n||n.state!=="running")return"locked";let j;try{j=await n.decodeAudioData(k.bytes.slice(0))}catch{return"broken"}try{const b=n.createBufferSource(),N=n.createGain();return b.buffer=j,N.gain.setValueAtTime(ire(k.normalizationGain,w.level),n.currentTime),b.connect(N).connect(n.destination),r.add(b),(v=b.addEventListener)==null||v.call(b,"ended",()=>r.delete(b)),b.start(n.currentTime),"played"}catch{return"unavailable"}}function h(g,w=!1){var v,b;if(!w&&!e.enabled())return!1;const k=pre((v=e.prefs)==null?void 0:v.call(e),g),j=((b=e.customSelection)==null?void 0:b.call(e)[g])??null;return j&&e.loadCustom?(d(j,k).then(N=>{var S;N==="played"||N==="locked"||((N==="missing"||N==="broken")&&((S=e.onCustomFailure)==null||S.call(e,g,j)),c(g,{...k,figure:Un},Un))}),!0):!n||n.state!=="running"?!1:c(g,k)}function f(g,w=To){return d(g,{level:Mf(w),figure:Un}),!0}function p(){try{typeof window<"u"&&"speechSynthesis"in window&&window.speechSynthesis.cancel()}catch{}for(const g of r)try{g.stop()}catch{}r.clear()}return{unlock:i,play:h,previewCustom:f,silence:p,state:s,get context(){return n}}}function Ype({chimesRef:e,soundOnRef:t,tonePrefsRef:n,customSelectionsRef:r,fallbackCustomRef:s}){y.useEffect(()=>{const o=Kpe({enabled:()=>t.current===!0,prefs:()=>n.current,customSelection:()=>r.current,loadCustom:Qne,onCustomFailure:(h,f)=>s.current(h,f)});e.current=o;const i=["pointerdown","pointerup","keydown"],c=()=>{for(const h of i)window.removeEventListener(h,d,{capture:!0})},d=()=>{var h;o.unlock(),((h=o.context)==null?void 0:h.state)==="running"&&c()};for(const h of i)window.addEventListener(h,d,{capture:!0});return c},[])}function Xpe(){const[e,t]=y.useState(Upe),[n,r]=y.useState(()=>e9(Ge(D_))),[s,o]=y.useState(()=>Q7(Ge(F_))),[i,c]=y.useState(()=>t9(Ge(K$),n,Dpe)),[d,h]=y.useState(()=>new Set),[f,p]=y.useState(0);y.useEffect(()=>{Ve(WD,String(e))},[e]),y.useEffect(()=>{Ve(F_,s?"1":"0")},[s]),y.useEffect(()=>{Ve(D_,JSON.stringify(n))},[n]),y.useEffect(()=>{Ve(K$,i)},[i]);const g=y.useCallback((b,N=!1)=>{r(S=>{const E=S.find(C=>C.id===b.id);return E?!N||!b.radio||!E.radio||E.url===b.url&&JSON.stringify(E.radio)===JSON.stringify(b.radio)?S:S.map(C=>C.id===b.id?{...C,url:b.url,radio:b.radio}:C):[...S,b]}),h(S=>{if(!S.has(b.id))return S;const E=new Set(S);return E.delete(b.id),E})},[]),w=y.useCallback((b,N)=>{const S=N.trim();!S||S.length>$I||r(E=>E.map(C=>C.id===b?{...C,name:S}:C))},[]),k=y.useCallback(b=>{r(N=>N.filter(S=>S.id!==b)),c(N=>n9(N,b)),h(N=>{if(!N.has(b))return N;const S=new Set(N);return S.delete(b),S})},[]),j=y.useCallback((b,N=!1)=>{const S=B_(b),E=d.has(S);b===i&&!E&&!N||(E&&h(C=>{const $=new Set(C);return $.delete(S),$}),c(b),p(C=>C+1))},[i,d]),v=y.useCallback((b,N)=>{const S=B_(b);h(E=>{if(E.has(S)===N)return E;const $=new Set(E);return N?$.add(S):$.delete(S),$})},[]);return{fmVolume:e,setFmVolume:t,fmMuted:s,setFmMuted:o,fmSource:i,customFmStations:n,unavailableFmStations:d,fmPlayRequest:f,addFmStation:g,renameFmStation:w,removeFmStation:k,pickFmSource:j,markFmStationAvailability:v}}function Zpe(e){const[t,n]=y.useState(null),[r,s]=y.useState(!1),[o,i]=y.useState(null),c=y.useRef(0);y.useEffect(()=>{if(!e||!Ro())return;let k=!1;const j=c.current;return fetch("/api/desktop-update").then(v=>v.ok?v.json():null).then(v=>{if(k||c.current!==j)return;const b=m$(v);b&&n(b)}).catch(()=>{}),()=>{k=!0}},[e]);const d=Rce(t),h=y.useRef(!1),f=y.useRef(0),p=y.useRef(0);y.useEffect(()=>()=>window.clearTimeout(f.current),[]);const g=y.useCallback(async k=>{if(!qn(h.current))return;const j=++p.current;window.clearTimeout(f.current),h.current=!0,s(!0),i(null);const v=b=>{j===p.current&&(window.clearTimeout(f.current),h.current=!1,s(!1),i({failure:b,version:k}))};try{const b=await fetch("/api/desktop-update/restart",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({version:k})});if(!b.ok)return v(Mce(await b.json().catch(()=>null)))}catch{return v("unreachable")}j===p.current&&(f.current=window.setTimeout(()=>v("timeout"),uD))},[]),w=y.useCallback(k=>{if(Ro())try{const j=m$(JSON.parse(k));j&&(c.current++,n(j),j.status!=="ready"&&(p.current++,window.clearTimeout(f.current),h.current=!1,s(!1)))}catch{}},[]);return{desktopUpdateRestarting:r,desktopUpdateFailure:o,readyAppUpdate:d,appUpdate:t,askDesktopUpdateRestart:g,onDesktopUpdateEvent:w}}const zd="agent-dag.autoRestart",Z$="agent-dag.bundleReloadedFor";function Jpe({now:e,stateRef:t,version:n,notice:r,noticeOpen:s,upgradeFailure:o,paused:i}){const[c,d]=y.useState(()=>Ge(zd)!=="0"),h=y.useRef(!1),f=y.useCallback(()=>{const U=!c;h.current=!0,es(zd),d(U),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:U})}).then(P=>P.ok?P.json():null).then(P=>{var L;P!=null&&P.ok&&d(((L=P.prefs)==null?void 0:L.autoUpdate)!==!1)}).catch(()=>{})},[c]),[p,g]=y.useState(!1),[w,k]=y.useState("restart"),[j,v]=y.useState(null),b=y.useRef(!1),N=y.useRef(null),S=y.useRef(0),E=y.useRef(null),C=y.useCallback(async U=>{if(!qn(b.current))return;const P=(U==null?void 0:U.upgrade)===!0,L=(U==null?void 0:U.whenIdle)===!0;b.current=!0,N.current=o;const F=++S.current,A=()=>{k(P?"npx":"restart"),g(!0)};L||A();try{window.sessionStorage.setItem("agent-dag.restartPending",(r==null?void 0:r.to)??"")}catch{}let B=!1;try{const D=await fetch("/api/restart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(L?{upgrade:P,whenIdle:L}:{upgrade:P})});B=L&&D.status===409}catch{}if(B){b.current=!1,E.current=null;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}return}L&&A(),window.setTimeout(()=>{if(S.current===F&&b.current){b.current=!1,g(!1);try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}}},P?18e4:3e4)},[r==null?void 0:r.to,o]);y.useEffect(()=>{const U=y$(t.current.agents.values())>0,P=wue({enabled:c,kind:r==null?void 0:r.kind,canRestart:(n==null?void 0:n.canRestart)===!0,noticeOpen:s,visible:document.visibilityState==="visible",busy:U,idleSince:E.current,now:e});E.current=P.idleSince,P.restart&&C({whenIdle:!0})},[c,r==null?void 0:r.kind,n==null?void 0:n.canRestart,s,e,C]);const $=y$(t.current.agents.values()),T=yue($,i),I=mD({enabled:c,kind:r==null?void 0:r.kind,canRestart:(n==null?void 0:n.canRestart)===!0,noticeOpen:s,visible:document.visibilityState==="visible",busy:$>0,idleSince:E.current,now:e});y.useEffect(()=>{const U=n==null?void 0:n.running;let P=null,L=null;try{P=window.sessionStorage.getItem("agent-dag.restartPending"),L=window.sessionStorage.getItem(Z$)}catch{return}const F=hue({bundle:"3.42.0",running:U,pending:P,lastTried:L});if(F==="reload"){try{window.sessionStorage.setItem(Z$,U??"")}catch{return}window.location.reload();return}if(F!=="confirm")return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}b.current=!1,g(!1),v(U??null);const A=window.setTimeout(()=>v(null),6e3);return()=>window.clearTimeout(A)},[n==null?void 0:n.running]),y.useEffect(()=>{if(p&&pue({asked:N.current,reported:o})){try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}b.current=!1,g(!1)}},[p,o]);const O=y.useCallback(U=>{var P,L;if(!h.current){const F=Ge(zd)==="0";es(zd),F&&((P=U.prefs)==null?void 0:P.autoUpdate)!==!1?(d(!1),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:!1})}).catch(()=>{})):d(((L=U.prefs)==null?void 0:L.autoUpdate)!==!1)}},[]);return{autoRestart:c,toggleAutoRestart:f,restarting:p,restartMode:w,restartedTo:j,askRestart:C,restartCopy:T,restartFuseMs:I,loadAutoRestartPrefs:O}}function Qpe(){const[e,t]=y.useState([]),n=y.useRef(new Set),[r,s]=y.useState(null),[o,i]=y.useState(void 0);y.useEffect(()=>{let h=!0,f=0;const p=()=>{fetch("/api/lan").then(g=>g.ok?g.json():null).then(g=>h?(g!=null&&g.ok&&t(rC(Array.isArray(g.pending)?g.pending:[],g.aliases)),g):null).catch(()=>null).then(g=>{h&&(i(w=>g!=null&&g.ok?g:w===void 0?null:w),f=window.setTimeout(p,(g==null?void 0:g.enabled)===!0?H0:nP))})};return p(),()=>{h=!1,window.clearTimeout(f)}},[]);const c=y.useCallback(async(h,f)=>{if(!r){s(h);try{const g=await(await fetch("/api/lan/peer",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:h,fp:f})})).json().catch(()=>null);g&&Array.isArray(g.pending)?t(rC(g.pending,g.aliases)):t(w=>w.filter(k=>k.fp!==f))}catch{}finally{s(null)}}},[r]),d=y.useCallback(h=>{r||(n.current.add(h),t(f=>[...f]))},[r]);return{lanPending:e,lanDeferred:n,lanBusy:r,answerLanPair:c,deferLanPair:d,lanStatus:o}}const eme=6e4;function tme({enabled:e,lanStatus:t,now:n}){const[r,s]=y.useState(null),[o,i]=y.useState(()=>new Set),[c,d]=y.useState(null),h=y.useCallback(b=>{b!=null&&b.ok&&Array.isArray(b.accounts)&&s(b.accounts)},[]),f=y.useCallback(async b=>{try{const N=await fetch(`/api/claude-accounts${b?"?refresh=1":""}`);N.ok&&h(await N.json())}catch{}},[h]);y.useEffect(()=>{e&&f(!1)},[e,f]),y.useEffect(()=>{if(!e)return;let b=Date.now();const N=()=>{document.visibilityState!=="visible"||Date.now()-b<eme||(b=Date.now(),f(!1))};return document.addEventListener("visibilitychange",N),window.addEventListener("focus",N),()=>{document.removeEventListener("visibilitychange",N),window.removeEventListener("focus",N)}},[e,f]);const p=y.useMemo(()=>e?ihe(r,{lan:t,now:n,closed:o}):[],[e,r,t,n,o]),g=y.useRef(p);g.current=p;const w=y.useCallback(b=>{b.length&&i(N=>new Set([...N,...b]))},[]),k=y.useCallback(()=>{const b=g.current;b.length&&(w(b.map(N=>N.id)),fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"reauth-later",incidents:b.map(N=>({key:N.key,since:N.since}))})}).catch(()=>{}))},[w]),j=y.useRef(c);j.current=c;const v=y.useCallback(b=>{const N=j.current;w(lhe(N?[N,...g.current]:g.current,b))},[w]);return{rows:p,signingIn:c,observe:h,signIn:d,signedIn:v,refresh:y.useCallback(()=>{f(!0)},[f]),closeSignIn:y.useCallback(()=>d(null),[]),later:k}}const VD=288,nme=VD;function rme(e,t,n){return e?"session-list":t||n?"accounts":null}function sme(e){return e==="session-list"?nme:e==="accounts"?VD:0}const ame=240,ome=20;function ime(e){const t=y.useRef(0),n=y.useRef(e);return y.useLayoutEffect(()=>{n.current!==e&&(n.current=e,t.current=Yc()?0:performance.now()+ame+ome)},[e]),t}const GD="agent-dag.sessionListOpen",KD="agent-dag.accountsPanelOpen";function lme(){return Ge(GD)==="1"}function cme(e){Ve(GD,e?"1":"0")}function ume(){const e=Ge(KD);return e===null?!0:e==="1"}function dme(){const[e,t]=y.useState(lme);y.useEffect(()=>{cme(e)},[e]);const n=y.useRef(!1),[r,s]=y.useState(()=>{const p=ume();return p&&e?(n.current=!0,!1):p});y.useEffect(()=>{!r&&n.current||Ve(KD,r?"1":"0")},[r]),y.useEffect(()=>{!e&&n.current&&(n.current=!1,s(!0))},[e]);const o=y.useCallback(()=>{t(p=>(p||s(g=>(g&&(n.current=!0),!1)),!p))},[]),i=y.useCallback(()=>{n.current=!1,s(p=>(p||t(!1),!p))},[]),c=y.useCallback(()=>t(!1),[]),d=y.useCallback(()=>{n.current=!1,t(!1)},[]),h=y.useCallback(()=>s(!1),[]),f=rme(e,r,n.current);return{sessionListOpen:e,accountsPanelOpen:r,panel:f,toggleSessionList:o,toggleAccountsPanel:i,closeSessionList:c,closeSessionListToCanvas:d,closeAccountsPanel:h}}const YD="agent-dag.detailOpen",XD="agent-dag.usagePanelOpen",ZD="agent-dag.systemPanelOpen";function hme(){return Ge(YD)==="1"}function fme(e){Ve(YD,e?"1":"0")}function pme(){const e=Ge(XD);return e===null?!0:e==="1"}function mme(e){Ve(XD,e?"1":"0")}function gme(){const e=Ge(ZD);return e===null?!0:e==="1"}function yme(e){Ve(ZD,e?"1":"0")}function wme(){const[e,t]=y.useState(hme);y.useEffect(()=>{fme(e)},[e]);const[n,r]=y.useState(pme);y.useEffect(()=>{mme(n)},[n]);const[s,o]=y.useState(gme);return y.useEffect(()=>{yme(s)},[s]),Jt("usage-panel",n),Jt("machine-panel",s),{detailOpen:e,setDetailOpen:t,usagePanelOpen:n,setUsagePanelOpen:r,machinePanelOpen:s,setMachinePanelOpen:o}}const xme={permission:"your permission",asked:"your answer"},vme="No sessions are waiting for you.";function bme(e){if(e.length===0)return"";const[t,...n]=e,r=t.waiting.kind,s=n.every(i=>i.waiting.kind===r)?xme[r]??"you":"you";if(n.length===0)return`${t.label} is waiting for ${s}.`;const o=`${n.length} more session${n.length===1?"":"s"}`;return`${t.label} and ${o} are waiting for ${s}.`}function zb(e,t,n=vme){return t!==""?t:e===""?"":n}function kme({waitingSessions:e,watchUnseen:t,incidents:n=[]}){const[r,s]=y.useState(""),o=bme(e);y.useEffect(()=>{s(g=>zb(g,o))},[o]);const[i,c]=y.useState(""),d=t>0?`Browser watch has ${t} unread ${t===1?"finding":"findings"}.`:"";y.useEffect(()=>{c(g=>zb(g,d,"Browser watch has no unread findings."))},[d]);const[h,f]=y.useState(""),p=Mpe(n);return y.useEffect(()=>{f(g=>zb(g,p,$pe))},[p]),{blockedSaid:r,watchSaid:i,setWatchSaid:c,incidentSaid:h}}const jme="/icon-192.png",JD=Object.freeze({notifySwap:!0,notifyQuota:!1,notifyReset:!1});function J$(e){const t=n=>typeof(e==null?void 0:e[n])=="boolean"?e[n]:JD[n];return{notifySwap:t("notifySwap"),notifyQuota:t("notifyQuota"),notifyReset:t("notifyReset")}}function Nme({waitingSessions:e,liveSince:t,focusSession:n}){const[r,s]=y.useState(()=>typeof Notification>"u"?"denied":Notification.permission),[o,i]=y.useState(null),[c,d]=y.useState(!1),[h,f]=y.useState(!1),[p,g]=y.useState(JD),w=y.useCallback(I=>{const O=!p[I];g(U=>({...U,[I]:O})),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({[I]:O})}).then(U=>U.ok?U.json():null).then(U=>{U!=null&&U.ok&&g(J$(U.prefs))}).catch(()=>{})},[p]),k=y.useRef(()=>{}),j=y.useRef(new Set),v=Wn(e),b=y.useCallback(()=>{const I=!c;d(I),I&&(j.current=Ed(v.current)),I&&typeof Notification<"u"&&Notification.permission==="default"&&k.current(),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({notifications:I})}).then(O=>O.ok?O.json():null).then(O=>{var U;O!=null&&O.ok&&(d(((U=O.prefs)==null?void 0:U.notifications)===!0),f(O.notificationsVetoed===!0))}).catch(()=>{})},[c]),N=typeof Notification<"u";y.useEffect(()=>{if(!o)return;const O=setTimeout(()=>i(null),o==="blocked"?8e3:4e3);return()=>clearTimeout(O)},[o]);const S=y.useCallback(()=>{typeof Notification>"u"||Notification.requestPermission().then(I=>{const O=I;s(O),O==="granted"?i("on"):O==="denied"&&i("blocked")})},[]);k.current=S;const E=y.useRef(null),C=e.map(I=>cf(I.id,I.waiting)).join("|");y.useEffect(()=>{ZW(E.current,r)&&(E.current=r,j.current=Ed(e))},[r]);const $=y.useRef(!1);y.useEffect(()=>{JW($.current,t)&&($.current=!0,j.current=Ed(e))},[t]),y.useEffect(()=>{if(typeof Notification>"u"||Notification.permission!=="granted"||!QW(E.current,t))return;const I=typeof document>"u"||!document.hidden,O=YW(e,j.current,I,c);for(const U of O)try{const P=new Notification(U.title,{body:U.body,tag:U.key,icon:jme});P.onclick=()=>{window.focus(),n(U.sessionId),P.close()}}catch{}j.current=I?Ed(e):XW(e,O,j.current)},[C,t]);const T=y.useCallback(I=>{var O;d(((O=I.prefs)==null?void 0:O.notifications)===!0),f(I.notificationsVetoed===!0),g(J$(I.prefs))},[]);return{notifyPermission:r,notifySaid:o,notifyOn:c,notifyVetoed:h,toggleNotify:b,notifySupported:N,askForNotifications:S,loadNotifyPrefs:T,accountNotify:p,toggleAccountNotify:w}}function Sme({openedTool:e,usageHistoryOpen:t,contextFor:n,tourOpen:r,summaryFor:s,browserWatchOpen:o,keyHelpOpen:i,releaseNotes:c,feedbackOpen:d,trafficRadarOpen:h=!1}){const f=Wn(i),p=y.useRef(!1);return p.current=e!=null||t||n!=null||r||s!=null||o||i||c!=null||d||h,{keyHelpOpenRef:f,modalOpenRef:p}}function _me({stateRef:e,tourOpen:t,releaseNotes:n}){const[r,s]=y.useState(null),o=y.useCallback((L,F)=>s({agentId:L,toolId:F}),[]),[i,c]=y.useState(null),[d,h]=y.useState(null),f=y.useCallback(L=>h(L),[]),[p,g]=y.useState(!1),[w,k]=y.useState(!1),[j,v]=y.useState(!1),[b,N]=y.useState(!1),[S,E]=y.useState(!1),[C,$]=y.useState(null),T=y.useCallback(L=>{$(L??null),E(!0)},[]);Jt("tool-detail",r!==null),Jt("session-summary",i!==null),Jt("context-window",d!==null),Jt("keyboard-help",p),Jt("usage-history",w),Jt("browser-watch",j),Jt("feedback",S);const I=r?lW(e.current.agents,r.agentId,r.toolId):null,O=d?e.current.agents.get(d):void 0,{keyHelpOpenRef:U,modalOpenRef:P}=Sme({openedTool:I,usageHistoryOpen:w,contextFor:d,tourOpen:t,summaryFor:i,browserWatchOpen:j,keyHelpOpen:p,releaseNotes:n,feedbackOpen:S,trafficRadarOpen:b});return{setOpenedToolKey:s,openTool:o,openedTool:I,summaryFor:i,setSummaryFor:c,contextFor:d,setContextFor:h,openContext:f,contextAgent:O,keyHelpOpen:p,setKeyHelpOpen:g,usageHistoryOpen:w,setUsageHistoryOpen:k,browserWatchOpen:j,setBrowserWatchOpen:v,trafficRadarOpen:b,setTrafficRadarOpen:N,feedbackOpen:S,setFeedbackOpen:E,feedbackPrefill:C,setFeedbackPrefill:$,openFeedback:T,keyHelpOpenRef:U,modalOpenRef:P}}function Eme({stateRef:e,pinnedRef:t,measuredRef:n,positionsRef:r,lastLayoutSigRef:s,forgetRemovals:o,clearSelection:i,rerender:c,modalOpenRef:d}){const[h,f]=y.useState(!1),p=y.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}e.current=Mk(),t.current.clear(),n.current.clear(),r.current.clear(),s.current="",X4(),o(),i(),c()},[c,i,o]),g=Wn(h),w=y.useCallback(k=>{const j=bue(k,{confirmOpen:g.current,modalOpen:d.current});j==="confirm"?f(!0):j==="clear"&&(f(!1),p())},[p]);return{clearConfirmOpen:h,setClearConfirmOpen:f,requestClear:w}}const Q$="agent-dag.oldNameNoticeDismissed";function Cme(e){const[t,n]=y.useState(()=>Ge(Q$)??""),r=e!=null&&e.invokedAs&&e.invokedAs!==Lt?e.invokedAs:null,s=r!=null&&t!==r,o=y.useCallback(()=>{r&&(n(r),Ve(Q$,r))},[r]);return{oldName:r,oldNameOpen:s,dismissOldName:o}}const Tme=300*1e3,Rme=1800*1e3,Ame=8e3,Mme=3e4;function eL(e){return fetch("/api/rating",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)}).catch(()=>null)}function $me({modalOpenRef:e}){const t=y.useCallback(()=>Zd({appModal:e.current,dialogDepth:jn.dialogDepth()}),[e]),[n,r]=y.useState("hidden"),[s,o]=y.useState(null),[i,c]=y.useState(!1),d=y.useRef(n);d.current=n,y.useEffect(()=>{let w=!1;const k=async()=>{if(d.current==="thanks"||d.current==="hidden"&&(document.hidden||t()))return;const b=await fetch("/api/rating").then(N=>N.ok?N.json():null).catch(()=>null);w||!b||r(N=>N==="thanks"?N:b.ask===!0?"asking":"hidden")},j=window.setTimeout(k,Tme),v=window.setInterval(k,Rme);return()=>{w=!0,window.clearTimeout(j),window.clearInterval(v)}},[t]),y.useEffect(()=>{if(n!=="thanks"||i)return;const w=s!==null&&s<=6?Mme:Ame;let k=0;const j=()=>{t()?k=window.setTimeout(j,w):r("hidden")};return k=window.setTimeout(j,w),()=>window.clearTimeout(k)},[n,s,i,t]);const h=y.useCallback(w=>{o(w),c(!1),r("thanks"),eL({score:w})},[]),f=y.useCallback(w=>c(w),[]),p=y.useCallback(()=>{r("hidden"),eL({later:!0})},[]),g=y.useCallback(()=>r("hidden"),[]);return{ratingPhase:n,ratingScore:s,answerRating:h,rateLater:p,closeRating:g,holdThanks:f}}function Lme({chimesRef:e,setTonePrefs:t,tonePrefsRef:n,previewTone:r}){const[s,o]=y.useState(()=>qne(Ge)),i=Wn(s),[c,d]=y.useState([]),h=y.useCallback(N=>{o(S=>{const E={...S,[N]:null};return i.current=E,E}),es(xc[N])},[]),f=y.useCallback((N,S)=>{const E=i.current[N];S&&E!==S||(h(N),t(C=>{const $={...C,[N]:{...C[N],figure:Un}};return n.current=$,$}),Ve(Fh[N],Un))},[h]),p=Wn(f);y.useEffect(()=>{let N=!0;return Jne().then(S=>{if(!N)return;d(S);const E=new Set(S.map(C=>C.id));for(const C of rh){const $=i.current[C];$&&!E.has($)&&p.current(C,$)}},()=>{}),()=>{N=!1}},[]);const g=y.useCallback((N,S)=>{if(!c.some(C=>C.id===S))return;const E={...i.current,[N]:S};i.current=E,o(E),Ve(xc[N],S),r(N,!0)},[c,r]),w=y.useCallback(async N=>{var $;const S=X0(c.length);if(S)throw new Error(S);const E=window.AudioContext??window.webkitAudioContext;if(!E)throw new Error("This browser cannot decode audio files.");const C=new E;try{const T=await Gne(N,O=>C.decodeAudioData(O));await RC(T);const I=Uc(T);d(O=>[...O.filter(U=>U.id!==I.id),I])}finally{($=C.close)==null||$.call(C)}},[c.length]),k=y.useCallback(async N=>{const S=X0(c.length);if(S)throw new Error(S);const E=Kne(N);await RC(E);const C=Uc(E);d($=>[...$.filter(T=>T.id!==C.id),C])},[c.length]),j=y.useCallback(async(N,S)=>{const E=c.find($=>$.id===N),C=S.trim().slice(0,80);!E||!C||C===E.name||(await ere(N,C),d($=>$.map(T=>T.id===N?{...T,name:C}:T)))},[c]),v=y.useCallback(async N=>{await tre(N),d($=>$.filter(T=>T.id!==N));const S=i.current,E=Une(S,N);i.current=E,o(E);const C=rh.filter($=>S[$]===N);for(const $ of C)es(xc[$]),Ve(Fh[$],Un);C.length>0&&t($=>{const T={...$};for(const I of C)T[I]={...T[I],figure:Un};return n.current=T,T})},[]),b=y.useCallback(N=>{var C,$;const S=rh.find(T=>i.current[T]===N),E=S?n.current[S].level:To;(C=e.current)==null||C.unlock(),($=e.current)==null||$.previewCustom(N,E)},[]);return{customSelections:s,customSelectionsRef:i,customAssets:c,clearCustomOnly:h,fallbackCustomRef:p,selectCustomTone:g,importNotificationAudio:w,createNotificationVoice:k,renameCustomAsset:j,deleteCustomAsset:v,previewCustomAsset:b}}function Ome(e){const[t,n]=y.useState(()=>fre(Ge)),r=Wn(t),s=y.useRef(null),o=y.useCallback((c,d=!1)=>{var h,f;if((h=e.current)==null||h.unlock(),s.current!==null&&clearTimeout(s.current),s.current=null,!d){(f=e.current)==null||f.play(c,!0);return}s.current=setTimeout(()=>{var p;s.current=null,(p=e.current)==null||p.play(c,!0)},lre)},[]),i=y.useCallback((c,d)=>{n(h=>{const f={level:Mf(d.level??h[c].level),figure:$P(c,d.figure??h[c].figure)};return Ve(IP[c],String(f.level)),Ve(Fh[c],f.figure),{...h,[c]:f}}),o(c,!0)},[o]);return y.useEffect(()=>()=>{s.current!==null&&clearTimeout(s.current)},[]),{tonePrefs:t,setTonePrefs:n,tonePrefsRef:r,previewTone:o,changeTone:i}}const Ime=15e3;function Pme(e){return e.visibilityState==="visible"&&e.hasFocus()}function Dme(e,t){return t||e===!0}function Fme(){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 Bme(){y.useEffect(()=>{const e=Fme();let t=null;const n=i=>{fetch("/api/presence",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tab:e,looking:i}),keepalive:!0}).catch(()=>{})},r=()=>{const i=Pme(document);Dme(t,i)&&n(i),t=i},s=()=>{t&&n(!1),t=!1};r();const o=window.setInterval(r,Ime);return window.addEventListener("focus",r),window.addEventListener("blur",r),document.addEventListener("visibilitychange",r),window.addEventListener("pagehide",s),()=>{window.clearInterval(o),window.removeEventListener("focus",r),window.removeEventListener("blur",r),document.removeEventListener("visibilitychange",r),window.removeEventListener("pagehide",s),s()}},[])}function qme({loadAutoRestartPrefs:e,loadNotifyPrefs:t,loadReportsPrefs:n}){y.useEffect(()=>{let r=!0;return fetch("/api/prefs").then(s=>s.ok?s.json():null).then(s=>{!r||!(s!=null&&s.ok)||(e(s),t(s),n(s))}).catch(()=>{}),()=>{r=!1}},[])}const Vb="agent-dag.versionNoticeDismissed",Ume=15*6e4;function Hme(e){const[t,n]=y.useState(null),[r,s]=y.useState(()=>Ge(Vb)??""),o=y.useRef(0),[i,c]=y.useState(!1),d=y.useCallback((j=!1)=>(j&&(o.current=Date.now(),c(!0)),fetch(j?"/api/version?refresh=1":"/api/version").then(v=>v.ok?v.json():null).then(v=>(v&&n(v),v??null)).catch(()=>null).finally(()=>{j&&c(!1)})),[]),h=y.useCallback(()=>{d(Date.now()-o.current>=Ume)},[d]);y.useEffect(()=>{d();const j=window.setInterval(h,5*6e4),v=()=>{document.visibilityState==="visible"&&h()};return document.addEventListener("visibilitychange",v),()=>{window.clearInterval(j),document.removeEventListener("visibilitychange",v)}},[d,h]),y.useEffect(()=>{e&&d()},[e,d]);const f=(t==null?void 0:t.notice)??null,p=hD(f),g=Dce(f,r),w=y.useCallback(()=>{s(""),Ve(Vb,"")},[]),k=y.useCallback(()=>{f&&(s(p),Ve(Vb,p))},[f,p]);return{version:t,notice:f,noticeOpen:g,showNotice:w,dismissNotice:k,versionChecking:i,loadVersion:d}}function Wme({version:e,readyAppUpdate:t}){const[n,r]=y.useState(!1),s=y.useRef(null),[o,i]=y.useState(null),c=o&&t?t.version:null,d=y.useRef(null);y.useEffect(()=>{!c||d.current===c||(d.current=c,fetch("/api/desktop-update/seen",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({version:c})}).catch(()=>{}))},[c]);const h=y.useRef(!1);y.useEffect(()=>{if(h.current)return;const v=Li(),b=The(v),N=Ohe({stored:b,running:(e==null?void 0:e.running)??null,notes:R$,remembers:Rhe(v)});if(N.reason==="no-version")return;h.current=!0,N.record&&Ahe(v,N.record);let S=!0;return(async()=>{var I;let C=Mhe(v);if(Ro())try{const O=await fetch("/api/prefs");if(!O.ok)throw new Error("desktop tour preferences unavailable");const U=await O.json();if(!(U!=null&&U.ok))throw new Error("desktop tour preferences unavailable");const P=((I=U.prefs)==null?void 0:I.tourSeen)===!0;C&&!P&&fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tourSeen:!0}),keepalive:!0}).catch(()=>{}),C=C||P}catch{C=!0}if(!S)return;const $=Lhe({tourSeen:C,decision:N}),T=N.show.length?{entries:N.show,since:b,firstRun:!1}:null;$.tour&&r(!0),$.notes==="now"?i(T):$.notes==="after"&&(s.current=T)})(),()=>{S=!1}},[e==null?void 0:e.running]);const f=(e==null?void 0:e.running)??"3.42.0",p=y.useMemo(()=>AD(R$,null,f),[f]),g=y.useCallback(()=>{i({entries:p,since:null,firstRun:!1})},[p]),w=y.useCallback(()=>r(!0),[]),k=y.useCallback(()=>i(null),[]),j=y.useCallback(()=>{r(!1),$he(Li()),Ro()&&fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tourSeen:!0}),keepalive:!0}).catch(()=>{});const v=s.current;s.current=null,v&&i(v)},[]);return{tourOpen:n,openTour:w,closeTour:j,releaseNotes:o,closeReleaseNotes:k,chipVersion:f,openReleaseNotes:g}}function zme(){const[e,t]=y.useState(void 0),[n,r]=y.useState(!1),s=y.useRef(!1);return s.current=e===!0&&!n,y.useEffect(()=>lpe(()=>s.current),[]),{loadReportsPrefs:y.useCallback(i=>{var c;t(((c=i.prefs)==null?void 0:c.reports)!==!1),r(i.reportsVetoed===!0)},[])}}function Vme(e){const[t,n]=y.useState(null);y.useEffect(()=>{const c=Ge("agent-dag.sound");n(c===null?!0:c==="on")},[]);const r=y.useCallback(()=>{n(c=>{var h,f;const d=c!==!0;return Ve("agent-dag.sound",d?"on":"off"),d?(h=e.current)==null||h.unlock():(f=e.current)==null||f.silence(),d})},[]),s=y.useCallback(c=>{r()},[r]),o=Wn(s),i=Wn(t);return{soundOn:t,toggleSound:r,activateSoundRef:o,soundOnRef:i}}function Gme(){const[e,t]=y.useState($le),n=y.useCallback(o=>{t(i=>Lle(i,o))},[]),r=y.useCallback(()=>t(o=>({...o,open:!1})),[]),s=y.useCallback(o=>t(i=>({...i,section:o})),[]);return{settingsOpen:e.open,settingsSection:e.section,openSettings:n,closeSettings:r,showSection:s}}const Kme="agent-dag.autoFitDisabled";function Yme(e){const t=y.useRef(!1),[n,r]=y.useState(!1);y.useEffect(()=>{es(Kme)},[]);const s=y.useCallback(()=>{t.current||(t.current=!0,r(!0))},[]),o=y.useCallback(()=>{t.current=!1,r(!1),e(400)},[e]);return{autoFitDisabled:n,autoFitDisabledRef:t,disableAutoFit:s,enableAutoFitAndRefit:o}}function Xme(){return a.jsx(Ak,{children:a.jsx(dpe,{children:a.jsx(Zme,{})})})}function Zme(){const e=Qi(),t=y.useState(Mk)[0],n=y.useRef(t),[,r]=y.useState(0),s=y.useCallback(()=>r(Ln=>Ln+1),[]),{detailOpen:o,setDetailOpen:i,usagePanelOpen:c,setUsagePanelOpen:d,machinePanelOpen:h,setMachinePanelOpen:f}=wme(),{selectedIds:p,primarySelectedId:g,selectAgent:w,clearSelection:k,pruneSelectionToBoard:j}=Are(n,i),{sessionListOpen:v,accountsPanelOpen:b,panel:N,toggleSessionList:S,toggleAccountsPanel:E,closeSessionList:C,closeSessionListToCanvas:$,closeAccountsPanel:T}=dme(),I=Ei(b,200),O=Ei(v,200),U=o_(v,O),P=Ei(c,130),L=Ei(h,130),F=y.useRef(null),A=Vme(F),{activateSoundRef:B,soundOnRef:D}=A,K=Ome(F),{setTonePrefs:G,tonePrefsRef:H,previewTone:q}=K,M=Lme({chimesRef:F,setTonePrefs:G,tonePrefsRef:H,previewTone:q}),{customSelectionsRef:V,fallbackCustomRef:Z}=M,W=Gme(),{openSettings:X}=W;Ype({chimesRef:F,soundOnRef:D,tonePrefsRef:H,customSelectionsRef:V,fallbackCustomRef:Z});const Y=ppe(n),{pauseGate:J,paused:ee,togglePause:ne}=Y,se=y.useRef(()=>{}),{live:ce,tabCapped:de,everConnected:ae,liveSince:pe}=bre({stateRef:n,rerender:s,pauseGate:J,chimesRef:F,desktopUpdateRef:se}),fe=Hme(ce),{version:Ee,notice:ye,noticeOpen:oe,loadVersion:we}=fe,Ne=Zpe(ce),{readyAppUpdate:ge,onDesktopUpdateEvent:Ae}=Ne;se.current=Ae,Bme();const Oe=Wme({version:Ee,readyAppUpdate:ge}),{tourOpen:qe,openTour:Me,releaseNotes:He}=Oe,{workspace:rt,providers:Ue,providersRef:it}=gpe(ce),Et=sme(N==="accounts"&&!Ue.claude?null:N),st=ime(Et),ht=o_(b,I)&&Ue.claude,ft=Cme(Ee),Be=Lpe({version:Ee,loadVersion:we}),{upgradeFailure:Kt}=Be,at=_me({stateRef:n,tourOpen:qe,releaseNotes:He}),At=$me({modalOpenRef:at.modalOpenRef}),{openTool:et,setSummaryFor:pt,setContextFor:jt,openContext:wt,setKeyHelpOpen:tt,setUsageHistoryOpen:Ct,setBrowserWatchOpen:Tn,keyHelpOpenRef:Mt,modalOpenRef:an}=at,fn=zme(),pn=Ipe(),{watchOn:Rn,watchUnseen:Yt}=pn,An=Qpe(),[je,$e]=y.useState(0),{presentCats:De,hiddenCats:lt,toggleCat:Wt,catBarRef:is,catBarOccluded:Ma}=Gpe(n),ls=y.useRef(null),[Ds,mn]=y.useState(0),It=Mre({stateRef:n,rerender:s,pruneSelectionToBoard:j,setContextFor:jt,setSummaryFor:pt}),Fs=vpe(Ue.claude||Ue.codex),$r=Ape(Fs,It),Lr=tme({enabled:Ue.claude,lanStatus:An.lanStatus,now:It}),ur=Jpe({now:It,stateRef:n,version:Ee,notice:ye,noticeOpen:oe,upgradeFailure:Kt,paused:Y.paused}),{askRestart:Bs,loadAutoRestartPrefs:cs}=ur,dr=Vpe(),{setTheme:qs,palette:me}=dr,Xe=Xpe(),Ze=Lie(),{applyViewport:Mn,moveCamera:Or,fitLeft:$n,cameraEpochRef:Us,lastFitTimeRef:hr}=Ze,Nt=Kie(Ze),{pinnedRef:Ir,positionsRef:en,lastLayoutSigRef:Qf,handleRelayout:ep,rearrangeUndo:tp}=Nt,$a=y.useRef(null),La=y.useRef(()=>{}),Oa=pe!==null,Ia=y.useRef(0),uu=y.useCallback(()=>{Ia.current=Date.now()},[]),{canvasRef:Pr,canvasSize:cl,paneSizeRef:du}=Ele(st),Po=Yme($n),{autoFitDisabledRef:Hs,disableAutoFit:ul}=Po,Pa=y.useRef(!1),{measuredRef:Ke,measuredVersionRef:hu,sizeVersion:fu,domSizeVersion:dl}=Cle(Pa),{removedNodes:hl,removedAgentIds:us,removeNode:pu,removeSelectedNode:Do,removalNotice:Da,bringBack:Gn,bringBackAll:Dr,forgetRemovals:Fr}=mle({stateRef:n,pinnedRef:Ir,positionsRef:en,canvasRef:Pr,clearSelection:k,primarySelectedId:g}),ds=ule({stateRef:n,now:It,removedAgentIds:us,sizeVersion:fu,domSizeVersion:dl});Yie(ds,Nt),ple({layoutSig:ds,rf:e,stateRef:n,measuredRef:Ke,pinnedRef:Ir,positionsRef:en,paneSizeRef:du,lastInteractRef:Ia,autoFitDisabledRef:Hs,lastFitTimeRef:hr,fitLeft:$n});const Ws=Tle(),{bubbling:Br,endBubble:np,onBubble:mu}=Ene(),[hs,rp]=y.useState(!1),fl=Sne(),{beginTrashDrag:Fo,trackTrashDrag:gu,endTrashDrag:sp}=fl,zs=Lne({stateRef:n,measuredRef:Ke,measuredVersionRef:hu,canvasRef:Pr}),{lodRef:Fa,applyZoom:Vs}=zs,Ba=Nle({applyViewport:Mn,lastFitTimeRef:hr,cameraEpochRef:Us,disableAutoFit:ul,markInteract:uu,canvasRef:Pr,applyZoom:Vs}),qa=g?n.current.agents.get(g):null,pl=o&&qa!=null,qr=qle({sessionListShown:U,usageShown:xa(P),machineShown:xa(L),accountsShown:ht,detailShown:pl,primarySelectedId:g,canvasRef:Pr}),{railInsetRef:fs,availableWidth:Bo,availableHeight:ml}=Tie({canvasRef:Pr,canvasSize:cl,machinePhase:L,usagePhase:P,usagePanelOpen:c,detailShown:pl}),fr=dle({stateRef:n,now:It,availableWidth:Bo,availableHeight:ml,layout:Nt,measuredRef:Ke,onBubble:mu,settled:Ws,dragging:hs,layoutSig:ds,selectedIds:p,openContext:wt,historyReplayed:Oa,removedNodes:hl,removedAgentIds:us,dragTick:je,dragPatchRef:ls,dragMoveTick:Ds}),{nodes:Ua,edges:qo}=fr,Uo=Wn(g);Xie({nodes:Ua,edges:qo,settled:Ws,dragging:hs,availableWidth:Bo,availableHeight:ml,layout:Nt,camera:Ze,rf:e,measuredRef:Ke,stateRef:n,lastFocusRef:$a,primarySelectedIdRef:Uo,focusAgentRef:La,autoFitDisabledRef:Hs});const Ha=Eme({stateRef:n,pinnedRef:Ir,measuredRef:Ke,positionsRef:en,lastLayoutSigRef:Qf,forgetRemovals:Fr,clearSelection:k,rerender:s,modalOpenRef:an}),{requestClear:Wa}=Ha,yu=Ule({nodes:Ua,stateRef:n,pinnedRef:Ir,positionsRef:en,draggingRef:Pa,dragPatchRef:ls,setDragging:rp,setDragMoveTick:mn,setDragTick:$e,endBubble:np,markInteract:uu,disableAutoFit:ul,beginTrashDrag:Fo,trackTrashDrag:gu,endTrashDrag:sp,removeNode:pu}),on=y.useCallback(()=>$n(500),[$n]),Ur=Wn(Ua),{focusAgent:Gs,stepAgent:za,focusSession:Ks}=Iie({canvasRef:Pr,stateRef:n,measuredRef:Ke,nodesRef:Ur,railInsetRef:fs,moveCamera:Or,disableAutoFit:ul,lastFocusRef:$a,focusAgentRef:La,selectAgent:w,primarySelectedIdRef:Uo}),gl=Sle({clearSelection:k,selectAgent:w,detailOpen:o,setDetailOpen:i,detailShown:pl,focusAgent:Gs,draggingRef:Pa,lodRef:Fa}),yl=Pie({nodesRef:Ur,stateRef:n,canvasRef:Pr,railInsetRef:fs}),Va=Wn(Do),Ys=y.useRef(null),wl=y.useCallback(Ln=>{us.has(Ln)&&Gn([Ln]),Ks(Ln)},[us,Gn,Ks]),ap=Rle();Fle({pointerFocusRef:ap,nodesRef:Ur,stateRef:n,primarySelectedIdRef:Uo,providersRef:it,soundOnRef:D,keyHelpOpenRef:Mt,modalOpenRef:an,waitingCursorRef:Ys,removeSelectedRef:Va,activateSoundRef:B,clearSelection:k,selectAgent:w,focusAgent:Gs,stepAgent:za,focusSession:Ks,requestClear:Wa,handleRelayout:ep,undoRearrange:tp.undo,handleFit:on,togglePause:ne,toggleSessionList:S,toggleAccountsPanel:E,setDetailOpen:i,setUsageHistoryOpen:Ct,setUsagePanelOpen:d,setMachinePanelOpen:f,setBrowserWatchOpen:Tn,setKeyHelpOpen:tt,setTheme:qs,openSettings:X});const wu=n.current.agents.size,Xs=y.useMemo(()=>d0(n.current.agents.values()),[n.current,n.current.revision]);gle({stateRef:n,waitingSessions:Xs,removedAgentIds:us,removedNodes:hl,bringBack:Gn}),ble({stateRef:n,waitingSessions:Xs,live:ce});const Ho=kme({waitingSessions:Xs,watchUnseen:Yt,incidents:$r}),xl=Nme({waitingSessions:Xs,liveSince:pe,focusSession:Ks}),{loadNotifyPrefs:op}=xl;qme({loadAutoRestartPrefs:cs,loadNotifyPrefs:op,loadReportsPrefs:fn.loadReportsPrefs});const ps=Xk(vce),[xu,vu]=y.useState(!1),[bu,ku]=y.useState(!1),ip=y.useCallback(()=>ku(!1),[]),lp=y.useCallback(()=>vu(!1),[]),Hr=kce({providers:Ue,sessionListOpen:v,toggleSessionList:S,accountsPanelOpen:b,toggleAccountsPanel:E,usagePanelOpen:c,setUsagePanelOpen:d,machinePanelOpen:h,setMachinePanelOpen:f,setUsageHistoryOpen:Ct,watchOn:Rn,watchUnseen:Yt,setBrowserWatchOpen:Tn,setTrafficRadarOpen:at.setTrafficRadarOpen,openSettings:X,onFeedback:at.openFeedback,radioOpen:xu,setRadioOpen:vu,openToolActivity:()=>ku(!0),toggles:qr.toggles}),[vl,cp]=y.useState(0),up=y.useCallback(Ln=>{wl(Ln),ps&&$()},[wl,ps,$]),dp=y.useCallback(()=>{v||S(),requestAnimationFrame(()=>{var Ln;return(Ln=document.querySelector("#session-list .sl-row"))==null?void 0:Ln.focus()})},[v,S]);return a.jsxs("div",{className:"app",children:[a.jsx("a",{className:"skip-link",href:"#canvas",children:"Skip to the canvas"}),a.jsxs("header",{className:"topbar",children:[a.jsx(DG,{}),a.jsx(Yce,{versionCheck:fe,welcome:Oe,desktopUpdate:Ne,pause:Y,announcements:Ho,notify:xl,waitingSessions:Xs,waitingCursorRef:Ys,focusSession:Ks,live:ce,now:It,incidents:$r,queueNamed:ps?0:vl}),!ps&&a.jsx(Vce,{waitingSessions:Xs,waitingCursorRef:Ys,focusSession:Ks,now:It,onFit:cp,onMore:dp}),qa&&a.jsx(Xce,{selected:qa,now:It,selectedIds:p,focusAgent:Gs,clearSelection:k}),!ps&&a.jsx("div",{className:"actions",children:a.jsx(wce,{items:Hr.utilities})})]}),ps?a.jsx(yce,{items:[...Hr.left,...Hr.right[0],Hr.utilities[0]],more:[...Hr.right.slice(1).flat(),Hr.utilities[1]]}):a.jsx(f$,{side:"left",label:"Left column",groups:[Hr.left]}),a.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:Da?`${Da.label} removed from the board.`:""}),a.jsx(vue,{restart:ur,versionCheck:fe,upgrade:Be,oldNameNotice:ft,rating:At,onFeedback:at.openFeedback,everConnected:ae,live:ce,paused:ee}),(U||ht)&&a.jsxs(wne,{width:Et,children:[ht&&a.jsx(yne,{leaving:i_(b,I),onReport:at.openFeedback,onRoster:Lr.observe,onClose:()=>{qr.accounts(),T()}}),U&&a.jsx(JG,{leaving:i_(v,O),state:n.current,now:It,selectedIds:p,onSelect:up,onClose:()=>{qr.sessionList(),C()},removedIds:us,onBringBackAll:Dr})]}),a.jsxs(tue,{canvasRef:Pr,bubbling:Br,dragging:hs,trash:fl,zoom:zs,viewport:Ba,stateRef:n,peek:yl,children:[wu===0&&(!ce&&de?a.jsx(Wle,{reservedRight:fs.current}):a.jsx(zle,{live:ce,everConnected:ae,providers:Ue,workspace:rt,onTour:Me,reservedRight:fs.current})),(De.length>1||lt.size>0)&&a.jsx(Zce,{catBarRef:is,catBarOccluded:Ma,presentCats:De,hiddenCats:lt,toggleCat:Wt}),a.jsx(PG,{graph:fr,layout:Nt,viewport:Ba,clicks:gl,drag:yu,appearance:dr,fm:Xe,radioOpen:xu,onRadioClose:lp,autoFit:Po,pause:Y,stateRef:n,measuredRef:Ke,hiddenCats:lt,now:It,openTool:et,focusAgent:Gs,requestClear:Wa,setKeyHelpOpen:tt})]}),!ps&&a.jsx(f$,{side:"right",label:"Right panels",groups:Hr.right}),bu&&a.jsx(RK,{onClose:ip}),xa(P)&&a.jsx(PY,{state:n.current,now:It,providers:Ue,incidents:$r,liveSince:pe,leaving:P==="leaving",onClose:()=>{qr.usage(),d(!1)}}),xa(L)&&a.jsx(kX,{usageOpen:c,leaving:L==="leaving",onClose:()=>{qr.machine(),f(!1)}}),o&&qa?a.jsx(sce,{selected:qa,now:It,openTool:et,setSummaryFor:pt,stateRef:n,removeSelectedNode:Do,onClose:()=>{qr.detail(),i(!1)}}):null,a.jsx(Gfe,{dialogs:at,welcome:Oe,desktopUpdate:Ne,versionCheck:fe,restart:ur,upgrade:Be,lanPairs:An,attention:Lr,clearFlow:Ha,watchBadge:pn,announcements:Ho,appearance:dr,providers:Ue,stateRef:n,agentCount:wu,menus:W,sound:A,tones:K,customTones:M,notify:xl})]})}try{$z(window.localStorage)}catch{}const Jme=x6.createRoot(document.getElementById("root"));window.ccdeckWindow&&(document.documentElement.dataset.desktopChrome="true",document.documentElement.dataset.desktopPlatform=window.ccdeckWindow.platform);Jme.render(a.jsx(Xme,{}));export{Xi as A,Sa as B,m1 as C,AV as D,Nf as E,dge as F,zk as G,Ki as H,h9 as I,rge as J,tge as K,nge as L,pf as M,pz as N,Ppe as O,ege as P,MV as Q,l3 as R,_fe as V,h3 as a,ut as b,rs as c,dt as d,Ts as e,Ye as f,sge as g,ts as h,age as i,a as j,Bc as k,Vn as l,zne as m,oge as n,Dhe as o,T0 as p,ige as q,y as r,qn as s,lge as t,ot as u,cge as v,Mo as w,Phe as x,uge as y,bf as z};
|