ccdeck 3.45.0 → 3.46.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.
Files changed (31) hide show
  1. package/README.md +7 -4
  2. package/bin/cli/startup.js +4 -3
  3. package/dist/web/assets/BrowserWatchModal-CoX9FIUE.js +1 -0
  4. package/dist/web/assets/IntegrationModal-B1ypkK-E.js +5 -0
  5. package/dist/web/assets/RadioPanel-biw_BbZq.js +1 -0
  6. package/dist/web/assets/TrafficRadar-nhtFoYVv.js +8 -0
  7. package/dist/web/assets/{UsageHistoryModal-DAhplVju.js → UsageHistoryModal-Bd-JRAa4.js} +1 -1
  8. package/dist/web/assets/app-BlRY6EME.css +1 -0
  9. package/dist/web/assets/app-DhGvSH7o.js +319 -0
  10. package/dist/web/assets/{index-r8Ymr47Q.js → index-DmENqVdt.js} +1 -1
  11. package/dist/web/index.html +3 -3
  12. package/package.json +1 -1
  13. package/release-notes.json +30 -0
  14. package/src/server/claude-accounts.mjs +35 -19
  15. package/src/server/claude-login.mjs +111 -0
  16. package/src/server/cswap-admin.mjs +12 -3
  17. package/src/server/installer.mjs +24 -7
  18. package/src/server/login-service.mjs +2 -2
  19. package/src/server/skill-hook.mjs +28 -22
  20. package/src/server/system-metrics.mjs +4 -0
  21. package/src/server/tool-audit-routes.mjs +4 -0
  22. package/src/server/traffic-radar-config.mjs +33 -0
  23. package/src/server/traffic-radar-platform.mjs +84 -17
  24. package/src/server/traffic-radar-service.mjs +6 -3
  25. package/src/server/traffic-radar.mjs +32 -9
  26. package/dist/web/assets/BrowserWatchModal-Cbzf3TWa.js +0 -1
  27. package/dist/web/assets/IntegrationModal-BnnBr0a3.js +0 -5
  28. package/dist/web/assets/RadioPanel-BIqrMLQN.js +0 -1
  29. package/dist/web/assets/TrafficRadar-D1gZCIwX.js +0 -8
  30. package/dist/web/assets/app-BW3NYUYB.js +0 -318
  31. package/dist/web/assets/app-C5RY_wZ4.css +0 -1
@@ -0,0 +1,319 @@
1
+ var wB=Object.defineProperty;var xB=(e,t,n)=>t in e?wB(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Fa=(e,t,n)=>xB(e,typeof t!="symbol"?t+"":t,n);var bh=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function K1(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Kg={exports:{}},$c={},Yg={exports:{}},tt={};/**
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 rC;function vB(){if(rC)return tt;rC=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($){return $===null||typeof $!="object"?null:($=p&&$[p]||$["@@iterator"],typeof $=="function"?$:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},v=Object.assign,b={};function k($,W,Z){this.props=$,this.context=W,this.refs=b,this.updater=Z||w}k.prototype.isReactComponent={},k.prototype.setState=function($,W){if(typeof $!="object"&&typeof $!="function"&&$!=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,$,W,"setState")},k.prototype.forceUpdate=function($){this.updater.enqueueForceUpdate(this,$,"forceUpdate")};function N(){}N.prototype=k.prototype;function j($,W,Z){this.props=$,this.context=W,this.refs=b,this.updater=Z||w}var S=j.prototype=new N;S.constructor=j,v(S,k.prototype),S.isPureReactComponent=!0;var _=Array.isArray,T=Object.prototype.hasOwnProperty,L={current:null},A={key:!0,ref:!0,__self:!0,__source:!0};function P($,W,Z){var V,Y={},X=null,J=null;if(W!=null)for(V in W.ref!==void 0&&(J=W.ref),W.key!==void 0&&(X=""+W.key),W)T.call(W,V)&&!A.hasOwnProperty(V)&&(Y[V]=W[V]);var Q=arguments.length-2;if(Q===1)Y.children=Z;else if(1<Q){for(var te=Array(Q),ce=0;ce<Q;ce++)te[ce]=arguments[ce+2];Y.children=te}if($&&$.defaultProps)for(V in Q=$.defaultProps,Q)Y[V]===void 0&&(Y[V]=Q[V]);return{$$typeof:e,type:$,key:X,ref:J,props:Y,_owner:L.current}}function O($,W){return{$$typeof:e,type:$.type,key:W,ref:$.ref,props:$.props,_owner:$._owner}}function U($){return typeof $=="object"&&$!==null&&$.$$typeof===e}function q($){var W={"=":"=0",":":"=2"};return"$"+$.replace(/[=:]/g,function(Z){return W[Z]})}var M=/\/+/g;function I($,W){return typeof $=="object"&&$!==null&&$.key!=null?q(""+$.key):W.toString(36)}function E($,W,Z,V,Y){var X=typeof $;(X==="undefined"||X==="boolean")&&($=null);var J=!1;if($===null)J=!0;else switch(X){case"string":case"number":J=!0;break;case"object":switch($.$$typeof){case e:case t:J=!0}}if(J)return J=$,Y=Y(J),$=V===""?"."+I(J,0):V,_(Y)?(Z="",$!=null&&(Z=$.replace(M,"$&/")+"/"),E(Y,W,Z,"",function(ce){return ce})):Y!=null&&(U(Y)&&(Y=O(Y,Z+(!Y.key||J&&J.key===Y.key?"":(""+Y.key).replace(M,"$&/")+"/")+$)),W.push(Y)),1;if(J=0,V=V===""?".":V+":",_($))for(var Q=0;Q<$.length;Q++){X=$[Q];var te=V+I(X,Q);J+=E(X,W,Z,te,Y)}else if(te=m($),typeof te=="function")for($=te.call($),Q=0;!(X=$.next()).done;)X=X.value,te=V+I(X,Q++),J+=E(X,W,Z,te,Y);else if(X==="object")throw W=String($),Error("Objects are not valid as a React child (found: "+(W==="[object Object]"?"object with keys {"+Object.keys($).join(", ")+"}":W)+"). If you meant to render a collection of children, use an array instead.");return J}function D($,W,Z){if($==null)return $;var V=[],Y=0;return E($,V,"","",function(X){return W.call(Z,X,Y++)}),V}function B($){if($._status===-1){var W=$._result;W=W(),W.then(function(Z){($._status===0||$._status===-1)&&($._status=1,$._result=Z)},function(Z){($._status===0||$._status===-1)&&($._status=2,$._result=Z)}),$._status===-1&&($._status=0,$._result=W)}if($._status===1)return $._result.default;throw $._result}var H={current:null},G={transition:null},z={ReactCurrentDispatcher:H,ReactCurrentBatchConfig:G,ReactCurrentOwner:L};function F(){throw Error("act(...) is not supported in production builds of React.")}return tt.Children={map:D,forEach:function($,W,Z){D($,function(){W.apply(this,arguments)},Z)},count:function($){var W=0;return D($,function(){W++}),W},toArray:function($){return D($,function(W){return W})||[]},only:function($){if(!U($))throw Error("React.Children.only expected to receive a single React element child.");return $}},tt.Component=k,tt.Fragment=n,tt.Profiler=a,tt.PureComponent=j,tt.StrictMode=s,tt.Suspense=d,tt.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=z,tt.act=F,tt.cloneElement=function($,W,Z){if($==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+$+".");var V=v({},$.props),Y=$.key,X=$.ref,J=$._owner;if(W!=null){if(W.ref!==void 0&&(X=W.ref,J=L.current),W.key!==void 0&&(Y=""+W.key),$.type&&$.type.defaultProps)var Q=$.type.defaultProps;for(te in W)T.call(W,te)&&!A.hasOwnProperty(te)&&(V[te]=W[te]===void 0&&Q!==void 0?Q[te]:W[te])}var te=arguments.length-2;if(te===1)V.children=Z;else if(1<te){Q=Array(te);for(var ce=0;ce<te;ce++)Q[ce]=arguments[ce+2];V.children=Q}return{$$typeof:e,type:$.type,key:Y,ref:X,props:V,_owner:J}},tt.createContext=function($){return $={$$typeof:i,_currentValue:$,_currentValue2:$,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},$.Provider={$$typeof:o,_context:$},$.Consumer=$},tt.createElement=P,tt.createFactory=function($){var W=P.bind(null,$);return W.type=$,W},tt.createRef=function(){return{current:null}},tt.forwardRef=function($){return{$$typeof:c,render:$}},tt.isValidElement=U,tt.lazy=function($){return{$$typeof:f,_payload:{_status:-1,_result:$},_init:B}},tt.memo=function($,W){return{$$typeof:h,type:$,compare:W===void 0?null:W}},tt.startTransition=function($){var W=G.transition;G.transition={};try{$()}finally{G.transition=W}},tt.unstable_act=F,tt.useCallback=function($,W){return H.current.useCallback($,W)},tt.useContext=function($){return H.current.useContext($)},tt.useDebugValue=function(){},tt.useDeferredValue=function($){return H.current.useDeferredValue($)},tt.useEffect=function($,W){return H.current.useEffect($,W)},tt.useId=function(){return H.current.useId()},tt.useImperativeHandle=function($,W,Z){return H.current.useImperativeHandle($,W,Z)},tt.useInsertionEffect=function($,W){return H.current.useInsertionEffect($,W)},tt.useLayoutEffect=function($,W){return H.current.useLayoutEffect($,W)},tt.useMemo=function($,W){return H.current.useMemo($,W)},tt.useReducer=function($,W,Z){return H.current.useReducer($,W,Z)},tt.useRef=function($){return H.current.useRef($)},tt.useState=function($){return H.current.useState($)},tt.useSyncExternalStore=function($,W,Z){return H.current.useSyncExternalStore($,W,Z)},tt.useTransition=function(){return H.current.useTransition()},tt.version="18.3.1",tt}var aC;function Bu(){return aC||(aC=1,Yg.exports=vB()),Yg.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 oC;function bB(){if(oC)return $c;oC=1;var e=Bu(),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 $c.Fragment=n,$c.jsx=i,$c.jsxs=i,$c}var iC;function kB(){return iC||(iC=1,Kg.exports=bB()),Kg.exports}var r=kB(),kh={},Xg={exports:{}},Rn={},Zg={exports:{}},Jg={};/**
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 lC;function jB(){return lC||(lC=1,(function(e){function t(G,z){var F=G.length;G.push(z);e:for(;0<F;){var $=F-1>>>1,W=G[$];if(0<a(W,z))G[$]=z,G[F]=W,F=$;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],F=G.pop();if(F!==z){G[0]=F;e:for(var $=0,W=G.length,Z=W>>>1;$<Z;){var V=2*($+1)-1,Y=G[V],X=V+1,J=G[X];if(0>a(Y,F))X<W&&0>a(J,Y)?(G[$]=J,G[X]=F,$=X):(G[$]=Y,G[V]=F,$=V);else if(X<W&&0>a(J,F))G[$]=J,G[X]=F,$=X;else break e}}return z}function a(G,z){var F=G.sortIndex-z.sortIndex;return F!==0?F: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,v=!1,b=!1,k=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,j=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function 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(b=!1,S(G),!v)if(n(d)!==null)v=!0,B(T);else{var z=n(h);z!==null&&H(_,z.startTime-G)}}function T(G,z){v=!1,b&&(b=!1,N(P),P=-1),w=!0;var F=m;try{for(S(z),p=n(d);p!==null&&(!(p.expirationTime>z)||G&&!q());){var $=p.callback;if(typeof $=="function"){p.callback=null,m=p.priorityLevel;var W=$(p.expirationTime<=z);z=e.unstable_now(),typeof W=="function"?p.callback=W:p===n(d)&&s(d),S(z)}else s(d);p=n(d)}if(p!==null)var Z=!0;else{var V=n(h);V!==null&&H(_,V.startTime-z),Z=!1}return Z}finally{p=null,m=F,w=!1}}var L=!1,A=null,P=-1,O=5,U=-1;function q(){return!(e.unstable_now()-U<O)}function M(){if(A!==null){var G=e.unstable_now();U=G;var z=!0;try{z=A(!0,G)}finally{z?I():(L=!1,A=null)}}else L=!1}var I;if(typeof j=="function")I=function(){j(M)};else if(typeof MessageChannel<"u"){var E=new MessageChannel,D=E.port2;E.port1.onmessage=M,I=function(){D.postMessage(null)}}else I=function(){k(M,0)};function B(G){A=G,L||(L=!0,I())}function H(G,z){P=k(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(){v||w||(v=!0,B(T))},e.unstable_forceFrameRate=function(G){0>G||125<G?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):O=0<G?Math.floor(1e3/G):5},e.unstable_getCurrentPriorityLevel=function(){return 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 F=m;m=z;try{return G()}finally{m=F}},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 F=m;m=G;try{return z()}finally{m=F}},e.unstable_scheduleCallback=function(G,z,F){var $=e.unstable_now();switch(typeof F=="object"&&F!==null?(F=F.delay,F=typeof F=="number"&&0<F?$+F:$):F=$,G){case 1:var W=-1;break;case 2:W=250;break;case 5:W=1073741823;break;case 4:W=1e4;break;default:W=5e3}return W=F+W,G={id:f++,callback:z,priorityLevel:G,startTime:F,expirationTime:W,sortIndex:-1},F>$?(G.sortIndex=F,t(h,G),n(d)===null&&G===n(h)&&(b?(N(P),P=-1):b=!0,H(_,F-$))):(G.sortIndex=W,t(d,G),v||w||(v=!0,B(T))),G},e.unstable_shouldYield=q,e.unstable_wrapCallback=function(G){var z=m;return function(){var F=m;m=z;try{return G.apply(this,arguments)}finally{m=F}}}})(Jg)),Jg}var cC;function NB(){return cC||(cC=1,Zg.exports=jB()),Zg.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 uC;function SB(){if(uC)return Rn;uC=1;var e=Bu(),t=NB();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 v(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 b(l,u,g,x,C,R,K){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=K}var k={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(l){k[l]=new b(l,0,!1,l,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(l){var u=l[0];k[u]=new b(u,1,!1,l[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(l){k[l]=new b(l,2,!1,l.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(l){k[l]=new b(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){k[l]=new b(l,3,!1,l.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(l){k[l]=new b(l,3,!0,l,null,!1,!1)}),["capture","download"].forEach(function(l){k[l]=new b(l,4,!1,l,null,!1,!1)}),["cols","rows","size","span"].forEach(function(l){k[l]=new b(l,6,!1,l,null,!1,!1)}),["rowSpan","start"].forEach(function(l){k[l]=new b(l,5,!1,l.toLowerCase(),null,!1,!1)});var N=/[\-:]([a-z])/g;function j(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(N,j);k[u]=new b(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(N,j);k[u]=new b(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(N,j);k[u]=new b(u,1,!1,l,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(l){k[l]=new b(l,1,!1,l.toLowerCase(),null,!1,!1)}),k.xlinkHref=new b("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(l){k[l]=new b(l,1,!1,l.toLowerCase(),null,!0,!0)});function S(l,u,g,x){var C=k.hasOwnProperty(u)?k[u]:null;(C!==null?C.type!==0:x||!(2<u.length)||u[0]!=="o"&&u[0]!=="O"||u[1]!=="n"&&u[1]!=="N")&&(v(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,T=Symbol.for("react.element"),L=Symbol.for("react.portal"),A=Symbol.for("react.fragment"),P=Symbol.for("react.strict_mode"),O=Symbol.for("react.profiler"),U=Symbol.for("react.provider"),q=Symbol.for("react.context"),M=Symbol.for("react.forward_ref"),I=Symbol.for("react.suspense"),E=Symbol.for("react.suspense_list"),D=Symbol.for("react.memo"),B=Symbol.for("react.lazy"),H=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 F=Object.assign,$;function W(l){if($===void 0)try{throw Error()}catch(g){var u=g.stack.trim().match(/\n( *(at )?)/);$=u&&u[1]||""}return`
34
+ `+$+l}var Z=!1;function V(l,u){if(!l||Z)return"";Z=!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(de){var x=de}Reflect.construct(l,[],u)}else{try{u.call()}catch(de){x=de}l.call(u.prototype)}else{try{throw Error()}catch(de){x=de}l()}}catch(de){if(de&&x&&typeof de.stack=="string"){for(var C=de.stack.split(`
35
+ `),R=x.stack.split(`
36
+ `),K=C.length-1,ee=R.length-1;1<=K&&0<=ee&&C[K]!==R[ee];)ee--;for(;1<=K&&0<=ee;K--,ee--)if(C[K]!==R[ee]){if(K!==1||ee!==1)do if(K--,ee--,0>ee||C[K]!==R[ee]){var ne=`
37
+ `+C[K].replace(" at new "," at ");return l.displayName&&ne.includes("<anonymous>")&&(ne=ne.replace("<anonymous>",l.displayName)),ne}while(1<=K&&0<=ee);break}}}finally{Z=!1,Error.prepareStackTrace=g}return(l=l?l.displayName||l.name:"")?W(l):""}function Y(l){switch(l.tag){case 5:return W(l.type);case 16:return W("Lazy");case 13:return W("Suspense");case 19:return W("SuspenseList");case 0:case 2:case 15:return l=V(l.type,!1),l;case 11:return l=V(l.type.render,!1),l;case 1:return l=V(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 L:return"Portal";case O:return"Profiler";case P:return"StrictMode";case I:return"Suspense";case E:return"SuspenseList"}if(typeof l=="object")switch(l.$$typeof){case q:return(l.displayName||"Context")+".Consumer";case U:return(l._context.displayName||"Context")+".Provider";case M:var u=l.render;return l=l.displayName,l||(l=u.displayName||u.name||"",l=l!==""?"ForwardRef("+l+")":"ForwardRef"),l;case D:return u=l.displayName||null,u!==null?u:X(l.type)||"Memo";case B:u=l._payload,l=l._init;try{return X(l(u))}catch{}}return null}function J(l){var u=l.type;switch(l.tag){case 24:return"Cache";case 9:return(u.displayName||"Context")+".Consumer";case 10:return(u._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return l=u.render,l=l.displayName||l.name||"",u.displayName||(l!==""?"ForwardRef("+l+")":"ForwardRef");case 7:return"Fragment";case 5:return u;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return X(u);case 8:return u===P?"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 Q(l){switch(typeof l){case"boolean":case"number":case"string":case"undefined":return l;case"object":return l;default:return""}}function te(l){var u=l.type;return(l=l.nodeName)&&l.toLowerCase()==="input"&&(u==="checkbox"||u==="radio")}function ce(l){var u=te(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(K){x=""+K,R.call(this,K)}}),Object.defineProperty(l,u,{enumerable:g.enumerable}),{getValue:function(){return x},setValue:function(K){x=""+K},stopTracking:function(){l._valueTracker=null,delete l[u]}}}}function ue(l){l._valueTracker||(l._valueTracker=ce(l))}function ie(l){if(!l)return!1;var u=l._valueTracker;if(!u)return!0;var g=u.getValue(),x="";return l&&(x=te(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 fe(l,u){var g=u.checked;return F({},u,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:g??l._wrapperState.initialChecked})}function ae(l,u){var g=u.defaultValue==null?"":u.defaultValue,x=u.checked!=null?u.checked:u.defaultChecked;g=Q(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 je(l,u){u=u.checked,u!=null&&S(l,"checked",u,!1)}function me(l,u){je(l,u);var g=Q(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")?xe(l,u.type,g):u.hasOwnProperty("defaultValue")&&xe(l,u.type,Q(u.defaultValue)),u.checked==null&&u.defaultChecked!=null&&(l.defaultChecked=!!u.defaultChecked)}function pe(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 xe(l,u,g){(u!=="number"||re(l.ownerDocument)!==l)&&(g==null?l.defaultValue=""+l._wrapperState.initialValue:l.defaultValue!==""+g&&(l.defaultValue=""+g))}var _e=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=""+Q(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 Ie(l,u){if(u.dangerouslySetInnerHTML!=null)throw Error(n(91));return F({},u,{value:void 0,defaultValue:void 0,children:""+l._wrapperState.initialValue})}function Pe(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(_e(g)){if(1<g.length)throw Error(n(93));g=g[0]}u=g}u==null&&(u=""),g=u}l._wrapperState={initialValue:Q(g)}}function Ue(l,u){var g=Q(u.value),x=Q(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 $e(l){var u=l.textContent;u===l._wrapperState.initialValue&&u!==""&&u!==null&&(l.value=u)}function Je(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 Qe(l,u){return l==null||l==="http://www.w3.org/1999/xhtml"?Je(u):l==="http://www.w3.org/2000/svg"&&u==="foreignObject"?"http://www.w3.org/1999/xhtml":l}var ze,Ne=(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(ze=ze||document.createElement("div"),ze.innerHTML="<svg>"+u.valueOf().toString()+"</svg>",u=ze.firstChild;l.firstChild;)l.removeChild(l.firstChild);for(;u.firstChild;)l.appendChild(u.firstChild)}});function Ae(l,u){if(u){var g=l.firstChild;if(g&&g===l.lastChild&&g.nodeType===3){g.nodeValue=u;return}}l.textContent=u}var qe={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},et=["Webkit","ms","Moz","O"];Object.keys(qe).forEach(function(l){et.forEach(function(u){u=u+l.charAt(0).toUpperCase()+l.substring(1),qe[u]=qe[l]})});function ot(l,u,g){return u==null||typeof u=="boolean"||u===""?"":g||typeof u!="number"||u===0||qe.hasOwnProperty(l)&&qe[l]?(""+u).trim():u+"px"}function we(l,u){l=l.style;for(var g in u)if(u.hasOwnProperty(g)){var x=g.indexOf("--")===0,C=ot(g,u[g],x);g==="float"&&(g="cssFloat"),x?l.setProperty(g,C):l[g]=C}}var Ge=F({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 Ye(l,u){if(u){if(Ge[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 Xe(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 rt=null;function jt(l){return l=l.target||l.srcElement||window,l.correspondingUseElement&&(l=l.correspondingUseElement),l.nodeType===3?l.parentNode:l}var Ut=null,pt=null,Ct=null;function It(l){if(l=wc(l)){if(typeof Ut!="function")throw Error(n(280));var u=l.stateNode;u&&(u=Od(u),Ut(l.stateNode,l.type,u))}}function Wt(l){pt?Ct?Ct.push(l):Ct=[l]:pt=l}function tr(){if(pt){var l=pt,u=Ct;if(Ct=pt=null,It(l),u)for(l=0;l<u.length;l++)It(u[l])}}function Cs(l,u){return l(u)}function Jn(){}var Qn=!1;function Es(l,u,g){if(Qn)return l(u,g);Qn=!0;try{return Cs(l,u,g)}finally{Qn=!1,(pt!==null||Ct!==null)&&(Jn(),tr())}}function fn(l,u){var g=l.stateNode;if(g===null)return null;var x=Od(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 Un=!1;if(c)try{var Ce={};Object.defineProperty(Ce,"passive",{get:function(){Un=!0}}),window.addEventListener("test",Ce,Ce),window.removeEventListener("test",Ce,Ce)}catch{Un=!1}function Re(l,u,g,x,C,R,K,ee,ne){var de=Array.prototype.slice.call(arguments,3);try{u.apply(g,de)}catch(be){this.onError(be)}}var He=!1,vt=null,Et=!1,es=null,ts={onError:function(l){He=!0,vt=l}};function pn(l,u,g,x,C,R,K,ee,ne){He=!1,vt=null,Re.apply(ts,arguments)}function nr(l,u,g,x,C,R,K,ee,ne){if(pn.apply(this,arguments),He){if(He){var de=vt;He=!1,vt=null}else throw Error(n(198));Et||(Et=!0,es=de)}}function mn(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 nn(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 ns(l){if(mn(l)!==l)throw Error(n(188))}function Ts(l){var u=l.alternate;if(!u){if(u=mn(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 ns(C),l;if(R===x)return ns(C),u;R=R.sibling}throw Error(n(188))}if(g.return!==x.return)g=C,x=R;else{for(var K=!1,ee=C.child;ee;){if(ee===g){K=!0,g=C,x=R;break}if(ee===x){K=!0,x=C,g=R;break}ee=ee.sibling}if(!K){for(ee=R.child;ee;){if(ee===g){K=!0,g=R,x=C;break}if(ee===x){K=!0,x=R,g=C;break}ee=ee.sibling}if(!K)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 sr(l){return l=Ts(l),l!==null?As(l):null}function As(l){if(l.tag===5||l.tag===6)return l;for(l=l.child;l!==null;){var u=As(l);if(u!==null)return u;l=l.sibling}return null}var rr=t.unstable_scheduleCallback,ar=t.unstable_cancelCallback,or=t.unstable_shouldYield,ha=t.unstable_requestPaint,ht=t.unstable_now,fa=t.unstable_getCurrentPriorityLevel,Tr=t.unstable_ImmediatePriority,pa=t.unstable_UserBlockingPriority,Mt=t.unstable_NormalPriority,Ar=t.unstable_LowPriority,ir=t.unstable_IdlePriority,ss=null,Zt=null;function Rr(l){if(Zt&&typeof Zt.onCommitFiberRoot=="function")try{Zt.onCommitFiberRoot(ss,l,void 0,(l.current.flags&128)===128)}catch{}}var on=Math.clz32?Math.clz32:Vl,ma=Math.log,ui=Math.LN2;function Vl(l){return l>>>=0,l===0?32:31-(ma(l)/ui|0)|0}var Mr=64,Rs=4194304;function lr(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 ge(l,u){var g=l.pendingLanes;if(g===0)return 0;var x=0,C=l.suspendedLanes,R=l.pingedLanes,K=g&268435455;if(K!==0){var ee=K&~C;ee!==0?x=lr(ee):(R&=K,R!==0&&(x=lr(R)))}else K=g&~C,K!==0?x=lr(K):R!==0&&(x=lr(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-on(u),C=1<<g,x|=l[g],u&=~C;return x}function We(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 dt(l,u){for(var g=l.suspendedLanes,x=l.pingedLanes,C=l.expirationTimes,R=l.pendingLanes;0<R;){var K=31-on(R),ee=1<<K,ne=C[K];ne===-1?((ee&g)===0||(ee&x)!==0)&&(C[K]=We(ee,u)):ne<=u&&(l.expiredLanes|=ee),R&=~ee}}function Nt(l){return l=l.pendingLanes&-1073741825,l!==0?l:l&1073741824?1073741824:0}function Nn(){var l=Mr;return Mr<<=1,(Mr&4194240)===0&&(Mr=64),l}function rs(l){for(var u=[],g=0;31>g;g++)u.push(l);return u}function as(l,u,g){l.pendingLanes|=u,u!==536870912&&(l.suspendedLanes=0,l.pingedLanes=0),l=l.eventTimes,u=31-on(u),l[u]=g}function Gl(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-on(g),R=1<<C;u[C]=0,x[C]=-1,l[C]=-1,g&=~R}}function ga(l,u){var g=l.entangledLanes|=u;for(l=l.entanglements;g;){var x=31-on(g),C=1<<x;C&u|l[x]&u&&(l[x]|=u),g&=~C}}var at=0;function Kl(l){return l&=-l,1<l?4<l?(l&268435455)!==0?16:536870912:4:1}var Yl,di,Xl,Zl,Ms,Jl=!1,hi=[],$s=null,Ls=null,os=null,$r=new Map,Wn=new Map,cr=[],ym="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 dd(l,u){switch(l){case"focusin":case"focusout":$s=null;break;case"dragenter":case"dragleave":Ls=null;break;case"mouseover":case"mouseout":os=null;break;case"pointerover":case"pointerout":$r.delete(u.pointerId);break;case"gotpointercapture":case"lostpointercapture":Wn.delete(u.pointerId)}}function Lr(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=wc(u),u!==null&&di(u)),l):(l.eventSystemFlags|=x,u=l.targetContainers,C!==null&&u.indexOf(C)===-1&&u.push(C),l)}function ya(l,u,g,x,C){switch(u){case"focusin":return $s=Lr($s,l,u,g,x,C),!0;case"dragenter":return Ls=Lr(Ls,l,u,g,x,C),!0;case"mouseover":return os=Lr(os,l,u,g,x,C),!0;case"pointerover":var R=C.pointerId;return $r.set(R,Lr($r.get(R)||null,l,u,g,x,C)),!0;case"gotpointercapture":return R=C.pointerId,Wn.set(R,Lr(Wn.get(R)||null,l,u,g,x,C)),!0}return!1}function hd(l){var u=xo(l.target);if(u!==null){var g=mn(u);if(g!==null){if(u=g.tag,u===13){if(u=nn(g),u!==null){l.blockedOn=u,Ms(l.priority,function(){Xl(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 ho(l){if(l.blockedOn!==null)return!1;for(var u=l.targetContainers;0<u.length;){var g=po(l.domEventName,l.eventSystemFlags,u[0],l.nativeEvent);if(g===null){g=l.nativeEvent;var x=new g.constructor(g.type,g);rt=x,g.target.dispatchEvent(x),rt=null}else return u=wc(g),u!==null&&di(u),l.blockedOn=g,!1;u.shift()}return!0}function Ql(l,u,g){ho(l)&&g.delete(u)}function wm(){Jl=!1,$s!==null&&ho($s)&&($s=null),Ls!==null&&ho(Ls)&&(Ls=null),os!==null&&ho(os)&&(os=null),$r.forEach(Ql),Wn.forEach(Ql)}function Ir(l,u){l.blockedOn===u&&(l.blockedOn=null,Jl||(Jl=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,wm)))}function fo(l){function u(C){return Ir(C,l)}if(0<hi.length){Ir(hi[0],l);for(var g=1;g<hi.length;g++){var x=hi[g];x.blockedOn===l&&(x.blockedOn=null)}}for($s!==null&&Ir($s,l),Ls!==null&&Ir(Ls,l),os!==null&&Ir(os,l),$r.forEach(u),Wn.forEach(u),g=0;g<cr.length;g++)x=cr[g],x.blockedOn===l&&(x.blockedOn=null);for(;0<cr.length&&(g=cr[0],g.blockedOn===null);)hd(g),g.blockedOn===null&&cr.shift()}var wa=_.ReactCurrentBatchConfig,xa=!0;function fd(l,u,g,x){var C=at,R=wa.transition;wa.transition=null;try{at=1,ec(l,u,g,x)}finally{at=C,wa.transition=R}}function xm(l,u,g,x){var C=at,R=wa.transition;wa.transition=null;try{at=4,ec(l,u,g,x)}finally{at=C,wa.transition=R}}function ec(l,u,g,x){if(xa){var C=po(l,u,g,x);if(C===null)Dm(l,u,x,fi,g),dd(l,x);else if(ya(C,l,u,g,x))x.stopPropagation();else if(dd(l,x),u&4&&-1<ym.indexOf(l)){for(;C!==null;){var R=wc(C);if(R!==null&&Yl(R),R=po(l,u,g,x),R===null&&Dm(l,u,x,fi,g),R===C)break;C=R}C!==null&&x.stopPropagation()}else Dm(l,u,x,null,g)}}var fi=null;function po(l,u,g,x){if(fi=null,l=jt(x),l=xo(l),l!==null)if(u=mn(l),u===null)l=null;else if(g=u.tag,g===13){if(l=nn(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 fi=l,null}function pd(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(fa()){case Tr:return 1;case pa:return 4;case Mt:case Ar:return 16;case ir:return 536870912;default:return 16}default:return 16}}var Is=null,tc=null,pi=null;function md(){if(pi)return pi;var l,u=tc,g=u.length,x,C="value"in Is?Is.value:Is.textContent,R=C.length;for(l=0;l<g&&u[l]===C[l];l++);var K=g-l;for(x=1;x<=K&&u[g-x]===C[R-x];x++);return pi=C.slice(l,1<x?1-x:void 0)}function mo(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 mi(){return!0}function gd(){return!1}function ln(l){function u(g,x,C,R,K){this._reactName=g,this._targetInst=C,this.type=x,this.nativeEvent=R,this.target=K,this.currentTarget=null;for(var ee in l)l.hasOwnProperty(ee)&&(g=l[ee],this[ee]=g?g(R):R[ee]);return this.isDefaultPrevented=(R.defaultPrevented!=null?R.defaultPrevented:R.returnValue===!1)?mi:gd,this.isPropagationStopped=gd,this}return F(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=mi)},stopPropagation:function(){var g=this.nativeEvent;g&&(g.stopPropagation?g.stopPropagation():typeof g.cancelBubble!="unknown"&&(g.cancelBubble=!0),this.isPropagationStopped=mi)},persist:function(){},isPersistent:mi}),u}var is={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(l){return l.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},go=ln(is),ls=F({},is,{view:0,detail:0}),gi=ln(ls),yi,wi,va,ba=F({},ls,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:oc,button:0,buttons:0,relatedTarget:function(l){return l.relatedTarget===void 0?l.fromElement===l.srcElement?l.toElement:l.fromElement:l.relatedTarget},movementX:function(l){return"movementX"in l?l.movementX:(l!==va&&(va&&l.type==="mousemove"?(yi=l.screenX-va.screenX,wi=l.screenY-va.screenY):wi=yi=0,va=l),yi)},movementY:function(l){return"movementY"in l?l.movementY:wi}}),yd=ln(ba),nc=F({},ba,{dataTransfer:0}),wd=ln(nc),xd=F({},ls,{relatedTarget:0}),sc=ln(xd),vm=F({},is,{animationName:0,elapsedTime:0,pseudoElement:0}),rc=ln(vm),xi=F({},is,{clipboardData:function(l){return"clipboardData"in l?l.clipboardData:window.clipboardData}}),bm=ln(xi),ka=F({},is,{data:0}),vd=ln(ka),km={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},jm={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"},ac={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function vi(l){var u=this.nativeEvent;return u.getModifierState?u.getModifierState(l):(l=ac[l])?!!u[l]:!1}function oc(){return vi}var bd=F({},ls,{key:function(l){if(l.key){var u=km[l.key]||l.key;if(u!=="Unidentified")return u}return l.type==="keypress"?(l=mo(l),l===13?"Enter":String.fromCharCode(l)):l.type==="keydown"||l.type==="keyup"?jm[l.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:oc,charCode:function(l){return l.type==="keypress"?mo(l):0},keyCode:function(l){return l.type==="keydown"||l.type==="keyup"?l.keyCode:0},which:function(l){return l.type==="keypress"?mo(l):l.type==="keydown"||l.type==="keyup"?l.keyCode:0}}),ja=ln(bd),kd=F({},ba,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),bi=ln(kd),Nm=F({},ls,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:oc}),Or=ln(Nm),jd=F({},is,{propertyName:0,elapsedTime:0,pseudoElement:0}),Nd=ln(jd),Sd=F({},ba,{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}),ic=ln(Sd),Sm=[9,13,27,32],lc=c&&"CompositionEvent"in window,yo=null;c&&"documentMode"in document&&(yo=document.documentMode);var _m=c&&"TextEvent"in window&&!yo,cc=c&&(!lc||yo&&8<yo&&11>=yo),uc=" ",_d=!1;function Sn(l,u){switch(l){case"keyup":return Sm.indexOf(u.keyCode)!==-1;case"keydown":return u.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Cd(l){return l=l.detail,typeof l=="object"&&"data"in l?l.data:null}var Na=!1;function Cm(l,u){switch(l){case"compositionend":return Cd(u);case"keypress":return u.which!==32?null:(_d=!0,uc);case"textInput":return l=u.data,l===uc&&_d?null:l;default:return null}}function Em(l,u){if(Na)return l==="compositionend"||!lc&&Sn(l,u)?(l=md(),pi=tc=Is=null,Na=!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 cc&&u.locale!=="ko"?null:u.data;default:return null}}var Ed={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 gt(l){var u=l&&l.nodeName&&l.nodeName.toLowerCase();return u==="input"?!!Ed[l.type]:u==="textarea"}function Pr(l,u,g,x){Wt(x),u=$d(u,"onChange"),0<u.length&&(g=new go("onChange","change",null,g,x),l.push({event:g,listeners:u}))}var wo=null,dc=null;function w8(l){vS(l,0)}function Td(l){var u=_i(l);if(ie(u))return l}function x8(l,u){if(l==="change")return u}var sS=!1;if(c){var Tm;if(c){var Am="oninput"in document;if(!Am){var rS=document.createElement("div");rS.setAttribute("oninput","return;"),Am=typeof rS.oninput=="function"}Tm=Am}else Tm=!1;sS=Tm&&(!document.documentMode||9<document.documentMode)}function aS(){wo&&(wo.detachEvent("onpropertychange",oS),dc=wo=null)}function oS(l){if(l.propertyName==="value"&&Td(dc)){var u=[];Pr(u,dc,l,jt(l)),Es(w8,u)}}function v8(l,u,g){l==="focusin"?(aS(),wo=u,dc=g,wo.attachEvent("onpropertychange",oS)):l==="focusout"&&aS()}function b8(l){if(l==="selectionchange"||l==="keyup"||l==="keydown")return Td(dc)}function k8(l,u){if(l==="click")return Td(u)}function j8(l,u){if(l==="input"||l==="change")return Td(u)}function N8(l,u){return l===u&&(l!==0||1/l===1/u)||l!==l&&u!==u}var Os=typeof Object.is=="function"?Object.is:N8;function hc(l,u){if(Os(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)||!Os(l[C],u[C]))return!1}return!0}function iS(l){for(;l&&l.firstChild;)l=l.firstChild;return l}function lS(l,u){var g=iS(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=iS(g)}}function cS(l,u){return l&&u?l===u?!0:l&&l.nodeType===3?!1:u&&u.nodeType===3?cS(l,u.parentNode):"contains"in l?l.contains(u):l.compareDocumentPosition?!!(l.compareDocumentPosition(u)&16):!1:!1}function uS(){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 Rm(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 S8(l){var u=uS(),g=l.focusedElem,x=l.selectionRange;if(u!==g&&g&&g.ownerDocument&&cS(g.ownerDocument.documentElement,g)){if(x!==null&&Rm(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=lS(g,R);var K=lS(g,x);C&&K&&(l.rangeCount!==1||l.anchorNode!==C.node||l.anchorOffset!==C.offset||l.focusNode!==K.node||l.focusOffset!==K.offset)&&(u=u.createRange(),u.setStart(C.node,C.offset),l.removeAllRanges(),R>x?(l.addRange(u),l.extend(K.node,K.offset)):(u.setEnd(K.node,K.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 _8=c&&"documentMode"in document&&11>=document.documentMode,ki=null,Mm=null,fc=null,$m=!1;function dS(l,u,g){var x=g.window===g?g.document:g.nodeType===9?g:g.ownerDocument;$m||ki==null||ki!==re(x)||(x=ki,"selectionStart"in x&&Rm(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}),fc&&hc(fc,x)||(fc=x,x=$d(Mm,"onSelect"),0<x.length&&(u=new go("onSelect","select",null,u,g),l.push({event:u,listeners:x}),u.target=ki)))}function Ad(l,u){var g={};return g[l.toLowerCase()]=u.toLowerCase(),g["Webkit"+l]="webkit"+u,g["Moz"+l]="moz"+u,g}var ji={animationend:Ad("Animation","AnimationEnd"),animationiteration:Ad("Animation","AnimationIteration"),animationstart:Ad("Animation","AnimationStart"),transitionend:Ad("Transition","TransitionEnd")},Lm={},hS={};c&&(hS=document.createElement("div").style,"AnimationEvent"in window||(delete ji.animationend.animation,delete ji.animationiteration.animation,delete ji.animationstart.animation),"TransitionEvent"in window||delete ji.transitionend.transition);function Rd(l){if(Lm[l])return Lm[l];if(!ji[l])return l;var u=ji[l],g;for(g in u)if(u.hasOwnProperty(g)&&g in hS)return Lm[l]=u[g];return l}var fS=Rd("animationend"),pS=Rd("animationiteration"),mS=Rd("animationstart"),gS=Rd("transitionend"),yS=new Map,wS="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 Sa(l,u){yS.set(l,u),o(u,[l])}for(var Im=0;Im<wS.length;Im++){var Om=wS[Im],C8=Om.toLowerCase(),E8=Om[0].toUpperCase()+Om.slice(1);Sa(C8,"on"+E8)}Sa(fS,"onAnimationEnd"),Sa(pS,"onAnimationIteration"),Sa(mS,"onAnimationStart"),Sa("dblclick","onDoubleClick"),Sa("focusin","onFocus"),Sa("focusout","onBlur"),Sa(gS,"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 pc="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(" "),T8=new Set("cancel close invalid load scroll toggle".split(" ").concat(pc));function xS(l,u,g){var x=l.type||"unknown-event";l.currentTarget=g,nr(x,u,void 0,l),l.currentTarget=null}function vS(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 K=x.length-1;0<=K;K--){var ee=x[K],ne=ee.instance,de=ee.currentTarget;if(ee=ee.listener,ne!==R&&C.isPropagationStopped())break e;xS(C,ee,de),R=ne}else for(K=0;K<x.length;K++){if(ee=x[K],ne=ee.instance,de=ee.currentTarget,ee=ee.listener,ne!==R&&C.isPropagationStopped())break e;xS(C,ee,de),R=ne}}}if(Et)throw l=es,Et=!1,es=null,l}function bt(l,u){var g=u[Hm];g===void 0&&(g=u[Hm]=new Set);var x=l+"__bubble";g.has(x)||(bS(u,l,2,!1),g.add(x))}function Pm(l,u,g){var x=0;u&&(x|=4),bS(g,l,x,u)}var Md="_reactListening"+Math.random().toString(36).slice(2);function mc(l){if(!l[Md]){l[Md]=!0,s.forEach(function(g){g!=="selectionchange"&&(T8.has(g)||Pm(g,!1,l),Pm(g,!0,l))});var u=l.nodeType===9?l:l.ownerDocument;u===null||u[Md]||(u[Md]=!0,Pm("selectionchange",!1,u))}}function bS(l,u,g,x){switch(pd(u)){case 1:var C=fd;break;case 4:C=xm;break;default:C=ec}g=C.bind(null,u,g,l),C=void 0,!Un||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 Dm(l,u,g,x,C){var R=x;if((u&1)===0&&(u&2)===0&&x!==null)e:for(;;){if(x===null)return;var K=x.tag;if(K===3||K===4){var ee=x.stateNode.containerInfo;if(ee===C||ee.nodeType===8&&ee.parentNode===C)break;if(K===4)for(K=x.return;K!==null;){var ne=K.tag;if((ne===3||ne===4)&&(ne=K.stateNode.containerInfo,ne===C||ne.nodeType===8&&ne.parentNode===C))return;K=K.return}for(;ee!==null;){if(K=xo(ee),K===null)return;if(ne=K.tag,ne===5||ne===6){x=R=K;continue e}ee=ee.parentNode}}x=x.return}Es(function(){var de=R,be=jt(g),ke=[];e:{var ve=yS.get(l);if(ve!==void 0){var Ee=go,Me=l;switch(l){case"keypress":if(mo(g)===0)break e;case"keydown":case"keyup":Ee=ja;break;case"focusin":Me="focus",Ee=sc;break;case"focusout":Me="blur",Ee=sc;break;case"beforeblur":case"afterblur":Ee=sc;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=yd;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Ee=wd;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Ee=Or;break;case fS:case pS:case mS:Ee=rc;break;case gS:Ee=Nd;break;case"scroll":Ee=gi;break;case"wheel":Ee=ic;break;case"copy":case"cut":case"paste":Ee=bm;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Ee=bi}var Le=(u&4)!==0,Ot=!Le&&l==="scroll",oe=Le?ve!==null?ve+"Capture":null:ve;Le=[];for(var se=de,le;se!==null;){le=se;var Se=le.stateNode;if(le.tag===5&&Se!==null&&(le=Se,oe!==null&&(Se=fn(se,oe),Se!=null&&Le.push(gc(se,Se,le)))),Ot)break;se=se.return}0<Le.length&&(ve=new Ee(ve,Me,null,g,be),ke.push({event:ve,listeners:Le}))}}if((u&7)===0){e:{if(ve=l==="mouseover"||l==="pointerover",Ee=l==="mouseout"||l==="pointerout",ve&&g!==rt&&(Me=g.relatedTarget||g.fromElement)&&(xo(Me)||Me[Dr]))break e;if((Ee||ve)&&(ve=be.window===be?be:(ve=be.ownerDocument)?ve.defaultView||ve.parentWindow:window,Ee?(Me=g.relatedTarget||g.toElement,Ee=de,Me=Me?xo(Me):null,Me!==null&&(Ot=mn(Me),Me!==Ot||Me.tag!==5&&Me.tag!==6)&&(Me=null)):(Ee=null,Me=de),Ee!==Me)){if(Le=yd,Se="onMouseLeave",oe="onMouseEnter",se="mouse",(l==="pointerout"||l==="pointerover")&&(Le=bi,Se="onPointerLeave",oe="onPointerEnter",se="pointer"),Ot=Ee==null?ve:_i(Ee),le=Me==null?ve:_i(Me),ve=new Le(Se,se+"leave",Ee,g,be),ve.target=Ot,ve.relatedTarget=le,Se=null,xo(be)===de&&(Le=new Le(oe,se+"enter",Me,g,be),Le.target=le,Le.relatedTarget=Ot,Se=Le),Ot=Se,Ee&&Me)t:{for(Le=Ee,oe=Me,se=0,le=Le;le;le=Ni(le))se++;for(le=0,Se=oe;Se;Se=Ni(Se))le++;for(;0<se-le;)Le=Ni(Le),se--;for(;0<le-se;)oe=Ni(oe),le--;for(;se--;){if(Le===oe||oe!==null&&Le===oe.alternate)break t;Le=Ni(Le),oe=Ni(oe)}Le=null}else Le=null;Ee!==null&&kS(ke,ve,Ee,Le,!1),Me!==null&&Ot!==null&&kS(ke,Ot,Me,Le,!0)}}e:{if(ve=de?_i(de):window,Ee=ve.nodeName&&ve.nodeName.toLowerCase(),Ee==="select"||Ee==="input"&&ve.type==="file")var Oe=x8;else if(gt(ve))if(sS)Oe=j8;else{Oe=b8;var Fe=v8}else(Ee=ve.nodeName)&&Ee.toLowerCase()==="input"&&(ve.type==="checkbox"||ve.type==="radio")&&(Oe=k8);if(Oe&&(Oe=Oe(l,de))){Pr(ke,Oe,g,be);break e}Fe&&Fe(l,ve,de),l==="focusout"&&(Fe=ve._wrapperState)&&Fe.controlled&&ve.type==="number"&&xe(ve,"number",ve.value)}switch(Fe=de?_i(de):window,l){case"focusin":(gt(Fe)||Fe.contentEditable==="true")&&(ki=Fe,Mm=de,fc=null);break;case"focusout":fc=Mm=ki=null;break;case"mousedown":$m=!0;break;case"contextmenu":case"mouseup":case"dragend":$m=!1,dS(ke,g,be);break;case"selectionchange":if(_8)break;case"keydown":case"keyup":dS(ke,g,be)}var Be;if(lc)e:{switch(l){case"compositionstart":var Ve="onCompositionStart";break e;case"compositionend":Ve="onCompositionEnd";break e;case"compositionupdate":Ve="onCompositionUpdate";break e}Ve=void 0}else Na?Sn(l,g)&&(Ve="onCompositionEnd"):l==="keydown"&&g.keyCode===229&&(Ve="onCompositionStart");Ve&&(cc&&g.locale!=="ko"&&(Na||Ve!=="onCompositionStart"?Ve==="onCompositionEnd"&&Na&&(Be=md()):(Is=be,tc="value"in Is?Is.value:Is.textContent,Na=!0)),Fe=$d(de,Ve),0<Fe.length&&(Ve=new vd(Ve,l,null,g,be),ke.push({event:Ve,listeners:Fe}),Be?Ve.data=Be:(Be=Cd(g),Be!==null&&(Ve.data=Be)))),(Be=_m?Cm(l,g):Em(l,g))&&(de=$d(de,"onBeforeInput"),0<de.length&&(be=new vd("onBeforeInput","beforeinput",null,g,be),ke.push({event:be,listeners:de}),be.data=Be))}vS(ke,u)})}function gc(l,u,g){return{instance:l,listener:u,currentTarget:g}}function $d(l,u){for(var g=u+"Capture",x=[];l!==null;){var C=l,R=C.stateNode;C.tag===5&&R!==null&&(C=R,R=fn(l,g),R!=null&&x.unshift(gc(l,R,C)),R=fn(l,u),R!=null&&x.push(gc(l,R,C))),l=l.return}return x}function Ni(l){if(l===null)return null;do l=l.return;while(l&&l.tag!==5);return l||null}function kS(l,u,g,x,C){for(var R=u._reactName,K=[];g!==null&&g!==x;){var ee=g,ne=ee.alternate,de=ee.stateNode;if(ne!==null&&ne===x)break;ee.tag===5&&de!==null&&(ee=de,C?(ne=fn(g,R),ne!=null&&K.unshift(gc(g,ne,ee))):C||(ne=fn(g,R),ne!=null&&K.push(gc(g,ne,ee)))),g=g.return}K.length!==0&&l.push({event:u,listeners:K})}var A8=/\r\n?/g,R8=/\u0000|\uFFFD/g;function jS(l){return(typeof l=="string"?l:""+l).replace(A8,`
38
+ `).replace(R8,"")}function Ld(l,u,g){if(u=jS(u),jS(l)!==u&&g)throw Error(n(425))}function Id(){}var Fm=null,Bm=null;function qm(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 Um=typeof setTimeout=="function"?setTimeout:void 0,M8=typeof clearTimeout=="function"?clearTimeout:void 0,NS=typeof Promise=="function"?Promise:void 0,$8=typeof queueMicrotask=="function"?queueMicrotask:typeof NS<"u"?function(l){return NS.resolve(null).then(l).catch(L8)}:Um;function L8(l){setTimeout(function(){throw l})}function Wm(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),fo(u);return}x--}else g!=="$"&&g!=="$?"&&g!=="$!"||x++;g=C}while(g);fo(u)}function _a(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 SS(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 Si=Math.random().toString(36).slice(2),ur="__reactFiber$"+Si,yc="__reactProps$"+Si,Dr="__reactContainer$"+Si,Hm="__reactEvents$"+Si,I8="__reactListeners$"+Si,O8="__reactHandles$"+Si;function xo(l){var u=l[ur];if(u)return u;for(var g=l.parentNode;g;){if(u=g[Dr]||g[ur]){if(g=u.alternate,u.child!==null||g!==null&&g.child!==null)for(l=SS(l);l!==null;){if(g=l[ur])return g;l=SS(l)}return u}l=g,g=l.parentNode}return null}function wc(l){return l=l[ur]||l[Dr],!l||l.tag!==5&&l.tag!==6&&l.tag!==13&&l.tag!==3?null:l}function _i(l){if(l.tag===5||l.tag===6)return l.stateNode;throw Error(n(33))}function Od(l){return l[yc]||null}var zm=[],Ci=-1;function Ca(l){return{current:l}}function kt(l){0>Ci||(l.current=zm[Ci],zm[Ci]=null,Ci--)}function yt(l,u){Ci++,zm[Ci]=l.current,l.current=u}var Ea={},cn=Ca(Ea),_n=Ca(!1),vo=Ea;function Ei(l,u){var g=l.type.contextTypes;if(!g)return Ea;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 Cn(l){return l=l.childContextTypes,l!=null}function Pd(){kt(_n),kt(cn)}function _S(l,u,g){if(cn.current!==Ea)throw Error(n(168));yt(cn,u),yt(_n,g)}function CS(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,J(l)||"Unknown",C));return F({},g,x)}function Dd(l){return l=(l=l.stateNode)&&l.__reactInternalMemoizedMergedChildContext||Ea,vo=cn.current,yt(cn,l),yt(_n,_n.current),!0}function ES(l,u,g){var x=l.stateNode;if(!x)throw Error(n(169));g?(l=CS(l,u,vo),x.__reactInternalMemoizedMergedChildContext=l,kt(_n),kt(cn),yt(cn,l)):kt(_n),yt(_n,g)}var Fr=null,Fd=!1,Vm=!1;function TS(l){Fr===null?Fr=[l]:Fr.push(l)}function P8(l){Fd=!0,TS(l)}function Ta(){if(!Vm&&Fr!==null){Vm=!0;var l=0,u=at;try{var g=Fr;for(at=1;l<g.length;l++){var x=g[l];do x=x(!0);while(x!==null)}Fr=null,Fd=!1}catch(C){throw Fr!==null&&(Fr=Fr.slice(l+1)),rr(Tr,Ta),C}finally{at=u,Vm=!1}}return null}var Ti=[],Ai=0,Bd=null,qd=0,cs=[],us=0,bo=null,Br=1,qr="";function ko(l,u){Ti[Ai++]=qd,Ti[Ai++]=Bd,Bd=l,qd=u}function AS(l,u,g){cs[us++]=Br,cs[us++]=qr,cs[us++]=bo,bo=l;var x=Br;l=qr;var C=32-on(x)-1;x&=~(1<<C),g+=1;var R=32-on(u)+C;if(30<R){var K=C-C%5;R=(x&(1<<K)-1).toString(32),x>>=K,C-=K,Br=1<<32-on(u)+C|g<<C|x,qr=R+l}else Br=1<<R|g<<C|x,qr=l}function Gm(l){l.return!==null&&(ko(l,1),AS(l,1,0))}function Km(l){for(;l===Bd;)Bd=Ti[--Ai],Ti[Ai]=null,qd=Ti[--Ai],Ti[Ai]=null;for(;l===bo;)bo=cs[--us],cs[us]=null,qr=cs[--us],cs[us]=null,Br=cs[--us],cs[us]=null}var Hn=null,zn=null,St=!1,Ps=null;function RS(l,u){var g=ps(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 MS(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,Hn=l,zn=_a(u.firstChild),!0):!1;case 6:return u=l.pendingProps===""||u.nodeType!==3?null:u,u!==null?(l.stateNode=u,Hn=l,zn=null,!0):!1;case 13:return u=u.nodeType!==8?null:u,u!==null?(g=bo!==null?{id:Br,overflow:qr}:null,l.memoizedState={dehydrated:u,treeContext:g,retryLane:1073741824},g=ps(18,null,null,0),g.stateNode=u,g.return=l,l.child=g,Hn=l,zn=null,!0):!1;default:return!1}}function Ym(l){return(l.mode&1)!==0&&(l.flags&128)===0}function Xm(l){if(St){var u=zn;if(u){var g=u;if(!MS(l,u)){if(Ym(l))throw Error(n(418));u=_a(g.nextSibling);var x=Hn;u&&MS(l,u)?RS(x,g):(l.flags=l.flags&-4097|2,St=!1,Hn=l)}}else{if(Ym(l))throw Error(n(418));l.flags=l.flags&-4097|2,St=!1,Hn=l}}}function $S(l){for(l=l.return;l!==null&&l.tag!==5&&l.tag!==3&&l.tag!==13;)l=l.return;Hn=l}function Ud(l){if(l!==Hn)return!1;if(!St)return $S(l),St=!0,!1;var u;if((u=l.tag!==3)&&!(u=l.tag!==5)&&(u=l.type,u=u!=="head"&&u!=="body"&&!qm(l.type,l.memoizedProps)),u&&(u=zn)){if(Ym(l))throw LS(),Error(n(418));for(;u;)RS(l,u),u=_a(u.nextSibling)}if($S(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){zn=_a(l.nextSibling);break e}u--}else g!=="$"&&g!=="$!"&&g!=="$?"||u++}l=l.nextSibling}zn=null}}else zn=Hn?_a(l.stateNode.nextSibling):null;return!0}function LS(){for(var l=zn;l;)l=_a(l.nextSibling)}function Ri(){zn=Hn=null,St=!1}function Zm(l){Ps===null?Ps=[l]:Ps.push(l)}var D8=_.ReactCurrentBatchConfig;function xc(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(K){var ee=C.refs;K===null?delete ee[R]:ee[R]=K},u._stringRef=R,u)}if(typeof l!="string")throw Error(n(284));if(!g._owner)throw Error(n(290,l))}return l}function Wd(l,u){throw l=Object.prototype.toString.call(u),Error(n(31,l==="[object Object]"?"object with keys {"+Object.keys(u).join(", ")+"}":l))}function IS(l){var u=l._init;return u(l._payload)}function OS(l){function u(oe,se){if(l){var le=oe.deletions;le===null?(oe.deletions=[se],oe.flags|=16):le.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=Pa(oe,se),oe.index=0,oe.sibling=null,oe}function R(oe,se,le){return oe.index=le,l?(le=oe.alternate,le!==null?(le=le.index,le<se?(oe.flags|=2,se):le):(oe.flags|=2,se)):(oe.flags|=1048576,se)}function K(oe){return l&&oe.alternate===null&&(oe.flags|=2),oe}function ee(oe,se,le,Se){return se===null||se.tag!==6?(se=Ug(le,oe.mode,Se),se.return=oe,se):(se=C(se,le),se.return=oe,se)}function ne(oe,se,le,Se){var Oe=le.type;return Oe===A?be(oe,se,le.props.children,Se,le.key):se!==null&&(se.elementType===Oe||typeof Oe=="object"&&Oe!==null&&Oe.$$typeof===B&&IS(Oe)===se.type)?(Se=C(se,le.props),Se.ref=xc(oe,se,le),Se.return=oe,Se):(Se=fh(le.type,le.key,le.props,null,oe.mode,Se),Se.ref=xc(oe,se,le),Se.return=oe,Se)}function de(oe,se,le,Se){return se===null||se.tag!==4||se.stateNode.containerInfo!==le.containerInfo||se.stateNode.implementation!==le.implementation?(se=Wg(le,oe.mode,Se),se.return=oe,se):(se=C(se,le.children||[]),se.return=oe,se)}function be(oe,se,le,Se,Oe){return se===null||se.tag!==7?(se=Ao(le,oe.mode,Se,Oe),se.return=oe,se):(se=C(se,le),se.return=oe,se)}function ke(oe,se,le){if(typeof se=="string"&&se!==""||typeof se=="number")return se=Ug(""+se,oe.mode,le),se.return=oe,se;if(typeof se=="object"&&se!==null){switch(se.$$typeof){case T:return le=fh(se.type,se.key,se.props,null,oe.mode,le),le.ref=xc(oe,null,se),le.return=oe,le;case L:return se=Wg(se,oe.mode,le),se.return=oe,se;case B:var Se=se._init;return ke(oe,Se(se._payload),le)}if(_e(se)||z(se))return se=Ao(se,oe.mode,le,null),se.return=oe,se;Wd(oe,se)}return null}function ve(oe,se,le,Se){var Oe=se!==null?se.key:null;if(typeof le=="string"&&le!==""||typeof le=="number")return Oe!==null?null:ee(oe,se,""+le,Se);if(typeof le=="object"&&le!==null){switch(le.$$typeof){case T:return le.key===Oe?ne(oe,se,le,Se):null;case L:return le.key===Oe?de(oe,se,le,Se):null;case B:return Oe=le._init,ve(oe,se,Oe(le._payload),Se)}if(_e(le)||z(le))return Oe!==null?null:be(oe,se,le,Se,null);Wd(oe,le)}return null}function Ee(oe,se,le,Se,Oe){if(typeof Se=="string"&&Se!==""||typeof Se=="number")return oe=oe.get(le)||null,ee(se,oe,""+Se,Oe);if(typeof Se=="object"&&Se!==null){switch(Se.$$typeof){case T:return oe=oe.get(Se.key===null?le:Se.key)||null,ne(se,oe,Se,Oe);case L:return oe=oe.get(Se.key===null?le:Se.key)||null,de(se,oe,Se,Oe);case B:var Fe=Se._init;return Ee(oe,se,le,Fe(Se._payload),Oe)}if(_e(Se)||z(Se))return oe=oe.get(le)||null,be(se,oe,Se,Oe,null);Wd(se,Se)}return null}function Me(oe,se,le,Se){for(var Oe=null,Fe=null,Be=se,Ve=se=0,en=null;Be!==null&&Ve<le.length;Ve++){Be.index>Ve?(en=Be,Be=null):en=Be.sibling;var ct=ve(oe,Be,le[Ve],Se);if(ct===null){Be===null&&(Be=en);break}l&&Be&&ct.alternate===null&&u(oe,Be),se=R(ct,se,Ve),Fe===null?Oe=ct:Fe.sibling=ct,Fe=ct,Be=en}if(Ve===le.length)return g(oe,Be),St&&ko(oe,Ve),Oe;if(Be===null){for(;Ve<le.length;Ve++)Be=ke(oe,le[Ve],Se),Be!==null&&(se=R(Be,se,Ve),Fe===null?Oe=Be:Fe.sibling=Be,Fe=Be);return St&&ko(oe,Ve),Oe}for(Be=x(oe,Be);Ve<le.length;Ve++)en=Ee(Be,oe,Ve,le[Ve],Se),en!==null&&(l&&en.alternate!==null&&Be.delete(en.key===null?Ve:en.key),se=R(en,se,Ve),Fe===null?Oe=en:Fe.sibling=en,Fe=en);return l&&Be.forEach(function(Da){return u(oe,Da)}),St&&ko(oe,Ve),Oe}function Le(oe,se,le,Se){var Oe=z(le);if(typeof Oe!="function")throw Error(n(150));if(le=Oe.call(le),le==null)throw Error(n(151));for(var Fe=Oe=null,Be=se,Ve=se=0,en=null,ct=le.next();Be!==null&&!ct.done;Ve++,ct=le.next()){Be.index>Ve?(en=Be,Be=null):en=Be.sibling;var Da=ve(oe,Be,ct.value,Se);if(Da===null){Be===null&&(Be=en);break}l&&Be&&Da.alternate===null&&u(oe,Be),se=R(Da,se,Ve),Fe===null?Oe=Da:Fe.sibling=Da,Fe=Da,Be=en}if(ct.done)return g(oe,Be),St&&ko(oe,Ve),Oe;if(Be===null){for(;!ct.done;Ve++,ct=le.next())ct=ke(oe,ct.value,Se),ct!==null&&(se=R(ct,se,Ve),Fe===null?Oe=ct:Fe.sibling=ct,Fe=ct);return St&&ko(oe,Ve),Oe}for(Be=x(oe,Be);!ct.done;Ve++,ct=le.next())ct=Ee(Be,oe,Ve,ct.value,Se),ct!==null&&(l&&ct.alternate!==null&&Be.delete(ct.key===null?Ve:ct.key),se=R(ct,se,Ve),Fe===null?Oe=ct:Fe.sibling=ct,Fe=ct);return l&&Be.forEach(function(yB){return u(oe,yB)}),St&&ko(oe,Ve),Oe}function Ot(oe,se,le,Se){if(typeof le=="object"&&le!==null&&le.type===A&&le.key===null&&(le=le.props.children),typeof le=="object"&&le!==null){switch(le.$$typeof){case T:e:{for(var Oe=le.key,Fe=se;Fe!==null;){if(Fe.key===Oe){if(Oe=le.type,Oe===A){if(Fe.tag===7){g(oe,Fe.sibling),se=C(Fe,le.props.children),se.return=oe,oe=se;break e}}else if(Fe.elementType===Oe||typeof Oe=="object"&&Oe!==null&&Oe.$$typeof===B&&IS(Oe)===Fe.type){g(oe,Fe.sibling),se=C(Fe,le.props),se.ref=xc(oe,Fe,le),se.return=oe,oe=se;break e}g(oe,Fe);break}else u(oe,Fe);Fe=Fe.sibling}le.type===A?(se=Ao(le.props.children,oe.mode,Se,le.key),se.return=oe,oe=se):(Se=fh(le.type,le.key,le.props,null,oe.mode,Se),Se.ref=xc(oe,se,le),Se.return=oe,oe=Se)}return K(oe);case L:e:{for(Fe=le.key;se!==null;){if(se.key===Fe)if(se.tag===4&&se.stateNode.containerInfo===le.containerInfo&&se.stateNode.implementation===le.implementation){g(oe,se.sibling),se=C(se,le.children||[]),se.return=oe,oe=se;break e}else{g(oe,se);break}else u(oe,se);se=se.sibling}se=Wg(le,oe.mode,Se),se.return=oe,oe=se}return K(oe);case B:return Fe=le._init,Ot(oe,se,Fe(le._payload),Se)}if(_e(le))return Me(oe,se,le,Se);if(z(le))return Le(oe,se,le,Se);Wd(oe,le)}return typeof le=="string"&&le!==""||typeof le=="number"?(le=""+le,se!==null&&se.tag===6?(g(oe,se.sibling),se=C(se,le),se.return=oe,oe=se):(g(oe,se),se=Ug(le,oe.mode,Se),se.return=oe,oe=se),K(oe)):g(oe,se)}return Ot}var Mi=OS(!0),PS=OS(!1),Hd=Ca(null),zd=null,$i=null,Jm=null;function Qm(){Jm=$i=zd=null}function eg(l){var u=Hd.current;kt(Hd),l._currentValue=u}function tg(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 Li(l,u){zd=l,Jm=$i=null,l=l.dependencies,l!==null&&l.firstContext!==null&&((l.lanes&u)!==0&&(En=!0),l.firstContext=null)}function ds(l){var u=l._currentValue;if(Jm!==l)if(l={context:l,memoizedValue:u,next:null},$i===null){if(zd===null)throw Error(n(308));$i=l,zd.dependencies={lanes:0,firstContext:l}}else $i=$i.next=l;return u}var jo=null;function ng(l){jo===null?jo=[l]:jo.push(l)}function DS(l,u,g,x){var C=u.interleaved;return C===null?(g.next=g,ng(u)):(g.next=C.next,C.next=g),u.interleaved=g,Ur(l,x)}function Ur(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 Aa=!1;function sg(l){l.updateQueue={baseState:l.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function FS(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 Wr(l,u){return{eventTime:l,lane:u,tag:0,payload:null,callback:null,next:null}}function Ra(l,u,g){var x=l.updateQueue;if(x===null)return null;if(x=x.shared,(it&2)!==0){var C=x.pending;return C===null?u.next=u:(u.next=C.next,C.next=u),x.pending=u,Ur(l,g)}return C=x.interleaved,C===null?(u.next=u,ng(x)):(u.next=C.next,C.next=u),x.interleaved=u,Ur(l,g)}function Vd(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,ga(l,g)}}function BS(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 K={eventTime:g.eventTime,lane:g.lane,tag:g.tag,payload:g.payload,callback:g.callback,next:null};R===null?C=R=K:R=R.next=K,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 Gd(l,u,g,x){var C=l.updateQueue;Aa=!1;var R=C.firstBaseUpdate,K=C.lastBaseUpdate,ee=C.shared.pending;if(ee!==null){C.shared.pending=null;var ne=ee,de=ne.next;ne.next=null,K===null?R=de:K.next=de,K=ne;var be=l.alternate;be!==null&&(be=be.updateQueue,ee=be.lastBaseUpdate,ee!==K&&(ee===null?be.firstBaseUpdate=de:ee.next=de,be.lastBaseUpdate=ne))}if(R!==null){var ke=C.baseState;K=0,be=de=ne=null,ee=R;do{var ve=ee.lane,Ee=ee.eventTime;if((x&ve)===ve){be!==null&&(be=be.next={eventTime:Ee,lane:0,tag:ee.tag,payload:ee.payload,callback:ee.callback,next:null});e:{var Me=l,Le=ee;switch(ve=u,Ee=g,Le.tag){case 1:if(Me=Le.payload,typeof Me=="function"){ke=Me.call(Ee,ke,ve);break e}ke=Me;break e;case 3:Me.flags=Me.flags&-65537|128;case 0:if(Me=Le.payload,ve=typeof Me=="function"?Me.call(Ee,ke,ve):Me,ve==null)break e;ke=F({},ke,ve);break e;case 2:Aa=!0}}ee.callback!==null&&ee.lane!==0&&(l.flags|=64,ve=C.effects,ve===null?C.effects=[ee]:ve.push(ee))}else Ee={eventTime:Ee,lane:ve,tag:ee.tag,payload:ee.payload,callback:ee.callback,next:null},be===null?(de=be=Ee,ne=ke):be=be.next=Ee,K|=ve;if(ee=ee.next,ee===null){if(ee=C.shared.pending,ee===null)break;ve=ee,ee=ve.next,ve.next=null,C.lastBaseUpdate=ve,C.shared.pending=null}}while(!0);if(be===null&&(ne=ke),C.baseState=ne,C.firstBaseUpdate=de,C.lastBaseUpdate=be,u=C.shared.interleaved,u!==null){C=u;do K|=C.lane,C=C.next;while(C!==u)}else R===null&&(C.shared.lanes=0);_o|=K,l.lanes=K,l.memoizedState=ke}}function qS(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 vc={},dr=Ca(vc),bc=Ca(vc),kc=Ca(vc);function No(l){if(l===vc)throw Error(n(174));return l}function rg(l,u){switch(yt(kc,u),yt(bc,l),yt(dr,vc),l=u.nodeType,l){case 9:case 11:u=(u=u.documentElement)?u.namespaceURI:Qe(null,"");break;default:l=l===8?u.parentNode:u,u=l.namespaceURI||null,l=l.tagName,u=Qe(u,l)}kt(dr),yt(dr,u)}function Ii(){kt(dr),kt(bc),kt(kc)}function US(l){No(kc.current);var u=No(dr.current),g=Qe(u,l.type);u!==g&&(yt(bc,l),yt(dr,g))}function ag(l){bc.current===l&&(kt(dr),kt(bc))}var Tt=Ca(0);function Kd(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 og=[];function ig(){for(var l=0;l<og.length;l++)og[l]._workInProgressVersionPrimary=null;og.length=0}var Yd=_.ReactCurrentDispatcher,lg=_.ReactCurrentBatchConfig,So=0,At=null,Ht=null,Jt=null,Xd=!1,jc=!1,Nc=0,F8=0;function un(){throw Error(n(321))}function cg(l,u){if(u===null)return!1;for(var g=0;g<u.length&&g<l.length;g++)if(!Os(l[g],u[g]))return!1;return!0}function ug(l,u,g,x,C,R){if(So=R,At=u,u.memoizedState=null,u.updateQueue=null,u.lanes=0,Yd.current=l===null||l.memoizedState===null?W8:H8,l=g(x,C),jc){R=0;do{if(jc=!1,Nc=0,25<=R)throw Error(n(301));R+=1,Jt=Ht=null,u.updateQueue=null,Yd.current=z8,l=g(x,C)}while(jc)}if(Yd.current=Qd,u=Ht!==null&&Ht.next!==null,So=0,Jt=Ht=At=null,Xd=!1,u)throw Error(n(300));return l}function dg(){var l=Nc!==0;return Nc=0,l}function hr(){var l={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return Jt===null?At.memoizedState=Jt=l:Jt=Jt.next=l,Jt}function hs(){if(Ht===null){var l=At.alternate;l=l!==null?l.memoizedState:null}else l=Ht.next;var u=Jt===null?At.memoizedState:Jt.next;if(u!==null)Jt=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},Jt===null?At.memoizedState=Jt=l:Jt=Jt.next=l}return Jt}function Sc(l,u){return typeof u=="function"?u(l):u}function hg(l){var u=hs(),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 K=C.next;C.next=R.next,R.next=K}x.baseQueue=C=R,g.pending=null}if(C!==null){R=C.next,x=x.baseState;var ee=K=null,ne=null,de=R;do{var be=de.lane;if((So&be)===be)ne!==null&&(ne=ne.next={lane:0,action:de.action,hasEagerState:de.hasEagerState,eagerState:de.eagerState,next:null}),x=de.hasEagerState?de.eagerState:l(x,de.action);else{var ke={lane:be,action:de.action,hasEagerState:de.hasEagerState,eagerState:de.eagerState,next:null};ne===null?(ee=ne=ke,K=x):ne=ne.next=ke,At.lanes|=be,_o|=be}de=de.next}while(de!==null&&de!==R);ne===null?K=x:ne.next=ee,Os(x,u.memoizedState)||(En=!0),u.memoizedState=x,u.baseState=K,u.baseQueue=ne,g.lastRenderedState=x}if(l=g.interleaved,l!==null){C=l;do R=C.lane,At.lanes|=R,_o|=R,C=C.next;while(C!==l)}else C===null&&(g.lanes=0);return[u.memoizedState,g.dispatch]}function fg(l){var u=hs(),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 K=C=C.next;do R=l(R,K.action),K=K.next;while(K!==C);Os(R,u.memoizedState)||(En=!0),u.memoizedState=R,u.baseQueue===null&&(u.baseState=R),g.lastRenderedState=R}return[R,x]}function WS(){}function HS(l,u){var g=At,x=hs(),C=u(),R=!Os(x.memoizedState,C);if(R&&(x.memoizedState=C,En=!0),x=x.queue,pg(GS.bind(null,g,x,l),[l]),x.getSnapshot!==u||R||Jt!==null&&Jt.memoizedState.tag&1){if(g.flags|=2048,_c(9,VS.bind(null,g,x,C,u),void 0,null),Qt===null)throw Error(n(349));(So&30)!==0||zS(g,u,C)}return C}function zS(l,u,g){l.flags|=16384,l={getSnapshot:u,value:g},u=At.updateQueue,u===null?(u={lastEffect:null,stores:null},At.updateQueue=u,u.stores=[l]):(g=u.stores,g===null?u.stores=[l]:g.push(l))}function VS(l,u,g,x){u.value=g,u.getSnapshot=x,KS(u)&&YS(l)}function GS(l,u,g){return g(function(){KS(u)&&YS(l)})}function KS(l){var u=l.getSnapshot;l=l.value;try{var g=u();return!Os(l,g)}catch{return!0}}function YS(l){var u=Ur(l,1);u!==null&&qs(u,l,1,-1)}function XS(l){var u=hr();return typeof l=="function"&&(l=l()),u.memoizedState=u.baseState=l,l={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Sc,lastRenderedState:l},u.queue=l,l=l.dispatch=U8.bind(null,At,l),[u.memoizedState,l]}function _c(l,u,g,x){return l={tag:l,create:u,destroy:g,deps:x,next:null},u=At.updateQueue,u===null?(u={lastEffect:null,stores:null},At.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 ZS(){return hs().memoizedState}function Zd(l,u,g,x){var C=hr();At.flags|=l,C.memoizedState=_c(1|u,g,void 0,x===void 0?null:x)}function Jd(l,u,g,x){var C=hs();x=x===void 0?null:x;var R=void 0;if(Ht!==null){var K=Ht.memoizedState;if(R=K.destroy,x!==null&&cg(x,K.deps)){C.memoizedState=_c(u,g,R,x);return}}At.flags|=l,C.memoizedState=_c(1|u,g,R,x)}function JS(l,u){return Zd(8390656,8,l,u)}function pg(l,u){return Jd(2048,8,l,u)}function QS(l,u){return Jd(4,2,l,u)}function e_(l,u){return Jd(4,4,l,u)}function t_(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 n_(l,u,g){return g=g!=null?g.concat([l]):null,Jd(4,4,t_.bind(null,u,l),g)}function mg(){}function s_(l,u){var g=hs();u=u===void 0?null:u;var x=g.memoizedState;return x!==null&&u!==null&&cg(u,x[1])?x[0]:(g.memoizedState=[l,u],l)}function r_(l,u){var g=hs();u=u===void 0?null:u;var x=g.memoizedState;return x!==null&&u!==null&&cg(u,x[1])?x[0]:(l=l(),g.memoizedState=[l,u],l)}function a_(l,u,g){return(So&21)===0?(l.baseState&&(l.baseState=!1,En=!0),l.memoizedState=g):(Os(g,u)||(g=Nn(),At.lanes|=g,_o|=g,l.baseState=!0),u)}function B8(l,u){var g=at;at=g!==0&&4>g?g:4,l(!0);var x=lg.transition;lg.transition={};try{l(!1),u()}finally{at=g,lg.transition=x}}function o_(){return hs().memoizedState}function q8(l,u,g){var x=Ia(l);if(g={lane:x,action:g,hasEagerState:!1,eagerState:null,next:null},i_(l))l_(u,g);else if(g=DS(l,u,g,x),g!==null){var C=yn();qs(g,l,x,C),c_(g,u,x)}}function U8(l,u,g){var x=Ia(l),C={lane:x,action:g,hasEagerState:!1,eagerState:null,next:null};if(i_(l))l_(u,C);else{var R=l.alternate;if(l.lanes===0&&(R===null||R.lanes===0)&&(R=u.lastRenderedReducer,R!==null))try{var K=u.lastRenderedState,ee=R(K,g);if(C.hasEagerState=!0,C.eagerState=ee,Os(ee,K)){var ne=u.interleaved;ne===null?(C.next=C,ng(u)):(C.next=ne.next,ne.next=C),u.interleaved=C;return}}catch{}finally{}g=DS(l,u,C,x),g!==null&&(C=yn(),qs(g,l,x,C),c_(g,u,x))}}function i_(l){var u=l.alternate;return l===At||u!==null&&u===At}function l_(l,u){jc=Xd=!0;var g=l.pending;g===null?u.next=u:(u.next=g.next,g.next=u),l.pending=u}function c_(l,u,g){if((g&4194240)!==0){var x=u.lanes;x&=l.pendingLanes,g|=x,u.lanes=g,ga(l,g)}}var Qd={readContext:ds,useCallback:un,useContext:un,useEffect:un,useImperativeHandle:un,useInsertionEffect:un,useLayoutEffect:un,useMemo:un,useReducer:un,useRef:un,useState:un,useDebugValue:un,useDeferredValue:un,useTransition:un,useMutableSource:un,useSyncExternalStore:un,useId:un,unstable_isNewReconciler:!1},W8={readContext:ds,useCallback:function(l,u){return hr().memoizedState=[l,u===void 0?null:u],l},useContext:ds,useEffect:JS,useImperativeHandle:function(l,u,g){return g=g!=null?g.concat([l]):null,Zd(4194308,4,t_.bind(null,u,l),g)},useLayoutEffect:function(l,u){return Zd(4194308,4,l,u)},useInsertionEffect:function(l,u){return Zd(4,2,l,u)},useMemo:function(l,u){var g=hr();return u=u===void 0?null:u,l=l(),g.memoizedState=[l,u],l},useReducer:function(l,u,g){var x=hr();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=q8.bind(null,At,l),[x.memoizedState,l]},useRef:function(l){var u=hr();return l={current:l},u.memoizedState=l},useState:XS,useDebugValue:mg,useDeferredValue:function(l){return hr().memoizedState=l},useTransition:function(){var l=XS(!1),u=l[0];return l=B8.bind(null,l[1]),hr().memoizedState=l,[u,l]},useMutableSource:function(){},useSyncExternalStore:function(l,u,g){var x=At,C=hr();if(St){if(g===void 0)throw Error(n(407));g=g()}else{if(g=u(),Qt===null)throw Error(n(349));(So&30)!==0||zS(x,u,g)}C.memoizedState=g;var R={value:g,getSnapshot:u};return C.queue=R,JS(GS.bind(null,x,R,l),[l]),x.flags|=2048,_c(9,VS.bind(null,x,R,g,u),void 0,null),g},useId:function(){var l=hr(),u=Qt.identifierPrefix;if(St){var g=qr,x=Br;g=(x&~(1<<32-on(x)-1)).toString(32)+g,u=":"+u+"R"+g,g=Nc++,0<g&&(u+="H"+g.toString(32)),u+=":"}else g=F8++,u=":"+u+"r"+g.toString(32)+":";return l.memoizedState=u},unstable_isNewReconciler:!1},H8={readContext:ds,useCallback:s_,useContext:ds,useEffect:pg,useImperativeHandle:n_,useInsertionEffect:QS,useLayoutEffect:e_,useMemo:r_,useReducer:hg,useRef:ZS,useState:function(){return hg(Sc)},useDebugValue:mg,useDeferredValue:function(l){var u=hs();return a_(u,Ht.memoizedState,l)},useTransition:function(){var l=hg(Sc)[0],u=hs().memoizedState;return[l,u]},useMutableSource:WS,useSyncExternalStore:HS,useId:o_,unstable_isNewReconciler:!1},z8={readContext:ds,useCallback:s_,useContext:ds,useEffect:pg,useImperativeHandle:n_,useInsertionEffect:QS,useLayoutEffect:e_,useMemo:r_,useReducer:fg,useRef:ZS,useState:function(){return fg(Sc)},useDebugValue:mg,useDeferredValue:function(l){var u=hs();return Ht===null?u.memoizedState=l:a_(u,Ht.memoizedState,l)},useTransition:function(){var l=fg(Sc)[0],u=hs().memoizedState;return[l,u]},useMutableSource:WS,useSyncExternalStore:HS,useId:o_,unstable_isNewReconciler:!1};function Ds(l,u){if(l&&l.defaultProps){u=F({},u),l=l.defaultProps;for(var g in l)u[g]===void 0&&(u[g]=l[g]);return u}return u}function gg(l,u,g,x){u=l.memoizedState,g=g(x,u),g=g==null?u:F({},u,g),l.memoizedState=g,l.lanes===0&&(l.updateQueue.baseState=g)}var eh={isMounted:function(l){return(l=l._reactInternals)?mn(l)===l:!1},enqueueSetState:function(l,u,g){l=l._reactInternals;var x=yn(),C=Ia(l),R=Wr(x,C);R.payload=u,g!=null&&(R.callback=g),u=Ra(l,R,C),u!==null&&(qs(u,l,C,x),Vd(u,l,C))},enqueueReplaceState:function(l,u,g){l=l._reactInternals;var x=yn(),C=Ia(l),R=Wr(x,C);R.tag=1,R.payload=u,g!=null&&(R.callback=g),u=Ra(l,R,C),u!==null&&(qs(u,l,C,x),Vd(u,l,C))},enqueueForceUpdate:function(l,u){l=l._reactInternals;var g=yn(),x=Ia(l),C=Wr(g,x);C.tag=2,u!=null&&(C.callback=u),u=Ra(l,C,x),u!==null&&(qs(u,l,x,g),Vd(u,l,x))}};function u_(l,u,g,x,C,R,K){return l=l.stateNode,typeof l.shouldComponentUpdate=="function"?l.shouldComponentUpdate(x,R,K):u.prototype&&u.prototype.isPureReactComponent?!hc(g,x)||!hc(C,R):!0}function d_(l,u,g){var x=!1,C=Ea,R=u.contextType;return typeof R=="object"&&R!==null?R=ds(R):(C=Cn(u)?vo:cn.current,x=u.contextTypes,R=(x=x!=null)?Ei(l,C):Ea),u=new u(g,R),l.memoizedState=u.state!==null&&u.state!==void 0?u.state:null,u.updater=eh,l.stateNode=u,u._reactInternals=l,x&&(l=l.stateNode,l.__reactInternalMemoizedUnmaskedChildContext=C,l.__reactInternalMemoizedMaskedChildContext=R),u}function h_(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&&eh.enqueueReplaceState(u,u.state,null)}function yg(l,u,g,x){var C=l.stateNode;C.props=g,C.state=l.memoizedState,C.refs={},sg(l);var R=u.contextType;typeof R=="object"&&R!==null?C.context=ds(R):(R=Cn(u)?vo:cn.current,C.context=Ei(l,R)),C.state=l.memoizedState,R=u.getDerivedStateFromProps,typeof R=="function"&&(gg(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&&eh.enqueueReplaceState(C,C.state,null),Gd(l,g,C,x),C.state=l.memoizedState),typeof C.componentDidMount=="function"&&(l.flags|=4194308)}function Oi(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 wg(l,u,g){return{value:l,source:null,stack:g??null,digest:u??null}}function xg(l,u){try{console.error(u.value)}catch(g){setTimeout(function(){throw g})}}var V8=typeof WeakMap=="function"?WeakMap:Map;function f_(l,u,g){g=Wr(-1,g),g.tag=3,g.payload={element:null};var x=u.value;return g.callback=function(){ih||(ih=!0,Lg=x),xg(l,u)},g}function p_(l,u,g){g=Wr(-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(){xg(l,u)}}var R=l.stateNode;return R!==null&&typeof R.componentDidCatch=="function"&&(g.callback=function(){xg(l,u),typeof x!="function"&&($a===null?$a=new Set([this]):$a.add(this));var K=u.stack;this.componentDidCatch(u.value,{componentStack:K!==null?K:""})}),g}function m_(l,u,g){var x=l.pingCache;if(x===null){x=l.pingCache=new V8;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=oB.bind(null,l,u,g),u.then(l,l))}function g_(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 y_(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=Wr(-1,1),u.tag=2,Ra(g,u,1))),g.lanes|=1),l):(l.flags|=65536,l.lanes=C,l)}var G8=_.ReactCurrentOwner,En=!1;function gn(l,u,g,x){u.child=l===null?PS(u,null,g,x):Mi(u,l.child,g,x)}function w_(l,u,g,x,C){g=g.render;var R=u.ref;return Li(u,C),x=ug(l,u,g,x,R,C),g=dg(),l!==null&&!En?(u.updateQueue=l.updateQueue,u.flags&=-2053,l.lanes&=~C,Hr(l,u,C)):(St&&g&&Gm(u),u.flags|=1,gn(l,u,x,C),u.child)}function x_(l,u,g,x,C){if(l===null){var R=g.type;return typeof R=="function"&&!qg(R)&&R.defaultProps===void 0&&g.compare===null&&g.defaultProps===void 0?(u.tag=15,u.type=R,v_(l,u,R,x,C)):(l=fh(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 K=R.memoizedProps;if(g=g.compare,g=g!==null?g:hc,g(K,x)&&l.ref===u.ref)return Hr(l,u,C)}return u.flags|=1,l=Pa(R,x),l.ref=u.ref,l.return=u,u.child=l}function v_(l,u,g,x,C){if(l!==null){var R=l.memoizedProps;if(hc(R,x)&&l.ref===u.ref)if(En=!1,u.pendingProps=x=R,(l.lanes&C)!==0)(l.flags&131072)!==0&&(En=!0);else return u.lanes=l.lanes,Hr(l,u,C)}return vg(l,u,g,x,C)}function b_(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},yt(Di,Vn),Vn|=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,yt(Di,Vn),Vn|=l,null;u.memoizedState={baseLanes:0,cachePool:null,transitions:null},x=R!==null?R.baseLanes:g,yt(Di,Vn),Vn|=x}else R!==null?(x=R.baseLanes|g,u.memoizedState=null):x=g,yt(Di,Vn),Vn|=x;return gn(l,u,C,g),u.child}function k_(l,u){var g=u.ref;(l===null&&g!==null||l!==null&&l.ref!==g)&&(u.flags|=512,u.flags|=2097152)}function vg(l,u,g,x,C){var R=Cn(g)?vo:cn.current;return R=Ei(u,R),Li(u,C),g=ug(l,u,g,x,R,C),x=dg(),l!==null&&!En?(u.updateQueue=l.updateQueue,u.flags&=-2053,l.lanes&=~C,Hr(l,u,C)):(St&&x&&Gm(u),u.flags|=1,gn(l,u,g,C),u.child)}function j_(l,u,g,x,C){if(Cn(g)){var R=!0;Dd(u)}else R=!1;if(Li(u,C),u.stateNode===null)nh(l,u),d_(u,g,x),yg(u,g,x,C),x=!0;else if(l===null){var K=u.stateNode,ee=u.memoizedProps;K.props=ee;var ne=K.context,de=g.contextType;typeof de=="object"&&de!==null?de=ds(de):(de=Cn(g)?vo:cn.current,de=Ei(u,de));var be=g.getDerivedStateFromProps,ke=typeof be=="function"||typeof K.getSnapshotBeforeUpdate=="function";ke||typeof K.UNSAFE_componentWillReceiveProps!="function"&&typeof K.componentWillReceiveProps!="function"||(ee!==x||ne!==de)&&h_(u,K,x,de),Aa=!1;var ve=u.memoizedState;K.state=ve,Gd(u,x,K,C),ne=u.memoizedState,ee!==x||ve!==ne||_n.current||Aa?(typeof be=="function"&&(gg(u,g,be,x),ne=u.memoizedState),(ee=Aa||u_(u,g,ee,x,ve,ne,de))?(ke||typeof K.UNSAFE_componentWillMount!="function"&&typeof K.componentWillMount!="function"||(typeof K.componentWillMount=="function"&&K.componentWillMount(),typeof K.UNSAFE_componentWillMount=="function"&&K.UNSAFE_componentWillMount()),typeof K.componentDidMount=="function"&&(u.flags|=4194308)):(typeof K.componentDidMount=="function"&&(u.flags|=4194308),u.memoizedProps=x,u.memoizedState=ne),K.props=x,K.state=ne,K.context=de,x=ee):(typeof K.componentDidMount=="function"&&(u.flags|=4194308),x=!1)}else{K=u.stateNode,FS(l,u),ee=u.memoizedProps,de=u.type===u.elementType?ee:Ds(u.type,ee),K.props=de,ke=u.pendingProps,ve=K.context,ne=g.contextType,typeof ne=="object"&&ne!==null?ne=ds(ne):(ne=Cn(g)?vo:cn.current,ne=Ei(u,ne));var Ee=g.getDerivedStateFromProps;(be=typeof Ee=="function"||typeof K.getSnapshotBeforeUpdate=="function")||typeof K.UNSAFE_componentWillReceiveProps!="function"&&typeof K.componentWillReceiveProps!="function"||(ee!==ke||ve!==ne)&&h_(u,K,x,ne),Aa=!1,ve=u.memoizedState,K.state=ve,Gd(u,x,K,C);var Me=u.memoizedState;ee!==ke||ve!==Me||_n.current||Aa?(typeof Ee=="function"&&(gg(u,g,Ee,x),Me=u.memoizedState),(de=Aa||u_(u,g,de,x,ve,Me,ne)||!1)?(be||typeof K.UNSAFE_componentWillUpdate!="function"&&typeof K.componentWillUpdate!="function"||(typeof K.componentWillUpdate=="function"&&K.componentWillUpdate(x,Me,ne),typeof K.UNSAFE_componentWillUpdate=="function"&&K.UNSAFE_componentWillUpdate(x,Me,ne)),typeof K.componentDidUpdate=="function"&&(u.flags|=4),typeof K.getSnapshotBeforeUpdate=="function"&&(u.flags|=1024)):(typeof K.componentDidUpdate!="function"||ee===l.memoizedProps&&ve===l.memoizedState||(u.flags|=4),typeof K.getSnapshotBeforeUpdate!="function"||ee===l.memoizedProps&&ve===l.memoizedState||(u.flags|=1024),u.memoizedProps=x,u.memoizedState=Me),K.props=x,K.state=Me,K.context=ne,x=de):(typeof K.componentDidUpdate!="function"||ee===l.memoizedProps&&ve===l.memoizedState||(u.flags|=4),typeof K.getSnapshotBeforeUpdate!="function"||ee===l.memoizedProps&&ve===l.memoizedState||(u.flags|=1024),x=!1)}return bg(l,u,g,x,R,C)}function bg(l,u,g,x,C,R){k_(l,u);var K=(u.flags&128)!==0;if(!x&&!K)return C&&ES(u,g,!1),Hr(l,u,R);x=u.stateNode,G8.current=u;var ee=K&&typeof g.getDerivedStateFromError!="function"?null:x.render();return u.flags|=1,l!==null&&K?(u.child=Mi(u,l.child,null,R),u.child=Mi(u,null,ee,R)):gn(l,u,ee,R),u.memoizedState=x.state,C&&ES(u,g,!0),u.child}function N_(l){var u=l.stateNode;u.pendingContext?_S(l,u.pendingContext,u.pendingContext!==u.context):u.context&&_S(l,u.context,!1),rg(l,u.containerInfo)}function S_(l,u,g,x,C){return Ri(),Zm(C),u.flags|=256,gn(l,u,g,x),u.child}var kg={dehydrated:null,treeContext:null,retryLane:0};function jg(l){return{baseLanes:l,cachePool:null,transitions:null}}function __(l,u,g){var x=u.pendingProps,C=Tt.current,R=!1,K=(u.flags&128)!==0,ee;if((ee=K)||(ee=l!==null&&l.memoizedState===null?!1:(C&2)!==0),ee?(R=!0,u.flags&=-129):(l===null||l.memoizedState!==null)&&(C|=1),yt(Tt,C&1),l===null)return Xm(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):(K=x.children,l=x.fallback,R?(x=u.mode,R=u.child,K={mode:"hidden",children:K},(x&1)===0&&R!==null?(R.childLanes=0,R.pendingProps=K):R=ph(K,x,0,null),l=Ao(l,x,g,null),R.return=u,l.return=u,R.sibling=l,u.child=R,u.child.memoizedState=jg(g),u.memoizedState=kg,l):Ng(u,K));if(C=l.memoizedState,C!==null&&(ee=C.dehydrated,ee!==null))return K8(l,u,K,x,ee,C,g);if(R){R=x.fallback,K=u.mode,C=l.child,ee=C.sibling;var ne={mode:"hidden",children:x.children};return(K&1)===0&&u.child!==C?(x=u.child,x.childLanes=0,x.pendingProps=ne,u.deletions=null):(x=Pa(C,ne),x.subtreeFlags=C.subtreeFlags&14680064),ee!==null?R=Pa(ee,R):(R=Ao(R,K,g,null),R.flags|=2),R.return=u,x.return=u,x.sibling=R,u.child=x,x=R,R=u.child,K=l.child.memoizedState,K=K===null?jg(g):{baseLanes:K.baseLanes|g,cachePool:null,transitions:K.transitions},R.memoizedState=K,R.childLanes=l.childLanes&~g,u.memoizedState=kg,x}return R=l.child,l=R.sibling,x=Pa(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 Ng(l,u){return u=ph({mode:"visible",children:u},l.mode,0,null),u.return=l,l.child=u}function th(l,u,g,x){return x!==null&&Zm(x),Mi(u,l.child,null,g),l=Ng(u,u.pendingProps.children),l.flags|=2,u.memoizedState=null,l}function K8(l,u,g,x,C,R,K){if(g)return u.flags&256?(u.flags&=-257,x=wg(Error(n(422))),th(l,u,K,x)):u.memoizedState!==null?(u.child=l.child,u.flags|=128,null):(R=x.fallback,C=u.mode,x=ph({mode:"visible",children:x.children},C,0,null),R=Ao(R,C,K,null),R.flags|=2,x.return=u,R.return=u,x.sibling=R,u.child=x,(u.mode&1)!==0&&Mi(u,l.child,null,K),u.child.memoizedState=jg(K),u.memoizedState=kg,R);if((u.mode&1)===0)return th(l,u,K,null);if(C.data==="$!"){if(x=C.nextSibling&&C.nextSibling.dataset,x)var ee=x.dgst;return x=ee,R=Error(n(419)),x=wg(R,x,void 0),th(l,u,K,x)}if(ee=(K&l.childLanes)!==0,En||ee){if(x=Qt,x!==null){switch(K&-K){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|K))!==0?0:C,C!==0&&C!==R.retryLane&&(R.retryLane=C,Ur(l,C),qs(x,l,C,-1))}return Bg(),x=wg(Error(n(421))),th(l,u,K,x)}return C.data==="$?"?(u.flags|=128,u.child=l.child,u=iB.bind(null,l),C._reactRetry=u,null):(l=R.treeContext,zn=_a(C.nextSibling),Hn=u,St=!0,Ps=null,l!==null&&(cs[us++]=Br,cs[us++]=qr,cs[us++]=bo,Br=l.id,qr=l.overflow,bo=u),u=Ng(u,x.children),u.flags|=4096,u)}function C_(l,u,g){l.lanes|=u;var x=l.alternate;x!==null&&(x.lanes|=u),tg(l.return,u,g)}function Sg(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 E_(l,u,g){var x=u.pendingProps,C=x.revealOrder,R=x.tail;if(gn(l,u,x.children,g),x=Tt.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&&C_(l,g,u);else if(l.tag===19)C_(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(yt(Tt,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&&Kd(l)===null&&(C=g),g=g.sibling;g=C,g===null?(C=u.child,u.child=null):(C=g.sibling,g.sibling=null),Sg(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&&Kd(l)===null){u.child=C;break}l=C.sibling,C.sibling=g,g=C,C=l}Sg(u,!0,g,null,R);break;case"together":Sg(u,!1,null,null,void 0);break;default:u.memoizedState=null}return u.child}function nh(l,u){(u.mode&1)===0&&l!==null&&(l.alternate=null,u.alternate=null,u.flags|=2)}function Hr(l,u,g){if(l!==null&&(u.dependencies=l.dependencies),_o|=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=Pa(l,l.pendingProps),u.child=g,g.return=u;l.sibling!==null;)l=l.sibling,g=g.sibling=Pa(l,l.pendingProps),g.return=u;g.sibling=null}return u.child}function Y8(l,u,g){switch(u.tag){case 3:N_(u),Ri();break;case 5:US(u);break;case 1:Cn(u.type)&&Dd(u);break;case 4:rg(u,u.stateNode.containerInfo);break;case 10:var x=u.type._context,C=u.memoizedProps.value;yt(Hd,x._currentValue),x._currentValue=C;break;case 13:if(x=u.memoizedState,x!==null)return x.dehydrated!==null?(yt(Tt,Tt.current&1),u.flags|=128,null):(g&u.child.childLanes)!==0?__(l,u,g):(yt(Tt,Tt.current&1),l=Hr(l,u,g),l!==null?l.sibling:null);yt(Tt,Tt.current&1);break;case 19:if(x=(g&u.childLanes)!==0,(l.flags&128)!==0){if(x)return E_(l,u,g);u.flags|=128}if(C=u.memoizedState,C!==null&&(C.rendering=null,C.tail=null,C.lastEffect=null),yt(Tt,Tt.current),x)break;return null;case 22:case 23:return u.lanes=0,b_(l,u,g)}return Hr(l,u,g)}var T_,_g,A_,R_;T_=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}},_g=function(){},A_=function(l,u,g,x){var C=l.memoizedProps;if(C!==x){l=u.stateNode,No(dr.current);var R=null;switch(g){case"input":C=fe(l,C),x=fe(l,x),R=[];break;case"select":C=F({},C,{value:void 0}),x=F({},x,{value:void 0}),R=[];break;case"textarea":C=Ie(l,C),x=Ie(l,x),R=[];break;default:typeof C.onClick!="function"&&typeof x.onClick=="function"&&(l.onclick=Id)}Ye(g,x);var K;g=null;for(de in C)if(!x.hasOwnProperty(de)&&C.hasOwnProperty(de)&&C[de]!=null)if(de==="style"){var ee=C[de];for(K in ee)ee.hasOwnProperty(K)&&(g||(g={}),g[K]="")}else de!=="dangerouslySetInnerHTML"&&de!=="children"&&de!=="suppressContentEditableWarning"&&de!=="suppressHydrationWarning"&&de!=="autoFocus"&&(a.hasOwnProperty(de)?R||(R=[]):(R=R||[]).push(de,null));for(de in x){var ne=x[de];if(ee=C!=null?C[de]:void 0,x.hasOwnProperty(de)&&ne!==ee&&(ne!=null||ee!=null))if(de==="style")if(ee){for(K in ee)!ee.hasOwnProperty(K)||ne&&ne.hasOwnProperty(K)||(g||(g={}),g[K]="");for(K in ne)ne.hasOwnProperty(K)&&ee[K]!==ne[K]&&(g||(g={}),g[K]=ne[K])}else g||(R||(R=[]),R.push(de,g)),g=ne;else de==="dangerouslySetInnerHTML"?(ne=ne?ne.__html:void 0,ee=ee?ee.__html:void 0,ne!=null&&ee!==ne&&(R=R||[]).push(de,ne)):de==="children"?typeof ne!="string"&&typeof ne!="number"||(R=R||[]).push(de,""+ne):de!=="suppressContentEditableWarning"&&de!=="suppressHydrationWarning"&&(a.hasOwnProperty(de)?(ne!=null&&de==="onScroll"&&bt("scroll",l),R||ee===ne||(R=[])):(R=R||[]).push(de,ne))}g&&(R=R||[]).push("style",g);var de=R;(u.updateQueue=de)&&(u.flags|=4)}},R_=function(l,u,g,x){g!==x&&(u.flags|=4)};function Cc(l,u){if(!St)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 dn(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 X8(l,u,g){var x=u.pendingProps;switch(Km(u),u.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return dn(u),null;case 1:return Cn(u.type)&&Pd(),dn(u),null;case 3:return x=u.stateNode,Ii(),kt(_n),kt(cn),ig(),x.pendingContext&&(x.context=x.pendingContext,x.pendingContext=null),(l===null||l.child===null)&&(Ud(u)?u.flags|=4:l===null||l.memoizedState.isDehydrated&&(u.flags&256)===0||(u.flags|=1024,Ps!==null&&(Pg(Ps),Ps=null))),_g(l,u),dn(u),null;case 5:ag(u);var C=No(kc.current);if(g=u.type,l!==null&&u.stateNode!=null)A_(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 dn(u),null}if(l=No(dr.current),Ud(u)){x=u.stateNode,g=u.type;var R=u.memoizedProps;switch(x[ur]=u,x[yc]=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<pc.length;C++)bt(pc[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":ae(x,R),bt("invalid",x);break;case"select":x._wrapperState={wasMultiple:!!R.multiple},bt("invalid",x);break;case"textarea":Pe(x,R),bt("invalid",x)}Ye(g,R),C=null;for(var K in R)if(R.hasOwnProperty(K)){var ee=R[K];K==="children"?typeof ee=="string"?x.textContent!==ee&&(R.suppressHydrationWarning!==!0&&Ld(x.textContent,ee,l),C=["children",ee]):typeof ee=="number"&&x.textContent!==""+ee&&(R.suppressHydrationWarning!==!0&&Ld(x.textContent,ee,l),C=["children",""+ee]):a.hasOwnProperty(K)&&ee!=null&&K==="onScroll"&&bt("scroll",x)}switch(g){case"input":ue(x),pe(x,R,!0);break;case"textarea":ue(x),$e(x);break;case"select":case"option":break;default:typeof R.onClick=="function"&&(x.onclick=Id)}x=C,u.updateQueue=x,x!==null&&(u.flags|=4)}else{K=C.nodeType===9?C:C.ownerDocument,l==="http://www.w3.org/1999/xhtml"&&(l=Je(g)),l==="http://www.w3.org/1999/xhtml"?g==="script"?(l=K.createElement("div"),l.innerHTML="<script><\/script>",l=l.removeChild(l.firstChild)):typeof x.is=="string"?l=K.createElement(g,{is:x.is}):(l=K.createElement(g),g==="select"&&(K=l,x.multiple?K.multiple=!0:x.size&&(K.size=x.size))):l=K.createElementNS(l,g),l[ur]=u,l[yc]=x,T_(l,u,!1,!1),u.stateNode=l;e:{switch(K=Xe(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<pc.length;C++)bt(pc[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":ae(l,x),C=fe(l,x),bt("invalid",l);break;case"option":C=x;break;case"select":l._wrapperState={wasMultiple:!!x.multiple},C=F({},x,{value:void 0}),bt("invalid",l);break;case"textarea":Pe(l,x),C=Ie(l,x),bt("invalid",l);break;default:C=x}Ye(g,C),ee=C;for(R in ee)if(ee.hasOwnProperty(R)){var ne=ee[R];R==="style"?we(l,ne):R==="dangerouslySetInnerHTML"?(ne=ne?ne.__html:void 0,ne!=null&&Ne(l,ne)):R==="children"?typeof ne=="string"?(g!=="textarea"||ne!=="")&&Ae(l,ne):typeof ne=="number"&&Ae(l,""+ne):R!=="suppressContentEditableWarning"&&R!=="suppressHydrationWarning"&&R!=="autoFocus"&&(a.hasOwnProperty(R)?ne!=null&&R==="onScroll"&&bt("scroll",l):ne!=null&&S(l,R,ne,K))}switch(g){case"input":ue(l),pe(l,x,!1);break;case"textarea":ue(l),$e(l);break;case"option":x.value!=null&&l.setAttribute("value",""+Q(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=Id)}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 dn(u),null;case 6:if(l&&u.stateNode!=null)R_(l,u,l.memoizedProps,x);else{if(typeof x!="string"&&u.stateNode===null)throw Error(n(166));if(g=No(kc.current),No(dr.current),Ud(u)){if(x=u.stateNode,g=u.memoizedProps,x[ur]=u,(R=x.nodeValue!==g)&&(l=Hn,l!==null))switch(l.tag){case 3:Ld(x.nodeValue,g,(l.mode&1)!==0);break;case 5:l.memoizedProps.suppressHydrationWarning!==!0&&Ld(x.nodeValue,g,(l.mode&1)!==0)}R&&(u.flags|=4)}else x=(g.nodeType===9?g:g.ownerDocument).createTextNode(x),x[ur]=u,u.stateNode=x}return dn(u),null;case 13:if(kt(Tt),x=u.memoizedState,l===null||l.memoizedState!==null&&l.memoizedState.dehydrated!==null){if(St&&zn!==null&&(u.mode&1)!==0&&(u.flags&128)===0)LS(),Ri(),u.flags|=98560,R=!1;else if(R=Ud(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[ur]=u}else Ri(),(u.flags&128)===0&&(u.memoizedState=null),u.flags|=4;dn(u),R=!1}else Ps!==null&&(Pg(Ps),Ps=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||(Tt.current&1)!==0?zt===0&&(zt=3):Bg())),u.updateQueue!==null&&(u.flags|=4),dn(u),null);case 4:return Ii(),_g(l,u),l===null&&mc(u.stateNode.containerInfo),dn(u),null;case 10:return eg(u.type._context),dn(u),null;case 17:return Cn(u.type)&&Pd(),dn(u),null;case 19:if(kt(Tt),R=u.memoizedState,R===null)return dn(u),null;if(x=(u.flags&128)!==0,K=R.rendering,K===null)if(x)Cc(R,!1);else{if(zt!==0||l!==null&&(l.flags&128)!==0)for(l=u.child;l!==null;){if(K=Kd(l),K!==null){for(u.flags|=128,Cc(R,!1),x=K.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,K=R.alternate,K===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=K.childLanes,R.lanes=K.lanes,R.child=K.child,R.subtreeFlags=0,R.deletions=null,R.memoizedProps=K.memoizedProps,R.memoizedState=K.memoizedState,R.updateQueue=K.updateQueue,R.type=K.type,l=K.dependencies,R.dependencies=l===null?null:{lanes:l.lanes,firstContext:l.firstContext}),g=g.sibling;return yt(Tt,Tt.current&1|2),u.child}l=l.sibling}R.tail!==null&&ht()>Fi&&(u.flags|=128,x=!0,Cc(R,!1),u.lanes=4194304)}else{if(!x)if(l=Kd(K),l!==null){if(u.flags|=128,x=!0,g=l.updateQueue,g!==null&&(u.updateQueue=g,u.flags|=4),Cc(R,!0),R.tail===null&&R.tailMode==="hidden"&&!K.alternate&&!St)return dn(u),null}else 2*ht()-R.renderingStartTime>Fi&&g!==1073741824&&(u.flags|=128,x=!0,Cc(R,!1),u.lanes=4194304);R.isBackwards?(K.sibling=u.child,u.child=K):(g=R.last,g!==null?g.sibling=K:u.child=K,R.last=K)}return R.tail!==null?(u=R.tail,R.rendering=u,R.tail=u.sibling,R.renderingStartTime=ht(),u.sibling=null,g=Tt.current,yt(Tt,x?g&1|2:g&1),u):(dn(u),null);case 22:case 23:return Fg(),x=u.memoizedState!==null,l!==null&&l.memoizedState!==null!==x&&(u.flags|=8192),x&&(u.mode&1)!==0?(Vn&1073741824)!==0&&(dn(u),u.subtreeFlags&6&&(u.flags|=8192)):dn(u),null;case 24:return null;case 25:return null}throw Error(n(156,u.tag))}function Z8(l,u){switch(Km(u),u.tag){case 1:return Cn(u.type)&&Pd(),l=u.flags,l&65536?(u.flags=l&-65537|128,u):null;case 3:return Ii(),kt(_n),kt(cn),ig(),l=u.flags,(l&65536)!==0&&(l&128)===0?(u.flags=l&-65537|128,u):null;case 5:return ag(u),null;case 13:if(kt(Tt),l=u.memoizedState,l!==null&&l.dehydrated!==null){if(u.alternate===null)throw Error(n(340));Ri()}return l=u.flags,l&65536?(u.flags=l&-65537|128,u):null;case 19:return kt(Tt),null;case 4:return Ii(),null;case 10:return eg(u.type._context),null;case 22:case 23:return Fg(),null;case 24:return null;default:return null}}var sh=!1,hn=!1,J8=typeof WeakSet=="function"?WeakSet:Set,Te=null;function Pi(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 Cg(l,u,g){try{g()}catch(x){$t(l,u,x)}}var M_=!1;function Q8(l,u){if(Fm=xa,l=uS(),Rm(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 K=0,ee=-1,ne=-1,de=0,be=0,ke=l,ve=null;t:for(;;){for(var Ee;ke!==g||C!==0&&ke.nodeType!==3||(ee=K+C),ke!==R||x!==0&&ke.nodeType!==3||(ne=K+x),ke.nodeType===3&&(K+=ke.nodeValue.length),(Ee=ke.firstChild)!==null;)ve=ke,ke=Ee;for(;;){if(ke===l)break t;if(ve===g&&++de===C&&(ee=K),ve===R&&++be===x&&(ne=K),(Ee=ke.nextSibling)!==null)break;ke=ve,ve=ke.parentNode}ke=Ee}g=ee===-1||ne===-1?null:{start:ee,end:ne}}else g=null}g=g||{start:0,end:0}}else g=null;for(Bm={focusedElem:l,selectionRange:g},xa=!1,Te=u;Te!==null;)if(u=Te,l=u.child,(u.subtreeFlags&1028)!==0&&l!==null)l.return=u,Te=l;else for(;Te!==null;){u=Te;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,Ot=Me.memoizedState,oe=u.stateNode,se=oe.getSnapshotBeforeUpdate(u.elementType===u.type?Le:Ds(u.type,Le),Ot);oe.__reactInternalSnapshotBeforeUpdate=se}break;case 3:var le=u.stateNode.containerInfo;le.nodeType===1?le.textContent="":le.nodeType===9&&le.documentElement&&le.removeChild(le.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(Se){$t(u,u.return,Se)}if(l=u.sibling,l!==null){l.return=u.return,Te=l;break}Te=u.return}return Me=M_,M_=!1,Me}function Ec(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&&Cg(u,g,R)}C=C.next}while(C!==x)}}function rh(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 Eg(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 $_(l){var u=l.alternate;u!==null&&(l.alternate=null,$_(u)),l.child=null,l.deletions=null,l.sibling=null,l.tag===5&&(u=l.stateNode,u!==null&&(delete u[ur],delete u[yc],delete u[Hm],delete u[I8],delete u[O8])),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 L_(l){return l.tag===5||l.tag===3||l.tag===4}function I_(l){e:for(;;){for(;l.sibling===null;){if(l.return===null||L_(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 Tg(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=Id));else if(x!==4&&(l=l.child,l!==null))for(Tg(l,u,g),l=l.sibling;l!==null;)Tg(l,u,g),l=l.sibling}function Ag(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(Ag(l,u,g),l=l.sibling;l!==null;)Ag(l,u,g),l=l.sibling}var sn=null,Fs=!1;function Ma(l,u,g){for(g=g.child;g!==null;)O_(l,u,g),g=g.sibling}function O_(l,u,g){if(Zt&&typeof Zt.onCommitFiberUnmount=="function")try{Zt.onCommitFiberUnmount(ss,g)}catch{}switch(g.tag){case 5:hn||Pi(g,u);case 6:var x=sn,C=Fs;sn=null,Ma(l,u,g),sn=x,Fs=C,sn!==null&&(Fs?(l=sn,g=g.stateNode,l.nodeType===8?l.parentNode.removeChild(g):l.removeChild(g)):sn.removeChild(g.stateNode));break;case 18:sn!==null&&(Fs?(l=sn,g=g.stateNode,l.nodeType===8?Wm(l.parentNode,g):l.nodeType===1&&Wm(l,g),fo(l)):Wm(sn,g.stateNode));break;case 4:x=sn,C=Fs,sn=g.stateNode.containerInfo,Fs=!0,Ma(l,u,g),sn=x,Fs=C;break;case 0:case 11:case 14:case 15:if(!hn&&(x=g.updateQueue,x!==null&&(x=x.lastEffect,x!==null))){C=x=x.next;do{var R=C,K=R.destroy;R=R.tag,K!==void 0&&((R&2)!==0||(R&4)!==0)&&Cg(g,u,K),C=C.next}while(C!==x)}Ma(l,u,g);break;case 1:if(!hn&&(Pi(g,u),x=g.stateNode,typeof x.componentWillUnmount=="function"))try{x.props=g.memoizedProps,x.state=g.memoizedState,x.componentWillUnmount()}catch(ee){$t(g,u,ee)}Ma(l,u,g);break;case 21:Ma(l,u,g);break;case 22:g.mode&1?(hn=(x=hn)||g.memoizedState!==null,Ma(l,u,g),hn=x):Ma(l,u,g);break;default:Ma(l,u,g)}}function P_(l){var u=l.updateQueue;if(u!==null){l.updateQueue=null;var g=l.stateNode;g===null&&(g=l.stateNode=new J8),u.forEach(function(x){var C=lB.bind(null,l,x);g.has(x)||(g.add(x),x.then(C,C))})}}function Bs(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,K=u,ee=K;e:for(;ee!==null;){switch(ee.tag){case 5:sn=ee.stateNode,Fs=!1;break e;case 3:sn=ee.stateNode.containerInfo,Fs=!0;break e;case 4:sn=ee.stateNode.containerInfo,Fs=!0;break e}ee=ee.return}if(sn===null)throw Error(n(160));O_(R,K,C),sn=null,Fs=!1;var ne=C.alternate;ne!==null&&(ne.return=null),C.return=null}catch(de){$t(C,u,de)}}if(u.subtreeFlags&12854)for(u=u.child;u!==null;)D_(u,l),u=u.sibling}function D_(l,u){var g=l.alternate,x=l.flags;switch(l.tag){case 0:case 11:case 14:case 15:if(Bs(u,l),fr(l),x&4){try{Ec(3,l,l.return),rh(3,l)}catch(Le){$t(l,l.return,Le)}try{Ec(5,l,l.return)}catch(Le){$t(l,l.return,Le)}}break;case 1:Bs(u,l),fr(l),x&512&&g!==null&&Pi(g,g.return);break;case 5:if(Bs(u,l),fr(l),x&512&&g!==null&&Pi(g,g.return),l.flags&32){var C=l.stateNode;try{Ae(C,"")}catch(Le){$t(l,l.return,Le)}}if(x&4&&(C=l.stateNode,C!=null)){var R=l.memoizedProps,K=g!==null?g.memoizedProps:R,ee=l.type,ne=l.updateQueue;if(l.updateQueue=null,ne!==null)try{ee==="input"&&R.type==="radio"&&R.name!=null&&je(C,R),Xe(ee,K);var de=Xe(ee,R);for(K=0;K<ne.length;K+=2){var be=ne[K],ke=ne[K+1];be==="style"?we(C,ke):be==="dangerouslySetInnerHTML"?Ne(C,ke):be==="children"?Ae(C,ke):S(C,be,ke,de)}switch(ee){case"input":me(C,R);break;case"textarea":Ue(C,R);break;case"select":var ve=C._wrapperState.wasMultiple;C._wrapperState.wasMultiple=!!R.multiple;var Ee=R.value;Ee!=null?ye(C,!!R.multiple,Ee,!1):ve!==!!R.multiple&&(R.defaultValue!=null?ye(C,!!R.multiple,R.defaultValue,!0):ye(C,!!R.multiple,R.multiple?[]:"",!1))}C[yc]=R}catch(Le){$t(l,l.return,Le)}}break;case 6:if(Bs(u,l),fr(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(Bs(u,l),fr(l),x&4&&g!==null&&g.memoizedState.isDehydrated)try{fo(u.containerInfo)}catch(Le){$t(l,l.return,Le)}break;case 4:Bs(u,l),fr(l);break;case 13:Bs(u,l),fr(l),C=l.child,C.flags&8192&&(R=C.memoizedState!==null,C.stateNode.isHidden=R,!R||C.alternate!==null&&C.alternate.memoizedState!==null||($g=ht())),x&4&&P_(l);break;case 22:if(be=g!==null&&g.memoizedState!==null,l.mode&1?(hn=(de=hn)||be,Bs(u,l),hn=de):Bs(u,l),fr(l),x&8192){if(de=l.memoizedState!==null,(l.stateNode.isHidden=de)&&!be&&(l.mode&1)!==0)for(Te=l,be=l.child;be!==null;){for(ke=Te=be;Te!==null;){switch(ve=Te,Ee=ve.child,ve.tag){case 0:case 11:case 14:case 15:Ec(4,ve,ve.return);break;case 1:Pi(ve,ve.return);var Me=ve.stateNode;if(typeof Me.componentWillUnmount=="function"){x=ve,g=ve.return;try{u=x,Me.props=u.memoizedProps,Me.state=u.memoizedState,Me.componentWillUnmount()}catch(Le){$t(x,g,Le)}}break;case 5:Pi(ve,ve.return);break;case 22:if(ve.memoizedState!==null){q_(ke);continue}}Ee!==null?(Ee.return=ve,Te=Ee):q_(ke)}be=be.sibling}e:for(be=null,ke=l;;){if(ke.tag===5){if(be===null){be=ke;try{C=ke.stateNode,de?(R=C.style,typeof R.setProperty=="function"?R.setProperty("display","none","important"):R.display="none"):(ee=ke.stateNode,ne=ke.memoizedProps.style,K=ne!=null&&ne.hasOwnProperty("display")?ne.display:null,ee.style.display=ot("display",K))}catch(Le){$t(l,l.return,Le)}}}else if(ke.tag===6){if(be===null)try{ke.stateNode.nodeValue=de?"":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;be===ke&&(be=null),ke=ke.return}be===ke&&(be=null),ke.sibling.return=ke.return,ke=ke.sibling}}break;case 19:Bs(u,l),fr(l),x&4&&P_(l);break;case 21:break;default:Bs(u,l),fr(l)}}function fr(l){var u=l.flags;if(u&2){try{e:{for(var g=l.return;g!==null;){if(L_(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&&(Ae(C,""),x.flags&=-33);var R=I_(l);Ag(l,R,C);break;case 3:case 4:var K=x.stateNode.containerInfo,ee=I_(l);Tg(l,ee,K);break;default:throw Error(n(161))}}catch(ne){$t(l,l.return,ne)}l.flags&=-3}u&4096&&(l.flags&=-4097)}function eB(l,u,g){Te=l,F_(l)}function F_(l,u,g){for(var x=(l.mode&1)!==0;Te!==null;){var C=Te,R=C.child;if(C.tag===22&&x){var K=C.memoizedState!==null||sh;if(!K){var ee=C.alternate,ne=ee!==null&&ee.memoizedState!==null||hn;ee=sh;var de=hn;if(sh=K,(hn=ne)&&!de)for(Te=C;Te!==null;)K=Te,ne=K.child,K.tag===22&&K.memoizedState!==null?U_(C):ne!==null?(ne.return=K,Te=ne):U_(C);for(;R!==null;)Te=R,F_(R),R=R.sibling;Te=C,sh=ee,hn=de}B_(l)}else(C.subtreeFlags&8772)!==0&&R!==null?(R.return=C,Te=R):B_(l)}}function B_(l){for(;Te!==null;){var u=Te;if((u.flags&8772)!==0){var g=u.alternate;try{if((u.flags&8772)!==0)switch(u.tag){case 0:case 11:case 15:hn||rh(5,u);break;case 1:var x=u.stateNode;if(u.flags&4&&!hn)if(g===null)x.componentDidMount();else{var C=u.elementType===u.type?g.memoizedProps:Ds(u.type,g.memoizedProps);x.componentDidUpdate(C,g.memoizedState,x.__reactInternalSnapshotBeforeUpdate)}var R=u.updateQueue;R!==null&&qS(u,R,x);break;case 3:var K=u.updateQueue;if(K!==null){if(g=null,u.child!==null)switch(u.child.tag){case 5:g=u.child.stateNode;break;case 1:g=u.child.stateNode}qS(u,K,g)}break;case 5:var ee=u.stateNode;if(g===null&&u.flags&4){g=ee;var ne=u.memoizedProps;switch(u.type){case"button":case"input":case"select":case"textarea":ne.autoFocus&&g.focus();break;case"img":ne.src&&(g.src=ne.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(u.memoizedState===null){var de=u.alternate;if(de!==null){var be=de.memoizedState;if(be!==null){var ke=be.dehydrated;ke!==null&&fo(ke)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}hn||u.flags&512&&Eg(u)}catch(ve){$t(u,u.return,ve)}}if(u===l){Te=null;break}if(g=u.sibling,g!==null){g.return=u.return,Te=g;break}Te=u.return}}function q_(l){for(;Te!==null;){var u=Te;if(u===l){Te=null;break}var g=u.sibling;if(g!==null){g.return=u.return,Te=g;break}Te=u.return}}function U_(l){for(;Te!==null;){var u=Te;try{switch(u.tag){case 0:case 11:case 15:var g=u.return;try{rh(4,u)}catch(ne){$t(u,g,ne)}break;case 1:var x=u.stateNode;if(typeof x.componentDidMount=="function"){var C=u.return;try{x.componentDidMount()}catch(ne){$t(u,C,ne)}}var R=u.return;try{Eg(u)}catch(ne){$t(u,R,ne)}break;case 5:var K=u.return;try{Eg(u)}catch(ne){$t(u,K,ne)}}}catch(ne){$t(u,u.return,ne)}if(u===l){Te=null;break}var ee=u.sibling;if(ee!==null){ee.return=u.return,Te=ee;break}Te=u.return}}var tB=Math.ceil,ah=_.ReactCurrentDispatcher,Rg=_.ReactCurrentOwner,fs=_.ReactCurrentBatchConfig,it=0,Qt=null,Ft=null,rn=0,Vn=0,Di=Ca(0),zt=0,Tc=null,_o=0,oh=0,Mg=0,Ac=null,Tn=null,$g=0,Fi=1/0,zr=null,ih=!1,Lg=null,$a=null,lh=!1,La=null,ch=0,Rc=0,Ig=null,uh=-1,dh=0;function yn(){return(it&6)!==0?ht():uh!==-1?uh:uh=ht()}function Ia(l){return(l.mode&1)===0?1:(it&2)!==0&&rn!==0?rn&-rn:D8.transition!==null?(dh===0&&(dh=Nn()),dh):(l=at,l!==0||(l=window.event,l=l===void 0?16:pd(l.type)),l)}function qs(l,u,g,x){if(50<Rc)throw Rc=0,Ig=null,Error(n(185));as(l,g,x),((it&2)===0||l!==Qt)&&(l===Qt&&((it&2)===0&&(oh|=g),zt===4&&Oa(l,rn)),An(l,x),g===1&&it===0&&(u.mode&1)===0&&(Fi=ht()+500,Fd&&Ta()))}function An(l,u){var g=l.callbackNode;dt(l,u);var x=ge(l,l===Qt?rn:0);if(x===0)g!==null&&ar(g),l.callbackNode=null,l.callbackPriority=0;else if(u=x&-x,l.callbackPriority!==u){if(g!=null&&ar(g),u===1)l.tag===0?P8(H_.bind(null,l)):TS(H_.bind(null,l)),$8(function(){(it&6)===0&&Ta()}),g=null;else{switch(Kl(x)){case 1:g=Tr;break;case 4:g=pa;break;case 16:g=Mt;break;case 536870912:g=ir;break;default:g=Mt}g=J_(g,W_.bind(null,l))}l.callbackPriority=u,l.callbackNode=g}}function W_(l,u){if(uh=-1,dh=0,(it&6)!==0)throw Error(n(327));var g=l.callbackNode;if(Bi()&&l.callbackNode!==g)return null;var x=ge(l,l===Qt?rn:0);if(x===0)return null;if((x&30)!==0||(x&l.expiredLanes)!==0||u)u=hh(l,x);else{u=x;var C=it;it|=2;var R=V_();(Qt!==l||rn!==u)&&(zr=null,Fi=ht()+500,Eo(l,u));do try{rB();break}catch(ee){z_(l,ee)}while(!0);Qm(),ah.current=R,it=C,Ft!==null?u=0:(Qt=null,rn=0,u=zt)}if(u!==0){if(u===2&&(C=Nt(l),C!==0&&(x=C,u=Og(l,C))),u===1)throw g=Tc,Eo(l,0),Oa(l,x),An(l,ht()),g;if(u===6)Oa(l,x);else{if(C=l.current.alternate,(x&30)===0&&!nB(C)&&(u=hh(l,x),u===2&&(R=Nt(l),R!==0&&(x=R,u=Og(l,R))),u===1))throw g=Tc,Eo(l,0),Oa(l,x),An(l,ht()),g;switch(l.finishedWork=C,l.finishedLanes=x,u){case 0:case 1:throw Error(n(345));case 2:To(l,Tn,zr);break;case 3:if(Oa(l,x),(x&130023424)===x&&(u=$g+500-ht(),10<u)){if(ge(l,0)!==0)break;if(C=l.suspendedLanes,(C&x)!==x){yn(),l.pingedLanes|=l.suspendedLanes&C;break}l.timeoutHandle=Um(To.bind(null,l,Tn,zr),u);break}To(l,Tn,zr);break;case 4:if(Oa(l,x),(x&4194240)===x)break;for(u=l.eventTimes,C=-1;0<x;){var K=31-on(x);R=1<<K,K=u[K],K>C&&(C=K),x&=~R}if(x=C,x=ht()-x,x=(120>x?120:480>x?480:1080>x?1080:1920>x?1920:3e3>x?3e3:4320>x?4320:1960*tB(x/1960))-x,10<x){l.timeoutHandle=Um(To.bind(null,l,Tn,zr),x);break}To(l,Tn,zr);break;case 5:To(l,Tn,zr);break;default:throw Error(n(329))}}}return An(l,ht()),l.callbackNode===g?W_.bind(null,l):null}function Og(l,u){var g=Ac;return l.current.memoizedState.isDehydrated&&(Eo(l,u).flags|=256),l=hh(l,u),l!==2&&(u=Tn,Tn=g,u!==null&&Pg(u)),l}function Pg(l){Tn===null?Tn=l:Tn.push.apply(Tn,l)}function nB(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(!Os(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 Oa(l,u){for(u&=~Mg,u&=~oh,l.suspendedLanes|=u,l.pingedLanes&=~u,l=l.expirationTimes;0<u;){var g=31-on(u),x=1<<g;l[g]=-1,u&=~x}}function H_(l){if((it&6)!==0)throw Error(n(327));Bi();var u=ge(l,0);if((u&1)===0)return An(l,ht()),null;var g=hh(l,u);if(l.tag!==0&&g===2){var x=Nt(l);x!==0&&(u=x,g=Og(l,x))}if(g===1)throw g=Tc,Eo(l,0),Oa(l,u),An(l,ht()),g;if(g===6)throw Error(n(345));return l.finishedWork=l.current.alternate,l.finishedLanes=u,To(l,Tn,zr),An(l,ht()),null}function Dg(l,u){var g=it;it|=1;try{return l(u)}finally{it=g,it===0&&(Fi=ht()+500,Fd&&Ta())}}function Co(l){La!==null&&La.tag===0&&(it&6)===0&&Bi();var u=it;it|=1;var g=fs.transition,x=at;try{if(fs.transition=null,at=1,l)return l()}finally{at=x,fs.transition=g,it=u,(it&6)===0&&Ta()}}function Fg(){Vn=Di.current,kt(Di)}function Eo(l,u){l.finishedWork=null,l.finishedLanes=0;var g=l.timeoutHandle;if(g!==-1&&(l.timeoutHandle=-1,M8(g)),Ft!==null)for(g=Ft.return;g!==null;){var x=g;switch(Km(x),x.tag){case 1:x=x.type.childContextTypes,x!=null&&Pd();break;case 3:Ii(),kt(_n),kt(cn),ig();break;case 5:ag(x);break;case 4:Ii();break;case 13:kt(Tt);break;case 19:kt(Tt);break;case 10:eg(x.type._context);break;case 22:case 23:Fg()}g=g.return}if(Qt=l,Ft=l=Pa(l.current,null),rn=Vn=u,zt=0,Tc=null,Mg=oh=_o=0,Tn=Ac=null,jo!==null){for(u=0;u<jo.length;u++)if(g=jo[u],x=g.interleaved,x!==null){g.interleaved=null;var C=x.next,R=g.pending;if(R!==null){var K=R.next;R.next=C,x.next=K}g.pending=x}jo=null}return l}function z_(l,u){do{var g=Ft;try{if(Qm(),Yd.current=Qd,Xd){for(var x=At.memoizedState;x!==null;){var C=x.queue;C!==null&&(C.pending=null),x=x.next}Xd=!1}if(So=0,Jt=Ht=At=null,jc=!1,Nc=0,Rg.current=null,g===null||g.return===null){zt=1,Tc=u,Ft=null;break}e:{var R=l,K=g.return,ee=g,ne=u;if(u=rn,ee.flags|=32768,ne!==null&&typeof ne=="object"&&typeof ne.then=="function"){var de=ne,be=ee,ke=be.tag;if((be.mode&1)===0&&(ke===0||ke===11||ke===15)){var ve=be.alternate;ve?(be.updateQueue=ve.updateQueue,be.memoizedState=ve.memoizedState,be.lanes=ve.lanes):(be.updateQueue=null,be.memoizedState=null)}var Ee=g_(K);if(Ee!==null){Ee.flags&=-257,y_(Ee,K,ee,R,u),Ee.mode&1&&m_(R,de,u),u=Ee,ne=de;var Me=u.updateQueue;if(Me===null){var Le=new Set;Le.add(ne),u.updateQueue=Le}else Me.add(ne);break e}else{if((u&1)===0){m_(R,de,u),Bg();break e}ne=Error(n(426))}}else if(St&&ee.mode&1){var Ot=g_(K);if(Ot!==null){(Ot.flags&65536)===0&&(Ot.flags|=256),y_(Ot,K,ee,R,u),Zm(Oi(ne,ee));break e}}R=ne=Oi(ne,ee),zt!==4&&(zt=2),Ac===null?Ac=[R]:Ac.push(R),R=K;do{switch(R.tag){case 3:R.flags|=65536,u&=-u,R.lanes|=u;var oe=f_(R,ne,u);BS(R,oe);break e;case 1:ee=ne;var se=R.type,le=R.stateNode;if((R.flags&128)===0&&(typeof se.getDerivedStateFromError=="function"||le!==null&&typeof le.componentDidCatch=="function"&&($a===null||!$a.has(le)))){R.flags|=65536,u&=-u,R.lanes|=u;var Se=p_(R,ee,u);BS(R,Se);break e}}R=R.return}while(R!==null)}K_(g)}catch(Oe){u=Oe,Ft===g&&g!==null&&(Ft=g=g.return);continue}break}while(!0)}function V_(){var l=ah.current;return ah.current=Qd,l===null?Qd:l}function Bg(){(zt===0||zt===3||zt===2)&&(zt=4),Qt===null||(_o&268435455)===0&&(oh&268435455)===0||Oa(Qt,rn)}function hh(l,u){var g=it;it|=2;var x=V_();(Qt!==l||rn!==u)&&(zr=null,Eo(l,u));do try{sB();break}catch(C){z_(l,C)}while(!0);if(Qm(),it=g,ah.current=x,Ft!==null)throw Error(n(261));return Qt=null,rn=0,zt}function sB(){for(;Ft!==null;)G_(Ft)}function rB(){for(;Ft!==null&&!or();)G_(Ft)}function G_(l){var u=Z_(l.alternate,l,Vn);l.memoizedProps=l.pendingProps,u===null?K_(l):Ft=u,Rg.current=null}function K_(l){var u=l;do{var g=u.alternate;if(l=u.return,(u.flags&32768)===0){if(g=X8(g,u,Vn),g!==null){Ft=g;return}}else{if(g=Z8(g,u),g!==null){g.flags&=32767,Ft=g;return}if(l!==null)l.flags|=32768,l.subtreeFlags=0,l.deletions=null;else{zt=6,Ft=null;return}}if(u=u.sibling,u!==null){Ft=u;return}Ft=u=l}while(u!==null);zt===0&&(zt=5)}function To(l,u,g){var x=at,C=fs.transition;try{fs.transition=null,at=1,aB(l,u,g,x)}finally{fs.transition=C,at=x}return null}function aB(l,u,g,x){do Bi();while(La!==null);if((it&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(Gl(l,R),l===Qt&&(Ft=Qt=null,rn=0),(g.subtreeFlags&2064)===0&&(g.flags&2064)===0||lh||(lh=!0,J_(Mt,function(){return Bi(),null})),R=(g.flags&15990)!==0,(g.subtreeFlags&15990)!==0||R){R=fs.transition,fs.transition=null;var K=at;at=1;var ee=it;it|=4,Rg.current=null,Q8(l,g),D_(g,l),S8(Bm),xa=!!Fm,Bm=Fm=null,l.current=g,eB(g),ha(),it=ee,at=K,fs.transition=R}else l.current=g;if(lh&&(lh=!1,La=l,ch=C),R=l.pendingLanes,R===0&&($a=null),Rr(g.stateNode),An(l,ht()),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(ih)throw ih=!1,l=Lg,Lg=null,l;return(ch&1)!==0&&l.tag!==0&&Bi(),R=l.pendingLanes,(R&1)!==0?l===Ig?Rc++:(Rc=0,Ig=l):Rc=0,Ta(),null}function Bi(){if(La!==null){var l=Kl(ch),u=fs.transition,g=at;try{if(fs.transition=null,at=16>l?16:l,La===null)var x=!1;else{if(l=La,La=null,ch=0,(it&6)!==0)throw Error(n(331));var C=it;for(it|=4,Te=l.current;Te!==null;){var R=Te,K=R.child;if((Te.flags&16)!==0){var ee=R.deletions;if(ee!==null){for(var ne=0;ne<ee.length;ne++){var de=ee[ne];for(Te=de;Te!==null;){var be=Te;switch(be.tag){case 0:case 11:case 15:Ec(8,be,R)}var ke=be.child;if(ke!==null)ke.return=be,Te=ke;else for(;Te!==null;){be=Te;var ve=be.sibling,Ee=be.return;if($_(be),be===de){Te=null;break}if(ve!==null){ve.return=Ee,Te=ve;break}Te=Ee}}}var Me=R.alternate;if(Me!==null){var Le=Me.child;if(Le!==null){Me.child=null;do{var Ot=Le.sibling;Le.sibling=null,Le=Ot}while(Le!==null)}}Te=R}}if((R.subtreeFlags&2064)!==0&&K!==null)K.return=R,Te=K;else e:for(;Te!==null;){if(R=Te,(R.flags&2048)!==0)switch(R.tag){case 0:case 11:case 15:Ec(9,R,R.return)}var oe=R.sibling;if(oe!==null){oe.return=R.return,Te=oe;break e}Te=R.return}}var se=l.current;for(Te=se;Te!==null;){K=Te;var le=K.child;if((K.subtreeFlags&2064)!==0&&le!==null)le.return=K,Te=le;else e:for(K=se;Te!==null;){if(ee=Te,(ee.flags&2048)!==0)try{switch(ee.tag){case 0:case 11:case 15:rh(9,ee)}}catch(Oe){$t(ee,ee.return,Oe)}if(ee===K){Te=null;break e}var Se=ee.sibling;if(Se!==null){Se.return=ee.return,Te=Se;break e}Te=ee.return}}if(it=C,Ta(),Zt&&typeof Zt.onPostCommitFiberRoot=="function")try{Zt.onPostCommitFiberRoot(ss,l)}catch{}x=!0}return x}finally{at=g,fs.transition=u}}return!1}function Y_(l,u,g){u=Oi(g,u),u=f_(l,u,1),l=Ra(l,u,1),u=yn(),l!==null&&(as(l,1,u),An(l,u))}function $t(l,u,g){if(l.tag===3)Y_(l,l,g);else for(;u!==null;){if(u.tag===3){Y_(u,l,g);break}else if(u.tag===1){var x=u.stateNode;if(typeof u.type.getDerivedStateFromError=="function"||typeof x.componentDidCatch=="function"&&($a===null||!$a.has(x))){l=Oi(g,l),l=p_(u,l,1),u=Ra(u,l,1),l=yn(),u!==null&&(as(u,1,l),An(u,l));break}}u=u.return}}function oB(l,u,g){var x=l.pingCache;x!==null&&x.delete(u),u=yn(),l.pingedLanes|=l.suspendedLanes&g,Qt===l&&(rn&g)===g&&(zt===4||zt===3&&(rn&130023424)===rn&&500>ht()-$g?Eo(l,0):Mg|=g),An(l,u)}function X_(l,u){u===0&&((l.mode&1)===0?u=1:(u=Rs,Rs<<=1,(Rs&130023424)===0&&(Rs=4194304)));var g=yn();l=Ur(l,u),l!==null&&(as(l,u,g),An(l,g))}function iB(l){var u=l.memoizedState,g=0;u!==null&&(g=u.retryLane),X_(l,g)}function lB(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),X_(l,g)}var Z_;Z_=function(l,u,g){if(l!==null)if(l.memoizedProps!==u.pendingProps||_n.current)En=!0;else{if((l.lanes&g)===0&&(u.flags&128)===0)return En=!1,Y8(l,u,g);En=(l.flags&131072)!==0}else En=!1,St&&(u.flags&1048576)!==0&&AS(u,qd,u.index);switch(u.lanes=0,u.tag){case 2:var x=u.type;nh(l,u),l=u.pendingProps;var C=Ei(u,cn.current);Li(u,g),C=ug(null,u,x,l,C,g);var R=dg();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,Cn(x)?(R=!0,Dd(u)):R=!1,u.memoizedState=C.state!==null&&C.state!==void 0?C.state:null,sg(u),C.updater=eh,u.stateNode=C,C._reactInternals=u,yg(u,x,l,g),u=bg(null,u,x,!0,R,g)):(u.tag=0,St&&R&&Gm(u),gn(null,u,C,g),u=u.child),u;case 16:x=u.elementType;e:{switch(nh(l,u),l=u.pendingProps,C=x._init,x=C(x._payload),u.type=x,C=u.tag=uB(x),l=Ds(x,l),C){case 0:u=vg(null,u,x,l,g);break e;case 1:u=j_(null,u,x,l,g);break e;case 11:u=w_(null,u,x,l,g);break e;case 14:u=x_(null,u,x,Ds(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:Ds(x,C),vg(l,u,x,C,g);case 1:return x=u.type,C=u.pendingProps,C=u.elementType===x?C:Ds(x,C),j_(l,u,x,C,g);case 3:e:{if(N_(u),l===null)throw Error(n(387));x=u.pendingProps,R=u.memoizedState,C=R.element,FS(l,u),Gd(u,x,null,g);var K=u.memoizedState;if(x=K.element,R.isDehydrated)if(R={element:x,isDehydrated:!1,cache:K.cache,pendingSuspenseBoundaries:K.pendingSuspenseBoundaries,transitions:K.transitions},u.updateQueue.baseState=R,u.memoizedState=R,u.flags&256){C=Oi(Error(n(423)),u),u=S_(l,u,x,g,C);break e}else if(x!==C){C=Oi(Error(n(424)),u),u=S_(l,u,x,g,C);break e}else for(zn=_a(u.stateNode.containerInfo.firstChild),Hn=u,St=!0,Ps=null,g=PS(u,null,x,g),u.child=g;g;)g.flags=g.flags&-3|4096,g=g.sibling;else{if(Ri(),x===C){u=Hr(l,u,g);break e}gn(l,u,x,g)}u=u.child}return u;case 5:return US(u),l===null&&Xm(u),x=u.type,C=u.pendingProps,R=l!==null?l.memoizedProps:null,K=C.children,qm(x,C)?K=null:R!==null&&qm(x,R)&&(u.flags|=32),k_(l,u),gn(l,u,K,g),u.child;case 6:return l===null&&Xm(u),null;case 13:return __(l,u,g);case 4:return rg(u,u.stateNode.containerInfo),x=u.pendingProps,l===null?u.child=Mi(u,null,x,g):gn(l,u,x,g),u.child;case 11:return x=u.type,C=u.pendingProps,C=u.elementType===x?C:Ds(x,C),w_(l,u,x,C,g);case 7:return gn(l,u,u.pendingProps,g),u.child;case 8:return gn(l,u,u.pendingProps.children,g),u.child;case 12:return gn(l,u,u.pendingProps.children,g),u.child;case 10:e:{if(x=u.type._context,C=u.pendingProps,R=u.memoizedProps,K=C.value,yt(Hd,x._currentValue),x._currentValue=K,R!==null)if(Os(R.value,K)){if(R.children===C.children&&!_n.current){u=Hr(l,u,g);break e}}else for(R=u.child,R!==null&&(R.return=u);R!==null;){var ee=R.dependencies;if(ee!==null){K=R.child;for(var ne=ee.firstContext;ne!==null;){if(ne.context===x){if(R.tag===1){ne=Wr(-1,g&-g),ne.tag=2;var de=R.updateQueue;if(de!==null){de=de.shared;var be=de.pending;be===null?ne.next=ne:(ne.next=be.next,be.next=ne),de.pending=ne}}R.lanes|=g,ne=R.alternate,ne!==null&&(ne.lanes|=g),tg(R.return,g,u),ee.lanes|=g;break}ne=ne.next}}else if(R.tag===10)K=R.type===u.type?null:R.child;else if(R.tag===18){if(K=R.return,K===null)throw Error(n(341));K.lanes|=g,ee=K.alternate,ee!==null&&(ee.lanes|=g),tg(K,g,u),K=R.sibling}else K=R.child;if(K!==null)K.return=R;else for(K=R;K!==null;){if(K===u){K=null;break}if(R=K.sibling,R!==null){R.return=K.return,K=R;break}K=K.return}R=K}gn(l,u,C.children,g),u=u.child}return u;case 9:return C=u.type,x=u.pendingProps.children,Li(u,g),C=ds(C),x=x(C),u.flags|=1,gn(l,u,x,g),u.child;case 14:return x=u.type,C=Ds(x,u.pendingProps),C=Ds(x.type,C),x_(l,u,x,C,g);case 15:return v_(l,u,u.type,u.pendingProps,g);case 17:return x=u.type,C=u.pendingProps,C=u.elementType===x?C:Ds(x,C),nh(l,u),u.tag=1,Cn(x)?(l=!0,Dd(u)):l=!1,Li(u,g),d_(u,x,C),yg(u,x,C,g),bg(null,u,x,!0,l,g);case 19:return E_(l,u,g);case 22:return b_(l,u,g)}throw Error(n(156,u.tag))};function J_(l,u){return rr(l,u)}function cB(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 ps(l,u,g,x){return new cB(l,u,g,x)}function qg(l){return l=l.prototype,!(!l||!l.isReactComponent)}function uB(l){if(typeof l=="function")return qg(l)?1:0;if(l!=null){if(l=l.$$typeof,l===M)return 11;if(l===D)return 14}return 2}function Pa(l,u){var g=l.alternate;return g===null?(g=ps(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 fh(l,u,g,x,C,R){var K=2;if(x=l,typeof l=="function")qg(l)&&(K=1);else if(typeof l=="string")K=5;else e:switch(l){case A:return Ao(g.children,C,R,u);case P:K=8,C|=8;break;case O:return l=ps(12,g,u,C|2),l.elementType=O,l.lanes=R,l;case I:return l=ps(13,g,u,C),l.elementType=I,l.lanes=R,l;case E:return l=ps(19,g,u,C),l.elementType=E,l.lanes=R,l;case H:return ph(g,C,R,u);default:if(typeof l=="object"&&l!==null)switch(l.$$typeof){case U:K=10;break e;case q:K=9;break e;case M:K=11;break e;case D:K=14;break e;case B:K=16,x=null;break e}throw Error(n(130,l==null?l:typeof l,""))}return u=ps(K,g,u,C),u.elementType=l,u.type=x,u.lanes=R,u}function Ao(l,u,g,x){return l=ps(7,l,x,u),l.lanes=g,l}function ph(l,u,g,x){return l=ps(22,l,x,u),l.elementType=H,l.lanes=g,l.stateNode={isHidden:!1},l}function Ug(l,u,g){return l=ps(6,l,null,u),l.lanes=g,l}function Wg(l,u,g){return u=ps(4,l.children!==null?l.children:[],l.key,u),u.lanes=g,u.stateNode={containerInfo:l.containerInfo,pendingChildren:null,implementation:l.implementation},u}function dB(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=rs(0),this.expirationTimes=rs(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=rs(0),this.identifierPrefix=x,this.onRecoverableError=C,this.mutableSourceEagerHydrationData=null}function Hg(l,u,g,x,C,R,K,ee,ne){return l=new dB(l,u,g,ee,ne),u===1?(u=1,R===!0&&(u|=8)):u=0,R=ps(3,null,null,u),l.current=R,R.stateNode=l,R.memoizedState={element:x,isDehydrated:g,cache:null,transitions:null,pendingSuspenseBoundaries:null},sg(R),l}function hB(l,u,g){var x=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:L,key:x==null?null:""+x,children:l,containerInfo:u,implementation:g}}function Q_(l){if(!l)return Ea;l=l._reactInternals;e:{if(mn(l)!==l||l.tag!==1)throw Error(n(170));var u=l;do{switch(u.tag){case 3:u=u.stateNode.context;break e;case 1:if(Cn(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(Cn(g))return CS(l,g,u)}return u}function eC(l,u,g,x,C,R,K,ee,ne){return l=Hg(g,x,!0,l,C,R,K,ee,ne),l.context=Q_(null),g=l.current,x=yn(),C=Ia(g),R=Wr(x,C),R.callback=u??null,Ra(g,R,C),l.current.lanes=C,as(l,C,x),An(l,x),l}function mh(l,u,g,x){var C=u.current,R=yn(),K=Ia(C);return g=Q_(g),u.context===null?u.context=g:u.pendingContext=g,u=Wr(R,K),u.payload={element:l},x=x===void 0?null:x,x!==null&&(u.callback=x),l=Ra(C,u,K),l!==null&&(qs(l,C,K,R),Vd(l,C,K)),K}function gh(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 tC(l,u){if(l=l.memoizedState,l!==null&&l.dehydrated!==null){var g=l.retryLane;l.retryLane=g!==0&&g<u?g:u}}function zg(l,u){tC(l,u),(l=l.alternate)&&tC(l,u)}function fB(){return null}var nC=typeof reportError=="function"?reportError:function(l){console.error(l)};function Vg(l){this._internalRoot=l}yh.prototype.render=Vg.prototype.render=function(l){var u=this._internalRoot;if(u===null)throw Error(n(409));mh(l,u,null,null)},yh.prototype.unmount=Vg.prototype.unmount=function(){var l=this._internalRoot;if(l!==null){this._internalRoot=null;var u=l.containerInfo;Co(function(){mh(null,l,null,null)}),u[Dr]=null}};function yh(l){this._internalRoot=l}yh.prototype.unstable_scheduleHydration=function(l){if(l){var u=Zl();l={blockedOn:null,target:l,priority:u};for(var g=0;g<cr.length&&u!==0&&u<cr[g].priority;g++);cr.splice(g,0,l),g===0&&hd(l)}};function Gg(l){return!(!l||l.nodeType!==1&&l.nodeType!==9&&l.nodeType!==11)}function wh(l){return!(!l||l.nodeType!==1&&l.nodeType!==9&&l.nodeType!==11&&(l.nodeType!==8||l.nodeValue!==" react-mount-point-unstable "))}function sC(){}function pB(l,u,g,x,C){if(C){if(typeof x=="function"){var R=x;x=function(){var de=gh(K);R.call(de)}}var K=eC(u,x,l,0,null,!1,!1,"",sC);return l._reactRootContainer=K,l[Dr]=K.current,mc(l.nodeType===8?l.parentNode:l),Co(),K}for(;C=l.lastChild;)l.removeChild(C);if(typeof x=="function"){var ee=x;x=function(){var de=gh(ne);ee.call(de)}}var ne=Hg(l,0,!1,null,null,!1,!1,"",sC);return l._reactRootContainer=ne,l[Dr]=ne.current,mc(l.nodeType===8?l.parentNode:l),Co(function(){mh(u,ne,g,x)}),ne}function xh(l,u,g,x,C){var R=g._reactRootContainer;if(R){var K=R;if(typeof C=="function"){var ee=C;C=function(){var ne=gh(K);ee.call(ne)}}mh(u,K,l,C)}else K=pB(g,u,l,C,x);return gh(K)}Yl=function(l){switch(l.tag){case 3:var u=l.stateNode;if(u.current.memoizedState.isDehydrated){var g=lr(u.pendingLanes);g!==0&&(ga(u,g|1),An(u,ht()),(it&6)===0&&(Fi=ht()+500,Ta()))}break;case 13:Co(function(){var x=Ur(l,1);if(x!==null){var C=yn();qs(x,l,1,C)}}),zg(l,1)}},di=function(l){if(l.tag===13){var u=Ur(l,134217728);if(u!==null){var g=yn();qs(u,l,134217728,g)}zg(l,134217728)}},Xl=function(l){if(l.tag===13){var u=Ia(l),g=Ur(l,u);if(g!==null){var x=yn();qs(g,l,u,x)}zg(l,u)}},Zl=function(){return at},Ms=function(l,u){var g=at;try{return at=l,u()}finally{at=g}},Ut=function(l,u,g){switch(u){case"input":if(me(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=Od(x);if(!C)throw Error(n(90));ie(x),me(x,C)}}}break;case"textarea":Ue(l,g);break;case"select":u=g.value,u!=null&&ye(l,!!g.multiple,u,!1)}},Cs=Dg,Jn=Co;var mB={usingClientEntryPoint:!1,Events:[wc,_i,Od,Wt,tr,Dg]},Mc={findFiberByHostInstance:xo,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},gB={bundleType:Mc.bundleType,version:Mc.version,rendererPackageName:Mc.rendererPackageName,rendererConfig:Mc.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=sr(l),l===null?null:l.stateNode},findFiberByHostInstance:Mc.findFiberByHostInstance||fB,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 vh=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!vh.isDisabled&&vh.supportsFiber)try{ss=vh.inject(gB),Zt=vh}catch{}}return Rn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=mB,Rn.createPortal=function(l,u){var g=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Gg(u))throw Error(n(200));return hB(l,u,null,g)},Rn.createRoot=function(l,u){if(!Gg(l))throw Error(n(299));var g=!1,x="",C=nC;return u!=null&&(u.unstable_strictMode===!0&&(g=!0),u.identifierPrefix!==void 0&&(x=u.identifierPrefix),u.onRecoverableError!==void 0&&(C=u.onRecoverableError)),u=Hg(l,1,!1,null,null,g,!1,x,C),l[Dr]=u.current,mc(l.nodeType===8?l.parentNode:l),new Vg(u)},Rn.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=sr(u),l=l===null?null:l.stateNode,l},Rn.flushSync=function(l){return Co(l)},Rn.hydrate=function(l,u,g){if(!wh(u))throw Error(n(200));return xh(null,l,u,!0,g)},Rn.hydrateRoot=function(l,u,g){if(!Gg(l))throw Error(n(405));var x=g!=null&&g.hydratedSources||null,C=!1,R="",K=nC;if(g!=null&&(g.unstable_strictMode===!0&&(C=!0),g.identifierPrefix!==void 0&&(R=g.identifierPrefix),g.onRecoverableError!==void 0&&(K=g.onRecoverableError)),u=eC(u,null,l,1,g??null,C,!1,R,K),l[Dr]=u.current,mc(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 yh(u)},Rn.render=function(l,u,g){if(!wh(u))throw Error(n(200));return xh(null,l,u,!1,g)},Rn.unmountComponentAtNode=function(l){if(!wh(l))throw Error(n(40));return l._reactRootContainer?(Co(function(){xh(null,null,l,!1,function(){l._reactRootContainer=null,l[Dr]=null})}),!0):!1},Rn.unstable_batchedUpdates=Dg,Rn.unstable_renderSubtreeIntoContainer=function(l,u,g,x){if(!wh(g))throw Error(n(200));if(l==null||l._reactInternals===void 0)throw Error(n(38));return xh(l,u,g,!1,x)},Rn.version="18.3.1-next-f1338f8080-20240426",Rn}var dC;function kO(){if(dC)return Xg.exports;dC=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(),Xg.exports=SB(),Xg.exports}var hC;function _B(){if(hC)return kh;hC=1;var e=kO();return kh.createRoot=e.createRoot,kh.hydrateRoot=e.hydrateRoot,kh}var CB=_B(),y=Bu();const he=K1(y);function an(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=an(e[n]))!==""&&(t+=(t&&" ")+s);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var Qg={exports:{}},ey={},ty={exports:{}},ny={};/**
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 fC;function EB(){if(fC)return ny;fC=1;var e=Bu();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(),v=s({inst:{value:w,getSnapshot:m}}),b=v[0].inst,k=v[1];return o(function(){b.value=w,b.getSnapshot=m,d(b)&&k({inst:b})},[p,w,m]),a(function(){return d(b)&&k({inst:b}),p(function(){d(b)&&k({inst:b})})},[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 ny.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:f,ny}var pC;function TB(){return pC||(pC=1,ty.exports=EB()),ty.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 mC;function AB(){if(mC)return ey;mC=1;var e=Bu(),t=TB();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 ey.useSyncExternalStoreWithSelector=function(h,f,p,m,w){var v=o(null);if(v.current===null){var b={hasValue:!1,value:null};v.current=b}else b=v.current;v=c(function(){function N(L){if(!j){if(j=!0,S=L,L=m(L),w!==void 0&&b.hasValue){var A=b.value;if(w(A,L))return _=A}return _=L}if(A=_,s(S,L))return A;var P=m(L);return w!==void 0&&w(A,P)?(S=L,A):(S=L,_=P)}var j=!1,S,_,T=p===void 0?null:p;return[function(){return N(f())},T===null?void 0:function(){return N(T())}]},[f,p,m,w]);var k=a(h,v[0],v[1]);return i(function(){b.hasValue=!0,b.value=k},[k]),d(k),k},ey}var gC;function RB(){return gC||(gC=1,Qg.exports=AB()),Qg.exports}var MB=RB();const $B=K1(MB),LB={},yC=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(v=>v(t,w))}},a=()=>t,d={setState:s,getState:a,getInitialState:()=>h,subscribe:f=>(n.add(f),()=>n.delete(f)),destroy:()=>{(LB?"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},IB=e=>e?yC(e):yC,{useDebugValue:OB}=he,{useSyncExternalStoreWithSelector:PB}=$B,DB=e=>e;function jO(e,t=DB,n){const s=PB(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return OB(s),s}const wC=(e,t)=>{const n=IB(e),s=(a,o=t)=>jO(n,a,o);return Object.assign(s,n),s},FB=(e,t)=>e?wC(e,t):wC;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 BB={value:()=>{}};function pp(){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 ef(n)}function ef(e){this._=e}function qB(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}})}ef.prototype=pp.prototype={constructor:ef,on:function(e,t){var n=this._,s=qB(e+"",n),a,o=-1,i=s.length;if(arguments.length<2){for(;++o<i;)if((a=(e=s[o]).type)&&(a=UB(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]=xC(n[a],e.name,t);else if(t==null)for(a in n)n[a]=xC(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 ef(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 UB(e,t){for(var n=0,s=e.length,a;n<s;++n)if((a=e[n]).name===t)return a.value}function xC(e,t,n){for(var s=0,a=e.length;s<a;++s)if(e[s].name===t){e[s]=BB,e=e.slice(0,s).concat(e.slice(s+1));break}return n!=null&&e.push({name:t,value:n}),e}var y0="http://www.w3.org/1999/xhtml";const vC={svg:"http://www.w3.org/2000/svg",xhtml:y0,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function mp(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),vC.hasOwnProperty(t)?{space:vC[t],local:e}:e}function WB(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===y0&&t.documentElement.namespaceURI===y0?t.createElement(e):t.createElementNS(n,e)}}function HB(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function NO(e){var t=mp(e);return(t.local?HB:WB)(t)}function zB(){}function Y1(e){return e==null?zB:function(){return this.querySelector(e)}}function VB(e){typeof e!="function"&&(e=Y1(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 Zn(s,this._parents)}function GB(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function KB(){return[]}function SO(e){return e==null?KB:function(){return this.querySelectorAll(e)}}function YB(e){return function(){return GB(e.apply(this,arguments))}}function XB(e){typeof e=="function"?e=YB(e):e=SO(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 Zn(s,a)}function _O(e){return function(){return this.matches(e)}}function CO(e){return function(t){return t.matches(e)}}var ZB=Array.prototype.find;function JB(e){return function(){return ZB.call(this.children,e)}}function QB(){return this.firstElementChild}function eq(e){return this.select(e==null?QB:JB(typeof e=="function"?e:CO(e)))}var tq=Array.prototype.filter;function nq(){return Array.from(this.children)}function sq(e){return function(){return tq.call(this.children,e)}}function rq(e){return this.selectAll(e==null?nq:sq(typeof e=="function"?e:CO(e)))}function aq(e){typeof e!="function"&&(e=_O(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 Zn(s,this._parents)}function EO(e){return new Array(e.length)}function oq(){return new Zn(this._enter||this._groups.map(EO),this._parents)}function vf(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}vf.prototype={constructor:vf,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 iq(e){return function(){return e}}function lq(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 vf(e,o[i]);for(;i<d;++i)(c=t[i])&&(a[i]=c)}function cq(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 vf(e,o[c]);for(c=0;c<f;++c)(d=t[c])&&h.get(m[c])===d&&(a[c]=d)}function uq(e){return e.__data__}function dq(e,t){if(!arguments.length)return Array.from(this,uq);var n=t?cq:lq,s=this._parents,a=this._groups;typeof e!="function"&&(e=iq(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=hq(e.call(f,f&&f.__data__,h,s)),v=w.length,b=c[h]=new Array(v),k=i[h]=new Array(v),N=d[h]=new Array(m);n(f,p,b,k,N,w,t);for(var j=0,S=0,_,T;j<v;++j)if(_=b[j]){for(j>=S&&(S=j+1);!(T=k[S])&&++S<v;);_._next=T||null}}return i=new Zn(i,s),i._enter=c,i._exit=d,i}function hq(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function fq(){return new Zn(this._exit||this._groups.map(EO),this._parents)}function pq(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 mq(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,v=0;v<p;++v)(w=h[v]||f[v])&&(m[v]=w);for(;d<a;++d)c[d]=n[d];return new Zn(c,this._parents)}function gq(){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 yq(e){e||(e=wq);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 Zn(a,this._parents).order()}function wq(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function xq(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function vq(){return Array.from(this)}function bq(){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 kq(){let e=0;for(const t of this)++e;return e}function jq(){return!this.node()}function Nq(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 Sq(e){return function(){this.removeAttribute(e)}}function _q(e){return function(){this.removeAttributeNS(e.space,e.local)}}function Cq(e,t){return function(){this.setAttribute(e,t)}}function Eq(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function Tq(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function Aq(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 Rq(e,t){var n=mp(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?_q:Sq:typeof t=="function"?n.local?Aq:Tq:n.local?Eq:Cq)(n,t))}function TO(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function Mq(e){return function(){this.style.removeProperty(e)}}function $q(e,t,n){return function(){this.style.setProperty(e,t,n)}}function Lq(e,t,n){return function(){var s=t.apply(this,arguments);s==null?this.style.removeProperty(e):this.style.setProperty(e,s,n)}}function Iq(e,t,n){return arguments.length>1?this.each((t==null?Mq:typeof t=="function"?Lq:$q)(e,t,n??"")):jl(this.node(),e)}function jl(e,t){return e.style.getPropertyValue(t)||TO(e).getComputedStyle(e,null).getPropertyValue(t)}function Oq(e){return function(){delete this[e]}}function Pq(e,t){return function(){this[e]=t}}function Dq(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function Fq(e,t){return arguments.length>1?this.each((t==null?Oq:typeof t=="function"?Dq:Pq)(e,t)):this.node()[e]}function AO(e){return e.trim().split(/^|\s+/)}function X1(e){return e.classList||new RO(e)}function RO(e){this._node=e,this._names=AO(e.getAttribute("class")||"")}RO.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 MO(e,t){for(var n=X1(e),s=-1,a=t.length;++s<a;)n.add(t[s])}function $O(e,t){for(var n=X1(e),s=-1,a=t.length;++s<a;)n.remove(t[s])}function Bq(e){return function(){MO(this,e)}}function qq(e){return function(){$O(this,e)}}function Uq(e,t){return function(){(t.apply(this,arguments)?MO:$O)(this,e)}}function Wq(e,t){var n=AO(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"?Uq:t?Bq:qq)(n,t))}function Hq(){this.textContent=""}function zq(e){return function(){this.textContent=e}}function Vq(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function Gq(e){return arguments.length?this.each(e==null?Hq:(typeof e=="function"?Vq:zq)(e)):this.node().textContent}function Kq(){this.innerHTML=""}function Yq(e){return function(){this.innerHTML=e}}function Xq(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function Zq(e){return arguments.length?this.each(e==null?Kq:(typeof e=="function"?Xq:Yq)(e)):this.node().innerHTML}function Jq(){this.nextSibling&&this.parentNode.appendChild(this)}function Qq(){return this.each(Jq)}function eU(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function tU(){return this.each(eU)}function nU(e){var t=typeof e=="function"?e:NO(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function sU(){return null}function rU(e,t){var n=typeof e=="function"?e:NO(e),s=t==null?sU:typeof t=="function"?t:Y1(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),s.apply(this,arguments)||null)})}function aU(){var e=this.parentNode;e&&e.removeChild(this)}function oU(){return this.each(aU)}function iU(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function lU(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function cU(e){return this.select(e?lU:iU)}function uU(e){return arguments.length?this.property("__data__",e):this.node().__data__}function dU(e){return function(t){e.call(this,t,this.__data__)}}function hU(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 fU(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 pU(e,t,n){return function(){var s=this.__on,a,o=dU(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 mU(e,t,n){var s=hU(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?pU:fU,a=0;a<o;++a)this.each(c(s[a],t,n));return this}function LO(e,t,n){var s=TO(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 gU(e,t){return function(){return LO(this,e,t)}}function yU(e,t){return function(){return LO(this,e,t.apply(this,arguments))}}function wU(e,t){return this.each((typeof t=="function"?yU:gU)(e,t))}function*xU(){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 IO=[null];function Zn(e,t){this._groups=e,this._parents=t}function qu(){return new Zn([[document.documentElement]],IO)}function vU(){return this}Zn.prototype=qu.prototype={constructor:Zn,select:VB,selectAll:XB,selectChild:eq,selectChildren:rq,filter:aq,data:dq,enter:oq,exit:fq,join:pq,merge:mq,selection:vU,order:gq,sort:yq,call:xq,nodes:vq,node:bq,size:kq,empty:jq,each:Nq,attr:Rq,style:Iq,property:Fq,classed:Wq,text:Gq,html:Zq,raise:Qq,lower:tU,append:nU,insert:rU,remove:oU,clone:cU,datum:uU,on:mU,dispatch:wU,[Symbol.iterator]:xU};function xs(e){return typeof e=="string"?new Zn([[document.querySelector(e)]],[document.documentElement]):new Zn([[e]],IO)}function bU(e){let t;for(;t=e.sourceEvent;)e=t;return e}function zs(e,t){if(e=bU(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 kU={passive:!1},pu={capture:!0,passive:!1};function sy(e){e.stopImmediatePropagation()}function hl(e){e.preventDefault(),e.stopImmediatePropagation()}function OO(e){var t=e.document.documentElement,n=xs(e).on("dragstart.drag",hl,pu);"onselectstart"in t?n.on("selectstart.drag",hl,pu):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function PO(e,t){var n=e.document.documentElement,s=xs(e).on("dragstart.drag",null);t&&(s.on("click.drag",hl,pu),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 jh=e=>()=>e;function w0(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}})}w0.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function jU(e){return!e.ctrlKey&&!e.button}function NU(){return this.parentNode}function SU(e,t){return t??{x:e.x,y:e.y}}function _U(){return navigator.maxTouchPoints||"ontouchstart"in this}function CU(){var e=jU,t=NU,n=SU,s=_U,a={},o=pp("start","drag","end"),i=0,c,d,h,f,p=0;function m(_){_.on("mousedown.drag",w).filter(s).on("touchstart.drag",k).on("touchmove.drag",N,kU).on("touchend.drag touchcancel.drag",j).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function w(_,T){if(!(f||!e.call(this,_,T))){var L=S(this,t.call(this,_,T),_,T,"mouse");L&&(xs(_.view).on("mousemove.drag",v,pu).on("mouseup.drag",b,pu),OO(_.view),sy(_),h=!1,c=_.clientX,d=_.clientY,L("start",_))}}function v(_){if(hl(_),!h){var T=_.clientX-c,L=_.clientY-d;h=T*T+L*L>p}a.mouse("drag",_)}function b(_){xs(_.view).on("mousemove.drag mouseup.drag",null),PO(_.view,h),hl(_),a.mouse("end",_)}function k(_,T){if(e.call(this,_,T)){var L=_.changedTouches,A=t.call(this,_,T),P=L.length,O,U;for(O=0;O<P;++O)(U=S(this,A,_,T,L[O].identifier,L[O]))&&(sy(_),U("start",_,L[O]))}}function N(_){var T=_.changedTouches,L=T.length,A,P;for(A=0;A<L;++A)(P=a[T[A].identifier])&&(hl(_),P("drag",_,T[A]))}function j(_){var T=_.changedTouches,L=T.length,A,P;for(f&&clearTimeout(f),f=setTimeout(function(){f=null},500),A=0;A<L;++A)(P=a[T[A].identifier])&&(sy(_),P("end",_,T[A]))}function S(_,T,L,A,P,O){var U=o.copy(),q=zs(O||L,T),M,I,E;if((E=n.call(_,new w0("beforestart",{sourceEvent:L,target:m,identifier:P,active:i,x:q[0],y:q[1],dx:0,dy:0,dispatch:U}),A))!=null)return M=E.x-q[0]||0,I=E.y-q[1]||0,function D(B,H,G){var z=q,F;switch(B){case"start":a[P]=D,F=i++;break;case"end":delete a[P],--i;case"drag":q=zs(G||H,T),F=i;break}U.call(B,_,new w0(B,{sourceEvent:H,subject:E,target:m,identifier:P,active:F,x:q[0]+M,y:q[1]+I,dx:q[0]-z[0],dy:q[1]-z[1],dispatch:U}),A)}}return m.filter=function(_){return arguments.length?(e=typeof _=="function"?_:jh(!!_),m):e},m.container=function(_){return arguments.length?(t=typeof _=="function"?_:jh(_),m):t},m.subject=function(_){return arguments.length?(n=typeof _=="function"?_:jh(_),m):n},m.touchable=function(_){return arguments.length?(s=typeof _=="function"?_:jh(!!_),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 Z1(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function DO(e,t){var n=Object.create(e.prototype);for(var s in t)n[s]=t[s];return n}function Uu(){}var mu=.7,bf=1/mu,fl="\\s*([+-]?\\d+)\\s*",gu="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",br="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",EU=/^#([0-9a-f]{3,8})$/,TU=new RegExp(`^rgb\\(${fl},${fl},${fl}\\)$`),AU=new RegExp(`^rgb\\(${br},${br},${br}\\)$`),RU=new RegExp(`^rgba\\(${fl},${fl},${fl},${gu}\\)$`),MU=new RegExp(`^rgba\\(${br},${br},${br},${gu}\\)$`),$U=new RegExp(`^hsl\\(${gu},${br},${br}\\)$`),LU=new RegExp(`^hsla\\(${gu},${br},${br},${gu}\\)$`),bC={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};Z1(Uu,yu,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:kC,formatHex:kC,formatHex8:IU,formatHsl:OU,formatRgb:jC,toString:jC});function kC(){return this.rgb().formatHex()}function IU(){return this.rgb().formatHex8()}function OU(){return FO(this).formatHsl()}function jC(){return this.rgb().formatRgb()}function yu(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=EU.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?NC(t):n===3?new $n(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Nh(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Nh(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=TU.exec(e))?new $n(t[1],t[2],t[3],1):(t=AU.exec(e))?new $n(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=RU.exec(e))?Nh(t[1],t[2],t[3],t[4]):(t=MU.exec(e))?Nh(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=$U.exec(e))?CC(t[1],t[2]/100,t[3]/100,1):(t=LU.exec(e))?CC(t[1],t[2]/100,t[3]/100,t[4]):bC.hasOwnProperty(e)?NC(bC[e]):e==="transparent"?new $n(NaN,NaN,NaN,0):null}function NC(e){return new $n(e>>16&255,e>>8&255,e&255,1)}function Nh(e,t,n,s){return s<=0&&(e=t=n=NaN),new $n(e,t,n,s)}function PU(e){return e instanceof Uu||(e=yu(e)),e?(e=e.rgb(),new $n(e.r,e.g,e.b,e.opacity)):new $n}function x0(e,t,n,s){return arguments.length===1?PU(e):new $n(e,t,n,s??1)}function $n(e,t,n,s){this.r=+e,this.g=+t,this.b=+n,this.opacity=+s}Z1($n,x0,DO(Uu,{brighter(e){return e=e==null?bf:Math.pow(bf,e),new $n(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?mu:Math.pow(mu,e),new $n(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new $n(Uo(this.r),Uo(this.g),Uo(this.b),kf(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:SC,formatHex:SC,formatHex8:DU,formatRgb:_C,toString:_C}));function SC(){return`#${Do(this.r)}${Do(this.g)}${Do(this.b)}`}function DU(){return`#${Do(this.r)}${Do(this.g)}${Do(this.b)}${Do((isNaN(this.opacity)?1:this.opacity)*255)}`}function _C(){const e=kf(this.opacity);return`${e===1?"rgb(":"rgba("}${Uo(this.r)}, ${Uo(this.g)}, ${Uo(this.b)}${e===1?")":`, ${e})`}`}function kf(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Uo(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Do(e){return e=Uo(e),(e<16?"0":"")+e.toString(16)}function CC(e,t,n,s){return s<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Vs(e,t,n,s)}function FO(e){if(e instanceof Vs)return new Vs(e.h,e.s,e.l,e.opacity);if(e instanceof Uu||(e=yu(e)),!e)return new Vs;if(e instanceof Vs)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 Vs(i,c,d,e.opacity)}function FU(e,t,n,s){return arguments.length===1?FO(e):new Vs(e,t,n,s??1)}function Vs(e,t,n,s){this.h=+e,this.s=+t,this.l=+n,this.opacity=+s}Z1(Vs,FU,DO(Uu,{brighter(e){return e=e==null?bf:Math.pow(bf,e),new Vs(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?mu:Math.pow(mu,e),new Vs(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 $n(ry(e>=240?e-240:e+120,a,s),ry(e,a,s),ry(e<120?e+240:e-120,a,s),this.opacity)},clamp(){return new Vs(EC(this.h),Sh(this.s),Sh(this.l),kf(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=kf(this.opacity);return`${e===1?"hsl(":"hsla("}${EC(this.h)}, ${Sh(this.s)*100}%, ${Sh(this.l)*100}%${e===1?")":`, ${e})`}`}}));function EC(e){return e=(e||0)%360,e<0?e+360:e}function Sh(e){return Math.max(0,Math.min(1,e||0))}function ry(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 BO=e=>()=>e;function BU(e,t){return function(n){return e+n*t}}function qU(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 UU(e){return(e=+e)==1?qO:function(t,n){return n-t?qU(t,n,e):BO(isNaN(t)?n:t)}}function qO(e,t){var n=t-e;return n?BU(e,n):BO(isNaN(e)?t:e)}const TC=(function e(t){var n=UU(t);function s(a,o){var i=n((a=x0(a)).r,(o=x0(o)).r),c=n(a.g,o.g),d=n(a.b,o.b),h=qO(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 Ha(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var v0=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,ay=new RegExp(v0.source,"g");function WU(e){return function(){return e}}function HU(e){return function(t){return e(t)+""}}function zU(e,t){var n=v0.lastIndex=ay.lastIndex=0,s,a,o,i=-1,c=[],d=[];for(e=e+"",t=t+"";(s=v0.exec(e))&&(a=ay.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:Ha(s,a)})),n=ay.lastIndex;return n<t.length&&(o=t.slice(n),c[i]?c[i]+=o:c[++i]=o),c.length<2?d[0]?HU(d[0].x):WU(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 AC=180/Math.PI,b0={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function UO(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)*AC,skewX:Math.atan(d)*AC,scaleX:i,scaleY:c}}var _h;function VU(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?b0:UO(t.a,t.b,t.c,t.d,t.e,t.f)}function GU(e){return e==null||(_h||(_h=document.createElementNS("http://www.w3.org/2000/svg","g")),_h.setAttribute("transform",e),!(e=_h.transform.baseVal.consolidate()))?b0:(e=e.matrix,UO(e.a,e.b,e.c,e.d,e.e,e.f))}function WO(e,t,n,s){function a(h){return h.length?h.pop()+" ":""}function o(h,f,p,m,w,v){if(h!==p||f!==m){var b=w.push("translate(",null,t,null,n);v.push({i:b-4,x:Ha(h,p)},{i:b-2,x:Ha(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:Ha(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:Ha(h,f)}):f&&p.push(a(p)+"skewX("+f+s)}function d(h,f,p,m,w,v){if(h!==p||f!==m){var b=w.push(a(w)+"scale(",null,",",null,")");v.push({i:b-4,x:Ha(h,p)},{i:b-2,x:Ha(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 v=-1,b=m.length,k;++v<b;)p[(k=m[v]).i]=k.x(w);return p.join("")}}}var KU=WO(VU,"px, ","px)","deg)"),YU=WO(GU,", ",")",")"),XU=1e-12;function RC(e){return((e=Math.exp(e))+1/e)/2}function ZU(e){return((e=Math.exp(e))-1/e)/2}function JU(e){return((e=Math.exp(2*e))-1)/(e+1)}const QU=(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,v=p-d,b=w*w+v*v,k,N;if(b<XU)N=Math.log(m/h)/t,k=function(A){return[c+A*w,d+A*v,h*Math.exp(t*A*N)]};else{var j=Math.sqrt(b),S=(m*m-h*h+s*b)/(2*h*n*j),_=(m*m-h*h-s*b)/(2*m*n*j),T=Math.log(Math.sqrt(S*S+1)-S),L=Math.log(Math.sqrt(_*_+1)-_);N=(L-T)/t,k=function(A){var P=A*N,O=RC(T),U=h/(n*j)*(O*JU(t*P+T)-ZU(T));return[c+U*w,d+U*v,h*O/RC(t*P+T)]}}return k.duration=N*1e3*t/Math.SQRT2,k}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 Nl=0,Kc=0,Lc=0,HO=1e3,jf,Yc,Nf=0,Xo=0,gp=0,wu=typeof performance=="object"&&performance.now?performance:Date,zO=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function J1(){return Xo||(zO(eW),Xo=wu.now()+gp)}function eW(){Xo=0}function Sf(){this._call=this._time=this._next=null}Sf.prototype=VO.prototype={constructor:Sf,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?J1():+n)+(t==null?0:+t),!this._next&&Yc!==this&&(Yc?Yc._next=this:jf=this,Yc=this),this._call=e,this._time=n,k0()},stop:function(){this._call&&(this._call=null,this._time=1/0,k0())}};function VO(e,t,n){var s=new Sf;return s.restart(e,t,n),s}function tW(){J1(),++Nl;for(var e=jf,t;e;)(t=Xo-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Nl}function MC(){Xo=(Nf=wu.now())+gp,Nl=Kc=0;try{tW()}finally{Nl=0,sW(),Xo=0}}function nW(){var e=wu.now(),t=e-Nf;t>HO&&(gp-=t,Nf=e)}function sW(){for(var e,t=jf,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:jf=n);Yc=e,k0(s)}function k0(e){if(!Nl){Kc&&(Kc=clearTimeout(Kc));var t=e-Xo;t>24?(e<1/0&&(Kc=setTimeout(MC,e-wu.now()-gp)),Lc&&(Lc=clearInterval(Lc))):(Lc||(Nf=wu.now(),Lc=setInterval(nW,HO)),Nl=1,zO(MC))}}function $C(e,t,n){var s=new Sf;return t=t==null?0:+t,s.restart(a=>{s.stop(),e(a+t)},t,n),s}var rW=pp("start","end","cancel","interrupt"),aW=[],GO=0,LC=1,j0=2,tf=3,IC=4,N0=5,nf=6;function yp(e,t,n,s,a,o){var i=e.__transition;if(!i)e.__transition={};else if(n in i)return;oW(e,n,{name:t,index:s,group:a,on:rW,tween:aW,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:GO})}function Q1(e,t){var n=Qs(e,t);if(n.state>GO)throw new Error("too late; already scheduled");return n}function Sr(e,t){var n=Qs(e,t);if(n.state>tf)throw new Error("too late; already running");return n}function Qs(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function oW(e,t,n){var s=e.__transition,a;s[t]=n,n.timer=VO(o,0,n.time);function o(h){n.state=LC,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!==LC)return d();for(f in s)if(w=s[f],w.name===n.name){if(w.state===tf)return $C(i);w.state===IC?(w.state=nf,w.timer.stop(),w.on.call("interrupt",e,e.__data__,w.index,w.group),delete s[f]):+f<t&&(w.state=nf,w.timer.stop(),w.on.call("cancel",e,e.__data__,w.index,w.group),delete s[f])}if($C(function(){n.state===tf&&(n.state=IC,n.timer.restart(c,n.delay,n.time),c(h))}),n.state=j0,n.on.call("start",e,e.__data__,n.index,n.group),n.state===j0){for(n.state=tf,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=N0,1),p=-1,m=a.length;++p<m;)a[p].call(e,f);n.state===N0&&(n.on.call("end",e,e.__data__,n.index,n.group),d())}function d(){n.state=nf,n.timer.stop(),delete s[t];for(var h in s)return;delete e.__transition}}function sf(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>j0&&s.state<N0,s.state=nf,s.timer.stop(),s.on.call(a?"interrupt":"cancel",e,e.__data__,s.index,s.group),delete n[i]}o&&delete e.__transition}}function iW(e){return this.each(function(){sf(this,e)})}function lW(e,t){var n,s;return function(){var a=Sr(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 cW(e,t,n){var s,a;if(typeof n!="function")throw new Error;return function(){var o=Sr(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 uW(e,t){var n=this._id;if(e+="",arguments.length<2){for(var s=Qs(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?lW:cW)(n,e,t))}function ej(e,t,n){var s=e._id;return e.each(function(){var a=Sr(this,s);(a.value||(a.value={}))[t]=n.apply(this,arguments)}),function(a){return Qs(a,s).value[t]}}function KO(e,t){var n;return(typeof t=="number"?Ha:t instanceof yu?TC:(n=yu(t))?(t=n,TC):zU)(e,t)}function dW(e){return function(){this.removeAttribute(e)}}function hW(e){return function(){this.removeAttributeNS(e.space,e.local)}}function fW(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 pW(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 mW(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 gW(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 yW(e,t){var n=mp(e),s=n==="transform"?YU:KO;return this.attrTween(e,typeof t=="function"?(n.local?gW:mW)(n,s,ej(this,"attr."+e,t)):t==null?(n.local?hW:dW)(n):(n.local?pW:fW)(n,s,t))}function wW(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function xW(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function vW(e,t){var n,s;function a(){var o=t.apply(this,arguments);return o!==s&&(n=(s=o)&&xW(e,o)),n}return a._value=t,a}function bW(e,t){var n,s;function a(){var o=t.apply(this,arguments);return o!==s&&(n=(s=o)&&wW(e,o)),n}return a._value=t,a}function kW(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=mp(e);return this.tween(n,(s.local?vW:bW)(s,t))}function jW(e,t){return function(){Q1(this,e).delay=+t.apply(this,arguments)}}function NW(e,t){return t=+t,function(){Q1(this,e).delay=t}}function SW(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?jW:NW)(t,e)):Qs(this.node(),t).delay}function _W(e,t){return function(){Sr(this,e).duration=+t.apply(this,arguments)}}function CW(e,t){return t=+t,function(){Sr(this,e).duration=t}}function EW(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?_W:CW)(t,e)):Qs(this.node(),t).duration}function TW(e,t){if(typeof t!="function")throw new Error;return function(){Sr(this,e).ease=t}}function AW(e){var t=this._id;return arguments.length?this.each(TW(t,e)):Qs(this.node(),t).ease}function RW(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Sr(this,e).ease=n}}function MW(e){if(typeof e!="function")throw new Error;return this.each(RW(this._id,e))}function $W(e){typeof e!="function"&&(e=_O(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 ra(s,this._parents,this._name,this._id)}function LW(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 ra(i,this._parents,this._name,this._id)}function IW(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 OW(e,t,n){var s,a,o=IW(t)?Q1:Sr;return function(){var i=o(this,e),c=i.on;c!==s&&(a=(s=c).copy()).on(t,n),i.on=a}}function PW(e,t){var n=this._id;return arguments.length<2?Qs(this.node(),n).on.on(e):this.each(OW(n,e,t))}function DW(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function FW(){return this.on("end.remove",DW(this._id))}function BW(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Y1(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,yp(h[m],t,n,m,h,Qs(f,n)));return new ra(o,this._parents,t,n)}function qW(e){var t=this._name,n=this._id;typeof e!="function"&&(e=SO(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,v=Qs(f,n),b=0,k=m.length;b<k;++b)(w=m[b])&&yp(w,t,n,b,m,v);o.push(m),i.push(f)}return new ra(o,i,t,n)}var UW=qu.prototype.constructor;function WW(){return new UW(this._groups,this._parents)}function HW(e,t){var n,s,a;return function(){var o=jl(this,e),i=(this.style.removeProperty(e),jl(this,e));return o===i?null:o===n&&i===s?a:a=t(n=o,s=i)}}function YO(e){return function(){this.style.removeProperty(e)}}function zW(e,t,n){var s,a=n+"",o;return function(){var i=jl(this,e);return i===a?null:i===s?o:o=t(s=i,n)}}function VW(e,t,n){var s,a,o;return function(){var i=jl(this,e),c=n(this),d=c+"";return c==null&&(d=c=(this.style.removeProperty(e),jl(this,e))),i===d?null:i===s&&d===a?o:(a=d,o=t(s=i,c))}}function GW(e,t){var n,s,a,o="style."+t,i="end."+o,c;return function(){var d=Sr(this,e),h=d.on,f=d.value[o]==null?c||(c=YO(t)):void 0;(h!==n||a!==f)&&(s=(n=h).copy()).on(i,a=f),d.on=s}}function KW(e,t,n){var s=(e+="")=="transform"?KU:KO;return t==null?this.styleTween(e,HW(e,s)).on("end.style."+e,YO(e)):typeof t=="function"?this.styleTween(e,VW(e,s,ej(this,"style."+e,t))).each(GW(this._id,e)):this.styleTween(e,zW(e,s,t),n).on("end.style."+e,null)}function YW(e,t,n){return function(s){this.style.setProperty(e,t.call(this,s),n)}}function XW(e,t,n){var s,a;function o(){var i=t.apply(this,arguments);return i!==a&&(s=(a=i)&&YW(e,i,n)),s}return o._value=t,o}function ZW(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,XW(e,t,n??""))}function JW(e){return function(){this.textContent=e}}function QW(e){return function(){var t=e(this);this.textContent=t??""}}function eH(e){return this.tween("text",typeof e=="function"?QW(ej(this,"text",e)):JW(e==null?"":e+""))}function tH(e){return function(t){this.textContent=e.call(this,t)}}function nH(e){var t,n;function s(){var a=e.apply(this,arguments);return a!==n&&(t=(n=a)&&tH(a)),t}return s._value=e,s}function sH(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,nH(e))}function rH(){for(var e=this._name,t=this._id,n=XO(),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=Qs(d,t);yp(d,e,n,h,i,{time:f.time+f.delay+f.duration,delay:0,duration:f.duration,ease:f.ease})}return new ra(s,this._parents,e,n)}function aH(){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=Sr(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 oH=0;function ra(e,t,n,s){this._groups=e,this._parents=t,this._name=n,this._id=s}function XO(){return++oH}var Vr=qu.prototype;ra.prototype={constructor:ra,select:BW,selectAll:qW,selectChild:Vr.selectChild,selectChildren:Vr.selectChildren,filter:$W,merge:LW,selection:WW,transition:rH,call:Vr.call,nodes:Vr.nodes,node:Vr.node,size:Vr.size,empty:Vr.empty,each:Vr.each,on:PW,attr:yW,attrTween:kW,style:KW,styleTween:ZW,text:eH,textTween:sH,remove:FW,tween:uW,delay:SW,duration:EW,ease:AW,easeVarying:MW,end:aH,[Symbol.iterator]:Vr[Symbol.iterator]};function iH(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var lH={time:null,delay:0,duration:250,ease:iH};function cH(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 uH(e){var t,n;e instanceof ra?(t=e._id,e=e._name):(t=XO(),(n=lH).time=J1(),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])&&yp(d,e,t,h,i,n||cH(d,t));return new ra(s,this._parents,e,t)}qu.prototype.interrupt=iW;qu.prototype.transition=uH;const Ch=e=>()=>e;function dH(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 ea(e,t,n){this.k=e,this.x=t,this.y=n}ea.prototype={constructor:ea,scale:function(e){return e===1?this:new ea(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new ea(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 ta=new ea(1,0,0);ea.prototype;function oy(e){e.stopImmediatePropagation()}function Ic(e){e.preventDefault(),e.stopImmediatePropagation()}function hH(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function fH(){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 OC(){return this.__zoom||ta}function pH(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function mH(){return navigator.maxTouchPoints||"ontouchstart"in this}function gH(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 ZO(){var e=hH,t=fH,n=gH,s=pH,a=mH,o=[0,1/0],i=[[-1/0,-1/0],[1/0,1/0]],c=250,d=QU,h=pp("start","zoom","end"),f,p,m,w=500,v=150,b=0,k=10;function N(E){E.property("__zoom",OC).on("wheel.zoom",P,{passive:!1}).on("mousedown.zoom",O).on("dblclick.zoom",U).filter(a).on("touchstart.zoom",q).on("touchmove.zoom",M).on("touchend.zoom touchcancel.zoom",I).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}N.transform=function(E,D,B,H){var G=E.selection?E.selection():E;G.property("__zoom",OC),E!==G?T(E,D,B,H):G.interrupt().each(function(){L(this,arguments).event(H).start().zoom(null,typeof D=="function"?D.apply(this,arguments):D).end()})},N.scaleBy=function(E,D,B,H){N.scaleTo(E,function(){var G=this.__zoom.k,z=typeof D=="function"?D.apply(this,arguments):D;return G*z},B,H)},N.scaleTo=function(E,D,B,H){N.transform(E,function(){var G=t.apply(this,arguments),z=this.__zoom,F=B==null?_(G):typeof B=="function"?B.apply(this,arguments):B,$=z.invert(F),W=typeof D=="function"?D.apply(this,arguments):D;return n(S(j(z,W),F,$),G,i)},B,H)},N.translateBy=function(E,D,B,H){N.transform(E,function(){return n(this.__zoom.translate(typeof D=="function"?D.apply(this,arguments):D,typeof B=="function"?B.apply(this,arguments):B),t.apply(this,arguments),i)},null,H)},N.translateTo=function(E,D,B,H,G){N.transform(E,function(){var z=t.apply(this,arguments),F=this.__zoom,$=H==null?_(z):typeof H=="function"?H.apply(this,arguments):H;return n(ta.translate($[0],$[1]).scale(F.k).translate(typeof D=="function"?-D.apply(this,arguments):-D,typeof B=="function"?-B.apply(this,arguments):-B),z,i)},H,G)};function j(E,D){return D=Math.max(o[0],Math.min(o[1],D)),D===E.k?E:new ea(D,E.x,E.y)}function S(E,D,B){var H=D[0]-B[0]*E.k,G=D[1]-B[1]*E.k;return H===E.x&&G===E.y?E:new ea(E.k,H,G)}function _(E){return[(+E[0][0]+ +E[1][0])/2,(+E[0][1]+ +E[1][1])/2]}function T(E,D,B,H){E.on("start.zoom",function(){L(this,arguments).event(H).start()}).on("interrupt.zoom end.zoom",function(){L(this,arguments).event(H).end()}).tween("zoom",function(){var G=this,z=arguments,F=L(G,z).event(H),$=t.apply(G,z),W=B==null?_($):typeof B=="function"?B.apply(G,z):B,Z=Math.max($[1][0]-$[0][0],$[1][1]-$[0][1]),V=G.__zoom,Y=typeof D=="function"?D.apply(G,z):D,X=d(V.invert(W).concat(Z/V.k),Y.invert(W).concat(Z/Y.k));return function(J){if(J===1)J=Y;else{var Q=X(J),te=Z/Q[2];J=new ea(te,W[0]-Q[0]*te,W[1]-Q[1]*te)}F.zoom(null,J)}})}function L(E,D,B){return!B&&E.__zooming||new A(E,D)}function A(E,D){this.that=E,this.args=D,this.active=0,this.sourceEvent=null,this.extent=t.apply(E,D),this.taps=0}A.prototype={event:function(E){return E&&(this.sourceEvent=E),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(E,D){return this.mouse&&E!=="mouse"&&(this.mouse[1]=D.invert(this.mouse[0])),this.touch0&&E!=="touch"&&(this.touch0[1]=D.invert(this.touch0[0])),this.touch1&&E!=="touch"&&(this.touch1[1]=D.invert(this.touch1[0])),this.that.__zoom=D,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(E){var D=xs(this.that).datum();h.call(E,this.that,new dH(E,{sourceEvent:this.sourceEvent,target:N,transform:this.that.__zoom,dispatch:h}),D)}};function P(E,...D){if(!e.apply(this,arguments))return;var B=L(this,D).event(E),H=this.__zoom,G=Math.max(o[0],Math.min(o[1],H.k*Math.pow(2,s.apply(this,arguments)))),z=zs(E);if(B.wheel)(B.mouse[0][0]!==z[0]||B.mouse[0][1]!==z[1])&&(B.mouse[1]=H.invert(B.mouse[0]=z)),clearTimeout(B.wheel);else{if(H.k===G)return;B.mouse=[z,H.invert(z)],sf(this),B.start()}Ic(E),B.wheel=setTimeout(F,v),B.zoom("mouse",n(S(j(H,G),B.mouse[0],B.mouse[1]),B.extent,i));function F(){B.wheel=null,B.end()}}function O(E,...D){if(m||!e.apply(this,arguments))return;var B=E.currentTarget,H=L(this,D,!0).event(E),G=xs(E.view).on("mousemove.zoom",W,!0).on("mouseup.zoom",Z,!0),z=zs(E,B),F=E.clientX,$=E.clientY;OO(E.view),oy(E),H.mouse=[z,this.__zoom.invert(z)],sf(this),H.start();function W(V){if(Ic(V),!H.moved){var Y=V.clientX-F,X=V.clientY-$;H.moved=Y*Y+X*X>b}H.event(V).zoom("mouse",n(S(H.that.__zoom,H.mouse[0]=zs(V,B),H.mouse[1]),H.extent,i))}function Z(V){G.on("mousemove.zoom mouseup.zoom",null),PO(V.view,H.moved),Ic(V),H.event(V).end()}}function U(E,...D){if(e.apply(this,arguments)){var B=this.__zoom,H=zs(E.changedTouches?E.changedTouches[0]:E,this),G=B.invert(H),z=B.k*(E.shiftKey?.5:2),F=n(S(j(B,z),H,G),t.apply(this,D),i);Ic(E),c>0?xs(this).transition().duration(c).call(T,F,H,E):xs(this).call(N.transform,F,H,E)}}function q(E,...D){if(e.apply(this,arguments)){var B=E.touches,H=B.length,G=L(this,D,E.changedTouches.length===H).event(E),z,F,$,W;for(oy(E),F=0;F<H;++F)$=B[F],W=zs($,this),W=[W,this.__zoom.invert(W),$.identifier],G.touch0?!G.touch1&&G.touch0[2]!==W[2]&&(G.touch1=W,G.taps=0):(G.touch0=W,z=!0,G.taps=1+!!f);f&&(f=clearTimeout(f)),z&&(G.taps<2&&(p=W[0],f=setTimeout(function(){f=null},w)),sf(this),G.start())}}function M(E,...D){if(this.__zooming){var B=L(this,D).event(E),H=E.changedTouches,G=H.length,z,F,$,W;for(Ic(E),z=0;z<G;++z)F=H[z],$=zs(F,this),B.touch0&&B.touch0[2]===F.identifier?B.touch0[0]=$:B.touch1&&B.touch1[2]===F.identifier&&(B.touch1[0]=$);if(F=B.that.__zoom,B.touch1){var Z=B.touch0[0],V=B.touch0[1],Y=B.touch1[0],X=B.touch1[1],J=(J=Y[0]-Z[0])*J+(J=Y[1]-Z[1])*J,Q=(Q=X[0]-V[0])*Q+(Q=X[1]-V[1])*Q;F=j(F,Math.sqrt(J/Q)),$=[(Z[0]+Y[0])/2,(Z[1]+Y[1])/2],W=[(V[0]+X[0])/2,(V[1]+X[1])/2]}else if(B.touch0)$=B.touch0[0],W=B.touch0[1];else return;B.zoom("touch",n(S(F,$,W),B.extent,i))}}function I(E,...D){if(this.__zooming){var B=L(this,D).event(E),H=E.changedTouches,G=H.length,z,F;for(oy(E),m&&clearTimeout(m),m=setTimeout(function(){m=null},w),z=0;z<G;++z)F=H[z],B.touch0&&B.touch0[2]===F.identifier?delete B.touch0:B.touch1&&B.touch1[2]===F.identifier&&delete B.touch1;if(B.touch1&&!B.touch0&&(B.touch0=B.touch1,delete B.touch1),B.touch0)B.touch0[1]=this.__zoom.invert(B.touch0[0]);else if(B.end(),B.taps===2&&(F=zs(F,this),Math.hypot(p[0]-F[0],p[1]-F[1])<k)){var $=xs(this).on("dblclick.zoom");$&&$.apply(this,arguments)}}}return N.wheelDelta=function(E){return arguments.length?(s=typeof E=="function"?E:Ch(+E),N):s},N.filter=function(E){return arguments.length?(e=typeof E=="function"?E:Ch(!!E),N):e},N.touchable=function(E){return arguments.length?(a=typeof E=="function"?E:Ch(!!E),N):a},N.extent=function(E){return arguments.length?(t=typeof E=="function"?E:Ch([[+E[0][0],+E[0][1]],[+E[1][0],+E[1][1]]]),N):t},N.scaleExtent=function(E){return arguments.length?(o[0]=+E[0],o[1]=+E[1],N):[o[0],o[1]]},N.translateExtent=function(E){return arguments.length?(i[0][0]=+E[0][0],i[1][0]=+E[1][0],i[0][1]=+E[0][1],i[1][1]=+E[1][1],N):[[i[0][0],i[0][1]],[i[1][0],i[1][1]]]},N.constrain=function(E){return arguments.length?(n=E,N):n},N.duration=function(E){return arguments.length?(c=+E,N):c},N.interpolate=function(E){return arguments.length?(d=E,N):d},N.on=function(){var E=h.on.apply(h,arguments);return E===h?N:E},N.clickDistance=function(E){return arguments.length?(b=(E=+E)*E,N):Math.sqrt(b)},N.tapDistance=function(E){return arguments.length?(k=+E,N):k},N}var xt=kO();const wp=y.createContext(null),yH=wp.Provider,aa={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.`},JO=aa.error001();function lt(e,t){const n=y.useContext(wp);if(n===null)throw new Error(JO);return jO(n,e,t)}const Pt=()=>{const e=y.useContext(wp);if(e===null)throw new Error(JO);return y.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy}),[e])},wH=e=>e.userSelectionActive?"none":"all";function tj({position:e,children:t,className:n,style:s,...a}){const o=lt(wH),i=`${e}`.split("-");return he.createElement("div",{className:an(["react-flow__panel",n,...i]),style:{...s,pointerEvents:o},...a},t)}function xH({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:he.createElement(tj,{position:t,className:"react-flow__attribution","data-message":"Please only hide this attribution when you are subscribed to React Flow Pro: https://reactflow.dev/pro"},he.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}const vH=({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}),v=an(["react-flow__edge-textwrapper",h]);return y.useEffect(()=>{if(p.current){const b=p.current.getBBox();w({x:b.x,y:b.y,width:b.width,height:b.height})}},[n]),typeof n>"u"||!n?null:he.createElement("g",{transform:`translate(${e-m.width/2} ${t-m.height/2})`,className:v,visibility:m.width?"visible":"hidden",...f},a&&he.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}),he.createElement("text",{className:"react-flow__edge-text",y:m.height/2,dy:"0.3em",ref:p,style:s},n),d)};var bH=y.memo(vH);const nj=e=>({width:e.offsetWidth,height:e.offsetHeight}),Sl=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),sj=(e={x:0,y:0},t)=>({x:Sl(e.x,t[0][0],t[1][0]),y:Sl(e.y,t[0][1],t[1][1])}),PC=(e,t,n)=>e<t?Sl(Math.abs(e-t),1,50)/50:e>n?-Sl(Math.abs(e-n),1,50)/50:0,QO=(e,t)=>{const n=PC(e.x,35,t.width-35)*20,s=PC(e.y,35,t.height-35)*20;return[n,s]},e3=e=>{var t;return((t=e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},t3=(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)}),xu=({x:e,y:t,width:n,height:s})=>({x:e,y:t,x2:e+n,y2:t+s}),n3=({x:e,y:t,x2:n,y2:s})=>({x:e,y:t,width:n-e,height:s-t}),DC=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),kH=(e,t)=>n3(t3(xu(e),xu(t))),S0=(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)},jH=e=>vs(e.width)&&vs(e.height)&&vs(e.x)&&vs(e.y),vs=e=>!isNaN(e)&&isFinite(e),Lt=Symbol.for("internals"),s3=["Enter"," ","Escape"],NH=(e,t)=>{},SH=e=>"nativeEvent"in e;function _0(e){var a,o;const t=SH(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 r3=e=>"clientX"in e,Qa=(e,t)=>{var o,i;const n=r3(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)}},_f=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0},Wu=({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})=>he.createElement(he.Fragment,null,he.createElement("path",{id:e,style:f,d:t,fill:"none",className:"react-flow__edge-path",markerEnd:p,markerStart:m}),w&&he.createElement("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:w,className:"react-flow__edge-interaction"}),a&&vs(n)&&vs(s)?he.createElement(bH,{x:n,y:s,label:a,labelStyle:o,labelShowBg:i,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h}):null);Wu.displayName="BaseEdge";function Oc(e,t,n){return n===void 0?n:s=>{const a=t().edges.find(o=>o.id===e);a&&n(s,{...a})}}function a3({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 o3({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 Zo;(function(e){e.Strict="strict",e.Loose="loose"})(Zo||(Zo={}));var Fo;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Fo||(Fo={}));var vu;(function(e){e.Partial="partial",e.Full="full"})(vu||(vu={}));var Ga;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Ga||(Ga={}));var Cf;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Cf||(Cf={}));var De;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(De||(De={}));function FC({pos:e,x1:t,y1:n,x2:s,y2:a}){return e===De.Left||e===De.Right?[.5*(t+s),n]:[t,.5*(n+a)]}function i3({sourceX:e,sourceY:t,sourcePosition:n=De.Bottom,targetX:s,targetY:a,targetPosition:o=De.Top}){const[i,c]=FC({pos:n,x1:e,y1:t,x2:s,y2:a}),[d,h]=FC({pos:o,x1:s,y1:a,x2:e,y2:t}),[f,p,m,w]=o3({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 rj=y.memo(({sourceX:e,sourceY:t,targetX:n,targetY:s,sourcePosition:a=De.Bottom,targetPosition:o=De.Top,label:i,labelStyle:c,labelShowBg:d,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:w,markerStart:v,interactionWidth:b})=>{const[k,N,j]=i3({sourceX:e,sourceY:t,sourcePosition:a,targetX:n,targetY:s,targetPosition:o});return he.createElement(Wu,{path:k,labelX:N,labelY:j,label:i,labelStyle:c,labelShowBg:d,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:w,markerStart:v,interactionWidth:b})});rj.displayName="SimpleBezierEdge";const BC={[De.Left]:{x:-1,y:0},[De.Right]:{x:1,y:0},[De.Top]:{x:0,y:-1},[De.Bottom]:{x:0,y:1}},_H=({source:e,sourcePosition:t=De.Bottom,target:n})=>t===De.Left||t===De.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},qC=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function CH({source:e,sourcePosition:t=De.Bottom,target:n,targetPosition:s=De.Top,center:a,offset:o}){const i=BC[t],c=BC[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=_H({source:d,sourcePosition:t,target:h}),p=f.x!==0?"x":"y",m=f[p];let w=[],v,b;const k={x:0,y:0},N={x:0,y:0},[j,S,_,T]=a3({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(i[p]*c[p]===-1){v=a.x??j,b=a.y??S;const A=[{x:v,y:d.y},{x:v,y:h.y}],P=[{x:d.x,y:b},{x:h.x,y:b}];i[p]===m?w=p==="x"?A:P:w=p==="x"?P:A}else{const A=[{x:d.x,y:h.y}],P=[{x:h.x,y:d.y}];if(p==="x"?w=i.x===m?P:A:w=i.y===m?A:P,t===s){const I=Math.abs(e[p]-n[p]);if(I<=o){const E=Math.min(o-1,o-I);i[p]===m?k[p]=(d[p]>e[p]?-1:1)*E:N[p]=(h[p]>n[p]?-1:1)*E}}if(t!==s){const I=p==="x"?"y":"x",E=i[p]===c[I],D=d[I]>h[I],B=d[I]<h[I];(i[p]===1&&(!E&&D||E&&B)||i[p]!==1&&(!E&&B||E&&D))&&(w=p==="x"?A:P)}const O={x:d.x+k.x,y:d.y+k.y},U={x:h.x+N.x,y:h.y+N.y},q=Math.max(Math.abs(O.x-w[0].x),Math.abs(U.x-w[0].x)),M=Math.max(Math.abs(O.y-w[0].y),Math.abs(U.y-w[0].y));q>=M?(v=(O.x+U.x)/2,b=w[0].y):(v=w[0].x,b=(O.y+U.y)/2)}return[[e,{x:d.x+k.x,y:d.y+k.y},...w,{x:h.x+N.x,y:h.y+N.y},n],v,b,_,T]}function EH(e,t,n,s){const a=Math.min(qC(e,t)/2,qC(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 C0({sourceX:e,sourceY:t,sourcePosition:n=De.Bottom,targetX:s,targetY:a,targetPosition:o=De.Top,borderRadius:i=5,centerX:c,centerY:d,offset:h=20}){const[f,p,m,w,v]=CH({source:{x:e,y:t},sourcePosition:n,target:{x:s,y:a},targetPosition:o,center:{x:c,y:d},offset:h});return[f.reduce((k,N,j)=>{let S="";return j>0&&j<f.length-1?S=EH(f[j-1],N,f[j+1],i):S=`${j===0?"M":"L"}${N.x} ${N.y}`,k+=S,k},""),p,m,w,v]}const xp=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=De.Bottom,targetPosition:m=De.Top,markerEnd:w,markerStart:v,pathOptions:b,interactionWidth:k})=>{const[N,j,S]=C0({sourceX:e,sourceY:t,sourcePosition:p,targetX:n,targetY:s,targetPosition:m,borderRadius:b==null?void 0:b.borderRadius,offset:b==null?void 0:b.offset});return he.createElement(Wu,{path:N,labelX:j,labelY:S,label:a,labelStyle:o,labelShowBg:i,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:w,markerStart:v,interactionWidth:k})});xp.displayName="SmoothStepEdge";const aj=y.memo(e=>{var t;return he.createElement(xp,{...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])})});aj.displayName="StepEdge";function TH({sourceX:e,sourceY:t,targetX:n,targetY:s}){const[a,o,i,c]=a3({sourceX:e,sourceY:t,targetX:n,targetY:s});return[`M ${e},${t}L ${n},${s}`,a,o,i,c]}const oj=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[v,b,k]=TH({sourceX:e,sourceY:t,targetX:n,targetY:s});return he.createElement(Wu,{path:v,labelX:b,labelY:k,label:a,labelStyle:o,labelShowBg:i,labelBgStyle:c,labelBgPadding:d,labelBgBorderRadius:h,style:f,markerEnd:p,markerStart:m,interactionWidth:w})});oj.displayName="StraightEdge";function Eh(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function UC({pos:e,x1:t,y1:n,x2:s,y2:a,c:o}){switch(e){case De.Left:return[t-Eh(t-s,o),n];case De.Right:return[t+Eh(s-t,o),n];case De.Top:return[t,n-Eh(n-a,o)];case De.Bottom:return[t,n+Eh(a-n,o)]}}function ij({sourceX:e,sourceY:t,sourcePosition:n=De.Bottom,targetX:s,targetY:a,targetPosition:o=De.Top,curvature:i=.25}){const[c,d]=UC({pos:n,x1:e,y1:t,x2:s,y2:a,c:i}),[h,f]=UC({pos:o,x1:s,y1:a,x2:e,y2:t,c:i}),[p,m,w,v]=o3({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,v]}const Ef=y.memo(({sourceX:e,sourceY:t,targetX:n,targetY:s,sourcePosition:a=De.Bottom,targetPosition:o=De.Top,label:i,labelStyle:c,labelShowBg:d,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:w,markerStart:v,pathOptions:b,interactionWidth:k})=>{const[N,j,S]=ij({sourceX:e,sourceY:t,sourcePosition:a,targetX:n,targetY:s,targetPosition:o,curvature:b==null?void 0:b.curvature});return he.createElement(Wu,{path:N,labelX:j,labelY:S,label:i,labelStyle:c,labelShowBg:d,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:w,markerStart:v,interactionWidth:k})});Ef.displayName="BezierEdge";const lj=y.createContext(null),AH=lj.Provider;lj.Consumer;const RH=()=>y.useContext(lj),MH=e=>"id"in e&&"source"in e&&"target"in e,$H=({source:e,sourceHandle:t,target:n,targetHandle:s})=>`reactflow__edge-${e}${t||""}-${n}${s||""}`,E0=(e,t)=>typeof e>"u"?"":typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(s=>`${s}=${e[s]}`).join("&")}`,LH=(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)),IH=(e,t)=>{if(!e.source||!e.target)return t;let n;return MH(e)?n={...e}:n={...e,id:$H(e)},LH(n,t)?t:t.concat(n)},T0=({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},l3=({x:e,y:t},[n,s,a])=>({x:e*a+n,y:t*a+s}),Wo=(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}},vp=(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}=Wo(a,t).positionAbsolute;return t3(s,xu({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 n3(n)},c3=(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:v=!1}=f;if(i&&!w||v)return!1;const{positionAbsolute:b}=Wo(f,c),k={x:b.x,y:b.y,width:p||0,height:m||0},N=S0(d,k),j=typeof p>"u"||typeof m>"u"||p===null||m===null,S=o&&N>0,_=(p||0)*(m||0);(j||S||N>=_||f.dragging)&&h.push(f)}),h},u3=(e,t)=>{const n=e.map(s=>s.id);return t.filter(s=>n.includes(s.source)||n.includes(s.target))},d3=(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=Sl(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}},$o=(e,t=0)=>e.transition().duration(t);function WC(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 OH(e,t,n,s,a,o){const{x:i,y:c}=Qa(e),h=t.elementsFromPoint(i,c).find(v=>v.classList.contains("react-flow__handle"));if(h){const v=h.getAttribute("data-nodeid");if(v){const b=cj(void 0,h),k=h.getAttribute("data-handleid"),N=o({nodeId:v,id:k,type:b});if(N){const j=a.find(S=>S.nodeId===v&&S.type===b&&S.id===k);return{handle:{id:k,type:b,nodeId:v,x:(j==null?void 0:j.x)||n.x,y:(j==null?void 0:j.y)||n.y},validHandleResult:N}}}}let f=[],p=1/0;if(a.forEach(v=>{const b=Math.sqrt((v.x-n.x)**2+(v.y-n.y)**2);if(b<=s){const k=o(v);b<=p&&(b<p?f=[{handle:v,validHandleResult:k}]:b===p&&f.push({handle:v,validHandleResult:k}),p=b)}}),!f.length)return{handle:null,validHandleResult:h3()};if(f.length===1)return f[0];const m=f.some(({validHandleResult:v})=>v.isValid),w=f.some(({handle:v})=>v.type==="target");return f.find(({handle:v,validHandleResult:b})=>w?v.type==="target":m?b.isValid:!0)||f[0]}const PH={source:null,target:null,sourceHandle:null,targetHandle:null},h3=()=>({handleDomNode:null,isValid:!1,connection:PH,endHandle:null});function f3(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={...h3(),handleDomNode:d};if(d){const f=cj(void 0,d),p=d.getAttribute("data-nodeid"),m=d.getAttribute("data-handleid"),w=d.classList.contains("connectable"),v=d.classList.contains("connectableend"),b={source:c?p:n,sourceHandle:c?m:s,target:c?n:p,targetHandle:c?s:m};h.connection=b,w&&v&&(t===Zo.Strict?c&&f==="source"||!c&&f==="target":p!==n||m!==s)&&(h.endHandle={nodeId:p,handleId:m,type:f},h.isValid=o(b))}return h}function DH({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=WC(o,i,"source",`${t}-${n}-${s}`),d=WC(o,i,"target",`${t}-${n}-${s}`)),a.push(...c,...d)}return a},[])}function cj(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function iy(e){e==null||e.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function FH(e,t){let n=null;return t?n="valid":e&&!t&&(n="invalid"),n}function p3({event:e,handleId:t,nodeId:n,onConnect:s,isTarget:a,getState:o,setState:i,isValidConnection:c,edgeUpdaterType:d,onReconnectEnd:h}){const f=e3(e.target),{connectionMode:p,domNode:m,autoPanOnConnect:w,connectionRadius:v,onConnectStart:b,panBy:k,getNodes:N,cancelConnection:j}=o();let S=0,_;const{x:T,y:L}=Qa(e),A=f==null?void 0:f.elementFromPoint(T,L),P=cj(d,A),O=m==null?void 0:m.getBoundingClientRect();if(!O||!P)return;let U,q=Qa(e,O),M=!1,I=null,E=!1,D=null;const B=DH({nodes:N(),nodeId:n,handleId:t,handleType:P}),H=()=>{if(!w)return;const[F,$]=QO(q,O);k({x:F,y:$}),S=requestAnimationFrame(H)};i({connectionPosition:q,connectionStatus:null,connectionNodeId:n,connectionHandleId:t,connectionHandleType:P,connectionStartHandle:{nodeId:n,handleId:t,type:P},connectionEndHandle:null}),b==null||b(e,{nodeId:n,handleId:t,handleType:P});function G(F){const{transform:$}=o();q=Qa(F,O);const{handle:W,validHandleResult:Z}=OH(F,f,T0(q,$,!1,[1,1]),v,B,V=>f3(V,p,n,t,a?"target":"source",c,f));if(_=W,M||(H(),M=!0),D=Z.handleDomNode,I=Z.connection,E=Z.isValid,i({connectionPosition:_&&E?l3({x:_.x,y:_.y},$):q,connectionStatus:FH(!!_,E),connectionEndHandle:Z.endHandle}),!_&&!E&&!D)return iy(U);I.source!==I.target&&D&&(iy(U),U=D,D.classList.add("connecting","react-flow__handle-connecting"),D.classList.toggle("valid",E),D.classList.toggle("react-flow__handle-valid",E))}function z(F){var $,W;(_||D)&&I&&E&&(s==null||s(I)),(W=($=o()).onConnectEnd)==null||W.call($,F),d&&(h==null||h(F)),iy(U),j(),cancelAnimationFrame(S),M=!1,E=!1,I=null,D=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 HC=()=>!0,BH=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),qH=(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}},m3=y.forwardRef(({type:e="source",position:t=De.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 O,U;const v=i||null,b=e==="target",k=Pt(),N=RH(),{connectOnClick:j,noPanClassName:S}=lt(BH,Xt),{connecting:_,clickConnecting:T}=lt(qH(N,v,e),Xt);N||(U=(O=k.getState()).onError)==null||U.call(O,"010",aa.error010());const L=q=>{const{defaultEdgeOptions:M,onConnect:I,hasDefaultEdges:E}=k.getState(),D={...M,...q};if(E){const{edges:B,setEdges:H}=k.getState();H(IH(D,B))}I==null||I(D),c==null||c(D)},A=q=>{if(!N)return;const M=r3(q);a&&(M&&q.button===0||!M)&&p3({event:q,handleId:v,nodeId:N,onConnect:L,isTarget:b,getState:k.getState,setState:k.setState,isValidConnection:n||k.getState().isValidConnection||HC}),M?f==null||f(q):p==null||p(q)},P=q=>{const{onClickConnectStart:M,onClickConnectEnd:I,connectionClickStartHandle:E,connectionMode:D,isValidConnection:B}=k.getState();if(!N||!E&&!a)return;if(!E){M==null||M(q,{nodeId:N,handleId:v,handleType:e}),k.setState({connectionClickStartHandle:{nodeId:N,type:e,handleId:v}});return}const H=e3(q.target),G=n||B||HC,{connection:z,isValid:F}=f3({nodeId:N,id:v,type:e},D,E.nodeId,E.handleId||null,E.type,G,H);F&&L(z),I==null||I(q),k.setState({connectionClickStartHandle:null})};return he.createElement("div",{"data-handleid":v,"data-nodeid":N,"data-handlepos":t,"data-id":`${N}-${v}-${e}`,className:an(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",S,h,{source:!b,target:b,connectable:s,connectablestart:a,connectableend:o,connecting:T,connectionindicator:s&&(a&&!_||o&&_)}]),onMouseDown:A,onTouchStart:A,onClick:j?P:void 0,ref:w,...m},d)});m3.displayName="Handle";var Jo=y.memo(m3);const g3=({data:e,isConnectable:t,targetPosition:n=De.Top,sourcePosition:s=De.Bottom})=>he.createElement(he.Fragment,null,he.createElement(Jo,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,he.createElement(Jo,{type:"source",position:s,isConnectable:t}));g3.displayName="DefaultNode";var A0=y.memo(g3);const y3=({data:e,isConnectable:t,sourcePosition:n=De.Bottom})=>he.createElement(he.Fragment,null,e==null?void 0:e.label,he.createElement(Jo,{type:"source",position:n,isConnectable:t}));y3.displayName="InputNode";var w3=y.memo(y3);const x3=({data:e,isConnectable:t,targetPosition:n=De.Top})=>he.createElement(he.Fragment,null,he.createElement(Jo,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label);x3.displayName="OutputNode";var v3=y.memo(x3);const uj=()=>null;uj.displayName="GroupNode";const UH=e=>({selectedNodes:e.getNodes().filter(t=>t.selected),selectedEdges:e.edges.filter(t=>t.selected).map(t=>({...t}))}),Th=e=>e.id;function WH(e,t){return Xt(e.selectedNodes.map(Th),t.selectedNodes.map(Th))&&Xt(e.selectedEdges.map(Th),t.selectedEdges.map(Th))}const b3=y.memo(({onSelectionChange:e})=>{const t=Pt(),{selectedNodes:n,selectedEdges:s}=lt(UH,WH);return y.useEffect(()=>{const a={nodes:n,edges:s};e==null||e(a),t.getState().onSelectionChange.forEach(o=>o(a))},[n,s,e]),null});b3.displayName="SelectionListener";const HH=e=>!!e.onSelectionChange;function zH({onSelectionChange:e}){const t=lt(HH);return e||t?he.createElement(b3,{onSelectionChange:e}):null}const VH=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 qi(e,t){y.useEffect(()=>{typeof e<"u"&&t(e)},[e])}function nt(e,t,n){y.useEffect(()=>{typeof t<"u"&&n({[e]:t})},[t])}const GH=({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:v,minZoom:b,maxZoom:k,nodeExtent:N,onNodesChange:j,onEdgesChange:S,elementsSelectable:_,connectionMode:T,snapGrid:L,snapToGrid:A,translateExtent:P,connectOnClick:O,defaultEdgeOptions:U,fitView:q,fitViewOptions:M,onNodesDelete:I,onEdgesDelete:E,onNodeDrag:D,onNodeDragStart:B,onNodeDragStop:H,onSelectionDrag:G,onSelectionDragStart:z,onSelectionDragStop:F,noPanClassName:$,nodeOrigin:W,rfId:Z,autoPanOnConnect:V,autoPanOnNodeDrag:Y,onError:X,connectionRadius:J,isValidConnection:Q,nodeDragThreshold:te})=>{const{setNodes:ce,setEdges:ue,setDefaultNodesAndEdges:ie,setMinZoom:re,setMaxZoom:fe,setTranslateExtent:ae,setNodeExtent:je,reset:me}=lt(VH,Xt),pe=Pt();return y.useEffect(()=>{const xe=s==null?void 0:s.map(_e=>({..._e,...U}));return ie(n,xe),()=>{me()}},[]),nt("defaultEdgeOptions",U,pe.setState),nt("connectionMode",T,pe.setState),nt("onConnect",a,pe.setState),nt("onConnectStart",o,pe.setState),nt("onConnectEnd",i,pe.setState),nt("onClickConnectStart",c,pe.setState),nt("onClickConnectEnd",d,pe.setState),nt("nodesDraggable",h,pe.setState),nt("nodesConnectable",f,pe.setState),nt("nodesFocusable",p,pe.setState),nt("edgesFocusable",m,pe.setState),nt("edgesUpdatable",w,pe.setState),nt("elementsSelectable",_,pe.setState),nt("elevateNodesOnSelect",v,pe.setState),nt("snapToGrid",A,pe.setState),nt("snapGrid",L,pe.setState),nt("onNodesChange",j,pe.setState),nt("onEdgesChange",S,pe.setState),nt("connectOnClick",O,pe.setState),nt("fitViewOnInit",q,pe.setState),nt("fitViewOnInitOptions",M,pe.setState),nt("onNodesDelete",I,pe.setState),nt("onEdgesDelete",E,pe.setState),nt("onNodeDrag",D,pe.setState),nt("onNodeDragStart",B,pe.setState),nt("onNodeDragStop",H,pe.setState),nt("onSelectionDrag",G,pe.setState),nt("onSelectionDragStart",z,pe.setState),nt("onSelectionDragStop",F,pe.setState),nt("noPanClassName",$,pe.setState),nt("nodeOrigin",W,pe.setState),nt("rfId",Z,pe.setState),nt("autoPanOnConnect",V,pe.setState),nt("autoPanOnNodeDrag",Y,pe.setState),nt("onError",X,pe.setState),nt("connectionRadius",J,pe.setState),nt("isValidConnection",Q,pe.setState),nt("nodeDragThreshold",te,pe.setState),qi(e,ce),qi(t,ue),qi(b,re),qi(k,fe),qi(P,ae),qi(N,je),null},zC={display:"none"},KH={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},k3="react-flow__node-desc",j3="react-flow__edge-desc",YH="react-flow__aria-live",XH=e=>e.ariaLiveMessage;function ZH({rfId:e}){const t=lt(XH);return he.createElement("div",{id:`${YH}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:KH},t)}function JH({rfId:e,disableKeyboardA11y:t}){return he.createElement(he.Fragment,null,he.createElement("div",{id:`${k3}-${e}`,style:zC},"Press enter or space to select a node.",!t&&"You can then use the arrow keys to move the node around."," Press delete to remove it and escape to cancel."," "),he.createElement("div",{id:`${j3}-${e}`,style:zC},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!t&&he.createElement(ZH,{rfId:e}))}var bu=(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)&&_0(w))return!1;const b=GC(w.code,c);o.current.add(w[b]),VC(i,o.current,!1)&&(w.preventDefault(),s(!0))},p=w=>{if((!a.current||a.current&&!t.actInsideInputWithModifier)&&_0(w))return!1;const b=GC(w.code,c);VC(i,o.current,!0)?(s(!1),o.current.clear()):o.current.delete(w[b]),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 VC(e,t,n){return e.filter(s=>n||s.length===t.size).some(s=>s.every(a=>t.has(a)))}function GC(e,t){return t.includes(e)?"code":"key"}function N3(e,t,n,s){var c,d;const a=e.parentNode||e.parentId;if(!a)return n;const o=t.get(a),i=Wo(o,s);return N3(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 S3(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}=N3(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 ly(e,t,n,s){const a=new Map,o={},i=s?1e3:0;return e.forEach(c=>{var w;const d=(vs(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)}),S3(a,n,o),a}function _3(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 v=n().filter(k=>{var j;const N=t.includeHiddenNodes?k.width&&k.height:!k.hidden;return(j=t.nodes)!=null&&j.length?N&&t.nodes.some(S=>S.id===k.id):N}),b=v.every(k=>k.width&&k.height);if(v.length>0&&b){const k=vp(v,p),{x:N,y:j,zoom:S}=d3(k,s,a,t.minZoom??o,t.maxZoom??i,t.padding??.1),_=ta.translate(N,j).scale(S);return typeof t.duration=="number"&&t.duration>0?c.transform($o(d,t.duration),_):c.transform(d,_),!0}}return!1}function QH(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 e7(e,t){return t.map(n=>{const s=e.find(a=>a.id===n.id);return s&&(n.selected=s.selected),n})}function Ah({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:QH(e,a)}),i==null||i(e)),t!=null&&t.length&&(h&&s({edges:e7(t,o)}),c==null||c(t))}const Ui=()=>{},t7={zoomIn:Ui,zoomOut:Ui,zoomTo:Ui,getZoom:()=>1,setViewport:Ui,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:Ui,fitBounds:Ui,project:e=>e,screenToFlowPosition:e=>e,flowToScreenPosition:e=>e,viewportInitialized:!1},n7=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection}),s7=()=>{const e=Pt(),{d3Zoom:t,d3Selection:n}=lt(n7,Xt);return y.useMemo(()=>n&&t?{zoomIn:a=>t.scaleBy($o(n,a==null?void 0:a.duration),1.2),zoomOut:a=>t.scaleBy($o(n,a==null?void 0:a.duration),1/1.2),zoomTo:(a,o)=>t.scaleTo($o(n,o==null?void 0:o.duration),a),getZoom:()=>e.getState().transform[2],setViewport:(a,o)=>{const[i,c,d]=e.getState().transform,h=ta.translate(a.x??i,a.y??c).scale(a.zoom??d);t.transform($o(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=>_3(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=ta.translate(p,m).scale(f);t.transform($o(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}=d3(a,i,c,d,h,(o==null?void 0:o.padding)??.1),w=ta.translate(f,p).scale(m);t.transform($o(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"),T0(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 T0(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=l3(a,o);return{x:h.x+c,y:h.y+d}},viewportInitialized:!0}:t7,[t,n])};function Ll(){const e=s7(),t=Pt(),n=y.useCallback(()=>t.getState().getNodes().map(b=>({...b})),[]),s=y.useCallback(b=>t.getState().nodeInternals.get(b),[]),a=y.useCallback(()=>{const{edges:b=[]}=t.getState();return b.map(k=>({...k}))},[]),o=y.useCallback(b=>{const{edges:k=[]}=t.getState();return k.find(N=>N.id===b)},[]),i=y.useCallback(b=>{const{getNodes:k,setNodes:N,hasDefaultNodes:j,onNodesChange:S}=t.getState(),_=k(),T=typeof b=="function"?b(_):b;if(j)N(T);else if(S){const L=T.length===0?_.map(A=>({type:"remove",id:A.id})):T.map(A=>({item:A,type:"reset"}));S(L)}},[]),c=y.useCallback(b=>{const{edges:k=[],setEdges:N,hasDefaultEdges:j,onEdgesChange:S}=t.getState(),_=typeof b=="function"?b(k):b;if(j)N(_);else if(S){const T=_.length===0?k.map(L=>({type:"remove",id:L.id})):_.map(L=>({item:L,type:"reset"}));S(T)}},[]),d=y.useCallback(b=>{const k=Array.isArray(b)?b:[b],{getNodes:N,setNodes:j,hasDefaultNodes:S,onNodesChange:_}=t.getState();if(S){const L=[...N(),...k];j(L)}else if(_){const T=k.map(L=>({item:L,type:"add"}));_(T)}},[]),h=y.useCallback(b=>{const k=Array.isArray(b)?b:[b],{edges:N=[],setEdges:j,hasDefaultEdges:S,onEdgesChange:_}=t.getState();if(S)j([...N,...k]);else if(_){const T=k.map(L=>({item:L,type:"add"}));_(T)}},[]),f=y.useCallback(()=>{const{getNodes:b,edges:k=[],transform:N}=t.getState(),[j,S,_]=N;return{nodes:b().map(T=>({...T})),edges:k.map(T=>({...T})),viewport:{x:j,y:S,zoom:_}}},[]),p=y.useCallback(({nodes:b,edges:k})=>{const{nodeInternals:N,getNodes:j,edges:S,hasDefaultNodes:_,hasDefaultEdges:T,onNodesDelete:L,onEdgesDelete:A,onNodesChange:P,onEdgesChange:O}=t.getState(),U=(b||[]).map(D=>D.id),q=(k||[]).map(D=>D.id),M=j().reduce((D,B)=>{const H=B.parentNode||B.parentId,G=!U.includes(B.id)&&H&&D.find(F=>F.id===H);return(typeof B.deletable=="boolean"?B.deletable:!0)&&(U.includes(B.id)||G)&&D.push(B),D},[]),I=S.filter(D=>typeof D.deletable=="boolean"?D.deletable:!0),E=I.filter(D=>q.includes(D.id));if(M||E){const D=u3(M,I),B=[...E,...D],H=B.reduce((G,z)=>(G.includes(z.id)||G.push(z.id),G),[]);if((T||_)&&(T&&t.setState({edges:S.filter(G=>!H.includes(G.id))}),_&&(M.forEach(G=>{N.delete(G.id)}),t.setState({nodeInternals:new Map(N)}))),H.length>0&&(A==null||A(B),O&&O(H.map(G=>({id:G,type:"remove"})))),M.length>0&&(L==null||L(M),P)){const G=M.map(z=>({id:z.id,type:"remove"}));P(G)}}},[]),m=y.useCallback(b=>{const k=jH(b),N=k?null:t.getState().nodeInternals.get(b.id);return!k&&!N?[null,null,k]:[k?b:DC(N),N,k]},[]),w=y.useCallback((b,k=!0,N)=>{const[j,S,_]=m(b);return j?(N||t.getState().getNodes()).filter(T=>{if(!_&&(T.id===S.id||!T.positionAbsolute))return!1;const L=DC(T),A=S0(L,j);return k&&A>0||A>=j.width*j.height}):[]},[]),v=y.useCallback((b,k,N=!0)=>{const[j]=m(b);if(!j)return!1;const S=S0(j,k);return N&&S>0||S>=j.width*j.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:v}),[e,n,s,a,o,i,c,d,h,f,p,w,v])}const r7={actInsideInputWithModifier:!1};var a7=({deleteKeyCode:e,multiSelectionKeyCode:t})=>{const n=Pt(),{deleteElements:s}=Ll(),a=bu(e,r7),o=bu(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 o7(e){const t=Pt();y.useEffect(()=>{let n;const s=()=>{var o,i;if(!e.current)return;const a=nj(e.current);(a.height===0||a.width===0)&&((i=(o=t.getState()).onError)==null||i.call(o,"004",aa.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 dj={position:"absolute",width:"100%",height:"100%",top:0,left:0},i7=(e,t)=>e.x!==t.x||e.y!==t.y||e.zoom!==t.k,Rh=e=>({x:e.x,y:e.y,zoom:e.k}),Wi=(e,t)=>e.target.closest(`.${t}`),KC=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),YC=e=>{const t=e.ctrlKey&&_f()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t},l7=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),c7=({onMove:e,onMoveStart:t,onMoveEnd:n,onPaneContextMenu:s,zoomOnScroll:a=!0,zoomOnPinch:o=!0,panOnScroll:i=!1,panOnScrollSpeed:c=.5,panOnScrollMode:d=Fo.Free,zoomOnDoubleClick:h=!0,elementsSelectable:f,panOnDrag:p=!0,defaultViewport:m,translateExtent:w,minZoom:v,maxZoom:b,zoomActivationKeyCode:k,preventScrolling:N=!0,children:j,noWheelClassName:S,noPanClassName:_})=>{const T=y.useRef(),L=Pt(),A=y.useRef(!1),P=y.useRef(!1),O=y.useRef(null),U=y.useRef({x:0,y:0,zoom:0}),{d3Zoom:q,d3Selection:M,d3ZoomHandler:I,userSelectionActive:E}=lt(l7,Xt),D=bu(k),B=y.useRef(0),H=y.useRef(!1),G=y.useRef();return o7(O),y.useEffect(()=>{if(O.current){const z=O.current.getBoundingClientRect(),F=ZO().scaleExtent([v,b]).translateExtent(w),$=xs(O.current).call(F),W=ta.translate(m.x,m.y).scale(Sl(m.zoom,v,b)),Z=[[0,0],[z.width,z.height]],V=F.constrain()(W,Z,w);F.transform($,V),F.wheelDelta(YC),L.setState({d3Zoom:F,d3Selection:$,d3ZoomHandler:$.on("wheel.zoom"),transform:[V.x,V.y,V.k],domNode:O.current.closest(".react-flow")})}},[]),y.useEffect(()=>{M&&q&&(i&&!D&&!E?M.on("wheel.zoom",z=>{if(Wi(z,S))return!1;z.preventDefault(),z.stopImmediatePropagation();const F=M.property("__zoom").k||1;if(z.ctrlKey&&o){const Q=zs(z),te=YC(z),ce=F*Math.pow(2,te);q.scaleTo(M,ce,Q,z);return}const $=z.deltaMode===1?20:1;let W=d===Fo.Vertical?0:z.deltaX*$,Z=d===Fo.Horizontal?0:z.deltaY*$;!_f()&&z.shiftKey&&d!==Fo.Vertical&&(W=z.deltaY*$,Z=0),q.translateBy(M,-(W/F)*c,-(Z/F)*c,{internal:!0});const V=Rh(M.property("__zoom")),{onViewportChangeStart:Y,onViewportChange:X,onViewportChangeEnd:J}=L.getState();clearTimeout(G.current),H.current||(H.current=!0,t==null||t(z,V),Y==null||Y(V)),H.current&&(e==null||e(z,V),X==null||X(V),G.current=setTimeout(()=>{n==null||n(z,V),J==null||J(V),H.current=!1},150))},{passive:!1}):typeof I<"u"&&M.on("wheel.zoom",function(z,F){if(!N&&z.type==="wheel"&&!z.ctrlKey||Wi(z,S))return null;z.preventDefault(),I.call(this,z,F)},{passive:!1}))},[E,i,d,M,q,I,D,o,N,S,t,e,n]),y.useEffect(()=>{q&&q.on("start",z=>{var W,Z;if(!z.sourceEvent||z.sourceEvent.internal)return null;B.current=(W=z.sourceEvent)==null?void 0:W.button;const{onViewportChangeStart:F}=L.getState(),$=Rh(z.transform);A.current=!0,U.current=$,((Z=z.sourceEvent)==null?void 0:Z.type)==="mousedown"&&L.setState({paneDragging:!0}),F==null||F($),t==null||t(z.sourceEvent,$)})},[q,t]),y.useEffect(()=>{q&&(E&&!A.current?q.on("zoom",null):E||q.on("zoom",z=>{var $;const{onViewportChange:F}=L.getState();if(L.setState({transform:[z.transform.x,z.transform.y,z.transform.k]}),P.current=!!(s&&KC(p,B.current??0)),(e||F)&&!(($=z.sourceEvent)!=null&&$.internal)){const W=Rh(z.transform);F==null||F(W),e==null||e(z.sourceEvent,W)}}))},[E,q,e,p,s]),y.useEffect(()=>{q&&q.on("end",z=>{if(!z.sourceEvent||z.sourceEvent.internal)return null;const{onViewportChangeEnd:F}=L.getState();if(A.current=!1,L.setState({paneDragging:!1}),s&&KC(p,B.current??0)&&!P.current&&s(z.sourceEvent),P.current=!1,(n||F)&&i7(U.current,z.transform)){const $=Rh(z.transform);U.current=$,clearTimeout(T.current),T.current=setTimeout(()=>{F==null||F($),n==null||n(z.sourceEvent,$)},i?150:0)}})},[q,i,p,n,s]),y.useEffect(()=>{q&&q.filter(z=>{const F=D||a,$=o&&z.ctrlKey;if((p===!0||Array.isArray(p)&&p.includes(1))&&z.button===1&&z.type==="mousedown"&&(Wi(z,"react-flow__node")||Wi(z,"react-flow__edge")))return!0;if(!p&&!F&&!i&&!h&&!o||E||!h&&z.type==="dblclick"||Wi(z,S)&&z.type==="wheel"||Wi(z,_)&&(z.type!=="wheel"||i&&z.type==="wheel"&&!D)||!o&&z.ctrlKey&&z.type==="wheel"||!F&&!i&&!$&&z.type==="wheel"||!p&&(z.type==="mousedown"||z.type==="touchstart")||Array.isArray(p)&&!p.includes(z.button)&&z.type==="mousedown")return!1;const W=Array.isArray(p)&&p.includes(z.button)||!z.button||z.button<=1;return(!z.ctrlKey||z.type==="wheel")&&W})},[E,q,a,o,i,h,p,f,D]),he.createElement("div",{className:"react-flow__renderer",ref:O,style:dj},j)},u7=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function d7(){const{userSelectionActive:e,userSelectionRect:t}=lt(u7,Xt);return e&&t?he.createElement("div",{className:"react-flow__selection react-flow__container",style:{width:t.width,height:t.height,transform:`translate(${t.x}px, ${t.y}px)`}}):null}function XC(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 h7(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&&XC(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&&XC(s,i);break}case"remove":return s}return s.push(i),s},n)}function f7(e,t){return h7(e,t)}const za=(e,t)=>({id:e,type:"select",selected:t});function rl(e,t){return e.reduce((n,s)=>{const a=t.includes(s.id);return!s.selected&&a?(s.selected=!0,n.push(za(s.id,!0))):s.selected&&!a&&(s.selected=!1,n.push(za(s.id,!1))),n},[])}const cy=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},p7=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),C3=y.memo(({isSelecting:e,selectionMode:t=vu.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=Pt(),v=y.useRef(0),b=y.useRef(0),k=y.useRef(),{userSelectionActive:N,elementsSelectable:j,dragging:S}=lt(p7,Xt),_=()=>{w.setState({userSelectionActive:!1,userSelectionRect:null}),v.current=0,b.current=0},T=I=>{o==null||o(I),w.getState().resetSelectedElements(),w.setState({nodesSelectionActive:!1})},L=I=>{if(Array.isArray(n)&&(n!=null&&n.includes(2))){I.preventDefault();return}i==null||i(I)},A=c?I=>c(I):void 0,P=I=>{const{resetSelectedElements:E,domNode:D}=w.getState();if(k.current=D==null?void 0:D.getBoundingClientRect(),!j||!e||I.button!==0||I.target!==m.current||!k.current)return;const{x:B,y:H}=Qa(I,k.current);E(),w.setState({userSelectionRect:{width:0,height:0,startX:B,startY:H,x:B,y:H}}),s==null||s(I)},O=I=>{const{userSelectionRect:E,nodeInternals:D,edges:B,transform:H,onNodesChange:G,onEdgesChange:z,nodeOrigin:F,getNodes:$}=w.getState();if(!e||!k.current||!E)return;w.setState({userSelectionActive:!0,nodesSelectionActive:!1});const W=Qa(I,k.current),Z=E.startX??0,V=E.startY??0,Y={...E,x:W.x<Z?W.x:Z,y:W.y<V?W.y:V,width:Math.abs(W.x-Z),height:Math.abs(W.y-V)},X=$(),J=c3(D,Y,H,t===vu.Partial,!0,F),Q=u3(J,B).map(ce=>ce.id),te=J.map(ce=>ce.id);if(v.current!==te.length){v.current=te.length;const ce=rl(X,te);ce.length&&(G==null||G(ce))}if(b.current!==Q.length){b.current=Q.length;const ce=rl(B,Q);ce.length&&(z==null||z(ce))}w.setState({userSelectionRect:Y})},U=I=>{if(I.button!==0)return;const{userSelectionRect:E}=w.getState();!N&&E&&I.target===m.current&&(T==null||T(I)),w.setState({nodesSelectionActive:v.current>0}),_(),a==null||a(I)},q=I=>{N&&(w.setState({nodesSelectionActive:v.current>0}),a==null||a(I)),_()},M=j&&(e||N);return he.createElement("div",{className:an(["react-flow__pane",{dragging:S,selection:e}]),onClick:M?void 0:cy(T,m),onContextMenu:cy(L,m),onWheel:cy(A,m),onMouseEnter:M?void 0:d,onMouseDown:M?P:void 0,onMouseMove:M?O:h,onMouseUp:M?U:void 0,onMouseLeave:M?q:f,ref:m,style:dj},p,he.createElement(d7,null))});C3.displayName="Pane";function E3(e,t){const n=e.parentNode||e.parentId;if(!n)return!1;const s=t.get(n);return s?s.selected?!0:E3(s,t):!1}function ZC(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 m7(e,t,n,s){return Array.from(e.values()).filter(a=>(a.selected||a.id===s)&&(!a.parentNode||a.parentId||!E3(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 g7(e,t){return!t||t==="parent"?t:[t[0],[t[1][0]-(e.width||0),t[1][1]-(e.height||0)]]}function T3(e,t,n,s,a=[0,0],o){const i=g7(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}=Wo(p,a).positionAbsolute;c=p&&vs(m)&&vs(w)&&vs(p.width)&&vs(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",aa.error005()),c=i;else if(e.extent&&d&&e.extent!=="parent"){const p=n.get(d),{x:m,y:w}=Wo(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=Wo(p,a).positionAbsolute}const f=c&&c!=="parent"?sj(t,c):t;return{position:{x:f.x-h.x,y:f.y-h.y},positionAbsolute:f}}function uy({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 JC=(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,...nj(d)}})};function Pc(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",aa.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 y7(){const e=Pt();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 dy(e){return(t,n,s)=>e==null?void 0:e(t,s)}function A3({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:s,nodeId:a,isSelectable:o,selectNodesOnDrag:i}){const c=Pt(),[d,h]=y.useState(!1),f=y.useRef([]),p=y.useRef({x:null,y:null}),m=y.useRef(0),w=y.useRef(null),v=y.useRef({x:0,y:0}),b=y.useRef(null),k=y.useRef(!1),N=y.useRef(!1),j=y.useRef(!1),S=y7();return y.useEffect(()=>{if(e!=null&&e.current){const _=xs(e.current),T=({x:P,y:O})=>{const{nodeInternals:U,onNodeDrag:q,onSelectionDrag:M,updateNodePositions:I,nodeExtent:E,snapGrid:D,snapToGrid:B,nodeOrigin:H,onError:G}=c.getState();p.current={x:P,y:O};let z=!1,F={x:0,y:0,x2:0,y2:0};if(f.current.length>1&&E){const W=vp(f.current,H);F=xu(W)}if(f.current=f.current.map(W=>{const Z={x:P-W.distance.x,y:O-W.distance.y};B&&(Z.x=D[0]*Math.round(Z.x/D[0]),Z.y=D[1]*Math.round(Z.y/D[1]));const V=[[E[0][0],E[0][1]],[E[1][0],E[1][1]]];f.current.length>1&&E&&!W.extent&&(V[0][0]=W.positionAbsolute.x-F.x+E[0][0],V[1][0]=W.positionAbsolute.x+(W.width??0)-F.x2+E[1][0],V[0][1]=W.positionAbsolute.y-F.y+E[0][1],V[1][1]=W.positionAbsolute.y+(W.height??0)-F.y2+E[1][1]);const Y=T3(W,Z,U,V,H,G);return z=z||W.position.x!==Y.position.x||W.position.y!==Y.position.y,W.position=Y.position,W.positionAbsolute=Y.positionAbsolute,W}),!z)return;I(f.current,!0,!0),h(!0);const $=a?q:dy(M);if($&&b.current){const[W,Z]=uy({nodeId:a,dragItems:f.current,nodeInternals:U});$(b.current,W,Z)}},L=()=>{if(!w.current)return;const[P,O]=QO(v.current,w.current);if(P!==0||O!==0){const{transform:U,panBy:q}=c.getState();p.current.x=(p.current.x??0)-P/U[2],p.current.y=(p.current.y??0)-O/U[2],q({x:P,y:O})&&T(p.current)}m.current=requestAnimationFrame(L)},A=P=>{var H;const{nodeInternals:O,multiSelectionActive:U,nodesDraggable:q,unselectNodesAndEdges:M,onNodeDragStart:I,onSelectionDragStart:E}=c.getState();N.current=!0;const D=a?I:dy(E);(!i||!o)&&!U&&a&&((H=O.get(a))!=null&&H.selected||M()),a&&o&&i&&R0({id:a,store:c,nodeRef:e});const B=S(P);if(p.current=B,f.current=m7(O,q,B,a),D&&f.current){const[G,z]=uy({nodeId:a,dragItems:f.current,nodeInternals:O});D(P.sourceEvent,G,z)}};if(t)_.on(".drag",null);else{const P=CU().on("start",O=>{const{domNode:U,nodeDragThreshold:q}=c.getState();q===0&&A(O),j.current=!1;const M=S(O);p.current=M,w.current=(U==null?void 0:U.getBoundingClientRect())||null,v.current=Qa(O.sourceEvent,w.current)}).on("drag",O=>{var I,E;const U=S(O),{autoPanOnNodeDrag:q,nodeDragThreshold:M}=c.getState();if(O.sourceEvent.type==="touchmove"&&O.sourceEvent.touches.length>1&&(j.current=!0),!j.current){if(!k.current&&N.current&&q&&(k.current=!0,L()),!N.current){const D=U.xSnapped-(((I=p==null?void 0:p.current)==null?void 0:I.x)??0),B=U.ySnapped-(((E=p==null?void 0:p.current)==null?void 0:E.y)??0);Math.sqrt(D*D+B*B)>M&&A(O)}(p.current.x!==U.xSnapped||p.current.y!==U.ySnapped)&&f.current&&N.current&&(b.current=O.sourceEvent,v.current=Qa(O.sourceEvent,w.current),T(U))}}).on("end",O=>{if(!(!N.current||j.current)&&(h(!1),k.current=!1,N.current=!1,cancelAnimationFrame(m.current),f.current)){const{updateNodePositions:U,nodeInternals:q,onNodeDragStop:M,onSelectionDragStop:I}=c.getState(),E=a?M:dy(I);if(U(f.current,!1,!1),E){const[D,B]=uy({nodeId:a,dragItems:f.current,nodeInternals:q});E(O.sourceEvent,D,B)}}}).filter(O=>{const U=O.target;return!O.button&&(!n||!ZC(U,`.${n}`,e))&&(!s||ZC(U,s,e))});return _.call(P),()=>{_.on(".drag",null)}}}},[e,t,n,s,o,c,a,i,S]),d}function R3(){const e=Pt();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(j=>j.selected&&(j.draggable||f&&typeof j.draggable>"u")),m=c?d[0]:5,w=c?d[1]:5,v=n.isShiftPressed?4:1,b=n.x*m*v,k=n.y*w*v,N=p.map(j=>{if(j.positionAbsolute){const S={x:j.positionAbsolute.x+b,y:j.positionAbsolute.y+k};c&&(S.x=d[0]*Math.round(S.x/d[0]),S.y=d[1]*Math.round(S.y/d[1]));const{positionAbsolute:_,position:T}=T3(j,S,s,a,void 0,h);j.position=T,j.positionAbsolute=_}return j});o(N,!0,!1)},[])}const pl={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var Dc=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:v,onDoubleClick:b,style:k,className:N,isDraggable:j,isSelectable:S,isConnectable:_,isFocusable:T,selectNodesOnDrag:L,sourcePosition:A,targetPosition:P,hidden:O,resizeObserver:U,dragHandle:q,zIndex:M,isParent:I,noDragClassName:E,noPanClassName:D,initialized:B,disableKeyboardA11y:H,ariaLabel:G,rfId:z,hasHandleBounds:F})=>{const $=Pt(),W=y.useRef(null),Z=y.useRef(null),V=y.useRef(A),Y=y.useRef(P),X=y.useRef(s),J=S||j||f||p||m||w,Q=R3(),te=Pc(n,$.getState,p),ce=Pc(n,$.getState,m),ue=Pc(n,$.getState,w),ie=Pc(n,$.getState,v),re=Pc(n,$.getState,b),fe=me=>{const{nodeDragThreshold:pe}=$.getState();if(S&&(!L||!j||pe>0)&&R0({id:n,store:$,nodeRef:W}),f){const xe=$.getState().nodeInternals.get(n);xe&&f(me,{...xe})}},ae=me=>{if(!_0(me)&&!H)if(s3.includes(me.key)&&S){const pe=me.key==="Escape";R0({id:n,store:$,unselect:pe,nodeRef:W})}else j&&h&&Object.prototype.hasOwnProperty.call(pl,me.key)&&($.setState({ariaLiveMessage:`Moved selected node ${me.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~o}, y: ${~~i}`}),Q({x:pl[me.key].x,y:pl[me.key].y,isShiftPressed:me.shiftKey}))};y.useEffect(()=>()=>{Z.current&&(U==null||U.unobserve(Z.current),Z.current=null)},[]),y.useEffect(()=>{if(W.current&&!O){const me=W.current;(!B||!F||Z.current!==me)&&(Z.current&&(U==null||U.unobserve(Z.current)),U==null||U.observe(me),Z.current=me)}},[O,B,F]),y.useEffect(()=>{const me=X.current!==s,pe=V.current!==A,xe=Y.current!==P;W.current&&(me||pe||xe)&&(me&&(X.current=s),pe&&(V.current=A),xe&&(Y.current=P),$.getState().updateNodeDimensions([{id:n,nodeElement:W.current,forceUpdate:!0}]))},[n,s,A,P]);const je=A3({nodeRef:W,disabled:O||!j,noDragClassName:E,handleSelector:q,nodeId:n,isSelectable:S,selectNodesOnDrag:L});return O?null:he.createElement("div",{className:an(["react-flow__node",`react-flow__node-${s}`,{[D]:j},N,{selected:h,selectable:S,parent:I,dragging:je}]),ref:W,style:{zIndex:M,transform:`translate(${c}px,${d}px)`,pointerEvents:J?"all":"none",visibility:B?"visible":"hidden",...k},"data-id":n,"data-testid":`rf__node-${n}`,onMouseEnter:te,onMouseMove:ce,onMouseLeave:ue,onContextMenu:ie,onClick:fe,onDoubleClick:re,onKeyDown:T?ae:void 0,tabIndex:T?0:void 0,role:T?"button":void 0,"aria-describedby":H?void 0:`${k3}-${z}`,"aria-label":G},he.createElement(AH,{value:n},he.createElement(e,{id:n,data:a,type:s,xPos:o,yPos:i,selected:h,isConnectable:_,sourcePosition:A,targetPosition:P,dragging:je,dragHandle:q,zIndex:M})))};return t.displayName="NodeWrapper",y.memo(t)};const w7=e=>{const t=e.getNodes().filter(n=>n.selected);return{...vp(t,e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive}};function x7({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const s=Pt(),{width:a,height:o,x:i,y:c,transformString:d,userSelectionActive:h}=lt(w7,Xt),f=R3(),p=y.useRef(null);if(y.useEffect(()=>{var v;n||(v=p.current)==null||v.focus({preventScroll:!0})},[n]),A3({nodeRef:p}),h||!a||!o)return null;const m=e?v=>{const b=s.getState().getNodes().filter(k=>k.selected);e(v,b)}:void 0,w=v=>{Object.prototype.hasOwnProperty.call(pl,v.key)&&f({x:pl[v.key].x,y:pl[v.key].y,isShiftPressed:v.shiftKey})};return he.createElement("div",{className:an(["react-flow__nodesselection","react-flow__container",t]),style:{transform:d}},he.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 v7=y.memo(x7);const b7=e=>e.nodesSelectionActive,M3=({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:v,onSelectionEnd:b,multiSelectionKeyCode:k,panActivationKeyCode:N,zoomActivationKeyCode:j,elementsSelectable:S,zoomOnScroll:_,zoomOnPinch:T,panOnScroll:L,panOnScrollSpeed:A,panOnScrollMode:P,zoomOnDoubleClick:O,panOnDrag:U,defaultViewport:q,translateExtent:M,minZoom:I,maxZoom:E,preventScrolling:D,onSelectionContextMenu:B,noWheelClassName:H,noPanClassName:G,disableKeyboardA11y:z})=>{const F=lt(b7),$=bu(p),W=bu(N),Z=W||U,V=W||L,Y=$||m&&Z!==!0;return a7({deleteKeyCode:c,multiSelectionKeyCode:k}),he.createElement(c7,{onMove:d,onMoveStart:h,onMoveEnd:f,onPaneContextMenu:o,elementsSelectable:S,zoomOnScroll:_,zoomOnPinch:T,panOnScroll:V,panOnScrollSpeed:A,panOnScrollMode:P,zoomOnDoubleClick:O,panOnDrag:!$&&Z,defaultViewport:q,translateExtent:M,minZoom:I,maxZoom:E,zoomActivationKeyCode:j,preventScrolling:D,noWheelClassName:H,noPanClassName:G},he.createElement(C3,{onSelectionStart:v,onSelectionEnd:b,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:o,onPaneScroll:i,panOnDrag:Z,isSelecting:!!Y,selectionMode:w},e,F&&he.createElement(v7,{onSelectionContextMenu:B,noPanClassName:G,disableKeyboardA11y:z})))};M3.displayName="FlowRenderer";var k7=y.memo(M3);function j7(e){return lt(y.useCallback(n=>e?c3(n.nodeInternals,{x:0,y:0,width:n.width,height:n.height},n.transform,!0):n.getNodes(),[e]))}function N7(e){const t={input:Dc(e.input||w3),default:Dc(e.default||A0),output:Dc(e.output||v3),group:Dc(e.group||uj)},n={},s=Object.keys(e).filter(a=>!["input","default","output","group"].includes(a)).reduce((a,o)=>(a[o]=Dc(e[o]||A0),a),n);return{...t,...s}}const S7=({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]},_7=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),$3=e=>{const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:s,elementsSelectable:a,updateNodeDimensions:o,onError:i}=lt(_7,Xt),c=j7(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()},[]),he.createElement("div",{className:"react-flow__nodes",style:dj},c.map(f=>{var T,L,A;let p=f.type||"default";e.nodeTypes[p]||(i==null||i("003",aa.error003(p)),p="default");const m=e.nodeTypes[p]||e.nodeTypes.default,w=!!(f.draggable||t&&typeof f.draggable>"u"),v=!!(f.selectable||a&&typeof f.selectable>"u"),b=!!(f.connectable||n&&typeof f.connectable>"u"),k=!!(f.focusable||s&&typeof f.focusable>"u"),N=e.nodeExtent?sj(f.positionAbsolute,e.nodeExtent):f.positionAbsolute,j=(N==null?void 0:N.x)??0,S=(N==null?void 0:N.y)??0,_=S7({x:j,y:S,width:f.width??0,height:f.height??0,origin:e.nodeOrigin});return he.createElement(m,{key:f.id,id:f.id,className:f.className,style:f.style,type:p,data:f.data,sourcePosition:f.sourcePosition||De.Bottom,targetPosition:f.targetPosition||De.Top,hidden:f.hidden,xPos:j,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:v,isConnectable:b,isFocusable:k,resizeObserver:h,dragHandle:f.dragHandle,zIndex:((T=f[Lt])==null?void 0:T.z)??0,isParent:!!((L=f[Lt])!=null&&L.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)})}))};$3.displayName="NodeRenderer";var C7=y.memo($3);const E7=(e,t,n)=>n===De.Left?e-t:n===De.Right?e+t:e,T7=(e,t,n)=>n===De.Top?e-t:n===De.Bottom?e+t:e,QC="react-flow__edgeupdater",eE=({position:e,centerX:t,centerY:n,radius:s=10,onMouseDown:a,onMouseEnter:o,onMouseOut:i,type:c})=>he.createElement("circle",{onMouseDown:a,onMouseEnter:o,onMouseOut:i,className:an([QC,`${QC}-${c}`]),cx:E7(t,s,e),cy:T7(n,s,e),r:s,stroke:"transparent",fill:"transparent"}),A7=()=>!0;var Hi=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:v,labelBgBorderRadius:b,style:k,source:N,target:j,sourceX:S,sourceY:_,targetX:T,targetY:L,sourcePosition:A,targetPosition:P,elementsSelectable:O,hidden:U,sourceHandleId:q,targetHandleId:M,onContextMenu:I,onMouseEnter:E,onMouseMove:D,onMouseLeave:B,reconnectRadius:H,onReconnect:G,onReconnectStart:z,onReconnectEnd:F,markerEnd:$,markerStart:W,rfId:Z,ariaLabel:V,isFocusable:Y,isReconnectable:X,pathOptions:J,interactionWidth:Q,disableKeyboardA11y:te})=>{const ce=y.useRef(null),[ue,ie]=y.useState(!1),[re,fe]=y.useState(!1),ae=Pt(),je=y.useMemo(()=>`url('#${E0(W,Z)}')`,[W,Z]),me=y.useMemo(()=>`url('#${E0($,Z)}')`,[$,Z]);if(U)return null;const pe=qe=>{var Xe;const{edges:et,addSelectedEdges:ot,unselectNodesAndEdges:we,multiSelectionActive:Ge}=ae.getState(),Ye=et.find(rt=>rt.id===n);Ye&&(O&&(ae.setState({nodesSelectionActive:!1}),Ye.selected&&Ge?(we({nodes:[],edges:[Ye]}),(Xe=ce.current)==null||Xe.blur()):ot([n])),i&&i(qe,Ye))},xe=Oc(n,ae.getState,c),_e=Oc(n,ae.getState,I),ye=Oc(n,ae.getState,E),Ie=Oc(n,ae.getState,D),Pe=Oc(n,ae.getState,B),Ue=(qe,et)=>{if(qe.button!==0)return;const{edges:ot,isValidConnection:we}=ae.getState(),Ge=et?j:N,Ye=(et?M:q)||null,Xe=et?"target":"source",rt=we||A7,jt=et,Ut=ot.find(It=>It.id===n);fe(!0),z==null||z(qe,Ut,Xe);const pt=It=>{fe(!1),F==null||F(It,Ut,Xe)};p3({event:qe,handleId:Ye,nodeId:Ge,onConnect:It=>G==null?void 0:G(Ut,It),isTarget:jt,getState:ae.getState,setState:ae.setState,isValidConnection:rt,edgeUpdaterType:Xe,onReconnectEnd:pt})},$e=qe=>Ue(qe,!0),Je=qe=>Ue(qe,!1),Qe=()=>ie(!0),ze=()=>ie(!1),Ne=!O&&!i,Ae=qe=>{var et;if(!te&&s3.includes(qe.key)&&O){const{unselectNodesAndEdges:ot,addSelectedEdges:we,edges:Ge}=ae.getState();qe.key==="Escape"?((et=ce.current)==null||et.blur(),ot({edges:[Ge.find(Xe=>Xe.id===n)]})):we([n])}};return he.createElement("g",{className:an(["react-flow__edge",`react-flow__edge-${a}`,s,{selected:d,animated:h,inactive:Ne,updating:ue}]),onClick:pe,onDoubleClick:xe,onContextMenu:_e,onMouseEnter:ye,onMouseMove:Ie,onMouseLeave:Pe,onKeyDown:Y?Ae:void 0,tabIndex:Y?0:void 0,role:Y?"button":"img","data-testid":`rf__edge-${n}`,"aria-label":V===null?void 0:V||`Edge from ${N} to ${j}`,"aria-describedby":Y?`${j3}-${Z}`:void 0,ref:ce},!re&&he.createElement(e,{id:n,source:N,target:j,selected:d,animated:h,label:f,labelStyle:p,labelShowBg:m,labelBgStyle:w,labelBgPadding:v,labelBgBorderRadius:b,data:o,style:k,sourceX:S,sourceY:_,targetX:T,targetY:L,sourcePosition:A,targetPosition:P,sourceHandleId:q,targetHandleId:M,markerStart:je,markerEnd:me,pathOptions:J,interactionWidth:Q}),X&&he.createElement(he.Fragment,null,(X==="source"||X===!0)&&he.createElement(eE,{position:A,centerX:S,centerY:_,radius:H,onMouseDown:$e,onMouseEnter:Qe,onMouseOut:ze,type:"source"}),(X==="target"||X===!0)&&he.createElement(eE,{position:P,centerX:T,centerY:L,radius:H,onMouseDown:Je,onMouseEnter:Qe,onMouseOut:ze,type:"target"})))};return t.displayName="EdgeWrapper",y.memo(t)};function R7(e){const t={default:Hi(e.default||Ef),straight:Hi(e.bezier||oj),step:Hi(e.step||aj),smoothstep:Hi(e.step||xp),simplebezier:Hi(e.simplebezier||rj)},n={},s=Object.keys(e).filter(a=>!["default","bezier"].includes(a)).reduce((a,o)=>(a[o]=Hi(e[o]||Ef),a),n);return{...t,...s}}function tE(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 De.Top:return{x:s+o/2,y:a};case De.Right:return{x:s+o,y:a+i/2};case De.Bottom:return{x:s+o/2,y:a+i};case De.Left:return{x:s,y:a+i/2}}}function nE(e,t){return e?e.length===1||!t?e[0]:t&&e.find(n=>n.id===t)||null:null}const M7=(e,t,n,s,a,o)=>{const i=tE(n,e,t),c=tE(o,s,a);return{sourceX:i.x,sourceY:i.y,targetX:c.x,targetY:c.y}};function $7({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=xu({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 sE(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 L7=[{level:0,isMaxLevel:!0,edges:[]}];function I7(e,t,n=!1){let s=-1;const a=e.reduce((i,c)=>{var f,p;const d=vs(c.zIndex);let h=d?c.zIndex:0;if(n){const m=t.get(c.target),w=t.get(c.source),v=c.selected||(m==null?void 0:m.selected)||(w==null?void 0:w.selected),b=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)+(v?b: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?L7:o}function O7(e,t,n){const s=lt(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)&&$7({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 I7(s,t,n)}const P7=({color:e="none",strokeWidth:t=1})=>he.createElement("polyline",{style:{stroke:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),D7=({color:e="none",strokeWidth:t=1})=>he.createElement("polyline",{style:{stroke:e,fill:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"}),rE={[Cf.Arrow]:P7,[Cf.ArrowClosed]:D7};function F7(e){const t=Pt();return y.useMemo(()=>{var a,o;return Object.prototype.hasOwnProperty.call(rE,e)?rE[e]:((o=(a=t.getState()).onError)==null||o.call(a,"009",aa.error009(e)),null)},[e])}const B7=({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=F7(t);return d?he.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"},he.createElement(d,{color:n,strokeWidth:i})):null},q7=({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=E0(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))},L3=({defaultColor:e,rfId:t})=>{const n=lt(y.useCallback(q7({defaultColor:e,rfId:t}),[e,t]),(s,a)=>!(s.length!==a.length||s.some((o,i)=>o.id!==a[i].id)));return he.createElement("defs",null,n.map(s=>he.createElement(B7,{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})))};L3.displayName="MarkerDefinitions";var U7=y.memo(L3);const W7=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}),I3=({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:v,reconnectRadius:b,children:k,disableKeyboardA11y:N})=>{const{edgesFocusable:j,edgesUpdatable:S,elementsSelectable:_,width:T,height:L,connectionMode:A,nodeInternals:P,onError:O}=lt(W7,Xt),U=O7(t,P,n);return T?he.createElement(he.Fragment,null,U.map(({level:q,edges:M,isMaxLevel:I})=>he.createElement("svg",{key:q,style:{zIndex:q},width:T,height:L,className:"react-flow__edges react-flow__container"},I&&he.createElement(U7,{defaultColor:e,rfId:s}),he.createElement("g",null,M.map(E=>{const[D,B,H]=sE(P.get(E.source)),[G,z,F]=sE(P.get(E.target));if(!H||!F)return null;let $=E.type||"default";a[$]||(O==null||O("011",aa.error011($)),$="default");const W=a[$]||a.default,Z=A===Zo.Strict?z.target:(z.target??[]).concat(z.source??[]),V=nE(B.source,E.sourceHandle),Y=nE(Z,E.targetHandle),X=(V==null?void 0:V.position)||De.Bottom,J=(Y==null?void 0:Y.position)||De.Top,Q=!!(E.focusable||j&&typeof E.focusable>"u"),te=E.reconnectable||E.updatable,ce=typeof m<"u"&&(te||S&&typeof te>"u");if(!V||!Y)return O==null||O("008",aa.error008(V,E)),null;const{sourceX:ue,sourceY:ie,targetX:re,targetY:fe}=M7(D,V,X,G,Y,J);return he.createElement(W,{key:E.id,id:E.id,className:an([E.className,o]),type:$,data:E.data,selected:!!E.selected,animated:!!E.animated,hidden:!!E.hidden,label:E.label,labelStyle:E.labelStyle,labelShowBg:E.labelShowBg,labelBgStyle:E.labelBgStyle,labelBgPadding:E.labelBgPadding,labelBgBorderRadius:E.labelBgBorderRadius,style:E.style,source:E.source,target:E.target,sourceHandleId:E.sourceHandle,targetHandleId:E.targetHandle,markerEnd:E.markerEnd,markerStart:E.markerStart,sourceX:ue,sourceY:ie,targetX:re,targetY:fe,sourcePosition:X,targetPosition:J,elementsSelectable:_,onContextMenu:i,onMouseEnter:c,onMouseMove:d,onMouseLeave:h,onClick:f,onEdgeDoubleClick:p,onReconnect:m,onReconnectStart:w,onReconnectEnd:v,reconnectRadius:b,rfId:s,ariaLabel:E.ariaLabel,isFocusable:Q,isReconnectable:ce,pathOptions:"pathOptions"in E?E.pathOptions:void 0,interactionWidth:E.interactionWidth,disableKeyboardA11y:N})})))),k):null};I3.displayName="EdgeRenderer";var H7=y.memo(I3);const z7=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function V7({children:e}){const t=lt(z7);return he.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:t}},e)}function G7(e){const t=Ll(),n=y.useRef(!1);y.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const K7={[De.Left]:De.Right,[De.Right]:De.Left,[De.Top]:De.Bottom,[De.Bottom]:De.Top},O3=({nodeId:e,handleType:t,style:n,type:s=Ga.Bezier,CustomComponent:a,connectionStatus:o})=>{var L,A,P;const{fromNode:i,handleId:c,toX:d,toY:h,connectionMode:f}=lt(y.useCallback(O=>({fromNode:O.nodeInternals.get(e),handleId:O.connectionHandleId,toX:(O.connectionPosition.x-O.transform[0])/O.transform[2],toY:(O.connectionPosition.y-O.transform[1])/O.transform[2],connectionMode:O.connectionMode}),[e]),Xt),p=(L=i==null?void 0:i[Lt])==null?void 0:L.handleBounds;let m=p==null?void 0:p[t];if(f===Zo.Loose&&(m=m||(p==null?void 0:p[t==="source"?"target":"source"])),!i||!m)return null;const w=c?m.find(O=>O.id===c):m[0],v=w?w.x+w.width/2:(i.width??0)/2,b=w?w.y+w.height/2:i.height??0,k=(((A=i.positionAbsolute)==null?void 0:A.x)??0)+v,N=(((P=i.positionAbsolute)==null?void 0:P.y)??0)+b,j=w==null?void 0:w.position,S=j?K7[j]:null;if(!j||!S)return null;if(a)return he.createElement(a,{connectionLineType:s,connectionLineStyle:n,fromNode:i,fromHandle:w,fromX:k,fromY:N,toX:d,toY:h,fromPosition:j,toPosition:S,connectionStatus:o});let _="";const T={sourceX:k,sourceY:N,sourcePosition:j,targetX:d,targetY:h,targetPosition:S};return s===Ga.Bezier?[_]=ij(T):s===Ga.Step?[_]=C0({...T,borderRadius:0}):s===Ga.SmoothStep?[_]=C0(T):s===Ga.SimpleBezier?[_]=i3(T):_=`M${k},${N} ${d},${h}`,he.createElement("path",{d:_,fill:"none",className:"react-flow__connection-path",style:n})};O3.displayName="ConnectionLine";const Y7=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function X7({containerStyle:e,style:t,type:n,component:s}){const{nodeId:a,handleType:o,nodesConnectable:i,width:c,height:d,connectionStatus:h}=lt(Y7,Xt);return!(a&&o&&c&&i)?null:he.createElement("svg",{style:e,width:c,height:d,className:"react-flow__edges react-flow__connectionline react-flow__container"},he.createElement("g",{className:an(["react-flow__connection",h])},he.createElement(O3,{nodeId:a,handleType:o,style:t,type:n,CustomComponent:s,connectionStatus:h})))}function aE(e,t){return y.useRef(null),Pt(),y.useMemo(()=>t(e),[e])}const P3=({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:v,onSelectionStart:b,onSelectionEnd:k,connectionLineType:N,connectionLineStyle:j,connectionLineComponent:S,connectionLineContainerStyle:_,selectionKeyCode:T,selectionOnDrag:L,selectionMode:A,multiSelectionKeyCode:P,panActivationKeyCode:O,zoomActivationKeyCode:U,deleteKeyCode:q,onlyRenderVisibleElements:M,elementsSelectable:I,selectNodesOnDrag:E,defaultViewport:D,translateExtent:B,minZoom:H,maxZoom:G,preventScrolling:z,defaultMarkerColor:F,zoomOnScroll:$,zoomOnPinch:W,panOnScroll:Z,panOnScrollSpeed:V,panOnScrollMode:Y,zoomOnDoubleClick:X,panOnDrag:J,onPaneClick:Q,onPaneMouseEnter:te,onPaneMouseMove:ce,onPaneMouseLeave:ue,onPaneScroll:ie,onPaneContextMenu:re,onEdgeContextMenu:fe,onEdgeMouseEnter:ae,onEdgeMouseMove:je,onEdgeMouseLeave:me,onReconnect:pe,onReconnectStart:xe,onReconnectEnd:_e,reconnectRadius:ye,noDragClassName:Ie,noWheelClassName:Pe,noPanClassName:Ue,elevateEdgesOnSelect:$e,disableKeyboardA11y:Je,nodeOrigin:Qe,nodeExtent:ze,rfId:Ne})=>{const Ae=aE(e,N7),qe=aE(t,R7);return G7(o),he.createElement(k7,{onPaneClick:Q,onPaneMouseEnter:te,onPaneMouseMove:ce,onPaneMouseLeave:ue,onPaneContextMenu:re,onPaneScroll:ie,deleteKeyCode:q,selectionKeyCode:T,selectionOnDrag:L,selectionMode:A,onSelectionStart:b,onSelectionEnd:k,multiSelectionKeyCode:P,panActivationKeyCode:O,zoomActivationKeyCode:U,elementsSelectable:I,onMove:n,onMoveStart:s,onMoveEnd:a,zoomOnScroll:$,zoomOnPinch:W,zoomOnDoubleClick:X,panOnScroll:Z,panOnScrollSpeed:V,panOnScrollMode:Y,panOnDrag:J,defaultViewport:D,translateExtent:B,minZoom:H,maxZoom:G,onSelectionContextMenu:v,preventScrolling:z,noDragClassName:Ie,noWheelClassName:Pe,noPanClassName:Ue,disableKeyboardA11y:Je},he.createElement(V7,null,he.createElement(H7,{edgeTypes:qe,onEdgeClick:c,onEdgeDoubleClick:h,onlyRenderVisibleElements:M,onEdgeContextMenu:fe,onEdgeMouseEnter:ae,onEdgeMouseMove:je,onEdgeMouseLeave:me,onReconnect:pe,onReconnectStart:xe,onReconnectEnd:_e,reconnectRadius:ye,defaultMarkerColor:F,noPanClassName:Ue,elevateEdgesOnSelect:!!$e,disableKeyboardA11y:Je,rfId:Ne},he.createElement(X7,{style:j,type:N,component:S,containerStyle:_})),he.createElement("div",{className:"react-flow__edgelabel-renderer"}),he.createElement(C7,{nodeTypes:Ae,onNodeClick:i,onNodeDoubleClick:d,onNodeMouseEnter:f,onNodeMouseMove:p,onNodeMouseLeave:m,onNodeContextMenu:w,selectNodesOnDrag:E,onlyRenderVisibleElements:M,noPanClassName:Ue,noDragClassName:Ie,disableKeyboardA11y:Je,nodeOrigin:Qe,nodeExtent:ze,rfId:Ne})))};P3.displayName="GraphView";var Z7=y.memo(P3);const M0=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Ba={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:M0,nodeExtent:M0,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:Zo.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:NH,isValidConnection:void 0},J7=()=>FB((e,t)=>({...Ba,setNodes:n=>{const{nodeInternals:s,nodeOrigin:a,elevateNodesOnSelect:o}=t();e({nodeInternals:ly(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?ly(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((b,k)=>{const N=a.get(k.id);if(N!=null&&N.hidden)a.set(N.id,{...N,[Lt]:{...N[Lt],handleBounds:void 0}});else if(N){const j=nj(k.nodeElement);!!(j.width&&j.height&&(N.width!==j.width||N.height!==j.height||k.forceUpdate))&&(a.set(N.id,{...N,[Lt]:{...N[Lt],handleBounds:{source:JC(".source",k.nodeElement,m,h),target:JC(".target",k.nodeElement,m,h)}},...j}),b.push({id:N.id,type:"dimensions",dimensions:j}))}return b},[]);S3(a,h);const v=i||o&&!i&&_3(t,{initial:!0,...c});e({nodeInternals:new Map(a),fitViewOnInitDone:v}),(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=f7(n,c()),f=ly(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=>za(d,!0)):(i=rl(o(),n),c=rl(a,[])),Ah({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=>za(d,!0)):(i=rl(a,n),c=rl(o(),[])),Ah({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,za(f.id,!1))),h=c.map(f=>za(f.id,!1));Ah({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=>za(c.id,!1)),i=n.filter(c=>c.selected).map(c=>za(c.id,!1));Ah({changedNodes:o,changedEdges:i,get:t,set:e})},setNodeExtent:n=>{const{nodeInternals:s}=t();s.forEach(a=>{a.positionAbsolute=sj(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=ta.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:Ba.connectionNodeId,connectionHandleId:Ba.connectionHandleId,connectionHandleType:Ba.connectionHandleType,connectionStatus:Ba.connectionStatus,connectionStartHandle:Ba.connectionStartHandle,connectionEndHandle:Ba.connectionEndHandle}),reset:()=>e({...Ba})}),Object.is),hj=({children:e})=>{const t=y.useRef(null);return t.current||(t.current=J7()),he.createElement(yH,{value:t.current},e)};hj.displayName="ReactFlowProvider";const D3=({children:e})=>y.useContext(wp)?he.createElement(he.Fragment,null,e):he.createElement(hj,null,e);D3.displayName="ReactFlowWrapper";const Q7={input:w3,default:A0,output:v3,group:uj},ez={default:Ef,straight:oj,step:aj,smoothstep:xp,simplebezier:rj},tz=[0,0],nz=[15,15],sz={x:0,y:0,zoom:1},rz={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},F3=y.forwardRef(({nodes:e,edges:t,defaultNodes:n,defaultEdges:s,className:a,nodeTypes:o=Q7,edgeTypes:i=ez,onNodeClick:c,onEdgeClick:d,onInit:h,onMove:f,onMoveStart:p,onMoveEnd:m,onConnect:w,onConnectStart:v,onConnectEnd:b,onClickConnectStart:k,onClickConnectEnd:N,onNodeMouseEnter:j,onNodeMouseMove:S,onNodeMouseLeave:_,onNodeContextMenu:T,onNodeDoubleClick:L,onNodeDragStart:A,onNodeDrag:P,onNodeDragStop:O,onNodesDelete:U,onEdgesDelete:q,onSelectionChange:M,onSelectionDragStart:I,onSelectionDrag:E,onSelectionDragStop:D,onSelectionContextMenu:B,onSelectionStart:H,onSelectionEnd:G,connectionMode:z=Zo.Strict,connectionLineType:F=Ga.Bezier,connectionLineStyle:$,connectionLineComponent:W,connectionLineContainerStyle:Z,deleteKeyCode:V="Backspace",selectionKeyCode:Y="Shift",selectionOnDrag:X=!1,selectionMode:J=vu.Full,panActivationKeyCode:Q="Space",multiSelectionKeyCode:te=_f()?"Meta":"Control",zoomActivationKeyCode:ce=_f()?"Meta":"Control",snapToGrid:ue=!1,snapGrid:ie=nz,onlyRenderVisibleElements:re=!1,selectNodesOnDrag:fe=!0,nodesDraggable:ae,nodesConnectable:je,nodesFocusable:me,nodeOrigin:pe=tz,edgesFocusable:xe,edgesUpdatable:_e,elementsSelectable:ye,defaultViewport:Ie=sz,minZoom:Pe=.5,maxZoom:Ue=2,translateExtent:$e=M0,preventScrolling:Je=!0,nodeExtent:Qe,defaultMarkerColor:ze="#b1b1b7",zoomOnScroll:Ne=!0,zoomOnPinch:Ae=!0,panOnScroll:qe=!1,panOnScrollSpeed:et=.5,panOnScrollMode:ot=Fo.Free,zoomOnDoubleClick:we=!0,panOnDrag:Ge=!0,onPaneClick:Ye,onPaneMouseEnter:Xe,onPaneMouseMove:rt,onPaneMouseLeave:jt,onPaneScroll:Ut,onPaneContextMenu:pt,children:Ct,onEdgeContextMenu:It,onEdgeDoubleClick:Wt,onEdgeMouseEnter:tr,onEdgeMouseMove:Cs,onEdgeMouseLeave:Jn,onEdgeUpdate:Qn,onEdgeUpdateStart:Es,onEdgeUpdateEnd:fn,onReconnect:Un,onReconnectStart:Ce,onReconnectEnd:Re,reconnectRadius:He=10,edgeUpdaterRadius:vt=10,onNodesChange:Et,onEdgesChange:es,noDragClassName:ts="nodrag",noWheelClassName:pn="nowheel",noPanClassName:nr="nopan",fitView:mn=!1,fitViewOptions:nn,connectOnClick:ns=!0,attributionPosition:Ts,proOptions:sr,defaultEdgeOptions:As,elevateNodesOnSelect:rr=!0,elevateEdgesOnSelect:ar=!1,disableKeyboardA11y:or=!1,autoPanOnConnect:ha=!0,autoPanOnNodeDrag:ht=!0,connectionRadius:fa=20,isValidConnection:Tr,onError:pa,style:Mt,id:Ar,nodeDragThreshold:ir,...ss},Zt)=>{const Rr=Ar||"1";return he.createElement("div",{...ss,style:{...Mt,...rz},ref:Zt,className:an(["react-flow",a]),"data-testid":"rf__wrapper",id:Ar},he.createElement(D3,null,he.createElement(Z7,{onInit:h,onMove:f,onMoveStart:p,onMoveEnd:m,onNodeClick:c,onEdgeClick:d,onNodeMouseEnter:j,onNodeMouseMove:S,onNodeMouseLeave:_,onNodeContextMenu:T,onNodeDoubleClick:L,nodeTypes:o,edgeTypes:i,connectionLineType:F,connectionLineStyle:$,connectionLineComponent:W,connectionLineContainerStyle:Z,selectionKeyCode:Y,selectionOnDrag:X,selectionMode:J,deleteKeyCode:V,multiSelectionKeyCode:te,panActivationKeyCode:Q,zoomActivationKeyCode:ce,onlyRenderVisibleElements:re,selectNodesOnDrag:fe,defaultViewport:Ie,translateExtent:$e,minZoom:Pe,maxZoom:Ue,preventScrolling:Je,zoomOnScroll:Ne,zoomOnPinch:Ae,zoomOnDoubleClick:we,panOnScroll:qe,panOnScrollSpeed:et,panOnScrollMode:ot,panOnDrag:Ge,onPaneClick:Ye,onPaneMouseEnter:Xe,onPaneMouseMove:rt,onPaneMouseLeave:jt,onPaneScroll:Ut,onPaneContextMenu:pt,onSelectionContextMenu:B,onSelectionStart:H,onSelectionEnd:G,onEdgeContextMenu:It,onEdgeDoubleClick:Wt,onEdgeMouseEnter:tr,onEdgeMouseMove:Cs,onEdgeMouseLeave:Jn,onReconnect:Un??Qn,onReconnectStart:Ce??Es,onReconnectEnd:Re??fn,reconnectRadius:He??vt,defaultMarkerColor:ze,noDragClassName:ts,noWheelClassName:pn,noPanClassName:nr,elevateEdgesOnSelect:ar,rfId:Rr,disableKeyboardA11y:or,nodeOrigin:pe,nodeExtent:Qe}),he.createElement(GH,{nodes:e,edges:t,defaultNodes:n,defaultEdges:s,onConnect:w,onConnectStart:v,onConnectEnd:b,onClickConnectStart:k,onClickConnectEnd:N,nodesDraggable:ae,nodesConnectable:je,nodesFocusable:me,edgesFocusable:xe,edgesUpdatable:_e,elementsSelectable:ye,elevateNodesOnSelect:rr,minZoom:Pe,maxZoom:Ue,nodeExtent:Qe,onNodesChange:Et,onEdgesChange:es,snapToGrid:ue,snapGrid:ie,connectionMode:z,translateExtent:$e,connectOnClick:ns,defaultEdgeOptions:As,fitView:mn,fitViewOptions:nn,onNodesDelete:U,onEdgesDelete:q,onNodeDragStart:A,onNodeDrag:P,onNodeDragStop:O,onSelectionDrag:E,onSelectionDragStart:I,onSelectionDragStop:D,noPanClassName:nr,nodeOrigin:pe,rfId:Rr,autoPanOnConnect:ha,autoPanOnNodeDrag:ht,onError:pa,connectionRadius:fa,isValidConnection:Tr,nodeDragThreshold:ir}),he.createElement(zH,{onSelectionChange:M}),Ct,he.createElement(xH,{proOptions:sr,position:Ts}),he.createElement(JH,{rfId:Rr,disableKeyboardA11y:or})))});F3.displayName="ReactFlow";const az=e=>({x:e.transform[0],y:e.transform[1],zoom:e.transform[2]});function B3(){return lt(az,Xt)}const q3=({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:v,backgroundColor:b}=o||{},k=i||v||b;return he.createElement("rect",{className:an(["react-flow__minimap-node",{selected:w},h]),x:t,y:n,rx:f,ry:f,width:s,height:a,fill:k,stroke:c,strokeWidth:d,shapeRendering:p,onClick:m?N=>m(N,e):void 0})};q3.displayName="MiniMapNode";var oz=y.memo(q3);const iz=e=>e.nodeOrigin,lz=e=>e.getNodes().filter(t=>!t.hidden&&t.width&&t.height),hy=e=>e instanceof Function?e:()=>e;function cz({nodeStrokeColor:e="transparent",nodeColor:t="#e2e2e2",nodeClassName:n="",nodeBorderRadius:s=5,nodeStrokeWidth:a=2,nodeComponent:o=oz,onClick:i}){const c=lt(lz,Xt),d=lt(iz),h=hy(t),f=hy(e),p=hy(n),m=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return he.createElement(he.Fragment,null,c.map(w=>{const{x:v,y:b}=Wo(w,d).positionAbsolute;return he.createElement(o,{key:w.id,x:v,y:b,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 uz=y.memo(cz);const dz=200,hz=150,fz=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?kH(vp(t,e.nodeOrigin),n):n,rfId:e.rfId}},pz="react-flow__minimap-desc";function U3({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:v=!1,zoomable:b=!1,ariaLabel:k="React Flow mini map",inversePan:N=!1,zoomStep:j=10,offsetScale:S=5}){const _=Pt(),T=y.useRef(null),{boundingRect:L,viewBB:A,rfId:P}=lt(fz,Xt),O=(e==null?void 0:e.width)??dz,U=(e==null?void 0:e.height)??hz,q=L.width/O,M=L.height/U,I=Math.max(q,M),E=I*O,D=I*U,B=S*I,H=L.x-(E-L.width)/2-B,G=L.y-(D-L.height)/2-B,z=E+B*2,F=D+B*2,$=`${pz}-${P}`,W=y.useRef(0);W.current=I,y.useEffect(()=>{if(T.current){const Y=xs(T.current),X=te=>{const{transform:ce,d3Selection:ue,d3Zoom:ie}=_.getState();if(te.sourceEvent.type!=="wheel"||!ue||!ie)return;const re=-te.sourceEvent.deltaY*(te.sourceEvent.deltaMode===1?.05:te.sourceEvent.deltaMode?1:.002)*j,fe=ce[2]*Math.pow(2,re);ie.scaleTo(ue,fe)},J=te=>{const{transform:ce,d3Selection:ue,d3Zoom:ie,translateExtent:re,width:fe,height:ae}=_.getState();if(te.sourceEvent.type!=="mousemove"||!ue||!ie)return;const je=W.current*Math.max(1,ce[2])*(N?-1:1),me={x:ce[0]-te.sourceEvent.movementX*je,y:ce[1]-te.sourceEvent.movementY*je},pe=[[0,0],[fe,ae]],xe=ta.translate(me.x,me.y).scale(ce[2]),_e=ie.constrain()(xe,pe,re);ie.transform(ue,_e)},Q=ZO().on("zoom",v?J:null).on("zoom.wheel",b?X:null);return Y.call(Q),()=>{Y.on("zoom",null)}}},[v,b,N,j]);const Z=m?Y=>{const X=zs(Y);m(Y,{x:X[0],y:X[1]})}:void 0,V=w?(Y,X)=>{const J=_.getState().nodeInternals.get(X);w(Y,J)}:void 0;return he.createElement(tj,{position:p,style:e,className:an(["react-flow__minimap",t]),"data-testid":"rf__minimap"},he.createElement("svg",{width:O,height:U,viewBox:`${H} ${G} ${z} ${F}`,role:"img","aria-labelledby":$,ref:T,onClick:Z},k&&he.createElement("title",{id:$},k),he.createElement(uz,{onClick:V,nodeColor:s,nodeStrokeColor:n,nodeBorderRadius:o,nodeClassName:a,nodeStrokeWidth:i,nodeComponent:c}),he.createElement("path",{className:"react-flow__minimap-mask",d:`M${H-B},${G-B}h${z+B*2}v${F+B*2}h${-z-B*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"})))}U3.displayName="MiniMap";var mz=y.memo(U3);function gz(){return he.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},he.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function yz(){return he.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},he.createElement("path",{d:"M0 0h32v4.2H0z"}))}function wz(){return he.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},he.createElement("path",{d:"M3.692 4.63c0-.53.4-.938.939-.938h5.215V0H4.708C2.13 0 0 2.054 0 4.63v5.216h3.692V4.631zM27.354 0h-5.2v3.692h5.17c.53 0 .984.4.984.939v5.215H32V4.631A4.624 4.624 0 0027.354 0zm.954 24.83c0 .532-.4.94-.939.94h-5.215v3.768h5.215c2.577 0 4.631-2.13 4.631-4.707v-5.139h-3.692v5.139zm-23.677.94c-.531 0-.939-.4-.939-.94v-5.138H0v5.139c0 2.577 2.13 4.707 4.708 4.707h5.138V25.77H4.631z"}))}function xz(){return he.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},he.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0 8 0 4.571 3.429 4.571 7.619v3.048H3.048A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047zm4.724-13.866H7.467V7.619c0-2.59 2.133-4.724 4.723-4.724 2.591 0 4.724 2.133 4.724 4.724v3.048z"}))}function vz(){return he.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},he.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"}))}const gs=({children:e,className:t,...n})=>he.createElement("button",{type:"button",className:an(["react-flow__controls-button",t]),...n},e);gs.displayName="ControlButton";const bz=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),W3=({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=Pt(),[w,v]=y.useState(!1),{isInteractive:b,minZoomReached:k,maxZoomReached:N}=lt(bz,Xt),{zoomIn:j,zoomOut:S,fitView:_}=Ll();if(y.useEffect(()=>{v(!0)},[]),!w)return null;const T=()=>{j(),o==null||o()},L=()=>{S(),i==null||i()},A=()=>{_(a),c==null||c()},P=()=>{m.setState({nodesDraggable:!b,nodesConnectable:!b,elementsSelectable:!b}),d==null||d(!b)};return he.createElement(tj,{className:an(["react-flow__controls",h]),position:p,style:e,"data-testid":"rf__controls"},t&&he.createElement(he.Fragment,null,he.createElement(gs,{onClick:T,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:N},he.createElement(gz,null)),he.createElement(gs,{onClick:L,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:k},he.createElement(yz,null))),n&&he.createElement(gs,{className:"react-flow__controls-fitview",onClick:A,title:"fit view","aria-label":"fit view"},he.createElement(wz,null)),s&&he.createElement(gs,{className:"react-flow__controls-interactive",onClick:P,title:"toggle interactivity","aria-label":"toggle interactivity"},b?he.createElement(vz,null):he.createElement(xz,null)),f)};W3.displayName="Controls";var kz=y.memo(W3),Ks;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Ks||(Ks={}));function jz({color:e,dimensions:t,lineWidth:n}){return he.createElement("path",{stroke:e,strokeWidth:n,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`})}function Nz({color:e,radius:t}){return he.createElement("circle",{cx:t,cy:t,r:t,fill:e})}const Sz={[Ks.Dots]:"#91919a",[Ks.Lines]:"#eee",[Ks.Cross]:"#e2e2e2"},_z={[Ks.Dots]:1,[Ks.Lines]:1,[Ks.Cross]:6},Cz=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function H3({id:e,variant:t=Ks.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}=lt(Cz,Xt),m=i||Sz[t],w=s||_z[t],v=t===Ks.Dots,b=t===Ks.Cross,k=Array.isArray(n)?n:[n,n],N=[k[0]*f[2]||1,k[1]*f[2]||1],j=w*f[2],S=b?[j,j]:N,_=v?[j/o,j/o]:[S[0]/o,S[1]/o];return he.createElement("svg",{className:an(["react-flow__background",d]),style:{...c,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:h,"data-testid":"rf__background"},he.createElement("pattern",{id:p+e,x:f[0]%N[0],y:f[1]%N[1],width:N[0],height:N[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${_[0]},-${_[1]})`},v?he.createElement(Nz,{color:m,radius:j/o}):he.createElement(jz,{dimensions:S,color:m,lineWidth:a})),he.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${p+e})`}))}H3.displayName="Background";var Ez=y.memo(H3);function Tz(e,t){return e?t==="gone"?"entering":t==="leaving"?"here":t:t==="gone"?"gone":"leaving"}function Xa(e){return e!=="gone"}function oE(e,t){return e||Xa(t)}function iE(e,t){return!e&&Xa(t)}function al(e,t){const[n,s]=y.useState(()=>e?"here":"gone"),a=y.useRef(null);return y.useEffect(()=>{s(o=>Tz(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 z3=.2,V3=1.6;function Az(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<z3||a>V3?null:{x:n,y:s,zoom:a}}function $0({durationMs:e,documentHidden:t,reducedMotion:n=Hu()}){return t||n?!1:Number.isFinite(e)&&e>0}function Hu(){return typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches}function fj(){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 ca(e,t){return`${e}::${t}`}function Il(e,t){return`${e}\0${t}`}const Rz=/[0-9a-f]{16,}/i,Mz=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function G3(e){return Rz.test(e)||Mz.test(e)}function $z(e){if(!e)return;const t=e.replace(/\\/g,"/").split("/").filter(Boolean);for(let n=t.length-1;n>=0;n--)if(!G3(t[n]))return t[n];return t[t.length-1]}function K3(){return{inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0}}function Y3(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 bp(e){const t=Y3(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=bp({...e.longContext,longContext:void 0})),n}function Lz(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]=bp(a);const o=Iz(a.speeds);o&&(t[n].bySpeed=o)}return Object.keys(t).length?t:void 0}function Iz(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,bp(s)]);return t.length?Object.fromEntries(t):void 0}function X3(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),...Y3(n)};for(const s of Object.values(n)){const a=X3(s,t+1);if(a)return a}return null}function pj(e){return $z(e)}function mj(e){const t=e.agent_type??e.subagent_type;return t&&!G3(t)?t:"subagent"}function Ol(e){return e.agent_id?e.agent_id:e.parent_tool_use_id?e.parent_tool_use_id:null}function Qo(e,t){!e.cwd&&t.cwd&&(e.cwd=t.cwd,e.cwdBasename=pj(t.cwd))}function gj(e,t){e.label==="session"&&t.cwd&&(e.label=pj(t.cwd)??"session")}function Z3(e,t){const n=mj(t);n&&(e.label==="subagent"||!e.label)&&(e.label=n)}function io(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:K3()},e.agents.set(a,o),o)}function J3(e,t,n,s){const a=ca(t,n),o=e.agents.get(a);return o?(Qo(o,s),Z3(o,s),o):null}function Oz(e,t,n){var h;const s=t.session_id??"unknown",a=Ol(t);if(a){const f=J3(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(ca(s,c));if(f)return Qo(f,t),f}const d=io(e,s,n,t.hook_event_name!=="SessionStart");return Qo(d,t),gj(d,t),d}function Pz(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 Dz(e,t,n,s,a){const o=ca(t,n),i=io(e,t,a,!0);let c=e.agents.get(o);if(c)return Qo(c,s),Z3(c,s),c;c={id:o,sessionId:t,label:mj(s),kind:"subagent",parentId:i.id,state:"active",startedAt:a,tools:[],prompts:[],cwd:s.cwd,cwdBasename:pj(s.cwd),toolCount:0,childCount:0,usage:K3()},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 Fz(e,t,n){const s=e.activeSubagentStack.get(t)??[];s.includes(n)||(s.push(n),e.activeSubagentStack.set(t,s))}function Q3(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 Bz=new Set(["PreToolUse","PostToolUse","PostToolUseFailure","Stop","SubagentStop"]),e4=/^[a-z][a-z0-9_-]{0,23}$/i;function qz(e,t){if(t.provider==="codex")return;const n=t.effort&&typeof t.effort=="object"?t.effort.level:void 0;return typeof n=="string"&&e4.test(n)?n:Bz.has(e)?null:void 0}function t4(){return{msgsUser:0,msgsAssistant:0,toolUses:0,toolResults:0,systemReminders:0,currentContextTokens:0,memoryFiles:[]}}function yj(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"&&e4.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??t4(),currentContextTokens:t.context_tokens})}}const Uz=6e4,lE=64;function n4(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=ca(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 s4(e,t,n){const s=t.context??null;if(s){const a=e.agents.get(n);if(a){const o=a.context??t4(),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 r4(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 Wz(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 a4(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 Hz=new Set(["working","blocked","done","failed","stopped"]);function o4(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"||!Hz.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 zz(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<Uz);c.push(o),i.outputs=c.length>lE?c.slice(-lE):c}e.revision+=1}}function wj(e,t,n){const s=t.usage??null;if(s){const a=e.agents.get(n);if(a){const o=bp(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=Lz(t.usageByModel))}}}function Kt(e,t){return Object.hasOwn(e,t)?e[t]:void 0}const Vz=/^\s*<task-notification>([\s\S]*?)<\/task-notification>/;function cE(e,t){var n;return((n=new RegExp(`<${t}>([\\s\\S]*?)</${t}>`).exec(e))==null?void 0:n[1].trim())||void 0}const Gz={completed:"background task finished",failed:"background task failed",killed:"background task stopped"};function kp(e){const t=Vz.exec(e);if(!t)return null;const n=cE(t[1],"status");return{label:(n?Kt(Gz,n):void 0)??"background task update",detail:cE(t[1],"summary")}}function i4(e){return e.filter(t=>!kp(t.text))}const uE=2e3;function Kz(e,t,n){for(let s=e.length-1;s>=0;s--){const a=e[s];if(a.at<t-uE)return!1;if(a.text===n&&a.at<=t+uE)return!0}return!1}function Yz(e,t,n){if(Kz(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 Tf=2e3;function Xz(e){const t=e.prompts[e.prompts.length-1];return t&&t.at>e.startedAt?t.at:e.startedAt}const dE=["B","KB","MB","GB","TB"];function Zr(e){if(e==null||!Number.isFinite(e)||e<0)return"—";if(e===0)return"0 B";let t=e,n=0;for(;n<dE.length-1&&Number(t.toFixed(1))>=1024;)t/=1024,n++;return`${t.toFixed(1)} ${dE[n]}`}const Zz=60,Jz=6e3,ks=e=>e!=null&&typeof e=="object"&&!Array.isArray(e),Gn=e=>typeof e=="string"?e:null;function Qz(e){return ks(e)&&e.ccdeck_truncated===!0&&typeof e.chars=="number"&&Object.keys(e).length===2?e.chars:null}function _l(e){const t=Qz(e);if(t!=null)return`(too large to show — ${Zr(t)}, cut by the hook)`;if(Array.isArray(e)){const n=e.map(_l);return n.some((s,a)=>s!==e[a])?n:e}if(ks(e)){let n=!1;const s={};for(const[a,o]of Object.entries(e))s[a]=_l(o),s[a]!==o&&(n=!0);return n?s:e}return e}function ei(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=ei(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 e9(e){return e.lines??e.text.split(`
61
+ `).map(t=>({text:t}))}function l4(e,t){if(t)return{shown:e,cut:!1};const n=[];let s=0;for(const a of e){if(n.length===Zz)return{shown:n,cut:!0};const o=Jz-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 t9(e,t){return l4(e,!1).cut?t?{label:"show less",expanded:!0}:{label:"show all",expanded:!1}:null}const xn=(e,t,n=!1)=>({...e?{label:e}:{},text:t,...n?{err:!0}:{}}),Kn=(e,t)=>({label:e,text:t,inline:!0}),c4=(e,t)=>({label:e,text:t.map(n=>n.text).join(`
62
+ `),lines:t});function n9(e,t){return[...e.split(`
63
+ `).map(n=>({text:`- ${n}`,tone:"del"})),...t.split(`
64
+ `).map(n=>({text:`+ ${n}`,tone:"add"}))]}function s9(e){if(!Array.isArray(e)||e.length===0)return null;const t=[];for(const n of e){if(!ks(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 hE(e){if(typeof e=="string")return[xn(void 0,e)];if(!ks(e))return[xn(void 0,ei(e))];const t=[],n=Gn(e.type);n==="create"&&t.push(Kn("result","created the file"));const s=s9(e.structuredPatch);return s&&t.push(c4("applied",s)),e.userModified===!0&&t.push(Kn("note","the user changed it before it was applied")),t.length?t:[Kn("result",n==="update"?"updated the file":"done")]}function r9(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 a9(e){if(typeof e=="string")return[xn(void 0,e)];const t=ks(e)&&ks(e.file)?e.file:null,n=Gn(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(Kn("lines",o>=i?`all ${i}`:Number.isFinite(c)?`${c}–${c+o-1} of ${i}`:`${o} of ${i}`)),a.push(xn("content",n)),a}const s=ks(e)?Gn(e.type):null;return s&&s!=="text"?[Kn("result",`${/^[aeiou]/i.test(s)?"an":"a"} ${s} file`)]:[xn(void 0,ei(e))]}function o9(e){if(typeof e=="string")return[xn("output",e)];if(!ks(e))return[xn(void 0,ei(e))];const t=Gn(e.stdout),n=Gn(e.stderr);if(t==null&&n==null)return[xn(void 0,ei(e))];const s=[];return t&&s.push(xn("output",t.replace(/\n$/,""))),n&&s.push(xn("errors",n.replace(/\n$/,""),!0)),e.interrupted===!0&&s.push(Kn("note","interrupted before it finished")),s.length?s:[Kn("output","none")]}function i9(e,t,n){const s=_l(t),a=_l(n),o=ks(s)?s:null;if(o&&(e==="Edit"||e==="MultiEdit")){const i=Gn(o.file_path),c=(e==="MultiEdit"?Array.isArray(o.edits)?o.edits:[]:[o]).filter(ks).filter(d=>Gn(d.old_string)!=null&&Gn(d.new_string)!=null);if(i&&c.length){const d=[Kn("file",i)];return c.forEach((h,f)=>{const p=h.replace_all===!0?", every occurrence":"";d.push(c4(c.length>1?`change ${f+1}${p}`:`change${p}`,n9(h.old_string,h.new_string)))}),{input:d,response:hE(a)}}}if(o&&e==="Write"){const i=Gn(o.file_path),c=Gn(o.content);if(i&&c!=null)return{input:[Kn("file",i),xn("content",c)],response:hE(a)}}if(o&&e==="Read"){const i=Gn(o.file_path);if(i){const c=r9(o);return{input:c?[Kn("file",i),Kn("lines",c)]:[Kn("file",i)],response:a9(a)}}}if(o&&e==="Bash"){const i=Gn(o.command);if(i!=null){const c=Gn(o.description);return{input:c?[xn("command",i),Kn("why",c)]:[xn("command",i)],response:o9(a)}}}return{input:[xn(void 0,ei(s))],response:[xn(void 0,ei(a))]}}function fE(e,t,n){const s=_l(n);if(s==null)return"";if(typeof s=="string")return s;if(ks(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"&&ks(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 l9=new Set(["TodoWrite","update_plan"]),c9=new Set(["TaskCreate","TaskUpdate","TaskList","TaskGet"]);function Xc(e){return e==="pending"||e==="in_progress"||e==="completed"?e:null}function ys(e){return typeof e=="string"?e.trim():""}function Lo(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 u9(e,t){const n=Lo(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=ys(e==="TodoWrite"?c.content:c.step),h=Xc(c.status);if(!d||!h)continue;const f=ys(c.activeForm??c.active_form);a.push(f?{text:d,status:h,active:f}:{text:d,status:h})}const o=e==="update_plan"?ys(n.explanation):"";return o?{items:a,note:o}:{items:a}}function Wa(e,t,n){return n?{items:e,at:t,note:n}:{items:e,at:t}}function d9(e,t,n,s){if(!t||!l9.has(t)||e.plan&&s<e.plan.at)return;const a=u9(t,n);a&&(e.plan=Wa(a.items,s,a.note))}function zi(e){if(!e)return"";const t=e.taskId??e.id??e.task_id;return typeof t=="number"?String(t):ys(t)}function h9(e,t,n,s,a){var b,k,N,j,S,_,T,L,A,P,O,U,q,M,I;if(!t||!c9.has(t))return;const o=Lo(n),i=Lo(s),c=((b=e.plan)==null?void 0:b.items)??[],d=E=>c.findIndex(D=>D.id===E);if(t==="TaskCreate"){const E=Lo(i==null?void 0:i.task),D=zi(E),B=ys(E==null?void 0:E.subject)||ys(o==null?void 0:o.subject);if(!D||!B)return;const H=ys((o==null?void 0:o.activeForm)??(o==null?void 0:o.active_form)),G=d(D),z={id:D,text:B,status:G>=0?c[G].status:"pending",...H?{active:H}:{}},F=c.slice();G>=0?F[G]=z:F.push(z),e.plan=Wa(F,Math.max(a,((k=e.plan)==null?void 0:k.at)??a),(N=e.plan)==null?void 0:N.note);return}if(t==="TaskUpdate"){if(i&&i.success===!1)return;const E=zi(i)||zi(o);if(!E)return;const D=o==null?void 0:o.status,B=d(E);if(D==="deleted"){if(B<0)return;e.plan=Wa(c.filter((Z,V)=>V!==B),Math.max(a,((j=e.plan)==null?void 0:j.at)??a),(S=e.plan)==null?void 0:S.note);return}const H=ys(o==null?void 0:o.subject),G=ys((o==null?void 0:o.activeForm)??(o==null?void 0:o.active_form)),z=Xc(D)??Xc((_=Lo(i==null?void 0:i.statusChange))==null?void 0:_.to);if(B<0){if(!H)return;const Z={id:E,text:H,status:z??"pending",...G?{active:G}:{}};e.plan=Wa([...c,Z],Math.max(a,((T=e.plan)==null?void 0:T.at)??a),(L=e.plan)==null?void 0:L.note);return}const $={...c[B],...H?{text:H}:{},...z?{status:z}:{},...G?{active:G}:{}},W=c.slice();W[B]=$,e.plan=Wa(W,Math.max(a,((A=e.plan)==null?void 0:A.at)??a),(P=e.plan)==null?void 0:P.note);return}if(t==="TaskList"){if(!i||!Array.isArray(i.tasks)||e.plan&&a<e.plan.at)return;const E=[];for(const D of i.tasks){const B=Lo(D),H=zi(B),G=ys(B==null?void 0:B.subject),z=Xc(B==null?void 0:B.status);if(!H||!G||!z)continue;const F=c.find($=>$.id===H);E.push(F!=null&&F.active?{id:H,text:G,status:z,active:F.active}:{id:H,text:G,status:z})}e.plan=Wa(E,a,(O=e.plan)==null?void 0:O.note);return}const h=i&&"task"in i?Lo(i.task):void 0,f=zi(h??null)||zi(o),p=f?d(f):-1;if(p<0)return;if(h===null){e.plan=Wa(c.filter((E,D)=>D!==p),Math.max(a,((U=e.plan)==null?void 0:U.at)??a),(q=e.plan)==null?void 0:q.note);return}const m=ys(h==null?void 0:h.subject),w=Xc(h==null?void 0:h.status);if(!m&&!w)return;const v=c.slice();v[p]={...c[p],...m?{text:m}:{},...w?{status:w}:{}},e.plan=Wa(v,Math.max(a,((M=e.plan)==null?void 0:M.at)??a),(I=e.plan)==null?void 0:I.note)}function _r(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 xj(e){const t=`${e.done}/${e.total}`;return e.allDone||!e.current?`${t} · done`:`${t} · ${e.next?"next: ":""}${e.current}`}function u4(e){const t=`plan ${e.done} of ${e.total} done`;return e.allDone||!e.current?t:`${t}, ${e.next?"next":"now"}: ${e.current}`}function jp(e){return e.map(t=>`${t.status==="completed"?"✓":t.status==="in_progress"?"▸":"○"} ${t.text}`).join(`
66
+ `)}function f9(e,t=5){if(e.length<=t)return{shown:e,before:0,after:0};let n=e.findIndex(a=>a.status==="in_progress");n<0&&(n=e.findIndex(a=>a.status==="pending")),n<0&&(n=e.length-1);const s=Math.max(0,Math.min(n-1,e.length-t));return{shown:e.slice(s,s+t),before:s,after:e.length-s-t}}function ku(e,t=80){const n=_l(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 pE=200;function d4(e,t,n){const s=t.ok===!1;t.ok=n,e&&s===n&&(e.toolErrorCount=(e.toolErrorCount??0)+(n?-1:1))}function h4(e,t){return t.agentId==null?void 0:e.agents.get(t.agentId)}function ru(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 p9(e,t,n){var s;return((s=e.get(t))==null?void 0:s.tools.find(a=>a.id===n))??null}const f4=25;function p4(e,t){const n=t.tools;if(n.length>pE){const s=n.splice(0,n.length-pE);for(const a of s)g4(e,t,a)}for(let s=n.length-f4-1;s>=0;s--){const a=n[s];if(a.trimmed)break;a.input=void 0,a.response=void 0,a.trimmed=!0}}function m9(e,t,n){const s=e.toolIndex.get(Il(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 m4(e,t){for(const n of t.tools)g4(e,t,n)}function g4(e,t,n){const s=Il(t.sessionId,n.id);e.toolIndex.get(s)===n&&e.toolIndex.delete(s)}function g9(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,ru(a,i.name,-1),i.ok===!1&&(a.toolErrorCount=(a.toolErrorCount??0)-1),i.agentId=n.id,n.tools.push(i),n.toolCount+=1,ru(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),p4(e,n);for(let a=0;a<n.tools.length-f4;a++){const o=n.tools[a];o.trimmed||(o.input=void 0,o.response=void 0,o.trimmed=!0)}}}const y9="no result reached the deck — events were dropped while the deck was paused";function y4(e,t,n,s,a){n.endedAt=s,d4(t,n,!1),n.errorPreview=n.outcomeGap?y9:a,e.toolIndex.delete(Il(t.sessionId,n.id))}function w9(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(Il((n==null?void 0:n.session_id)??"unknown",a))}function x9(e,t,n,s,a){const o=t.tool_use_id?m9(e,s,t.tool_use_id):null;if(o){if(t.tool_name&&o.name==="?"){o.name=t.tool_name;const h=h4(e,o);h&&(ru(h,"?",-1),ru(h,o.name,1))}o.endedAt==null&&!o.trimmed&&t.tool_input!==void 0&&(o.input=t.tool_input,o.inputPreview=ku(t.tool_input));return}const i=t.tool_use_id??`${s.id}:${s.toolCount}`,c=Ol(t),d={id:i,name:t.tool_name??"?",input:t.tool_input,inputPreview:ku(t.tool_input),agentId:s.id,explicitSubagentId:c?ca(n,c):void 0,startedAt:a};s.tools.push(d),s.toolCount+=1,ru(s,d.name,1),s.state="active",e.toolIndex.set(Il(s.sessionId,i),d),p4(e,s),d9(s,d.name,t.tool_input,a)}function v9(e,t,n,s,a){const o=t.tool_use_id;if(!o)return;const i=Il(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&&h9(f,t.tool_name??c.name,t.tool_input??c.input,t.tool_response,a)}c.outcomeGap=void 0,c.endedAt=a,d4(h4(e,c),c,n==="PostToolUse"),c.trimmed||(c.response=t.tool_response),n==="PostToolUseFailure"?c.errorPreview=ku(t.tool_response):d&&(c.errorPreview=void 0);const h=X3(t.tool_response);h&&(c.usage=h),e.toolIndex.delete(i)}function b9(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 vj(e,t){e!=null&&e.stopFailure&&t>e.stopFailure.at&&(e.stopFailure=null)}function k9(e,t,n,s){const a=io(e,n,s,!1);a.synthetic=!1,a.state="active",a.closedAt=void 0,a.endedAt=void 0,vj(a,s),a.startedAt=Math.min(a.startedAt??s,s),Qo(a,t),gj(a,t)}function j9(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=io(e,n,s,!1);a.state="active",a.endedAt=void 0,a.closedAt=void 0,a.exitAt=void 0,vj(a,s);const o=(typeof t.prompt=="string"?t.prompt:typeof t.message=="string"?t.message:"")??"";o&&Yz(a.prompts,s,o)&&!a.firstPrompt&&!kp(o)&&(a.firstPrompt=ku(o,120))}function L0(e,t,n,s,a){const o=io(e,n,s,!1),i=Xz(o);if(s<i)return;const c=o.lastTurnEndAt;if(!(c!=null&&i>c&&s<=c+Tf)){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&&y4(e,d,h,s,"the turn ended before this call returned");t==="SessionEnd"&&(o.closedAt=s),e.activeSubagentStack.delete(n)}}function N9(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&&(L0(e,t.recovery_session_closed===!0?"SessionEnd":"Stop",s,n),a.restoredFromLog=void 0);return}const o=io(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,Qo(o,t),gj(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=ku(t.prompt,120))),yj(e,t,s),wj(e,t,s)}function S9(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=io(e,s,n,!0);c.provider="codex",c.parentId=a,Qo(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 _9=["us-gov","global","apac","us","eu","jp","au"],C9=new RegExp(`^(?:(?:${_9.join("|")})\\.)?anthropic\\.`,"i");function yr(e){return e.replace(C9,"")}const E9=/^(?:claude[-_]|gpt[-_]|o\d|codex[-_])/i,T9=new Set(["tool_input","tool_response"]);function w4(e,t=0){if(!e||typeof e!="object"||t>6)return null;const n=e;if(typeof n.model=="string"&&E9.test(yr(n.model)))return n.model;for(const[s,a]of Object.entries(n)){if(T9.has(s))continue;const o=w4(a,t+1);if(o)return o}return null}const A9=256,rf={ModelObserved:n4,UsageObserved:wj,ContextObserved:s4,SessionNamed:r4,ActivityObserved:a4,JobObserved:o4},Xr=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Mh=e=>typeof e=="string"&&e.trim()!=="",R9=[["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]],M9=new Set(["working","blocked","done","failed","stopped"]),mE=e=>Xr(e)&&typeof e.text=="string"&&e.text.trim()!==""&&Number.isFinite(e.at);function $9(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 R9)o(t[a])||s(a);switch(t.hook_event_name){case"ModelObserved":typeof t.model=="string"&&t.model!==""||s("model"),(Xr(e.subagentModels)||Xr(t.subagentModels))&&(n.subagentModels={...Xr(e.subagentModels)?e.subagentModels:{},...Xr(t.subagentModels)?t.subagentModels:{}});break;case"ContextObserved":{if(!Xr(t.context)){s("context");break}const a=Xr(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=Mh(t.sessionName)?t.sessionName:e.sessionName??null;let o=Mh(t.sessionTitle)?t.sessionTitle:e.sessionTitle??null;Mh(a)&&Mh(o)&&o.trim().toLowerCase()===a.trim().toLowerCase()&&(o=null),n.sessionName=a,n.sessionTitle=o;break}case"ActivityObserved":(!mE(t.activity)||mE(e.activity)&&t.activity.at<e.activity.at)&&s("activity");break;case"JobObserved":t.job===null||Xr(t.job)&&M9.has(t.job.state)||s("job");break;case"UsageObserved":Xr(t.usage)?t.usageByModel===void 0&&delete n.usageByModel:(s("usage"),s("usageByModel"));break}return n}function L9(e,t,n,s){if(!(t in rf)||e.agents.has(s))return!1;const a=e.parkedEnrichment.get(s)??new Map,o=$9(a.get(t),n);for(a.delete(t),a.set(t,o),e.parkedEnrichment.delete(s),e.parkedEnrichment.set(s,a);e.parkedEnrichment.size>A9;){const i=e.parkedEnrichment.keys().next().value;if(i===void 0)break;e.parkedEnrichment.delete(i)}return!0}function I9(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)yj(e,o,t),(s=rf[a])==null||s.call(rf,e,o,t)}}function x4(e,t){e.parkedEnrichment.delete(t)}const O9="StopFailure",gE=Object.freeze({authentication_failed:"login",rate_limit:"usage-limit"});function P9(e){return typeof e=="string"&&Object.hasOwn(gE,e)?gE[e]:"api-error"}const D9=/^[a-z][a-z0-9_]{0,39}$/;function F9(e){const t=e==null?void 0:e.error;return typeof t=="string"&&D9.test(t)?t:"unknown"}const yE=160;function wE(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>yE?`${n.slice(0,yE-1).join("").trimEnd()}…`:t}function B9(e){return wE(e==null?void 0:e.last_assistant_message)||wE(e==null?void 0:e.error_details)}function q9(e,t){if(!e||typeof e!="object"||e.hook_event_name!==O9)return null;const n=F9(e);return{kind:P9(n),error:n,message:B9(e),at:t}}function U9(e,t,n,s){const a=Ol(t);if(!a)return;const o=Dz(e,n,a,t,s),i=mj(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<=Tf,h=c!=null&&s-c<=Tf;if(d||h){const f=h?c:o.endedAt;o.state="done",o.endedAt=f,o.startedAt=Math.min(o.startedAt,f),Q3(e,n,a);return}o.state="active",o.startedAt=o.startedAt||s,o.exitAt=void 0,o.endedAt=void 0,Fz(e,n,a)}function W9(e,t,n,s){const a=Ol(t);if(!a)return;const o=J3(e,n,a,t);if(!o){for(const[i,c]of e.subagentTombstones)s-c>Tf&&e.subagentTombstones.delete(i);e.subagentTombstones.set(ca(n,a),s);return}o.state="done",o.endedAt=Math.min(o.endedAt??s,s),Q3(e,n,a)}const H9=["command","cmd","file_path","path","url","pattern","notebook_path"],xE=120,fy=e=>e.length>xE?`${e.slice(0,xE-1)}…`:e;function z9(e){if(typeof e=="string")return e.trim()?fy(e.trim()):null;if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e;for(const n of H9){const s=t[n];if(typeof s=="string"&&s.trim())return fy(s.trim());if(Array.isArray(s)&&s.length>0&&s.every(a=>typeof a=="string")){const a=s.join(" ").trim();if(a)return fy(a)}}return null}function V9(e){return e==="permission_prompt"?"permission":e==="agent_needs_input"?"asked":e==="idle_prompt"?"idle":null}const G9=new Set(["Notification","ModelObserved","ContextObserved","UsageObserved","SessionNamed","SessionRecapped","OutputObserved","ActivityObserved","JobObserved"]);function K9(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 Y9=3e4;function X9(e,t){if(!(!e||!e.name)&&!(t-e.startedAt>Y9)&&!(e.startedAt>t))return{name:e.name,preview:z9(e.input)??""}}function Z9(e,t,n,s,a){if(n!=="permission")return{kind:n,message:s,since:a};const o=K9(e,t),i={kind:n,message:s,since:a};o!=null&&o.explicitSubagentId&&(i.subagentId=o.explicitSubagentId);const c=X9(o,a);return c&&(i.tool=c),i}function J9(e,t,n){if(e.kind==="idle")return!0;const s=Ol(t);return s==null?!0:e.subagentId!=null&&ca(n,s)===e.subagentId}function Q9(e,t,n,s){if(!G9.has(t)){const a=e.agents.get(s);a!=null&&a.waiting&&J9(a.waiting,n,s)&&(a.waiting=null)}}function eV(e,t,n,s){const a=V9(t.notification_type);if(!a)return;const o=io(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)}:Z9(e,n,a,i,s)}function Np(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 zu(e,t){return t&&(e.revision+=1),t}function tV(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=Np(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,v]of e.agents){if(v.parentId!=null){const b=h.get(v.parentId);b?b.push(w):h.set(v.parentId,[w])}o(v)&&!c.has(i.get(w))&&d.push({id:w,endedAt:v.endedAt})}if(d.length===0)return!1;d.sort((w,v)=>w.endedAt-v.endedAt);let f=0;const p=new Set,m=w=>{const v=e.agents.get(w);v&&(m4(e,v),e.agents.delete(w),v.kind==="root"&&x4(e,v.sessionId),p.add(v.sessionId),f++)};for(const w of d){if(e.agents.size<=n)break;if(!e.agents.has(w.id))continue;const v=[],b=new Set([w.id]),k=[...h.get(w.id)??[]];for(;k.length;){const N=k.pop();if(b.has(N))continue;b.add(N);const j=e.agents.get(N);j&&(v.push(j),k.push(...h.get(N)??[]))}if(!v.some(N=>!o(N))){for(const N of v.reverse())m(N.id);m(w.id)}}if(a&&p.size>0){const w=new Set;for(const v of e.agents.values())w.add(v.sessionId);for(const v of p)w.has(v)||a(v)}return zu(e,f>0)}function nV(e,t,n,s,a){const o=new Map;for(const[m,w]of e.agents){let v=o.get(w.sessionId);v||(v={ids:[],endedAt:0,live:!1,closed:!1},o.set(w.sessionId,v)),v.ids.push(m),w.kind==="root"&&w.closedAt!=null&&(v.closed=!0),w.state==="done"&&w.endedAt!=null?v.endedAt=Math.max(v.endedAt,w.endedAt):v.live=!0}const i=Np(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 b of w.ids){const k=e.agents.get(b);k&&m4(e,k),e.agents.delete(b)}x4(e,m);const v=ca(m,"");for(const b of e.pendingSubagentModels.keys())b.startsWith(v)&&e.pendingSubagentModels.delete(b);a==null||a(m),f--,p=!0}return zu(e,p)}function sV(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 zu(e,t)}function rV(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&&(y4(e,a,c,d,"session ended before this call returned"),s=!0)}}return zu(e,s)}const vE=90*6e4;function aV(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 zu(e,s)}function ju(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 v4(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{...fj(),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 N9(e,s,a),e;if(o==="CodexThreadLinked")return S9(e,s,a),e;const i=s.session_id??"unknown";if(Q9(e,o,s,i),o!=="JobObserved"&&b9(e,i,a),yj(e,s,i),L9(e,o,s,i))return e;switch(o){case"ModelObserved":return n4(e,s,i),e;case"ContextObserved":return s4(e,s,i),e;case"SessionNamed":return r4(e,s,i),e;case"SessionRecapped":return Wz(e,s,i),e;case"ActivityObserved":return a4(e,s,i),e;case"JobObserved":return o4(e,s,i),e;case"OutputObserved":return zz(e,s,i,a),e;case"UsageObserved":return wj(e,s,i),e}const c=Oz(e,s,a),d=e.agents.get(i);d&&a>=(d.recoveryLiveAt??0)&&(d.recoveryLiveAt=a,d.restoredFromLog=void 0),I9(e,i),Pz(e,o,s,i)&&g9(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=w4(s),f=Ol(s),p=f?ca(i,f):i;h&&c.id===p&&(c.model=h);const m=qz(o,s);switch(m!==void 0&&c.id===p&&(c.effort=m??void 0),(o==="PreToolUse"||o==="PostToolUse"||o==="PostToolUseFailure")&&f==null&&vj(e.agents.get(i),a),o){case"SessionStart":k9(e,s,i,a);break;case"UserPromptSubmit":j9(e,s,i,a);break;case"PreToolUse":x9(e,s,i,c,a);break;case"PostToolUse":case"PostToolUseFailure":v9(e,s,o,i,a);break;case"SubagentStart":U9(e,s,i,a);break;case"SubagentStop":W9(e,s,i,a);break;case"Stop":case"StopFailure":L0(e,o,i,a,{stopFailure:q9(s,a)});break;case"SessionEnd":L0(e,o,i,a);break;case"Notification":eV(e,s,i,a);break}return e}const oV="codex-auto-review",b4="chatgpt-auto-review-free",iV={input:2,output:10,cacheRead:.2,cacheWrite:2.5,cacheWrite1h:4},lV=[{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:iV},{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}}],cV=[{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 k4(e){return e?/^(?:gpt[-_]|codex[-_]|o\d)/i.test(e):!1}function jr(e,t=Date.now(),n=oa){if(!e)return null;if(e===oV&&n===b4)return{input:0,output:0,cacheRead:0,cacheWrite:0};if(n!==oa&&k4(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:jr(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=uV.get(n);if(!s)return null;const a=yr(e);for(const o of s)if(o.match.test(a))return typeof o.rates=="function"?o.rates(t):o.rates;return null}const oa="standard",uV=new Map([[oa,lV],["fast",cV]]);function au(e,t){return e*t/1e6}function j4(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:au(o,t.cacheWrite),usd1h:au(n,i)}}function N4(e,t,n=Date.now()){if(!k4(t))return e.inputTokens;const s=jr(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 Sp(e,t,n=Date.now()){const s={input:0,output:0,cacheRead:0,cacheWrite:0,total:0};for(const a of Vu(e)){const o=Nu(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 Nu(e,t,n,s=Date.now()){const a=jr(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 S4(e,t)){const c=i.usage,d=_4(a,i.long);o.input+=au(N4(c,t,s),d.input),o.output+=au(c.outputTokens,d.output),o.cacheRead+=au(c.cacheReadTokens,d.cacheRead);const h=j4(c,d);o.cacheWrite+=h.usd5m+h.usd1h}return o.total=o.input+o.output+o.cacheRead+o.cacheWrite,o}function S4(e,t){if(!e.longContext||!/^claude[-_]haiku[-_]5[-_.]5\b(?![-_.]\d{1,7}(?!\d))/i.test(yr(t??"")))return[{usage:e,long:!1}];const n=e.longContext;return[{usage:bj(e,[n]),long:!1},{usage:n,long:!0}]}function _4(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 Vu(e){const t=e.bySpeed?Object.entries(e.bySpeed):[];return t.length===0?[{speed:oa,usage:e}]:[{speed:oa,usage:bj(e,t.map(([,n])=>n))},...t.map(([n,s])=>({speed:n,usage:s}))]}function bj(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=bj(e.longContext,t.flatMap(o=>o.longContext?[o.longContext]:[]))),a}const ia="not priced";function ou(e,t,n){const s=e.toFixed(t);return Number(s)<n?s:null}function st(e){if(e<=0)return"—";if(e<.005)return"<1¢";if(e<1){const t=ou(e*100,e<.1?1:0,100);if(t!==null)return`${t}¢`}if(e<100){const t=ou(e,2,100);if(t!==null)return`$${t}`}if(e<1e4){const t=ou(e,0,1e4);if(t!==null)return`$${t}`}return`$${(e/1e3).toFixed(1)}k`}function kj(e,t){if(e<=0||t<10)return null;const n=e/t,s=n*60;return s>=.01?`${st(s)}/min`:`${st(n*3600)}/hr`}function I0(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=I0(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?I0(i,o):o)}n.bySpeed=Object.fromEntries(s)}return n}function dV(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 Pl(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=dV(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:I0(s[o].usage,a)}:s.push({model:e.model,usage:a})}return s}function Fn(e,t=Date.now()){const n={input:0,output:0,cacheRead:0,cacheWrite:0,total:0};for(const s of Pl(e)){const a=Sp(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 O0(e,t=Date.now()){return Pl(e).every(n=>{const s=Vu(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=>jr(n.model,t,a.speed)!==null):jr(n.model,t)!==null})}function Cl(e,t=Date.now()){let n=0;for(const s of Pl(e))for(const a of Vu(s.usage))jr(s.model,t,a.speed)==null&&(n+=a.usage.inputTokens+a.usage.outputTokens);return n}function C4(e){const t=[];for(const n of Pl(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 jj(e){return C4(e).filter(t=>t!==e.model)}function bE(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
+ `:"")+hV(e,t)}function hV(e,t){if(!e.bySpeed)return py(e,t,oa);const n=Vu(e).filter(s=>s.speed!==oa||E4(s.usage));return n.length===1?py(n[0].usage,t,n[0].speed):[...n.map(s=>py(s.usage,t,s.speed)),"═════════════════════════════════════════",`all speeds = ${st(Sp(e,t).total)}`].join(`
68
+ `)}function E4(e){return e.inputTokens+e.outputTokens+e.cacheReadTokens+e.cacheCreateTokens>0}function py(e,t,n){const s=S4(e,t).filter(a=>E4(a.usage));return e.longContext&&s.some(a=>a.long)?[...s.map(a=>kE(a.usage,t,n,a.long)),`all context tiers = ${st(Nu(e,t,n).total)}`].join(`
69
+ `):kE(e,t,n,!1)}function kE(e,t,n,s){const a=jr(t,Date.now(),n),o=a?_4(a,s):null,i=s?" · prompt >100K":"",c=(n===b4?`model: ${t} · no charge for ChatGPT auto-review`:n===oa?`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=b=>b.toLocaleString(),h=b=>`$${b}/MTok`,f=Nu(s?{...e,longContext:e}:{...e,longContext:void 0},t,n),p=j4(e,o),m=p.tokens1h>0?[`cache w5m${d(p.tokens5m).padStart(14)} × ${h(o.cacheWrite).padEnd(11)} = ${st(p.usd5m)}`,`cache w1h${d(p.tokens1h).padStart(14)} × ${h(o.cacheWrite1h??o.cacheWrite).padEnd(11)} = ${st(p.usd1h)}`]:[`cache w ${d(p.tokens5m).padStart(14)} × ${h(o.cacheWrite).padEnd(11)} = ${st(p.usd5m)}`],w=N4(e,t),v=w===e.inputTokens?"input":"uncached";return[c,`${v.padEnd(9)}${d(w).padStart(14)} × ${h(o.input).padEnd(11)} = ${st(f.input)}`,`output ${d(e.outputTokens).padStart(14)} × ${h(o.output).padEnd(11)} = ${st(f.output)}`,`cache r ${d(e.cacheReadTokens).padStart(14)} × ${h(o.cacheRead).padEnd(11)} = ${st(f.cacheRead)}`,...m,"─────────────────────────────────────────",`total = ${st(f.total)}`].join(`
71
+ `)}function jE(e){const t=Pl(e),[n]=t;return t.length<=1?bE(n.usage,n.model):[...t.map(s=>bE(s.usage,s.model)),"═════════════════════════════════════════",`all models = ${st(Fn(e).total)}`].join(`
72
+ `)}function fV(e){if(!e.model)return null;const t=jr(e.model),n=Fn(e),s=Cl(e);if(!t&&n.total<=0&&s>0)return e.usage.inputTokens+e.usage.outputTokens<=0?null:{kind:"unpriced",tt:jE(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?kj(n.total,a):null,i=jE(e)+(o?`
73
+ burn: ${o}`:"");return{kind:"spent",total:n.total,floor:s>0,tt:i}}const pV=new Set(["untrusted","on-request","on-failure"]);function mV(e){return typeof e!="string"||!e?null:pV.has(e)?!0:e==="never"?!1:null}function T4(e){if(e.provider!=="codex"||e.kind!=="root"||e.waiting||e.state!=="active")return null;const t=mV(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 NE(e){return e[0].toUpperCase()+e.slice(1).toLowerCase()}function to(e){const t=yr(e).replace(/[-_]\d{8}(?!\d)/,""),n=t.match(/^claude[-_](opus|sonnet|haiku|fable|mythos)[-_](\d+(?:[-_.]\d+)*)/i);if(n){const a=NE(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(NE);return[`GPT-${a}`,...o].join(" ")}return e}function _p(e){const t=yr(e??""),n=t.match(/^claude[-_](opus|sonnet|haiku|fable|mythos)[-_]/i);return n?n[1].toLowerCase():/^gpt[-_]/i.test(t)?"gpt":""}function Cp(e,t){return t?`${to(e)} · ${t}`:to(e)}function Su(e,t){return t?`${e}
76
+ effort: ${t}`:e}function gV(e){return!e.model&&e.provider!=="codex"?0:e.model&&e.effort?2:1}function yV(e,t){return(t.overflowing||t.folderCut)&&e<t.max?e+1:e}function wV(e){return{kind:e<1,effort:e<2}}function In(e){return(e==null?void 0:e.kind)==="permission"||(e==null?void 0:e.kind)==="asked"}function P0(e){const t=[];for(const n of e)n.kind==="root"&&In(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 xV(e,t){if(e.length===0)return null;const n=e.findIndex(s=>s.id===t);return e[(n+1)%e.length]}function vV(e){const t=new Set;for(const n of e)n.state==="active"&&t.add(n.sessionId);return t.size}function Ep(e,t){return`${e}@${t.since}`}function A4(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 bV(e){const t=e.message||"Needs your permission",n=A4(e,t);return n?`${t}
77
+ Likely on: ${n}`:t}function kV(e,t,n,s=!0){if(!s)return[];if(n)return[];const a=[];for(const o of e){if(!In(o.waiting))continue;const i=Ep(o.id,o.waiting);t.has(i)||a.push({key:i,title:o.label,body:bV(o.waiting),sessionId:o.id})}return a}function jV(e,t,n){const s=new Set;for(const o of e)s.add(Ep(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 $h(e){return new Set(e.map(t=>Ep(t.id,t.waiting)))}function NV(e,t){return e!==t}function SV(e,t){return!e&&t!=null}function _V(e,t){return e!==null&&t!=null}function Nj(e){switch(e){case"login":return"login expired";case"usage-limit":return"usage limit";default:return"API error"}}function R4(e){return`Stopped · ${Nj(e.kind)}`}function M4(e){const t=Nj(e.kind);return t.charAt(0).toUpperCase()+t.slice(1)}function Sj(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 CV(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 EV(e){return e.message?`It said: “${e.message}”`:""}function TV(e,t=!1){return[CV(e),EV(e),Sj(e.kind,t)].filter(Boolean).join(`
78
+ `)}function AV(e,t=!1){return`${M4(e)}. ${Sj(e.kind,t)}`}function RV(e){return`Claude Code's StopFailure hook${e!=null&&e.message?`: “${e.message}”`:""}`}function MV(e,t=!1){const n=Sj(e.kind,t).replace(/\.$/,"");return`stopped, ${Nj(e.kind)} — ${n.charAt(0).toLowerCase()}${n.slice(1)}`}function Tp(e){return e.provider==="codex"&&e.parentId?"child session":e.kind==="root"?"session":"subagent"}function El(e){return e==="active"?"live":e==="done"?"done":"err"}function Tl(e){return e.message?e.message:e.kind==="permission"?"Needs your permission":"Waiting for your input"}function $V(e){return`${e} subagent${e===1?"":"s"} spawned`}function LV(e){const t=[Tp(e)];if(e.childCount>0&&t.push(`→ ${e.childCount}`),e.kind==="subagent"&&e.cwdBasename&&t.push(e.cwdBasename),e.model){const n=jj(e).length;t.push(`${to(e.model)}${n>0?` +${n}`:""}`)}else e.provider==="codex"&&t.push("Codex");return t.join(" · ")}function IV(e,t=Date.now(),n=!1){const s=e.toolErrorCount??0,a=Fn(e,t).total;return[e.label,Tp(e),e.kind==="root"&&e.stopFailure?MV(e.stopFailure,e.job!=null):El(e.state),In(e.waiting)?Tl(e.waiting):null,e.model?to(e.model):null,(()=>{const o=_r(e.plan);return o?u4(o):null})(),`${e.toolCount} ${e.toolCount===1?"tool":"tools"}`,s>0?`${s} failed`:null,a>0?`${st(a)}${Cl(e,t)>0?"+":""}`:null,n?"selected":null].filter(Boolean).join(", ")}function $4(e,t){const n=A4(e,t);return n?`Likely on: ${n}`:null}function Af(e){return e.kind==="idle"?"Your turn":Tl(e)}function wt(e){const t=Math.round(e);if(t<1e3)return`${t}`;if(t<1e6){const n=ou(t/1e3,1,1e3);if(n!==null)return`${n}k`}if(t<1e9){const n=ou(t/1e6,2,1e3);if(n!==null)return`${n}M`}return`${(t/1e9).toFixed(2)}B`}function Al(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 L4(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 Ap(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 SE=2e5,OV=1e6,PV=[/\[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],DV=[{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 FV(e){if(!e)return SE;const t=yr(e);for(const n of PV)if(n.test(t))return OV;for(const n of DV)if(n.match.test(t))return n.window;return SE}function I4(e,t){return typeof e=="number"&&e>0?e:FV(t)}const BV=1;function qV(){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 vn=qV(),O4=e=>e==="Escape";function UV(e){return e.overlayOpen?"dismiss":e.typing?"blur":"clear-selection"}function _E(e){return String(e.tagName??"").toUpperCase()==="BODY"}function CE(e,t){return!e||!e.isConnected||_E(e)?!1:t==null||_E(t)}const Rf="a[href], button, input, select, textarea, summary, [tabindex]";function P4(e){return!e||e.disabled||e.rendered===!1?!1:(e.tabIndex??0)>=0}function WV(e){if(!e||!e.overflowing||e.hasFocusable)return!1;const t=String(e.overflow??"").toLowerCase();return t==="auto"||t==="scroll"}function HV({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 zV(e){e.key!=="Escape"&&e.key!=="Tab"&&e.stopPropagation()}const VV=new Set(["button","checkbox","color","file","image","radio","range","reset","submit"]),GV=new Set(["INPUT","TEXTAREA","SELECT","OPTION","BUTTON","SUMMARY","A"]),KV=new Set(["button","checkbox","combobox","link","listbox","menu","menubar","menuitem","menuitemcheckbox","menuitemradio","option","radio","searchbox","slider","spinbutton","switch","tab","textbox","treeitem"]);function _j(e){return typeof e.tagName=="string"?e.tagName.toUpperCase():""}function YV(e){return _j(e)==="BUTTON"?!0:(typeof e.role=="string"?e.role.trim().toLowerCase():"").split(/\s+/).includes("button")}function Ho(e){if(!e)return!1;if(e.isContentEditable)return!0;const t=_j(e);return t==="TEXTAREA"?!0:t!=="INPUT"?!1:!VV.has(String(e.type??"text").toLowerCase())}function XV(e,t){if(!e)return!1;if(Ho(e))return!0;if(t!=null&&(t.length===1||t==="Delete")&&t!==" "&&e.pointerFocused&&YV(e))return!1;if(GV.has(_j(e)))return!0;const n=typeof e.role=="string"?e.role.trim().toLowerCase():"";return n!==""&&n.split(/\s+/).some(s=>KV.has(s))}function ZV({key:e,modalOpen:t,sheetOpen:n}){return t?!(e==="?"&&n):!1}function JV({key:e,sheetOpen:t,target:n}){return t&&e==="?"&&!Ho(n)}function af({appModal:e,dialogDepth:t}){return e||t>0}function D4(e){return e?Array.from(e.querySelectorAll("*")).filter(t=>{if(t.matches(Rf))return P4({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)&&WV({overflowing:n,overflow:getComputedStyle(t).overflowY,hasFocusable:t.querySelector(Rf)!=null}):!1}):[]}function QV(e,t){const n=D4(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 ft(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(()=>vn.push(f,a,i),[f,a,i]),y.useEffect(()=>{var m;const p=document.activeElement;return(m=(n==null?void 0:n.current)??D4(c.current)[0])==null||m.focus(),()=>{if(CE(p,document.activeElement)&&p.focus(),s&&document.activeElement===document.body){const w=s();CE(w,document.activeElement)&&w.focus()}}},[]),y.useEffect(()=>{const p=m=>{var j;if(m.key!=="Tab"||Rp(m))return;const w=c.current;if(!w)return;const v=document.activeElement;if(!(v!=null&&w.contains(v))&&!vn.isTop(f))return;const k=QV(w,v),N=HV({count:k.length,index:v?k.indexOf(v):-1,shiftKey:m.shiftKey});N.kind!=="allow"&&(m.preventDefault(),N.kind==="focus"&&((j=k[N.index])==null||j.focus()))};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[f]),c}function mt(e){const t=y.useRef(!1);return{onPointerDown:n=>{t.current=n.target===n.currentTarget},onPointerUp:n=>{n.target!==n.currentTarget&&(t.current=!1)},onClick:n=>{const s=t.current&&n.target===n.currentTarget;t.current=!1,s&&e()}}}function eG(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 ms(e){return e.toLocaleString()}const tG=60;function nG(e,t=tG){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 sG({agent:e,onClose:t}){var w;const n=y.useRef(null),s=ft(t,{focusRef:n}),a=mt(t),o=e.context,i=e.usage,c=(o==null?void 0:o.currentContextTokens)??0,d=I4(e.contextWindow,e.model),h=Math.min(100,c/d*100),f=Fn(e),p=e.provider==="codex"?i.inputTokens+i.outputTokens:i.inputTokens+i.outputTokens+i.cacheReadTokens+i.cacheCreateTokens,m=eG(e.provider);return r.jsx("div",{className:"modal-backdrop",...a,role:"presentation",children:r.jsxs("div",{ref:s,className:"modal ctx-modal",onClick:v=>v.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:[ms(c)," / ",ms(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(Us,{label:"input tokens",val:ms(i.inputTokens)}),r.jsx(Us,{label:"output tokens",val:ms(i.outputTokens)}),r.jsx(Us,{label:"cache reads",val:ms(i.cacheReadTokens)}),r.jsx(Us,{label:"cache writes",val:ms(i.cacheCreateTokens)}),r.jsx(Us,{label:"cumulative total",val:ms(p)}),r.jsx(Us,{label:"estimated cost",val:st(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(Us,{label:"user messages",val:ms((o==null?void 0:o.msgsUser)??0)}),r.jsx(Us,{label:"assistant messages",val:ms((o==null?void 0:o.msgsAssistant)??0)}),r.jsx(Us,{label:"tool uses",val:ms((o==null?void 0:o.toolUses)??0)}),r.jsx(Us,{label:"tool results",val:ms((o==null?void 0:o.toolResults)??0)}),r.jsx(Us,{label:"system-reminders",val:ms((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(v=>r.jsxs("li",{children:[r.jsx("span",{className:"ctx-md-path",title:v.path,children:nG(v.path)}),r.jsx("span",{className:"ctx-md-size",children:Zr(v.bytes)})]},v.path))})]})})}function Us({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 rG({currentContextTokens:e,modelId:t,contextWindow:n,size:s=26,onClick:a}){const o=I4(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 EE=new Map;function F4(e){let t=EE.get(e);return t||(t={now:Date.now(),listeners:new Set,timer:null},EE.set(e,t)),t}function aG(e,t){const n=F4(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 oG(e){return F4(e).now}const TE=new Map,AE=new Map;function Cr(e=1e3){let t=TE.get(e);t||(t=s=>aG(e,s),TE.set(e,t));let n=AE.get(e);return n||(n=()=>oG(e),AE.set(e,n)),y.useSyncExternalStore(t,n,n)}function iG(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 lG="1",RE="agent-dag.schema",cG=["agent-dag.layout","agent-dag.viewport"];function Ke(e){if(typeof window>"u")return null;try{return window.localStorage.getItem(e)}catch{return null}}function Ze(e,t){if(!(typeof window>"u"))try{window.localStorage.setItem(e,t)}catch{}}function Ys(e){if(!(typeof window>"u"))try{window.localStorage.removeItem(e)}catch{}}function wr(){if(typeof window>"u")return null;try{return window.localStorage}catch{return null}}function uG(e,t=lG){let n=null;try{n=e.getItem(RE)}catch{return[]}if(n===t)return[];const s=[];if(n!==null)for(const a of cG)try{e.getItem(a)!==null&&(e.removeItem(a),s.push(a))}catch{}try{e.setItem(RE,t)}catch{}return s}const B4="agent-dag.recapsDismissed",ME=200;function dG(){const e=Ke(B4);if(!e)return[];try{const t=JSON.parse(e);return Array.isArray(t)?t.filter(n=>typeof n=="string"):[]}catch{return[]}}let Rl=new Set(dG());const D0=new Set;let q4=0;function U4(e){return D0.add(e),()=>{D0.delete(e)}}function W4(e){Rl=e,q4++;const t=Array.from(e);Ze(B4,JSON.stringify(t.length>ME?t.slice(-ME):t));for(const n of D0)n()}function hG(e,t){return`${e}@${t}`}function fG(e){return Rl.has(e)}function pG(e){if(Rl.has(e))return;const t=new Set(Rl);t.add(e),W4(t)}function mG(e){const t=new Set(Rl);t.delete(e)||t.add(e),W4(t)}function gG(e){return y.useSyncExternalStore(U4,()=>e!=null&&Rl.has(e),()=>!1)}function Cj(e){return`recap:${e}`}function yG(e){return e.startsWith("recap:")}function wG(){return y.useSyncExternalStore(U4,()=>q4,()=>0)}function Dl(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 xG(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 vG(e){let t=null;for(const n of e.prompts)(!t||n.at>t.at)&&(t=n);return t}const $E=160;function bG(e){const t=kp(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>$E?s.slice(0,$E-1).trimEnd()+"…":s}function kG(e){const t=e.stopFailure;if(t)return{kind:"stopped",text:AV(t,e.job!=null),at:t.at,source:"stop",stop:t,key:`${e.sessionId}@stopped:${t.at}`};const n=vG(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?xG(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=bG(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 Ej(e){if(e.kind!=="root"||e.closedAt!=null)return null;const t=kG(e);if((t==null?void 0:t.kind)==="stopped")return t;const n=iG(e),s=n?{kind:"recap",text:n.text,at:n.at,source:"recap",key:hG(e.sessionId,n.at)}:null;return t&&s?s.at>t.at?s:t:t??s}function H4(e){const t=Ej(e);if(e.kind!=="root"||e.closedAt!=null)return null;const n=_r(e.plan),s=n?e.plan:null;return t?{note:t,plan:s,key:t.key}:s&&!n.allDone?{note:null,plan:s,key:`${e.sessionId}@plan`}:null}function Mp(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 RV(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 jG(e){const t=new Map,n=[...e],s=Np(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 z4(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 V4(e){return e.live>0?`→ ${e.total} · ${e.live} live`:`→ ${e.total} · done`}function NG(e,t,n){const s=e.kind==="root"?e.waiting:null;if(s&&In(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:R4(a),short:M4(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(e.state==="active"){const i=_r(e.plan);if(i&&i.current&&!i.allDone)return{tone:"muted",long:xj(i),short:`${i.done}/${i.total} done`}}if(t&&t.total>0)return{tone:"muted",long:z4(t),short:V4(t)};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 SG(e,t){return t?t.includes(e)?t:`${e}
80
+ ${t}`:e}function ml(e){return e.kind==="root"&&e.stopFailure&&e.state==="done"?"err":e.state}function F0(e){return e==="active"?"live":e==="done"?"done":"err"}const $p={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"}},_G=Object.fromEntries(Object.entries($p).map(([e,t])=>[e,t.category])),CG=Object.fromEntries(Object.entries($p).map(([e,t])=>[e,t.emoji])),EG=Object.fromEntries(Object.entries($p).map(([e,t])=>[e,t.label])),TG=new Set(Object.entries($p).filter(([,e])=>e.shell).map(([e])=>e)),AG={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",..._G};function G4(e){return e.startsWith("mcp__")?"mcp":Kt(AG,e)??"other"}const RG=/\btools\.exec_command\s*\(\s*\{[^{}]*?\bcmd\s*:\s*(["'`])((?:\\.|(?!\1)[^\\])*)\1/,MG=/\btools\.([A-Za-z_$][\w$]*)\s*\(/;function $G(e){if(typeof e!="string"||!e)return null;const t=RG.exec(e);if(t){const s=LG(t[2]);if(s.trim())return s}const n=MG.exec(e);return n?n[1]:null}function LG(e){return e.replace(/\\(["'`\\nrt])/g,(t,n)=>n==="n"?`
81
+ `:n==="r"?"\r":n==="t"?" ":n)}const IG={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:"📡",...CG};function LE(e){return e.startsWith("mcp__")?"🔌":Kt(IG,e)??"✨"}const OG={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 K4(e){return/^-(?:Command|c)$/i.test(e)||/^-[a-z]+c$/.test(e)}function Y4(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=>K4(o)||/^-(?:NoProfile|NonInteractive)$/i.test(o)))return Y4(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 PG(e){if(typeof e=="string")return e;if(!e||typeof e!="object")return null;const t=e;if(typeof t.script=="string"){const n=$G(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(K4);if(s>=0&&s+1<n.length)return n[s+1]}return n.join(" ")}return typeof t.script=="string"?t.script:null}const DG=new Set(["Bash","PowerShell",...TG]);function FG(e,t){if(!DG.has(e))return null;const n=PG(t);if(!n)return null;const s=Y4(n);return s?{emoji:Kt(OG,s)??"⚙️",label:s,category:"shell",detail:n}:null}const BG=new Set(["Read","Write","Edit","MultiEdit","NotebookEdit","LS","Glob","apply_patch"]),qG={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:"🗄️"},UG={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 WG(e){const n=e.replace(/\\/g,"/").replace(/\/+$/,""),s=n.lastIndexOf("/");return s>=0?n.slice(s+1):n}function HG(e){const t=e.toLowerCase(),n=Kt(UG,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(qG,t.slice(s+1));if(a!==void 0)return a}return"📄"}function zG(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 VG(e,t){if(!BG.has(e))return null;const n=zG(e,t);if(!n)return null;const s=WG(n);return s?{emoji:e==="LS"?"📂":HG(s),label:s,category:"file",detail:n}:null}const GG={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 Tj(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 KG(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 X4(e){return Kt(GG,e.toLowerCase())}function YG(e,t){const n=Tj(e);if(!n)return null;const{server:s,method:a}=n;if(!a)return null;const o=X4(s);return{emoji:(o==null?void 0:o.emoji)??"🔌",label:a,category:"mcp",detail:o?`${o.name} · ${a}`:`${s} · ${a}`}}function Z4(e,t){return FG(e,t)??VG(e,t)??YG(e)}function XG(e,t){var n;return((n=Z4(e,t))==null?void 0:n.label)??null}const ZG=EG,IE=18;function Lh(e){const t=[...e];return t.length<=IE?e:t.slice(0,IE-1).join("")+"…"}const my=13,JG=6;function QG(e,t){const n=[...e];if(n.length<=my)return e;const s=n.lastIndexOf("."),a=s>0?n.slice(s):[];return t==="file"&&a.length>1&&a.length<=JG?n.slice(0,my-1-a.length).join("")+"…"+a.join(""):n.slice(0,my-1).join("")+"…"}function Aj(e){const t=Tj(e);if(t){const s=X4(t.server);return s?{emoji:s.emoji,label:Lh(s.name)}:{emoji:"🔌",label:Lh(t.server),hue:KG(t.server)}}const n=Kt(ZG,e)??"";return n?{emoji:LE(e),label:Lh(n)}:{emoji:LE(e),label:Lh(e)}}function eK(e){let t=null,n="";for(const s of e){const a=Tj(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:Aj(n)}const B0=6e4,gl=24,OE=B0/gl,gy=132,of=14;function tK(e,t,n){const s=new Array(gl).fill(0);let a=0;const o=m=>{const w=n-m;if(w<0||w>=B0)return;const v=gl-1-Math.floor(w/OE);v>=0&&v<gl&&(s[v]+=1,a+=1)};for(const m of e)o(m.startedAt);for(const m of t??[])o(m);const c=Math.max(0,...s)/(OE/1e3),d=e.filter(m=>n-m.startedAt>=0&&n-m.startedAt<B0).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 nK=2;function sK(e){return e===0?1.5:Math.max(1.5,Math.min(1,e/nK)*of)}function J4({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 Rj(){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 Q4(){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 Mf({recap:e}){return e?r.jsx(Q4,{}):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 lo(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 no(e,t){return{disabled:e!=null&&e!==t,busy:e===t}}function Lp(e){return e==null}const q0="self";function On(e,t=!1){const n=no(e?q0:null,q0);return{disabled:t||n.disabled,"aria-busy":n.busy}}function bn(e){return Lp(e?q0:null)}const ti=400;function ni({armedFor:e,target:t,armedAt:n,now:s,gapMs:a}){return e!==t?"arm":s-n<a?"ignore":"fire"}function eP(e){return[...e==null?[]:[`#ap-more-${e}`],".accounts-panel .ap-refresh"]}function Bn(e){return e==null||e==="BODY"||e==="HTML"}const tP="Continue from where you left off.";function rK(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 nP(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 $f(e){return nP(Math.floor(e/1e3))}function Gu(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 aK(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function Lf(e,t,n){const s=new Date(e),a=$f(t-e);return{label:aK(s,new Date(t))?a:`${a} · ${s.toLocaleDateString(n,{month:"short",day:"numeric"})}`,title:s.toLocaleString(n,{dateStyle:"medium",timeStyle:"medium"})}}function Mj(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 oK(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 $j(e,t){const n=$f(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 If(e){if(!e.ok)return oK(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: “${tP}”${n}`}function sP({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 iK(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 lK(e,t){return[`claude stop ${e}`,`claude --resume ${t} --bg "${tP}"`].join(`
83
+ `)}let eo={answer:null,pressing:new Set,pressed:{}};const yy={current:new Set},U0=new Set;function W0(e){eo={...eo,...e};for(const t of U0)t()}const cK=e=>(U0.add(e),()=>{U0.delete(e)}),PE=()=>eo;function Lj(){return y.useSyncExternalStore(cK,PE,PE)}const uK=new Set(["login","usage-limit","api-error"]),Ij=e=>typeof e=="number"&&Number.isFinite(e)?e:null,rP=e=>typeof e=="string"?e:"";function dK(e){if(!e||typeof e!="object")return null;const t=e,n=Ij(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:rP(t.detail),stopped:t.stopped===!0}}function hK(e){if(!e||typeof e!="object")return null;const t=e;return{ok:t.ok===!0,at:Ij(t.at)??0,room:typeof t.room=="boolean"?t.room:null}}function fK(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&&uK.has(d.kind)&&Ij(d.at)!=null?{kind:d.kind,at:d.at}:null;s[o]={stop:h,held:c.held===!0,tried:c.tried===!0,last:dK(c.last)}}return{auto:n.auto===!0,login:t?hK(n.login):null,withLogin:t,sessions:s}}async function lf(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=fK(await s.json(),e);if(!a)return;const o=e?a.login:((t=eo.answer)==null?void 0:t.login)??null;W0({answer:{...a,login:o,withLogin:e||(((n=eo.answer)==null?void 0:n.withLogin)??!1)}})}catch{}}async function pK(e,t){if(!bn(yy.current.has(e)))return null;yy.current.add(e),W0({pressing:new Set([...eo.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"?Mj((o==null?void 0:o.gate)??null):rP(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}}yy.current.delete(e);const s=new Set(eo.pressing);return s.delete(e),W0({pressing:s,pressed:{...eo.pressed,[e]:n}}),lf(!0),n}const aP=30*6e4;function Oj(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:rK(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 mK=15e3,gK=2*6e4;function yK(e){for(const t of e.agents.values())if(t.kind==="root"&&t.stopFailure)return!0;return!1}function wK({stateRef:e,now:t,enabled:n}){const s=y.useRef(0);n&&yK(e.current)&&(s.current=t);const a=n&&s.current>0&&t-s.current<gK;y.useEffect(()=>{n&&lf(!1)},[n]),y.useEffect(()=>{if(!a)return;lf(!0);const o=window.setInterval(()=>{lf(!0)},mK);return()=>window.clearInterval(o)},[a])}function oP(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.":Mj(e.gate.reason):"Checking for a working login…",e.stop?sP({auto:e.auto,kind:e.stop.kind,held:e.held,tried:e.tried}):"",e.last&&e.stop&&e.last.at>=e.stop.at?`${$j(e.last,t)}. ${If(e.last)}`:""].filter(Boolean).join(`
84
+ `)}function iP(e,t){return y.useCallback(()=>{!(e!=null&&e.stop)||!e.gate.ready||e.pressing||pK(t,e.stop)},[e,t])}function xK({data:e}){const t=Lj(),n=Cr(15e3),s=Oj(e,t),a=iP(s,e.sessionId);return!(s!=null&&s.stop)||!s.background?null:r.jsx("button",{type:"button",className:"stop-continue",...On(s.pressing,!(s.loaded&&s.gate.ready)),title:oP(s,n),onClick:o=>{o.stopPropagation(),a()},children:s.pressing?"Continuing…":"Continue"})}function vK({data:e}){const t=Lj(),n=Cr(15e3),s=Oj(e,t);return!s||s.stop||!s.last||n-s.last.at>aP?null:r.jsxs("div",{className:`continued-row${s.last.ok?"":" failed"}`,title:If(s.last),children:[r.jsx("span",{className:"waiting-dot","aria-hidden":!0}),r.jsx("span",{className:"continued-said",children:$j(s.last,n)})]})}function bK({agent:e}){const t=Lj(),n=Cr(15e3),s=Oj(e,t),a=iP(s,e.sessionId),[o,i]=y.useState(null),c=y.useCallback(async(m,w)=>{await lo(w)&&(i(m),window.setTimeout(()=>i(v=>v===m?null:v),1600))},[]);if(!s)return null;const d=s.last&&(!s.stop||s.last.at>=s.stop.at)&&n-s.last.at<=aP?r.jsxs("p",{className:`detail-continue-last${s.last.ok?"":" failed"}`,title:If(s.last),children:[$j(s.last,n),". ",If(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.":Mj(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:iK(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=sP({auto:s.auto,kind:s.stop.kind,held:s.held,tried:s.tried}),p=s.jobId?lK(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",...On(s.pressing,!(s.loaded&&s.gate.ready)),title:oP(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 DE=typeof window>"u"?y.useEffect:y.useLayoutEffect;function kK({data:e}){var q,M;const t=ml(e),n=["agent-node",`state-${t}`,e.synthetic?"synthetic":""].filter(Boolean).join(" "),s=e.tools.filter(I=>!I.endedAt).length,a=e.toolErrorCount??0,o=ju(e.canvasSessionId??e.sessionId),i=((q=e.context)==null?void 0:q.currentContextTokens)??0,c=e.kind==="root"&&i>0,d=e.sessionTitle?e.cwd?`${e.cwd}
85
+ ${e.sessionTitle}`:e.sessionTitle:e.cwd,h=jj(e),f=y.useRef(null),p=y.useRef(null),m=gV(e),[w,v]=y.useState(0),[b,k]=y.useState(null);DE(()=>{v(0)},[e.effort,e.model,h.length,e.cwdBasename,e.childCount,e.kind,m,b]),DE(()=>{const I=f.current;if(!I||w>=m)return;const E=p.current,D=yV(w,{overflowing:I.scrollWidth>I.clientWidth,folderCut:!!E&&E.scrollWidth>E.clientWidth,max:m});D!==w&&v(D)}),y.useEffect(()=>{const I=f.current;if(!I||typeof ResizeObserver>"u")return;let E=I.clientWidth;const D=new ResizeObserver(()=>{I.clientWidth!==E&&(E=I.clientWidth,xt.flushSync(()=>k(E)))});return D.observe(I),()=>D.disconnect()},[]);const N=wV(w),j=e.model&&(h.length>0?`${Su(e.model,e.effort)}
86
+ spend on this card also covers:
87
+ ${h.join(`
88
+ `)}`:Su(e.model,e.effort)),S=Ap(e.sessionName,e.sessionTitle),_=H4(e),T=(_==null?void 0:_.note)??null,L=_?_.key:null,A=gG(L),P=_!=null&&!A,O=(T==null?void 0:T.kind)==="recap",U=fV(e);return r.jsxs("div",{className:n,style:{"--session-hue":o},children:[r.jsx("span",{className:"accent-stripe"}),r.jsx(Jo,{type:"target",position:De.Left,style:{background:"transparent",border:"none"}}),r.jsxs("div",{className:"head",children:[r.jsxs("div",{className:"title",children:[r.jsx(CK,{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:"?"}),_&&L&&r.jsx("button",{type:"button",className:"glyph-btn recap-pin","aria-label":O?"Claude Code's recap":T?`Session note: ${Dl(T.kind)}`:"Session note: plan","aria-expanded":P,title:O?P?"Hide the recap":"Show Claude Code's recap":T?P?"Hide this note":"Show what this session is doing":P?"Hide the plan":"Show the plan",onClick:I=>{I.stopPropagation(),mG(L)},children:r.jsx(Mf,{recap:O})})]}),r.jsx("div",{className:"head-right",children:c&&e.onOpenContext&&r.jsx(rG,{currentContextTokens:i,modelId:e.model,contextWindow:e.contextWindow,onClick:()=>e.onOpenContext(e.sessionId)})})]}),r.jsxs("div",{className:"sub",title:LV(e),children:[r.jsxs("span",{className:"sub-details",ref:f,children:[N.kind&&r.jsx("span",{children:Tp(e)}),e.childCount>0&&r.jsxs("span",{className:"spawn-badge",title:$V(e.childCount),children:["→ ",e.childCount]}),e.cwdBasename&&e.kind==="subagent"&&r.jsxs("span",{className:"sub-folder",ref:p,children:[N.kind?"· ":"",e.cwdBasename]}),e.model?r.jsxs("span",{className:"model-chip","data-family":_p(e.model),title:j,children:[Cp(e.model,N.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(_K,{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(EK,{data:e,stop:e.stopFailure}),e.kind==="root"&&!e.stopFailure&&r.jsx(vK,{data:e}),e.waiting&&!(e.stopFailure&&e.waiting.kind==="idle")&&r.jsx(TK,{waiting:e.waiting}),(()=>{const I=T4(e);return I?r.jsxs("div",{className:"approval-blind-row",title:I.detail,children:[r.jsx("span",{className:"approval-blind-dot","aria-hidden":!0}),r.jsx("span",{className:"approval-blind-said",children:I.label})]}):null})(),(()=>{const I=_r(e.plan);return I&&e.plan?r.jsx(NK,{plan:I,items:e.plan.items}):null})(),(e.tools.length>0||(((M=e.outputs)==null?void 0:M.length)??0)>0)&&r.jsx(AK,{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:wt(e.usage.inputTokens+e.usage.outputTokens)})," tok"]}),(U==null?void 0:U.kind)==="unpriced"&&r.jsx("span",{className:"cost-unpriced",title:U.tt,children:ia}),(U==null?void 0:U.kind)==="spent"&&r.jsx("span",{className:"cost-meta",title:U.tt,children:r.jsxs("b",{children:[st(U.total),U.floor?"+":""]})})]}),r.jsx(SK,{data:e,title:e.kind==="root"?S.face:void 0}),r.jsx(Jo,{type:"source",position:De.Right,style:{background:"transparent",border:"none"}})]})}const jK=y.memo(kK);function NK({plan:e,items:t}){return r.jsxs("div",{className:e.allDone?"plan-row plan-done":"plan-row",title:jp(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 SK({data:e,title:t}){const n=e.kind==="root"&&In(e.waiting),s=NG(e,e.branch,{sayWaiting:Af,describeCall:a=>({name:Aj(a.name).label,subject:XG(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(J4,{kind:F0(ml(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(Rj,{})]}),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 _K({start:e,end:t}){const n=Cr(1e3);return r.jsx(r.Fragment,{children:Al(e,t,n)})}function CK({state:e}){return r.jsx("span",{className:`state-pill state-${e}`,children:El(e)})}function EK({data:e,stop:t}){return r.jsxs("div",{className:"stop-row",title:TV(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:R4(t)}),r.jsx(xK,{data:e})]})}function TK({waiting:e}){const t=Cr(1e3),n=In(e),s=Tl(e);return r.jsxs("div",{className:n?"waiting-row permission":"waiting-row idle",title:`${s}
89
+ Blocked for ${Al(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:Al(e.since,void 0,t)})]})}function AK({tools:e,outputs:t}){const n=Cr(1e3),{counts:s,title:a}=tK(e,t,n),o=gy/gl;return r.jsxs("div",{className:"tool-spark-row",title:a,children:[r.jsx("svg",{className:"tool-spark",width:gy,height:of,viewBox:`0 0 ${gy} ${of}`,"aria-hidden":!0,children:s.map((i,c)=>{const d=sK(i),h=c===gl-1&&i>0,p=`tool-spark-bar${i>0?" active":""}${h?" latest":""}`;return r.jsx("rect",{x:c*o+.4,y:of-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 RK({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 Pj="agent-dag.single-key-shortcuts";function lP(e){return e!=="0"}function cP(e){return e.length===1}function uP(e,t){return!t&&cP(e)}function kn(e,t,n){return n?`${e} (${t})`:e}let zo=null;const Zc=new Set;function dP(){for(const e of Zc)e()}function H0(){return zo===null&&(zo=lP(Ke(Pj))),zo}function MK(e){zo!==e&&(zo=e,Ze(Pj,e?"1":"0"),dP())}function FE(e){if(e.key!==Pj)return;const t=lP(e.newValue);t!==zo&&(zo=t,dP())}function $K(e){var t;return Zc.add(e),Zc.size===1&&typeof window<"u"&&((t=window.addEventListener)==null||t.call(window,"storage",FE)),()=>{var n;Zc.delete(e),Zc.size===0&&typeof window<"u"&&((n=window.removeEventListener)==null||n.call(window,"storage",FE))}}function Of(e){const t=Math.max(0,Math.floor(e));return`${t} event${t===1?"":"s"}`}const BE=99;function LK(e){const t=Math.max(0,Math.floor(e));return t>BE?`${BE}+`:String(t)}const IK="Pause the canvas";function OK(e){const t=e.singleKeys??!0;if(!e.paused)return kn("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?kn(`The pause is full — ${Of(e.held)} held and ${n} older ${n===1?"one":"ones"} already dropped. Resume to follow the canvas again`,"Space",t):e.held<=0?kn("Nothing has arrived since you paused. Resume to follow the canvas again","Space",t):kn(`${Of(e.held)} arrived while paused and will be applied in order when you resume`,"Space",t)}function PK(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 hP="paused · full",DK=(e,t)=>t>0?hP:e>0?`paused · ${LK(e)}`:"paused";function FK(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:DK(e.held,t),widest:hP,title:kn(t>0?`Connected — the pause is full at ${Of(e.held)}; the oldest are being dropped as new ones arrive. Resume to catch up`:e.held>0?`Connected — ${Of(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 qn(){return y.useSyncExternalStore($K,H0,H0)}const BK=e=>e.transform[2]>=e.maxZoom,qK=e=>e.transform[2]<=e.minZoom;function UK({autoFitDisabled:e,enableAutoFitAndRefit:t,paused:n,pauseGate:s,togglePause:a,handleRelayout:o,requestClear:i,setKeyHelpOpen:c}){const d=Ll(),h=lt(BK),f=lt(qK),p=qn();return r.jsxs(kz,{showInteractive:!1,showFitView:!1,showZoom:!1,children:[r.jsx(gs,{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(gs,{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(gs,{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(gs,{"data-group-start":"",onClick:a,title:OK({paused:n,held:s.size,dropped:s.dropped,singleKeys:p}),"aria-label":IK,"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(gs,{onClick:o,title:kn("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(gs,{"data-group-start":"","data-danger":"",onClick:()=>i("button"),title:kn("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(gs,{"data-group-start":"",onClick:()=>c(m=>!m),title:p?kn("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 WK="modulepreload",HK=function(e){return"/"+e},qE={},Fl=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=HK(h),h in qE)return;qE[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":WK,f||(m.as="script"),m.crossOrigin="",m.href=h,d&&m.setAttribute("nonce",d),document.head.appendChild(m),f)return new Promise((w,v)=>{m.addEventListener("load",w),m.addEventListener("error",()=>v(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)})},UE="agent-dag.fm-custom-stations",WE="agent-dag.fm-muted",z0="custom:",zK=/^UC[A-Za-z0-9_-]{22}$/,VK=/^[A-Za-z0-9_-]{11}$/,fP=/^[A-Za-z0-9_-]{1,80}$/,GK=/\.(mp3|aac|ogg)$/i,KK=/\.m3u8$/i,YK=2048,pP=80;function Ml(e){return`${z0}${e}`}function Ip(e){if(!e.startsWith(z0))return null;const t=e.slice(z0.length);return fP.test(t)?t:null}function HE(e){return Ip(e)??e}function Dj(e){var i,c;const t=e.trim();if(t.length>YK)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&&zK.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(VK.test(f))return{kind:"youtube-video",url:s,video:f}}return null}return KK.test(n.pathname)?{kind:"direct-audio",url:s,format:"hls"}:GK.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 XK(e){return e==="1"}function ZK(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=Dj(c);if(!fP.test(o)||n.has(o)||!i||i.length>pP||!d)continue;n.add(o);const h=mP(a.radio);s.push({id:o,name:i,url:d.url,...h?{radio:h}:{}})}return s}function JK(e,t,n){const s=Ip(e??"");return s&&t.some(a=>a.id===s)?Ml(s):n(e)}function QK(e,t){return e===Ml(t)?"claude-fm":e}function mP(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 V0="https://www.youtube-nocookie.com";function eY(e,t,n){const s=new URLSearchParams({...n?{}:{channel:e},enablejsapi:"1",autoplay:"1",playsinline:"1",rel:"0",modestbranding:"1",origin:t});return`${V0}/embed/${n?encodeURIComponent(n):"live_stream"}?${s.toString()}`}function Vi(e,t=[]){return JSON.stringify({event:"command",func:e,args:t})}function tY(e="claude-fm"){return JSON.stringify({event:"listening",id:e,channel:"widget"})}const nY=[1],sY=[0,2],rY=[2,5,100,101,150,153];function aY(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:nY.includes(a)?{kind:"playing",playing:!0}:a===3?{kind:"buffering"}:sY.includes(a)?{kind:"playing",playing:!1}:null}return null}const Fc=new Set;let zE="";function VE(e){const t=new Date().toISOString().slice(0,10);if(t!==zE&&(Fc.clear(),zE=t),!Fc.has(e)){Fc.add(e);try{const n=typeof navigator>"u"?void 0:navigator;(!n||typeof n.sendBeacon!="function"||!n.sendBeacon("/api/feature",JSON.stringify({name:e})))&&Fc.delete(e)}catch{Fc.delete(e)}}}const GE=864e5,oY=6e4;function tn(e,t=!0){y.useEffect(()=>{if(!t)return;VE(e);let n;const s=()=>{n=setTimeout(()=>{VE(e),s()},GE-Date.now()%GE+oY)};return s(),()=>clearTimeout(n)},[e,t])}const iY={"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 lY({fetchImpl:e,enabled:t=!0,volume:n,muted:s,source:a,playRequest:o,customStation:i,onAvailabilityChange:c}){var I;const[d,h]=y.useState(null),[f,p]=y.useState(!1),[m,w]=y.useState(!1),[v,b]=y.useState(!1),[k,N]=y.useState(!1);tn("claude-fm",v);const j=y.useRef(o),S=y.useRef(null),_=y.useRef(null),T=y.useRef(void 0),L=y.useRef(null),A=y.useCallback(()=>{var D;clearTimeout(T.current),(D=_.current)==null||D.destroy(),_.current=null;const E=S.current;E&&(E.pause(),E.removeAttribute("src"),E.load(),S.current=null)},[]),P=y.useCallback(E=>{var D,B;(B=(D=L.current)==null?void 0:D.contentWindow)==null||B.postMessage(E,V0)},[]),O=y.useRef(n);O.current=n;const U=y.useRef(s);U.current=s;const q=y.useCallback((E,D,B)=>{A();const H=new Audio;H.preload="none",H.volume=O.current/100,H.muted=U.current,S.current=H,w(!0),b(!1),N(!1);let G=!1;const z=()=>S.current===H,F=()=>{clearTimeout(T.current),A(),w(!1),b(!1),N(!1)},$=()=>{z()&&(F(),p(!0),c==null||c(B,!0))},W=V=>{if(z()&&!(V instanceof DOMException&&V.name==="AbortError")){if(V instanceof DOMException&&V.name==="NotAllowedError"){F();return}$()}};T.current=setTimeout(()=>{z()&&!G&&$()},15e3),H.addEventListener("playing",()=>{z()&&(clearTimeout(T.current),G=!0,b(!0),N(!1),c==null||c(B,!1))});const Z=()=>{z()&&(b(!1),N(G),clearTimeout(T.current),T.current=setTimeout(()=>{z()&&$()},15e3))};H.addEventListener("waiting",Z),H.addEventListener("stalled",Z),H.addEventListener("ended",()=>{z()&&F()}),H.addEventListener("error",$,{once:!0}),D&&!H.canPlayType("application/vnd.apple.mpegurl")?Fl(async()=>{const{default:V}=await import("./hls-BFpXDghs.js");return{default:V}},[]).then(({default:V})=>{if(!z())return;if(!V.isSupported()){$();return}const Y=new V;_.current=Y,Y.on(V.Events.ERROR,(X,J)=>{J.fatal&&$()}),Y.on(V.Events.MEDIA_ATTACHED,()=>Y.loadSource(E)),Y.on(V.Events.MANIFEST_PARSED,()=>{H.play().catch(W)}),Y.attachMedia(H)},$):(H.src=E,H.play().catch(W))},[c,A]);y.useEffect(()=>{m&&(P(Vi("setVolume",[n])),P(Vi(s?"mute":"unMute")),S.current&&(S.current.volume=n/100,S.current.muted=s))},[n,s,m,P]),y.useEffect(()=>{var F;let E=!0;const D=e??fetch,B=j.current!==o;if(j.current=o,h(null),p(!1),N(!1),w(B),b(!1),A(),!t){w(!1),b(!1);return}const H=i&&Ml(i.id)===a?Dj(i.url):null;if(H){if(H.kind==="direct-audio"){const $=H.format==="hls"||((F=i==null?void 0:i.radio)==null?void 0:F.hls)===!0;return h({live:!0,channel:"",audio:H.url,hls:$}),c==null||c(a,!1),B&&q(H.url,$,a),()=>{E=!1}}return D(`/api/fm-station?url=${encodeURIComponent(H.url)}`).then($=>$.ok?$.json():null).then($=>{E&&($!=null&&$.channel||$!=null&&$.video?(h({live:!0,channel:$.channel??"",video:$.video??void 0}),c==null||c(a,!1)):(p(!0),w(!1),b(!1),N(!1),c==null||c(a,!0)))}).catch(()=>{E&&(p(!0),w(!1),b(!1),N(!1),c==null||c(a,!0))}),()=>{E=!1}}if(Ip(a))return p(!0),c==null||c(a,!0),()=>{E=!1};const G=a,z=iY[G];if(z)D(z).then($=>$.ok?$.json():null).then($=>{E&&($!=null&&$.video&&h({live:!0,channel:"",video:$.video}),$!=null&&$.video||(p(!0),w(!1),b(!1)),c==null||c(a,!($!=null&&$.video)))}).catch(()=>{E&&(p(!0),w(!1),b(!1),c==null||c(a,!0))});else if(G!=="claude-fm"){const $=G.replace("lofi-","");D(`/api/lofi-girl?station=${encodeURIComponent($)}`).then(W=>W.ok?W.json():null).then(W=>{E&&(W!=null&&W.video&&h({live:!0,channel:"",video:W.video}),W!=null&&W.video||(p(!0),w(!1),b(!1)),c==null||c(a,!(W!=null&&W.video)))}).catch(()=>{E&&(p(!0),w(!1),b(!1),c==null||c(a,!0))})}else D("/api/claude-fm").then($=>$.ok?$.json():null).then($=>{if(!E)return;const W=!!($!=null&&$.live&&($!=null&&$.channel));W&&h({live:!0,channel:$.channel}),W||(p(!0),w(!1),b(!1)),c==null||c(a,!W)}).catch(()=>{E&&(p(!0),w(!1),b(!1),c==null||c(a,!0))});return()=>{E=!1}},[i==null?void 0:i.id,i==null?void 0:i.url,(I=i==null?void 0:i.radio)==null?void 0:I.hls,t,e,c,o,a,q,A]),y.useEffect(()=>()=>A(),[A]),y.useEffect(()=>{if(!m||d!=null&&d.audio)return;let E;const D=()=>{clearTimeout(E),E=void 0,w(!1),b(!1),N(!1),p(!0),c==null||c(a,!0)},B=()=>{E??(E=setTimeout(D,15e3))};B();const H=G=>{var F;if(G.origin!==V0||G.source!==((F=L.current)==null?void 0:F.contentWindow))return;const z=aY(G.data);if(z){if(z.kind==="ready"){P(Vi("setVolume",[O.current])),P(Vi(U.current?"mute":"unMute")),P(Vi("playVideo"));return}if(z.kind==="blocked"){clearTimeout(E),E=void 0,w(!1),b(!1),N(!1);return}if(z.kind==="buffering"){b(!1),N(!0),B();return}if(z.kind==="playing"){clearTimeout(E),E=void 0,b(z.playing),N(!1),z.playing||w(!1);return}rY.includes(z.code)&&D()}};return window.addEventListener("message",H),()=>{clearTimeout(E),window.removeEventListener("message",H)}},[m,d==null?void 0:d.audio,o,c,P,a]);const M=y.useCallback(()=>{if(d){if(d.audio){if(m){A(),w(!1),b(!1),N(!1);return}q(d.audio,d.hls===!0,a);return}if(!m){w(!0),b(!1),N(!1);return}P(Vi("pauseVideo")),w(!1),b(!1),N(!1)}},[d,m,v,a,P,q,A]);return y.useMemo(()=>({probe:d,dead:f,armed:m,playing:v,buffering:k,frame:L,say:P,press:M}),[d,f,m,v,k,P,M])}const KE="agent-dag.radio-favorites",YE="agent-dag.radio-recent",XE="agent-dag.radio-catalogue";function cY(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"?Dj(s.url):null,c=mP(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 ZE(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 uY(e,t){return[t,...e.filter(n=>n!==t)].slice(0,50)}function $ke(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 Lke(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 gP(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 Ike(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 Oke(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 dY(){const[e,t]=y.useState(()=>ZE(Ke(KE))),[n,s]=y.useState(()=>ZE(Ke(YE))),[a,o]=y.useState(()=>{try{return cY(JSON.parse(Ke(XE)??"[]"))}catch{return[]}});y.useEffect(()=>{Ze(KE,JSON.stringify(e))},[e]),y.useEffect(()=>{Ze(YE,JSON.stringify(n))},[n]);const i=y.useCallback(h=>s(f=>uY(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),Ze(XE,JSON.stringify(h))},[]);return{favorites:e,recent:n,catalogue:a,remember:i,toggleFavorite:c,updateCatalogue:d}}function hY(e,t,n,s){const a=gP(e,t,n);if(!a)return()=>{};const o=setTimeout(()=>{n.add(t),s(a)},1e3);return()=>clearTimeout(o)}const Op=148,JE=6e3,fY=16e3,yP=46,Za=34;function pY(e,t,n=Op){let s=-Math.round(t()*n);if(Math.abs(s-e)<Za){const a=e-Za>=-n?-Za:Za;s=Math.max(-n,Math.min(0,Math.round(e+a)))}return{to:s,ms:Math.round(Math.abs(s-e)*yP)}}function mY(e){return Math.round(JE+e()*(fY-JE))}const QE=[{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 gY(e){const t=QE.reduce((s,a)=>s+a.weight,0);let n=e()*t;for(const s of QE)if(n-=s.weight,n<0)return s.kind;return"stroll"}const yY=720,wY=260,xY=620,vY=220,eT=520,wP=1600,tT=7e3,bY=15e3,nT=6e3,kY=14e3;function Gi(e,t,n=Op){let s=-Math.round(t()*n);if(Math.abs(s-e)<Za){const a=e-Za>=-n?-Za:Za;s=Math.max(-n,Math.min(0,Math.round(e+a)))}return s}const Yt=(e,t)=>Math.round(Math.abs(t-e)*yP),jY=120,Ih=0;function NY(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:yY},{x:Ih,prop:n({held:!0}),act:"carry",ms:Yt(t,Ih)},{x:Ih,prop:n({held:!0}),act:"windup",ms:wY},{x:Ih,prop:n({held:!0,leaving:!0}),act:"toss",ms:xY}]}function SY(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:vY,facing:n>0?"right":"left"},{x:s,prop:a({leaving:!0}),act:"kick",ms:eT,facing:n>0?"right":"left"},{x:s,prop:a({leaving:!0}),act:"stand",ms:wP-eT}]}const xP=640;function _Y(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 CY(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:xP*(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 EY(e,t,n){return[{x:t,prop:null,act:"walk",ms:Yt(e,t)},{x:t,prop:null,act:"sit",ms:Math.round(nT+n()*(kY-nT))},{x:t,prop:null,act:"stand",ms:400}]}function TY(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(tT+n()*(bY-tT))},{x:t,prop:s(),act:"scope-pack",ms:480},{x:t,prop:null,act:"stand",ms:240}]}function wy(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 AY=1500,RY=e=>Math.round(1e3*Math.sqrt(2*e/AY)),MY=115,$Y=e=>Math.round(e/MY*1e3),LY=620,IY=200,OY=760,PY=600,DY=240;function FY(e,t,n){const a=-(t.ledgeSpan??Op),o=RY(t.ledgeH),i=$Y(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:LY},{x:a,act:"fall",prop:null,ms:o,place:"floor"},{x:a,act:"land",prop:null,ms:IY,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:OY,place:"floor"},{x:a,act:"rope-throw",prop:null,ms:PY,place:"floor"},{x:a,act:"rope-catch",prop:null,ms:DY,place:"floor"},{x:a,act:"climb",prop:null,ms:i},{x:a,act:"pull-up",prop:null,ms:480}]}function BY(e,t,n){const s=(n==null?void 0:n.ledgeSpan)??Op;switch(gY(t)){case"tidy":return NY(e,Gi(e,t,s));case"kick":return SY(e,Gi(e,t,s));case"sit":return EY(e,Gi(e,t,s),t);case"watch":return TY(e,Gi(e,t,s),t);case"fish":return _Y(e,Gi(e,t,s),t);case"skip":return CY(e,Gi(e,t,s),t);case"leave":{if(!n||!(n.ledgeH>0)||!(n.floorSpan>0))break;return FY(e,n,t)}}const o=pY(e,t,s);return[{x:o.to,prop:null,act:"walk",ms:o.ms}]}const qY=420;function UY(e,t,n){const s=t==="right"?n-e-18:e-18;return(t==="right"?1:-1)*Math.min(qY,Math.max(0,s))}const WY=260,HY=200;function zY(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:WY},{...h,x:d,act:"walk",ms:Yt(c,d)},{x:d,prop:null,act:"dismount",ms:HY,place:"floor"},{x:t,prop:null,act:"walk",ms:Yt(d,t),place:"floor"}]}const vP=["bob","sway","groove"],sT=9e3,VY=16e3,bP=1e3,GY=.08;function KY(e,t){const n=vP.filter(o=>o!==e),s=n[Math.min(n.length-1,Math.floor(t()*n.length))],a=(t()*2-1)*GY;return{dance:s,beatMs:Math.round(bP*(1+a))}}function YY(e){return Math.round(sT+e()*(VY-sT))}const Fj=["......aaaaaa......","....aa......aa....","...a..bbbbbs..a...","...cpcbbbbbscpc...","...cpcbebbescpc...","...cpcbbbbbscpc...","...cpcbbbbbscpc...","....ccbbbbbscc....","....bbbbbbbbbs....","....bbbbbbbbbs....","......bbbbbs......","......bb..bs......","......bb..bs......","......bb..bs......"],rT=18,XY=Fj.length,kP="M6 9H4V1H5V0H7V-1H9V1H7V2H5V7H6V8H7V9Z",jP="M12 9H14V6H13V3H11V2H9V4H12Z",Bj=new Set(["a","c","p"]);function co(e=Fj){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 ZY=[".xx.","xxxx",".xx."],JY=["..xx..",".xsxx.","xssxxx","xxxxsx",".xxxx.","..xx.."],QY=["...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."],xy={litter:ZY,ball:JY,scope:QY},eX=["...hhhhhh...","...hhhhhh...","...kkkkkk...","hhhhhhhhhhhh"],tX=3,nX=-1,G0=11,aT=9;function oT(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 sX(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,v]=y.useState("ledge"),[b,k]=y.useState("left"),[N,j]=y.useState(0),S=y.useRef(null),[_,T]=y.useState(()=>document.hidden);y.useEffect(()=>{const M=new Set,I=()=>{var E;if(document.hidden){for(const D of((E=S.current)==null?void 0:E.getAnimations({subtree:!0}))??[])if(D.playState==="running"||D.pending){const B=D.currentTime;D.pause(),B!==null&&(D.currentTime=B),M.add(D)}}else{for(const D of M)D.playState==="paused"&&D.play();M.clear()}T(document.hidden)};return I(),document.addEventListener("visibilitychange",I),()=>document.removeEventListener("visibilitychange",I)},[e,t]);const[L,A]=y.useState(null),[P,O]=y.useState(bP),[U,q]=y.useState(()=>{var M;return((M=window.matchMedia)==null?void 0:M.call(window,"(prefers-reduced-motion: reduce)").matches)??!1});return y.useEffect(()=>{var E;const M=(E=window.matchMedia)==null?void 0:E.call(window,"(prefers-reduced-motion: reduce)");if(!M)return;const I=()=>q(M.matches);return I(),M.addEventListener("change",I),()=>M.removeEventListener("change",I)},[]),y.useEffect(()=>{var J;if(!e||t||U)return;const M=oT(document);let I=0;a(Q=>I=Q);let E=null,D=0,B=0;const H=Q=>{var re,fe;const[te,...ce]=Q;if(!te){E=null,d(null),f(null),V();return}d(te.act),f(te.prop),v(te.place??"ledge"),j(te.riser??0);const ue=I,ie=W(te);if(te.act==="kick"){const ae=(fe=(re=S.current)==null?void 0:re.querySelector('.fm-prop[data-prop="ball"]'))==null?void 0:fe.getBoundingClientRect();ae&&m({x:UY(ae.x,wy(te,ue,"left"),window.innerWidth),drop:Math.max(48,window.innerHeight-ae.y+24)})}B=te.act==="walk"?Math.max(Yt(ue,ie),jY):te.ms,te.act==="carry"&&(B=Yt(ue,ie)),i(B),k(ae=>wy({...te,x:ie},ue,ae)),a(ie),I=ie,E=te,D=Date.now(),M.schedule(()=>H(ce),B)},G=()=>{const Q=S.current,te=Q==null?void 0:Q.querySelector(".fm-sprite"),ce=Q==null?void 0:Q.parentElement;if(!Q||!te||!ce)return null;const ue=Q.getBoundingClientRect(),ie=ce.getBoundingClientRect(),re=ie.right-ue.right,fe=ie.width-re*2-te.offsetWidth;return fe>0?fe:null},z=()=>{const Q=S.current,te=Q==null?void 0:Q.querySelector(".fm-sprite");return!Q||!te?0:Math.max(0,Q.getBoundingClientRect().width-te.offsetWidth)},F=()=>{const Q=S.current,te=Q==null?void 0:Q.querySelector(".fm-walker"),ce=G();if(!Q||!te||ce==null)return;const ue=Q.getBoundingClientRect().bottom-te.getBoundingClientRect().bottom;if(ue>0)return{ledgeH:ue,floorSpan:ce,ledgeSpan:z()}},$=()=>{const Q=S.current,te=document.querySelector(".canvas-notices");if(!Q||!te)return null;const ce=Q.getBoundingClientRect(),ue=te.getBoundingClientRect();return ue.width<=0||ue.height<=0?null:{left:ue.left-ce.right,right:ue.right-ce.right,height:ue.height}},W=Q=>{const te=(Q.place??"ledge")==="floor",ce=te?G()??z():z(),ue=te&&Q.floorFrac!=null?-Math.round(Q.floorFrac*ce):Q.x;return Math.max(-ce,Math.min(0,ue))},Z=()=>{if(!E)return;const Q=W(E);Q!==I&&(i(Math.max(0,D+B-Date.now())),k(te=>wy({...E,x:Q},I,te)),a(Q),I=Q)},V=()=>{M.schedule(()=>{const Q=BY(I,Math.random,F()),te=Q.some(ie=>ie.place==="floor")?$():null;let ce=I;const ue=Q.flatMap(ie=>{const re=ce;if(ce=ie.x,!(ie.place==="floor"&&ie.act==="walk"))return[ie];const fe=zY(re,ie.x,te),ae=fe.length-1;return ie.floorFrac==null?fe:fe.map((je,me)=>me===ae?{...je,floorFrac:ie.floorFrac}:je)});H(ue)},mY(Math.random))},Y=(J=S.current)==null?void 0:J.parentElement,X=typeof ResizeObserver>"u"?null:new ResizeObserver(Z);return Y&&X&&X.observe(Y),V(),()=>{M.dispose(),X==null||X.disconnect(),v("ledge"),a(Q=>Math.max(-z(),Math.min(0,Q))),i(0),d(null),f(null),j(0)}},[e,t,U]),y.useEffect(()=>{if(!n||U){A(null);return}const M=oT(document),I=E=>{const D=KY(E,Math.random);A(D.dance),O(D.beatMs),M.schedule(()=>I(D.dance),YY(Math.random))};return I(null),()=>M.dispose()},[n,U]),{scene:S,suspended:_,x:s,walkMs:o,act:c,prop:h,ballFlight:p,place:w,facing:b,riser:N,dance:L,beatMs:P}}const vy={e:"fm-eye",s:"fm-shade",p:"fm-pad"},Pf=co().filter(e=>!Bj.has(e.cell)),rX=co().filter(e=>Bj.has(e.cell)),iT=Pf.filter(e=>e.cell==="e"),aX=co(eX),oX=Pf.filter(e=>e.y<G0&&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),iX={left:Pf.filter(e=>e.y>=G0&&e.x<aT),right:Pf.filter(e=>e.y>=G0&&e.x>=aT)},lX=y.memo(function({act:t,facing:n}){return r.jsxs("svg",{viewBox:`0 0 ${rT} ${XY}`,shapeRendering:"crispEdges","aria-hidden":!0,children:[r.jsx("g",{className:"fm-gear",children:r.jsx("g",{className:"fm-gear-motion",children:rX.map(s=>r.jsx("rect",{x:s.x,y:s.y,width:s.w,height:1,className:vy[s.cell]},`g${s.y}-${s.x}`))})}),r.jsxs("g",{className:"fm-body",children:[iT.map(s=>r.jsx("rect",{x:s.x,y:s.y,width:s.w,height:1,fill:"var(--accent)"},`eye-bed-${s.x}`)),oX.map(s=>r.jsx("rect",{x:s.x,y:s.y,width:s.w,height:1,className:vy[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"})]}),iT.map(s=>r.jsx("rect",{x:s.x-(s.x>=rT/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:aX.map(s=>r.jsx("rect",{x:tX+s.x,y:nX+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:kP}),r.jsx("path",{className:"fm-grip-right",d:jP})]}),(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:iX[s].map(a=>r.jsx("rect",{x:a.x,y:a.y,width:a.w,height:1,className:vy[a.cell]},`${s}${a.y}-${a.x}`))},s))]})}),cX=["...o........o.....","...of......fo.....","...owffffffwo.....","...offfffffso.....","...ofefffefso.....","....owwnwwso......",".....wwwww........",".....fwwwfs.......","....ffwwwffs...ww.","....ffwwwffs..wfs.","......fwwfssfffs..","......ff..fsffs...","......ff..fs......","......oo..oo......"],uX=[".....aaaaaaa......","...aa.......aa....","..a...........a...","..cp.........pc...","..cp.........pc...","..cp.........pc...","..c...........c..."],pr={f:"#d88735",s:"#a55b24",o:"#63351e",w:"#ffe2aa",n:"#372821"},dX={p:"fm-pad"},_u=co(cX),hX=co(uX);function K0(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 fX=K0(_u.filter(e=>e.y>=8),12,18),pX=_u.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),lT=_u.filter(e=>e.cell==="e"),mX={left:K0(_u.filter(e=>e.y>=11),0,9),right:K0(_u.filter(e=>e.y>=11),9,12)},gX=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:fX.map(i=>r.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,fill:pr[i.cell]},`t${i.y}-${i.x}`))}),r.jsx("g",{className:"fm-gear",children:r.jsx("g",{className:"fm-gear-motion",children:hX.map(i=>r.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,className:dX[i.cell]},`g${i.y}-${i.x}`))})}),r.jsxs("g",{className:"fm-body",children:[pX.map(i=>r.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,fill:pr[i.cell]},`b${i.y}-${i.x}`)),lT.map(i=>r.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,fill:pr.f},`bed${i.x}`)),r.jsxs("g",{className:"fm-arms",fill:pr.f,children:[r.jsx("rect",{x:4,y:8,width:2,height:2}),r.jsx("rect",{x:12,y:8,width:1,height:2})]}),lT.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:pr.n}},`e${i.x}`))]}),s&&r.jsxs("g",{className:"fm-grip",style:{fill:pr.f},children:[r.jsx("path",{className:"fm-grip-left",d:kP}),r.jsx("path",{className:"fm-grip-right",d:jP})]}),a&&r.jsxs("g",{className:"fm-crouch-legs",style:{fill:pr.f},children:[r.jsx("path",{d:"M6 11H8V13H6Z"}),r.jsx("path",{d:"M10 11H12V13H10Z"})]}),o&&r.jsxs("g",{className:"fm-seated-legs",style:{fill:pr.f},children:[r.jsx("path",{className:"fm-seated-far",style:{fill:pr.s},d:"M10 10H12V11H11V14H8V13H9V11H10Z"}),r.jsx("path",{d:"M6 10H9V11H7V15H4V14H5V11H6Z"})]}),["left","right"].map(i=>r.jsx("g",{className:"fm-leg","data-side":i,children:mX[i].map(c=>r.jsx("rect",{x:c.x,y:c.y,width:c.w,height:1,fill:pr[c.cell]},`${c.y}-${c.x}`))},i))]})}),yX=[".......dddd.......","......dhhhhd......",".....dhhhhhhd.....","....dhwwhhwwhd....","....dhwewwewhd....","....dhwwbbwwhd....","....dhwwwwwwhd....","....dhwwwwwwhd....","....dhwwwwwwhd....",".....dhwwwwhd.....",".....dhwwwwhd.....","......dhhhhd......","......bb..bb......",".....bbb..bbb....."],Gr={d:"#3b4855",h:"#657b8b",w:"#f4f0df",e:"#19242b",b:"#f0b44b",s:"#c88736"},wX={p:"fm-pad"},Df=co(yX),xX=co(Fj).filter(e=>Bj.has(e.cell)),cT=Df.filter(e=>e.cell==="e"),vX=Df.filter(e=>e.y<12&&e.cell!=="e"),bX={left:Df.filter(e=>e.y>=12&&e.x<9),right:Df.filter(e=>e.y>=12&&e.x>=9)},kX=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:xX.map(o=>r.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,className:wX[o.cell]},`g${o.y}-${o.x}`))})}),r.jsxs("g",{className:"fm-body",children:[vX.map(o=>r.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,fill:Gr[o.cell]},`b${o.y}-${o.x}`)),cT.map(o=>r.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,fill:Gr.w},`bed${o.x}`)),r.jsxs("g",{className:"fm-arms",fill:Gr.d,children:[r.jsx("path",{d:"M4 8H6V10H5V11H4Z"}),r.jsx("path",{d:"M12 8H14V11H13V10H12Z"})]}),cT.map(o=>r.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,className:"fm-eye",style:{fill:Gr.e}},`e${o.x}`))]}),n&&r.jsxs("g",{className:"fm-grip",style:{fill:Gr.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:Gr.b},children:[r.jsx("path",{d:"M5 12H8V13H5Z"}),r.jsx("path",{d:"M10 12H13V13H10Z"})]}),a&&r.jsxs("g",{className:"fm-seated-legs",style:{fill:Gr.b},children:[r.jsx("path",{className:"fm-seated-far",style:{fill:Gr.s},d:"M10 11H12V12H13V14H10V13H11V12H10Z"}),r.jsx("path",{d:"M6 11H8V12H7V13H8V14H4V13H5V12H6Z"})]}),["left","right"].map(o=>r.jsx("g",{className:"fm-leg","data-side":o,children:bX[o].map(i=>r.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,fill:Gr.b},`${i.y}-${i.x}`))},o))]})});function NP({character:e,act:t,facing:n}){return e==="penguin"?r.jsx(kX,{act:t,facing:n}):e==="fox"?r.jsx(gX,{act:t,facing:n}):r.jsx(lX,{act:t,facing:n})}const jX={"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 SP(e,t){return t&&Ml(t.id)===e?t.name:Ip(e)?"Custom FM":jX[e]}function by(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:co(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 uT={litter:by(xy.litter,"litter"),ball:by(xy.ball,"ball"),scope:by(xy.scope,"scope")};function NX(e){try{return new URL(e).host}catch{return"the station's server"}}const SX=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:v,ballFlight:b,place:k,facing:N,riser:j,dance:S,beatMs:_}=sX(o,i,c);if(!o||i)return null;const T=SP(n,s),L=o.audio?NX(o.audio):"YouTube";return r.jsxs("div",{ref:h,className:"fm","data-suspended":f?"":void 0,"data-place":k,style:{"--fm-beat":`${_}ms`},children:[v&&!v.held&&r.jsx("div",{className:"fm-prop","data-prop":v.kind,"data-leaving":v.leaving?"":void 0,style:{"--fm-prop-x":`${v.at}px`,"--fm-roll-to":`${b.x}px`,"--fm-ball-drop":`${b.drop}px`,"--fm-ball-flight-ms":`${wP}ms`,"--fm-ball-turn":N==="right"?"1080deg":"-1080deg"},children:uT[v.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":k,"data-facing":N,style:{"--fm-x":`${p}px`,"--fm-walk-ms":`${m}ms`,"--fm-riser":`${j}px`,"--fm-skip-beat":`${xP}ms`},children:[(v==null?void 0:v.held)&&r.jsx("div",{className:"fm-held","data-prop":v.kind,"data-toss":v.leaving?"":void 0,children:uT[v.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??vP[0]:void 0,onClick:d,title:c?`Stop ${T}`:`Play ${T} — streams from ${L}`,"aria-label":c?`Stop ${T}`:`Play ${T}`,children:r.jsx(NP,{character:a,act:w,facing:N})})]})]})});function _X({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:eY(n.channel,window.location.origin,n.video),onLoad:()=>o(tY()),allow:"autoplay; encrypted-media",sandbox:"allow-scripts allow-same-origin allow-presentation"})}):null}const CX={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 EX({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:CX[e]})})}function TX({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 AX({onClose:e}){const[t]=y.useState(()=>{var s;return((s=document.activeElement)==null?void 0:s.matches(":focus-visible"))??!1}),n=ft(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:zV,children:[r.jsx("button",{type:"button",className:"icon-btn","aria-label":"Close radio",onClick:e,children:r.jsx(EX,{name:"close"})}),r.jsx(TX,{opening:!0})]})}const RX=y.lazy(()=>Fl(()=>import("./RadioPanel-biw_BbZq.js"),[]));function MX({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=dY(),[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(P=>P.ok?P.json():null).then(P=>{A.signal.aborted||(i((P==null?void 0:P.enabled)===!0),d(P?"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=>Ml(A.id)===e.fmSource),v=w!=null&&w.radio?w:void 0,b=lY({volume:e.fmVolume,muted:e.fmMuted,source:e.fmSource,playRequest:e.fmPlayRequest,customStation:w,enabled:o,onAvailabilityChange:e.markFmStationAvailability}),k=SP(e.fmSource,w),N=o&&v&&b.dead&&e.fmPlayRequest>0?gP(f??h.catalogue,v.id,m.current):null,{remember:j}=h,S=(w==null?void 0:w.id)??e.fmSource;y.useEffect(()=>{b.playing&&j(S)},[S,b.playing,j]);const _=a,T=mt(a),L=y.useCallback((A,P=!1)=>{var M;if(!o)return;P||m.current.clear();const O=Ml(A.id),U=O===e.fmSource;if(U&&b.armed&&!b.dead){b.press();return}const q=U&&!!w&&(w.url!==A.url||((M=w.radio)==null?void 0:M.hls)!==A.radio.hls);e.addFmStation(A,!0),U&&!b.dead&&!q?b.press():e.pickFmSource(O,q),fetch(`/api/radio-click?id=${encodeURIComponent(A.id)}`).catch(()=>{})},[o,w,e.addFmStation,e.fmSource,e.pickFmSource,b.armed,b.dead,b.press]);return y.useEffect(()=>{b.playing&&!b.dead&&m.current.clear()},[b.playing,b.dead]),y.useEffect(()=>{if(!(!o||!v||!b.dead||e.fmPlayRequest===0))return hY(f??h.catalogue,v.id,m.current,A=>L(A,!0))},[o,v==null?void 0:v.id,b.dead,e.fmPlayRequest,f,h.catalogue,L]),r.jsxs(r.Fragment,{children:[t&&r.jsx(SX,{character:n,player:b,source:e.fmSource,customStation:w}),r.jsx(_X,{player:b,label:k}),s&&xt.createPortal(r.jsx("div",{className:"modal-backdrop radio-backdrop",...T,children:r.jsx(y.Suspense,{fallback:r.jsx(AX,{onClose:_}),children:r.jsx(RX,{fm:e,player:b,library:h,selected:v,label:k,enabled:o,disabledReason:c,autoNext:N==null?void 0:N.name,onPick:L,onQueueChange:p,onClose:_})})}),document.body)]})}function $X({data:e}){const t=Cr(3e4),n=e.note,s=e.plan??null,a=(n==null?void 0:n.kind)==="recap",o=Lf((n==null?void 0:n.at)??(s==null?void 0:s.at)??t,t),i=`${a?"recap-note":`recap-note is-status status-${(n==null?void 0:n.kind)??"plan"}`}${s?" has-plan":""}`,c=a||!n?void 0:Mp(n),d=_r(s),h=n?Dl(n.kind):`plan ${d?`${d.done}/${d.total}`:""}`.trim();return r.jsxs("div",{className:i,role:"note","aria-label":a?"Claude Code's recap":`Session note: ${h}`,"aria-description":c,style:{"--session-hue":e.hue},children:[r.jsxs("div",{className:"recap-note-head",title:c,children:[r.jsxs("span",{className:"recap-note-mark",children:[r.jsx(Mf,{recap:a}),h]}),r.jsx("span",{className:"recap-note-age",title:o.title,children:o.label}),r.jsx("button",{type:"button",className:"glyph-btn recap-note-close","aria-label":a?"Hide the recap":n?"Hide this note":"Hide the plan",title:"Hide — the mark on the card brings it back",onClick:f=>{f.stopPropagation(),pG(e.noteKey)},children:"×"})]}),n&&r.jsx("p",{className:"recap-note-text",title:SG(n.text,c),children:n.text}),(n==null?void 0:n.reply)&&r.jsxs("p",{className:"recap-note-reply",title:`suggested reply “${n.reply}”`,children:["suggested reply “",n.reply,"”"]}),s&&r.jsx(dT,{plan:s,head:n!=null}),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(Mf,{recap:a}),h]}),r.jsx("span",{className:"recap-face-age",children:o.label})]}),n&&r.jsx("p",{className:"recap-face-text",children:n.text}),s&&r.jsx(dT,{plan:s,head:n!=null,face:!0})]}),r.jsx(Jo,{type:"source",position:De.Right,style:{background:"transparent",border:"none"}})]})}const LX={completed:"done",in_progress:"now",pending:"to do"};function dT({plan:e,head:t,face:n=!1}){const s=_r(e);if(!s)return null;const a=f9(e.items);return r.jsxs("div",{className:n?"recap-face-plan":"recap-note-plan",title:n?void 0:jp(e.items),children:[t&&r.jsxs("div",{className:"recap-note-plan-head",children:["Plan ",r.jsxs("span",{className:"recap-note-plan-count",children:[s.done,"/",s.total,s.allDone?" · done":""]})]}),!s.allDone&&r.jsxs("ol",{className:"plan-list",children:[a.shown.map((o,i)=>r.jsxs("li",{className:"plan-item","data-status":o.status,children:[r.jsx("span",{className:"plan-mark","aria-hidden":!0}),!n&&r.jsxs("span",{className:"vis-hidden",children:[LX[o.status],": "]}),r.jsx("span",{className:"plan-text",children:o.status==="in_progress"&&o.active?o.active:o.text}),o.status==="in_progress"&&r.jsx("span",{className:"plan-now","aria-hidden":!0,children:"now"})]},o.id??`${i}:${o.text}`)),(a.before>0||a.after>0)&&r.jsx("li",{className:"recap-note-plan-more",children:[a.before>0?`${a.before} earlier`:null,a.after>0?`+${a.after} more`:null].filter(Boolean).join(" · ")})]})]})}function Ku(){var t;return typeof navigator>"u"?"":((t=navigator.userAgentData)==null?void 0:t.platform)||navigator.platform||""}function Yu(e){return/mac|iphone|ipad/i.test(e)}const Ff=e=>new Map([...e].map(([t,n])=>[t,{x:n.x,y:n.y}]));function IX(e,t,n){return{positions:Ff(e.positions),pinned:Ff(e.pinned),provisional:new Set(e.provisional),layoutSig:e.layoutSig.current,stored:{...t},viewport:n?{...n}:null}}function OX(e,t){t.positions.clear();for(const[n,s]of Ff(e.positions))t.positions.set(n,s);t.pinned.clear();for(const[n,s]of Ff(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 hT=7e3,PX=2e3,DX=140,FX="Layout re-arranged",BX="Layout re-arranged. Undo available.",fT="Layout restored.",qX={set:(e,t)=>setTimeout(e,t),clear:e=>clearTimeout(e),now:()=>Date.now()};function UX(e,t=qX){let n=null,s=null,a=0,o=hT;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=hT,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,PX),d())},get isOpen(){return n!==null},get snapshot(){return n}}}function WX(e){return(e.key==="z"||e.key==="Z")&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey}function HX(e){return Yu(e)?"⌘Z":"Ctrl+Z"}function zX({undo:e}){const{open:t,said:n,undo:s,dismiss:a,hold:o,release:i}=e,c=al(t,DX),d=y.useRef(null);return y.useEffect(()=>t?vn.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}),Xa(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:FX}),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:HX(Ku())})]})]})]})}function VX({sourceX:e,sourceY:t,targetX:n,targetY:s,sourcePosition:a,targetPosition:o,style:i}){const[c]=ij({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 Y0(e){return e.replace(/[^a-zA-Z0-9]/g,"")}function Bf(e,t){const n=Y0(e);return n?n.slice(-t):e.slice(-t)}function _P(e,t,n=4){const s=Y0(e);if(!s)return Bf(e,n);let a=n;for(const o of t){if(o===e)continue;const i=Y0(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 ol=" · ",GX=32,KX=/[\u1100-\u115F\u2E80-\u303E\u3041-\u33FF\u3400-\u4DBF\u4E00-\u9FFF\uA000-\uA4CF\uAC00-\uD7A3\uF900-\uFAFF\uFE30-\uFE6F\uFF00-\uFF60\uFFE0-\uFFE6]/;function pT(e){return KX.test(e)?2:1}function mT(e,t=GX){const n=[...e];let s=0;for(const i of n)s+=pT(i);if(s<=t)return e;const a=[];let o=0;for(const i of n){const c=pT(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 YX(e,t,n,s,a=[],{branch:o,plan:i,alarm:c=!1}={}){const d=(t==null?void 0:t.trim())??"",h=s?_P(n,a):void 0,f=[e,d||void 0,h].filter(Boolean),p=[e,i?`plan ${i}`:void 0,o,d||void 0,h].filter(Boolean).join(ol);return{label:mT(e),name:d?mT(d):void 0,shortId:h,fullLabel:f.join(ol),title:`${c?"waiting on you: ":""}${p}
90
+ Zoom to this session
91
+ drag the wrapper to move the whole session`}}const Bo=18,X0=26,qj=12,Cu=240,Uj=130,Z0=Bo*2+X0+qj,XX=72,yl=Z0+XX,cf=24,CP=70,EP=Bo*2+cf,qf=yl;function TP(e,t){var s;let n=Cu;for(const a of e)n=Math.max(n,((s=t.get(a.id))==null?void 0:s.width)??Cu);return n}const wl=420,uf=300,Uf=130,AP=160,RP=1;function ZX(e,t,n,s){return Math.min(RP,n/Math.max(1,e),s/Math.max(1,t))}function jn(e){const t=e.data;return(t==null?void 0:t.canvasSessionId)??(t==null?void 0:t.sessionId)??"_default"}function Pp(e,t=()=>!0){const n=new Map;for(const s of e){if(!t(s))continue;const a=jn(s),o=n.get(a);o?o.push(s):n.set(a,[s])}return n}function JX(e,t){return((t==null?void 0:t.get(e))??0)>0?wl:0}function QX(e,t){const n=(t==null?void 0:t.get(e))??0;return n>0?6+n*36:0}function Eu(e,t){const n=t.get(e);return{w:(n==null?void 0:n.width)??Cu,h:(n==null?void 0:n.height)??Uj}}function Xu(e,t,n){const s=Eu(e,t);return{w:s.w+JX(e,n),h:Math.max(s.h,QX(e,n))}}function eZ(e){return[...e.keys()].sort().map(t=>`${t}:${e.get(t)}`).join("|")}const tZ=240,MP=16;function $P(e,t){return(e+tZ)*(t||1)}function nZ(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 sZ(e,t,n,s){return{position:"absolute",left:e.x+MP,top:e.y-qj/(t||1),transform:`scale(${1/(t||1)})`,transformOrigin:"left top",maxWidth:s??$P(e.w,t),"--session-hue":n}}function rZ(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(jn(a)),p=o.canvasSessionId&&o.canvasSessionId!==o.sessionId?null:aZ(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,f.plan=p.plan,f.planLine=p.planLine)):t.set(jn(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,plan:p==null?void 0:p.plan,planLine:p==null?void 0:p.planLine})}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,...YX(o.label,o.name,a,c,i,{branch:o.branch,plan:o.planLine,alarm:o.alarm}),x:o.minX-Bo,y:o.minY-Bo-X0,w:o.maxX-o.minX+Bo*2,h:o.maxY-o.minY+Bo*2+X0,...o.alarm?{alarm:!0}:null,...o.branch?{branch:o.branch}:null,...o.plan?{plan:o.plan,planLine:o.planLine}:null})}return s}function aZ(e){if(e.kind!=="root")return null;const t=e.branch,n=_r(e.plan);return{label:e.label,name:Ap(e.sessionName,e.sessionTitle).face,alarm:In(e.waiting),branch:t&&t.total>0?V4(t):void 0,plan:n?`plan ${n.done}/${n.total}`:void 0,planLine:n?xj(n):void 0}}function oZ(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.plan!==a.plan||s.planLine!==a.planLine||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 iZ=20,Kr=4,lZ=64,cZ=".cat-filter-bar, .react-flow__panel, .autofit-chip, .rearrange-undo, .usage-panel, .sysdetail, .detail";function uZ(e,t,n,s){const a=t.zoom||1,o=$P(e.w,a);if(n.width<=0||n.height<=0)return{maxWidth:o,hidden:!1};const i=(e.x+MP)*a+t.x,c=e.y*a+t.y-qj,d=c+iZ;let h=Math.min(o,n.width-Kr-i),f=i<Kr||c<Kr||d>n.height-Kr;for(const p of s)if(!(p.top-Kr>=d||p.bottom+Kr<=c)&&!(p.right+Kr<=i)){if(p.left-Kr<=i){f=!0;break}h=Math.min(h,p.left-Kr-i)}return h<lZ&&(f=!0),{maxWidth:Math.max(0,h),hidden:f}}function dZ(e){const t=e.getBoundingClientRect(),n=[];for(const s of e.ownerDocument.querySelectorAll(cZ)){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 hZ(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 fZ=500;function LP({focus:e,setTimeout:t,clearTimeout:n,ms:s=fZ}){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 pZ(e){return rZ(e.nodeInternals.values())}const mZ=e=>e.width,gZ=e=>e.height,yZ=e=>{var t;return((t=e.domNode)==null?void 0:t.querySelector(".react-flow__viewport"))??null};function wZ({onFocusSession:e}){const{x:t,y:n,zoom:s}=B3(),a=lt(pZ,oZ),o=lt(mZ),i=lt(gZ),c={width:o,height:i},d=y.useRef(null),h=lt(yZ),[f,p]=y.useState([]);y.useLayoutEffect(()=>{var L;const S=(L=d.current)==null?void 0:L.parentElement;if(!S)return;const _=dZ(S),T=requestAnimationFrame(()=>{p(A=>hZ(A,_)?A:_)});return()=>cancelAnimationFrame(T)});const m=y.useRef(e);m.current=e;const[w]=y.useState(()=>LP({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 v=S=>{try{e==null||e(S)}catch{}},b=(S,_)=>{S.detail>0&&Hu()?w.hold(_):v(_)},k={transform:`translate(${t}px, ${n}px) scale(${s})`},N=r.jsx("div",{className:"session-clusters",style:k,ref:d,children:a.map(S=>{const _=ju(S.sessionId),T=nZ(S,_);return r.jsx("div",{className:"cluster-card",style:T,"aria-hidden":!0},S.sessionId)})}),j=h&&xt.createPortal(r.jsx("div",{className:"cluster-labels nopan",children:a.map(S=>{const _=ju(S.sessionId),T=uZ(S,{x:t,y:n,zoom:s},c,f),L=sZ(S,s,_,T.maxWidth);return r.jsxs("button",{type:"button",className:"cluster-label","data-alarm":S.alarm?"":void 0,"data-offpane":T.hidden?"":void 0,style:L,title:S.title,onClick:A=>b(A,S.sessionId),children:[S.alarm?r.jsxs(r.Fragment,{children:[r.jsx(Rj,{}),r.jsx("span",{className:"cluster-label-said",children:"waiting on you: "})]}):null,S.label,S.plan?r.jsx("span",{className:"cluster-label-plan",children:ol+S.plan}):null,S.branch?r.jsx("span",{className:"cluster-label-branch",children:ol+S.branch}):null,S.name?r.jsx("span",{className:"cluster-label-name",children:ol+S.name}):null,S.shortId?r.jsx("span",{className:"cluster-label-id",children:ol+S.shortId}):null]},S.sessionId)})}),h);return r.jsxs(r.Fragment,{children:[N,j]})}function xZ({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 IP=600,vZ=4,bZ=36,Wf=14,kZ=60,jZ=6,gT=220,NZ=96,SZ=28;function _Z(e,t){return Math.max(NZ,61+[...t].length*6.8)}function CZ(e){return e.endedAt==null?"inflight":e.ok===!1?"err":"done"}function EZ(e,t){if(t==null)return 1;const n=e-t;return n<0?1:Math.max(0,1-n/IP)}function TZ(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 AZ(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>IP)continue;const d=s.get(c.id)??n.get(c.id);if(!d)continue;const h=TZ(c.tools,vZ);if(h.length===0)continue;const f=c.exitAt??null,p=a.get(c.id),m=Math.max((p==null?void 0:p.width)??gT,gT),w=(p==null?void 0:p.height)??130,v=d.x,b=d.y,k=v+m,N=b+w/2;h.forEach((j,S)=>{const _=S*bZ,T=v+m+kZ,L=b+jZ+_,A=EZ(o,f),P=j.inputPreview??"",O=CZ(j),U=A<.999,q=Aj(j.name);i.push({id:`${c.id}::${j.id}`,toolId:j.id,agentId:c.id,toolName:j.name,name:q.label,emoji:q.emoji,status:O,category:G4(j.name),mcpHue:q.hue,inputPreview:P,fade:A,fading:U,worldX:T,worldY:L,anchorX:k,anchorY:N,spawnDx:k-T,spawnDy:N-(L+Wf)});const M=Z4(j.name,j.input);if(M){const I=_Z(j.name,q.label),E=T+I+SZ,D=L,B=T+I,H=L+Wf;i.push({id:`sub:${c.id}::${j.id}`,toolId:j.id,agentId:c.id,toolName:j.name,name:QG(M.label,M.category),fullName:M.label,emoji:M.emoji,isSub:!0,status:O,category:M.category,inputPreview:M.detail??P,fade:A,fading:U,worldX:E,worldY:D,anchorX:B,anchorY:H,spawnDx:B-E,spawnDy:0})}})}return i}function RZ({agents:e,visibleAgentIds:t,positions:n,pinned:s,measured:a,spotlight:o,hiddenCategories:i,now:c,onOpenTool:d}){const h=AZ(e,t,n,s,a,c),f=i&&i.size>0?h.filter(p=>!i.has(p.category)):h;return r.jsx(MZ,{bursts:f,spotlight:o,onOpenTool:d})}function MZ({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+Wf,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,v=d-f*.25,b=t!=null&&!t.has(o.agentId),k=o.fade*(b?.14:1);return r.jsx("path",{d:`M ${i} ${c} C ${m} ${w}, ${v} ${h}, ${d} ${h}`,className:`tool-conn status-${o.status}${o.fading?" fading":""}`,opacity:k,vectorEffect:"non-scaling-stroke"},`l:${o.id}`)}),a=e.map(o=>r.jsx(IZ,{b:o,dim:t!=null&&!t.has(o.agentId),onOpenTool:n},o.id));return r.jsx($Z,{connectors:s,bubbles:a})}function $Z({connectors:e,bubbles:t}){const{x:n,y:s,zoom:a}=B3();return r.jsxs("div",{className:"tool-bursts-layer","aria-hidden":!0,style:{"--tool-burst-height":`${2*Wf}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 LZ(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 IZ=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:"×"})]})})},LZ),OZ={width:140,height:105},PZ={agent:jK,sessionGroup:xZ,recapNote:$X},DZ={recapTie:VX},yT=400;function FZ({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:v,openTool:b,focusAgent:k,requestClear:N,setKeyHelpOpen:j}){const{allNodes:S,edges:_,visibleAgentIds:T,spotlightSet:L}=e,{positionsRef:A,pinnedRef:P,handleRelayout:O,rearrangeUndo:U}=t,{restoredViewport:q,onMoveStart:M,onMove:I}=n,{onNodeClick:E,onPaneClick:D,onNodeDoubleClick:B,onNodeMouseEnter:H,onNodeMouseLeave:G}=s,{onNodeDragStart:z,onNodeDrag:F,onNodeDragStop:$}=a,{palette:W,minimapNodeFill:Z,characterEnabled:V}=o,{autoFitDisabled:Y,enableAutoFitAndRefit:X}=h,{paused:J,pauseGate:Q,togglePause:te}=f;return r.jsxs(F3,{nodes:S,edges:_,nodeTypes:PZ,edgesFocusable:!1,edgeTypes:DZ,fitView:!q,fitViewOptions:{padding:.25,duration:$0({durationMs:yT,documentHidden:document.hidden})?yT:0},minZoom:z3,maxZoom:V3,panOnScroll:!0,panActivationKeyCode:null,nodesDraggable:!0,nodesConnectable:!1,selectionOnDrag:!1,nodeDragThreshold:5,disableKeyboardA11y:!0,deleteKeyCode:null,onNodeClick:E,onPaneClick:D,onNodeDoubleClick:B,onNodeMouseEnter:H,onNodeMouseLeave:G,onMoveStart:M,onMove:I,onNodeDragStart:(ce,ue,ie)=>{U.dismiss(),z(ce,ue,ie)},onNodeDrag:F,onNodeDragStop:$,children:[r.jsx(Ez,{gap:28,size:1,color:W["--grid-line"]}),r.jsx(wZ,{onFocusSession:k}),r.jsx(RZ,{agents:p.current.agents,visibleAgentIds:T,positions:A.current,pinned:P.current,measured:m.current,spotlight:L,hiddenCategories:w,now:v,onOpenTool:b}),r.jsxs("div",{className:"canvas-notices",children:[Y&&r.jsx(RK,{enableAutoFitAndRefit:X}),r.jsx(zX,{undo:U})]}),r.jsx(UK,{autoFitDisabled:Y,enableAutoFitAndRefit:X,paused:J,pauseGate:Q,togglePause:te,handleRelayout:O,requestClear:N,setKeyHelpOpen:j}),r.jsx(mz,{style:OZ,zoomable:!0,pannable:!0,nodeColor:Z,nodeStrokeWidth:2,maskColor:W["--minimap-mask"],maskStrokeColor:W["--line"]}),r.jsx(MX,{fm:i,character:o.character,characterEnabled:V,open:c,onClose:d})]})}function BZ(){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 qZ(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=Fn(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 UZ="spend on this board",WZ="on this board",OP=`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
+ `,HZ=OP+"Press H for the totals ccusage reads off the logs on disk, which do not forget.";function wT(e){return e?HZ:OP+"Usage history has the totals ccusage reads off the logs on disk, which do not forget."}const PP="session spend",J0="__unknown__",zZ=12;function VZ(e,t=Date.now()){const n=new Map;for(const s of e)for(const a of Pl(s)){const o=a.model??J0,i=Sp(a.usage,a.model,t),c=O0({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 GZ(e,t=Date.now()){const n=[...e],s=[];for(const a of n){if(a.kind!=="root")continue;let o=Fn(a,t).total,i=a.usage.inputTokens,c=a.usage.outputTokens,d=Cl(a,t),h=O0(a,t);for(const f of n)f.sessionId!==a.sessionId||f.kind==="root"||(o+=Fn(f,t).total,i+=f.usage.inputTokens,c+=f.usage.outputTokens,d+=Cl(f,t),h=h&&O0(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,zZ)}const KZ=600;function Dp(e,t){return!(e.exitAt!=null&&t-e.exitAt>KZ||e.kind==="root"&&e.state==="done"&&e.tools.length===0&&e.endedAt!=null&&e.endedAt-e.startedAt<3e3&&!e.stopFailure)}function YZ(e,t){const n=new Set;for(const s of e.agents.values())Dp(s,t)&&n.add(s.id);return n}function XZ(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 ZZ(e,t,n=0){if(!e)return!1;for(const s of t)if(XZ(e,s,n))return!0;return!1}function xT(e){return e.waiting?In(e.waiting)?0:1:e.state==="active"?2:3}function JZ(e,t){var s;const n=[];for(const a of e.agents.values()){if(a.kind!=="root")continue;let o=a.toolCount,i=Fn(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+=Fn(p).total;const m=p.endedAt??p.startedAt;m>c&&(c=m)}const d=Ej(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:ml(a),waiting:a.waiting,recap:h,status:f,modelId:a.model,effort:a.effort,plan:_r(a.plan),planTitle:jp(((s=a.plan)==null?void 0:s.items)??[]),toolCount:o,cost:i,startedAt:a.startedAt,lastActivity:c})}return n.sort((a,o)=>{const i=xT(a),c=xT(o);return i!==c?i-c:a.waiting&&o.waiting?a.waiting.since-o.waiting.since:o.lastActivity-a.lastActivity}),n}function QZ(e){return[e.text,e.reply?`Suggested reply: ${e.reply}`:"",Mp(e)].filter(Boolean).join(`
94
+ `)}function Hf(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 eJ({state:e,now:t,selectedIds:n,onSelect:s,onClose:a,removedIds:o,onBringBackAll:i,leaving:c=!1}){const d=qn(),h=y.useMemo(()=>JZ(e),[e,e.revision,t]),f=h.filter(m=>m.state==="active").length,p=h.filter(m=>In(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:kn("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 b;const w=n.has(m.sessionId),v=(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":""}${v?" removed":""}`,"aria-current":w?"true":void 0,onClick:()=>s(m.sessionId),title:v?`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:El(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}),v&&r.jsx("span",{className:"sl-removed",children:"off the board"}),m.modelId&&r.jsx("span",{className:"model-chip","data-family":_p(m.modelId),title:Su(m.modelId,m.effort),children:Cp(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:PP,children:r.jsx("b",{children:st(m.cost)})}),m.waiting?r.jsxs("span",{className:"sl-waiting",title:[Tl(m.waiting),$4(m.waiting,Tl(m.waiting)),`${In(m.waiting)?"Blocked":"Your turn"} since ${new Date(m.waiting.since).toLocaleTimeString()} · started ${new Date(m.startedAt).toLocaleString()}`].filter(Boolean).join(`
95
+ `),children:[In(m.waiting)?"waiting":"your turn"," ",Hf(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:Hf(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:u4(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(Q4,{}),m.recap.text]}),m.status&&r.jsxs("span",{className:`sl-status status-${m.status.kind}`,title:QZ(m.status),children:[r.jsx("span",{className:"sl-status-tag",children:Dl(m.status.kind)})," ",m.status.text]}),((b=m.status)==null?void 0:b.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 v=e.agents.get(w);v&&Dp(v,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 v=w.currentTarget.closest(".session-list");i(),requestAnimationFrame(()=>{var b;return(b=v==null?void 0:v.querySelector(".sl-row"))==null?void 0:b.focus()})},children:["Bring back ",m," removed ",m===1?"card":"cards"]})})})()]})}const Yn=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`:""}`},tJ=e=>e<1024?`${e} B`:e<1048576?`${(e/1024).toLocaleString(void 0,{maximumFractionDigits:1})} KB`:`${(e/1048576).toLocaleString(void 0,{maximumFractionDigits:1})} MB`,nJ=e=>new Date(e).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});async function zf(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 vT={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 Tu(e){if(Object.hasOwn(vT,e))return vT[e];const t=/^(npm|pnpm|yarn|bun) run (.+)$/.exec(e);if(t)return`Runs the “${t[2]}” script`;const n=DP(e);return n?`From the ${n.server} MCP server`:null}function DP(e){const t=/^mcp__(.+?)__(.+)$/.exec(e);return t?{server:t[1],tool:t[2]}:null}const Au=e=>{var t;return((t=DP(e))==null?void 0:t.tool)??e},sJ=[{id:"calls",label:"Most used"},{id:"time",label:"Most time"},{id:"slowest",label:"Slowest"},{id:"failed",label:"Failures"}];function Vf(e,t){return t==="calls"?e.calls:t==="time"?e.totalMs:t==="slowest"?e.medianMs:e.failed}const rJ=(e,t)=>{const n=t.trim().toLowerCase();return!n||e.operation.toLowerCase().includes(n)||(Tu(e.operation)??"").toLowerCase().includes(n)};function bT(e,t,n=""){return e.filter(s=>rJ(s,n)).sort((s,a)=>{const o=Vf(s,t),i=Vf(a,t);return o!==i?o===null?1:i===null?-1:i-o:a.calls-s.calls||s.operation.localeCompare(a.operation)})}const Wj=(e,t)=>{const n=e/t*100;return`${n>0&&n<1?"<1":Math.round(n)}%`},Fp=e=>e.failed>0&&e.completed>0?Wj(e.failed,e.completed):null;function aJ(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:`${Yn(a.totalMs)} over ${Pn(a.calls,"call")}, ${Wj(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 ${Pn(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 ${Yn(i.medianMs)} per call; the longest took ${Yn(i.maxMs)}.`}),n}const Pn=(e,t)=>`${e.toLocaleString()} ${t}${e===1?"":"s"}`,Ru={1:"24 hours",7:"7 days",30:"30 days",90:"90 days"},oJ={all:"your agents",claude:"Claude",codex:"Codex"};function iJ(e,t,n){return{lead:`In the last ${Ru[n]??`${n} days`}, ${oJ[t]} made`,calls:Pn(e.total,"tool call"),time:e.totalMs?Yn(e.totalMs):null,failed:e.failed,failedShare:e.failed&&e.completed?Wj(e.failed,e.completed):null}}const iu=e=>new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric"});function Mu(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 Bp(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 lJ({keyboard:e,onClose:t,children:n}){const s=y.useRef(null),a=ft(t,{focusRef:s}),o=mt(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]),xt.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 cJ({keyboard:e,itemKey:t,onClose:n,children:s}){const a=y.useRef(null),o=y.useRef(n);return o.current=n,y.useEffect(()=>vn.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 FP(e){return Bp("(max-width: 700px)")?r.jsx(lJ,{...e}):r.jsx(cJ,{...e})}const Ka=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString(void 0,{timeZone:"UTC",month:"short",day:"numeric"});function uJ(e,t){return e.status==="outside-history"?`${Ka(e.date)} · before recording started`:e.calls?`${Ka(e.date)} · ${Pn(e.calls,t)}${e.medianMs!=null?` · usually ${Yn(e.medianMs)}`:""}`:`${Ka(e.date)} · no ${t}s`}function BP({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 ${Ka(n[0].date)} to ${Ka(n.at(-1).date)}. The busiest day was ${Ka(c.date)} with ${Pn(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:Ka(n[0].date)}),r.jsx("span",{children:Ka(n.at(-1).date)})]}),r.jsx("p",{className:"ta-note ta-history-day","aria-live":"polite",children:uJ(i,t)})]})}function qP(){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 dJ={success:"Done",failed:"Failed",unmatched:"No result"},hJ=({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 fJ(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 pJ({row:e,details:t,loading:n,error:s,kind:a,setKind:o,onClose:i,onShowSkills:c}){const d=Tu(e.operation),h=(t==null?void 0:t[a])??[],f=Date.now(),p=Fp(e);return r.jsxs("section",{className:"ta-inspector","aria-label":`${Au(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:Au(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(qP,{})})]}),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:Yn(e.totalMs)})]}),r.jsxs("div",{children:[r.jsx("dt",{children:"Usually"}),r.jsx("dd",{children:Yn(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:[fJ(e),e.maxMs!==null&&e.measured>1&&r.jsxs(r.Fragment,{children:[" · longest ",Yn(e.maxMs)]}),e.unmatched>0&&r.jsxs(r.Fragment,{children:[" · ",Pn(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(BP,{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:Mu(m.capturedAt,f)}),r.jsx("span",{className:"ta-call-who",children:m.provider==="claude"?"Claude":"Codex"}),r.jsx("span",{className:"ta-call-took",children:Yn(m.durationMs)}),r.jsxs("span",{className:"ta-call-state",children:[r.jsx(hJ,{state:m.state}),dJ[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 Q0="agent-dag.text-size",e1="agent-dag.density",kT=["smallest","smaller","default","larger","largest"],jT=["tightest","tighter","compact","default","comfortable"],Hj={smallest:-2,smaller:-1,default:0,larger:2,largest:4};function zj(){var e,t;return Vj(typeof document>"u"?null:(t=(e=document.documentElement)==null?void 0:e.dataset)==null?void 0:t.textSize)}function Vj(e){return e==="smallest"||e==="smaller"||e==="larger"||e==="largest"?e:"default"}function UP(e){return e==="tightest"||e==="tighter"||e==="compact"||e==="comfortable"?e:"default"}const mJ=()=>Vj(Ke(Q0)),gJ=()=>UP(Ke(e1)),xr={min:320,standard:380,max:1600},yJ=420,wJ=8,WP="agent-dag.tool-activity.details-width";function Bc(e,t){const n=Math.max(xr.min,Math.min(xr.max,t-yJ-wJ));return Math.round(Math.min(n,Math.max(xr.min,Number.isFinite(e)?e:Gf())))}function Gf(){return xr.standard+12*Math.max(0,Hj[zj()])}function HP(){const e=Number(Ke(WP));return Number.isFinite(e)&&e>=xr.min&&e<=xr.max?Math.round(e):Gf()}function zP(e){Ze(WP,String(Math.round(e)))}function VP({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=Bc(e,o()),c=w=>{var v,b;(v=t.current)==null||v.style.setProperty("--ta-details-w",`${w}px`),(b=s.current)==null||b.setAttribute("aria-valuenow",String(w))},d=w=>{c(w),n(w)},h=w=>{var v;w.button===0&&(w.preventDefault(),w.currentTarget.setPointerCapture(w.pointerId),a.current={x:w.clientX,width:i,room:o(),last:i},(v=t.current)==null||v.setAttribute("data-resizing",""))},f=w=>{const v=a.current;v&&(v.last=Bc(v.width+v.x-w.clientX,v.room),c(v.last))},p=()=>{var v;const w=a.current;w&&(a.current=null,(v=t.current)==null||v.removeAttribute("data-resizing"),d(w.last))},m=w=>{const v=w.shiftKey?64:16,b=w.key==="ArrowLeft"?i+v:w.key==="ArrowRight"?i-v:w.key==="Home"?xr.min:w.key==="End"?xr.max:w.key==="Enter"?Gf():null;b!==null&&(w.preventDefault(),d(Bc(b,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":xr.min,"aria-valuemax":Bc(xr.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(Bc(Gf(),o())),onKeyDown:m})}const xJ=[{id:"uses",label:"Most used"},{id:"recent",label:"Latest"},{id:"name",label:"Name"}];function Kf(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 vJ(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"?Kf(a.name).short.localeCompare(Kf(o.name).short)||a.name.localeCompare(o.name):o.uses-a.uses||o.lastAt-a.lastAt||a.name.localeCompare(o.name))}const bJ={claude:"Claude",codex:"Codex"};function GP(e){const{claude:t,codex:n}=e.providers;return t&&n?"Claude and Codex":n?"Codex":"Claude"}function kJ(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 jJ={typed:"Typed",agent:"By the agent",detected:"Detected"},NJ=e=>bJ[e.provider],SJ={all:"your agents",claude:"Claude",codex:"Codex"};function _J(e,t,n){const s=e.rows.filter(a=>a.uses>0).length;return{lead:`In the last ${Ru[n]??`${n} days`}, ${SJ[t]} used`,skills:Pn(s,"skill"),uses:e.total===1?"once":`${e.total.toLocaleString()} times`,failed:e.failed,repeats:e.repeats}}const CJ=e=>e.countedSince>e.since;function EJ(e,t){return t==="codex"||!e.typedCommands||e.typedCommands==="on"?null:e.typedCommands==="off"?"Slash commands you type are not counted: the deck was started with AGENTS_DECK_SKILL_HOOK turned off.":"Slash commands you type are not counted yet: that needs Claude Code 2.1.116 or newer everywhere on this device. The deck’s start-up report says what it found."}function TJ({row:e,details:t,loading:n,error:s,onClose:a,sessionLabel:o,onOpenSession:i}){const{namespace:c,short:d}=Kf(e.name),h=Date.now(),f=kJ(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 ${GP(e)}`})]}),r.jsx("button",{type:"button",className:"glyph-btn","aria-label":"Close details",onClick:a,children:r.jsx(qP,{})})]}),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:Mu(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&&" · ",Pn(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(BP,{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:Pn(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 v=(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:Mu(w.at,h)}),r.jsxs("span",{className:"ta-call-who",children:[NJ(w)," · ",jJ[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}),v&&i?r.jsx("button",{type:"button",className:"sa-session",onClick:()=>i(w.session),title:"Show this session on the canvas",children:v}):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 NT=12,AJ=()=>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 RJ(e){return`${e.name}: ${Pn(e.uses,"use")}, last used ${Mu(e.lastAt)}${e.failed?`, ${e.failed.toLocaleString()} failed`:""}`}function MJ({filters:e,provider:t,period:n,setPeriod:s,refresh:a,onStatus:o,sessionLabel:i,onOpenSession:c}){tn("skill-activity");const[d,h]=y.useState("uses"),[f,p]=y.useState(""),[m,w]=y.useState(!1),[v,b]=y.useState(null),[k,N]=y.useState(!1),j=y.useRef(null),[S,_]=y.useState(null),[T,L]=y.useState(null),[A,P]=y.useState(!0),[O,U]=y.useState(!1),[q,M]=y.useState(""),[I,E]=y.useState(""),D=y.useRef(null),B=y.useRef(!1),H=y.useRef(null),G=y.useRef(null),z=Bp("(min-width: 960px)"),[F,$]=y.useState(HP),W=ae=>{$(ae),zP(ae)},Z=new URLSearchParams({view:"skills",provider:t,days:n}).toString(),V=y.useRef(o);V.current=o,y.useEffect(()=>{V.current({loading:A,detailLoading:O,capturedAt:(S==null?void 0:S.capturedAt)??null,hasData:!!S})},[A,O,S]),y.useEffect(()=>{const ae=new AbortController;let je=!0;const me=window.setTimeout(()=>ae.abort(),65e3);return M(""),D.current!==Z&&(_(null),L(null),w(!1)),B.current=!0,P(!0),(async()=>{try{const pe=await zf(Z,ae.signal);je&&(D.current=Z,_(pe),b(xe=>xe&&pe.rows.some(_e=>_e.name===xe)?xe:null))}catch(pe){je&&M(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(me),je&&(B.current=!1,P(!1))}})(),()=>{je=!1,ae.abort(),window.clearTimeout(me),B.current=!1}},[Z,a]),y.useEffect(()=>{if(L(pe=>(pe==null?void 0:pe.name)===v&&D.current===Z?pe:null),E(""),!v||!S||A||B.current){U(!1);return}let ae=!0;const je=new AbortController,me=window.setTimeout(()=>je.abort(),65e3);return U(!0),(async()=>{var pe;try{const xe=await zf(`${Z}&skill=${encodeURIComponent(v)}&history=1&timeZone=${encodeURIComponent(Intl.DateTimeFormat().resolvedOptions().timeZone)}`,je.signal);ae&&((pe=xe.details)!=null&&pe.row?L(xe.details):b(null))}catch{ae&&E("Could not read the uses of this skill. Close it and open it again to retry.")}finally{window.clearTimeout(me),ae&&U(!1)}})(),()=>{ae=!1,je.abort(),window.clearTimeout(me)}},[v,S,A,Z]);const Y=y.useMemo(()=>vJ((S==null?void 0:S.rows)??[],d,f),[S,d,f]),X=m||f?Y:Y.slice(0,NT),J=Y.reduce((ae,je)=>Math.max(ae,je.uses),0),Q=S==null?void 0:S.rows.find(ae=>ae.name===v),te=!!S&&S.failed>0,ce=ae=>je=>{j.current=je.currentTarget,N(je.detail===0),b(me=>me===ae?null:ae)},ue=()=>{const ae=v;b(null),requestAnimationFrame(()=>{var pe,xe;const je=j.current,me=Array.from(((pe=H.current)==null?void 0:pe.querySelectorAll(".ta-row[data-skill]"))??[]).find(_e=>_e.dataset.skill===ae);(xe=je!=null&&je.isConnected&&je.checkVisibility()?je:me)==null||xe.focus({preventScroll:!0})})},ie=S&&_J(S,t,n),re=S&&CJ(S),fe=S&&EJ(S,t);return r.jsxs("div",{className:"ta-workspace",ref:G,"data-inspecting":!!Q||void 0,style:{"--ta-details-w":`${F}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",{})]}),q&&r.jsx("div",{className:"ta-message",role:"alert",children:r.jsxs("p",{children:[S&&"Showing the last numbers. ",q]})}),S&&ie&&(S.total===0&&S.repeats===0?r.jsxs("div",{className:"ta-empty",children:[r.jsxs("h3",{children:["No skills used in the last ",Ru[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 ",iu(S.countedSince),". Sessions from before that are not imported. Use a skill and it shows up here."]}),fe&&r.jsx("p",{className:"sa-typed-note",children:fe}),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:[ie.lead," ",r.jsx("strong",{children:ie.skills}),S.total>0&&r.jsxs(r.Fragment,{children:[" ",r.jsx("strong",{children:ie.uses})]}),"."," ",ie.failed>0&&r.jsxs(r.Fragment,{children:[r.jsxs("strong",{className:"ta-bad",children:[ie.failed.toLocaleString()," failed"]}),". "]}),ie.repeats>0&&r.jsxs(r.Fragment,{children:[Pn(ie.repeats,"repeated run"),", such as ",r.jsx("code",{children:"/loop"})," ticks, ",ie.repeats===1?"is":"are"," left out."]})]}),re&&r.jsxs("p",{className:"ta-note sa-since",children:["Counting started ",iu(S.countedSince),", so the days before it are empty rather than unused."]}),fe&&r.jsx("p",{className:"ta-note sa-typed-note",children:fe}),(!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(AJ,{}),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:xJ.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":te||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"}),te&&r.jsx("span",{"data-col":"failed",children:"Failed"})]}),r.jsx("ul",{className:"ta-list sa-list",ref:H,"data-sort":d,"data-failures":te||void 0,children:X.map(ae=>{const{namespace:je,short:me}=Kf(ae.name);return r.jsx("li",{children:r.jsxs("button",{type:"button",className:"ta-row","data-skill":ae.name,"data-selected":v===ae.name||void 0,"aria-expanded":v===ae.name,"aria-controls":v===ae.name?"tool-operation-inspector":void 0,"aria-label":RJ(ae),onClick:ce(ae.name),children:[r.jsxs("span",{className:"ta-row-name",children:[r.jsxs("span",{className:"ta-op",children:[je&&r.jsx("span",{className:"sa-namespace",children:je}),me]}),r.jsxs("span",{className:"ta-desc",children:[GP(ae)," · ",Pn(ae.sessions,"session"),ae.repeats>0?` · ${Pn(ae.repeats,"repeat")}`:""]}),r.jsx("span",{className:"ta-bar","aria-hidden":"true",style:{"--ta-share":J&&d==="uses"?Math.max(.015,ae.uses/J):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 "}),Mu(ae.lastAt)]}),te&&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>NT&&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 reach the deck through Claude Code’s ",r.jsx("code",{children:"UserPromptExpansion"})," hook, which the deck adds when every Claude Code on this device is 2.1.116 or newer. Starting the deck with ",r.jsx("code",{children:"AGENTS_DECK_SKILL_HOOK=0"})," leaves it out, and then 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 ",iu(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."]})]})]})]}))]})}),Q&&z&&r.jsx(VP,{width:F,workspace:G,onCommit:W}),Q&&r.jsx(FP,{keyboard:k,itemKey:Q.name,onClose:ue,children:r.jsx(TJ,{row:(T==null?void 0:T.name)===v&&T.row?T.row:Q,details:(T==null?void 0:T.name)===v?T:null,loading:O,error:I,onClose:ue,sessionLabel:i,onOpenSession:c})})]})}const ST=12,$J=[{id:"all",label:"All agents"},{id:"claude",label:"Claude"},{id:"codex",label:"Codex"}],_T={tools:"Tool activity",skills:"Skill activity"},LJ={tools:"tool-activity",skills:"skill-activity"},IJ=()=>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"})}),OJ=()=>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"})]}),PJ={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 DJ(e){const t=e.failed?`${e.failed.toLocaleString()} failed (${Fp(e)})`:"none failed",n=e.totalMs===null?"not timed":`${Yn(e.totalMs)} in total, usually ${Yn(e.medianMs)}`;return`${Au(e.operation)}${Tu(e.operation)?`, ${Tu(e.operation)}`:""}: ${Pn(e.calls,"call")}, ${n}, ${t}`}function FJ({view:e="tools",onClose:t,sessionLabel:n,onOpenSession:s}){const[a,o]=y.useState(e),[i,c]=y.useState("all"),[d,h]=y.useState("7"),[f,p]=y.useState(0),[m,w]=y.useState({loading:!0,detailLoading:!1,capturedAt:null,hasData:!1}),[v,b]=y.useState("calls"),[k,N]=y.useState(""),j=y.useRef(v);j.current=v;const S=y.useRef(k);S.current=k;const[_,T]=y.useState(!1),[L,A]=y.useState(null),P=y.useRef(!1),[O,U]=y.useState(!1),q=y.useRef(L);q.current=L;const M=y.useRef(null),[I,E]=y.useState(null),[D,B]=y.useState(null),[H,G]=y.useState("recent"),[z,F]=y.useState(!0),[$,W]=y.useState(!1),[Z,V]=y.useState(""),[Y,X]=y.useState(""),[J,Q]=y.useState(0),te=y.useRef(!1),ce=y.useRef(null),ue=y.useRef(null),ie=y.useRef(null),re=Bp("(min-width: 960px)"),[fe,ae]=y.useState(HP),je=we=>{ae(we),zP(we)},[me]=y.useState(()=>document.activeElement instanceof HTMLElement?document.activeElement:null),pe=()=>{t(),requestAnimationFrame(()=>{var Ye;const we=me,Ge=Array.from(document.querySelectorAll(`[data-rail-item="${LJ[e]}"], [data-rail-item="more"]`)).find(Xe=>Xe.checkVisibility());(Ye=we&&we!==document.body&&we.isConnected&&we.checkVisibility()?we:Ge)==null||Ye.focus({preventScroll:!0})})},xe=ft(pe,{focusRef:ue}),_e=mt(pe),ye=new URLSearchParams({provider:i,days:d}).toString();y.useEffect(()=>{if(a!=="tools")return;const we=new AbortController;let Ge=!0;const Ye=window.setTimeout(()=>we.abort(),65e3);return V(""),ce.current!==ye&&(E(null),B(null),T(!1)),te.current=!0,F(!0),(async()=>{try{const Xe=await zf(ye,we.signal);if(Ge){ce.current=ye,E(Xe);const rt=!P.current&&bT(Xe.rows,j.current,S.current)[0];rt?(P.current=!0,A(rt.operation)):q.current&&!Xe.rows.some(jt=>jt.operation===q.current)&&A(null)}}catch(Xe){Ge&&V(Xe instanceof Error&&Xe.name!=="AbortError"?Xe.message:"Reading the history took too long. Try again, or keep less history in Settings.")}finally{window.clearTimeout(Ye),Ge&&(te.current=!1,F(!1))}})(),()=>{Ge=!1,we.abort(),window.clearTimeout(Ye),te.current=!1}},[ye,J,a]),y.useEffect(()=>{if(B(Xe=>(Xe==null?void 0:Xe.operation)===L&&ce.current===ye?Xe:null),X(""),!L||!I||z||te.current||a!=="tools"){W(!1);return}let we=!0;const Ge=new AbortController,Ye=window.setTimeout(()=>Ge.abort(),65e3);return W(!0),(async()=>{var Xe;try{const rt=await zf(`${ye}&operation=${encodeURIComponent(L)}&history=1&timeZone=${encodeURIComponent(Intl.DateTimeFormat().resolvedOptions().timeZone)}`,Ge.signal);we&&(((Xe=rt.details)==null?void 0:Xe.measurements)===null?A(null):B(rt.details))}catch{we&&X("Could not read the calls for this tool. Close it and open it again to retry.")}finally{window.clearTimeout(Ye),we&&W(!1)}})(),()=>{we=!1,Ge.abort(),window.clearTimeout(Ye)}},[L,I,z,ye,a]);const Ie=y.useMemo(()=>bT((I==null?void 0:I.rows)??[],v,k),[I,v,k]),Pe=y.useMemo(()=>I?aJ(I.rows,I.totalMs):[],[I]),Ue=_||k?Ie:Ie.slice(0,ST),$e=Ie.length?Vf(Ie[0],v)??0:0,Je=I==null?void 0:I.rows.find(we=>we.operation===L),Qe=we=>Ge=>{M.current=Ge.currentTarget,U(Ge.detail===0),G("recent"),A(Ye=>Ye===we?null:we)},ze=()=>{const we=L;A(null),requestAnimationFrame(()=>{var Xe,rt;const Ge=M.current,Ye=Array.from(((Xe=xe.current)==null?void 0:Xe.querySelectorAll(".ta-row[data-operation]"))??[]).find(jt=>jt.dataset.operation===we);(rt=Ge!=null&&Ge.isConnected&&Ge.checkVisibility()?Ge:Ye??ue.current)==null||rt.focus({preventScroll:!0})})},Ne=()=>{if(a==="skills"){!m.loading&&!m.detailLoading&&p(we=>we+1);return}te.current||$||(te.current=!0,Q(we=>we+1))},Ae=I&&iJ(I,i,d),qe=a==="skills"?m.loading:z,et=a==="skills"?m.hasData?m.capturedAt:null:(I==null?void 0:I.capturedAt)??null,ot=r.jsxs("div",{className:"ta-filters",children:[r.jsx("div",{className:"uh-range",role:"group","aria-label":"Period",children:Object.entries(Ru).map(([we,Ge])=>r.jsx("button",{type:"button",className:"uh-range-btn","aria-pressed":d===we,onClick:()=>h(we),children:Ge},we))}),r.jsx("div",{className:"uh-range",role:"group","aria-label":"Agent",children:$J.map(we=>r.jsx("button",{type:"button",className:"uh-range-btn","aria-pressed":i===we.id,onClick:()=>c(we.id),children:we.label},we.id))})]});return xt.createPortal(r.jsx("div",{className:"modal-backdrop",role:"presentation",..._e,children:r.jsxs("div",{className:"modal ta-report",ref:xe,role:"dialog","aria-modal":"true","aria-labelledby":"tool-audit-title","data-view":a,children:[r.jsxs("header",{className:"ta-report-header",children:[r.jsx("h2",{id:"tool-audit-title",children:_T[a]}),r.jsxs("div",{className:"ta-actions",children:[r.jsx("span",{className:"ta-freshness",role:"status",children:qe?et!==null?"Updating…":"Reading history…":et!==null?`Updated ${new Date(et).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"})}`:""}),r.jsx("button",{type:"button",className:"glyph-btn","aria-label":a==="skills"?"Refresh skill activity":"Refresh tool activity",title:"Refresh","data-loading":qe||void 0,"aria-busy":a==="skills"?m.loading||m.detailLoading:z||$,onClick:Ne,children:r.jsx(IJ,{})}),r.jsx("button",{type:"button",ref:ue,className:"glyph-btn",onClick:pe,"aria-label":`Close ${_T[a].toLowerCase()}`,title:"Close (Esc)",children:"×"})]})]}),r.jsx("div",{className:"ta-view-panel",children:a==="skills"?r.jsx(MJ,{filters:ot,provider:i,period:d,setPeriod:h,refresh:f,onStatus:w,sessionLabel:n,onOpenSession:s}):r.jsxs("div",{className:"ta-workspace",ref:ie,"data-inspecting":!!Je||void 0,style:{"--ta-details-w":`${fe}px`},children:[r.jsx("div",{className:"ta-body",children:r.jsxs("div",{className:"ta-report-content",children:[ot,z&&!I&&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",{})]}),Z&&r.jsxs("div",{className:"ta-message",role:"alert",children:[r.jsxs("p",{children:[I&&"Showing the last numbers. ",Z]}),r.jsx("button",{type:"button",className:"btn",onClick:Ne,children:"Try again"})]}),I&&Ae&&(I.total===0?r.jsxs("div",{className:"ta-empty",children:[r.jsxs("h3",{children:["No tool calls in the last ",Ru[d]]}),r.jsxs("p",{children:["ccdeck records each tool ",i==="all"?"Claude Code and Codex use":i==="claude"?"Claude Code uses":"Codex uses"," on this device, starting ",iu(I.startedAt),". Run a session and the calls show up here."]}),d!=="90"&&r.jsx("button",{type:"button",className:"btn",onClick:()=>h("90"),children:"Show the last 90 days"})]}):r.jsxs(r.Fragment,{children:[r.jsxs("p",{className:"ta-summary",children:[Ae.lead," ",r.jsx("strong",{children:Ae.calls}),Ae.time&&r.jsxs(r.Fragment,{children:[" and spent ",r.jsx("strong",{children:Ae.time})," running them"]}),"."," ",Ae.failed?r.jsxs(r.Fragment,{children:[r.jsxs("strong",{className:"ta-bad",children:[Ae.failed.toLocaleString()," failed"]})," (",Ae.failedShare,")."]}):"None failed."]}),(!I.storageOk||I.dropped>0||I.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.",!I.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":L===we.operation,"aria-controls":L===we.operation?"tool-operation-inspector":void 0,onClick:Qe(we.operation),children:[r.jsx("span",{className:"ta-highlight-glyph",children:PJ[we.kind]}),r.jsxs("span",{className:"ta-highlight-text",children:[r.jsxs("span",{children:[r.jsx("code",{children:Au(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:I.rows.length.toLocaleString()})]}),r.jsxs("label",{className:"ta-search",children:[r.jsx(OJ,{}),r.jsx("input",{type:"search","aria-label":"Find a tool or command",placeholder:"Find a tool or command",value:k,onChange:we=>N(we.target.value)})]})]}),r.jsx("div",{className:"uh-range ta-sorts",role:"group","aria-label":"Sort by",children:sJ.map(we=>r.jsx("button",{type:"button",className:"uh-range-btn","aria-pressed":v===we.id,onClick:()=>b(we.id),children:we.label},we.id))}),r.jsxs("div",{className:"ta-list-head","aria-hidden":"true","data-sort":v,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":v,children:Ue.map(we=>{const Ge=Vf(we,v),Ye=Tu(we.operation);return r.jsx("li",{children:r.jsxs("button",{type:"button",className:"ta-row","data-operation":we.operation,"data-selected":L===we.operation||void 0,"aria-expanded":L===we.operation,"aria-controls":L===we.operation?"tool-operation-inspector":void 0,"aria-label":DJ(we),onClick:Qe(we.operation),children:[r.jsxs("span",{className:"ta-row-name",children:[r.jsx("span",{className:"ta-op",children:Au(we.operation)}),Ye&&r.jsx("span",{className:"ta-desc",children:Ye}),r.jsx("span",{className:"ta-bar","aria-hidden":"true",style:{"--ta-share":$e&&Ge?Math.max(.015,Ge/$e):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:[Yn(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 "}),Yn(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)})}),!Ie.length&&r.jsxs("p",{className:"ta-note ta-no-match",children:["No tool or command matches “",k.trim(),"”."]}),!k&&!_&&Ie.length>ST&&r.jsxs("button",{type:"button",className:"btn ta-more",onClick:()=>T(!0),children:["Show all ",Ie.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 ",iu(I.startedAt)," and kept for ",I.retentionDays," days. Commands are grouped by name; their arguments and output are never saved. Change this in Settings."]})]})]})]}))]})}),Je&&re&&r.jsx(VP,{width:fe,workspace:ie,onCommit:je}),Je&&r.jsx(FP,{keyboard:O,itemKey:Je.operation,onClose:ze,children:r.jsx(pJ,{row:(D==null?void 0:D.operation)===L&&D.measurements?D.measurements:Je,details:(D==null?void 0:D.operation)===L?D:null,loading:$,error:Y,kind:H,setKind:G,onClose:ze,onShowSkills:Je.operation==="Skill"?()=>{A(null),o("skills")}:void 0})})]})})]})}),document.body)}const t1={cost:0,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0,unpricedTokens:0,sessions:0};function BJ(e){if(!e.synthetic)return!1;const t=e.usage;return t.inputTokens+t.outputTokens+t.cacheReadTokens+t.cacheCreateTokens<=0}function n1(e,t){const n=new Map;for(const s of e){if(s.kind!=="root"||!s.sessionId||BJ(s))continue;const a=Fn(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:Cl(s,t)})}return n}function qJ(e,t){if(!e)return t1;const n={...t1};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 s1(e,t=new Date){return new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate()-(e-1))).toISOString().slice(0,10).replace(/-/g,"")}const qp=[{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 UJ(e,t,n=qp.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 WJ(e,t=new Date){return e==="today"?s1(1,t):e==="month"?s1(t.getDate(),t):"20200101"}const wn=e=>typeof e=="number"&&Number.isFinite(e)?e:0,df=e=>typeof e=="string"?e:"";function Gj(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=df(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+=wn(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,wn(o.cost)))),c.inputTokens+=wn(o==null?void 0:o.inputTokens),c.outputTokens+=wn(o==null?void 0:o.outputTokens),c.cacheReadTokens+=wn(o==null?void 0:o.cacheReadTokens),c.cacheCreateTokens+=wn(o==null?void 0:o.cacheCreationTokens)}}return[...n.values()].sort((s,a)=>a.cost-s.cost||a.tokens-s.tokens)}const HJ=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function zJ(e){var t;return((t=HJ.exec(e))==null?void 0:t[0])??e}function VJ(e,t=new Map){const n=Array.isArray(e==null?void 0:e.sessions)?e.sessions:[],s=new Set(Gj(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=df(o==null?void 0:o.period);if(!i)continue;const c=zJ(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(df).filter(Boolean):[];a.push({sessionId:c,label:t.get(c)??null,agent:df(o==null?void 0:o.agent)||"claude",cost:wn(o==null?void 0:o.totalCost),priced:f.length>0&&f.every(p=>s.has(p)),tokens:wn(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 GJ(e,t=Kj(e).cost){const s=(Array.isArray(e==null?void 0:e.sessions)?e.sessions:[]).reduce((o,i)=>o+wn(i==null?void 0:i.totalCost),0),a=Math.max(.01,t*.01);return{sum:s,total:t,over:s>t+a}}function KJ(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 Kj(e){const t=e==null?void 0:e.totals;if(t&&typeof t=="object"){const d=wn(t.cacheReadTokens),h=wn(t.cacheCreationTokens),f=wn(t.inputTokens),p=wn(t.outputTokens);return{cost:wn(t.totalCost),inputTokens:f,outputTokens:p,cacheReadTokens:d,cacheCreateTokens:h,tokens:wn(t.totalTokens)||f+p+d+h}}const n=Gj(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 YJ(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 KP(e,t){var n;return((n=qp.find(s=>s.key===(e??t)))==null?void 0:n.noun)??"today"}function XJ(e,t,n){const s=e!=null,a=Kj(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 YP="agent-dag.usagePeriod";function ZJ(){const e=Ke(YP);return qp.some(t=>t.key===e)?e:"today"}function JJ(e){Ze(YP,e)}const XP="agent-dag.usageSessionsOpen";function QJ(){return Ke(XP)==="1"}function eQ(e){Ze(XP,e?"1":"0")}function Yj({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}: ${st(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 Oh="https://ccdeck.dev/guides",tQ={localNetwork:{href:`${Oh}/local-network/#film`,subject:"Local network"},claudeAccounts:{href:`${Oh}/claude-accounts/#film`,subject:"Claude accounts"},usage:{href:`${Oh}/cost-and-quota/#film`,subject:"cost and quota"},tour:{href:`${Oh}/first-run/#film`,subject:"first run"}};function $u({film:e,action:t=!1}){const{href:n,subject:s}=tQ[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",nQ="/brand/ccdeck-mark-gradient-small-optical.svg",sQ="/brand/ccdeck-mark-mono-dark-small-optical.svg",rQ={month:"short",day:"numeric",hour:"numeric",minute:"2-digit",hour12:!0};function ZP(e,t){const n=t.nextExpiryAt!=null?` · ${`expires ${new Date(t.nextExpiryAt).toLocaleString("en-US",rQ).replace(/\s+(AM|PM)/,(s,a)=>a.toLowerCase())}`.replace(/\s/g," ")}`:"";return`${t.availableCount} ${e}${t.availableCount!==1?"s":""} available${n}`}function JP(){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 Xj(){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 aQ({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(Xj,{})}),r.jsxs("span",{className:"vis-hidden",children:[", on ",t.host,", opens in a new tab"]})]},t.provider))})}function QP({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(Xj,{})}),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 oQ(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),v=Math.floor(p%3600/60);m.runsOutIn=w>0?`${w}h ${v}m`:`${v}m`}return m}return{label:`${Math.round(-d)}% under pace`,color:"var(--ok)",expectedPct:c,isDeficit:!1}}function Ya({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",v=m?2:h,b=s&&!c?Gu(s,i):null,k=d&&s&&a?oQ(h,s,a,i,o):null,[N,j]=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(${v/100})`,background:p,opacity:m?.4:1}}),k&&r.jsx("div",{className:"qb-pace-rail",style:{transform:`translateX(${k.expectedPct}%)`},children:r.jsx("div",{"aria-hidden":!0,className:"qb-pace-marker",style:{background:k.isDeficit?"var(--err)":"var(--ok)"},title:`To last until reset, stay near ${Math.round(k.expectedPct)}% by now`})})]}),r.jsxs("div",{className:"qb-reset-row",children:[c?r.jsx("span",{className:"qb-reset",children:"waiting for a new reading"}):b?r.jsxs("span",{className:"qb-reset",children:["resets in ",b]}):n?r.jsxs("span",{className:"qb-reset",children:["resets ",n]}):null,k&&r.jsxs("button",{type:"button",className:"qb-pace",style:{color:k.color},"aria-expanded":N,"aria-controls":N?S:void 0,onClick:()=>j(_=>!_),children:[r.jsx("i",{className:"qb-pace-key","aria-hidden":!0,style:{background:k.isDeficit?"var(--err)":"var(--ok)"}}),k.runsOutIn?`runs out in ${k.runsOutIn}`:k.label]})]}),N&&k&&r.jsxs("div",{id:S,className:"qb-why",children:["To last until reset, stay near ",Math.round(k.expectedPct),"% by now."]})]})}function eD(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 iQ(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 lQ(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 cQ(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 uQ({quota:e,quotaLoading:t,nowSec:n,incident:s}){const a=eD(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:iQ(e==null?void 0:e.source),children:[a,(e==null?void 0:e.stale)&&" · no newer reading"]})]}),r.jsx(QP,{incident:s}),e!=null&&e.ok?r.jsxs("div",{className:"up-quota-bars",children:[e.session5hPct!=null&&r.jsx(Ya,{label:"5-hour window",pct:e.session5hPct,reset:e.session5hReset,resetAt:e.session5hResetAt,windowSec:e.session5hWindowSec,nowSec:n}),r.jsx(Ya,{label:"7-day window",pct:e.week7dPct??null,reset:e.week7dReset,resetAt:e.week7dResetAt,windowSec:e.week7dWindowSec,nowSec:n}),e.weekSonnetPct!=null&&r.jsx(Ya,{label:"Sonnet (7d)",pct:e.weekSonnetPct,nowSec:n}),e.weekOpusPct!=null&&r.jsx(Ya,{label:"Opus (7d)",pct:e.weekOpusPct,nowSec:n}),e.extraEnabled&&e.extraUsedCredits!=null&&e.extraMonthlyLimit?r.jsx(Ya,{label:`Extra credits (month${e.extraCurrency?`, ${e.extraCurrency}`:""})`,pct:Math.min(100,Math.round(e.extraUsedCredits/e.extraMonthlyLimit*100)),nowSec:n}):e.extraEnabled&&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:ZP("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:lQ(e.reason)})]}):r.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]})}function dQ({codexQuota:e,codexLoading:t,nowSec:n,incident:s}){var o,i;const a=eD(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(QP,{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(Ya,{label:c.label,pct:c.pct,reset:c.reset??void 0,resetAt:c.resetAt??void 0,windowSec:c.windowSec??void 0,limitReached:e.limitReached&&c.pct>=100,nowSec:n},c.id)),(i=e.extraWindows)==null?void 0:i.map(c=>r.jsx(Ya,{label:c.label,pct:c.pct,reset:c.reset??void 0,resetAt:c.resetAt??void 0,windowSec:c.windowSec??void 0,nowSec:n},c.id)),e.creditLimit&&r.jsx(Ya,{label:`spend cap · $${Math.round(e.creditLimit.used)} of $${Math.round(e.creditLimit.limit)}`,pct:e.creditLimit.usedPct,reset:e.creditLimit.reset??void 0,resetAt:e.creditLimit.resetAt??void 0,limitReached:e.spendControlReached,nowSec:n}),e.creditsBalance&&!e.creditsUnlimited&&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:ZP("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:cQ(e.reason)})]}):r.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]})}function r1(e,t){return t&&e<=0?ia:st(e)+(t?"+":"")}const Pke="Some models have no known price. Tokens are counted; their cost is missing from the total.";function CT(e,t){if(e==null)return null;const n=Math.min(Math.max(0,e),Math.max(0,t));return`Recorded in logs: ${st(n)} · other reported cost: ${st(Math.max(0,t-n))}. Both are included in the total; recorded costs are not a verified bill.`}function hQ({fromRange:e,rangeModelRows:t,boardModelRows:n}){const s=t.filter(o=>o.storedCost!==void 0),a=e?CT(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,CT(o.storedCost,o.cost)].filter(Boolean).join(`
97
+ `),children:to(o.model)}),r.jsx("td",{className:"up-num",children:wt(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:r1(o.cost,!0)}):r.jsx("td",{className:"up-num up-cost-val",children:r1(o.cost)})]},o.model)):n.map(o=>r.jsxs("tr",{children:[r.jsx("td",{className:"up-model-name",title:o.model===J0?"no model reported yet":o.model,children:o.model===J0?"unknown":to(o.model)}),r.jsx("td",{className:"up-num",children:wt(o.inputTokens+o.outputTokens)}),o.priced?r.jsx("td",{className:"up-num up-cost-val",children:st(o.cost.total)}):r.jsx("td",{className:"up-num up-unpriced",children:ia})]},o.model))})]}),a&&r.jsx("p",{className:"uh-cost-note",children:a})]})}function fQ({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=UJ(a.key,o);i!==null&&(a.preventDefault(),(c=s.current[i])==null||c.focus())},children:qp.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 ${KP(e,e)}…`:""})]})}function pQ(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 mQ(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 ET({sessionId:e,agent:t,label:n,onOpen:s,children:a}){return s&&pQ(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 gQ({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:KJ(i,c,st),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(ET,{sessionId:p.sessionId,agent:p.agent,label:p.label??Bf(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:El(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??Bf(p.sessionId,8)}),r.jsx("span",{className:"up-session-tokens",children:wt(p.tokens)}),p.cost>0||p.priced?r.jsx("span",{className:"up-session-cost",title:p.models.join(", ")||void 0,children:st(p.cost)}):r.jsx("span",{className:"up-session-cost up-unpriced",children:ia})]},`${p.agent}:${p.sessionId}`)}),!e&&n.map(p=>r.jsxs(ET,{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:El(p.state)}),r.jsx("span",{className:"up-session-label",children:p.label}),r.jsx("span",{className:"up-session-tokens",children:wt(p.inputTokens+p.outputTokens)}),p.cost>0||p.priced?r.jsxs("span",{className:"up-session-cost",title:p.unpricedTokens>0?`${wt(p.unpricedTokens)} tokens in this session are on an unpriced model, so this is a floor`:void 0,children:[st(p.cost),p.unpricedTokens>0?"+":""]}):r.jsx("span",{className:"up-session-cost up-unpriced",children:ia})]},p.sessionId))]})]})}function yQ(e){return e.claude&&e.codex?"Claude Code and Codex":e.claude?"Claude Code":e.codex?"Codex":null}const wQ={claude:"Claude Code",codex:"Codex",opencode:"OpenCode",openclaw:"OpenClaw",copilot:"GitHub Copilot",pi:"pi-agent",zcode:"ZCode"};function tD(e){const t=e.toLowerCase(),n=Kt(wQ,t);return n!==void 0?n:t?t[0].toUpperCase()+t.slice(1):""}function xQ(e){return e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function Dke(e,t=[]){const n=t.length?xQ(t.map(tD)):yQ(e);return n?`via ccusage · local ${n} logs`:"via ccusage · local agent logs"}function vQ(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 bQ(){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 Ph=e=>e.toLocaleString(),TT=e=>new Date(e).toLocaleString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"});function kQ({session:e,onClose:t}){var k,N;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=ft(t,{focusRef:h}),p=mt(t),m=i!=null&&i.ok&&((k=i.detail)==null?void 0:k.speed)===n?i.detail:void 0;y.useEffect(()=>{const j=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:j.signal}).then(async _=>{const T=await _.json();j.signal.aborted||c(T)}).catch(()=>{j.signal.aborted||c({ok:!1})}),()=>j.abort()},[e.agent,e.sessionId,n,a]);const w=(m==null?void 0:m.models.filter(j=>j.missingPricing))??[],v=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)"}]:[],b=v.reduce((j,S)=>j+S.n,0);return xt.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(j=>j+1),disabled:!i,"aria-label":"Refresh session usage",title:"Refresh session usage",children:r.jsx(JP,{})}),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:tD(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:j=>{c(null),s(j.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(bQ,{}),i&&!i.ok&&r.jsxs("p",{className:"su-message",role:"status",title:i.error,children:[mQ(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?st(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:Ph(m.totalTokens),children:wt(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:((N=m.cacheReuse)==null?void 0:N.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"})]}),b>0&&r.jsx("div",{className:"su-composition","aria-hidden":"true",children:v.filter(j=>j.n>0).map(j=>r.jsx("span",{style:{width:`${j.n/b*100}%`,background:j.color}},j.name))}),r.jsx("dl",{className:"su-tokens",children:v.map(({name:j,n:S,color:_})=>r.jsxs("div",{children:[r.jsxs("dt",{children:[r.jsx("span",{className:"su-key",style:{background:_},"aria-hidden":"true"}),j]}),r.jsxs("dd",{title:Ph(S),children:[wt(S),r.jsx("span",{className:"su-share",children:b>0?`${(S/b*100).toLocaleString(void 0,{maximumFractionDigits:1})}%`:"—"})]})]},j))}),m.reasoningOutputTokens>0&&r.jsxs("p",{className:"su-note su-reasoning",children:[wt(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(j=>r.jsxs("tr",{children:[r.jsxs("th",{scope:"row",title:j.model,children:[to(j.model),j.missingPricing&&r.jsx("span",{className:"su-unpriced",children:" · not priced"})]}),r.jsx("td",{title:Ph(j.totalTokens),children:wt(j.totalTokens)})]},j.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:TT(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:TT(m.lastActivity)})})]}),m.entries!=null&&r.jsxs("div",{children:[r.jsx("dt",{children:"Usage records"}),r.jsx("dd",{children:Ph(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 Dh=e=>`${e.id}:${e.windowSec}:${e.resetAt}`;function jQ(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 NQ(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 Zj({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 xl=e=>new Date(e).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}),AT=e=>new Date(e).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"});function SQ({series:e}){const t=jQ(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:[xl(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?xl(n):AT(n)}),r.jsx("span",{children:e.windowSec>86400?xl(s):AT(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 _Q({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(""),[v,b]=y.useState(0),[k,N]=y.useState(Date.now),j=y.useRef(!1),S=y.useRef(null),_=ft(n,{focusRef:S}),T=mt(n),L=t[a];y.useEffect(()=>{let q=!1,M=null;c(null),p(!1);const I=async()=>{if(M)return;if(!L){j.current=!1,h(!1);return}const D=new AbortController;M=D,j.current=!0;const B=window.setTimeout(()=>D.abort(),12e3);h(!0);try{const H=await fetch(`/api/quota/history?provider=${a}&account=${encodeURIComponent(L)}`,{signal:D.signal}),G=await H.json();if(!H.ok||!G.ok||!Array.isArray(G.series))throw new Error("History unavailable");q||(c(G.account===L?G:{...G,series:[]}),p(!1))}catch{q||p(!0)}finally{window.clearTimeout(B),M=null,q||(j.current=!1,h(!1))}};I();const E=window.setInterval(()=>{N(Date.now()),document.visibilityState==="visible"&&I()},6e4);return()=>{q=!0,M==null||M.abort(),window.clearInterval(E)}},[a,L,v]);const A=((i==null?void 0:i.series)??[]).slice().sort((q,M)=>M.resetAt-q.resetAt||q.windowSec-M.windowSec),P=A.find(q=>Dh(q)===m)??A.find(q=>q.resetAt*1e3>k&&q.windowSec<=6*3600)??A[0],O=P==null?void 0:P.points.at(-1),U=()=>{bn(j.current)&&(j.current=!0,b(q=>q+1))};return xt.createPortal(r.jsx("div",{className:"modal-backdrop",role:"presentation",...T,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",...On(d),onClick:U,children:d?"…":r.jsx(JP,{})}),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(q=>e[q]).map(q=>r.jsx("button",{type:"button",className:"qh-provider","aria-pressed":a===q,onClick:()=>{o(q),w("")},children:q==="claude"?"Claude":"Codex"},q))}),A.length>0&&r.jsxs("label",{className:"qh-window",children:["Window",r.jsx("select",{"aria-label":"Quota window",value:P?Dh(P):"",onChange:q=>w(q.target.value),children:A.map(q=>r.jsxs("option",{value:Dh(q),children:[q.label," · ",xl(q.resetAt*1e3)]},Dh(q)))})]})]}),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."]}),P&&O?r.jsxs("div",{className:"qh-result read-result",children:[r.jsxs("div",{className:"qh-summary",children:[r.jsxs("strong",{children:[Math.round(100-O.pct),"% remaining"]}),r.jsxs("span",{title:xl(O.t),children:["Captured ",NQ(O.t,k),P.resetAt*1e3<=k&&" · window ended"]})]}),r.jsx(SQ,{series:P}),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 (",P.points.length,")"]}),r.jsxs("table",{children:[r.jsx("caption",{children:P.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:P.points.slice(-50).reverse().map(q=>r.jsxs("tr",{children:[r.jsx("td",{children:xl(q.t)}),r.jsxs("td",{children:[(100-q.pct).toLocaleString(void 0,{maximumFractionDigits:1}),"%"]})]},q.t))})]})]})]}):!f&&(d&&L?r.jsx(Zj,{kind:"quota",title:"Reading quota history…",note:"Loading this account’s saved quota readings."}):r.jsx("p",{className:"qh-message",role:"status",children:L?"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 CQ=6e4,EQ=2e4;function TQ(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&&!bn(i.current))){h&&(i.current=!0,a(!0));try{const p=await fetch(h?"/api/quota?refresh=1":"/api/quota",{signal:AbortSignal.timeout(EQ)});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),CQ),()=>{o.current!=null&&window.clearInterval(o.current)}},[e]),{quota:t,loading:s,refresh:()=>{e&&c(!0)}}}const AQ=6e4;function RQ(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&&!bn(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),AQ),()=>{o.current!=null&&window.clearInterval(o.current)}},[e]),{data:t,loading:s,refresh:()=>{e&&c(!0)}}}const RT=6e4;function MQ(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(b=>b+1)},w=window.setInterval(m,RT),v=()=>{p()&&Date.now()-h.current>=RT&&d(b=>b+1)};return document.addEventListener("visibilitychange",v),()=>{window.clearInterval(w),document.removeEventListener("visibilitychange",v)}},[]);const f=y.useRef(t);return y.useEffect(()=>{let p=!0;const m=t!==f.current;f.current=t;const w=e,v=WJ(w);return i(!0),fetch(`/api/ccusage?since=${v}${m?"&refresh=1":""}`).then(b=>b.ok?b.json():null).then(b=>{!p||!(b!=null&&b.ok)||(h.current=Date.now(),a({period:w,data:b,baseline:n()}))}).catch(()=>{}).finally(()=>{p&&i(!1)}),()=>{p=!1}},[e,t,c]),{...YJ(s,e),loading:o}}const $Q=e=>1-Math.pow(1-e,5),nD=420;function LQ(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 IQ(e,t,n,s=nD){return n>=s?t:n<=0?e:e+(t-e)*$Q(n/s)}function sD(){return typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches}function MT(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??sD,d=s.hidden??(()=>typeof document=="object"&&document.hidden===!0);if(c()||d()||!LQ(e,t))return n(t),()=>{};const h=a();let f=0,p=!0;const m=()=>{if(!p)return;const w=a()-h;n(IQ(e,t,w)),w<nD&&(f=o(m))};return f=o(m),()=>{p=!1,f&&i(f)}}const OQ=typeof window>"u"?y.useEffect:y.useLayoutEffect;function Po(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]),OQ(()=>{!t||sD()||(a.current=0,s(0))},[]),y.useEffect(()=>{if(o.current){if(o.current=!1,t)return MT(0,e,c=>{a.current=c,s(c)});a.current=e,s(e);return}return MT(a.current,e,c=>{a.current=c,s(c)})},[e]),n}function rD(e,t,n){const s=DQ*Math.max(1,n/oD);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 $T={samples:[],last:new Map,watched:0},aD=10*6e4,PQ=6e4,oD=5e3,DQ=20;function FQ(e,t,n){const s=e.samples[e.samples.length-1];if(s&&t-s.t<oD)return e;const a=e.watched+rD(e.last,n,s?t-s.t:0),o=e.samples.filter(i=>t-i.t<=aD);return o.push({t,watched:a}),{samples:o,last:n,watched:a}}function BQ(e,t,n){const s=e.samples[0];if(!s)return null;const a=t-s.t;if(a<PQ)return null;const o=e.samples[e.samples.length-1].t,i=e.watched+rD(e.last,n,t-o)-s.watched;return i>0?{spent:i,spanSec:a/1e3,spanMin:Math.min(aD/6e4,Math.ceil(a/6e4))}:null}function qQ(e,t,n){const s=y.useRef($T),a=y.useRef(null);return y.useMemo(()=>{const o=VZ(e.agents.values()),i=qZ(e.agents.values());a.current!==n&&(a.current=n,s.current=$T);const c=n1(e.agents.values(),t);n!=null&&(s.current=FQ(s.current,t,c));const d=n==null?null:BQ(s.current,t,c),h=d?{label:kj(d.spent,d.spanSec),spanMin:d.spanMin}:null;return{byModel:o,totalCost:i.cost,totalTokens:i,burnRate:h}},[e,e.revision,t,n])}const UQ=3e4;function Jj(){const[e,t]=y.useState(()=>Math.floor(Date.now()/1e3));return y.useEffect(()=>{const n=window.setInterval(()=>t(Math.floor(Date.now()/1e3)),UQ);return()=>window.clearInterval(n)},[]),e}function LT(e){return(typeof e.cost=="number"?e.cost:e.cost.total)>0||e.inputTokens+e.outputTokens>0}function WQ(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 HQ(e){return e.claude&&e.codex?"Refresh Claude + Codex quota":e.codex?"Refresh Codex quota":"Refresh Claude quota"}function zQ(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 VQ(e){const t=new Map;for(const n of e)n.kind!=="root"||!n.sessionId||t.set(n.sessionId,n.state);return t}function GQ(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 KQ({state:e,now:t,providers:n,incidents:s=[],leaving:a,onClose:o,liveSince:i=null}){const c=qn(),[d,h]=y.useState(null),[f,p]=y.useState(null),m=y.useMemo(()=>new Map([...e.agents.values()].filter($e=>$e.kind==="root").map($e=>[$e.sessionId,$e.provider??"claude"])),[e,e.revision]),{quota:w,loading:v,refresh:b}=TQ(n.claude),{data:k,loading:N,refresh:j}=RQ(n.codex),S=Jj(),{byModel:_,totalCost:T,totalTokens:L}=qQ(e,t,i),A=y.useMemo(()=>GZ(e.agents.values()),[e,e.revision]),[P,O]=y.useState(ZJ);y.useEffect(()=>{JJ(P)},[P]);const[U,q]=y.useState(QJ);y.useEffect(()=>{eQ(U)},[U]);const[M,I]=y.useState(0),E=y.useRef(()=>new Map);E.current=()=>i==null?null:n1(e.agents.values(),t);const D=y.useCallback(()=>E.current(),[]),{data:B,shown:H,stale:G,loading:z,baseline:F}=MQ(P,M,D),$=B!=null,W=z&&G,Z=y.useMemo(()=>zQ(e.agents.values()),[e,e.revision]),V=y.useMemo(()=>VQ(e.agents.values()),[e,e.revision]),Y=y.useMemo(()=>$?Gj(B):[],[B,$]),X=y.useMemo(()=>$?GQ(VJ(B,Z).slice(0,12)):[],[B,$,Z]),J=y.useMemo(()=>Kj(B),[B]),Q=y.useMemo(()=>GJ(B,J.cost),[B,J.cost]),te=KP(H,P),ce=y.useMemo(()=>$?qJ(F,n1(e.agents.values(),t)):t1,[e,e.revision,F,$,t]),ue=XJ(B,{...L,cost:T},ce),ie=ue.hasCost,re=ue.tokenSum,fe=Po(ue.cost),ae=Po(ue.inputTokens),je=Po(ue.outputTokens),me=Po(ue.cacheReadTokens),pe=Po(ue.cacheCreateTokens),xe=_.filter(LT),_e=A.filter(LT),ye=WQ($,Y,xe,ce.unpricedTokens),Ie=v||N,Pe=()=>{b(),j(),I($e=>$e+1)},Ue=HQ(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:$e=>p($e.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:Pe,...On(Ie),"aria-label":Ue,title:Ue,children:Ie?"…":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:kn("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(uQ,{quota:w,quotaLoading:v,nowSec:S,incident:s.find($e=>$e.provider==="claude")}),n.codex&&r.jsx(dQ,{codexQuota:k,codexLoading:N,nowSec:S,incident:s.find($e=>$e.provider==="codex")}),$&&r.jsx(fQ,{period:P,rangePending:W,setPeriod:O}),re>0?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"up-total",title:$?void 0:wT(c),children:[r.jsx("span",{className:!ie&&ye?"up-total-value up-unpriced":"up-total-value",children:ie?r.jsxs(r.Fragment,{children:[st(fe),ye&&"+"]}):r1(0,ye)}),ie&&r.jsx("span",{className:"up-total-label",children:$?te:UZ})]}),ie&&r.jsxs(r.Fragment,{children:[r.jsxs("p",{className:"up-source",children:["Local estimate · ",$?"ccusage":"live sessions"]}),ue.showCostBar&&r.jsx(Yj,{cost:T})]}),r.jsxs("div",{className:"up-tokens-row",title:$?void 0:wT(c),children:[r.jsxs("span",{className:"up-tok",children:[r.jsx("span",{className:"up-k",children:"in"}),wt(ae)]}),r.jsxs("span",{className:"up-tok",children:[r.jsx("span",{className:"up-k",children:"out"}),wt(je)]}),ue.cacheReadTokens>0&&r.jsxs("span",{className:"up-tok",children:[r.jsx("span",{className:"up-k",children:"cache r"}),wt(me)]}),ue.cacheCreateTokens>0&&r.jsxs("span",{className:"up-tok",children:[r.jsx("span",{className:"up-k",children:"cache c"}),wt(pe)]}),!ie&&r.jsx("span",{className:"up-tok up-scope",children:$?te:WZ})]}),($?Y.length:xe.length)>0&&r.jsx(hQ,{fromRange:$,rangeModelRows:Y,boardModelRows:xe}),$&&X.length===0&&J.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 ",te," yet — ccusage dates sessions in UTC, and the totals above are your local day."]})]}),($?X.length:_e.length)>0&&r.jsx(gQ,{fromRange:$,rangeSessionRows:X,boardSessionRows:_e,boardStates:V,sessionsOpen:U,setSessionsOpen:q,periodNoun:te,sessionScale:Q,onOpenSession:h,boardProviders:m}),ye&&r.jsxs("div",{className:"up-hint",children:["“",ia,"” 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:$?(H??P)==="all"?r.jsx(r.Fragment,{children:"No usage in any transcript on this machine."}):r.jsxs(r.Fragment,{children:["No usage ",te,".",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($u,{film:"usage"})}),d&&r.jsx(kQ,{session:d,onClose:()=>h(null)},`${d.agent}:${d.sessionId}`),f&&r.jsx(_Q,{providers:n,instant:f==="keyboard",accounts:{claude:w==null?void 0:w.historyAccount,codex:k==null?void 0:k.historyAccount},onClose:()=>p(null)})]})}function ky(e){return e<9.95?e.toFixed(1):String(Math.round(e))}function Qj(e){const t=Number.isFinite(e)?Math.max(0,e):0;return t<50?{value:"0",unit:"KB/s"}:t<999500?{value:ky(t/1e3),unit:"KB/s"}:t<9995e5?{value:ky(t/1e6),unit:"MB/s"}:{value:ky(t/1e9),unit:"GB/s"}}function Up(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 Lu(e){return e.unit?e.unit==="%"||e.unit==="°C"?`${e.value}${e.unit}`:`${e.value} ${e.unit}`:e.value}const YQ="thermal:Throttling";function eN(e){const t="timeHeld"in e?e.timeHeld:100-e.speedLimit;return Math.max(0,Math.min(100,t))}function XQ(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[YQ]=eN(e.thermal.throttle)),t}function lu(e,t){return t==="B/s"?Lu(Qj(e)):t==="ms"?Lu(Up(e)):t==="C"?`${Math.round(e)}°`:t==="%"?`${Math.round(e)}%`:e.toFixed(2)}function Fh(e,t){return t==="B/s"||t==="ms"||!Number.isInteger(e)?lu(e,t):t==="C"?`${e}°`:t==="%"?`${e}%`:`${e}`}function ZQ(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 JQ(e,t,n){return e>=n?"hot":e>=t?"warn":"calm"}function QQ(e,t,n=Date.now()){const s=eN(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 ${IT(t.lastMs,n)}`:`at full speed · held to ${100-t.peak}% ${IT(t.lastMs,n)}`:"running at full speed, and never held back"}}function IT(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 eee(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 tee(e){var s,a;const t=(s=e.thermal)==null?void 0:s.throttle,n=t?eN(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 nee(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 see=3e3;function ree(){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,see))},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 aee(e,t){return!e||e.key!==t?"none":e.dir==="asc"?"ascending":"descending"}function el({col:e,label:t,note:n,sort:s,next:a,onSort:o,className:i}){const c=aee(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 jy(e,t){return t==="B/s"?Qj(e):t==="ms"?Up(e):{value:String(e),unit:t==="C"?"°C":t}}const Vt={l:30,r:6,t:6,b:2},qa={l:0,r:0,t:2,b:1},Wp=104,oee=64;function Gs(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 iD(e,t){return t??[e[0].t,e[e.length-1].t]}function tN(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 lD(e,t,n,s=100,a=Wp,o=Vt,i){if(!e.length)return"";const c=iD(e,i),d=p=>tN(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)} ${Gs(p.v,s,a,o).toFixed(1)}`,f=p}return h}function cD(e,t,n,s=100,a=Wp,o=Vt,i){if(e.length<2)return"";const c=a-o.b,d=iD(e,i),h=w=>tN(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 v of p)w+=`L${h(v.t).toFixed(1)} ${Gs(v.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 iee(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 uD(e,t,n){return n!=null&&e>=n?"hot":t!=null&&e>=t?"warn":""}function lee(e,t,n=s=>Va(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 OT(e,t){return t==null||!Number.isFinite(t)||t<=0||!Number.isFinite(e)||e<0?null:`${(e/t).toFixed(1)}× the core count`}function Va(e){const t=new Date(e);return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}function nN(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 cee({group:e,title:t,liveNote:n,onClose:s}){const a=ft(s),o=mt(s),[i,c]=y.useState(null);y.useEffect(()=>{let m=!0;const w=async()=>{try{const b=await fetch(`/api/system/history?group=${e}`);if(!b.ok)return;const k=await b.json();m&&(k!=null&&k.ok)&&c(k)}catch{}};w();const v=window.setInterval(w,2e4);return()=>{m=!1,window.clearInterval(v)}},[e]);const d=(i==null?void 0:i.series)??[],[h,f,p]=y.useMemo(()=>{let m=1/0,w=0;for(const v of d)v.points.length&&(m=Math.min(m,v.points[0].t),w=Math.max(w,v.points[v.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 xt.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 ",Va(h)," · ",nN(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(Zj,{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(uee,{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 uee({series:e,stepMs:t,domain:n}){const s=y.useRef(null),[a,o]=y.useState(560),[i,c]=y.useState(null),[d,h]=y.useState(null);y.useEffect(()=>{const $=s.current;if(!$||typeof ResizeObserver>"u")return;const W=new ResizeObserver(([Z])=>o(Math.max(160,Z.contentRect.width)));return W.observe($),()=>W.disconnect()},[]);const{points:f,unit:p,warnAt:m,critAt:w,label:v,top:b,restsAtZero:k,changes:N,cores:j}=e,S=k?oee:Wp,{now:_,peak:T}=iee(f),L=_!=null?jy(_,p):null,A=T!=null?jy(T,p):null,P=v==="Throttling"?lee(f,t):null;let O=null;if(T!=null&&f.length>1)for(let $=f.length-1;$>=0&&!O;$--)f[$].v===T&&(O=f[$]);const U=d!=null?f.find($=>$.t===d)??null:null,q=i!=null?f[i]:U,M=q?OT(q.v,j):null,[I,E]=n??(f.length?[f[0].t,f[f.length-1].t]:[0,0]),D=$=>tN($,[I,E],a),B=$=>{if(f.length<2)return null;const W=$.currentTarget.getBoundingClientRect(),Z=($.clientX-W.left-Vt.l)/Math.max(1,W.width-Vt.l-Vt.r),V=I+(E-I)*Math.max(0,Math.min(1,Z));let Y=0;for(let X=1;X<f.length;X++)Math.abs(f[X].t-V)<Math.abs(f[Y].t-V)&&(Y=X);return Y},H=$=>{const W=B($);W!=null&&c(W)},G=$=>{const W=B($);if(W==null)return;const Z=f[W].t;h(V=>V===Z?null:Z)},z=T!=null&&A&&r.jsxs(r.Fragment,{children:[r.jsx("b",{className:uD(T,m,w),children:A.value}),r.jsxs("span",{children:[A.unit," peak"]})]}),F=T!=null?OT(T,j):null;return r.jsxs("section",{className:"hist-series","aria-label":`${v} history`,children:[r.jsxs("div",{className:"hist-head",children:[r.jsx("span",{className:"hist-label",children:v}),r.jsxs("span",{className:"hist-stats",children:[L&&r.jsxs(r.Fragment,{children:[r.jsx("b",{children:L.value}),r.jsxs("span",{children:[L.unit," now"]})]}),z&&(O?r.jsx("button",{type:"button",className:"hist-peak",onClick:()=>h(O.t),title:"Show when it peaked",children:z}):z)]})]}),r.jsx("div",{className:"hist-plot",ref:s,children:r.jsxs("svg",{className:"hist-chart",width:"100%",height:S,viewBox:`0 0 ${a} ${S}`,preserveAspectRatio:"none",role:"img","aria-label":L==null||A==null?`${v}: nothing measured yet`:`${v}: ${Lu(L)} now, peak ${Lu(A)}${O?` at ${Va(O.t)}`:""}${F?` (${F})`:""}, over ${nN(f[0].t,f[f.length-1].t)}`,onPointerMove:H,onPointerLeave:()=>c(null),onClick:G,children:[[["warn",m],["hot",w]].map(([$,W])=>W==null||W>b?null:r.jsxs("g",{children:[r.jsx("line",{className:`hist-rule ${$}`,x1:Vt.l,x2:a-Vt.r,y1:Gs(W,b,S),y2:Gs(W,b,S)}),r.jsx("text",{className:`hist-rule-tag ${$}`,x:2,y:Gs(W,b,S)+3,children:W})]},$)),r.jsx("line",{className:"hist-floor",x1:Vt.l,x2:a-Vt.r,y1:S-Vt.b,y2:S-Vt.b}),(N??[]).filter($=>$.from!=null&&f.length>1&&$.t>=I&&$.t<=E).map($=>r.jsx("line",{className:"hist-mark",x1:D($.t),x2:D($.t),y1:Vt.t,y2:S-Vt.b},$.t)),r.jsx("path",{className:"hist-area",d:cD(f,a,t,b,S,Vt,[I,E])}),r.jsx("path",{className:"hist-line",d:lD(f,a,t,b,S,Vt,[I,E])}),f.length===1&&r.jsx("circle",{className:"hist-dot",cx:D(f[0].t),cy:Gs(f[0].v,b,S),r:3}),q&&r.jsxs("g",{children:[r.jsx("line",{className:"hist-cross",x1:D(q.t),x2:D(q.t),y1:Vt.t,y2:S-Vt.b}),r.jsx("circle",{className:"hist-dot",cx:D(q.t),cy:Gs(q.v,b,S),r:3})]})]})}),r.jsxs("div",{className:"hist-axis",children:[q?r.jsxs("span",{className:"hist-at",children:[Va(q.t)," — ",(()=>{const $=jy(q.v,p);return r.jsxs(r.Fragment,{children:[r.jsx("b",{children:$.value}),$.unit==="%"||$.unit==="°C"||!$.unit?$.unit:` ${$.unit}`]})})(),M&&` · ${M}`]}):r.jsxs(r.Fragment,{children:[r.jsx("span",{children:f.length?Va(I):""}),r.jsx("span",{children:f.length?Va(E):""})]}),U&&r.jsx("button",{type:"button",className:"glyph-btn hist-unpin",onClick:()=>h(null),"aria-label":"Stop showing this reading",title:"Stop showing this reading",children:"×"})]}),P&&r.jsx("div",{className:"hist-note",children:P}),N==null?void 0:N.slice(-3).map($=>r.jsx("div",{className:"hist-note hist-route",children:$.from==null?`Since ${Va($.t)} — ${$.label}`:`${Va($.t)} — ${$.label.charAt(0).toUpperCase()+$.label.slice(1)}`},$.t))]})}const PT=["cores","memory","load","thermal"],Ro=116,mr=24,dee=60,hee=6e4;function fee(e){return e.points.length?e.restsAtZero?e.points.some(t=>t.v>0):!0:!1}function pee(e){return e.unit==="C"?`${e.label} temp`:e.key==="mem:physical"?"Physical RAM":e.key==="mem:swap"?`${e.label} memory`:e.label}function mee(e,t=dee){return e.points.length<=t?e:{...e,points:e.points.slice(-t)}}function gee({sys:e}){const[t,n]=y.useState({});y.useEffect(()=>{let i=!0;const c=async()=>{const h=await Promise.all(PT.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(),hee);return()=>{i=!1,clearInterval(d)}},[]);const s=y.useMemo(()=>XQ(e),[e]),a=y.useMemo(()=>PT.flatMap(i=>{const c=t[i];return c?c.series.filter(fee).map(d=>({series:mee(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)?nN(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(yee,{series:i,stepMs:c,now:s[i.key],span:o},i.key))}):null}function yee({series:e,stepMs:t,now:n,span:s}){var w;const{points:a,top:o,unit:i,warnAt:c,critAt:d}=e,h=pee(e),f=n??((w=a[a.length-1])==null?void 0:w.v),p=f==null?"":uD(f,c,d),m=Math.max(...a.map(v=>v.v));return r.jsxs("div",{className:`pl-cell${p?` ${p}`:""}`,title:[`${h} · peak ${lu(m,i)} over the last ${s}`,c!=null?`over ${Fh(c,i)} is uncomfortable`:"",d!=null?`over ${Fh(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?"—":lu(f,i)})]}),r.jsxs("svg",{className:"pl-spark",width:Ro,height:mr,viewBox:`0 0 ${Ro} ${mr}`,preserveAspectRatio:"none","aria-hidden":!0,children:[r.jsx("line",{className:"pl-spark-floor",x1:0,x2:Ro,y1:mr-qa.b,y2:mr-qa.b}),r.jsx("path",{className:"pl-spark-area",d:cD(a,Ro,t,o,mr,qa)}),c!=null&&r.jsx("line",{className:"pl-rule warn",x1:0,x2:Ro,y1:Gs(c,o,mr,qa),y2:Gs(c,o,mr,qa)}),d!=null&&r.jsx("line",{className:"pl-rule hot",x1:0,x2:Ro,y1:Gs(d,o,mr,qa),y2:Gs(d,o,mr,qa)}),r.jsx("path",{className:"pl-spark-line",d:lD(a,Ro,t,o,mr,qa)})]}),r.jsxs("span",{className:"vis-hidden",children:["peak ",lu(m,i)," over the last ",s,c!=null&&`, uncomfortable over ${Fh(c,i)}`,d!=null&&`, the machine acts over ${Fh(d,i)}`]})]})}const dD={key:"cpu",dir:"desc"};function wee(e,t){return e.key===t?{...e,dir:e.dir==="asc"?"desc":"asc"}:{key:t,dir:t==="name"||t==="user"?"asc":"desc"}}function xee(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 vee=4e3;function bee(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 kee(){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=>bee(c,i))}catch{}};s();const a=window.setInterval(s,vee);return()=>{n=!1,window.clearInterval(a)}},[]),e}function jee(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 Nee({sys:e,onClose:t}){tn("process-list");const n=ft(t),s=mt(t),[a,o]=y.useState(dD),i=kee();return xt.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(See,{read:i,sort:a,onSort:o,sys:e,onClose:t})})}),document.body)}function See({read:e,sort:t,onSort:n,sys:s,onClose:a}){const o=e?xee(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(Zj,{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(Ki,{col:"cpu",label:"cpu",sort:t,onSort:n}),r.jsx(Ki,{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(Ki,{col:"threads",label:"threads",sort:t,onSort:n}),r.jsx(Ki,{col:"uptime",label:"up",sort:t,onSort:n}),r.jsx(Ki,{col:"user",label:"user",sort:t,onSort:n}),r.jsx("th",{scope:"col",className:"pl-pid-h",children:"pid"}),r.jsx(Ki,{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:Zr(i.rssBytes)}),r.jsx("td",{className:"sd-num sd-dim",children:i.threads??"—"}),r.jsx("td",{className:"sd-num sd-dim",children:jee(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(gee,{sys:s})]})]})}function Ki(e){return r.jsx(el,{...e,next:(t,n)=>wee(t??dD,n)})}function a1({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 _ee=300;function Iu({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=v=>{var b;m(),!(v.detail>1||((b=window.getSelection())==null?void 0:b.isCollapsed)===!1)&&(p.current=window.setTimeout(()=>{var k,N;p.current=null,((k=window.getSelection())==null?void 0:k.isCollapsed)!==!1&&((N=f.current)==null||N.focus({preventScroll:!0}),h(!0))},_ee))};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:v=>{v.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(cee,{group:e,title:t,liveNote:i,onClose:()=>h(!1)})]})}function Yf({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 Cee(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 Ja=4,ws=8;function sN(e,t,n){const s=n.width-ws-(e.right+Ja),a=e.left-Ja-ws,o=t.width<=s||s>=a?"right":"left",i=o==="right"?e.right+Ja:e.left-Ja-t.width,c=n.height-ws*2,d=t.height<=c,h=d?t.height:Math.max(0,c),f=Math.max(ws,Math.min(e.top,n.height-ws-h)),p=Math.max(ws,Math.min(i,n.width-ws-t.width));return{top:f,left:p,side:o,maxHeight:d?null:h}}function Eee(e,t,n){const s=n.height-ws-(e.bottom+Ja),a=e.top-Ja-ws,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+Ja:e.top-Ja-d,f=Math.max(ws,Math.min(e.right-t.width,n.width-ws-t.width));return{top:Math.max(ws,h),left:f,side:o,maxHeight:c?null:d}}function Tee(e,t,n){return!(!e||t!=null&&t.contains(e)||n!=null&&n.contains(e))}function Aee(e,t,n){const s=y.useRef(t);s.current=t;const a=y.useRef(n);a.current=n,y.useEffect(()=>{const o=i=>{Tee(i.target,e.current,s.current())&&a.current()};return window.addEventListener("pointerdown",o,!0),()=>window.removeEventListener("pointerdown",o,!0)},[e])}const hD='[role="menuitem"]';function DT(e){return e?Array.from(e.querySelectorAll(hD)).filter(t=>!t.disabled):[]}function Hp({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 v=ft(()=>{var S;(S=document.getElementById(e))==null||S.focus(),m.current()},{popover:!0,focusRef:d}),b=y.useCallback(()=>{var P,O,U;const S=v.current;if(!S)return;const _=document.getElementById(e);if(!_){m.current();return}if(_.getClientRects().length===0){S.contains(document.activeElement)&&((O=(P=w.current)==null?void 0:P.call(w))==null||O.focus()),m.current();return}const T=_.getBoundingClientRect(),L=t?(U=document.getElementById(t))==null?void 0:U.getBoundingClientRect():null;if(L&&(T.bottom<=L.top||T.top>=L.bottom)){S.contains(document.activeElement)&&_.focus({preventScroll:!0}),m.current();return}S.style.maxHeight="";const A=Eee(T,{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,v]);y.useLayoutEffect(()=>{b()}),y.useEffect(()=>{const S=_=>{var T;(T=v.current)!=null&&T.contains(_.target)||b()};return window.addEventListener("scroll",S,!0),window.addEventListener("resize",b),()=>{window.removeEventListener("scroll",S,!0),window.removeEventListener("resize",b)}},[b,v]),Aee(v,()=>document.getElementById(e),f),y.useEffect(()=>{var _;if(o!=="menu")return;const S=DT(v.current);(_=c==="last"?S[S.length-1]:S[0])==null||_.focus()},[]);const k=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 T=DT(v.current),L=Cee(S,T.indexOf(document.activeElement),T.length);L.kind==="focus"&&(S.preventDefault(),T[L.index].focus())}S.key.length===1&&S.stopPropagation()},N=S=>{S.target.closest("button, input, select, textarea, code")||S.preventDefault()},j=S=>{if(o!=="menu"||S.pointerType==="touch")return;const _=S.target.closest(hD);_&&!_.disabled&&document.activeElement!==_&&_.focus({preventScroll:!0})};return xt.createPortal(r.jsx("div",{ref:v,id:s,className:`anchored-popover${a?` ${a}`:""}`,role:o,"aria-labelledby":i,onKeyDown:k,onMouseDown:N,onPointerMove:j,children:p}),(n?document.getElementById(n):null)??document.body)}function Ree({network:e}){const{down:t,up:n,api:s,route:a}=e,[o,i]=y.useState(!1),c=s&&s.ms!=null?Up(s.ms):null,d=t!=null&&n!=null;return r.jsxs("div",{className:"sd-section",role:"group","aria-label":"Network",children:[r.jsxs(Iu,{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=Qj(f);return r.jsx(a1,{value:p.value,unit:p.unit,cap:h},h)}),c&&r.jsx(a1,{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(Mee,{route:a,api:s,onClose:()=>i(!1)})]})]})}function Mee({route:e,api:t,onClose:n}){return r.jsxs(Hp,{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 ",nee(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`:`${Lu(Up(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 FT({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 $ee({usageOpen:e,leaving:t,onClose:n}){const s=ree();if(!s||s.cpu==null||!s.memory)return r.jsx(FT,{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(FT,{usageOpen:e,leaving:t,sub:`up ${eee(h)} · ${d} cores`,flag:tee(s),onClose:n,children:[r.jsx(Lee,{cpu:w,perCore:i,loadavg:c,cores:d}),r.jsx(Iee,{memory:a,swap:o,platform:f}),m&&r.jsx(Ree,{network:m}),r.jsx(Oee,{thermal:p}),r.jsx(Pee,{sys:s})]})}function Lee({cpu:e,perCore:t,loadavg:n,cores:s}){const a=ZQ(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(Iu,{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(Iu,{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(a1,{value:i.toFixed(2),cap:["1m","5m","15m"][c]},c))}),a&&r.jsx("div",{className:"sd-note",children:a})]})]})}function Iee({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(Iu,{group:"memory",title:"Memory history",action:"Show memory history",label:"Memory",children:[r.jsx(Yf,{label:"Physical",value:r.jsxs(r.Fragment,{children:[r.jsx("b",{children:Zr(s)})," of ",Zr(e.total)]}),pct:e.usedPct,tone:e.usedPct>=90?"warn":"calm",note:`${Zr(e.available)} available`}),t&&t.total>0&&r.jsx(Yf,{label:a,value:r.jsxs(r.Fragment,{children:[r.jsx("b",{children:Zr(t.used)})," of ",Zr(t.total)]}),pct:o,tone:o>=90?"warn":"calm"})]})})}function Oee({thermal:e}){if(!e)return null;const t=e.throttle?QQ(e.throttle,e.heldBack):null;return r.jsx("div",{className:"sd-section",role:"group","aria-label":"Thermal",children:r.jsxs(Iu,{group:"thermal",title:"Thermal history",action:"Show thermal history",label:"Thermal",children:[e.celsius.map(n=>r.jsx(Yf,{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:JQ(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(Yf,{label:"Throttling",value:r.jsx("b",{children:t.value}),pct:t.pct,tone:t.tone,note:t.note})]})})}function Pee({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(Nee,{sys:e,onClose:()=>n(!1)})]})}function Dee(){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 Xf(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=Xf(e.l));const n=e.s?Object.entries(e.s):[];return n.length>0&&(t.bySpeed=Object.fromEntries(n.map(([s,a])=>[s,Xf(a)]))),t}function BT(e){const t=s=>({...s,cacheCreate1hTokens:0,cacheCreate5mTokens:0,...s.longContext?{longContext:{...s.longContext,cacheCreate1hTokens:0,cacheCreate5mTokens:0}}:{}}),n=t(Xf(e));return n.bySpeed&&(n.bySpeed=Object.fromEntries(Object.entries(n.bySpeed).map(([s,a])=>[s,t(a)]))),n}function fD(e){return e.i+e.o+e.cr+e.cc}function o1(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&&o1(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??{}))o1((n=e.s??(e.s={}))[s]??(n[s]={i:0,o:0,cr:0,cc:0,c1h:0,c5m:0}),a);return e}function qT(e,t,n){let s=0,a=0,o=0;const i=[];for(const c of Vu(e)){if(!jr(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+=Nu(c.usage,t,c.speed,n).total,a+=Nu({...c.usage,longContext:void 0},t,oa,n).total}return{atSpeed:s,atStandard:a,unpriced:o,unpricedSpeeds:i}}function UT(e){let t=0;for(const n of Object.values(e))t+=fD(n);return t}function Fee(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 Bee(e,t,n,s=Date.now()){const a=new Map;for(const A of e){const P={},O=U=>{for(const[q,M]of Object.entries(U))o1(P[q]??(P[q]={i:0,o:0,cr:0,cc:0,c1h:0,c5m:0}),M)};for(const U of A.projects)O(U.models);A.unattributed&&O(A.unattributed);for(const[U,q]of Object.entries(P)){if(!q.s&&!q.l)continue;const{atSpeed:M,atStandard:I}=qT(BT(q),U,s);if(!(M>0&&I>0))continue;let E=a.get(A.day);E||(E=new Map,a.set(A.day,E)),E.set(U,M/I),E.has(yr(U))||E.set(yr(U),M/I)}}const o=(A,P)=>{const O=a.get(A);return(O==null?void 0:O.get(P))??(O==null?void 0:O.get(yr(P)))??1},i=new Map;let c=0,d=0;for(const[A,P]of n){const O=A.indexOf("|"),U=A.slice(0,O),q=A.slice(O+1),M=Sp(P.usage,q,s).total*o(U,q);if(!(M>0&&P.cost>0))continue;c+=P.cost,d+=M;let I=i.get(U);I||(I=new Map,i.set(U,I)),I.set(q,P.cost/M)}const h=d>0,f=(A,P)=>{const O=i.get(A);return(O==null?void 0:O.get(P))??(O==null?void 0:O.get(yr(P)))??null},p=new Set,m=(A,P)=>{let O=0,U=0;for(const[q,M]of Object.entries(A)){if(jr(q,s)){const E=P(q),D=qT(E===null?Xf(M):BT(M),q,s);O+=E===null?D.atSpeed:D.atSpeed*E,U+=D.unpriced;for(const B of D.unpricedSpeeds)p.add(`${q} (${B})`);continue}const I=fD(M);I>0&&(U+=I,p.add(q))}return{cost:O,unpriced:U}},w=new Map,v=[];for(const A of e){const P=new Map,O=new Map;let U=0;for(const q of A.projects){const{cost:M,unpriced:I}=m(q.models,D=>f(A.day,D));P.set(q.path,(P.get(q.path)??0)+M),I>0&&O.set(q.path,(O.get(q.path)??0)+I),U+=M;let E=w.get(q.path);E||(E={path:q.path,cost:0,tokens:0,unpricedTokens:0},w.set(q.path,E)),E.cost+=M,E.tokens+=UT(q.models),E.unpricedTokens+=I}v.push({day:A.day,total:U,byPath:P,unpricedByPath:O})}const b=[...w.values()].sort((A,P)=>P.cost-A.cost||P.tokens-A.tokens),k=b.reduce((A,P)=>A+P.cost,0),N=b.reduce((A,P)=>A+P.tokens,0),j=b.reduce((A,P)=>A+P.unpricedTokens,0),S=h?c/d:null,_=t?UT(t):0,T=t?m(t,()=>S):{cost:0,unpriced:0},L=T.cost>0||_>0?{cost:T.cost,tokens:_,unpricedTokens:T.unpriced}:null;return{projects:b,totalCost:k,totalTokens:N,unpricedTokens:j,perDay:v,unattributed:L,unpricedModels:[...p].sort(),calibrated:h,reconciled:h&&j===0}}function gr(e,t,n=st){return t>0?e>0?`${n(e)}+`:ia:n(e)}function Yi(e){return e>0?`${wt(e)} of these tokens are on an unpriced model, so this is a floor`:void 0}function qee(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 ${ia}: this build holds no published rate for it, so its tokens are counted and its dollars are not.`:`${n} are ${ia}: this build holds no published rate for them, so their tokens are counted and their dollars are not.`}const Uee={phase:"running"},Wee={phase:"failed"},Hee={gen:0,report:null,error:null,early:null};function zee(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:Uee;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 Vee(e){var t;return((t=e.report)==null?void 0:t.gen)!==e.gen&&e.error===null}function Gee(e){const t=e;return t&&t.ok!==!1?{phase:"ready",range:t}:Wee}function Kee(e){return`${e.getFullYear()}${String(e.getMonth()+1).padStart(2,"0")}${String(e.getDate()).padStart(2,"0")}`}function Yee(e,t,n=Date.now()){const s=t===0?60:t,a=new Date(n),o=s1(s,a),i=Kee(a);return{report:`/api/account-projects?num=${e}&days=${t}`,ccusage:`/api/ccusage?since=${o}&until=${i}`}}function Xee({num:e,days:t,gen:n,dispatch:s,get:a=(i,c)=>fetch(i,c),now:o=Date.now()}){const i=Yee(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:Gee(d)}))}function pD(e){return/^[A-Za-z]:[\\/]$/.test(e)?e:e.replace(/[\\/]+$/,"")}function Ny(e){const t=pD(e).replace(/\\/g,"/");return/^[A-Za-z]:\//.test(t)?t.toLowerCase():t}function WT(e){if(!e)return e;const t=pD(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 Zee(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 i1(e){return e===0?"all time":e===1?"today":`the last ${e} days`}function Jee(e){return e===1?"No work attributed to this account yet today.":`No work attributed to this account in ${i1(e)}.`}function Qee(e){return e===1?7:e===7?30:e===30?0:null}function ete(e,t){return e!==1&&t>0}const tte=[{days:1,label:"Today"},{days:7,label:"7d"},{days:30,label:"30d"},{days:0,label:"All"}],Xi=["var(--usage-blue)","var(--usage-teal)","var(--usage-lime)","var(--usage-purple)","var(--usage-indigo)","var(--usage-pink)","var(--usage-orange)","var(--usage-zinc)"],nte="var(--usage-zinc)",Sy=6,ste=1600;function rte(e){const t=st(e),n=/^\$(\d{4,})$/.exec(t);return n?`$${Number(n[1]).toLocaleString("en-US")}`:t}function Bh(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 ate(e){const t=/^\d{4}-(\d{2})-(\d{2})$/.exec(e);return t?`${Number(t[1])}/${Number(t[2])}`:e}function ote(e){const t=Math.max(1,Math.ceil(e/6));return n=>n===0||n===e-1||n%t===0}function _y(e){if(!e)return"";try{return new Date(e).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return""}}function ite({num:e,name:t,onClose:n}){var B,H,G,z;tn("account-projects");const[s,a]=y.useState(1),[o,i]=y.useReducer(zee,Hee),c=((B=o.report)==null?void 0:B.data)??null,d=((H=o.report)==null?void 0:H.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,v]=y.useState(()=>new Set),b=Vee(o),k=o.error,[N,j]=y.useState(null),S=y.useRef(void 0),_=y.useRef(!0);y.useEffect(()=>()=>{_.current=!1,window.clearTimeout(S.current)},[]);const T=y.useRef(null),L=ft(n,{focusRef:T}),A=mt(n),P=y.useRef(0);y.useEffect(()=>{const F=++P.current;i({type:"start",gen:F}),m(null),v(new Set),Xee({num:e,days:s,gen:F,dispatch:i})},[e,s]);const O=y.useMemo(()=>{const F=Date.now();if(!c)return null;const $=Bee(c.daily??[],c.unattributed,Fee(h),F),W=xe=>xe.replace(/[\\/]+$/,"").split(/[\\/]/).pop()||xe||"(unknown)",Z=new Map;for(const xe of $.projects)Z.set(W(xe.path),(Z.get(W(xe.path))??0)+1);const V=xe=>{const _e=W(xe);if((Z.get(_e)??0)<=1)return _e;const ye=xe.replace(/[\\/]+$/,"").split(/[\\/]/).slice(-2,-1)[0];return ye?`${ye}/${_e}`:_e},Y=$.projects.map(xe=>({path:xe.path,label:V(xe.path)})),X=xe=>({path:xe.path,label:V(xe.path),parentLabel:Zee(xe.path,Y),cost:xe.cost,tokens:xe.tokens,unpricedTokens:xe.unpricedTokens}),J=Xi[Sy%Xi.length],Q=new Map,te=[],ce=$.projects.slice(0,Sy),ue=$.projects.slice(Sy);ce.forEach((xe,_e)=>{Q.set(xe.path,Xi[_e%Xi.length]),te.push({key:xe.path,...X(xe),color:Xi[_e%Xi.length]})}),ue.length&&te.push({key:"__other__",label:`Other · ${ue.length} project${ue.length>1?"s":""}`,cost:ue.reduce((xe,_e)=>xe+_e.cost,0),tokens:ue.reduce((xe,_e)=>xe+_e.tokens,0),unpricedTokens:ue.reduce((xe,_e)=>xe+_e.unpricedTokens,0),color:J,muted:!0,members:ue.map(X)});const ie=$.totalCost,re=$.totalTokens,fe=ie>0&&$.unpricedTokens===0?"cost":"tokens",ae=fe==="cost"?ie:re,je=te.map(xe=>xe.color),me=$.perDay.map(xe=>{const _e=new Map;for(const[Pe,Ue]of xe.byPath){const $e=Q.get(Pe)??J;_e.set($e,(_e.get($e)??0)+Ue)}const ye=new Map;let Ie=0;for(const[Pe,Ue]of xe.unpricedByPath){const $e=Q.get(Pe)??J;ye.set($e,(ye.get($e)??0)+Ue),Ie+=Ue}return{day:xe.day,total:xe.total,costByColor:_e,unpricedByColor:ye,unpriced:Ie}}),pe=me.reduce((xe,_e)=>Math.max(xe,_e.total),0);return{projectCount:$.projects.length,rows:te,totalCost:ie,totalTokens:re,basis:fe,denom:ae,un:$.unattributed,chart:me,maxDay:pe,colorOrder:je,unpricedTokens:$.unpricedTokens,unpricedNote:qee($.unpricedModels),calibrated:$.calibrated,reconciled:$.reconciled}},[c,h]),U=(F,$)=>{lo(F).then(W=>{_.current&&(window.clearTimeout(S.current),j({path:F,label:$,ok:W}),S.current=window.setTimeout(()=>{_.current&&j(null)},ste))})},q=F=>N!=null&&N.ok&&N.path===F?"Copied":"Copy",M=c!=null&&c.trackedSince?`Tracked since ${_y(c.trackedSince)}`:"Tracking starts with this version",I=i1(d),E=Qee(d),D=b&&!!c;return xt.createPortal(r.jsx("div",{className:"modal-backdrop",...A,role:"presentation",children:r.jsxs("div",{ref:L,className:"modal ap-proj-modal",onClick:F=>F.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:tte.map(F=>r.jsx("button",{type:"button",className:"uh-range-btn","aria-pressed":s===F.days,onClick:()=>a(F.days),children:F.label},F.days))}),r.jsx("button",{ref:T,className:"glyph-btn ap-proj-close",onClick:n,"aria-label":"Close",children:"×"})]}),r.jsxs("div",{className:`ap-proj-body${D?" refreshing":""}`,"aria-busy":b,children:[b&&!c&&r.jsx(Dee,{}),!b&&k&&r.jsxs("div",{className:"ap-proj-state ap-proj-error",children:["Couldn’t load this report: ",k]}),!k&&O&&r.jsx("div",{className:"ap-proj-ready",children:O.rows.length===0?r.jsxs("div",{className:"ap-proj-state",children:[D?"Updating…":Jee(d),E!=null&&r.jsx("div",{className:"ap-proj-widen-wrap",children:r.jsxs("button",{type:"button",className:"ap-proj-copy",onClick:()=>a(E),children:["Show ",i1(E)]})}),r.jsxs("div",{className:"ap-proj-note",children:[M,". 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 ${O.basis==="cost"?st(O.totalCost):`${wt(O.totalTokens)} tokens`} across ${O.projectCount} project${O.projectCount>1?"s":""}`,children:O.rows.map(F=>{const $=O.basis==="cost"?F.cost:F.tokens,W=O.denom>0?$/O.denom*100:0;if(W<=0)return null;const Z=O.basis==="cost"?Bh(F.cost,O.totalCost):`${Bh(F.tokens,O.totalTokens)} of tokens`;return r.jsx("span",{className:"ap-proj-seg",style:{width:`${W}%`,background:F.color},title:`${F.label} · ${gr(F.cost,F.unpricedTokens)} · ${Z}${F.tokens?` · ${wt(F.tokens)} tokens`:""}`},F.key)})}),r.jsxs("div",{className:"ap-proj-totals",children:[r.jsx("span",{className:"ap-proj-total-cost",title:Yi(O.unpricedTokens),children:gr(O.totalCost,O.unpricedTokens)}),r.jsxs("span",{className:"ap-proj-total-tok",children:[wt(O.totalTokens)," tokens"]}),r.jsxs("span",{className:"ap-proj-total-win",children:["· ",D?"updating…":I]}),f&&r.jsx("span",{className:"ap-proj-total-pending",children:"Reconciling cost…"})]}),O.unpricedNote&&r.jsx("div",{className:"ap-proj-note",children:O.unpricedNote}),ete(d,O.chart.length)&&r.jsxs("div",{className:"ap-proj-days",children:[r.jsxs("div",{className:"ap-proj-days-cap",children:["By day",O.chart.length>1?" · click a bar":""]}),r.jsx("div",{className:"ap-proj-days-plot",role:"group","aria-label":`Spend across ${O.chart.length} day${O.chart.length>1?"s":""}`,children:O.chart.map(F=>{const $=O.maxDay>0?F.total/O.maxDay*100:0,W=p===F.day,Z=O.rows.map(Y=>({label:Y.label,c:F.costByColor.get(Y.color)??0,u:F.unpricedByColor.get(Y.color)??0})).filter(Y=>Y.c>0||Y.u>0),V=`${_y(Date.parse(`${F.day}T00:00:00`))}, ${gr(F.total,F.unpriced)}. ${Z.map(Y=>`${Y.label} ${gr(Y.c,Y.u)}`).join(", ")}`;return r.jsx("button",{type:"button",className:`ap-proj-day${W?" selected":""}`,"aria-pressed":W,"aria-label":V,title:`${F.day} · ${gr(F.total,F.unpriced)}`,onClick:()=>m(Y=>Y===F.day?null:F.day),children:r.jsx("span",{className:"ap-proj-col",style:{height:`${$}%`},children:O.colorOrder.map((Y,X)=>{const J=F.costByColor.get(Y)??0;return J<=0||F.total<=0?null:r.jsx("span",{className:"ap-proj-colseg",style:{height:`${J/F.total*100}%`,background:Y}},X)})})},F.day)})}),(()=>{const F=ote(O.chart.length);return r.jsx("div",{className:"ap-proj-days-axis","aria-hidden":"true",children:O.chart.map(($,W)=>r.jsx("div",{className:"ap-proj-axis-cell",children:F(W)?ate($.day):""},$.day))})})(),(()=>{const F=p?O.chart.find(W=>W.day===p):null;if(!F)return null;const $=O.rows.map(W=>({r:W,c:F.costByColor.get(W.color)??0,u:F.unpricedByColor.get(W.color)??0})).filter(W=>W.c>0||W.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:_y(Date.parse(`${F.day}T00:00:00`))}),r.jsx("span",{className:"ap-proj-day-detail-total",title:Yi(F.unpriced),children:gr(F.total,F.unpriced)})]}),$.map(({r:W,c:Z,u:V})=>r.jsxs("div",{className:"ap-proj-day-detail-row",children:[r.jsx("span",{className:"ap-proj-dot",style:{background:W.color},"aria-hidden":"true"}),r.jsx("span",{className:"ap-proj-day-detail-name",children:W.label}),r.jsx("span",{className:"ap-proj-day-detail-cost",title:Yi(V),children:gr(Z,V)})]},W.key))]})})()]}),r.jsx("ul",{className:"ap-proj-list",children:O.rows.map((F,$)=>{const W=O.basis==="cost"?F.cost:F.tokens,Z=O.denom>0?W/O.denom*100:0,V=w.has(F.key),Y=`ap-proj-details-${$}`,X=V&&(!!F.path||!!F.members),J=F.members?`${V?"Hide":"Show"} the ${F.members.length} project${F.members.length>1?"s":""} folded into Other`:`${V?"Hide":"Show"} location for ${F.label}`;return r.jsxs("li",{className:`ap-proj-row${F.muted?" muted":""}${V?" expanded":""}`,children:[r.jsx("span",{className:"ap-proj-dot",style:{background:F.color},"aria-hidden":"true"}),r.jsxs("span",{className:"ap-proj-name",children:[F.label,F.parentLabel&&r.jsxs("span",{className:"ap-proj-parent",children:[" · in ",F.parentLabel]})]}),r.jsx("span",{className:"ap-proj-track",title:O.basis==="cost"?`${Bh(F.cost,O.totalCost)} of tracked cost`:`${Bh(F.tokens,O.totalTokens)} of tracked tokens`,children:r.jsx("span",{className:"ap-proj-fill",style:{width:`${Z}%`,background:F.color}})}),r.jsx("span",{className:"ap-proj-cost",title:Yi(F.unpricedTokens),children:gr(F.cost,F.unpricedTokens)}),r.jsx("span",{className:"ap-proj-tok",children:wt(F.tokens)}),r.jsx("button",{type:"button",className:"glyph-btn ap-proj-info","aria-expanded":V,"aria-controls":X?Y:void 0,"aria-label":J,onClick:()=>v(Q=>{const te=new Set(Q);return te.has(F.key)?te.delete(F.key):te.add(F.key),te}),children:"ⓘ"}),V&&F.path&&r.jsxs("div",{className:"ap-proj-details",id:Y,children:[r.jsx("code",{className:"ap-proj-path",children:WT(F.path)}),r.jsx("button",{type:"button",className:"ap-proj-copy","aria-label":`${q(F.path)} location for ${F.label}`,onClick:()=>U(F.path,F.label),children:q(F.path)})]}),V&&F.members&&r.jsx("div",{className:"ap-proj-details ap-proj-other-members",id:Y,children:F.members.map(Q=>r.jsxs("div",{className:"ap-proj-other-member",children:[r.jsxs("div",{className:"ap-proj-other-name",children:[Q.label,Q.parentLabel&&r.jsxs("span",{className:"ap-proj-parent",children:[" · in ",Q.parentLabel]})]}),r.jsx("code",{className:"ap-proj-path",children:WT(Q.path)}),r.jsx("span",{className:"ap-proj-cost",title:Yi(Q.unpricedTokens),children:gr(Q.cost,Q.unpricedTokens)}),r.jsx("span",{className:"ap-proj-tok",children:wt(Q.tokens)}),r.jsx("button",{type:"button",className:"ap-proj-copy","aria-label":`${q(Q.path)} location for ${Q.label}`,onClick:()=>U(Q.path,Q.label),children:q(Q.path)})]},Q.path))})]},F.key)})}),O.un&&r.jsxs("div",{className:"ap-proj-unattributed",children:[r.jsx("span",{className:"ap-proj-dot",style:{background:nte},"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:Yi(O.un.unpricedTokens),children:gr(O.un.cost,O.un.unpricedTokens,rte)}),r.jsx("span",{className:"ap-proj-un-tok",children:wt(O.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:N&&(N.ok?`Copied the location of ${N.label}`:`Could not copy the location of ${N.label} — select it and copy it by hand`)}),r.jsxs("div",{className:"ap-proj-foot",children:[f?"Dollars estimated · ccusage still running":O.reconciled?"Dollars from ccusage · split by activity":O.calibrated?"Dollars from ccusage for the priced models · split by activity":h?"Dollars estimated · ccusage could not price this window":"Dollars estimated · ccusage unavailable"," · ",M]})]})})]})]})}),document.body)}function la(e,t){return nP(t-Math.floor(e/1e3))}function lte(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 rN(){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 cte({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(Hp,{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(rN,{}),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 ${la(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})]})]})})}const ute=5*6e4;function dte(e,t){return typeof e!="string"||!e?!1:e==="::1"||e==="localhost"||e.startsWith("127.")?!0:Array.isArray(t)&&t.includes(e)}function hte(e,t,n=ute){const s=new Map;if(!(e!=null&&e.enabled))return s;const a=new Set;for(const o of Array.isArray(e.peers)?e.peers:[]){if(!o||o.paired!==!0)continue;const i=o.offers,c=i!=null&&i.current&&typeof i.current.key=="string"?i.current.key:"";if(!c||typeof i.at!="number"||!Number.isFinite(i.at)||t-i.at>n||i.at-t>n||dte(o.addr,e.addrs))continue;const d=`${c}|${o.peerFp??o.fp}`;a.has(d)||(a.add(d),s.set(c,[...s.get(c)??[],o]))}return s}function mD(e){return e.length<=1?e[0]??"another deck":`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function Jc(e){return e.charAt(0).toUpperCase()+e.slice(1)}function fte(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 pte(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 mte(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 HT={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 gte(e){const t=mD(e),n=e.length>1?"are":"is";return{text:`Also active on ${t}`,hint:`${t} ${n} using this login right now as well. A Claude login renews once: whichever machine renews it first keeps it, and the other is signed out (“Login expired · Please run /login”). Use a different account on one of them. Signing in on each machine separately gives each its own login, and those do not collide.`,fix:null,tone:"warn",blocksSwitch:!1}}function si(e,t,n){var a;const s=wte(e,t);return e.active===!0&&((a=n==null?void 0:n.elsewhere)!=null&&a.length)&&(!s||s.tone!=="warn")?gte(n.elsewhere):!s||!(n!=null&&n.noCopyWorksNearby)||!yte(e)?s:{...s,text:HT.text,hint:HT.hint}}function yte(e){return e.staleCopy?!1:e.stopped?e.collector==="relogin_required":e.error==="invalid_grant"||e.error==="no_refresh_token"}function wte(e,t){if(e.staleCopy){const n=fte(e.repair??null,t);return{text:Jc(n.text),hint:n.hint,fix:null,tone:"quiet",blocksSwitch:!1}}if(e.stopped){const n=mte(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:Jc(n.text),hint:n.hint,fix:n.fix?Jc(n.fix):null,tone:s||e.collector==="keychain_unavailable"?"warn":"quiet",blocksSwitch:s}}if(e.error){const n=pte(e.error);return{text:Jc(n.text),hint:n.hint,fix:n.fixable?"Sign in again":null,tone:n.fixable?"warn":"quiet",blocksSwitch:n.fixable}}return null}function zT(e){return typeof e.id=="string"&&e.id.startsWith("scoped-")}function VT(e){const t=e.filter(c=>!zT(c)),n=e.filter(c=>zT(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 Ou(e,t){return!!e.resetAt&&e.resetAt<=t}function aN(e,t){return(e.lanes??[]).some(s=>Ou(s,t))?null:e.headroom}const xte="\0";function bs(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}${xte}${n}`}function vte(e,t,n=bs){const s=n(t);return e.includes(s)?e.filter(a=>a!==s):[...e,s]}const zp="slot",oN=[{lane:"five_hour",name:"5h"},{lane:"seven_day",name:"7d"}],gD=e=>e.id.startsWith("scoped-");function bte(e){var t;return((t=oN.find(n=>n.lane===e.id))==null?void 0:t.name)??e.label}function kte(e){if(e==="room")return"room";const t=/^(.+):(full|empty)$/.exec(e);return t?t[1]:null}function yD(e){const t=[...new Set(e.flatMap(s=>(s.lanes??[]).filter(gD).map(a=>a.label)))].sort((s,a)=>s.localeCompare(a)),n=[...oN.map(s=>s.name),...t];return[{id:zp,label:"Slot"},...n.flatMap(s=>[{id:`${s}:full`,label:`${s} · fullest`},{id:`${s}:empty`,label:`${s} · emptiest`}]),{id:"room",label:"Most room"}]}function GT(e,t,n){const s=oN.find(o=>o.name===t),a=(e.lanes??[]).find(o=>s?o.id===s.lane:gD(o)&&o.label===t);return a&&n!=null&&Ou(a,n)?null:a&&Number.isFinite(a.pct)?a.pct:null}function wD(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:aN(p,s);return o(KT(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=>GT(f,c,s)!=null))return a;const h=KT(a,f=>GT(f,c,s),d==="full"?"desc":"asc");return d==="empty"?o(h):h}function KT(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 xD(e,t){return yD(t).some(n=>n.id===e)?e:zp}function l1(e,t){if(!t)return[...e];const n=new Map(t.map((o,i)=>[o,i])),s=e.filter(o=>n.has(bs(o))).sort((o,i)=>n.get(bs(o))-n.get(bs(i))),a=e.filter(o=>!n.has(bs(o)));return[...s,...a]}function iN(e){const t=bs(e);return t.startsWith("slot:")?t:`h:${jte(t)}`}function jte(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 c1={mode:"some",keys:[]};function vD(e,t){const n=e.keys.includes(iN(t));return e.mode==="all"?!n:n}function Nte(e,t){return{mode:e.mode,keys:vte(e.keys,t,iN)}}function bD(e,t){return t.length>0&&t.every(n=>vD(e,n))}function Ste(e,t){return bD(e,t)?c1:{mode:"all",keys:[]}}function _te(e,t){if(!Array.isArray(t))return e;const n=new Set(t.map(iN)),s=e.keys.filter(a=>n.has(a));return s.length===e.keys.length?e:{mode:e.mode,keys:s}}const Vo=[{id:"five_hour",label:"5h",long:"5-hour"},{id:"seven_day",label:"7d",long:"7-day"}];function YT(e){return e.counted?e.pct:e.why==="login"?null:e.estimate}function Cte(e){const t=YT(e.five_hour),n=YT(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 Ete(e,t){const n=Vo.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:la(e.updatedAt,t),old:!0}}const kD=15*6e4;function Vp(e){return e!=null&&e>0&&Number.isFinite(e)&&Number.isFinite(new Date(e).getTime())?e:null}const jD=e=>e.alias??e.email??`account ${e.num}`;function cu(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 u1(e,t,n){const s=Vo.find(w=>w.id===t).label,a=(e.lanes??[]).find(w=>w.id===t),o=a&&Number.isFinite(a.pct)?ND(a.pct):null,i=si(e,n),c=cu(e,t),d=c!=null&&c<=n,h=SD(a,e.fetchedAt,n),f=(w,v)=>({counted:!1,why:w,say:v,last:o,estimate:o,resetAt:d?null:cu(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=Vp(e.fetchedAt);return e.stale||e.staleCopy===!0||e.stopped===!0||p==null||n*1e3-p>kD?f("stale",p!=null?`Updated ${la(p,n)}`:"Never read"):{counted:!0,pct:o,resetAt:cu(e,t)}}const ND=e=>Math.min(100,Math.max(0,e));function SD(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=Vp(t),a=s!=null?`read ${la(s,n)}`:"last read";return`Reported reset time passed ${la(e.resetAt*1e3,n)}, ${so(ND(e.pct))}% when ${a}`}function Tte(e,t){const n=Vo.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 lN(e,t){const n=e.map(a=>{const o={five_hour:u1(a,"five_hour",t),seven_day:u1(a,"seven_day",t)};return{num:a.num,key:bs(a),name:jD(a),active:a.active,heldOut:a.disabled===!0,cells:o,resets:{five_hour:cu(a,"five_hour"),seven_day:cu(a,"seven_day")},status:Cte(o),updatedAt:Vp(a.fetchedAt)}}),s=n.filter(a=>a.status==="ready").length;return{rows:n,windows:Vo.map(a=>Tte(n,a.id)),roomInBoth:s}}function qc(e,t){return(e==null?void 0:e.key)===t?{key:t,dir:e.dir==="asc"?"desc":"asc"}:{key:t,dir:"asc"}}const Ate={ready:0,limited:1,exhausted:2,stale:3};function Rte(e){return e.counted?e.pct:e.reset?e.estimate:e.last}function XT(e,t){return t==="status"?Ate[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:Rte(e.cells[t])}function Mte(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=XT(o,t.key),d=XT(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 so(e){return e>=100?100:Math.min(99,Math.round(e))}function $te(e){const t=so(e);return{used:t,available:100-t}}function Lte(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 _D=new Set(["awaiting_url","awaiting_code","registering"]);function CD(e){return e!=null&&_D.has(e)}function ED(e){return e!=null&&e!=="done"&&!_D.has(e)}const TD="the sign-in ended before it finished — the deck restarted, or it was cancelled in another tab",Ite="the sign-in did not complete";function Ote({state:e,serverError:t,localError:n}){const s=e==="idle";return{title:s?"Sign-in ended":"Sign-in failed",message:n||t||(s?TD:Ite)}}function ZT({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 JT({started:e,state:t}){return!e||t==="done"?null:{action:"login-cancel"}}function Pte({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":ED(e==null?void 0:e.state)||n&&t&&!s?"ended":s||CD(e==null?void 0:e.state)?"asking":"primer"}function cN(e,t){return t?Kt(e,t):void 0}const Dte={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"},Fte={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"},uN=`claude-swap could not read the login keychain — start ${Rt} from a Terminal window rather than a background service`,Bte={unreadable_here:{short:"Keychain locked on this Mac",long:`${uN}.`},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 Zf(e){return e?Kt(Bte,e)??null:null}const AD={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 d1(e,t,n){const s=n==null?null:AD[n];if(s)return s;if((e==null?void 0:e.reason)!=="no_cswap"&&/keychain/i.test(Pu(e)))return uN;const a=cN(Fte,e==null?void 0:e.reason);return a||(e==null?void 0:e.reason)||t}function Pu(e){return((e==null?void 0:e.output)||(e==null?void 0:e.detail)||(e==null?void 0:e.error)||"").trim()}const qte={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"},Ute="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 Wte(e){return/\bnpx\b/i.test(e)&&/(command not found|not found|not recognized|ENOENT)/i.test(e)}const Hte="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",zte="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",Vte=e=>/\b(?:ERR_)?MODULE_NOT_FOUND\b|cannot find (?:module|package)/i.test(e),Gte=/node_modules[\\/]npm[\\/]bin[\\/]|\bnpm-prefix\.js\b|\bnp[mx][-.][\w.-]*cli\.js\b/i,Kte=/[\\/]_npx[\\/]/i,Yte=`the copy of ccusage ${Rt} installed for itself`;function Xte(e){const t=String((e==null?void 0:e.install)??"").replace(/\s+/g," ").trim();return t.length>240?`${t.slice(0,239)}…`:t}function Fke(e,t){const n=Zte(e,t),s=Xte(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 ${Uc(n)}`:`there is no managed copy of ccusage on this machine, and the npx fallback failed: ${Uc(n)}`;case"managed":return`${Yte} failed to run: ${Uc(n)}`;case"path":return e.bin?`the ccusage this deck found at ${e.bin} failed to run: ${Uc(n)}`:`the ccusage this deck found on your PATH failed to run: ${Uc(n)}`;default:return n}}const Uc=e=>/^[A-Z][a-z]/.test(e)?e[0].toLowerCase()+e.slice(1):e;function Zte(e,t){const n=Pu(e);if(Vte(n)){if(Kte.test(n))return zte;if(Gte.test(n))return Hte}if(Wte(n))return Ute;const s=cN(qte,e==null?void 0:e.reason);return s||(e==null?void 0:e.reason)||t}function il(e,t,n){const s=n==null?null:AD[n];if(s)return s;if(e!=null&&e.detail)return e.detail;if(e!=null&&e.error&&ED(e.state))return e.error;const a=cN(Dte,e==null?void 0:e.reason);return a||(e!=null&&e.error?e.error:(e==null?void 0:e.reason)||t)}function kr(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 Jte={keychain_unavailable:{short:"Keychain locked on the other Mac",long:`the other Mac could not export it. On that Mac: ${uN}. 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 h1(e){return e.why?Kt(Jte,e.why)??Zf(e.why):null}const dN={"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"}},Qte={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 QT(e){var s;const t=ene[e];if(t)return t;const n=(s=/\b(E[A-Z]{3,})\b/.exec(e))==null?void 0:s[1];return n&&Qte[n]||e}const ene={"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 Gp(e,t){var f;if(!e)return null;if(e.error&&((f=e.done)!=null&&f.length)){const p=Gp({...e,error:void 0},t),m=` · ${kr(e.at,t)}`;return{...p,text:`${p.text.slice(0,-m.length)}, then ${QT(e.error)}${m}`,tone:"bad"}}if(e.error)return dN[e.error]??{text:QT(e.error),tone:"bad"};const n=e.done??[];if(!n.length)return{text:`all logins fine · ${kr(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:h1(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=kr(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 tne=9e4;function nne({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<tne);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 Kp(e,t){var n,s;return(n=e.last)!=null&&n.error&&!dN[e.last.error]?!1:!!((s=e.last)!=null&&s.at&&t-e.last.at<f1||e.lastSeen!=null&&t-e.lastSeen<f1)}const f1=95e3;function sne(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?RD(p.lastSeen,t):Kp(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 $D(s,m=>fN(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 rne(e,t,n){if(n)return"checking…";if(e==null)return"not checked yet";const s=kr(e,t);return s==="now"?"checked just now":`checked ${s}`}function hN(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 RD(e,t){return e!=null&&t-e<f1}function ane(e,t){if(e==null)return{text:"one-way · has not called yet",here:!1};const n=RD(e,t);return{text:n?"online · one-way, it calls in":`one-way · last online ${kr(e,t)}`,here:n}}function eA(e,t,n){return t?"online":e.lastSeen!=null?`last online ${kr(e.lastSeen,n)}`:e.waiting?"has not called yet":"never reached"}function one(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(ine(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(lne(p,m,t)):i.push(cne(p,m,o,t)))}n.push(...hne(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(une(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(dne(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 ine(e,t,n){const s=Yp(t,e.fp,e.name||e.fp);return{fp:e.fp,...s,addr:e.addr??"",kind:"asks",state:`wants to pair · ${hN(e.at,n)}`,tone:"wait",here:!0,hint:`${s.name} at ${e.addr}${e.via==="tailscale"?", over Tailscale,":""} is waiting for an answer.`,...Xp(e.via)}}function lne(e,t,n){var o;const s=Gp(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?p1(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.`,...Xp(e.via)}}function cne(e,t,n,s){var w,v,b,k;const a=Gp(e.last,s),o=Kp(e,s),i=e.addr?`${e.addr}:${e.port}`:"",c=e.waiting?ane(e.lastSeen,s):null,d=c?c.here:o,h=!c&&a?d?`online · ${p1(a)}`:`${p1(a)} · ${eA(e,d,s)}`:c?c.text:eA(e,d,s),f=(w=e.last)!=null&&w.error?dN[e.last.error]:null,p=!c&&d&&!((v=e.last)!=null&&v.error)&&!(((b=e.last)==null?void 0:b.done)??[]).length,m=fN(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,...Xp(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 ${kr(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}`:""}${(k=e.last)!=null&&k.error?` — ${e.last.error}`:""}${a!=null&&a.hint?` — ${a.hint}`:""}`}}function fN(e,t,n){return e.manual&&!e.met?{name:e.addr?`${e.addr}:${e.port}`:""}:Yp(n,t,e.name||t)}function MD(e,t){return fN(e,e.peerFp??e.fp,t).name}function une(e,t,n){const s=Yp(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.`,...Xp(e.via)}}function dne(e,t){const n=Yp(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 Yp(e,t,n){const s=t?e[t]:void 0;return s&&s!==n?{name:s,self:n}:{name:n}}function Xp(e){return e==="tailscale"?{via:"tailscale"}:{}}function p1(e){return e.text.replace(/ · .*$/,"")}function hne(e){return $D(e,t=>t.name,t=>t.addr).map(fne)}function $D(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 fne(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 tA(e,t){return t?e.map(n=>t[n.fp]?{...n,name:t[n.fp]}:n):e}function Du(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 pne(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 mne(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 nA(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 gne(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 yne(e,t,n){if(!(t!=null&&t.enabled))return!1;const s=(t.peers??[]).filter(o=>o.paired&&Kp(o,n));if(s.some(o=>{var i,c,d;return wne((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 wne=e=>!!e&&typeof e=="object"&&e.hidden===!0;function xne(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||!Kp(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 vne(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=>MD(s,t.aliases??{})).filter(Boolean);return[...new Set(n)].sort((s,a)=>s.localeCompare(a))}function bne(e,t,n){const s=hte(t,n).get(e);if(!(s!=null&&s.length))return null;const a=s.map(o=>MD(o,(t==null?void 0:t.aliases)??{})).filter(Boolean);return[...new Set(a)].sort((o,i)=>o.localeCompare(i))}function kne(e,t){return e.flatMap(n=>{const s=vne(n.key,t);return s?[[n.key,{to:s,inUse:n.inUse===!0}]]:[]})}function sA(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."}const LD={OTEL_LOG_USER_PROMPTS:"prompts",OTEL_LOG_ASSISTANT_RESPONSES:"responses",OTEL_LOG_TOOL_DETAILS:"tool details",OTEL_LOG_TOOL_CONTENT:"tool output",OTEL_LOG_RAW_API_BODIES:"full API bodies"};function Jf(e){return e.length<=1?e.join(""):`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function jne(e,t,{holdOut:n=!1}={}){if(!e||e.level!=="metrics"&&e.level!=="content")return null;const s=e.level==="content"?e.content.map(c=>LD[c]??c):[],a=e.orgName?e.orgName:"This account's organization",o=s.length?`usage data, and your ${Jf(s)}`:"usage data",i=e.destinations.length?Jf(e.destinations):"its collector";return{text:`Telemetry · ${s.length?s.join(", "):"usage data"}`,tone:s.length?"warn":"quiet",detail:`${a} turns on Claude Code telemetry for new sessions: ${o}, sent to ${i}. Seen ${la(e.seenAt,t)}, while this account was active.`+(n?" To keep Auto-switch off it, choose Hold out of rotation in its ⋯ menu.":"")}}function Nne(e){if(!e||e.level!=="metrics"&&e.level!=="content")return null;const t=e.level==="content"?e.content.map(o=>LD[o]??o):[],n=t.length?`your ${Jf(t)}`:"usage data",s=e.orgName?`${e.orgName}'s telemetry`:"Its organization's telemetry",a=e.destinations.length?` to ${Jf(e.destinations)}`:"";return`${s} is on for them: it sends ${n}${a}.`}function Sne(e){return e>=90?"hi":e>=70?"mid":void 0}function _ne({lane:e,nowSec:t,readAt:n,frozen:s,sortedBy:a}){const o=Math.min(100,Math.max(0,e.pct)),i=Ou(e,t),c=s||i,d=c?"var(--muted)":o>=90?"var(--err)":o>=70?"var(--warn)":"var(--accent)",h=e.resetAt&&!c?Gu(e.resetAt,t):null,f=i?SD(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 Cne({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:v,swapped:b,displaced:k,issueExpanded:N,onOpenIssue:j,sortKey:S=null,home:_=null,rotating:T=!1}){const L=e.lanes.filter(z=>!Ou(z,t)),{shown:A}=VT(e.lanes),{fuller:P}=VT(L),O=S==="room"?L.reduce((z,F)=>z&&z.pct>=F.pct?z:F,null):S?e.lanes.find(z=>bte(z)===S)??null:null,U=si(e,t,n),q=e.active||s,M=e.alias??e.email??`account ${e.num}`,I=e.alias&&e.email?`${e.alias} · ${e.email}`:M,E=e.stale||(U==null?void 0:U.blocksSwitch)===!0,D=P?[...A,P]:A,B=e.fetchedAt?la(e.fetchedAt,t):null,H=jne(e.telemetry,t,{holdOut:T&&!e.active&&!e.disabled}),G=Nne(e.telemetry);return r.jsxs("li",{className:`ap-account${e.active?" active":""}`,"aria-current":e.active?"true":void 0,"data-open":q?"":void 0,"data-frozen":E?"":void 0,children:[!e.active&&r.jsx("button",{type:"button",className:"ap-row-open",id:`ap-row-${e.num}`,title:I,"aria-expanded":q,"aria-controls":q?`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,!q&&!(U!=null&&U.blocksSwitch)?`ap-quota-${e.num}`:null,H?`ap-telemetry-${e.num}`:null].filter(Boolean).join(" ")||void 0,onClick:()=>a(),children:r.jsxs("span",{className:"vis-hidden",children:[M,", ",q?"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:sA(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:sA(n.sharedTo,n.sharedInUse)})]}),e.disabled&&r.jsx("span",{className:"ap-held",children:"held out"}),!e.active&&!e.disabled&&!(U!=null&&U.blocksSwitch)&&r.jsx("button",{type:"button",className:"ap-switch",...i(`switch-${e.num}`),onClick:()=>c(e.num,M),"aria-label":`Switch to ${M}`,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:z=>{z.key!=="ArrowDown"&&z.key!=="ArrowUp"||(z.preventDefault(),h(e.num,z.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??M}`,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&&v&&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."}),e.active&&v&&G&&r.jsx("p",{className:"ap-switched",children:G}),b&&(()=>{const z=(k==null?void 0:k.alias)??(k==null?void 0:k.email)??"the account that was there";return r.jsxs("p",{className:"ap-note ap-swap-note",title:`Slot ${b.at} was taken, so the two accounts traded places: ${z} now holds slot ${b.displaced}.`,children:["swapped with slot ",b.displaced]})})(),U&&r.jsxs("div",{className:"ap-issue-line",children:[r.jsxs("button",{type:"button",id:`ap-issue-${e.num}`,className:"ap-issue","data-tone":U.tone,"aria-haspopup":"dialog","aria-expanded":N,"aria-controls":N?"ap-issue-pop":void 0,onClick:()=>j(e.num,`ap-issue-${e.num}`),children:[U.tone==="warn"&&r.jsx(rN,{}),r.jsx("span",{className:"ap-issue-text",children:U.text})]}),!q&&r.jsx("span",{className:"ap-issue-age",title:"When claude-swap last read this account's usage",children:B??"never collected"})]}),H&&r.jsxs("p",{className:"ap-telemetry",id:`ap-telemetry-${e.num}`,"data-tone":H.tone,title:H.detail,children:[r.jsx("span",{"aria-hidden":!0,children:H.text}),r.jsx("span",{className:"vis-hidden",children:H.detail})]}),!q&&!(U!=null&&U.blocksSwitch)&&r.jsxs("p",{className:"ap-quota",id:`ap-quota-${e.num}`,children:[D.length?D.map(z=>r.jsxs("span",{className:"ap-q","data-sort-key":z.id===(O==null?void 0:O.id)?"":void 0,children:[r.jsx("span",{className:"ap-q-label",children:z.label})," ",Ou(z,t)?r.jsx("span",{className:"ap-q-pct",title:`${z.label} has reset since this reading`,children:"reset"}):r.jsxs("span",{className:"ap-q-pct","data-level":E?void 0:Sne(z.pct),children:[Math.round(z.pct),"%"]})]},z.id)):r.jsx("span",{className:"ap-q-label",children:"no usage recorded yet"}),e.stale&&!U&&r.jsx("span",{className:"ap-q-age","data-never":B?void 0:"",title:"When claude-swap last read this account's usage",children:B??"never collected"})]}),q&&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(z=>r.jsx(_ne,{lane:z,nowSec:t,readAt:e.fetchedAt,frozen:E,sortedBy:z.id===(O==null?void 0:O.id)},z.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&&!U?" 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 ",la(e.fetchedAt,t),U!=null&&U.blocksSwitch?"":lte(e.nextAt,t)]}):r.jsx("span",{className:"ap-age ap-stale",title:"claude-swap has not read this account yet",children:"never collected"})})]})]})}function Ene({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 Tne({canShare:e,onAdd:t,onShareSet:n,onReload:s,pressProps:a,reloading:o,closeButton:i}){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:()=>t(),"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"})})}),e&&r.jsx("button",{type:"button",className:"glyph-btn",onClick:()=>n(),"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:()=>s(),...a("reload",o),"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"})]})}),i]})]})}const Ane=[{value:"room",label:"Most room left"},{value:"weekly",label:"Soonest weekly reset"}],Rne="Uses up quota that resets within 4 days first";function Mne(e){return e==="room"||e==="weekly"}function Cy(e,t){return!t||!e.email?!1:e.email.trim().toLowerCase()===t.email.trim().toLowerCase()&&(e.orgUuid??"")===(t.orgUuid??"")}function $ne(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 Ey=[70,80,85,90,95],ID="custom",tl=50,nl=99,Lne=`A whole percent from ${tl} to ${nl}.`;function Ine(e){const t=Number(e);return[...Number.isFinite(t)&&t>0&&!Ey.includes(t)?[...Ey,t]:Ey].sort((s,a)=>s-a)}function One(e){const t=e.trim().replace(/\s*%$/,"");if(t==="")return{ok:!1,reason:"empty",message:`Enter a number from ${tl} to ${nl}.`};if(!/^\d+(\.\d*)?$|^\.\d+$/.test(t))return{ok:!1,reason:"not_a_number",message:`Enter a number from ${tl} to ${nl}.`};const n=Number(t);return Number.isInteger(n)?n<tl?{ok:!1,reason:"too_low",message:`The lowest is ${tl}%.`}:n>nl?{ok:!1,reason:"too_high",message:`The highest is ${nl}%.`}:{ok:!0,value:String(n)}:{ok:!1,reason:"not_whole",message:`Use a whole number from ${tl} to ${nl}.`}}const m1={pick:null,custom:null,refusal:null};function Pne(e,t){switch(t.kind){case"pick":return t.pick===ID?{...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 m1;case"leave":return e.custom&&(e.pick??t.stored)===t.stored?m1:e}}async function Dne(e,t,n){if(!t.sends)return{kind:"unchanged"};const s=One(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 Fne({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:v,nextPick:b,nextCtl:k,nextSaved:N,nextRef:j,nextSaveRef:S,proposeNext:_,doNext:T,pressProps:L,post:A,load:P}){const O=y.useId(),U=y.useId(),q=y.useId(),M=y.useId();return r.jsxs("div",{className:"ap-policy-block",children:[r.jsxs("div",{className:"ap-policy",children:[r.jsx("h3",{className:"ap-auto-title",children:"Auto-switch"}),r.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":e.enabled,"aria-label":"Auto-switch",...L("enable"),onClick:()=>A({action:"enable",enabled:!e.enabled},"enable").then(()=>P(!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"})})]}),r.jsxs("div",{className:"ap-policy ap-setting",onKeyDown:c?m:void 0,children:[r.jsx("label",{className:"ap-setting-label",htmlFor:U,title:"Switch once the active account passes this much of its limit",children:"Switch at"}),c?r.jsx("form",{className:"ap-threshold-form",noValidate:!0,onSubmit:I=>{I.preventDefault(),v(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,id:U,className:"ap-manage-input ap-threshold-input",type:"text",inputMode:"numeric","aria-describedby":O,"aria-invalid":d?!0:void 0,value:n,...L("threshold"),onChange:I=>p(I.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,id:U,value:n,...L("threshold"),onChange:I=>f(I.target.value),children:[Ine(t).map(I=>r.jsxs("option",{value:I,children:[I,"%"]},I)),r.jsx("option",{value:ID,children:"Custom…"})]})}),(s.sends||a)&&r.jsx("button",{ref:i,type:"button",className:"ap-manage-btn",...L("threshold"),title:s.title,onClick:()=>v(n,s),children:a&&!s.sends?s.done:s.label})]}),d?r.jsx("p",{id:O,className:"ap-threshold-note",role:"alert","data-tone":"err",children:d},"refusal"):c?r.jsx("p",{id:O,className:"ap-threshold-note",children:Lne},"hint"):null,r.jsxs("div",{className:"ap-policy ap-setting ap-next",children:[r.jsx("label",{className:"ap-setting-label",htmlFor:q,children:"Next account"}),r.jsx("span",{className:"ap-field",children:r.jsx("select",{id:q,ref:j,value:b,"aria-describedby":b==="weekly"?M:void 0,...L("next"),onChange:I=>_(I.target.value),children:Ane.map(I=>r.jsx("option",{value:I.value,children:I.label},I.value))})}),(k.sends||N)&&r.jsx("button",{ref:S,type:"button",className:"ap-manage-btn",...L("next"),title:k.title,onClick:()=>T(),children:N&&!k.sends?k.done:k.label})]}),b==="weekly"&&r.jsx("p",{id:M,className:"ap-threshold-note",children:Rne}),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 rA=18,Bne=1100,Zi=(e,t)=>{const n=Math.sin(e*12.9898+t*78.233)*43758.5453;return n-Math.floor(n)},qne=Array.from({length:rA},(e,t)=>{const n=-72+144*t/(rA-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 aA({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),Bne);return()=>window.clearTimeout(c)},[e,s]),s||!t?null:xt.createPortal(r.jsx("div",{className:"confetti",style:{left:`${t.x}px`,top:`${t.y}px`},"aria-hidden":!0,children:qne.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 Qf=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"})]}));Qf.displayName="SuccessMark";const Une={done:", done",active:", in progress",failed:", failed",pending:""};function Wne({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 Hne({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(Wne,{status:i.status}),r.jsxs("span",{className:"aa-stage-label",children:[i.label,r.jsx("span",{className:"vis-hidden",children:Une[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 Ty=["link","approve","confirm","save"],oA={confirm:"confirm",save:"save",restore:"save"};function OD(e){return e!=null&&Object.prototype.hasOwnProperty.call(oA,e)?oA[e]:null}function zne({state:e,step:t,starting:n}){return e==="registering"?OD(t)??"confirm":e==="awaiting_code"?"approve":e==="awaiting_url"||e==null&&n?"link":null}function Vne({state:e,step:t,url:n,lastLive:s}){return e==="failed"?OD(t)??(n?"approve":"link"):e==="idle"?s??"link":"link"}const Gne={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 Kne(e,t,n){return t==="failed"?PD(e,n):Gne[e][t]}function Yne({live:e=null,failed:t=null,done:n=!1,state:s=null}){const a=n?Ty.length:Ty.indexOf(t??e);return Ty.map((o,i)=>{const c=n||i<a?"done":i>a||a<0?"pending":t?"failed":"active";return{id:o,status:c,label:Kne(o,c,s)}})}function Xne(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 Zne={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 PD(e,t){return t==="idle"?"Sign-in ended":Zne[e]}const Jne=/^(?:claude|claude-swap|cswap|ccdeck|npm|uv)\b/;function hf(e){const t=String(e??"").trim();if(!t)return"";const n=Jne.test(t)?t:t[0].toUpperCase()+t.slice(1);return/[.!?…]$/.test(n)?n:`${n}.`}hf(TD);const Qne=1e4,ese=1e4,tse=5;function nse({since:e,now:t,expiresAt:n}){if(e==null||t-e<Qne)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<=tse?`${a} — the sign-in stays open ${s} more minute${s===1?"":"s"}.`:`${a}.`}function sse({since:e,now:t}){return e==null||t-e<ese?null:"Still importing. claude-swap stops by itself after a minute if it cannot finish."}function rse(e){return e==="registering"?400:1500}const DD=460;function ase({fromStages:e,reducedMotion:t}){return e&&!t?DD:0}function ose({added:e,reducedMotion:t}){return e&&!t}function iA({num:e,added:t}){return t?e!=null&&e!==""?`Account ${e} added`:"Account added":"Credentials refreshed"}function ise(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 lse="done";function cse(){let e=!1;return{shouldAnnounce(t){return t!==lse?(e=!1,!1):e?!1:(e=!0,!0)}}}function pN(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"}}}function FD(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 use(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 dse(e,t){return e.filter(n=>!t.includes(n.num)).map(n=>n.num)}function hse(e,t){return e.includes(t)?e.filter(n=>n!==t):[...e,t]}function fse(e){return e.length?{action:"share",accounts:[...e]}:null}function pse(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 g1(e){return`${e.email}|${e.org??""}`}function mse(e,t,n){return e&&e.map(s=>g1(s)===t?n:s)}function gse(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 lA(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=Zf(f.check))==null?void 0:p.short}).filter(f=>!!f))];return`${s.join(", ")}${h.length?`, ${h.join(", ")}`:""}.`}function yse(e){try{return e?new URL(e).host:""}catch{return""}}const qh=[{id:"login",label:"Sign in"},{id:"paste",label:"Paste a share"}],cA="aa-panel",uA=e=>`aa-tab-${e}`;async function Mo(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}function BD({onClose:e,onChanged:t,email:n=null,onSignedIn:s}){tn("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),[v,b]=y.useState(!1),[k,N]=y.useState(null),[j,S]=y.useState(null),_=m||v,[T,L]=y.useState(null),[A,P]=y.useState(null),[O,U]=y.useState(null),q=y.useRef(""),M=y.useRef(!1),I=y.useRef(!1),E=y.useRef(null),D=y.useRef(null),B=y.useRef(null),H=y.useRef(null),G=y.useRef([]),z=y.useRef(!1),F=y.useRef(0),$=y.useRef(null),W=y.useRef("primer"),Z=y.useRef(null),V=y.useRef(null),Y=y.useRef(null),X=y.useRef(!1),J=y.useState(Hu)[0],[Q,te]=y.useState(null),[ce,ue]=y.useState(!1),[ie,re]=y.useState(()=>Date.now()),[fe,ae]=y.useState(null),[je,me]=y.useState(null),[pe,xe]=y.useState(null),_e=y.useCallback(()=>{const Ce=JT({started:M.current,state:i==null?void 0:i.state});Ce&&Mo(Ce).catch(()=>{}),e()},[e,i==null?void 0:i.state]),ye=ft(_e,{focusRef:B}),Ie=mt(_e),Pe=y.useCallback(async()=>{if(!bn(I.current))return;const Ce=++F.current;I.current=!0,w(!0),N(null),xe(null),M.current=!0;let Re=await Mo(n?{action:"login",email:n}:{action:"login"}).catch(()=>null);if(n&&(Re==null?void 0:Re.reason)==="bad_email"&&Ce===F.current&&(Re=await Mo({action:"login"}).catch(()=>null)),Ce===F.current){if(I.current=!1,w(!1),!(Re!=null&&Re.ok)){N(il(Re,"could not start the sign-in"));return}c(Re)}},[n]);y.useEffect(()=>{if(!CD(i==null?void 0:i.state))return;const Ce=window.setInterval(async()=>{try{const Re=await fetch("/api/claude-accounts/login");Re.ok&&c(await Re.json())}catch{}},rse(i==null?void 0:i.state));return()=>window.clearInterval(Ce)},[i]);const Ue=y.useCallback(async()=>{const Ce=JT({started:M.current,state:i==null?void 0:i.state});if(F.current+=1,M.current=!1,I.current=!1,w(!1),N(null),c(null),h(""),ue(!1),X.current=!0,!Ce)return;const Re=await Mo(Ce).catch(()=>null);xe(ZT({restored:Re==null?void 0:Re.restored,activeAccount:Re==null?void 0:Re.activeAccount}))},[i==null?void 0:i.state]),$e=y.useCallback(()=>{M.current=!1,c(null),N(null),h(""),ue(!1),Pe()},[Pe]),Je=y.useRef(t);Je.current=t;const Qe=y.useState(cse)[0];y.useEffect(()=>{Qe.shouldAnnounce(i==null?void 0:i.state)&&Je.current()},[i==null?void 0:i.state,Qe]),y.useEffect(()=>{var Ce;ce&&((Ce=E.current)==null||Ce.focus())},[ce]);const ze=y.useRef(s);ze.current=s;const Ne=y.useRef(null);y.useEffect(()=>{var He;const Ce=(i==null?void 0:i.state)==="done"?i.account:null,Re=Ce?`${Ce.num??""}|${Ce.email}`:null;!Ce||Ne.current===Re||(Ne.current=Re,(He=ze.current)==null||He.call(ze,Ce))},[i]),y.useEffect(()=>{var Ce;a==="paste"&&!z.current&&((Ce=D.current)==null||Ce.focus()),z.current=!1},[a]);const Ae=y.useCallback(Ce=>{var He;const Re=pN(Ce,qh.findIndex(vt=>vt.id===a),qh.length);Re.kind!=="pass"&&(Ce.preventDefault(),z.current=!0,o(qh[Re.index].id),(He=G.current[Re.index])==null||He.focus())},[a]),qe=y.useCallback(async()=>{var He;if(!bn(I.current))return;const Ce=F.current;I.current=!0,w(!0),N(null);const Re=await Mo({action:"login-code",code:d}).catch(()=>null);if(Ce===F.current){if(I.current=!1,w(!1),!(Re!=null&&Re.ok)){N(il(Re,"the code was not accepted")),Re!=null&&Re.state&&c(Re),(He=E.current)==null||He.select();return}h(""),c(Re)}},[d,i]),et=y.useCallback(async()=>{if(!bn(I.current))return;I.current=!0,b(!0),S(null);const Ce=await Mo({action:"import",blob:f}).catch(()=>null);if(I.current=!1,b(!1),!(Ce!=null&&Ce.ok)){S(il(Ce,"the import failed"));return}q.current=f,p(""),U(null),L(Ce.results??[]),t()},[f,t]),ot=y.useCallback(async Ce=>{const Re=g1(Ce);if(!bn(I.current)||!q.current)return;I.current=!0,b(!0),P(Re),U(null);const He=await Mo({action:"import",blob:q.current,force:!0,only:{email:Ce.email,org:Ce.org??""}}).catch(()=>null);if(I.current=!1,b(!1),P(null),!(He!=null&&He.ok)){U({key:Re,text:il(He,"that account could not be updated")});return}const vt=(He.results??[])[0];vt&&L(Et=>mse(Et,Re,vt)),t()},[t]),we=(i==null?void 0:i.state)==="done"?i.account:null,Ge=ZT({restored:i==null?void 0:i.restored,activeAccount:i==null?void 0:i.activeAccount}),Ye=Pte({login:i,started:M.current,loginError:k,loginBusy:m}),Xe=Ote({state:i==null?void 0:i.state,serverError:i==null?void 0:i.error,localError:k}),rt=Ye==="asking"||Ye==="code"?zne({state:i==null?void 0:i.state,step:i==null?void 0:i.step,starting:Ye==="asking"})??"link":null,jt=Ye==="ended"?Vne({state:i==null?void 0:i.state,step:i==null?void 0:i.step,url:i==null?void 0:i.url,lastLive:$.current}):null,Ut=we?`${we.num??""}|${we.email}`:null,pt=Ye==="done"&&Ut!==Q&&ase({fromStages:W.current==="progress",reducedMotion:J})>0,Ct=Ye==="primer"?"primer":Ye==="done"&&we&&!pt?"done":"progress",It=jt?"failed":pt?"resolving":"live",Wt=Yne(pt?{done:!0}:jt?{failed:jt,state:i==null?void 0:i.state}:{live:rt}),tr=jt?PD(jt,i==null?void 0:i.state):"",Cs=hf(Xe.message),Jn=rt==="approve"?nse({since:fe,now:ie,expiresAt:i==null?void 0:i.expiresAt}):null,Qn=v?sse({since:je,now:ie}):null,Es=a==="login"?Ct==="done"&&we?`${iA(we)}.`:It==="failed"?`${tr}. ${Cs}`:Ct==="progress"&&!pt?ise(rt)??"":"":v?"Importing the share.":j?hf(j):T?hf(lA(T)):"";y.useEffect(()=>{rt&&($.current=rt)},[rt]),y.useEffect(()=>{W.current=Ct},[Ct]),y.useEffect(()=>{if(!pt||!Ut)return;const Ce=window.setTimeout(()=>te(Ut),DD);return()=>window.clearTimeout(Ce)},[pt,Ut]);const fn=rt==="approve";y.useEffect(()=>{ae(fn?Date.now():null)},[fn]),y.useEffect(()=>{me(v?Date.now():null)},[v]);const Un=fn||v;return y.useEffect(()=>{if(!Un)return;re(Date.now());const Ce=window.setInterval(()=>re(Date.now()),1e3);return()=>window.clearInterval(Ce)},[Un]),y.useEffect(()=>{var Re,He,vt,Et;if(a!=="login")return;if(Ct==="done"){(Re=V.current)==null||Re.focus();return}if(Ct==="primer"){X.current&&((He=B.current)==null||He.focus()),X.current=!1;return}if(It==="failed"){(vt=Y.current)==null||vt.focus();return}const Ce=document.activeElement;rt==="approve"&&(!Ce||Ce===document.body)&&((Et=Z.current)==null||Et.focus())},[a,Ct,It,rt]),xt.createPortal(r.jsx("div",{className:"modal-backdrop",...Ie,role:"presentation",children:r.jsxs("div",{ref:ye,className:"modal aa-modal",onClick:Ce=>Ce.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:Ae,children:qh.map((Ce,Re)=>r.jsx("button",{type:"button",role:"tab",id:uA(Ce.id),ref:He=>{G.current[Re]=He},"aria-selected":a===Ce.id,"aria-controls":cA,tabIndex:a===Ce.id?0:-1,className:`aa-tab${a===Ce.id?" on":""}`,onClick:()=>{z.current=!1,o(Ce.id)},children:Ce.label},Ce.id))})}),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 aa-body",id:cA,role:"tabpanel","aria-labelledby":uA(a),children:[a==="login"?Ct==="done"&&we?r.jsxs("div",{className:`aa-done${Q===Ut?" from-orbit":""}`,children:[r.jsx(Qf,{ref:H}),ose({added:we.added,reducedMotion:J})&&r.jsx(aA,{anchor:H}),r.jsx("h4",{children:iA(we)}),r.jsxs("p",{className:"aa-note",children:[r.jsx("strong",{children:we.email}),we.added?Ge?" 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."]}),Ge?r.jsx("p",{className:"aa-note aa-warn",role:"status",children:Ge}):null,r.jsx("button",{type:"button",ref:V,className:"btn primary",onClick:_e,children:"Done"})]}):Ct==="progress"?r.jsx(Hne,{rows:Wt,phase:It,detail:It==="failed"?r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"aa-note aa-reason",children:Cs}),r.jsx("div",{className:"aa-actions",children:r.jsx("button",{type:"button",ref:Y,className:"btn primary",onClick:$e,children:jt==="link"?"Try again":"Start over"})})]}):rt==="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:Z,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:[yse(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"})})]})]}),Jn?r.jsx("p",{className:"aa-note aa-arrive",children:Jn}):null,r.jsxs("details",{className:"aa-code",open:ce,onToggle:Ce=>ue(Ce.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:E,type:"text",value:d,onChange:Ce=>h(Ce.target.value),onKeyDown:Ce=>{Ce.key==="Enter"&&d.trim()&&!_&&qe()},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",...On(_,!d.trim()||i.state==="registering"),onClick:qe,children:"Continue"})]}),(k||i.error)&&r.jsx("p",{className:"aa-err",children:k??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."})]})]}):rt?r.jsx("p",{className:"aa-note",children:Xne(rt,i==null?void 0:i.step)}):null,actions:rt==="link"||rt==="approve"?r.jsx("button",{type:"button",className:"btn",onClick:Ue,children:"Cancel"}):null}):r.jsxs("div",{className:"aa-step aa-primer",children:[pe?r.jsx("p",{className:"aa-note aa-warn",role:"status",children:pe}):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:B,className:"btn primary",...On(_),onClick:Pe,children:"Open the sign-in page"})})]}):T?(()=>{const Ce=T.filter(He=>He.state==="imported").length,Re=T.some(He=>Zf(He.check));return r.jsxs("div",{className:"aa-done",children:[!Re&&r.jsx(Qf,{ref:H}),Ce>0&&!Re&&r.jsx(aA,{anchor:H}),r.jsx("h4",{children:lA(T)}),T.length>0&&r.jsx("ul",{className:"aa-results",children:T.map(He=>{const vt=g1(He),Et=Zf(He.check);return r.jsxs("li",{className:`aa-result ${He.state}`,children:[r.jsx("span",{className:"aa-result-who",children:He.email||(He.num?`slot ${He.num}`:"an account")}),r.jsx("span",{className:"aa-result-what",children:gse(He.state)}),He.state==="present"&&r.jsx("button",{type:"button",className:"aa-result-fix","aria-busy":A===vt,title:`Overwrite the stored login for ${He.email} with the one in this share. Do this when that account has stopped working here; if it works, leave it.`,onClick:()=>ot(He),children:A===vt?"updating…":"update anyway"}),Et&&r.jsx("span",{className:"aa-result-err",children:Et.long}),(O==null?void 0:O.key)===vt&&r.jsx("span",{className:"aa-result-err",children:O.text})]},vt)})}),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:_e,children:"Done"}),r.jsx("button",{type:"button",className:"btn",onClick:()=>{q.current="",U(null),L(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:D,type:"text",value:f,onChange:Ce=>p(Ce.target.value),onKeyDown:Ce=>{Ce.key==="Enter"&&f.trim()&&!_&&et()},placeholder:"ccdeck2:…",spellCheck:!1,autoComplete:"off","aria-label":"Shared account"}),r.jsx("button",{type:"button",className:"btn primary",...On(_,!f.trim()),onClick:et,children:v?"importing…":"Import"})]}),j&&r.jsx("p",{className:"aa-err",children:j}),v?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:Qn??"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:Es})]})]})}),document.body)}function wse(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 xse(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 vse=64;function bse(e,t){const n=e.trim();return{alias:n,commit:n!==(t??"").trim()}}function kse(e,t,n){return t!=null&&e.some(s=>s.slot===t)?t:n}function jse(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 Nse(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 Sse(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 _se({a:e,slots:t,nowSec:n,boundaryId:s,accountMenu:a,busy:o,pressProps:i,onProjects:c,onRotation:d,home:h,onHome:f}){const{menu:p,menuError:m,aliasDraft:w,confirmRemove:v,share:b,shareCopied:k,slotDraft:N,dropMenu:j,closeMenu:S,startRename:_,typeAlias:T,doAlias:L,startMove:A,pickSlot:P,doSlot:O,makeShare:U,copyShare:q,pressRemove:M}=a;if(!p)return null;const I=`ap-pop-title-${e.num}`,E=m&&r.jsx("p",{className:"ap-pop-error",role:"alert",title:m.raw||void 0,children:m.text});return r.jsxs(Hp,{anchorId:`ap-more-${e.num}`,boundaryId:s,id:`ap-menu-${e.num}`,className:"ap-pop",role:p.view==="menu"?"menu":"dialog",labelledBy:p.view==="menu"?`ap-more-${e.num}`:I,start:p.start,onClose:j,children:[p.view==="menu"&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",onClick:()=>_(e.num,e.alias),children:"Rename"}),r.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",onClick:()=>A(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:()=>U(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:()=>c(),children:"Projects"}),(!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:()=>d(),children:e.disabled?"Put back in rotation":"Hold out of rotation"}),(h||e.email)&&r.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",...i(`home-${e.num}`),title:h?"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:()=>f(),children:h?"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${v===e.num?" armed":""}`,...i(`rm-${e.num}`),"aria-label":v===e.num?"Confirm remove":void 0,title:v===e.num?"This deletes the stored credentials for this account":"Remove this account from claude-swap",onClick:()=>M(e.num),children:o===`rm-${e.num}`?"Removing…":v===e.num?"Confirm":"Remove"}),E]}),p.view==="rename"&&r.jsxs("form",{className:"ap-pop-form",onSubmit:D=>{D.preventDefault(),L(e.num,e.alias)},children:[r.jsx("label",{className:"ap-pop-title",id:I,htmlFor:`ap-alias-${e.num}`,children:"Rename account"}),r.jsx("input",{id:`ap-alias-${e.num}`,className:"ap-manage-input",type:"text",value:w,onChange:D=>T(D.target.value),maxLength:vse,placeholder:"e.g. work",spellCheck:!1,autoComplete:"off",autoFocus:!0,onFocus:D=>D.currentTarget.select()}),E,r.jsxs("div",{className:"ap-pop-actions",children:[r.jsx("button",{type:"button",className:"btn",onClick:()=>S(),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"})]})]}),p.view==="move"&&(()=>{const D=wse(t,e.num),B=kse(D,N,e.num),H=jse(D,B,e.num);return r.jsxs("div",{className:"ap-pop-form",children:[r.jsx("label",{className:"ap-pop-title",id:I,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(B),...i(`move-${e.num}`),onChange:G=>P(Number(G.target.value)),autoFocus:!0,children:D.map(G=>r.jsx("option",{value:G.slot,children:G.label},G.slot))})}),E,r.jsxs("div",{className:"ap-pop-actions",children:[r.jsx("button",{type:"button",className:"btn",onClick:()=>S(),children:"Cancel"}),r.jsx("button",{type:"button",className:"btn primary",...i(`move-${e.num}`),title:H.title,onClick:()=>O(e.num,B,H),children:o===`move-${e.num}`?"…":Jc(H.label)})]})]})})(),p.view==="share"&&(b==null?void 0:b.num)===e.num&&(()=>{const D=FD(b.expiresAt,n),B=D.tone==="gone";return r.jsxs("div",{className:"ap-pop-form",children:[r.jsx("p",{className:"ap-pop-title",id:I,children:"Share account"}),r.jsx("code",{className:"ap-share-blob",children:b.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 ${D.tone}`,children:D.text})]}),E,r.jsxs("div",{className:"ap-pop-actions",children:[r.jsx("button",{type:"button",className:"btn",onClick:()=>S(),children:"Done"}),r.jsx("button",{type:"button",className:"btn primary",...i(`share-${e.num}`),autoFocus:!0,onClick:async()=>{if(B){await U(e.num);return}await q(b.blob)},children:B?"Make a new share":k?"Copied":"Copy"})]})]})})()]})}const Cse=6;function Ese(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?Tse(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 Tse(e){const t=e.map(n=>n.headroom).filter(n=>typeof n=="number");return t.length?Math.round(Math.max(...t)):null}function Ase(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,Cse),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 qD=160,UD=140;function Rse(){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),UD)},holdPeek:()=>window.clearTimeout(n.current),dropPeek:()=>{window.clearTimeout(n.current),t(!1)}}}function Mse(e){var t;return((t=e==null?void 0:e.detail)==null?void 0:t.fix)==="give_back"}function Hs(e,t){return{text:e,giveBack:Mse(t),done:!1}}async function $se(){try{return await(await fetch("/api/prefs/give-back",{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"})).json().catch(()=>null)}catch{return null}}const Lse={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 Ise(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?Lse[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 y1=5e3,WD=6e4;function Gt(e,t){if(t==null)return`Could not ${e} — the deck did not answer.`;const n=t.reason?Dse(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 Ose={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."},Pse=new Set(["EACCES","EPERM"]);function Dse(e,t){const n=Ose[e];if(!n)return;const s=e==="prefs_unreadable"&&t?Fse(t):void 0,a=t!=null&&t.code&&t.code!=="BADJSON"?` Error code: ${t.code}.`:"";return(s??n)+a}function Fse({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&&!Pse.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 Ji(e,t){return(await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).json().catch(()=>null)}function Bse(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(q=>Lp(f.current)?(f.current=q,c(q),!0):!1,[]),m=y.useCallback(()=>{f.current=null,k.current&&c(null)},[]),w=q=>{const M=no(i,q);return{disabled:M.disabled,"aria-busy":M.busy}},[v,b]=y.useState(()=>Date.now()),k=y.useRef(!0),N=y.useRef(y1),j=y.useCallback(async()=>{var q,M;try{const[I,E]=await Promise.all([fetch("/api/lan").then(D=>D.json()),fetch("/api/prefs").then(D=>D.json())]);if(!k.current)return;I!=null&&I.ok&&s(I),E!=null&&E.ok&&o(Array.isArray((M=(q=E.prefs)==null?void 0:q.lan)==null?void 0:M.manual)?E.prefs.lan.manual:[]),N.current=(I==null?void 0:I.enabled)===!0?y1:WD}catch{}},[]);y.useEffect(()=>{k.current=!0;let q=0;const M=async()=>{b(Date.now()),await j(),k.current&&(q=window.setTimeout(M,N.current))};return M(),()=>{k.current=!1,window.clearTimeout(q)}},[j]);const S=y.useCallback(async()=>{const q=(n==null?void 0:n.enabled)===!0;if(p("switch"))try{const M=await Ji("/api/prefs",{lan:{enabled:!q}});if(!k.current)return;M!=null&&M.ok?(h(null),q||t()):h(Hs(Gt(q?"turn this off":"turn this on",M),M)),await j()}catch{k.current&&h(Hs(Gt(q?"turn this off":"turn this on",null)))}finally{m()}},[n==null?void 0:n.enabled,j,p,m,t]),_=y.useCallback(async(q,M,I)=>{if(!p(`${q}:${M}`))return null;let E=null;try{const D=await Ji("/api/lan/peer",{action:q,fp:M});if(!k.current)return null;D!=null&&D.ok?(s(D),h(null)):(E=Gt(I,D),h(Hs(E,D))),await j()}catch{E=Gt(I,null),k.current&&h(Hs(E))}finally{m()}return E},[j,p,m]),T=y.useCallback(async q=>{if(!p(`drop:${q}`))return null;let M=null;try{const I=await Ji("/api/prefs",{lan:{manual:a.filter(E=>E!==q)}});if(!k.current)return null;I!=null&&I.ok?(h(null),e()):(M=Gt("stop dialling that address",I),h(Hs(M,I))),await j()}catch{M=Gt("stop dialling that address",null),k.current&&h(Hs(M))}finally{m()}return M},[a,j,e,p,m]),L=y.useCallback(async(q,M)=>{if(!p(`alias:${q}`))return"Something else is still being saved. Try again in a moment.";try{const I=await Ji("/api/lan/peer",{action:"alias",fp:q,name:M});return k.current?I!=null&&I.ok?(s(I),null):Gt("rename that deck",I):null}catch{return Gt("rename that deck",null)}finally{m()}},[p,m]),A=y.useCallback(async q=>{if(!p(`check:${q}`))return null;try{const M=await Ji("/api/lan/sync",{fp:q});return k.current?M!=null&&M.ok?(s(M),e(),null):(M==null?void 0:M.reason)==="no_address"?"There is no address here to call it on. It calls this deck, and it is up to date each time it does.":Gt("check that deck",M):null}catch{return Gt("check that deck",null)}finally{m()}},[p,m,e]),P=y.useCallback(async()=>{if(p("check"))try{const q=await Ji("/api/lan/sync",{});if(!k.current)return;q!=null&&q.ok?(s(q),h(null)):h(Hs(Gt("check the other decks",q),q)),e()}catch{k.current&&h(Hs(Gt("check the other decks",null)))}finally{m()}},[p,m,e]);return{status:n,manual:a,now:v,busy:i,failure:d,dismissFailure:()=>h(null),answerGiveBack:q=>{h(q),q.done&&(j(),e())},pressProps:w,load:j,toggle:S,answer:_,dropAddress:T,rename:L,checkOne:A,checkNow:P}}function qse(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=ni({armedFor:t,target:o.fp,armedAt:s.current,now:i,gapMs:ti});if(c==="arm"){n(o.fp),s.current=i;return}c!=="ignore"&&(n(null),e("unpair",o.fp,"unpair that deck"))}}}function HD({title:e,steps:t,finish:n,aside:s,onClose:a}){const o=y.useRef(null),i=ft(a,{focusRef:o}),c=mt(a),[d,h]=y.useState(0),f=d===t.length-1,p=t[d],m=b=>h(Math.max(0,Math.min(t.length-1,b)));y.useEffect(()=>{var b,k;Bn(((b=document.activeElement)==null?void 0:b.tagName)??null)&&((k=o.current)==null||k.focus())},[d]);const w=b=>{b.key!=="ArrowRight"&&b.key!=="ArrowLeft"||(b.preventDefault(),b.stopPropagation(),m(b.key==="ArrowRight"?d+1:d-1))},v=()=>{if(!f){m(d+1);return}n?n.act():a()};return xt.createPortal(r.jsx("div",{className:"modal-backdrop",...c,role:"presentation",children:r.jsxs("div",{ref:i,className:"modal guide",onClick:b=>b.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((b,k)=>r.jsx("button",{type:"button",className:"glyph-btn guide-dot","aria-label":`Step ${k+1} of ${t.length}`,"aria-current":k===d?"step":void 0,onClick:()=>m(k)},k))}),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:v,children:f?(n==null?void 0:n.label)??"Done":"Next"})]})]})]})}),document.body)}const w1={ok:"ga-ok",warn:"ga-warn",accent:"ga-accent",flight:"ga-flight"};function Ns({children:e}){return r.jsx("svg",{className:"guide-art",viewBox:"0 0 440 200","aria-hidden":!0,focusable:"false",children:e})}function js({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 Xs({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:w1[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 ${w1[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 zD({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 Uh({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 dA({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 hA({x:e,y:t,d:n}){return r.jsx("path",{d:n,transform:`translate(${e} ${t})`,className:"ga-glyph"})}function mN({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 gN(){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 ll({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:w1[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 vl({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 ep({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(zD,{x:e+118,y:t-13,on:!0})]})}function Use(){return r.jsxs(Ns,{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 Wse(){return r.jsxs(Ns,{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(ll,{x:20,y:80,w:116,title:"main",sub:"Opus 5 · 9 tools",tone:"accent"}),r.jsx(ll,{x:196,y:18,w:112,title:"explore",sub:"Haiku · 14 tools",tone:"flight"}),r.jsx(ll,{x:196,y:80,w:112,title:"tests",sub:"Sonnet · 6 tools",tone:"flight"}),r.jsx(ll,{x:196,y:142,w:112,title:"review",sub:"done · 38s",tone:"ok"}),r.jsx(vl,{x:326,y:28,label:"Read"}),r.jsx(vl,{x:380,y:28,label:"Grep",live:!0}),r.jsx(vl,{x:326,y:90,label:"Bash",live:!0})]})}function fA({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 Hse(){return r.jsxs(Ns,{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(fA,{x:216,y:80,label:"5-hour window",pct:24,note:"resets in 53m"}),r.jsx(fA,{x:216,y:124,label:"7-day window",pct:61,note:"resets in 4d"})]})}function zse(){return r.jsxs(Ns,{children:[r.jsx("rect",{x:14,y:40,width:172,height:120,rx:10,className:"ga-canvas"}),r.jsx(ll,{x:30,y:80,w:140,title:"tests",sub:"Sonnet 5 · 6 tools",tone:"flight"}),r.jsx(mN,{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(js,{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(vl,{x:214,y:122,label:"Read"}),r.jsx(vl,{x:266,y:122,label:"Edit"}),r.jsx(vl,{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 Vse(){const e=[18,24,28,14,22,26,30,16,24,28,20,26];return r.jsxs(Ns,{children:[r.jsx(js,{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 Gse(){return r.jsxs(Ns,{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(ll,{x:278,y:80,w:120,title:"my-project",sub:"Opus 5 · live",tone:"accent"})})]})}function Kse(){return r.jsxs(Ns,{children:[r.jsx(js,{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(hA,{x:196,y:33,d:"M7 2.2v9.6M2.2 7h9.6"}),r.jsx(hA,{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(Xs,{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(Xs,{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(mN,{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(js,{x:282,y:62,w:144,h:64,label:"ANOTHER MACHINE"}),r.jsx("g",{className:"ga-pop",children:r.jsx(Xs,{x:296,y:92,email:"work@team.dev",state:"shared here",tone:"ok"})})]})}function Yse(){return r.jsxs(Ns,{children:[r.jsx(js,{x:14,label:"THIS MACHINE"}),r.jsx(ep,{x:28,y:60}),r.jsx("g",{className:"ga-swap-out",children:r.jsx(Xs,{x:28,y:98,email:"work@team.dev",state:"login expired",tone:"warn"})}),r.jsx("g",{className:"ga-swap-in",children:r.jsx(Xs,{x:28,y:98,email:"work@team.dev",state:"working again",tone:"ok",bars:[24,61]})}),r.jsx(js,{x:250,label:"ANOTHER MACHINE"}),r.jsx(ep,{x:264,y:60}),r.jsx(Xs,{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(gN,{})})]})}const Xse=[{art:r.jsx(Use,{}),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(Wse,{}),line:"Every agent and subagent is a node. Tool calls light up as they run."},{art:r.jsx(zse,{}),line:"Double-click any node: its prompt, every tool call, tokens and timing."},{art:r.jsx(Hse,{}),line:"What each session costs, and how much quota is left."},{art:r.jsx(Vse,{}),line:"Cores, memory and heat while the agents run, and what is hogging them."},{art:r.jsx(Kse,{}),line:"Several Claude accounts: switch, add one, share one to another machine."},{art:r.jsx(Yse,{}),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(Gse,{}),line:"Run claude or codex in any folder. It shows up here on its own."}];function Zse(){return r.jsxs(Ns,{children:[r.jsx(js,{x:14,label:"THIS MACHINE"}),r.jsx(Xs,{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(js,{x:250,label:"ANOTHER MACHINE"}),r.jsx(Xs,{x:264,y:64,email:"work@team.dev",state:"working",tone:"ok",bars:[24,61]})]})}function Jse(){return r.jsxs(Ns,{children:[r.jsx(js,{x:14,label:"THIS MACHINE"}),r.jsx(ep,{x:28,y:60}),r.jsx(Uh,{x:28,y:92,name:"Ana's MacBook"}),r.jsx(Uh,{x:28,y:114,name:"Dorin's PC"}),r.jsx(js,{x:250,label:"ANOTHER MACHINE"}),r.jsx(ep,{x:264,y:60}),r.jsx(Uh,{x:264,y:92,name:"Your MacBook"}),r.jsx(Uh,{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 Qse(){return r.jsxs(Ns,{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(dA,{x:106,y:88,on:!0}),r.jsx("text",{x:126,y:98,className:"ga-t ga-mono",children:"work@team.dev"}),r.jsx(dA,{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(zD,{x:304,y:157,on:!0}),r.jsx(mN,{x:115,y:97})]})}function ere(){return r.jsxs(Ns,{children:[r.jsx(js,{x:14,label:"THIS MACHINE"}),r.jsx("g",{className:"ga-swap-out",children:r.jsx(Xs,{x:28,y:64,email:"work@team.dev",state:"login expired",tone:"warn"})}),r.jsx("g",{className:"ga-swap-in",children:r.jsx(Xs,{x:28,y:64,email:"work@team.dev",state:"working again",tone:"ok",bars:[24,61]})}),r.jsx(js,{x:250,label:"ANOTHER MACHINE"}),r.jsx(Xs,{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(gN,{})})]})}const tre=[{art:r.jsx(Zse,{}),line:"A login can expire on one machine while it still works on another."},{art:r.jsx(Jse,{}),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(Qse,{}),line:"Tick which logins this machine may hand out. Nothing is shared until you do."},{art:r.jsx(ere,{}),line:"An expired login is copied from a paired machine within a minute."}];function nre(){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(gN,{})})]})}const sre={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."},rre=1600;function VD({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 lo(o.join(`
101
+ `))&&a.current&&(s(!0),window.setTimeout(()=>{a.current&&s(!1)},rre))},[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:sre[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 are(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 ore(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 Ay(e,t){return(await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).json().catch(()=>null)}const ire={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."},lre={not_running:"This deck is not on the network yet. Turn Local network on, then make one."};function pA(e,t,n){return(t==null?void 0:t.reason)&&e[t.reason]||Gt(n,t)}function cre({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=ft(s,{focusRef:h?i:o}),p=mt(s),[m,w]=y.useState(""),[v,b]=y.useState(""),[k,N]=y.useState(null),[j,S]=y.useState(null),[_,T]=y.useState(null),[L,A]=y.useState(null),[P,O]=y.useState(()=>Date.now());y.useEffect(()=>{const X=window.setInterval(()=>O(Date.now()),1e3);return()=>window.clearInterval(X)},[]);const U=y.useRef(!0);y.useEffect(()=>()=>{U.current=!1},[]);const q=y.useRef(null),M=y.useRef(null),I=y.useCallback(X=>Lp(q.current)?(q.current=X,T(X),!0):!1,[]),E=y.useCallback(()=>{q.current=null,U.current&&T(null)},[]),D=X=>{const J=no(_,X);return{disabled:J.disabled,"aria-busy":J.busy}},B=X=>(k==null?void 0:k.field)===X?{"aria-invalid":!0,"aria-describedby":"lan-add-failure"}:{},H=X=>N(J=>J&&J.field===X?null:J),G=y.useCallback(async()=>{if(h)return;const X=are(m);if(!X){N({text:ure(m),field:"addr"});return}const J=`${X.addr}:${X.port}`,Q=e.peers.find(te=>te.addr===X.addr&&te.port===X.port&&te.paired);if(Q){N({text:`Already paired with ${Q.name} at that address.`,field:"addr"});return}if(t.includes(J)){N({text:"This deck already calls that address.",field:"addr"});return}if(I("add"))try{const te=await Ay("/api/prefs",{lan:{manual:[...t,J]}});if(!U.current)return;te!=null&&te.ok?(N(null),w(""),a(),s()):N({text:Gt("add that address",te),field:"addr"})}catch{U.current&&N({text:Gt("add that address",null),field:"addr"})}finally{E()}},[m,h,t,e.peers,a,s,I,E]),z=y.useCallback(async X=>{if(!I(`invite:${X}`))return;const J=X==="make"?"make an invite":"cancel that invite";try{const Q=await Ay("/api/lan/invite",{action:X});if(!U.current)return;Q!=null&&Q.ok?(M.current=X,N(null),S(null),a()):N({text:pA(lre,Q,J)})}catch{U.current&&N({text:Gt(J,null)})}finally{E()}},[a,I,E]),F=y.useCallback(async()=>{const X=v.trim();if(!(!X||!I("join"))){A(null);try{const J=await Ay("/api/lan/invite",{action:"join",token:X});if(!U.current)return;J!=null&&J.ok?(b(""),N(null),a(),s()):(J==null?void 0:J.reason)==="unreachable"&&Array.isArray(J.tried)&&J.tried.length?(A(J.tried),N(null)):(A(null),N({text:pA(ire,J,"use that invite"),field:"join"}))}catch{U.current&&N({text:Gt("use that invite",null),field:"join"})}finally{E()}}},[v,a,s,I,E]),$=y.useCallback(async(X,J)=>{try{await navigator.clipboard.writeText(X),S(J),window.setTimeout(()=>{U.current&&S(Q=>Q===J?null:Q)},1600)}catch{N({text:"Could not copy it — select the text and copy it by hand."})}},[]),W=e.invite&&e.invite.expiresAt>P?e.invite:null,Z=y.useRef(!1);y.useEffect(()=>{n!=="invite"||Z.current||W||(Z.current=!0,z("make"))},[n,W,z]);const V=y.useRef(!1);y.useEffect(()=>{var X;n!=="invite"||V.current||!W||(V.current=!0,(X=c.current)==null||X.focus())},[n,W]),y.useEffect(()=>{var J,Q;const X=M.current;!X||X==="make"!=!!W||(M.current=null,Bn(((J=document.activeElement)==null?void 0:J.tagName)??null)&&((Q=(X==="make"?c:d).current)==null||Q.focus()))},[W]);const Y=e.port!=null?(e.addrs??[]).map(X=>`${X}:${e.port}`):[];return xt.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:[k&&r.jsxs("div",{className:"ap-failure",role:"alert",children:[r.jsx("span",{id:"lan-add-failure",className:"ap-failure-text",children:k.text}),r.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>N(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),r.jsx(VD,{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,...B("addr"),onChange:X=>{w(X.target.value),H("addr")},onKeyDown:X=>{X.key==="Enter"&&G()}}),m.trim()!==""&&r.jsx("button",{type:"button",className:"ap-manage-btn",...D("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,J)=>r.jsxs("span",{children:[J>0&&" or ",r.jsx("code",{className:"ap-lan-code",children:X})]},X)),r.jsx("button",{type:"button",className:"ap-lan-word lan-copy",...D("copy:mine"),onClick:()=>void $(Y.join(" "),"mine"),title:"Copy this deck's address, to send to whoever is adding it",children:j==="mine"?"copied":"copy"})]})]}),r.jsxs("div",{className:"modal-section",children:[r.jsxs("h3",{className:"lan-h",children:["With an invite",!W&&r.jsx("button",{type:"button",className:"ap-lan-word lan-h-act",ref:d,...D("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:v,placeholder:"paste one you were sent",spellCheck:!1,...B("join"),onChange:X=>{b(X.target.value),A(null),H("join")},onKeyDown:X=>{X.key==="Enter"&&F()}}),v.trim()!==""&&r.jsx("button",{type:"button",className:"ap-manage-btn",...D("join"),onClick:()=>void F(),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."}),L&&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."}),L.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))]}),W&&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:[ore(W.expiresAt,P)," left"]})]}),r.jsx("code",{className:"ap-lan-token",children:W.token}),r.jsxs("div",{className:"ap-lan-acts",children:[r.jsx("button",{type:"button",className:"ap-manage-btn",ref:c,...D("copy:invite"),"aria-label":j==="invite"?"Invite copied":"Copy invite","aria-describedby":"lan-invite-left",onClick:()=>void $(W.token,"invite"),title:"Copy it, and send it however you already talk to them",children:j==="invite"?"copied":"copy"}),r.jsx("button",{type:"button",className:"ap-manage-btn",...D("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 ure(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 dre({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 hre({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 fre(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 pre({on:e,status:t}){return r.jsxs(r.Fragment,{children:[e&&r.jsx(VD,{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:fre(t)})]})}const mA=["online","offline","loose"],mre={online:0,offline:1,loose:2};function gre(e){return e.kind==="declined"?null:e.kind==="paired"?e.here?"online":"offline":"loose"}const yre=76,wre=62,tp=96,xre={1:[.62],2:[.58,1],3:[.42,.72,1]},vre=.2,bre=.16,kre=.05,jre=20,Nre=17,Wh=7,Sre=30,_re=116,Cre=6.6,Ere=6,Tre=e=>yN(e,null),Are=1.5,Rre=80,Mre=.45,gA=40,$re=64,Lre=150,yA=.3,wA=84,xA=8,Ire=1.3,np=6,Ore=5.94,vA=7,bA=16,Wc=4,kA=.16;function x1(e,t){return Math.PI*(3*(e+t)-Math.sqrt((3*e+t)*(e+3*t)))}function GD(e,t){return t<-Math.abs(e)*.6?"top":"bottom"}function Pre(e,t){if(e<=2)return t%2===0?0:90;const n=360/e;return-90+(t%2===0?0:n/2)}function Dre(e){return e.map((t,n)=>({...t,i:n})).sort((t,n)=>mA.indexOf(t.tier)-mA.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 jA(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 Fre(e,t,n){const s=[...xre[e.length]??[]];for(let a=0;a<s.length;a++){const o=e[a];if(o<2)continue;const i=x1(t*s[a],n*s[a])/o;if(!(i>0)||i>=tp)continue;const c=a+1<s.length?s[a+1]-vre:1;s[a]=Math.max(s[a],Math.min(c,s[a]*(tp/i)*1.02))}return s}const Io=(e,t)=>e.x0<t.x1&&t.x0<e.x1&&e.y0<t.y1&&t.y0<e.y1,Ry={h:16,ch:6.1,maxW:100};function Bre(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 KD(e,t,n,s,a,o){const i=t==="loose"?Nre:jre,c=!a||e.kind==="asks",d=c?Sre:Ry.h,h=a?Ry.ch:Cre,f=c?o.length:0,p=Math.min(a?Ry.maxW:_re,Math.max(2*i,XD(e).length*h,f*Ere)),m={x0:n-i,y0:s-i,x1:n+i,y1:s+i},w=GD(n,s)==="top"?{x0:n-p/2,y0:s-i-Wh-d,x1:n+p/2,y1:s-i-Wh}:{x0:n-p/2,y0:s+i+Wh,x1:n+p/2,y1:s+i+Wh+d};return[m,w]}const v1=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]},Hh=(e,t)=>((e-t)%360+540)%360-180;function NA(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]=v1(f);return KD(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*Are,v=s.get(f.ring),b=(f.count>2?360/f.count:f.turn)*Mre,k=v[(f.index+1)%f.count],N=v[(f.index-1+f.count)%f.count];return!(k===f||(p>0?Hh(k.theta,w)>=b:Hh(w,N.theta)>=b))||w<f.lo||w>f.hi?!1:(f.theta=w,!0)},i=([f,p],[m,w])=>Io(p,m)||Io(w,f)||Io(p,w)||Io(f,m),c=([f,p])=>Io(f,n)||Io(p,n);for(let f=0;f<Rre;f++){const p=a();let m=!1;for(let w=0;w<e.length;w++){c(p[w])&&(m=o(e[w],Hh(e[w].theta,90)>=0?1:-1,!0)||m);for(let v=w+1;v<e.length;v++){if(!i(p[w],p[v]))continue;const b=e[w],k=e[v],N=k.ring.ring>b.ring.ring||k.ring===b.ring&&v>w?k:b,j=N===k?b:k,S=Hh(N.theta,j.theta)>=0?1:-1;m=o(N,S)||o(j,-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 qre={online:0,offline:1,loose:1};function Ure(e,t,n,s="",a=Tre){const o=[];for(const i of[!0,!1]){const c=SA(e,t,n,s,mre,a,i);if(c.clashes===0)return c.named();if(o.push(c),c.layout.rings.length===3){const d=SA(e,t,n,s,qre,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 SA(e,t,n,s,a,o,i=!0){const c=new Map;for(const I of e){const E=gre(I);if(!E)continue;const D=a[E];c.has(D)||c.set(D,[]),c.get(D).push({row:I,tier:E})}const d=[...c.keys()].sort((I,E)=>I-E),h=Math.max(0,t/2-yre),f=Math.max(0,n/2-wre),p=Fre(d.map(I=>c.get(I).length),h,f),m=d.map((I,E)=>({ring:I,rx:h*p[E],ry:f*p[E],count:c.get(I).length})),w=m.reduce((I,E)=>I+E.count,0),v=I=>I.row.via==="tailscale",b=[...c.values()].flat().filter(v).length,k=Math.max(0,...m.map(I=>{const E=c.get(I.ring).filter(v).length,D=x1(I.rx,I.ry);return E>0&&D>0?E*tp*Ire/D*360:0})),N=i&&b>0&&b<w?Math.min(Lre,Math.max($re,b/w*360,k)):0,j=gA-N/2,S=gA+N/2,_=[];let T=!1;m.forEach((I,E)=>{const D=Dre(c.get(I.ring)),B=D.length,H=B>1&&x1(I.rx,I.ry)/B<tp;H&&(T=!0);const G=E===m.length-1,z=G?-kA*(p[E]-(p[E-1]??0)):kA*(p[E+1]-p[E]),F=N>0?[{members:D.filter(W=>W.row.via!=="tailscale"),from:S,width:360-N},{members:D.filter(W=>W.row.via==="tailscale"),from:j+360,width:N}]:[{members:D,from:null,width:360}];let $=0;for(const W of F){const Z=W.members.length;if(Z===0)continue;const V=W.width/Z,Y=Z>2;W.members.forEach(({row:X,tier:J},Q)=>{const te=Ws(X),ce=W.from==null?Pre(Z,E)+V*Q:W.from+V*(Q+.5),ue=Y?jA(te,1)*bre*V:0,ie=H&&$%2===1?1+z/p[E]:1,re=Y?jA(te,2)*kre:0,fe=V*.3;_.push({row:X,tier:J,ring:I,index:$,count:B,theta:ce+ue,reach:ie*(1+(G?-Math.abs(re):re)),lo:W.from==null?-1/0:W.from+fe,hi:W.from==null?1/0:W.from+W.width-fe,turn:V,caption:o(X)}),$++})}});const L=Bre(s);let A=NA(_,T,L);A>0&&!T&&(T=!0,A=NA(_,!0,L));const P=_.map((I,E)=>{const[D,B]=v1(I);return{row:I.row,tier:I.tier,ring:I.ring.ring,x:D,y:B,angle:Wre(Math.atan2(B,D)*180/Math.PI),dist:Math.hypot(D,B),side:GD(D,B),order:E}}),O=m.reduce((I,E,D)=>c.get(E.ring).some(v)?Math.max(I,p[D]):I,0),U=I=>({from:j,to:S,inner:{rx:h*yA,ry:f*yA},outer:{rx:Math.min(t/2-8,h*O+I),ry:Math.min(n/2-8,f*O+I)},count:b}),q={nodes:P,rings:m,dense:T,zone:N>0?{...U(wA),labelAt:null}:null};return{layout:q,clashes:A,named:()=>{if(!q.zone)return q;const I=_.flatMap(B=>{const[H,G]=v1(B);return KD(B.row,B.tier,H,G,T,B.caption)});let E={...q.zone,labelAt:_A(q.zone,I)},D=E.outer;for(let B=wA+xA;E.labelAt==null;B+=xA){const H=U(B);if(H.outer.rx===D.rx&&H.outer.ry===D.ry)break;D=H.outer;const G=_A(H,I);G!=null&&(E={...H,labelAt:G})}return{...q,zone:E}}}}function YD(e){return`Tailscale · ${e} deck${e===1?"":"s"}`}function _A(e,t){const n={rx:e.outer.rx-np,ry:e.outer.ry-np};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 j=e.to;j>=e.from;j-=s){const S=j*Math.PI/180;a.push([Math.cos(S)*n.rx,Math.sin(S)*n.ry])}const o=vA+Wc,i={x0:Math.min(...a.map(j=>j[0]))-o,x1:Math.max(...a.map(j=>j[0]))+o,y0:Math.min(...a.map(j=>j[1]))-o,y1:Math.max(...a.map(j=>j[1]))+o},c=t.map(j=>({x0:j.x0-Wc,y0:j.y0-Wc,x1:j.x1+Wc,y1:j.y1+Wc})).filter(j=>Io(j,i)),d=(j,S)=>c.some(_=>j>_.x0&&j<_.x1&&S>_.y0&&S<_.y1),h=[],f=[];let p=0;a.forEach(([j,S],_)=>{_>0&&(p+=Math.hypot(j-a[_-1][0],S-a[_-1][1]));const T=Math.hypot(j,S)||1;let L=!1;for(let A=0;A<=vA&&!L;A+=1.75)L=d(j-j/T*A,S-S/T*A);h.push(p),f.push((f.at(-1)??0)+(L?1:0))});const m=YD(e.count).length*Ore/2,w=m+bA,v=p-m-bA;if(!(p>0)||v<w)return null;const b=j=>{let S=0,_=h.length;for(;S<_;){const T=S+_>>1;h[T]<j?S=T+1:_=T}return S},k=j=>{const S=b(j-m),_=b(j+m+1e-9)-1;return _<S||f[_]-(S>0?f[S-1]:0)===0},N=p/2;for(let j=0;N-j>=w;j+=2)for(const S of j===0?[N]:[N-j,N+j])if(k(S))return S/p;return null}function Wre(e){return(e%360+360)%360}function Hre(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 zre(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 yN(e,t){switch(e.kind){case"asks":return"wants to pair";case"nearby":return e.state;case"dialling":return ZD(e)?`${e.name.slice(e.addr.length)} · dialling`:"dialling";case"declined":return"declined";case"paired":{if(e.here)return t?Vre(t):"online";const n=QD(e);return n?n==="now"?"away · just now":`away · ${n}`:e.state.startsWith("one-way")?"has not called yet":"away"}}}function XD(e){return ZD(e)?e.addr:e.name}function ZD(e){return e.kind==="dialling"&&!!e.addr&&e.name.startsWith(`${e.addr}:`)}function JD(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=QD(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 QD(e){var t;return((t=/last online (.+)$/.exec(e.state))==null?void 0:t[1])??null}function Vre(e){return e.trim().split(/\s+/).slice(0,2).join(" ")}function Gre(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 Ws(e){let t=e.fp;for(const n of e.twins??[])n.fp<t&&(t=n.fp);return t}function Kre(e,t){if(e==null)return t;const n=((t-e)%360+540)%360-180;return e+n}function Yre(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} ${e5}`:e.nearby===1?`${n} Open it to ask to pair.`:`${n} Open one to ask to pair.`}return null}const e5="This deck pairs by invite only. Send one from Add a deck.";function Xre(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"?e5:"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 Zre(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 Jre(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 Qre(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 eae(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 tae(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=eae(h,f),w=f?f.alive?f.shareable===!1?f.inUse?"inUse":"unavailable":"works":"expired":"missing",v=!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:v,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 nae=1e3;function sae(e,t){const n=new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),s=kr(e,t);return`${n} · ${s==="now"?"just now":s}`}function b1(e){return e&&[e.version,e.os,e.arch].filter(Boolean).join(" · ")||null}const t5={works:"works here",expired:"expired here",missing:"not on this deck",unavailable:"cannot share here",inUse:"in use here"},n5={works:"works there",broken:"broken there",unavailable:"cannot share there",unknown:"not offered by that deck",inUse:"in use there"};function s5(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`${t5[e.here]}, ${n5[e.there]}, ${t}${n}.`}function r5({row:e,source:t,status:n,accounts:s,now:a}){var J,Q,te,ce,ue;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=((J=n.about)==null?void 0:J.version)??null,v=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",b=b1(n.about),k=b1(m),N=m!=null&&m.version&&w?Qre(m.version,w):null,j=o?Gp(o.last,a):null,S=o&&((Q=o.last)!=null&&Q.error)?nne({error:o.last.error,host:o.addr,port:o.port},[...n.strangers??[],...n.pending??[],...(n.peers??[]).filter(ie=>!ie.manual&&ie.addr).map(ie=>({fp:ie.fp,name:ie.name,addr:ie.addr,port:ie.port,at:ie.lastSeen??0}))],a):null,_=(te=o==null?void 0:o.last)!=null&&te.error&&j&&j.text!==o.last.error?o.last.error:null,T=((ce=o==null?void 0:o.last)==null?void 0:ce.done)??[],L=!!j&&!!_&&!e.quiet&&e.state.startsWith(j.text),A=c||e.kind==="dialling",P=((o==null?void 0:o.via)??e.via)==="tailscale",O=o?o.waiting?null:o.manual?P?"added by its Tailscale address":"added by address":P?"over Tailscale":"on this network":e.kind==="nearby"?P?"heard over Tailscale":"heard on this network":P?"asked this deck to pair, over Tailscale":"asked this deck to pair",U=e.tone==="bad"?"bad":c?e.here?"up":"down":"loose",q=(o==null?void 0:o.offers)??null,M=U==="up"?(q==null?void 0:q.current)??null:null,I=M&&"key"in M?M.key:null,E=!!M&&"hidden"in M,D=!!M&&"other"in M,B=(n.shared??[]).filter(ie=>{var re;return!((re=o==null?void 0:o.notOffered)!=null&&re.includes(ie))}),H=c?tae((q==null?void 0:q.accounts)??null,s,B,I):[],G=H.filter(ie=>ie.in==null&&ie.out==="cut"&&ie.here!=="inUse"),z=H.some(ie=>ie.in!=null),F=H.some(ie=>ie.out!=null),$=new Set((n.peers??[]).filter(ie=>ie.paired).flatMap(ie=>ie.notOffered??[])),W=H.some(ie=>ie.out!=null&&$.has(ie.key))?"decks you chose":"every paired deck",Z=new Map(T.map(ie=>[ie.email,ie])),V=T.filter(ie=>!H.some(re=>re.email===ie.email)),Y=c?q?q.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.":(ue=o==null?void 0:o.last)!=null&&ue.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=q&&(o!=null&&o.last)&&o.last.at-q.at>nae?kr(q.at,a):null;return{peer:o,stranger:i,paired:c,own:d,canRename:h,fp:f,where:p,about:m,unsaid:v,hereRuns:b,thereRuns:k,order:N,line:j,silence:S,raw:_,echoed:L,showRound:A,how:O,link:U,hiddenThere:E,otherThere:D,lanes:H,spent:G,taking:z,giving:F,givenTo:W,told:Z,unplaced:V,unknown:Y,stale:X}}function k1(){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 zh({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 rae({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:v,silence:b,raw:k,echoed:N,showRound:j,how:S,link:_,hiddenThere:T,otherThere:L,lanes:A,spent:P,taking:O,giving:U,givenTo:q,told:M,unplaced:I,unknown:E,stale:D}=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]}),T&&r.jsx("span",{className:"lan-end-note",children:"current account hidden"}),L&&r.jsx("span",{className:"lan-end-note",children:"on another account"})]})]}),r.jsxs("div",{className:"lan-link",children:[r.jsx(k1,{}),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(k1,{}),(d&&S||j)&&r.jsxs("p",{className:"lan-link-sub",children:[d&&S,d&&S&&j&&" · ",j&&(v?N?r.jsx("code",{className:"ap-lan-code",children:k}):r.jsx("span",{className:"lan-round","data-tone":v.tone,children:v.text.replace(/ · now$/," · just now")}):"not asked yet"),j&&k&&!N&&r.jsx("code",{className:"lan-fact-raw",children:k})]}),I.length>0&&r.jsx("ul",{className:"lan-done",children:I.map(B=>{const H=h1(B);return r.jsxs("li",{"data-ok":B.ok&&!H,children:[B.email," ",r.jsxs("span",{className:"lan-done-what",children:[B.ok?"arrived":"did not arrive",H&&` — ${H.long}`]})]},`${B.email}:${B.action}`)})}),b&&r.jsx("p",{className:"lan-note lan-link-note",children:b}),(i==null?void 0:i.waiting)&&r.jsx("p",{className:"lan-note lan-link-note",children:t.hint}),(v==null?void 0:v.hint)&&r.jsx("p",{className:"lan-note lan-link-note",children:v.hint})]}),A.length>0&&r.jsx("ul",{className:"lan-lanes",role:"list","aria-label":`Logins between this deck and ${t.name}`,children:A.map((B,H)=>{const G=M.get(B.email),z=G?h1(G):null,F=B.out==="live"||B.in!=null&&B.in!=="cut";return r.jsxs("li",{role:"listitem",className:"lan-lane","data-tone":B.tone,"data-draw":B.in&&B.out?"both":B.in?"in":"out","data-used-there":B.usedThere||void 0,style:{"--i":H},children:[r.jsx("i",{className:"lan-pip","data-end":"here","data-state":B.here,"aria-hidden":!0}),r.jsxs("span",{className:"lan-track",children:[r.jsxs("span",{className:"lan-wire","data-flow":F?"live":"cut","aria-hidden":!0,children:[(B.in==="live"||B.in==="wait")&&r.jsx("i",{className:"lan-glint","data-dir":"in","data-tone":B.in}),B.out==="live"&&r.jsx("i",{className:"lan-glint","data-dir":"out"})]}),B.in&&B.in!=="cut"&&r.jsx(zh,{dir:"in"}),B.out==="live"&&r.jsx(zh,{dir:"out"}),r.jsx("span",{className:"lan-lane-email",children:B.email})]}),r.jsx("i",{className:"lan-pip","data-end":"there","data-state":B.there,"aria-hidden":!0}),r.jsx("span",{className:"vis-hidden",children:s5(B)}),(B.caption||G)&&r.jsxs("span",{className:"lan-lane-note",children:[B.caption,B.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}`]})]})]},B.key)})},a),c&&r.jsxs(r.Fragment,{children:[P.length>0&&r.jsxs("p",{className:"lan-spent",children:["Paired decks get nothing from ",P.length===1?P[0].email:"the expired ones"," until you sign in again here."]}),E&&r.jsx("p",{className:"lan-empty",children:E}),D&&r.jsxs("p",{className:"lan-stale",children:["As of ",D==="now"?"just now":D,", when it last answered."]}),r.jsxs("div",{className:"lan-legend",children:[O&&r.jsxs("span",{className:"lan-key",children:[r.jsx("span",{className:"lan-key-wire","data-dir":"in","aria-hidden":!0,children:r.jsx(zh,{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(zh,{dir:"out"})}),"from this deck, to ",q]}):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 aae=20,oae=17,CA=34,iae=160,lae=80,cae=200,uae=8,dae=14,hae=10,fae=.61803398875;function pae({status:e,rows:t,accounts:n,now:s,covered:a,onOpenDeck:o,onClose:i}){const c=y.useRef(null),d=ft(i,{focusRef:c}),h=mt(i),f=y.useRef(null),[p,m]=y.useState(null),[w,v]=y.useState(!1),b=y.useRef(null);y.useLayoutEffect(()=>{const re=f.current;if(!re)return;let fe=null;const ae=()=>{const me=Math.round(re.clientWidth),pe=Math.round(re.clientHeight);fe&&fe.w===me&&fe.h===pe||(fe&&(v(!0),b.current!=null&&window.clearTimeout(b.current),b.current=window.setTimeout(()=>v(!1),cae)),fe={w:me,h:pe},m(fe))};if(ae(),typeof ResizeObserver>"u")return;const je=new ResizeObserver(ae);return je.observe(re),()=>{je.disconnect(),b.current!=null&&window.clearTimeout(b.current)}},[]);const k=y.useMemo(()=>p?Ure(t,p.w,p.h,(e==null?void 0:e.name)??"",re=>{var fe,ae;return yN(re,(ae=(fe=Du(e,re).peer)==null?void 0:fe.about)==null?void 0:ae.os)}):null,[t,p,e]),N=y.useMemo(()=>Hre(t),[t]),j=(k==null?void 0:k.nodes)??[],S=y.useRef(new Map),_=y.useMemo(()=>{const re=new Map;for(const fe of j){const ae=Ws(fe.row);re.set(ae,Kre(S.current.get(ae),fe.angle))}return S.current=re,re},[j]),[T,L]=y.useState(null),[A,P]=y.useState(null),[O,U]=y.useState("none"),q=y.useRef(null),M=y.useCallback((re,fe)=>{q.current!==re&&(q.current=re,U(fe),P(re))},[]),I=y.useRef(null),E=y.useRef(null),D=y.useCallback(()=>{E.current!=null&&window.clearTimeout(E.current),E.current=null},[]),B=y.useCallback((re,fe)=>{if(I.current!=null&&window.clearTimeout(I.current),I.current=null,D(),L(re),fe==="keyboard"){M(re,"none");return}E.current=window.setTimeout(()=>M(re,q.current?"swap":"full"),lae)},[M,D]),H=y.useCallback(()=>{I.current!=null&&window.clearTimeout(I.current),D(),I.current=window.setTimeout(()=>L(null),iae)},[D]);y.useEffect(()=>()=>{I.current!=null&&window.clearTimeout(I.current),D()},[D]);const G=T&&j.some(re=>Ws(re.row)===T)?T:null,z=A?t.find(re=>Ws(re)===A)??null:null;y.useEffect(()=>{A&&!z&&M(null,"swap")},[A,z,M]);const[F,$]=y.useState(null),W=y.useRef(new Map),Z=j.findIndex(re=>Ws(re.row)===F),V=Z<0?0:Z,Y=re=>{var me;if(j.length===0)return;const fe=re.key==="ArrowRight"||re.key==="ArrowDown"?1:re.key==="ArrowLeft"||re.key==="ArrowUp"?-1:0,ae=re.key==="Home"?0:re.key==="End"?j.length-1:fe?(V+fe+j.length)%j.length:null;if(ae==null)return;re.preventDefault();const je=Ws(j[ae].row);$(je),(me=W.current.get(je))==null||me.focus()},[X,J]=y.useState(()=>typeof document<"u"&&document.hidden);y.useEffect(()=>{const re=()=>J(document.hidden);return document.addEventListener("visibilitychange",re),()=>document.removeEventListener("visibilitychange",re)},[]);const Q=(e==null?void 0:e.enabled)===!0,te=e?Q?zre(N):"Local network is off":"checking…",ce=()=>{D(),M(null,"swap"),L(null)},ue=G?j.find(re=>Ws(re.row)===G)??null:null,ie=()=>{var re;A&&((re=W.current.get(A))==null||re.focus()),ce()};return xt.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:te})]}),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":ue==null?void 0:ue.row.via,"data-dense":(k==null?void 0:k.dense)||void 0,"data-still":w||void 0,onClick:re=>{re.target===re.currentTarget&&ce()},children:p&&k&&r.jsxs(r.Fragment,{children:[r.jsx(mae,{layout:k,w:p.w,h:p.h}),j.map(re=>{const fe=Ws(re.row);return r.jsx(wae,{node:re,angle:_.get(fe)??re.angle,lit:G===fe},fe)}),r.jsx(xae,{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, ${j.length}`,"aria-describedby":"nm-ring-hint",onKeyDown:Y,children:j.map((re,fe)=>{var je,me;const ae=Ws(re.row);return r.jsx(vae,{node:re,angle:_.get(ae)??re.angle,os:(me=(je=Du(e,re.row).peer)==null?void 0:je.about)==null?void 0:me.os,lit:G===ae,shown:A===ae,tabbable:fe===V,register:pe=>{pe?W.current.set(ae,pe):W.current.delete(ae)},onHold:pe=>{$(ae),B(ae,pe)},onRelease:H,onOpen:()=>o(re.row.fp)},ae)})}),j.length===0&&r.jsx(bae,{status:e})]})}),r.jsx(kae,{slice:(k==null?void 0:k.zone)!=null})]}),r.jsx("aside",{className:"nm-side","aria-label":"Details",children:z&&e?r.jsx(Nae,{row:z,status:e,accounts:n,now:s,entrance:O,onOpen:()=>o(z.fp),onBack:ie},Ws(z)):r.jsx(jae,{status:e,summary:N,entrance:O,slice:(k==null?void 0:k.zone)!=null})})]})]})}),document.body)}function a5(){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 mae({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:yae(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:gae(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:YD(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 EA(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 gae(e,t,n){const s=e.to-e.from>180?1:0,a=(N,j)=>{const S=j*Math.PI/180;return[t+Math.cos(S)*N.rx,n+Math.sin(S)*N.ry]},o=(N,j)=>j/((N.rx+N.ry)/2)*(180/Math.PI),i=(N,j,S)=>{const _=Math.hypot(j[0]-N[0],j[1]-N[1])||1,T=Math.min(.5,S/_);return[N[0]+(j[0]-N[0])*T,N[1]+(j[1]-N[1])*T]},c=([N,j])=>`${N.toFixed(1)},${j.toFixed(1)}`,d=hae,h=dae,f=o(e.inner,d),p=o(e.outer,h),m=a(e.inner,e.from),w=a(e.outer,e.from),v=a(e.outer,e.to),b=a(e.inner,e.to),k=N=>`${N.rx.toFixed(1)},${N.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${k(e.outer)} 0 ${s} 1 ${c(a(e.outer,e.to-p))}`,`Q${c(v)} ${c(i(v,b,h))}`,`L${c(i(b,v,d))}`,`Q${c(b)} ${c(a(e.inner,e.to-f))}`,`A${k(e.inner)} 0 ${s} 0 ${c(a(e.inner,e.from+f))}`,"Z"].join(" ")}function yae(e,t,n){const s={rx:e.outer.rx-np,ry:e.outer.ry-np},a=e.to-e.from>180?1:0;return`M${EA(s,t,n,e.to)} A${s.rx.toFixed(1)},${s.ry.toFixed(1)} 0 ${a} 0 ${EA(s,t,n,e.from)}`}function wae({node:e,angle:t,lit:n}){const s=e.row.kind==="paired"&&e.row.here,a=e.order*fae%1*uae;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":`${CA}px`,"--gap":`${CA+(e.tier==="loose"?oae:aae)}px`,"--i":e.order,"--phase":`${a.toFixed(2)}s`},children:s&&r.jsx("i",{className:"nm-glint"})})}function xae({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 vae({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-${Sae(Ws(f))}`,m=e.angle*Math.PI/180,w=yN(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}: ${JD(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:v=>{v.pointerType==="mouse"&&c("pointer")},onPointerLeave:d,onFocus:v=>c(v.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(k1,{}),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:XD(f)}),r.jsx("span",{className:"nm-cap",children:w})]}),e.tier==="online"&&r.jsx("span",{id:p,className:"vis-hidden",children:w})]})}function bae({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 kae({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 o5({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 jae({status:e,summary:t,entrance:n,slice:s}){const a=Gre(e),o=b1(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=Yre(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(o5,{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 Nae({row:e,status:t,accounts:n,now:s,entrance:a,onOpen:o,onBack:i}){var b;const c=r5({row:e,source:Du(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=Xre(e,t.pairingMode),p=Zre(c.lanes),m=p.length,w=Jre(p),v=c.unknown&&((b=c.peer)!=null&&b.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:JD(e)}),f&&r.jsx("p",{className:"nm-next",children:f}),d.length>0&&r.jsx(o5,{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((k,N)=>r.jsxs("li",{className:"nm-lane","data-tone":k.tone,style:{"--k":N},children:[r.jsx("i",{className:"nm-lane-dot","aria-hidden":!0}),r.jsx("span",{className:"nm-lane-email","aria-hidden":!0,children:k.email}),TA(k)&&r.jsx("span",{className:"nm-lane-said","aria-hidden":!0,children:TA(k)}),k.usedThere&&r.jsx("span",{className:"nm-lane-used","aria-hidden":!0,children:"in use there"}),r.jsxs("span",{className:"vis-hidden",children:[k.email,": ",s5(k)]})]},k.key))}),v&&r.jsx("p",{className:"nm-panel-hint",children:v})]})]})}function TA(e){return e.caption?e.caption:e.tone==="ok"?null:`${t5[e.here]} · ${n5[e.there]}`}function Sae(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 _ae=6;function Cae({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,_ae),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 v=sN(w.getBoundingClientRect(),{width:m.offsetWidth,height:m.offsetHeight},{width:window.innerWidth,height:window.innerHeight});m.style.top=`${v.top}px`,m.style.left=`${v.left}px`,m.style.maxHeight=v.maxHeight==null?"":`${v.maxHeight}px`,m.dataset.side=v.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]),xt.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 Eae({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(qD)},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(a5,{})}),a&&r.jsx(Cae,{anchorId:"ap-lan-entry",id:"ap-lan-peek",rows:t,onHold:c,onLet:i})]})}function Tae({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=ni({armedFor:a?e.fp:null,target:e.fp,armedAt:i.current,now:p,gapMs:ti});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=ni({armedFor:c,target:p,armedAt:i.current,now:m,gapMs:ti});if(w==="arm"){d(p),o(!1),i.current=m;return}w!=="ignore"&&(d(null),t(()=>s(p)))}}}function Aae({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 Rae({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 v,b,k,N;const h=(v=c.peer)!=null&&v.addr?`${c.peer.addr}:${c.peer.port}`:c.row.addr,f=h||c.row.fp,p=(b=c.peer)!=null&&b.pairedAt?kr(c.peer.pairedAt,t):null,m=[(N=(k=c.peer)==null?void 0:k.about)!=null&&N.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:j=>{j.repeat&&j.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 Mae(){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 $ae({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 v=y.useRef(null),b=ft(i,{focusRef:v}),k=mt(i),[N,j]=y.useState(null),[S,_]=y.useState(null),[T,L]=y.useState(!1),[A,P]=y.useState(0),O=y.useRef(null),U=y.useRef(null),q=y.useRef(!0);y.useEffect(()=>()=>{q.current=!1},[]);const M=N!=null;y.useEffect(()=>{var re;M&&((re=O.current)==null||re.select())},[M]);const I=y.useRef(!1);y.useEffect(()=>{var re,fe;I.current&&!M&&Bn(((re=document.activeElement)==null?void 0:re.tagName)??null)&&((fe=U.current)==null||fe.focus()),I.current=M},[M]);const E=re=>{const fe=no(o,re);return{disabled:fe.disabled,"aria-busy":fe.busy}},D=async re=>{const fe=await re();return q.current&&_(fe),fe==null},{armed:B,armedTwin:H,pressOwn:G,pressTwin:z}=Tae({row:e,run:D,onVerb:h,onUnpair:w}),F=r5({row:e,source:t,status:n,accounts:s,now:a}),{peer:$,stranger:W,paired:Z,own:V,canRename:Y,fp:X}=F,J=o===`check:${e.fp}`,Q=async re=>{const fe=re.trim()===V?"":re;await D(()=>c(fe))&&j(null)},te=()=>void D(d).then(re=>{re&&q.current&&P(fe=>fe+1)}),ce=async()=>{if(X)try{if(await navigator.clipboard.writeText(X),!q.current)return;L(!0),window.setTimeout(()=>{q.current&&L(!1)},1600)}catch{q.current&&_("Could not copy it — select the fingerprint and copy it by hand.")}},ue=[];Z&&($!=null&&$.pairedAt)?ue.push({label:"Paired",value:sae($.pairedAt,a),tone:"meta"}):e.kind==="declined"&&W&&ue.push({label:"Paired",value:`no · you said no ${hN(W.at,a)}`,tone:"meta"}),ue.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":T?"Fingerprint copied":"Copy the fingerprint",children:T?"copied":"copy"})]}):"not known — nothing has answered there",tone:X?void 0:"quiet"});const ie=m.length?[{row:e,peer:$??null},...m]:[];return xt.createPortal(r.jsx("div",{className:"modal-backdrop",...k,role:"presentation",children:r.jsxs("div",{ref:b,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:[M?r.jsxs("form",{className:"lan-peer-edit",onSubmit:re=>{re.preventDefault(),Q(N??"")},children:[r.jsx("span",{id:"lan-peer-title",className:"vis-hidden",children:e.name}),r.jsx("input",{ref:O,className:"ap-manage-input lan-peer-input",value:N??"",maxLength:48,placeholder:V,"aria-label":"Name for this deck, shown on this deck only",onChange:re=>j(re.target.value)}),r.jsx("button",{type:"submit",className:"ap-manage-btn",...E(`alias:${e.fp}`),children:"save"}),r.jsx("button",{type:"button",className:"ap-manage-btn",onClick:()=>j(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),j(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(Mae,{})})]}),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}),M&&r.jsx("button",{type:"button",className:"ap-lan-word lan-peer-restore",...E(`alias:${e.fp}`),onClick:()=>void Q(""),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:v,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(rae,{view:F,row:e,status:n,asking:J,drawn:A,onSettings:f}),r.jsx("dl",{className:"lan-facts",children:ue.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))}),ie.length>1&&r.jsx(Rae,{instances:ie,now:a,busy:o,press:E,armedTwin:H,pressTwin:z,onUnpair:w})]}),r.jsx(Aae,{row:e,paired:Z,peer:$,status:n,busy:o,press:E,checkNow:te,armed:B,pressOwn:G,run:D,onVerb:h,onInvite:p})]})}),document.body)}function Jr(e,t){const n=y.useRef(!1);return y.useEffect(()=>{var s,a;!e||!n.current||(n.current=!1,Bn(((s=document.activeElement)==null?void 0:s.tagName)??null)&&(typeof t=="function"?t():(a=t.current)==null||a.focus()))},[e]),()=>{n.current=!0}}function Lae(e,t){if(e.length!==t.length)return!1;const n=new Set(e);return t.every(s=>n.has(s))}function Iae(e,t,n,s){const a=new Set(e??t);return s?a.add(n):a.delete(n),[...a]}function AA(e,t,n){return e==null||n!=null&&!n.ok||Lae(e,t)?null:e}function i5({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 $se();o.current=!1,i.current&&(a(!1),h.current=document.activeElement===c.current,n(Ise(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 Oae(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 Vh="Paused while this deck pairs only by invite. Turn that off above to use it.";function Pae({status:e,accounts:t,onClose:n,onChanged:s}){tn("lan-setup");const a=ft(n),o=mt(n),[i,c]=y.useState(null),[d,h]=y.useState(null),[f,p]=y.useState(!1),[m,w]=y.useState(null),v=y.useRef(null),b=F=>{const $=no(m,F);return{disabled:$.disabled,"aria-busy":$.busy}},k=y.useRef(null),N=y.useRef(!0);y.useEffect(()=>()=>{N.current=!1},[]),y.useEffect(()=>{k.current=AA(k.current,e.shared??[],null)},[e.shared]);const j=y.useCallback(async(F,$,W="write")=>{v.current=W,w(W);try{const V=await(await fetch("/api/prefs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({lan:F})})).json().catch(()=>null);return N.current?(V!=null&&V.ok?h(null):h(Hs(Gt($,V),V)),s(),(V==null?void 0:V.ok)===!0):!1}catch{return N.current&&h(Hs(Gt($,null))),!1}finally{v.current=null,N.current&&w(null)}},[s]),S=y.useCallback(async F=>{const $=await j({name:F},"save the name","name");return $&&N.current&&c(W=>W===F?null:W),$},[j]),_=y.useRef(null),T=i!=null&&i!==(e.name??""),L=Jr(!T,_),A=y.useCallback(async()=>{T&&!await S(i)||n()},[T,i,S,n]),P=async()=>{if(!e.fp)return;const F=await lo(e.fp);if(N.current){if(!F){h(Hs("Could not copy it — select the fingerprint and copy it by hand."));return}p(!0),window.setTimeout(()=>{N.current&&p(!1)},1600)}},O=new Set(k.current??e.shared??[]),U=e.autoAsk!==!1,q=e.autoAccept!==!1,M=e.pairingMode==="invite",I=F=>{const $=b(F);return{...$,disabled:$.disabled||M}},E=e.shareActive!==!1,D=e.sendInUse===!0,B=e.tailscale??null,H=!!(B!=null&&B.on),G=(B==null?void 0:B.ask)!==!1,z=(B==null?void 0:B.accept)!==!1;return xt.createPortal(r.jsx("div",{className:"modal-backdrop",...o,role:"presentation",children:r.jsxs("div",{ref:a,className:"modal lan-modal",onClick:F=>F.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(i5,{line:d,onDismiss:()=>h(null),onAnswer:F=>{h(F),F.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:F=>c(F.target.value),onKeyDown:F=>{F.key!=="Enter"||i==null||S(i)}}),T&&r.jsx("button",{type:"button",className:"ap-manage-btn",...b("name"),onClick:()=>{L(),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 P(),"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(F=>r.jsxs("label",{className:"ap-lan-pick",title:F.alive?F.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:O.has(F.key),onChange:$=>{const W=Iae(k.current,e.shared??[],F.key,$.target.checked);k.current=W,j({shared:W},$.target.checked?"share that account":"stop sharing that account").then(Z=>{k.current===W&&(k.current=AA(W,e.shared??[],{ok:Z}))})}}),r.jsx("span",{className:"ap-lan-pick-name",children:F.email}),!F.alive&&r.jsx("span",{className:"ap-lan-dead",children:"not working here"}),F.alive&&F.inUse&&O.has(F.key)&&r.jsx("span",{className:"ap-lan-dead",children:"in use here · not sent"})]},F.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":E,"aria-label":"Show paired decks which of these this deck is using",...b("current"),onClick:()=>void j({shareActive:!E},E?"stop showing which account this deck is using":"show which account this deck is using","current"),title:E?"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",D&&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":D,"aria-label":"Send the login this deck is using too","aria-describedby":D?"lan-send-in-use-detail":void 0,"data-tone":"warn",...b("send-in-use"),onKeyDown:F=>{F.repeat&&F.preventDefault()},onClick:()=>void j({sendInUse:!D},D?"keep the login this deck is using here":"send the login this deck is using","send-in-use"),title:D?"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",M&&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":M,"aria-label":"Pair new decks only by invite","aria-describedby":M?"lan-invite-only-detail":void 0,...b("mode"),onKeyDown:F=>{F.repeat&&F.preventDefault()},onClick:()=>void j({pairingMode:M?"automatic":"invite"},M?"let decks pair on their own again":"pair new decks only by invite","mode"),title:M?"Let decks on this network pair as the two switches below say again.":"Only a deck you send an invite to can pair with this one. Nearby decks can't ask, and requests waiting now are turned away.",children: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",M&&r.jsx("span",{className:"lan-sub-state",children:" · paused while pairing is invite-only"})]}),r.jsxs("div",{className:"lan-switches","data-paused":M||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",...I("ask"),onClick:()=>void j({autoAsk:!U},U?"stop asking automatically":"ask every deck this one finds","ask"),title:M?Vh: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":q,"aria-label":"Say yes to every deck that asks","data-tone":"warn",...I("accept"),onKeyDown:F=>{F.repeat&&F.preventDefault()},onClick:()=>void j({autoAccept:!q},q?"stop accepting automatically":"accept every deck that asks","accept"),title:M?Vh:q?"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"})})]})]})]})]}),(B==null?void 0:B.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:Oae(B)})]}),r.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":H,"aria-label":"Look for my devices over Tailscale","aria-describedby":"lan-ts-detail",...b("tailscale"),onClick:()=>void j({tailscale:!H},H?"stop looking over Tailscale":"look for your devices over Tailscale","tailscale"),title:H?"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"})})]}),H&&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",M&&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":M||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",...I("tailscale-ask"),onClick:()=>void j({tailscaleAsk:!G},G?"stop asking your devices automatically":"ask your devices automatically","tailscale-ask"),title:M?Vh: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":M||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",...I("tailscale-accept"),onKeyDown:F=>{F.repeat&&F.preventDefault()},onClick:()=>void j({tailscaleAccept:!z},z?"stop accepting your devices automatically":"accept your devices automatically","tailscale-accept"),title:M?Vh: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",...b("name"),onClick:()=>void A(),children:"Done"})]})]})}),document.body)}function Dae({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(a5,{})}),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 Fae({accounts:e,onChanged:t,onNoCopy:n,onShared:s,onElsewhere:a,view:o,onOpen:i,onBack:c,closeButton:d}){const[h,f]=y.useState(!1),[p,m]=y.useState(!1),[w,v]=y.useState(!1),b=Rse(),[k,N]=y.useState(!1),{status:j,manual:S,now:_,busy:T,failure:L,dismissFailure:A,answerGiveBack:P,pressProps:O,load:U,toggle:q,answer:M,dropAddress:I,rename:E,checkOne:D,checkNow:B}=Bse(t,()=>f(!0)),{armed:H,pressUnpair:G}=qse(M),[z,F]=y.useState(null),[$,W]=y.useState(!1),Z=y.useMemo(()=>gne(e,j??null),[e,j]),V=y.useMemo(()=>Z.filter(_e=>yne(_e.key,j??null,_)).map(_e=>_e.key).sort().join(`
103
+ `),[Z,j,_]);y.useEffect(()=>{n==null||n(V?V.split(`
104
+ `):[])},[V,n]);const Y=y.useMemo(()=>JSON.stringify(kne(Z,j??null)),[Z,j]);y.useEffect(()=>{s==null||s(new Map(JSON.parse(Y)))},[Y,s]);const X=y.useMemo(()=>JSON.stringify(Z.flatMap(_e=>{const ye=bne(_e.key,j??null,_);return ye?[[_e.key,ye]]:[]})),[Z,j,_]);y.useEffect(()=>{a==null||a(new Map(JSON.parse(X)))},[X,a]);const J=(j==null?void 0:j.enabled)===!0,Q=y.useMemo(()=>one((j==null?void 0:j.pairingMode)==="invite"&&j?{...j,pending:[]}:j,_),[j,_]),te=z?Q.find(_e=>{var ye;return _e.fp===z||((ye=_e.twins)==null?void 0:ye.some(Ie=>Ie.fp===z))})??null:null;y.useEffect(()=>{z&&j&&!te&&F(null)},[z,j,te]);const{asks:ce,rest:ue,live:ie,folded:re,troubled:fe,shown:ae,paired:je}=mne(Q,k),me=sne(j,_),pe=pne(j,Q),xe=r.jsxs(r.Fragment,{children:[p&&j&&r.jsx(cre,{status:j,manual:S,startWith:p==="invite"?"invite":void 0,onClose:()=>m(!1),onChanged:()=>{U(),t()}}),w&&r.jsx(HD,{title:"How Local network works",steps:tre,finish:J?void 0:{label:"Turn it on",act:()=>{v(!1),q()}},onClose:()=>v(!1)}),h&&j&&r.jsx(Pae,{status:{...j,manualRows:S},accounts:Z,manual:S,onClose:()=>f(!1),onChanged:()=>{U(),t()}}),$&&r.jsx(pae,{status:j,rows:Q,accounts:Z,now:_,covered:!!te||h||!!p||w,onOpenDeck:F,onClose:()=>W(!1)}),te&&j&&r.jsx($ae,{row:te,source:Du(j,te),status:j,accounts:Z,now:_,busy:T,onClose:()=>F(null),onRename:_e=>E(te.fp,_e),onCheck:()=>D(te.fp),onVerb:()=>{switch(te.kind){case"paired":return M("unpair",te.fp,"unpair that deck");case"nearby":return M("accept",te.fp,"reach that deck");case"declined":return M("allow",te.fp,"let that deck ask again");case"dialling":return I(te.fp);default:return Promise.resolve(null)}},onSettings:()=>{F(null),f(!0)},onInvite:()=>{F(null),m("invite")},twins:(te.twins??[]).map(_e=>({row:_e,peer:Du(j,_e).peer??null})),onUnpair:_e=>M("unpair",_e,"unpair that deck")})]});return o?r.jsxs("div",{className:"ap-lan-view",children:[r.jsx(Dae,{on:J,status:j,paired:je,busy:T,pressProps:O,checkNow:B,setAddOpen:m,setSetupOpen:f,setMapOpen:W,onBack:c,closeButton:d}),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":J,"aria-label":"Sync with paired decks",...O("switch"),onClick:()=>void q(),title:J?"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(pre,{on:J,status:j}),!J&&r.jsxs("div",{className:"ap-lan-intro-row",children:[r.jsxs("button",{type:"button",className:"ap-lan-intro",onClick:()=>v(!0),title:"Four pictures: what this does, and what to do on each machine",children:[r.jsx(nre,{}),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($u,{film:"localNetwork"})]}),r.jsx("p",{className:`ap-lan-status ${me.tone}`,role:"status",children:me.tone==="ok"?"":me.text}),r.jsx(i5,{line:L,onDismiss:A,onAnswer:P}),J&&r.jsxs(r.Fragment,{children:[ce.length>0&&r.jsx(dre,{asks:ce,pressProps:O,answer:M}),ae.length>0&&r.jsx(hre,{rows:ae,pairingMode:j==null?void 0:j.pairingMode,armed:H,pressProps:O,answer:M,dropAddress:I,onUnpair:G,onOpenPeer:F,onInvite:()=>m("invite")}),(ie.length>0&&re.length>0||J&&je>0)&&r.jsxs("div",{className:"ap-lan-tail",children:[ie.length>0&&re.length>0&&r.jsxs("button",{type:"button",className:"ap-lan-word ap-lan-more","aria-expanded":k,onClick:()=>N(_e=>!_e),title:k?"Show only the decks that are on":`Show the ${re.length} deck${re.length===1?"":"s"} that are not responding right now`,children:[r.jsx("span",{className:`ap-lan-chev${k?" open":""}`,"aria-hidden":!0,children:"›"}),k?"fewer":`${re.length} more`,!k&&fe>0&&r.jsxs("span",{className:"ap-lan-more-bad",children:[" · ",fe," not responding"]})]}),J&&je>0&&r.jsx("span",{className:"ap-lan-checked",children:rne(j==null?void 0:j.checkedAt,_,T==="check")})]}),ue.length===0&&ce.length===0&&!(j!=null&&j.stalled)&&!(j!=null&&j.deaf)&&!(j!=null&&j.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:()=>v(!0),children:"How it works"}),r.jsx($u,{film:"localNetwork"})]})]})]})}),xe]}):r.jsxs("div",{className:"ap-foot",children:[r.jsx(Eae,{entry:pe,rows:Q,onOpen:i,onMap:J?()=>W(!0):void 0,...b}),r.jsx("p",{className:"vis-hidden",role:"status",children:me.tone==="ok"?"":me.text}),xe]})}function Bae({anchorId:e,id:t,peers:n,onHold:s,onLet:a}){const o=y.useRef(null),{title:i,shown:c,rest:d}=Ase(n),h=y.useCallback(()=>{const f=o.current,p=document.getElementById(e);if(!f||!p)return;f.style.maxHeight="";const m=sN(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]),xt.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 qae({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),v=y.useRef(0);y.useEffect(()=>()=>window.clearTimeout(v.current),[]),y.useEffect(()=>{a&&(window.clearTimeout(v.current),w(!1))},[a]);const b=_=>{a||(window.clearTimeout(v.current),v.current=window.setTimeout(()=>w(!0),_))},k=()=>{window.clearTimeout(v.current),v.current=window.setTimeout(()=>w(!1),UD)},N=()=>window.clearTimeout(v.current),j=()=>{window.clearTimeout(v.current),w(!1)},S=Ese(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:()=>{j(),o()},onPointerEnter:_=>{_.pointerType==="mouse"&&b(qD)},onPointerLeave:k,onFocus:_=>{_.target.matches(":focus-visible")&&b(0)},onBlur:k,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(Bae,{anchorId:"ap-rest-entry",id:"ap-rest-peek",peers:e,onHold:N,onLet:k}),a&&r.jsx(Uae,{order:i,choices:c,onOrder:d,allOpen:h,onToggleAll:f,held:p})]})}function Uae({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===zp?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 Wae(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}const Hae=1800;function zae({accounts:e,onClose:t,copyText:n}){tn("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,v]=y.useState(()=>Math.floor(Date.now()/1e3)),b=y.useRef(null),k=y.useRef(!1),N=ft(t,{focusRef:b}),j=mt(t),S=Jr(o!=null,b),_=Jr(o==null,b);y.useEffect(()=>{if(!o)return;v(Math.floor(Date.now()/1e3));const B=window.setInterval(()=>v(Math.floor(Date.now()/1e3)),1e3);return()=>window.clearInterval(B)},[o]);const T=use(e),L=dse(e,s),A=L.length===e.length,P=B=>a(H=>hse(H,B)),O=y.useCallback(async()=>{const B=fse(L);if(!bn(k.current)||!B)return;k.current=!0,d(!0),f(null),m(!1);const H=await Wae(B).catch(()=>null);if(k.current=!1,d(!1),!(H!=null&&H.ok)){f(il(H,"the share could not be made"));return}i({blob:H.blob,expiresAt:H.expiresAt,shared:H.shared??[],failed:H.failed??[]})},[e,L]),U=o?FD(o.expiresAt,w):null,q=(U==null?void 0:U.tone)==="gone",M=(o==null?void 0:o.shared.length)??0,I=q?"This share has expired":M===1?"1 account, ready to paste":`${M} accounts, ready to paste`,E=M===1?"this is the password":`this is ${M} passwords`,D=o?q?I:`${I} — ${E}`:"";return xt.createPortal(r.jsx("div",{className:"modal-backdrop",...j,role:"presentation",children:r.jsxs("div",{ref:N,className:"modal sa-modal",onClick:B=>B.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:D}),o?r.jsxs("div",{className:"sa-step",children:[r.jsx("h4",{children:I}),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:b,onClick:async()=>{if(q){_(),S(),i(null),O();return}await n(o.blob)&&(m(!0),window.setTimeout(()=>m(!1),Hae))},children:q?"make a new share":p?"copied":`copy ${M===1?"the share":"all "+M}`}),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:E})," · ",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(B=>{var G;const H=!!(B.email&&((G=B.detail)!=null&&G.includes(B.email)));return r.jsxs("li",{children:[!H&&r.jsx("span",{className:"sa-who",children:B.email||`account ${B.num}`}),r.jsx("span",{className:"sa-why",children:B.detail||"could not be exported"})]},`${B.num}-${B.email}`)})})]}),r.jsx("p",{className:"sa-note",children:q?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:b,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${L.length?"":" empty"}`,children:pse(L.length)}),r.jsx("ul",{className:"sa-list sa-pick",children:T.map(B=>r.jsx("li",{children:r.jsxs("label",{className:"sa-row",children:[r.jsx("input",{type:"checkbox",checked:L.includes(B.num),onChange:()=>P(B.num)}),r.jsx("span",{className:"sa-who",children:B.label}),B.sub&&r.jsx("span",{className:"sa-sub",children:B.sub})]})},B.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(B=>B.num):[]),children:A?"Clear all":"Select all"}),r.jsx("button",{type:"button",className:"btn primary",ref:b,...On(c,!L.length),onClick:()=>{S(),O()},children:c?"making the share…":L.length===0?"Share":L.length===1?"Share 1 account":`Share ${L.length} accounts`})]})]})]})]})}),document.body)}function wN(e,t){var n;return!e.disabled&&!((n=si(e,t))!=null&&n.blocksSwitch)}function Vae(e,t,n){return e.map(s=>{const a=si(s,t,n==null?void 0:n(s));return{key:bs(s),name:s.alias??s.email??`account ${s.num}`,ready:wN(s,t),why:s.disabled?"held out":a!=null&&a.blocksSwitch?a.text:null,warn:(a==null?void 0:a.tone)==="warn",headroom:aN(s,t)}})}function Gae(e,t,n){const s=Number(t),a=e&&(n==null?e.headroom:aN(e,n));return a!=null&&Number.isFinite(s)&&100-a>=s}function Kae(e){return(e==null?void 0:e.ok)===!0&&(e.enabled||e.external)}const l5="agent-dag.otherAccountsOrder",c5="agent-dag.otherAccountsOpen";function u5(){const e=Ke(l5);return typeof e=="string"&&e.length>0&&e.length<=64?e:zp}function Yae(e){Ze(l5,e)}function Xae(){const e=Ke(c5);if(!e)return c1;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 c1}function Zae(e){Ze(c5,JSON.stringify({mode:e.mode,keys:e.keys.filter(t=>!t.startsWith("slot:"))}))}function Jae(){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=no(e,i);return{disabled:d.disabled,"aria-busy":d.busy||c}}}}const Qae=8e3,eoe=1800,toe=4e3;function noe({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(""),[v,b]=y.useState(null),k=y.useRef(0);y.useEffect(()=>{if(v==null)return;const V=window.setTimeout(()=>b(null),toe);return()=>window.clearTimeout(V)},[v]);const[N,j]=y.useState(null),[S,_]=y.useState(!1),[T,L]=y.useState(null),[A,P]=y.useState(null),O=y.useCallback(async(V,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(V)}),J=await X.json().catch(()=>null);return J!=null&&J.ok||p({text:il(J,"command failed",X.status)}),J}catch{return p({text:"server unreachable"}),null}finally{t()}},[e,t,s]),U=y.useCallback(()=>{c(null),p(null),b(null),j(null),_(!1)},[]),q=(V,Y="first")=>{U(),P(null),c({num:V,view:"menu",start:Y})},M=y.useCallback(V=>{var J,Q;const Y=h.current;if(!Y||V!=null&&Y.num!==V)return;const X=document.getElementById(`ap-menu-${Y.num}`);(X!=null&&X.contains(document.activeElement)||Bn(((J=document.activeElement)==null?void 0:J.tagName)??null))&&((Q=document.getElementById(`ap-more-${Y.num}`))==null||Q.focus()),U()},[U]),I=y.useCallback(V=>p(V),[]),E=(V,Y)=>{w(Y??""),p(null),c({num:V,view:"rename"})},D=V=>w(V),B=V=>{P(null),p(null),c({num:V,view:"move"})},H=V=>P(V),G=async V=>{var X;_(!1);const Y=await O({action:"share",account:V},`share-${V}`);!(Y!=null&&Y.ok)||((X=h.current)==null?void 0:X.num)!==V||(j({num:V,blob:Y.blob,expiresAt:Y.expiresAt}),c({num:V,view:"share"}))},z=async V=>{await lo(V)&&(_(!0),window.setTimeout(()=>_(!1),eoe))},F=async(V,Y)=>{const{commit:X,alias:J}=bse(m,Y);if(X){const Q=await O({action:"alias",account:V,alias:J},`alias-${V}`);if(await n(!0),!(Q!=null&&Q.ok))return}M(V)},$=async(V,Y)=>{var Q,te,ce;const X=await O({action:"move",account:V,slot:Y},`move-${V}`),J=xse({menuFor:((Q=h.current)==null?void 0:Q.num)??null,shareFor:(N==null?void 0:N.num)??null},V,X);if(await n(!0),J){if(J.menuFor!=null){const ie=document.getElementById(`ap-menu-${V}`),re=document.getElementById(`ap-more-${J.menuFor}`);re&&(ie!=null&&ie.contains(document.activeElement)||Bn(((te=document.activeElement)==null?void 0:te.tagName)??null))&&re.focus()}((ce=h.current)==null?void 0:ce.num)===V&&U(),b(J.confirmRemove),J.shareFor==null&&(j(null),_(!1)),L(J.swapNote);const ue=J.swapNote;ue&&window.setTimeout(()=>L(ie=>ie===ue?null:ie),Qae),P(null),a(J.menuFor)}return X};return{menu:i,menuFor:d,menuError:f,aliasDraft:m,confirmRemove:v,share:N,shareCopied:S,slotDraft:A,swapNote:T,showMenu:q,dropMenu:U,closeMenu:M,sayInMenu:I,startRename:E,typeAlias:D,doAlias:F,startMove:B,pickSlot:H,doSlot:async(V,Y,X)=>{if(!X.sends){M(V);return}await $(V,Y)},makeShare:G,copyShare:z,pressRemove:V=>{const Y=Date.now(),X=ni({armedFor:v,target:V,armedAt:k.current,now:Y,gapMs:ti});if(X==="arm"){b(V),k.current=Y;return}X!=="ignore"&&(b(null),O({action:"remove",account:V},`rm-${V}`).then(J=>{var Q;n(!0),J!=null&&J.ok&&(o==null||o(J),((Q=h.current)==null?void 0:Q.num)===V&&U(),a(null))}))}}}function soe(e,t){return!e||!t||t.some(n=>n.num===e.num&&n.active)?e:null}const roe="login_expired";function aoe(e,t,n){return(e==null?void 0:e.reason)!==roe?null:{text:`${t}'s login expired · sign in again to use it`,row:n,signIn:!0}}const ooe="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 ioe(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:ooe}}:null}function loe({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,v,b="panel")=>{if(!t(v))return null;const k=b==="menu"?i:a;k(null);try{const N=await fetch("/api/cswap-auto",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(w)}),j=await N.json().catch(()=>null);return j!=null&&j.ok||k({text:d1(j,"command failed",N.status),raw:Pu(j)}),j}catch{return k({text:"server unreachable"}),null}finally{n()}},[t,n,i,a]);y.useEffect(()=>{!(e!=null&&e.ok)||!e.accounts||h(w=>soe(w,e.accounts))},[e]);const p=async(w,v)=>{if(t(`switch-${w}`)){o(),h(null);try{const k=await(await fetch("/api/claude-accounts/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({account:w})})).json().catch(()=>null),N=aoe(k,v,w);N?a(N):k!=null&&k.ok?h({num:w,name:v}):a({text:d1(k,"the switch failed"),raw:Pu(k),row:w}),await s(!0)}catch{a({text:"server unreachable",row:w})}finally{n(),c(w)}}},m=y.useCallback((w,v)=>h({num:w,name:v}),[]);return{switched:d,post:f,doSwitch:p,noteSwitched:m}}const coe=1800;function uoe({auto:e,post:t,load:n}){var L;const[s,a]=y.useReducer(Pne,m1),[o,i]=y.useState(!1),c=y.useRef(null),d=y.useRef(null),h=y.useRef(null),f=y.useRef(!1),p=((L=e==null?void 0:e.settings["autoswitch.threshold"])==null?void 0:L.value)??"90",m=s.pick??p,w=Sse(m,p),v=s.custom!=null,b=s.refusal,k=y.useRef(v);return y.useEffect(()=>{var A,P,O;k.current!==v&&(k.current=v,v?((A=h.current)==null||A.focus(),(P=h.current)==null||P.select()):f.current&&((O=c.current)==null||O.focus()),f.current=!1)},[v]),{threshold:p,thresholdPick:m,thresholdCtl:w,thresholdSaved:o,thresholdRef:c,thresholdSaveRef:d,thresholdCustom:v,thresholdRefusal:b,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,P)=>{const O=await Dne(A,P,t);if(O.kind==="refused"){a({kind:"refuse",message:O.message});return}O.kind==="sent"&&(await n(!0),!O.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)},coe))}}}const doe=1800;function hoe({auto:e,post:t,load:n}){var v;const[s,a]=y.useState(null),[o,i]=y.useState(!1),c=y.useRef(null),d=y.useRef(null),h=((v=e==null?void 0:e.choice)==null?void 0:v.next)??"room",f=s??h,p=Nse(f,h);return{nextPick:f,nextCtl:p,nextSaved:o,nextRef:c,nextSaveRef:d,proposeNext:b=>a(Mne(b)?b:null),doNext:async()=>{if(!p.sends)return;const b=await t({action:"next",value:f},"next");await n(!0),b!=null&&b.ok&&(a(null),i(!0),window.setTimeout(()=>{var k;document.activeElement===d.current&&((k=c.current)==null||k.focus()),i(!1)},doe))}}}const foe=Object.freeze({text:"couldn't reach the deck server",reload:!0}),poe=Object.freeze({text:"still waiting on the deck server — claude-swap can be slow to answer",reload:!0});async function RA(e){return e.ok?{ok:!0,status:e.status,body:null}:{ok:!1,status:e.status,body:await e.json().catch(()=>null)}}function moe(e){const t=e.find(s=>!s.ok);if(!t)return null;const n=Pu(t.body);return{text:d1(t.body,`the deck server answered ${t.status}`),...n?{raw:n}:{},reload:!0}}function My(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 $y=e=>e!=null&&typeof e=="object"&&!Array.isArray(e),Ly=e=>e==null||typeof e=="string",Iy=e=>e==null||typeof e=="number"&&Number.isFinite(e)&&e>=0&&Number.isFinite(new Date(e).getTime());function goe(e){if(!$y(e)||typeof e.ok!="boolean")return!1;if(!e.ok)return Ly(e.reason)&&Ly(e.hint);if(!Array.isArray(e.accounts))return!1;const t=new Set;return e.accounts.every(n=>{if(!$y(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(Ly)||![n.active,n.disabled,n.stale].every(a=>typeof a=="boolean")||!Iy(n.fetchedAt)||!Iy(n.nextAt)||!Array.isArray(n.lanes)))return!1;const s=new Set;return n.lanes.every(a=>!$y(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||!Iy(a.resetAt==null?null:typeof a.resetAt=="number"?a.resetAt*1e3:NaN)?!1:(s.add(a.id),!0))})}const d5=15e3,yoe=3e4;function h5(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(k=!1)=>{if(!p.current||!k&&m.current.size>0)return;const N=++f.current;k&&i(!0);const j=new AbortController;m.current.add(j);const S=window.setTimeout(()=>j.abort(),yoe);try{const[_,T]=await Promise.all([fetch(`/api/claude-accounts${k?"?refresh=1":""}`,{signal:j.signal}),fetch("/api/cswap-auto",{signal:j.signal})]),[L,A]=await Promise.all([_.ok?_.json():null,T.ok?T.json():null]),P=moe([await RA(_),await RA(T)]);if(!p.current||N!==f.current)return;if(L&&!goe(L)){d(O=>My(O,{text:"the deck server returned unreadable account data",reload:!0}));return}L&&(n(L),e(L)),A&&a(A),d(O=>My(O,P))}catch{p.current&&N===f.current&&d(_=>My(_,j.signal.aborted?poe:foe))}finally{window.clearTimeout(S),m.current.delete(j),p.current&&N===f.current&&i(!1)}},[e]);y.useEffect(()=>(p.current=!0,w(!0),h.current=window.setInterval(()=>w(!1),d5),()=>{p.current=!1,f.current++,h.current!=null&&window.clearInterval(h.current);for(const k of m.current)k.abort()}),[w]);const v=y.useCallback(k=>d(k),[]),b=y.useCallback(()=>d(null),[]);return{data:t,auto:s,reloading:o,failure:c,load:w,sayFailure:v,clearFailure:b}}const woe="#ap-rest-entry";function xoe(e){return[`#${e}`,woe,...eP(null)]}function voe(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||!Bn(((o=document.activeElement)==null?void 0:o.tagName)??null)))for(const i of xoe(a)){const c=document.querySelector(i);if(c){c.focus();return}}},[e]),{onFocus:n,onBlur:s}}function boe({onClose:e,leaving:t,onReport:n,onRoster:s,lanWanted:a=!1,onLanShown:o}){var Mr,Rs,lr;tn("accounts-panel");const i=qn(),{busy:c,claim:d,release:h,pressProps:f}=Jae(),[p,m]=y.useState("accounts"),[w,v]=y.useState(!1),[b,k]=y.useState(null),N=y.useRef(b);N.current=b;const[j,S]=y.useState(!1),[_,T]=y.useState(null),[L,A]=y.useState(!1),[P,O]=y.useState(null),[U,q]=y.useState(Xae),[M,I]=y.useState(u5),[E,D]=y.useState(null),[B,H]=y.useState(!1),G=y.useRef(s);G.current=s;const z=y.useCallback(ge=>{var We;q(dt=>_te(dt,ge.accounts)),(We=G.current)==null||We.call(G,ge)},[]),{data:F,auto:$,reloading:W,failure:Z,load:V,sayFailure:Y,clearFailure:X}=h5(z),J=voe(F),Q=y.useCallback(ge=>{window.requestAnimationFrame(()=>{var We;if(Bn(((We=document.activeElement)==null?void 0:We.tagName)??null))for(const dt of eP(ge)){const Nt=document.querySelector(dt);if(Nt){Nt.focus();return}}})},[]),te=y.useRef(null),ce=noe({claim:d,release:h,load:V,clearFailure:X,rescueFocus:Q,afterRemove:ge=>{var We;return(We=te.current)==null?void 0:We.call(te,ge)}}),{menu:ue,menuFor:ie,swapNote:re,showMenu:fe,dropMenu:ae,closeMenu:je,sayInMenu:me}=ce,{switched:pe,post:xe,doSwitch:_e,noteSwitched:ye}=loe({data:F,claim:d,release:h,load:V,sayFailure:Y,clearFailure:X,sayInMenu:me,rescueFocus:Q});te.current=ge=>{const We=ioe(ge);We&&"switched"in We?ye(We.switched.num,We.switched.name):We&&Y(We.failure)};const Ie=ge=>{T(ge),S(!0)},{threshold:Pe,thresholdPick:Ue,thresholdCtl:$e,thresholdSaved:Je,thresholdRef:Qe,thresholdSaveRef:ze,thresholdCustom:Ne,thresholdRefusal:Ae,thresholdFieldRef:qe,proposeThreshold:et,typeThreshold:ot,cancelThreshold:we,leaveThreshold:Ge,doThreshold:Ye}=uoe({auto:$,post:xe,load:V}),{nextPick:Xe,nextCtl:rt,nextSaved:jt,nextRef:Ut,nextSaveRef:pt,proposeNext:Ct,doNext:It}=hoe({auto:$,post:xe,load:V}),Wt=Jj();y.useEffect(()=>{Zae(U)},[U]),y.useEffect(()=>{Yae(M)},[M]);const[tr,Cs]=y.useState(()=>new Set),Jn=y.useCallback(ge=>Cs(new Set(ge)),[]),[Qn,Es]=y.useState(()=>new Map),[fn,Un]=y.useState(()=>new Map),Ce=ge=>{const We=nA([ge])[0].key,dt=Qn.get(We);return{noCopyWorksNearby:tr.has(We),sharedTo:(dt==null?void 0:dt.to)??null,sharedInUse:(dt==null?void 0:dt.inUse)===!0,elsewhere:fn.get(We)??null}},Re=(Mr=F==null?void 0:F.accounts)==null?void 0:Mr.find(ge=>ge.active),He=Re?si(Re,Wt,Ce(Re)):null,vt=pe?(Rs=F==null?void 0:F.accounts)==null?void 0:Rs.find(ge=>ge.num===pe.num):void 0,Et=vt?Ce(vt).elsewhere:null,es=Et!=null&&Et.length?`. Also active on ${mD(Et)}: when one machine renews this login, the other is signed out.`:"",ts=(F==null?void 0:F.accounts)??[],pn=Re?ts.filter(ge=>!ge.active):[],nr=yD(pn),mn=xD(M,pn),nn=l1(wD(pn,mn,ge=>wN(ge,Wt),Wt),E),ns=y.useRef(!1),Ts=y.useRef(!1),sr=y.useRef(!1),As=y.useCallback(()=>{!ns.current&&!Ts.current&&!sr.current&&D(null)},[]),rr=()=>D(ge=>ge??nn.map(bs)),ar={onPointerEnter:()=>{ns.current=!0,rr()},onPointerLeave:()=>{ns.current=!1,As()},onFocus:ge=>{ge.target.matches(":focus-visible")&&(Ts.current=!0,rr())},onBlur:ge=>{ge.currentTarget.contains(ge.relatedTarget)||(Ts.current=!1,As())}},or=ie!=null&&pn.some(ge=>ge.num===ie)||b!=null&&pn.some(ge=>ge.num===b.num);y.useEffect(()=>{sr.current=or,or||As()},[or,As]);const ha=B&&pn.length>0;y.useEffect(()=>{ha||(ns.current=Ts.current=sr.current=!1,D(null))},[ha]);const ht=y.useRef(!1);y.useEffect(()=>{ht.current&&pn.length===0&&Q(null),ht.current=pn.length>0},[pn.length,Q]);const fa=nn.length?ts.filter(ge=>ge.active):ts,Tr=Vae(nn,Wt,Ce),pa=Gae(Re,Pe,Wt),Mt=Kae($),Ar=ge=>B&&nn.some(We=>We.num===ge)?"ap-rest-list":"ap-scroll",ir=(ge,We="first")=>{fe(ge,We),k(null)},ss=(ge,We)=>{ae(),k(dt=>(dt==null?void 0:dt.anchor)===We?null:{num:ge,anchor:We})},Zt=y.useCallback((ge=!1)=>{var dt;const We=N.current;ge&&We&&((dt=document.getElementById(We.anchor))==null||dt.focus()),k(null)},[]),Rr=()=>{ae(),k(null),m("lan")},on=y.useRef(p);y.useEffect(()=>{on.current!==p&&(on.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&&v(!0)},[F==null?void 0:F.ok]),y.useEffect(()=>{!a||!w||(Rr(),o==null||o())},[a,w]),y.useEffect(()=>{t&&(ae(),k(null))},[t,ae]),y.useEffect(()=>{ue&&(F!=null&&F.accounts)&&!F.accounts.some(ge=>ge.num===ue.num)&&ae(),b&&(F!=null&&F.accounts)&&!F.accounts.some(ge=>ge.num===b.num)&&k(null)},[F,ue,b,ae]),y.useEffect(()=>{P==null||!(F!=null&&F.accounts)||F.accounts.some(ge=>ge.num===P.num)||(O(null),Q(null))},[F,P,Q]);const ma=r.jsx("button",{type:"button",className:"glyph-btn",onClick:e,"aria-label":"Close accounts panel",title:kn("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"})})}),ui=ge=>{var ga;const We=vD(U,ge),dt=ie===ge.num,Nt=(Z==null?void 0:Z.row)===ge.num?Z:null,Nn=(pe==null?void 0:pe.num)===ge.num,rs=(re==null?void 0:re.at)===ge.num?re:null,as=rs?ts.find(at=>at.num===rs.displaced):void 0,Gl=(b==null?void 0:b.anchor)===`ap-issue-${ge.num}`;return r.jsx(Cne,{a:ge,nowSec:Wt,lan:Ce(ge),opened:We,onToggleLanes:()=>q(at=>Nte(at,ge)),busy:c,pressProps:f,onSwitch:_e,menuOpen:dt,onOpenMenu:ir,onCloseMenu:je,refusal:Nt,onDismissRefusal:()=>X(),onSignIn:Ie,switchedHere:Nn,swapped:rs,displaced:as,issueExpanded:Gl,onOpenIssue:ss,sortKey:ge.active?null:kte(mn),home:Cy(ge,(ga=$==null?void 0:$.choice)==null?void 0:ga.home)?$ne(ge,!!($!=null&&$.enabled)):null,rotating:!!($!=null&&$.enabled||$!=null&&$.external)},ge.num)},Vl=F!=null&&F.ok&&($!=null&&$.ok)?r.jsx(Fne,{auto:$,threshold:Pe,thresholdPick:Ue,thresholdCtl:$e,thresholdSaved:Je,thresholdRef:Qe,thresholdSaveRef:ze,thresholdCustom:Ne,thresholdRefusal:Ae,thresholdFieldRef:qe,proposeThreshold:et,typeThreshold:ot,cancelThreshold:we,leaveThreshold:Ge,doThreshold:Ye,nextPick:Xe,nextCtl:rt,nextSaved:jt,nextRef:Ut,nextSaveRef:pt,proposeNext:Ct,doNext:It,pressProps:f,post:xe,load:V}):null;return r.jsxs("aside",{className:`accounts-panel${t?" leaving":""}`,id:"accounts-panel","aria-label":"Claude accounts",onFocus:J.onFocus,onBlur:J.onBlur,children:[p==="accounts"&&r.jsx(Tne,{canShare:(((lr=F==null?void 0:F.accounts)==null?void 0:lr.length)??0)>0,onAdd:()=>S(!0),onShareSet:()=>A(!0),onReload:()=>V(!0),pressProps:f,reloading:W,closeButton:ma}),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 ",d5/1e3," seconds."]}),r.jsx("button",{type:"button",className:"ap-fix",...f("reload",W),onClick:()=>V(!0).then(()=>Q(null)),children:W?"trying…":"try again"})]}):r.jsx("div",{className:"ap-empty",children:"Checking…"}):F.ok?r.jsxs(r.Fragment,{children:[Re&&(He==null?void 0:He.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":(b==null?void 0:b.anchor)==="ap-notice","aria-controls":(b==null?void 0:b.anchor)==="ap-notice"?"ap-issue-pop":void 0,onClick:()=>ss(Re.num,"ap-notice"),children:[r.jsx(rN,{}),r.jsx("span",{className:"ap-issue-text",children:"Current account needs attention"})]}),He.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"})]}),!Re&&F.unlistedLogin&&r.jsxs("div",{className:"ap-notice",children:[r.jsxs("span",{className:"ap-notice-text",children:["Claude Code is signed in to ",r.jsx("strong",{children:F.unlistedLogin}),", which isn't in your accounts."]}),r.jsx("button",{type:"button",className:"ap-notice-fix",onClick:()=>S(!0),title:"Open the add dialog. Once this login is one of your accounts, the deck can switch to it and back.",children:"Add account"})]}),r.jsx("ul",{className:"ap-list",children:fa.map(ui)}),nn.length>0&&r.jsx(qae,{peers:Tr,strained:pa,armed:Mt,threshold:$!=null&&$.ok?Pe:null,open:B,onToggle:()=>H(ge=>!ge),order:mn,choices:nr,onOrder:I,allOpen:bD(U,nn),onToggleAll:()=>q(ge=>Ste(ge,nn)),held:E!=null}),nn.length>0&&B&&r.jsxs("div",{className:"ap-rest-panel",id:"ap-rest-panel",children:[r.jsx("ul",{className:"ap-list ap-others",id:"ap-rest-list",...ar,children:nn.map(ui)}),Vl]}),nn.length===0&&Vl,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:()=>X(),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),ue&&(()=>{var We,dt;const ge=(We=F.accounts)==null?void 0:We.find(Nt=>Nt.num===ue.num);return ge?r.jsx(_se,{a:ge,accountMenu:ce,slots:(F.accounts??[]).map(Nt=>Nt.num),boundaryId:Ar(ge.num),nowSec:Wt,busy:c,pressProps:f,onProjects:()=>{O({num:ge.num,name:ge.alias??ge.email??`account ${ge.num}`}),je(ge.num)},onRotation:()=>xe({action:"account",account:ge.num,enabled:ge.disabled},`rot-${ge.num}`,"menu").then(Nt=>{V(!0),Nt!=null&&Nt.ok&&je(ge.num)}),home:Cy(ge,(dt=$==null?void 0:$.choice)==null?void 0:dt.home),onHome:()=>{var Nt;return xe({action:"home",account:Cy(ge,(Nt=$==null?void 0:$.choice)==null?void 0:Nt.home)?null:ge.num},`home-${ge.num}`,"menu").then(Nn=>{V(!0),Nn!=null&&Nn.ok&&je(ge.num)})}}):null})(),b&&(()=>{var dt;const ge=(dt=F.accounts)==null?void 0:dt.find(Nt=>Nt.num===b.num),We=ge?si(ge,Wt,Ce(ge)):null;return!ge||!We?null:r.jsx(cte,{anchorId:b.anchor,boundaryId:b.anchor==="ap-notice"?"ap-scroll":Ar(ge.num),issue:We,who:ge.alias??ge.email??`account ${ge.num}`,fetchedAt:ge.fetchedAt,nowSec:Wt,onClose:Zt,onSignIn:()=>S(!0),onReport:n&&(()=>n({initialKind:We.tone==="warn"?"bug":"other",initialBody:`Account issue: ${We.text}. ${We.hint}`}))})})()]}):r.jsx(Ene,{data:F}),r.jsx("div",{className:"film-foot",children:r.jsx($u,{film:"claudeAccounts"})})]}),r.jsxs("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:[pe?`Now active: ${pe.name}`:"",pe?es:""]}),w&&r.jsx(Fae,{accounts:nA((F==null?void 0:F.accounts)??[]),onChanged:()=>V(!0),onNoCopy:Jn,onShared:Es,onElsewhere:Un,view:p==="lan",onOpen:Rr,onBack:()=>m("accounts"),closeButton:ma}),j&&r.jsx(BD,{email:_,onClose:()=>{S(!1),T(null)},onChanged:()=>V(!0)}),L&&r.jsx(zae,{accounts:((F==null?void 0:F.accounts)??[]).map(ge=>({num:ge.num,email:ge.email,alias:ge.alias,org:ge.org})),onClose:()=>A(!1),copyText:lo}),P!=null&&(()=>{var We;const ge=(We=F==null?void 0:F.accounts)==null?void 0:We.find(dt=>dt.num===P.num);return F!=null&&F.accounts&&!ge?null:r.jsx(ite,{num:P.num,name:ge?ge.alias??ge.email??`account ${ge.num}`:P.name,onClose:()=>O(null)})})()]})}function Dt({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 koe=()=>r.jsxs(Dt,{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"})]}),joe=()=>r.jsxs(Dt,{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"})]}),Noe=()=>r.jsxs(Dt,{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"})]}),Soe=()=>r.jsxs(Dt,{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"})]}),_oe=()=>r.jsxs(Dt,{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"})]}),Coe=()=>r.jsxs(Dt,{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"})]}),Eoe=({watching:e})=>r.jsxs(Dt,{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"})]}),Toe=()=>r.jsxs(Dt,{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"})]}),Aoe=()=>r.jsxs(Dt,{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"})]}),Roe=()=>r.jsx(Dt,{children:r.jsx("path",{d:"M4.6 2.9v8.2L11.1 7Z"})}),Moe=()=>r.jsxs(Dt,{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"})]}),$oe=()=>r.jsxs(Dt,{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"})]}),Loe=()=>r.jsx(Dt,{children:r.jsx("path",{d:"M2 5h10v7H2z M4 5l6-3 M4 8h3 M9 8h1 M4 10h1 M8 10h2"})}),Ioe=()=>r.jsxs(Dt,{children:[r.jsx("rect",{x:"1.6",y:"5.4",width:"10.8",height:"6.4",rx:"1.2"}),r.jsx("path",{d:"M4 5.4V3h6v2.4"}),r.jsx("path",{d:"M1.6 8.4h4.2M8.2 8.4h4.2"}),r.jsx("path",{d:"M5.8 7.6h2.4v1.6H5.8z"})]}),Ooe=()=>r.jsxs(Dt,{children:[r.jsx("path",{d:"M6 2.4c.4 2.5 1.5 3.6 4 4-2.5.4-3.6 1.5-4 4-.4-2.5-1.5-3.6-4-4 2.5-.4 3.6-1.5 4-4Z"}),r.jsx("path",{d:"M11.2 1.4v2.6M9.9 2.7h2.6"})]}),Poe=()=>r.jsxs(Dt,{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"})]}),Doe=()=>r.jsxs(Dt,{children:[r.jsx("rect",{x:"2.2",y:"3.2",width:"9.6",height:"8.6",rx:"1.4"}),r.jsx("path",{d:"M2.2 6.2h9.6M4.9 1.8v2.6M9.1 1.8v2.6"}),r.jsx("path",{d:"M8.6 9h.2"})]}),Foe=()=>r.jsxs(Dt,{children:[r.jsx("circle",{cx:"7",cy:"7",r:"5"}),r.jsx("path",{d:"M7 3.8V7l2.2 1.4"})]}),Boe=()=>r.jsx(Dt,{children:r.jsx("path",{fill:"currentColor",stroke:"none",transform:"translate(1.25 1.25) scale(0.479)",d:"M11.571 11.513H0a5.218 5.218 0 0 0 5.232 5.215h2.13v2.057A5.215 5.215 0 0 0 12.575 24V12.518a1.005 1.005 0 0 0-1.005-1.005zm5.723-5.756H5.736a5.215 5.215 0 0 0 5.215 5.214h2.129v2.058a5.218 5.218 0 0 0 5.215 5.214V6.758a1.001 1.001 0 0 0-1.001-1.001zM23.013 0H11.455a5.215 5.215 0 0 0 5.215 5.215h2.129v2.057A5.215 5.215 0 0 0 24 12.483V1.005A1.001 1.001 0 0 0 23.013 0z"})}),qoe=()=>r.jsx(Dt,{children:r.jsx("path",{fill:"currentColor",stroke:"none",transform:"translate(1.25 1.25) scale(0.479)",d:"M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"})}),Uoe=()=>r.jsx(Dt,{children:r.jsx("path",{fill:"currentColor",stroke:"none",transform:"translate(1.25 1.25) scale(0.479)",d:"m23.6004 9.5927-.0337-.0862L20.3.9814a.851.851 0 0 0-.3362-.405.8748.8748 0 0 0-.9997.0539.8748.8748 0 0 0-.29.4399l-2.2055 6.748H7.5375l-2.2057-6.748a.8573.8573 0 0 0-.29-.4412.8748.8748 0 0 0-.9997-.0537.8585.8585 0 0 0-.3362.4049L.4332 9.5015l-.0325.0862a6.0657 6.0657 0 0 0 2.0119 7.0105l.0113.0087.03.0213 4.976 3.7264 2.462 1.8633 1.4995 1.1321a1.0085 1.0085 0 0 0 1.2197 0l1.4995-1.1321 2.4619-1.8633 5.006-3.7489.0125-.01a6.0682 6.0682 0 0 0 2.0094-7.003z"})});function MA(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`}function Woe(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:MA(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(j=>j.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=u1(c,"seven_day",t),m=si(c,t),w=Vp(c.fetchedAt),v=w==null,b=n||v||c.stale||c.staleCopy===!0||c.stopped===!0||(m==null?void 0:m.blocksSwitch)===!0||t*1e3-w>kD,k=n?"Last saved reading":m!=null&&m.blocksSwitch||c.staleCopy||c.stopped?(m==null?void 0:m.text)??"Not collecting":v?"Never read":b?`${c.stale?"Marked stale · ":""}Read ${la(w,t)}`:null,N={key:bs(c),name:jD(c),active:c.active,heldOut:c.disabled,at:f,used:p.counted?p.pct:p.last,stale:b,note:k};if(f==null)i.push({...N,reason:"unknown"});else if(f<=t)i.push({...N,reason:"passed"});else{const j=o.get(MA(new Date(f*1e3)));j?(j.entries.push(N),b?j.outdated++:j.scheduled++):i.push({...N,reason:"outside"})}}for(const c of a)c.entries.sort((d,h)=>d.at-h.at);return{days:a,unscheduled:i}}const ff=e=>e.toLocaleDateString(void 0,{weekday:"short"}),sp=e=>e.toLocaleDateString(void 0,{month:"short",day:"numeric"}),uu=e=>e.toLocaleDateString(void 0,{weekday:"long",month:"long",day:"numeric",year:"numeric"}),xN=(e,t)=>e-t<60?"less than 1m":Gu(e,t);function Zp({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 pf({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 f5({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(pf,{entry:e}),o]}):s?r.jsxs("span",{className:"ap-reset-summary-content",children:[r.jsx(pf,{entry:e}),r.jsx(p5,{entry:e,older:a})]}):r.jsx(pf,{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: ":""}${so(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 ${xN(h,n)}`," · ",r.jsx(Zp,{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 p5({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: ":""}${so(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 Hoe({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(f5,{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:[sp(new Date(e.at*1e3))," · ",r.jsx(Zp,{at:e.at})]})]}),r.jsx(p5,{entry:e,past:e.reason==="passed"})]})})})}function $A({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":uu(a.date),children:[r.jsxs("h4",{className:"vis-hidden",children:[uu(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:[ff(a.date)," · ",sp(a.date)]}),r.jsx(Zp,{at:i}),!s&&r.jsxs("span",{children:["in ",xN(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(f5,{entry:d,row:t.get(d.key),nowSec:n,withReading:!0,older:s})},d.key))})]},i))})]},a.key):null})})}function zoe({accounts:e,nowSec:t,held:n,selectedDate:s=null,onSelect:a=()=>{},scope:o="upcoming",onScope:i=()=>{}}){const{days:c,unscheduled:d}=Woe(e,t,n!=null),h=c.find(P=>P.key===s)??null,f=h?[h]:c,p=c.reduce((P,O)=>P+O.scheduled,0),m=f.reduce((P,O)=>P+O.outdated,0),w=c.reduce((P,O)=>P+O.outdated,0),v=h?h.scheduled:p,b=c.flatMap(P=>P.entries).find(P=>!P.stale),k=b?c.flatMap(P=>P.entries).filter(P=>!P.stale&&P.at===b.at):[],N=y.useRef(null),j=y.useRef(null),S=y.useRef(null);y.useEffect(()=>{var O,U;const P=S.current;P&&!P.isConnected&&document.activeElement===document.body&&((U=(O=j.current)==null?void 0:O.querySelector('.ap-reset-coverage-link[aria-pressed="true"]'))==null||U.focus({preventScroll:!0}))});const _=()=>{N.current&&(N.current.scrollTop=0)},T=P=>{_(),a(null),i(P)},L=Intl.DateTimeFormat().resolvedOptions().timeZone,A=new Map(lN(e,t).rows.map(P=>[P.key,P]));return r.jsxs("div",{ref:j,onFocusCapture:P=>{S.current=P.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:b?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"ap-reset-next-identity",children:[r.jsxs("h3",{children:[r.jsx(Foe,{}),"Next reported reset ",r.jsx("span",{className:"ap-reset-global",children:"· all days"})]}),k.length>1?r.jsxs("span",{className:"ap-reset-name",children:[k.length," accounts"]}):r.jsxs("details",{className:"ap-reset-next-account",children:[r.jsxs("summary",{title:b.name,children:[r.jsx(pf,{entry:b}),r.jsx("span",{className:"vis-hidden",children:" · Full account name"})]}),r.jsx("p",{className:"ap-reset-full-name",children:b.name})]}),r.jsxs("p",{children:[ff(new Date(b.at*1e3)),", ",sp(new Date(b.at*1e3))," · ",r.jsx(Zp,{at:b.at})]}),r.jsxs("p",{className:"ap-reset-next-note",children:["Reported time · recent reading",k.length>1?"s":b.used!=null?` · ${so(b.used)}% weekly used`:""]})]}),r.jsxs("p",{className:"ap-reset-countdown",children:[r.jsx("strong",{children:xN(b.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:()=>T("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:()=>T("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:()=>T("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:L})]}),r.jsx("ol",{className:"ap-reset-week",role:"list","aria-label":"Seven-day reset counts",children:c.map((P,O)=>r.jsx("li",{"data-today":O===0?"":void 0,children:r.jsxs("button",{type:"button",className:"ap-reset-day-button","aria-current":O===0?"date":void 0,"data-active":P.scheduled>0?"":void 0,"aria-pressed":(h==null?void 0:h.key)===P.key,"aria-label":`${uu(P.date)}: ${P.scheduled} scheduled resets${P.outdated?`, ${P.outdated} readings need updating`:""}`,onClick:()=>{_(),i("upcoming"),a((h==null?void 0:h.key)===P.key?null:P.key)},children:[r.jsxs("time",{dateTime:P.key,title:uu(P.date),children:[r.jsx("span",{className:"ap-reset-weekday",children:O===0?"Today":ff(P.date)}),r.jsx("span",{className:"ap-reset-date",children:P.date.getDate()})]}),r.jsxs("span",{className:"ap-reset-count",children:[r.jsx("b",{children:P.scheduled||"—"}),r.jsxs("span",{children:[" ",P.scheduled===1?"reset":"resets"]})]})]})},P.key))})]})]}),r.jsxs("div",{ref:N,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?`${ff(h.date)}, ${sp(h.date)}`:"All upcoming resets"," ",r.jsx("span",{children:v})]}),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 ${uu(h.date)}.`:"All days · select a date to narrow the agenda."}),v>0?r.jsx($A,{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($A,{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(P=>r.jsx(Hoe,{entry:P,row:A.get(P.key),nowSec:t},P.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 ",L,"; 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 m5(e){return e>=90?"hi":e>=70?"mid":void 0}const g5=(e,t,n)=>`${e} ${e===1?t:n}`;function LA(e){const t=e.more>0?`, and ${g5(e.more,"more account","more accounts")} in the same minute`:"";return`First: ${e.name} (${so(e.pct)}% used)${t}`}function Voe({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}=$te(e.used??0),c=Math.round(Po(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?Gu(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":m5(o),"aria-hidden":!0,children:r.jsx("i",{style:{"--left":i/100}})}),d&&e.nextReset&&r.jsxs("p",{className:"ap-report-reset",title:LA(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:[". ",LA(e.nextReset)]})]}),a]})}function Goe({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"})]}):`${so(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":m5(e.pct),children:[so(e.pct),"%"]})]})}function Koe({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=Gu(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 Yoe={ready:"Ready",limited:"Limited",exhausted:"Exhausted",stale:"Stale"};function Xoe({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}),Yoe[e.status]]}),Object.values(e.cells).some(t=>!t.counted&&t.reset)&&r.jsx("span",{className:"ap-report-state-note",children:"Awaiting read"})]})}function Zoe({row:e,nowSec:t}){const n=Ete(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 Joe(){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 Qoe({accounts:e,nowSec:t,held:n,sort:s=null,onSort:a=()=>{}}){const o=lN(e,t),i=o.rows.length,c=Math.round(Po(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 ",g5(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(Voe,{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",{}),Vo.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(el,{col:"account",label:"Account",sort:s,next:qc,onSort:a}),Vo.map(d=>r.jsxs(y.Fragment,{children:[r.jsx(el,{col:d.id,label:`${d.label} used`,sort:s,next:qc,onSort:a}),r.jsx(el,{col:`${d.id}_reset`,label:`${d.label} reset`,sort:s,next:qc,onSort:a})]},d.id)),r.jsx(el,{col:"status",label:"Status",sort:s,next:qc,onSort:a}),r.jsx(el,{col:"updated",label:"Updated",className:"ap-report-upd-h",sort:s,next:qc,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"})]})}),Vo.map(f=>r.jsxs(y.Fragment,{children:[r.jsx(Goe,{cell:d.cells[f.id],label:f.label}),r.jsx(Koe,{at:d.resets[f.id],nowSec:t,label:f.label})]},f.id)),r.jsx(Xoe,{row:d}),r.jsx(Zoe,{row:d,nowSec:t})]},d.num))})]})}),r.jsxs("details",{className:"ap-report-how",children:[r.jsxs("summary",{children:[r.jsx(Joe,{}),"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."]})]})]})]})}const eie={accounts:"Account capacity",calendar:"Reset calendar"};function tie({accounts:e,order:t,failed:n,nowSec:s,onClose:a,view:o}){const i=y.useRef(null),c=ft(a,{focusRef:i}),d=mt(a),[h,f]=y.useState("upcoming"),[p,m]=y.useState(null),[w,v]=y.useState(e??[]);y.useEffect(()=>{e!=null&&v(e)},[e]);const b=Lte(n,e==null,w.length>0),[k,N]=y.useState(null),j=l1(w,(k==null?void 0:k.order)??t),S=_=>{const T=lN(l1(w,t),s).rows;N({sort:_,order:Mte(T,_).map(L=>L.key)})};return xt.createPortal(r.jsx("div",{className:"modal-backdrop",...d,role:"presentation",children:r.jsxs("div",{ref:c,className:"modal ap-report-modal","data-view":o,onClick:_=>_.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:eie[o]})}),r.jsx("button",{ref:i,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??""}),o==="accounts"?r.jsx(Qoe,{accounts:j,nowSec:s,held:b,sort:(k==null?void 0:k.sort)??null,onSort:S}):r.jsx(zoe,{accounts:j,nowSec:s,held:b,selectedDate:p,onSelect:m,scope:h,onScope:f})]})}),document.body)}function nie(e,t,n){const s=e.filter(o=>o.active);if(s.length===0)return e.map(bs);const a=e.filter(o=>!o.active);return[...s,...wD(a,xD(t,a),o=>wN(o,n),n)].map(bs)}function sie(){}function rie({view:e,onClose:t}){const{data:n,failure:s}=h5(sie),a=Jj(),[o,i]=y.useState(null);return y.useEffect(()=>{o==null&&n&&i(nie(n.accounts??[],u5(),a))},[n,o,a]),o==null&&s==null?null:r.jsx(tie,{accounts:(n==null?void 0:n.accounts)??null,order:o??[],failed:s!=null&&s.reload?s.text:null,nowSec:a,onClose:t,view:e})}function aie({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 oie=16,iie=120;function lie(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 cie(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 uie(e,t){return lie(e,t,oie)?"over":cie(e,t)<=iie?"near":"far"}function die(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 hie(){const[e,t]=y.useState(!1),[n,s]=y.useState(""),[a,o]=y.useState("far"),i=y.useRef(null),c=al(e,140),d=y.useCallback(m=>{var b;const w=(b=i.current)==null?void 0:b.getBoundingClientRect(),v=die(m);return w&&v?uie(v,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 v=w&&d(m)==="over";return t(!1),v},[d]);return{trashDragging:e,trashLabel:n,trashState:a,trashZoneRef:i,trashPhase:c,beginTrashDrag:h,trackTrashDrag:f,endTrashDrag:p}}const fie=420;function pie(){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),fie+80)})},[]);return y.useEffect(()=>()=>{n.current&&window.clearTimeout(n.current)},[]),{bubbling:e,endBubble:s,onBubble:a}}const vN=11;function y5(e=0){return vN+Math.min(0,e)}const w5=7.2,x5=6.6,mie={width:104,height:48},IA={width:96,height:44},v5={width:220,height:103};function gie(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)?v5:{width:Math.max(160,t),height:Math.max(72,n)}}function Oy(e,t,n){return e.width*t>=n.width&&e.height*t>=n.height}function yie(e,t,n=v5,s=vN){if(!Number.isFinite(t)||t<=0)return e??"detail";const a=s*t;return e==="detail"?a>=x5?"detail":Oy(n,t,IA)?"compact":"overview":a>=w5?"detail":e==="compact"?Oy(n,t,IA)?"compact":"overview":Oy(n,t,mie)?"compact":"overview"}function wie(e,t,n=vN){return e>=w5/n?e:Math.max(e,Math.min(t,x5/n-.001))}const xie=.8,vie=1;function bie({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 v of e.current.agents.keys()){const b=t.current.get(v);b&&p.push(b)}const m=gie(p);return c.current={version:f,card:m},m},[]),h=y.useCallback(f=>{var m;const p=yie(i.current,f,d(),y5(Hj[zj()]));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 kie=40,jie=120;function Nie(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=kie){const h=t.now(),f=Math.max(a+d,h);if(f<=h){i(),o();return}c(f,h,d)},replay(d=jie){i(),s=t.now()+d,n=t.setTimeout(o,d)},flush(){i(),o()},cancel(){i()}}}const Sie=1024*1024,OA=5,b5=.8,j1=24,_ie="agent-dag.soundCustom.done",Cie="agent-dag.soundCustom.needs-input",du={done:_ie,"needs-input":Cie};function Fu(e){if(e.kind!=="audio")return e;const{bytes:t,...n}=e;return n}function PA(e){return!e||!/^[a-zA-Z0-9._-]{1,96}$/.test(e)?null:e}function Eie(e){return{done:PA(e(du.done)),"needs-input":PA(e(du["needs-input"]))}}function Tie(e,t){return{done:e.done===t?null:e.done,"needs-input":e["needs-input"]===t?null:e["needs-input"]}}function Aie(e){return e.done&&e.done===e["needs-input"]?e.done:null}const Rie={wav:"audio/wav",wave:"audio/wav",mp3:"audio/mpeg",ogg:"audio/ogg",oga:"audio/ogg",webm:"audio/webm",m4a:"audio/mp4",mp4:"audio/mp4"},k5=new Set(["audio/wav","audio/x-wav","audio/mpeg","audio/mp3","audio/ogg","audio/webm","audio/mp4"]);function j5(e,t){const n=t.toLowerCase().split(";")[0].trim();if(k5.has(n))return n;const s=e.toLowerCase().split(".").pop()??"";return Rie[s]??n}function DA(e,t){const n=j5(e.name,e.type);if(!k5.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>Sie)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>OA)return`Audio must be ${OA} seconds or shorter.`}return null}function N1(e){return e>=j1?`There are already ${j1} custom sounds. Delete one first.`:null}function Mie(e,t){const n=e.indexOf(t);return n<0?null:e[n+1]??e[n-1]??null}function $ie(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,b5/t)}function N5(){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 Lie(e,t,n=N5()){var h;const s=((h=e.name)==null?void 0:h.trim())||"Custom sound",a=DA({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=DA({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:j5(s,e.type),duration:i.duration,normalizationGain:$ie(d),bytes:o}}function Iie(e,t=N5()){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 Oie="ccdeck-notification-audio",Pie=2,Zs="assets",Nr="summaries";function Zu(){return typeof window<"u"?window.ccdeckNotificationAudio??null:null}function Die(){return new Promise((e,t)=>{const n=indexedDB.open(Oie,Pie);n.onupgradeneeded=s=>{const a=n.result,o=a.objectStoreNames.contains(Zs)?n.transaction.objectStore(Zs):a.createObjectStore(Zs,{keyPath:"id"});if(a.objectStoreNames.contains(Nr))return;const i=a.createObjectStore(Nr,{keyPath:"id"});if(s.oldVersion<1)return;const c=o.openCursor();c.onsuccess=()=>{const d=c.result;d&&(i.put(Fu(d.value)),d.continue())}},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error??new Error("Could not open local audio storage."))})}async function Ju(e,t,n){const s=await Die();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 Fie(){const e=Zu();return e?e.list():typeof indexedDB>"u"?[]:await Ju([Nr],"readonly",t=>t.objectStore(Nr).getAll())??[]}async function Bie(e){const t=Zu();return t?t.get(e):typeof indexedDB>"u"?null:await Ju([Zs],"readonly",n=>n.objectStore(Zs).get(e))??null}async function FA(e){const t=Zu();if(t){await t.put(e);return}if(typeof indexedDB>"u")throw new Error("Local audio storage is unavailable in this browser.");await Ju([Zs,Nr],"readwrite",n=>{n.objectStore(Zs).put(e),n.objectStore(Nr).put(Fu(e))})}async function qie(e,t){const n=Zu();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 Ju([Zs,Nr],"readwrite",s=>{const a=s.objectStore(Zs),o=a.get(e);o.onsuccess=()=>{const i=o.result;if(!i)return;const c={...i,name:t};a.put(c),s.objectStore(Nr).put(Fu(c))}})}async function Uie(e){const t=Zu();if(t){await t.remove(e);return}typeof indexedDB>"u"||await Ju([Zs,Nr],"readwrite",n=>{n.objectStore(Zs).delete(e),n.objectStore(Nr).delete(e)})}const hu=["done","needs-input"],Wie=[{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}]}],Hie=[{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}]}],bN={done:Wie,"needs-input":Hie},Xn="two";function S1(e,t){const n=bN[e];return n.find(s=>s.id===t)??n.find(s=>s.id===Xn)??n[0]}function S5(e,t){return bN[e].some(s=>s.id===t)?t:Xn}S1("done",Xn).notes,S1("needs-input",Xn).notes;const BA=.04,_5=.24,mf=0,rp=100,kN=5,ri=50;function Jp(e,t=kN){if(!Number.isFinite(e))return ri;const n=Math.round(e/t)*t;return Math.min(rp,Math.max(mf,n))}function C5(e,t=kN){if(e==null)return ri;const n=e.trim();return/^-?\d+(\.\d+)?$/.test(n)?Jp(Number(n),t):ri}function jN(e){const t=Jp(e),n=BA+(_5-BA)*(t/rp);return Math.round(n*1e4)/1e4}function zie(e,t){const n=t.trim,s=typeof n=="number"&&Number.isFinite(n)&&n>0&&n<=1?n:1;return Math.round(jN(e)*s*1e4)/1e4}const Vie=.012,qA=1e-4;function Gie(e){return Math.min(1,jN(e)/_5)}function Kie(e,t){const n=e*(jN(t)/b5);return Math.max(1e-4,n)}const Yie=160,Xie="agent-dag.soundLevel.done",Zie="agent-dag.soundLevel.needs-input",Jie="agent-dag.soundFigure.done",Qie="agent-dag.soundFigure.needs-input",E5={done:Xie,"needs-input":Zie},ap={done:Jie,"needs-input":Qie},UA={done:{level:ri,figure:Xn},"needs-input":{level:ri,figure:Xn}};function ele(e){const t=n=>({level:C5(e(E5[n])),figure:S5(n,e(ap[n]))});return{done:t("done"),"needs-input":t("needs-input")}}function tle(e,t){return(e??UA)[t]??UA[t]}const nle={Stop:"done",Notification:"needs-input"};function sle(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(nle,n)??null}const rle=6,ale="ccdeck-tabs";function ole(e){return e>=rle}function ile(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 lle({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 v=new EventSource("/events"),b=Nie(t,{now:()=>Date.now(),setTimeout:(S,_)=>window.setTimeout(S,_),clearTimeout:S=>window.clearTimeout(S)});let k=!1;const N=typeof BroadcastChannel=="function"?ile(new BroadcastChannel(ale),Math.random().toString(36).slice(2),()=>k):null,j=window.setInterval(()=>{k||!N||N.ask(600).then(S=>{k||d(ole(S))})},3e3);return v.addEventListener("open",()=>{i(!0),f(!0)}),v.addEventListener("error",()=>{i(!1),w(null)}),v.addEventListener("open",()=>{k=!0,d(!1)}),v.addEventListener("error",()=>{k=!1}),v.addEventListener("replay-end",()=>{p.current=!1,b.flush(),w(Date.now())}),v.addEventListener("desktop-update",S=>a.current(S.data)),v.addEventListener("hook",S=>{var _;try{const T=JSON.parse(S.data);if(!n.accept(T))return;e.current=v4(e.current,T);const L=T.replay===!0||p.current||Date.now()-T.receivedAt>3e4;L?b.replay():b.live();const A=sle(T,L);A&&((_=s.current)==null||_.play(A))}catch{}}),()=>{v.close(),b.cancel(),window.clearInterval(j),N==null||N.leave()}},[t]),{live:o,tabCapped:c,everConnected:h,liveSince:m}}const cle=200,ule=5*6e4,dle=6,hle=2*6e4;function Gh(e,t){if(t.size!==0)for(const n of Array.from(e.keys()))t.has(n)||e.delete(n)}function fle(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 ple(e){const t=new Set;for(const n of e)t.add(n.id),t.add(`group:${n.sessionId}`),n.kind==="root"&&t.add(Cj(n.id));return t}function mle(e){const t=new Set;for(const n of e)t.add(n.id),n.kind==="root"&&t.add(Cj(n.id));return t}function gle(e,t){let n=rV(e,t,vE);aV(e,t,vE)&&(n=!0);const s=[],a=o=>{s.push(o)};return tV(e,t,cle,ule,a)&&(n=!0),nV(e,t,dle,hle,a)&&(n=!0),{changed:n,forgotten:s}}function yle(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 wle(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=>yle(m,h,f)),!f&&p&&t(!0)},[]),c=y.useCallback(()=>{s({ids:new Set,primary:null})},[]),d=y.useCallback(()=>{s(h=>{const f=fle(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 xle({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}=gle(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 NN(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 Py,WA;function vle(){if(WA)return Py;WA=1;function e(){this.__data__=[],this.size=0}return Py=e,Py}var Dy,HA;function Bl(){if(HA)return Dy;HA=1;function e(t,n){return t===n||t!==t&&n!==n}return Dy=e,Dy}var Fy,zA;function Qp(){if(zA)return Fy;zA=1;var e=Bl();function t(n,s){for(var a=n.length;a--;)if(e(n[a][0],s))return a;return-1}return Fy=t,Fy}var By,VA;function ble(){if(VA)return By;VA=1;var e=Qp(),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 By=s,By}var qy,GA;function kle(){if(GA)return qy;GA=1;var e=Qp();function t(n){var s=this.__data__,a=e(s,n);return a<0?void 0:s[a][1]}return qy=t,qy}var Uy,KA;function jle(){if(KA)return Uy;KA=1;var e=Qp();function t(n){return e(this.__data__,n)>-1}return Uy=t,Uy}var Wy,YA;function Nle(){if(YA)return Wy;YA=1;var e=Qp();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 Wy=t,Wy}var Hy,XA;function em(){if(XA)return Hy;XA=1;var e=vle(),t=ble(),n=kle(),s=jle(),a=Nle();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,Hy=o,Hy}var zy,ZA;function Sle(){if(ZA)return zy;ZA=1;var e=em();function t(){this.__data__=new e,this.size=0}return zy=t,zy}var Vy,JA;function _le(){if(JA)return Vy;JA=1;function e(t){var n=this.__data__,s=n.delete(t);return this.size=n.size,s}return Vy=e,Vy}var Gy,QA;function Cle(){if(QA)return Gy;QA=1;function e(t){return this.__data__.get(t)}return Gy=e,Gy}var Ky,eR;function Ele(){if(eR)return Ky;eR=1;function e(t){return this.__data__.has(t)}return Ky=e,Ky}var Yy,tR;function T5(){if(tR)return Yy;tR=1;var e=typeof bh=="object"&&bh&&bh.Object===Object&&bh;return Yy=e,Yy}var Xy,nR;function er(){if(nR)return Xy;nR=1;var e=T5(),t=typeof self=="object"&&self&&self.Object===Object&&self,n=e||t||Function("return this")();return Xy=n,Xy}var Zy,sR;function ql(){if(sR)return Zy;sR=1;var e=er(),t=e.Symbol;return Zy=t,Zy}var Jy,rR;function Tle(){if(rR)return Jy;rR=1;var e=ql(),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 Jy=o,Jy}var Qy,aR;function Ale(){if(aR)return Qy;aR=1;var e=Object.prototype,t=e.toString;function n(s){return t.call(s)}return Qy=n,Qy}var ew,oR;function oi(){if(oR)return ew;oR=1;var e=ql(),t=Tle(),n=Ale(),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 ew=i,ew}var tw,iR;function Ss(){if(iR)return tw;iR=1;function e(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}return tw=e,tw}var nw,lR;function Qu(){if(lR)return nw;lR=1;var e=oi(),t=Ss(),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 nw=i,nw}var sw,cR;function Rle(){if(cR)return sw;cR=1;var e=er(),t=e["__core-js_shared__"];return sw=t,sw}var rw,uR;function Mle(){if(uR)return rw;uR=1;var e=Rle(),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 rw=n,rw}var aw,dR;function A5(){if(dR)return aw;dR=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 aw=n,aw}var ow,hR;function $le(){if(hR)return ow;hR=1;var e=Qu(),t=Mle(),n=Ss(),s=A5(),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 ow=p,ow}var iw,fR;function Lle(){if(fR)return iw;fR=1;function e(t,n){return t==null?void 0:t[n]}return iw=e,iw}var lw,pR;function ii(){if(pR)return lw;pR=1;var e=$le(),t=Lle();function n(s,a){var o=t(s,a);return e(o)?o:void 0}return lw=n,lw}var cw,mR;function SN(){if(mR)return cw;mR=1;var e=ii(),t=er(),n=e(t,"Map");return cw=n,cw}var uw,gR;function tm(){if(gR)return uw;gR=1;var e=ii(),t=e(Object,"create");return uw=t,uw}var dw,yR;function Ile(){if(yR)return dw;yR=1;var e=tm();function t(){this.__data__=e?e(null):{},this.size=0}return dw=t,dw}var hw,wR;function Ole(){if(wR)return hw;wR=1;function e(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n}return hw=e,hw}var fw,xR;function Ple(){if(xR)return fw;xR=1;var e=tm(),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 fw=a,fw}var pw,vR;function Dle(){if(vR)return pw;vR=1;var e=tm(),t=Object.prototype,n=t.hasOwnProperty;function s(a){var o=this.__data__;return e?o[a]!==void 0:n.call(o,a)}return pw=s,pw}var mw,bR;function Fle(){if(bR)return mw;bR=1;var e=tm(),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 mw=n,mw}var gw,kR;function Ble(){if(kR)return gw;kR=1;var e=Ile(),t=Ole(),n=Ple(),s=Dle(),a=Fle();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,gw=o,gw}var yw,jR;function qle(){if(jR)return yw;jR=1;var e=Ble(),t=em(),n=SN();function s(){this.size=0,this.__data__={hash:new e,map:new(n||t),string:new e}}return yw=s,yw}var ww,NR;function Ule(){if(NR)return ww;NR=1;function e(t){var n=typeof t;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?t!=="__proto__":t===null}return ww=e,ww}var xw,SR;function nm(){if(SR)return xw;SR=1;var e=Ule();function t(n,s){var a=n.__data__;return e(s)?a[typeof s=="string"?"string":"hash"]:a.map}return xw=t,xw}var vw,_R;function Wle(){if(_R)return vw;_R=1;var e=nm();function t(n){var s=e(this,n).delete(n);return this.size-=s?1:0,s}return vw=t,vw}var bw,CR;function Hle(){if(CR)return bw;CR=1;var e=nm();function t(n){return e(this,n).get(n)}return bw=t,bw}var kw,ER;function zle(){if(ER)return kw;ER=1;var e=nm();function t(n){return e(this,n).has(n)}return kw=t,kw}var jw,TR;function Vle(){if(TR)return jw;TR=1;var e=nm();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 jw=t,jw}var Nw,AR;function _N(){if(AR)return Nw;AR=1;var e=qle(),t=Wle(),n=Hle(),s=zle(),a=Vle();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,RR;function Gle(){if(RR)return Sw;RR=1;var e=em(),t=SN(),n=_N(),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 _w,MR;function sm(){if(MR)return _w;MR=1;var e=em(),t=Sle(),n=_le(),s=Cle(),a=Ele(),o=Gle();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,_w=i,_w}var Cw,$R;function CN(){if($R)return Cw;$R=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 Cw=e,Cw}var Ew,LR;function R5(){if(LR)return Ew;LR=1;var e=ii(),t=(function(){try{var n=e(Object,"defineProperty");return n({},"",{}),n}catch{}})();return Ew=t,Ew}var Tw,IR;function rm(){if(IR)return Tw;IR=1;var e=R5();function t(n,s,a){s=="__proto__"&&e?e(n,s,{configurable:!0,enumerable:!0,value:a,writable:!0}):n[s]=a}return Tw=t,Tw}var Aw,OR;function am(){if(OR)return Aw;OR=1;var e=rm(),t=Bl(),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 Aw=a,Aw}var Rw,PR;function ed(){if(PR)return Rw;PR=1;var e=am(),t=rm();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 Rw=n,Rw}var Mw,DR;function Kle(){if(DR)return Mw;DR=1;function e(t,n){for(var s=-1,a=Array(t);++s<t;)a[s]=n(s);return a}return Mw=e,Mw}var $w,FR;function Er(){if(FR)return $w;FR=1;function e(t){return t!=null&&typeof t=="object"}return $w=e,$w}var Lw,BR;function Yle(){if(BR)return Lw;BR=1;var e=oi(),t=Er(),n="[object Arguments]";function s(a){return t(a)&&e(a)==n}return Lw=s,Lw}var Iw,qR;function td(){if(qR)return Iw;qR=1;var e=Yle(),t=Er(),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 Iw=o,Iw}var Ow,UR;function qt(){if(UR)return Ow;UR=1;var e=Array.isArray;return Ow=e,Ow}var Qc={exports:{}},Pw,WR;function Xle(){if(WR)return Pw;WR=1;function e(){return!1}return Pw=e,Pw}Qc.exports;var HR;function Ul(){return HR||(HR=1,(function(e,t){var n=er(),s=Xle(),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 Dw,zR;function om(){if(zR)return Dw;zR=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 Dw=n,Dw}var Fw,VR;function EN(){if(VR)return Fw;VR=1;var e=9007199254740991;function t(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=e}return Fw=t,Fw}var Bw,GR;function Zle(){if(GR)return Bw;GR=1;var e=oi(),t=EN(),n=Er(),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]",v="[object String]",b="[object WeakMap]",k="[object ArrayBuffer]",N="[object DataView]",j="[object Float32Array]",S="[object Float64Array]",_="[object Int8Array]",T="[object Int16Array]",L="[object Int32Array]",A="[object Uint8Array]",P="[object Uint8ClampedArray]",O="[object Uint16Array]",U="[object Uint32Array]",q={};q[j]=q[S]=q[_]=q[T]=q[L]=q[A]=q[P]=q[O]=q[U]=!0,q[s]=q[a]=q[k]=q[o]=q[N]=q[i]=q[c]=q[d]=q[h]=q[f]=q[p]=q[m]=q[w]=q[v]=q[b]=!1;function M(I){return n(I)&&t(I.length)&&!!q[e(I)]}return Bw=M,Bw}var qw,KR;function im(){if(KR)return qw;KR=1;function e(t){return function(n){return t(n)}}return qw=e,qw}var eu={exports:{}};eu.exports;var YR;function TN(){return YR||(YR=1,(function(e,t){var n=T5(),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})(eu,eu.exports)),eu.exports}var Uw,XR;function nd(){if(XR)return Uw;XR=1;var e=Zle(),t=im(),n=TN(),s=n&&n.isTypedArray,a=s?t(s):e;return Uw=a,Uw}var Ww,ZR;function M5(){if(ZR)return Ww;ZR=1;var e=Kle(),t=td(),n=qt(),s=Ul(),a=om(),o=nd(),i=Object.prototype,c=i.hasOwnProperty;function d(h,f){var p=n(h),m=!p&&t(h),w=!p&&!m&&s(h),v=!p&&!m&&!w&&o(h),b=p||m||w||v,k=b?e(h.length,String):[],N=k.length;for(var j in h)(f||c.call(h,j))&&!(b&&(j=="length"||w&&(j=="offset"||j=="parent")||v&&(j=="buffer"||j=="byteLength"||j=="byteOffset")||a(j,N)))&&k.push(j);return k}return Ww=d,Ww}var Hw,JR;function lm(){if(JR)return Hw;JR=1;var e=Object.prototype;function t(n){var s=n&&n.constructor,a=typeof s=="function"&&s.prototype||e;return n===a}return Hw=t,Hw}var zw,QR;function $5(){if(QR)return zw;QR=1;function e(t,n){return function(s){return t(n(s))}}return zw=e,zw}var Vw,e2;function Jle(){if(e2)return Vw;e2=1;var e=$5(),t=e(Object.keys,Object);return Vw=t,Vw}var Gw,t2;function AN(){if(t2)return Gw;t2=1;var e=lm(),t=Jle(),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 Gw=a,Gw}var Kw,n2;function ua(){if(n2)return Kw;n2=1;var e=Qu(),t=EN();function n(s){return s!=null&&t(s.length)&&!e(s)}return Kw=n,Kw}var Yw,s2;function uo(){if(s2)return Yw;s2=1;var e=M5(),t=AN(),n=ua();function s(a){return n(a)?e(a):t(a)}return Yw=s,Yw}var Xw,r2;function Qle(){if(r2)return Xw;r2=1;var e=ed(),t=uo();function n(s,a){return s&&e(a,t(a),s)}return Xw=n,Xw}var Zw,a2;function ece(){if(a2)return Zw;a2=1;function e(t){var n=[];if(t!=null)for(var s in Object(t))n.push(s);return n}return Zw=e,Zw}var Jw,o2;function tce(){if(o2)return Jw;o2=1;var e=Ss(),t=lm(),n=ece(),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 Jw=o,Jw}var Qw,i2;function li(){if(i2)return Qw;i2=1;var e=M5(),t=tce(),n=ua();function s(a){return n(a)?e(a,!0):t(a)}return Qw=s,Qw}var ex,l2;function nce(){if(l2)return ex;l2=1;var e=ed(),t=li();function n(s,a){return s&&e(a,t(a),s)}return ex=n,ex}var tu={exports:{}};tu.exports;var c2;function L5(){return c2||(c2=1,(function(e,t){var n=er(),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})(tu,tu.exports)),tu.exports}var tx,u2;function I5(){if(u2)return tx;u2=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 tx=e,tx}var nx,d2;function O5(){if(d2)return nx;d2=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 nx=e,nx}var sx,h2;function P5(){if(h2)return sx;h2=1;function e(){return[]}return sx=e,sx}var rx,f2;function RN(){if(f2)return rx;f2=1;var e=O5(),t=P5(),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 rx=o,rx}var ax,p2;function sce(){if(p2)return ax;p2=1;var e=ed(),t=RN();function n(s,a){return e(s,t(s),a)}return ax=n,ax}var ox,m2;function MN(){if(m2)return ox;m2=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 ox=e,ox}var ix,g2;function cm(){if(g2)return ix;g2=1;var e=$5(),t=e(Object.getPrototypeOf,Object);return ix=t,ix}var lx,y2;function D5(){if(y2)return lx;y2=1;var e=MN(),t=cm(),n=RN(),s=P5(),a=Object.getOwnPropertySymbols,o=a?function(i){for(var c=[];i;)e(c,n(i)),i=t(i);return c}:s;return lx=o,lx}var cx,w2;function rce(){if(w2)return cx;w2=1;var e=ed(),t=D5();function n(s,a){return e(s,t(s),a)}return cx=n,cx}var ux,x2;function F5(){if(x2)return ux;x2=1;var e=MN(),t=qt();function n(s,a,o){var i=a(s);return t(s)?i:e(i,o(s))}return ux=n,ux}var dx,v2;function B5(){if(v2)return dx;v2=1;var e=F5(),t=RN(),n=uo();function s(a){return e(a,n,t)}return dx=s,dx}var hx,b2;function ace(){if(b2)return hx;b2=1;var e=F5(),t=D5(),n=li();function s(a){return e(a,n,t)}return hx=s,hx}var fx,k2;function oce(){if(k2)return fx;k2=1;var e=ii(),t=er(),n=e(t,"DataView");return fx=n,fx}var px,j2;function ice(){if(j2)return px;j2=1;var e=ii(),t=er(),n=e(t,"Promise");return px=n,px}var mx,N2;function q5(){if(N2)return mx;N2=1;var e=ii(),t=er(),n=e(t,"Set");return mx=n,mx}var gx,S2;function lce(){if(S2)return gx;S2=1;var e=ii(),t=er(),n=e(t,"WeakMap");return gx=n,gx}var yx,_2;function Wl(){if(_2)return yx;_2=1;var e=oce(),t=SN(),n=ice(),s=q5(),a=lce(),o=oi(),i=A5(),c="[object Map]",d="[object Object]",h="[object Promise]",f="[object Set]",p="[object WeakMap]",m="[object DataView]",w=i(e),v=i(t),b=i(n),k=i(s),N=i(a),j=o;return(e&&j(new e(new ArrayBuffer(1)))!=m||t&&j(new t)!=c||n&&j(n.resolve())!=h||s&&j(new s)!=f||a&&j(new a)!=p)&&(j=function(S){var _=o(S),T=_==d?S.constructor:void 0,L=T?i(T):"";if(L)switch(L){case w:return m;case v:return c;case b:return h;case k:return f;case N:return p}return _}),yx=j,yx}var wx,C2;function cce(){if(C2)return wx;C2=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 wx=n,wx}var xx,E2;function U5(){if(E2)return xx;E2=1;var e=er(),t=e.Uint8Array;return xx=t,xx}var vx,T2;function $N(){if(T2)return vx;T2=1;var e=U5();function t(n){var s=new n.constructor(n.byteLength);return new e(s).set(new e(n)),s}return vx=t,vx}var bx,A2;function uce(){if(A2)return bx;A2=1;var e=$N();function t(n,s){var a=s?e(n.buffer):n.buffer;return new n.constructor(a,n.byteOffset,n.byteLength)}return bx=t,bx}var kx,R2;function dce(){if(R2)return kx;R2=1;var e=/\w*$/;function t(n){var s=new n.constructor(n.source,e.exec(n));return s.lastIndex=n.lastIndex,s}return kx=t,kx}var jx,M2;function hce(){if(M2)return jx;M2=1;var e=ql(),t=e?e.prototype:void 0,n=t?t.valueOf:void 0;function s(a){return n?Object(n.call(a)):{}}return jx=s,jx}var Nx,$2;function W5(){if($2)return Nx;$2=1;var e=$N();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,L2;function fce(){if(L2)return Sx;L2=1;var e=$N(),t=uce(),n=dce(),s=hce(),a=W5(),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]",v="[object DataView]",b="[object Float32Array]",k="[object Float64Array]",N="[object Int8Array]",j="[object Int16Array]",S="[object Int32Array]",_="[object Uint8Array]",T="[object Uint8ClampedArray]",L="[object Uint16Array]",A="[object Uint32Array]";function P(O,U,q){var M=O.constructor;switch(U){case w:return e(O);case o:case i:return new M(+O);case v:return t(O,q);case b:case k:case N:case j:case S:case _:case T:case L:case A:return a(O,q);case c:return new M;case d:case p:return new M(O);case h:return n(O);case f:return new M;case m:return s(O)}}return Sx=P,Sx}var _x,I2;function H5(){if(I2)return _x;I2=1;var e=Ss(),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 _x=n,_x}var Cx,O2;function z5(){if(O2)return Cx;O2=1;var e=H5(),t=cm(),n=lm();function s(a){return typeof a.constructor=="function"&&!n(a)?e(t(a)):{}}return Cx=s,Cx}var Ex,P2;function pce(){if(P2)return Ex;P2=1;var e=Wl(),t=Er(),n="[object Map]";function s(a){return t(a)&&e(a)==n}return Ex=s,Ex}var Tx,D2;function mce(){if(D2)return Tx;D2=1;var e=pce(),t=im(),n=TN(),s=n&&n.isMap,a=s?t(s):e;return Tx=a,Tx}var Ax,F2;function gce(){if(F2)return Ax;F2=1;var e=Wl(),t=Er(),n="[object Set]";function s(a){return t(a)&&e(a)==n}return Ax=s,Ax}var Rx,B2;function yce(){if(B2)return Rx;B2=1;var e=gce(),t=im(),n=TN(),s=n&&n.isSet,a=s?t(s):e;return Rx=a,Rx}var Mx,q2;function V5(){if(q2)return Mx;q2=1;var e=sm(),t=CN(),n=am(),s=Qle(),a=nce(),o=L5(),i=I5(),c=sce(),d=rce(),h=B5(),f=ace(),p=Wl(),m=cce(),w=fce(),v=z5(),b=qt(),k=Ul(),N=mce(),j=Ss(),S=yce(),_=uo(),T=li(),L=1,A=2,P=4,O="[object Arguments]",U="[object Array]",q="[object Boolean]",M="[object Date]",I="[object Error]",E="[object Function]",D="[object GeneratorFunction]",B="[object Map]",H="[object Number]",G="[object Object]",z="[object RegExp]",F="[object Set]",$="[object String]",W="[object Symbol]",Z="[object WeakMap]",V="[object ArrayBuffer]",Y="[object DataView]",X="[object Float32Array]",J="[object Float64Array]",Q="[object Int8Array]",te="[object Int16Array]",ce="[object Int32Array]",ue="[object Uint8Array]",ie="[object Uint8ClampedArray]",re="[object Uint16Array]",fe="[object Uint32Array]",ae={};ae[O]=ae[U]=ae[V]=ae[Y]=ae[q]=ae[M]=ae[X]=ae[J]=ae[Q]=ae[te]=ae[ce]=ae[B]=ae[H]=ae[G]=ae[z]=ae[F]=ae[$]=ae[W]=ae[ue]=ae[ie]=ae[re]=ae[fe]=!0,ae[I]=ae[E]=ae[Z]=!1;function je(me,pe,xe,_e,ye,Ie){var Pe,Ue=pe&L,$e=pe&A,Je=pe&P;if(xe&&(Pe=ye?xe(me,_e,ye,Ie):xe(me)),Pe!==void 0)return Pe;if(!j(me))return me;var Qe=b(me);if(Qe){if(Pe=m(me),!Ue)return i(me,Pe)}else{var ze=p(me),Ne=ze==E||ze==D;if(k(me))return o(me,Ue);if(ze==G||ze==O||Ne&&!ye){if(Pe=$e||Ne?{}:v(me),!Ue)return $e?d(me,a(Pe,me)):c(me,s(Pe,me))}else{if(!ae[ze])return ye?me:{};Pe=w(me,ze,Ue)}}Ie||(Ie=new e);var Ae=Ie.get(me);if(Ae)return Ae;Ie.set(me,Pe),S(me)?me.forEach(function(ot){Pe.add(je(ot,pe,xe,ot,me,Ie))}):N(me)&&me.forEach(function(ot,we){Pe.set(we,je(ot,pe,xe,we,me,Ie))});var qe=Je?$e?f:h:$e?T:_,et=Qe?void 0:qe(me);return t(et||me,function(ot,we){et&&(we=ot,ot=me[we]),n(Pe,we,je(ot,pe,xe,we,me,Ie))}),Pe}return Mx=je,Mx}var $x,U2;function wce(){if(U2)return $x;U2=1;var e=V5(),t=4;function n(s){return e(s,t)}return $x=n,$x}var Lx,W2;function LN(){if(W2)return Lx;W2=1;function e(t){return function(){return t}}return Lx=e,Lx}var Ix,H2;function xce(){if(H2)return Ix;H2=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 Ix=e,Ix}var Ox,z2;function IN(){if(z2)return Ox;z2=1;var e=xce(),t=e();return Ox=t,Ox}var Px,V2;function ON(){if(V2)return Px;V2=1;var e=IN(),t=uo();function n(s,a){return s&&e(s,a,t)}return Px=n,Px}var Dx,G2;function vce(){if(G2)return Dx;G2=1;var e=ua();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 Dx=t,Dx}var Fx,K2;function um(){if(K2)return Fx;K2=1;var e=ON(),t=vce(),n=t(e);return Fx=n,Fx}var Bx,Y2;function ci(){if(Y2)return Bx;Y2=1;function e(t){return t}return Bx=e,Bx}var qx,X2;function G5(){if(X2)return qx;X2=1;var e=ci();function t(n){return typeof n=="function"?n:e}return qx=t,qx}var Ux,Z2;function K5(){if(Z2)return Ux;Z2=1;var e=CN(),t=um(),n=G5(),s=qt();function a(o,i){var c=s(o)?e:t;return c(o,n(i))}return Ux=a,Ux}var Wx,J2;function Y5(){return J2||(J2=1,Wx=K5()),Wx}var Hx,Q2;function bce(){if(Q2)return Hx;Q2=1;var e=um();function t(n,s){var a=[];return e(n,function(o,i,c){s(o,i,c)&&a.push(o)}),a}return Hx=t,Hx}var zx,eM;function kce(){if(eM)return zx;eM=1;var e="__lodash_hash_undefined__";function t(n){return this.__data__.set(n,e),this}return zx=t,zx}var Vx,tM;function jce(){if(tM)return Vx;tM=1;function e(t){return this.__data__.has(t)}return Vx=e,Vx}var Gx,nM;function X5(){if(nM)return Gx;nM=1;var e=_N(),t=kce(),n=jce();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,Gx=s,Gx}var Kx,sM;function Nce(){if(sM)return Kx;sM=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 Kx=e,Kx}var Yx,rM;function Z5(){if(rM)return Yx;rM=1;function e(t,n){return t.has(n)}return Yx=e,Yx}var Xx,aM;function J5(){if(aM)return Xx;aM=1;var e=X5(),t=Nce(),n=Z5(),s=1,a=2;function o(i,c,d,h,f,p){var m=d&s,w=i.length,v=c.length;if(w!=v&&!(m&&v>w))return!1;var b=p.get(i),k=p.get(c);if(b&&k)return b==c&&k==i;var N=-1,j=!0,S=d&a?new e:void 0;for(p.set(i,c),p.set(c,i);++N<w;){var _=i[N],T=c[N];if(h)var L=m?h(T,_,N,c,i,p):h(_,T,N,i,c,p);if(L!==void 0){if(L)continue;j=!1;break}if(S){if(!t(c,function(A,P){if(!n(S,P)&&(_===A||f(_,A,d,h,p)))return S.push(P)})){j=!1;break}}else if(!(_===T||f(_,T,d,h,p))){j=!1;break}}return p.delete(i),p.delete(c),j}return Xx=o,Xx}var Zx,oM;function Sce(){if(oM)return Zx;oM=1;function e(t){var n=-1,s=Array(t.size);return t.forEach(function(a,o){s[++n]=[o,a]}),s}return Zx=e,Zx}var Jx,iM;function PN(){if(iM)return Jx;iM=1;function e(t){var n=-1,s=Array(t.size);return t.forEach(function(a){s[++n]=a}),s}return Jx=e,Jx}var Qx,lM;function _ce(){if(lM)return Qx;lM=1;var e=ql(),t=U5(),n=Bl(),s=J5(),a=Sce(),o=PN(),i=1,c=2,d="[object Boolean]",h="[object Date]",f="[object Error]",p="[object Map]",m="[object Number]",w="[object RegExp]",v="[object Set]",b="[object String]",k="[object Symbol]",N="[object ArrayBuffer]",j="[object DataView]",S=e?e.prototype:void 0,_=S?S.valueOf:void 0;function T(L,A,P,O,U,q,M){switch(P){case j:if(L.byteLength!=A.byteLength||L.byteOffset!=A.byteOffset)return!1;L=L.buffer,A=A.buffer;case N:return!(L.byteLength!=A.byteLength||!q(new t(L),new t(A)));case d:case h:case m:return n(+L,+A);case f:return L.name==A.name&&L.message==A.message;case w:case b:return L==A+"";case p:var I=a;case v:var E=O&i;if(I||(I=o),L.size!=A.size&&!E)return!1;var D=M.get(L);if(D)return D==A;O|=c,M.set(L,A);var B=s(I(L),I(A),O,U,q,M);return M.delete(L),B;case k:if(_)return _.call(L)==_.call(A)}return!1}return Qx=T,Qx}var ev,cM;function Cce(){if(cM)return ev;cM=1;var e=B5(),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,v=e(i),b=v.length;if(w!=b&&!p)return!1;for(var k=w;k--;){var N=m[k];if(!(p?N in i:s.call(i,N)))return!1}var j=f.get(o),S=f.get(i);if(j&&S)return j==i&&S==o;var _=!0;f.set(o,i),f.set(i,o);for(var T=p;++k<w;){N=m[k];var L=o[N],A=i[N];if(d)var P=p?d(A,L,N,i,o,f):d(L,A,N,o,i,f);if(!(P===void 0?L===A||h(L,A,c,d,f):P)){_=!1;break}T||(T=N=="constructor")}if(_&&!T){var O=o.constructor,U=i.constructor;O!=U&&"constructor"in o&&"constructor"in i&&!(typeof O=="function"&&O instanceof O&&typeof U=="function"&&U instanceof U)&&(_=!1)}return f.delete(o),f.delete(i),_}return ev=a,ev}var tv,uM;function Ece(){if(uM)return tv;uM=1;var e=sm(),t=J5(),n=_ce(),s=Cce(),a=Wl(),o=qt(),i=Ul(),c=nd(),d=1,h="[object Arguments]",f="[object Array]",p="[object Object]",m=Object.prototype,w=m.hasOwnProperty;function v(b,k,N,j,S,_){var T=o(b),L=o(k),A=T?f:a(b),P=L?f:a(k);A=A==h?p:A,P=P==h?p:P;var O=A==p,U=P==p,q=A==P;if(q&&i(b)){if(!i(k))return!1;T=!0,O=!1}if(q&&!O)return _||(_=new e),T||c(b)?t(b,k,N,j,S,_):n(b,k,A,N,j,S,_);if(!(N&d)){var M=O&&w.call(b,"__wrapped__"),I=U&&w.call(k,"__wrapped__");if(M||I){var E=M?b.value():b,D=I?k.value():k;return _||(_=new e),S(E,D,N,j,_)}}return q?(_||(_=new e),s(b,k,N,j,S,_)):!1}return tv=v,tv}var nv,dM;function Q5(){if(dM)return nv;dM=1;var e=Ece(),t=Er();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 nv=n,nv}var sv,hM;function Tce(){if(hM)return sv;hM=1;var e=sm(),t=Q5(),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],v=o[w],b=m[1];if(p&&m[2]){if(v===void 0&&!(w in o))return!1}else{var k=new e;if(d)var N=d(v,b,w,o,i,k);if(!(N===void 0?t(b,v,n|s,d,k):N))return!1}}return!0}return sv=a,sv}var rv,fM;function e6(){if(fM)return rv;fM=1;var e=Ss();function t(n){return n===n&&!e(n)}return rv=t,rv}var av,pM;function Ace(){if(pM)return av;pM=1;var e=e6(),t=uo();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 av=n,av}var ov,mM;function t6(){if(mM)return ov;mM=1;function e(t,n){return function(s){return s==null?!1:s[t]===n&&(n!==void 0||t in Object(s))}}return ov=e,ov}var iv,gM;function Rce(){if(gM)return iv;gM=1;var e=Tce(),t=Ace(),n=t6();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 iv=s,iv}var lv,yM;function Hl(){if(yM)return lv;yM=1;var e=oi(),t=Er(),n="[object Symbol]";function s(a){return typeof a=="symbol"||t(a)&&e(a)==n}return lv=s,lv}var cv,wM;function DN(){if(wM)return cv;wM=1;var e=qt(),t=Hl(),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 cv=a,cv}var uv,xM;function Mce(){if(xM)return uv;xM=1;var e=_N(),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,uv=n,uv}var dv,vM;function $ce(){if(vM)return dv;vM=1;var e=Mce(),t=500;function n(s){var a=e(s,function(i){return o.size===t&&o.clear(),i}),o=a.cache;return a}return dv=n,dv}var hv,bM;function Lce(){if(bM)return hv;bM=1;var e=$ce(),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 hv=s,hv}var fv,kM;function dm(){if(kM)return fv;kM=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 fv=e,fv}var pv,jM;function Ice(){if(jM)return pv;jM=1;var e=ql(),t=dm(),n=qt(),s=Hl(),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 pv=i,pv}var mv,NM;function n6(){if(NM)return mv;NM=1;var e=Ice();function t(n){return n==null?"":e(n)}return mv=t,mv}var gv,SM;function hm(){if(SM)return gv;SM=1;var e=qt(),t=DN(),n=Lce(),s=n6();function a(o,i){return e(o)?o:t(o,i)?[o]:n(s(o))}return gv=a,gv}var yv,_M;function sd(){if(_M)return yv;_M=1;var e=Hl();function t(n){if(typeof n=="string"||e(n))return n;var s=n+"";return s=="0"&&1/n==-1/0?"-0":s}return yv=t,yv}var wv,CM;function fm(){if(CM)return wv;CM=1;var e=hm(),t=sd();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 wv=n,wv}var xv,EM;function Oce(){if(EM)return xv;EM=1;var e=fm();function t(n,s,a){var o=n==null?void 0:e(n,s);return o===void 0?a:o}return xv=t,xv}var vv,TM;function Pce(){if(TM)return vv;TM=1;function e(t,n){return t!=null&&n in Object(t)}return vv=e,vv}var bv,AM;function s6(){if(AM)return bv;AM=1;var e=hm(),t=td(),n=qt(),s=om(),a=EN(),o=sd();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 bv=i,bv}var kv,RM;function r6(){if(RM)return kv;RM=1;var e=Pce(),t=s6();function n(s,a){return s!=null&&t(s,a,e)}return kv=n,kv}var jv,MM;function Dce(){if(MM)return jv;MM=1;var e=Q5(),t=Oce(),n=r6(),s=DN(),a=e6(),o=t6(),i=sd(),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 jv=h,jv}var Nv,$M;function a6(){if($M)return Nv;$M=1;function e(t){return function(n){return n==null?void 0:n[t]}}return Nv=e,Nv}var Sv,LM;function Fce(){if(LM)return Sv;LM=1;var e=fm();function t(n){return function(s){return e(s,n)}}return Sv=t,Sv}var _v,IM;function Bce(){if(IM)return _v;IM=1;var e=a6(),t=Fce(),n=DN(),s=sd();function a(o){return n(o)?e(s(o)):t(o)}return _v=a,_v}var Cv,OM;function da(){if(OM)return Cv;OM=1;var e=Rce(),t=Dce(),n=ci(),s=qt(),a=Bce();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 Cv=o,Cv}var Ev,PM;function o6(){if(PM)return Ev;PM=1;var e=O5(),t=bce(),n=da(),s=qt();function a(o,i){var c=s(o)?e:t;return c(o,n(i,3))}return Ev=a,Ev}var Tv,DM;function qce(){if(DM)return Tv;DM=1;var e=Object.prototype,t=e.hasOwnProperty;function n(s,a){return s!=null&&t.call(s,a)}return Tv=n,Tv}var Av,FM;function i6(){if(FM)return Av;FM=1;var e=qce(),t=s6();function n(s,a){return s!=null&&t(s,a,e)}return Av=n,Av}var Rv,BM;function Uce(){if(BM)return Rv;BM=1;var e=AN(),t=Wl(),n=td(),s=qt(),a=ua(),o=Ul(),i=lm(),c=nd(),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 v=t(w);if(v==d||v==h)return!w.size;if(i(w))return!e(w).length;for(var b in w)if(p.call(w,b))return!1;return!0}return Rv=m,Rv}var Mv,qM;function l6(){if(qM)return Mv;qM=1;function e(t){return t===void 0}return Mv=e,Mv}var $v,UM;function c6(){if(UM)return $v;UM=1;var e=um(),t=ua();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 $v=n,$v}var Lv,WM;function u6(){if(WM)return Lv;WM=1;var e=dm(),t=da(),n=c6(),s=qt();function a(o,i){var c=s(o)?e:n;return c(o,t(i,3))}return Lv=a,Lv}var Iv,HM;function Wce(){if(HM)return Iv;HM=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 Iv=e,Iv}var Ov,zM;function Hce(){if(zM)return Ov;zM=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 Ov=e,Ov}var Pv,VM;function d6(){if(VM)return Pv;VM=1;var e=Wce(),t=um(),n=da(),s=Hce(),a=qt();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 Pv=o,Pv}var Dv,GM;function zce(){if(GM)return Dv;GM=1;var e=oi(),t=qt(),n=Er(),s="[object String]";function a(o){return typeof o=="string"||!t(o)&&n(o)&&e(o)==s}return Dv=a,Dv}var Fv,KM;function Vce(){if(KM)return Fv;KM=1;var e=a6(),t=e("length");return Fv=t,Fv}var Bv,YM;function Gce(){if(YM)return Bv;YM=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 Bv=d,Bv}var qv,XM;function Kce(){if(XM)return qv;XM=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",v=h+"?",b="["+o+"]?",k="(?:"+w+"(?:"+[f,p,m].join("|")+")"+b+v+")*",N=b+v+k,j="(?:"+[f+c+"?",c,p,m,i].join("|")+")",S=RegExp(d+"(?="+d+")|"+j+N,"g");function _(T){for(var L=S.lastIndex=0;S.test(T);)++L;return L}return qv=_,qv}var Uv,ZM;function Yce(){if(ZM)return Uv;ZM=1;var e=Vce(),t=Gce(),n=Kce();function s(a){return t(a)?n(a):e(a)}return Uv=s,Uv}var Wv,JM;function Xce(){if(JM)return Wv;JM=1;var e=AN(),t=Wl(),n=ua(),s=zce(),a=Yce(),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 Wv=c,Wv}var Hv,QM;function Zce(){if(QM)return Hv;QM=1;var e=CN(),t=H5(),n=ON(),s=da(),a=cm(),o=qt(),i=Ul(),c=Qu(),d=Ss(),h=nd();function f(p,m,w){var v=o(p),b=v||i(p)||h(p);if(m=s(m,4),w==null){var k=p&&p.constructor;b?w=v?new k:[]:d(p)?w=c(k)?t(a(p)):{}:w={}}return(b?e:n)(p,function(N,j,S){return m(w,N,j,S)}),w}return Hv=f,Hv}var zv,e$;function Jce(){if(e$)return zv;e$=1;var e=ql(),t=td(),n=qt(),s=e?e.isConcatSpreadable:void 0;function a(o){return n(o)||t(o)||!!(s&&o&&o[s])}return zv=a,zv}var Vv,t$;function FN(){if(t$)return Vv;t$=1;var e=MN(),t=Jce();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 Vv=n,Vv}var Gv,n$;function Qce(){if(n$)return Gv;n$=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 Gv=e,Gv}var Kv,s$;function h6(){if(s$)return Kv;s$=1;var e=Qce(),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 Kv=n,Kv}var Yv,r$;function eue(){if(r$)return Yv;r$=1;var e=LN(),t=R5(),n=ci(),s=t?function(a,o){return t(a,"toString",{configurable:!0,enumerable:!1,value:e(o),writable:!0})}:n;return Yv=s,Yv}var Xv,a$;function tue(){if(a$)return Xv;a$=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 Xv=s,Xv}var Zv,o$;function f6(){if(o$)return Zv;o$=1;var e=eue(),t=tue(),n=t(e);return Zv=n,Zv}var Jv,i$;function pm(){if(i$)return Jv;i$=1;var e=ci(),t=h6(),n=f6();function s(a,o){return n(t(a,o,e),a+"")}return Jv=s,Jv}var Qv,l$;function p6(){if(l$)return Qv;l$=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 Qv=e,Qv}var eb,c$;function nue(){if(c$)return eb;c$=1;function e(t){return t!==t}return eb=e,eb}var tb,u$;function sue(){if(u$)return tb;u$=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 tb=e,tb}var nb,d$;function rue(){if(d$)return nb;d$=1;var e=p6(),t=nue(),n=sue();function s(a,o,i){return o===o?n(a,o,i):e(a,t,i)}return nb=s,nb}var sb,h$;function aue(){if(h$)return sb;h$=1;var e=rue();function t(n,s){var a=n==null?0:n.length;return!!a&&e(n,s,0)>-1}return sb=t,sb}var rb,f$;function oue(){if(f$)return rb;f$=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 rb=e,rb}var ab,p$;function iue(){if(p$)return ab;p$=1;function e(){}return ab=e,ab}var ob,m$;function lue(){if(m$)return ob;m$=1;var e=q5(),t=iue(),n=PN(),s=1/0,a=e&&1/n(new e([,-0]))[1]==s?function(o){return new e(o)}:t;return ob=a,ob}var ib,g$;function cue(){if(g$)return ib;g$=1;var e=X5(),t=aue(),n=oue(),s=Z5(),a=lue(),o=PN(),i=200;function c(d,h,f){var p=-1,m=t,w=d.length,v=!0,b=[],k=b;if(f)v=!1,m=n;else if(w>=i){var N=h?null:a(d);if(N)return o(N);v=!1,m=s,k=new e}else k=h?[]:b;e:for(;++p<w;){var j=d[p],S=h?h(j):j;if(j=f||j!==0?j:0,v&&S===S){for(var _=k.length;_--;)if(k[_]===S)continue e;h&&k.push(S),b.push(j)}else m(k,S,f)||(k!==b&&k.push(S),b.push(j))}return b}return ib=c,ib}var lb,y$;function m6(){if(y$)return lb;y$=1;var e=ua(),t=Er();function n(s){return t(s)&&e(s)}return lb=n,lb}var cb,w$;function uue(){if(w$)return cb;w$=1;var e=FN(),t=pm(),n=cue(),s=m6(),a=t(function(o){return n(e(o,1,s,!0))});return cb=a,cb}var ub,x$;function due(){if(x$)return ub;x$=1;var e=dm();function t(n,s){return e(s,function(a){return n[a]})}return ub=t,ub}var db,v$;function g6(){if(v$)return db;v$=1;var e=due(),t=uo();function n(s){return s==null?[]:e(s,t(s))}return db=n,db}var hb,b$;function _s(){if(b$)return hb;b$=1;var e;if(typeof NN=="function")try{e={clone:wce(),constant:LN(),each:Y5(),filter:o6(),has:i6(),isArray:qt(),isEmpty:Uce(),isFunction:Qu(),isUndefined:l6(),keys:uo(),map:u6(),reduce:d6(),size:Xce(),transform:Zce(),union:uue(),values:g6()}}catch{}return e||(e=window._),hb=e,hb}var fb,k$;function BN(){if(k$)return fb;k$=1;var e=_s();fb=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(v){m.length>1?w.setNode(v,p):w.setNode(v)}),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(b,k){f(k)&&p.setNode(k,b)}),e.each(this._edgeObjs,function(b){p.hasNode(b.v)&&p.hasNode(b.w)&&p.setEdge(b,m.edge(b))});var w={};function v(b){var k=m.parent(b);return k===void 0||p.hasNode(k)?(w[b]=k,k):k in w?w[k]:v(k)}return this._isCompound&&e.each(p.nodes(),function(b){p.setParent(b,v(b))}),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(v,b){return w.length>1?m.setEdge(v,b,p):m.setEdge(v,b),b}),this},a.prototype.setEdge=function(){var f,p,m,w,v=!1,b=arguments[0];typeof b=="object"&&b!==null&&"v"in b?(f=b.v,p=b.w,m=b.name,arguments.length===2&&(w=arguments[1],v=!0)):(f=b,p=arguments[1],m=arguments[3],arguments.length>2&&(w=arguments[2],v=!0)),f=""+f,p=""+p,e.isUndefined(m)||(m=""+m);var k=c(this._isDirected,f,p,m);if(e.has(this._edgeLabels,k))return v&&(this._edgeLabels[k]=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[k]=v?w:this._defaultEdgeLabelFn(f,p,m);var N=d(this._isDirected,f,p,m);return f=N.v,p=N.w,Object.freeze(N),this._edgeObjs[k]=N,o(this._preds[p],f),o(this._sucs[f],p),this._in[p][k]=N,this._out[f][k]=N,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),v=this._edgeObjs[w];return v&&(f=v.v,p=v.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(v){return v.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(v){return v.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 v=""+p,b=""+m;if(!f&&v>b){var k=v;v=b,b=k}return v+s+b+s+(e.isUndefined(w)?t:w)}function d(f,p,m,w){var v=""+p,b=""+m;if(!f&&v>b){var k=v;v=b,b=k}var N={v,w:b};return w&&(N.name=w),N}function h(f,p){return c(f,p.v,p.w,p.name)}return fb}var pb,j$;function hue(){return j$||(j$=1,pb="2.1.8"),pb}var mb,N$;function fue(){return N$||(N$=1,mb={Graph:BN(),version:hue()}),mb}var gb,S$;function pue(){if(S$)return gb;S$=1;var e=_s(),t=BN();gb={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 gb}var yb,_$;function mue(){if(_$)return yb;_$=1;var e=_s();yb=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 yb}var wb,C$;function y6(){if(C$)return wb;C$=1;var e=_s();wb=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},wb}var xb,E$;function w6(){if(E$)return xb;E$=1;var e=_s(),t=y6();xb=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(v){var b=v.v!==p?v.v:v.w,k=h[b],N=c(v),j=m.distance+N;if(N<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+v+" Weight: "+N);j<k.distance&&(k.distance=j,k.predecessor=p,f.decrease(b,j))};for(o.nodes().forEach(function(v){var b=v===i?0:Number.POSITIVE_INFINITY;h[v]={distance:b},f.add(v,b)});f.size()>0&&(p=f.removeMin(),m=h[p],m.distance!==Number.POSITIVE_INFINITY);)d(p).forEach(w);return h}return xb}var vb,T$;function gue(){if(T$)return vb;T$=1;var e=w6(),t=_s();vb=n;function n(s,a,o){return t.transform(s.nodes(),function(i,c){i[c]=e(s,c,a,o)},{})}return vb}var bb,A$;function x6(){if(A$)return bb;A$=1;var e=_s();bb=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 bb}var kb,R$;function yue(){if(R$)return kb;R$=1;var e=_s(),t=x6();kb=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 kb}var jb,M$;function wue(){if(M$)return jb;M$=1;var e=_s();jb=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 v=m[h],b=f[w],k=m[w],N=v.distance+b.distance;N<k.distance&&(k.distance=N,k.predecessor=b.predecessor)})})}),c}return jb}var Nb,$$;function v6(){if($$)return Nb;$$=1;var e=_s();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,L$;function xue(){if(L$)return Sb;L$=1;var e=v6();Sb=t;function t(n){try{e(n)}catch(s){if(s instanceof e.CycleException)return!1;throw s}return!0}return Sb}var _b,I$;function b6(){if(I$)return _b;I$=1;var e=_s();_b=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 _b}var Cb,O$;function vue(){if(O$)return Cb;O$=1;var e=b6();Cb=t;function t(n,s){return e(n,s,"post")}return Cb}var Eb,P$;function bue(){if(P$)return Eb;P$=1;var e=b6();Eb=t;function t(n,s){return e(n,s,"pre")}return Eb}var Tb,D$;function kue(){if(D$)return Tb;D$=1;var e=_s(),t=BN(),n=y6();Tb=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,v=d.priority(w);if(v!==void 0){var b=o(m);b<v&&(c[w]=h,d.decrease(w,b))}}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 Tb}var Ab,F$;function jue(){return F$||(F$=1,Ab={components:mue(),dijkstra:w6(),dijkstraAll:gue(),findCycles:yue(),floydWarshall:wue(),isAcyclic:xue(),postorder:vue(),preorder:bue(),prim:kue(),tarjan:x6(),topsort:v6()}),Ab}var Rb,B$;function Nue(){if(B$)return Rb;B$=1;var e=fue();return Rb={Graph:e.Graph,json:pue(),alg:jue(),version:e.version},Rb}var Mb,q$;function Js(){if(q$)return Mb;q$=1;var e;if(typeof NN=="function")try{e=Nue()}catch{}return e||(e=window.graphlib),Mb=e,Mb}var $b,U$;function Sue(){if(U$)return $b;U$=1;var e=V5(),t=1,n=4;function s(a){return e(a,t|n)}return $b=s,$b}var Lb,W$;function mm(){if(W$)return Lb;W$=1;var e=Bl(),t=ua(),n=om(),s=Ss();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 Lb=a,Lb}var Ib,H$;function _ue(){if(H$)return Ib;H$=1;var e=pm(),t=Bl(),n=mm(),s=li(),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),v=-1,b=w.length;++v<b;){var k=w[v],N=c[k];(N===void 0||t(N,a[k])&&!o.call(c,k))&&(c[k]=m[k])}return c});return Ib=i,Ib}var Ob,z$;function Cue(){if(z$)return Ob;z$=1;var e=da(),t=ua(),n=uo();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 Ob=s,Ob}var Pb,V$;function Eue(){if(V$)return Pb;V$=1;var e=/\s/;function t(n){for(var s=n.length;s--&&e.test(n.charAt(s)););return s}return Pb=t,Pb}var Db,G$;function Tue(){if(G$)return Db;G$=1;var e=Eue(),t=/^\s+/;function n(s){return s&&s.slice(0,e(s)+1).replace(t,"")}return Db=n,Db}var Fb,K$;function Aue(){if(K$)return Fb;K$=1;var e=Tue(),t=Ss(),n=Hl(),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 Fb=d,Fb}var Bb,Y$;function k6(){if(Y$)return Bb;Y$=1;var e=Aue(),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 Bb=s,Bb}var qb,X$;function Rue(){if(X$)return qb;X$=1;var e=k6();function t(n){var s=e(n),a=s%1;return s===s?a?s-a:s:0}return qb=t,qb}var Ub,Z$;function Mue(){if(Z$)return Ub;Z$=1;var e=p6(),t=da(),n=Rue(),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 Ub=a,Ub}var Wb,J$;function $ue(){if(J$)return Wb;J$=1;var e=Cue(),t=Mue(),n=e(t);return Wb=n,Wb}var Hb,Q$;function j6(){if(Q$)return Hb;Q$=1;var e=FN();function t(n){var s=n==null?0:n.length;return s?e(n,1):[]}return Hb=t,Hb}var zb,eL;function Lue(){if(eL)return zb;eL=1;var e=IN(),t=G5(),n=li();function s(a,o){return a==null?a:e(a,t(o),n)}return zb=s,zb}var Vb,tL;function Iue(){if(tL)return Vb;tL=1;function e(t){var n=t==null?0:t.length;return n?t[n-1]:void 0}return Vb=e,Vb}var Gb,nL;function Oue(){if(nL)return Gb;nL=1;var e=rm(),t=ON(),n=da();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 Gb=s,Gb}var Kb,sL;function qN(){if(sL)return Kb;sL=1;var e=Hl();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 Kb=t,Kb}var Yb,rL;function Pue(){if(rL)return Yb;rL=1;function e(t,n){return t>n}return Yb=e,Yb}var Xb,aL;function Due(){if(aL)return Xb;aL=1;var e=qN(),t=Pue(),n=ci();function s(a){return a&&a.length?e(a,n,t):void 0}return Xb=s,Xb}var Zb,oL;function N6(){if(oL)return Zb;oL=1;var e=rm(),t=Bl();function n(s,a,o){(o!==void 0&&!t(s[a],o)||o===void 0&&!(a in s))&&e(s,a,o)}return Zb=n,Zb}var Jb,iL;function Fue(){if(iL)return Jb;iL=1;var e=oi(),t=cm(),n=Er(),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 Jb=h,Jb}var Qb,lL;function S6(){if(lL)return Qb;lL=1;function e(t,n){if(!(n==="constructor"&&typeof t[n]=="function")&&n!="__proto__")return t[n]}return Qb=e,Qb}var ek,cL;function Bue(){if(cL)return ek;cL=1;var e=ed(),t=li();function n(s){return e(s,t(s))}return ek=n,ek}var tk,uL;function que(){if(uL)return tk;uL=1;var e=N6(),t=L5(),n=W5(),s=I5(),a=z5(),o=td(),i=qt(),c=m6(),d=Ul(),h=Qu(),f=Ss(),p=Fue(),m=nd(),w=S6(),v=Bue();function b(k,N,j,S,_,T,L){var A=w(k,j),P=w(N,j),O=L.get(P);if(O){e(k,j,O);return}var U=T?T(A,P,j+"",k,N,L):void 0,q=U===void 0;if(q){var M=i(P),I=!M&&d(P),E=!M&&!I&&m(P);U=P,M||I||E?i(A)?U=A:c(A)?U=s(A):I?(q=!1,U=t(P,!0)):E?(q=!1,U=n(P,!0)):U=[]:p(P)||o(P)?(U=A,o(A)?U=v(A):(!f(A)||h(A))&&(U=a(P))):q=!1}q&&(L.set(P,U),_(U,P,S,T,L),L.delete(P)),e(k,j,U)}return tk=b,tk}var nk,dL;function Uue(){if(dL)return nk;dL=1;var e=sm(),t=N6(),n=IN(),s=que(),a=Ss(),o=li(),i=S6();function c(d,h,f,p,m){d!==h&&n(h,function(w,v){if(m||(m=new e),a(w))s(d,h,v,f,c,p,m);else{var b=p?p(i(d,v),w,v+"",d,h,m):void 0;b===void 0&&(b=w),t(d,v,b)}},o)}return nk=c,nk}var sk,hL;function Wue(){if(hL)return sk;hL=1;var e=pm(),t=mm();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 sk=n,sk}var rk,fL;function Hue(){if(fL)return rk;fL=1;var e=Uue(),t=Wue(),n=t(function(s,a,o){e(s,a,o)});return rk=n,rk}var ak,pL;function _6(){if(pL)return ak;pL=1;function e(t,n){return t<n}return ak=e,ak}var ok,mL;function zue(){if(mL)return ok;mL=1;var e=qN(),t=_6(),n=ci();function s(a){return a&&a.length?e(a,n,t):void 0}return ok=s,ok}var ik,gL;function Vue(){if(gL)return ik;gL=1;var e=qN(),t=da(),n=_6();function s(a,o){return a&&a.length?e(a,t(o,2),n):void 0}return ik=s,ik}var lk,yL;function Gue(){if(yL)return lk;yL=1;var e=er(),t=function(){return e.Date.now()};return lk=t,lk}var ck,wL;function Kue(){if(wL)return ck;wL=1;var e=am(),t=hm(),n=om(),s=Ss(),a=sd();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 v=a(c[f]),b=d;if(v==="__proto__"||v==="constructor"||v==="prototype")return i;if(f!=m){var k=w[v];b=h?h(k,v,w):void 0,b===void 0&&(b=s(k)?k:n(c[f+1])?[]:{})}e(w,v,b),w=w[v]}return i}return ck=o,ck}var uk,xL;function Yue(){if(xL)return uk;xL=1;var e=fm(),t=Kue(),n=hm();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 uk=s,uk}var dk,vL;function Xue(){if(vL)return dk;vL=1;var e=Yue(),t=r6();function n(s,a){return e(s,a,function(o,i){return t(s,i)})}return dk=n,dk}var hk,bL;function Zue(){if(bL)return hk;bL=1;var e=j6(),t=h6(),n=f6();function s(a){return n(t(a,void 0,e),a+"")}return hk=s,hk}var fk,kL;function Jue(){if(kL)return fk;kL=1;var e=Xue(),t=Zue(),n=t(function(s,a){return s==null?{}:e(s,a)});return fk=n,fk}var pk,jL;function Que(){if(jL)return pk;jL=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 pk=n,pk}var mk,NL;function ede(){if(NL)return mk;NL=1;var e=Que(),t=mm(),n=k6();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 mk=s,mk}var gk,SL;function tde(){if(SL)return gk;SL=1;var e=ede(),t=e();return gk=t,gk}var yk,_L;function nde(){if(_L)return yk;_L=1;function e(t,n){var s=t.length;for(t.sort(n);s--;)t[s]=t[s].value;return t}return yk=e,yk}var wk,CL;function sde(){if(CL)return wk;CL=1;var e=Hl();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 wk=t,wk}var xk,EL;function rde(){if(EL)return xk;EL=1;var e=sde();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 xk=t,xk}var vk,TL;function ade(){if(TL)return vk;TL=1;var e=dm(),t=fm(),n=da(),s=c6(),a=nde(),o=im(),i=rde(),c=ci(),d=qt();function h(f,p,m){p.length?p=e(p,function(b){return d(b)?function(k){return t(k,b.length===1?b[0]:b)}:b}):p=[c];var w=-1;p=e(p,o(n));var v=s(f,function(b,k,N){var j=e(p,function(S){return S(b)});return{criteria:j,index:++w,value:b}});return a(v,function(b,k){return i(b,k,m)})}return vk=h,vk}var bk,AL;function ode(){if(AL)return bk;AL=1;var e=FN(),t=ade(),n=pm(),s=mm(),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 bk=a,bk}var kk,RL;function ide(){if(RL)return kk;RL=1;var e=n6(),t=0;function n(s){var a=++t;return e(s)+a}return kk=n,kk}var jk,ML;function lde(){if(ML)return jk;ML=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 jk=e,jk}var Nk,$L;function cde(){if($L)return Nk;$L=1;var e=am(),t=lde();function n(s,a){return t(s||[],a||[],e)}return Nk=n,Nk}var Sk,LL;function _t(){if(LL)return Sk;LL=1;var e;if(typeof NN=="function")try{e={cloneDeep:Sue(),constant:LN(),defaults:_ue(),each:Y5(),filter:o6(),find:$ue(),flatten:j6(),forEach:K5(),forIn:Lue(),has:i6(),isUndefined:l6(),last:Iue(),map:u6(),mapValues:Oue(),max:Due(),merge:Hue(),min:zue(),minBy:Vue(),now:Gue(),pick:Jue(),range:tde(),reduce:d6(),sortBy:ode(),uniqueId:ide(),values:g6(),zipObject:cde()}}catch{}return e||(e=window._),Sk=e,Sk}var _k,IL;function ude(){if(IL)return _k;IL=1,_k=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 _k}var Ck,OL;function dde(){if(OL)return Ck;OL=1;var e=_t(),t=Js().Graph,n=ude();Ck=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],v=f[0],b;h.nodeCount();){for(;b=v.dequeue();)i(h,f,p,b);for(;b=w.dequeue();)i(h,f,p,b);if(h.nodeCount()){for(var k=f.length-2;k>0;--k)if(b=f[k].dequeue(),b){m=m.concat(i(h,f,p,b,!0));break}}}return m}function i(h,f,p,m,w){var v=w?[]:void 0;return e.forEach(h.inEdges(m.v),function(b){var k=h.edge(b),N=h.node(b.v);w&&v.push({v:b.v,w:b.w}),N.out-=k,d(f,p,N)}),e.forEach(h.outEdges(m.v),function(b){var k=h.edge(b),N=b.w,j=h.node(N);j.in-=k,d(f,p,j)}),h.removeNode(m.v),v}function c(h,f){var p=new t,m=0,w=0;e.forEach(h.nodes(),function(k){p.setNode(k,{v:k,in:0,out:0})}),e.forEach(h.edges(),function(k){var N=p.edge(k.v,k.w)||0,j=f(k),S=N+j;p.setEdge(k.v,k.w,S),w=Math.max(w,p.node(k.v).out+=j),m=Math.max(m,p.node(k.w).in+=j)});var v=e.range(w+m+3).map(function(){return new n}),b=m+1;return e.forEach(p.nodes(),function(k){d(v,b,p.node(k))}),{graph:p,buckets:v,zeroIdx:b}}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 Ck}var Ek,PL;function hde(){if(PL)return Ek;PL=1;var e=_t(),t=dde();Ek={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 Ek}var Tk,DL;function Dn(){if(DL)return Tk;DL=1;var e=_t(),t=Js().Graph;Tk={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:v,notime:b};function n(k,N,j,S){var _;do _=e.uniqueId(S);while(k.hasNode(_));return j.dummy=N,k.setNode(_,j),_}function s(k){var N=new t().setGraph(k.graph());return e.forEach(k.nodes(),function(j){N.setNode(j,k.node(j))}),e.forEach(k.edges(),function(j){var S=N.edge(j.v,j.w)||{weight:0,minlen:1},_=k.edge(j);N.setEdge(j.v,j.w,{weight:S.weight+_.weight,minlen:Math.max(S.minlen,_.minlen)})}),N}function a(k){var N=new t({multigraph:k.isMultigraph()}).setGraph(k.graph());return e.forEach(k.nodes(),function(j){k.children(j).length||N.setNode(j,k.node(j))}),e.forEach(k.edges(),function(j){N.setEdge(j,k.edge(j))}),N}function o(k){var N=e.map(k.nodes(),function(j){var S={};return e.forEach(k.outEdges(j),function(_){S[_.w]=(S[_.w]||0)+k.edge(_).weight}),S});return e.zipObject(k.nodes(),N)}function i(k){var N=e.map(k.nodes(),function(j){var S={};return e.forEach(k.inEdges(j),function(_){S[_.v]=(S[_.v]||0)+k.edge(_).weight}),S});return e.zipObject(k.nodes(),N)}function c(k,N){var j=k.x,S=k.y,_=N.x-j,T=N.y-S,L=k.width/2,A=k.height/2;if(!_&&!T)throw new Error("Not possible to find intersection inside of the rectangle");var P,O;return Math.abs(T)*L>Math.abs(_)*A?(T<0&&(A=-A),P=A*_/T,O=A):(_<0&&(L=-L),P=L,O=L*T/_),{x:j+P,y:S+O}}function d(k){var N=e.map(e.range(m(k)+1),function(){return[]});return e.forEach(k.nodes(),function(j){var S=k.node(j),_=S.rank;e.isUndefined(_)||(N[_][S.order]=j)}),N}function h(k){var N=e.min(e.map(k.nodes(),function(j){return k.node(j).rank}));e.forEach(k.nodes(),function(j){var S=k.node(j);e.has(S,"rank")&&(S.rank-=N)})}function f(k){var N=e.min(e.map(k.nodes(),function(T){return k.node(T).rank})),j=[];e.forEach(k.nodes(),function(T){var L=k.node(T).rank-N;j[L]||(j[L]=[]),j[L].push(T)});var S=0,_=k.graph().nodeRankFactor;e.forEach(j,function(T,L){e.isUndefined(T)&&L%_!==0?--S:S&&e.forEach(T,function(A){k.node(A).rank+=S})})}function p(k,N,j,S){var _={width:0,height:0};return arguments.length>=4&&(_.rank=j,_.order=S),n(k,"border",_,N)}function m(k){return e.max(e.map(k.nodes(),function(N){var j=k.node(N).rank;if(!e.isUndefined(j))return j}))}function w(k,N){var j={lhs:[],rhs:[]};return e.forEach(k,function(S){N(S)?j.lhs.push(S):j.rhs.push(S)}),j}function v(k,N){var j=e.now();try{return N()}finally{console.log(k+" time: "+(e.now()-j)+"ms")}}function b(k,N){return N()}return Tk}var Ak,FL;function fde(){if(FL)return Ak;FL=1;var e=_t(),t=Dn();Ak={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 v,b,k;for(k=0,++d;d<f;++k,++d)m.points=[],b={width:0,height:0,edgeLabel:m,edgeObj:i,rank:d},v=t.addDummyNode(o,"edge",b,"_d"),d===w&&(b.width=m.width,b.height=m.height,b.dummy="edge-label",b.labelpos=m.labelpos),o.setEdge(c,v,{weight:m.weight},p),k===0&&o.graph().dummyChains.push(v),c=v;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 Ak}var Rk,BL;function op(){if(BL)return Rk;BL=1;var e=_t();Rk={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 Rk}var Mk,qL;function C6(){if(qL)return Mk;qL=1;var e=_t(),t=Js().Graph,n=op().slack;Mk=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 Mk}var $k,UL;function pde(){if(UL)return $k;UL=1;var e=_t(),t=C6(),n=op().slack,s=op().longestPath,a=Js().alg.preorder,o=Js().alg.postorder,i=Dn().simplify;$k=c,c.initLowLimValues=p,c.initCutValues=d,c.calcCutValue=f,c.leaveEdge=w,c.enterEdge=v,c.exchangeEdges=b;function c(S){S=i(S),s(S);var _=t(S);p(_),d(_,S);for(var T,L;T=w(_);)L=v(_,S,T),b(_,S,T,L)}function d(S,_){var T=o(S,S.nodes());T=T.slice(0,T.length-1),e.forEach(T,function(L){h(S,_,L)})}function h(S,_,T){var L=S.node(T),A=L.parent;S.edge(T,A).cutvalue=f(S,_,T)}function f(S,_,T){var L=S.node(T),A=L.parent,P=!0,O=_.edge(T,A),U=0;return O||(P=!1,O=_.edge(A,T)),U=O.weight,e.forEach(_.nodeEdges(T),function(q){var M=q.v===T,I=M?q.w:q.v;if(I!==A){var E=M===P,D=_.edge(q).weight;if(U+=E?D:-D,N(S,T,I)){var B=S.edge(T,I).cutvalue;U+=E?-B:B}}}),U}function p(S,_){arguments.length<2&&(_=S.nodes()[0]),m(S,{},1,_)}function m(S,_,T,L,A){var P=T,O=S.node(L);return _[L]=!0,e.forEach(S.neighbors(L),function(U){e.has(_,U)||(T=m(S,_,T,U,L))}),O.low=P,O.lim=T++,A?O.parent=A:delete O.parent,T}function w(S){return e.find(S.edges(),function(_){return S.edge(_).cutvalue<0})}function v(S,_,T){var L=T.v,A=T.w;_.hasEdge(L,A)||(L=T.w,A=T.v);var P=S.node(L),O=S.node(A),U=P,q=!1;P.lim>O.lim&&(U=O,q=!0);var M=e.filter(_.edges(),function(I){return q===j(S,S.node(I.v),U)&&q!==j(S,S.node(I.w),U)});return e.minBy(M,function(I){return n(_,I)})}function b(S,_,T,L){var A=T.v,P=T.w;S.removeEdge(A,P),S.setEdge(L.v,L.w,{}),p(S),d(S,_),k(S,_)}function k(S,_){var T=e.find(S.nodes(),function(A){return!_.node(A).parent}),L=a(S,T);L=L.slice(1),e.forEach(L,function(A){var P=S.node(A).parent,O=_.edge(A,P),U=!1;O||(O=_.edge(P,A),U=!0),_.node(A).rank=_.node(P).rank+(U?O.minlen:-O.minlen)})}function N(S,_,T){return S.hasEdge(_,T)}function j(S,_,T){return T.low<=_.lim&&_.lim<=T.lim}return $k}var Lk,WL;function mde(){if(WL)return Lk;WL=1;var e=op(),t=e.longestPath,n=C6(),s=pde();Lk=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 Lk}var Ik,HL;function gde(){if(HL)return Ik;HL=1;var e=_t();Ik=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],v=!0;i!==d.w;){if(c=a.node(i),v){for(;(w=f[m])!==p&&a.node(w).maxRank<c.rank;)m++;w===p&&(v=!1)}if(!v){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 Ik}var Ok,zL;function yde(){if(zL)return Ok;zL=1;var e=_t(),t=Dn();Ok={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 v=c.children(w);if(!v.length){w!==d&&c.setEdge(d,w,{weight:0,minlen:h});return}var b=t.addBorderNode(c,"_bt"),k=t.addBorderNode(c,"_bb"),N=c.node(w);c.setParent(b,w),N.borderTop=b,c.setParent(k,w),N.borderBottom=k,e.forEach(v,function(j){s(c,d,h,f,p,m,j);var S=c.node(j),_=S.borderTop?S.borderTop:j,T=S.borderBottom?S.borderBottom:j,L=S.borderTop?f:2*f,A=_!==T?1:p-m[w]+1;c.setEdge(b,_,{weight:L,minlen:A,nestingEdge:!0}),c.setEdge(T,k,{weight:L,minlen:A,nestingEdge:!0})}),c.parent(w)||c.setEdge(d,b,{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 Ok}var Pk,VL;function wde(){if(VL)return Pk;VL=1;var e=_t(),t=Dn();Pk=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 Pk}var Dk,GL;function xde(){if(GL)return Dk;GL=1;var e=_t();Dk={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 Dk}var Fk,KL;function vde(){if(KL)return Fk;KL=1;var e=_t();Fk=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 Fk}var Bk,YL;function bde(){if(YL)return Bk;YL=1;var e=_t();Bk=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 v=0;w>0;)w%2&&(v+=f[w+1]),w=w-1>>1,f[w]+=m.weight;p+=m.weight*v})),p}return Bk}var qk,XL;function kde(){if(XL)return qk;XL=1;var e=_t();qk=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 qk}var Uk,ZL;function jde(){if(ZL)return Uk;ZL=1;var e=_t();Uk=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 Uk}var Wk,JL;function Nde(){if(JL)return Wk;JL=1;var e=_t(),t=Dn();Wk=n;function n(o,i){var c=t.partition(o,function(b){return e.has(b,"barycenter")}),d=c.lhs,h=e.sortBy(c.rhs,function(b){return-b.i}),f=[],p=0,m=0,w=0;d.sort(a(!!i)),w=s(f,h,w),e.forEach(d,function(b){w+=b.vs.length,f.push(b.vs),p+=b.barycenter*b.weight,m+=b.weight,w=s(f,h,w)});var v={vs:e.flatten(f,!0)};return m&&(v.barycenter=p/m,v.weight=m),v}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 Wk}var Hk,QL;function Sde(){if(QL)return Hk;QL=1;var e=_t(),t=kde(),n=jde(),s=Nde();Hk=a;function a(c,d,h,f){var p=c.children(d),m=c.node(d),w=m?m.borderLeft:void 0,v=m?m.borderRight:void 0,b={};w&&(p=e.filter(p,function(T){return T!==w&&T!==v}));var k=t(c,p);e.forEach(k,function(T){if(c.children(T.v).length){var L=a(c,T.v,h,f);b[T.v]=L,e.has(L,"barycenter")&&i(T,L)}});var N=n(k,h);o(N,b);var j=s(N,f);if(w&&(j.vs=e.flatten([w,j.vs,v],!0),c.predecessors(w).length)){var S=c.node(c.predecessors(w)[0]),_=c.node(c.predecessors(v)[0]);e.has(j,"barycenter")||(j.barycenter=0,j.weight=0),j.barycenter=(j.barycenter*j.weight+S.order+_.order)/(j.weight+2),j.weight+=2}return j}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 Hk}var zk,eI;function _de(){if(eI)return zk;eI=1;var e=_t(),t=Js().Graph;zk=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,v=d.edge(w,h),b=e.isUndefined(v)?0:v.weight;d.setEdge(w,h,{weight:a.edge(m).weight+b})}),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 zk}var Vk,tI;function Cde(){if(tI)return Vk;tI=1;var e=_t();Vk=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 Vk}var Gk,nI;function Ede(){if(nI)return Gk;nI=1;var e=_t(),t=vde(),n=bde(),s=Sde(),a=_de(),o=Cde(),i=Js().Graph,c=Dn();Gk=d;function d(m){var w=c.maxRank(m),v=h(m,e.range(1,w+1),"inEdges"),b=h(m,e.range(w-1,-1,-1),"outEdges"),k=t(m);p(m,k);for(var N=Number.POSITIVE_INFINITY,j,S=0,_=0;_<4;++S,++_){f(S%2?v:b,S%4>=2),k=c.buildLayerMatrix(m);var T=n(m,k);T<N&&(_=0,j=e.cloneDeep(k),N=T)}p(m,j)}function h(m,w,v){return e.map(w,function(b){return a(m,b,v)})}function f(m,w){var v=new i;e.forEach(m,function(b){var k=b.graph().root,N=s(b,k,v,w);e.forEach(N.vs,function(j,S){b.node(j).order=S}),o(b,v,N.vs)})}function p(m,w){e.forEach(w,function(v){e.forEach(v,function(b,k){m.node(b).order=k})})}return Gk}var Kk,sI;function Tde(){if(sI)return Kk;sI=1;var e=_t(),t=Js().Graph,n=Dn();Kk={positionX:v,findType1Conflicts:s,findType2Conflicts:a,addConflict:i,hasConflict:c,verticalAlignment:d,horizontalCompaction:h,alignCoordinates:m,findSmallestWidthAlignment:p,balance:w};function s(N,j){var S={};function _(T,L){var A=0,P=0,O=T.length,U=e.last(L);return e.forEach(L,function(q,M){var I=o(N,q),E=I?N.node(I).order:O;(I||q===U)&&(e.forEach(L.slice(P,M+1),function(D){e.forEach(N.predecessors(D),function(B){var H=N.node(B),G=H.order;(G<A||E<G)&&!(H.dummy&&N.node(D).dummy)&&i(S,B,D)})}),P=M+1,A=E)}),L}return e.reduce(j,_),S}function a(N,j){var S={};function _(L,A,P,O,U){var q;e.forEach(e.range(A,P),function(M){q=L[M],N.node(q).dummy&&e.forEach(N.predecessors(q),function(I){var E=N.node(I);E.dummy&&(E.order<O||E.order>U)&&i(S,I,q)})})}function T(L,A){var P=-1,O,U=0;return e.forEach(A,function(q,M){if(N.node(q).dummy==="border"){var I=N.predecessors(q);I.length&&(O=N.node(I[0]).order,_(A,U,M,P,O),U=M,P=O)}_(A,U,A.length,O,L.length)}),A}return e.reduce(j,T),S}function o(N,j){if(N.node(j).dummy)return e.find(N.predecessors(j),function(S){return N.node(S).dummy})}function i(N,j,S){if(j>S){var _=j;j=S,S=_}var T=N[j];T||(N[j]=T={}),T[S]=!0}function c(N,j,S){if(j>S){var _=j;j=S,S=_}return e.has(N[j],S)}function d(N,j,S,_){var T={},L={},A={};return e.forEach(j,function(P){e.forEach(P,function(O,U){T[O]=O,L[O]=O,A[O]=U})}),e.forEach(j,function(P){var O=-1;e.forEach(P,function(U){var q=_(U);if(q.length){q=e.sortBy(q,function(B){return A[B]});for(var M=(q.length-1)/2,I=Math.floor(M),E=Math.ceil(M);I<=E;++I){var D=q[I];L[U]===U&&O<A[D]&&!c(S,U,D)&&(L[D]=U,L[U]=T[U]=T[D],O=A[D])}}})}),{root:T,align:L}}function h(N,j,S,_,T){var L={},A=f(N,j,S,T),P=T?"borderLeft":"borderRight";function O(M,I){for(var E=A.nodes(),D=E.pop(),B={};D;)B[D]?M(D):(B[D]=!0,E.push(D),E=E.concat(I(D))),D=E.pop()}function U(M){L[M]=A.inEdges(M).reduce(function(I,E){return Math.max(I,L[E.v]+A.edge(E))},0)}function q(M){var I=A.outEdges(M).reduce(function(D,B){return Math.min(D,L[B.w]-A.edge(B))},Number.POSITIVE_INFINITY),E=N.node(M);I!==Number.POSITIVE_INFINITY&&E.borderType!==P&&(L[M]=Math.max(L[M],I))}return O(U,A.predecessors.bind(A)),O(q,A.successors.bind(A)),e.forEach(_,function(M){L[M]=L[S[M]]}),L}function f(N,j,S,_){var T=new t,L=N.graph(),A=b(L.nodesep,L.edgesep,_);return e.forEach(j,function(P){var O;e.forEach(P,function(U){var q=S[U];if(T.setNode(q),O){var M=S[O],I=T.edge(M,q);T.setEdge(M,q,Math.max(A(N,U,O),I||0))}O=U})}),T}function p(N,j){return e.minBy(e.values(j),function(S){var _=Number.NEGATIVE_INFINITY,T=Number.POSITIVE_INFINITY;return e.forIn(S,function(L,A){var P=k(N,A)/2;_=Math.max(L+P,_),T=Math.min(L-P,T)}),_-T})}function m(N,j){var S=e.values(j),_=e.min(S),T=e.max(S);e.forEach(["u","d"],function(L){e.forEach(["l","r"],function(A){var P=L+A,O=N[P],U;if(O!==j){var q=e.values(O);U=A==="l"?_-e.min(q):T-e.max(q),U&&(N[P]=e.mapValues(O,function(M){return M+U}))}})})}function w(N,j){return e.mapValues(N.ul,function(S,_){if(j)return N[j.toLowerCase()][_];var T=e.sortBy(e.map(N,_));return(T[1]+T[2])/2})}function v(N){var j=n.buildLayerMatrix(N),S=e.merge(s(N,j),a(N,j)),_={},T;e.forEach(["u","d"],function(A){T=A==="u"?j:e.values(j).reverse(),e.forEach(["l","r"],function(P){P==="r"&&(T=e.map(T,function(M){return e.values(M).reverse()}));var O=(A==="u"?N.predecessors:N.successors).bind(N),U=d(N,T,S,O),q=h(N,T,U.root,U.align,P==="r");P==="r"&&(q=e.mapValues(q,function(M){return-M})),_[A+P]=q})});var L=p(N,_);return m(_,L),w(_,N.graph().align)}function b(N,j,S){return function(_,T,L){var A=_.node(T),P=_.node(L),O=0,U;if(O+=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&&(O+=S?U:-U),U=0,O+=(A.dummy?j:N)/2,O+=(P.dummy?j:N)/2,O+=P.width/2,e.has(P,"labelpos"))switch(P.labelpos.toLowerCase()){case"l":U=P.width/2;break;case"r":U=-P.width/2;break}return U&&(O+=S?U:-U),U=0,O}}function k(N,j){return N.node(j).width}return Kk}var Yk,rI;function Ade(){if(rI)return Yk;rI=1;var e=_t(),t=Dn(),n=Tde().positionX;Yk=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 Yk}var Xk,aI;function Rde(){if(aI)return Xk;aI=1;var e=_t(),t=hde(),n=fde(),s=mde(),a=Dn().normalizeRanks,o=gde(),i=Dn().removeEmptyRanks,c=yde(),d=wde(),h=xde(),f=Ede(),p=Ade(),m=Dn(),w=Js().Graph;Xk=v;function v(V,Y){var X=Y&&Y.debugTiming?m.time:m.notime;X("layout",function(){var J=X(" buildLayoutGraph",function(){return O(V)});X(" runLayout",function(){b(J,X)}),X(" updateInputGraph",function(){k(V,J)})})}function b(V,Y){Y(" makeSpaceForEdgeLabels",function(){U(V)}),Y(" removeSelfEdges",function(){z(V)}),Y(" acyclic",function(){t.run(V)}),Y(" nestingGraph.run",function(){c.run(V)}),Y(" rank",function(){s(m.asNonCompoundGraph(V))}),Y(" injectEdgeLabelProxies",function(){q(V)}),Y(" removeEmptyRanks",function(){i(V)}),Y(" nestingGraph.cleanup",function(){c.cleanup(V)}),Y(" normalizeRanks",function(){a(V)}),Y(" assignRankMinMax",function(){M(V)}),Y(" removeEdgeLabelProxies",function(){I(V)}),Y(" normalize.run",function(){n.run(V)}),Y(" parentDummyChains",function(){o(V)}),Y(" addBorderSegments",function(){d(V)}),Y(" order",function(){f(V)}),Y(" insertSelfEdges",function(){F(V)}),Y(" adjustCoordinateSystem",function(){h.adjust(V)}),Y(" position",function(){p(V)}),Y(" positionSelfEdges",function(){$(V)}),Y(" removeBorderNodes",function(){G(V)}),Y(" normalize.undo",function(){n.undo(V)}),Y(" fixupEdgeLabelCoords",function(){B(V)}),Y(" undoCoordinateSystem",function(){h.undo(V)}),Y(" translateGraph",function(){E(V)}),Y(" assignNodeIntersects",function(){D(V)}),Y(" reversePoints",function(){H(V)}),Y(" acyclic.undo",function(){t.undo(V)})}function k(V,Y){e.forEach(V.nodes(),function(X){var J=V.node(X),Q=Y.node(X);J&&(J.x=Q.x,J.y=Q.y,Y.children(X).length&&(J.width=Q.width,J.height=Q.height))}),e.forEach(V.edges(),function(X){var J=V.edge(X),Q=Y.edge(X);J.points=Q.points,e.has(Q,"x")&&(J.x=Q.x,J.y=Q.y)}),V.graph().width=Y.graph().width,V.graph().height=Y.graph().height}var N=["nodesep","edgesep","ranksep","marginx","marginy"],j={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},S=["acyclicer","ranker","rankdir","align"],_=["width","height"],T={width:0,height:0},L=["minlen","weight","width","height","labeloffset"],A={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},P=["labelpos"];function O(V){var Y=new w({multigraph:!0,compound:!0}),X=Z(V.graph());return Y.setGraph(e.merge({},j,W(X,N),e.pick(X,S))),e.forEach(V.nodes(),function(J){var Q=Z(V.node(J));Y.setNode(J,e.defaults(W(Q,_),T)),Y.setParent(J,V.parent(J))}),e.forEach(V.edges(),function(J){var Q=Z(V.edge(J));Y.setEdge(J,e.merge({},A,W(Q,L),e.pick(Q,P)))}),Y}function U(V){var Y=V.graph();Y.ranksep/=2,e.forEach(V.edges(),function(X){var J=V.edge(X);J.minlen*=2,J.labelpos.toLowerCase()!=="c"&&(Y.rankdir==="TB"||Y.rankdir==="BT"?J.width+=J.labeloffset:J.height+=J.labeloffset)})}function q(V){e.forEach(V.edges(),function(Y){var X=V.edge(Y);if(X.width&&X.height){var J=V.node(Y.v),Q=V.node(Y.w),te={rank:(Q.rank-J.rank)/2+J.rank,e:Y};m.addDummyNode(V,"edge-proxy",te,"_ep")}})}function M(V){var Y=0;e.forEach(V.nodes(),function(X){var J=V.node(X);J.borderTop&&(J.minRank=V.node(J.borderTop).rank,J.maxRank=V.node(J.borderBottom).rank,Y=e.max(Y,J.maxRank))}),V.graph().maxRank=Y}function I(V){e.forEach(V.nodes(),function(Y){var X=V.node(Y);X.dummy==="edge-proxy"&&(V.edge(X.e).labelRank=X.rank,V.removeNode(Y))})}function E(V){var Y=Number.POSITIVE_INFINITY,X=0,J=Number.POSITIVE_INFINITY,Q=0,te=V.graph(),ce=te.marginx||0,ue=te.marginy||0;function ie(re){var fe=re.x,ae=re.y,je=re.width,me=re.height;Y=Math.min(Y,fe-je/2),X=Math.max(X,fe+je/2),J=Math.min(J,ae-me/2),Q=Math.max(Q,ae+me/2)}e.forEach(V.nodes(),function(re){ie(V.node(re))}),e.forEach(V.edges(),function(re){var fe=V.edge(re);e.has(fe,"x")&&ie(fe)}),Y-=ce,J-=ue,e.forEach(V.nodes(),function(re){var fe=V.node(re);fe.x-=Y,fe.y-=J}),e.forEach(V.edges(),function(re){var fe=V.edge(re);e.forEach(fe.points,function(ae){ae.x-=Y,ae.y-=J}),e.has(fe,"x")&&(fe.x-=Y),e.has(fe,"y")&&(fe.y-=J)}),te.width=X-Y+ce,te.height=Q-J+ue}function D(V){e.forEach(V.edges(),function(Y){var X=V.edge(Y),J=V.node(Y.v),Q=V.node(Y.w),te,ce;X.points?(te=X.points[0],ce=X.points[X.points.length-1]):(X.points=[],te=Q,ce=J),X.points.unshift(m.intersectRect(J,te)),X.points.push(m.intersectRect(Q,ce))})}function B(V){e.forEach(V.edges(),function(Y){var X=V.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 H(V){e.forEach(V.edges(),function(Y){var X=V.edge(Y);X.reversed&&X.points.reverse()})}function G(V){e.forEach(V.nodes(),function(Y){if(V.children(Y).length){var X=V.node(Y),J=V.node(X.borderTop),Q=V.node(X.borderBottom),te=V.node(e.last(X.borderLeft)),ce=V.node(e.last(X.borderRight));X.width=Math.abs(ce.x-te.x),X.height=Math.abs(Q.y-J.y),X.x=te.x+X.width/2,X.y=J.y+X.height/2}}),e.forEach(V.nodes(),function(Y){V.node(Y).dummy==="border"&&V.removeNode(Y)})}function z(V){e.forEach(V.edges(),function(Y){if(Y.v===Y.w){var X=V.node(Y.v);X.selfEdges||(X.selfEdges=[]),X.selfEdges.push({e:Y,label:V.edge(Y)}),V.removeEdge(Y)}})}function F(V){var Y=m.buildLayerMatrix(V);e.forEach(Y,function(X){var J=0;e.forEach(X,function(Q,te){var ce=V.node(Q);ce.order=te+J,e.forEach(ce.selfEdges,function(ue){m.addDummyNode(V,"selfedge",{width:ue.label.width,height:ue.label.height,rank:ce.rank,order:te+ ++J,e:ue.e,label:ue.label},"_se")}),delete ce.selfEdges})})}function $(V){e.forEach(V.nodes(),function(Y){var X=V.node(Y);if(X.dummy==="selfedge"){var J=V.node(X.e.v),Q=J.x+J.width/2,te=J.y,ce=X.x-Q,ue=J.height/2;V.setEdge(X.e,X.label),V.removeNode(Y),X.label.points=[{x:Q+2*ce/3,y:te-ue},{x:Q+5*ce/6,y:te-ue},{x:Q+ce,y:te},{x:Q+5*ce/6,y:te+ue},{x:Q+2*ce/3,y:te+ue}],X.label.x=X.x,X.label.y=X.y}})}function W(V,Y){return e.mapValues(e.pick(V,Y),Number)}function Z(V){var Y={};return e.forEach(V,function(X,J){Y[J.toLowerCase()]=X}),Y}return Xk}var Zk,oI;function Mde(){if(oI)return Zk;oI=1;var e=_t(),t=Dn(),n=Js().Graph;Zk={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 Zk}var Jk,iI;function $de(){return iI||(iI=1,Jk="0.8.5"),Jk}var Qk,lI;function Lde(){return lI||(lI=1,Qk={graphlib:Js(),layout:Rde(),debug:Mde(),util:{time:Dn().time,notime:Dn().notime},version:$de()}),Qk}var Ide=Lde();const cI=K1(Ide),uI=e=>{var t;return(t=e.data)==null?void 0:t.parentId};function Ode(e,t,n,s){const a=Pp(e,f=>!t.has(f.id)&&n(f.id)!=null);if(a.size===0)return e;for(const f of a.values())f.sort((p,m)=>p.id.localeCompare(m.id));const o=f=>{var p;return(s==null?void 0:s(f).h)??((p=e.find(m=>m.id===f))==null?void 0:p.height)??Uj},i=new Map(e.map(f=>[f.id,f.position])),c=new Map,d=f=>t.has(f)?void 0:c.get(f)??n(f),h=e.filter(f=>!t.has(f.id)&&!n(f.id)&&a.has(jn(f))).sort((f,p)=>f.position.x-p.position.x||f.position.y-p.position.y);for(const f of h){const p=jn(f),m=uI(f),w=m?d(m):void 0;if(m&&w&&f.type!=="recapNote"){const N={x:w.x-i.get(m).x,y:w.y-i.get(m).y},j={x:f.position.x+N.x,y:f.position.y+N.y};let S=null;for(const _ of e){if(_.id===f.id||_.type==="recapNote"||uI(_)!==m||jn(_)!==p)continue;const T=d(_.id);if(!T||Math.abs(T.x-j.x)>wl||T.x<=w.x)continue;const L=T.y+o(_.id);(!S||L>S.bottom)&&(S={at:T,bottom:L})}if(S){c.set(f.id,{x:S.at.x,y:S.bottom+CP});continue}}const v=a.get(p)[0].id,b=w??n(v),k=i.get(w?m:v);c.set(f.id,{x:f.position.x+b.x-k.x,y:f.position.y+b.y-k.y})}return c.size===0?e:e.map(f=>{const p=c.get(f.id);return p?{...f,position:p}:f})}const e0=e=>e.type==="recapNote";function Pde(e,t,n,s,a,o,i){const c=S=>Xu(S,s,o),d=S=>n.get(S)??t.get(S),h=S=>{const{w:_,h:T}=Eu(S,s);return{cw:_,ch:T}},f=i!=null&&i.width>0&&i.height>0,p=Pp(e,S=>d(S.id)!=null&&!e0(S)),m=new Set;for(const[S,_]of p)_.every(T=>a.has(T.id)&&!n.has(T.id))&&m.add(S);const w=new Map,v=[];for(const S of e){const _=d(S.id);if(!_)continue;const{w:T,h:L}=c(S.id),A=jn(S);m.has(A)?e0(S)||(w.get(A)??w.set(A,[]).get(A)).push(S):v.push({sid:A,x:_.x,y:_.y,w:T,h:L,...h(S.id),note:e0(S)})}if(w.size===0||f&&v.length===0)return[];const b=qf,k=(S,_,T,L)=>v.some(A=>S<A.x+A.w+Z0&&A.x<S+T+Z0&&_<A.y+A.h+b&&A.y<_+L+b),N=TP(e,s),j=[];for(const S of[...w.keys()].sort()){const _=w.get(S);let T=1/0,L=1/0,A=-1/0,P=-1/0,O=-1/0,U=-1/0;for(const F of _){const $=d(F.id),{w:W,h:Z}=c(F.id),{cw:V,ch:Y}=h(F.id);T=Math.min(T,$.x),L=Math.min(L,$.y),A=Math.max(A,$.x+W),P=Math.max(P,$.y+Z),O=Math.max(O,$.x+V),U=Math.max(U,$.y+Y)}const q=P-L,M=_.some(F=>{var $;return(($=F.data)==null?void 0:$.kind)==="root"})?uf+AP:0,I=Math.max(A,O+wl)-T,E=(F,$)=>!k(F-M,$,M+I,q),D=new Map;for(const F of v)F.note||D.set(F.sid,Math.min(D.get(F.sid)??1/0,F.x));const B=[...new Set([...D.values()].map(F=>Math.round(F)))].sort((F,$)=>F-$),H=B.length?B:[T],G=[0,...v.map(F=>F.y+F.h+b)].sort((F,$)=>F-$);let z=null;if(f){let F=1/0,$=1/0,W=-1/0,Z=-1/0;for(const te of v)F=Math.min(F,te.x),$=Math.min($,te.y),W=Math.max(W,te.x+te.cw),Z=Math.max(Z,te.y+te.ch);const V=(te,ce)=>{const ue=i.width/(Math.max(W,te+O-T)-Math.min(F,te-M)+wl),ie=i.height/(Math.max(Z,ce+U-L)-Math.min($,ce));return[Math.min(RP,ue,ie),Math.min(ue,ie),Math.max(ue,ie)]},Y=(te,ce)=>{for(let ue=0;ue<te.length;ue++){if(te[ue]>ce[ue]+1e-9)return!0;if(te[ue]<ce[ue]-1e-9)return!1}return!1},X=Math.round(W+wl+N+M),J=[...new Set([...G,$])].sort((te,ce)=>te-ce);let Q=null;for(const te of[...H,X])for(const ce of J){if(!E(te,ce))continue;const ue=V(te,ce);(Q===null||Y(ue,Q))&&(Q=ue,z={x:te,y:ce})}z&&z.x===T&&z.y===L&&(z=null)}else e:for(const F of H)for(const $ of G){if($>=L)break;if(E(F,$)){z={x:F,y:$};break e}}if(z){const F=z.x-T,$=z.y-L;for(const W of _){const Z=d(W.id);t.set(W.id,{x:Z.x+F,y:Z.y+$})}j.push(S)}for(const F of _){const $=d(F.id),{w:W,h:Z}=c(F.id);v.push({sid:S,x:$.x,y:$.y,w:W,h:Z,...h(F.id),note:!1})}if(M>0){const F=T+(z?z.x-T:0),$=L+(z?z.y-L:0);v.push({sid:S,x:F-M,y:$,w:uf,h:Uf,cw:uf,ch:Uf,note:!0})}}return j}function Dde(e,t,n,s,a,o){const i=m=>Xu(m,s,a),c=new Map(e.map(m=>[m.id,jn(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:v,h:b}=i(m);d.push({x:w.x,y:w.y,w:v,h:b,sid:c.get(m)??"_default"})}const p=[];for(const{id:m,pos:w}of h){if(f(m))continue;const{w:v,h:b}=i(m),k=c.get(m)??"_default";if(n.has(m)){d.push({x:w.x,y:w.y,w:v,h:b,sid:k});continue}let N=w.y;for(let j=0;j<d.length+1;j++){const S=d.find(_=>{const T=_.sid===k?cf:EP,L=_.sid===k?cf:qf;return w.x<_.x+_.w+T&&_.x<w.x+v+T&&N<_.y+_.h+L&&_.y<N+b+L});if(!S)break;N=S.y+S.h+(S.sid===k?cf:qf)}N!==w.y&&(t.set(m,{x:w.x,y:N}),p.push(m)),d.push({x:w.x,y:N,w:v,h:b,sid:k})}return p}function Fde(e,t,n,s,a,o=!1,i){const d=EP+1,h=qf+1,f=8,p=1.75,m=200,w=.7,v=.01,b=M=>Xu(M,s,i),k=M=>n.get(M)??t.get(M),N=Pp(e,M=>k(M.id)!=null),j=[],S=new Set,_=new Set,T=a.size===0;for(const M of[...N.keys()].sort()){const I=N.get(M);let E=1/0,D=1/0,B=-1/0,H=-1/0,G=!1;for(const W of I){const Z=k(W.id),{w:V,h:Y}=b(W.id);E=Math.min(E,Z.x),D=Math.min(D,Z.y),B=Math.max(B,Z.x+V),H=Math.max(H,Z.y+Y),n.has(W.id)&&(G=!0)}const z=B-E,F=H-D;_.add(M);const $=a.get(M);$&&(z>$.w+f||F>$.h+f)&&S.add(M),a.set(M,{w:z,h:F}),j.push({sid:M,members:I.map(W=>W.id),x:E,y:D,w:z,h:F,anchored:G,mass:1})}for(const M of[...a.keys()])_.has(M)||a.delete(M);if(o||T)return[];let L=!1;for(let M=0;M<j.length&&!L;M++)for(let I=M+1;I<j.length;I++){const E=j[M],D=j[I];if(!(E.anchored&&D.anchored)&&Math.abs(E.x+E.w/2-(D.x+D.w/2))<(E.w+D.w)/2+d&&Math.abs(E.y+E.h/2-(D.y+D.h/2))<(E.h+D.h)/2+h){L=!0;break}}if(S.size===0&&!L)return[];if(S.size>0)for(const M of j)S.has(M.sid)&&(M.mass=8);else for(const M of j)M.mass=Math.max(1,M.w*M.h/(Cu*Uj));const A=new Map(j.map(M=>[M.sid,M.x])),P=new Map(j.map(M=>[M.sid,M.y])),O=new Map(j.map(M=>[M.sid,Math.min(0,M.x)])),U=new Map(j.map(M=>[M.sid,Math.min(0,M.y)]));for(let M=0;M<m;M++){const I=new Map,E=new Map;let D=0;for(let B=0;B<j.length;B++)for(let H=B+1;H<j.length;H++){const G=j[B],z=j[H];if(G.anchored&&z.anchored)continue;const F=G.x+G.w/2,$=G.y+G.h/2,W=z.x+z.w/2,Z=z.y+z.h/2,V=(G.w+z.w)/2+d-Math.abs(F-W),Y=(G.h+z.h)/2+h-Math.abs($-Z);if(V<=0||Y<=0)continue;const X=($e,Je)=>!$e.anchored&&!(Je<0&&$e.x<=O.get($e.sid)),J=($e,Je)=>!$e.anchored&&!(Je<0&&$e.y<=U.get($e.sid)),Q=($e,Je,Qe)=>{const ze=$e===Je,Ne=ze?G.sid<z.sid?-1:1:Math.sign($e-Je);return Qe(G,Ne)||Qe(z,-Ne)?Ne:ze&&(Qe(G,-Ne)||Qe(z,Ne))?-Ne:0},te=Q(F,W,X),ce=Q($,Z,J),ue=te!==0,ie=ce!==0;if(!ue&&!ie)continue;const re=ue&&(!ie||V*p<Y),[fe,ae,je,me]=re?[te,V,I,X]:[ce,Y,E,J],pe=me(G,fe),xe=me(z,-fe),_e=G.mass,ye=z.mass,Ie=pe?xe?ye/(_e+ye):1:0,Pe=xe?pe?_e/(_e+ye):1:0,Ue=ae*w;je.set(G.sid,(je.get(G.sid)??0)+fe*Ue*Ie),je.set(z.sid,(je.get(z.sid)??0)-fe*Ue*Pe),D+=Ue}for(const B of j)B.anchored||(B.x=Math.max(O.get(B.sid),B.x+(I.get(B.sid)??0)),B.y=Math.max(U.get(B.sid),B.y+(E.get(B.sid)??0)));if(D<v)break}const q=[];for(const M of j){const I=M.x-A.get(M.sid),E=M.y-P.get(M.sid);if(!(Math.abs(I)<1&&Math.abs(E)<1)){for(const D of M.members){if(n.has(D))continue;const B=t.get(D);B&&t.set(D,{x:B.x+I,y:B.y+E})}q.push(M.sid)}}return q}const E6=160,Bde=40,qde=80;function dI(e,t,n){const s=Eu(e,t),a=Xu(e,t,n),o=a.w-s.w,i=Bde+(t.has(e)?0:qde);return o>0?{w:s.w+Math.max(0,o+i-E6),h:a.h}:a}function Ude(e,t,n,s,a,o){const i=new cI.graphlib.Graph;i.setDefaultEdgeLabel(()=>({})),i.setGraph({rankdir:n,marginx:0,marginy:0,nodesep:CP,ranksep:E6,edgesep:30});const c=e.filter(N=>!a.has(N)),d=new Set(c);for(const N of c){const{w:j,h:S}=dI(N,s,o);i.setNode(N,{width:j,height:S})}for(const N of t)d.has(N.source)&&d.has(N.target)&&i.setEdge(N.source,N.target);cI.layout(i);const h=new Map;let f=1/0,p=1/0,m=-1/0,w=-1/0;for(const N of c){const j=i.node(N);if(!j)continue;const{w:S,h:_}=Eu(N,s),T=dI(N,s,o),L=j.x-T.w/2,A=j.y-T.h/2;h.set(N,{x:L,y:A}),L<f&&(f=L),A<p&&(p=A),L+S>m&&(m=L+S),A+_>w&&(w=A+_)}if(Number.isFinite(f)&&Number.isFinite(p))for(const[N,j]of h)h.set(N,{x:j.x-f,y:j.y-p});const v=Number.isFinite(m)?m-f:0,b=Number.isFinite(w)?w-p:0;let k=null;for(const N of e){const j=a.get(N);if(!j)continue;const{w:S,h:_}=Eu(N,s);k=k===null?{minX:j.x,minY:j.y,maxX:j.x+S,maxY:j.y+_}:{minX:Math.min(k.minX,j.x),minY:Math.min(k.minY,j.y),maxX:Math.max(k.maxX,j.x+S),maxY:Math.max(k.maxY,j.y+_)}}return{positions:h,width:v,height:b,pinnedBox:k}}function T6(e,t,n){const s=n.direction??"LR",a=n.pinned??new Map,o=n.measured??new Map,i=n.lanes,c=Pp(e);return{laid:Array.from(c.keys()).sort().map(f=>({sid:f,...Ude(c.get(f).map(p=>p.id),t,s,o,a,i)})),gap:TP(e,o)}}const A6=e=>e.reduce((t,n)=>Math.max(t,n.width),0)+wl,Wde=e=>e.reduce((t,n)=>t+n.height,0)+yl*Math.max(0,e.length-1);function _1(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+yl;return h},o=[];for(let d=0;d<e.length;d++){let h=-yl;for(let f=d;f<e.length;f++)o.push(h+=e[f].height+yl)}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=>ZX(f.reduce((p,m)=>p+A6(m),0)+t*(f.length-1),Math.max(...f.map(Wde)),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 Hde(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}=T6(e,t,n);return o.length<2?!1:_1(o,i,s.width,s.height).length!==_1(o,i,a.width,a.height).length}function zde(e,t,n={}){const s=n.pinned??new Map,{laid:a,gap:o}=T6(e,t,n),i=_1(a,o,n.availableWidth??0,n.availableHeight??0),c=new Map;let d=0;for(const h of i){const f=A6(h);let p=0;for(const{positions:m,height:w,pinnedBox:v}of h){for(const[k,N]of m)c.set(k,{x:N.x+d,y:N.y+p});let b=p+w;v&&v.maxY>b&&v.minX<d+f&&d<v.maxX&&(b=v.maxY),p=b+yl}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 gf(e,t,n){return!t.has(e)||n.has(e)}function Vde(e,t,n,s){return!t.has(e)&&gf(e,n,s)}function Gde(e,t,n){const s={x:0,y:0};return t.set(e,s),n.add(e),s}function hI(e,t,n,s){n.set(e,t),s.delete(e)}const fI=new WeakMap;function Kde(e,t){let n=fI.get(e);(!n||n.revision!==e.revision||n.open!==t)&&(n={revision:e.revision,open:t,byId:new Map,branches:jG(e.agents.values()),groups:Np(e.agents.values())},fI.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 UN(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 Yde(e,t){const n=i=>jn(i),s=new Map;for(const i of e){const c=n(i),d=i.position.x+(i.width??Cu),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 Xde(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 Zde(e,t,n,s,a,o,i,c,d,h,f,p,m,w,v,b,k,N,j,S){var G,z,F,$;const _=[],T=[],L=Kde(e,N);for(const W of e.agents.values()){if(!k.has(W.id))continue;const Z=W.exitAt!=null,V=b!=null&&!b.has(W.id),Y=[Z?"rf-exiting":"",V?"rf-spotlit-out":"",v.has(W.id)?"rf-selected":""].filter(Boolean).join(" ")||void 0,X=o.get(W.id);if(_.push({id:W.id,type:"agent",position:{x:0,y:0},data:L(W),className:Y,ariaLabel:IV(W,t,v.has(W.id)),...X?{width:X.width,height:X.height}:null}),W.parentId&&k.has(W.parentId)){const ce=ju(W.sessionId),ue=Z,ie=v.size>0&&(v.has(W.id)||v.has(W.parentId)),re=b!=null&&!b.has(W.id)&&!b.has(W.parentId),fe=W.state==="active"?2:1.5,ae=ie?fe+1.5:fe,je=ue?.2:re?.12:1,me=["sess-edge",W.state==="active"?"sess-live":"sess-idle",ue?"rf-edge-exiting":"",ie?"rf-edge-selected":""].filter(Boolean).join(" ");T.push({id:`e:${W.parentId}->${W.id}`,source:W.parentId,target:W.id,animated:(W.state==="active"||ie)&&!ue,type:"smoothstep",style:{"--session-hue":ce,strokeWidth:`calc(${ae}px * var(--edge-k, 1))`,opacity:je,transition:"var(--edge-transition)"},className:me})}const J=W.kind==="root"?H4(W):null,Q=(J==null?void 0:J.note)??null,te=J?J.key:null;if(J&&te&&!fG(te)){const ce=Cj(W.id),ue=ju(W.sessionId),ie=o.get(ce);_.push({id:ce,type:"recapNote",position:{x:0,y:0},data:{sessionId:W.sessionId,canvasSessionId:L(W).canvasSessionId,parentId:W.id,note:Q,plan:J.plan,noteKey:te,hue:ue},className:V?"rf-spotlit-out":void 0,selectable:!1,focusable:!1,ariaLabel:Q?Q.kind==="recap"?`Claude Code's recap for ${W.label}`:`${W.label}: ${Dl(Q.kind)}`:`${W.label}: plan`,...ie?{width:ie.width,height:ie.height}:null}),T.push({id:`e:recap:${W.id}`,source:ce,target:W.id,type:"recapTie",className:"recap-edge",focusable:!1,style:{"--session-hue":ue}})}}const A=UN(e),P=S.size>0&&!(d&&j);P||S.clear();const O=_.filter(W=>W.data.provider==="codex"&&W.data.parentId).map(W=>`${W.id}:${jn(W)}:${W.data.parentId}`).sort().join("|"),U=`${m}${O?`#codex:${O}`:""}#lanes:${eZ(A)}${P?"#held":""}`,q=new Set(_.filter(W=>W.type==="recapNote").map(W=>W.id));for(const W of Array.from(f.keys()))j&&yG(W)&&!q.has(W)&&!a.has(W)&&(f.delete(W),p.delete(W));const M=_.filter(W=>Vde(W.id,a,f,p));if(M.length>0||U!==w.current){if(M.length>0){for(const Z of M)S.delete(Z.id);const W=Ode(zde(_,T,{direction:"LR",pinned:a,measured:o,availableWidth:n,availableHeight:s,lanes:A}),a,Z=>gf(Z,f,p)?void 0:f.get(Z),Z=>Xu(Z,o,A));for(const Z of W)gf(Z.id,f,p)&&hI(Z.id,Z.position,f,p);Pde(_,f,a,o,new Set(M.filter(Z=>Z.type!=="recapNote").map(Z=>Z.id)),A,{width:n,height:s});for(const Z of M){if(Z.type!=="recapNote")continue;const V=(G=Z.data)==null?void 0:G.parentId;if(!V)continue;const Y=a.get(V)??(gf(V,f,p)?void 0:f.get(V));if(!Y)continue;const X=((z=o.get(Z.id))==null?void 0:z.width)??uf,J=((F=o.get(Z.id))==null?void 0:F.height)??Uf,Q=(($=o.get(V))==null?void 0:$.height)??Uf;hI(Z.id,{x:Y.x-AP-X,y:Y.y+(Q-J)/2},f,p)}}Dde(_,f,a,o,A,P?S:void 0),w.current=U}const I=Fde(_,f,a,o,i,!d||h,A);I.length>0&&c(I);const E=mle(e.agents.values());j&&Gh(f,E),Gh(p,E),j&&Gh(a,E),Gh(o,ple(e.agents.values()));const D=[];let B=!1;for(const W of _){let Z=a.get(W.id)??f.get(W.id);Z||(Z=Gde(W.id,f,p),B=!0),D.push({...W,position:Z})}return B&&(w.current=""),{nodes:Yde(D,W=>{if(W.type==="recapNote")return-1;const Z=e.agents.get(W.id);return Z?Xde(e,Z):0}),edges:T}}function Jde(e){return e.slice().sort((t,n)=>t.y-n.y||t.x-n.x)}function Qde(e,t,n){var i;if(e.length===0)return null;const s=Jde(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 ehe=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Escape","Backspace"]);function the(e,t){return t==null?{kind:"deck",nodeId:null}:e.key==="Enter"||e.key===" "?{kind:"activate",nodeId:t,additive:e.shiftKey}:ehe.has(e.key)?{kind:"node",nodeId:t}:{kind:"deck",nodeId:t}}const nhe=new Set(["","BODY","HTML","#DOCUMENT"]);function she(e){return!e||Ho(e)?!1:!nhe.has(String(e.tagName??"").toUpperCase())}const R6="react-flow__node";function WN(e){var t,n;return!!e&&((n=(t=e.classList)==null?void 0:t.contains)==null?void 0:n.call(t,R6))===!0}function M6(e){try{const t=document.querySelector(`.${R6}[data-id="${CSS.escape(e)}"]`);t==null||t.focus({preventScroll:!0})}catch{}}let Go=null,cl=null;const C1=new Set,E1=()=>{for(const e of C1)e()},rhe=e=>(C1.add(e),()=>{C1.delete(e)}),pI=()=>Go,ahe=90;function $6(e){!cl||e!=null&&cl.at.id!==e||(clearTimeout(cl.timer),cl=null)}function L6(e,t,n="pointer"){$6();const s={id:e,anchor:t,by:n};if(Go||n==="focus"){Go=s,E1();return}cl={at:s,timer:setTimeout(()=>{cl=null,Go=s,E1()},ahe)}}function ro(e){$6(e),!(!Go||e!=null&&Go.id!==e)&&(Go=null,E1())}function ohe({agentFor:e,recapFor:t,labelFor:n,bounds:s}){const a=y.useSyncExternalStore(rhe,pI,pI),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&&ro(a.id)},[c,a]),!a||c?null:o?r.jsx(lhe,{a:o,anchor:a.anchor,parentLabel:o.parentId?n(o.parentId):void 0,bounds:s},a.id):i?r.jsx(ihe,{r:i,anchor:a.anchor,bounds:s},a.id):null}function I6(e,t){const n=y.useRef(null),s=y.useCallback(()=>{const a=n.current;if(!a||!e.isConnected)return;a.style.maxHeight="";const o=sN(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 ihe({r:e,anchor:t,bounds:n}){var h;const s=I6(t,n),a=Cr(3e4),o=e.note,i=_r(e.plan),c=(o==null?void 0:o.kind)==="recap",d=Lf((o==null?void 0:o.at)??((h=e.plan)==null?void 0:h.at)??a,a);return xt.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(Mf,{recap:c}),o?Dl(o.kind):"plan"]}),r.jsx("span",{className:"node-peek-time",title:d.title,children:d.label})]}),e.sessionLabel&&r.jsx("div",{className:"node-peek-kind",children:r.jsxs("span",{children:[o?`${Mp(o)} · `:"",e.sessionLabel]})}),o&&r.jsx("p",{className:"recap-peek-text",children:o.text}),(o==null?void 0:o.reply)&&r.jsxs("p",{className:"recap-peek-text",children:["Suggested reply: “",o.reply,"”"]}),i&&e.plan&&r.jsxs("p",{className:"recap-peek-text recap-peek-plan",children:["Plan ",xj(i),i.allDone?"":`
105
+ ${jp(e.plan.items)}`]}),r.jsx("p",{className:"node-peek-hint",children:"Click to go to the session · double-click for its details"})]}),document.body)}function lhe({a:e,anchor:t,parentLabel:n,bounds:s}){const a=I6(t,s),o=Cr(1e3),i=Ap(e.sessionName,e.sessionTitle),c=e.toolErrorCount??0,d=e.tools.filter(b=>!b.endedAt).length,h=Fn(e,o).total,f=e.usage.inputTokens+e.usage.outputTokens,p=e.kind==="root"&&In(e.waiting),m=T4(e),w=e.kind==="root"?"session":n?`subagent of ${n}`:"subagent",v=[`${e.toolCount} ${e.toolCount===1?"tool":"tools"}`,d>0?`${d} in-flight`:null,f>0?`${wt(f)} tok`:null,h>0?`${st(h)}${Cl(e,o)>0?"+":""}`:null].filter(Boolean).join(" · ");return xt.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?"≥ ":"",Al(e.startedAt,e.endedAt,o)]})]}),r.jsxs("div",{className:"node-peek-kind",children:[r.jsxs("span",{className:"node-peek-state","data-kind":F0(ml(e)),children:[r.jsx(J4,{kind:F0(ml(e))}),El(ml(e))]}),r.jsx("span",{children:w}),e.model?r.jsx("span",{children:Cp(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(Rj,{}),r.jsxs("span",{className:"node-peek-said",title:Af(e.waiting),children:[r.jsx("span",{className:"node-peek-since",children:r.jsx("b",{children:Al(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:[v,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:z4(e.branch)}),r.jsx("p",{className:"node-peek-hint",children:"Click to go to the session · double-click for details"})]}),document.body)}function che(e){const t=e.minZoom??xie,n=e.maxZoom??vie,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,v,b,k,N,j)=>{let S=w+(v-k*p)/2-b*p;const _=N*p+S,T=(N+j)*p+S;return j*p<=v?_<w?S+=w-_:T>w+v&&(S-=T-(w+v)):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 uhe(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 Ln(e){const t=y.useRef(e);return t.current=e,t}const T1=80,A1=.86;function O6(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 dhe({canvasRef:e,canvasSize:t,machinePhase:n,usagePhase:s,usagePanelOpen:a,detailShown:o}){const[i,c]=y.useState(0);y.useEffect(()=>{const p=O6(e.current);c(m=>Math.abs(m-p)>40?p:m)},[n,s,a,o,t.w]);const d=Ln(i),h=t.w>0?Math.max(0,(t.w-i-T1*2)*A1):0,f=t.h>0?Math.max(0,(t.h-T1*2)*A1):0;return{railInsetRef:d,availableWidth:h,availableHeight:f}}const mI=1e-6;function fu(e){return Number.isFinite(e[0])&&Number.isFinite(e[1])&&Number.isFinite(e[2])&&e[2]>0}function gI(e,t,n){return Math.abs(e[2]-t[2])<=mI*t[2]&&Math.hypot(e[0]-t[0],e[1]-t[1])<=mI*n}function hhe(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 fhe(e,t,n){const s=e(0),a=e(.5),o=e(1);if(!fu(s)||!fu(a)||!fu(o))return!1;const i=Math.max(t[2],n[2]);return gI(s,t,i)&&gI(o,n,i)}function phe(e){return(t,n)=>{const s=e(t,n),a=fhe(s,t,n)?s:hhe(t,n);let o=fu(t)?t:n;return i=>{const c=a(i);return fu(c)&&(o=c),o}}}function mhe(e){return Number.isFinite(e.x)&&Number.isFinite(e.y)&&Number.isFinite(e.zoom)&&e.zoom>0}const yI=new WeakSet,P6=420;function ghe(){const e=Ll(),t=Pt(),n=y.useCallback((h,f)=>{if(!mhe(h))return;if($0({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||yI.has(f)||(yI.add(f),f.interpolate(phe(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=$0({durationMs:f,documentHidden:document.hidden})?{target:h,until:Date.now()+f+60}:null,p},[n]),c=y.useCallback((h=500)=>{const f=T1,p=1,m=.2,w=A1;try{const v=document.querySelector(".canvas-wrap"),b=Array.from(document.querySelectorAll(".react-flow__node")).filter(D=>D.offsetWidth>0);if(!v||b.length===0)return;const k=v.getBoundingClientRect(),N=e.getViewport();if(!Number.isFinite(N.zoom)||N.zoom<=0)return;const j=new Map(e.getNodes().map(D=>[D.id,D])),S=b.flatMap(D=>{const B=j.get(D.dataset.id??"");if(!B)return[];const H=B.positionAbsolute??B.position,G=B.width??D.offsetWidth,z=B.height??D.offsetHeight;return G>0&&z>0?[{left:H.x,right:H.x+G,top:H.y,bottom:H.y+z}]:[]});if(S.length===0)return;const _=Math.min(...S.map(D=>D.left)),T=Math.max(...S.map(D=>D.right)),L=Math.min(...S.map(D=>D.top)),A=Math.max(...S.map(D=>D.bottom)),P=T-_,O=A-L;if(!(P>0&&O>0))return;const U=O6(v),q=D=>Math.max(m,Math.min(p,(k.width-U-f*2)/(P+D)*w,(k.height-f*2)/O*w)),M=wie(q(P6),q(0),y5(Hj[zj()])),I={x:f-_*M,y:(k.height>k.width-U?f:Math.max(f,(k.height-O*M)/2))-L*M,zoom:M},E=i(I,h);window.setTimeout(()=>{var D;try{if(((D=s.current)==null?void 0:D.target)===I&&(s.current=null),a.current!==E)return;const B=e.getViewport();(Math.abs(B.zoom-M)>.01||Math.abs(B.x-I.x)>2||Math.abs(B.y-I.y)>2)&&n(I,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 yhe=450;function whe({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(v=>{const b=e.current,k=t.current.agents.get(v);if(!b||!k)return;const N=UN(t.current),j=(P,O)=>{const U=n.current.get(P.id);if(!U)return null;const q=O&&N.has(P.id)?P6:0;return{x:P.position.x,y:P.position.y,width:U.width+q,height:U.height}},S=s.current.find(P=>P.id===v),_=S?j(S,!1):null;if(!_)return;const T=[];for(const P of s.current){if(P.type!=="agent"&&P.type!=="recapNote"||jn(P)!==jn(S))continue;const O=j(P,P.type==="agent");O&&T.push(O)}const L=b.getBoundingClientRect(),A=che({pane:{width:L.width,height:L.height},insets:{top:56,left:72,bottom:32,right:a.current+32},context:uhe(T)??_,anchor:_});ro(),i(),c.current={id:v,at:Date.now()},o(A,yhe)},[o,i]);d.current=p;const m=y.useCallback(v=>{const b=s.current.filter(S=>S.type==="agent"),k=Qde(b.map(S=>({id:S.id,x:S.position.x,y:S.position.y})),f.current,v),N=k?b.find(S=>S.id===k):void 0;if(!N)return;const j=WN(document.activeElement);h(N.id,!1),window.setTimeout(()=>{try{p(N.id)}catch{}j&&M6(N.id)},30)},[h,p]),w=y.useCallback(v=>{h(v,!1),window.setTimeout(()=>{try{p(v)}catch{}},60)},[h,p]);return{focusAgent:p,stepAgent:m,focusSession:w}}function xhe({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,plan:f.plan,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 vhe(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 wI(e){return Object.entries(e??{}).filter(([,t])=>t&&typeof t.x=="number"&&typeof t.y=="number")}function bhe(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=wI(n);return{positions:a,pins:a.map(([o])=>o)}}const s=n;return{positions:wI(s.positions),pins:Array.isArray(s.pins)?s.pins:[]}}function khe(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 jhe(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 rd="agent-dag.layout",ad="agent-dag.layoutFrame",od="agent-dag.viewport";function Nhe(){return bhe(Ke(rd))}function bl(e,t){Ze(rd,khe(e,t))}function She(){return jhe(Ke(ad))}function D6(e){Ze(ad,JSON.stringify(e))}function _he(){return Az(Ke(od))}function Che(e){Ze(od,JSON.stringify(e))}function Ehe(){return{layout:Ke(rd),frame:Ke(ad),viewport:Ke(od)}}function The(e){const t=(n,s)=>s===null?Ys(n):Ze(n,s);t(rd,e.layout),t(ad,e.frame),t(od,e.viewport)}function F6(){Ys(rd),Ys(od),Ys(ad)}function Ahe({fitLeft:e,moveCamera:t,currentViewport:n}){const s=y.useState(()=>vhe(Nhe()))[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(She)[0],p=y.useRef(f),[m,w]=y.useState(!1),[v,b]=y.useState(""),k=y.useState(()=>UX(O=>{w(O),O||b(U=>U===fT?U:"")}))[0];y.useEffect(()=>()=>k.close(),[k]),y.useEffect(()=>{if(typeof document>"u")return;const O=()=>document.hidden?k.hold("hidden"):k.release("hidden");return document.addEventListener("visibilitychange",O),()=>document.removeEventListener("visibilitychange",O)},[k]);const N=y.useRef(null),j=()=>({positions:o.current,pinned:a.current,provisional:i.current,layoutSig:c}),S=y.useCallback(()=>{k.open(k.snapshot??IX(j(),Ehe(),n())),b(BX),a.current.clear(),o.current.clear(),c.current="",F6(),h(O=>O+1),N.current!=null&&window.clearTimeout(N.current),N.current=window.setTimeout(()=>{N.current=null,bl(o.current,a.current),p.current&&D6(p.current),e(500)},80)},[e,n,k]),_=y.useCallback(()=>{const O=k.take();return O?(N.current!=null&&window.clearTimeout(N.current),N.current=null,OX(O,j()),The(O.stored),h(U=>U+1),O.viewport&&t(O.viewport,500),b(fT),!0):!1},[t,k]),T=y.useCallback(()=>k.close(),[k]),L=y.useCallback(O=>k.hold(O),[k]),A=y.useCallback(O=>k.release(O),[k]);return{restoredLayout:s,pinnedRef:a,positionsRef:o,provisionalRef:i,lastLayoutSigRef:c,layoutEpoch:d,setLayoutEpoch:h,lastLayoutFrameRef:p,handleRelayout:S,rearrangeUndo:{open:m,said:v,undo:_,dismiss:T,hold:L,release:A}}}function Rhe(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(()=>{bl(n.current,s.current)},1500),()=>{a.current!=null&&window.clearTimeout(a.current)}),[e])}function Mhe({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:v}){const{lastLayoutFrameRef:b,pinnedRef:k,positionsRef:N,provisionalRef:j,lastLayoutSigRef:S,setLayoutEpoch:_}=i,{applyViewport:T,fitLeft:L,cameraEpochRef:A,lastFitTimeRef:P}=c;y.useEffect(()=>{if(!n||s)return;const O={width:a,height:o};if(!(O.width>0&&O.height>0))return;const U=b.current;if(b.current=O,D6(O),!U||U.width===O.width&&U.height===O.height)return;const q={direction:"LR",pinned:k.current,measured:h.current,lanes:UN(f.current)},M=p.current&&Date.now()-p.current.at<1500?p.current.id:null;if(!Hde(e,t,q,U,O)){const D=A.current,B=window.setTimeout(()=>{var H;A.current===D&&(v.current?M&&((H=p.current)==null?void 0:H.id)===M&&w.current(M):L(500))},80);return()=>window.clearTimeout(B)}const I=M??m.current,E=I?k.current.get(I)??N.current.get(I):void 0;for(const D of Array.from(N.current.keys()))k.current.has(D)||N.current.delete(D);j.current.clear(),S.current="",_(D=>D+1),window.setTimeout(()=>{if(bl(N.current,k.current),v.current){if(M){w.current(M);return}const D=I?k.current.get(I)??N.current.get(I):void 0;if(E&&D&&(D.x!==E.x||D.y!==E.y)){const B=d.getViewport();A.current+=1,T({x:B.x-(D.x-E.x)*B.zoom,y:B.y-(D.y-E.y)*B.zoom,zoom:B.zoom},0),P.current=Date.now()}return}L(500)},80)},[a,o,n,s,L,d,T])}function $he(e,t,n,s,a){const o=[];for(const i of e)!Dp(i,t)||n.has(i.id)||o.push(i.id+(i.parentId?`>${i.parentId}`:""));return o.sort(),`${o.join("|")}#sv${s}.${a}`}const HN="agent-dag.removedNodes";function Lhe(e){try{const t=JSON.parse((e==null?void 0:e.getItem(HN))??"[]");return new Set(Array.isArray(t)?t.filter(n=>typeof n=="string"):[])}catch{return new Set}}function t0(e,t){try{e==null||e.setItem(HN,JSON.stringify([...t]))}catch{}}function B6(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 Ihe(e,t){if(t.size===0)return new Set;const n=[...e],s=B6(n,t);return new Set(n.filter(s).map(a=>a.id))}function Ohe(e,t,n){const s=c=>({id:c.id,parentId:c.data.parentId,sessionId:c.data.sessionId}),a=B6(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 Phe(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 Dhe(e,t){return t.size===0?[]:[...e].filter(n=>t.has(n.id)).map(n=>n.id)}function Fhe(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 Bhe(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 qhe(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=Fhe(c);if(d<=a)continue;const h=[],f=new Set,p=w=>{var v;for(let b=w;b&&!f.has(b);b=(v=e.get(b))==null?void 0:v.parentId)f.add(b),n.has(b)&&h.push(b)};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 ip="sessionGroup";function Uhe(e,t){var s,a;if(e.type===ip)return"transparent";if(In((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 Kh=Bo;function Whe(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(jn(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(jn(s),{minX:c,minY:d,maxX:h,maxY:f})}const n=[];for(const[s,a]of t){const o=a.maxX-a.minX+Kh*2,i=a.maxY-a.minY+Kh*2;n.push({id:`group:${s}`,type:ip,position:{x:a.minX-Kh,y:a.minY-Kh},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 Hhe(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 zhe(e,t){const n=new Set;for(const s of t){const a=Hhe(e,s);if(a)for(const o of a)n.add(o)}return n.size>0?n:null}function Vhe({stateRef:e,now:t,removedAgentIds:n,sizeVersion:s,domSizeVersion:a}){return y.useMemo(()=>$he(e.current.agents.values(),t,n,s,a),[e.current,e.current.revision,t,s,a,n])}function Ghe({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:v,dragTick:b,dragPatchRef:k,dragMoveTick:N}){const{pinnedRef:j,positionsRef:S,provisionalRef:_,lastLayoutSigRef:T,restoredLayout:L,layoutEpoch:A}=a,P=y.useMemo(()=>zhe(e.current,f),[e.current,e.current.revision,f]),O=y.useMemo(()=>{const B=YZ(e.current,t);for(const H of v)B.delete(H);return B},[e.current,e.current.revision,t,v]),U=y.useRef(new Map),q=wG(),{nodes:M,edges:I}=y.useMemo(()=>{const B=Zde(e.current,t,n,s,j.current,o.current,U.current,i,c,d,S.current,_.current,h,T,f,P,O,p,m,L.restored);return Ohe(B.nodes,B.edges,w)},[e.current,e.current.revision,t,n,s,c,d,h,f,P,O,p,b,q,w,A,m]),E=y.useMemo(()=>Whe(M),[M]),D=y.useMemo(()=>{const B=[...E,...M],H=k.current;return!H||H.size===0?B:B.map(G=>{const z=H.get(G.id);return z?{...G,position:z}:G})},[E,M,N]);return{spotlightSet:P,visibleAgentIds:O,nodes:M,edges:I,allNodes:D}}function Khe(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 Yhe({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,Khe(a,t,e))return!1;return s}function Xhe({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 v=n.current,b=Date.now(),k=[];for(const j of v.agents.values())Dp(j,b)&&k.push({id:j.id});if(k.length===0)return;const N=[];for(const{id:j}of k){const S=s.current.get(j),_=a.current.get(j)??o.current.get(j);!S||!_||N.push({x:_.x,y:_.y,width:S.width,height:S.height})}Yhe({pane:i.current,viewport:t.getViewport(),boxes:N})&&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 Zhe({stateRef:e,pinnedRef:t,positionsRef:n,canvasRef:s,clearSelection:a,primarySelectedId:o}){const[i,c]=y.useState(()=>Lhe(wr())),[d,h]=y.useState(null),f=y.useMemo(()=>Ihe(e.current.agents.values(),i),[e.current,e.current.revision,i]),p=y.useCallback(j=>{const S=e.current.agents.get(j);S&&(c(_=>{const T=new Set(_);return T.add(j),t0(wr(),T),T}),h({id:j,label:S.label}),t.current.delete(j),n.current.delete(j),a())},[a]),m=y.useCallback(()=>{o&&p(o)},[o,p]),w=d&&i.has(d.id)?d:null;y.useEffect(()=>{var j;d&&((j=s.current)==null||j.focus())},[d]);const v=y.useCallback(j=>{const S=[...j];c(_=>{let T=null;for(const L of S)_.has(L)||(T??(T=new Set(_)),T.add(L));return T?(t0(wr(),T),T):_});for(const _ of S)t.current.delete(_),n.current.delete(_)},[]),b=y.useCallback(j=>{const S=[...j];c(_=>{const T=Phe(_,S);return T!==_&&t0(wr(),T),T})},[]),k=y.useCallback(()=>{b([...i]),h(null)},[b,i]),N=y.useCallback(()=>{c(new Set),h(null),Ys(HN)},[]);return{removedNodes:i,lastRemoval:d,removedAgentIds:f,removeNode:p,removeSelectedNode:m,removalNotice:w,hideSessions:v,bringBack:b,bringBackAll:k,forgetRemovals:N}}function Jhe({stateRef:e,waitingSessions:t,removedAgentIds:n,removedNodes:s,bringBack:a}){const o=y.useRef(new Map);y.useEffect(()=>{o.current=Bhe(o.current,s,Date.now());const i=[...Dhe(t,n),...qhe(e.current.agents,n,s,o.current)];i.length>0&&a(i)},[t,n,s,a])}const q6=[0,5,15,30,60],zN="agent-dag.hide-finished-after",U6="agent-dag.hide-finished-turns",Qhe=300,efe=1e4;function VN(e){const t=Number(e);return q6.includes(t)?t:0}function tfe(e){return e===0?"Never":`${e} min`}let Ko=null;const nu=new Set;function W6(){for(const e of nu)e()}function xI(){return Ko===null&&(Ko=VN(Ke(zN))),Ko}function nfe(e){const t=VN(String(e));Ko!==t&&(Ko=t,Ze(zN,String(t)),W6())}function vI(e){if(e.key!==zN)return;const t=VN(e.newValue);t!==Ko&&(Ko=t,W6())}function sfe(e){var t;return nu.add(e),nu.size===1&&typeof window<"u"&&((t=window.addEventListener)==null||t.call(window,"storage",vI)),()=>{var n;nu.delete(e),nu.size===0&&typeof window<"u"&&((n=window.removeEventListener)==null||n.call(window,"storage",vI))}}function rfe(e){try{const t=JSON.parse((e==null?void 0:e.getItem(U6))??"{}");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 bI(e,t){const n=[...t].sort((s,a)=>a[1]-s[1]).slice(0,Qhe);try{e==null||e.setItem(U6,JSON.stringify(Object.fromEntries(n)))}catch{}}function H6(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"&&In(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 afe(e,{afterMs:t,now:n,removed:s,handled:a,keep:o}){if(t<=0)return[];const i=[];for(const[c,d]of H6(e))n-d<t||s.has(c)||c===o||a.get(c)!==d&&i.push({id:c,endedAt:d});return i}function ofe(e,t,n,s){const a=[...t].filter(c=>!n.has(c));if(a.length===0)return e;const o=H6(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 z6(){return y.useSyncExternalStore(sfe,xI,xI)}function ife({stateRef:e,removedNodes:t,hideSessions:n,keepSessionId:s,ready:a}){const o=z6(),[i]=y.useState(()=>rfe(wr())),c=y.useRef(i),d=y.useRef(t);y.useEffect(()=>{const h=ofe(c.current,d.current,t,e.current.agents.values());d.current=t,h!==c.current&&(c.current=h,bI(wr(),h))},[t]),y.useEffect(()=>{if(!a||o===0)return;const h=()=>{const p=afe(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:v}of p)m.set(w,v);c.current=m,bI(wr(),m),n(p.map(w=>w.id))};h();const f=window.setInterval(h,efe);return()=>window.clearInterval(f)},[a,o,t,s,n])}function lfe({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 V6=Object.freeze({offline:"/state/favicon-error.svg",waiting:"/state/favicon-waiting.svg",running:"/state/favicon-syncing.svg",idle:"/favicon.svg"}),G6=Object.freeze({offline:"/state/favicon-error-32.png",waiting:"/state/favicon-waiting-32.png",running:"/state/favicon-syncing-32.png",idle:"/favicon.ico"}),cfe=Object.freeze([...new Set([...Object.values(V6),...Object.values(G6)])]),R1=new Map;function kI(e){return R1.get(e)??e}async function ufe(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,${dfe(new Uint8Array(await s.arrayBuffer()))}`)}catch{}}))}function dfe(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function hfe({stateRef:e,waitingSessions:t,live:n}){const s=y.useMemo(()=>vV(e.current.agents.values()),[e.current,e.current.revision]),a=y.useRef(null);y.useEffect(()=>{n&&ufe(cfe)},[n]),y.useEffect(()=>{const o=lfe({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&&K6(o.icon)},[t.length,s,n])}function K6(e){const t=document.querySelector('link[rel="icon"][type="image/svg+xml"]');t&&(t.href=kI(V6[e]));const n=document.querySelector('link[rel="icon"][sizes="32x32"]');n&&(n.href=kI(G6[e]))}const ffe=1200,pfe=1e3;function n0(e){return e.lastDeckFitAt>0&&e.at-e.lastDeckFitAt<ffe?!1:e.hasSourceEvent?!0:e.lastCanvasInputAt>0&&e.at-e.lastCanvasInputAt<pfe}function mfe({applyViewport:e,lastFitTimeRef:t,cameraEpochRef:n,disableAutoFit:s,markInteract:a,canvasRef:o,applyZoom:i}){const c=y.useState(()=>_he())[0];y.useEffect(()=>{if(!c)return;const v=window.setTimeout(()=>{try{e(c,0)}catch{}t.current=Date.now()},60);return()=>window.clearTimeout(v)},[e,c]);const d=y.useRef(null),h=y.useRef(0),f=y.useCallback(()=>{h.current=Date.now()},[]),p=y.useCallback(v=>({hasSourceEvent:!!v,at:Date.now(),lastDeckFitAt:t.current,lastCanvasInputAt:h.current}),[]);return{restoredViewport:c,markCanvasInput:f,onMoveStart:v=>{ro(),n0(p(v))&&(n.current+=1),n0(p(v))&&s()},onMove:(v,b)=>{var k;a(),n0(p(v))&&s(),(k=o.current)==null||k.style.setProperty("--zoom",String(b.zoom)),i(b.zoom)==="detail"&&ro(),d.current&&window.clearTimeout(d.current),d.current=window.setTimeout(()=>Che(b),250)}}}function gfe({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(()=>LP({focus:b=>d.current(b),setTimeout:(b,k)=>window.setTimeout(b,k),clearTimeout:b=>window.clearTimeout(b)}));return y.useEffect(()=>()=>h.cancel(),[h]),{onNodeClick:(b,k)=>{if(k.type==="sessionGroup"){h.cancel(),e();return}const N=k.type==="recapNote"?k.data.parentId:k.id;t(N,b.shiftKey,!1),!b.shiftKey&&(n&&s(!1),Hu()?h.hold(N):a?window.setTimeout(()=>{try{o(N)}catch{}},80):o(N))},onPaneClick:()=>{h.cancel(),ro(),e()},onNodeDoubleClick:(b,k)=>{if(k.type!=="agent"&&k.type!=="recapNote")return;h.cancel();const N=k.type==="recapNote"?k.data.parentId:k.id;t(N,!1),window.setTimeout(()=>{try{o(N)}catch{}},80)},onNodeMouseEnter:(b,k)=>{k.type!=="agent"&&k.type!=="recapNote"||i.current||c.current==null||c.current==="detail"||L6(k.id,b.currentTarget)},onNodeMouseLeave:(b,k)=>ro(k.id)}}function yfe({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 wfe(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=yfe({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 xfe(e){const t=Pt(),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 v of t.getState().nodeInternals.values()){if(v.type===ip)continue;const b=v.width,k=v.height;if(b==null||k==null)continue;const N=a.current.get(v.id);(!N||Math.abs(N.width-b)>4||Math.abs(N.height-k)>4)&&(a.current.set(v.id,{width:b,height:k}),n.current.set(v.id,{width:b,height:k}),m=!0)}if(m&&(s.current+=1,i(s.current)),e.current)return;let w=!1;for(const v of document.querySelectorAll(".react-flow__node[data-id]")){if(v.classList.contains(`react-flow__node-${ip}`))continue;const b=v.getAttribute("data-id");if(!b)continue;const k=v.offsetWidth,N=v.offsetHeight;if(!k||!N)continue;const j=n.current.get(b);(!j||Math.abs(j.width-k)>4||Math.abs(j.height-N)>4)&&(n.current.set(b,{width:k,height:N}),w=!0)}w&&d(v=>v+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 vfe(){const[e,t]=y.useState(!1);return y.useEffect(()=>{const n=window.setTimeout(()=>t(!0),2500);return()=>window.clearTimeout(n)},[]),e}function bfe(){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 lp=[{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:"integrations",label:"Integrations",note:"Where the deck reads your work from: Jira, GitHub and GitLab. Read only."},{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 kfe(e,t){return e!=="none"||t==="integrations"?lp:lp.filter(n=>n.id!=="integrations")}const jI="settings-tab-";function jfe(e,t){return e!=null&&e.startsWith(jI)?e===`${jI}${t}`?null:t:null}const Nfe={open:!1,section:"general"};function Sfe(e,t){return{open:!0,section:t??e.section}}function Ua(e,t){return()=>{e(),t()}}function _fe(e){return e.key===","&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey}function Cfe(e){return Yu(e)?"⌘,":"Ctrl+,"}function Efe(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 id={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"}},Qr=Object.keys(id);function M1(e){return Qr[(Qr.indexOf(e)+1)%Qr.length]}const Y6="agent-dag.theme";function Tfe(e,t=!1){return typeof e=="string"&&Object.hasOwn(id,e)?e:"rider-black"}function Afe(){return Tfe(Ke(Y6))}function Rfe({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:v,focusSession:b,requestClear:k,handleRelayout:N,undoRearrange:j,handleFit:S,togglePause:_,toggleSessionList:T,toggleAccountsPanel:L,setDetailOpen:A,setUsageHistoryOpen:P,setUsagePanelOpen:O,setMachinePanelOpen:U,setBrowserWatchOpen:q,setKeyHelpOpen:M,setTheme:I,openSettings:E,openIntegrationRef:D}){y.useEffect(()=>{const B=H=>{var Z,V;const G=H.target,z={tagName:G==null?void 0:G.tagName,isContentEditable:G==null?void 0:G.isContentEditable,role:(Z=G==null?void 0:G.getAttribute)==null?void 0:Z.call(G,"role"),type:G==null?void 0:G.type,pointerFocused:G!=null&&G===e.current};if(H.key==="Escape"){const Y=UV({overlayOpen:vn.depth()>0,typing:Ho(z)});Y==="dismiss"?vn.dismissTop():Y==="blur"?G==null||G.blur():(she(z)&&(G==null||G.blur()),p());return}if(H.key===","&&_fe(H)){if(Ho(z)||af({appModal:c.current,dialogDepth:vn.dialogDepth()}))return;H.preventDefault(),H.repeat||E();return}if(WX(H)){if(Ho(z)||af({appModal:c.current,dialogDepth:vn.dialogDepth()}))return;!H.repeat&&j()&&H.preventDefault();return}if(Rp(H))return;const F=WN(G)?(V=G==null?void 0:G.getAttribute)==null?void 0:V.call(G,"data-id"):null,$=F&&t.current.some(Y=>Y.id===F)?F:null,W=the(H,$);if(W.kind==="activate"){H.preventDefault(),m(W.nodeId,W.additive);return}if(W.kind!=="node"&&!uP(H.key,H0())){if(JV({key:H.key,sheetOpen:i.current,target:z})){H.repeat||M(!1);return}if(!(W.nodeId==null&&XV(z,H.key))&&!ZV({key:H.key,modalOpen:af({appModal:c.current,dialogDepth:vn.dialogDepth()}),sheetOpen:i.current})&&!(H.repeat&&!/^[ jkJK]$/.test(H.key))){if(H.key===" "&&(H.preventDefault(),H.repeat||_()),(H.key==="c"||H.key==="C")&&k("shortcut"),(H.key==="r"||H.key==="R")&&N(),(H.key==="f"||H.key==="F")&&S(),(H.key==="z"||H.key==="Z")&&s.current&&w(s.current),H.key==="Delete"&&h.current(),(H.key==="l"||H.key==="L")&&T(),H.key==="d"||H.key==="D")if(s.current)A(Y=>!Y);else{const Y=P0(n.current.agents.values());Y.length>0?b(Y[0].id):v(1)}if((H.key==="h"||H.key==="H")&&P(Y=>!Y),(H.key==="u"||H.key==="U")&&O(Y=>!Y),(H.key==="a"||H.key==="A")&&a.current.claude&&L(),(H.key==="j"||H.key==="J")&&v(1),(H.key==="k"||H.key==="K")&&v(-1),H.key==="w"||H.key==="W"){const Y=xV(P0(n.current.agents.values()),d.current);Y&&(d.current=Y.id,b(Y.id))}(H.key==="t"||H.key==="T")&&I(M1),(H.key==="m"||H.key==="M")&&o.current!==null&&f.current(H.shiftKey),(H.key==="s"||H.key==="S")&&U(Y=>!Y),(H.key==="b"||H.key==="B")&&q(Y=>!Y),(H.key==="v"||H.key==="V")&&E("sounds"),(H.key==="i"||H.key==="I")&&(D==null||D.current("jira")),H.key==="?"&&M(Y=>!Y)}}};return window.addEventListener("keydown",B),()=>window.removeEventListener("keydown",B)},[k,N,j,S,p,m,v,b,w,_])}function Mfe(){var e,t;return((t=(e=document.activeElement)==null?void 0:e.matches)==null?void 0:t.call(e,":focus-visible"))===!0}function $fe({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=>()=>{Mfe()&&h()};return{toggles:c,sessionList:d(Jr(!e,c.sessionList)),usage:d(Jr(!t,c.usage)),machine:d(Jr(!n,c.machine)),accounts:d(Jr(!s,c.accounts)),detail:d(Jr(!a,()=>{var h,f;o&&M6(o),Bn(((h=document.activeElement)==null?void 0:h.tagName)??null)&&((f=i.current)==null||f.focus({preventScroll:!0}))}))}}function Lfe({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:v,removeNode:b}){const k=y.useRef(null);return{onNodeDragStart:(_,T)=>{var L,A;if(T){if(ro(),h(),a.current=!0,o.current=new Map,i(!0),f(),p(),T.type==="sessionGroup"){const P=(L=T.data)==null?void 0:L.sessionId,O=new Map,U=new Map;if(P)for(const M of e)!M.data||jn(M)!==P||(O.set(M.id,{x:M.position.x,y:M.position.y}),U.set(M.id,n.current.get(M.id)));k.current={sessionId:P,start:{x:T.position.x,y:T.position.y},members:O,pinsBefore:U};const q=P?t.current.agents.get(P):void 0;m(q?q.label:null);return}m(T.type==="agent"?((A=t.current.agents.get(T.id))==null?void 0:A.label)??"":null),n.current.set(T.id,{x:T.position.x,y:T.position.y})}},onNodeDrag:(_,T)=>{var L;if(T){if(f(),(T.type==="agent"||T.type==="sessionGroup")&&w(_),T.type==="sessionGroup"){const A=k.current;if(!A)return;const P=T.position.x-A.start.x,O=T.position.y-A.start.y;for(const[q,M]of A.members){const I={x:M.x+P,y:M.y+O};n.current.set(q,I),s.current.set(q,I)}const U=o.current;if(U){for(const[q,M]of A.members)U.set(q,{x:M.x+P,y:M.y+O});U.set(T.id,{x:T.position.x,y:T.position.y})}c(q=>q+1);return}n.current.set(T.id,{x:T.position.x,y:T.position.y}),s.current.set(T.id,{x:T.position.x,y:T.position.y}),(L=o.current)==null||L.set(T.id,{x:T.position.x,y:T.position.y}),c(A=>A+1)}},onNodeDragStop:(_,T)=>{f();const L=v(_,(T==null?void 0:T.type)==="agent"||(T==null?void 0:T.type)==="sessionGroup");if(a.current=!1,o.current=null,i(!1),d(A=>A+1),!T){k.current=null,bl(s.current,n.current);return}if(T.type==="sessionGroup"){const A=k.current;if(A&&L&&A.sessionId){for(const[P,O]of A.members){const U=A.pinsBefore.get(P);U?n.current.set(P,U):n.current.delete(P),s.current.set(P,O)}k.current=null,b(A.sessionId);return}if(A){const P=T.position.x-A.start.x,O=T.position.y-A.start.y;for(const[U,q]of A.members){const M={x:q.x+P,y:q.y+O};n.current.set(U,M),s.current.set(U,M)}}k.current=null,bl(s.current,n.current),d(P=>P+1);return}if(n.current.set(T.id,{x:T.position.x,y:T.position.y}),s.current.set(T.id,{x:T.position.x,y:T.position.y}),L){b(T.id);return}bl(s.current,n.current)}}}function Ife(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 X6({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 Ofe({reservedRight:e=0}){return r.jsx("div",{className:"empty-stage",style:{right:e},children:r.jsxs("div",{className:"empty-hero",children:[r.jsx(X6,{}),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 Pfe({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(X6,{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."]})]}):Dfe(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($u,{film:"tour",action:!0})]})]})})}function Dfe(e,t){const n=Ife(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?"}),vQ(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 Ffe=1;function Bfe(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 qfe(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:Ffe,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(Bfe)}))}}function Ufe(e,t){const n=(e||"session").replace(/[^a-z0-9._-]/gi,"_");return`${Rt}-${n}-${Bf(t,8)}.json`}const Z6={file:"📁",shell:"⚡",web:"🌐",agent:"🤖",task:"📋",plan:"🧭",mcp:"🔌",other:"✨"},Wfe={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 Hfe({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:Wfe[e]})})}const cp={file:"file",shell:"shell",web:"web",agent:"agent",task:"task",plan:"plan",mcp:"mcp",other:"other"},J6=G4;function zfe({agent:e,now:t,onOpenTool:n,onShowSummary:s,onExportSession:a,onRemove:o,singleKeys:i=!0}){var k;const c=`${e.synthetic?"≥ ":""}${Al(e.startedAt,e.endedAt,t)}`,d=Fn(e),h=d.total>0,f=e.usage.inputTokens+e.usage.outputTokens,p=new Map;for(const[N,j]of e.toolCountByName??[]){const S=J6(N);p.set(S,(p.get(S)??0)+j)}const m=e.toolErrorCount??0,w=e.tools.filter(N=>!N.endedAt).length,v=Array.from(p.entries()).sort((N,j)=>j[1]-N[1]),b=p.has("mcp")?eK(((k=e.toolCountByName)==null?void 0:k.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:Tp(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 N=jj(e);return r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"hero-sep",children:"·"}),r.jsxs("span",{className:"model-chip","data-family":_p(e.model),title:N.length>0?`${Su(e.model,e.effort)}
106
+ spend on this panel also covers:
107
+ ${N.join(`
108
+ `)}`:Su(e.model,e.effort),children:[Cp(e.model,e.effort),N.length>0?` +${N.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:st(d.total)}),r.jsx("span",{className:"hero-cost-label",children:"spend"})]}),r.jsx(Yj,{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; ${kn("the session list","L",i)} brings it back`:`Take this card and the ones under it off the board (Delete). ${kn("The session list","L",i)} brings it back`,children:"Remove from board"})]})]}),r.jsx(bK,{agent:e}),(()=>{const N=Ej(e);if(!N)return null;const j=Lf(N.at,t),S=N.kind==="recap"?"Recap":Dl(N.kind).replace(/^./,_=>_.toUpperCase());return r.jsxs("section",{className:"detail-section",children:[r.jsxs("h3",{children:[S," ",r.jsx("span",{className:"section-count",title:j.title,children:j.label})]}),r.jsx("p",{className:"detail-recap",title:Mp(N),children:N.text}),N.reply&&r.jsxs("p",{className:"detail-recap detail-note-reply",children:["Suggested reply: “",N.reply,"”"]})]})})(),(()=>{const N=_r(e.plan);return!N||!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:[N.done,"/",N.total]}),r.jsxs("span",{className:"vis-hidden",children:[N.done," of ",N.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((j,S)=>r.jsxs("li",{className:"plan-item","data-status":j.status,children:[r.jsx("span",{className:"plan-mark","aria-hidden":!0}),r.jsxs("span",{className:"vis-hidden",children:[Yfe[j.status],": "]}),r.jsx("span",{className:"plan-text",children:j.status==="in_progress"&&j.active?j.active:j.text}),j.status==="in_progress"&&r.jsx("span",{className:"plan-now","aria-hidden":!0,children:"now"})]},j.id??`${S}:${j.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:v.map(([N,j])=>{const S=N==="mcp"?b:null,_=S==null?void 0:S.hue,T=`${j} ${cp[N]} call${j===1?"":"s"}`;return r.jsxs("span",{className:`cat-chip cat-${N}${_!=null?" mcp-hue":""}`,style:_!=null?{"--mcp-hue":_}:void 0,title:S?`${T}, all to ${S.label}`:T,children:[r.jsx("span",{className:"cat-emoji","aria-hidden":!0,children:Z6[N]}),r.jsx("span",{className:"cat-name",children:cp[N]}),r.jsx("span",{className:"cat-count",children:j}),S&&r.jsx("span",{className:"cat-server",children:S.label})]},N)})})]})]}),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:wt(e.usage.inputTokens)})]}),r.jsxs("div",{children:[r.jsx("span",{className:"k",children:"out"}),r.jsx("b",{title:e.usage.outputTokens.toLocaleString(),children:wt(e.usage.outputTokens)})]}),r.jsxs("div",{children:[r.jsx("span",{className:"k",children:"cache r"}),r.jsx("b",{title:e.usage.cacheReadTokens.toLocaleString(),children:wt(e.usage.cacheReadTokens)})]}),r.jsxs("div",{children:[r.jsx("span",{className:"k",children:"cache c"}),r.jsx("b",{title:e.usage.cacheCreateTokens.toLocaleString(),children:wt(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:i4(e.prompts).length})]}),r.jsx("div",{className:"prompts",children:Vfe(e.prompts).reverse().map(({pr:N,key:j})=>{const S=Lf(N.at,t),_=kp(N.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})]},j):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:N.text})]},j)})})]}),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(N=>r.jsx(Kfe,{t:N,onClick:()=>n(e.id,N.id)},N.id))})]})]})}function Vfe(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 Gfe={inflight:"in-flight",done:"done",err:"error"};function Kfe({t:e,onClick:t}){const n=e.endedAt==null?"inflight":e.ok===!1?"err":"done",s=L4(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:Gfe[n]}),e.name]}),r.jsx("span",{style:{color:"var(--muted)"},children:s})]})}const Yfe={completed:"done",in_progress:"now",pending:"to do"};function Xfe(e,t){const n=qfe(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=Ufe(n.label,t),document.body.appendChild(i),i.click(),document.body.removeChild(i),setTimeout(()=>URL.revokeObjectURL(o),1e3)}function Zfe({selected:e,now:t,openTool:n,setSummaryFor:s,onClose:a,stateRef:o,removeSelectedNode:i}){tn("detail-panel");const c=qn();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(zfe,{agent:e,now:t,onOpenTool:n,onShowSummary:s,onExportSession:d=>Xfe(o.current,d),onRemove:i,singleKeys:c})]})}const Jfe=450,Qfe=400,epe=100,Yh=8,tpe={right:"hint hint-right",left:"hint hint-left",below:"hint hint-below",above:"hint hint-above"},Hc=8;let Yr=null,NI=-1/0;function npe(e,t,n){return n||e-t<Qfe}function spe(e,t,n,s,a=null){const o=Math.max(Hc,((a==null?void 0:a.left)??0)+Hc),i=Math.min(window.innerWidth,(a==null?void 0:a.right)??1/0)-n-Hc,c=p=>Math.max(o,Math.min(p,i)),d=p=>Math.max(Hc,Math.min(p,window.innerHeight-s-Hc)),h=t.top+t.height/2-s/2,f=t.left+t.width/2-n/2;return e==="right"?{left:t.right+Yh,top:d(h)}:e==="left"?{left:t.left-Yh-n,top:d(h)}:e==="above"?{left:c(f),top:t.top-Yh-s}:{left:c(f),top:t.bottom+Yh}}const rpe={chrome:"",dialog:" hint-over-dialog"};function zl(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&&(NI=performance.now()),null))},[]),d=y.useCallback((w,v,b)=>{window.clearTimeout(a.current),window.clearTimeout(o.current);const k=Yr!==null,N=npe(performance.now(),NI,k),j=()=>{var _;Yr&&Yr!==c&&Yr(),Yr=c;const S=t==="dialog"?((_=w.closest('[role="dialog"]'))==null?void 0:_.getBoundingClientRect())??null:null;s({spec:v,box:w.getBoundingClientRect(),within:S,instant:N})};b||N?j():a.current=window.setTimeout(j,Jfe)},[c,t]),h=y.useCallback(()=>{window.clearTimeout(a.current),window.clearTimeout(o.current),o.current=window.setTimeout(c,epe)},[c]),f=n!==null;y.useEffect(()=>{if(!f)return;const w=vn.push(c,0,"popover");return window.addEventListener("resize",c),window.addEventListener("scroll",c,!0),()=>{w(),window.removeEventListener("resize",c),window.removeEventListener("scroll",c,!0),Yr===c&&(Yr=null)}},[f,c]),y.useEffect(()=>()=>{window.clearTimeout(a.current),window.clearTimeout(o.current),Yr===c&&(Yr=null)},[c]),y.useLayoutEffect(()=>{const w=i.current;if(!w||!n)return;const{width:v,height:b}=w.getBoundingClientRect(),k=spe(e,n.box,v,b,n.within);w.style.left=`${k.left}px`,w.style.top=`${k.top}px`,w.style.visibility="visible"},[n,e]);const p=y.useCallback(w=>({onPointerEnter:v=>{w&&v.pointerType==="mouse"&&d(v.currentTarget,w,!1)},onPointerLeave:h,onPointerDown:c,onFocus:v=>{w&&v.currentTarget.matches(":focus-visible")&&d(v.currentTarget,w,!0)},onBlur:c}),[d,h,c]),m=n&&xt.createPortal(r.jsxs("span",{ref:i,className:tpe[e]+rpe[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}}const Q6="(max-width: 640px)",ape=600,ope=588,ipe=40;function lpe(e){if(typeof window>"u")return!1;const t=window.innerWidth;return t>0?t-2*ipe-e-ope<ape:!1}function $1(){if(typeof window>"u"||typeof window.matchMedia!="function")return!1;try{return window.matchMedia(Q6).matches}catch{return!1}}function eF(e,t){return e&&(t||!e.single)?e:void 0}function cpe(e,t,n){var i;const s=(i=eF(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 tF={stripe:"rail-btn rail-btn-stripe",dock:"rail-btn rail-btn-dock",bar:"rail-btn rail-btn-bar"},upe={left:"edge-rail edge-rail-left",right:"edge-rail edge-rail-right"},dpe={vertical:"ArrowDown",horizontal:"ArrowRight"},hpe={vertical:"ArrowUp",horizontal:"ArrowLeft"};function nF(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===dpe[t]?h=(d+1)%c.length:i.key===hpe[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 sl=null;function GN(e){y.useLayoutEffect(()=>{var a,o;sl&&document.activeElement===document.body&&((o=(a=e.current)==null?void 0:a.querySelector(`[data-rail-item="${sl}"]`))==null||o.focus()),sl=null;const t=i=>{var d;const c=(d=i.target.dataset)==null?void 0:d.railItem;c&&(sl=c)},n=i=>{var c;(c=e.current)!=null&&c.contains(i.relatedTarget)||(sl=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 KN({item:e,index:t,tabbable:n,onFocusIndex:s,hint:a,variant:o}){var h;const i=qn(),c=a.bind(cpe(e,i,o!=="stripe")),d=e.kind==="panel";return r.jsxs("button",{ref:e.buttonRef,type:"button","data-rail-item":e.id,className:tF[o],tabIndex:o==="bar"?void 0:n?0:-1,"aria-label":e.ariaLabel,"aria-keyshortcuts":(h=eF(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 SI({side:e,label:t,groups:n}){const s=zl(e==="left"?"right":"left"),a=n.filter(d=>d.length>0),o=nF(a.flat().length,"vertical"),i=y.useRef(null);GN(i);let c=0;return r.jsxs("div",{ref:i,className:upe[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(KN,{item:f,index:p,tabbable:p===o.active,onFocusIndex:o.setCurrent,hint:s,variant:"stripe"},f.id)})},h)),s.node]})}const Xh="dock-more",_I="dock-more-menu";function fpe({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(Xh))==null||f.focus(),o(null),h.onPress()};return r.jsxs(r.Fragment,{children:[r.jsxs("button",{id:Xh,type:"button","data-rail-item":"more",className:tF.dock,tabIndex:t?0:-1,"aria-label":`More: ${e.map(h=>h.ariaLabel).join(", ")}`,"aria-haspopup":"menu","aria-expanded":i,"aria-controls":i?_I: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(Hp,{anchorId:Xh,id:_I,className:"ap-pop",role:"menu",labelledBy:Xh,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:()=>{sl=h.id},onClick:d(h),children:h.badge?`${h.menu??h.label} · ${h.badge} unread`:h.menu??h.label},h.id))})]})}function ppe({items:e,more:t}){const n=zl("above"),s=nF(e.length+1,"horizontal"),a=y.useRef(null);return GN(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(KN,{item:o,index:i,tabbable:i===s.active,onFocusIndex:s.setCurrent,hint:n,variant:"dock"},o.id)),r.jsx(fpe,{items:t,index:e.length,tabbable:s.active===e.length,onFocusIndex:s.setCurrent}),n.node]})}function mpe({items:e,side:t="below"}){const n=zl(t),s=y.useRef(null);return GN(s),r.jsxs("div",{ref:s,className:"utility-run",children:[e.map((a,o)=>r.jsx(KN,{item:a,index:o,tabbable:!0,onFocusIndex:gpe,hint:n,variant:"bar"},a.id)),n.node]})}function gpe(){}function ype(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}
109
+ ${t} unread`:n}function wpe({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:v,setRadioOpen:b,openToolActivity:k,openSettings:N,onFeedback:j,toggles:S,openCapacity:_,integrations:T=[]}){const L=Cfe(Ku()),A={id:"session-list",label:"Session list",short:"Sessions",key:{cap:"L",aria:"L",single:!0},ariaLabel:"Session list",glyph:r.jsx(koe,{}),kind:"panel",open:t,controls:"session-list",onPress:n,buttonRef:S.sessionList},P={id:"accounts",label:"Accounts",short:"Accounts",key:{cap:"A",aria:"A",single:!0},ariaLabel:"Accounts",hint:"Claude accounts",glyph:r.jsx(joe,{}),kind:"panel",open:s,controls:"accounts-panel",onPress:a,buttonRef:S.accounts},O=_?[{id:"account-capacity",label:"Account capacity",short:"Capacity",ariaLabel:"Account capacity",detail:"How many accounts are ready, and what the 5h and 7d windows have left",glyph:r.jsx(Poe,{}),kind:"dialog",onPress:()=>_("accounts")},{id:"reset-calendar",label:"Reset calendar",short:"Calendar",ariaLabel:"Reset calendar",detail:"When each account's 5h and 7d windows come back",glyph:r.jsx(Doe,{}),kind:"dialog",onPress:()=>_("calendar")}]:[],U={id:"usage",label:"Usage",short:"Usage",key:{cap:"U",aria:"U",single:!0},ariaLabel:"Usage",glyph:r.jsx(Noe,{}),kind:"panel",open:o,controls:"usage-panel",onPress:()=>i(H=>!H),buttonRef:S.usage},q={id:"machine",label:"Machine",short:"Machine",key:{cap:"S",aria:"S",single:!0},ariaLabel:"Machine",hint:"This machine",glyph:r.jsx(_oe,{}),kind:"panel",open:c,controls:"system-panel",onPress:()=>d(H=>!H),buttonRef:S.machine},M={id:"history",label:"Usage history",short:"History",key:{cap:"H",aria:"H",single:!0},ariaLabel:"Usage history",glyph:r.jsx(Soe,{}),kind:"dialog",onPress:()=>h(H=>!H)},I={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:ype(f,p),glyph:r.jsx(Eoe,{watching:f===!0||p>0}),kind:"dialog",onPress:()=>m(H=>!H),badge:p},E={id:"settings",label:"Settings",short:"Settings",key:{cap:L,aria:"Control+, Meta+,",single:!1},ariaLabel:"Settings",glyph:r.jsx(Toe,{}),kind:"dialog",onPress:()=>N()},D={id:"feedback",label:"Feedback",short:"Feedback",menu:"Send feedback",ariaLabel:"Send feedback",glyph:r.jsx(Aoe,{}),kind:"dialog",onPress:j},B=k?[{id:"tool-activity",label:"Tool activity",short:"Tools",ariaLabel:"Tool activity",glyph:r.jsx(Ioe,{}),kind:"dialog",detail:"Which tools your agents run, how long they take and what fails",onPress:()=>k("tools")},{id:"skill-activity",label:"Skill activity",short:"Skills",ariaLabel:"Skill activity",glyph:r.jsx(Ooe,{}),kind:"dialog",detail:"Which skills your agents use, whether you typed them or the agent called them",onPress:()=>k("skills")}]:[];return{left:e.claude?[P,A]:[A],leftStripe:e.claude?[P,...O,A]:[A],capacity:e.claude?O:[],right:[[U,q],[M,...B,I,...w?[{id:"traffic-radar",label:"Telemetry Radar",short:"Radar",ariaLabel:"Telemetry Radar",glyph:r.jsx(Coe,{}),kind:"dialog",detail:"Claude telemetry configuration and observed connections",onPress:()=>w(!0)}]:[]],...b?[[{id:"radio",label:"Radio",short:"Radio",ariaLabel:"Radio",glyph:r.jsx(Loe,{}),kind:"panel",open:v,controls:"radio-panel",detail:"Explore stations around the world",onPress:()=>b(H=>!H)}]]:[]],utilities:[E,D],integrations:T.map(({provider:H,onPress:G})=>({id:`integration-${H.kind}`,label:H.label,short:H.label,ariaLabel:H.label,detail:H.detail,key:H.shortcut?{cap:H.shortcut.toUpperCase(),aria:H.shortcut.toUpperCase(),single:!0}:void 0,glyph:r.jsx(H.Glyph,{}),kind:"dialog",onPress:G}))}}const up=[{value:"bug",label:"Bug",question:"What happened?",placeholder:`I was trying to…
110
+ 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 sF(e){return up.find(t=>t.value===e)??up[0]}const L1=3,s0=120,rF=1e4,aF=200,xpe="Write something first.";function CI(e){return e.trim()!==""}function vpe(e){var o;const t=e.trim();if(t==="")return"";const n=EI(t.split(/\r?\n/,1)[0]),s=((o=/^(.+?[.!?])(?=\s|$)/.exec(n))==null?void 0:o[1])??n,a=r0(s).length>=L1?r0(s):r0(n);return kpe(a.length>=L1?a:EI(t))}function bpe(e,t){const n=vpe(t);return n.length>=L1?n:`${sF(e).label}: ${n}`}function EI(e){return e.replace(/\s+/g," ").trim()}function r0(e){return/[^.]\.$/.test(e)?e.slice(0,-1):e}function kpe(e){if(e.length<=s0)return e;const t=e.slice(0,s0-1),n=t.lastIndexOf(" ");return`${(n>=s0/2?t.slice(0,n):t).replace(/[\uD800-\uDBFF]$/,"").replace(/[\s,;:.\-–—]+$/,"")}…`}function jpe({kind:e,body:t,contact:n}){const s={kind:e,title:bpe(e,t),body:t.trim()};return n.trim()!==""&&(s.contact=n.trim()),s}function Npe(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 Spe={darwin:"macOS",win32:"Windows",linux:"Linux"};function _pe(e){const t=e.indexOf("-"),n=t===-1?e:e.slice(0,t),s=t===-1?"":e.slice(t+1),a=Spe[n]??n;return s?`${a} · ${s}`:a}function Cpe(e){return e?`ccdeck ${e.appVersion} · ${_pe(e.platform)}`:null}const Epe="sent with it",Tpe="Your ccdeck version and system are sent with it.",Ape="Add details",Rpe="How to reach you",Mpe="Email or GitHub @name",$pe="Only if you would like an answer.",Lpe=["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 Ipe(e){return e.key==="Enter"&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey&&!e.isComposing}function YN(e){return e.key==="Enter"&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey&&!e.isComposing}function Ope(e){return Yu(e)?["⌘","Enter"]:["Ctrl","Enter"]}function Ppe(e){return[...e].length===1}const oF="Thanks — feedback sent.";function TI(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 Dpe(e){return e==="sending"?"Sending…":e==="sent"?oF:""}const AI=1400,Fpe=160,iF=y.createContext({values:{}});function lF(){return y.useContext(iF)}function Bpe(e,t){const n=e.variants;return n?{...e,...n.by[t[n.field]??""]??{}}:e}const RI=(e,t)=>!e.when||e.when.is.includes(t[e.when.field]??"");function MI({def:e,existing:t,busy:n,error:s,onSubmit:a,onCancel:o}){var U,q;const i=y.useId(),[c,d]=y.useState(()=>Object.fromEntries(e.fields.map(M=>{var I,E,D;return[M.name,M.secret?"":((I=M.initial)==null?void 0:I.call(M,t))??(M.type==="choice"?((D=(E=M.options)==null?void 0:E[0])==null?void 0:D.value)??"":"")]}))),[h,f]=y.useState((t==null?void 0:t.name)??""),p=y.useRef(new Map),m=!!t,w=y.useRef(c),v=e.fields.filter(M=>M.type==="choice").every(M=>c[M.name]===w.current[M.name]),b=m&&t.tokenSaved&&v,k=(M,I)=>d(E=>({...E,[M]:I})),N=M=>{if(M.preventDefault(),n)return;const I={};for(const E of e.fields)RI(E,c)&&(I[E.name]=(c[E.name]??"").trim());a(I,h.trim()),d(E=>Object.fromEntries(Object.entries(E).map(([D,B])=>{var H;return[D,(H=e.fields.find(G=>G.name===D))!=null&&H.secret?"":B]})))},j=y.useMemo(()=>{const M=c.baseUrl??"";try{return M?new URL(/^[a-z]+:\/\//i.test(M)?M:`https://${M}`).host:""}catch{return""}},[c.baseUrl]),S=y.useMemo(()=>({values:c,existing:t}),[c,t]),_=e.fields.filter(M=>RI(M,c)),T=(U=_.find(M=>!M.secret&&M.type!=="choice"))==null?void 0:U.name,L=(q=_.find(M=>M.secret))==null?void 0:q.name,A=s!=null&&s.field&&_.some(M=>M.name===s.field&&M.type!=="choice")?s.field:null,P=`${i}-error`;y.useEffect(()=>{var I;const M=m?L:T;M&&((I=p.current.get(M))==null||I.focus())},[m]),y.useEffect(()=>{var M;A&&((M=p.current.get(A))==null||M.focus())},[s,A]);const O=s&&r.jsxs(r.Fragment,{children:[s.message,s.detail&&r.jsxs("span",{className:"ig-form-detail",children:[" ",e.label," said: ",s.detail]}),s.kind==="rate-limit"&&s.retryAfter?r.jsxs("span",{children:[" Try again in ",s.retryAfter," s."]}):null]});return r.jsx(iF.Provider,{value:S,children:r.jsxs("form",{className:"ig-form",onSubmit:N,"aria-labelledby":`${i}-title`,noValidate:!0,children:[r.jsx("h4",{className:"ig-form-title",id:`${i}-title`,children:m?`Edit ${t.name}`:`Connect ${e.label}`}),_.map(M=>{const I=Bpe(M,c),E=(s==null?void 0:s.field)===I.name,D=[I.hint?`${i}-${I.name}-hint`:"",E?P:""].filter(Boolean).join(" ")||void 0;if(I.type==="choice")return r.jsxs("fieldset",{className:"fb-kinds","aria-invalid":E||void 0,children:[r.jsx("legend",{className:"vis-hidden",children:I.label}),(I.options??[]).map(G=>r.jsxs("label",{className:"fb-kind",children:[r.jsx("input",{type:"radio",name:`${i}-${I.name}`,value:G.value,checked:c[I.name]===G.value,onChange:()=>k(I.name,G.value),onKeyDown:z=>{YN(z.nativeEvent)&&z.preventDefault()}}),G.label]},G.value))]},I.name);const B=I.secret&&b,H=`${i}-${I.name}`;return r.jsxs("div",{className:"fb-field",children:[r.jsxs("label",{className:"fb-field-label",htmlFor:H,children:[I.label,I.optional&&r.jsx("span",{className:"fb-optional",children:" optional"})]}),r.jsx("input",{id:H,className:`ap-manage-input ig-input${I.secret?" ig-mono":""}`,ref:G=>{G?p.current.set(I.name,G):p.current.delete(I.name)},type:I.type,inputMode:I.type==="url"?"url":I.type==="email"?"email":void 0,autoComplete:I.autoComplete??"off",spellCheck:!1,value:c[I.name]??"",onChange:G=>k(I.name,G.target.value),placeholder:B?"Saved. Leave blank to keep it":I.placeholder,"aria-invalid":E||void 0,"aria-describedby":D}),I.hint&&r.jsx("span",{className:"ig-hint",id:`${i}-${I.name}-hint`,children:I.hint}),E&&A===I.name&&r.jsx("span",{className:"ig-form-error",id:P,role:"alert",children:O})]},I.name)}),r.jsx("div",{className:"ig-help",children:e.tokenHelp}),r.jsxs("div",{className:"fb-field",children:[r.jsxs("label",{className:"fb-field-label",htmlFor:`${i}-name`,children:["Name ",r.jsx("span",{className:"fb-optional",children:"optional"})]}),r.jsx("input",{id:`${i}-name`,className:"ap-manage-input ig-input",type:"text",autoComplete:"off",maxLength:120,value:h,onChange:M=>f(M.target.value),placeholder:j||e.label})]}),s&&!A&&r.jsx("p",{className:"ig-form-error",id:P,role:"alert",children:O}),r.jsxs("div",{className:"ig-form-actions",children:[r.jsx("button",{type:"button",className:"btn",onClick:o,children:"Cancel"}),r.jsx("button",{type:"submit",className:"btn primary","aria-busy":n,children:n?"Checking…":m?"Save":"Connect"})]})]})})}const qpe="https://id.atlassian.com/manage-profile/security/api-tokens",Upe="https://support.atlassian.com/atlassian-account/docs/manage-api-tokens-for-your-atlassian-account/",Wpe="https://confluence.atlassian.com/enterprise/using-personal-access-tokens-1026032365.html",Hpe=[{scope:"read:jira-work",why:"issues, comments, search"},{scope:"read:jira-user",why:"your account and avatars"},{scope:"read:board-scope:jira-software",why:"boards and backlogs"},{scope:"read:board-scope.admin:jira-software",why:"a board's estimation and quick filters"},{scope:"read:sprint:jira-software",why:"sprints"},{scope:"read:epic:jira-software",why:"epic names and colours"},{scope:"read:issue-details:jira",why:"issue lists"},{scope:"read:jql:jira",why:"filtered lists"}];function zpe(e){const t=e.trim();if(!t)return null;try{const n=new URL(/^[a-z]+:\/\//i.test(t)?t:`https://${t}`),s=n.hostname==="localhost"||n.hostname==="127.0.0.1";return n.protocol!=="https:"&&!s||!n.hostname.includes(".")&&!s?null:`${n.origin}${n.pathname.replace(/\/+$/,"")}/secure/ViewProfile.jspa?selectedTab=com.atlassian.pats.pats-plugin:jira-user-personal-access-tokens`}catch{return null}}function Vpe(){const{values:e}=lF(),t=e.deployment==="cloud",n=t?null:zpe(e.baseUrl??"");let s="";try{s=n?new URL(n).host:""}catch{}return r.jsxs(r.Fragment,{children:[t?r.jsxs(r.Fragment,{children:[r.jsxs("p",{children:["Make one at ",r.jsx("a",{href:qpe,target:"_blank",rel:"noreferrer noopener",children:"id.atlassian.com → Security → API tokens"}),". A classic token reads Jira as you. A token ",r.jsx("em",{children:"with scopes"})," works too: the deck finds your site’s api.atlassian.com address itself, and needs these read scopes:"]}),r.jsx("ul",{className:"ig-scopes",children:Hpe.map(a=>r.jsxs("li",{children:[r.jsx("code",{children:a.scope})," ",r.jsx("span",{children:a.why})]},a.scope))}),r.jsx("p",{children:r.jsx("a",{href:Upe,target:"_blank",rel:"noreferrer noopener",children:"How Atlassian API tokens work"})})]}):r.jsxs(r.Fragment,{children:[r.jsxs("p",{children:["In Jira, open your avatar → ",r.jsx("strong",{children:"Profile"})," → ",r.jsx("strong",{children:"Personal Access Tokens"})," → ",r.jsx("strong",{children:"Create token"}),n&&r.jsxs(r.Fragment,{children:[" (",r.jsxs("a",{href:n,target:"_blank",rel:"noreferrer noopener",children:["open it on ",s]}),")"]}),". The token reads what your account can read. Give it an expiry you are comfortable with. Needs Jira 8.14 or newer."]}),r.jsx("p",{children:r.jsx("a",{href:Wpe,target:"_blank",rel:"noreferrer noopener",children:"How personal access tokens work"})})]}),r.jsx("p",{className:"ig-dim",children:"The deck only reads: it sends Jira nothing but GET requests, keeps the token on this machine, and never shows it again."})]})}function a0(e,t,n="classic"){if(e==="github")return n==="classic"?"https://github.com/settings/tokens/new?scopes=repo,read:org&description=ccdeck":"https://github.com/settings/personal-access-tokens/new";const s=(t??"").trim()||"https://gitlab.com";let a;try{a=new URL(/^[a-z][a-z0-9+.-]*:\/\//i.test(s)?s:`https://${s}`)}catch{return null}return a.protocol!=="https:"&&a.protocol!=="http:"||!a.hostname.includes(".")&&a.hostname!=="localhost"?null:`${a.origin}${a.pathname.replace(/\/+$/,"")}/-/user_settings/personal_access_tokens?name=ccdeck&scopes=read_api`}function o0({href:e,children:t}){return e?r.jsxs("a",{className:"fg-token-link",href:e,target:"_blank",rel:"noreferrer noopener",children:[t," ",r.jsx(Xj,{})]}):null}function cF({kind:e,baseUrl:t}){const{values:n}=lF();if(e==="github")return r.jsxs("div",{className:"fg-token-help",children:[r.jsx("p",{children:"A personal access token. Either kind works:"}),r.jsxs("ul",{children:[r.jsxs("li",{children:[r.jsx("strong",{children:"Classic"})," — the ",r.jsx("code",{children:"repo"})," and ",r.jsx("code",{children:"read:org"})," scopes."," ",r.jsx(o0,{href:a0("github"),children:"Make one"})]}),r.jsxs("li",{children:[r.jsx("strong",{children:"Fine-grained"})," — the repositories you want to see, with read-only access to Actions, Checks, Commit statuses, Contents, Issues, Metadata and Pull requests. Contents is for branches and commits; the panel never opens your files."," ",r.jsx(o0,{href:a0("github",null,"fine-grained"),children:"Make one"})]})]}),r.jsx("p",{children:"An organization may have to approve a fine-grained token, or a classic one be authorized for its single sign-on, before its repositories show."})]});const s=a0("gitlab",t??(n.where==="self"?n.baseUrl:null));return r.jsxs("div",{className:"fg-token-help",children:[r.jsxs("p",{children:["A personal access token with the ",r.jsx("code",{children:"read_api"})," scope, and nothing more."," ",r.jsx(o0,{href:s,children:`Make one on ${s?new URL(s).host:"GitLab"}`})]}),r.jsx("p",{children:"GitLab tokens expire. When this one does, the panel says so and brings you back here."})]})}const uF={name:"token",label:"Personal access token",type:"password",secret:!0,placeholder:"Paste the token"},Gpe=[uF],$I=e=>{try{return e?new URL(e.baseUrl).host!=="gitlab.com":!1}catch{return!1}},Kpe=[{name:"where",label:"Which GitLab",type:"choice",options:[{value:"cloud",label:"GitLab.com"},{value:"self",label:"Self-managed"}],initial:e=>$I(e)?"self":"cloud"},{name:"baseUrl",label:"GitLab URL",type:"url",placeholder:"https://gitlab.example.com",hint:"The address you open GitLab at, with its path if it has one. https only.",when:{field:"where",is:["self"]},initial:e=>$I(e)?e.baseUrl:""},uF],Ype=y.createElement(cF,{kind:"github"}),Xpe=y.createElement(cF,{kind:"gitlab"}),Zpe=e=>{var t;return((t=e==null?void 0:e.meta)==null?void 0:t.deployment)==="cloud"?"cloud":"server"},Jpe={kind:"jira",label:"Jira",Glyph:Boe,shortcut:"I",detail:"Your board, sprint first",blurb:"Jira Cloud, or Jira Server / Data Center 8.14 and newer.",fields:[{name:"deployment",label:"Which Jira",type:"choice",options:[{value:"server",label:"Jira Server / Data Center"},{value:"cloud",label:"Jira Cloud"}],initial:Zpe},{name:"baseUrl",label:"Jira URL",type:"url",initial:e=>(e==null?void 0:e.baseUrl)??"",variants:{field:"deployment",by:{server:{label:"Jira URL",placeholder:"https://jira.example.com",hint:"The address you open Jira at, with its path if it has one (…/jira). https only."},cloud:{label:"Site URL",placeholder:"your-site.atlassian.net",hint:"The address you open Jira at. Your site name alone is enough."}}}},{name:"email",label:"Atlassian account email",type:"email",placeholder:"you@example.com",autoComplete:"username",secret:!0,when:{field:"deployment",is:["cloud"]}},{name:"token",label:"Personal access token",type:"password",secret:!0,variants:{field:"deployment",by:{server:{label:"Personal access token",placeholder:"Paste the token"},cloud:{label:"API token",placeholder:"Paste the API token"}}}}],tokenHelp:y.createElement(Vpe)},Qpe={kind:"github",label:"GitHub",Glyph:qoe,detail:"Branches, pull requests, Actions",blurb:"github.com, read-only, with a personal access token.",fields:Gpe,tokenHelp:Ype},eme={kind:"gitlab",label:"GitLab",Glyph:Uoe,detail:"Branches, merge requests, pipelines",blurb:"GitLab.com or your own instance, read-only.",fields:Kpe,tokenHelp:Xpe},I1={jira:Jpe,github:Qpe,gitlab:eme},dF=()=>Object.values(I1).filter(e=>!!e);function hF(e){return(Object.hasOwn(I1,e)?I1[e]:void 0)??null}function gm(e,t){const n=s=>typeof t=="string"?t:t(s);return y.lazy(()=>e().catch(s=>(console.warn(`ccdeck could not load ${typeof t=="string"?t:"a dialog"}`,s),{default:a=>r.jsx(tme,{name:n(a),onClose:a.onClose})})))}function tme({name:e,onClose:t}){const n=y.useRef(null),s=ft(t,{focusRef:n}),a=mt(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"})]})]})]})})}const fF=()=>Fl(()=>import("./IntegrationModal-B1ypkK-E.js"),[]);function nme(){fF().catch(()=>{})}const sme=gm(fF,e=>{var t;return((t=hF(e.kind))==null?void 0:t.label)??"The tracker"});function rme({onClose:e}){return y.useEffect(()=>vn.push(e,0,"dialog"),[e]),null}function ame(e){return r.jsx(y.Suspense,{fallback:r.jsx(rme,{onClose:e.onClose}),children:r.jsx(sme,{...e})})}class vr extends Error{constructor(n,s,a={}){super(s);Fa(this,"kind");Fa(this,"status");Fa(this,"retryAfter");Fa(this,"field");Fa(this,"detail");this.name="IntegrationFailure",this.kind=n,Object.assign(this,a)}}async function pF(e){try{const t=await e.json(),n=t==null?void 0:t.error;if(n&&typeof n.kind=="string"&&typeof n.message=="string")return new vr(n.kind,n.message,{status:n.status,retryAfter:n.retryAfter,field:n.field,detail:n.detail})}catch{}return new vr(e.status===401?"auth":"upstream",`The deck answered ${e.status}.`)}async function ld(e,t={}){const{timeoutMs:n=3e4,...s}=t,a=new AbortController,o=window.setTimeout(()=>a.abort(),n),i=s.signal,c=()=>a.abort();i==null||i.addEventListener("abort",c,{once:!0});let d;try{d=await fetch(e,{...s,signal:a.signal,headers:s.body?{"Content-Type":"application/json",...s.headers??{}}:s.headers})}catch(h){throw i!=null&&i.aborted?h:new vr("network",a.signal.aborted?"The deck took too long to answer.":"The deck could not be reached.")}finally{window.clearTimeout(o),i==null||i.removeEventListener("abort",c)}if(!d.ok)throw await pF(d);return d.json()}const mF=e=>`/api/integrations/${encodeURIComponent(e.kind)}/${encodeURIComponent(e.id)}/`;function Bke(e){const t=mF(e);return(n,s)=>fetch(`${t}${n.replace(/^\/+/,"")}`,s)}function qke(e){const t=mF(e);return n=>`${t}asset?url=${encodeURIComponent(n)}`}function Uke(e){const t=new URLSearchParams;for(const[s,a]of Object.entries(e))a===void 0||a===""||a===!1||t.set(s,a===!0?"1":String(a));const n=t.toString();return n?`?${n}`:""}async function Wke(e,t,{signal:n,timeoutMs:s=45e3}={}){const a=new AbortController,o=window.setTimeout(()=>a.abort(),s),i=()=>a.abort();n==null||n.addEventListener("abort",i,{once:!0});let c;try{c=await e(t,{signal:a.signal,headers:{Accept:"application/json"}})}catch(d){throw n!=null&&n.aborted?d:new vr("network",a.signal.aborted?"The deck took too long to answer.":"The deck could not be reached.")}finally{window.clearTimeout(o),n==null||n.removeEventListener("abort",i)}if(!c.ok)throw await pF(c);try{return await c.json()}catch{throw new vr("upstream","The deck answered with something that is not JSON.")}}let na={connections:null,providers:[],error:""};const ul=new Set;let Zh=null,zc=null,kl=null,LI=0;const ome=5e3,ime=3;function dp(e){na={...na,...e},ul.forEach(t=>t(na))}function XN(){return zc||(zc=(async()=>{try{const e=await ld("/api/integrations",{timeoutMs:1e4}),t=e==null?void 0:e.connections,n=e==null?void 0:e.providers;if(!Array.isArray(t)||!Array.isArray(n))throw new vr("upstream","The deck answered with something that is not the list of connections.");dp({connections:t,providers:n,error:""})}catch(e){dp({error:e instanceof Error?e.message:"Could not read the connections."}),na.connections===null&&ul.size>0&&kl===null&&LI<ime&&(kl=window.setTimeout(()=>{kl=null,XN()},ome*2**LI++))}finally{zc=null}})(),zc)}function lme(e){return e.connections===null||e.providers.length>0||e.connections.length>0}function II(){lme(na)&&XN()}function ZN(e){const t=na.connections??[],n=t.findIndex(s=>s.id===e.id);dp({connections:n<0?[...t,e]:t.map(s=>s.id===e.id?e:s)})}function cme(e){dp({connections:(na.connections??[]).filter(t=>t.id!==e)})}function cd(){const[e,t]=y.useState(na);return y.useEffect(()=>{ul.add(t),t(na);const n=()=>{document.visibilityState==="visible"&&II()};return ul.size===1&&(XN(),Zh=window.setInterval(II,6e4),document.addEventListener("visibilitychange",n)),()=>{ul.delete(t),ul.size===0&&(Zh!==null&&window.clearInterval(Zh),Zh=null,kl!==null&&window.clearTimeout(kl),kl=null,document.removeEventListener("visibilitychange",n))}},[]),e}function gF(e,t){return(e.connections??[]).filter(n=>n.kind===t)}function JN(e){return e.connections===null?new Set:new Set(e.providers.filter(t=>(t==null?void 0:t.available)===!0).map(t=>t.kind))}function ud(e,t){return JN(e).has(t)}function ume(e,t){return ud(e,t)&&gF(e,t).length>0}function yF(e){return JN(e).size>0?"all":(e.connections??[]).length>0?"connections":"none"}async function dme(e,t,n){const s=await ld("/api/integrations/connections",{method:"POST",body:JSON.stringify({kind:e,name:n,input:t}),timeoutMs:6e4});return ZN(s.connection),s.connection}async function hme(e,t){const n=await ld(`/api/integrations/connections/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t),timeoutMs:6e4});return ZN(n.connection),n}async function fme(e){const t=await ld(`/api/integrations/connections/${encodeURIComponent(e)}/test`,{method:"POST",body:"{}",timeoutMs:6e4});return ZN(t.connection),t.connection}async function pme(e){await ld(`/api/integrations/connections/${encodeURIComponent(e)}`,{method:"DELETE"}),cme(e)}function mme(e){try{return new URL(e.baseUrl).host}catch{return e.baseUrl}}function gme(e){const t=e.trim().split(/\s+/).filter(Boolean);return t.length?(t.length===1?t[0].slice(0,2):`${t[0][0]}${t[t.length-1][0]}`).toUpperCase():"?"}let O1=null;function yme(e){O1=e}function wme(){const e=O1;return O1=null,e}function xme({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 wF(e){return e.tool?e.tool.name:e.kind==="asked"?"question":"permission"}const vme=20;function bme(e,t=vme){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 kme(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 jme(e,t,n){const s=t.tool?`on ${t.tool.name}`:t.kind==="asked"?"for an answer":"for permission";return`${e}, waiting ${kme(n)} ${s}; go to session`}function Nme(e){const t=Tl(e),n=$4(e,t);return n?`${t}
111
+ ${n}`:t}const Sme=new Set(["idle","checking","current","downloading","ready","error"]);function OI(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.status!="string"||!Sme.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 _me(e){return(e==null?void 0:e.status)==="ready"&&e.version?{version:e.version}:null}function xF(e=typeof navigator>"u"?"":navigator.userAgent){var t;return((t=/\bccdeck-desktop\/(\d[^\s]*)/.exec(e))==null?void 0:t[1])??null}const $l="Restart to update",vF=3e4;function bF(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 Cme(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 ${$l} comes first`}}function kF(e,t=!1){return{text:t?"Restarting…":$l,label:t?void 0:`${$l} 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 Eme(e){const t=e==null?void 0:e.reason;return t==="app_disconnected"||t==="update_not_ready"?t:"refused"}function jF(e,t,n=typeof navigator>"u"?"":navigator.userAgent){const s=bF(n),a=`Use ${$l} 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, ${$l} is in ${s}.`;case"timeout":return`ccdeck has not restarted after ${vF/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 Tme="Update checks are off (AGENTS_DECK_NO_UPDATE_CHECK=1)",i0="click for what's new";function Ame(e){if(e.checkDisabled)return`${Tme} · ${i0}`;if(e.checking)return`Asking npm for the newest release… · ${i0}`;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 · ${i0}, and to check npm now`}function Rme(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 Mme(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 NF(e){return e?`${e.kind}:${e.to}`:""}function $me(e,t){return e!=null&&t!==NF(e)}function Lme({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=Cme(xF()??a,e.version),w=f&&kF(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":Mme({...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?$f(i-s.checkedAt):null,checkFailedAgo:s!=null&&s.checkFailedAt&&s.checkFailedAt>(s.checkedAt??0)?$f(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":Rme(m),title:Ame(m),children:["v",m.running]})})()})}function Ime({live:e,paused:t,pauseGate:n}){const s=qn();return r.jsx("span",{className:"status",children:(()=>{const a=FK({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 Ome(e,t){return`${e.label} — ${wF(e.waiting)} · ${Hf(e.waiting.since,void 0,t)}`}function SF(e,t){const n=e.slice(0,6).map(s=>Ome(s,t));return e.length>6&&n.push(`and ${e.length-6} more`),n.join(`
112
+ `)}function Pme({waitingSessions:e,waitingCursorRef:t,focusSession:n,now:s,named:a}){const o=qn(),i=zl("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?SF(c,s):void 0}),children:[r.jsx("span",{className:"ap-pulse","aria-hidden":!0}),r.jsx("b",{children:d})," waiting"]}),i.node]})}function PI({w:e,now:t}){return r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"we-name",children:bme(e.label)}),r.jsx("span",{className:"we-wait",children:Hf(e.waiting.since,void 0,t)}),r.jsxs("span",{className:"we-what",children:["· ",wF(e.waiting)]})]})}const Dme=12,Fme=2e3,Bme=4;function qme({waitingSessions:e,waitingCursorRef:t,focusSession:n,now:s,onFit:a,onMore:o}){const i=qn(),c=zl("below"),d=y.useRef(null),h=y.useRef(null),[f,p]=y.useState(0),m=e.map(k=>k.id).join(`
113
+ `);y.useLayoutEffect(()=>{const k=d.current,N=h.current;if(!k||!N)return;const j=()=>{const _=Array.from(N.children),T=_.pop();p(xme({widths:_.map(L=>L.getBoundingClientRect().width),room:k.clientWidth-Dme,gap:Bme,more:(T==null?void 0:T.getBoundingClientRect().width)??0}))};if(j(),typeof ResizeObserver>"u")return;const S=new ResizeObserver(j);return S.observe(k),S.observe(N),()=>S.disconnect()},[m]);const w=e.slice(0,f),v=e.slice(f);y.useEffect(()=>{a(w.length)},[w.length,a]);const b=k=>{t.current=k,n(k)};return r.jsxs("div",{className:"wait-names",ref:d,children:[r.jsxs("ul",{className:"wait-list",children:[w.map(k=>r.jsx("li",{"data-fresh":s-k.waiting.since<Fme||void 0,children:r.jsx("button",{type:"button",className:"wait-entry",onClick:()=>b(k.id),"aria-label":jme(k.label,k.waiting,s-k.waiting.since),...c.bind({label:k.label,detail:Nme(k.waiting)}),children:r.jsx(PI,{w:k,now:s})})},k.id)),w.length>0&&v.length>0&&r.jsx("li",{children:r.jsxs("button",{type:"button",className:"wait-more",onClick:o,"aria-label":`${v.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:SF(v,s)}),children:["+",v.length," more"]})})]}),e.length>0&&r.jsxs("span",{className:"wait-ruler",ref:h,"aria-hidden":!0,children:[e.map(k=>r.jsx("span",{className:"wait-entry",children:r.jsx(PI,{w:k,now:s})},k.id)),r.jsxs("span",{className:"wait-more",children:["+",e.length," more"]})]}),c.node]})}const P1={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 Ume(e){return e==="on"?`Notifications on. ${P1.on}.`:e==="blocked"?`${P1.blocked}.`:""}function Wme({notifySaid:e}){return r.jsx("span",{className:e==="on"?"notify-said":"notify-said notify-said-blocked","aria-hidden":!0,title:P1[e],children:e==="on"?"notifications on":"notifications blocked"})}function Hme({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:v,noticeOpen:b,showNotice:k,versionChecking:N,loadVersion:j}=e,{chipVersion:S,openReleaseNotes:_}=t,{readyAppUpdate:T,desktopUpdateRestarting:L,desktopUpdateFailure:A,askDesktopUpdateRestart:P}=n,O=y.useRef(!1);y.useEffect(()=>{L||!O.current||(O.current=!1,A&&_())},[L,A,_]);const U=H=>{O.current=!0,P(H)},{paused:q,pauseGate:M}=s,{blockedSaid:I,watchSaid:E,incidentSaid:D}=a,{notifySaid:B}=o;return r.jsxs("div",{className:"readout",children:[r.jsxs("div",{className:"brand",children:[r.jsx("img",{className:"logo logo-on-dark",src:nQ,width:19,height:16,alt:""}),r.jsx("img",{className:"logo logo-on-light",src:sQ,width:19,height:16,alt:""}),r.jsx("h1",{children:Rt}),r.jsx(Lme,{readyAppUpdate:T,notice:v,noticeOpen:b,version:w,chipVersion:S,versionChecking:N,now:f,openReleaseNotes:_,showNotice:k,loadVersion:j,restartToUpdate:U,updateRestarting:L})]}),r.jsx(Ime,{live:h,paused:q,pauseGate:M}),r.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:I}),r.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:E}),r.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:D}),r.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:Ume(B)}),r.jsx(aQ,{incidents:p}),i.length>0&&r.jsx(Pme,{waitingSessions:i,waitingCursorRef:c,focusSession:d,now:f,named:m}),B&&r.jsx(Wme,{notifySaid:B})]})}function zme({selected:e,now:t,selectedIds:n,focusAgent:s,clearSelection:a}){const o=qn(),i=Fn(e),c=Math.max(0,((e.endedAt??t)-e.startedAt)/1e3),d=e.state==="active"&&!e.synthetic?kj(i.total,c):null,h=n.size-1;return r.jsxs("button",{type:"button",className:"selected-ribbon",title:`${kn(`Zoom to ${e.label} and its session`,"Z",o)}${i.total>0?`
114
+ ${st(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:[st(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 Vme({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"} ${cp[o]} tools`,children:[r.jsx(Hfe,{cat:o}),r.jsx("span",{className:"cat-name",children:cp[o]})]},o)})})}const Gme=["a[href]","button:not(:disabled)","input:not(:disabled)","select:not(:disabled)","textarea:not(:disabled)","summary","[tabindex]"].join(",");function Kme(e){var n,s;const t=e.target;!(t!=null&&t.closest)||t.closest(Gme)!==e.currentTarget||(e.preventDefault(),(s=(n=document.activeElement)==null?void 0:n.blur)==null||s.call(n))}function Yme({trashZoneRef:e,trashState:t,trashPhase:n,trashLabel:s}){const a=qn();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"?`${kn("The session list","L",a)} brings it back`:"The session keeps running"})]})]})}function Xme({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:v,lodRef:b}=a,{markCanvasInput:k}=o,{peekAgent:N,peekLabel:j,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":v,ref:e,onMouseDownCapture:Kme,onPointerDownCapture:k,onPointerUpCapture:k,onWheelCapture:k,onFocusCapture:T=>{const L=T.target;if(!WN(L)||b.current==null||b.current==="detail")return;const A=L.getAttribute("data-id");A&&i.current.agents.has(A)&&L.matches(":focus-visible")&&L6(A,L,"focus")},onBlurCapture:T=>{var A,P;const L=(P=(A=T.target).getAttribute)==null?void 0:P.call(A,"data-id");L&&ro(L)},children:[d,Xa(p)&&r.jsx(Yme,{trashZoneRef:m,trashState:f,trashPhase:p,trashLabel:w}),r.jsx(ohe,{agentFor:N,recapFor:S,labelFor:j,bounds:_})]})}function Zme({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=PK({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 Jme({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 _F="Thanks — that helps.",Qme=Array.from({length:11},(e,t)=>t);function ege(e){return e===0?"0 out of 10, not useful":e===10?"10 out of 10, extremely useful":`${e} out of 10`}const tge=6;function nge(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 sge(){var e;(e=document.getElementById("canvas"))==null||e.focus()}function rge({phase:e,score:t,onAnswer:n,onLater:s,onClose:a,onFeedback:o,onHold:i}){const c=nge(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,Bn(((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)&&sge(),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:_F}),t!==null&&t<=tge?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:Qme.map(m=>r.jsx("button",{type:"button",className:"rating-pick","aria-label":ege(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 age=3e4;function oge({bundle:e,running:t,lastTried:n}){return!t||e===t?!1:n!==t}function ige({bundle:e,running:t,pending:n,lastTried:s}){return t?oge({bundle:e,running:t,lastTried:s})?"reload":n==null||n&&n!==t?"wait":"confirm":"wait"}function lge(e){return!e||e.state!=="failed"?null:`${typeof e.at=="number"?e.at:0}:${e.error??""}`}function cge({asked:e,reported:t}){return t?t!==e:!1}function CF(e){const t=e.thresholdMs??age;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 uge(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 dge(e,t){return e?t==null?"auto when idle":`auto in ${uge(t)}`:"auto-restart off"}function DI(e){let t=0;for(const n of e)n.state==="active"&&t++;return t}function hge(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 fge(e){const t=CF(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 D1={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 pge({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,v,b;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(),...On(m),title:`Stop this process and bring it back on the same port. The canvas replays from the event log.
115
+
116
+ 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:dge(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,...On(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}),...On(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:((v=t==null?void 0:t.upgrade)==null?void 0:v.error)??"",children:[(t==null?void 0:t.upgradeMode)==="npx"?"update failed":"install failed",": ",((b=t==null?void 0:t.upgrade)==null?void 0:b.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:":D1.npx}):t!=null&&t.upgradeBlocked?r.jsx("span",{className:"ver-sub",children:Kt(D1,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 mge({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:v,restartCopy:b,restartFuseMs:k}=e,{version:N,notice:j,noticeOpen:S,dismissNotice:_}=t,{upgradeState:T,startUpgrade:L,copyCommand:A,cmdCopied:P}=n,{oldName:O,oldNameOpen:U,dismissOldName:q}=s,{ratingPhase:M,ratingScore:I,answerRating:E,rateLater:D,closeRating:B,holdThanks:H}=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(Zme,{restarting:p,restartMode:m,live:c,paused:d}):S&&j?r.jsx(pge,{notice:j,version:N,dismissNotice:_,upgradeState:T,startUpgrade:L,copyCommand:A,cmdCopied:P,autoRestart:h,toggleAutoRestart:f,askRestart:v,restartCopy:b,restartFuseMs:k,restarting:p}):U&&O?r.jsx(Jme,{oldName:O,version:N,dismissOldName:q}):M!=="hidden"?r.jsx(rge,{phase:M,score:I,onAnswer:E,onLater:D,onClose:B,onFeedback:o,onHold:H}):null;return r.jsxs(r.Fragment,{children:[G,r.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:M==="thanks"?_F:""})]})}function gge(e,t){return e==="confirmation"?t.confirmOpen?"clear":"ignore":t.modalOpen||t.confirmOpen?"ignore":"confirm"}function yge(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 wge(e){return e<=0?null:e===1?"the one agent":`all ${e} agents`}function xge(e,t){const n=wge(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 vge({agentCount:e,onConfirm:t,onCancel:n}){const s=y.useRef(null),a=ft(n,{focusRef:s,layer:BV}),o=mt(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(yge(w))}).catch(()=>{}),()=>{m=!0}},[]);const{goes:d,stays:h,final:f,confirm:p}=xge(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})]})]})]})})}function bge({kind:e,onChange:t}){return r.jsxs("fieldset",{className:"fb-kinds",children:[r.jsx("legend",{className:"vis-hidden",children:"Kind of feedback"}),up.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=>{YN(s.nativeEvent)&&s.preventDefault()}}),n.label]},n.value))]})}const EF="fb-details";function kge({open:e,onToggle:t}){return r.jsxs("button",{type:"button",className:"fb-tool fb-more","aria-expanded":e,"aria-controls":EF,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 jge({open:e,contact:t,onContact:n}){const s=y.useId();return r.jsx("div",{id:EF,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:[Rpe,r.jsx("span",{className:"fb-optional",children:"optional"})]}),r.jsx("input",{id:"fb-contact",className:"ap-manage-input",type:"text",value:t,maxLength:aF,autoComplete:"email",placeholder:Mpe,"aria-describedby":s,onChange:a=>n(a.target.value),onKeyDown:a=>{YN(a.nativeEvent)&&a.preventDefault()}}),r.jsx("p",{id:s,className:"fb-hint",children:$pe})]}),r.jsx("div",{className:"fb-where",children:Lpe.map(a=>r.jsx("p",{children:a},a))})]})})})}const qo=3,Nge=5*1024*1024,Sge=12*1024*1024,F1=8192,_ge=64*1024,Cge=256*1024,Ege=.92,Tge=640,TF=.9,Age=.85,Rge=6,Mge=512*1024,hp={png:"image/png",jpeg:"image/jpeg"},$ge={png:"png",jpeg:"jpg"},Lge=[137,80,78,71,13,10,26,10],Ige=[255,216,255];function AF(e){const t=n=>e.length>=n.length&&n.every((s,a)=>e[a]===s);return t(Lge)?"png":t(Ige)?"jpeg":null}function Oge(e){const t=AF(e);return t==="png"?Pge(e):t==="jpeg"?Fge(e):null}function Pge(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 Dge(e){return e>=192&&e<=207&&e!==196&&e!==200&&e!==204}function Fge(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(Dge(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 FI(e,t){return e.bytes>t||e.width>F1||e.height>F1}function Bge(e){return Math.min(Nge,Sge-_ge-e)}function RF(e,t){return{width:Math.max(1,Math.floor(e.width*t)),height:Math.max(1,Math.floor(e.height*t))}}function qge(e,t){const n=F1/Math.max(e.width,e.height),s=e.bytes>t?Math.sqrt(t/e.bytes)*TF:1;return RF(e,Math.min(1,n,s))}async function Uge(e,t,n){let s=qge(e,t),a=e.format;for(let o=0;o<Rge;o++){const i=await n(s,a,a==="jpeg"?Ege:void 0);if(!i)return null;if(i.size<=t)return{...s,blob:i,format:a};if(a==="png"){a="jpeg";continue}if(s=RF(s,Math.min(Age,Math.sqrt(t/i.size)*TF)),Math.max(s.width,s.height)<Tge)return null}return null}async function Wge(e,t,n){const s=new Uint8Array(await e.slice(0,Mge).arrayBuffer()),a=AF(s);if(!a)return{ok:!1,problem:"type"};if(t<Cge)return{ok:!1,problem:"no_room"};const o=e.type===hp[a]?e:new Blob([e],{type:hp[a]}),i=Oge(s);if(i&&!FI({...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(!FI(d,t))return{ok:!0,blob:o,resized:null};const h=await Uge(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 Hge(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)},hp[s],a)})}const zge=async e=>{const t=await createImageBitmap(e);return{width:t.width,height:t.height,encoder:Hge(t),release:()=>t.close()}};function Vge(e){return e.includes("Files")}function Gge({files:e,hasText:t,intoTextField:n}){return e>0&&(!t||!n)}function Kge(e,t){const n=e.indexOf(t);return e[n+1]??e[n-1]??null}function Yge(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===hp.jpeg?"jpeg":"png";n.append("images",s,`image-${a+1}.${$ge[o]}`)}),{method:"POST",body:n}}const Xge="Add screenshot",BI="PNG or JPEG, up to three. You can also paste one, or drop it on this dialog.",Zge="A screenshot can show emails, costs and paths. Crop out what should not be seen.",qI="Three images at most. Remove one to add another.",Jge="An image could not be attached, so nothing was sent. Check the images and send again; your text is still here.";function Qge(e,t,n){const s=n?`, resized to ${n.width} × ${n.height} to fit`:"";return`Replace image ${e+1}: ${t}${s}`}function eye(e,t){const n=`${e} of ${qo}`;return t>0?`${n} · ${t} resized to fit`:n}function tye(e){return`Three images at most, so ${e===1?"one was":`${e} were`} left out.`}function nye(e){return`“${e.length>40?`${e.slice(0,30)}…${e.slice(-9)}`:e}”`}function sye(e,t){const n=nye(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 MF="image/png,image/jpeg";function $F({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 rye({images:e,buttonRef:t}){const n=y.useRef(null),s=e.shots.length>=qo;return r.jsxs(r.Fragment,{children:[r.jsxs("button",{ref:t,type:"button",className:"fb-tool",title:BI,"aria-describedby":"fb-attach-hint",onClick:()=>{var a;return s?e.sayFull():(a=n.current)==null?void 0:a.click()},children:[r.jsx($F,{}),Xge]}),r.jsx("span",{id:"fb-attach-hint",hidden:!0,children:BI}),r.jsx("input",{ref:n,type:"file",accept:MF,multiple:!0,hidden:!0,onChange:a=>{e.add(Array.from(a.target.files??[])),a.target.value=""}})]})}function aye({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=eye(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(Kge(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:MF,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":Qge(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:v=>{v?n.current.set(m.id,v):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:Zge})]}),e.problem&&r.jsx("p",{ref:s,className:"fb-error",role:"alert",children:e.problem},e.problemId)]})}function oye(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 iye(e,t,n){return n?e.map(s=>s.id===t.id?t:s):[...e,t]}function lye(e,t,n){return n?e.map(s=>s.id===t?n:s):e.filter(s=>s.id!==t)}function cye(e){const[t,n]=y.useState(()=>oye((e==null?void 0:e.ready)??[],1)),[s,a]=y.useState({problem:"",id:0}),o=y.useRef(0),i=y.useCallback(M=>{M&&o.current++,a(I=>M?{problem:M,id:I.id+1}:I.problem?{problem:"",id:I.id}:I)},[]),[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),v=y.useRef([]),b=y.useRef(0),k=y.useCallback(M=>{h.current=M(h.current),n(h.current)},[]);y.useEffect(()=>(m.current=!0,()=>{m.current=!1;for(const M of h.current)URL.revokeObjectURL(M.url)}),[]);const N=y.useCallback(async(M,I)=>{const E=h.current.reduce((Z,V)=>{var Y;return Z+(V.id===(I==null?void 0:I.id)?0:((Y=V.blob)==null?void 0:Y.size)??0)},0),D=(I==null?void 0:I.id)??++p.current,B=URL.createObjectURL(M),H={id:D,name:M.name||"image",url:B,blob:null,resized:null},G=b.current;w.current.set(D,M);let z=!1;const F=()=>{z||(z=!0,k(Z=>iye(Z,H,I!==void 0)))},$=await Wge(M,Bge(E),async Z=>(F(),zge(Z))).catch(()=>({ok:!1,problem:"unreadable"})),W=h.current.some(Z=>Z.id===D);return!m.current||b.current!==G||!W&&(z||I)?(URL.revokeObjectURL(B),I&&URL.revokeObjectURL(I.url),m.current&&w.current.delete(D),""):(w.current.delete(D),$.ok?(F(),I&&URL.revokeObjectURL(I.url),k(Z=>Z.map(V=>V.id===D?{...V,blob:$.blob,resized:$.resized}:V)),""):(URL.revokeObjectURL(B),z&&k(Z=>lye(Z,D,I)),sye($.problem,M.name||"image")))},[k]),j=y.useCallback(async M=>{i("");const I=b.current,E=[];let D=0,B=0;for(const G of M){if(!m.current||b.current!==I)return;const z=v.current.indexOf(G);if(z!==-1&&v.current.splice(z,1),h.current.length>=qo){D++;continue}const F=h.current.length,$=await N(G);$&&E.push($),h.current.length>F&&B++}if(!m.current||b.current!==I)return;D>0&&E.push(B===0&&E.length===0?qI:tye(D)),i(E.join(" "));const H=h.current.length;B>0&&d(`${B===1?"Image":`${B} images`} added, ${H} of ${qo}.`)},[N,i]),S=y.useCallback(async(M,I)=>{i("");const E=h.current.find(H=>H.id===M);if(!E)return j([I]);const D=await N(I,E);if(!m.current)return;i(D);const B=h.current.findIndex(H=>H.id===M);!D&&B!==-1&&d(`Image ${B+1} replaced, ${h.current.length} of ${qo}.`)},[j,N,i]),_=y.useCallback(M=>{const I=b.current;f.current=(f.current??Promise.resolve()).then(()=>b.current===I?M():void 0).catch(()=>{})},[]),T=y.useCallback(M=>{M.length!==0&&(v.current.push(...M),_(()=>j(M)))},[j,_]);y.useEffect(()=>{e&&e.waiting.length>0&&T(e.waiting)},[]);const L=y.useCallback((M,I)=>{const E=I[0];E&&_(()=>S(M,E))},[_,S]),A=y.useCallback(M=>{const I=h.current.find(E=>E.id===M);I&&(URL.revokeObjectURL(I.url),w.current.delete(M),k(E=>E.filter(D=>D.id!==M)),i(""),d(`Image removed, ${h.current.length} of ${qo}.`))},[k,i]),P=y.useCallback(()=>i(qI),[i]),O=y.useCallback(async()=>{const M=o.current;return await f.current,o.current!==M?null:h.current.flatMap(I=>I.blob?[I.blob]:[])},[]),U=y.useCallback(()=>({ready:h.current.flatMap(M=>M.blob&&!w.current.has(M.id)?[{name:M.name,blob:M.blob,resized:M.resized}]:[]),waiting:[...w.current.values(),...v.current]}),[]),q=y.useCallback(()=>{b.current++;for(const M of h.current)URL.revokeObjectURL(M.url);w.current.clear(),v.current=[],k(()=>[]),i("")},[k,i]);return{shots:t,problem:s.problem,problemId:s.id,announcement:c,add:T,replace:L,remove:A,sayFull:P,ready:O,kept:U,clear:q}}function uye(){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(Npe(s))}).catch(()=>{}),()=>{n=!1}},[]),e}function dye(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(!bn(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:Jge});return}const f=await fetch("/api/feedback",{...Yge(jpe(c),h),signal:d}),p=await f.json().catch(()=>null);n(f.ok&&(p!=null&&p.ok)?{state:"sent"}:{state:"failed",message:TI(f.status,p==null?void 0:p.reason,p==null?void 0:p.errors)})}catch{d.aborted||n({state:"failed",message:TI(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 hye(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),AI),i=window.setTimeout(()=>a.current(),AI+Fpe);return()=>{window.clearTimeout(o),window.clearTimeout(i)}},[e]),n}const l0="agent-dag.feedbackDrafts",UI=4;function fye({initialKind:e,initialBody:t}){return{kind:e??"bug",body:t??""}}function pye(e){return JSON.stringify([e.kind,e.body])}function mye(e){return e.ready.length+e.waiting.length}function LF(e,t){return e.body.trim()!==t.body.trim()||e.contact.trim()!==""||e.images>0}function gye(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 yye="Discard",wye="Confirm discard",xye="Clear the message, the screenshots and the contact",WI="Press again to clear this draft. It cannot be brought back.",vye={ready:[],waiting:[]};function bye(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!up.some(i=>i.value===n)||typeof s!="string"||s.length>rF||typeof a!="string"||a.length>aF||typeof o!="number"||!Number.isInteger(o)||o<0||o>qo?null:[e[0],{kind:n,body:s,contact:a,images:o}]}function kye(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(l0),c=i?JSON.parse(i):[];if(Array.isArray(c))for(const d of c.slice(-UI)){const h=bye(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(l0):o.setItem(l0,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??vye,imagesLost:i.images?0:i.imageCount}:null},keep(o,i,c){const d=mye(i.images);if(!LF({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<=UI)break;h.delete(f)}s()},forget:a}}function jye(){try{return typeof window>"u"?null:window.sessionStorage}catch{return null}}const B1=kye(jye),Nye=4e3;function Sye(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||B1.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&&B1.forget(e)},[a,e])}const HI="draft";function _ye(e){const[t,n]=y.useState(!1),s=y.useRef(0);y.useEffect(()=>{if(!t)return;const o=window.setTimeout(()=>n(!1),Nye);return()=>window.clearTimeout(o)},[t]);function a(){const o=Date.now(),i=ni({armedFor:t?HI:null,target:HI,armedAt:s.current,now:o,gapMs:ti});if(i==="arm"){n(!0),s.current=o;return}i!=="ignore"&&(n(!1),e())}return{armed:t,press:a}}function IF({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=ft(e,{focusRef:s}),w=mt(e),v=fye({initialKind:t,initialBody:n}),b=pye(v),[k]=y.useState(()=>B1.read(b)),[N,j]=y.useState((k==null?void 0:k.kind)??v.kind),[S,_]=y.useState((k==null?void 0:k.body)??v.body),[T,L]=y.useState((k==null?void 0:k.contact)??""),[A,P]=y.useState((k==null?void 0:k.imagesLost)??0),[O,U]=y.useState(!1),[q,M]=y.useState(!1),[I,E]=y.useState(!1),D=cye(k==null?void 0:k.images),B=Cpe(uye()),{outcome:H,sending:G,send:z,clearFailure:F}=dye(D),$=H.state==="sent",W=hye($,e);Sye(b,v,{kind:N,body:S,contact:T},D,$);const Z=LF({body:S,contact:T,images:D.shots.length},v),V=_ye(()=>{var ye;j(v.kind),_(v.body),L(""),P(0),M(!1),D.clear(),F(),(ye=s.current)==null||ye.focus()}),Y=sF(N),X=q&&!CI(S),J=A>0&&D.shots.length===0,Q=[X&&"fb-body-error",J&&"fb-images-lost"].filter(Boolean).join(" ")||void 0,[te,ce]=Ope(Ku());y.useEffect(()=>{var Pe,Ue;const ye=i.current;if(!ye)return;const Ie=ye.contains(document.activeElement)||Bn(((Pe=document.activeElement)==null?void 0:Pe.tagName)??null);ye.inert=$,$&&Ie&&((Ue=a.current)==null||Ue.focus())},[$]),y.useEffect(()=>{var $e,Je;const ye=c.current;if(!ye)return;const Ie=h.current;if(G){const Qe=document.activeElement,ze=Qe!=null&&(ye.contains(Qe)||Qe===Ie);f.current=ze?Qe:null,ye.inert=!0,Ie&&(Ie.inert=!0),f.current&&(($e=d.current)==null||$e.focus());return}ye.inert=!1,Ie&&(Ie.inert=!1);const Pe=f.current;f.current=null;const Ue=document.activeElement===d.current||Bn(((Je=document.activeElement)==null?void 0:Je.tagName)??null);!$&&Pe&&Ue&&Pe.focus()},[G,$]);function ue(ye){var Ie;if(ye.preventDefault(),!CI(S)){M(!0),(Ie=s.current)==null||Ie.focus();return}z({kind:N,body:S,contact:T})}const ie=!$&&!G,re=ye=>Vge(Array.from(ye.dataTransfer.types));function fe(ye){!re(ye)||!ie||(ye.preventDefault(),p.current++,E(!0))}function ae(ye){re(ye)&&(ye.preventDefault(),ye.dataTransfer.dropEffect=ie?"copy":"none")}function je(ye){re(ye)&&(p.current=Math.max(0,p.current-1),p.current===0&&E(!1))}function me(ye){re(ye)&&(ye.preventDefault(),p.current=0,E(!1),ie&&D.add(Array.from(ye.dataTransfer.files)))}function pe(ye){ye.target!==ye.currentTarget||!re(ye)||(ye.preventDefault(),ye.dataTransfer.dropEffect="none")}function xe(ye){re(ye)&&ye.preventDefault()}function _e(ye){if(!ie)return;const Ie=Array.from(ye.clipboardData.files),Pe=ye.target,Ue=Pe instanceof HTMLTextAreaElement||Pe instanceof HTMLInputElement,$e=Array.from(ye.clipboardData.types).includes("text/plain");Gge({files:Ie.length,hasText:$e,intoTextField:Ue})&&(ye.preventDefault(),D.add(Ie))}return r.jsx("div",{className:"modal-backdrop",...w,role:"presentation",onDragOver:pe,onDrop:xe,"data-leaving":W||void 0,children:r.jsxs("div",{ref:m,className:"modal feedback-dialog",onClick:ye=>ye.stopPropagation(),onDragEnter:fe,onDragOver:ae,onDragLeave:je,onDrop:me,onPaste:_e,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:V.armed?WI:Dpe(H.state)}),r.jsxs("div",{className:"fb-stage",children:[r.jsxs("form",{ref:i,className:"fb-form",onSubmit:ue,onKeyDown:ye=>{Ipe(ye.nativeEvent)&&(ye.preventDefault(),ye.currentTarget.requestSubmit())},noValidate:!0,children:[r.jsxs("section",{ref:c,className:"modal-body fb-body",children:[r.jsx(bge,{kind:N,onChange:j}),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:rF,rows:5,placeholder:Y.placeholder,onChange:ye=>_(ye.target.value),"aria-invalid":X||void 0,"aria-describedby":Q,required:!0}),X&&r.jsx("p",{id:"fb-body-error",className:"fb-error",children:xpe}),r.jsx(aye,{images:D,addRef:o}),J&&r.jsx("p",{id:"fb-images-lost",className:"fb-hint",children:gye(A)}),r.jsxs("div",{className:"fb-tools",children:[r.jsx(rye,{images:D,buttonRef:o}),r.jsx(kge,{open:O,onToggle:()=>U(ye=>!ye)})]}),r.jsx(jge,{open:O,contact:T,onContact:L})]}),r.jsx("p",{className:"fb-facts",children:B?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"fb-facts-value",children:B})," — ",Epe]}):Tpe}),H.state==="failed"&&r.jsx("p",{className:"fb-error",role:"alert",children:H.message})]}),r.jsxs("div",{className:"fb-foot",children:[Z&&r.jsx("button",{ref:h,type:"button",className:`btn danger fb-discard${V.armed?" armed":""}`,onKeyDown:ye=>{ye.repeat&&ye.preventDefault()},onClick:V.press,title:V.armed?WI:xye,children:V.armed?wye:yye}),r.jsxs("span",{className:"fb-shortcut","aria-hidden":"true",children:[r.jsx("kbd",{"data-symbol":Ppe(te)||void 0,children:te}),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",...On(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…"})]})})]})]}),$&&r.jsxs("div",{className:"fb-done",children:[r.jsx(Qf,{}),r.jsx("p",{className:"fb-done-line",children:oF})]})]}),r.jsx("div",{className:"fb-drop","aria-hidden":"true","data-active":I||void 0,children:r.jsxs("div",{className:"fb-drop-frame",children:[r.jsx($F,{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 OF="Press Esc first if a key does nothing.",c0=[{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:"I",action:"Jira, once it is connected in Settings › Integrations",binds:["i","I"],integration:"jira"},{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:[]}]}],Cye=/ \([A-Z?]\)/g;function PF(e,t=()=>!0){const n=s=>s.integration===void 0||t(s.integration);return e&&c0.every(s=>s.rows.every(n))?c0:c0.map(s=>({...s,rows:s.rows.filter(n).filter(a=>e||a.chord||!a.binds.some(cP)).map(a=>e?a:{...a,action:a.action.replace(Cye,"")})})).filter(s=>s.rows.length>0)}const Eye="Single-key shortcuts are off.",DF="Settings › Keyboard",Tye=`Single-key shortcuts can be turned off in ${DF}.`;function Aye({onClose:e,onTour:t,onSettings:n}){const s=ft(e),a=mt(e),o=Yu(Ku()),i=qn(),c=cd(),d=PF(i,h=>ud(c,h));return r.jsx("div",{className:"modal-backdrop",...a,role:"presentation",children:r.jsxs("div",{ref:s,className:"modal key-help",onClick:h=>h.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:Eye})," Turn them back on in"," ",r.jsx("span",{className:"kh-place",children:DF}),". 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:d.map(h=>r.jsxs(y.Fragment,{children:[r.jsx("h3",{className:"kh-group",children:h.title}),h.rows.map(f=>r.jsxs("div",{className:"sc",children:[r.jsx("kbd",{children:o&&f.macCap?f.macCap:f.cap}),r.jsx("span",{children:f.action})]},`${h.title}:${f.cap}:${f.action}`))]},h.title))}),i&&r.jsxs("p",{className:"kh-foot",children:[OF," ",Tye]})]})]})})}function Rye(e,t){return`${e}#${t}`}function Mye(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=Rye(i.key,i.since);if(s.has(c)||xne(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 $ye(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 FF({rows:e,ours:t,dialogs:n}){return e===0?!1:t||n===0}function Lye(e){return e===1?"Account needs your attention":"Accounts need your attention"}function Iye(e){return`${e===1?"One Claude account needs":`${e} Claude accounts need`} you to sign in again.`}const Oye="Login expired",Pye="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.",Dye="The account stays marked in the Accounts panel. This will not ask again until it has worked and stopped again.";function Fye(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 Bye({request:e,waiting:t,busy:n,now:s,onAccept:a,onDecline:o,onLater:i}){const c=y.useRef(null),d=ft(i,{focusRef:c}),h=mt(i),f=no(n,"accept"),p=no(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 ",hN(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 qye(e){const t=y.useRef(!1),n=Uye(e),s=FF({rows:n?1:0,ours:t.current,dialogs:vn.dialogDepth()});return t.current=s,s?n:null}function Uye({lanPending:e,lanDeferred:t,lanBusy:n,answerLanPair:s,deferLanPair:a}){const{request:o,waiting:i}=Fye(e,t.current);return o?r.jsx(Bye,{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 Wye({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:Pye})]}):r.jsxs(r.Fragment,{children:[r.jsx("p",{id:"reauth-lead",className:"reauth-lead",children:Iye(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:Oye}),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:Dye,onClick:n,children:"Not now"}),a&&r.jsx("button",{type:"button",className:"btn primary",ref:s,onClick:()=>t(a),children:"Sign in again"})]})]})}function Hye({rows:e,onSignIn:t,onLater:n}){const s=y.useRef(null),a=ft(n,{focusRef:s}),o=mt(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:Lye(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(Wye,{rows:e,onSignIn:t,onLater:n,firstRef:s})]})})}function zye({rows:e,signingIn:t,signIn:n,signedIn:s,refresh:a,closeSignIn:o,later:i,pairing:c=!1}){const d=y.useRef(!1),h=vn.dialogDepth()+(c?1:0),f=t!=null||FF({rows:e.length,ours:d.current,dialogs:h});return d.current=f,t?r.jsx(BD,{email:t.email||null,onClose:o,onChanged:a,onSignedIn:s}):f?r.jsx(Hye,{rows:e,onSignIn:n,onLater:i},e.length===1?"one":"many"):null}const Vye={"//":["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.46.0":[{title:"🔗 Jira, GitHub and GitLab panels are easier to read and navigate",body:"Jira rows show each issue's status, lists answer the arrow keys and fit a phone, and a failed refresh says “Not updated”."},{title:"📡 Radar finds more Claude Code processes on Linux",body:"It now sees Claude Code started from its versioned install folder, plus connection attempts that got no reply and the telemetry variables it was launched with."},{title:"🗺️ Plans are easier to follow on the session canvas",body:"A session's plan now shows on its note and as “plan 2/5” at every zoom. Subagents line up in one column, closer to their parent."},{title:"✅ The active account follows your Claude Code login",body:"After a /login, the accounts panel, Switch, Auto-switch and Usage use the account Claude Code is signed in to. Auto-switch can now be set up while it is off."},{title:"📊 Account capacity and the Reset calendar have their own buttons",body:"Both open from the left stripe, under Claude accounts, instead of from the small gauge in the accounts panel's header."},{title:"🧩 Skill activity has its own button and counts typed skills",body:"It opens from the right stripe. To count skills you start with a slash command, the deck now adds a UserPromptExpansion hook to Claude Code's settings.json (2.1.116 or newer); AGENTS_DECK_SKILL_HOOK=0 leaves it out."},{title:"📈 Load history keeps the reading you click",body:"Click a minute on a chart to keep its reading. Saved limit resets now show their expiry time, and Tool activity has a clearer icon."}],"3.45.0":[{title:"🔗 Read-only Jira, GitHub and GitLab panels beside your agents",body:"Settings › Integrations connects Jira (Cloud, Server or Data Center), GitHub, and GitLab.com or your own GitLab, each with a token, and a control on the left stripe opens its panel: a Jira board's backlog in Jira's own order, or a project's branches, pull or merge requests, pipelines and issues, with the item beside the list. The panels only read: they never comment, merge, re-run a job or change an issue. The token stays on this machine, in a file only you can read, and goes only to that connection's own API. Nothing is read until you connect a tracker, and then only while its panel is open."},{title:"📤 Each account says what its organization's telemetry sends",body:"A Team or Enterprise organization can turn on Claude Code's telemetry for every member, and Claude Code applies it without asking. Each account of such an organization now carries a line under its name: “Telemetry · usage data”, or “Telemetry · prompts, tool details” in the warning colour when your prompts and tool details are sent too. Its tooltip names the organization and where the data goes. After a switch, Auto-switch's notification and the row's “Now active” note say it too. The deck changes nothing; it learns what the organization turns on from a Claude Code session run on one of its accounts, and until then that account shows no line."},{title:"⚠️ A warning when a paired deck is on the same Claude login",body:"A Claude login renews once, so when two machines use one copied login, the one that renews second is signed out. When a paired deck on Local network says it is on the login this deck is using, the live account's row now says “Also active on” and names that deck, with what to do: use a different account on one of the machines, or sign in on each one separately. A switch onto such a login says so too, and so does one desktop notification per incident, “Login active on another deck” in Settings › Notifications, which is on by default."},{title:"📱 A phone opens one panel at most when the deck loads",body:"On a window 640 px wide or less, a reload used to open Accounts, Usage and the machine panel on top of each other, with none of the board in sight. It now opens at most one of them, preferring Usage over the machine panel, and Accounts and the session list open from the dock. A wider window loads exactly as before, and nothing you chose is forgotten."}],"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.
117
+
118
+ 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.
119
+
120
+ 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.
121
+
122
+ 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.
123
+
124
+ 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.
125
+
126
+ 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.
127
+
128
+ 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".
129
+
130
+ **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.
131
+
132
+ \`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.
133
+
134
+ **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.
135
+
136
+ 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.
137
+
138
+ 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.
139
+
140
+ 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.
141
+
142
+ 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.
143
+
144
+ 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.
145
+
146
+ 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.
147
+
148
+ What you are reading is the first version that does not.
149
+
150
+ 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.
151
+
152
+ 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.
153
+
154
+ 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.
155
+
156
+ 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.
157
+
158
+ 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.
159
+
160
+ 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.
161
+
162
+ The count of what is behind it is on the heading's tooltip, so collapsing it does not hide how much there is.
163
+
164
+ **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.
165
+
166
+ 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.
167
+
168
+ \`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.
169
+
170
+ 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.
171
+
172
+ **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.
173
+
174
+ **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.
175
+
176
+ **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.
177
+
178
+ **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.
179
+
180
+ **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.
181
+
182
+ **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.
183
+
184
+ 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.
185
+
186
+ 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.
187
+
188
+ 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.
189
+
190
+ 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.
191
+
192
+ 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.
193
+
194
+ 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.
195
+
196
+ 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.
197
+
198
+ 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.
199
+
200
+ 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.
201
+
202
+ 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.
203
+
204
+ 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.
205
+
206
+ 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.
207
+
208
+ 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.
209
+
210
+ 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.
211
+
212
+ 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.
213
+
214
+ 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.
215
+
216
+ 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.
217
+
218
+ 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.
219
+
220
+ 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.
221
+
222
+ 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.
223
+
224
+ 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.
225
+
226
+ 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.
227
+
228
+ 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.
229
+
230
+ 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.
231
+
232
+ 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.
233
+
234
+ 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.
235
+
236
+ 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.
237
+
238
+ 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.
239
+
240
+ 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.
241
+
242
+ 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.
243
+
244
+ 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.
245
+
246
+ 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.
247
+
248
+ 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.
249
+
250
+ 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.
251
+
252
+ 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.
253
+
254
+ 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.
255
+
256
+ 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.
257
+
258
+ 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.
259
+
260
+ 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.
261
+
262
+ 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".
263
+
264
+ 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.
265
+
266
+ 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.
267
+
268
+ 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.
269
+
270
+ 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.
271
+
272
+ 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.
273
+
274
+ 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.
275
+
276
+ 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.
277
+
278
+ 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.
279
+
280
+ 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.
281
+
282
+ 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.
283
+
284
+ 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.
285
+
286
+ 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.
287
+
288
+ 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.
289
+
290
+ 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.
291
+
292
+ 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.
293
+
294
+ 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.
295
+
296
+ 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.
297
+
298
+ 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.
299
+
300
+ 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.
301
+
302
+ 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.
303
+
304
+ 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.
305
+
306
+ 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.
307
+
308
+ 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.
309
+
310
+ 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.
311
+
312
+ 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.`}]},QN="agent-dag.releaseNotesSeen";function zI(e){return e.split(/[.\-+]/).map(t=>parseInt(t,10)).map(t=>Number.isNaN(t)?0:t)}function ai(e,t){const n=zI(e),s=zI(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 ao(e){return typeof e=="string"&&/^\d+\.\d+\.\d+/.test(e)}function Gye(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 Kye(e){if(!e||typeof e!="object")return[];const t=[];for(const[n,s]of Object.entries(e)){if(!ao(n)||!Array.isArray(s))continue;const a=s.filter(Gye);a.length&&t.push({version:n,notes:a})}return t.sort((n,s)=>ai(s.version,n.version))}const VI=Kye(Vye);function BF(e,t,n){return e.filter(s=>ai(s.version,n)<=0&&(t===null||ai(s.version,t)>0))}function Yye(e,t){return e.filter(n=>ai(n.version,t)===0)}function Xye(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 Zye({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&&ao(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(!ao(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=ai(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 Jye=new RegExp("^(?:\\p{Extended_Pictographic}|\\p{Emoji_Modifier}|\\p{Regional_Indicator}|[\\u200D\\uFE0F])+(?= \\S)","u");function Qye(e){const t=Jye.exec(e);return t?{icon:t[0],rest:e.slice(t[0].length)}:{icon:null,rest:e}}function ewe(e){if(!e)return null;let t=null;try{t=e.getItem(QN)}catch{return null}return ao(t)?t:null}function twe(e){if(!e)return!1;try{return e.getItem(QN),!0}catch{return!1}}function nwe(e,t){if(!e)return!1;try{return e.setItem(QN,t),!0}catch{return!1}}const qF="agent-dag.tourSeen";function swe(e){if(!e)return!1;try{return e.getItem(qF)==="1"}catch{return!1}}function rwe(e){if(!e)return!1;try{return e.setItem(qF,"1"),!0}catch{return!1}}function awe({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 owe({stored:e,running:t,notes:n,remembers:s=!0}){if(!ao(t))return{show:[],record:null,reason:"no-version"};if(!ao(e)){if(!s)return{show:[],record:t,reason:"cannot-remember"};const i=Yye(n,t);return i.length?{show:i,record:t,reason:"welcome"}:{show:[],record:t,reason:"first-run"}}const a=ai(e,t);if(a===0)return{show:[],record:null,reason:"seen"};if(a>0)return{show:[],record:null,reason:"ahead"};const o=BF(n,e,t);return o.length?{show:o,record:t,reason:"new-notes"}:{show:[],record:t,reason:"nothing-new"}}function iwe(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 UF(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=iwe(e,o);if(i>0){a(),n.push({kind:"bold",kids:UF(e.slice(o+2,i),!1)}),o=i+2;continue}}s+=e[o],o+=1}return a(),n}function oo(e=typeof navigator>"u"?"":navigator.userAgent){return/\bccdeck-desktop\/\d/.test(e)}function Hke(e,t,n){if(e===null)return null;const s=e+t-n;return s>0?s:null}function zke(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 lwe(e){return(e??[]).filter(t=>t.installed&&t.profiles>0)}function Vke(e){return!Number.isFinite(e)||e<=0?"empty":Zr(e)}function Gke(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 cwe(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 Kke(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=lwe(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 uwe="Check for updates",WF="Ask npm now whether a newer ccdeck is out.",GI="Checking…",dwe="Couldn't reach npm. Try again.",hwe="Couldn't reach the deck. Try again.",HF="Update checks are off on this deck (AGENTS_DECK_NO_UPDATE_CHECK or AGENTS_DECK_NO_INSTALL).",fwe="The deck looks again in five minutes.";function pwe(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 Mn=(e,t={})=>({said:e,tone:"answer",age:null,command:null,action:null,...t}),Oo=e=>Mn(e,{tone:"note"});function KI(e,t){return cwe(e,t)??"just now"}function mwe(e,t){const n=e.update;return(n==null?void 0:n.status)==="ready"?Oo(`${n.version} is ready. Restart to update.`):(n==null?void 0:n.status)==="checking"?Oo("The app is checking for updates…"):(n==null?void 0:n.status)==="downloading"?Oo(n.version?`${n.version} is out. The app is downloading it.`:"The app is downloading an update."):(n==null?void 0:n.status)==="current"?Oo(`You're on the latest, ${e.version??t}. You can check again here.`):(n==null?void 0:n.status)==="error"?Oo("The app's last update check failed. Try Check for updates again."):Oo("The app keeps itself up to date. Check for updates here.")}function gwe(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 Mn(`${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 Mn(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 Mn(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:`:pwe(t,n,s==null?void 0:s.upgradeBlocked,(s==null?void 0:s.upgradeMode)==="npx"),o=(s==null?void 0:s.command)??null;return Mn(a,{command:o,action:o?{kind:"copy",label:e.copied?"Copied":"Copy",busy:!1}:null})}function ywe(e){const t=e.version;if(e.unreachable)return Mn(hwe,{tone:"warn"});const n=t!=null&&t.checkFailedAt&&t.checkFailedAt>(t.checkedAt??0)?t.checkFailedAt:null;if(n)return Mn(dwe,{tone:"warn",age:e.answered?null:`Last tried ${KI(n,e.now)}.`});const s=t!=null&&t.latestPending&&t.latestPending!==e.running?t.latestPending:null;if(s)return Mn(`${s} is tagged on npm but can't be installed yet. ${fwe}`);const a=t!=null&&t.checkedAt?KI(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 Mn(o,{age:a?`Checked ${a}.`:null})}return Mn("",{age:a?`Last checked ${a}.`:null})}function wwe(e,t){var a,o;const n=e.version;if((a=e.app)!=null&&a.inApp&&(n!=null&&n.checkDisabled)){const i=mwe(e.app,e.running);return i&&{canCheck:!0,checking:e.checking||((o=e.app.update)==null?void 0:o.status)==="checking",line:e.unreachable?Mn("The desktop updater did not accept the check. Try the ccdeck menu or update the desktop app.",{tone:"warn"}):e.checking?Mn(GI):i}}if(n!=null&&n.checkDisabled)return{canCheck:!1,checking:!1,line:Oo(HF)};const s=(n==null?void 0:n.notice)??null;if((s==null?void 0:s.kind)==="upgrade")return{canCheck:!0,checking:e.checking,line:gwe(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:Mn(i)}}return e.checking?{canCheck:!0,checking:!0,line:Mn(GI)}:{canCheck:!0,checking:!1,line:ywe(e)}}const zF=450;async function xwe(e,t=n=>new Promise(s=>setTimeout(s,n))){const[n]=await Promise.all([e(!0),t(zF)]);return n?"answered":"unreachable"}async function vwe(e=fetch){try{const[t]=await Promise.all([e("/api/desktop-update/check",{method:"POST",signal:AbortSignal.timeout(8e3)}),new Promise(n=>setTimeout(n,zF))]);return t.ok?"answered":"unreachable"}catch{return"unreachable"}}const q1="Eight pictures of what the deck shows.",YI="Restart the deck. Sessions, settings and pairings come back as they were.";function bwe(e){var L;const t=(e==null?void 0:e.versionCheck.versionChecking)??!1,n=Cr(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:v,running:b,onHandOff:k}=e,N=wwe({version:p.version,running:b,checking:s||t,answered:d,unreachable:i,now:n,upgradeState:m.upgradeState,copied:m.cmdCopied,restarting:w.restarting,app:{inApp:oo(),update:v.appUpdate,version:xF(),menu:bF()}},D1);if(!N)return null;const j=oo()&&((L=p.version)==null?void 0:L.checkDisabled);return{state:N,check:async()=>{var P;if(!bn(o.current||t)||j&&((P=v.appUpdate)==null?void 0:P.status)==="checking")return;o.current=!0,a(!0);const A=j?await vwe():await xwe(p.loadVersion);o.current=!1,a(!1),c(A==="unreachable"),h(!0)},act:A=>{if(A.kind==="copy")return void m.copyCommand();k(),p.showNotice(),A.kind==="install"?m.startUpgrade():w.askRestart({upgrade:!0})},checkWhy:j?"Ask the desktop app whether a newer ccdeck is out.":WF}}function kwe({onTour:e,onRestart:t,updateCheck:n}){var h,f;const s=zl("above","dialog"),a=bwe(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:q1}),children:[r.jsx(Roe,{}),"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(Moe,{}),uwe]}),d&&r.jsxs("button",{type:"button",className:"btn rn-act rn-act-restart",onClick:d,"aria-describedby":`${o}-restart`,...s.bind({label:YI}),children:[r.jsx($oe,{}),"Restart"]})]}),a&&r.jsx(jwe,{line:a.state.line,onAct:a.act,bindHint:s.bind,whyId:`${o}-act`}),r.jsx("span",{hidden:!0,id:`${o}-tour`,children:q1}),r.jsx("span",{hidden:!0,id:`${o}-check`,children:(a==null?void 0:a.checkWhy)??WF}),r.jsx("span",{hidden:!0,id:`${o}-restart`,children:YI}),s.node]})}function jwe({line:e,onAct:t,bindHint:n,whyId:s}){const{action:a}=e,o=a&&r.jsx(Nwe,{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 Nwe({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 Swe({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=ft(a),w=mt(a),v=Xye(e);return r.jsx("div",{className:"modal-backdrop",...w,role:"presentation",children:r.jsxs("div",{ref:m,className:"modal release-notes",onClick:b=>b.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"}),v&&r.jsx("span",{className:"modal-tool-id",children:v})]}),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…":$l})]}),r.jsx("p",{className:"rn-update-said",role:"status",children:h})]}),r.jsx("p",{className:"modal-note",children:Zye({since:t,running:n,firstRun:s,entries:e})}),r.jsx(kwe,{onTour:i?void 0:o,onRestart:f,updateCheck:p}),e.map(b=>r.jsxs("section",{className:"modal-section",children:[r.jsxs("h3",{className:"rn-version",children:["v",b.version]}),r.jsx("ul",{className:"rn-notes",children:b.notes.map((k,N)=>{const{icon:j,rest:S}=Qye(k.title);return r.jsxs("li",{className:"rn-note",children:[r.jsxs("p",{className:"rn-note-title",children:[j&&r.jsx("span",{className:"rn-note-icon",children:j}),S]}),r.jsx("p",{className:"rn-note-body",children:VF(UF(k.body))})]},N)})})]},b.version))]})]})})}function VF(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:VF(t.kids)},n))}function _we({state:e,sessionId:t,onClose:n}){const s=y.useMemo(()=>Cwe(e,t),[e,e.revision,t]),a=y.useRef(null),o=ft(n,{focusRef:a}),i=mt(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:PP}),r.jsx("div",{className:"ss-cost",children:st(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":_p(c),title:c,children:to(c)},c))})]}),r.jsx("div",{className:"ss-hero-right",children:s.cost.total>0&&r.jsxs(r.Fragment,{children:[r.jsx(Yj,{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:st(s.cost.input)})]}),r.jsxs("span",{className:"ssl ssl-out",children:["output ",r.jsx("b",{children:st(s.cost.output)})]}),r.jsxs("span",{className:"ssl ssl-cr",children:["cache r ",r.jsx("b",{children:st(s.cost.cacheRead)})]}),r.jsxs("span",{className:"ssl ssl-cw",children:["cache w ",r.jsx("b",{children:st(s.cost.cacheWrite)})]})]})]})})]}),r.jsxs("section",{className:"ss-stats",children:[r.jsx(Qi,{label:"agents",value:s.agentCount}),r.jsx(Qi,{label:"subagents",value:s.subagentCount}),r.jsx(Qi,{label:"tool calls",value:s.toolCount}),r.jsx(Qi,{label:"prompts",value:s.promptCount}),r.jsx(Qi,{label:"tokens",value:s.tokensSum.toLocaleString()}),s.errCount>0&&r.jsx(Qi,{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 Qi({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 Cwe(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,v=0;for(const S of s){const _=Fn(S);a.input+=_.input,a.output+=_.output,a.cacheRead+=_.cacheRead,a.cacheWrite+=_.cacheWrite,a.total+=_.total;for(const L of C4(S))o.add(L);S.model&&o.add(S.model),S.kind==="subagent"&&p++;const T=i4(S.prompts);d+=T.length,!m&&T.length>0&&(m=T[0].text),h+=S.usage.inputTokens+S.usage.outputTokens,c+=S.toolCount,f+=S.toolErrorCount??0;for(const[L,A]of S.toolCountByName??[])i.set(L,(i.get(L)??0)+A);w=Math.min(w,S.startedAt),v=Math.max(v,S.endedAt??Date.now())}const b=Math.max(0,v-w),k=Math.floor(b/1e3),N=k<60?`${k}s`:k<3600?`${Math.floor(k/60)}m ${String(k%60).padStart(2,"0")}s`:`${Math.floor(k/3600)}h ${Math.floor(k%3600/60)}m`,j=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:N,cost:a,modelChips:Array.from(o),agentCount:s.length,subagentCount:p,toolCount:c,promptCount:d,tokensSum:h,errCount:f,topTools:j,firstPrompt:m}}function Bt({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 ut({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 GF(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||!bn(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 XI({provider:e}){const t=e==="Codex"?"recoverCodexSessions":"recoverClaudeSessions",n=`${e.toLowerCase()}-session-recovery`,s=GF(t,!0);return r.jsxs(Bt,{id:`${n}-title`,title:`${e} sessions`,note:"Choose what appears after ccdeck starts.",children:[r.jsx(ut,{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,...On(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(Ewe,{})]})}function Ewe(){const e=GF("continueStopped",!1);return r.jsxs(r.Fragment,{children:[r.jsx(ut,{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,...On(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 KF="agent-dag.character",yf=[{id:"deck",name:"Deck companion"},{id:"fox",name:"Fox"},{id:"penguin",name:"Penguin"}];function Twe(e){return e==="fox"||e==="penguin"?e:"deck"}function Awe(){return Twe(Ke(KF))}const Rwe="With no deck tab open, get a notification wherever a sound would have played.",Mwe="With the ccdeck window closed, get a notification wherever a sound would have played.";function $we(e){return e?Mwe:Rwe}const Lwe="Held off for this run — the deck was started with alerts disabled. Your choice is saved for the next start.",YF=[{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"},{kind:"notifyElsewhere",label:"Login active on another deck",title:"When a paired deck is on the same Claude login as this one — when one renews it, the other is signed out"}],Iwe="For the Claude and Codex accounts you're on, whether or not the deck is open.",Owe="Held off for this run too.",ZI="Get notified when you're away from this tab.";function Pwe(e){switch(e){case"granted":return{status:"Enabled",ask:!1,ok:!0,note:ZI};case"default":return{status:null,ask:!0,ok:!1,note:ZI};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 XF="section:";function ZF(e){return e.id.startsWith(XF)}const Dwe={general:["behaviour","behavior","preferences"],appearance:["look","style"],reading:["readability","legibility"],keyboard:["shortcuts","hotkeys","keybindings","keys"],notifications:["alerts","notify"],sounds:["audio","tones","chimes"],integrations:["jira","atlassian","tracker","issues","connect","token","board","sprint"],data:["privacy","local data"],radar:["telemetry","collector","monitoring"],about:["information"]},Fwe={done:"Turn finished","needs-input":"Claude is asking"},Bwe={done:["done","complete","finished","end of turn","volume","preview","chime","tone"],"needs-input":["question","needs input","permission","waiting","volume","preview","chime","tone"]},qwe={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"],notifyElsewhere:["login","signed out","local network","another deck","same account","alerts"]},eS=e=>{var t;return((t=lp.find(n=>n.id===e))==null?void 0:t.label)??e};function Uwe(e){return{id:`${XF}${e}`,section:e,label:eS(e),keywords:Dwe[e]}}function Wwe(){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"]},...Qr.map(t=>({id:`theme-${t}`,section:"appearance",group:"Theme",label:id[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",...yf.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"]},...YF.map(({kind:t,label:n})=>({id:t,section:"notifications",group:"Accounts",label:n,keywords:qwe[t]}))],sounds:[{id:"play-sounds",section:"sounds",label:"Play sounds",keywords:["sound","mute","unmute","silence","quiet"]},...hu.map(t=>({id:`tone-${t}`,section:"sounds",label:Fwe[t],keywords:Bwe[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"]}],integrations:[{id:"integrations-add",section:"integrations",label:"Add integration",keywords:["connect","jira","jira cloud","jira server","data center","api token","personal access token","pat"]},{id:"integrations-connections",section:"integrations",label:"Connections",keywords:["disconnect","reconnect","test connection","edit","token","expired","jira"]}],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 lp.flatMap(({id:t})=>[Uwe(t),...e[t]])}const U1=Wwe();function Hwe(e,t="all"){return e&&t==="all"?U1:U1.filter(n=>(e||!n.claudeOnly)&&(n.section!=="integrations"||t==="all"||t==="connections"&&n.id!=="integrations-add"))}function JF(e){if(ZF(e))return"Section";const t=eS(e.section);return e.group&&e.group!==e.label?`${t} › ${e.group}`:t}function zwe(e){return`${e.label}, ${JF(e).replace(/ › /g,", ")}`}function su(e){return e.normalize("NFD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/\s+/g," ").trim()}function Jh(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 Vwe(e,t){const n=su(e.label);if(n.startsWith(t))return 0;if(Jh(n,t))return 1;const s=e.keywords.map(su);if(s.some(i=>Jh(i,t)))return 2;const a=[su(eS(e.section)),...e.group?[su(e.group)]:[]];if(a.some(i=>Jh(i,t)))return 3;const o=t.split(" ");if(o.length>1){const i=[n,...s,...a];if(o.every(c=>i.some(d=>Jh(d,c))))return 4}return null}const Gwe=12;function Kwe(e,t=U1){const n=su(e);return n?t.map((s,a)=>({entry:s,at:a,score:Vwe(s,n)})).filter(s=>s.score!==null).sort((s,a)=>s.score-a.score||s.at-a.at).slice(0,Gwe).map(s=>s.entry):[]}function QF(e,t){const n=t.trim();return e===0?`No setting matches “${n}”.`:e===1?`1 setting matches “${n}”`:`${e} settings match “${n}”`}function Ywe(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 Xwe="Hide finished sessions after",Zwe="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 Jwe(){const e=z6();return r.jsx(Bt,{id:"settings-board-caption",title:"Board",children:r.jsx(ut,{settingId:"hide-finished",name:Xwe,nameId:"settings-hide-finished-label",note:Zwe,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=>nfe(Number(t.target.value)),children:q6.map(t=>r.jsx("option",{value:t,children:tfe(t)},t))})})})}const Qwe="Accounts and auto-switch",exe="Your Claude accounts, and Auto-switch, which moves Claude Code to another one before the account in use runs out.",txe="Local network",nxe="Pairing with the decks on your other machines, so a login that expires on one is repaired from another.",sxe="Browser Watch",rxe="Whether something drove your browser while you were away, and what the deck does about it.";function axe({claudeHere:e,singleKeys:t,doors:n}){return r.jsxs(Bt,{id:"settings-elsewhere-caption",title:"Elsewhere on the deck",children:[e&&r.jsx(u0,{settingId:"accounts",name:Qwe,note:exe,onOpen:n.accounts,cap:t?{key:"A",title:"Press A anywhere to show or hide the accounts panel"}:null}),e&&r.jsx(u0,{settingId:"local-network",name:txe,note:nxe,onOpen:n.localNetwork,cap:null}),r.jsx(u0,{settingId:"browser-watch",name:sxe,note:rxe,onOpen:n.browserWatch,dialog:!0,cap:t?{key:"B",title:"Press B anywhere to open or close Browser Watch"}:null})]})}function u0({settingId:e,name:t,note:n,onOpen:s,cap:a,dialog:o=!1}){const i=`settings-${e}`;return r.jsx(ut,{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 oxe="Single-key shortcuts",ixe="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 lxe(e){const t=e.binds.includes("?")?"the keyboard shortcuts sheet":e.action;return t.charAt(0).toUpperCase()+t.slice(1)}function cxe(e,t){const n=t.trim().toLowerCase();return n?[e.action,e.cap,e.macCap??""].some(s=>s.toLowerCase().includes(n)):!0}function uxe({singleKeys:e,onToggleSingleKeys:t}){const n=Yu(Ku()),[s,a]=y.useState(""),o=y.useId(),i=cd(),c=PF(e,d=>ud(i,d)).map(d=>({...d,rows:d.rows.filter(h=>cxe(h,s))})).filter(d=>d.rows.length>0);return r.jsxs(r.Fragment,{children:[r.jsx(Bt,{children:r.jsx(ut,{settingId:"single-keys",name:oxe,nameId:"settings-single-keys-label",note:ixe,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:d=>a(d.target.value),onKeyDown:d=>{O4(d.key)&&s&&(d.stopPropagation(),a(""))}})]}),c.map(d=>{const h=`settings-keys-${d.title.toLowerCase().replace(/[^a-z]+/g,"-")}`;return r.jsx(Bt,{id:h,title:d.title,className:"settings-keys",children:d.rows.map(f=>r.jsx(ut,{as:"div",name:lxe(f),control:r.jsx("kbd",{className:"settings-key",children:n&&f.macCap?f.macCap:f.cap})},`${f.cap}:${f.action}`))},d.title)}),c.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:OF})]})}function dxe({notifyOn:e,onToggleNotify:t,notifyVetoed:n,notifyPermission:s,onAskNotify:a,accountNotify:o,onToggleAccountNotify:i}){const c=Pwe(s),d=oo(),h=e&&!n&&!d,f=y.useRef(null),p=Jr(!c.ask,f);return r.jsxs(r.Fragment,{children:[r.jsxs(Bt,{id:"sm-closed-caption",title:"While the deck is closed",children:[r.jsx(ut,{settingId:"notify-closed",name:"Notifications while closed",nameId:"sm-notify-label",note:n?Lwe:$we(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(ut,{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(Bt,{id:"sm-accounts-caption",title:"Accounts",note:n?Owe:Iwe,children:YF.map(({kind:m,label:w,title:v})=>r.jsx(ut,{settingId:m,name:w,nameId:`sm-${m}-label`,note:v,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 e8({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==="integrations"&&r.jsxs(r.Fragment,{children:[r.jsx("path",{d:"M5.1 1.6v2.6M8.9 1.6v2.6"}),r.jsx("path",{d:"M3.4 4.2h7.2v2.3a3.6 3.6 0 0 1-7.2 0z"}),r.jsx("path",{d:"M7 10.1v2.3"})]}),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 hxe=["audio/webm;codecs=opus","audio/ogg;codecs=opus","audio/mp4"];function fxe(e){return hxe.find(t=>e(t))}const pxe=4400;function mxe(e){const t=e.split(";")[0];return{name:`Recorded voice.${t==="audio/mp4"?"m4a":t==="audio/ogg"?"ogg":"webm"}`,type:t}}function gxe({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=fxe(k=>MediaRecorder.isTypeSupported(k)),v=new MediaRecorder(p,w?{mimeType:w}:void 0),b=[];i.current=v,v.ondataavailable=k=>{k.data.size&&b.push(k.data)},v.onerror=()=>t("Recording failed. Please try again."),v.onstop=()=>{p.getTracks().forEach(S=>S.stop()),c.current!==null&&clearTimeout(c.current),c.current=null;const k=i.current===v;if(k&&(i.current=null),o(!1),!k||!b.length)return;const N=mxe(v.mimeType),j=new File(b,N.name,{type:N.type});n(()=>s(j))},v.start(200),o(!0),c.current=setTimeout(h,pxe)}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 yxe({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"),[v,b]=y.useState([]);return y.useEffect(()=>{if(typeof window>"u"||!("speechSynthesis"in window))return;const k=()=>{b(window.speechSynthesis.getVoices())};return k(),window.speechSynthesis.addEventListener("voiceschanged",k),()=>window.speechSynthesis.removeEventListener("voiceschanged",k)},[]),r.jsxs("details",{className:"sm-voice",children:[r.jsxs("summary",{className:"settings-row",...t,onClick:k=>{const N=k.currentTarget.parentElement;e&&N&&!N.open&&k.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:k=>o(k.target.value)})]}),r.jsxs("label",{children:[r.jsx("span",{children:"Text"}),r.jsx("input",{className:"ap-manage-input",value:i,maxLength:180,onChange:k=>c(k.target.value)})]}),r.jsxs("label",{children:[r.jsx("span",{children:"Voice"}),r.jsxs("select",{className:"sm-select",value:d,onChange:k=>h(k.target.value),children:[r.jsx("option",{value:"",children:"System default"}),v.map(k=>r.jsx("option",{value:k.voiceURI,children:k.name},k.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:k=>p(k.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:k=>w(k.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 wxe({customAssets:e,onImportCustom:t,onCreateVoice:n,onRenameCustom:s,onPreviewCustom:a,onDeleteCustom:o}){const[i,c]=y.useState(""),d=e.length,h=N1(d),f=h!==null,p=f?{"aria-disabled":!0,"aria-describedby":"sm-custom-full"}:{},[m,w]=y.useState(null),v=y.useRef(0),b=y.useRef(new Map),k=y.useRef(null),N=y.useRef(null);y.useEffect(()=>{if(!m)return;const A=window.setTimeout(()=>w(null),4e3);return()=>window.clearTimeout(A)},[m]);const j=async A=>{c("");try{await A()}catch(P){c(P instanceof Error?P.message:"Custom audio could not be saved.")}},S=(A,P)=>{const O=Date.now(),U=ni({armedFor:m,target:A,armedAt:v.current,now:O,gapMs:ti});if(U==="arm"){w(A),v.current=O;return}if(U==="ignore")return;w(null);const q=Mie(e.map(M=>M.id),A);j(async()=>{var I;await o(A);const M=document.activeElement;M!==P&&!Bn((M==null?void 0:M.tagName)??null)||(I=q?b.current.get(q):k.current)==null||I.focus()})},{recording:_,startRecording:T,stopRecording:L}=gxe({full:f,setCustomError:c,runCustom:j,onImportCustom:t});return r.jsxs(Bt,{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 ",j1]}),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(ut,{as:"div",settingId:"custom-import",name:"Import audio",note:"WAV, MP3 or OGG",control:r.jsx("button",{ref:k,type:"button",className:"btn sm-custom-action",...p,onClick:()=>{var A;f||(A=N.current)==null||A.click()},children:"Choose file"}),children:r.jsx("input",{ref:N,type:"file",hidden:!0,accept:"audio/wav,audio/x-wav,audio/mpeg,audio/mp3,audio/ogg,.wav,.mp3,.ogg",onChange:A=>{var O;const P=(O=A.target.files)==null?void 0:O[0];A.currentTarget.value="",P&&!f&&j(()=>t(P))}})}),r.jsx(ut,{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:L,children:"Stop & save"}):r.jsx("button",{type:"button",className:"btn sm-custom-action",...p,onClick:()=>void T(),children:"Record"})}),r.jsx(yxe,{full:f,fullProps:p,runCustom:j,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:P=>{if(!P.target.value.trim()){P.target.value=A.name;return}j(()=>s(A.id,P.target.value))},onKeyDown:P=>{P.key==="Enter"&&P.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:P=>{P?b.current.set(A.id,P):b.current.delete(A.id)},className:`btn sm-custom-icon${m===A.id?" armed":""}`,onKeyDown:P=>{P.repeat&&P.preventDefault()},onClick:P=>S(A.id,P.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 xxe="A tone when a turn finishes, and when Claude asks for something.";function vxe({soundOn:e,onToggleSound:t}){const n=y.useId(),s=qn(),a=y.useId();return r.jsx(Bt,{children:r.jsx(ut,{settingId:"play-sounds",name:"Play sounds",nameId:n,note:xxe,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 W1="custom:";function JI(e){return`${W1}${e}`}function bxe(e){return e.startsWith(W1)?e.slice(W1.length):null}function kxe({id:e,label:t="Volume",value:n,step:s=kN,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:mf,max:rp,step:s,value:n,"aria-describedby":o,onChange:i=>a(Number(i.target.value)),style:{"--sm-level":`${(n-mf)/(rp-mf)*100}%`}}),r.jsxs("span",{className:"sm-read",children:[n,"%"]})]})}const QI={done:"Turn finished","needs-input":"Claude is asking"},jxe={done:"Plays when Claude or Codex finishes a turn.","needs-input":"Available in Claude Code only."};function Nxe({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(Bt,{id:`sm-name-${e}`,title:QI[e],note:jxe[e],settingId:`tone-${e}`,aside:r.jsxs("button",{type:"button",className:"btn sm-hear",onClick:()=>c(e),"aria-label":`Hear the ${QI[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(kxe,{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?JI(m):t.figure,onChange:w=>{const v=w.target.value,b=bxe(v);b!==null?h(e,b):(d(e),i(e,v))},children:[bN[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:JI(w.id),children:w.name},w.id))})]})]})]})}const Sxe="Claude Code isn't on this machine, so only Turn finished plays here — for Codex turns.";function _xe({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:v,onDeleteCustom:b}){var S;const k=Aie(d),N=((S=c.find(_=>_.id===k))==null?void 0:S.name)??"the same custom sound",j=k?`Both tones use “${N}”. They may be harder to tell apart.`:"";return r.jsxs("div",{className:"sm-sounds",children:[r.jsx(vxe,{soundOn:e,onToggleSound:t}),!s&&r.jsx("p",{className:"sm-note",children:Sxe}),!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:hu.map(_=>r.jsx(Nxe,{chime:_,tone:n[_],soundOn:e,customAssets:c,customSelections:d,onLevel:a,onFigure:o,onPreview:i,onBuiltInSelected:h,onCustomSelected:f},_))}),j&&r.jsx("p",{className:"sm-note","aria-hidden":!0,children:j}),r.jsx("p",{className:"vis-hidden",role:"status",children:j}),r.jsx(wxe,{customAssets:c,onImportCustom:p,onCreateVoice:m,onRenameCustom:w,onPreviewCustom:v,onDeleteCustom:b})]})}let Yo={enabled:null,busy:!1,error:""};const wf=new Set;let Vc=null,sa=null,d0=!1,xf=0;const dl=e=>{Yo={...Yo,...e},wf.forEach(t=>t(Yo))};async function H1(){if(d0||Yo.busy)return;d0=!0;const e=xf,t=new AbortController;sa=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===xf&&!t.signal.aborted&&dl({enabled:o.enabled,error:""})}catch{e===xf&&(n||!t.signal.aborted)&&dl({error:"Could not read Radar settings. Try again."})}finally{clearTimeout(s),d0=!1,sa===t&&(sa=null)}}async function Cxe(e){if(Yo.busy)return;xf++,sa==null||sa.abort(),dl({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;dl({enabled:a.enabled})}catch{dl({error:"Could not save Radar settings. Try again."})}finally{clearTimeout(n),dl({busy:!1})}}function Exe(){const[e,t]=y.useState(Yo);return y.useEffect(()=>(wf.add(t),t(Yo),Vc||(H1(),Vc=setInterval(()=>void H1(),1e4)),()=>{wf.delete(t),wf.size||(Vc&&clearInterval(Vc),Vc=null,sa==null||sa.abort())}),[]),e}const Txe="Monitor automatically",Axe="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 Rxe({onOpen:e}){const{enabled:t,busy:n,error:s}=Exe();return r.jsxs(Bt,{children:[r.jsx(ut,{settingId:"radar-enabled",name:Txe,nameId:"radar-enabled-label",note:Axe,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&&Cxe(!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(ut,{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 H1(),children:"Retry"})})]})]})}const Mxe="Local statistics for Claude and Codex on this device. Commands are grouped by operation; raw arguments and outputs are not saved.";function $xe(){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 b=new AbortController,k=window.setTimeout(()=>b.abort(),12e3);try{const N=await fetch("/api/tool-audit/storage",{signal:b.signal}),j=await N.json();if(!N.ok||!j.ok)throw new Error;p.current&&t(j)}catch{p.current&&s("Could not read tool history storage. Try again.")}finally{window.clearTimeout(k),f.current=!1,p.current&&o(!1)}};y.useEffect(()=>(p.current=!0,m(),()=>{p.current=!1}),[]);const w=async(b,k)=>{if(f.current)return;f.current=!0,o(!0),s(""),h("");let N=!1;const j=new AbortController,S=window.setTimeout(()=>j.abort(),15e3);try{const _=await fetch("/api/tool-audit/storage",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b==="clear"?{action:b,confirm:!0}:{action:b,days:k}),signal:j.signal}),T=await _.json();if(!_.ok||!T.ok)throw new Error;N=!0,p.current&&(c(null),h(b==="clear"?"Tool history cleared. New calls will continue to be recorded.":`Retention changed to ${k} 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),N&&m())}},v=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(Bt,{id:"tool-history-settings-title",title:"Tool history",note:Mxe,className:"ta-settings",children:[e?r.jsxs(r.Fragment,{children:[r.jsx(ut,{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:b=>{if(f.current)return;const k=Number(b.target.value);k<e.retentionDays?c(k):w("retention",k)},children:[30,60,90].map(b=>r.jsxs("option",{value:b,children:[b," days"]},b))})}),typeof i=="number"&&v,r.jsx(ut,{as:"div",settingId:"tool-history-size",name:"Space used",note:`Collected since ${nJ(e.startedAt)}`,control:r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"settings-read",children:tJ(e.bytes)}),r.jsx("button",{type:"button",className:"btn","aria-busy":a,onClick:()=>{m()},children:"Refresh"})]})}),r.jsx(ut,{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"&&v,!e.storageOk&&r.jsx(ut,{as:"div",name:"Some calls could not be saved",note:"Check free space and storage permissions."})]}):r.jsx(ut,{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})]})}const z1="agent-dag.integrations.active",tS=(e,t)=>`agent-dag.integrations.prefs.${e}:${t}`,Lxe=32e3;function eO(e,t){const n=Ke(tS(e,t));if(!n)return{};try{const s=JSON.parse(n);return s&&typeof s=="object"&&!Array.isArray(s)?s:{}}catch{return{}}}function Yke(e,t){return{read(n,s){const a=eO(e,t)[n];return s(a)?a:void 0},write(n,s){const a=eO(e,t);s===void 0?delete a[n]:a[n]=s;const o=JSON.stringify(a);o.length<=Lxe&&Ze(tS(e,t),o)}}}function Ixe(e,t){Ys(tS(e,t))}function Xke(e){const t=Ke(z1);if(!t)return null;try{const n=JSON.parse(t),s=n&&typeof n=="object"?n[e]:null;return typeof s=="string"&&s.length<=80?s:null}catch{return null}}function Zke(e,t){let n={};try{const s=Ke(z1),a=s?JSON.parse(s):{};a&&typeof a=="object"&&!Array.isArray(a)&&(n=Object.fromEntries(Object.entries(a).filter(([,o])=>typeof o=="string").slice(0,20)))}catch{}n[e]=t,Ze(z1,JSON.stringify(n))}const h0=new Set;function t8(e){return{width:e,height:e,"--ig-avatar-size":`${e}px`}}function nS({src:e,name:t,size:n=20,you:s=!1,className:a=""}){const[o,i]=y.useState(()=>!!e&&h0.has(e));y.useEffect(()=>i(!!e&&h0.has(e)),[e]);const c=t8(n),d=s||void 0;return!e||o?r.jsx("span",{className:`ig-avatar ig-avatar-initials ${a}`.trim(),"data-large":n>=28||void 0,"data-you":d,style:c,"aria-hidden":!0,children:gme(t)}):r.jsx("img",{className:`ig-avatar ${a}`.trim(),style:c,src:e,alt:"","aria-hidden":!0,referrerPolicy:"no-referrer",loading:"lazy",decoding:"async",draggable:!1,"data-you":d,onError:()=>{h0.add(e),i(!0)}})}function Jke({size:e=20}){return r.jsx("span",{className:"ig-avatar ig-avatar-none",style:t8(e),"aria-hidden":!0})}function Qke({src:e,name:t,size:n=20,you:s=!1,nameless:a=!1}){return r.jsxs("span",{className:"ig-person",title:a?t:void 0,children:[r.jsx(nS,{src:e,name:t,size:n,you:s}),a?r.jsx("span",{className:"vis-hidden",children:t}):r.jsx("span",{className:"ig-person-name",children:t})]})}function Oxe(e){return e.length<=1?e[0]??"":e.length===2?`${e[0]} and ${e[1]}`:`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function e0e({people:e,max:t=3,size:n=20,label:s}){if(!e.length)return null;const a=e.map(d=>d.name),o=e.length>t?e.slice(0,t):e,i=e.length-o.length,c=Oxe(a);return r.jsxs("span",{className:"ig-stack",role:"img","aria-label":s?`${s} ${c}`:c,title:a.join(", "),children:[o.map(d=>r.jsx(nS,{src:d.src,name:d.name,size:n,you:d.you},d.key)),i>0&&r.jsxs("span",{className:"ig-stack-more","aria-hidden":!0,children:["+",i]})]})}function tO(e){const t=e.meta??{},n=[];if(t.deploymentType==="Cloud"?n.push("Jira Cloud"):t.deploymentType&&n.push(`Jira ${t.deploymentType==="DataCenter"?"Data Center":String(t.deploymentType)}${t.serverVersion?` ${t.serverVersion}`:""}`),t.checkedAt){const s=new Date(String(t.checkedAt));Number.isNaN(s.getTime())||n.push(`checked ${s.toLocaleString(void 0,{dateStyle:"medium",timeStyle:"short"})}`)}return n.join(" · ")}function Pxe(){const e=cd(),{connections:t,error:n}=e,[s,a]=y.useState(null),[o,i]=y.useState(null),c=y.useRef(null),[d,h]=y.useState(null),[f,p]=y.useState([]),[m,w]=y.useState(null),v=y.useRef(0),[b,k]=y.useState(null),N=y.useRef(null),j=y.useRef(new Map);y.useEffect(()=>{const E=wme();E&&(k(E),a({mode:"edit",id:E}))},[]),y.useEffect(()=>{var E,D;!b||!t||(D=(E=j.current.get(b))==null?void 0:E.scrollIntoView)==null||D.call(E,{block:"nearest"})},[b,t]),y.useEffect(()=>{if(!m)return;const E=window.setTimeout(()=>w(null),4e3);return()=>window.clearTimeout(E)},[m]);const S=(E,D,B)=>p(H=>[...H.filter(G=>G.id!==E),{id:E,tone:D,text:B}]),_=E=>p(D=>D.filter(B=>B.id!==E)),T=async(E,D)=>{if(!c.current){c.current=E,i(E);try{await D()}finally{c.current=null,i(null)}}},L=E=>(D,B)=>void T("form",async()=>{h(null);try{const H=await dme(E,D,B||void 0);a(null),S(H.id,"ok",`Connected as ${H.account.name||H.account.login}.`),k(H.id)}catch(H){h(H instanceof vr?H:new vr("upstream","The connection could not be saved."))}}),A=E=>(D,B)=>void T("form",async()=>{h(null);try{const{connection:H,validated:G}=await hme(E.id,{name:B,input:D});a(null),S(H.id,"ok",G?`Saved and checked: signed in as ${H.account.name||H.account.login}.`:"Saved.")}catch(H){h(H instanceof vr?H:new vr("upstream","The change could not be saved."))}}),P=E=>void T(`test:${E.id}`,async()=>{_(E.id);try{const D=await fme(E.id);S(E.id,"ok",`Working: signed in as ${D.account.name||D.account.login}.`)}catch(D){S(E.id,"err",D instanceof Error?D.message:"The test failed.")}}),O=(E,D)=>{const B=Date.now(),H=ni({armedFor:m,target:E.id,armedAt:v.current,now:B,gapMs:ti});if(H==="arm"){w(E.id),v.current=B;return}H!=="ignore"&&(w(null),T(`delete:${E.id}`,async()=>{var G;try{await pme(E.id),Ixe(E.kind,E.id),_(E.id),(s==null?void 0:s.mode)==="edit"&&s.id===E.id&&a(null);const z=document.activeElement;(z===D||Bn((z==null?void 0:z.tagName)??null))&&((G=N.current??document.getElementById("settings-tab-integrations"))==null||G.focus())}catch(z){S(E.id,"err",z instanceof Error?z.message:"Disconnect failed.")}}))},U=t??[],q=JN(e),M=dF().filter(E=>q.has(E.kind)),I=yF(e);return r.jsxs(r.Fragment,{children:[I==="all"&&r.jsx(Bt,{id:"integrations-add-title",title:"Add integration",note:"Browse your work in a tracker beside your agents. Tokens stay on this machine: they are never shown again, never logged, and never shared with paired decks.",settingId:"integrations-add",children:(s==null?void 0:s.mode)==="add"?(()=>{const E=M.find(D=>D.kind===s.kind);return E?r.jsx("div",{className:"settings-row ig-form-row",children:r.jsx(MI,{def:E,busy:o==="form",error:d,onSubmit:L(s.kind),onCancel:()=>{a(null),h(null),requestAnimationFrame(()=>{var D;return(D=N.current)==null?void 0:D.focus()})}})}):null})():(s==null?void 0:s.mode)==="pick"?r.jsxs(r.Fragment,{children:[M.map(E=>r.jsx(ut,{as:"div",name:r.jsxs("span",{className:"ig-provider-name",children:[r.jsx("span",{className:"ig-provider-glyph","aria-hidden":!0,children:r.jsx(E.Glyph,{})}),E.label]}),note:E.blurb,control:r.jsxs("button",{type:"button",className:"btn primary",onClick:()=>{h(null),a({mode:"add",kind:E.kind})},children:["Connect ",E.label]})},E.kind)),r.jsx(ut,{as:"div",name:"More trackers",note:"Further providers will appear here as the deck learns them.",control:r.jsx("button",{type:"button",className:"btn",onClick:()=>{a(null),requestAnimationFrame(()=>{var E;return(E=N.current)==null?void 0:E.focus()})},children:"Cancel"})})]}):r.jsx(ut,{as:"div",name:"Connect a tracker",note:M.map(E=>E.label).join(", "),control:r.jsx("button",{ref:N,type:"button",className:"btn",onClick:()=>a({mode:"pick"}),children:"Add integration"})})}),r.jsxs(Bt,{id:"integrations-list-title",title:"Connections",aside:r.jsx("span",{className:"settings-caption-count",children:U.length}),settingId:"integrations-connections",children:[t===null&&!n&&r.jsx("p",{className:"settings-row settings-row-status",role:"status",children:"Reading connections…"}),n&&r.jsx("p",{className:"settings-row settings-row-status ig-error",role:"alert",children:n}),t!==null&&U.length===0&&r.jsx("p",{className:"settings-row settings-row-status",children:M.length>0?"Nothing connected yet. A tracker you add gets its own button on the left edge, under Accounts and Session list.":"Nothing connected."}),U.map(E=>{var $;const D=hF(E.kind),B=!ud(e,E.kind),H=!B&&(s==null?void 0:s.mode)==="edit"&&s.id===E.id,G=f.find(W=>W.id===E.id),z=Array.isArray(($=E.meta)==null?void 0:$.warnings)?E.meta.warnings.filter(W=>typeof W=="string"):[],F=m===E.id;return r.jsxs("div",{className:"settings-row ig-conn","data-focused":b===E.id||void 0,ref:W=>{W?j.current.set(E.id,W):j.current.delete(E.id)},children:[r.jsxs("div",{className:"ig-conn-head",children:[r.jsx(nS,{src:E.account.avatarUrl,name:E.account.name||E.account.login||E.name,size:32}),r.jsxs("div",{className:"ig-conn-text",children:[r.jsx("span",{className:"ig-conn-name",children:E.name}),r.jsxs("span",{className:"ig-conn-line",children:[(D==null?void 0:D.label)??E.kind," · ",r.jsx("span",{className:"ig-mono",children:mme(E)})]}),r.jsxs("span",{className:"ig-conn-line",children:[E.account.name||E.account.login?r.jsxs(r.Fragment,{children:["Signed in as ",E.account.name,E.account.login&&E.account.login!==E.account.name?r.jsxs(r.Fragment,{children:[" (",r.jsx("span",{className:"ig-mono",children:E.account.login}),")"]}):null]}):"No account read yet",!E.tokenSaved&&r.jsxs(r.Fragment,{children:[" · ",r.jsx("span",{className:"ig-bad",children:"no token saved"})]})]}),tO(E)&&r.jsx("span",{className:"ig-conn-line ig-dim",children:tO(E)}),B&&r.jsxs("span",{className:"ig-stranded",children:[(D==null?void 0:D.label)??E.kind," is not available on this deck. Disconnect deletes this connection and its saved token."]})]}),!H&&r.jsxs("div",{className:"ig-conn-actions",children:[!B&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",className:"btn","aria-busy":o===`test:${E.id}`,onClick:()=>P(E),"aria-label":`Test ${E.name}`,children:o===`test:${E.id}`?"Testing…":"Test"}),r.jsx("button",{type:"button",className:"btn",onClick:()=>{h(null),a({mode:"edit",id:E.id})},"aria-label":`Edit ${E.name}`,children:"Edit"})]}),r.jsx("button",{type:"button",className:`btn danger${F?" armed":""}`,"aria-busy":o===`delete:${E.id}`,onKeyDown:W=>{W.repeat&&W.preventDefault()},onClick:W=>O(E,W.currentTarget),"aria-label":F?`Confirm disconnecting ${E.name}`:`Disconnect ${E.name}`,title:F?"Press again to disconnect. The saved token is deleted from this machine.":"Disconnect and delete the saved token",children:F?"Confirm":"Disconnect"})]})]}),z.length>0&&r.jsx("ul",{className:"ig-warnings",children:z.map(W=>r.jsx("li",{children:W},W))}),G&&r.jsx("p",{className:"ig-note","data-tone":G.tone,role:G.tone==="err"?"alert":"status",children:G.text}),H&&D&&r.jsx(MI,{def:D,existing:E,busy:o==="form",error:d,onSubmit:A(E),onCancel:()=>{a(null),h(null)}})]},E.id)})]})]})}function Dxe({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 Fxe({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=(Qr.indexOf(o??e)+(a.key==="ArrowLeft"||a.key==="ArrowUp"?-1:1)+Qr.length)%Qr.length;t(Qr[c]),(h=a.currentTarget.querySelectorAll('[role="radio"]')[c])==null||h.focus()};return r.jsx(Bt,{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:Qr.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(Dxe,{theme:a}),r.jsxs("span",{className:"appearance-theme-name",children:[id[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 Bxe=[["smallest","Smallest","11 px"],["smaller","Smaller","12 px"],["default","Default","13 px"],["larger","Larger","15 px"],["largest","Largest","17 px"]],qxe=[["tightest","Tightest","30%"],["tighter","Tighter","50%"],["compact","Compact","70%"],["default","Default","100%"],["comfortable","Comfortable","140%"]];function nO(){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 Uxe({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 Wxe({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":kT.length,"--reading-selected":kT.indexOf(e)},children:Bxe.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(nO,{})]},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":jT.length,"--reading-selected":jT.indexOf(t)},children:qxe.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(nO,{})]},a))})]}),r.jsxs(Bt,{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 Hxe="AGPL-3.0-only",zxe="GNU Affero General Public License, version 3 only.",Vxe="https://github.com/BarganConstantin/ccdeck",Gxe="What changed in each release, newest first.",Kxe="Tell the people who make ccdeck what works and what does not.";function Yxe(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 Xxe(e,t){return ao(e)&&ao(t)&&ai(e,t)<0}function Zxe(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 Jxe({version:e,notice:t,readyAppUpdate:n,updateRestarting:s,updateFailure:a,onUpdateRestart:o,doors:i,bundle:c="3.46.0"}){const d=(e==null?void 0:e.running)??c,h=Zxe(n,t);return r.jsxs(r.Fragment,{children:[r.jsxs(Bt,{id:"settings-about-caption",title:Rt,children:[r.jsx(ut,{as:"div",settingId:"version",name:"Version",note:Xxe(c,e==null?void 0:e.running)?Yxe(c):void 0,control:r.jsx("span",{className:"settings-read",children:d})}),h&&r.jsx(Qxe,{offer:h,restarting:s,failure:a,onRestart:o,onUpdate:i.update}),r.jsx(ut,{as:"div",settingId:"whats-new",name:"What's new",note:Gxe,control:r.jsx("button",{type:"button",className:"btn","aria-haspopup":"dialog","aria-label":"Open What's new",onClick:i.whatsNew,children:"Open"})}),r.jsx(ut,{as:"div",settingId:"licence",name:"Licence",note:zxe,control:r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"settings-read",children:Hxe}),r.jsxs("a",{className:"settings-link",href:Vxe,target:"_blank",rel:"noreferrer",children:["Source",r.jsx("span",{className:"vis-hidden",children:": the source code, opens in your browser"})]})]})})]}),r.jsxs(Bt,{id:"settings-about-help-caption",title:"Tour and feedback",children:[r.jsx(ut,{as:"div",settingId:"tour",name:"Take the tour",note:q1,control:r.jsx("button",{type:"button",className:"btn","aria-haspopup":"dialog","aria-label":"Start the tour",onClick:i.tour,children:"Start"})}),r.jsx(ut,{as:"div",settingId:"feedback",name:"Send feedback",note:Kxe,control:r.jsx("button",{type:"button",className:"btn","aria-haspopup":"dialog","aria-label":"Open the feedback dialog",onClick:i.feedback,children:"Open"})})]})]})}function Qxe({offer:e,restarting:t,failure:n,onRestart:s,onUpdate:a}){if(e.kind==="notice")return r.jsx(ut,{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=kF(e.to,t),i=n&&n.version===e.to?jF(n.failure,n.version):"";return r.jsx(ut,{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 eve="Update when idle",tve="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.",nve=`${HF} 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.`,sve="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.",rve="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 ave(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 ove={plain:tve,"checks-off":nve,"no-restart":sve};function ive({autoRestart:e,onToggleAutoRestart:t,version:n,inApp:s=oo()}){const a=ave(n,s);return r.jsx(Bt,{id:"settings-updates-caption",title:"Updates",children:a==="app"?r.jsx(ut,{as:"div",settingId:"auto-update",name:"Updates",note:rve}):r.jsx(ut,{settingId:"auto-update",name:eve,nameId:"settings-auto-update-label",note:ove[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 lve({character:e,onCharacter:t}){const n=y.useRef([]);function s(a,o){var c;const i=pN(a,o,yf.length,"vertical");i.kind==="select"&&(a.preventDefault(),t(yf[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:yf.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(NP,{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 cve="Stands beside the minimap. Press it to play the radio.";function uve({characterEnabled:e,onToggleCharacter:t,character:n="deck",onCharacter:s}){return r.jsxs(Bt,{id:"appearance-character-caption",title:"Character",list:!1,children:[r.jsx("div",{className:"settings-list",children:r.jsx(ut,{settingId:"character",name:"Show the character",nameId:"appearance-character-label",note:cve,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(lve,{character:n,onCharacter:s})]})}const sO="settings-search-field",n8="settings-search-results",V1=e=>`settings-result-${e}`;function dve({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=Ywe(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:sO,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:sO,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?n8:void 0,"aria-activedescendant":d?V1(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 hve({query:e,results:t,active:n,onOpen:s}){const a=QF(t.length,e);return y.useEffect(()=>{var o,i;(i=(o=document.getElementById(V1(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:n8,role:"listbox","aria-label":"Matching settings",children:t.map((o,i)=>r.jsxs("button",{type:"button",role:"option",id:V1(i),className:"settings-result",tabIndex:-1,"aria-selected":i===n,"aria-label":zwe(o),"data-highlighted":i===n,onMouseDown:c=>c.preventDefault(),onClick:()=>s(o),children:[r.jsx(e8,{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:JF(o)})]})]},o.id))})})]})}function fve({query:e,count:t}){return r.jsx("p",{className:"vis-hidden",role:"status",children:e.trim()?QF(t,e):""})}const pve=1500,mve=3e3,gve=e=>e.checkVisibility?e.checkVisibility():e.getClientRects().length>0;function yve(e){if(e.matches(Rf)&&!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(Rf)).filter(s=>P4({disabled:s.disabled,tabIndex:s.tabIndex,rendered:gve(s)}));return n.find(s=>s.closest(".settings-list")!=null)??n[0]??null}function wve(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 b,k;a(null);const v=w.offsetHeight>c.clientHeight-48;w.scrollIntoView({block:v?"start":"center"}),(b=yve(w))==null||b.focus({preventScroll:!0}),window.clearTimeout(o.current),(k=i.current)==null||k.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)},pve)},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)},mve);return()=>{p.disconnect(),window.clearTimeout(m)}},[e,s,t,n]),a}function xve({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),v=ft(n,{focusRef:w}),b=mt(n),k=y.useRef([]),N=yF(cd()),j=kfe(N,e),S=Math.max(0,j.findIndex(Ne=>Ne.id===e)),[_,T]=y.useState(""),[L,A]=y.useState(0),P=y.useRef(null),O=y.useRef(null),U=_.trim()!=="",q=y.useMemo(()=>Kwe(_,Hwe(s.claude,N)),[_,s.claude,N]),M=wve(O,!U,e),I=Ne=>{T(Ne),A(0)},E=Ne=>{I(""),t(Ne)},D=Ne=>{I(""),t(Ne.section),ZF(Ne)||M(Ne.id)};y.useEffect(()=>{const Ne=Ae=>{var ot,we;if(!Efe(Ae))return;const qe=v.current,et=Ae.target;!qe||!(et===document.body||et===document.documentElement||et&&qe.contains(et))||(Ae.preventDefault(),(ot=P.current)==null||ot.focus(),(we=P.current)==null||we.select())};return window.addEventListener("keydown",Ne),()=>window.removeEventListener("keydown",Ne)},[v]),y.useEffect(()=>{var Ne,Ae,qe,et;jfe((Ne=document.activeElement)==null?void 0:Ne.id,e)&&((Ae=w.current)==null||Ae.focus()),(et=(qe=w.current)==null?void 0:qe.scrollIntoView)==null||et.call(qe,{block:"nearest",inline:"nearest"})},[e]);const{theme:B,setTheme:H,characterEnabled:G,setCharacterEnabled:z,character:F,setCharacter:$}=d,W=qn(),Z=Ne=>{var qe;const Ae=pN(Ne,S,j.length,"vertical");Ae.kind!=="pass"&&(Ne.preventDefault(),I(""),t(j[Ae.index].id),(qe=k.current[Ae.index])==null||qe.focus())},V=Ne=>{var et;if(Ne.key===" "){Ne.stopPropagation();return}if(uP(Ne.key,W))return;const Ae=Ne.target;if(Ho(Ae)||Ae.tagName==="SELECT"||Ne.key!=="t"&&Ne.key!=="T"||Ne.ctrlKey||Ne.metaKey||Ne.altKey)return;Ne.preventDefault(),Ne.stopPropagation();const qe=M1(Ae.dataset.themeChoice??B);H(M1),Ae.getAttribute("role")==="radio"&&((et=Ne.currentTarget.querySelector(`[role="radio"][data-theme-choice="${qe}"]`))==null||et.focus())},{soundOn:Y,toggleSound:X}=a,{tonePrefs:J,previewTone:Q,changeTone:te}=o,{customSelections:ce,customAssets:ue,clearCustomOnly:ie,selectCustomTone:re,importNotificationAudio:fe,createNotificationVoice:ae,renameCustomAsset:je,deleteCustomAsset:me,previewCustomAsset:pe}=i,{notifyPermission:xe,notifyOn:_e,notifyVetoed:ye,toggleNotify:Ie,notifySupported:Pe,askForNotifications:Ue,accountNotify:$e,toggleAccountNotify:Je}=c,Qe=(()=>{switch(e){case"radar":return r.jsx(Rxe,{onOpen:m.radar});case"appearance":return r.jsxs(r.Fragment,{children:[r.jsx(Fxe,{theme:B,onTheme:H,singleKeys:W}),r.jsx(uve,{characterEnabled:G,character:F,onCharacter:$,onToggleCharacter:()=>z(Ne=>!Ne)})]});case"reading":return r.jsx(Wxe,{textSize:d.textSize,density:d.density,onTextSize:d.setTextSize,onDensity:d.setDensity});case"keyboard":return r.jsx(uxe,{singleKeys:W,onToggleSingleKeys:()=>MK(!W)});case"notifications":return r.jsx(dxe,{notifyOn:_e,onToggleNotify:Ie,notifyVetoed:ye,notifyPermission:Pe?xe:"unsupported",onAskNotify:Ue,accountNotify:$e,onToggleAccountNotify:Je});case"sounds":return r.jsx(_xe,{soundOn:Y===!0,onToggleSound:X,prefs:J,claudeHere:s.claude,onLevel:(Ne,Ae)=>te(Ne,{level:Ae}),onFigure:(Ne,Ae)=>te(Ne,{figure:Ae}),onPreview:Ne=>Q(Ne),customAssets:ue,customSelections:ce,onBuiltInSelected:ie,onCustomSelected:re,onImportCustom:fe,onCreateVoice:ae,onRenameCustom:je,onPreviewCustom:pe,onDeleteCustom:me});case"integrations":return r.jsx(Pxe,{});case"data":return r.jsx($xe,{});case"about":return r.jsx(Jxe,{version:h.version,notice:h.notice,readyAppUpdate:f.readyAppUpdate,updateRestarting:f.desktopUpdateRestarting,updateFailure:f.desktopUpdateFailure,onUpdateRestart:Ne=>{f.askDesktopUpdateRestart(Ne)},doors:m});default:return r.jsxs(r.Fragment,{children:[r.jsx(Jwe,{}),r.jsx(XI,{provider:"Codex"}),s.claude&&r.jsx(XI,{provider:"Claude"}),r.jsx(ive,{autoRestart:p.autoRestart,onToggleAutoRestart:p.toggleAutoRestart,version:h.version}),r.jsx(axe,{claudeHere:s.claude,singleKeys:W,doors:m})]})}})(),ze=e==="reading"?r.jsx(Uxe,{textSize:d.textSize,density:d.density,onTextSize:d.setTextSize,onDensity:d.setDensity}):null;return r.jsx("div",{className:"modal-backdrop",...b,role:"presentation",children:r.jsxs("div",{ref:v,id:"settings",className:"modal settings-modal",role:"dialog","aria-modal":"true","aria-labelledby":"settings-title",onClick:Ne=>Ne.stopPropagation(),onKeyDown:V,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(dve,{inputRef:P,query:_,onQuery:I,results:q,active:L,onActive:A,onOpen:D}),r.jsx(fve,{query:_,count:q.length}),r.jsx("div",{className:"settings-nav",role:"tablist","aria-label":"Settings sections","aria-orientation":"vertical",onKeyDown:Z,children:j.map((Ne,Ae)=>r.jsxs("button",{ref:qe=>{k.current[Ae]=qe,Ne.id===e&&(w.current=qe)},type:"button",role:"tab",id:`settings-tab-${Ne.id}`,className:"settings-tab","aria-selected":Ne.id===e,"aria-controls":"settings-pane",tabIndex:Ne.id===e?0:-1,onClick:()=>E(Ne.id),children:[r.jsx(e8,{section:Ne.id}),r.jsx("span",{className:"settings-tab-label",children:Ne.label})]},Ne.id))})]}),r.jsxs("div",{ref:O,className:"settings-pane",role:"tabpanel",id:"settings-pane","aria-labelledby":`settings-tab-${e}`,hidden:U||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:j[S].label}),r.jsx("p",{className:"settings-pane-note",children:j[S].note})]}),ze]}),Qe]},e),U&&r.jsx(hve,{query:_,results:q,active:L,onOpen:D})]})]})})}function vve({tool:e,onClose:t}){const n=ft(t),s=mt(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=i9(e.name,i,c);return{input:f.input.map((p,m)=>r.jsx(rO,{block:p},m)),response:f.response.map((p,m)=>r.jsx(rO,{block:p},m)),copyInput:fE(e.name,"input",i),copyResponse:fE(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:L4(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(aO,{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(aO,{text:h.copyResponse,what:"response"})]}),e.endedAt==null?r.jsx("pre",{children:"(waiting…)"}):h.response]})]})]})})}const bve={del:"tm-del",add:"tm-add",ctx:"tm-ctx"};function rO({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(()=>e9(e),[e]),{shown:a}=l4(s,t),o=t9(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?bve[i.tone]:void 0,children:[i.text,c<a.length-1?`
313
+ `:""]},c)):a.map(i=>i.text).join(`
314
+ `)}),o&&r.jsx("button",{type:"button",className:"btn tm-more","aria-expanded":o.expanded,onClick:()=>n(i=>!i),children:o.label})]})}function aO({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 lo(e).then(o=>{!o||!a.current||(s(!0),window.setTimeout(()=>{a.current&&s(!1)},1600))}),children:n?"copied":"copy"})}const kve=gm(()=>Fl(()=>import("./UsageHistoryModal-Bd-JRAa4.js"),[]),"Usage history"),jve=gm(()=>Fl(()=>import("./BrowserWatchModal-CoX9FIUE.js"),[]),"Browser Watch"),Nve=gm(()=>Fl(()=>import("./TrafficRadar-nhtFoYVv.js"),[]),"Telemetry Radar");function Sve({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:v,menus:b,sound:k,tones:N,customTones:j,notify:S,panelDoors:_}){const{openedTool:T,setOpenedToolKey:L,usageHistoryOpen:A,setUsageHistoryOpen:P,browserWatchOpen:O,setBrowserWatchOpen:U,contextAgent:q,setContextFor:M,summaryFor:I,setSummaryFor:E,keyHelpOpen:D,setKeyHelpOpen:B,feedbackOpen:H,setFeedbackOpen:G,feedbackPrefill:z,setFeedbackPrefill:F,openFeedback:$}=e,{trafficRadarOpen:W,setTrafficRadarOpen:Z}=e,{tourOpen:V,openTour:Y,closeTour:X,releaseNotes:J,closeReleaseNotes:Q,chipVersion:te,openReleaseNotes:ce}=t,{desktopUpdateRestarting:ue,desktopUpdateFailure:ie,readyAppUpdate:re,askDesktopUpdateRestart:fe}=n,{version:ae,showNotice:je}=s,{askRestart:me}=a,{clearConfirmOpen:pe,setClearConfirmOpen:xe,requestClear:_e}=d,{setWatchOn:ye,markWatchSeen:Ie}=h,{setWatchSaid:Pe}=f,{palette:Ue}=p,{settingsOpen:$e,settingsSection:Je,showSection:Qe,closeSettings:ze,openSettings:Ne}=b;return r.jsxs(r.Fragment,{children:[T&&r.jsx(vve,{tool:T,onClose:()=>L(null)}),A&&r.jsx(y.Suspense,{fallback:null,children:r.jsx(kve,{providers:m,onClose:()=>P(!1)})}),O&&r.jsx(y.Suspense,{fallback:null,children:r.jsx(jve,{onClose:()=>U(!1),onSeen:Ae=>{Pe(""),Ie(Ae)},onWatching:ye,palette:Ue})}),q&&r.jsx(sG,{agent:q,onClose:()=>M(null)}),W&&r.jsx(y.Suspense,{fallback:null,children:r.jsx(Nve,{sessions:[...w.current.agents.values()].filter(Ae=>Ae.kind==="root"&&Ae.provider!=="codex").map(Ae=>({id:Ae.sessionId,label:Ap(Ae.sessionName,Ae.sessionTitle).face??Ae.cwdBasename??Ae.label,project:Ae.cwdBasename??Ae.label,workspace:Ae.cwd})),onClose:()=>Z(!1)})}),H&&r.jsx(IF,{initialKind:z==null?void 0:z.initialKind,initialBody:z==null?void 0:z.initialBody,onClose:()=>{G(!1),F(null)}}),I&&r.jsx(_we,{state:w.current,sessionId:I,onClose:()=>E(null)}),$e&&r.jsx(xve,{section:Je,onSection:Qe,onClose:ze,providers:m,sound:k,tones:N,customTones:j,notify:S,appearance:p,versionCheck:s,desktopUpdate:n,restart:a,doors:{whatsNew:Ua(ze,ce),update:Ua(ze,()=>{ce(),je()}),tour:Ua(ze,Y),feedback:Ua(ze,()=>$()),accounts:Ua(ze,_.accounts),localNetwork:Ua(ze,_.localNetwork),browserWatch:Ua(ze,()=>U(!0)),radar:Ua(ze,()=>Z(!0))}}),J&&r.jsx(Swe,{entries:J.entries,since:J.since,firstRun:J.firstRun,running:te,onClose:Q,onTour:()=>{Q(),Y()},updateVersion:re==null?void 0:re.version,updateBusy:ue,updateFailure:ie&&(!re||re.version===ie.version)?jF(ie.failure,ie.version):void 0,onUpdateRestart:re?()=>{fe(re.version)}:void 0,onRestart:!re&&(ae!=null&&ae.canRestart)?()=>{Q(),me()}:void 0,updateCheck:{versionCheck:s,upgrade:o,restart:a,desktopUpdate:n,running:te,onHandOff:Q}}),r.jsx(_ve,{lanPairs:i,attention:c}),D&&r.jsx(Aye,{onClose:()=>B(!1),onTour:()=>{B(!1),Y()},onSettings:()=>{B(!1),Ne("keyboard")}}),V&&r.jsx(HD,{title:"What the deck shows you",steps:Xse,onClose:X}),pe&&r.jsx(vge,{agentCount:v,onConfirm:()=>_e("confirmation"),onCancel:()=>xe(!1)})]})}function _ve({lanPairs:e,attention:t}){const n=qye(e);return r.jsxs(r.Fragment,{children:[n,r.jsx(zye,{...t,pairing:n!=null})]})}const Cve=10,s8=500,r8=4e3,Eve=[/ResizeObserver loop/i,/^Script error\.?$/i],oO=/^(?:[a-z][\w+.-]*-extension|webkit-masked-url):\/\//i,Tve=/[a-z][\w+.-]*:\/\/[^\s()]+/gi;function Ave(e,t){const n=typeof e=="string"?e.split(`
315
+ `):[],s=n.some(o=>/^\s*at\s/.test(o)),a=n.flatMap(o=>!s||/^\s*at\s/.test(o)?o.match(Tve)??[]:[]);return a.length?a.every(o=>oO.test(o)):typeof t=="string"&&oO.test(t)}const fp=String.raw`[^\s\\/:'"\`<>|?*;,]`,Rve=String.raw`${fp}(?:[^\\/\r\n:'"\`<>|?*;,]*${fp})?[\\/]`,Mve=String.raw`[^\s\\/:'"\`<>|?*;,()]+`,Gc=String.raw`(?:${Rve})*(?:${Mve})?`,$ve=String.raw`(?<![\w.~/\\\]-]|<(?:deck|host)>)(?:file://(?:/[A-Za-z]:)?[^\s:'"\`<>()]*|~[\\/]${Gc}|[A-Za-z]:[\\/]${Gc}|\\\\(?:[?.]\\)?(?:[A-Za-z]:\\)?${Gc}|/(?=${fp})${Gc}|(?<!:)//(?=${fp})${Gc})`,Lve=String.raw`(?<![\w-])(?:[A-Za-z]--|-[A-Za-z0-9][\w.]*-)[\w.-]*`,Ive=new Set([".claude",".codex"]);function Ove(e){if(!e.startsWith("~"))return"<path>";const t=e[1],[n,...s]=e.slice(2).split(/[\\/]/);return n?Ive.has(n)?s.join("")?`~${t}${n}${t}<path>`:e:`~${t}<path>`:e}const Pve=String.raw`\b(https?|wss?)://[^\s/?#\\'"\x60<>(),;]+(?=(/assets/)?)`;function Dve(e,t,n){return n?"<deck>":`${t}://<host>`}const iO=String.raw`(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)`,a8=String.raw`${iO}(?:\.${iO}){3}`,f0=String.raw`[0-9A-Fa-f]{1,4}`,lO=String.raw`(?=[0-9A-Fa-f:]*\d)(?=[0-9A-Fa-f:]*::|(?:${f0}:){7})(?:(?:${f0})?:)+(?:${a8}|${f0})?`,cO=String.raw`%[\w-]+(?:\.[\w-]+)*`,uO=String.raw`(?:::1?|::ffff:(?:127(?:\.\d{1,3}){3}|0\.0\.0\.0))`,Fve=String.raw`(?<![\w:.%-])(?:\[(?!${uO}\])${lO}(?:${cO})?\]|(?!${uO}(?::\d{1,5})?(?![\w:%]|\.\d))${lO}(?:${cO})?(?![\w%]|\.\d))|(?<![\w./-])(?!127\.|0\.0\.0\.0\b)${a8}(?![\w-]|\.\d)`,p0=String.raw`(?=[\w.-]*[A-Za-z])[A-Za-z0-9][\w-]*(?:\.[\w-]+)*`,Bve=String.raw`(?<![\w.@/\\%-])(?!localhost(?![\w-]|\.\w))(?:(?<=\b(?:(?:getaddrinfo|connect) E[A-Z_]+|ENOTFOUND|EAI_AGAIN) )${p0}|${p0}(?=:\d{1,5}(?![\w:-]|\.\w))|${p0}\.(?:local|lan|home|internal|ts\.net)(?![\w-]|\.\w))`;function dO(e){return String(e??"").replace(/\/(?:home|Users)\/[^/\s:'"]+/g,"~").replace(/[A-Za-z]:\\(?:Users|Documents and Settings)\\[^\\\r\n:'"]+/gi,"~").replace(new RegExp($ve,"g"),Ove).replace(new RegExp(Lve,"g"),"<project>").replace(new RegExp(Pve,"g"),Dve).replace(new RegExp(Fve,"g"),"<host>").replace(new RegExp(Bve,"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 o8=e=>{fetch("/api/client-error",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e),keepalive:!0}).catch(()=>{})};function qve(e,t,n=o8){const s=String(e??"").slice(0,s8).trim();s&&n({message:s,stack:typeof t=="string"?t.slice(0,r8):void 0})}function Uve(e,t=window,n=o8){let s=0;const a=new Set,o=(d,h,f)=>{const p=String(d??"").slice(0,s8).trim();!e()||!p||s>=Cve||a.has(p)||Eve.some(m=>m.test(p))||Ave(h,f)||(a.add(p),s++,n({message:p,stack:typeof h=="string"?h.slice(0,r8):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 Wve=12;function Hve(e,t){const n=[dO(e).trim()||"The deck threw an error with no message."],s=t==null?void 0:t.trim();if(s){const a=s.split(`
316
+ `).slice(0,Wve).join(`
317
+ `);n.push("",dO(a).trim())}return n.join(`
318
+ `)}class zve extends y.Component{constructor(){super(...arguments);Fa(this,"state",{error:null,componentStack:null,reportOpen:!1});Fa(this,"onKey",n=>{O4(n.key)&&vn.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}),qve(n.message,n.stack),K6("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(IF,{initialKind:"bug",initialBody:Hve(n.message,s),onClose:()=>this.setState({reportOpen:!1})})]}):this.props.children}}const Vve=1e3;function Gve(e={}){const t=Math.max(1,Math.floor(e.limit??Vve)),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 v=0;if(o.size<a.length)for(;o.has(a[v]);)v++;const[b]=a.splice(v,1);o.delete(b),i++}return!1},setPaused(h){if(s=h,h)return[];const f=a;return a=[],o=new Set,i=0,f}}}function Kve(e){const t=y.useState(()=>Gve({protect:o=>w9(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&&sV(e.current);for(const c of i)e.current=v4(e.current,c);s(t.paused)},[t,e]);return{pauseGate:t,paused:n,togglePause:a}}const G1={kind:"assumed",claude:!0,codex:!0};function Yve(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 Xve(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(Yve(c)),!(!c||typeof c.workspace!="string")&&n(c.workspace))}).catch(()=>{}),()=>{i=!0}},[e]);const o=Ln(s);return{workspace:t,providers:s,providersRef:o}}const i8=3*6e4,Zve=2e4;function Jve({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>=i8&&await i()},stop:()=>{o=!1}}}async function Qve(){try{const e=await fetch("/api/provider-status",{signal:AbortSignal.timeout(Zve)});return e.ok?await e.json():null}catch{return null}}function ebe(e){const[t,n]=y.useState(null);return y.useEffect(()=>{if(!e){n(null);return}const s=Jve({fetchReport:Qve,visible:()=>document.visibilityState==="visible",now:()=>Date.now(),onReport:n});s.tick();const a=window.setInterval(s.tick,i8),o=()=>{s.wake()};return document.addEventListener("visibilitychange",o),()=>{s.stop(),window.clearInterval(a),document.removeEventListener("visibilitychange",o)}},[e]),t}const tbe={degraded:"degraded performance",partial_outage:"partial outage",major_outage:"major outage",maintenance:"maintenance"},nbe={degraded:"degraded",partial_outage:"partial outage",major_outage:"major outage",maintenance:"maintenance"},sbe={degraded:"degraded",partial_outage:"outage",major_outage:"outage",maintenance:"maint."},rbe={claude:"Claude",codex:"Codex"},abe=new Set(["status.claude.com","status.openai.com"]),obe=30*6e4,ibe=10*6e4;function lbe(e){if(typeof e!="string")return null;try{const t=new URL(e);return t.protocol==="https:"&&abe.has(t.hostname)?t:null}catch{return null}}function hO(e){return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hourCycle:"h23"})}function cbe(e){const t=Math.floor(e/6e4);return t<1?"just now":t<60?`${t} min ago`:`${Math.floor(t/60)} h ago`}function ube(e,t){if(!e||typeof e!="object")return null;const n=Kt(tbe,e.state),s=Kt(rbe,e.provider);if(!n||!s||typeof e.checkedAt!="number"||t-e.checkedAt>obe)return null;const a=lbe(e.statusPageUrl);if(!a)return null;const o=Array.isArray(e.components)?e.components:[],i=e.stale===!0||t-e.checkedAt>ibe,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 ${hO(e.checkedAt)}; this is the last thing it said`:`Reported by ${a.hostname}, checked ${cbe(t-e.checkedAt)}`,"Opens the status page"],d=i?hO(e.checkedAt):null;return{provider:e.provider,state:e.state,name:s,label:`${s} · ${n}${d?` · as of ${d}`:""}`,words:n,chipWords:Kt(nbe,e.state)??n,shortWords:Kt(sbe,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(`
319
+ `)}}function dbe(e,t){return!(e!=null&&e.ok)||e.disabled||!Array.isArray(e.providers)?[]:e.providers.map(n=>ube(n,t)).filter(n=>n!==null)}function hbe(e){return e.map(t=>`${t.name}'s status page reports ${t.state.endsWith("outage")?`a ${t.words}`:t.words}.`).join(" ")}const fbe="The providers' status pages report no incident.";function pbe({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=lge(e==null?void 0:e.upgrade),i=y.useRef(!1),c=y.useCallback(async()=>{if(bn(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 lo(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 fO="agent-dag.browserWatch.seenMs";function mbe(e,t){return e.filter(n=>n.startMs>t)}function gbe(){const[e,t]=y.useState(()=>Number(Ke(fO))||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(()=>mbe(n,e).length,[n,e]),c=y.useCallback(d=>{t(d),Ze(fO,String(d))},[]);return{watchOn:a,setWatchOn:o,watchUnseen:i,markWatchSeen:c}}const l8="agent-dag.character-enabled",c8="agent-dag.fm-volume",ybe=1,pO="agent-dag.fm-source",t0e=[{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 wbe(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 xbe(e){return e!=="0"}function vbe(){return xbe(Ke(l8))}function bbe(e){return C5(e,ybe)}function kbe(){return bbe(Ke(c8))}const u8=["--err","--inflight","--ok","--warn","--muted","--grid-line","--minimap-mask","--panel","--line","--accent","--text-dim","--bg"];function mO(e){const t={};for(const n of u8)t[n]=e(n);return t}function jbe(e){return t=>e[t]??""}function Nbe(e,t){return u8.every(n=>e[n]===t[n])}function Sbe(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 gO(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}function _be(){const[e,t]=y.useState(mJ),[n,s]=y.useState(gJ),[a,o]=y.useState(Afe),i=y.useRef(a),[c]=y.useState(()=>Sbe(document,()=>{try{return window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!0}})),d=y.useCallback(N=>{const j=typeof N=="function"?N(i.current):N;j!==i.current&&(i.current=j,c.run(()=>xt.flushSync(()=>o(j))))},[c]);y.useEffect(()=>()=>c.cancel(),[c]);const[h,f]=y.useState(vbe),[p,m]=y.useState(Awe),[w,v]=y.useState(()=>mO(gO)),b=y.useMemo(()=>jbe(w),[w]),k=y.useCallback(N=>Uhe(N,b),[b]);return y.useEffect(()=>{document.documentElement.dataset.textSize=e,Ze(Q0,e)},[e]),y.useEffect(()=>{document.documentElement.dataset.density=n,Ze(e1,n)},[n]),y.useEffect(()=>{const N=j=>{j.storageArea===wr()&&((j.key===Q0||j.key===null)&&t(Vj(j.newValue)),(j.key===e1||j.key===null)&&s(UP(j.newValue)))};return window.addEventListener("storage",N),()=>window.removeEventListener("storage",N)},[]),y.useLayoutEffect(()=>{document.documentElement.dataset.theme=a,document.documentElement.dataset.colorScheme=id[a].colorScheme,Ze(Y6,a),v(N=>{const j=mO(gO);return Nbe(N,j)?N:j})},[a]),y.useEffect(()=>{Ze(l8,h?"1":"0")},[h]),y.useEffect(()=>{Ze(KF,p)},[p]),y.useEffect(()=>{const N=document.querySelector('meta[name="theme-color"]'),j=w["--panel"];N&&j&&N.setAttribute("content",j)},[w]),{textSize:e,setTextSize:t,density:n,setDensity:s,theme:a,setTheme:d,characterEnabled:h,setCharacterEnabled:f,character:p,setCharacter:m,palette:w,minimapNodeFill:k}}function Cbe(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(J6(f.name));return Object.keys(Z6).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(v=>v.getBoundingClientRect()),w=ZZ(p,m,8);s(v=>v===w?v: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 Ebe(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,v=w.figure){if(!n||n.state!=="running")return!1;const b=S1(m,v),k=zie(w.level,b),N=n.currentTime;for(const j of b.notes){const S=n.createOscillator(),_=n.createGain();S.type=b.type??"sine",S.frequency.value=j.hz;const T=N+j.at,L=T+j.ms/1e3;_.gain.setValueAtTime(qA,T),_.gain.exponentialRampToValueAtTime(k,T+Vie),_.gain.exponentialRampToValueAtTime(qA,L),S.connect(_).connect(n.destination),S.start(T),S.stop(L+.02)}return!0}async function d(m,w){var k;if(!e.loadCustom)return"unavailable";let v;try{v=await e.loadCustom(m)}catch{return"unavailable"}if(!v)return"missing";if(v.kind==="tts"){if(typeof window>"u"||!("speechSynthesis"in window)||typeof SpeechSynthesisUtterance>"u")return"unavailable";const N=new SpeechSynthesisUtterance(v.text),j=window.speechSynthesis.getVoices();N.voice=j.find(S=>S.voiceURI===v.voiceURI)??null,N.rate=v.rate,N.pitch=v.pitch,N.volume=Gie(w.level);try{return window.speechSynthesis.cancel(),window.speechSynthesis.speak(N),"played"}catch{return"unavailable"}}if(!n||n.state!=="running")return"locked";let b;try{b=await n.decodeAudioData(v.bytes.slice(0))}catch{return"broken"}try{const N=n.createBufferSource(),j=n.createGain();return N.buffer=b,j.gain.setValueAtTime(Kie(v.normalizationGain,w.level),n.currentTime),N.connect(j).connect(n.destination),s.add(N),(k=N.addEventListener)==null||k.call(N,"ended",()=>s.delete(N)),N.start(n.currentTime),"played"}catch{return"unavailable"}}function h(m,w=!1){var k,N;if(!w&&!e.enabled())return!1;const v=tle((k=e.prefs)==null?void 0:k.call(e),m),b=((N=e.customSelection)==null?void 0:N.call(e)[m])??null;return b&&e.loadCustom?(d(b,v).then(j=>{var S;j==="played"||j==="locked"||((j==="missing"||j==="broken")&&((S=e.onCustomFailure)==null||S.call(e,m,b)),c(m,{...v,figure:Xn},Xn))}),!0):!n||n.state!=="running"?!1:c(m,v)}function f(m,w=ri){return d(m,{level:Jp(w),figure:Xn}),!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 Tbe({chimesRef:e,soundOnRef:t,tonePrefsRef:n,customSelectionsRef:s,fallbackCustomRef:a}){y.useEffect(()=>{const o=Ebe({enabled:()=>t.current===!0,prefs:()=>n.current,customSelection:()=>s.current,loadCustom:Bie,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 Abe(){const[e,t]=y.useState(kbe),[n,s]=y.useState(()=>ZK(Ke(UE))),[a,o]=y.useState(()=>XK(Ke(WE))),[i,c]=y.useState(()=>JK(Ke(pO),n,wbe)),[d,h]=y.useState(()=>new Set),[f,p]=y.useState(0);y.useEffect(()=>{Ze(c8,String(e))},[e]),y.useEffect(()=>{Ze(WE,a?"1":"0")},[a]),y.useEffect(()=>{Ze(UE,JSON.stringify(n))},[n]),y.useEffect(()=>{Ze(pO,i)},[i]);const m=y.useCallback((N,j=!1)=>{s(S=>{const _=S.find(T=>T.id===N.id);return _?!j||!N.radio||!_.radio||_.url===N.url&&JSON.stringify(_.radio)===JSON.stringify(N.radio)?S:S.map(T=>T.id===N.id?{...T,url:N.url,radio:N.radio}:T):[...S,N]}),h(S=>{if(!S.has(N.id))return S;const _=new Set(S);return _.delete(N.id),_})},[]),w=y.useCallback((N,j)=>{const S=j.trim();!S||S.length>pP||s(_=>_.map(T=>T.id===N?{...T,name:S}:T))},[]),v=y.useCallback(N=>{s(j=>j.filter(S=>S.id!==N)),c(j=>QK(j,N)),h(j=>{if(!j.has(N))return j;const S=new Set(j);return S.delete(N),S})},[]),b=y.useCallback((N,j=!1)=>{const S=HE(N),_=d.has(S);N===i&&!_&&!j||(_&&h(T=>{const L=new Set(T);return L.delete(S),L}),c(N),p(T=>T+1))},[i,d]),k=y.useCallback((N,j)=>{const S=HE(N);h(_=>{if(_.has(S)===j)return _;const L=new Set(_);return j?L.add(S):L.delete(S),L})},[]);return{fmVolume:e,setFmVolume:t,fmMuted:a,setFmMuted:o,fmSource:i,customFmStations:n,unavailableFmStations:d,fmPlayRequest:f,addFmStation:m,renameFmStation:w,removeFmStation:v,pickFmSource:b,markFmStationAvailability:k}}function Rbe(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||!oo())return;let v=!1;const b=c.current;return fetch("/api/desktop-update").then(k=>k.ok?k.json():null).then(k=>{if(v||c.current!==b)return;const N=OI(k);N&&n(N)}).catch(()=>{}),()=>{v=!0}},[e]);const d=_me(t),h=y.useRef(!1),f=y.useRef(0),p=y.useRef(0);y.useEffect(()=>()=>window.clearTimeout(f.current),[]);const m=y.useCallback(async v=>{if(!bn(h.current))return;const b=++p.current;window.clearTimeout(f.current),h.current=!0,a(!0),i(null);const k=N=>{b===p.current&&(window.clearTimeout(f.current),h.current=!1,a(!1),i({failure:N,version:v}))};try{const N=await fetch("/api/desktop-update/restart",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({version:v})});if(!N.ok)return k(Eme(await N.json().catch(()=>null)))}catch{return k("unreachable")}b===p.current&&(f.current=window.setTimeout(()=>k("timeout"),vF))},[]),w=y.useCallback(v=>{if(oo())try{const b=OI(JSON.parse(v));b&&(c.current++,n(b),b.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 Qh="agent-dag.autoRestart",yO="agent-dag.bundleReloadedFor";function Mbe({now:e,stateRef:t,version:n,notice:s,noticeOpen:a,upgradeFailure:o,paused:i}){const[c,d]=y.useState(()=>Ke(Qh)!=="0"),h=y.useRef(!1),f=y.useCallback(()=>{const U=!c;h.current=!0,Ys(Qh),d(U),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:U})}).then(q=>q.ok?q.json():null).then(q=>{var M;q!=null&&q.ok&&d(((M=q.prefs)==null?void 0:M.autoUpdate)!==!1)}).catch(()=>{})},[c]),[p,m]=y.useState(!1),[w,v]=y.useState("restart"),[b,k]=y.useState(null),N=y.useRef(!1),j=y.useRef(null),S=y.useRef(0),_=y.useRef(null),T=y.useCallback(async U=>{if(!bn(N.current))return;const q=(U==null?void 0:U.upgrade)===!0,M=(U==null?void 0:U.whenIdle)===!0;N.current=!0,j.current=o;const I=++S.current,E=()=>{v(q?"npx":"restart"),m(!0)};M||E();try{window.sessionStorage.setItem("agent-dag.restartPending",(s==null?void 0:s.to)??"")}catch{}let D=!1;try{const B=await fetch("/api/restart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(M?{upgrade:q,whenIdle:M}:{upgrade:q})});D=M&&B.status===409}catch{}if(D){N.current=!1,_.current=null;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}return}M&&E(),window.setTimeout(()=>{if(S.current===I&&N.current){N.current=!1,m(!1);try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}}},q?18e4:3e4)},[s==null?void 0:s.to,o]);y.useEffect(()=>{const U=DI(t.current.agents.values())>0,q=fge({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=q.idleSince,q.restart&&T({whenIdle:!0})},[c,s==null?void 0:s.kind,n==null?void 0:n.canRestart,a,e,T]);const L=DI(t.current.agents.values()),A=hge(L,i),P=CF({enabled:c,kind:s==null?void 0:s.kind,canRestart:(n==null?void 0:n.canRestart)===!0,noticeOpen:a,visible:document.visibilityState==="visible",busy:L>0,idleSince:_.current,now:e});y.useEffect(()=>{const U=n==null?void 0:n.running;let q=null,M=null;try{q=window.sessionStorage.getItem("agent-dag.restartPending"),M=window.sessionStorage.getItem(yO)}catch{return}const I=ige({bundle:"3.46.0",running:U,pending:q,lastTried:M});if(I==="reload"){try{window.sessionStorage.setItem(yO,U??"")}catch{return}window.location.reload();return}if(I!=="confirm")return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}N.current=!1,m(!1),k(U??null);const E=window.setTimeout(()=>k(null),6e3);return()=>window.clearTimeout(E)},[n==null?void 0:n.running]),y.useEffect(()=>{if(p&&cge({asked:j.current,reported:o})){try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}N.current=!1,m(!1)}},[p,o]);const O=y.useCallback(U=>{var q,M;if(!h.current){const I=Ke(Qh)==="0";Ys(Qh),I&&((q=U.prefs)==null?void 0:q.autoUpdate)!==!1?(d(!1),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:!1})}).catch(()=>{})):d(((M=U.prefs)==null?void 0:M.autoUpdate)!==!1)}},[]);return{autoRestart:c,toggleAutoRestart:f,restarting:p,restartMode:w,restartedTo:b,askRestart:T,restartCopy:A,restartFuseMs:P,loadAutoRestartPrefs:O}}function $be(){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(tA(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?y1:WD))})};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(tA(m.pending,m.aliases)):t(w=>w.filter(v=>v.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 Lbe=6e4;function Ibe({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(N=>{N!=null&&N.ok&&Array.isArray(N.accounts)&&a(N.accounts)},[]),f=y.useCallback(async N=>{try{const j=await fetch(`/api/claude-accounts${N?"?refresh=1":""}`);j.ok&&h(await j.json())}catch{}},[h]);y.useEffect(()=>{e&&f(!1)},[e,f]),y.useEffect(()=>{if(!e)return;let N=Date.now();const j=()=>{document.visibilityState!=="visible"||Date.now()-N<Lbe||(N=Date.now(),f(!1))};return document.addEventListener("visibilitychange",j),window.addEventListener("focus",j),()=>{document.removeEventListener("visibilitychange",j),window.removeEventListener("focus",j)}},[e,f]);const p=y.useMemo(()=>e?Mye(s,{lan:t,now:n,closed:o}):[],[e,s,t,n,o]),m=y.useRef(p);m.current=p;const w=y.useCallback(N=>{N.length&&i(j=>new Set([...j,...N]))},[]),v=y.useCallback(()=>{const N=m.current;N.length&&(w(N.map(j=>j.id)),fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"reauth-later",incidents:N.map(j=>({key:j.key,since:j.since}))})}).catch(()=>{}))},[w]),b=y.useRef(c);b.current=c;const k=y.useCallback(N=>{const j=b.current;w($ye(j?[j,...m.current]:m.current,N))},[w]);return{rows:p,signingIn:c,observe:h,signIn:d,signedIn:k,refresh:y.useCallback(()=>{f(!0)},[f]),closeSignIn:y.useCallback(()=>d(null),[]),later:v}}const d8=288,Obe=d8;function Pbe(e,t,n){return e?"session-list":t||n?"accounts":null}function wO(e){return e==="session-list"?Obe:e==="accounts"?d8:0}const Dbe=240,Fbe=20;function Bbe(e){const t=y.useRef(0),n=y.useRef(e);return y.useLayoutEffect(()=>{n.current!==e&&(n.current=e,t.current=Hu()?0:performance.now()+Dbe+Fbe)},[e]),t}const h8="agent-dag.sessionListOpen",f8="agent-dag.accountsPanelOpen";function qbe(){return Ke(h8)==="1"}function Ube(e){Ze(h8,e?"1":"0")}function Wbe(){const e=Ke(f8);return e===null?!0:e==="1"}function Hbe(){const e=y.useRef(!1),t=y.useRef(!1),[n,s]=y.useState(()=>{const v=qbe();return v&&$1()?(e.current=!0,!1):v});y.useEffect(()=>{if(n)e.current=!1;else if(e.current)return;Ube(n)},[n]);const a=y.useRef(!1),[o,i]=y.useState(()=>{const v=Wbe();return v&&n?(a.current=!0,!1):v&&$1()?(t.current=!0,!1):v});y.useEffect(()=>{if(o)t.current=!1;else if(t.current)return;!o&&a.current||Ze(f8,o?"1":"0")},[o]),y.useEffect(()=>{!n&&a.current&&(a.current=!1,i(!0))},[n]);const c=y.useCallback(()=>{s(v=>(v||i(b=>(b&&(a.current=!0),!1)),!v))},[]),d=y.useCallback(()=>{a.current=!1,i(v=>(v||s(!1),!v))},[]),h=y.useCallback(()=>{a.current=!1,i(v=>(v||s(!1),!0))},[]),f=y.useCallback(()=>s(!1),[]),p=y.useCallback(()=>{a.current=!1,s(!1)},[]),m=y.useCallback(()=>i(!1),[]),w=Pbe(n,o,a.current);return{sessionListOpen:n,accountsPanelOpen:o,panel:w,toggleSessionList:c,toggleAccountsPanel:d,openAccountsPanel:h,closeSessionList:f,closeSessionListToCanvas:p,closeAccountsPanel:m}}const p8="agent-dag.detailOpen",m8="agent-dag.usagePanelOpen",g8="agent-dag.systemPanelOpen";function zbe(){return Ke(p8)==="1"}function Vbe(e){Ze(p8,e?"1":"0")}function Gbe(){const e=Ke(m8);return e===null?!0:e==="1"}function Kbe(e){Ze(m8,e?"1":"0")}function Ybe(){const e=Ke(g8);return e===null?!0:e==="1"}function Xbe(e){Ze(g8,e?"1":"0")}function Zbe(e=0){const[t,n]=y.useState(zbe);y.useEffect(()=>{Vbe(t)},[t]);const[s,a]=y.useState(Gbe);y.useEffect(()=>{Kbe(s)},[s]);const o=y.useRef(!1),[i,c]=y.useState(()=>{const d=Ybe();return d&&s&&($1()||lpe(e))?(o.current=!0,!1):d});return y.useEffect(()=>{if(i)o.current=!1;else if(o.current)return;Xbe(i)},[i]),tn("usage-panel",s),tn("machine-panel",i),{detailOpen:t,setDetailOpen:n,usagePanelOpen:s,setUsagePanelOpen:a,machinePanelOpen:i,setMachinePanelOpen:c}}const Jbe={permission:"your permission",asked:"your answer"},Qbe="No sessions are waiting for you.";function eke(e){if(e.length===0)return"";const[t,...n]=e,s=t.waiting.kind,a=n.every(i=>i.waiting.kind===s)?Jbe[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 m0(e,t,n=Qbe){return t!==""?t:e===""?"":n}function tke({waitingSessions:e,watchUnseen:t,incidents:n=[]}){const[s,a]=y.useState(""),o=eke(e);y.useEffect(()=>{a(m=>m0(m,o))},[o]);const[i,c]=y.useState(""),d=t>0?`Browser watch has ${t} unread ${t===1?"finding":"findings"}.`:"";y.useEffect(()=>{c(m=>m0(m,d,"Browser watch has no unread findings."))},[d]);const[h,f]=y.useState(""),p=hbe(n);return y.useEffect(()=>{f(m=>m0(m,p,fbe))},[p]),{blockedSaid:s,watchSaid:i,setWatchSaid:c,incidentSaid:h}}const nke="/icon-192.png",y8=Object.freeze({notifySwap:!0,notifyQuota:!1,notifyReset:!1,notifyStopped:!0,notifyElsewhere:!0});function xO(e){const t=n=>typeof(e==null?void 0:e[n])=="boolean"?e[n]:y8[n];return{notifySwap:t("notifySwap"),notifyQuota:t("notifyQuota"),notifyReset:t("notifyReset"),notifyStopped:t("notifyStopped"),notifyElsewhere:t("notifyElsewhere")}}function ske({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(y8),w=y.useCallback(P=>{const O=!p[P];m(U=>({...U,[P]:O})),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({[P]:O})}).then(U=>U.ok?U.json():null).then(U=>{U!=null&&U.ok&&m(xO(U.prefs))}).catch(()=>{})},[p]),v=y.useRef(()=>{}),b=y.useRef(new Set),k=Ln(e),N=y.useCallback(()=>{const P=!c;d(P),P&&(b.current=$h(k.current)),P&&typeof Notification<"u"&&Notification.permission==="default"&&v.current(),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({notifications:P})}).then(O=>O.ok?O.json():null).then(O=>{var U;O!=null&&O.ok&&(d(((U=O.prefs)==null?void 0:U.notifications)===!0),f(O.notificationsVetoed===!0))}).catch(()=>{})},[c]),j=typeof Notification<"u";y.useEffect(()=>{if(!o)return;const O=setTimeout(()=>i(null),o==="blocked"?8e3:4e3);return()=>clearTimeout(O)},[o]);const S=y.useCallback(()=>{typeof Notification>"u"||Notification.requestPermission().then(P=>{const O=P;a(O),O==="granted"?i("on"):O==="denied"&&i("blocked")})},[]);v.current=S;const _=y.useRef(null),T=e.map(P=>Ep(P.id,P.waiting)).join("|");y.useEffect(()=>{NV(_.current,s)&&(_.current=s,b.current=$h(e))},[s]);const L=y.useRef(!1);y.useEffect(()=>{SV(L.current,t)&&(L.current=!0,b.current=$h(e))},[t]),y.useEffect(()=>{if(typeof Notification>"u"||Notification.permission!=="granted"||!_V(_.current,t))return;const P=typeof document>"u"||!document.hidden,O=kV(e,b.current,P,c);for(const U of O)try{const q=new Notification(U.title,{body:U.body,tag:U.key,icon:nke});q.onclick=()=>{window.focus(),n(U.sessionId),q.close()}}catch{}b.current=P?$h(e):jV(e,O,b.current)},[T,t]);const A=y.useCallback(P=>{var O;d(((O=P.prefs)==null?void 0:O.notifications)===!0),f(P.notificationsVetoed===!0),m(xO(P.prefs))},[]);return{notifyPermission:s,notifySaid:o,notifyOn:c,notifyVetoed:h,toggleNotify:N,notifySupported:j,askForNotifications:S,loadNotifyPrefs:A,accountNotify:p,toggleAccountNotify:w}}function rke({openedTool:e,usageHistoryOpen:t,contextFor:n,tourOpen:s,summaryFor:a,browserWatchOpen:o,keyHelpOpen:i,releaseNotes:c,feedbackOpen:d,trafficRadarOpen:h=!1}){const f=Ln(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 ake({stateRef:e,tourOpen:t,releaseNotes:n}){const[s,a]=y.useState(null),o=y.useCallback((M,I)=>a({agentId:M,toolId:I}),[]),[i,c]=y.useState(null),[d,h]=y.useState(null),f=y.useCallback(M=>h(M),[]),[p,m]=y.useState(!1),[w,v]=y.useState(!1),[b,k]=y.useState(!1),[N,j]=y.useState(!1),[S,_]=y.useState(!1),[T,L]=y.useState(null),A=y.useCallback(M=>{L(M??null),_(!0)},[]);tn("tool-detail",s!==null),tn("session-summary",i!==null),tn("context-window",d!==null),tn("keyboard-help",p),tn("usage-history",w),tn("browser-watch",b),tn("feedback",S);const P=s?p9(e.current.agents,s.agentId,s.toolId):null,O=d?e.current.agents.get(d):void 0,{keyHelpOpenRef:U,modalOpenRef:q}=rke({openedTool:P,usageHistoryOpen:w,contextFor:d,tourOpen:t,summaryFor:i,browserWatchOpen:b,keyHelpOpen:p,releaseNotes:n,feedbackOpen:S,trafficRadarOpen:N});return{setOpenedToolKey:a,openTool:o,openedTool:P,summaryFor:i,setSummaryFor:c,contextFor:d,setContextFor:h,openContext:f,contextAgent:O,keyHelpOpen:p,setKeyHelpOpen:m,usageHistoryOpen:w,setUsageHistoryOpen:v,browserWatchOpen:b,setBrowserWatchOpen:k,trafficRadarOpen:N,setTrafficRadarOpen:j,feedbackOpen:S,setFeedbackOpen:_,feedbackPrefill:T,setFeedbackPrefill:L,openFeedback:A,keyHelpOpenRef:U,modalOpenRef:q}}function oke({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=fj(),t.current.clear(),n.current.clear(),s.current.clear(),a.current="",F6(),o(),i(),c()},[c,i,o]),m=Ln(h),w=y.useCallback(v=>{const b=gge(v,{confirmOpen:m.current,modalOpen:d.current});b==="confirm"?f(!0):b==="clear"&&(f(!1),p())},[p]);return{clearConfirmOpen:h,setClearConfirmOpen:f,requestClear:w}}const vO="agent-dag.oldNameNoticeDismissed";function ike(e){const[t,n]=y.useState(()=>Ke(vO)??""),s=e!=null&&e.invokedAs&&e.invokedAs!==Rt?e.invokedAs:null,a=s!=null&&t!==s,o=y.useCallback(()=>{s&&(n(s),Ze(vO,s))},[s]);return{oldName:s,oldNameOpen:a,dismissOldName:o}}const lke=300*1e3,cke=1800*1e3,uke=8e3,dke=3e4;function bO(e){return fetch("/api/rating",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)}).catch(()=>null)}function hke({modalOpenRef:e}){const t=y.useCallback(()=>af({appModal:e.current,dialogDepth:vn.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 v=async()=>{if(d.current==="thanks"||d.current==="hidden"&&(document.hidden||t()))return;const N=await fetch("/api/rating").then(j=>j.ok?j.json():null).catch(()=>null);w||!N||s(j=>j==="thanks"?j:N.ask===!0?"asking":"hidden")},b=window.setTimeout(v,lke),k=window.setInterval(v,cke);return()=>{w=!0,window.clearTimeout(b),window.clearInterval(k)}},[t]),y.useEffect(()=>{if(n!=="thanks"||i)return;const w=a!==null&&a<=6?dke:uke;let v=0;const b=()=>{t()?v=window.setTimeout(b,w):s("hidden")};return v=window.setTimeout(b,w),()=>window.clearTimeout(v)},[n,a,i,t]);const h=y.useCallback(w=>{o(w),c(!1),s("thanks"),bO({score:w})},[]),f=y.useCallback(w=>c(w),[]),p=y.useCallback(()=>{s("hidden"),bO({later:!0})},[]),m=y.useCallback(()=>s("hidden"),[]);return{ratingPhase:n,ratingScore:a,answerRating:h,rateLater:p,closeRating:m,holdThanks:f}}function fke({chimesRef:e,setTonePrefs:t,tonePrefsRef:n,previewTone:s}){const[a,o]=y.useState(()=>Eie(Ke)),i=Ln(a),[c,d]=y.useState([]),h=y.useCallback(j=>{o(S=>{const _={...S,[j]:null};return i.current=_,_}),Ys(du[j])},[]),f=y.useCallback((j,S)=>{const _=i.current[j];S&&_!==S||(h(j),t(T=>{const L={...T,[j]:{...T[j],figure:Xn}};return n.current=L,L}),Ze(ap[j],Xn))},[h]),p=Ln(f);y.useEffect(()=>{let j=!0;return Fie().then(S=>{if(!j)return;d(S);const _=new Set(S.map(T=>T.id));for(const T of hu){const L=i.current[T];L&&!_.has(L)&&p.current(T,L)}},()=>{}),()=>{j=!1}},[]);const m=y.useCallback((j,S)=>{if(!c.some(T=>T.id===S))return;const _={...i.current,[j]:S};i.current=_,o(_),Ze(du[j],S),s(j,!0)},[c,s]),w=y.useCallback(async j=>{var L;const S=N1(c.length);if(S)throw new Error(S);const _=window.AudioContext??window.webkitAudioContext;if(!_)throw new Error("This browser cannot decode audio files.");const T=new _;try{const A=await Lie(j,O=>T.decodeAudioData(O));await FA(A);const P=Fu(A);d(O=>[...O.filter(U=>U.id!==P.id),P])}finally{(L=T.close)==null||L.call(T)}},[c.length]),v=y.useCallback(async j=>{const S=N1(c.length);if(S)throw new Error(S);const _=Iie(j);await FA(_);const T=Fu(_);d(L=>[...L.filter(A=>A.id!==T.id),T])},[c.length]),b=y.useCallback(async(j,S)=>{const _=c.find(L=>L.id===j),T=S.trim().slice(0,80);!_||!T||T===_.name||(await qie(j,T),d(L=>L.map(A=>A.id===j?{...A,name:T}:A)))},[c]),k=y.useCallback(async j=>{await Uie(j),d(L=>L.filter(A=>A.id!==j));const S=i.current,_=Tie(S,j);i.current=_,o(_);const T=hu.filter(L=>S[L]===j);for(const L of T)Ys(du[L]),Ze(ap[L],Xn);T.length>0&&t(L=>{const A={...L};for(const P of T)A[P]={...A[P],figure:Xn};return n.current=A,A})},[]),N=y.useCallback(j=>{var T,L;const S=hu.find(A=>i.current[A]===j),_=S?n.current[S].level:ri;(T=e.current)==null||T.unlock(),(L=e.current)==null||L.previewCustom(j,_)},[]);return{customSelections:a,customSelectionsRef:i,customAssets:c,clearCustomOnly:h,fallbackCustomRef:p,selectCustomTone:m,importNotificationAudio:w,createNotificationVoice:v,renameCustomAsset:b,deleteCustomAsset:k,previewCustomAsset:N}}function pke(e){const[t,n]=y.useState(()=>ele(Ke)),s=Ln(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)},Yie)},[]),i=y.useCallback((c,d)=>{n(h=>{const f={level:Jp(d.level??h[c].level),figure:S5(c,d.figure??h[c].figure)};return Ze(E5[c],String(f.level)),Ze(ap[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 mke=15e3;function gke(e){return e.visibilityState==="visible"&&e.hasFocus()}function yke(e,t){return t||e===!0}function wke(){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 xke(){y.useEffect(()=>{const e=wke();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=gke(document);yke(t,i)&&n(i),t=i},a=()=>{t&&n(!1),t=!1};s();const o=window.setInterval(s,mke);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 vke({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 g0="agent-dag.versionNoticeDismissed",bke=15*6e4;function kke(e){const[t,n]=y.useState(null),[s,a]=y.useState(()=>Ke(g0)??""),o=y.useRef(0),[i,c]=y.useState(!1),d=y.useCallback((b=!1)=>(b&&(o.current=Date.now(),c(!0)),fetch(b?"/api/version?refresh=1":"/api/version").then(k=>k.ok?k.json():null).then(k=>(k&&n(k),k??null)).catch(()=>null).finally(()=>{b&&c(!1)})),[]),h=y.useCallback(()=>{d(Date.now()-o.current>=bke)},[d]);y.useEffect(()=>{d();const b=window.setInterval(h,5*6e4),k=()=>{document.visibilityState==="visible"&&h()};return document.addEventListener("visibilitychange",k),()=>{window.clearInterval(b),document.removeEventListener("visibilitychange",k)}},[d,h]),y.useEffect(()=>{e&&d()},[e,d]);const f=(t==null?void 0:t.notice)??null,p=NF(f),m=$me(f,s),w=y.useCallback(()=>{a(""),Ze(g0,"")},[]),v=y.useCallback(()=>{f&&(a(p),Ze(g0,p))},[f,p]);return{version:t,notice:f,noticeOpen:m,showNotice:w,dismissNotice:v,versionChecking:i,loadVersion:d}}function jke({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 k=wr(),N=ewe(k),j=owe({stored:N,running:(e==null?void 0:e.running)??null,notes:VI,remembers:twe(k)});if(j.reason==="no-version")return;h.current=!0,j.record&&nwe(k,j.record);let S=!0;return(async()=>{var P;let T=swe(k);if(oo())try{const O=await fetch("/api/prefs");if(!O.ok)throw new Error("desktop tour preferences unavailable");const U=await O.json();if(!(U!=null&&U.ok))throw new Error("desktop tour preferences unavailable");const q=((P=U.prefs)==null?void 0:P.tourSeen)===!0;T&&!q&&fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tourSeen:!0}),keepalive:!0}).catch(()=>{}),T=T||q}catch{T=!0}if(!S)return;const L=awe({tourSeen:T,decision:j}),A=j.show.length?{entries:j.show,since:N,firstRun:!1}:null;L.tour&&s(!0),L.notes==="now"?i(A):L.notes==="after"&&(a.current=A)})(),()=>{S=!1}},[e==null?void 0:e.running]);const f=(e==null?void 0:e.running)??"3.46.0",p=y.useMemo(()=>BF(VI,null,f),[f]),m=y.useCallback(()=>{i({entries:p,since:null,firstRun:!1})},[p]),w=y.useCallback(()=>s(!0),[]),v=y.useCallback(()=>i(null),[]),b=y.useCallback(()=>{s(!1),rwe(wr()),oo()&&fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tourSeen:!0}),keepalive:!0}).catch(()=>{});const k=a.current;a.current=null,k&&i(k)},[]);return{tourOpen:n,openTour:w,closeTour:b,releaseNotes:o,closeReleaseNotes:v,chipVersion:f,openReleaseNotes:m}}function Nke(){const[e,t]=y.useState(void 0),[n,s]=y.useState(!1),a=y.useRef(!1);return a.current=e===!0&&!n,y.useEffect(()=>Uve(()=>a.current),[]),{loadReportsPrefs:y.useCallback(i=>{var c;t(((c=i.prefs)==null?void 0:c.reports)!==!1),s(i.reportsVetoed===!0)},[])}}function Ske(e){const[t,n]=y.useState(null);y.useEffect(()=>{const c=Ke("agent-dag.sound");n(c===null?!0:c==="on")},[]);const s=y.useCallback(()=>{n(c=>{var h,f;const d=c!==!0;return Ze("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=Ln(a),i=Ln(t);return{soundOn:t,toggleSound:s,activateSoundRef:o,soundOnRef:i}}function _ke(){const[e,t]=y.useState(Nfe),n=y.useCallback(o=>{t(i=>Sfe(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 Cke="agent-dag.autoFitDisabled";function Eke(e){const t=y.useRef(!1),[n,s]=y.useState(!1);y.useEffect(()=>{Ys(Cke)},[]);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 Tke(){return r.jsx(hj,{children:r.jsx(zve,{children:r.jsx(Ake,{})})})}function Ake(){var Ed;const e=Ll(),t=y.useState(fj)[0],n=y.useRef(t),[,s]=y.useState(0),a=y.useCallback(()=>s(gt=>gt+1),[]),{sessionListOpen:o,accountsPanelOpen:i,panel:c,toggleSessionList:d,toggleAccountsPanel:h,openAccountsPanel:f,closeSessionList:p,closeSessionListToCanvas:m,closeAccountsPanel:w}=Hbe(),{detailOpen:v,setDetailOpen:b,usagePanelOpen:k,setUsagePanelOpen:N,machinePanelOpen:j,setMachinePanelOpen:S}=Zbe(wO(c)),{selectedIds:_,primarySelectedId:T,selectAgent:L,clearSelection:A,pruneSelectionToBoard:P}=wle(n,b),O=al(i,200),U=al(o,200),q=oE(o,U),M=al(k,130),I=al(j,130),E=y.useRef(null),D=Ske(E),{activateSoundRef:B,soundOnRef:H}=D,G=pke(E),{setTonePrefs:z,tonePrefsRef:F,previewTone:$}=G,W=fke({chimesRef:E,setTonePrefs:z,tonePrefsRef:F,previewTone:$}),{customSelectionsRef:Z,fallbackCustomRef:V}=W,Y=_ke(),{openSettings:X}=Y;Tbe({chimesRef:E,soundOnRef:H,tonePrefsRef:F,customSelectionsRef:Z,fallbackCustomRef:V});const J=Kve(n),{pauseGate:Q,paused:te,togglePause:ce}=J,ue=y.useRef(()=>{}),{live:ie,tabCapped:re,everConnected:fe,liveSince:ae}=lle({stateRef:n,rerender:a,pauseGate:Q,chimesRef:E,desktopUpdateRef:ue}),je=kke(ie),{version:me,notice:pe,noticeOpen:xe,loadVersion:_e}=je,ye=Rbe(ie),{readyAppUpdate:Ie,onDesktopUpdateEvent:Pe}=ye;ue.current=Pe,xke();const Ue=jke({version:me,readyAppUpdate:Ie}),{tourOpen:$e,openTour:Je,releaseNotes:Qe}=Ue,{workspace:ze,providers:Ne,providersRef:Ae}=Xve(ie),qe=wO(c==="accounts"&&!Ne.claude?null:c),et=Bbe(qe),ot=oE(i,O)&&Ne.claude,[we,Ge]=y.useState(!1),Ye=y.useCallback(()=>{f(),Ge(!0)},[f]);y.useEffect(()=>{i||Ge(!1)},[i]);const Xe=y.useCallback(()=>Ge(!1),[]),rt=ike(me),jt=pbe({version:me,loadVersion:_e}),{upgradeFailure:Ut}=jt,pt=ake({stateRef:n,tourOpen:$e,releaseNotes:Qe}),Ct=hke({modalOpenRef:pt.modalOpenRef}),{openTool:It,setSummaryFor:Wt,setContextFor:tr,openContext:Cs,setKeyHelpOpen:Jn,setUsageHistoryOpen:Qn,setBrowserWatchOpen:Es,keyHelpOpenRef:fn,modalOpenRef:Un}=pt,Ce=Nke(),Re=gbe(),{watchOn:He,watchUnseen:vt}=Re,Et=cd(),[es,ts]=y.useState(null),pn=y.useCallback(()=>ts(null),[]),nr=dF().filter(gt=>ume(Et,gt.kind)),mn=Ln(gt=>{const Pr=nr.find(wo=>wo.kind===gt);Pr&&ts(Pr.kind)}),nn=y.useCallback(gt=>{yme(gt),X("integrations")},[X]),ns=nr.length>0;y.useEffect(()=>{ns&&nme()},[ns]);const Ts=$be(),[sr,As]=y.useState(0),{presentCats:rr,hiddenCats:ar,toggleCat:or,catBarRef:ha,catBarOccluded:ht}=Cbe(n),fa=y.useRef(null),[Tr,pa]=y.useState(0),Mt=xle({stateRef:n,rerender:a,pruneSelectionToBoard:P,setContextFor:tr,setSummaryFor:Wt});wK({stateRef:n,now:Mt,enabled:Ne.claude});const Ar=ebe(Ne.claude||Ne.codex),ir=dbe(Ar,Mt),ss=Ibe({enabled:Ne.claude,lanStatus:Ts.lanStatus,now:Mt}),Zt=Mbe({now:Mt,stateRef:n,version:me,notice:pe,noticeOpen:xe,upgradeFailure:Ut,paused:J.paused}),{askRestart:Rr,loadAutoRestartPrefs:on}=Zt,ma=_be(),{setTheme:ui,palette:Vl}=ma,Mr=Abe(),Rs=ghe(),{applyViewport:lr,moveCamera:ge,fitLeft:We,cameraEpochRef:dt,lastFitTimeRef:Nt}=Rs,Nn=Ahe(Rs),{pinnedRef:rs,positionsRef:as,lastLayoutSigRef:Gl,handleRelayout:ga,rearrangeUndo:at}=Nn,Kl=y.useRef(null),Yl=y.useRef(()=>{}),di=ae!==null,Xl=y.useRef(0),Zl=y.useCallback(()=>{Xl.current=Date.now()},[]),{canvasRef:Ms,canvasSize:Jl,paneSizeRef:hi}=wfe(et),$s=Eke(We),{autoFitDisabledRef:Ls,disableAutoFit:os}=$s,$r=y.useRef(!1),{measuredRef:Wn,measuredVersionRef:cr,sizeVersion:ym,domSizeVersion:dd}=xfe($r),{removedNodes:Lr,removedAgentIds:ya,removeNode:hd,removeSelectedNode:ho,removalNotice:Ql,hideSessions:wm,bringBack:Ir,bringBackAll:fo,forgetRemovals:wa}=Zhe({stateRef:n,pinnedRef:rs,positionsRef:as,canvasRef:Ms,clearSelection:A,primarySelectedId:T});ife({stateRef:n,removedNodes:Lr,hideSessions:wm,ready:di,keepSessionId:T?((Ed=n.current.agents.get(T))==null?void 0:Ed.sessionId)??T:null});const xa=Vhe({stateRef:n,now:Mt,removedAgentIds:ya,sizeVersion:ym,domSizeVersion:dd});Rhe(xa,Nn),Xhe({layoutSig:xa,rf:e,stateRef:n,measuredRef:Wn,pinnedRef:rs,positionsRef:as,paneSizeRef:hi,lastInteractRef:Xl,autoFitDisabledRef:Ls,lastFitTimeRef:Nt,fitLeft:We});const fd=vfe(),{bubbling:xm,endBubble:ec,onBubble:fi}=pie(),[po,pd]=y.useState(!1),Is=hie(),{beginTrashDrag:tc,trackTrashDrag:pi,endTrashDrag:md}=Is,mo=bie({stateRef:n,measuredRef:Wn,measuredVersionRef:cr,canvasRef:Ms}),{lodRef:mi,applyZoom:gd}=mo,ln=mfe({applyViewport:lr,lastFitTimeRef:Nt,cameraEpochRef:dt,disableAutoFit:os,markInteract:Zl,canvasRef:Ms,applyZoom:gd}),is=T?n.current.agents.get(T):null,go=v&&is!=null,ls=$fe({sessionListShown:q,usageShown:Xa(M),machineShown:Xa(I),accountsShown:ot,detailShown:go,primarySelectedId:T,canvasRef:Ms}),{railInsetRef:gi,availableWidth:yi,availableHeight:wi}=dhe({canvasRef:Ms,canvasSize:Jl,machinePhase:I,usagePhase:M,usagePanelOpen:k,detailShown:go}),va=Ghe({stateRef:n,now:Mt,availableWidth:yi,availableHeight:wi,layout:Nn,measuredRef:Wn,onBubble:fi,settled:fd,dragging:po,layoutSig:xa,selectedIds:_,openContext:Cs,historyReplayed:di,removedNodes:Lr,removedAgentIds:ya,dragTick:sr,dragPatchRef:fa,dragMoveTick:Tr}),{nodes:ba,edges:yd}=va,nc=Ln(T);Mhe({nodes:ba,edges:yd,settled:fd,dragging:po,availableWidth:yi,availableHeight:wi,layout:Nn,camera:Rs,rf:e,measuredRef:Wn,stateRef:n,lastFocusRef:Kl,primarySelectedIdRef:nc,focusAgentRef:Yl,autoFitDisabledRef:Ls});const wd=oke({stateRef:n,pinnedRef:rs,measuredRef:Wn,positionsRef:as,lastLayoutSigRef:Gl,forgetRemovals:wa,clearSelection:A,rerender:a,modalOpenRef:Un}),{requestClear:xd}=wd,sc=Lfe({nodes:ba,stateRef:n,pinnedRef:rs,positionsRef:as,draggingRef:$r,dragPatchRef:fa,setDragging:pd,setDragMoveTick:pa,setDragTick:As,endBubble:ec,markInteract:Zl,disableAutoFit:os,beginTrashDrag:tc,trackTrashDrag:pi,endTrashDrag:md,removeNode:hd}),vm=y.useCallback(()=>We(500),[We]),rc=Ln(ba),{focusAgent:xi,stepAgent:bm,focusSession:ka}=whe({canvasRef:Ms,stateRef:n,measuredRef:Wn,nodesRef:rc,railInsetRef:gi,moveCamera:ge,disableAutoFit:os,lastFocusRef:Kl,focusAgentRef:Yl,selectAgent:L,primarySelectedIdRef:nc}),vd=gfe({clearSelection:A,selectAgent:L,detailOpen:v,setDetailOpen:b,detailShown:go,focusAgent:xi,draggingRef:$r,lodRef:mi}),km=xhe({nodesRef:rc,stateRef:n,canvasRef:Ms,railInsetRef:gi}),jm=Ln(ho),ac=y.useRef(null),vi=y.useCallback(gt=>{ya.has(gt)&&Ir([gt]),ka(gt)},[ya,Ir,ka]),oc=bfe();Rfe({pointerFocusRef:oc,nodesRef:rc,stateRef:n,primarySelectedIdRef:nc,providersRef:Ae,soundOnRef:H,keyHelpOpenRef:fn,modalOpenRef:Un,waitingCursorRef:ac,removeSelectedRef:jm,activateSoundRef:B,clearSelection:A,selectAgent:L,focusAgent:xi,stepAgent:bm,focusSession:ka,requestClear:xd,handleRelayout:ga,undoRearrange:at.undo,handleFit:vm,togglePause:ce,toggleSessionList:d,toggleAccountsPanel:h,setDetailOpen:b,setUsageHistoryOpen:Qn,setUsagePanelOpen:N,setMachinePanelOpen:S,setBrowserWatchOpen:Es,setKeyHelpOpen:Jn,setTheme:ui,openSettings:X,openIntegrationRef:mn});const bd=n.current.agents.size,ja=y.useMemo(()=>P0(n.current.agents.values()),[n.current,n.current.revision]);Jhe({stateRef:n,waitingSessions:ja,removedAgentIds:ya,removedNodes:Lr,bringBack:Ir}),hfe({stateRef:n,waitingSessions:ja,live:ie});const kd=tke({waitingSessions:ja,watchUnseen:vt,incidents:ir}),bi=ske({waitingSessions:ja,liveSince:ae,focusSession:ka}),{loadNotifyPrefs:Nm}=bi;vke({loadAutoRestartPrefs:on,loadNotifyPrefs:Nm,loadReportsPrefs:Ce.loadReportsPrefs});const Or=Bp(Q6),[jd,Nd]=y.useState(!1),[Sd,ic]=y.useState(null),Sm=y.useCallback(()=>ic(null),[]),lc=y.useCallback(gt=>{const Pr=n.current.agents.get(gt);return Pr?Pr.label||Pr.cwdBasename||"session":null},[]),yo=y.useCallback(gt=>{ic(null),vi(gt)},[vi]),_m=y.useCallback(()=>Nd(!1),[]),[cc,uc]=y.useState(null),_d=y.useCallback(()=>uc(null),[]),Sn=wpe({providers:Ne,sessionListOpen:o,toggleSessionList:d,accountsPanelOpen:i,toggleAccountsPanel:h,usagePanelOpen:k,setUsagePanelOpen:N,machinePanelOpen:j,setMachinePanelOpen:S,setUsageHistoryOpen:Qn,watchOn:He,watchUnseen:vt,setBrowserWatchOpen:Es,setTrafficRadarOpen:pt.setTrafficRadarOpen,openSettings:X,onFeedback:pt.openFeedback,radioOpen:jd,setRadioOpen:Nd,openToolActivity:ic,openCapacity:uc,toggles:ls.toggles,integrations:nr.map(gt=>({provider:gt,onPress:()=>ts(gt.kind)}))}),[Cd,Na]=y.useState(0),Cm=y.useCallback(gt=>{vi(gt),Or&&m()},[vi,Or,m]),Em=y.useCallback(()=>{o||d(),requestAnimationFrame(()=>{var gt;return(gt=document.querySelector("#session-list .sl-row"))==null?void 0:gt.focus()})},[o,d]);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(BZ,{}),r.jsx(Hme,{versionCheck:je,welcome:Ue,desktopUpdate:ye,pause:J,announcements:kd,notify:bi,waitingSessions:ja,waitingCursorRef:ac,focusSession:ka,live:ie,now:Mt,incidents:ir,queueNamed:Or?0:Cd}),!Or&&r.jsx(qme,{waitingSessions:ja,waitingCursorRef:ac,focusSession:ka,now:Mt,onFit:Na,onMore:Em}),is&&r.jsx(zme,{selected:is,now:Mt,selectedIds:_,focusAgent:xi,clearSelection:A}),!Or&&r.jsx("div",{className:"actions",children:r.jsx(mpe,{items:Sn.utilities})})]}),Or?r.jsx(ppe,{items:[...Sn.left,...Sn.right[0],Sn.utilities[0]],more:[...Sn.capacity,...Sn.right.slice(1).flat(),...Sn.integrations,Sn.utilities[1]]}):r.jsx(SI,{side:"left",label:"Left column",groups:[Sn.leftStripe,Sn.integrations]}),r.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:Ql?`${Ql.label} removed from the board.`:""}),r.jsx(mge,{restart:Zt,versionCheck:je,upgrade:jt,oldNameNotice:rt,rating:Ct,onFeedback:pt.openFeedback,everConnected:fe,live:ie,paused:te}),(q||ot)&&r.jsxs(aie,{width:qe,children:[ot&&r.jsx(boe,{leaving:iE(i,O),onReport:pt.openFeedback,onRoster:ss.observe,onClose:()=>{ls.accounts(),w()},lanWanted:we,onLanShown:Xe}),q&&r.jsx(eJ,{leaving:iE(o,U),state:n.current,now:Mt,selectedIds:_,onSelect:Cm,onClose:()=>{ls.sessionList(),p()},removedIds:ya,onBringBackAll:fo})]}),r.jsxs(Xme,{canvasRef:Ms,bubbling:xm,dragging:po,trash:Is,zoom:mo,viewport:ln,stateRef:n,peek:km,children:[bd===0&&(!ie&&re?r.jsx(Ofe,{reservedRight:gi.current}):r.jsx(Pfe,{live:ie,everConnected:fe,providers:Ne,workspace:ze,onTour:Je,reservedRight:gi.current})),(rr.length>1||ar.size>0)&&r.jsx(Vme,{catBarRef:ha,catBarOccluded:ht,presentCats:rr,hiddenCats:ar,toggleCat:or}),r.jsx(FZ,{graph:va,layout:Nn,viewport:ln,clicks:vd,drag:sc,appearance:ma,fm:Mr,radioOpen:jd,onRadioClose:_m,autoFit:$s,pause:J,stateRef:n,measuredRef:Wn,hiddenCats:ar,now:Mt,openTool:It,focusAgent:xi,requestClear:xd,setKeyHelpOpen:Jn})]}),!Or&&r.jsx(SI,{side:"right",label:"Right panels",groups:Sn.right}),Sd&&r.jsx(FJ,{view:Sd,onClose:Sm,sessionLabel:lc,onOpenSession:yo}),cc&&r.jsx(rie,{view:cc,onClose:_d}),es&&r.jsx(ame,{kind:es,connections:ud(Et,es)?gF(Et,es):[],onClose:pn,onReconnect:nn}),Xa(M)&&r.jsx(KQ,{state:n.current,now:Mt,providers:Ne,incidents:ir,liveSince:ae,leaving:M==="leaving",onClose:()=>{ls.usage(),N(!1)}}),Xa(I)&&r.jsx($ee,{usageOpen:k,leaving:I==="leaving",onClose:()=>{ls.machine(),S(!1)}}),v&&is?r.jsx(Zfe,{selected:is,now:Mt,openTool:It,setSummaryFor:Wt,stateRef:n,removeSelectedNode:ho,onClose:()=>{ls.detail(),b(!1)}}):null,r.jsx(Sve,{dialogs:pt,welcome:Ue,desktopUpdate:ye,versionCheck:je,restart:Zt,upgrade:jt,lanPairs:Ts,attention:ss,clearFlow:wd,watchBadge:Re,announcements:kd,appearance:ma,providers:Ne,stateRef:n,agentCount:bd,menus:Y,sound:D,tones:G,customTones:W,notify:bi,panelDoors:{accounts:f,localNetwork:Ye}})]})}try{uG(window.localStorage)}catch{}const Rke=CB.createRoot(document.getElementById("root"));window.ccdeckWindow&&(document.documentElement.dataset.desktopChrome="true",document.documentElement.dataset.desktopPlatform=window.ccdeckWindow.platform);Rke.render(r.jsx(Tke,{}));export{zke as $,Hp as A,Bke as B,xt as C,hF as D,Xj as E,Zke as F,tD as G,st as H,vr as I,s1 as J,CT as K,r1 as L,Pke as M,wt as N,to as O,Jr as P,Dke as Q,JP as R,Fke as S,Rf as T,Jke as U,Pu as V,Bn as W,Mie as X,Hke as Y,Gke as Z,cwe as _,Ys as a,Vke as a0,lwe as a1,Kke as a2,Lp as a3,he as a4,ni as a5,no as a6,EX as a7,t0e as a8,Dj as a9,Ml as aa,cY as ab,Oke as ac,Lke as ad,Ike as ae,Ip as af,zV as ag,kxe as ah,ybe as ai,$ke as aj,TX as ak,y as b,Wke as c,On as d,$f as e,e0e as f,mme as g,nS as h,lo as i,r as j,Qke as k,P4 as l,vn as m,ft as n,mt as o,Hu as p,Uke as q,Ke as r,bn as s,pN as t,Bp as u,tn as v,Ze as w,Xke as x,Yke as y,qke as z};