ccdeck 3.43.4 → 3.44.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 +69 -17
- package/THIRD_PARTY_NOTICES.md +43 -7
- package/bin/cli/commands.js +613 -0
- package/bin/cli/help.js +26 -3
- package/bin/cli/one-shot.js +2 -2
- package/bin/cli/picker.js +86 -0
- package/bin/cli/startup.js +13 -0
- package/bin/deck.js +16 -1
- package/dist/web/assets/{BrowserWatchModal-nOxhGOO4.js → BrowserWatchModal-DMIUygWz.js} +1 -1
- package/dist/web/assets/{RadioPanel-BLfpQ1Iw.js → RadioPanel-DNB_AHSs.js} +1 -1
- package/dist/web/assets/TrafficRadar-Ch0LVdSl.js +8 -0
- package/dist/web/assets/UsageHistoryModal-Du0ZkIJ1.js +1 -0
- package/dist/web/assets/app-CQIstkMF.js +318 -0
- package/dist/web/assets/app-Ch-0CYlK.css +1 -0
- package/dist/web/assets/{index-Ch4ks76J.js → index-BQbOfxbL.js} +1 -1
- package/dist/web/index.html +3 -3
- package/package.json +2 -1
- package/release-notes.json +34 -0
- package/src/server/account-notify.mjs +206 -9
- package/src/server/account-pick.mjs +160 -0
- package/src/server/account-projects.mjs +55 -15
- package/src/server/account-routes.mjs +47 -4
- package/src/server/account-watch.mjs +48 -4
- package/src/server/activity.mjs +3 -2
- package/src/server/args.mjs +112 -2
- package/src/server/autoswitch-failover.mjs +138 -0
- package/src/server/claude-accounts.mjs +115 -14
- package/src/server/claude-dir.mjs +142 -5
- package/src/server/claude-identity.mjs +23 -0
- package/src/server/cli-lines.mjs +224 -0
- package/src/server/codex-cost-usage.mjs +67 -0
- package/src/server/codex-enrichment.mjs +53 -9
- package/src/server/codex-review-policy.d.mts +4 -0
- package/src/server/codex-review-policy.mjs +11 -0
- package/src/server/codex-skills.mjs +146 -0
- package/src/server/codex-watch.mjs +5 -2
- package/src/server/cswap-auto-choice.mjs +53 -0
- package/src/server/cswap-auto-loop.mjs +100 -9
- package/src/server/deck-client.mjs +112 -0
- package/src/server/deck-prefs.mjs +16 -5
- package/src/server/event-pipeline.mjs +19 -3
- package/src/server/event-routes.mjs +15 -0
- package/src/server/exec.mjs +6 -2
- package/src/server/index.mjs +17 -1
- package/src/server/installer.mjs +149 -8
- package/src/server/lan-engine.mjs +2 -2
- package/src/server/lan-sync.mjs +3 -3
- package/src/server/lan-wire.mjs +3 -3
- package/src/server/login-guard.mjs +162 -0
- package/src/server/login-service.mjs +3 -0
- package/src/server/pinned-build.mjs +5 -0
- package/src/server/prefs-routes.mjs +4 -0
- package/src/server/request-gates.mjs +7 -0
- package/src/server/session-read-gate.mjs +5 -3
- package/src/server/session-summary.mjs +281 -0
- package/src/server/skill-hook.mjs +162 -0
- package/src/server/stop-continue-gate.d.mts +8 -0
- package/src/server/stop-continue-gate.mjs +77 -0
- package/src/server/stop-continue.mjs +544 -0
- package/src/server/stop-failure.d.mts +10 -0
- package/src/server/stop-failure.mjs +97 -0
- package/src/server/swap-log.mjs +19 -10
- package/src/server/tool-audit-report.mjs +5 -3
- package/src/server/tool-audit-routes.mjs +5 -3
- package/src/server/tool-audit-skills.mjs +82 -0
- package/src/server/tool-audit.mjs +53 -11
- package/src/server/traffic-radar-capture.mjs +10 -1
- package/src/server/traffic-radar-monitor.mjs +4 -2
- package/src/server/traffic-radar-routes.mjs +13 -0
- package/src/server/traffic-radar-service.mjs +133 -0
- package/src/server/usage-day.mjs +1 -1
- package/dist/web/assets/TrafficRadar-BFrObpjW.js +0 -1
- package/dist/web/assets/UsageHistoryModal-DCnFf1vi.js +0 -1
- package/dist/web/assets/app-BiJ8TfUl.css +0 -1
- package/dist/web/assets/app-DBsNB-2y.js +0 -312
|
@@ -0,0 +1,318 @@
|
|
|
1
|
+
var u8=Object.defineProperty;var d8=(e,t,n)=>t in e?u8(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Sg=(e,t,n)=>d8(e,typeof t!="symbol"?t+"":t,n);var Jd=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function y1(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var _g={exports:{}},kc={},Cg={exports:{}},Je={};/**
|
|
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 k_;function h8(){if(k_)return Je;k_=1;var e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),a=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 m(D){return D===null||typeof D!="object"?null:(D=p&&D[p]||D["@@iterator"],typeof D=="function"?D:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},j=Object.assign,v={};function b(D,H,ee){this.props=D,this.context=H,this.refs=v,this.updater=ee||w}b.prototype.isReactComponent={},b.prototype.setState=function(D,H){if(typeof D!="object"&&typeof D!="function"&&D!=null)throw Error("setState(...): takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,D,H,"setState")},b.prototype.forceUpdate=function(D){this.updater.enqueueForceUpdate(this,D,"forceUpdate")};function k(){}k.prototype=b.prototype;function N(D,H,ee){this.props=D,this.context=H,this.refs=v,this.updater=ee||w}var S=N.prototype=new k;S.constructor=N,j(S,b.prototype),S.isPureReactComponent=!0;var _=Array.isArray,E=Object.prototype.hasOwnProperty,I={current:null},A={key:!0,ref:!0,__self:!0,__source:!0};function O(D,H,ee){var F,Y={},X=null,Z=null;if(H!=null)for(F in H.ref!==void 0&&(Z=H.ref),H.key!==void 0&&(X=""+H.key),H)E.call(H,F)&&!A.hasOwnProperty(F)&&(Y[F]=H[F]);var J=arguments.length-2;if(J===1)Y.children=ee;else if(1<J){for(var ne=Array(J),ce=0;ce<J;ce++)ne[ce]=arguments[ce+2];Y.children=ne}if(D&&D.defaultProps)for(F in J=D.defaultProps,J)Y[F]===void 0&&(Y[F]=J[F]);return{$$typeof:e,type:D,key:X,ref:Z,props:Y,_owner:I.current}}function L(D,H){return{$$typeof:e,type:D.type,key:H,ref:D.ref,props:D.props,_owner:D._owner}}function U(D){return typeof D=="object"&&D!==null&&D.$$typeof===e}function P(D){var H={"=":"=0",":":"=2"};return"$"+D.replace(/[=:]/g,function(ee){return H[ee]})}var T=/\/+/g;function B(D,H){return typeof D=="object"&&D!==null&&D.key!=null?P(""+D.key):H.toString(36)}function M(D,H,ee,F,Y){var X=typeof D;(X==="undefined"||X==="boolean")&&(D=null);var Z=!1;if(D===null)Z=!0;else switch(X){case"string":case"number":Z=!0;break;case"object":switch(D.$$typeof){case e:case t:Z=!0}}if(Z)return Z=D,Y=Y(Z),D=F===""?"."+B(Z,0):F,_(Y)?(ee="",D!=null&&(ee=D.replace(T,"$&/")+"/"),M(Y,H,ee,"",function(ce){return ce})):Y!=null&&(U(Y)&&(Y=L(Y,ee+(!Y.key||Z&&Z.key===Y.key?"":(""+Y.key).replace(T,"$&/")+"/")+D)),H.push(Y)),1;if(Z=0,F=F===""?".":F+":",_(D))for(var J=0;J<D.length;J++){X=D[J];var ne=F+B(X,J);Z+=M(X,H,ee,ne,Y)}else if(ne=m(D),typeof ne=="function")for(D=ne.call(D),J=0;!(X=D.next()).done;)X=X.value,ne=F+B(X,J++),Z+=M(X,H,ee,ne,Y);else if(X==="object")throw H=String(D),Error("Objects are not valid as a React child (found: "+(H==="[object Object]"?"object with keys {"+Object.keys(D).join(", ")+"}":H)+"). If you meant to render a collection of children, use an array instead.");return Z}function q(D,H,ee){if(D==null)return D;var F=[],Y=0;return M(D,F,"","",function(X){return H.call(ee,X,Y++)}),F}function $(D){if(D._status===-1){var H=D._result;H=H(),H.then(function(ee){(D._status===0||D._status===-1)&&(D._status=1,D._result=ee)},function(ee){(D._status===0||D._status===-1)&&(D._status=2,D._result=ee)}),D._status===-1&&(D._status=0,D._result=H)}if(D._status===1)return D._result.default;throw D._result}var K={current:null},G={transition:null},z={ReactCurrentDispatcher:K,ReactCurrentBatchConfig:G,ReactCurrentOwner:I};function W(){throw Error("act(...) is not supported in production builds of React.")}return Je.Children={map:q,forEach:function(D,H,ee){q(D,function(){H.apply(this,arguments)},ee)},count:function(D){var H=0;return q(D,function(){H++}),H},toArray:function(D){return q(D,function(H){return H})||[]},only:function(D){if(!U(D))throw Error("React.Children.only expected to receive a single React element child.");return D}},Je.Component=b,Je.Fragment=n,Je.Profiler=a,Je.PureComponent=N,Je.StrictMode=s,Je.Suspense=d,Je.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=z,Je.act=W,Je.cloneElement=function(D,H,ee){if(D==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+D+".");var F=j({},D.props),Y=D.key,X=D.ref,Z=D._owner;if(H!=null){if(H.ref!==void 0&&(X=H.ref,Z=I.current),H.key!==void 0&&(Y=""+H.key),D.type&&D.type.defaultProps)var J=D.type.defaultProps;for(ne in H)E.call(H,ne)&&!A.hasOwnProperty(ne)&&(F[ne]=H[ne]===void 0&&J!==void 0?J[ne]:H[ne])}var ne=arguments.length-2;if(ne===1)F.children=ee;else if(1<ne){J=Array(ne);for(var ce=0;ce<ne;ce++)J[ce]=arguments[ce+2];F.children=J}return{$$typeof:e,type:D.type,key:Y,ref:X,props:F,_owner:Z}},Je.createContext=function(D){return D={$$typeof:i,_currentValue:D,_currentValue2:D,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},D.Provider={$$typeof:o,_context:D},D.Consumer=D},Je.createElement=O,Je.createFactory=function(D){var H=O.bind(null,D);return H.type=D,H},Je.createRef=function(){return{current:null}},Je.forwardRef=function(D){return{$$typeof:c,render:D}},Je.isValidElement=U,Je.lazy=function(D){return{$$typeof:f,_payload:{_status:-1,_result:D},_init:$}},Je.memo=function(D,H){return{$$typeof:h,type:D,compare:H===void 0?null:H}},Je.startTransition=function(D){var H=G.transition;G.transition={};try{D()}finally{G.transition=H}},Je.unstable_act=W,Je.useCallback=function(D,H){return K.current.useCallback(D,H)},Je.useContext=function(D){return K.current.useContext(D)},Je.useDebugValue=function(){},Je.useDeferredValue=function(D){return K.current.useDeferredValue(D)},Je.useEffect=function(D,H){return K.current.useEffect(D,H)},Je.useId=function(){return K.current.useId()},Je.useImperativeHandle=function(D,H,ee){return K.current.useImperativeHandle(D,H,ee)},Je.useInsertionEffect=function(D,H){return K.current.useInsertionEffect(D,H)},Je.useLayoutEffect=function(D,H){return K.current.useLayoutEffect(D,H)},Je.useMemo=function(D,H){return K.current.useMemo(D,H)},Je.useReducer=function(D,H,ee){return K.current.useReducer(D,H,ee)},Je.useRef=function(D){return K.current.useRef(D)},Je.useState=function(D){return K.current.useState(D)},Je.useSyncExternalStore=function(D,H,ee){return K.current.useSyncExternalStore(D,H,ee)},Je.useTransition=function(){return K.current.useTransition()},Je.version="18.3.1",Je}var j_;function Tu(){return j_||(j_=1,Cg.exports=h8()),Cg.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 N_;function f8(){if(N_)return kc;N_=1;var e=Tu(),t=Symbol.for("react.element"),n=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,a=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={},m=null,w=null;h!==void 0&&(m=""+h),d.key!==void 0&&(m=""+d.key),d.ref!==void 0&&(w=d.ref);for(f in d)s.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:m,ref:w,props:p,_owner:a.current}}return kc.Fragment=n,kc.jsx=i,kc.jsxs=i,kc}var S_;function p8(){return S_||(S_=1,_g.exports=f8()),_g.exports}var r=p8(),Qd={},Eg={exports:{}},En={},Tg={exports:{}},Rg={};/**
|
|
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 __;function m8(){return __||(__=1,(function(e){function t(G,z){var W=G.length;G.push(z);e:for(;0<W;){var D=W-1>>>1,H=G[D];if(0<a(H,z))G[D]=z,G[W]=H,W=D;else break e}}function n(G){return G.length===0?null:G[0]}function s(G){if(G.length===0)return null;var z=G[0],W=G.pop();if(W!==z){G[0]=W;e:for(var D=0,H=G.length,ee=H>>>1;D<ee;){var F=2*(D+1)-1,Y=G[F],X=F+1,Z=G[X];if(0>a(Y,W))X<H&&0>a(Z,Y)?(G[D]=Z,G[X]=W,D=X):(G[D]=Y,G[F]=W,D=F);else if(X<H&&0>a(Z,W))G[D]=Z,G[X]=W,D=X;else break e}}return z}function a(G,z){var W=G.sortIndex-z.sortIndex;return W!==0?W:G.id-z.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,m=3,w=!1,j=!1,v=!1,b=typeof setTimeout=="function"?setTimeout:null,k=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 z=n(h);z!==null;){if(z.callback===null)s(h);else if(z.startTime<=G)s(h),z.sortIndex=z.expirationTime,t(d,z);else break;z=n(h)}}function _(G){if(v=!1,S(G),!j)if(n(d)!==null)j=!0,$(E);else{var z=n(h);z!==null&&K(_,z.startTime-G)}}function E(G,z){j=!1,v&&(v=!1,k(O),O=-1),w=!0;var W=m;try{for(S(z),p=n(d);p!==null&&(!(p.expirationTime>z)||G&&!P());){var D=p.callback;if(typeof D=="function"){p.callback=null,m=p.priorityLevel;var H=D(p.expirationTime<=z);z=e.unstable_now(),typeof H=="function"?p.callback=H:p===n(d)&&s(d),S(z)}else s(d);p=n(d)}if(p!==null)var ee=!0;else{var F=n(h);F!==null&&K(_,F.startTime-z),ee=!1}return ee}finally{p=null,m=W,w=!1}}var I=!1,A=null,O=-1,L=5,U=-1;function P(){return!(e.unstable_now()-U<L)}function T(){if(A!==null){var G=e.unstable_now();U=G;var z=!0;try{z=A(!0,G)}finally{z?B():(I=!1,A=null)}}else I=!1}var B;if(typeof N=="function")B=function(){N(T)};else if(typeof MessageChannel<"u"){var M=new MessageChannel,q=M.port2;M.port1.onmessage=T,B=function(){q.postMessage(null)}}else B=function(){b(T,0)};function $(G){A=G,I||(I=!0,B())}function K(G,z){O=b(function(){G(e.unstable_now())},z)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(G){G.callback=null},e.unstable_continueExecution=function(){j||w||(j=!0,$(E))},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"):L=0<G?Math.floor(1e3/G):5},e.unstable_getCurrentPriorityLevel=function(){return m},e.unstable_getFirstCallbackNode=function(){return n(d)},e.unstable_next=function(G){switch(m){case 1:case 2:case 3:var z=3;break;default:z=m}var W=m;m=z;try{return G()}finally{m=W}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(G,z){switch(G){case 1:case 2:case 3:case 4:case 5:break;default:G=3}var W=m;m=G;try{return z()}finally{m=W}},e.unstable_scheduleCallback=function(G,z,W){var D=e.unstable_now();switch(typeof W=="object"&&W!==null?(W=W.delay,W=typeof W=="number"&&0<W?D+W:D):W=D,G){case 1:var H=-1;break;case 2:H=250;break;case 5:H=1073741823;break;case 4:H=1e4;break;default:H=5e3}return H=W+H,G={id:f++,callback:z,priorityLevel:G,startTime:W,expirationTime:H,sortIndex:-1},W>D?(G.sortIndex=W,t(h,G),n(d)===null&&G===n(h)&&(v?(k(O),O=-1):v=!0,K(_,W-D))):(G.sortIndex=H,t(d,G),j||w||(j=!0,$(E))),G},e.unstable_shouldYield=P,e.unstable_wrapCallback=function(G){var z=m;return function(){var W=m;m=z;try{return G.apply(this,arguments)}finally{m=W}}}})(Rg)),Rg}var C_;function g8(){return C_||(C_=1,Tg.exports=m8()),Tg.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 E_;function y8(){if(E_)return En;E_=1;var e=Tu(),t=g8();function n(l){for(var u="https://reactjs.org/docs/error-decoder.html?invariant="+l,g=1;g<arguments.length;g++)u+="&args[]="+encodeURIComponent(arguments[g]);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 s=new Set,a={};function o(l,u){i(l,u),i(l+"Capture",u)}function i(l,u){for(a[l]=u,l=0;l<u.length;l++)s.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 m(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,g,x){if(g!==null&&g.type===0)return!1;switch(typeof u){case"function":case"symbol":return!0;case"boolean":return x?!1:g!==null?!g.acceptsBooleans:(l=l.toLowerCase().slice(0,5),l!=="data-"&&l!=="aria-");default:return!1}}function j(l,u,g,x){if(u===null||typeof u>"u"||w(l,u,g,x))return!0;if(x)return!1;if(g!==null)switch(g.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 v(l,u,g,x,C,R,V){this.acceptsBooleans=u===2||u===3||u===4,this.attributeName=x,this.attributeNamespace=C,this.mustUseProperty=g,this.propertyName=l,this.type=u,this.sanitizeURL=R,this.removeEmptyString=V}var b={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(l){b[l]=new v(l,0,!1,l,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(l){var u=l[0];b[u]=new v(u,1,!1,l[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(l){b[l]=new v(l,2,!1,l.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(l){b[l]=new v(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){b[l]=new v(l,3,!1,l.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(l){b[l]=new v(l,3,!0,l,null,!1,!1)}),["capture","download"].forEach(function(l){b[l]=new v(l,4,!1,l,null,!1,!1)}),["cols","rows","size","span"].forEach(function(l){b[l]=new v(l,6,!1,l,null,!1,!1)}),["rowSpan","start"].forEach(function(l){b[l]=new v(l,5,!1,l.toLowerCase(),null,!1,!1)});var k=/[\-:]([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(k,N);b[u]=new v(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(k,N);b[u]=new v(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(k,N);b[u]=new v(u,1,!1,l,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(l){b[l]=new v(l,1,!1,l.toLowerCase(),null,!1,!1)}),b.xlinkHref=new v("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(l){b[l]=new v(l,1,!1,l.toLowerCase(),null,!0,!0)});function S(l,u,g,x){var C=b.hasOwnProperty(u)?b[u]:null;(C!==null?C.type!==0:x||!(2<u.length)||u[0]!=="o"&&u[0]!=="O"||u[1]!=="n"&&u[1]!=="N")&&(j(u,g,C,x)&&(g=null),x||C===null?m(u)&&(g===null?l.removeAttribute(u):l.setAttribute(u,""+g)):C.mustUseProperty?l[C.propertyName]=g===null?C.type===3?!1:"":g:(u=C.attributeName,x=C.attributeNamespace,g===null?l.removeAttribute(u):(C=C.type,g=C===3||C===4&&g===!0?"":""+g,x?l.setAttributeNS(x,u,g):l.setAttribute(u,g))))}var _=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,E=Symbol.for("react.element"),I=Symbol.for("react.portal"),A=Symbol.for("react.fragment"),O=Symbol.for("react.strict_mode"),L=Symbol.for("react.profiler"),U=Symbol.for("react.provider"),P=Symbol.for("react.context"),T=Symbol.for("react.forward_ref"),B=Symbol.for("react.suspense"),M=Symbol.for("react.suspense_list"),q=Symbol.for("react.memo"),$=Symbol.for("react.lazy"),K=Symbol.for("react.offscreen"),G=Symbol.iterator;function z(l){return l===null||typeof l!="object"?null:(l=G&&l[G]||l["@@iterator"],typeof l=="function"?l:null)}var W=Object.assign,D;function H(l){if(D===void 0)try{throw Error()}catch(g){var u=g.stack.trim().match(/\n( *(at )?)/);D=u&&u[1]||""}return`
|
|
34
|
+
`+D+l}var ee=!1;function F(l,u){if(!l||ee)return"";ee=!0;var g=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 C=ue.stack.split(`
|
|
35
|
+
`),R=x.stack.split(`
|
|
36
|
+
`),V=C.length-1,Q=R.length-1;1<=V&&0<=Q&&C[V]!==R[Q];)Q--;for(;1<=V&&0<=Q;V--,Q--)if(C[V]!==R[Q]){if(V!==1||Q!==1)do if(V--,Q--,0>Q||C[V]!==R[Q]){var te=`
|
|
37
|
+
`+C[V].replace(" at new "," at ");return l.displayName&&te.includes("<anonymous>")&&(te=te.replace("<anonymous>",l.displayName)),te}while(1<=V&&0<=Q);break}}}finally{ee=!1,Error.prepareStackTrace=g}return(l=l?l.displayName||l.name:"")?H(l):""}function Y(l){switch(l.tag){case 5:return H(l.type);case 16:return H("Lazy");case 13:return H("Suspense");case 19:return H("SuspenseList");case 0:case 2:case 15:return l=F(l.type,!1),l;case 11:return l=F(l.type.render,!1),l;case 1:return l=F(l.type,!0),l;default:return""}}function X(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 A:return"Fragment";case I:return"Portal";case L:return"Profiler";case O:return"StrictMode";case B:return"Suspense";case M: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 T:var u=l.render;return l=l.displayName,l||(l=u.displayName||u.name||"",l=l!==""?"ForwardRef("+l+")":"ForwardRef"),l;case q:return u=l.displayName||null,u!==null?u:X(l.type)||"Memo";case $:u=l._payload,l=l._init;try{return X(l(u))}catch{}}return null}function Z(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 X(u);case 8:return u===O?"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 J(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 ce(l){var u=ne(l)?"checked":"value",g=Object.getOwnPropertyDescriptor(l.constructor.prototype,u),x=""+l[u];if(!l.hasOwnProperty(u)&&typeof g<"u"&&typeof g.get=="function"&&typeof g.set=="function"){var C=g.get,R=g.set;return Object.defineProperty(l,u,{configurable:!0,get:function(){return C.call(this)},set:function(V){x=""+V,R.call(this,V)}}),Object.defineProperty(l,u,{enumerable:g.enumerable}),{getValue:function(){return x},setValue:function(V){x=""+V},stopTracking:function(){l._valueTracker=null,delete l[u]}}}}function he(l){l._valueTracker||(l._valueTracker=ce(l))}function le(l){if(!l)return!1;var u=l._valueTracker;if(!u)return!0;var g=u.getValue(),x="";return l&&(x=ne(l)?l.checked?"true":"false":l.value),l=x,l!==g?(u.setValue(l),!0):!1}function re(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 ae(l,u){var g=u.checked;return W({},u,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:g??l._wrapperState.initialChecked})}function de(l,u){var g=u.defaultValue==null?"":u.defaultValue,x=u.checked!=null?u.checked:u.defaultChecked;g=J(u.value!=null?u.value:g),l._wrapperState={initialChecked:x,initialValue:g,controlled:u.type==="checkbox"||u.type==="radio"?u.checked!=null:u.value!=null}}function Se(l,u){u=u.checked,u!=null&&S(l,"checked",u,!1)}function pe(l,u){Se(l,u);var g=J(u.value),x=u.type;if(g!=null)x==="number"?(g===0&&l.value===""||l.value!=g)&&(l.value=""+g):l.value!==""+g&&(l.value=""+g);else if(x==="submit"||x==="reset"){l.removeAttribute("value");return}u.hasOwnProperty("value")?be(l,u.type,g):u.hasOwnProperty("defaultValue")&&be(l,u.type,J(u.defaultValue)),u.checked==null&&u.defaultChecked!=null&&(l.defaultChecked=!!u.defaultChecked)}function me(l,u,g){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,g||u===l.value||(l.value=u),l.defaultValue=u}g=l.name,g!==""&&(l.name=""),l.defaultChecked=!!l._wrapperState.initialChecked,g!==""&&(l.name=g)}function be(l,u,g){(u!=="number"||re(l.ownerDocument)!==l)&&(g==null?l.defaultValue=""+l._wrapperState.initialValue:l.defaultValue!==""+g&&(l.defaultValue=""+g))}var Ce=Array.isArray;function ye(l,u,g,x){if(l=l.options,u){u={};for(var C=0;C<g.length;C++)u["$"+g[C]]=!0;for(g=0;g<l.length;g++)C=u.hasOwnProperty("$"+l[g].value),l[g].selected!==C&&(l[g].selected=C),C&&x&&(l[g].defaultSelected=!0)}else{for(g=""+J(g),u=null,C=0;C<l.length;C++){if(l[C].value===g){l[C].selected=!0,x&&(l[C].defaultSelected=!0);return}u!==null||l[C].disabled||(u=l[C])}u!==null&&(u.selected=!0)}}function Pe(l,u){if(u.dangerouslySetInnerHTML!=null)throw Error(n(91));return W({},u,{value:void 0,defaultValue:void 0,children:""+l._wrapperState.initialValue})}function Oe(l,u){var g=u.value;if(g==null){if(g=u.children,u=u.defaultValue,g!=null){if(u!=null)throw Error(n(92));if(Ce(g)){if(1<g.length)throw Error(n(93));g=g[0]}u=g}u==null&&(u=""),g=u}l._wrapperState={initialValue:J(g)}}function We(l,u){var g=J(u.value),x=J(u.defaultValue);g!=null&&(g=""+g,g!==l.value&&(l.value=g),u.defaultValue==null&&l.defaultValue!==g&&(l.defaultValue=g)),x!=null&&(l.defaultValue=""+x)}function Re(l){var u=l.textContent;u===l._wrapperState.initialValue&&u!==""&&u!==null&&(l.value=u)}function st(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 je(l,u){return l==null||l==="http://www.w3.org/1999/xhtml"?st(u):l==="http://www.w3.org/2000/svg"&&u==="foreignObject"?"http://www.w3.org/1999/xhtml":l}var Te,$e=(function(l){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(u,g,x,C){MSApp.execUnsafeLocalFunction(function(){return l(u,g,x,C)})}:l})(function(l,u){if(l.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in l)l.innerHTML=u;else{for(Te=Te||document.createElement("div"),Te.innerHTML="<svg>"+u.valueOf().toString()+"</svg>",u=Te.firstChild;l.firstChild;)l.removeChild(l.firstChild);for(;u.firstChild;)l.appendChild(u.firstChild)}});function Ge(l,u){if(u){var g=l.firstChild;if(g&&g===l.lastChild&&g.nodeType===3){g.nodeValue=u;return}}l.textContent=u}var tt={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(tt).forEach(function(l){ht.forEach(function(u){u=u+l.charAt(0).toUpperCase()+l.substring(1),tt[u]=tt[l]})});function it(l,u,g){return u==null||typeof u=="boolean"||u===""?"":g||typeof u!="number"||u===0||tt.hasOwnProperty(l)&&tt[l]?(""+u).trim():u+"px"}function nt(l,u){l=l.style;for(var g in u)if(u.hasOwnProperty(g)){var x=g.indexOf("--")===0,C=it(g,u[g],x);g==="float"&&(g="cssFloat"),x?l.setProperty(g,C):l[g]=C}}var we=W({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function Be(l,u){if(u){if(we[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 Ye(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 He=null;function ft(l){return l=l.target||l.srcElement||window,l.correspondingUseElement&&(l=l.correspondingUseElement),l.nodeType===3?l.parentNode:l}var St=null,gt=null,_t=null;function It(l){if(l=ic(l)){if(typeof St!="function")throw Error(n(280));var u=l.stateNode;u&&(u=fd(u),St(l.stateNode,l.type,u))}}function ks(l){gt?_t?_t.push(l):_t=[l]:gt=l}function Xs(){if(gt){var l=gt,u=_t;if(_t=gt=null,It(l),u)for(l=0;l<u.length;l++)It(u[l])}}function js(l,u){return l(u)}function Zn(){}var Ot=!1;function Ns(l,u,g){if(Ot)return l(u,g);Ot=!0;try{return js(l,u,g)}finally{Ot=!1,(gt!==null||_t!==null)&&(Zn(),Xs())}}function hn(l,u){var g=l.stateNode;if(g===null)return null;var x=fd(g);if(x===null)return null;g=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(g&&typeof g!="function")throw Error(n(231,u,typeof g));return g}var Dn=!1;if(c)try{var _e={};Object.defineProperty(_e,"passive",{get:function(){Dn=!0}}),window.addEventListener("test",_e,_e),window.removeEventListener("test",_e,_e)}catch{Dn=!1}function De(l,u,g,x,C,R,V,Q,te){var ue=Array.prototype.slice.call(arguments,3);try{u.apply(g,ue)}catch(ve){this.onError(ve)}}var ze=!1,ut=null,At=!1,Jn=null,fn={onError:function(l){ze=!0,ut=l}};function la(l,u,g,x,C,R,V,Q,te){ze=!1,ut=null,De.apply(fn,arguments)}function Qn(l,u,g,x,C,R,V,Q,te){if(la.apply(this,arguments),ze){if(ze){var ue=ut;ze=!1,ut=null}else throw Error(n(198));At||(At=!0,Jn=ue)}}function Ct(l){var u=l,g=l;if(l.alternate)for(;u.return;)u=u.return;else{l=u;do u=l,(u.flags&4098)!==0&&(g=u.return),l=u.return;while(l)}return u.tag===3?g:null}function Ss(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 _s(l){if(Ct(l)!==l)throw Error(n(188))}function Zs(l){var u=l.alternate;if(!u){if(u=Ct(l),u===null)throw Error(n(188));return u!==l?null:l}for(var g=l,x=u;;){var C=g.return;if(C===null)break;var R=C.alternate;if(R===null){if(x=C.return,x!==null){g=x;continue}break}if(C.child===R.child){for(R=C.child;R;){if(R===g)return _s(C),l;if(R===x)return _s(C),u;R=R.sibling}throw Error(n(188))}if(g.return!==x.return)g=C,x=R;else{for(var V=!1,Q=C.child;Q;){if(Q===g){V=!0,g=C,x=R;break}if(Q===x){V=!0,x=C,g=R;break}Q=Q.sibling}if(!V){for(Q=R.child;Q;){if(Q===g){V=!0,g=R,x=C;break}if(Q===x){V=!0,x=R,g=C;break}Q=Q.sibling}if(!V)throw Error(n(189))}}if(g.alternate!==x)throw Error(n(190))}if(g.tag!==3)throw Error(n(188));return g.stateNode.current===g?l:u}function Cs(l){return l=Zs(l),l!==null?Sr(l):null}function Sr(l){if(l.tag===5||l.tag===6)return l;for(l=l.child;l!==null;){var u=Sr(l);if(u!==null)return u;l=l.sibling}return null}var Ft=t.unstable_scheduleCallback,Js=t.unstable_cancelCallback,Es=t.unstable_shouldYield,_r=t.unstable_requestPaint,dt=t.unstable_now,ri=t.unstable_getCurrentPriorityLevel,Cr=t.unstable_ImmediatePriority,Qs=t.unstable_UserBlockingPriority,Ts=t.unstable_NormalPriority,so=t.unstable_LowPriority,Er=t.unstable_IdlePriority,es=null,nn=null;function er(l){if(nn&&typeof nn.onCommitFiberRoot=="function")try{nn.onCommitFiberRoot(es,l,void 0,(l.current.flags&128)===128)}catch{}}var Wt=Math.clz32?Math.clz32:tr,ai=Math.log,ro=Math.LN2;function tr(l){return l>>>=0,l===0?32:31-(ai(l)/ro|0)|0}var ts=64,ns=4194304;function ge(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 Ve(l,u){var g=l.pendingLanes;if(g===0)return 0;var x=0,C=l.suspendedLanes,R=l.pingedLanes,V=g&268435455;if(V!==0){var Q=V&~C;Q!==0?x=ge(Q):(R&=V,R!==0&&(x=ge(R)))}else V=g&~C,V!==0?x=ge(V):R!==0&&(x=ge(R));if(x===0)return 0;if(u!==0&&u!==x&&(u&C)===0&&(C=x&-x,R=u&-u,C>=R||C===16&&(R&4194240)!==0))return u;if((x&4)!==0&&(x|=g&16),u=l.entangledLanes,u!==0)for(l=l.entanglements,u&=x;0<u;)g=31-Wt(u),C=1<<g,x|=l[g],u&=~C;return x}function lt(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 Mt(l,u){for(var g=l.suspendedLanes,x=l.pingedLanes,C=l.expirationTimes,R=l.pendingLanes;0<R;){var V=31-Wt(R),Q=1<<V,te=C[V];te===-1?((Q&g)===0||(Q&x)!==0)&&(C[V]=lt(Q,u)):te<=u&&(l.expiredLanes|=Q),R&=~Q}}function ss(l){return l=l.pendingLanes&-1073741825,l!==0?l:l&1073741824?1073741824:0}function Tr(){var l=ts;return ts<<=1,(ts&4194240)===0&&(ts=64),l}function ca(l){for(var u=[],g=0;31>g;g++)u.push(l);return u}function nr(l,u,g){l.pendingLanes|=u,u!==536870912&&(l.suspendedLanes=0,l.pingedLanes=0),l=l.eventTimes,u=31-Wt(u),l[u]=g}function Fn(l,u){var g=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<g;){var C=31-Wt(g),R=1<<C;u[C]=0,x[C]=-1,l[C]=-1,g&=~R}}function Rr(l,u){var g=l.entangledLanes|=u;for(l=l.entanglements;g;){var x=31-Wt(g),C=1<<x;C&u|l[x]&u&&(l[x]|=u),g&=~C}}var ct=0;function Ol(l){return l&=-l,1<l?4<l?(l&268435455)!==0?16:536870912:4:1}var Pl,ao,oi,sr,Ju,Dl=!1,ii=[],rs=null,pn=null,rr=null,ua=new Map,da=new Map,ar=[],Fl="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 Qu(l,u){switch(l){case"focusin":case"focusout":rs=null;break;case"dragenter":case"dragleave":pn=null;break;case"mouseover":case"mouseout":rr=null;break;case"pointerover":case"pointerout":ua.delete(u.pointerId);break;case"gotpointercapture":case"lostpointercapture":da.delete(u.pointerId)}}function oo(l,u,g,x,C,R){return l===null||l.nativeEvent!==R?(l={blockedOn:u,domEventName:g,eventSystemFlags:x,nativeEvent:R,targetContainers:[C]},u!==null&&(u=ic(u),u!==null&&ao(u)),l):(l.eventSystemFlags|=x,u=l.targetContainers,C!==null&&u.indexOf(C)===-1&&u.push(C),l)}function Bl(l,u,g,x,C){switch(u){case"focusin":return rs=oo(rs,l,u,g,x,C),!0;case"dragenter":return pn=oo(pn,l,u,g,x,C),!0;case"mouseover":return rr=oo(rr,l,u,g,x,C),!0;case"pointerover":var R=C.pointerId;return ua.set(R,oo(ua.get(R)||null,l,u,g,x,C)),!0;case"gotpointercapture":return R=C.pointerId,da.set(R,oo(da.get(R)||null,l,u,g,x,C)),!0}return!1}function ql(l){var u=po(l.target);if(u!==null){var g=Ct(u);if(g!==null){if(u=g.tag,u===13){if(u=Ss(g),u!==null){l.blockedOn=u,Ju(l.priority,function(){oi(g)});return}}else if(u===3&&g.stateNode.current.memoizedState.isDehydrated){l.blockedOn=g.tag===3?g.stateNode.containerInfo:null;return}}}l.blockedOn=null}function li(l){if(l.blockedOn!==null)return!1;for(var u=l.targetContainers;0<u.length;){var g=Ul(l.domEventName,l.eventSystemFlags,u[0],l.nativeEvent);if(g===null){g=l.nativeEvent;var x=new g.constructor(g.type,g);He=x,g.target.dispatchEvent(x),He=null}else return u=ic(g),u!==null&&ao(u),l.blockedOn=g,!1;u.shift()}return!0}function ed(l,u,g){li(l)&&g.delete(u)}function zp(){Dl=!1,rs!==null&&li(rs)&&(rs=null),pn!==null&&li(pn)&&(pn=null),rr!==null&&li(rr)&&(rr=null),ua.forEach(ed),da.forEach(ed)}function Ar(l,u){l.blockedOn===u&&(l.blockedOn=null,Dl||(Dl=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,zp)))}function io(l){function u(C){return Ar(C,l)}if(0<ii.length){Ar(ii[0],l);for(var g=1;g<ii.length;g++){var x=ii[g];x.blockedOn===l&&(x.blockedOn=null)}}for(rs!==null&&Ar(rs,l),pn!==null&&Ar(pn,l),rr!==null&&Ar(rr,l),ua.forEach(u),da.forEach(u),g=0;g<ar.length;g++)x=ar[g],x.blockedOn===l&&(x.blockedOn=null);for(;0<ar.length&&(g=ar[0],g.blockedOn===null);)ql(g),g.blockedOn===null&&ar.shift()}var Mr=_.ReactCurrentBatchConfig,ci=!0;function Vp(l,u,g,x){var C=ct,R=Mr.transition;Mr.transition=null;try{ct=1,ui(l,u,g,x)}finally{ct=C,Mr.transition=R}}function Gp(l,u,g,x){var C=ct,R=Mr.transition;Mr.transition=null;try{ct=4,ui(l,u,g,x)}finally{ct=C,Mr.transition=R}}function ui(l,u,g,x){if(ci){var C=Ul(l,u,g,x);if(C===null)mm(l,u,x,di,g),Qu(l,x);else if(Bl(C,l,u,g,x))x.stopPropagation();else if(Qu(l,x),u&4&&-1<Fl.indexOf(l)){for(;C!==null;){var R=ic(C);if(R!==null&&Pl(R),R=Ul(l,u,g,x),R===null&&mm(l,u,x,di,g),R===C)break;C=R}C!==null&&x.stopPropagation()}else mm(l,u,x,null,g)}}var di=null;function Ul(l,u,g,x){if(di=null,l=ft(x),l=po(l),l!==null)if(u=Ct(l),u===null)l=null;else if(g=u.tag,g===13){if(l=Ss(u),l!==null)return l;l=null}else if(g===3){if(u.stateNode.current.memoizedState.isDehydrated)return u.tag===3?u.stateNode.containerInfo:null;l=null}else u!==l&&(l=null);return di=l,null}function Wl(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(ri()){case Cr:return 1;case Qs:return 4;case Ts:case so:return 16;case Er:return 536870912;default:return 16}default:return 16}}var kn=null,lo=null,Rs=null;function co(){if(Rs)return Rs;var l,u=lo,g=u.length,x,C="value"in kn?kn.value:kn.textContent,R=C.length;for(l=0;l<g&&u[l]===C[l];l++);var V=g-l;for(x=1;x<=V&&u[g-x]===C[R-x];x++);return Rs=C.slice(l,1<x?1-x:void 0)}function uo(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 ho(){return!0}function Hl(){return!1}function sn(l){function u(g,x,C,R,V){this._reactName=g,this._targetInst=C,this.type=x,this.nativeEvent=R,this.target=V,this.currentTarget=null;for(var Q in l)l.hasOwnProperty(Q)&&(g=l[Q],this[Q]=g?g(R):R[Q]);return this.isDefaultPrevented=(R.defaultPrevented!=null?R.defaultPrevented:R.returnValue===!1)?ho:Hl,this.isPropagationStopped=Hl,this}return W(u.prototype,{preventDefault:function(){this.defaultPrevented=!0;var g=this.nativeEvent;g&&(g.preventDefault?g.preventDefault():typeof g.returnValue!="unknown"&&(g.returnValue=!1),this.isDefaultPrevented=ho)},stopPropagation:function(){var g=this.nativeEvent;g&&(g.stopPropagation?g.stopPropagation():typeof g.cancelBubble!="unknown"&&(g.cancelBubble=!0),this.isPropagationStopped=ho)},persist:function(){},isPersistent:ho}),u}var ha={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(l){return l.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},fo=sn(ha),fa=W({},ha,{view:0,detail:0}),td=sn(fa),zl,Vl,$r,Lr=W({},fa,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:fi,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!==$r&&($r&&l.type==="mousemove"?(zl=l.screenX-$r.screenX,Vl=l.screenY-$r.screenY):Vl=zl=0,$r=l),zl)},movementY:function(l){return"movementY"in l?l.movementY:Vl}}),nd=sn(Lr),pa=W({},Lr,{dataTransfer:0}),Kp=sn(pa),Yp=W({},fa,{relatedTarget:0}),Gl=sn(Yp),Kl=W({},ha,{animationName:0,elapsedTime:0,pseudoElement:0}),hi=sn(Kl),Xp=W({},ha,{clipboardData:function(l){return"clipboardData"in l?l.clipboardData:window.clipboardData}}),sd=sn(Xp),ma=W({},ha,{data:0}),Yl=sn(ma),Xl={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Zp={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"},Ir={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function rd(l){var u=this.nativeEvent;return u.getModifierState?u.getModifierState(l):(l=Ir[l])?!!u[l]:!1}function fi(){return rd}var Jp=W({},fa,{key:function(l){if(l.key){var u=Xl[l.key]||l.key;if(u!=="Unidentified")return u}return l.type==="keypress"?(l=uo(l),l===13?"Enter":String.fromCharCode(l)):l.type==="keydown"||l.type==="keyup"?Zp[l.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:fi,charCode:function(l){return l.type==="keypress"?uo(l):0},keyCode:function(l){return l.type==="keydown"||l.type==="keyup"?l.keyCode:0},which:function(l){return l.type==="keypress"?uo(l):l.type==="keydown"||l.type==="keyup"?l.keyCode:0}}),Zl=sn(Jp),Qp=W({},Lr,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),ad=sn(Qp),em=W({},fa,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:fi}),tm=sn(em),or=W({},ha,{propertyName:0,elapsedTime:0,pseudoElement:0}),nm=sn(or),sm=W({},Lr,{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}),rm=sn(sm),am=[9,13,27,32],pi=c&&"CompositionEvent"in window,Bt=null;c&&"documentMode"in document&&(Bt=document.documentMode);var Jl=c&&"TextEvent"in window&&!Bt,pN=c&&(!pi||Bt&&8<Bt&&11>=Bt),mN=" ",gN=!1;function yN(l,u){switch(l){case"keyup":return am.indexOf(u.keyCode)!==-1;case"keydown":return u.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function wN(l){return l=l.detail,typeof l=="object"&&"data"in l?l.data:null}var mi=!1;function i6(l,u){switch(l){case"compositionend":return wN(u);case"keypress":return u.which!==32?null:(gN=!0,mN);case"textInput":return l=u.data,l===mN&&gN?null:l;default:return null}}function l6(l,u){if(mi)return l==="compositionend"||!pi&&yN(l,u)?(l=co(),Rs=lo=kn=null,mi=!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 pN&&u.locale!=="ko"?null:u.data;default:return null}}var c6={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 xN(l){var u=l&&l.nodeName&&l.nodeName.toLowerCase();return u==="input"?!!c6[l.type]:u==="textarea"}function vN(l,u,g,x){ks(x),u=ud(u,"onChange"),0<u.length&&(g=new fo("onChange","change",null,g,x),l.push({event:g,listeners:u}))}var Ql=null,ec=null;function u6(l){DN(l,0)}function od(l){var u=vi(l);if(le(u))return l}function d6(l,u){if(l==="change")return u}var bN=!1;if(c){var om;if(c){var im="oninput"in document;if(!im){var kN=document.createElement("div");kN.setAttribute("oninput","return;"),im=typeof kN.oninput=="function"}om=im}else om=!1;bN=om&&(!document.documentMode||9<document.documentMode)}function jN(){Ql&&(Ql.detachEvent("onpropertychange",NN),ec=Ql=null)}function NN(l){if(l.propertyName==="value"&&od(ec)){var u=[];vN(u,ec,l,ft(l)),Ns(u6,u)}}function h6(l,u,g){l==="focusin"?(jN(),Ql=u,ec=g,Ql.attachEvent("onpropertychange",NN)):l==="focusout"&&jN()}function f6(l){if(l==="selectionchange"||l==="keyup"||l==="keydown")return od(ec)}function p6(l,u){if(l==="click")return od(u)}function m6(l,u){if(l==="input"||l==="change")return od(u)}function g6(l,u){return l===u&&(l!==0||1/l===1/u)||l!==l&&u!==u}var As=typeof Object.is=="function"?Object.is:g6;function tc(l,u){if(As(l,u))return!0;if(typeof l!="object"||l===null||typeof u!="object"||u===null)return!1;var g=Object.keys(l),x=Object.keys(u);if(g.length!==x.length)return!1;for(x=0;x<g.length;x++){var C=g[x];if(!d.call(u,C)||!As(l[C],u[C]))return!1}return!0}function SN(l){for(;l&&l.firstChild;)l=l.firstChild;return l}function _N(l,u){var g=SN(l);l=0;for(var x;g;){if(g.nodeType===3){if(x=l+g.textContent.length,l<=u&&x>=u)return{node:g,offset:u-l};l=x}e:{for(;g;){if(g.nextSibling){g=g.nextSibling;break e}g=g.parentNode}g=void 0}g=SN(g)}}function CN(l,u){return l&&u?l===u?!0:l&&l.nodeType===3?!1:u&&u.nodeType===3?CN(l,u.parentNode):"contains"in l?l.contains(u):l.compareDocumentPosition?!!(l.compareDocumentPosition(u)&16):!1:!1}function EN(){for(var l=window,u=re();u instanceof l.HTMLIFrameElement;){try{var g=typeof u.contentWindow.location.href=="string"}catch{g=!1}if(g)l=u.contentWindow;else break;u=re(l.document)}return u}function lm(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 y6(l){var u=EN(),g=l.focusedElem,x=l.selectionRange;if(u!==g&&g&&g.ownerDocument&&CN(g.ownerDocument.documentElement,g)){if(x!==null&&lm(g)){if(u=x.start,l=x.end,l===void 0&&(l=u),"selectionStart"in g)g.selectionStart=u,g.selectionEnd=Math.min(l,g.value.length);else if(l=(u=g.ownerDocument||document)&&u.defaultView||window,l.getSelection){l=l.getSelection();var C=g.textContent.length,R=Math.min(x.start,C);x=x.end===void 0?R:Math.min(x.end,C),!l.extend&&R>x&&(C=x,x=R,R=C),C=_N(g,R);var V=_N(g,x);C&&V&&(l.rangeCount!==1||l.anchorNode!==C.node||l.anchorOffset!==C.offset||l.focusNode!==V.node||l.focusOffset!==V.offset)&&(u=u.createRange(),u.setStart(C.node,C.offset),l.removeAllRanges(),R>x?(l.addRange(u),l.extend(V.node,V.offset)):(u.setEnd(V.node,V.offset),l.addRange(u)))}}for(u=[],l=g;l=l.parentNode;)l.nodeType===1&&u.push({element:l,left:l.scrollLeft,top:l.scrollTop});for(typeof g.focus=="function"&&g.focus(),g=0;g<u.length;g++)l=u[g],l.element.scrollLeft=l.left,l.element.scrollTop=l.top}}var w6=c&&"documentMode"in document&&11>=document.documentMode,gi=null,cm=null,nc=null,um=!1;function TN(l,u,g){var x=g.window===g?g.document:g.nodeType===9?g:g.ownerDocument;um||gi==null||gi!==re(x)||(x=gi,"selectionStart"in x&&lm(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}),nc&&tc(nc,x)||(nc=x,x=ud(cm,"onSelect"),0<x.length&&(u=new fo("onSelect","select",null,u,g),l.push({event:u,listeners:x}),u.target=gi)))}function id(l,u){var g={};return g[l.toLowerCase()]=u.toLowerCase(),g["Webkit"+l]="webkit"+u,g["Moz"+l]="moz"+u,g}var yi={animationend:id("Animation","AnimationEnd"),animationiteration:id("Animation","AnimationIteration"),animationstart:id("Animation","AnimationStart"),transitionend:id("Transition","TransitionEnd")},dm={},RN={};c&&(RN=document.createElement("div").style,"AnimationEvent"in window||(delete yi.animationend.animation,delete yi.animationiteration.animation,delete yi.animationstart.animation),"TransitionEvent"in window||delete yi.transitionend.transition);function ld(l){if(dm[l])return dm[l];if(!yi[l])return l;var u=yi[l],g;for(g in u)if(u.hasOwnProperty(g)&&g in RN)return dm[l]=u[g];return l}var AN=ld("animationend"),MN=ld("animationiteration"),$N=ld("animationstart"),LN=ld("transitionend"),IN=new Map,ON="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 ga(l,u){IN.set(l,u),o(u,[l])}for(var hm=0;hm<ON.length;hm++){var fm=ON[hm],x6=fm.toLowerCase(),v6=fm[0].toUpperCase()+fm.slice(1);ga(x6,"on"+v6)}ga(AN,"onAnimationEnd"),ga(MN,"onAnimationIteration"),ga($N,"onAnimationStart"),ga("dblclick","onDoubleClick"),ga("focusin","onFocus"),ga("focusout","onBlur"),ga(LN,"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 sc="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(" "),b6=new Set("cancel close invalid load scroll toggle".split(" ").concat(sc));function PN(l,u,g){var x=l.type||"unknown-event";l.currentTarget=g,Qn(x,u,void 0,l),l.currentTarget=null}function DN(l,u){u=(u&4)!==0;for(var g=0;g<l.length;g++){var x=l[g],C=x.event;x=x.listeners;e:{var R=void 0;if(u)for(var V=x.length-1;0<=V;V--){var Q=x[V],te=Q.instance,ue=Q.currentTarget;if(Q=Q.listener,te!==R&&C.isPropagationStopped())break e;PN(C,Q,ue),R=te}else for(V=0;V<x.length;V++){if(Q=x[V],te=Q.instance,ue=Q.currentTarget,Q=Q.listener,te!==R&&C.isPropagationStopped())break e;PN(C,Q,ue),R=te}}}if(At)throw l=Jn,At=!1,Jn=null,l}function bt(l,u){var g=u[bm];g===void 0&&(g=u[bm]=new Set);var x=l+"__bubble";g.has(x)||(FN(u,l,2,!1),g.add(x))}function pm(l,u,g){var x=0;u&&(x|=4),FN(g,l,x,u)}var cd="_reactListening"+Math.random().toString(36).slice(2);function rc(l){if(!l[cd]){l[cd]=!0,s.forEach(function(g){g!=="selectionchange"&&(b6.has(g)||pm(g,!1,l),pm(g,!0,l))});var u=l.nodeType===9?l:l.ownerDocument;u===null||u[cd]||(u[cd]=!0,pm("selectionchange",!1,u))}}function FN(l,u,g,x){switch(Wl(u)){case 1:var C=Vp;break;case 4:C=Gp;break;default:C=ui}g=C.bind(null,u,g,l),C=void 0,!Dn||u!=="touchstart"&&u!=="touchmove"&&u!=="wheel"||(C=!0),x?C!==void 0?l.addEventListener(u,g,{capture:!0,passive:C}):l.addEventListener(u,g,!0):C!==void 0?l.addEventListener(u,g,{passive:C}):l.addEventListener(u,g,!1)}function mm(l,u,g,x,C){var R=x;if((u&1)===0&&(u&2)===0&&x!==null)e:for(;;){if(x===null)return;var V=x.tag;if(V===3||V===4){var Q=x.stateNode.containerInfo;if(Q===C||Q.nodeType===8&&Q.parentNode===C)break;if(V===4)for(V=x.return;V!==null;){var te=V.tag;if((te===3||te===4)&&(te=V.stateNode.containerInfo,te===C||te.nodeType===8&&te.parentNode===C))return;V=V.return}for(;Q!==null;){if(V=po(Q),V===null)return;if(te=V.tag,te===5||te===6){x=R=V;continue e}Q=Q.parentNode}}x=x.return}Ns(function(){var ue=R,ve=ft(g),ke=[];e:{var xe=IN.get(l);if(xe!==void 0){var Ee=fo,Me=l;switch(l){case"keypress":if(uo(g)===0)break e;case"keydown":case"keyup":Ee=Zl;break;case"focusin":Me="focus",Ee=Gl;break;case"focusout":Me="blur",Ee=Gl;break;case"beforeblur":case"afterblur":Ee=Gl;break;case"click":if(g.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Ee=nd;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Ee=Kp;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Ee=tm;break;case AN:case MN:case $N:Ee=hi;break;case LN:Ee=nm;break;case"scroll":Ee=td;break;case"wheel":Ee=rm;break;case"copy":case"cut":case"paste":Ee=sd;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Ee=ad}var Le=(u&4)!==0,Pt=!Le&&l==="scroll",oe=Le?xe!==null?xe+"Capture":null:xe;Le=[];for(var se=ue,ie;se!==null;){ie=se;var Ne=ie.stateNode;if(ie.tag===5&&Ne!==null&&(ie=Ne,oe!==null&&(Ne=hn(se,oe),Ne!=null&&Le.push(ac(se,Ne,ie)))),Pt)break;se=se.return}0<Le.length&&(xe=new Ee(xe,Me,null,g,ve),ke.push({event:xe,listeners:Le}))}}if((u&7)===0){e:{if(xe=l==="mouseover"||l==="pointerover",Ee=l==="mouseout"||l==="pointerout",xe&&g!==He&&(Me=g.relatedTarget||g.fromElement)&&(po(Me)||Me[Or]))break e;if((Ee||xe)&&(xe=ve.window===ve?ve:(xe=ve.ownerDocument)?xe.defaultView||xe.parentWindow:window,Ee?(Me=g.relatedTarget||g.toElement,Ee=ue,Me=Me?po(Me):null,Me!==null&&(Pt=Ct(Me),Me!==Pt||Me.tag!==5&&Me.tag!==6)&&(Me=null)):(Ee=null,Me=ue),Ee!==Me)){if(Le=nd,Ne="onMouseLeave",oe="onMouseEnter",se="mouse",(l==="pointerout"||l==="pointerover")&&(Le=ad,Ne="onPointerLeave",oe="onPointerEnter",se="pointer"),Pt=Ee==null?xe:vi(Ee),ie=Me==null?xe:vi(Me),xe=new Le(Ne,se+"leave",Ee,g,ve),xe.target=Pt,xe.relatedTarget=ie,Ne=null,po(ve)===ue&&(Le=new Le(oe,se+"enter",Me,g,ve),Le.target=ie,Le.relatedTarget=Pt,Ne=Le),Pt=Ne,Ee&&Me)t:{for(Le=Ee,oe=Me,se=0,ie=Le;ie;ie=wi(ie))se++;for(ie=0,Ne=oe;Ne;Ne=wi(Ne))ie++;for(;0<se-ie;)Le=wi(Le),se--;for(;0<ie-se;)oe=wi(oe),ie--;for(;se--;){if(Le===oe||oe!==null&&Le===oe.alternate)break t;Le=wi(Le),oe=wi(oe)}Le=null}else Le=null;Ee!==null&&BN(ke,xe,Ee,Le,!1),Me!==null&&Pt!==null&&BN(ke,Pt,Me,Le,!0)}}e:{if(xe=ue?vi(ue):window,Ee=xe.nodeName&&xe.nodeName.toLowerCase(),Ee==="select"||Ee==="input"&&xe.type==="file")var Ie=d6;else if(xN(xe))if(bN)Ie=m6;else{Ie=f6;var qe=h6}else(Ee=xe.nodeName)&&Ee.toLowerCase()==="input"&&(xe.type==="checkbox"||xe.type==="radio")&&(Ie=p6);if(Ie&&(Ie=Ie(l,ue))){vN(ke,Ie,g,ve);break e}qe&&qe(l,xe,ue),l==="focusout"&&(qe=xe._wrapperState)&&qe.controlled&&xe.type==="number"&&be(xe,"number",xe.value)}switch(qe=ue?vi(ue):window,l){case"focusin":(xN(qe)||qe.contentEditable==="true")&&(gi=qe,cm=ue,nc=null);break;case"focusout":nc=cm=gi=null;break;case"mousedown":um=!0;break;case"contextmenu":case"mouseup":case"dragend":um=!1,TN(ke,g,ve);break;case"selectionchange":if(w6)break;case"keydown":case"keyup":TN(ke,g,ve)}var Ue;if(pi)e:{switch(l){case"compositionstart":var Ke="onCompositionStart";break e;case"compositionend":Ke="onCompositionEnd";break e;case"compositionupdate":Ke="onCompositionUpdate";break e}Ke=void 0}else mi?yN(l,g)&&(Ke="onCompositionEnd"):l==="keydown"&&g.keyCode===229&&(Ke="onCompositionStart");Ke&&(pN&&g.locale!=="ko"&&(mi||Ke!=="onCompositionStart"?Ke==="onCompositionEnd"&&mi&&(Ue=co()):(kn=ve,lo="value"in kn?kn.value:kn.textContent,mi=!0)),qe=ud(ue,Ke),0<qe.length&&(Ke=new Yl(Ke,l,null,g,ve),ke.push({event:Ke,listeners:qe}),Ue?Ke.data=Ue:(Ue=wN(g),Ue!==null&&(Ke.data=Ue)))),(Ue=Jl?i6(l,g):l6(l,g))&&(ue=ud(ue,"onBeforeInput"),0<ue.length&&(ve=new Yl("onBeforeInput","beforeinput",null,g,ve),ke.push({event:ve,listeners:ue}),ve.data=Ue))}DN(ke,u)})}function ac(l,u,g){return{instance:l,listener:u,currentTarget:g}}function ud(l,u){for(var g=u+"Capture",x=[];l!==null;){var C=l,R=C.stateNode;C.tag===5&&R!==null&&(C=R,R=hn(l,g),R!=null&&x.unshift(ac(l,R,C)),R=hn(l,u),R!=null&&x.push(ac(l,R,C))),l=l.return}return x}function wi(l){if(l===null)return null;do l=l.return;while(l&&l.tag!==5);return l||null}function BN(l,u,g,x,C){for(var R=u._reactName,V=[];g!==null&&g!==x;){var Q=g,te=Q.alternate,ue=Q.stateNode;if(te!==null&&te===x)break;Q.tag===5&&ue!==null&&(Q=ue,C?(te=hn(g,R),te!=null&&V.unshift(ac(g,te,Q))):C||(te=hn(g,R),te!=null&&V.push(ac(g,te,Q)))),g=g.return}V.length!==0&&l.push({event:u,listeners:V})}var k6=/\r\n?/g,j6=/\u0000|\uFFFD/g;function qN(l){return(typeof l=="string"?l:""+l).replace(k6,`
|
|
38
|
+
`).replace(j6,"")}function dd(l,u,g){if(u=qN(u),qN(l)!==u&&g)throw Error(n(425))}function hd(){}var gm=null,ym=null;function wm(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 xm=typeof setTimeout=="function"?setTimeout:void 0,N6=typeof clearTimeout=="function"?clearTimeout:void 0,UN=typeof Promise=="function"?Promise:void 0,S6=typeof queueMicrotask=="function"?queueMicrotask:typeof UN<"u"?function(l){return UN.resolve(null).then(l).catch(_6)}:xm;function _6(l){setTimeout(function(){throw l})}function vm(l,u){var g=u,x=0;do{var C=g.nextSibling;if(l.removeChild(g),C&&C.nodeType===8)if(g=C.data,g==="/$"){if(x===0){l.removeChild(C),io(u);return}x--}else g!=="$"&&g!=="$?"&&g!=="$!"||x++;g=C}while(g);io(u)}function ya(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 WN(l){l=l.previousSibling;for(var u=0;l;){if(l.nodeType===8){var g=l.data;if(g==="$"||g==="$!"||g==="$?"){if(u===0)return l;u--}else g==="/$"&&u++}l=l.previousSibling}return null}var xi=Math.random().toString(36).slice(2),ir="__reactFiber$"+xi,oc="__reactProps$"+xi,Or="__reactContainer$"+xi,bm="__reactEvents$"+xi,C6="__reactListeners$"+xi,E6="__reactHandles$"+xi;function po(l){var u=l[ir];if(u)return u;for(var g=l.parentNode;g;){if(u=g[Or]||g[ir]){if(g=u.alternate,u.child!==null||g!==null&&g.child!==null)for(l=WN(l);l!==null;){if(g=l[ir])return g;l=WN(l)}return u}l=g,g=l.parentNode}return null}function ic(l){return l=l[ir]||l[Or],!l||l.tag!==5&&l.tag!==6&&l.tag!==13&&l.tag!==3?null:l}function vi(l){if(l.tag===5||l.tag===6)return l.stateNode;throw Error(n(33))}function fd(l){return l[oc]||null}var km=[],bi=-1;function wa(l){return{current:l}}function kt(l){0>bi||(l.current=km[bi],km[bi]=null,bi--)}function wt(l,u){bi++,km[bi]=l.current,l.current=u}var xa={},ln=wa(xa),jn=wa(!1),mo=xa;function ki(l,u){var g=l.type.contextTypes;if(!g)return xa;var x=l.stateNode;if(x&&x.__reactInternalMemoizedUnmaskedChildContext===u)return x.__reactInternalMemoizedMaskedChildContext;var C={},R;for(R in g)C[R]=u[R];return x&&(l=l.stateNode,l.__reactInternalMemoizedUnmaskedChildContext=u,l.__reactInternalMemoizedMaskedChildContext=C),C}function Nn(l){return l=l.childContextTypes,l!=null}function pd(){kt(jn),kt(ln)}function HN(l,u,g){if(ln.current!==xa)throw Error(n(168));wt(ln,u),wt(jn,g)}function zN(l,u,g){var x=l.stateNode;if(u=u.childContextTypes,typeof x.getChildContext!="function")return g;x=x.getChildContext();for(var C in x)if(!(C in u))throw Error(n(108,Z(l)||"Unknown",C));return W({},g,x)}function md(l){return l=(l=l.stateNode)&&l.__reactInternalMemoizedMergedChildContext||xa,mo=ln.current,wt(ln,l),wt(jn,jn.current),!0}function VN(l,u,g){var x=l.stateNode;if(!x)throw Error(n(169));g?(l=zN(l,u,mo),x.__reactInternalMemoizedMergedChildContext=l,kt(jn),kt(ln),wt(ln,l)):kt(jn),wt(jn,g)}var Pr=null,gd=!1,jm=!1;function GN(l){Pr===null?Pr=[l]:Pr.push(l)}function T6(l){gd=!0,GN(l)}function va(){if(!jm&&Pr!==null){jm=!0;var l=0,u=ct;try{var g=Pr;for(ct=1;l<g.length;l++){var x=g[l];do x=x(!0);while(x!==null)}Pr=null,gd=!1}catch(C){throw Pr!==null&&(Pr=Pr.slice(l+1)),Ft(Cr,va),C}finally{ct=u,jm=!1}}return null}var ji=[],Ni=0,yd=null,wd=0,as=[],os=0,go=null,Dr=1,Fr="";function yo(l,u){ji[Ni++]=wd,ji[Ni++]=yd,yd=l,wd=u}function KN(l,u,g){as[os++]=Dr,as[os++]=Fr,as[os++]=go,go=l;var x=Dr;l=Fr;var C=32-Wt(x)-1;x&=~(1<<C),g+=1;var R=32-Wt(u)+C;if(30<R){var V=C-C%5;R=(x&(1<<V)-1).toString(32),x>>=V,C-=V,Dr=1<<32-Wt(u)+C|g<<C|x,Fr=R+l}else Dr=1<<R|g<<C|x,Fr=l}function Nm(l){l.return!==null&&(yo(l,1),KN(l,1,0))}function Sm(l){for(;l===yd;)yd=ji[--Ni],ji[Ni]=null,wd=ji[--Ni],ji[Ni]=null;for(;l===go;)go=as[--os],as[os]=null,Fr=as[--os],as[os]=null,Dr=as[--os],as[os]=null}var Bn=null,qn=null,jt=!1,Ms=null;function YN(l,u){var g=us(5,null,null,0);g.elementType="DELETED",g.stateNode=u,g.return=l,u=l.deletions,u===null?(l.deletions=[g],l.flags|=16):u.push(g)}function XN(l,u){switch(l.tag){case 5:var g=l.type;return u=u.nodeType!==1||g.toLowerCase()!==u.nodeName.toLowerCase()?null:u,u!==null?(l.stateNode=u,Bn=l,qn=ya(u.firstChild),!0):!1;case 6:return u=l.pendingProps===""||u.nodeType!==3?null:u,u!==null?(l.stateNode=u,Bn=l,qn=null,!0):!1;case 13:return u=u.nodeType!==8?null:u,u!==null?(g=go!==null?{id:Dr,overflow:Fr}:null,l.memoizedState={dehydrated:u,treeContext:g,retryLane:1073741824},g=us(18,null,null,0),g.stateNode=u,g.return=l,l.child=g,Bn=l,qn=null,!0):!1;default:return!1}}function _m(l){return(l.mode&1)!==0&&(l.flags&128)===0}function Cm(l){if(jt){var u=qn;if(u){var g=u;if(!XN(l,u)){if(_m(l))throw Error(n(418));u=ya(g.nextSibling);var x=Bn;u&&XN(l,u)?YN(x,g):(l.flags=l.flags&-4097|2,jt=!1,Bn=l)}}else{if(_m(l))throw Error(n(418));l.flags=l.flags&-4097|2,jt=!1,Bn=l}}}function ZN(l){for(l=l.return;l!==null&&l.tag!==5&&l.tag!==3&&l.tag!==13;)l=l.return;Bn=l}function xd(l){if(l!==Bn)return!1;if(!jt)return ZN(l),jt=!0,!1;var u;if((u=l.tag!==3)&&!(u=l.tag!==5)&&(u=l.type,u=u!=="head"&&u!=="body"&&!wm(l.type,l.memoizedProps)),u&&(u=qn)){if(_m(l))throw JN(),Error(n(418));for(;u;)YN(l,u),u=ya(u.nextSibling)}if(ZN(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 g=l.data;if(g==="/$"){if(u===0){qn=ya(l.nextSibling);break e}u--}else g!=="$"&&g!=="$!"&&g!=="$?"||u++}l=l.nextSibling}qn=null}}else qn=Bn?ya(l.stateNode.nextSibling):null;return!0}function JN(){for(var l=qn;l;)l=ya(l.nextSibling)}function Si(){qn=Bn=null,jt=!1}function Em(l){Ms===null?Ms=[l]:Ms.push(l)}var R6=_.ReactCurrentBatchConfig;function lc(l,u,g){if(l=g.ref,l!==null&&typeof l!="function"&&typeof l!="object"){if(g._owner){if(g=g._owner,g){if(g.tag!==1)throw Error(n(309));var x=g.stateNode}if(!x)throw Error(n(147,l));var C=x,R=""+l;return u!==null&&u.ref!==null&&typeof u.ref=="function"&&u.ref._stringRef===R?u.ref:(u=function(V){var Q=C.refs;V===null?delete Q[R]:Q[R]=V},u._stringRef=R,u)}if(typeof l!="string")throw Error(n(284));if(!g._owner)throw Error(n(290,l))}return l}function vd(l,u){throw l=Object.prototype.toString.call(u),Error(n(31,l==="[object Object]"?"object with keys {"+Object.keys(u).join(", ")+"}":l))}function QN(l){var u=l._init;return u(l._payload)}function eS(l){function u(oe,se){if(l){var ie=oe.deletions;ie===null?(oe.deletions=[se],oe.flags|=16):ie.push(se)}}function g(oe,se){if(!l)return null;for(;se!==null;)u(oe,se),se=se.sibling;return null}function x(oe,se){for(oe=new Map;se!==null;)se.key!==null?oe.set(se.key,se):oe.set(se.index,se),se=se.sibling;return oe}function C(oe,se){return oe=Ea(oe,se),oe.index=0,oe.sibling=null,oe}function R(oe,se,ie){return oe.index=ie,l?(ie=oe.alternate,ie!==null?(ie=ie.index,ie<se?(oe.flags|=2,se):ie):(oe.flags|=2,se)):(oe.flags|=1048576,se)}function V(oe){return l&&oe.alternate===null&&(oe.flags|=2),oe}function Q(oe,se,ie,Ne){return se===null||se.tag!==6?(se=xg(ie,oe.mode,Ne),se.return=oe,se):(se=C(se,ie),se.return=oe,se)}function te(oe,se,ie,Ne){var Ie=ie.type;return Ie===A?ve(oe,se,ie.props.children,Ne,ie.key):se!==null&&(se.elementType===Ie||typeof Ie=="object"&&Ie!==null&&Ie.$$typeof===$&&QN(Ie)===se.type)?(Ne=C(se,ie.props),Ne.ref=lc(oe,se,ie),Ne.return=oe,Ne):(Ne=Hd(ie.type,ie.key,ie.props,null,oe.mode,Ne),Ne.ref=lc(oe,se,ie),Ne.return=oe,Ne)}function ue(oe,se,ie,Ne){return se===null||se.tag!==4||se.stateNode.containerInfo!==ie.containerInfo||se.stateNode.implementation!==ie.implementation?(se=vg(ie,oe.mode,Ne),se.return=oe,se):(se=C(se,ie.children||[]),se.return=oe,se)}function ve(oe,se,ie,Ne,Ie){return se===null||se.tag!==7?(se=So(ie,oe.mode,Ne,Ie),se.return=oe,se):(se=C(se,ie),se.return=oe,se)}function ke(oe,se,ie){if(typeof se=="string"&&se!==""||typeof se=="number")return se=xg(""+se,oe.mode,ie),se.return=oe,se;if(typeof se=="object"&&se!==null){switch(se.$$typeof){case E:return ie=Hd(se.type,se.key,se.props,null,oe.mode,ie),ie.ref=lc(oe,null,se),ie.return=oe,ie;case I:return se=vg(se,oe.mode,ie),se.return=oe,se;case $:var Ne=se._init;return ke(oe,Ne(se._payload),ie)}if(Ce(se)||z(se))return se=So(se,oe.mode,ie,null),se.return=oe,se;vd(oe,se)}return null}function xe(oe,se,ie,Ne){var Ie=se!==null?se.key:null;if(typeof ie=="string"&&ie!==""||typeof ie=="number")return Ie!==null?null:Q(oe,se,""+ie,Ne);if(typeof ie=="object"&&ie!==null){switch(ie.$$typeof){case E:return ie.key===Ie?te(oe,se,ie,Ne):null;case I:return ie.key===Ie?ue(oe,se,ie,Ne):null;case $:return Ie=ie._init,xe(oe,se,Ie(ie._payload),Ne)}if(Ce(ie)||z(ie))return Ie!==null?null:ve(oe,se,ie,Ne,null);vd(oe,ie)}return null}function Ee(oe,se,ie,Ne,Ie){if(typeof Ne=="string"&&Ne!==""||typeof Ne=="number")return oe=oe.get(ie)||null,Q(se,oe,""+Ne,Ie);if(typeof Ne=="object"&&Ne!==null){switch(Ne.$$typeof){case E:return oe=oe.get(Ne.key===null?ie:Ne.key)||null,te(se,oe,Ne,Ie);case I:return oe=oe.get(Ne.key===null?ie:Ne.key)||null,ue(se,oe,Ne,Ie);case $:var qe=Ne._init;return Ee(oe,se,ie,qe(Ne._payload),Ie)}if(Ce(Ne)||z(Ne))return oe=oe.get(ie)||null,ve(se,oe,Ne,Ie,null);vd(se,Ne)}return null}function Me(oe,se,ie,Ne){for(var Ie=null,qe=null,Ue=se,Ke=se=0,Qt=null;Ue!==null&&Ke<ie.length;Ke++){Ue.index>Ke?(Qt=Ue,Ue=null):Qt=Ue.sibling;var ot=xe(oe,Ue,ie[Ke],Ne);if(ot===null){Ue===null&&(Ue=Qt);break}l&&Ue&&ot.alternate===null&&u(oe,Ue),se=R(ot,se,Ke),qe===null?Ie=ot:qe.sibling=ot,qe=ot,Ue=Qt}if(Ke===ie.length)return g(oe,Ue),jt&&yo(oe,Ke),Ie;if(Ue===null){for(;Ke<ie.length;Ke++)Ue=ke(oe,ie[Ke],Ne),Ue!==null&&(se=R(Ue,se,Ke),qe===null?Ie=Ue:qe.sibling=Ue,qe=Ue);return jt&&yo(oe,Ke),Ie}for(Ue=x(oe,Ue);Ke<ie.length;Ke++)Qt=Ee(Ue,oe,Ke,ie[Ke],Ne),Qt!==null&&(l&&Qt.alternate!==null&&Ue.delete(Qt.key===null?Ke:Qt.key),se=R(Qt,se,Ke),qe===null?Ie=Qt:qe.sibling=Qt,qe=Qt);return l&&Ue.forEach(function(Ta){return u(oe,Ta)}),jt&&yo(oe,Ke),Ie}function Le(oe,se,ie,Ne){var Ie=z(ie);if(typeof Ie!="function")throw Error(n(150));if(ie=Ie.call(ie),ie==null)throw Error(n(151));for(var qe=Ie=null,Ue=se,Ke=se=0,Qt=null,ot=ie.next();Ue!==null&&!ot.done;Ke++,ot=ie.next()){Ue.index>Ke?(Qt=Ue,Ue=null):Qt=Ue.sibling;var Ta=xe(oe,Ue,ot.value,Ne);if(Ta===null){Ue===null&&(Ue=Qt);break}l&&Ue&&Ta.alternate===null&&u(oe,Ue),se=R(Ta,se,Ke),qe===null?Ie=Ta:qe.sibling=Ta,qe=Ta,Ue=Qt}if(ot.done)return g(oe,Ue),jt&&yo(oe,Ke),Ie;if(Ue===null){for(;!ot.done;Ke++,ot=ie.next())ot=ke(oe,ot.value,Ne),ot!==null&&(se=R(ot,se,Ke),qe===null?Ie=ot:qe.sibling=ot,qe=ot);return jt&&yo(oe,Ke),Ie}for(Ue=x(oe,Ue);!ot.done;Ke++,ot=ie.next())ot=Ee(Ue,oe,Ke,ot.value,Ne),ot!==null&&(l&&ot.alternate!==null&&Ue.delete(ot.key===null?Ke:ot.key),se=R(ot,se,Ke),qe===null?Ie=ot:qe.sibling=ot,qe=ot);return l&&Ue.forEach(function(c8){return u(oe,c8)}),jt&&yo(oe,Ke),Ie}function Pt(oe,se,ie,Ne){if(typeof ie=="object"&&ie!==null&&ie.type===A&&ie.key===null&&(ie=ie.props.children),typeof ie=="object"&&ie!==null){switch(ie.$$typeof){case E:e:{for(var Ie=ie.key,qe=se;qe!==null;){if(qe.key===Ie){if(Ie=ie.type,Ie===A){if(qe.tag===7){g(oe,qe.sibling),se=C(qe,ie.props.children),se.return=oe,oe=se;break e}}else if(qe.elementType===Ie||typeof Ie=="object"&&Ie!==null&&Ie.$$typeof===$&&QN(Ie)===qe.type){g(oe,qe.sibling),se=C(qe,ie.props),se.ref=lc(oe,qe,ie),se.return=oe,oe=se;break e}g(oe,qe);break}else u(oe,qe);qe=qe.sibling}ie.type===A?(se=So(ie.props.children,oe.mode,Ne,ie.key),se.return=oe,oe=se):(Ne=Hd(ie.type,ie.key,ie.props,null,oe.mode,Ne),Ne.ref=lc(oe,se,ie),Ne.return=oe,oe=Ne)}return V(oe);case I:e:{for(qe=ie.key;se!==null;){if(se.key===qe)if(se.tag===4&&se.stateNode.containerInfo===ie.containerInfo&&se.stateNode.implementation===ie.implementation){g(oe,se.sibling),se=C(se,ie.children||[]),se.return=oe,oe=se;break e}else{g(oe,se);break}else u(oe,se);se=se.sibling}se=vg(ie,oe.mode,Ne),se.return=oe,oe=se}return V(oe);case $:return qe=ie._init,Pt(oe,se,qe(ie._payload),Ne)}if(Ce(ie))return Me(oe,se,ie,Ne);if(z(ie))return Le(oe,se,ie,Ne);vd(oe,ie)}return typeof ie=="string"&&ie!==""||typeof ie=="number"?(ie=""+ie,se!==null&&se.tag===6?(g(oe,se.sibling),se=C(se,ie),se.return=oe,oe=se):(g(oe,se),se=xg(ie,oe.mode,Ne),se.return=oe,oe=se),V(oe)):g(oe,se)}return Pt}var _i=eS(!0),tS=eS(!1),bd=wa(null),kd=null,Ci=null,Tm=null;function Rm(){Tm=Ci=kd=null}function Am(l){var u=bd.current;kt(bd),l._currentValue=u}function Mm(l,u,g){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===g)break;l=l.return}}function Ei(l,u){kd=l,Tm=Ci=null,l=l.dependencies,l!==null&&l.firstContext!==null&&((l.lanes&u)!==0&&(Sn=!0),l.firstContext=null)}function is(l){var u=l._currentValue;if(Tm!==l)if(l={context:l,memoizedValue:u,next:null},Ci===null){if(kd===null)throw Error(n(308));Ci=l,kd.dependencies={lanes:0,firstContext:l}}else Ci=Ci.next=l;return u}var wo=null;function $m(l){wo===null?wo=[l]:wo.push(l)}function nS(l,u,g,x){var C=u.interleaved;return C===null?(g.next=g,$m(u)):(g.next=C.next,C.next=g),u.interleaved=g,Br(l,x)}function Br(l,u){l.lanes|=u;var g=l.alternate;for(g!==null&&(g.lanes|=u),g=l,l=l.return;l!==null;)l.childLanes|=u,g=l.alternate,g!==null&&(g.childLanes|=u),g=l,l=l.return;return g.tag===3?g.stateNode:null}var ba=!1;function Lm(l){l.updateQueue={baseState:l.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function sS(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 qr(l,u){return{eventTime:l,lane:u,tag:0,payload:null,callback:null,next:null}}function ka(l,u,g){var x=l.updateQueue;if(x===null)return null;if(x=x.shared,(rt&2)!==0){var C=x.pending;return C===null?u.next=u:(u.next=C.next,C.next=u),x.pending=u,Br(l,g)}return C=x.interleaved,C===null?(u.next=u,$m(x)):(u.next=C.next,C.next=u),x.interleaved=u,Br(l,g)}function jd(l,u,g){if(u=u.updateQueue,u!==null&&(u=u.shared,(g&4194240)!==0)){var x=u.lanes;x&=l.pendingLanes,g|=x,u.lanes=g,Rr(l,g)}}function rS(l,u){var g=l.updateQueue,x=l.alternate;if(x!==null&&(x=x.updateQueue,g===x)){var C=null,R=null;if(g=g.firstBaseUpdate,g!==null){do{var V={eventTime:g.eventTime,lane:g.lane,tag:g.tag,payload:g.payload,callback:g.callback,next:null};R===null?C=R=V:R=R.next=V,g=g.next}while(g!==null);R===null?C=R=u:R=R.next=u}else C=R=u;g={baseState:x.baseState,firstBaseUpdate:C,lastBaseUpdate:R,shared:x.shared,effects:x.effects},l.updateQueue=g;return}l=g.lastBaseUpdate,l===null?g.firstBaseUpdate=u:l.next=u,g.lastBaseUpdate=u}function Nd(l,u,g,x){var C=l.updateQueue;ba=!1;var R=C.firstBaseUpdate,V=C.lastBaseUpdate,Q=C.shared.pending;if(Q!==null){C.shared.pending=null;var te=Q,ue=te.next;te.next=null,V===null?R=ue:V.next=ue,V=te;var ve=l.alternate;ve!==null&&(ve=ve.updateQueue,Q=ve.lastBaseUpdate,Q!==V&&(Q===null?ve.firstBaseUpdate=ue:Q.next=ue,ve.lastBaseUpdate=te))}if(R!==null){var ke=C.baseState;V=0,ve=ue=te=null,Q=R;do{var xe=Q.lane,Ee=Q.eventTime;if((x&xe)===xe){ve!==null&&(ve=ve.next={eventTime:Ee,lane:0,tag:Q.tag,payload:Q.payload,callback:Q.callback,next:null});e:{var Me=l,Le=Q;switch(xe=u,Ee=g,Le.tag){case 1:if(Me=Le.payload,typeof Me=="function"){ke=Me.call(Ee,ke,xe);break e}ke=Me;break e;case 3:Me.flags=Me.flags&-65537|128;case 0:if(Me=Le.payload,xe=typeof Me=="function"?Me.call(Ee,ke,xe):Me,xe==null)break e;ke=W({},ke,xe);break e;case 2:ba=!0}}Q.callback!==null&&Q.lane!==0&&(l.flags|=64,xe=C.effects,xe===null?C.effects=[Q]:xe.push(Q))}else Ee={eventTime:Ee,lane:xe,tag:Q.tag,payload:Q.payload,callback:Q.callback,next:null},ve===null?(ue=ve=Ee,te=ke):ve=ve.next=Ee,V|=xe;if(Q=Q.next,Q===null){if(Q=C.shared.pending,Q===null)break;xe=Q,Q=xe.next,xe.next=null,C.lastBaseUpdate=xe,C.shared.pending=null}}while(!0);if(ve===null&&(te=ke),C.baseState=te,C.firstBaseUpdate=ue,C.lastBaseUpdate=ve,u=C.shared.interleaved,u!==null){C=u;do V|=C.lane,C=C.next;while(C!==u)}else R===null&&(C.shared.lanes=0);bo|=V,l.lanes=V,l.memoizedState=ke}}function aS(l,u,g){if(l=u.effects,u.effects=null,l!==null)for(u=0;u<l.length;u++){var x=l[u],C=x.callback;if(C!==null){if(x.callback=null,x=g,typeof C!="function")throw Error(n(191,C));C.call(x)}}}var cc={},lr=wa(cc),uc=wa(cc),dc=wa(cc);function xo(l){if(l===cc)throw Error(n(174));return l}function Im(l,u){switch(wt(dc,u),wt(uc,l),wt(lr,cc),l=u.nodeType,l){case 9:case 11:u=(u=u.documentElement)?u.namespaceURI:je(null,"");break;default:l=l===8?u.parentNode:u,u=l.namespaceURI||null,l=l.tagName,u=je(u,l)}kt(lr),wt(lr,u)}function Ti(){kt(lr),kt(uc),kt(dc)}function oS(l){xo(dc.current);var u=xo(lr.current),g=je(u,l.type);u!==g&&(wt(uc,l),wt(lr,g))}function Om(l){uc.current===l&&(kt(lr),kt(uc))}var Et=wa(0);function Sd(l){for(var u=l;u!==null;){if(u.tag===13){var g=u.memoizedState;if(g!==null&&(g=g.dehydrated,g===null||g.data==="$?"||g.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 Pm=[];function Dm(){for(var l=0;l<Pm.length;l++)Pm[l]._workInProgressVersionPrimary=null;Pm.length=0}var _d=_.ReactCurrentDispatcher,Fm=_.ReactCurrentBatchConfig,vo=0,Tt=null,Ht=null,Zt=null,Cd=!1,hc=!1,fc=0,A6=0;function cn(){throw Error(n(321))}function Bm(l,u){if(u===null)return!1;for(var g=0;g<u.length&&g<l.length;g++)if(!As(l[g],u[g]))return!1;return!0}function qm(l,u,g,x,C,R){if(vo=R,Tt=u,u.memoizedState=null,u.updateQueue=null,u.lanes=0,_d.current=l===null||l.memoizedState===null?I6:O6,l=g(x,C),hc){R=0;do{if(hc=!1,fc=0,25<=R)throw Error(n(301));R+=1,Zt=Ht=null,u.updateQueue=null,_d.current=P6,l=g(x,C)}while(hc)}if(_d.current=Rd,u=Ht!==null&&Ht.next!==null,vo=0,Zt=Ht=Tt=null,Cd=!1,u)throw Error(n(300));return l}function Um(){var l=fc!==0;return fc=0,l}function cr(){var l={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Zt===null?Tt.memoizedState=Zt=l:Zt=Zt.next=l,Zt}function ls(){if(Ht===null){var l=Tt.alternate;l=l!==null?l.memoizedState:null}else l=Ht.next;var u=Zt===null?Tt.memoizedState:Zt.next;if(u!==null)Zt=u,Ht=l;else{if(l===null)throw Error(n(310));Ht=l,l={memoizedState:Ht.memoizedState,baseState:Ht.baseState,baseQueue:Ht.baseQueue,queue:Ht.queue,next:null},Zt===null?Tt.memoizedState=Zt=l:Zt=Zt.next=l}return Zt}function pc(l,u){return typeof u=="function"?u(l):u}function Wm(l){var u=ls(),g=u.queue;if(g===null)throw Error(n(311));g.lastRenderedReducer=l;var x=Ht,C=x.baseQueue,R=g.pending;if(R!==null){if(C!==null){var V=C.next;C.next=R.next,R.next=V}x.baseQueue=C=R,g.pending=null}if(C!==null){R=C.next,x=x.baseState;var Q=V=null,te=null,ue=R;do{var ve=ue.lane;if((vo&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 ke={lane:ve,action:ue.action,hasEagerState:ue.hasEagerState,eagerState:ue.eagerState,next:null};te===null?(Q=te=ke,V=x):te=te.next=ke,Tt.lanes|=ve,bo|=ve}ue=ue.next}while(ue!==null&&ue!==R);te===null?V=x:te.next=Q,As(x,u.memoizedState)||(Sn=!0),u.memoizedState=x,u.baseState=V,u.baseQueue=te,g.lastRenderedState=x}if(l=g.interleaved,l!==null){C=l;do R=C.lane,Tt.lanes|=R,bo|=R,C=C.next;while(C!==l)}else C===null&&(g.lanes=0);return[u.memoizedState,g.dispatch]}function Hm(l){var u=ls(),g=u.queue;if(g===null)throw Error(n(311));g.lastRenderedReducer=l;var x=g.dispatch,C=g.pending,R=u.memoizedState;if(C!==null){g.pending=null;var V=C=C.next;do R=l(R,V.action),V=V.next;while(V!==C);As(R,u.memoizedState)||(Sn=!0),u.memoizedState=R,u.baseQueue===null&&(u.baseState=R),g.lastRenderedState=R}return[R,x]}function iS(){}function lS(l,u){var g=Tt,x=ls(),C=u(),R=!As(x.memoizedState,C);if(R&&(x.memoizedState=C,Sn=!0),x=x.queue,zm(dS.bind(null,g,x,l),[l]),x.getSnapshot!==u||R||Zt!==null&&Zt.memoizedState.tag&1){if(g.flags|=2048,mc(9,uS.bind(null,g,x,C,u),void 0,null),Jt===null)throw Error(n(349));(vo&30)!==0||cS(g,u,C)}return C}function cS(l,u,g){l.flags|=16384,l={getSnapshot:u,value:g},u=Tt.updateQueue,u===null?(u={lastEffect:null,stores:null},Tt.updateQueue=u,u.stores=[l]):(g=u.stores,g===null?u.stores=[l]:g.push(l))}function uS(l,u,g,x){u.value=g,u.getSnapshot=x,hS(u)&&fS(l)}function dS(l,u,g){return g(function(){hS(u)&&fS(l)})}function hS(l){var u=l.getSnapshot;l=l.value;try{var g=u();return!As(l,g)}catch{return!0}}function fS(l){var u=Br(l,1);u!==null&&Os(u,l,1,-1)}function pS(l){var u=cr();return typeof l=="function"&&(l=l()),u.memoizedState=u.baseState=l,l={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:pc,lastRenderedState:l},u.queue=l,l=l.dispatch=L6.bind(null,Tt,l),[u.memoizedState,l]}function mc(l,u,g,x){return l={tag:l,create:u,destroy:g,deps:x,next:null},u=Tt.updateQueue,u===null?(u={lastEffect:null,stores:null},Tt.updateQueue=u,u.lastEffect=l.next=l):(g=u.lastEffect,g===null?u.lastEffect=l.next=l:(x=g.next,g.next=l,l.next=x,u.lastEffect=l)),l}function mS(){return ls().memoizedState}function Ed(l,u,g,x){var C=cr();Tt.flags|=l,C.memoizedState=mc(1|u,g,void 0,x===void 0?null:x)}function Td(l,u,g,x){var C=ls();x=x===void 0?null:x;var R=void 0;if(Ht!==null){var V=Ht.memoizedState;if(R=V.destroy,x!==null&&Bm(x,V.deps)){C.memoizedState=mc(u,g,R,x);return}}Tt.flags|=l,C.memoizedState=mc(1|u,g,R,x)}function gS(l,u){return Ed(8390656,8,l,u)}function zm(l,u){return Td(2048,8,l,u)}function yS(l,u){return Td(4,2,l,u)}function wS(l,u){return Td(4,4,l,u)}function xS(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 vS(l,u,g){return g=g!=null?g.concat([l]):null,Td(4,4,xS.bind(null,u,l),g)}function Vm(){}function bS(l,u){var g=ls();u=u===void 0?null:u;var x=g.memoizedState;return x!==null&&u!==null&&Bm(u,x[1])?x[0]:(g.memoizedState=[l,u],l)}function kS(l,u){var g=ls();u=u===void 0?null:u;var x=g.memoizedState;return x!==null&&u!==null&&Bm(u,x[1])?x[0]:(l=l(),g.memoizedState=[l,u],l)}function jS(l,u,g){return(vo&21)===0?(l.baseState&&(l.baseState=!1,Sn=!0),l.memoizedState=g):(As(g,u)||(g=Tr(),Tt.lanes|=g,bo|=g,l.baseState=!0),u)}function M6(l,u){var g=ct;ct=g!==0&&4>g?g:4,l(!0);var x=Fm.transition;Fm.transition={};try{l(!1),u()}finally{ct=g,Fm.transition=x}}function NS(){return ls().memoizedState}function $6(l,u,g){var x=_a(l);if(g={lane:x,action:g,hasEagerState:!1,eagerState:null,next:null},SS(l))_S(u,g);else if(g=nS(l,u,g,x),g!==null){var C=gn();Os(g,l,x,C),CS(g,u,x)}}function L6(l,u,g){var x=_a(l),C={lane:x,action:g,hasEagerState:!1,eagerState:null,next:null};if(SS(l))_S(u,C);else{var R=l.alternate;if(l.lanes===0&&(R===null||R.lanes===0)&&(R=u.lastRenderedReducer,R!==null))try{var V=u.lastRenderedState,Q=R(V,g);if(C.hasEagerState=!0,C.eagerState=Q,As(Q,V)){var te=u.interleaved;te===null?(C.next=C,$m(u)):(C.next=te.next,te.next=C),u.interleaved=C;return}}catch{}finally{}g=nS(l,u,C,x),g!==null&&(C=gn(),Os(g,l,x,C),CS(g,u,x))}}function SS(l){var u=l.alternate;return l===Tt||u!==null&&u===Tt}function _S(l,u){hc=Cd=!0;var g=l.pending;g===null?u.next=u:(u.next=g.next,g.next=u),l.pending=u}function CS(l,u,g){if((g&4194240)!==0){var x=u.lanes;x&=l.pendingLanes,g|=x,u.lanes=g,Rr(l,g)}}var Rd={readContext:is,useCallback:cn,useContext:cn,useEffect:cn,useImperativeHandle:cn,useInsertionEffect:cn,useLayoutEffect:cn,useMemo:cn,useReducer:cn,useRef:cn,useState:cn,useDebugValue:cn,useDeferredValue:cn,useTransition:cn,useMutableSource:cn,useSyncExternalStore:cn,useId:cn,unstable_isNewReconciler:!1},I6={readContext:is,useCallback:function(l,u){return cr().memoizedState=[l,u===void 0?null:u],l},useContext:is,useEffect:gS,useImperativeHandle:function(l,u,g){return g=g!=null?g.concat([l]):null,Ed(4194308,4,xS.bind(null,u,l),g)},useLayoutEffect:function(l,u){return Ed(4194308,4,l,u)},useInsertionEffect:function(l,u){return Ed(4,2,l,u)},useMemo:function(l,u){var g=cr();return u=u===void 0?null:u,l=l(),g.memoizedState=[l,u],l},useReducer:function(l,u,g){var x=cr();return u=g!==void 0?g(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=$6.bind(null,Tt,l),[x.memoizedState,l]},useRef:function(l){var u=cr();return l={current:l},u.memoizedState=l},useState:pS,useDebugValue:Vm,useDeferredValue:function(l){return cr().memoizedState=l},useTransition:function(){var l=pS(!1),u=l[0];return l=M6.bind(null,l[1]),cr().memoizedState=l,[u,l]},useMutableSource:function(){},useSyncExternalStore:function(l,u,g){var x=Tt,C=cr();if(jt){if(g===void 0)throw Error(n(407));g=g()}else{if(g=u(),Jt===null)throw Error(n(349));(vo&30)!==0||cS(x,u,g)}C.memoizedState=g;var R={value:g,getSnapshot:u};return C.queue=R,gS(dS.bind(null,x,R,l),[l]),x.flags|=2048,mc(9,uS.bind(null,x,R,g,u),void 0,null),g},useId:function(){var l=cr(),u=Jt.identifierPrefix;if(jt){var g=Fr,x=Dr;g=(x&~(1<<32-Wt(x)-1)).toString(32)+g,u=":"+u+"R"+g,g=fc++,0<g&&(u+="H"+g.toString(32)),u+=":"}else g=A6++,u=":"+u+"r"+g.toString(32)+":";return l.memoizedState=u},unstable_isNewReconciler:!1},O6={readContext:is,useCallback:bS,useContext:is,useEffect:zm,useImperativeHandle:vS,useInsertionEffect:yS,useLayoutEffect:wS,useMemo:kS,useReducer:Wm,useRef:mS,useState:function(){return Wm(pc)},useDebugValue:Vm,useDeferredValue:function(l){var u=ls();return jS(u,Ht.memoizedState,l)},useTransition:function(){var l=Wm(pc)[0],u=ls().memoizedState;return[l,u]},useMutableSource:iS,useSyncExternalStore:lS,useId:NS,unstable_isNewReconciler:!1},P6={readContext:is,useCallback:bS,useContext:is,useEffect:zm,useImperativeHandle:vS,useInsertionEffect:yS,useLayoutEffect:wS,useMemo:kS,useReducer:Hm,useRef:mS,useState:function(){return Hm(pc)},useDebugValue:Vm,useDeferredValue:function(l){var u=ls();return Ht===null?u.memoizedState=l:jS(u,Ht.memoizedState,l)},useTransition:function(){var l=Hm(pc)[0],u=ls().memoizedState;return[l,u]},useMutableSource:iS,useSyncExternalStore:lS,useId:NS,unstable_isNewReconciler:!1};function $s(l,u){if(l&&l.defaultProps){u=W({},u),l=l.defaultProps;for(var g in l)u[g]===void 0&&(u[g]=l[g]);return u}return u}function Gm(l,u,g,x){u=l.memoizedState,g=g(x,u),g=g==null?u:W({},u,g),l.memoizedState=g,l.lanes===0&&(l.updateQueue.baseState=g)}var Ad={isMounted:function(l){return(l=l._reactInternals)?Ct(l)===l:!1},enqueueSetState:function(l,u,g){l=l._reactInternals;var x=gn(),C=_a(l),R=qr(x,C);R.payload=u,g!=null&&(R.callback=g),u=ka(l,R,C),u!==null&&(Os(u,l,C,x),jd(u,l,C))},enqueueReplaceState:function(l,u,g){l=l._reactInternals;var x=gn(),C=_a(l),R=qr(x,C);R.tag=1,R.payload=u,g!=null&&(R.callback=g),u=ka(l,R,C),u!==null&&(Os(u,l,C,x),jd(u,l,C))},enqueueForceUpdate:function(l,u){l=l._reactInternals;var g=gn(),x=_a(l),C=qr(g,x);C.tag=2,u!=null&&(C.callback=u),u=ka(l,C,x),u!==null&&(Os(u,l,x,g),jd(u,l,x))}};function ES(l,u,g,x,C,R,V){return l=l.stateNode,typeof l.shouldComponentUpdate=="function"?l.shouldComponentUpdate(x,R,V):u.prototype&&u.prototype.isPureReactComponent?!tc(g,x)||!tc(C,R):!0}function TS(l,u,g){var x=!1,C=xa,R=u.contextType;return typeof R=="object"&&R!==null?R=is(R):(C=Nn(u)?mo:ln.current,x=u.contextTypes,R=(x=x!=null)?ki(l,C):xa),u=new u(g,R),l.memoizedState=u.state!==null&&u.state!==void 0?u.state:null,u.updater=Ad,l.stateNode=u,u._reactInternals=l,x&&(l=l.stateNode,l.__reactInternalMemoizedUnmaskedChildContext=C,l.__reactInternalMemoizedMaskedChildContext=R),u}function RS(l,u,g,x){l=u.state,typeof u.componentWillReceiveProps=="function"&&u.componentWillReceiveProps(g,x),typeof u.UNSAFE_componentWillReceiveProps=="function"&&u.UNSAFE_componentWillReceiveProps(g,x),u.state!==l&&Ad.enqueueReplaceState(u,u.state,null)}function Km(l,u,g,x){var C=l.stateNode;C.props=g,C.state=l.memoizedState,C.refs={},Lm(l);var R=u.contextType;typeof R=="object"&&R!==null?C.context=is(R):(R=Nn(u)?mo:ln.current,C.context=ki(l,R)),C.state=l.memoizedState,R=u.getDerivedStateFromProps,typeof R=="function"&&(Gm(l,u,R,g),C.state=l.memoizedState),typeof u.getDerivedStateFromProps=="function"||typeof C.getSnapshotBeforeUpdate=="function"||typeof C.UNSAFE_componentWillMount!="function"&&typeof C.componentWillMount!="function"||(u=C.state,typeof C.componentWillMount=="function"&&C.componentWillMount(),typeof C.UNSAFE_componentWillMount=="function"&&C.UNSAFE_componentWillMount(),u!==C.state&&Ad.enqueueReplaceState(C,C.state,null),Nd(l,g,C,x),C.state=l.memoizedState),typeof C.componentDidMount=="function"&&(l.flags|=4194308)}function Ri(l,u){try{var g="",x=u;do g+=Y(x),x=x.return;while(x);var C=g}catch(R){C=`
|
|
39
|
+
Error generating stack: `+R.message+`
|
|
40
|
+
`+R.stack}return{value:l,source:u,stack:C,digest:null}}function Ym(l,u,g){return{value:l,source:null,stack:g??null,digest:u??null}}function Xm(l,u){try{console.error(u.value)}catch(g){setTimeout(function(){throw g})}}var D6=typeof WeakMap=="function"?WeakMap:Map;function AS(l,u,g){g=qr(-1,g),g.tag=3,g.payload={element:null};var x=u.value;return g.callback=function(){Dd||(Dd=!0,dg=x),Xm(l,u)},g}function MS(l,u,g){g=qr(-1,g),g.tag=3;var x=l.type.getDerivedStateFromError;if(typeof x=="function"){var C=u.value;g.payload=function(){return x(C)},g.callback=function(){Xm(l,u)}}var R=l.stateNode;return R!==null&&typeof R.componentDidCatch=="function"&&(g.callback=function(){Xm(l,u),typeof x!="function"&&(Na===null?Na=new Set([this]):Na.add(this));var V=u.stack;this.componentDidCatch(u.value,{componentStack:V!==null?V:""})}),g}function $S(l,u,g){var x=l.pingCache;if(x===null){x=l.pingCache=new D6;var C=new Set;x.set(u,C)}else C=x.get(u),C===void 0&&(C=new Set,x.set(u,C));C.has(g)||(C.add(g),l=J6.bind(null,l,u,g),u.then(l,l))}function LS(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 IS(l,u,g,x,C){return(l.mode&1)===0?(l===u?l.flags|=65536:(l.flags|=128,g.flags|=131072,g.flags&=-52805,g.tag===1&&(g.alternate===null?g.tag=17:(u=qr(-1,1),u.tag=2,ka(g,u,1))),g.lanes|=1),l):(l.flags|=65536,l.lanes=C,l)}var F6=_.ReactCurrentOwner,Sn=!1;function mn(l,u,g,x){u.child=l===null?tS(u,null,g,x):_i(u,l.child,g,x)}function OS(l,u,g,x,C){g=g.render;var R=u.ref;return Ei(u,C),x=qm(l,u,g,x,R,C),g=Um(),l!==null&&!Sn?(u.updateQueue=l.updateQueue,u.flags&=-2053,l.lanes&=~C,Ur(l,u,C)):(jt&&g&&Nm(u),u.flags|=1,mn(l,u,x,C),u.child)}function PS(l,u,g,x,C){if(l===null){var R=g.type;return typeof R=="function"&&!wg(R)&&R.defaultProps===void 0&&g.compare===null&&g.defaultProps===void 0?(u.tag=15,u.type=R,DS(l,u,R,x,C)):(l=Hd(g.type,null,x,u,u.mode,C),l.ref=u.ref,l.return=u,u.child=l)}if(R=l.child,(l.lanes&C)===0){var V=R.memoizedProps;if(g=g.compare,g=g!==null?g:tc,g(V,x)&&l.ref===u.ref)return Ur(l,u,C)}return u.flags|=1,l=Ea(R,x),l.ref=u.ref,l.return=u,u.child=l}function DS(l,u,g,x,C){if(l!==null){var R=l.memoizedProps;if(tc(R,x)&&l.ref===u.ref)if(Sn=!1,u.pendingProps=x=R,(l.lanes&C)!==0)(l.flags&131072)!==0&&(Sn=!0);else return u.lanes=l.lanes,Ur(l,u,C)}return Zm(l,u,g,x,C)}function FS(l,u,g){var x=u.pendingProps,C=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},wt(Mi,Un),Un|=g;else{if((g&1073741824)===0)return l=R!==null?R.baseLanes|g:g,u.lanes=u.childLanes=1073741824,u.memoizedState={baseLanes:l,cachePool:null,transitions:null},u.updateQueue=null,wt(Mi,Un),Un|=l,null;u.memoizedState={baseLanes:0,cachePool:null,transitions:null},x=R!==null?R.baseLanes:g,wt(Mi,Un),Un|=x}else R!==null?(x=R.baseLanes|g,u.memoizedState=null):x=g,wt(Mi,Un),Un|=x;return mn(l,u,C,g),u.child}function BS(l,u){var g=u.ref;(l===null&&g!==null||l!==null&&l.ref!==g)&&(u.flags|=512,u.flags|=2097152)}function Zm(l,u,g,x,C){var R=Nn(g)?mo:ln.current;return R=ki(u,R),Ei(u,C),g=qm(l,u,g,x,R,C),x=Um(),l!==null&&!Sn?(u.updateQueue=l.updateQueue,u.flags&=-2053,l.lanes&=~C,Ur(l,u,C)):(jt&&x&&Nm(u),u.flags|=1,mn(l,u,g,C),u.child)}function qS(l,u,g,x,C){if(Nn(g)){var R=!0;md(u)}else R=!1;if(Ei(u,C),u.stateNode===null)$d(l,u),TS(u,g,x),Km(u,g,x,C),x=!0;else if(l===null){var V=u.stateNode,Q=u.memoizedProps;V.props=Q;var te=V.context,ue=g.contextType;typeof ue=="object"&&ue!==null?ue=is(ue):(ue=Nn(g)?mo:ln.current,ue=ki(u,ue));var ve=g.getDerivedStateFromProps,ke=typeof ve=="function"||typeof V.getSnapshotBeforeUpdate=="function";ke||typeof V.UNSAFE_componentWillReceiveProps!="function"&&typeof V.componentWillReceiveProps!="function"||(Q!==x||te!==ue)&&RS(u,V,x,ue),ba=!1;var xe=u.memoizedState;V.state=xe,Nd(u,x,V,C),te=u.memoizedState,Q!==x||xe!==te||jn.current||ba?(typeof ve=="function"&&(Gm(u,g,ve,x),te=u.memoizedState),(Q=ba||ES(u,g,Q,x,xe,te,ue))?(ke||typeof V.UNSAFE_componentWillMount!="function"&&typeof V.componentWillMount!="function"||(typeof V.componentWillMount=="function"&&V.componentWillMount(),typeof V.UNSAFE_componentWillMount=="function"&&V.UNSAFE_componentWillMount()),typeof V.componentDidMount=="function"&&(u.flags|=4194308)):(typeof V.componentDidMount=="function"&&(u.flags|=4194308),u.memoizedProps=x,u.memoizedState=te),V.props=x,V.state=te,V.context=ue,x=Q):(typeof V.componentDidMount=="function"&&(u.flags|=4194308),x=!1)}else{V=u.stateNode,sS(l,u),Q=u.memoizedProps,ue=u.type===u.elementType?Q:$s(u.type,Q),V.props=ue,ke=u.pendingProps,xe=V.context,te=g.contextType,typeof te=="object"&&te!==null?te=is(te):(te=Nn(g)?mo:ln.current,te=ki(u,te));var Ee=g.getDerivedStateFromProps;(ve=typeof Ee=="function"||typeof V.getSnapshotBeforeUpdate=="function")||typeof V.UNSAFE_componentWillReceiveProps!="function"&&typeof V.componentWillReceiveProps!="function"||(Q!==ke||xe!==te)&&RS(u,V,x,te),ba=!1,xe=u.memoizedState,V.state=xe,Nd(u,x,V,C);var Me=u.memoizedState;Q!==ke||xe!==Me||jn.current||ba?(typeof Ee=="function"&&(Gm(u,g,Ee,x),Me=u.memoizedState),(ue=ba||ES(u,g,ue,x,xe,Me,te)||!1)?(ve||typeof V.UNSAFE_componentWillUpdate!="function"&&typeof V.componentWillUpdate!="function"||(typeof V.componentWillUpdate=="function"&&V.componentWillUpdate(x,Me,te),typeof V.UNSAFE_componentWillUpdate=="function"&&V.UNSAFE_componentWillUpdate(x,Me,te)),typeof V.componentDidUpdate=="function"&&(u.flags|=4),typeof V.getSnapshotBeforeUpdate=="function"&&(u.flags|=1024)):(typeof V.componentDidUpdate!="function"||Q===l.memoizedProps&&xe===l.memoizedState||(u.flags|=4),typeof V.getSnapshotBeforeUpdate!="function"||Q===l.memoizedProps&&xe===l.memoizedState||(u.flags|=1024),u.memoizedProps=x,u.memoizedState=Me),V.props=x,V.state=Me,V.context=te,x=ue):(typeof V.componentDidUpdate!="function"||Q===l.memoizedProps&&xe===l.memoizedState||(u.flags|=4),typeof V.getSnapshotBeforeUpdate!="function"||Q===l.memoizedProps&&xe===l.memoizedState||(u.flags|=1024),x=!1)}return Jm(l,u,g,x,R,C)}function Jm(l,u,g,x,C,R){BS(l,u);var V=(u.flags&128)!==0;if(!x&&!V)return C&&VN(u,g,!1),Ur(l,u,R);x=u.stateNode,F6.current=u;var Q=V&&typeof g.getDerivedStateFromError!="function"?null:x.render();return u.flags|=1,l!==null&&V?(u.child=_i(u,l.child,null,R),u.child=_i(u,null,Q,R)):mn(l,u,Q,R),u.memoizedState=x.state,C&&VN(u,g,!0),u.child}function US(l){var u=l.stateNode;u.pendingContext?HN(l,u.pendingContext,u.pendingContext!==u.context):u.context&&HN(l,u.context,!1),Im(l,u.containerInfo)}function WS(l,u,g,x,C){return Si(),Em(C),u.flags|=256,mn(l,u,g,x),u.child}var Qm={dehydrated:null,treeContext:null,retryLane:0};function eg(l){return{baseLanes:l,cachePool:null,transitions:null}}function HS(l,u,g){var x=u.pendingProps,C=Et.current,R=!1,V=(u.flags&128)!==0,Q;if((Q=V)||(Q=l!==null&&l.memoizedState===null?!1:(C&2)!==0),Q?(R=!0,u.flags&=-129):(l===null||l.memoizedState!==null)&&(C|=1),wt(Et,C&1),l===null)return Cm(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):(V=x.children,l=x.fallback,R?(x=u.mode,R=u.child,V={mode:"hidden",children:V},(x&1)===0&&R!==null?(R.childLanes=0,R.pendingProps=V):R=zd(V,x,0,null),l=So(l,x,g,null),R.return=u,l.return=u,R.sibling=l,u.child=R,u.child.memoizedState=eg(g),u.memoizedState=Qm,l):tg(u,V));if(C=l.memoizedState,C!==null&&(Q=C.dehydrated,Q!==null))return B6(l,u,V,x,Q,C,g);if(R){R=x.fallback,V=u.mode,C=l.child,Q=C.sibling;var te={mode:"hidden",children:x.children};return(V&1)===0&&u.child!==C?(x=u.child,x.childLanes=0,x.pendingProps=te,u.deletions=null):(x=Ea(C,te),x.subtreeFlags=C.subtreeFlags&14680064),Q!==null?R=Ea(Q,R):(R=So(R,V,g,null),R.flags|=2),R.return=u,x.return=u,x.sibling=R,u.child=x,x=R,R=u.child,V=l.child.memoizedState,V=V===null?eg(g):{baseLanes:V.baseLanes|g,cachePool:null,transitions:V.transitions},R.memoizedState=V,R.childLanes=l.childLanes&~g,u.memoizedState=Qm,x}return R=l.child,l=R.sibling,x=Ea(R,{mode:"visible",children:x.children}),(u.mode&1)===0&&(x.lanes=g),x.return=u,x.sibling=null,l!==null&&(g=u.deletions,g===null?(u.deletions=[l],u.flags|=16):g.push(l)),u.child=x,u.memoizedState=null,x}function tg(l,u){return u=zd({mode:"visible",children:u},l.mode,0,null),u.return=l,l.child=u}function Md(l,u,g,x){return x!==null&&Em(x),_i(u,l.child,null,g),l=tg(u,u.pendingProps.children),l.flags|=2,u.memoizedState=null,l}function B6(l,u,g,x,C,R,V){if(g)return u.flags&256?(u.flags&=-257,x=Ym(Error(n(422))),Md(l,u,V,x)):u.memoizedState!==null?(u.child=l.child,u.flags|=128,null):(R=x.fallback,C=u.mode,x=zd({mode:"visible",children:x.children},C,0,null),R=So(R,C,V,null),R.flags|=2,x.return=u,R.return=u,x.sibling=R,u.child=x,(u.mode&1)!==0&&_i(u,l.child,null,V),u.child.memoizedState=eg(V),u.memoizedState=Qm,R);if((u.mode&1)===0)return Md(l,u,V,null);if(C.data==="$!"){if(x=C.nextSibling&&C.nextSibling.dataset,x)var Q=x.dgst;return x=Q,R=Error(n(419)),x=Ym(R,x,void 0),Md(l,u,V,x)}if(Q=(V&l.childLanes)!==0,Sn||Q){if(x=Jt,x!==null){switch(V&-V){case 4:C=2;break;case 16:C=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:C=32;break;case 536870912:C=268435456;break;default:C=0}C=(C&(x.suspendedLanes|V))!==0?0:C,C!==0&&C!==R.retryLane&&(R.retryLane=C,Br(l,C),Os(x,l,C,-1))}return yg(),x=Ym(Error(n(421))),Md(l,u,V,x)}return C.data==="$?"?(u.flags|=128,u.child=l.child,u=Q6.bind(null,l),C._reactRetry=u,null):(l=R.treeContext,qn=ya(C.nextSibling),Bn=u,jt=!0,Ms=null,l!==null&&(as[os++]=Dr,as[os++]=Fr,as[os++]=go,Dr=l.id,Fr=l.overflow,go=u),u=tg(u,x.children),u.flags|=4096,u)}function zS(l,u,g){l.lanes|=u;var x=l.alternate;x!==null&&(x.lanes|=u),Mm(l.return,u,g)}function ng(l,u,g,x,C){var R=l.memoizedState;R===null?l.memoizedState={isBackwards:u,rendering:null,renderingStartTime:0,last:x,tail:g,tailMode:C}:(R.isBackwards=u,R.rendering=null,R.renderingStartTime=0,R.last=x,R.tail=g,R.tailMode=C)}function VS(l,u,g){var x=u.pendingProps,C=x.revealOrder,R=x.tail;if(mn(l,u,x.children,g),x=Et.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&&zS(l,g,u);else if(l.tag===19)zS(l,g,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(wt(Et,x),(u.mode&1)===0)u.memoizedState=null;else switch(C){case"forwards":for(g=u.child,C=null;g!==null;)l=g.alternate,l!==null&&Sd(l)===null&&(C=g),g=g.sibling;g=C,g===null?(C=u.child,u.child=null):(C=g.sibling,g.sibling=null),ng(u,!1,C,g,R);break;case"backwards":for(g=null,C=u.child,u.child=null;C!==null;){if(l=C.alternate,l!==null&&Sd(l)===null){u.child=C;break}l=C.sibling,C.sibling=g,g=C,C=l}ng(u,!0,g,null,R);break;case"together":ng(u,!1,null,null,void 0);break;default:u.memoizedState=null}return u.child}function $d(l,u){(u.mode&1)===0&&l!==null&&(l.alternate=null,u.alternate=null,u.flags|=2)}function Ur(l,u,g){if(l!==null&&(u.dependencies=l.dependencies),bo|=u.lanes,(g&u.childLanes)===0)return null;if(l!==null&&u.child!==l.child)throw Error(n(153));if(u.child!==null){for(l=u.child,g=Ea(l,l.pendingProps),u.child=g,g.return=u;l.sibling!==null;)l=l.sibling,g=g.sibling=Ea(l,l.pendingProps),g.return=u;g.sibling=null}return u.child}function q6(l,u,g){switch(u.tag){case 3:US(u),Si();break;case 5:oS(u);break;case 1:Nn(u.type)&&md(u);break;case 4:Im(u,u.stateNode.containerInfo);break;case 10:var x=u.type._context,C=u.memoizedProps.value;wt(bd,x._currentValue),x._currentValue=C;break;case 13:if(x=u.memoizedState,x!==null)return x.dehydrated!==null?(wt(Et,Et.current&1),u.flags|=128,null):(g&u.child.childLanes)!==0?HS(l,u,g):(wt(Et,Et.current&1),l=Ur(l,u,g),l!==null?l.sibling:null);wt(Et,Et.current&1);break;case 19:if(x=(g&u.childLanes)!==0,(l.flags&128)!==0){if(x)return VS(l,u,g);u.flags|=128}if(C=u.memoizedState,C!==null&&(C.rendering=null,C.tail=null,C.lastEffect=null),wt(Et,Et.current),x)break;return null;case 22:case 23:return u.lanes=0,FS(l,u,g)}return Ur(l,u,g)}var GS,sg,KS,YS;GS=function(l,u){for(var g=u.child;g!==null;){if(g.tag===5||g.tag===6)l.appendChild(g.stateNode);else if(g.tag!==4&&g.child!==null){g.child.return=g,g=g.child;continue}if(g===u)break;for(;g.sibling===null;){if(g.return===null||g.return===u)return;g=g.return}g.sibling.return=g.return,g=g.sibling}},sg=function(){},KS=function(l,u,g,x){var C=l.memoizedProps;if(C!==x){l=u.stateNode,xo(lr.current);var R=null;switch(g){case"input":C=ae(l,C),x=ae(l,x),R=[];break;case"select":C=W({},C,{value:void 0}),x=W({},x,{value:void 0}),R=[];break;case"textarea":C=Pe(l,C),x=Pe(l,x),R=[];break;default:typeof C.onClick!="function"&&typeof x.onClick=="function"&&(l.onclick=hd)}Be(g,x);var V;g=null;for(ue in C)if(!x.hasOwnProperty(ue)&&C.hasOwnProperty(ue)&&C[ue]!=null)if(ue==="style"){var Q=C[ue];for(V in Q)Q.hasOwnProperty(V)&&(g||(g={}),g[V]="")}else ue!=="dangerouslySetInnerHTML"&&ue!=="children"&&ue!=="suppressContentEditableWarning"&&ue!=="suppressHydrationWarning"&&ue!=="autoFocus"&&(a.hasOwnProperty(ue)?R||(R=[]):(R=R||[]).push(ue,null));for(ue in x){var te=x[ue];if(Q=C!=null?C[ue]:void 0,x.hasOwnProperty(ue)&&te!==Q&&(te!=null||Q!=null))if(ue==="style")if(Q){for(V in Q)!Q.hasOwnProperty(V)||te&&te.hasOwnProperty(V)||(g||(g={}),g[V]="");for(V in te)te.hasOwnProperty(V)&&Q[V]!==te[V]&&(g||(g={}),g[V]=te[V])}else g||(R||(R=[]),R.push(ue,g)),g=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"&&(a.hasOwnProperty(ue)?(te!=null&&ue==="onScroll"&&bt("scroll",l),R||Q===te||(R=[])):(R=R||[]).push(ue,te))}g&&(R=R||[]).push("style",g);var ue=R;(u.updateQueue=ue)&&(u.flags|=4)}},YS=function(l,u,g,x){g!==x&&(u.flags|=4)};function gc(l,u){if(!jt)switch(l.tailMode){case"hidden":u=l.tail;for(var g=null;u!==null;)u.alternate!==null&&(g=u),u=u.sibling;g===null?l.tail=null:g.sibling=null;break;case"collapsed":g=l.tail;for(var x=null;g!==null;)g.alternate!==null&&(x=g),g=g.sibling;x===null?u||l.tail===null?l.tail=null:l.tail.sibling=null:x.sibling=null}}function un(l){var u=l.alternate!==null&&l.alternate.child===l.child,g=0,x=0;if(u)for(var C=l.child;C!==null;)g|=C.lanes|C.childLanes,x|=C.subtreeFlags&14680064,x|=C.flags&14680064,C.return=l,C=C.sibling;else for(C=l.child;C!==null;)g|=C.lanes|C.childLanes,x|=C.subtreeFlags,x|=C.flags,C.return=l,C=C.sibling;return l.subtreeFlags|=x,l.childLanes=g,u}function U6(l,u,g){var x=u.pendingProps;switch(Sm(u),u.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return un(u),null;case 1:return Nn(u.type)&&pd(),un(u),null;case 3:return x=u.stateNode,Ti(),kt(jn),kt(ln),Dm(),x.pendingContext&&(x.context=x.pendingContext,x.pendingContext=null),(l===null||l.child===null)&&(xd(u)?u.flags|=4:l===null||l.memoizedState.isDehydrated&&(u.flags&256)===0||(u.flags|=1024,Ms!==null&&(pg(Ms),Ms=null))),sg(l,u),un(u),null;case 5:Om(u);var C=xo(dc.current);if(g=u.type,l!==null&&u.stateNode!=null)KS(l,u,g,x,C),l.ref!==u.ref&&(u.flags|=512,u.flags|=2097152);else{if(!x){if(u.stateNode===null)throw Error(n(166));return un(u),null}if(l=xo(lr.current),xd(u)){x=u.stateNode,g=u.type;var R=u.memoizedProps;switch(x[ir]=u,x[oc]=R,l=(u.mode&1)!==0,g){case"dialog":bt("cancel",x),bt("close",x);break;case"iframe":case"object":case"embed":bt("load",x);break;case"video":case"audio":for(C=0;C<sc.length;C++)bt(sc[C],x);break;case"source":bt("error",x);break;case"img":case"image":case"link":bt("error",x),bt("load",x);break;case"details":bt("toggle",x);break;case"input":de(x,R),bt("invalid",x);break;case"select":x._wrapperState={wasMultiple:!!R.multiple},bt("invalid",x);break;case"textarea":Oe(x,R),bt("invalid",x)}Be(g,R),C=null;for(var V in R)if(R.hasOwnProperty(V)){var Q=R[V];V==="children"?typeof Q=="string"?x.textContent!==Q&&(R.suppressHydrationWarning!==!0&&dd(x.textContent,Q,l),C=["children",Q]):typeof Q=="number"&&x.textContent!==""+Q&&(R.suppressHydrationWarning!==!0&&dd(x.textContent,Q,l),C=["children",""+Q]):a.hasOwnProperty(V)&&Q!=null&&V==="onScroll"&&bt("scroll",x)}switch(g){case"input":he(x),me(x,R,!0);break;case"textarea":he(x),Re(x);break;case"select":case"option":break;default:typeof R.onClick=="function"&&(x.onclick=hd)}x=C,u.updateQueue=x,x!==null&&(u.flags|=4)}else{V=C.nodeType===9?C:C.ownerDocument,l==="http://www.w3.org/1999/xhtml"&&(l=st(g)),l==="http://www.w3.org/1999/xhtml"?g==="script"?(l=V.createElement("div"),l.innerHTML="<script><\/script>",l=l.removeChild(l.firstChild)):typeof x.is=="string"?l=V.createElement(g,{is:x.is}):(l=V.createElement(g),g==="select"&&(V=l,x.multiple?V.multiple=!0:x.size&&(V.size=x.size))):l=V.createElementNS(l,g),l[ir]=u,l[oc]=x,GS(l,u,!1,!1),u.stateNode=l;e:{switch(V=Ye(g,x),g){case"dialog":bt("cancel",l),bt("close",l),C=x;break;case"iframe":case"object":case"embed":bt("load",l),C=x;break;case"video":case"audio":for(C=0;C<sc.length;C++)bt(sc[C],l);C=x;break;case"source":bt("error",l),C=x;break;case"img":case"image":case"link":bt("error",l),bt("load",l),C=x;break;case"details":bt("toggle",l),C=x;break;case"input":de(l,x),C=ae(l,x),bt("invalid",l);break;case"option":C=x;break;case"select":l._wrapperState={wasMultiple:!!x.multiple},C=W({},x,{value:void 0}),bt("invalid",l);break;case"textarea":Oe(l,x),C=Pe(l,x),bt("invalid",l);break;default:C=x}Be(g,C),Q=C;for(R in Q)if(Q.hasOwnProperty(R)){var te=Q[R];R==="style"?nt(l,te):R==="dangerouslySetInnerHTML"?(te=te?te.__html:void 0,te!=null&&$e(l,te)):R==="children"?typeof te=="string"?(g!=="textarea"||te!=="")&&Ge(l,te):typeof te=="number"&&Ge(l,""+te):R!=="suppressContentEditableWarning"&&R!=="suppressHydrationWarning"&&R!=="autoFocus"&&(a.hasOwnProperty(R)?te!=null&&R==="onScroll"&&bt("scroll",l):te!=null&&S(l,R,te,V))}switch(g){case"input":he(l),me(l,x,!1);break;case"textarea":he(l),Re(l);break;case"option":x.value!=null&&l.setAttribute("value",""+J(x.value));break;case"select":l.multiple=!!x.multiple,R=x.value,R!=null?ye(l,!!x.multiple,R,!1):x.defaultValue!=null&&ye(l,!!x.multiple,x.defaultValue,!0);break;default:typeof C.onClick=="function"&&(l.onclick=hd)}switch(g){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 un(u),null;case 6:if(l&&u.stateNode!=null)YS(l,u,l.memoizedProps,x);else{if(typeof x!="string"&&u.stateNode===null)throw Error(n(166));if(g=xo(dc.current),xo(lr.current),xd(u)){if(x=u.stateNode,g=u.memoizedProps,x[ir]=u,(R=x.nodeValue!==g)&&(l=Bn,l!==null))switch(l.tag){case 3:dd(x.nodeValue,g,(l.mode&1)!==0);break;case 5:l.memoizedProps.suppressHydrationWarning!==!0&&dd(x.nodeValue,g,(l.mode&1)!==0)}R&&(u.flags|=4)}else x=(g.nodeType===9?g:g.ownerDocument).createTextNode(x),x[ir]=u,u.stateNode=x}return un(u),null;case 13:if(kt(Et),x=u.memoizedState,l===null||l.memoizedState!==null&&l.memoizedState.dehydrated!==null){if(jt&&qn!==null&&(u.mode&1)!==0&&(u.flags&128)===0)JN(),Si(),u.flags|=98560,R=!1;else if(R=xd(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[ir]=u}else Si(),(u.flags&128)===0&&(u.memoizedState=null),u.flags|=4;un(u),R=!1}else Ms!==null&&(pg(Ms),Ms=null),R=!0;if(!R)return u.flags&65536?u:null}return(u.flags&128)!==0?(u.lanes=g,u):(x=x!==null,x!==(l!==null&&l.memoizedState!==null)&&x&&(u.child.flags|=8192,(u.mode&1)!==0&&(l===null||(Et.current&1)!==0?zt===0&&(zt=3):yg())),u.updateQueue!==null&&(u.flags|=4),un(u),null);case 4:return Ti(),sg(l,u),l===null&&rc(u.stateNode.containerInfo),un(u),null;case 10:return Am(u.type._context),un(u),null;case 17:return Nn(u.type)&&pd(),un(u),null;case 19:if(kt(Et),R=u.memoizedState,R===null)return un(u),null;if(x=(u.flags&128)!==0,V=R.rendering,V===null)if(x)gc(R,!1);else{if(zt!==0||l!==null&&(l.flags&128)!==0)for(l=u.child;l!==null;){if(V=Sd(l),V!==null){for(u.flags|=128,gc(R,!1),x=V.updateQueue,x!==null&&(u.updateQueue=x,u.flags|=4),u.subtreeFlags=0,x=g,g=u.child;g!==null;)R=g,l=x,R.flags&=14680066,V=R.alternate,V===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=V.childLanes,R.lanes=V.lanes,R.child=V.child,R.subtreeFlags=0,R.deletions=null,R.memoizedProps=V.memoizedProps,R.memoizedState=V.memoizedState,R.updateQueue=V.updateQueue,R.type=V.type,l=V.dependencies,R.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext}),g=g.sibling;return wt(Et,Et.current&1|2),u.child}l=l.sibling}R.tail!==null&&dt()>$i&&(u.flags|=128,x=!0,gc(R,!1),u.lanes=4194304)}else{if(!x)if(l=Sd(V),l!==null){if(u.flags|=128,x=!0,g=l.updateQueue,g!==null&&(u.updateQueue=g,u.flags|=4),gc(R,!0),R.tail===null&&R.tailMode==="hidden"&&!V.alternate&&!jt)return un(u),null}else 2*dt()-R.renderingStartTime>$i&&g!==1073741824&&(u.flags|=128,x=!0,gc(R,!1),u.lanes=4194304);R.isBackwards?(V.sibling=u.child,u.child=V):(g=R.last,g!==null?g.sibling=V:u.child=V,R.last=V)}return R.tail!==null?(u=R.tail,R.rendering=u,R.tail=u.sibling,R.renderingStartTime=dt(),u.sibling=null,g=Et.current,wt(Et,x?g&1|2:g&1),u):(un(u),null);case 22:case 23:return gg(),x=u.memoizedState!==null,l!==null&&l.memoizedState!==null!==x&&(u.flags|=8192),x&&(u.mode&1)!==0?(Un&1073741824)!==0&&(un(u),u.subtreeFlags&6&&(u.flags|=8192)):un(u),null;case 24:return null;case 25:return null}throw Error(n(156,u.tag))}function W6(l,u){switch(Sm(u),u.tag){case 1:return Nn(u.type)&&pd(),l=u.flags,l&65536?(u.flags=l&-65537|128,u):null;case 3:return Ti(),kt(jn),kt(ln),Dm(),l=u.flags,(l&65536)!==0&&(l&128)===0?(u.flags=l&-65537|128,u):null;case 5:return Om(u),null;case 13:if(kt(Et),l=u.memoizedState,l!==null&&l.dehydrated!==null){if(u.alternate===null)throw Error(n(340));Si()}return l=u.flags,l&65536?(u.flags=l&-65537|128,u):null;case 19:return kt(Et),null;case 4:return Ti(),null;case 10:return Am(u.type._context),null;case 22:case 23:return gg(),null;case 24:return null;default:return null}}var Ld=!1,dn=!1,H6=typeof WeakSet=="function"?WeakSet:Set,Ae=null;function Ai(l,u){var g=l.ref;if(g!==null)if(typeof g=="function")try{g(null)}catch(x){$t(l,u,x)}else g.current=null}function rg(l,u,g){try{g()}catch(x){$t(l,u,x)}}var XS=!1;function z6(l,u){if(gm=ci,l=EN(),lm(l)){if("selectionStart"in l)var g={start:l.selectionStart,end:l.selectionEnd};else e:{g=(g=l.ownerDocument)&&g.defaultView||window;var x=g.getSelection&&g.getSelection();if(x&&x.rangeCount!==0){g=x.anchorNode;var C=x.anchorOffset,R=x.focusNode;x=x.focusOffset;try{g.nodeType,R.nodeType}catch{g=null;break e}var V=0,Q=-1,te=-1,ue=0,ve=0,ke=l,xe=null;t:for(;;){for(var Ee;ke!==g||C!==0&&ke.nodeType!==3||(Q=V+C),ke!==R||x!==0&&ke.nodeType!==3||(te=V+x),ke.nodeType===3&&(V+=ke.nodeValue.length),(Ee=ke.firstChild)!==null;)xe=ke,ke=Ee;for(;;){if(ke===l)break t;if(xe===g&&++ue===C&&(Q=V),xe===R&&++ve===x&&(te=V),(Ee=ke.nextSibling)!==null)break;ke=xe,xe=ke.parentNode}ke=Ee}g=Q===-1||te===-1?null:{start:Q,end:te}}else g=null}g=g||{start:0,end:0}}else g=null;for(ym={focusedElem:l,selectionRange:g},ci=!1,Ae=u;Ae!==null;)if(u=Ae,l=u.child,(u.subtreeFlags&1028)!==0&&l!==null)l.return=u,Ae=l;else for(;Ae!==null;){u=Ae;try{var Me=u.alternate;if((u.flags&1024)!==0)switch(u.tag){case 0:case 11:case 15:break;case 1:if(Me!==null){var Le=Me.memoizedProps,Pt=Me.memoizedState,oe=u.stateNode,se=oe.getSnapshotBeforeUpdate(u.elementType===u.type?Le:$s(u.type,Le),Pt);oe.__reactInternalSnapshotBeforeUpdate=se}break;case 3:var ie=u.stateNode.containerInfo;ie.nodeType===1?ie.textContent="":ie.nodeType===9&&ie.documentElement&&ie.removeChild(ie.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(Ne){$t(u,u.return,Ne)}if(l=u.sibling,l!==null){l.return=u.return,Ae=l;break}Ae=u.return}return Me=XS,XS=!1,Me}function yc(l,u,g){var x=u.updateQueue;if(x=x!==null?x.lastEffect:null,x!==null){var C=x=x.next;do{if((C.tag&l)===l){var R=C.destroy;C.destroy=void 0,R!==void 0&&rg(u,g,R)}C=C.next}while(C!==x)}}function Id(l,u){if(u=u.updateQueue,u=u!==null?u.lastEffect:null,u!==null){var g=u=u.next;do{if((g.tag&l)===l){var x=g.create;g.destroy=x()}g=g.next}while(g!==u)}}function ag(l){var u=l.ref;if(u!==null){var g=l.stateNode;switch(l.tag){case 5:l=g;break;default:l=g}typeof u=="function"?u(l):u.current=l}}function ZS(l){var u=l.alternate;u!==null&&(l.alternate=null,ZS(u)),l.child=null,l.deletions=null,l.sibling=null,l.tag===5&&(u=l.stateNode,u!==null&&(delete u[ir],delete u[oc],delete u[bm],delete u[C6],delete u[E6])),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 JS(l){return l.tag===5||l.tag===3||l.tag===4}function QS(l){e:for(;;){for(;l.sibling===null;){if(l.return===null||JS(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 og(l,u,g){var x=l.tag;if(x===5||x===6)l=l.stateNode,u?g.nodeType===8?g.parentNode.insertBefore(l,u):g.insertBefore(l,u):(g.nodeType===8?(u=g.parentNode,u.insertBefore(l,g)):(u=g,u.appendChild(l)),g=g._reactRootContainer,g!=null||u.onclick!==null||(u.onclick=hd));else if(x!==4&&(l=l.child,l!==null))for(og(l,u,g),l=l.sibling;l!==null;)og(l,u,g),l=l.sibling}function ig(l,u,g){var x=l.tag;if(x===5||x===6)l=l.stateNode,u?g.insertBefore(l,u):g.appendChild(l);else if(x!==4&&(l=l.child,l!==null))for(ig(l,u,g),l=l.sibling;l!==null;)ig(l,u,g),l=l.sibling}var rn=null,Ls=!1;function ja(l,u,g){for(g=g.child;g!==null;)e_(l,u,g),g=g.sibling}function e_(l,u,g){if(nn&&typeof nn.onCommitFiberUnmount=="function")try{nn.onCommitFiberUnmount(es,g)}catch{}switch(g.tag){case 5:dn||Ai(g,u);case 6:var x=rn,C=Ls;rn=null,ja(l,u,g),rn=x,Ls=C,rn!==null&&(Ls?(l=rn,g=g.stateNode,l.nodeType===8?l.parentNode.removeChild(g):l.removeChild(g)):rn.removeChild(g.stateNode));break;case 18:rn!==null&&(Ls?(l=rn,g=g.stateNode,l.nodeType===8?vm(l.parentNode,g):l.nodeType===1&&vm(l,g),io(l)):vm(rn,g.stateNode));break;case 4:x=rn,C=Ls,rn=g.stateNode.containerInfo,Ls=!0,ja(l,u,g),rn=x,Ls=C;break;case 0:case 11:case 14:case 15:if(!dn&&(x=g.updateQueue,x!==null&&(x=x.lastEffect,x!==null))){C=x=x.next;do{var R=C,V=R.destroy;R=R.tag,V!==void 0&&((R&2)!==0||(R&4)!==0)&&rg(g,u,V),C=C.next}while(C!==x)}ja(l,u,g);break;case 1:if(!dn&&(Ai(g,u),x=g.stateNode,typeof x.componentWillUnmount=="function"))try{x.props=g.memoizedProps,x.state=g.memoizedState,x.componentWillUnmount()}catch(Q){$t(g,u,Q)}ja(l,u,g);break;case 21:ja(l,u,g);break;case 22:g.mode&1?(dn=(x=dn)||g.memoizedState!==null,ja(l,u,g),dn=x):ja(l,u,g);break;default:ja(l,u,g)}}function t_(l){var u=l.updateQueue;if(u!==null){l.updateQueue=null;var g=l.stateNode;g===null&&(g=l.stateNode=new H6),u.forEach(function(x){var C=e8.bind(null,l,x);g.has(x)||(g.add(x),x.then(C,C))})}}function Is(l,u){var g=u.deletions;if(g!==null)for(var x=0;x<g.length;x++){var C=g[x];try{var R=l,V=u,Q=V;e:for(;Q!==null;){switch(Q.tag){case 5:rn=Q.stateNode,Ls=!1;break e;case 3:rn=Q.stateNode.containerInfo,Ls=!0;break e;case 4:rn=Q.stateNode.containerInfo,Ls=!0;break e}Q=Q.return}if(rn===null)throw Error(n(160));e_(R,V,C),rn=null,Ls=!1;var te=C.alternate;te!==null&&(te.return=null),C.return=null}catch(ue){$t(C,u,ue)}}if(u.subtreeFlags&12854)for(u=u.child;u!==null;)n_(u,l),u=u.sibling}function n_(l,u){var g=l.alternate,x=l.flags;switch(l.tag){case 0:case 11:case 14:case 15:if(Is(u,l),ur(l),x&4){try{yc(3,l,l.return),Id(3,l)}catch(Le){$t(l,l.return,Le)}try{yc(5,l,l.return)}catch(Le){$t(l,l.return,Le)}}break;case 1:Is(u,l),ur(l),x&512&&g!==null&&Ai(g,g.return);break;case 5:if(Is(u,l),ur(l),x&512&&g!==null&&Ai(g,g.return),l.flags&32){var C=l.stateNode;try{Ge(C,"")}catch(Le){$t(l,l.return,Le)}}if(x&4&&(C=l.stateNode,C!=null)){var R=l.memoizedProps,V=g!==null?g.memoizedProps:R,Q=l.type,te=l.updateQueue;if(l.updateQueue=null,te!==null)try{Q==="input"&&R.type==="radio"&&R.name!=null&&Se(C,R),Ye(Q,V);var ue=Ye(Q,R);for(V=0;V<te.length;V+=2){var ve=te[V],ke=te[V+1];ve==="style"?nt(C,ke):ve==="dangerouslySetInnerHTML"?$e(C,ke):ve==="children"?Ge(C,ke):S(C,ve,ke,ue)}switch(Q){case"input":pe(C,R);break;case"textarea":We(C,R);break;case"select":var xe=C._wrapperState.wasMultiple;C._wrapperState.wasMultiple=!!R.multiple;var Ee=R.value;Ee!=null?ye(C,!!R.multiple,Ee,!1):xe!==!!R.multiple&&(R.defaultValue!=null?ye(C,!!R.multiple,R.defaultValue,!0):ye(C,!!R.multiple,R.multiple?[]:"",!1))}C[oc]=R}catch(Le){$t(l,l.return,Le)}}break;case 6:if(Is(u,l),ur(l),x&4){if(l.stateNode===null)throw Error(n(162));C=l.stateNode,R=l.memoizedProps;try{C.nodeValue=R}catch(Le){$t(l,l.return,Le)}}break;case 3:if(Is(u,l),ur(l),x&4&&g!==null&&g.memoizedState.isDehydrated)try{io(u.containerInfo)}catch(Le){$t(l,l.return,Le)}break;case 4:Is(u,l),ur(l);break;case 13:Is(u,l),ur(l),C=l.child,C.flags&8192&&(R=C.memoizedState!==null,C.stateNode.isHidden=R,!R||C.alternate!==null&&C.alternate.memoizedState!==null||(ug=dt())),x&4&&t_(l);break;case 22:if(ve=g!==null&&g.memoizedState!==null,l.mode&1?(dn=(ue=dn)||ve,Is(u,l),dn=ue):Is(u,l),ur(l),x&8192){if(ue=l.memoizedState!==null,(l.stateNode.isHidden=ue)&&!ve&&(l.mode&1)!==0)for(Ae=l,ve=l.child;ve!==null;){for(ke=Ae=ve;Ae!==null;){switch(xe=Ae,Ee=xe.child,xe.tag){case 0:case 11:case 14:case 15:yc(4,xe,xe.return);break;case 1:Ai(xe,xe.return);var Me=xe.stateNode;if(typeof Me.componentWillUnmount=="function"){x=xe,g=xe.return;try{u=x,Me.props=u.memoizedProps,Me.state=u.memoizedState,Me.componentWillUnmount()}catch(Le){$t(x,g,Le)}}break;case 5:Ai(xe,xe.return);break;case 22:if(xe.memoizedState!==null){a_(ke);continue}}Ee!==null?(Ee.return=xe,Ae=Ee):a_(ke)}ve=ve.sibling}e:for(ve=null,ke=l;;){if(ke.tag===5){if(ve===null){ve=ke;try{C=ke.stateNode,ue?(R=C.style,typeof R.setProperty=="function"?R.setProperty("display","none","important"):R.display="none"):(Q=ke.stateNode,te=ke.memoizedProps.style,V=te!=null&&te.hasOwnProperty("display")?te.display:null,Q.style.display=it("display",V))}catch(Le){$t(l,l.return,Le)}}}else if(ke.tag===6){if(ve===null)try{ke.stateNode.nodeValue=ue?"":ke.memoizedProps}catch(Le){$t(l,l.return,Le)}}else if((ke.tag!==22&&ke.tag!==23||ke.memoizedState===null||ke===l)&&ke.child!==null){ke.child.return=ke,ke=ke.child;continue}if(ke===l)break e;for(;ke.sibling===null;){if(ke.return===null||ke.return===l)break e;ve===ke&&(ve=null),ke=ke.return}ve===ke&&(ve=null),ke.sibling.return=ke.return,ke=ke.sibling}}break;case 19:Is(u,l),ur(l),x&4&&t_(l);break;case 21:break;default:Is(u,l),ur(l)}}function ur(l){var u=l.flags;if(u&2){try{e:{for(var g=l.return;g!==null;){if(JS(g)){var x=g;break e}g=g.return}throw Error(n(160))}switch(x.tag){case 5:var C=x.stateNode;x.flags&32&&(Ge(C,""),x.flags&=-33);var R=QS(l);ig(l,R,C);break;case 3:case 4:var V=x.stateNode.containerInfo,Q=QS(l);og(l,Q,V);break;default:throw Error(n(161))}}catch(te){$t(l,l.return,te)}l.flags&=-3}u&4096&&(l.flags&=-4097)}function V6(l,u,g){Ae=l,s_(l)}function s_(l,u,g){for(var x=(l.mode&1)!==0;Ae!==null;){var C=Ae,R=C.child;if(C.tag===22&&x){var V=C.memoizedState!==null||Ld;if(!V){var Q=C.alternate,te=Q!==null&&Q.memoizedState!==null||dn;Q=Ld;var ue=dn;if(Ld=V,(dn=te)&&!ue)for(Ae=C;Ae!==null;)V=Ae,te=V.child,V.tag===22&&V.memoizedState!==null?o_(C):te!==null?(te.return=V,Ae=te):o_(C);for(;R!==null;)Ae=R,s_(R),R=R.sibling;Ae=C,Ld=Q,dn=ue}r_(l)}else(C.subtreeFlags&8772)!==0&&R!==null?(R.return=C,Ae=R):r_(l)}}function r_(l){for(;Ae!==null;){var u=Ae;if((u.flags&8772)!==0){var g=u.alternate;try{if((u.flags&8772)!==0)switch(u.tag){case 0:case 11:case 15:dn||Id(5,u);break;case 1:var x=u.stateNode;if(u.flags&4&&!dn)if(g===null)x.componentDidMount();else{var C=u.elementType===u.type?g.memoizedProps:$s(u.type,g.memoizedProps);x.componentDidUpdate(C,g.memoizedState,x.__reactInternalSnapshotBeforeUpdate)}var R=u.updateQueue;R!==null&&aS(u,R,x);break;case 3:var V=u.updateQueue;if(V!==null){if(g=null,u.child!==null)switch(u.child.tag){case 5:g=u.child.stateNode;break;case 1:g=u.child.stateNode}aS(u,V,g)}break;case 5:var Q=u.stateNode;if(g===null&&u.flags&4){g=Q;var te=u.memoizedProps;switch(u.type){case"button":case"input":case"select":case"textarea":te.autoFocus&&g.focus();break;case"img":te.src&&(g.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 ke=ve.dehydrated;ke!==null&&io(ke)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}dn||u.flags&512&&ag(u)}catch(xe){$t(u,u.return,xe)}}if(u===l){Ae=null;break}if(g=u.sibling,g!==null){g.return=u.return,Ae=g;break}Ae=u.return}}function a_(l){for(;Ae!==null;){var u=Ae;if(u===l){Ae=null;break}var g=u.sibling;if(g!==null){g.return=u.return,Ae=g;break}Ae=u.return}}function o_(l){for(;Ae!==null;){var u=Ae;try{switch(u.tag){case 0:case 11:case 15:var g=u.return;try{Id(4,u)}catch(te){$t(u,g,te)}break;case 1:var x=u.stateNode;if(typeof x.componentDidMount=="function"){var C=u.return;try{x.componentDidMount()}catch(te){$t(u,C,te)}}var R=u.return;try{ag(u)}catch(te){$t(u,R,te)}break;case 5:var V=u.return;try{ag(u)}catch(te){$t(u,V,te)}}}catch(te){$t(u,u.return,te)}if(u===l){Ae=null;break}var Q=u.sibling;if(Q!==null){Q.return=u.return,Ae=Q;break}Ae=u.return}}var G6=Math.ceil,Od=_.ReactCurrentDispatcher,lg=_.ReactCurrentOwner,cs=_.ReactCurrentBatchConfig,rt=0,Jt=null,qt=null,an=0,Un=0,Mi=wa(0),zt=0,wc=null,bo=0,Pd=0,cg=0,xc=null,_n=null,ug=0,$i=1/0,Wr=null,Dd=!1,dg=null,Na=null,Fd=!1,Sa=null,Bd=0,vc=0,hg=null,qd=-1,Ud=0;function gn(){return(rt&6)!==0?dt():qd!==-1?qd:qd=dt()}function _a(l){return(l.mode&1)===0?1:(rt&2)!==0&&an!==0?an&-an:R6.transition!==null?(Ud===0&&(Ud=Tr()),Ud):(l=ct,l!==0||(l=window.event,l=l===void 0?16:Wl(l.type)),l)}function Os(l,u,g,x){if(50<vc)throw vc=0,hg=null,Error(n(185));nr(l,g,x),((rt&2)===0||l!==Jt)&&(l===Jt&&((rt&2)===0&&(Pd|=g),zt===4&&Ca(l,an)),Cn(l,x),g===1&&rt===0&&(u.mode&1)===0&&($i=dt()+500,gd&&va()))}function Cn(l,u){var g=l.callbackNode;Mt(l,u);var x=Ve(l,l===Jt?an:0);if(x===0)g!==null&&Js(g),l.callbackNode=null,l.callbackPriority=0;else if(u=x&-x,l.callbackPriority!==u){if(g!=null&&Js(g),u===1)l.tag===0?T6(l_.bind(null,l)):GN(l_.bind(null,l)),S6(function(){(rt&6)===0&&va()}),g=null;else{switch(Ol(x)){case 1:g=Cr;break;case 4:g=Qs;break;case 16:g=Ts;break;case 536870912:g=Er;break;default:g=Ts}g=g_(g,i_.bind(null,l))}l.callbackPriority=u,l.callbackNode=g}}function i_(l,u){if(qd=-1,Ud=0,(rt&6)!==0)throw Error(n(327));var g=l.callbackNode;if(Li()&&l.callbackNode!==g)return null;var x=Ve(l,l===Jt?an:0);if(x===0)return null;if((x&30)!==0||(x&l.expiredLanes)!==0||u)u=Wd(l,x);else{u=x;var C=rt;rt|=2;var R=u_();(Jt!==l||an!==u)&&(Wr=null,$i=dt()+500,jo(l,u));do try{X6();break}catch(Q){c_(l,Q)}while(!0);Rm(),Od.current=R,rt=C,qt!==null?u=0:(Jt=null,an=0,u=zt)}if(u!==0){if(u===2&&(C=ss(l),C!==0&&(x=C,u=fg(l,C))),u===1)throw g=wc,jo(l,0),Ca(l,x),Cn(l,dt()),g;if(u===6)Ca(l,x);else{if(C=l.current.alternate,(x&30)===0&&!K6(C)&&(u=Wd(l,x),u===2&&(R=ss(l),R!==0&&(x=R,u=fg(l,R))),u===1))throw g=wc,jo(l,0),Ca(l,x),Cn(l,dt()),g;switch(l.finishedWork=C,l.finishedLanes=x,u){case 0:case 1:throw Error(n(345));case 2:No(l,_n,Wr);break;case 3:if(Ca(l,x),(x&130023424)===x&&(u=ug+500-dt(),10<u)){if(Ve(l,0)!==0)break;if(C=l.suspendedLanes,(C&x)!==x){gn(),l.pingedLanes|=l.suspendedLanes&C;break}l.timeoutHandle=xm(No.bind(null,l,_n,Wr),u);break}No(l,_n,Wr);break;case 4:if(Ca(l,x),(x&4194240)===x)break;for(u=l.eventTimes,C=-1;0<x;){var V=31-Wt(x);R=1<<V,V=u[V],V>C&&(C=V),x&=~R}if(x=C,x=dt()-x,x=(120>x?120:480>x?480:1080>x?1080:1920>x?1920:3e3>x?3e3:4320>x?4320:1960*G6(x/1960))-x,10<x){l.timeoutHandle=xm(No.bind(null,l,_n,Wr),x);break}No(l,_n,Wr);break;case 5:No(l,_n,Wr);break;default:throw Error(n(329))}}}return Cn(l,dt()),l.callbackNode===g?i_.bind(null,l):null}function fg(l,u){var g=xc;return l.current.memoizedState.isDehydrated&&(jo(l,u).flags|=256),l=Wd(l,u),l!==2&&(u=_n,_n=g,u!==null&&pg(u)),l}function pg(l){_n===null?_n=l:_n.push.apply(_n,l)}function K6(l){for(var u=l;;){if(u.flags&16384){var g=u.updateQueue;if(g!==null&&(g=g.stores,g!==null))for(var x=0;x<g.length;x++){var C=g[x],R=C.getSnapshot;C=C.value;try{if(!As(R(),C))return!1}catch{return!1}}}if(g=u.child,u.subtreeFlags&16384&&g!==null)g.return=u,u=g;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 Ca(l,u){for(u&=~cg,u&=~Pd,l.suspendedLanes|=u,l.pingedLanes&=~u,l=l.expirationTimes;0<u;){var g=31-Wt(u),x=1<<g;l[g]=-1,u&=~x}}function l_(l){if((rt&6)!==0)throw Error(n(327));Li();var u=Ve(l,0);if((u&1)===0)return Cn(l,dt()),null;var g=Wd(l,u);if(l.tag!==0&&g===2){var x=ss(l);x!==0&&(u=x,g=fg(l,x))}if(g===1)throw g=wc,jo(l,0),Ca(l,u),Cn(l,dt()),g;if(g===6)throw Error(n(345));return l.finishedWork=l.current.alternate,l.finishedLanes=u,No(l,_n,Wr),Cn(l,dt()),null}function mg(l,u){var g=rt;rt|=1;try{return l(u)}finally{rt=g,rt===0&&($i=dt()+500,gd&&va())}}function ko(l){Sa!==null&&Sa.tag===0&&(rt&6)===0&&Li();var u=rt;rt|=1;var g=cs.transition,x=ct;try{if(cs.transition=null,ct=1,l)return l()}finally{ct=x,cs.transition=g,rt=u,(rt&6)===0&&va()}}function gg(){Un=Mi.current,kt(Mi)}function jo(l,u){l.finishedWork=null,l.finishedLanes=0;var g=l.timeoutHandle;if(g!==-1&&(l.timeoutHandle=-1,N6(g)),qt!==null)for(g=qt.return;g!==null;){var x=g;switch(Sm(x),x.tag){case 1:x=x.type.childContextTypes,x!=null&&pd();break;case 3:Ti(),kt(jn),kt(ln),Dm();break;case 5:Om(x);break;case 4:Ti();break;case 13:kt(Et);break;case 19:kt(Et);break;case 10:Am(x.type._context);break;case 22:case 23:gg()}g=g.return}if(Jt=l,qt=l=Ea(l.current,null),an=Un=u,zt=0,wc=null,cg=Pd=bo=0,_n=xc=null,wo!==null){for(u=0;u<wo.length;u++)if(g=wo[u],x=g.interleaved,x!==null){g.interleaved=null;var C=x.next,R=g.pending;if(R!==null){var V=R.next;R.next=C,x.next=V}g.pending=x}wo=null}return l}function c_(l,u){do{var g=qt;try{if(Rm(),_d.current=Rd,Cd){for(var x=Tt.memoizedState;x!==null;){var C=x.queue;C!==null&&(C.pending=null),x=x.next}Cd=!1}if(vo=0,Zt=Ht=Tt=null,hc=!1,fc=0,lg.current=null,g===null||g.return===null){zt=1,wc=u,qt=null;break}e:{var R=l,V=g.return,Q=g,te=u;if(u=an,Q.flags|=32768,te!==null&&typeof te=="object"&&typeof te.then=="function"){var ue=te,ve=Q,ke=ve.tag;if((ve.mode&1)===0&&(ke===0||ke===11||ke===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 Ee=LS(V);if(Ee!==null){Ee.flags&=-257,IS(Ee,V,Q,R,u),Ee.mode&1&&$S(R,ue,u),u=Ee,te=ue;var Me=u.updateQueue;if(Me===null){var Le=new Set;Le.add(te),u.updateQueue=Le}else Me.add(te);break e}else{if((u&1)===0){$S(R,ue,u),yg();break e}te=Error(n(426))}}else if(jt&&Q.mode&1){var Pt=LS(V);if(Pt!==null){(Pt.flags&65536)===0&&(Pt.flags|=256),IS(Pt,V,Q,R,u),Em(Ri(te,Q));break e}}R=te=Ri(te,Q),zt!==4&&(zt=2),xc===null?xc=[R]:xc.push(R),R=V;do{switch(R.tag){case 3:R.flags|=65536,u&=-u,R.lanes|=u;var oe=AS(R,te,u);rS(R,oe);break e;case 1:Q=te;var se=R.type,ie=R.stateNode;if((R.flags&128)===0&&(typeof se.getDerivedStateFromError=="function"||ie!==null&&typeof ie.componentDidCatch=="function"&&(Na===null||!Na.has(ie)))){R.flags|=65536,u&=-u,R.lanes|=u;var Ne=MS(R,Q,u);rS(R,Ne);break e}}R=R.return}while(R!==null)}h_(g)}catch(Ie){u=Ie,qt===g&&g!==null&&(qt=g=g.return);continue}break}while(!0)}function u_(){var l=Od.current;return Od.current=Rd,l===null?Rd:l}function yg(){(zt===0||zt===3||zt===2)&&(zt=4),Jt===null||(bo&268435455)===0&&(Pd&268435455)===0||Ca(Jt,an)}function Wd(l,u){var g=rt;rt|=2;var x=u_();(Jt!==l||an!==u)&&(Wr=null,jo(l,u));do try{Y6();break}catch(C){c_(l,C)}while(!0);if(Rm(),rt=g,Od.current=x,qt!==null)throw Error(n(261));return Jt=null,an=0,zt}function Y6(){for(;qt!==null;)d_(qt)}function X6(){for(;qt!==null&&!Es();)d_(qt)}function d_(l){var u=m_(l.alternate,l,Un);l.memoizedProps=l.pendingProps,u===null?h_(l):qt=u,lg.current=null}function h_(l){var u=l;do{var g=u.alternate;if(l=u.return,(u.flags&32768)===0){if(g=U6(g,u,Un),g!==null){qt=g;return}}else{if(g=W6(g,u),g!==null){g.flags&=32767,qt=g;return}if(l!==null)l.flags|=32768,l.subtreeFlags=0,l.deletions=null;else{zt=6,qt=null;return}}if(u=u.sibling,u!==null){qt=u;return}qt=u=l}while(u!==null);zt===0&&(zt=5)}function No(l,u,g){var x=ct,C=cs.transition;try{cs.transition=null,ct=1,Z6(l,u,g,x)}finally{cs.transition=C,ct=x}return null}function Z6(l,u,g,x){do Li();while(Sa!==null);if((rt&6)!==0)throw Error(n(327));g=l.finishedWork;var C=l.finishedLanes;if(g===null)return null;if(l.finishedWork=null,l.finishedLanes=0,g===l.current)throw Error(n(177));l.callbackNode=null,l.callbackPriority=0;var R=g.lanes|g.childLanes;if(Fn(l,R),l===Jt&&(qt=Jt=null,an=0),(g.subtreeFlags&2064)===0&&(g.flags&2064)===0||Fd||(Fd=!0,g_(Ts,function(){return Li(),null})),R=(g.flags&15990)!==0,(g.subtreeFlags&15990)!==0||R){R=cs.transition,cs.transition=null;var V=ct;ct=1;var Q=rt;rt|=4,lg.current=null,z6(l,g),n_(g,l),y6(ym),ci=!!gm,ym=gm=null,l.current=g,V6(g),_r(),rt=Q,ct=V,cs.transition=R}else l.current=g;if(Fd&&(Fd=!1,Sa=l,Bd=C),R=l.pendingLanes,R===0&&(Na=null),er(g.stateNode),Cn(l,dt()),u!==null)for(x=l.onRecoverableError,g=0;g<u.length;g++)C=u[g],x(C.value,{componentStack:C.stack,digest:C.digest});if(Dd)throw Dd=!1,l=dg,dg=null,l;return(Bd&1)!==0&&l.tag!==0&&Li(),R=l.pendingLanes,(R&1)!==0?l===hg?vc++:(vc=0,hg=l):vc=0,va(),null}function Li(){if(Sa!==null){var l=Ol(Bd),u=cs.transition,g=ct;try{if(cs.transition=null,ct=16>l?16:l,Sa===null)var x=!1;else{if(l=Sa,Sa=null,Bd=0,(rt&6)!==0)throw Error(n(331));var C=rt;for(rt|=4,Ae=l.current;Ae!==null;){var R=Ae,V=R.child;if((Ae.flags&16)!==0){var Q=R.deletions;if(Q!==null){for(var te=0;te<Q.length;te++){var ue=Q[te];for(Ae=ue;Ae!==null;){var ve=Ae;switch(ve.tag){case 0:case 11:case 15:yc(8,ve,R)}var ke=ve.child;if(ke!==null)ke.return=ve,Ae=ke;else for(;Ae!==null;){ve=Ae;var xe=ve.sibling,Ee=ve.return;if(ZS(ve),ve===ue){Ae=null;break}if(xe!==null){xe.return=Ee,Ae=xe;break}Ae=Ee}}}var Me=R.alternate;if(Me!==null){var Le=Me.child;if(Le!==null){Me.child=null;do{var Pt=Le.sibling;Le.sibling=null,Le=Pt}while(Le!==null)}}Ae=R}}if((R.subtreeFlags&2064)!==0&&V!==null)V.return=R,Ae=V;else e:for(;Ae!==null;){if(R=Ae,(R.flags&2048)!==0)switch(R.tag){case 0:case 11:case 15:yc(9,R,R.return)}var oe=R.sibling;if(oe!==null){oe.return=R.return,Ae=oe;break e}Ae=R.return}}var se=l.current;for(Ae=se;Ae!==null;){V=Ae;var ie=V.child;if((V.subtreeFlags&2064)!==0&&ie!==null)ie.return=V,Ae=ie;else e:for(V=se;Ae!==null;){if(Q=Ae,(Q.flags&2048)!==0)try{switch(Q.tag){case 0:case 11:case 15:Id(9,Q)}}catch(Ie){$t(Q,Q.return,Ie)}if(Q===V){Ae=null;break e}var Ne=Q.sibling;if(Ne!==null){Ne.return=Q.return,Ae=Ne;break e}Ae=Q.return}}if(rt=C,va(),nn&&typeof nn.onPostCommitFiberRoot=="function")try{nn.onPostCommitFiberRoot(es,l)}catch{}x=!0}return x}finally{ct=g,cs.transition=u}}return!1}function f_(l,u,g){u=Ri(g,u),u=AS(l,u,1),l=ka(l,u,1),u=gn(),l!==null&&(nr(l,1,u),Cn(l,u))}function $t(l,u,g){if(l.tag===3)f_(l,l,g);else for(;u!==null;){if(u.tag===3){f_(u,l,g);break}else if(u.tag===1){var x=u.stateNode;if(typeof u.type.getDerivedStateFromError=="function"||typeof x.componentDidCatch=="function"&&(Na===null||!Na.has(x))){l=Ri(g,l),l=MS(u,l,1),u=ka(u,l,1),l=gn(),u!==null&&(nr(u,1,l),Cn(u,l));break}}u=u.return}}function J6(l,u,g){var x=l.pingCache;x!==null&&x.delete(u),u=gn(),l.pingedLanes|=l.suspendedLanes&g,Jt===l&&(an&g)===g&&(zt===4||zt===3&&(an&130023424)===an&&500>dt()-ug?jo(l,0):cg|=g),Cn(l,u)}function p_(l,u){u===0&&((l.mode&1)===0?u=1:(u=ns,ns<<=1,(ns&130023424)===0&&(ns=4194304)));var g=gn();l=Br(l,u),l!==null&&(nr(l,u,g),Cn(l,g))}function Q6(l){var u=l.memoizedState,g=0;u!==null&&(g=u.retryLane),p_(l,g)}function e8(l,u){var g=0;switch(l.tag){case 13:var x=l.stateNode,C=l.memoizedState;C!==null&&(g=C.retryLane);break;case 19:x=l.stateNode;break;default:throw Error(n(314))}x!==null&&x.delete(u),p_(l,g)}var m_;m_=function(l,u,g){if(l!==null)if(l.memoizedProps!==u.pendingProps||jn.current)Sn=!0;else{if((l.lanes&g)===0&&(u.flags&128)===0)return Sn=!1,q6(l,u,g);Sn=(l.flags&131072)!==0}else Sn=!1,jt&&(u.flags&1048576)!==0&&KN(u,wd,u.index);switch(u.lanes=0,u.tag){case 2:var x=u.type;$d(l,u),l=u.pendingProps;var C=ki(u,ln.current);Ei(u,g),C=qm(null,u,x,l,C,g);var R=Um();return u.flags|=1,typeof C=="object"&&C!==null&&typeof C.render=="function"&&C.$$typeof===void 0?(u.tag=1,u.memoizedState=null,u.updateQueue=null,Nn(x)?(R=!0,md(u)):R=!1,u.memoizedState=C.state!==null&&C.state!==void 0?C.state:null,Lm(u),C.updater=Ad,u.stateNode=C,C._reactInternals=u,Km(u,x,l,g),u=Jm(null,u,x,!0,R,g)):(u.tag=0,jt&&R&&Nm(u),mn(null,u,C,g),u=u.child),u;case 16:x=u.elementType;e:{switch($d(l,u),l=u.pendingProps,C=x._init,x=C(x._payload),u.type=x,C=u.tag=n8(x),l=$s(x,l),C){case 0:u=Zm(null,u,x,l,g);break e;case 1:u=qS(null,u,x,l,g);break e;case 11:u=OS(null,u,x,l,g);break e;case 14:u=PS(null,u,x,$s(x.type,l),g);break e}throw Error(n(306,x,""))}return u;case 0:return x=u.type,C=u.pendingProps,C=u.elementType===x?C:$s(x,C),Zm(l,u,x,C,g);case 1:return x=u.type,C=u.pendingProps,C=u.elementType===x?C:$s(x,C),qS(l,u,x,C,g);case 3:e:{if(US(u),l===null)throw Error(n(387));x=u.pendingProps,R=u.memoizedState,C=R.element,sS(l,u),Nd(u,x,null,g);var V=u.memoizedState;if(x=V.element,R.isDehydrated)if(R={element:x,isDehydrated:!1,cache:V.cache,pendingSuspenseBoundaries:V.pendingSuspenseBoundaries,transitions:V.transitions},u.updateQueue.baseState=R,u.memoizedState=R,u.flags&256){C=Ri(Error(n(423)),u),u=WS(l,u,x,g,C);break e}else if(x!==C){C=Ri(Error(n(424)),u),u=WS(l,u,x,g,C);break e}else for(qn=ya(u.stateNode.containerInfo.firstChild),Bn=u,jt=!0,Ms=null,g=tS(u,null,x,g),u.child=g;g;)g.flags=g.flags&-3|4096,g=g.sibling;else{if(Si(),x===C){u=Ur(l,u,g);break e}mn(l,u,x,g)}u=u.child}return u;case 5:return oS(u),l===null&&Cm(u),x=u.type,C=u.pendingProps,R=l!==null?l.memoizedProps:null,V=C.children,wm(x,C)?V=null:R!==null&&wm(x,R)&&(u.flags|=32),BS(l,u),mn(l,u,V,g),u.child;case 6:return l===null&&Cm(u),null;case 13:return HS(l,u,g);case 4:return Im(u,u.stateNode.containerInfo),x=u.pendingProps,l===null?u.child=_i(u,null,x,g):mn(l,u,x,g),u.child;case 11:return x=u.type,C=u.pendingProps,C=u.elementType===x?C:$s(x,C),OS(l,u,x,C,g);case 7:return mn(l,u,u.pendingProps,g),u.child;case 8:return mn(l,u,u.pendingProps.children,g),u.child;case 12:return mn(l,u,u.pendingProps.children,g),u.child;case 10:e:{if(x=u.type._context,C=u.pendingProps,R=u.memoizedProps,V=C.value,wt(bd,x._currentValue),x._currentValue=V,R!==null)if(As(R.value,V)){if(R.children===C.children&&!jn.current){u=Ur(l,u,g);break e}}else for(R=u.child,R!==null&&(R.return=u);R!==null;){var Q=R.dependencies;if(Q!==null){V=R.child;for(var te=Q.firstContext;te!==null;){if(te.context===x){if(R.tag===1){te=qr(-1,g&-g),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|=g,te=R.alternate,te!==null&&(te.lanes|=g),Mm(R.return,g,u),Q.lanes|=g;break}te=te.next}}else if(R.tag===10)V=R.type===u.type?null:R.child;else if(R.tag===18){if(V=R.return,V===null)throw Error(n(341));V.lanes|=g,Q=V.alternate,Q!==null&&(Q.lanes|=g),Mm(V,g,u),V=R.sibling}else V=R.child;if(V!==null)V.return=R;else for(V=R;V!==null;){if(V===u){V=null;break}if(R=V.sibling,R!==null){R.return=V.return,V=R;break}V=V.return}R=V}mn(l,u,C.children,g),u=u.child}return u;case 9:return C=u.type,x=u.pendingProps.children,Ei(u,g),C=is(C),x=x(C),u.flags|=1,mn(l,u,x,g),u.child;case 14:return x=u.type,C=$s(x,u.pendingProps),C=$s(x.type,C),PS(l,u,x,C,g);case 15:return DS(l,u,u.type,u.pendingProps,g);case 17:return x=u.type,C=u.pendingProps,C=u.elementType===x?C:$s(x,C),$d(l,u),u.tag=1,Nn(x)?(l=!0,md(u)):l=!1,Ei(u,g),TS(u,x,C),Km(u,x,C,g),Jm(null,u,x,!0,l,g);case 19:return VS(l,u,g);case 22:return FS(l,u,g)}throw Error(n(156,u.tag))};function g_(l,u){return Ft(l,u)}function t8(l,u,g,x){this.tag=l,this.key=g,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 us(l,u,g,x){return new t8(l,u,g,x)}function wg(l){return l=l.prototype,!(!l||!l.isReactComponent)}function n8(l){if(typeof l=="function")return wg(l)?1:0;if(l!=null){if(l=l.$$typeof,l===T)return 11;if(l===q)return 14}return 2}function Ea(l,u){var g=l.alternate;return g===null?(g=us(l.tag,u,l.key,l.mode),g.elementType=l.elementType,g.type=l.type,g.stateNode=l.stateNode,g.alternate=l,l.alternate=g):(g.pendingProps=u,g.type=l.type,g.flags=0,g.subtreeFlags=0,g.deletions=null),g.flags=l.flags&14680064,g.childLanes=l.childLanes,g.lanes=l.lanes,g.child=l.child,g.memoizedProps=l.memoizedProps,g.memoizedState=l.memoizedState,g.updateQueue=l.updateQueue,u=l.dependencies,g.dependencies=u===null?null:{lanes:u.lanes,firstContext:u.firstContext},g.sibling=l.sibling,g.index=l.index,g.ref=l.ref,g}function Hd(l,u,g,x,C,R){var V=2;if(x=l,typeof l=="function")wg(l)&&(V=1);else if(typeof l=="string")V=5;else e:switch(l){case A:return So(g.children,C,R,u);case O:V=8,C|=8;break;case L:return l=us(12,g,u,C|2),l.elementType=L,l.lanes=R,l;case B:return l=us(13,g,u,C),l.elementType=B,l.lanes=R,l;case M:return l=us(19,g,u,C),l.elementType=M,l.lanes=R,l;case K:return zd(g,C,R,u);default:if(typeof l=="object"&&l!==null)switch(l.$$typeof){case U:V=10;break e;case P:V=9;break e;case T:V=11;break e;case q:V=14;break e;case $:V=16,x=null;break e}throw Error(n(130,l==null?l:typeof l,""))}return u=us(V,g,u,C),u.elementType=l,u.type=x,u.lanes=R,u}function So(l,u,g,x){return l=us(7,l,x,u),l.lanes=g,l}function zd(l,u,g,x){return l=us(22,l,x,u),l.elementType=K,l.lanes=g,l.stateNode={isHidden:!1},l}function xg(l,u,g){return l=us(6,l,null,u),l.lanes=g,l}function vg(l,u,g){return u=us(4,l.children!==null?l.children:[],l.key,u),u.lanes=g,u.stateNode={containerInfo:l.containerInfo,pendingChildren:null,implementation:l.implementation},u}function s8(l,u,g,x,C){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=ca(0),this.expirationTimes=ca(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=ca(0),this.identifierPrefix=x,this.onRecoverableError=C,this.mutableSourceEagerHydrationData=null}function bg(l,u,g,x,C,R,V,Q,te){return l=new s8(l,u,g,Q,te),u===1?(u=1,R===!0&&(u|=8)):u=0,R=us(3,null,null,u),l.current=R,R.stateNode=l,R.memoizedState={element:x,isDehydrated:g,cache:null,transitions:null,pendingSuspenseBoundaries:null},Lm(R),l}function r8(l,u,g){var x=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:I,key:x==null?null:""+x,children:l,containerInfo:u,implementation:g}}function y_(l){if(!l)return xa;l=l._reactInternals;e:{if(Ct(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(Nn(u.type)){u=u.stateNode.__reactInternalMemoizedMergedChildContext;break e}}u=u.return}while(u!==null);throw Error(n(171))}if(l.tag===1){var g=l.type;if(Nn(g))return zN(l,g,u)}return u}function w_(l,u,g,x,C,R,V,Q,te){return l=bg(g,x,!0,l,C,R,V,Q,te),l.context=y_(null),g=l.current,x=gn(),C=_a(g),R=qr(x,C),R.callback=u??null,ka(g,R,C),l.current.lanes=C,nr(l,C,x),Cn(l,x),l}function Vd(l,u,g,x){var C=u.current,R=gn(),V=_a(C);return g=y_(g),u.context===null?u.context=g:u.pendingContext=g,u=qr(R,V),u.payload={element:l},x=x===void 0?null:x,x!==null&&(u.callback=x),l=ka(C,u,V),l!==null&&(Os(l,C,V,R),jd(l,C,V)),V}function Gd(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 x_(l,u){if(l=l.memoizedState,l!==null&&l.dehydrated!==null){var g=l.retryLane;l.retryLane=g!==0&&g<u?g:u}}function kg(l,u){x_(l,u),(l=l.alternate)&&x_(l,u)}function a8(){return null}var v_=typeof reportError=="function"?reportError:function(l){console.error(l)};function jg(l){this._internalRoot=l}Kd.prototype.render=jg.prototype.render=function(l){var u=this._internalRoot;if(u===null)throw Error(n(409));Vd(l,u,null,null)},Kd.prototype.unmount=jg.prototype.unmount=function(){var l=this._internalRoot;if(l!==null){this._internalRoot=null;var u=l.containerInfo;ko(function(){Vd(null,l,null,null)}),u[Or]=null}};function Kd(l){this._internalRoot=l}Kd.prototype.unstable_scheduleHydration=function(l){if(l){var u=sr();l={blockedOn:null,target:l,priority:u};for(var g=0;g<ar.length&&u!==0&&u<ar[g].priority;g++);ar.splice(g,0,l),g===0&&ql(l)}};function Ng(l){return!(!l||l.nodeType!==1&&l.nodeType!==9&&l.nodeType!==11)}function Yd(l){return!(!l||l.nodeType!==1&&l.nodeType!==9&&l.nodeType!==11&&(l.nodeType!==8||l.nodeValue!==" react-mount-point-unstable "))}function b_(){}function o8(l,u,g,x,C){if(C){if(typeof x=="function"){var R=x;x=function(){var ue=Gd(V);R.call(ue)}}var V=w_(u,x,l,0,null,!1,!1,"",b_);return l._reactRootContainer=V,l[Or]=V.current,rc(l.nodeType===8?l.parentNode:l),ko(),V}for(;C=l.lastChild;)l.removeChild(C);if(typeof x=="function"){var Q=x;x=function(){var ue=Gd(te);Q.call(ue)}}var te=bg(l,0,!1,null,null,!1,!1,"",b_);return l._reactRootContainer=te,l[Or]=te.current,rc(l.nodeType===8?l.parentNode:l),ko(function(){Vd(u,te,g,x)}),te}function Xd(l,u,g,x,C){var R=g._reactRootContainer;if(R){var V=R;if(typeof C=="function"){var Q=C;C=function(){var te=Gd(V);Q.call(te)}}Vd(u,V,l,C)}else V=o8(g,u,l,C,x);return Gd(V)}Pl=function(l){switch(l.tag){case 3:var u=l.stateNode;if(u.current.memoizedState.isDehydrated){var g=ge(u.pendingLanes);g!==0&&(Rr(u,g|1),Cn(u,dt()),(rt&6)===0&&($i=dt()+500,va()))}break;case 13:ko(function(){var x=Br(l,1);if(x!==null){var C=gn();Os(x,l,1,C)}}),kg(l,1)}},ao=function(l){if(l.tag===13){var u=Br(l,134217728);if(u!==null){var g=gn();Os(u,l,134217728,g)}kg(l,134217728)}},oi=function(l){if(l.tag===13){var u=_a(l),g=Br(l,u);if(g!==null){var x=gn();Os(g,l,u,x)}kg(l,u)}},sr=function(){return ct},Ju=function(l,u){var g=ct;try{return ct=l,u()}finally{ct=g}},St=function(l,u,g){switch(u){case"input":if(pe(l,g),u=g.name,g.type==="radio"&&u!=null){for(g=l;g.parentNode;)g=g.parentNode;for(g=g.querySelectorAll("input[name="+JSON.stringify(""+u)+'][type="radio"]'),u=0;u<g.length;u++){var x=g[u];if(x!==l&&x.form===l.form){var C=fd(x);if(!C)throw Error(n(90));le(x),pe(x,C)}}}break;case"textarea":We(l,g);break;case"select":u=g.value,u!=null&&ye(l,!!g.multiple,u,!1)}},js=mg,Zn=ko;var i8={usingClientEntryPoint:!1,Events:[ic,vi,fd,ks,Xs,mg]},bc={findFiberByHostInstance:po,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},l8={bundleType:bc.bundleType,version:bc.version,rendererPackageName:bc.rendererPackageName,rendererConfig:bc.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:_.ReactCurrentDispatcher,findHostInstanceByFiber:function(l){return l=Cs(l),l===null?null:l.stateNode},findFiberByHostInstance:bc.findFiberByHostInstance||a8,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 Zd=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Zd.isDisabled&&Zd.supportsFiber)try{es=Zd.inject(l8),nn=Zd}catch{}}return En.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=i8,En.createPortal=function(l,u){var g=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Ng(u))throw Error(n(200));return r8(l,u,null,g)},En.createRoot=function(l,u){if(!Ng(l))throw Error(n(299));var g=!1,x="",C=v_;return u!=null&&(u.unstable_strictMode===!0&&(g=!0),u.identifierPrefix!==void 0&&(x=u.identifierPrefix),u.onRecoverableError!==void 0&&(C=u.onRecoverableError)),u=bg(l,1,!1,null,null,g,!1,x,C),l[Or]=u.current,rc(l.nodeType===8?l.parentNode:l),new jg(u)},En.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=Cs(u),l=l===null?null:l.stateNode,l},En.flushSync=function(l){return ko(l)},En.hydrate=function(l,u,g){if(!Yd(u))throw Error(n(200));return Xd(null,l,u,!0,g)},En.hydrateRoot=function(l,u,g){if(!Ng(l))throw Error(n(405));var x=g!=null&&g.hydratedSources||null,C=!1,R="",V=v_;if(g!=null&&(g.unstable_strictMode===!0&&(C=!0),g.identifierPrefix!==void 0&&(R=g.identifierPrefix),g.onRecoverableError!==void 0&&(V=g.onRecoverableError)),u=w_(u,null,l,1,g??null,C,!1,R,V),l[Or]=u.current,rc(l),x)for(l=0;l<x.length;l++)g=x[l],C=g._getVersion,C=C(g._source),u.mutableSourceEagerHydrationData==null?u.mutableSourceEagerHydrationData=[g,C]:u.mutableSourceEagerHydrationData.push(g,C);return new Kd(u)},En.render=function(l,u,g){if(!Yd(u))throw Error(n(200));return Xd(null,l,u,!1,g)},En.unmountComponentAtNode=function(l){if(!Yd(l))throw Error(n(40));return l._reactRootContainer?(ko(function(){Xd(null,null,l,!1,function(){l._reactRootContainer=null,l[Or]=null})}),!0):!1},En.unstable_batchedUpdates=mg,En.unstable_renderSubtreeIntoContainer=function(l,u,g,x){if(!Yd(g))throw Error(n(200));if(l==null||l._reactInternals===void 0)throw Error(n(38));return Xd(l,u,g,!1,x)},En.version="18.3.1-next-f1338f8080-20240426",En}var T_;function TI(){if(T_)return Eg.exports;T_=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(),Eg.exports=y8(),Eg.exports}var R_;function w8(){if(R_)return Qd;R_=1;var e=TI();return Qd.createRoot=e.createRoot,Qd.hydrateRoot=e.hydrateRoot,Qd}var x8=w8(),y=Tu();const fe=y1(y);function on(e){if(typeof e=="string"||typeof e=="number")return""+e;let t="";if(Array.isArray(e))for(let n=0,s;n<e.length;n++)(s=on(e[n]))!==""&&(t+=(t&&" ")+s);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var Ag={exports:{}},Mg={},$g={exports:{}},Lg={};/**
|
|
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 A_;function v8(){if(A_)return Lg;A_=1;var e=Tu();function t(p,m){return p===m&&(p!==0||1/p===1/m)||p!==p&&m!==m}var n=typeof Object.is=="function"?Object.is:t,s=e.useState,a=e.useEffect,o=e.useLayoutEffect,i=e.useDebugValue;function c(p,m){var w=m(),j=s({inst:{value:w,getSnapshot:m}}),v=j[0].inst,b=j[1];return o(function(){v.value=w,v.getSnapshot=m,d(v)&&b({inst:v})},[p,w,m]),a(function(){return d(v)&&b({inst:v}),p(function(){d(v)&&b({inst:v})})},[p]),i(w),w}function d(p){var m=p.getSnapshot;p=p.value;try{var w=m();return!n(p,w)}catch{return!0}}function h(p,m){return m()}var f=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?h:c;return Lg.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:f,Lg}var M_;function b8(){return M_||(M_=1,$g.exports=v8()),$g.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 $_;function k8(){if($_)return Mg;$_=1;var e=Tu(),t=b8();function n(h,f){return h===f&&(h!==0||1/h===1/f)||h!==h&&f!==f}var s=typeof Object.is=="function"?Object.is:n,a=t.useSyncExternalStore,o=e.useRef,i=e.useEffect,c=e.useMemo,d=e.useDebugValue;return Mg.useSyncExternalStoreWithSelector=function(h,f,p,m,w){var j=o(null);if(j.current===null){var v={hasValue:!1,value:null};j.current=v}else v=j.current;j=c(function(){function k(I){if(!N){if(N=!0,S=I,I=m(I),w!==void 0&&v.hasValue){var A=v.value;if(w(A,I))return _=A}return _=I}if(A=_,s(S,I))return A;var O=m(I);return w!==void 0&&w(A,O)?(S=I,A):(S=I,_=O)}var N=!1,S,_,E=p===void 0?null:p;return[function(){return k(f())},E===null?void 0:function(){return k(E())}]},[f,p,m,w]);var b=a(h,j[0],j[1]);return i(function(){v.hasValue=!0,v.value=b},[b]),d(b),b},Mg}var L_;function j8(){return L_||(L_=1,Ag.exports=k8()),Ag.exports}var N8=j8();const S8=y1(N8),_8={},I_=e=>{let t;const n=new Set,s=(f,p)=>{const m=typeof f=="function"?f(t):f;if(!Object.is(m,t)){const w=t;t=p??(typeof m!="object"||m===null)?m:Object.assign({},t,m),n.forEach(j=>j(t,w))}},a=()=>t,d={setState:s,getState:a,getInitialState:()=>h,subscribe:f=>(n.add(f),()=>n.delete(f)),destroy:()=>{(_8?"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(s,a,d);return d},C8=e=>e?I_(e):I_,{useDebugValue:E8}=fe,{useSyncExternalStoreWithSelector:T8}=S8,R8=e=>e;function RI(e,t=R8,n){const s=T8(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return E8(s),s}const O_=(e,t)=>{const n=C8(e),s=(a,o=t)=>RI(n,a,o);return Object.assign(s,n),s},A8=(e,t)=>e?O_(e,t):O_;function Xt(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[s,a]of e)if(!Object.is(a,t.get(s)))return!1;return!0}if(e instanceof Set&&t instanceof Set){if(e.size!==t.size)return!1;for(const s of e)if(!t.has(s))return!1;return!0}const n=Object.keys(e);if(n.length!==Object.keys(t).length)return!1;for(const s of n)if(!Object.prototype.hasOwnProperty.call(t,s)||!Object.is(e[s],t[s]))return!1;return!0}var M8={value:()=>{}};function Uf(){for(var e=0,t=arguments.length,n={},s;e<t;++e){if(!(s=arguments[e]+"")||s in n||/[\s.]/.test(s))throw new Error("illegal type: "+s);n[s]=[]}return new Ah(n)}function Ah(e){this._=e}function $8(e,t){return e.trim().split(/^|\s+/).map(function(n){var s="",a=n.indexOf(".");if(a>=0&&(s=n.slice(a+1),n=n.slice(0,a)),n&&!t.hasOwnProperty(n))throw new Error("unknown type: "+n);return{type:n,name:s}})}Ah.prototype=Uf.prototype={constructor:Ah,on:function(e,t){var n=this._,s=$8(e+"",n),a,o=-1,i=s.length;if(arguments.length<2){for(;++o<i;)if((a=(e=s[o]).type)&&(a=L8(n[a],e.name)))return a;return}if(t!=null&&typeof t!="function")throw new Error("invalid callback: "+t);for(;++o<i;)if(a=(e=s[o]).type)n[a]=P_(n[a],e.name,t);else if(t==null)for(a in n)n[a]=P_(n[a],e.name,null);return this},copy:function(){var e={},t=this._;for(var n in t)e[n]=t[n].slice();return new Ah(e)},call:function(e,t){if((a=arguments.length-2)>0)for(var n=new Array(a),s=0,a,o;s<a;++s)n[s]=arguments[s+2];if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(o=this._[e],s=0,a=o.length;s<a;++s)o[s].value.apply(t,n)},apply:function(e,t,n){if(!this._.hasOwnProperty(e))throw new Error("unknown type: "+e);for(var s=this._[e],a=0,o=s.length;a<o;++a)s[a].value.apply(t,n)}};function L8(e,t){for(var n=0,s=e.length,a;n<s;++n)if((a=e[n]).name===t)return a.value}function P_(e,t,n){for(var s=0,a=e.length;s<a;++s)if(e[s].name===t){e[s]=M8,e=e.slice(0,s).concat(e.slice(s+1));break}return n!=null&&e.push({name:t,value:n}),e}var Hk="http://www.w3.org/1999/xhtml";const D_={svg:"http://www.w3.org/2000/svg",xhtml:Hk,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Wf(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),D_.hasOwnProperty(t)?{space:D_[t],local:e}:e}function I8(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Hk&&t.documentElement.namespaceURI===Hk?t.createElement(e):t.createElementNS(n,e)}}function O8(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function AI(e){var t=Wf(e);return(t.local?O8:I8)(t)}function P8(){}function w1(e){return e==null?P8:function(){return this.querySelector(e)}}function D8(e){typeof e!="function"&&(e=w1(e));for(var t=this._groups,n=t.length,s=new Array(n),a=0;a<n;++a)for(var o=t[a],i=o.length,c=s[a]=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 Kn(s,this._parents)}function F8(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function B8(){return[]}function MI(e){return e==null?B8:function(){return this.querySelectorAll(e)}}function q8(e){return function(){return F8(e.apply(this,arguments))}}function U8(e){typeof e=="function"?e=q8(e):e=MI(e);for(var t=this._groups,n=t.length,s=[],a=[],o=0;o<n;++o)for(var i=t[o],c=i.length,d,h=0;h<c;++h)(d=i[h])&&(s.push(e.call(d,d.__data__,h,i)),a.push(d));return new Kn(s,a)}function $I(e){return function(){return this.matches(e)}}function LI(e){return function(t){return t.matches(e)}}var W8=Array.prototype.find;function H8(e){return function(){return W8.call(this.children,e)}}function z8(){return this.firstElementChild}function V8(e){return this.select(e==null?z8:H8(typeof e=="function"?e:LI(e)))}var G8=Array.prototype.filter;function K8(){return Array.from(this.children)}function Y8(e){return function(){return G8.call(this.children,e)}}function X8(e){return this.selectAll(e==null?K8:Y8(typeof e=="function"?e:LI(e)))}function Z8(e){typeof e!="function"&&(e=$I(e));for(var t=this._groups,n=t.length,s=new Array(n),a=0;a<n;++a)for(var o=t[a],i=o.length,c=s[a]=[],d,h=0;h<i;++h)(d=o[h])&&e.call(d,d.__data__,h,o)&&c.push(d);return new Kn(s,this._parents)}function II(e){return new Array(e.length)}function J8(){return new Kn(this._enter||this._groups.map(II),this._parents)}function Yh(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Yh.prototype={constructor:Yh,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 Q8(e){return function(){return e}}function eB(e,t,n,s,a,o){for(var i=0,c,d=t.length,h=o.length;i<h;++i)(c=t[i])?(c.__data__=o[i],s[i]=c):n[i]=new Yh(e,o[i]);for(;i<d;++i)(c=t[i])&&(a[i]=c)}function tB(e,t,n,s,a,o,i){var c,d,h=new Map,f=t.length,p=o.length,m=new Array(f),w;for(c=0;c<f;++c)(d=t[c])&&(m[c]=w=i.call(d,d.__data__,c,t)+"",h.has(w)?a[c]=d:h.set(w,d));for(c=0;c<p;++c)w=i.call(e,o[c],c,o)+"",(d=h.get(w))?(s[c]=d,d.__data__=o[c],h.delete(w)):n[c]=new Yh(e,o[c]);for(c=0;c<f;++c)(d=t[c])&&h.get(m[c])===d&&(a[c]=d)}function nB(e){return e.__data__}function sB(e,t){if(!arguments.length)return Array.from(this,nB);var n=t?tB:eB,s=this._parents,a=this._groups;typeof e!="function"&&(e=Q8(e));for(var o=a.length,i=new Array(o),c=new Array(o),d=new Array(o),h=0;h<o;++h){var f=s[h],p=a[h],m=p.length,w=rB(e.call(f,f&&f.__data__,h,s)),j=w.length,v=c[h]=new Array(j),b=i[h]=new Array(j),k=d[h]=new Array(m);n(f,p,v,b,k,w,t);for(var N=0,S=0,_,E;N<j;++N)if(_=v[N]){for(N>=S&&(S=N+1);!(E=b[S])&&++S<j;);_._next=E||null}}return i=new Kn(i,s),i._enter=c,i._exit=d,i}function rB(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function aB(){return new Kn(this._exit||this._groups.map(II),this._parents)}function oB(e,t,n){var s=this.enter(),a=this,o=this.exit();return typeof e=="function"?(s=e(s),s&&(s=s.selection())):s=s.append(e+""),t!=null&&(a=t(a),a&&(a=a.selection())),n==null?o.remove():n(o),s&&a?s.merge(a).order():a}function iB(e){for(var t=e.selection?e.selection():e,n=this._groups,s=t._groups,a=n.length,o=s.length,i=Math.min(a,o),c=new Array(a),d=0;d<i;++d)for(var h=n[d],f=s[d],p=h.length,m=c[d]=new Array(p),w,j=0;j<p;++j)(w=h[j]||f[j])&&(m[j]=w);for(;d<a;++d)c[d]=n[d];return new Kn(c,this._parents)}function lB(){for(var e=this._groups,t=-1,n=e.length;++t<n;)for(var s=e[t],a=s.length-1,o=s[a],i;--a>=0;)(i=s[a])&&(o&&i.compareDocumentPosition(o)^4&&o.parentNode.insertBefore(i,o),o=i);return this}function cB(e){e||(e=uB);function t(p,m){return p&&m?e(p.__data__,m.__data__):!p-!m}for(var n=this._groups,s=n.length,a=new Array(s),o=0;o<s;++o){for(var i=n[o],c=i.length,d=a[o]=new Array(c),h,f=0;f<c;++f)(h=i[f])&&(d[f]=h);d.sort(t)}return new Kn(a,this._parents).order()}function uB(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function dB(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function hB(){return Array.from(this)}function fB(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var s=e[t],a=0,o=s.length;a<o;++a){var i=s[a];if(i)return i}return null}function pB(){let e=0;for(const t of this)++e;return e}function mB(){return!this.node()}function gB(e){for(var t=this._groups,n=0,s=t.length;n<s;++n)for(var a=t[n],o=0,i=a.length,c;o<i;++o)(c=a[o])&&e.call(c,c.__data__,o,a);return this}function yB(e){return function(){this.removeAttribute(e)}}function wB(e){return function(){this.removeAttributeNS(e.space,e.local)}}function xB(e,t){return function(){this.setAttribute(e,t)}}function vB(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function bB(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function kB(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 jB(e,t){var n=Wf(e);if(arguments.length<2){var s=this.node();return n.local?s.getAttributeNS(n.space,n.local):s.getAttribute(n)}return this.each((t==null?n.local?wB:yB:typeof t=="function"?n.local?kB:bB:n.local?vB:xB)(n,t))}function OI(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function NB(e){return function(){this.style.removeProperty(e)}}function SB(e,t,n){return function(){this.style.setProperty(e,t,n)}}function _B(e,t,n){return function(){var s=t.apply(this,arguments);s==null?this.style.removeProperty(e):this.style.setProperty(e,s,n)}}function CB(e,t,n){return arguments.length>1?this.each((t==null?NB:typeof t=="function"?_B:SB)(e,t,n??"")):fl(this.node(),e)}function fl(e,t){return e.style.getPropertyValue(t)||OI(e).getComputedStyle(e,null).getPropertyValue(t)}function EB(e){return function(){delete this[e]}}function TB(e,t){return function(){this[e]=t}}function RB(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function AB(e,t){return arguments.length>1?this.each((t==null?EB:typeof t=="function"?RB:TB)(e,t)):this.node()[e]}function PI(e){return e.trim().split(/^|\s+/)}function x1(e){return e.classList||new DI(e)}function DI(e){this._node=e,this._names=PI(e.getAttribute("class")||"")}DI.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 FI(e,t){for(var n=x1(e),s=-1,a=t.length;++s<a;)n.add(t[s])}function BI(e,t){for(var n=x1(e),s=-1,a=t.length;++s<a;)n.remove(t[s])}function MB(e){return function(){FI(this,e)}}function $B(e){return function(){BI(this,e)}}function LB(e,t){return function(){(t.apply(this,arguments)?FI:BI)(this,e)}}function IB(e,t){var n=PI(e+"");if(arguments.length<2){for(var s=x1(this.node()),a=-1,o=n.length;++a<o;)if(!s.contains(n[a]))return!1;return!0}return this.each((typeof t=="function"?LB:t?MB:$B)(n,t))}function OB(){this.textContent=""}function PB(e){return function(){this.textContent=e}}function DB(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function FB(e){return arguments.length?this.each(e==null?OB:(typeof e=="function"?DB:PB)(e)):this.node().textContent}function BB(){this.innerHTML=""}function qB(e){return function(){this.innerHTML=e}}function UB(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function WB(e){return arguments.length?this.each(e==null?BB:(typeof e=="function"?UB:qB)(e)):this.node().innerHTML}function HB(){this.nextSibling&&this.parentNode.appendChild(this)}function zB(){return this.each(HB)}function VB(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function GB(){return this.each(VB)}function KB(e){var t=typeof e=="function"?e:AI(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function YB(){return null}function XB(e,t){var n=typeof e=="function"?e:AI(e),s=t==null?YB:typeof t=="function"?t:w1(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),s.apply(this,arguments)||null)})}function ZB(){var e=this.parentNode;e&&e.removeChild(this)}function JB(){return this.each(ZB)}function QB(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function eq(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function tq(e){return this.select(e?eq:QB)}function nq(e){return arguments.length?this.property("__data__",e):this.node().__data__}function sq(e){return function(t){e.call(this,t,this.__data__)}}function rq(e){return e.trim().split(/^|\s+/).map(function(t){var n="",s=t.indexOf(".");return s>=0&&(n=t.slice(s+1),t=t.slice(0,s)),{type:t,name:n}})}function aq(e){return function(){var t=this.__on;if(t){for(var n=0,s=-1,a=t.length,o;n<a;++n)o=t[n],(!e.type||o.type===e.type)&&o.name===e.name?this.removeEventListener(o.type,o.listener,o.options):t[++s]=o;++s?t.length=s:delete this.__on}}}function oq(e,t,n){return function(){var s=this.__on,a,o=sq(t);if(s){for(var i=0,c=s.length;i<c;++i)if((a=s[i]).type===e.type&&a.name===e.name){this.removeEventListener(a.type,a.listener,a.options),this.addEventListener(a.type,a.listener=o,a.options=n),a.value=t;return}}this.addEventListener(e.type,o,n),a={type:e.type,name:e.name,value:t,listener:o,options:n},s?s.push(a):this.__on=[a]}}function iq(e,t,n){var s=rq(e+""),a,o=s.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(a=0,f=c[d];a<o;++a)if((i=s[a]).type===f.type&&i.name===f.name)return f.value}return}for(c=t?oq:aq,a=0;a<o;++a)this.each(c(s[a],t,n));return this}function qI(e,t,n){var s=OI(e),a=s.CustomEvent;typeof a=="function"?a=new a(t,n):(a=s.document.createEvent("Event"),n?(a.initEvent(t,n.bubbles,n.cancelable),a.detail=n.detail):a.initEvent(t,!1,!1)),e.dispatchEvent(a)}function lq(e,t){return function(){return qI(this,e,t)}}function cq(e,t){return function(){return qI(this,e,t.apply(this,arguments))}}function uq(e,t){return this.each((typeof t=="function"?cq:lq)(e,t))}function*dq(){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var s=e[t],a=0,o=s.length,i;a<o;++a)(i=s[a])&&(yield i)}var UI=[null];function Kn(e,t){this._groups=e,this._parents=t}function Ru(){return new Kn([[document.documentElement]],UI)}function hq(){return this}Kn.prototype=Ru.prototype={constructor:Kn,select:D8,selectAll:U8,selectChild:V8,selectChildren:X8,filter:Z8,data:sB,enter:J8,exit:aB,join:oB,merge:iB,selection:hq,order:lB,sort:cB,call:dB,nodes:hB,node:fB,size:pB,empty:mB,each:gB,attr:jB,style:CB,property:AB,classed:IB,text:FB,html:WB,raise:zB,lower:GB,append:KB,insert:XB,remove:JB,clone:tq,datum:nq,on:iq,dispatch:uq,[Symbol.iterator]:dq};function ms(e){return typeof e=="string"?new Kn([[document.querySelector(e)]],[document.documentElement]):new Kn([[e]],UI)}function fq(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Bs(e,t){if(e=fq(e),t===void 0&&(t=e.currentTarget),t){var n=t.ownerSVGElement||t;if(n.createSVGPoint){var s=n.createSVGPoint();return s.x=e.clientX,s.y=e.clientY,s=s.matrixTransform(t.getScreenCTM().inverse()),[s.x,s.y]}if(t.getBoundingClientRect){var a=t.getBoundingClientRect();return[e.clientX-a.left-t.clientLeft,e.clientY-a.top-t.clientTop]}}return[e.pageX,e.pageY]}const pq={passive:!1},su={capture:!0,passive:!1};function Ig(e){e.stopImmediatePropagation()}function rl(e){e.preventDefault(),e.stopImmediatePropagation()}function WI(e){var t=e.document.documentElement,n=ms(e).on("dragstart.drag",rl,su);"onselectstart"in t?n.on("selectstart.drag",rl,su):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function HI(e,t){var n=e.document.documentElement,s=ms(e).on("dragstart.drag",null);t&&(s.on("click.drag",rl,su),setTimeout(function(){s.on("click.drag",null)},0)),"onselectstart"in n?s.on("selectstart.drag",null):(n.style.MozUserSelect=n.__noselect,delete n.__noselect)}const eh=e=>()=>e;function zk(e,{sourceEvent:t,subject:n,target:s,identifier:a,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:s,enumerable:!0,configurable:!0},identifier:{value:a,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}})}zk.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function mq(e){return!e.ctrlKey&&!e.button}function gq(){return this.parentNode}function yq(e,t){return t??{x:e.x,y:e.y}}function wq(){return navigator.maxTouchPoints||"ontouchstart"in this}function xq(){var e=mq,t=gq,n=yq,s=wq,a={},o=Uf("start","drag","end"),i=0,c,d,h,f,p=0;function m(_){_.on("mousedown.drag",w).filter(s).on("touchstart.drag",b).on("touchmove.drag",k,pq).on("touchend.drag touchcancel.drag",N).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function w(_,E){if(!(f||!e.call(this,_,E))){var I=S(this,t.call(this,_,E),_,E,"mouse");I&&(ms(_.view).on("mousemove.drag",j,su).on("mouseup.drag",v,su),WI(_.view),Ig(_),h=!1,c=_.clientX,d=_.clientY,I("start",_))}}function j(_){if(rl(_),!h){var E=_.clientX-c,I=_.clientY-d;h=E*E+I*I>p}a.mouse("drag",_)}function v(_){ms(_.view).on("mousemove.drag mouseup.drag",null),HI(_.view,h),rl(_),a.mouse("end",_)}function b(_,E){if(e.call(this,_,E)){var I=_.changedTouches,A=t.call(this,_,E),O=I.length,L,U;for(L=0;L<O;++L)(U=S(this,A,_,E,I[L].identifier,I[L]))&&(Ig(_),U("start",_,I[L]))}}function k(_){var E=_.changedTouches,I=E.length,A,O;for(A=0;A<I;++A)(O=a[E[A].identifier])&&(rl(_),O("drag",_,E[A]))}function N(_){var E=_.changedTouches,I=E.length,A,O;for(f&&clearTimeout(f),f=setTimeout(function(){f=null},500),A=0;A<I;++A)(O=a[E[A].identifier])&&(Ig(_),O("end",_,E[A]))}function S(_,E,I,A,O,L){var U=o.copy(),P=Bs(L||I,E),T,B,M;if((M=n.call(_,new zk("beforestart",{sourceEvent:I,target:m,identifier:O,active:i,x:P[0],y:P[1],dx:0,dy:0,dispatch:U}),A))!=null)return T=M.x-P[0]||0,B=M.y-P[1]||0,function q($,K,G){var z=P,W;switch($){case"start":a[O]=q,W=i++;break;case"end":delete a[O],--i;case"drag":P=Bs(G||K,E),W=i;break}U.call($,_,new zk($,{sourceEvent:K,subject:M,target:m,identifier:O,active:W,x:P[0]+T,y:P[1]+B,dx:P[0]-z[0],dy:P[1]-z[1],dispatch:U}),A)}}return m.filter=function(_){return arguments.length?(e=typeof _=="function"?_:eh(!!_),m):e},m.container=function(_){return arguments.length?(t=typeof _=="function"?_:eh(_),m):t},m.subject=function(_){return arguments.length?(n=typeof _=="function"?_:eh(_),m):n},m.touchable=function(_){return arguments.length?(s=typeof _=="function"?_:eh(!!_),m):s},m.on=function(){var _=o.on.apply(o,arguments);return _===o?m:_},m.clickDistance=function(_){return arguments.length?(p=(_=+_)*_,m):Math.sqrt(p)},m}function v1(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function zI(e,t){var n=Object.create(e.prototype);for(var s in t)n[s]=t[s];return n}function Au(){}var ru=.7,Xh=1/ru,al="\\s*([+-]?\\d+)\\s*",au="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",yr="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",vq=/^#([0-9a-f]{3,8})$/,bq=new RegExp(`^rgb\\(${al},${al},${al}\\)$`),kq=new RegExp(`^rgb\\(${yr},${yr},${yr}\\)$`),jq=new RegExp(`^rgba\\(${al},${al},${al},${au}\\)$`),Nq=new RegExp(`^rgba\\(${yr},${yr},${yr},${au}\\)$`),Sq=new RegExp(`^hsl\\(${au},${yr},${yr}\\)$`),_q=new RegExp(`^hsla\\(${au},${yr},${yr},${au}\\)$`),F_={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};v1(Au,ou,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:B_,formatHex:B_,formatHex8:Cq,formatHsl:Eq,formatRgb:q_,toString:q_});function B_(){return this.rgb().formatHex()}function Cq(){return this.rgb().formatHex8()}function Eq(){return VI(this).formatHsl()}function q_(){return this.rgb().formatRgb()}function ou(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=vq.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?U_(t):n===3?new An(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?th(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?th(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=bq.exec(e))?new An(t[1],t[2],t[3],1):(t=kq.exec(e))?new An(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=jq.exec(e))?th(t[1],t[2],t[3],t[4]):(t=Nq.exec(e))?th(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=Sq.exec(e))?z_(t[1],t[2]/100,t[3]/100,1):(t=_q.exec(e))?z_(t[1],t[2]/100,t[3]/100,t[4]):F_.hasOwnProperty(e)?U_(F_[e]):e==="transparent"?new An(NaN,NaN,NaN,0):null}function U_(e){return new An(e>>16&255,e>>8&255,e&255,1)}function th(e,t,n,s){return s<=0&&(e=t=n=NaN),new An(e,t,n,s)}function Tq(e){return e instanceof Au||(e=ou(e)),e?(e=e.rgb(),new An(e.r,e.g,e.b,e.opacity)):new An}function Vk(e,t,n,s){return arguments.length===1?Tq(e):new An(e,t,n,s??1)}function An(e,t,n,s){this.r=+e,this.g=+t,this.b=+n,this.opacity=+s}v1(An,Vk,zI(Au,{brighter(e){return e=e==null?Xh:Math.pow(Xh,e),new An(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?ru:Math.pow(ru,e),new An(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new An(Do(this.r),Do(this.g),Do(this.b),Zh(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:W_,formatHex:W_,formatHex8:Rq,formatRgb:H_,toString:H_}));function W_(){return`#${Lo(this.r)}${Lo(this.g)}${Lo(this.b)}`}function Rq(){return`#${Lo(this.r)}${Lo(this.g)}${Lo(this.b)}${Lo((isNaN(this.opacity)?1:this.opacity)*255)}`}function H_(){const e=Zh(this.opacity);return`${e===1?"rgb(":"rgba("}${Do(this.r)}, ${Do(this.g)}, ${Do(this.b)}${e===1?")":`, ${e})`}`}function Zh(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Do(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Lo(e){return e=Do(e),(e<16?"0":"")+e.toString(16)}function z_(e,t,n,s){return s<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new qs(e,t,n,s)}function VI(e){if(e instanceof qs)return new qs(e.h,e.s,e.l,e.opacity);if(e instanceof Au||(e=ou(e)),!e)return new qs;if(e instanceof qs)return e;e=e.rgb();var t=e.r/255,n=e.g/255,s=e.b/255,a=Math.min(t,n,s),o=Math.max(t,n,s),i=NaN,c=o-a,d=(o+a)/2;return c?(t===o?i=(n-s)/c+(n<s)*6:n===o?i=(s-t)/c+2:i=(t-n)/c+4,c/=d<.5?o+a:2-o-a,i*=60):c=d>0&&d<1?0:i,new qs(i,c,d,e.opacity)}function Aq(e,t,n,s){return arguments.length===1?VI(e):new qs(e,t,n,s??1)}function qs(e,t,n,s){this.h=+e,this.s=+t,this.l=+n,this.opacity=+s}v1(qs,Aq,zI(Au,{brighter(e){return e=e==null?Xh:Math.pow(Xh,e),new qs(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?ru:Math.pow(ru,e),new qs(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,s=n+(n<.5?n:1-n)*t,a=2*n-s;return new An(Og(e>=240?e-240:e+120,a,s),Og(e,a,s),Og(e<120?e+240:e-120,a,s),this.opacity)},clamp(){return new qs(V_(this.h),nh(this.s),nh(this.l),Zh(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=Zh(this.opacity);return`${e===1?"hsl(":"hsla("}${V_(this.h)}, ${nh(this.s)*100}%, ${nh(this.l)*100}%${e===1?")":`, ${e})`}`}}));function V_(e){return e=(e||0)%360,e<0?e+360:e}function nh(e){return Math.max(0,Math.min(1,e||0))}function Og(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 GI=e=>()=>e;function Mq(e,t){return function(n){return e+n*t}}function $q(e,t,n){return e=Math.pow(e,n),t=Math.pow(t,n)-e,n=1/n,function(s){return Math.pow(e+s*t,n)}}function Lq(e){return(e=+e)==1?KI:function(t,n){return n-t?$q(t,n,e):GI(isNaN(t)?n:t)}}function KI(e,t){var n=t-e;return n?Mq(e,n):GI(isNaN(e)?t:e)}const G_=(function e(t){var n=Lq(t);function s(a,o){var i=n((a=Vk(a)).r,(o=Vk(o)).r),c=n(a.g,o.g),d=n(a.b,o.b),h=KI(a.opacity,o.opacity);return function(f){return a.r=i(f),a.g=c(f),a.b=d(f),a.opacity=h(f),a+""}}return s.gamma=e,s})(1);function La(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var Gk=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Pg=new RegExp(Gk.source,"g");function Iq(e){return function(){return e}}function Oq(e){return function(t){return e(t)+""}}function Pq(e,t){var n=Gk.lastIndex=Pg.lastIndex=0,s,a,o,i=-1,c=[],d=[];for(e=e+"",t=t+"";(s=Gk.exec(e))&&(a=Pg.exec(t));)(o=a.index)>n&&(o=t.slice(n,o),c[i]?c[i]+=o:c[++i]=o),(s=s[0])===(a=a[0])?c[i]?c[i]+=a:c[++i]=a:(c[++i]=null,d.push({i,x:La(s,a)})),n=Pg.lastIndex;return n<t.length&&(o=t.slice(n),c[i]?c[i]+=o:c[++i]=o),c.length<2?d[0]?Oq(d[0].x):Iq(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 K_=180/Math.PI,Kk={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function YI(e,t,n,s,a,o){var i,c,d;return(i=Math.sqrt(e*e+t*t))&&(e/=i,t/=i),(d=e*n+t*s)&&(n-=e*d,s-=t*d),(c=Math.sqrt(n*n+s*s))&&(n/=c,s/=c,d/=c),e*s<t*n&&(e=-e,t=-t,d=-d,i=-i),{translateX:a,translateY:o,rotate:Math.atan2(t,e)*K_,skewX:Math.atan(d)*K_,scaleX:i,scaleY:c}}var sh;function Dq(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?Kk:YI(t.a,t.b,t.c,t.d,t.e,t.f)}function Fq(e){return e==null||(sh||(sh=document.createElementNS("http://www.w3.org/2000/svg","g")),sh.setAttribute("transform",e),!(e=sh.transform.baseVal.consolidate()))?Kk:(e=e.matrix,YI(e.a,e.b,e.c,e.d,e.e,e.f))}function XI(e,t,n,s){function a(h){return h.length?h.pop()+" ":""}function o(h,f,p,m,w,j){if(h!==p||f!==m){var v=w.push("translate(",null,t,null,n);j.push({i:v-4,x:La(h,p)},{i:v-2,x:La(f,m)})}else(p||m)&&w.push("translate("+p+t+m+n)}function i(h,f,p,m){h!==f?(h-f>180?f+=360:f-h>180&&(h+=360),m.push({i:p.push(a(p)+"rotate(",null,s)-2,x:La(h,f)})):f&&p.push(a(p)+"rotate("+f+s)}function c(h,f,p,m){h!==f?m.push({i:p.push(a(p)+"skewX(",null,s)-2,x:La(h,f)}):f&&p.push(a(p)+"skewX("+f+s)}function d(h,f,p,m,w,j){if(h!==p||f!==m){var v=w.push(a(w)+"scale(",null,",",null,")");j.push({i:v-4,x:La(h,p)},{i:v-2,x:La(f,m)})}else(p!==1||m!==1)&&w.push(a(w)+"scale("+p+","+m+")")}return function(h,f){var p=[],m=[];return h=e(h),f=e(f),o(h.translateX,h.translateY,f.translateX,f.translateY,p,m),i(h.rotate,f.rotate,p,m),c(h.skewX,f.skewX,p,m),d(h.scaleX,h.scaleY,f.scaleX,f.scaleY,p,m),h=f=null,function(w){for(var j=-1,v=m.length,b;++j<v;)p[(b=m[j]).i]=b.x(w);return p.join("")}}}var Bq=XI(Dq,"px, ","px)","deg)"),qq=XI(Fq,", ",")",")"),Uq=1e-12;function Y_(e){return((e=Math.exp(e))+1/e)/2}function Wq(e){return((e=Math.exp(e))-1/e)/2}function Hq(e){return((e=Math.exp(2*e))-1)/(e+1)}const zq=(function e(t,n,s){function a(o,i){var c=o[0],d=o[1],h=o[2],f=i[0],p=i[1],m=i[2],w=f-c,j=p-d,v=w*w+j*j,b,k;if(v<Uq)k=Math.log(m/h)/t,b=function(A){return[c+A*w,d+A*j,h*Math.exp(t*A*k)]};else{var N=Math.sqrt(v),S=(m*m-h*h+s*v)/(2*h*n*N),_=(m*m-h*h-s*v)/(2*m*n*N),E=Math.log(Math.sqrt(S*S+1)-S),I=Math.log(Math.sqrt(_*_+1)-_);k=(I-E)/t,b=function(A){var O=A*k,L=Y_(E),U=h/(n*N)*(L*Hq(t*O+E)-Wq(E));return[c+U*w,d+U*j,h*L/Y_(t*O+E)]}}return b.duration=k*1e3*t/Math.SQRT2,b}return a.rho=function(o){var i=Math.max(.001,+o),c=i*i,d=c*c;return e(i,c,d)},a})(Math.SQRT2,2,4);var pl=0,Oc=0,jc=0,ZI=1e3,Jh,Pc,Qh=0,Vo=0,Hf=0,iu=typeof performance=="object"&&performance.now?performance:Date,JI=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function b1(){return Vo||(JI(Vq),Vo=iu.now()+Hf)}function Vq(){Vo=0}function ef(){this._call=this._time=this._next=null}ef.prototype=QI.prototype={constructor:ef,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?b1():+n)+(t==null?0:+t),!this._next&&Pc!==this&&(Pc?Pc._next=this:Jh=this,Pc=this),this._call=e,this._time=n,Yk()},stop:function(){this._call&&(this._call=null,this._time=1/0,Yk())}};function QI(e,t,n){var s=new ef;return s.restart(e,t,n),s}function Gq(){b1(),++pl;for(var e=Jh,t;e;)(t=Vo-e._time)>=0&&e._call.call(void 0,t),e=e._next;--pl}function X_(){Vo=(Qh=iu.now())+Hf,pl=Oc=0;try{Gq()}finally{pl=0,Yq(),Vo=0}}function Kq(){var e=iu.now(),t=e-Qh;t>ZI&&(Hf-=t,Qh=e)}function Yq(){for(var e,t=Jh,n,s=1/0;t;)t._call?(s>t._time&&(s=t._time),e=t,t=t._next):(n=t._next,t._next=null,t=e?e._next=n:Jh=n);Pc=e,Yk(s)}function Yk(e){if(!pl){Oc&&(Oc=clearTimeout(Oc));var t=e-Vo;t>24?(e<1/0&&(Oc=setTimeout(X_,e-iu.now()-Hf)),jc&&(jc=clearInterval(jc))):(jc||(Qh=iu.now(),jc=setInterval(Kq,ZI)),pl=1,JI(X_))}}function Z_(e,t,n){var s=new ef;return t=t==null?0:+t,s.restart(a=>{s.stop(),e(a+t)},t,n),s}var Xq=Uf("start","end","cancel","interrupt"),Zq=[],eO=0,J_=1,Xk=2,Mh=3,Q_=4,Zk=5,$h=6;function zf(e,t,n,s,a,o){var i=e.__transition;if(!i)e.__transition={};else if(n in i)return;Jq(e,n,{name:t,index:s,group:a,on:Xq,tween:Zq,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:eO})}function k1(e,t){var n=Ks(e,t);if(n.state>eO)throw new Error("too late; already scheduled");return n}function kr(e,t){var n=Ks(e,t);if(n.state>Mh)throw new Error("too late; already running");return n}function Ks(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function Jq(e,t,n){var s=e.__transition,a;s[t]=n,n.timer=QI(o,0,n.time);function o(h){n.state=J_,n.timer.restart(i,n.delay,n.time),n.delay<=h&&i(h-n.delay)}function i(h){var f,p,m,w;if(n.state!==J_)return d();for(f in s)if(w=s[f],w.name===n.name){if(w.state===Mh)return Z_(i);w.state===Q_?(w.state=$h,w.timer.stop(),w.on.call("interrupt",e,e.__data__,w.index,w.group),delete s[f]):+f<t&&(w.state=$h,w.timer.stop(),w.on.call("cancel",e,e.__data__,w.index,w.group),delete s[f])}if(Z_(function(){n.state===Mh&&(n.state=Q_,n.timer.restart(c,n.delay,n.time),c(h))}),n.state=Xk,n.on.call("start",e,e.__data__,n.index,n.group),n.state===Xk){for(n.state=Mh,a=new Array(m=n.tween.length),f=0,p=-1;f<m;++f)(w=n.tween[f].value.call(e,e.__data__,n.index,n.group))&&(a[++p]=w);a.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=Zk,1),p=-1,m=a.length;++p<m;)a[p].call(e,f);n.state===Zk&&(n.on.call("end",e,e.__data__,n.index,n.group),d())}function d(){n.state=$h,n.timer.stop(),delete s[t];for(var h in s)return;delete e.__transition}}function Lh(e,t){var n=e.__transition,s,a,o=!0,i;if(n){t=t==null?null:t+"";for(i in n){if((s=n[i]).name!==t){o=!1;continue}a=s.state>Xk&&s.state<Zk,s.state=$h,s.timer.stop(),s.on.call(a?"interrupt":"cancel",e,e.__data__,s.index,s.group),delete n[i]}o&&delete e.__transition}}function Qq(e){return this.each(function(){Lh(this,e)})}function eU(e,t){var n,s;return function(){var a=kr(this,e),o=a.tween;if(o!==n){s=n=o;for(var i=0,c=s.length;i<c;++i)if(s[i].name===t){s=s.slice(),s.splice(i,1);break}}a.tween=s}}function tU(e,t,n){var s,a;if(typeof n!="function")throw new Error;return function(){var o=kr(this,e),i=o.tween;if(i!==s){a=(s=i).slice();for(var c={name:t,value:n},d=0,h=a.length;d<h;++d)if(a[d].name===t){a[d]=c;break}d===h&&a.push(c)}o.tween=a}}function nU(e,t){var n=this._id;if(e+="",arguments.length<2){for(var s=Ks(this.node(),n).tween,a=0,o=s.length,i;a<o;++a)if((i=s[a]).name===e)return i.value;return null}return this.each((t==null?eU:tU)(n,e,t))}function j1(e,t,n){var s=e._id;return e.each(function(){var a=kr(this,s);(a.value||(a.value={}))[t]=n.apply(this,arguments)}),function(a){return Ks(a,s).value[t]}}function tO(e,t){var n;return(typeof t=="number"?La:t instanceof ou?G_:(n=ou(t))?(t=n,G_):Pq)(e,t)}function sU(e){return function(){this.removeAttribute(e)}}function rU(e){return function(){this.removeAttributeNS(e.space,e.local)}}function aU(e,t,n){var s,a=n+"",o;return function(){var i=this.getAttribute(e);return i===a?null:i===s?o:o=t(s=i,n)}}function oU(e,t,n){var s,a=n+"",o;return function(){var i=this.getAttributeNS(e.space,e.local);return i===a?null:i===s?o:o=t(s=i,n)}}function iU(e,t,n){var s,a,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===s&&d===a?o:(a=d,o=t(s=i,c)))}}function lU(e,t,n){var s,a,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===s&&d===a?o:(a=d,o=t(s=i,c)))}}function cU(e,t){var n=Wf(e),s=n==="transform"?qq:tO;return this.attrTween(e,typeof t=="function"?(n.local?lU:iU)(n,s,j1(this,"attr."+e,t)):t==null?(n.local?rU:sU)(n):(n.local?oU:aU)(n,s,t))}function uU(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function dU(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function hU(e,t){var n,s;function a(){var o=t.apply(this,arguments);return o!==s&&(n=(s=o)&&dU(e,o)),n}return a._value=t,a}function fU(e,t){var n,s;function a(){var o=t.apply(this,arguments);return o!==s&&(n=(s=o)&&uU(e,o)),n}return a._value=t,a}function pU(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 s=Wf(e);return this.tween(n,(s.local?hU:fU)(s,t))}function mU(e,t){return function(){k1(this,e).delay=+t.apply(this,arguments)}}function gU(e,t){return t=+t,function(){k1(this,e).delay=t}}function yU(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?mU:gU)(t,e)):Ks(this.node(),t).delay}function wU(e,t){return function(){kr(this,e).duration=+t.apply(this,arguments)}}function xU(e,t){return t=+t,function(){kr(this,e).duration=t}}function vU(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?wU:xU)(t,e)):Ks(this.node(),t).duration}function bU(e,t){if(typeof t!="function")throw new Error;return function(){kr(this,e).ease=t}}function kU(e){var t=this._id;return arguments.length?this.each(bU(t,e)):Ks(this.node(),t).ease}function jU(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;kr(this,e).ease=n}}function NU(e){if(typeof e!="function")throw new Error;return this.each(jU(this._id,e))}function SU(e){typeof e!="function"&&(e=$I(e));for(var t=this._groups,n=t.length,s=new Array(n),a=0;a<n;++a)for(var o=t[a],i=o.length,c=s[a]=[],d,h=0;h<i;++h)(d=o[h])&&e.call(d,d.__data__,h,o)&&c.push(d);return new ta(s,this._parents,this._name,this._id)}function _U(e){if(e._id!==this._id)throw new Error;for(var t=this._groups,n=e._groups,s=t.length,a=n.length,o=Math.min(s,a),i=new Array(s),c=0;c<o;++c)for(var d=t[c],h=n[c],f=d.length,p=i[c]=new Array(f),m,w=0;w<f;++w)(m=d[w]||h[w])&&(p[w]=m);for(;c<s;++c)i[c]=t[c];return new ta(i,this._parents,this._name,this._id)}function CU(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 EU(e,t,n){var s,a,o=CU(t)?k1:kr;return function(){var i=o(this,e),c=i.on;c!==s&&(a=(s=c).copy()).on(t,n),i.on=a}}function TU(e,t){var n=this._id;return arguments.length<2?Ks(this.node(),n).on.on(e):this.each(EU(n,e,t))}function RU(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function AU(){return this.on("end.remove",RU(this._id))}function MU(e){var t=this._name,n=this._id;typeof e!="function"&&(e=w1(e));for(var s=this._groups,a=s.length,o=new Array(a),i=0;i<a;++i)for(var c=s[i],d=c.length,h=o[i]=new Array(d),f,p,m=0;m<d;++m)(f=c[m])&&(p=e.call(f,f.__data__,m,c))&&("__data__"in f&&(p.__data__=f.__data__),h[m]=p,zf(h[m],t,n,m,h,Ks(f,n)));return new ta(o,this._parents,t,n)}function $U(e){var t=this._name,n=this._id;typeof e!="function"&&(e=MI(e));for(var s=this._groups,a=s.length,o=[],i=[],c=0;c<a;++c)for(var d=s[c],h=d.length,f,p=0;p<h;++p)if(f=d[p]){for(var m=e.call(f,f.__data__,p,d),w,j=Ks(f,n),v=0,b=m.length;v<b;++v)(w=m[v])&&zf(w,t,n,v,m,j);o.push(m),i.push(f)}return new ta(o,i,t,n)}var LU=Ru.prototype.constructor;function IU(){return new LU(this._groups,this._parents)}function OU(e,t){var n,s,a;return function(){var o=fl(this,e),i=(this.style.removeProperty(e),fl(this,e));return o===i?null:o===n&&i===s?a:a=t(n=o,s=i)}}function nO(e){return function(){this.style.removeProperty(e)}}function PU(e,t,n){var s,a=n+"",o;return function(){var i=fl(this,e);return i===a?null:i===s?o:o=t(s=i,n)}}function DU(e,t,n){var s,a,o;return function(){var i=fl(this,e),c=n(this),d=c+"";return c==null&&(d=c=(this.style.removeProperty(e),fl(this,e))),i===d?null:i===s&&d===a?o:(a=d,o=t(s=i,c))}}function FU(e,t){var n,s,a,o="style."+t,i="end."+o,c;return function(){var d=kr(this,e),h=d.on,f=d.value[o]==null?c||(c=nO(t)):void 0;(h!==n||a!==f)&&(s=(n=h).copy()).on(i,a=f),d.on=s}}function BU(e,t,n){var s=(e+="")=="transform"?Bq:tO;return t==null?this.styleTween(e,OU(e,s)).on("end.style."+e,nO(e)):typeof t=="function"?this.styleTween(e,DU(e,s,j1(this,"style."+e,t))).each(FU(this._id,e)):this.styleTween(e,PU(e,s,t),n).on("end.style."+e,null)}function qU(e,t,n){return function(s){this.style.setProperty(e,t.call(this,s),n)}}function UU(e,t,n){var s,a;function o(){var i=t.apply(this,arguments);return i!==a&&(s=(a=i)&&qU(e,i,n)),s}return o._value=t,o}function WU(e,t,n){var s="style."+(e+="");if(arguments.length<2)return(s=this.tween(s))&&s._value;if(t==null)return this.tween(s,null);if(typeof t!="function")throw new Error;return this.tween(s,UU(e,t,n??""))}function HU(e){return function(){this.textContent=e}}function zU(e){return function(){var t=e(this);this.textContent=t??""}}function VU(e){return this.tween("text",typeof e=="function"?zU(j1(this,"text",e)):HU(e==null?"":e+""))}function GU(e){return function(t){this.textContent=e.call(this,t)}}function KU(e){var t,n;function s(){var a=e.apply(this,arguments);return a!==n&&(t=(n=a)&&GU(a)),t}return s._value=e,s}function YU(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,KU(e))}function XU(){for(var e=this._name,t=this._id,n=sO(),s=this._groups,a=s.length,o=0;o<a;++o)for(var i=s[o],c=i.length,d,h=0;h<c;++h)if(d=i[h]){var f=Ks(d,t);zf(d,e,n,h,i,{time:f.time+f.delay+f.duration,delay:0,duration:f.duration,ease:f.ease})}return new ta(s,this._parents,e,n)}function ZU(){var e,t,n=this,s=n._id,a=n.size();return new Promise(function(o,i){var c={value:i},d={value:function(){--a===0&&o()}};n.each(function(){var h=kr(this,s),f=h.on;f!==e&&(t=(e=f).copy(),t._.cancel.push(c),t._.interrupt.push(c),t._.end.push(d)),h.on=t}),a===0&&o()})}var JU=0;function ta(e,t,n,s){this._groups=e,this._parents=t,this._name=n,this._id=s}function sO(){return++JU}var Hr=Ru.prototype;ta.prototype={constructor:ta,select:MU,selectAll:$U,selectChild:Hr.selectChild,selectChildren:Hr.selectChildren,filter:SU,merge:_U,selection:IU,transition:XU,call:Hr.call,nodes:Hr.nodes,node:Hr.node,size:Hr.size,empty:Hr.empty,each:Hr.each,on:TU,attr:cU,attrTween:pU,style:BU,styleTween:WU,text:VU,textTween:YU,remove:AU,tween:nU,delay:yU,duration:vU,ease:kU,easeVarying:NU,end:ZU,[Symbol.iterator]:Hr[Symbol.iterator]};function QU(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var eW={time:null,delay:0,duration:250,ease:QU};function tW(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 nW(e){var t,n;e instanceof ta?(t=e._id,e=e._name):(t=sO(),(n=eW).time=b1(),e=e==null?null:e+"");for(var s=this._groups,a=s.length,o=0;o<a;++o)for(var i=s[o],c=i.length,d,h=0;h<c;++h)(d=i[h])&&zf(d,e,t,h,i,n||tW(d,t));return new ta(s,this._parents,e,t)}Ru.prototype.interrupt=Qq;Ru.prototype.transition=nW;const rh=e=>()=>e;function sW(e,{sourceEvent:t,target:n,transform:s,dispatch:a}){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:s,enumerable:!0,configurable:!0},_:{value:a}})}function Jr(e,t,n){this.k=e,this.x=t,this.y=n}Jr.prototype={constructor:Jr,scale:function(e){return e===1?this:new Jr(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new Jr(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 Qr=new Jr(1,0,0);Jr.prototype;function Dg(e){e.stopImmediatePropagation()}function Nc(e){e.preventDefault(),e.stopImmediatePropagation()}function rW(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function aW(){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 eC(){return this.__zoom||Qr}function oW(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function iW(){return navigator.maxTouchPoints||"ontouchstart"in this}function lW(e,t,n){var s=e.invertX(t[0][0])-n[0][0],a=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(a>s?(s+a)/2:Math.min(0,s)||Math.max(0,a),i>o?(o+i)/2:Math.min(0,o)||Math.max(0,i))}function rO(){var e=rW,t=aW,n=lW,s=oW,a=iW,o=[0,1/0],i=[[-1/0,-1/0],[1/0,1/0]],c=250,d=zq,h=Uf("start","zoom","end"),f,p,m,w=500,j=150,v=0,b=10;function k(M){M.property("__zoom",eC).on("wheel.zoom",O,{passive:!1}).on("mousedown.zoom",L).on("dblclick.zoom",U).filter(a).on("touchstart.zoom",P).on("touchmove.zoom",T).on("touchend.zoom touchcancel.zoom",B).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}k.transform=function(M,q,$,K){var G=M.selection?M.selection():M;G.property("__zoom",eC),M!==G?E(M,q,$,K):G.interrupt().each(function(){I(this,arguments).event(K).start().zoom(null,typeof q=="function"?q.apply(this,arguments):q).end()})},k.scaleBy=function(M,q,$,K){k.scaleTo(M,function(){var G=this.__zoom.k,z=typeof q=="function"?q.apply(this,arguments):q;return G*z},$,K)},k.scaleTo=function(M,q,$,K){k.transform(M,function(){var G=t.apply(this,arguments),z=this.__zoom,W=$==null?_(G):typeof $=="function"?$.apply(this,arguments):$,D=z.invert(W),H=typeof q=="function"?q.apply(this,arguments):q;return n(S(N(z,H),W,D),G,i)},$,K)},k.translateBy=function(M,q,$,K){k.transform(M,function(){return n(this.__zoom.translate(typeof q=="function"?q.apply(this,arguments):q,typeof $=="function"?$.apply(this,arguments):$),t.apply(this,arguments),i)},null,K)},k.translateTo=function(M,q,$,K,G){k.transform(M,function(){var z=t.apply(this,arguments),W=this.__zoom,D=K==null?_(z):typeof K=="function"?K.apply(this,arguments):K;return n(Qr.translate(D[0],D[1]).scale(W.k).translate(typeof q=="function"?-q.apply(this,arguments):-q,typeof $=="function"?-$.apply(this,arguments):-$),z,i)},K,G)};function N(M,q){return q=Math.max(o[0],Math.min(o[1],q)),q===M.k?M:new Jr(q,M.x,M.y)}function S(M,q,$){var K=q[0]-$[0]*M.k,G=q[1]-$[1]*M.k;return K===M.x&&G===M.y?M:new Jr(M.k,K,G)}function _(M){return[(+M[0][0]+ +M[1][0])/2,(+M[0][1]+ +M[1][1])/2]}function E(M,q,$,K){M.on("start.zoom",function(){I(this,arguments).event(K).start()}).on("interrupt.zoom end.zoom",function(){I(this,arguments).event(K).end()}).tween("zoom",function(){var G=this,z=arguments,W=I(G,z).event(K),D=t.apply(G,z),H=$==null?_(D):typeof $=="function"?$.apply(G,z):$,ee=Math.max(D[1][0]-D[0][0],D[1][1]-D[0][1]),F=G.__zoom,Y=typeof q=="function"?q.apply(G,z):q,X=d(F.invert(H).concat(ee/F.k),Y.invert(H).concat(ee/Y.k));return function(Z){if(Z===1)Z=Y;else{var J=X(Z),ne=ee/J[2];Z=new Jr(ne,H[0]-J[0]*ne,H[1]-J[1]*ne)}W.zoom(null,Z)}})}function I(M,q,$){return!$&&M.__zooming||new A(M,q)}function A(M,q){this.that=M,this.args=q,this.active=0,this.sourceEvent=null,this.extent=t.apply(M,q),this.taps=0}A.prototype={event:function(M){return M&&(this.sourceEvent=M),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(M,q){return this.mouse&&M!=="mouse"&&(this.mouse[1]=q.invert(this.mouse[0])),this.touch0&&M!=="touch"&&(this.touch0[1]=q.invert(this.touch0[0])),this.touch1&&M!=="touch"&&(this.touch1[1]=q.invert(this.touch1[0])),this.that.__zoom=q,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(M){var q=ms(this.that).datum();h.call(M,this.that,new sW(M,{sourceEvent:this.sourceEvent,target:k,transform:this.that.__zoom,dispatch:h}),q)}};function O(M,...q){if(!e.apply(this,arguments))return;var $=I(this,q).event(M),K=this.__zoom,G=Math.max(o[0],Math.min(o[1],K.k*Math.pow(2,s.apply(this,arguments)))),z=Bs(M);if($.wheel)($.mouse[0][0]!==z[0]||$.mouse[0][1]!==z[1])&&($.mouse[1]=K.invert($.mouse[0]=z)),clearTimeout($.wheel);else{if(K.k===G)return;$.mouse=[z,K.invert(z)],Lh(this),$.start()}Nc(M),$.wheel=setTimeout(W,j),$.zoom("mouse",n(S(N(K,G),$.mouse[0],$.mouse[1]),$.extent,i));function W(){$.wheel=null,$.end()}}function L(M,...q){if(m||!e.apply(this,arguments))return;var $=M.currentTarget,K=I(this,q,!0).event(M),G=ms(M.view).on("mousemove.zoom",H,!0).on("mouseup.zoom",ee,!0),z=Bs(M,$),W=M.clientX,D=M.clientY;WI(M.view),Dg(M),K.mouse=[z,this.__zoom.invert(z)],Lh(this),K.start();function H(F){if(Nc(F),!K.moved){var Y=F.clientX-W,X=F.clientY-D;K.moved=Y*Y+X*X>v}K.event(F).zoom("mouse",n(S(K.that.__zoom,K.mouse[0]=Bs(F,$),K.mouse[1]),K.extent,i))}function ee(F){G.on("mousemove.zoom mouseup.zoom",null),HI(F.view,K.moved),Nc(F),K.event(F).end()}}function U(M,...q){if(e.apply(this,arguments)){var $=this.__zoom,K=Bs(M.changedTouches?M.changedTouches[0]:M,this),G=$.invert(K),z=$.k*(M.shiftKey?.5:2),W=n(S(N($,z),K,G),t.apply(this,q),i);Nc(M),c>0?ms(this).transition().duration(c).call(E,W,K,M):ms(this).call(k.transform,W,K,M)}}function P(M,...q){if(e.apply(this,arguments)){var $=M.touches,K=$.length,G=I(this,q,M.changedTouches.length===K).event(M),z,W,D,H;for(Dg(M),W=0;W<K;++W)D=$[W],H=Bs(D,this),H=[H,this.__zoom.invert(H),D.identifier],G.touch0?!G.touch1&&G.touch0[2]!==H[2]&&(G.touch1=H,G.taps=0):(G.touch0=H,z=!0,G.taps=1+!!f);f&&(f=clearTimeout(f)),z&&(G.taps<2&&(p=H[0],f=setTimeout(function(){f=null},w)),Lh(this),G.start())}}function T(M,...q){if(this.__zooming){var $=I(this,q).event(M),K=M.changedTouches,G=K.length,z,W,D,H;for(Nc(M),z=0;z<G;++z)W=K[z],D=Bs(W,this),$.touch0&&$.touch0[2]===W.identifier?$.touch0[0]=D:$.touch1&&$.touch1[2]===W.identifier&&($.touch1[0]=D);if(W=$.that.__zoom,$.touch1){var ee=$.touch0[0],F=$.touch0[1],Y=$.touch1[0],X=$.touch1[1],Z=(Z=Y[0]-ee[0])*Z+(Z=Y[1]-ee[1])*Z,J=(J=X[0]-F[0])*J+(J=X[1]-F[1])*J;W=N(W,Math.sqrt(Z/J)),D=[(ee[0]+Y[0])/2,(ee[1]+Y[1])/2],H=[(F[0]+X[0])/2,(F[1]+X[1])/2]}else if($.touch0)D=$.touch0[0],H=$.touch0[1];else return;$.zoom("touch",n(S(W,D,H),$.extent,i))}}function B(M,...q){if(this.__zooming){var $=I(this,q).event(M),K=M.changedTouches,G=K.length,z,W;for(Dg(M),m&&clearTimeout(m),m=setTimeout(function(){m=null},w),z=0;z<G;++z)W=K[z],$.touch0&&$.touch0[2]===W.identifier?delete $.touch0:$.touch1&&$.touch1[2]===W.identifier&&delete $.touch1;if($.touch1&&!$.touch0&&($.touch0=$.touch1,delete $.touch1),$.touch0)$.touch0[1]=this.__zoom.invert($.touch0[0]);else if($.end(),$.taps===2&&(W=Bs(W,this),Math.hypot(p[0]-W[0],p[1]-W[1])<b)){var D=ms(this).on("dblclick.zoom");D&&D.apply(this,arguments)}}}return k.wheelDelta=function(M){return arguments.length?(s=typeof M=="function"?M:rh(+M),k):s},k.filter=function(M){return arguments.length?(e=typeof M=="function"?M:rh(!!M),k):e},k.touchable=function(M){return arguments.length?(a=typeof M=="function"?M:rh(!!M),k):a},k.extent=function(M){return arguments.length?(t=typeof M=="function"?M:rh([[+M[0][0],+M[0][1]],[+M[1][0],+M[1][1]]]),k):t},k.scaleExtent=function(M){return arguments.length?(o[0]=+M[0],o[1]=+M[1],k):[o[0],o[1]]},k.translateExtent=function(M){return arguments.length?(i[0][0]=+M[0][0],i[1][0]=+M[1][0],i[0][1]=+M[0][1],i[1][1]=+M[1][1],k):[[i[0][0],i[0][1]],[i[1][0],i[1][1]]]},k.constrain=function(M){return arguments.length?(n=M,k):n},k.duration=function(M){return arguments.length?(c=+M,k):c},k.interpolate=function(M){return arguments.length?(d=M,k):d},k.on=function(){var M=h.on.apply(h,arguments);return M===h?k:M},k.clickDistance=function(M){return arguments.length?(v=(M=+M)*M,k):Math.sqrt(v)},k.tapDistance=function(M){return arguments.length?(b=+M,k):b},k}var vt=TI();const Vf=y.createContext(null),cW=Vf.Provider,na={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.`},aO=na.error001();function at(e,t){const n=y.useContext(Vf);if(n===null)throw new Error(aO);return RI(n,e,t)}const Dt=()=>{const e=y.useContext(Vf);if(e===null)throw new Error(aO);return y.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy}),[e])},uW=e=>e.userSelectionActive?"none":"all";function N1({position:e,children:t,className:n,style:s,...a}){const o=at(uW),i=`${e}`.split("-");return fe.createElement("div",{className:on(["react-flow__panel",n,...i]),style:{...s,pointerEvents:o},...a},t)}function dW({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:fe.createElement(N1,{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"},fe.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}const hW=({x:e,y:t,label:n,labelStyle:s={},labelShowBg:a=!0,labelBgStyle:o={},labelBgPadding:i=[2,4],labelBgBorderRadius:c=2,children:d,className:h,...f})=>{const p=y.useRef(null),[m,w]=y.useState({x:0,y:0,width:0,height:0}),j=on(["react-flow__edge-textwrapper",h]);return y.useEffect(()=>{if(p.current){const v=p.current.getBBox();w({x:v.x,y:v.y,width:v.width,height:v.height})}},[n]),typeof n>"u"||!n?null:fe.createElement("g",{transform:`translate(${e-m.width/2} ${t-m.height/2})`,className:j,visibility:m.width?"visible":"hidden",...f},a&&fe.createElement("rect",{width:m.width+2*i[0],x:-i[0],y:-i[1],height:m.height+2*i[1],className:"react-flow__edge-textbg",style:o,rx:c,ry:c}),fe.createElement("text",{className:"react-flow__edge-text",y:m.height/2,dy:"0.3em",ref:p,style:s},n),d)};var fW=y.memo(hW);const S1=e=>({width:e.offsetWidth,height:e.offsetHeight}),ml=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),_1=(e={x:0,y:0},t)=>({x:ml(e.x,t[0][0],t[1][0]),y:ml(e.y,t[0][1],t[1][1])}),tC=(e,t,n)=>e<t?ml(Math.abs(e-t),1,50)/50:e>n?-ml(Math.abs(e-n),1,50)/50:0,oO=(e,t)=>{const n=tC(e.x,35,t.width-35)*20,s=tC(e.y,35,t.height-35)*20;return[n,s]},iO=e=>{var t;return((t=e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},lO=(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)}),lu=({x:e,y:t,width:n,height:s})=>({x:e,y:t,x2:e+n,y2:t+s}),cO=({x:e,y:t,x2:n,y2:s})=>({x:e,y:t,width:n-e,height:s-t}),nC=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),pW=(e,t)=>cO(lO(lu(e),lu(t))),Jk=(e,t)=>{const n=Math.max(0,Math.min(e.x+e.width,t.x+t.width)-Math.max(e.x,t.x)),s=Math.max(0,Math.min(e.y+e.height,t.y+t.height)-Math.max(e.y,t.y));return Math.ceil(n*s)},mW=e=>gs(e.width)&&gs(e.height)&&gs(e.x)&&gs(e.y),gs=e=>!isNaN(e)&&isFinite(e),Lt=Symbol.for("internals"),uO=["Enter"," ","Escape"],gW=(e,t)=>{},yW=e=>"nativeEvent"in e;function Qk(e){var a,o;const t=yW(e)?e.nativeEvent:e,n=((o=(a=t.composedPath)==null?void 0:a.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 dO=e=>"clientX"in e,Wa=(e,t)=>{var o,i;const n=dO(e),s=n?e.clientX:(o=e.touches)==null?void 0:o[0].clientX,a=n?e.clientY:(i=e.touches)==null?void 0:i[0].clientY;return{x:s-((t==null?void 0:t.left)??0),y:a-((t==null?void 0:t.top)??0)}},tf=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0},Mu=({id:e,path:t,labelX:n,labelY:s,label:a,labelStyle:o,labelShowBg:i,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:p,markerStart:m,interactionWidth:w=20})=>fe.createElement(fe.Fragment,null,fe.createElement("path",{id:e,style:f,d:t,fill:"none",className:"react-flow__edge-path",markerEnd:p,markerStart:m}),w&&fe.createElement("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:w,className:"react-flow__edge-interaction"}),a&&gs(n)&&gs(s)?fe.createElement(fW,{x:n,y:s,label:a,labelStyle:o,labelShowBg:i,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h}):null);Mu.displayName="BaseEdge";function Sc(e,t,n){return n===void 0?n:s=>{const a=t().edges.find(o=>o.id===e);a&&n(s,{...a})}}function hO({sourceX:e,sourceY:t,targetX:n,targetY:s}){const a=Math.abs(n-e)/2,o=n<e?n+a:n-a,i=Math.abs(s-t)/2,c=s<t?s+i:s-i;return[o,c,a,i]}function fO({sourceX:e,sourceY:t,targetX:n,targetY:s,sourceControlX:a,sourceControlY:o,targetControlX:i,targetControlY:c}){const d=e*.125+a*.375+i*.375+n*.125,h=t*.125+o*.375+c*.375+s*.125,f=Math.abs(d-e),p=Math.abs(h-t);return[d,h,f,p]}var Go;(function(e){e.Strict="strict",e.Loose="loose"})(Go||(Go={}));var Io;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Io||(Io={}));var cu;(function(e){e.Partial="partial",e.Full="full"})(cu||(cu={}));var Oa;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Oa||(Oa={}));var nf;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(nf||(nf={}));var Fe;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Fe||(Fe={}));function sC({pos:e,x1:t,y1:n,x2:s,y2:a}){return e===Fe.Left||e===Fe.Right?[.5*(t+s),n]:[t,.5*(n+a)]}function pO({sourceX:e,sourceY:t,sourcePosition:n=Fe.Bottom,targetX:s,targetY:a,targetPosition:o=Fe.Top}){const[i,c]=sC({pos:n,x1:e,y1:t,x2:s,y2:a}),[d,h]=sC({pos:o,x1:s,y1:a,x2:e,y2:t}),[f,p,m,w]=fO({sourceX:e,sourceY:t,targetX:s,targetY:a,sourceControlX:i,sourceControlY:c,targetControlX:d,targetControlY:h});return[`M${e},${t} C${i},${c} ${d},${h} ${s},${a}`,f,p,m,w]}const C1=y.memo(({sourceX:e,sourceY:t,targetX:n,targetY:s,sourcePosition:a=Fe.Bottom,targetPosition:o=Fe.Top,label:i,labelStyle:c,labelShowBg:d,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:w,markerStart:j,interactionWidth:v})=>{const[b,k,N]=pO({sourceX:e,sourceY:t,sourcePosition:a,targetX:n,targetY:s,targetPosition:o});return fe.createElement(Mu,{path:b,labelX:k,labelY:N,label:i,labelStyle:c,labelShowBg:d,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:w,markerStart:j,interactionWidth:v})});C1.displayName="SimpleBezierEdge";const rC={[Fe.Left]:{x:-1,y:0},[Fe.Right]:{x:1,y:0},[Fe.Top]:{x:0,y:-1},[Fe.Bottom]:{x:0,y:1}},wW=({source:e,sourcePosition:t=Fe.Bottom,target:n})=>t===Fe.Left||t===Fe.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},aC=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function xW({source:e,sourcePosition:t=Fe.Bottom,target:n,targetPosition:s=Fe.Top,center:a,offset:o}){const i=rC[t],c=rC[s],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=wW({source:d,sourcePosition:t,target:h}),p=f.x!==0?"x":"y",m=f[p];let w=[],j,v;const b={x:0,y:0},k={x:0,y:0},[N,S,_,E]=hO({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(i[p]*c[p]===-1){j=a.x??N,v=a.y??S;const A=[{x:j,y:d.y},{x:j,y:h.y}],O=[{x:d.x,y:v},{x:h.x,y:v}];i[p]===m?w=p==="x"?A:O:w=p==="x"?O:A}else{const A=[{x:d.x,y:h.y}],O=[{x:h.x,y:d.y}];if(p==="x"?w=i.x===m?O:A:w=i.y===m?A:O,t===s){const B=Math.abs(e[p]-n[p]);if(B<=o){const M=Math.min(o-1,o-B);i[p]===m?b[p]=(d[p]>e[p]?-1:1)*M:k[p]=(h[p]>n[p]?-1:1)*M}}if(t!==s){const B=p==="x"?"y":"x",M=i[p]===c[B],q=d[B]>h[B],$=d[B]<h[B];(i[p]===1&&(!M&&q||M&&$)||i[p]!==1&&(!M&&$||M&&q))&&(w=p==="x"?A:O)}const L={x:d.x+b.x,y:d.y+b.y},U={x:h.x+k.x,y:h.y+k.y},P=Math.max(Math.abs(L.x-w[0].x),Math.abs(U.x-w[0].x)),T=Math.max(Math.abs(L.y-w[0].y),Math.abs(U.y-w[0].y));P>=T?(j=(L.x+U.x)/2,v=w[0].y):(j=w[0].x,v=(L.y+U.y)/2)}return[[e,{x:d.x+b.x,y:d.y+b.y},...w,{x:h.x+k.x,y:h.y+k.y},n],j,v,_,E]}function vW(e,t,n,s){const a=Math.min(aC(e,t)/2,aC(t,n)/2,s),{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+a*h},${i}Q ${o},${i} ${o},${i+a*f}`}const c=e.x<n.x?1:-1,d=e.y<n.y?-1:1;return`L ${o},${i+a*d}Q ${o},${i} ${o+a*c},${i}`}function e0({sourceX:e,sourceY:t,sourcePosition:n=Fe.Bottom,targetX:s,targetY:a,targetPosition:o=Fe.Top,borderRadius:i=5,centerX:c,centerY:d,offset:h=20}){const[f,p,m,w,j]=xW({source:{x:e,y:t},sourcePosition:n,target:{x:s,y:a},targetPosition:o,center:{x:c,y:d},offset:h});return[f.reduce((b,k,N)=>{let S="";return N>0&&N<f.length-1?S=vW(f[N-1],k,f[N+1],i):S=`${N===0?"M":"L"}${k.x} ${k.y}`,b+=S,b},""),p,m,w,j]}const Gf=y.memo(({sourceX:e,sourceY:t,targetX:n,targetY:s,label:a,labelStyle:o,labelShowBg:i,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:f,sourcePosition:p=Fe.Bottom,targetPosition:m=Fe.Top,markerEnd:w,markerStart:j,pathOptions:v,interactionWidth:b})=>{const[k,N,S]=e0({sourceX:e,sourceY:t,sourcePosition:p,targetX:n,targetY:s,targetPosition:m,borderRadius:v==null?void 0:v.borderRadius,offset:v==null?void 0:v.offset});return fe.createElement(Mu,{path:k,labelX:N,labelY:S,label:a,labelStyle:o,labelShowBg:i,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:w,markerStart:j,interactionWidth:b})});Gf.displayName="SmoothStepEdge";const E1=y.memo(e=>{var t;return fe.createElement(Gf,{...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])})});E1.displayName="StepEdge";function bW({sourceX:e,sourceY:t,targetX:n,targetY:s}){const[a,o,i,c]=hO({sourceX:e,sourceY:t,targetX:n,targetY:s});return[`M ${e},${t}L ${n},${s}`,a,o,i,c]}const T1=y.memo(({sourceX:e,sourceY:t,targetX:n,targetY:s,label:a,labelStyle:o,labelShowBg:i,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:p,markerStart:m,interactionWidth:w})=>{const[j,v,b]=bW({sourceX:e,sourceY:t,targetX:n,targetY:s});return fe.createElement(Mu,{path:j,labelX:v,labelY:b,label:a,labelStyle:o,labelShowBg:i,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:p,markerStart:m,interactionWidth:w})});T1.displayName="StraightEdge";function ah(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function oC({pos:e,x1:t,y1:n,x2:s,y2:a,c:o}){switch(e){case Fe.Left:return[t-ah(t-s,o),n];case Fe.Right:return[t+ah(s-t,o),n];case Fe.Top:return[t,n-ah(n-a,o)];case Fe.Bottom:return[t,n+ah(a-n,o)]}}function R1({sourceX:e,sourceY:t,sourcePosition:n=Fe.Bottom,targetX:s,targetY:a,targetPosition:o=Fe.Top,curvature:i=.25}){const[c,d]=oC({pos:n,x1:e,y1:t,x2:s,y2:a,c:i}),[h,f]=oC({pos:o,x1:s,y1:a,x2:e,y2:t,c:i}),[p,m,w,j]=fO({sourceX:e,sourceY:t,targetX:s,targetY:a,sourceControlX:c,sourceControlY:d,targetControlX:h,targetControlY:f});return[`M${e},${t} C${c},${d} ${h},${f} ${s},${a}`,p,m,w,j]}const sf=y.memo(({sourceX:e,sourceY:t,targetX:n,targetY:s,sourcePosition:a=Fe.Bottom,targetPosition:o=Fe.Top,label:i,labelStyle:c,labelShowBg:d,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:w,markerStart:j,pathOptions:v,interactionWidth:b})=>{const[k,N,S]=R1({sourceX:e,sourceY:t,sourcePosition:a,targetX:n,targetY:s,targetPosition:o,curvature:v==null?void 0:v.curvature});return fe.createElement(Mu,{path:k,labelX:N,labelY:S,label:i,labelStyle:c,labelShowBg:d,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:w,markerStart:j,interactionWidth:b})});sf.displayName="BezierEdge";const A1=y.createContext(null),kW=A1.Provider;A1.Consumer;const jW=()=>y.useContext(A1),NW=e=>"id"in e&&"source"in e&&"target"in e,SW=({source:e,sourceHandle:t,target:n,targetHandle:s})=>`reactflow__edge-${e}${t||""}-${n}${s||""}`,t0=(e,t)=>typeof e>"u"?"":typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(s=>`${s}=${e[s]}`).join("&")}`,_W=(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)),CW=(e,t)=>{if(!e.source||!e.target)return t;let n;return NW(e)?n={...e}:n={...e,id:SW(e)},_W(n,t)?t:t.concat(n)},n0=({x:e,y:t},[n,s,a],o,[i,c])=>{const d={x:(e-n)/a,y:(t-s)/a};return o?{x:i*Math.round(d.x/i),y:c*Math.round(d.y/c)}:d},mO=({x:e,y:t},[n,s,a])=>({x:e*a+n,y:t*a+s}),Fo=(e,t=[0,0])=>{if(!e)return{x:0,y:0,positionAbsolute:{x:0,y:0}};const n=(e.width??0)*t[0],s=(e.height??0)*t[1],a={x:e.position.x-n,y:e.position.y-s};return{...a,positionAbsolute:e.positionAbsolute?{x:e.positionAbsolute.x-n,y:e.positionAbsolute.y-s}:a}},Kf=(e,t=[0,0])=>{if(e.length===0)return{x:0,y:0,width:0,height:0};const n=e.reduce((s,a)=>{const{x:o,y:i}=Fo(a,t).positionAbsolute;return lO(s,lu({x:o,y:i,width:a.width||0,height:a.height||0}))},{x:1/0,y:1/0,x2:-1/0,y2:-1/0});return cO(n)},gO=(e,t,[n,s,a]=[0,0,1],o=!1,i=!1,c=[0,0])=>{const d={x:(t.x-n)/a,y:(t.y-s)/a,width:t.width/a,height:t.height/a},h=[];return e.forEach(f=>{const{width:p,height:m,selectable:w=!0,hidden:j=!1}=f;if(i&&!w||j)return!1;const{positionAbsolute:v}=Fo(f,c),b={x:v.x,y:v.y,width:p||0,height:m||0},k=Jk(d,b),N=typeof p>"u"||typeof m>"u"||p===null||m===null,S=o&&k>0,_=(p||0)*(m||0);(N||S||k>=_||f.dragging)&&h.push(f)}),h},yO=(e,t)=>{const n=e.map(s=>s.id);return t.filter(s=>n.includes(s.source)||n.includes(s.target))},wO=(e,t,n,s,a,o=.1)=>{const i=t/(e.width*(1+o)),c=n/(e.height*(1+o)),d=Math.min(i,c),h=ml(d,s,a),f=e.x+e.width/2,p=e.y+e.height/2,m=t/2-f*h,w=n/2-p*h;return{x:m,y:w,zoom:h}},Eo=(e,t=0)=>e.transition().duration(t);function iC(e,t,n,s){return(t[n]||[]).reduce((a,o)=>{var i,c;return`${e.id}-${o.id}-${n}`!==s&&a.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}),a},[])}function EW(e,t,n,s,a,o){const{x:i,y:c}=Wa(e),h=t.elementsFromPoint(i,c).find(j=>j.classList.contains("react-flow__handle"));if(h){const j=h.getAttribute("data-nodeid");if(j){const v=M1(void 0,h),b=h.getAttribute("data-handleid"),k=o({nodeId:j,id:b,type:v});if(k){const N=a.find(S=>S.nodeId===j&&S.type===v&&S.id===b);return{handle:{id:b,type:v,nodeId:j,x:(N==null?void 0:N.x)||n.x,y:(N==null?void 0:N.y)||n.y},validHandleResult:k}}}}let f=[],p=1/0;if(a.forEach(j=>{const v=Math.sqrt((j.x-n.x)**2+(j.y-n.y)**2);if(v<=s){const b=o(j);v<=p&&(v<p?f=[{handle:j,validHandleResult:b}]:v===p&&f.push({handle:j,validHandleResult:b}),p=v)}}),!f.length)return{handle:null,validHandleResult:xO()};if(f.length===1)return f[0];const m=f.some(({validHandleResult:j})=>j.isValid),w=f.some(({handle:j})=>j.type==="target");return f.find(({handle:j,validHandleResult:v})=>w?j.type==="target":m?v.isValid:!0)||f[0]}const TW={source:null,target:null,sourceHandle:null,targetHandle:null},xO=()=>({handleDomNode:null,isValid:!1,connection:TW,endHandle:null});function vO(e,t,n,s,a,o,i){const c=a==="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={...xO(),handleDomNode:d};if(d){const f=M1(void 0,d),p=d.getAttribute("data-nodeid"),m=d.getAttribute("data-handleid"),w=d.classList.contains("connectable"),j=d.classList.contains("connectableend"),v={source:c?p:n,sourceHandle:c?m:s,target:c?n:p,targetHandle:c?s:m};h.connection=v,w&&j&&(t===Go.Strict?c&&f==="source"||!c&&f==="target":p!==n||m!==s)&&(h.endHandle={nodeId:p,handleId:m,type:f},h.isValid=o(v))}return h}function RW({nodes:e,nodeId:t,handleId:n,handleType:s}){return e.reduce((a,o)=>{if(o[Lt]){const{handleBounds:i}=o[Lt];let c=[],d=[];i&&(c=iC(o,i,"source",`${t}-${n}-${s}`),d=iC(o,i,"target",`${t}-${n}-${s}`)),a.push(...c,...d)}return a},[])}function M1(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function Fg(e){e==null||e.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function AW(e,t){let n=null;return t?n="valid":e&&!t&&(n="invalid"),n}function bO({event:e,handleId:t,nodeId:n,onConnect:s,isTarget:a,getState:o,setState:i,isValidConnection:c,edgeUpdaterType:d,onReconnectEnd:h}){const f=iO(e.target),{connectionMode:p,domNode:m,autoPanOnConnect:w,connectionRadius:j,onConnectStart:v,panBy:b,getNodes:k,cancelConnection:N}=o();let S=0,_;const{x:E,y:I}=Wa(e),A=f==null?void 0:f.elementFromPoint(E,I),O=M1(d,A),L=m==null?void 0:m.getBoundingClientRect();if(!L||!O)return;let U,P=Wa(e,L),T=!1,B=null,M=!1,q=null;const $=RW({nodes:k(),nodeId:n,handleId:t,handleType:O}),K=()=>{if(!w)return;const[W,D]=oO(P,L);b({x:W,y:D}),S=requestAnimationFrame(K)};i({connectionPosition:P,connectionStatus:null,connectionNodeId:n,connectionHandleId:t,connectionHandleType:O,connectionStartHandle:{nodeId:n,handleId:t,type:O},connectionEndHandle:null}),v==null||v(e,{nodeId:n,handleId:t,handleType:O});function G(W){const{transform:D}=o();P=Wa(W,L);const{handle:H,validHandleResult:ee}=EW(W,f,n0(P,D,!1,[1,1]),j,$,F=>vO(F,p,n,t,a?"target":"source",c,f));if(_=H,T||(K(),T=!0),q=ee.handleDomNode,B=ee.connection,M=ee.isValid,i({connectionPosition:_&&M?mO({x:_.x,y:_.y},D):P,connectionStatus:AW(!!_,M),connectionEndHandle:ee.endHandle}),!_&&!M&&!q)return Fg(U);B.source!==B.target&&q&&(Fg(U),U=q,q.classList.add("connecting","react-flow__handle-connecting"),q.classList.toggle("valid",M),q.classList.toggle("react-flow__handle-valid",M))}function z(W){var D,H;(_||q)&&B&&M&&(s==null||s(B)),(H=(D=o()).onConnectEnd)==null||H.call(D,W),d&&(h==null||h(W)),Fg(U),N(),cancelAnimationFrame(S),T=!1,M=!1,B=null,q=null,f.removeEventListener("mousemove",G),f.removeEventListener("mouseup",z),f.removeEventListener("touchmove",G),f.removeEventListener("touchend",z)}f.addEventListener("mousemove",G),f.addEventListener("mouseup",z),f.addEventListener("touchmove",G),f.addEventListener("touchend",z)}const lC=()=>!0,MW=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),$W=(e,t,n)=>s=>{const{connectionStartHandle:a,connectionEndHandle:o,connectionClickStartHandle:i}=s;return{connecting:(a==null?void 0:a.nodeId)===e&&(a==null?void 0:a.handleId)===t&&(a==null?void 0:a.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}},kO=y.forwardRef(({type:e="source",position:t=Fe.Top,isValidConnection:n,isConnectable:s=!0,isConnectableStart:a=!0,isConnectableEnd:o=!0,id:i,onConnect:c,children:d,className:h,onMouseDown:f,onTouchStart:p,...m},w)=>{var L,U;const j=i||null,v=e==="target",b=Dt(),k=jW(),{connectOnClick:N,noPanClassName:S}=at(MW,Xt),{connecting:_,clickConnecting:E}=at($W(k,j,e),Xt);k||(U=(L=b.getState()).onError)==null||U.call(L,"010",na.error010());const I=P=>{const{defaultEdgeOptions:T,onConnect:B,hasDefaultEdges:M}=b.getState(),q={...T,...P};if(M){const{edges:$,setEdges:K}=b.getState();K(CW(q,$))}B==null||B(q),c==null||c(q)},A=P=>{if(!k)return;const T=dO(P);a&&(T&&P.button===0||!T)&&bO({event:P,handleId:j,nodeId:k,onConnect:I,isTarget:v,getState:b.getState,setState:b.setState,isValidConnection:n||b.getState().isValidConnection||lC}),T?f==null||f(P):p==null||p(P)},O=P=>{const{onClickConnectStart:T,onClickConnectEnd:B,connectionClickStartHandle:M,connectionMode:q,isValidConnection:$}=b.getState();if(!k||!M&&!a)return;if(!M){T==null||T(P,{nodeId:k,handleId:j,handleType:e}),b.setState({connectionClickStartHandle:{nodeId:k,type:e,handleId:j}});return}const K=iO(P.target),G=n||$||lC,{connection:z,isValid:W}=vO({nodeId:k,id:j,type:e},q,M.nodeId,M.handleId||null,M.type,G,K);W&&I(z),B==null||B(P),b.setState({connectionClickStartHandle:null})};return fe.createElement("div",{"data-handleid":j,"data-nodeid":k,"data-handlepos":t,"data-id":`${k}-${j}-${e}`,className:on(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",S,h,{source:!v,target:v,connectable:s,connectablestart:a,connectableend:o,connecting:E,connectionindicator:s&&(a&&!_||o&&_)}]),onMouseDown:A,onTouchStart:A,onClick:N?O:void 0,ref:w,...m},d)});kO.displayName="Handle";var Ko=y.memo(kO);const jO=({data:e,isConnectable:t,targetPosition:n=Fe.Top,sourcePosition:s=Fe.Bottom})=>fe.createElement(fe.Fragment,null,fe.createElement(Ko,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,fe.createElement(Ko,{type:"source",position:s,isConnectable:t}));jO.displayName="DefaultNode";var s0=y.memo(jO);const NO=({data:e,isConnectable:t,sourcePosition:n=Fe.Bottom})=>fe.createElement(fe.Fragment,null,e==null?void 0:e.label,fe.createElement(Ko,{type:"source",position:n,isConnectable:t}));NO.displayName="InputNode";var SO=y.memo(NO);const _O=({data:e,isConnectable:t,targetPosition:n=Fe.Top})=>fe.createElement(fe.Fragment,null,fe.createElement(Ko,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label);_O.displayName="OutputNode";var CO=y.memo(_O);const $1=()=>null;$1.displayName="GroupNode";const LW=e=>({selectedNodes:e.getNodes().filter(t=>t.selected),selectedEdges:e.edges.filter(t=>t.selected).map(t=>({...t}))}),oh=e=>e.id;function IW(e,t){return Xt(e.selectedNodes.map(oh),t.selectedNodes.map(oh))&&Xt(e.selectedEdges.map(oh),t.selectedEdges.map(oh))}const EO=y.memo(({onSelectionChange:e})=>{const t=Dt(),{selectedNodes:n,selectedEdges:s}=at(LW,IW);return y.useEffect(()=>{const a={nodes:n,edges:s};e==null||e(a),t.getState().onSelectionChange.forEach(o=>o(a))},[n,s,e]),null});EO.displayName="SelectionListener";const OW=e=>!!e.onSelectionChange;function PW({onSelectionChange:e}){const t=at(OW);return e||t?fe.createElement(EO,{onSelectionChange:e}):null}const DW=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 Ii(e,t){y.useEffect(()=>{typeof e<"u"&&t(e)},[e])}function Qe(e,t,n){y.useEffect(()=>{typeof t<"u"&&n({[e]:t})},[t])}const FW=({nodes:e,edges:t,defaultNodes:n,defaultEdges:s,onConnect:a,onConnectStart:o,onConnectEnd:i,onClickConnectStart:c,onClickConnectEnd:d,nodesDraggable:h,nodesConnectable:f,nodesFocusable:p,edgesFocusable:m,edgesUpdatable:w,elevateNodesOnSelect:j,minZoom:v,maxZoom:b,nodeExtent:k,onNodesChange:N,onEdgesChange:S,elementsSelectable:_,connectionMode:E,snapGrid:I,snapToGrid:A,translateExtent:O,connectOnClick:L,defaultEdgeOptions:U,fitView:P,fitViewOptions:T,onNodesDelete:B,onEdgesDelete:M,onNodeDrag:q,onNodeDragStart:$,onNodeDragStop:K,onSelectionDrag:G,onSelectionDragStart:z,onSelectionDragStop:W,noPanClassName:D,nodeOrigin:H,rfId:ee,autoPanOnConnect:F,autoPanOnNodeDrag:Y,onError:X,connectionRadius:Z,isValidConnection:J,nodeDragThreshold:ne})=>{const{setNodes:ce,setEdges:he,setDefaultNodesAndEdges:le,setMinZoom:re,setMaxZoom:ae,setTranslateExtent:de,setNodeExtent:Se,reset:pe}=at(DW,Xt),me=Dt();return y.useEffect(()=>{const be=s==null?void 0:s.map(Ce=>({...Ce,...U}));return le(n,be),()=>{pe()}},[]),Qe("defaultEdgeOptions",U,me.setState),Qe("connectionMode",E,me.setState),Qe("onConnect",a,me.setState),Qe("onConnectStart",o,me.setState),Qe("onConnectEnd",i,me.setState),Qe("onClickConnectStart",c,me.setState),Qe("onClickConnectEnd",d,me.setState),Qe("nodesDraggable",h,me.setState),Qe("nodesConnectable",f,me.setState),Qe("nodesFocusable",p,me.setState),Qe("edgesFocusable",m,me.setState),Qe("edgesUpdatable",w,me.setState),Qe("elementsSelectable",_,me.setState),Qe("elevateNodesOnSelect",j,me.setState),Qe("snapToGrid",A,me.setState),Qe("snapGrid",I,me.setState),Qe("onNodesChange",N,me.setState),Qe("onEdgesChange",S,me.setState),Qe("connectOnClick",L,me.setState),Qe("fitViewOnInit",P,me.setState),Qe("fitViewOnInitOptions",T,me.setState),Qe("onNodesDelete",B,me.setState),Qe("onEdgesDelete",M,me.setState),Qe("onNodeDrag",q,me.setState),Qe("onNodeDragStart",$,me.setState),Qe("onNodeDragStop",K,me.setState),Qe("onSelectionDrag",G,me.setState),Qe("onSelectionDragStart",z,me.setState),Qe("onSelectionDragStop",W,me.setState),Qe("noPanClassName",D,me.setState),Qe("nodeOrigin",H,me.setState),Qe("rfId",ee,me.setState),Qe("autoPanOnConnect",F,me.setState),Qe("autoPanOnNodeDrag",Y,me.setState),Qe("onError",X,me.setState),Qe("connectionRadius",Z,me.setState),Qe("isValidConnection",J,me.setState),Qe("nodeDragThreshold",ne,me.setState),Ii(e,ce),Ii(t,he),Ii(v,re),Ii(b,ae),Ii(O,de),Ii(k,Se),null},cC={display:"none"},BW={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",RO="react-flow__edge-desc",qW="react-flow__aria-live",UW=e=>e.ariaLiveMessage;function WW({rfId:e}){const t=at(UW);return fe.createElement("div",{id:`${qW}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:BW},t)}function HW({rfId:e,disableKeyboardA11y:t}){return fe.createElement(fe.Fragment,null,fe.createElement("div",{id:`${TO}-${e}`,style:cC},"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."," "),fe.createElement("div",{id:`${RO}-${e}`,style:cC},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!t&&fe.createElement(WW,{rfId:e}))}var uu=(e=null,t={actInsideInputWithModifier:!0})=>{const[n,s]=y.useState(!1),a=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,m)=>p.concat(...m),[]);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(a.current=w.ctrlKey||w.metaKey||w.shiftKey,(!a.current||a.current&&!t.actInsideInputWithModifier)&&Qk(w))return!1;const v=dC(w.code,c);o.current.add(w[v]),uC(i,o.current,!1)&&(w.preventDefault(),s(!0))},p=w=>{if((!a.current||a.current&&!t.actInsideInputWithModifier)&&Qk(w))return!1;const v=dC(w.code,c);uC(i,o.current,!0)?(s(!1),o.current.clear()):o.current.delete(w[v]),w.key==="Meta"&&o.current.clear(),a.current=!1},m=()=>{o.current.clear(),s(!1)};return h==null||h.addEventListener("keydown",f),h==null||h.addEventListener("keyup",p),window.addEventListener("blur",m),()=>{h==null||h.removeEventListener("keydown",f),h==null||h.removeEventListener("keyup",p),window.removeEventListener("blur",m)}}},[e,s]),n};function uC(e,t,n){return e.filter(s=>n||s.length===t.size).some(s=>s.every(a=>t.has(a)))}function dC(e,t){return t.includes(e)?"code":"key"}function AO(e,t,n,s){var c,d;const a=e.parentNode||e.parentId;if(!a)return n;const o=t.get(a),i=Fo(o,s);return AO(o,t,{x:(n.x??0)+i.x,y:(n.y??0)+i.y,z:(((c=o[Lt])==null?void 0:c.z)??0)>(n.z??0)?((d=o[Lt])==null?void 0:d.z)??0:n.z??0},s)}function MO(e,t,n){e.forEach(s=>{var o;const a=s.parentNode||s.parentId;if(a&&!e.has(a))throw new Error(`Parent node ${a} not found`);if(a||n!=null&&n[s.id]){const{x:i,y:c,z:d}=AO(s,e,{...s.position,z:((o=s[Lt])==null?void 0:o.z)??0},t);s.positionAbsolute={x:i,y:c},s[Lt].z=d,n!=null&&n[s.id]&&(s[Lt].isParent=!0)}})}function Bg(e,t,n,s){const a=new Map,o={},i=s?1e3:0;return e.forEach(c=>{var w;const d=(gs(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 m=(h==null?void 0:h.type)&&(h==null?void 0:h.type)!==c.type;Object.defineProperty(f,Lt,{enumerable:!1,value:{handleBounds:m||(w=h==null?void 0:h[Lt])==null?void 0:w.handleBounds,z:d}}),a.set(c.id,f)}),MO(a,n,o),a}function $O(e,t={}){const{getNodes:n,width:s,height:a,minZoom:o,maxZoom:i,d3Zoom:c,d3Selection:d,fitViewOnInitDone:h,fitViewOnInit:f,nodeOrigin:p}=e(),m=t.initial&&!h&&f;if(c&&d&&(m||!t.initial)){const j=n().filter(b=>{var N;const k=t.includeHiddenNodes?b.width&&b.height:!b.hidden;return(N=t.nodes)!=null&&N.length?k&&t.nodes.some(S=>S.id===b.id):k}),v=j.every(b=>b.width&&b.height);if(j.length>0&&v){const b=Kf(j,p),{x:k,y:N,zoom:S}=wO(b,s,a,t.minZoom??o,t.maxZoom??i,t.padding??.1),_=Qr.translate(k,N).scale(S);return typeof t.duration=="number"&&t.duration>0?c.transform(Eo(d,t.duration),_):c.transform(d,_),!0}}return!1}function zW(e,t){return e.forEach(n=>{const s=t.get(n.id);s&&t.set(s.id,{...s,[Lt]:s[Lt],selected:n.selected})}),new Map(t)}function VW(e,t){return t.map(n=>{const s=e.find(a=>a.id===n.id);return s&&(n.selected=s.selected),n})}function ih({changedNodes:e,changedEdges:t,get:n,set:s}){const{nodeInternals:a,edges:o,onNodesChange:i,onEdgesChange:c,hasDefaultNodes:d,hasDefaultEdges:h}=n();e!=null&&e.length&&(d&&s({nodeInternals:zW(e,a)}),i==null||i(e)),t!=null&&t.length&&(h&&s({edges:VW(t,o)}),c==null||c(t))}const Oi=()=>{},GW={zoomIn:Oi,zoomOut:Oi,zoomTo:Oi,getZoom:()=>1,setViewport:Oi,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:Oi,fitBounds:Oi,project:e=>e,screenToFlowPosition:e=>e,flowToScreenPosition:e=>e,viewportInitialized:!1},KW=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection}),YW=()=>{const e=Dt(),{d3Zoom:t,d3Selection:n}=at(KW,Xt);return y.useMemo(()=>n&&t?{zoomIn:a=>t.scaleBy(Eo(n,a==null?void 0:a.duration),1.2),zoomOut:a=>t.scaleBy(Eo(n,a==null?void 0:a.duration),1/1.2),zoomTo:(a,o)=>t.scaleTo(Eo(n,o==null?void 0:o.duration),a),getZoom:()=>e.getState().transform[2],setViewport:(a,o)=>{const[i,c,d]=e.getState().transform,h=Qr.translate(a.x??i,a.y??c).scale(a.zoom??d);t.transform(Eo(n,o==null?void 0:o.duration),h)},getViewport:()=>{const[a,o,i]=e.getState().transform;return{x:a,y:o,zoom:i}},fitView:a=>$O(e.getState,a),setCenter:(a,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-a*f,m=d/2-o*f,w=Qr.translate(p,m).scale(f);t.transform(Eo(n,i==null?void 0:i.duration),w)},fitBounds:(a,o)=>{const{width:i,height:c,minZoom:d,maxZoom:h}=e.getState(),{x:f,y:p,zoom:m}=wO(a,i,c,d,h,(o==null?void 0:o.padding)??.1),w=Qr.translate(f,p).scale(m);t.transform(Eo(n,o==null?void 0:o.duration),w)},project:a=>{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"),n0(a,o,i,c)},screenToFlowPosition:a=>{const{transform:o,snapToGrid:i,snapGrid:c,domNode:d}=e.getState();if(!d)return a;const{x:h,y:f}=d.getBoundingClientRect(),p={x:a.x-h,y:a.y-f};return n0(p,o,i,c)},flowToScreenPosition:a=>{const{transform:o,domNode:i}=e.getState();if(!i)return a;const{x:c,y:d}=i.getBoundingClientRect(),h=mO(a,o);return{x:h.x+c,y:h.y+d}},viewportInitialized:!0}:GW,[t,n])};function _l(){const e=YW(),t=Dt(),n=y.useCallback(()=>t.getState().getNodes().map(v=>({...v})),[]),s=y.useCallback(v=>t.getState().nodeInternals.get(v),[]),a=y.useCallback(()=>{const{edges:v=[]}=t.getState();return v.map(b=>({...b}))},[]),o=y.useCallback(v=>{const{edges:b=[]}=t.getState();return b.find(k=>k.id===v)},[]),i=y.useCallback(v=>{const{getNodes:b,setNodes:k,hasDefaultNodes:N,onNodesChange:S}=t.getState(),_=b(),E=typeof v=="function"?v(_):v;if(N)k(E);else if(S){const I=E.length===0?_.map(A=>({type:"remove",id:A.id})):E.map(A=>({item:A,type:"reset"}));S(I)}},[]),c=y.useCallback(v=>{const{edges:b=[],setEdges:k,hasDefaultEdges:N,onEdgesChange:S}=t.getState(),_=typeof v=="function"?v(b):v;if(N)k(_);else if(S){const E=_.length===0?b.map(I=>({type:"remove",id:I.id})):_.map(I=>({item:I,type:"reset"}));S(E)}},[]),d=y.useCallback(v=>{const b=Array.isArray(v)?v:[v],{getNodes:k,setNodes:N,hasDefaultNodes:S,onNodesChange:_}=t.getState();if(S){const I=[...k(),...b];N(I)}else if(_){const E=b.map(I=>({item:I,type:"add"}));_(E)}},[]),h=y.useCallback(v=>{const b=Array.isArray(v)?v:[v],{edges:k=[],setEdges:N,hasDefaultEdges:S,onEdgesChange:_}=t.getState();if(S)N([...k,...b]);else if(_){const E=b.map(I=>({item:I,type:"add"}));_(E)}},[]),f=y.useCallback(()=>{const{getNodes:v,edges:b=[],transform:k}=t.getState(),[N,S,_]=k;return{nodes:v().map(E=>({...E})),edges:b.map(E=>({...E})),viewport:{x:N,y:S,zoom:_}}},[]),p=y.useCallback(({nodes:v,edges:b})=>{const{nodeInternals:k,getNodes:N,edges:S,hasDefaultNodes:_,hasDefaultEdges:E,onNodesDelete:I,onEdgesDelete:A,onNodesChange:O,onEdgesChange:L}=t.getState(),U=(v||[]).map(q=>q.id),P=(b||[]).map(q=>q.id),T=N().reduce((q,$)=>{const K=$.parentNode||$.parentId,G=!U.includes($.id)&&K&&q.find(W=>W.id===K);return(typeof $.deletable=="boolean"?$.deletable:!0)&&(U.includes($.id)||G)&&q.push($),q},[]),B=S.filter(q=>typeof q.deletable=="boolean"?q.deletable:!0),M=B.filter(q=>P.includes(q.id));if(T||M){const q=yO(T,B),$=[...M,...q],K=$.reduce((G,z)=>(G.includes(z.id)||G.push(z.id),G),[]);if((E||_)&&(E&&t.setState({edges:S.filter(G=>!K.includes(G.id))}),_&&(T.forEach(G=>{k.delete(G.id)}),t.setState({nodeInternals:new Map(k)}))),K.length>0&&(A==null||A($),L&&L(K.map(G=>({id:G,type:"remove"})))),T.length>0&&(I==null||I(T),O)){const G=T.map(z=>({id:z.id,type:"remove"}));O(G)}}},[]),m=y.useCallback(v=>{const b=mW(v),k=b?null:t.getState().nodeInternals.get(v.id);return!b&&!k?[null,null,b]:[b?v:nC(k),k,b]},[]),w=y.useCallback((v,b=!0,k)=>{const[N,S,_]=m(v);return N?(k||t.getState().getNodes()).filter(E=>{if(!_&&(E.id===S.id||!E.positionAbsolute))return!1;const I=nC(E),A=Jk(I,N);return b&&A>0||A>=N.width*N.height}):[]},[]),j=y.useCallback((v,b,k=!0)=>{const[N]=m(v);if(!N)return!1;const S=Jk(N,b);return k&&S>0||S>=N.width*N.height},[]);return y.useMemo(()=>({...e,getNodes:n,getNode:s,getEdges:a,getEdge:o,setNodes:i,setEdges:c,addNodes:d,addEdges:h,toObject:f,deleteElements:p,getIntersectingNodes:w,isNodeIntersecting:j}),[e,n,s,a,o,i,c,d,h,f,p,w,j])}const XW={actInsideInputWithModifier:!1};var ZW=({deleteKeyCode:e,multiSelectionKeyCode:t})=>{const n=Dt(),{deleteElements:s}=_l(),a=uu(e,XW),o=uu(t);y.useEffect(()=>{if(a){const{edges:i,getNodes:c}=n.getState(),d=c().filter(f=>f.selected),h=i.filter(f=>f.selected);s({nodes:d,edges:h}),n.setState({nodesSelectionActive:!1})}},[a]),y.useEffect(()=>{n.setState({multiSelectionActive:o})},[o])};function JW(e){const t=Dt();y.useEffect(()=>{let n;const s=()=>{var o,i;if(!e.current)return;const a=S1(e.current);(a.height===0||a.width===0)&&((i=(o=t.getState()).onError)==null||i.call(o,"004",na.error004())),t.setState({width:a.width||500,height:a.height||500})};return s(),window.addEventListener("resize",s),e.current&&(n=new ResizeObserver(()=>s()),n.observe(e.current)),()=>{window.removeEventListener("resize",s),n&&e.current&&n.unobserve(e.current)}},[])}const L1={position:"absolute",width:"100%",height:"100%",top:0,left:0},QW=(e,t)=>e.x!==t.x||e.y!==t.y||e.zoom!==t.k,lh=e=>({x:e.x,y:e.y,zoom:e.k}),Pi=(e,t)=>e.target.closest(`.${t}`),hC=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),fC=e=>{const t=e.ctrlKey&&tf()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t},eH=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),tH=({onMove:e,onMoveStart:t,onMoveEnd:n,onPaneContextMenu:s,zoomOnScroll:a=!0,zoomOnPinch:o=!0,panOnScroll:i=!1,panOnScrollSpeed:c=.5,panOnScrollMode:d=Io.Free,zoomOnDoubleClick:h=!0,elementsSelectable:f,panOnDrag:p=!0,defaultViewport:m,translateExtent:w,minZoom:j,maxZoom:v,zoomActivationKeyCode:b,preventScrolling:k=!0,children:N,noWheelClassName:S,noPanClassName:_})=>{const E=y.useRef(),I=Dt(),A=y.useRef(!1),O=y.useRef(!1),L=y.useRef(null),U=y.useRef({x:0,y:0,zoom:0}),{d3Zoom:P,d3Selection:T,d3ZoomHandler:B,userSelectionActive:M}=at(eH,Xt),q=uu(b),$=y.useRef(0),K=y.useRef(!1),G=y.useRef();return JW(L),y.useEffect(()=>{if(L.current){const z=L.current.getBoundingClientRect(),W=rO().scaleExtent([j,v]).translateExtent(w),D=ms(L.current).call(W),H=Qr.translate(m.x,m.y).scale(ml(m.zoom,j,v)),ee=[[0,0],[z.width,z.height]],F=W.constrain()(H,ee,w);W.transform(D,F),W.wheelDelta(fC),I.setState({d3Zoom:W,d3Selection:D,d3ZoomHandler:D.on("wheel.zoom"),transform:[F.x,F.y,F.k],domNode:L.current.closest(".react-flow")})}},[]),y.useEffect(()=>{T&&P&&(i&&!q&&!M?T.on("wheel.zoom",z=>{if(Pi(z,S))return!1;z.preventDefault(),z.stopImmediatePropagation();const W=T.property("__zoom").k||1;if(z.ctrlKey&&o){const J=Bs(z),ne=fC(z),ce=W*Math.pow(2,ne);P.scaleTo(T,ce,J,z);return}const D=z.deltaMode===1?20:1;let H=d===Io.Vertical?0:z.deltaX*D,ee=d===Io.Horizontal?0:z.deltaY*D;!tf()&&z.shiftKey&&d!==Io.Vertical&&(H=z.deltaY*D,ee=0),P.translateBy(T,-(H/W)*c,-(ee/W)*c,{internal:!0});const F=lh(T.property("__zoom")),{onViewportChangeStart:Y,onViewportChange:X,onViewportChangeEnd:Z}=I.getState();clearTimeout(G.current),K.current||(K.current=!0,t==null||t(z,F),Y==null||Y(F)),K.current&&(e==null||e(z,F),X==null||X(F),G.current=setTimeout(()=>{n==null||n(z,F),Z==null||Z(F),K.current=!1},150))},{passive:!1}):typeof B<"u"&&T.on("wheel.zoom",function(z,W){if(!k&&z.type==="wheel"&&!z.ctrlKey||Pi(z,S))return null;z.preventDefault(),B.call(this,z,W)},{passive:!1}))},[M,i,d,T,P,B,q,o,k,S,t,e,n]),y.useEffect(()=>{P&&P.on("start",z=>{var H,ee;if(!z.sourceEvent||z.sourceEvent.internal)return null;$.current=(H=z.sourceEvent)==null?void 0:H.button;const{onViewportChangeStart:W}=I.getState(),D=lh(z.transform);A.current=!0,U.current=D,((ee=z.sourceEvent)==null?void 0:ee.type)==="mousedown"&&I.setState({paneDragging:!0}),W==null||W(D),t==null||t(z.sourceEvent,D)})},[P,t]),y.useEffect(()=>{P&&(M&&!A.current?P.on("zoom",null):M||P.on("zoom",z=>{var D;const{onViewportChange:W}=I.getState();if(I.setState({transform:[z.transform.x,z.transform.y,z.transform.k]}),O.current=!!(s&&hC(p,$.current??0)),(e||W)&&!((D=z.sourceEvent)!=null&&D.internal)){const H=lh(z.transform);W==null||W(H),e==null||e(z.sourceEvent,H)}}))},[M,P,e,p,s]),y.useEffect(()=>{P&&P.on("end",z=>{if(!z.sourceEvent||z.sourceEvent.internal)return null;const{onViewportChangeEnd:W}=I.getState();if(A.current=!1,I.setState({paneDragging:!1}),s&&hC(p,$.current??0)&&!O.current&&s(z.sourceEvent),O.current=!1,(n||W)&&QW(U.current,z.transform)){const D=lh(z.transform);U.current=D,clearTimeout(E.current),E.current=setTimeout(()=>{W==null||W(D),n==null||n(z.sourceEvent,D)},i?150:0)}})},[P,i,p,n,s]),y.useEffect(()=>{P&&P.filter(z=>{const W=q||a,D=o&&z.ctrlKey;if((p===!0||Array.isArray(p)&&p.includes(1))&&z.button===1&&z.type==="mousedown"&&(Pi(z,"react-flow__node")||Pi(z,"react-flow__edge")))return!0;if(!p&&!W&&!i&&!h&&!o||M||!h&&z.type==="dblclick"||Pi(z,S)&&z.type==="wheel"||Pi(z,_)&&(z.type!=="wheel"||i&&z.type==="wheel"&&!q)||!o&&z.ctrlKey&&z.type==="wheel"||!W&&!i&&!D&&z.type==="wheel"||!p&&(z.type==="mousedown"||z.type==="touchstart")||Array.isArray(p)&&!p.includes(z.button)&&z.type==="mousedown")return!1;const H=Array.isArray(p)&&p.includes(z.button)||!z.button||z.button<=1;return(!z.ctrlKey||z.type==="wheel")&&H})},[M,P,a,o,i,h,p,f,q]),fe.createElement("div",{className:"react-flow__renderer",ref:L,style:L1},N)},nH=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function sH(){const{userSelectionActive:e,userSelectionRect:t}=at(nH,Xt);return e&&t?fe.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 pC(e,t){const n=t.parentNode||t.parentId,s=e.find(a=>a.id===n);if(s){const a=t.position.x+t.width-s.width,o=t.position.y+t.height-s.height;if(a>0||o>0||t.position.x<0||t.position.y<0){if(s.style={...s.style},s.style.width=s.style.width??s.width,s.style.height=s.style.height??s.height,a>0&&(s.style.width+=a),o>0&&(s.style.height+=o),t.position.x<0){const i=Math.abs(t.position.x);s.position.x=s.position.x-i,s.style.width+=i,t.position.x=0}if(t.position.y<0){const i=Math.abs(t.position.y);s.position.y=s.position.y-i,s.style.height+=i,t.position.y=0}s.width=s.style.width,s.height=s.style.height}}}function rH(e,t){if(e.some(s=>s.type==="reset"))return e.filter(s=>s.type==="reset").map(s=>s.item);const n=e.filter(s=>s.type==="add").map(s=>s.item);return t.reduce((s,a)=>{const o=e.filter(c=>c.id===a.id);if(o.length===0)return s.push(a),s;const i={...a};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&&pC(s,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&&pC(s,i);break}case"remove":return s}return s.push(i),s},n)}function aH(e,t){return rH(e,t)}const Ia=(e,t)=>({id:e,type:"select",selected:t});function Ji(e,t){return e.reduce((n,s)=>{const a=t.includes(s.id);return!s.selected&&a?(s.selected=!0,n.push(Ia(s.id,!0))):s.selected&&!a&&(s.selected=!1,n.push(Ia(s.id,!1))),n},[])}const qg=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},oH=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),LO=y.memo(({isSelecting:e,selectionMode:t=cu.Full,panOnDrag:n,onSelectionStart:s,onSelectionEnd:a,onPaneClick:o,onPaneContextMenu:i,onPaneScroll:c,onPaneMouseEnter:d,onPaneMouseMove:h,onPaneMouseLeave:f,children:p})=>{const m=y.useRef(null),w=Dt(),j=y.useRef(0),v=y.useRef(0),b=y.useRef(),{userSelectionActive:k,elementsSelectable:N,dragging:S}=at(oH,Xt),_=()=>{w.setState({userSelectionActive:!1,userSelectionRect:null}),j.current=0,v.current=0},E=B=>{o==null||o(B),w.getState().resetSelectedElements(),w.setState({nodesSelectionActive:!1})},I=B=>{if(Array.isArray(n)&&(n!=null&&n.includes(2))){B.preventDefault();return}i==null||i(B)},A=c?B=>c(B):void 0,O=B=>{const{resetSelectedElements:M,domNode:q}=w.getState();if(b.current=q==null?void 0:q.getBoundingClientRect(),!N||!e||B.button!==0||B.target!==m.current||!b.current)return;const{x:$,y:K}=Wa(B,b.current);M(),w.setState({userSelectionRect:{width:0,height:0,startX:$,startY:K,x:$,y:K}}),s==null||s(B)},L=B=>{const{userSelectionRect:M,nodeInternals:q,edges:$,transform:K,onNodesChange:G,onEdgesChange:z,nodeOrigin:W,getNodes:D}=w.getState();if(!e||!b.current||!M)return;w.setState({userSelectionActive:!0,nodesSelectionActive:!1});const H=Wa(B,b.current),ee=M.startX??0,F=M.startY??0,Y={...M,x:H.x<ee?H.x:ee,y:H.y<F?H.y:F,width:Math.abs(H.x-ee),height:Math.abs(H.y-F)},X=D(),Z=gO(q,Y,K,t===cu.Partial,!0,W),J=yO(Z,$).map(ce=>ce.id),ne=Z.map(ce=>ce.id);if(j.current!==ne.length){j.current=ne.length;const ce=Ji(X,ne);ce.length&&(G==null||G(ce))}if(v.current!==J.length){v.current=J.length;const ce=Ji($,J);ce.length&&(z==null||z(ce))}w.setState({userSelectionRect:Y})},U=B=>{if(B.button!==0)return;const{userSelectionRect:M}=w.getState();!k&&M&&B.target===m.current&&(E==null||E(B)),w.setState({nodesSelectionActive:j.current>0}),_(),a==null||a(B)},P=B=>{k&&(w.setState({nodesSelectionActive:j.current>0}),a==null||a(B)),_()},T=N&&(e||k);return fe.createElement("div",{className:on(["react-flow__pane",{dragging:S,selection:e}]),onClick:T?void 0:qg(E,m),onContextMenu:qg(I,m),onWheel:qg(A,m),onMouseEnter:T?void 0:d,onMouseDown:T?O:void 0,onMouseMove:T?L:h,onMouseUp:T?U:void 0,onMouseLeave:T?P:f,ref:m,style:L1},p,fe.createElement(sH,null))});LO.displayName="Pane";function IO(e,t){const n=e.parentNode||e.parentId;if(!n)return!1;const s=t.get(n);return s?s.selected?!0:IO(s,t):!1}function mC(e,t,n){let s=e;do{if(s!=null&&s.matches(t))return!0;if(s===n.current)return!1;s=s.parentElement}while(s);return!1}function iH(e,t,n,s){return Array.from(e.values()).filter(a=>(a.selected||a.id===s)&&(!a.parentNode||a.parentId||!IO(a,e))&&(a.draggable||t&&typeof a.draggable>"u")).map(a=>{var o,i;return{id:a.id,position:a.position||{x:0,y:0},positionAbsolute:a.positionAbsolute||{x:0,y:0},distance:{x:n.x-(((o=a.positionAbsolute)==null?void 0:o.x)??0),y:n.y-(((i=a.positionAbsolute)==null?void 0:i.y)??0)},delta:{x:0,y:0},extent:a.extent,parentNode:a.parentNode||a.parentId,parentId:a.parentNode||a.parentId,width:a.width,height:a.height,expandParent:a.expandParent}})}function lH(e,t){return!t||t==="parent"?t:[t[0],[t[1][0]-(e.width||0),t[1][1]-(e.height||0)]]}function OO(e,t,n,s,a=[0,0],o){const i=lH(e,e.extent||s);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:m,y:w}=Fo(p,a).positionAbsolute;c=p&&gs(m)&&gs(w)&&gs(p.width)&&gs(p.height)?[[m+e.width*a[0],w+e.height*a[1]],[m+p.width-e.width+e.width*a[0],w+p.height-e.height+e.height*a[1]]]:c}else o==null||o("005",na.error005()),c=i;else if(e.extent&&d&&e.extent!=="parent"){const p=n.get(d),{x:m,y:w}=Fo(p,a).positionAbsolute;c=[[e.extent[0][0]+m,e.extent[0][1]+w],[e.extent[1][0]+m,e.extent[1][1]+w]]}let h={x:0,y:0};if(d){const p=n.get(d);h=Fo(p,a).positionAbsolute}const f=c&&c!=="parent"?_1(t,c):t;return{position:{x:f.x-h.x,y:f.y-h.y},positionAbsolute:f}}function Ug({nodeId:e,dragItems:t,nodeInternals:n}){const s=t.map(a=>({...n.get(a.id),position:a.position,positionAbsolute:a.positionAbsolute}));return[e?s.find(a=>a.id===e):s[0],s]}const gC=(e,t,n,s)=>{const a=t.querySelectorAll(e);if(!a||!a.length)return null;const o=Array.from(a),i=t.getBoundingClientRect(),c={x:i.width*s[0],y:i.height*s[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,...S1(d)}})};function _c(e,t,n){return n===void 0?n:s=>{const a=t().nodeInternals.get(e);a&&n(s,{...a})}}function r0({id:e,store:t,unselect:n=!1,nodeRef:s}){const{addSelectedNodes:a,unselectNodesAndEdges:o,multiSelectionActive:i,nodeInternals:c,onError:d}=t.getState(),h=c.get(e);if(!h){d==null||d("012",na.error012(e));return}t.setState({nodesSelectionActive:!1}),h.selected?(n||h.selected&&i)&&(o({nodes:[h],edges:[]}),requestAnimationFrame(()=>{var f;return(f=s==null?void 0:s.current)==null?void 0:f.blur()})):a([e])}function cH(){const e=Dt();return y.useCallback(({sourceEvent:n})=>{const{transform:s,snapGrid:a,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-s[0])/s[2],y:(c-s[1])/s[2]};return{xSnapped:o?a[0]*Math.round(d.x/a[0]):d.x,ySnapped:o?a[1]*Math.round(d.y/a[1]):d.y,...d}},[])}function Wg(e){return(t,n,s)=>e==null?void 0:e(t,s)}function PO({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:s,nodeId:a,isSelectable:o,selectNodesOnDrag:i}){const c=Dt(),[d,h]=y.useState(!1),f=y.useRef([]),p=y.useRef({x:null,y:null}),m=y.useRef(0),w=y.useRef(null),j=y.useRef({x:0,y:0}),v=y.useRef(null),b=y.useRef(!1),k=y.useRef(!1),N=y.useRef(!1),S=cH();return y.useEffect(()=>{if(e!=null&&e.current){const _=ms(e.current),E=({x:O,y:L})=>{const{nodeInternals:U,onNodeDrag:P,onSelectionDrag:T,updateNodePositions:B,nodeExtent:M,snapGrid:q,snapToGrid:$,nodeOrigin:K,onError:G}=c.getState();p.current={x:O,y:L};let z=!1,W={x:0,y:0,x2:0,y2:0};if(f.current.length>1&&M){const H=Kf(f.current,K);W=lu(H)}if(f.current=f.current.map(H=>{const ee={x:O-H.distance.x,y:L-H.distance.y};$&&(ee.x=q[0]*Math.round(ee.x/q[0]),ee.y=q[1]*Math.round(ee.y/q[1]));const F=[[M[0][0],M[0][1]],[M[1][0],M[1][1]]];f.current.length>1&&M&&!H.extent&&(F[0][0]=H.positionAbsolute.x-W.x+M[0][0],F[1][0]=H.positionAbsolute.x+(H.width??0)-W.x2+M[1][0],F[0][1]=H.positionAbsolute.y-W.y+M[0][1],F[1][1]=H.positionAbsolute.y+(H.height??0)-W.y2+M[1][1]);const Y=OO(H,ee,U,F,K,G);return z=z||H.position.x!==Y.position.x||H.position.y!==Y.position.y,H.position=Y.position,H.positionAbsolute=Y.positionAbsolute,H}),!z)return;B(f.current,!0,!0),h(!0);const D=a?P:Wg(T);if(D&&v.current){const[H,ee]=Ug({nodeId:a,dragItems:f.current,nodeInternals:U});D(v.current,H,ee)}},I=()=>{if(!w.current)return;const[O,L]=oO(j.current,w.current);if(O!==0||L!==0){const{transform:U,panBy:P}=c.getState();p.current.x=(p.current.x??0)-O/U[2],p.current.y=(p.current.y??0)-L/U[2],P({x:O,y:L})&&E(p.current)}m.current=requestAnimationFrame(I)},A=O=>{var K;const{nodeInternals:L,multiSelectionActive:U,nodesDraggable:P,unselectNodesAndEdges:T,onNodeDragStart:B,onSelectionDragStart:M}=c.getState();k.current=!0;const q=a?B:Wg(M);(!i||!o)&&!U&&a&&((K=L.get(a))!=null&&K.selected||T()),a&&o&&i&&r0({id:a,store:c,nodeRef:e});const $=S(O);if(p.current=$,f.current=iH(L,P,$,a),q&&f.current){const[G,z]=Ug({nodeId:a,dragItems:f.current,nodeInternals:L});q(O.sourceEvent,G,z)}};if(t)_.on(".drag",null);else{const O=xq().on("start",L=>{const{domNode:U,nodeDragThreshold:P}=c.getState();P===0&&A(L),N.current=!1;const T=S(L);p.current=T,w.current=(U==null?void 0:U.getBoundingClientRect())||null,j.current=Wa(L.sourceEvent,w.current)}).on("drag",L=>{var B,M;const U=S(L),{autoPanOnNodeDrag:P,nodeDragThreshold:T}=c.getState();if(L.sourceEvent.type==="touchmove"&&L.sourceEvent.touches.length>1&&(N.current=!0),!N.current){if(!b.current&&k.current&&P&&(b.current=!0,I()),!k.current){const q=U.xSnapped-(((B=p==null?void 0:p.current)==null?void 0:B.x)??0),$=U.ySnapped-(((M=p==null?void 0:p.current)==null?void 0:M.y)??0);Math.sqrt(q*q+$*$)>T&&A(L)}(p.current.x!==U.xSnapped||p.current.y!==U.ySnapped)&&f.current&&k.current&&(v.current=L.sourceEvent,j.current=Wa(L.sourceEvent,w.current),E(U))}}).on("end",L=>{if(!(!k.current||N.current)&&(h(!1),b.current=!1,k.current=!1,cancelAnimationFrame(m.current),f.current)){const{updateNodePositions:U,nodeInternals:P,onNodeDragStop:T,onSelectionDragStop:B}=c.getState(),M=a?T:Wg(B);if(U(f.current,!1,!1),M){const[q,$]=Ug({nodeId:a,dragItems:f.current,nodeInternals:P});M(L.sourceEvent,q,$)}}}).filter(L=>{const U=L.target;return!L.button&&(!n||!mC(U,`.${n}`,e))&&(!s||mC(U,s,e))});return _.call(O),()=>{_.on(".drag",null)}}}},[e,t,n,s,o,c,a,i,S]),d}function DO(){const e=Dt();return y.useCallback(n=>{const{nodeInternals:s,nodeExtent:a,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")),m=c?d[0]:5,w=c?d[1]:5,j=n.isShiftPressed?4:1,v=n.x*m*j,b=n.y*w*j,k=p.map(N=>{if(N.positionAbsolute){const S={x:N.positionAbsolute.x+v,y:N.positionAbsolute.y+b};c&&(S.x=d[0]*Math.round(S.x/d[0]),S.y=d[1]*Math.round(S.y/d[1]));const{positionAbsolute:_,position:E}=OO(N,S,s,a,void 0,h);N.position=E,N.positionAbsolute=_}return N});o(k,!0,!1)},[])}const ol={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var Cc=e=>{const t=({id:n,type:s,data:a,xPos:o,yPos:i,xPosOrigin:c,yPosOrigin:d,selected:h,onClick:f,onMouseEnter:p,onMouseMove:m,onMouseLeave:w,onContextMenu:j,onDoubleClick:v,style:b,className:k,isDraggable:N,isSelectable:S,isConnectable:_,isFocusable:E,selectNodesOnDrag:I,sourcePosition:A,targetPosition:O,hidden:L,resizeObserver:U,dragHandle:P,zIndex:T,isParent:B,noDragClassName:M,noPanClassName:q,initialized:$,disableKeyboardA11y:K,ariaLabel:G,rfId:z,hasHandleBounds:W})=>{const D=Dt(),H=y.useRef(null),ee=y.useRef(null),F=y.useRef(A),Y=y.useRef(O),X=y.useRef(s),Z=S||N||f||p||m||w,J=DO(),ne=_c(n,D.getState,p),ce=_c(n,D.getState,m),he=_c(n,D.getState,w),le=_c(n,D.getState,j),re=_c(n,D.getState,v),ae=pe=>{const{nodeDragThreshold:me}=D.getState();if(S&&(!I||!N||me>0)&&r0({id:n,store:D,nodeRef:H}),f){const be=D.getState().nodeInternals.get(n);be&&f(pe,{...be})}},de=pe=>{if(!Qk(pe)&&!K)if(uO.includes(pe.key)&&S){const me=pe.key==="Escape";r0({id:n,store:D,unselect:me,nodeRef:H})}else N&&h&&Object.prototype.hasOwnProperty.call(ol,pe.key)&&(D.setState({ariaLiveMessage:`Moved selected node ${pe.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~o}, y: ${~~i}`}),J({x:ol[pe.key].x,y:ol[pe.key].y,isShiftPressed:pe.shiftKey}))};y.useEffect(()=>()=>{ee.current&&(U==null||U.unobserve(ee.current),ee.current=null)},[]),y.useEffect(()=>{if(H.current&&!L){const pe=H.current;(!$||!W||ee.current!==pe)&&(ee.current&&(U==null||U.unobserve(ee.current)),U==null||U.observe(pe),ee.current=pe)}},[L,$,W]),y.useEffect(()=>{const pe=X.current!==s,me=F.current!==A,be=Y.current!==O;H.current&&(pe||me||be)&&(pe&&(X.current=s),me&&(F.current=A),be&&(Y.current=O),D.getState().updateNodeDimensions([{id:n,nodeElement:H.current,forceUpdate:!0}]))},[n,s,A,O]);const Se=PO({nodeRef:H,disabled:L||!N,noDragClassName:M,handleSelector:P,nodeId:n,isSelectable:S,selectNodesOnDrag:I});return L?null:fe.createElement("div",{className:on(["react-flow__node",`react-flow__node-${s}`,{[q]:N},k,{selected:h,selectable:S,parent:B,dragging:Se}]),ref:H,style:{zIndex:T,transform:`translate(${c}px,${d}px)`,pointerEvents:Z?"all":"none",visibility:$?"visible":"hidden",...b},"data-id":n,"data-testid":`rf__node-${n}`,onMouseEnter:ne,onMouseMove:ce,onMouseLeave:he,onContextMenu:le,onClick:ae,onDoubleClick:re,onKeyDown:E?de:void 0,tabIndex:E?0:void 0,role:E?"button":void 0,"aria-describedby":K?void 0:`${TO}-${z}`,"aria-label":G},fe.createElement(kW,{value:n},fe.createElement(e,{id:n,data:a,type:s,xPos:o,yPos:i,selected:h,isConnectable:_,sourcePosition:A,targetPosition:O,dragging:Se,dragHandle:P,zIndex:T})))};return t.displayName="NodeWrapper",y.memo(t)};const uH=e=>{const t=e.getNodes().filter(n=>n.selected);return{...Kf(t,e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive}};function dH({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const s=Dt(),{width:a,height:o,x:i,y:c,transformString:d,userSelectionActive:h}=at(uH,Xt),f=DO(),p=y.useRef(null);if(y.useEffect(()=>{var j;n||(j=p.current)==null||j.focus({preventScroll:!0})},[n]),PO({nodeRef:p}),h||!a||!o)return null;const m=e?j=>{const v=s.getState().getNodes().filter(b=>b.selected);e(j,v)}:void 0,w=j=>{Object.prototype.hasOwnProperty.call(ol,j.key)&&f({x:ol[j.key].x,y:ol[j.key].y,isShiftPressed:j.shiftKey})};return fe.createElement("div",{className:on(["react-flow__nodesselection","react-flow__container",t]),style:{transform:d}},fe.createElement("div",{ref:p,className:"react-flow__nodesselection-rect",onContextMenu:m,tabIndex:n?void 0:-1,onKeyDown:n?void 0:w,style:{width:a,height:o,top:c,left:i}}))}var hH=y.memo(dH);const fH=e=>e.nodesSelectionActive,FO=({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:o,onPaneScroll:i,deleteKeyCode:c,onMove:d,onMoveStart:h,onMoveEnd:f,selectionKeyCode:p,selectionOnDrag:m,selectionMode:w,onSelectionStart:j,onSelectionEnd:v,multiSelectionKeyCode:b,panActivationKeyCode:k,zoomActivationKeyCode:N,elementsSelectable:S,zoomOnScroll:_,zoomOnPinch:E,panOnScroll:I,panOnScrollSpeed:A,panOnScrollMode:O,zoomOnDoubleClick:L,panOnDrag:U,defaultViewport:P,translateExtent:T,minZoom:B,maxZoom:M,preventScrolling:q,onSelectionContextMenu:$,noWheelClassName:K,noPanClassName:G,disableKeyboardA11y:z})=>{const W=at(fH),D=uu(p),H=uu(k),ee=H||U,F=H||I,Y=D||m&&ee!==!0;return ZW({deleteKeyCode:c,multiSelectionKeyCode:b}),fe.createElement(tH,{onMove:d,onMoveStart:h,onMoveEnd:f,onPaneContextMenu:o,elementsSelectable:S,zoomOnScroll:_,zoomOnPinch:E,panOnScroll:F,panOnScrollSpeed:A,panOnScrollMode:O,zoomOnDoubleClick:L,panOnDrag:!D&&ee,defaultViewport:P,translateExtent:T,minZoom:B,maxZoom:M,zoomActivationKeyCode:N,preventScrolling:q,noWheelClassName:K,noPanClassName:G},fe.createElement(LO,{onSelectionStart:j,onSelectionEnd:v,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:o,onPaneScroll:i,panOnDrag:ee,isSelecting:!!Y,selectionMode:w},e,W&&fe.createElement(hH,{onSelectionContextMenu:$,noPanClassName:G,disableKeyboardA11y:z})))};FO.displayName="FlowRenderer";var pH=y.memo(FO);function mH(e){return at(y.useCallback(n=>e?gO(n.nodeInternals,{x:0,y:0,width:n.width,height:n.height},n.transform,!0):n.getNodes(),[e]))}function gH(e){const t={input:Cc(e.input||SO),default:Cc(e.default||s0),output:Cc(e.output||CO),group:Cc(e.group||$1)},n={},s=Object.keys(e).filter(a=>!["input","default","output","group"].includes(a)).reduce((a,o)=>(a[o]=Cc(e[o]||s0),a),n);return{...t,...s}}const yH=({x:e,y:t,width:n,height:s,origin:a})=>!n||!s?{x:e,y:t}:a[0]<0||a[1]<0||a[0]>1||a[1]>1?{x:e,y:t}:{x:e-n*a[0],y:t-s*a[1]},wH=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),BO=e=>{const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:s,elementsSelectable:a,updateNodeDimensions:o,onError:i}=at(wH,Xt),c=mH(e.onlyRenderVisibleElements),d=y.useRef(),h=y.useMemo(()=>{if(typeof ResizeObserver>"u")return null;const f=new ResizeObserver(p=>{const m=p.map(w=>({id:w.target.getAttribute("data-id"),nodeElement:w.target,forceUpdate:!0}));o(m)});return d.current=f,f},[]);return y.useEffect(()=>()=>{var f;(f=d==null?void 0:d.current)==null||f.disconnect()},[]),fe.createElement("div",{className:"react-flow__nodes",style:L1},c.map(f=>{var E,I,A;let p=f.type||"default";e.nodeTypes[p]||(i==null||i("003",na.error003(p)),p="default");const m=e.nodeTypes[p]||e.nodeTypes.default,w=!!(f.draggable||t&&typeof f.draggable>"u"),j=!!(f.selectable||a&&typeof f.selectable>"u"),v=!!(f.connectable||n&&typeof f.connectable>"u"),b=!!(f.focusable||s&&typeof f.focusable>"u"),k=e.nodeExtent?_1(f.positionAbsolute,e.nodeExtent):f.positionAbsolute,N=(k==null?void 0:k.x)??0,S=(k==null?void 0:k.y)??0,_=yH({x:N,y:S,width:f.width??0,height:f.height??0,origin:e.nodeOrigin});return fe.createElement(m,{key:f.id,id:f.id,className:f.className,style:f.style,type:p,data:f.data,sourcePosition:f.sourcePosition||Fe.Bottom,targetPosition:f.targetPosition||Fe.Top,hidden:f.hidden,xPos:N,yPos:S,xPosOrigin:_.x,yPosOrigin:_.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:j,isConnectable:v,isFocusable:b,resizeObserver:h,dragHandle:f.dragHandle,zIndex:((E=f[Lt])==null?void 0:E.z)??0,isParent:!!((I=f[Lt])!=null&&I.isParent),noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,initialized:!!f.width&&!!f.height,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,ariaLabel:f.ariaLabel,hasHandleBounds:!!((A=f[Lt])!=null&&A.handleBounds)})}))};BO.displayName="NodeRenderer";var xH=y.memo(BO);const vH=(e,t,n)=>n===Fe.Left?e-t:n===Fe.Right?e+t:e,bH=(e,t,n)=>n===Fe.Top?e-t:n===Fe.Bottom?e+t:e,yC="react-flow__edgeupdater",wC=({position:e,centerX:t,centerY:n,radius:s=10,onMouseDown:a,onMouseEnter:o,onMouseOut:i,type:c})=>fe.createElement("circle",{onMouseDown:a,onMouseEnter:o,onMouseOut:i,className:on([yC,`${yC}-${c}`]),cx:vH(t,s,e),cy:bH(n,s,e),r:s,stroke:"transparent",fill:"transparent"}),kH=()=>!0;var Di=e=>{const t=({id:n,className:s,type:a,data:o,onClick:i,onEdgeDoubleClick:c,selected:d,animated:h,label:f,labelStyle:p,labelShowBg:m,labelBgStyle:w,labelBgPadding:j,labelBgBorderRadius:v,style:b,source:k,target:N,sourceX:S,sourceY:_,targetX:E,targetY:I,sourcePosition:A,targetPosition:O,elementsSelectable:L,hidden:U,sourceHandleId:P,targetHandleId:T,onContextMenu:B,onMouseEnter:M,onMouseMove:q,onMouseLeave:$,reconnectRadius:K,onReconnect:G,onReconnectStart:z,onReconnectEnd:W,markerEnd:D,markerStart:H,rfId:ee,ariaLabel:F,isFocusable:Y,isReconnectable:X,pathOptions:Z,interactionWidth:J,disableKeyboardA11y:ne})=>{const ce=y.useRef(null),[he,le]=y.useState(!1),[re,ae]=y.useState(!1),de=Dt(),Se=y.useMemo(()=>`url('#${t0(H,ee)}')`,[H,ee]),pe=y.useMemo(()=>`url('#${t0(D,ee)}')`,[D,ee]);if(U)return null;const me=tt=>{var Ye;const{edges:ht,addSelectedEdges:it,unselectNodesAndEdges:nt,multiSelectionActive:we}=de.getState(),Be=ht.find(He=>He.id===n);Be&&(L&&(de.setState({nodesSelectionActive:!1}),Be.selected&&we?(nt({nodes:[],edges:[Be]}),(Ye=ce.current)==null||Ye.blur()):it([n])),i&&i(tt,Be))},be=Sc(n,de.getState,c),Ce=Sc(n,de.getState,B),ye=Sc(n,de.getState,M),Pe=Sc(n,de.getState,q),Oe=Sc(n,de.getState,$),We=(tt,ht)=>{if(tt.button!==0)return;const{edges:it,isValidConnection:nt}=de.getState(),we=ht?N:k,Be=(ht?T:P)||null,Ye=ht?"target":"source",He=nt||kH,ft=ht,St=it.find(It=>It.id===n);ae(!0),z==null||z(tt,St,Ye);const gt=It=>{ae(!1),W==null||W(It,St,Ye)};bO({event:tt,handleId:Be,nodeId:we,onConnect:It=>G==null?void 0:G(St,It),isTarget:ft,getState:de.getState,setState:de.setState,isValidConnection:He,edgeUpdaterType:Ye,onReconnectEnd:gt})},Re=tt=>We(tt,!0),st=tt=>We(tt,!1),je=()=>le(!0),Te=()=>le(!1),$e=!L&&!i,Ge=tt=>{var ht;if(!ne&&uO.includes(tt.key)&&L){const{unselectNodesAndEdges:it,addSelectedEdges:nt,edges:we}=de.getState();tt.key==="Escape"?((ht=ce.current)==null||ht.blur(),it({edges:[we.find(Ye=>Ye.id===n)]})):nt([n])}};return fe.createElement("g",{className:on(["react-flow__edge",`react-flow__edge-${a}`,s,{selected:d,animated:h,inactive:$e,updating:he}]),onClick:me,onDoubleClick:be,onContextMenu:Ce,onMouseEnter:ye,onMouseMove:Pe,onMouseLeave:Oe,onKeyDown:Y?Ge:void 0,tabIndex:Y?0:void 0,role:Y?"button":"img","data-testid":`rf__edge-${n}`,"aria-label":F===null?void 0:F||`Edge from ${k} to ${N}`,"aria-describedby":Y?`${RO}-${ee}`:void 0,ref:ce},!re&&fe.createElement(e,{id:n,source:k,target:N,selected:d,animated:h,label:f,labelStyle:p,labelShowBg:m,labelBgStyle:w,labelBgPadding:j,labelBgBorderRadius:v,data:o,style:b,sourceX:S,sourceY:_,targetX:E,targetY:I,sourcePosition:A,targetPosition:O,sourceHandleId:P,targetHandleId:T,markerStart:Se,markerEnd:pe,pathOptions:Z,interactionWidth:J}),X&&fe.createElement(fe.Fragment,null,(X==="source"||X===!0)&&fe.createElement(wC,{position:A,centerX:S,centerY:_,radius:K,onMouseDown:Re,onMouseEnter:je,onMouseOut:Te,type:"source"}),(X==="target"||X===!0)&&fe.createElement(wC,{position:O,centerX:E,centerY:I,radius:K,onMouseDown:st,onMouseEnter:je,onMouseOut:Te,type:"target"})))};return t.displayName="EdgeWrapper",y.memo(t)};function jH(e){const t={default:Di(e.default||sf),straight:Di(e.bezier||T1),step:Di(e.step||E1),smoothstep:Di(e.step||Gf),simplebezier:Di(e.simplebezier||C1)},n={},s=Object.keys(e).filter(a=>!["default","bezier"].includes(a)).reduce((a,o)=>(a[o]=Di(e[o]||sf),a),n);return{...t,...s}}function xC(e,t,n=null){const s=((n==null?void 0:n.x)||0)+t.x,a=((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 Fe.Top:return{x:s+o/2,y:a};case Fe.Right:return{x:s+o,y:a+i/2};case Fe.Bottom:return{x:s+o/2,y:a+i};case Fe.Left:return{x:s,y:a+i/2}}}function vC(e,t){return e?e.length===1||!t?e[0]:t&&e.find(n=>n.id===t)||null:null}const NH=(e,t,n,s,a,o)=>{const i=xC(n,e,t),c=xC(o,s,a);return{sourceX:i.x,sourceY:i.y,targetX:c.x,targetY:c.y}};function SH({sourcePos:e,targetPos:t,sourceWidth:n,sourceHeight:s,targetWidth:a,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+a),y2:Math.max(e.y+s,t.y+o)};h.x===h.x2&&(h.x2+=1),h.y===h.y2&&(h.y2+=1);const f=lu({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)),m=Math.max(0,Math.min(f.y2,h.y2)-Math.max(f.y,h.y));return Math.ceil(p*m)>0}function bC(e){var s,a,o,i,c;const t=((s=e==null?void 0:e[Lt])==null?void 0:s.handleBounds)||null,n=t&&(e==null?void 0:e.width)&&(e==null?void 0:e.height)&&typeof((a=e==null?void 0:e.positionAbsolute)==null?void 0:a.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 _H=[{level:0,isMaxLevel:!0,edges:[]}];function CH(e,t,n=!1){let s=-1;const a=e.reduce((i,c)=>{var f,p;const d=gs(c.zIndex);let h=d?c.zIndex:0;if(n){const m=t.get(c.target),w=t.get(c.source),j=c.selected||(m==null?void 0:m.selected)||(w==null?void 0:w.selected),v=Math.max(((f=w==null?void 0:w[Lt])==null?void 0:f.z)||0,((p=m==null?void 0:m[Lt])==null?void 0:p.z)||0,1e3);h=(d?c.zIndex:0)+(j?v:0)}return i[h]?i[h].push(c):i[h]=[c],s=h>s?h:s,i},{}),o=Object.entries(a).map(([i,c])=>{const d=+i;return{edges:c,level:d,isMaxLevel:d===s}});return o.length===0?_H:o}function EH(e,t,n){const s=at(y.useCallback(a=>e?a.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)&&SH({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:a.width,height:a.height,transform:a.transform})}):a.edges,[e,t]));return CH(s,t,n)}const TH=({color:e="none",strokeWidth:t=1})=>fe.createElement("polyline",{style:{stroke:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),RH=({color:e="none",strokeWidth:t=1})=>fe.createElement("polyline",{style:{stroke:e,fill:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"}),kC={[nf.Arrow]:TH,[nf.ArrowClosed]:RH};function AH(e){const t=Dt();return y.useMemo(()=>{var a,o;return Object.prototype.hasOwnProperty.call(kC,e)?kC[e]:((o=(a=t.getState()).onError)==null||o.call(a,"009",na.error009(e)),null)},[e])}const MH=({id:e,type:t,color:n,width:s=12.5,height:a=12.5,markerUnits:o="strokeWidth",strokeWidth:i,orient:c="auto-start-reverse"})=>{const d=AH(t);return d?fe.createElement("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${s}`,markerHeight:`${a}`,viewBox:"-10 -10 20 20",markerUnits:o,orient:c,refX:"0",refY:"0"},fe.createElement(d,{color:n,strokeWidth:i})):null},$H=({defaultColor:e,rfId:t})=>n=>{const s=[];return n.edges.reduce((a,o)=>([o.markerStart,o.markerEnd].forEach(i=>{if(i&&typeof i=="object"){const c=t0(i,t);s.includes(c)||(a.push({id:c,color:i.color||e,...i}),s.push(c))}}),a),[]).sort((a,o)=>a.id.localeCompare(o.id))},qO=({defaultColor:e,rfId:t})=>{const n=at(y.useCallback($H({defaultColor:e,rfId:t}),[e,t]),(s,a)=>!(s.length!==a.length||s.some((o,i)=>o.id!==a[i].id)));return fe.createElement("defs",null,n.map(s=>fe.createElement(MH,{id:s.id,key:s.id,type:s.type,color:s.color,width:s.width,height:s.height,markerUnits:s.markerUnits,strokeWidth:s.strokeWidth,orient:s.orient})))};qO.displayName="MarkerDefinitions";var LH=y.memo(qO);const IH=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}),UO=({defaultMarkerColor:e,onlyRenderVisibleElements:t,elevateEdgesOnSelect:n,rfId:s,edgeTypes:a,noPanClassName:o,onEdgeContextMenu:i,onEdgeMouseEnter:c,onEdgeMouseMove:d,onEdgeMouseLeave:h,onEdgeClick:f,onEdgeDoubleClick:p,onReconnect:m,onReconnectStart:w,onReconnectEnd:j,reconnectRadius:v,children:b,disableKeyboardA11y:k})=>{const{edgesFocusable:N,edgesUpdatable:S,elementsSelectable:_,width:E,height:I,connectionMode:A,nodeInternals:O,onError:L}=at(IH,Xt),U=EH(t,O,n);return E?fe.createElement(fe.Fragment,null,U.map(({level:P,edges:T,isMaxLevel:B})=>fe.createElement("svg",{key:P,style:{zIndex:P},width:E,height:I,className:"react-flow__edges react-flow__container"},B&&fe.createElement(LH,{defaultColor:e,rfId:s}),fe.createElement("g",null,T.map(M=>{const[q,$,K]=bC(O.get(M.source)),[G,z,W]=bC(O.get(M.target));if(!K||!W)return null;let D=M.type||"default";a[D]||(L==null||L("011",na.error011(D)),D="default");const H=a[D]||a.default,ee=A===Go.Strict?z.target:(z.target??[]).concat(z.source??[]),F=vC($.source,M.sourceHandle),Y=vC(ee,M.targetHandle),X=(F==null?void 0:F.position)||Fe.Bottom,Z=(Y==null?void 0:Y.position)||Fe.Top,J=!!(M.focusable||N&&typeof M.focusable>"u"),ne=M.reconnectable||M.updatable,ce=typeof m<"u"&&(ne||S&&typeof ne>"u");if(!F||!Y)return L==null||L("008",na.error008(F,M)),null;const{sourceX:he,sourceY:le,targetX:re,targetY:ae}=NH(q,F,X,G,Y,Z);return fe.createElement(H,{key:M.id,id:M.id,className:on([M.className,o]),type:D,data:M.data,selected:!!M.selected,animated:!!M.animated,hidden:!!M.hidden,label:M.label,labelStyle:M.labelStyle,labelShowBg:M.labelShowBg,labelBgStyle:M.labelBgStyle,labelBgPadding:M.labelBgPadding,labelBgBorderRadius:M.labelBgBorderRadius,style:M.style,source:M.source,target:M.target,sourceHandleId:M.sourceHandle,targetHandleId:M.targetHandle,markerEnd:M.markerEnd,markerStart:M.markerStart,sourceX:he,sourceY:le,targetX:re,targetY:ae,sourcePosition:X,targetPosition:Z,elementsSelectable:_,onContextMenu:i,onMouseEnter:c,onMouseMove:d,onMouseLeave:h,onClick:f,onEdgeDoubleClick:p,onReconnect:m,onReconnectStart:w,onReconnectEnd:j,reconnectRadius:v,rfId:s,ariaLabel:M.ariaLabel,isFocusable:J,isReconnectable:ce,pathOptions:"pathOptions"in M?M.pathOptions:void 0,interactionWidth:M.interactionWidth,disableKeyboardA11y:k})})))),b):null};UO.displayName="EdgeRenderer";var OH=y.memo(UO);const PH=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function DH({children:e}){const t=at(PH);return fe.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:t}},e)}function FH(e){const t=_l(),n=y.useRef(!1);y.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const BH={[Fe.Left]:Fe.Right,[Fe.Right]:Fe.Left,[Fe.Top]:Fe.Bottom,[Fe.Bottom]:Fe.Top},WO=({nodeId:e,handleType:t,style:n,type:s=Oa.Bezier,CustomComponent:a,connectionStatus:o})=>{var I,A,O;const{fromNode:i,handleId:c,toX:d,toY:h,connectionMode:f}=at(y.useCallback(L=>({fromNode:L.nodeInternals.get(e),handleId:L.connectionHandleId,toX:(L.connectionPosition.x-L.transform[0])/L.transform[2],toY:(L.connectionPosition.y-L.transform[1])/L.transform[2],connectionMode:L.connectionMode}),[e]),Xt),p=(I=i==null?void 0:i[Lt])==null?void 0:I.handleBounds;let m=p==null?void 0:p[t];if(f===Go.Loose&&(m=m||(p==null?void 0:p[t==="source"?"target":"source"])),!i||!m)return null;const w=c?m.find(L=>L.id===c):m[0],j=w?w.x+w.width/2:(i.width??0)/2,v=w?w.y+w.height/2:i.height??0,b=(((A=i.positionAbsolute)==null?void 0:A.x)??0)+j,k=(((O=i.positionAbsolute)==null?void 0:O.y)??0)+v,N=w==null?void 0:w.position,S=N?BH[N]:null;if(!N||!S)return null;if(a)return fe.createElement(a,{connectionLineType:s,connectionLineStyle:n,fromNode:i,fromHandle:w,fromX:b,fromY:k,toX:d,toY:h,fromPosition:N,toPosition:S,connectionStatus:o});let _="";const E={sourceX:b,sourceY:k,sourcePosition:N,targetX:d,targetY:h,targetPosition:S};return s===Oa.Bezier?[_]=R1(E):s===Oa.Step?[_]=e0({...E,borderRadius:0}):s===Oa.SmoothStep?[_]=e0(E):s===Oa.SimpleBezier?[_]=pO(E):_=`M${b},${k} ${d},${h}`,fe.createElement("path",{d:_,fill:"none",className:"react-flow__connection-path",style:n})};WO.displayName="ConnectionLine";const qH=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function UH({containerStyle:e,style:t,type:n,component:s}){const{nodeId:a,handleType:o,nodesConnectable:i,width:c,height:d,connectionStatus:h}=at(qH,Xt);return!(a&&o&&c&&i)?null:fe.createElement("svg",{style:e,width:c,height:d,className:"react-flow__edges react-flow__connectionline react-flow__container"},fe.createElement("g",{className:on(["react-flow__connection",h])},fe.createElement(WO,{nodeId:a,handleType:o,style:t,type:n,CustomComponent:s,connectionStatus:h})))}function jC(e,t){return y.useRef(null),Dt(),y.useMemo(()=>t(e),[e])}const HO=({nodeTypes:e,edgeTypes:t,onMove:n,onMoveStart:s,onMoveEnd:a,onInit:o,onNodeClick:i,onEdgeClick:c,onNodeDoubleClick:d,onEdgeDoubleClick:h,onNodeMouseEnter:f,onNodeMouseMove:p,onNodeMouseLeave:m,onNodeContextMenu:w,onSelectionContextMenu:j,onSelectionStart:v,onSelectionEnd:b,connectionLineType:k,connectionLineStyle:N,connectionLineComponent:S,connectionLineContainerStyle:_,selectionKeyCode:E,selectionOnDrag:I,selectionMode:A,multiSelectionKeyCode:O,panActivationKeyCode:L,zoomActivationKeyCode:U,deleteKeyCode:P,onlyRenderVisibleElements:T,elementsSelectable:B,selectNodesOnDrag:M,defaultViewport:q,translateExtent:$,minZoom:K,maxZoom:G,preventScrolling:z,defaultMarkerColor:W,zoomOnScroll:D,zoomOnPinch:H,panOnScroll:ee,panOnScrollSpeed:F,panOnScrollMode:Y,zoomOnDoubleClick:X,panOnDrag:Z,onPaneClick:J,onPaneMouseEnter:ne,onPaneMouseMove:ce,onPaneMouseLeave:he,onPaneScroll:le,onPaneContextMenu:re,onEdgeContextMenu:ae,onEdgeMouseEnter:de,onEdgeMouseMove:Se,onEdgeMouseLeave:pe,onReconnect:me,onReconnectStart:be,onReconnectEnd:Ce,reconnectRadius:ye,noDragClassName:Pe,noWheelClassName:Oe,noPanClassName:We,elevateEdgesOnSelect:Re,disableKeyboardA11y:st,nodeOrigin:je,nodeExtent:Te,rfId:$e})=>{const Ge=jC(e,gH),tt=jC(t,jH);return FH(o),fe.createElement(pH,{onPaneClick:J,onPaneMouseEnter:ne,onPaneMouseMove:ce,onPaneMouseLeave:he,onPaneContextMenu:re,onPaneScroll:le,deleteKeyCode:P,selectionKeyCode:E,selectionOnDrag:I,selectionMode:A,onSelectionStart:v,onSelectionEnd:b,multiSelectionKeyCode:O,panActivationKeyCode:L,zoomActivationKeyCode:U,elementsSelectable:B,onMove:n,onMoveStart:s,onMoveEnd:a,zoomOnScroll:D,zoomOnPinch:H,zoomOnDoubleClick:X,panOnScroll:ee,panOnScrollSpeed:F,panOnScrollMode:Y,panOnDrag:Z,defaultViewport:q,translateExtent:$,minZoom:K,maxZoom:G,onSelectionContextMenu:j,preventScrolling:z,noDragClassName:Pe,noWheelClassName:Oe,noPanClassName:We,disableKeyboardA11y:st},fe.createElement(DH,null,fe.createElement(OH,{edgeTypes:tt,onEdgeClick:c,onEdgeDoubleClick:h,onlyRenderVisibleElements:T,onEdgeContextMenu:ae,onEdgeMouseEnter:de,onEdgeMouseMove:Se,onEdgeMouseLeave:pe,onReconnect:me,onReconnectStart:be,onReconnectEnd:Ce,reconnectRadius:ye,defaultMarkerColor:W,noPanClassName:We,elevateEdgesOnSelect:!!Re,disableKeyboardA11y:st,rfId:$e},fe.createElement(UH,{style:N,type:k,component:S,containerStyle:_})),fe.createElement("div",{className:"react-flow__edgelabel-renderer"}),fe.createElement(xH,{nodeTypes:Ge,onNodeClick:i,onNodeDoubleClick:d,onNodeMouseEnter:f,onNodeMouseMove:p,onNodeMouseLeave:m,onNodeContextMenu:w,selectNodesOnDrag:M,onlyRenderVisibleElements:T,noPanClassName:We,noDragClassName:Pe,disableKeyboardA11y:st,nodeOrigin:je,nodeExtent:Te,rfId:$e})))};HO.displayName="GraphView";var WH=y.memo(HO);const a0=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Ra={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:a0,nodeExtent:a0,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:Go.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:gW,isValidConnection:void 0},HH=()=>A8((e,t)=>({...Ra,setNodes:n=>{const{nodeInternals:s,nodeOrigin:a,elevateNodesOnSelect:o}=t();e({nodeInternals:Bg(n,s,a,o)})},getNodes:()=>Array.from(t().nodeInternals.values()),setEdges:n=>{const{defaultEdgeOptions:s={}}=t();e({edges:n.map(a=>({...s,...a}))})},setDefaultNodesAndEdges:(n,s)=>{const a=typeof n<"u",o=typeof s<"u",i=a?Bg(n,new Map,t().nodeOrigin,t().elevateNodesOnSelect):new Map;e({nodeInternals:i,edges:o?s:[],hasDefaultNodes:a,hasDefaultEdges:o})},updateNodeDimensions:n=>{const{onNodesChange:s,nodeInternals:a,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:m}=new window.DOMMatrixReadOnly(p.transform),w=n.reduce((v,b)=>{const k=a.get(b.id);if(k!=null&&k.hidden)a.set(k.id,{...k,[Lt]:{...k[Lt],handleBounds:void 0}});else if(k){const N=S1(b.nodeElement);!!(N.width&&N.height&&(k.width!==N.width||k.height!==N.height||b.forceUpdate))&&(a.set(k.id,{...k,[Lt]:{...k[Lt],handleBounds:{source:gC(".source",b.nodeElement,m,h),target:gC(".target",b.nodeElement,m,h)}},...N}),v.push({id:k.id,type:"dimensions",dimensions:N}))}return v},[]);MO(a,h);const j=i||o&&!i&&$O(t,{initial:!0,...c});e({nodeInternals:new Map(a),fitViewOnInitDone:j}),(w==null?void 0:w.length)>0&&(s==null||s(w))},updateNodePositions:(n,s=!0,a=!1)=>{const{triggerNodeChanges:o}=t(),i=n.map(c=>{const d={id:c.id,type:"position",dragging:a};return s&&(d.positionAbsolute=c.positionAbsolute,d.position=c.position),d});o(i)},triggerNodeChanges:n=>{const{onNodesChange:s,nodeInternals:a,hasDefaultNodes:o,nodeOrigin:i,getNodes:c,elevateNodesOnSelect:d}=t();if(n!=null&&n.length){if(o){const h=aH(n,c()),f=Bg(h,a,i,d);e({nodeInternals:f})}s==null||s(n)}},addSelectedNodes:n=>{const{multiSelectionActive:s,edges:a,getNodes:o}=t();let i,c=null;s?i=n.map(d=>Ia(d,!0)):(i=Ji(o(),n),c=Ji(a,[])),ih({changedNodes:i,changedEdges:c,get:t,set:e})},addSelectedEdges:n=>{const{multiSelectionActive:s,edges:a,getNodes:o}=t();let i,c=null;s?i=n.map(d=>Ia(d,!0)):(i=Ji(a,n),c=Ji(o(),[])),ih({changedNodes:c,changedEdges:i,get:t,set:e})},unselectNodesAndEdges:({nodes:n,edges:s}={})=>{const{edges:a,getNodes:o}=t(),i=n||o(),c=s||a,d=i.map(f=>(f.selected=!1,Ia(f.id,!1))),h=c.map(f=>Ia(f.id,!1));ih({changedNodes:d,changedEdges:h,get:t,set:e})},setMinZoom:n=>{const{d3Zoom:s,maxZoom:a}=t();s==null||s.scaleExtent([n,a]),e({minZoom:n})},setMaxZoom:n=>{const{d3Zoom:s,minZoom:a}=t();s==null||s.scaleExtent([a,n]),e({maxZoom:n})},setTranslateExtent:n=>{var s;(s=t().d3Zoom)==null||s.translateExtent(n),e({translateExtent:n})},resetSelectedElements:()=>{const{edges:n,getNodes:s}=t(),o=s().filter(c=>c.selected).map(c=>Ia(c.id,!1)),i=n.filter(c=>c.selected).map(c=>Ia(c.id,!1));ih({changedNodes:o,changedEdges:i,get:t,set:e})},setNodeExtent:n=>{const{nodeInternals:s}=t();s.forEach(a=>{a.positionAbsolute=_1(a.position,n)}),e({nodeExtent:n,nodeInternals:new Map(s)})},panBy:n=>{const{transform:s,width:a,height:o,d3Zoom:i,d3Selection:c,translateExtent:d}=t();if(!i||!c||!n.x&&!n.y)return!1;const h=Qr.translate(s[0]+n.x,s[1]+n.y).scale(s[2]),f=[[0,0],[a,o]],p=i==null?void 0:i.constrain()(h,f,d);return i.transform(c,p),s[0]!==p.x||s[1]!==p.y||s[2]!==p.k},cancelConnection:()=>e({connectionNodeId:Ra.connectionNodeId,connectionHandleId:Ra.connectionHandleId,connectionHandleType:Ra.connectionHandleType,connectionStatus:Ra.connectionStatus,connectionStartHandle:Ra.connectionStartHandle,connectionEndHandle:Ra.connectionEndHandle}),reset:()=>e({...Ra})}),Object.is),I1=({children:e})=>{const t=y.useRef(null);return t.current||(t.current=HH()),fe.createElement(cW,{value:t.current},e)};I1.displayName="ReactFlowProvider";const zO=({children:e})=>y.useContext(Vf)?fe.createElement(fe.Fragment,null,e):fe.createElement(I1,null,e);zO.displayName="ReactFlowWrapper";const zH={input:SO,default:s0,output:CO,group:$1},VH={default:sf,straight:T1,step:E1,smoothstep:Gf,simplebezier:C1},GH=[0,0],KH=[15,15],YH={x:0,y:0,zoom:1},XH={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},VO=y.forwardRef(({nodes:e,edges:t,defaultNodes:n,defaultEdges:s,className:a,nodeTypes:o=zH,edgeTypes:i=VH,onNodeClick:c,onEdgeClick:d,onInit:h,onMove:f,onMoveStart:p,onMoveEnd:m,onConnect:w,onConnectStart:j,onConnectEnd:v,onClickConnectStart:b,onClickConnectEnd:k,onNodeMouseEnter:N,onNodeMouseMove:S,onNodeMouseLeave:_,onNodeContextMenu:E,onNodeDoubleClick:I,onNodeDragStart:A,onNodeDrag:O,onNodeDragStop:L,onNodesDelete:U,onEdgesDelete:P,onSelectionChange:T,onSelectionDragStart:B,onSelectionDrag:M,onSelectionDragStop:q,onSelectionContextMenu:$,onSelectionStart:K,onSelectionEnd:G,connectionMode:z=Go.Strict,connectionLineType:W=Oa.Bezier,connectionLineStyle:D,connectionLineComponent:H,connectionLineContainerStyle:ee,deleteKeyCode:F="Backspace",selectionKeyCode:Y="Shift",selectionOnDrag:X=!1,selectionMode:Z=cu.Full,panActivationKeyCode:J="Space",multiSelectionKeyCode:ne=tf()?"Meta":"Control",zoomActivationKeyCode:ce=tf()?"Meta":"Control",snapToGrid:he=!1,snapGrid:le=KH,onlyRenderVisibleElements:re=!1,selectNodesOnDrag:ae=!0,nodesDraggable:de,nodesConnectable:Se,nodesFocusable:pe,nodeOrigin:me=GH,edgesFocusable:be,edgesUpdatable:Ce,elementsSelectable:ye,defaultViewport:Pe=YH,minZoom:Oe=.5,maxZoom:We=2,translateExtent:Re=a0,preventScrolling:st=!0,nodeExtent:je,defaultMarkerColor:Te="#b1b1b7",zoomOnScroll:$e=!0,zoomOnPinch:Ge=!0,panOnScroll:tt=!1,panOnScrollSpeed:ht=.5,panOnScrollMode:it=Io.Free,zoomOnDoubleClick:nt=!0,panOnDrag:we=!0,onPaneClick:Be,onPaneMouseEnter:Ye,onPaneMouseMove:He,onPaneMouseLeave:ft,onPaneScroll:St,onPaneContextMenu:gt,children:_t,onEdgeContextMenu:It,onEdgeDoubleClick:ks,onEdgeMouseEnter:Xs,onEdgeMouseMove:js,onEdgeMouseLeave:Zn,onEdgeUpdate:Ot,onEdgeUpdateStart:Ns,onEdgeUpdateEnd:hn,onReconnect:Dn,onReconnectStart:_e,onReconnectEnd:De,reconnectRadius:ze=10,edgeUpdaterRadius:ut=10,onNodesChange:At,onEdgesChange:Jn,noDragClassName:fn="nodrag",noWheelClassName:la="nowheel",noPanClassName:Qn="nopan",fitView:Ct=!1,fitViewOptions:Ss,connectOnClick:_s=!0,attributionPosition:Zs,proOptions:Cs,defaultEdgeOptions:Sr,elevateNodesOnSelect:Ft=!0,elevateEdgesOnSelect:Js=!1,disableKeyboardA11y:Es=!1,autoPanOnConnect:_r=!0,autoPanOnNodeDrag:dt=!0,connectionRadius:ri=20,isValidConnection:Cr,onError:Qs,style:Ts,id:so,nodeDragThreshold:Er,...es},nn)=>{const er=so||"1";return fe.createElement("div",{...es,style:{...Ts,...XH},ref:nn,className:on(["react-flow",a]),"data-testid":"rf__wrapper",id:so},fe.createElement(zO,null,fe.createElement(WH,{onInit:h,onMove:f,onMoveStart:p,onMoveEnd:m,onNodeClick:c,onEdgeClick:d,onNodeMouseEnter:N,onNodeMouseMove:S,onNodeMouseLeave:_,onNodeContextMenu:E,onNodeDoubleClick:I,nodeTypes:o,edgeTypes:i,connectionLineType:W,connectionLineStyle:D,connectionLineComponent:H,connectionLineContainerStyle:ee,selectionKeyCode:Y,selectionOnDrag:X,selectionMode:Z,deleteKeyCode:F,multiSelectionKeyCode:ne,panActivationKeyCode:J,zoomActivationKeyCode:ce,onlyRenderVisibleElements:re,selectNodesOnDrag:ae,defaultViewport:Pe,translateExtent:Re,minZoom:Oe,maxZoom:We,preventScrolling:st,zoomOnScroll:$e,zoomOnPinch:Ge,zoomOnDoubleClick:nt,panOnScroll:tt,panOnScrollSpeed:ht,panOnScrollMode:it,panOnDrag:we,onPaneClick:Be,onPaneMouseEnter:Ye,onPaneMouseMove:He,onPaneMouseLeave:ft,onPaneScroll:St,onPaneContextMenu:gt,onSelectionContextMenu:$,onSelectionStart:K,onSelectionEnd:G,onEdgeContextMenu:It,onEdgeDoubleClick:ks,onEdgeMouseEnter:Xs,onEdgeMouseMove:js,onEdgeMouseLeave:Zn,onReconnect:Dn??Ot,onReconnectStart:_e??Ns,onReconnectEnd:De??hn,reconnectRadius:ze??ut,defaultMarkerColor:Te,noDragClassName:fn,noWheelClassName:la,noPanClassName:Qn,elevateEdgesOnSelect:Js,rfId:er,disableKeyboardA11y:Es,nodeOrigin:me,nodeExtent:je}),fe.createElement(FW,{nodes:e,edges:t,defaultNodes:n,defaultEdges:s,onConnect:w,onConnectStart:j,onConnectEnd:v,onClickConnectStart:b,onClickConnectEnd:k,nodesDraggable:de,nodesConnectable:Se,nodesFocusable:pe,edgesFocusable:be,edgesUpdatable:Ce,elementsSelectable:ye,elevateNodesOnSelect:Ft,minZoom:Oe,maxZoom:We,nodeExtent:je,onNodesChange:At,onEdgesChange:Jn,snapToGrid:he,snapGrid:le,connectionMode:z,translateExtent:Re,connectOnClick:_s,defaultEdgeOptions:Sr,fitView:Ct,fitViewOptions:Ss,onNodesDelete:U,onEdgesDelete:P,onNodeDragStart:A,onNodeDrag:O,onNodeDragStop:L,onSelectionDrag:M,onSelectionDragStart:B,onSelectionDragStop:q,noPanClassName:Qn,nodeOrigin:me,rfId:er,autoPanOnConnect:_r,autoPanOnNodeDrag:dt,onError:Qs,connectionRadius:ri,isValidConnection:Cr,nodeDragThreshold:Er}),fe.createElement(PW,{onSelectionChange:T}),_t,fe.createElement(dW,{proOptions:Cs,position:Zs}),fe.createElement(HW,{rfId:er,disableKeyboardA11y:Es})))});VO.displayName="ReactFlow";const ZH=e=>({x:e.transform[0],y:e.transform[1],zoom:e.transform[2]});function GO(){return at(ZH,Xt)}const KO=({id:e,x:t,y:n,width:s,height:a,style:o,color:i,strokeColor:c,strokeWidth:d,className:h,borderRadius:f,shapeRendering:p,onClick:m,selected:w})=>{const{background:j,backgroundColor:v}=o||{},b=i||j||v;return fe.createElement("rect",{className:on(["react-flow__minimap-node",{selected:w},h]),x:t,y:n,rx:f,ry:f,width:s,height:a,fill:b,stroke:c,strokeWidth:d,shapeRendering:p,onClick:m?k=>m(k,e):void 0})};KO.displayName="MiniMapNode";var JH=y.memo(KO);const QH=e=>e.nodeOrigin,ez=e=>e.getNodes().filter(t=>!t.hidden&&t.width&&t.height),Hg=e=>e instanceof Function?e:()=>e;function tz({nodeStrokeColor:e="transparent",nodeColor:t="#e2e2e2",nodeClassName:n="",nodeBorderRadius:s=5,nodeStrokeWidth:a=2,nodeComponent:o=JH,onClick:i}){const c=at(ez,Xt),d=at(QH),h=Hg(t),f=Hg(e),p=Hg(n),m=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return fe.createElement(fe.Fragment,null,c.map(w=>{const{x:j,y:v}=Fo(w,d).positionAbsolute;return fe.createElement(o,{key:w.id,x:j,y:v,width:w.width,height:w.height,style:w.style,selected:w.selected,className:p(w),color:h(w),borderRadius:s,strokeColor:f(w),strokeWidth:a,shapeRendering:m,onClick:i,id:w.id})}))}var nz=y.memo(tz);const sz=200,rz=150,az=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?pW(Kf(t,e.nodeOrigin),n):n,rfId:e.rfId}},oz="react-flow__minimap-desc";function YO({style:e,className:t,nodeStrokeColor:n="transparent",nodeColor:s="#e2e2e2",nodeClassName:a="",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:m,onNodeClick:w,pannable:j=!1,zoomable:v=!1,ariaLabel:b="React Flow mini map",inversePan:k=!1,zoomStep:N=10,offsetScale:S=5}){const _=Dt(),E=y.useRef(null),{boundingRect:I,viewBB:A,rfId:O}=at(az,Xt),L=(e==null?void 0:e.width)??sz,U=(e==null?void 0:e.height)??rz,P=I.width/L,T=I.height/U,B=Math.max(P,T),M=B*L,q=B*U,$=S*B,K=I.x-(M-I.width)/2-$,G=I.y-(q-I.height)/2-$,z=M+$*2,W=q+$*2,D=`${oz}-${O}`,H=y.useRef(0);H.current=B,y.useEffect(()=>{if(E.current){const Y=ms(E.current),X=ne=>{const{transform:ce,d3Selection:he,d3Zoom:le}=_.getState();if(ne.sourceEvent.type!=="wheel"||!he||!le)return;const re=-ne.sourceEvent.deltaY*(ne.sourceEvent.deltaMode===1?.05:ne.sourceEvent.deltaMode?1:.002)*N,ae=ce[2]*Math.pow(2,re);le.scaleTo(he,ae)},Z=ne=>{const{transform:ce,d3Selection:he,d3Zoom:le,translateExtent:re,width:ae,height:de}=_.getState();if(ne.sourceEvent.type!=="mousemove"||!he||!le)return;const Se=H.current*Math.max(1,ce[2])*(k?-1:1),pe={x:ce[0]-ne.sourceEvent.movementX*Se,y:ce[1]-ne.sourceEvent.movementY*Se},me=[[0,0],[ae,de]],be=Qr.translate(pe.x,pe.y).scale(ce[2]),Ce=le.constrain()(be,me,re);le.transform(he,Ce)},J=rO().on("zoom",j?Z:null).on("zoom.wheel",v?X:null);return Y.call(J),()=>{Y.on("zoom",null)}}},[j,v,k,N]);const ee=m?Y=>{const X=Bs(Y);m(Y,{x:X[0],y:X[1]})}:void 0,F=w?(Y,X)=>{const Z=_.getState().nodeInternals.get(X);w(Y,Z)}:void 0;return fe.createElement(N1,{position:p,style:e,className:on(["react-flow__minimap",t]),"data-testid":"rf__minimap"},fe.createElement("svg",{width:L,height:U,viewBox:`${K} ${G} ${z} ${W}`,role:"img","aria-labelledby":D,ref:E,onClick:ee},b&&fe.createElement("title",{id:D},b),fe.createElement(nz,{onClick:F,nodeColor:s,nodeStrokeColor:n,nodeBorderRadius:o,nodeClassName:a,nodeStrokeWidth:i,nodeComponent:c}),fe.createElement("path",{className:"react-flow__minimap-mask",d:`M${K-$},${G-$}h${z+$*2}v${W+$*2}h${-z-$*2}z
|
|
57
|
+
M${A.x},${A.y}h${A.width}v${A.height}h${-A.width}z`,fill:d,fillRule:"evenodd",stroke:h,strokeWidth:f,pointerEvents:"none"})))}YO.displayName="MiniMap";var iz=y.memo(YO);function lz(){return fe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},fe.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function cz(){return fe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},fe.createElement("path",{d:"M0 0h32v4.2H0z"}))}function uz(){return fe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},fe.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 dz(){return fe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},fe.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 hz(){return fe.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},fe.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 hs=({children:e,className:t,...n})=>fe.createElement("button",{type:"button",className:on(["react-flow__controls-button",t]),...n},e);hs.displayName="ControlButton";const fz=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),XO=({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:s=!0,fitViewOptions:a,onZoomIn:o,onZoomOut:i,onFitView:c,onInteractiveChange:d,className:h,children:f,position:p="bottom-left"})=>{const m=Dt(),[w,j]=y.useState(!1),{isInteractive:v,minZoomReached:b,maxZoomReached:k}=at(fz,Xt),{zoomIn:N,zoomOut:S,fitView:_}=_l();if(y.useEffect(()=>{j(!0)},[]),!w)return null;const E=()=>{N(),o==null||o()},I=()=>{S(),i==null||i()},A=()=>{_(a),c==null||c()},O=()=>{m.setState({nodesDraggable:!v,nodesConnectable:!v,elementsSelectable:!v}),d==null||d(!v)};return fe.createElement(N1,{className:on(["react-flow__controls",h]),position:p,style:e,"data-testid":"rf__controls"},t&&fe.createElement(fe.Fragment,null,fe.createElement(hs,{onClick:E,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:k},fe.createElement(lz,null)),fe.createElement(hs,{onClick:I,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:b},fe.createElement(cz,null))),n&&fe.createElement(hs,{className:"react-flow__controls-fitview",onClick:A,title:"fit view","aria-label":"fit view"},fe.createElement(uz,null)),s&&fe.createElement(hs,{className:"react-flow__controls-interactive",onClick:O,title:"toggle interactivity","aria-label":"toggle interactivity"},v?fe.createElement(hz,null):fe.createElement(dz,null)),f)};XO.displayName="Controls";var pz=y.memo(XO),Hs;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Hs||(Hs={}));function mz({color:e,dimensions:t,lineWidth:n}){return fe.createElement("path",{stroke:e,strokeWidth:n,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`})}function gz({color:e,radius:t}){return fe.createElement("circle",{cx:t,cy:t,r:t,fill:e})}const yz={[Hs.Dots]:"#91919a",[Hs.Lines]:"#eee",[Hs.Cross]:"#e2e2e2"},wz={[Hs.Dots]:1,[Hs.Lines]:1,[Hs.Cross]:6},xz=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function ZO({id:e,variant:t=Hs.Dots,gap:n=20,size:s,lineWidth:a=1,offset:o=2,color:i,style:c,className:d}){const h=y.useRef(null),{transform:f,patternId:p}=at(xz,Xt),m=i||yz[t],w=s||wz[t],j=t===Hs.Dots,v=t===Hs.Cross,b=Array.isArray(n)?n:[n,n],k=[b[0]*f[2]||1,b[1]*f[2]||1],N=w*f[2],S=v?[N,N]:k,_=j?[N/o,N/o]:[S[0]/o,S[1]/o];return fe.createElement("svg",{className:on(["react-flow__background",d]),style:{...c,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:h,"data-testid":"rf__background"},fe.createElement("pattern",{id:p+e,x:f[0]%k[0],y:f[1]%k[1],width:k[0],height:k[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${_[0]},-${_[1]})`},j?fe.createElement(gz,{color:m,radius:N/o}):fe.createElement(mz,{dimensions:S,color:m,lineWidth:a})),fe.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${p+e})`}))}ZO.displayName="Background";var vz=y.memo(ZO);function bz(e,t){return e?t==="gone"?"entering":t==="leaving"?"here":t:t==="gone"?"gone":"leaving"}function Ba(e){return e!=="gone"}function NC(e,t){return e||Ba(t)}function SC(e,t){return!e&&Ba(t)}function Qi(e,t){const[n,s]=y.useState(()=>e?"here":"gone"),a=y.useRef(null);return y.useEffect(()=>{s(o=>bz(e,o))},[e]),y.useEffect(()=>{if(n==="leaving")return a.current=window.setTimeout(()=>s("gone"),t),()=>{a.current!=null&&window.clearTimeout(a.current)}},[n,t]),y.useEffect(()=>{n==="entering"&&s("here")},[n]),n}const JO=.2,QO=1.6;function kz(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:s,zoom:a}=t;return typeof n!="number"||typeof s!="number"||typeof a!="number"||!Number.isFinite(n)||!Number.isFinite(s)||!Number.isFinite(a)||a<JO||a>QO?null:{x:n,y:s,zoom:a}}function o0({durationMs:e,documentHidden:t,reducedMotion:n=$u()}){return t||n?!1:Number.isFinite(e)&&e>0}function $u(){return typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches}function O1(){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 aa(e,t){return`${e}::${t}`}function Cl(e,t){return`${e}\0${t}`}const jz=/[0-9a-f]{16,}/i,Nz=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function e3(e){return jz.test(e)||Nz.test(e)}function Sz(e){if(!e)return;const t=e.replace(/\\/g,"/").split("/").filter(Boolean);for(let n=t.length-1;n>=0;n--)if(!e3(t[n]))return t[n];return t[t.length-1]}function t3(){return{inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0}}function n3(e){const t=e.cache_creation,n=t&&typeof t=="object"?t:e,s=n.ephemeral_1h_input_tokens,a=n.ephemeral_5m_input_tokens;return typeof s!="number"&&typeof a!="number"?{}:{cacheCreate1hTokens:Number(s??0),cacheCreate5mTokens:Number(a??0)}}function Yf(e){const t=n3(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=Yf({...e.longContext,longContext:void 0})),n}function _z(e){if(!e||typeof e!="object"||Array.isArray(e))return;const t={};for(const[n,s]of Object.entries(e)){if(!n||!s||typeof s!="object")continue;const a=s;t[n]=Yf(a);const o=Cz(a.speeds);o&&(t[n].bySpeed=o)}return Object.keys(t).length?t:void 0}function Cz(e){if(!e||typeof e!="object"||Array.isArray(e))return;const t=Object.entries(e).filter(([n,s])=>n&&s&&typeof s=="object").map(([n,s])=>[n,Yf(s)]);return t.length?Object.fromEntries(t):void 0}function s3(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),...n3(n)};for(const s of Object.values(n)){const a=s3(s,t+1);if(a)return a}return null}function P1(e){return Sz(e)}function D1(e){const t=e.agent_type??e.subagent_type;return t&&!e3(t)?t:"subagent"}function El(e){return e.agent_id?e.agent_id:e.parent_tool_use_id?e.parent_tool_use_id:null}function Yo(e,t){!e.cwd&&t.cwd&&(e.cwd=t.cwd,e.cwdBasename=P1(t.cwd))}function F1(e,t){e.label==="session"&&t.cwd&&(e.label=P1(t.cwd)??"session")}function r3(e,t){const n=D1(t);n&&(e.label==="subagent"||!e.label)&&(e.label=n)}function Qa(e,t,n,s){const a=t;let o=e.agents.get(a);return o||(o={id:a,sessionId:t,label:"session",kind:"root",state:"active",startedAt:n,lastEventAt:n,tools:[],prompts:[],toolCount:0,childCount:0,synthetic:s,usage:t3()},e.agents.set(a,o),o)}function a3(e,t,n,s){const a=aa(t,n),o=e.agents.get(a);return o?(Yo(o,s),r3(o,s),o):null}function Ez(e,t,n){var h;const s=t.session_id??"unknown",a=El(t);if(a){const f=a3(e,s,a,t);if(f)return f}const i=((h=e.agents.get(s))==null?void 0:h.keyedSubagents)===!0?void 0:e.activeSubagentStack.get(s),c=i&&i.length>0?i[i.length-1]:null;if(c){const f=e.agents.get(aa(s,c));if(f)return Yo(f,t),f}const d=Qa(e,s,n,t.hook_event_name!=="SessionStart");return Yo(d,t),F1(d,t),d}function Tz(e,t,n,s){if(t==="SubagentStart"||t==="SubagentStop"||typeof n.agent_id!="string"||n.agent_id==="")return!1;const a=e.agents.get(s);return!a||a.keyedSubagents?!1:(a.keyedSubagents=!0,!0)}function Rz(e,t,n,s,a){const o=aa(t,n),i=Qa(e,t,a,!0);let c=e.agents.get(o);if(c)return Yo(c,s),r3(c,s),c;c={id:o,sessionId:t,label:D1(s),kind:"subagent",parentId:i.id,state:"active",startedAt:a,tools:[],prompts:[],cwd:s.cwd,cwdBasename:P1(s.cwd),toolCount:0,childCount:0,usage:t3()},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 Az(e,t,n){const s=e.activeSubagentStack.get(t)??[];s.includes(n)||(s.push(n),e.activeSubagentStack.set(t,s))}function o3(e,t,n){const s=e.activeSubagentStack.get(t);if(s){for(let a=s.length-1;a>=0;a--)if(s[a]===n){s.splice(a,1);break}s.length===0&&e.activeSubagentStack.delete(t)}}const Mz=new Set(["PreToolUse","PostToolUse","PostToolUseFailure","Stop","SubagentStop"]),i3=/^[a-z][a-z0-9_-]{0,23}$/i;function $z(e,t){if(t.provider==="codex")return;const n=t.effort&&typeof t.effort=="object"?t.effort.level:void 0;return typeof n=="string"&&i3.test(n)?n:Mz.has(e)?null:void 0}function l3(){return{msgsUser:0,msgsAssistant:0,toolUses:0,toolResults:0,systemReminders:0,currentContextTokens:0,memoryFiles:[]}}function B1(e,t,n){if(typeof t.model_context_window=="number"&&t.model_context_window>0){const s=e.agents.get(n);s&&(s.contextWindow=t.model_context_window)}if(typeof t.approval_policy=="string"&&t.approval_policy){const s=e.agents.get(n);s&&(s.approvalPolicy=t.approval_policy)}if(t.reasoning_effort===null||typeof t.reasoning_effort=="string"&&i3.test(t.reasoning_effort)){const s=e.agents.get(n);s&&(s.effort=t.reasoning_effort??void 0)}if(typeof t.context_tokens=="number"&&t.context_tokens>=0){const s=e.agents.get(n);s&&(s.context={...s.context??l3(),currentContextTokens:t.context_tokens})}}const Lz=6e4,_C=64;function c3(e,t,n){const s=typeof t.model=="string"?t.model:null;if(s){const o=e.agents.get(n);o&&(o.model=s)}const a=t.subagentModels;if(a&&typeof a=="object")for(const[o,i]of Object.entries(a)){if(typeof i!="string")continue;const c=aa(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 u3(e,t,n){const s=t.context??null;if(s){const a=e.agents.get(n);if(a){const o=a.context??l3(),i=(d,h)=>typeof s[d]=="number"?s[d]:h,c=Array.isArray(s.memoryFiles)?s.memoryFiles:Array.isArray(s.claudeMdFiles)?s.claudeMdFiles:null;a.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 d3(e,t,n){const s=e.agents.get(n);if(s){const a=typeof t.sessionName=="string"?t.sessionName.trim():"",o=typeof t.sessionTitle=="string"?t.sessionTitle.trim():"";a&&(s.sessionName=a),o&&(s.sessionTitle=o);const i=s.sessionName??"";s.sessionTitle&&i&&s.sessionTitle.toLowerCase()===i.toLowerCase()&&(s.sessionTitle=void 0)}}function Iz(e,t,n){const s=e.agents.get(n);if(s){const a=t.recap;a===null?s.recap=void 0:a&&typeof a.text=="string"&&a.text.trim()&&Number.isFinite(a.at)&&(s.recap={text:a.text.trim(),at:a.at})}}function h3(e,t,n){const s=e.agents.get(n),a=t.activity;!s||!a||typeof a.text!="string"||!a.text.trim()||!Number.isFinite(a.at)||s.activity&&a.at<s.activity.at||(s.activity={text:a.text.trim(),source:a.source==="said"?"said":"tool",at:a.at})}const Oz=new Set(["working","blocked","done","failed","stopped"]);function f3(e,t,n){const s=e.agents.get(n);if(!s)return;const a=t.job;if(a===null){s.job=void 0;return}if(!a||typeof a!="object"||!Oz.has(a.state))return;const o=i=>typeof i=="string"&&i.trim()?i.trim():void 0;s.job={id:o(a.id)??"",state:a.state,detail:o(a.detail)??"",needs:o(a.needs),suggestedReply:o(a.suggestedReply),result:o(a.result),updatedAt:Number.isFinite(a.updatedAt)?a.updatedAt:0}}function Pz(e,t,n,s){const a=t.kind==="thinking"||t.kind==="text"||t.kind==="tool_use"?t.kind:null,o=typeof t.at=="number"&&Number.isFinite(t.at)?t.at:s;if(!a)return;const i=e.agents.get(n);if(i&&!(i.lastOutputAt!=null&&o<=i.lastOutputAt)){if(i.lastOutputAt=o,a!=="tool_use"){const c=(i.outputs??[]).filter(d=>o-d<Lz);c.push(o),i.outputs=c.length>_C?c.slice(-_C):c}e.revision+=1}}function q1(e,t,n){const s=t.usage??null;if(s){const a=e.agents.get(n);if(a){const o=Yf(s),i=o.inputTokens<a.usage.inputTokens||o.outputTokens<a.usage.outputTokens||o.cacheReadTokens<a.usage.cacheReadTokens||o.cacheCreateTokens<a.usage.cacheCreateTokens;Object.assign(a.usage,o),(a.provider!=="codex"||t.usageByModel!==void 0||i)&&(a.usageByModel=_z(t.usageByModel))}}}function Kt(e,t){return Object.hasOwn(e,t)?e[t]:void 0}const Dz=/^\s*<task-notification>([\s\S]*?)<\/task-notification>/;function CC(e,t){var n;return((n=new RegExp(`<${t}>([\\s\\S]*?)</${t}>`).exec(e))==null?void 0:n[1].trim())||void 0}const Fz={completed:"background task finished",failed:"background task failed",killed:"background task stopped"};function Xf(e){const t=Dz.exec(e);if(!t)return null;const n=CC(t[1],"status");return{label:(n?Kt(Fz,n):void 0)??"background task update",detail:CC(t[1],"summary")}}function p3(e){return e.filter(t=>!Xf(t.text))}const EC=2e3;function Bz(e,t,n){for(let s=e.length-1;s>=0;s--){const a=e[s];if(a.at<t-EC)return!1;if(a.text===n&&a.at<=t+EC)return!0}return!1}function qz(e,t,n){if(Bz(e,t,n))return!1;let s=e.length;for(;s>0&&e[s-1].at>t;)s--;return e.splice(s,0,{at:t,text:n}),!0}const rf=2e3;function Uz(e){const t=e.prompts[e.prompts.length-1];return t&&t.at>e.startedAt?t.at:e.startedAt}const TC=["B","KB","MB","GB","TB"];function Yr(e){if(e==null||!Number.isFinite(e)||e<0)return"—";if(e===0)return"0 B";let t=e,n=0;for(;n<TC.length-1&&Number(t.toFixed(1))>=1024;)t/=1024,n++;return`${t.toFixed(1)} ${TC[n]}`}const Wz=60,Hz=6e3,ys=e=>e!=null&&typeof e=="object"&&!Array.isArray(e),Wn=e=>typeof e=="string"?e:null;function zz(e){return ys(e)&&e.ccdeck_truncated===!0&&typeof e.chars=="number"&&Object.keys(e).length===2?e.chars:null}function gl(e){const t=zz(e);if(t!=null)return`(too large to show — ${Yr(t)}, cut by the hook)`;if(Array.isArray(e)){const n=e.map(gl);return n.some((s,a)=>s!==e[a])?n:e}if(ys(e)){let n=!1;const s={};for(const[a,o]of Object.entries(e))s[a]=gl(o),s[a]!==o&&(n=!0);return n?s:e}return e}function Xo(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),s=n?e.map((o,i)=>[String(i),o]):Object.entries(e);if(s.length===0)return n?"[]":"{}";const a=[];for(const[o,i]of s){const c=n?`${t}-`:`${t}${o}:`;if(typeof i=="string"&&i.includes(`
|
|
58
|
+
`)){a.push(c);for(const d of i.split(`
|
|
59
|
+
`))a.push(`${t} ${d}`)}else if(i!==null&&typeof i=="object"){const d=Xo(i,`${t} `);d==="[]"||d==="{}"?a.push(`${c} ${d}`):a.push(c,d)}else a.push(`${c} ${i===void 0?"(none)":String(i)}`)}return a.join(`
|
|
60
|
+
`)}function Vz(e){return e.lines??e.text.split(`
|
|
61
|
+
`).map(t=>({text:t}))}function m3(e,t){if(t)return{shown:e,cut:!1};const n=[];let s=0;for(const a of e){if(n.length===Wz)return{shown:n,cut:!0};const o=Hz-s;if(a.text.length>o)return n.push({...a,text:`${a.text.slice(0,Math.max(o,0))}…`}),{shown:n,cut:!0};n.push(a),s+=a.text.length+1}return{shown:n,cut:!1}}function Gz(e,t){return m3(e,!1).cut?t?{label:"show less",expanded:!0}:{label:"show all",expanded:!1}:null}const wn=(e,t,n=!1)=>({...e?{label:e}:{},text:t,...n?{err:!0}:{}}),Hn=(e,t)=>({label:e,text:t,inline:!0}),g3=(e,t)=>({label:e,text:t.map(n=>n.text).join(`
|
|
62
|
+
`),lines:t});function Kz(e,t){return[...e.split(`
|
|
63
|
+
`).map(n=>({text:`- ${n}`,tone:"del"})),...t.split(`
|
|
64
|
+
`).map(n=>({text:`+ ${n}`,tone:"add"}))]}function Yz(e){if(!Array.isArray(e)||e.length===0)return null;const t=[];for(const n of e){if(!ys(n)||!Array.isArray(n.lines))return null;t.push({text:`@@ -${n.oldStart},${n.oldLines} +${n.newStart},${n.newLines} @@`,tone:"ctx"});for(const s of n.lines){const a=String(s);t.push(a.startsWith("+")?{text:a,tone:"add"}:a.startsWith("-")?{text:a,tone:"del"}:{text:a})}}return t}function RC(e){if(typeof e=="string")return[wn(void 0,e)];if(!ys(e))return[wn(void 0,Xo(e))];const t=[],n=Wn(e.type);n==="create"&&t.push(Hn("result","created the file"));const s=Yz(e.structuredPatch);return s&&t.push(g3("applied",s)),e.userModified===!0&&t.push(Hn("note","the user changed it before it was applied")),t.length?t:[Hn("result",n==="update"?"updated the file":"done")]}function Xz(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 s=t??1;return n!=null?`${s}–${s+n-1}`:`from ${s}`}function Zz(e){if(typeof e=="string")return[wn(void 0,e)];const t=ys(e)&&ys(e.file)?e.file:null,n=Wn(t==null?void 0:t.content);if(t&&n!=null){const a=[],o=Number(t.numLines),i=Number(t.totalLines),c=Number(t.startLine);return Number.isFinite(o)&&Number.isFinite(i)&&i>0&&a.push(Hn("lines",o>=i?`all ${i}`:Number.isFinite(c)?`${c}–${c+o-1} of ${i}`:`${o} of ${i}`)),a.push(wn("content",n)),a}const s=ys(e)?Wn(e.type):null;return s&&s!=="text"?[Hn("result",`${/^[aeiou]/i.test(s)?"an":"a"} ${s} file`)]:[wn(void 0,Xo(e))]}function Jz(e){if(typeof e=="string")return[wn("output",e)];if(!ys(e))return[wn(void 0,Xo(e))];const t=Wn(e.stdout),n=Wn(e.stderr);if(t==null&&n==null)return[wn(void 0,Xo(e))];const s=[];return t&&s.push(wn("output",t.replace(/\n$/,""))),n&&s.push(wn("errors",n.replace(/\n$/,""),!0)),e.interrupted===!0&&s.push(Hn("note","interrupted before it finished")),s.length?s:[Hn("output","none")]}function Qz(e,t,n){const s=gl(t),a=gl(n),o=ys(s)?s:null;if(o&&(e==="Edit"||e==="MultiEdit")){const i=Wn(o.file_path),c=(e==="MultiEdit"?Array.isArray(o.edits)?o.edits:[]:[o]).filter(ys).filter(d=>Wn(d.old_string)!=null&&Wn(d.new_string)!=null);if(i&&c.length){const d=[Hn("file",i)];return c.forEach((h,f)=>{const p=h.replace_all===!0?", every occurrence":"";d.push(g3(c.length>1?`change ${f+1}${p}`:`change${p}`,Kz(h.old_string,h.new_string)))}),{input:d,response:RC(a)}}}if(o&&e==="Write"){const i=Wn(o.file_path),c=Wn(o.content);if(i&&c!=null)return{input:[Hn("file",i),wn("content",c)],response:RC(a)}}if(o&&e==="Read"){const i=Wn(o.file_path);if(i){const c=Xz(o);return{input:c?[Hn("file",i),Hn("lines",c)]:[Hn("file",i)],response:Zz(a)}}}if(o&&e==="Bash"){const i=Wn(o.command);if(i!=null){const c=Wn(o.description);return{input:c?[wn("command",i),Hn("why",c)]:[wn("command",i)],response:Jz(a)}}}return{input:[wn(void 0,Xo(s))],response:[wn(void 0,Xo(a))]}}function AC(e,t,n){const s=gl(n);if(s==null)return"";if(typeof s=="string")return s;if(ys(s)){if(e==="Bash"&&t==="input"&&typeof s.command=="string")return s.command;if(e==="Bash"&&t==="response"&&(typeof s.stdout=="string"||typeof s.stderr=="string"))return[s.stdout,s.stderr].filter(a=>typeof a=="string"&&a!=="").join(`
|
|
65
|
+
`);if(e==="Read"&&t==="response"&&ys(s.file)&&typeof s.file.content=="string")return s.file.content}try{return JSON.stringify(s,null,2)??String(s)}catch{return String(s)}}const e7=new Set(["TodoWrite","update_plan"]),t7=new Set(["TaskCreate","TaskUpdate","TaskList","TaskGet"]);function Dc(e){return e==="pending"||e==="in_progress"||e==="completed"?e:null}function fs(e){return typeof e=="string"?e.trim():""}function To(e){if(e&&typeof e=="object"&&!Array.isArray(e))return e;if(typeof e=="string")try{const t=JSON.parse(e);return t&&typeof t=="object"&&!Array.isArray(t)?t:null}catch{return null}return null}function n7(e,t){const n=To(t);if(!n)return null;const s=e==="TodoWrite"?n.todos:n.plan;if(!Array.isArray(s))return null;const a=[];for(const i of s){if(!i||typeof i!="object")continue;const c=i,d=fs(e==="TodoWrite"?c.content:c.step),h=Dc(c.status);if(!d||!h)continue;const f=fs(c.activeForm??c.active_form);a.push(f?{text:d,status:h,active:f}:{text:d,status:h})}const o=e==="update_plan"?fs(n.explanation):"";return o?{items:a,note:o}:{items:a}}function $a(e,t,n){return n?{items:e,at:t,note:n}:{items:e,at:t}}function s7(e,t,n,s){if(!t||!e7.has(t)||e.plan&&s<e.plan.at)return;const a=n7(t,n);a&&(e.plan=$a(a.items,s,a.note))}function Fi(e){if(!e)return"";const t=e.taskId??e.id??e.task_id;return typeof t=="number"?String(t):fs(t)}function r7(e,t,n,s,a){var v,b,k,N,S,_,E,I,A,O,L,U,P,T,B;if(!t||!t7.has(t))return;const o=To(n),i=To(s),c=((v=e.plan)==null?void 0:v.items)??[],d=M=>c.findIndex(q=>q.id===M);if(t==="TaskCreate"){const M=To(i==null?void 0:i.task),q=Fi(M),$=fs(M==null?void 0:M.subject)||fs(o==null?void 0:o.subject);if(!q||!$)return;const K=fs((o==null?void 0:o.activeForm)??(o==null?void 0:o.active_form)),G=d(q),z={id:q,text:$,status:G>=0?c[G].status:"pending",...K?{active:K}:{}},W=c.slice();G>=0?W[G]=z:W.push(z),e.plan=$a(W,Math.max(a,((b=e.plan)==null?void 0:b.at)??a),(k=e.plan)==null?void 0:k.note);return}if(t==="TaskUpdate"){if(i&&i.success===!1)return;const M=Fi(i)||Fi(o);if(!M)return;const q=o==null?void 0:o.status,$=d(M);if(q==="deleted"){if($<0)return;e.plan=$a(c.filter((ee,F)=>F!==$),Math.max(a,((N=e.plan)==null?void 0:N.at)??a),(S=e.plan)==null?void 0:S.note);return}const K=fs(o==null?void 0:o.subject),G=fs((o==null?void 0:o.activeForm)??(o==null?void 0:o.active_form)),z=Dc(q)??Dc((_=To(i==null?void 0:i.statusChange))==null?void 0:_.to);if($<0){if(!K)return;const ee={id:M,text:K,status:z??"pending",...G?{active:G}:{}};e.plan=$a([...c,ee],Math.max(a,((E=e.plan)==null?void 0:E.at)??a),(I=e.plan)==null?void 0:I.note);return}const D={...c[$],...K?{text:K}:{},...z?{status:z}:{},...G?{active:G}:{}},H=c.slice();H[$]=D,e.plan=$a(H,Math.max(a,((A=e.plan)==null?void 0:A.at)??a),(O=e.plan)==null?void 0:O.note);return}if(t==="TaskList"){if(!i||!Array.isArray(i.tasks)||e.plan&&a<e.plan.at)return;const M=[];for(const q of i.tasks){const $=To(q),K=Fi($),G=fs($==null?void 0:$.subject),z=Dc($==null?void 0:$.status);if(!K||!G||!z)continue;const W=c.find(D=>D.id===K);M.push(W!=null&&W.active?{id:K,text:G,status:z,active:W.active}:{id:K,text:G,status:z})}e.plan=$a(M,a,(L=e.plan)==null?void 0:L.note);return}const h=i&&"task"in i?To(i.task):void 0,f=Fi(h??null)||Fi(o),p=f?d(f):-1;if(p<0)return;if(h===null){e.plan=$a(c.filter((M,q)=>q!==p),Math.max(a,((U=e.plan)==null?void 0:U.at)??a),(P=e.plan)==null?void 0:P.note);return}const m=fs(h==null?void 0:h.subject),w=Dc(h==null?void 0:h.status);if(!m&&!w)return;const j=c.slice();j[p]={...c[p],...m?{text:m}:{},...w?{status:w}:{}},e.plan=$a(j,Math.max(a,((T=e.plan)==null?void 0:T.at)??a),(B=e.plan)==null?void 0:B.note)}function Lu(e){const t=(e==null?void 0:e.items)??[];if(t.length===0)return null;const n=t.filter(i=>i.status==="completed").length,s=t.find(i=>i.status==="in_progress"),a=s?null:t.find(i=>i.status==="pending"),o=s?s.active||s.text:a?a.text:null;return{done:n,total:t.length,current:o,next:!s&&!!a,allDone:n===t.length}}function a7(e){const t=`${e.done}/${e.total}`;return e.allDone||!e.current?`${t} · done`:`${t} · ${e.next?"next: ":""}${e.current}`}function y3(e){const t=`plan ${e.done} of ${e.total} done`;return e.allDone||!e.current?t:`${t}, ${e.next?"next":"now"}: ${e.current}`}function w3(e){return e.map(t=>`${t.status==="completed"?"✓":t.status==="in_progress"?"▸":"○"} ${t.text}`).join(`
|
|
66
|
+
`)}function du(e,t=80){const n=gl(e);if(n==null)return"";if(typeof n=="string")return n.length>t?n.slice(0,t-1)+"…":n;try{const s=JSON.stringify(n);return s.length>t?s.slice(0,t-1)+"…":s}catch{return String(n)}}const MC=200;function x3(e,t,n){const s=t.ok===!1;t.ok=n,e&&s===n&&(e.toolErrorCount=(e.toolErrorCount??0)+(n?-1:1))}function v3(e,t){return t.agentId==null?void 0:e.agents.get(t.agentId)}function Vc(e,t,n){const s=e.toolCountByName??(e.toolCountByName=new Map),a=(s.get(t)??0)+n;a>0?s.set(t,a):s.delete(t)}function o7(e,t,n){var s;return((s=e.get(t))==null?void 0:s.tools.find(a=>a.id===n))??null}const b3=25;function k3(e,t){const n=t.tools;if(n.length>MC){const s=n.splice(0,n.length-MC);for(const a of s)N3(e,t,a)}for(let s=n.length-b3-1;s>=0;s--){const a=n[s];if(a.trimmed)break;a.input=void 0,a.response=void 0,a.trimmed=!0}}function i7(e,t,n){const s=e.toolIndex.get(Cl(t.sessionId,n));if(s)return s;for(let a=t.tools.length-1;a>=0;a--)if(t.tools[a].id===n)return t.tools[a];return null}function j3(e,t){for(const n of t.tools)N3(e,t,n)}function N3(e,t,n){const s=Cl(t.sessionId,n.id);e.toolIndex.get(s)===n&&e.toolIndex.delete(s)}function l7(e,t){const n=e.agents.get(t);if(!n)return;let s=!1;for(const a of e.agents.values()){if(a===n||a.sessionId!==t)continue;const o=a.tools.filter(i=>i.explicitSubagentId==null);if(o.length!==0){for(const i of o)a.toolCount-=1,Vc(a,i.name,-1),i.ok===!1&&(a.toolErrorCount=(a.toolErrorCount??0)-1),i.agentId=n.id,n.tools.push(i),n.toolCount+=1,Vc(n,i.name,1),i.ok===!1&&(n.toolErrorCount=(n.toolErrorCount??0)+1);a.tools=a.tools.filter(i=>i.explicitSubagentId!=null),s=!0}}if(s){n.tools.sort((a,o)=>a.startedAt-o.startedAt),k3(e,n);for(let a=0;a<n.tools.length-b3;a++){const o=n.tools[a];o.trimmed||(o.input=void 0,o.response=void 0,o.trimmed=!0)}}}const c7="no result reached the deck — events were dropped while the deck was paused";function S3(e,t,n,s,a){n.endedAt=s,x3(t,n,!1),n.errorPreview=n.outcomeGap?c7:a,e.toolIndex.delete(Cl(t.sessionId,n.id))}function u7(e,t){const n=t==null?void 0:t.payload,s=n==null?void 0:n.hook_event_name;if(s!=="PostToolUse"&&s!=="PostToolUseFailure")return!1;const a=n==null?void 0:n.tool_use_id;return typeof a!="string"||a.length===0?!1:e.toolIndex.has(Cl((n==null?void 0:n.session_id)??"unknown",a))}function d7(e,t,n,s,a){const o=t.tool_use_id?i7(e,s,t.tool_use_id):null;if(o){if(t.tool_name&&o.name==="?"){o.name=t.tool_name;const h=v3(e,o);h&&(Vc(h,"?",-1),Vc(h,o.name,1))}o.endedAt==null&&!o.trimmed&&t.tool_input!==void 0&&(o.input=t.tool_input,o.inputPreview=du(t.tool_input));return}const i=t.tool_use_id??`${s.id}:${s.toolCount}`,c=El(t),d={id:i,name:t.tool_name??"?",input:t.tool_input,inputPreview:du(t.tool_input),agentId:s.id,explicitSubagentId:c?aa(n,c):void 0,startedAt:a};s.tools.push(d),s.toolCount+=1,Vc(s,d.name,1),s.state="active",e.toolIndex.set(Cl(s.sessionId,i),d),k3(e,s),s7(s,d.name,t.tool_input,a)}function h7(e,t,n,s,a){const o=t.tool_use_id;if(!o)return;const i=Cl(s,o);let c=e.toolIndex.get(i),d=!1;if(!c)for(const f of e.agents.values()){if(f.sessionId!==s)continue;const p=f.tools.find(m=>m.id===o);if(p){c=p,d=!0;break}}if(!c||c.outcomeApplied)return;if(c.outcomeApplied=!0,n==="PostToolUse"){const f=e.agents.get(s);f&&r7(f,t.tool_name??c.name,t.tool_input??c.input,t.tool_response,a)}c.outcomeGap=void 0,c.endedAt=a,x3(v3(e,c),c,n==="PostToolUse"),c.trimmed||(c.response=t.tool_response),n==="PostToolUseFailure"?c.errorPreview=du(t.tool_response):d&&(c.errorPreview=void 0);const h=s3(t.tool_response);h&&(c.usage=h),e.toolIndex.delete(i)}function f7(e,t,n){const s=e.agents.get(t);s&&n>(s.lastEventAt??0)&&(s.lastEventAt=n,s.reaped&&(s.reaped=!1,s.state="active",s.endedAt=void 0,s.closedAt=void 0))}function U1(e,t){e!=null&&e.stopFailure&&t>e.stopFailure.at&&(e.stopFailure=null)}function p7(e,t,n,s){const a=Qa(e,n,s,!1);a.synthetic=!1,a.state="active",a.closedAt=void 0,a.endedAt=void 0,U1(a,s),a.startedAt=Math.min(a.startedAt??s,s),Yo(a,t),F1(a,t)}function m7(e,t,n,s){for(const i of e.agents.values())i.sessionId===n&&i.kind==="subagent"&&i.state==="done"&&i.exitAt==null&&i.endedAt!=null&&i.endedAt<s&&(i.exitAt=s);const a=Qa(e,n,s,!1);a.state="active",a.endedAt=void 0,a.closedAt=void 0,a.exitAt=void 0,U1(a,s);const o=(typeof t.prompt=="string"?t.prompt:typeof t.message=="string"?t.message:"")??"";o&&qz(a.prompts,s,o)&&!a.firstPrompt&&!Xf(o)&&(a.firstPrompt=du(o,120))}function i0(e,t,n,s,a){const o=Qa(e,n,s,!1),i=Uz(o);if(s<i)return;const c=o.lastTurnEndAt;if(!(c!=null&&i>c&&s<=c+rf)){o.state="done",o.endedAt=s,o.lastTurnEndAt=s,a&&(!o.stopFailure||s>=o.stopFailure.at)&&(o.stopFailure=a.stopFailure);for(const d of o.provider==="codex"?[]:e.agents.values())if(d.sessionId===n)for(const h of d.tools)h.endedAt==null&&h.explicitSubagentId==null&&S3(e,d,h,s,"the turn ended before this call returned");t==="SessionEnd"&&(o.closedAt=s),e.activeSubagentStack.delete(n)}}function g7(e,t,n){var i;const s=t.session_id;if(t.provider!=="codex"&&t.provider!=="claude"||typeof s!="string"||!s)return;const a=e.agents.get(s);if(a!=null&&a.provider&&a.provider!==t.provider||a&&Number.isFinite(t.snapshot_observed_at)&&(a.recoveryLiveAt??a.lastEventAt??0)>=t.snapshot_observed_at)return;if(t.recovery_active===!1){a&&(i0(e,t.recovery_session_closed===!0?"SessionEnd":"Stop",s,n),a.restoredFromLog=void 0);return}const o=Qa(e,s,n,!0);o.recoveryLiveAt??(o.recoveryLiveAt=(a==null?void 0:a.lastEventAt)??0),o.provider=t.provider,o.state="active",o.endedAt=o.closedAt=o.exitAt=void 0,o.reaped=!1,o.restoredFromLog=!0,o.lastEventAt=n,Yo(o,t),F1(o,t),typeof t.model=="string"&&t.model&&(o.model=t.model),!a&&Number.isFinite(t.turn_started_at)&&t.turn_started_at<=n&&(o.startedAt=t.turn_started_at),typeof t.prompt=="string"&&t.prompt&&(((i=o.prompts.at(-1))==null?void 0:i.text)!==t.prompt&&o.prompts.push({at:n,text:t.prompt}),o.firstPrompt||(o.firstPrompt=du(t.prompt,120))),B1(e,t,s),q1(e,t,s)}function y7(e,t,n){const s=t.session_id,a=t.parent_session_id;if(t.provider!=="codex"||typeof s!="string"||!s||typeof a!="string"||!a||s===a)return;const o=e.agents.get(s);if(o!=null&&o.provider&&o.provider!=="codex"||o!=null&&o.parentId&&o.parentId!==a)return;const i=new Set([s]);for(let f=a;f;){if(i.has(f))return;i.add(f);const p=e.agents.get(f);if(p!=null&&p.provider&&p.provider!=="codex")return;f=p==null?void 0:p.parentId}const c=Qa(e,s,n,!0);c.provider="codex",c.parentId=a,Yo(c,t);const d=t.agent_nickname||t.agent_role;typeof d=="string"&&d.trim()&&(c.label=d);const h=e.agents.get(a);h&&(h.childCount=[...e.agents.values()].filter(f=>f.parentId===a).length)}const w7=["us-gov","global","apac","us","eu","jp","au"],x7=new RegExp(`^(?:(?:${w7.join("|")})\\.)?anthropic\\.`,"i");function pr(e){return e.replace(x7,"")}const v7=/^(?:claude[-_]|gpt[-_]|o\d|codex[-_])/i,b7=new Set(["tool_input","tool_response"]);function _3(e,t=0){if(!e||typeof e!="object"||t>6)return null;const n=e;if(typeof n.model=="string"&&v7.test(pr(n.model)))return n.model;for(const[s,a]of Object.entries(n)){if(b7.has(s))continue;const o=_3(a,t+1);if(o)return o}return null}const k7=256,Ih={ModelObserved:c3,UsageObserved:q1,ContextObserved:u3,SessionNamed:d3,ActivityObserved:h3,JobObserved:f3},Kr=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),ch=e=>typeof e=="string"&&e.trim()!=="",j7=[["model_context_window",e=>typeof e=="number"&&e>0],["approval_policy",e=>typeof e=="string"&&e!==""],["reasoning_effort",e=>typeof e=="string"&&e!==""||e===null],["context_tokens",e=>typeof e=="number"&&e>=0]],N7=new Set(["working","blocked","done","failed","stopped"]),$C=e=>Kr(e)&&typeof e.text=="string"&&e.text.trim()!==""&&Number.isFinite(e.at);function S7(e,t){if(!e)return t;const n={...e};for(const[a,o]of Object.entries(t))o!==void 0&&(n[a]=o);const s=a=>{a in e?n[a]=e[a]:delete n[a]};for(const[a,o]of j7)o(t[a])||s(a);switch(t.hook_event_name){case"ModelObserved":typeof t.model=="string"&&t.model!==""||s("model"),(Kr(e.subagentModels)||Kr(t.subagentModels))&&(n.subagentModels={...Kr(e.subagentModels)?e.subagentModels:{},...Kr(t.subagentModels)?t.subagentModels:{}});break;case"ContextObserved":{if(!Kr(t.context)){s("context");break}const a=Kr(e.context)?{...e.context}:{};for(const[o,i]of Object.entries(t.context))(typeof i=="number"||Array.isArray(i))&&(a[o]=i);n.context=a;break}case"SessionNamed":{const a=ch(t.sessionName)?t.sessionName:e.sessionName??null;let o=ch(t.sessionTitle)?t.sessionTitle:e.sessionTitle??null;ch(a)&&ch(o)&&o.trim().toLowerCase()===a.trim().toLowerCase()&&(o=null),n.sessionName=a,n.sessionTitle=o;break}case"ActivityObserved":(!$C(t.activity)||$C(e.activity)&&t.activity.at<e.activity.at)&&s("activity");break;case"JobObserved":t.job===null||Kr(t.job)&&N7.has(t.job.state)||s("job");break;case"UsageObserved":Kr(t.usage)?t.usageByModel===void 0&&delete n.usageByModel:(s("usage"),s("usageByModel"));break}return n}function _7(e,t,n,s){if(!(t in Ih)||e.agents.has(s))return!1;const a=e.parkedEnrichment.get(s)??new Map,o=S7(a.get(t),n);for(a.delete(t),a.set(t,o),e.parkedEnrichment.delete(s),e.parkedEnrichment.set(s,a);e.parkedEnrichment.size>k7;){const i=e.parkedEnrichment.keys().next().value;if(i===void 0)break;e.parkedEnrichment.delete(i)}return!0}function C7(e,t){var s;const n=e.parkedEnrichment.get(t);if(!(!n||!e.agents.has(t))){e.parkedEnrichment.delete(t);for(const[a,o]of n)B1(e,o,t),(s=Ih[a])==null||s.call(Ih,e,o,t)}}function C3(e,t){e.parkedEnrichment.delete(t)}const E7="StopFailure",LC=Object.freeze({authentication_failed:"login",rate_limit:"usage-limit"});function T7(e){return typeof e=="string"&&Object.hasOwn(LC,e)?LC[e]:"api-error"}const R7=/^[a-z][a-z0-9_]{0,39}$/;function A7(e){const t=e==null?void 0:e.error;return typeof t=="string"&&R7.test(t)?t:"unknown"}const IC=160;function OC(e){if(typeof e!="string")return"";const t=e.replace(/\x1b\[[0-?]*[ -/]*[@-~]/g,"").replace(/\x1b\][^\x07\x1b]*(?:\x07|\x1b\\)?/g,"").replace(/[\p{Cc}\p{Cf}]/gu," ").replace(/\bsk-ant-[A-Za-z0-9_-]+/g,"sk-ant-…").replace(/\b(Bearer)\s+[A-Za-z0-9._~+/=-]+/gi,"$1 …").replace(/\s+/g," ").trim(),n=[...t];return n.length>IC?`${n.slice(0,IC-1).join("").trimEnd()}…`:t}function M7(e){return OC(e==null?void 0:e.last_assistant_message)||OC(e==null?void 0:e.error_details)}function $7(e,t){if(!e||typeof e!="object"||e.hook_event_name!==E7)return null;const n=A7(e);return{kind:T7(n),error:n,message:M7(e),at:t}}function L7(e,t,n,s){const a=El(t);if(!a)return;const o=Rz(e,n,a,t,s),i=D1(t);i&&(o.label=i);const c=e.subagentTombstones.get(o.id);c!=null&&e.subagentTombstones.delete(o.id);const d=o.endedAt!=null&&s-o.endedAt<=rf,h=c!=null&&s-c<=rf;if(d||h){const f=h?c:o.endedAt;o.state="done",o.endedAt=f,o.startedAt=Math.min(o.startedAt,f),o3(e,n,a);return}o.state="active",o.startedAt=o.startedAt||s,o.exitAt=void 0,o.endedAt=void 0,Az(e,n,a)}function I7(e,t,n,s){const a=El(t);if(!a)return;const o=a3(e,n,a,t);if(!o){for(const[i,c]of e.subagentTombstones)s-c>rf&&e.subagentTombstones.delete(i);e.subagentTombstones.set(aa(n,a),s);return}o.state="done",o.endedAt=Math.min(o.endedAt??s,s),o3(e,n,a)}const O7=["command","cmd","file_path","path","url","pattern","notebook_path"],PC=120,zg=e=>e.length>PC?`${e.slice(0,PC-1)}…`:e;function P7(e){if(typeof e=="string")return e.trim()?zg(e.trim()):null;if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e;for(const n of O7){const s=t[n];if(typeof s=="string"&&s.trim())return zg(s.trim());if(Array.isArray(s)&&s.length>0&&s.every(a=>typeof a=="string")){const a=s.join(" ").trim();if(a)return zg(a)}}return null}function D7(e){return e==="permission_prompt"?"permission":e==="agent_needs_input"?"asked":e==="idle_prompt"?"idle":null}const F7=new Set(["Notification","ModelObserved","ContextObserved","UsageObserved","SessionNamed","SessionRecapped","OutputObserved","ActivityObserved","JobObserved"]);function B7(e,t){let n=null;for(const s of e.toolIndex.values()){const a=s.agentId?e.agents.get(s.agentId):void 0;!a||a.sessionId!==t||(!n||s.startedAt>n.startedAt)&&(n=s)}return n}const q7=3e4;function U7(e,t){if(!(!e||!e.name)&&!(t-e.startedAt>q7)&&!(e.startedAt>t))return{name:e.name,preview:P7(e.input)??""}}function W7(e,t,n,s,a){if(n!=="permission")return{kind:n,message:s,since:a};const o=B7(e,t),i={kind:n,message:s,since:a};o!=null&&o.explicitSubagentId&&(i.subagentId=o.explicitSubagentId);const c=U7(o,a);return c&&(i.tool=c),i}function H7(e,t,n){if(e.kind==="idle")return!0;const s=El(t);return s==null?!0:e.subagentId!=null&&aa(n,s)===e.subagentId}function z7(e,t,n,s){if(!F7.has(t)){const a=e.agents.get(s);a!=null&&a.waiting&&H7(a.waiting,n,s)&&(a.waiting=null)}}function V7(e,t,n,s){const a=D7(t.notification_type);if(!a)return;const o=Qa(e,n,s,!1),i=typeof t.message=="string"?t.message:"",c=o.waiting;o.waiting=c&&c.kind===a&&c.message===i?{...c,since:Math.min(c.since,s)}:W7(e,n,a,i,s)}function Zf(e){const t=[...e],n=new Map(t.map(a=>[a.id,a])),s=new Map;for(const a of t){let o=a;const i=new Set;for(;o.provider==="codex"&&o.parentId;){if(i.has(o.id)){o=a;break}i.add(o.id);const c=n.get(o.parentId);if(!c||c.provider!=="codex")break;o=c}s.set(a.id,o.sessionId)}return s}function Iu(e,t){return t&&(e.revision+=1),t}function G7(e,t,n,s,a){if(e.agents.size<=n)return!1;const o=w=>w.state==="done"&&w.endedAt!=null&&t-w.endedAt>s,i=Zf(e.agents.values()),c=new Set([...e.agents.values()].filter(w=>w.provider==="codex"&&!o(w)).map(w=>i.get(w.id))),d=[],h=new Map;for(const[w,j]of e.agents){if(j.parentId!=null){const v=h.get(j.parentId);v?v.push(w):h.set(j.parentId,[w])}o(j)&&!c.has(i.get(w))&&d.push({id:w,endedAt:j.endedAt})}if(d.length===0)return!1;d.sort((w,j)=>w.endedAt-j.endedAt);let f=0;const p=new Set,m=w=>{const j=e.agents.get(w);j&&(j3(e,j),e.agents.delete(w),j.kind==="root"&&C3(e,j.sessionId),p.add(j.sessionId),f++)};for(const w of d){if(e.agents.size<=n)break;if(!e.agents.has(w.id))continue;const j=[],v=new Set([w.id]),b=[...h.get(w.id)??[]];for(;b.length;){const k=b.pop();if(v.has(k))continue;v.add(k);const N=e.agents.get(k);N&&(j.push(N),b.push(...h.get(k)??[]))}if(!j.some(k=>!o(k))){for(const k of j.reverse())m(k.id);m(w.id)}}if(a&&p.size>0){const w=new Set;for(const j of e.agents.values())w.add(j.sessionId);for(const j of p)w.has(j)||a(j)}return Iu(e,f>0)}function K7(e,t,n,s,a){const o=new Map;for(const[m,w]of e.agents){let j=o.get(w.sessionId);j||(j={ids:[],endedAt:0,live:!1,closed:!1},o.set(w.sessionId,j)),j.ids.push(m),w.kind==="root"&&w.closedAt!=null&&(j.closed=!0),w.state==="done"&&w.endedAt!=null?j.endedAt=Math.max(j.endedAt,w.endedAt):j.live=!0}const i=Zf(e.agents.values()),c=new Set([...e.agents.values()].filter(m=>m.state!=="done"||m.endedAt==null).map(m=>i.get(m.id))),d=[...o].filter(([m,w])=>!c.has(i.get(m))&&!w.live&&w.endedAt>0&&t-w.endedAt>s).sort(([,m],[,w])=>m.closed===w.closed?m.endedAt-w.endedAt:m.closed?-1:1);let f=[...o.values()].filter(m=>!m.live).length-n;if(f<=0)return!1;let p=!1;for(const[m,w]of d){if(f<=0)break;for(const v of w.ids){const b=e.agents.get(v);b&&j3(e,b),e.agents.delete(v)}C3(e,m);const j=aa(m,"");for(const v of e.pendingSubagentModels.keys())v.startsWith(j)&&e.pendingSubagentModels.delete(v);a==null||a(m),f--,p=!0}return Iu(e,p)}function Y7(e){let t=!1;for(const n of e.agents.values())for(const s of n.tools)s.endedAt!=null||s.outcomeGap||(s.outcomeGap=!0,t=!0);return Iu(e,t)}function X7(e,t,n){let s=!1;for(const a of e.agents.values()){if(a.provider==="codex")continue;const o=e.agents.get(a.sessionId),i=(o==null?void 0:o.lastEventAt)??(o==null?void 0:o.startedAt);for(const c of a.tools){const d=Math.max(c.startedAt,i??c.startedAt);c.endedAt==null&&t-d>n&&(S3(e,a,c,d,"session ended before this call returned"),s=!0)}}return Iu(e,s)}const DC=90*6e4;function Z7(e,t,n){let s=!1;for(const a of e.agents.values()){if(a.kind!=="root")continue;const o=a.lastEventAt??a.startedAt;if(!(t-o<=n)){a.waiting&&(a.waiting=null,s=!0),a.closedAt==null&&(a.closedAt=o),a.state==="active"&&(a.state="done",a.endedAt=o,a.reaped=!0,s=!0);for(const i of e.agents.values())i.sessionId!==a.sessionId||i.kind==="root"||i.state!=="active"||(i.state="done",i.endedAt=o,s=!0);e.activeSubagentStack.delete(a.sessionId)}}return Iu(e,s)}function hu(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 E3(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 s=t.payload??{},a=t.receivedAt,o=s.hook_event_name??"Unknown";if(o==="__clear")return{...O1(),lastSeq:t.seq,seqEpoch:e.seqEpoch,revision:e.revision+1};if(e.totalEvents+=1,e.lastSeq=t.seq,e.revision+=1,o==="CodexSessionRecovered"||o==="ClaudeSessionRecovered")return g7(e,s,a),e;if(o==="CodexThreadLinked")return y7(e,s,a),e;const i=s.session_id??"unknown";if(z7(e,o,s,i),o!=="JobObserved"&&f7(e,i,a),B1(e,s,i),_7(e,o,s,i))return e;switch(o){case"ModelObserved":return c3(e,s,i),e;case"ContextObserved":return u3(e,s,i),e;case"SessionNamed":return d3(e,s,i),e;case"SessionRecapped":return Iz(e,s,i),e;case"ActivityObserved":return h3(e,s,i),e;case"JobObserved":return f3(e,s,i),e;case"OutputObserved":return Pz(e,s,i,a),e;case"UsageObserved":return q1(e,s,i),e}const c=Ez(e,s,a),d=e.agents.get(i);d&&a>=(d.recoveryLiveAt??0)&&(d.recoveryLiveAt=a,d.restoredFromLog=void 0),C7(e,i),Tz(e,o,s,i)&&l7(e,i),c.provider||(c.provider=s.provider==="codex"?"codex":"claude"),c.provider==="codex"&&(c.childCount=[...e.agents.values()].filter(w=>w.parentId===c.id).length);const h=_3(s),f=El(s),p=f?aa(i,f):i;h&&c.id===p&&(c.model=h);const m=$z(o,s);switch(m!==void 0&&c.id===p&&(c.effort=m??void 0),(o==="PreToolUse"||o==="PostToolUse"||o==="PostToolUseFailure")&&f==null&&U1(e.agents.get(i),a),o){case"SessionStart":p7(e,s,i,a);break;case"UserPromptSubmit":m7(e,s,i,a);break;case"PreToolUse":d7(e,s,i,c,a);break;case"PostToolUse":case"PostToolUseFailure":h7(e,s,o,i,a);break;case"SubagentStart":L7(e,s,i,a);break;case"SubagentStop":I7(e,s,i,a);break;case"Stop":case"StopFailure":i0(e,o,i,a,{stopFailure:$7(s,a)});break;case"SessionEnd":i0(e,o,i,a);break;case"Notification":V7(e,s,i,a);break}return e}const J7="codex-auto-review",T3="chatgpt-auto-review-free",Q7={input:2,output:10,cacheRead:.2,cacheWrite:2.5,cacheWrite1h:4},e9=[{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:Q7},{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}}],t9=[{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 R3(e){return e?/^(?:gpt[-_]|codex[-_]|o\d)/i.test(e):!1}function vr(e,t=Date.now(),n=sa){if(!e)return null;if(e===J7&&n===T3)return{input:0,output:0,cacheRead:0,cacheWrite:0};if(n!==sa&&R3(e)){const i=/^gpt[-_]6(?:[-_.]1)?[-_](?:astra|sol|luna)\b(?![-_][A-Za-z])/i.test(e)?new Map([["fast",2],["flex",.5]]).get(n):void 0,c=i===void 0?null:vr(e,t);return c&&i!==void 0?{input:c.input*i,output:c.output*i,cacheRead:c.cacheRead*i,cacheWrite:c.cacheWrite*i}:null}const s=n9.get(n);if(!s)return null;const a=pr(e);for(const o of s)if(o.match.test(a))return typeof o.rates=="function"?o.rates(t):o.rates;return null}const sa="standard",n9=new Map([[sa,e9],["fast",t9]]);function Gc(e,t){return e*t/1e6}function A3(e,t){const n=Math.max(0,e.cacheCreate1hTokens??0),s=Math.max(0,e.cacheCreate5mTokens??0),a=Math.max(0,e.cacheCreateTokens-n-s),o=s+a,i=t.cacheWrite1h??t.cacheWrite;return{tokens5m:o,tokens1h:n,usd5m:Gc(o,t.cacheWrite),usd1h:Gc(n,i)}}function M3(e,t,n=Date.now()){if(!R3(t))return e.inputTokens;const s=vr(t,n),a=((s==null?void 0:s.cacheWrite)??0)>0?Math.max(0,e.cacheCreateTokens):0;return Math.max(0,e.inputTokens-e.cacheReadTokens-a)}function Jf(e,t,n=Date.now()){const s={input:0,output:0,cacheRead:0,cacheWrite:0,total:0};for(const a of Ou(e)){const o=fu(a.usage,t,a.speed,n);s.input+=o.input,s.output+=o.output,s.cacheRead+=o.cacheRead,s.cacheWrite+=o.cacheWrite,s.total+=o.total}return s}function fu(e,t,n,s=Date.now()){const a=vr(t,s,n);if(!a)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 $3(e,t)){const c=i.usage,d=L3(a,i.long);o.input+=Gc(M3(c,t,s),d.input),o.output+=Gc(c.outputTokens,d.output),o.cacheRead+=Gc(c.cacheReadTokens,d.cacheRead);const h=A3(c,d);o.cacheWrite+=h.usd5m+h.usd1h}return o.total=o.input+o.output+o.cacheRead+o.cacheWrite,o}function $3(e,t){if(!e.longContext||!/^claude[-_]haiku[-_]5[-_.]5\b(?![-_.]\d{1,7}(?!\d))/i.test(pr(t??"")))return[{usage:e,long:!1}];const n=e.longContext;return[{usage:W1(e,[n]),long:!1},{usage:n,long:!0}]}function L3(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 Ou(e){const t=e.bySpeed?Object.entries(e.bySpeed):[];return t.length===0?[{speed:sa,usage:e}]:[{speed:sa,usage:W1(e,t.map(([,n])=>n))},...t.map(([n,s])=>({speed:n,usage:s}))]}function W1(e,t){const n=o=>t.reduce((i,c)=>i+(o(c)??0),0),s=o=>Math.max(0,(o(e)??0)-n(o)),a={inputTokens:s(o=>o.inputTokens),outputTokens:s(o=>o.outputTokens),cacheReadTokens:s(o=>o.cacheReadTokens),cacheCreateTokens:s(o=>o.cacheCreateTokens)};return(e.cacheCreate1hTokens!==void 0||e.cacheCreate5mTokens!==void 0)&&(a.cacheCreate1hTokens=s(o=>o.cacheCreate1hTokens),a.cacheCreate5mTokens=s(o=>o.cacheCreate5mTokens)),e.reasoningOutputTokens!==void 0&&(a.reasoningOutputTokens=e.reasoningOutputTokens),e.longContext&&(a.longContext=W1(e.longContext,t.flatMap(o=>o.longContext?[o.longContext]:[]))),a}const ra="not priced";function Kc(e,t,n){const s=e.toFixed(t);return Number(s)<n?s:null}function et(e){if(e<=0)return"—";if(e<.005)return"<1¢";if(e<1){const t=Kc(e*100,e<.1?1:0,100);if(t!==null)return`${t}¢`}if(e<100){const t=Kc(e,2,100);if(t!==null)return`$${t}`}if(e<1e4){const t=Kc(e,0,1e4);if(t!==null)return`$${t}`}return`$${(e/1e3).toFixed(1)}k`}function H1(e,t){if(e<=0||t<10)return null;const n=e/t,s=n*60;return s>=.01?`${et(s)}/min`:`${et(n*3600)}/hr`}function l0(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 s={inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0};n.longContext=l0(e.longContext??s,t.longContext??s)}if(e.bySpeed||t.bySpeed){const s=new Map(Object.entries(e.bySpeed??{}));for(const[a,o]of Object.entries(t.bySpeed??{})){const i=s.get(a);s.set(a,i?l0(i,o):o)}n.bySpeed=Object.fromEntries(s)}return n}function s9(e,t){let n=0,s=0,a=0,o=0,i=0,c=0;for(const p of t)n+=p.inputTokens,s+=p.outputTokens,a+=p.cacheReadTokens,o+=p.cacheCreateTokens,i+=p.cacheCreate1hTokens??0,c+=p.cacheCreate5mTokens??0;const d=(p,m)=>Math.max(0,p-m),h={inputTokens:d(e.inputTokens,n),outputTokens:d(e.outputTokens,s),cacheReadTokens:d(e.cacheReadTokens,a),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 Tl(e){const t=e.usageByModel,n=t?Object.keys(t):[];if(!t||n.length===0)return[{model:e.model,usage:e.usage}];const s=n.map(o=>({model:o,usage:t[o]})),a=s9(e.usage,s.map(o=>o.usage));if(a){const o=s.findIndex(i=>i.model===e.model);o>=0?s[o]={model:s[o].model,usage:l0(s[o].usage,a)}:s.push({model:e.model,usage:a})}return s}function On(e,t=Date.now()){const n={input:0,output:0,cacheRead:0,cacheWrite:0,total:0};for(const s of Tl(e)){const a=Jf(s.usage,s.model,t);n.input+=a.input,n.output+=a.output,n.cacheRead+=a.cacheRead,n.cacheWrite+=a.cacheWrite,n.total+=a.total}return n}function c0(e,t=Date.now()){return Tl(e).every(n=>{const s=Ou(n.usage).filter(({usage:a})=>a.inputTokens+a.outputTokens+a.cacheReadTokens+a.cacheCreateTokens+(a.cacheCreate1hTokens??0)+(a.cacheCreate5mTokens??0)>0);return s.length>0?s.every(a=>vr(n.model,t,a.speed)!==null):vr(n.model,t)!==null})}function yl(e,t=Date.now()){let n=0;for(const s of Tl(e))for(const a of Ou(s.usage))vr(s.model,t,a.speed)==null&&(n+=a.usage.inputTokens+a.usage.outputTokens);return n}function I3(e){const t=[];for(const n of Tl(e)){if(!n.model||t.includes(n.model))continue;const s=n.usage;s.inputTokens+s.outputTokens+s.cacheReadTokens+s.cacheCreateTokens<=0||t.push(n.model)}return t}function z1(e){return I3(e).filter(t=>t!==e.model)}function FC(e,t){return(/^gpt[-_]/i.test(t??"")?`API-equivalent estimate. Recorded Codex settings do not confirm the served tier; tokens without tier evidence use standard rates.
|
|
67
|
+
`:"")+r9(e,t)}function r9(e,t){if(!e.bySpeed)return Vg(e,t,sa);const n=Ou(e).filter(s=>s.speed!==sa||O3(s.usage));return n.length===1?Vg(n[0].usage,t,n[0].speed):[...n.map(s=>Vg(s.usage,t,s.speed)),"═════════════════════════════════════════",`all speeds = ${et(Jf(e,t).total)}`].join(`
|
|
68
|
+
`)}function O3(e){return e.inputTokens+e.outputTokens+e.cacheReadTokens+e.cacheCreateTokens>0}function Vg(e,t,n){const s=$3(e,t).filter(a=>O3(a.usage));return e.longContext&&s.some(a=>a.long)?[...s.map(a=>BC(a.usage,t,n,a.long)),`all context tiers = ${et(fu(e,t,n).total)}`].join(`
|
|
69
|
+
`):BC(e,t,n,!1)}function BC(e,t,n,s){const a=vr(t,Date.now(),n),o=a?L3(a,s):null,i=s?" · prompt >100K":"",c=(n===T3?`model: ${t} · no charge for ChatGPT auto-review`:n===sa?`model: ${t}`:`model: ${t} · ${n}`)+i;if(!o)return`${c}
|
|
70
|
+
no published rate in this build — the tokens are counted, the dollars are not`;const d=v=>v.toLocaleString(),h=v=>`$${v}/MTok`,f=fu(s?{...e,longContext:e}:{...e,longContext:void 0},t,n),p=A3(e,o),m=p.tokens1h>0?[`cache w5m${d(p.tokens5m).padStart(14)} × ${h(o.cacheWrite).padEnd(11)} = ${et(p.usd5m)}`,`cache w1h${d(p.tokens1h).padStart(14)} × ${h(o.cacheWrite1h??o.cacheWrite).padEnd(11)} = ${et(p.usd1h)}`]:[`cache w ${d(p.tokens5m).padStart(14)} × ${h(o.cacheWrite).padEnd(11)} = ${et(p.usd5m)}`],w=M3(e,t),j=w===e.inputTokens?"input":"uncached";return[c,`${j.padEnd(9)}${d(w).padStart(14)} × ${h(o.input).padEnd(11)} = ${et(f.input)}`,`output ${d(e.outputTokens).padStart(14)} × ${h(o.output).padEnd(11)} = ${et(f.output)}`,`cache r ${d(e.cacheReadTokens).padStart(14)} × ${h(o.cacheRead).padEnd(11)} = ${et(f.cacheRead)}`,...m,"─────────────────────────────────────────",`total = ${et(f.total)}`].join(`
|
|
71
|
+
`)}function qC(e){const t=Tl(e),[n]=t;return t.length<=1?FC(n.usage,n.model):[...t.map(s=>FC(s.usage,s.model)),"═════════════════════════════════════════",`all models = ${et(On(e).total)}`].join(`
|
|
72
|
+
`)}function a9(e){if(!e.model)return null;const t=vr(e.model),n=On(e),s=yl(e);if(!t&&n.total<=0&&s>0)return e.usage.inputTokens+e.usage.outputTokens<=0?null:{kind:"unpriced",tt:qC(e)};if(n.total<=0)return null;const a=Math.max(0,((e.endedAt??Date.now())-e.startedAt)/1e3),o=e.state==="active"&&!e.synthetic?H1(n.total,a):null,i=qC(e)+(o?`
|
|
73
|
+
burn: ${o}`:"");return{kind:"spent",total:n.total,floor:s>0,tt:i}}const o9=new Set(["untrusted","on-request","on-failure"]);function i9(e){return typeof e!="string"||!e?null:o9.has(e)?!0:e==="never"?!1:null}function P3(e){if(e.provider!=="codex"||e.kind!=="root"||e.waiting||e.state!=="active")return null;const t=i9(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."}
|
|
74
|
+
|
|
75
|
+
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 UC(e){return e[0].toUpperCase()+e.slice(1).toLowerCase()}function Va(e){const t=pr(e).replace(/[-_]\d{8}(?!\d)/,""),n=t.match(/^claude[-_](opus|sonnet|haiku|fable|mythos)[-_](\d+(?:[-_.]\d+)*)/i);if(n){const a=UC(n[1]),o=n[2].replace(/[-_]/g,".");return`${a} ${o}`}const s=t.match(/^gpt[-_](\d+(?:[-_.]\d+)*)((?:[-_][A-Za-z0-9.]+)*)$/i);if(s){const a=s[1].replace(/[-_]/g,"."),o=s[2].split(/[-_]/).filter(Boolean).map(UC);return[`GPT-${a}`,...o].join(" ")}return e}function Qf(e){const t=pr(e??""),n=t.match(/^claude[-_](opus|sonnet|haiku|fable|mythos)[-_]/i);return n?n[1].toLowerCase():/^gpt[-_]/i.test(t)?"gpt":""}function ep(e,t){return t?`${Va(e)} · ${t}`:Va(e)}function pu(e,t){return t?`${e}
|
|
76
|
+
effort: ${t}`:e}function l9(e){return!e.model&&e.provider!=="codex"?0:e.model&&e.effort?2:1}function c9(e,t){return(t.overflowing||t.folderCut)&&e<t.max?e+1:e}function u9(e){return{kind:e<1,effort:e<2}}function Mn(e){return(e==null?void 0:e.kind)==="permission"||(e==null?void 0:e.kind)==="asked"}function u0(e){const t=[];for(const n of e)n.kind==="root"&&Mn(n.waiting)&&t.push({id:n.id,label:n.label,waiting:n.waiting});return t.sort((n,s)=>n.waiting.since-s.waiting.since)}function d9(e,t){if(e.length===0)return null;const n=e.findIndex(s=>s.id===t);return e[(n+1)%e.length]}function h9(e){const t=new Set;for(const n of e)n.state==="active"&&t.add(n.sessionId);return t.size}function tp(e,t){return`${e}@${t.since}`}function D3(e,t){if(!e.tool)return null;const{name:n,preview:s}=e.tool,a=new RegExp(`\\b${n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}\\b`,"i").test(t);return s?a?s:`${n} · ${s}`:a?null:n}function f9(e){const t=e.message||"Needs your permission",n=D3(e,t);return n?`${t}
|
|
77
|
+
Likely on: ${n}`:t}function p9(e,t,n,s=!0){if(!s)return[];if(n)return[];const a=[];for(const o of e){if(!Mn(o.waiting))continue;const i=tp(o.id,o.waiting);t.has(i)||a.push({key:i,title:o.label,body:f9(o.waiting),sessionId:o.id})}return a}function m9(e,t,n){const s=new Set;for(const o of e)s.add(tp(o.id,o.waiting));const a=new Set;for(const o of n)s.has(o)&&a.add(o);for(const o of t)a.add(o.key);return a}function uh(e){return new Set(e.map(t=>tp(t.id,t.waiting)))}function g9(e,t){return e!==t}function y9(e,t){return!e&&t!=null}function w9(e,t){return e!==null&&t!=null}function V1(e){switch(e){case"login":return"login expired";case"usage-limit":return"usage limit";default:return"API error"}}function F3(e){return`Stopped · ${V1(e.kind)}`}function B3(e){const t=V1(e.kind);return t.charAt(0).toUpperCase()+t.slice(1)}function G1(e,t=!1){if(t)switch(e){case"login":return"Press Continue once a working login is active.";case"usage-limit":return"Press Continue once the limit resets or another account is active.";default:return"Press Continue to run the turn again."}switch(e){case"login":return"Type “continue” in this session once a working login is active.";case"usage-limit":return"Type “continue” in this session once the limit resets or another account is active.";default:return"Type “continue” in this session to run the turn again."}}function x9(e){switch(e.kind){case"login":return"Claude Code stopped this turn: the login expired.";case"usage-limit":return"Claude Code stopped this turn: a usage limit was reached.";default:return`Claude Code stopped this turn on an API error (${e.error.replace(/_/g," ")}).`}}function v9(e){return e.message?`It said: “${e.message}”`:""}function b9(e,t=!1){return[x9(e),v9(e),G1(e.kind,t)].filter(Boolean).join(`
|
|
78
|
+
`)}function k9(e,t=!1){return`${B3(e)}. ${G1(e.kind,t)}`}function j9(e){return`Claude Code's StopFailure hook${e!=null&&e.message?`: “${e.message}”`:""}`}function N9(e,t=!1){const n=G1(e.kind,t).replace(/\.$/,"");return`stopped, ${V1(e.kind)} — ${n.charAt(0).toLowerCase()}${n.slice(1)}`}function np(e){return e.provider==="codex"&&e.parentId?"child session":e.kind==="root"?"session":"subagent"}function wl(e){return e==="active"?"live":e==="done"?"done":"err"}function xl(e){return e.message?e.message:e.kind==="permission"?"Needs your permission":"Waiting for your input"}function S9(e){return`${e} subagent${e===1?"":"s"} spawned`}function _9(e){const t=[np(e)];if(e.childCount>0&&t.push(`→ ${e.childCount}`),e.kind==="subagent"&&e.cwdBasename&&t.push(e.cwdBasename),e.model){const n=z1(e).length;t.push(`${Va(e.model)}${n>0?` +${n}`:""}`)}else e.provider==="codex"&&t.push("Codex");return t.join(" · ")}function C9(e,t=Date.now(),n=!1){const s=e.toolErrorCount??0,a=On(e,t).total;return[e.label,np(e),e.kind==="root"&&e.stopFailure?N9(e.stopFailure,e.job!=null):wl(e.state),Mn(e.waiting)?xl(e.waiting):null,e.model?Va(e.model):null,(()=>{const o=Lu(e.plan);return o?y3(o):null})(),`${e.toolCount} ${e.toolCount===1?"tool":"tools"}`,s>0?`${s} failed`:null,a>0?`${et(a)}${yl(e,t)>0?"+":""}`:null,n?"selected":null].filter(Boolean).join(", ")}function q3(e,t){const n=D3(e,t);return n?`Likely on: ${n}`:null}function af(e){return e.kind==="idle"?"Your turn":xl(e)}function xt(e){const t=Math.round(e);if(t<1e3)return`${t}`;if(t<1e6){const n=Kc(t/1e3,1,1e3);if(n!==null)return`${n}k`}if(t<1e9){const n=Kc(t/1e6,2,1e3);if(n!==null)return`${n}M`}return`${(t/1e9).toFixed(2)}B`}function vl(e,t,n){const s=(t??n)-e;if(s<1e3)return`${Math.max(0,s)}ms`;const a=Math.floor(s/1e3);if(a<60)return`${a}s`;const o=Math.floor(a/60);if(o>=100)return`${Math.floor(o/60)}h ${o%60}m`;const i=a%60;return`${o}m ${String(i).padStart(2,"0")}s`}function U3(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 sp(e,t){const n=typeof e=="string"?e.trim():"",s=typeof t=="string"?t.trim():"";return{face:n||s||void 0,tooltip:s||n||void 0}}const WC=2e5,E9=1e6,T9=[/\[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],R9=[{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 A9(e){if(!e)return WC;const t=pr(e);for(const n of T9)if(n.test(t))return E9;for(const n of R9)if(n.match.test(t))return n.window;return WC}function W3(e,t){return typeof e=="number"&&e>0?e:A9(t)}const M9=1;function $9(){const e=[];let t=0;function n(){let s;for(const a of e)(!s||a.layer>s.layer||a.layer===s.layer&&a.seq>s.seq)&&(s=a);return s}return{push(s,a=0,o="dialog"){const i={dismiss:s,layer:a,kind:o,seq:t++};return e.push(i),()=>{const c=e.indexOf(i);c!==-1&&e.splice(c,1)}},dismissTop(){const s=n();return s?(s.dismiss(),!0):!1},isTop(s){const a=n();return a!=null&&a.dismiss===s},depth(){return e.length},dialogDepth(){return e.filter(s=>s.kind==="dialog").length}}}const Tn=$9(),H3=e=>e==="Escape";function L9(e){return e.overlayOpen?"dismiss":e.typing?"blur":"clear-selection"}function HC(e){return String(e.tagName??"").toUpperCase()==="BODY"}function zC(e,t){return!e||!e.isConnected||HC(e)?!1:t==null||HC(t)}const of="a[href], button, input, select, textarea, summary, [tabindex]";function z3(e){return!e||e.disabled||e.rendered===!1?!1:(e.tabIndex??0)>=0}function I9(e){if(!e||!e.overflowing||e.hasFocusable)return!1;const t=String(e.overflow??"").toLowerCase();return t==="auto"||t==="scroll"}function O9({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 rp(e){return e.ctrlKey||e.metaKey||e.altKey}function P9(e){e.key!=="Escape"&&e.key!=="Tab"&&e.stopPropagation()}const D9=new Set(["button","checkbox","color","file","image","radio","range","reset","submit"]),F9=new Set(["INPUT","TEXTAREA","SELECT","OPTION","BUTTON","SUMMARY","A"]),B9=new Set(["button","checkbox","combobox","link","listbox","menu","menubar","menuitem","menuitemcheckbox","menuitemradio","option","radio","searchbox","slider","spinbutton","switch","tab","textbox","treeitem"]);function K1(e){return typeof e.tagName=="string"?e.tagName.toUpperCase():""}function q9(e){return K1(e)==="BUTTON"?!0:(typeof e.role=="string"?e.role.trim().toLowerCase():"").split(/\s+/).includes("button")}function Bo(e){if(!e)return!1;if(e.isContentEditable)return!0;const t=K1(e);return t==="TEXTAREA"?!0:t!=="INPUT"?!1:!D9.has(String(e.type??"text").toLowerCase())}function U9(e,t){if(!e)return!1;if(Bo(e))return!0;if(t!=null&&(t.length===1||t==="Delete")&&t!==" "&&e.pointerFocused&&q9(e))return!1;if(F9.has(K1(e)))return!0;const n=typeof e.role=="string"?e.role.trim().toLowerCase():"";return n!==""&&n.split(/\s+/).some(s=>B9.has(s))}function W9({key:e,modalOpen:t,sheetOpen:n}){return t?!(e==="?"&&n):!1}function H9({key:e,sheetOpen:t,target:n}){return t&&e==="?"&&!Bo(n)}function Oh({appModal:e,dialogDepth:t}){return e||t>0}function V3(e){return e?Array.from(e.querySelectorAll("*")).filter(t=>{if(t.matches(of))return z3({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)&&I9({overflowing:n,overflow:getComputedStyle(t).overflowY,hasFocusable:t.querySelector(of)!=null}):!1}):[]}function z9(e,t){const n=V3(e);if(!t||!e.contains(t)||n.includes(t))return n;const s=n.findIndex(a=>(t.compareDocumentPosition(a)&Node.DOCUMENT_POSITION_FOLLOWING)!==0);return s===-1?[...n,t]:[...n.slice(0,s),t,...n.slice(s)]}function mt(e,t={}){const{focusRef:n,restoreFocusFallback:s,layer:a,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(()=>Tn.push(f,a,i),[f,a,i]),y.useEffect(()=>{var m;const p=document.activeElement;return(m=(n==null?void 0:n.current)??V3(c.current)[0])==null||m.focus(),()=>{if(zC(p,document.activeElement)&&p.focus(),s&&document.activeElement===document.body){const w=s();zC(w,document.activeElement)&&w.focus()}}},[]),y.useEffect(()=>{const p=m=>{var N;if(m.key!=="Tab"||rp(m))return;const w=c.current;if(!w)return;const j=document.activeElement;if(!(j!=null&&w.contains(j))&&!Tn.isTop(f))return;const b=z9(w,j),k=O9({count:b.length,index:j?b.indexOf(j):-1,shiftKey:m.shiftKey});k.kind!=="allow"&&(m.preventDefault(),k.kind==="focus"&&((N=b[k.index])==null||N.focus()))};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[f]),c}function yt(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 s=t.current&&n.target===n.currentTarget;t.current=!1,s&&e()}}}function V9(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 ds(e){return e.toLocaleString()}const G9=60;function K9(e,t=G9){if(e.length<=t)return e;const n=e.slice(e.length-(t-1)),s=n.search(/[/\\]/);return"…"+(s===-1?n:n.slice(s))}function Y9({agent:e,onClose:t}){var w;const n=y.useRef(null),s=mt(t,{focusRef:n}),a=yt(t),o=e.context,i=e.usage,c=(o==null?void 0:o.currentContextTokens)??0,d=W3(e.contextWindow,e.model),h=Math.min(100,c/d*100),f=On(e),p=e.provider==="codex"?i.inputTokens+i.outputTokens:i.inputTokens+i.outputTokens+i.cacheReadTokens+i.cacheCreateTokens,m=V9(e.provider);return r.jsx("div",{className:"modal-backdrop",...a,role:"presentation",children:r.jsxs("div",{ref:s,className:"modal ctx-modal",onClick:j=>j.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Context breakdown",children:[r.jsxs("header",{className:"ctx-modal-head",children:[r.jsxs("div",{children:[r.jsxs("div",{className:"ctx-modal-title",children:["Context · ",e.label]}),r.jsx("div",{className:"ctx-modal-sub",children:m.subtitle})]}),r.jsx("button",{type:"button",ref:n,className:"glyph-btn ctx-modal-close",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]}),r.jsxs("section",{className:"ctx-window-row",children:[r.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:r.jsx("div",{className:"ctx-window-fill",style:{transform:`scaleX(${Math.min(100,Math.max(0,h))/100})`}})}),r.jsxs("div",{className:"ctx-window-meta",children:[r.jsxs("span",{className:"ctx-window-pct",children:[h.toFixed(1),"%"]}),r.jsxs("span",{children:[ds(c)," / ",ds(d)," tok (",m.windowScope,")"]})]})]}),r.jsx("h3",{className:"ctx-section-title",children:"Cumulative usage · whole session"}),r.jsxs("div",{className:"ctx-grid",children:[r.jsx(Ps,{label:"input tokens",val:ds(i.inputTokens)}),r.jsx(Ps,{label:"output tokens",val:ds(i.outputTokens)}),r.jsx(Ps,{label:"cache reads",val:ds(i.cacheReadTokens)}),r.jsx(Ps,{label:"cache writes",val:ds(i.cacheCreateTokens)}),r.jsx(Ps,{label:"cumulative total",val:ds(p)}),r.jsx(Ps,{label:"estimated cost",val:et(f.total),accent:!0})]}),r.jsx("h3",{className:"ctx-section-title",children:"Transcript composition"}),m.compositionCounted?r.jsxs("div",{className:"ctx-grid",children:[r.jsx(Ps,{label:"user messages",val:ds((o==null?void 0:o.msgsUser)??0)}),r.jsx(Ps,{label:"assistant messages",val:ds((o==null?void 0:o.msgsAssistant)??0)}),r.jsx(Ps,{label:"tool uses",val:ds((o==null?void 0:o.toolUses)??0)}),r.jsx(Ps,{label:"tool results",val:ds((o==null?void 0:o.toolResults)??0)}),r.jsx(Ps,{label:"system-reminders",val:ds((o==null?void 0:o.systemReminders)??0)})]}):r.jsx("div",{className:"ctx-empty",children:m.compositionUncounted}),r.jsx("h3",{className:"ctx-section-title",children:m.memoryHeading}),(((w=o==null?void 0:o.memoryFiles)==null?void 0:w.length)??0)===0?r.jsx("div",{className:"ctx-empty",children:m.memoryEmpty}):r.jsx("ul",{className:"ctx-md-list",children:o.memoryFiles.map(j=>r.jsxs("li",{children:[r.jsx("span",{className:"ctx-md-path",title:j.path,children:K9(j.path)}),r.jsx("span",{className:"ctx-md-size",children:Yr(j.bytes)})]},j.path))})]})})}function Ps({label:e,val:t,accent:n}){return r.jsxs("div",{className:`ctx-row${n?" accent":""}`,children:[r.jsx("span",{className:"ctx-row-label",children:e}),r.jsx("span",{className:"ctx-row-val",children:t})]})}function X9({currentContextTokens:e,modelId:t,contextWindow:n,size:s=26,onClick:a}){const o=W3(n,t),i=Math.min(1,e/o),c=s/2-3,d=s/2,h=2*Math.PI*c,f=h*i,p=i>.9?"var(--err)":i>.7?"var(--warn)":"var(--accent)";return r.jsx("button",{type:"button",className:"ctx-donut",onClick:m=>{m.stopPropagation(),a==null||a()},title:`context: ${e.toLocaleString()} / ${o.toLocaleString()} (${(i*100).toFixed(1)}%)`,"aria-label":`Context ${Math.round(i*100)}% of ${o.toLocaleString()} tokens — show breakdown`,children:r.jsxs("svg",{width:s,height:s,viewBox:`0 0 ${s} ${s}`,"aria-hidden":"true",children:[r.jsx("circle",{cx:d,cy:d,r:c,stroke:"var(--line)",strokeWidth:"2.5",fill:"none"}),r.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)"}}),r.jsx("text",{x:d,y:d+3,textAnchor:"middle",fontSize:"8",fill:"var(--text)",fontWeight:"600",children:Math.round(i*100)})]})})}const VC=new Map;function G3(e){let t=VC.get(e);return t||(t={now:Date.now(),listeners:new Set,timer:null},VC.set(e,t)),t}function Z9(e,t){const n=G3(e);return n.listeners.add(t),n.timer===null&&(n.now=Date.now(),n.timer=setInterval(()=>{n.now=Date.now();for(const s of n.listeners)s()},e)),()=>{n.listeners.delete(t),n.listeners.size===0&&n.timer!==null&&(clearInterval(n.timer),n.timer=null)}}function J9(e){return G3(e).now}const GC=new Map,KC=new Map;function jr(e=1e3){let t=GC.get(e);t||(t=s=>Z9(e,s),GC.set(e,t));let n=KC.get(e);return n||(n=()=>J9(e),KC.set(e,n)),y.useSyncExternalStore(t,n,n)}function Q9(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 eV="1",YC="agent-dag.schema",tV=["agent-dag.layout","agent-dag.viewport"];function Ze(e){if(typeof window>"u")return null;try{return window.localStorage.getItem(e)}catch{return null}}function Xe(e,t){if(!(typeof window>"u"))try{window.localStorage.setItem(e,t)}catch{}}function wr(e){if(!(typeof window>"u"))try{window.localStorage.removeItem(e)}catch{}}function mr(){if(typeof window>"u")return null;try{return window.localStorage}catch{return null}}function nV(e,t=eV){let n=null;try{n=e.getItem(YC)}catch{return[]}if(n===t)return[];const s=[];if(n!==null)for(const a of tV)try{e.getItem(a)!==null&&(e.removeItem(a),s.push(a))}catch{}try{e.setItem(YC,t)}catch{}return s}const K3="agent-dag.recapsDismissed",XC=200;function sV(){const e=Ze(K3);if(!e)return[];try{const t=JSON.parse(e);return Array.isArray(t)?t.filter(n=>typeof n=="string"):[]}catch{return[]}}let bl=new Set(sV());const d0=new Set;let Y3=0;function X3(e){return d0.add(e),()=>{d0.delete(e)}}function Z3(e){bl=e,Y3++;const t=Array.from(e);Xe(K3,JSON.stringify(t.length>XC?t.slice(-XC):t));for(const n of d0)n()}function rV(e,t){return`${e}@${t}`}function aV(e){return bl.has(e)}function oV(e){if(bl.has(e))return;const t=new Set(bl);t.add(e),Z3(t)}function iV(e){const t=new Set(bl);t.delete(e)||t.add(e),Z3(t)}function lV(e){return y.useSyncExternalStore(X3,()=>e!=null&&bl.has(e),()=>!1)}function Y1(e){return`recap:${e}`}function cV(e){return e.startsWith("recap:")}function uV(){return y.useSyncExternalStore(X3,()=>Y3,()=>0)}function Ha(e){switch(e){case"recap":return"recap";case"needs":return"needs you";case"done":return"done";case"failed":return"failed";case"stopped":return"stopped";case"last":return"last";default:return"now"}}function dV(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 s={kind:t,text:n,at:e.updatedAt,source:"job"};return t==="needs"&&e.suggestedReply&&(s.reply=e.suggestedReply),s}function hV(e){let t=null;for(const n of e.prompts)(!t||n.at>t.at)&&(t=n);return t}const ZC=160;function fV(e){const t=Xf(e);if(t)return t.detail?`${t.label}: ${t.detail}`:t.label;const s=(e.split(`
|
|
79
|
+
`).map(a=>a.trim()).find(Boolean)??"").replace(/\s+/g," ");return s.length>ZC?s.slice(0,ZC-1).trimEnd()+"…":s}function pV(e){const t=e.stopFailure;if(t)return{kind:"stopped",text:k9(t,e.job!=null),at:t.at,source:"stop",stop:t,key:`${e.sessionId}@stopped:${t.at}`};const n=hV(e),s=(n==null?void 0:n.at)??e.startedAt,a=c=>({...c,key:`${e.sessionId}@${c.kind==="last"?"now":c.kind}:${s}`}),o=e.job?dV(e.job):null;if(o)return a(o);const i=e.activity;if(i&&(!n||n.at<=i.at))return a({kind:e.state==="active"?"now":"last",text:i.text,at:i.at,source:"activity"});if(n&&e.state==="active"){const c=fV(n.text);if(c){const d={kind:"now",text:c,at:n.at,source:"prompt"};return e.provider==="codex"&&(d.codex=!0),a(d)}}return null}function ap(e){if(e.kind!=="root"||e.closedAt!=null)return null;const t=pV(e);if((t==null?void 0:t.kind)==="stopped")return t;const n=Q9(e),s=n?{kind:"recap",text:n.text,at:n.at,source:"recap",key:rV(e.sessionId,n.at)}:null;return t&&s?s.at>t.at?s:t:t??s}function op(e){switch(e.source){case"recap":return"Claude Code's recap";case"job":return"Claude Code's own line for this background session";case"stop":return j9(e.stop);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 mV(e){const t=new Map,n=[...e],s=Zf(n);for(const a of n){if(a.kind!=="subagent"&&!(a.provider==="codex"&&a.parentId)||a.exitAt!=null)continue;const o=s.get(a.id)??a.sessionId;if(a.provider==="codex"&&o===a.sessionId)continue;let i=t.get(o);i||(i={total:0,live:0,done:0,err:0,failed:0},t.set(o,i)),i.total+=1,a.state==="active"?i.live+=1:a.state==="err"?i.err+=1:i.done+=1,i.failed+=a.toolErrorCount??0}return t}function J3(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 Q3(e){return e.live>0?`→ ${e.total} · ${e.live} live`:`→ ${e.total} · done`}function gV(e,t,n){const s=e.kind==="root"?e.waiting:null;if(s&&Mn(s))return{tone:"warn",long:n.sayWaiting(s),short:s.kind==="permission"?"Needs you":"Asked you"};const a=e.kind==="root"?e.stopFailure:null;if(a)return{tone:"err",long:F3(a),short:B3(a)};if(s&&s.kind==="idle"){const i=n.sayWaiting(s);return{tone:"idle",long:i,short:i}}const o=e.toolErrorCount??0;if(o>0)return{tone:"err",long:`${o} tool ${o===1?"call":"calls"} failed`,short:`${o} failed`};if(t&&t.total>0)return{tone:"muted",long:J3(t),short:Q3(t)};if(e.state==="active"){const i=Lu(e.plan);if(i&&i.current&&!i.allDone)return{tone:"muted",long:a7(i),short:`${i.done}/${i.total} done`}}if(e.state==="active")for(let i=e.tools.length-1;i>=0;i--){const c=e.tools[i];if(c.endedAt!=null)continue;const{name:d,subject:h}=n.describeCall(c);return{tone:"muted",long:h?`${d} · ${h}`:d,short:d}}return null}function yV(e,t){return t?t.includes(e)?t:`${e}
|
|
80
|
+
${t}`:e}function il(e){return e.kind==="root"&&e.stopFailure&&e.state==="done"?"err":e.state}function h0(e){return e==="active"?"live":e==="done"?"done":"err"}const ip={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"}},wV=Object.fromEntries(Object.entries(ip).map(([e,t])=>[e,t.category])),xV=Object.fromEntries(Object.entries(ip).map(([e,t])=>[e,t.emoji])),vV=Object.fromEntries(Object.entries(ip).map(([e,t])=>[e,t.label])),bV=new Set(Object.entries(ip).filter(([,e])=>e.shell).map(([e])=>e)),kV={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",...wV};function eP(e){return e.startsWith("mcp__")?"mcp":Kt(kV,e)??"other"}const jV=/\btools\.exec_command\s*\(\s*\{[^{}]*?\bcmd\s*:\s*(["'`])((?:\\.|(?!\1)[^\\])*)\1/,NV=/\btools\.([A-Za-z_$][\w$]*)\s*\(/;function SV(e){if(typeof e!="string"||!e)return null;const t=jV.exec(e);if(t){const s=_V(t[2]);if(s.trim())return s}const n=NV.exec(e);return n?n[1]:null}function _V(e){return e.replace(/\\(["'`\\nrt])/g,(t,n)=>n==="n"?`
|
|
81
|
+
`:n==="r"?"\r":n==="t"?" ":n)}const CV={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:"📡",...xV};function JC(e){return e.startsWith("mcp__")?"🔌":Kt(CV,e)??"✨"}const EV={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 tP(e){return/^-(?:Command|c)$/i.test(e)||/^-[a-z]+c$/.test(e)}function nP(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=>tP(o)||/^-(?:NoProfile|NonInteractive)$/i.test(o)))return nP(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 s=t.match(/^([^\s|;&<>(]+)/);if(!s)return null;let a=s[1];return/^[A-Za-z0-9_][\w.+-]*$/.test(a.replace(/^.*[/\\]/,""))?(a=a.replace(/^.*[/\\]/,""),a=a.replace(/\.(exe|cmd|bat|ps1)$/i,""),a||null):null}function TV(e){if(typeof e=="string")return e;if(!e||typeof e!="object")return null;const t=e;if(typeof t.script=="string"){const n=SV(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 s=n.findIndex(tP);if(s>=0&&s+1<n.length)return n[s+1]}return n.join(" ")}return typeof t.script=="string"?t.script:null}const RV=new Set(["Bash","PowerShell",...bV]);function AV(e,t){if(!RV.has(e))return null;const n=TV(t);if(!n)return null;const s=nP(n);return s?{emoji:Kt(EV,s)??"⚙️",label:s,category:"shell",detail:n}:null}const MV=new Set(["Read","Write","Edit","MultiEdit","NotebookEdit","LS","Glob","apply_patch"]),$V={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:"🗄️"},LV={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 IV(e){const n=e.replace(/\\/g,"/").replace(/\/+$/,""),s=n.lastIndexOf("/");return s>=0?n.slice(s+1):n}function OV(e){const t=e.toLowerCase(),n=Kt(LV,t);if(n!==void 0)return n;if(t.startsWith("dockerfile."))return"🐳";if(/\.(test|spec)\.[a-z]+$/.test(t))return"🧪";const s=t.lastIndexOf(".");if(s>0&&s<t.length-1){const a=Kt($V,t.slice(s+1));if(a!==void 0)return a}return"📄"}function PV(e,t){if(!t||typeof t!="object")return null;const n=t;if(e==="apply_patch"&&typeof n.patch=="string"){const s=n.patch.match(/^\*\*\* (?:Update|Add|Delete) File: (.+)$/m);return s?s[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 DV(e,t){if(!MV.has(e))return null;const n=PV(e,t);if(!n)return null;const s=IV(n);return s?{emoji:e==="LS"?"📂":OV(s),label:s,category:"file",detail:n}:null}const FV={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 X1(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 BV(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 sP(e){return Kt(FV,e.toLowerCase())}function qV(e,t){const n=X1(e);if(!n)return null;const{server:s,method:a}=n;if(!a)return null;const o=sP(s);return{emoji:(o==null?void 0:o.emoji)??"🔌",label:a,category:"mcp",detail:o?`${o.name} · ${a}`:`${s} · ${a}`}}function rP(e,t){return AV(e,t)??DV(e,t)??qV(e)}function UV(e,t){var n;return((n=rP(e,t))==null?void 0:n.label)??null}const WV=vV,QC=18;function dh(e){const t=[...e];return t.length<=QC?e:t.slice(0,QC-1).join("")+"…"}const Gg=13,HV=6;function zV(e,t){const n=[...e];if(n.length<=Gg)return e;const s=n.lastIndexOf("."),a=s>0?n.slice(s):[];return t==="file"&&a.length>1&&a.length<=HV?n.slice(0,Gg-1-a.length).join("")+"…"+a.join(""):n.slice(0,Gg-1).join("")+"…"}function Z1(e){const t=X1(e);if(t){const s=sP(t.server);return s?{emoji:s.emoji,label:dh(s.name)}:{emoji:"🔌",label:dh(t.server),hue:BV(t.server)}}const n=Kt(WV,e)??"";return n?{emoji:JC(e),label:dh(n)}:{emoji:JC(e),label:dh(e)}}function VV(e){let t=null,n="";for(const s of e){const a=X1(s);if(a){if(!a.server)return null;if(t===null)t=a.server,n=s;else if(a.server!==t)return null}}return t===null?null:Z1(n)}const f0=6e4,ll=24,eE=f0/ll,Kg=132,Ph=14;function GV(e,t,n){const s=new Array(ll).fill(0);let a=0;const o=m=>{const w=n-m;if(w<0||w>=f0)return;const j=ll-1-Math.floor(w/eE);j>=0&&j<ll&&(s[j]+=1,a+=1)};for(const m of e)o(m.startedAt);for(const m of t??[])o(m);const c=Math.max(0,...s)/(eE/1e3),d=e.filter(m=>n-m.startedAt>=0&&n-m.startedAt<f0).length,h=a-d,f=[d>0?`${d} tool ${d===1?"call":"calls"}`:"",h>0?`${h} ${h===1?"block":"blocks"} of thinking and writing`:""].filter(Boolean),p=a===0?"nothing in the last 60s":`${f.join(" · ")} in last 60s · peak ${c.toFixed(1)}/s`;return{counts:s,title:p}}const KV=2;function YV(e){return e===0?1.5:Math.max(1.5,Math.min(1,e/KV)*Ph)}function aP({kind:e}){return r.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"&&r.jsx("circle",{cx:"5",cy:"5",r:"3.2",fill:"currentColor"}),e==="done"&&r.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"&&r.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 J1(){return r.jsxs("svg",{className:"alert-mark",viewBox:"0 0 12 12",width:"12",height:"12","aria-hidden":"true",focusable:"false",children:[r.jsx("path",{d:"M6 1.4l4.7 8.3H1.3z",stroke:"currentColor",strokeWidth:"1.3",strokeLinejoin:"round",fill:"none"}),r.jsx("path",{d:"M6 4.6v2.4",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round"}),r.jsx("circle",{cx:"6",cy:"8.35",r:"0.72",fill:"currentColor"})]})}function oP(){return r.jsxs("svg",{className:"recap-glyph",viewBox:"0 0 12 12",width:"10",height:"10","aria-hidden":"true",focusable:"false",children:[r.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"}),r.jsx("circle",{cx:"6",cy:"1.2",r:"1.05",fill:"currentColor"}),r.jsx("circle",{cx:"6",cy:"10.8",r:"1.05",fill:"currentColor"}),r.jsx("circle",{cx:"1.2",cy:"6",r:"1.05",fill:"currentColor"}),r.jsx("circle",{cx:"10.8",cy:"6",r:"1.05",fill:"currentColor"})]})}function lf({recap:e}){return e?r.jsx(oP,{}):r.jsx("svg",{className:"recap-glyph note-glyph",viewBox:"0 0 12 12",width:"10",height:"10","aria-hidden":"true",focusable:"false",children:r.jsx("circle",{cx:"6",cy:"6",r:"3",fill:"currentColor"})})}async function eo(e,t=500){var s;if(!e)return!1;let n=!1;try{n=await Promise.race([((s=navigator.clipboard)==null?void 0:s.writeText(e).then(()=>!0))??Promise.resolve(!1),new Promise(a=>window.setTimeout(()=>a(!1),t))])}catch{n=!1}if(n)return!0;try{const a=document.createElement("textarea");a.value=e,a.setAttribute("readonly",""),a.style.cssText="position:fixed;top:0;left:0;opacity:0",document.body.appendChild(a),a.select(),n=document.execCommand("copy"),a.remove()}catch{n=!1}return n}function Ga(e,t){return{disabled:e!=null&&e!==t,busy:e===t}}function lp(e){return e==null}const p0="self";function $n(e,t=!1){const n=Ga(e?p0:null,p0);return{disabled:t||n.disabled,"aria-busy":n.busy}}function xn(e){return lp(e?p0:null)}const kl=400;function jl({armedFor:e,target:t,armedAt:n,now:s,gapMs:a}){return e!==t?"arm":s-n<a?"ignore":"fire"}function iP(e){return[...e==null?[]:[`#ap-more-${e}`],".accounts-panel .ap-refresh"]}function Yn(e){return e==null||e==="BODY"||e==="HTML"}const lP="Continue from where you left off.";function XV(e,t){return!e||typeof e!="object"?{ready:!1,reason:"no-login"}:e.kind!=="login"&&e.kind!=="usage-limit"?{ready:!0,reason:null}:!t||!t.ok?{ready:!1,reason:"no-login"}:t.at>e.at?t.room===!1?{ready:!1,reason:"no-room"}:{ready:!0,reason:null}:{ready:!1,reason:"before-stop"}}function cP(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 cf(e){return cP(Math.floor(e/1e3))}function Pu(e,t){const n=e-t;if(n<=0)return null;const s=Math.floor(n/86400),a=Math.floor(n%86400/3600),o=Math.floor(n%3600/60);return s>0?`${s}d ${a}h`:a>0?`${a}h ${o}m`:`${o}m`}function ZV(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function uf(e,t,n){const s=new Date(e),a=cf(t-e);return{label:ZV(s,new Date(t))?a:`${a} · ${s.toLocaleDateString(n,{month:"short",day:"numeric"})}`,title:s.toLocaleString(n,{dateStyle:"medium",timeStyle:"medium"})}}function Q1(e){switch(e){case"before-stop":return"Not yet: nothing shows a working login since it stopped. The active account's next usage reading will.";case"no-room":return"Not yet: the active account has no room left in its 5-hour or 7-day window.";case"no-login":return"Not yet: the active account's usage could not be read, so there is no sign of a working login.";default:return""}}function JV(e,t="",n=!1){const s=t?`: ${t.replace(/[.\s]+$/,"")}`:"";switch(e){case"interactive":return"This session runs in a terminal, so ccdeck can't continue it. Type “continue” there.";case"not_listed":return"Claude Code doesn't list it as a background session any more, so nothing was sent.";case"working":return"It's working again already, so nothing was sent.";case"waiting":return"It's waiting on a prompt or a dialog. Answer it in agent view or with claude attach.";case"not_held":return"Claude Code doesn't show it as held up, so it wasn't continued automatically.";case"no_dir":return"Its folder is gone, so it can't be resumed there.";case"unreadable":return"claude agents --json printed something ccdeck couldn't read, so nothing was sent.";case"cli_failed":return`claude agents --json failed${s}. Nothing was sent.`;case"stop_failed":return`claude stop failed${s}. Nothing was sent.`;case"still_running":return"Claude Code still lists its process as running after claude stop, so nothing was sent.";case"resume_failed":return n?`ccdeck stopped it, then claude --resume --bg failed${s}. The conversation is kept: open it from agent view.`:`claude --resume --bg failed${s}.`;case"busy":return"A continue is already running for it.";case"not_ready":return t||"Not yet: there is no sign of a working login since it stopped.";case"unreachable":return"ccdeck's server could not be reached.";default:return"ccdeck refused the request."}}function ej(e,t){const n=cf(t-e.at);return e.ok?`${e.outcome==="copied"?"Continued as a copy":"Continued"}${e.auto?" automatically":""} ${n}`:`${e.auto?"Automatic continue failed":"Continue failed"} ${n}`}function df(e){if(!e.ok)return JV(e.reason,e.detail,e.stopped);const t=e.auto?"ccdeck continued it automatically once a working login was active":"Continued from ccdeck",n=e.outcome==="copied"?`
|
|
82
|
+
Claude Code started a copy instead of continuing it in place${e.detail?`: “${e.detail}”`:"."}`:"";return`${t}. It sent: “${lP}”${n}`}function uP({auto:e,kind:t,held:n,tried:s}){return!e||t!=="login"&&t!=="usage-limit"?"":n?"Not continued automatically: it stopped again after the last automatic continue. Press Continue to try again.":s?"":"Continues automatically once a working login with room is active."}function QV(e){return`This session runs in a terminal, and ccdeck can't type into it. Type “continue” there${e==="login"?" once a working login is active":e==="usage-limit"?" once the limit resets or another account is active":""}.`}function eG(e,t){return[`claude stop ${e}`,`claude --resume ${t} --bg "${lP}"`].join(`
|
|
83
|
+
`)}let za={answer:null,pressing:new Set,pressed:{}};const Yg={current:new Set},m0=new Set;function g0(e){za={...za,...e};for(const t of m0)t()}const tG=e=>(m0.add(e),()=>{m0.delete(e)}),tE=()=>za;function tj(){return y.useSyncExternalStore(tG,tE,tE)}const nG=new Set(["login","usage-limit","api-error"]),nj=e=>typeof e=="number"&&Number.isFinite(e)?e:null,dP=e=>typeof e=="string"?e:"";function sG(e){if(!e||typeof e!="object")return null;const t=e,n=nj(t.at);return n==null?null:{at:n,auto:t.auto===!0,ok:t.ok===!0,outcome:t.outcome==="continued"||t.outcome==="copied"?t.outcome:null,reason:typeof t.reason=="string"?t.reason:null,detail:dP(t.detail),stopped:t.stopped===!0}}function rG(e){if(!e||typeof e!="object")return null;const t=e;return{ok:t.ok===!0,at:nj(t.at)??0,room:typeof t.room=="boolean"?t.room:null}}function aG(e,t){if(!e||typeof e!="object"||e.ok!==!0)return null;const n=e,s={},a=n.sessions&&typeof n.sessions=="object"?n.sessions:{};for(const[o,i]of Object.entries(a)){if(!i||typeof i!="object")continue;const c=i,d=c.stop,h=d&&nG.has(d.kind)&&nj(d.at)!=null?{kind:d.kind,at:d.at}:null;s[o]={stop:h,held:c.held===!0,tried:c.tried===!0,last:sG(c.last)}}return{auto:n.auto===!0,login:t?rG(n.login):null,withLogin:t,sessions:s}}async function Dh(e=!0){var t,n;try{const s=await fetch(`/api/stop-continue${e?"?login=1":""}`,{signal:AbortSignal.timeout(2e4)});if(!s.ok)return;const a=aG(await s.json(),e);if(!a)return;const o=e?a.login:((t=za.answer)==null?void 0:t.login)??null;g0({answer:{...a,login:o,withLogin:e||(((n=za.answer)==null?void 0:n.withLogin)??!1)}})}catch{}}async function oG(e,t){if(!xn(Yg.current.has(e)))return null;Yg.current.add(e),g0({pressing:new Set([...za.pressing,e])});let n;try{const a=await fetch("/api/stop-continue",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({sessionId:e,stop:{kind:t.kind,at:t.at}})}),o=await a.json().catch(()=>null),i=typeof(o==null?void 0:o.reason)=="string"?o.reason:a.ok?null:a.status===401||a.status===403?"refused":"failed";n={at:Date.now(),auto:!1,ok:(o==null?void 0:o.ok)===!0,outcome:(o==null?void 0:o.outcome)==="copied"?"copied":(o==null?void 0:o.ok)===!0?"continued":null,reason:i,detail:i==="not_ready"?Q1((o==null?void 0:o.gate)??null):dP(o==null?void 0:o.detail),stopped:(o==null?void 0:o.stopped)===!0}}catch{n={at:Date.now(),auto:!1,ok:!1,outcome:null,reason:"unreachable",detail:"",stopped:!1}}Yg.current.delete(e);const s=new Set(za.pressing);return s.delete(e),g0({pressing:s,pressed:{...za.pressed,[e]:n}}),Dh(!0),n}const hP=30*6e4;function sj(e,t){var c,d,h,f,p;if(e.kind!=="root"||e.provider==="codex")return null;const n=((c=t.answer)==null?void 0:c.sessions[e.sessionId])??null,s=t.pressed[e.sessionId]??null,a=[(n==null?void 0:n.last)??null,s].filter(m=>m!=null).sort((m,w)=>w.at-m.at)[0]??null,o=e.stopFailure??null;if(!o&&!a)return null;const i=(n==null?void 0:n.stop)!=null&&o!=null&&n.stop.at===o.at;return{stop:o,background:e.job!=null,jobId:((d=e.job)==null?void 0:d.id)||null,loaded:((h=t.answer)==null?void 0:h.withLogin)===!0,gate:XV(o,((f=t.answer)==null?void 0:f.login)??null),pressing:t.pressing.has(e.sessionId),auto:((p=t.answer)==null?void 0:p.auto)===!0,held:i&&n.held,tried:i&&n.tried,last:a}}const iG=15e3,lG=2*6e4;function cG(e){for(const t of e.agents.values())if(t.kind==="root"&&t.stopFailure)return!0;return!1}function uG({stateRef:e,now:t,enabled:n}){const s=y.useRef(0);n&&cG(e.current)&&(s.current=t);const a=n&&s.current>0&&t-s.current<lG;y.useEffect(()=>{n&&Dh(!1)},[n]),y.useEffect(()=>{if(!a)return;Dh(!0);const o=window.setInterval(()=>{Dh(!0)},iG);return()=>window.clearInterval(o)},[a])}function fP(e,t){return[e.pressing?"Continuing…":e.loaded?e.gate.ready?"Run the turn that failed again, in place, through Claude Code's background commands.":Q1(e.gate.reason):"Checking for a working login…",e.stop?uP({auto:e.auto,kind:e.stop.kind,held:e.held,tried:e.tried}):"",e.last&&e.stop&&e.last.at>=e.stop.at?`${ej(e.last,t)}. ${df(e.last)}`:""].filter(Boolean).join(`
|
|
84
|
+
`)}function pP(e,t){return y.useCallback(()=>{!(e!=null&&e.stop)||!e.gate.ready||e.pressing||oG(t,e.stop)},[e,t])}function dG({data:e}){const t=tj(),n=jr(15e3),s=sj(e,t),a=pP(s,e.sessionId);return!(s!=null&&s.stop)||!s.background?null:r.jsx("button",{type:"button",className:"stop-continue",...$n(s.pressing,!(s.loaded&&s.gate.ready)),title:fP(s,n),onClick:o=>{o.stopPropagation(),a()},children:s.pressing?"Continuing…":"Continue"})}function hG({data:e}){const t=tj(),n=jr(15e3),s=sj(e,t);return!s||s.stop||!s.last||n-s.last.at>hP?null:r.jsxs("div",{className:`continued-row${s.last.ok?"":" failed"}`,title:df(s.last),children:[r.jsx("span",{className:"waiting-dot","aria-hidden":!0}),r.jsx("span",{className:"continued-said",children:ej(s.last,n)})]})}function fG({agent:e}){const t=tj(),n=jr(15e3),s=sj(e,t),a=pP(s,e.sessionId),[o,i]=y.useState(null),c=y.useCallback(async(m,w)=>{await eo(w)&&(i(m),window.setTimeout(()=>i(j=>j===m?null:j),1600))},[]);if(!s)return null;const d=s.last&&(!s.stop||s.last.at>=s.stop.at)&&n-s.last.at<=hP?r.jsxs("p",{className:`detail-continue-last${s.last.ok?"":" failed"}`,title:df(s.last),children:[ej(s.last,n),". ",df(s.last)]}):null;if(!s.stop)return d?r.jsxs("section",{className:"detail-section",children:[r.jsx("h3",{children:"Continue"}),d]}):null;const h=s.loaded?s.gate.ready?s.stop.kind==="api-error"?"":"A working login with room is active now.":Q1(s.gate.reason):"Checking for a working login…";if(!s.background)return r.jsxs("section",{className:"detail-section",children:[r.jsx("h3",{children:"Continue"}),r.jsx("p",{className:"detail-recap",children:QV(s.stop.kind)}),h&&r.jsx("p",{className:"detail-continue-state",children:h}),r.jsx("div",{className:"detail-continue-actions",children:r.jsx("button",{type:"button",className:"btn detail-continue-btn",onClick:()=>{c("word","continue")},children:o==="word"?"Copied":"Copy “continue”"})})]});const f=uP({auto:s.auto,kind:s.stop.kind,held:s.held,tried:s.tried}),p=s.jobId?eG(s.jobId,e.sessionId):null;return r.jsxs("section",{className:"detail-section",children:[r.jsx("h3",{children:"Continue"}),r.jsx("p",{className:"detail-recap",children:"A background session: ccdeck can run the turn that failed again, in place, through Claude Code's own background commands."}),h&&r.jsx("p",{className:"detail-continue-state",children:h}),f&&r.jsx("p",{className:"detail-continue-state",children:f}),d,r.jsx("div",{className:"detail-continue-actions",children:r.jsx("button",{type:"button",className:"btn primary detail-continue-btn",...$n(s.pressing,!(s.loaded&&s.gate.ready)),title:fP(s,n),onClick:a,children:s.pressing?"Continuing…":"Continue"})}),p&&r.jsxs("details",{className:"detail-continue-how",children:[r.jsx("summary",{children:"The commands it runs"}),r.jsx("pre",{className:"detail-continue-cmd",children:r.jsx("code",{children:p})}),r.jsx("p",{className:"detail-continue-note",children:"The stop runs only while its process is alive and idle, and the resume only once Claude Code lists no live process for it."}),r.jsx("button",{type:"button",className:"btn detail-continue-btn",onClick:()=>{c("commands",p)},children:o==="commands"?"Copied":"Copy"})]})]})}const nE=typeof window>"u"?y.useEffect:y.useLayoutEffect;function pG({data:e}){var U,P;const t=il(e),n=["agent-node",`state-${t}`,e.synthetic?"synthetic":""].filter(Boolean).join(" "),s=e.tools.filter(T=>!T.endedAt).length,a=e.toolErrorCount??0,o=hu(e.canvasSessionId??e.sessionId),i=((U=e.context)==null?void 0:U.currentContextTokens)??0,c=e.kind==="root"&&i>0,d=e.sessionTitle?e.cwd?`${e.cwd}
|
|
85
|
+
${e.sessionTitle}`:e.sessionTitle:e.cwd,h=z1(e),f=y.useRef(null),p=y.useRef(null),m=l9(e),[w,j]=y.useState(0),[v,b]=y.useState(null);nE(()=>{j(0)},[e.effort,e.model,h.length,e.cwdBasename,e.childCount,e.kind,m,v]),nE(()=>{const T=f.current;if(!T||w>=m)return;const B=p.current,M=c9(w,{overflowing:T.scrollWidth>T.clientWidth,folderCut:!!B&&B.scrollWidth>B.clientWidth,max:m});M!==w&&j(M)}),y.useEffect(()=>{const T=f.current;if(!T||typeof ResizeObserver>"u")return;let B=T.clientWidth;const M=new ResizeObserver(()=>{T.clientWidth!==B&&(B=T.clientWidth,vt.flushSync(()=>b(B)))});return M.observe(T),()=>M.disconnect()},[]);const k=u9(w),N=e.model&&(h.length>0?`${pu(e.model,e.effort)}
|
|
86
|
+
spend on this card also covers:
|
|
87
|
+
${h.join(`
|
|
88
|
+
`)}`:pu(e.model,e.effort)),S=sp(e.sessionName,e.sessionTitle),_=ap(e),E=_?_.key:null,I=lV(E),A=_!=null&&!I,O=(_==null?void 0:_.kind)==="recap",L=a9(e);return r.jsxs("div",{className:n,style:{"--session-hue":o},children:[r.jsx("span",{className:"accent-stripe"}),r.jsx(Ko,{type:"target",position:Fe.Left,style:{background:"transparent",border:"none"}}),r.jsxs("div",{className:"head",children:[r.jsxs("div",{className:"title",children:[r.jsx(xG,{state:t}),r.jsx("span",{className:"label",title:d,children:e.label}),e.restoredFromLog&&r.jsx("span",{className:"synth-tag",title:e.provider==="claude"?"Restored from Claude’s busy-session registry after verifying the process identity. Earlier tool history is partial.":"Restored from a log with no recorded ending. Process status is not confirmed.",children:"restored"}),e.synthetic&&r.jsx("span",{className:"synth-tag",title:"No SessionStart captured — synthesised",children:"?"}),_&&E&&r.jsx("button",{type:"button",className:"glyph-btn recap-pin","aria-label":O?"Claude Code's recap":`Session note: ${Ha(_.kind)}`,"aria-expanded":A,title:O?A?"Hide the recap":"Show Claude Code's recap":A?"Hide this note":"Show what this session is doing",onClick:T=>{T.stopPropagation(),iV(E)},children:r.jsx(lf,{recap:O})})]}),r.jsx("div",{className:"head-right",children:c&&e.onOpenContext&&r.jsx(X9,{currentContextTokens:i,modelId:e.model,contextWindow:e.contextWindow,onClick:()=>e.onOpenContext(e.sessionId)})})]}),r.jsxs("div",{className:"sub",title:_9(e),children:[r.jsxs("span",{className:"sub-details",ref:f,children:[k.kind&&r.jsx("span",{children:np(e)}),e.childCount>0&&r.jsxs("span",{className:"spawn-badge",title:S9(e.childCount),children:["→ ",e.childCount]}),e.cwdBasename&&e.kind==="subagent"&&r.jsxs("span",{className:"sub-folder",ref:p,children:[k.kind?"· ":"",e.cwdBasename]}),e.model?r.jsxs("span",{className:"model-chip","data-family":Qf(e.model),title:N,children:[ep(e.model,k.effort?e.effort:void 0),h.length>0?` +${h.length}`:""]}):e.provider==="codex"?r.jsx("span",{className:"model-chip",title:"OpenAI Codex — no model reported yet",children:"Codex"}):null]}),r.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?"≥ ":"",r.jsx(wG,{start:e.startedAt,end:e.endedAt})]})]}),e.kind==="root"&&S.face&&r.jsx("div",{className:"session-name",title:S.tooltip,children:S.face}),e.kind==="root"&&e.stopFailure&&r.jsx(vG,{data:e,stop:e.stopFailure}),e.kind==="root"&&!e.stopFailure&&r.jsx(hG,{data:e}),e.waiting&&!(e.stopFailure&&e.waiting.kind==="idle")&&r.jsx(bG,{waiting:e.waiting}),(()=>{const T=P3(e);return T?r.jsxs("div",{className:"approval-blind-row",title:T.detail,children:[r.jsx("span",{className:"approval-blind-dot","aria-hidden":!0}),r.jsx("span",{className:"approval-blind-said",children:T.label})]}):null})(),(()=>{const T=Lu(e.plan);return T&&e.plan?r.jsx(gG,{plan:T,items:e.plan.items}):null})(),(e.tools.length>0||(((P=e.outputs)==null?void 0:P.length)??0)>0)&&r.jsx(kG,{tools:e.tools,outputs:e.outputs}),r.jsxs("div",{className:"meta",children:[r.jsxs("span",{children:[r.jsx("b",{children:e.toolCount})," ",e.toolCount===1?"tool":"tools"]}),a>0&&r.jsxs("span",{className:"failed-meta",title:`${a} tool ${a===1?"call":"calls"} returned an error`,children:[r.jsx("b",{children:a})," err"]}),s>0&&r.jsxs("span",{className:"inflight-meta",children:[r.jsx("b",{children:s})," in-flight"]}),e.usage.inputTokens+e.usage.outputTokens>0&&r.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:[r.jsx("b",{children:xt(e.usage.inputTokens+e.usage.outputTokens)})," tok"]}),(L==null?void 0:L.kind)==="unpriced"&&r.jsx("span",{className:"cost-unpriced",title:L.tt,children:ra}),(L==null?void 0:L.kind)==="spent"&&r.jsx("span",{className:"cost-meta",title:L.tt,children:r.jsxs("b",{children:[et(L.total),L.floor?"+":""]})})]}),r.jsx(yG,{data:e,title:e.kind==="root"?S.face:void 0}),r.jsx(Ko,{type:"source",position:Fe.Right,style:{background:"transparent",border:"none"}})]})}const mG=y.memo(pG);function gG({plan:e,items:t}){return r.jsxs("div",{className:e.allDone?"plan-row plan-done":"plan-row",title:w3(t),children:[r.jsx("span",{className:"plan-meter","aria-hidden":!0,style:{"--plan-done":e.done/e.total}}),r.jsxs("span",{className:"plan-count",children:[e.done,"/",e.total]}),r.jsx("span",{className:"plan-step",children:e.allDone||!e.current?"done":r.jsxs(r.Fragment,{children:[e.next&&r.jsx("span",{className:"plan-next",children:"next: "}),e.current]})})]})}function yG({data:e,title:t}){const n=e.kind==="root"&&Mn(e.waiting),s=gV(e,e.branch,{sayWaiting:af,describeCall:a=>({name:Z1(a.name).label,subject:UV(a.name,a.input)})});return r.jsxs("div",{className:"lod-face","data-kind":e.kind,"data-alarm":n?"":void 0,"data-signal":s?"":void 0,"aria-hidden":!0,children:[r.jsxs("div",{className:"lod-id",children:[r.jsx(aP,{kind:h0(il(e))}),r.jsx("span",{className:"lod-name",children:e.label}),s&&r.jsx("span",{className:"lod-inline","data-tone":s.tone,children:s.short}),n&&r.jsx(J1,{})]}),t&&r.jsx("div",{className:"lod-title",children:t}),s&&r.jsxs("div",{className:"lod-signal","data-tone":s.tone,children:[r.jsx("span",{className:"lod-long",children:s.long}),r.jsx("span",{className:"lod-short",children:s.short})]})]})}function wG({start:e,end:t}){const n=jr(1e3);return r.jsx(r.Fragment,{children:vl(e,t,n)})}function xG({state:e}){return r.jsx("span",{className:`state-pill state-${e}`,children:wl(e)})}function vG({data:e,stop:t}){return r.jsxs("div",{className:"stop-row",title:b9(t,e.job!=null),"data-kind":t.kind,children:[r.jsx("span",{className:"waiting-dot","aria-hidden":!0}),r.jsx("span",{className:"stop-said",children:F3(t)}),r.jsx(dG,{data:e})]})}function bG({waiting:e}){const t=jr(1e3),n=Mn(e),s=xl(e);return r.jsxs("div",{className:n?"waiting-row permission":"waiting-row idle",title:`${s}
|
|
89
|
+
Blocked for ${vl(e.since,void 0,t)} — the answer goes in the terminal, not here.`,children:[n?r.jsx("span",{className:"ap-pulse","aria-hidden":!0}):r.jsx("span",{className:"waiting-dot","aria-hidden":!0}),r.jsx("span",{className:"waiting-said",children:af(e)}),r.jsx("b",{children:vl(e.since,void 0,t)})]})}function kG({tools:e,outputs:t}){const n=jr(1e3),{counts:s,title:a}=GV(e,t,n),o=Kg/ll;return r.jsxs("div",{className:"tool-spark-row",title:a,children:[r.jsx("svg",{className:"tool-spark",width:Kg,height:Ph,viewBox:`0 0 ${Kg} ${Ph}`,"aria-hidden":!0,children:s.map((i,c)=>{const d=YV(i),h=c===ll-1&&i>0,p=`tool-spark-bar${i>0?" active":""}${h?" latest":""}`;return r.jsx("rect",{x:c*o+.4,y:Ph-d,width:Math.max(.5,o-1),height:d,rx:.8,className:p},h?`landed:${i}`:c)})}),r.jsx("span",{className:"tool-spark-label",children:"60s"})]})}function jG({enableAutoFitAndRefit:e}){return r.jsxs("div",{className:"autofit-chip",children:[r.jsx("span",{className:"autofit-state",title:"New sessions are not brought into view while you are moving it yourself",children:"Auto-fit off"}),r.jsx("button",{type:"button",className:"autofit-resume",onClick:e,title:"Bring new sessions into view again","aria-label":"Resume auto-fit",children:"Resume"})]})}const rj="agent-dag.single-key-shortcuts";function mP(e){return e!=="0"}function gP(e){return e.length===1}function yP(e,t){return!t&&gP(e)}function vn(e,t,n){return n?`${e} (${t})`:e}let qo=null;const Fc=new Set;function wP(){for(const e of Fc)e()}function y0(){return qo===null&&(qo=mP(Ze(rj))),qo}function NG(e){qo!==e&&(qo=e,Xe(rj,e?"1":"0"),wP())}function sE(e){if(e.key!==rj)return;const t=mP(e.newValue);t!==qo&&(qo=t,wP())}function SG(e){var t;return Fc.add(e),Fc.size===1&&typeof window<"u"&&((t=window.addEventListener)==null||t.call(window,"storage",sE)),()=>{var n;Fc.delete(e),Fc.size===0&&typeof window<"u"&&((n=window.removeEventListener)==null||n.call(window,"storage",sE))}}function hf(e){const t=Math.max(0,Math.floor(e));return`${t} event${t===1?"":"s"}`}const rE=99;function _G(e){const t=Math.max(0,Math.floor(e));return t>rE?`${rE}+`:String(t)}const CG="Pause the canvas";function EG(e){const t=e.singleKeys??!0;if(!e.paused)return vn("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?vn(`The pause is full — ${hf(e.held)} held and ${n} older ${n===1?"one":"ones"} already dropped. Resume to follow the canvas again`,"Space",t):e.held<=0?vn("Nothing has arrived since you paused. Resume to follow the canvas again","Space",t):vn(`${hf(e.held)} arrived while paused and will be applied in order when you resume`,"Space",t)}function TG(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 xP="paused · full",RG=(e,t)=>t>0?xP:e>0?`paused · ${_G(e)}`:"paused";function AG(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:RG(e.held,t),widest:xP,title:vn(t>0?`Connected — the pause is full at ${hf(e.held)}; the oldest are being dropped as new ones arrive. Resume to catch up`:e.held>0?`Connected — ${hf(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 Pn(){return y.useSyncExternalStore(SG,y0,y0)}const MG=e=>e.transform[2]>=e.maxZoom,$G=e=>e.transform[2]<=e.minZoom;function LG({autoFitDisabled:e,enableAutoFitAndRefit:t,paused:n,pauseGate:s,togglePause:a,handleRelayout:o,requestClear:i,setKeyHelpOpen:c}){const d=_l(),h=at(MG),f=at($G),p=Pn();return r.jsxs(pz,{showInteractive:!1,showFitView:!1,showZoom:!1,children:[r.jsx(hs,{onClick:()=>{h||d.zoomIn()},title:"Zoom in","aria-label":"Zoom in","aria-disabled":h||void 0,children:r.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:r.jsx("path",{d:"M12 5v14M5 12h14",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})})}),r.jsx(hs,{onClick:()=>{f||d.zoomOut()},title:"Zoom out","aria-label":"Zoom out","aria-disabled":f||void 0,children:r.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:r.jsx("path",{d:"M5 12h14",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})})}),r.jsx(hs,{onClick:t,title:e?"Recenter view + re-enable autofit":"Recenter view (autofit already on)","aria-label":"Recenter view","data-nudge":e?"":void 0,children:r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[r.jsx("circle",{cx:"12",cy:"12",r:"3.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),r.jsx("path",{d:"M12 2v4M12 18v4M2 12h4M18 12h4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})]})}),r.jsx(hs,{"data-group-start":"",onClick:a,title:EG({paused:n,held:s.size,dropped:s.dropped,singleKeys:p}),"aria-label":CG,"aria-pressed":n,children:r.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:r.jsx("path",{d:"M9 5.5v13M15 5.5v13",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})})}),r.jsx(hs,{onClick:o,title:vn("Auto-arrange — clear pins","R",p),"aria-label":"Re-arrange the canvas",children:r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[r.jsx("rect",{x:"8.5",y:"2",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),r.jsx("rect",{x:"1.5",y:"17",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),r.jsx("rect",{x:"15.5",y:"17",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),r.jsx("path",{d:"M12 7v6.5M5 17v-3.5h14V17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]})}),r.jsx(hs,{"data-group-start":"","data-danger":"",onClick:()=>i("button"),title:vn("Clear the canvas and the server's event log — asks first","C",p),"aria-label":"Clear the canvas",children:r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[r.jsx("path",{d:"M4 6.2h16",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"}),r.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"}),r.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"}),r.jsx("path",{d:"M10.3 10.6v6.8M13.7 10.6v6.8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})]})}),r.jsx(hs,{"data-group-start":"",onClick:()=>c(m=>!m),title:p?vn("Keyboard shortcuts","?",!0):"Keyboard shortcuts — the single-key ones are off","aria-label":"Open the keyboard shortcuts","aria-haspopup":"dialog",children:r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[r.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"}),r.jsx("path",{d:"M12 18.4v.2",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",fill:"none"})]})})]})}const IG="modulepreload",OG=function(e){return"/"+e},aE={},Du=function(t,n,s){let a=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"));a=i(n.map(h=>{if(h=OG(h),h in aE)return;aE[h]=!0;const f=h.endsWith(".css"),p=f?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${h}"]${p}`))return;const m=document.createElement("link");if(m.rel=f?"stylesheet":IG,f||(m.as="script"),m.crossOrigin="",m.href=h,d&&m.setAttribute("nonce",d),document.head.appendChild(m),f)return new Promise((w,j)=>{m.addEventListener("load",w),m.addEventListener("error",()=>j(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 a.then(i=>{for(const c of i||[])c.status==="rejected"&&o(c.reason);return t().catch(o)})},oE="agent-dag.fm-custom-stations",iE="agent-dag.fm-muted",w0="custom:",PG=/^UC[A-Za-z0-9_-]{22}$/,DG=/^[A-Za-z0-9_-]{11}$/,vP=/^[A-Za-z0-9_-]{1,80}$/,FG=/\.(mp3|aac|ogg)$/i,BG=/\.m3u8$/i,qG=2048,bP=80;function Nl(e){return`${w0}${e}`}function cp(e){if(!e.startsWith(w0))return null;const t=e.slice(w0.length);return vP.test(t)?t:null}function lE(e){return cp(e)??e}function aj(e){var i,c;const t=e.trim();if(t.length>qG)return null;let n;try{n=new URL(t)}catch{return null}if(n.protocol!=="https:"||n.username||n.password)return null;const s=n.toString(),a=n.hostname.toLowerCase();if(a==="youtube.com"||a==="www.youtube.com"||a==="m.youtube.com"){if(n.port)return null;const d=(i=/^\/channel\/([^/]+)(?:\/live)?\/?$/.exec(n.pathname))==null?void 0:i[1];if(d&&PG.test(d))return{kind:"youtube-channel",url:s,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:s,handle:h};if(n.pathname==="/watch"){const f=n.searchParams.get("v")??"";if(DG.test(f))return{kind:"youtube-video",url:s,video:f}}return null}return BG.test(n.pathname)?{kind:"direct-audio",url:s,format:"hls"}:FG.test(n.pathname)?{kind:"direct-audio",url:s,format:"audio"}:/\.(html?|pls|m3u)$/i.test(n.pathname)?null:{kind:"direct-audio",url:s,format:"audio"}}function UG(e){return e==="1"}function WG(e){if(!e)return[];let t;try{t=JSON.parse(e)}catch{return[]}if(!Array.isArray(t))return[];const n=new Set,s=[];for(const a of t){if(!a||typeof a!="object")continue;const o=typeof a.id=="string"?a.id:"",i=typeof a.name=="string"?a.name.trim():"",c=typeof a.url=="string"?a.url.trim():"",d=aj(c);if(!vP.test(o)||n.has(o)||!i||i.length>bP||!d)continue;n.add(o);const h=kP(a.radio);s.push({id:o,name:i,url:d.url,...h?{radio:h}:{}})}return s}function HG(e,t,n){const s=cp(e??"");return s&&t.some(a=>a.id===s)?Nl(s):n(e)}function zG(e,t){return e===Nl(t)?"claude-fm":e}function kP(e){if(!e||typeof e!="object")return null;const t=e,n=(a,o)=>typeof t[a]=="string"?t[a].slice(0,o):"",s=(a,o)=>typeof t[a]=="number"&&Number.isFinite(t[a])&&Math.abs(t[a])<=o?t[a]: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:s("lat",90),lon:s("lon",180)}}const x0="https://www.youtube-nocookie.com";function VG(e,t,n){const s=new URLSearchParams({...n?{}:{channel:e},enablejsapi:"1",autoplay:"1",playsinline:"1",rel:"0",modestbranding:"1",origin:t});return`${x0}/embed/${n?encodeURIComponent(n):"live_stream"}?${s.toString()}`}function Bi(e,t=[]){return JSON.stringify({event:"command",func:e,args:t})}function GG(e="claude-fm"){return JSON.stringify({event:"listening",id:e,channel:"widget"})}const KG=[1],YG=[0,2],XG=[2,5,100,101,150,153];function ZG(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:s}=t;if(n==="onReady")return{kind:"ready"};if(n==="onAutoplayBlocked")return{kind:"blocked"};if(n==="onError"){const a=typeof s=="number"?s:Number(s==null?void 0:s.errorCode);return Number.isFinite(a)?{kind:"error",code:a}:null}if(n==="onStateChange"||n==="infoDelivery"){const a=typeof s=="number"?s:s==null?void 0:s.playerState;return typeof a!="number"||!Number.isFinite(a)?null:KG.includes(a)?{kind:"playing",playing:!0}:a===3?{kind:"buffering"}:YG.includes(a)?{kind:"playing",playing:!1}:null}return null}const Ec=new Set;let cE="";function uE(e){const t=new Date().toISOString().slice(0,10);if(t!==cE&&(Ec.clear(),cE=t),!Ec.has(e)){Ec.add(e);try{const n=typeof navigator>"u"?void 0:navigator;(!n||typeof n.sendBeacon!="function"||!n.sendBeacon("/api/feature",JSON.stringify({name:e})))&&Ec.delete(e)}catch{Ec.delete(e)}}}const dE=864e5,JG=6e4;function en(e,t=!0){y.useEffect(()=>{if(!t)return;uE(e);let n;const s=()=>{n=setTimeout(()=>{uE(e),s()},dE-Date.now()%dE+JG)};return s(),()=>clearTimeout(n)},[e,t])}const QG={"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 eK({fetchImpl:e,enabled:t=!0,volume:n,muted:s,source:a,playRequest:o,customStation:i,onAvailabilityChange:c}){var B;const[d,h]=y.useState(null),[f,p]=y.useState(!1),[m,w]=y.useState(!1),[j,v]=y.useState(!1),[b,k]=y.useState(!1);en("claude-fm",j);const N=y.useRef(o),S=y.useRef(null),_=y.useRef(null),E=y.useRef(void 0),I=y.useRef(null),A=y.useCallback(()=>{var q;clearTimeout(E.current),(q=_.current)==null||q.destroy(),_.current=null;const M=S.current;M&&(M.pause(),M.removeAttribute("src"),M.load(),S.current=null)},[]),O=y.useCallback(M=>{var q,$;($=(q=I.current)==null?void 0:q.contentWindow)==null||$.postMessage(M,x0)},[]),L=y.useRef(n);L.current=n;const U=y.useRef(s);U.current=s;const P=y.useCallback((M,q,$)=>{A();const K=new Audio;K.preload="none",K.volume=L.current/100,K.muted=U.current,S.current=K,w(!0),v(!1),k(!1);let G=!1;const z=()=>S.current===K,W=()=>{clearTimeout(E.current),A(),w(!1),v(!1),k(!1)},D=()=>{z()&&(W(),p(!0),c==null||c($,!0))},H=F=>{if(z()&&!(F instanceof DOMException&&F.name==="AbortError")){if(F instanceof DOMException&&F.name==="NotAllowedError"){W();return}D()}};E.current=setTimeout(()=>{z()&&!G&&D()},15e3),K.addEventListener("playing",()=>{z()&&(clearTimeout(E.current),G=!0,v(!0),k(!1),c==null||c($,!1))});const ee=()=>{z()&&(v(!1),k(G),clearTimeout(E.current),E.current=setTimeout(()=>{z()&&D()},15e3))};K.addEventListener("waiting",ee),K.addEventListener("stalled",ee),K.addEventListener("ended",()=>{z()&&W()}),K.addEventListener("error",D,{once:!0}),q&&!K.canPlayType("application/vnd.apple.mpegurl")?Du(async()=>{const{default:F}=await import("./hls-BFpXDghs.js");return{default:F}},[]).then(({default:F})=>{if(!z())return;if(!F.isSupported()){D();return}const Y=new F;_.current=Y,Y.on(F.Events.ERROR,(X,Z)=>{Z.fatal&&D()}),Y.on(F.Events.MEDIA_ATTACHED,()=>Y.loadSource(M)),Y.on(F.Events.MANIFEST_PARSED,()=>{K.play().catch(H)}),Y.attachMedia(K)},D):(K.src=M,K.play().catch(H))},[c,A]);y.useEffect(()=>{m&&(O(Bi("setVolume",[n])),O(Bi(s?"mute":"unMute")),S.current&&(S.current.volume=n/100,S.current.muted=s))},[n,s,m,O]),y.useEffect(()=>{var W;let M=!0;const q=e??fetch,$=N.current!==o;if(N.current=o,h(null),p(!1),k(!1),w($),v(!1),A(),!t){w(!1),v(!1);return}const K=i&&Nl(i.id)===a?aj(i.url):null;if(K){if(K.kind==="direct-audio"){const D=K.format==="hls"||((W=i==null?void 0:i.radio)==null?void 0:W.hls)===!0;return h({live:!0,channel:"",audio:K.url,hls:D}),c==null||c(a,!1),$&&P(K.url,D,a),()=>{M=!1}}return q(`/api/fm-station?url=${encodeURIComponent(K.url)}`).then(D=>D.ok?D.json():null).then(D=>{M&&(D!=null&&D.channel||D!=null&&D.video?(h({live:!0,channel:D.channel??"",video:D.video??void 0}),c==null||c(a,!1)):(p(!0),w(!1),v(!1),k(!1),c==null||c(a,!0)))}).catch(()=>{M&&(p(!0),w(!1),v(!1),k(!1),c==null||c(a,!0))}),()=>{M=!1}}if(cp(a))return p(!0),c==null||c(a,!0),()=>{M=!1};const G=a,z=QG[G];if(z)q(z).then(D=>D.ok?D.json():null).then(D=>{M&&(D!=null&&D.video&&h({live:!0,channel:"",video:D.video}),D!=null&&D.video||(p(!0),w(!1),v(!1)),c==null||c(a,!(D!=null&&D.video)))}).catch(()=>{M&&(p(!0),w(!1),v(!1),c==null||c(a,!0))});else if(G!=="claude-fm"){const D=G.replace("lofi-","");q(`/api/lofi-girl?station=${encodeURIComponent(D)}`).then(H=>H.ok?H.json():null).then(H=>{M&&(H!=null&&H.video&&h({live:!0,channel:"",video:H.video}),H!=null&&H.video||(p(!0),w(!1),v(!1)),c==null||c(a,!(H!=null&&H.video)))}).catch(()=>{M&&(p(!0),w(!1),v(!1),c==null||c(a,!0))})}else q("/api/claude-fm").then(D=>D.ok?D.json():null).then(D=>{if(!M)return;const H=!!(D!=null&&D.live&&(D!=null&&D.channel));H&&h({live:!0,channel:D.channel}),H||(p(!0),w(!1),v(!1)),c==null||c(a,!H)}).catch(()=>{M&&(p(!0),w(!1),v(!1),c==null||c(a,!0))});return()=>{M=!1}},[i==null?void 0:i.id,i==null?void 0:i.url,(B=i==null?void 0:i.radio)==null?void 0:B.hls,t,e,c,o,a,P,A]),y.useEffect(()=>()=>A(),[A]),y.useEffect(()=>{if(!m||d!=null&&d.audio)return;let M;const q=()=>{clearTimeout(M),M=void 0,w(!1),v(!1),k(!1),p(!0),c==null||c(a,!0)},$=()=>{M??(M=setTimeout(q,15e3))};$();const K=G=>{var W;if(G.origin!==x0||G.source!==((W=I.current)==null?void 0:W.contentWindow))return;const z=ZG(G.data);if(z){if(z.kind==="ready"){O(Bi("setVolume",[L.current])),O(Bi(U.current?"mute":"unMute")),O(Bi("playVideo"));return}if(z.kind==="blocked"){clearTimeout(M),M=void 0,w(!1),v(!1),k(!1);return}if(z.kind==="buffering"){v(!1),k(!0),$();return}if(z.kind==="playing"){clearTimeout(M),M=void 0,v(z.playing),k(!1),z.playing||w(!1);return}XG.includes(z.code)&&q()}};return window.addEventListener("message",K),()=>{clearTimeout(M),window.removeEventListener("message",K)}},[m,d==null?void 0:d.audio,o,c,O,a]);const T=y.useCallback(()=>{if(d){if(d.audio){if(m){A(),w(!1),v(!1),k(!1);return}P(d.audio,d.hls===!0,a);return}if(!m){w(!0),v(!1),k(!1);return}O(Bi("pauseVideo")),w(!1),v(!1),k(!1)}},[d,m,j,a,O,P,A]);return y.useMemo(()=>({probe:d,dead:f,armed:m,playing:j,buffering:b,frame:I,say:O,press:T}),[d,f,m,j,b,O,T])}const hE="agent-dag.radio-favorites",fE="agent-dag.radio-recent",pE="agent-dag.radio-catalogue";function tK(e){if(!Array.isArray(e))return[];const t=new Set;return e.slice(0,300).flatMap(n=>{if(!n||typeof n!="object")return[];const s=n,a=typeof s.id=="string"?s.id:"",o=typeof s.name=="string"?s.name.trim().slice(0,80):"",i=typeof s.url=="string"?aj(s.url):null,c=kP(s.radio??s);return!/^radio-[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/i.test(a)||!o||!c||!i||i.kind!=="direct-audio"||t.has(a)?[]:(t.add(a),[{id:a,name:o,url:i.url,radio:c}])})}function mE(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 nK(e,t){return[t,...e.filter(n=>n!==t)].slice(0,50)}function Sve(e,t,n=Math.random){const s=e.filter(a=>a.id!==t);return s.length?s[Math.min(s.length-1,Math.floor(Math.max(0,n())*s.length))]:null}function _ve(e,t,n){if(!e.length)return null;const s=e.findIndex(o=>o.id===t),a=e[s<0?n===1?0:e.length-1:(s+n+e.length)%e.length];return a.id===t?null:a}function jP(e,t,n){const s=e.findIndex(a=>a.id===t);for(let a=1;a<=e.length;a++){const o=e[(s+a)%e.length];if(o.id!==t&&!n.has(o.id))return o}return null}function Cve(e,t){if(!e.length)return null;const n=[...e].sort((a,o)=>a.id.localeCompare(o.id));let s=0;for(const a of t)s=Math.imul(s,31)+a.charCodeAt(0)>>>0;return n[s%n.length]}function Eve(e,t,n,s,a){return(!t||`${e.name} ${e.radio.country} ${e.radio.region} ${e.radio.tags}`.toLowerCase().includes(t.toLowerCase()))&&(!n||e.radio.countryCode===n)&&(!s||e.radio.tags.toLowerCase().includes(s.toLowerCase()))&&(!a||e.radio.language.toLowerCase().includes(a.toLowerCase()))}function sK(){const[e,t]=y.useState(()=>mE(Ze(hE))),[n,s]=y.useState(()=>mE(Ze(fE))),[a,o]=y.useState(()=>{try{return tK(JSON.parse(Ze(pE)??"[]"))}catch{return[]}});y.useEffect(()=>{Xe(hE,JSON.stringify(e))},[e]),y.useEffect(()=>{Xe(fE,JSON.stringify(n))},[n]);const i=y.useCallback(h=>s(f=>nK(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),Xe(pE,JSON.stringify(h))},[]);return{favorites:e,recent:n,catalogue:a,remember:i,toggleFavorite:c,updateCatalogue:d}}function rK(e,t,n,s){const a=jP(e,t,n);if(!a)return()=>{};const o=setTimeout(()=>{n.add(t),s(a)},1e3);return()=>clearTimeout(o)}const up=148,gE=6e3,aK=16e3,NP=46,qa=34;function oK(e,t,n=up){let s=-Math.round(t()*n);if(Math.abs(s-e)<qa){const a=e-qa>=-n?-qa:qa;s=Math.max(-n,Math.min(0,Math.round(e+a)))}return{to:s,ms:Math.round(Math.abs(s-e)*NP)}}function iK(e){return Math.round(gE+e()*(aK-gE))}const yE=[{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 lK(e){const t=yE.reduce((s,a)=>s+a.weight,0);let n=e()*t;for(const s of yE)if(n-=s.weight,n<0)return s.kind;return"stroll"}const cK=720,uK=260,dK=620,hK=220,wE=520,SP=1600,xE=7e3,fK=15e3,vE=6e3,pK=14e3;function qi(e,t,n=up){let s=-Math.round(t()*n);if(Math.abs(s-e)<qa){const a=e-qa>=-n?-qa:qa;s=Math.max(-n,Math.min(0,Math.round(e+a)))}return s}const Yt=(e,t)=>Math.round(Math.abs(t-e)*NP),mK=120,hh=0;function gK(e,t){const n=s=>({kind:"litter",at:t,...s});return[{x:t,prop:n({}),act:"walk",ms:Yt(e,t)},{x:t,prop:n({}),act:"stoop",ms:cK},{x:hh,prop:n({held:!0}),act:"carry",ms:Yt(t,hh)},{x:hh,prop:n({held:!0}),act:"windup",ms:uK},{x:hh,prop:n({held:!0,leaving:!0}),act:"toss",ms:dK}]}function yK(e,t){const n=t>e?1:-1,s=t-n*Math.min(15,Math.abs(t-e)),a=(o={})=>({kind:"ball",at:t,...o});return[{x:s,prop:a(),act:"walk",ms:Yt(e,s)},{x:s,prop:a(),act:"windup",ms:hK,facing:n>0?"right":"left"},{x:s,prop:a({leaving:!0}),act:"kick",ms:wE,facing:n>0?"right":"left"},{x:s,prop:a({leaving:!0}),act:"stand",ms:SP-wE}]}const _P=640;function wK(e,t,n){const s=Math.max(-70,Math.min(-20,t)),a={x:s,prop:null,facing:"left"};return[{x:s,prop:null,act:"walk",ms:Yt(e,s)},{...a,act:"sit",ms:600},{...a,act:"cast",ms:900},{...a,act:"fish",ms:6e3+Math.round(n()*4e3)},{...a,act:"reel",ms:1200},{...a,act:"stow",ms:500},{...a,act:"stand",ms:400},{x:0,prop:null,act:"walk",ms:Yt(s,0)}]}function xK(e,t,n){const s=Math.max(-110,Math.min(-30,t)),a={x:s,prop:null};return[{...a,act:"walk",ms:Yt(e,s)},{...a,act:"skip-ready",ms:500},{...a,act:"skip",ms:_P*(6+Math.floor(n()*5))},{...a,act:"skip-rest",ms:600},{...a,act:"stand",ms:350},{x:0,prop:null,act:"walk",ms:Yt(s,0)}]}function vK(e,t,n){return[{x:t,prop:null,act:"walk",ms:Yt(e,t)},{x:t,prop:null,act:"sit",ms:Math.round(vE+n()*(pK-vE))},{x:t,prop:null,act:"stand",ms:400}]}function bK(e,t,n){t=Math.max(-110,Math.min(0,t));const s=()=>({kind:"scope",at:t,held:!0});return[{x:t,prop:null,act:"walk",ms:Yt(e,t)},{x:t,prop:s(),act:"watch",ms:Math.round(xE+n()*(fK-xE))},{x:t,prop:s(),act:"scope-pack",ms:480},{x:t,prop:null,act:"stand",ms:240}]}function Xg(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 kK=1500,jK=e=>Math.round(1e3*Math.sqrt(2*e/kK)),NK=115,SK=e=>Math.round(e/NK*1e3),_K=620,CK=200,EK=760,TK=600,RK=240;function AK(e,t,n){const a=-(t.ledgeSpan??up),o=jK(t.ledgeH),i=SK(t.ledgeH),c=n(),d=n(),h=-Math.round(c*t.floorSpan),f=-Math.round(d*t.floorSpan);return[{x:a,act:"walk",prop:null,ms:Yt(e,a)},{x:a,act:"peer",prop:null,ms:_K},{x:a,act:"fall",prop:null,ms:o,place:"floor"},{x:a,act:"land",prop:null,ms:CK,place:"floor"},{x:h,act:"walk",prop:null,ms:Yt(a,h),place:"floor",floorFrac:c},{x:f,act:"walk",prop:null,ms:Yt(h,f),place:"floor",floorFrac:d},{x:a,act:"walk",prop:null,ms:Yt(f,a),place:"floor"},{x:a,act:"lasso",prop:null,ms:EK,place:"floor"},{x:a,act:"rope-throw",prop:null,ms:TK,place:"floor"},{x:a,act:"rope-catch",prop:null,ms:RK,place:"floor"},{x:a,act:"climb",prop:null,ms:i},{x:a,act:"pull-up",prop:null,ms:480}]}function MK(e,t,n){const s=(n==null?void 0:n.ledgeSpan)??up;switch(lK(t)){case"tidy":return gK(e,qi(e,t,s));case"kick":return yK(e,qi(e,t,s));case"sit":return vK(e,qi(e,t,s),t);case"watch":return bK(e,qi(e,t,s),t);case"fish":return wK(e,qi(e,t,s),t);case"skip":return xK(e,qi(e,t,s),t);case"leave":{if(!n||!(n.ledgeH>0)||!(n.floorSpan>0))break;return AK(e,n,t)}}const o=oK(e,t,s);return[{x:o.to,prop:null,act:"walk",ms:o.ms}]}const $K=420;function LK(e,t,n){const s=t==="right"?n-e-18:e-18;return(t==="right"?1:-1)*Math.min($K,Math.max(0,s))}const IK=260,OK=200;function PK(e,t,n){const s=(f,p=Yt(e,f))=>({x:f,prop:null,act:"walk",ms:p,place:"floor"});if(!n||n.height<=0)return[s(t)];const a=Math.min(e,t);if(Math.max(e,t)<=n.left||a>=n.right)return[s(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[s(c,Yt(e,c)),{...h,x:c,act:"mount",ms:IK},{...h,x:d,act:"walk",ms:Yt(c,d)},{x:d,prop:null,act:"dismount",ms:OK,place:"floor"},{x:t,prop:null,act:"walk",ms:Yt(d,t),place:"floor"}]}const CP=["bob","sway","groove"],bE=9e3,DK=16e3,EP=1e3,FK=.08;function BK(e,t){const n=CP.filter(o=>o!==e),s=n[Math.min(n.length-1,Math.floor(t()*n.length))],a=(t()*2-1)*FK;return{dance:s,beatMs:Math.round(EP*(1+a))}}function qK(e){return Math.round(bE+e()*(DK-bE))}const oj=["......aaaaaa......","....aa......aa....","...a..bbbbbs..a...","...cpcbbbbbscpc...","...cpcbebbescpc...","...cpcbbbbbscpc...","...cpcbbbbbscpc...","....ccbbbbbscc....","....bbbbbbbbbs....","....bbbbbbbbbs....","......bbbbbs......","......bb..bs......","......bb..bs......","......bb..bs......"],kE=18,UK=oj.length,TP="M6 9H4V1H5V0H7V-1H9V1H7V2H5V7H6V8H7V9Z",RP="M12 9H14V6H13V3H11V2H9V4H12Z",ij=new Set(["a","c","p"]);function to(e=oj){const t=[];return e.forEach((n,s)=>{let a=0;for(;a<n.length;){const o=n[a];if(o==="."){a+=1;continue}let i=1;for(;a+i<n.length&&n[a+i]===o;)i+=1;t.push({x:a,y:s,w:i,cell:o}),a+=i}}),t}const WK=[".xx.","xxxx",".xx."],HK=["..xx..",".xsxx.","xssxxx","xxxxsx",".xxxx.","..xx.."],zK=["...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."],Zg={litter:WK,ball:HK,scope:zK},VK=["...hhhhhh...","...hhhhhh...","...kkkkkk...","hhhhhhhhhhhh"],GK=3,KK=-1,v0=11,jE=9;function NE(e){let t=null,n=null,s=0,a=0,o=!1;const i=()=>{t!==null&&clearTimeout(t),t=null},c=()=>{o||e.hidden||!n||t!==null||(a=performance.now(),t=setTimeout(()=>{t=null;const h=n;n=null,h==null||h()},s))},d=()=>{e.hidden&&t!==null?(s=Math.max(0,s-(performance.now()-a)),i()):e.hidden||c()};return e.addEventListener("visibilitychange",d),{schedule(h,f){o||(i(),n=h,s=Math.max(0,f),c())},dispose(){o=!0,i(),n=null,e.removeEventListener("visibilitychange",d)}}}function YK(e,t,n){const[s,a]=y.useState(0),[o,i]=y.useState(0),[c,d]=y.useState(null),[h,f]=y.useState(null),[p,m]=y.useState({x:0,drop:0}),[w,j]=y.useState("ledge"),[v,b]=y.useState("left"),[k,N]=y.useState(0),S=y.useRef(null),[_,E]=y.useState(()=>document.hidden);y.useEffect(()=>{const T=new Set,B=()=>{var M;if(document.hidden){for(const q of((M=S.current)==null?void 0:M.getAnimations({subtree:!0}))??[])if(q.playState==="running"||q.pending){const $=q.currentTime;q.pause(),$!==null&&(q.currentTime=$),T.add(q)}}else{for(const q of T)q.playState==="paused"&&q.play();T.clear()}E(document.hidden)};return B(),document.addEventListener("visibilitychange",B),()=>document.removeEventListener("visibilitychange",B)},[e,t]);const[I,A]=y.useState(null),[O,L]=y.useState(EP),[U,P]=y.useState(()=>{var T;return((T=window.matchMedia)==null?void 0:T.call(window,"(prefers-reduced-motion: reduce)").matches)??!1});return y.useEffect(()=>{var M;const T=(M=window.matchMedia)==null?void 0:M.call(window,"(prefers-reduced-motion: reduce)");if(!T)return;const B=()=>P(T.matches);return B(),T.addEventListener("change",B),()=>T.removeEventListener("change",B)},[]),y.useEffect(()=>{var Z;if(!e||t||U)return;const T=NE(document);let B=0;a(J=>B=J);let M=null,q=0,$=0;const K=J=>{var re,ae;const[ne,...ce]=J;if(!ne){M=null,d(null),f(null),F();return}d(ne.act),f(ne.prop),j(ne.place??"ledge"),N(ne.riser??0);const he=B,le=H(ne);if(ne.act==="kick"){const de=(ae=(re=S.current)==null?void 0:re.querySelector('.fm-prop[data-prop="ball"]'))==null?void 0:ae.getBoundingClientRect();de&&m({x:LK(de.x,Xg(ne,he,"left"),window.innerWidth),drop:Math.max(48,window.innerHeight-de.y+24)})}$=ne.act==="walk"?Math.max(Yt(he,le),mK):ne.ms,ne.act==="carry"&&($=Yt(he,le)),i($),b(de=>Xg({...ne,x:le},he,de)),a(le),B=le,M=ne,q=Date.now(),T.schedule(()=>K(ce),$)},G=()=>{const J=S.current,ne=J==null?void 0:J.querySelector(".fm-sprite"),ce=J==null?void 0:J.parentElement;if(!J||!ne||!ce)return null;const he=J.getBoundingClientRect(),le=ce.getBoundingClientRect(),re=le.right-he.right,ae=le.width-re*2-ne.offsetWidth;return ae>0?ae:null},z=()=>{const J=S.current,ne=J==null?void 0:J.querySelector(".fm-sprite");return!J||!ne?0:Math.max(0,J.getBoundingClientRect().width-ne.offsetWidth)},W=()=>{const J=S.current,ne=J==null?void 0:J.querySelector(".fm-walker"),ce=G();if(!J||!ne||ce==null)return;const he=J.getBoundingClientRect().bottom-ne.getBoundingClientRect().bottom;if(he>0)return{ledgeH:he,floorSpan:ce,ledgeSpan:z()}},D=()=>{const J=S.current,ne=document.querySelector(".canvas-notices");if(!J||!ne)return null;const ce=J.getBoundingClientRect(),he=ne.getBoundingClientRect();return he.width<=0||he.height<=0?null:{left:he.left-ce.right,right:he.right-ce.right,height:he.height}},H=J=>{const ne=(J.place??"ledge")==="floor",ce=ne?G()??z():z(),he=ne&&J.floorFrac!=null?-Math.round(J.floorFrac*ce):J.x;return Math.max(-ce,Math.min(0,he))},ee=()=>{if(!M)return;const J=H(M);J!==B&&(i(Math.max(0,q+$-Date.now())),b(ne=>Xg({...M,x:J},B,ne)),a(J),B=J)},F=()=>{T.schedule(()=>{const J=MK(B,Math.random,W()),ne=J.some(le=>le.place==="floor")?D():null;let ce=B;const he=J.flatMap(le=>{const re=ce;if(ce=le.x,!(le.place==="floor"&&le.act==="walk"))return[le];const ae=PK(re,le.x,ne),de=ae.length-1;return le.floorFrac==null?ae:ae.map((Se,pe)=>pe===de?{...Se,floorFrac:le.floorFrac}:Se)});K(he)},iK(Math.random))},Y=(Z=S.current)==null?void 0:Z.parentElement,X=typeof ResizeObserver>"u"?null:new ResizeObserver(ee);return Y&&X&&X.observe(Y),F(),()=>{T.dispose(),X==null||X.disconnect(),j("ledge"),a(J=>Math.max(-z(),Math.min(0,J))),i(0),d(null),f(null),N(0)}},[e,t,U]),y.useEffect(()=>{if(!n||U){A(null);return}const T=NE(document),B=M=>{const q=BK(M,Math.random);A(q.dance),L(q.beatMs),T.schedule(()=>B(q.dance),qK(Math.random))};return B(null),()=>T.dispose()},[n,U]),{scene:S,suspended:_,x:s,walkMs:o,act:c,prop:h,ballFlight:p,place:w,facing:v,riser:k,dance:I,beatMs:O}}const Jg={e:"fm-eye",s:"fm-shade",p:"fm-pad"},ff=to().filter(e=>!ij.has(e.cell)),XK=to().filter(e=>ij.has(e.cell)),SE=ff.filter(e=>e.cell==="e"),ZK=to(VK),JK=ff.filter(e=>e.y<v0&&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),QK={left:ff.filter(e=>e.y>=v0&&e.x<jE),right:ff.filter(e=>e.y>=v0&&e.x>=jE)},eY=y.memo(function({act:t,facing:n}){return r.jsxs("svg",{viewBox:`0 0 ${kE} ${UK}`,shapeRendering:"crispEdges","aria-hidden":!0,children:[r.jsx("g",{className:"fm-gear",children:r.jsx("g",{className:"fm-gear-motion",children:XK.map(s=>r.jsx("rect",{x:s.x,y:s.y,width:s.w,height:1,className:Jg[s.cell]},`g${s.y}-${s.x}`))})}),r.jsxs("g",{className:"fm-body",children:[SE.map(s=>r.jsx("rect",{x:s.x,y:s.y,width:s.w,height:1,fill:"var(--accent)"},`eye-bed-${s.x}`)),JK.map(s=>r.jsx("rect",{x:s.x,y:s.y,width:s.w,height:1,className:Jg[s.cell]},`b${s.y}-${s.x}`)),r.jsxs("g",{className:"fm-arms",children:[r.jsx("rect",{x:4,y:8,width:2,height:2}),r.jsx("rect",{x:12,y:8,width:1,height:2}),r.jsx("rect",{x:13,y:8,width:1,height:2,className:"fm-shade"})]}),SE.map(s=>r.jsx("rect",{x:s.x-(s.x>=kE/2?1:0)+(n==="right"?1:0),y:s.y,width:s.w,height:1,className:"fm-eye"},`eye-${s.x}`))]}),r.jsx("g",{className:"fm-hat",children:ZK.map(s=>r.jsx("rect",{x:GK+s.x,y:KK+s.y,width:s.w,height:1,className:s.cell==="k"?"fm-hatband":void 0},`h${s.y}-${s.x}`))}),(t==="climb"||t==="rope-throw"||t==="rope-catch"||t==="pull-up")&&r.jsxs("g",{className:"fm-grip",children:[r.jsx("path",{className:"fm-grip-left",d:TP}),r.jsx("path",{className:"fm-grip-right",d:RP})]}),(t==="land"||t==="dismount")&&r.jsxs("g",{className:"fm-crouch-legs",children:[r.jsx("path",{d:"M6 11H8V13H6Z"}),r.jsx("path",{d:"M10 11H12V13H10Z"})]}),["sit","cast","fish","reel","stow"].includes(t)&&r.jsxs("g",{className:"fm-seated-legs",children:[r.jsx("path",{className:"fm-seated-far",d:"M10 10H12V11H11V14H8V13H9V11H10Z"}),r.jsx("path",{d:"M6 10H9V11H7V15H4V14H5V11H6Z"})]}),["left","right"].map(s=>r.jsx("g",{className:"fm-leg","data-side":s,children:QK[s].map(a=>r.jsx("rect",{x:a.x,y:a.y,width:a.w,height:1,className:Jg[a.cell]},`${s}${a.y}-${a.x}`))},s))]})}),tY=["...o........o.....","...of......fo.....","...owffffffwo.....","...offfffffso.....","...ofefffefso.....","....owwnwwso......",".....wwwww........",".....fwwwfs.......","....ffwwwffs...ww.","....ffwwwffs..wfs.","......fwwfssfffs..","......ff..fsffs...","......ff..fs......","......oo..oo......"],nY=[".....aaaaaaa......","...aa.......aa....","..a...........a...","..cp.........pc...","..cp.........pc...","..cp.........pc...","..c...........c..."],dr={f:"#d88735",s:"#a55b24",o:"#63351e",w:"#ffe2aa",n:"#372821"},sY={p:"fm-pad"},mu=to(tY),rY=to(nY);function b0(e,t,n){return e.map(s=>({...s,x:Math.max(t,s.x),w:Math.max(0,Math.min(n,s.x+s.w)-Math.max(t,s.x))})).filter(s=>s.w>0)}const aY=b0(mu.filter(e=>e.y>=8),12,18),oY=mu.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),_E=mu.filter(e=>e.cell==="e"),iY={left:b0(mu.filter(e=>e.y>=11),0,9),right:b0(mu.filter(e=>e.y>=11),9,12)},lY=y.memo(function({act:t,facing:n}){const s=t==="climb"||t==="rope-throw"||t==="rope-catch"||t==="pull-up",a=t==="land"||t==="dismount",o=t==="sit"||t==="cast"||t==="fish"||t==="reel"||t==="stow";return r.jsxs("svg",{"data-character":"fox",viewBox:"0 0 18 14",shapeRendering:"crispEdges","aria-hidden":!0,focusable:"false",children:[r.jsx("g",{className:"fm-body","data-part":"tail",children:aY.map(i=>r.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,fill:dr[i.cell]},`t${i.y}-${i.x}`))}),r.jsx("g",{className:"fm-gear",children:r.jsx("g",{className:"fm-gear-motion",children:rY.map(i=>r.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,className:sY[i.cell]},`g${i.y}-${i.x}`))})}),r.jsxs("g",{className:"fm-body",children:[oY.map(i=>r.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,fill:dr[i.cell]},`b${i.y}-${i.x}`)),_E.map(i=>r.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,fill:dr.f},`bed${i.x}`)),r.jsxs("g",{className:"fm-arms",fill:dr.f,children:[r.jsx("rect",{x:4,y:8,width:2,height:2}),r.jsx("rect",{x:12,y:8,width:1,height:2})]}),_E.map(i=>r.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:dr.n}},`e${i.x}`))]}),s&&r.jsxs("g",{className:"fm-grip",style:{fill:dr.f},children:[r.jsx("path",{className:"fm-grip-left",d:TP}),r.jsx("path",{className:"fm-grip-right",d:RP})]}),a&&r.jsxs("g",{className:"fm-crouch-legs",style:{fill:dr.f},children:[r.jsx("path",{d:"M6 11H8V13H6Z"}),r.jsx("path",{d:"M10 11H12V13H10Z"})]}),o&&r.jsxs("g",{className:"fm-seated-legs",style:{fill:dr.f},children:[r.jsx("path",{className:"fm-seated-far",style:{fill:dr.s},d:"M10 10H12V11H11V14H8V13H9V11H10Z"}),r.jsx("path",{d:"M6 10H9V11H7V15H4V14H5V11H6Z"})]}),["left","right"].map(i=>r.jsx("g",{className:"fm-leg","data-side":i,children:iY[i].map(c=>r.jsx("rect",{x:c.x,y:c.y,width:c.w,height:1,fill:dr[c.cell]},`${c.y}-${c.x}`))},i))]})}),cY=[".......dddd.......","......dhhhhd......",".....dhhhhhhd.....","....dhwwhhwwhd....","....dhwewwewhd....","....dhwwbbwwhd....","....dhwwwwwwhd....","....dhwwwwwwhd....","....dhwwwwwwhd....",".....dhwwwwhd.....",".....dhwwwwhd.....","......dhhhhd......","......bb..bb......",".....bbb..bbb....."],zr={d:"#3b4855",h:"#657b8b",w:"#f4f0df",e:"#19242b",b:"#f0b44b",s:"#c88736"},uY={p:"fm-pad"},pf=to(cY),dY=to(oj).filter(e=>ij.has(e.cell)),CE=pf.filter(e=>e.cell==="e"),hY=pf.filter(e=>e.y<12&&e.cell!=="e"),fY={left:pf.filter(e=>e.y>=12&&e.x<9),right:pf.filter(e=>e.y>=12&&e.x>=9)},pY=y.memo(function({act:t}){const n=t==="climb"||t==="rope-throw"||t==="rope-catch"||t==="pull-up",s=t==="land"||t==="dismount",a=t==="sit"||t==="cast"||t==="fish"||t==="reel"||t==="stow";return r.jsxs("svg",{"data-character":"penguin",viewBox:"0 0 18 14",shapeRendering:"crispEdges","aria-hidden":!0,focusable:"false",children:[r.jsx("g",{className:"fm-gear",children:r.jsx("g",{className:"fm-gear-motion",children:dY.map(o=>r.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,className:uY[o.cell]},`g${o.y}-${o.x}`))})}),r.jsxs("g",{className:"fm-body",children:[hY.map(o=>r.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,fill:zr[o.cell]},`b${o.y}-${o.x}`)),CE.map(o=>r.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,fill:zr.w},`bed${o.x}`)),r.jsxs("g",{className:"fm-arms",fill:zr.d,children:[r.jsx("path",{d:"M4 8H6V10H5V11H4Z"}),r.jsx("path",{d:"M12 8H14V11H13V10H12Z"})]}),CE.map(o=>r.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,className:"fm-eye",style:{fill:zr.e}},`e${o.x}`))]}),n&&r.jsxs("g",{className:"fm-grip",style:{fill:zr.h},children:[r.jsx("path",{className:"fm-grip-left",d:"M5 10H4V4H5V2H6V1H7V0H9V2H7V3H6V10Z"}),r.jsx("path",{className:"fm-grip-right",d:"M12 10H14V6H13V3H11V2H9V4H12Z"})]}),s&&r.jsxs("g",{className:"fm-crouch-legs",style:{fill:zr.b},children:[r.jsx("path",{d:"M5 12H8V13H5Z"}),r.jsx("path",{d:"M10 12H13V13H10Z"})]}),a&&r.jsxs("g",{className:"fm-seated-legs",style:{fill:zr.b},children:[r.jsx("path",{className:"fm-seated-far",style:{fill:zr.s},d:"M10 11H12V12H13V14H10V13H11V12H10Z"}),r.jsx("path",{d:"M6 11H8V12H7V13H8V14H4V13H5V12H6Z"})]}),["left","right"].map(o=>r.jsx("g",{className:"fm-leg","data-side":o,children:fY[o].map(i=>r.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,fill:zr.b},`${i.y}-${i.x}`))},o))]})});function AP({character:e,act:t,facing:n}){return e==="penguin"?r.jsx(pY,{act:t,facing:n}):e==="fox"?r.jsx(lY,{act:t,facing:n}):r.jsx(eY,{act:t,facing:n})}const mY={"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 MP(e,t){return t&&Nl(t.id)===e?t.name:cp(e)?"Custom FM":mY[e]}function Qg(e,t){var s;const n=((s=e[0])==null?void 0:s.length)??0;return r.jsx("svg",{viewBox:`0 0 ${n} ${e.length}`,shapeRendering:"crispEdges","aria-hidden":!0,children:to(e).map(a=>r.jsx("rect",{x:a.x,y:a.y,width:a.w,height:1,fill:a.cell==="s"?"var(--fm-prop-shadow, var(--bg))":a.cell==="l"?"var(--fm-prop-light, var(--text))":a.cell==="a"?"var(--accent)":void 0},`${t}${a.y}-${a.x}`))})}const EE={litter:Qg(Zg.litter,"litter"),ball:Qg(Zg.ball,"ball"),scope:Qg(Zg.scope,"scope")};function gY(e){try{return new URL(e).host}catch{return"the station's server"}}const yY=y.memo(function({player:t,source:n,customStation:s,character:a="deck"}){const{probe:o,dead:i,playing:c,press:d}=t,{scene:h,suspended:f,x:p,walkMs:m,act:w,prop:j,ballFlight:v,place:b,facing:k,riser:N,dance:S,beatMs:_}=YK(o,i,c);if(!o||i)return null;const E=MP(n,s),I=o.audio?gY(o.audio):"YouTube";return r.jsxs("div",{ref:h,className:"fm","data-suspended":f?"":void 0,"data-place":b,style:{"--fm-beat":`${_}ms`},children:[j&&!j.held&&r.jsx("div",{className:"fm-prop","data-prop":j.kind,"data-leaving":j.leaving?"":void 0,style:{"--fm-prop-x":`${j.at}px`,"--fm-roll-to":`${v.x}px`,"--fm-ball-drop":`${v.drop}px`,"--fm-ball-flight-ms":`${SP}ms`,"--fm-ball-turn":k==="right"?"1080deg":"-1080deg"},children:EE[j.kind]}),(w==="lasso"||w==="rope-throw"||w==="rope-catch"||w==="climb"||w==="pull-up")&&r.jsxs("div",{className:"fm-rope","data-act":w,style:{"--fm-rope-x":`${p}px`,"--fm-rope-ms":`${m}ms`},children:[r.jsx("div",{className:"fm-rope-line"}),r.jsxs("svg",{className:"fm-rope-hook",viewBox:"0 0 9 9",shapeRendering:"crispEdges","aria-hidden":!0,children:[r.jsx("path",{d:"M4 8V3H3V1H1V3H0V5H2V4H3V6H5V4H6V5H8V3H7V1H5V3H4"}),r.jsx("rect",{className:"fm-rope-knot",x:"3",y:"6",width:"3",height:"2"})]})]}),r.jsxs("div",{className:"fm-walker","data-act":w??void 0,"data-place":b,"data-facing":k,style:{"--fm-x":`${p}px`,"--fm-walk-ms":`${m}ms`,"--fm-riser":`${N}px`,"--fm-skip-beat":`${_P}ms`},children:[(j==null?void 0:j.held)&&r.jsx("div",{className:"fm-held","data-prop":j.kind,"data-toss":j.leaving?"":void 0,children:EE[j.kind]}),["cast","fish","reel","stow"].includes(w)&&r.jsxs("svg",{className:"fm-fishing",viewBox:"0 0 24 32",shapeRendering:"crispEdges","aria-hidden":!0,children:[r.jsxs("g",{children:[r.jsx("path",{d:"M24 11H22V9H20V7H18V5H16V3H13V2H8"}),r.jsx("rect",{className:"fm-fishing-grip",x:"21",y:"9",width:"3",height:"3"})]}),r.jsxs("g",{className:"fm-fishing-line",children:[r.jsx("path",{d:"M8 2V26"}),r.jsxs("g",{className:"fm-float",children:[r.jsx("rect",{x:"7",y:"25",width:"3",height:"2"}),r.jsx("rect",{x:"8",y:"24",width:"1",height:"1"})]})]}),r.jsx("path",{className:"fm-ripple",d:"M3 28H6M10 28H14M5 30H12"})]}),["skip-ready","skip","skip-rest"].includes(w)&&r.jsxs("svg",{className:"fm-skipping-rope",viewBox:"0 0 26 26",shapeRendering:"crispEdges","aria-hidden":!0,children:[r.jsx("path",{className:"fm-skip-back",d:"M5 18H3V8H5V5H8V2H18V5H21V8H23V18H21"}),r.jsx("path",{className:"fm-skip-forward",d:"M5 18H3V14H5V11H8V9H18V11H21V14H23V18H21"}),r.jsx("path",{className:"fm-skip-front",d:"M5 18H3V21H5V23H8V25H18V23H21V21H23V18H21"}),r.jsx("path",{className:"fm-skip-return",d:"M5 18H3V19H8V20H18V19H23V18H21"}),r.jsx("path",{className:"fm-skip-handles",d:"M5 17V19M21 17V19"})]}),r.jsx("button",{type:"button",className:"fm-sprite","data-playing":c?"":void 0,"data-dance":c?S??CP[0]:void 0,onClick:d,title:c?`Stop ${E}`:`Play ${E} — streams from ${I}`,"aria-label":c?`Stop ${E}`:`Play ${E}`,children:r.jsx(AP,{character:a,act:w,facing:k})})]})]})});function wY({player:e,label:t}){const{probe:n,armed:s,frame:a,say:o}=e;return n?r.jsx(r.Fragment,{children:s&&!n.audio&&(n.channel||n.video)&&r.jsx("iframe",{ref:a,className:"fm-frame",title:t,src:VG(n.channel,window.location.origin,n.video),onLoad:()=>o(GG()),allow:"autoplay; encrypted-media",sandbox:"allow-scripts allow-same-origin allow-presentation"})}):null}const xY={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 vY({name:e}){return r.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:r.jsx("path",{d:xY[e]})})}function bY({opening:e=!1}){const[t,n]=y.useState(()=>document.hidden);return y.useEffect(()=>{const s=()=>n(document.hidden);return document.addEventListener("visibilitychange",s),()=>document.removeEventListener("visibilitychange",s)},[]),r.jsxs("div",{className:"radio-tuning",role:"status","data-paused":t||void 0,children:[r.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:[r.jsxs("g",{className:"radio-tuning-tower",children:[r.jsx("circle",{cx:"40",cy:"24",r:"4"}),r.jsx("path",{d:"M40 28v60 M40 36L24 88h32L40 36 M31 66h18 M28 77h24 M20 92h40"}),r.jsx("path",{d:"M29 17a15 15 0 0 0 0 14 M51 17a15 15 0 0 1 0 14"})]}),r.jsxs("g",{className:"radio-tuning-send",children:[r.jsx("path",{d:"M75 26q7 8 0 16"}),r.jsx("path",{d:"M102 26q7 8 0 16"}),r.jsx("path",{d:"M129 26q7 8 0 16"})]}),r.jsxs("g",{className:"radio-tuning-receiver",children:[r.jsx("path",{d:"M165 49l30-22"}),r.jsx("rect",{x:"154",y:"49",width:"66",height:"43",rx:"7"}),r.jsx("path",{d:"M161 92v3 M213 92v3 M163 60h17 M163 66h17 M163 72h17 M163 78h17"}),r.jsx("circle",{cx:"202",cy:"65",r:"7"}),r.jsx("path",{d:"M202 62v3l3 2 M197 81h10"})]})]}),r.jsx("strong",{children:e?"Opening Radio":"Tuning into the world"}),r.jsx("span",{children:e?"Getting your explorer ready…":"Finding stations…"})]})}function kY({onClose:e}){const[t]=y.useState(()=>{var s;return((s=document.activeElement)==null?void 0:s.matches(":focus-visible"))??!1}),n=mt(e);return r.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:P9,children:[r.jsx("button",{type:"button",className:"icon-btn","aria-label":"Close radio",onClick:e,children:r.jsx(vY,{name:"close"})}),r.jsx(bY,{opening:!0})]})}const jY=y.lazy(()=>Du(()=>import("./RadioPanel-DNB_AHSs.js"),[]));function NY({fm:e,characterEnabled:t,character:n,open:s,onClose:a}){const[o,i]=y.useState(!1),[c,d]=y.useState("Connecting to the deck…"),h=sK(),[f,p]=y.useState(null),m=y.useRef(new Set);y.useEffect(()=>{const A=new AbortController;return fetch("/api/music-config",{signal:A.signal}).then(O=>O.ok?O.json():null).then(O=>{A.signal.aborted||(i((O==null?void 0:O.enabled)===!0),d(O?"Music is turned off on this deck.":"Cannot reach the deck. Reopen Radio when it reconnects."))}).catch(()=>{A.signal.aborted||d("Cannot reach the deck. Reopen Radio when it reconnects.")}),()=>A.abort()},[s]);const w=e.customFmStations.find(A=>Nl(A.id)===e.fmSource),j=w!=null&&w.radio?w:void 0,v=eK({volume:e.fmVolume,muted:e.fmMuted,source:e.fmSource,playRequest:e.fmPlayRequest,customStation:w,enabled:o,onAvailabilityChange:e.markFmStationAvailability}),b=MP(e.fmSource,w),k=o&&j&&v.dead&&e.fmPlayRequest>0?jP(f??h.catalogue,j.id,m.current):null,{remember:N}=h,S=(w==null?void 0:w.id)??e.fmSource;y.useEffect(()=>{v.playing&&N(S)},[S,v.playing,N]);const _=a,E=yt(a),I=y.useCallback((A,O=!1)=>{var T;if(!o)return;O||m.current.clear();const L=Nl(A.id),U=L===e.fmSource;if(U&&v.armed&&!v.dead){v.press();return}const P=U&&!!w&&(w.url!==A.url||((T=w.radio)==null?void 0:T.hls)!==A.radio.hls);e.addFmStation(A,!0),U&&!v.dead&&!P?v.press():e.pickFmSource(L,P),fetch(`/api/radio-click?id=${encodeURIComponent(A.id)}`).catch(()=>{})},[o,w,e.addFmStation,e.fmSource,e.pickFmSource,v.armed,v.dead,v.press]);return y.useEffect(()=>{v.playing&&!v.dead&&m.current.clear()},[v.playing,v.dead]),y.useEffect(()=>{if(!(!o||!j||!v.dead||e.fmPlayRequest===0))return rK(f??h.catalogue,j.id,m.current,A=>I(A,!0))},[o,j==null?void 0:j.id,v.dead,e.fmPlayRequest,f,h.catalogue,I]),r.jsxs(r.Fragment,{children:[t&&r.jsx(yY,{character:n,player:v,source:e.fmSource,customStation:w}),r.jsx(wY,{player:v,label:b}),s&&vt.createPortal(r.jsx("div",{className:"modal-backdrop radio-backdrop",...E,children:r.jsx(y.Suspense,{fallback:r.jsx(kY,{onClose:_}),children:r.jsx(jY,{fm:e,player:v,library:h,selected:j,label:b,enabled:o,disabledReason:c,autoNext:k==null?void 0:k.name,onPick:I,onQueueChange:p,onClose:_})})}),document.body)]})}function SY({data:e}){const t=jr(3e4),n=e.note,s=n.kind==="recap",a=uf(n.at,t),o=s?"recap-note":`recap-note is-status status-${n.kind}`,i=s?void 0:op(n);return r.jsxs("div",{className:o,role:"note","aria-label":s?"Claude Code's recap":`Session note: ${Ha(n.kind)}`,"aria-description":i,style:{"--session-hue":e.hue},children:[r.jsxs("div",{className:"recap-note-head",title:i,children:[r.jsxs("span",{className:"recap-note-mark",children:[r.jsx(lf,{recap:s}),Ha(n.kind)]}),r.jsx("span",{className:"recap-note-age",title:a.title,children:a.label}),r.jsx("button",{type:"button",className:"glyph-btn recap-note-close","aria-label":s?"Hide the recap":"Hide this note",title:"Hide — the mark on the card brings it back",onClick:c=>{c.stopPropagation(),oV(e.noteKey)},children:"×"})]}),r.jsx("p",{className:"recap-note-text",title:yV(n.text,i),children:n.text}),n.reply&&r.jsxs("p",{className:"recap-note-reply",title:`suggested reply “${n.reply}”`,children:["suggested reply “",n.reply,"”"]}),r.jsxs("div",{className:"lod-face recap-face","aria-hidden":!0,children:[r.jsxs("div",{className:"lod-id",children:[r.jsxs("span",{className:"recap-note-mark",children:[r.jsx(lf,{recap:s}),Ha(n.kind)]}),r.jsx("span",{className:"recap-face-age",children:a.label})]}),r.jsx("p",{className:"recap-face-text",children:n.text})]}),r.jsx(Ko,{type:"source",position:Fe.Right,style:{background:"transparent",border:"none"}})]})}function Fu(){var t;return typeof navigator>"u"?"":((t=navigator.userAgentData)==null?void 0:t.platform)||navigator.platform||""}function Bu(e){return/mac|iphone|ipad/i.test(e)}const mf=e=>new Map([...e].map(([t,n])=>[t,{x:n.x,y:n.y}]));function _Y(e,t,n){return{positions:mf(e.positions),pinned:mf(e.pinned),provisional:new Set(e.provisional),layoutSig:e.layoutSig.current,stored:{...t},viewport:n?{...n}:null}}function CY(e,t){t.positions.clear();for(const[n,s]of mf(e.positions))t.positions.set(n,s);t.pinned.clear();for(const[n,s]of mf(e.pinned))t.pinned.set(n,s);t.provisional.clear();for(const n of e.provisional)t.provisional.add(n);t.layoutSig.current=e.layoutSig}const TE=7e3,EY=2e3,TY=140,RY="Layout re-arranged",AY="Layout re-arranged. Undo available.",RE="Layout restored.",MY={set:(e,t)=>setTimeout(e,t),clear:e=>clearTimeout(e),now:()=>Date.now()};function $Y(e,t=MY){let n=null,s=null,a=0,o=TE;const i=new Set,c=()=>{s!==null&&t.clear(s),s=null},d=()=>{c(),!(n===null||i.size>0)&&(a=t.now()+o,s=t.set(()=>{s=null,h()},o))};function h(){c(),i.clear(),n!==null&&(n=null,e(!1))}return{open(f){const p=n===null;n=f,o=TE,d(),p&&e(!0)},take(){const f=n;return h(),f},close:h,hold(f){n!==null&&(i.size===0&&s!==null&&(o=Math.max(0,a-t.now()),c()),i.add(f))},release(f){!i.delete(f)||i.size>0||n===null||(o=Math.max(o,EY),d())},get isOpen(){return n!==null},get snapshot(){return n}}}function LY(e){return(e.key==="z"||e.key==="Z")&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey}function IY(e){return Bu(e)?"⌘Z":"Ctrl+Z"}function OY({undo:e}){const{open:t,said:n,undo:s,dismiss:a,hold:o,release:i}=e,c=Qi(t,TY),d=y.useRef(null);return y.useEffect(()=>t?Tn.push(a,0,"popover"):void 0,[t,a]),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]),r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:n}),Ba(c)&&r.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:[r.jsx("span",{id:"rearrange-undo-state",className:"rearrange-undo-state",children:RY}),r.jsxs("button",{type:"button",className:"rearrange-undo-act",onClick:s,"aria-describedby":"rearrange-undo-state","aria-keyshortcuts":"Meta+Z Control+Z",children:["Undo",r.jsx("span",{className:"rearrange-undo-key","aria-hidden":"true",children:IY(Fu())})]})]})]})}function PY({sourceX:e,sourceY:t,targetX:n,targetY:s,sourcePosition:a,targetPosition:o,style:i}){const[c]=R1({sourceX:e,sourceY:t,sourcePosition:a,targetX:n,targetY:s,targetPosition:o,curvature:.35});return r.jsxs("g",{className:"recap-tie",style:i,children:[r.jsx("path",{className:"recap-tie-thread",d:c,vectorEffect:"non-scaling-stroke"}),r.jsx("path",{className:"recap-tie-beads",d:c,vectorEffect:"non-scaling-stroke"}),r.jsx("circle",{className:"recap-tie-end",cx:e,cy:t,r:3.5}),r.jsx("circle",{className:"recap-tie-end",cx:n,cy:s,r:3.5})]})}function k0(e){return e.replace(/[^a-zA-Z0-9]/g,"")}function gf(e,t){const n=k0(e);return n?n.slice(-t):e.slice(-t)}function $P(e,t,n=4){const s=k0(e);if(!s)return gf(e,n);let a=n;for(const o of t){if(o===e)continue;const i=k0(o);let c=0;for(;c<s.length&&c<i.length&&s[s.length-1-c]===i[i.length-1-c];)c++;a=Math.max(a,c+1)}return s.slice(-a)}const Yc=" · ",DY=32,FY=/[\u1100-\u115F\u2E80-\u303E\u3041-\u33FF\u3400-\u4DBF\u4E00-\u9FFF\uA000-\uA4CF\uAC00-\uD7A3\uF900-\uFAFF\uFE30-\uFE6F\uFF00-\uFF60\uFFE0-\uFFE6]/;function AE(e){return FY.test(e)?2:1}function ME(e,t=DY){const n=[...e];let s=0;for(const i of n)s+=AE(i);if(s<=t)return e;const a=[];let o=0;for(const i of n){const c=AE(i);if(o+c>t-1)break;a.push(i),o+=c}for(;a.length&&/[\s\-_.:/]/.test(a[a.length-1]);)a.pop();return`${a.join("")}…`}function BY(e,t,n,s,a=[],{branch:o,alarm:i=!1}={}){const c=(t==null?void 0:t.trim())??"",d=s?$P(n,a):void 0,h=[e,c||void 0,d].filter(Boolean),f=[e,o,c||void 0,d].filter(Boolean).join(Yc);return{label:ME(e),name:c?ME(c):void 0,shortId:d,fullLabel:h.join(Yc),title:`${i?"waiting on you: ":""}${f}
|
|
90
|
+
Zoom to this session
|
|
91
|
+
drag the wrapper to move the whole session`}}const Oo=18,j0=26,lj=12,gu=240,LP=130,N0=Oo*2+j0+lj,qY=72,cl=N0+qY,Fh=24,IP=Oo*2+Fh,yf=cl;function OP(e,t){var s;let n=gu;for(const a of e)n=Math.max(n,((s=t.get(a.id))==null?void 0:s.width)??gu);return n}const wf=420,PP=1;function UY(e,t,n,s){return Math.min(PP,n/Math.max(1,e),s/Math.max(1,t))}function Xn(e){const t=e.data;return(t==null?void 0:t.canvasSessionId)??(t==null?void 0:t.sessionId)??"_default"}function dp(e,t=()=>!0){const n=new Map;for(const s of e){if(!t(s))continue;const a=Xn(s),o=n.get(a);o?o.push(s):n.set(a,[s])}return n}function WY(e,t){return((t==null?void 0:t.get(e))??0)>0?wf:0}function HY(e,t){const n=(t==null?void 0:t.get(e))??0;return n>0?6+n*36:0}function xf(e,t){const n=t.get(e);return{w:(n==null?void 0:n.width)??gu,h:(n==null?void 0:n.height)??LP}}function yu(e,t,n){const s=xf(e,t);return{w:s.w+WY(e,n),h:Math.max(s.h,HY(e,n))}}function zY(e){return[...e.keys()].sort().map(t=>`${t}:${e.get(t)}`).join("|")}const VY=240,DP=16;function FP(e,t){return(e+VY)*(t||1)}function GY(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 KY(e,t,n,s){return{position:"absolute",left:e.x+DP,top:e.y-lj/(t||1),transform:`scale(${1/(t||1)})`,transformOrigin:"left top",maxWidth:s??FP(e.w,t),"--session-hue":n}}function YY(e){const t=new Map;for(const a of e){if(a.type!=="agent"&&a.type!=="recapNote")continue;const o=a.data;if(!(o!=null&&o.sessionId)||o.exitAt!=null||a.width==null||a.height==null)continue;const i=a.position.x,c=a.position.y,d=i+a.width,h=c+a.height,f=t.get(Xn(a)),p=o.canvasSessionId&&o.canvasSessionId!==o.sessionId?null:XY(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(Xn(a),{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[a,o]of t){const i=n.get(o.label);i?i.push(a):n.set(o.label,[a])}const s=[];for(const[a,o]of t){const i=n.get(o.label)??[],c=i.length>1;s.push({sessionId:a,...BY(o.label,o.name,a,c,i,{branch:o.branch,alarm:o.alarm}),x:o.minX-Oo,y:o.minY-Oo-j0,w:o.maxX-o.minX+Oo*2,h:o.maxY-o.minY+Oo*2+j0,...o.alarm?{alarm:!0}:null,...o.branch?{branch:o.branch}:null})}return s}function XY(e){if(e.kind!=="root")return null;const t=e.branch;return{label:e.label,name:sp(e.sessionName,e.sessionTitle).face,alarm:Mn(e.waiting),branch:t&&t.total>0?Q3(t):void 0}}function ZY(e,t){if(e.length!==t.length)return!1;for(let n=0;n<e.length;n++){const s=e[n],a=t[n];if(s.sessionId!==a.sessionId||s.label!==a.label||s.name!==a.name||s.shortId!==a.shortId||s.alarm!==a.alarm||s.branch!==a.branch||s.fullLabel!==a.fullLabel||s.title!==a.title||s.x!==a.x||s.y!==a.y||s.w!==a.w||s.h!==a.h)return!1}return!0}const JY=20,Vr=4,QY=64,eX=".cat-filter-bar, .react-flow__panel, .autofit-chip, .rearrange-undo, .usage-panel, .sysdetail, .detail";function tX(e,t,n,s){const a=t.zoom||1,o=FP(e.w,a);if(n.width<=0||n.height<=0)return{maxWidth:o,hidden:!1};const i=(e.x+DP)*a+t.x,c=e.y*a+t.y-lj,d=c+JY;let h=Math.min(o,n.width-Vr-i),f=i<Vr||c<Vr||d>n.height-Vr;for(const p of s)if(!(p.top-Vr>=d||p.bottom+Vr<=c)&&!(p.right+Vr<=i)){if(p.left-Vr<=i){f=!0;break}h=Math.min(h,p.left-Vr-i)}return h<QY&&(f=!0),{maxWidth:Math.max(0,h),hidden:f}}function nX(e){const t=e.getBoundingClientRect(),n=[];for(const s of e.ownerDocument.querySelectorAll(eX)){const a=s.getBoundingClientRect(),o=Math.max(a.left,t.left)-t.left,i=Math.max(a.top,t.top)-t.top,c=Math.min(a.right,t.right)-t.left,d=Math.min(a.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 sX(e,t){return e.length===t.length&&e.every((n,s)=>{const a=t[s];return n.left===a.left&&n.top===a.top&&n.right===a.right&&n.bottom===a.bottom})}const rX=500;function BP({focus:e,setTimeout:t,clearTimeout:n,ms:s=rX}){let a=null;const o=()=>{a!==null&&(n(a),a=null)};return{hold(i){o(),a=t(()=>{a=null;try{e(i)}catch{}},s)},cancel:o}}function aX(e){return YY(e.nodeInternals.values())}const oX=e=>e.width,iX=e=>e.height,lX=e=>{var t;return((t=e.domNode)==null?void 0:t.querySelector(".react-flow__viewport"))??null};function cX({onFocusSession:e}){const{x:t,y:n,zoom:s}=GO(),a=at(aX,ZY),o=at(oX),i=at(iX),c={width:o,height:i},d=y.useRef(null),h=at(lX),[f,p]=y.useState([]);y.useLayoutEffect(()=>{var I;const S=(I=d.current)==null?void 0:I.parentElement;if(!S)return;const _=nX(S),E=requestAnimationFrame(()=>{p(A=>sX(A,_)?A:_)});return()=>cancelAnimationFrame(E)});const m=y.useRef(e);m.current=e;const[w]=y.useState(()=>BP({focus:S=>{var _;return(_=m.current)==null?void 0:_.call(m,S)},setTimeout:(S,_)=>window.setTimeout(S,_),clearTimeout:S=>window.clearTimeout(S)}));if(y.useEffect(()=>()=>w.cancel(),[w]),a.length<=1)return null;const j=S=>{try{e==null||e(S)}catch{}},v=(S,_)=>{S.detail>0&&$u()?w.hold(_):j(_)},b={transform:`translate(${t}px, ${n}px) scale(${s})`},k=r.jsx("div",{className:"session-clusters",style:b,ref:d,children:a.map(S=>{const _=hu(S.sessionId),E=GY(S,_);return r.jsx("div",{className:"cluster-card",style:E,"aria-hidden":!0},S.sessionId)})}),N=h&&vt.createPortal(r.jsx("div",{className:"cluster-labels nopan",children:a.map(S=>{const _=hu(S.sessionId),E=tX(S,{x:t,y:n,zoom:s},c,f),I=KY(S,s,_,E.maxWidth);return r.jsxs("button",{type:"button",className:"cluster-label","data-alarm":S.alarm?"":void 0,"data-offpane":E.hidden?"":void 0,style:I,title:S.title,onClick:A=>v(A,S.sessionId),children:[S.alarm?r.jsxs(r.Fragment,{children:[r.jsx(J1,{}),r.jsx("span",{className:"cluster-label-said",children:"waiting on you: "})]}):null,S.label,S.branch?r.jsx("span",{className:"cluster-label-branch",children:Yc+S.branch}):null,S.name?r.jsx("span",{className:"cluster-label-name",children:Yc+S.name}):null,S.shortId?r.jsx("span",{className:"cluster-label-id",children:Yc+S.shortId}):null]},S.sessionId)})}),h);return r.jsxs(r.Fragment,{children:[k,N]})}function uX({data:e}){return r.jsx("div",{className:"session-group-handle",style:{width:(e==null?void 0:e.w)??0,height:(e==null?void 0:e.h)??0}})}const qP=600,dX=4,hX=36,vf=14,fX=60,pX=6,$E=220,mX=96,gX=28;function yX(e,t){return Math.max(mX,61+[...t].length*6.8)}function wX(e){return e.endedAt==null?"inflight":e.ok===!1?"err":"done"}function xX(e,t){if(t==null)return 1;const n=e-t;return n<0?1:Math.max(0,1-n/qP)}function vX(e,t){const n=[],s=new Set;for(let a=e.length-1;a>=0&&n.length<t;a--){const o=e[a];s.has(o.id)||(s.add(o.id),n.push(o))}return n.reverse()}function bX(e,t,n,s,a,o){const i=[];for(const c of e.values()){if(!t.has(c.id)||c.exitAt!=null&&o-c.exitAt>qP)continue;const d=s.get(c.id)??n.get(c.id);if(!d)continue;const h=vX(c.tools,dX);if(h.length===0)continue;const f=c.exitAt??null,p=a.get(c.id),m=Math.max((p==null?void 0:p.width)??$E,$E),w=(p==null?void 0:p.height)??130,j=d.x,v=d.y,b=j+m,k=v+w/2;h.forEach((N,S)=>{const _=S*hX,E=j+m+fX,I=v+pX+_,A=xX(o,f),O=N.inputPreview??"",L=wX(N),U=A<.999,P=Z1(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:L,category:eP(N.name),mcpHue:P.hue,inputPreview:O,fade:A,fading:U,worldX:E,worldY:I,anchorX:b,anchorY:k,spawnDx:b-E,spawnDy:k-(I+vf)});const T=rP(N.name,N.input);if(T){const B=yX(N.name,P.label),M=E+B+gX,q=I,$=E+B,K=I+vf;i.push({id:`sub:${c.id}::${N.id}`,toolId:N.id,agentId:c.id,toolName:N.name,name:zV(T.label,T.category),fullName:T.label,emoji:T.emoji,isSub:!0,status:L,category:T.category,inputPreview:T.detail??O,fade:A,fading:U,worldX:M,worldY:q,anchorX:$,anchorY:K,spawnDx:$-M,spawnDy:0})}})}return i}function kX({agents:e,visibleAgentIds:t,positions:n,pinned:s,measured:a,spotlight:o,hiddenCategories:i,now:c,onOpenTool:d}){const h=bX(e,t,n,s,a,c),f=i&&i.size>0?h.filter(p=>!i.has(p.category)):h;return r.jsx(jX,{bursts:f,spotlight:o,onOpenTool:d})}function jX({bursts:e,spotlight:t,onOpenTool:n}){const s=e.map(o=>{const i=o.anchorX,c=o.anchorY,d=o.worldX+6,h=o.worldY+vf,f=Math.max(1,d-i),p=Math.min(1,Math.abs(h-c)/f),m=i+f*(.55-.22*p),w=c+(h-c)*.12,j=d-f*.25,v=t!=null&&!t.has(o.agentId),b=o.fade*(v?.14:1);return r.jsx("path",{d:`M ${i} ${c} C ${m} ${w}, ${j} ${h}, ${d} ${h}`,className:`tool-conn status-${o.status}${o.fading?" fading":""}`,opacity:b,vectorEffect:"non-scaling-stroke"},`l:${o.id}`)}),a=e.map(o=>r.jsx(_X,{b:o,dim:t!=null&&!t.has(o.agentId),onOpenTool:n},o.id));return r.jsx(NX,{connectors:s,bubbles:a})}function NX({connectors:e,bubbles:t}){const{x:n,y:s,zoom:a}=GO();return r.jsxs("div",{className:"tool-bursts-layer","aria-hidden":!0,style:{"--tool-burst-height":`${2*vf}px`},children:[r.jsx("svg",{className:"tool-bursts-svg",children:r.jsx("g",{transform:`translate(${n} ${s}) scale(${a})`,children:e})}),r.jsx("div",{className:"tool-bursts-world",style:{transform:`translate(${n}px, ${s}px) scale(${a})`},children:t})]})}function SX(e,t){const n=e.b,s=t.b;return e.dim===t.dim&&e.onOpenTool===t.onOpenTool&&n.id===s.id&&n.toolId===s.toolId&&n.worldX===s.worldX&&n.worldY===s.worldY&&n.spawnDx===s.spawnDx&&n.spawnDy===s.spawnDy&&n.status===s.status&&n.fading===s.fading&&n.category===s.category&&n.mcpHue===s.mcpHue&&n.isSub===s.isSub&&n.emoji===s.emoji&&n.name===s.name&&n.fullName===s.fullName&&n.toolName===s.toolName&&n.inputPreview===s.inputPreview}const _X=y.memo(function({b:t,dim:n,onOpenTool:s}){const a={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=s!=null,d=t.mcpHue!=null?{"--mcp-hue":t.mcpHue}:{},h=n?" dim":"";return r.jsx("div",{className:"tool-burst-wrap",style:a,children:r.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?()=>s(t.agentId,t.toolId):void 0,children:[r.jsx("span",{className:"tb-emoji",children:t.emoji}),r.jsx("span",{className:"tb-name",children:t.name}),t.status==="inflight"&&r.jsx("span",{className:"tb-spin"}),t.status==="done"&&r.jsx("span",{className:"tb-mark done",children:"✓"}),t.status==="err"&&r.jsx("span",{className:"tb-mark err",children:"×"})]})})},SX),CX={width:140,height:105},EX={agent:mG,sessionGroup:uX,recapNote:SY},TX={recapTie:PY},LE=400;function RX({graph:e,layout:t,viewport:n,clicks:s,drag:a,appearance:o,fm:i,radioOpen:c,onRadioClose:d,autoFit:h,pause:f,stateRef:p,measuredRef:m,hiddenCats:w,now:j,openTool:v,focusAgent:b,requestClear:k,setKeyHelpOpen:N}){const{allNodes:S,edges:_,visibleAgentIds:E,spotlightSet:I}=e,{positionsRef:A,pinnedRef:O,handleRelayout:L,rearrangeUndo:U}=t,{restoredViewport:P,onMoveStart:T,onMove:B}=n,{onNodeClick:M,onPaneClick:q,onNodeDoubleClick:$,onNodeMouseEnter:K,onNodeMouseLeave:G}=s,{onNodeDragStart:z,onNodeDrag:W,onNodeDragStop:D}=a,{palette:H,minimapNodeFill:ee,characterEnabled:F}=o,{autoFitDisabled:Y,enableAutoFitAndRefit:X}=h,{paused:Z,pauseGate:J,togglePause:ne}=f;return r.jsxs(VO,{nodes:S,edges:_,nodeTypes:EX,edgesFocusable:!1,edgeTypes:TX,fitView:!P,fitViewOptions:{padding:.25,duration:o0({durationMs:LE,documentHidden:document.hidden})?LE:0},minZoom:JO,maxZoom:QO,panOnScroll:!0,panActivationKeyCode:null,nodesDraggable:!0,nodesConnectable:!1,selectionOnDrag:!1,nodeDragThreshold:5,disableKeyboardA11y:!0,deleteKeyCode:null,onNodeClick:M,onPaneClick:q,onNodeDoubleClick:$,onNodeMouseEnter:K,onNodeMouseLeave:G,onMoveStart:T,onMove:B,onNodeDragStart:(ce,he,le)=>{U.dismiss(),z(ce,he,le)},onNodeDrag:W,onNodeDragStop:D,children:[r.jsx(vz,{gap:28,size:1,color:H["--grid-line"]}),r.jsx(cX,{onFocusSession:b}),r.jsx(kX,{agents:p.current.agents,visibleAgentIds:E,positions:A.current,pinned:O.current,measured:m.current,spotlight:I,hiddenCategories:w,now:j,onOpenTool:v}),r.jsxs("div",{className:"canvas-notices",children:[Y&&r.jsx(jG,{enableAutoFitAndRefit:X}),r.jsx(OY,{undo:U})]}),r.jsx(LG,{autoFitDisabled:Y,enableAutoFitAndRefit:X,paused:Z,pauseGate:J,togglePause:ne,handleRelayout:L,requestClear:k,setKeyHelpOpen:N}),r.jsx(iz,{style:CX,zoomable:!0,pannable:!0,nodeColor:ee,nodeStrokeWidth:2,maskColor:H["--minimap-mask"],maskStrokeColor:H["--line"]}),r.jsx(NY,{fm:i,character:o.character,characterEnabled:F,open:c,onClose:d})]})}function AX(){const e=window.ccdeckWindow;return y.useEffect(()=>{if(!e)return;const t=()=>{const s=document.querySelector(".topbar");if(!s)return;const a=getComputedStyle(s),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(a.backgroundColor),symbolColor:o(a.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:r.jsx("button",{type:"button",className:"desktop-menu btn","aria-label":"Application menu",title:"Application menu","aria-haspopup":"menu",onClick:()=>{e.menu().catch(()=>{})},children:r.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none","aria-hidden":"true",children:r.jsx("path",{d:"M3 4h10M3 8h10M3 12h10",stroke:"currentColor",strokeWidth:"1.25",strokeLinecap:"round"})})})}function MX(e){const t={input:0,output:0,cacheRead:0,cacheWrite:0,total:0};let n=0,s=0,a=0,o=0;for(const i of e){const c=On(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,s+=i.usage.outputTokens,a+=i.usage.cacheReadTokens,o+=i.usage.cacheCreateTokens}return{cost:t,inputTokens:n,outputTokens:s,cacheReadTokens:a,cacheCreateTokens:o,sum:n+s}}const $X="spend on this board",LX="on this board",UP=`Everything on the board right now, and only that.
|
|
92
|
+
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.
|
|
93
|
+
`,IX=UP+"Press H for the totals ccusage reads off the logs on disk, which do not forget.";function IE(e){return e?IX:UP+"Usage history has the totals ccusage reads off the logs on disk, which do not forget."}const WP="session spend",S0="__unknown__",OX=12;function PX(e,t=Date.now()){const n=new Map;for(const s of e)for(const a of Tl(s)){const o=a.model??S0,i=Jf(a.usage,a.model,t),c=c0({model:a.model,usage:a.usage},t),d=n.get(o);d?(d.inputTokens+=a.usage.inputTokens,d.outputTokens+=a.usage.outputTokens,d.cacheReadTokens+=a.usage.cacheReadTokens,d.cacheCreateTokens+=a.usage.cacheCreateTokens,d.cost.total+=i.total,d.cost.input+=i.input,d.cost.output+=i.output,d.cost.cacheRead+=i.cacheRead,d.cost.cacheWrite+=i.cacheWrite,d.agentCount++,d.priced=d.priced&&c):n.set(o,{model:o,inputTokens:a.usage.inputTokens,outputTokens:a.usage.outputTokens,cacheReadTokens:a.usage.cacheReadTokens,cacheCreateTokens:a.usage.cacheCreateTokens,cost:{...i},agentCount:1,priced:c})}return Array.from(n.values()).sort((s,a)=>a.cost.total-s.cost.total||a.inputTokens+a.outputTokens-(s.inputTokens+s.outputTokens))}function DX(e,t=Date.now()){const n=[...e],s=[];for(const a of n){if(a.kind!=="root")continue;let o=On(a,t).total,i=a.usage.inputTokens,c=a.usage.outputTokens,d=yl(a,t),h=c0(a,t);for(const f of n)f.sessionId!==a.sessionId||f.kind==="root"||(o+=On(f,t).total,i+=f.usage.inputTokens,c+=f.usage.outputTokens,d+=yl(f,t),h=h&&c0(f,t));s.push({priced:h,sessionId:a.sessionId,label:a.label||a.cwdBasename||"session",state:a.state,cost:o,inputTokens:i,outputTokens:c,unpricedTokens:d})}return s.sort((a,o)=>o.cost-a.cost||o.inputTokens+o.outputTokens-(a.inputTokens+a.outputTokens)).slice(0,OX)}const FX=600;function hp(e,t){return!(e.exitAt!=null&&t-e.exitAt>FX||e.kind==="root"&&e.state==="done"&&e.tools.length===0&&e.endedAt!=null&&e.endedAt-e.startedAt<3e3&&!e.stopFailure)}function BX(e,t){const n=new Set;for(const s of e.agents.values())hp(s,t)&&n.add(s.id);return n}function qX(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 UX(e,t,n=0){if(!e)return!1;for(const s of t)if(qX(e,s,n))return!0;return!1}function OE(e){return e.waiting?Mn(e.waiting)?0:1:e.state==="active"?2:3}function WX(e,t){var s;const n=[];for(const a of e.agents.values()){if(a.kind!=="root")continue;let o=a.toolCount,i=On(a).total,c=a.endedAt??a.startedAt;for(const p of e.agents.values()){if(p.sessionId!==a.sessionId||p.kind==="root")continue;o+=p.toolCount,i+=On(p).total;const m=p.endedAt??p.startedAt;m>c&&(c=m)}const d=ap(a),h=(d==null?void 0:d.kind)==="recap"?{text:d.text,at:d.at}:null,f=d&&d.kind!=="recap"?d:null;n.push({sessionId:a.sessionId,label:a.label||a.cwdBasename||"session",cwdBasename:a.cwdBasename,state:il(a),waiting:a.waiting,recap:h,status:f,modelId:a.model,effort:a.effort,plan:Lu(a.plan),planTitle:w3(((s=a.plan)==null?void 0:s.items)??[]),toolCount:o,cost:i,startedAt:a.startedAt,lastActivity:c})}return n.sort((a,o)=>{const i=OE(a),c=OE(o);return i!==c?i-c:a.waiting&&o.waiting?a.waiting.since-o.waiting.since:o.lastActivity-a.lastActivity}),n}function HX(e){return[e.text,e.reply?`Suggested reply: ${e.reply}`:"",op(e)].filter(Boolean).join(`
|
|
94
|
+
`)}function bf(e,t,n){const s=(t??n)-e;if(s<1e3)return"<1s";const a=Math.floor(s/1e3);if(a<60)return`${a}s`;const o=Math.floor(a/60);return o<60?`${o}m`:`${Math.floor(o/60)}h ${o%60}m`}function zX({state:e,now:t,selectedIds:n,onSelect:s,onClose:a,removedIds:o,onBringBackAll:i,leaving:c=!1}){const d=Pn(),h=y.useMemo(()=>WX(e),[e,e.revision,t]),f=h.filter(m=>m.state==="active").length,p=h.filter(m=>Mn(m.waiting)).length;return r.jsxs("aside",{className:`session-list${c?" leaving":""}`,id:"session-list","aria-label":"Sessions",children:[r.jsxs("div",{className:"sl-header",children:[r.jsxs("h2",{children:["Sessions ",r.jsx("span",{className:"sl-count",children:h.length})]}),p>0&&r.jsxs("span",{className:"sl-waiting-count",children:[p," waiting"]}),f>0&&r.jsxs("span",{className:"sl-live-count",children:[f," live"]}),r.jsx("button",{className:"glyph-btn sl-close",onClick:a,title:vn("Hide sidebar","L",d),"aria-label":"Hide session list",children:"‹"})]}),r.jsxs("ul",{className:"sl-rows",children:[h.length===0&&r.jsx("li",{className:"sl-empty",children:"No sessions yet."}),h.map(m=>{var v;const w=n.has(m.sessionId),j=(o==null?void 0:o.has(m.sessionId))??!1;return r.jsx("li",{className:"sl-row-item",children:r.jsxs("button",{type:"button",className:`sl-row state-${m.state}${w?" selected":""}${j?" removed":""}`,"aria-current":w?"true":void 0,onClick:()=>s(m.sessionId),title:j?`Bring ${m.label} back to the board`:`Focus ${m.label}`,children:[r.jsx("span",{className:`sl-dot state-${m.state}`,"aria-hidden":!0}),r.jsx("span",{className:"vis-hidden",children:wl(m.state)}),r.jsxs("div",{className:"sl-row-body",children:[r.jsxs("div",{className:"sl-row-head",children:[r.jsx("span",{className:"sl-label",children:m.label}),j&&r.jsx("span",{className:"sl-removed",children:"off the board"}),m.modelId&&r.jsx("span",{className:"model-chip","data-family":Qf(m.modelId),title:pu(m.modelId,m.effort),children:ep(m.modelId,m.effort)})]}),r.jsxs("div",{className:"sl-row-meta",children:[r.jsxs("span",{title:"tool calls",children:[r.jsx("b",{children:m.toolCount})," ",m.toolCount===1?"tool":"tools"]}),m.cost>0&&r.jsx("span",{className:"sl-cost",title:WP,children:r.jsx("b",{children:et(m.cost)})}),m.waiting?r.jsxs("span",{className:"sl-waiting",title:[xl(m.waiting),q3(m.waiting,xl(m.waiting)),`${Mn(m.waiting)?"Blocked":"Your turn"} since ${new Date(m.waiting.since).toLocaleTimeString()} · started ${new Date(m.startedAt).toLocaleString()}`].filter(Boolean).join(`
|
|
95
|
+
`),children:[Mn(m.waiting)?"waiting":"your turn"," ",bf(m.waiting.since,void 0,t),m.waiting.tool&&r.jsxs("span",{className:"sl-waiting-tool",children:[" · ",m.waiting.tool.name]})]}):r.jsx("span",{className:"sl-elapsed",title:`Started ${new Date(m.startedAt).toLocaleString()}`,children:bf(m.startedAt,m.state==="active"?void 0:m.lastActivity,t)})]}),m.plan&&r.jsxs("span",{className:m.plan.allDone?"sl-plan sl-plan-done":"sl-plan",title:m.planTitle,children:[r.jsxs("span",{className:"sl-plan-count","aria-hidden":!0,children:[m.plan.done,"/",m.plan.total]}),r.jsx("span",{className:"vis-hidden",children:y3(m.plan)}),r.jsx("span",{className:"sl-plan-step","aria-hidden":!0,children:m.plan.allDone||!m.plan.current?"done":`${m.plan.next?"next: ":""}${m.plan.current}`})]}),m.recap&&r.jsxs("span",{className:"sl-recap",title:m.recap.text,children:[r.jsx(oP,{}),m.recap.text]}),m.status&&r.jsxs("span",{className:`sl-status status-${m.status.kind}`,title:HX(m.status),children:[r.jsx("span",{className:"sl-status-tag",children:Ha(m.status.kind)})," ",m.status.text]}),((v=m.status)==null?void 0:v.reply)&&r.jsxs("span",{className:"sl-status-reply",title:`suggested reply “${m.status.reply}”`,children:["suggested reply “",m.status.reply,"”"]})]})]})},m.sessionId)})]}),(()=>{let m=0;for(const w of o??[]){const j=e.agents.get(w);j&&hp(j,t)&&m++}return m===0||!i?null:r.jsx("div",{className:"sl-foot",children:r.jsxs("button",{type:"button",className:"btn sl-bring-back",onClick:w=>{const j=w.currentTarget.closest(".session-list");i(),requestAnimationFrame(()=>{var v;return(v=j==null?void 0:j.querySelector(".sl-row"))==null?void 0:v.focus()})},children:["Bring back ",m," removed ",m===1?"card":"cards"]})})})()]})}const zn=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),s=t%60;return`${n.toLocaleString()} h${s?` ${s} min`:""}`},VX=e=>e<1024?`${e} B`:e<1048576?`${(e/1024).toLocaleString(void 0,{maximumFractionDigits:1})} KB`:`${(e/1048576).toLocaleString(void 0,{maximumFractionDigits:1})} MB`,GX=e=>new Date(e).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});async function kf(e,t){for(let n=0;n<4;n++){const s=await fetch(`/api/tool-audit?${e}`,{signal:t}),a=await s.json();if(s.status===409&&a.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(!s.ok||!a.ok||!Array.isArray(a.rows))throw new Error("Could not build the report. Try Refresh or reduce history retention in Settings.");return a}throw new Error("A tool report is already running. Try Refresh in a moment.")}const PE={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 wu(e){if(Object.hasOwn(PE,e))return PE[e];const t=/^(npm|pnpm|yarn|bun) run (.+)$/.exec(e);if(t)return`Runs the “${t[2]}” script`;const n=HP(e);return n?`From the ${n.server} MCP server`:null}function HP(e){const t=/^mcp__(.+?)__(.+)$/.exec(e);return t?{server:t[1],tool:t[2]}:null}const xu=e=>{var t;return((t=HP(e))==null?void 0:t.tool)??e},KX=[{id:"calls",label:"Most used"},{id:"time",label:"Most time"},{id:"slowest",label:"Slowest"},{id:"failed",label:"Failures"}];function jf(e,t){return t==="calls"?e.calls:t==="time"?e.totalMs:t==="slowest"?e.medianMs:e.failed}const YX=(e,t)=>{const n=t.trim().toLowerCase();return!n||e.operation.toLowerCase().includes(n)||(wu(e.operation)??"").toLowerCase().includes(n)};function DE(e,t,n=""){return e.filter(s=>YX(s,n)).sort((s,a)=>{const o=jf(s,t),i=jf(a,t);return o!==i?o===null?1:i===null?-1:i-o:a.calls-s.calls||s.operation.localeCompare(a.operation)})}const cj=(e,t)=>{const n=e/t*100;return`${n>0&&n<1?"<1":Math.round(n)}%`},fp=e=>e.failed>0&&e.completed>0?cj(e.failed,e.completed):null;function XX(e,t){const n=[],a=e.filter(c=>c.totalMs!==null&&c.measured>=2).slice().sort((c,d)=>d.totalMs-c.totalMs)[0];a&&t&&a.totalMs>=t*.2&&n.push({kind:"time",operation:a.operation,title:"takes the most time",detail:`${zn(a.totalMs)} over ${Ln(a.calls,"call")}, ${cj(a.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 ${Ln(o.completed,"call")} failed (${fp(o)}).`});const i=e.filter(c=>c.medianMs!==null&&c.measured>=3&&c.medianMs>=1e4&&c.operation!==(a==null?void 0:a.operation)).sort((c,d)=>d.medianMs-c.medianMs)[0];return i&&n.push({kind:"slow",operation:i.operation,title:"is the slowest",detail:`Usually ${zn(i.medianMs)} per call; the longest took ${zn(i.maxMs)}.`}),n}const Ln=(e,t)=>`${e.toLocaleString()} ${t}${e===1?"":"s"}`,vu={1:"24 hours",7:"7 days",30:"30 days",90:"90 days"},ZX={all:"your agents",claude:"Claude",codex:"Codex"};function JX(e,t,n){return{lead:`In the last ${vu[n]??`${n} days`}, ${ZX[t]} made`,calls:Ln(e.total,"tool call"),time:e.totalMs?zn(e.totalMs):null,failed:e.failed,failedShare:e.failed&&e.completed?cj(e.failed,e.completed):null}}const Xc=e=>new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric"});function bu(e,t=Date.now()){const n=a=>new Date(a).toDateString(),s=new Date(e).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"});return n(e)===n(t)?`Today ${s}`:n(e)===n(t-864e5)?`Yesterday ${s}`:`${new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric"})}, ${s}`}function pp(e){const[t,n]=y.useState(()=>typeof window.matchMedia=="function"&&window.matchMedia(e).matches);return y.useEffect(()=>{if(typeof window.matchMedia!="function")return;const s=window.matchMedia(e),a=()=>n(s.matches);return a(),s.addEventListener("change",a),()=>s.removeEventListener("change",a)},[e]),t}function QX({keyboard:e,onClose:t,children:n}){const s=y.useRef(null),a=mt(t,{focusRef:s}),o=yt(t);return y.useEffect(()=>{var i,c;s.current=((i=a.current)==null?void 0:i.querySelector("#tool-operation-heading"))??null,(c=s.current)==null||c.focus({preventScroll:!0})},[a]),vt.createPortal(r.jsx("div",{className:"ta-drawer-backdrop",role:"presentation",...o,children:r.jsx("div",{className:"ta-drawer","data-keyboard":e||void 0,ref:a,role:"dialog","aria-modal":"true","aria-labelledby":"tool-operation-heading",children:n})}),document.body)}function eZ({keyboard:e,itemKey:t,onClose:n,children:s}){const a=y.useRef(null),o=y.useRef(n);return o.current=n,y.useEffect(()=>Tn.push(()=>o.current(),0,"popover"),[]),y.useLayoutEffect(()=>{var c,d;a.current&&(a.current.scrollTop=0);const i=document.activeElement;(i===document.body||e&&i instanceof HTMLElement&&(i.dataset.operation??i.dataset.skill)===t)&&((d=(c=a.current)==null?void 0:c.querySelector("#tool-operation-heading"))==null||d.focus({preventScroll:!0}))},[t,e]),y.useLayoutEffect(()=>{var d,h;if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return;const i=(d=a.current)==null?void 0:d.querySelector(".ta-inspector"),c=(h=i==null?void 0:i.animate)==null?void 0:h.call(i,[{opacity:.65,transform:"translateX(6px)"},{opacity:1,transform:"translateX(0)"}],{duration:140,easing:"cubic-bezier(0.16, 1, 0.3, 1)"});return()=>c==null?void 0:c.cancel()},[t]),r.jsx("aside",{ref:a,className:"ta-drawer ta-integrated-inspector","data-keyboard":e||void 0,"aria-labelledby":"tool-operation-heading",children:s})}function zP(e){return pp("(max-width: 700px)")?r.jsx(QX,{...e}):r.jsx(eZ,{...e})}const Pa=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString(void 0,{timeZone:"UTC",month:"short",day:"numeric"});function tZ(e,t){return e.status==="outside-history"?`${Pa(e.date)} · before recording started`:e.calls?`${Pa(e.date)} · ${Ln(e.calls,t)}${e.medianMs!=null?` · usually ${zn(e.medianMs)}`:""}`:`${Pa(e.date)} · no ${t}s`}function VP({history:e,noun:t="call"}){const n=e.days,s=[...n].reverse().find(f=>f.calls>0)??n.at(-1),[a,o]=y.useState(null);if(n.length<3||!s)return null;const i=n.find(f=>f.date===a)??s,c=n.reduce((f,p)=>p.calls>f.calls?p:f,n[0]),d=Math.max(1,c.calls),h=`${t[0].toUpperCase()}${t.slice(1)}s`;return r.jsxs("section",{className:"ta-history","aria-labelledby":"ta-history-title",children:[r.jsxs("h4",{id:"ta-history-title",children:[h," per day"]}),r.jsx("div",{className:"ta-history-bars",role:"img","aria-label":`${h} per day from ${Pa(n[0].date)} to ${Pa(n.at(-1).date)}. The busiest day was ${Pa(c.date)} with ${Ln(c.calls,t)}.`,onPointerLeave:()=>o(null),style:{"--ta-days":n.length},children:n.map(f=>r.jsx("span",{"data-shown":f.date===i.date||void 0,"data-outside":f.status==="outside-history"||void 0,onPointerEnter:()=>o(f.date),children:r.jsx("i",{style:{"--ta-height":f.calls/d}})},f.date))}),r.jsxs("div",{className:"ta-history-axis","aria-hidden":"true",children:[r.jsx("span",{children:Pa(n[0].date)}),r.jsx("span",{children:Pa(n.at(-1).date)})]}),r.jsx("p",{className:"ta-note ta-history-day","aria-live":"polite",children:tZ(i,t)})]})}function GP(){return r.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round","aria-hidden":"true",children:r.jsx("path",{d:"m6 6 12 12M18 6 6 18"})})}const nZ={success:"Done",failed:"Failed",unmatched:"No result"},sZ=({state:e})=>r.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round","aria-hidden":"true",children:r.jsx("path",{d:e==="failed"?"m4 4 8 8m0-8-8 8":e==="success"?"m3 8.5 3 3 7-7":"M4 8h8"})});function rZ(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 aZ({row:e,details:t,loading:n,error:s,kind:a,setKind:o,onClose:i,onShowSkills:c}){const d=wu(e.operation),h=(t==null?void 0:t[a])??[],f=Date.now(),p=fp(e);return r.jsxs("section",{className:"ta-inspector","aria-label":`${xu(e.operation)} details`,id:"tool-operation-inspector",children:[r.jsxs("header",{className:"ta-inspector-head",children:[r.jsxs("div",{children:[r.jsx("h3",{tabIndex:-1,id:"tool-operation-heading",children:xu(e.operation)}),d&&r.jsx("p",{children:d})]}),r.jsx("button",{type:"button",className:"glyph-btn","aria-label":"Close details",onClick:i,children:r.jsx(GP,{})})]}),r.jsxs("dl",{className:"ta-facts",children:[r.jsxs("div",{children:[r.jsx("dt",{children:"Calls"}),r.jsx("dd",{children:e.calls.toLocaleString()})]}),r.jsxs("div",{children:[r.jsx("dt",{children:"Total time"}),r.jsx("dd",{children:zn(e.totalMs)})]}),r.jsxs("div",{children:[r.jsx("dt",{children:"Usually"}),r.jsx("dd",{children:zn(e.medianMs)})]}),r.jsxs("div",{children:[r.jsx("dt",{children:"Failed"}),r.jsxs("dd",{"data-bad":e.failed>0||void 0,children:[e.failed.toLocaleString(),p&&r.jsx("small",{children:p})]})]})]}),r.jsxs("p",{className:"ta-note",children:[rZ(e),e.maxMs!==null&&e.measured>1&&r.jsxs(r.Fragment,{children:[" · longest ",zn(e.maxMs)]}),e.unmatched>0&&r.jsxs(r.Fragment,{children:[" · ",Ln(e.unmatched,"call")," without a result yet"]})]}),c&&r.jsx("button",{type:"button",className:"btn ta-show-skills",onClick:c,children:"See which skills ran →"}),s&&r.jsx("p",{className:"ta-message",role:"alert",children:s}),(t==null?void 0:t.history)&&r.jsx(VP,{history:t.history},e.operation),r.jsxs("section",{className:"ta-calls-section","aria-labelledby":"ta-calls-title",children:[r.jsxs("div",{className:"ta-calls-head",children:[r.jsx("h4",{id:"ta-calls-title",children:"Calls"}),r.jsxs("div",{className:"uh-range",role:"group","aria-label":"Show calls",children:[r.jsx("button",{type:"button",className:"uh-range-btn","aria-pressed":a==="recent",onClick:()=>o("recent"),children:"Latest"}),r.jsx("button",{type:"button",className:"uh-range-btn","aria-pressed":a==="slowest",onClick:()=>o("slowest"),children:"Slowest"})]})]}),n&&!t&&r.jsx("p",{className:"ta-note",role:"status",children:"Reading calls…"}),t&&r.jsxs(r.Fragment,{children:[r.jsx("ul",{className:"ta-calls",children:h.map(m=>r.jsxs("li",{"data-state":m.state,children:[r.jsx("span",{className:"ta-call-when",children:bu(m.capturedAt,f)}),r.jsx("span",{className:"ta-call-who",children:m.provider==="claude"?"Claude":"Codex"}),r.jsx("span",{className:"ta-call-took",children:zn(m.durationMs)}),r.jsxs("span",{className:"ta-call-state",children:[r.jsx(sZ,{state:m.state}),nZ[m.state]]})]},m.id))}),!h.length&&r.jsx("p",{className:"ta-note",children:a==="slowest"?"None of these calls was timed.":"No calls in this period."}),t.total>h.length&&h.length>0&&r.jsxs("p",{className:"ta-note",children:["The ",a==="recent"?"latest":"slowest"," ",h.length," of ",t.total.toLocaleString(),"."]})]})]}),r.jsx("p",{className:"ta-note ta-inspector-foot",children:"Times include any wait for your approval."})]})}const _0="agent-dag.text-size",C0="agent-dag.density",FE=["smallest","smaller","default","larger","largest"],BE=["tightest","tighter","compact","default","comfortable"],uj={smallest:-2,smaller:-1,default:0,larger:2,largest:4};function dj(){var e,t;return hj(typeof document>"u"?null:(t=(e=document.documentElement)==null?void 0:e.dataset)==null?void 0:t.textSize)}function hj(e){return e==="smallest"||e==="smaller"||e==="larger"||e==="largest"?e:"default"}function KP(e){return e==="tightest"||e==="tighter"||e==="compact"||e==="comfortable"?e:"default"}const oZ=()=>hj(Ze(_0)),iZ=()=>KP(Ze(C0)),gr={min:320,standard:380,max:1600},lZ=420,cZ=8,YP="agent-dag.tool-activity.details-width";function Tc(e,t){const n=Math.max(gr.min,Math.min(gr.max,t-lZ-cZ));return Math.round(Math.min(n,Math.max(gr.min,Number.isFinite(e)?e:Nf())))}function Nf(){return gr.standard+12*Math.max(0,uj[dj()])}function XP(){const e=Number(Ze(YP));return Number.isFinite(e)&&e>=gr.min&&e<=gr.max?Math.round(e):Nf()}function ZP(e){Xe(YP,String(Math.round(e)))}function JP({width:e,workspace:t,onCommit:n}){const s=y.useRef(null),a=y.useRef(null),o=()=>{var w;return((w=t.current)==null?void 0:w.clientWidth)??window.innerWidth},i=Tc(e,o()),c=w=>{var j,v;(j=t.current)==null||j.style.setProperty("--ta-details-w",`${w}px`),(v=s.current)==null||v.setAttribute("aria-valuenow",String(w))},d=w=>{c(w),n(w)},h=w=>{var j;w.button===0&&(w.preventDefault(),w.currentTarget.setPointerCapture(w.pointerId),a.current={x:w.clientX,width:i,room:o(),last:i},(j=t.current)==null||j.setAttribute("data-resizing",""))},f=w=>{const j=a.current;j&&(j.last=Tc(j.width+j.x-w.clientX,j.room),c(j.last))},p=()=>{var j;const w=a.current;w&&(a.current=null,(j=t.current)==null||j.removeAttribute("data-resizing"),d(w.last))},m=w=>{const j=w.shiftKey?64:16,v=w.key==="ArrowLeft"?i+j:w.key==="ArrowRight"?i-j:w.key==="Home"?gr.min:w.key==="End"?gr.max:w.key==="Enter"?Nf():null;v!==null&&(w.preventDefault(),d(Tc(v,o())))};return r.jsx("div",{ref:s,className:"ta-splitter",role:"separator","aria-orientation":"vertical","aria-label":"Details width","aria-controls":"tool-operation-inspector","aria-valuemin":gr.min,"aria-valuemax":Tc(gr.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(Tc(Nf(),o())),onKeyDown:m})}const uZ=[{id:"uses",label:"Most used"},{id:"recent",label:"Latest"},{id:"name",label:"Name"}];function Sf(e){const t=e.lastIndexOf(":");return t>0&&t<e.length-1?{namespace:e.slice(0,t+1),short:e.slice(t+1)}:{namespace:"",short:e}}function dZ(e,t,n=""){const s=n.trim().toLowerCase();return e.filter(a=>!s||a.name.toLowerCase().includes(s)).sort((a,o)=>t==="recent"&&a.lastAt!==o.lastAt?o.lastAt-a.lastAt:t==="name"?Sf(a.name).short.localeCompare(Sf(o.name).short)||a.name.localeCompare(o.name):o.uses-a.uses||o.lastAt-a.lastAt||a.name.localeCompare(o.name))}const hZ={claude:"Claude",codex:"Codex"};function QP(e){const{claude:t,codex:n}=e.providers;return t&&n?"Claude and Codex":n?"Codex":"Claude"}function fZ(e){return[e.typed?`${e.typed.toLocaleString()} typed by you`:"",e.agent?`${e.agent.toLocaleString()} called by the agent`:"",e.detected?`${e.detected.toLocaleString()} detected in Codex`:"",e.subagent?`${e.subagent.toLocaleString()} in a subagent`:""].filter(Boolean)}const pZ={typed:"Typed",agent:"By the agent",detected:"Detected"},mZ=e=>hZ[e.provider],gZ={all:"your agents",claude:"Claude",codex:"Codex"};function yZ(e,t,n){const s=e.rows.filter(a=>a.uses>0).length;return{lead:`In the last ${vu[n]??`${n} days`}, ${gZ[t]} used`,skills:Ln(s,"skill"),uses:e.total===1?"once":`${e.total.toLocaleString()} times`,failed:e.failed,repeats:e.repeats}}const wZ=e=>e.countedSince>e.since;function xZ({row:e,details:t,loading:n,error:s,onClose:a,sessionLabel:o,onOpenSession:i}){const{namespace:c,short:d}=Sf(e.name),h=Date.now(),f=fZ(e),{claude:p,codex:m}=e.providers;return r.jsxs("section",{className:"ta-inspector","aria-label":`${e.name} details`,id:"tool-operation-inspector",children:[r.jsxs("header",{className:"ta-inspector-head",children:[r.jsxs("div",{children:[r.jsxs("h3",{tabIndex:-1,id:"tool-operation-heading",children:[c&&r.jsx("span",{className:"sa-namespace",children:c}),d]}),r.jsx("p",{children:p&&m?`${p.toLocaleString()} by Claude, ${m.toLocaleString()} by Codex`:`All by ${QP(e)}`})]}),r.jsx("button",{type:"button",className:"glyph-btn","aria-label":"Close details",onClick:a,children:r.jsx(GP,{})})]}),r.jsxs("dl",{className:"ta-facts",children:[r.jsxs("div",{children:[r.jsx("dt",{children:"Uses"}),r.jsx("dd",{children:e.uses.toLocaleString()})]}),r.jsxs("div",{children:[r.jsx("dt",{children:"Sessions"}),r.jsx("dd",{children:e.sessions.toLocaleString()})]}),r.jsxs("div",{children:[r.jsx("dt",{children:"Last used"}),r.jsx("dd",{className:"sa-fact-time",children:bu(e.lastAt,h)})]}),e.failed>0?r.jsxs("div",{children:[r.jsx("dt",{children:"Failed"}),r.jsx("dd",{"data-bad":!0,children:e.failed.toLocaleString()})]}):r.jsxs("div",{children:[r.jsx("dt",{children:"Projects"}),r.jsx("dd",{children:e.projects.toLocaleString()})]})]}),(f.length>0||e.repeats>0)&&r.jsxs("p",{className:"ta-note",children:[f.join(" · "),e.repeats>0&&r.jsxs(r.Fragment,{children:[f.length>0&&" · ",Ln(e.repeats,"repeated run")," not counted, such as ",r.jsx("code",{children:"/loop"})," ticks"]})]}),s&&r.jsx("p",{className:"ta-message",role:"alert",children:s}),(t==null?void 0:t.history)&&r.jsx(VP,{noun:"use",history:{days:t.history.days.map(w=>({date:w.date,calls:w.uses,status:w.status==="outside-history"?"outside-history":w.uses?"measured":"no-calls"}))}},e.name),t&&t.projects.length>0&&r.jsxs("section",{className:"sa-projects","aria-labelledby":"sa-projects-title",children:[r.jsx("h4",{id:"sa-projects-title",children:"Projects"}),r.jsx("ul",{children:t.projects.map(w=>r.jsxs("li",{children:[r.jsx("span",{children:w.name}),r.jsx("span",{children:Ln(w.uses,"use")})]},w.name))})]}),r.jsxs("section",{className:"ta-calls-section","aria-labelledby":"sa-uses-title",children:[r.jsx("div",{className:"ta-calls-head",children:r.jsx("h4",{id:"sa-uses-title",children:"Latest uses"})}),n&&!t&&r.jsx("p",{className:"ta-note",role:"status",children:"Reading uses…"}),t&&r.jsxs(r.Fragment,{children:[r.jsx("ul",{className:"ta-calls sa-uses",children:t.recent.map(w=>{const j=(o==null?void 0:o(w.session))??null;return r.jsxs("li",{"data-state":w.state==="failed"?"failed":void 0,children:[r.jsx("span",{className:"ta-call-when",children:bu(w.at,h)}),r.jsxs("span",{className:"ta-call-who",children:[mZ(w)," · ",pZ[w.origin],w.subagent?" · subagent":"",w.state==="failed"?" · failed":""]}),r.jsxs("span",{className:"sa-use-where",children:[w.project&&r.jsx("span",{className:"sa-use-project",children:w.project}),j&&i?r.jsx("button",{type:"button",className:"sa-session",onClick:()=>i(w.session),title:"Show this session on the canvas",children:j}):r.jsx("span",{className:"sa-session-gone",children:"not on the canvas"})]})]},w.id)})}),!t.recent.length&&r.jsx("p",{className:"ta-note",children:"No uses in this period."}),t.total>t.recent.length&&t.recent.length>0&&r.jsxs("p",{className:"ta-note",children:["The latest ",t.recent.length," of ",t.total.toLocaleString(),"."]})]})]})]})}const qE=12,vZ=()=>r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round","aria-hidden":"true",children:[r.jsx("circle",{cx:"11",cy:"11",r:"6.5"}),r.jsx("path",{d:"m16 16 4.5 4.5"})]});function bZ(e){return`${e.name}: ${Ln(e.uses,"use")}, last used ${bu(e.lastAt)}${e.failed?`, ${e.failed.toLocaleString()} failed`:""}`}function kZ({filters:e,provider:t,period:n,setPeriod:s,refresh:a,onStatus:o,sessionLabel:i,onOpenSession:c}){en("skill-activity");const[d,h]=y.useState("uses"),[f,p]=y.useState(""),[m,w]=y.useState(!1),[j,v]=y.useState(null),[b,k]=y.useState(!1),N=y.useRef(null),[S,_]=y.useState(null),[E,I]=y.useState(null),[A,O]=y.useState(!0),[L,U]=y.useState(!1),[P,T]=y.useState(""),[B,M]=y.useState(""),q=y.useRef(null),$=y.useRef(!1),K=y.useRef(null),G=y.useRef(null),z=pp("(min-width: 960px)"),[W,D]=y.useState(XP),H=ae=>{D(ae),ZP(ae)},ee=new URLSearchParams({view:"skills",provider:t,days:n}).toString(),F=y.useRef(o);F.current=o,y.useEffect(()=>{F.current({loading:A,detailLoading:L,capturedAt:(S==null?void 0:S.capturedAt)??null,hasData:!!S})},[A,L,S]),y.useEffect(()=>{const ae=new AbortController;let de=!0;const Se=window.setTimeout(()=>ae.abort(),65e3);return T(""),q.current!==ee&&(_(null),I(null),w(!1)),$.current=!0,O(!0),(async()=>{try{const pe=await kf(ee,ae.signal);de&&(q.current=ee,_(pe),v(me=>me&&pe.rows.some(be=>be.name===me)?me:null))}catch(pe){de&&T(pe instanceof Error&&pe.name!=="AbortError"?pe.message:"Reading the history took too long. Try again, or keep less history in Settings.")}finally{window.clearTimeout(Se),de&&($.current=!1,O(!1))}})(),()=>{de=!1,ae.abort(),window.clearTimeout(Se),$.current=!1}},[ee,a]),y.useEffect(()=>{if(I(pe=>(pe==null?void 0:pe.name)===j&&q.current===ee?pe:null),M(""),!j||!S||A||$.current){U(!1);return}let ae=!0;const de=new AbortController,Se=window.setTimeout(()=>de.abort(),65e3);return U(!0),(async()=>{var pe;try{const me=await kf(`${ee}&skill=${encodeURIComponent(j)}&history=1&timeZone=${encodeURIComponent(Intl.DateTimeFormat().resolvedOptions().timeZone)}`,de.signal);ae&&((pe=me.details)!=null&&pe.row?I(me.details):v(null))}catch{ae&&M("Could not read the uses of this skill. Close it and open it again to retry.")}finally{window.clearTimeout(Se),ae&&U(!1)}})(),()=>{ae=!1,de.abort(),window.clearTimeout(Se)}},[j,S,A,ee]);const Y=y.useMemo(()=>dZ((S==null?void 0:S.rows)??[],d,f),[S,d,f]),X=m||f?Y:Y.slice(0,qE),Z=Y.reduce((ae,de)=>Math.max(ae,de.uses),0),J=S==null?void 0:S.rows.find(ae=>ae.name===j),ne=!!S&&S.failed>0,ce=ae=>de=>{N.current=de.currentTarget,k(de.detail===0),v(Se=>Se===ae?null:ae)},he=()=>{const ae=j;v(null),requestAnimationFrame(()=>{var pe,me;const de=N.current,Se=Array.from(((pe=K.current)==null?void 0:pe.querySelectorAll(".ta-row[data-skill]"))??[]).find(be=>be.dataset.skill===ae);(me=de!=null&&de.isConnected&&de.checkVisibility()?de:Se)==null||me.focus({preventScroll:!0})})},le=S&&yZ(S,t,n),re=S&&wZ(S);return r.jsxs("div",{className:"ta-workspace",ref:G,"data-inspecting":!!J||void 0,style:{"--ta-details-w":`${W}px`},children:[r.jsx("div",{className:"ta-body",children:r.jsxs("div",{className:"ta-report-content",children:[e,A&&!S&&r.jsxs("div",{className:"ta-loading",role:"status","aria-label":"Reading skill history",children:[r.jsx("i",{}),r.jsx("i",{}),r.jsx("i",{}),r.jsx("i",{}),r.jsx("i",{})]}),P&&r.jsx("div",{className:"ta-message",role:"alert",children:r.jsxs("p",{children:[S&&"Showing the last numbers. ",P]})}),S&&le&&(S.total===0&&S.repeats===0?r.jsxs("div",{className:"ta-empty",children:[r.jsxs("h3",{children:["No skills used in the last ",vu[n]]}),r.jsxs("p",{children:["ccdeck counts each skill ",t==="all"?"Claude Code and Codex load":t==="claude"?"Claude Code loads":"Codex loads"," on this device, starting ",Xc(S.countedSince),". Sessions from before that are not imported. Use a skill and it shows up here."]}),n!=="90"&&!re&&r.jsx("button",{type:"button",className:"btn",onClick:()=>s("90"),children:"Show the last 90 days"})]}):r.jsxs(r.Fragment,{children:[r.jsxs("p",{className:"ta-summary",children:[le.lead," ",r.jsx("strong",{children:le.skills}),S.total>0&&r.jsxs(r.Fragment,{children:[" ",r.jsx("strong",{children:le.uses})]}),"."," ",le.failed>0&&r.jsxs(r.Fragment,{children:[r.jsxs("strong",{className:"ta-bad",children:[le.failed.toLocaleString()," failed"]}),". "]}),le.repeats>0&&r.jsxs(r.Fragment,{children:[Ln(le.repeats,"repeated run"),", such as ",r.jsx("code",{children:"/loop"})," ticks, ",le.repeats===1?"is":"are"," left out."]})]}),re&&r.jsxs("p",{className:"ta-note sa-since",children:["Counting started ",Xc(S.countedSince),", so the days before it are empty rather than unused."]}),(!S.storageOk||S.dropped>0||S.corrupt>0)&&r.jsxs("p",{className:"ta-warning",role:"status",children:["Some uses could not be saved or read, so these numbers may be a little low.",!S.storageOk&&" Check free disk space."]}),r.jsxs("section",{className:"ta-tools","aria-labelledby":"sa-skills-title",children:[r.jsxs("div",{className:"ta-tools-head",children:[r.jsxs("h3",{id:"sa-skills-title",children:["Skills ",r.jsx("span",{className:"ta-count",children:S.rows.length.toLocaleString()})]}),r.jsxs("label",{className:"ta-search",children:[r.jsx(vZ,{}),r.jsx("input",{type:"search","aria-label":"Find a skill",placeholder:"Find a skill",value:f,onChange:ae=>p(ae.target.value)})]})]}),r.jsx("div",{className:"uh-range ta-sorts sa-sorts",role:"group","aria-label":"Sort by",children:uZ.map(ae=>r.jsx("button",{type:"button",className:"uh-range-btn","aria-pressed":d===ae.id,onClick:()=>h(ae.id),children:ae.label},ae.id))}),r.jsxs("div",{className:"ta-list-head sa-list-head","aria-hidden":"true","data-sort":d,"data-failures":ne||void 0,children:[r.jsx("span",{children:"Name"}),r.jsx("span",{"data-col":"uses",children:"Uses"}),r.jsx("span",{"data-col":"recent",children:"Last used"}),ne&&r.jsx("span",{"data-col":"failed",children:"Failed"})]}),r.jsx("ul",{className:"ta-list sa-list",ref:K,"data-sort":d,"data-failures":ne||void 0,children:X.map(ae=>{const{namespace:de,short:Se}=Sf(ae.name);return r.jsx("li",{children:r.jsxs("button",{type:"button",className:"ta-row","data-skill":ae.name,"data-selected":j===ae.name||void 0,"aria-expanded":j===ae.name,"aria-controls":j===ae.name?"tool-operation-inspector":void 0,"aria-label":bZ(ae),onClick:ce(ae.name),children:[r.jsxs("span",{className:"ta-row-name",children:[r.jsxs("span",{className:"ta-op",children:[de&&r.jsx("span",{className:"sa-namespace",children:de}),Se]}),r.jsxs("span",{className:"ta-desc",children:[QP(ae)," · ",Ln(ae.sessions,"session"),ae.repeats>0?` · ${Ln(ae.repeats,"repeat")}`:""]}),r.jsx("span",{className:"ta-bar","aria-hidden":"true",style:{"--ta-share":Z&&d==="uses"?Math.max(.015,ae.uses/Z):0}})]}),r.jsxs("span",{className:"ta-cell","data-col":"uses",children:[ae.uses.toLocaleString(),r.jsxs("span",{className:"ta-unit",children:[" ",ae.uses===1?"use":"uses"]})]}),r.jsxs("span",{className:"ta-cell","data-col":"recent",children:[r.jsx("span",{className:"ta-unit",children:"last "}),bu(ae.lastAt)]}),ne&&r.jsx("span",{className:"ta-cell","data-col":"failed","data-bad":ae.failed>0||void 0,children:ae.failed?r.jsxs(r.Fragment,{children:[ae.failed.toLocaleString(),r.jsx("span",{className:"ta-unit",children:" failed"})]}):r.jsxs("span",{className:"ta-zero",children:["0",r.jsx("span",{className:"ta-unit",children:" failed"})]})})]})},ae.name)})}),!Y.length&&r.jsxs("p",{className:"ta-note ta-no-match",children:["No skill matches “",f.trim(),"”."]}),!f&&!m&&Y.length>qE&&r.jsxs("button",{type:"button",className:"btn ta-more",onClick:()=>w(!0),children:["Show all ",Y.length.toLocaleString()]})]}),r.jsxs("details",{className:"ta-explain",children:[r.jsx("summary",{children:"How this is counted"}),r.jsxs("ul",{children:[r.jsxs("li",{children:["A use is a skill loaded into an agent: Claude calling its Skill tool, a slash command you type, or a skill you pick in Codex with ",r.jsx("code",{children:"$"})," or ",r.jsx("code",{children:"/skills"}),". Custom commands count as skills."]}),r.jsxs("li",{children:["When Codex picks a skill itself, it only reads the skill’s ",r.jsx("code",{children:"SKILL.md"})," or runs one of its scripts. That counts once per turn, only for a skill Codex listed for the session, and shows as detected."]}),r.jsxs("li",{children:["Typed commands are counted only when the deck was started with ",r.jsx("code",{children:"AGENTS_DECK_SKILL_HOOK=1"})," and every Claude Code on this device is 2.1.116 or newer, which reports them to its hooks (",r.jsx("code",{children:"UserPromptExpansion"}),"). Otherwise only the skills Claude calls itself are counted."]}),r.jsxs("li",{children:["The same command run again in one session with the same arguments, such as a ",r.jsx("code",{children:"/loop"})," tick, is a repeat and stays out of the ranking."]}),r.jsxs("li",{children:["Built-in commands such as ",r.jsx("code",{children:"/clear"})," or ",r.jsx("code",{children:"/model"}),", MCP prompts and a skill’s name typed inside a message are not uses. Skills that are installed but never ran do not appear."]}),r.jsx("li",{children:"Failures are shown only when Claude reports that loading a skill failed; Codex reports none."}),r.jsxs("li",{children:["Recorded on this device since ",Xc(S.countedSince)," and kept with the tool history for ",S.retentionDays," days. The skill’s name, the session and the project folder’s name are saved; arguments and paths never are. Change this in Settings."]})]})]})]}))]})}),J&&z&&r.jsx(JP,{width:W,workspace:G,onCommit:H}),J&&r.jsx(zP,{keyboard:b,itemKey:J.name,onClose:he,children:r.jsx(xZ,{row:(E==null?void 0:E.name)===j&&E.row?E.row:J,details:(E==null?void 0:E.name)===j?E:null,loading:L,error:B,onClose:he,sessionLabel:i,onOpenSession:c})})]})}function mp(e,t,n,s="horizontal"){if(n<=0||rp(e))return{kind:"pass"};const a=t>=0&&t<n?t:-1,o=s==="vertical",i=e.key==="ArrowRight"||o&&e.key==="ArrowDown",c=e.key==="ArrowLeft"||o&&e.key==="ArrowUp";if(i)return{kind:"select",index:a===-1?0:(a+1)%n};if(c)return{kind:"select",index:a===-1?n-1:(a-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"}}}const UE=12,jZ=[{id:"all",label:"All agents"},{id:"claude",label:"Claude"},{id:"codex",label:"Codex"}],fh=[{id:"tools",label:"Tools"},{id:"skills",label:"Skills"}],NZ=()=>r.jsx("svg",{width:"17",height:"17",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round","aria-hidden":"true",children:r.jsx("path",{d:"M20 7v5h-5M20 12a8 8 0 1 0-2 5"})}),SZ=()=>r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.8",strokeLinecap:"round","aria-hidden":"true",children:[r.jsx("circle",{cx:"11",cy:"11",r:"6.5"}),r.jsx("path",{d:"m16 16 4.5 4.5"})]}),_Z={time:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round","aria-hidden":"true",children:[r.jsx("circle",{cx:"12",cy:"13",r:"8"}),r.jsx("path",{d:"M12 9v4l2.5 2M9.5 2.5h5"})]}),failing:r.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round","aria-hidden":"true",children:[r.jsx("circle",{cx:"12",cy:"12",r:"9"}),r.jsx("path",{d:"m9 9 6 6m0-6-6 6"})]}),slow:r.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round","aria-hidden":"true",children:r.jsx("path",{d:"M3 17h18M6 17a6 6 0 0 1 12 0M12 17l3.5-4.5"})})};function CZ(e){const t=e.failed?`${e.failed.toLocaleString()} failed (${fp(e)})`:"none failed",n=e.totalMs===null?"not timed":`${zn(e.totalMs)} in total, usually ${zn(e.medianMs)}`;return`${xu(e.operation)}${wu(e.operation)?`, ${wu(e.operation)}`:""}: ${Ln(e.calls,"call")}, ${n}, ${t}`}function EZ({onClose:e,sessionLabel:t,onOpenSession:n}){const[s,a]=y.useState("tools"),[o,i]=y.useState("all"),[c,d]=y.useState("7"),[h,f]=y.useState(0),[p,m]=y.useState({loading:!0,detailLoading:!1,capturedAt:null,hasData:!1}),[w,j]=y.useState("calls"),[v,b]=y.useState(""),k=y.useRef(w);k.current=w;const N=y.useRef(v);N.current=v;const[S,_]=y.useState(!1),[E,I]=y.useState(null),A=y.useRef(!1),[O,L]=y.useState(!1),U=y.useRef(E);U.current=E;const P=y.useRef(null),[T,B]=y.useState(null),[M,q]=y.useState(null),[$,K]=y.useState("recent"),[G,z]=y.useState(!0),[W,D]=y.useState(!1),[H,ee]=y.useState(""),[F,Y]=y.useState(""),[X,Z]=y.useState(0),J=y.useRef(!1),ne=y.useRef(null),ce=y.useRef(null),he=y.useRef(null),le=pp("(min-width: 960px)"),[re,ae]=y.useState(XP),de=we=>{ae(we),ZP(we)},[Se]=y.useState(()=>document.activeElement instanceof HTMLElement?document.activeElement:null),pe=()=>{e(),requestAnimationFrame(()=>{var Ye;const we=Se,Be=Array.from(document.querySelectorAll('[data-rail-item="tool-activity"], [data-rail-item="more"]')).find(He=>He.checkVisibility());(Ye=we&&we!==document.body&&we.isConnected&&we.checkVisibility()?we:Be)==null||Ye.focus({preventScroll:!0})})},me=mt(pe,{focusRef:ce}),be=yt(pe),Ce=new URLSearchParams({provider:o,days:c}).toString();y.useEffect(()=>{if(s!=="tools")return;const we=new AbortController;let Be=!0;const Ye=window.setTimeout(()=>we.abort(),65e3);return ee(""),ne.current!==Ce&&(B(null),q(null),_(!1)),J.current=!0,z(!0),(async()=>{try{const He=await kf(Ce,we.signal);if(Be){ne.current=Ce,B(He);const ft=!A.current&&DE(He.rows,k.current,N.current)[0];ft?(A.current=!0,I(ft.operation)):U.current&&!He.rows.some(St=>St.operation===U.current)&&I(null)}}catch(He){Be&&ee(He instanceof Error&&He.name!=="AbortError"?He.message:"Reading the history took too long. Try again, or keep less history in Settings.")}finally{window.clearTimeout(Ye),Be&&(J.current=!1,z(!1))}})(),()=>{Be=!1,we.abort(),window.clearTimeout(Ye),J.current=!1}},[Ce,X,s]),y.useEffect(()=>{if(q(He=>(He==null?void 0:He.operation)===E&&ne.current===Ce?He:null),Y(""),!E||!T||G||J.current||s!=="tools"){D(!1);return}let we=!0;const Be=new AbortController,Ye=window.setTimeout(()=>Be.abort(),65e3);return D(!0),(async()=>{var He;try{const ft=await kf(`${Ce}&operation=${encodeURIComponent(E)}&history=1&timeZone=${encodeURIComponent(Intl.DateTimeFormat().resolvedOptions().timeZone)}`,Be.signal);we&&(((He=ft.details)==null?void 0:He.measurements)===null?I(null):q(ft.details))}catch{we&&Y("Could not read the calls for this tool. Close it and open it again to retry.")}finally{window.clearTimeout(Ye),we&&D(!1)}})(),()=>{we=!1,Be.abort(),window.clearTimeout(Ye)}},[E,T,G,Ce,s]);const ye=y.useMemo(()=>DE((T==null?void 0:T.rows)??[],w,v),[T,w,v]),Pe=y.useMemo(()=>T?XX(T.rows,T.totalMs):[],[T]),Oe=S||v?ye:ye.slice(0,UE),We=ye.length?jf(ye[0],w)??0:0,Re=T==null?void 0:T.rows.find(we=>we.operation===E),st=we=>Be=>{P.current=Be.currentTarget,L(Be.detail===0),K("recent"),I(Ye=>Ye===we?null:we)},je=()=>{const we=E;I(null),requestAnimationFrame(()=>{var He,ft;const Be=P.current,Ye=Array.from(((He=me.current)==null?void 0:He.querySelectorAll(".ta-row[data-operation]"))??[]).find(St=>St.dataset.operation===we);(ft=Be!=null&&Be.isConnected&&Be.checkVisibility()?Be:Ye??ce.current)==null||ft.focus({preventScroll:!0})})},Te=()=>{if(s==="skills"){!p.loading&&!p.detailLoading&&f(we=>we+1);return}J.current||W||(J.current=!0,Z(we=>we+1))},$e=T&&JX(T,o,c),Ge=y.useRef([]),tt=we=>{var Ye;const Be=mp(we,fh.findIndex(He=>He.id===s),fh.length);Be.kind!=="pass"&&(we.preventDefault(),a(fh[Be.index].id),(Ye=Ge.current[Be.index])==null||Ye.focus())},ht=s==="skills"?p.loading:G,it=s==="skills"?p.hasData?p.capturedAt:null:(T==null?void 0:T.capturedAt)??null,nt=r.jsxs("div",{className:"ta-filters",children:[r.jsx("div",{className:"uh-range",role:"group","aria-label":"Period",children:Object.entries(vu).map(([we,Be])=>r.jsx("button",{type:"button",className:"uh-range-btn","aria-pressed":c===we,onClick:()=>d(we),children:Be},we))}),r.jsx("div",{className:"uh-range",role:"group","aria-label":"Agent",children:jZ.map(we=>r.jsx("button",{type:"button",className:"uh-range-btn","aria-pressed":o===we.id,onClick:()=>i(we.id),children:we.label},we.id))})]});return vt.createPortal(r.jsx("div",{className:"modal-backdrop",role:"presentation",...be,children:r.jsxs("div",{className:"modal ta-report",ref:me,role:"dialog","aria-modal":"true","aria-labelledby":"tool-audit-title",children:[r.jsxs("header",{className:"ta-report-header",children:[r.jsx("h2",{id:"tool-audit-title",children:"Tool activity"}),r.jsx("div",{className:"ta-views",role:"tablist","aria-label":"Show",onKeyDown:tt,children:fh.map((we,Be)=>r.jsx("button",{ref:Ye=>{Ge.current[Be]=Ye},type:"button",role:"tab",id:`ta-view-${we.id}`,className:"ta-view","aria-selected":s===we.id,"aria-controls":"ta-view-panel",tabIndex:s===we.id?0:-1,onClick:()=>a(we.id),children:we.label},we.id))}),r.jsxs("div",{className:"ta-actions",children:[r.jsx("span",{className:"ta-freshness",role:"status",children:ht?it!==null?"Updating…":"Reading history…":it!==null?`Updated ${new Date(it).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})}`:""}),r.jsx("button",{type:"button",className:"glyph-btn","aria-label":s==="skills"?"Refresh skill activity":"Refresh tool activity",title:"Refresh","data-loading":ht||void 0,"aria-busy":s==="skills"?p.loading||p.detailLoading:G||W,onClick:Te,children:r.jsx(NZ,{})}),r.jsx("button",{type:"button",ref:ce,className:"glyph-btn",onClick:pe,"aria-label":"Close tool activity",title:"Close (Esc)",children:"×"})]})]}),r.jsx("div",{className:"ta-view-panel",id:"ta-view-panel",role:"tabpanel","aria-labelledby":`ta-view-${s}`,children:s==="skills"?r.jsx(kZ,{filters:nt,provider:o,period:c,setPeriod:d,refresh:h,onStatus:m,sessionLabel:t,onOpenSession:n}):r.jsxs("div",{className:"ta-workspace",ref:he,"data-inspecting":!!Re||void 0,style:{"--ta-details-w":`${re}px`},children:[r.jsx("div",{className:"ta-body",children:r.jsxs("div",{className:"ta-report-content",children:[nt,G&&!T&&r.jsxs("div",{className:"ta-loading",role:"status","aria-label":"Reading tool history",children:[r.jsx("i",{}),r.jsx("i",{}),r.jsx("i",{}),r.jsx("i",{}),r.jsx("i",{})]}),H&&r.jsxs("div",{className:"ta-message",role:"alert",children:[r.jsxs("p",{children:[T&&"Showing the last numbers. ",H]}),r.jsx("button",{type:"button",className:"btn",onClick:Te,children:"Try again"})]}),T&&$e&&(T.total===0?r.jsxs("div",{className:"ta-empty",children:[r.jsxs("h3",{children:["No tool calls in the last ",vu[c]]}),r.jsxs("p",{children:["ccdeck records each tool ",o==="all"?"Claude Code and Codex use":o==="claude"?"Claude Code uses":"Codex uses"," on this device, starting ",Xc(T.startedAt),". Run a session and the calls show up here."]}),c!=="90"&&r.jsx("button",{type:"button",className:"btn",onClick:()=>d("90"),children:"Show the last 90 days"})]}):r.jsxs(r.Fragment,{children:[r.jsxs("p",{className:"ta-summary",children:[$e.lead," ",r.jsx("strong",{children:$e.calls}),$e.time&&r.jsxs(r.Fragment,{children:[" and spent ",r.jsx("strong",{children:$e.time})," running them"]}),"."," ",$e.failed?r.jsxs(r.Fragment,{children:[r.jsxs("strong",{className:"ta-bad",children:[$e.failed.toLocaleString()," failed"]})," (",$e.failedShare,")."]}):"None failed."]}),(!T.storageOk||T.dropped>0||T.corrupt>0)&&r.jsxs("p",{className:"ta-warning",role:"status",children:["Some calls could not be saved or read, so these numbers may be a little low.",!T.storageOk&&" Check free disk space."]}),Pe.length>0&&r.jsxs("section",{className:"ta-highlights","aria-labelledby":"ta-highlights-title",children:[r.jsx("h3",{id:"ta-highlights-title",children:"Worth a look"}),r.jsx("ul",{children:Pe.map(we=>r.jsx("li",{children:r.jsxs("button",{type:"button",className:"ta-highlight","data-kind":we.kind,"data-operation":we.operation,"aria-expanded":E===we.operation,"aria-controls":E===we.operation?"tool-operation-inspector":void 0,onClick:st(we.operation),children:[r.jsx("span",{className:"ta-highlight-glyph",children:_Z[we.kind]}),r.jsxs("span",{className:"ta-highlight-text",children:[r.jsxs("span",{children:[r.jsx("code",{children:xu(we.operation)})," ",we.title]}),r.jsx("small",{children:we.detail})]})]})},we.kind))})]}),r.jsxs("section",{className:"ta-tools","aria-labelledby":"ta-tools-title",children:[r.jsxs("div",{className:"ta-tools-head",children:[r.jsxs("h3",{id:"ta-tools-title",children:["Tools and commands ",r.jsx("span",{className:"ta-count",children:T.rows.length.toLocaleString()})]}),r.jsxs("label",{className:"ta-search",children:[r.jsx(SZ,{}),r.jsx("input",{type:"search","aria-label":"Find a tool or command",placeholder:"Find a tool or command",value:v,onChange:we=>b(we.target.value)})]})]}),r.jsx("div",{className:"uh-range ta-sorts",role:"group","aria-label":"Sort by",children:KX.map(we=>r.jsx("button",{type:"button",className:"uh-range-btn","aria-pressed":w===we.id,onClick:()=>j(we.id),children:we.label},we.id))}),r.jsxs("div",{className:"ta-list-head","aria-hidden":"true","data-sort":w,children:[r.jsx("span",{children:"Name"}),r.jsx("span",{"data-col":"calls",children:"Calls"}),r.jsx("span",{"data-col":"time",children:"Total time"}),r.jsx("span",{"data-col":"slowest",children:"Usually"}),r.jsx("span",{"data-col":"failed",children:"Failed"})]}),r.jsx("ul",{className:"ta-list","data-sort":w,children:Oe.map(we=>{const Be=jf(we,w),Ye=wu(we.operation);return r.jsx("li",{children:r.jsxs("button",{type:"button",className:"ta-row","data-operation":we.operation,"data-selected":E===we.operation||void 0,"aria-expanded":E===we.operation,"aria-controls":E===we.operation?"tool-operation-inspector":void 0,"aria-label":CZ(we),onClick:st(we.operation),children:[r.jsxs("span",{className:"ta-row-name",children:[r.jsx("span",{className:"ta-op",children:xu(we.operation)}),Ye&&r.jsx("span",{className:"ta-desc",children:Ye}),r.jsx("span",{className:"ta-bar","aria-hidden":"true",style:{"--ta-share":We&&Be?Math.max(.015,Be/We):0}})]}),r.jsxs("span",{className:"ta-cell","data-col":"calls",children:[we.calls.toLocaleString(),r.jsxs("span",{className:"ta-unit",children:[" ",we.calls===1?"call":"calls"]})]}),r.jsxs("span",{className:"ta-cell","data-col":"time",children:[zn(we.totalMs),r.jsx("span",{className:"ta-unit",children:" total"})]}),r.jsxs("span",{className:"ta-cell","data-col":"slowest",children:[r.jsx("span",{className:"ta-unit",children:"usually "}),zn(we.medianMs)]}),r.jsx("span",{className:"ta-cell","data-col":"failed","data-bad":we.failed>0||void 0,children:we.failed?r.jsxs(r.Fragment,{children:[we.failed.toLocaleString(),r.jsx("span",{className:"ta-unit",children:" failed"}),r.jsx("small",{children:fp(we)})]}):r.jsxs("span",{className:"ta-zero",children:["0",r.jsx("span",{className:"ta-unit",children:" failed"})]})})]})},we.operation)})}),!ye.length&&r.jsxs("p",{className:"ta-note ta-no-match",children:["No tool or command matches “",v.trim(),"”."]}),!v&&!S&&ye.length>UE&&r.jsxs("button",{type:"button",className:"btn ta-more",onClick:()=>_(!0),children:["Show all ",ye.length.toLocaleString()]})]}),r.jsxs("details",{className:"ta-explain",children:[r.jsx("summary",{children:"How this is counted"}),r.jsxs("ul",{children:[r.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."}),r.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."}),r.jsx("li",{children:"“Usually” is the middle value: half of the calls were quicker, half took longer."}),r.jsxs("li",{children:["A command line such as ",r.jsx("code",{children:"git add . && git commit"})," counts once for each command in it, and shares its time and result with both."]}),r.jsx("li",{children:"Claude and Codex report times in different ways, so do not compare one with the other."}),r.jsxs("li",{children:["Recorded on this device since ",Xc(T.startedAt)," and kept for ",T.retentionDays," days. Commands are grouped by name; their arguments and output are never saved. Change this in Settings."]})]})]})]}))]})}),Re&&le&&r.jsx(JP,{width:re,workspace:he,onCommit:de}),Re&&r.jsx(zP,{keyboard:O,itemKey:Re.operation,onClose:je,children:r.jsx(aZ,{row:(M==null?void 0:M.operation)===E&&M.measurements?M.measurements:Re,details:(M==null?void 0:M.operation)===E?M:null,loading:W,error:F,kind:$,setKind:K,onClose:je,onShowSkills:Re.operation==="Skill"?()=>{I(null),a("skills")}:void 0})})]})})]})}),document.body)}const E0={cost:0,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0,unpricedTokens:0,sessions:0};function TZ(e){if(!e.synthetic)return!1;const t=e.usage;return t.inputTokens+t.outputTokens+t.cacheReadTokens+t.cacheCreateTokens<=0}function T0(e,t){const n=new Map;for(const s of e){if(s.kind!=="root"||!s.sessionId||TZ(s))continue;const a=On(s,t);n.set(s.sessionId,{cost:a.total,inputTokens:s.usage.inputTokens,outputTokens:s.usage.outputTokens,cacheReadTokens:s.usage.cacheReadTokens,cacheCreateTokens:s.usage.cacheCreateTokens,unpricedTokens:yl(s,t)})}return n}function RZ(e,t){if(!e)return E0;const n={...E0};for(const[s,a]of t){const o=e.get(s);if(!o)continue;const i={cost:a.cost-o.cost,inputTokens:a.inputTokens-o.inputTokens,outputTokens:a.outputTokens-o.outputTokens,cacheReadTokens:a.cacheReadTokens-o.cacheReadTokens,cacheCreateTokens:a.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.unpricedTokens=(n.unpricedTokens??0)+Math.max(0,(a.unpricedTokens??0)-(o.unpricedTokens??0)),n.sessions+=1)}return n}function R0(e,t=new Date){return new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate()-(e-1))).toISOString().slice(0,10).replace(/-/g,"")}const gp=[{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 AZ(e,t,n=gp.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 MZ(e,t=new Date){return e==="today"?R0(1,t):e==="month"?R0(t.getDate(),t):"20200101"}const yn=e=>typeof e=="number"&&Number.isFinite(e)?e:0,Bh=e=>typeof e=="string"?e:"";function fj(e){const t=Array.isArray(e==null?void 0:e.days)?e.days:[],n=new Map;for(const s of t){const a=Array.isArray(s==null?void 0:s.modelBreakdowns)?s.modelBreakdowns:[];for(const o of a){const i=Bh(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+=yn(o==null?void 0:o.cost),typeof(o==null?void 0:o.missingPricing)=="boolean"&&(c.missingPricing=c.missingPricing===!0||o.missingPricing),typeof(o==null?void 0:o.storedCost)=="number"&&Number.isFinite(o.storedCost)&&o.storedCost>=0&&(c.storedCost=(c.storedCost??0)+Math.min(o.storedCost,Math.max(0,yn(o.cost)))),c.inputTokens+=yn(o==null?void 0:o.inputTokens),c.outputTokens+=yn(o==null?void 0:o.outputTokens),c.cacheReadTokens+=yn(o==null?void 0:o.cacheReadTokens),c.cacheCreateTokens+=yn(o==null?void 0:o.cacheCreationTokens)}}return[...n.values()].sort((s,a)=>a.cost-s.cost||a.tokens-s.tokens)}const $Z=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function LZ(e){var t;return((t=$Z.exec(e))==null?void 0:t[0])??e}function IZ(e,t=new Map){const n=Array.isArray(e==null?void 0:e.sessions)?e.sessions:[],s=new Set(fj(e).filter(o=>!(o.missingPricing===!0||o.missingPricing===void 0&&o.cost<=0&&o.tokens>0)).map(o=>o.model)),a=[];for(const o of n){const i=Bh(o==null?void 0:o.period);if(!i)continue;const c=LZ(i),d=o==null?void 0:o.metadata,h=typeof(d==null?void 0:d.lastActivity)=="string"?Date.parse(d.lastActivity):NaN,f=Array.isArray(o==null?void 0:o.modelsUsed)?o.modelsUsed.map(Bh).filter(Boolean):[];a.push({sessionId:c,label:t.get(c)??null,agent:Bh(o==null?void 0:o.agent)||"claude",cost:yn(o==null?void 0:o.totalCost),priced:f.length>0&&f.every(p=>s.has(p)),tokens:yn(o==null?void 0:o.totalTokens),models:f,lastActivityMs:Number.isFinite(h)?h:null})}return a.sort((o,i)=>i.cost-o.cost||i.tokens-o.tokens)}function OZ(e,t=pj(e).cost){const s=(Array.isArray(e==null?void 0:e.sessions)?e.sessions:[]).reduce((o,i)=>o+yn(i==null?void 0:i.totalCost),0),a=Math.max(.01,t*.01);return{sum:s,total:t,over:s>t+a}}function PZ(e,t,n){const s=`Sessions with activity ${e}, and what ccusage puts against each one.`;return t.over?`${s}
|
|
96
|
+
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.`:s}function pj(e){const t=e==null?void 0:e.totals;if(t&&typeof t=="object"){const d=yn(t.cacheReadTokens),h=yn(t.cacheCreationTokens),f=yn(t.inputTokens),p=yn(t.outputTokens);return{cost:yn(t.totalCost),inputTokens:f,outputTokens:p,cacheReadTokens:d,cacheCreateTokens:h,tokens:yn(t.totalTokens)||f+p+d+h}}const n=fj(e),s=d=>n.reduce((h,f)=>h+d(f),0),a=s(d=>d.inputTokens),o=s(d=>d.outputTokens),i=s(d=>d.cacheReadTokens),c=s(d=>d.cacheCreateTokens);return{cost:s(d=>d.cost),inputTokens:a,outputTokens:o,cacheReadTokens:i,cacheCreateTokens:c,tokens:a+o+i+c}}function DZ(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 e4(e,t){var n;return((n=gp.find(s=>s.key===(e??t)))==null?void 0:n.noun)??"today"}function FZ(e,t,n){const s=e!=null,a=pj(e);return{fromRange:s,cost:s?a.cost+n.cost:t.cost.total,inputTokens:s?a.inputTokens+n.inputTokens:t.inputTokens,outputTokens:s?a.outputTokens+n.outputTokens:t.outputTokens,cacheReadTokens:s?a.cacheReadTokens+n.cacheReadTokens:t.cacheReadTokens,cacheCreateTokens:s?a.cacheCreateTokens+n.cacheCreateTokens:t.cacheCreateTokens,hasCost:s?a.cost>0:t.cost.total>0,tokenSum:s?a.tokens:t.sum,showCostBar:!s}}const t4="agent-dag.usagePeriod";function BZ(){const e=Ze(t4);return gp.some(t=>t.key===e)?e:"today"}function qZ(e){Xe(t4,e)}const n4="agent-dag.usageSessionsOpen";function UZ(){return Ze(n4)==="1"}function WZ(e){Xe(n4,e?"1":"0")}function mj({cost:e,size:t="md"}){const n=e.total;if(n<=0)return null;const s=(o,i,c)=>{if(o<=0)return null;const d=o/n*100;return r.jsx("span",{className:`cb-seg ${i}`,style:{width:`${d}%`},title:`${c}: ${et(o)} (${d.toFixed(0)}%)`},i)},a=t==="lg";return r.jsxs("div",{className:a?"cost-bar cost-bar-lg":"cost-bar",role:"img","aria-label":"Cost breakdown",children:[s(e.input,"cb-input","input"),s(e.output,"cb-output","output"),s(e.cacheRead,"cb-cache-r","cache read"),s(e.cacheWrite,"cb-cache-w","cache write")]})}const ph="https://ccdeck.dev/guides",HZ={localNetwork:{href:`${ph}/local-network/#film`,subject:"Local network"},claudeAccounts:{href:`${ph}/claude-accounts/#film`,subject:"Claude accounts"},usage:{href:`${ph}/cost-and-quota/#film`,subject:"cost and quota"},tour:{href:`${ph}/first-run/#film`,subject:"first run"}};function ku({film:e,action:t=!1}){const{href:n,subject:s}=HZ[e];return r.jsxs("a",{className:t?"film-link film-action":"film-link",href:n,target:"_blank",rel:"noopener noreferrer",title:`The ${s} video on ccdeck.dev, 30 seconds — opens in your browser`,children:[t?r.jsxs(r.Fragment,{children:[r.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinejoin:"round","aria-hidden":"true",children:r.jsx("path",{d:"m8 5 11 7-11 7V5Z"})}),r.jsx("span",{children:"Watch video"}),r.jsx("span",{className:"film-duration",children:"30 s"})]}):"Watch · 30 s",r.jsxs("span",{className:"vis-hidden",children:[": the ",s," video on ccdeck.dev, opens in your browser"]})]})}const Rt="ccdeck",zZ="/brand/ccdeck-mark-gradient-small-optical.svg",VZ="/brand/ccdeck-mark-mono-dark-small-optical.svg";function s4(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 r4(){return r.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:[r.jsx("path",{d:"M11.6 6.2A4.8 4.8 0 1 0 11 9.6"}),r.jsx("path",{d:"M11.9 2.6v3.7h-3.6"})]})}function a4(){return r.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:r.jsx("path",{d:"M3.3 10.7L10.7 3.3M5.5 3.3h5.2v5.2"})})}function GZ({incidents:e}){return r.jsx(r.Fragment,{children:e.map(t=>r.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:[r.jsx("span",{className:"pi-dot","aria-hidden":!0}),r.jsx("span",{className:"pi-name",children:t.name}),r.jsxs("span",{className:"pi-words",children:["· ",t.chipWords]}),r.jsxs("span",{className:"pi-short",children:["· ",t.shortWords]}),t.asOf&&r.jsxs("span",{className:"pi-asof",children:["· as of ",t.asOf]}),r.jsx("span",{className:"pi-go","aria-hidden":!0,children:r.jsx(a4,{})}),r.jsxs("span",{className:"vis-hidden",children:[", on ",t.host,", opens in a new tab"]})]},t.provider))})}function o4({incident:e}){return e?r.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:[r.jsx("span",{className:"pi-dot","aria-hidden":!0}),r.jsxs("span",{className:"up-incident-words",children:[r.jsxs("span",{className:"vis-hidden",children:[e.name,": "]}),e.words[0].toUpperCase()+e.words.slice(1),e.asOf?` · as of ${e.asOf}`:""]}),r.jsx("span",{className:"up-incident-go","aria-hidden":!0,children:r.jsx(a4,{})}),e.what&&r.jsx("span",{className:"up-incident-what",children:e.what}),r.jsxs("span",{className:"vis-hidden",children:[", on ",e.host,", opens in a new tab"]})]}):null}function KZ(e,t,n,s,a=!1){const o=Math.max(0,t-s),i=Math.max(0,n-o);if(i<120)return null;const c=Math.min(100,i/n*100),d=e-c;if(a||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,m={label:`${Math.round(d)}% over pace`,color:"var(--warn)",expectedPct:c,isDeficit:!0};if(p<o&&p<86400){const w=Math.floor(p/3600),j=Math.floor(p%3600/60);m.runsOutIn=w>0?`${w}h ${j}m`:`${j}m`}return m}return{label:`${Math.round(-d)}% under pace`,color:"var(--ok)",expectedPct:c,isDeficit:!1}}function Da({pct:e,label:t,reset:n,resetAt:s,windowSec:a,limitReached:o,nowSec:i}){const c=!!s&&s<=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)",m=h<1,w=c?"reset":d?m?"< 1%":`${Math.round(h)}%`:"no reading",j=m?2:h,v=s&&!c?Pu(s,i):null,b=d&&s&&a?KZ(h,s,a,i,o):null,[k,N]=y.useState(!1),S=y.useId();return r.jsxs("div",{className:"qb-row",children:[r.jsxs("div",{className:"qb-meta",children:[r.jsxs("span",{className:"qb-label",children:[t,o&&!c&&r.jsx("span",{className:"qb-limit-badge",title:"Rate limit reached",children:"⛔"})]}),r.jsx("span",{className:"qb-pct",style:{color:d?p:"var(--muted)"},children:w})]}),r.jsxs("div",{className:"qb-track",children:[d&&r.jsx("div",{className:"qb-fill",style:{transform:`scaleX(${j/100})`,background:p,opacity:m?.4:1}}),b&&r.jsx("div",{className:"qb-pace-rail",style:{transform:`translateX(${b.expectedPct}%)`},children:r.jsx("div",{"aria-hidden":!0,className:"qb-pace-marker",style:{background:b.isDeficit?"var(--err)":"var(--ok)"},title:`To last until reset, stay near ${Math.round(b.expectedPct)}% by now`})})]}),r.jsxs("div",{className:"qb-reset-row",children:[c?r.jsx("span",{className:"qb-reset",children:"waiting for a new reading"}):v?r.jsxs("span",{className:"qb-reset",children:["resets in ",v]}):n?r.jsxs("span",{className:"qb-reset",children:["resets ",n]}):null,b&&r.jsxs("button",{type:"button",className:"qb-pace",style:{color:b.color},"aria-expanded":k,"aria-controls":k?S:void 0,onClick:()=>N(_=>!_),children:[r.jsx("i",{className:"qb-pace-key","aria-hidden":!0,style:{background:b.isDeficit?"var(--err)":"var(--ok)"}}),b.runsOutIn?`runs out in ${b.runsOutIn}`:b.label]})]}),k&&b&&r.jsxs("div",{id:S,className:"qb-why",children:["To last until reset, stay near ",Math.round(b.expectedPct),"% by now."]})]})}function i4(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 YZ(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 XZ(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 ZZ(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 JZ({quota:e,quotaLoading:t,nowSec:n,incident:s}){const a=i4(e==null?void 0:e.fetchedAt,n);return r.jsxs("section",{className:"up-section up-quota-section",children:[r.jsxs("h3",{className:"up-section-title",children:["Claude quota",a&&!t&&r.jsxs("span",{className:"up-section-age",title:YZ(e==null?void 0:e.source),children:[a,(e==null?void 0:e.stale)&&" · no newer reading"]})]}),r.jsx(o4,{incident:s}),e!=null&&e.ok?r.jsxs("div",{className:"up-quota-bars",children:[e.session5hPct!=null&&r.jsx(Da,{label:"5-hour window",pct:e.session5hPct,reset:e.session5hReset,resetAt:e.session5hResetAt,windowSec:e.session5hWindowSec,nowSec:n}),r.jsx(Da,{label:"7-day window",pct:e.week7dPct??null,reset:e.week7dReset,resetAt:e.week7dResetAt,windowSec:e.week7dWindowSec,nowSec:n}),e.weekSonnetPct!=null&&r.jsx(Da,{label:"Sonnet (7d)",pct:e.weekSonnetPct,nowSec:n}),e.weekOpusPct!=null&&r.jsx(Da,{label:"Opus (7d)",pct:e.weekOpusPct,nowSec:n}),e.extraEnabled&&e.extraUsedCredits!=null&&e.extraMonthlyLimit?r.jsx(Da,{label:`Extra credits (month${e.extraCurrency?`, ${e.extraCurrency}`:""})`,pct:Math.min(100,Math.round(e.extraUsedCredits/e.extraMonthlyLimit*100)),nowSec:n}):e.extraEnabled&&r.jsx("div",{className:"up-quota-sub up-credits",children:"extra usage credits: on"}),e.resetCredits&&e.resetCredits.availableCount>0&&r.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 — ${Rt} only reports them`,children:s4("limit reset",e.resetCredits)})]}):(e==null?void 0:e.ok)===!1?r.jsxs("div",{className:"up-quota-na",children:[r.jsx("span",{children:e.reason==="no_subscription"?"No quota to show.":"Quota unavailable."}),r.jsx("span",{className:"up-quota-hint",children:XZ(e.reason)})]}):r.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]})}function QZ({codexQuota:e,codexLoading:t,nowSec:n,incident:s}){var o,i;const a=i4(e==null?void 0:e.fetchedAt,n);return r.jsxs("section",{className:"up-section up-quota-section",children:[r.jsxs("h3",{className:"up-section-title",children:["Codex quota",(e==null?void 0:e.ok)&&e.planLabel&&r.jsx("span",{className:"up-plan-badge",children:e.planLabel}),a&&!t&&r.jsx("span",{className:"up-section-age",title:"Fetched from the Codex usage endpoint",children:a})]}),r.jsx(o4,{incident:s}),e!=null&&e.ok?r.jsxs("div",{className:"up-quota-bars",children:[(o=e.windows)==null?void 0:o.map(c=>r.jsx(Da,{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=>r.jsx(Da,{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&&r.jsx(Da,{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&&r.jsxs("div",{className:"up-quota-sub up-credits",children:["credits: $",e.creditsBalance,e.overageReached&&" · overage limit reached"]}),e.creditsUnlimited&&r.jsx("div",{className:"up-quota-sub up-credits",children:"credits: unlimited"}),e.resetCredits&&e.resetCredits.availableCount>0&&r.jsx("div",{className:"up-quota-sub up-reset-credits",title:`Redeem in the Codex CLI or ChatGPT — ${Rt} only reports them`,children:s4("rate-limit reset",e.resetCredits)}),e.promo&&r.jsx("div",{className:"up-quota-sub",children:e.promo}),e.partial&&r.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?r.jsxs("div",{className:"up-quota-na",children:[r.jsx("span",{children:"Quota unavailable."}),r.jsx("span",{className:"up-quota-hint",children:ZZ(e.reason)})]}):r.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]})}function A0(e,t){return t&&e<=0?ra:et(e)+(t?"+":"")}const Tve="Some models have no known price. Tokens are counted; their cost is missing from the total.";function WE(e,t){if(e==null)return null;const n=Math.min(Math.max(0,e),Math.max(0,t));return`Recorded in logs: ${et(n)} · other reported cost: ${et(Math.max(0,t-n))}. Both are included in the total; recorded costs are not a verified bill.`}function eJ({fromRange:e,rangeModelRows:t,boardModelRows:n}){const s=t.filter(o=>o.storedCost!==void 0),a=e?WE(s.length?s.reduce((o,i)=>o+i.storedCost,0):null,t.reduce((o,i)=>o+i.cost,0)):null;return r.jsxs("section",{className:"up-section",children:[r.jsx("h3",{className:"up-section-title",children:"By model"}),r.jsxs("table",{className:"up-table",children:[r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{children:"Model"}),r.jsx("th",{children:"Tokens"}),r.jsx("th",{children:"Cost"})]})}),r.jsx("tbody",{children:e?t.map(o=>r.jsxs("tr",{children:[r.jsx("td",{className:"up-model-name",title:[o.model,WE(o.storedCost,o.cost)].filter(Boolean).join(`
|
|
97
|
+
`),children:Va(o.model)}),r.jsx("td",{className:"up-num",children:xt(o.tokens)}),o.missingPricing===!0||o.missingPricing===void 0&&o.cost<=0&&o.tokens>0?r.jsx("td",{className:"up-num up-unpriced",title:"Cost is incomplete because pricing is missing.",children:A0(o.cost,!0)}):r.jsx("td",{className:"up-num up-cost-val",children:A0(o.cost)})]},o.model)):n.map(o=>r.jsxs("tr",{children:[r.jsx("td",{className:"up-model-name",title:o.model===S0?"no model reported yet":o.model,children:o.model===S0?"unknown":Va(o.model)}),r.jsx("td",{className:"up-num",children:xt(o.inputTokens+o.outputTokens)}),o.priced?r.jsx("td",{className:"up-num up-cost-val",children:et(o.cost.total)}):r.jsx("td",{className:"up-num up-unpriced",children:ra})]},o.model))})]}),a&&r.jsx("p",{className:"uh-cost-note",children:a})]})}function tJ({period:e,rangePending:t,setPeriod:n}){const s=y.useRef([]);return r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"uh-range up-period",role:"toolbar","aria-orientation":"horizontal","aria-label":"Period","aria-busy":t||void 0,onKeyDown:a=>{var c;const o=s.current.indexOf(a.target);if(o<0)return;const i=AZ(a.key,o);i!==null&&(a.preventDefault(),(c=s.current[i])==null||c.focus())},children:gp.map((a,o)=>r.jsx("button",{type:"button",ref:i=>{s.current[o]=i},tabIndex:e===a.key?0:-1,"aria-pressed":e===a.key,"data-pending":e===a.key&&t?"":void 0,title:e===a.key&&t?`Reading ${a.noun} from the transcripts on this machine…`:a.hint,className:"uh-range-btn",onClick:()=>n(a.key),children:a.label},a.key))}),r.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:t?`Reading ${e4(e,e)}…`:""})]})}function nJ(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 sJ(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 HE({sessionId:e,agent:t,label:n,onOpen:s,children:a}){return s&&nJ(t,e)?r.jsxs("button",{type:"button",className:"up-session-row up-session-open",title:`Inspect session usage · ${n}`,onClick:()=>s({sessionId:e,agent:t,label:n}),children:[a,r.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:r.jsx("path",{d:"m3.5 2 3 3-3 3"})}),r.jsx("span",{className:"vis-hidden",children:"Open session usage"})]}):r.jsx("div",{className:"up-session-row",children:a})}function rJ({fromRange:e,rangeSessionRows:t,boardSessionRows:n,boardStates:s,sessionsOpen:a,setSessionsOpen:o,periodNoun:i,sessionScale:c,onOpenSession:d,boardProviders:h}){const f=e?t.length:n.length;return r.jsxs("section",{className:"up-section",children:[r.jsx("h3",{className:"up-section-title",children:r.jsxs("button",{type:"button",className:"up-disclose","aria-expanded":a,"aria-controls":"up-sessions",title:a?"Hide the per-session breakdown":`Show the per-session breakdown — ${f} session${f===1?"":"s"}`,onClick:()=>o(p=>!p),children:["By session",e&&r.jsxs("span",{className:"up-section-age",title:PZ(i,c,et),children:["active ",i]}),r.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:r.jsx("path",{d:"M2.2 3.6 5 6.4 7.8 3.6"})})]})}),r.jsxs("div",{className:"up-sessions",id:"up-sessions",hidden:!a,children:[e&&t.map(p=>{const m=s.get(p.sessionId);return r.jsxs(HE,{sessionId:p.sessionId,agent:p.agent,label:p.label??gf(p.sessionId,8),onOpen:d,children:[m?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:`sl-dot state-${m}`,"aria-hidden":!0}),r.jsx("span",{className:"vis-hidden",children:wl(m)})]}):r.jsx("span",{className:"sl-dot up-dot-past","aria-hidden":!0}),r.jsx("span",{className:`up-session-label${p.label?"":" up-session-id"}`,title:p.label?`${p.label}
|
|
98
|
+
${p.sessionId}`:p.sessionId,children:p.label??gf(p.sessionId,8)}),r.jsx("span",{className:"up-session-tokens",children:xt(p.tokens)}),p.cost>0||p.priced?r.jsx("span",{className:"up-session-cost",title:p.models.join(", ")||void 0,children:et(p.cost)}):r.jsx("span",{className:"up-session-cost up-unpriced",children:ra})]},`${p.agent}:${p.sessionId}`)}),!e&&n.map(p=>r.jsxs(HE,{sessionId:p.sessionId,agent:(h==null?void 0:h.get(p.sessionId))??"claude",label:p.label,onOpen:d,children:[r.jsx("span",{className:`sl-dot state-${p.state}`,"aria-hidden":!0}),r.jsx("span",{className:"vis-hidden",children:wl(p.state)}),r.jsx("span",{className:"up-session-label",children:p.label}),r.jsx("span",{className:"up-session-tokens",children:xt(p.inputTokens+p.outputTokens)}),p.cost>0||p.priced?r.jsxs("span",{className:"up-session-cost",title:p.unpricedTokens>0?`${xt(p.unpricedTokens)} tokens in this session are on an unpriced model, so this is a floor`:void 0,children:[et(p.cost),p.unpricedTokens>0?"+":""]}):r.jsx("span",{className:"up-session-cost up-unpriced",children:ra})]},p.sessionId))]})]})}function aJ(e){return e.claude&&e.codex?"Claude Code and Codex":e.claude?"Claude Code":e.codex?"Codex":null}const oJ={claude:"Claude Code",codex:"Codex",opencode:"OpenCode",openclaw:"OpenClaw",copilot:"GitHub Copilot",pi:"pi-agent",zcode:"ZCode"};function l4(e){const t=e.toLowerCase(),n=Kt(oJ,t);return n!==void 0?n:t?t[0].toUpperCase()+t.slice(1):""}function iJ(e){return e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function Rve(e,t=[]){const n=t.length?iJ(t.map(l4)):aJ(e);return n?`via ccusage · local ${n} logs`:"via ccusage · local agent logs"}function lJ(e){const t=e.claude?{provider:"claude",watching:!0,spans:[{text:"Claude Code sends its events through a hook in "},{text:"~/.claude/settings.json",code:!0},{text:" — or in "},{text:"$CLAUDE_CONFIG_DIR/settings.json",code:!0},{text:" when you have that set — which the deck installs on first run."}]}:{provider:"claude",watching:!1,spans:[{text:"Claude Code capture is off: no Claude Code was found on this machine, or the deck was started with "},{text:"--no-claude",code:!0},{text:"."}]},n=e.codex?{provider:"codex",watching:!0,spans:[{text:"Codex installs nothing and needs no trust prompt — the deck reads "},{text:"~/.codex/sessions/",code:!0},{text:" itself, so an empty canvas means no rollout has been written there yet, or that "},{text:"$CODEX_HOME",code:!0},{text:" points at a different tree."}]}:{provider:"codex",watching:!1,spans:[{text:"Codex capture is off: no "},{text:"~/.codex/",code:!0},{text:" was found — set "},{text:"$CODEX_HOME",code:!0},{text:" if yours lives elsewhere — or the deck was started with "},{text:"--no-codex",code:!0},{text:"."}]};return[t,n]}function cJ(){const[e,t]=y.useState(()=>typeof document<"u"&&document.hidden);return y.useEffect(()=>{const n=()=>t(document.hidden);return document.addEventListener("visibilitychange",n),()=>document.removeEventListener("visibilitychange",n)},[]),r.jsxs("div",{className:"su-loading",role:"status","aria-label":"Reading local session usage","data-paused":e||void 0,children:[r.jsxs("svg",{className:"su-loading-art",viewBox:"0 0 144 88",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[r.jsx("path",{d:"M47 21v-7a4 4 0 0 1 4-4h39a4 4 0 0 1 4 4v49"}),r.jsx("rect",{x:"39",y:"21",width:"46",height:"56",rx:"4"}),r.jsx("path",{d:"M49 32h26M49 40h19M49 48h24M49 62h12"}),r.jsx("path",{className:"su-loading-read",d:"M49 32h26"})]}),r.jsx("strong",{children:"Reading local session usage…"}),r.jsx("span",{children:"Checking the session’s recorded tokens and costs."})]})}const mh=e=>e.toLocaleString(),zE=e=>new Date(e).toLocaleString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"});function uJ({session:e,onClose:t}){var b,k;const[n,s]=y.useState("auto"),[a,o]=y.useState(0),[i,c]=y.useState(null),d=y.useRef(a),h=y.useRef(null),f=mt(t,{focusRef:h}),p=yt(t),m=i!=null&&i.ok&&((b=i.detail)==null?void 0:b.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 a!==d.current&&S.set("refresh","1"),d.current=a,fetch(`/api/ccusage/session?${S}`,{signal:N.signal}).then(async _=>{const E=await _.json();N.signal.aborted||c(E)}).catch(()=>{N.signal.aborted||c({ok:!1})}),()=>N.abort()},[e.agent,e.sessionId,n,a]);const w=(m==null?void 0:m.models.filter(N=>N.missingPricing))??[],j=m?[{name:"Input",n:m.inputTokens,color:"var(--usage-blue)"},{name:"Output",n:m.outputTokens,color:"var(--usage-purple)"},{name:"Cache read",n:m.cacheReadTokens,color:"var(--usage-teal)"},{name:"Cache write",n:m.cacheCreationTokens,color:"var(--usage-orange)"}]:[],v=j.reduce((N,S)=>N+S.n,0);return vt.createPortal(r.jsx("div",{className:"modal-backdrop",...p,role:"presentation",children:r.jsxs("div",{className:"modal su-modal",ref:f,role:"dialog","aria-modal":"true","aria-labelledby":"session-usage-title",children:[r.jsxs("header",{className:"modal-head",children:[r.jsxs("div",{className:"su-title",children:[r.jsx("h2",{id:"session-usage-title",children:"Session usage"}),r.jsx("span",{title:e.label,children:e.label})]}),r.jsxs("div",{className:"modal-actions",children:[r.jsx("button",{type:"button",className:"glyph-btn",onClick:()=>o(N=>N+1),disabled:!i,"aria-label":"Refresh session usage",title:"Refresh session usage",children:r.jsx(r4,{})}),r.jsx("button",{type:"button",className:"glyph-btn",ref:h,onClick:t,"aria-label":"Close session usage (Esc)",title:"Close (Esc)",children:"×"})]})]}),r.jsxs("div",{className:"modal-body su-body","aria-busy":!i,children:[r.jsxs("div",{className:"su-scope",children:[r.jsx("span",{children:l4(e.agent)}),r.jsx("span",{children:"Whole session"})]}),e.agent==="codex"&&r.jsxs("label",{className:"su-pricing",children:["Estimate using",r.jsxs("select",{value:n,disabled:!i,onChange:N=>{c(null),s(N.target.value)},children:[r.jsx("option",{value:"auto",children:"Session settings / config"}),r.jsx("option",{value:"standard",children:"Standard scenario"}),r.jsx("option",{value:"fast",children:"Fast scenario"}),r.jsx("option",{value:"flex",children:"Flex scenario"})]})]}),!i&&r.jsx(cJ,{}),i&&!i.ok&&r.jsxs("p",{className:"su-message",role:"status",title:i.error,children:[sJ(i)," Use Refresh to try again."]}),m&&r.jsxs("div",{className:"su-result",children:[r.jsxs("dl",{className:"su-totals",children:[r.jsxs("div",{children:[r.jsxs("dt",{children:[n==="auto"?"Estimated cost":"Scenario estimate",w.length>0?" · partial":""]}),r.jsxs("dd",{children:[m.totalCost>0?et(m.totalCost):m.totalTokens>0?"No cost reported":"$0.00",w.length>0&&m.totalCost>0?"+":""]})]}),r.jsxs("div",{children:[r.jsx("dt",{children:"Total tokens"}),r.jsx("dd",{title:mh(m.totalTokens),children:xt(m.totalTokens)})]})]}),r.jsxs("section",{"aria-labelledby":"session-tokens-title",children:[r.jsx("div",{className:"su-section-head",children:r.jsx("h3",{id:"session-tokens-title",children:"Token breakdown"})}),r.jsxs("div",{className:"su-cache-reuse",children:[r.jsx("span",{children:"Cached input reuse"}),r.jsx("strong",{children:((k=m.cacheReuse)==null?void 0:k.pct)!=null?`${m.cacheReuse.pct.toLocaleString(void 0,{maximumFractionDigits:1})}%`:"—"}),r.jsx("span",{className:"su-note",children:m.cacheReuse&&m.cacheReuse.measured>0?`${m.cacheReuse.measured} of ${m.cacheReuse.total} ${m.cacheReuse.unit} measured${m.cacheReuse.pct==null?" · no input tokens":""}`:"No cache measurements available"})]}),v>0&&r.jsx("div",{className:"su-composition","aria-hidden":"true",children:j.filter(N=>N.n>0).map(N=>r.jsx("span",{style:{width:`${N.n/v*100}%`,background:N.color}},N.name))}),r.jsx("dl",{className:"su-tokens",children:j.map(({name:N,n:S,color:_})=>r.jsxs("div",{children:[r.jsxs("dt",{children:[r.jsx("span",{className:"su-key",style:{background:_},"aria-hidden":"true"}),N]}),r.jsxs("dd",{title:mh(S),children:[xt(S),r.jsx("span",{className:"su-share",children:v>0?`${(S/v*100).toLocaleString(void 0,{maximumFractionDigits:1})}%`:"—"})]})]},N))}),m.reasoningOutputTokens>0&&r.jsxs("p",{className:"su-note su-reasoning",children:[xt(m.reasoningOutputTokens)," reasoning tokens, included in output."]})]}),r.jsxs("section",{className:"su-models","aria-labelledby":"session-models-title",children:[r.jsxs("div",{className:"su-section-head",children:[r.jsx("h3",{id:"session-models-title",children:"Models"}),r.jsxs("span",{children:[m.models.length," used"]})]}),r.jsxs("table",{children:[r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{scope:"col",children:"Model"}),r.jsx("th",{scope:"col",children:"Tokens"})]})}),r.jsx("tbody",{children:m.models.map(N=>r.jsxs("tr",{children:[r.jsxs("th",{scope:"row",title:N.model,children:[Va(N.model),N.missingPricing&&r.jsx("span",{className:"su-unpriced",children:" · not priced"})]}),r.jsx("td",{title:mh(N.totalTokens),children:xt(N.totalTokens)})]},N.model))})]}),m.models.length===0&&r.jsx("p",{className:"su-note",children:"No model breakdown was reported."})]}),w.length>0&&r.jsx("p",{className:"su-note",children:"Tokens on unpriced models are included; their cost is missing from the estimate."}),r.jsxs("dl",{className:"su-dates",children:[m.firstActivity&&r.jsxs("div",{children:[r.jsx("dt",{children:"First activity"}),r.jsx("dd",{children:r.jsx("time",{dateTime:m.firstActivity,title:new Date(m.firstActivity).toLocaleString(),children:zE(m.firstActivity)})})]}),m.lastActivity&&r.jsxs("div",{children:[r.jsx("dt",{children:"Last activity"}),r.jsx("dd",{children:r.jsx("time",{dateTime:m.lastActivity,title:new Date(m.lastActivity).toLocaleString(),children:zE(m.lastActivity)})})]}),m.entries!=null&&r.jsxs("div",{children:[r.jsx("dt",{children:"Usage records"}),r.jsx("dd",{children:mh(m.entries)})]})]})]}),r.jsxs("footer",{className:"su-footer",children:[r.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."]}),r.jsxs("details",{className:"su-id su-assumptions",children:[r.jsx("summary",{children:"Estimate details"}),r.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."]})]}),r.jsxs("details",{className:"su-id",children:[r.jsx("summary",{children:"Session ID"}),r.jsx("code",{children:e.sessionId})]})]})]})]})}),document.body)}const gh=e=>`${e.id}:${e.windowSec}:${e.resetAt}`;function dJ(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,s=i=>12+Math.max(0,Math.min(100,i))/100*150,a=[];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=a.at(-1))==null?void 0:o.at(-1);(!c||i.t-c.t>10*6e4||i.t<=c.t)&&a.push([]),a.at(-1).push({...i,x:n(i.t),y:s(i.pct)})}return a}function hJ(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 gj({kind:e,title:t,note:n,delayed:s=!1}){const[a,o]=y.useState(()=>typeof document<"u"&&document.hidden);return y.useEffect(()=>{const i=()=>o(document.hidden);return document.addEventListener("visibilitychange",i),()=>document.removeEventListener("visibilitychange",i)},[]),r.jsxs("div",{className:"read-activity","data-kind":e,role:"status","aria-label":t,"data-paused":a||void 0,"data-delayed":s||void 0,children:[r.jsx("svg",{className:"read-activity-art",viewBox:"0 0 180 100",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e==="quota"?r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M36 26a23 23 0 1 1-3 28M34 20v14h14"}),r.jsx("path",{d:"M56 33v14l8 5"}),r.jsx("rect",{x:"104",y:"20",width:"40",height:"58",rx:"4"}),r.jsx("path",{d:"M113 32h22M113 42h22M113 52h15M82 47h15"}),r.jsx("circle",{className:"read-activity-mark",cx:"80",cy:"47",r:"2"})]}):e==="processes"?r.jsxs(r.Fragment,{children:[r.jsx("rect",{x:"34",y:"18",width:"112",height:"64",rx:"5"}),r.jsx("path",{d:"M34 33h112M43 25h2M51 25h2M59 25h2M49 46h24M49 57h36M49 68h28M113 46h17M113 57h17M113 68h17"}),r.jsx("path",{className:"read-activity-mark",d:"M49 43h24"})]}):r.jsxs(r.Fragment,{children:[r.jsx("rect",{x:"37",y:"18",width:"107",height:"64",rx:"5"}),r.jsx("circle",{cx:"65",cy:"48",r:"17"}),r.jsx("path",{d:"M65 38v11l7 4M98 35h32M98 47h25M98 59h30"}),r.jsx("path",{className:"read-activity-mark",d:"M98 32h25"})]})}),r.jsx("strong",{children:t}),n&&r.jsx("span",{children:n})]})}const ul=e=>new Date(e).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}),VE=e=>new Date(e).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"});function fJ({series:e}){const t=dJ(e),n=(e.resetAt-e.windowSec)*1e3,s=e.resetAt*1e3;return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"qh-chart-wrap",children:[r.jsxs("div",{className:"qh-axis","aria-hidden":"true",children:[r.jsx("span",{children:"100%"}),r.jsx("span",{children:"50%"}),r.jsx("span",{children:"0%"})]}),r.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(a=>r.jsx("g",{children:r.jsx("line",{className:"qh-grid",x1:"36",x2:"552",y1:12+a*1.5,y2:12+a*1.5})},a)),r.jsx("path",{className:"qh-guide",d:"M36 12 L552 162"}),t.map((a,o)=>r.jsxs("g",{children:[a.length>1&&r.jsx("path",{className:"qh-observed",d:a.map((i,c)=>`${c?"L":"M"}${i.x} ${i.y}`).join(" ")}),[a[0],...a.length>1?[a.at(-1)]:[]].map(i=>r.jsx("circle",{className:"qh-point",cx:i.x,cy:i.y,r:"2.5",children:r.jsxs("title",{children:[ul(i.t)," · ",Math.round(100-i.pct),"% remaining"]})},i.t))]},o))]}),r.jsxs("div",{className:"qh-times","aria-hidden":"true",children:[r.jsx("span",{children:e.windowSec>86400?ul(n):VE(n)}),r.jsx("span",{children:e.windowSec>86400?ul(s):VE(s)})]})]}),r.jsxs("div",{className:"qh-legend",children:[r.jsxs("span",{children:[r.jsx("i",{className:"qh-key"}),"Observed remaining"]}),r.jsxs("span",{children:[r.jsx("i",{className:"qh-key qh-key-guide"}),"Even-use guide"]})]})]})}function pJ({providers:e,accounts:t,onClose:n,instant:s=!1}){const[a,o]=y.useState(e.claude?"claude":"codex"),[i,c]=y.useState(null),[d,h]=y.useState(!0),[f,p]=y.useState(!1),[m,w]=y.useState(""),[j,v]=y.useState(0),[b,k]=y.useState(Date.now),N=y.useRef(!1),S=y.useRef(null),_=mt(n,{focusRef:S}),E=yt(n),I=t[a];y.useEffect(()=>{let P=!1,T=null;c(null),p(!1);const B=async()=>{if(T)return;if(!I){N.current=!1,h(!1);return}const q=new AbortController;T=q,N.current=!0;const $=window.setTimeout(()=>q.abort(),12e3);h(!0);try{const K=await fetch(`/api/quota/history?provider=${a}&account=${encodeURIComponent(I)}`,{signal:q.signal}),G=await K.json();if(!K.ok||!G.ok||!Array.isArray(G.series))throw new Error("History unavailable");P||(c(G.account===I?G:{...G,series:[]}),p(!1))}catch{P||p(!0)}finally{window.clearTimeout($),T=null,P||(N.current=!1,h(!1))}};B();const M=window.setInterval(()=>{k(Date.now()),document.visibilityState==="visible"&&B()},6e4);return()=>{P=!0,T==null||T.abort(),window.clearInterval(M)}},[a,I,j]);const A=((i==null?void 0:i.series)??[]).slice().sort((P,T)=>T.resetAt-P.resetAt||P.windowSec-T.windowSec),O=A.find(P=>gh(P)===m)??A.find(P=>P.resetAt*1e3>b&&P.windowSec<=6*3600)??A[0],L=O==null?void 0:O.points.at(-1),U=()=>{xn(N.current)&&(N.current=!0,v(P=>P+1))};return vt.createPortal(r.jsx("div",{className:"modal-backdrop",role:"presentation",...E,children:r.jsxs("div",{className:"modal qh-modal","data-keyboard-interaction":s||void 0,ref:_,role:"dialog","aria-modal":"true","aria-labelledby":"quota-history-title",children:[r.jsxs("header",{className:"modal-head",children:[r.jsx("h2",{id:"quota-history-title",children:"Quota history"}),r.jsxs("div",{className:"qh-header-actions",children:[r.jsx("button",{type:"button",className:"glyph-btn","aria-label":"Refresh quota history",title:"Read recorded quota history",...$n(d),onClick:U,children:d?"…":r.jsx(r4,{})}),r.jsx("button",{type:"button",ref:S,className:"glyph-btn",onClick:n,"aria-label":"Close quota history",children:"×"})]})]}),r.jsxs("div",{className:"modal-body qh-body","aria-busy":d,children:[r.jsxs("div",{className:"qh-controls",children:[r.jsx("div",{className:"qh-providers",role:"group","aria-label":"Quota provider",children:["claude","codex"].filter(P=>e[P]).map(P=>r.jsx("button",{type:"button",className:"qh-provider","aria-pressed":a===P,onClick:()=>{o(P),w("")},children:P==="claude"?"Claude":"Codex"},P))}),A.length>0&&r.jsxs("label",{className:"qh-window",children:["Window",r.jsx("select",{"aria-label":"Quota window",value:O?gh(O):"",onChange:P=>w(P.target.value),children:A.map(P=>r.jsxs("option",{value:gh(P),children:[P.label," · ",ul(P.resetAt*1e3)]},gh(P)))})]})]}),f&&r.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."]}),O&&L?r.jsxs("div",{className:"qh-result read-result",children:[r.jsxs("div",{className:"qh-summary",children:[r.jsxs("strong",{children:[Math.round(100-L.pct),"% remaining"]}),r.jsxs("span",{title:ul(L.t),children:["Captured ",hJ(L.t,b),O.resetAt*1e3<=b&&" · window ended"]})]}),r.jsx(fJ,{series:O}),r.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."}),r.jsxs("details",{className:"qh-readings",children:[r.jsxs("summary",{children:["Recorded readings (",O.points.length,")"]}),r.jsxs("table",{children:[r.jsx("caption",{children:O.points.length>50?"Latest 50 readings":"Recorded readings"}),r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{scope:"col",children:"Captured"}),r.jsx("th",{scope:"col",children:"Remaining"})]})}),r.jsx("tbody",{children:O.points.slice(-50).reverse().map(P=>r.jsxs("tr",{children:[r.jsx("td",{children:ul(P.t)}),r.jsxs("td",{children:[(100-P.pct).toLocaleString(void 0,{maximumFractionDigits:1}),"%"]})]},P.t))})]})]})]}):!f&&(d&&I?r.jsx(gj,{kind:"quota",title:"Reading quota history…",note:"Loading this account’s saved quota readings."}):r.jsx("p",{className:"qh-message",role:"status",children:I?"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&&r.jsx("p",{className:"qh-note",role:"status",children:"History is available for this run, but could not be saved to disk."}),r.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 mJ=6e4,gJ=2e4;function yJ(e){const[t,n]=y.useState(null),[s,a]=y.useState(!1),o=y.useRef(null),i=y.useRef(!1),c=async(h=!1)=>{if(!(h&&!xn(i.current))){h&&(i.current=!0,a(!0));try{const p=await fetch(h?"/api/quota?refresh=1":"/api/quota",{signal:AbortSignal.timeout(gJ)});p.ok&&n(await p.json())}catch{}finally{h&&(i.current=!1,a(!1))}}};return y.useEffect(()=>{if(e)return c(!0),o.current=window.setInterval(()=>c(!1),mJ),()=>{o.current!=null&&window.clearInterval(o.current)}},[e]),{quota:t,loading:s,refresh:()=>{e&&c(!0)}}}const wJ=6e4;function xJ(e){const[t,n]=y.useState(null),[s,a]=y.useState(!1),o=y.useRef(null),i=y.useRef(!1),c=async(h=!1)=>{if(!(h&&!xn(i.current))){h&&(i.current=!0,a(!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,a(!1))}}};return y.useEffect(()=>{if(e)return c(!0),o.current=window.setInterval(()=>c(!1),wJ),()=>{o.current!=null&&window.clearInterval(o.current)}},[e]),{data:t,loading:s,refresh:()=>{e&&c(!0)}}}const GE=6e4;function vJ(e,t,n){const[s,a]=y.useState(null),[o,i]=y.useState(!1),[c,d]=y.useState(0),h=y.useRef(0);y.useEffect(()=>{const p=()=>document.visibilityState==="visible",m=()=>{p()&&d(v=>v+1)},w=window.setInterval(m,GE),j=()=>{p()&&Date.now()-h.current>=GE&&d(v=>v+1)};return document.addEventListener("visibilitychange",j),()=>{window.clearInterval(w),document.removeEventListener("visibilitychange",j)}},[]);const f=y.useRef(t);return y.useEffect(()=>{let p=!0;const m=t!==f.current;f.current=t;const w=e,j=MZ(w);return i(!0),fetch(`/api/ccusage?since=${j}${m?"&refresh=1":""}`).then(v=>v.ok?v.json():null).then(v=>{!p||!(v!=null&&v.ok)||(h.current=Date.now(),a({period:w,data:v,baseline:n()}))}).catch(()=>{}).finally(()=>{p&&i(!1)}),()=>{p=!1}},[e,t,c]),{...DZ(s,e),loading:o}}const bJ=e=>1-Math.pow(1-e,5),c4=420;function kJ(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 s=Math.max(Math.abs(e),Math.abs(t));return s===0||n/s>=.005}function jJ(e,t,n,s=c4){return n>=s?t:n<=0?e:e+(t-e)*bJ(n/s)}function u4(){return typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches}function KE(e,t,n,s={}){const a=s.now??(()=>performance.now()),o=s.raf??(w=>requestAnimationFrame(w)),i=s.cancel??(w=>cancelAnimationFrame(w)),c=s.reducedMotion??u4,d=s.hidden??(()=>typeof document=="object"&&document.hidden===!0);if(c()||d()||!kJ(e,t))return n(t),()=>{};const h=a();let f=0,p=!0;const m=()=>{if(!p)return;const w=a()-h;n(jJ(e,t,w)),w<c4&&(f=o(m))};return f=o(m),()=>{p=!1,f&&i(f)}}const NJ=typeof window>"u"?y.useEffect:y.useLayoutEffect;function Mo(e,{countIn:t=!1}={}){const[n,s]=y.useState(e),a=y.useRef(e),o=y.useRef(!0);return y.useEffect(()=>{a.current=n},[n]),NJ(()=>{!t||u4()||(a.current=0,s(0))},[]),y.useEffect(()=>{if(o.current){if(o.current=!1,t)return KE(0,e,c=>{a.current=c,s(c)});a.current=e,s(e);return}return KE(a.current,e,c=>{a.current=c,s(c)})},[e]),n}function d4(e,t,n){const s=_J*Math.max(1,n/f4);let a=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<=s&&(a+=d)}return a}const YE={samples:[],last:new Map,watched:0},h4=10*6e4,SJ=6e4,f4=5e3,_J=20;function CJ(e,t,n){const s=e.samples[e.samples.length-1];if(s&&t-s.t<f4)return e;const a=e.watched+d4(e.last,n,s?t-s.t:0),o=e.samples.filter(i=>t-i.t<=h4);return o.push({t,watched:a}),{samples:o,last:n,watched:a}}function EJ(e,t,n){const s=e.samples[0];if(!s)return null;const a=t-s.t;if(a<SJ)return null;const o=e.samples[e.samples.length-1].t,i=e.watched+d4(e.last,n,t-o)-s.watched;return i>0?{spent:i,spanSec:a/1e3,spanMin:Math.min(h4/6e4,Math.ceil(a/6e4))}:null}function TJ(e,t,n){const s=y.useRef(YE),a=y.useRef(null);return y.useMemo(()=>{const o=PX(e.agents.values()),i=MX(e.agents.values());a.current!==n&&(a.current=n,s.current=YE);const c=T0(e.agents.values(),t);n!=null&&(s.current=CJ(s.current,t,c));const d=n==null?null:EJ(s.current,t,c),h=d?{label:H1(d.spent,d.spanSec),spanMin:d.spanMin}:null;return{byModel:o,totalCost:i.cost,totalTokens:i,burnRate:h}},[e,e.revision,t,n])}const RJ=3e4;function p4(){const[e,t]=y.useState(()=>Math.floor(Date.now()/1e3));return y.useEffect(()=>{const n=window.setInterval(()=>t(Math.floor(Date.now()/1e3)),RJ);return()=>window.clearInterval(n)},[]),e}function XE(e){return(typeof e.cost=="number"?e.cost:e.cost.total)>0||e.inputTokens+e.outputTokens>0}function AJ(e,t,n,s=0){return e?t.some(a=>a.missingPricing===!0||a.missingPricing===void 0&&a.cost<=0&&a.tokens>0)||s>0:n.some(a=>!a.priced)}function MJ(e){return e.claude&&e.codex?"Refresh Claude + Codex quota":e.codex?"Refresh Codex quota":"Refresh Claude quota"}function $J(e){const t=new Map;for(const n of e){if(n.kind!=="root"||!n.sessionId)continue;const s=n.label||n.cwdBasename;s&&t.set(n.sessionId,s)}return t}function LJ(e){const t=new Map;for(const n of e)n.kind!=="root"||!n.sessionId||t.set(n.sessionId,n.state);return t}function IJ(e){const t=new Map;for(const n of e){if(!n.label)continue;const s=t.get(n.label);s?s.push(n.sessionId):t.set(n.label,[n.sessionId])}return e.map(n=>{const s=n.label?t.get(n.label)??[]:[];return s.length>1?{...n,label:`${n.label} ${$P(n.sessionId,s)}`}:n})}function OJ({state:e,now:t,providers:n,incidents:s=[],leaving:a,onClose:o,liveSince:i=null}){const c=Pn(),[d,h]=y.useState(null),[f,p]=y.useState(null),m=y.useMemo(()=>new Map([...e.agents.values()].filter(Re=>Re.kind==="root").map(Re=>[Re.sessionId,Re.provider??"claude"])),[e,e.revision]),{quota:w,loading:j,refresh:v}=yJ(n.claude),{data:b,loading:k,refresh:N}=xJ(n.codex),S=p4(),{byModel:_,totalCost:E,totalTokens:I}=TJ(e,t,i),A=y.useMemo(()=>DX(e.agents.values()),[e,e.revision]),[O,L]=y.useState(BZ);y.useEffect(()=>{qZ(O)},[O]);const[U,P]=y.useState(UZ);y.useEffect(()=>{WZ(U)},[U]);const[T,B]=y.useState(0),M=y.useRef(()=>new Map);M.current=()=>i==null?null:T0(e.agents.values(),t);const q=y.useCallback(()=>M.current(),[]),{data:$,shown:K,stale:G,loading:z,baseline:W}=vJ(O,T,q),D=$!=null,H=z&&G,ee=y.useMemo(()=>$J(e.agents.values()),[e,e.revision]),F=y.useMemo(()=>LJ(e.agents.values()),[e,e.revision]),Y=y.useMemo(()=>D?fj($):[],[$,D]),X=y.useMemo(()=>D?IJ(IZ($,ee).slice(0,12)):[],[$,D,ee]),Z=y.useMemo(()=>pj($),[$]),J=y.useMemo(()=>OZ($,Z.cost),[$,Z.cost]),ne=e4(K,O),ce=y.useMemo(()=>D?RZ(W,T0(e.agents.values(),t)):E0,[e,e.revision,W,D,t]),he=FZ($,{...I,cost:E},ce),le=he.hasCost,re=he.tokenSum,ae=Mo(he.cost),de=Mo(he.inputTokens),Se=Mo(he.outputTokens),pe=Mo(he.cacheReadTokens),me=Mo(he.cacheCreateTokens),be=_.filter(XE),Ce=A.filter(XE),ye=AJ(D,Y,be,ce.unpricedTokens),Pe=j||k,Oe=()=>{v(),N(),B(Re=>Re+1)},We=MJ(n);return r.jsxs("aside",{className:`usage-panel${a?" leaving":""}`,id:"usage-panel","aria-label":"Usage",children:[r.jsxs("div",{className:"up-header",children:[r.jsx("h2",{children:"Usage"}),r.jsxs("div",{className:"up-header-right",children:[(n.claude||n.codex)&&r.jsx("button",{type:"button",className:"glyph-btn","aria-label":"Open quota history",title:"Quota history",onClick:Re=>p(Re.detail===0?"keyboard":"pointer"),children:r.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:r.jsx("path",{d:"M4 4v16h16M8 8l4 4 4-3 4 7"})})}),(n.claude||n.codex)&&r.jsx("button",{type:"button",className:"glyph-btn up-refresh-btn",onClick:Oe,...$n(Pe),"aria-label":We,title:We,children:Pe?"…":r.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:r.jsx("path",{d:"M20 7v5h-5M20 12a8 8 0 1 0-2 5"})})}),r.jsx("button",{type:"button",className:"glyph-btn up-close",onClick:o,"aria-label":"Close usage panel",title:vn("Close","U",c),children:r.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round","aria-hidden":!0,children:r.jsx("path",{d:"m6 6 12 12M18 6 6 18"})})})]})]}),n.claude&&r.jsx(JZ,{quota:w,quotaLoading:j,nowSec:S,incident:s.find(Re=>Re.provider==="claude")}),n.codex&&r.jsx(QZ,{codexQuota:b,codexLoading:k,nowSec:S,incident:s.find(Re=>Re.provider==="codex")}),D&&r.jsx(tJ,{period:O,rangePending:H,setPeriod:L}),re>0?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"up-total",title:D?void 0:IE(c),children:[r.jsx("span",{className:!le&&ye?"up-total-value up-unpriced":"up-total-value",children:le?r.jsxs(r.Fragment,{children:[et(ae),ye&&"+"]}):A0(0,ye)}),le&&r.jsx("span",{className:"up-total-label",children:D?ne:$X})]}),le&&r.jsxs(r.Fragment,{children:[r.jsxs("p",{className:"up-source",children:["Local estimate · ",D?"ccusage":"live sessions"]}),he.showCostBar&&r.jsx(mj,{cost:E})]}),r.jsxs("div",{className:"up-tokens-row",title:D?void 0:IE(c),children:[r.jsxs("span",{className:"up-tok",children:[r.jsx("span",{className:"up-k",children:"in"}),xt(de)]}),r.jsxs("span",{className:"up-tok",children:[r.jsx("span",{className:"up-k",children:"out"}),xt(Se)]}),he.cacheReadTokens>0&&r.jsxs("span",{className:"up-tok",children:[r.jsx("span",{className:"up-k",children:"cache r"}),xt(pe)]}),he.cacheCreateTokens>0&&r.jsxs("span",{className:"up-tok",children:[r.jsx("span",{className:"up-k",children:"cache c"}),xt(me)]}),!le&&r.jsx("span",{className:"up-tok up-scope",children:LX})]}),(D?Y.length:be.length)>0&&r.jsx(eJ,{fromRange:D,rangeModelRows:Y,boardModelRows:be}),D&&X.length===0&&Z.tokens>0&&r.jsxs("section",{className:"up-section",children:[r.jsx("h3",{className:"up-section-title",children:"By session"}),r.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."]})]}),(D?X.length:Ce.length)>0&&r.jsx(rJ,{fromRange:D,rangeSessionRows:X,boardSessionRows:Ce,boardStates:F,sessionsOpen:U,setSessionsOpen:P,periodNoun:ne,sessionScale:J,onOpenSession:h,boardProviders:m}),ye&&r.jsxs("div",{className:"up-hint",children:["“",ra,"” means this build holds no published rate for that model — those tokens are counted above and their dollars are not."]})]}):r.jsx("div",{className:"up-empty",children:D?(K??O)==="all"?r.jsx(r.Fragment,{children:"No usage in any transcript on this machine."}):r.jsxs(r.Fragment,{children:["No usage ",ne,".",r.jsx("br",{}),"Try a longer period."]}):r.jsxs(r.Fragment,{children:["No usage data yet.",r.jsx("br",{}),"Start a Claude Code or Codex session."]})}),r.jsx("div",{className:"film-foot",children:r.jsx(ku,{film:"usage"})}),d&&r.jsx(uJ,{session:d,onClose:()=>h(null)},`${d.agent}:${d.sessionId}`),f&&r.jsx(pJ,{providers:n,instant:f==="keyboard",accounts:{claude:w==null?void 0:w.historyAccount,codex:b==null?void 0:b.historyAccount},onClose:()=>p(null)})]})}function ey(e){return e<9.95?e.toFixed(1):String(Math.round(e))}function yj(e){const t=Number.isFinite(e)?Math.max(0,e):0;return t<50?{value:"0",unit:"KB/s"}:t<999500?{value:ey(t/1e3),unit:"KB/s"}:t<9995e5?{value:ey(t/1e6),unit:"MB/s"}:{value:ey(t/1e9),unit:"GB/s"}}function yp(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 ju(e){return e.unit?e.unit==="%"||e.unit==="°C"?`${e.value}${e.unit}`:`${e.value} ${e.unit}`:e.value}const PJ="thermal:Throttling";function wj(e){const t="timeHeld"in e?e.timeHeld:100-e.speedLimit;return Math.max(0,Math.min(100,t))}function DJ(e){var n,s,a,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),(s=e.loadavg)!=null&&s.length&&(t["load:1m"]=e.loadavg[0]);for(const i of((a=e.thermal)==null?void 0:a.celsius)??[])t[`thermal:${i.label}`]=i.celsius;return(o=e.thermal)!=null&&o.throttle&&(t[PJ]=wj(e.thermal.throttle)),t}function Zc(e,t){return t==="B/s"?ju(yj(e)):t==="ms"?ju(yp(e)):t==="C"?`${Math.round(e)}°`:t==="%"?`${Math.round(e)}%`:e.toFixed(2)}function yh(e,t){return t==="B/s"||t==="ms"||!Number.isInteger(e)?Zc(e,t):t==="C"?`${e}°`:t==="%"?`${e}%`:`${e}`}function FJ(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 BJ(e,t,n){return e>=n?"hot":e>=t?"warn":"calm"}function qJ(e,t,n=Date.now()){const s=wj(e),a="timeHeld"in e;return{pct:s,value:`${s}%`,tone:s===0?"calm":s>=30?"hot":"warn",note:s>0?a?`CPU throttled ${s}% of the time to cool down`:`CPU held to ${100-s}% of full speed to cool down`:t?a?`at full speed · ${t.peak}% throttled ${ZE(t.lastMs,n)}`:`at full speed · held to ${100-t.peak}% ${ZE(t.lastMs,n)}`:"running at full speed, and never held back"}}function ZE(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 s=Math.floor(n/60);return s===1?"an hour ago":`${s} hours ago`}function UJ(e){const t=Math.floor(e/86400),n=Math.floor(e%86400/3600),s=Math.floor(e%3600/60);return t>0?`${t}d ${n}h`:n>0?`${n}h ${s}m`:`${s}m`}function WJ(e){var s,a;const t=(s=e.thermal)==null?void 0:s.throttle,n=t?wj(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`:(a=e.network)!=null&&a.api&&e.network.api.ms==null?"the Claude API is not answering":null}function HJ(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 zJ=3e3;function VJ(){const[e,t]=y.useState(null),n=y.useRef(null);return y.useEffect(()=>{let s=!0;const a=async()=>{if(document.visibilityState!=="hidden")try{const d=await fetch("/api/system");if(!d.ok)return;const h=await d.json();s&&(h!=null&&h.ok)&&t(h)}catch{}},o=()=>{n.current==null&&(a(),n.current=window.setInterval(a,zJ))},i=()=>{n.current!=null&&(window.clearInterval(n.current),n.current=null)},c=()=>{if(document.visibilityState==="hidden"){i();return}o(),a()};return o(),document.addEventListener("visibilitychange",c),()=>{s=!1,i(),document.removeEventListener("visibilitychange",c)}},[]),e}function GJ(e,t){return!e||e.key!==t?"none":e.dir==="asc"?"ascending":"descending"}function Ki({col:e,label:t,note:n,sort:s,next:a,onSort:o,className:i}){const c=GJ(s,e);return r.jsx("th",{scope:"col","aria-sort":c,className:i,children:r.jsxs("button",{type:"button",className:"sd-sort",title:n?`Sort by ${t}
|
|
99
|
+
|
|
100
|
+
${n}`:`Sort by ${t}`,onClick:()=>o(a(s,e)),children:[t,r.jsx("span",{className:"sd-sort-dir","aria-hidden":!0,children:c==="none"?"":c==="ascending"?"↑":"↓"})]})})}function ty(e,t){return t==="B/s"?yj(e):t==="ms"?yp(e):{value:String(e),unit:t==="C"?"°C":t}}const Vt={l:30,r:6,t:6,b:2},Aa={l:0,r:0,t:2,b:1},wp=104,KJ=64;function Us(e,t=100,n=wp,s=Vt){const a=n-s.t-s.b;return s.t+a*(1-Math.max(0,Math.min(t,e))/t)}function m4(e,t){return t??[e[0].t,e[e.length-1].t]}function xj(e,[t,n],s,a=Vt){const o=s-a.l-a.r,i=n-t;return a.l+(i>0?o*(e-t)/i:o/2)}function g4(e,t,n,s=100,a=wp,o=Vt,i){if(!e.length)return"";const c=m4(e,i),d=p=>xj(p,c,t,o);let h="",f=null;for(const p of e){const m=f&&p.t-f.t<=n*2?"L":"M";h+=`${m}${d(p.t).toFixed(1)} ${Us(p.v,s,a,o).toFixed(1)}`,f=p}return h}function y4(e,t,n,s=100,a=wp,o=Vt,i){if(e.length<2)return"";const c=a-o.b,d=m4(e,i),h=w=>xj(w,d,t,o);let f="",p=[];const m=()=>{if(p.length>=2){let w=`M${h(p[0].t).toFixed(1)} ${c}`;for(const j of p)w+=`L${h(j.t).toFixed(1)} ${Us(j.v,s,a,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&&m(),p.push(w);return m(),f}function YJ(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 w4(e,t,n){return n!=null&&e>=n?"hot":t!=null&&e>=t?"warn":""}function XJ(e,t,n=s=>$o(s)){const s=e.filter(i=>i.v>0);if(!e.length)return null;if(!s.length)return"never held back";const a=s.length*(t/6e4),o=s[s.length-1];return`held back for ${a===1?"1 minute":`${a} minutes`}, last at ${n(o.t)}`}function $o(e){const t=new Date(e);return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}function vj(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 s=Math.floor(n/60),a=n%60;return a?`${s}h ${a}m`:`${s}h`}function ZJ({group:e,title:t,liveNote:n,onClose:s}){const a=mt(s),o=yt(s),[i,c]=y.useState(null);y.useEffect(()=>{let m=!0;const w=async()=>{try{const v=await fetch(`/api/system/history?group=${e}`);if(!v.ok)return;const b=await v.json();m&&(b!=null&&b.ok)&&c(b)}catch{}};w();const j=window.setInterval(w,2e4);return()=>{m=!1,window.clearInterval(j)}},[e]);const d=(i==null?void 0:i.series)??[],[h,f,p]=y.useMemo(()=>{let m=1/0,w=0;for(const j of d)j.points.length&&(m=Math.min(m,j.points[0].t),w=Math.max(w,j.points[j.points.length-1].t));return Number.isFinite(m)?[Math.max(m,(i==null?void 0:i.sinceMs)??0),w,[m,w]]:[(i==null?void 0:i.sinceMs)??0,w,void 0]},[d,i==null?void 0:i.sinceMs]);return vt.createPortal(r.jsx("div",{className:"modal-backdrop",...o,role:"presentation",children:r.jsxs("div",{ref:a,className:"modal hist-modal",onClick:m=>m.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"hist-modal-title",children:[r.jsxs("div",{className:"modal-head",children:[r.jsx("span",{className:"modal-title",id:"hist-modal-title",children:t}),i&&h>0&&r.jsxs("span",{className:"hist-since",children:["since ",$o(h)," · ",vj(h,f||Date.now())]}),r.jsx("button",{type:"button",className:"glyph-btn",onClick:s,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]}),r.jsxs("div",{className:"hist-body",children:[i==null?r.jsx(gj,{kind:"history",title:"Reading sensor history…",note:"Loading the readings recorded on this machine.",delayed:!0}):d.length===0?r.jsx("p",{className:"hist-empty",children:"Nothing has been measured yet."}):r.jsx("div",{className:"read-result",children:d.map(m=>r.jsx(JJ,{series:m,stepMs:i.stepMs,domain:p},m.label))}),e==="load"&&n&&r.jsxs("p",{className:"hist-note hist-load-summary",children:[r.jsx("span",{children:"Current 1-minute load"}),r.jsx("strong",{children:n})]})]})]})}),document.body)}function JJ({series:e,stepMs:t,domain:n}){const s=y.useRef(null),[a,o]=y.useState(560),[i,c]=y.useState(null);y.useEffect(()=>{const P=s.current;if(!P||typeof ResizeObserver>"u")return;const T=new ResizeObserver(([B])=>o(Math.max(160,B.contentRect.width)));return T.observe(P),()=>T.disconnect()},[]);const{points:d,unit:h,warnAt:f,critAt:p,label:m,top:w,restsAtZero:j,changes:v}=e,b=j?KJ:wp,{now:k,peak:N}=YJ(d),S=k!=null?ty(k,h):null,_=N!=null?ty(N,h):null,E=m==="Throttling"?XJ(d,t):null,I=i!=null?d[i]:null,[A,O]=n??(d.length?[d[0].t,d[d.length-1].t]:[0,0]),L=P=>xj(P,[A,O],a),U=P=>{if(d.length<2)return;const T=P.currentTarget.getBoundingClientRect(),B=(P.clientX-T.left-Vt.l)/Math.max(1,T.width-Vt.l-Vt.r),M=A+(O-A)*Math.max(0,Math.min(1,B));let q=0;for(let $=1;$<d.length;$++)Math.abs(d[$].t-M)<Math.abs(d[q].t-M)&&(q=$);c(q)};return r.jsxs("section",{className:"hist-series","aria-label":`${m} history`,children:[r.jsxs("div",{className:"hist-head",children:[r.jsx("span",{className:"hist-label",children:m}),r.jsxs("span",{className:"hist-stats",children:[S&&r.jsxs(r.Fragment,{children:[r.jsx("b",{children:S.value}),r.jsxs("span",{children:[S.unit," now"]})]}),N!=null&&_&&r.jsxs(r.Fragment,{children:[r.jsx("b",{className:w4(N,f,p),children:_.value}),r.jsxs("span",{children:[_.unit," peak"]})]})]})]}),r.jsx("div",{className:"hist-plot",ref:s,children:r.jsxs("svg",{className:"hist-chart",width:"100%",height:b,viewBox:`0 0 ${a} ${b}`,preserveAspectRatio:"none",role:"img","aria-label":S==null||_==null?`${m}: nothing measured yet`:`${m}: ${ju(S)} now, peak ${ju(_)}, over ${vj(d[0].t,d[d.length-1].t)}`,onPointerMove:U,onPointerLeave:()=>c(null),children:[[["warn",f],["hot",p]].map(([P,T])=>T==null||T>w?null:r.jsxs("g",{children:[r.jsx("line",{className:`hist-rule ${P}`,x1:Vt.l,x2:a-Vt.r,y1:Us(T,w,b),y2:Us(T,w,b)}),r.jsx("text",{className:`hist-rule-tag ${P}`,x:2,y:Us(T,w,b)+3,children:T})]},P)),r.jsx("line",{className:"hist-floor",x1:Vt.l,x2:a-Vt.r,y1:b-Vt.b,y2:b-Vt.b}),(v??[]).filter(P=>P.from!=null&&d.length>1&&P.t>=A&&P.t<=O).map(P=>r.jsx("line",{className:"hist-mark",x1:L(P.t),x2:L(P.t),y1:Vt.t,y2:b-Vt.b},P.t)),r.jsx("path",{className:"hist-area",d:y4(d,a,t,w,b,Vt,[A,O])}),r.jsx("path",{className:"hist-line",d:g4(d,a,t,w,b,Vt,[A,O])}),d.length===1&&r.jsx("circle",{className:"hist-dot",cx:L(d[0].t),cy:Us(d[0].v,w,b),r:3}),I&&r.jsxs("g",{children:[r.jsx("line",{className:"hist-cross",x1:L(I.t),x2:L(I.t),y1:Vt.t,y2:b-Vt.b}),r.jsx("circle",{className:"hist-dot",cx:L(I.t),cy:Us(I.v,w,b),r:3})]})]})}),r.jsx("div",{className:"hist-axis",children:I?r.jsxs("span",{className:"hist-at",children:[$o(I.t)," — ",(()=>{const P=ty(I.v,h);return r.jsxs(r.Fragment,{children:[r.jsx("b",{children:P.value}),P.unit==="%"||P.unit==="°C"||!P.unit?P.unit:` ${P.unit}`]})})()]}):r.jsxs(r.Fragment,{children:[r.jsx("span",{children:d.length?$o(A):""}),r.jsx("span",{children:d.length?$o(O):""})]})}),E&&r.jsx("div",{className:"hist-note",children:E}),v==null?void 0:v.slice(-3).map(P=>r.jsx("div",{className:"hist-note hist-route",children:P.from==null?`Since ${$o(P.t)} — ${P.label}`:`${$o(P.t)} — ${P.label.charAt(0).toUpperCase()+P.label.slice(1)}`},P.t))]})}const JE=["cores","memory","load","thermal"],_o=116,hr=24,QJ=60,eQ=6e4;function tQ(e){return e.points.length?e.restsAtZero?e.points.some(t=>t.v>0):!0:!1}function nQ(e){return e.unit==="C"?`${e.label} temp`:e.key==="mem:physical"?"Physical RAM":e.key==="mem:swap"?`${e.label} memory`:e.label}function sQ(e,t=QJ){return e.points.length<=t?e:{...e,points:e.points.slice(-t)}}function rQ({sys:e}){const[t,n]=y.useState({});y.useEffect(()=>{let i=!0;const c=async()=>{const h=await Promise.all(JE.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[m,w]of h)w!=null&&w.ok&&(p[m]=w);return p})};c();const d=setInterval(()=>void c(),eQ);return()=>{i=!1,clearInterval(d)}},[]);const s=y.useMemo(()=>DJ(e),[e]),a=y.useMemo(()=>JE.flatMap(i=>{const c=t[i];return c?c.series.filter(tQ).map(d=>({series:sQ(d),stepMs:c.stepMs})):[]}),[t]),o=y.useMemo(()=>{let i=1/0,c=-1/0;for(const{series:d}of a){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)?vj(i,c):"less than a minute"},[a]);return Object.keys(s).length?r.jsx("div",{className:"pl-strip",role:"group","aria-label":`This machine, over the last ${o}`,children:a.map(({series:i,stepMs:c})=>r.jsx(aQ,{series:i,stepMs:c,now:s[i.key],span:o},i.key))}):null}function aQ({series:e,stepMs:t,now:n,span:s}){var w;const{points:a,top:o,unit:i,warnAt:c,critAt:d}=e,h=nQ(e),f=n??((w=a[a.length-1])==null?void 0:w.v),p=f==null?"":w4(f,c,d),m=Math.max(...a.map(j=>j.v));return r.jsxs("div",{className:`pl-cell${p?` ${p}`:""}`,title:[`${h} · peak ${Zc(m,i)} over the last ${s}`,c!=null?`over ${yh(c,i)} is uncomfortable`:"",d!=null?`over ${yh(d,i)} the machine acts`:""].filter(Boolean).join(" · "),children:[r.jsxs("div",{className:"pl-cell-head",children:[r.jsx("span",{className:"pl-cell-label",children:h}),r.jsx("span",{className:"pl-cell-now",children:f==null?"—":Zc(f,i)})]}),r.jsxs("svg",{className:"pl-spark",width:_o,height:hr,viewBox:`0 0 ${_o} ${hr}`,preserveAspectRatio:"none","aria-hidden":!0,children:[r.jsx("line",{className:"pl-spark-floor",x1:0,x2:_o,y1:hr-Aa.b,y2:hr-Aa.b}),r.jsx("path",{className:"pl-spark-area",d:y4(a,_o,t,o,hr,Aa)}),c!=null&&r.jsx("line",{className:"pl-rule warn",x1:0,x2:_o,y1:Us(c,o,hr,Aa),y2:Us(c,o,hr,Aa)}),d!=null&&r.jsx("line",{className:"pl-rule hot",x1:0,x2:_o,y1:Us(d,o,hr,Aa),y2:Us(d,o,hr,Aa)}),r.jsx("path",{className:"pl-spark-line",d:g4(a,_o,t,o,hr,Aa)})]}),r.jsxs("span",{className:"vis-hidden",children:["peak ",Zc(m,i)," over the last ",s,c!=null&&`, uncomfortable over ${yh(c,i)}`,d!=null&&`, the machine acts over ${yh(d,i)}`]})]})}const x4={key:"cpu",dir:"desc"};function oQ(e,t){return e.key===t?{...e,dir:e.dir==="asc"?"desc":"asc"}:{key:t,dir:t==="name"||t==="user"?"asc":"desc"}}function iQ(e,t){const n=t.dir==="asc"?1:-1,s=o=>t.key==="cpu"?o.cpu:t.key==="mem"?o.mem:t.key==="rss"?o.rssBytes:t.key==="threads"?o.threads:o.uptimeSec,a=(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=s(o),d=s(i);return c==null||d==null?c==null?d==null?0:1:-1:n*(c-d)};return[...e].sort((o,i)=>a(o,i)||(i.cpu??-1)-(o.cpu??-1)||i.mem-o.mem||o.pid-i.pid)}const lQ=4e3;function cQ(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 uQ(){const[e,t]=y.useState(null);return y.useEffect(()=>{let n=!0;const s=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=>cQ(c,i))}catch{}};s();const a=window.setInterval(s,lQ);return()=>{n=!1,window.clearInterval(a)}},[]),e}function dQ(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 hQ({sys:e,onClose:t}){en("process-list");const n=mt(t),s=yt(t),[a,o]=y.useState(x4),i=uQ();return vt.createPortal(r.jsx("div",{className:"modal-backdrop",...s,role:"presentation",children:r.jsx("div",{ref:n,className:"modal pl-modal",onClick:c=>c.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"pl-modal-title",children:r.jsx(fQ,{read:i,sort:a,onSort:o,sys:e,onClose:t})})}),document.body)}function fQ({read:e,sort:t,onSort:n,sys:s,onClose:a}){const o=e?iQ(e.procs,t):null;return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"modal-head",children:[r.jsx("span",{className:"modal-title",id:"pl-modal-title",children:"Busiest processes"}),o!=null&&o.length>0&&r.jsxs("span",{className:"pl-count",children:[o.length," of ",e.total," running"]}),r.jsx("button",{type:"button",className:"glyph-btn",onClick:a,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]}),r.jsxs("div",{className:"pl-split",children:[r.jsx("div",{className:"pl-body",children:o==null?r.jsx(gj,{kind:"processes",title:"Reading the process list…",delayed:!0}):o.length===0?r.jsx("p",{className:"pl-empty",children:"Could not read the process list — retrying."}):r.jsxs("table",{className:"sd-procs pl-table",children:[r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx(Ui,{col:"cpu",label:"cpu",sort:t,onSort:n}),r.jsx(Ui,{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}),r.jsx(Ui,{col:"threads",label:"threads",sort:t,onSort:n}),r.jsx(Ui,{col:"uptime",label:"up",sort:t,onSort:n}),r.jsx(Ui,{col:"user",label:"user",sort:t,onSort:n}),r.jsx("th",{scope:"col",className:"pl-pid-h",children:"pid"}),r.jsx(Ui,{col:"name",label:"process",note:"Command lines have anything secret-shaped removed, which is a filter and not a guarantee.",sort:t,onSort:n})]})}),r.jsx("tbody",{children:o.map(i=>r.jsxs("tr",{children:[r.jsx("td",{className:"sd-num",children:i.cpu==null?"—":i.cpu.toFixed(0)}),r.jsx("td",{className:"sd-num sd-dim",title:`${i.mem.toFixed(1)}% of installed memory`,children:Yr(i.rssBytes)}),r.jsx("td",{className:"sd-num sd-dim",children:i.threads??"—"}),r.jsx("td",{className:"sd-num sd-dim",children:dQ(i.uptimeSec)}),r.jsx("td",{className:"sd-dim pl-user",children:i.user??"—"}),r.jsx("td",{className:"sd-num sd-dim pl-pid",children:i.pid}),r.jsxs("td",{className:"pl-name",children:[i.name,i.cmd&&r.jsxs("span",{className:"pl-cmd",title:i.cmd,children:[" ",i.cmd]})]})]},i.pid))})]})}),r.jsx(rQ,{sys:s})]})]})}function Ui(e){return r.jsx(Ki,{...e,next:(t,n)=>oQ(t??x4,n)})}function M0({value:e,unit:t,cap:n}){return t?r.jsxs("span",{className:"sd-fig",children:[r.jsx("span",{className:"sd-fig-cap",children:n}),r.jsxs("span",{className:"sd-fig-read",children:[r.jsx("b",{children:e})," ",r.jsx("span",{className:"sd-fig-unit",children:t})]})]}):r.jsxs("span",{className:"sd-fig",children:[r.jsx("b",{children:e}),r.jsx("span",{className:"sd-fig-cap",children:n})]})}const pQ=300;function Nu({group:e,title:t,action:n,label:s,value:a,hint:o,liveNote:i,children:c}){const[d,h]=y.useState(!1),f=y.useRef(null),p=y.useRef(null),m=()=>{p.current!=null&&window.clearTimeout(p.current),p.current=null};y.useEffect(()=>m,[]);const w=j=>{var v;m(),!(j.detail>1||((v=window.getSelection())==null?void 0:v.isCollapsed)===!1)&&(p.current=window.setTimeout(()=>{var b,k;p.current=null,((b=window.getSelection())==null?void 0:b.isCollapsed)!==!1&&((k=f.current)==null||k.focus({preventScroll:!0}),h(!0))},pQ))};return r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"sd-reading",onClick:w,children:[r.jsx("button",{ref:f,type:"button",className:"sd-open",onClick:j=>{j.stopPropagation(),m(),h(!0)},title:n,"aria-label":a==null?`${s}: show history`:`${s}: show history, now ${a}`,"aria-describedby":o?`sd-hint-${e}`:void 0,children:r.jsxs("span",{className:"sd-h","aria-hidden":!0,children:[s," ",r.jsx("i",{className:"sd-row-more",children:"›"}),a!=null&&r.jsx("span",{className:"sd-h-val",children:a})]})}),c]}),o&&r.jsx("span",{id:`sd-hint-${e}`,className:"vis-hidden",children:o}),d&&r.jsx(ZJ,{group:e,title:t,liveNote:i,onClose:()=>h(!1)})]})}function _f({label:e,value:t,pct:n,tone:s="calm",note:a,mark:o,title:i,trackLabel:c}){return r.jsxs("div",{className:"sd-row",title:i,children:[r.jsxs("div",{className:"sd-row-head",children:[r.jsx("span",{className:"sd-row-label",children:e}),r.jsx("span",{className:"sd-row-val",children:t})]}),r.jsxs("span",{className:"sd-track",role:c?"img":void 0,"aria-label":c,children:[r.jsx("span",{className:`sd-fill${s==="calm"?"":` ${s}`}`,style:{transform:`scaleX(${n<=0?0:Math.max(1,Math.min(100,n))/100})`}}),o!=null&&o>0&&o<100&&r.jsx("span",{className:"sd-mark",style:{left:`${o}%`},"aria-hidden":!0})]}),a&&r.jsx("div",{className:"sd-note",children:a})]})}function mQ(e,t,n){if(n<=0||rp(e))return{kind:"pass"};const s=t>=0&&t<n?t:-1;switch(e.key){case"ArrowDown":return{kind:"focus",index:s===-1?0:(s+1)%n};case"ArrowUp":return{kind:"focus",index:s===-1?n-1:(s-1+n)%n};case"Home":return{kind:"focus",index:0};case"End":return{kind:"focus",index:n-1};default:return{kind:"pass"}}}const Ua=4,ps=8;function bj(e,t,n){const s=n.width-ps-(e.right+Ua),a=e.left-Ua-ps,o=t.width<=s||s>=a?"right":"left",i=o==="right"?e.right+Ua:e.left-Ua-t.width,c=n.height-ps*2,d=t.height<=c,h=d?t.height:Math.max(0,c),f=Math.max(ps,Math.min(e.top,n.height-ps-h)),p=Math.max(ps,Math.min(i,n.width-ps-t.width));return{top:f,left:p,side:o,maxHeight:d?null:h}}function gQ(e,t,n){const s=n.height-ps-(e.bottom+Ua),a=e.top-Ua-ps,o=t.height<=s||s>=a?"below":"above",i=o==="below"?s:a,c=t.height<=i,d=c?t.height:Math.max(0,i),h=o==="below"?e.bottom+Ua:e.top-Ua-d,f=Math.max(ps,Math.min(e.right-t.width,n.width-ps-t.width));return{top:Math.max(ps,h),left:f,side:o,maxHeight:c?null:d}}function yQ(e,t,n){return!(!e||t!=null&&t.contains(e)||n!=null&&n.contains(e))}function wQ(e,t,n){const s=y.useRef(t);s.current=t;const a=y.useRef(n);a.current=n,y.useEffect(()=>{const o=i=>{yQ(i.target,e.current,s.current())&&a.current()};return window.addEventListener("pointerdown",o,!0),()=>window.removeEventListener("pointerdown",o,!0)},[e])}const v4='[role="menuitem"]';function QE(e){return e?Array.from(e.querySelectorAll(v4)).filter(t=>!t.disabled):[]}function xp({anchorId:e,boundaryId:t,portalRootId:n,id:s,className:a,role:o,labelledBy:i,start:c="first",focusRef:d,fallbackFocus:h,onClose:f,children:p}){const m=y.useRef(f);m.current=f;const w=y.useRef(h);w.current=h;const j=mt(()=>{var S;(S=document.getElementById(e))==null||S.focus(),m.current()},{popover:!0,focusRef:d}),v=y.useCallback(()=>{var O,L,U;const S=j.current;if(!S)return;const _=document.getElementById(e);if(!_){m.current();return}if(_.getClientRects().length===0){S.contains(document.activeElement)&&((L=(O=w.current)==null?void 0:O.call(w))==null||L.focus()),m.current();return}const E=_.getBoundingClientRect(),I=t?(U=document.getElementById(t))==null?void 0:U.getBoundingClientRect():null;if(I&&(E.bottom<=I.top||E.top>=I.bottom)){S.contains(document.activeElement)&&_.focus({preventScroll:!0}),m.current();return}S.style.maxHeight="";const A=gQ(E,{width:S.offsetWidth,height:S.offsetHeight},{width:window.innerWidth,height:window.innerHeight});S.style.top=`${A.top}px`,S.style.left=`${A.left}px`,S.style.maxHeight=A.maxHeight==null?"":`${A.maxHeight}px`,S.dataset.side=A.side},[e,t,j]);y.useLayoutEffect(()=>{v()}),y.useEffect(()=>{const S=_=>{var E;(E=j.current)!=null&&E.contains(_.target)||v()};return window.addEventListener("scroll",S,!0),window.addEventListener("resize",v),()=>{window.removeEventListener("scroll",S,!0),window.removeEventListener("resize",v)}},[v,j]),wQ(j,()=>document.getElementById(e),f),y.useEffect(()=>{var _;if(o!=="menu")return;const S=QE(j.current);(_=c==="last"?S[S.length-1]:S[0])==null||_.focus()},[]);const b=S=>{var _;if(o==="menu"&&S.key==="Tab"){S.stopPropagation(),(_=document.getElementById(e))==null||_.focus(),S.shiftKey&&S.preventDefault(),m.current();return}if(o==="menu"){const E=QE(j.current),I=mQ(S,E.indexOf(document.activeElement),E.length);I.kind==="focus"&&(S.preventDefault(),E[I.index].focus())}S.key.length===1&&S.stopPropagation()},k=S=>{S.target.closest("button, input, select, textarea, code")||S.preventDefault()},N=S=>{if(o!=="menu"||S.pointerType==="touch")return;const _=S.target.closest(v4);_&&!_.disabled&&document.activeElement!==_&&_.focus({preventScroll:!0})};return vt.createPortal(r.jsx("div",{ref:j,id:s,className:`anchored-popover${a?` ${a}`:""}`,role:o,"aria-labelledby":i,onKeyDown:b,onMouseDown:k,onPointerMove:N,children:p}),(n?document.getElementById(n):null)??document.body)}function xQ({network:e}){const{down:t,up:n,api:s,route:a}=e,[o,i]=y.useState(!1),c=s&&s.ms!=null?yp(s.ms):null,d=t!=null&&n!=null;return r.jsxs("div",{className:"sd-section",role:"group","aria-label":"Network",children:[r.jsxs(Nu,{group:"network",title:"Network history",action:"Show network history",label:"Network",children:[(d||c)&&r.jsxs("div",{className:"sd-figs sd-figs-named",children:[d&&[["Download",t],["Upload",n]].map(([h,f])=>{const p=yj(f);return r.jsx(M0,{value:p.value,unit:p.unit,cap:h},h)}),c&&r.jsx(M0,{value:c.value,unit:c.unit,cap:"Claude API"})]}),!d&&r.jsx("div",{className:"sd-note",children:"measuring…"}),s&&s.ms==null&&r.jsx("div",{className:"sd-note sd-note-warn",children:"Can’t reach Claude"})]}),a&&r.jsxs(r.Fragment,{children:[r.jsxs("button",{type:"button",className:"sd-detail",id:"sd-conn","aria-expanded":o,"aria-haspopup":"dialog",onClick:()=>i(h=>!h),children:["Connection details",a.relay&&r.jsx("span",{className:"sd-route-relay",children:" · relayed"}),r.jsx("i",{className:"sd-row-more","aria-hidden":!0,children:"›"})]}),o&&r.jsx(vQ,{route:a,api:s,onClose:()=>i(!1)})]})]})}function vQ({route:e,api:t,onClose:n}){return r.jsxs(xp,{anchorId:"sd-conn",boundaryId:"system-panel",id:"sd-conn-pop",className:"sd-pop",role:"dialog",labelledBy:"sd-conn-title",onClose:n,children:[r.jsx("p",{className:"sd-pop-title",id:"sd-conn-title",children:"Connection"}),r.jsxs("dl",{className:"sd-pop-rows",children:[r.jsxs("div",{className:"sd-pop-row",children:[r.jsx("dt",{children:e.to==="claude"?"Traffic to Claude":"Internet traffic"}),r.jsxs("dd",{children:["through ",HJ(e)]})]}),e.relay&&r.jsxs("div",{className:"sd-pop-row",children:[r.jsx("dt",{children:"Relay"}),r.jsxs("dd",{children:[r.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&&r.jsxs("div",{className:"sd-pop-row",children:[r.jsx("dt",{children:"Round trip"}),r.jsx("dd",{children:t.ms==null?`${t.host} did not answer`:`${ju(yp(t.ms))} to open a connection to ${t.host}`})]}),r.jsxs("div",{className:"sd-pop-row",children:[r.jsx("dt",{children:"Throughput"}),r.jsx("dd",{children:"every interface on this machine, not this path alone"})]})]})]})}function eT({usageOpen:e,leaving:t,sub:n,flag:s,onClose:a,children:o}){return r.jsxs("aside",{className:`sysdetail${e?" shifted":""}${t?" leaving":""}`,id:"system-panel","aria-labelledby":"sd-title",children:[r.jsxs("div",{className:"sd-top",children:[r.jsxs("div",{className:"sd-head",children:[r.jsx("h2",{className:"sd-title",id:"sd-title",children:"This machine"}),n&&r.jsx("span",{className:"sd-sub",children:n}),r.jsx("button",{type:"button",className:"glyph-btn sd-close",onClick:a,"aria-label":"Close",title:"Close",children:"×"})]}),s&&r.jsx("p",{className:"sd-flag",children:s})]}),o]})}function bQ({usageOpen:e,leaving:t,onClose:n}){const s=VJ();if(!s||s.cpu==null||!s.memory)return r.jsx(eT,{usageOpen:e,leaving:t,onClose:n,children:r.jsx("div",{className:"sd-note",children:"reading this machine…"})});const{memory:a,swap:o,perCore:i,loadavg:c,cores:d,uptimeSec:h,platform:f,thermal:p,network:m,cpu:w}=s;return r.jsxs(eT,{usageOpen:e,leaving:t,sub:`up ${UJ(h)} · ${d} cores`,flag:WJ(s),onClose:n,children:[r.jsx(kQ,{cpu:w,perCore:i,loadavg:c,cores:d}),r.jsx(jQ,{memory:a,swap:o,platform:f}),m&&r.jsx(xQ,{network:m}),r.jsx(NQ,{thermal:p}),r.jsx(SQ,{sys:s})]})}function kQ({cpu:e,perCore:t,loadavg:n,cores:s}){const a=FJ(n==null?void 0:n[0],s),o=!!t&&t.length>0;return!o&&!n?null:r.jsxs("div",{className:"sd-section sd-cpu",role:"group","aria-label":"CPU",children:[o&&r.jsx(Nu,{group:"cores",title:"Core history",action:"Show core history",label:"CPU",value:e==null?null:`${Math.round(e)}%`,children:r.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)=>r.jsx("span",{className:"sd-core",title:`logical core ${c+1} · ${i}% busy`,children:r.jsx("span",{className:"sd-core-fill",style:{transform:`scaleY(${Math.max(2,i)/100})`}})},c))})}),n&&r.jsxs(Nu,{group:"load",title:"Load history",action:"Show load history",label:"Load average",liveNote:a,hint:"the queue for the cores, counted in tasks rather than as a share of them",children:[r.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)=>r.jsx(M0,{value:i.toFixed(2),cap:["1m","5m","15m"][c]},c))}),a&&r.jsx("div",{className:"sd-note",children:a})]})]})}function jQ({memory:e,swap:t,platform:n}){const s=e.total-e.available,a=n==="win32"?"Commit":"Swap",o=t&&t.total>0?t.used/t.total*100:0;return r.jsx("div",{className:"sd-section",role:"group","aria-label":"Memory",children:r.jsxs(Nu,{group:"memory",title:"Memory history",action:"Show memory history",label:"Memory",children:[r.jsx(_f,{label:"Physical",value:r.jsxs(r.Fragment,{children:[r.jsx("b",{children:Yr(s)})," of ",Yr(e.total)]}),pct:e.usedPct,tone:e.usedPct>=90?"warn":"calm",note:`${Yr(e.available)} available`}),t&&t.total>0&&r.jsx(_f,{label:a,value:r.jsxs(r.Fragment,{children:[r.jsx("b",{children:Yr(t.used)})," of ",Yr(t.total)]}),pct:o,tone:o>=90?"warn":"calm"})]})})}function NQ({thermal:e}){if(!e)return null;const t=e.throttle?qJ(e.throttle,e.heldBack):null;return r.jsx("div",{className:"sd-section",role:"group","aria-label":"Thermal",children:r.jsxs(Nu,{group:"thermal",title:"Thermal history",action:"Show thermal history",label:"Thermal",children:[e.celsius.map(n=>r.jsx(_f,{label:n.label,value:r.jsxs(r.Fragment,{children:[r.jsx("b",{children:n.celsius})," °C"]}),pct:n.celsius/n.critAt*100,mark:n.warnAt/n.critAt*100,tone:BJ(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&&r.jsx(_f,{label:"Throttling",value:r.jsx("b",{children:t.value}),pct:t.pct,tone:t.tone,note:t.note})]})})}function SQ({sys:e}){const[t,n]=y.useState(!1);return r.jsxs("div",{className:"sd-section sd-door-section",children:[r.jsx("button",{type:"button",className:"sd-open sd-door",onClick:()=>n(!0),"aria-label":"Busiest processes: show every process the deck is watching",children:r.jsxs("span",{className:"sd-door-plate",children:[r.jsxs("span",{className:"sd-door-name",children:["Busiest processes",r.jsx("i",{className:"sd-row-more","aria-hidden":!0,children:"›"})]}),r.jsx("span",{className:"sd-door-sub",children:"every process, with its command line"})]})}),t&&r.jsx(hQ,{sys:e,onClose:()=>n(!1)})]})}function _Q(){const[e,t]=y.useState(()=>typeof document<"u"&&document.hidden);return y.useEffect(()=>{const n=()=>t(document.hidden);return document.addEventListener("visibilitychange",n),()=>document.removeEventListener("visibilitychange",n)},[]),r.jsxs("div",{className:"ap-proj-loading",role:"status","aria-label":"Reading project activity","data-paused":e||void 0,children:[r.jsxs("svg",{className:"ap-proj-loading-art",viewBox:"0 0 240 112",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:[r.jsx("rect",{x:"100",y:"8",width:"40",height:"43",rx:"4"}),r.jsx("path",{d:"M108 21h24M108 29h18M108 37h21"}),r.jsx("path",{className:"ap-proj-loading-scan",d:"M108 21h24"}),r.jsx("path",{className:"ap-proj-loading-links",d:"M120 51v15M51 76V66h138v10M120 66v10"}),r.jsx("path",{d:"M30 83v-7h14l6 7h22v23H30zM99 83v-7h14l6 7h22v23H99zM168 83v-7h14l6 7h22v23h-42z"})]}),r.jsx("strong",{children:"Reading project activity"}),r.jsx("span",{children:"Gathering this account’s work by project…"})]})}function Cf(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=Cf(e.l));const n=e.s?Object.entries(e.s):[];return n.length>0&&(t.bySpeed=Object.fromEntries(n.map(([s,a])=>[s,Cf(a)]))),t}function tT(e){const t=s=>({...s,cacheCreate1hTokens:0,cacheCreate5mTokens:0,...s.longContext?{longContext:{...s.longContext,cacheCreate1hTokens:0,cacheCreate5mTokens:0}}:{}}),n=t(Cf(e));return n.bySpeed&&(n.bySpeed=Object.fromEntries(Object.entries(n.bySpeed).map(([s,a])=>[s,t(a)]))),n}function b4(e){return e.i+e.o+e.cr+e.cc}function $0(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&&$0(e.l??(e.l={i:0,o:0,cr:0,cc:0,c1h:0,c5m:0}),t.l);for(const[s,a]of Object.entries(t.s??{}))$0((n=e.s??(e.s={}))[s]??(n[s]={i:0,o:0,cr:0,cc:0,c1h:0,c5m:0}),a);return e}function nT(e,t,n){let s=0,a=0,o=0;const i=[];for(const c of Ou(e)){if(!vr(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}s+=fu(c.usage,t,c.speed,n).total,a+=fu({...c.usage,longContext:void 0},t,sa,n).total}return{atSpeed:s,atStandard:a,unpriced:o,unpricedSpeeds:i}}function sT(e){let t=0;for(const n of Object.values(e))t+=b4(n);return t}function CQ(e){const t=a=>typeof a=="number"&&Number.isFinite(a)?a:0,n=new Map,s=e&&Array.isArray(e.days)?e.days:[];for(const a of s){const o=typeof a.period=="string"?a.period:"",i=Array.isArray(a.modelBreakdowns)?a.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 EQ(e,t,n,s=Date.now()){const a=new Map;for(const A of e){const O={},L=U=>{for(const[P,T]of Object.entries(U))$0(O[P]??(O[P]={i:0,o:0,cr:0,cc:0,c1h:0,c5m:0}),T)};for(const U of A.projects)L(U.models);A.unattributed&&L(A.unattributed);for(const[U,P]of Object.entries(O)){if(!P.s&&!P.l)continue;const{atSpeed:T,atStandard:B}=nT(tT(P),U,s);if(!(T>0&&B>0))continue;let M=a.get(A.day);M||(M=new Map,a.set(A.day,M)),M.set(U,T/B),M.has(pr(U))||M.set(pr(U),T/B)}}const o=(A,O)=>{const L=a.get(A);return(L==null?void 0:L.get(O))??(L==null?void 0:L.get(pr(O)))??1},i=new Map;let c=0,d=0;for(const[A,O]of n){const L=A.indexOf("|"),U=A.slice(0,L),P=A.slice(L+1),T=Jf(O.usage,P,s).total*o(U,P);if(!(T>0&&O.cost>0))continue;c+=O.cost,d+=T;let B=i.get(U);B||(B=new Map,i.set(U,B)),B.set(P,O.cost/T)}const h=d>0,f=(A,O)=>{const L=i.get(A);return(L==null?void 0:L.get(O))??(L==null?void 0:L.get(pr(O)))??null},p=new Set,m=(A,O)=>{let L=0,U=0;for(const[P,T]of Object.entries(A)){if(vr(P,s)){const M=O(P),q=nT(M===null?Cf(T):tT(T),P,s);L+=M===null?q.atSpeed:q.atSpeed*M,U+=q.unpriced;for(const $ of q.unpricedSpeeds)p.add(`${P} (${$})`);continue}const B=b4(T);B>0&&(U+=B,p.add(P))}return{cost:L,unpriced:U}},w=new Map,j=[];for(const A of e){const O=new Map,L=new Map;let U=0;for(const P of A.projects){const{cost:T,unpriced:B}=m(P.models,q=>f(A.day,q));O.set(P.path,(O.get(P.path)??0)+T),B>0&&L.set(P.path,(L.get(P.path)??0)+B),U+=T;let M=w.get(P.path);M||(M={path:P.path,cost:0,tokens:0,unpricedTokens:0},w.set(P.path,M)),M.cost+=T,M.tokens+=sT(P.models),M.unpricedTokens+=B}j.push({day:A.day,total:U,byPath:O,unpricedByPath:L})}const v=[...w.values()].sort((A,O)=>O.cost-A.cost||O.tokens-A.tokens),b=v.reduce((A,O)=>A+O.cost,0),k=v.reduce((A,O)=>A+O.tokens,0),N=v.reduce((A,O)=>A+O.unpricedTokens,0),S=h?c/d:null,_=t?sT(t):0,E=t?m(t,()=>S):{cost:0,unpriced:0},I=E.cost>0||_>0?{cost:E.cost,tokens:_,unpricedTokens:E.unpriced}:null;return{projects:v,totalCost:b,totalTokens:k,unpricedTokens:N,perDay:j,unattributed:I,unpricedModels:[...p].sort(),calibrated:h,reconciled:h&&N===0}}function fr(e,t,n=et){return t>0?e>0?`${n(e)}+`:ra:n(e)}function Wi(e){return e>0?`${xt(e)} of these tokens are on an unpriced model, so this is a floor`:void 0}function TQ(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 ${ra}: this build holds no published rate for it, so its tokens are counted and its dollars are not.`:`${n} are ${ra}: this build holds no published rate for them, so their tokens are counted and their dollars are not.`}const RQ={phase:"running"},AQ={phase:"failed"},MQ={gen:0,report:null,error:null,early:null};function $Q(e,t){var n,s;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 a=((n=e.early)==null?void 0:n.gen)===t.gen?e.early.cost:RQ;return{...e,report:{gen:t.gen,days:t.days,data:t.data,cost:a},early:null}}case"reportFailed":return{...e,report:null,error:t.message,early:null};case"cost":return((s=e.report)==null?void 0:s.gen)===t.gen?{...e,report:{...e.report,cost:t.cost}}:{...e,early:{gen:t.gen,cost:t.cost}}}}function LQ(e){var t;return((t=e.report)==null?void 0:t.gen)!==e.gen&&e.error===null}function IQ(e){const t=e;return t&&t.ok!==!1?{phase:"ready",range:t}:AQ}function OQ(e){return`${e.getFullYear()}${String(e.getMonth()+1).padStart(2,"0")}${String(e.getDate()).padStart(2,"0")}`}function PQ(e,t,n=Date.now()){const s=t===0?60:t,a=new Date(n),o=R0(s,a),i=OQ(a);return{report:`/api/account-projects?num=${e}&days=${t}`,ccusage:`/api/ccusage?since=${o}&until=${i}`}}function DQ({num:e,days:t,gen:n,dispatch:s,get:a=(i,c)=>fetch(i,c),now:o=Date.now()}){const i=PQ(e,t,o),c={credentials:"same-origin"};a(i.report,c).then(d=>d.ok?d.json():Promise.reject(new Error(`HTTP ${d.status}`))).then(d=>s({type:"report",gen:n,days:t,data:d}),d=>s({type:"reportFailed",gen:n,message:(d==null?void 0:d.message)||"Could not load"})),a(i.ccusage,c).then(d=>d.ok?d.json():null).catch(()=>null).then(d=>s({type:"cost",gen:n,cost:IQ(d)}))}function k4(e){return/^[A-Za-z]:[\\/]$/.test(e)?e:e.replace(/[\\/]+$/,"")}function ny(e){const t=k4(e).replace(/\\/g,"/");return/^[A-Za-z]:\//.test(t)?t.toLowerCase():t}function rT(e){if(!e)return e;const t=k4(e),n=t.match(/^\/(?:Users|home)\/[^/]+(\/.*)?$/);if(n)return`~${n[1]??""}`;const s=t.replace(/\\/g,"/").match(/^[A-Za-z]:\/Users\/[^/]+(\/.*)?$/i);return s?`~${s[1]??""}`:t.replace(/\\/g,"/")}function FQ(e,t){const n=ny(e);let s;for(const a of t){const o=ny(a.path);!o||o===n||!n.startsWith(`${o}/`)||(!s||ny(s.path).length<o.length)&&(s=a)}return s==null?void 0:s.label}function L0(e){return e===0?"all time":e===1?"today":`the last ${e} days`}function BQ(e){return e===1?"No work attributed to this account yet today.":`No work attributed to this account in ${L0(e)}.`}function qQ(e){return e===1?7:e===7?30:e===30?0:null}function UQ(e,t){return e!==1&&t>0}const WQ=[{days:1,label:"Today"},{days:7,label:"7d"},{days:30,label:"30d"},{days:0,label:"All"}],Hi=["var(--usage-blue)","var(--usage-teal)","var(--usage-lime)","var(--usage-purple)","var(--usage-indigo)","var(--usage-pink)","var(--usage-orange)","var(--usage-zinc)"],HQ="var(--usage-zinc)",sy=6,zQ=1600;function VQ(e){const t=et(e),n=/^\$(\d{4,})$/.exec(t);return n?`$${Number(n[1]).toLocaleString("en-US")}`:t}function wh(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 GQ(e){const t=/^\d{4}-(\d{2})-(\d{2})$/.exec(e);return t?`${Number(t[1])}/${Number(t[2])}`:e}function KQ(e){const t=Math.max(1,Math.ceil(e/6));return n=>n===0||n===e-1||n%t===0}function ry(e){if(!e)return"";try{return new Date(e).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return""}}function YQ({num:e,name:t,onClose:n}){var $,K,G,z;en("account-projects");const[s,a]=y.useState(1),[o,i]=y.useReducer($Q,MQ),c=(($=o.report)==null?void 0:$.data)??null,d=((K=o.report)==null?void 0:K.days)??s,h=((G=o.report)==null?void 0:G.cost.phase)==="ready"?o.report.cost.range:null,f=((z=o.report)==null?void 0:z.cost.phase)==="running",[p,m]=y.useState(null),[w,j]=y.useState(()=>new Set),v=LQ(o),b=o.error,[k,N]=y.useState(null),S=y.useRef(void 0),_=y.useRef(!0);y.useEffect(()=>()=>{_.current=!1,window.clearTimeout(S.current)},[]);const E=y.useRef(null),I=mt(n,{focusRef:E}),A=yt(n),O=y.useRef(0);y.useEffect(()=>{const W=++O.current;i({type:"start",gen:W}),m(null),j(new Set),DQ({num:e,days:s,gen:W,dispatch:i})},[e,s]);const L=y.useMemo(()=>{const W=Date.now();if(!c)return null;const D=EQ(c.daily??[],c.unattributed,CQ(h),W),H=be=>be.replace(/[\\/]+$/,"").split(/[\\/]/).pop()||be||"(unknown)",ee=new Map;for(const be of D.projects)ee.set(H(be.path),(ee.get(H(be.path))??0)+1);const F=be=>{const Ce=H(be);if((ee.get(Ce)??0)<=1)return Ce;const ye=be.replace(/[\\/]+$/,"").split(/[\\/]/).slice(-2,-1)[0];return ye?`${ye}/${Ce}`:Ce},Y=D.projects.map(be=>({path:be.path,label:F(be.path)})),X=be=>({path:be.path,label:F(be.path),parentLabel:FQ(be.path,Y),cost:be.cost,tokens:be.tokens,unpricedTokens:be.unpricedTokens}),Z=Hi[sy%Hi.length],J=new Map,ne=[],ce=D.projects.slice(0,sy),he=D.projects.slice(sy);ce.forEach((be,Ce)=>{J.set(be.path,Hi[Ce%Hi.length]),ne.push({key:be.path,...X(be),color:Hi[Ce%Hi.length]})}),he.length&&ne.push({key:"__other__",label:`Other · ${he.length} project${he.length>1?"s":""}`,cost:he.reduce((be,Ce)=>be+Ce.cost,0),tokens:he.reduce((be,Ce)=>be+Ce.tokens,0),unpricedTokens:he.reduce((be,Ce)=>be+Ce.unpricedTokens,0),color:Z,muted:!0,members:he.map(X)});const le=D.totalCost,re=D.totalTokens,ae=le>0&&D.unpricedTokens===0?"cost":"tokens",de=ae==="cost"?le:re,Se=ne.map(be=>be.color),pe=D.perDay.map(be=>{const Ce=new Map;for(const[Oe,We]of be.byPath){const Re=J.get(Oe)??Z;Ce.set(Re,(Ce.get(Re)??0)+We)}const ye=new Map;let Pe=0;for(const[Oe,We]of be.unpricedByPath){const Re=J.get(Oe)??Z;ye.set(Re,(ye.get(Re)??0)+We),Pe+=We}return{day:be.day,total:be.total,costByColor:Ce,unpricedByColor:ye,unpriced:Pe}}),me=pe.reduce((be,Ce)=>Math.max(be,Ce.total),0);return{projectCount:D.projects.length,rows:ne,totalCost:le,totalTokens:re,basis:ae,denom:de,un:D.unattributed,chart:pe,maxDay:me,colorOrder:Se,unpricedTokens:D.unpricedTokens,unpricedNote:TQ(D.unpricedModels),calibrated:D.calibrated,reconciled:D.reconciled}},[c,h]),U=(W,D)=>{eo(W).then(H=>{_.current&&(window.clearTimeout(S.current),N({path:W,label:D,ok:H}),S.current=window.setTimeout(()=>{_.current&&N(null)},zQ))})},P=W=>k!=null&&k.ok&&k.path===W?"Copied":"Copy",T=c!=null&&c.trackedSince?`Tracked since ${ry(c.trackedSince)}`:"Tracking starts with this version",B=L0(d),M=qQ(d),q=v&&!!c;return vt.createPortal(r.jsx("div",{className:"modal-backdrop",...A,role:"presentation",children:r.jsxs("div",{ref:I,className:"modal ap-proj-modal",onClick:W=>W.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ap-proj-title ap-proj-sub",children:[r.jsxs("header",{className:"ap-proj-head",children:[r.jsxs("div",{className:"ap-proj-titlewrap",children:[r.jsx("div",{className:"ap-proj-title",id:"ap-proj-title",children:"Projects"}),r.jsx("div",{className:"ap-proj-sub",id:"ap-proj-sub",title:t,children:t})]}),r.jsx("div",{className:"uh-range",role:"group","aria-label":"Range",children:WQ.map(W=>r.jsx("button",{type:"button",className:"uh-range-btn","aria-pressed":s===W.days,onClick:()=>a(W.days),children:W.label},W.days))}),r.jsx("button",{ref:E,className:"glyph-btn ap-proj-close",onClick:n,"aria-label":"Close",children:"×"})]}),r.jsxs("div",{className:`ap-proj-body${q?" refreshing":""}`,"aria-busy":v,children:[v&&!c&&r.jsx(_Q,{}),!v&&b&&r.jsxs("div",{className:"ap-proj-state ap-proj-error",children:["Couldn’t load this report: ",b]}),!b&&L&&r.jsx("div",{className:"ap-proj-ready",children:L.rows.length===0?r.jsxs("div",{className:"ap-proj-state",children:[q?"Updating…":BQ(d),M!=null&&r.jsx("div",{className:"ap-proj-widen-wrap",children:r.jsxs("button",{type:"button",className:"ap-proj-copy",onClick:()=>a(M),children:["Show ",L0(M)]})}),r.jsxs("div",{className:"ap-proj-note",children:[T,". Only work from this version onward can be tied to an account."]})]}):r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"ap-proj-bar",role:"img","aria-label":`Share of ${L.basis==="cost"?et(L.totalCost):`${xt(L.totalTokens)} tokens`} across ${L.projectCount} project${L.projectCount>1?"s":""}`,children:L.rows.map(W=>{const D=L.basis==="cost"?W.cost:W.tokens,H=L.denom>0?D/L.denom*100:0;if(H<=0)return null;const ee=L.basis==="cost"?wh(W.cost,L.totalCost):`${wh(W.tokens,L.totalTokens)} of tokens`;return r.jsx("span",{className:"ap-proj-seg",style:{width:`${H}%`,background:W.color},title:`${W.label} · ${fr(W.cost,W.unpricedTokens)} · ${ee}${W.tokens?` · ${xt(W.tokens)} tokens`:""}`},W.key)})}),r.jsxs("div",{className:"ap-proj-totals",children:[r.jsx("span",{className:"ap-proj-total-cost",title:Wi(L.unpricedTokens),children:fr(L.totalCost,L.unpricedTokens)}),r.jsxs("span",{className:"ap-proj-total-tok",children:[xt(L.totalTokens)," tokens"]}),r.jsxs("span",{className:"ap-proj-total-win",children:["· ",q?"updating…":B]}),f&&r.jsx("span",{className:"ap-proj-total-pending",children:"Reconciling cost…"})]}),L.unpricedNote&&r.jsx("div",{className:"ap-proj-note",children:L.unpricedNote}),UQ(d,L.chart.length)&&r.jsxs("div",{className:"ap-proj-days",children:[r.jsxs("div",{className:"ap-proj-days-cap",children:["By day",L.chart.length>1?" · click a bar":""]}),r.jsx("div",{className:"ap-proj-days-plot",role:"group","aria-label":`Spend across ${L.chart.length} day${L.chart.length>1?"s":""}`,children:L.chart.map(W=>{const D=L.maxDay>0?W.total/L.maxDay*100:0,H=p===W.day,ee=L.rows.map(Y=>({label:Y.label,c:W.costByColor.get(Y.color)??0,u:W.unpricedByColor.get(Y.color)??0})).filter(Y=>Y.c>0||Y.u>0),F=`${ry(Date.parse(`${W.day}T00:00:00`))}, ${fr(W.total,W.unpriced)}. ${ee.map(Y=>`${Y.label} ${fr(Y.c,Y.u)}`).join(", ")}`;return r.jsx("button",{type:"button",className:`ap-proj-day${H?" selected":""}`,"aria-pressed":H,"aria-label":F,title:`${W.day} · ${fr(W.total,W.unpriced)}`,onClick:()=>m(Y=>Y===W.day?null:W.day),children:r.jsx("span",{className:"ap-proj-col",style:{height:`${D}%`},children:L.colorOrder.map((Y,X)=>{const Z=W.costByColor.get(Y)??0;return Z<=0||W.total<=0?null:r.jsx("span",{className:"ap-proj-colseg",style:{height:`${Z/W.total*100}%`,background:Y}},X)})})},W.day)})}),(()=>{const W=KQ(L.chart.length);return r.jsx("div",{className:"ap-proj-days-axis","aria-hidden":"true",children:L.chart.map((D,H)=>r.jsx("div",{className:"ap-proj-axis-cell",children:W(H)?GQ(D.day):""},D.day))})})(),(()=>{const W=p?L.chart.find(H=>H.day===p):null;if(!W)return null;const D=L.rows.map(H=>({r:H,c:W.costByColor.get(H.color)??0,u:W.unpricedByColor.get(H.color)??0})).filter(H=>H.c>0||H.u>0);return r.jsxs("div",{className:"ap-proj-day-detail",children:[r.jsxs("div",{className:"ap-proj-day-detail-head",children:[r.jsx("span",{children:ry(Date.parse(`${W.day}T00:00:00`))}),r.jsx("span",{className:"ap-proj-day-detail-total",title:Wi(W.unpriced),children:fr(W.total,W.unpriced)})]}),D.map(({r:H,c:ee,u:F})=>r.jsxs("div",{className:"ap-proj-day-detail-row",children:[r.jsx("span",{className:"ap-proj-dot",style:{background:H.color},"aria-hidden":"true"}),r.jsx("span",{className:"ap-proj-day-detail-name",children:H.label}),r.jsx("span",{className:"ap-proj-day-detail-cost",title:Wi(F),children:fr(ee,F)})]},H.key))]})})()]}),r.jsx("ul",{className:"ap-proj-list",children:L.rows.map((W,D)=>{const H=L.basis==="cost"?W.cost:W.tokens,ee=L.denom>0?H/L.denom*100:0,F=w.has(W.key),Y=`ap-proj-details-${D}`,X=F&&(!!W.path||!!W.members),Z=W.members?`${F?"Hide":"Show"} the ${W.members.length} project${W.members.length>1?"s":""} folded into Other`:`${F?"Hide":"Show"} location for ${W.label}`;return r.jsxs("li",{className:`ap-proj-row${W.muted?" muted":""}${F?" expanded":""}`,children:[r.jsx("span",{className:"ap-proj-dot",style:{background:W.color},"aria-hidden":"true"}),r.jsxs("span",{className:"ap-proj-name",children:[W.label,W.parentLabel&&r.jsxs("span",{className:"ap-proj-parent",children:[" · in ",W.parentLabel]})]}),r.jsx("span",{className:"ap-proj-track",title:L.basis==="cost"?`${wh(W.cost,L.totalCost)} of tracked cost`:`${wh(W.tokens,L.totalTokens)} of tracked tokens`,children:r.jsx("span",{className:"ap-proj-fill",style:{width:`${ee}%`,background:W.color}})}),r.jsx("span",{className:"ap-proj-cost",title:Wi(W.unpricedTokens),children:fr(W.cost,W.unpricedTokens)}),r.jsx("span",{className:"ap-proj-tok",children:xt(W.tokens)}),r.jsx("button",{type:"button",className:"glyph-btn ap-proj-info","aria-expanded":F,"aria-controls":X?Y:void 0,"aria-label":Z,onClick:()=>j(J=>{const ne=new Set(J);return ne.has(W.key)?ne.delete(W.key):ne.add(W.key),ne}),children:"ⓘ"}),F&&W.path&&r.jsxs("div",{className:"ap-proj-details",id:Y,children:[r.jsx("code",{className:"ap-proj-path",children:rT(W.path)}),r.jsx("button",{type:"button",className:"ap-proj-copy","aria-label":`${P(W.path)} location for ${W.label}`,onClick:()=>U(W.path,W.label),children:P(W.path)})]}),F&&W.members&&r.jsx("div",{className:"ap-proj-details ap-proj-other-members",id:Y,children:W.members.map(J=>r.jsxs("div",{className:"ap-proj-other-member",children:[r.jsxs("div",{className:"ap-proj-other-name",children:[J.label,J.parentLabel&&r.jsxs("span",{className:"ap-proj-parent",children:[" · in ",J.parentLabel]})]}),r.jsx("code",{className:"ap-proj-path",children:rT(J.path)}),r.jsx("span",{className:"ap-proj-cost",title:Wi(J.unpricedTokens),children:fr(J.cost,J.unpricedTokens)}),r.jsx("span",{className:"ap-proj-tok",children:xt(J.tokens)}),r.jsx("button",{type:"button",className:"ap-proj-copy","aria-label":`${P(J.path)} location for ${J.label}`,onClick:()=>U(J.path,J.label),children:P(J.path)})]},J.path))})]},W.key)})}),L.un&&r.jsxs("div",{className:"ap-proj-unattributed",children:[r.jsx("span",{className:"ap-proj-dot",style:{background:HQ},"aria-hidden":"true"}),r.jsxs("div",{className:"ap-proj-un-labels",children:[r.jsx("span",{className:"ap-proj-un-title",children:"Unattributed usage"}),r.jsx("span",{className:"ap-proj-un-tag",children:"Excluded from the project totals"})]}),r.jsx("span",{className:"ap-proj-un-cost",title:Wi(L.un.unpricedTokens),children:fr(L.un.cost,L.un.unpricedTokens,VQ)}),r.jsx("span",{className:"ap-proj-un-tok",children:xt(L.un.tokens)}),r.jsx("div",{className:"ap-proj-note",children:"Work no account could be tied to — from before tracking, or a gap."})]}),r.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:k&&(k.ok?`Copied the location of ${k.label}`:`Could not copy the location of ${k.label} — select it and copy it by hand`)}),r.jsxs("div",{className:"ap-proj-foot",children:[f?"Dollars estimated · ccusage still running":L.reconciled?"Dollars from ccusage · split by activity":L.calibrated?"Dollars from ccusage for the priced models · split by activity":h?"Dollars estimated · ccusage could not price this window":"Dollars estimated · ccusage unavailable"," · ",T]})]})})]})]})}),document.body)}function Ka(e,t){return cP(t-Math.floor(e/1e3))}function XQ(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 kj(){return r.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:[r.jsx("path",{d:"M7 1.9 12.9 12H1.1Z"}),r.jsx("path",{d:"M7 5.6v2.9"}),r.jsx("path",{d:"M7 10.3v.05"})]})}function ZQ({anchorId:e,boundaryId:t,issue:n,who:s,fetchedAt:a,nowSec:o,onClose:i,onSignIn:c,onReport:d}){const h=y.useRef(null);return r.jsx(xp,{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:r.jsxs("div",{className:"ap-pop-form",children:[r.jsxs("p",{className:"ap-pop-title ap-issue-title",id:"ap-issue-title","data-tone":n.tone,children:[n.tone==="warn"&&r.jsx(kj,{}),n.text]}),r.jsx("p",{className:"ap-pop-note ap-issue-hint",children:n.hint}),r.jsxs("p",{className:"ap-pop-note ap-issue-when",children:[r.jsx("span",{className:"ap-issue-who",children:s})," · ",a?`last collected ${Ka(a,o)}`:"never collected"]}),r.jsxs("div",{className:"ap-pop-actions",children:[d&&r.jsx("button",{type:"button",className:"ap-issue-report",onClick:()=>{i(),d()},children:"Report this"}),r.jsx("button",{type:"button",ref:h,className:"btn",onClick:()=>i(!0),children:"Done"}),n.fix&&r.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 Bc(e){return e.charAt(0).toUpperCase()+e.slice(1)}function JQ(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 s=Math.max(1,Math.ceil((e.retryAt/1e3-t)/60)),a=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} ${a} It tries again in ${s}m. No sign-in, no switch.`}}return{text:"numbers paused",hint:n}}function QQ(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 eee(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 aT={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 Zo(e,t,n){const s=nee(e,t);return!s||!(n!=null&&n.noCopyWorksNearby)||!tee(e)?s:{...s,text:aT.text,hint:aT.hint}}function tee(e){return e.staleCopy?!1:e.stopped?e.collector==="relogin_required":e.error==="invalid_grant"||e.error==="no_refresh_token"}function nee(e,t){if(e.staleCopy){const n=JQ(e.repair??null,t);return{text:Bc(n.text),hint:n.hint,fix:null,tone:"quiet",blocksSwitch:!1}}if(e.stopped){const n=eee(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 s=e.collector==="no_credentials"||e.collector==="relogin_required";return{text:Bc(n.text),hint:n.hint,fix:n.fix?Bc(n.fix):null,tone:s||e.collector==="keychain_unavailable"?"warn":"quiet",blocksSwitch:s}}if(e.error){const n=QQ(e.error);return{text:Bc(n.text),hint:n.hint,fix:n.fixable?"Sign in again":null,tone:n.fixable?"warn":"quiet",blocksSwitch:n.fixable}}return null}function oT(e){return typeof e.id=="string"&&e.id.startsWith("scoped-")}function iT(e){const t=e.filter(c=>!oT(c)),n=e.filter(c=>oT(c)),s=t.length?t:n,a=t.length?n:[],o=s.reduce((c,d)=>c&&c.pct>=d.pct?c:d,null);let i=null;for(const c of a)o&&c.pct<=o.pct||(!i||c.pct>i.pct)&&(i=c);return{shown:s,rest:a,fuller:i,peak:i??o}}function Su(e,t){return!!e.resetAt&&e.resetAt<=t}function jj(e,t){return(e.lanes??[]).some(s=>Su(s,t))?null:e.headroom}const see="\0";function Ws(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}${see}${n}`}function ree(e,t,n=Ws){const s=n(t);return e.includes(s)?e.filter(a=>a!==s):[...e,s]}const vp="slot",Nj=[{lane:"five_hour",name:"5h"},{lane:"seven_day",name:"7d"}],j4=e=>e.id.startsWith("scoped-");function aee(e){var t;return((t=Nj.find(n=>n.lane===e.id))==null?void 0:t.name)??e.label}function oee(e){if(e==="room")return"room";const t=/^(.+):(full|empty)$/.exec(e);return t?t[1]:null}function N4(e){const t=[...new Set(e.flatMap(s=>(s.lanes??[]).filter(j4).map(a=>a.label)))].sort((s,a)=>s.localeCompare(a)),n=[...Nj.map(s=>s.name),...t];return[{id:vp,label:"Slot"},...n.flatMap(s=>[{id:`${s}:full`,label:`${s} · fullest`},{id:`${s}:empty`,label:`${s} · emptiest`}]),{id:"room",label:"Most room"}]}function lT(e,t,n){const s=Nj.find(o=>o.name===t),a=(e.lanes??[]).find(o=>s?o.id===s.lane:j4(o)&&o.label===t);return a&&n!=null&&Su(a,n)?null:a&&Number.isFinite(a.pct)?a.pct:null}function iee(e,t,n=()=>!0,s){const a=[...e],o=f=>[...f.filter(n),...f.filter(p=>!n(p))];if(t==="room"){const f=p=>s==null?p.headroom:jj(p,s);return o(cT(a,p=>{const m=f(p);return Number.isFinite(m)?m:null},"desc"))}const i=/^(.+):(full|empty)$/.exec(t);if(!i)return a;const[,c,d]=i;if(!a.some(f=>lT(f,c,s)!=null))return a;const h=cT(a,f=>lT(f,c,s),d==="full"?"desc":"asc");return d==="empty"?o(h):h}function cT(e,t,n){const s=e.filter(o=>t(o)!=null),a=e.filter(o=>t(o)==null);return s.sort((o,i)=>n==="desc"?t(i)-t(o):t(o)-t(i)),[...s,...a]}function lee(e,t){return N4(t).some(n=>n.id===e)?e:vp}function I0(e,t){if(!t)return[...e];const n=new Map(t.map((o,i)=>[o,i])),s=e.filter(o=>n.has(Ws(o))).sort((o,i)=>n.get(Ws(o))-n.get(Ws(i))),a=e.filter(o=>!n.has(Ws(o)));return[...s,...a]}function Sj(e){const t=Ws(e);return t.startsWith("slot:")?t:`h:${cee(t)}`}function cee(e){let t=3735928559,n=1103547991;for(let s=0;s<e.length;s++){const a=e.charCodeAt(s);t=Math.imul(t^a,2654435761),n=Math.imul(n^a,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 S4(e,t){const n=e.keys.includes(Sj(t));return e.mode==="all"?!n:n}function uee(e,t){return{mode:e.mode,keys:ree(e.keys,t,Sj)}}function _4(e,t){return t.length>0&&t.every(n=>S4(e,n))}function dee(e,t){return _4(e,t)?O0:{mode:"all",keys:[]}}function hee(e,t){if(!Array.isArray(t))return e;const n=new Set(t.map(Sj)),s=e.keys.filter(a=>n.has(a));return s.length===e.keys.length?e:{mode:e.mode,keys:s}}const Uo=[{id:"five_hour",label:"5h",long:"5-hour"},{id:"seven_day",label:"7d",long:"7-day"}];function uT(e){return e.counted?e.pct:e.why==="login"?null:e.estimate}function fee(e){const t=uT(e.five_hour),n=uT(e.seven_day);if(t==null||n==null)return"stale";const s=+(t>=100)+ +(n>=100);return s===0?"ready":s===1?"limited":"exhausted"}function pee(e,t){const n=Uo.map(s=>e.cells[s.id]);for(const s of n)if(!s.counted&&(s.why==="login"||s.why==="none"))return{text:s.say,old:!0};return e.updatedAt==null?{text:"never read",old:!0}:n.every(s=>s.counted)?{text:"now",old:!1}:{text:Ka(e.updatedAt,t),old:!0}}const C4=15*6e4;function bp(e){return e!=null&&e>0&&Number.isFinite(e)&&Number.isFinite(new Date(e).getTime())?e:null}const E4=e=>e.alias??e.email??`account ${e.num}`;function Jc(e,t){var s,a;const n=(a=(s=e.lanes)==null?void 0:s.find(o=>o.id===t))==null?void 0:a.resetAt;return n!=null&&n>0&&Number.isFinite(n)&&Number.isFinite(new Date(n*1e3).getTime())?n:null}function P0(e,t,n){const s=Uo.find(w=>w.id===t).label,a=(e.lanes??[]).find(w=>w.id===t),o=a&&Number.isFinite(a.pct)?T4(a.pct):null,i=Zo(e,n),c=Jc(e,t),d=c!=null&&c<=n,h=R4(a,e.fetchedAt,n),f=(w,j)=>({counted:!1,why:w,say:j,last:o,estimate:o,resetAt:d?null:Jc(e,t),reset:h});if(i!=null&&i.blocksSwitch)return f("login",i.text);if(o==null)return f("none",`No ${s} reading`);if(h)return f("reset",h);const p=bp(e.fetchedAt);return e.stale||e.staleCopy===!0||e.stopped===!0||p==null||n*1e3-p>C4?f("stale",p!=null?`Updated ${Ka(p,n)}`:"Never read"):{counted:!0,pct:o,resetAt:Jc(e,t)}}const T4=e=>Math.min(100,Math.max(0,e));function R4(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 s=bp(t),a=s!=null?`read ${Ka(s,n)}`:"last read";return`Reported reset time passed ${Ka(e.resetAt*1e3,n)}, ${Ya(T4(e.pct))}% when ${a}`}function mee(e,t){const n=Uo.find(h=>h.id===t);let s=0,a=0,o=0;const i=[];for(const h of e){const f=h.cells[t],p=f.counted?f.pct:f.estimate;p!=null&&(s+=p,o++,f.counted&&a++,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:a,included:o,total:e.length,used:o?s/o:null,nextReset:d}}function _j(e,t){const n=e.map(a=>{const o={five_hour:P0(a,"five_hour",t),seven_day:P0(a,"seven_day",t)};return{num:a.num,key:Ws(a),name:E4(a),active:a.active,heldOut:a.disabled===!0,cells:o,resets:{five_hour:Jc(a,"five_hour"),seven_day:Jc(a,"seven_day")},status:fee(o),updatedAt:bp(a.fetchedAt)}}),s=n.filter(a=>a.status==="ready").length;return{rows:n,windows:Uo.map(a=>mee(n,a.id)),roomInBoth:s}}function Rc(e,t){return(e==null?void 0:e.key)===t?{key:t,dir:e.dir==="asc"?"desc":"asc"}:{key:t,dir:"asc"}}const gee={ready:0,limited:1,exhausted:2,stale:3};function yee(e){return e.counted?e.pct:e.reset?e.estimate:e.last}function dT(e,t){return t==="status"?gee[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:yee(e.cells[t])}function wee(e,t){if(!t)return[...e];const n=t.dir==="asc"?1:-1,s=new Map(e.map((o,i)=>[o.num,i])),a=(o,i)=>{if(t.key==="account")return n*o.name.localeCompare(i.name,void 0,{sensitivity:"base"});const c=dT(o,t.key),d=dT(i,t.key);return c==null||d==null?c==null?d==null?0:1:-1:n*(c-d)};return[...e].sort((o,i)=>a(o,i)||s.get(o.num)-s.get(i.num))}function Ya(e){return e>=100?100:Math.min(99,Math.round(e))}function xee(e){const t=Ya(e);return{used:t,available:100-t}}function vee(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}const A4=new Set(["awaiting_url","awaiting_code","registering"]);function M4(e){return e!=null&&A4.has(e)}function $4(e){return e!=null&&e!=="done"&&!A4.has(e)}const L4="the sign-in ended before it finished — the deck restarted, or it was cancelled in another tab",bee="the sign-in did not complete";function kee({state:e,serverError:t,localError:n}){const s=e==="idle";return{title:s?"Sign-in ended":"Sign-in failed",message:n||t||(s?L4:bee)}}function hT({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 fT({started:e,state:t}){return!e||t==="done"?null:{action:"login-cancel"}}function jee({login:e,started:t,loginError:n,loginBusy:s}){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":$4(e==null?void 0:e.state)||n&&t&&!s?"ended":s||M4(e==null?void 0:e.state)?"asking":"primer"}function Cj(e,t){return t?Kt(e,t):void 0}const Nee={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 ${Rt}`,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"},See={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",login_expired:"that account's login expired, so the deck did not switch to it — sign in again to use it",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"},Ej=`claude-swap could not read the login keychain — start ${Rt} from a Terminal window rather than a background service`,_ee={unreadable_here:{short:"Keychain locked on this Mac",long:`${Ej}.`},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 Ef(e){return e?Kt(_ee,e)??null:null}const I4={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 s=n==null?null:I4[n];if(s)return s;if((e==null?void 0:e.reason)!=="no_cswap"&&/keychain/i.test(_u(e)))return Ej;const a=Cj(See,e==null?void 0:e.reason);return a||(e==null?void 0:e.reason)||t}function _u(e){return((e==null?void 0:e.output)||(e==null?void 0:e.detail)||(e==null?void 0:e.error)||"").trim()}const Cee={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"},Eee="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 Tee(e){return/\bnpx\b/i.test(e)&&/(command not found|not found|not recognized|ENOENT)/i.test(e)}const Ree="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",Aee="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",Mee=e=>/\b(?:ERR_)?MODULE_NOT_FOUND\b|cannot find (?:module|package)/i.test(e),$ee=/node_modules[\\/]npm[\\/]bin[\\/]|\bnpm-prefix\.js\b|\bnp[mx][-.][\w.-]*cli\.js\b/i,Lee=/[\\/]_npx[\\/]/i,Iee=`the copy of ccusage ${Rt} installed for itself`;function Oee(e){const t=String((e==null?void 0:e.install)??"").replace(/\s+/g," ").trim();return t.length>240?`${t.slice(0,239)}…`:t}function Ave(e,t){const n=Pee(e,t),s=Oee(e);switch(e==null?void 0:e.stage){case"npx":return s?`ccusage failed on both of its paths. The managed install failed first — ${s} — and the deck then fell back to npx, where ${Ac(n)}`:`there is no managed copy of ccusage on this machine, and the npx fallback failed: ${Ac(n)}`;case"managed":return`${Iee} failed to run: ${Ac(n)}`;case"path":return e.bin?`the ccusage this deck found at ${e.bin} failed to run: ${Ac(n)}`:`the ccusage this deck found on your PATH failed to run: ${Ac(n)}`;default:return n}}const Ac=e=>/^[A-Z][a-z]/.test(e)?e[0].toLowerCase()+e.slice(1):e;function Pee(e,t){const n=_u(e);if(Mee(n)){if(Lee.test(n))return Aee;if($ee.test(n))return Ree}if(Tee(n))return Eee;const s=Cj(Cee,e==null?void 0:e.reason);return s||(e==null?void 0:e.reason)||t}function el(e,t,n){const s=n==null?null:I4[n];if(s)return s;if(e!=null&&e.detail)return e.detail;if(e!=null&&e.error&&$4(e.state))return e.error;const a=Cj(Nee,e==null?void 0:e.reason);return a||(e!=null&&e.error?e.error:(e==null?void 0:e.reason)||t)}function xr(e,t){if(e==null)return"not seen";const n=Math.max(0,Math.round((t-e)/1e3));if(n<90)return"now";const s=Math.round(n/60);if(s<60)return`${s}m ago`;const a=Math.round(s/60);return a<48?`${a}h ago`:`${Math.round(a/24)}d ago`}const Dee={keychain_unavailable:{short:"Keychain locked on the other Mac",long:`the other Mac could not export it. On that Mac: ${Ej}. The next round brings it.`},"in use":{short:"in use on the other deck",long:"the other deck is using this login right now and does not send it: two machines on one login race to renew it, and the loser is signed out. It comes on the first round after that deck switches away — or sign in to it here, which gives this machine a login of its own."}};function F0(e){return e.why?Kt(Dee,e.why)??Ef(e.why):null}const Tj={"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"}},Fee={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 pT(e){var s;const t=Bee[e];if(t)return t;const n=(s=/\b(E[A-Z]{3,})\b/.exec(e))==null?void 0:s[1];return n&&Fee[n]||e}const Bee={"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 kp(e,t){var f;if(!e)return null;if(e.error&&((f=e.done)!=null&&f.length)){const p=kp({...e,error:void 0},t),m=` · ${xr(e.at,t)}`;return{...p,text:`${p.text.slice(0,-m.length)}, then ${pT(e.error)}${m}`,tone:"bad"}}if(e.error)return Tj[e.error]??{text:pT(e.error),tone:"bad"};const n=e.done??[];if(!n.length)return{text:`all logins fine · ${xr(e.at,t)}`,tone:"idle"};const s=n.filter(p=>p.ok),a=s.length===1?"login":"logins",o=n.map(p=>({d:p,why:F0(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=xr(e.at,t);return s.length===n.length?{text:`${s.length} ${a} arrived${c} · ${h}`,tone:o.length?"warn":"ok",...d?{hint:d}:{}}:{text:`${s.length} of ${n.length} logins arrived${c} · ${h}`,tone:"bad",...d?{hint:d}:{}}}const qee=9e4;function Uee({error:e,host:t,port:n},s,a,o=45317){if(e!=="handshake timed out")return null;const i=(t??"").trim();if(!i)return null;const c=s.filter(h=>h.addr===i&&h.port&&h.at>0&&a-h.at<qee);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 jp(e,t){var n,s;return(n=e.last)!=null&&n.error&&!Tj[e.last.error]?!1:!!((s=e.last)!=null&&s.at&&t-e.last.at<B0||e.lastSeen!=null&&t-e.lastSeen<B0)}const B0=95e3;function Wee(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 s=(e.peers??[]).filter(p=>p.paired!==!1||p.met);if(!s.length)return{text:"no deck paired yet",tone:"idle"};const a=p=>p.waiting?O4(p.lastSeen,t):jp(p,t),o=p=>{var m;return!p.waiting&&((m=p.last)==null?void 0:m.error)==="waiting for the other deck to accept this one"},i=e.aliases??{};let c=0,d=0,h=0;for(const p of P4(s,m=>Aj(m,m.peerFp??m.fp,i).name,m=>m.addr??"")){const m=p.filter(a);if(!m.length){h++;continue}c++,m.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 Hee(e,t,n){if(n)return"checking…";if(e==null)return"not checked yet";const s=xr(e,t);return s==="now"?"checked just now":`checked ${s}`}function Rj(e,t){const n=Math.max(0,Math.round((t-e)/1e3));if(n<90)return"just now";const s=Math.round(n/60);return s<60?`${s}m ago`:`${Math.round(s/60)}h ago`}function O4(e,t){return e!=null&&t-e<B0}function zee(e,t){if(e==null)return{text:"one-way · has not called yet",here:!1};const n=O4(e,t);return{text:n?"online · one-way, it calls in":`one-way · last online ${xr(e,t)}`,here:n}}function mT(e,t,n){return t?"online":e.lastSeen!=null?`last online ${xr(e.lastSeen,n)}`:e.waiting?"has not called yet":"never reached"}function Vee(e,t){if(!e)return[];const n=[],s=new Set,a=(p,m)=>p.name.localeCompare(m.name,void 0,{numeric:!0}),o=e.aliases??{};for(const p of e.pending??[])!(p!=null&&p.fp)||s.has(p.fp)||(s.add(p.fp),n.push(Gee(p,o,t)));const i=[],c=[];for(const p of e.peers??[]){const m=p.peerFp??p.fp;!m||s.has(m)||(s.add(m),!p.paired&&p.manual&&!p.met?c.push(Kee(p,m,t)):i.push(Yee(p,m,o,t)))}n.push(...Qee(i).sort(a),...c.sort(a));const d=[];for(const p of e.strangers??[])!(p!=null&&p.fp)||s.has(p.fp)||(s.add(p.fp),d.push(Zee(p,o,e.pairingMode)));n.push(...d.sort(a));const h=[];for(const p of e.declined??[])!(p!=null&&p.fp)||s.has(p.fp)||(s.add(p.fp),h.push(Jee(p,o)));n.push(...h.sort(a));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 Gee(e,t,n){const s=Np(t,e.fp,e.name||e.fp);return{fp:e.fp,...s,addr:e.addr??"",kind:"asks",state:`wants to pair · ${Rj(e.at,n)}`,tone:"wait",here:!0,hint:`${s.name} at ${e.addr}${e.via==="tailscale"?", over Tailscale,":""} is waiting for an answer.`,...Sp(e.via)}}function Kee(e,t,n){var o;const s=kp(e.last,n),a=e.addr?`${e.addr}:${e.port}`:"";return{fp:a,name:a||e.name||t,addr:e.addr??"",kind:"dialling",state:s?q0(s):"trying…",tone:s?s.tone:"idle",here:!1,hint:(o=e.last)!=null&&o.error?`Nothing has answered at ${a} yet — ${e.last.error}.`:`Dialling ${a} until something answers.`,...Sp(e.via)}}function Yee(e,t,n,s){var w,j,v,b;const a=kp(e.last,s),o=jp(e,s),i=e.addr?`${e.addr}:${e.port}`:"",c=e.waiting?zee(e.lastSeen,s):null,d=c?c.here:o,h=!c&&a?d?`online · ${q0(a)}`:`${q0(a)} · ${mT(e,d,s)}`:c?c.text:mT(e,d,s),f=(w=e.last)!=null&&w.error?Tj[e.last.error]:null,p=!c&&d&&!((j=e.last)!=null&&j.error)&&!(((v=e.last)==null?void 0:v.done)??[]).length,m=Aj(e,t,n);return{fp:t,...m,addr:e.addr??"",kind:"paired",state:h,quiet:p,tone:f?f.tone==="bad"?"bad":"wait":a?a.tone:d?"ok":"idle",here:c?c.here:o,...Sp(e.via),hint:c?`${m.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 ${xr(e.lastSeen,s)}.`} Add its address through Add a deck, the link at the top of this view, to reach it either way.`:`${m.name}${i?` at ${i}`:""}${(b=e.last)!=null&&b.error?` — ${e.last.error}`:""}${a!=null&&a.hint?` — ${a.hint}`:""}`}}function Aj(e,t,n){return e.manual&&!e.met?{name:e.addr?`${e.addr}:${e.port}`:""}:Np(n,t,e.name||t)}function Xee(e,t){return Aj(e,e.peerFp??e.fp,t).name}function Zee(e,t,n){const s=Np(t,e.fp,e.name||e.fp);return{fp:e.fp,...s,addr:e.addr??"",kind:"nearby",state:n==="invite"?"needs an invite":"not paired yet",tone:"idle",here:!0,hint:e.via==="tailscale"?`${s.name} at ${e.addr} is on your tailnet and nothing is shared with it.`:`${s.name} at ${e.addr} is on this network and nothing is shared with it.`,...Sp(e.via)}}function Jee(e,t){const n=Np(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 Np(e,t,n){const s=t?e[t]:void 0;return s&&s!==n?{name:s,self:n}:{name:n}}function Sp(e){return e==="tailscale"?{via:"tailscale"}:{}}function q0(e){return e.text.replace(/ · .*$/,"")}function Qee(e){return P4(e,t=>t.name,t=>t.addr).map(ete)}function P4(e,t,n){const s=new Map;for(const o of e){const i=s.get(t(o));i?i.push(o):s.set(t(o),[o])}const a=[];for(const o of s.values()){const i=[...new Set(o.map(n).filter(Boolean))];if(i.length>1){for(const c of i)a.push(o.filter(d=>n(d)===c));for(const c of o)n(c)||a.push([c])}else a.push(o)}return a}function ete(e){const[t,...n]=[...e].sort((s,a)=>Number(a.here)-Number(s.here)||+!!a.addr-+!!s.addr);return n.length?{...t,twins:n}:t}function gT(e,t){return t?e.map(n=>t[n.fp]?{...n,name:t[n.fp]}:n):e}function Cu(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 tte(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 s=t.filter(i=>i.kind==="paired");if(!s.length)return{text:"On · none paired yet",tone:"idle",live:!1};const a=s.filter(i=>i.here).length;return a?a===s.length?{text:`${a} online`,tone:"ok",live:!0}:{text:`${a} of ${s.length} online`,tone:"ok",live:!0}:{text:`none of ${s.length} online`,tone:"idle",live:!1}}function nte(e,t){const n=e.filter(f=>f.kind==="asks"),s=e.filter(f=>f.kind!=="asks"),a=s.filter(f=>f.here),o=s.filter(f=>!f.here),i=o.filter(f=>f.tone==="bad").length,c=t||a.length===0,d=c?[...a,...o]:a,h=s.filter(f=>f.kind==="paired").length;return{asks:n,rest:s,live:a,folded:o,troubled:i,showFolded:c,shown:d,paired:h}}function yT(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,...t.active?{active:!0}:{}}))}function ste(e,t){if((t==null?void 0:t.sendInUse)===!0)return e;const n=new Set(e.filter(s=>s.active).map(s=>s.key));return e.map(s=>n.has(s.key)?{...s,shareable:!1,inUse:!0}:s)}function rte(e,t,n){if(!(t!=null&&t.enabled))return!1;const s=(t.peers??[]).filter(o=>o.paired&&jp(o,n));if(s.some(o=>{var i,c,d;return ate((i=o.offers)==null?void 0:i.current)&&!((d=(c=o.offers)==null?void 0:c.accounts)!=null&&d.some(h=>h.key===e))}))return!1;const a=s.map(o=>{var i,c;return(c=(i=o.offers)==null?void 0:i.accounts)==null?void 0:c.find(d=>d.key===e)}).filter(o=>o!=null);return a.length>0&&a.every(o=>!o.alive)}const ate=e=>!!e&&typeof e=="object"&&e.hidden===!0;function ote(e,t,n,s){if(!(n!=null&&n.enabled)||n.running===!1)return!1;const a=String(t??"").trim().toLowerCase();return(n.peers??[]).some(o=>{var c,d,h,f;if(!o.paired||!jp(o,s))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()===a))})}function ite(e,t){if(!(t!=null&&t.enabled)||!(t.shared??[]).includes(e))return null;const n=(t.peers??[]).filter(s=>s.paired&&!(s.notOffered??[]).includes(e)).map(s=>Xee(s,t.aliases??{})).filter(Boolean);return[...new Set(n)].sort((s,a)=>s.localeCompare(a))}function lte(e,t){return e.flatMap(n=>{const s=ite(n.key,t);return s?[[n.key,{to:s,inUse:n.inUse===!0}]]:[]})}function wT(e,t=!1){const n=e.length===1?e[0]:`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`;return t?e.length?`Shared on Local network: in use here · not sent to ${n} while this deck is on it.`:"Shared on Local network: in use here · not sent while this deck is on it. None is paired yet.":e.length?`Shared on Local network: offered to ${n}.`:"Shared on Local network: offered to every deck you pair with. None is paired yet."}function cte(e){return e>=90?"hi":e>=70?"mid":void 0}function ute({lane:e,nowSec:t,readAt:n,frozen:s,sortedBy:a}){const o=Math.min(100,Math.max(0,e.pct)),i=Su(e,t),c=s||i,d=c?"var(--muted)":o>=90?"var(--err)":o>=70?"var(--warn)":"var(--accent)",h=e.resetAt&&!c?Pu(e.resetAt,t):null,f=i?R4(e,n,t):null;return r.jsxs("div",{className:"ap-lane","data-sort-key":a?"":void 0,children:[r.jsx("span",{className:"ap-lane-label",title:e.label,children:e.label}),r.jsx("div",{className:"ap-lane-track",children:!i&&r.jsx("div",{className:"ap-lane-fill",style:{width:`${o===0?1.5:o}%`,background:d,opacity:o===0||c?.4:1}})}),i?r.jsx("span",{className:"ap-lane-pct",style:{color:d},"data-reset":"",title:f??void 0,children:f?r.jsxs(r.Fragment,{children:[r.jsx("span",{"aria-hidden":!0,children:"reset"}),r.jsx("span",{className:"vis-hidden",children:f})]}):"reset"}):r.jsxs("span",{className:"ap-lane-pct",style:{color:d},children:[Math.round(o),"%"]}),r.jsx("span",{className:"ap-lane-reset",title:h?`${e.label} resets in ${h}`:void 0,children:h&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"vis-hidden",children:"resets in "}),h]})})]})}function dte({a:e,nowSec:t,lan:n,opened:s,onToggleLanes:a,busy:o,pressProps:i,onSwitch:c,menuOpen:d,onOpenMenu:h,onCloseMenu:f,refusal:p,onDismissRefusal:m,onSignIn:w,switchedHere:j,swapped:v,displaced:b,issueExpanded:k,onOpenIssue:N,sortKey:S=null,home:_=null}){const E=e.lanes.filter($=>!Su($,t)),{shown:I}=iT(e.lanes),{fuller:A}=iT(E),O=S==="room"?E.reduce(($,K)=>$&&$.pct>=K.pct?$:K,null):S?e.lanes.find($=>aee($)===S)??null:null,L=Zo(e,t,n),U=e.active||s,P=e.alias??e.email??`account ${e.num}`,T=e.alias&&e.email?`${e.alias} · ${e.email}`:P,B=e.stale||(L==null?void 0:L.blocksSwitch)===!0,M=A?[...I,A]:I,q=e.fetchedAt?Ka(e.fetchedAt,t):null;return r.jsxs("li",{className:`ap-account${e.active?" active":""}`,"aria-current":e.active?"true":void 0,"data-open":U?"":void 0,"data-frozen":B?"":void 0,children:[!e.active&&r.jsx("button",{type:"button",className:"ap-row-open",id:`ap-row-${e.num}`,title:T,"aria-expanded":U,"aria-controls":U?`ap-detail-${e.num}`:void 0,"aria-describedby":[e.alias&&e.email?`ap-email-${e.num}`:null,_?`ap-home-${e.num}`:null,n!=null&&n.sharedTo?`ap-shared-${e.num}`:null,!U&&!(L!=null&&L.blocksSwitch)?`ap-quota-${e.num}`:null].filter(Boolean).join(" ")||void 0,onClick:()=>a(),children:r.jsxs("span",{className:"vis-hidden",children:[P,", ",U?"hide details":"details"]})}),r.jsxs("div",{className:"ap-account-head",children:[e.active?r.jsx("span",{className:"ap-live",title:`Active account · slot ${e.num}`,children:r.jsxs("span",{className:"vis-hidden",children:["Active account, slot ",e.num,":"]})}):r.jsx("span",{className:"ap-num",children:e.num}),e.alias&&r.jsx("span",{className:"ap-alias",title:e.alias,children:e.alias}),r.jsx("span",{className:"ap-email",id:`ap-email-${e.num}`,title:e.email??void 0,children:e.email}),_&&r.jsxs("span",{className:"ap-home",id:`ap-home-${e.num}`,title:_,children:[r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[r.jsx("path",{d:"M2.2 6.6 7 2.6l4.8 4"}),r.jsx("path",{d:"M3.6 5.6v5.8h6.8V5.6"}),r.jsx("path",{d:"M6 11.4V8.6h2v2.8"})]}),r.jsx("span",{className:"vis-hidden",children:_})]}),(n==null?void 0:n.sharedTo)&&r.jsxs("span",{className:"ap-shared",id:`ap-shared-${e.num}`,title:wT(n.sharedTo,n.sharedInUse),children:[r.jsxs("svg",{width:"12",height:"12",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":!0,children:[r.jsx("circle",{cx:"10.5",cy:"3.2",r:"1.7"}),r.jsx("circle",{cx:"3.5",cy:"7",r:"1.7"}),r.jsx("circle",{cx:"10.5",cy:"10.8",r:"1.7"}),r.jsx("path",{d:"M5.2 6.1 8.8 4.1M5.2 7.9l3.6 2"})]}),r.jsx("span",{className:"vis-hidden",children:wT(n.sharedTo,n.sharedInUse)})]}),e.disabled&&r.jsx("span",{className:"ap-held",children:"held out"}),!e.active&&!e.disabled&&!(L!=null&&L.blocksSwitch)&&r.jsx("button",{type:"button",className:"ap-switch",...i(`switch-${e.num}`),onClick:()=>c(e.num,P),"aria-label":`Switch to ${P}`,title:`Switch to ${e.alias??e.email}`,children:o===`switch-${e.num}`?"…":"Switch"}),r.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:$=>{$.key!=="ArrowDown"&&$.key!=="ArrowUp"||($.preventDefault(),h(e.num,$.key==="ArrowUp"?"last":"first"))},children:r.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"currentColor","aria-hidden":!0,children:[r.jsx("circle",{cx:"2.8",cy:"7",r:"1.15"}),r.jsx("circle",{cx:"7",cy:"7",r:"1.15"}),r.jsx("circle",{cx:"11.2",cy:"7",r:"1.15"})]})})]}),p&&r.jsxs("div",{className:"ap-failure ap-row-failure",role:"alert",children:[r.jsx("span",{className:"ap-failure-text",title:p.raw||void 0,children:p.text}),p.signIn&&w&&r.jsx("button",{type:"button",className:"ap-fix ap-failure-fix",onClick:()=>w(e.email),"aria-label":`Sign in again as ${e.email??P}`,title:"Open the sign-in dialog. Signing in as this account replaces its expired login in place — it keeps its slot, its alias and its history.",children:"Sign in again"}),r.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>m(),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),e.active&&j&&r.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."}),v&&(()=>{const $=(b==null?void 0:b.alias)??(b==null?void 0:b.email)??"the account that was there";return r.jsxs("p",{className:"ap-note ap-swap-note",title:`Slot ${v.at} was taken, so the two accounts traded places: ${$} now holds slot ${v.displaced}.`,children:["swapped with slot ",v.displaced]})})(),L&&r.jsxs("div",{className:"ap-issue-line",children:[r.jsxs("button",{type:"button",id:`ap-issue-${e.num}`,className:"ap-issue","data-tone":L.tone,"aria-haspopup":"dialog","aria-expanded":k,"aria-controls":k?"ap-issue-pop":void 0,onClick:()=>N(e.num,`ap-issue-${e.num}`),children:[L.tone==="warn"&&r.jsx(kj,{}),r.jsx("span",{className:"ap-issue-text",children:L.text})]}),!U&&r.jsx("span",{className:"ap-issue-age",title:"When claude-swap last read this account's usage",children:q??"never collected"})]}),!U&&!(L!=null&&L.blocksSwitch)&&r.jsxs("p",{className:"ap-quota",id:`ap-quota-${e.num}`,children:[M.length?M.map($=>r.jsxs("span",{className:"ap-q","data-sort-key":$.id===(O==null?void 0:O.id)?"":void 0,children:[r.jsx("span",{className:"ap-q-label",children:$.label})," ",Su($,t)?r.jsx("span",{className:"ap-q-pct",title:`${$.label} has reset since this reading`,children:"reset"}):r.jsxs("span",{className:"ap-q-pct","data-level":B?void 0:cte($.pct),children:[Math.round($.pct),"%"]})]},$.id)):r.jsx("span",{className:"ap-q-label",children:"no usage recorded yet"}),e.stale&&!L&&r.jsx("span",{className:"ap-q-age","data-never":q?void 0:"",title:"When claude-swap last read this account's usage",children:q??"never collected"})]}),U&&r.jsxs("div",{className:"ap-detail",id:`ap-detail-${e.num}`,children:[r.jsx("div",{className:"ap-lanes",children:e.lanes.length?e.lanes.map($=>r.jsx(ute,{lane:$,nowSec:t,readAt:e.fetchedAt,frozen:B,sortedBy:$.id===(O==null?void 0:O.id)},$.id)):r.jsx("div",{className:"ap-hint",children:"No usage recorded yet."})}),r.jsx("div",{className:"ap-meta",children:e.fetchedAt?r.jsxs("span",{className:`ap-age${e.stale&&!L?" 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 ",Ka(e.fetchedAt,t),L!=null&&L.blocksSwitch?"":XQ(e.nextAt,t)]}):r.jsx("span",{className:"ap-age ap-stale",title:"claude-swap has not read this account yet",children:"never collected"})})]})]})}function hte({data:e}){return r.jsx("div",{className:"ap-empty",children:e.reason==="cswap_installing"?r.jsxs(r.Fragment,{children:[r.jsx("span",{children:"Installing claude-swap…"}),r.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"?r.jsxs(r.Fragment,{children:[r.jsx("span",{children:"claude-swap isn't installed."}),r.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&&r.jsx("code",{className:"ap-cmd",children:e.hint}),r.jsxs("span",{className:"ap-hint",children:["Then add an account with the ",r.jsx("strong",{children:"+"})," button above."]})]}):e.reason==="cswap_refused"?r.jsxs(r.Fragment,{children:[r.jsx("span",{children:"claude-swap was installed, but not the version the deck asked for."}),r.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"?r.jsxs(r.Fragment,{children:[r.jsx("span",{children:"No accounts added yet."}),r.jsxs("span",{className:"ap-hint",children:["claude-swap is installed but has nothing in its store. Use the ",r.jsx("strong",{children:"+"})," above to sign one in, or to paste one shared from another deck."]})]}):r.jsxs(r.Fragment,{children:[r.jsx("span",{children:"Couldn't read the account store."}),r.jsxs("span",{className:"ap-hint",children:["claude-swap is installed, but its store could not be read",e.reason?` (${e.reason})`:"","."]})]})})}function fte({canShare:e,canReport:t,onAdd:n,onReport:s,onShareSet:a,onReload:o,pressProps:i,reloading:c,closeButton:d}){return r.jsxs("div",{className:"ap-header",children:[r.jsx("h2",{children:"Claude accounts"}),r.jsxs("div",{className:"ap-header-right",children:[r.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:r.jsx("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":!0,children:r.jsx("path",{d:"M7 2.2v9.6M2.2 7h9.6"})})}),t&&r.jsx("button",{type:"button",className:"glyph-btn",onClick:()=>s(),"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:r.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":!0,children:[r.jsx("path",{d:"M2.5 10.9A5.2 5.2 0 1 1 11.5 10.9"}),r.jsx("path",{d:"M7 8.3l2.1-2.1"})]})}),e&&r.jsx("button",{type:"button",className:"glyph-btn",onClick:()=>a(),"aria-label":"Share accounts with another deck",title:`Copy several accounts to another ${Rt} in one paste. The text carries a live login for each one — treat it as those passwords.`,children:r.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:[r.jsx("path",{d:"M3.3 10.7L10.7 3.3"}),r.jsx("path",{d:"M5.5 3.3h5.2v5.2"})]})}),r.jsx("button",{type:"button",className:"glyph-btn ap-refresh",onClick:()=>o(),...i("reload",c),"aria-label":"Reload accounts",title:"Reload from claude-swap",children:r.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:[r.jsx("path",{d:"M11.6 6.2A4.8 4.8 0 1 0 11 9.6"}),r.jsx("path",{d:"M11.9 2.6v3.7h-3.6"})]})}),d]})]})}function bn({children:e,narrow:t}){return r.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 pte=()=>r.jsxs(bn,{children:[r.jsx("path",{d:"M5.4 3.6h6.6M5.4 7h6.6M5.4 10.4h6.6"}),r.jsx("path",{d:"M2.2 3.6h.2M2.2 7h.2M2.2 10.4h.2"})]}),mte=()=>r.jsxs(bn,{children:[r.jsx("circle",{cx:"7",cy:"4.6",r:"2.4"}),r.jsx("path",{d:"M2.4 12c0-2.3 2.1-3.7 4.6-3.7s4.6 1.4 4.6 3.7"})]}),gte=()=>r.jsxs(bn,{narrow:!0,children:[r.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"}),r.jsx("path",{d:"M7 1.6v1.5M7 10.9v1.5"})]}),yte=()=>r.jsxs(bn,{children:[r.jsx("line",{x1:"3",y1:"11.5",x2:"3",y2:"7"}),r.jsx("line",{x1:"7",y1:"11.5",x2:"7",y2:"3"}),r.jsx("line",{x1:"11",y1:"11.5",x2:"11",y2:"8.5"})]}),wte=()=>r.jsxs(bn,{children:[r.jsx("rect",{x:"3.6",y:"3.6",width:"6.8",height:"6.8",rx:"1.2"}),r.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"})]}),xte=()=>r.jsxs(bn,{children:[r.jsx("circle",{cx:"7",cy:"7",r:"5"}),r.jsx("path",{d:"M7 2v5l3.5-3.5"}),r.jsx("circle",{cx:"4.5",cy:"8.5",r:".7"})]}),vte=({watching:e})=>r.jsxs(bn,{children:[r.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?r.jsx("circle",{cx:"7",cy:"7",r:"1.8",fill:"currentColor",stroke:"none"}):r.jsx("line",{x1:"2.4",y1:"11.6",x2:"11.6",y2:"2.4"})]}),bte=()=>r.jsxs(bn,{children:[r.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"}),r.jsx("circle",{cx:"7",cy:"7",r:"1.9"})]}),kte=()=>r.jsxs(bn,{children:[r.jsx("path",{d:"M2.2 3.3h9.6v5.3H6.1L3.5 10.8V8.6H2.2Z"}),r.jsx("path",{d:"M7 4.9v1.7"}),r.jsx("path",{d:"M7 7.7v.05"})]}),jte=()=>r.jsx(bn,{children:r.jsx("path",{d:"M4.6 2.9v8.2L11.1 7Z"})}),Nte=()=>r.jsxs(bn,{children:[r.jsx("path",{d:"M11.6 6.2A4.8 4.8 0 1 0 11 9.6"}),r.jsx("path",{d:"M11.9 2.6v3.7h-3.6"})]}),Ste=()=>r.jsxs(bn,{children:[r.jsx("path",{d:"M7 1.6v5"}),r.jsx("path",{d:"M4.2 3.6a4.8 4.8 0 1 0 5.6 0"})]}),_te=()=>r.jsx(bn,{children:r.jsx("path",{d:"M2 5h10v7H2z M4 5l6-3 M4 8h3 M9 8h1 M4 10h1 M8 10h2"})}),Cte=()=>r.jsx(bn,{children:r.jsx("path",{d:"M8.8 1.5a3 3 0 0 0-3.7 3.7l-3 3a1.8 1.8 0 0 0 2.5 2.5l3-3a3 3 0 0 0 3.7-3.7L9.4 5.9 7 3.5z"})}),Ete=()=>r.jsxs(bn,{children:[r.jsx("circle",{cx:"7",cy:"7",r:"5"}),r.jsx("path",{d:"M7 3.8V7l2.2 1.4"})]});function xT(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`}function Tte(e,t,n=!1){const s=new Date(t*1e3),a=Array.from({length:7},(c,d)=>{const h=new Date(s.getFullYear(),s.getMonth(),s.getDate()+d);return{key:xT(h),date:h,entries:[],scheduled:0,outdated:0}}),o=new Map(a.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=P0(c,"seven_day",t),m=Zo(c,t),w=bp(c.fetchedAt),j=w==null,v=n||j||c.stale||c.staleCopy===!0||c.stopped===!0||(m==null?void 0:m.blocksSwitch)===!0||t*1e3-w>C4,b=n?"Last saved reading":m!=null&&m.blocksSwitch||c.staleCopy||c.stopped?(m==null?void 0:m.text)??"Not collecting":j?"Never read":v?`${c.stale?"Marked stale · ":""}Read ${Ka(w,t)}`:null,k={key:Ws(c),name:E4(c),active:c.active,heldOut:c.disabled,at:f,used:p.counted?p.pct:p.last,stale:v,note:b};if(f==null)i.push({...k,reason:"unknown"});else if(f<=t)i.push({...k,reason:"passed"});else{const N=o.get(xT(new Date(f*1e3)));N?(N.entries.push(k),v?N.outdated++:N.scheduled++):i.push({...k,reason:"outside"})}}for(const c of a)c.entries.sort((d,h)=>d.at-h.at);return{days:a,unscheduled:i}}const qh=e=>e.toLocaleDateString(void 0,{weekday:"short"}),Tf=e=>e.toLocaleDateString(void 0,{month:"short",day:"numeric"}),Qc=e=>e.toLocaleDateString(void 0,{weekday:"long",month:"long",day:"numeric",year:"numeric"}),Mj=(e,t)=>e-t<60?"less than 1m":Pu(e,t);function _p({at:e}){const t=new Date(e*1e3);return r.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 Uh({entry:e}){return r.jsxs("span",{className:"ap-reset-name",children:[r.jsx("span",{children:e.name}),e.active&&r.jsx("span",{className:"ap-report-current",children:"Current"}),e.heldOut&&r.jsx("span",{className:"ap-report-tag",children:"held out"})]})}function D4({entry:e,row:t,nowSec:n,withReading:s=!1,older:a=!1,context:o}){return r.jsxs("details",{className:"ap-reset-account",children:[r.jsxs("summary",{children:[o?r.jsxs("span",{className:"ap-reset-summary-other",children:[r.jsx(Uh,{entry:e}),o]}):s?r.jsxs("span",{className:"ap-reset-summary-content",children:[r.jsx(Uh,{entry:e}),r.jsx(F4,{entry:e,older:a})]}):r.jsx(Uh,{entry:e}),r.jsx("span",{className:"vis-hidden",children:" · Account details"})]}),r.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 r.jsxs("p",{children:[r.jsx("strong",{children:i==="five_hour"?"5-hour":"7-day"}),r.jsx("span",{children:d==null?"No usage reading":`${e.stale||!c.counted?"Last read: ":""}${Ya(d)}% used`}),r.jsx("span",{children:h==null?"Reset time unknown":h<=n?"Reported time passed · awaiting a new reading":r.jsxs(r.Fragment,{children:[e.stale?"Last reported reset":`Reset in ${Mj(h,n)}`," · ",r.jsx(_p,{at:h})]})})]},i)}),r.jsx("p",{children:e.heldOut?"Excluded from automatic rotation.":"A weekly reset does not remove a separate 5-hour limit."})]})]})}function F4({entry:e,past:t=!1,older:n=!1}){return r.jsxs("span",{className:"ap-reset-reading","data-level":e.stale||t?"older":e.used!=null&&e.used>=70?"limited":void 0,children:[r.jsx("span",{className:"ap-reset-usage",children:e.used==null?"Usage unavailable":`${e.stale||t?"Last read: ":""}${Ya(e.used)}% used`}),e.used!=null&&!e.stale&&!t&&r.jsx("span",{className:"ap-reset-meter","data-level":e.used>=90?"hi":e.used>=70?"mid":void 0,"aria-hidden":"true",children:r.jsx("span",{style:{"--reset-used":Math.min(100,Math.max(0,e.used))/100}})}),e.stale&&r.jsxs("span",{className:"ap-reset-old",children:[!n&&"Needs a fresh reading · ",e.note]})]})}function Rte({entry:e,row:t,nowSec:n}){const s=e.reason==="unknown"?"Reset time unknown":e.reason==="passed"?"Reported time passed · awaiting a new reading":"Beyond these seven days";return r.jsx("li",{className:"ap-reset-unplaced-row",children:r.jsx(D4,{entry:e,row:t,nowSec:n,context:r.jsxs(r.Fragment,{children:[r.jsxs("span",{className:"ap-reset-unplaced-detail",children:[r.jsx("span",{children:s}),e.at!=null&&r.jsxs("span",{children:[Tf(new Date(e.at*1e3))," · ",r.jsx(_p,{at:e.at})]})]}),r.jsx(F4,{entry:e,past:e.reason==="passed"})]})})})}function vT({days:e,rows:t,nowSec:n,outdated:s=!1}){return r.jsx("div",{className:"ap-reset-agenda",children:e.map(a=>{const o=a.entries.filter(i=>i.stale===s);return o.length?r.jsxs("section",{className:"ap-reset-day","aria-label":Qc(a.date),children:[r.jsxs("h4",{className:"vis-hidden",children:[Qc(a.date)," · ",o.length," ",o.length===1?"account":"accounts"]}),r.jsx("ul",{children:Array.from(new Set(o.map(i=>i.at))).map((i,c)=>r.jsxs("li",{className:"ap-reset-event",children:[r.jsxs("div",{className:"ap-reset-when","data-outdated":s?"":void 0,children:[s&&r.jsx("span",{className:"ap-reset-last-reported",children:"Last reported"}),c===0&&r.jsxs("time",{className:"ap-reset-day-label",dateTime:a.key,children:[qh(a.date)," · ",Tf(a.date)]}),r.jsx(_p,{at:i}),!s&&r.jsxs("span",{children:["in ",Mj(i,n)]})]}),r.jsx("ul",{children:o.filter(d=>d.at===i).map(d=>r.jsx("li",{className:"ap-reset-entry","data-outdated":d.stale?"":void 0,children:r.jsx(D4,{entry:d,row:t.get(d.key),nowSec:n,withReading:!0,older:s})},d.key))})]},i))})]},a.key):null})})}function Ate({accounts:e,nowSec:t,held:n,selectedDate:s=null,onSelect:a=()=>{},scope:o="upcoming",onScope:i=()=>{}}){const{days:c,unscheduled:d}=Tte(e,t,n!=null),h=c.find(O=>O.key===s)??null,f=h?[h]:c,p=c.reduce((O,L)=>O+L.scheduled,0),m=f.reduce((O,L)=>O+L.outdated,0),w=c.reduce((O,L)=>O+L.outdated,0),j=h?h.scheduled:p,v=c.flatMap(O=>O.entries).find(O=>!O.stale),b=v?c.flatMap(O=>O.entries).filter(O=>!O.stale&&O.at===v.at):[],k=y.useRef(null),N=y.useRef(null),S=y.useRef(null);y.useEffect(()=>{var L,U;const O=S.current;O&&!O.isConnected&&document.activeElement===document.body&&((U=(L=N.current)==null?void 0:L.querySelector('.ap-reset-coverage-link[aria-pressed="true"]'))==null||U.focus({preventScroll:!0}))});const _=()=>{k.current&&(k.current.scrollTop=0)},E=O=>{_(),a(null),i(O)},I=Intl.DateTimeFormat().resolvedOptions().timeZone,A=new Map(_j(e,t).rows.map(O=>[O.key,O]));return r.jsxs("div",{ref:N,onFocusCapture:O=>{S.current=O.target},className:"ap-proj-body ap-report-body ap-reset-body",role:"region","aria-label":"Weekly reset calendar",children:[n&&r.jsx("p",{className:"ap-report-held",children:n}),r.jsxs("div",{className:"ap-reset-overview",children:[r.jsxs("div",{className:"ap-reset-command",children:[r.jsx("section",{className:"ap-reset-next","aria-label":"Next weekly reset",children:v?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"ap-reset-next-identity",children:[r.jsxs("h3",{children:[r.jsx(Ete,{}),"Next reported reset ",r.jsx("span",{className:"ap-reset-global",children:"· all days"})]}),b.length>1?r.jsxs("span",{className:"ap-reset-name",children:[b.length," accounts"]}):r.jsxs("details",{className:"ap-reset-next-account",children:[r.jsxs("summary",{title:v.name,children:[r.jsx(Uh,{entry:v}),r.jsx("span",{className:"vis-hidden",children:" · Full account name"})]}),r.jsx("p",{className:"ap-reset-full-name",children:v.name})]}),r.jsxs("p",{children:[qh(new Date(v.at*1e3)),", ",Tf(new Date(v.at*1e3))," · ",r.jsx(_p,{at:v.at})]}),r.jsxs("p",{className:"ap-reset-next-note",children:["Reported time · recent reading",b.length>1?"s":v.used!=null?` · ${Ya(v.used)}% weekly used`:""]})]}),r.jsxs("p",{className:"ap-reset-countdown",children:[r.jsx("strong",{children:Mj(v.at,t)}),r.jsxs("span",{children:[r.jsx("span",{className:"vis-hidden",children:"until "}),"reported reset"]})]})]}):r.jsxs("div",{className:"ap-reset-next-identity",children:[r.jsx("h3",{children:"No upcoming weekly resets"}),r.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."})]})}),r.jsxs("div",{className:"ap-reset-coverage",role:"group","aria-label":"Schedule data",children:[r.jsxs("button",{type:"button",className:"ap-reset-coverage-link","data-scope":"upcoming","aria-pressed":o==="upcoming",onClick:()=>E("upcoming"),children:[r.jsx("b",{children:p}),r.jsxs("span",{children:["Upcoming",r.jsx("span",{children:"Recent readings"})]})]}),r.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:()=>E("older"),children:[r.jsx("b",{children:w}),r.jsxs("span",{children:["Needs fresh data",r.jsx("span",{children:"This week · excluded"})]})]}),r.jsxs("button",{type:"button",className:"ap-reset-coverage-link","data-scope":"other","aria-pressed":o==="other",onClick:()=>E("other"),children:[r.jsx("b",{children:d.length}),r.jsxs("span",{children:["Other reset times",r.jsx("span",{children:"Unknown, elapsed or later"})]})]})]})]}),r.jsxs("section",{className:"ap-reset-navigation","aria-label":"Choose a calendar day",children:[r.jsxs("div",{className:"ap-reset-intro",children:[r.jsxs("h3",{children:["Next 7 days ",r.jsxs("span",{children:[p," weekly ",p===1?"reset":"resets"]})]}),r.jsx("p",{children:I})]}),r.jsx("ol",{className:"ap-reset-week",role:"list","aria-label":"Seven-day reset counts",children:c.map((O,L)=>r.jsx("li",{"data-today":L===0?"":void 0,children:r.jsxs("button",{type:"button",className:"ap-reset-day-button","aria-current":L===0?"date":void 0,"data-active":O.scheduled>0?"":void 0,"aria-pressed":(h==null?void 0:h.key)===O.key,"aria-label":`${Qc(O.date)}: ${O.scheduled} scheduled resets${O.outdated?`, ${O.outdated} readings need updating`:""}`,onClick:()=>{_(),i("upcoming"),a((h==null?void 0:h.key)===O.key?null:O.key)},children:[r.jsxs("time",{dateTime:O.key,title:Qc(O.date),children:[r.jsx("span",{className:"ap-reset-weekday",children:L===0?"Today":qh(O.date)}),r.jsx("span",{className:"ap-reset-date",children:O.date.getDate()})]}),r.jsxs("span",{className:"ap-reset-count",children:[r.jsx("b",{children:O.scheduled||"—"}),r.jsxs("span",{children:[" ",O.scheduled===1?"reset":"resets"]})]})]})},O.key))})]})]}),r.jsxs("div",{ref:k,className:"ap-reset-results",children:[r.jsxs("section",{className:"ap-reset-scheduled",hidden:o!=="upcoming","aria-label":"Scheduled weekly resets",children:[r.jsxs("div",{className:"ap-reset-list-head",children:[r.jsxs("h3",{children:[h?`${qh(h.date)}, ${Tf(h.date)}`:"All upcoming resets"," ",r.jsx("span",{children:j})]}),r.jsx("button",{className:"btn",type:"button","aria-pressed":!h,onClick:()=>{_(),a(null)},children:"All days"})]}),r.jsx("p",{className:"ap-reset-hint",role:"status",children:h?`Showing only ${Qc(h.date)}.`:"All days · select a date to narrow the agenda."}),j>0?r.jsx(vT,{days:f,rows:A,nowSec:t}):r.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."})]}),r.jsxs("section",{className:"ap-reset-disclosure",hidden:o!=="older","aria-label":"Accounts needing fresh readings",children:[r.jsxs("h3",{children:["Needs a fresh reading ",r.jsxs("span",{children:[m," ",m===1?"account":"accounts"," · excluded from counts"]})]}),r.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."}),m>0?r.jsx(vT,{days:f,rows:A,nowSec:t,outdated:!0}):r.jsx("p",{className:"ap-reset-empty",children:"No older schedules in these seven days. Unknown or elapsed times are listed in Other reset times."})]}),r.jsxs("section",{className:"ap-reset-disclosure ap-reset-unplaced",hidden:o!=="other","aria-label":"Other reset times",children:[r.jsxs("h3",{children:["Other reset times ",r.jsxs("span",{children:[d.length," ",d.length===1?"account":"accounts"," · unknown, elapsed or later"]})]}),d.length>0?r.jsx("ul",{children:d.map(O=>r.jsx(Rte,{entry:O,row:A.get(O.key),nowSec:t},O.key))}):r.jsx("p",{className:"ap-reset-empty",children:"All reported reset times fall within the upcoming week."})]}),r.jsxs("details",{className:"ap-reset-about",children:[r.jsx("summary",{children:"How to read this schedule"}),r.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 ",I,"; 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 B4(e){return e>=90?"hi":e>=70?"mid":void 0}const q4=(e,t,n)=>`${e} ${e===1?t:n}`;function bT(e){const t=e.more>0?`, and ${q4(e.more,"more account","more accounts")} in the same minute`:"";return`First: ${e.name} (${Ya(e.pct)}% used)${t}`}function Mte({w:e,nowSec:t}){const n=`ap-report-${e.id}`,s=e.total-e.included,a=s>0&&r.jsxs("p",{className:"ap-report-basis",children:[s," never read"]}),{used:o,available:i}=xee(e.used??0),c=Math.round(Mo(i,{countIn:!0}));if(e.used==null)return r.jsxs("section",{className:"ap-report-sum","aria-labelledby":n,children:[r.jsxs("h3",{className:"ap-report-win",id:n,children:[e.long," window"]}),r.jsxs("p",{className:"ap-report-none",children:["No account has a ",e.long," reading yet."]}),a]});const d=e.nextReset?Pu(e.nextReset.at,t):null;return r.jsxs("section",{className:"ap-report-sum","aria-labelledby":n,children:[r.jsxs("h3",{className:"ap-report-win",id:n,children:[e.long," window"]}),r.jsxs("p",{className:"ap-report-left",children:[r.jsxs("b",{children:[c,"%"]})," average remaining"]}),r.jsx("div",{className:"ap-report-meter","data-level":B4(o),"aria-hidden":!0,children:r.jsx("i",{style:{"--left":i/100}})}),d&&e.nextReset&&r.jsxs("p",{className:"ap-report-reset",title:bT(e.nextReset),children:[r.jsxs("span",{children:["Next reported reset in ",r.jsx("span",{className:"ap-report-num",children:d})]}),r.jsx("span",{"aria-hidden":!0,children:"·"}),r.jsx("span",{className:"ap-report-who",children:e.nextReset.name}),e.nextReset.more>0&&r.jsxs("span",{className:"ap-report-more",children:["+",e.nextReset.more]}),r.jsxs("span",{className:"vis-hidden",children:[". ",bT(e.nextReset)]})]}),a]})}function $te({cell:e,label:t}){if(!e.counted){const n=e.estimate==null?", not counted":", last reading, counted as is";return r.jsxs("td",{className:"ap-report-cell","data-uncounted":"",title:e.reset??void 0,children:[r.jsxs("span",{className:"ap-report-mobile-label","aria-hidden":"true",children:[t," used"]}),r.jsx("span",{className:"ap-report-pct",children:e.last==null?r.jsxs(r.Fragment,{children:[r.jsx("span",{"aria-hidden":!0,children:"—"}),r.jsx("span",{className:"vis-hidden",children:"no reading"})]}):`${Ya(e.last)}%`}),r.jsx("span",{className:"vis-hidden",children:e.reset?`. ${e.reset}. Awaiting a fresh reading${n}.`:n})]})}return r.jsxs("td",{className:"ap-report-cell",children:[r.jsxs("span",{className:"ap-report-mobile-label","aria-hidden":"true",children:[t," used"]}),r.jsxs("span",{className:"ap-report-pct","data-level":B4(e.pct),children:[Ya(e.pct),"%"]})]})}function Lte({at:e,nowSec:t,label:n}){if(e==null)return r.jsxs("td",{className:"ap-report-reset-cell",children:[r.jsxs("span",{className:"ap-report-mobile-label","aria-hidden":"true",children:[n," reset"]}),r.jsx("span",{"aria-hidden":!0,children:"—"}),r.jsx("span",{className:"vis-hidden",children:"No reset time"})]});const s=new Date(e*1e3),a=Pu(e,t);return r.jsxs("td",{className:"ap-report-reset-cell",title:`Recorded reset: ${s.toLocaleString()}`,children:[r.jsxs("span",{className:"ap-report-mobile-label","aria-hidden":"true",children:[n," reset"]}),r.jsxs("time",{dateTime:s.toISOString(),children:[r.jsx("span",{className:"vis-hidden",children:a?"reported reset in ":"reported reset "}),a??"due"]}),!a&&r.jsx("span",{className:"ap-report-state-note",children:"Awaiting read"}),r.jsxs("span",{className:"vis-hidden",children:[" · Recorded reset: ",s.toLocaleString()]})]})}const Ite={ready:"Ready",limited:"Limited",exhausted:"Exhausted",stale:"Stale"};function Ote({row:e}){return r.jsxs("td",{className:"ap-report-state","data-status":e.status,children:[r.jsx("span",{className:"ap-report-mobile-label","aria-hidden":"true",children:"Status"}),r.jsxs("span",{className:"ap-report-state-word",children:[r.jsx("i",{"aria-hidden":!0}),Ite[e.status]]}),Object.values(e.cells).some(t=>!t.counted&&t.reset)&&r.jsx("span",{className:"ap-report-state-note",children:"Awaiting read"})]})}function Pte({row:e,nowSec:t}){const n=pee(e,t);return r.jsxs("td",{className:"ap-report-upd","data-old":n.old?"":void 0,children:[r.jsx("span",{className:"ap-report-mobile-label","aria-hidden":"true",children:"Updated"}),n.text]})}function Dte(){return r.jsxs("svg",{className:"ap-report-how-mark",viewBox:"0 0 16 16",width:"12",height:"12","aria-hidden":!0,focusable:"false",children:[r.jsx("circle",{cx:"8",cy:"8",r:"6.5",fill:"none",stroke:"currentColor",strokeWidth:"1.4"}),r.jsx("path",{d:"M8 7.2v4.1M8 4.8v.1",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round"})]})}function Fte({accounts:e,nowSec:t,held:n,sort:s=null,onSort:a=()=>{}}){const o=_j(e,t),i=o.rows.length,c=Math.round(Mo(o.roomInBoth,{countIn:!0}));return r.jsxs("div",{className:"ap-proj-body ap-report-body",role:"region","aria-label":"Report",children:[n&&r.jsx("p",{className:"ap-report-held",children:n}),r.jsxs("div",{className:"ap-report-overview",children:[r.jsxs("p",{className:"ap-report-lead",children:[r.jsx("b",{children:c})," of ",q4(i,"Claude account","Claude accounts")," ready"]}),r.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`]})]}),r.jsx("div",{className:"ap-report-sums",children:o.windows.map(d=>r.jsx(Mte,{w:d,nowSec:t},d.id))}),r.jsx("div",{className:"ap-report-table-scroll",role:"region","aria-label":"Account capacity table",children:r.jsxs("table",{className:"ap-report-table",children:[r.jsx("caption",{className:"vis-hidden",children:"Each account's use and reset of each window, and what it can do now"}),r.jsxs("colgroup",{children:[r.jsx("col",{}),Uo.map(d=>r.jsxs(y.Fragment,{children:[r.jsx("col",{className:"ap-report-col-win"}),r.jsx("col",{className:"ap-report-col-reset"})]},d.id)),r.jsx("col",{className:"ap-report-col-state"}),r.jsx("col",{className:"ap-report-col-upd"})]}),r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx(Ki,{col:"account",label:"Account",sort:s,next:Rc,onSort:a}),Uo.map(d=>r.jsxs(y.Fragment,{children:[r.jsx(Ki,{col:d.id,label:`${d.label} used`,sort:s,next:Rc,onSort:a}),r.jsx(Ki,{col:`${d.id}_reset`,label:`${d.label} reset`,sort:s,next:Rc,onSort:a})]},d.id)),r.jsx(Ki,{col:"status",label:"Status",sort:s,next:Rc,onSort:a}),r.jsx(Ki,{col:"updated",label:"Updated",className:"ap-report-upd-h",sort:s,next:Rc,onSort:a})]})}),r.jsx("tbody",{children:o.rows.map((d,h)=>r.jsxs("tr",{"data-active":d.active?"":void 0,style:{"--row":h},children:[r.jsx("th",{scope:"row",className:"ap-report-acct",children:r.jsxs("span",{className:"ap-report-acct-in",children:[r.jsx("span",{className:"ap-report-name",title:d.name,children:d.name}),d.active&&r.jsx("span",{className:"ap-report-current",children:"Current"}),d.heldOut&&r.jsx("span",{className:"ap-report-tag",children:"held out"})]})}),Uo.map(f=>r.jsxs(y.Fragment,{children:[r.jsx($te,{cell:d.cells[f.id],label:f.label}),r.jsx(Lte,{at:d.resets[f.id],nowSec:t,label:f.label})]},f.id)),r.jsx(Ote,{row:d}),r.jsx(Pte,{row:d,nowSec:t})]},d.num))})]})}),r.jsxs("details",{className:"ap-report-how",children:[r.jsxs("summary",{children:[r.jsx(Dte,{}),"How usage is calculated"]}),r.jsxs("div",{className:"ap-report-how-body",children:[r.jsxs("p",{children:["Every account here, at its last reading: ",r.jsx("b",{children:"used"})," is their average, and ",r.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."]}),r.jsxs("p",{children:[r.jsx("b",{children:"Ready"})," has room in both windows. ",r.jsx("b",{children:"Limited"})," is at the limit of one, and ",r.jsx("b",{children:"Exhausted"})," of both. ",r.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 Bte({accounts:e,order:t,failed:n,nowSec:s,onClose:a}){const o=y.useRef(null),i=mt(a,{focusRef:o}),c=yt(a),[d,h]=y.useState("accounts"),[f,p]=y.useState("upcoming"),[m,w]=y.useState(null),[j,v]=y.useState(e??[]);y.useEffect(()=>{e!=null&&v(e)},[e]);const b=vee(n,e==null,j.length>0),[k,N]=y.useState(null),S=I0(j,(k==null?void 0:k.order)??t),_=E=>{const I=_j(I0(j,t),s).rows;N({sort:E,order:wee(I,E).map(A=>A.key)})};return vt.createPortal(r.jsx("div",{className:"modal-backdrop",...c,role:"presentation",children:r.jsxs("div",{ref:i,className:"modal ap-report-modal","data-view":d,onClick:E=>E.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ap-report-title",children:[r.jsxs("header",{className:"ap-proj-head",children:[r.jsx("div",{className:"ap-proj-titlewrap",children:r.jsx("h2",{className:"ap-proj-title",id:"ap-report-title",children:"Account capacity"})}),r.jsxs("div",{className:"ap-report-views",role:"group","aria-label":"Capacity view",children:[r.jsx("button",{type:"button",className:"ap-report-view","aria-pressed":d==="accounts",onClick:()=>h("accounts"),children:"Accounts"}),r.jsx("button",{type:"button",className:"ap-report-view","aria-pressed":d==="calendar",onClick:()=>h("calendar"),children:"Reset calendar"})]}),r.jsx("button",{ref:o,type:"button",className:"glyph-btn ap-proj-close",onClick:a,"aria-label":"Close",children:"×"})]}),r.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:b??""}),d==="accounts"?r.jsx(Fte,{accounts:S,nowSec:s,held:b,sort:(k==null?void 0:k.sort)??null,onSort:_}):r.jsx(Ate,{accounts:S,nowSec:s,held:b,selectedDate:m,onSelect:w,scope:f,onScope:p})]})}),document.body)}const qte=[{value:"room",label:"Most room left"},{value:"weekly",label:"Soonest weekly reset"}],Ute="Uses up quota that resets within 4 days first";function Wte(e){return e==="room"||e==="weekly"}function ay(e,t){return!t||!e.email?!1:e.email.trim().toLowerCase()===t.email.trim().toLowerCase()&&(e.orgUuid??"")===(t.orgUuid??"")}function Hte(e,t){return t?e.disabled?"Home · paused while held out of rotation":e.alive===!1||e.error||e.reauth?"Home · paused until this account is signed in again":"Home · Auto-switch comes back here after its 5-hour window resets":"Home · Auto-switch comes back here while it is on"}const oy=[70,80,85,90,95],U4="custom",Yi=50,Xi=99,zte=`A whole percent from ${Yi} to ${Xi}.`;function Vte(e){const t=Number(e);return[...Number.isFinite(t)&&t>0&&!oy.includes(t)?[...oy,t]:oy].sort((s,a)=>s-a)}function Gte(e){const t=e.trim().replace(/\s*%$/,"");if(t==="")return{ok:!1,reason:"empty",message:`Enter a number from ${Yi} to ${Xi}.`};if(!/^\d+(\.\d*)?$|^\.\d+$/.test(t))return{ok:!1,reason:"not_a_number",message:`Enter a number from ${Yi} to ${Xi}.`};const n=Number(t);return Number.isInteger(n)?n<Yi?{ok:!1,reason:"too_low",message:`The lowest is ${Yi}%.`}:n>Xi?{ok:!1,reason:"too_high",message:`The highest is ${Xi}%.`}:{ok:!0,value:String(n)}:{ok:!1,reason:"not_whole",message:`Use a whole number from ${Yi} to ${Xi}.`}}const U0={pick:null,custom:null,refusal:null};function Kte(e,t){switch(t.kind){case"pick":return t.pick===U4?{...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 U0;case"leave":return e.custom&&(e.pick??t.stored)===t.stored?U0:e}}async function Yte(e,t,n){if(!t.sends)return{kind:"unchanged"};const s=Gte(e);if(!s.ok)return{kind:"refused",message:s.message};const a=await n({action:"setting",key:"autoswitch.threshold",value:s.value},"threshold");return{kind:"sent",ok:(a==null?void 0:a.ok)===!0}}function Xte({auto:e,threshold:t,thresholdPick:n,thresholdCtl:s,thresholdSaved:a,thresholdRef:o,thresholdSaveRef:i,thresholdCustom:c,thresholdRefusal:d,thresholdFieldRef:h,proposeThreshold:f,typeThreshold:p,cancelThreshold:m,leaveThreshold:w,doThreshold:j,nextPick:v,nextCtl:b,nextSaved:k,nextRef:N,nextSaveRef:S,proposeNext:_,doNext:E,pressProps:I,post:A,load:O}){const L=y.useId(),U=y.useId(),P=y.useId();return r.jsxs("div",{className:"ap-policy-block",children:[r.jsxs("div",{className:"ap-policy",onKeyDown:c?m:void 0,children:[r.jsx("h3",{className:"ap-auto-title",children:"Auto-switch"}),c?r.jsx("form",{className:"ap-threshold-form",noValidate:!0,onSubmit:T=>{T.preventDefault(),j(n,s)},children:r.jsxs("span",{className:"ap-threshold-field",title:"Switch once the active account passes this much of its limit",children:[r.jsx("input",{ref:h,className:"ap-manage-input ap-threshold-input",type:"text",inputMode:"numeric","aria-label":"Switch threshold","aria-describedby":L,"aria-invalid":d?!0:void 0,value:n,...I("threshold"),onChange:T=>p(T.target.value),onBlur:()=>w(),autoComplete:"off",spellCheck:!1}),r.jsx("span",{className:"ap-threshold-unit","aria-hidden":!0,children:"%"})]})}):r.jsx("span",{className:"ap-field",title:"Switch once the active account passes this much of its limit",children:r.jsxs("select",{ref:o,"aria-label":"Switch threshold",value:n,...I("threshold"),onChange:T=>f(T.target.value),children:[Vte(t).map(T=>r.jsxs("option",{value:T,children:[T,"%"]},T)),r.jsx("option",{value:U4,children:"Custom…"})]})}),(s.sends||a)&&r.jsx("button",{ref:i,type:"button",className:"ap-manage-btn",...I("threshold"),title:s.title,onClick:()=>j(n,s),children:a&&!s.sends?s.done:s.label}),r.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":e.enabled,"aria-label":"Auto-switch",...I("enable"),onClick:()=>A({action:"enable",enabled:!e.enabled},"enable").then(()=>O(!0)),title:e.enabled?"Stop switching accounts automatically":"Switch accounts automatically when the active one nears its limit",children:r.jsx("span",{className:"switch-knob"})})]}),d?r.jsx("p",{id:L,className:"ap-threshold-note",role:"alert","data-tone":"err",children:d},"refusal"):c?r.jsx("p",{id:L,className:"ap-threshold-note",children:zte},"hint"):null,e.enabled&&r.jsxs("div",{className:"ap-policy ap-next",children:[r.jsx("label",{className:"ap-next-label",htmlFor:U,children:"Next account"}),r.jsx("span",{className:"ap-field",children:r.jsx("select",{id:U,ref:N,value:v,"aria-describedby":v==="weekly"?P:void 0,...I("next"),onChange:T=>_(T.target.value),children:qte.map(T=>r.jsx("option",{value:T.value,children:T.label},T.value))})}),(b.sends||k)&&r.jsx("button",{ref:S,type:"button",className:"ap-manage-btn",...I("next"),title:b.title,onClick:()=>E(),children:k&&!b.sends?b.done:b.label})]}),e.enabled&&v==="weekly"&&r.jsx("p",{id:P,className:"ap-threshold-note",children:Ute}),e.external&&r.jsxs("p",{className:"ap-auto-note",children:[r.jsx("i",{className:"ap-pulse","aria-hidden":!0})," A ",r.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 kT=18,Zte=1100,zi=(e,t)=>{const n=Math.sin(e*12.9898+t*78.233)*43758.5453;return n-Math.floor(n)},Jte=Array.from({length:kT},(e,t)=>{const n=-72+144*t/(kT-1)+(zi(t,1)-.5)*9,s=(n-90)*(Math.PI/180),a=(54+32*Math.cos(n*Math.PI/180))*(.74+zi(t,2)*.52);return{dx:Math.cos(s)*a,dy:Math.sin(s)*a,rot:(t%2?1:-1)*(100+zi(t,3)*260),delay:Math.round(zi(t,4)*90),dur:760+Math.round(zi(t,5)*260),scale:.8+zi(t,6)*.45,hue:t%4,round:t%3===0}});function jT({anchor:e}){var a;const[t,n]=y.useState(null),s=typeof window<"u"&&((a=window.matchMedia)==null?void 0:a.call(window,"(prefers-reduced-motion: reduce)").matches);return y.useEffect(()=>{if(s)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),Zte);return()=>window.clearTimeout(c)},[e,s]),s||!t?null:vt.createPortal(r.jsx("div",{className:"confetti",style:{left:`${t.x}px`,top:`${t.y}px`},"aria-hidden":!0,children:Jte.map((o,i)=>r.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 Rf=y.forwardRef((e,t)=>r.jsxs("svg",{className:"aa-mark",viewBox:"0 0 44 44","aria-hidden":!0,ref:t,children:[r.jsx("circle",{className:"aa-mark-ring",cx:"22",cy:"22",r:"20"}),r.jsx("path",{className:"aa-mark-tick",d:"M13.5 22.5 L19.5 28.5 L31 17"})]}));Rf.displayName="SuccessMark";const Qte={done:", done",active:", in progress",failed:", failed",pending:""};function ene({status:e}){return r.jsx("svg",{className:"aa-stage-icon",viewBox:"0 0 16 16","aria-hidden":!0,children:e==="done"?r.jsx("path",{className:"aa-stage-tick",d:"M4 8.5 L7 11.5 L12.5 5"}):e==="failed"?r.jsx("path",{className:"aa-stage-cross",d:"M5 5 L11 11 M11 5 L5 11"}):e==="active"?r.jsx("circle",{className:"aa-stage-now",cx:"8",cy:"8",r:"3.5"}):r.jsx("circle",{className:"aa-stage-later",cx:"8",cy:"8",r:"3"})})}function tne({rows:e,phase:t,detail:n,actions:s}){var o;const a=(o=e.find(i=>i.status==="active"))==null?void 0:o.id;return r.jsxs("div",{className:`aa-progress ${t}`,"data-at":a,children:[r.jsxs("svg",{className:"aa-orbit",viewBox:"0 0 44 44","aria-hidden":!0,children:[r.jsx("circle",{className:"aa-orbit-track",cx:"22",cy:"22",r:"20"}),t==="live"||t==="resolving"?r.jsx("circle",{className:"aa-orbit-arc",cx:"22",cy:"22",r:"20"}):null,t==="resolving"?r.jsx("circle",{className:"aa-orbit-close",cx:"22",cy:"22",r:"20"}):null,t==="failed"?r.jsx("path",{className:"aa-orbit-cross",d:"M17 17 L27 27 M27 17 L17 27"}):null]}),r.jsx("ol",{className:"aa-stages",children:e.map(i=>{const c=i.status==="active"||i.status==="failed";return r.jsxs("li",{className:"aa-stage","data-status":i.status,"aria-current":i.status==="active"?"step":void 0,children:[r.jsx(ene,{status:i.status}),r.jsxs("span",{className:"aa-stage-label",children:[i.label,r.jsx("span",{className:"vis-hidden",children:Qte[i.status]})]}),c&&n?r.jsx("div",{className:"aa-stage-more",children:n}):null]},i.id)})}),s?r.jsx("div",{className:"aa-actions aa-progress-actions",children:s}):null]})}const iy=["link","approve","confirm","save"],NT={confirm:"confirm",save:"save",restore:"save"};function W4(e){return e!=null&&Object.prototype.hasOwnProperty.call(NT,e)?NT[e]:null}function nne({state:e,step:t,starting:n}){return e==="registering"?W4(t)??"confirm":e==="awaiting_code"?"approve":e==="awaiting_url"||e==null&&n?"link":null}function sne({state:e,step:t,url:n,lastLive:s}){return e==="failed"?W4(t)??(n?"approve":"link"):e==="idle"?s??"link":"link"}const rne={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 ane(e,t,n){return t==="failed"?H4(e,n):rne[e][t]}function one({live:e=null,failed:t=null,done:n=!1,state:s=null}){const a=n?iy.length:iy.indexOf(t??e);return iy.map((o,i)=>{const c=n||i<a?"done":i>a||a<0?"pending":t?"failed":"active";return{id:o,status:c,label:ane(o,c,s)}})}function ine(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 lne={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 H4(e,t){return t==="idle"?"Sign-in ended":lne[e]}const cne=/^(?:claude|claude-swap|cswap|ccdeck|npm|uv)\b/;function Wh(e){const t=String(e??"").trim();if(!t)return"";const n=cne.test(t)?t:t[0].toUpperCase()+t.slice(1);return/[.!?…]$/.test(n)?n:`${n}.`}Wh(L4);const une=1e4,dne=1e4,hne=5;function fne({since:e,now:t,expiresAt:n}){if(e==null||t-e<une)return null;const s=n!=null?Math.ceil((n-t)/6e4):NaN,a="Still waiting for the browser. If no tab opened, or you closed it, use the link above";return s>=1&&s<=hne?`${a} — the sign-in stays open ${s} more minute${s===1?"":"s"}.`:`${a}.`}function pne({since:e,now:t}){return e==null||t-e<dne?null:"Still importing. claude-swap stops by itself after a minute if it cannot finish."}function mne(e){return e==="registering"?400:1500}const z4=460;function gne({fromStages:e,reducedMotion:t}){return e&&!t?z4:0}function yne({added:e,reducedMotion:t}){return e&&!t}function ST({num:e,added:t}){return t?e!=null&&e!==""?`Account ${e} added`:"Account added":"Credentials refreshed"}function wne(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 xne="done";function vne(){let e=!1;return{shouldAnnounce(t){return t!==xne?(e=!1,!1):e?!1:(e=!0,!0)}}}function V4(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 bne(e){const t=new Map;for(const n of e){const s=(n.email??"").trim().toLowerCase();s&&t.set(s,(t.get(s)??0)+1)}return e.map(n=>{const s=(n.email??"").trim(),a=n.alias||s||`account ${n.num}`,o=[];return n.alias&&s&&o.push(s),s&&(t.get(s.toLowerCase())??0)>1&&o.push(n.org||`slot ${n.num}`),{num:n.num,label:a,sub:o.length?o.join(" · "):null}})}function kne(e,t){return e.filter(n=>!t.includes(n.num)).map(n=>n.num)}function jne(e,t){return e.includes(t)?e.filter(n=>n!==t):[...e,t]}function Nne(e){return e.length?{action:"share",accounts:[...e]}:null}function Sne(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 W0(e){return`${e.email}|${e.org??""}`}function _ne(e,t,n){return e&&e.map(s=>W0(s)===t?n:s)}function Cne(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 _T(e){const t=e.length;if(!t)return"Nothing to import.";const n=f=>e.filter(p=>p.state===f).length,s=[],a=n("imported");a&&s.push(`${a} of ${t} imported`);const o=n("healed");o&&s.push(`${o} had a dead token replaced`);const i=n("updated");i&&s.push(`${i} updated`);const c=n("present");c&&s.push(`${c} already here`);const d=n("failed");d&&s.push(`${d} did not arrive`);const h=[...new Set(e.map(f=>{var p;return(p=Ef(f.check))==null?void 0:p.short}).filter(f=>!!f))];return`${s.join(", ")}${h.length?`, ${h.join(", ")}`:""}.`}function Ene(e){try{return e?new URL(e).host:""}catch{return""}}const xh=[{id:"login",label:"Sign in"},{id:"paste",label:"Paste a share"}],CT="aa-panel",ET=e=>`aa-tab-${e}`;async function Co(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}function G4({onClose:e,onChanged:t,email:n=null,onSignedIn:s}){en("add-account");const[a,o]=y.useState("login"),[i,c]=y.useState(null),[d,h]=y.useState(""),[f,p]=y.useState(""),[m,w]=y.useState(!1),[j,v]=y.useState(!1),[b,k]=y.useState(null),[N,S]=y.useState(null),_=m||j,[E,I]=y.useState(null),[A,O]=y.useState(null),[L,U]=y.useState(null),P=y.useRef(""),T=y.useRef(!1),B=y.useRef(!1),M=y.useRef(null),q=y.useRef(null),$=y.useRef(null),K=y.useRef(null),G=y.useRef([]),z=y.useRef(!1),W=y.useRef(0),D=y.useRef(null),H=y.useRef("primer"),ee=y.useRef(null),F=y.useRef(null),Y=y.useRef(null),X=y.useRef(!1),Z=y.useState($u)[0],[J,ne]=y.useState(null),[ce,he]=y.useState(!1),[le,re]=y.useState(()=>Date.now()),[ae,de]=y.useState(null),[Se,pe]=y.useState(null),[me,be]=y.useState(null),Ce=y.useCallback(()=>{const _e=fT({started:T.current,state:i==null?void 0:i.state});_e&&Co(_e).catch(()=>{}),e()},[e,i==null?void 0:i.state]),ye=mt(Ce,{focusRef:$}),Pe=yt(Ce),Oe=y.useCallback(async()=>{if(!xn(B.current))return;const _e=++W.current;B.current=!0,w(!0),k(null),be(null),T.current=!0;let De=await Co(n?{action:"login",email:n}:{action:"login"}).catch(()=>null);if(n&&(De==null?void 0:De.reason)==="bad_email"&&_e===W.current&&(De=await Co({action:"login"}).catch(()=>null)),_e===W.current){if(B.current=!1,w(!1),!(De!=null&&De.ok)){k(el(De,"could not start the sign-in"));return}c(De)}},[n]);y.useEffect(()=>{if(!M4(i==null?void 0:i.state))return;const _e=window.setInterval(async()=>{try{const De=await fetch("/api/claude-accounts/login");De.ok&&c(await De.json())}catch{}},mne(i==null?void 0:i.state));return()=>window.clearInterval(_e)},[i]);const We=y.useCallback(async()=>{const _e=fT({started:T.current,state:i==null?void 0:i.state});if(W.current+=1,T.current=!1,B.current=!1,w(!1),k(null),c(null),h(""),he(!1),X.current=!0,!_e)return;const De=await Co(_e).catch(()=>null);be(hT({restored:De==null?void 0:De.restored,activeAccount:De==null?void 0:De.activeAccount}))},[i==null?void 0:i.state]),Re=y.useCallback(()=>{T.current=!1,c(null),k(null),h(""),he(!1),Oe()},[Oe]),st=y.useRef(t);st.current=t;const je=y.useState(vne)[0];y.useEffect(()=>{je.shouldAnnounce(i==null?void 0:i.state)&&st.current()},[i==null?void 0:i.state,je]),y.useEffect(()=>{var _e;ce&&((_e=M.current)==null||_e.focus())},[ce]);const Te=y.useRef(s);Te.current=s;const $e=y.useRef(null);y.useEffect(()=>{var ze;const _e=(i==null?void 0:i.state)==="done"?i.account:null,De=_e?`${_e.num??""}|${_e.email}`:null;!_e||$e.current===De||($e.current=De,(ze=Te.current)==null||ze.call(Te,_e))},[i]),y.useEffect(()=>{var _e;a==="paste"&&!z.current&&((_e=q.current)==null||_e.focus()),z.current=!1},[a]);const Ge=y.useCallback(_e=>{var ze;const De=mp(_e,xh.findIndex(ut=>ut.id===a),xh.length);De.kind!=="pass"&&(_e.preventDefault(),z.current=!0,o(xh[De.index].id),(ze=G.current[De.index])==null||ze.focus())},[a]),tt=y.useCallback(async()=>{var ze;if(!xn(B.current))return;const _e=W.current;B.current=!0,w(!0),k(null);const De=await Co({action:"login-code",code:d}).catch(()=>null);if(_e===W.current){if(B.current=!1,w(!1),!(De!=null&&De.ok)){k(el(De,"the code was not accepted")),De!=null&&De.state&&c(De),(ze=M.current)==null||ze.select();return}h(""),c(De)}},[d,i]),ht=y.useCallback(async()=>{if(!xn(B.current))return;B.current=!0,v(!0),S(null);const _e=await Co({action:"import",blob:f}).catch(()=>null);if(B.current=!1,v(!1),!(_e!=null&&_e.ok)){S(el(_e,"the import failed"));return}P.current=f,p(""),U(null),I(_e.results??[]),t()},[f,t]),it=y.useCallback(async _e=>{const De=W0(_e);if(!xn(B.current)||!P.current)return;B.current=!0,v(!0),O(De),U(null);const ze=await Co({action:"import",blob:P.current,force:!0,only:{email:_e.email,org:_e.org??""}}).catch(()=>null);if(B.current=!1,v(!1),O(null),!(ze!=null&&ze.ok)){U({key:De,text:el(ze,"that account could not be updated")});return}const ut=(ze.results??[])[0];ut&&I(At=>_ne(At,De,ut)),t()},[t]),nt=(i==null?void 0:i.state)==="done"?i.account:null,we=hT({restored:i==null?void 0:i.restored,activeAccount:i==null?void 0:i.activeAccount}),Be=jee({login:i,started:T.current,loginError:b,loginBusy:m}),Ye=kee({state:i==null?void 0:i.state,serverError:i==null?void 0:i.error,localError:b}),He=Be==="asking"||Be==="code"?nne({state:i==null?void 0:i.state,step:i==null?void 0:i.step,starting:Be==="asking"})??"link":null,ft=Be==="ended"?sne({state:i==null?void 0:i.state,step:i==null?void 0:i.step,url:i==null?void 0:i.url,lastLive:D.current}):null,St=nt?`${nt.num??""}|${nt.email}`:null,gt=Be==="done"&&St!==J&&gne({fromStages:H.current==="progress",reducedMotion:Z})>0,_t=Be==="primer"?"primer":Be==="done"&&nt&&!gt?"done":"progress",It=ft?"failed":gt?"resolving":"live",ks=one(gt?{done:!0}:ft?{failed:ft,state:i==null?void 0:i.state}:{live:He}),Xs=ft?H4(ft,i==null?void 0:i.state):"",js=Wh(Ye.message),Zn=He==="approve"?fne({since:ae,now:le,expiresAt:i==null?void 0:i.expiresAt}):null,Ot=j?pne({since:Se,now:le}):null,Ns=a==="login"?_t==="done"&&nt?`${ST(nt)}.`:It==="failed"?`${Xs}. ${js}`:_t==="progress"&&!gt?wne(He)??"":"":j?"Importing the share.":N?Wh(N):E?Wh(_T(E)):"";y.useEffect(()=>{He&&(D.current=He)},[He]),y.useEffect(()=>{H.current=_t},[_t]),y.useEffect(()=>{if(!gt||!St)return;const _e=window.setTimeout(()=>ne(St),z4);return()=>window.clearTimeout(_e)},[gt,St]);const hn=He==="approve";y.useEffect(()=>{de(hn?Date.now():null)},[hn]),y.useEffect(()=>{pe(j?Date.now():null)},[j]);const Dn=hn||j;return y.useEffect(()=>{if(!Dn)return;re(Date.now());const _e=window.setInterval(()=>re(Date.now()),1e3);return()=>window.clearInterval(_e)},[Dn]),y.useEffect(()=>{var De,ze,ut,At;if(a!=="login")return;if(_t==="done"){(De=F.current)==null||De.focus();return}if(_t==="primer"){X.current&&((ze=$.current)==null||ze.focus()),X.current=!1;return}if(It==="failed"){(ut=Y.current)==null||ut.focus();return}const _e=document.activeElement;He==="approve"&&(!_e||_e===document.body)&&((At=ee.current)==null||At.focus())},[a,_t,It,He]),vt.createPortal(r.jsx("div",{className:"modal-backdrop",...Pe,role:"presentation",children:r.jsxs("div",{ref:ye,className:"modal aa-modal",onClick:_e=>_e.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Add a Claude account",children:[r.jsxs("header",{className:"modal-head",children:[r.jsx("div",{className:"modal-title",children:r.jsx("span",{className:"aa-tabs",role:"tablist","aria-label":"How to add the account",onKeyDown:Ge,children:xh.map((_e,De)=>r.jsx("button",{type:"button",role:"tab",id:ET(_e.id),ref:ze=>{G.current[De]=ze},"aria-selected":a===_e.id,"aria-controls":CT,tabIndex:a===_e.id?0:-1,className:`aa-tab${a===_e.id?" on":""}`,onClick:()=>{z.current=!1,o(_e.id)},children:_e.label},_e.id))})}),r.jsx("div",{className:"modal-actions",children:r.jsx("button",{type:"button",className:"glyph-btn",onClick:Ce,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),r.jsxs("section",{className:"modal-body aa-body",id:CT,role:"tabpanel","aria-labelledby":ET(a),children:[a==="login"?_t==="done"&&nt?r.jsxs("div",{className:`aa-done${J===St?" from-orbit":""}`,children:[r.jsx(Rf,{ref:K}),yne({added:nt.added,reducedMotion:Z})&&r.jsx(jT,{anchor:K}),r.jsx("h4",{children:ST(nt)}),r.jsxs("p",{className:"aa-note",children:[r.jsx("strong",{children:nt.email}),nt.added?we?" 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."]}),we?r.jsx("p",{className:"aa-note aa-warn",role:"status",children:we}):null,r.jsx("button",{type:"button",ref:F,className:"btn primary",onClick:Ce,children:"Done"})]}):_t==="progress"?r.jsx(tne,{rows:ks,phase:It,detail:It==="failed"?r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"aa-note aa-reason",children:js}),r.jsx("div",{className:"aa-actions",children:r.jsx("button",{type:"button",ref:Y,className:"btn primary",onClick:Re,children:ft==="link"?"Try again":"Start over"})})]}):He==="approve"&&i?r.jsxs(r.Fragment,{children:[r.jsxs("p",{className:"aa-note",children:["Approve the sign-in in the tab that opened",n?r.jsxs(r.Fragment,{children:[", with ",r.jsx("strong",{children:n})," filled in"]}):null,". This moves on by itself."]}),r.jsxs("a",{ref:ee,className:"aa-link",href:i.url??"#",target:"_blank",rel:"noreferrer noopener",children:[r.jsx("span",{children:"Open it in this browser"}),r.jsxs("span",{className:"aa-link-host",children:[Ene(i.url),r.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:r.jsx("path",{d:"M3 7 7 3M3.6 3H7v3.4"})})]})]}),Zn?r.jsx("p",{className:"aa-note aa-arrive",children:Zn}):null,r.jsxs("details",{className:"aa-code",open:ce,onToggle:_e=>he(_e.currentTarget.open),children:[r.jsxs("summary",{children:[r.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:r.jsx("path",{d:"M3.6 2.2 6.4 5 3.6 7.8"})}),"Paste a code, if the page shows one"]}),r.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."}),r.jsxs("div",{className:"aa-field",children:[r.jsx("input",{ref:M,type:"text",value:d,onChange:_e=>h(_e.target.value),onKeyDown:_e=>{_e.key==="Enter"&&d.trim()&&!_&&tt()},placeholder:"paste the code here",spellCheck:!1,autoComplete:"off","aria-label":"Sign-in code",disabled:i.state==="registering"}),r.jsx("button",{type:"button",className:"btn primary",...$n(_,!d.trim()||i.state==="registering"),onClick:tt,children:"Continue"})]}),(b||i.error)&&r.jsx("p",{className:"aa-err",children:b??i.error}),r.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."})]})]}):He?r.jsx("p",{className:"aa-note",children:ine(He,i==null?void 0:i.step)}):null,actions:He==="link"||He==="approve"?r.jsx("button",{type:"button",className:"btn",onClick:We,children:"Cancel"}):null}):r.jsxs("div",{className:"aa-step aa-primer",children:[me?r.jsx("p",{className:"aa-note aa-warn",role:"status",children:me}):null,r.jsx("h4",{children:n?r.jsxs(r.Fragment,{children:["Sign in again as ",r.jsx("strong",{children:n})]}):"Sign in to Anthropic"}),r.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."]}),r.jsx("div",{className:"aa-actions",children:r.jsx("button",{type:"button",ref:$,className:"btn primary",...$n(_),onClick:Oe,children:"Open the sign-in page"})})]}):E?(()=>{const _e=E.filter(ze=>ze.state==="imported").length,De=E.some(ze=>Ef(ze.check));return r.jsxs("div",{className:"aa-done",children:[!De&&r.jsx(Rf,{ref:K}),_e>0&&!De&&r.jsx(jT,{anchor:K}),r.jsx("h4",{children:_T(E)}),E.length>0&&r.jsx("ul",{className:"aa-results",children:E.map(ze=>{const ut=W0(ze),At=Ef(ze.check);return r.jsxs("li",{className:`aa-result ${ze.state}`,children:[r.jsx("span",{className:"aa-result-who",children:ze.email||(ze.num?`slot ${ze.num}`:"an account")}),r.jsx("span",{className:"aa-result-what",children:Cne(ze.state)}),ze.state==="present"&&r.jsx("button",{type:"button",className:"aa-result-fix","aria-busy":A===ut,title:`Overwrite the stored login for ${ze.email} with the one in this share. Do this when that account has stopped working here; if it works, leave it.`,onClick:()=>it(ze),children:A===ut?"updating…":"update anyway"}),At&&r.jsx("span",{className:"aa-result-err",children:At.long}),(L==null?void 0:L.key)===ut&&r.jsx("span",{className:"aa-result-err",children:L.text})]},ut)})}),r.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",r.jsx("strong",{children:" update anyway"}),"."]}),r.jsxs("div",{className:"aa-actions",children:[r.jsx("button",{type:"button",className:"btn primary",onClick:Ce,children:"Done"}),r.jsx("button",{type:"button",className:"btn",onClick:()=>{P.current="",U(null),I(null)},children:"Import another"})]})]})})():r.jsxs("div",{className:"aa-step",children:[r.jsx("h4",{children:"Paste an account shared from another deck"}),r.jsxs("div",{className:"aa-field",children:[r.jsx("input",{ref:q,type:"text",value:f,onChange:_e=>p(_e.target.value),onKeyDown:_e=>{_e.key==="Enter"&&f.trim()&&!_&&ht()},placeholder:"ccdeck2:…",spellCheck:!1,autoComplete:"off","aria-label":"Shared account"}),r.jsx("button",{type:"button",className:"btn primary",...$n(_,!f.trim()),onClick:ht,children:j?"importing…":"Import"})]}),N&&r.jsx("p",{className:"aa-err",children:N}),j?r.jsxs("p",{className:"aa-live-line",children:[r.jsxs("svg",{className:"aa-spin",viewBox:"0 0 16 16","aria-hidden":!0,children:[r.jsx("circle",{className:"aa-spin-track",cx:"8",cy:"8",r:"6"}),r.jsx("circle",{className:"aa-spin-arc",cx:"8",cy:"8",r:"6"})]}),r.jsx("span",{children:Ot??"claude-swap is adding the accounts in this share. Any already here are left as they are."})]}):null,r.jsxs("p",{className:"aa-note",children:["Use ",r.jsx("strong",{children:"share"})," on one account in the other deck, or ",r.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."]})]}),r.jsx("p",{className:"vis-hidden",role:"status","aria-live":"polite",children:Ns})]})]})}),document.body)}function Tne(e,t){const n=new Set(e),s=e.length?Math.max(...e):0;return[...new Set([...e,s+1])].sort((a,o)=>a-o).map(a=>{const o=a===t?"here":n.has(a)?"swap":"free";return{slot:a,kind:o,label:o==="here"?`slot ${a}`:`slot ${a} · ${o}`}})}function Rne(e,t,n){if(!(n!=null&&n.ok))return null;const s=Number.isInteger(n.to)?n.to:null;if(s==null)return{menuFor:null,confirmRemove:null,shareFor:null,swapNote:null};const a=n.swapped===!0&&s!==t;return{menuFor:e.menuFor===t?s:a&&e.menuFor===s?t:e.menuFor,confirmRemove:null,shareFor:null,swapNote:a?{at:s,displaced:t}:null}}const Ane=64;function Mne(e,t){const n=e.trim();return{alias:n,commit:n!==(t??"").trim()}}function $ne(e,t,n){return t!=null&&e.some(s=>s.slot===t)?t:n}function Lne(e,t,n){var a;const s=((a=e.find(o=>o.slot===t))==null?void 0:a.kind)??"here";return s==="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}.`}:s==="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 Ine(e,t){return{label:"save",done:"saved",sends:e!==t,swaps:!1,title:e==="weekly"?"Move to the account whose weekly limit resets soonest, within 4 days.":"Move to the account with the most room left."}}function One(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 Pne({a:e,slots:t,nowSec:n,boundaryId:s,accountMenu:a,busy:o,pressProps:i,rotating:c,onProjects:d,onRotation:h,home:f,canSetHome:p,onHome:m}){const{menu:w,menuError:j,aliasDraft:v,confirmRemove:b,share:k,shareCopied:N,slotDraft:S,dropMenu:_,closeMenu:E,startRename:I,typeAlias:A,doAlias:O,startMove:L,pickSlot:U,doSlot:P,makeShare:T,copyShare:B,pressRemove:M}=a;if(!w)return null;const q=`ap-pop-title-${e.num}`,$=j&&r.jsx("p",{className:"ap-pop-error",role:"alert",title:j.raw||void 0,children:j.text});return r.jsxs(xp,{anchorId:`ap-more-${e.num}`,boundaryId:s,id:`ap-menu-${e.num}`,className:"ap-pop",role:w.view==="menu"?"menu":"dialog",labelledBy:w.view==="menu"?`ap-more-${e.num}`:q,start:w.start,onClose:_,children:[w.view==="menu"&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",onClick:()=>I(e.num,e.alias),children:"Rename"}),r.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",onClick:()=>L(e.num),children:"Move to slot…"}),r.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",...i(`share-${e.num}`),title:`Copy this account to another ${Rt}. 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:()=>T(e.num),children:o===`share-${e.num}`?"Sharing…":"Share"}),r.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)&&r.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"}),(f||p&&e.email)&&r.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",...i(`home-${e.num}`),title:f?"Auto-switch stops coming back to this account":"Auto-switch takes you here, and comes back after this account's 5-hour window resets",onClick:()=>m(),children:f?"Remove home":"Set as home"}),r.jsx("div",{role:"separator",className:"ap-menu-sep"}),r.jsx("button",{type:"button",role:"menuitem",className:`ap-menu-item danger${b===e.num?" armed":""}`,...i(`rm-${e.num}`),"aria-label":b===e.num?"Confirm remove":void 0,title:b===e.num?"This deletes the stored credentials for this account":"Remove this account from claude-swap",onClick:()=>M(e.num),children:o===`rm-${e.num}`?"Removing…":b===e.num?"Confirm":"Remove"}),$]}),w.view==="rename"&&r.jsxs("form",{className:"ap-pop-form",onSubmit:K=>{K.preventDefault(),O(e.num,e.alias)},children:[r.jsx("label",{className:"ap-pop-title",id:q,htmlFor:`ap-alias-${e.num}`,children:"Rename account"}),r.jsx("input",{id:`ap-alias-${e.num}`,className:"ap-manage-input",type:"text",value:v,onChange:K=>A(K.target.value),maxLength:Ane,placeholder:"e.g. work",spellCheck:!1,autoComplete:"off",autoFocus:!0,onFocus:K=>K.currentTarget.select()}),$,r.jsxs("div",{className:"ap-pop-actions",children:[r.jsx("button",{type:"button",className:"btn",onClick:()=>E(),children:"Cancel"}),r.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"})]})]}),w.view==="move"&&(()=>{const K=Tne(t,e.num),G=$ne(K,S,e.num),z=Lne(K,G,e.num);return r.jsxs("div",{className:"ap-pop-form",children:[r.jsx("label",{className:"ap-pop-title",id:q,htmlFor:`ap-slot-${e.num}`,children:"Move to slot"}),r.jsx("span",{className:"ap-field",children:r.jsx("select",{id:`ap-slot-${e.num}`,value:String(G),...i(`move-${e.num}`),onChange:W=>U(Number(W.target.value)),autoFocus:!0,children:K.map(W=>r.jsx("option",{value:W.slot,children:W.label},W.slot))})}),$,r.jsxs("div",{className:"ap-pop-actions",children:[r.jsx("button",{type:"button",className:"btn",onClick:()=>E(),children:"Cancel"}),r.jsx("button",{type:"button",className:"btn primary",...i(`move-${e.num}`),title:z.title,onClick:()=>P(e.num,G,z),children:o===`move-${e.num}`?"…":Bc(z.label)})]})]})})(),w.view==="share"&&(k==null?void 0:k.num)===e.num&&(()=>{const K=V4(k.expiresAt,n),G=K.tone==="gone";return r.jsxs("div",{className:"ap-pop-form",children:[r.jsx("p",{className:"ap-pop-title",id:q,children:"Share account"}),r.jsx("code",{className:"ap-share-blob",children:k.blob}),r.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:[r.jsx("span",{className:"ap-share-warn",children:"This is the password"})," · ",r.jsx("span",{className:`ap-share-expiry ${K.tone}`,children:K.text})]}),$,r.jsxs("div",{className:"ap-pop-actions",children:[r.jsx("button",{type:"button",className:"btn",onClick:()=>E(),children:"Done"}),r.jsx("button",{type:"button",className:"btn primary",...i(`share-${e.num}`),autoFocus:!0,onClick:async()=>{if(G){await T(e.num);return}await B(k.blob)},children:G?"Make a new share":N?"Copied":"Copy"})]})]})})()]})}const Dne=6;function Fne(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 s=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`,a=n.length?"ok":"idle",o=t.strained&&!t.armed?Bne(n):null,i=[s];return o!=null&&i.push(`${o}% free`),i.push(t.armed?`auto ${t.threshold??"on"}${t.threshold?"%":""}`:"auto off"),{text:i.join(" · "),tone:a,free:o}}function Bne(e){const t=e.map(n=>n.headroom).filter(n=>typeof n=="number");return t.length?Math.round(Math.max(...t)):null}function qne(e){const t=[...e].sort((a,o)=>{if(a.ready!==o.ready)return a.ready?-1:1;if(!a.ready)return a.name.localeCompare(o.name);const i=a.headroom,c=o.headroom;return i==null&&c==null?a.name.localeCompare(o.name):i==null?1:c==null?-1:c-i}),n=t.slice(0,Dne),s=t.length-n.length;return{title:e.some(a=>a.ready)?"Where you could switch":"Nothing to switch to",shown:n,rest:s>0?`and ${s} more`:null}}const K4=160,Y4=140;function Une(){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),Y4)},holdPeek:()=>window.clearTimeout(n.current),dropPeek:()=>{window.clearTimeout(n.current),t(!1)}}}function Wne(e){var t;return((t=e==null?void 0:e.detail)==null?void 0:t.fix)==="give_back"}function Fs(e,t){return{text:e,giveBack:Wne(t),done:!1}}async function Hne(){try{return await(await fetch("/api/prefs/give-back",{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"})).json().catch(()=>null)}catch{return null}}const zne={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 Vne(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?zne[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,X4=6e4;function Gt(e,t){if(t==null)return`Could not ${e} — the deck did not answer.`;const n=t.reason?Yne(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 Gne={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."},Kne=new Set(["EACCES","EPERM"]);function Yne(e,t){const n=Gne[e];if(!n)return;const s=e==="prefs_unreadable"&&t?Xne(t):void 0,a=t!=null&&t.code&&t.code!=="BADJSON"?` Error code: ${t.code}.`:"";return(s??n)+a}function Xne({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&&!Kne.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 Zne(e,t){const[n,s]=y.useState(null),[a,o]=y.useState([]),[i,c]=y.useState(null),[d,h]=y.useState(null),f=y.useRef(null),p=y.useCallback(P=>lp(f.current)?(f.current=P,c(P),!0):!1,[]),m=y.useCallback(()=>{f.current=null,b.current&&c(null)},[]),w=P=>{const T=Ga(i,P);return{disabled:T.disabled,"aria-busy":T.busy}},[j,v]=y.useState(()=>Date.now()),b=y.useRef(!0),k=y.useRef(H0),N=y.useCallback(async()=>{var P,T;try{const[B,M]=await Promise.all([fetch("/api/lan").then(q=>q.json()),fetch("/api/prefs").then(q=>q.json())]);if(!b.current)return;B!=null&&B.ok&&s(B),M!=null&&M.ok&&o(Array.isArray((T=(P=M.prefs)==null?void 0:P.lan)==null?void 0:T.manual)?M.prefs.lan.manual:[]),k.current=(B==null?void 0:B.enabled)===!0?H0:X4}catch{}},[]);y.useEffect(()=>{b.current=!0;let P=0;const T=async()=>{v(Date.now()),await N(),b.current&&(P=window.setTimeout(T,k.current))};return T(),()=>{b.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 T=await Vi("/api/prefs",{lan:{enabled:!P}});if(!b.current)return;T!=null&&T.ok?(h(null),P||t()):h(Fs(Gt(P?"turn this off":"turn this on",T),T)),await N()}catch{b.current&&h(Fs(Gt(P?"turn this off":"turn this on",null)))}finally{m()}},[n==null?void 0:n.enabled,N,p,m,t]),_=y.useCallback(async(P,T,B)=>{if(!p(`${P}:${T}`))return null;let M=null;try{const q=await Vi("/api/lan/peer",{action:P,fp:T});if(!b.current)return null;q!=null&&q.ok?(s(q),h(null)):(M=Gt(B,q),h(Fs(M,q))),await N()}catch{M=Gt(B,null),b.current&&h(Fs(M))}finally{m()}return M},[N,p,m]),E=y.useCallback(async P=>{if(!p(`drop:${P}`))return null;let T=null;try{const B=await Vi("/api/prefs",{lan:{manual:a.filter(M=>M!==P)}});if(!b.current)return null;B!=null&&B.ok?(h(null),e()):(T=Gt("stop dialling that address",B),h(Fs(T,B))),await N()}catch{T=Gt("stop dialling that address",null),b.current&&h(Fs(T))}finally{m()}return T},[a,N,e,p,m]),I=y.useCallback(async(P,T)=>{if(!p(`alias:${P}`))return"Something else is still being saved. Try again in a moment.";try{const B=await Vi("/api/lan/peer",{action:"alias",fp:P,name:T});return b.current?B!=null&&B.ok?(s(B),null):Gt("rename that deck",B):null}catch{return Gt("rename that deck",null)}finally{m()}},[p,m]),A=y.useCallback(async P=>{if(!p(`check:${P}`))return null;try{const T=await Vi("/api/lan/sync",{fp:P});return b.current?T!=null&&T.ok?(s(T),e(),null):(T==null?void 0:T.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.":Gt("check that deck",T):null}catch{return Gt("check that deck",null)}finally{m()}},[p,m,e]),O=y.useCallback(async()=>{if(p("check"))try{const P=await Vi("/api/lan/sync",{});if(!b.current)return;P!=null&&P.ok?(s(P),h(null)):h(Fs(Gt("check the other decks",P),P)),e()}catch{b.current&&h(Fs(Gt("check the other decks",null)))}finally{m()}},[p,m,e]);return{status:n,manual:a,now:j,busy:i,failure:d,dismissFailure:()=>h(null),answerGiveBack:P=>{h(P),P.done&&(N(),e())},pressProps:w,load:N,toggle:S,answer:_,dropAddress:E,rename:I,checkOne:A,checkNow:O}}function Jne(e){const[t,n]=y.useState(null),s=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=jl({armedFor:t,target:o.fp,armedAt:s.current,now:i,gapMs:kl});if(c==="arm"){n(o.fp),s.current=i;return}c!=="ignore"&&(n(null),e("unpair",o.fp,"unpair that deck"))}}}function Z4({title:e,steps:t,finish:n,aside:s,onClose:a}){const o=y.useRef(null),i=mt(a,{focusRef:o}),c=yt(a),[d,h]=y.useState(0),f=d===t.length-1,p=t[d],m=v=>h(Math.max(0,Math.min(t.length-1,v)));y.useEffect(()=>{var v,b;Yn(((v=document.activeElement)==null?void 0:v.tagName)??null)&&((b=o.current)==null||b.focus())},[d]);const w=v=>{v.key!=="ArrowRight"&&v.key!=="ArrowLeft"||(v.preventDefault(),v.stopPropagation(),m(v.key==="ArrowRight"?d+1:d-1))},j=()=>{if(!f){m(d+1);return}n?n.act():a()};return vt.createPortal(r.jsx("div",{className:"modal-backdrop",...c,role:"presentation",children:r.jsxs("div",{ref:i,className:"modal guide",onClick:v=>v.stopPropagation(),onKeyDown:w,role:"dialog","aria-modal":"true","aria-labelledby":"guide-title",children:[r.jsxs("header",{className:"modal-head",children:[r.jsxs("div",{className:"modal-title",children:[r.jsx("span",{id:"guide-title",className:"modal-tool-name",children:e}),r.jsxs("span",{className:"modal-tool-id",children:[d+1," / ",t.length]})]}),r.jsx("div",{className:"modal-actions",children:r.jsx("button",{type:"button",className:"glyph-btn",onClick:a,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),r.jsxs("section",{className:"modal-body",children:[r.jsx("div",{className:"guide-stage",children:p.art},d),r.jsx("p",{className:"guide-line","aria-live":"polite",children:p.line}),r.jsx("p",{className:"guide-tip",children:p.tip??""}),r.jsxs("div",{className:"guide-foot",children:[r.jsx("div",{className:"guide-dots",children:t.map((v,b)=>r.jsx("button",{type:"button",className:"glyph-btn guide-dot","aria-label":`Step ${b+1} of ${t.length}`,"aria-current":b===d?"step":void 0,onClick:()=>m(b)},b))}),f&&s&&r.jsx("button",{type:"button",className:"ap-lan-word guide-aside",onClick:s.act,children:s.label}),d>0&&r.jsx("button",{type:"button",className:"btn",onClick:()=>m(d-1),children:"Back"}),r.jsx("button",{ref:o,type:"button",className:"btn primary",onClick:j,children:f?(n==null?void 0:n.label)??"Done":"Next"})]})]})]})}),document.body)}const z0={ok:"ga-ok",warn:"ga-warn",accent:"ga-accent",flight:"ga-flight"};function xs({children:e}){return r.jsx("svg",{className:"guide-art",viewBox:"0 0 440 200","aria-hidden":!0,focusable:"false",children:e})}function ws({x:e,y:t=34,w:n=176,h:s=132,label:a}){return r.jsxs(r.Fragment,{children:[a&&r.jsx("text",{x:e+2,y:t-9,className:"ga-cap",children:a}),r.jsx("rect",{x:e,y:t,width:n,height:s,rx:10,className:"ga-screen"})]})}function zs({x:e,y:t,email:n,state:s,tone:a,bars:o}){return r.jsxs(r.Fragment,{children:[r.jsx("circle",{cx:e+3,cy:t-4,r:3,className:z0[a]}),r.jsx("text",{x:e+12,y:t,className:"ga-t ga-mono",children:n}),r.jsx("text",{x:e+12,y:t+16,className:`ga-s ${z0[a]}`,children:s}),o==null?void 0:o.map((i,c)=>r.jsxs("g",{children:[r.jsx("text",{x:e,y:t+40+c*18,className:"ga-s",children:c?"7d":"5h"}),r.jsx("rect",{x:e+22,y:t+35+c*18,width:96,height:4,rx:2,className:"ga-track"}),r.jsx("rect",{x:e+22,y:t+35+c*18,width:96*i/100,height:4,rx:2,className:"ga-accent"}),r.jsxs("text",{x:e+148,y:t+40+c*18,className:"ga-s ga-accent",textAnchor:"end",children:[i,"%"]})]},c))]})}function J4({x:e,y:t,on:n}){return r.jsxs(r.Fragment,{children:[r.jsx("rect",{x:e,y:t,width:30,height:18,rx:9,className:n?"ga-switch-on":"ga-switch"}),r.jsx("circle",{cx:n?e+21:e+9,cy:t+9,r:6,className:n?"ga-knob-on":"ga-knob"})]})}function vh({x:e,y:t,name:n,here:s=!0}){return r.jsxs(r.Fragment,{children:[r.jsx("circle",{cx:e+3,cy:t-4,r:3,className:s?"ga-ok":"ga-dim"}),r.jsx("text",{x:e+12,y:t,className:s?"ga-t":"ga-s",children:n})]})}function TT({x:e,y:t,on:n}){return n?r.jsxs(r.Fragment,{children:[r.jsx("rect",{x:e,y:t,width:12,height:12,rx:3,className:"ga-accent"}),r.jsx("path",{d:`M${e+3} ${t+6.2}l2.3 2.3 4-4.6`,className:"ga-tick"})]}):r.jsx("rect",{x:e+.5,y:t+.5,width:11,height:11,rx:3,className:"ga-box"})}function RT({x:e,y:t,d:n}){return r.jsx("path",{d:n,transform:`translate(${e} ${t})`,className:"ga-glyph"})}function $j({x:e,y:t}){return r.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 Lj(){return r.jsxs(r.Fragment,{children:[r.jsx("circle",{r:9,className:"ga-key-bed"}),r.jsxs("g",{transform:"translate(-6 -6) scale(0.857)",className:"ga-key",children:[r.jsx("circle",{cx:4.6,cy:7,r:2.6}),r.jsx("path",{d:"M7.2 7h5.2M10.6 7v2.2M12.4 7v1.6"})]})]})}function tl({x:e,y:t,w:n,title:s,sub:a,tone:o}){return r.jsxs(r.Fragment,{children:[r.jsx("rect",{x:e,y:t,width:n,height:40,rx:8,className:"ga-screen"}),r.jsx("rect",{x:e+6,y:t+10,width:3,height:20,rx:1.5,className:z0[o]}),r.jsx("text",{x:e+16,y:t+17,className:"ga-t ga-strong",children:s}),r.jsx("text",{x:e+16,y:t+31,className:"ga-s",children:a})]})}function dl({x:e,y:t,label:n,live:s}){return r.jsxs(r.Fragment,{children:[r.jsx("rect",{x:e,y:t,width:46,height:20,rx:10,className:s?"ga-chip-live":"ga-chip"}),r.jsx("text",{x:e+23,y:t+14,className:"ga-s ga-mono",textAnchor:"middle",children:n})]})}function Af({x:e,y:t}){return r.jsxs(r.Fragment,{children:[r.jsx("text",{x:e,y:t,className:"ga-cap",children:"LOCAL NETWORK"}),r.jsx(J4,{x:e+118,y:t-13,on:!0})]})}function Qne(){return r.jsxs(xs,{children:[r.jsx("rect",{x:14,y:14,width:206,height:172,rx:10,className:"ga-screen"}),r.jsx("text",{x:28,y:38,className:"ga-t ga-strong",children:"Sessions"}),r.jsx("text",{x:206,y:38,className:"ga-s ga-warn",textAnchor:"end",children:"1 waiting"}),r.jsx("rect",{x:20,y:50,width:194,height:42,rx:6,className:"ga-bed-warn"}),r.jsx("circle",{cx:33,cy:64,r:7,className:"ga-ring-warn ga-ping"}),r.jsx("circle",{cx:33,cy:64,r:3.5,className:"ga-warn"}),r.jsx("text",{x:44,y:68,className:"ga-t",children:"api-server"}),r.jsx("text",{x:44,y:83,className:"ga-s ga-warn",children:"waiting 6m · Bash"}),r.jsx("circle",{cx:33,cy:108,r:3.5,className:"ga-flight"}),r.jsx("text",{x:44,y:112,className:"ga-t",children:"docs-site"}),r.jsx("text",{x:44,y:127,className:"ga-s",children:"running · 12 tools"}),r.jsx("circle",{cx:33,cy:150,r:3.5,className:"ga-ok"}),r.jsx("text",{x:44,y:154,className:"ga-t",children:"billing"}),r.jsx("text",{x:44,y:169,className:"ga-s",children:"done · $0.84"}),r.jsx("path",{d:"M216 71C234 71 230 100 244 100",className:"ga-arc"}),r.jsx("path",{d:"M239 96l5 4-5 4",className:"ga-arrow"}),r.jsx("rect",{x:248,y:44,width:178,height:112,rx:10,className:"ga-screen"}),r.jsx("text",{x:262,y:64,className:"ga-cap",children:"API-SERVER"}),r.jsx("line",{x1:248,y1:74,x2:426,y2:74,className:"ga-line"}),r.jsx("text",{x:262,y:96,className:"ga-s ga-mono",children:"Bash(npm test)"}),r.jsx("text",{x:262,y:116,className:"ga-t ga-mono ga-warn",children:"Allow this command?"}),r.jsx("text",{x:262,y:136,className:"ga-s ga-mono",children:"> 1. Yes 2. No"})]})}function ese(){return r.jsxs(xs,{children:[r.jsx("path",{d:"M136 100C166 100 166 38 196 38",className:"ga-edge ga-flow"}),r.jsx("path",{d:"M136 100H196",className:"ga-edge ga-flow"}),r.jsx("path",{d:"M136 100C166 100 166 162 196 162",className:"ga-edge-done"}),r.jsx("path",{d:"M308 38H326M308 100H326",className:"ga-edge"}),r.jsx(tl,{x:20,y:80,w:116,title:"main",sub:"Opus 5 · 9 tools",tone:"accent"}),r.jsx(tl,{x:196,y:18,w:112,title:"explore",sub:"Haiku · 14 tools",tone:"flight"}),r.jsx(tl,{x:196,y:80,w:112,title:"tests",sub:"Sonnet · 6 tools",tone:"flight"}),r.jsx(tl,{x:196,y:142,w:112,title:"review",sub:"done · 38s",tone:"ok"}),r.jsx(dl,{x:326,y:28,label:"Read"}),r.jsx(dl,{x:380,y:28,label:"Grep",live:!0}),r.jsx(dl,{x:326,y:90,label:"Bash",live:!0})]})}function AT({x:e,y:t,label:n,pct:s,note:a}){return r.jsxs(r.Fragment,{children:[r.jsx("text",{x:e,y:t,className:"ga-s",children:n}),r.jsxs("text",{x:e+194,y:t,className:"ga-s ga-accent",textAnchor:"end",children:[s,"%"]}),r.jsx("rect",{x:e,y:t+7,width:194,height:5,rx:2.5,className:"ga-track"}),r.jsx("rect",{x:e,y:t+7,width:194*s/100,height:5,rx:2.5,className:"ga-accent"}),r.jsx("text",{x:e,y:t+26,className:"ga-s",children:a})]})}function tse(){return r.jsxs(xs,{children:[r.jsx("rect",{x:14,y:30,width:172,height:140,rx:10,className:"ga-screen"}),r.jsx("text",{x:30,y:56,className:"ga-cap",children:"THIS SESSION"}),r.jsx("text",{x:30,y:98,className:"ga-big",children:"$3.66"}),r.jsx("text",{x:30,y:122,className:"ga-s",children:"Opus 5 · 1.2M tokens"}),r.jsx("text",{x:30,y:150,className:"ga-s",children:"$21.40 today"}),r.jsx("rect",{x:200,y:30,width:226,height:140,rx:10,className:"ga-screen"}),r.jsx("text",{x:216,y:56,className:"ga-cap",children:"CLAUDE QUOTA"}),r.jsx(AT,{x:216,y:80,label:"5-hour window",pct:24,note:"resets in 53m"}),r.jsx(AT,{x:216,y:124,label:"7-day window",pct:61,note:"resets in 4d"})]})}function nse(){return r.jsxs(xs,{children:[r.jsx("rect",{x:14,y:40,width:172,height:120,rx:10,className:"ga-canvas"}),r.jsx(tl,{x:30,y:80,w:140,title:"tests",sub:"Sonnet 5 · 6 tools",tone:"flight"}),r.jsx($j,{x:156,y:106}),r.jsx("path",{d:"M170 92C186 92 184 60 200 60",className:"ga-arc"}),r.jsx("path",{d:"M195 56l5 4-5 4",className:"ga-arrow"}),r.jsx(ws,{x:200,y:22,w:226,h:160}),r.jsx("text",{x:214,y:46,className:"ga-t ga-strong",children:"tests"}),r.jsx("text",{x:412,y:46,className:"ga-s",textAnchor:"end",children:"Sonnet 5 · 38s"}),r.jsx("line",{x1:200,y1:56,x2:426,y2:56,className:"ga-line"}),r.jsx("text",{x:214,y:76,className:"ga-cap",children:"PROMPT"}),r.jsx("text",{x:214,y:92,className:"ga-t",children:"Run the suite and fix what fails"}),r.jsx("text",{x:214,y:116,className:"ga-cap",children:"TOOLS · 6"}),r.jsx(dl,{x:214,y:122,label:"Read"}),r.jsx(dl,{x:266,y:122,label:"Edit"}),r.jsx(dl,{x:318,y:122,label:"Bash",live:!0}),r.jsx("text",{x:214,y:164,className:"ga-cap",children:"TOKENS"}),r.jsx("text",{x:214,y:178,className:"ga-s ga-mono",children:"41k in · 2.1k out · $0.12"})]})}function sse(){const e=[18,24,28,14,22,26,30,16,24,28,20,26];return r.jsxs(xs,{children:[r.jsx(ws,{x:14,y:20,w:412,h:160}),r.jsx("text",{x:28,y:44,className:"ga-t ga-strong",children:"This machine"}),r.jsx("text",{x:412,y:44,className:"ga-s",textAnchor:"end",children:"12 cores · up 10d"}),r.jsx("line",{x1:14,y1:56,x2:426,y2:56,className:"ga-line"}),r.jsx("text",{x:28,y:76,className:"ga-cap",children:"CORES"}),e.map((t,n)=>r.jsxs("g",{children:[r.jsx("rect",{x:28+n*15,y:82,width:10,height:30,rx:2,className:"ga-track"}),r.jsx("rect",{x:28+n*15,y:112-t,width:10,height:t,rx:2,className:"ga-accent"})]},n)),r.jsx("text",{x:28,y:136,className:"ga-cap",children:"MEMORY"}),r.jsx("rect",{x:28,y:143,width:178,height:5,rx:2.5,className:"ga-track"}),r.jsx("rect",{x:28,y:143,width:105,height:5,rx:2.5,className:"ga-accent"}),r.jsx("text",{x:28,y:165,className:"ga-s",children:"18.9 GB of 32.0 GB"}),r.jsx("text",{x:240,y:76,className:"ga-cap",children:"THERMAL"}),r.jsx("text",{x:240,y:100,className:"ga-big",children:"66 °C"}),r.jsx("text",{x:240,y:118,className:"ga-s ga-ok",children:"running at full speed"}),r.jsx("text",{x:240,y:142,className:"ga-cap",children:"BUSIEST PROCESSES"}),r.jsx("text",{x:240,y:160,className:"ga-s ga-mono",children:"node · claude"}),r.jsx("text",{x:412,y:160,className:"ga-s ga-mono",textAnchor:"end",children:"38%"}),r.jsx("text",{x:240,y:176,className:"ga-s ga-mono",children:"esbuild"}),r.jsx("text",{x:412,y:176,className:"ga-s ga-mono",textAnchor:"end",children:"21%"})]})}function rse(){return r.jsxs(xs,{children:[r.jsx("rect",{x:14,y:40,width:188,height:120,rx:10,className:"ga-screen"}),r.jsx("text",{x:28,y:60,className:"ga-cap",children:"~/MY-PROJECT"}),r.jsx("line",{x1:14,y1:70,x2:202,y2:70,className:"ga-line"}),r.jsxs("text",{x:28,y:100,className:"ga-t ga-mono",children:[r.jsx("tspan",{className:"ga-accent",children:"$"})," claude"]}),r.jsx("rect",{x:86,y:90,width:7,height:13,className:"ga-caret ga-blink"}),r.jsx("text",{x:28,y:130,className:"ga-s ga-mono",children:"or: codex"}),r.jsx("path",{d:"M210 100H238",className:"ga-arc"}),r.jsx("path",{d:"M233 95l6 5-6 5",className:"ga-arrow"}),r.jsx("rect",{x:250,y:40,width:176,height:120,rx:10,className:"ga-canvas"}),r.jsx("g",{className:"ga-pop",children:r.jsx(tl,{x:278,y:80,w:120,title:"my-project",sub:"Opus 5 · live",tone:"accent"})})]})}function ase(){return r.jsxs(xs,{children:[r.jsx(ws,{x:14,y:16,w:232,h:170}),r.jsx("text",{x:28,y:40,className:"ga-t ga-strong",children:"Claude accounts"}),r.jsx(RT,{x:196,y:33,d:"M7 2.2v9.6M2.2 7h9.6"}),r.jsx(RT,{x:220,y:33,d:"M3.3 10.7L10.7 3.3M5.2 3.3h5.5v5.5"}),r.jsx("line",{x1:14,y1:52,x2:246,y2:52,className:"ga-line"}),r.jsx(zs,{x:28,y:74,email:"work@team.dev",state:"working",tone:"ok",bars:[24,61]}),r.jsx("rect",{x:190,y:62,width:44,height:18,rx:9,className:"ga-accent"}),r.jsx("text",{x:212,y:74,className:"ga-s ga-on-accent",textAnchor:"middle",children:"active"}),r.jsx("line",{x1:14,y1:140,x2:246,y2:140,className:"ga-line"}),r.jsx(zs,{x:28,y:160,email:"personal@me.dev",state:"signed in",tone:"ok"}),r.jsx("rect",{x:188,y:148,width:46,height:18,rx:9,className:"ga-chip"}),r.jsx("text",{x:211,y:160,className:"ga-s",textAnchor:"middle",children:"switch"}),r.jsx($j,{x:221,y:161}),r.jsx("path",{d:"M250 40C270 40 262 78 282 78",className:"ga-arc"}),r.jsx("path",{d:"M277 74l5 4-5 4",className:"ga-arrow"}),r.jsx(ws,{x:282,y:62,w:144,h:64,label:"ANOTHER MACHINE"}),r.jsx("g",{className:"ga-pop",children:r.jsx(zs,{x:296,y:92,email:"work@team.dev",state:"shared here",tone:"ok"})})]})}function ose(){return r.jsxs(xs,{children:[r.jsx(ws,{x:14,label:"THIS MACHINE"}),r.jsx(Af,{x:28,y:60}),r.jsx("g",{className:"ga-swap-out",children:r.jsx(zs,{x:28,y:98,email:"work@team.dev",state:"login expired",tone:"warn"})}),r.jsx("g",{className:"ga-swap-in",children:r.jsx(zs,{x:28,y:98,email:"work@team.dev",state:"working again",tone:"ok",bars:[24,61]})}),r.jsx(ws,{x:250,label:"ANOTHER MACHINE"}),r.jsx(Af,{x:264,y:60}),r.jsx(zs,{x:264,y:98,email:"work@team.dev",state:"working",tone:"ok",bars:[24,61]}),r.jsx("path",{d:"M246 120C234 80 206 80 194 120",className:"ga-arc"}),r.jsx("g",{className:"ga-travel ga-travel-low",transform:"translate(220 90)",children:r.jsx(Lj,{})})]})}const ise=[{art:r.jsx(Qne,{}),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:r.jsx(ese,{}),line:"Every agent and subagent is a node. Tool calls light up as they run."},{art:r.jsx(nse,{}),line:"Double-click any node: its prompt, every tool call, tokens and timing."},{art:r.jsx(tse,{}),line:"What each session costs, and how much quota is left."},{art:r.jsx(sse,{}),line:"Cores, memory and heat while the agents run, and what is hogging them."},{art:r.jsx(ase,{}),line:"Several Claude accounts: switch, add one, share one to another machine."},{art:r.jsx(ose,{}),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:r.jsx(rse,{}),line:"Run claude or codex in any folder. It shows up here on its own."}];function lse(){return r.jsxs(xs,{children:[r.jsx(ws,{x:14,label:"THIS MACHINE"}),r.jsx(zs,{x:28,y:64,email:"work@team.dev",state:"login expired",tone:"warn"}),r.jsx("rect",{x:40,y:94,width:86,height:20,rx:10,className:"ga-pill-warn"}),r.jsx("text",{x:83,y:108,className:"ga-s ga-warn",textAnchor:"middle",children:"sign in again"}),r.jsx("line",{x1:198,y1:100,x2:242,y2:100,className:"ga-off"}),r.jsx(ws,{x:250,label:"ANOTHER MACHINE"}),r.jsx(zs,{x:264,y:64,email:"work@team.dev",state:"working",tone:"ok",bars:[24,61]})]})}function cse(){return r.jsxs(xs,{children:[r.jsx(ws,{x:14,label:"THIS MACHINE"}),r.jsx(Af,{x:28,y:60}),r.jsx(vh,{x:28,y:92,name:"Ana's MacBook"}),r.jsx(vh,{x:28,y:114,name:"Dorin's PC"}),r.jsx(ws,{x:250,label:"ANOTHER MACHINE"}),r.jsx(Af,{x:264,y:60}),r.jsx(vh,{x:264,y:92,name:"Your MacBook"}),r.jsx(vh,{x:264,y:114,name:"Dorin's PC"}),r.jsx("line",{x1:196,y1:100,x2:244,y2:100,className:"ga-arc"}),r.jsx("circle",{cx:220,cy:100,r:10,className:"ga-ring ga-ping"}),r.jsx("circle",{cx:220,cy:100,r:10,className:"ga-ring ga-ping ga-ping-2"}),r.jsx("circle",{cx:220,cy:100,r:3,className:"ga-accent"})]})}function use(){return r.jsxs(xs,{children:[r.jsx("rect",{x:90,y:18,width:260,height:164,rx:10,className:"ga-screen"}),r.jsx("text",{x:106,y:42,className:"ga-t ga-strong",children:"This deck on the network"}),r.jsx("line",{x1:90,y1:54,x2:350,y2:54,className:"ga-line"}),r.jsx("text",{x:106,y:76,className:"ga-cap",children:"SHARE THESE ACCOUNTS"}),r.jsx(TT,{x:106,y:88,on:!0}),r.jsx("text",{x:126,y:98,className:"ga-t ga-mono",children:"work@team.dev"}),r.jsx(TT,{x:106,y:112}),r.jsx("text",{x:126,y:122,className:"ga-s ga-mono",children:"personal@me.dev"}),r.jsx("text",{x:106,y:150,className:"ga-cap",children:"PAIRING"}),r.jsx("text",{x:106,y:168,className:"ga-s",children:"Say yes to every deck that asks"}),r.jsx(J4,{x:304,y:157,on:!0}),r.jsx($j,{x:115,y:97})]})}function dse(){return r.jsxs(xs,{children:[r.jsx(ws,{x:14,label:"THIS MACHINE"}),r.jsx("g",{className:"ga-swap-out",children:r.jsx(zs,{x:28,y:64,email:"work@team.dev",state:"login expired",tone:"warn"})}),r.jsx("g",{className:"ga-swap-in",children:r.jsx(zs,{x:28,y:64,email:"work@team.dev",state:"working again",tone:"ok",bars:[24,61]})}),r.jsx(ws,{x:250,label:"ANOTHER MACHINE"}),r.jsx(zs,{x:264,y:64,email:"work@team.dev",state:"working",tone:"ok",bars:[24,61]}),r.jsx("path",{d:"M246 96C234 56 206 56 194 96",className:"ga-arc"}),r.jsx("g",{className:"ga-travel",transform:"translate(220 66)",children:r.jsx(Lj,{})})]})}const hse=[{art:r.jsx(lse,{}),line:"A login can expire on one machine while it still works on another."},{art:r.jsx(cse,{}),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:r.jsx(use,{}),line:"Tick which logins this machine may hand out. Nothing is shared until you do."},{art:r.jsx(dse,{}),line:"An expired login is copied from a paired machine within a minute."}];function fse(){return r.jsxs("svg",{className:"guide-art",viewBox:"0 0 232 60","aria-hidden":!0,focusable:"false",children:[r.jsx("rect",{x:1,y:14,width:78,height:42,rx:7,className:"ga-screen"}),r.jsx("circle",{cx:13,cy:29,r:3,className:"ga-warn"}),r.jsx("rect",{x:21,y:27,width:46,height:4,rx:2,className:"ga-track"}),r.jsx("rect",{x:13,y:39,width:40,height:3,rx:1.5,className:"ga-track"}),r.jsx("rect",{x:153,y:14,width:78,height:42,rx:7,className:"ga-screen"}),r.jsx("circle",{cx:165,cy:29,r:3,className:"ga-ok"}),r.jsx("rect",{x:173,y:27,width:46,height:4,rx:2,className:"ga-track"}),r.jsx("rect",{x:165,y:39,width:40,height:3,rx:1.5,className:"ga-accent"}),r.jsx("path",{d:"M150 36C138 6 94 6 82 36",className:"ga-arc"}),r.jsx("g",{transform:"translate(116 13)",children:r.jsx(Lj,{})})]})}const pse={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."},mse=1600;function Q4({reach:e,where:t}){const[n,s]=y.useState(!1),a=y.useRef(!0);y.useEffect(()=>()=>{a.current=!1},[]);const o=(e==null?void 0:e.steps)??[],i=y.useCallback(async()=>{await eo(o.join(`
|
|
101
|
+
`))&&a.current&&(s(!0),window.setTimeout(()=>{a.current&&s(!1)},mse))},[o]);if(!(e!=null&&e.blocked))return null;const c=e.shell==="sh",d=!!e.tool;return r.jsxs("div",{className:"ap-lan-reach",children:[r.jsx("p",{className:"lan-warn",children:e.text}),r.jsx("p",{className:"lan-note",children:pse[t]}),o.length>0&&r.jsxs("details",{className:"ap-lan-reach-fix",children:[r.jsx("summary",{children:"or let them find this deck on their own"}),r.jsxs("p",{className:"lan-note",children:[d?r.jsx(r.Fragment,{children:"Run this in a terminal on this machine. It applies at once, and this note goes away when another deck connects."}):c?r.jsx(r.Fragment,{children:"Run this in a terminal on this machine, then restart the deck."}):r.jsxs(r.Fragment,{children:["Run this in PowerShell ",r.jsx("strong",{children:"as Administrator"}),", then restart the deck."]}),e.category==="Public"&&r.jsx(r.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&&r.jsxs(r.Fragment,{children:[" ",e.unsure]})]}),r.jsx("pre",{className:"ap-lan-cmd",children:r.jsx("code",{children:o.join(`
|
|
102
|
+
`)})}),r.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 gse(e){const t=(e??"").trim(),n=t.lastIndexOf(":");if(n<=0||n===t.length-1)return null;const s=t.slice(0,n).trim(),a=Number(t.slice(n+1).trim());return!s||!Number.isInteger(a)||a<1||a>65535||s.includes(":")&&!(s.startsWith("[")&&s.endsWith("]"))?null:{addr:s,port:a}}function yse(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 ly(e,t){return(await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).json().catch(()=>null)}const wse={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."},xse={not_running:"This deck is not on the network yet. Turn Local network on, then make one."};function MT(e,t,n){return(t==null?void 0:t.reason)&&e[t.reason]||Gt(n,t)}function vse({status:e,manual:t,startWith:n,onClose:s,onChanged:a}){const o=y.useRef(null),i=y.useRef(null),c=y.useRef(null),d=y.useRef(null),h=e.pairingMode==="invite",f=mt(s,{focusRef:h?i:o}),p=yt(s),[m,w]=y.useState(""),[j,v]=y.useState(""),[b,k]=y.useState(null),[N,S]=y.useState(null),[_,E]=y.useState(null),[I,A]=y.useState(null),[O,L]=y.useState(()=>Date.now());y.useEffect(()=>{const X=window.setInterval(()=>L(Date.now()),1e3);return()=>window.clearInterval(X)},[]);const U=y.useRef(!0);y.useEffect(()=>()=>{U.current=!1},[]);const P=y.useRef(null),T=y.useRef(null),B=y.useCallback(X=>lp(P.current)?(P.current=X,E(X),!0):!1,[]),M=y.useCallback(()=>{P.current=null,U.current&&E(null)},[]),q=X=>{const Z=Ga(_,X);return{disabled:Z.disabled,"aria-busy":Z.busy}},$=X=>(b==null?void 0:b.field)===X?{"aria-invalid":!0,"aria-describedby":"lan-add-failure"}:{},K=X=>k(Z=>Z&&Z.field===X?null:Z),G=y.useCallback(async()=>{if(h)return;const X=gse(m);if(!X){k({text:bse(m),field:"addr"});return}const Z=`${X.addr}:${X.port}`,J=e.peers.find(ne=>ne.addr===X.addr&&ne.port===X.port&&ne.paired);if(J){k({text:`Already paired with ${J.name} at that address.`,field:"addr"});return}if(t.includes(Z)){k({text:"This deck already calls that address.",field:"addr"});return}if(B("add"))try{const ne=await ly("/api/prefs",{lan:{manual:[...t,Z]}});if(!U.current)return;ne!=null&&ne.ok?(k(null),w(""),a(),s()):k({text:Gt("add that address",ne),field:"addr"})}catch{U.current&&k({text:Gt("add that address",null),field:"addr"})}finally{M()}},[m,h,t,e.peers,a,s,B,M]),z=y.useCallback(async X=>{if(!B(`invite:${X}`))return;const Z=X==="make"?"make an invite":"cancel that invite";try{const J=await ly("/api/lan/invite",{action:X});if(!U.current)return;J!=null&&J.ok?(T.current=X,k(null),S(null),a()):k({text:MT(xse,J,Z)})}catch{U.current&&k({text:Gt(Z,null)})}finally{M()}},[a,B,M]),W=y.useCallback(async()=>{const X=j.trim();if(!(!X||!B("join"))){A(null);try{const Z=await ly("/api/lan/invite",{action:"join",token:X});if(!U.current)return;Z!=null&&Z.ok?(v(""),k(null),a(),s()):(Z==null?void 0:Z.reason)==="unreachable"&&Array.isArray(Z.tried)&&Z.tried.length?(A(Z.tried),k(null)):(A(null),k({text:MT(wse,Z,"use that invite"),field:"join"}))}catch{U.current&&k({text:Gt("use that invite",null),field:"join"})}finally{M()}}},[j,a,s,B,M]),D=y.useCallback(async(X,Z)=>{try{await navigator.clipboard.writeText(X),S(Z),window.setTimeout(()=>{U.current&&S(J=>J===Z?null:J)},1600)}catch{k({text:"Could not copy it — select the text and copy it by hand."})}},[]),H=e.invite&&e.invite.expiresAt>O?e.invite:null,ee=y.useRef(!1);y.useEffect(()=>{n!=="invite"||ee.current||H||(ee.current=!0,z("make"))},[n,H,z]);const F=y.useRef(!1);y.useEffect(()=>{var X;n!=="invite"||F.current||!H||(F.current=!0,(X=c.current)==null||X.focus())},[n,H]),y.useEffect(()=>{var Z,J;const X=T.current;!X||X==="make"!=!!H||(T.current=null,Yn(((Z=document.activeElement)==null?void 0:Z.tagName)??null)&&((J=(X==="make"?c:d).current)==null||J.focus()))},[H]);const Y=e.port!=null?(e.addrs??[]).map(X=>`${X}:${e.port}`):[];return vt.createPortal(r.jsx("div",{className:"modal-backdrop",...p,role:"presentation",children:r.jsxs("div",{ref:f,className:"modal lan-add",onClick:X=>X.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-add-title",children:[r.jsxs("header",{className:"modal-head",children:[r.jsx("div",{className:"modal-title",children:r.jsx("span",{id:"lan-add-title",className:"modal-tool-name",children:"Add a deck"})}),r.jsx("div",{className:"modal-actions",children:r.jsx("button",{className:"glyph-btn",onClick:s,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),r.jsxs("section",{className:"modal-body",children:[b&&r.jsxs("div",{className:"ap-failure",role:"alert",children:[r.jsx("span",{id:"lan-add-failure",className:"ap-failure-text",children:b.text}),r.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>k(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),r.jsx(Q4,{reach:e.reach,where:"dialog"}),h&&r.jsx("div",{className:"modal-section",children:r.jsx("p",{className:"lan-note",children:"Adding by address is off while this deck pairs only by invite."})}),!h&&r.jsxs("div",{className:"modal-section",children:[r.jsx("h3",{className:"lan-h",children:"By address"}),r.jsxs("div",{className:"ap-lan-row",children:[r.jsx("input",{ref:o,className:"ap-manage-input ap-lan-input","aria-label":"Another deck's address",value:m,placeholder:"192.168.1.5:54340",spellCheck:!1,...$("addr"),onChange:X=>{w(X.target.value),K("addr")},onKeyDown:X=>{X.key==="Enter"&&G()}}),m.trim()!==""&&r.jsx("button",{type:"button",className:"ap-manage-btn",...q("add"),onClick:()=>void G(),title:"Add it to the decks this one calls, starting now.",children:"add"})]}),r.jsx("p",{className:"lan-note",children:"This deck calls that address until somebody there accepts."}),e.port!=null&&Y.length>0&&r.jsxs("p",{className:"lan-note",children:["They type this deck’s own address into the same field on theirs:"," ",Y.map((X,Z)=>r.jsxs("span",{children:[Z>0&&" or ",r.jsx("code",{className:"ap-lan-code",children:X})]},X)),r.jsx("button",{type:"button",className:"ap-lan-word lan-copy",...q("copy:mine"),onClick:()=>void D(Y.join(" "),"mine"),title:"Copy this deck's address, to send to whoever is adding it",children:N==="mine"?"copied":"copy"})]})]}),r.jsxs("div",{className:"modal-section",children:[r.jsxs("h3",{className:"lan-h",children:["With an invite",!H&&r.jsx("button",{type:"button",className:"ap-lan-word lan-h-act",ref:d,...q("invite:make"),onClick:()=>void z("make"),title:"One piece of text you send them. They paste it, and the two decks pair — nobody has to press anything here.",children:_==="invite:make"?"making…":"make one to send"})]}),r.jsxs("div",{className:"ap-lan-row",children:[r.jsx("input",{ref:i,className:"ap-manage-input ap-lan-input","aria-label":"An invite you were sent",value:j,placeholder:"paste one you were sent",spellCheck:!1,...$("join"),onChange:X=>{v(X.target.value),A(null),K("join")},onKeyDown:X=>{X.key==="Enter"&&W()}}),j.trim()!==""&&r.jsx("button",{type:"button",className:"ap-manage-btn",...q("join"),onClick:()=>void W(),title:"Reach that deck and pair with it. Nobody has to press anything there.",children:_==="join"?"joining…":"join"})]}),r.jsx("p",{className:"lan-note",children:"Pasting one pairs both decks on the spot — nobody has to accept."}),I&&r.jsxs("div",{className:"ap-lan-tried",children:[r.jsx("span",{className:"lan-note",children:"Nothing answered at any address in that invite. Check that deck is running with its Local network switch on."}),I.map(X=>r.jsxs("span",{className:"ap-lan-tried-row",children:[r.jsx("code",{className:"ap-lan-code",children:X.addr}),r.jsx("span",{className:"ap-lan-bad",children:X.why})]},X.addr))]}),H&&r.jsxs("div",{className:"ap-lan-invite",children:[r.jsxs("div",{className:"ap-lan-invite-head",children:[r.jsx("span",{className:"ap-lan-invite-title",children:"Send this to them"}),r.jsxs("span",{className:"ap-lan-invite-left",id:"lan-invite-left",children:[yse(H.expiresAt,O)," left"]})]}),r.jsx("code",{className:"ap-lan-token",children:H.token}),r.jsxs("div",{className:"ap-lan-acts",children:[r.jsx("button",{type:"button",className:"ap-manage-btn",ref:c,...q("copy:invite"),"aria-label":N==="invite"?"Invite copied":"Copy invite","aria-describedby":"lan-invite-left",onClick:()=>void D(H.token,"invite"),title:"Copy it, and send it however you already talk to them",children:N==="invite"?"copied":"copy"}),r.jsx("button",{type:"button",className:"ap-manage-btn",...q("invite:withdraw"),onClick:()=>void z("withdraw"),title:"Cancel it. Anybody already holding the text can no longer use it.",children:"cancel"})]}),r.jsx("p",{className:"lan-warn",children:"Anyone who gets this text can pair with this deck until it runs out."})]})]})]})]})}),document.body)}function bse(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 kse({asks:e,pressProps:t,answer:n}){return r.jsx("div",{className:"ap-lan-asks",role:"alert",children:e.map(s=>r.jsxs("div",{className:"ap-lan-ask",children:[r.jsxs("span",{className:"ap-lan-ask-what",children:[r.jsx("strong",{className:"ap-lan-peer-name",children:s.name})," at ",r.jsx("code",{className:"ap-lan-code",children:s.addr})," wants to pair"]}),r.jsxs("span",{className:"ap-lan-ask-fp",id:`lan-ask-fp-${s.fp}`,children:["fingerprint ",r.jsx("code",{className:"ap-lan-code",children:s.fp})]}),r.jsxs("span",{className:"ap-lan-ask-acts",children:[r.jsx("button",{type:"button",className:"ap-manage-btn",...t(`accept:${s.fp}`),"aria-label":`Accept ${s.name}`,"aria-describedby":`lan-ask-fp-${s.fp}`,onClick:()=>void n("accept",s.fp,"accept that deck"),title:`Talk to this deck from now on. Its fingerprint is ${s.fp} — check it matches the one on their screen before you accept.`,children:"accept"}),r.jsx("button",{type:"button",className:"ap-manage-btn",...t(`dismiss:${s.fp}`),"aria-label":`Decline ${s.name}`,"aria-describedby":`lan-ask-fp-${s.fp}`,onClick:()=>void n("dismiss",s.fp,"decline that request"),title:"Say no. Nothing is shared, and that deck is told rather than left waiting.",children:"decline"})]})]},s.fp))})}function jse({rows:e,pairingMode:t,armed:n,pressProps:s,answer:a,dropAddress:o,onUnpair:i,onOpenPeer:c,onInvite:d}){return r.jsx("ul",{className:"ap-lan-here",children:e.map((h,f)=>r.jsxs("li",{className:"ap-lan-who","data-tone":h.tone,children:[r.jsx("i",{className:h.here?"ap-pulse":"ap-dot","aria-hidden":!0}),r.jsxs("span",{className:"ap-lan-who-name","aria-hidden":!0,children:[h.name,h.via==="tailscale"&&r.jsx("span",{className:"ap-lan-via",children:" · Tailscale"})]}),r.jsx("button",{type:"button",className:"ap-lan-who-open","aria-haspopup":"dialog","aria-describedby":`lan-who-state-${f}`,onClick:()=>c(h.fp),children:r.jsxs("span",{className:"vis-hidden",children:[h.name,h.via==="tailscale"?", over Tailscale":"",", details"]})}),r.jsx("span",{id:`lan-who-state-${f}`,className:h.quiet?"vis-hidden":"ap-lan-who-when",children:h.state}),h.kind==="nearby"&&t!=="invite"&&r.jsx("button",{type:"button",className:"ap-manage-btn ap-lan-do",...s(`accept:${h.fp}`),onClick:()=>void a("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"&&r.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"&&r.jsx("button",{type:"button",className:`ap-manage-btn ap-lan-do danger${n===h.fp?" armed":""}`,...s(`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"&&r.jsx("button",{type:"button",className:"ap-manage-btn ap-lan-do",...s(`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"&&r.jsx("button",{type:"button",className:"ap-manage-btn ap-lan-do",...s(`allow:${h.fp}`),onClick:()=>void a("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 Nse(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 Sse({on:e,status:t}){return r.jsxs(r.Fragment,{children:[e&&r.jsx(Q4,{reach:t==null?void 0:t.reach,where:"panel"}),e&&(t==null?void 0:t.deaf)&&r.jsx("p",{className:"ap-lan-fine",children:t.deaf}),e&&(t==null?void 0:t.lanTunneled)&&r.jsx("p",{className:"ap-lan-fine",children:Nse(t)})]})}const $T=["online","offline","loose"],_se={online:0,offline:1,loose:2};function Cse(e){return e.kind==="declined"?null:e.kind==="paired"?e.here?"online":"offline":"loose"}const Ese=76,Tse=62,Mf=96,Rse={1:[.62],2:[.58,1],3:[.42,.72,1]},Ase=.2,Mse=.16,$se=.05,Lse=20,Ise=17,bh=7,Ose=30,Pse=116,Dse=6.6,Fse=6,Bse=e=>Ij(e,null),qse=1.5,Use=80,Wse=.45,LT=40,Hse=64,zse=150,IT=.3,OT=84,PT=8,Vse=1.3,$f=6,Gse=5.94,DT=7,FT=16,Mc=4,BT=.16;function V0(e,t){return Math.PI*(3*(e+t)-Math.sqrt((3*e+t)*(e+3*t)))}function eD(e,t){return t<-Math.abs(e)*.6?"top":"bottom"}function Kse(e,t){if(e<=2)return t%2===0?0:90;const n=360/e;return-90+(t%2===0?0:n/2)}function Yse(e){return e.map((t,n)=>({...t,i:n})).sort((t,n)=>$T.indexOf(t.tier)-$T.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 qT(e,t){let n=2166136261^t;for(let s=0;s<e.length;s++)n^=e.charCodeAt(s),n=Math.imul(n,16777619);return(n>>>0)%2e4/1e4-1}function Xse(e,t,n){const s=[...Rse[e.length]??[]];for(let a=0;a<s.length;a++){const o=e[a];if(o<2)continue;const i=V0(t*s[a],n*s[a])/o;if(!(i>0)||i>=Mf)continue;const c=a+1<s.length?s[a+1]-Ase:1;s[a]=Math.max(s[a],Math.min(c,s[a]*(Mf/i)*1.02))}return s}const Ro=(e,t)=>e.x0<t.x1&&t.x0<e.x1&&e.y0<t.y1&&t.y0<e.y1,cy={h:16,ch:6.1,maxW:100};function Zse(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 tD(e,t,n,s,a,o){const i=t==="loose"?Ise:Lse,c=!a||e.kind==="asks",d=c?Ose:cy.h,h=a?cy.ch:Dse,f=c?o.length:0,p=Math.min(a?cy.maxW:Pse,Math.max(2*i,sD(e).length*h,f*Fse)),m={x0:n-i,y0:s-i,x1:n+i,y1:s+i},w=eD(n,s)==="top"?{x0:n-p/2,y0:s-i-bh-d,x1:n+p/2,y1:s-i-bh}:{x0:n-p/2,y0:s+i+bh,x1:n+p/2,y1:s+i+bh+d};return[m,w]}const G0=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]},kh=(e,t)=>((e-t)%360+540)%360-180;function UT(e,t,n){const s=new Map;for(const f of e)s.has(f.ring)||s.set(f.ring,[]),s.get(f.ring).push(f);const a=()=>e.map(f=>{const[p,m]=G0(f);return tD(f.row,f.tier,p,m,t,f.caption)}),o=(f,p,m=!1)=>{if(f.count<=2&&!m)return!1;const w=f.theta+p*qse,j=s.get(f.ring),v=(f.count>2?360/f.count:f.turn)*Wse,b=j[(f.index+1)%f.count],k=j[(f.index-1+f.count)%f.count];return!(b===f||(p>0?kh(b.theta,w)>=v:kh(w,k.theta)>=v))||w<f.lo||w>f.hi?!1:(f.theta=w,!0)},i=([f,p],[m,w])=>Ro(p,m)||Ro(w,f)||Ro(p,w)||Ro(f,m),c=([f,p])=>Ro(f,n)||Ro(p,n);for(let f=0;f<Use;f++){const p=a();let m=!1;for(let w=0;w<e.length;w++){c(p[w])&&(m=o(e[w],kh(e[w].theta,90)>=0?1:-1,!0)||m);for(let j=w+1;j<e.length;j++){if(!i(p[w],p[j]))continue;const v=e[w],b=e[j],k=b.ring.ring>v.ring.ring||b.ring===v.ring&&j>w?b:v,N=k===b?v:b,S=kh(k.theta,N.theta)>=0?1:-1;m=o(k,S)||o(N,-S)||m}}if(!m)break}const d=a();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 Jse={online:0,offline:1,loose:1};function Qse(e,t,n,s="",a=Bse){const o=[];for(const i of[!0,!1]){const c=WT(e,t,n,s,_se,a,i);if(c.clashes===0)return c.named();if(o.push(c),c.layout.rings.length===3){const d=WT(e,t,n,s,Jse,a,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 WT(e,t,n,s,a,o,i=!0){const c=new Map;for(const B of e){const M=Cse(B);if(!M)continue;const q=a[M];c.has(q)||c.set(q,[]),c.get(q).push({row:B,tier:M})}const d=[...c.keys()].sort((B,M)=>B-M),h=Math.max(0,t/2-Ese),f=Math.max(0,n/2-Tse),p=Xse(d.map(B=>c.get(B).length),h,f),m=d.map((B,M)=>({ring:B,rx:h*p[M],ry:f*p[M],count:c.get(B).length})),w=m.reduce((B,M)=>B+M.count,0),j=B=>B.row.via==="tailscale",v=[...c.values()].flat().filter(j).length,b=Math.max(0,...m.map(B=>{const M=c.get(B.ring).filter(j).length,q=V0(B.rx,B.ry);return M>0&&q>0?M*Mf*Vse/q*360:0})),k=i&&v>0&&v<w?Math.min(zse,Math.max(Hse,v/w*360,b)):0,N=LT-k/2,S=LT+k/2,_=[];let E=!1;m.forEach((B,M)=>{const q=Yse(c.get(B.ring)),$=q.length,K=$>1&&V0(B.rx,B.ry)/$<Mf;K&&(E=!0);const G=M===m.length-1,z=G?-BT*(p[M]-(p[M-1]??0)):BT*(p[M+1]-p[M]),W=k>0?[{members:q.filter(H=>H.row.via!=="tailscale"),from:S,width:360-k},{members:q.filter(H=>H.row.via==="tailscale"),from:N+360,width:k}]:[{members:q,from:null,width:360}];let D=0;for(const H of W){const ee=H.members.length;if(ee===0)continue;const F=H.width/ee,Y=ee>2;H.members.forEach(({row:X,tier:Z},J)=>{const ne=Ds(X),ce=H.from==null?Kse(ee,M)+F*J:H.from+F*(J+.5),he=Y?qT(ne,1)*Mse*F:0,le=K&&D%2===1?1+z/p[M]:1,re=Y?qT(ne,2)*$se:0,ae=F*.3;_.push({row:X,tier:Z,ring:B,index:D,count:$,theta:ce+he,reach:le*(1+(G?-Math.abs(re):re)),lo:H.from==null?-1/0:H.from+ae,hi:H.from==null?1/0:H.from+H.width-ae,turn:F,caption:o(X)}),D++})}});const I=Zse(s);let A=UT(_,E,I);A>0&&!E&&(E=!0,A=UT(_,!0,I));const O=_.map((B,M)=>{const[q,$]=G0(B);return{row:B.row,tier:B.tier,ring:B.ring.ring,x:q,y:$,angle:ere(Math.atan2($,q)*180/Math.PI),dist:Math.hypot(q,$),side:eD(q,$),order:M}}),L=m.reduce((B,M,q)=>c.get(M.ring).some(j)?Math.max(B,p[q]):B,0),U=B=>({from:N,to:S,inner:{rx:h*IT,ry:f*IT},outer:{rx:Math.min(t/2-8,h*L+B),ry:Math.min(n/2-8,f*L+B)},count:v}),P={nodes:O,rings:m,dense:E,zone:k>0?{...U(OT),labelAt:null}:null};return{layout:P,clashes:A,named:()=>{if(!P.zone)return P;const B=_.flatMap($=>{const[K,G]=G0($);return tD($.row,$.tier,K,G,E,$.caption)});let M={...P.zone,labelAt:HT(P.zone,B)},q=M.outer;for(let $=OT+PT;M.labelAt==null;$+=PT){const K=U($);if(K.outer.rx===q.rx&&K.outer.ry===q.ry)break;q=K.outer;const G=HT(K,B);G!=null&&(M={...K,labelAt:G})}return{...P,zone:M}}}}function nD(e){return`Tailscale · ${e} deck${e===1?"":"s"}`}function HT(e,t){const n={rx:e.outer.rx-$f,ry:e.outer.ry-$f};if(!(n.rx>0&&n.ry>0))return null;const s=Math.min(.5,2/Math.max(n.rx,n.ry)*(180/Math.PI)),a=[];for(let N=e.to;N>=e.from;N-=s){const S=N*Math.PI/180;a.push([Math.cos(S)*n.rx,Math.sin(S)*n.ry])}const o=DT+Mc,i={x0:Math.min(...a.map(N=>N[0]))-o,x1:Math.max(...a.map(N=>N[0]))+o,y0:Math.min(...a.map(N=>N[1]))-o,y1:Math.max(...a.map(N=>N[1]))+o},c=t.map(N=>({x0:N.x0-Mc,y0:N.y0-Mc,x1:N.x1+Mc,y1:N.y1+Mc})).filter(N=>Ro(N,i)),d=(N,S)=>c.some(_=>N>_.x0&&N<_.x1&&S>_.y0&&S<_.y1),h=[],f=[];let p=0;a.forEach(([N,S],_)=>{_>0&&(p+=Math.hypot(N-a[_-1][0],S-a[_-1][1]));const E=Math.hypot(N,S)||1;let I=!1;for(let A=0;A<=DT&&!I;A+=1.75)I=d(N-N/E*A,S-S/E*A);h.push(p),f.push((f.at(-1)??0)+(I?1:0))});const m=nD(e.count).length*Gse/2,w=m+FT,j=p-m-FT;if(!(p>0)||j<w)return null;const v=N=>{let S=0,_=h.length;for(;S<_;){const E=S+_>>1;h[E]<N?S=E+1:_=E}return S},b=N=>{const S=v(N-m),_=v(N+m+1e-9)-1;return _<S||f[_]-(S>0?f[S-1]:0)===0},k=p/2;for(let N=0;k-N>=w;N+=2)for(const S of N===0?[k]:[k-N,k+N])if(b(S))return S/p;return null}function ere(e){return(e%360+360)%360}function tre(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 nre(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 Ij(e,t){switch(e.kind){case"asks":return"wants to pair";case"nearby":return e.state;case"dialling":return rD(e)?`${e.name.slice(e.addr.length)} · dialling`:"dialling";case"declined":return"declined";case"paired":{if(e.here)return t?sre(t):"online";const n=oD(e);return n?n==="now"?"away · just now":`away · ${n}`:e.state.startsWith("one-way")?"has not called yet":"away"}}}function sD(e){return rD(e)?e.addr:e.name}function rD(e){return e.kind==="dialling"&&!!e.addr&&e.name.startsWith(`${e.addr}:`)}function aD(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=oD(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 oD(e){var t;return((t=/last online (.+)$/.exec(e.state))==null?void 0:t[1])??null}function sre(e){return e.trim().split(/\s+/).slice(0,2).join(" ")}function rre(e){var s;if(!e)return[];const t=(e.addrs??[]).map(a=>`${a}:${e.port}`),n=(s=e.tailscale)==null?void 0:s.addr;return n&&!(e.addrs??[]).includes(n)&&t.push(`${n}:${e.port}`),t}function Ds(e){let t=e.fp;for(const n of e.twins??[])n.fp<t&&(t=n.fp);return t}function are(e,t){if(e==null)return t;const n=((t-e)%360+540)%360-180;return e+n}function ore(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} ${iD}`:e.nearby===1?`${n} Open it to ask to pair.`:`${n} Open one to ask to pair.`}return null}const iD="This deck pairs by invite only. Send one from Add a deck.";function ire(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"?iD:"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 lre(e){const t={bad:0,wait:1,idle:2,ok:3};return e.map((n,s)=>({l:n,i:s})).sort((n,s)=>t[n.l.tone]-t[s.l.tone]||n.i-s.i).map(({l:n})=>n)}function cre(e){const t=e.length,n=e.filter(s=>s.tone==="ok").length;return t===0?"No shared logins":n===t?`${t} shared login${t===1?", fine":"s, all fine"}`:`${t} shared login${t===1?"":"s"} · ${n} fine`}function ure(e,t){const n=/^(\d+)\.(\d+)\.(\d+)/.exec(e??""),s=/^(\d+)\.(\d+)\.(\d+)/.exec(t??"");if(!n||!s)return null;for(let a=1;a<=3;a++){const o=Number(n[a])-Number(s[a]);if(o)return Math.sign(o)}return 0}function dre(e,t){const n=t?t.alive?t.shareable===!1?t.inUse?"in use here":"cannot share here":"works here":"expired here":"not on this deck";if(e.alive&&e.shareable===!1)return{there:e.inUse?"in use there":"cannot share there",here:n,note:null,tone:e.inUse&&(t!=null&&t.alive)?"ok":"idle"};if(!e.alive){const s=t&&!t.alive?"neither copy works — sign in again here":null;return{there:"broken there",here:n,note:s,tone:s?"bad":"idle"}}return t?t.alive?{there:"works there",here:n,note:null,tone:t.shareable===!1&&!t.inUse?"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 hre(e,t,n,s=null){var d;const a=new Map;for(const h of t)(d=a.get(h.key))!=null&&d.alive||a.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=a.get(h.key)??null,p=o.has(h.key),m=dre(h,f),w=f?f.alive?f.shareable===!1?f.inUse?"inUse":"unavailable":"works":"expired":"missing",j=!h.alive&&f&&!f.alive?m.note:[w==="works"?null:m.here,h.alive&&h.shareable!==!1?null:m.there,m.note].filter(Boolean).join(" · ")||null;i.push({key:h.key,email:h.email,here:w,there:h.alive?h.shareable===!1?h.inUse?"inUse":"unavailable":"works":"broken",in:!h.alive||h.shareable===!1?"cut":m.tone==="wait"?"wait":"live",out:p&&f?f.alive&&f.shareable!==!1?"live":"cut":null,caption:j,tone:m.tone,usedThere:s===h.key})}for(const h of n){const f=a.get(h);!f||c.has(h)||(c.add(h),i.push({key:h,email:f.email,here:f.alive?f.shareable===!1?f.inUse?"inUse":"unavailable":"works":"expired",there:"unknown",in:null,out:f.alive&&f.shareable!==!1?"live":"cut",caption:f.alive?f.shareable===!1?f.inUse?"in use here":"cannot share here":null:"expired here",tone:f.alive?f.shareable===!1&&!f.inUse?"idle":"ok":"bad",usedThere:!1}))}return i}const fre=1e3;function pre(e,t){const n=new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),s=xr(e,t);return`${n} · ${s==="now"?"just now":s}`}function K0(e){return e&&[e.version,e.os,e.arch].filter(Boolean).join(" · ")||null}const lD={works:"works here",expired:"expired here",missing:"not on this deck",unavailable:"cannot share here",inUse:"in use here"},cD={works:"works there",broken:"broken there",unavailable:"cannot share there",unknown:"not offered by that deck",inUse:"in use there"};function uD(e){const t=e.in&&e.out?"offered both ways":e.in?"offered by that deck":"offered by this deck",n=e.usedThere&&e.there!=="inUse"?", in use there":"";return`${lD[e.here]}, ${cD[e.there]}, ${t}${n}.`}function dD({row:e,source:t,status:n,accounts:s,now:a}){var Z,J,ne,ce,he;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,m=(o==null?void 0:o.about)??null,w=((Z=n.about)==null?void 0:Z.version)??null,j=c?o!=null&&o.waiting?o.lastSeen!=null?"not said — it runs an older version":"not said yet — it says when it next calls":o!=null&&o.offers?"not said — it runs an older version":"not reached yet":"shown once paired",v=K0(n.about),b=K0(m),k=m!=null&&m.version&&w?ure(m.version,w):null,N=o?kp(o.last,a):null,S=o&&((J=o.last)!=null&&J.error)?Uee({error:o.last.error,host:o.addr,port:o.port},[...n.strangers??[],...n.pending??[],...(n.peers??[]).filter(le=>!le.manual&&le.addr).map(le=>({fp:le.fp,name:le.name,addr:le.addr,port:le.port,at:le.lastSeen??0}))],a):null,_=(ne=o==null?void 0:o.last)!=null&&ne.error&&N&&N.text!==o.last.error?o.last.error:null,E=((ce=o==null?void 0:o.last)==null?void 0:ce.done)??[],I=!!N&&!!_&&!e.quiet&&e.state.startsWith(N.text),A=c||e.kind==="dialling",O=((o==null?void 0:o.via)??e.via)==="tailscale",L=o?o.waiting?null:o.manual?O?"added by its Tailscale address":"added by address":O?"over Tailscale":"on this network":e.kind==="nearby"?O?"heard over Tailscale":"heard on this network":O?"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,T=U==="up"?(P==null?void 0:P.current)??null:null,B=T&&"key"in T?T.key:null,M=!!T&&"hidden"in T,q=!!T&&"other"in T,$=(n.shared??[]).filter(le=>{var re;return!((re=o==null?void 0:o.notOffered)!=null&&re.includes(le))}),K=c?hre((P==null?void 0:P.accounts)??null,s,$,B):[],G=K.filter(le=>le.in==null&&le.out==="cut"&&le.here!=="inUse"),z=K.some(le=>le.in!=null),W=K.some(le=>le.out!=null),D=new Set((n.peers??[]).filter(le=>le.paired).flatMap(le=>le.notOffered??[])),H=K.some(le=>le.out!=null&&D.has(le.key))?"decks you chose":"every paired deck",ee=new Map(E.map(le=>[le.email,le])),F=E.filter(le=>!K.some(re=>re.email===le.email)),Y=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.":(he=o==null?void 0:o.last)!=null&&he.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,X=P&&(o!=null&&o.last)&&o.last.at-P.at>fre?xr(P.at,a):null;return{peer:o,stranger:i,paired:c,own:d,canRename:h,fp:f,where:p,about:m,unsaid:j,hereRuns:v,thereRuns:b,order:k,line:N,silence:S,raw:_,echoed:I,showRound:A,how:L,link:U,hiddenThere:M,otherThere:q,lanes:K,spent:G,taking:z,giving:W,givenTo:H,told:ee,unplaced:F,unknown:Y,stale:X}}function Y0(){return r.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:[r.jsx("rect",{x:"2.5",y:"3",width:"11",height:"7.5",rx:"1.2"}),r.jsx("path",{d:"M1 13h14"})]})}function jh({dir:e}){return r.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:r.jsx("path",{d:e==="out"?"M2.8 1L6 4 2.8 7":"M5.2 1L2 4l3.2 3"})})}function mre({view:e,row:t,status:n,asking:s,drawn:a,onSettings:o}){const{peer:i,paired:c,where:d,about:h,unsaid:f,hereRuns:p,thereRuns:m,order:w,line:j,silence:v,raw:b,echoed:k,showRound:N,how:S,link:_,hiddenThere:E,otherThere:I,lanes:A,spent:O,taking:L,giving:U,givenTo:P,told:T,unplaced:B,unknown:M,stale:q}=e;return r.jsxs("div",{className:"lan-map","data-link":_,"data-asking":s||void 0,"data-bus":A.length>0||void 0,children:[r.jsxs("div",{className:"lan-ends",children:[r.jsxs("p",{className:"lan-end",children:[r.jsx("span",{className:"lan-end-name",children:"This deck"}),p&&r.jsx("span",{className:"lan-end-runs",children:p}),c&&n.shareActive===!1&&r.jsx("span",{className:"lan-end-note",children:"current account hidden"})]}),r.jsxs("p",{className:"lan-end","data-side":"there",children:[r.jsx("span",{className:"lan-end-name",children:t.name}),t.kind!=="dialling"&&r.jsxs("span",{className:"lan-end-runs",children:[m??(h?"not said":f),w?` · ${w<0?"older":"newer"}`:null]}),E&&r.jsx("span",{className:"lan-end-note",children:"current account hidden"}),I&&r.jsx("span",{className:"lan-end-note",children:"on another account"})]})]}),r.jsxs("div",{className:"lan-link",children:[r.jsx(Y0,{}),r.jsxs("span",{className:"lan-span",children:[r.jsxs("span",{className:"lan-wire","aria-hidden":!0,children:[r.jsx("i",{className:"lan-glint","data-dir":"out"}),r.jsx("i",{className:"lan-glint","data-dir":"in"})]}),r.jsx("span",{className:"lan-link-label",children:d?r.jsx("code",{className:"ap-lan-code",children:d}):"none here — it calls this deck"})]}),r.jsx(Y0,{}),(d&&S||N)&&r.jsxs("p",{className:"lan-link-sub",children:[d&&S,d&&S&&N&&" · ",N&&(j?k?r.jsx("code",{className:"ap-lan-code",children:b}):r.jsx("span",{className:"lan-round","data-tone":j.tone,children:j.text.replace(/ · now$/," · just now")}):"not asked yet"),N&&b&&!k&&r.jsx("code",{className:"lan-fact-raw",children:b})]}),B.length>0&&r.jsx("ul",{className:"lan-done",children:B.map($=>{const K=F0($);return r.jsxs("li",{"data-ok":$.ok&&!K,children:[$.email," ",r.jsxs("span",{className:"lan-done-what",children:[$.ok?"arrived":"did not arrive",K&&` — ${K.long}`]})]},`${$.email}:${$.action}`)})}),v&&r.jsx("p",{className:"lan-note lan-link-note",children:v}),(i==null?void 0:i.waiting)&&r.jsx("p",{className:"lan-note lan-link-note",children:t.hint}),(j==null?void 0:j.hint)&&r.jsx("p",{className:"lan-note lan-link-note",children:j.hint})]}),A.length>0&&r.jsx("ul",{className:"lan-lanes",role:"list","aria-label":`Logins between this deck and ${t.name}`,children:A.map(($,K)=>{const G=T.get($.email),z=G?F0(G):null,W=$.out==="live"||$.in!=null&&$.in!=="cut";return r.jsxs("li",{role:"listitem",className:"lan-lane","data-tone":$.tone,"data-draw":$.in&&$.out?"both":$.in?"in":"out","data-used-there":$.usedThere||void 0,style:{"--i":K},children:[r.jsx("i",{className:"lan-pip","data-end":"here","data-state":$.here,"aria-hidden":!0}),r.jsxs("span",{className:"lan-track",children:[r.jsxs("span",{className:"lan-wire","data-flow":W?"live":"cut","aria-hidden":!0,children:[($.in==="live"||$.in==="wait")&&r.jsx("i",{className:"lan-glint","data-dir":"in","data-tone":$.in}),$.out==="live"&&r.jsx("i",{className:"lan-glint","data-dir":"out"})]}),$.in&&$.in!=="cut"&&r.jsx(jh,{dir:"in"}),$.out==="live"&&r.jsx(jh,{dir:"out"}),r.jsx("span",{className:"lan-lane-email",children:$.email})]}),r.jsx("i",{className:"lan-pip","data-end":"there","data-state":$.there,"aria-hidden":!0}),r.jsx("span",{className:"vis-hidden",children:uD($)}),($.caption||G)&&r.jsxs("span",{className:"lan-lane-note",children:[$.caption,$.caption&&G&&" · ",G&&r.jsxs("span",{className:"lan-lane-done","data-ok":G.ok&&!z,children:[G.ok?"arrived last round":"did not arrive last round",z&&` — ${z.long}`]})]})]},$.key)})},a),c&&r.jsxs(r.Fragment,{children:[O.length>0&&r.jsxs("p",{className:"lan-spent",children:["Paired decks get nothing from ",O.length===1?O[0].email:"the expired ones"," until you sign in again here."]}),M&&r.jsx("p",{className:"lan-empty",children:M}),q&&r.jsxs("p",{className:"lan-stale",children:["As of ",q==="now"?"just now":q,", when it last answered."]}),r.jsxs("div",{className:"lan-legend",children:[L&&r.jsxs("span",{className:"lan-key",children:[r.jsx("span",{className:"lan-key-wire","data-dir":"in","aria-hidden":!0,children:r.jsx(jh,{dir:"in"})}),"from ",t.name]}),U?r.jsxs("span",{className:"lan-key",children:[r.jsx("span",{className:"lan-key-wire","data-dir":"out","aria-hidden":!0,children:r.jsx(jh,{dir:"out"})}),"from this deck, to ",P]}):r.jsx("span",{className:"lan-key",children:"This deck offers nothing yet."}),r.jsx("button",{type:"button",className:"ap-lan-word lan-legend-act",onClick:o,"aria-label":"Change what this deck offers",children:"change"})]})]})]})}const gre=20,yre=17,zT=34,wre=160,xre=80,vre=200,bre=8,kre=14,jre=10,Nre=.61803398875;function Sre({status:e,rows:t,accounts:n,now:s,covered:a,onOpenDeck:o,onClose:i}){const c=y.useRef(null),d=mt(i,{focusRef:c}),h=yt(i),f=y.useRef(null),[p,m]=y.useState(null),[w,j]=y.useState(!1),v=y.useRef(null);y.useLayoutEffect(()=>{const re=f.current;if(!re)return;let ae=null;const de=()=>{const pe=Math.round(re.clientWidth),me=Math.round(re.clientHeight);ae&&ae.w===pe&&ae.h===me||(ae&&(j(!0),v.current!=null&&window.clearTimeout(v.current),v.current=window.setTimeout(()=>j(!1),vre)),ae={w:pe,h:me},m(ae))};if(de(),typeof ResizeObserver>"u")return;const Se=new ResizeObserver(de);return Se.observe(re),()=>{Se.disconnect(),v.current!=null&&window.clearTimeout(v.current)}},[]);const b=y.useMemo(()=>p?Qse(t,p.w,p.h,(e==null?void 0:e.name)??"",re=>{var ae,de;return Ij(re,(de=(ae=Cu(e,re).peer)==null?void 0:ae.about)==null?void 0:de.os)}):null,[t,p,e]),k=y.useMemo(()=>tre(t),[t]),N=(b==null?void 0:b.nodes)??[],S=y.useRef(new Map),_=y.useMemo(()=>{const re=new Map;for(const ae of N){const de=Ds(ae.row);re.set(de,are(S.current.get(de),ae.angle))}return S.current=re,re},[N]),[E,I]=y.useState(null),[A,O]=y.useState(null),[L,U]=y.useState("none"),P=y.useRef(null),T=y.useCallback((re,ae)=>{P.current!==re&&(P.current=re,U(ae),O(re))},[]),B=y.useRef(null),M=y.useRef(null),q=y.useCallback(()=>{M.current!=null&&window.clearTimeout(M.current),M.current=null},[]),$=y.useCallback((re,ae)=>{if(B.current!=null&&window.clearTimeout(B.current),B.current=null,q(),I(re),ae==="keyboard"){T(re,"none");return}M.current=window.setTimeout(()=>T(re,P.current?"swap":"full"),xre)},[T,q]),K=y.useCallback(()=>{B.current!=null&&window.clearTimeout(B.current),q(),B.current=window.setTimeout(()=>I(null),wre)},[q]);y.useEffect(()=>()=>{B.current!=null&&window.clearTimeout(B.current),q()},[q]);const G=E&&N.some(re=>Ds(re.row)===E)?E:null,z=A?t.find(re=>Ds(re)===A)??null:null;y.useEffect(()=>{A&&!z&&T(null,"swap")},[A,z,T]);const[W,D]=y.useState(null),H=y.useRef(new Map),ee=N.findIndex(re=>Ds(re.row)===W),F=ee<0?0:ee,Y=re=>{var pe;if(N.length===0)return;const ae=re.key==="ArrowRight"||re.key==="ArrowDown"?1:re.key==="ArrowLeft"||re.key==="ArrowUp"?-1:0,de=re.key==="Home"?0:re.key==="End"?N.length-1:ae?(F+ae+N.length)%N.length:null;if(de==null)return;re.preventDefault();const Se=Ds(N[de].row);D(Se),(pe=H.current.get(Se))==null||pe.focus()},[X,Z]=y.useState(()=>typeof document<"u"&&document.hidden);y.useEffect(()=>{const re=()=>Z(document.hidden);return document.addEventListener("visibilitychange",re),()=>document.removeEventListener("visibilitychange",re)},[]);const J=(e==null?void 0:e.enabled)===!0,ne=e?J?nre(k):"Local network is off":"checking…",ce=()=>{q(),T(null,"swap"),I(null)},he=G?N.find(re=>Ds(re.row)===G)??null:null,le=()=>{var re;A&&((re=H.current.get(A))==null||re.focus()),ce()};return vt.createPortal(r.jsx("div",{className:"modal-backdrop",...h,role:"presentation",children:r.jsxs("div",{ref:d,className:"modal nm-modal",onClick:re=>re.stopPropagation(),"data-paused":a||X||void 0,role:"dialog","aria-modal":"true","aria-labelledby":"nm-title","aria-describedby":"nm-sub",children:[r.jsxs("header",{className:"modal-head nm-head",children:[r.jsxs("div",{className:"nm-heading",children:[r.jsx("h2",{id:"nm-title",className:"modal-title nm-title",children:"Network map"}),r.jsx("p",{id:"nm-sub",className:"nm-sub",children:ne})]}),r.jsx("div",{className:"modal-actions",children:r.jsx("button",{ref:c,type:"button",className:"glyph-btn",onClick:i,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),r.jsxs("div",{className:"nm-body",children:[r.jsxs("div",{className:"nm-view",children:[r.jsx("div",{ref:f,className:"nm-stage","data-focus":G?"":void 0,"data-focus-via":he==null?void 0:he.row.via,"data-dense":(b==null?void 0:b.dense)||void 0,"data-still":w||void 0,onClick:re=>{re.target===re.currentTarget&&ce()},children:p&&b&&r.jsxs(r.Fragment,{children:[r.jsx(_re,{layout:b,w:p.w,h:p.h}),N.map(re=>{const ae=Ds(re.row);return r.jsx(Tre,{node:re,angle:_.get(ae)??re.angle,lit:G===ae},ae)}),r.jsx(Rre,{status:e}),r.jsx("span",{id:"nm-ring-hint",className:"vis-hidden",children:"Arrow keys move between decks. Enter opens the deck's own dialog."}),r.jsx("div",{className:"nm-ring",role:"group","aria-label":`Decks around this deck, ${N.length}`,"aria-describedby":"nm-ring-hint",onKeyDown:Y,children:N.map((re,ae)=>{var Se,pe;const de=Ds(re.row);return r.jsx(Are,{node:re,angle:_.get(de)??re.angle,os:(pe=(Se=Cu(e,re.row).peer)==null?void 0:Se.about)==null?void 0:pe.os,lit:G===de,shown:A===de,tabbable:ae===F,register:me=>{me?H.current.set(de,me):H.current.delete(de)},onHold:me=>{D(de),$(de,me)},onRelease:K,onOpen:()=>o(re.row.fp)},de)})}),N.length===0&&r.jsx(Mre,{status:e})]})}),r.jsx($re,{slice:(b==null?void 0:b.zone)!=null})]}),r.jsx("aside",{className:"nm-side","aria-label":"Details",children:z&&e?r.jsx(Ire,{row:z,status:e,accounts:n,now:s,entrance:L,onOpen:()=>o(z.fp),onBack:le},Ds(z)):r.jsx(Lre,{status:e,summary:k,entrance:L,slice:(b==null?void 0:b.zone)!=null})})]})]})}),document.body)}function hD(){return r.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:[r.jsx("circle",{cx:"7",cy:"7.4",r:"1.8"}),r.jsx("circle",{cx:"2.4",cy:"2.9",r:"1.2"}),r.jsx("circle",{cx:"11.6",cy:"2.9",r:"1.2"}),r.jsx("circle",{cx:"7",cy:"12.4",r:"1.1"}),r.jsx("path",{d:"M5.7 6.1 3.3 3.8M8.3 6.1l2.4-2.3M7 9.2v2.1"})]})}function _re({layout:e,w:t,h:n}){const{zone:s}=e;return r.jsxs("svg",{className:"nm-orbits",width:t,height:n,viewBox:`0 0 ${t} ${n}`,"aria-hidden":!0,children:[s&&r.jsxs(r.Fragment,{children:[r.jsxs("defs",{children:[r.jsx("path",{id:"nm-zone-arc",d:Ere(s,t/2,n/2)}),r.jsxs("radialGradient",{id:"nm-zone-fill",gradientUnits:"userSpaceOnUse",cx:t/2,cy:n/2,r:Math.max(s.outer.rx,s.outer.ry),children:[r.jsx("stop",{className:"nm-zone-stop",offset:"0.2","data-at":"in"}),r.jsx("stop",{className:"nm-zone-stop",offset:"0.5","data-at":"mid"}),r.jsx("stop",{className:"nm-zone-stop",offset:"1","data-at":"out"})]})]}),r.jsx("path",{className:"nm-zone",d:Cre(s,t/2,n/2),fill:"url(#nm-zone-fill)"}),s.labelAt!=null&&r.jsx("text",{className:"nm-zone-label",children:r.jsx("textPath",{href:"#nm-zone-arc",startOffset:`${(s.labelAt*100).toFixed(2)}%`,textAnchor:"middle",children:nD(s.count)})})]}),e.rings.map((a,o)=>r.jsx("ellipse",{className:"nm-orbit","data-ring":a.ring,"data-folded":e.folded&&a.ring===1||void 0,cx:t/2,cy:n/2,rx:a.rx,ry:a.ry,style:{"--ring":o}},a.ring))]})}function VT(e,t,n,s){const a=s*Math.PI/180;return`${(t+Math.cos(a)*e.rx).toFixed(1)},${(n+Math.sin(a)*e.ry).toFixed(1)}`}function Cre(e,t,n){const s=e.to-e.from>180?1:0,a=(k,N)=>{const S=N*Math.PI/180;return[t+Math.cos(S)*k.rx,n+Math.sin(S)*k.ry]},o=(k,N)=>N/((k.rx+k.ry)/2)*(180/Math.PI),i=(k,N,S)=>{const _=Math.hypot(N[0]-k[0],N[1]-k[1])||1,E=Math.min(.5,S/_);return[k[0]+(N[0]-k[0])*E,k[1]+(N[1]-k[1])*E]},c=([k,N])=>`${k.toFixed(1)},${N.toFixed(1)}`,d=jre,h=kre,f=o(e.inner,d),p=o(e.outer,h),m=a(e.inner,e.from),w=a(e.outer,e.from),j=a(e.outer,e.to),v=a(e.inner,e.to),b=k=>`${k.rx.toFixed(1)},${k.ry.toFixed(1)}`;return[`M${c(a(e.inner,e.from+f))}`,`Q${c(m)} ${c(i(m,w,d))}`,`L${c(i(w,m,h))}`,`Q${c(w)} ${c(a(e.outer,e.from+p))}`,`A${b(e.outer)} 0 ${s} 1 ${c(a(e.outer,e.to-p))}`,`Q${c(j)} ${c(i(j,v,h))}`,`L${c(i(v,j,d))}`,`Q${c(v)} ${c(a(e.inner,e.to-f))}`,`A${b(e.inner)} 0 ${s} 0 ${c(a(e.inner,e.from+f))}`,"Z"].join(" ")}function Ere(e,t,n){const s={rx:e.outer.rx-$f,ry:e.outer.ry-$f},a=e.to-e.from>180?1:0;return`M${VT(s,t,n,e.to)} A${s.rx.toFixed(1)},${s.ry.toFixed(1)} 0 ${a} 0 ${VT(s,t,n,e.from)}`}function Tre({node:e,angle:t,lit:n}){const s=e.row.kind==="paired"&&e.row.here,a=e.order*Nre%1*bre;return r.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":`${zT}px`,"--gap":`${zT+(e.tier==="loose"?yre:gre)}px`,"--i":e.order,"--phase":`${a.toFixed(2)}s`},children:s&&r.jsx("i",{className:"nm-glint"})})}function Rre({status:e}){const t=(e==null?void 0:e.enabled)===!0&&e.running;return r.jsxs("div",{className:"nm-core","data-listening":t||void 0,children:[r.jsx("span",{className:"nm-core-orb","aria-hidden":!0}),r.jsxs("span",{className:"nm-core-label",children:[r.jsx("span",{className:"nm-core-name",children:(e==null?void 0:e.name)??"…"}),r.jsx("span",{className:"nm-core-what",children:"this deck"})]})]})}function Are({node:e,angle:t,os:n,lit:s,shown:a,tabbable:o,register:i,onHold:c,onRelease:d,onOpen:h}){const{row:f}=e,p=`nm-d-${Ore(Ds(f))}`,m=e.angle*Math.PI/180,w=Ij(f,n);return r.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":s||void 0,"data-shown":a||void 0,"aria-label":`${f.name}: ${aD(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(m)*14).toFixed(1)}px`,"--in-y":`${(-Math.sin(m)*14).toFixed(1)}px`},onPointerEnter:j=>{j.pointerType==="mouse"&&c("pointer")},onPointerLeave:d,onFocus:j=>c(j.currentTarget.matches(":focus-visible")?"keyboard":"pointer"),onBlur:d,onClick:h,children:[r.jsx("i",{className:"nm-halo","data-tier":e.tier,"aria-hidden":!0}),f.kind==="dialling"?r.jsx("i",{className:"nm-addr-dot","aria-hidden":!0}):r.jsx(Y0,{}),e.tier!=="online"&&r.jsx("i",{className:"nm-mark","data-tier":e.tier,"data-kind":f.kind,"aria-hidden":!0}),r.jsxs("span",{className:"nm-label","aria-hidden":!0,children:[r.jsx("span",{className:"nm-name",children:sD(f)}),r.jsx("span",{className:"nm-cap",children:w})]}),e.tier==="online"&&r.jsx("span",{id:p,className:"vis-hidden",children:w})]})}function Mre({status:e}){const t=(e==null?void 0:e.enabled)===!0;return r.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 $re({slice:e}){return r.jsxs("ul",{className:"nm-legend",children:[r.jsxs("li",{children:[r.jsxs("span",{className:"nm-key","aria-hidden":!0,children:[r.jsx("i",{className:"nm-key-wire","data-tier":"online"}),r.jsx("i",{className:"nm-key-mark","data-tier":"online"})]}),"online"]}),r.jsxs("li",{children:[r.jsxs("span",{className:"nm-key","aria-hidden":!0,children:[r.jsx("i",{className:"nm-key-wire","data-tier":"offline"}),r.jsx("i",{className:"nm-key-mark","data-tier":"offline"})]}),"away"]}),r.jsxs("li",{children:[r.jsxs("span",{className:"nm-key","aria-hidden":!0,children:[r.jsx("i",{className:"nm-key-wire","data-tier":"loose"}),r.jsx("i",{className:"nm-key-mark","data-tier":"loose"})]}),"not paired"]}),e&&r.jsxs("li",{children:[r.jsx("i",{className:"nm-key-zone","aria-hidden":!0}),"over Tailscale"]})]})}function fD({facts:e}){return r.jsx("dl",{className:"lan-facts nm-facts",children:e.map(t=>r.jsxs("div",{className:"lan-fact","data-tone":t.quiet?"quiet":void 0,children:[r.jsx("dt",{children:t.label}),r.jsx("dd",{children:t.value})]},t.label))})}function Lre({status:e,summary:t,entrance:n,slice:s}){const a=rre(e),o=K0(e==null?void 0:e.about),i=[];o&&i.push({label:"Runs",value:o}),i.push({label:a.length>1?"Addresses":"Address",value:a.length?r.jsx("span",{className:"nm-addrs",children:a.map(h=>r.jsx("code",{className:"ap-lan-code",children:h},h))}):"none yet",quiet:a.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:r.jsx("i",{className:"nm-key-mark","data-tier":"online","aria-hidden":!0})},{key:"away",n:t.offline,words:"away",mark:r.jsx("i",{className:"nm-key-mark","data-tier":"offline","aria-hidden":!0})},{key:"asks",n:t.asks,words:"asking to pair",mark:r.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:r.jsx("i",{className:"nm-key-mark","data-tier":"loose","aria-hidden":!0})},{key:"dialling",n:t.dialling,words:"still dialling",mark:r.jsx("i",{className:"nm-key-mark","data-tier":"loose","aria-hidden":!0})},{key:"declined",n:t.declined,words:"declined, not drawn",mark:r.jsx("i",{"aria-hidden":!0})}],d=ore(t,e==null?void 0:e.pairingMode);return r.jsxs("div",{className:"nm-panel","data-view":"network","data-entrance":n,children:[r.jsx("h3",{className:"nm-panel-name",children:(e==null?void 0:e.name)??"…"}),r.jsx("p",{className:"nm-panel-self",children:"this deck, at the centre of the map"}),r.jsx("ul",{className:"nm-counts",children:c.filter(h=>h.n>0).map(h=>r.jsxs("li",{"data-count":h.key,children:[h.mark,r.jsx("span",{className:"nm-count-n",children:h.n}),r.jsx("span",{className:"nm-count-words",children:h.words})]},h.key))}),t.tailnet>0&&r.jsxs("p",{className:"nm-counts-note",children:[t.tailnet," reached over Tailscale",s?" — the shaded slice, lower right":""]}),d&&r.jsx("p",{className:"nm-next",children:d}),r.jsx(fD,{facts:i}),r.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 Ire({row:e,status:t,accounts:n,now:s,entrance:a,onOpen:o,onBack:i}){var v;const c=dD({row:e,source:Cu(t,e),status:t,accounts:n,now:s}),d=[];c.where&&d.push({label:"Address",value:r.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=ire(e,t.pairingMode),p=lre(c.lanes),m=p.length,w=cre(p),j=c.unknown&&((v=c.peer)!=null&&v.waiting)&&!c.peer.offers?"Its side is not known until it next calls.":c.unknown;return r.jsxs("div",{className:"nm-panel","data-view":"deck","data-entrance":a,"data-tier":e.kind==="paired"?e.here?"online":"offline":"loose",children:[r.jsxs("button",{type:"button",className:"ap-lan-word nm-back",onClick:i,children:[r.jsx("span",{"aria-hidden":!0,children:"‹ "}),"the whole network"]}),r.jsxs("div",{className:"nm-panel-head",children:[r.jsxs("h3",{className:"nm-panel-name",children:[r.jsx("i",{className:h?"ap-pulse":"ap-dot","data-kind":e.kind,"aria-hidden":!0}),r.jsx("span",{className:"nm-panel-title",children:e.name})]}),r.jsx("button",{type:"button",className:"btn nm-open",onClick:o,"aria-label":`Open ${e.name}`,children:"Open"})]}),e.self&&r.jsxs("p",{className:"nm-panel-self",children:["calls itself ",e.self]}),r.jsx("p",{className:"nm-panel-state","data-kind":e.kind,children:aD(e)}),f&&r.jsx("p",{className:"nm-next",children:f}),d.length>0&&r.jsx(fD,{facts:d}),c.paired&&r.jsxs("section",{className:"nm-logins","aria-label":"Logins the two decks share",children:[r.jsx("p",{className:"nm-logins-title",children:w}),m>0&&r.jsx("ul",{className:"nm-lanes",children:p.map((b,k)=>r.jsxs("li",{className:"nm-lane","data-tone":b.tone,style:{"--k":k},children:[r.jsx("i",{className:"nm-lane-dot","aria-hidden":!0}),r.jsx("span",{className:"nm-lane-email","aria-hidden":!0,children:b.email}),GT(b)&&r.jsx("span",{className:"nm-lane-said","aria-hidden":!0,children:GT(b)}),b.usedThere&&r.jsx("span",{className:"nm-lane-used","aria-hidden":!0,children:"in use there"}),r.jsxs("span",{className:"vis-hidden",children:[b.email,": ",uD(b)]})]},b.key))}),j&&r.jsx("p",{className:"nm-panel-hint",children:j})]})]})}function GT(e){return e.caption?e.caption:e.tone==="ok"?null:`${lD[e.here]} · ${cD[e.there]}`}function Ore(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 Pre=6;function Dre({anchorId:e,id:t,rows:n,onHold:s,onLet:a}){const o=y.useRef(null),i=n.filter(m=>m.kind==="paired"),c=i.filter(m=>m.here),d=c.slice(0,Pre),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 m=o.current,w=document.getElementById(e);if(!m||!w)return;m.style.maxHeight="";const j=bj(w.getBoundingClientRect(),{width:m.offsetWidth,height:m.offsetHeight},{width:window.innerWidth,height:window.innerHeight});m.style.top=`${j.top}px`,m.style.left=`${j.left}px`,m.style.maxHeight=j.maxHeight==null?"":`${j.maxHeight}px`,m.dataset.side=j.side},[e]);return y.useLayoutEffect(()=>{p()}),y.useEffect(()=>(window.addEventListener("scroll",p,!0),window.addEventListener("resize",p),()=>{window.removeEventListener("scroll",p,!0),window.removeEventListener("resize",p)}),[p]),vt.createPortal(r.jsxs("div",{ref:o,id:t,className:"ap-peek",role:"tooltip",onPointerEnter:s,onPointerLeave:a,children:[r.jsx("p",{className:"ap-peek-title",children:c.length?"On the network now":"Nobody on the network"}),d.length>0&&r.jsx("div",{className:"ap-peek-list",children:d.map(m=>r.jsxs("span",{className:"ap-peek-who",children:[r.jsx("i",{className:"ap-nav-live","aria-hidden":!0}),r.jsxs("span",{title:m.via==="tailscale"?`${m.name} · Tailscale`:m.name,children:[m.name,m.via==="tailscale"&&r.jsx("span",{className:"ap-lan-via",children:" · Tailscale"})]})]},`${m.kind}:${m.fp}`))}),f&&r.jsx("p",{className:"ap-peek-rest",children:f})]}),document.body)}function Fre({entry:e,rows:t,onOpen:n,onMap:s,peek:a,openPeek:o,shutPeek:i,holdPeek:c,dropPeek:d}){return r.jsxs(r.Fragment,{children:[r.jsxs("button",{type:"button",id:"ap-lan-entry",className:"ap-nav",onClick:()=>{d(),n()},"aria-describedby":a?"ap-lan-peek":void 0,onPointerEnter:h=>{h.pointerType==="mouse"&&o(K4)},onPointerLeave:i,onFocus:h=>{h.target.matches(":focus-visible")&&o(0)},onBlur:i,children:[r.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:[r.jsx("rect",{x:"1.8",y:"2.3",width:"10.4",height:"7.2",rx:"1.2"}),r.jsx("path",{d:"M5 11.9h4M7 9.5v2.4"})]}),r.jsxs("span",{className:"ap-nav-text",children:[r.jsx("span",{className:"ap-nav-name",children:"Local network"}),r.jsxs("span",{className:"ap-nav-state","data-tone":e.tone,children:[e.live&&r.jsx("i",{className:"ap-nav-live","aria-hidden":!0}),e.text]})]}),r.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:r.jsx("path",{d:"M5.6 3.4 9.2 7l-3.6 3.6"})})]}),s&&r.jsx("button",{type:"button",className:"ap-lan-map",onClick:()=>{d(),s()},"aria-label":"Show the network map",title:"Network map — every deck this one knows, drawn around it",children:r.jsx(hD,{})}),a&&r.jsx(Dre,{anchorId:"ap-lan-entry",id:"ap-lan-peek",rows:t,onHold:c,onLet:i})]})}function Bre({row:e,run:t,onVerb:n,onUnpair:s}){const[a,o]=y.useState(!1),i=y.useRef(0),[c,d]=y.useState(null);return y.useEffect(()=>{if(!a)return;const p=window.setTimeout(()=>o(!1),4e3);return()=>window.clearTimeout(p)},[a]),y.useEffect(()=>{if(!c)return;const p=window.setTimeout(()=>d(null),4e3);return()=>window.clearTimeout(p)},[c]),{armed:a,armedTwin:c,pressOwn:()=>{const p=Date.now(),m=jl({armedFor:a?e.fp:null,target:e.fp,armedAt:i.current,now:p,gapMs:kl});if(m==="arm"){o(!0),d(null),i.current=p;return}m!=="ignore"&&(o(!1),t(n))},pressTwin:p=>{if(!s)return;const m=Date.now(),w=jl({armedFor:c,target:p,armedAt:i.current,now:m,gapMs:kl});if(w==="arm"){d(p),o(!1),i.current=m;return}w!=="ignore"&&(d(null),t(()=>s(p)))}}}function qre({row:e,paired:t,peer:n,status:s,busy:a,press:o,checkNow:i,armed:c,pressOwn:d,run:h,onVerb:f,onInvite:p}){return r.jsxs("footer",{className:"lan-peer-foot",children:[e.kind==="asks"&&r.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)&&r.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:a===`check:${e.fp}`?"Checking…":"Check now"}),e.kind==="paired"&&r.jsx("button",{type:"button",className:`btn danger lan-peer-verb${c?" armed":""}`,...o(`unpair:${e.fp}`),onKeyDown:m=>{m.repeat&&m.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:a===`unpair:${e.fp}`?"Unpairing…":c?"Confirm unpair":"Unpair"}),e.kind==="nearby"&&s.pairingMode!=="invite"&&r.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:a===`accept:${e.fp}`?"Asking…":"Ask to pair"}),e.kind==="dialling"&&r.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:a===`drop:${e.fp}`?"Stopping…":"Stop dialling"}),e.kind==="declined"&&s.pairingMode!=="invite"&&r.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:a===`allow:${e.fp}`?"Allowing…":"Let it ask again"}),(e.kind==="nearby"||e.kind==="declined")&&s.pairingMode==="invite"&&p&&r.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 Ure({instances:e,now:t,busy:n,press:s,armedTwin:a,pressTwin:o,onUnpair:i}){return r.jsxs("div",{className:"modal-section",children:[r.jsxs("h3",{className:"lan-h",children:[e.length," decks on this machine"]}),r.jsx("ul",{className:"lan-twins",role:"list",children:e.map((c,d)=>{var j,v,b,k;const h=(j=c.peer)!=null&&j.addr?`${c.peer.addr}:${c.peer.port}`:c.row.addr,f=h||c.row.fp,p=(v=c.peer)!=null&&v.pairedAt?xr(c.peer.pairedAt,t):null,m=[(k=(b=c.peer)==null?void 0:b.about)!=null&&k.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 r.jsxs("li",{role:"listitem",className:"lan-twin","data-tone":c.row.tone,children:[r.jsx("i",{className:c.row.here?"ap-pulse":"ap-dot","aria-hidden":!0}),h?r.jsx("code",{className:"ap-lan-code lan-twin-at",children:h}):r.jsx("span",{className:"lan-twin-at lan-twin-none",children:"no address here"}),r.jsx("code",{className:"ap-lan-code lan-twin-fp",children:w}),d>0&&i&&r.jsx("button",{type:"button",className:`ap-manage-btn danger lan-twin-do${a===w?" armed":""}`,...s(`unpair:${w}`),onKeyDown:N=>{N.repeat&&N.preventDefault()},onClick:()=>o(w),"aria-label":a===w?`Confirm unpairing ${f}`:`Unpair ${f}`,title:a===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…":a===w?"confirm":"unpair"}),r.jsx("span",{className:"lan-twin-meta",children:d===0?`${m} · shown above`:m})]},w)})})]})}function Wre(){return r.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:[r.jsx("path",{d:"M9.6 2.4l2 2L5 11l-2.6.6L3 9z"}),r.jsx("path",{d:"M8.4 3.6l2 2"})]})}function Hre({row:e,source:t,status:n,accounts:s,now:a,busy:o,onClose:i,onRename:c,onCheck:d,onVerb:h,onSettings:f,onInvite:p,twins:m=[],onUnpair:w}){const j=y.useRef(null),v=mt(i,{focusRef:j}),b=yt(i),[k,N]=y.useState(null),[S,_]=y.useState(null),[E,I]=y.useState(!1),[A,O]=y.useState(0),L=y.useRef(null),U=y.useRef(null),P=y.useRef(!0);y.useEffect(()=>()=>{P.current=!1},[]);const T=k!=null;y.useEffect(()=>{var re;T&&((re=L.current)==null||re.select())},[T]);const B=y.useRef(!1);y.useEffect(()=>{var re,ae;B.current&&!T&&Yn(((re=document.activeElement)==null?void 0:re.tagName)??null)&&((ae=U.current)==null||ae.focus()),B.current=T},[T]);const M=re=>{const ae=Ga(o,re);return{disabled:ae.disabled,"aria-busy":ae.busy}},q=async re=>{const ae=await re();return P.current&&_(ae),ae==null},{armed:$,armedTwin:K,pressOwn:G,pressTwin:z}=Bre({row:e,run:q,onVerb:h,onUnpair:w}),W=dD({row:e,source:t,status:n,accounts:s,now:a}),{peer:D,stranger:H,paired:ee,own:F,canRename:Y,fp:X}=W,Z=o===`check:${e.fp}`,J=async re=>{const ae=re.trim()===F?"":re;await q(()=>c(ae))&&N(null)},ne=()=>void q(d).then(re=>{re&&P.current&&O(ae=>ae+1)}),ce=async()=>{if(X)try{if(await navigator.clipboard.writeText(X),!P.current)return;I(!0),window.setTimeout(()=>{P.current&&I(!1)},1600)}catch{P.current&&_("Could not copy it — select the fingerprint and copy it by hand.")}},he=[];ee&&(D!=null&&D.pairedAt)?he.push({label:"Paired",value:pre(D.pairedAt,a),tone:"meta"}):e.kind==="declined"&&H&&he.push({label:"Paired",value:`no · you said no ${Rj(H.at,a)}`,tone:"meta"}),he.push({label:"Fingerprint",value:X?r.jsxs("span",{className:"lan-fp",children:[r.jsx("code",{className:"ap-lan-code",children:X}),r.jsx("button",{type:"button",className:"ap-lan-word lan-copy",onClick:()=>void ce(),"aria-label":E?"Fingerprint copied":"Copy the fingerprint",children:E?"copied":"copy"})]}):"not known — nothing has answered there",tone:X?void 0:"quiet"});const le=m.length?[{row:e,peer:D??null},...m]:[];return vt.createPortal(r.jsx("div",{className:"modal-backdrop",...b,role:"presentation",children:r.jsxs("div",{ref:v,className:"modal lan-peer","data-tone":e.tone,onClick:re=>re.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-peer-title","aria-describedby":"lan-peer-sub",children:[r.jsxs("header",{className:"modal-head lan-peer-head",children:[r.jsx("i",{className:e.here?"ap-pulse":"ap-dot","aria-hidden":!0}),r.jsxs("div",{className:"lan-peer-id",children:[T?r.jsxs("form",{className:"lan-peer-edit",onSubmit:re=>{re.preventDefault(),J(k??"")},children:[r.jsx("span",{id:"lan-peer-title",className:"vis-hidden",children:e.name}),r.jsx("input",{ref:L,className:"ap-manage-input lan-peer-input",value:k??"",maxLength:48,placeholder:F,"aria-label":"Name for this deck, shown on this deck only",onChange:re=>N(re.target.value)}),r.jsx("button",{type:"submit",className:"ap-manage-btn",...M(`alias:${e.fp}`),children:"save"}),r.jsx("button",{type:"button",className:"ap-manage-btn",onClick:()=>N(null),children:"cancel"})]}):r.jsxs("span",{className:"lan-peer-title",children:[r.jsx("span",{id:"lan-peer-title",className:"lan-peer-name",children:e.name}),Y&&r.jsx("button",{type:"button",className:"glyph-btn lan-peer-rename",ref:U,onClick:()=>{_(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:r.jsx(Wre,{})})]}),r.jsxs("p",{id:"lan-peer-sub",className:"lan-peer-sub",children:[e.self&&r.jsxs(r.Fragment,{children:["calls itself ",r.jsx("span",{className:"lan-peer-self",children:e.self}),T&&r.jsx("button",{type:"button",className:"ap-lan-word lan-peer-restore",...M(`alias:${e.fp}`),onClick:()=>void J(""),children:"use this name"}),r.jsx("span",{className:"vis-hidden",children:". "}),!e.quiet&&r.jsx("span",{"aria-hidden":!0,children:" · "})]}),r.jsx("span",{className:e.quiet?"vis-hidden":"lan-peer-state",children:e.state})]})]}),r.jsx("div",{className:"modal-actions",children:r.jsx("button",{ref:j,type:"button",className:"glyph-btn",onClick:i,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),r.jsxs("section",{className:"modal-body lan-peer-body",children:[S&&r.jsxs("div",{className:"ap-failure",role:"alert",children:[r.jsx("span",{className:"ap-failure-text",children:S}),r.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>_(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),r.jsx(mre,{view:W,row:e,status:n,asking:Z,drawn:A,onSettings:f}),r.jsx("dl",{className:"lan-facts",children:he.map(re=>r.jsxs("div",{className:"lan-fact","data-tone":re.tone,children:[r.jsx("dt",{children:re.label}),r.jsx("dd",{children:re.value})]},re.label))}),le.length>1&&r.jsx(Ure,{instances:le,now:a,busy:o,press:M,armedTwin:K,pressTwin:z,onUnpair:w})]}),r.jsx(qre,{row:e,paired:ee,peer:D,status:n,busy:o,press:M,checkNow:ne,armed:$,pressOwn:G,run:q,onVerb:h,onInvite:p})]})}),document.body)}function Xr(e,t){const n=y.useRef(!1);return y.useEffect(()=>{var s,a;!e||!n.current||(n.current=!1,Yn(((s=document.activeElement)==null?void 0:s.tagName)??null)&&(typeof t=="function"?t():(a=t.current)==null||a.focus()))},[e]),()=>{n.current=!0}}function zre(e,t){if(e.length!==t.length)return!1;const n=new Set(e);return t.every(s=>n.has(s))}function Vre(e,t,n,s){const a=new Set(e??t);return s?a.add(n):a.delete(n),[...a]}function KT(e,t,n){return e==null||n!=null&&!n.ok||zre(e,t)?null:e}function pD({line:e,onDismiss:t,onAnswer:n}){const[s,a]=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,a(!0);const p=await Hne();o.current=!1,i.current&&(a(!1),h.current=document.activeElement===c.current,n(Vne(p)))};return r.jsxs("div",{className:e.done?"ap-failure ap-failure-done":"ap-failure",role:"alert",children:[r.jsx("span",{className:"ap-failure-text",children:e.text}),e.giveBack&&r.jsx("button",{ref:c,type:"button",className:"ap-fix ap-give-back","aria-busy":s,onClick:f,title:"Opens macOS's password dialog to make the settings folder yours again",children:s?"waiting for macOS…":"give it back"}),r.jsx("button",{ref:d,type:"button",className:"ap-failure-x",onClick:t,"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]})}function Gre(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 Nh="Paused while this deck pairs only by invite. Turn that off above to use it.";function Kre({status:e,accounts:t,onClose:n,onChanged:s}){en("lan-setup");const a=mt(n),o=yt(n),[i,c]=y.useState(null),[d,h]=y.useState(null),[f,p]=y.useState(!1),[m,w]=y.useState(null),j=y.useRef(null),v=W=>{const D=Ga(m,W);return{disabled:D.disabled,"aria-busy":D.busy}},b=y.useRef(null),k=y.useRef(!0);y.useEffect(()=>()=>{k.current=!1},[]),y.useEffect(()=>{b.current=KT(b.current,e.shared??[],null)},[e.shared]);const N=y.useCallback(async(W,D,H="write")=>{j.current=H,w(H);try{const F=await(await fetch("/api/prefs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({lan:W})})).json().catch(()=>null);return k.current?(F!=null&&F.ok?h(null):h(Fs(Gt(D,F),F)),s(),(F==null?void 0:F.ok)===!0):!1}catch{return k.current&&h(Fs(Gt(D,null))),!1}finally{j.current=null,k.current&&w(null)}},[s]),S=y.useCallback(async W=>{const D=await N({name:W},"save the name","name");return D&&k.current&&c(H=>H===W?null:H),D},[N]),_=y.useRef(null),E=i!=null&&i!==(e.name??""),I=Xr(!E,_),A=y.useCallback(async()=>{E&&!await S(i)||n()},[E,i,S,n]),O=async()=>{if(!e.fp)return;const W=await eo(e.fp);if(k.current){if(!W){h(Fs("Could not copy it — select the fingerprint and copy it by hand."));return}p(!0),window.setTimeout(()=>{k.current&&p(!1)},1600)}},L=new Set(b.current??e.shared??[]),U=e.autoAsk!==!1,P=e.autoAccept!==!1,T=e.pairingMode==="invite",B=W=>{const D=v(W);return{...D,disabled:D.disabled||T}},M=e.shareActive!==!1,q=e.sendInUse===!0,$=e.tailscale??null,K=!!($!=null&&$.on),G=($==null?void 0:$.ask)!==!1,z=($==null?void 0:$.accept)!==!1;return vt.createPortal(r.jsx("div",{className:"modal-backdrop",...o,role:"presentation",children:r.jsxs("div",{ref:a,className:"modal lan-modal",onClick:W=>W.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-modal-title",children:[r.jsxs("header",{className:"modal-head",children:[r.jsx("div",{className:"modal-title",children:r.jsx("span",{id:"lan-modal-title",className:"modal-tool-name",children:"This deck on the network"})}),r.jsx("div",{className:"modal-actions",children:r.jsx("button",{className:"glyph-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),r.jsxs("section",{className:"modal-body",children:[r.jsx(pD,{line:d,onDismiss:()=>h(null),onAnswer:W=>{h(W),W.done&&s()}}),r.jsxs("div",{className:"modal-section",children:[r.jsx("h3",{className:"lan-h",children:"Name"}),r.jsxs("div",{className:"ap-lan-row",children:[r.jsx("span",{className:"ap-lan-label",children:"appear as"}),r.jsx("input",{ref:_,className:"ap-manage-input ap-lan-input","aria-label":"This deck's name on the network",value:i??e.name??"",placeholder:"this machine",onChange:W=>c(W.target.value),onKeyDown:W=>{W.key!=="Enter"||i==null||S(i)}}),E&&r.jsx("button",{type:"button",className:"ap-manage-btn",...v("name"),onClick:()=>{I(),S(i)},title:"Save it. This is the name other decks show for this one.",children:"save"})]}),r.jsxs("div",{className:"ap-lan-row",children:[r.jsx("span",{className:"ap-lan-label",children:"fingerprint"}),e.fp?r.jsxs("span",{className:"lan-fp",children:[r.jsx("code",{className:"ap-lan-code",children:e.fp}),r.jsx("button",{type:"button",className:"ap-lan-word lan-copy",onClick:()=>void O(),"aria-label":f?"Fingerprint copied":"Copy this deck's fingerprint",children:f?"copied":"copy"})]}):r.jsx("span",{className:"ap-lan-label",children:"not known yet"})]})]}),r.jsxs("div",{className:"modal-section",children:[r.jsx("h3",{className:"lan-h",children:"Share these accounts"}),r.jsxs("div",{className:"ap-lan-picks",children:[t.length===0&&r.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(W=>r.jsxs("label",{className:"ap-lan-pick",title:W.alive?W.inUse?"Offer this account to the decks you have paired with. While this deck is on it, it stays here, and it goes out like the others once this deck switches away. Unticking stops it being offered from now on; it does not take back a copy somebody already has.":"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:[r.jsx("input",{type:"checkbox",checked:L.has(W.key),onChange:D=>{const H=Vre(b.current,e.shared??[],W.key,D.target.checked);b.current=H,N({shared:H},D.target.checked?"share that account":"stop sharing that account").then(ee=>{b.current===H&&(b.current=KT(H,e.shared??[],{ok:ee}))})}}),r.jsx("span",{className:"ap-lan-pick-name",children:W.email}),!W.alive&&r.jsx("span",{className:"ap-lan-dead",children:"not working here"}),W.alive&&W.inUse&&L.has(W.key)&&r.jsx("span",{className:"ap-lan-dead",children:"in use here · not sent"})]},W.key))]}),t.length>0&&r.jsxs("div",{className:"lan-switches",children:[r.jsxs("div",{className:"lan-switch",children:[r.jsx("span",{className:"lan-switch-what",children:"Show paired decks which of these this deck is using"}),r.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":M,"aria-label":"Show paired decks which of these this deck is using",...v("current"),onClick:()=>void N({shareActive:!M},M?"stop showing which account this deck is using":"show which account this deck is using","current"),title:M?"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:r.jsx("span",{className:"switch-knob"})})]}),r.jsxs("div",{className:"lan-switch",children:[r.jsxs("span",{className:"lan-switch-what",children:["Send the login this deck is using too",q&&r.jsx("span",{id:"lan-send-in-use-detail",className:"lan-switch-detail",children:"The other machine renews its copy even when idle, and whichever renews it second is signed out."})]}),r.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":q,"aria-label":"Send the login this deck is using too","aria-describedby":q?"lan-send-in-use-detail":void 0,"data-tone":"warn",...v("send-in-use"),onKeyDown:W=>{W.repeat&&W.preventDefault()},onClick:()=>void N({sendInUse:!q},q?"keep the login this deck is using here":"send the login this deck is using","send-in-use"),title:q?"Keep the account this deck is signed in to here while it is. It goes out like the others once this deck switches away.":"Also hand out the account this deck is signed in to right now. Two machines on one login race to renew it, and the one that renews it second is signed out (“Login expired · Please run /login”).",children:r.jsx("span",{className:"switch-knob"})})]})]})]}),r.jsxs("div",{className:"modal-section",children:[r.jsx("h3",{className:"lan-h",id:"lan-pairing-h",children:"Pairing"}),r.jsx("div",{className:"lan-switches lan-switches-lead",role:"group","aria-labelledby":"lan-pairing-h",children:r.jsxs("div",{className:"lan-switch",children:[r.jsxs("span",{className:"lan-switch-what",children:["Pair new decks only by invite",T&&r.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."})]}),r.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":T,"aria-label":"Pair new decks only by invite","aria-describedby":T?"lan-invite-only-detail":void 0,...v("mode"),onKeyDown:W=>{W.repeat&&W.preventDefault()},onClick:()=>void N({pairingMode:T?"automatic":"invite"},T?"let decks pair on their own again":"pair new decks only by invite","mode"),title:T?"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:r.jsx("span",{className:"switch-knob"})})]})}),r.jsxs("div",{className:"lan-auto",role:"group","aria-labelledby":"lan-auto-h",children:[r.jsxs("p",{className:"lan-sub",id:"lan-auto-h",children:["Automatic pairing",T&&r.jsx("span",{className:"lan-sub-state",children:" · paused while pairing is invite-only"})]}),r.jsxs("div",{className:"lan-switches","data-paused":T||void 0,children:[r.jsxs("div",{className:"lan-switch",children:[r.jsx("span",{className:"lan-switch-what",children:"Ask every deck this one finds"}),r.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":U,"aria-label":"Ask every deck this one finds",...B("ask"),onClick:()=>void N({autoAsk:!U},U?"stop asking automatically":"ask every deck this one finds","ask"),title:T?Nh: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:r.jsx("span",{className:"switch-knob"})})]}),r.jsxs("div",{className:"lan-switch",children:[r.jsx("span",{className:"lan-switch-what",children:"Say yes to every deck that asks"}),r.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",...B("accept"),onKeyDown:W=>{W.repeat&&W.preventDefault()},onClick:()=>void N({autoAccept:!P},P?"stop accepting automatically":"accept every deck that asks","accept"),title:T?Nh: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:r.jsx("span",{className:"switch-knob"})})]})]})]})]}),($==null?void 0:$.found)&&r.jsxs("div",{className:"modal-section",children:[r.jsx("h3",{className:"lan-h",children:"Tailscale"}),r.jsxs("div",{className:"lan-switches",children:[r.jsxs("div",{className:"lan-switch",children:[r.jsxs("span",{className:"lan-switch-what",children:["Look for my devices",r.jsx("span",{id:"lan-ts-detail",className:"lan-switch-detail",children:Gre($)})]}),r.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":K,"aria-label":"Look for my devices over Tailscale","aria-describedby":"lan-ts-detail",...v("tailscale"),onClick:()=>void N({tailscale:!K},K?"stop looking over Tailscale":"look for your devices over Tailscale","tailscale"),title:K?"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:r.jsx("span",{className:"switch-knob"})})]}),K&&r.jsxs("div",{className:"lan-auto",role:"group","aria-labelledby":"lan-ts-auto-h",children:[r.jsxs("p",{className:"lan-sub",id:"lan-ts-auto-h",children:["Automatic pairing with my devices",T&&r.jsx("span",{className:"lan-sub-state",children:" · paused while pairing is invite-only"})]}),r.jsxs("div",{className:"lan-switches",children:[r.jsxs("div",{className:"lan-switch","data-paused":T||void 0,children:[r.jsx("span",{className:"lan-switch-what",children:"Ask each device it finds"}),r.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":G,"aria-label":"Ask each of my devices it finds over Tailscale",...B("tailscale-ask"),onClick:()=>void N({tailscaleAsk:!G},G?"stop asking your devices automatically":"ask your devices automatically","tailscale-ask"),title:T?Nh:G?"Stop sending requests on their own. You press ask on the row instead.":"Send a pairing request to every deck found on your devices over Tailscale.",children:r.jsx("span",{className:"switch-knob"})})]}),r.jsxs("div",{className:"lan-switch","data-paused":T||void 0,children:[r.jsx("span",{className:"lan-switch-what",children:"Say yes to each device that asks"}),r.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":z,"aria-label":"Say yes to my devices when they ask over Tailscale","data-tone":"warn",...B("tailscale-accept"),onKeyDown:W=>{W.repeat&&W.preventDefault()},onClick:()=>void N({tailscaleAccept:!z},z?"stop accepting your devices automatically":"accept your devices automatically","tailscale-accept"),title:T?Nh:z?"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:r.jsx("span",{className:"switch-knob"})})]})]})]})]})]})]}),r.jsxs("footer",{className:"lan-setup-foot",children:[r.jsx("span",{className:"lan-foot-note",children:"Changes are saved as you make them."}),r.jsx("button",{type:"button",className:"btn primary",...v("name"),onClick:()=>void A(),children:"Done"})]})]})}),document.body)}function Yre({on:e,status:t,paired:n,busy:s,pressProps:a,checkNow:o,setAddOpen:i,setSetupOpen:c,setMapOpen:d,onBack:h,closeButton:f}){return r.jsxs("div",{className:"ap-header",children:[r.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:r.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:r.jsx("path",{d:"M8.4 3.4 4.8 7l3.6 3.6"})})}),r.jsx("h2",{id:"ap-lan-title",children:"Local network"}),r.jsxs("div",{className:"ap-header-right",children:[e&&r.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:r.jsx(hD,{})}),e&&r.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:r.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:[r.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"}),r.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&&r.jsx("button",{type:"button",className:"glyph-btn ap-lan-check",...a("check"),onClick:()=>void o(),"aria-label":s==="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:r.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:[r.jsx("circle",{cx:"7",cy:"7",r:"1.1",fill:"currentColor",stroke:"none"}),r.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"}),r.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&&r.jsx("button",{type:"button",className:"glyph-btn ap-lan-set",...a("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:r.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":!0,children:[r.jsx("path",{d:"M1.8 4.7h10.4M1.8 9.3h10.4"}),r.jsx("circle",{cx:"9.1",cy:"4.7",r:"1.6",fill:"var(--panel)"}),r.jsx("circle",{cx:"4.9",cy:"9.3",r:"1.6",fill:"var(--panel)"})]})}),f]})]})}function Xre({accounts:e,onChanged:t,onNoCopy:n,onShared:s,view:a,onOpen:o,onBack:i,closeButton:c}){const[d,h]=y.useState(!1),[f,p]=y.useState(!1),[m,w]=y.useState(!1),j=Une(),[v,b]=y.useState(!1),{status:k,manual:N,now:S,busy:_,failure:E,dismissFailure:I,answerGiveBack:A,pressProps:O,load:L,toggle:U,answer:P,dropAddress:T,rename:B,checkOne:M,checkNow:q}=Zne(t,()=>h(!0)),{armed:$,pressUnpair:K}=Jne(P),[G,z]=y.useState(null),[W,D]=y.useState(!1),H=y.useMemo(()=>ste(e,k??null),[e,k]),ee=y.useMemo(()=>H.filter(me=>rte(me.key,k??null,S)).map(me=>me.key).sort().join(`
|
|
103
|
+
`),[H,k,S]);y.useEffect(()=>{n==null||n(ee?ee.split(`
|
|
104
|
+
`):[])},[ee,n]);const F=y.useMemo(()=>JSON.stringify(lte(H,k??null)),[H,k]);y.useEffect(()=>{s==null||s(new Map(JSON.parse(F)))},[F,s]);const Y=(k==null?void 0:k.enabled)===!0,X=y.useMemo(()=>Vee((k==null?void 0:k.pairingMode)==="invite"&&k?{...k,pending:[]}:k,S),[k,S]),Z=G?X.find(me=>{var be;return me.fp===G||((be=me.twins)==null?void 0:be.some(Ce=>Ce.fp===G))})??null:null;y.useEffect(()=>{G&&k&&!Z&&z(null)},[G,k,Z]);const{asks:J,rest:ne,live:ce,folded:he,troubled:le,shown:re,paired:ae}=nte(X,v),de=Wee(k,S),Se=tte(k,X),pe=r.jsxs(r.Fragment,{children:[f&&k&&r.jsx(vse,{status:k,manual:N,startWith:f==="invite"?"invite":void 0,onClose:()=>p(!1),onChanged:()=>{L(),t()}}),m&&r.jsx(Z4,{title:"How Local network works",steps:hse,finish:Y?void 0:{label:"Turn it on",act:()=>{w(!1),U()}},onClose:()=>w(!1)}),d&&k&&r.jsx(Kre,{status:{...k,manualRows:N},accounts:H,manual:N,onClose:()=>h(!1),onChanged:()=>{L(),t()}}),W&&r.jsx(Sre,{status:k,rows:X,accounts:H,now:S,covered:!!Z||d||!!f||m,onOpenDeck:z,onClose:()=>D(!1)}),Z&&k&&r.jsx(Hre,{row:Z,source:Cu(k,Z),status:k,accounts:H,now:S,busy:_,onClose:()=>z(null),onRename:me=>B(Z.fp,me),onCheck:()=>M(Z.fp),onVerb:()=>{switch(Z.kind){case"paired":return P("unpair",Z.fp,"unpair that deck");case"nearby":return P("accept",Z.fp,"reach that deck");case"declined":return P("allow",Z.fp,"let that deck ask again");case"dialling":return T(Z.fp);default:return Promise.resolve(null)}},onSettings:()=>{z(null),h(!0)},onInvite:()=>{z(null),p("invite")},twins:(Z.twins??[]).map(me=>({row:me,peer:Cu(k,me).peer??null})),onUnpair:me=>P("unpair",me,"unpair that deck")})]});return a?r.jsxs("div",{className:"ap-lan-view",children:[r.jsx(Yre,{on:Y,status:k,paired:ae,busy:_,pressProps:O,checkNow:q,setAddOpen:p,setSetupOpen:h,setMapOpen:D,onBack:i,closeButton:c}),r.jsx("div",{className:"ap-scroll",id:"ap-lan-scroll",children:r.jsxs("div",{className:"ap-lan",children:[r.jsxs("div",{className:"ap-policy",children:[r.jsx("h3",{className:"ap-auto-title",children:"Sync with paired decks"}),r.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":Y,"aria-label":"Sync with paired decks",...O("switch"),onClick:()=>void U(),title:Y?"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:r.jsx("span",{className:"switch-knob"})})]}),r.jsx(Sse,{on:Y,status:k}),!Y&&r.jsxs("div",{className:"ap-lan-intro-row",children:[r.jsxs("button",{type:"button",className:"ap-lan-intro",onClick:()=>w(!0),title:"Four pictures: what this does, and what to do on each machine",children:[r.jsx(fse,{}),r.jsx("span",{className:"ap-lan-intro-text",children:"Paired machines repair each other's expired logins."}),r.jsx("span",{className:"ap-lan-intro-go",children:"See how it works"})]}),r.jsx(ku,{film:"localNetwork"})]}),r.jsx("p",{className:`ap-lan-status ${de.tone}`,role:"status",children:de.tone==="ok"?"":de.text}),r.jsx(pD,{line:E,onDismiss:I,onAnswer:A}),Y&&r.jsxs(r.Fragment,{children:[J.length>0&&r.jsx(kse,{asks:J,pressProps:O,answer:P}),re.length>0&&r.jsx(jse,{rows:re,pairingMode:k==null?void 0:k.pairingMode,armed:$,pressProps:O,answer:P,dropAddress:T,onUnpair:K,onOpenPeer:z,onInvite:()=>p("invite")}),(ce.length>0&&he.length>0||Y&&ae>0)&&r.jsxs("div",{className:"ap-lan-tail",children:[ce.length>0&&he.length>0&&r.jsxs("button",{type:"button",className:"ap-lan-word ap-lan-more","aria-expanded":v,onClick:()=>b(me=>!me),title:v?"Show only the decks that are on":`Show the ${he.length} deck${he.length===1?"":"s"} that are not responding right now`,children:[r.jsx("span",{className:`ap-lan-chev${v?" open":""}`,"aria-hidden":!0,children:"›"}),v?"fewer":`${he.length} more`,!v&&le>0&&r.jsxs("span",{className:"ap-lan-more-bad",children:[" · ",le," not responding"]})]}),Y&&ae>0&&r.jsx("span",{className:"ap-lan-checked",children:Hee(k==null?void 0:k.checkedAt,S,_==="check")})]}),ne.length===0&&J.length===0&&!(k!=null&&k.stalled)&&!(k!=null&&k.deaf)&&!(k!=null&&k.lanTunneled)&&r.jsxs(r.Fragment,{children:[r.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."}),r.jsx("button",{type:"button",className:"ap-lan-word ap-lan-how",onClick:()=>w(!0),children:"How it works"}),r.jsx(ku,{film:"localNetwork"})]})]})]})}),pe]}):r.jsxs("div",{className:"ap-foot",children:[r.jsx(Fre,{entry:Se,rows:X,onOpen:o,onMap:Y?()=>D(!0):void 0,...j}),r.jsx("p",{className:"vis-hidden",role:"status",children:de.tone==="ok"?"":de.text}),pe]})}function Zre({anchorId:e,id:t,peers:n,onHold:s,onLet:a}){const o=y.useRef(null),{title:i,shown:c,rest:d}=qne(n),h=y.useCallback(()=>{const f=o.current,p=document.getElementById(e);if(!f||!p)return;f.style.maxHeight="";const m=bj(p.getBoundingClientRect(),{width:f.offsetWidth,height:f.offsetHeight},{width:window.innerWidth,height:window.innerHeight});f.style.top=`${m.top}px`,f.style.left=`${m.left}px`,f.style.maxHeight=m.maxHeight==null?"":`${m.maxHeight}px`,f.dataset.side=m.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]),vt.createPortal(r.jsxs("div",{ref:o,id:t,className:"ap-peek ap-fold-peek",role:"tooltip",onPointerEnter:s,onPointerLeave:a,children:[r.jsx("p",{className:"ap-peek-title",children:i}),r.jsx("div",{className:"ap-peek-list",children:c.map(f=>r.jsxs("span",{className:"ap-peek-who ap-fold-who",children:[r.jsx("span",{className:"ap-fold-name",title:f.name,children:f.name}),r.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&&r.jsx("p",{className:"ap-peek-rest",children:d})]}),document.body)}function Jre({peers:e,strained:t,armed:n,threshold:s,open:a,onToggle:o,order:i,choices:c,onOrder:d,allOpen:h,onToggleAll:f,held:p=!1}){const[m,w]=y.useState(!1),j=y.useRef(0);y.useEffect(()=>()=>window.clearTimeout(j.current),[]),y.useEffect(()=>{a&&(window.clearTimeout(j.current),w(!1))},[a]);const v=_=>{a||(window.clearTimeout(j.current),j.current=window.setTimeout(()=>w(!0),_))},b=()=>{window.clearTimeout(j.current),j.current=window.setTimeout(()=>w(!1),Y4)},k=()=>window.clearTimeout(j.current),N=()=>{window.clearTimeout(j.current),w(!1)},S=Fne(e,{strained:t&&!a,armed:n,threshold:s});return r.jsxs("div",{className:"ap-rest",children:[r.jsxs("button",{type:"button",id:"ap-rest-entry",className:"ap-nav","aria-expanded":a,"aria-controls":a?"ap-rest-panel":void 0,"aria-describedby":m?"ap-rest-peek":void 0,onClick:()=>{N(),o()},onPointerEnter:_=>{_.pointerType==="mouse"&&v(K4)},onPointerLeave:b,onFocus:_=>{_.target.matches(":focus-visible")&&v(0)},onBlur:b,children:[r.jsxs("span",{className:"ap-nav-text",children:[r.jsx("span",{className:"ap-nav-name",children:"Other accounts"}),r.jsx("span",{className:"ap-nav-state","data-tone":S.tone,children:S.text})]}),r.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:r.jsx("path",{d:"M5.6 3.4 9.2 7l-3.6 3.6"})})]}),m&&r.jsx(Zre,{anchorId:"ap-rest-entry",id:"ap-rest-peek",peers:e,onHold:k,onLet:b}),a&&r.jsx(Qre,{order:i,choices:c,onOrder:d,allOpen:h,onToggleAll:f,held:p})]})}function Qre({order:e,choices:t,onOrder:n,allOpen:s,onToggleAll:a,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 m=new ResizeObserver(p);return m.observe(h),()=>{m.disconnect(),f.style.removeProperty("--rest-tools-w")}},[]);const c=((d=t.find(h=>h.id===e))==null?void 0:d.label)??"Slot";return r.jsxs("div",{className:"ap-rest-tools",ref:i,children:[r.jsxs("span",{className:"ap-rest-sort",children:[r.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===vp?void 0:"","data-held":o?"":void 0,children:t.map(h=>r.jsx("option",{value:h.id,children:h.label},h.id))}),r.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:r.jsx("path",{d:"M2.5 3.8 5 6.3l2.5-2.5"})})]}),r.jsx("button",{type:"button",className:"ap-rest-all","aria-label":"Expand every account","aria-pressed":s,"aria-controls":"ap-rest-list",title:s?"Collapse every account":"Expand every account",onClick:a,children:r.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:r.jsx("path",{d:s?"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 eae(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}const tae=1800;function nae({accounts:e,onClose:t,copyText:n}){en("share-accounts");const[s,a]=y.useState([]),[o,i]=y.useState(null),[c,d]=y.useState(!1),[h,f]=y.useState(null),[p,m]=y.useState(!1),[w,j]=y.useState(()=>Math.floor(Date.now()/1e3)),v=y.useRef(null),b=y.useRef(!1),k=mt(t,{focusRef:v}),N=yt(t),S=Xr(o!=null,v),_=Xr(o==null,v);y.useEffect(()=>{if(!o)return;j(Math.floor(Date.now()/1e3));const $=window.setInterval(()=>j(Math.floor(Date.now()/1e3)),1e3);return()=>window.clearInterval($)},[o]);const E=bne(e),I=kne(e,s),A=I.length===e.length,O=$=>a(K=>jne(K,$)),L=y.useCallback(async()=>{const $=Nne(I);if(!xn(b.current)||!$)return;b.current=!0,d(!0),f(null),m(!1);const K=await eae($).catch(()=>null);if(b.current=!1,d(!1),!(K!=null&&K.ok)){f(el(K,"the share could not be made"));return}i({blob:K.blob,expiresAt:K.expiresAt,shared:K.shared??[],failed:K.failed??[]})},[e,I]),U=o?V4(o.expiresAt,w):null,P=(U==null?void 0:U.tone)==="gone",T=(o==null?void 0:o.shared.length)??0,B=P?"This share has expired":T===1?"1 account, ready to paste":`${T} accounts, ready to paste`,M=T===1?"this is the password":`this is ${T} passwords`,q=o?P?B:`${B} — ${M}`:"";return vt.createPortal(r.jsx("div",{className:"modal-backdrop",...N,role:"presentation",children:r.jsxs("div",{ref:k,className:"modal sa-modal",onClick:$=>$.stopPropagation(),role:"dialog","aria-modal":"true","aria-label":"Share accounts with another deck",children:[r.jsxs("header",{className:"modal-head",children:[r.jsx("div",{className:"modal-title",children:r.jsx("h3",{children:"Share accounts"})}),r.jsx("div",{className:"modal-actions",children:r.jsx("button",{type:"button",className:"glyph-btn",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),r.jsxs("section",{className:"modal-body sa-body",children:[r.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:q}),o?r.jsxs("div",{className:"sa-step",children:[r.jsx("h4",{children:B}),r.jsx("code",{className:"ap-share-blob",children:o.blob}),r.jsxs("div",{className:"ap-share-foot",children:[r.jsx("button",{type:"button",className:"ap-manage-btn",ref:v,onClick:async()=>{if(P){_(),S(),i(null),L();return}await n(o.blob)&&(m(!0),window.setTimeout(()=>m(!1),tae))},children:P?"make a new share":p?"copied":`copy ${T===1?"the share":"all "+T}`}),r.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:[r.jsx("span",{className:"ap-share-warn",children:M})," · ",r.jsx("span",{className:`ap-share-expiry ${U==null?void 0:U.tone}`,children:U==null?void 0:U.text})]})]}),o.failed.length>0&&r.jsxs("div",{className:"sa-failed",role:"alert",children:[r.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:`}),r.jsx("ul",{className:"sa-list",children:o.failed.map($=>{var G;const K=!!($.email&&((G=$.detail)!=null&&G.includes($.email)));return r.jsxs("li",{children:[!K&&r.jsx("span",{className:"sa-who",children:$.email||`account ${$.num}`}),r.jsx("span",{className:"sa-why",children:$.detail||"could not be exported"})]},`${$.num}-${$.email}`)})})]}),r.jsx("p",{className:"sa-note",children:P?r.jsx(r.Fragment,{children:"Another deck will refuse this text now. Make a new one — the same accounts are still picked."}):r.jsxs(r.Fragment,{children:["Paste it into the other deck with ",r.jsx("strong",{children:"+"})," → ",r.jsx("strong",{children:"Paste a share"}),". Accounts it already holds are left exactly as they are."]})}),r.jsxs("div",{className:"sa-actions",children:[r.jsx("button",{type:"button",className:"btn",onClick:()=>{_(),i(null),m(!1)},children:"Pick again"}),r.jsx("button",{type:"button",className:"btn primary",onClick:t,children:"Done"})]})]}):e.length===0?r.jsxs("div",{className:"sa-step",children:[r.jsx("h4",{children:"Nothing to share"}),r.jsxs("p",{className:"sa-note",children:["This deck is not holding any accounts right now. Sign one in with ",r.jsx("strong",{children:"+"}),", or wait — the panel is still reading the store."]}),r.jsx("div",{className:"sa-actions",children:r.jsx("button",{type:"button",className:"btn primary",ref:v,onClick:t,children:"Close"})})]}):r.jsxs("div",{className:"sa-step",children:[r.jsxs("h4",{children:["Which accounts go to the other ",Rt,"?"]}),r.jsx("p",{className:`sa-count${I.length?"":" empty"}`,children:Sne(I.length)}),r.jsx("ul",{className:"sa-list sa-pick",children:E.map($=>r.jsx("li",{children:r.jsxs("label",{className:"sa-row",children:[r.jsx("input",{type:"checkbox",checked:I.includes($.num),onChange:()=>O($.num)}),r.jsx("span",{className:"sa-who",children:$.label}),$.sub&&r.jsx("span",{className:"sa-sub",children:$.sub})]})},$.num))}),h&&r.jsx("p",{className:"aa-err",role:"alert",children:h}),r.jsxs("div",{className:"sa-actions",children:[r.jsx("button",{type:"button",className:"btn",onClick:()=>a(A?e.map($=>$.num):[]),children:A?"Clear all":"Select all"}),r.jsx("button",{type:"button",className:"btn primary",ref:v,...$n(c,!I.length),onClick:()=>{S(),L()},children:c?"making the share…":I.length===0?"Share":I.length===1?"Share 1 account":`Share ${I.length} accounts`})]})]})]})]})}),document.body)}function mD(e,t){var n;return!e.disabled&&!((n=Zo(e,t))!=null&&n.blocksSwitch)}function sae(e,t,n){return e.map(s=>{const a=Zo(s,t,n==null?void 0:n(s));return{key:Ws(s),name:s.alias??s.email??`account ${s.num}`,ready:mD(s,t),why:s.disabled?"held out":a!=null&&a.blocksSwitch?a.text:null,warn:(a==null?void 0:a.tone)==="warn",headroom:jj(s,t)}})}function rae(e,t,n){const s=Number(t),a=e&&(n==null?e.headroom:jj(e,n));return a!=null&&Number.isFinite(s)&&100-a>=s}function aae(e){return(e==null?void 0:e.ok)===!0&&(e.enabled||e.external)}const gD="agent-dag.otherAccountsOrder",yD="agent-dag.otherAccountsOpen";function oae(){const e=Ze(gD);return typeof e=="string"&&e.length>0&&e.length<=64?e:vp}function iae(e){Xe(gD,e)}function lae(){const e=Ze(yD);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 cae(e){Xe(yD,JSON.stringify({mode:e.mode,keys:e.keys.filter(t=>!t.startsWith("slot:"))}))}function uae(){const[e,t]=y.useState(null),n=y.useRef(null),s=y.useCallback(i=>lp(n.current)?(n.current=i,t(i),!0):!1,[]),a=y.useCallback(()=>{n.current=null,t(null)},[]);return{busy:e,claim:s,release:a,pressProps:(i,c=!1)=>{const d=Ga(e,i);return{disabled:d.disabled,"aria-busy":d.busy||c}}}}const dae=8e3,hae=1800,fae=4e3;function pae({claim:e,release:t,load:n,clearFailure:s,rescueFocus:a,afterRemove:o}){const[i,c]=y.useState(null),d=(i==null?void 0:i.num)??null,h=y.useRef(i);h.current=i;const[f,p]=y.useState(null),[m,w]=y.useState(""),[j,v]=y.useState(null),b=y.useRef(0);y.useEffect(()=>{if(j==null)return;const F=window.setTimeout(()=>v(null),fae);return()=>window.clearTimeout(F)},[j]);const[k,N]=y.useState(null),[S,_]=y.useState(!1),[E,I]=y.useState(null),[A,O]=y.useState(null),L=y.useCallback(async(F,Y)=>{if(!e(Y))return null;s(),p(null);try{const X=await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(F)}),Z=await X.json().catch(()=>null);return Z!=null&&Z.ok||p({text:el(Z,"command failed",X.status)}),Z}catch{return p({text:"server unreachable"}),null}finally{t()}},[e,t,s]),U=y.useCallback(()=>{c(null),p(null),v(null),N(null),_(!1)},[]),P=(F,Y="first")=>{U(),O(null),c({num:F,view:"menu",start:Y})},T=y.useCallback(F=>{var Z,J;const Y=h.current;if(!Y||F!=null&&Y.num!==F)return;const X=document.getElementById(`ap-menu-${Y.num}`);(X!=null&&X.contains(document.activeElement)||Yn(((Z=document.activeElement)==null?void 0:Z.tagName)??null))&&((J=document.getElementById(`ap-more-${Y.num}`))==null||J.focus()),U()},[U]),B=y.useCallback(F=>p(F),[]),M=(F,Y)=>{w(Y??""),p(null),c({num:F,view:"rename"})},q=F=>w(F),$=F=>{O(null),p(null),c({num:F,view:"move"})},K=F=>O(F),G=async F=>{var X;_(!1);const Y=await L({action:"share",account:F},`share-${F}`);!(Y!=null&&Y.ok)||((X=h.current)==null?void 0:X.num)!==F||(N({num:F,blob:Y.blob,expiresAt:Y.expiresAt}),c({num:F,view:"share"}))},z=async F=>{await eo(F)&&(_(!0),window.setTimeout(()=>_(!1),hae))},W=async(F,Y)=>{const{commit:X,alias:Z}=Mne(m,Y);if(X){const J=await L({action:"alias",account:F,alias:Z},`alias-${F}`);if(await n(!0),!(J!=null&&J.ok))return}T(F)},D=async(F,Y)=>{var J,ne,ce;const X=await L({action:"move",account:F,slot:Y},`move-${F}`),Z=Rne({menuFor:((J=h.current)==null?void 0:J.num)??null,shareFor:(k==null?void 0:k.num)??null},F,X);if(await n(!0),Z){if(Z.menuFor!=null){const le=document.getElementById(`ap-menu-${F}`),re=document.getElementById(`ap-more-${Z.menuFor}`);re&&(le!=null&&le.contains(document.activeElement)||Yn(((ne=document.activeElement)==null?void 0:ne.tagName)??null))&&re.focus()}((ce=h.current)==null?void 0:ce.num)===F&&U(),v(Z.confirmRemove),Z.shareFor==null&&(N(null),_(!1)),I(Z.swapNote);const he=Z.swapNote;he&&window.setTimeout(()=>I(le=>le===he?null:le),dae),O(null),a(Z.menuFor)}return X};return{menu:i,menuFor:d,menuError:f,aliasDraft:m,confirmRemove:j,share:k,shareCopied:S,slotDraft:A,swapNote:E,showMenu:P,dropMenu:U,closeMenu:T,sayInMenu:B,startRename:M,typeAlias:q,doAlias:W,startMove:$,pickSlot:K,doSlot:async(F,Y,X)=>{if(!X.sends){T(F);return}await D(F,Y)},makeShare:G,copyShare:z,pressRemove:F=>{const Y=Date.now(),X=jl({armedFor:j,target:F,armedAt:b.current,now:Y,gapMs:kl});if(X==="arm"){v(F),b.current=Y;return}X!=="ignore"&&(v(null),L({action:"remove",account:F},`rm-${F}`).then(Z=>{var J;n(!0),Z!=null&&Z.ok&&(o==null||o(Z),((J=h.current)==null?void 0:J.num)===F&&U(),a(null))}))}}}function mae(e,t){return!e||!t||t.some(n=>n.num===e.num&&n.active)?e:null}const gae="login_expired";function yae(e,t,n){return(e==null?void 0:e.reason)!==gae?null:{text:`${t}'s login expired · sign in again to use it`,row:n,signIn:!0}}const wae="Removed. Claude Code is still signed in with that expired login, and no other account here was ready to take over — sign in to one from +";function xae(e){if(!(e!=null&&e.ok))return null;const t=e.movedTo;return t&&Number.isInteger(t.num)?{switched:{num:t.num,name:t.alias??t.email??`account ${t.num}`}}:e.stillExpired?{failure:{text:wae}}:null}function vae({data:e,claim:t,release:n,load:s,sayFailure:a,clearFailure:o,sayInMenu:i,rescueFocus:c}){const[d,h]=y.useState(null),f=y.useCallback(async(w,j,v="panel")=>{if(!t(j))return null;const b=v==="menu"?i:a;b(null);try{const k=await fetch("/api/cswap-auto",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(w)}),N=await k.json().catch(()=>null);return N!=null&&N.ok||b({text:D0(N,"command failed",k.status),raw:_u(N)}),N}catch{return b({text:"server unreachable"}),null}finally{n()}},[t,n,i,a]);y.useEffect(()=>{!(e!=null&&e.ok)||!e.accounts||h(w=>mae(w,e.accounts))},[e]);const p=async(w,j)=>{if(t(`switch-${w}`)){o(),h(null);try{const b=await(await fetch("/api/claude-accounts/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({account:w})})).json().catch(()=>null),k=yae(b,j,w);k?a(k):b!=null&&b.ok?h({num:w,name:j}):a({text:D0(b,"the switch failed"),raw:_u(b),row:w}),await s(!0)}catch{a({text:"server unreachable",row:w})}finally{n(),c(w)}}},m=y.useCallback((w,j)=>h({num:w,name:j}),[]);return{switched:d,post:f,doSwitch:p,noteSwitched:m}}const bae=1800;function kae({auto:e,post:t,load:n}){var I;const[s,a]=y.useReducer(Kte,U0),[o,i]=y.useState(!1),c=y.useRef(null),d=y.useRef(null),h=y.useRef(null),f=y.useRef(!1),p=((I=e==null?void 0:e.settings["autoswitch.threshold"])==null?void 0:I.value)??"90",m=s.pick??p,w=One(m,p),j=s.custom!=null,v=s.refusal,b=y.useRef(j);return y.useEffect(()=>{var A,O,L;b.current!==j&&(b.current=j,j?((A=h.current)==null||A.focus(),(O=h.current)==null||O.select()):f.current&&((L=c.current)==null||L.focus()),f.current=!1)},[j]),{threshold:p,thresholdPick:m,thresholdCtl:w,thresholdSaved:o,thresholdRef:c,thresholdSaveRef:d,thresholdCustom:j,thresholdRefusal:v,thresholdFieldRef:h,proposeThreshold:A=>a({kind:"pick",pick:A}),typeThreshold:A=>a({kind:"type",text:A}),cancelThreshold:A=>{A.key!=="Escape"||A.nativeEvent.isComposing||!s.custom||(A.preventDefault(),A.stopPropagation(),f.current=!0,a({kind:"cancel"}))},leaveThreshold:()=>a({kind:"leave",stored:p}),doThreshold:async(A,O)=>{const L=await Yte(A,O,t);if(L.kind==="refused"){a({kind:"refuse",message:L.message});return}L.kind==="sent"&&(await n(!0),!L.ok)||(f.current=document.activeElement===h.current,a({kind:"settle"}),i(!0),window.setTimeout(()=>{var U;document.activeElement===d.current&&((U=c.current)==null||U.focus()),i(!1)},bae))}}}const jae=1800;function Nae({auto:e,post:t,load:n}){var j;const[s,a]=y.useState(null),[o,i]=y.useState(!1),c=y.useRef(null),d=y.useRef(null),h=((j=e==null?void 0:e.choice)==null?void 0:j.next)??"room",f=s??h,p=Ine(f,h);return{nextPick:f,nextCtl:p,nextSaved:o,nextRef:c,nextSaveRef:d,proposeNext:v=>a(Wte(v)?v:null),doNext:async()=>{if(!p.sends)return;const v=await t({action:"next",value:f},"next");await n(!0),v!=null&&v.ok&&(a(null),i(!0),window.setTimeout(()=>{var b;document.activeElement===d.current&&((b=c.current)==null||b.focus()),i(!1)},jae))}}}const Sae=Object.freeze({text:"couldn't reach the deck server",reload:!0}),_ae=Object.freeze({text:"still waiting on the deck server — claude-swap can be slow to answer",reload:!0});async function YT(e){return e.ok?{ok:!0,status:e.status,body:null}:{ok:!1,status:e.status,body:await e.json().catch(()=>null)}}function Cae(e){const t=e.find(s=>!s.ok);if(!t)return null;const n=_u(t.body);return{text:D0(t.body,`the deck server answered ${t.status}`),...n?{raw:n}:{},reload:!0}}function uy(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 dy=e=>e!=null&&typeof e=="object"&&!Array.isArray(e),hy=e=>e==null||typeof e=="string",fy=e=>e==null||typeof e=="number"&&Number.isFinite(e)&&e>=0&&Number.isFinite(new Date(e).getTime());function Eae(e){if(!dy(e)||typeof e.ok!="boolean")return!1;if(!e.ok)return hy(e.reason)&&hy(e.hint);if(!Array.isArray(e.accounts))return!1;const t=new Set;return e.accounts.every(n=>{if(!dy(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(hy)||![n.active,n.disabled,n.stale].every(a=>typeof a=="boolean")||!fy(n.fetchedAt)||!fy(n.nextAt)||!Array.isArray(n.lanes)))return!1;const s=new Set;return n.lanes.every(a=>!dy(a)||typeof a.id!="string"||!a.id||s.has(a.id)||typeof a.label!="string"||typeof a.pct!="number"||!Number.isFinite(a.pct)||a.pct<0||a.pct>100||!fy(a.resetAt==null?null:typeof a.resetAt=="number"?a.resetAt*1e3:NaN)?!1:(s.add(a.id),!0))})}const wD=15e3,Tae=3e4;function Rae(e){const[t,n]=y.useState(null),[s,a]=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),m=y.useRef(new Set),w=y.useCallback(async(b=!1)=>{if(!p.current||!b&&m.current.size>0)return;const k=++f.current;b&&i(!0);const N=new AbortController;m.current.add(N);const S=window.setTimeout(()=>N.abort(),Tae);try{const[_,E]=await Promise.all([fetch(`/api/claude-accounts${b?"?refresh=1":""}`,{signal:N.signal}),fetch("/api/cswap-auto",{signal:N.signal})]),[I,A]=await Promise.all([_.ok?_.json():null,E.ok?E.json():null]),O=Cae([await YT(_),await YT(E)]);if(!p.current||k!==f.current)return;if(I&&!Eae(I)){d(L=>uy(L,{text:"the deck server returned unreadable account data",reload:!0}));return}I&&(n(I),e(I)),A&&a(A),d(L=>uy(L,O))}catch{p.current&&k===f.current&&d(_=>uy(_,N.signal.aborted?_ae:Sae))}finally{window.clearTimeout(S),m.current.delete(N),p.current&&k===f.current&&i(!1)}},[e]);y.useEffect(()=>(p.current=!0,w(!0),h.current=window.setInterval(()=>w(!1),wD),()=>{p.current=!1,f.current++,h.current!=null&&window.clearInterval(h.current);for(const b of m.current)b.abort()}),[w]);const j=y.useCallback(b=>d(b),[]),v=y.useCallback(()=>d(null),[]);return{data:t,auto:s,reloading:o,failure:c,load:w,sayFailure:j,clearFailure:v}}const Aae="#ap-rest-entry";function Mae(e){return[`#${e}`,Aae,...iP(null)]}function $ae(e){const t=y.useRef(null),n=a=>{t.current=a.target.id||null},s=a=>{a.target.isConnected&&(t.current=null)};return y.useLayoutEffect(()=>{var o;const a=t.current;if(!(!a||!Yn(((o=document.activeElement)==null?void 0:o.tagName)??null)))for(const i of Mae(a)){const c=document.querySelector(i);if(c){c.focus();return}}},[e]),{onFocus:n,onBlur:s}}function Lae({onClose:e,leaving:t,onReport:n,onRoster:s,lanWanted:a=!1,onLanShown:o}){var tr,ts,ns;en("accounts-panel");const i=Pn(),{busy:c,claim:d,release:h,pressProps:f}=uae(),[p,m]=y.useState("accounts"),[w,j]=y.useState(!1),[v,b]=y.useState(null),k=y.useRef(v);k.current=v;const[N,S]=y.useState(!1),[_,E]=y.useState(null),[I,A]=y.useState(!1),[O,L]=y.useState([]),[U,P]=y.useState(!1),[T,B]=y.useState(null),[M,q]=y.useState(lae),[$,K]=y.useState(oae),[G,z]=y.useState(null),[W,D]=y.useState(!1),H=y.useRef(s);H.current=s;const ee=y.useCallback(ge=>{var Ve;q(lt=>hee(lt,ge.accounts)),(Ve=H.current)==null||Ve.call(H,ge)},[]),{data:F,auto:Y,reloading:X,failure:Z,load:J,sayFailure:ne,clearFailure:ce}=Rae(ee),he=$ae(F),le=y.useCallback(ge=>{window.requestAnimationFrame(()=>{var Ve;if(Yn(((Ve=document.activeElement)==null?void 0:Ve.tagName)??null))for(const lt of iP(ge)){const Mt=document.querySelector(lt);if(Mt){Mt.focus();return}}})},[]),re=y.useRef(null),ae=pae({claim:d,release:h,load:J,clearFailure:ce,rescueFocus:le,afterRemove:ge=>{var Ve;return(Ve=re.current)==null?void 0:Ve.call(re,ge)}}),{menu:de,menuFor:Se,swapNote:pe,showMenu:me,dropMenu:be,closeMenu:Ce,sayInMenu:ye}=ae,{switched:Pe,post:Oe,doSwitch:We,noteSwitched:Re}=vae({data:F,claim:d,release:h,load:J,sayFailure:ne,clearFailure:ce,sayInMenu:ye,rescueFocus:le});re.current=ge=>{const Ve=xae(ge);Ve&&"switched"in Ve?Re(Ve.switched.num,Ve.switched.name):Ve&&ne(Ve.failure)};const st=ge=>{E(ge),S(!0)},{threshold:je,thresholdPick:Te,thresholdCtl:$e,thresholdSaved:Ge,thresholdRef:tt,thresholdSaveRef:ht,thresholdCustom:it,thresholdRefusal:nt,thresholdFieldRef:we,proposeThreshold:Be,typeThreshold:Ye,cancelThreshold:He,leaveThreshold:ft,doThreshold:St}=kae({auto:Y,post:Oe,load:J}),{nextPick:gt,nextCtl:_t,nextSaved:It,nextRef:ks,nextSaveRef:Xs,proposeNext:js,doNext:Zn}=Nae({auto:Y,post:Oe,load:J}),Ot=p4();y.useEffect(()=>{cae(M)},[M]),y.useEffect(()=>{iae($)},[$]);const[Ns,hn]=y.useState(()=>new Set),Dn=y.useCallback(ge=>hn(new Set(ge)),[]),[_e,De]=y.useState(()=>new Map),ze=ge=>{const Ve=yT([ge])[0].key,lt=_e.get(Ve);return{noCopyWorksNearby:Ns.has(Ve),sharedTo:(lt==null?void 0:lt.to)??null,sharedInUse:(lt==null?void 0:lt.inUse)===!0}},ut=(tr=F==null?void 0:F.accounts)==null?void 0:tr.find(ge=>ge.active),At=ut?Zo(ut,Ot,ze(ut)):null,Jn=(F==null?void 0:F.accounts)??[],fn=ut?Jn.filter(ge=>!ge.active):[],la=N4(fn),Qn=lee($,fn),Ct=I0(iee(fn,Qn,ge=>mD(ge,Ot),Ot),G),Ss=y.useRef(!1),_s=y.useRef(!1),Zs=y.useRef(!1),Cs=y.useCallback(()=>{!Ss.current&&!_s.current&&!Zs.current&&z(null)},[]),Sr=()=>z(ge=>ge??Ct.map(Ws)),Ft={onPointerEnter:()=>{Ss.current=!0,Sr()},onPointerLeave:()=>{Ss.current=!1,Cs()},onFocus:ge=>{ge.target.matches(":focus-visible")&&(_s.current=!0,Sr())},onBlur:ge=>{ge.currentTarget.contains(ge.relatedTarget)||(_s.current=!1,Cs())}},Js=Se!=null&&fn.some(ge=>ge.num===Se)||v!=null&&fn.some(ge=>ge.num===v.num);y.useEffect(()=>{Zs.current=Js,Js||Cs()},[Js,Cs]);const Es=W&&fn.length>0;y.useEffect(()=>{Es||(Ss.current=_s.current=Zs.current=!1,z(null))},[Es]);const _r=y.useRef(!1);y.useEffect(()=>{_r.current&&fn.length===0&&le(null),_r.current=fn.length>0},[fn.length,le]);const dt=Ct.length?Jn.filter(ge=>ge.active):Jn,ri=sae(Ct,Ot,ze),Cr=rae(ut,je,Ot),Qs=aae(Y),Ts=ge=>W&&Ct.some(Ve=>Ve.num===ge)?"ap-rest-list":"ap-scroll",so=(ge,Ve="first")=>{me(ge,Ve),b(null)},Er=(ge,Ve)=>{be(),b(lt=>(lt==null?void 0:lt.anchor)===Ve?null:{num:ge,anchor:Ve})},es=y.useCallback((ge=!1)=>{var lt;const Ve=k.current;ge&&Ve&&((lt=document.getElementById(Ve.anchor))==null||lt.focus()),b(null)},[]),nn=()=>{be(),b(null),m("lan")},er=y.useRef(p);y.useEffect(()=>{er.current!==p&&(er.current=p,window.requestAnimationFrame(()=>{var ge;(ge=document.getElementById(p==="lan"?"ap-lan-back":"ap-lan-entry"))==null||ge.focus()}))},[p]),y.useEffect(()=>{F!=null&&F.ok&&j(!0)},[F==null?void 0:F.ok]),y.useEffect(()=>{!a||!w||(nn(),o==null||o())},[a,w]),y.useEffect(()=>{t&&(be(),b(null))},[t,be]),y.useEffect(()=>{de&&(F!=null&&F.accounts)&&!F.accounts.some(ge=>ge.num===de.num)&&be(),v&&(F!=null&&F.accounts)&&!F.accounts.some(ge=>ge.num===v.num)&&b(null)},[F,de,v,be]),y.useEffect(()=>{T==null||!(F!=null&&F.accounts)||F.accounts.some(ge=>ge.num===T.num)||(B(null),le(null))},[F,T,le]);const Wt=r.jsx("button",{type:"button",className:"glyph-btn",onClick:e,"aria-label":"Close accounts panel",title:vn("Close","A",i),children:r.jsx("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round","aria-hidden":!0,children:r.jsx("path",{d:"M3.4 3.4l7.2 7.2M10.6 3.4l-7.2 7.2"})})}),ai=ge=>{var Fn;const Ve=S4(M,ge),lt=Se===ge.num,Mt=(Z==null?void 0:Z.row)===ge.num?Z:null,ss=(Pe==null?void 0:Pe.num)===ge.num,Tr=(pe==null?void 0:pe.at)===ge.num?pe:null,ca=Tr?Jn.find(Rr=>Rr.num===Tr.displaced):void 0,nr=(v==null?void 0:v.anchor)===`ap-issue-${ge.num}`;return r.jsx(dte,{a:ge,nowSec:Ot,lan:ze(ge),opened:Ve,onToggleLanes:()=>q(Rr=>uee(Rr,ge)),busy:c,pressProps:f,onSwitch:We,menuOpen:lt,onOpenMenu:so,onCloseMenu:Ce,refusal:Mt,onDismissRefusal:()=>ce(),onSignIn:st,switchedHere:ss,swapped:Tr,displaced:ca,issueExpanded:nr,onOpenIssue:Er,sortKey:ge.active?null:oee(Qn),home:ay(ge,(Fn=Y==null?void 0:Y.choice)==null?void 0:Fn.home)?Hte(ge,!!(Y!=null&&Y.enabled)):null},ge.num)},ro=F!=null&&F.ok&&(Y!=null&&Y.ok)?r.jsx(Xte,{auto:Y,threshold:je,thresholdPick:Te,thresholdCtl:$e,thresholdSaved:Ge,thresholdRef:tt,thresholdSaveRef:ht,thresholdCustom:it,thresholdRefusal:nt,thresholdFieldRef:we,proposeThreshold:Be,typeThreshold:Ye,cancelThreshold:He,leaveThreshold:ft,doThreshold:St,nextPick:gt,nextCtl:_t,nextSaved:It,nextRef:ks,nextSaveRef:Xs,proposeNext:js,doNext:Zn,pressProps:f,post:Oe,load:J}):null;return r.jsxs("aside",{className:`accounts-panel${t?" leaving":""}`,id:"accounts-panel","aria-label":"Claude accounts",onFocus:he.onFocus,onBlur:he.onBlur,children:[p==="accounts"&&r.jsx(fte,{canShare:(((ts=F==null?void 0:F.accounts)==null?void 0:ts.length)??0)>0,canReport:(((ns=F==null?void 0:F.accounts)==null?void 0:ns.length)??0)>1||I,onAdd:()=>S(!0),onReport:()=>{L([...dt,...Ct].map(Ws)),A(!0)},onShareSet:()=>P(!0),onReload:()=>J(!0),pressProps:f,reloading:X,closeButton:Wt}),p==="accounts"&&r.jsxs("div",{className:"ap-scroll",id:"ap-scroll",children:[F==null?Z?r.jsxs("div",{className:"ap-empty",role:"alert",children:[r.jsx("span",{title:Z.raw||void 0,children:Z.text}),r.jsxs("span",{className:"ap-hint",children:["No accounts have arrived, so there is nothing to show yet. The panel keeps trying every ",wD/1e3," seconds."]}),r.jsx("button",{type:"button",className:"ap-fix",...f("reload",X),onClick:()=>J(!0).then(()=>le(null)),children:X?"trying…":"try again"})]}):r.jsx("div",{className:"ap-empty",children:"Checking…"}):F.ok?r.jsxs(r.Fragment,{children:[ut&&(At==null?void 0:At.tone)==="warn"&&r.jsxs("div",{className:"ap-notice",children:[r.jsxs("button",{type:"button",id:"ap-notice",className:"ap-issue","data-tone":"warn","aria-haspopup":"dialog","aria-expanded":(v==null?void 0:v.anchor)==="ap-notice","aria-controls":(v==null?void 0:v.anchor)==="ap-notice"?"ap-issue-pop":void 0,onClick:()=>Er(ut.num,"ap-notice"),children:[r.jsx(kj,{}),r.jsx("span",{className:"ap-issue-text",children:"Current account needs attention"})]}),At.fix&&r.jsx("button",{type:"button",className:"ap-notice-fix",onClick:()=>S(!0),title:"Open the sign-in dialog. Signing in as this account replaces its stored login in place.",children:"Sign in"})]}),r.jsx("ul",{className:"ap-list",children:dt.map(ai)}),Ct.length>0&&r.jsx(Jre,{peers:ri,strained:Cr,armed:Qs,threshold:Y!=null&&Y.ok?je:null,open:W,onToggle:()=>D(ge=>!ge),order:Qn,choices:la,onOrder:K,allOpen:_4(M,Ct),onToggleAll:()=>q(ge=>dee(ge,Ct)),held:G!=null}),Ct.length>0&&W&&r.jsxs("div",{className:"ap-rest-panel",id:"ap-rest-panel",children:[r.jsx("ul",{className:"ap-list ap-others",id:"ap-rest-list",...Ft,children:Ct.map(ai)}),ro]}),Ct.length===0&&ro,Z&&Z.row==null&&r.jsxs("div",{className:"ap-failure",role:"alert",children:[r.jsx("span",{className:"ap-failure-text",title:Z.raw||void 0,children:Z.text}),r.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>ce(),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),de&&(()=>{var Ve,lt;const ge=(Ve=F.accounts)==null?void 0:Ve.find(Mt=>Mt.num===de.num);return ge?r.jsx(Pne,{a:ge,accountMenu:ae,slots:(F.accounts??[]).map(Mt=>Mt.num),boundaryId:Ts(ge.num),nowSec:Ot,busy:c,pressProps:f,rotating:!!(Y!=null&&Y.enabled||Y!=null&&Y.external),onProjects:()=>{B({num:ge.num,name:ge.alias??ge.email??`account ${ge.num}`}),Ce(ge.num)},onRotation:()=>Oe({action:"account",account:ge.num,enabled:ge.disabled},`rot-${ge.num}`,"menu").then(Mt=>{J(!0),Mt!=null&&Mt.ok&&Ce(ge.num)}),home:ay(ge,(lt=Y==null?void 0:Y.choice)==null?void 0:lt.home),canSetHome:!!(Y!=null&&Y.enabled)&&!(Y!=null&&Y.external),onHome:()=>{var Mt;return Oe({action:"home",account:ay(ge,(Mt=Y==null?void 0:Y.choice)==null?void 0:Mt.home)?null:ge.num},`home-${ge.num}`,"menu").then(ss=>{J(!0),ss!=null&&ss.ok&&Ce(ge.num)})}}):null})(),v&&(()=>{var lt;const ge=(lt=F.accounts)==null?void 0:lt.find(Mt=>Mt.num===v.num),Ve=ge?Zo(ge,Ot,ze(ge)):null;return!ge||!Ve?null:r.jsx(ZQ,{anchorId:v.anchor,boundaryId:v.anchor==="ap-notice"?"ap-scroll":Ts(ge.num),issue:Ve,who:ge.alias??ge.email??`account ${ge.num}`,fetchedAt:ge.fetchedAt,nowSec:Ot,onClose:es,onSignIn:()=>S(!0),onReport:n&&(()=>n({initialKind:Ve.tone==="warn"?"bug":"other",initialBody:`Account issue: ${Ve.text}. ${Ve.hint}`}))})})()]}):r.jsx(hte,{data:F}),r.jsx("div",{className:"film-foot",children:r.jsx(ku,{film:"claudeAccounts"})})]}),r.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:Pe?`Now active: ${Pe.name}`:""}),w&&r.jsx(Xre,{accounts:yT((F==null?void 0:F.accounts)??[]),onChanged:()=>J(!0),onNoCopy:Dn,onShared:De,view:p==="lan",onOpen:nn,onBack:()=>m("accounts"),closeButton:Wt}),N&&r.jsx(G4,{email:_,onClose:()=>{S(!1),E(null)},onChanged:()=>J(!0)}),U&&r.jsx(nae,{accounts:((F==null?void 0:F.accounts)??[]).map(ge=>({num:ge.num,email:ge.email,alias:ge.alias,org:ge.org})),onClose:()=>P(!1),copyText:eo}),T!=null&&(()=>{var Ve;const ge=(Ve=F==null?void 0:F.accounts)==null?void 0:Ve.find(lt=>lt.num===T.num);return F!=null&&F.accounts&&!ge?null:r.jsx(YQ,{num:T.num,name:ge?ge.alias??ge.email??`account ${ge.num}`:T.name,onClose:()=>B(null)})})(),I&&r.jsx(Bte,{accounts:(F==null?void 0:F.accounts)??null,order:O,failed:Z!=null&&Z.reload?Z.text:null,nowSec:Ot,onClose:()=>A(!1)})]})}function Iae({width:e,children:t}){const n=y.useRef(null);return y.useLayoutEffect(()=>{var s;for(const a of Array.from(((s=n.current)==null?void 0:s.children)??[]))a.inert=a.classList.contains("leaving")}),r.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 Oae=16,Pae=120;function Dae(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 Fae(e,t){const n=Math.max(t.left-e.clientX,0,e.clientX-t.right),s=Math.max(t.top-e.clientY,0,e.clientY-t.bottom);return Math.hypot(n,s)}function Bae(e,t){return Dae(e,t,Oae)?"over":Fae(e,t)<=Pae?"near":"far"}function qae(e){var n,s;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])??((s=e.touches)==null?void 0:s[0]);return t?{clientX:t.clientX,clientY:t.clientY}:null}function Uae(){const[e,t]=y.useState(!1),[n,s]=y.useState(""),[a,o]=y.useState("far"),i=y.useRef(null),c=Qi(e,140),d=y.useCallback(m=>{var v;const w=(v=i.current)==null?void 0:v.getBoundingClientRect(),j=qae(m);return w&&j?Bae(j,w):"far"},[]),h=y.useCallback(m=>{m!==null&&(s(m),t(!0)),o("far")},[]),f=y.useCallback(m=>{o(d(m))},[d]),p=y.useCallback((m,w)=>{const j=w&&d(m)==="over";return t(!1),j},[d]);return{trashDragging:e,trashLabel:n,trashState:a,trashZoneRef:i,trashPhase:c,beginTrashDrag:h,trackTrashDrag:f,endTrashDrag:p}}const Wae=420;function Hae(){const[e,t]=y.useState(!1),n=y.useRef(null),s=y.useCallback(()=>{n.current&&(window.clearTimeout(n.current),n.current=null),t(!1)},[]),a=y.useCallback(o=>{o.length!==0&&queueMicrotask(()=>{t(!0),n.current&&window.clearTimeout(n.current),n.current=window.setTimeout(()=>t(!1),Wae+80)})},[]);return y.useEffect(()=>()=>{n.current&&window.clearTimeout(n.current)},[]),{bubbling:e,endBubble:s,onBubble:a}}const Oj=11;function xD(e=0){return Oj+Math.min(0,e)}const vD=7.2,bD=6.6,zae={width:104,height:48},XT={width:96,height:44},kD={width:220,height:103};function Vae(e){let t=1/0,n=1/0;for(const s of e)!(s.width>0)||!(s.height>0)||(t=Math.min(t,s.width),n=Math.min(n,s.height));return!Number.isFinite(t)||!Number.isFinite(n)?kD:{width:Math.max(160,t),height:Math.max(72,n)}}function py(e,t,n){return e.width*t>=n.width&&e.height*t>=n.height}function Gae(e,t,n=kD,s=Oj){if(!Number.isFinite(t)||t<=0)return e??"detail";const a=s*t;return e==="detail"?a>=bD?"detail":py(n,t,XT)?"compact":"overview":a>=vD?"detail":e==="compact"?py(n,t,XT)?"compact":"overview":py(n,t,zae)?"compact":"overview"}function Kae(e,t,n=Oj){return e>=vD/n?e:Math.max(e,Math.min(t,bD/n-.001))}const Yae=.8,Xae=1;function Zae({stateRef:e,measuredRef:t,measuredVersionRef:n,canvasRef:s}){const[a,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 j of e.current.agents.keys()){const v=t.current.get(j);v&&p.push(v)}const m=Vae(p);return c.current={version:f,card:m},m},[]),h=y.useCallback(f=>{var m;const p=Gae(i.current,f,d(),xD(uj[dj()]));return p===i.current?null:(i.current=p,(m=s.current)==null||m.setAttribute("data-lod",p),o(p),p)},[d,s]);return{lod:a,lodRef:i,applyZoom:h}}const Jae=40,Qae=120;function eoe(e,t){let n=null,s=0,a=Number.NEGATIVE_INFINITY;const o=()=>{n=null,a=t.now(),e()},i=()=>{n!=null&&(t.clearTimeout(n),n=null)},c=(d,h,f)=>{if(n!=null){if(s<=d)return;i()}const p=Math.min(f,Math.max(0,d-h));s=d,n=t.setTimeout(o,p)};return{live(d=Jae){const h=t.now(),f=Math.max(a+d,h);if(f<=h){i(),o();return}c(f,h,d)},replay(d=Qae){i(),s=t.now()+d,n=t.setTimeout(o,d)},flush(){i(),o()},cancel(){i()}}}const toe=1024*1024,ZT=5,jD=.8,X0=24,noe="agent-dag.soundCustom.done",soe="agent-dag.soundCustom.needs-input",eu={done:noe,"needs-input":soe};function Eu(e){if(e.kind!=="audio")return e;const{bytes:t,...n}=e;return n}function JT(e){return!e||!/^[a-zA-Z0-9._-]{1,96}$/.test(e)?null:e}function roe(e){return{done:JT(e(eu.done)),"needs-input":JT(e(eu["needs-input"]))}}function aoe(e,t){return{done:e.done===t?null:e.done,"needs-input":e["needs-input"]===t?null:e["needs-input"]}}function ooe(e){return e.done&&e.done===e["needs-input"]?e.done:null}const ioe={wav:"audio/wav",wave:"audio/wav",mp3:"audio/mpeg",ogg:"audio/ogg",oga:"audio/ogg",webm:"audio/webm",m4a:"audio/mp4",mp4:"audio/mp4"},ND=new Set(["audio/wav","audio/x-wav","audio/mpeg","audio/mp3","audio/ogg","audio/webm","audio/mp4"]);function SD(e,t){const n=t.toLowerCase().split(";")[0].trim();if(ND.has(n))return n;const s=e.toLowerCase().split(".").pop()??"";return ioe[s]??n}function QT(e,t){const n=SD(e.name,e.type);if(!ND.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>toe)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>ZT)return`Audio must be ${ZT} seconds or shorter.`}return null}function Z0(e){return e>=X0?`There are already ${X0} custom sounds. Delete one first.`:null}function loe(e,t){const n=e.indexOf(t);return n<0?null:e[n+1]??e[n-1]??null}function coe(e){let t=0;for(const n of e)for(let s=0;s<n.length;s++)t=Math.max(t,Math.abs(n[s]));return t<=1e-5?1:Math.min(16,jD/t)}function _D(){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 uoe(e,t,n=_D()){var h;const s=((h=e.name)==null?void 0:h.trim())||"Custom sound",a=QT({name:s,type:e.type,size:e.size});if(a)throw new Error(a);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=QT({name:s,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:s.replace(/\.(wav|wave|mp3|ogg|oga|webm|m4a|mp4)$/i,"")||"Custom sound",kind:"audio",mime:SD(s,e.type),duration:i.duration,normalizationGain:coe(d),bytes:o}}function doe(e,t=_D()){const n=e.name.trim()||"Custom voice",s=e.text.trim();if(!s)throw new Error("Enter the words this voice should say.");const a=Number.isFinite(e.rate)?e.rate:1,o=Number.isFinite(e.pitch)?e.pitch:1;return{id:t,name:n,kind:"tts",text:s.slice(0,180),voiceURI:e.voiceURI??"",rate:Math.min(2,Math.max(.5,a)),pitch:Math.min(2,Math.max(.5,o))}}const hoe="ccdeck-notification-audio",foe=2,Vs="assets",br="summaries";function qu(){return typeof window<"u"?window.ccdeckNotificationAudio??null:null}function poe(){return new Promise((e,t)=>{const n=indexedDB.open(hoe,foe);n.onupgradeneeded=s=>{const a=n.result,o=a.objectStoreNames.contains(Vs)?n.transaction.objectStore(Vs):a.createObjectStore(Vs,{keyPath:"id"});if(a.objectStoreNames.contains(br))return;const i=a.createObjectStore(br,{keyPath:"id"});if(s.oldVersion<1)return;const c=o.openCursor();c.onsuccess=()=>{const d=c.result;d&&(i.put(Eu(d.value)),d.continue())}},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error??new Error("Could not open local audio storage."))})}async function Uu(e,t,n){const s=await poe();try{return await new Promise((a,o)=>{const i=s.transaction(e,t),c=n(i),d=()=>o(i.error??new Error("Local audio storage failed."));i.oncomplete=()=>a(c?c.result:void 0),i.onerror=d,i.onabort=d})}finally{s.close()}}async function moe(){const e=qu();return e?e.list():typeof indexedDB>"u"?[]:await Uu([br],"readonly",t=>t.objectStore(br).getAll())??[]}async function goe(e){const t=qu();return t?t.get(e):typeof indexedDB>"u"?null:await Uu([Vs],"readonly",n=>n.objectStore(Vs).get(e))??null}async function eR(e){const t=qu();if(t){await t.put(e);return}if(typeof indexedDB>"u")throw new Error("Local audio storage is unavailable in this browser.");await Uu([Vs,br],"readwrite",n=>{n.objectStore(Vs).put(e),n.objectStore(br).put(Eu(e))})}async function yoe(e,t){const n=qu();if(n){const s=await n.get(e);s&&await n.put({...s,name:t});return}if(typeof indexedDB>"u")throw new Error("Local audio storage is unavailable in this browser.");await Uu([Vs,br],"readwrite",s=>{const a=s.objectStore(Vs),o=a.get(e);o.onsuccess=()=>{const i=o.result;if(!i)return;const c={...i,name:t};a.put(c),s.objectStore(br).put(Eu(c))}})}async function woe(e){const t=qu();if(t){await t.remove(e);return}typeof indexedDB>"u"||await Uu([Vs,br],"readwrite",n=>{n.objectStore(Vs).delete(e),n.objectStore(br).delete(e)})}const tu=["done","needs-input"],xoe=[{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}]}],voe=[{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}]}],Pj={done:xoe,"needs-input":voe},Vn="two";function J0(e,t){const n=Pj[e];return n.find(s=>s.id===t)??n.find(s=>s.id===Vn)??n[0]}function CD(e,t){return Pj[e].some(s=>s.id===t)?t:Vn}J0("done",Vn).notes,J0("needs-input",Vn).notes;const tR=.04,ED=.24,Hh=0,Lf=100,Dj=5,Jo=50;function Cp(e,t=Dj){if(!Number.isFinite(e))return Jo;const n=Math.round(e/t)*t;return Math.min(Lf,Math.max(Hh,n))}function TD(e,t=Dj){if(e==null)return Jo;const n=e.trim();return/^-?\d+(\.\d+)?$/.test(n)?Cp(Number(n),t):Jo}function Fj(e){const t=Cp(e),n=tR+(ED-tR)*(t/Lf);return Math.round(n*1e4)/1e4}function boe(e,t){const n=t.trim,s=typeof n=="number"&&Number.isFinite(n)&&n>0&&n<=1?n:1;return Math.round(Fj(e)*s*1e4)/1e4}const koe=.012,nR=1e-4;function joe(e){return Math.min(1,Fj(e)/ED)}function Noe(e,t){const n=e*(Fj(t)/jD);return Math.max(1e-4,n)}const Soe=160,_oe="agent-dag.soundLevel.done",Coe="agent-dag.soundLevel.needs-input",Eoe="agent-dag.soundFigure.done",Toe="agent-dag.soundFigure.needs-input",RD={done:_oe,"needs-input":Coe},If={done:Eoe,"needs-input":Toe},sR={done:{level:Jo,figure:Vn},"needs-input":{level:Jo,figure:Vn}};function Roe(e){const t=n=>({level:TD(e(RD[n])),figure:CD(n,e(If[n]))});return{done:t("done"),"needs-input":t("needs-input")}}function Aoe(e,t){return(e??sR)[t]??sR[t]}const Moe={Stop:"done",Notification:"needs-input"};function $oe(e,t){var s;if(t)return null;const n=(s=e==null?void 0:e.payload)==null?void 0:s.hook_event_name;return typeof n!="string"?null:Kt(Moe,n)??null}const Loe=6,Ioe="ccdeck-tabs";function Ooe(e){return e>=Loe}function Poe(e,t,n){const s=a=>{const o=a.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",s),{ask(a,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)},a)})},leave(){var a;e.removeEventListener("message",s),(a=e.close)==null||a.call(e)}}}function Doe({stateRef:e,rerender:t,pauseGate:n,chimesRef:s,desktopUpdateRef:a}){const[o,i]=y.useState(!1),[c,d]=y.useState(!1),[h,f]=y.useState(!1),p=y.useRef(!0),[m,w]=y.useState(null);return y.useEffect(()=>{const j=new EventSource("/events"),v=eoe(t,{now:()=>Date.now(),setTimeout:(S,_)=>window.setTimeout(S,_),clearTimeout:S=>window.clearTimeout(S)});let b=!1;const k=typeof BroadcastChannel=="function"?Poe(new BroadcastChannel(Ioe),Math.random().toString(36).slice(2),()=>b):null,N=window.setInterval(()=>{b||!k||k.ask(600).then(S=>{b||d(Ooe(S))})},3e3);return j.addEventListener("open",()=>{i(!0),f(!0)}),j.addEventListener("error",()=>{i(!1),w(null)}),j.addEventListener("open",()=>{b=!0,d(!1)}),j.addEventListener("error",()=>{b=!1}),j.addEventListener("replay-end",()=>{p.current=!1,v.flush(),w(Date.now())}),j.addEventListener("desktop-update",S=>a.current(S.data)),j.addEventListener("hook",S=>{var _;try{const E=JSON.parse(S.data);if(!n.accept(E))return;e.current=E3(e.current,E);const I=E.replay===!0||p.current||Date.now()-E.receivedAt>3e4;I?v.replay():v.live();const A=$oe(E,I);A&&((_=s.current)==null||_.play(A))}catch{}}),()=>{j.close(),v.cancel(),window.clearInterval(N),k==null||k.leave()}},[t]),{live:o,tabCapped:c,everConnected:h,liveSince:m}}const Foe=200,Boe=5*6e4,qoe=6,Uoe=2*6e4;function Sh(e,t){if(t.size!==0)for(const n of Array.from(e.keys()))t.has(n)||e.delete(n)}function Woe(e,t){let n=!1;for(const a of e)if(!t.has(a)){n=!0;break}if(!n)return e;const s=new Set;for(const a of e)t.has(a)&&s.add(a);return s}function Hoe(e){const t=new Set;for(const n of e)t.add(n.id),t.add(`group:${n.sessionId}`),n.kind==="root"&&t.add(Y1(n.id));return t}function zoe(e){const t=new Set;for(const n of e)t.add(n.id),n.kind==="root"&&t.add(Y1(n.id));return t}function Voe(e,t){let n=X7(e,t,DC);Z7(e,t,DC)&&(n=!0);const s=[],a=o=>{s.push(o)};return G7(e,t,Foe,Boe,a)&&(n=!0),K7(e,t,qoe,Uoe,a)&&(n=!0),{changed:n,forgotten:s}}function Goe(e,t,n){if(!n)return{ids:new Set([t]),primary:t};const s=new Set(e.ids);if(!s.has(t))return s.add(t),{ids:s,primary:t};if(s.delete(t),e.primary!==t)return{ids:s,primary:e.primary};let a=null;for(const o of s)a=o;return{ids:s,primary:a}}function Koe(e,t){const[n,s]=y.useState(()=>({ids:new Set,primary:null})),{ids:a,primary:o}=n,i=y.useCallback((h,f,p=!f)=>{s(m=>Goe(m,h,f)),!f&&p&&t(!0)},[]),c=y.useCallback(()=>{s({ids:new Set,primary:null})},[]),d=y.useCallback(()=>{s(h=>{const f=Woe(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:a,primarySelectedId:o,selectAgent:i,clearSelection:c,pruneSelectionToBoard:d}}function Yoe({stateRef:e,rerender:t,pruneSelectionToBoard:n,setContextFor:s,setSummaryFor:a}){const[o,i]=y.useState(Date.now());return y.useEffect(()=>{const c=setInterval(()=>{const d=Date.now();i(d);const{changed:h,forgotten:f}=Voe(e.current,d);f.length>0&&fetch("/api/forget",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({ids:f})}).catch(()=>{}),n(),s(p=>p!=null&&!e.current.agents.has(p)?null:p),a(p=>p!=null&&!e.current.agents.has(p)?null:p),h&&t()},250);return()=>clearInterval(c)},[t]),o}function Bj(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 my,rR;function Xoe(){if(rR)return my;rR=1;function e(){this.__data__=[],this.size=0}return my=e,my}var gy,aR;function Rl(){if(aR)return gy;aR=1;function e(t,n){return t===n||t!==t&&n!==n}return gy=e,gy}var yy,oR;function Ep(){if(oR)return yy;oR=1;var e=Rl();function t(n,s){for(var a=n.length;a--;)if(e(n[a][0],s))return a;return-1}return yy=t,yy}var wy,iR;function Zoe(){if(iR)return wy;iR=1;var e=Ep(),t=Array.prototype,n=t.splice;function s(a){var o=this.__data__,i=e(o,a);if(i<0)return!1;var c=o.length-1;return i==c?o.pop():n.call(o,i,1),--this.size,!0}return wy=s,wy}var xy,lR;function Joe(){if(lR)return xy;lR=1;var e=Ep();function t(n){var s=this.__data__,a=e(s,n);return a<0?void 0:s[a][1]}return xy=t,xy}var vy,cR;function Qoe(){if(cR)return vy;cR=1;var e=Ep();function t(n){return e(this.__data__,n)>-1}return vy=t,vy}var by,uR;function eie(){if(uR)return by;uR=1;var e=Ep();function t(n,s){var a=this.__data__,o=e(a,n);return o<0?(++this.size,a.push([n,s])):a[o][1]=s,this}return by=t,by}var ky,dR;function Tp(){if(dR)return ky;dR=1;var e=Xoe(),t=Zoe(),n=Joe(),s=Qoe(),a=eie();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=s,o.prototype.set=a,ky=o,ky}var jy,hR;function tie(){if(hR)return jy;hR=1;var e=Tp();function t(){this.__data__=new e,this.size=0}return jy=t,jy}var Ny,fR;function nie(){if(fR)return Ny;fR=1;function e(t){var n=this.__data__,s=n.delete(t);return this.size=n.size,s}return Ny=e,Ny}var Sy,pR;function sie(){if(pR)return Sy;pR=1;function e(t){return this.__data__.get(t)}return Sy=e,Sy}var _y,mR;function rie(){if(mR)return _y;mR=1;function e(t){return this.__data__.has(t)}return _y=e,_y}var Cy,gR;function AD(){if(gR)return Cy;gR=1;var e=typeof Jd=="object"&&Jd&&Jd.Object===Object&&Jd;return Cy=e,Cy}var Ey,yR;function Ys(){if(yR)return Ey;yR=1;var e=AD(),t=typeof self=="object"&&self&&self.Object===Object&&self,n=e||t||Function("return this")();return Ey=n,Ey}var Ty,wR;function Al(){if(wR)return Ty;wR=1;var e=Ys(),t=e.Symbol;return Ty=t,Ty}var Ry,xR;function aie(){if(xR)return Ry;xR=1;var e=Al(),t=Object.prototype,n=t.hasOwnProperty,s=t.toString,a=e?e.toStringTag:void 0;function o(i){var c=n.call(i,a),d=i[a];try{i[a]=void 0;var h=!0}catch{}var f=s.call(i);return h&&(c?i[a]=d:delete i[a]),f}return Ry=o,Ry}var Ay,vR;function oie(){if(vR)return Ay;vR=1;var e=Object.prototype,t=e.toString;function n(s){return t.call(s)}return Ay=n,Ay}var My,bR;function ei(){if(bR)return My;bR=1;var e=Al(),t=aie(),n=oie(),s="[object Null]",a="[object Undefined]",o=e?e.toStringTag:void 0;function i(c){return c==null?c===void 0?a:s:o&&o in Object(c)?t(c):n(c)}return My=i,My}var $y,kR;function vs(){if(kR)return $y;kR=1;function e(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}return $y=e,$y}var Ly,jR;function Wu(){if(jR)return Ly;jR=1;var e=ei(),t=vs(),n="[object AsyncFunction]",s="[object Function]",a="[object GeneratorFunction]",o="[object Proxy]";function i(c){if(!t(c))return!1;var d=e(c);return d==s||d==a||d==n||d==o}return Ly=i,Ly}var Iy,NR;function iie(){if(NR)return Iy;NR=1;var e=Ys(),t=e["__core-js_shared__"];return Iy=t,Iy}var Oy,SR;function lie(){if(SR)return Oy;SR=1;var e=iie(),t=(function(){var s=/[^.]+$/.exec(e&&e.keys&&e.keys.IE_PROTO||"");return s?"Symbol(src)_1."+s:""})();function n(s){return!!t&&t in s}return Oy=n,Oy}var Py,_R;function MD(){if(_R)return Py;_R=1;var e=Function.prototype,t=e.toString;function n(s){if(s!=null){try{return t.call(s)}catch{}try{return s+""}catch{}}return""}return Py=n,Py}var Dy,CR;function cie(){if(CR)return Dy;CR=1;var e=Wu(),t=lie(),n=vs(),s=MD(),a=/[\\^$.*+?()[\]{}|]/g,o=/^\[object .+?Constructor\]$/,i=Function.prototype,c=Object.prototype,d=i.toString,h=c.hasOwnProperty,f=RegExp("^"+d.call(h).replace(a,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function p(m){if(!n(m)||t(m))return!1;var w=e(m)?f:o;return w.test(s(m))}return Dy=p,Dy}var Fy,ER;function uie(){if(ER)return Fy;ER=1;function e(t,n){return t==null?void 0:t[n]}return Fy=e,Fy}var By,TR;function ti(){if(TR)return By;TR=1;var e=cie(),t=uie();function n(s,a){var o=t(s,a);return e(o)?o:void 0}return By=n,By}var qy,RR;function qj(){if(RR)return qy;RR=1;var e=ti(),t=Ys(),n=e(t,"Map");return qy=n,qy}var Uy,AR;function Rp(){if(AR)return Uy;AR=1;var e=ti(),t=e(Object,"create");return Uy=t,Uy}var Wy,MR;function die(){if(MR)return Wy;MR=1;var e=Rp();function t(){this.__data__=e?e(null):{},this.size=0}return Wy=t,Wy}var Hy,$R;function hie(){if($R)return Hy;$R=1;function e(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n}return Hy=e,Hy}var zy,LR;function fie(){if(LR)return zy;LR=1;var e=Rp(),t="__lodash_hash_undefined__",n=Object.prototype,s=n.hasOwnProperty;function a(o){var i=this.__data__;if(e){var c=i[o];return c===t?void 0:c}return s.call(i,o)?i[o]:void 0}return zy=a,zy}var Vy,IR;function pie(){if(IR)return Vy;IR=1;var e=Rp(),t=Object.prototype,n=t.hasOwnProperty;function s(a){var o=this.__data__;return e?o[a]!==void 0:n.call(o,a)}return Vy=s,Vy}var Gy,OR;function mie(){if(OR)return Gy;OR=1;var e=Rp(),t="__lodash_hash_undefined__";function n(s,a){var o=this.__data__;return this.size+=this.has(s)?0:1,o[s]=e&&a===void 0?t:a,this}return Gy=n,Gy}var Ky,PR;function gie(){if(PR)return Ky;PR=1;var e=die(),t=hie(),n=fie(),s=pie(),a=mie();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=s,o.prototype.set=a,Ky=o,Ky}var Yy,DR;function yie(){if(DR)return Yy;DR=1;var e=gie(),t=Tp(),n=qj();function s(){this.size=0,this.__data__={hash:new e,map:new(n||t),string:new e}}return Yy=s,Yy}var Xy,FR;function wie(){if(FR)return Xy;FR=1;function e(t){var n=typeof t;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?t!=="__proto__":t===null}return Xy=e,Xy}var Zy,BR;function Ap(){if(BR)return Zy;BR=1;var e=wie();function t(n,s){var a=n.__data__;return e(s)?a[typeof s=="string"?"string":"hash"]:a.map}return Zy=t,Zy}var Jy,qR;function xie(){if(qR)return Jy;qR=1;var e=Ap();function t(n){var s=e(this,n).delete(n);return this.size-=s?1:0,s}return Jy=t,Jy}var Qy,UR;function vie(){if(UR)return Qy;UR=1;var e=Ap();function t(n){return e(this,n).get(n)}return Qy=t,Qy}var ew,WR;function bie(){if(WR)return ew;WR=1;var e=Ap();function t(n){return e(this,n).has(n)}return ew=t,ew}var tw,HR;function kie(){if(HR)return tw;HR=1;var e=Ap();function t(n,s){var a=e(this,n),o=a.size;return a.set(n,s),this.size+=a.size==o?0:1,this}return tw=t,tw}var nw,zR;function Uj(){if(zR)return nw;zR=1;var e=yie(),t=xie(),n=vie(),s=bie(),a=kie();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=s,o.prototype.set=a,nw=o,nw}var sw,VR;function jie(){if(VR)return sw;VR=1;var e=Tp(),t=qj(),n=Uj(),s=200;function a(o,i){var c=this.__data__;if(c instanceof e){var d=c.__data__;if(!t||d.length<s-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 sw=a,sw}var rw,GR;function Mp(){if(GR)return rw;GR=1;var e=Tp(),t=tie(),n=nie(),s=sie(),a=rie(),o=jie();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=s,i.prototype.has=a,i.prototype.set=o,rw=i,rw}var aw,KR;function Wj(){if(KR)return aw;KR=1;function e(t,n){for(var s=-1,a=t==null?0:t.length;++s<a&&n(t[s],s,t)!==!1;);return t}return aw=e,aw}var ow,YR;function $D(){if(YR)return ow;YR=1;var e=ti(),t=(function(){try{var n=e(Object,"defineProperty");return n({},"",{}),n}catch{}})();return ow=t,ow}var iw,XR;function $p(){if(XR)return iw;XR=1;var e=$D();function t(n,s,a){s=="__proto__"&&e?e(n,s,{configurable:!0,enumerable:!0,value:a,writable:!0}):n[s]=a}return iw=t,iw}var lw,ZR;function Lp(){if(ZR)return lw;ZR=1;var e=$p(),t=Rl(),n=Object.prototype,s=n.hasOwnProperty;function a(o,i,c){var d=o[i];(!(s.call(o,i)&&t(d,c))||c===void 0&&!(i in o))&&e(o,i,c)}return lw=a,lw}var cw,JR;function Hu(){if(JR)return cw;JR=1;var e=Lp(),t=$p();function n(s,a,o,i){var c=!o;o||(o={});for(var d=-1,h=a.length;++d<h;){var f=a[d],p=i?i(o[f],s[f],f,o,s):void 0;p===void 0&&(p=s[f]),c?t(o,f,p):e(o,f,p)}return o}return cw=n,cw}var uw,QR;function Nie(){if(QR)return uw;QR=1;function e(t,n){for(var s=-1,a=Array(t);++s<t;)a[s]=n(s);return a}return uw=e,uw}var dw,eA;function Nr(){if(eA)return dw;eA=1;function e(t){return t!=null&&typeof t=="object"}return dw=e,dw}var hw,tA;function Sie(){if(tA)return hw;tA=1;var e=ei(),t=Nr(),n="[object Arguments]";function s(a){return t(a)&&e(a)==n}return hw=s,hw}var fw,nA;function zu(){if(nA)return fw;nA=1;var e=Sie(),t=Nr(),n=Object.prototype,s=n.hasOwnProperty,a=n.propertyIsEnumerable,o=e((function(){return arguments})())?e:function(i){return t(i)&&s.call(i,"callee")&&!a.call(i,"callee")};return fw=o,fw}var pw,sA;function Ut(){if(sA)return pw;sA=1;var e=Array.isArray;return pw=e,pw}var qc={exports:{}},mw,rA;function _ie(){if(rA)return mw;rA=1;function e(){return!1}return mw=e,mw}qc.exports;var aA;function Ml(){return aA||(aA=1,(function(e,t){var n=Ys(),s=_ie(),a=t&&!t.nodeType&&t,o=a&&!0&&e&&!e.nodeType&&e,i=o&&o.exports===a,c=i?n.Buffer:void 0,d=c?c.isBuffer:void 0,h=d||s;e.exports=h})(qc,qc.exports)),qc.exports}var gw,oA;function Ip(){if(oA)return gw;oA=1;var e=9007199254740991,t=/^(?:0|[1-9]\d*)$/;function n(s,a){var o=typeof s;return a=a??e,!!a&&(o=="number"||o!="symbol"&&t.test(s))&&s>-1&&s%1==0&&s<a}return gw=n,gw}var yw,iA;function Hj(){if(iA)return yw;iA=1;var e=9007199254740991;function t(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=e}return yw=t,yw}var ww,lA;function Cie(){if(lA)return ww;lA=1;var e=ei(),t=Hj(),n=Nr(),s="[object Arguments]",a="[object Array]",o="[object Boolean]",i="[object Date]",c="[object Error]",d="[object Function]",h="[object Map]",f="[object Number]",p="[object Object]",m="[object RegExp]",w="[object Set]",j="[object String]",v="[object WeakMap]",b="[object ArrayBuffer]",k="[object DataView]",N="[object Float32Array]",S="[object Float64Array]",_="[object Int8Array]",E="[object Int16Array]",I="[object Int32Array]",A="[object Uint8Array]",O="[object Uint8ClampedArray]",L="[object Uint16Array]",U="[object Uint32Array]",P={};P[N]=P[S]=P[_]=P[E]=P[I]=P[A]=P[O]=P[L]=P[U]=!0,P[s]=P[a]=P[b]=P[o]=P[k]=P[i]=P[c]=P[d]=P[h]=P[f]=P[p]=P[m]=P[w]=P[j]=P[v]=!1;function T(B){return n(B)&&t(B.length)&&!!P[e(B)]}return ww=T,ww}var xw,cA;function Op(){if(cA)return xw;cA=1;function e(t){return function(n){return t(n)}}return xw=e,xw}var Uc={exports:{}};Uc.exports;var uA;function zj(){return uA||(uA=1,(function(e,t){var n=AD(),s=t&&!t.nodeType&&t,a=s&&!0&&e&&!e.nodeType&&e,o=a&&a.exports===s,i=o&&n.process,c=(function(){try{var d=a&&a.require&&a.require("util").types;return d||i&&i.binding&&i.binding("util")}catch{}})();e.exports=c})(Uc,Uc.exports)),Uc.exports}var vw,dA;function Vu(){if(dA)return vw;dA=1;var e=Cie(),t=Op(),n=zj(),s=n&&n.isTypedArray,a=s?t(s):e;return vw=a,vw}var bw,hA;function LD(){if(hA)return bw;hA=1;var e=Nie(),t=zu(),n=Ut(),s=Ml(),a=Ip(),o=Vu(),i=Object.prototype,c=i.hasOwnProperty;function d(h,f){var p=n(h),m=!p&&t(h),w=!p&&!m&&s(h),j=!p&&!m&&!w&&o(h),v=p||m||w||j,b=v?e(h.length,String):[],k=b.length;for(var N in h)(f||c.call(h,N))&&!(v&&(N=="length"||w&&(N=="offset"||N=="parent")||j&&(N=="buffer"||N=="byteLength"||N=="byteOffset")||a(N,k)))&&b.push(N);return b}return bw=d,bw}var kw,fA;function Pp(){if(fA)return kw;fA=1;var e=Object.prototype;function t(n){var s=n&&n.constructor,a=typeof s=="function"&&s.prototype||e;return n===a}return kw=t,kw}var jw,pA;function ID(){if(pA)return jw;pA=1;function e(t,n){return function(s){return t(n(s))}}return jw=e,jw}var Nw,mA;function Eie(){if(mA)return Nw;mA=1;var e=ID(),t=e(Object.keys,Object);return Nw=t,Nw}var Sw,gA;function Vj(){if(gA)return Sw;gA=1;var e=Pp(),t=Eie(),n=Object.prototype,s=n.hasOwnProperty;function a(o){if(!e(o))return t(o);var i=[];for(var c in Object(o))s.call(o,c)&&c!="constructor"&&i.push(c);return i}return Sw=a,Sw}var _w,yA;function oa(){if(yA)return _w;yA=1;var e=Wu(),t=Hj();function n(s){return s!=null&&t(s.length)&&!e(s)}return _w=n,_w}var Cw,wA;function no(){if(wA)return Cw;wA=1;var e=LD(),t=Vj(),n=oa();function s(a){return n(a)?e(a):t(a)}return Cw=s,Cw}var Ew,xA;function Tie(){if(xA)return Ew;xA=1;var e=Hu(),t=no();function n(s,a){return s&&e(a,t(a),s)}return Ew=n,Ew}var Tw,vA;function Rie(){if(vA)return Tw;vA=1;function e(t){var n=[];if(t!=null)for(var s in Object(t))n.push(s);return n}return Tw=e,Tw}var Rw,bA;function Aie(){if(bA)return Rw;bA=1;var e=vs(),t=Pp(),n=Rie(),s=Object.prototype,a=s.hasOwnProperty;function o(i){if(!e(i))return n(i);var c=t(i),d=[];for(var h in i)h=="constructor"&&(c||!a.call(i,h))||d.push(h);return d}return Rw=o,Rw}var Aw,kA;function ni(){if(kA)return Aw;kA=1;var e=LD(),t=Aie(),n=oa();function s(a){return n(a)?e(a,!0):t(a)}return Aw=s,Aw}var Mw,jA;function Mie(){if(jA)return Mw;jA=1;var e=Hu(),t=ni();function n(s,a){return s&&e(a,t(a),s)}return Mw=n,Mw}var Wc={exports:{}};Wc.exports;var NA;function OD(){return NA||(NA=1,(function(e,t){var n=Ys(),s=t&&!t.nodeType&&t,a=s&&!0&&e&&!e.nodeType&&e,o=a&&a.exports===s,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,m=c?c(p):new h.constructor(p);return h.copy(m),m}e.exports=d})(Wc,Wc.exports)),Wc.exports}var $w,SA;function PD(){if(SA)return $w;SA=1;function e(t,n){var s=-1,a=t.length;for(n||(n=Array(a));++s<a;)n[s]=t[s];return n}return $w=e,$w}var Lw,_A;function DD(){if(_A)return Lw;_A=1;function e(t,n){for(var s=-1,a=t==null?0:t.length,o=0,i=[];++s<a;){var c=t[s];n(c,s,t)&&(i[o++]=c)}return i}return Lw=e,Lw}var Iw,CA;function FD(){if(CA)return Iw;CA=1;function e(){return[]}return Iw=e,Iw}var Ow,EA;function Gj(){if(EA)return Ow;EA=1;var e=DD(),t=FD(),n=Object.prototype,s=n.propertyIsEnumerable,a=Object.getOwnPropertySymbols,o=a?function(i){return i==null?[]:(i=Object(i),e(a(i),function(c){return s.call(i,c)}))}:t;return Ow=o,Ow}var Pw,TA;function $ie(){if(TA)return Pw;TA=1;var e=Hu(),t=Gj();function n(s,a){return e(s,t(s),a)}return Pw=n,Pw}var Dw,RA;function Kj(){if(RA)return Dw;RA=1;function e(t,n){for(var s=-1,a=n.length,o=t.length;++s<a;)t[o+s]=n[s];return t}return Dw=e,Dw}var Fw,AA;function Dp(){if(AA)return Fw;AA=1;var e=ID(),t=e(Object.getPrototypeOf,Object);return Fw=t,Fw}var Bw,MA;function BD(){if(MA)return Bw;MA=1;var e=Kj(),t=Dp(),n=Gj(),s=FD(),a=Object.getOwnPropertySymbols,o=a?function(i){for(var c=[];i;)e(c,n(i)),i=t(i);return c}:s;return Bw=o,Bw}var qw,$A;function Lie(){if($A)return qw;$A=1;var e=Hu(),t=BD();function n(s,a){return e(s,t(s),a)}return qw=n,qw}var Uw,LA;function qD(){if(LA)return Uw;LA=1;var e=Kj(),t=Ut();function n(s,a,o){var i=a(s);return t(s)?i:e(i,o(s))}return Uw=n,Uw}var Ww,IA;function UD(){if(IA)return Ww;IA=1;var e=qD(),t=Gj(),n=no();function s(a){return e(a,n,t)}return Ww=s,Ww}var Hw,OA;function Iie(){if(OA)return Hw;OA=1;var e=qD(),t=BD(),n=ni();function s(a){return e(a,n,t)}return Hw=s,Hw}var zw,PA;function Oie(){if(PA)return zw;PA=1;var e=ti(),t=Ys(),n=e(t,"DataView");return zw=n,zw}var Vw,DA;function Pie(){if(DA)return Vw;DA=1;var e=ti(),t=Ys(),n=e(t,"Promise");return Vw=n,Vw}var Gw,FA;function WD(){if(FA)return Gw;FA=1;var e=ti(),t=Ys(),n=e(t,"Set");return Gw=n,Gw}var Kw,BA;function Die(){if(BA)return Kw;BA=1;var e=ti(),t=Ys(),n=e(t,"WeakMap");return Kw=n,Kw}var Yw,qA;function $l(){if(qA)return Yw;qA=1;var e=Oie(),t=qj(),n=Pie(),s=WD(),a=Die(),o=ei(),i=MD(),c="[object Map]",d="[object Object]",h="[object Promise]",f="[object Set]",p="[object WeakMap]",m="[object DataView]",w=i(e),j=i(t),v=i(n),b=i(s),k=i(a),N=o;return(e&&N(new e(new ArrayBuffer(1)))!=m||t&&N(new t)!=c||n&&N(n.resolve())!=h||s&&N(new s)!=f||a&&N(new a)!=p)&&(N=function(S){var _=o(S),E=_==d?S.constructor:void 0,I=E?i(E):"";if(I)switch(I){case w:return m;case j:return c;case v:return h;case b:return f;case k:return p}return _}),Yw=N,Yw}var Xw,UA;function Fie(){if(UA)return Xw;UA=1;var e=Object.prototype,t=e.hasOwnProperty;function n(s){var a=s.length,o=new s.constructor(a);return a&&typeof s[0]=="string"&&t.call(s,"index")&&(o.index=s.index,o.input=s.input),o}return Xw=n,Xw}var Zw,WA;function HD(){if(WA)return Zw;WA=1;var e=Ys(),t=e.Uint8Array;return Zw=t,Zw}var Jw,HA;function Yj(){if(HA)return Jw;HA=1;var e=HD();function t(n){var s=new n.constructor(n.byteLength);return new e(s).set(new e(n)),s}return Jw=t,Jw}var Qw,zA;function Bie(){if(zA)return Qw;zA=1;var e=Yj();function t(n,s){var a=s?e(n.buffer):n.buffer;return new n.constructor(a,n.byteOffset,n.byteLength)}return Qw=t,Qw}var ex,VA;function qie(){if(VA)return ex;VA=1;var e=/\w*$/;function t(n){var s=new n.constructor(n.source,e.exec(n));return s.lastIndex=n.lastIndex,s}return ex=t,ex}var tx,GA;function Uie(){if(GA)return tx;GA=1;var e=Al(),t=e?e.prototype:void 0,n=t?t.valueOf:void 0;function s(a){return n?Object(n.call(a)):{}}return tx=s,tx}var nx,KA;function zD(){if(KA)return nx;KA=1;var e=Yj();function t(n,s){var a=s?e(n.buffer):n.buffer;return new n.constructor(a,n.byteOffset,n.length)}return nx=t,nx}var sx,YA;function Wie(){if(YA)return sx;YA=1;var e=Yj(),t=Bie(),n=qie(),s=Uie(),a=zD(),o="[object Boolean]",i="[object Date]",c="[object Map]",d="[object Number]",h="[object RegExp]",f="[object Set]",p="[object String]",m="[object Symbol]",w="[object ArrayBuffer]",j="[object DataView]",v="[object Float32Array]",b="[object Float64Array]",k="[object Int8Array]",N="[object Int16Array]",S="[object Int32Array]",_="[object Uint8Array]",E="[object Uint8ClampedArray]",I="[object Uint16Array]",A="[object Uint32Array]";function O(L,U,P){var T=L.constructor;switch(U){case w:return e(L);case o:case i:return new T(+L);case j:return t(L,P);case v:case b:case k:case N:case S:case _:case E:case I:case A:return a(L,P);case c:return new T;case d:case p:return new T(L);case h:return n(L);case f:return new T;case m:return s(L)}}return sx=O,sx}var rx,XA;function VD(){if(XA)return rx;XA=1;var e=vs(),t=Object.create,n=(function(){function s(){}return function(a){if(!e(a))return{};if(t)return t(a);s.prototype=a;var o=new s;return s.prototype=void 0,o}})();return rx=n,rx}var ax,ZA;function GD(){if(ZA)return ax;ZA=1;var e=VD(),t=Dp(),n=Pp();function s(a){return typeof a.constructor=="function"&&!n(a)?e(t(a)):{}}return ax=s,ax}var ox,JA;function Hie(){if(JA)return ox;JA=1;var e=$l(),t=Nr(),n="[object Map]";function s(a){return t(a)&&e(a)==n}return ox=s,ox}var ix,QA;function zie(){if(QA)return ix;QA=1;var e=Hie(),t=Op(),n=zj(),s=n&&n.isMap,a=s?t(s):e;return ix=a,ix}var lx,e2;function Vie(){if(e2)return lx;e2=1;var e=$l(),t=Nr(),n="[object Set]";function s(a){return t(a)&&e(a)==n}return lx=s,lx}var cx,t2;function Gie(){if(t2)return cx;t2=1;var e=Vie(),t=Op(),n=zj(),s=n&&n.isSet,a=s?t(s):e;return cx=a,cx}var ux,n2;function KD(){if(n2)return ux;n2=1;var e=Mp(),t=Wj(),n=Lp(),s=Tie(),a=Mie(),o=OD(),i=PD(),c=$ie(),d=Lie(),h=UD(),f=Iie(),p=$l(),m=Fie(),w=Wie(),j=GD(),v=Ut(),b=Ml(),k=zie(),N=vs(),S=Gie(),_=no(),E=ni(),I=1,A=2,O=4,L="[object Arguments]",U="[object Array]",P="[object Boolean]",T="[object Date]",B="[object Error]",M="[object Function]",q="[object GeneratorFunction]",$="[object Map]",K="[object Number]",G="[object Object]",z="[object RegExp]",W="[object Set]",D="[object String]",H="[object Symbol]",ee="[object WeakMap]",F="[object ArrayBuffer]",Y="[object DataView]",X="[object Float32Array]",Z="[object Float64Array]",J="[object Int8Array]",ne="[object Int16Array]",ce="[object Int32Array]",he="[object Uint8Array]",le="[object Uint8ClampedArray]",re="[object Uint16Array]",ae="[object Uint32Array]",de={};de[L]=de[U]=de[F]=de[Y]=de[P]=de[T]=de[X]=de[Z]=de[J]=de[ne]=de[ce]=de[$]=de[K]=de[G]=de[z]=de[W]=de[D]=de[H]=de[he]=de[le]=de[re]=de[ae]=!0,de[B]=de[M]=de[ee]=!1;function Se(pe,me,be,Ce,ye,Pe){var Oe,We=me&I,Re=me&A,st=me&O;if(be&&(Oe=ye?be(pe,Ce,ye,Pe):be(pe)),Oe!==void 0)return Oe;if(!N(pe))return pe;var je=v(pe);if(je){if(Oe=m(pe),!We)return i(pe,Oe)}else{var Te=p(pe),$e=Te==M||Te==q;if(b(pe))return o(pe,We);if(Te==G||Te==L||$e&&!ye){if(Oe=Re||$e?{}:j(pe),!We)return Re?d(pe,a(Oe,pe)):c(pe,s(Oe,pe))}else{if(!de[Te])return ye?pe:{};Oe=w(pe,Te,We)}}Pe||(Pe=new e);var Ge=Pe.get(pe);if(Ge)return Ge;Pe.set(pe,Oe),S(pe)?pe.forEach(function(it){Oe.add(Se(it,me,be,it,pe,Pe))}):k(pe)&&pe.forEach(function(it,nt){Oe.set(nt,Se(it,me,be,nt,pe,Pe))});var tt=st?Re?f:h:Re?E:_,ht=je?void 0:tt(pe);return t(ht||pe,function(it,nt){ht&&(nt=it,it=pe[nt]),n(Oe,nt,Se(it,me,be,nt,pe,Pe))}),Oe}return ux=Se,ux}var dx,s2;function Kie(){if(s2)return dx;s2=1;var e=KD(),t=4;function n(s){return e(s,t)}return dx=n,dx}var hx,r2;function Xj(){if(r2)return hx;r2=1;function e(t){return function(){return t}}return hx=e,hx}var fx,a2;function Yie(){if(a2)return fx;a2=1;function e(t){return function(n,s,a){for(var o=-1,i=Object(n),c=a(n),d=c.length;d--;){var h=c[t?d:++o];if(s(i[h],h,i)===!1)break}return n}}return fx=e,fx}var px,o2;function Zj(){if(o2)return px;o2=1;var e=Yie(),t=e();return px=t,px}var mx,i2;function Jj(){if(i2)return mx;i2=1;var e=Zj(),t=no();function n(s,a){return s&&e(s,a,t)}return mx=n,mx}var gx,l2;function Xie(){if(l2)return gx;l2=1;var e=oa();function t(n,s){return function(a,o){if(a==null)return a;if(!e(a))return n(a,o);for(var i=a.length,c=s?i:-1,d=Object(a);(s?c--:++c<i)&&o(d[c],c,d)!==!1;);return a}}return gx=t,gx}var yx,c2;function Fp(){if(c2)return yx;c2=1;var e=Jj(),t=Xie(),n=t(e);return yx=n,yx}var wx,u2;function si(){if(u2)return wx;u2=1;function e(t){return t}return wx=e,wx}var xx,d2;function YD(){if(d2)return xx;d2=1;var e=si();function t(n){return typeof n=="function"?n:e}return xx=t,xx}var vx,h2;function XD(){if(h2)return vx;h2=1;var e=Wj(),t=Fp(),n=YD(),s=Ut();function a(o,i){var c=s(o)?e:t;return c(o,n(i))}return vx=a,vx}var bx,f2;function ZD(){return f2||(f2=1,bx=XD()),bx}var kx,p2;function Zie(){if(p2)return kx;p2=1;var e=Fp();function t(n,s){var a=[];return e(n,function(o,i,c){s(o,i,c)&&a.push(o)}),a}return kx=t,kx}var jx,m2;function Jie(){if(m2)return jx;m2=1;var e="__lodash_hash_undefined__";function t(n){return this.__data__.set(n,e),this}return jx=t,jx}var Nx,g2;function Qie(){if(g2)return Nx;g2=1;function e(t){return this.__data__.has(t)}return Nx=e,Nx}var Sx,y2;function JD(){if(y2)return Sx;y2=1;var e=Uj(),t=Jie(),n=Qie();function s(a){var o=-1,i=a==null?0:a.length;for(this.__data__=new e;++o<i;)this.add(a[o])}return s.prototype.add=s.prototype.push=t,s.prototype.has=n,Sx=s,Sx}var _x,w2;function ele(){if(w2)return _x;w2=1;function e(t,n){for(var s=-1,a=t==null?0:t.length;++s<a;)if(n(t[s],s,t))return!0;return!1}return _x=e,_x}var Cx,x2;function QD(){if(x2)return Cx;x2=1;function e(t,n){return t.has(n)}return Cx=e,Cx}var Ex,v2;function eF(){if(v2)return Ex;v2=1;var e=JD(),t=ele(),n=QD(),s=1,a=2;function o(i,c,d,h,f,p){var m=d&s,w=i.length,j=c.length;if(w!=j&&!(m&&j>w))return!1;var v=p.get(i),b=p.get(c);if(v&&b)return v==c&&b==i;var k=-1,N=!0,S=d&a?new e:void 0;for(p.set(i,c),p.set(c,i);++k<w;){var _=i[k],E=c[k];if(h)var I=m?h(E,_,k,c,i,p):h(_,E,k,i,c,p);if(I!==void 0){if(I)continue;N=!1;break}if(S){if(!t(c,function(A,O){if(!n(S,O)&&(_===A||f(_,A,d,h,p)))return S.push(O)})){N=!1;break}}else if(!(_===E||f(_,E,d,h,p))){N=!1;break}}return p.delete(i),p.delete(c),N}return Ex=o,Ex}var Tx,b2;function tle(){if(b2)return Tx;b2=1;function e(t){var n=-1,s=Array(t.size);return t.forEach(function(a,o){s[++n]=[o,a]}),s}return Tx=e,Tx}var Rx,k2;function Qj(){if(k2)return Rx;k2=1;function e(t){var n=-1,s=Array(t.size);return t.forEach(function(a){s[++n]=a}),s}return Rx=e,Rx}var Ax,j2;function nle(){if(j2)return Ax;j2=1;var e=Al(),t=HD(),n=Rl(),s=eF(),a=tle(),o=Qj(),i=1,c=2,d="[object Boolean]",h="[object Date]",f="[object Error]",p="[object Map]",m="[object Number]",w="[object RegExp]",j="[object Set]",v="[object String]",b="[object Symbol]",k="[object ArrayBuffer]",N="[object DataView]",S=e?e.prototype:void 0,_=S?S.valueOf:void 0;function E(I,A,O,L,U,P,T){switch(O){case N:if(I.byteLength!=A.byteLength||I.byteOffset!=A.byteOffset)return!1;I=I.buffer,A=A.buffer;case k:return!(I.byteLength!=A.byteLength||!P(new t(I),new t(A)));case d:case h:case m:return n(+I,+A);case f:return I.name==A.name&&I.message==A.message;case w:case v:return I==A+"";case p:var B=a;case j:var M=L&i;if(B||(B=o),I.size!=A.size&&!M)return!1;var q=T.get(I);if(q)return q==A;L|=c,T.set(I,A);var $=s(B(I),B(A),L,U,P,T);return T.delete(I),$;case b:if(_)return _.call(I)==_.call(A)}return!1}return Ax=E,Ax}var Mx,N2;function sle(){if(N2)return Mx;N2=1;var e=UD(),t=1,n=Object.prototype,s=n.hasOwnProperty;function a(o,i,c,d,h,f){var p=c&t,m=e(o),w=m.length,j=e(i),v=j.length;if(w!=v&&!p)return!1;for(var b=w;b--;){var k=m[b];if(!(p?k in i:s.call(i,k)))return!1}var N=f.get(o),S=f.get(i);if(N&&S)return N==i&&S==o;var _=!0;f.set(o,i),f.set(i,o);for(var E=p;++b<w;){k=m[b];var I=o[k],A=i[k];if(d)var O=p?d(A,I,k,i,o,f):d(I,A,k,o,i,f);if(!(O===void 0?I===A||h(I,A,c,d,f):O)){_=!1;break}E||(E=k=="constructor")}if(_&&!E){var L=o.constructor,U=i.constructor;L!=U&&"constructor"in o&&"constructor"in i&&!(typeof L=="function"&&L instanceof L&&typeof U=="function"&&U instanceof U)&&(_=!1)}return f.delete(o),f.delete(i),_}return Mx=a,Mx}var $x,S2;function rle(){if(S2)return $x;S2=1;var e=Mp(),t=eF(),n=nle(),s=sle(),a=$l(),o=Ut(),i=Ml(),c=Vu(),d=1,h="[object Arguments]",f="[object Array]",p="[object Object]",m=Object.prototype,w=m.hasOwnProperty;function j(v,b,k,N,S,_){var E=o(v),I=o(b),A=E?f:a(v),O=I?f:a(b);A=A==h?p:A,O=O==h?p:O;var L=A==p,U=O==p,P=A==O;if(P&&i(v)){if(!i(b))return!1;E=!0,L=!1}if(P&&!L)return _||(_=new e),E||c(v)?t(v,b,k,N,S,_):n(v,b,A,k,N,S,_);if(!(k&d)){var T=L&&w.call(v,"__wrapped__"),B=U&&w.call(b,"__wrapped__");if(T||B){var M=T?v.value():v,q=B?b.value():b;return _||(_=new e),S(M,q,k,N,_)}}return P?(_||(_=new e),s(v,b,k,N,S,_)):!1}return $x=j,$x}var Lx,_2;function tF(){if(_2)return Lx;_2=1;var e=rle(),t=Nr();function n(s,a,o,i,c){return s===a?!0:s==null||a==null||!t(s)&&!t(a)?s!==s&&a!==a:e(s,a,o,i,n,c)}return Lx=n,Lx}var Ix,C2;function ale(){if(C2)return Ix;C2=1;var e=Mp(),t=tF(),n=1,s=2;function a(o,i,c,d){var h=c.length,f=h,p=!d;if(o==null)return!f;for(o=Object(o);h--;){var m=c[h];if(p&&m[2]?m[1]!==o[m[0]]:!(m[0]in o))return!1}for(;++h<f;){m=c[h];var w=m[0],j=o[w],v=m[1];if(p&&m[2]){if(j===void 0&&!(w in o))return!1}else{var b=new e;if(d)var k=d(j,v,w,o,i,b);if(!(k===void 0?t(v,j,n|s,d,b):k))return!1}}return!0}return Ix=a,Ix}var Ox,E2;function nF(){if(E2)return Ox;E2=1;var e=vs();function t(n){return n===n&&!e(n)}return Ox=t,Ox}var Px,T2;function ole(){if(T2)return Px;T2=1;var e=nF(),t=no();function n(s){for(var a=t(s),o=a.length;o--;){var i=a[o],c=s[i];a[o]=[i,c,e(c)]}return a}return Px=n,Px}var Dx,R2;function sF(){if(R2)return Dx;R2=1;function e(t,n){return function(s){return s==null?!1:s[t]===n&&(n!==void 0||t in Object(s))}}return Dx=e,Dx}var Fx,A2;function ile(){if(A2)return Fx;A2=1;var e=ale(),t=ole(),n=sF();function s(a){var o=t(a);return o.length==1&&o[0][2]?n(o[0][0],o[0][1]):function(i){return i===a||e(i,a,o)}}return Fx=s,Fx}var Bx,M2;function Ll(){if(M2)return Bx;M2=1;var e=ei(),t=Nr(),n="[object Symbol]";function s(a){return typeof a=="symbol"||t(a)&&e(a)==n}return Bx=s,Bx}var qx,$2;function eN(){if($2)return qx;$2=1;var e=Ut(),t=Ll(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,s=/^\w*$/;function a(o,i){if(e(o))return!1;var c=typeof o;return c=="number"||c=="symbol"||c=="boolean"||o==null||t(o)?!0:s.test(o)||!n.test(o)||i!=null&&o in Object(i)}return qx=a,qx}var Ux,L2;function lle(){if(L2)return Ux;L2=1;var e=Uj(),t="Expected a function";function n(s,a){if(typeof s!="function"||a!=null&&typeof a!="function")throw new TypeError(t);var o=function(){var i=arguments,c=a?a.apply(this,i):i[0],d=o.cache;if(d.has(c))return d.get(c);var h=s.apply(this,i);return o.cache=d.set(c,h)||d,h};return o.cache=new(n.Cache||e),o}return n.Cache=e,Ux=n,Ux}var Wx,I2;function cle(){if(I2)return Wx;I2=1;var e=lle(),t=500;function n(s){var a=e(s,function(i){return o.size===t&&o.clear(),i}),o=a.cache;return a}return Wx=n,Wx}var Hx,O2;function ule(){if(O2)return Hx;O2=1;var e=cle(),t=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,n=/\\(\\)?/g,s=e(function(a){var o=[];return a.charCodeAt(0)===46&&o.push(""),a.replace(t,function(i,c,d,h){o.push(d?h.replace(n,"$1"):c||i)}),o});return Hx=s,Hx}var zx,P2;function Bp(){if(P2)return zx;P2=1;function e(t,n){for(var s=-1,a=t==null?0:t.length,o=Array(a);++s<a;)o[s]=n(t[s],s,t);return o}return zx=e,zx}var Vx,D2;function dle(){if(D2)return Vx;D2=1;var e=Al(),t=Bp(),n=Ut(),s=Ll(),a=e?e.prototype:void 0,o=a?a.toString:void 0;function i(c){if(typeof c=="string")return c;if(n(c))return t(c,i)+"";if(s(c))return o?o.call(c):"";var d=c+"";return d=="0"&&1/c==-1/0?"-0":d}return Vx=i,Vx}var Gx,F2;function rF(){if(F2)return Gx;F2=1;var e=dle();function t(n){return n==null?"":e(n)}return Gx=t,Gx}var Kx,B2;function qp(){if(B2)return Kx;B2=1;var e=Ut(),t=eN(),n=ule(),s=rF();function a(o,i){return e(o)?o:t(o,i)?[o]:n(s(o))}return Kx=a,Kx}var Yx,q2;function Gu(){if(q2)return Yx;q2=1;var e=Ll();function t(n){if(typeof n=="string"||e(n))return n;var s=n+"";return s=="0"&&1/n==-1/0?"-0":s}return Yx=t,Yx}var Xx,U2;function Up(){if(U2)return Xx;U2=1;var e=qp(),t=Gu();function n(s,a){a=e(a,s);for(var o=0,i=a.length;s!=null&&o<i;)s=s[t(a[o++])];return o&&o==i?s:void 0}return Xx=n,Xx}var Zx,W2;function hle(){if(W2)return Zx;W2=1;var e=Up();function t(n,s,a){var o=n==null?void 0:e(n,s);return o===void 0?a:o}return Zx=t,Zx}var Jx,H2;function fle(){if(H2)return Jx;H2=1;function e(t,n){return t!=null&&n in Object(t)}return Jx=e,Jx}var Qx,z2;function aF(){if(z2)return Qx;z2=1;var e=qp(),t=zu(),n=Ut(),s=Ip(),a=Hj(),o=Gu();function i(c,d,h){d=e(d,c);for(var f=-1,p=d.length,m=!1;++f<p;){var w=o(d[f]);if(!(m=c!=null&&h(c,w)))break;c=c[w]}return m||++f!=p?m:(p=c==null?0:c.length,!!p&&a(p)&&s(w,p)&&(n(c)||t(c)))}return Qx=i,Qx}var ev,V2;function oF(){if(V2)return ev;V2=1;var e=fle(),t=aF();function n(s,a){return s!=null&&t(s,a,e)}return ev=n,ev}var tv,G2;function ple(){if(G2)return tv;G2=1;var e=tF(),t=hle(),n=oF(),s=eN(),a=nF(),o=sF(),i=Gu(),c=1,d=2;function h(f,p){return s(f)&&a(p)?o(i(f),p):function(m){var w=t(m,f);return w===void 0&&w===p?n(m,f):e(p,w,c|d)}}return tv=h,tv}var nv,K2;function iF(){if(K2)return nv;K2=1;function e(t){return function(n){return n==null?void 0:n[t]}}return nv=e,nv}var sv,Y2;function mle(){if(Y2)return sv;Y2=1;var e=Up();function t(n){return function(s){return e(s,n)}}return sv=t,sv}var rv,X2;function gle(){if(X2)return rv;X2=1;var e=iF(),t=mle(),n=eN(),s=Gu();function a(o){return n(o)?e(s(o)):t(o)}return rv=a,rv}var av,Z2;function ia(){if(Z2)return av;Z2=1;var e=ile(),t=ple(),n=si(),s=Ut(),a=gle();function o(i){return typeof i=="function"?i:i==null?n:typeof i=="object"?s(i)?t(i[0],i[1]):e(i):a(i)}return av=o,av}var ov,J2;function lF(){if(J2)return ov;J2=1;var e=DD(),t=Zie(),n=ia(),s=Ut();function a(o,i){var c=s(o)?e:t;return c(o,n(i,3))}return ov=a,ov}var iv,Q2;function yle(){if(Q2)return iv;Q2=1;var e=Object.prototype,t=e.hasOwnProperty;function n(s,a){return s!=null&&t.call(s,a)}return iv=n,iv}var lv,eM;function cF(){if(eM)return lv;eM=1;var e=yle(),t=aF();function n(s,a){return s!=null&&t(s,a,e)}return lv=n,lv}var cv,tM;function wle(){if(tM)return cv;tM=1;var e=Vj(),t=$l(),n=zu(),s=Ut(),a=oa(),o=Ml(),i=Pp(),c=Vu(),d="[object Map]",h="[object Set]",f=Object.prototype,p=f.hasOwnProperty;function m(w){if(w==null)return!0;if(a(w)&&(s(w)||typeof w=="string"||typeof w.splice=="function"||o(w)||c(w)||n(w)))return!w.length;var j=t(w);if(j==d||j==h)return!w.size;if(i(w))return!e(w).length;for(var v in w)if(p.call(w,v))return!1;return!0}return cv=m,cv}var uv,nM;function uF(){if(nM)return uv;nM=1;function e(t){return t===void 0}return uv=e,uv}var dv,sM;function dF(){if(sM)return dv;sM=1;var e=Fp(),t=oa();function n(s,a){var o=-1,i=t(s)?Array(s.length):[];return e(s,function(c,d,h){i[++o]=a(c,d,h)}),i}return dv=n,dv}var hv,rM;function hF(){if(rM)return hv;rM=1;var e=Bp(),t=ia(),n=dF(),s=Ut();function a(o,i){var c=s(o)?e:n;return c(o,t(i,3))}return hv=a,hv}var fv,aM;function xle(){if(aM)return fv;aM=1;function e(t,n,s,a){var o=-1,i=t==null?0:t.length;for(a&&i&&(s=t[++o]);++o<i;)s=n(s,t[o],o,t);return s}return fv=e,fv}var pv,oM;function vle(){if(oM)return pv;oM=1;function e(t,n,s,a,o){return o(t,function(i,c,d){s=a?(a=!1,i):n(s,i,c,d)}),s}return pv=e,pv}var mv,iM;function fF(){if(iM)return mv;iM=1;var e=xle(),t=Fp(),n=ia(),s=vle(),a=Ut();function o(i,c,d){var h=a(i)?e:s,f=arguments.length<3;return h(i,n(c,4),d,f,t)}return mv=o,mv}var gv,lM;function ble(){if(lM)return gv;lM=1;var e=ei(),t=Ut(),n=Nr(),s="[object String]";function a(o){return typeof o=="string"||!t(o)&&n(o)&&e(o)==s}return gv=a,gv}var yv,cM;function kle(){if(cM)return yv;cM=1;var e=iF(),t=e("length");return yv=t,yv}var wv,uM;function jle(){if(uM)return wv;uM=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",s="\\u20d0-\\u20ff",a=t+n+s,o="\\ufe0e\\ufe0f",i="\\u200d",c=RegExp("["+i+e+a+o+"]");function d(h){return c.test(h)}return wv=d,wv}var xv,dM;function Nle(){if(dM)return xv;dM=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",s="\\u20d0-\\u20ff",a=t+n+s,o="\\ufe0e\\ufe0f",i="["+e+"]",c="["+a+"]",d="\\ud83c[\\udffb-\\udfff]",h="(?:"+c+"|"+d+")",f="[^"+e+"]",p="(?:\\ud83c[\\udde6-\\uddff]){2}",m="[\\ud800-\\udbff][\\udc00-\\udfff]",w="\\u200d",j=h+"?",v="["+o+"]?",b="(?:"+w+"(?:"+[f,p,m].join("|")+")"+v+j+")*",k=v+j+b,N="(?:"+[f+c+"?",c,p,m,i].join("|")+")",S=RegExp(d+"(?="+d+")|"+N+k,"g");function _(E){for(var I=S.lastIndex=0;S.test(E);)++I;return I}return xv=_,xv}var vv,hM;function Sle(){if(hM)return vv;hM=1;var e=kle(),t=jle(),n=Nle();function s(a){return t(a)?n(a):e(a)}return vv=s,vv}var bv,fM;function _le(){if(fM)return bv;fM=1;var e=Vj(),t=$l(),n=oa(),s=ble(),a=Sle(),o="[object Map]",i="[object Set]";function c(d){if(d==null)return 0;if(n(d))return s(d)?a(d):d.length;var h=t(d);return h==o||h==i?d.size:e(d).length}return bv=c,bv}var kv,pM;function Cle(){if(pM)return kv;pM=1;var e=Wj(),t=VD(),n=Jj(),s=ia(),a=Dp(),o=Ut(),i=Ml(),c=Wu(),d=vs(),h=Vu();function f(p,m,w){var j=o(p),v=j||i(p)||h(p);if(m=s(m,4),w==null){var b=p&&p.constructor;v?w=j?new b:[]:d(p)?w=c(b)?t(a(p)):{}:w={}}return(v?e:n)(p,function(k,N,S){return m(w,k,N,S)}),w}return kv=f,kv}var jv,mM;function Ele(){if(mM)return jv;mM=1;var e=Al(),t=zu(),n=Ut(),s=e?e.isConcatSpreadable:void 0;function a(o){return n(o)||t(o)||!!(s&&o&&o[s])}return jv=a,jv}var Nv,gM;function tN(){if(gM)return Nv;gM=1;var e=Kj(),t=Ele();function n(s,a,o,i,c){var d=-1,h=s.length;for(o||(o=t),c||(c=[]);++d<h;){var f=s[d];a>0&&o(f)?a>1?n(f,a-1,o,i,c):e(c,f):i||(c[c.length]=f)}return c}return Nv=n,Nv}var Sv,yM;function Tle(){if(yM)return Sv;yM=1;function e(t,n,s){switch(s.length){case 0:return t.call(n);case 1:return t.call(n,s[0]);case 2:return t.call(n,s[0],s[1]);case 3:return t.call(n,s[0],s[1],s[2])}return t.apply(n,s)}return Sv=e,Sv}var _v,wM;function pF(){if(wM)return _v;wM=1;var e=Tle(),t=Math.max;function n(s,a,o){return a=t(a===void 0?s.length-1:a,0),function(){for(var i=arguments,c=-1,d=t(i.length-a,0),h=Array(d);++c<d;)h[c]=i[a+c];c=-1;for(var f=Array(a+1);++c<a;)f[c]=i[c];return f[a]=o(h),e(s,this,f)}}return _v=n,_v}var Cv,xM;function Rle(){if(xM)return Cv;xM=1;var e=Xj(),t=$D(),n=si(),s=t?function(a,o){return t(a,"toString",{configurable:!0,enumerable:!1,value:e(o),writable:!0})}:n;return Cv=s,Cv}var Ev,vM;function Ale(){if(vM)return Ev;vM=1;var e=800,t=16,n=Date.now;function s(a){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 a.apply(void 0,arguments)}}return Ev=s,Ev}var Tv,bM;function mF(){if(bM)return Tv;bM=1;var e=Rle(),t=Ale(),n=t(e);return Tv=n,Tv}var Rv,kM;function Wp(){if(kM)return Rv;kM=1;var e=si(),t=pF(),n=mF();function s(a,o){return n(t(a,o,e),a+"")}return Rv=s,Rv}var Av,jM;function gF(){if(jM)return Av;jM=1;function e(t,n,s,a){for(var o=t.length,i=s+(a?1:-1);a?i--:++i<o;)if(n(t[i],i,t))return i;return-1}return Av=e,Av}var Mv,NM;function Mle(){if(NM)return Mv;NM=1;function e(t){return t!==t}return Mv=e,Mv}var $v,SM;function $le(){if(SM)return $v;SM=1;function e(t,n,s){for(var a=s-1,o=t.length;++a<o;)if(t[a]===n)return a;return-1}return $v=e,$v}var Lv,_M;function Lle(){if(_M)return Lv;_M=1;var e=gF(),t=Mle(),n=$le();function s(a,o,i){return o===o?n(a,o,i):e(a,t,i)}return Lv=s,Lv}var Iv,CM;function Ile(){if(CM)return Iv;CM=1;var e=Lle();function t(n,s){var a=n==null?0:n.length;return!!a&&e(n,s,0)>-1}return Iv=t,Iv}var Ov,EM;function Ole(){if(EM)return Ov;EM=1;function e(t,n,s){for(var a=-1,o=t==null?0:t.length;++a<o;)if(s(n,t[a]))return!0;return!1}return Ov=e,Ov}var Pv,TM;function Ple(){if(TM)return Pv;TM=1;function e(){}return Pv=e,Pv}var Dv,RM;function Dle(){if(RM)return Dv;RM=1;var e=WD(),t=Ple(),n=Qj(),s=1/0,a=e&&1/n(new e([,-0]))[1]==s?function(o){return new e(o)}:t;return Dv=a,Dv}var Fv,AM;function Fle(){if(AM)return Fv;AM=1;var e=JD(),t=Ile(),n=Ole(),s=QD(),a=Dle(),o=Qj(),i=200;function c(d,h,f){var p=-1,m=t,w=d.length,j=!0,v=[],b=v;if(f)j=!1,m=n;else if(w>=i){var k=h?null:a(d);if(k)return o(k);j=!1,m=s,b=new e}else b=h?[]:v;e:for(;++p<w;){var N=d[p],S=h?h(N):N;if(N=f||N!==0?N:0,j&&S===S){for(var _=b.length;_--;)if(b[_]===S)continue e;h&&b.push(S),v.push(N)}else m(b,S,f)||(b!==v&&b.push(S),v.push(N))}return v}return Fv=c,Fv}var Bv,MM;function yF(){if(MM)return Bv;MM=1;var e=oa(),t=Nr();function n(s){return t(s)&&e(s)}return Bv=n,Bv}var qv,$M;function Ble(){if($M)return qv;$M=1;var e=tN(),t=Wp(),n=Fle(),s=yF(),a=t(function(o){return n(e(o,1,s,!0))});return qv=a,qv}var Uv,LM;function qle(){if(LM)return Uv;LM=1;var e=Bp();function t(n,s){return e(s,function(a){return n[a]})}return Uv=t,Uv}var Wv,IM;function wF(){if(IM)return Wv;IM=1;var e=qle(),t=no();function n(s){return s==null?[]:e(s,t(s))}return Wv=n,Wv}var Hv,OM;function bs(){if(OM)return Hv;OM=1;var e;if(typeof Bj=="function")try{e={clone:Kie(),constant:Xj(),each:ZD(),filter:lF(),has:cF(),isArray:Ut(),isEmpty:wle(),isFunction:Wu(),isUndefined:uF(),keys:no(),map:hF(),reduce:fF(),size:_le(),transform:Cle(),union:Ble(),values:wF()}}catch{}return e||(e=window._),Hv=e,Hv}var zv,PM;function nN(){if(PM)return zv;PM=1;var e=bs();zv=a;var t="\0",n="\0",s="";function a(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={}}a.prototype._nodeCount=0,a.prototype._edgeCount=0,a.prototype.isDirected=function(){return this._isDirected},a.prototype.isMultigraph=function(){return this._isMultigraph},a.prototype.isCompound=function(){return this._isCompound},a.prototype.setGraph=function(f){return this._label=f,this},a.prototype.graph=function(){return this._label},a.prototype.setDefaultNodeLabel=function(f){return e.isFunction(f)||(f=e.constant(f)),this._defaultNodeLabelFn=f,this},a.prototype.nodeCount=function(){return this._nodeCount},a.prototype.nodes=function(){return e.keys(this._nodes)},a.prototype.sources=function(){var f=this;return e.filter(this.nodes(),function(p){return e.isEmpty(f._in[p])})},a.prototype.sinks=function(){var f=this;return e.filter(this.nodes(),function(p){return e.isEmpty(f._out[p])})},a.prototype.setNodes=function(f,p){var m=arguments,w=this;return e.each(f,function(j){m.length>1?w.setNode(j,p):w.setNode(j)}),this},a.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)},a.prototype.node=function(f){return this._nodes[f]},a.prototype.hasNode=function(f){return e.has(this._nodes,f)},a.prototype.removeNode=function(f){var p=this;if(e.has(this._nodes,f)){var m=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]),m),delete this._in[f],delete this._preds[f],e.each(e.keys(this._out[f]),m),delete this._out[f],delete this._sucs[f],--this._nodeCount}return this},a.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 m=p;!e.isUndefined(m);m=this.parent(m))if(m===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},a.prototype._removeFromParentsChildList=function(f){delete this._children[this._parent[f]][f]},a.prototype.parent=function(f){if(this._isCompound){var p=this._parent[f];if(p!==n)return p}},a.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[]}},a.prototype.predecessors=function(f){var p=this._preds[f];if(p)return e.keys(p)},a.prototype.successors=function(f){var p=this._sucs[f];if(p)return e.keys(p)},a.prototype.neighbors=function(f){var p=this.predecessors(f);if(p)return e.union(p,this.successors(f))},a.prototype.isLeaf=function(f){var p;return this.isDirected()?p=this.successors(f):p=this.neighbors(f),p.length===0},a.prototype.filterNodes=function(f){var p=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});p.setGraph(this.graph());var m=this;e.each(this._nodes,function(v,b){f(b)&&p.setNode(b,v)}),e.each(this._edgeObjs,function(v){p.hasNode(v.v)&&p.hasNode(v.w)&&p.setEdge(v,m.edge(v))});var w={};function j(v){var b=m.parent(v);return b===void 0||p.hasNode(b)?(w[v]=b,b):b in w?w[b]:j(b)}return this._isCompound&&e.each(p.nodes(),function(v){p.setParent(v,j(v))}),p},a.prototype.setDefaultEdgeLabel=function(f){return e.isFunction(f)||(f=e.constant(f)),this._defaultEdgeLabelFn=f,this},a.prototype.edgeCount=function(){return this._edgeCount},a.prototype.edges=function(){return e.values(this._edgeObjs)},a.prototype.setPath=function(f,p){var m=this,w=arguments;return e.reduce(f,function(j,v){return w.length>1?m.setEdge(j,v,p):m.setEdge(j,v),v}),this},a.prototype.setEdge=function(){var f,p,m,w,j=!1,v=arguments[0];typeof v=="object"&&v!==null&&"v"in v?(f=v.v,p=v.w,m=v.name,arguments.length===2&&(w=arguments[1],j=!0)):(f=v,p=arguments[1],m=arguments[3],arguments.length>2&&(w=arguments[2],j=!0)),f=""+f,p=""+p,e.isUndefined(m)||(m=""+m);var b=c(this._isDirected,f,p,m);if(e.has(this._edgeLabels,b))return j&&(this._edgeLabels[b]=w),this;if(!e.isUndefined(m)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(f),this.setNode(p),this._edgeLabels[b]=j?w:this._defaultEdgeLabelFn(f,p,m);var k=d(this._isDirected,f,p,m);return f=k.v,p=k.w,Object.freeze(k),this._edgeObjs[b]=k,o(this._preds[p],f),o(this._sucs[f],p),this._in[p][b]=k,this._out[f][b]=k,this._edgeCount++,this},a.prototype.edge=function(f,p,m){var w=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,f,p,m);return this._edgeLabels[w]},a.prototype.hasEdge=function(f,p,m){var w=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,f,p,m);return e.has(this._edgeLabels,w)},a.prototype.removeEdge=function(f,p,m){var w=arguments.length===1?h(this._isDirected,arguments[0]):c(this._isDirected,f,p,m),j=this._edgeObjs[w];return j&&(f=j.v,p=j.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},a.prototype.inEdges=function(f,p){var m=this._in[f];if(m){var w=e.values(m);return p?e.filter(w,function(j){return j.v===p}):w}},a.prototype.outEdges=function(f,p){var m=this._out[f];if(m){var w=e.values(m);return p?e.filter(w,function(j){return j.w===p}):w}},a.prototype.nodeEdges=function(f,p){var m=this.inEdges(f,p);if(m)return m.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,m,w){var j=""+p,v=""+m;if(!f&&j>v){var b=j;j=v,v=b}return j+s+v+s+(e.isUndefined(w)?t:w)}function d(f,p,m,w){var j=""+p,v=""+m;if(!f&&j>v){var b=j;j=v,v=b}var k={v:j,w:v};return w&&(k.name=w),k}function h(f,p){return c(f,p.v,p.w,p.name)}return zv}var Vv,DM;function Ule(){return DM||(DM=1,Vv="2.1.8"),Vv}var Gv,FM;function Wle(){return FM||(FM=1,Gv={Graph:nN(),version:Ule()}),Gv}var Kv,BM;function Hle(){if(BM)return Kv;BM=1;var e=bs(),t=nN();Kv={write:n,read:o};function n(i){var c={options:{directed:i.isDirected(),multigraph:i.isMultigraph(),compound:i.isCompound()},nodes:s(i),edges:a(i)};return e.isUndefined(i.graph())||(c.value=e.clone(i.graph())),c}function s(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 a(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 Kv}var Yv,qM;function zle(){if(qM)return Yv;qM=1;var e=bs();Yv=t;function t(n){var s={},a=[],o;function i(c){e.has(s,c)||(s[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&&a.push(o)}),a}return Yv}var Xv,UM;function xF(){if(UM)return Xv;UM=1;var e=bs();Xv=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 s=this._keyIndices[n];if(s!==void 0)return this._arr[s].priority},t.prototype.min=function(){if(this.size()===0)throw new Error("Queue underflow");return this._arr[0].key},t.prototype.add=function(n,s){var a=this._keyIndices;if(n=String(n),!e.has(a,n)){var o=this._arr,i=o.length;return a[n]=i,o.push({key:n,priority:s}),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,s){var a=this._keyIndices[n];if(s>this._arr[a].priority)throw new Error("New priority is greater than current priority. Key: "+n+" Old: "+this._arr[a].priority+" New: "+s);this._arr[a].priority=s,this._decrease(a)},t.prototype._heapify=function(n){var s=this._arr,a=2*n,o=a+1,i=n;a<s.length&&(i=s[a].priority<s[i].priority?a:i,o<s.length&&(i=s[o].priority<s[i].priority?o:i),i!==n&&(this._swap(n,i),this._heapify(i)))},t.prototype._decrease=function(n){for(var s=this._arr,a=s[n].priority,o;n!==0&&(o=n>>1,!(s[o].priority<a));)this._swap(n,o),n=o},t.prototype._swap=function(n,s){var a=this._arr,o=this._keyIndices,i=a[n],c=a[s];a[n]=c,a[s]=i,o[c.key]=n,o[i.key]=s},Xv}var Zv,WM;function vF(){if(WM)return Zv;WM=1;var e=bs(),t=xF();Zv=s;var n=e.constant(1);function s(o,i,c,d){return a(o,String(i),c||n,d||function(h){return o.outEdges(h)})}function a(o,i,c,d){var h={},f=new t,p,m,w=function(j){var v=j.v!==p?j.v:j.w,b=h[v],k=c(j),N=m.distance+k;if(k<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+j+" Weight: "+k);N<b.distance&&(b.distance=N,b.predecessor=p,f.decrease(v,N))};for(o.nodes().forEach(function(j){var v=j===i?0:Number.POSITIVE_INFINITY;h[j]={distance:v},f.add(j,v)});f.size()>0&&(p=f.removeMin(),m=h[p],m.distance!==Number.POSITIVE_INFINITY);)d(p).forEach(w);return h}return Zv}var Jv,HM;function Vle(){if(HM)return Jv;HM=1;var e=vF(),t=bs();Jv=n;function n(s,a,o){return t.transform(s.nodes(),function(i,c){i[c]=e(s,c,a,o)},{})}return Jv}var Qv,zM;function bF(){if(zM)return Qv;zM=1;var e=bs();Qv=t;function t(n){var s=0,a=[],o={},i=[];function c(d){var h=o[d]={onStack:!0,lowlink:s,index:s++};if(a.push(d),n.successors(d).forEach(function(m){e.has(o,m)?o[m].onStack&&(h.lowlink=Math.min(h.lowlink,o[m].index)):(c(m),h.lowlink=Math.min(h.lowlink,o[m].lowlink))}),h.lowlink===h.index){var f=[],p;do p=a.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 Qv}var eb,VM;function Gle(){if(VM)return eb;VM=1;var e=bs(),t=bF();eb=n;function n(s){return e.filter(t(s),function(a){return a.length>1||a.length===1&&s.hasEdge(a[0],a[0])})}return eb}var tb,GM;function Kle(){if(GM)return tb;GM=1;var e=bs();tb=n;var t=e.constant(1);function n(a,o,i){return s(a,o||t,i||function(c){return a.outEdges(c)})}function s(a,o,i){var c={},d=a.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,m=o(f);c[h][p]={distance:m,predecessor:h}})}),d.forEach(function(h){var f=c[h];d.forEach(function(p){var m=c[p];d.forEach(function(w){var j=m[h],v=f[w],b=m[w],k=j.distance+v.distance;k<b.distance&&(b.distance=k,b.predecessor=v.predecessor)})})}),c}return tb}var nb,KM;function kF(){if(KM)return nb;KM=1;var e=bs();nb=t,t.CycleException=n;function t(s){var a={},o={},i=[];function c(d){if(e.has(o,d))throw new n;e.has(a,d)||(o[d]=!0,a[d]=!0,e.each(s.predecessors(d),c),delete o[d],i.push(d))}if(e.each(s.sinks(),c),e.size(a)!==s.nodeCount())throw new n;return i}function n(){}return n.prototype=new Error,nb}var sb,YM;function Yle(){if(YM)return sb;YM=1;var e=kF();sb=t;function t(n){try{e(n)}catch(s){if(s instanceof e.CycleException)return!1;throw s}return!0}return sb}var rb,XM;function jF(){if(XM)return rb;XM=1;var e=bs();rb=t;function t(s,a,o){e.isArray(a)||(a=[a]);var i=(s.isDirected()?s.successors:s.neighbors).bind(s),c=[],d={};return e.each(a,function(h){if(!s.hasNode(h))throw new Error("Graph does not have node: "+h);n(s,h,o==="post",d,i,c)}),c}function n(s,a,o,i,c,d){e.has(i,a)||(i[a]=!0,o||d.push(a),e.each(c(a),function(h){n(s,h,o,i,c,d)}),o&&d.push(a))}return rb}var ab,ZM;function Xle(){if(ZM)return ab;ZM=1;var e=jF();ab=t;function t(n,s){return e(n,s,"post")}return ab}var ob,JM;function Zle(){if(JM)return ob;JM=1;var e=jF();ob=t;function t(n,s){return e(n,s,"pre")}return ob}var ib,QM;function Jle(){if(QM)return ib;QM=1;var e=bs(),t=nN(),n=xF();ib=s;function s(a,o){var i=new t,c={},d=new n,h;function f(m){var w=m.v===h?m.w:m.v,j=d.priority(w);if(j!==void 0){var v=o(m);v<j&&(c[w]=h,d.decrease(w,v))}}if(a.nodeCount()===0)return i;e.each(a.nodes(),function(m){d.add(m,Number.POSITIVE_INFINITY),i.setNode(m)}),d.decrease(a.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: "+a);p=!0}a.nodeEdges(h).forEach(f)}return i}return ib}var lb,e$;function Qle(){return e$||(e$=1,lb={components:zle(),dijkstra:vF(),dijkstraAll:Vle(),findCycles:Gle(),floydWarshall:Kle(),isAcyclic:Yle(),postorder:Xle(),preorder:Zle(),prim:Jle(),tarjan:bF(),topsort:kF()}),lb}var cb,t$;function ece(){if(t$)return cb;t$=1;var e=Wle();return cb={Graph:e.Graph,json:Hle(),alg:Qle(),version:e.version},cb}var ub,n$;function Gs(){if(n$)return ub;n$=1;var e;if(typeof Bj=="function")try{e=ece()}catch{}return e||(e=window.graphlib),ub=e,ub}var db,s$;function tce(){if(s$)return db;s$=1;var e=KD(),t=1,n=4;function s(a){return e(a,t|n)}return db=s,db}var hb,r$;function Hp(){if(r$)return hb;r$=1;var e=Rl(),t=oa(),n=Ip(),s=vs();function a(o,i,c){if(!s(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 hb=a,hb}var fb,a$;function nce(){if(a$)return fb;a$=1;var e=Wp(),t=Rl(),n=Hp(),s=ni(),a=Object.prototype,o=a.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 m=d[h],w=s(m),j=-1,v=w.length;++j<v;){var b=w[j],k=c[b];(k===void 0||t(k,a[b])&&!o.call(c,b))&&(c[b]=m[b])}return c});return fb=i,fb}var pb,o$;function sce(){if(o$)return pb;o$=1;var e=ia(),t=oa(),n=no();function s(a){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=a(o,i,c);return f>-1?d[h?o[f]:f]:void 0}}return pb=s,pb}var mb,i$;function rce(){if(i$)return mb;i$=1;var e=/\s/;function t(n){for(var s=n.length;s--&&e.test(n.charAt(s)););return s}return mb=t,mb}var gb,l$;function ace(){if(l$)return gb;l$=1;var e=rce(),t=/^\s+/;function n(s){return s&&s.slice(0,e(s)+1).replace(t,"")}return gb=n,gb}var yb,c$;function oce(){if(c$)return yb;c$=1;var e=ace(),t=vs(),n=Ll(),s=NaN,a=/^[-+]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 s;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):a.test(h)?s:+h}return yb=d,yb}var wb,u$;function NF(){if(u$)return wb;u$=1;var e=oce(),t=1/0,n=17976931348623157e292;function s(a){if(!a)return a===0?a:0;if(a=e(a),a===t||a===-t){var o=a<0?-1:1;return o*n}return a===a?a:0}return wb=s,wb}var xb,d$;function ice(){if(d$)return xb;d$=1;var e=NF();function t(n){var s=e(n),a=s%1;return s===s?a?s-a:s:0}return xb=t,xb}var vb,h$;function lce(){if(h$)return vb;h$=1;var e=gF(),t=ia(),n=ice(),s=Math.max;function a(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=s(d+h,0)),e(o,t(i,3),h)}return vb=a,vb}var bb,f$;function cce(){if(f$)return bb;f$=1;var e=sce(),t=lce(),n=e(t);return bb=n,bb}var kb,p$;function SF(){if(p$)return kb;p$=1;var e=tN();function t(n){var s=n==null?0:n.length;return s?e(n,1):[]}return kb=t,kb}var jb,m$;function uce(){if(m$)return jb;m$=1;var e=Zj(),t=YD(),n=ni();function s(a,o){return a==null?a:e(a,t(o),n)}return jb=s,jb}var Nb,g$;function dce(){if(g$)return Nb;g$=1;function e(t){var n=t==null?0:t.length;return n?t[n-1]:void 0}return Nb=e,Nb}var Sb,y$;function hce(){if(y$)return Sb;y$=1;var e=$p(),t=Jj(),n=ia();function s(a,o){var i={};return o=n(o,3),t(a,function(c,d,h){e(i,d,o(c,d,h))}),i}return Sb=s,Sb}var _b,w$;function sN(){if(w$)return _b;w$=1;var e=Ll();function t(n,s,a){for(var o=-1,i=n.length;++o<i;){var c=n[o],d=s(c);if(d!=null&&(h===void 0?d===d&&!e(d):a(d,h)))var h=d,f=c}return f}return _b=t,_b}var Cb,x$;function fce(){if(x$)return Cb;x$=1;function e(t,n){return t>n}return Cb=e,Cb}var Eb,v$;function pce(){if(v$)return Eb;v$=1;var e=sN(),t=fce(),n=si();function s(a){return a&&a.length?e(a,n,t):void 0}return Eb=s,Eb}var Tb,b$;function _F(){if(b$)return Tb;b$=1;var e=$p(),t=Rl();function n(s,a,o){(o!==void 0&&!t(s[a],o)||o===void 0&&!(a in s))&&e(s,a,o)}return Tb=n,Tb}var Rb,k$;function mce(){if(k$)return Rb;k$=1;var e=ei(),t=Dp(),n=Nr(),s="[object Object]",a=Function.prototype,o=Object.prototype,i=a.toString,c=o.hasOwnProperty,d=i.call(Object);function h(f){if(!n(f)||e(f)!=s)return!1;var p=t(f);if(p===null)return!0;var m=c.call(p,"constructor")&&p.constructor;return typeof m=="function"&&m instanceof m&&i.call(m)==d}return Rb=h,Rb}var Ab,j$;function CF(){if(j$)return Ab;j$=1;function e(t,n){if(!(n==="constructor"&&typeof t[n]=="function")&&n!="__proto__")return t[n]}return Ab=e,Ab}var Mb,N$;function gce(){if(N$)return Mb;N$=1;var e=Hu(),t=ni();function n(s){return e(s,t(s))}return Mb=n,Mb}var $b,S$;function yce(){if(S$)return $b;S$=1;var e=_F(),t=OD(),n=zD(),s=PD(),a=GD(),o=zu(),i=Ut(),c=yF(),d=Ml(),h=Wu(),f=vs(),p=mce(),m=Vu(),w=CF(),j=gce();function v(b,k,N,S,_,E,I){var A=w(b,N),O=w(k,N),L=I.get(O);if(L){e(b,N,L);return}var U=E?E(A,O,N+"",b,k,I):void 0,P=U===void 0;if(P){var T=i(O),B=!T&&d(O),M=!T&&!B&&m(O);U=O,T||B||M?i(A)?U=A:c(A)?U=s(A):B?(P=!1,U=t(O,!0)):M?(P=!1,U=n(O,!0)):U=[]:p(O)||o(O)?(U=A,o(A)?U=j(A):(!f(A)||h(A))&&(U=a(O))):P=!1}P&&(I.set(O,U),_(U,O,S,E,I),I.delete(O)),e(b,N,U)}return $b=v,$b}var Lb,_$;function wce(){if(_$)return Lb;_$=1;var e=Mp(),t=_F(),n=Zj(),s=yce(),a=vs(),o=ni(),i=CF();function c(d,h,f,p,m){d!==h&&n(h,function(w,j){if(m||(m=new e),a(w))s(d,h,j,f,c,p,m);else{var v=p?p(i(d,j),w,j+"",d,h,m):void 0;v===void 0&&(v=w),t(d,j,v)}},o)}return Lb=c,Lb}var Ib,C$;function xce(){if(C$)return Ib;C$=1;var e=Wp(),t=Hp();function n(s){return e(function(a,o){var i=-1,c=o.length,d=c>1?o[c-1]:void 0,h=c>2?o[2]:void 0;for(d=s.length>3&&typeof d=="function"?(c--,d):void 0,h&&t(o[0],o[1],h)&&(d=c<3?void 0:d,c=1),a=Object(a);++i<c;){var f=o[i];f&&s(a,f,i,d)}return a})}return Ib=n,Ib}var Ob,E$;function vce(){if(E$)return Ob;E$=1;var e=wce(),t=xce(),n=t(function(s,a,o){e(s,a,o)});return Ob=n,Ob}var Pb,T$;function EF(){if(T$)return Pb;T$=1;function e(t,n){return t<n}return Pb=e,Pb}var Db,R$;function bce(){if(R$)return Db;R$=1;var e=sN(),t=EF(),n=si();function s(a){return a&&a.length?e(a,n,t):void 0}return Db=s,Db}var Fb,A$;function kce(){if(A$)return Fb;A$=1;var e=sN(),t=ia(),n=EF();function s(a,o){return a&&a.length?e(a,t(o,2),n):void 0}return Fb=s,Fb}var Bb,M$;function jce(){if(M$)return Bb;M$=1;var e=Ys(),t=function(){return e.Date.now()};return Bb=t,Bb}var qb,$$;function Nce(){if($$)return qb;$$=1;var e=Lp(),t=qp(),n=Ip(),s=vs(),a=Gu();function o(i,c,d,h){if(!s(i))return i;c=t(c,i);for(var f=-1,p=c.length,m=p-1,w=i;w!=null&&++f<p;){var j=a(c[f]),v=d;if(j==="__proto__"||j==="constructor"||j==="prototype")return i;if(f!=m){var b=w[j];v=h?h(b,j,w):void 0,v===void 0&&(v=s(b)?b:n(c[f+1])?[]:{})}e(w,j,v),w=w[j]}return i}return qb=o,qb}var Ub,L$;function Sce(){if(L$)return Ub;L$=1;var e=Up(),t=Nce(),n=qp();function s(a,o,i){for(var c=-1,d=o.length,h={};++c<d;){var f=o[c],p=e(a,f);i(p,f)&&t(h,n(f,a),p)}return h}return Ub=s,Ub}var Wb,I$;function _ce(){if(I$)return Wb;I$=1;var e=Sce(),t=oF();function n(s,a){return e(s,a,function(o,i){return t(s,i)})}return Wb=n,Wb}var Hb,O$;function Cce(){if(O$)return Hb;O$=1;var e=SF(),t=pF(),n=mF();function s(a){return n(t(a,void 0,e),a+"")}return Hb=s,Hb}var zb,P$;function Ece(){if(P$)return zb;P$=1;var e=_ce(),t=Cce(),n=t(function(s,a){return s==null?{}:e(s,a)});return zb=n,zb}var Vb,D$;function Tce(){if(D$)return Vb;D$=1;var e=Math.ceil,t=Math.max;function n(s,a,o,i){for(var c=-1,d=t(e((a-s)/(o||1)),0),h=Array(d);d--;)h[i?d:++c]=s,s+=o;return h}return Vb=n,Vb}var Gb,F$;function Rce(){if(F$)return Gb;F$=1;var e=Tce(),t=Hp(),n=NF();function s(a){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,a)}}return Gb=s,Gb}var Kb,B$;function Ace(){if(B$)return Kb;B$=1;var e=Rce(),t=e();return Kb=t,Kb}var Yb,q$;function Mce(){if(q$)return Yb;q$=1;function e(t,n){var s=t.length;for(t.sort(n);s--;)t[s]=t[s].value;return t}return Yb=e,Yb}var Xb,U$;function $ce(){if(U$)return Xb;U$=1;var e=Ll();function t(n,s){if(n!==s){var a=n!==void 0,o=n===null,i=n===n,c=e(n),d=s!==void 0,h=s===null,f=s===s,p=e(s);if(!h&&!p&&!c&&n>s||c&&d&&f&&!h&&!p||o&&d&&f||!a&&f||!i)return 1;if(!o&&!c&&!p&&n<s||p&&a&&i&&!o&&!c||h&&a&&i||!d&&i||!f)return-1}return 0}return Xb=t,Xb}var Zb,W$;function Lce(){if(W$)return Zb;W$=1;var e=$ce();function t(n,s,a){for(var o=-1,i=n.criteria,c=s.criteria,d=i.length,h=a.length;++o<d;){var f=e(i[o],c[o]);if(f){if(o>=h)return f;var p=a[o];return f*(p=="desc"?-1:1)}}return n.index-s.index}return Zb=t,Zb}var Jb,H$;function Ice(){if(H$)return Jb;H$=1;var e=Bp(),t=Up(),n=ia(),s=dF(),a=Mce(),o=Op(),i=Lce(),c=si(),d=Ut();function h(f,p,m){p.length?p=e(p,function(v){return d(v)?function(b){return t(b,v.length===1?v[0]:v)}:v}):p=[c];var w=-1;p=e(p,o(n));var j=s(f,function(v,b,k){var N=e(p,function(S){return S(v)});return{criteria:N,index:++w,value:v}});return a(j,function(v,b){return i(v,b,m)})}return Jb=h,Jb}var Qb,z$;function Oce(){if(z$)return Qb;z$=1;var e=tN(),t=Ice(),n=Wp(),s=Hp(),a=n(function(o,i){if(o==null)return[];var c=i.length;return c>1&&s(o,i[0],i[1])?i=[]:c>2&&s(i[0],i[1],i[2])&&(i=[i[0]]),t(o,e(i,1),[])});return Qb=a,Qb}var ek,V$;function Pce(){if(V$)return ek;V$=1;var e=rF(),t=0;function n(s){var a=++t;return e(s)+a}return ek=n,ek}var tk,G$;function Dce(){if(G$)return tk;G$=1;function e(t,n,s){for(var a=-1,o=t.length,i=n.length,c={};++a<o;){var d=a<i?n[a]:void 0;s(c,t[a],d)}return c}return tk=e,tk}var nk,K$;function Fce(){if(K$)return nk;K$=1;var e=Lp(),t=Dce();function n(s,a){return t(s||[],a||[],e)}return nk=n,nk}var sk,Y$;function Nt(){if(Y$)return sk;Y$=1;var e;if(typeof Bj=="function")try{e={cloneDeep:tce(),constant:Xj(),defaults:nce(),each:ZD(),filter:lF(),find:cce(),flatten:SF(),forEach:XD(),forIn:uce(),has:cF(),isUndefined:uF(),last:dce(),map:hF(),mapValues:hce(),max:pce(),merge:vce(),min:bce(),minBy:kce(),now:jce(),pick:Ece(),range:Ace(),reduce:fF(),sortBy:Oce(),uniqueId:Pce(),values:wF(),zipObject:Fce()}}catch{}return e||(e=window._),sk=e,sk}var rk,X$;function Bce(){if(X$)return rk;X$=1,rk=e;function e(){var s={};s._next=s._prev=s,this._sentinel=s}e.prototype.dequeue=function(){var s=this._sentinel,a=s._prev;if(a!==s)return t(a),a},e.prototype.enqueue=function(s){var a=this._sentinel;s._prev&&s._next&&t(s),s._next=a._next,a._next._prev=s,a._next=s,s._prev=a},e.prototype.toString=function(){for(var s=[],a=this._sentinel,o=a._prev;o!==a;)s.push(JSON.stringify(o,n)),o=o._prev;return"["+s.join(", ")+"]"};function t(s){s._prev._next=s._next,s._next._prev=s._prev,delete s._next,delete s._prev}function n(s,a){if(s!=="_next"&&s!=="_prev")return a}return rk}var ak,Z$;function qce(){if(Z$)return ak;Z$=1;var e=Nt(),t=Gs().Graph,n=Bce();ak=a;var s=e.constant(1);function a(h,f){if(h.nodeCount()<=1)return[];var p=c(h,f||s),m=o(p.graph,p.buckets,p.zeroIdx);return e.flatten(e.map(m,function(w){return h.outEdges(w.v,w.w)}),!0)}function o(h,f,p){for(var m=[],w=f[f.length-1],j=f[0],v;h.nodeCount();){for(;v=j.dequeue();)i(h,f,p,v);for(;v=w.dequeue();)i(h,f,p,v);if(h.nodeCount()){for(var b=f.length-2;b>0;--b)if(v=f[b].dequeue(),v){m=m.concat(i(h,f,p,v,!0));break}}}return m}function i(h,f,p,m,w){var j=w?[]:void 0;return e.forEach(h.inEdges(m.v),function(v){var b=h.edge(v),k=h.node(v.v);w&&j.push({v:v.v,w:v.w}),k.out-=b,d(f,p,k)}),e.forEach(h.outEdges(m.v),function(v){var b=h.edge(v),k=v.w,N=h.node(k);N.in-=b,d(f,p,N)}),h.removeNode(m.v),j}function c(h,f){var p=new t,m=0,w=0;e.forEach(h.nodes(),function(b){p.setNode(b,{v:b,in:0,out:0})}),e.forEach(h.edges(),function(b){var k=p.edge(b.v,b.w)||0,N=f(b),S=k+N;p.setEdge(b.v,b.w,S),w=Math.max(w,p.node(b.v).out+=N),m=Math.max(m,p.node(b.w).in+=N)});var j=e.range(w+m+3).map(function(){return new n}),v=m+1;return e.forEach(p.nodes(),function(b){d(j,v,p.node(b))}),{graph:p,buckets:j,zeroIdx:v}}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 ak}var ok,J$;function Uce(){if(J$)return ok;J$=1;var e=Nt(),t=qce();ok={run:n,undo:a};function n(o){var i=o.graph().acyclicer==="greedy"?t(o,c(o)):s(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 s(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 a(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 ok}var ik,Q$;function In(){if(Q$)return ik;Q$=1;var e=Nt(),t=Gs().Graph;ik={addDummyNode:n,simplify:s,asNonCompoundGraph:a,successorWeights:o,predecessorWeights:i,intersectRect:c,buildLayerMatrix:d,normalizeRanks:h,removeEmptyRanks:f,addBorderNode:p,maxRank:m,partition:w,time:j,notime:v};function n(b,k,N,S){var _;do _=e.uniqueId(S);while(b.hasNode(_));return N.dummy=k,b.setNode(_,N),_}function s(b){var k=new t().setGraph(b.graph());return e.forEach(b.nodes(),function(N){k.setNode(N,b.node(N))}),e.forEach(b.edges(),function(N){var S=k.edge(N.v,N.w)||{weight:0,minlen:1},_=b.edge(N);k.setEdge(N.v,N.w,{weight:S.weight+_.weight,minlen:Math.max(S.minlen,_.minlen)})}),k}function a(b){var k=new t({multigraph:b.isMultigraph()}).setGraph(b.graph());return e.forEach(b.nodes(),function(N){b.children(N).length||k.setNode(N,b.node(N))}),e.forEach(b.edges(),function(N){k.setEdge(N,b.edge(N))}),k}function o(b){var k=e.map(b.nodes(),function(N){var S={};return e.forEach(b.outEdges(N),function(_){S[_.w]=(S[_.w]||0)+b.edge(_).weight}),S});return e.zipObject(b.nodes(),k)}function i(b){var k=e.map(b.nodes(),function(N){var S={};return e.forEach(b.inEdges(N),function(_){S[_.v]=(S[_.v]||0)+b.edge(_).weight}),S});return e.zipObject(b.nodes(),k)}function c(b,k){var N=b.x,S=b.y,_=k.x-N,E=k.y-S,I=b.width/2,A=b.height/2;if(!_&&!E)throw new Error("Not possible to find intersection inside of the rectangle");var O,L;return Math.abs(E)*I>Math.abs(_)*A?(E<0&&(A=-A),O=A*_/E,L=A):(_<0&&(I=-I),O=I,L=I*E/_),{x:N+O,y:S+L}}function d(b){var k=e.map(e.range(m(b)+1),function(){return[]});return e.forEach(b.nodes(),function(N){var S=b.node(N),_=S.rank;e.isUndefined(_)||(k[_][S.order]=N)}),k}function h(b){var k=e.min(e.map(b.nodes(),function(N){return b.node(N).rank}));e.forEach(b.nodes(),function(N){var S=b.node(N);e.has(S,"rank")&&(S.rank-=k)})}function f(b){var k=e.min(e.map(b.nodes(),function(E){return b.node(E).rank})),N=[];e.forEach(b.nodes(),function(E){var I=b.node(E).rank-k;N[I]||(N[I]=[]),N[I].push(E)});var S=0,_=b.graph().nodeRankFactor;e.forEach(N,function(E,I){e.isUndefined(E)&&I%_!==0?--S:S&&e.forEach(E,function(A){b.node(A).rank+=S})})}function p(b,k,N,S){var _={width:0,height:0};return arguments.length>=4&&(_.rank=N,_.order=S),n(b,"border",_,k)}function m(b){return e.max(e.map(b.nodes(),function(k){var N=b.node(k).rank;if(!e.isUndefined(N))return N}))}function w(b,k){var N={lhs:[],rhs:[]};return e.forEach(b,function(S){k(S)?N.lhs.push(S):N.rhs.push(S)}),N}function j(b,k){var N=e.now();try{return k()}finally{console.log(b+" time: "+(e.now()-N)+"ms")}}function v(b,k){return k()}return ik}var lk,eL;function Wce(){if(eL)return lk;eL=1;var e=Nt(),t=In();lk={run:n,undo:a};function n(o){o.graph().dummyChains=[],e.forEach(o.edges(),function(i){s(o,i)})}function s(o,i){var c=i.v,d=o.node(c).rank,h=i.w,f=o.node(h).rank,p=i.name,m=o.edge(i),w=m.labelRank;if(f!==d+1){o.removeEdge(i);var j,v,b;for(b=0,++d;d<f;++b,++d)m.points=[],v={width:0,height:0,edgeLabel:m,edgeObj:i,rank:d},j=t.addDummyNode(o,"edge",v,"_d"),d===w&&(v.width=m.width,v.height=m.height,v.dummy="edge-label",v.labelpos=m.labelpos),o.setEdge(c,j,{weight:m.weight},p),b===0&&o.graph().dummyChains.push(j),c=j;o.setEdge(c,h,{weight:m.weight},p)}}function a(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 lk}var ck,tL;function Of(){if(tL)return ck;tL=1;var e=Nt();ck={longestPath:t,slack:n};function t(s){var a={};function o(i){var c=s.node(i);if(e.has(a,i))return c.rank;a[i]=!0;var d=e.min(e.map(s.outEdges(i),function(h){return o(h.w)-s.edge(h).minlen}));return(d===Number.POSITIVE_INFINITY||d===void 0||d===null)&&(d=0),c.rank=d}e.forEach(s.sources(),o)}function n(s,a){return s.node(a.w).rank-s.node(a.v).rank-s.edge(a).minlen}return ck}var uk,nL;function TF(){if(nL)return uk;nL=1;var e=Nt(),t=Gs().Graph,n=Of().slack;uk=s;function s(c){var d=new t({directed:!1}),h=c.nodes()[0],f=c.nodeCount();d.setNode(h,{});for(var p,m;a(d,c)<f;)p=o(d,c),m=d.hasNode(p.v)?n(c,p):-n(c,p),i(d,c,m);return d}function a(c,d){function h(f){e.forEach(d.nodeEdges(f),function(p){var m=p.v,w=f===m?p.w:m;!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 uk}var dk,sL;function Hce(){if(sL)return dk;sL=1;var e=Nt(),t=TF(),n=Of().slack,s=Of().longestPath,a=Gs().alg.preorder,o=Gs().alg.postorder,i=In().simplify;dk=c,c.initLowLimValues=p,c.initCutValues=d,c.calcCutValue=f,c.leaveEdge=w,c.enterEdge=j,c.exchangeEdges=v;function c(S){S=i(S),s(S);var _=t(S);p(_),d(_,S);for(var E,I;E=w(_);)I=j(_,S,E),v(_,S,E,I)}function d(S,_){var E=o(S,S.nodes());E=E.slice(0,E.length-1),e.forEach(E,function(I){h(S,_,I)})}function h(S,_,E){var I=S.node(E),A=I.parent;S.edge(E,A).cutvalue=f(S,_,E)}function f(S,_,E){var I=S.node(E),A=I.parent,O=!0,L=_.edge(E,A),U=0;return L||(O=!1,L=_.edge(A,E)),U=L.weight,e.forEach(_.nodeEdges(E),function(P){var T=P.v===E,B=T?P.w:P.v;if(B!==A){var M=T===O,q=_.edge(P).weight;if(U+=M?q:-q,k(S,E,B)){var $=S.edge(E,B).cutvalue;U+=M?-$:$}}}),U}function p(S,_){arguments.length<2&&(_=S.nodes()[0]),m(S,{},1,_)}function m(S,_,E,I,A){var O=E,L=S.node(I);return _[I]=!0,e.forEach(S.neighbors(I),function(U){e.has(_,U)||(E=m(S,_,E,U,I))}),L.low=O,L.lim=E++,A?L.parent=A:delete L.parent,E}function w(S){return e.find(S.edges(),function(_){return S.edge(_).cutvalue<0})}function j(S,_,E){var I=E.v,A=E.w;_.hasEdge(I,A)||(I=E.w,A=E.v);var O=S.node(I),L=S.node(A),U=O,P=!1;O.lim>L.lim&&(U=L,P=!0);var T=e.filter(_.edges(),function(B){return P===N(S,S.node(B.v),U)&&P!==N(S,S.node(B.w),U)});return e.minBy(T,function(B){return n(_,B)})}function v(S,_,E,I){var A=E.v,O=E.w;S.removeEdge(A,O),S.setEdge(I.v,I.w,{}),p(S),d(S,_),b(S,_)}function b(S,_){var E=e.find(S.nodes(),function(A){return!_.node(A).parent}),I=a(S,E);I=I.slice(1),e.forEach(I,function(A){var O=S.node(A).parent,L=_.edge(A,O),U=!1;L||(L=_.edge(O,A),U=!0),_.node(A).rank=_.node(O).rank+(U?L.minlen:-L.minlen)})}function k(S,_,E){return S.hasEdge(_,E)}function N(S,_,E){return E.low<=_.lim&&_.lim<=E.lim}return dk}var hk,rL;function zce(){if(rL)return hk;rL=1;var e=Of(),t=e.longestPath,n=TF(),s=Hce();hk=a;function a(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){s(d)}return hk}var fk,aL;function Vce(){if(aL)return fk;aL=1;var e=Nt();fk=t;function t(a){var o=s(a);e.forEach(a.graph().dummyChains,function(i){for(var c=a.node(i),d=c.edgeObj,h=n(a,o,d.v,d.w),f=h.path,p=h.lca,m=0,w=f[m],j=!0;i!==d.w;){if(c=a.node(i),j){for(;(w=f[m])!==p&&a.node(w).maxRank<c.rank;)m++;w===p&&(j=!1)}if(!j){for(;m<f.length-1&&a.node(w=f[m+1]).minRank<=c.rank;)m++;w=f[m]}a.setParent(i,w),i=a.successors(i)[0]}})}function n(a,o,i,c){var d=[],h=[],f=Math.min(o[i].low,o[c].low),p=Math.max(o[i].lim,o[c].lim),m,w;m=i;do m=a.parent(m),d.push(m);while(m&&(o[m].low>f||p>o[m].lim));for(w=m,m=c;(m=a.parent(m))!==w;)h.push(m);return{path:d.concat(h.reverse()),lca:w}}function s(a){var o={},i=0;function c(d){var h=i;e.forEach(a.children(d),c),o[d]={low:h,lim:i++}}return e.forEach(a.children(),c),o}return fk}var pk,oL;function Gce(){if(oL)return pk;oL=1;var e=Nt(),t=In();pk={run:n,cleanup:i};function n(c){var d=t.addDummyNode(c,"root",{},"_root"),h=a(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 m=o(c)+1;e.forEach(c.children(),function(w){s(c,d,p,m,f,h,w)}),c.graph().nodeRankFactor=p}function s(c,d,h,f,p,m,w){var j=c.children(w);if(!j.length){w!==d&&c.setEdge(d,w,{weight:0,minlen:h});return}var v=t.addBorderNode(c,"_bt"),b=t.addBorderNode(c,"_bb"),k=c.node(w);c.setParent(v,w),k.borderTop=v,c.setParent(b,w),k.borderBottom=b,e.forEach(j,function(N){s(c,d,h,f,p,m,N);var S=c.node(N),_=S.borderTop?S.borderTop:N,E=S.borderBottom?S.borderBottom:N,I=S.borderTop?f:2*f,A=_!==E?1:p-m[w]+1;c.setEdge(v,_,{weight:I,minlen:A,nestingEdge:!0}),c.setEdge(E,b,{weight:I,minlen:A,nestingEdge:!0})}),c.parent(w)||c.setEdge(d,v,{weight:0,minlen:p+m[w]})}function a(c){var d={};function h(f,p){var m=c.children(f);m&&m.length&&e.forEach(m,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 pk}var mk,iL;function Kce(){if(iL)return mk;iL=1;var e=Nt(),t=In();mk=n;function n(a){function o(i){var c=a.children(i),d=a.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)s(a,"borderLeft","_bl",i,d,h),s(a,"borderRight","_br",i,d,h)}}e.forEach(a.children(),o)}function s(a,o,i,c,d,h){var f={width:0,height:0,rank:h,borderType:o},p=d[o][h-1],m=t.addDummyNode(a,"border",f,i);d[o][h]=m,a.setParent(m,c),p&&a.setEdge(p,m,{weight:1})}return mk}var gk,lL;function Yce(){if(lL)return gk;lL=1;var e=Nt();gk={adjust:t,undo:n};function t(h){var f=h.graph().rankdir.toLowerCase();(f==="lr"||f==="rl")&&s(h)}function n(h){var f=h.graph().rankdir.toLowerCase();(f==="bt"||f==="rl")&&o(h),(f==="lr"||f==="rl")&&(c(h),s(h))}function s(h){e.forEach(h.nodes(),function(f){a(h.node(f))}),e.forEach(h.edges(),function(f){a(h.edge(f))})}function a(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 gk}var yk,cL;function Xce(){if(cL)return yk;cL=1;var e=Nt();yk=t;function t(n){var s={},a=e.filter(n.nodes(),function(h){return!n.children(h).length}),o=e.max(e.map(a,function(h){return n.node(h).rank})),i=e.map(e.range(o+1),function(){return[]});function c(h){if(!e.has(s,h)){s[h]=!0;var f=n.node(h);i[f.rank].push(h),e.forEach(n.successors(h),c)}}var d=e.sortBy(a,function(h){return n.node(h).rank});return e.forEach(d,c),i}return yk}var wk,uL;function Zce(){if(uL)return wk;uL=1;var e=Nt();wk=t;function t(s,a){for(var o=0,i=1;i<a.length;++i)o+=n(s,a[i-1],a[i]);return o}function n(s,a,o){for(var i=e.zipObject(o,e.map(o,function(m,w){return w})),c=e.flatten(e.map(a,function(m){return e.sortBy(e.map(s.outEdges(m),function(w){return{pos:i[w.w],weight:s.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(m){var w=m.pos+d;f[w]+=m.weight;for(var j=0;w>0;)w%2&&(j+=f[w+1]),w=w-1>>1,f[w]+=m.weight;p+=m.weight*j})),p}return wk}var xk,dL;function Jce(){if(dL)return xk;dL=1;var e=Nt();xk=t;function t(n,s){return e.map(s,function(a){var o=n.inEdges(a);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:a,barycenter:i.sum/i.weight,weight:i.weight}}else return{v:a}})}return xk}var vk,hL;function Qce(){if(hL)return vk;hL=1;var e=Nt();vk=t;function t(a,o){var i={};e.forEach(a,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(a){var o=[];function i(h){return function(f){f.merged||(e.isUndefined(f.barycenter)||e.isUndefined(h.barycenter)||f.barycenter>=h.barycenter)&&s(h,f)}}function c(h){return function(f){f.in.push(h),--f.indegree===0&&a.push(f)}}for(;a.length;){var d=a.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 s(a,o){var i=0,c=0;a.weight&&(i+=a.barycenter*a.weight,c+=a.weight),o.weight&&(i+=o.barycenter*o.weight,c+=o.weight),a.vs=o.vs.concat(a.vs),a.barycenter=i/c,a.weight=c,a.i=Math.min(o.i,a.i),o.merged=!0}return vk}var bk,fL;function eue(){if(fL)return bk;fL=1;var e=Nt(),t=In();bk=n;function n(o,i){var c=t.partition(o,function(v){return e.has(v,"barycenter")}),d=c.lhs,h=e.sortBy(c.rhs,function(v){return-v.i}),f=[],p=0,m=0,w=0;d.sort(a(!!i)),w=s(f,h,w),e.forEach(d,function(v){w+=v.vs.length,f.push(v.vs),p+=v.barycenter*v.weight,m+=v.weight,w=s(f,h,w)});var j={vs:e.flatten(f,!0)};return m&&(j.barycenter=p/m,j.weight=m),j}function s(o,i,c){for(var d;i.length&&(d=e.last(i)).i<=c;)i.pop(),o.push(d.vs),c++;return c}function a(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 bk}var kk,pL;function tue(){if(pL)return kk;pL=1;var e=Nt(),t=Jce(),n=Qce(),s=eue();kk=a;function a(c,d,h,f){var p=c.children(d),m=c.node(d),w=m?m.borderLeft:void 0,j=m?m.borderRight:void 0,v={};w&&(p=e.filter(p,function(E){return E!==w&&E!==j}));var b=t(c,p);e.forEach(b,function(E){if(c.children(E.v).length){var I=a(c,E.v,h,f);v[E.v]=I,e.has(I,"barycenter")&&i(E,I)}});var k=n(b,h);o(k,v);var N=s(k,f);if(w&&(N.vs=e.flatten([w,N.vs,j],!0),c.predecessors(w).length)){var S=c.node(c.predecessors(w)[0]),_=c.node(c.predecessors(j)[0]);e.has(N,"barycenter")||(N.barycenter=0,N.weight=0),N.barycenter=(N.barycenter*N.weight+S.order+_.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 kk}var jk,mL;function nue(){if(mL)return jk;mL=1;var e=Nt(),t=Gs().Graph;jk=n;function n(a,o,i){var c=s(a),d=new t({compound:!0}).setGraph({root:c}).setDefaultNodeLabel(function(h){return a.node(h)});return e.forEach(a.nodes(),function(h){var f=a.node(h),p=a.parent(h);(f.rank===o||f.minRank<=o&&o<=f.maxRank)&&(d.setNode(h),d.setParent(h,p||c),e.forEach(a[i](h),function(m){var w=m.v===h?m.w:m.v,j=d.edge(w,h),v=e.isUndefined(j)?0:j.weight;d.setEdge(w,h,{weight:a.edge(m).weight+v})}),e.has(f,"minRank")&&d.setNode(h,{borderLeft:f.borderLeft[o],borderRight:f.borderRight[o]}))}),d}function s(a){for(var o;a.hasNode(o=e.uniqueId("_root")););return o}return jk}var Nk,gL;function sue(){if(gL)return Nk;gL=1;var e=Nt();Nk=t;function t(n,s,a){var o={},i;e.forEach(a,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){s.setEdge(f,d);return}d=h}})}return Nk}var Sk,yL;function rue(){if(yL)return Sk;yL=1;var e=Nt(),t=Xce(),n=Zce(),s=tue(),a=nue(),o=sue(),i=Gs().Graph,c=In();Sk=d;function d(m){var w=c.maxRank(m),j=h(m,e.range(1,w+1),"inEdges"),v=h(m,e.range(w-1,-1,-1),"outEdges"),b=t(m);p(m,b);for(var k=Number.POSITIVE_INFINITY,N,S=0,_=0;_<4;++S,++_){f(S%2?j:v,S%4>=2),b=c.buildLayerMatrix(m);var E=n(m,b);E<k&&(_=0,N=e.cloneDeep(b),k=E)}p(m,N)}function h(m,w,j){return e.map(w,function(v){return a(m,v,j)})}function f(m,w){var j=new i;e.forEach(m,function(v){var b=v.graph().root,k=s(v,b,j,w);e.forEach(k.vs,function(N,S){v.node(N).order=S}),o(v,j,k.vs)})}function p(m,w){e.forEach(w,function(j){e.forEach(j,function(v,b){m.node(v).order=b})})}return Sk}var _k,wL;function aue(){if(wL)return _k;wL=1;var e=Nt(),t=Gs().Graph,n=In();_k={positionX:j,findType1Conflicts:s,findType2Conflicts:a,addConflict:i,hasConflict:c,verticalAlignment:d,horizontalCompaction:h,alignCoordinates:m,findSmallestWidthAlignment:p,balance:w};function s(k,N){var S={};function _(E,I){var A=0,O=0,L=E.length,U=e.last(I);return e.forEach(I,function(P,T){var B=o(k,P),M=B?k.node(B).order:L;(B||P===U)&&(e.forEach(I.slice(O,T+1),function(q){e.forEach(k.predecessors(q),function($){var K=k.node($),G=K.order;(G<A||M<G)&&!(K.dummy&&k.node(q).dummy)&&i(S,$,q)})}),O=T+1,A=M)}),I}return e.reduce(N,_),S}function a(k,N){var S={};function _(I,A,O,L,U){var P;e.forEach(e.range(A,O),function(T){P=I[T],k.node(P).dummy&&e.forEach(k.predecessors(P),function(B){var M=k.node(B);M.dummy&&(M.order<L||M.order>U)&&i(S,B,P)})})}function E(I,A){var O=-1,L,U=0;return e.forEach(A,function(P,T){if(k.node(P).dummy==="border"){var B=k.predecessors(P);B.length&&(L=k.node(B[0]).order,_(A,U,T,O,L),U=T,O=L)}_(A,U,A.length,L,I.length)}),A}return e.reduce(N,E),S}function o(k,N){if(k.node(N).dummy)return e.find(k.predecessors(N),function(S){return k.node(S).dummy})}function i(k,N,S){if(N>S){var _=N;N=S,S=_}var E=k[N];E||(k[N]=E={}),E[S]=!0}function c(k,N,S){if(N>S){var _=N;N=S,S=_}return e.has(k[N],S)}function d(k,N,S,_){var E={},I={},A={};return e.forEach(N,function(O){e.forEach(O,function(L,U){E[L]=L,I[L]=L,A[L]=U})}),e.forEach(N,function(O){var L=-1;e.forEach(O,function(U){var P=_(U);if(P.length){P=e.sortBy(P,function($){return A[$]});for(var T=(P.length-1)/2,B=Math.floor(T),M=Math.ceil(T);B<=M;++B){var q=P[B];I[U]===U&&L<A[q]&&!c(S,U,q)&&(I[q]=U,I[U]=E[U]=E[q],L=A[q])}}})}),{root:E,align:I}}function h(k,N,S,_,E){var I={},A=f(k,N,S,E),O=E?"borderLeft":"borderRight";function L(T,B){for(var M=A.nodes(),q=M.pop(),$={};q;)$[q]?T(q):($[q]=!0,M.push(q),M=M.concat(B(q))),q=M.pop()}function U(T){I[T]=A.inEdges(T).reduce(function(B,M){return Math.max(B,I[M.v]+A.edge(M))},0)}function P(T){var B=A.outEdges(T).reduce(function(q,$){return Math.min(q,I[$.w]-A.edge($))},Number.POSITIVE_INFINITY),M=k.node(T);B!==Number.POSITIVE_INFINITY&&M.borderType!==O&&(I[T]=Math.max(I[T],B))}return L(U,A.predecessors.bind(A)),L(P,A.successors.bind(A)),e.forEach(_,function(T){I[T]=I[S[T]]}),I}function f(k,N,S,_){var E=new t,I=k.graph(),A=v(I.nodesep,I.edgesep,_);return e.forEach(N,function(O){var L;e.forEach(O,function(U){var P=S[U];if(E.setNode(P),L){var T=S[L],B=E.edge(T,P);E.setEdge(T,P,Math.max(A(k,U,L),B||0))}L=U})}),E}function p(k,N){return e.minBy(e.values(N),function(S){var _=Number.NEGATIVE_INFINITY,E=Number.POSITIVE_INFINITY;return e.forIn(S,function(I,A){var O=b(k,A)/2;_=Math.max(I+O,_),E=Math.min(I-O,E)}),_-E})}function m(k,N){var S=e.values(N),_=e.min(S),E=e.max(S);e.forEach(["u","d"],function(I){e.forEach(["l","r"],function(A){var O=I+A,L=k[O],U;if(L!==N){var P=e.values(L);U=A==="l"?_-e.min(P):E-e.max(P),U&&(k[O]=e.mapValues(L,function(T){return T+U}))}})})}function w(k,N){return e.mapValues(k.ul,function(S,_){if(N)return k[N.toLowerCase()][_];var E=e.sortBy(e.map(k,_));return(E[1]+E[2])/2})}function j(k){var N=n.buildLayerMatrix(k),S=e.merge(s(k,N),a(k,N)),_={},E;e.forEach(["u","d"],function(A){E=A==="u"?N:e.values(N).reverse(),e.forEach(["l","r"],function(O){O==="r"&&(E=e.map(E,function(T){return e.values(T).reverse()}));var L=(A==="u"?k.predecessors:k.successors).bind(k),U=d(k,E,S,L),P=h(k,E,U.root,U.align,O==="r");O==="r"&&(P=e.mapValues(P,function(T){return-T})),_[A+O]=P})});var I=p(k,_);return m(_,I),w(_,k.graph().align)}function v(k,N,S){return function(_,E,I){var A=_.node(E),O=_.node(I),L=0,U;if(L+=A.width/2,e.has(A,"labelpos"))switch(A.labelpos.toLowerCase()){case"l":U=-A.width/2;break;case"r":U=A.width/2;break}if(U&&(L+=S?U:-U),U=0,L+=(A.dummy?N:k)/2,L+=(O.dummy?N:k)/2,L+=O.width/2,e.has(O,"labelpos"))switch(O.labelpos.toLowerCase()){case"l":U=O.width/2;break;case"r":U=-O.width/2;break}return U&&(L+=S?U:-U),U=0,L}}function b(k,N){return k.node(N).width}return _k}var Ck,xL;function oue(){if(xL)return Ck;xL=1;var e=Nt(),t=In(),n=aue().positionX;Ck=s;function s(o){o=t.asNonCompoundGraph(o),a(o),e.forEach(n(o),function(i,c){o.node(c).x=i})}function a(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 Ck}var Ek,vL;function iue(){if(vL)return Ek;vL=1;var e=Nt(),t=Uce(),n=Wce(),s=zce(),a=In().normalizeRanks,o=Vce(),i=In().removeEmptyRanks,c=Gce(),d=Kce(),h=Yce(),f=rue(),p=oue(),m=In(),w=Gs().Graph;Ek=j;function j(F,Y){var X=Y&&Y.debugTiming?m.time:m.notime;X("layout",function(){var Z=X(" buildLayoutGraph",function(){return L(F)});X(" runLayout",function(){v(Z,X)}),X(" updateInputGraph",function(){b(F,Z)})})}function v(F,Y){Y(" makeSpaceForEdgeLabels",function(){U(F)}),Y(" removeSelfEdges",function(){z(F)}),Y(" acyclic",function(){t.run(F)}),Y(" nestingGraph.run",function(){c.run(F)}),Y(" rank",function(){s(m.asNonCompoundGraph(F))}),Y(" injectEdgeLabelProxies",function(){P(F)}),Y(" removeEmptyRanks",function(){i(F)}),Y(" nestingGraph.cleanup",function(){c.cleanup(F)}),Y(" normalizeRanks",function(){a(F)}),Y(" assignRankMinMax",function(){T(F)}),Y(" removeEdgeLabelProxies",function(){B(F)}),Y(" normalize.run",function(){n.run(F)}),Y(" parentDummyChains",function(){o(F)}),Y(" addBorderSegments",function(){d(F)}),Y(" order",function(){f(F)}),Y(" insertSelfEdges",function(){W(F)}),Y(" adjustCoordinateSystem",function(){h.adjust(F)}),Y(" position",function(){p(F)}),Y(" positionSelfEdges",function(){D(F)}),Y(" removeBorderNodes",function(){G(F)}),Y(" normalize.undo",function(){n.undo(F)}),Y(" fixupEdgeLabelCoords",function(){$(F)}),Y(" undoCoordinateSystem",function(){h.undo(F)}),Y(" translateGraph",function(){M(F)}),Y(" assignNodeIntersects",function(){q(F)}),Y(" reversePoints",function(){K(F)}),Y(" acyclic.undo",function(){t.undo(F)})}function b(F,Y){e.forEach(F.nodes(),function(X){var Z=F.node(X),J=Y.node(X);Z&&(Z.x=J.x,Z.y=J.y,Y.children(X).length&&(Z.width=J.width,Z.height=J.height))}),e.forEach(F.edges(),function(X){var Z=F.edge(X),J=Y.edge(X);Z.points=J.points,e.has(J,"x")&&(Z.x=J.x,Z.y=J.y)}),F.graph().width=Y.graph().width,F.graph().height=Y.graph().height}var k=["nodesep","edgesep","ranksep","marginx","marginy"],N={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},S=["acyclicer","ranker","rankdir","align"],_=["width","height"],E={width:0,height:0},I=["minlen","weight","width","height","labeloffset"],A={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},O=["labelpos"];function L(F){var Y=new w({multigraph:!0,compound:!0}),X=ee(F.graph());return Y.setGraph(e.merge({},N,H(X,k),e.pick(X,S))),e.forEach(F.nodes(),function(Z){var J=ee(F.node(Z));Y.setNode(Z,e.defaults(H(J,_),E)),Y.setParent(Z,F.parent(Z))}),e.forEach(F.edges(),function(Z){var J=ee(F.edge(Z));Y.setEdge(Z,e.merge({},A,H(J,I),e.pick(J,O)))}),Y}function U(F){var Y=F.graph();Y.ranksep/=2,e.forEach(F.edges(),function(X){var Z=F.edge(X);Z.minlen*=2,Z.labelpos.toLowerCase()!=="c"&&(Y.rankdir==="TB"||Y.rankdir==="BT"?Z.width+=Z.labeloffset:Z.height+=Z.labeloffset)})}function P(F){e.forEach(F.edges(),function(Y){var X=F.edge(Y);if(X.width&&X.height){var Z=F.node(Y.v),J=F.node(Y.w),ne={rank:(J.rank-Z.rank)/2+Z.rank,e:Y};m.addDummyNode(F,"edge-proxy",ne,"_ep")}})}function T(F){var Y=0;e.forEach(F.nodes(),function(X){var Z=F.node(X);Z.borderTop&&(Z.minRank=F.node(Z.borderTop).rank,Z.maxRank=F.node(Z.borderBottom).rank,Y=e.max(Y,Z.maxRank))}),F.graph().maxRank=Y}function B(F){e.forEach(F.nodes(),function(Y){var X=F.node(Y);X.dummy==="edge-proxy"&&(F.edge(X.e).labelRank=X.rank,F.removeNode(Y))})}function M(F){var Y=Number.POSITIVE_INFINITY,X=0,Z=Number.POSITIVE_INFINITY,J=0,ne=F.graph(),ce=ne.marginx||0,he=ne.marginy||0;function le(re){var ae=re.x,de=re.y,Se=re.width,pe=re.height;Y=Math.min(Y,ae-Se/2),X=Math.max(X,ae+Se/2),Z=Math.min(Z,de-pe/2),J=Math.max(J,de+pe/2)}e.forEach(F.nodes(),function(re){le(F.node(re))}),e.forEach(F.edges(),function(re){var ae=F.edge(re);e.has(ae,"x")&&le(ae)}),Y-=ce,Z-=he,e.forEach(F.nodes(),function(re){var ae=F.node(re);ae.x-=Y,ae.y-=Z}),e.forEach(F.edges(),function(re){var ae=F.edge(re);e.forEach(ae.points,function(de){de.x-=Y,de.y-=Z}),e.has(ae,"x")&&(ae.x-=Y),e.has(ae,"y")&&(ae.y-=Z)}),ne.width=X-Y+ce,ne.height=J-Z+he}function q(F){e.forEach(F.edges(),function(Y){var X=F.edge(Y),Z=F.node(Y.v),J=F.node(Y.w),ne,ce;X.points?(ne=X.points[0],ce=X.points[X.points.length-1]):(X.points=[],ne=J,ce=Z),X.points.unshift(m.intersectRect(Z,ne)),X.points.push(m.intersectRect(J,ce))})}function $(F){e.forEach(F.edges(),function(Y){var X=F.edge(Y);if(e.has(X,"x"))switch((X.labelpos==="l"||X.labelpos==="r")&&(X.width-=X.labeloffset),X.labelpos){case"l":X.x-=X.width/2+X.labeloffset;break;case"r":X.x+=X.width/2+X.labeloffset;break}})}function K(F){e.forEach(F.edges(),function(Y){var X=F.edge(Y);X.reversed&&X.points.reverse()})}function G(F){e.forEach(F.nodes(),function(Y){if(F.children(Y).length){var X=F.node(Y),Z=F.node(X.borderTop),J=F.node(X.borderBottom),ne=F.node(e.last(X.borderLeft)),ce=F.node(e.last(X.borderRight));X.width=Math.abs(ce.x-ne.x),X.height=Math.abs(J.y-Z.y),X.x=ne.x+X.width/2,X.y=Z.y+X.height/2}}),e.forEach(F.nodes(),function(Y){F.node(Y).dummy==="border"&&F.removeNode(Y)})}function z(F){e.forEach(F.edges(),function(Y){if(Y.v===Y.w){var X=F.node(Y.v);X.selfEdges||(X.selfEdges=[]),X.selfEdges.push({e:Y,label:F.edge(Y)}),F.removeEdge(Y)}})}function W(F){var Y=m.buildLayerMatrix(F);e.forEach(Y,function(X){var Z=0;e.forEach(X,function(J,ne){var ce=F.node(J);ce.order=ne+Z,e.forEach(ce.selfEdges,function(he){m.addDummyNode(F,"selfedge",{width:he.label.width,height:he.label.height,rank:ce.rank,order:ne+ ++Z,e:he.e,label:he.label},"_se")}),delete ce.selfEdges})})}function D(F){e.forEach(F.nodes(),function(Y){var X=F.node(Y);if(X.dummy==="selfedge"){var Z=F.node(X.e.v),J=Z.x+Z.width/2,ne=Z.y,ce=X.x-J,he=Z.height/2;F.setEdge(X.e,X.label),F.removeNode(Y),X.label.points=[{x:J+2*ce/3,y:ne-he},{x:J+5*ce/6,y:ne-he},{x:J+ce,y:ne},{x:J+5*ce/6,y:ne+he},{x:J+2*ce/3,y:ne+he}],X.label.x=X.x,X.label.y=X.y}})}function H(F,Y){return e.mapValues(e.pick(F,Y),Number)}function ee(F){var Y={};return e.forEach(F,function(X,Z){Y[Z.toLowerCase()]=X}),Y}return Ek}var Tk,bL;function lue(){if(bL)return Tk;bL=1;var e=Nt(),t=In(),n=Gs().Graph;Tk={debugOrdering:s};function s(a){var o=t.buildLayerMatrix(a),i=new n({compound:!0,multigraph:!0}).setGraph({});return e.forEach(a.nodes(),function(c){i.setNode(c,{label:c}),i.setParent(c,"layer"+a.node(c).rank)}),e.forEach(a.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 Tk}var Rk,kL;function cue(){return kL||(kL=1,Rk="0.8.5"),Rk}var Ak,jL;function uue(){return jL||(jL=1,Ak={graphlib:Gs(),layout:iue(),debug:lue(),util:{time:In().time,notime:In().notime},version:cue()}),Ak}var due=uue();const NL=y1(due);function hue(e,t,n){const s=dp(e,a=>!t.has(a.id)&&n(a.id)!=null);if(s.size===0)return e;for(const a of s.values())a.sort((o,i)=>o.id.localeCompare(i.id));return e.map(a=>{var h;if(t.has(a.id)||n(a.id))return a;const o=s.get(Xn(a));if(!o)return a;const i=(h=a.data)==null?void 0:h.parentId,c=o.find(f=>f.id===i)??o[0],d=n(c.id);return{...a,position:{x:a.position.x+d.x-c.position.x,y:a.position.y+d.y-c.position.y}}})}function fue(e,t,n,s,a,o,i){const c=S=>yu(S,s,o),d=S=>n.get(S)??t.get(S),h=S=>{const{w:_,h:E}=xf(S,s);return{cw:_,ch:E}},f=i!=null&&i.width>0&&i.height>0,p=dp(e,S=>d(S.id)!=null),m=new Set;for(const[S,_]of p)_.every(E=>a.has(E.id)&&!n.has(E.id))&&m.add(S);const w=new Map,j=[];for(const S of e){const _=d(S.id);if(!_)continue;const{w:E,h:I}=c(S.id),A=Xn(S);m.has(A)?(w.get(A)??w.set(A,[]).get(A)).push(S):j.push({sid:A,x:_.x,y:_.y,w:E,h:I,...h(S.id)})}if(w.size===0||f&&j.length===0)return[];const v=yf,b=(S,_,E,I)=>j.some(A=>S<A.x+A.w+N0&&A.x<S+E+N0&&_<A.y+A.h+v&&A.y<_+I+v),k=OP(e,s),N=[];for(const S of[...w.keys()].sort()){const _=w.get(S);let E=1/0,I=1/0,A=-1/0,O=-1/0,L=-1/0,U=-1/0;for(const G of _){const z=d(G.id),{w:W,h:D}=c(G.id),{cw:H,ch:ee}=h(G.id);E=Math.min(E,z.x),I=Math.min(I,z.y),A=Math.max(A,z.x+W),O=Math.max(O,z.y+D),L=Math.max(L,z.x+H),U=Math.max(U,z.y+ee)}const P=A-E,T=O-I,B=new Map;for(const G of j)B.set(G.sid,Math.min(B.get(G.sid)??1/0,G.x));const M=[...new Set([...B.values()].map(G=>Math.round(G)))].sort((G,z)=>G-z),q=M.length?M:[E],$=[0,...j.map(G=>G.y+G.h+v)].sort((G,z)=>G-z);let K=null;if(f){let G=1/0,z=1/0,W=-1/0,D=-1/0;for(const Z of j)G=Math.min(G,Z.x),z=Math.min(z,Z.y),W=Math.max(W,Z.x+Z.cw),D=Math.max(D,Z.y+Z.ch);const H=(Z,J)=>{const ne=i.width/(Math.max(W,Z+L-E)-Math.min(G,Z)+wf),ce=i.height/(Math.max(D,J+U-I)-Math.min(z,J));return[Math.min(PP,ne,ce),Math.min(ne,ce),Math.max(ne,ce)]},ee=(Z,J)=>{for(let ne=0;ne<Z.length;ne++){if(Z[ne]>J[ne]+1e-9)return!0;if(Z[ne]<J[ne]-1e-9)return!1}return!1},F=Math.round(W+wf+k),Y=[...new Set([...$,z])].sort((Z,J)=>Z-J);let X=null;for(const Z of[...q,F])for(const J of Y){if(b(Z,J,P,T))continue;const ne=H(Z,J);(X===null||ee(ne,X))&&(X=ne,K={x:Z,y:J})}K&&K.x===E&&K.y===I&&(K=null)}else e:for(const G of q)for(const z of $){if(z>=I)break;if(!b(G,z,P,T)){K={x:G,y:z};break e}}if(K){const G=K.x-E,z=K.y-I;for(const W of _){const D=d(W.id);t.set(W.id,{x:D.x+G,y:D.y+z})}N.push(S)}for(const G of _){const z=d(G.id),{w:W,h:D}=c(G.id);j.push({sid:S,x:z.x,y:z.y,w:W,h:D,...h(G.id)})}}return N}function pue(e,t,n,s,a,o){const i=m=>yu(m,s,a),c=new Map(e.map(m=>[m.id,Xn(m)])),d=[],h=e.map(m=>({id:m.id,pos:n.get(m.id)??t.get(m.id)})).filter(m=>m.pos!=null).sort((m,w)=>m.pos.y-w.pos.y||m.pos.x-w.pos.x||m.id.localeCompare(w.id)),f=m=>(o==null?void 0:o.has(m))===!0&&!n.has(m);for(const{id:m,pos:w}of h){if(!f(m))continue;const{w:j,h:v}=i(m);d.push({x:w.x,y:w.y,w:j,h:v,sid:c.get(m)??"_default"})}const p=[];for(const{id:m,pos:w}of h){if(f(m))continue;const{w:j,h:v}=i(m),b=c.get(m)??"_default";if(n.has(m)){d.push({x:w.x,y:w.y,w:j,h:v,sid:b});continue}let k=w.y;for(let N=0;N<d.length+1;N++){const S=d.find(_=>{const E=_.sid===b?Fh:IP,I=_.sid===b?Fh:yf;return w.x<_.x+_.w+E&&_.x<w.x+j+E&&k<_.y+_.h+I&&_.y<k+v+I});if(!S)break;k=S.y+S.h+(S.sid===b?Fh:yf)}k!==w.y&&(t.set(m,{x:w.x,y:k}),p.push(m)),d.push({x:w.x,y:k,w:j,h:v,sid:b})}return p}function mue(e,t,n,s,a,o=!1,i){const d=IP+1,h=yf+1,f=8,p=1.75,m=200,w=.7,j=.01,v=T=>yu(T,s,i),b=T=>n.get(T)??t.get(T),k=dp(e,T=>b(T.id)!=null),N=[],S=new Set,_=new Set,E=a.size===0;for(const T of[...k.keys()].sort()){const B=k.get(T);let M=1/0,q=1/0,$=-1/0,K=-1/0,G=!1;for(const H of B){const ee=b(H.id),{w:F,h:Y}=v(H.id);M=Math.min(M,ee.x),q=Math.min(q,ee.y),$=Math.max($,ee.x+F),K=Math.max(K,ee.y+Y),n.has(H.id)&&(G=!0)}const z=$-M,W=K-q;_.add(T);const D=a.get(T);D&&(z>D.w+f||W>D.h+f)&&S.add(T),a.set(T,{w:z,h:W}),N.push({sid:T,members:B.map(H=>H.id),x:M,y:q,w:z,h:W,anchored:G,mass:1})}for(const T of[...a.keys()])_.has(T)||a.delete(T);if(o||E)return[];let I=!1;for(let T=0;T<N.length&&!I;T++)for(let B=T+1;B<N.length;B++){const M=N[T],q=N[B];if(!(M.anchored&&q.anchored)&&Math.abs(M.x+M.w/2-(q.x+q.w/2))<(M.w+q.w)/2+d&&Math.abs(M.y+M.h/2-(q.y+q.h/2))<(M.h+q.h)/2+h){I=!0;break}}if(S.size===0&&!I)return[];if(S.size>0)for(const T of N)S.has(T.sid)&&(T.mass=8);else for(const T of N)T.mass=Math.max(1,T.w*T.h/(gu*LP));const A=new Map(N.map(T=>[T.sid,T.x])),O=new Map(N.map(T=>[T.sid,T.y])),L=new Map(N.map(T=>[T.sid,Math.min(0,T.x)])),U=new Map(N.map(T=>[T.sid,Math.min(0,T.y)]));for(let T=0;T<m;T++){const B=new Map,M=new Map;let q=0;for(let $=0;$<N.length;$++)for(let K=$+1;K<N.length;K++){const G=N[$],z=N[K];if(G.anchored&&z.anchored)continue;const W=G.x+G.w/2,D=G.y+G.h/2,H=z.x+z.w/2,ee=z.y+z.h/2,F=(G.w+z.w)/2+d-Math.abs(W-H),Y=(G.h+z.h)/2+h-Math.abs(D-ee);if(F<=0||Y<=0)continue;const X=(Re,st)=>!Re.anchored&&!(st<0&&Re.x<=L.get(Re.sid)),Z=(Re,st)=>!Re.anchored&&!(st<0&&Re.y<=U.get(Re.sid)),J=(Re,st,je)=>{const Te=Re===st,$e=Te?G.sid<z.sid?-1:1:Math.sign(Re-st);return je(G,$e)||je(z,-$e)?$e:Te&&(je(G,-$e)||je(z,$e))?-$e:0},ne=J(W,H,X),ce=J(D,ee,Z),he=ne!==0,le=ce!==0;if(!he&&!le)continue;const re=he&&(!le||F*p<Y),[ae,de,Se,pe]=re?[ne,F,B,X]:[ce,Y,M,Z],me=pe(G,ae),be=pe(z,-ae),Ce=G.mass,ye=z.mass,Pe=me?be?ye/(Ce+ye):1:0,Oe=be?me?Ce/(Ce+ye):1:0,We=de*w;Se.set(G.sid,(Se.get(G.sid)??0)+ae*We*Pe),Se.set(z.sid,(Se.get(z.sid)??0)-ae*We*Oe),q+=We}for(const $ of N)$.anchored||($.x=Math.max(L.get($.sid),$.x+(B.get($.sid)??0)),$.y=Math.max(U.get($.sid),$.y+(M.get($.sid)??0)));if(q<j)break}const P=[];for(const T of N){const B=T.x-A.get(T.sid),M=T.y-O.get(T.sid);if(!(Math.abs(B)<1&&Math.abs(M)<1)){for(const q of T.members){if(n.has(q))continue;const $=t.get(q);$&&t.set(q,{x:$.x+B,y:$.y+M})}P.push(T.sid)}}return P}function gue(e,t,n,s,a,o){const i=new NL.graphlib.Graph;i.setDefaultEdgeLabel(()=>({})),i.setGraph({rankdir:n,marginx:0,marginy:0,nodesep:70,ranksep:160,edgesep:30});const c=e.filter(k=>!a.has(k)),d=new Set(c);for(const k of c){const{w:N,h:S}=yu(k,s,o);i.setNode(k,{width:N,height:S})}for(const k of t)d.has(k.source)&&d.has(k.target)&&i.setEdge(k.source,k.target);NL.layout(i);const h=new Map;let f=1/0,p=1/0,m=-1/0,w=-1/0;for(const k of c){const N=i.node(k);if(!N)continue;const{w:S,h:_}=xf(k,s),E=yu(k,s,o),I=N.x-E.w/2,A=N.y-E.h/2;h.set(k,{x:I,y:A}),I<f&&(f=I),A<p&&(p=A),I+S>m&&(m=I+S),A+_>w&&(w=A+_)}if(Number.isFinite(f)&&Number.isFinite(p))for(const[k,N]of h)h.set(k,{x:N.x-f,y:N.y-p});const j=Number.isFinite(m)?m-f:0,v=Number.isFinite(w)?w-p:0;let b=null;for(const k of e){const N=a.get(k);if(!N)continue;const{w:S,h:_}=xf(k,s);b=b===null?{minX:N.x,minY:N.y,maxX:N.x+S,maxY:N.y+_}:{minX:Math.min(b.minX,N.x),minY:Math.min(b.minY,N.y),maxX:Math.max(b.maxX,N.x+S),maxY:Math.max(b.maxY,N.y+_)}}return{positions:h,width:j,height:v,pinnedBox:b}}function RF(e,t,n){const s=n.direction??"LR",a=n.pinned??new Map,o=n.measured??new Map,i=n.lanes,c=dp(e);return{laid:Array.from(c.keys()).sort().map(f=>({sid:f,...gue(c.get(f).map(p=>p.id),t,s,o,a,i)})),gap:OP(e,o)}}const AF=e=>e.reduce((t,n)=>Math.max(t,n.width),0)+wf,yue=e=>e.reduce((t,n)=>t+n.height,0)+cl*Math.max(0,e.length-1);function Q0(e,t,n,s){const a=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+cl;return h},o=[];for(let d=0;d<e.length;d++){let h=-cl;for(let f=d;f<e.length;f++)o.push(h+=e[f].height+cl)}o.sort((d,h)=>d-h);const i=d=>{let h=0,f=o.length-1;for(;h<f;){const p=h+f>>1;a(o[p]).length<=d?f=p:h=p+1}return a(o[h])};let c=[e];if(n>0&&s>0){const d=f=>UY(f.reduce((p,m)=>p+AF(m),0)+t*(f.length-1),Math.max(...f.map(yue)),n,s);let h=d(c);for(let f=2;f<=e.length;f++){const p=i(f),m=d(p);m>h+1e-9&&(h=m,c=p)}}return c}function wue(e,t,n,s,a){if(!(s.width>0&&s.height>0&&a.width>0&&a.height>0))return!1;const{laid:o,gap:i}=RF(e,t,n);return o.length<2?!1:Q0(o,i,s.width,s.height).length!==Q0(o,i,a.width,a.height).length}function xue(e,t,n={}){const s=n.pinned??new Map,{laid:a,gap:o}=RF(e,t,n),i=Q0(a,o,n.availableWidth??0,n.availableHeight??0),c=new Map;let d=0;for(const h of i){const f=AF(h);let p=0;for(const{positions:m,height:w,pinnedBox:j}of h){for(const[b,k]of m)c.set(b,{x:k.x+d,y:k.y+p});let v=p+w;j&&j.maxY>v&&j.minX<d+f&&d<j.maxX&&(v=j.maxY),p=v+cl}d+=f+o}return e.map(h=>{const f=s.get(h.id);if(f)return{...h,position:f};const p=c.get(h.id);return p?{...h,position:p}:h})}function zh(e,t,n){return!t.has(e)||n.has(e)}function vue(e,t,n,s){return!t.has(e)&&zh(e,n,s)}function bue(e,t,n){const s={x:0,y:0};return t.set(e,s),n.add(e),s}function SL(e,t,n,s){n.set(e,t),s.delete(e)}const kue=300,_L=130,jue=160,CL=new WeakMap;function Nue(e,t){let n=CL.get(e);(!n||n.revision!==e.revision||n.open!==t)&&(n={revision:e.revision,open:t,byId:new Map,branches:mV(e.agents.values()),groups:Zf(e.agents.values())},CL.set(e,n));const{byId:s,branches:a,groups:o}=n;return i=>{let c=s.get(i.id);if(!c){const d=i.kind==="root"?a.get(i.sessionId):void 0;c=d?{...i,onOpenContext:t,branch:d}:{...i,onOpenContext:t},c.canvasSessionId=o.get(i.id),s.set(i.id,c)}return c}}function rN(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 Sue(e,t){const n=i=>Xn(i),s=new Map;for(const i of e){const c=n(i),d=i.position.x+(i.width??gu),h=s.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)):s.set(c,{minX:i.position.x,maxX:d,minY:i.position.y})}const a=[];for(const[i,c]of[...s].sort((d,h)=>d[1].minX-h[1].minX)){const d=a[a.length-1];d&&c.minX<d.maxX?(d.maxX=Math.max(d.maxX,c.maxX),d.sessions.push({sid:i,top:c.minY})):a.push({maxX:c.maxX,sessions:[{sid:i,top:c.minY}]})}const o=new Map;for(const i of a)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 _ue(e,t){var s;let n=0;for(let a=t.parentId;a!=null&&n<e.agents.size;a=(s=e.agents.get(a))==null?void 0:s.parentId)n++;return n}function Cue(e,t,n,s,a,o,i,c,d,h,f,p,m,w,j,v,b,k,N,S){var G,z,W,D;const _=[],E=[],I=Nue(e,k);for(const H of e.agents.values()){if(!b.has(H.id))continue;const ee=H.exitAt!=null,F=v!=null&&!v.has(H.id),Y=[ee?"rf-exiting":"",F?"rf-spotlit-out":"",j.has(H.id)?"rf-selected":""].filter(Boolean).join(" ")||void 0,X=o.get(H.id);if(_.push({id:H.id,type:"agent",position:{x:0,y:0},data:I(H),className:Y,ariaLabel:C9(H,t,j.has(H.id)),...X?{width:X.width,height:X.height}:null}),H.parentId&&b.has(H.parentId)){const ne=hu(H.sessionId),ce=ee,he=j.size>0&&(j.has(H.id)||j.has(H.parentId)),le=v!=null&&!v.has(H.id)&&!v.has(H.parentId),re=H.state==="active"?2:1.5,ae=he?re+1.5:re,de=ce?.2:le?.12:1,Se=["sess-edge",H.state==="active"?"sess-live":"sess-idle",ce?"rf-edge-exiting":"",he?"rf-edge-selected":""].filter(Boolean).join(" ");E.push({id:`e:${H.parentId}->${H.id}`,source:H.parentId,target:H.id,animated:(H.state==="active"||he)&&!ce,type:"smoothstep",style:{"--session-hue":ne,strokeWidth:`calc(${ae}px * var(--edge-k, 1))`,opacity:de,transition:"var(--edge-transition)"},className:Se})}const Z=H.kind==="root"?ap(H):null,J=Z?Z.key:null;if(Z&&J&&!aV(J)){const ne=Y1(H.id),ce=hu(H.sessionId),he=o.get(ne);_.push({id:ne,type:"recapNote",position:{x:0,y:0},data:{sessionId:H.sessionId,canvasSessionId:I(H).canvasSessionId,parentId:H.id,note:Z,noteKey:J,hue:ce},className:F?"rf-spotlit-out":void 0,selectable:!1,focusable:!1,ariaLabel:Z.kind==="recap"?`Claude Code's recap for ${H.label}`:`${H.label}: ${Ha(Z.kind)}`,...he?{width:he.width,height:he.height}:null}),E.push({id:`e:recap:${H.id}`,source:ne,target:H.id,type:"recapTie",className:"recap-edge",focusable:!1,style:{"--session-hue":ce}})}}const A=rN(e),O=S.size>0&&!(d&&N);O||S.clear();const L=_.filter(H=>H.data.provider==="codex"&&H.data.parentId).map(H=>`${H.id}:${Xn(H)}:${H.data.parentId}`).sort().join("|"),U=`${m}${L?`#codex:${L}`:""}#lanes:${zY(A)}${O?"#held":""}`,P=new Set(_.filter(H=>H.type==="recapNote").map(H=>H.id));for(const H of Array.from(f.keys()))N&&cV(H)&&!P.has(H)&&!a.has(H)&&(f.delete(H),p.delete(H));const T=_.filter(H=>vue(H.id,a,f,p));if(T.length>0||U!==w.current){if(T.length>0){for(const ee of T)S.delete(ee.id);const H=hue(xue(_,E,{direction:"LR",pinned:a,measured:o,availableWidth:n,availableHeight:s,lanes:A}),a,ee=>zh(ee,f,p)?void 0:f.get(ee));for(const ee of H)zh(ee.id,f,p)&&SL(ee.id,ee.position,f,p);fue(_,f,a,o,new Set(T.filter(ee=>ee.type!=="recapNote").map(ee=>ee.id)),A,{width:n,height:s});for(const ee of T){if(ee.type!=="recapNote")continue;const F=(G=ee.data)==null?void 0:G.parentId;if(!F)continue;const Y=a.get(F)??(zh(F,f,p)?void 0:f.get(F));if(!Y)continue;const X=((z=o.get(ee.id))==null?void 0:z.width)??kue,Z=((W=o.get(ee.id))==null?void 0:W.height)??_L,J=((D=o.get(F))==null?void 0:D.height)??_L;SL(ee.id,{x:Y.x-jue-X,y:Y.y+(J-Z)/2},f,p)}}pue(_,f,a,o,A,O?S:void 0),w.current=U}const B=mue(_,f,a,o,i,!d||h,A);B.length>0&&c(B);const M=zoe(e.agents.values());N&&Sh(f,M),Sh(p,M),N&&Sh(a,M),Sh(o,Hoe(e.agents.values()));const q=[];let $=!1;for(const H of _){let ee=a.get(H.id)??f.get(H.id);ee||(ee=bue(H.id,f,p),$=!0),q.push({...H,position:ee})}return $&&(w.current=""),{nodes:Sue(q,H=>{if(H.type==="recapNote")return-1;const ee=e.agents.get(H.id);return ee?_ue(e,ee):0}),edges:E}}function Eue(e){return e.slice().sort((t,n)=>t.y-n.y||t.x-n.x)}function Tue(e,t,n){var i;if(e.length===0)return null;const s=Eue(e),a=t?s.findIndex(c=>c.id===t):-1,o=a===-1?n===1?0:s.length-1:(a+n+s.length)%s.length;return((i=s[o])==null?void 0:i.id)??null}const Rue=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Escape","Backspace"]);function Aue(e,t){return t==null?{kind:"deck",nodeId:null}:e.key==="Enter"||e.key===" "?{kind:"activate",nodeId:t,additive:e.shiftKey}:Rue.has(e.key)?{kind:"node",nodeId:t}:{kind:"deck",nodeId:t}}const Mue=new Set(["","BODY","HTML","#DOCUMENT"]);function $ue(e){return!e||Bo(e)?!1:!Mue.has(String(e.tagName??"").toUpperCase())}const MF="react-flow__node";function aN(e){var t,n;return!!e&&((n=(t=e.classList)==null?void 0:t.contains)==null?void 0:n.call(t,MF))===!0}function $F(e){try{const t=document.querySelector(`.${MF}[data-id="${CSS.escape(e)}"]`);t==null||t.focus({preventScroll:!0})}catch{}}let Wo=null,nl=null;const e1=new Set,t1=()=>{for(const e of e1)e()},Lue=e=>(e1.add(e),()=>{e1.delete(e)}),EL=()=>Wo,Iue=90;function LF(e){!nl||e!=null&&nl.at.id!==e||(clearTimeout(nl.timer),nl=null)}function IF(e,t,n="pointer"){LF();const s={id:e,anchor:t,by:n};if(Wo||n==="focus"){Wo=s,t1();return}nl={at:s,timer:setTimeout(()=>{nl=null,Wo=s,t1()},Iue)}}function Xa(e){LF(e),!(!Wo||e!=null&&Wo.id!==e)&&(Wo=null,t1())}function Oue({agentFor:e,recapFor:t,labelFor:n,bounds:s}){const a=y.useSyncExternalStore(Lue,EL,EL),o=a?e(a.id):void 0,i=a&&!o?t(a.id):void 0,c=a!=null&&(!o&&!i||!a.anchor.isConnected);return y.useEffect(()=>{c&&a&&Xa(a.id)},[c,a]),!a||c?null:o?r.jsx(Due,{a:o,anchor:a.anchor,parentLabel:o.parentId?n(o.parentId):void 0,bounds:s},a.id):i?r.jsx(Pue,{r:i,anchor:a.anchor,bounds:s},a.id):null}function OF(e,t){const n=y.useRef(null),s=y.useCallback(()=>{const a=n.current;if(!a||!e.isConnected)return;a.style.maxHeight="";const o=bj(e.getBoundingClientRect(),{width:a.offsetWidth,height:a.offsetHeight},t());a.style.top=`${o.top}px`,a.style.left=`${o.left}px`,a.style.maxHeight=o.maxHeight==null?"":`${o.maxHeight}px`,a.dataset.side=o.side},[e,t]);return y.useLayoutEffect(()=>{s()}),n}function Pue({r:e,anchor:t,bounds:n}){const s=OF(t,n),a=jr(3e4),o=e.note,i=o.kind==="recap",c=uf(o.at,a);return vt.createPortal(r.jsxs("div",{ref:s,className:"ap-peek node-peek recap-peek",role:"tooltip",id:"node-peek",style:{"--session-hue":e.hue},children:[r.jsxs("div",{className:"node-peek-head",children:[r.jsxs("span",{className:"recap-peek-mark",children:[r.jsx(lf,{recap:i}),Ha(o.kind)]}),r.jsx("span",{className:"node-peek-time",title:c.title,children:c.label})]}),e.sessionLabel&&r.jsx("div",{className:"node-peek-kind",children:r.jsxs("span",{children:[op(o)," · ",e.sessionLabel]})}),r.jsx("p",{className:"recap-peek-text",children:o.text}),o.reply&&r.jsxs("p",{className:"recap-peek-text",children:["Suggested reply: “",o.reply,"”"]}),r.jsx("p",{className:"node-peek-hint",children:"Click to go to the session · double-click for its details"})]}),document.body)}function Due({a:e,anchor:t,parentLabel:n,bounds:s}){const a=OF(t,s),o=jr(1e3),i=sp(e.sessionName,e.sessionTitle),c=e.toolErrorCount??0,d=e.tools.filter(v=>!v.endedAt).length,h=On(e,o).total,f=e.usage.inputTokens+e.usage.outputTokens,p=e.kind==="root"&&Mn(e.waiting),m=P3(e),w=e.kind==="root"?"session":n?`subagent of ${n}`:"subagent",j=[`${e.toolCount} ${e.toolCount===1?"tool":"tools"}`,d>0?`${d} in-flight`:null,f>0?`${xt(f)} tok`:null,h>0?`${et(h)}${yl(e,o)>0?"+":""}`:null].filter(Boolean).join(" · ");return vt.createPortal(r.jsxs("div",{ref:a,className:"ap-peek node-peek",role:"tooltip",id:"node-peek",children:[r.jsxs("div",{className:"node-peek-head",children:[r.jsx("span",{className:"node-peek-name",title:e.label,children:e.label}),r.jsxs("span",{className:"node-peek-time",children:[e.synthetic?"≥ ":"",vl(e.startedAt,e.endedAt,o)]})]}),r.jsxs("div",{className:"node-peek-kind",children:[r.jsxs("span",{className:"node-peek-state","data-kind":h0(il(e)),children:[r.jsx(aP,{kind:h0(il(e))}),wl(il(e))]}),r.jsx("span",{children:w}),e.model?r.jsx("span",{children:ep(e.model,e.effort)}):null]}),e.kind==="root"&&i.face&&r.jsx("p",{className:"node-peek-title",title:i.face,children:i.face}),e.kind==="root"&&e.waiting&&r.jsxs("p",{className:`node-peek-wait${p?" warn":""}`,children:[p&&r.jsx(J1,{}),r.jsxs("span",{className:"node-peek-said",title:af(e.waiting),children:[r.jsx("span",{className:"node-peek-since",children:r.jsx("b",{children:vl(e.waiting.since,void 0,o)})}),af(e.waiting)]})]}),m&&r.jsxs("p",{className:"node-peek-blind",children:[r.jsx("span",{className:"approval-blind-dot","aria-hidden":!0}),m.label]}),r.jsxs("p",{className:"node-peek-facts",children:[j,c>0&&r.jsxs("span",{className:"node-peek-failed",children:[" · ",c," failed"]})]}),e.branch&&e.branch.total>0&&r.jsx("p",{className:"node-peek-branch",children:J3(e.branch)}),r.jsx("p",{className:"node-peek-hint",children:"Click to go to the session · double-click for details"})]}),document.body)}function Fue(e){const t=e.minZoom??Yae,n=e.maxZoom??Xae,s=e.fill??.9,a=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))*s,p=Math.max(t,Math.min(n,f)),m=(w,j,v,b,k,N)=>{let S=w+(j-b*p)/2-v*p;const _=k*p+S,E=(k+N)*p+S;return N*p<=j?_<w?S+=w-_:E>w+j&&(S-=E-(w+j)):S+=w-_,S};return{x:m(a,i,d.x,d.width,h.x,h.width),y:m(o,c,d.y,d.height,h.y,h.height),zoom:p}}function Bue(e){let t=1/0,n=1/0,s=-1/0,a=-1/0;for(const o of e)t=Math.min(t,o.x),n=Math.min(n,o.y),s=Math.max(s,o.x+o.width),a=Math.max(a,o.y+o.height);return Number.isFinite(t)?{x:t,y:n,width:s-t,height:a-n}:null}function Gn(e){const t=y.useRef(e);return t.current=e,t}const n1=80,s1=.86;function PF(e){if(!e)return 0;const t=e.getBoundingClientRect();let n=t.right;for(const s of document.querySelectorAll(".sysdetail:not(.leaving), .usage-panel:not(.leaving)")){const a=s.getBoundingClientRect();a.width>0&&a.left>t.left&&(n=Math.min(n,a.left))}return Math.max(0,t.right-n)}function que({canvasRef:e,canvasSize:t,machinePhase:n,usagePhase:s,usagePanelOpen:a,detailShown:o}){const[i,c]=y.useState(0);y.useEffect(()=>{const p=PF(e.current);c(m=>Math.abs(m-p)>40?p:m)},[n,s,a,o,t.w]);const d=Gn(i),h=t.w>0?Math.max(0,(t.w-i-n1*2)*s1):0,f=t.h>0?Math.max(0,(t.h-n1*2)*s1):0;return{railInsetRef:d,availableWidth:h,availableHeight:f}}const TL=1e-6;function nu(e){return Number.isFinite(e[0])&&Number.isFinite(e[1])&&Number.isFinite(e[2])&&e[2]>0}function RL(e,t,n){return Math.abs(e[2]-t[2])<=TL*t[2]&&Math.hypot(e[0]-t[0],e[1]-t[1])<=TL*n}function Uue(e,t){const n=t[2]/e[2];return s=>[e[0]+(t[0]-e[0])*s,e[1]+(t[1]-e[1])*s,e[2]*n**s]}function Wue(e,t,n){const s=e(0),a=e(.5),o=e(1);if(!nu(s)||!nu(a)||!nu(o))return!1;const i=Math.max(t[2],n[2]);return RL(s,t,i)&&RL(o,n,i)}function Hue(e){return(t,n)=>{const s=e(t,n),a=Wue(s,t,n)?s:Uue(t,n);let o=nu(t)?t:n;return i=>{const c=a(i);return nu(c)&&(o=c),o}}}function zue(e){return Number.isFinite(e.x)&&Number.isFinite(e.y)&&Number.isFinite(e.zoom)&&e.zoom>0}const AL=new WeakSet,DF=420;function Vue(){const e=_l(),t=Dt(),n=y.useCallback((h,f)=>{if(!zue(h))return;if(o0({durationMs:f,documentHidden:document.hidden})){e.setViewport(h,{duration:f});return}const{d3Zoom:p,d3Selection:m}=t.getState(),w=m==null?void 0:m.property("__zoom");if(p&&m&&w&&w.k>0&&h.zoom>0){p.transform(m,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||AL.has(f)||(AL.add(f),f.interpolate(Hue(f.interpolate())))};return h(t.getState().d3Zoom),t.subscribe(f=>h(f.d3Zoom))},[t]);const s=y.useRef(null),a=y.useRef(0),o=y.useRef(0),i=y.useCallback((h,f)=>{const p=++a.current;return o.current=Date.now(),n(h,f),s.current=o0({durationMs:f,documentHidden:document.hidden})?{target:h,until:Date.now()+f+60}:null,p},[n]),c=y.useCallback((h=500)=>{const f=n1,p=1,m=.2,w=s1;try{const j=document.querySelector(".canvas-wrap"),v=Array.from(document.querySelectorAll(".react-flow__node")).filter(q=>q.offsetWidth>0);if(!j||v.length===0)return;const b=j.getBoundingClientRect(),k=e.getViewport();if(!Number.isFinite(k.zoom)||k.zoom<=0)return;const N=new Map(e.getNodes().map(q=>[q.id,q])),S=v.flatMap(q=>{const $=N.get(q.dataset.id??"");if(!$)return[];const K=$.positionAbsolute??$.position,G=$.width??q.offsetWidth,z=$.height??q.offsetHeight;return G>0&&z>0?[{left:K.x,right:K.x+G,top:K.y,bottom:K.y+z}]:[]});if(S.length===0)return;const _=Math.min(...S.map(q=>q.left)),E=Math.max(...S.map(q=>q.right)),I=Math.min(...S.map(q=>q.top)),A=Math.max(...S.map(q=>q.bottom)),O=E-_,L=A-I;if(!(O>0&&L>0))return;const U=PF(j),P=q=>Math.max(m,Math.min(p,(b.width-U-f*2)/(O+q)*w,(b.height-f*2)/L*w)),T=Kae(P(DF),P(0),xD(uj[dj()])),B={x:f-_*T,y:(b.height>b.width-U?f:Math.max(f,(b.height-L*T)/2))-I*T,zoom:T},M=i(B,h);window.setTimeout(()=>{var q;try{if(((q=s.current)==null?void 0:q.target)===B&&(s.current=null),a.current!==M)return;const $=e.getViewport();(Math.abs($.zoom-T)>.01||Math.abs($.x-B.x)>2||Math.abs($.y-B.y)>2)&&n(B,0)}catch{}},h+60)}catch{}},[e,n,i]);y.useEffect(()=>{const h=()=>{if(!document.hidden)return;const f=s.current;if(s.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:a,lastFitTimeRef:o}}const Gue=450;function Kue({canvasRef:e,stateRef:t,measuredRef:n,nodesRef:s,railInsetRef:a,moveCamera:o,disableAutoFit:i,lastFocusRef:c,focusAgentRef:d,selectAgent:h,primarySelectedIdRef:f}){const p=y.useCallback(j=>{const v=e.current,b=t.current.agents.get(j);if(!v||!b)return;const k=rN(t.current),N=(O,L)=>{const U=n.current.get(O.id);if(!U)return null;const P=L&&k.has(O.id)?DF:0;return{x:O.position.x,y:O.position.y,width:U.width+P,height:U.height}},S=s.current.find(O=>O.id===j),_=S?N(S,!1):null;if(!_)return;const E=[];for(const O of s.current){if(O.type!=="agent"&&O.type!=="recapNote"||Xn(O)!==Xn(S))continue;const L=N(O,O.type==="agent");L&&E.push(L)}const I=v.getBoundingClientRect(),A=Fue({pane:{width:I.width,height:I.height},insets:{top:56,left:72,bottom:32,right:a.current+32},context:Bue(E)??_,anchor:_});Xa(),i(),c.current={id:j,at:Date.now()},o(A,Gue)},[o,i]);d.current=p;const m=y.useCallback(j=>{const v=s.current.filter(S=>S.type==="agent"),b=Tue(v.map(S=>({id:S.id,x:S.position.x,y:S.position.y})),f.current,j),k=b?v.find(S=>S.id===b):void 0;if(!k)return;const N=aN(document.activeElement);h(k.id,!1),window.setTimeout(()=>{try{p(k.id)}catch{}N&&$F(k.id)},30)},[h,p]),w=y.useCallback(j=>{h(j,!1),window.setTimeout(()=>{try{p(j)}catch{}},60)},[h,p]);return{focusAgent:p,stepAgent:m,focusSession:w}}function Yue({nodesRef:e,stateRef:t,canvasRef:n,railInsetRef:s}){const a=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(m=>m.id===d&&m.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-s.current,height:d.bottom}:{width:h.clientWidth,height:h.clientHeight}},[]);return{peekAgent:a,peekLabel:o,peekRecap:i,peekBounds:c}}function Xue(e){const t=new Set(e.pins),n=new Map,s=new Map;for(const[a,o]of e.positions)n.set(a,o),t.has(a)&&s.set(a,o);return{positions:n,pinned:s,restored:new Set(n.keys())}}function ML(e){return Object.entries(e??{}).filter(([,t])=>t&&typeof t.x=="number"&&typeof t.y=="number")}function Zue(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 a=ML(n);return{positions:a,pins:a.map(([o])=>o)}}const s=n;return{positions:ML(s.positions),pins:Array.isArray(s.pins)?s.pins:[]}}function Jue(e,t){const n={};for(const[s,a]of e)n[s]=a;for(const[s,a]of t)n[s]=a;return JSON.stringify({v:2,positions:n,pins:Array.from(t.keys())})}function Que(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 Ku="agent-dag.layout",Yu="agent-dag.layoutFrame",Xu="agent-dag.viewport";function ede(){return Zue(Ze(Ku))}function hl(e,t){Xe(Ku,Jue(e,t))}function tde(){return Que(Ze(Yu))}function FF(e){Xe(Yu,JSON.stringify(e))}function nde(){return kz(Ze(Xu))}function sde(e){Xe(Xu,JSON.stringify(e))}function rde(){return{layout:Ze(Ku),frame:Ze(Yu),viewport:Ze(Xu)}}function ade(e){const t=(n,s)=>s===null?wr(n):Xe(n,s);t(Ku,e.layout),t(Yu,e.frame),t(Xu,e.viewport)}function BF(){wr(Ku),wr(Xu),wr(Yu)}function ode({fitLeft:e,moveCamera:t,currentViewport:n}){const s=y.useState(()=>Xue(ede()))[0],a=y.useRef(s.pinned),o=y.useRef(s.positions),i=y.useRef(new Set),c=y.useRef(""),[d,h]=y.useState(0),f=y.useState(tde)[0],p=y.useRef(f),[m,w]=y.useState(!1),[j,v]=y.useState(""),b=y.useState(()=>$Y(L=>{w(L),L||v(U=>U===RE?U:"")}))[0];y.useEffect(()=>()=>b.close(),[b]),y.useEffect(()=>{if(typeof document>"u")return;const L=()=>document.hidden?b.hold("hidden"):b.release("hidden");return document.addEventListener("visibilitychange",L),()=>document.removeEventListener("visibilitychange",L)},[b]);const k=y.useRef(null),N=()=>({positions:o.current,pinned:a.current,provisional:i.current,layoutSig:c}),S=y.useCallback(()=>{b.open(b.snapshot??_Y(N(),rde(),n())),v(AY),a.current.clear(),o.current.clear(),c.current="",BF(),h(L=>L+1),k.current!=null&&window.clearTimeout(k.current),k.current=window.setTimeout(()=>{k.current=null,hl(o.current,a.current),p.current&&FF(p.current),e(500)},80)},[e,n,b]),_=y.useCallback(()=>{const L=b.take();return L?(k.current!=null&&window.clearTimeout(k.current),k.current=null,CY(L,N()),ade(L.stored),h(U=>U+1),L.viewport&&t(L.viewport,500),v(RE),!0):!1},[t,b]),E=y.useCallback(()=>b.close(),[b]),I=y.useCallback(L=>b.hold(L),[b]),A=y.useCallback(L=>b.release(L),[b]);return{restoredLayout:s,pinnedRef:a,positionsRef:o,provisionalRef:i,lastLayoutSigRef:c,layoutEpoch:d,setLayoutEpoch:h,lastLayoutFrameRef:p,handleRelayout:S,rearrangeUndo:{open:m,said:j,undo:_,dismiss:E,hold:I,release:A}}}function ide(e,t){const{positionsRef:n,pinnedRef:s}=t,a=y.useRef(null);y.useEffect(()=>(a.current!=null&&window.clearTimeout(a.current),a.current=window.setTimeout(()=>{hl(n.current,s.current)},1500),()=>{a.current!=null&&window.clearTimeout(a.current)}),[e])}function lde({nodes:e,edges:t,settled:n,dragging:s,availableWidth:a,availableHeight:o,layout:i,camera:c,rf:d,measuredRef:h,stateRef:f,lastFocusRef:p,primarySelectedIdRef:m,focusAgentRef:w,autoFitDisabledRef:j}){const{lastLayoutFrameRef:v,pinnedRef:b,positionsRef:k,provisionalRef:N,lastLayoutSigRef:S,setLayoutEpoch:_}=i,{applyViewport:E,fitLeft:I,cameraEpochRef:A,lastFitTimeRef:O}=c;y.useEffect(()=>{if(!n||s)return;const L={width:a,height:o};if(!(L.width>0&&L.height>0))return;const U=v.current;if(v.current=L,FF(L),!U||U.width===L.width&&U.height===L.height)return;const P={direction:"LR",pinned:b.current,measured:h.current,lanes:rN(f.current)},T=p.current&&Date.now()-p.current.at<1500?p.current.id:null;if(!wue(e,t,P,U,L)){const q=A.current,$=window.setTimeout(()=>{var K;A.current===q&&(j.current?T&&((K=p.current)==null?void 0:K.id)===T&&w.current(T):I(500))},80);return()=>window.clearTimeout($)}const B=T??m.current,M=B?b.current.get(B)??k.current.get(B):void 0;for(const q of Array.from(k.current.keys()))b.current.has(q)||k.current.delete(q);N.current.clear(),S.current="",_(q=>q+1),window.setTimeout(()=>{if(hl(k.current,b.current),j.current){if(T){w.current(T);return}const q=B?b.current.get(B)??k.current.get(B):void 0;if(M&&q&&(q.x!==M.x||q.y!==M.y)){const $=d.getViewport();A.current+=1,E({x:$.x-(q.x-M.x)*$.zoom,y:$.y-(q.y-M.y)*$.zoom,zoom:$.zoom},0),O.current=Date.now()}return}I(500)},80)},[a,o,n,s,I,d,E])}function cde(e,t,n,s,a){const o=[];for(const i of e)!hp(i,t)||n.has(i.id)||o.push(i.id+(i.parentId?`>${i.parentId}`:""));return o.sort(),`${o.join("|")}#sv${s}.${a}`}const oN="agent-dag.removedNodes";function ude(e){try{const t=JSON.parse((e==null?void 0:e.getItem(oN))??"[]");return new Set(Array.isArray(t)?t.filter(n=>typeof n=="string"):[])}catch{return new Set}}function Mk(e,t){try{e==null||e.setItem(oN,JSON.stringify([...t]))}catch{}}function qF(e,t){const n=new Map(e.map(o=>[o.id,o.parentId])),s=new Set(t),a=o=>{if(s.has(o))return!0;const i=new Set([o]);let c=n.get(o);for(;c&&!i.has(c);){if(s.has(c))return s.add(o),!0;i.add(c),c=n.get(c)}return!1};return o=>a(o.id)||a(o.sessionId??o.id)}function dde(e,t){if(t.size===0)return new Set;const n=[...e],s=qF(n,t);return new Set(n.filter(s).map(a=>a.id))}function hde(e,t,n){const s=c=>({id:c.id,parentId:c.data.parentId,sessionId:c.data.sessionId}),a=qF(e.map(s),n),o=e.filter(c=>!a(s(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 fde(e,t){let n=null;for(const s of t)e.has(s)&&(n??(n=new Set(e)),n.delete(s));return n??e}function pde(e,t){return t.size===0?[]:[...e].filter(n=>t.has(n.id)).map(n=>n.id)}function mde(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 s=e.prompts[e.prompts.length-1];return s&&s.at>t&&(t=s.at),e.lastOutputAt!=null&&e.lastOutputAt>t&&(t=e.lastOutputAt),t}function gde(e,t,n){let s=null;for(const a of t)e.has(a)||(s??(s=new Map(e)),s.set(a,n));for(const a of e.keys())t.has(a)||(s??(s=new Map(e)),s.delete(a));return s??e}function yde(e,t,n,s){if(n.size===0)return[];let a=1/0;for(const i of s.values())i<a&&(a=i);const o=new Set;for(const i of t){const c=e.get(i);if(!c)continue;const d=mde(c);if(d<=a)continue;const h=[],f=new Set,p=w=>{var j;for(let v=w;v&&!f.has(v);v=(j=e.get(v))==null?void 0:j.parentId)f.add(v),n.has(v)&&h.push(v)};p(c.id),p(c.sessionId);let m=-1/0;for(const w of h)m=Math.max(m,s.get(w)??1/0);if(d>m)for(const w of h)o.add(w)}return[...o]}const Pf="sessionGroup";function wde(e,t){var s,a;if(e.type===Pf)return"transparent";if(Mn((s=e.data)==null?void 0:s.waiting))return t("--warn");if(e.type==="recapNote")return t("--muted");const n=(a=e.data)==null?void 0:a.state;return t(n==="err"?"--err":n==="active"?"--inflight":"--ok")}const _h=Oo;function xde(e){const t=new Map;for(const s of e){const a=s.data;if(!(a!=null&&a.sessionId)||a.exitAt!=null)continue;const o=s.width,i=s.height;if(o==null||i==null)continue;const c=s.position.x,d=s.position.y,h=c+o,f=d+i,p=t.get(Xn(s));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(Xn(s),{minX:c,minY:d,maxX:h,maxY:f})}const n=[];for(const[s,a]of t){const o=a.maxX-a.minX+_h*2,i=a.maxY-a.minY+_h*2;n.push({id:`group:${s}`,type:Pf,position:{x:a.minX-_h,y:a.minY-_h},data:{sessionId:s,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 vde(e,t){if(!t||!e.agents.get(t))return null;const s=new Set([t]);let a=t;for(;a;){const i=e.agents.get(a);if(!(i!=null&&i.parentId)||s.has(i.parentId))break;s.add(i.parentId),a=i.parentId}let o=!0;for(;o;){o=!1;for(const i of e.agents.values())i.parentId&&s.has(i.parentId)&&!s.has(i.id)&&(s.add(i.id),o=!0)}return s}function bde(e,t){const n=new Set;for(const s of t){const a=vde(e,s);if(a)for(const o of a)n.add(o)}return n.size>0?n:null}function kde({stateRef:e,now:t,removedAgentIds:n,sizeVersion:s,domSizeVersion:a}){return y.useMemo(()=>cde(e.current.agents.values(),t,n,s,a),[e.current,e.current.revision,t,s,a,n])}function jde({stateRef:e,now:t,availableWidth:n,availableHeight:s,layout:a,measuredRef:o,onBubble:i,settled:c,dragging:d,layoutSig:h,selectedIds:f,openContext:p,historyReplayed:m,removedNodes:w,removedAgentIds:j,dragTick:v,dragPatchRef:b,dragMoveTick:k}){const{pinnedRef:N,positionsRef:S,provisionalRef:_,lastLayoutSigRef:E,restoredLayout:I,layoutEpoch:A}=a,O=y.useMemo(()=>bde(e.current,f),[e.current,e.current.revision,f]),L=y.useMemo(()=>{const $=BX(e.current,t);for(const K of j)$.delete(K);return $},[e.current,e.current.revision,t,j]),U=y.useRef(new Map),P=uV(),{nodes:T,edges:B}=y.useMemo(()=>{const $=Cue(e.current,t,n,s,N.current,o.current,U.current,i,c,d,S.current,_.current,h,E,f,O,L,p,m,I.restored);return hde($.nodes,$.edges,w)},[e.current,e.current.revision,t,n,s,c,d,h,f,O,L,p,v,P,w,A,m]),M=y.useMemo(()=>xde(T),[T]),q=y.useMemo(()=>{const $=[...M,...T],K=b.current;return!K||K.size===0?$:$.map(G=>{const z=K.get(G.id);return z?{...G,position:z}:G})},[M,T,k]);return{spotlightSet:O,visibleAgentIds:L,nodes:T,edges:B,allNodes:q}}function Nde(e,t,n){const s=e.x*t.zoom+t.x,a=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&&s<n.width&&i>0&&a<n.height}function Sde({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 s=!1;for(const a of n)if(s=!0,Nde(a,t,e))return!1;return s}function _de({layoutSig:e,rf:t,stateRef:n,measuredRef:s,pinnedRef:a,positionsRef:o,paneSizeRef:i,lastInteractRef:c,autoFitDisabledRef:d,lastFitTimeRef:h,fitLeft:f}){const p=y.useRef(null),m=y.useRef("");y.useEffect(()=>{const w=setInterval(()=>{if(d.current||Date.now()-c.current<800)return;const j=n.current,v=Date.now(),b=[];for(const N of j.agents.values())hp(N,v)&&b.push({id:N.id});if(b.length===0)return;const k=[];for(const{id:N}of b){const S=s.current.get(N),_=a.current.get(N)??o.current.get(N);!S||!_||k.push({x:_.x,y:_.y,width:S.width,height:S.height})}Sde({pane:i.current,viewport:t.getViewport(),boxes:k})&&f(600)},1500);return()=>clearInterval(w)},[t]),y.useEffect(()=>{if(m.current===e)return;const w=m.current;if(m.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 Cde({stateRef:e,pinnedRef:t,positionsRef:n,canvasRef:s,clearSelection:a,primarySelectedId:o}){const[i,c]=y.useState(()=>ude(mr())),[d,h]=y.useState(null),f=y.useMemo(()=>dde(e.current.agents.values(),i),[e.current,e.current.revision,i]),p=y.useCallback(N=>{const S=e.current.agents.get(N);S&&(c(_=>{const E=new Set(_);return E.add(N),Mk(mr(),E),E}),h({id:N,label:S.label}),t.current.delete(N),n.current.delete(N),a())},[a]),m=y.useCallback(()=>{o&&p(o)},[o,p]),w=d&&i.has(d.id)?d:null;y.useEffect(()=>{var N;d&&((N=s.current)==null||N.focus())},[d]);const j=y.useCallback(N=>{const S=[...N];c(_=>{let E=null;for(const I of S)_.has(I)||(E??(E=new Set(_)),E.add(I));return E?(Mk(mr(),E),E):_});for(const _ of S)t.current.delete(_),n.current.delete(_)},[]),v=y.useCallback(N=>{const S=[...N];c(_=>{const E=fde(_,S);return E!==_&&Mk(mr(),E),E})},[]),b=y.useCallback(()=>{v([...i]),h(null)},[v,i]),k=y.useCallback(()=>{c(new Set),h(null),wr(oN)},[]);return{removedNodes:i,lastRemoval:d,removedAgentIds:f,removeNode:p,removeSelectedNode:m,removalNotice:w,hideSessions:j,bringBack:v,bringBackAll:b,forgetRemovals:k}}function Ede({stateRef:e,waitingSessions:t,removedAgentIds:n,removedNodes:s,bringBack:a}){const o=y.useRef(new Map);y.useEffect(()=>{o.current=gde(o.current,s,Date.now());const i=[...pde(t,n),...yde(e.current.agents,n,s,o.current)];i.length>0&&a(i)},[t,n,s,a])}const UF=[0,5,15,30,60],iN="agent-dag.hide-finished-after",WF="agent-dag.hide-finished-turns",Tde=300,Rde=1e4;function lN(e){const t=Number(e);return UF.includes(t)?t:0}function Ade(e){return e===0?"Never":`${e} min`}let Ho=null;const Hc=new Set;function HF(){for(const e of Hc)e()}function $L(){return Ho===null&&(Ho=lN(Ze(iN))),Ho}function Mde(e){const t=lN(String(e));Ho!==t&&(Ho=t,Xe(iN,String(t)),HF())}function LL(e){if(e.key!==iN)return;const t=lN(e.newValue);t!==Ho&&(Ho=t,HF())}function $de(e){var t;return Hc.add(e),Hc.size===1&&typeof window<"u"&&((t=window.addEventListener)==null||t.call(window,"storage",LL)),()=>{var n;Hc.delete(e),Hc.size===0&&typeof window<"u"&&((n=window.removeEventListener)==null||n.call(window,"storage",LL))}}function Lde(e){try{const t=JSON.parse((e==null?void 0:e.getItem(WF))??"{}");return!t||typeof t!="object"||Array.isArray(t)?new Map:new Map(Object.entries(t).filter(n=>typeof n[1]=="number"))}catch{return new Map}}function IL(e,t){const n=[...t].sort((s,a)=>a[1]-s[1]).slice(0,Tde);try{e==null||e.setItem(WF,JSON.stringify(Object.fromEntries(n)))}catch{}}function zF(e){const t=new Map;for(const s of e){let a=t.get(s.sessionId);a||(a={endedAt:0,live:!1},t.set(s.sessionId,a)),s.kind==="root"&&Mn(s.waiting)&&(a.live=!0),s.state==="done"&&s.endedAt!=null?a.endedAt=Math.max(a.endedAt,s.endedAt):a.live=!0}const n=new Map;for(const[s,a]of t)!a.live&&a.endedAt>0&&n.set(s,a.endedAt);return n}function Ide(e,{afterMs:t,now:n,removed:s,handled:a,keep:o}){if(t<=0)return[];const i=[];for(const[c,d]of zF(e))n-d<t||s.has(c)||c===o||a.get(c)!==d&&i.push({id:c,endedAt:d});return i}function Ode(e,t,n,s){const a=[...t].filter(c=>!n.has(c));if(a.length===0)return e;const o=zF(s);let i=null;for(const c of a){const d=o.get(c);d==null||e.get(c)===d||(i??(i=new Map(e)),i.set(c,d))}return i??e}function VF(){return y.useSyncExternalStore($de,$L,$L)}function Pde({stateRef:e,removedNodes:t,hideSessions:n,keepSessionId:s,ready:a}){const o=VF(),[i]=y.useState(()=>Lde(mr())),c=y.useRef(i),d=y.useRef(t);y.useEffect(()=>{const h=Ode(c.current,d.current,t,e.current.agents.values());d.current=t,h!==c.current&&(c.current=h,IL(mr(),h))},[t]),y.useEffect(()=>{if(!a||o===0)return;const h=()=>{const p=Ide(e.current.agents.values(),{afterMs:o*6e4,now:Date.now(),removed:t,handled:c.current,keep:s});if(p.length===0)return;const m=new Map(c.current);for(const{id:w,endedAt:j}of p)m.set(w,j);c.current=m,IL(mr(),m),n(p.map(w=>w.id))};h();const f=window.setInterval(h,Rde);return()=>window.clearInterval(f)},[a,o,t,s,n])}function Dde({waiting:e,running:t,connected:n=!0}){return{title:e>0?`(${e}) ${Rt}`:Rt,icon:n?e>0?"waiting":t>0?"running":"idle":"offline"}}const GF=Object.freeze({offline:"/state/favicon-error.svg",waiting:"/state/favicon-waiting.svg",running:"/state/favicon-syncing.svg",idle:"/favicon.svg"}),KF=Object.freeze({offline:"/state/favicon-error-32.png",waiting:"/state/favicon-waiting-32.png",running:"/state/favicon-syncing-32.png",idle:"/favicon.ico"}),Fde=Object.freeze([...new Set([...Object.values(GF),...Object.values(KF)])]),r1=new Map;function OL(e){return r1.get(e)??e}async function Bde(e,t=n=>fetch(n)){await Promise.all(e.map(async n=>{if(!r1.has(n))try{const s=await t(n),a=(s.headers.get("Content-Type")??"").split(";")[0].trim();if(!s.ok||!a.startsWith("image/"))return;r1.set(n,`data:${a};base64,${qde(new Uint8Array(await s.arrayBuffer()))}`)}catch{}}))}function qde(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function Ude({stateRef:e,waitingSessions:t,live:n}){const s=y.useMemo(()=>h9(e.current.agents.values()),[e.current,e.current.revision]),a=y.useRef(null);y.useEffect(()=>{n&&Bde(Fde)},[n]),y.useEffect(()=>{const o=Dde({waiting:t.length,running:s,connected:n}),i=a.current;a.current=o,(i==null?void 0:i.title)!==o.title&&(document.title=o.title),(i==null?void 0:i.icon)!==o.icon&&YF(o.icon)},[t.length,s,n])}function YF(e){const t=document.querySelector('link[rel="icon"][type="image/svg+xml"]');t&&(t.href=OL(GF[e]));const n=document.querySelector('link[rel="icon"][sizes="32x32"]');n&&(n.href=OL(KF[e]))}const Wde=1200,Hde=1e3;function $k(e){return e.lastDeckFitAt>0&&e.at-e.lastDeckFitAt<Wde?!1:e.hasSourceEvent?!0:e.lastCanvasInputAt>0&&e.at-e.lastCanvasInputAt<Hde}function zde({applyViewport:e,lastFitTimeRef:t,cameraEpochRef:n,disableAutoFit:s,markInteract:a,canvasRef:o,applyZoom:i}){const c=y.useState(()=>nde())[0];y.useEffect(()=>{if(!c)return;const j=window.setTimeout(()=>{try{e(c,0)}catch{}t.current=Date.now()},60);return()=>window.clearTimeout(j)},[e,c]);const d=y.useRef(null),h=y.useRef(0),f=y.useCallback(()=>{h.current=Date.now()},[]),p=y.useCallback(j=>({hasSourceEvent:!!j,at:Date.now(),lastDeckFitAt:t.current,lastCanvasInputAt:h.current}),[]);return{restoredViewport:c,markCanvasInput:f,onMoveStart:j=>{Xa(),$k(p(j))&&(n.current+=1),$k(p(j))&&s()},onMove:(j,v)=>{var b;a(),$k(p(j))&&s(),(b=o.current)==null||b.style.setProperty("--zoom",String(v.zoom)),i(v.zoom)==="detail"&&Xa(),d.current&&window.clearTimeout(d.current),d.current=window.setTimeout(()=>sde(v),250)}}}function Vde({clearSelection:e,selectAgent:t,detailOpen:n,setDetailOpen:s,detailShown:a,focusAgent:o,draggingRef:i,lodRef:c}){const d=y.useRef(o);d.current=o;const[h]=y.useState(()=>BP({focus:v=>d.current(v),setTimeout:(v,b)=>window.setTimeout(v,b),clearTimeout:v=>window.clearTimeout(v)}));return y.useEffect(()=>()=>h.cancel(),[h]),{onNodeClick:(v,b)=>{if(b.type==="sessionGroup"){h.cancel(),e();return}const k=b.type==="recapNote"?b.data.parentId:b.id;t(k,v.shiftKey,!1),!v.shiftKey&&(n&&s(!1),$u()?h.hold(k):a?window.setTimeout(()=>{try{o(k)}catch{}},80):o(k))},onPaneClick:()=>{h.cancel(),Xa(),e()},onNodeDoubleClick:(v,b)=>{if(b.type!=="agent"&&b.type!=="recapNote")return;h.cancel();const k=b.type==="recapNote"?b.data.parentId:b.id;t(k,!1),window.setTimeout(()=>{try{o(k)}catch{}},80)},onNodeMouseEnter:(v,b)=>{b.type!=="agent"&&b.type!=="recapNote"||i.current||c.current==null||c.current==="detail"||IF(b.id,v.currentTarget)},onNodeMouseLeave:(v,b)=>Xa(b.id)}}function Gde({settleAt:e,now:t,take:n,schedule:s,cancel:a}){let o=null;const i=()=>{o!=null&&a(o),o=null};return{read(c,d){i();const h=e()-t();if(h>0){o=s(()=>{o=null,n(c,d)},h);return}n(c,d)},dispose:i}}function Kde(e){const t=y.useRef(null),n=y.useRef(null),[s,a]=y.useState({w:0,h:0});return y.useEffect(()=>{const o=n.current;if(!o||typeof ResizeObserver>"u")return;const i=Gde({settleAt:()=>(e==null?void 0:e.current)??0,now:()=>performance.now(),take:(d,h)=>a(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},a({w:o.clientWidth,h:o.clientHeight}),()=>{c.disconnect(),i.dispose()}},[]),{canvasRef:n,canvasSize:s,paneSizeRef:t}}function Yde(e){const t=Dt(),n=y.useRef(new Map),s=y.useRef(0),a=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 m=!1;for(const j of t.getState().nodeInternals.values()){if(j.type===Pf)continue;const v=j.width,b=j.height;if(v==null||b==null)continue;const k=a.current.get(j.id);(!k||Math.abs(k.width-v)>4||Math.abs(k.height-b)>4)&&(a.current.set(j.id,{width:v,height:b}),n.current.set(j.id,{width:v,height:b}),m=!0)}if(m&&(s.current+=1,i(s.current)),e.current)return;let w=!1;for(const j of document.querySelectorAll(".react-flow__node[data-id]")){if(j.classList.contains(`react-flow__node-${Pf}`))continue;const v=j.getAttribute("data-id");if(!v)continue;const b=j.offsetWidth,k=j.offsetHeight;if(!b||!k)continue;const N=n.current.get(v);(!N||Math.abs(N.width-b)>4||Math.abs(N.height-k)>4)&&(n.current.set(v,{width:b,height:k}),w=!0)}w&&d(j=>j+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 m=t.subscribe(p);return p(),()=>{m();const w=h.current;w&&(cancelAnimationFrame(w.frame),window.clearTimeout(w.timer),h.current=null)}},[t,p]),y.useEffect(p),{measuredRef:n,measuredVersionRef:s,sizeVersion:o,domSizeVersion:c}}function Xde(){const[e,t]=y.useState(!1);return y.useEffect(()=>{const n=window.setTimeout(()=>t(!0),2500);return()=>window.clearTimeout(n)},[]),e}function Zde(){const e=y.useRef(null);return y.useEffect(()=>{let t=-1/0;const n=()=>{t=performance.now()},s=a=>{e.current=performance.now()-t<250?a.target:null};return window.addEventListener("pointerdown",n,!0),window.addEventListener("focusin",s,!0),()=>{window.removeEventListener("pointerdown",n,!0),window.removeEventListener("focusin",s,!0)}},[]),e}const Fa=[{id:"general",label:"General",note:"The board, updates, and the settings that live in their own panels."},{id:"appearance",label:"Appearance",note:"The colour theme and the character on the canvas."},{id:"reading",label:"Text & density",note:"Make the deck comfortable to read. Changes apply immediately and stay separate from canvas zoom."},{id:"keyboard",label:"Keyboard",note:"Every shortcut, and whether single keys answer."},{id:"notifications",label:"Notifications",note:"How the deck reaches you while you are not looking at it."},{id:"sounds",label:"Sounds",note:"What plays when a turn finishes and when Claude asks."},{id:"data",label:"Data",note:"What the deck keeps on this device."},{id:"radar",label:"Radar",note:"Automatic monitoring of Claude telemetry, off unless you turn it on."},{id:"about",label:"About",note:"The version you are running, and where to say what you think of it."}];function Jde(e){return Math.max(0,Fa.findIndex(t=>t.id===e))}const PL="settings-tab-";function Qde(e,t){return e!=null&&e.startsWith(PL)?e===`${PL}${t}`?null:t:null}const ehe={open:!1,section:"general"};function the(e,t){return{open:!0,section:t??e.section}}function Ma(e,t){return()=>{e(),t()}}function nhe(e){return e.key===","&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey}function she(e){return Bu(e)?"⌘,":"Ctrl+,"}function rhe(e){if(!(e.metaKey||e.ctrlKey)||e.altKey||e.shiftKey)return!1;const t=e.key.toLowerCase();return t==="f"||!/^[a-z]$/.test(t)&&e.code==="KeyF"}const Zu={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"}},Zr=Object.keys(Zu);function a1(e){return Zr[(Zr.indexOf(e)+1)%Zr.length]}const XF="agent-dag.theme";function ahe(e,t=!1){return typeof e=="string"&&Object.hasOwn(Zu,e)?e:"rider-black"}function ohe(){return ahe(Ze(XF))}function ihe({pointerFocusRef:e,nodesRef:t,stateRef:n,primarySelectedIdRef:s,providersRef:a,soundOnRef:o,keyHelpOpenRef:i,modalOpenRef:c,waitingCursorRef:d,removeSelectedRef:h,activateSoundRef:f,clearSelection:p,selectAgent:m,focusAgent:w,stepAgent:j,focusSession:v,requestClear:b,handleRelayout:k,undoRearrange:N,handleFit:S,togglePause:_,toggleSessionList:E,toggleAccountsPanel:I,setDetailOpen:A,setUsageHistoryOpen:O,setUsagePanelOpen:L,setMachinePanelOpen:U,setBrowserWatchOpen:P,setKeyHelpOpen:T,setTheme:B,openSettings:M}){y.useEffect(()=>{const q=$=>{var H,ee;const K=$.target,G={tagName:K==null?void 0:K.tagName,isContentEditable:K==null?void 0:K.isContentEditable,role:(H=K==null?void 0:K.getAttribute)==null?void 0:H.call(K,"role"),type:K==null?void 0:K.type,pointerFocused:K!=null&&K===e.current};if($.key==="Escape"){const F=L9({overlayOpen:Tn.depth()>0,typing:Bo(G)});F==="dismiss"?Tn.dismissTop():F==="blur"?K==null||K.blur():($ue(G)&&(K==null||K.blur()),p());return}if($.key===","&&nhe($)){if(Bo(G)||Oh({appModal:c.current,dialogDepth:Tn.dialogDepth()}))return;$.preventDefault(),$.repeat||M();return}if(LY($)){if(Bo(G)||Oh({appModal:c.current,dialogDepth:Tn.dialogDepth()}))return;!$.repeat&&N()&&$.preventDefault();return}if(rp($))return;const z=aN(K)?(ee=K==null?void 0:K.getAttribute)==null?void 0:ee.call(K,"data-id"):null,W=z&&t.current.some(F=>F.id===z)?z:null,D=Aue($,W);if(D.kind==="activate"){$.preventDefault(),m(D.nodeId,D.additive);return}if(D.kind!=="node"&&!yP($.key,y0())){if(H9({key:$.key,sheetOpen:i.current,target:G})){$.repeat||T(!1);return}if(!(D.nodeId==null&&U9(G,$.key))&&!W9({key:$.key,modalOpen:Oh({appModal:c.current,dialogDepth:Tn.dialogDepth()}),sheetOpen:i.current})&&!($.repeat&&!/^[ jkJK]$/.test($.key))){if($.key===" "&&($.preventDefault(),$.repeat||_()),($.key==="c"||$.key==="C")&&b("shortcut"),($.key==="r"||$.key==="R")&&k(),($.key==="f"||$.key==="F")&&S(),($.key==="z"||$.key==="Z")&&s.current&&w(s.current),$.key==="Delete"&&h.current(),($.key==="l"||$.key==="L")&&E(),$.key==="d"||$.key==="D")if(s.current)A(F=>!F);else{const F=u0(n.current.agents.values());F.length>0?v(F[0].id):j(1)}if(($.key==="h"||$.key==="H")&&O(F=>!F),($.key==="u"||$.key==="U")&&L(F=>!F),($.key==="a"||$.key==="A")&&a.current.claude&&I(),($.key==="j"||$.key==="J")&&j(1),($.key==="k"||$.key==="K")&&j(-1),$.key==="w"||$.key==="W"){const F=d9(u0(n.current.agents.values()),d.current);F&&(d.current=F.id,v(F.id))}($.key==="t"||$.key==="T")&&B(a1),($.key==="m"||$.key==="M")&&o.current!==null&&f.current($.shiftKey),($.key==="s"||$.key==="S")&&U(F=>!F),($.key==="b"||$.key==="B")&&P(F=>!F),($.key==="v"||$.key==="V")&&M("sounds"),$.key==="?"&&T(F=>!F)}}};return window.addEventListener("keydown",q),()=>window.removeEventListener("keydown",q)},[b,k,N,S,p,m,j,v,w,_])}function lhe(){var e,t;return((t=(e=document.activeElement)==null?void 0:e.matches)==null?void 0:t.call(e,":focus-visible"))===!0}function che({sessionListShown:e,usageShown:t,machineShown:n,accountsShown:s,detailShown:a,primarySelectedId:o,canvasRef:i}){const c={sessionList:y.useRef(null),usage:y.useRef(null),accounts:y.useRef(null),machine:y.useRef(null)},d=h=>()=>{lhe()&&h()};return{toggles:c,sessionList:d(Xr(!e,c.sessionList)),usage:d(Xr(!t,c.usage)),machine:d(Xr(!n,c.machine)),accounts:d(Xr(!s,c.accounts)),detail:d(Xr(!a,()=>{var h,f;o&&$F(o),Yn(((h=document.activeElement)==null?void 0:h.tagName)??null)&&((f=i.current)==null||f.focus({preventScroll:!0}))}))}}function uhe({nodes:e,stateRef:t,pinnedRef:n,positionsRef:s,draggingRef:a,dragPatchRef:o,setDragging:i,setDragMoveTick:c,setDragTick:d,endBubble:h,markInteract:f,disableAutoFit:p,beginTrashDrag:m,trackTrashDrag:w,endTrashDrag:j,removeNode:v}){const b=y.useRef(null);return{onNodeDragStart:(_,E)=>{var I,A;if(E){if(Xa(),h(),a.current=!0,o.current=new Map,i(!0),f(),p(),E.type==="sessionGroup"){const O=(I=E.data)==null?void 0:I.sessionId,L=new Map,U=new Map;if(O)for(const T of e)!T.data||Xn(T)!==O||(L.set(T.id,{x:T.position.x,y:T.position.y}),U.set(T.id,n.current.get(T.id)));b.current={sessionId:O,start:{x:E.position.x,y:E.position.y},members:L,pinsBefore:U};const P=O?t.current.agents.get(O):void 0;m(P?P.label:null);return}m(E.type==="agent"?((A=t.current.agents.get(E.id))==null?void 0:A.label)??"":null),n.current.set(E.id,{x:E.position.x,y:E.position.y})}},onNodeDrag:(_,E)=>{var I;if(E){if(f(),(E.type==="agent"||E.type==="sessionGroup")&&w(_),E.type==="sessionGroup"){const A=b.current;if(!A)return;const O=E.position.x-A.start.x,L=E.position.y-A.start.y;for(const[P,T]of A.members){const B={x:T.x+O,y:T.y+L};n.current.set(P,B),s.current.set(P,B)}const U=o.current;if(U){for(const[P,T]of A.members)U.set(P,{x:T.x+O,y:T.y+L});U.set(E.id,{x:E.position.x,y:E.position.y})}c(P=>P+1);return}n.current.set(E.id,{x:E.position.x,y:E.position.y}),s.current.set(E.id,{x:E.position.x,y:E.position.y}),(I=o.current)==null||I.set(E.id,{x:E.position.x,y:E.position.y}),c(A=>A+1)}},onNodeDragStop:(_,E)=>{f();const I=j(_,(E==null?void 0:E.type)==="agent"||(E==null?void 0:E.type)==="sessionGroup");if(a.current=!1,o.current=null,i(!1),d(A=>A+1),!E){b.current=null,hl(s.current,n.current);return}if(E.type==="sessionGroup"){const A=b.current;if(A&&I&&A.sessionId){for(const[O,L]of A.members){const U=A.pinsBefore.get(O);U?n.current.set(O,U):n.current.delete(O),s.current.set(O,L)}b.current=null,v(A.sessionId);return}if(A){const O=E.position.x-A.start.x,L=E.position.y-A.start.y;for(const[U,P]of A.members){const T={x:P.x+O,y:P.y+L};n.current.set(U,T),s.current.set(U,T)}}b.current=null,hl(s.current,n.current),d(O=>O+1);return}if(n.current.set(E.id,{x:E.position.x,y:E.position.y}),s.current.set(E.id,{x:E.position.x,y:E.position.y}),I){v(E.id);return}hl(s.current,n.current)}}}function dhe(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 ZF({active:e=!1}){const[t,n]=y.useState(()=>typeof document>"u"||!document.hidden);return y.useEffect(()=>{const s=()=>n(!document.hidden);return document.addEventListener("visibilitychange",s),()=>document.removeEventListener("visibilitychange",s)},[]),r.jsx("div",{className:"empty-symbol","aria-hidden":"true","data-active":e&&t,children:r.jsxs("svg",{width:"32",height:"32",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round",children:[r.jsx("path",{d:"m6 8 4 4-4 4"}),r.jsx("path",{className:"empty-cursor",d:"M13 16h5"})]})})}function hhe({reservedRight:e=0}){return r.jsx("div",{className:"empty-stage",style:{right:e},children:r.jsxs("div",{className:"empty-hero",children:[r.jsx(ZF,{}),r.jsxs("h2",{children:["Too many ",Rt," tabs are open"]}),r.jsxs("p",{children:["This browser keeps at most six live connections to one address, and other ",r.jsx("code",{children:Rt})," tabs are holding them. Close one and this tab connects on its own."]})]})})}function fhe({live:e,everConnected:t,providers:n,workspace:s,onTour:a,reservedRight:o=0}){const i=!e;return r.jsx("div",{className:"empty-stage",style:{right:o},children:r.jsxs("div",{className:"empty-hero",children:[r.jsx(ZF,{active:e}),i?r.jsxs(r.Fragment,{children:[r.jsx("h2",{children:t?"Disconnected from server":"Server unreachable"}),r.jsxs("p",{children:[t?"This page lost its connection to ":"This page cannot reach ",r.jsx("code",{children:Rt}),". Check that it is still running in your terminal — the page picks up again on its own."]})]}):phe(n,s),!i&&r.jsxs("div",{className:"empty-actions",role:"group","aria-label":"Explore ccdeck",children:[r.jsx("button",{type:"button",className:"btn empty-tour",onClick:a,children:"Take the tour"}),r.jsx(ku,{film:"tour",action:!0})]})]})})}function phe(e,t){const n=dhe(t);return r.jsxs(r.Fragment,{children:[r.jsx("h2",{children:"Waiting for Claude Code or Codex"}),n.kind==="scoped"?r.jsxs("p",{children:[n.lead," ",r.jsx("code",{children:n.workspace}),n.tail]}):r.jsxs("p",{children:["Run ",r.jsx("code",{children:"claude"})," or ",r.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."]}),r.jsxs("details",{className:"empty-help",children:[r.jsx("summary",{children:"Session not showing up?"}),lJ(e).map(s=>r.jsx("p",{className:"hint-row",children:s.spans.map((a,o)=>a.code?r.jsx("code",{children:a.text},o):r.jsx("span",{children:a.text},o))},s.provider))]})]})}const mhe=1;function ghe(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 yhe(e,t,n){const s=e.agents.get(t);if(!s)return null;const a=[];for(const o of e.agents.values())o.sessionId===t&&a.push(o);return{schemaVersion:mhe,exportedAt:n,sessionId:t,label:s.label,cwd:s.cwd,startedAt:s.startedAt,endedAt:s.endedAt,model:s.model,agents:a.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(ghe)}))}}function whe(e,t){const n=(e||"session").replace(/[^a-z0-9._-]/gi,"_");return`${Rt}-${n}-${gf(t,8)}.json`}const JF={file:"📁",shell:"⚡",web:"🌐",agent:"🤖",task:"📋",plan:"🧭",mcp:"🔌",other:"✨"},xhe={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 vhe({cat:e}){return r.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:r.jsx("path",{d:xhe[e]})})}const Df={file:"file",shell:"shell",web:"web",agent:"agent",task:"task",plan:"plan",mcp:"mcp",other:"other"},QF=eP;function bhe({agent:e,now:t,onOpenTool:n,onShowSummary:s,onExportSession:a,onRemove:o,singleKeys:i=!0}){var b;const c=`${e.synthetic?"≥ ":""}${vl(e.startedAt,e.endedAt,t)}`,d=On(e),h=d.total>0,f=e.usage.inputTokens+e.usage.outputTokens,p=new Map;for(const[k,N]of e.toolCountByName??[]){const S=QF(k);p.set(S,(p.get(S)??0)+N)}const m=e.toolErrorCount??0,w=e.tools.filter(k=>!k.endedAt).length,j=Array.from(p.entries()).sort((k,N)=>N[1]-k[1]),v=p.has("mcp")?VV(((b=e.toolCountByName)==null?void 0:b.keys())??[]):null;return r.jsxs(r.Fragment,{children:[r.jsxs("header",{className:"detail-hero",children:[r.jsxs("div",{className:"hero-line",children:[r.jsx("span",{className:`state-pill state-${e.state}`,children:e.state==="active"?"live":e.state}),r.jsx("h2",{className:"hero-title",title:e.cwd??e.label,children:e.label})]}),r.jsxs("div",{className:"hero-meta",children:[r.jsx("span",{className:"hero-meta-item",children:np(e)}),r.jsx("span",{className:"hero-sep",children:"·"}),r.jsx("span",{className:"hero-meta-item",title:`started ${new Date(e.startedAt).toLocaleString()}`,children:c}),e.model&&(()=>{const k=z1(e);return r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"hero-sep",children:"·"}),r.jsxs("span",{className:"model-chip","data-family":Qf(e.model),title:k.length>0?`${pu(e.model,e.effort)}
|
|
105
|
+
spend on this panel also covers:
|
|
106
|
+
${k.join(`
|
|
107
|
+
`)}`:pu(e.model,e.effort),children:[ep(e.model,e.effort),k.length>0?` +${k.length}`:""]})]})})()]}),h&&r.jsxs("div",{className:"hero-cost",children:[r.jsxs("div",{className:"hero-cost-headline",children:[r.jsx("span",{className:"hero-cost-value",children:et(d.total)}),r.jsx("span",{className:"hero-cost-label",children:"spend"})]}),r.jsx(mj,{cost:d})]}),r.jsxs("div",{className:"hero-actions",children:[e.kind==="root"&&e.state==="done"&&s&&r.jsx("button",{type:"button",className:"btn hero-action-btn",onClick:()=>s(e.sessionId),title:"Reopen the end-of-session recap modal",children:"Show recap"}),a&&r.jsx("button",{type:"button",className:"btn hero-action-btn",onClick:()=>a(e.sessionId),title:"Download this session as JSON",children:"Export JSON"}),o&&r.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; ${vn("the session list","L",i)} brings it back`:`Take this card and the ones under it off the board (Delete). ${vn("The session list","L",i)} brings it back`,children:"Remove from board"})]})]}),r.jsx(fG,{agent:e}),(()=>{const k=ap(e);if(!k)return null;const N=uf(k.at,t),S=k.kind==="recap"?"Recap":Ha(k.kind).replace(/^./,_=>_.toUpperCase());return r.jsxs("section",{className:"detail-section",children:[r.jsxs("h3",{children:[S," ",r.jsx("span",{className:"section-count",title:N.title,children:N.label})]}),r.jsx("p",{className:"detail-recap",title:op(k),children:k.text}),k.reply&&r.jsxs("p",{className:"detail-recap detail-note-reply",children:["Suggested reply: “",k.reply,"”"]})]})})(),(()=>{const k=Lu(e.plan);return!k||!e.plan?null:r.jsxs("section",{className:"detail-section",children:[r.jsxs("h3",{children:["Plan"," ",r.jsxs("span",{className:"section-count","aria-hidden":!0,children:[k.done,"/",k.total]}),r.jsxs("span",{className:"vis-hidden",children:[k.done," of ",k.total," done"]})]}),e.plan.note&&r.jsx("p",{className:"detail-plan-note",children:e.plan.note}),r.jsx("ol",{className:"plan-list",children:e.plan.items.map((N,S)=>r.jsxs("li",{className:"plan-item","data-status":N.status,children:[r.jsx("span",{className:"plan-mark","aria-hidden":!0}),r.jsxs("span",{className:"vis-hidden",children:[She[N.status],": "]}),r.jsx("span",{className:"plan-text",children:N.status==="in_progress"&&N.active?N.active:N.text}),N.status==="in_progress"&&r.jsx("span",{className:"plan-now","aria-hidden":!0,children:"now"})]},N.id??`${S}:${N.text}`))})]})})(),e.tools.length>0&&r.jsxs("section",{className:"detail-section",children:[r.jsx("h3",{children:"Activity"}),r.jsxs("div",{className:"activity-row",children:[r.jsxs("div",{className:"activity-counters",children:[r.jsxs("span",{className:"ac-item",children:[r.jsx("b",{children:e.toolCount})," calls"]}),w>0&&r.jsxs("span",{className:"ac-item ac-live",children:[r.jsx("b",{children:w})," live"]}),m>0&&r.jsxs("span",{className:"ac-item ac-err",children:[r.jsx("b",{children:m})," err"]})]}),r.jsx("div",{className:"cat-strip",children:j.map(([k,N])=>{const S=k==="mcp"?v:null,_=S==null?void 0:S.hue,E=`${N} ${Df[k]} call${N===1?"":"s"}`;return r.jsxs("span",{className:`cat-chip cat-${k}${_!=null?" mcp-hue":""}`,style:_!=null?{"--mcp-hue":_}:void 0,title:S?`${E}, all to ${S.label}`:E,children:[r.jsx("span",{className:"cat-emoji","aria-hidden":!0,children:JF[k]}),r.jsx("span",{className:"cat-name",children:Df[k]}),r.jsx("span",{className:"cat-count",children:N}),S&&r.jsx("span",{className:"cat-server",children:S.label})]},k)})})]})]}),f>0&&r.jsxs("section",{className:"detail-section",children:[r.jsx("h3",{children:"Tokens"}),r.jsxs("div",{className:"tokens-grid",children:[r.jsxs("div",{children:[r.jsx("span",{className:"k",children:"in"}),r.jsx("b",{title:e.usage.inputTokens.toLocaleString(),children:xt(e.usage.inputTokens)})]}),r.jsxs("div",{children:[r.jsx("span",{className:"k",children:"out"}),r.jsx("b",{title:e.usage.outputTokens.toLocaleString(),children:xt(e.usage.outputTokens)})]}),r.jsxs("div",{children:[r.jsx("span",{className:"k",children:"cache r"}),r.jsx("b",{title:e.usage.cacheReadTokens.toLocaleString(),children:xt(e.usage.cacheReadTokens)})]}),r.jsxs("div",{children:[r.jsx("span",{className:"k",children:"cache c"}),r.jsx("b",{title:e.usage.cacheCreateTokens.toLocaleString(),children:xt(e.usage.cacheCreateTokens)})]})]})]}),r.jsxs("section",{className:"detail-section",children:[r.jsx("h3",{children:"Identity"}),r.jsxs("div",{children:[e.cwd&&r.jsxs("div",{className:"row",children:[r.jsx("span",{className:"k",children:"cwd"}),r.jsx("span",{className:"v",title:e.cwd,children:e.cwd})]}),r.jsxs("div",{className:"row",children:[r.jsx("span",{className:"k",children:"session"}),r.jsxs("span",{className:"v",children:[e.sessionId.slice(0,12),"…"]})]}),e.parentId&&r.jsxs("div",{className:"row",children:[r.jsx("span",{className:"k",children:"parent"}),r.jsxs("span",{className:"v",children:[e.parentId.slice(0,12),"…"]})]})]})]}),e.prompts.length>0&&r.jsxs("section",{className:"detail-section",children:[r.jsxs("h3",{children:["Prompts ",r.jsx("span",{className:"section-count",children:p3(e.prompts).length})]}),r.jsx("div",{className:"prompts",children:khe(e.prompts).reverse().map(({pr:k,key:N})=>{const S=uf(k.at,t),_=Xf(k.text);return _?r.jsxs("details",{className:"prompt-entry prompt-injected",children:[r.jsxs("summary",{children:[r.jsx("span",{className:"prompt-time",title:S.title,children:S.label}),r.jsx("span",{className:"prompt-injected-label",children:_.label})]}),_.detail&&r.jsx("div",{className:"prompt-injected-detail",children:_.detail})]},N):r.jsxs("div",{className:"prompt-entry",children:[r.jsx("div",{className:"prompt-time",title:S.title,children:S.label}),r.jsx("div",{className:"prompt-text",children:k.text})]},N)})})]}),r.jsxs("section",{className:"detail-section",children:[r.jsxs("h3",{children:["Tool calls ",r.jsx("span",{className:"section-count",children:e.tools.length})]}),e.tools.length===0&&r.jsx("div",{className:"empty",children:"No tool calls yet."}),r.jsx("div",{children:e.tools.slice().reverse().map(k=>r.jsx(Nhe,{t:k,onClick:()=>n(e.id,k.id)},k.id))})]})]})}function khe(e){const t=new Map;return e.map(n=>{const s=t.get(n.at)??0;return t.set(n.at,s+1),{pr:n,key:s===0?String(n.at):`${n.at}:${s}`}})}const jhe={inflight:"in-flight",done:"done",err:"error"};function Nhe({t:e,onClick:t}){const n=e.endedAt==null?"inflight":e.ok===!1?"err":"done",s=U3(e,"…");return r.jsxs("button",{className:"tool clickable",title:e.inputPreview||e.name,onClick:t,children:[r.jsxs("span",{className:"name",children:[r.jsx("span",{className:`status-dot ${n}`,"aria-hidden":!0}),r.jsx("span",{className:"vis-hidden",children:jhe[n]}),e.name]}),r.jsx("span",{style:{color:"var(--muted)"},children:s})]})}const She={completed:"done",in_progress:"now",pending:"to do"};function _he(e,t){const n=yhe(e,t,new Date().toISOString());if(!n)return;const s=JSON.stringify(n,null,2),a=new Blob([s],{type:"application/json"}),o=URL.createObjectURL(a),i=document.createElement("a");i.href=o,i.download=whe(n.label,t),document.body.appendChild(i),i.click(),document.body.removeChild(i),setTimeout(()=>URL.revokeObjectURL(o),1e3)}function Che({selected:e,now:t,openTool:n,setSummaryFor:s,onClose:a,stateRef:o,removeSelectedNode:i}){en("detail-panel");const c=Pn();return r.jsxs("aside",{className:"detail","aria-label":"Detail",children:[r.jsx("button",{type:"button",className:"glyph-btn detail-close",title:"Close panel","aria-label":"Close detail panel",onClick:a,children:"×"}),r.jsx(bhe,{agent:e,now:t,onOpenTool:n,onShowSummary:s,onExportSession:d=>_he(o.current,d),onRemove:i,singleKeys:c})]})}const Ehe=450,The=400,Rhe=100,Ch=8,Ahe={right:"hint hint-right",left:"hint hint-left",below:"hint hint-below",above:"hint hint-above"},$c=8;let Gr=null,DL=-1/0;function Mhe(e,t,n){return n||e-t<The}function $he(e,t,n,s,a=null){const o=Math.max($c,((a==null?void 0:a.left)??0)+$c),i=Math.min(window.innerWidth,(a==null?void 0:a.right)??1/0)-n-$c,c=p=>Math.max(o,Math.min(p,i)),d=p=>Math.max($c,Math.min(p,window.innerHeight-s-$c)),h=t.top+t.height/2-s/2,f=t.left+t.width/2-n/2;return e==="right"?{left:t.right+Ch,top:d(h)}:e==="left"?{left:t.left-Ch-n,top:d(h)}:e==="above"?{left:c(f),top:t.top-Ch-s}:{left:c(f),top:t.bottom+Ch}}const Lhe={chrome:"",dialog:" hint-over-dialog"};function Il(e,t="chrome"){const[n,s]=y.useState(null),a=y.useRef(void 0),o=y.useRef(void 0),i=y.useRef(null),c=y.useCallback(()=>{window.clearTimeout(a.current),window.clearTimeout(o.current),s(w=>(w&&(DL=performance.now()),null))},[]),d=y.useCallback((w,j,v)=>{window.clearTimeout(a.current),window.clearTimeout(o.current);const b=Gr!==null,k=Mhe(performance.now(),DL,b),N=()=>{var _;Gr&&Gr!==c&&Gr(),Gr=c;const S=t==="dialog"?((_=w.closest('[role="dialog"]'))==null?void 0:_.getBoundingClientRect())??null:null;s({spec:j,box:w.getBoundingClientRect(),within:S,instant:k})};v||k?N():a.current=window.setTimeout(N,Ehe)},[c,t]),h=y.useCallback(()=>{window.clearTimeout(a.current),window.clearTimeout(o.current),o.current=window.setTimeout(c,Rhe)},[c]),f=n!==null;y.useEffect(()=>{if(!f)return;const w=Tn.push(c,0,"popover");return window.addEventListener("resize",c),window.addEventListener("scroll",c,!0),()=>{w(),window.removeEventListener("resize",c),window.removeEventListener("scroll",c,!0),Gr===c&&(Gr=null)}},[f,c]),y.useEffect(()=>()=>{window.clearTimeout(a.current),window.clearTimeout(o.current),Gr===c&&(Gr=null)},[c]),y.useLayoutEffect(()=>{const w=i.current;if(!w||!n)return;const{width:j,height:v}=w.getBoundingClientRect(),b=$he(e,n.box,j,v,n.within);w.style.left=`${b.left}px`,w.style.top=`${b.top}px`,w.style.visibility="visible"},[n,e]);const p=y.useCallback(w=>({onPointerEnter:j=>{w&&j.pointerType==="mouse"&&d(j.currentTarget,w,!1)},onPointerLeave:h,onPointerDown:c,onFocus:j=>{w&&j.currentTarget.matches(":focus-visible")&&d(j.currentTarget,w,!0)},onBlur:c}),[d,h,c]),m=n&&vt.createPortal(r.jsxs("span",{ref:i,className:Ahe[e]+Lhe[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:[r.jsxs("span",{className:"hint-head",children:[r.jsx("span",{className:"hint-label",children:n.spec.label}),n.spec.keys&&r.jsx("kbd",{className:"hint-key",children:n.spec.keys})]}),n.spec.detail&&r.jsx("span",{className:"hint-detail",children:n.spec.detail})]}),document.body);return{bind:p,node:m}}function e5(e,t){return e&&(t||!e.single)?e:void 0}function Ihe(e,t,n){var i;const s=(i=e5(e.key,t))==null?void 0:i.cap,a=e.hint??e.label;return s!=null||e.detail!=null||a!==e.label||!n?{label:a,keys:s,detail:e.detail}:null}const t5={stripe:"rail-btn rail-btn-stripe",dock:"rail-btn rail-btn-dock",bar:"rail-btn rail-btn-bar"},Ohe={left:"edge-rail edge-rail-left",right:"edge-rail edge-rail-right"},Phe={vertical:"ArrowDown",horizontal:"ArrowRight"},Dhe={vertical:"ArrowUp",horizontal:"ArrowLeft"};function n5(e,t){const[n,s]=y.useState(0),a=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===Phe[t]?h=(d+1)%c.length:i.key===Dhe[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(),s(h),c[h].focus())},[t]);return{active:a,setCurrent:s,onKeyDown:o}}let Zi=null;function cN(e){y.useLayoutEffect(()=>{var a,o;Zi&&document.activeElement===document.body&&((o=(a=e.current)==null?void 0:a.querySelector(`[data-rail-item="${Zi}"]`))==null||o.focus()),Zi=null;const t=i=>{var d;const c=(d=i.target.dataset)==null?void 0:d.railItem;c&&(Zi=c)},n=i=>{var c;(c=e.current)!=null&&c.contains(i.relatedTarget)||(Zi=null)},s=e.current;return s==null||s.addEventListener("focusin",t),s==null||s.addEventListener("focusout",n),()=>{s==null||s.removeEventListener("focusin",t),s==null||s.removeEventListener("focusout",n)}},[e])}function uN({item:e,index:t,tabbable:n,onFocusIndex:s,hint:a,variant:o}){var h;const i=Pn(),c=a.bind(Ihe(e,i,o!=="stripe")),d=e.kind==="panel";return r.jsxs("button",{ref:e.buttonRef,type:"button","data-rail-item":e.id,className:t5[o],tabIndex:o==="bar"?void 0:n?0:-1,"aria-label":e.ariaLabel,"aria-keyshortcuts":(h=e5(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=>{s(t),c.onFocus(f)},onClick:()=>e.onPress(),children:[e.glyph,o!=="stripe"&&r.jsx("span",{className:"rail-word",children:o==="dock"?e.short:e.label}),e.badge!=null&&e.badge>0&&r.jsx("span",{className:"rail-badge","aria-hidden":!0,children:e.badge})]})}function FL({side:e,label:t,groups:n}){const s=Il(e==="left"?"right":"left"),a=n.filter(d=>d.length>0),o=n5(a.flat().length,"vertical"),i=y.useRef(null);cN(i);let c=0;return r.jsxs("div",{ref:i,className:Ohe[e],role:"toolbar","aria-label":t,"aria-orientation":"vertical",onKeyDown:o.onKeyDown,children:[a.map((d,h)=>r.jsx("div",{className:"rail-group",children:d.map(f=>{const p=c++;return r.jsx(uN,{item:f,index:p,tabbable:p===o.active,onFocusIndex:o.setCurrent,hint:s,variant:"stripe"},f.id)})},h)),s.node]})}const Eh="dock-more",BL="dock-more-menu";function Fhe({items:e,tabbable:t,onFocusIndex:n,index:s}){const[a,o]=y.useState(null),i=a!==null,c=e.reduce((h,f)=>h+(f.badge??0),0),d=h=>()=>{var f;(f=document.getElementById(Eh))==null||f.focus(),o(null),h.onPress()};return r.jsxs(r.Fragment,{children:[r.jsxs("button",{id:Eh,type:"button","data-rail-item":"more",className:t5.dock,tabIndex:t?0:-1,"aria-label":`More: ${e.map(h=>h.ariaLabel).join(", ")}`,"aria-haspopup":"menu","aria-expanded":i,"aria-controls":i?BL:void 0,onFocus:()=>n(s),onKeyDown:h=>{h.key!=="ArrowDown"&&h.key!=="ArrowUp"||(h.preventDefault(),o(h.key==="ArrowUp"?"last":"first"))},onClick:()=>o(i?null:"first"),children:[r.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:[r.jsx("circle",{cx:"2.8",cy:"7",r:"0.7"}),r.jsx("circle",{cx:"7",cy:"7",r:"0.7"}),r.jsx("circle",{cx:"11.2",cy:"7",r:"0.7"})]}),r.jsx("span",{className:"rail-word",children:"More"}),c>0&&r.jsx("span",{className:"rail-badge","aria-hidden":!0,children:c})]}),i&&r.jsx(xp,{anchorId:Eh,id:BL,className:"ap-pop",role:"menu",labelledBy:Eh,start:a,onClose:()=>o(null),children:e.map(h=>r.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item","data-rail-item":h.id,onFocus:()=>{Zi=h.id},onClick:d(h),children:h.badge?`${h.menu??h.label} · ${h.badge} unread`:h.menu??h.label},h.id))})]})}function Bhe({items:e,more:t}){const n=Il("above"),s=n5(e.length+1,"horizontal"),a=y.useRef(null);return cN(a),r.jsxs("div",{ref:a,className:"edge-dock",role:"toolbar","aria-label":"Panels and tools",onKeyDown:s.onKeyDown,children:[e.map((o,i)=>r.jsx(uN,{item:o,index:i,tabbable:i===s.active,onFocusIndex:s.setCurrent,hint:n,variant:"dock"},o.id)),r.jsx(Fhe,{items:t,index:e.length,tabbable:s.active===e.length,onFocusIndex:s.setCurrent}),n.node]})}function qhe({items:e,side:t="below"}){const n=Il(t),s=y.useRef(null);return cN(s),r.jsxs("div",{ref:s,className:"utility-run",children:[e.map((a,o)=>r.jsx(uN,{item:a,index:o,tabbable:!0,onFocusIndex:Uhe,hint:n,variant:"bar"},a.id)),n.node]})}function Uhe(){}const Whe="(max-width: 640px)";function Hhe(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}
|
|
108
|
+
${t} unread`:n}function zhe({providers:e,sessionListOpen:t,toggleSessionList:n,accountsPanelOpen:s,toggleAccountsPanel:a,usagePanelOpen:o,setUsagePanelOpen:i,machinePanelOpen:c,setMachinePanelOpen:d,setUsageHistoryOpen:h,watchOn:f,watchUnseen:p,setBrowserWatchOpen:m,setTrafficRadarOpen:w,radioOpen:j,setRadioOpen:v,openToolActivity:b,openSettings:k,onFeedback:N,toggles:S}){const _=she(Fu()),E={id:"session-list",label:"Session list",short:"Sessions",key:{cap:"L",aria:"L",single:!0},ariaLabel:"Session list",glyph:r.jsx(pte,{}),kind:"panel",open:t,controls:"session-list",onPress:n,buttonRef:S.sessionList},I={id:"accounts",label:"Accounts",short:"Accounts",key:{cap:"A",aria:"A",single:!0},ariaLabel:"Accounts",hint:"Claude accounts",glyph:r.jsx(mte,{}),kind:"panel",open:s,controls:"accounts-panel",onPress:a,buttonRef:S.accounts},A={id:"usage",label:"Usage",short:"Usage",key:{cap:"U",aria:"U",single:!0},ariaLabel:"Usage",glyph:r.jsx(gte,{}),kind:"panel",open:o,controls:"usage-panel",onPress:()=>i(B=>!B),buttonRef:S.usage},O={id:"machine",label:"Machine",short:"Machine",key:{cap:"S",aria:"S",single:!0},ariaLabel:"Machine",hint:"This machine",glyph:r.jsx(wte,{}),kind:"panel",open:c,controls:"system-panel",onPress:()=>d(B=>!B),buttonRef:S.machine},L={id:"history",label:"Usage history",short:"History",key:{cap:"H",aria:"H",single:!0},ariaLabel:"Usage history",glyph:r.jsx(yte,{}),kind:"dialog",onPress:()=>h(B=>!B)},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:Hhe(f,p),glyph:r.jsx(vte,{watching:f===!0||p>0}),kind:"dialog",onPress:()=>m(B=>!B),badge:p},P={id:"settings",label:"Settings",short:"Settings",key:{cap:_,aria:"Control+, Meta+,",single:!1},ariaLabel:"Settings",glyph:r.jsx(bte,{}),kind:"dialog",onPress:()=>k()},T={id:"feedback",label:"Feedback",short:"Feedback",menu:"Send feedback",ariaLabel:"Send feedback",glyph:r.jsx(kte,{}),kind:"dialog",onPress:N};return{left:e.claude?[I,E]:[E],right:[[A,O],[L,...b?[{id:"tool-activity",label:"Tool activity",short:"Tools",ariaLabel:"Tool activity",glyph:r.jsx(Cte,{}),kind:"dialog",detail:"Which tools your agents run, how long they take and what fails",onPress:()=>b()}]:[],U,...w?[{id:"traffic-radar",label:"Telemetry Radar",short:"Radar",ariaLabel:"Telemetry Radar",glyph:r.jsx(xte,{}),kind:"dialog",detail:"Claude telemetry configuration and observed connections",onPress:()=>w(!0)}]:[]],...v?[[{id:"radio",label:"Radio",short:"Radio",ariaLabel:"Radio",glyph:r.jsx(_te,{}),kind:"panel",open:j,controls:"radio-panel",detail:"Explore stations around the world",onPress:()=>v(B=>!B)}]]:[]],utilities:[P,T]}}function Vhe({widths:e,room:t,gap:n,more:s}){let a=0,o=0;for(let i=0;i<e.length;i++){a+=(i>0?n:0)+e[i];const c=i+1<e.length?n+s:0;if(a+c>t)break;o=i+1}return o}function s5(e){return e.tool?e.tool.name:e.kind==="asked"?"question":"permission"}const Ghe=20;function Khe(e,t=Ghe){if(e.length<=t)return e;const n=Math.floor((t-1)*.4),s=t-1-n;return`${e.slice(0,s)}…${e.slice(e.length-n)}`}function Yhe(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 s=Math.floor(t/60),a=t%60;return a===0?n(s,"hour"):`${n(s,"hour")} ${n(a,"minute")}`}function Xhe(e,t,n){const s=t.tool?`on ${t.tool.name}`:t.kind==="asked"?"for an answer":"for permission";return`${e}, waiting ${Yhe(n)} ${s}; go to session`}function Zhe(e){const t=xl(e),n=q3(e,t);return n?`${t}
|
|
109
|
+
${n}`:t}const Jhe=new Set(["idle","checking","current","downloading","ready","error"]);function qL(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.status!="string"||!Jhe.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 Qhe(e){return(e==null?void 0:e.status)==="ready"&&e.version?{version:e.version}:null}function r5(e=typeof navigator>"u"?"":navigator.userAgent){var t;return((t=/\bccdeck-desktop\/(\d[^\s]*)/.exec(e))==null?void 0:t[1])??null}const Sl="Restart to update",a5=3e4;function o5(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 efe(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 ${Sl} comes first`}}function i5(e,t=!1){return{text:t?"Restarting…":Sl,label:t?void 0:`${Sl} to v${e}`,title:`Install ccdeck v${e} now: ccdeck restarts and is back in a few seconds. Your Claude Code and Codex sessions keep running.`}}function tfe(e){const t=e==null?void 0:e.reason;return t==="app_disconnected"||t==="update_not_ready"?t:"refused"}function l5(e,t,n=typeof navigator>"u"?"":navigator.userAgent){const s=o5(n),a=`Use ${Sl} in ${s}.`;switch(e){case"app_disconnected":return`Nothing restarted: the app is not connected to this deck, so the request had nowhere to go. ${a}`;case"update_not_ready":return`Nothing restarted: the app no longer has v${t} ready. When it has one, ${Sl} is in ${s}.`;case"timeout":return`ccdeck has not restarted after ${a5/1e3} seconds. ${a}`;case"refused":return`Nothing restarted: the deck turned the request down. ${a}`;case"unreachable":return`Nothing restarted: the request did not reach the deck. ${a}`}}const nfe="Update checks are off (AGENTS_DECK_NO_UPDATE_CHECK=1)",Lk="click for what's new";function sfe(e){if(e.checkDisabled)return`${nfe} · ${Lk}`;if(e.checking)return`Asking npm for the newest release… · ${Lk}`;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 · ${Lk}, and to check npm now`}function rfe(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 afe(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 c5(e){return e?`${e.kind}:${e.to}`:""}function ofe(e,t){return e!=null&&t!==c5(e)}function ife({readyAppUpdate:e,notice:t,noticeOpen:n,version:s,chipVersion:a,versionChecking:o,now:i,openReleaseNotes:c,showNotice:d,loadVersion:h,restartToUpdate:f,updateRestarting:p=!1}){return r.jsx(r.Fragment,{children:e?(()=>{const m=efe(r5()??a,e.version),w=f&&i5(e.version,p);return r.jsxs(r.Fragment,{children:[r.jsxs("button",{type:"button",className:"v ready",onClick:c,"aria-haspopup":"dialog","aria-label":m.label,title:m.title,children:[m.text,r.jsx("span",{className:"v-dot","aria-hidden":!0})]}),w&&r.jsx("button",{type:"button",className:"v ready v-update",onClick:()=>f(e.version),"aria-busy":p||void 0,"aria-label":w.label,title:w.title,children:w.text})]})})():t?r.jsxs("button",{type:"button",className:"v stale",onClick:()=>{c(),d()},"aria-haspopup":"dialog","aria-label":afe({...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,r.jsx("span",{className:"v-dot","aria-hidden":!0})]}):(()=>{const m={running:a,latest:s==null?void 0:s.latest,latestPending:s==null?void 0:s.latestPending,checkedAgo:s!=null&&s.checkedAt?cf(i-s.checkedAt):null,checkFailedAgo:s!=null&&s.checkFailedAt&&s.checkFailedAt>(s.checkedAt??0)?cf(i-s.checkFailedAt):null,checkDisabled:s==null?void 0:s.checkDisabled,checking:o};return r.jsxs("button",{type:"button",className:o?"v checking":"v",onClick:()=>{c(),h(!0)},"aria-busy":o||void 0,"aria-haspopup":"dialog","aria-label":rfe(m),title:sfe(m),children:["v",m.running]})})()})}function lfe({live:e,paused:t,pauseGate:n}){const s=Pn();return r.jsx("span",{className:"status",children:(()=>{const a=AG({connected:e,paused:t,held:n.size,dropped:n.dropped,singleKeys:s});return a.resting?null:r.jsx("span",{className:`pill ${a.tone}`,title:a.title,children:r.jsxs("span",{className:"pill-box",children:[r.jsx("span",{className:"pill-widest","aria-hidden":!0,children:a.widest}),r.jsx("span",{className:"pill-label",children:a.label})]})})})()})}function cfe(e,t){return`${e.label} — ${s5(e.waiting)} · ${bf(e.waiting.since,void 0,t)}`}function u5(e,t){const n=e.slice(0,6).map(s=>cfe(s,t));return e.length>6&&n.push(`and ${e.length-6} more`),n.join(`
|
|
110
|
+
`)}function ufe({waitingSessions:e,waitingCursorRef:t,focusSession:n,now:s,named:a}){const o=Pn(),i=Il("below"),c=e.slice(a),d=e.length;return r.jsxs(r.Fragment,{children:[r.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?u5(c,s):void 0}),children:[r.jsx("span",{className:"ap-pulse","aria-hidden":!0}),r.jsx("b",{children:d})," waiting"]}),i.node]})}function UL({w:e,now:t}){return r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"we-name",children:Khe(e.label)}),r.jsx("span",{className:"we-wait",children:bf(e.waiting.since,void 0,t)}),r.jsxs("span",{className:"we-what",children:["· ",s5(e.waiting)]})]})}const dfe=12,hfe=2e3,ffe=4;function pfe({waitingSessions:e,waitingCursorRef:t,focusSession:n,now:s,onFit:a,onMore:o}){const i=Pn(),c=Il("below"),d=y.useRef(null),h=y.useRef(null),[f,p]=y.useState(0),m=e.map(b=>b.id).join(`
|
|
111
|
+
`);y.useLayoutEffect(()=>{const b=d.current,k=h.current;if(!b||!k)return;const N=()=>{const _=Array.from(k.children),E=_.pop();p(Vhe({widths:_.map(I=>I.getBoundingClientRect().width),room:b.clientWidth-dfe,gap:ffe,more:(E==null?void 0:E.getBoundingClientRect().width)??0}))};if(N(),typeof ResizeObserver>"u")return;const S=new ResizeObserver(N);return S.observe(b),S.observe(k),()=>S.disconnect()},[m]);const w=e.slice(0,f),j=e.slice(f);y.useEffect(()=>{a(w.length)},[w.length,a]);const v=b=>{t.current=b,n(b)};return r.jsxs("div",{className:"wait-names",ref:d,children:[r.jsxs("ul",{className:"wait-list",children:[w.map(b=>r.jsx("li",{"data-fresh":s-b.waiting.since<hfe||void 0,children:r.jsx("button",{type:"button",className:"wait-entry",onClick:()=>v(b.id),"aria-label":Xhe(b.label,b.waiting,s-b.waiting.since),...c.bind({label:b.label,detail:Zhe(b.waiting)}),children:r.jsx(UL,{w:b,now:s})})},b.id)),w.length>0&&j.length>0&&r.jsx("li",{children:r.jsxs("button",{type:"button",className:"wait-more",onClick:o,"aria-label":`${j.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:u5(j,s)}),children:["+",j.length," more"]})})]}),e.length>0&&r.jsxs("span",{className:"wait-ruler",ref:h,"aria-hidden":!0,children:[e.map(b=>r.jsx("span",{className:"wait-entry",children:r.jsx(UL,{w:b,now:s})},b.id)),r.jsxs("span",{className:"wait-more",children:["+",e.length," more"]})]}),c.node]})}const o1={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 mfe(e){return e==="on"?`Notifications on. ${o1.on}.`:e==="blocked"?`${o1.blocked}.`:""}function gfe({notifySaid:e}){return r.jsx("span",{className:e==="on"?"notify-said":"notify-said notify-said-blocked","aria-hidden":!0,title:o1[e],children:e==="on"?"notifications on":"notifications blocked"})}function yfe({versionCheck:e,welcome:t,desktopUpdate:n,pause:s,announcements:a,notify:o,waitingSessions:i,waitingCursorRef:c,focusSession:d,live:h,now:f,incidents:p,queueNamed:m}){const{version:w,notice:j,noticeOpen:v,showNotice:b,versionChecking:k,loadVersion:N}=e,{chipVersion:S,openReleaseNotes:_}=t,{readyAppUpdate:E,desktopUpdateRestarting:I,desktopUpdateFailure:A,askDesktopUpdateRestart:O}=n,L=y.useRef(!1);y.useEffect(()=>{I||!L.current||(L.current=!1,A&&_())},[I,A,_]);const U=K=>{L.current=!0,O(K)},{paused:P,pauseGate:T}=s,{blockedSaid:B,watchSaid:M,incidentSaid:q}=a,{notifySaid:$}=o;return r.jsxs("div",{className:"readout",children:[r.jsxs("div",{className:"brand",children:[r.jsx("img",{className:"logo logo-on-dark",src:zZ,width:19,height:16,alt:""}),r.jsx("img",{className:"logo logo-on-light",src:VZ,width:19,height:16,alt:""}),r.jsx("h1",{children:Rt}),r.jsx(ife,{readyAppUpdate:E,notice:j,noticeOpen:v,version:w,chipVersion:S,versionChecking:k,now:f,openReleaseNotes:_,showNotice:b,loadVersion:N,restartToUpdate:U,updateRestarting:I})]}),r.jsx(lfe,{live:h,paused:P,pauseGate:T}),r.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:B}),r.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:M}),r.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:q}),r.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:mfe($)}),r.jsx(GZ,{incidents:p}),i.length>0&&r.jsx(ufe,{waitingSessions:i,waitingCursorRef:c,focusSession:d,now:f,named:m}),$&&r.jsx(gfe,{notifySaid:$})]})}function wfe({selected:e,now:t,selectedIds:n,focusAgent:s,clearSelection:a}){const o=Pn(),i=On(e),c=Math.max(0,((e.endedAt??t)-e.startedAt)/1e3),d=e.state==="active"&&!e.synthetic?H1(i.total,c):null,h=n.size-1;return r.jsxs("button",{type:"button",className:"selected-ribbon",title:`${vn(`Zoom to ${e.label} and its session`,"Z",o)}${i.total>0?`
|
|
112
|
+
${et(i.total)} spent${d?` · ${d}`:""}`:""}`,onClick:()=>{try{s(e.id)}catch{}},children:[r.jsx("span",{className:`state-pill state-${e.state}`,children:e.state==="active"?"live":e.state}),r.jsx("span",{className:"selected-label",children:e.label}),i.total>0&&r.jsxs("span",{className:"selected-cost",children:[et(i.total),d?r.jsxs("span",{className:"selected-rate",children:[" · ",d]}):null]}),h>0&&r.jsxs("span",{className:"selected-extra",children:["+",h]}),r.jsx("span",{"aria-hidden":!0,className:"selected-close",onClick:f=>{f.stopPropagation(),a()},children:"×"})]})}function xfe({catBarRef:e,catBarOccluded:t,presentCats:n,hiddenCats:s,toggleCat:a}){return r.jsx("div",{ref:e,className:`cat-filter-bar${t?" occluded":""}`,role:"group","aria-label":"Filter tools by category",children:n.map(o=>{const i=s.has(o);return r.jsxs("button",{type:"button",className:`cat-filter${i?" off":""}`,onClick:()=>a(o),"aria-pressed":!i,title:`${i?"Show":"Hide"} ${Df[o]} tools`,children:[r.jsx(vhe,{cat:o}),r.jsx("span",{className:"cat-name",children:Df[o]})]},o)})})}const vfe=["a[href]","button:not(:disabled)","input:not(:disabled)","select:not(:disabled)","textarea:not(:disabled)","summary","[tabindex]"].join(",");function bfe(e){var n,s;const t=e.target;!(t!=null&&t.closest)||t.closest(vfe)!==e.currentTarget||(e.preventDefault(),(s=(n=document.activeElement)==null?void 0:n.blur)==null||s.call(n))}function kfe({trashZoneRef:e,trashState:t,trashPhase:n,trashLabel:s}){const a=Pn();return r.jsxs("div",{ref:e,className:`drag-trash-zone ${t}${n==="leaving"?" leaving":""}`,role:"status",children:[r.jsx("svg",{className:"drag-trash-icon",viewBox:"0 0 24 24","aria-hidden":"true",children:r.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"})}),r.jsxs("span",{className:"drag-trash-copy",children:[r.jsx("span",{className:"drag-trash-text",children:t==="over"?r.jsxs(r.Fragment,{children:["Release to remove ",r.jsx("strong",{className:"drag-trash-name",children:s||"this card"})]}):"Drop here to remove from the board"}),r.jsx("span",{className:"drag-trash-hint",children:t==="over"?`${vn("The session list","L",a)} brings it back`:"The session keeps running"})]})]})}function jfe({canvasRef:e,bubbling:t,dragging:n,trash:s,zoom:a,viewport:o,stateRef:i,peek:c,children:d}){const{trashDragging:h,trashState:f,trashPhase:p,trashZoneRef:m,trashLabel:w}=s,{lod:j,lodRef:v}=a,{markCanvasInput:b}=o,{peekAgent:k,peekLabel:N,peekRecap:S,peekBounds:_}=c;return r.jsxs("main",{id:"canvas",tabIndex:-1,className:`canvas-wrap${t?" bubbling":""}${n?" dragging-any":""}${h&&f==="over"?" trash-hover":""}`,"data-lod":j,ref:e,onMouseDownCapture:bfe,onPointerDownCapture:b,onPointerUpCapture:b,onWheelCapture:b,onFocusCapture:E=>{const I=E.target;if(!aN(I)||v.current==null||v.current==="detail")return;const A=I.getAttribute("data-id");A&&i.current.agents.has(A)&&I.matches(":focus-visible")&&IF(A,I,"focus")},onBlurCapture:E=>{var A,O;const I=(O=(A=E.target).getAttribute)==null?void 0:O.call(A,"data-id");I&&Xa(I)},children:[d,Ba(p)&&r.jsx(kfe,{trashZoneRef:m,trashState:f,trashPhase:p,trashLabel:w}),r.jsx(Oue,{agentFor:k,recapFor:S,labelFor:N,bounds:_})]})}function Nfe({restarting:e,restartMode:t,live:n,paused:s}){return r.jsxs("div",{className:"conn-banner",role:"alert",children:[r.jsx("span",{className:"conn-dot"}),e?t==="npx"?"Fetching the new version with npx — this can take a minute…":`Restarting ${Rt}…`:(()=>{const a=TG({connected:n,paused:s});return r.jsxs(r.Fragment,{children:[`Lost connection to the ${Rt} server. Reconnecting…`,a&&r.jsx("span",{className:"conn-sub",children:a})]})})()]})}function Sfe({oldName:e,version:t,dismissOldName:n}){return r.jsxs("div",{className:"ver-banner",role:"status",children:[r.jsx("span",{className:"ver-dot"}),r.jsxs("strong",{children:[e," still works — the deck is called ",Rt," now."]}),t!=null&&t.renameFix?r.jsx("span",{className:"ver-sub",children:t.renameFix}):null,r.jsx("button",{type:"button","aria-label":"Dismiss",className:"ver-close",onClick:n,children:"×"})]})}const d5="Thanks — that helps.",_fe=Array.from({length:11},(e,t)=>t);function Cfe(e){return e===0?"0 out of 10, not useful":e===10?"10 out of 10, extremely useful":`${e} out of 10`}const Efe=6;function Tfe(e){const t=y.useRef(null);return y.useLayoutEffect(()=>{const n=t.current,s=n==null?void 0:n.closest(".app");if(!n||!s)return;const a=()=>s.style.setProperty("--rating-h",`${Math.ceil(n.getBoundingClientRect().height)}px`);a();const o=typeof ResizeObserver>"u"?null:new ResizeObserver(a);return o==null||o.observe(n),()=>{o==null||o.disconnect(),s.style.removeProperty("--rating-h")}},[e]),t}function Rfe(){var e;(e=document.getElementById("canvas"))==null||e.focus()}function Afe({phase:e,score:t,onAnswer:n,onLater:s,onClose:a,onFeedback:o,onHold:i}){const c=Tfe(e),d=y.useRef(null),h=y.useRef(null),f=y.useRef(!1);y.useEffect(()=>{var m,w;e!=="thanks"||!f.current||(f.current=!1,Yn(((m=document.activeElement)==null?void 0:m.tagName)??null)&&((w=d.current??h.current)==null||w.focus()))},[e]);const p=m=>{var w;(w=c.current)!=null&&w.contains(document.activeElement)&&Rfe(),m()};return e==="thanks"?r.jsxs("div",{ref:c,className:"ver-banner note rating-banner",onFocus:()=>i(!0),onBlur:m=>{m.currentTarget.contains(m.relatedTarget)||i(!1)},children:[r.jsx("span",{className:"ver-dot"}),r.jsx("strong",{children:d5}),t!==null&&t<=Efe?r.jsx("button",{ref:d,type:"button",className:"ver-act",onClick:o,children:"Tell us what would make it better"}):null,r.jsx("button",{ref:h,type:"button","aria-label":"Dismiss",className:"ver-close",onClick:()=>p(a),children:"×"})]}):r.jsxs("div",{ref:c,className:"ver-banner note rating-banner",role:"group","aria-labelledby":"rating-question",children:[r.jsx("span",{className:"ver-dot"}),r.jsx("strong",{id:"rating-question",children:"How useful is ccdeck to you?"}),r.jsx("span",{className:"rating-scale",children:_fe.map(m=>r.jsx("button",{type:"button",className:"rating-pick","aria-label":Cfe(m),onClick:w=>{f.current=w.detail===0||w.currentTarget.matches(":focus-visible"),n(m)},children:m},m))}),r.jsx("span",{className:"ver-sub rating-ends","aria-hidden":"true",children:"0 not at all · 10 extremely"}),r.jsx("button",{type:"button",className:"ver-act",onClick:()=>p(s),children:"Not now"})]})}const Mfe=3e4;function $fe({bundle:e,running:t,lastTried:n}){return!t||e===t?!1:n!==t}function Lfe({bundle:e,running:t,pending:n,lastTried:s}){return t?$fe({bundle:e,running:t,lastTried:s})?"reload":n==null||n&&n!==t?"wait":"confirm":"wait"}function Ife(e){return!e||e.state!=="failed"?null:`${typeof e.at=="number"?e.at:0}:${e.error??""}`}function Ofe({asked:e,reported:t}){return t?t!==e:!1}function h5(e){const t=e.thresholdMs??Mfe;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 Pfe(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 Dfe(e,t){return e?t==null?"auto when idle":`auto in ${Pfe(t)}`:"auto-restart off"}function WL(e){let t=0;for(const n of e)n.state==="active"&&t++;return t}function Ffe(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 Bfe(e){const t=h5(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 i1={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 qfe({notice:e,version:t,dismissNotice:n,upgradeState:s,startUpgrade:a,copyCommand:o,cmdCopied:i,autoRestart:c,toggleAutoRestart:d,askRestart:h,restartCopy:f,restartFuseMs:p,restarting:m}){var w,j,v;return r.jsxs("div",{className:`ver-banner ${e.kind}`,role:"status",children:[r.jsx("span",{className:`ver-dot${p==null?"":" armed"}`}),e.kind==="restart"?r.jsxs(r.Fragment,{children:[r.jsxs("strong",{children:["v",e.to," is installed — this deck still runs v",e.from,"."]}),t!=null&&t.canRestart?r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",className:"ver-act",onClick:()=>h(),...$n(m),title:`Stop this process and bring it back on the same port. The canvas replays from the event log.
|
|
113
|
+
|
|
114
|
+
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:m?"restarting…":f.label}),!m&&r.jsx("span",{className:"ver-sub",children:f.clause}),r.jsxs("label",{className:"ver-auto",children:[r.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:r.jsx("span",{className:"switch-knob"})}),r.jsx("span",{"aria-hidden":!0,children:Dfe(c,p)})]})]}):r.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."})]}):r.jsxs(r.Fragment,{children:[r.jsxs("strong",{children:[Rt," v",e.to," is out — you are on v",e.from,"."]}),(t==null?void 0:t.upgradeMode)==="install"&&s!=="failed"&&r.jsx("button",{type:"button",className:"ver-act",onClick:a,...$n(s==="running",s==="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:s==="running"?"installing…":s==="done"?"installed":"Update now"}),(t==null?void 0:t.upgradeMode)==="npx"&&(t==null?void 0:t.canRestart)&&r.jsx("button",{type:"button",className:"ver-act",onClick:()=>h({upgrade:!0}),...$n(m),title:`Runs ${t==null?void 0:t.command} and hands it this port. Nothing is installed globally — npx unpacks its own copy.`,children:m?"fetching…":s==="failed"?"Retry update":"Update & restart"}),s==="failed"?r.jsxs("span",{className:"ver-sub fail",title:((j=t==null?void 0:t.upgrade)==null?void 0:j.error)??"",children:[(t==null?void 0:t.upgradeMode)==="npx"?"update failed":"install failed",": ",((v=t==null?void 0:t.upgrade)==null?void 0:v.error)??"unknown error"," — run it yourself:"]}):(t==null?void 0:t.upgradeMode)==="npx"?r.jsx("span",{className:"ver-sub",children:t!=null&&t.canRestart?"npx cannot upgrade in place, so the deck re-runs:":i1.npx}):t!=null&&t.upgradeBlocked?r.jsx("span",{className:"ver-sub",children:Kt(i1,t.upgradeBlocked)??"cannot install from here"}):null,r.jsxs("button",{type:"button",className:"ver-cmd",onClick:o,title:"Copy to clipboard",children:[r.jsx("code",{children:t==null?void 0:t.command}),r.jsx("span",{className:"ver-cmd-hint",children:i?"copied":"copy"})]})]}),r.jsx("button",{type:"button","aria-label":"Dismiss",className:"ver-close",onClick:n,children:"×"})]})}function Ufe({restart:e,versionCheck:t,upgrade:n,oldNameNotice:s,rating:a,onFeedback:o,everConnected:i,live:c,paused:d}){const{autoRestart:h,toggleAutoRestart:f,restarting:p,restartMode:m,restartedTo:w,askRestart:j,restartCopy:v,restartFuseMs:b}=e,{version:k,notice:N,noticeOpen:S,dismissNotice:_}=t,{upgradeState:E,startUpgrade:I,copyCommand:A,cmdCopied:O}=n,{oldName:L,oldNameOpen:U,dismissOldName:P}=s,{ratingPhase:T,ratingScore:B,answerRating:M,rateLater:q,closeRating:$,holdThanks:K}=a,G=w?r.jsxs("div",{className:"ver-banner done",role:"status",children:[r.jsx("span",{className:"ver-dot"}),r.jsxs("strong",{children:["Restarted — now running v",w,"."]}),r.jsx("span",{className:"ver-sub",children:"The canvas replayed from the event log."})]}):i&&!c?r.jsx(Nfe,{restarting:p,restartMode:m,live:c,paused:d}):S&&N?r.jsx(qfe,{notice:N,version:k,dismissNotice:_,upgradeState:E,startUpgrade:I,copyCommand:A,cmdCopied:O,autoRestart:h,toggleAutoRestart:f,askRestart:j,restartCopy:v,restartFuseMs:b,restarting:p}):U&&L?r.jsx(Sfe,{oldName:L,version:k,dismissOldName:P}):T!=="hidden"?r.jsx(Afe,{phase:T,score:B,onAnswer:M,onLater:q,onClose:$,onFeedback:o,onHold:K}):null;return r.jsxs(r.Fragment,{children:[G,r.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:T==="thanks"?d5:""})]})}function Wfe(e,t){return e==="confirmation"?t.confirmOpen?"clear":"ignore":t.modalOpen||t.confirmOpen?"ignore":"confirm"}function Hfe(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 zfe(e){return e<=0?null:e===1?"the one agent":`all ${e} agents`}function Vfe(e,t){const n=zfe(e),s=(...i)=>[n?`${n} on the canvas`:null,...i,"layout, pins and selection"].filter(c=>c!==null),a="This cannot be undone.";if(!t)return{goes:s("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:a,confirm:"Clear everything"};if(!t.path)return{goes:s(),stays:[],final:`This deck keeps no event log, so nothing on disk changes — and nothing can bring the canvas back. ${a}`,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:s(),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:s("this deck's event log — the file a restarted deck replays to rebuild what you see"),stays:[],final:a,confirm:"Clear everything"};const o=t.decks-1;return{goes:s(`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:a,confirm:"Clear everything"}}function Gfe({agentCount:e,onConfirm:t,onCancel:n}){const s=y.useRef(null),a=mt(n,{focusRef:s,layer:M9}),o=yt(n),[i,c]=y.useState(null);y.useEffect(()=>{let m=!1;return fetch("/api/clear").then(w=>w.ok?w.json():null).then(w=>{m||c(Hfe(w))}).catch(()=>{}),()=>{m=!0}},[]);const{goes:d,stays:h,final:f,confirm:p}=Vfe(e,i);return r.jsx("div",{className:"modal-backdrop",...o,role:"presentation",children:r.jsxs("div",{ref:a,className:"modal clear-confirm",onClick:m=>m.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"clear-confirm-title",children:[r.jsxs("header",{className:"modal-head",children:[r.jsxs("div",{className:"modal-title",children:[r.jsx("span",{className:"status-dot err","aria-hidden":!0}),r.jsx("span",{id:"clear-confirm-title",className:"modal-tool-name",children:"Clear the deck?"})]}),r.jsx("div",{className:"modal-actions",children:r.jsx("button",{type:"button",className:"glyph-btn",onClick:n,"aria-label":"Cancel (Esc)",title:"Cancel (Esc)",children:"×"})})]}),r.jsxs("section",{className:"modal-body",children:[r.jsxs("dl",{className:"cc-plan",children:[r.jsx("dt",{children:"Goes"}),r.jsx("dd",{children:d.map(m=>r.jsx("span",{children:m},m))}),r.jsx("dt",{children:"Stays"}),r.jsx("dd",{children:h.length>0?h.map(m=>r.jsx("span",{children:m},m)):r.jsx("span",{children:"nothing"})})]}),f&&r.jsx("p",{className:"cc-final",children:f}),r.jsxs("div",{className:"cc-actions",children:[r.jsx("button",{type:"button",ref:s,className:"btn",onClick:n,children:"Cancel"}),r.jsx("button",{type:"button",className:"btn danger",onClick:t,children:p})]})]})]})})}const Ff=[{value:"bug",label:"Bug",question:"What happened?",placeholder:`I was trying to…
|
|
115
|
+
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 f5(e){return Ff.find(t=>t.value===e)??Ff[0]}const l1=3,Ik=120,p5=1e4,m5=200,Kfe="Write something first.";function HL(e){return e.trim()!==""}function Yfe(e){var o;const t=e.trim();if(t==="")return"";const n=zL(t.split(/\r?\n/,1)[0]),s=((o=/^(.+?[.!?])(?=\s|$)/.exec(n))==null?void 0:o[1])??n,a=Ok(s).length>=l1?Ok(s):Ok(n);return Zfe(a.length>=l1?a:zL(t))}function Xfe(e,t){const n=Yfe(t);return n.length>=l1?n:`${f5(e).label}: ${n}`}function zL(e){return e.replace(/\s+/g," ").trim()}function Ok(e){return/[^.]\.$/.test(e)?e.slice(0,-1):e}function Zfe(e){if(e.length<=Ik)return e;const t=e.slice(0,Ik-1),n=t.lastIndexOf(" ");return`${(n>=Ik/2?t.slice(0,n):t).replace(/[\uD800-\uDBFF]$/,"").replace(/[\s,;:.\-–—]+$/,"")}…`}function Jfe({kind:e,body:t,contact:n}){const s={kind:e,title:Xfe(e,t),body:t.trim()};return n.trim()!==""&&(s.contact=n.trim()),s}function Qfe(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 epe={darwin:"macOS",win32:"Windows",linux:"Linux"};function tpe(e){const t=e.indexOf("-"),n=t===-1?e:e.slice(0,t),s=t===-1?"":e.slice(t+1),a=epe[n]??n;return s?`${a} · ${s}`:a}function npe(e){return e?`ccdeck ${e.appVersion} · ${tpe(e.platform)}`:null}const spe="sent with it",rpe="Your ccdeck version and system are sent with it.",ape="Add details",ope="How to reach you",ipe="Email or GitHub @name",lpe="Only if you would like an answer.",cpe=["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 upe(e){return e.key==="Enter"&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey&&!e.isComposing}function g5(e){return e.key==="Enter"&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey&&!e.isComposing}function dpe(e){return Bu(e)?["⌘","Enter"]:["Ctrl","Enter"]}function hpe(e){return[...e].length===1}const y5="Thanks — feedback sent.";function VL(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 s=n==null?void 0:n.images;return e===400&&Array.isArray(s)&&typeof s[0]=="string"?`The server did not accept an image. ${s[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 fpe(e){return e==="sending"?"Sending…":e==="sent"?y5:""}const GL=1400,ppe=160;function mpe({kind:e,onChange:t}){return r.jsxs("fieldset",{className:"fb-kinds",children:[r.jsx("legend",{className:"vis-hidden",children:"Kind of feedback"}),Ff.map(n=>r.jsxs("label",{className:"fb-kind",children:[r.jsx("input",{type:"radio",name:"feedback-kind",value:n.value,checked:e===n.value,onChange:()=>t(n.value),onKeyDown:s=>{g5(s.nativeEvent)&&s.preventDefault()}}),n.label]},n.value))]})}const w5="fb-details";function gpe({open:e,onToggle:t}){return r.jsxs("button",{type:"button",className:"fb-tool fb-more","aria-expanded":e,"aria-controls":w5,onClick:t,children:[ape,r.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:r.jsx("path",{d:"M2.5 3.75 5 6.25l2.5-2.5"})})]})}function ype({open:e,contact:t,onContact:n}){const s=y.useId();return r.jsx("div",{id:w5,className:"fb-details","data-open":e||void 0,children:r.jsx("div",{className:"fb-details-clip",children:r.jsxs("div",{className:"fb-details-body",children:[r.jsxs("div",{className:"fb-field",children:[r.jsxs("label",{className:"fb-field-label",htmlFor:"fb-contact",children:[ope,r.jsx("span",{className:"fb-optional",children:"optional"})]}),r.jsx("input",{id:"fb-contact",className:"ap-manage-input",type:"text",value:t,maxLength:m5,autoComplete:"email",placeholder:ipe,"aria-describedby":s,onChange:a=>n(a.target.value),onKeyDown:a=>{g5(a.nativeEvent)&&a.preventDefault()}}),r.jsx("p",{id:s,className:"fb-hint",children:lpe})]}),r.jsx("div",{className:"fb-where",children:cpe.map(a=>r.jsx("p",{children:a},a))})]})})})}const Po=3,wpe=5*1024*1024,xpe=12*1024*1024,c1=8192,vpe=64*1024,bpe=256*1024,kpe=.92,jpe=640,x5=.9,Npe=.85,Spe=6,_pe=512*1024,Bf={png:"image/png",jpeg:"image/jpeg"},Cpe={png:"png",jpeg:"jpg"},Epe=[137,80,78,71,13,10,26,10],Tpe=[255,216,255];function v5(e){const t=n=>e.length>=n.length&&n.every((s,a)=>e[a]===s);return t(Epe)?"png":t(Tpe)?"jpeg":null}function Rpe(e){const t=v5(e);return t==="png"?Ape(e):t==="jpeg"?$pe(e):null}function Ape(e){const t=[73,72,68,82];if(e.length<24||!t.every((s,a)=>e[12+a]===s))return null;const n=new DataView(e.buffer,e.byteOffset,e.byteLength);return{width:n.getUint32(16),height:n.getUint32(20)}}function Mpe(e){return e>=192&&e<=207&&e!==196&&e!==200&&e!==204}function $pe(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 s=e[t]<<8|e[t+1];if(s<2)return null;if(Mpe(n))return t+7>e.length?null:{height:e[t+3]<<8|e[t+4],width:e[t+5]<<8|e[t+6]};t+=s}return null}function KL(e,t){return e.bytes>t||e.width>c1||e.height>c1}function Lpe(e){return Math.min(wpe,xpe-vpe-e)}function b5(e,t){return{width:Math.max(1,Math.floor(e.width*t)),height:Math.max(1,Math.floor(e.height*t))}}function Ipe(e,t){const n=c1/Math.max(e.width,e.height),s=e.bytes>t?Math.sqrt(t/e.bytes)*x5:1;return b5(e,Math.min(1,n,s))}async function Ope(e,t,n){let s=Ipe(e,t),a=e.format;for(let o=0;o<Spe;o++){const i=await n(s,a,a==="jpeg"?kpe:void 0);if(!i)return null;if(i.size<=t)return{...s,blob:i,format:a};if(a==="png"){a="jpeg";continue}if(s=b5(s,Math.min(Npe,Math.sqrt(t/i.size)*x5)),Math.max(s.width,s.height)<jpe)return null}return null}async function Ppe(e,t,n){const s=new Uint8Array(await e.slice(0,_pe).arrayBuffer()),a=v5(s);if(!a)return{ok:!1,problem:"type"};if(t<bpe)return{ok:!1,problem:"no_room"};const o=e.type===Bf[a]?e:new Blob([e],{type:Bf[a]}),i=Rpe(s);if(i&&!KL({...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:a};if(!KL(d,t))return{ok:!0,blob:o,resized:null};const h=await Ope(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 Dpe(e){return({width:t,height:n},s,a)=>new Promise(o=>{const i=document.createElement("canvas");i.width=t,i.height=n;const c=i.getContext("2d");if(!c)return o(null);s==="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)},Bf[s],a)})}const Fpe=async e=>{const t=await createImageBitmap(e);return{width:t.width,height:t.height,encoder:Dpe(t),release:()=>t.close()}};function Bpe(e){return e.includes("Files")}function qpe({files:e,hasText:t,intoTextField:n}){return e>0&&(!t||!n)}function Upe(e,t){const n=e.indexOf(t);return e[n+1]??e[n-1]??null}function Wpe(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((s,a)=>{const o=s.type===Bf.jpeg?"jpeg":"png";n.append("images",s,`image-${a+1}.${Cpe[o]}`)}),{method:"POST",body:n}}const Hpe="Add screenshot",YL="PNG or JPEG, up to three. You can also paste one, or drop it on this dialog.",zpe="A screenshot can show emails, costs and paths. Crop out what should not be seen.",XL="Three images at most. Remove one to add another.",Vpe="An image could not be attached, so nothing was sent. Check the images and send again; your text is still here.";function Gpe(e,t,n){const s=n?`, resized to ${n.width} × ${n.height} to fit`:"";return`Replace image ${e+1}: ${t}${s}`}function Kpe(e,t){const n=`${e} of ${Po}`;return t>0?`${n} · ${t} resized to fit`:n}function Ype(e){return`Three images at most, so ${e===1?"one was":`${e} were`} left out.`}function Xpe(e){return`“${e.length>40?`${e.slice(0,30)}…${e.slice(-9)}`:e}”`}function Zpe(e,t){const n=Xpe(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 k5="image/png,image/jpeg";function j5({className:e="fb-glyph"}){return r.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:[r.jsx("rect",{x:"1.8",y:"2.4",width:"10.4",height:"9.2",rx:"1.6"}),r.jsx("circle",{cx:"5",cy:"5.6",r:"1"}),r.jsx("path",{d:"M2.4 10.4 5.5 7.6l2.1 1.8 1.5-1.3 2.5 2.2"})]})}function Jpe({images:e,buttonRef:t}){const n=y.useRef(null),s=e.shots.length>=Po;return r.jsxs(r.Fragment,{children:[r.jsxs("button",{ref:t,type:"button",className:"fb-tool",title:YL,"aria-describedby":"fb-attach-hint",onClick:()=>{var a;return s?e.sayFull():(a=n.current)==null?void 0:a.click()},children:[r.jsx(j5,{}),Hpe]}),r.jsx("span",{id:"fb-attach-hint",hidden:!0,children:YL}),r.jsx("input",{ref:n,type:"file",accept:k5,multiple:!0,hidden:!0,onChange:a=>{e.add(Array.from(a.target.files??[])),a.target.value=""}})]})}function Qpe({images:e,addRef:t}){const n=y.useRef(new Map),s=y.useRef(null),a=y.useRef(null),o=y.useRef(null),[i,c]=y.useState(null),{shots:d}=e,h=Kpe(d.length,d.filter(m=>m.resized).length);y.useLayoutEffect(()=>{var m;i!==null&&((m=i==="add"?t.current:n.current.get(i))==null||m.focus(),c(null))},[i,t]),y.useEffect(()=>{var m;e.problem&&((m=s.current)==null||m.scrollIntoView({block:"nearest"}))},[e.problem,e.problemId]);function f(m){c(Upe(d.map(w=>w.id),m)??"add"),e.remove(m)}function p(m){var w;o.current=m,(w=a.current)==null||w.click()}return r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"vis-hidden",role:"status",children:e.announcement}),r.jsx("input",{ref:a,type:"file",accept:k5,hidden:!0,onChange:m=>{const w=o.current;w!==null&&e.replace(w,Array.from(m.target.files??[])),o.current=null,m.target.value=""}}),d.length>0&&r.jsxs("div",{className:"fb-shots",children:[r.jsxs("div",{className:"fb-shots-row",children:[r.jsx("ul",{className:"fb-shots-list",children:d.map((m,w)=>r.jsxs("li",{className:"fb-shot","data-fitting":m.blob?void 0:!0,children:[r.jsxs("button",{type:"button",className:"fb-shot-pick","aria-label":Gpe(w,m.name,m.resized),onClick:()=>p(m.id),children:[r.jsx("img",{className:"fb-shot-img",src:m.url,alt:""}),m.blob?r.jsx("span",{className:"fb-shot-cue","aria-hidden":"true",children:"Replace"}):r.jsx("span",{className:"fb-shot-busy","aria-hidden":"true",children:"Resizing…"})]}),r.jsx("button",{ref:j=>{j?n.current.set(m.id,j):n.current.delete(m.id)},type:"button",className:"glyph-btn fb-shot-remove","aria-label":`Remove image ${w+1}`,title:`Remove image ${w+1}`,onClick:()=>f(m.id),children:r.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:r.jsx("path",{d:"M2.5 2.5 7.5 7.5M7.5 2.5 2.5 7.5"})})})]},m.id))}),r.jsx("span",{className:"fb-shots-count",children:h})]}),r.jsx("p",{className:"fb-hint",children:zpe})]}),e.problem&&r.jsx("p",{ref:s,className:"fb-error",role:"alert",children:e.problem},e.problemId)]})}function eme(e,t){return e.map((n,s)=>({id:t+s,name:n.name,url:URL.createObjectURL(n.blob),blob:n.blob,resized:n.resized}))}function tme(e,t,n){return n?e.map(s=>s.id===t.id?t:s):[...e,t]}function nme(e,t,n){return n?e.map(s=>s.id===t?n:s):e.filter(s=>s.id!==t)}function sme(e){const[t,n]=y.useState(()=>eme((e==null?void 0:e.ready)??[],1)),[s,a]=y.useState({problem:"",id:0}),o=y.useRef(0),i=y.useCallback(T=>{T&&o.current++,a(B=>T?{problem:T,id:B.id+1}:B.problem?{problem:"",id:B.id}:B)},[]),[c,d]=y.useState(""),h=y.useRef(t),f=y.useRef(null),p=y.useRef(t.length),m=y.useRef(!0),w=y.useRef(new Map),j=y.useRef([]),v=y.useRef(0),b=y.useCallback(T=>{h.current=T(h.current),n(h.current)},[]);y.useEffect(()=>(m.current=!0,()=>{m.current=!1;for(const T of h.current)URL.revokeObjectURL(T.url)}),[]);const k=y.useCallback(async(T,B)=>{const M=h.current.reduce((ee,F)=>{var Y;return ee+(F.id===(B==null?void 0:B.id)?0:((Y=F.blob)==null?void 0:Y.size)??0)},0),q=(B==null?void 0:B.id)??++p.current,$=URL.createObjectURL(T),K={id:q,name:T.name||"image",url:$,blob:null,resized:null},G=v.current;w.current.set(q,T);let z=!1;const W=()=>{z||(z=!0,b(ee=>tme(ee,K,B!==void 0)))},D=await Ppe(T,Lpe(M),async ee=>(W(),Fpe(ee))).catch(()=>({ok:!1,problem:"unreadable"})),H=h.current.some(ee=>ee.id===q);return!m.current||v.current!==G||!H&&(z||B)?(URL.revokeObjectURL($),B&&URL.revokeObjectURL(B.url),m.current&&w.current.delete(q),""):(w.current.delete(q),D.ok?(W(),B&&URL.revokeObjectURL(B.url),b(ee=>ee.map(F=>F.id===q?{...F,blob:D.blob,resized:D.resized}:F)),""):(URL.revokeObjectURL($),z&&b(ee=>nme(ee,q,B)),Zpe(D.problem,T.name||"image")))},[b]),N=y.useCallback(async T=>{i("");const B=v.current,M=[];let q=0,$=0;for(const G of T){if(!m.current||v.current!==B)return;const z=j.current.indexOf(G);if(z!==-1&&j.current.splice(z,1),h.current.length>=Po){q++;continue}const W=h.current.length,D=await k(G);D&&M.push(D),h.current.length>W&&$++}if(!m.current||v.current!==B)return;q>0&&M.push($===0&&M.length===0?XL:Ype(q)),i(M.join(" "));const K=h.current.length;$>0&&d(`${$===1?"Image":`${$} images`} added, ${K} of ${Po}.`)},[k,i]),S=y.useCallback(async(T,B)=>{i("");const M=h.current.find(K=>K.id===T);if(!M)return N([B]);const q=await k(B,M);if(!m.current)return;i(q);const $=h.current.findIndex(K=>K.id===T);!q&&$!==-1&&d(`Image ${$+1} replaced, ${h.current.length} of ${Po}.`)},[N,k,i]),_=y.useCallback(T=>{const B=v.current;f.current=(f.current??Promise.resolve()).then(()=>v.current===B?T():void 0).catch(()=>{})},[]),E=y.useCallback(T=>{T.length!==0&&(j.current.push(...T),_(()=>N(T)))},[N,_]);y.useEffect(()=>{e&&e.waiting.length>0&&E(e.waiting)},[]);const I=y.useCallback((T,B)=>{const M=B[0];M&&_(()=>S(T,M))},[_,S]),A=y.useCallback(T=>{const B=h.current.find(M=>M.id===T);B&&(URL.revokeObjectURL(B.url),w.current.delete(T),b(M=>M.filter(q=>q.id!==T)),i(""),d(`Image removed, ${h.current.length} of ${Po}.`))},[b,i]),O=y.useCallback(()=>i(XL),[i]),L=y.useCallback(async()=>{const T=o.current;return await f.current,o.current!==T?null:h.current.flatMap(B=>B.blob?[B.blob]:[])},[]),U=y.useCallback(()=>({ready:h.current.flatMap(T=>T.blob&&!w.current.has(T.id)?[{name:T.name,blob:T.blob,resized:T.resized}]:[]),waiting:[...w.current.values(),...j.current]}),[]),P=y.useCallback(()=>{v.current++;for(const T of h.current)URL.revokeObjectURL(T.url);w.current.clear(),j.current=[],b(()=>[]),i("")},[b,i]);return{shots:t,problem:s.problem,problemId:s.id,announcement:c,add:E,replace:I,remove:A,sayFull:O,ready:L,kept:U,clear:P}}function rme(){const[e,t]=y.useState(null);return y.useEffect(()=>{let n=!0;return fetch("/api/feedback").then(s=>s.ok?s.json():null).then(s=>{n&&t(Qfe(s))}).catch(()=>{}),()=>{n=!1}},[]),e}function ame(e){const[t,n]=y.useState({state:"idle"}),s=y.useRef(!1),a=y.useRef(null);y.useEffect(()=>()=>{var c;return(c=a.current)==null?void 0:c.abort()},[]);async function o(c){if(!xn(s.current))return;s.current=!0;const{signal:d}=a.current=new AbortController;n({state:"sending"});try{const h=await e.ready();if(d.aborted)return;if(!h){n({state:"failed",message:Vpe});return}const f=await fetch("/api/feedback",{...Wpe(Jfe(c),h),signal:d}),p=await f.json().catch(()=>null);n(f.ok&&(p!=null&&p.ok)?{state:"sent"}:{state:"failed",message:VL(f.status,p==null?void 0:p.reason,p==null?void 0:p.errors)})}catch{d.aborted||n({state:"failed",message:VL(0,null)})}finally{s.current=!1}}const i=()=>n(c=>c.state==="failed"?{state:"idle"}:c);return{outcome:t,sending:t.state==="sending",send:o,clearFailure:i}}function ome(e,t){const[n,s]=y.useState(!1),a=y.useRef(t);return a.current=t,y.useEffect(()=>{if(!e)return;const o=window.setTimeout(()=>s(!0),GL),i=window.setTimeout(()=>a.current(),GL+ppe);return()=>{window.clearTimeout(o),window.clearTimeout(i)}},[e]),n}const Pk="agent-dag.feedbackDrafts",ZL=4;function ime({initialKind:e,initialBody:t}){return{kind:e??"bug",body:t??""}}function lme(e){return JSON.stringify([e.kind,e.body])}function cme(e){return e.ready.length+e.waiting.length}function N5(e,t){return e.body.trim()!==t.body.trim()||e.contact.trim()!==""||e.images>0}function ume(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 dme="Discard",hme="Confirm discard",fme="Clear the message, the screenshots and the contact",JL="Press again to clear this draft. It cannot be brought back.",pme={ready:[],waiting:[]};function mme(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:s,contact:a,images:o}=t;return!Ff.some(i=>i.value===n)||typeof s!="string"||s.length>p5||typeof a!="string"||a.length>m5||typeof o!="number"||!Number.isInteger(o)||o<0||o>Po?null:[e[0],{kind:n,body:s,contact:a,images:o}]}function gme(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(Pk),c=i?JSON.parse(i):[];if(Array.isArray(c))for(const d of c.slice(-ZL)){const h=mme(d);h&&t.set(h[0],{...h[1],images:null,imageCount:h[1].images})}}catch{}return t}function s(){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(Pk):o.setItem(Pk,JSON.stringify(i))}catch{}}function a(o){n().delete(o)&&s()}return{read(o){const i=n().get(o);return i?{kind:i.kind,body:i.body,contact:i.contact,images:i.images??pme,imagesLost:i.images?0:i.imageCount}:null},keep(o,i,c){const d=cme(i.images);if(!N5({body:i.body,contact:i.contact,images:d},c)){a(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<=ZL)break;h.delete(f)}s()},forget:a}}function yme(){try{return typeof window>"u"?null:window.sessionStorage}catch{return null}}const u1=gme(yme),wme=4e3;function xme(e,t,n,s,a){const o=y.useRef(null);o.current={key:e,seed:t,words:n,images:s,sent:a};const i=y.useCallback(()=>{const c=o.current;!c||c.sent||u1.keep(c.key,{...c.words,images:c.images.kept()},c.seed)},[]);y.useEffect(i,[i,n.kind,n.body,n.contact,s.shots]),y.useEffect(()=>i,[i]),y.useEffect(()=>{a&&u1.forget(e)},[a,e])}const QL="draft";function vme(e){const[t,n]=y.useState(!1),s=y.useRef(0);y.useEffect(()=>{if(!t)return;const o=window.setTimeout(()=>n(!1),wme);return()=>window.clearTimeout(o)},[t]);function a(){const o=Date.now(),i=jl({armedFor:t?QL:null,target:QL,armedAt:s.current,now:o,gapMs:kl});if(i==="arm"){n(!0),s.current=o;return}i!=="ignore"&&(n(!1),e())}return{armed:t,press:a}}function S5({onClose:e,initialKind:t,initialBody:n}){const s=y.useRef(null),a=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),m=mt(e,{focusRef:s}),w=yt(e),j=ime({initialKind:t,initialBody:n}),v=lme(j),[b]=y.useState(()=>u1.read(v)),[k,N]=y.useState((b==null?void 0:b.kind)??j.kind),[S,_]=y.useState((b==null?void 0:b.body)??j.body),[E,I]=y.useState((b==null?void 0:b.contact)??""),[A,O]=y.useState((b==null?void 0:b.imagesLost)??0),[L,U]=y.useState(!1),[P,T]=y.useState(!1),[B,M]=y.useState(!1),q=sme(b==null?void 0:b.images),$=npe(rme()),{outcome:K,sending:G,send:z,clearFailure:W}=ame(q),D=K.state==="sent",H=ome(D,e);xme(v,j,{kind:k,body:S,contact:E},q,D);const ee=N5({body:S,contact:E,images:q.shots.length},j),F=vme(()=>{var ye;N(j.kind),_(j.body),I(""),O(0),T(!1),q.clear(),W(),(ye=s.current)==null||ye.focus()}),Y=f5(k),X=P&&!HL(S),Z=A>0&&q.shots.length===0,J=[X&&"fb-body-error",Z&&"fb-images-lost"].filter(Boolean).join(" ")||void 0,[ne,ce]=dpe(Fu());y.useEffect(()=>{var Oe,We;const ye=i.current;if(!ye)return;const Pe=ye.contains(document.activeElement)||Yn(((Oe=document.activeElement)==null?void 0:Oe.tagName)??null);ye.inert=D,D&&Pe&&((We=a.current)==null||We.focus())},[D]),y.useEffect(()=>{var Re,st;const ye=c.current;if(!ye)return;const Pe=h.current;if(G){const je=document.activeElement,Te=je!=null&&(ye.contains(je)||je===Pe);f.current=Te?je:null,ye.inert=!0,Pe&&(Pe.inert=!0),f.current&&((Re=d.current)==null||Re.focus());return}ye.inert=!1,Pe&&(Pe.inert=!1);const Oe=f.current;f.current=null;const We=document.activeElement===d.current||Yn(((st=document.activeElement)==null?void 0:st.tagName)??null);!D&&Oe&&We&&Oe.focus()},[G,D]);function he(ye){var Pe;if(ye.preventDefault(),!HL(S)){T(!0),(Pe=s.current)==null||Pe.focus();return}z({kind:k,body:S,contact:E})}const le=!D&&!G,re=ye=>Bpe(Array.from(ye.dataTransfer.types));function ae(ye){!re(ye)||!le||(ye.preventDefault(),p.current++,M(!0))}function de(ye){re(ye)&&(ye.preventDefault(),ye.dataTransfer.dropEffect=le?"copy":"none")}function Se(ye){re(ye)&&(p.current=Math.max(0,p.current-1),p.current===0&&M(!1))}function pe(ye){re(ye)&&(ye.preventDefault(),p.current=0,M(!1),le&&q.add(Array.from(ye.dataTransfer.files)))}function me(ye){ye.target!==ye.currentTarget||!re(ye)||(ye.preventDefault(),ye.dataTransfer.dropEffect="none")}function be(ye){re(ye)&&ye.preventDefault()}function Ce(ye){if(!le)return;const Pe=Array.from(ye.clipboardData.files),Oe=ye.target,We=Oe instanceof HTMLTextAreaElement||Oe instanceof HTMLInputElement,Re=Array.from(ye.clipboardData.types).includes("text/plain");qpe({files:Pe.length,hasText:Re,intoTextField:We})&&(ye.preventDefault(),q.add(Pe))}return r.jsx("div",{className:"modal-backdrop",...w,role:"presentation",onDragOver:me,onDrop:be,"data-leaving":H||void 0,children:r.jsxs("div",{ref:m,className:"modal feedback-dialog",onClick:ye=>ye.stopPropagation(),onDragEnter:ae,onDragOver:de,onDragLeave:Se,onDrop:pe,onPaste:Ce,role:"dialog","aria-modal":"true","aria-labelledby":"feedback-title",children:[r.jsxs("header",{className:"modal-head",children:[r.jsx("div",{className:"modal-title",children:r.jsx("span",{id:"feedback-title",className:"modal-tool-name",children:"Send feedback"})}),r.jsx("div",{className:"modal-actions",children:r.jsx("button",{ref:a,type:"button",className:"glyph-btn",onClick:e,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),r.jsx("p",{className:"vis-hidden",role:"status",children:F.armed?JL:fpe(K.state)}),r.jsxs("div",{className:"fb-stage",children:[r.jsxs("form",{ref:i,className:"fb-form",onSubmit:he,onKeyDown:ye=>{upe(ye.nativeEvent)&&(ye.preventDefault(),ye.currentTarget.requestSubmit())},noValidate:!0,children:[r.jsxs("section",{ref:c,className:"modal-body fb-body",children:[r.jsx(mpe,{kind:k,onChange:N}),r.jsxs("div",{className:"fb-compose",children:[r.jsx("label",{className:"fb-label",htmlFor:"fb-body",children:Y.question}),r.jsx("textarea",{ref:s,id:"fb-body",className:"ap-manage-input fb-message",value:S,maxLength:p5,rows:5,placeholder:Y.placeholder,onChange:ye=>_(ye.target.value),"aria-invalid":X||void 0,"aria-describedby":J,required:!0}),X&&r.jsx("p",{id:"fb-body-error",className:"fb-error",children:Kfe}),r.jsx(Qpe,{images:q,addRef:o}),Z&&r.jsx("p",{id:"fb-images-lost",className:"fb-hint",children:ume(A)}),r.jsxs("div",{className:"fb-tools",children:[r.jsx(Jpe,{images:q,buttonRef:o}),r.jsx(gpe,{open:L,onToggle:()=>U(ye=>!ye)})]}),r.jsx(ype,{open:L,contact:E,onContact:I})]}),r.jsx("p",{className:"fb-facts",children:$?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"fb-facts-value",children:$})," — ",spe]}):rpe}),K.state==="failed"&&r.jsx("p",{className:"fb-error",role:"alert",children:K.message})]}),r.jsxs("div",{className:"fb-foot",children:[ee&&r.jsx("button",{ref:h,type:"button",className:`btn danger fb-discard${F.armed?" armed":""}`,onKeyDown:ye=>{ye.repeat&&ye.preventDefault()},onClick:F.press,title:F.armed?JL:fme,children:F.armed?hme:dme}),r.jsxs("span",{className:"fb-shortcut","aria-hidden":"true",children:[r.jsx("kbd",{"data-symbol":hpe(ne)||void 0,children:ne}),r.jsx("kbd",{children:ce})," to send"]}),r.jsx("button",{type:"button",className:"btn",onClick:e,children:"Cancel"}),r.jsx("button",{ref:d,type:"submit",className:"btn primary fb-send","aria-keyshortcuts":"Meta+Enter Control+Enter",...$n(G),children:r.jsxs("span",{className:"fb-send-label",children:[r.jsx("span",{className:"fb-send-idle",children:"Send feedback"}),r.jsx("span",{className:"fb-send-busy",children:"Sending…"})]})})]})]}),D&&r.jsxs("div",{className:"fb-done",children:[r.jsx(Rf,{}),r.jsx("p",{className:"fb-done-line",children:y5})]})]}),r.jsx("div",{className:"fb-drop","aria-hidden":"true","data-active":B||void 0,children:r.jsxs("div",{className:"fb-drop-frame",children:[r.jsx(j5,{className:"fb-drop-glyph"}),r.jsx("p",{className:"fb-drop-title",children:"Drop to attach"}),r.jsx("p",{className:"fb-drop-note",children:"PNG or JPEG, up to three"})]})})]})})}const _5="Press Esc first if a key does nothing.",eI=[{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:[]}]}],bme=/ \([A-Z?]\)/g;function C5(e){return e?eI:eI.map(t=>({...t,rows:t.rows.filter(n=>n.chord||!n.binds.some(gP)).map(n=>({...n,action:n.action.replace(bme,"")}))})).filter(t=>t.rows.length>0)}const kme="Single-key shortcuts are off.",E5="Settings › Keyboard",jme=`Single-key shortcuts can be turned off in ${E5}.`;function Nme({onClose:e,onTour:t,onSettings:n}){const s=mt(e),a=yt(e),o=Bu(Fu()),i=Pn(),c=C5(i);return r.jsx("div",{className:"modal-backdrop",...a,role:"presentation",children:r.jsxs("div",{ref:s,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:[r.jsxs("header",{className:"modal-head",children:[r.jsx("div",{className:"modal-title",children:r.jsx("span",{id:"key-help-title",className:"modal-tool-name",children:"Keyboard shortcuts"})}),r.jsx("div",{className:"modal-actions",children:r.jsx("button",{type:"button",className:"glyph-btn",onClick:e,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),r.jsxs("section",{className:"modal-body",children:[!i&&r.jsxs("div",{className:"kh-off",children:[r.jsxs("p",{className:"kh-off-text",id:"key-help-off",children:[r.jsx("strong",{children:kme})," Turn them back on in"," ",r.jsx("span",{className:"kh-place",children:E5}),". Everything below still works."]}),n&&r.jsx("button",{type:"button",className:"btn",onClick:n,children:"Open Settings"})]}),t&&r.jsxs("div",{className:"guide-door",children:[r.jsx("span",{children:"Eight pictures of what the deck shows."}),r.jsx("button",{type:"button",className:"btn",onClick:t,children:"Take the tour"})]}),r.jsx("div",{className:"shortcuts",children:c.map(d=>r.jsxs(y.Fragment,{children:[r.jsx("h3",{className:"kh-group",children:d.title}),d.rows.map(h=>r.jsxs("div",{className:"sc",children:[r.jsx("kbd",{children:o&&h.macCap?h.macCap:h.cap}),r.jsx("span",{children:h.action})]},`${d.title}:${h.cap}:${h.action}`))]},d.title))}),i&&r.jsxs("p",{className:"kh-foot",children:[_5," ",jme]})]})]})})}function dN(e,t){return y.lazy(()=>e().catch(n=>(console.warn(`ccdeck could not load ${t}`,n),{default:({onClose:s})=>r.jsx(Sme,{name:t,onClose:s})})))}function Sme({name:e,onClose:t}){const n=y.useRef(null),s=mt(t,{focusRef:n}),a=yt(t);return r.jsx("div",{className:"modal-backdrop",...a,role:"presentation",children:r.jsxs("div",{ref:s,className:"modal dialog-missing",onClick:o=>o.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"dialog-missing-title",children:[r.jsxs("header",{className:"modal-head",children:[r.jsx("div",{className:"modal-title",children:r.jsx("span",{id:"dialog-missing-title",className:"modal-tool-name",children:e})}),r.jsx("div",{className:"modal-actions",children:r.jsx("button",{type:"button",className:"glyph-btn",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),r.jsxs("section",{className:"modal-body",children:[r.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."]}),r.jsxs("div",{className:"dm-actions",children:[r.jsx("button",{type:"button",className:"btn",onClick:t,children:"Close"}),r.jsx("button",{type:"button",ref:n,className:"btn primary",onClick:()=>window.location.reload(),children:"Reload"})]})]})]})})}function _me(e,t){return`${e}#${t}`}function Cme(e,{lan:t,now:n,closed:s}){if(t===void 0)return[];const a=[];for(const o of e??[]){const i=o.reauth;if(!i||i.dismissed||o.origin!=="ccdeck_signin")continue;const c=_me(i.key,i.since);if(s.has(c)||ote(i.key,o.email,t,n))continue;const d=o.email??"";a.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 a}function Eme(e,t){const n=String((t==null?void 0:t.email)??"").trim().toLowerCase();return n?e.filter(s=>s.email.toLowerCase()===n&&((t==null?void 0:t.num)==null||String(s.num)===String(t.num))).map(s=>s.id):[]}function T5({rows:e,ours:t,dialogs:n}){return e===0?!1:t||n===0}function Tme(e){return e===1?"Account needs your attention":"Accounts need your attention"}function Rme(e){return`${e===1?"One Claude account needs":`${e} Claude accounts need`} you to sign in again.`}const Ame="Login expired",Mme="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.",$me="The account stays marked in the Accounts panel. This will not ask again until it has worked and stopped again.";function Lme(e,t){const n=(e??[]).filter(a=>a&&typeof a.fp=="string"&&!t.has(a.fp));if(!n.length)return{request:null,waiting:0};const s=[...n].sort((a,o)=>(a.at??0)-(o.at??0));return{request:s[0],waiting:s.length-1}}function Ime({request:e,waiting:t,busy:n,now:s,onAccept:a,onDecline:o,onLater:i}){const c=y.useRef(null),d=mt(i,{focusRef:c}),h=yt(i),f=Ga(n,"accept"),p=Ga(n,"dismiss");return r.jsx("div",{className:"modal-backdrop",...h,role:"presentation",children:r.jsxs("div",{ref:d,className:"modal lan-ask",onClick:m=>m.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-ask-title","aria-describedby":"lan-ask-who",children:[r.jsxs("header",{className:"modal-head",children:[r.jsxs("div",{className:"modal-title",children:[r.jsx("i",{className:"ap-pulse","aria-hidden":!0}),r.jsx("span",{id:"lan-ask-title",className:"modal-tool-name",children:"A deck wants to pair"})]}),r.jsx("div",{className:"modal-actions",children:r.jsx("button",{type:"button",className:"glyph-btn",onClick:i,"aria-label":"Answer later (Esc)",title:"Answer later (Esc)",children:"×"})})]}),r.jsxs("section",{className:"modal-body",children:[r.jsxs("p",{id:"lan-ask-who",className:"lan-ask-who",children:[r.jsx("strong",{className:"lan-ask-name",children:e.name})," at ",r.jsx("code",{className:"ap-lan-code",children:e.addr})," · asked ",Rj(e.at,s)]}),r.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."}),r.jsxs("p",{className:"lan-ask-fp",children:["Its fingerprint is ",r.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&&r.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.`}),r.jsxs("div",{className:"lan-ask-acts",children:[r.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"}),r.jsx("button",{type:"button",className:"btn primary",disabled:f.disabled,"aria-busy":f.busy,onClick:a,title:"Talk to this deck from now on, and repair its expired logins with this deck's own.",children:n==="accept"?"accepting…":"Accept"})]})]})]})})}function Ome(e){const t=y.useRef(!1),n=Pme(e),s=T5({rows:n?1:0,ours:t.current,dialogs:Tn.dialogDepth()});return t.current=s,s?n:null}function Pme({lanPending:e,lanDeferred:t,lanBusy:n,answerLanPair:s,deferLanPair:a}){const{request:o,waiting:i}=Lme(e,t.current);return o?r.jsx(Ime,{request:o,waiting:i,busy:n,now:Date.now(),onAccept:()=>void s("accept",o.fp),onDecline:()=>void s("dismiss",o.fp),onLater:()=>a(o.fp)},o.fp):null}function Dme({rows:e,onSignIn:t,onLater:n,firstRef:s}){const a=e.length===1?e[0]:null;return r.jsxs("section",{className:"modal-body",children:[a?r.jsxs(r.Fragment,{children:[r.jsxs("p",{id:"reauth-lead",className:"reauth-lead",children:["The Claude login for ",r.jsx("strong",{className:"reauth-name",children:a.name}),a.alias?r.jsxs("span",{className:"reauth-alias",children:[" (",a.alias,")"]}):null," ","has expired and needs a new sign","‑","in."]}),r.jsx("p",{className:"reauth-note",children:Mme})]}):r.jsxs(r.Fragment,{children:[r.jsx("p",{id:"reauth-lead",className:"reauth-lead",children:Rme(e.length)}),r.jsx("ul",{className:"reauth-list",children:e.map((o,i)=>r.jsxs("li",{className:"reauth-row",children:[r.jsxs("span",{className:"reauth-who",title:o.alias?`${o.alias} — ${o.name}`:o.name,children:[o.name,o.alias?r.jsxs("span",{className:"reauth-alias",children:[" ",o.alias]}):null]}),r.jsx("span",{className:"reauth-what",children:Ame}),r.jsx("button",{type:"button",className:"btn",ref:i===0?s:void 0,"aria-label":`Sign in again as ${o.name}`,onClick:()=>t(o),children:"Sign in again"})]},o.id))}),r.jsx("p",{className:"reauth-note",children:"Each keeps its slot, its alias and its history."})]}),r.jsxs("div",{className:"reauth-acts",children:[r.jsx("button",{type:"button",className:"btn",title:$me,onClick:n,children:"Not now"}),a&&r.jsx("button",{type:"button",className:"btn primary",ref:s,onClick:()=>t(a),children:"Sign in again"})]})]})}function Fme({rows:e,onSignIn:t,onLater:n}){const s=y.useRef(null),a=mt(n,{focusRef:s}),o=yt(n);return r.jsx("div",{className:"modal-backdrop",...o,role:"presentation",children:r.jsxs("div",{ref:a,className:"modal reauth-ask",onClick:i=>i.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"reauth-title","aria-describedby":"reauth-lead",children:[r.jsxs("header",{className:"modal-head",children:[r.jsx("div",{className:"modal-title",children:r.jsx("span",{id:"reauth-title",className:"modal-tool-name",children:Tme(e.length)})}),r.jsx("div",{className:"modal-actions",children:r.jsx("button",{type:"button",className:"glyph-btn",onClick:n,"aria-label":"Not now (Esc)",title:"Not now (Esc)",children:"×"})})]}),r.jsx(Dme,{rows:e,onSignIn:t,onLater:n,firstRef:s})]})})}function Bme({rows:e,signingIn:t,signIn:n,signedIn:s,refresh:a,closeSignIn:o,later:i,pairing:c=!1}){const d=y.useRef(!1),h=Tn.dialogDepth()+(c?1:0),f=t!=null||T5({rows:e.length,ours:d.current,dialogs:h});return d.current=f,t?r.jsx(G4,{email:t.email||null,onClose:o,onChanged:a,onSignedIn:s}):f?r.jsx(Fme,{rows:e,onSignIn:n,onLater:i},e.length===1?"one":"many"):null}const qme={"//":["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.43.1","3.43.3"],"3.44.0":[{title:"⛔ A turn that stops on an error now shows as stopped",body:"When Claude Code ends a turn on an API error, such as an expired login or a usage limit, it sends StopFailure instead of Stop. The deck now adds StopFailure to the hooks it writes in Claude Code's settings.json, but only when every Claude Code it finds is 2.1.78 or newer; with an older one, or one whose version it cannot read, nothing changes. The card then says “Stopped · login expired”, “Stopped · usage limit” or “Stopped · API error”, and the sessions one expired login stops together arrive as one notification that names them. Each needs a “continue” once a working login is active."},{title:"🔑 Auto-switch leaves an expired login, and nothing switches onto one",body:"When Claude Code has signed a login out and claude-swap's saved copy is dead too, Auto-switch now moves to another account under your home and weekly-reset rules, and its notification says why. Neither Auto-switch nor Switch moves onto a login that is already known to be expired: that account's row says its login expired, with Sign in again, and nothing moves."},{title:"💲 Usage totals say how complete they are",body:"The usage headline is always shown now, by the rule History and the model table already used: an exact total when every cost is known, a known $0 included; the known part with “+” when some tokens could not be priced; and “not priced”, never a bare $0, when no cost is known. Sessions whose cost is a known zero show it too."},{title:"📡 Radar: a resizable inspector, prompt previews and a JSON view",body:"Radar's inspector can be resized and shows prompt previews, highlights and each record as a JSON tree, beside the File view. Settings › Radar has a new Monitor automatically switch. It is off, so Radar still watches only after you press Start, as before; turn it on to have the deck start monitoring by itself."},{title:"🧰 Tool activity opens over the deck, with the first tool's details open",body:"Tool activity now opens as a dialog over the deck instead of a page of its own, with the first tool selected and its details beside the list. Escape closes the details first, then the dialog. On a phone the details open as a sheet."},{title:"🧩 Tool activity counts skills, and the slash commands you type if you opt in",body:"Tool activity's Skills tab ranks the skills your Claude Code and Codex agents used. Counting the slash commands you type needs Claude Code's UserPromptExpansion hook, which the deck adds to settings.json only when you start it with AGENTS_DECK_SKILL_HOOK=1 and every Claude Code it finds is 2.1.116 or newer. Without that variable nothing in settings.json changes."},{title:"▶️ Continue a background session that stopped",body:"A background session that stopped on an error has a Continue button on its card and panel: the deck stops it if Claude Code still lists it, then resumes it in its own folder with “Continue from where you left off.” Continue stopped background sessions, in Settings › General, presses it for you once per stop. It is off until you turn it on."},{title:"⌨️ ccdeck commands for your terminal",body:"ccdeck accounts, ccdeck switch, ccdeck usage, ccdeck sessions and ccdeck open work from any terminal. ccdeck switch --best goes where Auto-switch would, and every switch follows the deck's own rules. Over SSH, ccdeck open prints the line that opens the deck on your own computer. Each command takes --json for scripts."}],"3.43.4":[{title:"🔐 Local network no longer sends the login a deck is signed in to",body:`Two machines on one Claude login race to renew it, and the one that renews second is signed out with “Login expired”. So paired decks no longer receive the login a deck is signed in to right now. Every other login you tick is shared as before, and this one goes out once the deck switches to another account.
|
|
116
|
+
|
|
117
|
+
Update every paired deck: an older deck still sends the login it is using, and the decks paired with it still take it. To send it anyway, as before, turn on Send the login this deck is using too in the Local network dialog. Not covered yet: a paired deck that already holds a copy of that login, from before this deck switched to it, can still renew it first and sign this deck out. Auto-switch can also still move a deck onto a login another paired deck is using, if the deck already holds a copy of it.`}],"3.43.0":[{title:"🏠 Auto-switch can come back to a home account",body:"Choose Set as home in an account’s ⋯ menu. With Auto-switch on, Next account › Soonest weekly reset uses up quota that resets within 4 days first."},{title:"🔄 Sessions already running appear when ccdeck starts",body:"Busy Codex sessions, and Claude ones on macOS and Linux, show up again after a restart. Restore unfinished sessions, in Settings › General, turns it off."},{title:"⚙️ Settings, reorganized and searchable",body:"Search every setting from the top of the list. Keyboard, Data and About have sections of their own."},{title:"📋 Plan progress and reasoning effort on agent cards",body:"Cards show how far an agent is through its plan, and the effort beside the model. Finished sessions can hide themselves after a delay you choose."},{title:"✨ Calmer desktop updates, marked shared accounts, Codex sub-agents kept together",body:"The desktop app installs an update only when no agent is working or waiting. Accounts shared on Local network are marked."}],"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.
|
|
118
|
+
|
|
119
|
+
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.
|
|
120
|
+
|
|
121
|
+
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.
|
|
122
|
+
|
|
123
|
+
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.
|
|
124
|
+
|
|
125
|
+
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.
|
|
126
|
+
|
|
127
|
+
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".
|
|
128
|
+
|
|
129
|
+
**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.
|
|
130
|
+
|
|
131
|
+
\`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.
|
|
132
|
+
|
|
133
|
+
**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.
|
|
134
|
+
|
|
135
|
+
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.
|
|
136
|
+
|
|
137
|
+
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.
|
|
138
|
+
|
|
139
|
+
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.
|
|
140
|
+
|
|
141
|
+
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.
|
|
142
|
+
|
|
143
|
+
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.
|
|
144
|
+
|
|
145
|
+
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.
|
|
146
|
+
|
|
147
|
+
What you are reading is the first version that does not.
|
|
148
|
+
|
|
149
|
+
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.
|
|
150
|
+
|
|
151
|
+
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.
|
|
152
|
+
|
|
153
|
+
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.
|
|
154
|
+
|
|
155
|
+
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.
|
|
156
|
+
|
|
157
|
+
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.
|
|
158
|
+
|
|
159
|
+
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.
|
|
160
|
+
|
|
161
|
+
The count of what is behind it is on the heading's tooltip, so collapsing it does not hide how much there is.
|
|
162
|
+
|
|
163
|
+
**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.
|
|
164
|
+
|
|
165
|
+
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.
|
|
166
|
+
|
|
167
|
+
\`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.
|
|
168
|
+
|
|
169
|
+
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.
|
|
170
|
+
|
|
171
|
+
**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.
|
|
172
|
+
|
|
173
|
+
**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.
|
|
174
|
+
|
|
175
|
+
**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.
|
|
176
|
+
|
|
177
|
+
**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.
|
|
178
|
+
|
|
179
|
+
**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.
|
|
180
|
+
|
|
181
|
+
**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.
|
|
182
|
+
|
|
183
|
+
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.
|
|
184
|
+
|
|
185
|
+
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.
|
|
186
|
+
|
|
187
|
+
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.
|
|
188
|
+
|
|
189
|
+
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.
|
|
190
|
+
|
|
191
|
+
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.
|
|
192
|
+
|
|
193
|
+
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.
|
|
194
|
+
|
|
195
|
+
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.
|
|
196
|
+
|
|
197
|
+
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.
|
|
198
|
+
|
|
199
|
+
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.
|
|
200
|
+
|
|
201
|
+
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.
|
|
202
|
+
|
|
203
|
+
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.
|
|
204
|
+
|
|
205
|
+
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.
|
|
206
|
+
|
|
207
|
+
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.
|
|
208
|
+
|
|
209
|
+
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.
|
|
210
|
+
|
|
211
|
+
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.
|
|
212
|
+
|
|
213
|
+
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.
|
|
214
|
+
|
|
215
|
+
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.
|
|
216
|
+
|
|
217
|
+
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.
|
|
218
|
+
|
|
219
|
+
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.
|
|
220
|
+
|
|
221
|
+
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.
|
|
222
|
+
|
|
223
|
+
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.
|
|
224
|
+
|
|
225
|
+
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.
|
|
226
|
+
|
|
227
|
+
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.
|
|
228
|
+
|
|
229
|
+
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.
|
|
230
|
+
|
|
231
|
+
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.
|
|
232
|
+
|
|
233
|
+
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.
|
|
234
|
+
|
|
235
|
+
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.
|
|
236
|
+
|
|
237
|
+
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.
|
|
238
|
+
|
|
239
|
+
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.
|
|
240
|
+
|
|
241
|
+
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.
|
|
242
|
+
|
|
243
|
+
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.
|
|
244
|
+
|
|
245
|
+
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.
|
|
246
|
+
|
|
247
|
+
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.
|
|
248
|
+
|
|
249
|
+
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.
|
|
250
|
+
|
|
251
|
+
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.
|
|
252
|
+
|
|
253
|
+
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.
|
|
254
|
+
|
|
255
|
+
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.
|
|
256
|
+
|
|
257
|
+
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.
|
|
258
|
+
|
|
259
|
+
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.
|
|
260
|
+
|
|
261
|
+
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".
|
|
262
|
+
|
|
263
|
+
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.
|
|
264
|
+
|
|
265
|
+
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.
|
|
266
|
+
|
|
267
|
+
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.
|
|
268
|
+
|
|
269
|
+
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.
|
|
270
|
+
|
|
271
|
+
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.
|
|
272
|
+
|
|
273
|
+
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.
|
|
274
|
+
|
|
275
|
+
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.
|
|
276
|
+
|
|
277
|
+
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.
|
|
278
|
+
|
|
279
|
+
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.
|
|
280
|
+
|
|
281
|
+
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.
|
|
282
|
+
|
|
283
|
+
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.
|
|
284
|
+
|
|
285
|
+
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.
|
|
286
|
+
|
|
287
|
+
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.
|
|
288
|
+
|
|
289
|
+
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.
|
|
290
|
+
|
|
291
|
+
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.
|
|
292
|
+
|
|
293
|
+
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.
|
|
294
|
+
|
|
295
|
+
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.
|
|
296
|
+
|
|
297
|
+
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.
|
|
298
|
+
|
|
299
|
+
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.
|
|
300
|
+
|
|
301
|
+
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.
|
|
302
|
+
|
|
303
|
+
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.
|
|
304
|
+
|
|
305
|
+
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.
|
|
306
|
+
|
|
307
|
+
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.
|
|
308
|
+
|
|
309
|
+
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.
|
|
310
|
+
|
|
311
|
+
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.`}]},hN="agent-dag.releaseNotesSeen";function tI(e){return e.split(/[.\-+]/).map(t=>parseInt(t,10)).map(t=>Number.isNaN(t)?0:t)}function Qo(e,t){const n=tI(e),s=tI(t);for(let a=0;a<Math.max(n.length,s.length);a++){const o=(n[a]??0)-(s[a]??0);if(o!==0)return o<0?-1:1}return 0}function Za(e){return typeof e=="string"&&/^\d+\.\d+\.\d+/.test(e)}function Ume(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 Wme(e){if(!e||typeof e!="object")return[];const t=[];for(const[n,s]of Object.entries(e)){if(!Za(n)||!Array.isArray(s))continue;const a=s.filter(Ume);a.length&&t.push({version:n,notes:a})}return t.sort((n,s)=>Qo(s.version,n.version))}const nI=Wme(qme);function R5(e,t,n){return e.filter(s=>Qo(s.version,n)<=0&&(t===null||Qo(s.version,t)>0))}function Hme(e,t){return e.filter(n=>Qo(n.version,t)===0)}function zme(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 Vme({since:e,running:t,entries:n,firstRun:s}){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(s&&Za(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 a=n[0].version;if(!Za(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=Qo(a,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 Gme=new RegExp("^(?:\\p{Extended_Pictographic}|\\p{Emoji_Modifier}|\\p{Regional_Indicator}|[\\u200D\\uFE0F])+(?= \\S)","u");function Kme(e){const t=Gme.exec(e);return t?{icon:t[0],rest:e.slice(t[0].length)}:{icon:null,rest:e}}function Yme(e){if(!e)return null;let t=null;try{t=e.getItem(hN)}catch{return null}return Za(t)?t:null}function Xme(e){if(!e)return!1;try{return e.getItem(hN),!0}catch{return!1}}function Zme(e,t){if(!e)return!1;try{return e.setItem(hN,t),!0}catch{return!1}}const A5="agent-dag.tourSeen";function Jme(e){if(!e)return!1;try{return e.getItem(A5)==="1"}catch{return!1}}function Qme(e){if(!e)return!1;try{return e.setItem(A5,"1"),!0}catch{return!1}}function ege({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 tge({stored:e,running:t,notes:n,remembers:s=!0}){if(!Za(t))return{show:[],record:null,reason:"no-version"};if(!Za(e)){if(!s)return{show:[],record:t,reason:"cannot-remember"};const i=Hme(n,t);return i.length?{show:i,record:t,reason:"welcome"}:{show:[],record:t,reason:"first-run"}}const a=Qo(e,t);if(a===0)return{show:[],record:null,reason:"seen"};if(a>0)return{show:[],record:null,reason:"ahead"};const o=R5(n,e,t);return o.length?{show:o,record:t,reason:"new-notes"}:{show:[],record:t,reason:"nothing-new"}}function nge(e,t){if(/\s|^$/.test(e[t+2]??""))return-1;let n=t+2;for(;n<e.length;){if(e[n]==="`"){const s=e.indexOf("`",n+1);if(s<0)break;n=s+1;continue}if(e.startsWith("**",n)&&!/\s/.test(e[n-1]??" "))return n;n++}return-1}function M5(e,t=!0){const n=[];let s="";const a=()=>{s&&(n.push({kind:"text",text:s}),s="")};let o=0;for(;o<e.length;){if(e[o]==="`"){const i=e.indexOf("`",o+1);if(i>o+1){a(),n.push({kind:"code",text:e.slice(o+1,i)}),o=i+1;continue}}else if(t&&e.startsWith("**",o)){const i=nge(e,o);if(i>0){a(),n.push({kind:"bold",kids:M5(e.slice(o+2,i),!1)}),o=i+2;continue}}s+=e[o],o+=1}return a(),n}function Ja(e=typeof navigator>"u"?"":navigator.userAgent){return/\bccdeck-desktop\/\d/.test(e)}function Mve(e,t,n){if(e===null)return null;const s=e+t-n;return s>0?s:null}function $ve(e){const t=Math.ceil(e/1e3),n=Math.floor(t/60),s=t%60;return n>0?`${n}m ${s}s`:`${s}s`}function sge(e){return(e??[]).filter(t=>t.installed&&t.profiles>0)}function Lve(e){return!Number.isFinite(e)||e<=0?"empty":Yr(e)}function Ive(e,t){return e.map(n=>({key:n.key,name:n.name,running:n.running,visits:t.filter(s=>s.browser===n.key).reduce((s,a)=>s+a.programVisits,0)}))}function rge(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 s=Math.round(n/60);return s<60?`${s} min ago`:`${Math.round(s/60)} hr ago`}function Ove(e){const t=e.profiles.filter(s=>s.degraded);if(t.length>0){const s=t[0],a=t.length-1;return{kind:"unreadable",text:`${s.name}/${s.profile} could not be read — ${s.reason??"no reason given"}`+(a>0?`, and ${a} more`:"")+". The watch continues on the profiles it can read."}}const n=sge(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(s=>s.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 age="Check for updates",$5="Ask npm now whether a newer ccdeck is out.",sI="Checking…",oge="Couldn't reach npm. Try again.",ige="Couldn't reach the deck. Try again.",L5="Update checks are off on this deck (AGENTS_DECK_NO_UPDATE_CHECK or AGENTS_DECK_NO_INSTALL).",lge="The deck looks again in five minutes.";function cge(e,t,n,s){const a=s?t.npx:n?Kt(t,n):void 0;return a?`${e} is out, but ${a}`:`${e} is out. Run:`}const Rn=(e,t={})=>({said:e,tone:"answer",age:null,command:null,action:null,...t}),Ao=e=>Rn(e,{tone:"note"});function rI(e,t){return rge(e,t)??"just now"}function uge(e,t){const n=e.update;return(n==null?void 0:n.status)==="ready"?Ao(`${n.version} is ready. Restart to update.`):(n==null?void 0:n.status)==="checking"?Ao("The app is checking for updates…"):(n==null?void 0:n.status)==="downloading"?Ao(n.version?`${n.version} is out. The app is downloading it.`:"The app is downloading an update."):(n==null?void 0:n.status)==="current"?Ao(`You're on the latest, ${e.version??t}. You can check again here.`):(n==null?void 0:n.status)==="error"?Ao("The app's last update check failed. Try Check for updates again."):Ao("The app keeps itself up to date. Check for updates here.")}function dge(e,t,n){var i;const s=e.version;if((s==null?void 0:s.upgradeMode)==="install"&&e.upgradeState!=="failed"){if(e.upgradeState==="done")return Rn(`${t} is installed.`);const c=e.upgradeState==="running",d=`Runs ${((i=s.upgrade)==null?void 0:i.command)??s.command} here, then restarts once nothing is running.`;return Rn(c?`Installing ${t}…`:`${t} is out.`,{action:{kind:"install",label:"Update now",busy:c,why:d}})}if((s==null?void 0:s.upgradeMode)==="npx"&&s.canRestart){const c=e.upgradeState==="failed";return Rn(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 ${s.command} and hands it this port. Nothing is installed globally — npx unpacks its own copy.`}})}const a=e.upgradeState==="failed"?`Installing ${t} failed. Run it yourself:`:cge(t,n,s==null?void 0:s.upgradeBlocked,(s==null?void 0:s.upgradeMode)==="npx"),o=(s==null?void 0:s.command)??null;return Rn(a,{command:o,action:o?{kind:"copy",label:e.copied?"Copied":"Copy",busy:!1}:null})}function hge(e){const t=e.version;if(e.unreachable)return Rn(ige,{tone:"warn"});const n=t!=null&&t.checkFailedAt&&t.checkFailedAt>(t.checkedAt??0)?t.checkFailedAt:null;if(n)return Rn(oge,{tone:"warn",age:e.answered?null:`Last tried ${rI(n,e.now)}.`});const s=t!=null&&t.latestPending&&t.latestPending!==e.running?t.latestPending:null;if(s)return Rn(`${s} is tagged on npm but can't be installed yet. ${lge}`);const a=t!=null&&t.checkedAt?rI(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 Rn(o,{age:a?`Checked ${a}.`:null})}return Rn("",{age:a?`Last checked ${a}.`:null})}function fge(e,t){var a,o;const n=e.version;if((a=e.app)!=null&&a.inApp&&(n!=null&&n.checkDisabled)){const i=uge(e.app,e.running);return i&&{canCheck:!0,checking:e.checking||((o=e.app.update)==null?void 0:o.status)==="checking",line:e.unreachable?Rn("The desktop updater did not accept the check. Try the ccdeck menu or update the desktop app.",{tone:"warn"}):e.checking?Rn(sI):i}}if(n!=null&&n.checkDisabled)return{canCheck:!1,checking:!1,line:Ao(L5)};const s=(n==null?void 0:n.notice)??null;if((s==null?void 0:s.kind)==="upgrade")return{canCheck:!0,checking:e.checking,line:dge(e,s.to,t)};if((s==null?void 0:s.kind)==="restart"){const i=n!=null&&n.canRestart?`${s.to} is installed. Restart the deck to start running it.`:`${s.to} is installed. Restart ccdeck to start running it.`;return{canCheck:!0,checking:e.checking,line:Rn(i)}}return e.checking?{canCheck:!0,checking:!0,line:Rn(sI)}:{canCheck:!0,checking:!1,line:hge(e)}}const I5=450;async function pge(e,t=n=>new Promise(s=>setTimeout(s,n))){const[n]=await Promise.all([e(!0),t(I5)]);return n?"answered":"unreachable"}async function mge(e=fetch){try{const[t]=await Promise.all([e("/api/desktop-update/check",{method:"POST",signal:AbortSignal.timeout(8e3)}),new Promise(n=>setTimeout(n,I5))]);return t.ok?"answered":"unreachable"}catch{return"unreachable"}}const d1="Eight pictures of what the deck shows.",aI="Restart the deck. Sessions, settings and pairings come back as they were.";function gge(e){var I;const t=(e==null?void 0:e.versionCheck.versionChecking)??!1,n=jr(3e4),[s,a]=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:m,restart:w,desktopUpdate:j,running:v,onHandOff:b}=e,k=fge({version:p.version,running:v,checking:s||t,answered:d,unreachable:i,now:n,upgradeState:m.upgradeState,copied:m.cmdCopied,restarting:w.restarting,app:{inApp:Ja(),update:j.appUpdate,version:r5(),menu:o5()}},i1);if(!k)return null;const N=Ja()&&((I=p.version)==null?void 0:I.checkDisabled);return{state:k,check:async()=>{var O;if(!xn(o.current||t)||N&&((O=j.appUpdate)==null?void 0:O.status)==="checking")return;o.current=!0,a(!0);const A=N?await mge():await pge(p.loadVersion);o.current=!1,a(!1),c(A==="unreachable"),h(!0)},act:A=>{if(A.kind==="copy")return void m.copyCommand();b(),p.showNotice(),A.kind==="install"?m.startUpgrade():w.askRestart({upgrade:!0})},checkWhy:N?"Ask the desktop app whether a newer ccdeck is out.":$5}}function yge({onTour:e,onRestart:t,updateCheck:n}){var h,f;const s=Il("above","dialog"),a=gge(n),o=y.useId(),i=(a==null?void 0:a.state.canCheck)??!1,d=((h=a==null?void 0:a.state.line.action)==null?void 0:h.kind)==="install"||((f=a==null?void 0:a.state.line.action)==null?void 0:f.kind)==="npx"?void 0:t;return!e&&!i&&!d&&!a?null:r.jsxs("div",{className:"rn-actions",children:[(e||i||d)&&r.jsxs("div",{className:"rn-acts",children:[e&&r.jsxs("button",{type:"button",className:"btn rn-act",onClick:e,"aria-describedby":`${o}-tour`,...s.bind({label:d1}),children:[r.jsx(jte,{}),"Take the tour"]}),a&&i&&r.jsxs("button",{type:"button",className:"btn rn-act",onClick:()=>void a.check(),"aria-busy":a.state.checking||void 0,"aria-describedby":`${o}-check`,...s.bind({label:a.checkWhy}),children:[r.jsx(Nte,{}),age]}),d&&r.jsxs("button",{type:"button",className:"btn rn-act rn-act-restart",onClick:d,"aria-describedby":`${o}-restart`,...s.bind({label:aI}),children:[r.jsx(Ste,{}),"Restart"]})]}),a&&r.jsx(wge,{line:a.state.line,onAct:a.act,bindHint:s.bind,whyId:`${o}-act`}),r.jsx("span",{hidden:!0,id:`${o}-tour`,children:d1}),r.jsx("span",{hidden:!0,id:`${o}-check`,children:(a==null?void 0:a.checkWhy)??$5}),r.jsx("span",{hidden:!0,id:`${o}-restart`,children:aI}),s.node]})}function wge({line:e,onAct:t,bindHint:n,whyId:s}){const{action:a}=e,o=a&&r.jsx(xge,{action:a,onAct:t,bindHint:n,whyId:s});return r.jsxs("p",{className:"rn-update-line","data-tone":e.tone,children:[r.jsx("span",{className:"rn-update-what",role:"status",children:e.said}),e.age&&r.jsx("span",{className:"rn-update-age",children:e.age}),e.command?r.jsxs("span",{className:"rn-update-cmd",children:[r.jsx("code",{className:"rn-code",children:e.command}),o]}):o]})}function xge({action:e,onAct:t,bindHint:n,whyId:s}){const a=e.kind==="copy"?null:e.why;return r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",className:a?"btn primary rn-line-act":"btn rn-line-act",onClick:()=>t(e),"aria-busy":e.busy||void 0,"aria-describedby":a&&s?s:void 0,...a&&n?n({label:a}):{},children:e.label}),a&&s&&r.jsx("span",{hidden:!0,id:s,children:a})]})}function vge({entries:e,since:t,running:n,firstRun:s,onClose:a,onTour:o,updateVersion:i,updateBusy:c,onUpdateRestart:d,updateFailure:h,onRestart:f,updateCheck:p}){const m=mt(a),w=yt(a),j=zme(e);return r.jsx("div",{className:"modal-backdrop",...w,role:"presentation",children:r.jsxs("div",{ref:m,className:"modal release-notes",onClick:v=>v.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"release-notes-title",children:[r.jsxs("header",{className:"modal-head",children:[r.jsxs("div",{className:"modal-title",children:[r.jsx("span",{id:"release-notes-title",className:"modal-tool-name",children:"What's new"}),j&&r.jsx("span",{className:"modal-tool-id",children:j})]}),r.jsx("div",{className:"modal-actions",children:r.jsx("button",{type:"button",className:"glyph-btn",onClick:a,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),r.jsxs("section",{className:"modal-body",children:[(i||h)&&r.jsxs("div",{className:"rn-update",children:[i&&d&&r.jsxs("div",{className:"guide-door",children:[r.jsxs("span",{children:["ccdeck v",i," is downloaded and verified."]}),r.jsx("button",{type:"button",className:"btn",onClick:d,"aria-busy":c||void 0,children:c?"Restarting…":Sl})]}),r.jsx("p",{className:"rn-update-said",role:"status",children:h})]}),r.jsx("p",{className:"modal-note",children:Vme({since:t,running:n,firstRun:s,entries:e})}),r.jsx(yge,{onTour:i?void 0:o,onRestart:f,updateCheck:p}),e.map(v=>r.jsxs("section",{className:"modal-section",children:[r.jsxs("h3",{className:"rn-version",children:["v",v.version]}),r.jsx("ul",{className:"rn-notes",children:v.notes.map((b,k)=>{const{icon:N,rest:S}=Kme(b.title);return r.jsxs("li",{className:"rn-note",children:[r.jsxs("p",{className:"rn-note-title",children:[N&&r.jsx("span",{className:"rn-note-icon",children:N}),S]}),r.jsx("p",{className:"rn-note-body",children:O5(M5(b.body))})]},k)})})]},v.version))]})]})})}function O5(e){return e.map((t,n)=>t.kind==="text"?t.text:t.kind==="code"?r.jsx("code",{className:"rn-code",children:t.text},n):r.jsx("strong",{className:"rn-strong",children:O5(t.kids)},n))}function bge({state:e,sessionId:t,onClose:n}){const s=y.useMemo(()=>kge(e,t),[e,e.revision,t]),a=y.useRef(null),o=mt(n,{focusRef:a}),i=yt(n);return s?r.jsx("div",{className:"modal-backdrop",...i,role:"presentation",children:r.jsxs("div",{ref:o,className:"modal session-summary",onClick:c=>c.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ss-title",children:[r.jsxs("div",{className:"modal-head",children:[r.jsxs("div",{className:"modal-title",children:[r.jsx("span",{className:"state-pill state-done","aria-hidden":!0,children:"done"}),r.jsx("span",{id:"ss-title",className:"modal-tool-name",title:s.cwd??s.sessionId,children:s.label}),r.jsxs("span",{className:"modal-tool-id",children:["· ",s.sessionId.slice(0,8)]})]}),r.jsxs("div",{className:"modal-actions",children:[r.jsx("span",{className:"modal-dur",title:"Total wall time",children:s.durationLabel}),r.jsx("button",{type:"button",ref:a,className:"glyph-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),r.jsxs("div",{className:"modal-body",children:[r.jsxs("section",{className:"ss-hero",children:[r.jsxs("div",{className:"ss-hero-left",children:[r.jsx("div",{className:"ss-cost-label",children:WP}),r.jsx("div",{className:"ss-cost",children:et(s.cost.total)}),s.modelChips.length>0&&r.jsx("div",{className:"ss-models",children:s.modelChips.map(c=>r.jsx("span",{className:"model-chip","data-family":Qf(c),title:c,children:Va(c)},c))})]}),r.jsx("div",{className:"ss-hero-right",children:s.cost.total>0&&r.jsxs(r.Fragment,{children:[r.jsx(mj,{cost:s.cost,size:"lg"}),r.jsxs("div",{className:"ss-cost-legend",children:[r.jsxs("span",{className:"ssl ssl-in",children:["input ",r.jsx("b",{children:et(s.cost.input)})]}),r.jsxs("span",{className:"ssl ssl-out",children:["output ",r.jsx("b",{children:et(s.cost.output)})]}),r.jsxs("span",{className:"ssl ssl-cr",children:["cache r ",r.jsx("b",{children:et(s.cost.cacheRead)})]}),r.jsxs("span",{className:"ssl ssl-cw",children:["cache w ",r.jsx("b",{children:et(s.cost.cacheWrite)})]})]})]})})]}),r.jsxs("section",{className:"ss-stats",children:[r.jsx(Gi,{label:"agents",value:s.agentCount}),r.jsx(Gi,{label:"subagents",value:s.subagentCount}),r.jsx(Gi,{label:"tool calls",value:s.toolCount}),r.jsx(Gi,{label:"prompts",value:s.promptCount}),r.jsx(Gi,{label:"tokens",value:s.tokensSum.toLocaleString()}),s.errCount>0&&r.jsx(Gi,{label:"errors",value:s.errCount,tone:"err"})]}),s.topTools.length>0&&r.jsxs("section",{className:"modal-section",children:[r.jsx("h4",{children:"Most-used tools"}),r.jsx("div",{className:"ss-top-tools",children:s.topTools.map(([c,d])=>r.jsxs("div",{className:"ss-tt",children:[r.jsx("span",{className:"ss-tt-name",children:c}),r.jsx("span",{className:"ss-tt-bar",children:r.jsx("span",{className:"ss-tt-bar-fill",style:{width:`${d/s.topTools[0][1]*100}%`}})}),r.jsx("span",{className:"ss-tt-count",children:d})]},c))})]}),s.firstPrompt&&r.jsxs("section",{className:"modal-section",children:[r.jsx("h4",{children:"Opening prompt"}),r.jsx("div",{className:"ss-prompt",children:s.firstPrompt})]})]})]})}):null}function Gi({label:e,value:t,tone:n}){return r.jsxs("div",{className:`ss-stat${n?` tone-${n}`:""}`,children:[r.jsx("div",{className:"ss-stat-value",children:t}),r.jsx("div",{className:"ss-stat-label",children:e})]})}function kge(e,t){const n=e.agents.get(t);if(!n)return null;const s=[];for(const S of e.agents.values())S.sessionId===t&&s.push(S);if(s.length===0)return null;const a={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,m,w=1/0,j=0;for(const S of s){const _=On(S);a.input+=_.input,a.output+=_.output,a.cacheRead+=_.cacheRead,a.cacheWrite+=_.cacheWrite,a.total+=_.total;for(const I of I3(S))o.add(I);S.model&&o.add(S.model),S.kind==="subagent"&&p++;const E=p3(S.prompts);d+=E.length,!m&&E.length>0&&(m=E[0].text),h+=S.usage.inputTokens+S.usage.outputTokens,c+=S.toolCount,f+=S.toolErrorCount??0;for(const[I,A]of S.toolCountByName??[])i.set(I,(i.get(I)??0)+A);w=Math.min(w,S.startedAt),j=Math.max(j,S.endedAt??Date.now())}const v=Math.max(0,j-w),b=Math.floor(v/1e3),k=b<60?`${b}s`:b<3600?`${Math.floor(b/60)}m ${String(b%60).padStart(2,"0")}s`:`${Math.floor(b/3600)}h ${Math.floor(b%3600/60)}m`,N=Array.from(i.entries()).sort((S,_)=>_[1]-S[1]).slice(0,5);return{sessionId:t,label:n.label||n.cwdBasename||"session",cwd:n.cwd,durationLabel:k,cost:a,modelChips:Array.from(o),agentCount:s.length,subagentCount:p,toolCount:c,promptCount:d,tokensSum:h,errCount:f,topTools:N,firstPrompt:m}}function tn({id:e,title:t,note:n,noteId:s,aside:a,list:o=!0,settingId:i,className:c,children:d}){const h=c?`settings-group ${c}`:"settings-group",f=o?r.jsx("div",{className:"settings-list",children:d}):d;return t===void 0?r.jsx("div",{className:h,"data-setting":i,children:f}):r.jsxs("section",{className:h,"aria-labelledby":e,"data-setting":i,children:[r.jsxs("div",{className:"settings-caption",children:[r.jsxs("div",{className:"settings-caption-text",children:[r.jsx("h3",{id:e,children:t}),n&&r.jsx("p",{className:"settings-caption-note",id:s,children:n})]}),a]}),f]})}function pt({name:e,nameId:t,note:n,noteId:s,control:a,as:o="label",settingId:i,className:c,children:d}){const h=o;return r.jsxs(h,{className:c?`settings-row ${c}`:"settings-row","data-setting":i,children:[r.jsx("span",{className:"settings-row-name",id:t,children:e}),n&&r.jsx("span",{className:"settings-row-note",id:s,children:n}),a!==void 0&&r.jsx("span",{className:"settings-row-control",children:a}),d]})}function P5(e,t){const[n,s]=y.useState(null),[a,o]=y.useState(!1),[i,c]=y.useState(""),d=y.useRef(!1),h=p=>typeof p=="boolean"?p:t;return y.useEffect(()=>{let p=!0;return fetch("/api/prefs").then(m=>{if(!m.ok)throw new Error;return m.json()}).then(m=>{var w;if(!m.ok)throw new Error;p&&s(h((w=m.prefs)==null?void 0:w[e]))}).catch(()=>{p&&c("Could not read this setting. Reopen Settings to retry.")}),()=>{p=!1}},[e]),{enabled:n,busy:a,error:i,change:async()=>{if(!(n===null||!xn(d.current))){d.current=!0,o(!0),c("");try{const p=await fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({[e]:!n})});if(!p.ok)throw new Error;const m=await p.json();if(!m.ok)throw new Error;s(h(m.prefs[e]))}catch{c("Could not save this setting. Try again.")}finally{d.current=!1,o(!1)}}}}}function oI({provider:e}){const t=e==="Codex"?"recoverCodexSessions":"recoverClaudeSessions",n=`${e.toLowerCase()}-session-recovery`,s=P5(t,!0);return r.jsxs(tn,{id:`${n}-title`,title:`${e} sessions`,note:"Choose what appears after ccdeck starts.",children:[r.jsx(pt,{settingId:n,name:"Restore unfinished sessions",note:e==="Codex"?"Find unfinished turns in recent local Codex logs on the next start. A missing ending does not confirm the process is still running.":"On the next start, find busy local Claude sessions whose process identity can be verified.",control:r.jsx("button",{type:"button",className:"switch",role:"switch","aria-label":`Restore unfinished ${e} sessions`,"aria-checked":s.enabled===!0,...$n(s.busy,s.enabled===null),onClick:()=>{s.change()},children:r.jsx("span",{className:"switch-knob"})})}),s.error&&r.jsx("p",{role:"alert",children:s.error}),e==="Claude"&&r.jsx(jge,{})]})}function jge(){const e=P5("continueStopped",!1);return r.jsxs(r.Fragment,{children:[r.jsx(pt,{settingId:"claude-continue-stopped",name:"Continue stopped background sessions",note:"When a background session stops on an expired login or a usage limit, continue it once a working login with room is active. Once per stop; a session that stops again right after waits for you.",control:r.jsx("button",{type:"button",className:"switch",role:"switch","aria-label":"Continue stopped background sessions automatically","aria-checked":e.enabled===!0,...$n(e.busy,e.enabled===null),onClick:()=>{e.change()},children:r.jsx("span",{className:"switch-knob"})})}),e.error&&r.jsx("p",{role:"alert",children:e.error})]})}const D5="agent-dag.character",Vh=[{id:"deck",name:"Deck companion"},{id:"fox",name:"Fox"},{id:"penguin",name:"Penguin"}];function Nge(e){return e==="fox"||e==="penguin"?e:"deck"}function Sge(){return Nge(Ze(D5))}const _ge="With no deck tab open, get a notification wherever a sound would have played.",Cge="With the ccdeck window closed, get a notification wherever a sound would have played.";function Ege(e){return e?Cge:_ge}const Tge="Held off for this run — the deck was started with alerts disabled. Your choice is saved for the next start.",F5=[{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"},{kind:"notifyStopped",label:"Sessions stopped on login or limit",title:"When Claude Code sessions stop on an expired login or a usage limit — once for all of them, with what to type to resume"}],Rge="For the Claude and Codex accounts you're on, whether or not the deck is open.",Age="Held off for this run too.",iI="Get notified when you're away from this tab.";function Mge(e){switch(e){case"granted":return{status:"Enabled",ask:!1,ok:!0,note:iI};case"default":return{status:null,ask:!0,ok:!1,note:iI};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."}}}const B5="section:";function q5(e){return e.id.startsWith(B5)}const $ge={general:["behaviour","behavior","preferences"],appearance:["look","style"],reading:["readability","legibility"],keyboard:["shortcuts","hotkeys","keybindings","keys"],notifications:["alerts","notify"],sounds:["audio","tones","chimes"],data:["privacy","local data"],radar:["telemetry","collector","monitoring"],about:["information"]},Lge={done:"Turn finished","needs-input":"Claude is asking"},Ige={done:["done","complete","finished","end of turn","volume","preview","chime","tone"],"needs-input":["question","needs input","permission","waiting","volume","preview","chime","tone"]},Oge={notifySwap:["auto-switch","switch account","swap","alerts"],notifyQuota:["quota","limit","rate limit","usage","alerts"],notifyReset:["quota","limit","window","available","alerts"],notifyStopped:["stopped","login","expired","usage limit","continue","alerts"]},fN=e=>{var t;return((t=Fa.find(n=>n.id===e))==null?void 0:t.label)??e};function Pge(e){return{id:`${B5}${e}`,section:e,label:fN(e),keywords:$ge[e]}}function Dge(){const e={general:[{id:"claude-session-recovery",claudeOnly:!0,section:"general",group:"Claude sessions",label:"Restore unfinished sessions",keywords:["claude","recover","restore","startup","restart","busy"]},{id:"claude-continue-stopped",claudeOnly:!0,section:"general",group:"Claude sessions",label:"Continue stopped background sessions",keywords:["claude","continue","background","stopped","login","usage limit","automatically"]},{id:"codex-session-recovery",section:"general",group:"Codex sessions",label:"Restore unfinished sessions",keywords:["codex","recover","restore","startup","restart","unfinished"]},{id:"hide-finished",section:"general",group:"Board",label:"Hide finished sessions after",keywords:["finished","done","completed","idle","clean up","auto hide","canvas","board","remove"]},{id:"auto-update",section:"general",group:"Updates",label:"Update when idle",keywords:["update","auto update","automatic updates","upgrade","restart","new version"]},{id:"accounts",section:"general",group:"Elsewhere on the deck",label:"Accounts and auto-switch",claudeOnly:!0,keywords:["accounts","auto-switch","switch account","login","claude accounts"]},{id:"local-network",section:"general",group:"Elsewhere on the deck",label:"Local network",claudeOnly:!0,keywords:["lan","pairing","pair","other machines","sync","network"]},{id:"browser-watch",section:"general",group:"Elsewhere on the deck",label:"Browser Watch",keywords:["browser","watch","away","automation","security"]}],appearance:[{id:"theme",section:"appearance",label:"Theme",keywords:["colour theme","color theme","dark mode","light mode","colours","colors","palette","skin"]},...Zr.map(t=>({id:`theme-${t}`,section:"appearance",group:"Theme",label:Zu[t].name,keywords:t.endsWith("contrast")?["high contrast","accessibility"]:[]})),{id:"character",section:"appearance",group:"Character",label:"Show the character",keywords:["character","mascot","companion","claude fm","radio","music","minimap","hide the character"]},{id:"character-choice",section:"appearance",group:"Character",label:"Choose character",keywords:["mascot","avatar",...Vh.map(t=>t.name.toLowerCase())]}],reading:[{id:"text-size",section:"reading",label:"Text size",keywords:["font","font size","zoom","bigger","larger","smaller","scale","readability"]},{id:"density",section:"reading",label:"Density",keywords:["spacing","compact","comfortable","padding","tight","dense"]}],keyboard:[{id:"single-keys",section:"keyboard",label:"Single-key shortcuts",keywords:["single key","letters","voice control","dictation","accessibility"]}],notifications:[{id:"notify-closed",section:"notifications",group:"While the deck is closed",label:"Notifications while closed",keywords:["alerts","desktop notifications","browser notifications","push","background","permission"]},...F5.map(({kind:t,label:n})=>({id:t,section:"notifications",group:"Accounts",label:n,keywords:Oge[t]}))],sounds:[{id:"play-sounds",section:"sounds",label:"Play sounds",keywords:["sound","mute","unmute","silence","quiet"]},...tu.map(t=>({id:`tone-${t}`,section:"sounds",label:Lge[t],keywords:Ige[t]})),{id:"custom-sounds",section:"sounds",label:"Custom sounds",keywords:["voice","speech","text to speech","spoken voice","own sound","library"]},{id:"custom-import",section:"sounds",group:"Custom sounds",label:"Import audio",keywords:["import","upload","file","mp3","wav","ogg","own sound"]},{id:"custom-record",section:"sounds",group:"Custom sounds",label:"Record a clip",keywords:["record","microphone","mic","clip"]}],data:[{id:"tool-history-retention",section:"data",group:"Tool history",label:"Keep history",keywords:["retention","delete history","history","days","tool calls","statistics"]},{id:"tool-history-size",section:"data",group:"Tool history",label:"Space used",keywords:["storage","disk","size","bytes"]},{id:"tool-history-clear",section:"data",group:"Tool history",label:"Clear history",keywords:["delete history","erase","wipe","remove"]}],radar:[{id:"radar-enabled",section:"radar",label:"Monitor automatically",keywords:["telemetry","collector","monitoring","traffic","background","automatic","radar"]}],about:[{id:"version",section:"about",group:"ccdeck",label:"Version",keywords:["update","release","build","about"]},{id:"whats-new",section:"about",group:"ccdeck",label:"What's new",keywords:["changelog","release notes","changes","news"]},{id:"licence",section:"about",group:"ccdeck",label:"Licence",keywords:["license","agpl","source","source code","open source","github"]},{id:"tour",section:"about",group:"Tour and feedback",label:"Take the tour",keywords:["tour","guide","help","onboarding","tutorial","introduction"]},{id:"feedback",section:"about",group:"Tour and feedback",label:"Send feedback",keywords:["feedback","bug","report","contact","suggestion","idea"]}]};return Fa.flatMap(({id:t})=>[Pge(t),...e[t]])}const h1=Dge();function Fge(e){return e?h1:h1.filter(t=>!t.claudeOnly)}function U5(e){if(q5(e))return"Section";const t=fN(e.section);return e.group&&e.group!==e.label?`${t} › ${e.group}`:t}function Bge(e){return`${e.label}, ${U5(e).replace(/ › /g,", ")}`}function zc(e){return e.normalize("NFD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/\s+/g," ").trim()}function Th(e,t){for(let n=e.indexOf(t);n!==-1;n=e.indexOf(t,n+1))if(n===0||!/[a-z0-9]/.test(e[n-1]))return!0;return!1}function qge(e,t){const n=zc(e.label);if(n.startsWith(t))return 0;if(Th(n,t))return 1;const s=e.keywords.map(zc);if(s.some(i=>Th(i,t)))return 2;const a=[zc(fN(e.section)),...e.group?[zc(e.group)]:[]];if(a.some(i=>Th(i,t)))return 3;const o=t.split(" ");if(o.length>1){const i=[n,...s,...a];if(o.every(c=>i.some(d=>Th(d,c))))return 4}return null}const Uge=12;function Wge(e,t=h1){const n=zc(e);return n?t.map((s,a)=>({entry:s,at:a,score:qge(s,n)})).filter(s=>s.score!==null).sort((s,a)=>s.score-a.score||s.at-a.at).slice(0,Uge).map(s=>s.entry):[]}function W5(e,t){const n=t.trim();return e===0?`No setting matches “${n}”.`:e===1?`1 setting matches “${n}”`:`${e} settings match “${n}”`}function Hge(e,t,n,s){if(e==="Escape")return t!==""?{kind:"clear"}:{kind:"pass"};if(n===0)return{kind:"pass"};const a=Math.min(Math.max(s,0),n-1);return e==="ArrowDown"?{kind:"move",index:(a+1)%n}:e==="ArrowUp"?{kind:"move",index:(a-1+n)%n}:e==="Enter"?{kind:"open",index:a}:{kind:"pass"}}const zge="Hide finished sessions after",Vge="A finished session leaves the canvas after this long. It stays in the session list (L), and comes back when it starts working again or needs you.";function Gge(){const e=VF();return r.jsx(tn,{id:"settings-board-caption",title:"Board",children:r.jsx(pt,{settingId:"hide-finished",name:zge,nameId:"settings-hide-finished-label",note:Vge,noteId:"settings-hide-finished-note",control:r.jsx("select",{className:"sm-select",value:e,"aria-labelledby":"settings-hide-finished-label","aria-describedby":"settings-hide-finished-note",onChange:t=>Mde(Number(t.target.value)),children:UF.map(t=>r.jsx("option",{value:t,children:Ade(t)},t))})})})}const Kge="Accounts and auto-switch",Yge="Your Claude accounts, and Auto-switch, which moves Claude Code to another one before the account in use runs out.",Xge="Local network",Zge="Pairing with the decks on your other machines, so a login that expires on one is repaired from another.",Jge="Browser Watch",Qge="Whether something drove your browser while you were away, and what the deck does about it.";function eye({claudeHere:e,singleKeys:t,doors:n}){return r.jsxs(tn,{id:"settings-elsewhere-caption",title:"Elsewhere on the deck",children:[e&&r.jsx(Dk,{settingId:"accounts",name:Kge,note:Yge,onOpen:n.accounts,cap:t?{key:"A",title:"Press A anywhere to show or hide the accounts panel"}:null}),e&&r.jsx(Dk,{settingId:"local-network",name:Xge,note:Zge,onOpen:n.localNetwork,cap:null}),r.jsx(Dk,{settingId:"browser-watch",name:Jge,note:Qge,onOpen:n.browserWatch,dialog:!0,cap:t?{key:"B",title:"Press B anywhere to open or close Browser Watch"}:null})]})}function Dk({settingId:e,name:t,note:n,onOpen:s,cap:a,dialog:o=!1}){const i=`settings-${e}`;return r.jsx(pt,{as:"div",settingId:e,name:t,nameId:`${i}-name`,note:n,control:r.jsxs(r.Fragment,{children:[a&&r.jsx("kbd",{className:"settings-key","aria-hidden":!0,title:a.title,children:a.key}),r.jsx("button",{type:"button",className:"btn",id:`${i}-open`,"aria-labelledby":`${i}-open ${i}-name`,"aria-haspopup":o?"dialog":void 0,"aria-keyshortcuts":a?a.key:void 0,onClick:s,children:"Open"})]})})}const tye="Single-key shortcuts",nye="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 sye(e){const t=e.binds.includes("?")?"the keyboard shortcuts sheet":e.action;return t.charAt(0).toUpperCase()+t.slice(1)}function rye(e,t){const n=t.trim().toLowerCase();return n?[e.action,e.cap,e.macCap??""].some(s=>s.toLowerCase().includes(n)):!0}function aye({singleKeys:e,onToggleSingleKeys:t}){const n=Bu(Fu()),[s,a]=y.useState(""),o=y.useId(),i=C5(e).map(c=>({...c,rows:c.rows.filter(d=>rye(d,s))})).filter(c=>c.rows.length>0);return r.jsxs(r.Fragment,{children:[r.jsx(tn,{children:r.jsx(pt,{settingId:"single-keys",name:tye,nameId:"settings-single-keys-label",note:nye,noteId:"settings-single-keys-note",control:r.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:r.jsx("span",{className:"switch-knob"})})})}),r.jsxs("div",{className:"settings-filter",children:[r.jsx("label",{className:"vis-hidden",htmlFor:o,children:"Filter shortcuts"}),r.jsx("input",{id:o,type:"search",className:"settings-filter-field",placeholder:"Filter shortcuts",autoComplete:"off",spellCheck:!1,value:s,onChange:c=>a(c.target.value),onKeyDown:c=>{H3(c.key)&&s&&(c.stopPropagation(),a(""))}})]}),i.map(c=>{const d=`settings-keys-${c.title.toLowerCase().replace(/[^a-z]+/g,"-")}`;return r.jsx(tn,{id:d,title:c.title,className:"settings-keys",children:c.rows.map(h=>r.jsx(pt,{as:"div",name:sye(h),control:r.jsx("kbd",{className:"settings-key",children:n&&h.macCap?h.macCap:h.cap})},`${h.cap}:${h.action}`))},c.title)}),i.length===0&&r.jsxs("p",{className:"settings-empty",role:"status",children:["No shortcut matches “",s.trim(),"”."]}),s.trim()===""&&r.jsx("p",{className:"settings-foot",children:_5})]})}function oye({notifyOn:e,onToggleNotify:t,notifyVetoed:n,notifyPermission:s,onAskNotify:a,accountNotify:o,onToggleAccountNotify:i}){const c=Mge(s),d=Ja(),h=e&&!n&&!d,f=y.useRef(null),p=Xr(!c.ask,f);return r.jsxs(r.Fragment,{children:[r.jsxs(tn,{id:"sm-closed-caption",title:"While the deck is closed",children:[r.jsx(pt,{settingId:"notify-closed",name:"Notifications while closed",nameId:"sm-notify-label",note:n?Tge:Ege(d),noteId:"sm-notify-note",control:r.jsx("button",{ref:f,type:"button",role:"switch","aria-checked":e,"aria-labelledby":"sm-notify-label","aria-describedby":"sm-notify-note",className:"switch",onClick:t,children:r.jsx("span",{className:"switch-knob"})})}),h&&r.jsx(pt,{as:"div",name:"Browser notifications",nameId:"sm-channel-name",note:c.note,control:c.ask?r.jsx("button",{type:"button",className:"btn sm-channel-action",onClick:()=>{p(),a()},children:"Enable"}):r.jsxs("span",{className:"sm-channel-state","data-ok":c.ok||void 0,children:[c.ok&&r.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:r.jsx("path",{d:"M1.5 5.2 3.9 7.6 8.5 2.4"})}),c.status]})})]}),r.jsx(tn,{id:"sm-accounts-caption",title:"Accounts",note:n?Age:Rge,children:F5.map(({kind:m,label:w,title:j})=>r.jsx(pt,{settingId:m,name:w,nameId:`sm-${m}-label`,note:j,noteId:`sm-${m}-note`,control:r.jsx("button",{type:"button",role:"switch","aria-checked":o[m],"aria-labelledby":`sm-${m}-label`,"aria-describedby":`sm-${m}-note`,className:"switch",onClick:()=>i(m),children:r.jsx("span",{className:"switch-knob"})})},m))})]})}function H5({section:e}){return r.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==="radar"&&r.jsx(r.Fragment,{children:r.jsx("path",{d:"M11.8 7a4.8 4.8 0 1 1-4.8-4.8M9.7 7A2.7 2.7 0 1 1 7 4.3M7 7l4.8-4.8"})}),e==="reading"&&r.jsx(r.Fragment,{children:r.jsx("path",{d:"M2 11 5.5 3 9 11M3.3 8h4.4M10.5 4h2M10.5 7h2M10.5 10h2"})}),e==="sounds"&&r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M3.2 5.2h2L7.8 3v8L5.2 8.8h-2z"}),r.jsx("path",{d:"M9.8 5.4a2.4 2.4 0 0 1 0 3.2"}),r.jsx("path",{d:"M11.3 3.9a4.6 4.6 0 0 1 0 6.2"})]}),e==="general"&&r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M1.5 3h4.3M9.2 3h3.3M1.5 7h1.3M6.2 7h6.3M1.5 11h6.3M11.2 11h1.3"}),r.jsx("circle",{cx:"7.5",cy:"3",r:"1.7"}),r.jsx("circle",{cx:"4.5",cy:"7",r:"1.7"}),r.jsx("circle",{cx:"9.5",cy:"11",r:"1.7"})]}),e==="appearance"&&r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M7 1.7a5.3 5.3 0 1 0 0 10.6c.8 0 1.3-.5 1.3-1.2 0-.6-.5-1-.5-1.6 0-.7.5-1.2 1.2-1.2h1.3a2.3 2.3 0 0 0 2.3-2.3C12.6 3.7 10.1 1.7 7 1.7z"}),r.jsx("path",{d:"M4.3 6.7h.01M5.7 4.4h.01M8.4 4.2h.01"})]}),e==="keyboard"&&r.jsxs(r.Fragment,{children:[r.jsx("rect",{x:"1.5",y:"3.5",width:"11",height:"7",rx:"1.4"}),r.jsx("path",{d:"M4 5.9h.01M6 5.9h.01M8 5.9h.01M10 5.9h.01M4.6 8.2h4.8"})]}),e==="data"&&r.jsxs(r.Fragment,{children:[r.jsx("ellipse",{cx:"7",cy:"3.6",rx:"4.6",ry:"1.7"}),r.jsx("path",{d:"M2.4 3.6v6.8c0 .9 2.1 1.7 4.6 1.7s4.6-.8 4.6-1.7V3.6"}),r.jsx("path",{d:"M2.4 7c0 .9 2.1 1.7 4.6 1.7s4.6-.8 4.6-1.7"})]}),e==="about"&&r.jsxs(r.Fragment,{children:[r.jsx("circle",{cx:"7",cy:"7",r:"5.4"}),r.jsx("path",{d:"M7 6.4v3.4M7 4.4h.01"})]}),e==="notifications"&&r.jsxs(r.Fragment,{children:[r.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"}),r.jsx("path",{d:"M2.2 9.1h9.6"}),r.jsx("path",{d:"M5.7 11.2a1.3 1.3 0 0 0 2.6 0"})]})]})}const iye=["audio/webm;codecs=opus","audio/ogg;codecs=opus","audio/mp4"];function lye(e){return iye.find(t=>e(t))}const cye=4400;function uye(e){const t=e.split(";")[0];return{name:`Recorded voice.${t==="audio/mp4"?"m4a":t==="audio/ogg"?"ogg":"webm"}`,type:t}}function dye({full:e,setCustomError:t,runCustom:n,onImportCustom:s}){const[a,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 m;if(e)return;if(t(""),!((m=navigator.mediaDevices)!=null&&m.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=lye(b=>MediaRecorder.isTypeSupported(b)),j=new MediaRecorder(p,w?{mimeType:w}:void 0),v=[];i.current=j,j.ondataavailable=b=>{b.data.size&&v.push(b.data)},j.onerror=()=>t("Recording failed. Please try again."),j.onstop=()=>{p.getTracks().forEach(S=>S.stop()),c.current!==null&&clearTimeout(c.current),c.current=null;const b=i.current===j;if(b&&(i.current=null),o(!1),!b||!v.length)return;const k=uye(j.mimeType),N=new File(v,k.name,{type:k.type});n(()=>s(N))},j.start(200),o(!0),c.current=setTimeout(h,cye)}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:a,startRecording:f,stopRecording:h}}function hye({full:e,fullProps:t,runCustom:n,onCreateVoice:s}){const[a,o]=y.useState("Custom voice"),[i,c]=y.useState("Your turn"),[d,h]=y.useState(""),[f,p]=y.useState("1"),[m,w]=y.useState("1"),[j,v]=y.useState([]);return y.useEffect(()=>{if(typeof window>"u"||!("speechSynthesis"in window))return;const b=()=>{v(window.speechSynthesis.getVoices())};return b(),window.speechSynthesis.addEventListener("voiceschanged",b),()=>window.speechSynthesis.removeEventListener("voiceschanged",b)},[]),r.jsxs("details",{className:"sm-voice",children:[r.jsxs("summary",{className:"settings-row",...t,onClick:b=>{const k=b.currentTarget.parentElement;e&&k&&!k.open&&b.preventDefault()},children:[r.jsx("span",{className:"settings-row-name",children:"Spoken voice"}),r.jsx("span",{className:"settings-row-note",children:"Create from text"}),r.jsx("span",{className:"settings-row-control",children:r.jsx("svg",{className:"sm-voice-chevron",width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:r.jsx("path",{d:"M5.5 3.5 9 7l-3.5 3.5"})})})]}),r.jsxs("div",{className:"sm-voice-fields",children:[r.jsxs("label",{children:[r.jsx("span",{children:"Name"}),r.jsx("input",{className:"ap-manage-input",value:a,maxLength:80,onChange:b=>o(b.target.value)})]}),r.jsxs("label",{children:[r.jsx("span",{children:"Text"}),r.jsx("input",{className:"ap-manage-input",value:i,maxLength:180,onChange:b=>c(b.target.value)})]}),r.jsxs("label",{children:[r.jsx("span",{children:"Voice"}),r.jsxs("select",{className:"sm-select",value:d,onChange:b=>h(b.target.value),children:[r.jsx("option",{value:"",children:"System default"}),j.map(b=>r.jsx("option",{value:b.voiceURI,children:b.name},b.voiceURI))]})]}),r.jsxs("div",{className:"sm-voice-pair",children:[r.jsxs("label",{children:[r.jsx("span",{children:"Rate"}),r.jsx("input",{className:"ap-manage-input",type:"number",min:"0.5",max:"2",step:"0.1",value:f,onChange:b=>p(b.target.value)})]}),r.jsxs("label",{children:[r.jsx("span",{children:"Pitch"}),r.jsx("input",{className:"ap-manage-input",type:"number",min:"0.5",max:"2",step:"0.1",value:m,onChange:b=>w(b.target.value)})]})]}),r.jsx("button",{type:"button",className:"btn sm-custom-action",...t,onClick:()=>{e||n(async()=>{await s({name:a,text:i,voiceURI:d,rate:parseFloat(f),pitch:parseFloat(m)}),c("Your turn")})},children:"Add spoken voice"})]})]})}function fye({customAssets:e,onImportCustom:t,onCreateVoice:n,onRenameCustom:s,onPreviewCustom:a,onDeleteCustom:o}){const[i,c]=y.useState(""),d=e.length,h=Z0(d),f=h!==null,p=f?{"aria-disabled":!0,"aria-describedby":"sm-custom-full"}:{},[m,w]=y.useState(null),j=y.useRef(0),v=y.useRef(new Map),b=y.useRef(null),k=y.useRef(null);y.useEffect(()=>{if(!m)return;const A=window.setTimeout(()=>w(null),4e3);return()=>window.clearTimeout(A)},[m]);const N=async A=>{c("");try{await A()}catch(O){c(O instanceof Error?O.message:"Custom audio could not be saved.")}},S=(A,O)=>{const L=Date.now(),U=jl({armedFor:m,target:A,armedAt:j.current,now:L,gapMs:kl});if(U==="arm"){w(A),j.current=L;return}if(U==="ignore")return;w(null);const P=loe(e.map(T=>T.id),A);N(async()=>{var B;await o(A);const T=document.activeElement;T!==O&&!Yn((T==null?void 0:T.tagName)??null)||(B=P?v.current.get(P):b.current)==null||B.focus()})},{recording:_,startRecording:E,stopRecording:I}=dye({full:f,setCustomError:c,runCustom:N,onImportCustom:t});return r.jsxs(tn,{id:"sm-custom-title",title:"Custom sounds",note:"Your own files, clips and voices, kept on this machine. Either tone above can play one.",aside:r.jsxs("span",{className:"settings-caption-count",children:[d," of ",X0]}),className:"sm-custom",settingId:"custom-sounds",children:[f&&r.jsx("p",{className:"settings-row settings-row-status",id:"sm-custom-full",children:h}),r.jsx(pt,{as:"div",settingId:"custom-import",name:"Import audio",note:"WAV, MP3 or OGG",control:r.jsx("button",{ref:b,type:"button",className:"btn sm-custom-action",...p,onClick:()=>{var A;f||(A=k.current)==null||A.click()},children:"Choose file"}),children:r.jsx("input",{ref:k,type:"file",hidden:!0,accept:"audio/wav,audio/x-wav,audio/mpeg,audio/mp3,audio/ogg,.wav,.mp3,.ogg",onChange:A=>{var L;const O=(L=A.target.files)==null?void 0:L[0];A.currentTarget.value="",O&&!f&&N(()=>t(O))}})}),r.jsx(pt,{as:"div",settingId:"custom-record",name:"Record a clip",note:_?"Recording…":"Up to 5 seconds",control:_?r.jsx("button",{type:"button",className:"btn sm-custom-action",onClick:I,children:"Stop & save"}):r.jsx("button",{type:"button",className:"btn sm-custom-action",...p,onClick:()=>void E(),children:"Record"})}),r.jsx(hye,{full:f,fullProps:p,runCustom:N,onCreateVoice:n}),e.map(A=>r.jsxs("div",{className:"sm-custom-item",children:[r.jsx("input",{className:"ap-manage-input","aria-label":`Rename ${A.name}`,defaultValue:A.name,maxLength:80,onBlur:O=>{if(!O.target.value.trim()){O.target.value=A.name;return}N(()=>s(A.id,O.target.value))},onKeyDown:O=>{O.key==="Enter"&&O.currentTarget.blur()}}),r.jsx("span",{children:A.kind==="audio"?`${A.duration.toFixed(1)}s`:"Voice"}),r.jsx("button",{type:"button",className:"btn sm-custom-icon","aria-label":`Play ${A.name}`,onClick:()=>a(A.id),children:"Play"}),r.jsx("button",{type:"button",ref:O=>{O?v.current.set(A.id,O):v.current.delete(A.id)},className:`btn sm-custom-icon${m===A.id?" armed":""}`,onKeyDown:O=>{O.repeat&&O.preventDefault()},onClick:O=>S(A.id,O.currentTarget),"aria-label":m===A.id?`Confirm deleting ${A.name}`:`Delete ${A.name}`,title:m===A.id?"Press again to delete this sound. It cannot be brought back.":"Delete this sound",children:m===A.id?"Confirm":"Delete"})]},A.id)),i&&r.jsx("p",{className:"settings-row settings-row-status sm-custom-error",role:"alert",children:i})]})}const pye="A tone when a turn finishes, and when Claude asks for something.";function mye({soundOn:e,onToggleSound:t}){const n=y.useId(),s=Pn(),a=y.useId();return r.jsx(tn,{children:r.jsx(pt,{settingId:"play-sounds",name:"Play sounds",nameId:n,note:pye,noteId:a,control:r.jsxs(r.Fragment,{children:[s&&r.jsx("kbd",{className:"settings-key","aria-hidden":!0,title:"Press M anywhere to mute or unmute",children:"M"}),r.jsx("button",{type:"button",role:"switch","aria-checked":e,"aria-labelledby":n,"aria-describedby":a,"aria-keyshortcuts":s?"M":void 0,className:"switch",onClick:t,children:r.jsx("span",{className:"switch-knob"})})]})})})}const f1="custom:";function lI(e){return`${f1}${e}`}function gye(e){return e.startsWith(f1)?e.slice(f1.length):null}function yye({id:e,label:t="Volume",value:n,step:s=Dj,onLevel:a,"aria-describedby":o}){return r.jsxs("div",{className:"sm-row",children:[r.jsx("label",{htmlFor:e,children:t}),r.jsx("input",{id:e,type:"range",min:Hh,max:Lf,step:s,value:n,"aria-describedby":o,onChange:i=>a(Number(i.target.value)),style:{"--sm-level":`${(n-Hh)/(Lf-Hh)*100}%`}}),r.jsxs("span",{className:"sm-read",children:[n,"%"]})]})}const cI={done:"Turn finished","needs-input":"Claude is asking"},wye={done:"Plays when Claude or Codex finishes a turn.","needs-input":"Available in Claude Code only."};function xye({chime:e,tone:t,soundOn:n,customAssets:s,customSelections:a,onLevel:o,onFigure:i,onPreview:c,onBuiltInSelected:d,onCustomSelected:h}){const f=`sm-level-${e}`,p=`sm-figure-${e}`,m=a[e];return r.jsxs(tn,{id:`sm-name-${e}`,title:cI[e],note:wye[e],settingId:`tone-${e}`,aside:r.jsxs("button",{type:"button",className:"btn sm-hear",onClick:()=>c(e),"aria-label":`Hear the ${cI[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:[r.jsx("svg",{width:"11",height:"11",viewBox:"0 0 12 12",fill:"currentColor","aria-hidden":!0,children:r.jsx("path",{d:"M3 1.6v8.8l7-4.4z"})}),"Hear it"]}),children:[r.jsx(yye,{id:f,value:t.level,onLevel:w=>o(e,w)}),r.jsxs("div",{className:"sm-row",children:[r.jsx("label",{htmlFor:p,children:"Tone"}),r.jsxs("select",{id:p,className:"sm-select",value:m?lI(m):t.figure,onChange:w=>{const j=w.target.value,v=gye(j);v!==null?h(e,v):(d(e),i(e,j))},children:[Pj[e].map(w=>r.jsx("option",{value:w.id,children:w.label},w.id)),s.length>0&&r.jsx("optgroup",{label:"Custom",children:s.map(w=>r.jsx("option",{value:lI(w.id),children:w.name},w.id))})]})]})]})}const vye="Claude Code isn't on this machine, so only Turn finished plays here — for Codex turns.";function bye({soundOn:e,onToggleSound:t,prefs:n,claudeHere:s,onLevel:a,onFigure:o,onPreview:i,customAssets:c,customSelections:d,onBuiltInSelected:h,onCustomSelected:f,onImportCustom:p,onCreateVoice:m,onRenameCustom:w,onPreviewCustom:j,onDeleteCustom:v}){var S;const b=ooe(d),k=((S=c.find(_=>_.id===b))==null?void 0:S.name)??"the same custom sound",N=b?`Both tones use “${k}”. They may be harder to tell apart.`:"";return r.jsxs("div",{className:"sm-sounds",children:[r.jsx(mye,{soundOn:e,onToggleSound:t}),!s&&r.jsx("p",{className:"sm-note",children:vye}),!e&&r.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."}),r.jsx("div",{className:"sm-tones",children:tu.map(_=>r.jsx(xye,{chime:_,tone:n[_],soundOn:e,customAssets:c,customSelections:d,onLevel:a,onFigure:o,onPreview:i,onBuiltInSelected:h,onCustomSelected:f},_))}),N&&r.jsx("p",{className:"sm-note","aria-hidden":!0,children:N}),r.jsx("p",{className:"vis-hidden",role:"status",children:N}),r.jsx(fye,{customAssets:c,onImportCustom:p,onCreateVoice:m,onRenameCustom:w,onPreviewCustom:j,onDeleteCustom:v})]})}let zo={enabled:null,busy:!1,error:""};const Gh=new Set;let Lc=null,ea=null,Fk=!1,Kh=0;const sl=e=>{zo={...zo,...e},Gh.forEach(t=>t(zo))};async function p1(){if(Fk||zo.busy)return;Fk=!0;const e=Kh,t=new AbortController;ea=t;let n=!1;const s=setTimeout(()=>{n=!0,t.abort()},5e3);try{const a=await fetch("/api/system/traffic-radar/settings",{signal:t.signal}),o=await a.json();if(!a.ok||!o.ok||typeof o.enabled!="boolean")throw new Error;e===Kh&&!t.signal.aborted&&sl({enabled:o.enabled,error:""})}catch{e===Kh&&(n||!t.signal.aborted)&&sl({error:"Could not read Radar settings. Try again."})}finally{clearTimeout(s),Fk=!1,ea===t&&(ea=null)}}async function kye(e){if(zo.busy)return;Kh++,ea==null||ea.abort(),sl({busy:!0,error:""});const t=new AbortController,n=setTimeout(()=>t.abort(),15e3);try{const s=await fetch("/api/system/traffic-radar/settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({enabled:e}),signal:t.signal}),a=await s.json();if(!s.ok||!a.ok||typeof a.enabled!="boolean")throw new Error;sl({enabled:a.enabled})}catch{sl({error:"Could not save Radar settings. Try again."})}finally{clearTimeout(n),sl({busy:!1})}}function jye(){const[e,t]=y.useState(zo);return y.useEffect(()=>(Gh.add(t),t(zo),Lc||(p1(),Lc=setInterval(()=>void p1(),1e4)),()=>{Gh.delete(t),Gh.size||(Lc&&clearInterval(Lc),Lc=null,ea==null||ea.abort())}),[]),e}const Nye="Monitor automatically",Sye="Off by default. On, Radar finds Claude Code's collector and watches its telemetry in the background, even while Radar is closed. Turning it off stops monitoring.";function _ye({onOpen:e}){const{enabled:t,busy:n,error:s}=jye();return r.jsxs(tn,{children:[r.jsx(pt,{settingId:"radar-enabled",name:Nye,nameId:"radar-enabled-label",note:Sye,noteId:"radar-enabled-note",control:r.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":t===!0,"aria-labelledby":"radar-enabled-label","aria-describedby":"radar-enabled-note","aria-busy":n||t===null,onClick:()=>{!n&&t!==null&&kye(!t)},children:r.jsx("span",{className:"switch-knob"})})}),t===null&&!s&&r.jsx("p",{className:"settings-row settings-row-status",role:"status",children:"Reading Radar settings…"}),r.jsx(pt,{as:"div",name:"Radar",nameId:"settings-radar-open-name",note:"Claude's telemetry configuration and the connections it was seen making.",control:r.jsx("button",{type:"button",className:"btn",id:"settings-radar-open","aria-labelledby":"settings-radar-open settings-radar-open-name","aria-haspopup":"dialog",onClick:e,children:"Open"})}),s&&r.jsxs("div",{className:"settings-row",role:"alert",children:[r.jsx("span",{className:"settings-row-name",children:s}),r.jsx("span",{className:"settings-row-control",children:r.jsx("button",{type:"button",className:"btn","aria-busy":n,onClick:()=>void p1(),children:"Retry"})})]})]})}const Cye="Local statistics for Claude and Codex on this device. Commands are grouped by operation; raw arguments and outputs are not saved.";function Eye(){const[e,t]=y.useState(null),[n,s]=y.useState(""),[a,o]=y.useState(!1),[i,c]=y.useState(null),[d,h]=y.useState(""),f=y.useRef(!1),p=y.useRef(!0),m=async()=>{if(f.current)return;f.current=!0,o(!0),s("");const v=new AbortController,b=window.setTimeout(()=>v.abort(),12e3);try{const k=await fetch("/api/tool-audit/storage",{signal:v.signal}),N=await k.json();if(!k.ok||!N.ok)throw new Error;p.current&&t(N)}catch{p.current&&s("Could not read tool history storage. Try again.")}finally{window.clearTimeout(b),f.current=!1,p.current&&o(!1)}};y.useEffect(()=>(p.current=!0,m(),()=>{p.current=!1}),[]);const w=async(v,b)=>{if(f.current)return;f.current=!0,o(!0),s(""),h("");let k=!1;const N=new AbortController,S=window.setTimeout(()=>N.abort(),15e3);try{const _=await fetch("/api/tool-audit/storage",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(v==="clear"?{action:v,confirm:!0}:{action:v,days:b}),signal:N.signal}),E=await _.json();if(!_.ok||!E.ok)throw new Error;k=!0,p.current&&(c(null),h(v==="clear"?"Tool history cleared. New calls will continue to be recorded.":`Retention changed to ${b} days.`))}catch{p.current&&s("Could not update tool history. Check storage permissions and try again.")}finally{window.clearTimeout(S),f.current=!1,p.current&&(o(!1),k&&m())}},j=i!==null&&r.jsxs("div",{className:"settings-row settings-row-wide ta-confirm",role:"group","aria-label":"Confirm",children:[r.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.`}),r.jsxs("div",{children:[r.jsx("button",{type:"button",className:"btn danger","aria-busy":a,onClick:()=>{w(i==="clear"?"clear":"retention",typeof i=="number"?i:void 0)},children:i==="clear"?"Delete tool history":"Apply retention"}),r.jsx("button",{type:"button",className:"btn","aria-busy":a,onClick:()=>{f.current||c(null)},children:"Cancel"})]})]});return r.jsxs(tn,{id:"tool-history-settings-title",title:"Tool history",note:Cye,className:"ta-settings",children:[e?r.jsxs(r.Fragment,{children:[r.jsx(pt,{settingId:"tool-history-retention",name:"Keep history",nameId:"ta-keep-label",note:"Calls older than this are deleted.",control:r.jsx("select",{className:"sm-select","aria-labelledby":"ta-keep-label",value:e.retentionDays,"aria-busy":a,onChange:v=>{if(f.current)return;const b=Number(v.target.value);b<e.retentionDays?c(b):w("retention",b)},children:[30,60,90].map(v=>r.jsxs("option",{value:v,children:[v," days"]},v))})}),typeof i=="number"&&j,r.jsx(pt,{as:"div",settingId:"tool-history-size",name:"Space used",note:`Collected since ${GX(e.startedAt)}`,control:r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"settings-read",children:VX(e.bytes)}),r.jsx("button",{type:"button",className:"btn","aria-busy":a,onClick:()=>{m()},children:"Refresh"})]})}),r.jsx(pt,{as:"div",settingId:"tool-history-clear",name:"Clear history",note:"Deletes every recorded call on this device. New calls are still recorded.",control:r.jsx("button",{type:"button",className:"btn danger","aria-busy":a,onClick:()=>{f.current||c("clear")},children:"Clear…"})}),i==="clear"&&j,!e.storageOk&&r.jsx(pt,{as:"div",name:"Some calls could not be saved",note:"Check free space and storage permissions."})]}):r.jsx(pt,{as:"div",name:a?"Reading storage…":"Storage size unavailable."}),n&&r.jsxs("div",{className:"settings-row",role:"alert",children:[r.jsx("span",{className:"settings-row-name",children:n}),r.jsx("span",{className:"settings-row-control",children:r.jsx("button",{type:"button",className:"btn","aria-busy":a,onClick:()=>{m()},children:"Retry"})})]}),d&&r.jsx("p",{className:"settings-row settings-row-status",role:"status",children:d})]})}function Tye({theme:e}){return r.jsx("span",{className:"appearance-preview","data-swatch":e,children:r.jsxs("svg",{viewBox:"0 0 112 56","aria-hidden":!0,focusable:"false",children:[r.jsx("rect",{className:"tp-canvas",width:"112",height:"56"}),r.jsx("rect",{className:"tp-surface",width:"112",height:"7"}),r.jsx("rect",{className:"tp-rule",y:"7",width:"112",height:"1"}),r.jsx("rect",{className:"tp-surface",y:"8",width:"25",height:"48"}),r.jsx("rect",{className:"tp-rule",x:"25",y:"8",width:"1",height:"48"}),r.jsx("rect",{className:"tp-card",x:"36.5",y:"27.5",width:"28",height:"14",rx:"2.5"}),r.jsx("rect",{className:"tp-tag",x:"39.5",y:"25.5",width:"13",height:"4",rx:"2"}),r.jsx("rect",{className:"tp-card",x:"76.5",y:"14.5",width:"29",height:"20",rx:"2.5"}),r.jsx("rect",{className:"tp-rule",x:"81",y:"23",width:"20",height:"2",rx:"1"}),r.jsx("rect",{className:"tp-accent",x:"81",y:"23",width:"12",height:"2",rx:"1"})]})})}function Rye({theme:e,onTheme:t,singleKeys:n}){const s=a=>{var d,h;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(a.key))return;a.preventDefault();const o=(d=a.target.closest("[data-theme-choice]"))==null?void 0:d.dataset.themeChoice,c=(Zr.indexOf(o??e)+(a.key==="ArrowLeft"||a.key==="ArrowUp"?-1:1)+Zr.length)%Zr.length;t(Zr[c]),(h=a.currentTarget.querySelectorAll('[role="radio"]')[c])==null||h.focus()};return r.jsx(tn,{id:"appearance-theme-caption",title:"Theme",list:!1,settingId:"theme",aside:n&&r.jsx("kbd",{className:"settings-key","aria-hidden":!0,title:"Press T anywhere to switch themes",children:"T"}),children:r.jsx("div",{className:"appearance-themes",role:"radiogroup","aria-labelledby":"appearance-theme-caption","aria-keyshortcuts":n?"T":void 0,onKeyDown:s,children:Zr.map(a=>r.jsxs("button",{type:"button",className:"appearance-theme",role:"radio","data-theme-choice":a,"data-setting":`theme-${a}`,"aria-checked":e===a,tabIndex:e===a?0:-1,onClick:()=>t(a),children:[r.jsx(Tye,{theme:a}),r.jsxs("span",{className:"appearance-theme-name",children:[Zu[a].name,r.jsx("svg",{className:"appearance-check",viewBox:"0 0 12 12","aria-hidden":!0,focusable:"false",children:r.jsx("path",{d:"M2.5 6.4 4.9 8.7 9.5 3.6"})})]})]},a))})})}const Aye=[["smallest","Smallest","11 px"],["smaller","Smaller","12 px"],["default","Default","13 px"],["larger","Larger","15 px"],["largest","Largest","17 px"]],Mye=[["tightest","Tightest","30%"],["tighter","Tighter","50%"],["compact","Compact","70%"],["default","Default","100%"],["comfortable","Comfortable","140%"]];function uI(){return r.jsx("svg",{className:"reading-selected-mark",viewBox:"0 0 12 12",width:"12",height:"12","aria-hidden":"true",children:r.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 $ye({textSize:e,density:t,onTextSize:n,onDensity:s}){const a=e!=="default"||t!=="default";return r.jsx("button",{type:"button",className:"btn",disabled:!a,onClick:()=>{n("default"),s("default")},children:"Reset to defaults"})}function Lye({textSize:e,density:t,onTextSize:n,onDensity:s}){return r.jsxs(r.Fragment,{children:[r.jsxs("fieldset",{className:"reading-group",children:[r.jsx("legend",{children:"Text size"}),r.jsx("p",{id:"reading-size-help",children:"Adjust interface text without changing your browser zoom."}),r.jsx("div",{className:"reading-options reading-segmented","aria-describedby":"reading-size-help","data-setting":"text-size",style:{"--reading-count":FE.length,"--reading-selected":FE.indexOf(e)},children:Aye.map(([a,o,i])=>r.jsxs("label",{className:"reading-choice","data-size":a,children:[r.jsx("input",{type:"radio",name:"text-size","aria-label":`${o} ${i}`,value:a,checked:e===a,onChange:()=>n(a)}),r.jsx("span",{className:"reading-type-sample","aria-hidden":"true",children:"Aa"}),r.jsxs("span",{className:"reading-label",children:[r.jsx("strong",{children:o}),r.jsx("small",{children:i})]}),r.jsx(uI,{})]},a))})]}),r.jsxs("fieldset",{className:"reading-group",children:[r.jsx("legend",{children:"Density"}),r.jsx("p",{id:"reading-density-help",children:"Choose the spacing in lists, panels and controls. Text size stays the same."}),r.jsx("div",{className:"reading-options reading-segmented","aria-describedby":"reading-density-help","data-setting":"density",style:{"--reading-count":BE.length,"--reading-selected":BE.indexOf(t)},children:Mye.map(([a,o,i])=>r.jsxs("label",{className:"reading-choice",children:[r.jsx("input",{type:"radio",name:"density","aria-label":`${o} ${i} spacing`,value:a,checked:t===a,onChange:()=>s(a)}),r.jsxs("span",{className:"reading-density-sample","data-density":a,"aria-hidden":"true",children:[r.jsx("i",{}),r.jsx("i",{}),r.jsx("i",{})]}),r.jsxs("span",{className:"reading-label",children:[r.jsx("strong",{children:o}),r.jsx("small",{children:i})]}),r.jsx(uI,{})]},a))})]}),r.jsxs(tn,{id:"reading-preview-title",title:"Preview",children:[r.jsxs("div",{className:"reading-preview-row",children:[r.jsxs("div",{children:[r.jsx("strong",{children:"Frontend session"}),r.jsx("span",{children:"Waiting for your review"})]}),r.jsx("span",{className:"reading-preview-time",children:"4m"})]}),r.jsxs("div",{className:"reading-preview-row",children:[r.jsxs("div",{children:[r.jsx("strong",{children:"API integration"}),r.jsx("span",{children:"Working · 3 tool calls"})]}),r.jsx("span",{className:"reading-preview-time",children:"12m"})]})]}),r.jsx("p",{className:"settings-foot",children:"Preferences stay in this browser when storage is available. Default restores the existing ccdeck appearance."})]})}const Iye="AGPL-3.0-only",Oye="GNU Affero General Public License, version 3 only.",Pye="https://github.com/BarganConstantin/ccdeck",Dye="What changed in each release, newest first.",Fye="Tell the people who make ccdeck what works and what does not.";function Bye(e){return`This page is from v${e}. The deck has most likely been updated since this tab opened, and a reload picks up the new version.`}function qye(e,t){return Za(e)&&Za(t)&&Qo(e,t)<0}function Uye(e,t){return e?{kind:"ready",to:e.version,name:"Update ready",note:`${Rt} v${e.version} is downloaded and verified.`}:t?t.kind==="restart"?{kind:"notice",name:"Update installed",note:`v${t.to} is installed — this deck still runs v${t.from}.`}:{kind:"notice",name:"Update available",note:`${Rt} v${t.to} is out — you are on v${t.from}.`}:null}function Wye({version:e,notice:t,readyAppUpdate:n,updateRestarting:s,updateFailure:a,onUpdateRestart:o,doors:i,bundle:c="3.44.0"}){const d=(e==null?void 0:e.running)??c,h=Uye(n,t);return r.jsxs(r.Fragment,{children:[r.jsxs(tn,{id:"settings-about-caption",title:Rt,children:[r.jsx(pt,{as:"div",settingId:"version",name:"Version",note:qye(c,e==null?void 0:e.running)?Bye(c):void 0,control:r.jsx("span",{className:"settings-read",children:d})}),h&&r.jsx(Hye,{offer:h,restarting:s,failure:a,onRestart:o,onUpdate:i.update}),r.jsx(pt,{as:"div",settingId:"whats-new",name:"What's new",note:Dye,control:r.jsx("button",{type:"button",className:"btn","aria-haspopup":"dialog","aria-label":"Open What's new",onClick:i.whatsNew,children:"Open"})}),r.jsx(pt,{as:"div",settingId:"licence",name:"Licence",note:Oye,control:r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"settings-read",children:Iye}),r.jsxs("a",{className:"settings-link",href:Pye,target:"_blank",rel:"noreferrer",children:["Source",r.jsx("span",{className:"vis-hidden",children:": the source code, opens in your browser"})]})]})})]}),r.jsxs(tn,{id:"settings-about-help-caption",title:"Tour and feedback",children:[r.jsx(pt,{as:"div",settingId:"tour",name:"Take the tour",note:d1,control:r.jsx("button",{type:"button",className:"btn","aria-haspopup":"dialog","aria-label":"Start the tour",onClick:i.tour,children:"Start"})}),r.jsx(pt,{as:"div",settingId:"feedback",name:"Send feedback",note:Fye,control:r.jsx("button",{type:"button",className:"btn","aria-haspopup":"dialog","aria-label":"Open the feedback dialog",onClick:i.feedback,children:"Open"})})]})]})}function Hye({offer:e,restarting:t,failure:n,onRestart:s,onUpdate:a}){if(e.kind==="notice")return r.jsx(pt,{as:"div",name:e.name,note:e.note,control:r.jsx("button",{type:"button",className:"btn","aria-haspopup":"dialog",onClick:a,children:"Update…"})});const o=i5(e.to,t),i=n&&n.version===e.to?l5(n.failure,n.version):"";return r.jsx(pt,{as:"div",name:e.name,note:e.note,control:r.jsx("button",{type:"button",className:"btn",onClick:()=>s(e.to),"aria-busy":t||void 0,"aria-label":o.label,title:o.title,children:o.text}),children:r.jsx("span",{className:"settings-row-said",role:"status",children:i})})}const zye="Update when idle",Vye="When nothing has been running for 30 seconds, the deck restarts into a newer version. While you are looking at it, that is one already installed, and only while its notice is up; while nobody is, it installs the new version first. Off, it updates only when you press.",Gye=`${L5} It hears of no new release from npm, and restarts only into a version installed some other way, once nothing has been running for 30 seconds.`,Kye="This deck cannot restart itself (it runs without its supervisor, with --no-persist, or cannot write its event log), so nothing updates on its own here. Your choice is saved for the next start.",Yye="The desktop app keeps itself up to date. It installs a new version once it has been left alone and no agent has been working for a minute, or after waiting a day for that.";function Xye(e,t){return t&&(e!=null&&e.checkDisabled)?"app":(e==null?void 0:e.canRestart)===!1?"no-restart":e!=null&&e.checkDisabled?"checks-off":"plain"}const Zye={plain:Vye,"checks-off":Gye,"no-restart":Kye};function Jye({autoRestart:e,onToggleAutoRestart:t,version:n,inApp:s=Ja()}){const a=Xye(n,s);return r.jsx(tn,{id:"settings-updates-caption",title:"Updates",children:a==="app"?r.jsx(pt,{as:"div",settingId:"auto-update",name:"Updates",note:Yye}):r.jsx(pt,{settingId:"auto-update",name:zye,nameId:"settings-auto-update-label",note:Zye[a],noteId:"settings-auto-update-note",control:r.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":e,"aria-labelledby":"settings-auto-update-label","aria-describedby":"settings-auto-update-note",onClick:t,children:r.jsx("span",{className:"switch-knob"})})})})}function Qye({character:e,onCharacter:t}){const n=y.useRef([]);function s(a,o){var c;const i=mp(a,o,Vh.length,"vertical");i.kind==="select"&&(a.preventDefault(),t(Vh[i.index].id),(c=n.current[i.index])==null||c.focus())}return r.jsx("div",{className:"character-picker",role:"radiogroup","aria-label":"Choose character","data-setting":"character-choice",children:Vh.map((a,o)=>r.jsxs("button",{type:"button",className:"character-choice",role:"radio","aria-checked":e===a.id,tabIndex:e===a.id?0:-1,ref:i=>{n.current[o]=i},onClick:()=>t(a.id),onKeyDown:i=>s(i,o),children:[r.jsx("span",{className:"character-preview",children:r.jsx(AP,{character:a.id,act:null,facing:"right"})}),r.jsx("span",{children:a.name}),r.jsx("svg",{className:"character-check",viewBox:"0 0 16 16","aria-hidden":!0,focusable:"false",children:r.jsx("path",{d:"m3 8 3 3 7-7",fill:"none",stroke:"currentColor",strokeWidth:"1.5"})})]},a.id))})}const ewe="Stands beside the minimap. Press it to play the radio.";function twe({characterEnabled:e,onToggleCharacter:t,character:n="deck",onCharacter:s}){return r.jsxs(tn,{id:"appearance-character-caption",title:"Character",list:!1,children:[r.jsx("div",{className:"settings-list",children:r.jsx(pt,{settingId:"character",name:"Show the character",nameId:"appearance-character-label",note:ewe,noteId:"appearance-character-note",control:r.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":e,"aria-labelledby":"appearance-character-label","aria-describedby":"appearance-character-note",onClick:t,children:r.jsx("span",{className:"switch-knob"})})})}),r.jsx(Qye,{character:n,onCharacter:s})]})}const dI="settings-search-field",z5="settings-search-results",m1=e=>`settings-result-${e}`;function nwe({inputRef:e,query:t,onQuery:n,results:s,active:a,onActive:o,onOpen:i}){const c=t.trim()!=="",d=c&&s.length>0,h=f=>{if(f.nativeEvent.isComposing)return;const p=Hge(f.key,t,c?s.length:0,a);p.kind!=="pass"&&(f.preventDefault(),p.kind==="move"?o(p.index):p.kind==="open"?i(s[p.index]):(f.stopPropagation(),n("")))};return r.jsxs("div",{className:"settings-search",children:[r.jsx("label",{className:"vis-hidden",htmlFor:dI,children:"Search settings"}),r.jsxs("svg",{className:"settings-search-glyph",width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round","aria-hidden":!0,focusable:"false",children:[r.jsx("circle",{cx:"6",cy:"6",r:"4.2"}),r.jsx("path",{d:"m9.2 9.2 3.3 3.3"})]}),r.jsx("input",{ref:e,id:dI,type:"search",className:"settings-filter-field settings-search-field",placeholder:"Search settings",autoComplete:"off",spellCheck:!1,role:"combobox","aria-autocomplete":"list","aria-expanded":d,"aria-controls":d?z5:void 0,"aria-activedescendant":d?m1(Math.min(a,s.length-1)):void 0,"aria-keyshortcuts":"Control+F Meta+F",value:t,onChange:f=>n(f.target.value),onKeyDown:h})]})}function swe({query:e,results:t,active:n,onOpen:s}){const a=W5(t.length,e);return y.useEffect(()=>{var o,i;(i=(o=document.getElementById(m1(n)))==null?void 0:o.scrollIntoView)==null||i.call(o,{block:"nearest"})},[n]),r.jsxs("div",{className:"settings-pane",role:"region","aria-labelledby":"settings-search-title",children:[r.jsx("div",{className:"settings-pane-head",children:r.jsxs("div",{className:"settings-pane-heading",children:[r.jsx("h2",{className:"settings-pane-title",id:"settings-search-title",children:"Search"}),r.jsx("p",{className:"settings-pane-note","aria-hidden":!0,children:a})]})}),t.length>0&&r.jsx("div",{className:"settings-group",children:r.jsx("div",{className:"settings-list",id:z5,role:"listbox","aria-label":"Matching settings",children:t.map((o,i)=>r.jsxs("button",{type:"button",role:"option",id:m1(i),className:"settings-result",tabIndex:-1,"aria-selected":i===n,"aria-label":Bge(o),"data-highlighted":i===n,onMouseDown:c=>c.preventDefault(),onClick:()=>s(o),children:[r.jsx(H5,{section:o.section}),r.jsxs("span",{className:"settings-result-text",children:[r.jsx("span",{className:"settings-result-name",children:o.label}),r.jsx("span",{className:"settings-result-place",children:U5(o)})]})]},o.id))})})]})}function rwe({query:e,count:t}){return r.jsx("p",{className:"vis-hidden",role:"status",children:e.trim()?W5(t,e):""})}const awe=1500,owe=3e3,iwe=e=>e.checkVisibility?e.checkVisibility():e.getClientRects().length>0;function lwe(e){if(e.matches(of)&&!e.disabled)return e;const t=e.querySelector('input[type="radio"]:checked, [role="radio"][aria-checked="true"]');if(t)return t;const n=Array.from(e.querySelectorAll(of)).filter(s=>z3({disabled:s.disabled,tabIndex:s.tabIndex,rendered:iwe(s)}));return n.find(s=>s.closest(".settings-list")!=null)??n[0]??null}function cwe(e,t,n){const[s,a]=y.useState(null),o=y.useRef(void 0),i=y.useRef(null);return y.useEffect(()=>()=>{var c;window.clearTimeout(o.current),(c=i.current)==null||c.removeAttribute("data-jumped")},[]),y.useEffect(()=>{const c=e.current;if(!s||!t||!c)return;const d=()=>c.querySelector(`[data-setting="${CSS.escape(s)}"]`),h=w=>{var v,b;a(null);const j=w.offsetHeight>c.clientHeight-48;w.scrollIntoView({block:j?"start":"center"}),(v=lwe(w))==null||v.focus({preventScroll:!0}),window.clearTimeout(o.current),(b=i.current)==null||b.removeAttribute("data-jumped"),w.offsetWidth,w.setAttribute("data-jumped",""),i.current=w,o.current=window.setTimeout(()=>{w.removeAttribute("data-jumped"),i.current===w&&(i.current=null)},awe)},f=d();if(f){h(f);return}const p=new MutationObserver(()=>{const w=d();w&&(p.disconnect(),window.clearTimeout(m),h(w))});p.observe(c,{childList:!0,subtree:!0});const m=window.setTimeout(()=>{p.disconnect(),a(null)},owe);return()=>{p.disconnect(),window.clearTimeout(m)}},[e,s,t,n]),a}function uwe({section:e,onSection:t,onClose:n,providers:s,sound:a,tones:o,customTones:i,notify:c,appearance:d,versionCheck:h,desktopUpdate:f,restart:p,doors:m}){const w=y.useRef(null),j=mt(n,{focusRef:w}),v=yt(n),b=y.useRef([]),k=Jde(e),[N,S]=y.useState(""),[_,E]=y.useState(0),I=y.useRef(null),A=y.useRef(null),O=N.trim()!=="",L=y.useMemo(()=>Wge(N,Fge(s.claude)),[N,s.claude]),U=cwe(A,!O,e),P=je=>{S(je),E(0)},T=je=>{P(""),t(je)},B=je=>{P(""),t(je.section),q5(je)||U(je.id)};y.useEffect(()=>{const je=Te=>{var tt,ht;if(!rhe(Te))return;const $e=j.current,Ge=Te.target;!$e||!(Ge===document.body||Ge===document.documentElement||Ge&&$e.contains(Ge))||(Te.preventDefault(),(tt=I.current)==null||tt.focus(),(ht=I.current)==null||ht.select())};return window.addEventListener("keydown",je),()=>window.removeEventListener("keydown",je)},[j]),y.useEffect(()=>{var je,Te,$e,Ge;Qde((je=document.activeElement)==null?void 0:je.id,e)&&((Te=w.current)==null||Te.focus()),(Ge=($e=w.current)==null?void 0:$e.scrollIntoView)==null||Ge.call($e,{block:"nearest",inline:"nearest"})},[e]);const{theme:M,setTheme:q,characterEnabled:$,setCharacterEnabled:K,character:G,setCharacter:z}=d,W=Pn(),D=je=>{var $e;const Te=mp(je,k,Fa.length,"vertical");Te.kind!=="pass"&&(je.preventDefault(),P(""),t(Fa[Te.index].id),($e=b.current[Te.index])==null||$e.focus())},H=je=>{var Ge;if(je.key===" "){je.stopPropagation();return}if(yP(je.key,W))return;const Te=je.target;if(Bo(Te)||Te.tagName==="SELECT"||je.key!=="t"&&je.key!=="T"||je.ctrlKey||je.metaKey||je.altKey)return;je.preventDefault(),je.stopPropagation();const $e=a1(Te.dataset.themeChoice??M);q(a1),Te.getAttribute("role")==="radio"&&((Ge=je.currentTarget.querySelector(`[role="radio"][data-theme-choice="${$e}"]`))==null||Ge.focus())},{soundOn:ee,toggleSound:F}=a,{tonePrefs:Y,previewTone:X,changeTone:Z}=o,{customSelections:J,customAssets:ne,clearCustomOnly:ce,selectCustomTone:he,importNotificationAudio:le,createNotificationVoice:re,renameCustomAsset:ae,deleteCustomAsset:de,previewCustomAsset:Se}=i,{notifyPermission:pe,notifyOn:me,notifyVetoed:be,toggleNotify:Ce,notifySupported:ye,askForNotifications:Pe,accountNotify:Oe,toggleAccountNotify:We}=c,Re=(()=>{switch(e){case"radar":return r.jsx(_ye,{onOpen:m.radar});case"appearance":return r.jsxs(r.Fragment,{children:[r.jsx(Rye,{theme:M,onTheme:q,singleKeys:W}),r.jsx(twe,{characterEnabled:$,character:G,onCharacter:z,onToggleCharacter:()=>K(je=>!je)})]});case"reading":return r.jsx(Lye,{textSize:d.textSize,density:d.density,onTextSize:d.setTextSize,onDensity:d.setDensity});case"keyboard":return r.jsx(aye,{singleKeys:W,onToggleSingleKeys:()=>NG(!W)});case"notifications":return r.jsx(oye,{notifyOn:me,onToggleNotify:Ce,notifyVetoed:be,notifyPermission:ye?pe:"unsupported",onAskNotify:Pe,accountNotify:Oe,onToggleAccountNotify:We});case"sounds":return r.jsx(bye,{soundOn:ee===!0,onToggleSound:F,prefs:Y,claudeHere:s.claude,onLevel:(je,Te)=>Z(je,{level:Te}),onFigure:(je,Te)=>Z(je,{figure:Te}),onPreview:je=>X(je),customAssets:ne,customSelections:J,onBuiltInSelected:ce,onCustomSelected:he,onImportCustom:le,onCreateVoice:re,onRenameCustom:ae,onPreviewCustom:Se,onDeleteCustom:de});case"data":return r.jsx(Eye,{});case"about":return r.jsx(Wye,{version:h.version,notice:h.notice,readyAppUpdate:f.readyAppUpdate,updateRestarting:f.desktopUpdateRestarting,updateFailure:f.desktopUpdateFailure,onUpdateRestart:je=>{f.askDesktopUpdateRestart(je)},doors:m});default:return r.jsxs(r.Fragment,{children:[r.jsx(Gge,{}),r.jsx(oI,{provider:"Codex"}),s.claude&&r.jsx(oI,{provider:"Claude"}),r.jsx(Jye,{autoRestart:p.autoRestart,onToggleAutoRestart:p.toggleAutoRestart,version:h.version}),r.jsx(eye,{claudeHere:s.claude,singleKeys:W,doors:m})]})}})(),st=e==="reading"?r.jsx($ye,{textSize:d.textSize,density:d.density,onTextSize:d.setTextSize,onDensity:d.setDensity}):null;return r.jsx("div",{className:"modal-backdrop",...v,role:"presentation",children:r.jsxs("div",{ref:j,id:"settings",className:"modal settings-modal",role:"dialog","aria-modal":"true","aria-labelledby":"settings-title",onClick:je=>je.stopPropagation(),onKeyDown:H,children:[r.jsxs("header",{className:"modal-head",children:[r.jsx("div",{className:"modal-title",children:r.jsx("span",{id:"settings-title",className:"modal-tool-name",children:"Settings"})}),r.jsx("div",{className:"modal-actions",children:r.jsx("button",{type:"button",className:"glyph-btn",onClick:n,"aria-label":"Close settings",title:"Close (Esc)",children:"×"})})]}),r.jsxs("div",{className:"settings-body",children:[r.jsxs("div",{className:"settings-side",children:[r.jsx(nwe,{inputRef:I,query:N,onQuery:P,results:L,active:_,onActive:E,onOpen:B}),r.jsx(rwe,{query:N,count:L.length}),r.jsx("div",{className:"settings-nav",role:"tablist","aria-label":"Settings sections","aria-orientation":"vertical",onKeyDown:D,children:Fa.map((je,Te)=>r.jsxs("button",{ref:$e=>{b.current[Te]=$e,je.id===e&&(w.current=$e)},type:"button",role:"tab",id:`settings-tab-${je.id}`,className:"settings-tab","aria-selected":je.id===e,"aria-controls":"settings-pane",tabIndex:je.id===e?0:-1,onClick:()=>T(je.id),children:[r.jsx(H5,{section:je.id}),r.jsx("span",{className:"settings-tab-label",children:je.label})]},je.id))})]}),r.jsxs("div",{ref:A,className:"settings-pane",role:"tabpanel",id:"settings-pane","aria-labelledby":`settings-tab-${e}`,hidden:O||void 0,children:[r.jsxs("div",{className:"settings-pane-head",children:[r.jsxs("div",{className:"settings-pane-heading",children:[r.jsx("h2",{className:"settings-pane-title",children:Fa[k].label}),r.jsx("p",{className:"settings-pane-note",children:Fa[k].note})]}),st]}),Re]},e),O&&r.jsx(swe,{query:N,results:L,active:_,onOpen:B})]})]})})}function dwe({tool:e,onClose:t}){const n=mt(t),s=yt(t),a=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=Qz(e.name,i,c);return{input:f.input.map((p,m)=>r.jsx(hI,{block:p},m)),response:f.response.map((p,m)=>r.jsx(hI,{block:p},m)),copyInput:AC(e.name,"input",i),copyResponse:AC(e.name,"response",c)}},[e.name,i,c]);return r.jsx("div",{className:"modal-backdrop",...s,role:"presentation",children:r.jsxs("div",{ref:n,className:"modal",onClick:f=>f.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"tool-modal-title",children:[r.jsxs("header",{className:"modal-head",children:[r.jsxs("div",{className:"modal-title",children:[r.jsx("span",{className:`status-dot ${a}`,"aria-hidden":!0}),r.jsx("span",{id:"tool-modal-title",className:"modal-tool-name",children:e.name}),r.jsxs("span",{className:"modal-tool-id",title:e.id,children:[e.id.slice(0,12),"…"]})]}),r.jsxs("div",{className:"modal-actions",children:[r.jsx("span",{className:"modal-dur",children:U3(e,"in-flight…")}),r.jsx("button",{className:"glyph-btn",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),r.jsxs("section",{className:"modal-body",children:[d&&r.jsx("div",{className:"modal-section",children:r.jsx("p",{className:"modal-note",children:"Full payloads for this call were released to keep memory bounded — only the previews below are still held."})}),r.jsxs("div",{className:"modal-section",children:[r.jsxs("div",{className:"tm-head",children:[r.jsx("h4",{children:"Input"}),r.jsx(fI,{text:h.copyInput,what:"input"})]}),h.input]}),r.jsxs("div",{className:"modal-section",children:[r.jsxs("div",{className:"tm-head",children:[r.jsxs("h4",{children:["Response ",a==="err"&&r.jsx("span",{className:"err-tag",children:"error"})]}),e.endedAt!=null&&r.jsx(fI,{text:h.copyResponse,what:"response"})]}),e.endedAt==null?r.jsx("pre",{children:"(waiting…)"}):h.response]})]})]})})}const hwe={del:"tm-del",add:"tm-add",ctx:"tm-ctx"};function hI({block:e}){const[t,n]=y.useState(!1);if(e.inline)return r.jsxs("p",{className:"tm-inline",children:[e.label&&r.jsx("span",{className:"tm-label",children:e.label}),r.jsx("code",{children:e.text})]});const s=y.useMemo(()=>Vz(e),[e]),{shown:a}=m3(s,t),o=Gz(s,t);return r.jsxs("div",{className:"tm-block",children:[e.label&&r.jsx("span",{className:"tm-label",children:e.label}),r.jsx("pre",{className:e.err?"tm-err":void 0,children:e.lines?a.map((i,c)=>r.jsxs("span",{className:i.tone?hwe[i.tone]:void 0,children:[i.text,c<a.length-1?`
|
|
312
|
+
`:""]},c)):a.map(i=>i.text).join(`
|
|
313
|
+
`)}),o&&r.jsx("button",{type:"button",className:"btn tm-more","aria-expanded":o.expanded,onClick:()=>n(i=>!i),children:o.label})]})}function fI({text:e,what:t}){const[n,s]=y.useState(!1),a=y.useRef(!0);return y.useEffect(()=>()=>{a.current=!1},[]),r.jsx("button",{type:"button",className:"btn tm-copy",disabled:!e,"aria-label":n?`The ${t} was copied`:`Copy the ${t}`,onClick:()=>void eo(e).then(o=>{!o||!a.current||(s(!0),window.setTimeout(()=>{a.current&&s(!1)},1600))}),children:n?"copied":"copy"})}const fwe=dN(()=>Du(()=>import("./UsageHistoryModal-Du0ZkIJ1.js"),[]),"Usage history"),pwe=dN(()=>Du(()=>import("./BrowserWatchModal-DMIUygWz.js"),[]),"Browser Watch"),mwe=dN(()=>Du(()=>import("./TrafficRadar-Ch0LVdSl.js"),[]),"Telemetry Radar");function gwe({dialogs:e,welcome:t,desktopUpdate:n,versionCheck:s,restart:a,upgrade:o,lanPairs:i,attention:c,clearFlow:d,watchBadge:h,announcements:f,appearance:p,providers:m,stateRef:w,agentCount:j,menus:v,sound:b,tones:k,customTones:N,notify:S,panelDoors:_}){const{openedTool:E,setOpenedToolKey:I,usageHistoryOpen:A,setUsageHistoryOpen:O,browserWatchOpen:L,setBrowserWatchOpen:U,contextAgent:P,setContextFor:T,summaryFor:B,setSummaryFor:M,keyHelpOpen:q,setKeyHelpOpen:$,feedbackOpen:K,setFeedbackOpen:G,feedbackPrefill:z,setFeedbackPrefill:W,openFeedback:D}=e,{trafficRadarOpen:H,setTrafficRadarOpen:ee}=e,{tourOpen:F,openTour:Y,closeTour:X,releaseNotes:Z,closeReleaseNotes:J,chipVersion:ne,openReleaseNotes:ce}=t,{desktopUpdateRestarting:he,desktopUpdateFailure:le,readyAppUpdate:re,askDesktopUpdateRestart:ae}=n,{version:de,showNotice:Se}=s,{askRestart:pe}=a,{clearConfirmOpen:me,setClearConfirmOpen:be,requestClear:Ce}=d,{setWatchOn:ye,markWatchSeen:Pe}=h,{setWatchSaid:Oe}=f,{palette:We}=p,{settingsOpen:Re,settingsSection:st,showSection:je,closeSettings:Te,openSettings:$e}=v;return r.jsxs(r.Fragment,{children:[E&&r.jsx(dwe,{tool:E,onClose:()=>I(null)}),A&&r.jsx(y.Suspense,{fallback:null,children:r.jsx(fwe,{providers:m,onClose:()=>O(!1)})}),L&&r.jsx(y.Suspense,{fallback:null,children:r.jsx(pwe,{onClose:()=>U(!1),onSeen:Ge=>{Oe(""),Pe(Ge)},onWatching:ye,palette:We})}),P&&r.jsx(Y9,{agent:P,onClose:()=>T(null)}),H&&r.jsx(y.Suspense,{fallback:null,children:r.jsx(mwe,{sessions:[...w.current.agents.values()].filter(Ge=>Ge.kind==="root"&&Ge.provider!=="codex").map(Ge=>({id:Ge.sessionId,label:sp(Ge.sessionName,Ge.sessionTitle).face??Ge.cwdBasename??Ge.label,project:Ge.cwdBasename??Ge.label,workspace:Ge.cwd})),onClose:()=>ee(!1)})}),K&&r.jsx(S5,{initialKind:z==null?void 0:z.initialKind,initialBody:z==null?void 0:z.initialBody,onClose:()=>{G(!1),W(null)}}),B&&r.jsx(bge,{state:w.current,sessionId:B,onClose:()=>M(null)}),Re&&r.jsx(uwe,{section:st,onSection:je,onClose:Te,providers:m,sound:b,tones:k,customTones:N,notify:S,appearance:p,versionCheck:s,desktopUpdate:n,restart:a,doors:{whatsNew:Ma(Te,ce),update:Ma(Te,()=>{ce(),Se()}),tour:Ma(Te,Y),feedback:Ma(Te,()=>D()),accounts:Ma(Te,_.accounts),localNetwork:Ma(Te,_.localNetwork),browserWatch:Ma(Te,()=>U(!0)),radar:Ma(Te,()=>ee(!0))}}),Z&&r.jsx(vge,{entries:Z.entries,since:Z.since,firstRun:Z.firstRun,running:ne,onClose:J,onTour:()=>{J(),Y()},updateVersion:re==null?void 0:re.version,updateBusy:he,updateFailure:le&&(!re||re.version===le.version)?l5(le.failure,le.version):void 0,onUpdateRestart:re?()=>{ae(re.version)}:void 0,onRestart:!re&&(de!=null&&de.canRestart)?()=>{J(),pe()}:void 0,updateCheck:{versionCheck:s,upgrade:o,restart:a,desktopUpdate:n,running:ne,onHandOff:J}}),r.jsx(ywe,{lanPairs:i,attention:c}),q&&r.jsx(Nme,{onClose:()=>$(!1),onTour:()=>{$(!1),Y()},onSettings:()=>{$(!1),$e("keyboard")}}),F&&r.jsx(Z4,{title:"What the deck shows you",steps:ise,onClose:X}),me&&r.jsx(Gfe,{agentCount:j,onConfirm:()=>Ce("confirmation"),onCancel:()=>be(!1)})]})}function ywe({lanPairs:e,attention:t}){const n=Ome(e);return r.jsxs(r.Fragment,{children:[n,r.jsx(Bme,{...t,pairing:n!=null})]})}const wwe=10,V5=500,G5=4e3,xwe=[/ResizeObserver loop/i,/^Script error\.?$/i],pI=/^(?:[a-z][\w+.-]*-extension|webkit-masked-url):\/\//i,vwe=/[a-z][\w+.-]*:\/\/[^\s()]+/gi;function bwe(e,t){const n=typeof e=="string"?e.split(`
|
|
314
|
+
`):[],s=n.some(o=>/^\s*at\s/.test(o)),a=n.flatMap(o=>!s||/^\s*at\s/.test(o)?o.match(vwe)??[]:[]);return a.length?a.every(o=>pI.test(o)):typeof t=="string"&&pI.test(t)}const qf=String.raw`[^\s\\/:'"\`<>|?*;,]`,kwe=String.raw`${qf}(?:[^\\/\r\n:'"\`<>|?*;,]*${qf})?[\\/]`,jwe=String.raw`[^\s\\/:'"\`<>|?*;,()]+`,Ic=String.raw`(?:${kwe})*(?:${jwe})?`,Nwe=String.raw`(?<![\w.~/\\\]-]|<(?:deck|host)>)(?:file://(?:/[A-Za-z]:)?[^\s:'"\`<>()]*|~[\\/]${Ic}|[A-Za-z]:[\\/]${Ic}|\\\\(?:[?.]\\)?(?:[A-Za-z]:\\)?${Ic}|/(?=${qf})${Ic}|(?<!:)//(?=${qf})${Ic})`,Swe=String.raw`(?<![\w-])(?:[A-Za-z]--|-[A-Za-z0-9][\w.]*-)[\w.-]*`,_we=new Set([".claude",".codex"]);function Cwe(e){if(!e.startsWith("~"))return"<path>";const t=e[1],[n,...s]=e.slice(2).split(/[\\/]/);return n?_we.has(n)?s.join("")?`~${t}${n}${t}<path>`:e:`~${t}<path>`:e}const Ewe=String.raw`\b(https?|wss?)://[^\s/?#\\'"\x60<>(),;]+(?=(/assets/)?)`;function Twe(e,t,n){return n?"<deck>":`${t}://<host>`}const mI=String.raw`(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)`,K5=String.raw`${mI}(?:\.${mI}){3}`,Bk=String.raw`[0-9A-Fa-f]{1,4}`,gI=String.raw`(?=[0-9A-Fa-f:]*\d)(?=[0-9A-Fa-f:]*::|(?:${Bk}:){7})(?:(?:${Bk})?:)+(?:${K5}|${Bk})?`,yI=String.raw`%[\w-]+(?:\.[\w-]+)*`,wI=String.raw`(?:::1?|::ffff:(?:127(?:\.\d{1,3}){3}|0\.0\.0\.0))`,Rwe=String.raw`(?<![\w:.%-])(?:\[(?!${wI}\])${gI}(?:${yI})?\]|(?!${wI}(?::\d{1,5})?(?![\w:%]|\.\d))${gI}(?:${yI})?(?![\w%]|\.\d))|(?<![\w./-])(?!127\.|0\.0\.0\.0\b)${K5}(?![\w-]|\.\d)`,qk=String.raw`(?=[\w.-]*[A-Za-z])[A-Za-z0-9][\w-]*(?:\.[\w-]+)*`,Awe=String.raw`(?<![\w.@/\\%-])(?!localhost(?![\w-]|\.\w))(?:(?<=\b(?:(?:getaddrinfo|connect) E[A-Z_]+|ENOTFOUND|EAI_AGAIN) )${qk}|${qk}(?=:\d{1,5}(?![\w:-]|\.\w))|${qk}\.(?:local|lan|home|internal|ts\.net)(?![\w-]|\.\w))`;function xI(e){return String(e??"").replace(/\/(?:home|Users)\/[^/\s:'"]+/g,"~").replace(/[A-Za-z]:\\(?:Users|Documents and Settings)\\[^\\\r\n:'"]+/gi,"~").replace(new RegExp(Nwe,"g"),Cwe).replace(new RegExp(Swe,"g"),"<project>").replace(new RegExp(Ewe,"g"),Twe).replace(new RegExp(Rwe,"g"),"<host>").replace(new RegExp(Awe,"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,}|github_pat_[A-Za-z0-9_]{20,}|gl(?:pat|dt|rt|cbt|ptt|ft|imt|agent|oas|soat)-[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 Y5=e=>{fetch("/api/client-error",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e),keepalive:!0}).catch(()=>{})};function Mwe(e,t,n=Y5){const s=String(e??"").slice(0,V5).trim();s&&n({message:s,stack:typeof t=="string"?t.slice(0,G5):void 0})}function $we(e,t=window,n=Y5){let s=0;const a=new Set,o=(d,h,f)=>{const p=String(d??"").slice(0,V5).trim();!e()||!p||s>=wwe||a.has(p)||xwe.some(m=>m.test(p))||bwe(h,f)||(a.add(p),s++,n({message:p,stack:typeof h=="string"?h.slice(0,G5):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,d.filename)},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 Lwe=12;function Iwe(e,t){const n=[xI(e).trim()||"The deck threw an error with no message."],s=t==null?void 0:t.trim();if(s){const a=s.split(`
|
|
315
|
+
`).slice(0,Lwe).join(`
|
|
316
|
+
`);n.push("",xI(a).trim())}return n.join(`
|
|
317
|
+
`)}class Owe extends y.Component{constructor(){super(...arguments);Sg(this,"state",{error:null,componentStack:null,reportOpen:!1});Sg(this,"onKey",n=>{H3(n.key)&&Tn.dismissTop()})}static getDerivedStateFromError(n){return{error:n}}componentDidCatch(n,s){console.error("ccdeck hit a render error it could not draw past",n,s.componentStack),this.setState({componentStack:s.componentStack??null}),Mwe(n.message,n.stack),YF("offline")}componentDidUpdate(n,s){this.state.reportOpen!==s.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:s,reportOpen:a}=this.state;return n?r.jsxs("div",{className:"error-fallback",children:[r.jsxs("div",{className:"error-fallback-card",role:"alert",children:[r.jsx("p",{className:"error-fallback-title",children:"Something went wrong"}),r.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."}),r.jsxs("div",{className:"error-fallback-actions",children:[r.jsx("button",{type:"button",className:"btn primary",onClick:()=>window.location.reload(),children:"Reload"}),r.jsx("button",{type:"button",className:"btn",onClick:()=>this.setState({reportOpen:!0}),"aria-haspopup":"dialog",children:"Send report"})]})]}),a&&r.jsx(S5,{initialKind:"bug",initialBody:Iwe(n.message,s),onClose:()=>this.setState({reportOpen:!1})})]}):this.props.children}}const Pwe=1e3;function Dwe(e={}){const t=Math.max(1,Math.floor(e.limit??Pwe)),n=e.protect;let s=!1,a=[],o=new Set,i=0,c=0,d=null;return{get paused(){return s},get size(){return a.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,m=p!==null&&p!==d;m&&(d=p,c=0);const w=f!==null&&!m&&f<=c;if(f!==null&&f>c&&(c=f),!s)return!0;if(w)return!1;if(a.push(h),n!=null&&n(h)&&o.add(h),a.length>t){let j=0;if(o.size<a.length)for(;o.has(a[j]);)j++;const[v]=a.splice(j,1);o.delete(v),i++}return!1},setPaused(h){if(s=h,h)return[];const f=a;return a=[],o=new Set,i=0,f}}}function Fwe(e){const t=y.useState(()=>Dwe({protect:o=>u7(e.current,o)}))[0],[n,s]=y.useState(!1),a=y.useCallback(()=>{const o=t.paused&&t.dropped>0,i=t.setPaused(!t.paused);o&&Y7(e.current);for(const c of i)e.current=E3(e.current,c);s(t.paused)},[t,e]);return{pauseGate:t,paused:n,togglePause:a}}const g1={kind:"assumed",claude:!0,codex:!0};function Bwe(e){if(!e||typeof e!="object")return g1;const t=e.providers;if(!t||typeof t!="object")return g1;const n=t;return{kind:"reported",claude:n.claude!==!1,codex:n.codex!==!1}}function qwe(e){const[t,n]=y.useState(null),[s,a]=y.useState(g1);y.useEffect(()=>{let i=!1;return fetch("/api/health").then(c=>c.ok?c.json():null).then(c=>{i||(a(Bwe(c)),!(!c||typeof c.workspace!="string")&&n(c.workspace))}).catch(()=>{}),()=>{i=!0}},[e]);const o=Gn(s);return{workspace:t,providers:s,providersRef:o}}const X5=3*6e4,Uwe=2e4;function Wwe({fetchReport:e,visible:t,now:n,onReport:s}){let a=0,o=!0;const i=async()=>{if(!t())return;const c=await e();!o||!c||(a=n(),s(c))};return{tick:i,wake:async()=>{t()&&n()-a>=X5&&await i()},stop:()=>{o=!1}}}async function Hwe(){try{const e=await fetch("/api/provider-status",{signal:AbortSignal.timeout(Uwe)});return e.ok?await e.json():null}catch{return null}}function zwe(e){const[t,n]=y.useState(null);return y.useEffect(()=>{if(!e){n(null);return}const s=Wwe({fetchReport:Hwe,visible:()=>document.visibilityState==="visible",now:()=>Date.now(),onReport:n});s.tick();const a=window.setInterval(s.tick,X5),o=()=>{s.wake()};return document.addEventListener("visibilitychange",o),()=>{s.stop(),window.clearInterval(a),document.removeEventListener("visibilitychange",o)}},[e]),t}const Vwe={degraded:"degraded performance",partial_outage:"partial outage",major_outage:"major outage",maintenance:"maintenance"},Gwe={degraded:"degraded",partial_outage:"partial outage",major_outage:"major outage",maintenance:"maintenance"},Kwe={degraded:"degraded",partial_outage:"outage",major_outage:"outage",maintenance:"maint."},Ywe={claude:"Claude",codex:"Codex"},Xwe=new Set(["status.claude.com","status.openai.com"]),Zwe=30*6e4,Jwe=10*6e4;function Qwe(e){if(typeof e!="string")return null;try{const t=new URL(e);return t.protocol==="https:"&&Xwe.has(t.hostname)?t:null}catch{return null}}function vI(e){return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hourCycle:"h23"})}function exe(e){const t=Math.floor(e/6e4);return t<1?"just now":t<60?`${t} min ago`:`${Math.floor(t/60)} h ago`}function txe(e,t){if(!e||typeof e!="object")return null;const n=Kt(Vwe,e.state),s=Kt(Ywe,e.provider);if(!n||!s||typeof e.checkedAt!="number"||t-e.checkedAt>Zwe)return null;const a=Qwe(e.statusPageUrl);if(!a)return null;const o=Array.isArray(e.components)?e.components:[],i=e.stale===!0||t-e.checkedAt>Jwe,c=[`${s}: ${n}${e.summary?` — ${e.summary}`:""}`,o.length>0?`Affected: ${o.join(", ")}`:null,e.scope==="page"?`The page's overall status: it names none of ${s}'s components`:null,i?`Last read from ${a.hostname} at ${vI(e.checkedAt)}; this is the last thing it said`:`Reported by ${a.hostname}, checked ${exe(t-e.checkedAt)}`,"Opens the status page"],d=i?vI(e.checkedAt):null;return{provider:e.provider,state:e.state,name:s,label:`${s} · ${n}${d?` · as of ${d}`:""}`,words:n,chipWords:Kt(Gwe,e.state)??n,shortWords:Kt(Kwe,e.state)??n,asOf:d,what:e.summary||(o.length>0?o.join(", "):null),href:a.href,host:a.hostname,stale:i,detail:c.filter(Boolean).join(`
|
|
318
|
+
`)}}function nxe(e,t){return!(e!=null&&e.ok)||e.disabled||!Array.isArray(e.providers)?[]:e.providers.map(n=>txe(n,t)).filter(n=>n!==null)}function sxe(e){return e.map(t=>`${t.name}'s status page reports ${t.state.endsWith("outage")?`a ${t.words}`:t.words}.`).join(" ")}const rxe="The providers' status pages report no incident.";function axe({version:e,loadVersion:t}){var h;const[n,s]=y.useState(!1),a=((h=e==null?void 0:e.upgrade)==null?void 0:h.state)??"idle",o=Ife(e==null?void 0:e.upgrade),i=y.useRef(!1),c=y.useCallback(async()=>{if(xn(i.current||a==="running")){i.current=!0;try{await fetch("/api/upgrade",{method:"POST"})}catch{}await t(),i.current=!1}},[a,t]);y.useEffect(()=>{if(a!=="running")return;const f=window.setInterval(t,3e3);return()=>window.clearInterval(f)},[a,t]);const d=y.useCallback(async()=>{const f=e==null?void 0:e.command;!f||!await eo(f)||(s(!0),window.setTimeout(()=>s(!1),1600))},[e==null?void 0:e.command]);return{upgradeState:a,upgradeFailure:o,startUpgrade:c,copyCommand:d,cmdCopied:n}}const bI="agent-dag.browserWatch.seenMs";function oxe(e,t){return e.filter(n=>n.startMs>t)}function ixe(){const[e,t]=y.useState(()=>Number(Ze(bI))||0),[n,s]=y.useState([]),[a,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 m;!d||!(p!=null&&p.ok)||(s(p.episodes??[]),o(((m=p.settings)==null?void 0:m.enabled)===!0))}).catch(()=>{})};h();const f=setInterval(h,5*6e4);return()=>{d=!1,clearInterval(f)}},[]);const i=y.useMemo(()=>oxe(n,e).length,[n,e]),c=y.useCallback(d=>{t(d),Xe(bI,String(d))},[]);return{watchOn:a,setWatchOn:o,watchUnseen:i,markWatchSeen:c}}const Z5="agent-dag.character-enabled",J5="agent-dag.fm-volume",lxe=1,kI="agent-dag.fm-source",Pve=[{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 cxe(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 uxe(e){return e!=="0"}function dxe(){return uxe(Ze(Z5))}function hxe(e){return TD(e,lxe)}function fxe(){return hxe(Ze(J5))}const Q5=["--err","--inflight","--ok","--warn","--muted","--grid-line","--minimap-mask","--panel","--line","--accent","--text-dim","--bg"];function jI(e){const t={};for(const n of Q5)t[n]=e(n);return t}function pxe(e){return t=>e[t]??""}function mxe(e,t){return Q5.every(n=>e[n]===t[n])}function gxe(e,t){let n=null,s=0;function a(){s++,n==null||n.skipTransition(),n=null,delete e.documentElement.dataset.themeTransition}return{cancel:a,run(o){a();const i=s;let c=!1;const d=()=>{i!==s||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 NI(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}function yxe(){const[e,t]=y.useState(oZ),[n,s]=y.useState(iZ),[a,o]=y.useState(ohe),i=y.useRef(a),[c]=y.useState(()=>gxe(document,()=>{try{return window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!0}})),d=y.useCallback(k=>{const N=typeof k=="function"?k(i.current):k;N!==i.current&&(i.current=N,c.run(()=>vt.flushSync(()=>o(N))))},[c]);y.useEffect(()=>()=>c.cancel(),[c]);const[h,f]=y.useState(dxe),[p,m]=y.useState(Sge),[w,j]=y.useState(()=>jI(NI)),v=y.useMemo(()=>pxe(w),[w]),b=y.useCallback(k=>wde(k,v),[v]);return y.useEffect(()=>{document.documentElement.dataset.textSize=e,Xe(_0,e)},[e]),y.useEffect(()=>{document.documentElement.dataset.density=n,Xe(C0,n)},[n]),y.useEffect(()=>{const k=N=>{N.storageArea===mr()&&((N.key===_0||N.key===null)&&t(hj(N.newValue)),(N.key===C0||N.key===null)&&s(KP(N.newValue)))};return window.addEventListener("storage",k),()=>window.removeEventListener("storage",k)},[]),y.useLayoutEffect(()=>{document.documentElement.dataset.theme=a,document.documentElement.dataset.colorScheme=Zu[a].colorScheme,Xe(XF,a),j(k=>{const N=jI(NI);return mxe(k,N)?k:N})},[a]),y.useEffect(()=>{Xe(Z5,h?"1":"0")},[h]),y.useEffect(()=>{Xe(D5,p)},[p]),y.useEffect(()=>{const k=document.querySelector('meta[name="theme-color"]'),N=w["--panel"];k&&N&&k.setAttribute("content",N)},[w]),{textSize:e,setTextSize:t,density:n,setDensity:s,theme:a,setTheme:d,characterEnabled:h,setCharacterEnabled:f,character:p,setCharacter:m,palette:w,minimapNodeFill:b}}function wxe(e){const t=y.useRef(null),[n,s]=y.useState(!1),[a,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(QF(f.name));return Object.keys(JF).filter(h=>d.has(h))},[e.current,e.current.revision]);y.useEffect(()=>{if(i.length<=1){s(!1);return}let d=0;const h=()=>{const f=t.current;if(f&&!document.hidden){const p=f.getBoundingClientRect(),m=Array.from(document.querySelectorAll(".react-flow__node, .tool-burst")).map(j=>j.getBoundingClientRect()),w=UX(p,m,8);s(j=>j===w?j: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:a,toggleCat:c,catBarRef:t,catBarOccluded:n}}function xxe(e={enabled:()=>!0}){const t=e.ctor??(typeof window<"u"?window.AudioContext??window.webkitAudioContext??null:null);let n=null;const s=new Set,a=()=>e.enabled()?(n==null?void 0:n.state)==="running"?"ready":"locked":"off",o=()=>{var m;return(m=e.onState)==null?void 0:m.call(e,a())};function i(){var m,w;if(!(!t||(n==null?void 0:n.state)==="running"))try{n||(n=new t,(m=n.addEventListener)==null||m.call(n,"statechange",o)),(w=n.resume)==null||w.call(n).then(o,()=>{}),o()}catch{}}function c(m,w,j=w.figure){if(!n||n.state!=="running")return!1;const v=J0(m,j),b=boe(w.level,v),k=n.currentTime;for(const N of v.notes){const S=n.createOscillator(),_=n.createGain();S.type=v.type??"sine",S.frequency.value=N.hz;const E=k+N.at,I=E+N.ms/1e3;_.gain.setValueAtTime(nR,E),_.gain.exponentialRampToValueAtTime(b,E+koe),_.gain.exponentialRampToValueAtTime(nR,I),S.connect(_).connect(n.destination),S.start(E),S.stop(I+.02)}return!0}async function d(m,w){var b;if(!e.loadCustom)return"unavailable";let j;try{j=await e.loadCustom(m)}catch{return"unavailable"}if(!j)return"missing";if(j.kind==="tts"){if(typeof window>"u"||!("speechSynthesis"in window)||typeof SpeechSynthesisUtterance>"u")return"unavailable";const k=new SpeechSynthesisUtterance(j.text),N=window.speechSynthesis.getVoices();k.voice=N.find(S=>S.voiceURI===j.voiceURI)??null,k.rate=j.rate,k.pitch=j.pitch,k.volume=joe(w.level);try{return window.speechSynthesis.cancel(),window.speechSynthesis.speak(k),"played"}catch{return"unavailable"}}if(!n||n.state!=="running")return"locked";let v;try{v=await n.decodeAudioData(j.bytes.slice(0))}catch{return"broken"}try{const k=n.createBufferSource(),N=n.createGain();return k.buffer=v,N.gain.setValueAtTime(Noe(j.normalizationGain,w.level),n.currentTime),k.connect(N).connect(n.destination),s.add(k),(b=k.addEventListener)==null||b.call(k,"ended",()=>s.delete(k)),k.start(n.currentTime),"played"}catch{return"unavailable"}}function h(m,w=!1){var b,k;if(!w&&!e.enabled())return!1;const j=Aoe((b=e.prefs)==null?void 0:b.call(e),m),v=((k=e.customSelection)==null?void 0:k.call(e)[m])??null;return v&&e.loadCustom?(d(v,j).then(N=>{var S;N==="played"||N==="locked"||((N==="missing"||N==="broken")&&((S=e.onCustomFailure)==null||S.call(e,m,v)),c(m,{...j,figure:Vn},Vn))}),!0):!n||n.state!=="running"?!1:c(m,j)}function f(m,w=Jo){return d(m,{level:Cp(w),figure:Vn}),!0}function p(){try{typeof window<"u"&&"speechSynthesis"in window&&window.speechSynthesis.cancel()}catch{}for(const m of s)try{m.stop()}catch{}s.clear()}return{unlock:i,play:h,previewCustom:f,silence:p,state:a,get context(){return n}}}function vxe({chimesRef:e,soundOnRef:t,tonePrefsRef:n,customSelectionsRef:s,fallbackCustomRef:a}){y.useEffect(()=>{const o=xxe({enabled:()=>t.current===!0,prefs:()=>n.current,customSelection:()=>s.current,loadCustom:goe,onCustomFailure:(h,f)=>a.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 bxe(){const[e,t]=y.useState(fxe),[n,s]=y.useState(()=>WG(Ze(oE))),[a,o]=y.useState(()=>UG(Ze(iE))),[i,c]=y.useState(()=>HG(Ze(kI),n,cxe)),[d,h]=y.useState(()=>new Set),[f,p]=y.useState(0);y.useEffect(()=>{Xe(J5,String(e))},[e]),y.useEffect(()=>{Xe(iE,a?"1":"0")},[a]),y.useEffect(()=>{Xe(oE,JSON.stringify(n))},[n]),y.useEffect(()=>{Xe(kI,i)},[i]);const m=y.useCallback((k,N=!1)=>{s(S=>{const _=S.find(E=>E.id===k.id);return _?!N||!k.radio||!_.radio||_.url===k.url&&JSON.stringify(_.radio)===JSON.stringify(k.radio)?S:S.map(E=>E.id===k.id?{...E,url:k.url,radio:k.radio}:E):[...S,k]}),h(S=>{if(!S.has(k.id))return S;const _=new Set(S);return _.delete(k.id),_})},[]),w=y.useCallback((k,N)=>{const S=N.trim();!S||S.length>bP||s(_=>_.map(E=>E.id===k?{...E,name:S}:E))},[]),j=y.useCallback(k=>{s(N=>N.filter(S=>S.id!==k)),c(N=>zG(N,k)),h(N=>{if(!N.has(k))return N;const S=new Set(N);return S.delete(k),S})},[]),v=y.useCallback((k,N=!1)=>{const S=lE(k),_=d.has(S);k===i&&!_&&!N||(_&&h(E=>{const I=new Set(E);return I.delete(S),I}),c(k),p(E=>E+1))},[i,d]),b=y.useCallback((k,N)=>{const S=lE(k);h(_=>{if(_.has(S)===N)return _;const I=new Set(_);return N?I.add(S):I.delete(S),I})},[]);return{fmVolume:e,setFmVolume:t,fmMuted:a,setFmMuted:o,fmSource:i,customFmStations:n,unavailableFmStations:d,fmPlayRequest:f,addFmStation:m,renameFmStation:w,removeFmStation:j,pickFmSource:v,markFmStationAvailability:b}}function kxe(e){const[t,n]=y.useState(null),[s,a]=y.useState(!1),[o,i]=y.useState(null),c=y.useRef(0);y.useEffect(()=>{if(!e||!Ja())return;let j=!1;const v=c.current;return fetch("/api/desktop-update").then(b=>b.ok?b.json():null).then(b=>{if(j||c.current!==v)return;const k=qL(b);k&&n(k)}).catch(()=>{}),()=>{j=!0}},[e]);const d=Qhe(t),h=y.useRef(!1),f=y.useRef(0),p=y.useRef(0);y.useEffect(()=>()=>window.clearTimeout(f.current),[]);const m=y.useCallback(async j=>{if(!xn(h.current))return;const v=++p.current;window.clearTimeout(f.current),h.current=!0,a(!0),i(null);const b=k=>{v===p.current&&(window.clearTimeout(f.current),h.current=!1,a(!1),i({failure:k,version:j}))};try{const k=await fetch("/api/desktop-update/restart",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({version:j})});if(!k.ok)return b(tfe(await k.json().catch(()=>null)))}catch{return b("unreachable")}v===p.current&&(f.current=window.setTimeout(()=>b("timeout"),a5))},[]),w=y.useCallback(j=>{if(Ja())try{const v=qL(JSON.parse(j));v&&(c.current++,n(v),v.status!=="ready"&&(p.current++,window.clearTimeout(f.current),h.current=!1,a(!1)))}catch{}},[]);return{desktopUpdateRestarting:s,desktopUpdateFailure:o,readyAppUpdate:d,appUpdate:t,askDesktopUpdateRestart:m,onDesktopUpdateEvent:w}}const Rh="agent-dag.autoRestart",SI="agent-dag.bundleReloadedFor";function jxe({now:e,stateRef:t,version:n,notice:s,noticeOpen:a,upgradeFailure:o,paused:i}){const[c,d]=y.useState(()=>Ze(Rh)!=="0"),h=y.useRef(!1),f=y.useCallback(()=>{const U=!c;h.current=!0,wr(Rh),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 T;P!=null&&P.ok&&d(((T=P.prefs)==null?void 0:T.autoUpdate)!==!1)}).catch(()=>{})},[c]),[p,m]=y.useState(!1),[w,j]=y.useState("restart"),[v,b]=y.useState(null),k=y.useRef(!1),N=y.useRef(null),S=y.useRef(0),_=y.useRef(null),E=y.useCallback(async U=>{if(!xn(k.current))return;const P=(U==null?void 0:U.upgrade)===!0,T=(U==null?void 0:U.whenIdle)===!0;k.current=!0,N.current=o;const B=++S.current,M=()=>{j(P?"npx":"restart"),m(!0)};T||M();try{window.sessionStorage.setItem("agent-dag.restartPending",(s==null?void 0:s.to)??"")}catch{}let q=!1;try{const $=await fetch("/api/restart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(T?{upgrade:P,whenIdle:T}:{upgrade:P})});q=T&&$.status===409}catch{}if(q){k.current=!1,_.current=null;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}return}T&&M(),window.setTimeout(()=>{if(S.current===B&&k.current){k.current=!1,m(!1);try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}}},P?18e4:3e4)},[s==null?void 0:s.to,o]);y.useEffect(()=>{const U=WL(t.current.agents.values())>0,P=Bfe({enabled:c,kind:s==null?void 0:s.kind,canRestart:(n==null?void 0:n.canRestart)===!0,noticeOpen:a,visible:document.visibilityState==="visible",busy:U,idleSince:_.current,now:e});_.current=P.idleSince,P.restart&&E({whenIdle:!0})},[c,s==null?void 0:s.kind,n==null?void 0:n.canRestart,a,e,E]);const I=WL(t.current.agents.values()),A=Ffe(I,i),O=h5({enabled:c,kind:s==null?void 0:s.kind,canRestart:(n==null?void 0:n.canRestart)===!0,noticeOpen:a,visible:document.visibilityState==="visible",busy:I>0,idleSince:_.current,now:e});y.useEffect(()=>{const U=n==null?void 0:n.running;let P=null,T=null;try{P=window.sessionStorage.getItem("agent-dag.restartPending"),T=window.sessionStorage.getItem(SI)}catch{return}const B=Lfe({bundle:"3.44.0",running:U,pending:P,lastTried:T});if(B==="reload"){try{window.sessionStorage.setItem(SI,U??"")}catch{return}window.location.reload();return}if(B!=="confirm")return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}k.current=!1,m(!1),b(U??null);const M=window.setTimeout(()=>b(null),6e3);return()=>window.clearTimeout(M)},[n==null?void 0:n.running]),y.useEffect(()=>{if(p&&Ofe({asked:N.current,reported:o})){try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}k.current=!1,m(!1)}},[p,o]);const L=y.useCallback(U=>{var P,T;if(!h.current){const B=Ze(Rh)==="0";wr(Rh),B&&((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(((T=U.prefs)==null?void 0:T.autoUpdate)!==!1)}},[]);return{autoRestart:c,toggleAutoRestart:f,restarting:p,restartMode:w,restartedTo:v,askRestart:E,restartCopy:A,restartFuseMs:O,loadAutoRestartPrefs:L}}function Nxe(){const[e,t]=y.useState([]),n=y.useRef(new Set),[s,a]=y.useState(null),[o,i]=y.useState(void 0);y.useEffect(()=>{let h=!0,f=0;const p=()=>{fetch("/api/lan").then(m=>m.ok?m.json():null).then(m=>h?(m!=null&&m.ok&&t(gT(Array.isArray(m.pending)?m.pending:[],m.aliases)),m):null).catch(()=>null).then(m=>{h&&(i(w=>m!=null&&m.ok?m:w===void 0?null:w),f=window.setTimeout(p,(m==null?void 0:m.enabled)===!0?H0:X4))})};return p(),()=>{h=!1,window.clearTimeout(f)}},[]);const c=y.useCallback(async(h,f)=>{if(!s){a(h);try{const m=await(await fetch("/api/lan/peer",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:h,fp:f})})).json().catch(()=>null);m&&Array.isArray(m.pending)?t(gT(m.pending,m.aliases)):t(w=>w.filter(j=>j.fp!==f))}catch{}finally{a(null)}}},[s]),d=y.useCallback(h=>{s||(n.current.add(h),t(f=>[...f]))},[s]);return{lanPending:e,lanDeferred:n,lanBusy:s,answerLanPair:c,deferLanPair:d,lanStatus:o}}const Sxe=6e4;function _xe({enabled:e,lanStatus:t,now:n}){const[s,a]=y.useState(null),[o,i]=y.useState(()=>new Set),[c,d]=y.useState(null),h=y.useCallback(k=>{k!=null&&k.ok&&Array.isArray(k.accounts)&&a(k.accounts)},[]),f=y.useCallback(async k=>{try{const N=await fetch(`/api/claude-accounts${k?"?refresh=1":""}`);N.ok&&h(await N.json())}catch{}},[h]);y.useEffect(()=>{e&&f(!1)},[e,f]),y.useEffect(()=>{if(!e)return;let k=Date.now();const N=()=>{document.visibilityState!=="visible"||Date.now()-k<Sxe||(k=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?Cme(s,{lan:t,now:n,closed:o}):[],[e,s,t,n,o]),m=y.useRef(p);m.current=p;const w=y.useCallback(k=>{k.length&&i(N=>new Set([...N,...k]))},[]),j=y.useCallback(()=>{const k=m.current;k.length&&(w(k.map(N=>N.id)),fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"reauth-later",incidents:k.map(N=>({key:N.key,since:N.since}))})}).catch(()=>{}))},[w]),v=y.useRef(c);v.current=c;const b=y.useCallback(k=>{const N=v.current;w(Eme(N?[N,...m.current]:m.current,k))},[w]);return{rows:p,signingIn:c,observe:h,signIn:d,signedIn:b,refresh:y.useCallback(()=>{f(!0)},[f]),closeSignIn:y.useCallback(()=>d(null),[]),later:j}}const e6=288,Cxe=e6;function Exe(e,t,n){return e?"session-list":t||n?"accounts":null}function Txe(e){return e==="session-list"?Cxe:e==="accounts"?e6:0}const Rxe=240,Axe=20;function Mxe(e){const t=y.useRef(0),n=y.useRef(e);return y.useLayoutEffect(()=>{n.current!==e&&(n.current=e,t.current=$u()?0:performance.now()+Rxe+Axe)},[e]),t}const t6="agent-dag.sessionListOpen",n6="agent-dag.accountsPanelOpen";function $xe(){return Ze(t6)==="1"}function Lxe(e){Xe(t6,e?"1":"0")}function Ixe(){const e=Ze(n6);return e===null?!0:e==="1"}function Oxe(){const[e,t]=y.useState($xe);y.useEffect(()=>{Lxe(e)},[e]);const n=y.useRef(!1),[s,a]=y.useState(()=>{const m=Ixe();return m&&e?(n.current=!0,!1):m});y.useEffect(()=>{!s&&n.current||Xe(n6,s?"1":"0")},[s]),y.useEffect(()=>{!e&&n.current&&(n.current=!1,a(!0))},[e]);const o=y.useCallback(()=>{t(m=>(m||a(w=>(w&&(n.current=!0),!1)),!m))},[]),i=y.useCallback(()=>{n.current=!1,a(m=>(m||t(!1),!m))},[]),c=y.useCallback(()=>{n.current=!1,a(m=>(m||t(!1),!0))},[]),d=y.useCallback(()=>t(!1),[]),h=y.useCallback(()=>{n.current=!1,t(!1)},[]),f=y.useCallback(()=>a(!1),[]),p=Exe(e,s,n.current);return{sessionListOpen:e,accountsPanelOpen:s,panel:p,toggleSessionList:o,toggleAccountsPanel:i,openAccountsPanel:c,closeSessionList:d,closeSessionListToCanvas:h,closeAccountsPanel:f}}const s6="agent-dag.detailOpen",r6="agent-dag.usagePanelOpen",a6="agent-dag.systemPanelOpen";function Pxe(){return Ze(s6)==="1"}function Dxe(e){Xe(s6,e?"1":"0")}function Fxe(){const e=Ze(r6);return e===null?!0:e==="1"}function Bxe(e){Xe(r6,e?"1":"0")}function qxe(){const e=Ze(a6);return e===null?!0:e==="1"}function Uxe(e){Xe(a6,e?"1":"0")}function Wxe(){const[e,t]=y.useState(Pxe);y.useEffect(()=>{Dxe(e)},[e]);const[n,s]=y.useState(Fxe);y.useEffect(()=>{Bxe(n)},[n]);const[a,o]=y.useState(qxe);return y.useEffect(()=>{Uxe(a)},[a]),en("usage-panel",n),en("machine-panel",a),{detailOpen:e,setDetailOpen:t,usagePanelOpen:n,setUsagePanelOpen:s,machinePanelOpen:a,setMachinePanelOpen:o}}const Hxe={permission:"your permission",asked:"your answer"},zxe="No sessions are waiting for you.";function Vxe(e){if(e.length===0)return"";const[t,...n]=e,s=t.waiting.kind,a=n.every(i=>i.waiting.kind===s)?Hxe[s]??"you":"you";if(n.length===0)return`${t.label} is waiting for ${a}.`;const o=`${n.length} more session${n.length===1?"":"s"}`;return`${t.label} and ${o} are waiting for ${a}.`}function Uk(e,t,n=zxe){return t!==""?t:e===""?"":n}function Gxe({waitingSessions:e,watchUnseen:t,incidents:n=[]}){const[s,a]=y.useState(""),o=Vxe(e);y.useEffect(()=>{a(m=>Uk(m,o))},[o]);const[i,c]=y.useState(""),d=t>0?`Browser watch has ${t} unread ${t===1?"finding":"findings"}.`:"";y.useEffect(()=>{c(m=>Uk(m,d,"Browser watch has no unread findings."))},[d]);const[h,f]=y.useState(""),p=sxe(n);return y.useEffect(()=>{f(m=>Uk(m,p,rxe))},[p]),{blockedSaid:s,watchSaid:i,setWatchSaid:c,incidentSaid:h}}const Kxe="/icon-192.png",o6=Object.freeze({notifySwap:!0,notifyQuota:!1,notifyReset:!1,notifyStopped:!0});function _I(e){const t=n=>typeof(e==null?void 0:e[n])=="boolean"?e[n]:o6[n];return{notifySwap:t("notifySwap"),notifyQuota:t("notifyQuota"),notifyReset:t("notifyReset"),notifyStopped:t("notifyStopped")}}function Yxe({waitingSessions:e,liveSince:t,focusSession:n}){const[s,a]=y.useState(()=>typeof Notification>"u"?"denied":Notification.permission),[o,i]=y.useState(null),[c,d]=y.useState(!1),[h,f]=y.useState(!1),[p,m]=y.useState(o6),w=y.useCallback(O=>{const L=!p[O];m(U=>({...U,[O]:L})),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({[O]:L})}).then(U=>U.ok?U.json():null).then(U=>{U!=null&&U.ok&&m(_I(U.prefs))}).catch(()=>{})},[p]),j=y.useRef(()=>{}),v=y.useRef(new Set),b=Gn(e),k=y.useCallback(()=>{const O=!c;d(O),O&&(v.current=uh(b.current)),O&&typeof Notification<"u"&&Notification.permission==="default"&&j.current(),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({notifications:O})}).then(L=>L.ok?L.json():null).then(L=>{var U;L!=null&&L.ok&&(d(((U=L.prefs)==null?void 0:U.notifications)===!0),f(L.notificationsVetoed===!0))}).catch(()=>{})},[c]),N=typeof Notification<"u";y.useEffect(()=>{if(!o)return;const L=setTimeout(()=>i(null),o==="blocked"?8e3:4e3);return()=>clearTimeout(L)},[o]);const S=y.useCallback(()=>{typeof Notification>"u"||Notification.requestPermission().then(O=>{const L=O;a(L),L==="granted"?i("on"):L==="denied"&&i("blocked")})},[]);j.current=S;const _=y.useRef(null),E=e.map(O=>tp(O.id,O.waiting)).join("|");y.useEffect(()=>{g9(_.current,s)&&(_.current=s,v.current=uh(e))},[s]);const I=y.useRef(!1);y.useEffect(()=>{y9(I.current,t)&&(I.current=!0,v.current=uh(e))},[t]),y.useEffect(()=>{if(typeof Notification>"u"||Notification.permission!=="granted"||!w9(_.current,t))return;const O=typeof document>"u"||!document.hidden,L=p9(e,v.current,O,c);for(const U of L)try{const P=new Notification(U.title,{body:U.body,tag:U.key,icon:Kxe});P.onclick=()=>{window.focus(),n(U.sessionId),P.close()}}catch{}v.current=O?uh(e):m9(e,L,v.current)},[E,t]);const A=y.useCallback(O=>{var L;d(((L=O.prefs)==null?void 0:L.notifications)===!0),f(O.notificationsVetoed===!0),m(_I(O.prefs))},[]);return{notifyPermission:s,notifySaid:o,notifyOn:c,notifyVetoed:h,toggleNotify:k,notifySupported:N,askForNotifications:S,loadNotifyPrefs:A,accountNotify:p,toggleAccountNotify:w}}function Xxe({openedTool:e,usageHistoryOpen:t,contextFor:n,tourOpen:s,summaryFor:a,browserWatchOpen:o,keyHelpOpen:i,releaseNotes:c,feedbackOpen:d,trafficRadarOpen:h=!1}){const f=Gn(i),p=y.useRef(!1);return p.current=e!=null||t||n!=null||s||a!=null||o||i||c!=null||d||h,{keyHelpOpenRef:f,modalOpenRef:p}}function Zxe({stateRef:e,tourOpen:t,releaseNotes:n}){const[s,a]=y.useState(null),o=y.useCallback((T,B)=>a({agentId:T,toolId:B}),[]),[i,c]=y.useState(null),[d,h]=y.useState(null),f=y.useCallback(T=>h(T),[]),[p,m]=y.useState(!1),[w,j]=y.useState(!1),[v,b]=y.useState(!1),[k,N]=y.useState(!1),[S,_]=y.useState(!1),[E,I]=y.useState(null),A=y.useCallback(T=>{I(T??null),_(!0)},[]);en("tool-detail",s!==null),en("session-summary",i!==null),en("context-window",d!==null),en("keyboard-help",p),en("usage-history",w),en("browser-watch",v),en("feedback",S);const O=s?o7(e.current.agents,s.agentId,s.toolId):null,L=d?e.current.agents.get(d):void 0,{keyHelpOpenRef:U,modalOpenRef:P}=Xxe({openedTool:O,usageHistoryOpen:w,contextFor:d,tourOpen:t,summaryFor:i,browserWatchOpen:v,keyHelpOpen:p,releaseNotes:n,feedbackOpen:S,trafficRadarOpen:k});return{setOpenedToolKey:a,openTool:o,openedTool:O,summaryFor:i,setSummaryFor:c,contextFor:d,setContextFor:h,openContext:f,contextAgent:L,keyHelpOpen:p,setKeyHelpOpen:m,usageHistoryOpen:w,setUsageHistoryOpen:j,browserWatchOpen:v,setBrowserWatchOpen:b,trafficRadarOpen:k,setTrafficRadarOpen:N,feedbackOpen:S,setFeedbackOpen:_,feedbackPrefill:E,setFeedbackPrefill:I,openFeedback:A,keyHelpOpenRef:U,modalOpenRef:P}}function Jxe({stateRef:e,pinnedRef:t,measuredRef:n,positionsRef:s,lastLayoutSigRef:a,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=O1(),t.current.clear(),n.current.clear(),s.current.clear(),a.current="",BF(),o(),i(),c()},[c,i,o]),m=Gn(h),w=y.useCallback(j=>{const v=Wfe(j,{confirmOpen:m.current,modalOpen:d.current});v==="confirm"?f(!0):v==="clear"&&(f(!1),p())},[p]);return{clearConfirmOpen:h,setClearConfirmOpen:f,requestClear:w}}const CI="agent-dag.oldNameNoticeDismissed";function Qxe(e){const[t,n]=y.useState(()=>Ze(CI)??""),s=e!=null&&e.invokedAs&&e.invokedAs!==Rt?e.invokedAs:null,a=s!=null&&t!==s,o=y.useCallback(()=>{s&&(n(s),Xe(CI,s))},[s]);return{oldName:s,oldNameOpen:a,dismissOldName:o}}const eve=300*1e3,tve=1800*1e3,nve=8e3,sve=3e4;function EI(e){return fetch("/api/rating",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)}).catch(()=>null)}function rve({modalOpenRef:e}){const t=y.useCallback(()=>Oh({appModal:e.current,dialogDepth:Tn.dialogDepth()}),[e]),[n,s]=y.useState("hidden"),[a,o]=y.useState(null),[i,c]=y.useState(!1),d=y.useRef(n);d.current=n,y.useEffect(()=>{let w=!1;const j=async()=>{if(d.current==="thanks"||d.current==="hidden"&&(document.hidden||t()))return;const k=await fetch("/api/rating").then(N=>N.ok?N.json():null).catch(()=>null);w||!k||s(N=>N==="thanks"?N:k.ask===!0?"asking":"hidden")},v=window.setTimeout(j,eve),b=window.setInterval(j,tve);return()=>{w=!0,window.clearTimeout(v),window.clearInterval(b)}},[t]),y.useEffect(()=>{if(n!=="thanks"||i)return;const w=a!==null&&a<=6?sve:nve;let j=0;const v=()=>{t()?j=window.setTimeout(v,w):s("hidden")};return j=window.setTimeout(v,w),()=>window.clearTimeout(j)},[n,a,i,t]);const h=y.useCallback(w=>{o(w),c(!1),s("thanks"),EI({score:w})},[]),f=y.useCallback(w=>c(w),[]),p=y.useCallback(()=>{s("hidden"),EI({later:!0})},[]),m=y.useCallback(()=>s("hidden"),[]);return{ratingPhase:n,ratingScore:a,answerRating:h,rateLater:p,closeRating:m,holdThanks:f}}function ave({chimesRef:e,setTonePrefs:t,tonePrefsRef:n,previewTone:s}){const[a,o]=y.useState(()=>roe(Ze)),i=Gn(a),[c,d]=y.useState([]),h=y.useCallback(N=>{o(S=>{const _={...S,[N]:null};return i.current=_,_}),wr(eu[N])},[]),f=y.useCallback((N,S)=>{const _=i.current[N];S&&_!==S||(h(N),t(E=>{const I={...E,[N]:{...E[N],figure:Vn}};return n.current=I,I}),Xe(If[N],Vn))},[h]),p=Gn(f);y.useEffect(()=>{let N=!0;return moe().then(S=>{if(!N)return;d(S);const _=new Set(S.map(E=>E.id));for(const E of tu){const I=i.current[E];I&&!_.has(I)&&p.current(E,I)}},()=>{}),()=>{N=!1}},[]);const m=y.useCallback((N,S)=>{if(!c.some(E=>E.id===S))return;const _={...i.current,[N]:S};i.current=_,o(_),Xe(eu[N],S),s(N,!0)},[c,s]),w=y.useCallback(async N=>{var I;const S=Z0(c.length);if(S)throw new Error(S);const _=window.AudioContext??window.webkitAudioContext;if(!_)throw new Error("This browser cannot decode audio files.");const E=new _;try{const A=await uoe(N,L=>E.decodeAudioData(L));await eR(A);const O=Eu(A);d(L=>[...L.filter(U=>U.id!==O.id),O])}finally{(I=E.close)==null||I.call(E)}},[c.length]),j=y.useCallback(async N=>{const S=Z0(c.length);if(S)throw new Error(S);const _=doe(N);await eR(_);const E=Eu(_);d(I=>[...I.filter(A=>A.id!==E.id),E])},[c.length]),v=y.useCallback(async(N,S)=>{const _=c.find(I=>I.id===N),E=S.trim().slice(0,80);!_||!E||E===_.name||(await yoe(N,E),d(I=>I.map(A=>A.id===N?{...A,name:E}:A)))},[c]),b=y.useCallback(async N=>{await woe(N),d(I=>I.filter(A=>A.id!==N));const S=i.current,_=aoe(S,N);i.current=_,o(_);const E=tu.filter(I=>S[I]===N);for(const I of E)wr(eu[I]),Xe(If[I],Vn);E.length>0&&t(I=>{const A={...I};for(const O of E)A[O]={...A[O],figure:Vn};return n.current=A,A})},[]),k=y.useCallback(N=>{var E,I;const S=tu.find(A=>i.current[A]===N),_=S?n.current[S].level:Jo;(E=e.current)==null||E.unlock(),(I=e.current)==null||I.previewCustom(N,_)},[]);return{customSelections:a,customSelectionsRef:i,customAssets:c,clearCustomOnly:h,fallbackCustomRef:p,selectCustomTone:m,importNotificationAudio:w,createNotificationVoice:j,renameCustomAsset:v,deleteCustomAsset:b,previewCustomAsset:k}}function ove(e){const[t,n]=y.useState(()=>Roe(Ze)),s=Gn(t),a=y.useRef(null),o=y.useCallback((c,d=!1)=>{var h,f;if((h=e.current)==null||h.unlock(),a.current!==null&&clearTimeout(a.current),a.current=null,!d){(f=e.current)==null||f.play(c,!0);return}a.current=setTimeout(()=>{var p;a.current=null,(p=e.current)==null||p.play(c,!0)},Soe)},[]),i=y.useCallback((c,d)=>{n(h=>{const f={level:Cp(d.level??h[c].level),figure:CD(c,d.figure??h[c].figure)};return Xe(RD[c],String(f.level)),Xe(If[c],f.figure),{...h,[c]:f}}),o(c,!0)},[o]);return y.useEffect(()=>()=>{a.current!==null&&clearTimeout(a.current)},[]),{tonePrefs:t,setTonePrefs:n,tonePrefsRef:s,previewTone:o,changeTone:i}}const ive=15e3;function lve(e){return e.visibilityState==="visible"&&e.hasFocus()}function cve(e,t){return t||e===!0}function uve(){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 dve(){y.useEffect(()=>{const e=uve();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(()=>{})},s=()=>{const i=lve(document);cve(t,i)&&n(i),t=i},a=()=>{t&&n(!1),t=!1};s();const o=window.setInterval(s,ive);return window.addEventListener("focus",s),window.addEventListener("blur",s),document.addEventListener("visibilitychange",s),window.addEventListener("pagehide",a),()=>{window.clearInterval(o),window.removeEventListener("focus",s),window.removeEventListener("blur",s),document.removeEventListener("visibilitychange",s),window.removeEventListener("pagehide",a),a()}},[])}function hve({loadAutoRestartPrefs:e,loadNotifyPrefs:t,loadReportsPrefs:n}){y.useEffect(()=>{let s=!0;return fetch("/api/prefs").then(a=>a.ok?a.json():null).then(a=>{!s||!(a!=null&&a.ok)||(e(a),t(a),n(a))}).catch(()=>{}),()=>{s=!1}},[])}const Wk="agent-dag.versionNoticeDismissed",fve=15*6e4;function pve(e){const[t,n]=y.useState(null),[s,a]=y.useState(()=>Ze(Wk)??""),o=y.useRef(0),[i,c]=y.useState(!1),d=y.useCallback((v=!1)=>(v&&(o.current=Date.now(),c(!0)),fetch(v?"/api/version?refresh=1":"/api/version").then(b=>b.ok?b.json():null).then(b=>(b&&n(b),b??null)).catch(()=>null).finally(()=>{v&&c(!1)})),[]),h=y.useCallback(()=>{d(Date.now()-o.current>=fve)},[d]);y.useEffect(()=>{d();const v=window.setInterval(h,5*6e4),b=()=>{document.visibilityState==="visible"&&h()};return document.addEventListener("visibilitychange",b),()=>{window.clearInterval(v),document.removeEventListener("visibilitychange",b)}},[d,h]),y.useEffect(()=>{e&&d()},[e,d]);const f=(t==null?void 0:t.notice)??null,p=c5(f),m=ofe(f,s),w=y.useCallback(()=>{a(""),Xe(Wk,"")},[]),j=y.useCallback(()=>{f&&(a(p),Xe(Wk,p))},[f,p]);return{version:t,notice:f,noticeOpen:m,showNotice:w,dismissNotice:j,versionChecking:i,loadVersion:d}}function mve({version:e,readyAppUpdate:t}){const[n,s]=y.useState(!1),a=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 b=mr(),k=Yme(b),N=tge({stored:k,running:(e==null?void 0:e.running)??null,notes:nI,remembers:Xme(b)});if(N.reason==="no-version")return;h.current=!0,N.record&&Zme(b,N.record);let S=!0;return(async()=>{var O;let E=Jme(b);if(Ja())try{const L=await fetch("/api/prefs");if(!L.ok)throw new Error("desktop tour preferences unavailable");const U=await L.json();if(!(U!=null&&U.ok))throw new Error("desktop tour preferences unavailable");const P=((O=U.prefs)==null?void 0:O.tourSeen)===!0;E&&!P&&fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tourSeen:!0}),keepalive:!0}).catch(()=>{}),E=E||P}catch{E=!0}if(!S)return;const I=ege({tourSeen:E,decision:N}),A=N.show.length?{entries:N.show,since:k,firstRun:!1}:null;I.tour&&s(!0),I.notes==="now"?i(A):I.notes==="after"&&(a.current=A)})(),()=>{S=!1}},[e==null?void 0:e.running]);const f=(e==null?void 0:e.running)??"3.44.0",p=y.useMemo(()=>R5(nI,null,f),[f]),m=y.useCallback(()=>{i({entries:p,since:null,firstRun:!1})},[p]),w=y.useCallback(()=>s(!0),[]),j=y.useCallback(()=>i(null),[]),v=y.useCallback(()=>{s(!1),Qme(mr()),Ja()&&fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tourSeen:!0}),keepalive:!0}).catch(()=>{});const b=a.current;a.current=null,b&&i(b)},[]);return{tourOpen:n,openTour:w,closeTour:v,releaseNotes:o,closeReleaseNotes:j,chipVersion:f,openReleaseNotes:m}}function gve(){const[e,t]=y.useState(void 0),[n,s]=y.useState(!1),a=y.useRef(!1);return a.current=e===!0&&!n,y.useEffect(()=>$we(()=>a.current),[]),{loadReportsPrefs:y.useCallback(i=>{var c;t(((c=i.prefs)==null?void 0:c.reports)!==!1),s(i.reportsVetoed===!0)},[])}}function yve(e){const[t,n]=y.useState(null);y.useEffect(()=>{const c=Ze("agent-dag.sound");n(c===null?!0:c==="on")},[]);const s=y.useCallback(()=>{n(c=>{var h,f;const d=c!==!0;return Xe("agent-dag.sound",d?"on":"off"),d?(h=e.current)==null||h.unlock():(f=e.current)==null||f.silence(),d})},[]),a=y.useCallback(c=>{s()},[s]),o=Gn(a),i=Gn(t);return{soundOn:t,toggleSound:s,activateSoundRef:o,soundOnRef:i}}function wve(){const[e,t]=y.useState(ehe),n=y.useCallback(o=>{t(i=>the(i,o))},[]),s=y.useCallback(()=>t(o=>({...o,open:!1})),[]),a=y.useCallback(o=>t(i=>({...i,section:o})),[]);return{settingsOpen:e.open,settingsSection:e.section,openSettings:n,closeSettings:s,showSection:a}}const xve="agent-dag.autoFitDisabled";function vve(e){const t=y.useRef(!1),[n,s]=y.useState(!1);y.useEffect(()=>{wr(xve)},[]);const a=y.useCallback(()=>{t.current||(t.current=!0,s(!0))},[]),o=y.useCallback(()=>{t.current=!1,s(!1),e(400)},[e]);return{autoFitDisabled:n,autoFitDisabledRef:t,disableAutoFit:a,enableAutoFitAndRefit:o}}function bve(){return r.jsx(I1,{children:r.jsx(Owe,{children:r.jsx(kve,{})})})}function kve(){var pi;const e=_l(),t=y.useState(O1)[0],n=y.useRef(t),[,s]=y.useState(0),a=y.useCallback(()=>s(Bt=>Bt+1),[]),{detailOpen:o,setDetailOpen:i,usagePanelOpen:c,setUsagePanelOpen:d,machinePanelOpen:h,setMachinePanelOpen:f}=Wxe(),{selectedIds:p,primarySelectedId:m,selectAgent:w,clearSelection:j,pruneSelectionToBoard:v}=Koe(n,i),{sessionListOpen:b,accountsPanelOpen:k,panel:N,toggleSessionList:S,toggleAccountsPanel:_,openAccountsPanel:E,closeSessionList:I,closeSessionListToCanvas:A,closeAccountsPanel:O}=Oxe(),L=Qi(k,200),U=Qi(b,200),P=NC(b,U),T=Qi(c,130),B=Qi(h,130),M=y.useRef(null),q=yve(M),{activateSoundRef:$,soundOnRef:K}=q,G=ove(M),{setTonePrefs:z,tonePrefsRef:W,previewTone:D}=G,H=ave({chimesRef:M,setTonePrefs:z,tonePrefsRef:W,previewTone:D}),{customSelectionsRef:ee,fallbackCustomRef:F}=H,Y=wve(),{openSettings:X}=Y;vxe({chimesRef:M,soundOnRef:K,tonePrefsRef:W,customSelectionsRef:ee,fallbackCustomRef:F});const Z=Fwe(n),{pauseGate:J,paused:ne,togglePause:ce}=Z,he=y.useRef(()=>{}),{live:le,tabCapped:re,everConnected:ae,liveSince:de}=Doe({stateRef:n,rerender:a,pauseGate:J,chimesRef:M,desktopUpdateRef:he}),Se=pve(le),{version:pe,notice:me,noticeOpen:be,loadVersion:Ce}=Se,ye=kxe(le),{readyAppUpdate:Pe,onDesktopUpdateEvent:Oe}=ye;he.current=Oe,dve();const We=mve({version:pe,readyAppUpdate:Pe}),{tourOpen:Re,openTour:st,releaseNotes:je}=We,{workspace:Te,providers:$e,providersRef:Ge}=qwe(le),tt=Txe(N==="accounts"&&!$e.claude?null:N),ht=Mxe(tt),it=NC(k,L)&&$e.claude,[nt,we]=y.useState(!1),Be=y.useCallback(()=>{E(),we(!0)},[E]);y.useEffect(()=>{k||we(!1)},[k]);const Ye=y.useCallback(()=>we(!1),[]),He=Qxe(pe),ft=axe({version:pe,loadVersion:Ce}),{upgradeFailure:St}=ft,gt=Zxe({stateRef:n,tourOpen:Re,releaseNotes:je}),_t=rve({modalOpenRef:gt.modalOpenRef}),{openTool:It,setSummaryFor:ks,setContextFor:Xs,openContext:js,setKeyHelpOpen:Zn,setUsageHistoryOpen:Ot,setBrowserWatchOpen:Ns,keyHelpOpenRef:hn,modalOpenRef:Dn}=gt,_e=gve(),De=ixe(),{watchOn:ze,watchUnseen:ut}=De,At=Nxe(),[Jn,fn]=y.useState(0),{presentCats:la,hiddenCats:Qn,toggleCat:Ct,catBarRef:Ss,catBarOccluded:_s}=wxe(n),Zs=y.useRef(null),[Cs,Sr]=y.useState(0),Ft=Yoe({stateRef:n,rerender:a,pruneSelectionToBoard:v,setContextFor:Xs,setSummaryFor:ks});uG({stateRef:n,now:Ft,enabled:$e.claude});const Js=zwe($e.claude||$e.codex),Es=nxe(Js,Ft),_r=_xe({enabled:$e.claude,lanStatus:At.lanStatus,now:Ft}),dt=jxe({now:Ft,stateRef:n,version:pe,notice:me,noticeOpen:be,upgradeFailure:St,paused:Z.paused}),{askRestart:ri,loadAutoRestartPrefs:Cr}=dt,Qs=yxe(),{setTheme:Ts,palette:so}=Qs,Er=bxe(),es=Vue(),{applyViewport:nn,moveCamera:er,fitLeft:Wt,cameraEpochRef:ai,lastFitTimeRef:ro}=es,tr=ode(es),{pinnedRef:ts,positionsRef:ns,lastLayoutSigRef:ge,handleRelayout:Ve,rearrangeUndo:lt}=tr,Mt=y.useRef(null),ss=y.useRef(()=>{}),Tr=de!==null,ca=y.useRef(0),nr=y.useCallback(()=>{ca.current=Date.now()},[]),{canvasRef:Fn,canvasSize:Rr,paneSizeRef:ct}=Kde(ht),Ol=vve(Wt),{autoFitDisabledRef:Pl,disableAutoFit:ao}=Ol,oi=y.useRef(!1),{measuredRef:sr,measuredVersionRef:Ju,sizeVersion:Dl,domSizeVersion:ii}=Yde(oi),{removedNodes:rs,removedAgentIds:pn,removeNode:rr,removeSelectedNode:ua,removalNotice:da,hideSessions:ar,bringBack:Fl,bringBackAll:Qu,forgetRemovals:oo}=Cde({stateRef:n,pinnedRef:ts,positionsRef:ns,canvasRef:Fn,clearSelection:j,primarySelectedId:m});Pde({stateRef:n,removedNodes:rs,hideSessions:ar,ready:Tr,keepSessionId:m?((pi=n.current.agents.get(m))==null?void 0:pi.sessionId)??m:null});const Bl=kde({stateRef:n,now:Ft,removedAgentIds:pn,sizeVersion:Dl,domSizeVersion:ii});ide(Bl,tr),_de({layoutSig:Bl,rf:e,stateRef:n,measuredRef:sr,pinnedRef:ts,positionsRef:ns,paneSizeRef:ct,lastInteractRef:ca,autoFitDisabledRef:Pl,lastFitTimeRef:ro,fitLeft:Wt});const ql=Xde(),{bubbling:li,endBubble:ed,onBubble:zp}=Hae(),[Ar,io]=y.useState(!1),Mr=Uae(),{beginTrashDrag:ci,trackTrashDrag:Vp,endTrashDrag:Gp}=Mr,ui=Zae({stateRef:n,measuredRef:sr,measuredVersionRef:Ju,canvasRef:Fn}),{lodRef:di,applyZoom:Ul}=ui,Wl=zde({applyViewport:nn,lastFitTimeRef:ro,cameraEpochRef:ai,disableAutoFit:ao,markInteract:nr,canvasRef:Fn,applyZoom:Ul}),kn=m?n.current.agents.get(m):null,lo=o&&kn!=null,Rs=che({sessionListShown:P,usageShown:Ba(T),machineShown:Ba(B),accountsShown:it,detailShown:lo,primarySelectedId:m,canvasRef:Fn}),{railInsetRef:co,availableWidth:uo,availableHeight:ho}=que({canvasRef:Fn,canvasSize:Rr,machinePhase:B,usagePhase:T,usagePanelOpen:c,detailShown:lo}),Hl=jde({stateRef:n,now:Ft,availableWidth:uo,availableHeight:ho,layout:tr,measuredRef:sr,onBubble:zp,settled:ql,dragging:Ar,layoutSig:Bl,selectedIds:p,openContext:js,historyReplayed:Tr,removedNodes:rs,removedAgentIds:pn,dragTick:Jn,dragPatchRef:Zs,dragMoveTick:Cs}),{nodes:sn,edges:ha}=Hl,fo=Gn(m);lde({nodes:sn,edges:ha,settled:ql,dragging:Ar,availableWidth:uo,availableHeight:ho,layout:tr,camera:es,rf:e,measuredRef:sr,stateRef:n,lastFocusRef:Mt,primarySelectedIdRef:fo,focusAgentRef:ss,autoFitDisabledRef:Pl});const fa=Jxe({stateRef:n,pinnedRef:ts,measuredRef:sr,positionsRef:ns,lastLayoutSigRef:ge,forgetRemovals:oo,clearSelection:j,rerender:a,modalOpenRef:Dn}),{requestClear:td}=fa,zl=uhe({nodes:sn,stateRef:n,pinnedRef:ts,positionsRef:ns,draggingRef:oi,dragPatchRef:Zs,setDragging:io,setDragMoveTick:Sr,setDragTick:fn,endBubble:ed,markInteract:nr,disableAutoFit:ao,beginTrashDrag:ci,trackTrashDrag:Vp,endTrashDrag:Gp,removeNode:rr}),Vl=y.useCallback(()=>Wt(500),[Wt]),$r=Gn(sn),{focusAgent:Lr,stepAgent:nd,focusSession:pa}=Kue({canvasRef:Fn,stateRef:n,measuredRef:sr,nodesRef:$r,railInsetRef:co,moveCamera:er,disableAutoFit:ao,lastFocusRef:Mt,focusAgentRef:ss,selectAgent:w,primarySelectedIdRef:fo}),Kp=Vde({clearSelection:j,selectAgent:w,detailOpen:o,setDetailOpen:i,detailShown:lo,focusAgent:Lr,draggingRef:oi,lodRef:di}),Yp=Yue({nodesRef:$r,stateRef:n,canvasRef:Fn,railInsetRef:co}),Gl=Gn(ua),Kl=y.useRef(null),hi=y.useCallback(Bt=>{pn.has(Bt)&&Fl([Bt]),pa(Bt)},[pn,Fl,pa]),Xp=Zde();ihe({pointerFocusRef:Xp,nodesRef:$r,stateRef:n,primarySelectedIdRef:fo,providersRef:Ge,soundOnRef:K,keyHelpOpenRef:hn,modalOpenRef:Dn,waitingCursorRef:Kl,removeSelectedRef:Gl,activateSoundRef:$,clearSelection:j,selectAgent:w,focusAgent:Lr,stepAgent:nd,focusSession:pa,requestClear:td,handleRelayout:Ve,undoRearrange:lt.undo,handleFit:Vl,togglePause:ce,toggleSessionList:S,toggleAccountsPanel:_,setDetailOpen:i,setUsageHistoryOpen:Ot,setUsagePanelOpen:d,setMachinePanelOpen:f,setBrowserWatchOpen:Ns,setKeyHelpOpen:Zn,setTheme:Ts,openSettings:X});const sd=n.current.agents.size,ma=y.useMemo(()=>u0(n.current.agents.values()),[n.current,n.current.revision]);Ede({stateRef:n,waitingSessions:ma,removedAgentIds:pn,removedNodes:rs,bringBack:Fl}),Ude({stateRef:n,waitingSessions:ma,live:le});const Yl=Gxe({waitingSessions:ma,watchUnseen:ut,incidents:Es}),Xl=Yxe({waitingSessions:ma,liveSince:de,focusSession:pa}),{loadNotifyPrefs:Zp}=Xl;hve({loadAutoRestartPrefs:Cr,loadNotifyPrefs:Zp,loadReportsPrefs:_e.loadReportsPrefs});const Ir=pp(Whe),[rd,fi]=y.useState(!1),[Jp,Zl]=y.useState(!1),Qp=y.useCallback(()=>Zl(!1),[]),ad=y.useCallback(Bt=>{const Jl=n.current.agents.get(Bt);return Jl?Jl.label||Jl.cwdBasename||"session":null},[]),em=y.useCallback(Bt=>{Zl(!1),hi(Bt)},[hi]),tm=y.useCallback(()=>fi(!1),[]),or=zhe({providers:$e,sessionListOpen:b,toggleSessionList:S,accountsPanelOpen:k,toggleAccountsPanel:_,usagePanelOpen:c,setUsagePanelOpen:d,machinePanelOpen:h,setMachinePanelOpen:f,setUsageHistoryOpen:Ot,watchOn:ze,watchUnseen:ut,setBrowserWatchOpen:Ns,setTrafficRadarOpen:gt.setTrafficRadarOpen,openSettings:X,onFeedback:gt.openFeedback,radioOpen:rd,setRadioOpen:fi,openToolActivity:()=>Zl(!0),toggles:Rs.toggles}),[nm,sm]=y.useState(0),rm=y.useCallback(Bt=>{hi(Bt),Ir&&A()},[hi,Ir,A]),am=y.useCallback(()=>{b||S(),requestAnimationFrame(()=>{var Bt;return(Bt=document.querySelector("#session-list .sl-row"))==null?void 0:Bt.focus()})},[b,S]);return r.jsxs("div",{className:"app",children:[r.jsx("a",{className:"skip-link",href:"#canvas",children:"Skip to the canvas"}),r.jsxs("header",{className:"topbar",children:[r.jsx(AX,{}),r.jsx(yfe,{versionCheck:Se,welcome:We,desktopUpdate:ye,pause:Z,announcements:Yl,notify:Xl,waitingSessions:ma,waitingCursorRef:Kl,focusSession:pa,live:le,now:Ft,incidents:Es,queueNamed:Ir?0:nm}),!Ir&&r.jsx(pfe,{waitingSessions:ma,waitingCursorRef:Kl,focusSession:pa,now:Ft,onFit:sm,onMore:am}),kn&&r.jsx(wfe,{selected:kn,now:Ft,selectedIds:p,focusAgent:Lr,clearSelection:j}),!Ir&&r.jsx("div",{className:"actions",children:r.jsx(qhe,{items:or.utilities})})]}),Ir?r.jsx(Bhe,{items:[...or.left,...or.right[0],or.utilities[0]],more:[...or.right.slice(1).flat(),or.utilities[1]]}):r.jsx(FL,{side:"left",label:"Left column",groups:[or.left]}),r.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:da?`${da.label} removed from the board.`:""}),r.jsx(Ufe,{restart:dt,versionCheck:Se,upgrade:ft,oldNameNotice:He,rating:_t,onFeedback:gt.openFeedback,everConnected:ae,live:le,paused:ne}),(P||it)&&r.jsxs(Iae,{width:tt,children:[it&&r.jsx(Lae,{leaving:SC(k,L),onReport:gt.openFeedback,onRoster:_r.observe,onClose:()=>{Rs.accounts(),O()},lanWanted:nt,onLanShown:Ye}),P&&r.jsx(zX,{leaving:SC(b,U),state:n.current,now:Ft,selectedIds:p,onSelect:rm,onClose:()=>{Rs.sessionList(),I()},removedIds:pn,onBringBackAll:Qu})]}),r.jsxs(jfe,{canvasRef:Fn,bubbling:li,dragging:Ar,trash:Mr,zoom:ui,viewport:Wl,stateRef:n,peek:Yp,children:[sd===0&&(!le&&re?r.jsx(hhe,{reservedRight:co.current}):r.jsx(fhe,{live:le,everConnected:ae,providers:$e,workspace:Te,onTour:st,reservedRight:co.current})),(la.length>1||Qn.size>0)&&r.jsx(xfe,{catBarRef:Ss,catBarOccluded:_s,presentCats:la,hiddenCats:Qn,toggleCat:Ct}),r.jsx(RX,{graph:Hl,layout:tr,viewport:Wl,clicks:Kp,drag:zl,appearance:Qs,fm:Er,radioOpen:rd,onRadioClose:tm,autoFit:Ol,pause:Z,stateRef:n,measuredRef:sr,hiddenCats:Qn,now:Ft,openTool:It,focusAgent:Lr,requestClear:td,setKeyHelpOpen:Zn})]}),!Ir&&r.jsx(FL,{side:"right",label:"Right panels",groups:or.right}),Jp&&r.jsx(EZ,{onClose:Qp,sessionLabel:ad,onOpenSession:em}),Ba(T)&&r.jsx(OJ,{state:n.current,now:Ft,providers:$e,incidents:Es,liveSince:de,leaving:T==="leaving",onClose:()=>{Rs.usage(),d(!1)}}),Ba(B)&&r.jsx(bQ,{usageOpen:c,leaving:B==="leaving",onClose:()=>{Rs.machine(),f(!1)}}),o&&kn?r.jsx(Che,{selected:kn,now:Ft,openTool:It,setSummaryFor:ks,stateRef:n,removeSelectedNode:ua,onClose:()=>{Rs.detail(),i(!1)}}):null,r.jsx(gwe,{dialogs:gt,welcome:We,desktopUpdate:ye,versionCheck:Se,restart:dt,upgrade:ft,lanPairs:At,attention:_r,clearFlow:fa,watchBadge:De,announcements:Yl,appearance:Qs,providers:$e,stateRef:n,agentCount:sd,menus:Y,sound:q,tones:G,customTones:H,notify:Xl,panelDoors:{accounts:E,localNetwork:Be}})]})}try{nV(window.localStorage)}catch{}const jve=x8.createRoot(document.getElementById("root"));window.ccdeckWindow&&(document.documentElement.dataset.desktopChrome="true",document.documentElement.dataset.desktopPlatform=window.ccdeckWindow.platform);jve.render(r.jsx(bve,{}));export{Ove as A,lp as B,fe as C,Ze as D,jl as E,Xe as F,Ga as G,mp as H,vY as I,xp as J,Pve as K,aj as L,Tve as M,Nl as N,tK as O,Eve as P,_ve as Q,r4 as R,Cve as S,cp as T,P9 as U,yye as V,lxe as W,Sve as X,bY as Y,l4 as a,WE as b,A0 as c,xt as d,Va as e,et as f,yt as g,Xr as h,Rve as i,r as j,$n as k,Ave as l,_u as m,Yn as n,loe as o,R0 as p,Mve as q,y as r,xn as s,rge as t,mt as u,Ive as v,$ve as w,Lve as x,eo as y,sge as z};
|