ccdeck 3.46.0 → 3.47.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +72 -43
- package/bin/cli/startup.js +23 -0
- package/bin/deck.js +32 -1
- package/dist/web/assets/BrowserWatchModal-Bau0ttnH.js +1 -0
- package/dist/web/assets/IntegrationModal-8tTi25gA.js +6 -0
- package/dist/web/assets/{RadioPanel-biw_BbZq.js → RadioPanel-DbmJJPsz.js} +1 -1
- package/dist/web/assets/TrafficRadar-CPjAXd5e.js +8 -0
- package/dist/web/assets/{UsageHistoryModal-Bd-JRAa4.js → UsageHistoryModal-qfmvXdWJ.js} +1 -1
- package/dist/web/assets/app-BFFG6Wz8.js +321 -0
- package/dist/web/assets/app-DfcfHvcX.css +1 -0
- package/dist/web/assets/claude-settings-index-1Qg1AUda.js +1 -0
- package/dist/web/assets/{index-DmENqVdt.js → index-Ca87aJP9.js} +1 -1
- package/dist/web/index.html +3 -3
- package/package.json +1 -1
- package/release-notes.json +30 -0
- package/src/server/ccusage-install.mjs +58 -1
- package/src/server/ccusage-registry.mjs +289 -0
- package/src/server/ccusage-runner.mjs +9 -2
- package/src/server/claude-accounts.mjs +21 -0
- package/src/server/claude-login.mjs +21 -3
- package/src/server/claude-settings-catalog.d.mts +37 -0
- package/src/server/claude-settings-catalog.mjs +169 -0
- package/src/server/claude-settings-docs.mjs +109 -0
- package/src/server/claude-settings-index.json +251 -0
- package/src/server/claude-settings-routes.mjs +46 -0
- package/src/server/claude-settings.mjs +406 -0
- package/src/server/cli-arrival.mjs +64 -0
- package/src/server/index.mjs +18 -2
- package/src/server/integrations/proxy.mjs +11 -2
- package/src/server/integrations/routes.mjs +6 -4
- package/src/server/quota-close-watch.mjs +81 -0
- package/src/server/quota-closes.mjs +181 -0
- package/src/server/quota-history.mjs +8 -1
- package/src/server/quota-shape.mjs +12 -0
- package/src/server/quota.mjs +28 -1
- package/src/server/request-gates.mjs +3 -1
- package/src/server/tool-audit-operations.mjs +30 -10
- package/src/server/tool-audit-report.mjs +79 -7
- package/src/server/tool-audit-routes.mjs +1 -1
- package/src/server/tool-audit-skills.mjs +8 -3
- package/src/server/tool-audit.mjs +55 -5
- package/src/server/traffic-radar-capture.mjs +3 -3
- package/src/server/traffic-radar-config.mjs +10 -3
- package/src/server/traffic-radar-monitor.mjs +8 -5
- package/src/server/traffic-radar-permission.mjs +162 -0
- package/src/server/traffic-radar-platform.mjs +9 -3
- package/src/server/traffic-radar-routes.mjs +8 -18
- package/src/server/traffic-radar-service.mjs +76 -92
- package/src/server/usage-routes.mjs +14 -2
- package/dist/web/assets/BrowserWatchModal-CoX9FIUE.js +0 -1
- package/dist/web/assets/IntegrationModal-B1ypkK-E.js +0 -5
- package/dist/web/assets/TrafficRadar-nhtFoYVv.js +0 -8
- package/dist/web/assets/app-BlRY6EME.css +0 -1
- package/dist/web/assets/app-DhGvSH7o.js +0 -319
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
var xq=Object.defineProperty;var vq=(e,t,n)=>t in e?xq(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Ba=(e,t,n)=>vq(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 $j(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Sy={exports:{}},eu={},Cy={exports:{}},it={};/**
|
|
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 F_;function bq(){if(F_)return it;F_=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"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),h=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),p=Symbol.iterator;function m(I){return I===null||typeof I!="object"?null:(I=p&&I[p]||I["@@iterator"],typeof I=="function"?I:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},v=Object.assign,j={};function b(I,W,Z){this.props=I,this.context=W,this.refs=j,this.updater=Z||w}b.prototype.isReactComponent={},b.prototype.setState=function(I,W){if(typeof I!="object"&&typeof I!="function"&&I!=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,I,W,"setState")},b.prototype.forceUpdate=function(I){this.updater.enqueueForceUpdate(this,I,"forceUpdate")};function N(){}N.prototype=b.prototype;function x(I,W,Z){this.props=I,this.context=W,this.refs=j,this.updater=Z||w}var S=x.prototype=new N;S.constructor=x,v(S,b.prototype),S.isPureReactComponent=!0;var C=Array.isArray,_=Object.prototype.hasOwnProperty,M={current:null},R={key:!0,ref:!0,__self:!0,__source:!0};function P(I,W,Z){var z,X={},Y=null,J=null;if(W!=null)for(z in W.ref!==void 0&&(J=W.ref),W.key!==void 0&&(Y=""+W.key),W)_.call(W,z)&&!R.hasOwnProperty(z)&&(X[z]=W[z]);var Q=arguments.length-2;if(Q===1)X.children=Z;else if(1<Q){for(var te=Array(Q),le=0;le<Q;le++)te[le]=arguments[le+2];X.children=te}if(I&&I.defaultProps)for(z in Q=I.defaultProps,Q)X[z]===void 0&&(X[z]=Q[z]);return{$$typeof:e,type:I,key:Y,ref:J,props:X,_owner:M.current}}function L(I,W){return{$$typeof:e,type:I.type,key:W,ref:I.ref,props:I.props,_owner:I._owner}}function U(I){return typeof I=="object"&&I!==null&&I.$$typeof===e}function B(I){var W={"=":"=0",":":"=2"};return"$"+I.replace(/[=:]/g,function(Z){return W[Z]})}var A=/\/+/g;function q(I,W){return typeof I=="object"&&I!==null&&I.key!=null?B(""+I.key):W.toString(36)}function T(I,W,Z,z,X){var Y=typeof I;(Y==="undefined"||Y==="boolean")&&(I=null);var J=!1;if(I===null)J=!0;else switch(Y){case"string":case"number":J=!0;break;case"object":switch(I.$$typeof){case e:case t:J=!0}}if(J)return J=I,X=X(J),I=z===""?"."+q(J,0):z,C(X)?(Z="",I!=null&&(Z=I.replace(A,"$&/")+"/"),T(X,W,Z,"",function(le){return le})):X!=null&&(U(X)&&(X=L(X,Z+(!X.key||J&&J.key===X.key?"":(""+X.key).replace(A,"$&/")+"/")+I)),W.push(X)),1;if(J=0,z=z===""?".":z+":",C(I))for(var Q=0;Q<I.length;Q++){Y=I[Q];var te=z+q(Y,Q);J+=T(Y,W,Z,te,X)}else if(te=m(I),typeof te=="function")for(I=te.call(I),Q=0;!(Y=I.next()).done;)Y=Y.value,te=z+q(Y,Q++),J+=T(Y,W,Z,te,X);else if(Y==="object")throw W=String(I),Error("Objects are not valid as a React child (found: "+(W==="[object Object]"?"object with keys {"+Object.keys(I).join(", ")+"}":W)+"). If you meant to render a collection of children, use an array instead.");return J}function F(I,W,Z){if(I==null)return I;var z=[],X=0;return T(I,z,"","",function(Y){return W.call(Z,Y,X++)}),z}function O(I){if(I._status===-1){var W=I._result;W=W(),W.then(function(Z){(I._status===0||I._status===-1)&&(I._status=1,I._result=Z)},function(Z){(I._status===0||I._status===-1)&&(I._status=2,I._result=Z)}),I._status===-1&&(I._status=0,I._result=W)}if(I._status===1)return I._result.default;throw I._result}var K={current:null},V={transition:null},H={ReactCurrentDispatcher:K,ReactCurrentBatchConfig:V,ReactCurrentOwner:M};function D(){throw Error("act(...) is not supported in production builds of React.")}return it.Children={map:F,forEach:function(I,W,Z){F(I,function(){W.apply(this,arguments)},Z)},count:function(I){var W=0;return F(I,function(){W++}),W},toArray:function(I){return F(I,function(W){return W})||[]},only:function(I){if(!U(I))throw Error("React.Children.only expected to receive a single React element child.");return I}},it.Component=b,it.Fragment=n,it.Profiler=a,it.PureComponent=x,it.StrictMode=s,it.Suspense=u,it.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=H,it.act=D,it.cloneElement=function(I,W,Z){if(I==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+I+".");var z=v({},I.props),X=I.key,Y=I.ref,J=I._owner;if(W!=null){if(W.ref!==void 0&&(Y=W.ref,J=M.current),W.key!==void 0&&(X=""+W.key),I.type&&I.type.defaultProps)var Q=I.type.defaultProps;for(te in W)_.call(W,te)&&!R.hasOwnProperty(te)&&(z[te]=W[te]===void 0&&Q!==void 0?Q[te]:W[te])}var te=arguments.length-2;if(te===1)z.children=Z;else if(1<te){Q=Array(te);for(var le=0;le<te;le++)Q[le]=arguments[le+2];z.children=Q}return{$$typeof:e,type:I.type,key:X,ref:Y,props:z,_owner:J}},it.createContext=function(I){return I={$$typeof:i,_currentValue:I,_currentValue2:I,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},I.Provider={$$typeof:o,_context:I},I.Consumer=I},it.createElement=P,it.createFactory=function(I){var W=P.bind(null,I);return W.type=I,W},it.createRef=function(){return{current:null}},it.forwardRef=function(I){return{$$typeof:l,render:I}},it.isValidElement=U,it.lazy=function(I){return{$$typeof:f,_payload:{_status:-1,_result:I},_init:O}},it.memo=function(I,W){return{$$typeof:h,type:I,compare:W===void 0?null:W}},it.startTransition=function(I){var W=V.transition;V.transition={};try{I()}finally{V.transition=W}},it.unstable_act=D,it.useCallback=function(I,W){return K.current.useCallback(I,W)},it.useContext=function(I){return K.current.useContext(I)},it.useDebugValue=function(){},it.useDeferredValue=function(I){return K.current.useDeferredValue(I)},it.useEffect=function(I,W){return K.current.useEffect(I,W)},it.useId=function(){return K.current.useId()},it.useImperativeHandle=function(I,W,Z){return K.current.useImperativeHandle(I,W,Z)},it.useInsertionEffect=function(I,W){return K.current.useInsertionEffect(I,W)},it.useLayoutEffect=function(I,W){return K.current.useLayoutEffect(I,W)},it.useMemo=function(I,W){return K.current.useMemo(I,W)},it.useReducer=function(I,W,Z){return K.current.useReducer(I,W,Z)},it.useRef=function(I){return K.current.useRef(I)},it.useState=function(I){return K.current.useState(I)},it.useSyncExternalStore=function(I,W,Z){return K.current.useSyncExternalStore(I,W,Z)},it.useTransition=function(){return K.current.useTransition()},it.version="18.3.1",it}var B_;function ud(){return B_||(B_=1,Cy.exports=bq()),Cy.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 q_;function kq(){if(q_)return eu;q_=1;var e=ud(),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(l,u,h){var f,p={},m=null,w=null;h!==void 0&&(m=""+h),u.key!==void 0&&(m=""+u.key),u.ref!==void 0&&(w=u.ref);for(f in u)s.call(u,f)&&!o.hasOwnProperty(f)&&(p[f]=u[f]);if(l&&l.defaultProps)for(f in u=l.defaultProps,u)p[f]===void 0&&(p[f]=u[f]);return{$$typeof:t,type:l,key:m,ref:w,props:p,_owner:a.current}}return eu.Fragment=n,eu.jsx=i,eu.jsxs=i,eu}var U_;function jq(){return U_||(U_=1,Sy.exports=kq()),Sy.exports}var r=jq(),qh={},_y={exports:{}},In={},Ey={exports:{}},Ty={};/**
|
|
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 W_;function Nq(){return W_||(W_=1,(function(e){function t(V,H){var D=V.length;V.push(H);e:for(;0<D;){var I=D-1>>>1,W=V[I];if(0<a(W,H))V[I]=H,V[D]=W,D=I;else break e}}function n(V){return V.length===0?null:V[0]}function s(V){if(V.length===0)return null;var H=V[0],D=V.pop();if(D!==H){V[0]=D;e:for(var I=0,W=V.length,Z=W>>>1;I<Z;){var z=2*(I+1)-1,X=V[z],Y=z+1,J=V[Y];if(0>a(X,D))Y<W&&0>a(J,X)?(V[I]=J,V[Y]=D,I=Y):(V[I]=X,V[z]=D,I=z);else if(Y<W&&0>a(J,D))V[I]=J,V[Y]=D,I=Y;else break e}}return H}function a(V,H){var D=V.sortIndex-H.sortIndex;return D!==0?D:V.id-H.id}if(typeof performance=="object"&&typeof performance.now=="function"){var o=performance;e.unstable_now=function(){return o.now()}}else{var i=Date,l=i.now();e.unstable_now=function(){return i.now()-l}}var u=[],h=[],f=1,p=null,m=3,w=!1,v=!1,j=!1,b=typeof setTimeout=="function"?setTimeout:null,N=typeof clearTimeout=="function"?clearTimeout:null,x=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(V){for(var H=n(h);H!==null;){if(H.callback===null)s(h);else if(H.startTime<=V)s(h),H.sortIndex=H.expirationTime,t(u,H);else break;H=n(h)}}function C(V){if(j=!1,S(V),!v)if(n(u)!==null)v=!0,O(_);else{var H=n(h);H!==null&&K(C,H.startTime-V)}}function _(V,H){v=!1,j&&(j=!1,N(P),P=-1),w=!0;var D=m;try{for(S(H),p=n(u);p!==null&&(!(p.expirationTime>H)||V&&!B());){var I=p.callback;if(typeof I=="function"){p.callback=null,m=p.priorityLevel;var W=I(p.expirationTime<=H);H=e.unstable_now(),typeof W=="function"?p.callback=W:p===n(u)&&s(u),S(H)}else s(u);p=n(u)}if(p!==null)var Z=!0;else{var z=n(h);z!==null&&K(C,z.startTime-H),Z=!1}return Z}finally{p=null,m=D,w=!1}}var M=!1,R=null,P=-1,L=5,U=-1;function B(){return!(e.unstable_now()-U<L)}function A(){if(R!==null){var V=e.unstable_now();U=V;var H=!0;try{H=R(!0,V)}finally{H?q():(M=!1,R=null)}}else M=!1}var q;if(typeof x=="function")q=function(){x(A)};else if(typeof MessageChannel<"u"){var T=new MessageChannel,F=T.port2;T.port1.onmessage=A,q=function(){F.postMessage(null)}}else q=function(){b(A,0)};function O(V){R=V,M||(M=!0,q())}function K(V,H){P=b(function(){V(e.unstable_now())},H)}e.unstable_IdlePriority=5,e.unstable_ImmediatePriority=1,e.unstable_LowPriority=4,e.unstable_NormalPriority=3,e.unstable_Profiling=null,e.unstable_UserBlockingPriority=2,e.unstable_cancelCallback=function(V){V.callback=null},e.unstable_continueExecution=function(){v||w||(v=!0,O(_))},e.unstable_forceFrameRate=function(V){0>V||125<V?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):L=0<V?Math.floor(1e3/V):5},e.unstable_getCurrentPriorityLevel=function(){return m},e.unstable_getFirstCallbackNode=function(){return n(u)},e.unstable_next=function(V){switch(m){case 1:case 2:case 3:var H=3;break;default:H=m}var D=m;m=H;try{return V()}finally{m=D}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(V,H){switch(V){case 1:case 2:case 3:case 4:case 5:break;default:V=3}var D=m;m=V;try{return H()}finally{m=D}},e.unstable_scheduleCallback=function(V,H,D){var I=e.unstable_now();switch(typeof D=="object"&&D!==null?(D=D.delay,D=typeof D=="number"&&0<D?I+D:I):D=I,V){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=D+W,V={id:f++,callback:H,priorityLevel:V,startTime:D,expirationTime:W,sortIndex:-1},D>I?(V.sortIndex=D,t(h,V),n(u)===null&&V===n(h)&&(j?(N(P),P=-1):j=!0,K(C,D-I))):(V.sortIndex=W,t(u,V),v||w||(v=!0,O(_))),V},e.unstable_shouldYield=B,e.unstable_wrapCallback=function(V){var H=m;return function(){var D=m;m=H;try{return V.apply(this,arguments)}finally{m=D}}}})(Ty)),Ty}var H_;function Sq(){return H_||(H_=1,Ey.exports=Nq()),Ey.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 z_;function Cq(){if(z_)return In;z_=1;var e=ud(),t=Sq();function n(c){for(var d="https://reactjs.org/docs/error-decoder.html?invariant="+c,y=1;y<arguments.length;y++)d+="&args[]="+encodeURIComponent(arguments[y]);return"Minified React error #"+c+"; visit "+d+" 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(c,d){i(c,d),i(c+"Capture",d)}function i(c,d){for(a[c]=d,c=0;c<d.length;c++)s.add(d[c])}var l=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),u=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(c){return u.call(p,c)?!0:u.call(f,c)?!1:h.test(c)?p[c]=!0:(f[c]=!0,!1)}function w(c,d,y,k){if(y!==null&&y.type===0)return!1;switch(typeof d){case"function":case"symbol":return!0;case"boolean":return k?!1:y!==null?!y.acceptsBooleans:(c=c.toLowerCase().slice(0,5),c!=="data-"&&c!=="aria-");default:return!1}}function v(c,d,y,k){if(d===null||typeof d>"u"||w(c,d,y,k))return!0;if(k)return!1;if(y!==null)switch(y.type){case 3:return!d;case 4:return d===!1;case 5:return isNaN(d);case 6:return isNaN(d)||1>d}return!1}function j(c,d,y,k,E,$,G){this.acceptsBooleans=d===2||d===3||d===4,this.attributeName=k,this.attributeNamespace=E,this.mustUseProperty=y,this.propertyName=c,this.type=d,this.sanitizeURL=$,this.removeEmptyString=G}var b={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(c){b[c]=new j(c,0,!1,c,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(c){var d=c[0];b[d]=new j(d,1,!1,c[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(c){b[c]=new j(c,2,!1,c.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(c){b[c]=new j(c,2,!1,c,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(c){b[c]=new j(c,3,!1,c.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(c){b[c]=new j(c,3,!0,c,null,!1,!1)}),["capture","download"].forEach(function(c){b[c]=new j(c,4,!1,c,null,!1,!1)}),["cols","rows","size","span"].forEach(function(c){b[c]=new j(c,6,!1,c,null,!1,!1)}),["rowSpan","start"].forEach(function(c){b[c]=new j(c,5,!1,c.toLowerCase(),null,!1,!1)});var N=/[\-:]([a-z])/g;function x(c){return c[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(c){var d=c.replace(N,x);b[d]=new j(d,1,!1,c,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(c){var d=c.replace(N,x);b[d]=new j(d,1,!1,c,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(c){var d=c.replace(N,x);b[d]=new j(d,1,!1,c,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(c){b[c]=new j(c,1,!1,c.toLowerCase(),null,!1,!1)}),b.xlinkHref=new j("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(c){b[c]=new j(c,1,!1,c.toLowerCase(),null,!0,!0)});function S(c,d,y,k){var E=b.hasOwnProperty(d)?b[d]:null;(E!==null?E.type!==0:k||!(2<d.length)||d[0]!=="o"&&d[0]!=="O"||d[1]!=="n"&&d[1]!=="N")&&(v(d,y,E,k)&&(y=null),k||E===null?m(d)&&(y===null?c.removeAttribute(d):c.setAttribute(d,""+y)):E.mustUseProperty?c[E.propertyName]=y===null?E.type===3?!1:"":y:(d=E.attributeName,k=E.attributeNamespace,y===null?c.removeAttribute(d):(E=E.type,y=E===3||E===4&&y===!0?"":""+y,k?c.setAttributeNS(k,d,y):c.setAttribute(d,y))))}var C=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,_=Symbol.for("react.element"),M=Symbol.for("react.portal"),R=Symbol.for("react.fragment"),P=Symbol.for("react.strict_mode"),L=Symbol.for("react.profiler"),U=Symbol.for("react.provider"),B=Symbol.for("react.context"),A=Symbol.for("react.forward_ref"),q=Symbol.for("react.suspense"),T=Symbol.for("react.suspense_list"),F=Symbol.for("react.memo"),O=Symbol.for("react.lazy"),K=Symbol.for("react.offscreen"),V=Symbol.iterator;function H(c){return c===null||typeof c!="object"?null:(c=V&&c[V]||c["@@iterator"],typeof c=="function"?c:null)}var D=Object.assign,I;function W(c){if(I===void 0)try{throw Error()}catch(y){var d=y.stack.trim().match(/\n( *(at )?)/);I=d&&d[1]||""}return`
|
|
34
|
+
`+I+c}var Z=!1;function z(c,d){if(!c||Z)return"";Z=!0;var y=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(d)if(d=function(){throw Error()},Object.defineProperty(d.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(d,[])}catch(ue){var k=ue}Reflect.construct(c,[],d)}else{try{d.call()}catch(ue){k=ue}c.call(d.prototype)}else{try{throw Error()}catch(ue){k=ue}c()}}catch(ue){if(ue&&k&&typeof ue.stack=="string"){for(var E=ue.stack.split(`
|
|
35
|
+
`),$=k.stack.split(`
|
|
36
|
+
`),G=E.length-1,ee=$.length-1;1<=G&&0<=ee&&E[G]!==$[ee];)ee--;for(;1<=G&&0<=ee;G--,ee--)if(E[G]!==$[ee]){if(G!==1||ee!==1)do if(G--,ee--,0>ee||E[G]!==$[ee]){var ne=`
|
|
37
|
+
`+E[G].replace(" at new "," at ");return c.displayName&&ne.includes("<anonymous>")&&(ne=ne.replace("<anonymous>",c.displayName)),ne}while(1<=G&&0<=ee);break}}}finally{Z=!1,Error.prepareStackTrace=y}return(c=c?c.displayName||c.name:"")?W(c):""}function X(c){switch(c.tag){case 5:return W(c.type);case 16:return W("Lazy");case 13:return W("Suspense");case 19:return W("SuspenseList");case 0:case 2:case 15:return c=z(c.type,!1),c;case 11:return c=z(c.type.render,!1),c;case 1:return c=z(c.type,!0),c;default:return""}}function Y(c){if(c==null)return null;if(typeof c=="function")return c.displayName||c.name||null;if(typeof c=="string")return c;switch(c){case R:return"Fragment";case M:return"Portal";case L:return"Profiler";case P:return"StrictMode";case q:return"Suspense";case T:return"SuspenseList"}if(typeof c=="object")switch(c.$$typeof){case B:return(c.displayName||"Context")+".Consumer";case U:return(c._context.displayName||"Context")+".Provider";case A:var d=c.render;return c=c.displayName,c||(c=d.displayName||d.name||"",c=c!==""?"ForwardRef("+c+")":"ForwardRef"),c;case F:return d=c.displayName||null,d!==null?d:Y(c.type)||"Memo";case O:d=c._payload,c=c._init;try{return Y(c(d))}catch{}}return null}function J(c){var d=c.type;switch(c.tag){case 24:return"Cache";case 9:return(d.displayName||"Context")+".Consumer";case 10:return(d._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return c=d.render,c=c.displayName||c.name||"",d.displayName||(c!==""?"ForwardRef("+c+")":"ForwardRef");case 7:return"Fragment";case 5:return d;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Y(d);case 8:return d===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 d=="function")return d.displayName||d.name||null;if(typeof d=="string")return d}return null}function Q(c){switch(typeof c){case"boolean":case"number":case"string":case"undefined":return c;case"object":return c;default:return""}}function te(c){var d=c.type;return(c=c.nodeName)&&c.toLowerCase()==="input"&&(d==="checkbox"||d==="radio")}function le(c){var d=te(c)?"checked":"value",y=Object.getOwnPropertyDescriptor(c.constructor.prototype,d),k=""+c[d];if(!c.hasOwnProperty(d)&&typeof y<"u"&&typeof y.get=="function"&&typeof y.set=="function"){var E=y.get,$=y.set;return Object.defineProperty(c,d,{configurable:!0,get:function(){return E.call(this)},set:function(G){k=""+G,$.call(this,G)}}),Object.defineProperty(c,d,{enumerable:y.enumerable}),{getValue:function(){return k},setValue:function(G){k=""+G},stopTracking:function(){c._valueTracker=null,delete c[d]}}}}function de(c){c._valueTracker||(c._valueTracker=le(c))}function oe(c){if(!c)return!1;var d=c._valueTracker;if(!d)return!0;var y=d.getValue(),k="";return c&&(k=te(c)?c.checked?"true":"false":c.value),c=k,c!==y?(d.setValue(c),!0):!1}function re(c){if(c=c||(typeof document<"u"?document:void 0),typeof c>"u")return null;try{return c.activeElement||c.body}catch{return c.body}}function he(c,d){var y=d.checked;return D({},d,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:y??c._wrapperState.initialChecked})}function pe(c,d){var y=d.defaultValue==null?"":d.defaultValue,k=d.checked!=null?d.checked:d.defaultChecked;y=Q(d.value!=null?d.value:y),c._wrapperState={initialChecked:k,initialValue:y,controlled:d.type==="checkbox"||d.type==="radio"?d.checked!=null:d.value!=null}}function Le(c,d){d=d.checked,d!=null&&S(c,"checked",d,!1)}function ge(c,d){Le(c,d);var y=Q(d.value),k=d.type;if(y!=null)k==="number"?(y===0&&c.value===""||c.value!=y)&&(c.value=""+y):c.value!==""+y&&(c.value=""+y);else if(k==="submit"||k==="reset"){c.removeAttribute("value");return}d.hasOwnProperty("value")?je(c,d.type,y):d.hasOwnProperty("defaultValue")&&je(c,d.type,Q(d.defaultValue)),d.checked==null&&d.defaultChecked!=null&&(c.defaultChecked=!!d.defaultChecked)}function ve(c,d,y){if(d.hasOwnProperty("value")||d.hasOwnProperty("defaultValue")){var k=d.type;if(!(k!=="submit"&&k!=="reset"||d.value!==void 0&&d.value!==null))return;d=""+c._wrapperState.initialValue,y||d===c.value||(c.value=d),c.defaultValue=d}y=c.name,y!==""&&(c.name=""),c.defaultChecked=!!c._wrapperState.initialChecked,y!==""&&(c.name=y)}function je(c,d,y){(d!=="number"||re(c.ownerDocument)!==c)&&(y==null?c.defaultValue=""+c._wrapperState.initialValue:c.defaultValue!==""+y&&(c.defaultValue=""+y))}var Ee=Array.isArray;function xe(c,d,y,k){if(c=c.options,d){d={};for(var E=0;E<y.length;E++)d["$"+y[E]]=!0;for(y=0;y<c.length;y++)E=d.hasOwnProperty("$"+c[y].value),c[y].selected!==E&&(c[y].selected=E),E&&k&&(c[y].defaultSelected=!0)}else{for(y=""+Q(y),d=null,E=0;E<c.length;E++){if(c[E].value===y){c[E].selected=!0,k&&(c[E].defaultSelected=!0);return}d!==null||c[E].disabled||(d=c[E])}d!==null&&(d.selected=!0)}}function Ie(c,d){if(d.dangerouslySetInnerHTML!=null)throw Error(n(91));return D({},d,{value:void 0,defaultValue:void 0,children:""+c._wrapperState.initialValue})}function De(c,d){var y=d.value;if(y==null){if(y=d.children,d=d.defaultValue,y!=null){if(d!=null)throw Error(n(92));if(Ee(y)){if(1<y.length)throw Error(n(93));y=y[0]}d=y}d==null&&(d=""),y=d}c._wrapperState={initialValue:Q(y)}}function We(c,d){var y=Q(d.value),k=Q(d.defaultValue);y!=null&&(y=""+y,y!==c.value&&(c.value=y),d.defaultValue==null&&c.defaultValue!==y&&(c.defaultValue=y)),k!=null&&(c.defaultValue=""+k)}function Ke(c){var d=c.textContent;d===c._wrapperState.initialValue&&d!==""&&d!==null&&(c.value=d)}function ye(c){switch(c){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 Fe(c,d){return c==null||c==="http://www.w3.org/1999/xhtml"?ye(d):c==="http://www.w3.org/2000/svg"&&d==="foreignObject"?"http://www.w3.org/1999/xhtml":c}var $e,Re=(function(c){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(d,y,k,E){MSApp.execUnsafeLocalFunction(function(){return c(d,y,k,E)})}:c})(function(c,d){if(c.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in c)c.innerHTML=d;else{for($e=$e||document.createElement("div"),$e.innerHTML="<svg>"+d.valueOf().toString()+"</svg>",d=$e.firstChild;c.firstChild;)c.removeChild(c.firstChild);for(;d.firstChild;)c.appendChild(d.firstChild)}});function rt(c,d){if(d){var y=c.firstChild;if(y&&y===c.lastChild&&y.nodeType===3){y.nodeValue=d;return}}c.textContent=d}var He={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},se=["Webkit","ms","Moz","O"];Object.keys(He).forEach(function(c){se.forEach(function(d){d=d+c.charAt(0).toUpperCase()+c.substring(1),He[d]=He[c]})});function ke(c,d,y){return d==null||typeof d=="boolean"||d===""?"":y||typeof d!="number"||d===0||He.hasOwnProperty(c)&&He[c]?(""+d).trim():d+"px"}function Ae(c,d){c=c.style;for(var y in d)if(d.hasOwnProperty(y)){var k=y.indexOf("--")===0,E=ke(y,d[y],k);y==="float"&&(y="cssFloat"),k?c.setProperty(y,E):c[y]=E}}var Oe=D({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function be(c,d){if(d){if(Oe[c]&&(d.children!=null||d.dangerouslySetInnerHTML!=null))throw Error(n(137,c));if(d.dangerouslySetInnerHTML!=null){if(d.children!=null)throw Error(n(60));if(typeof d.dangerouslySetInnerHTML!="object"||!("__html"in d.dangerouslySetInnerHTML))throw Error(n(61))}if(d.style!=null&&typeof d.style!="object")throw Error(n(62))}}function fe(c,d){if(c.indexOf("-")===-1)return typeof d.is=="string";switch(c){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 _e=null;function Ve(c){return c=c.target||c.srcElement||window,c.correspondingUseElement&&(c=c.correspondingUseElement),c.nodeType===3?c.parentNode:c}var ot=null,tt=null,wt=null;function $t(c){if(c=Fc(c)){if(typeof ot!="function")throw Error(n(280));var d=c.stateNode;d&&(d=th(d),ot(c.stateNode,c.type,d))}}function Vt(c){tt?wt?wt.push(c):wt=[c]:tt=c}function er(){if(tt){var c=tt,d=wt;if(wt=tt=null,$t(c),d)for(c=0;c<d.length;c++)$t(d[c])}}function Ss(c,d){return c(d)}function Wn(){}var es=!1;function Cs(c,d,y){if(es)return c(d,y);es=!0;try{return Ss(c,d,y)}finally{es=!1,(tt!==null||wt!==null)&&(Wn(),er())}}function yn(c,d){var y=c.stateNode;if(y===null)return null;var k=th(y);if(k===null)return null;y=k[d];e:switch(d){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(k=!k.disabled)||(c=c.type,k=!(c==="button"||c==="input"||c==="select"||c==="textarea")),c=!k;break e;default:c=!1}if(c)return null;if(y&&typeof y!="function")throw Error(n(231,d,typeof y));return y}var Hn=!1;if(l)try{var Me={};Object.defineProperty(Me,"passive",{get:function(){Hn=!0}}),window.addEventListener("test",Me,Me),window.removeEventListener("test",Me,Me)}catch{Hn=!1}function qe(c,d,y,k,E,$,G,ee,ne){var ue=Array.prototype.slice.call(arguments,3);try{d.apply(y,ue)}catch(Se){this.onError(Se)}}var Je=!1,_t=null,Nt=!1,ts=null,zn={onError:function(c){Je=!0,_t=c}};function wn(c,d,y,k,E,$,G,ee,ne){Je=!1,_t=null,qe.apply(zn,arguments)}function Cr(c,d,y,k,E,$,G,ee,ne){if(wn.apply(this,arguments),Je){if(Je){var ue=_t;Je=!1,_t=null}else throw Error(n(198));Nt||(Nt=!0,ts=ue)}}function xn(c){var d=c,y=c;if(c.alternate)for(;d.return;)d=d.return;else{c=d;do d=c,(d.flags&4098)!==0&&(y=d.return),c=d.return;while(c)}return d.tag===3?y:null}function rn(c){if(c.tag===13){var d=c.memoizedState;if(d===null&&(c=c.alternate,c!==null&&(d=c.memoizedState)),d!==null)return d.dehydrated}return null}function _s(c){if(xn(c)!==c)throw Error(n(188))}function tr(c){var d=c.alternate;if(!d){if(d=xn(c),d===null)throw Error(n(188));return d!==c?null:c}for(var y=c,k=d;;){var E=y.return;if(E===null)break;var $=E.alternate;if($===null){if(k=E.return,k!==null){y=k;continue}break}if(E.child===$.child){for($=E.child;$;){if($===y)return _s(E),c;if($===k)return _s(E),d;$=$.sibling}throw Error(n(188))}if(y.return!==k.return)y=E,k=$;else{for(var G=!1,ee=E.child;ee;){if(ee===y){G=!0,y=E,k=$;break}if(ee===k){G=!0,k=E,y=$;break}ee=ee.sibling}if(!G){for(ee=$.child;ee;){if(ee===y){G=!0,y=$,k=E;break}if(ee===k){G=!0,k=$,y=E;break}ee=ee.sibling}if(!G)throw Error(n(189))}}if(y.alternate!==k)throw Error(n(190))}if(y.tag!==3)throw Error(n(188));return y.stateNode.current===y?c:d}function ns(c){return c=tr(c),c!==null?Es(c):null}function Es(c){if(c.tag===5||c.tag===6)return c;for(c=c.child;c!==null;){var d=Es(c);if(d!==null)return d;c=c.sibling}return null}var _r=t.unstable_scheduleCallback,Er=t.unstable_cancelCallback,Ts=t.unstable_shouldYield,ga=t.unstable_requestPaint,xt=t.unstable_now,ya=t.unstable_getCurrentPriorityLevel,As=t.unstable_ImmediatePriority,wa=t.unstable_UserBlockingPriority,nr=t.unstable_NormalPriority,Tr=t.unstable_LowPriority,Ar=t.unstable_IdlePriority,Rs=null,dn=null;function Lt(c){if(dn&&typeof dn.onCommitFiberRoot=="function")try{dn.onCommitFiberRoot(Rs,c,void 0,(c.current.flags&128)===128)}catch{}}var hn=Math.clz32?Math.clz32:va,xa=Math.log,go=Math.LN2;function va(c){return c>>>=0,c===0?32:31-(xa(c)/go|0)|0}var ba=64,Rr=4194304;function Vn(c){switch(c&-c){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 c&4194240;case 4194304:case 8388608:case 16777216:case 33554432:case 67108864:return c&130023424;case 134217728:return 134217728;case 268435456:return 268435456;case 536870912:return 536870912;case 1073741824:return 1073741824;default:return c}}function we(c,d){var y=c.pendingLanes;if(y===0)return 0;var k=0,E=c.suspendedLanes,$=c.pingedLanes,G=y&268435455;if(G!==0){var ee=G&~E;ee!==0?k=Vn(ee):($&=G,$!==0&&(k=Vn($)))}else G=y&~E,G!==0?k=Vn(G):$!==0&&(k=Vn($));if(k===0)return 0;if(d!==0&&d!==k&&(d&E)===0&&(E=k&-k,$=d&-d,E>=$||E===16&&($&4194240)!==0))return d;if((k&4)!==0&&(k|=y&16),d=c.entangledLanes,d!==0)for(c=c.entanglements,d&=k;0<d;)y=31-hn(d),E=1<<y,k|=c[y],d&=~E;return k}function et(c,d){switch(c){case 1:case 2:case 4:return d+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 d+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 pt(c,d){for(var y=c.suspendedLanes,k=c.pingedLanes,E=c.expirationTimes,$=c.pendingLanes;0<$;){var G=31-hn($),ee=1<<G,ne=E[G];ne===-1?((ee&y)===0||(ee&k)!==0)&&(E[G]=et(ee,d)):ne<=d&&(c.expiredLanes|=ee),$&=~ee}}function Et(c){return c=c.pendingLanes&-1073741825,c!==0?c:c&1073741824?1073741824:0}function sr(){var c=ba;return ba<<=1,(ba&4194240)===0&&(ba=64),c}function Mr(c){for(var d=[],y=0;31>y;y++)d.push(c);return d}function ss(c,d,y){c.pendingLanes|=d,d!==536870912&&(c.suspendedLanes=0,c.pingedLanes=0),c=c.eventTimes,d=31-hn(d),c[d]=y}function fc(c,d){var y=c.pendingLanes&~d;c.pendingLanes=d,c.suspendedLanes=0,c.pingedLanes=0,c.expiredLanes&=d,c.mutableReadLanes&=d,c.entangledLanes&=d,d=c.entanglements;var k=c.eventTimes;for(c=c.expirationTimes;0<y;){var E=31-hn(y),$=1<<E;d[E]=0,k[E]=-1,c[E]=-1,y&=~$}}function $r(c,d){var y=c.entangledLanes|=d;for(c=c.entanglements;y;){var k=31-hn(y),E=1<<k;E&d|c[k]&d&&(c[k]|=d),y&=~E}}var at=0;function yo(c){return c&=-c,1<c?4<c?(c&268435455)!==0?16:536870912:4:1}var wo,pc,mc,$d,gc,_i=!1,xo=[],Ms=null,$s=null,an=null,vo=new Map,bo=new Map,Ls=[],Ld="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 Ei(c,d){switch(c){case"focusin":case"focusout":Ms=null;break;case"dragenter":case"dragleave":$s=null;break;case"mouseover":case"mouseout":an=null;break;case"pointerover":case"pointerout":vo.delete(d.pointerId);break;case"gotpointercapture":case"lostpointercapture":bo.delete(d.pointerId)}}function Lr(c,d,y,k,E,$){return c===null||c.nativeEvent!==$?(c={blockedOn:d,domEventName:y,eventSystemFlags:k,nativeEvent:$,targetContainers:[E]},d!==null&&(d=Fc(d),d!==null&&pc(d)),c):(c.eventSystemFlags|=k,d=c.targetContainers,E!==null&&d.indexOf(E)===-1&&d.push(E),c)}function Ir(c,d,y,k,E){switch(d){case"focusin":return Ms=Lr(Ms,c,d,y,k,E),!0;case"dragenter":return $s=Lr($s,c,d,y,k,E),!0;case"mouseover":return an=Lr(an,c,d,y,k,E),!0;case"pointerover":var $=E.pointerId;return vo.set($,Lr(vo.get($)||null,c,d,y,k,E)),!0;case"gotpointercapture":return $=E.pointerId,bo.set($,Lr(bo.get($)||null,c,d,y,k,E)),!0}return!1}function Id(c){var d=Ro(c.target);if(d!==null){var y=xn(d);if(y!==null){if(d=y.tag,d===13){if(d=rn(y),d!==null){c.blockedOn=d,gc(c.priority,function(){mc(y)});return}}else if(d===3&&y.stateNode.current.memoizedState.isDehydrated){c.blockedOn=y.tag===3?y.stateNode.containerInfo:null;return}}}c.blockedOn=null}function Ti(c){if(c.blockedOn!==null)return!1;for(var d=c.targetContainers;0<d.length;){var y=No(c.domEventName,c.eventSystemFlags,d[0],c.nativeEvent);if(y===null){y=c.nativeEvent;var k=new y.constructor(y.type,y);_e=k,y.target.dispatchEvent(k),_e=null}else return d=Fc(y),d!==null&&pc(d),c.blockedOn=y,!1;d.shift()}return!0}function Od(c,d,y){Ti(c)&&y.delete(d)}function yc(){_i=!1,Ms!==null&&Ti(Ms)&&(Ms=null),$s!==null&&Ti($s)&&($s=null),an!==null&&Ti(an)&&(an=null),vo.forEach(Od),bo.forEach(Od)}function rs(c,d){c.blockedOn===d&&(c.blockedOn=null,_i||(_i=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,yc)))}function ko(c){function d(E){return rs(E,c)}if(0<xo.length){rs(xo[0],c);for(var y=1;y<xo.length;y++){var k=xo[y];k.blockedOn===c&&(k.blockedOn=null)}}for(Ms!==null&&rs(Ms,c),$s!==null&&rs($s,c),an!==null&&rs(an,c),vo.forEach(d),bo.forEach(d),y=0;y<Ls.length;y++)k=Ls[y],k.blockedOn===c&&(k.blockedOn=null);for(;0<Ls.length&&(y=Ls[0],y.blockedOn===null);)Id(y),y.blockedOn===null&&Ls.shift()}var Or=C.ReactCurrentBatchConfig,jo=!0;function zm(c,d,y,k){var E=at,$=Or.transition;Or.transition=null;try{at=1,xc(c,d,y,k)}finally{at=E,Or.transition=$}}function wc(c,d,y,k){var E=at,$=Or.transition;Or.transition=null;try{at=4,xc(c,d,y,k)}finally{at=E,Or.transition=$}}function xc(c,d,y,k){if(jo){var E=No(c,d,y,k);if(E===null)mg(c,d,k,Ai,y),Ei(c,k);else if(Ir(E,c,d,y,k))k.stopPropagation();else if(Ei(c,k),d&4&&-1<Ld.indexOf(c)){for(;E!==null;){var $=Fc(E);if($!==null&&wo($),$=No(c,d,y,k),$===null&&mg(c,d,k,Ai,y),$===E)break;E=$}E!==null&&k.stopPropagation()}else mg(c,d,k,null,y)}}var Ai=null;function No(c,d,y,k){if(Ai=null,c=Ve(k),c=Ro(c),c!==null)if(d=xn(c),d===null)c=null;else if(y=d.tag,y===13){if(c=rn(d),c!==null)return c;c=null}else if(y===3){if(d.stateNode.current.memoizedState.isDehydrated)return d.tag===3?d.stateNode.containerInfo:null;c=null}else d!==c&&(c=null);return Ai=c,null}function vc(c){switch(c){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(ya()){case As:return 1;case wa:return 4;case nr:case Tr:return 16;case Ar:return 536870912;default:return 16}default:return 16}}var rr=null,bc=null,Ri=null;function Mi(){if(Ri)return Ri;var c,d=bc,y=d.length,k,E="value"in rr?rr.value:rr.textContent,$=E.length;for(c=0;c<y&&d[c]===E[c];c++);var G=y-c;for(k=1;k<=G&&d[y-k]===E[$-k];k++);return Ri=E.slice(c,1<k?1-k:void 0)}function $i(c){var d=c.keyCode;return"charCode"in c?(c=c.charCode,c===0&&d===13&&(c=13)):c=d,c===10&&(c=13),32<=c||c===13?c:0}function So(){return!0}function Pd(){return!1}function vn(c){function d(y,k,E,$,G){this._reactName=y,this._targetInst=E,this.type=k,this.nativeEvent=$,this.target=G,this.currentTarget=null;for(var ee in c)c.hasOwnProperty(ee)&&(y=c[ee],this[ee]=y?y($):$[ee]);return this.isDefaultPrevented=($.defaultPrevented!=null?$.defaultPrevented:$.returnValue===!1)?So:Pd,this.isPropagationStopped=Pd,this}return D(d.prototype,{preventDefault:function(){this.defaultPrevented=!0;var y=this.nativeEvent;y&&(y.preventDefault?y.preventDefault():typeof y.returnValue!="unknown"&&(y.returnValue=!1),this.isDefaultPrevented=So)},stopPropagation:function(){var y=this.nativeEvent;y&&(y.stopPropagation?y.stopPropagation():typeof y.cancelBubble!="unknown"&&(y.cancelBubble=!0),this.isPropagationStopped=So)},persist:function(){},isPersistent:So}),d}var ka={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(c){return c.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Li=vn(ka),Co=D({},ka,{view:0,detail:0}),Vm=vn(Co),Ii,Pr,Dr,Is=D({},Co,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:Cc,button:0,buttons:0,relatedTarget:function(c){return c.relatedTarget===void 0?c.fromElement===c.srcElement?c.toElement:c.fromElement:c.relatedTarget},movementX:function(c){return"movementX"in c?c.movementX:(c!==Dr&&(Dr&&c.type==="mousemove"?(Ii=c.screenX-Dr.screenX,Pr=c.screenY-Dr.screenY):Pr=Ii=0,Dr=c),Ii)},movementY:function(c){return"movementY"in c?c.movementY:Pr}}),_o=vn(Is),Dd=D({},Is,{dataTransfer:0}),Fd=vn(Dd),Bd=D({},Co,{relatedTarget:0}),Eo=vn(Bd),Gm=D({},ka,{animationName:0,elapsedTime:0,pseudoElement:0}),kc=vn(Gm),qd=D({},ka,{clipboardData:function(c){return"clipboardData"in c?c.clipboardData:window.clipboardData}}),jc=vn(qd),Km=D({},ka,{data:0}),Nc=vn(Km),Sc={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},Oi={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"},Ym={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function ja(c){var d=this.nativeEvent;return d.getModifierState?d.getModifierState(c):(c=Ym[c])?!!d[c]:!1}function Cc(){return ja}var Xm=D({},Co,{key:function(c){if(c.key){var d=Sc[c.key]||c.key;if(d!=="Unidentified")return d}return c.type==="keypress"?(c=$i(c),c===13?"Enter":String.fromCharCode(c)):c.type==="keydown"||c.type==="keyup"?Oi[c.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:Cc,charCode:function(c){return c.type==="keypress"?$i(c):0},keyCode:function(c){return c.type==="keydown"||c.type==="keyup"?c.keyCode:0},which:function(c){return c.type==="keypress"?$i(c):c.type==="keydown"||c.type==="keyup"?c.keyCode:0}}),Zm=vn(Xm),_c=D({},Is,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),To=vn(_c),Jm=D({},Co,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Cc}),Qm=vn(Jm),Ec=D({},ka,{propertyName:0,elapsedTime:0,pseudoElement:0}),Ud=vn(Ec),eg=D({},Is,{deltaX:function(c){return"deltaX"in c?c.deltaX:"wheelDeltaX"in c?-c.wheelDeltaX:0},deltaY:function(c){return"deltaY"in c?c.deltaY:"wheelDeltaY"in c?-c.wheelDeltaY:"wheelDelta"in c?-c.wheelDelta:0},deltaZ:0,deltaMode:0}),tg=vn(eg),ng=[9,13,27,32],Ao=l&&"CompositionEvent"in window,as=null;l&&"documentMode"in document&&(as=document.documentMode);var Wd=l&&"TextEvent"in window&&!as,Pi=l&&(!Ao||as&&8<as&&11>=as),Hd=" ",ar=!1;function zd(c,d){switch(c){case"keyup":return ng.indexOf(d.keyCode)!==-1;case"keydown":return d.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Tc(c){return c=c.detail,typeof c=="object"&&"data"in c?c.data:null}var Fr=!1;function Ac(c,d){switch(c){case"compositionend":return Tc(d);case"keypress":return d.which!==32?null:(ar=!0,Hd);case"textInput":return c=d.data,c===Hd&&ar?null:c;default:return null}}function sg(c,d){if(Fr)return c==="compositionend"||!Ao&&zd(c,d)?(c=Mi(),Ri=bc=rr=null,Fr=!1,c):null;switch(c){case"paste":return null;case"keypress":if(!(d.ctrlKey||d.altKey||d.metaKey)||d.ctrlKey&&d.altKey){if(d.char&&1<d.char.length)return d.char;if(d.which)return String.fromCharCode(d.which)}return null;case"compositionend":return Pi&&d.locale!=="ko"?null:d.data;default:return null}}var rg={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 Vd(c){var d=c&&c.nodeName&&c.nodeName.toLowerCase();return d==="input"?!!rg[c.type]:d==="textarea"}function Gd(c,d,y,k){Vt(k),d=Jd(d,"onChange"),0<d.length&&(y=new Li("onChange","change",null,y,k),c.push({event:y,listeners:d}))}var Na=null,Sa=null;function ag(c){tC(c,0)}function qt(c){var d=Wi(c);if(oe(d))return c}function og(c,d){if(c==="change")return d}var Kd=!1;if(l){var Di;if(l){var Rc="oninput"in document;if(!Rc){var Mc=document.createElement("div");Mc.setAttribute("oninput","return;"),Rc=typeof Mc.oninput=="function"}Di=Rc}else Di=!1;Kd=Di&&(!document.documentMode||9<document.documentMode)}function ut(){Na&&(Na.detachEvent("onpropertychange",Br),Sa=Na=null)}function Br(c){if(c.propertyName==="value"&&qt(Sa)){var d=[];Gd(d,Sa,c,Ve(c)),Cs(ag,d)}}function ig(c,d,y){c==="focusin"?(ut(),Na=d,Sa=y,Na.attachEvent("onpropertychange",Br)):c==="focusout"&&ut()}function kB(c){if(c==="selectionchange"||c==="keyup"||c==="keydown")return qt(Sa)}function jB(c,d){if(c==="click")return qt(d)}function NB(c,d){if(c==="input"||c==="change")return qt(d)}function SB(c,d){return c===d&&(c!==0||1/c===1/d)||c!==c&&d!==d}var Os=typeof Object.is=="function"?Object.is:SB;function $c(c,d){if(Os(c,d))return!0;if(typeof c!="object"||c===null||typeof d!="object"||d===null)return!1;var y=Object.keys(c),k=Object.keys(d);if(y.length!==k.length)return!1;for(k=0;k<y.length;k++){var E=y[k];if(!u.call(d,E)||!Os(c[E],d[E]))return!1}return!0}function US(c){for(;c&&c.firstChild;)c=c.firstChild;return c}function WS(c,d){var y=US(c);c=0;for(var k;y;){if(y.nodeType===3){if(k=c+y.textContent.length,c<=d&&k>=d)return{node:y,offset:d-c};c=k}e:{for(;y;){if(y.nextSibling){y=y.nextSibling;break e}y=y.parentNode}y=void 0}y=US(y)}}function HS(c,d){return c&&d?c===d?!0:c&&c.nodeType===3?!1:d&&d.nodeType===3?HS(c,d.parentNode):"contains"in c?c.contains(d):c.compareDocumentPosition?!!(c.compareDocumentPosition(d)&16):!1:!1}function zS(){for(var c=window,d=re();d instanceof c.HTMLIFrameElement;){try{var y=typeof d.contentWindow.location.href=="string"}catch{y=!1}if(y)c=d.contentWindow;else break;d=re(c.document)}return d}function lg(c){var d=c&&c.nodeName&&c.nodeName.toLowerCase();return d&&(d==="input"&&(c.type==="text"||c.type==="search"||c.type==="tel"||c.type==="url"||c.type==="password")||d==="textarea"||c.contentEditable==="true")}function CB(c){var d=zS(),y=c.focusedElem,k=c.selectionRange;if(d!==y&&y&&y.ownerDocument&&HS(y.ownerDocument.documentElement,y)){if(k!==null&&lg(y)){if(d=k.start,c=k.end,c===void 0&&(c=d),"selectionStart"in y)y.selectionStart=d,y.selectionEnd=Math.min(c,y.value.length);else if(c=(d=y.ownerDocument||document)&&d.defaultView||window,c.getSelection){c=c.getSelection();var E=y.textContent.length,$=Math.min(k.start,E);k=k.end===void 0?$:Math.min(k.end,E),!c.extend&&$>k&&(E=k,k=$,$=E),E=WS(y,$);var G=WS(y,k);E&&G&&(c.rangeCount!==1||c.anchorNode!==E.node||c.anchorOffset!==E.offset||c.focusNode!==G.node||c.focusOffset!==G.offset)&&(d=d.createRange(),d.setStart(E.node,E.offset),c.removeAllRanges(),$>k?(c.addRange(d),c.extend(G.node,G.offset)):(d.setEnd(G.node,G.offset),c.addRange(d)))}}for(d=[],c=y;c=c.parentNode;)c.nodeType===1&&d.push({element:c,left:c.scrollLeft,top:c.scrollTop});for(typeof y.focus=="function"&&y.focus(),y=0;y<d.length;y++)c=d[y],c.element.scrollLeft=c.left,c.element.scrollTop=c.top}}var _B=l&&"documentMode"in document&&11>=document.documentMode,Fi=null,cg=null,Lc=null,ug=!1;function VS(c,d,y){var k=y.window===y?y.document:y.nodeType===9?y:y.ownerDocument;ug||Fi==null||Fi!==re(k)||(k=Fi,"selectionStart"in k&&lg(k)?k={start:k.selectionStart,end:k.selectionEnd}:(k=(k.ownerDocument&&k.ownerDocument.defaultView||window).getSelection(),k={anchorNode:k.anchorNode,anchorOffset:k.anchorOffset,focusNode:k.focusNode,focusOffset:k.focusOffset}),Lc&&$c(Lc,k)||(Lc=k,k=Jd(cg,"onSelect"),0<k.length&&(d=new Li("onSelect","select",null,d,y),c.push({event:d,listeners:k}),d.target=Fi)))}function Yd(c,d){var y={};return y[c.toLowerCase()]=d.toLowerCase(),y["Webkit"+c]="webkit"+d,y["Moz"+c]="moz"+d,y}var Bi={animationend:Yd("Animation","AnimationEnd"),animationiteration:Yd("Animation","AnimationIteration"),animationstart:Yd("Animation","AnimationStart"),transitionend:Yd("Transition","TransitionEnd")},dg={},GS={};l&&(GS=document.createElement("div").style,"AnimationEvent"in window||(delete Bi.animationend.animation,delete Bi.animationiteration.animation,delete Bi.animationstart.animation),"TransitionEvent"in window||delete Bi.transitionend.transition);function Xd(c){if(dg[c])return dg[c];if(!Bi[c])return c;var d=Bi[c],y;for(y in d)if(d.hasOwnProperty(y)&&y in GS)return dg[c]=d[y];return c}var KS=Xd("animationend"),YS=Xd("animationiteration"),XS=Xd("animationstart"),ZS=Xd("transitionend"),JS=new Map,QS="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 Ca(c,d){JS.set(c,d),o(d,[c])}for(var hg=0;hg<QS.length;hg++){var fg=QS[hg],EB=fg.toLowerCase(),TB=fg[0].toUpperCase()+fg.slice(1);Ca(EB,"on"+TB)}Ca(KS,"onAnimationEnd"),Ca(YS,"onAnimationIteration"),Ca(XS,"onAnimationStart"),Ca("dblclick","onDoubleClick"),Ca("focusin","onFocus"),Ca("focusout","onBlur"),Ca(ZS,"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 Ic="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(" "),AB=new Set("cancel close invalid load scroll toggle".split(" ").concat(Ic));function eC(c,d,y){var k=c.type||"unknown-event";c.currentTarget=y,Cr(k,d,void 0,c),c.currentTarget=null}function tC(c,d){d=(d&4)!==0;for(var y=0;y<c.length;y++){var k=c[y],E=k.event;k=k.listeners;e:{var $=void 0;if(d)for(var G=k.length-1;0<=G;G--){var ee=k[G],ne=ee.instance,ue=ee.currentTarget;if(ee=ee.listener,ne!==$&&E.isPropagationStopped())break e;eC(E,ee,ue),$=ne}else for(G=0;G<k.length;G++){if(ee=k[G],ne=ee.instance,ue=ee.currentTarget,ee=ee.listener,ne!==$&&E.isPropagationStopped())break e;eC(E,ee,ue),$=ne}}}if(Nt)throw c=ts,Nt=!1,ts=null,c}function Tt(c,d){var y=d[bg];y===void 0&&(y=d[bg]=new Set);var k=c+"__bubble";y.has(k)||(nC(d,c,2,!1),y.add(k))}function pg(c,d,y){var k=0;d&&(k|=4),nC(y,c,k,d)}var Zd="_reactListening"+Math.random().toString(36).slice(2);function Oc(c){if(!c[Zd]){c[Zd]=!0,s.forEach(function(y){y!=="selectionchange"&&(AB.has(y)||pg(y,!1,c),pg(y,!0,c))});var d=c.nodeType===9?c:c.ownerDocument;d===null||d[Zd]||(d[Zd]=!0,pg("selectionchange",!1,d))}}function nC(c,d,y,k){switch(vc(d)){case 1:var E=zm;break;case 4:E=wc;break;default:E=xc}y=E.bind(null,d,y,c),E=void 0,!Hn||d!=="touchstart"&&d!=="touchmove"&&d!=="wheel"||(E=!0),k?E!==void 0?c.addEventListener(d,y,{capture:!0,passive:E}):c.addEventListener(d,y,!0):E!==void 0?c.addEventListener(d,y,{passive:E}):c.addEventListener(d,y,!1)}function mg(c,d,y,k,E){var $=k;if((d&1)===0&&(d&2)===0&&k!==null)e:for(;;){if(k===null)return;var G=k.tag;if(G===3||G===4){var ee=k.stateNode.containerInfo;if(ee===E||ee.nodeType===8&&ee.parentNode===E)break;if(G===4)for(G=k.return;G!==null;){var ne=G.tag;if((ne===3||ne===4)&&(ne=G.stateNode.containerInfo,ne===E||ne.nodeType===8&&ne.parentNode===E))return;G=G.return}for(;ee!==null;){if(G=Ro(ee),G===null)return;if(ne=G.tag,ne===5||ne===6){k=$=G;continue e}ee=ee.parentNode}}k=k.return}Cs(function(){var ue=$,Se=Ve(y),Ce=[];e:{var Ne=JS.get(c);if(Ne!==void 0){var Pe=Li,Ue=c;switch(c){case"keypress":if($i(y)===0)break e;case"keydown":case"keyup":Pe=Zm;break;case"focusin":Ue="focus",Pe=Eo;break;case"focusout":Ue="blur",Pe=Eo;break;case"beforeblur":case"afterblur":Pe=Eo;break;case"click":if(y.button===2)break e;case"auxclick":case"dblclick":case"mousedown":case"mousemove":case"mouseup":case"mouseout":case"mouseover":case"contextmenu":Pe=_o;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Pe=Fd;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Pe=Qm;break;case KS:case YS:case XS:Pe=kc;break;case ZS:Pe=Ud;break;case"scroll":Pe=Vm;break;case"wheel":Pe=tg;break;case"copy":case"cut":case"paste":Pe=jc;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Pe=To}var ze=(d&4)!==0,Ut=!ze&&c==="scroll",ie=ze?Ne!==null?Ne+"Capture":null:Ne;ze=[];for(var ae=ue,ce;ae!==null;){ce=ae;var Te=ce.stateNode;if(ce.tag===5&&Te!==null&&(ce=Te,ie!==null&&(Te=yn(ae,ie),Te!=null&&ze.push(Pc(ae,Te,ce)))),Ut)break;ae=ae.return}0<ze.length&&(Ne=new Pe(Ne,Ue,null,y,Se),Ce.push({event:Ne,listeners:ze}))}}if((d&7)===0){e:{if(Ne=c==="mouseover"||c==="pointerover",Pe=c==="mouseout"||c==="pointerout",Ne&&y!==_e&&(Ue=y.relatedTarget||y.fromElement)&&(Ro(Ue)||Ue[qr]))break e;if((Pe||Ne)&&(Ne=Se.window===Se?Se:(Ne=Se.ownerDocument)?Ne.defaultView||Ne.parentWindow:window,Pe?(Ue=y.relatedTarget||y.toElement,Pe=ue,Ue=Ue?Ro(Ue):null,Ue!==null&&(Ut=xn(Ue),Ue!==Ut||Ue.tag!==5&&Ue.tag!==6)&&(Ue=null)):(Pe=null,Ue=ue),Pe!==Ue)){if(ze=_o,Te="onMouseLeave",ie="onMouseEnter",ae="mouse",(c==="pointerout"||c==="pointerover")&&(ze=To,Te="onPointerLeave",ie="onPointerEnter",ae="pointer"),Ut=Pe==null?Ne:Wi(Pe),ce=Ue==null?Ne:Wi(Ue),Ne=new ze(Te,ae+"leave",Pe,y,Se),Ne.target=Ut,Ne.relatedTarget=ce,Te=null,Ro(Se)===ue&&(ze=new ze(ie,ae+"enter",Ue,y,Se),ze.target=ce,ze.relatedTarget=Ut,Te=ze),Ut=Te,Pe&&Ue)t:{for(ze=Pe,ie=Ue,ae=0,ce=ze;ce;ce=qi(ce))ae++;for(ce=0,Te=ie;Te;Te=qi(Te))ce++;for(;0<ae-ce;)ze=qi(ze),ae--;for(;0<ce-ae;)ie=qi(ie),ce--;for(;ae--;){if(ze===ie||ie!==null&&ze===ie.alternate)break t;ze=qi(ze),ie=qi(ie)}ze=null}else ze=null;Pe!==null&&sC(Ce,Ne,Pe,ze,!1),Ue!==null&&Ut!==null&&sC(Ce,Ut,Ue,ze,!0)}}e:{if(Ne=ue?Wi(ue):window,Pe=Ne.nodeName&&Ne.nodeName.toLowerCase(),Pe==="select"||Pe==="input"&&Ne.type==="file")var Ge=og;else if(Vd(Ne))if(Kd)Ge=NB;else{Ge=kB;var Xe=ig}else(Pe=Ne.nodeName)&&Pe.toLowerCase()==="input"&&(Ne.type==="checkbox"||Ne.type==="radio")&&(Ge=jB);if(Ge&&(Ge=Ge(c,ue))){Gd(Ce,Ge,y,Se);break e}Xe&&Xe(c,Ne,ue),c==="focusout"&&(Xe=Ne._wrapperState)&&Xe.controlled&&Ne.type==="number"&&je(Ne,"number",Ne.value)}switch(Xe=ue?Wi(ue):window,c){case"focusin":(Vd(Xe)||Xe.contentEditable==="true")&&(Fi=Xe,cg=ue,Lc=null);break;case"focusout":Lc=cg=Fi=null;break;case"mousedown":ug=!0;break;case"contextmenu":case"mouseup":case"dragend":ug=!1,VS(Ce,y,Se);break;case"selectionchange":if(_B)break;case"keydown":case"keyup":VS(Ce,y,Se)}var Ze;if(Ao)e:{switch(c){case"compositionstart":var Qe="onCompositionStart";break e;case"compositionend":Qe="onCompositionEnd";break e;case"compositionupdate":Qe="onCompositionUpdate";break e}Qe=void 0}else Fr?zd(c,y)&&(Qe="onCompositionEnd"):c==="keydown"&&y.keyCode===229&&(Qe="onCompositionStart");Qe&&(Pi&&y.locale!=="ko"&&(Fr||Qe!=="onCompositionStart"?Qe==="onCompositionEnd"&&Fr&&(Ze=Mi()):(rr=Se,bc="value"in rr?rr.value:rr.textContent,Fr=!0)),Xe=Jd(ue,Qe),0<Xe.length&&(Qe=new Nc(Qe,c,null,y,Se),Ce.push({event:Qe,listeners:Xe}),Ze?Qe.data=Ze:(Ze=Tc(y),Ze!==null&&(Qe.data=Ze)))),(Ze=Wd?Ac(c,y):sg(c,y))&&(ue=Jd(ue,"onBeforeInput"),0<ue.length&&(Se=new Nc("onBeforeInput","beforeinput",null,y,Se),Ce.push({event:Se,listeners:ue}),Se.data=Ze))}tC(Ce,d)})}function Pc(c,d,y){return{instance:c,listener:d,currentTarget:y}}function Jd(c,d){for(var y=d+"Capture",k=[];c!==null;){var E=c,$=E.stateNode;E.tag===5&&$!==null&&(E=$,$=yn(c,y),$!=null&&k.unshift(Pc(c,$,E)),$=yn(c,d),$!=null&&k.push(Pc(c,$,E))),c=c.return}return k}function qi(c){if(c===null)return null;do c=c.return;while(c&&c.tag!==5);return c||null}function sC(c,d,y,k,E){for(var $=d._reactName,G=[];y!==null&&y!==k;){var ee=y,ne=ee.alternate,ue=ee.stateNode;if(ne!==null&&ne===k)break;ee.tag===5&&ue!==null&&(ee=ue,E?(ne=yn(y,$),ne!=null&&G.unshift(Pc(y,ne,ee))):E||(ne=yn(y,$),ne!=null&&G.push(Pc(y,ne,ee)))),y=y.return}G.length!==0&&c.push({event:d,listeners:G})}var RB=/\r\n?/g,MB=/\u0000|\uFFFD/g;function rC(c){return(typeof c=="string"?c:""+c).replace(RB,`
|
|
38
|
+
`).replace(MB,"")}function Qd(c,d,y){if(d=rC(d),rC(c)!==d&&y)throw Error(n(425))}function eh(){}var gg=null,yg=null;function wg(c,d){return c==="textarea"||c==="noscript"||typeof d.children=="string"||typeof d.children=="number"||typeof d.dangerouslySetInnerHTML=="object"&&d.dangerouslySetInnerHTML!==null&&d.dangerouslySetInnerHTML.__html!=null}var xg=typeof setTimeout=="function"?setTimeout:void 0,$B=typeof clearTimeout=="function"?clearTimeout:void 0,aC=typeof Promise=="function"?Promise:void 0,LB=typeof queueMicrotask=="function"?queueMicrotask:typeof aC<"u"?function(c){return aC.resolve(null).then(c).catch(IB)}:xg;function IB(c){setTimeout(function(){throw c})}function vg(c,d){var y=d,k=0;do{var E=y.nextSibling;if(c.removeChild(y),E&&E.nodeType===8)if(y=E.data,y==="/$"){if(k===0){c.removeChild(E),ko(d);return}k--}else y!=="$"&&y!=="$?"&&y!=="$!"||k++;y=E}while(y);ko(d)}function _a(c){for(;c!=null;c=c.nextSibling){var d=c.nodeType;if(d===1||d===3)break;if(d===8){if(d=c.data,d==="$"||d==="$!"||d==="$?")break;if(d==="/$")return null}}return c}function oC(c){c=c.previousSibling;for(var d=0;c;){if(c.nodeType===8){var y=c.data;if(y==="$"||y==="$!"||y==="$?"){if(d===0)return c;d--}else y==="/$"&&d++}c=c.previousSibling}return null}var Ui=Math.random().toString(36).slice(2),or="__reactFiber$"+Ui,Dc="__reactProps$"+Ui,qr="__reactContainer$"+Ui,bg="__reactEvents$"+Ui,OB="__reactListeners$"+Ui,PB="__reactHandles$"+Ui;function Ro(c){var d=c[or];if(d)return d;for(var y=c.parentNode;y;){if(d=y[qr]||y[or]){if(y=d.alternate,d.child!==null||y!==null&&y.child!==null)for(c=oC(c);c!==null;){if(y=c[or])return y;c=oC(c)}return d}c=y,y=c.parentNode}return null}function Fc(c){return c=c[or]||c[qr],!c||c.tag!==5&&c.tag!==6&&c.tag!==13&&c.tag!==3?null:c}function Wi(c){if(c.tag===5||c.tag===6)return c.stateNode;throw Error(n(33))}function th(c){return c[Dc]||null}var kg=[],Hi=-1;function Ea(c){return{current:c}}function At(c){0>Hi||(c.current=kg[Hi],kg[Hi]=null,Hi--)}function St(c,d){Hi++,kg[Hi]=c.current,c.current=d}var Ta={},fn=Ea(Ta),An=Ea(!1),Mo=Ta;function zi(c,d){var y=c.type.contextTypes;if(!y)return Ta;var k=c.stateNode;if(k&&k.__reactInternalMemoizedUnmaskedChildContext===d)return k.__reactInternalMemoizedMaskedChildContext;var E={},$;for($ in y)E[$]=d[$];return k&&(c=c.stateNode,c.__reactInternalMemoizedUnmaskedChildContext=d,c.__reactInternalMemoizedMaskedChildContext=E),E}function Rn(c){return c=c.childContextTypes,c!=null}function nh(){At(An),At(fn)}function iC(c,d,y){if(fn.current!==Ta)throw Error(n(168));St(fn,d),St(An,y)}function lC(c,d,y){var k=c.stateNode;if(d=d.childContextTypes,typeof k.getChildContext!="function")return y;k=k.getChildContext();for(var E in k)if(!(E in d))throw Error(n(108,J(c)||"Unknown",E));return D({},y,k)}function sh(c){return c=(c=c.stateNode)&&c.__reactInternalMemoizedMergedChildContext||Ta,Mo=fn.current,St(fn,c),St(An,An.current),!0}function cC(c,d,y){var k=c.stateNode;if(!k)throw Error(n(169));y?(c=lC(c,d,Mo),k.__reactInternalMemoizedMergedChildContext=c,At(An),At(fn),St(fn,c)):At(An),St(An,y)}var Ur=null,rh=!1,jg=!1;function uC(c){Ur===null?Ur=[c]:Ur.push(c)}function DB(c){rh=!0,uC(c)}function Aa(){if(!jg&&Ur!==null){jg=!0;var c=0,d=at;try{var y=Ur;for(at=1;c<y.length;c++){var k=y[c];do k=k(!0);while(k!==null)}Ur=null,rh=!1}catch(E){throw Ur!==null&&(Ur=Ur.slice(c+1)),_r(As,Aa),E}finally{at=d,jg=!1}}return null}var Vi=[],Gi=0,ah=null,oh=0,os=[],is=0,$o=null,Wr=1,Hr="";function Lo(c,d){Vi[Gi++]=oh,Vi[Gi++]=ah,ah=c,oh=d}function dC(c,d,y){os[is++]=Wr,os[is++]=Hr,os[is++]=$o,$o=c;var k=Wr;c=Hr;var E=32-hn(k)-1;k&=~(1<<E),y+=1;var $=32-hn(d)+E;if(30<$){var G=E-E%5;$=(k&(1<<G)-1).toString(32),k>>=G,E-=G,Wr=1<<32-hn(d)+E|y<<E|k,Hr=$+c}else Wr=1<<$|y<<E|k,Hr=c}function Ng(c){c.return!==null&&(Lo(c,1),dC(c,1,0))}function Sg(c){for(;c===ah;)ah=Vi[--Gi],Vi[Gi]=null,oh=Vi[--Gi],Vi[Gi]=null;for(;c===$o;)$o=os[--is],os[is]=null,Hr=os[--is],os[is]=null,Wr=os[--is],os[is]=null}var Gn=null,Kn=null,Rt=!1,Ps=null;function hC(c,d){var y=ds(5,null,null,0);y.elementType="DELETED",y.stateNode=d,y.return=c,d=c.deletions,d===null?(c.deletions=[y],c.flags|=16):d.push(y)}function fC(c,d){switch(c.tag){case 5:var y=c.type;return d=d.nodeType!==1||y.toLowerCase()!==d.nodeName.toLowerCase()?null:d,d!==null?(c.stateNode=d,Gn=c,Kn=_a(d.firstChild),!0):!1;case 6:return d=c.pendingProps===""||d.nodeType!==3?null:d,d!==null?(c.stateNode=d,Gn=c,Kn=null,!0):!1;case 13:return d=d.nodeType!==8?null:d,d!==null?(y=$o!==null?{id:Wr,overflow:Hr}:null,c.memoizedState={dehydrated:d,treeContext:y,retryLane:1073741824},y=ds(18,null,null,0),y.stateNode=d,y.return=c,c.child=y,Gn=c,Kn=null,!0):!1;default:return!1}}function Cg(c){return(c.mode&1)!==0&&(c.flags&128)===0}function _g(c){if(Rt){var d=Kn;if(d){var y=d;if(!fC(c,d)){if(Cg(c))throw Error(n(418));d=_a(y.nextSibling);var k=Gn;d&&fC(c,d)?hC(k,y):(c.flags=c.flags&-4097|2,Rt=!1,Gn=c)}}else{if(Cg(c))throw Error(n(418));c.flags=c.flags&-4097|2,Rt=!1,Gn=c}}}function pC(c){for(c=c.return;c!==null&&c.tag!==5&&c.tag!==3&&c.tag!==13;)c=c.return;Gn=c}function ih(c){if(c!==Gn)return!1;if(!Rt)return pC(c),Rt=!0,!1;var d;if((d=c.tag!==3)&&!(d=c.tag!==5)&&(d=c.type,d=d!=="head"&&d!=="body"&&!wg(c.type,c.memoizedProps)),d&&(d=Kn)){if(Cg(c))throw mC(),Error(n(418));for(;d;)hC(c,d),d=_a(d.nextSibling)}if(pC(c),c.tag===13){if(c=c.memoizedState,c=c!==null?c.dehydrated:null,!c)throw Error(n(317));e:{for(c=c.nextSibling,d=0;c;){if(c.nodeType===8){var y=c.data;if(y==="/$"){if(d===0){Kn=_a(c.nextSibling);break e}d--}else y!=="$"&&y!=="$!"&&y!=="$?"||d++}c=c.nextSibling}Kn=null}}else Kn=Gn?_a(c.stateNode.nextSibling):null;return!0}function mC(){for(var c=Kn;c;)c=_a(c.nextSibling)}function Ki(){Kn=Gn=null,Rt=!1}function Eg(c){Ps===null?Ps=[c]:Ps.push(c)}var FB=C.ReactCurrentBatchConfig;function Bc(c,d,y){if(c=y.ref,c!==null&&typeof c!="function"&&typeof c!="object"){if(y._owner){if(y=y._owner,y){if(y.tag!==1)throw Error(n(309));var k=y.stateNode}if(!k)throw Error(n(147,c));var E=k,$=""+c;return d!==null&&d.ref!==null&&typeof d.ref=="function"&&d.ref._stringRef===$?d.ref:(d=function(G){var ee=E.refs;G===null?delete ee[$]:ee[$]=G},d._stringRef=$,d)}if(typeof c!="string")throw Error(n(284));if(!y._owner)throw Error(n(290,c))}return c}function lh(c,d){throw c=Object.prototype.toString.call(d),Error(n(31,c==="[object Object]"?"object with keys {"+Object.keys(d).join(", ")+"}":c))}function gC(c){var d=c._init;return d(c._payload)}function yC(c){function d(ie,ae){if(c){var ce=ie.deletions;ce===null?(ie.deletions=[ae],ie.flags|=16):ce.push(ae)}}function y(ie,ae){if(!c)return null;for(;ae!==null;)d(ie,ae),ae=ae.sibling;return null}function k(ie,ae){for(ie=new Map;ae!==null;)ae.key!==null?ie.set(ae.key,ae):ie.set(ae.index,ae),ae=ae.sibling;return ie}function E(ie,ae){return ie=Da(ie,ae),ie.index=0,ie.sibling=null,ie}function $(ie,ae,ce){return ie.index=ce,c?(ce=ie.alternate,ce!==null?(ce=ce.index,ce<ae?(ie.flags|=2,ae):ce):(ie.flags|=2,ae)):(ie.flags|=1048576,ae)}function G(ie){return c&&ie.alternate===null&&(ie.flags|=2),ie}function ee(ie,ae,ce,Te){return ae===null||ae.tag!==6?(ae=xy(ce,ie.mode,Te),ae.return=ie,ae):(ae=E(ae,ce),ae.return=ie,ae)}function ne(ie,ae,ce,Te){var Ge=ce.type;return Ge===R?Se(ie,ae,ce.props.children,Te,ce.key):ae!==null&&(ae.elementType===Ge||typeof Ge=="object"&&Ge!==null&&Ge.$$typeof===O&&gC(Ge)===ae.type)?(Te=E(ae,ce.props),Te.ref=Bc(ie,ae,ce),Te.return=ie,Te):(Te=Mh(ce.type,ce.key,ce.props,null,ie.mode,Te),Te.ref=Bc(ie,ae,ce),Te.return=ie,Te)}function ue(ie,ae,ce,Te){return ae===null||ae.tag!==4||ae.stateNode.containerInfo!==ce.containerInfo||ae.stateNode.implementation!==ce.implementation?(ae=vy(ce,ie.mode,Te),ae.return=ie,ae):(ae=E(ae,ce.children||[]),ae.return=ie,ae)}function Se(ie,ae,ce,Te,Ge){return ae===null||ae.tag!==7?(ae=Uo(ce,ie.mode,Te,Ge),ae.return=ie,ae):(ae=E(ae,ce),ae.return=ie,ae)}function Ce(ie,ae,ce){if(typeof ae=="string"&&ae!==""||typeof ae=="number")return ae=xy(""+ae,ie.mode,ce),ae.return=ie,ae;if(typeof ae=="object"&&ae!==null){switch(ae.$$typeof){case _:return ce=Mh(ae.type,ae.key,ae.props,null,ie.mode,ce),ce.ref=Bc(ie,null,ae),ce.return=ie,ce;case M:return ae=vy(ae,ie.mode,ce),ae.return=ie,ae;case O:var Te=ae._init;return Ce(ie,Te(ae._payload),ce)}if(Ee(ae)||H(ae))return ae=Uo(ae,ie.mode,ce,null),ae.return=ie,ae;lh(ie,ae)}return null}function Ne(ie,ae,ce,Te){var Ge=ae!==null?ae.key:null;if(typeof ce=="string"&&ce!==""||typeof ce=="number")return Ge!==null?null:ee(ie,ae,""+ce,Te);if(typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case _:return ce.key===Ge?ne(ie,ae,ce,Te):null;case M:return ce.key===Ge?ue(ie,ae,ce,Te):null;case O:return Ge=ce._init,Ne(ie,ae,Ge(ce._payload),Te)}if(Ee(ce)||H(ce))return Ge!==null?null:Se(ie,ae,ce,Te,null);lh(ie,ce)}return null}function Pe(ie,ae,ce,Te,Ge){if(typeof Te=="string"&&Te!==""||typeof Te=="number")return ie=ie.get(ce)||null,ee(ae,ie,""+Te,Ge);if(typeof Te=="object"&&Te!==null){switch(Te.$$typeof){case _:return ie=ie.get(Te.key===null?ce:Te.key)||null,ne(ae,ie,Te,Ge);case M:return ie=ie.get(Te.key===null?ce:Te.key)||null,ue(ae,ie,Te,Ge);case O:var Xe=Te._init;return Pe(ie,ae,ce,Xe(Te._payload),Ge)}if(Ee(Te)||H(Te))return ie=ie.get(ce)||null,Se(ae,ie,Te,Ge,null);lh(ae,Te)}return null}function Ue(ie,ae,ce,Te){for(var Ge=null,Xe=null,Ze=ae,Qe=ae=0,nn=null;Ze!==null&&Qe<ce.length;Qe++){Ze.index>Qe?(nn=Ze,Ze=null):nn=Ze.sibling;var ft=Ne(ie,Ze,ce[Qe],Te);if(ft===null){Ze===null&&(Ze=nn);break}c&&Ze&&ft.alternate===null&&d(ie,Ze),ae=$(ft,ae,Qe),Xe===null?Ge=ft:Xe.sibling=ft,Xe=ft,Ze=nn}if(Qe===ce.length)return y(ie,Ze),Rt&&Lo(ie,Qe),Ge;if(Ze===null){for(;Qe<ce.length;Qe++)Ze=Ce(ie,ce[Qe],Te),Ze!==null&&(ae=$(Ze,ae,Qe),Xe===null?Ge=Ze:Xe.sibling=Ze,Xe=Ze);return Rt&&Lo(ie,Qe),Ge}for(Ze=k(ie,Ze);Qe<ce.length;Qe++)nn=Pe(Ze,ie,Qe,ce[Qe],Te),nn!==null&&(c&&nn.alternate!==null&&Ze.delete(nn.key===null?Qe:nn.key),ae=$(nn,ae,Qe),Xe===null?Ge=nn:Xe.sibling=nn,Xe=nn);return c&&Ze.forEach(function(Fa){return d(ie,Fa)}),Rt&&Lo(ie,Qe),Ge}function ze(ie,ae,ce,Te){var Ge=H(ce);if(typeof Ge!="function")throw Error(n(150));if(ce=Ge.call(ce),ce==null)throw Error(n(151));for(var Xe=Ge=null,Ze=ae,Qe=ae=0,nn=null,ft=ce.next();Ze!==null&&!ft.done;Qe++,ft=ce.next()){Ze.index>Qe?(nn=Ze,Ze=null):nn=Ze.sibling;var Fa=Ne(ie,Ze,ft.value,Te);if(Fa===null){Ze===null&&(Ze=nn);break}c&&Ze&&Fa.alternate===null&&d(ie,Ze),ae=$(Fa,ae,Qe),Xe===null?Ge=Fa:Xe.sibling=Fa,Xe=Fa,Ze=nn}if(ft.done)return y(ie,Ze),Rt&&Lo(ie,Qe),Ge;if(Ze===null){for(;!ft.done;Qe++,ft=ce.next())ft=Ce(ie,ft.value,Te),ft!==null&&(ae=$(ft,ae,Qe),Xe===null?Ge=ft:Xe.sibling=ft,Xe=ft);return Rt&&Lo(ie,Qe),Ge}for(Ze=k(ie,Ze);!ft.done;Qe++,ft=ce.next())ft=Pe(Ze,ie,Qe,ft.value,Te),ft!==null&&(c&&ft.alternate!==null&&Ze.delete(ft.key===null?Qe:ft.key),ae=$(ft,ae,Qe),Xe===null?Ge=ft:Xe.sibling=ft,Xe=ft);return c&&Ze.forEach(function(wq){return d(ie,wq)}),Rt&&Lo(ie,Qe),Ge}function Ut(ie,ae,ce,Te){if(typeof ce=="object"&&ce!==null&&ce.type===R&&ce.key===null&&(ce=ce.props.children),typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case _:e:{for(var Ge=ce.key,Xe=ae;Xe!==null;){if(Xe.key===Ge){if(Ge=ce.type,Ge===R){if(Xe.tag===7){y(ie,Xe.sibling),ae=E(Xe,ce.props.children),ae.return=ie,ie=ae;break e}}else if(Xe.elementType===Ge||typeof Ge=="object"&&Ge!==null&&Ge.$$typeof===O&&gC(Ge)===Xe.type){y(ie,Xe.sibling),ae=E(Xe,ce.props),ae.ref=Bc(ie,Xe,ce),ae.return=ie,ie=ae;break e}y(ie,Xe);break}else d(ie,Xe);Xe=Xe.sibling}ce.type===R?(ae=Uo(ce.props.children,ie.mode,Te,ce.key),ae.return=ie,ie=ae):(Te=Mh(ce.type,ce.key,ce.props,null,ie.mode,Te),Te.ref=Bc(ie,ae,ce),Te.return=ie,ie=Te)}return G(ie);case M:e:{for(Xe=ce.key;ae!==null;){if(ae.key===Xe)if(ae.tag===4&&ae.stateNode.containerInfo===ce.containerInfo&&ae.stateNode.implementation===ce.implementation){y(ie,ae.sibling),ae=E(ae,ce.children||[]),ae.return=ie,ie=ae;break e}else{y(ie,ae);break}else d(ie,ae);ae=ae.sibling}ae=vy(ce,ie.mode,Te),ae.return=ie,ie=ae}return G(ie);case O:return Xe=ce._init,Ut(ie,ae,Xe(ce._payload),Te)}if(Ee(ce))return Ue(ie,ae,ce,Te);if(H(ce))return ze(ie,ae,ce,Te);lh(ie,ce)}return typeof ce=="string"&&ce!==""||typeof ce=="number"?(ce=""+ce,ae!==null&&ae.tag===6?(y(ie,ae.sibling),ae=E(ae,ce),ae.return=ie,ie=ae):(y(ie,ae),ae=xy(ce,ie.mode,Te),ae.return=ie,ie=ae),G(ie)):y(ie,ae)}return Ut}var Yi=yC(!0),wC=yC(!1),ch=Ea(null),uh=null,Xi=null,Tg=null;function Ag(){Tg=Xi=uh=null}function Rg(c){var d=ch.current;At(ch),c._currentValue=d}function Mg(c,d,y){for(;c!==null;){var k=c.alternate;if((c.childLanes&d)!==d?(c.childLanes|=d,k!==null&&(k.childLanes|=d)):k!==null&&(k.childLanes&d)!==d&&(k.childLanes|=d),c===y)break;c=c.return}}function Zi(c,d){uh=c,Tg=Xi=null,c=c.dependencies,c!==null&&c.firstContext!==null&&((c.lanes&d)!==0&&(Mn=!0),c.firstContext=null)}function ls(c){var d=c._currentValue;if(Tg!==c)if(c={context:c,memoizedValue:d,next:null},Xi===null){if(uh===null)throw Error(n(308));Xi=c,uh.dependencies={lanes:0,firstContext:c}}else Xi=Xi.next=c;return d}var Io=null;function $g(c){Io===null?Io=[c]:Io.push(c)}function xC(c,d,y,k){var E=d.interleaved;return E===null?(y.next=y,$g(d)):(y.next=E.next,E.next=y),d.interleaved=y,zr(c,k)}function zr(c,d){c.lanes|=d;var y=c.alternate;for(y!==null&&(y.lanes|=d),y=c,c=c.return;c!==null;)c.childLanes|=d,y=c.alternate,y!==null&&(y.childLanes|=d),y=c,c=c.return;return y.tag===3?y.stateNode:null}var Ra=!1;function Lg(c){c.updateQueue={baseState:c.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function vC(c,d){c=c.updateQueue,d.updateQueue===c&&(d.updateQueue={baseState:c.baseState,firstBaseUpdate:c.firstBaseUpdate,lastBaseUpdate:c.lastBaseUpdate,shared:c.shared,effects:c.effects})}function Vr(c,d){return{eventTime:c,lane:d,tag:0,payload:null,callback:null,next:null}}function Ma(c,d,y){var k=c.updateQueue;if(k===null)return null;if(k=k.shared,(dt&2)!==0){var E=k.pending;return E===null?d.next=d:(d.next=E.next,E.next=d),k.pending=d,zr(c,y)}return E=k.interleaved,E===null?(d.next=d,$g(k)):(d.next=E.next,E.next=d),k.interleaved=d,zr(c,y)}function dh(c,d,y){if(d=d.updateQueue,d!==null&&(d=d.shared,(y&4194240)!==0)){var k=d.lanes;k&=c.pendingLanes,y|=k,d.lanes=y,$r(c,y)}}function bC(c,d){var y=c.updateQueue,k=c.alternate;if(k!==null&&(k=k.updateQueue,y===k)){var E=null,$=null;if(y=y.firstBaseUpdate,y!==null){do{var G={eventTime:y.eventTime,lane:y.lane,tag:y.tag,payload:y.payload,callback:y.callback,next:null};$===null?E=$=G:$=$.next=G,y=y.next}while(y!==null);$===null?E=$=d:$=$.next=d}else E=$=d;y={baseState:k.baseState,firstBaseUpdate:E,lastBaseUpdate:$,shared:k.shared,effects:k.effects},c.updateQueue=y;return}c=y.lastBaseUpdate,c===null?y.firstBaseUpdate=d:c.next=d,y.lastBaseUpdate=d}function hh(c,d,y,k){var E=c.updateQueue;Ra=!1;var $=E.firstBaseUpdate,G=E.lastBaseUpdate,ee=E.shared.pending;if(ee!==null){E.shared.pending=null;var ne=ee,ue=ne.next;ne.next=null,G===null?$=ue:G.next=ue,G=ne;var Se=c.alternate;Se!==null&&(Se=Se.updateQueue,ee=Se.lastBaseUpdate,ee!==G&&(ee===null?Se.firstBaseUpdate=ue:ee.next=ue,Se.lastBaseUpdate=ne))}if($!==null){var Ce=E.baseState;G=0,Se=ue=ne=null,ee=$;do{var Ne=ee.lane,Pe=ee.eventTime;if((k&Ne)===Ne){Se!==null&&(Se=Se.next={eventTime:Pe,lane:0,tag:ee.tag,payload:ee.payload,callback:ee.callback,next:null});e:{var Ue=c,ze=ee;switch(Ne=d,Pe=y,ze.tag){case 1:if(Ue=ze.payload,typeof Ue=="function"){Ce=Ue.call(Pe,Ce,Ne);break e}Ce=Ue;break e;case 3:Ue.flags=Ue.flags&-65537|128;case 0:if(Ue=ze.payload,Ne=typeof Ue=="function"?Ue.call(Pe,Ce,Ne):Ue,Ne==null)break e;Ce=D({},Ce,Ne);break e;case 2:Ra=!0}}ee.callback!==null&&ee.lane!==0&&(c.flags|=64,Ne=E.effects,Ne===null?E.effects=[ee]:Ne.push(ee))}else Pe={eventTime:Pe,lane:Ne,tag:ee.tag,payload:ee.payload,callback:ee.callback,next:null},Se===null?(ue=Se=Pe,ne=Ce):Se=Se.next=Pe,G|=Ne;if(ee=ee.next,ee===null){if(ee=E.shared.pending,ee===null)break;Ne=ee,ee=Ne.next,Ne.next=null,E.lastBaseUpdate=Ne,E.shared.pending=null}}while(!0);if(Se===null&&(ne=Ce),E.baseState=ne,E.firstBaseUpdate=ue,E.lastBaseUpdate=Se,d=E.shared.interleaved,d!==null){E=d;do G|=E.lane,E=E.next;while(E!==d)}else $===null&&(E.shared.lanes=0);Do|=G,c.lanes=G,c.memoizedState=Ce}}function kC(c,d,y){if(c=d.effects,d.effects=null,c!==null)for(d=0;d<c.length;d++){var k=c[d],E=k.callback;if(E!==null){if(k.callback=null,k=y,typeof E!="function")throw Error(n(191,E));E.call(k)}}}var qc={},ir=Ea(qc),Uc=Ea(qc),Wc=Ea(qc);function Oo(c){if(c===qc)throw Error(n(174));return c}function Ig(c,d){switch(St(Wc,d),St(Uc,c),St(ir,qc),c=d.nodeType,c){case 9:case 11:d=(d=d.documentElement)?d.namespaceURI:Fe(null,"");break;default:c=c===8?d.parentNode:d,d=c.namespaceURI||null,c=c.tagName,d=Fe(d,c)}At(ir),St(ir,d)}function Ji(){At(ir),At(Uc),At(Wc)}function jC(c){Oo(Wc.current);var d=Oo(ir.current),y=Fe(d,c.type);d!==y&&(St(Uc,c),St(ir,y))}function Og(c){Uc.current===c&&(At(ir),At(Uc))}var It=Ea(0);function fh(c){for(var d=c;d!==null;){if(d.tag===13){var y=d.memoizedState;if(y!==null&&(y=y.dehydrated,y===null||y.data==="$?"||y.data==="$!"))return d}else if(d.tag===19&&d.memoizedProps.revealOrder!==void 0){if((d.flags&128)!==0)return d}else if(d.child!==null){d.child.return=d,d=d.child;continue}if(d===c)break;for(;d.sibling===null;){if(d.return===null||d.return===c)return null;d=d.return}d.sibling.return=d.return,d=d.sibling}return null}var Pg=[];function Dg(){for(var c=0;c<Pg.length;c++)Pg[c]._workInProgressVersionPrimary=null;Pg.length=0}var ph=C.ReactCurrentDispatcher,Fg=C.ReactCurrentBatchConfig,Po=0,Ot=null,Gt=null,en=null,mh=!1,Hc=!1,zc=0,BB=0;function pn(){throw Error(n(321))}function Bg(c,d){if(d===null)return!1;for(var y=0;y<d.length&&y<c.length;y++)if(!Os(c[y],d[y]))return!1;return!0}function qg(c,d,y,k,E,$){if(Po=$,Ot=d,d.memoizedState=null,d.updateQueue=null,d.lanes=0,ph.current=c===null||c.memoizedState===null?HB:zB,c=y(k,E),Hc){$=0;do{if(Hc=!1,zc=0,25<=$)throw Error(n(301));$+=1,en=Gt=null,d.updateQueue=null,ph.current=VB,c=y(k,E)}while(Hc)}if(ph.current=wh,d=Gt!==null&&Gt.next!==null,Po=0,en=Gt=Ot=null,mh=!1,d)throw Error(n(300));return c}function Ug(){var c=zc!==0;return zc=0,c}function lr(){var c={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return en===null?Ot.memoizedState=en=c:en=en.next=c,en}function cs(){if(Gt===null){var c=Ot.alternate;c=c!==null?c.memoizedState:null}else c=Gt.next;var d=en===null?Ot.memoizedState:en.next;if(d!==null)en=d,Gt=c;else{if(c===null)throw Error(n(310));Gt=c,c={memoizedState:Gt.memoizedState,baseState:Gt.baseState,baseQueue:Gt.baseQueue,queue:Gt.queue,next:null},en===null?Ot.memoizedState=en=c:en=en.next=c}return en}function Vc(c,d){return typeof d=="function"?d(c):d}function Wg(c){var d=cs(),y=d.queue;if(y===null)throw Error(n(311));y.lastRenderedReducer=c;var k=Gt,E=k.baseQueue,$=y.pending;if($!==null){if(E!==null){var G=E.next;E.next=$.next,$.next=G}k.baseQueue=E=$,y.pending=null}if(E!==null){$=E.next,k=k.baseState;var ee=G=null,ne=null,ue=$;do{var Se=ue.lane;if((Po&Se)===Se)ne!==null&&(ne=ne.next={lane:0,action:ue.action,hasEagerState:ue.hasEagerState,eagerState:ue.eagerState,next:null}),k=ue.hasEagerState?ue.eagerState:c(k,ue.action);else{var Ce={lane:Se,action:ue.action,hasEagerState:ue.hasEagerState,eagerState:ue.eagerState,next:null};ne===null?(ee=ne=Ce,G=k):ne=ne.next=Ce,Ot.lanes|=Se,Do|=Se}ue=ue.next}while(ue!==null&&ue!==$);ne===null?G=k:ne.next=ee,Os(k,d.memoizedState)||(Mn=!0),d.memoizedState=k,d.baseState=G,d.baseQueue=ne,y.lastRenderedState=k}if(c=y.interleaved,c!==null){E=c;do $=E.lane,Ot.lanes|=$,Do|=$,E=E.next;while(E!==c)}else E===null&&(y.lanes=0);return[d.memoizedState,y.dispatch]}function Hg(c){var d=cs(),y=d.queue;if(y===null)throw Error(n(311));y.lastRenderedReducer=c;var k=y.dispatch,E=y.pending,$=d.memoizedState;if(E!==null){y.pending=null;var G=E=E.next;do $=c($,G.action),G=G.next;while(G!==E);Os($,d.memoizedState)||(Mn=!0),d.memoizedState=$,d.baseQueue===null&&(d.baseState=$),y.lastRenderedState=$}return[$,k]}function NC(){}function SC(c,d){var y=Ot,k=cs(),E=d(),$=!Os(k.memoizedState,E);if($&&(k.memoizedState=E,Mn=!0),k=k.queue,zg(EC.bind(null,y,k,c),[c]),k.getSnapshot!==d||$||en!==null&&en.memoizedState.tag&1){if(y.flags|=2048,Gc(9,_C.bind(null,y,k,E,d),void 0,null),tn===null)throw Error(n(349));(Po&30)!==0||CC(y,d,E)}return E}function CC(c,d,y){c.flags|=16384,c={getSnapshot:d,value:y},d=Ot.updateQueue,d===null?(d={lastEffect:null,stores:null},Ot.updateQueue=d,d.stores=[c]):(y=d.stores,y===null?d.stores=[c]:y.push(c))}function _C(c,d,y,k){d.value=y,d.getSnapshot=k,TC(d)&&AC(c)}function EC(c,d,y){return y(function(){TC(d)&&AC(c)})}function TC(c){var d=c.getSnapshot;c=c.value;try{var y=d();return!Os(c,y)}catch{return!0}}function AC(c){var d=zr(c,1);d!==null&&qs(d,c,1,-1)}function RC(c){var d=lr();return typeof c=="function"&&(c=c()),d.memoizedState=d.baseState=c,c={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Vc,lastRenderedState:c},d.queue=c,c=c.dispatch=WB.bind(null,Ot,c),[d.memoizedState,c]}function Gc(c,d,y,k){return c={tag:c,create:d,destroy:y,deps:k,next:null},d=Ot.updateQueue,d===null?(d={lastEffect:null,stores:null},Ot.updateQueue=d,d.lastEffect=c.next=c):(y=d.lastEffect,y===null?d.lastEffect=c.next=c:(k=y.next,y.next=c,c.next=k,d.lastEffect=c)),c}function MC(){return cs().memoizedState}function gh(c,d,y,k){var E=lr();Ot.flags|=c,E.memoizedState=Gc(1|d,y,void 0,k===void 0?null:k)}function yh(c,d,y,k){var E=cs();k=k===void 0?null:k;var $=void 0;if(Gt!==null){var G=Gt.memoizedState;if($=G.destroy,k!==null&&Bg(k,G.deps)){E.memoizedState=Gc(d,y,$,k);return}}Ot.flags|=c,E.memoizedState=Gc(1|d,y,$,k)}function $C(c,d){return gh(8390656,8,c,d)}function zg(c,d){return yh(2048,8,c,d)}function LC(c,d){return yh(4,2,c,d)}function IC(c,d){return yh(4,4,c,d)}function OC(c,d){if(typeof d=="function")return c=c(),d(c),function(){d(null)};if(d!=null)return c=c(),d.current=c,function(){d.current=null}}function PC(c,d,y){return y=y!=null?y.concat([c]):null,yh(4,4,OC.bind(null,d,c),y)}function Vg(){}function DC(c,d){var y=cs();d=d===void 0?null:d;var k=y.memoizedState;return k!==null&&d!==null&&Bg(d,k[1])?k[0]:(y.memoizedState=[c,d],c)}function FC(c,d){var y=cs();d=d===void 0?null:d;var k=y.memoizedState;return k!==null&&d!==null&&Bg(d,k[1])?k[0]:(c=c(),y.memoizedState=[c,d],c)}function BC(c,d,y){return(Po&21)===0?(c.baseState&&(c.baseState=!1,Mn=!0),c.memoizedState=y):(Os(y,d)||(y=sr(),Ot.lanes|=y,Do|=y,c.baseState=!0),d)}function qB(c,d){var y=at;at=y!==0&&4>y?y:4,c(!0);var k=Fg.transition;Fg.transition={};try{c(!1),d()}finally{at=y,Fg.transition=k}}function qC(){return cs().memoizedState}function UB(c,d,y){var k=Oa(c);if(y={lane:k,action:y,hasEagerState:!1,eagerState:null,next:null},UC(c))WC(d,y);else if(y=xC(c,d,y,k),y!==null){var E=kn();qs(y,c,k,E),HC(y,d,k)}}function WB(c,d,y){var k=Oa(c),E={lane:k,action:y,hasEagerState:!1,eagerState:null,next:null};if(UC(c))WC(d,E);else{var $=c.alternate;if(c.lanes===0&&($===null||$.lanes===0)&&($=d.lastRenderedReducer,$!==null))try{var G=d.lastRenderedState,ee=$(G,y);if(E.hasEagerState=!0,E.eagerState=ee,Os(ee,G)){var ne=d.interleaved;ne===null?(E.next=E,$g(d)):(E.next=ne.next,ne.next=E),d.interleaved=E;return}}catch{}finally{}y=xC(c,d,E,k),y!==null&&(E=kn(),qs(y,c,k,E),HC(y,d,k))}}function UC(c){var d=c.alternate;return c===Ot||d!==null&&d===Ot}function WC(c,d){Hc=mh=!0;var y=c.pending;y===null?d.next=d:(d.next=y.next,y.next=d),c.pending=d}function HC(c,d,y){if((y&4194240)!==0){var k=d.lanes;k&=c.pendingLanes,y|=k,d.lanes=y,$r(c,y)}}var wh={readContext:ls,useCallback:pn,useContext:pn,useEffect:pn,useImperativeHandle:pn,useInsertionEffect:pn,useLayoutEffect:pn,useMemo:pn,useReducer:pn,useRef:pn,useState:pn,useDebugValue:pn,useDeferredValue:pn,useTransition:pn,useMutableSource:pn,useSyncExternalStore:pn,useId:pn,unstable_isNewReconciler:!1},HB={readContext:ls,useCallback:function(c,d){return lr().memoizedState=[c,d===void 0?null:d],c},useContext:ls,useEffect:$C,useImperativeHandle:function(c,d,y){return y=y!=null?y.concat([c]):null,gh(4194308,4,OC.bind(null,d,c),y)},useLayoutEffect:function(c,d){return gh(4194308,4,c,d)},useInsertionEffect:function(c,d){return gh(4,2,c,d)},useMemo:function(c,d){var y=lr();return d=d===void 0?null:d,c=c(),y.memoizedState=[c,d],c},useReducer:function(c,d,y){var k=lr();return d=y!==void 0?y(d):d,k.memoizedState=k.baseState=d,c={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:c,lastRenderedState:d},k.queue=c,c=c.dispatch=UB.bind(null,Ot,c),[k.memoizedState,c]},useRef:function(c){var d=lr();return c={current:c},d.memoizedState=c},useState:RC,useDebugValue:Vg,useDeferredValue:function(c){return lr().memoizedState=c},useTransition:function(){var c=RC(!1),d=c[0];return c=qB.bind(null,c[1]),lr().memoizedState=c,[d,c]},useMutableSource:function(){},useSyncExternalStore:function(c,d,y){var k=Ot,E=lr();if(Rt){if(y===void 0)throw Error(n(407));y=y()}else{if(y=d(),tn===null)throw Error(n(349));(Po&30)!==0||CC(k,d,y)}E.memoizedState=y;var $={value:y,getSnapshot:d};return E.queue=$,$C(EC.bind(null,k,$,c),[c]),k.flags|=2048,Gc(9,_C.bind(null,k,$,y,d),void 0,null),y},useId:function(){var c=lr(),d=tn.identifierPrefix;if(Rt){var y=Hr,k=Wr;y=(k&~(1<<32-hn(k)-1)).toString(32)+y,d=":"+d+"R"+y,y=zc++,0<y&&(d+="H"+y.toString(32)),d+=":"}else y=BB++,d=":"+d+"r"+y.toString(32)+":";return c.memoizedState=d},unstable_isNewReconciler:!1},zB={readContext:ls,useCallback:DC,useContext:ls,useEffect:zg,useImperativeHandle:PC,useInsertionEffect:LC,useLayoutEffect:IC,useMemo:FC,useReducer:Wg,useRef:MC,useState:function(){return Wg(Vc)},useDebugValue:Vg,useDeferredValue:function(c){var d=cs();return BC(d,Gt.memoizedState,c)},useTransition:function(){var c=Wg(Vc)[0],d=cs().memoizedState;return[c,d]},useMutableSource:NC,useSyncExternalStore:SC,useId:qC,unstable_isNewReconciler:!1},VB={readContext:ls,useCallback:DC,useContext:ls,useEffect:zg,useImperativeHandle:PC,useInsertionEffect:LC,useLayoutEffect:IC,useMemo:FC,useReducer:Hg,useRef:MC,useState:function(){return Hg(Vc)},useDebugValue:Vg,useDeferredValue:function(c){var d=cs();return Gt===null?d.memoizedState=c:BC(d,Gt.memoizedState,c)},useTransition:function(){var c=Hg(Vc)[0],d=cs().memoizedState;return[c,d]},useMutableSource:NC,useSyncExternalStore:SC,useId:qC,unstable_isNewReconciler:!1};function Ds(c,d){if(c&&c.defaultProps){d=D({},d),c=c.defaultProps;for(var y in c)d[y]===void 0&&(d[y]=c[y]);return d}return d}function Gg(c,d,y,k){d=c.memoizedState,y=y(k,d),y=y==null?d:D({},d,y),c.memoizedState=y,c.lanes===0&&(c.updateQueue.baseState=y)}var xh={isMounted:function(c){return(c=c._reactInternals)?xn(c)===c:!1},enqueueSetState:function(c,d,y){c=c._reactInternals;var k=kn(),E=Oa(c),$=Vr(k,E);$.payload=d,y!=null&&($.callback=y),d=Ma(c,$,E),d!==null&&(qs(d,c,E,k),dh(d,c,E))},enqueueReplaceState:function(c,d,y){c=c._reactInternals;var k=kn(),E=Oa(c),$=Vr(k,E);$.tag=1,$.payload=d,y!=null&&($.callback=y),d=Ma(c,$,E),d!==null&&(qs(d,c,E,k),dh(d,c,E))},enqueueForceUpdate:function(c,d){c=c._reactInternals;var y=kn(),k=Oa(c),E=Vr(y,k);E.tag=2,d!=null&&(E.callback=d),d=Ma(c,E,k),d!==null&&(qs(d,c,k,y),dh(d,c,k))}};function zC(c,d,y,k,E,$,G){return c=c.stateNode,typeof c.shouldComponentUpdate=="function"?c.shouldComponentUpdate(k,$,G):d.prototype&&d.prototype.isPureReactComponent?!$c(y,k)||!$c(E,$):!0}function VC(c,d,y){var k=!1,E=Ta,$=d.contextType;return typeof $=="object"&&$!==null?$=ls($):(E=Rn(d)?Mo:fn.current,k=d.contextTypes,$=(k=k!=null)?zi(c,E):Ta),d=new d(y,$),c.memoizedState=d.state!==null&&d.state!==void 0?d.state:null,d.updater=xh,c.stateNode=d,d._reactInternals=c,k&&(c=c.stateNode,c.__reactInternalMemoizedUnmaskedChildContext=E,c.__reactInternalMemoizedMaskedChildContext=$),d}function GC(c,d,y,k){c=d.state,typeof d.componentWillReceiveProps=="function"&&d.componentWillReceiveProps(y,k),typeof d.UNSAFE_componentWillReceiveProps=="function"&&d.UNSAFE_componentWillReceiveProps(y,k),d.state!==c&&xh.enqueueReplaceState(d,d.state,null)}function Kg(c,d,y,k){var E=c.stateNode;E.props=y,E.state=c.memoizedState,E.refs={},Lg(c);var $=d.contextType;typeof $=="object"&&$!==null?E.context=ls($):($=Rn(d)?Mo:fn.current,E.context=zi(c,$)),E.state=c.memoizedState,$=d.getDerivedStateFromProps,typeof $=="function"&&(Gg(c,d,$,y),E.state=c.memoizedState),typeof d.getDerivedStateFromProps=="function"||typeof E.getSnapshotBeforeUpdate=="function"||typeof E.UNSAFE_componentWillMount!="function"&&typeof E.componentWillMount!="function"||(d=E.state,typeof E.componentWillMount=="function"&&E.componentWillMount(),typeof E.UNSAFE_componentWillMount=="function"&&E.UNSAFE_componentWillMount(),d!==E.state&&xh.enqueueReplaceState(E,E.state,null),hh(c,y,E,k),E.state=c.memoizedState),typeof E.componentDidMount=="function"&&(c.flags|=4194308)}function Qi(c,d){try{var y="",k=d;do y+=X(k),k=k.return;while(k);var E=y}catch($){E=`
|
|
39
|
+
Error generating stack: `+$.message+`
|
|
40
|
+
`+$.stack}return{value:c,source:d,stack:E,digest:null}}function Yg(c,d,y){return{value:c,source:null,stack:y??null,digest:d??null}}function Xg(c,d){try{console.error(d.value)}catch(y){setTimeout(function(){throw y})}}var GB=typeof WeakMap=="function"?WeakMap:Map;function KC(c,d,y){y=Vr(-1,y),y.tag=3,y.payload={element:null};var k=d.value;return y.callback=function(){Ch||(Ch=!0,dy=k),Xg(c,d)},y}function YC(c,d,y){y=Vr(-1,y),y.tag=3;var k=c.type.getDerivedStateFromError;if(typeof k=="function"){var E=d.value;y.payload=function(){return k(E)},y.callback=function(){Xg(c,d)}}var $=c.stateNode;return $!==null&&typeof $.componentDidCatch=="function"&&(y.callback=function(){Xg(c,d),typeof k!="function"&&(La===null?La=new Set([this]):La.add(this));var G=d.stack;this.componentDidCatch(d.value,{componentStack:G!==null?G:""})}),y}function XC(c,d,y){var k=c.pingCache;if(k===null){k=c.pingCache=new GB;var E=new Set;k.set(d,E)}else E=k.get(d),E===void 0&&(E=new Set,k.set(d,E));E.has(y)||(E.add(y),c=iq.bind(null,c,d,y),d.then(c,c))}function ZC(c){do{var d;if((d=c.tag===13)&&(d=c.memoizedState,d=d!==null?d.dehydrated!==null:!0),d)return c;c=c.return}while(c!==null);return null}function JC(c,d,y,k,E){return(c.mode&1)===0?(c===d?c.flags|=65536:(c.flags|=128,y.flags|=131072,y.flags&=-52805,y.tag===1&&(y.alternate===null?y.tag=17:(d=Vr(-1,1),d.tag=2,Ma(y,d,1))),y.lanes|=1),c):(c.flags|=65536,c.lanes=E,c)}var KB=C.ReactCurrentOwner,Mn=!1;function bn(c,d,y,k){d.child=c===null?wC(d,null,y,k):Yi(d,c.child,y,k)}function QC(c,d,y,k,E){y=y.render;var $=d.ref;return Zi(d,E),k=qg(c,d,y,k,$,E),y=Ug(),c!==null&&!Mn?(d.updateQueue=c.updateQueue,d.flags&=-2053,c.lanes&=~E,Gr(c,d,E)):(Rt&&y&&Ng(d),d.flags|=1,bn(c,d,k,E),d.child)}function e_(c,d,y,k,E){if(c===null){var $=y.type;return typeof $=="function"&&!wy($)&&$.defaultProps===void 0&&y.compare===null&&y.defaultProps===void 0?(d.tag=15,d.type=$,t_(c,d,$,k,E)):(c=Mh(y.type,null,k,d,d.mode,E),c.ref=d.ref,c.return=d,d.child=c)}if($=c.child,(c.lanes&E)===0){var G=$.memoizedProps;if(y=y.compare,y=y!==null?y:$c,y(G,k)&&c.ref===d.ref)return Gr(c,d,E)}return d.flags|=1,c=Da($,k),c.ref=d.ref,c.return=d,d.child=c}function t_(c,d,y,k,E){if(c!==null){var $=c.memoizedProps;if($c($,k)&&c.ref===d.ref)if(Mn=!1,d.pendingProps=k=$,(c.lanes&E)!==0)(c.flags&131072)!==0&&(Mn=!0);else return d.lanes=c.lanes,Gr(c,d,E)}return Zg(c,d,y,k,E)}function n_(c,d,y){var k=d.pendingProps,E=k.children,$=c!==null?c.memoizedState:null;if(k.mode==="hidden")if((d.mode&1)===0)d.memoizedState={baseLanes:0,cachePool:null,transitions:null},St(tl,Yn),Yn|=y;else{if((y&1073741824)===0)return c=$!==null?$.baseLanes|y:y,d.lanes=d.childLanes=1073741824,d.memoizedState={baseLanes:c,cachePool:null,transitions:null},d.updateQueue=null,St(tl,Yn),Yn|=c,null;d.memoizedState={baseLanes:0,cachePool:null,transitions:null},k=$!==null?$.baseLanes:y,St(tl,Yn),Yn|=k}else $!==null?(k=$.baseLanes|y,d.memoizedState=null):k=y,St(tl,Yn),Yn|=k;return bn(c,d,E,y),d.child}function s_(c,d){var y=d.ref;(c===null&&y!==null||c!==null&&c.ref!==y)&&(d.flags|=512,d.flags|=2097152)}function Zg(c,d,y,k,E){var $=Rn(y)?Mo:fn.current;return $=zi(d,$),Zi(d,E),y=qg(c,d,y,k,$,E),k=Ug(),c!==null&&!Mn?(d.updateQueue=c.updateQueue,d.flags&=-2053,c.lanes&=~E,Gr(c,d,E)):(Rt&&k&&Ng(d),d.flags|=1,bn(c,d,y,E),d.child)}function r_(c,d,y,k,E){if(Rn(y)){var $=!0;sh(d)}else $=!1;if(Zi(d,E),d.stateNode===null)bh(c,d),VC(d,y,k),Kg(d,y,k,E),k=!0;else if(c===null){var G=d.stateNode,ee=d.memoizedProps;G.props=ee;var ne=G.context,ue=y.contextType;typeof ue=="object"&&ue!==null?ue=ls(ue):(ue=Rn(y)?Mo:fn.current,ue=zi(d,ue));var Se=y.getDerivedStateFromProps,Ce=typeof Se=="function"||typeof G.getSnapshotBeforeUpdate=="function";Ce||typeof G.UNSAFE_componentWillReceiveProps!="function"&&typeof G.componentWillReceiveProps!="function"||(ee!==k||ne!==ue)&&GC(d,G,k,ue),Ra=!1;var Ne=d.memoizedState;G.state=Ne,hh(d,k,G,E),ne=d.memoizedState,ee!==k||Ne!==ne||An.current||Ra?(typeof Se=="function"&&(Gg(d,y,Se,k),ne=d.memoizedState),(ee=Ra||zC(d,y,ee,k,Ne,ne,ue))?(Ce||typeof G.UNSAFE_componentWillMount!="function"&&typeof G.componentWillMount!="function"||(typeof G.componentWillMount=="function"&&G.componentWillMount(),typeof G.UNSAFE_componentWillMount=="function"&&G.UNSAFE_componentWillMount()),typeof G.componentDidMount=="function"&&(d.flags|=4194308)):(typeof G.componentDidMount=="function"&&(d.flags|=4194308),d.memoizedProps=k,d.memoizedState=ne),G.props=k,G.state=ne,G.context=ue,k=ee):(typeof G.componentDidMount=="function"&&(d.flags|=4194308),k=!1)}else{G=d.stateNode,vC(c,d),ee=d.memoizedProps,ue=d.type===d.elementType?ee:Ds(d.type,ee),G.props=ue,Ce=d.pendingProps,Ne=G.context,ne=y.contextType,typeof ne=="object"&&ne!==null?ne=ls(ne):(ne=Rn(y)?Mo:fn.current,ne=zi(d,ne));var Pe=y.getDerivedStateFromProps;(Se=typeof Pe=="function"||typeof G.getSnapshotBeforeUpdate=="function")||typeof G.UNSAFE_componentWillReceiveProps!="function"&&typeof G.componentWillReceiveProps!="function"||(ee!==Ce||Ne!==ne)&&GC(d,G,k,ne),Ra=!1,Ne=d.memoizedState,G.state=Ne,hh(d,k,G,E);var Ue=d.memoizedState;ee!==Ce||Ne!==Ue||An.current||Ra?(typeof Pe=="function"&&(Gg(d,y,Pe,k),Ue=d.memoizedState),(ue=Ra||zC(d,y,ue,k,Ne,Ue,ne)||!1)?(Se||typeof G.UNSAFE_componentWillUpdate!="function"&&typeof G.componentWillUpdate!="function"||(typeof G.componentWillUpdate=="function"&&G.componentWillUpdate(k,Ue,ne),typeof G.UNSAFE_componentWillUpdate=="function"&&G.UNSAFE_componentWillUpdate(k,Ue,ne)),typeof G.componentDidUpdate=="function"&&(d.flags|=4),typeof G.getSnapshotBeforeUpdate=="function"&&(d.flags|=1024)):(typeof G.componentDidUpdate!="function"||ee===c.memoizedProps&&Ne===c.memoizedState||(d.flags|=4),typeof G.getSnapshotBeforeUpdate!="function"||ee===c.memoizedProps&&Ne===c.memoizedState||(d.flags|=1024),d.memoizedProps=k,d.memoizedState=Ue),G.props=k,G.state=Ue,G.context=ne,k=ue):(typeof G.componentDidUpdate!="function"||ee===c.memoizedProps&&Ne===c.memoizedState||(d.flags|=4),typeof G.getSnapshotBeforeUpdate!="function"||ee===c.memoizedProps&&Ne===c.memoizedState||(d.flags|=1024),k=!1)}return Jg(c,d,y,k,$,E)}function Jg(c,d,y,k,E,$){s_(c,d);var G=(d.flags&128)!==0;if(!k&&!G)return E&&cC(d,y,!1),Gr(c,d,$);k=d.stateNode,KB.current=d;var ee=G&&typeof y.getDerivedStateFromError!="function"?null:k.render();return d.flags|=1,c!==null&&G?(d.child=Yi(d,c.child,null,$),d.child=Yi(d,null,ee,$)):bn(c,d,ee,$),d.memoizedState=k.state,E&&cC(d,y,!0),d.child}function a_(c){var d=c.stateNode;d.pendingContext?iC(c,d.pendingContext,d.pendingContext!==d.context):d.context&&iC(c,d.context,!1),Ig(c,d.containerInfo)}function o_(c,d,y,k,E){return Ki(),Eg(E),d.flags|=256,bn(c,d,y,k),d.child}var Qg={dehydrated:null,treeContext:null,retryLane:0};function ey(c){return{baseLanes:c,cachePool:null,transitions:null}}function i_(c,d,y){var k=d.pendingProps,E=It.current,$=!1,G=(d.flags&128)!==0,ee;if((ee=G)||(ee=c!==null&&c.memoizedState===null?!1:(E&2)!==0),ee?($=!0,d.flags&=-129):(c===null||c.memoizedState!==null)&&(E|=1),St(It,E&1),c===null)return _g(d),c=d.memoizedState,c!==null&&(c=c.dehydrated,c!==null)?((d.mode&1)===0?d.lanes=1:c.data==="$!"?d.lanes=8:d.lanes=1073741824,null):(G=k.children,c=k.fallback,$?(k=d.mode,$=d.child,G={mode:"hidden",children:G},(k&1)===0&&$!==null?($.childLanes=0,$.pendingProps=G):$=$h(G,k,0,null),c=Uo(c,k,y,null),$.return=d,c.return=d,$.sibling=c,d.child=$,d.child.memoizedState=ey(y),d.memoizedState=Qg,c):ty(d,G));if(E=c.memoizedState,E!==null&&(ee=E.dehydrated,ee!==null))return YB(c,d,G,k,ee,E,y);if($){$=k.fallback,G=d.mode,E=c.child,ee=E.sibling;var ne={mode:"hidden",children:k.children};return(G&1)===0&&d.child!==E?(k=d.child,k.childLanes=0,k.pendingProps=ne,d.deletions=null):(k=Da(E,ne),k.subtreeFlags=E.subtreeFlags&14680064),ee!==null?$=Da(ee,$):($=Uo($,G,y,null),$.flags|=2),$.return=d,k.return=d,k.sibling=$,d.child=k,k=$,$=d.child,G=c.child.memoizedState,G=G===null?ey(y):{baseLanes:G.baseLanes|y,cachePool:null,transitions:G.transitions},$.memoizedState=G,$.childLanes=c.childLanes&~y,d.memoizedState=Qg,k}return $=c.child,c=$.sibling,k=Da($,{mode:"visible",children:k.children}),(d.mode&1)===0&&(k.lanes=y),k.return=d,k.sibling=null,c!==null&&(y=d.deletions,y===null?(d.deletions=[c],d.flags|=16):y.push(c)),d.child=k,d.memoizedState=null,k}function ty(c,d){return d=$h({mode:"visible",children:d},c.mode,0,null),d.return=c,c.child=d}function vh(c,d,y,k){return k!==null&&Eg(k),Yi(d,c.child,null,y),c=ty(d,d.pendingProps.children),c.flags|=2,d.memoizedState=null,c}function YB(c,d,y,k,E,$,G){if(y)return d.flags&256?(d.flags&=-257,k=Yg(Error(n(422))),vh(c,d,G,k)):d.memoizedState!==null?(d.child=c.child,d.flags|=128,null):($=k.fallback,E=d.mode,k=$h({mode:"visible",children:k.children},E,0,null),$=Uo($,E,G,null),$.flags|=2,k.return=d,$.return=d,k.sibling=$,d.child=k,(d.mode&1)!==0&&Yi(d,c.child,null,G),d.child.memoizedState=ey(G),d.memoizedState=Qg,$);if((d.mode&1)===0)return vh(c,d,G,null);if(E.data==="$!"){if(k=E.nextSibling&&E.nextSibling.dataset,k)var ee=k.dgst;return k=ee,$=Error(n(419)),k=Yg($,k,void 0),vh(c,d,G,k)}if(ee=(G&c.childLanes)!==0,Mn||ee){if(k=tn,k!==null){switch(G&-G){case 4:E=2;break;case 16:E=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:E=32;break;case 536870912:E=268435456;break;default:E=0}E=(E&(k.suspendedLanes|G))!==0?0:E,E!==0&&E!==$.retryLane&&($.retryLane=E,zr(c,E),qs(k,c,E,-1))}return yy(),k=Yg(Error(n(421))),vh(c,d,G,k)}return E.data==="$?"?(d.flags|=128,d.child=c.child,d=lq.bind(null,c),E._reactRetry=d,null):(c=$.treeContext,Kn=_a(E.nextSibling),Gn=d,Rt=!0,Ps=null,c!==null&&(os[is++]=Wr,os[is++]=Hr,os[is++]=$o,Wr=c.id,Hr=c.overflow,$o=d),d=ty(d,k.children),d.flags|=4096,d)}function l_(c,d,y){c.lanes|=d;var k=c.alternate;k!==null&&(k.lanes|=d),Mg(c.return,d,y)}function ny(c,d,y,k,E){var $=c.memoizedState;$===null?c.memoizedState={isBackwards:d,rendering:null,renderingStartTime:0,last:k,tail:y,tailMode:E}:($.isBackwards=d,$.rendering=null,$.renderingStartTime=0,$.last=k,$.tail=y,$.tailMode=E)}function c_(c,d,y){var k=d.pendingProps,E=k.revealOrder,$=k.tail;if(bn(c,d,k.children,y),k=It.current,(k&2)!==0)k=k&1|2,d.flags|=128;else{if(c!==null&&(c.flags&128)!==0)e:for(c=d.child;c!==null;){if(c.tag===13)c.memoizedState!==null&&l_(c,y,d);else if(c.tag===19)l_(c,y,d);else if(c.child!==null){c.child.return=c,c=c.child;continue}if(c===d)break e;for(;c.sibling===null;){if(c.return===null||c.return===d)break e;c=c.return}c.sibling.return=c.return,c=c.sibling}k&=1}if(St(It,k),(d.mode&1)===0)d.memoizedState=null;else switch(E){case"forwards":for(y=d.child,E=null;y!==null;)c=y.alternate,c!==null&&fh(c)===null&&(E=y),y=y.sibling;y=E,y===null?(E=d.child,d.child=null):(E=y.sibling,y.sibling=null),ny(d,!1,E,y,$);break;case"backwards":for(y=null,E=d.child,d.child=null;E!==null;){if(c=E.alternate,c!==null&&fh(c)===null){d.child=E;break}c=E.sibling,E.sibling=y,y=E,E=c}ny(d,!0,y,null,$);break;case"together":ny(d,!1,null,null,void 0);break;default:d.memoizedState=null}return d.child}function bh(c,d){(d.mode&1)===0&&c!==null&&(c.alternate=null,d.alternate=null,d.flags|=2)}function Gr(c,d,y){if(c!==null&&(d.dependencies=c.dependencies),Do|=d.lanes,(y&d.childLanes)===0)return null;if(c!==null&&d.child!==c.child)throw Error(n(153));if(d.child!==null){for(c=d.child,y=Da(c,c.pendingProps),d.child=y,y.return=d;c.sibling!==null;)c=c.sibling,y=y.sibling=Da(c,c.pendingProps),y.return=d;y.sibling=null}return d.child}function XB(c,d,y){switch(d.tag){case 3:a_(d),Ki();break;case 5:jC(d);break;case 1:Rn(d.type)&&sh(d);break;case 4:Ig(d,d.stateNode.containerInfo);break;case 10:var k=d.type._context,E=d.memoizedProps.value;St(ch,k._currentValue),k._currentValue=E;break;case 13:if(k=d.memoizedState,k!==null)return k.dehydrated!==null?(St(It,It.current&1),d.flags|=128,null):(y&d.child.childLanes)!==0?i_(c,d,y):(St(It,It.current&1),c=Gr(c,d,y),c!==null?c.sibling:null);St(It,It.current&1);break;case 19:if(k=(y&d.childLanes)!==0,(c.flags&128)!==0){if(k)return c_(c,d,y);d.flags|=128}if(E=d.memoizedState,E!==null&&(E.rendering=null,E.tail=null,E.lastEffect=null),St(It,It.current),k)break;return null;case 22:case 23:return d.lanes=0,n_(c,d,y)}return Gr(c,d,y)}var u_,sy,d_,h_;u_=function(c,d){for(var y=d.child;y!==null;){if(y.tag===5||y.tag===6)c.appendChild(y.stateNode);else if(y.tag!==4&&y.child!==null){y.child.return=y,y=y.child;continue}if(y===d)break;for(;y.sibling===null;){if(y.return===null||y.return===d)return;y=y.return}y.sibling.return=y.return,y=y.sibling}},sy=function(){},d_=function(c,d,y,k){var E=c.memoizedProps;if(E!==k){c=d.stateNode,Oo(ir.current);var $=null;switch(y){case"input":E=he(c,E),k=he(c,k),$=[];break;case"select":E=D({},E,{value:void 0}),k=D({},k,{value:void 0}),$=[];break;case"textarea":E=Ie(c,E),k=Ie(c,k),$=[];break;default:typeof E.onClick!="function"&&typeof k.onClick=="function"&&(c.onclick=eh)}be(y,k);var G;y=null;for(ue in E)if(!k.hasOwnProperty(ue)&&E.hasOwnProperty(ue)&&E[ue]!=null)if(ue==="style"){var ee=E[ue];for(G in ee)ee.hasOwnProperty(G)&&(y||(y={}),y[G]="")}else ue!=="dangerouslySetInnerHTML"&&ue!=="children"&&ue!=="suppressContentEditableWarning"&&ue!=="suppressHydrationWarning"&&ue!=="autoFocus"&&(a.hasOwnProperty(ue)?$||($=[]):($=$||[]).push(ue,null));for(ue in k){var ne=k[ue];if(ee=E!=null?E[ue]:void 0,k.hasOwnProperty(ue)&&ne!==ee&&(ne!=null||ee!=null))if(ue==="style")if(ee){for(G in ee)!ee.hasOwnProperty(G)||ne&&ne.hasOwnProperty(G)||(y||(y={}),y[G]="");for(G in ne)ne.hasOwnProperty(G)&&ee[G]!==ne[G]&&(y||(y={}),y[G]=ne[G])}else y||($||($=[]),$.push(ue,y)),y=ne;else ue==="dangerouslySetInnerHTML"?(ne=ne?ne.__html:void 0,ee=ee?ee.__html:void 0,ne!=null&&ee!==ne&&($=$||[]).push(ue,ne)):ue==="children"?typeof ne!="string"&&typeof ne!="number"||($=$||[]).push(ue,""+ne):ue!=="suppressContentEditableWarning"&&ue!=="suppressHydrationWarning"&&(a.hasOwnProperty(ue)?(ne!=null&&ue==="onScroll"&&Tt("scroll",c),$||ee===ne||($=[])):($=$||[]).push(ue,ne))}y&&($=$||[]).push("style",y);var ue=$;(d.updateQueue=ue)&&(d.flags|=4)}},h_=function(c,d,y,k){y!==k&&(d.flags|=4)};function Kc(c,d){if(!Rt)switch(c.tailMode){case"hidden":d=c.tail;for(var y=null;d!==null;)d.alternate!==null&&(y=d),d=d.sibling;y===null?c.tail=null:y.sibling=null;break;case"collapsed":y=c.tail;for(var k=null;y!==null;)y.alternate!==null&&(k=y),y=y.sibling;k===null?d||c.tail===null?c.tail=null:c.tail.sibling=null:k.sibling=null}}function mn(c){var d=c.alternate!==null&&c.alternate.child===c.child,y=0,k=0;if(d)for(var E=c.child;E!==null;)y|=E.lanes|E.childLanes,k|=E.subtreeFlags&14680064,k|=E.flags&14680064,E.return=c,E=E.sibling;else for(E=c.child;E!==null;)y|=E.lanes|E.childLanes,k|=E.subtreeFlags,k|=E.flags,E.return=c,E=E.sibling;return c.subtreeFlags|=k,c.childLanes=y,d}function ZB(c,d,y){var k=d.pendingProps;switch(Sg(d),d.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return mn(d),null;case 1:return Rn(d.type)&&nh(),mn(d),null;case 3:return k=d.stateNode,Ji(),At(An),At(fn),Dg(),k.pendingContext&&(k.context=k.pendingContext,k.pendingContext=null),(c===null||c.child===null)&&(ih(d)?d.flags|=4:c===null||c.memoizedState.isDehydrated&&(d.flags&256)===0||(d.flags|=1024,Ps!==null&&(py(Ps),Ps=null))),sy(c,d),mn(d),null;case 5:Og(d);var E=Oo(Wc.current);if(y=d.type,c!==null&&d.stateNode!=null)d_(c,d,y,k,E),c.ref!==d.ref&&(d.flags|=512,d.flags|=2097152);else{if(!k){if(d.stateNode===null)throw Error(n(166));return mn(d),null}if(c=Oo(ir.current),ih(d)){k=d.stateNode,y=d.type;var $=d.memoizedProps;switch(k[or]=d,k[Dc]=$,c=(d.mode&1)!==0,y){case"dialog":Tt("cancel",k),Tt("close",k);break;case"iframe":case"object":case"embed":Tt("load",k);break;case"video":case"audio":for(E=0;E<Ic.length;E++)Tt(Ic[E],k);break;case"source":Tt("error",k);break;case"img":case"image":case"link":Tt("error",k),Tt("load",k);break;case"details":Tt("toggle",k);break;case"input":pe(k,$),Tt("invalid",k);break;case"select":k._wrapperState={wasMultiple:!!$.multiple},Tt("invalid",k);break;case"textarea":De(k,$),Tt("invalid",k)}be(y,$),E=null;for(var G in $)if($.hasOwnProperty(G)){var ee=$[G];G==="children"?typeof ee=="string"?k.textContent!==ee&&($.suppressHydrationWarning!==!0&&Qd(k.textContent,ee,c),E=["children",ee]):typeof ee=="number"&&k.textContent!==""+ee&&($.suppressHydrationWarning!==!0&&Qd(k.textContent,ee,c),E=["children",""+ee]):a.hasOwnProperty(G)&&ee!=null&&G==="onScroll"&&Tt("scroll",k)}switch(y){case"input":de(k),ve(k,$,!0);break;case"textarea":de(k),Ke(k);break;case"select":case"option":break;default:typeof $.onClick=="function"&&(k.onclick=eh)}k=E,d.updateQueue=k,k!==null&&(d.flags|=4)}else{G=E.nodeType===9?E:E.ownerDocument,c==="http://www.w3.org/1999/xhtml"&&(c=ye(y)),c==="http://www.w3.org/1999/xhtml"?y==="script"?(c=G.createElement("div"),c.innerHTML="<script><\/script>",c=c.removeChild(c.firstChild)):typeof k.is=="string"?c=G.createElement(y,{is:k.is}):(c=G.createElement(y),y==="select"&&(G=c,k.multiple?G.multiple=!0:k.size&&(G.size=k.size))):c=G.createElementNS(c,y),c[or]=d,c[Dc]=k,u_(c,d,!1,!1),d.stateNode=c;e:{switch(G=fe(y,k),y){case"dialog":Tt("cancel",c),Tt("close",c),E=k;break;case"iframe":case"object":case"embed":Tt("load",c),E=k;break;case"video":case"audio":for(E=0;E<Ic.length;E++)Tt(Ic[E],c);E=k;break;case"source":Tt("error",c),E=k;break;case"img":case"image":case"link":Tt("error",c),Tt("load",c),E=k;break;case"details":Tt("toggle",c),E=k;break;case"input":pe(c,k),E=he(c,k),Tt("invalid",c);break;case"option":E=k;break;case"select":c._wrapperState={wasMultiple:!!k.multiple},E=D({},k,{value:void 0}),Tt("invalid",c);break;case"textarea":De(c,k),E=Ie(c,k),Tt("invalid",c);break;default:E=k}be(y,E),ee=E;for($ in ee)if(ee.hasOwnProperty($)){var ne=ee[$];$==="style"?Ae(c,ne):$==="dangerouslySetInnerHTML"?(ne=ne?ne.__html:void 0,ne!=null&&Re(c,ne)):$==="children"?typeof ne=="string"?(y!=="textarea"||ne!=="")&&rt(c,ne):typeof ne=="number"&&rt(c,""+ne):$!=="suppressContentEditableWarning"&&$!=="suppressHydrationWarning"&&$!=="autoFocus"&&(a.hasOwnProperty($)?ne!=null&&$==="onScroll"&&Tt("scroll",c):ne!=null&&S(c,$,ne,G))}switch(y){case"input":de(c),ve(c,k,!1);break;case"textarea":de(c),Ke(c);break;case"option":k.value!=null&&c.setAttribute("value",""+Q(k.value));break;case"select":c.multiple=!!k.multiple,$=k.value,$!=null?xe(c,!!k.multiple,$,!1):k.defaultValue!=null&&xe(c,!!k.multiple,k.defaultValue,!0);break;default:typeof E.onClick=="function"&&(c.onclick=eh)}switch(y){case"button":case"input":case"select":case"textarea":k=!!k.autoFocus;break e;case"img":k=!0;break e;default:k=!1}}k&&(d.flags|=4)}d.ref!==null&&(d.flags|=512,d.flags|=2097152)}return mn(d),null;case 6:if(c&&d.stateNode!=null)h_(c,d,c.memoizedProps,k);else{if(typeof k!="string"&&d.stateNode===null)throw Error(n(166));if(y=Oo(Wc.current),Oo(ir.current),ih(d)){if(k=d.stateNode,y=d.memoizedProps,k[or]=d,($=k.nodeValue!==y)&&(c=Gn,c!==null))switch(c.tag){case 3:Qd(k.nodeValue,y,(c.mode&1)!==0);break;case 5:c.memoizedProps.suppressHydrationWarning!==!0&&Qd(k.nodeValue,y,(c.mode&1)!==0)}$&&(d.flags|=4)}else k=(y.nodeType===9?y:y.ownerDocument).createTextNode(k),k[or]=d,d.stateNode=k}return mn(d),null;case 13:if(At(It),k=d.memoizedState,c===null||c.memoizedState!==null&&c.memoizedState.dehydrated!==null){if(Rt&&Kn!==null&&(d.mode&1)!==0&&(d.flags&128)===0)mC(),Ki(),d.flags|=98560,$=!1;else if($=ih(d),k!==null&&k.dehydrated!==null){if(c===null){if(!$)throw Error(n(318));if($=d.memoizedState,$=$!==null?$.dehydrated:null,!$)throw Error(n(317));$[or]=d}else Ki(),(d.flags&128)===0&&(d.memoizedState=null),d.flags|=4;mn(d),$=!1}else Ps!==null&&(py(Ps),Ps=null),$=!0;if(!$)return d.flags&65536?d:null}return(d.flags&128)!==0?(d.lanes=y,d):(k=k!==null,k!==(c!==null&&c.memoizedState!==null)&&k&&(d.child.flags|=8192,(d.mode&1)!==0&&(c===null||(It.current&1)!==0?Kt===0&&(Kt=3):yy())),d.updateQueue!==null&&(d.flags|=4),mn(d),null);case 4:return Ji(),sy(c,d),c===null&&Oc(d.stateNode.containerInfo),mn(d),null;case 10:return Rg(d.type._context),mn(d),null;case 17:return Rn(d.type)&&nh(),mn(d),null;case 19:if(At(It),$=d.memoizedState,$===null)return mn(d),null;if(k=(d.flags&128)!==0,G=$.rendering,G===null)if(k)Kc($,!1);else{if(Kt!==0||c!==null&&(c.flags&128)!==0)for(c=d.child;c!==null;){if(G=fh(c),G!==null){for(d.flags|=128,Kc($,!1),k=G.updateQueue,k!==null&&(d.updateQueue=k,d.flags|=4),d.subtreeFlags=0,k=y,y=d.child;y!==null;)$=y,c=k,$.flags&=14680066,G=$.alternate,G===null?($.childLanes=0,$.lanes=c,$.child=null,$.subtreeFlags=0,$.memoizedProps=null,$.memoizedState=null,$.updateQueue=null,$.dependencies=null,$.stateNode=null):($.childLanes=G.childLanes,$.lanes=G.lanes,$.child=G.child,$.subtreeFlags=0,$.deletions=null,$.memoizedProps=G.memoizedProps,$.memoizedState=G.memoizedState,$.updateQueue=G.updateQueue,$.type=G.type,c=G.dependencies,$.dependencies=c===null?null:{lanes:c.lanes,firstContext:c.firstContext}),y=y.sibling;return St(It,It.current&1|2),d.child}c=c.sibling}$.tail!==null&&xt()>nl&&(d.flags|=128,k=!0,Kc($,!1),d.lanes=4194304)}else{if(!k)if(c=fh(G),c!==null){if(d.flags|=128,k=!0,y=c.updateQueue,y!==null&&(d.updateQueue=y,d.flags|=4),Kc($,!0),$.tail===null&&$.tailMode==="hidden"&&!G.alternate&&!Rt)return mn(d),null}else 2*xt()-$.renderingStartTime>nl&&y!==1073741824&&(d.flags|=128,k=!0,Kc($,!1),d.lanes=4194304);$.isBackwards?(G.sibling=d.child,d.child=G):(y=$.last,y!==null?y.sibling=G:d.child=G,$.last=G)}return $.tail!==null?(d=$.tail,$.rendering=d,$.tail=d.sibling,$.renderingStartTime=xt(),d.sibling=null,y=It.current,St(It,k?y&1|2:y&1),d):(mn(d),null);case 22:case 23:return gy(),k=d.memoizedState!==null,c!==null&&c.memoizedState!==null!==k&&(d.flags|=8192),k&&(d.mode&1)!==0?(Yn&1073741824)!==0&&(mn(d),d.subtreeFlags&6&&(d.flags|=8192)):mn(d),null;case 24:return null;case 25:return null}throw Error(n(156,d.tag))}function JB(c,d){switch(Sg(d),d.tag){case 1:return Rn(d.type)&&nh(),c=d.flags,c&65536?(d.flags=c&-65537|128,d):null;case 3:return Ji(),At(An),At(fn),Dg(),c=d.flags,(c&65536)!==0&&(c&128)===0?(d.flags=c&-65537|128,d):null;case 5:return Og(d),null;case 13:if(At(It),c=d.memoizedState,c!==null&&c.dehydrated!==null){if(d.alternate===null)throw Error(n(340));Ki()}return c=d.flags,c&65536?(d.flags=c&-65537|128,d):null;case 19:return At(It),null;case 4:return Ji(),null;case 10:return Rg(d.type._context),null;case 22:case 23:return gy(),null;case 24:return null;default:return null}}var kh=!1,gn=!1,QB=typeof WeakSet=="function"?WeakSet:Set,Be=null;function el(c,d){var y=c.ref;if(y!==null)if(typeof y=="function")try{y(null)}catch(k){Dt(c,d,k)}else y.current=null}function ry(c,d,y){try{y()}catch(k){Dt(c,d,k)}}var f_=!1;function eq(c,d){if(gg=jo,c=zS(),lg(c)){if("selectionStart"in c)var y={start:c.selectionStart,end:c.selectionEnd};else e:{y=(y=c.ownerDocument)&&y.defaultView||window;var k=y.getSelection&&y.getSelection();if(k&&k.rangeCount!==0){y=k.anchorNode;var E=k.anchorOffset,$=k.focusNode;k=k.focusOffset;try{y.nodeType,$.nodeType}catch{y=null;break e}var G=0,ee=-1,ne=-1,ue=0,Se=0,Ce=c,Ne=null;t:for(;;){for(var Pe;Ce!==y||E!==0&&Ce.nodeType!==3||(ee=G+E),Ce!==$||k!==0&&Ce.nodeType!==3||(ne=G+k),Ce.nodeType===3&&(G+=Ce.nodeValue.length),(Pe=Ce.firstChild)!==null;)Ne=Ce,Ce=Pe;for(;;){if(Ce===c)break t;if(Ne===y&&++ue===E&&(ee=G),Ne===$&&++Se===k&&(ne=G),(Pe=Ce.nextSibling)!==null)break;Ce=Ne,Ne=Ce.parentNode}Ce=Pe}y=ee===-1||ne===-1?null:{start:ee,end:ne}}else y=null}y=y||{start:0,end:0}}else y=null;for(yg={focusedElem:c,selectionRange:y},jo=!1,Be=d;Be!==null;)if(d=Be,c=d.child,(d.subtreeFlags&1028)!==0&&c!==null)c.return=d,Be=c;else for(;Be!==null;){d=Be;try{var Ue=d.alternate;if((d.flags&1024)!==0)switch(d.tag){case 0:case 11:case 15:break;case 1:if(Ue!==null){var ze=Ue.memoizedProps,Ut=Ue.memoizedState,ie=d.stateNode,ae=ie.getSnapshotBeforeUpdate(d.elementType===d.type?ze:Ds(d.type,ze),Ut);ie.__reactInternalSnapshotBeforeUpdate=ae}break;case 3:var ce=d.stateNode.containerInfo;ce.nodeType===1?ce.textContent="":ce.nodeType===9&&ce.documentElement&&ce.removeChild(ce.documentElement);break;case 5:case 6:case 4:case 17:break;default:throw Error(n(163))}}catch(Te){Dt(d,d.return,Te)}if(c=d.sibling,c!==null){c.return=d.return,Be=c;break}Be=d.return}return Ue=f_,f_=!1,Ue}function Yc(c,d,y){var k=d.updateQueue;if(k=k!==null?k.lastEffect:null,k!==null){var E=k=k.next;do{if((E.tag&c)===c){var $=E.destroy;E.destroy=void 0,$!==void 0&&ry(d,y,$)}E=E.next}while(E!==k)}}function jh(c,d){if(d=d.updateQueue,d=d!==null?d.lastEffect:null,d!==null){var y=d=d.next;do{if((y.tag&c)===c){var k=y.create;y.destroy=k()}y=y.next}while(y!==d)}}function ay(c){var d=c.ref;if(d!==null){var y=c.stateNode;switch(c.tag){case 5:c=y;break;default:c=y}typeof d=="function"?d(c):d.current=c}}function p_(c){var d=c.alternate;d!==null&&(c.alternate=null,p_(d)),c.child=null,c.deletions=null,c.sibling=null,c.tag===5&&(d=c.stateNode,d!==null&&(delete d[or],delete d[Dc],delete d[bg],delete d[OB],delete d[PB])),c.stateNode=null,c.return=null,c.dependencies=null,c.memoizedProps=null,c.memoizedState=null,c.pendingProps=null,c.stateNode=null,c.updateQueue=null}function m_(c){return c.tag===5||c.tag===3||c.tag===4}function g_(c){e:for(;;){for(;c.sibling===null;){if(c.return===null||m_(c.return))return null;c=c.return}for(c.sibling.return=c.return,c=c.sibling;c.tag!==5&&c.tag!==6&&c.tag!==18;){if(c.flags&2||c.child===null||c.tag===4)continue e;c.child.return=c,c=c.child}if(!(c.flags&2))return c.stateNode}}function oy(c,d,y){var k=c.tag;if(k===5||k===6)c=c.stateNode,d?y.nodeType===8?y.parentNode.insertBefore(c,d):y.insertBefore(c,d):(y.nodeType===8?(d=y.parentNode,d.insertBefore(c,y)):(d=y,d.appendChild(c)),y=y._reactRootContainer,y!=null||d.onclick!==null||(d.onclick=eh));else if(k!==4&&(c=c.child,c!==null))for(oy(c,d,y),c=c.sibling;c!==null;)oy(c,d,y),c=c.sibling}function iy(c,d,y){var k=c.tag;if(k===5||k===6)c=c.stateNode,d?y.insertBefore(c,d):y.appendChild(c);else if(k!==4&&(c=c.child,c!==null))for(iy(c,d,y),c=c.sibling;c!==null;)iy(c,d,y),c=c.sibling}var on=null,Fs=!1;function $a(c,d,y){for(y=y.child;y!==null;)y_(c,d,y),y=y.sibling}function y_(c,d,y){if(dn&&typeof dn.onCommitFiberUnmount=="function")try{dn.onCommitFiberUnmount(Rs,y)}catch{}switch(y.tag){case 5:gn||el(y,d);case 6:var k=on,E=Fs;on=null,$a(c,d,y),on=k,Fs=E,on!==null&&(Fs?(c=on,y=y.stateNode,c.nodeType===8?c.parentNode.removeChild(y):c.removeChild(y)):on.removeChild(y.stateNode));break;case 18:on!==null&&(Fs?(c=on,y=y.stateNode,c.nodeType===8?vg(c.parentNode,y):c.nodeType===1&&vg(c,y),ko(c)):vg(on,y.stateNode));break;case 4:k=on,E=Fs,on=y.stateNode.containerInfo,Fs=!0,$a(c,d,y),on=k,Fs=E;break;case 0:case 11:case 14:case 15:if(!gn&&(k=y.updateQueue,k!==null&&(k=k.lastEffect,k!==null))){E=k=k.next;do{var $=E,G=$.destroy;$=$.tag,G!==void 0&&(($&2)!==0||($&4)!==0)&&ry(y,d,G),E=E.next}while(E!==k)}$a(c,d,y);break;case 1:if(!gn&&(el(y,d),k=y.stateNode,typeof k.componentWillUnmount=="function"))try{k.props=y.memoizedProps,k.state=y.memoizedState,k.componentWillUnmount()}catch(ee){Dt(y,d,ee)}$a(c,d,y);break;case 21:$a(c,d,y);break;case 22:y.mode&1?(gn=(k=gn)||y.memoizedState!==null,$a(c,d,y),gn=k):$a(c,d,y);break;default:$a(c,d,y)}}function w_(c){var d=c.updateQueue;if(d!==null){c.updateQueue=null;var y=c.stateNode;y===null&&(y=c.stateNode=new QB),d.forEach(function(k){var E=cq.bind(null,c,k);y.has(k)||(y.add(k),k.then(E,E))})}}function Bs(c,d){var y=d.deletions;if(y!==null)for(var k=0;k<y.length;k++){var E=y[k];try{var $=c,G=d,ee=G;e:for(;ee!==null;){switch(ee.tag){case 5:on=ee.stateNode,Fs=!1;break e;case 3:on=ee.stateNode.containerInfo,Fs=!0;break e;case 4:on=ee.stateNode.containerInfo,Fs=!0;break e}ee=ee.return}if(on===null)throw Error(n(160));y_($,G,E),on=null,Fs=!1;var ne=E.alternate;ne!==null&&(ne.return=null),E.return=null}catch(ue){Dt(E,d,ue)}}if(d.subtreeFlags&12854)for(d=d.child;d!==null;)x_(d,c),d=d.sibling}function x_(c,d){var y=c.alternate,k=c.flags;switch(c.tag){case 0:case 11:case 14:case 15:if(Bs(d,c),cr(c),k&4){try{Yc(3,c,c.return),jh(3,c)}catch(ze){Dt(c,c.return,ze)}try{Yc(5,c,c.return)}catch(ze){Dt(c,c.return,ze)}}break;case 1:Bs(d,c),cr(c),k&512&&y!==null&&el(y,y.return);break;case 5:if(Bs(d,c),cr(c),k&512&&y!==null&&el(y,y.return),c.flags&32){var E=c.stateNode;try{rt(E,"")}catch(ze){Dt(c,c.return,ze)}}if(k&4&&(E=c.stateNode,E!=null)){var $=c.memoizedProps,G=y!==null?y.memoizedProps:$,ee=c.type,ne=c.updateQueue;if(c.updateQueue=null,ne!==null)try{ee==="input"&&$.type==="radio"&&$.name!=null&&Le(E,$),fe(ee,G);var ue=fe(ee,$);for(G=0;G<ne.length;G+=2){var Se=ne[G],Ce=ne[G+1];Se==="style"?Ae(E,Ce):Se==="dangerouslySetInnerHTML"?Re(E,Ce):Se==="children"?rt(E,Ce):S(E,Se,Ce,ue)}switch(ee){case"input":ge(E,$);break;case"textarea":We(E,$);break;case"select":var Ne=E._wrapperState.wasMultiple;E._wrapperState.wasMultiple=!!$.multiple;var Pe=$.value;Pe!=null?xe(E,!!$.multiple,Pe,!1):Ne!==!!$.multiple&&($.defaultValue!=null?xe(E,!!$.multiple,$.defaultValue,!0):xe(E,!!$.multiple,$.multiple?[]:"",!1))}E[Dc]=$}catch(ze){Dt(c,c.return,ze)}}break;case 6:if(Bs(d,c),cr(c),k&4){if(c.stateNode===null)throw Error(n(162));E=c.stateNode,$=c.memoizedProps;try{E.nodeValue=$}catch(ze){Dt(c,c.return,ze)}}break;case 3:if(Bs(d,c),cr(c),k&4&&y!==null&&y.memoizedState.isDehydrated)try{ko(d.containerInfo)}catch(ze){Dt(c,c.return,ze)}break;case 4:Bs(d,c),cr(c);break;case 13:Bs(d,c),cr(c),E=c.child,E.flags&8192&&($=E.memoizedState!==null,E.stateNode.isHidden=$,!$||E.alternate!==null&&E.alternate.memoizedState!==null||(uy=xt())),k&4&&w_(c);break;case 22:if(Se=y!==null&&y.memoizedState!==null,c.mode&1?(gn=(ue=gn)||Se,Bs(d,c),gn=ue):Bs(d,c),cr(c),k&8192){if(ue=c.memoizedState!==null,(c.stateNode.isHidden=ue)&&!Se&&(c.mode&1)!==0)for(Be=c,Se=c.child;Se!==null;){for(Ce=Be=Se;Be!==null;){switch(Ne=Be,Pe=Ne.child,Ne.tag){case 0:case 11:case 14:case 15:Yc(4,Ne,Ne.return);break;case 1:el(Ne,Ne.return);var Ue=Ne.stateNode;if(typeof Ue.componentWillUnmount=="function"){k=Ne,y=Ne.return;try{d=k,Ue.props=d.memoizedProps,Ue.state=d.memoizedState,Ue.componentWillUnmount()}catch(ze){Dt(k,y,ze)}}break;case 5:el(Ne,Ne.return);break;case 22:if(Ne.memoizedState!==null){k_(Ce);continue}}Pe!==null?(Pe.return=Ne,Be=Pe):k_(Ce)}Se=Se.sibling}e:for(Se=null,Ce=c;;){if(Ce.tag===5){if(Se===null){Se=Ce;try{E=Ce.stateNode,ue?($=E.style,typeof $.setProperty=="function"?$.setProperty("display","none","important"):$.display="none"):(ee=Ce.stateNode,ne=Ce.memoizedProps.style,G=ne!=null&&ne.hasOwnProperty("display")?ne.display:null,ee.style.display=ke("display",G))}catch(ze){Dt(c,c.return,ze)}}}else if(Ce.tag===6){if(Se===null)try{Ce.stateNode.nodeValue=ue?"":Ce.memoizedProps}catch(ze){Dt(c,c.return,ze)}}else if((Ce.tag!==22&&Ce.tag!==23||Ce.memoizedState===null||Ce===c)&&Ce.child!==null){Ce.child.return=Ce,Ce=Ce.child;continue}if(Ce===c)break e;for(;Ce.sibling===null;){if(Ce.return===null||Ce.return===c)break e;Se===Ce&&(Se=null),Ce=Ce.return}Se===Ce&&(Se=null),Ce.sibling.return=Ce.return,Ce=Ce.sibling}}break;case 19:Bs(d,c),cr(c),k&4&&w_(c);break;case 21:break;default:Bs(d,c),cr(c)}}function cr(c){var d=c.flags;if(d&2){try{e:{for(var y=c.return;y!==null;){if(m_(y)){var k=y;break e}y=y.return}throw Error(n(160))}switch(k.tag){case 5:var E=k.stateNode;k.flags&32&&(rt(E,""),k.flags&=-33);var $=g_(c);iy(c,$,E);break;case 3:case 4:var G=k.stateNode.containerInfo,ee=g_(c);oy(c,ee,G);break;default:throw Error(n(161))}}catch(ne){Dt(c,c.return,ne)}c.flags&=-3}d&4096&&(c.flags&=-4097)}function tq(c,d,y){Be=c,v_(c)}function v_(c,d,y){for(var k=(c.mode&1)!==0;Be!==null;){var E=Be,$=E.child;if(E.tag===22&&k){var G=E.memoizedState!==null||kh;if(!G){var ee=E.alternate,ne=ee!==null&&ee.memoizedState!==null||gn;ee=kh;var ue=gn;if(kh=G,(gn=ne)&&!ue)for(Be=E;Be!==null;)G=Be,ne=G.child,G.tag===22&&G.memoizedState!==null?j_(E):ne!==null?(ne.return=G,Be=ne):j_(E);for(;$!==null;)Be=$,v_($),$=$.sibling;Be=E,kh=ee,gn=ue}b_(c)}else(E.subtreeFlags&8772)!==0&&$!==null?($.return=E,Be=$):b_(c)}}function b_(c){for(;Be!==null;){var d=Be;if((d.flags&8772)!==0){var y=d.alternate;try{if((d.flags&8772)!==0)switch(d.tag){case 0:case 11:case 15:gn||jh(5,d);break;case 1:var k=d.stateNode;if(d.flags&4&&!gn)if(y===null)k.componentDidMount();else{var E=d.elementType===d.type?y.memoizedProps:Ds(d.type,y.memoizedProps);k.componentDidUpdate(E,y.memoizedState,k.__reactInternalSnapshotBeforeUpdate)}var $=d.updateQueue;$!==null&&kC(d,$,k);break;case 3:var G=d.updateQueue;if(G!==null){if(y=null,d.child!==null)switch(d.child.tag){case 5:y=d.child.stateNode;break;case 1:y=d.child.stateNode}kC(d,G,y)}break;case 5:var ee=d.stateNode;if(y===null&&d.flags&4){y=ee;var ne=d.memoizedProps;switch(d.type){case"button":case"input":case"select":case"textarea":ne.autoFocus&&y.focus();break;case"img":ne.src&&(y.src=ne.src)}}break;case 6:break;case 4:break;case 12:break;case 13:if(d.memoizedState===null){var ue=d.alternate;if(ue!==null){var Se=ue.memoizedState;if(Se!==null){var Ce=Se.dehydrated;Ce!==null&&ko(Ce)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}gn||d.flags&512&&ay(d)}catch(Ne){Dt(d,d.return,Ne)}}if(d===c){Be=null;break}if(y=d.sibling,y!==null){y.return=d.return,Be=y;break}Be=d.return}}function k_(c){for(;Be!==null;){var d=Be;if(d===c){Be=null;break}var y=d.sibling;if(y!==null){y.return=d.return,Be=y;break}Be=d.return}}function j_(c){for(;Be!==null;){var d=Be;try{switch(d.tag){case 0:case 11:case 15:var y=d.return;try{jh(4,d)}catch(ne){Dt(d,y,ne)}break;case 1:var k=d.stateNode;if(typeof k.componentDidMount=="function"){var E=d.return;try{k.componentDidMount()}catch(ne){Dt(d,E,ne)}}var $=d.return;try{ay(d)}catch(ne){Dt(d,$,ne)}break;case 5:var G=d.return;try{ay(d)}catch(ne){Dt(d,G,ne)}}}catch(ne){Dt(d,d.return,ne)}if(d===c){Be=null;break}var ee=d.sibling;if(ee!==null){ee.return=d.return,Be=ee;break}Be=d.return}}var nq=Math.ceil,Nh=C.ReactCurrentDispatcher,ly=C.ReactCurrentOwner,us=C.ReactCurrentBatchConfig,dt=0,tn=null,Ht=null,ln=0,Yn=0,tl=Ea(0),Kt=0,Xc=null,Do=0,Sh=0,cy=0,Zc=null,$n=null,uy=0,nl=1/0,Kr=null,Ch=!1,dy=null,La=null,_h=!1,Ia=null,Eh=0,Jc=0,hy=null,Th=-1,Ah=0;function kn(){return(dt&6)!==0?xt():Th!==-1?Th:Th=xt()}function Oa(c){return(c.mode&1)===0?1:(dt&2)!==0&&ln!==0?ln&-ln:FB.transition!==null?(Ah===0&&(Ah=sr()),Ah):(c=at,c!==0||(c=window.event,c=c===void 0?16:vc(c.type)),c)}function qs(c,d,y,k){if(50<Jc)throw Jc=0,hy=null,Error(n(185));ss(c,y,k),((dt&2)===0||c!==tn)&&(c===tn&&((dt&2)===0&&(Sh|=y),Kt===4&&Pa(c,ln)),Ln(c,k),y===1&&dt===0&&(d.mode&1)===0&&(nl=xt()+500,rh&&Aa()))}function Ln(c,d){var y=c.callbackNode;pt(c,d);var k=we(c,c===tn?ln:0);if(k===0)y!==null&&Er(y),c.callbackNode=null,c.callbackPriority=0;else if(d=k&-k,c.callbackPriority!==d){if(y!=null&&Er(y),d===1)c.tag===0?DB(S_.bind(null,c)):uC(S_.bind(null,c)),LB(function(){(dt&6)===0&&Aa()}),y=null;else{switch(yo(k)){case 1:y=As;break;case 4:y=wa;break;case 16:y=nr;break;case 536870912:y=Ar;break;default:y=nr}y=$_(y,N_.bind(null,c))}c.callbackPriority=d,c.callbackNode=y}}function N_(c,d){if(Th=-1,Ah=0,(dt&6)!==0)throw Error(n(327));var y=c.callbackNode;if(sl()&&c.callbackNode!==y)return null;var k=we(c,c===tn?ln:0);if(k===0)return null;if((k&30)!==0||(k&c.expiredLanes)!==0||d)d=Rh(c,k);else{d=k;var E=dt;dt|=2;var $=__();(tn!==c||ln!==d)&&(Kr=null,nl=xt()+500,Bo(c,d));do try{aq();break}catch(ee){C_(c,ee)}while(!0);Ag(),Nh.current=$,dt=E,Ht!==null?d=0:(tn=null,ln=0,d=Kt)}if(d!==0){if(d===2&&(E=Et(c),E!==0&&(k=E,d=fy(c,E))),d===1)throw y=Xc,Bo(c,0),Pa(c,k),Ln(c,xt()),y;if(d===6)Pa(c,k);else{if(E=c.current.alternate,(k&30)===0&&!sq(E)&&(d=Rh(c,k),d===2&&($=Et(c),$!==0&&(k=$,d=fy(c,$))),d===1))throw y=Xc,Bo(c,0),Pa(c,k),Ln(c,xt()),y;switch(c.finishedWork=E,c.finishedLanes=k,d){case 0:case 1:throw Error(n(345));case 2:qo(c,$n,Kr);break;case 3:if(Pa(c,k),(k&130023424)===k&&(d=uy+500-xt(),10<d)){if(we(c,0)!==0)break;if(E=c.suspendedLanes,(E&k)!==k){kn(),c.pingedLanes|=c.suspendedLanes&E;break}c.timeoutHandle=xg(qo.bind(null,c,$n,Kr),d);break}qo(c,$n,Kr);break;case 4:if(Pa(c,k),(k&4194240)===k)break;for(d=c.eventTimes,E=-1;0<k;){var G=31-hn(k);$=1<<G,G=d[G],G>E&&(E=G),k&=~$}if(k=E,k=xt()-k,k=(120>k?120:480>k?480:1080>k?1080:1920>k?1920:3e3>k?3e3:4320>k?4320:1960*nq(k/1960))-k,10<k){c.timeoutHandle=xg(qo.bind(null,c,$n,Kr),k);break}qo(c,$n,Kr);break;case 5:qo(c,$n,Kr);break;default:throw Error(n(329))}}}return Ln(c,xt()),c.callbackNode===y?N_.bind(null,c):null}function fy(c,d){var y=Zc;return c.current.memoizedState.isDehydrated&&(Bo(c,d).flags|=256),c=Rh(c,d),c!==2&&(d=$n,$n=y,d!==null&&py(d)),c}function py(c){$n===null?$n=c:$n.push.apply($n,c)}function sq(c){for(var d=c;;){if(d.flags&16384){var y=d.updateQueue;if(y!==null&&(y=y.stores,y!==null))for(var k=0;k<y.length;k++){var E=y[k],$=E.getSnapshot;E=E.value;try{if(!Os($(),E))return!1}catch{return!1}}}if(y=d.child,d.subtreeFlags&16384&&y!==null)y.return=d,d=y;else{if(d===c)break;for(;d.sibling===null;){if(d.return===null||d.return===c)return!0;d=d.return}d.sibling.return=d.return,d=d.sibling}}return!0}function Pa(c,d){for(d&=~cy,d&=~Sh,c.suspendedLanes|=d,c.pingedLanes&=~d,c=c.expirationTimes;0<d;){var y=31-hn(d),k=1<<y;c[y]=-1,d&=~k}}function S_(c){if((dt&6)!==0)throw Error(n(327));sl();var d=we(c,0);if((d&1)===0)return Ln(c,xt()),null;var y=Rh(c,d);if(c.tag!==0&&y===2){var k=Et(c);k!==0&&(d=k,y=fy(c,k))}if(y===1)throw y=Xc,Bo(c,0),Pa(c,d),Ln(c,xt()),y;if(y===6)throw Error(n(345));return c.finishedWork=c.current.alternate,c.finishedLanes=d,qo(c,$n,Kr),Ln(c,xt()),null}function my(c,d){var y=dt;dt|=1;try{return c(d)}finally{dt=y,dt===0&&(nl=xt()+500,rh&&Aa())}}function Fo(c){Ia!==null&&Ia.tag===0&&(dt&6)===0&&sl();var d=dt;dt|=1;var y=us.transition,k=at;try{if(us.transition=null,at=1,c)return c()}finally{at=k,us.transition=y,dt=d,(dt&6)===0&&Aa()}}function gy(){Yn=tl.current,At(tl)}function Bo(c,d){c.finishedWork=null,c.finishedLanes=0;var y=c.timeoutHandle;if(y!==-1&&(c.timeoutHandle=-1,$B(y)),Ht!==null)for(y=Ht.return;y!==null;){var k=y;switch(Sg(k),k.tag){case 1:k=k.type.childContextTypes,k!=null&&nh();break;case 3:Ji(),At(An),At(fn),Dg();break;case 5:Og(k);break;case 4:Ji();break;case 13:At(It);break;case 19:At(It);break;case 10:Rg(k.type._context);break;case 22:case 23:gy()}y=y.return}if(tn=c,Ht=c=Da(c.current,null),ln=Yn=d,Kt=0,Xc=null,cy=Sh=Do=0,$n=Zc=null,Io!==null){for(d=0;d<Io.length;d++)if(y=Io[d],k=y.interleaved,k!==null){y.interleaved=null;var E=k.next,$=y.pending;if($!==null){var G=$.next;$.next=E,k.next=G}y.pending=k}Io=null}return c}function C_(c,d){do{var y=Ht;try{if(Ag(),ph.current=wh,mh){for(var k=Ot.memoizedState;k!==null;){var E=k.queue;E!==null&&(E.pending=null),k=k.next}mh=!1}if(Po=0,en=Gt=Ot=null,Hc=!1,zc=0,ly.current=null,y===null||y.return===null){Kt=1,Xc=d,Ht=null;break}e:{var $=c,G=y.return,ee=y,ne=d;if(d=ln,ee.flags|=32768,ne!==null&&typeof ne=="object"&&typeof ne.then=="function"){var ue=ne,Se=ee,Ce=Se.tag;if((Se.mode&1)===0&&(Ce===0||Ce===11||Ce===15)){var Ne=Se.alternate;Ne?(Se.updateQueue=Ne.updateQueue,Se.memoizedState=Ne.memoizedState,Se.lanes=Ne.lanes):(Se.updateQueue=null,Se.memoizedState=null)}var Pe=ZC(G);if(Pe!==null){Pe.flags&=-257,JC(Pe,G,ee,$,d),Pe.mode&1&&XC($,ue,d),d=Pe,ne=ue;var Ue=d.updateQueue;if(Ue===null){var ze=new Set;ze.add(ne),d.updateQueue=ze}else Ue.add(ne);break e}else{if((d&1)===0){XC($,ue,d),yy();break e}ne=Error(n(426))}}else if(Rt&&ee.mode&1){var Ut=ZC(G);if(Ut!==null){(Ut.flags&65536)===0&&(Ut.flags|=256),JC(Ut,G,ee,$,d),Eg(Qi(ne,ee));break e}}$=ne=Qi(ne,ee),Kt!==4&&(Kt=2),Zc===null?Zc=[$]:Zc.push($),$=G;do{switch($.tag){case 3:$.flags|=65536,d&=-d,$.lanes|=d;var ie=KC($,ne,d);bC($,ie);break e;case 1:ee=ne;var ae=$.type,ce=$.stateNode;if(($.flags&128)===0&&(typeof ae.getDerivedStateFromError=="function"||ce!==null&&typeof ce.componentDidCatch=="function"&&(La===null||!La.has(ce)))){$.flags|=65536,d&=-d,$.lanes|=d;var Te=YC($,ee,d);bC($,Te);break e}}$=$.return}while($!==null)}T_(y)}catch(Ge){d=Ge,Ht===y&&y!==null&&(Ht=y=y.return);continue}break}while(!0)}function __(){var c=Nh.current;return Nh.current=wh,c===null?wh:c}function yy(){(Kt===0||Kt===3||Kt===2)&&(Kt=4),tn===null||(Do&268435455)===0&&(Sh&268435455)===0||Pa(tn,ln)}function Rh(c,d){var y=dt;dt|=2;var k=__();(tn!==c||ln!==d)&&(Kr=null,Bo(c,d));do try{rq();break}catch(E){C_(c,E)}while(!0);if(Ag(),dt=y,Nh.current=k,Ht!==null)throw Error(n(261));return tn=null,ln=0,Kt}function rq(){for(;Ht!==null;)E_(Ht)}function aq(){for(;Ht!==null&&!Ts();)E_(Ht)}function E_(c){var d=M_(c.alternate,c,Yn);c.memoizedProps=c.pendingProps,d===null?T_(c):Ht=d,ly.current=null}function T_(c){var d=c;do{var y=d.alternate;if(c=d.return,(d.flags&32768)===0){if(y=ZB(y,d,Yn),y!==null){Ht=y;return}}else{if(y=JB(y,d),y!==null){y.flags&=32767,Ht=y;return}if(c!==null)c.flags|=32768,c.subtreeFlags=0,c.deletions=null;else{Kt=6,Ht=null;return}}if(d=d.sibling,d!==null){Ht=d;return}Ht=d=c}while(d!==null);Kt===0&&(Kt=5)}function qo(c,d,y){var k=at,E=us.transition;try{us.transition=null,at=1,oq(c,d,y,k)}finally{us.transition=E,at=k}return null}function oq(c,d,y,k){do sl();while(Ia!==null);if((dt&6)!==0)throw Error(n(327));y=c.finishedWork;var E=c.finishedLanes;if(y===null)return null;if(c.finishedWork=null,c.finishedLanes=0,y===c.current)throw Error(n(177));c.callbackNode=null,c.callbackPriority=0;var $=y.lanes|y.childLanes;if(fc(c,$),c===tn&&(Ht=tn=null,ln=0),(y.subtreeFlags&2064)===0&&(y.flags&2064)===0||_h||(_h=!0,$_(nr,function(){return sl(),null})),$=(y.flags&15990)!==0,(y.subtreeFlags&15990)!==0||$){$=us.transition,us.transition=null;var G=at;at=1;var ee=dt;dt|=4,ly.current=null,eq(c,y),x_(y,c),CB(yg),jo=!!gg,yg=gg=null,c.current=y,tq(y),ga(),dt=ee,at=G,us.transition=$}else c.current=y;if(_h&&(_h=!1,Ia=c,Eh=E),$=c.pendingLanes,$===0&&(La=null),Lt(y.stateNode),Ln(c,xt()),d!==null)for(k=c.onRecoverableError,y=0;y<d.length;y++)E=d[y],k(E.value,{componentStack:E.stack,digest:E.digest});if(Ch)throw Ch=!1,c=dy,dy=null,c;return(Eh&1)!==0&&c.tag!==0&&sl(),$=c.pendingLanes,($&1)!==0?c===hy?Jc++:(Jc=0,hy=c):Jc=0,Aa(),null}function sl(){if(Ia!==null){var c=yo(Eh),d=us.transition,y=at;try{if(us.transition=null,at=16>c?16:c,Ia===null)var k=!1;else{if(c=Ia,Ia=null,Eh=0,(dt&6)!==0)throw Error(n(331));var E=dt;for(dt|=4,Be=c.current;Be!==null;){var $=Be,G=$.child;if((Be.flags&16)!==0){var ee=$.deletions;if(ee!==null){for(var ne=0;ne<ee.length;ne++){var ue=ee[ne];for(Be=ue;Be!==null;){var Se=Be;switch(Se.tag){case 0:case 11:case 15:Yc(8,Se,$)}var Ce=Se.child;if(Ce!==null)Ce.return=Se,Be=Ce;else for(;Be!==null;){Se=Be;var Ne=Se.sibling,Pe=Se.return;if(p_(Se),Se===ue){Be=null;break}if(Ne!==null){Ne.return=Pe,Be=Ne;break}Be=Pe}}}var Ue=$.alternate;if(Ue!==null){var ze=Ue.child;if(ze!==null){Ue.child=null;do{var Ut=ze.sibling;ze.sibling=null,ze=Ut}while(ze!==null)}}Be=$}}if(($.subtreeFlags&2064)!==0&&G!==null)G.return=$,Be=G;else e:for(;Be!==null;){if($=Be,($.flags&2048)!==0)switch($.tag){case 0:case 11:case 15:Yc(9,$,$.return)}var ie=$.sibling;if(ie!==null){ie.return=$.return,Be=ie;break e}Be=$.return}}var ae=c.current;for(Be=ae;Be!==null;){G=Be;var ce=G.child;if((G.subtreeFlags&2064)!==0&&ce!==null)ce.return=G,Be=ce;else e:for(G=ae;Be!==null;){if(ee=Be,(ee.flags&2048)!==0)try{switch(ee.tag){case 0:case 11:case 15:jh(9,ee)}}catch(Ge){Dt(ee,ee.return,Ge)}if(ee===G){Be=null;break e}var Te=ee.sibling;if(Te!==null){Te.return=ee.return,Be=Te;break e}Be=ee.return}}if(dt=E,Aa(),dn&&typeof dn.onPostCommitFiberRoot=="function")try{dn.onPostCommitFiberRoot(Rs,c)}catch{}k=!0}return k}finally{at=y,us.transition=d}}return!1}function A_(c,d,y){d=Qi(y,d),d=KC(c,d,1),c=Ma(c,d,1),d=kn(),c!==null&&(ss(c,1,d),Ln(c,d))}function Dt(c,d,y){if(c.tag===3)A_(c,c,y);else for(;d!==null;){if(d.tag===3){A_(d,c,y);break}else if(d.tag===1){var k=d.stateNode;if(typeof d.type.getDerivedStateFromError=="function"||typeof k.componentDidCatch=="function"&&(La===null||!La.has(k))){c=Qi(y,c),c=YC(d,c,1),d=Ma(d,c,1),c=kn(),d!==null&&(ss(d,1,c),Ln(d,c));break}}d=d.return}}function iq(c,d,y){var k=c.pingCache;k!==null&&k.delete(d),d=kn(),c.pingedLanes|=c.suspendedLanes&y,tn===c&&(ln&y)===y&&(Kt===4||Kt===3&&(ln&130023424)===ln&&500>xt()-uy?Bo(c,0):cy|=y),Ln(c,d)}function R_(c,d){d===0&&((c.mode&1)===0?d=1:(d=Rr,Rr<<=1,(Rr&130023424)===0&&(Rr=4194304)));var y=kn();c=zr(c,d),c!==null&&(ss(c,d,y),Ln(c,y))}function lq(c){var d=c.memoizedState,y=0;d!==null&&(y=d.retryLane),R_(c,y)}function cq(c,d){var y=0;switch(c.tag){case 13:var k=c.stateNode,E=c.memoizedState;E!==null&&(y=E.retryLane);break;case 19:k=c.stateNode;break;default:throw Error(n(314))}k!==null&&k.delete(d),R_(c,y)}var M_;M_=function(c,d,y){if(c!==null)if(c.memoizedProps!==d.pendingProps||An.current)Mn=!0;else{if((c.lanes&y)===0&&(d.flags&128)===0)return Mn=!1,XB(c,d,y);Mn=(c.flags&131072)!==0}else Mn=!1,Rt&&(d.flags&1048576)!==0&&dC(d,oh,d.index);switch(d.lanes=0,d.tag){case 2:var k=d.type;bh(c,d),c=d.pendingProps;var E=zi(d,fn.current);Zi(d,y),E=qg(null,d,k,c,E,y);var $=Ug();return d.flags|=1,typeof E=="object"&&E!==null&&typeof E.render=="function"&&E.$$typeof===void 0?(d.tag=1,d.memoizedState=null,d.updateQueue=null,Rn(k)?($=!0,sh(d)):$=!1,d.memoizedState=E.state!==null&&E.state!==void 0?E.state:null,Lg(d),E.updater=xh,d.stateNode=E,E._reactInternals=d,Kg(d,k,c,y),d=Jg(null,d,k,!0,$,y)):(d.tag=0,Rt&&$&&Ng(d),bn(null,d,E,y),d=d.child),d;case 16:k=d.elementType;e:{switch(bh(c,d),c=d.pendingProps,E=k._init,k=E(k._payload),d.type=k,E=d.tag=dq(k),c=Ds(k,c),E){case 0:d=Zg(null,d,k,c,y);break e;case 1:d=r_(null,d,k,c,y);break e;case 11:d=QC(null,d,k,c,y);break e;case 14:d=e_(null,d,k,Ds(k.type,c),y);break e}throw Error(n(306,k,""))}return d;case 0:return k=d.type,E=d.pendingProps,E=d.elementType===k?E:Ds(k,E),Zg(c,d,k,E,y);case 1:return k=d.type,E=d.pendingProps,E=d.elementType===k?E:Ds(k,E),r_(c,d,k,E,y);case 3:e:{if(a_(d),c===null)throw Error(n(387));k=d.pendingProps,$=d.memoizedState,E=$.element,vC(c,d),hh(d,k,null,y);var G=d.memoizedState;if(k=G.element,$.isDehydrated)if($={element:k,isDehydrated:!1,cache:G.cache,pendingSuspenseBoundaries:G.pendingSuspenseBoundaries,transitions:G.transitions},d.updateQueue.baseState=$,d.memoizedState=$,d.flags&256){E=Qi(Error(n(423)),d),d=o_(c,d,k,y,E);break e}else if(k!==E){E=Qi(Error(n(424)),d),d=o_(c,d,k,y,E);break e}else for(Kn=_a(d.stateNode.containerInfo.firstChild),Gn=d,Rt=!0,Ps=null,y=wC(d,null,k,y),d.child=y;y;)y.flags=y.flags&-3|4096,y=y.sibling;else{if(Ki(),k===E){d=Gr(c,d,y);break e}bn(c,d,k,y)}d=d.child}return d;case 5:return jC(d),c===null&&_g(d),k=d.type,E=d.pendingProps,$=c!==null?c.memoizedProps:null,G=E.children,wg(k,E)?G=null:$!==null&&wg(k,$)&&(d.flags|=32),s_(c,d),bn(c,d,G,y),d.child;case 6:return c===null&&_g(d),null;case 13:return i_(c,d,y);case 4:return Ig(d,d.stateNode.containerInfo),k=d.pendingProps,c===null?d.child=Yi(d,null,k,y):bn(c,d,k,y),d.child;case 11:return k=d.type,E=d.pendingProps,E=d.elementType===k?E:Ds(k,E),QC(c,d,k,E,y);case 7:return bn(c,d,d.pendingProps,y),d.child;case 8:return bn(c,d,d.pendingProps.children,y),d.child;case 12:return bn(c,d,d.pendingProps.children,y),d.child;case 10:e:{if(k=d.type._context,E=d.pendingProps,$=d.memoizedProps,G=E.value,St(ch,k._currentValue),k._currentValue=G,$!==null)if(Os($.value,G)){if($.children===E.children&&!An.current){d=Gr(c,d,y);break e}}else for($=d.child,$!==null&&($.return=d);$!==null;){var ee=$.dependencies;if(ee!==null){G=$.child;for(var ne=ee.firstContext;ne!==null;){if(ne.context===k){if($.tag===1){ne=Vr(-1,y&-y),ne.tag=2;var ue=$.updateQueue;if(ue!==null){ue=ue.shared;var Se=ue.pending;Se===null?ne.next=ne:(ne.next=Se.next,Se.next=ne),ue.pending=ne}}$.lanes|=y,ne=$.alternate,ne!==null&&(ne.lanes|=y),Mg($.return,y,d),ee.lanes|=y;break}ne=ne.next}}else if($.tag===10)G=$.type===d.type?null:$.child;else if($.tag===18){if(G=$.return,G===null)throw Error(n(341));G.lanes|=y,ee=G.alternate,ee!==null&&(ee.lanes|=y),Mg(G,y,d),G=$.sibling}else G=$.child;if(G!==null)G.return=$;else for(G=$;G!==null;){if(G===d){G=null;break}if($=G.sibling,$!==null){$.return=G.return,G=$;break}G=G.return}$=G}bn(c,d,E.children,y),d=d.child}return d;case 9:return E=d.type,k=d.pendingProps.children,Zi(d,y),E=ls(E),k=k(E),d.flags|=1,bn(c,d,k,y),d.child;case 14:return k=d.type,E=Ds(k,d.pendingProps),E=Ds(k.type,E),e_(c,d,k,E,y);case 15:return t_(c,d,d.type,d.pendingProps,y);case 17:return k=d.type,E=d.pendingProps,E=d.elementType===k?E:Ds(k,E),bh(c,d),d.tag=1,Rn(k)?(c=!0,sh(d)):c=!1,Zi(d,y),VC(d,k,E),Kg(d,k,E,y),Jg(null,d,k,!0,c,y);case 19:return c_(c,d,y);case 22:return n_(c,d,y)}throw Error(n(156,d.tag))};function $_(c,d){return _r(c,d)}function uq(c,d,y,k){this.tag=c,this.key=y,this.sibling=this.child=this.return=this.stateNode=this.type=this.elementType=null,this.index=0,this.ref=null,this.pendingProps=d,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=k,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ds(c,d,y,k){return new uq(c,d,y,k)}function wy(c){return c=c.prototype,!(!c||!c.isReactComponent)}function dq(c){if(typeof c=="function")return wy(c)?1:0;if(c!=null){if(c=c.$$typeof,c===A)return 11;if(c===F)return 14}return 2}function Da(c,d){var y=c.alternate;return y===null?(y=ds(c.tag,d,c.key,c.mode),y.elementType=c.elementType,y.type=c.type,y.stateNode=c.stateNode,y.alternate=c,c.alternate=y):(y.pendingProps=d,y.type=c.type,y.flags=0,y.subtreeFlags=0,y.deletions=null),y.flags=c.flags&14680064,y.childLanes=c.childLanes,y.lanes=c.lanes,y.child=c.child,y.memoizedProps=c.memoizedProps,y.memoizedState=c.memoizedState,y.updateQueue=c.updateQueue,d=c.dependencies,y.dependencies=d===null?null:{lanes:d.lanes,firstContext:d.firstContext},y.sibling=c.sibling,y.index=c.index,y.ref=c.ref,y}function Mh(c,d,y,k,E,$){var G=2;if(k=c,typeof c=="function")wy(c)&&(G=1);else if(typeof c=="string")G=5;else e:switch(c){case R:return Uo(y.children,E,$,d);case P:G=8,E|=8;break;case L:return c=ds(12,y,d,E|2),c.elementType=L,c.lanes=$,c;case q:return c=ds(13,y,d,E),c.elementType=q,c.lanes=$,c;case T:return c=ds(19,y,d,E),c.elementType=T,c.lanes=$,c;case K:return $h(y,E,$,d);default:if(typeof c=="object"&&c!==null)switch(c.$$typeof){case U:G=10;break e;case B:G=9;break e;case A:G=11;break e;case F:G=14;break e;case O:G=16,k=null;break e}throw Error(n(130,c==null?c:typeof c,""))}return d=ds(G,y,d,E),d.elementType=c,d.type=k,d.lanes=$,d}function Uo(c,d,y,k){return c=ds(7,c,k,d),c.lanes=y,c}function $h(c,d,y,k){return c=ds(22,c,k,d),c.elementType=K,c.lanes=y,c.stateNode={isHidden:!1},c}function xy(c,d,y){return c=ds(6,c,null,d),c.lanes=y,c}function vy(c,d,y){return d=ds(4,c.children!==null?c.children:[],c.key,d),d.lanes=y,d.stateNode={containerInfo:c.containerInfo,pendingChildren:null,implementation:c.implementation},d}function hq(c,d,y,k,E){this.tag=d,this.containerInfo=c,this.finishedWork=this.pingCache=this.current=this.pendingChildren=null,this.timeoutHandle=-1,this.callbackNode=this.pendingContext=this.context=null,this.callbackPriority=0,this.eventTimes=Mr(0),this.expirationTimes=Mr(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Mr(0),this.identifierPrefix=k,this.onRecoverableError=E,this.mutableSourceEagerHydrationData=null}function by(c,d,y,k,E,$,G,ee,ne){return c=new hq(c,d,y,ee,ne),d===1?(d=1,$===!0&&(d|=8)):d=0,$=ds(3,null,null,d),c.current=$,$.stateNode=c,$.memoizedState={element:k,isDehydrated:y,cache:null,transitions:null,pendingSuspenseBoundaries:null},Lg($),c}function fq(c,d,y){var k=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:M,key:k==null?null:""+k,children:c,containerInfo:d,implementation:y}}function L_(c){if(!c)return Ta;c=c._reactInternals;e:{if(xn(c)!==c||c.tag!==1)throw Error(n(170));var d=c;do{switch(d.tag){case 3:d=d.stateNode.context;break e;case 1:if(Rn(d.type)){d=d.stateNode.__reactInternalMemoizedMergedChildContext;break e}}d=d.return}while(d!==null);throw Error(n(171))}if(c.tag===1){var y=c.type;if(Rn(y))return lC(c,y,d)}return d}function I_(c,d,y,k,E,$,G,ee,ne){return c=by(y,k,!0,c,E,$,G,ee,ne),c.context=L_(null),y=c.current,k=kn(),E=Oa(y),$=Vr(k,E),$.callback=d??null,Ma(y,$,E),c.current.lanes=E,ss(c,E,k),Ln(c,k),c}function Lh(c,d,y,k){var E=d.current,$=kn(),G=Oa(E);return y=L_(y),d.context===null?d.context=y:d.pendingContext=y,d=Vr($,G),d.payload={element:c},k=k===void 0?null:k,k!==null&&(d.callback=k),c=Ma(E,d,G),c!==null&&(qs(c,E,G,$),dh(c,E,G)),G}function Ih(c){if(c=c.current,!c.child)return null;switch(c.child.tag){case 5:return c.child.stateNode;default:return c.child.stateNode}}function O_(c,d){if(c=c.memoizedState,c!==null&&c.dehydrated!==null){var y=c.retryLane;c.retryLane=y!==0&&y<d?y:d}}function ky(c,d){O_(c,d),(c=c.alternate)&&O_(c,d)}function pq(){return null}var P_=typeof reportError=="function"?reportError:function(c){console.error(c)};function jy(c){this._internalRoot=c}Oh.prototype.render=jy.prototype.render=function(c){var d=this._internalRoot;if(d===null)throw Error(n(409));Lh(c,d,null,null)},Oh.prototype.unmount=jy.prototype.unmount=function(){var c=this._internalRoot;if(c!==null){this._internalRoot=null;var d=c.containerInfo;Fo(function(){Lh(null,c,null,null)}),d[qr]=null}};function Oh(c){this._internalRoot=c}Oh.prototype.unstable_scheduleHydration=function(c){if(c){var d=$d();c={blockedOn:null,target:c,priority:d};for(var y=0;y<Ls.length&&d!==0&&d<Ls[y].priority;y++);Ls.splice(y,0,c),y===0&&Id(c)}};function Ny(c){return!(!c||c.nodeType!==1&&c.nodeType!==9&&c.nodeType!==11)}function Ph(c){return!(!c||c.nodeType!==1&&c.nodeType!==9&&c.nodeType!==11&&(c.nodeType!==8||c.nodeValue!==" react-mount-point-unstable "))}function D_(){}function mq(c,d,y,k,E){if(E){if(typeof k=="function"){var $=k;k=function(){var ue=Ih(G);$.call(ue)}}var G=I_(d,k,c,0,null,!1,!1,"",D_);return c._reactRootContainer=G,c[qr]=G.current,Oc(c.nodeType===8?c.parentNode:c),Fo(),G}for(;E=c.lastChild;)c.removeChild(E);if(typeof k=="function"){var ee=k;k=function(){var ue=Ih(ne);ee.call(ue)}}var ne=by(c,0,!1,null,null,!1,!1,"",D_);return c._reactRootContainer=ne,c[qr]=ne.current,Oc(c.nodeType===8?c.parentNode:c),Fo(function(){Lh(d,ne,y,k)}),ne}function Dh(c,d,y,k,E){var $=y._reactRootContainer;if($){var G=$;if(typeof E=="function"){var ee=E;E=function(){var ne=Ih(G);ee.call(ne)}}Lh(d,G,c,E)}else G=mq(y,d,c,E,k);return Ih(G)}wo=function(c){switch(c.tag){case 3:var d=c.stateNode;if(d.current.memoizedState.isDehydrated){var y=Vn(d.pendingLanes);y!==0&&($r(d,y|1),Ln(d,xt()),(dt&6)===0&&(nl=xt()+500,Aa()))}break;case 13:Fo(function(){var k=zr(c,1);if(k!==null){var E=kn();qs(k,c,1,E)}}),ky(c,1)}},pc=function(c){if(c.tag===13){var d=zr(c,134217728);if(d!==null){var y=kn();qs(d,c,134217728,y)}ky(c,134217728)}},mc=function(c){if(c.tag===13){var d=Oa(c),y=zr(c,d);if(y!==null){var k=kn();qs(y,c,d,k)}ky(c,d)}},$d=function(){return at},gc=function(c,d){var y=at;try{return at=c,d()}finally{at=y}},ot=function(c,d,y){switch(d){case"input":if(ge(c,y),d=y.name,y.type==="radio"&&d!=null){for(y=c;y.parentNode;)y=y.parentNode;for(y=y.querySelectorAll("input[name="+JSON.stringify(""+d)+'][type="radio"]'),d=0;d<y.length;d++){var k=y[d];if(k!==c&&k.form===c.form){var E=th(k);if(!E)throw Error(n(90));oe(k),ge(k,E)}}}break;case"textarea":We(c,y);break;case"select":d=y.value,d!=null&&xe(c,!!y.multiple,d,!1)}},Ss=my,Wn=Fo;var gq={usingClientEntryPoint:!1,Events:[Fc,Wi,th,Vt,er,my]},Qc={findFiberByHostInstance:Ro,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},yq={bundleType:Qc.bundleType,version:Qc.version,rendererPackageName:Qc.rendererPackageName,rendererConfig:Qc.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:C.ReactCurrentDispatcher,findHostInstanceByFiber:function(c){return c=ns(c),c===null?null:c.stateNode},findFiberByHostInstance:Qc.findFiberByHostInstance||pq,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 Fh=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!Fh.isDisabled&&Fh.supportsFiber)try{Rs=Fh.inject(yq),dn=Fh}catch{}}return In.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=gq,In.createPortal=function(c,d){var y=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Ny(d))throw Error(n(200));return fq(c,d,null,y)},In.createRoot=function(c,d){if(!Ny(c))throw Error(n(299));var y=!1,k="",E=P_;return d!=null&&(d.unstable_strictMode===!0&&(y=!0),d.identifierPrefix!==void 0&&(k=d.identifierPrefix),d.onRecoverableError!==void 0&&(E=d.onRecoverableError)),d=by(c,1,!1,null,null,y,!1,k,E),c[qr]=d.current,Oc(c.nodeType===8?c.parentNode:c),new jy(d)},In.findDOMNode=function(c){if(c==null)return null;if(c.nodeType===1)return c;var d=c._reactInternals;if(d===void 0)throw typeof c.render=="function"?Error(n(188)):(c=Object.keys(c).join(","),Error(n(268,c)));return c=ns(d),c=c===null?null:c.stateNode,c},In.flushSync=function(c){return Fo(c)},In.hydrate=function(c,d,y){if(!Ph(d))throw Error(n(200));return Dh(null,c,d,!0,y)},In.hydrateRoot=function(c,d,y){if(!Ny(c))throw Error(n(405));var k=y!=null&&y.hydratedSources||null,E=!1,$="",G=P_;if(y!=null&&(y.unstable_strictMode===!0&&(E=!0),y.identifierPrefix!==void 0&&($=y.identifierPrefix),y.onRecoverableError!==void 0&&(G=y.onRecoverableError)),d=I_(d,null,c,1,y??null,E,!1,$,G),c[qr]=d.current,Oc(c),k)for(c=0;c<k.length;c++)y=k[c],E=y._getVersion,E=E(y._source),d.mutableSourceEagerHydrationData==null?d.mutableSourceEagerHydrationData=[y,E]:d.mutableSourceEagerHydrationData.push(y,E);return new Oh(d)},In.render=function(c,d,y){if(!Ph(d))throw Error(n(200));return Dh(null,c,d,!1,y)},In.unmountComponentAtNode=function(c){if(!Ph(c))throw Error(n(40));return c._reactRootContainer?(Fo(function(){Dh(null,null,c,!1,function(){c._reactRootContainer=null,c[qr]=null})}),!0):!1},In.unstable_batchedUpdates=my,In.unstable_renderSubtreeIntoContainer=function(c,d,y,k){if(!Ph(y))throw Error(n(200));if(c==null||c._reactInternals===void 0)throw Error(n(38));return Dh(c,d,y,!1,k)},In.version="18.3.1-next-f1338f8080-20240426",In}var V_;function f3(){if(V_)return _y.exports;V_=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(),_y.exports=Cq(),_y.exports}var G_;function _q(){if(G_)return qh;G_=1;var e=f3();return qh.createRoot=e.createRoot,qh.hydrateRoot=e.hydrateRoot,qh}var Eq=_q(),g=ud();const me=$j(g);function un(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=un(e[n]))!==""&&(t+=(t&&" ")+s);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var Ay={exports:{}},Ry={},My={exports:{}},$y={};/**
|
|
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 K_;function Tq(){if(K_)return $y;K_=1;var e=ud();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 l(p,m){var w=m(),v=s({inst:{value:w,getSnapshot:m}}),j=v[0].inst,b=v[1];return o(function(){j.value=w,j.getSnapshot=m,u(j)&&b({inst:j})},[p,w,m]),a(function(){return u(j)&&b({inst:j}),p(function(){u(j)&&b({inst:j})})},[p]),i(w),w}function u(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:l;return $y.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:f,$y}var Y_;function Aq(){return Y_||(Y_=1,My.exports=Tq()),My.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 X_;function Rq(){if(X_)return Ry;X_=1;var e=ud(),t=Aq();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,l=e.useMemo,u=e.useDebugValue;return Ry.useSyncExternalStoreWithSelector=function(h,f,p,m,w){var v=o(null);if(v.current===null){var j={hasValue:!1,value:null};v.current=j}else j=v.current;v=l(function(){function N(M){if(!x){if(x=!0,S=M,M=m(M),w!==void 0&&j.hasValue){var R=j.value;if(w(R,M))return C=R}return C=M}if(R=C,s(S,M))return R;var P=m(M);return w!==void 0&&w(R,P)?(S=M,R):(S=M,C=P)}var x=!1,S,C,_=p===void 0?null:p;return[function(){return N(f())},_===null?void 0:function(){return N(_())}]},[f,p,m,w]);var b=a(h,v[0],v[1]);return i(function(){j.hasValue=!0,j.value=b},[b]),u(b),b},Ry}var Z_;function Mq(){return Z_||(Z_=1,Ay.exports=Rq()),Ay.exports}var $q=Mq();const Lq=$j($q),Iq={},J_=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,u={setState:s,getState:a,getInitialState:()=>h,subscribe:f=>(n.add(f),()=>n.delete(f)),destroy:()=>{(Iq?"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,u);return u},Oq=e=>e?J_(e):J_,{useDebugValue:Pq}=me,{useSyncExternalStoreWithSelector:Dq}=Lq,Fq=e=>e;function p3(e,t=Fq,n){const s=Dq(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return Pq(s),s}const Q_=(e,t)=>{const n=Oq(e),s=(a,o=t)=>p3(n,a,o);return Object.assign(s,n),s},Bq=(e,t)=>e?Q_(e,t):Q_;function Qt(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 qq={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 Nf(n)}function Nf(e){this._=e}function Uq(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}})}Nf.prototype=Pp.prototype={constructor:Nf,on:function(e,t){var n=this._,s=Uq(e+"",n),a,o=-1,i=s.length;if(arguments.length<2){for(;++o<i;)if((a=(e=s[o]).type)&&(a=Wq(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]=eE(n[a],e.name,t);else if(t==null)for(a in n)n[a]=eE(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 Nf(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 Wq(e,t){for(var n=0,s=e.length,a;n<s;++n)if((a=e[n]).name===t)return a.value}function eE(e,t,n){for(var s=0,a=e.length;s<a;++s)if(e[s].name===t){e[s]=qq,e=e.slice(0,s).concat(e.slice(s+1));break}return n!=null&&e.push({name:t,value:n}),e}var Q0="http://www.w3.org/1999/xhtml";const tE={svg:"http://www.w3.org/2000/svg",xhtml:Q0,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Dp(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),tE.hasOwnProperty(t)?{space:tE[t],local:e}:e}function Hq(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===Q0&&t.documentElement.namespaceURI===Q0?t.createElement(e):t.createElementNS(n,e)}}function zq(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function m3(e){var t=Dp(e);return(t.local?zq:Hq)(t)}function Vq(){}function Lj(e){return e==null?Vq:function(){return this.querySelector(e)}}function Gq(e){typeof e!="function"&&(e=Lj(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,l=s[a]=new Array(i),u,h,f=0;f<i;++f)(u=o[f])&&(h=e.call(u,u.__data__,f,o))&&("__data__"in u&&(h.__data__=u.__data__),l[f]=h);return new Qn(s,this._parents)}function Kq(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Yq(){return[]}function g3(e){return e==null?Yq:function(){return this.querySelectorAll(e)}}function Xq(e){return function(){return Kq(e.apply(this,arguments))}}function Zq(e){typeof e=="function"?e=Xq(e):e=g3(e);for(var t=this._groups,n=t.length,s=[],a=[],o=0;o<n;++o)for(var i=t[o],l=i.length,u,h=0;h<l;++h)(u=i[h])&&(s.push(e.call(u,u.__data__,h,i)),a.push(u));return new Qn(s,a)}function y3(e){return function(){return this.matches(e)}}function w3(e){return function(t){return t.matches(e)}}var Jq=Array.prototype.find;function Qq(e){return function(){return Jq.call(this.children,e)}}function eU(){return this.firstElementChild}function tU(e){return this.select(e==null?eU:Qq(typeof e=="function"?e:w3(e)))}var nU=Array.prototype.filter;function sU(){return Array.from(this.children)}function rU(e){return function(){return nU.call(this.children,e)}}function aU(e){return this.selectAll(e==null?sU:rU(typeof e=="function"?e:w3(e)))}function oU(e){typeof e!="function"&&(e=y3(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,l=s[a]=[],u,h=0;h<i;++h)(u=o[h])&&e.call(u,u.__data__,h,o)&&l.push(u);return new Qn(s,this._parents)}function x3(e){return new Array(e.length)}function iU(){return new Qn(this._enter||this._groups.map(x3),this._parents)}function Uf(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Uf.prototype={constructor:Uf,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 lU(e){return function(){return e}}function cU(e,t,n,s,a,o){for(var i=0,l,u=t.length,h=o.length;i<h;++i)(l=t[i])?(l.__data__=o[i],s[i]=l):n[i]=new Uf(e,o[i]);for(;i<u;++i)(l=t[i])&&(a[i]=l)}function uU(e,t,n,s,a,o,i){var l,u,h=new Map,f=t.length,p=o.length,m=new Array(f),w;for(l=0;l<f;++l)(u=t[l])&&(m[l]=w=i.call(u,u.__data__,l,t)+"",h.has(w)?a[l]=u:h.set(w,u));for(l=0;l<p;++l)w=i.call(e,o[l],l,o)+"",(u=h.get(w))?(s[l]=u,u.__data__=o[l],h.delete(w)):n[l]=new Uf(e,o[l]);for(l=0;l<f;++l)(u=t[l])&&h.get(m[l])===u&&(a[l]=u)}function dU(e){return e.__data__}function hU(e,t){if(!arguments.length)return Array.from(this,dU);var n=t?uU:cU,s=this._parents,a=this._groups;typeof e!="function"&&(e=lU(e));for(var o=a.length,i=new Array(o),l=new Array(o),u=new Array(o),h=0;h<o;++h){var f=s[h],p=a[h],m=p.length,w=fU(e.call(f,f&&f.__data__,h,s)),v=w.length,j=l[h]=new Array(v),b=i[h]=new Array(v),N=u[h]=new Array(m);n(f,p,j,b,N,w,t);for(var x=0,S=0,C,_;x<v;++x)if(C=j[x]){for(x>=S&&(S=x+1);!(_=b[S])&&++S<v;);C._next=_||null}}return i=new Qn(i,s),i._enter=l,i._exit=u,i}function fU(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function pU(){return new Qn(this._exit||this._groups.map(x3),this._parents)}function mU(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 gU(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),l=new Array(a),u=0;u<i;++u)for(var h=n[u],f=s[u],p=h.length,m=l[u]=new Array(p),w,v=0;v<p;++v)(w=h[v]||f[v])&&(m[v]=w);for(;u<a;++u)l[u]=n[u];return new Qn(l,this._parents)}function yU(){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 wU(e){e||(e=xU);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],l=i.length,u=a[o]=new Array(l),h,f=0;f<l;++f)(h=i[f])&&(u[f]=h);u.sort(t)}return new Qn(a,this._parents).order()}function xU(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function vU(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function bU(){return Array.from(this)}function kU(){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 jU(){let e=0;for(const t of this)++e;return e}function NU(){return!this.node()}function SU(e){for(var t=this._groups,n=0,s=t.length;n<s;++n)for(var a=t[n],o=0,i=a.length,l;o<i;++o)(l=a[o])&&e.call(l,l.__data__,o,a);return this}function CU(e){return function(){this.removeAttribute(e)}}function _U(e){return function(){this.removeAttributeNS(e.space,e.local)}}function EU(e,t){return function(){this.setAttribute(e,t)}}function TU(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function AU(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function RU(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 MU(e,t){var n=Dp(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?_U:CU:typeof t=="function"?n.local?RU:AU:n.local?TU:EU)(n,t))}function v3(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function $U(e){return function(){this.style.removeProperty(e)}}function LU(e,t,n){return function(){this.style.setProperty(e,t,n)}}function IU(e,t,n){return function(){var s=t.apply(this,arguments);s==null?this.style.removeProperty(e):this.style.setProperty(e,s,n)}}function OU(e,t,n){return arguments.length>1?this.each((t==null?$U:typeof t=="function"?IU:LU)(e,t,n??"")):ql(this.node(),e)}function ql(e,t){return e.style.getPropertyValue(t)||v3(e).getComputedStyle(e,null).getPropertyValue(t)}function PU(e){return function(){delete this[e]}}function DU(e,t){return function(){this[e]=t}}function FU(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function BU(e,t){return arguments.length>1?this.each((t==null?PU:typeof t=="function"?FU:DU)(e,t)):this.node()[e]}function b3(e){return e.trim().split(/^|\s+/)}function Ij(e){return e.classList||new k3(e)}function k3(e){this._node=e,this._names=b3(e.getAttribute("class")||"")}k3.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 j3(e,t){for(var n=Ij(e),s=-1,a=t.length;++s<a;)n.add(t[s])}function N3(e,t){for(var n=Ij(e),s=-1,a=t.length;++s<a;)n.remove(t[s])}function qU(e){return function(){j3(this,e)}}function UU(e){return function(){N3(this,e)}}function WU(e,t){return function(){(t.apply(this,arguments)?j3:N3)(this,e)}}function HU(e,t){var n=b3(e+"");if(arguments.length<2){for(var s=Ij(this.node()),a=-1,o=n.length;++a<o;)if(!s.contains(n[a]))return!1;return!0}return this.each((typeof t=="function"?WU:t?qU:UU)(n,t))}function zU(){this.textContent=""}function VU(e){return function(){this.textContent=e}}function GU(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function KU(e){return arguments.length?this.each(e==null?zU:(typeof e=="function"?GU:VU)(e)):this.node().textContent}function YU(){this.innerHTML=""}function XU(e){return function(){this.innerHTML=e}}function ZU(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function JU(e){return arguments.length?this.each(e==null?YU:(typeof e=="function"?ZU:XU)(e)):this.node().innerHTML}function QU(){this.nextSibling&&this.parentNode.appendChild(this)}function eW(){return this.each(QU)}function tW(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function nW(){return this.each(tW)}function sW(e){var t=typeof e=="function"?e:m3(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function rW(){return null}function aW(e,t){var n=typeof e=="function"?e:m3(e),s=t==null?rW:typeof t=="function"?t:Lj(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),s.apply(this,arguments)||null)})}function oW(){var e=this.parentNode;e&&e.removeChild(this)}function iW(){return this.each(oW)}function lW(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function cW(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function uW(e){return this.select(e?cW:lW)}function dW(e){return arguments.length?this.property("__data__",e):this.node().__data__}function hW(e){return function(t){e.call(this,t,this.__data__)}}function fW(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 pW(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 mW(e,t,n){return function(){var s=this.__on,a,o=hW(t);if(s){for(var i=0,l=s.length;i<l;++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 gW(e,t,n){var s=fW(e+""),a,o=s.length,i;if(arguments.length<2){var l=this.node().__on;if(l){for(var u=0,h=l.length,f;u<h;++u)for(a=0,f=l[u];a<o;++a)if((i=s[a]).type===f.type&&i.name===f.name)return f.value}return}for(l=t?mW:pW,a=0;a<o;++a)this.each(l(s[a],t,n));return this}function S3(e,t,n){var s=v3(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 yW(e,t){return function(){return S3(this,e,t)}}function wW(e,t){return function(){return S3(this,e,t.apply(this,arguments))}}function xW(e,t){return this.each((typeof t=="function"?wW:yW)(e,t))}function*vW(){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 C3=[null];function Qn(e,t){this._groups=e,this._parents=t}function dd(){return new Qn([[document.documentElement]],C3)}function bW(){return this}Qn.prototype=dd.prototype={constructor:Qn,select:Gq,selectAll:Zq,selectChild:tU,selectChildren:aU,filter:oU,data:hU,enter:iU,exit:pU,join:mU,merge:gU,selection:bW,order:yU,sort:wU,call:vU,nodes:bU,node:kU,size:jU,empty:NU,each:SU,attr:MU,style:OU,property:BU,classed:HU,text:KU,html:JU,raise:eW,lower:nW,append:sW,insert:aW,remove:iW,clone:uW,datum:dW,on:gW,dispatch:xW,[Symbol.iterator]:vW};function gs(e){return typeof e=="string"?new Qn([[document.querySelector(e)]],[document.documentElement]):new Qn([[e]],C3)}function kW(e){let t;for(;t=e.sourceEvent;)e=t;return e}function zs(e,t){if(e=kW(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 jW={passive:!1},Du={capture:!0,passive:!1};function Ly(e){e.stopImmediatePropagation()}function Al(e){e.preventDefault(),e.stopImmediatePropagation()}function _3(e){var t=e.document.documentElement,n=gs(e).on("dragstart.drag",Al,Du);"onselectstart"in t?n.on("selectstart.drag",Al,Du):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function E3(e,t){var n=e.document.documentElement,s=gs(e).on("dragstart.drag",null);t&&(s.on("click.drag",Al,Du),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 Uh=e=>()=>e;function e1(e,{sourceEvent:t,subject:n,target:s,identifier:a,active:o,x:i,y:l,dx:u,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:l,enumerable:!0,configurable:!0},dx:{value:u,enumerable:!0,configurable:!0},dy:{value:h,enumerable:!0,configurable:!0},_:{value:f}})}e1.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function NW(e){return!e.ctrlKey&&!e.button}function SW(){return this.parentNode}function CW(e,t){return t??{x:e.x,y:e.y}}function _W(){return navigator.maxTouchPoints||"ontouchstart"in this}function EW(){var e=NW,t=SW,n=CW,s=_W,a={},o=Pp("start","drag","end"),i=0,l,u,h,f,p=0;function m(C){C.on("mousedown.drag",w).filter(s).on("touchstart.drag",b).on("touchmove.drag",N,jW).on("touchend.drag touchcancel.drag",x).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function w(C,_){if(!(f||!e.call(this,C,_))){var M=S(this,t.call(this,C,_),C,_,"mouse");M&&(gs(C.view).on("mousemove.drag",v,Du).on("mouseup.drag",j,Du),_3(C.view),Ly(C),h=!1,l=C.clientX,u=C.clientY,M("start",C))}}function v(C){if(Al(C),!h){var _=C.clientX-l,M=C.clientY-u;h=_*_+M*M>p}a.mouse("drag",C)}function j(C){gs(C.view).on("mousemove.drag mouseup.drag",null),E3(C.view,h),Al(C),a.mouse("end",C)}function b(C,_){if(e.call(this,C,_)){var M=C.changedTouches,R=t.call(this,C,_),P=M.length,L,U;for(L=0;L<P;++L)(U=S(this,R,C,_,M[L].identifier,M[L]))&&(Ly(C),U("start",C,M[L]))}}function N(C){var _=C.changedTouches,M=_.length,R,P;for(R=0;R<M;++R)(P=a[_[R].identifier])&&(Al(C),P("drag",C,_[R]))}function x(C){var _=C.changedTouches,M=_.length,R,P;for(f&&clearTimeout(f),f=setTimeout(function(){f=null},500),R=0;R<M;++R)(P=a[_[R].identifier])&&(Ly(C),P("end",C,_[R]))}function S(C,_,M,R,P,L){var U=o.copy(),B=zs(L||M,_),A,q,T;if((T=n.call(C,new e1("beforestart",{sourceEvent:M,target:m,identifier:P,active:i,x:B[0],y:B[1],dx:0,dy:0,dispatch:U}),R))!=null)return A=T.x-B[0]||0,q=T.y-B[1]||0,function F(O,K,V){var H=B,D;switch(O){case"start":a[P]=F,D=i++;break;case"end":delete a[P],--i;case"drag":B=zs(V||K,_),D=i;break}U.call(O,C,new e1(O,{sourceEvent:K,subject:T,target:m,identifier:P,active:D,x:B[0]+A,y:B[1]+q,dx:B[0]-H[0],dy:B[1]-H[1],dispatch:U}),R)}}return m.filter=function(C){return arguments.length?(e=typeof C=="function"?C:Uh(!!C),m):e},m.container=function(C){return arguments.length?(t=typeof C=="function"?C:Uh(C),m):t},m.subject=function(C){return arguments.length?(n=typeof C=="function"?C:Uh(C),m):n},m.touchable=function(C){return arguments.length?(s=typeof C=="function"?C:Uh(!!C),m):s},m.on=function(){var C=o.on.apply(o,arguments);return C===o?m:C},m.clickDistance=function(C){return arguments.length?(p=(C=+C)*C,m):Math.sqrt(p)},m}function Oj(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function T3(e,t){var n=Object.create(e.prototype);for(var s in t)n[s]=t[s];return n}function hd(){}var Fu=.7,Wf=1/Fu,Rl="\\s*([+-]?\\d+)\\s*",Bu="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",wr="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",TW=/^#([0-9a-f]{3,8})$/,AW=new RegExp(`^rgb\\(${Rl},${Rl},${Rl}\\)$`),RW=new RegExp(`^rgb\\(${wr},${wr},${wr}\\)$`),MW=new RegExp(`^rgba\\(${Rl},${Rl},${Rl},${Bu}\\)$`),$W=new RegExp(`^rgba\\(${wr},${wr},${wr},${Bu}\\)$`),LW=new RegExp(`^hsl\\(${Bu},${wr},${wr}\\)$`),IW=new RegExp(`^hsla\\(${Bu},${wr},${wr},${Bu}\\)$`),nE={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};Oj(hd,qu,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:sE,formatHex:sE,formatHex8:OW,formatHsl:PW,formatRgb:rE,toString:rE});function sE(){return this.rgb().formatHex()}function OW(){return this.rgb().formatHex8()}function PW(){return A3(this).formatHsl()}function rE(){return this.rgb().formatRgb()}function qu(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=TW.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?aE(t):n===3?new Pn(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Wh(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Wh(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=AW.exec(e))?new Pn(t[1],t[2],t[3],1):(t=RW.exec(e))?new Pn(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=MW.exec(e))?Wh(t[1],t[2],t[3],t[4]):(t=$W.exec(e))?Wh(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=LW.exec(e))?lE(t[1],t[2]/100,t[3]/100,1):(t=IW.exec(e))?lE(t[1],t[2]/100,t[3]/100,t[4]):nE.hasOwnProperty(e)?aE(nE[e]):e==="transparent"?new Pn(NaN,NaN,NaN,0):null}function aE(e){return new Pn(e>>16&255,e>>8&255,e&255,1)}function Wh(e,t,n,s){return s<=0&&(e=t=n=NaN),new Pn(e,t,n,s)}function DW(e){return e instanceof hd||(e=qu(e)),e?(e=e.rgb(),new Pn(e.r,e.g,e.b,e.opacity)):new Pn}function t1(e,t,n,s){return arguments.length===1?DW(e):new Pn(e,t,n,s??1)}function Pn(e,t,n,s){this.r=+e,this.g=+t,this.b=+n,this.opacity=+s}Oj(Pn,t1,T3(hd,{brighter(e){return e=e==null?Wf:Math.pow(Wf,e),new Pn(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Fu:Math.pow(Fu,e),new Pn(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Pn(si(this.r),si(this.g),si(this.b),Hf(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:oE,formatHex:oE,formatHex8:FW,formatRgb:iE,toString:iE}));function oE(){return`#${Qo(this.r)}${Qo(this.g)}${Qo(this.b)}`}function FW(){return`#${Qo(this.r)}${Qo(this.g)}${Qo(this.b)}${Qo((isNaN(this.opacity)?1:this.opacity)*255)}`}function iE(){const e=Hf(this.opacity);return`${e===1?"rgb(":"rgba("}${si(this.r)}, ${si(this.g)}, ${si(this.b)}${e===1?")":`, ${e})`}`}function Hf(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function si(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Qo(e){return e=si(e),(e<16?"0":"")+e.toString(16)}function lE(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 A3(e){if(e instanceof Vs)return new Vs(e.h,e.s,e.l,e.opacity);if(e instanceof hd||(e=qu(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,l=o-a,u=(o+a)/2;return l?(t===o?i=(n-s)/l+(n<s)*6:n===o?i=(s-t)/l+2:i=(t-n)/l+4,l/=u<.5?o+a:2-o-a,i*=60):l=u>0&&u<1?0:i,new Vs(i,l,u,e.opacity)}function BW(e,t,n,s){return arguments.length===1?A3(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}Oj(Vs,BW,T3(hd,{brighter(e){return e=e==null?Wf:Math.pow(Wf,e),new Vs(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Fu:Math.pow(Fu,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 Pn(Iy(e>=240?e-240:e+120,a,s),Iy(e,a,s),Iy(e<120?e+240:e-120,a,s),this.opacity)},clamp(){return new Vs(cE(this.h),Hh(this.s),Hh(this.l),Hf(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=Hf(this.opacity);return`${e===1?"hsl(":"hsla("}${cE(this.h)}, ${Hh(this.s)*100}%, ${Hh(this.l)*100}%${e===1?")":`, ${e})`}`}}));function cE(e){return e=(e||0)%360,e<0?e+360:e}function Hh(e){return Math.max(0,Math.min(1,e||0))}function Iy(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 R3=e=>()=>e;function qW(e,t){return function(n){return e+n*t}}function UW(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 WW(e){return(e=+e)==1?M3:function(t,n){return n-t?UW(t,n,e):R3(isNaN(t)?n:t)}}function M3(e,t){var n=t-e;return n?qW(e,n):R3(isNaN(e)?t:e)}const uE=(function e(t){var n=WW(t);function s(a,o){var i=n((a=t1(a)).r,(o=t1(o)).r),l=n(a.g,o.g),u=n(a.b,o.b),h=M3(a.opacity,o.opacity);return function(f){return a.r=i(f),a.g=l(f),a.b=u(f),a.opacity=h(f),a+""}}return s.gamma=e,s})(1);function za(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var n1=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Oy=new RegExp(n1.source,"g");function HW(e){return function(){return e}}function zW(e){return function(t){return e(t)+""}}function VW(e,t){var n=n1.lastIndex=Oy.lastIndex=0,s,a,o,i=-1,l=[],u=[];for(e=e+"",t=t+"";(s=n1.exec(e))&&(a=Oy.exec(t));)(o=a.index)>n&&(o=t.slice(n,o),l[i]?l[i]+=o:l[++i]=o),(s=s[0])===(a=a[0])?l[i]?l[i]+=a:l[++i]=a:(l[++i]=null,u.push({i,x:za(s,a)})),n=Oy.lastIndex;return n<t.length&&(o=t.slice(n),l[i]?l[i]+=o:l[++i]=o),l.length<2?u[0]?zW(u[0].x):HW(t):(t=u.length,function(h){for(var f=0,p;f<t;++f)l[(p=u[f]).i]=p.x(h);return l.join("")})}var dE=180/Math.PI,s1={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function $3(e,t,n,s,a,o){var i,l,u;return(i=Math.sqrt(e*e+t*t))&&(e/=i,t/=i),(u=e*n+t*s)&&(n-=e*u,s-=t*u),(l=Math.sqrt(n*n+s*s))&&(n/=l,s/=l,u/=l),e*s<t*n&&(e=-e,t=-t,u=-u,i=-i),{translateX:a,translateY:o,rotate:Math.atan2(t,e)*dE,skewX:Math.atan(u)*dE,scaleX:i,scaleY:l}}var zh;function GW(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?s1:$3(t.a,t.b,t.c,t.d,t.e,t.f)}function KW(e){return e==null||(zh||(zh=document.createElementNS("http://www.w3.org/2000/svg","g")),zh.setAttribute("transform",e),!(e=zh.transform.baseVal.consolidate()))?s1:(e=e.matrix,$3(e.a,e.b,e.c,e.d,e.e,e.f))}function L3(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 j=w.push("translate(",null,t,null,n);v.push({i:j-4,x:za(h,p)},{i:j-2,x:za(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:za(h,f)})):f&&p.push(a(p)+"rotate("+f+s)}function l(h,f,p,m){h!==f?m.push({i:p.push(a(p)+"skewX(",null,s)-2,x:za(h,f)}):f&&p.push(a(p)+"skewX("+f+s)}function u(h,f,p,m,w,v){if(h!==p||f!==m){var j=w.push(a(w)+"scale(",null,",",null,")");v.push({i:j-4,x:za(h,p)},{i:j-2,x:za(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),l(h.skewX,f.skewX,p,m),u(h.scaleX,h.scaleY,f.scaleX,f.scaleY,p,m),h=f=null,function(w){for(var v=-1,j=m.length,b;++v<j;)p[(b=m[v]).i]=b.x(w);return p.join("")}}}var YW=L3(GW,"px, ","px)","deg)"),XW=L3(KW,", ",")",")"),ZW=1e-12;function hE(e){return((e=Math.exp(e))+1/e)/2}function JW(e){return((e=Math.exp(e))-1/e)/2}function QW(e){return((e=Math.exp(2*e))-1)/(e+1)}const e7=(function e(t,n,s){function a(o,i){var l=o[0],u=o[1],h=o[2],f=i[0],p=i[1],m=i[2],w=f-l,v=p-u,j=w*w+v*v,b,N;if(j<ZW)N=Math.log(m/h)/t,b=function(R){return[l+R*w,u+R*v,h*Math.exp(t*R*N)]};else{var x=Math.sqrt(j),S=(m*m-h*h+s*j)/(2*h*n*x),C=(m*m-h*h-s*j)/(2*m*n*x),_=Math.log(Math.sqrt(S*S+1)-S),M=Math.log(Math.sqrt(C*C+1)-C);N=(M-_)/t,b=function(R){var P=R*N,L=hE(_),U=h/(n*x)*(L*QW(t*P+_)-JW(_));return[l+U*w,u+U*v,h*L/hE(t*P+_)]}}return b.duration=N*1e3*t/Math.SQRT2,b}return a.rho=function(o){var i=Math.max(.001,+o),l=i*i,u=l*l;return e(i,l,u)},a})(Math.SQRT2,2,4);var Ul=0,yu=0,tu=0,I3=1e3,zf,wu,Vf=0,di=0,Fp=0,Uu=typeof performance=="object"&&performance.now?performance:Date,O3=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Pj(){return di||(O3(t7),di=Uu.now()+Fp)}function t7(){di=0}function Gf(){this._call=this._time=this._next=null}Gf.prototype=P3.prototype={constructor:Gf,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Pj():+n)+(t==null?0:+t),!this._next&&wu!==this&&(wu?wu._next=this:zf=this,wu=this),this._call=e,this._time=n,r1()},stop:function(){this._call&&(this._call=null,this._time=1/0,r1())}};function P3(e,t,n){var s=new Gf;return s.restart(e,t,n),s}function n7(){Pj(),++Ul;for(var e=zf,t;e;)(t=di-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Ul}function fE(){di=(Vf=Uu.now())+Fp,Ul=yu=0;try{n7()}finally{Ul=0,r7(),di=0}}function s7(){var e=Uu.now(),t=e-Vf;t>I3&&(Fp-=t,Vf=e)}function r7(){for(var e,t=zf,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:zf=n);wu=e,r1(s)}function r1(e){if(!Ul){yu&&(yu=clearTimeout(yu));var t=e-di;t>24?(e<1/0&&(yu=setTimeout(fE,e-Uu.now()-Fp)),tu&&(tu=clearInterval(tu))):(tu||(Vf=Uu.now(),tu=setInterval(s7,I3)),Ul=1,O3(fE))}}function pE(e,t,n){var s=new Gf;return t=t==null?0:+t,s.restart(a=>{s.stop(),e(a+t)},t,n),s}var a7=Pp("start","end","cancel","interrupt"),o7=[],D3=0,mE=1,a1=2,Sf=3,gE=4,o1=5,Cf=6;function Bp(e,t,n,s,a,o){var i=e.__transition;if(!i)e.__transition={};else if(n in i)return;i7(e,n,{name:t,index:s,group:a,on:a7,tween:o7,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:D3})}function Dj(e,t){var n=Js(e,t);if(n.state>D3)throw new Error("too late; already scheduled");return n}function kr(e,t){var n=Js(e,t);if(n.state>Sf)throw new Error("too late; already running");return n}function Js(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function i7(e,t,n){var s=e.__transition,a;s[t]=n,n.timer=P3(o,0,n.time);function o(h){n.state=mE,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!==mE)return u();for(f in s)if(w=s[f],w.name===n.name){if(w.state===Sf)return pE(i);w.state===gE?(w.state=Cf,w.timer.stop(),w.on.call("interrupt",e,e.__data__,w.index,w.group),delete s[f]):+f<t&&(w.state=Cf,w.timer.stop(),w.on.call("cancel",e,e.__data__,w.index,w.group),delete s[f])}if(pE(function(){n.state===Sf&&(n.state=gE,n.timer.restart(l,n.delay,n.time),l(h))}),n.state=a1,n.on.call("start",e,e.__data__,n.index,n.group),n.state===a1){for(n.state=Sf,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 l(h){for(var f=h<n.duration?n.ease.call(null,h/n.duration):(n.timer.restart(u),n.state=o1,1),p=-1,m=a.length;++p<m;)a[p].call(e,f);n.state===o1&&(n.on.call("end",e,e.__data__,n.index,n.group),u())}function u(){n.state=Cf,n.timer.stop(),delete s[t];for(var h in s)return;delete e.__transition}}function _f(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>a1&&s.state<o1,s.state=Cf,s.timer.stop(),s.on.call(a?"interrupt":"cancel",e,e.__data__,s.index,s.group),delete n[i]}o&&delete e.__transition}}function l7(e){return this.each(function(){_f(this,e)})}function c7(e,t){var n,s;return function(){var a=kr(this,e),o=a.tween;if(o!==n){s=n=o;for(var i=0,l=s.length;i<l;++i)if(s[i].name===t){s=s.slice(),s.splice(i,1);break}}a.tween=s}}function u7(e,t,n){var s,a;if(typeof n!="function")throw new Error;return function(){var o=kr(this,e),i=o.tween;if(i!==s){a=(s=i).slice();for(var l={name:t,value:n},u=0,h=a.length;u<h;++u)if(a[u].name===t){a[u]=l;break}u===h&&a.push(l)}o.tween=a}}function d7(e,t){var n=this._id;if(e+="",arguments.length<2){for(var s=Js(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?c7:u7)(n,e,t))}function Fj(e,t,n){var s=e._id;return e.each(function(){var a=kr(this,s);(a.value||(a.value={}))[t]=n.apply(this,arguments)}),function(a){return Js(a,s).value[t]}}function F3(e,t){var n;return(typeof t=="number"?za:t instanceof qu?uE:(n=qu(t))?(t=n,uE):VW)(e,t)}function h7(e){return function(){this.removeAttribute(e)}}function f7(e){return function(){this.removeAttributeNS(e.space,e.local)}}function p7(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 m7(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 g7(e,t,n){var s,a,o;return function(){var i,l=n(this),u;return l==null?void this.removeAttribute(e):(i=this.getAttribute(e),u=l+"",i===u?null:i===s&&u===a?o:(a=u,o=t(s=i,l)))}}function y7(e,t,n){var s,a,o;return function(){var i,l=n(this),u;return l==null?void this.removeAttributeNS(e.space,e.local):(i=this.getAttributeNS(e.space,e.local),u=l+"",i===u?null:i===s&&u===a?o:(a=u,o=t(s=i,l)))}}function w7(e,t){var n=Dp(e),s=n==="transform"?XW:F3;return this.attrTween(e,typeof t=="function"?(n.local?y7:g7)(n,s,Fj(this,"attr."+e,t)):t==null?(n.local?f7:h7)(n):(n.local?m7:p7)(n,s,t))}function x7(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function v7(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function b7(e,t){var n,s;function a(){var o=t.apply(this,arguments);return o!==s&&(n=(s=o)&&v7(e,o)),n}return a._value=t,a}function k7(e,t){var n,s;function a(){var o=t.apply(this,arguments);return o!==s&&(n=(s=o)&&x7(e,o)),n}return a._value=t,a}function j7(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=Dp(e);return this.tween(n,(s.local?b7:k7)(s,t))}function N7(e,t){return function(){Dj(this,e).delay=+t.apply(this,arguments)}}function S7(e,t){return t=+t,function(){Dj(this,e).delay=t}}function C7(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?N7:S7)(t,e)):Js(this.node(),t).delay}function _7(e,t){return function(){kr(this,e).duration=+t.apply(this,arguments)}}function E7(e,t){return t=+t,function(){kr(this,e).duration=t}}function T7(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?_7:E7)(t,e)):Js(this.node(),t).duration}function A7(e,t){if(typeof t!="function")throw new Error;return function(){kr(this,e).ease=t}}function R7(e){var t=this._id;return arguments.length?this.each(A7(t,e)):Js(this.node(),t).ease}function M7(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;kr(this,e).ease=n}}function $7(e){if(typeof e!="function")throw new Error;return this.each(M7(this._id,e))}function L7(e){typeof e!="function"&&(e=y3(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,l=s[a]=[],u,h=0;h<i;++h)(u=o[h])&&e.call(u,u.__data__,h,o)&&l.push(u);return new la(s,this._parents,this._name,this._id)}function I7(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),l=0;l<o;++l)for(var u=t[l],h=n[l],f=u.length,p=i[l]=new Array(f),m,w=0;w<f;++w)(m=u[w]||h[w])&&(p[w]=m);for(;l<s;++l)i[l]=t[l];return new la(i,this._parents,this._name,this._id)}function O7(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 P7(e,t,n){var s,a,o=O7(t)?Dj:kr;return function(){var i=o(this,e),l=i.on;l!==s&&(a=(s=l).copy()).on(t,n),i.on=a}}function D7(e,t){var n=this._id;return arguments.length<2?Js(this.node(),n).on.on(e):this.each(P7(n,e,t))}function F7(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function B7(){return this.on("end.remove",F7(this._id))}function q7(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Lj(e));for(var s=this._groups,a=s.length,o=new Array(a),i=0;i<a;++i)for(var l=s[i],u=l.length,h=o[i]=new Array(u),f,p,m=0;m<u;++m)(f=l[m])&&(p=e.call(f,f.__data__,m,l))&&("__data__"in f&&(p.__data__=f.__data__),h[m]=p,Bp(h[m],t,n,m,h,Js(f,n)));return new la(o,this._parents,t,n)}function U7(e){var t=this._name,n=this._id;typeof e!="function"&&(e=g3(e));for(var s=this._groups,a=s.length,o=[],i=[],l=0;l<a;++l)for(var u=s[l],h=u.length,f,p=0;p<h;++p)if(f=u[p]){for(var m=e.call(f,f.__data__,p,u),w,v=Js(f,n),j=0,b=m.length;j<b;++j)(w=m[j])&&Bp(w,t,n,j,m,v);o.push(m),i.push(f)}return new la(o,i,t,n)}var W7=dd.prototype.constructor;function H7(){return new W7(this._groups,this._parents)}function z7(e,t){var n,s,a;return function(){var o=ql(this,e),i=(this.style.removeProperty(e),ql(this,e));return o===i?null:o===n&&i===s?a:a=t(n=o,s=i)}}function B3(e){return function(){this.style.removeProperty(e)}}function V7(e,t,n){var s,a=n+"",o;return function(){var i=ql(this,e);return i===a?null:i===s?o:o=t(s=i,n)}}function G7(e,t,n){var s,a,o;return function(){var i=ql(this,e),l=n(this),u=l+"";return l==null&&(u=l=(this.style.removeProperty(e),ql(this,e))),i===u?null:i===s&&u===a?o:(a=u,o=t(s=i,l))}}function K7(e,t){var n,s,a,o="style."+t,i="end."+o,l;return function(){var u=kr(this,e),h=u.on,f=u.value[o]==null?l||(l=B3(t)):void 0;(h!==n||a!==f)&&(s=(n=h).copy()).on(i,a=f),u.on=s}}function Y7(e,t,n){var s=(e+="")=="transform"?YW:F3;return t==null?this.styleTween(e,z7(e,s)).on("end.style."+e,B3(e)):typeof t=="function"?this.styleTween(e,G7(e,s,Fj(this,"style."+e,t))).each(K7(this._id,e)):this.styleTween(e,V7(e,s,t),n).on("end.style."+e,null)}function X7(e,t,n){return function(s){this.style.setProperty(e,t.call(this,s),n)}}function Z7(e,t,n){var s,a;function o(){var i=t.apply(this,arguments);return i!==a&&(s=(a=i)&&X7(e,i,n)),s}return o._value=t,o}function J7(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,Z7(e,t,n??""))}function Q7(e){return function(){this.textContent=e}}function eH(e){return function(){var t=e(this);this.textContent=t??""}}function tH(e){return this.tween("text",typeof e=="function"?eH(Fj(this,"text",e)):Q7(e==null?"":e+""))}function nH(e){return function(t){this.textContent=e.call(this,t)}}function sH(e){var t,n;function s(){var a=e.apply(this,arguments);return a!==n&&(t=(n=a)&&nH(a)),t}return s._value=e,s}function rH(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,sH(e))}function aH(){for(var e=this._name,t=this._id,n=q3(),s=this._groups,a=s.length,o=0;o<a;++o)for(var i=s[o],l=i.length,u,h=0;h<l;++h)if(u=i[h]){var f=Js(u,t);Bp(u,e,n,h,i,{time:f.time+f.delay+f.duration,delay:0,duration:f.duration,ease:f.ease})}return new la(s,this._parents,e,n)}function oH(){var e,t,n=this,s=n._id,a=n.size();return new Promise(function(o,i){var l={value:i},u={value:function(){--a===0&&o()}};n.each(function(){var h=kr(this,s),f=h.on;f!==e&&(t=(e=f).copy(),t._.cancel.push(l),t._.interrupt.push(l),t._.end.push(u)),h.on=t}),a===0&&o()})}var iH=0;function la(e,t,n,s){this._groups=e,this._parents=t,this._name=n,this._id=s}function q3(){return++iH}var Yr=dd.prototype;la.prototype={constructor:la,select:q7,selectAll:U7,selectChild:Yr.selectChild,selectChildren:Yr.selectChildren,filter:L7,merge:I7,selection:H7,transition:aH,call:Yr.call,nodes:Yr.nodes,node:Yr.node,size:Yr.size,empty:Yr.empty,each:Yr.each,on:D7,attr:w7,attrTween:j7,style:Y7,styleTween:J7,text:tH,textTween:rH,remove:B7,tween:d7,delay:C7,duration:T7,ease:R7,easeVarying:$7,end:oH,[Symbol.iterator]:Yr[Symbol.iterator]};function lH(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var cH={time:null,delay:0,duration:250,ease:lH};function uH(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 dH(e){var t,n;e instanceof la?(t=e._id,e=e._name):(t=q3(),(n=cH).time=Pj(),e=e==null?null:e+"");for(var s=this._groups,a=s.length,o=0;o<a;++o)for(var i=s[o],l=i.length,u,h=0;h<l;++h)(u=i[h])&&Bp(u,e,t,h,i,n||uH(u,t));return new la(s,this._parents,e,t)}dd.prototype.interrupt=l7;dd.prototype.transition=dH;const Vh=e=>()=>e;function hH(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 na(e,t,n){this.k=e,this.x=t,this.y=n}na.prototype={constructor:na,scale:function(e){return e===1?this:new na(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new na(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 ra=new na(1,0,0);na.prototype;function Py(e){e.stopImmediatePropagation()}function nu(e){e.preventDefault(),e.stopImmediatePropagation()}function fH(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function pH(){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 yE(){return this.__zoom||ra}function mH(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function gH(){return navigator.maxTouchPoints||"ontouchstart"in this}function yH(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 U3(){var e=fH,t=pH,n=yH,s=mH,a=gH,o=[0,1/0],i=[[-1/0,-1/0],[1/0,1/0]],l=250,u=e7,h=Pp("start","zoom","end"),f,p,m,w=500,v=150,j=0,b=10;function N(T){T.property("__zoom",yE).on("wheel.zoom",P,{passive:!1}).on("mousedown.zoom",L).on("dblclick.zoom",U).filter(a).on("touchstart.zoom",B).on("touchmove.zoom",A).on("touchend.zoom touchcancel.zoom",q).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}N.transform=function(T,F,O,K){var V=T.selection?T.selection():T;V.property("__zoom",yE),T!==V?_(T,F,O,K):V.interrupt().each(function(){M(this,arguments).event(K).start().zoom(null,typeof F=="function"?F.apply(this,arguments):F).end()})},N.scaleBy=function(T,F,O,K){N.scaleTo(T,function(){var V=this.__zoom.k,H=typeof F=="function"?F.apply(this,arguments):F;return V*H},O,K)},N.scaleTo=function(T,F,O,K){N.transform(T,function(){var V=t.apply(this,arguments),H=this.__zoom,D=O==null?C(V):typeof O=="function"?O.apply(this,arguments):O,I=H.invert(D),W=typeof F=="function"?F.apply(this,arguments):F;return n(S(x(H,W),D,I),V,i)},O,K)},N.translateBy=function(T,F,O,K){N.transform(T,function(){return n(this.__zoom.translate(typeof F=="function"?F.apply(this,arguments):F,typeof O=="function"?O.apply(this,arguments):O),t.apply(this,arguments),i)},null,K)},N.translateTo=function(T,F,O,K,V){N.transform(T,function(){var H=t.apply(this,arguments),D=this.__zoom,I=K==null?C(H):typeof K=="function"?K.apply(this,arguments):K;return n(ra.translate(I[0],I[1]).scale(D.k).translate(typeof F=="function"?-F.apply(this,arguments):-F,typeof O=="function"?-O.apply(this,arguments):-O),H,i)},K,V)};function x(T,F){return F=Math.max(o[0],Math.min(o[1],F)),F===T.k?T:new na(F,T.x,T.y)}function S(T,F,O){var K=F[0]-O[0]*T.k,V=F[1]-O[1]*T.k;return K===T.x&&V===T.y?T:new na(T.k,K,V)}function C(T){return[(+T[0][0]+ +T[1][0])/2,(+T[0][1]+ +T[1][1])/2]}function _(T,F,O,K){T.on("start.zoom",function(){M(this,arguments).event(K).start()}).on("interrupt.zoom end.zoom",function(){M(this,arguments).event(K).end()}).tween("zoom",function(){var V=this,H=arguments,D=M(V,H).event(K),I=t.apply(V,H),W=O==null?C(I):typeof O=="function"?O.apply(V,H):O,Z=Math.max(I[1][0]-I[0][0],I[1][1]-I[0][1]),z=V.__zoom,X=typeof F=="function"?F.apply(V,H):F,Y=u(z.invert(W).concat(Z/z.k),X.invert(W).concat(Z/X.k));return function(J){if(J===1)J=X;else{var Q=Y(J),te=Z/Q[2];J=new na(te,W[0]-Q[0]*te,W[1]-Q[1]*te)}D.zoom(null,J)}})}function M(T,F,O){return!O&&T.__zooming||new R(T,F)}function R(T,F){this.that=T,this.args=F,this.active=0,this.sourceEvent=null,this.extent=t.apply(T,F),this.taps=0}R.prototype={event:function(T){return T&&(this.sourceEvent=T),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(T,F){return this.mouse&&T!=="mouse"&&(this.mouse[1]=F.invert(this.mouse[0])),this.touch0&&T!=="touch"&&(this.touch0[1]=F.invert(this.touch0[0])),this.touch1&&T!=="touch"&&(this.touch1[1]=F.invert(this.touch1[0])),this.that.__zoom=F,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(T){var F=gs(this.that).datum();h.call(T,this.that,new hH(T,{sourceEvent:this.sourceEvent,target:N,transform:this.that.__zoom,dispatch:h}),F)}};function P(T,...F){if(!e.apply(this,arguments))return;var O=M(this,F).event(T),K=this.__zoom,V=Math.max(o[0],Math.min(o[1],K.k*Math.pow(2,s.apply(this,arguments)))),H=zs(T);if(O.wheel)(O.mouse[0][0]!==H[0]||O.mouse[0][1]!==H[1])&&(O.mouse[1]=K.invert(O.mouse[0]=H)),clearTimeout(O.wheel);else{if(K.k===V)return;O.mouse=[H,K.invert(H)],_f(this),O.start()}nu(T),O.wheel=setTimeout(D,v),O.zoom("mouse",n(S(x(K,V),O.mouse[0],O.mouse[1]),O.extent,i));function D(){O.wheel=null,O.end()}}function L(T,...F){if(m||!e.apply(this,arguments))return;var O=T.currentTarget,K=M(this,F,!0).event(T),V=gs(T.view).on("mousemove.zoom",W,!0).on("mouseup.zoom",Z,!0),H=zs(T,O),D=T.clientX,I=T.clientY;_3(T.view),Py(T),K.mouse=[H,this.__zoom.invert(H)],_f(this),K.start();function W(z){if(nu(z),!K.moved){var X=z.clientX-D,Y=z.clientY-I;K.moved=X*X+Y*Y>j}K.event(z).zoom("mouse",n(S(K.that.__zoom,K.mouse[0]=zs(z,O),K.mouse[1]),K.extent,i))}function Z(z){V.on("mousemove.zoom mouseup.zoom",null),E3(z.view,K.moved),nu(z),K.event(z).end()}}function U(T,...F){if(e.apply(this,arguments)){var O=this.__zoom,K=zs(T.changedTouches?T.changedTouches[0]:T,this),V=O.invert(K),H=O.k*(T.shiftKey?.5:2),D=n(S(x(O,H),K,V),t.apply(this,F),i);nu(T),l>0?gs(this).transition().duration(l).call(_,D,K,T):gs(this).call(N.transform,D,K,T)}}function B(T,...F){if(e.apply(this,arguments)){var O=T.touches,K=O.length,V=M(this,F,T.changedTouches.length===K).event(T),H,D,I,W;for(Py(T),D=0;D<K;++D)I=O[D],W=zs(I,this),W=[W,this.__zoom.invert(W),I.identifier],V.touch0?!V.touch1&&V.touch0[2]!==W[2]&&(V.touch1=W,V.taps=0):(V.touch0=W,H=!0,V.taps=1+!!f);f&&(f=clearTimeout(f)),H&&(V.taps<2&&(p=W[0],f=setTimeout(function(){f=null},w)),_f(this),V.start())}}function A(T,...F){if(this.__zooming){var O=M(this,F).event(T),K=T.changedTouches,V=K.length,H,D,I,W;for(nu(T),H=0;H<V;++H)D=K[H],I=zs(D,this),O.touch0&&O.touch0[2]===D.identifier?O.touch0[0]=I:O.touch1&&O.touch1[2]===D.identifier&&(O.touch1[0]=I);if(D=O.that.__zoom,O.touch1){var Z=O.touch0[0],z=O.touch0[1],X=O.touch1[0],Y=O.touch1[1],J=(J=X[0]-Z[0])*J+(J=X[1]-Z[1])*J,Q=(Q=Y[0]-z[0])*Q+(Q=Y[1]-z[1])*Q;D=x(D,Math.sqrt(J/Q)),I=[(Z[0]+X[0])/2,(Z[1]+X[1])/2],W=[(z[0]+Y[0])/2,(z[1]+Y[1])/2]}else if(O.touch0)I=O.touch0[0],W=O.touch0[1];else return;O.zoom("touch",n(S(D,I,W),O.extent,i))}}function q(T,...F){if(this.__zooming){var O=M(this,F).event(T),K=T.changedTouches,V=K.length,H,D;for(Py(T),m&&clearTimeout(m),m=setTimeout(function(){m=null},w),H=0;H<V;++H)D=K[H],O.touch0&&O.touch0[2]===D.identifier?delete O.touch0:O.touch1&&O.touch1[2]===D.identifier&&delete O.touch1;if(O.touch1&&!O.touch0&&(O.touch0=O.touch1,delete O.touch1),O.touch0)O.touch0[1]=this.__zoom.invert(O.touch0[0]);else if(O.end(),O.taps===2&&(D=zs(D,this),Math.hypot(p[0]-D[0],p[1]-D[1])<b)){var I=gs(this).on("dblclick.zoom");I&&I.apply(this,arguments)}}}return N.wheelDelta=function(T){return arguments.length?(s=typeof T=="function"?T:Vh(+T),N):s},N.filter=function(T){return arguments.length?(e=typeof T=="function"?T:Vh(!!T),N):e},N.touchable=function(T){return arguments.length?(a=typeof T=="function"?T:Vh(!!T),N):a},N.extent=function(T){return arguments.length?(t=typeof T=="function"?T:Vh([[+T[0][0],+T[0][1]],[+T[1][0],+T[1][1]]]),N):t},N.scaleExtent=function(T){return arguments.length?(o[0]=+T[0],o[1]=+T[1],N):[o[0],o[1]]},N.translateExtent=function(T){return arguments.length?(i[0][0]=+T[0][0],i[1][0]=+T[1][0],i[0][1]=+T[0][1],i[1][1]=+T[1][1],N):[[i[0][0],i[0][1]],[i[1][0],i[1][1]]]},N.constrain=function(T){return arguments.length?(n=T,N):n},N.duration=function(T){return arguments.length?(l=+T,N):l},N.interpolate=function(T){return arguments.length?(u=T,N):u},N.on=function(){var T=h.on.apply(h,arguments);return T===h?N:T},N.clickDistance=function(T){return arguments.length?(j=(T=+T)*T,N):Math.sqrt(j)},N.tapDistance=function(T){return arguments.length?(b=+T,N):b},N}var kt=f3();const qp=g.createContext(null),wH=qp.Provider,ca={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.`},W3=ca.error001();function ht(e,t){const n=g.useContext(qp);if(n===null)throw new Error(W3);return p3(n,e,t)}const Wt=()=>{const e=g.useContext(qp);if(e===null)throw new Error(W3);return g.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy}),[e])},xH=e=>e.userSelectionActive?"none":"all";function Bj({position:e,children:t,className:n,style:s,...a}){const o=ht(xH),i=`${e}`.split("-");return me.createElement("div",{className:un(["react-flow__panel",n,...i]),style:{...s,pointerEvents:o},...a},t)}function vH({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:me.createElement(Bj,{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"},me.createElement("a",{href:"https://reactflow.dev",target:"_blank",rel:"noopener noreferrer","aria-label":"React Flow attribution"},"React Flow"))}const bH=({x:e,y:t,label:n,labelStyle:s={},labelShowBg:a=!0,labelBgStyle:o={},labelBgPadding:i=[2,4],labelBgBorderRadius:l=2,children:u,className:h,...f})=>{const p=g.useRef(null),[m,w]=g.useState({x:0,y:0,width:0,height:0}),v=un(["react-flow__edge-textwrapper",h]);return g.useEffect(()=>{if(p.current){const j=p.current.getBBox();w({x:j.x,y:j.y,width:j.width,height:j.height})}},[n]),typeof n>"u"||!n?null:me.createElement("g",{transform:`translate(${e-m.width/2} ${t-m.height/2})`,className:v,visibility:m.width?"visible":"hidden",...f},a&&me.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:l,ry:l}),me.createElement("text",{className:"react-flow__edge-text",y:m.height/2,dy:"0.3em",ref:p,style:s},n),u)};var kH=g.memo(bH);const qj=e=>({width:e.offsetWidth,height:e.offsetHeight}),Wl=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Uj=(e={x:0,y:0},t)=>({x:Wl(e.x,t[0][0],t[1][0]),y:Wl(e.y,t[0][1],t[1][1])}),wE=(e,t,n)=>e<t?Wl(Math.abs(e-t),1,50)/50:e>n?-Wl(Math.abs(e-n),1,50)/50:0,H3=(e,t)=>{const n=wE(e.x,35,t.width-35)*20,s=wE(e.y,35,t.height-35)*20;return[n,s]},z3=e=>{var t;return((t=e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},V3=(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)}),Wu=({x:e,y:t,width:n,height:s})=>({x:e,y:t,x2:e+n,y2:t+s}),G3=({x:e,y:t,x2:n,y2:s})=>({x:e,y:t,width:n-e,height:s-t}),xE=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),jH=(e,t)=>G3(V3(Wu(e),Wu(t))),i1=(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)},NH=e=>ys(e.width)&&ys(e.height)&&ys(e.x)&&ys(e.y),ys=e=>!isNaN(e)&&isFinite(e),Ft=Symbol.for("internals"),K3=["Enter"," ","Escape"],SH=(e,t)=>{},CH=e=>"nativeEvent"in e;function l1(e){var a,o;const t=CH(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 Y3=e=>"clientX"in e,eo=(e,t)=>{var o,i;const n=Y3(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)}},Kf=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0},fd=({id:e,path:t,labelX:n,labelY:s,label:a,labelStyle:o,labelShowBg:i,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:h,style:f,markerEnd:p,markerStart:m,interactionWidth:w=20})=>me.createElement(me.Fragment,null,me.createElement("path",{id:e,style:f,d:t,fill:"none",className:"react-flow__edge-path",markerEnd:p,markerStart:m}),w&&me.createElement("path",{d:t,fill:"none",strokeOpacity:0,strokeWidth:w,className:"react-flow__edge-interaction"}),a&&ys(n)&&ys(s)?me.createElement(kH,{x:n,y:s,label:a,labelStyle:o,labelShowBg:i,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:h}):null);fd.displayName="BaseEdge";function su(e,t,n){return n===void 0?n:s=>{const a=t().edges.find(o=>o.id===e);a&&n(s,{...a})}}function X3({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,l=s<t?s+i:s-i;return[o,l,a,i]}function Z3({sourceX:e,sourceY:t,targetX:n,targetY:s,sourceControlX:a,sourceControlY:o,targetControlX:i,targetControlY:l}){const u=e*.125+a*.375+i*.375+n*.125,h=t*.125+o*.375+l*.375+s*.125,f=Math.abs(u-e),p=Math.abs(h-t);return[u,h,f,p]}var hi;(function(e){e.Strict="strict",e.Loose="loose"})(hi||(hi={}));var ei;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(ei||(ei={}));var Hu;(function(e){e.Partial="partial",e.Full="full"})(Hu||(Hu={}));var Ka;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Ka||(Ka={}));var Yf;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Yf||(Yf={}));var Ye;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Ye||(Ye={}));function vE({pos:e,x1:t,y1:n,x2:s,y2:a}){return e===Ye.Left||e===Ye.Right?[.5*(t+s),n]:[t,.5*(n+a)]}function J3({sourceX:e,sourceY:t,sourcePosition:n=Ye.Bottom,targetX:s,targetY:a,targetPosition:o=Ye.Top}){const[i,l]=vE({pos:n,x1:e,y1:t,x2:s,y2:a}),[u,h]=vE({pos:o,x1:s,y1:a,x2:e,y2:t}),[f,p,m,w]=Z3({sourceX:e,sourceY:t,targetX:s,targetY:a,sourceControlX:i,sourceControlY:l,targetControlX:u,targetControlY:h});return[`M${e},${t} C${i},${l} ${u},${h} ${s},${a}`,f,p,m,w]}const Wj=g.memo(({sourceX:e,sourceY:t,targetX:n,targetY:s,sourcePosition:a=Ye.Bottom,targetPosition:o=Ye.Top,label:i,labelStyle:l,labelShowBg:u,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:w,markerStart:v,interactionWidth:j})=>{const[b,N,x]=J3({sourceX:e,sourceY:t,sourcePosition:a,targetX:n,targetY:s,targetPosition:o});return me.createElement(fd,{path:b,labelX:N,labelY:x,label:i,labelStyle:l,labelShowBg:u,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:w,markerStart:v,interactionWidth:j})});Wj.displayName="SimpleBezierEdge";const bE={[Ye.Left]:{x:-1,y:0},[Ye.Right]:{x:1,y:0},[Ye.Top]:{x:0,y:-1},[Ye.Bottom]:{x:0,y:1}},_H=({source:e,sourcePosition:t=Ye.Bottom,target:n})=>t===Ye.Left||t===Ye.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},kE=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function EH({source:e,sourcePosition:t=Ye.Bottom,target:n,targetPosition:s=Ye.Top,center:a,offset:o}){const i=bE[t],l=bE[s],u={x:e.x+i.x*o,y:e.y+i.y*o},h={x:n.x+l.x*o,y:n.y+l.y*o},f=_H({source:u,sourcePosition:t,target:h}),p=f.x!==0?"x":"y",m=f[p];let w=[],v,j;const b={x:0,y:0},N={x:0,y:0},[x,S,C,_]=X3({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(i[p]*l[p]===-1){v=a.x??x,j=a.y??S;const R=[{x:v,y:u.y},{x:v,y:h.y}],P=[{x:u.x,y:j},{x:h.x,y:j}];i[p]===m?w=p==="x"?R:P:w=p==="x"?P:R}else{const R=[{x:u.x,y:h.y}],P=[{x:h.x,y:u.y}];if(p==="x"?w=i.x===m?P:R:w=i.y===m?R:P,t===s){const q=Math.abs(e[p]-n[p]);if(q<=o){const T=Math.min(o-1,o-q);i[p]===m?b[p]=(u[p]>e[p]?-1:1)*T:N[p]=(h[p]>n[p]?-1:1)*T}}if(t!==s){const q=p==="x"?"y":"x",T=i[p]===l[q],F=u[q]>h[q],O=u[q]<h[q];(i[p]===1&&(!T&&F||T&&O)||i[p]!==1&&(!T&&O||T&&F))&&(w=p==="x"?R:P)}const L={x:u.x+b.x,y:u.y+b.y},U={x:h.x+N.x,y:h.y+N.y},B=Math.max(Math.abs(L.x-w[0].x),Math.abs(U.x-w[0].x)),A=Math.max(Math.abs(L.y-w[0].y),Math.abs(U.y-w[0].y));B>=A?(v=(L.x+U.x)/2,j=w[0].y):(v=w[0].x,j=(L.y+U.y)/2)}return[[e,{x:u.x+b.x,y:u.y+b.y},...w,{x:h.x+N.x,y:h.y+N.y},n],v,j,C,_]}function TH(e,t,n,s){const a=Math.min(kE(e,t)/2,kE(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 l=e.x<n.x?1:-1,u=e.y<n.y?-1:1;return`L ${o},${i+a*u}Q ${o},${i} ${o+a*l},${i}`}function c1({sourceX:e,sourceY:t,sourcePosition:n=Ye.Bottom,targetX:s,targetY:a,targetPosition:o=Ye.Top,borderRadius:i=5,centerX:l,centerY:u,offset:h=20}){const[f,p,m,w,v]=EH({source:{x:e,y:t},sourcePosition:n,target:{x:s,y:a},targetPosition:o,center:{x:l,y:u},offset:h});return[f.reduce((b,N,x)=>{let S="";return x>0&&x<f.length-1?S=TH(f[x-1],N,f[x+1],i):S=`${x===0?"M":"L"}${N.x} ${N.y}`,b+=S,b},""),p,m,w,v]}const Up=g.memo(({sourceX:e,sourceY:t,targetX:n,targetY:s,label:a,labelStyle:o,labelShowBg:i,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:h,style:f,sourcePosition:p=Ye.Bottom,targetPosition:m=Ye.Top,markerEnd:w,markerStart:v,pathOptions:j,interactionWidth:b})=>{const[N,x,S]=c1({sourceX:e,sourceY:t,sourcePosition:p,targetX:n,targetY:s,targetPosition:m,borderRadius:j==null?void 0:j.borderRadius,offset:j==null?void 0:j.offset});return me.createElement(fd,{path:N,labelX:x,labelY:S,label:a,labelStyle:o,labelShowBg:i,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:h,style:f,markerEnd:w,markerStart:v,interactionWidth:b})});Up.displayName="SmoothStepEdge";const Hj=g.memo(e=>{var t;return me.createElement(Up,{...e,pathOptions:g.useMemo(()=>{var n;return{borderRadius:0,offset:(n=e.pathOptions)==null?void 0:n.offset}},[(t=e.pathOptions)==null?void 0:t.offset])})});Hj.displayName="StepEdge";function AH({sourceX:e,sourceY:t,targetX:n,targetY:s}){const[a,o,i,l]=X3({sourceX:e,sourceY:t,targetX:n,targetY:s});return[`M ${e},${t}L ${n},${s}`,a,o,i,l]}const zj=g.memo(({sourceX:e,sourceY:t,targetX:n,targetY:s,label:a,labelStyle:o,labelShowBg:i,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:h,style:f,markerEnd:p,markerStart:m,interactionWidth:w})=>{const[v,j,b]=AH({sourceX:e,sourceY:t,targetX:n,targetY:s});return me.createElement(fd,{path:v,labelX:j,labelY:b,label:a,labelStyle:o,labelShowBg:i,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:h,style:f,markerEnd:p,markerStart:m,interactionWidth:w})});zj.displayName="StraightEdge";function Gh(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function jE({pos:e,x1:t,y1:n,x2:s,y2:a,c:o}){switch(e){case Ye.Left:return[t-Gh(t-s,o),n];case Ye.Right:return[t+Gh(s-t,o),n];case Ye.Top:return[t,n-Gh(n-a,o)];case Ye.Bottom:return[t,n+Gh(a-n,o)]}}function Vj({sourceX:e,sourceY:t,sourcePosition:n=Ye.Bottom,targetX:s,targetY:a,targetPosition:o=Ye.Top,curvature:i=.25}){const[l,u]=jE({pos:n,x1:e,y1:t,x2:s,y2:a,c:i}),[h,f]=jE({pos:o,x1:s,y1:a,x2:e,y2:t,c:i}),[p,m,w,v]=Z3({sourceX:e,sourceY:t,targetX:s,targetY:a,sourceControlX:l,sourceControlY:u,targetControlX:h,targetControlY:f});return[`M${e},${t} C${l},${u} ${h},${f} ${s},${a}`,p,m,w,v]}const Xf=g.memo(({sourceX:e,sourceY:t,targetX:n,targetY:s,sourcePosition:a=Ye.Bottom,targetPosition:o=Ye.Top,label:i,labelStyle:l,labelShowBg:u,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:w,markerStart:v,pathOptions:j,interactionWidth:b})=>{const[N,x,S]=Vj({sourceX:e,sourceY:t,sourcePosition:a,targetX:n,targetY:s,targetPosition:o,curvature:j==null?void 0:j.curvature});return me.createElement(fd,{path:N,labelX:x,labelY:S,label:i,labelStyle:l,labelShowBg:u,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:w,markerStart:v,interactionWidth:b})});Xf.displayName="BezierEdge";const Gj=g.createContext(null),RH=Gj.Provider;Gj.Consumer;const MH=()=>g.useContext(Gj),$H=e=>"id"in e&&"source"in e&&"target"in e,LH=({source:e,sourceHandle:t,target:n,targetHandle:s})=>`reactflow__edge-${e}${t||""}-${n}${s||""}`,u1=(e,t)=>typeof e>"u"?"":typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(s=>`${s}=${e[s]}`).join("&")}`,IH=(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)),OH=(e,t)=>{if(!e.source||!e.target)return t;let n;return $H(e)?n={...e}:n={...e,id:LH(e)},IH(n,t)?t:t.concat(n)},d1=({x:e,y:t},[n,s,a],o,[i,l])=>{const u={x:(e-n)/a,y:(t-s)/a};return o?{x:i*Math.round(u.x/i),y:l*Math.round(u.y/l)}:u},Q3=({x:e,y:t},[n,s,a])=>({x:e*a+n,y:t*a+s}),ri=(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}},Wp=(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}=ri(a,t).positionAbsolute;return V3(s,Wu({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 G3(n)},e4=(e,t,[n,s,a]=[0,0,1],o=!1,i=!1,l=[0,0])=>{const u={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:j}=ri(f,l),b={x:j.x,y:j.y,width:p||0,height:m||0},N=i1(u,b),x=typeof p>"u"||typeof m>"u"||p===null||m===null,S=o&&N>0,C=(p||0)*(m||0);(x||S||N>=C||f.dragging)&&h.push(f)}),h},t4=(e,t)=>{const n=e.map(s=>s.id);return t.filter(s=>n.includes(s.source)||n.includes(s.target))},n4=(e,t,n,s,a,o=.1)=>{const i=t/(e.width*(1+o)),l=n/(e.height*(1+o)),u=Math.min(i,l),h=Wl(u,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}},Go=(e,t=0)=>e.transition().duration(t);function NE(e,t,n,s){return(t[n]||[]).reduce((a,o)=>{var i,l;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:(((l=e.positionAbsolute)==null?void 0:l.y)??0)+o.y+o.height/2}),a},[])}function PH(e,t,n,s,a,o){const{x:i,y:l}=eo(e),h=t.elementsFromPoint(i,l).find(v=>v.classList.contains("react-flow__handle"));if(h){const v=h.getAttribute("data-nodeid");if(v){const j=Kj(void 0,h),b=h.getAttribute("data-handleid"),N=o({nodeId:v,id:b,type:j});if(N){const x=a.find(S=>S.nodeId===v&&S.type===j&&S.id===b);return{handle:{id:b,type:j,nodeId:v,x:(x==null?void 0:x.x)||n.x,y:(x==null?void 0:x.y)||n.y},validHandleResult:N}}}}let f=[],p=1/0;if(a.forEach(v=>{const j=Math.sqrt((v.x-n.x)**2+(v.y-n.y)**2);if(j<=s){const b=o(v);j<=p&&(j<p?f=[{handle:v,validHandleResult:b}]:j===p&&f.push({handle:v,validHandleResult:b}),p=j)}}),!f.length)return{handle:null,validHandleResult:s4()};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:j})=>w?v.type==="target":m?j.isValid:!0)||f[0]}const DH={source:null,target:null,sourceHandle:null,targetHandle:null},s4=()=>({handleDomNode:null,isValid:!1,connection:DH,endHandle:null});function r4(e,t,n,s,a,o,i){const l=a==="target",u=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={...s4(),handleDomNode:u};if(u){const f=Kj(void 0,u),p=u.getAttribute("data-nodeid"),m=u.getAttribute("data-handleid"),w=u.classList.contains("connectable"),v=u.classList.contains("connectableend"),j={source:l?p:n,sourceHandle:l?m:s,target:l?n:p,targetHandle:l?s:m};h.connection=j,w&&v&&(t===hi.Strict?l&&f==="source"||!l&&f==="target":p!==n||m!==s)&&(h.endHandle={nodeId:p,handleId:m,type:f},h.isValid=o(j))}return h}function FH({nodes:e,nodeId:t,handleId:n,handleType:s}){return e.reduce((a,o)=>{if(o[Ft]){const{handleBounds:i}=o[Ft];let l=[],u=[];i&&(l=NE(o,i,"source",`${t}-${n}-${s}`),u=NE(o,i,"target",`${t}-${n}-${s}`)),a.push(...l,...u)}return a},[])}function Kj(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function Dy(e){e==null||e.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function BH(e,t){let n=null;return t?n="valid":e&&!t&&(n="invalid"),n}function a4({event:e,handleId:t,nodeId:n,onConnect:s,isTarget:a,getState:o,setState:i,isValidConnection:l,edgeUpdaterType:u,onReconnectEnd:h}){const f=z3(e.target),{connectionMode:p,domNode:m,autoPanOnConnect:w,connectionRadius:v,onConnectStart:j,panBy:b,getNodes:N,cancelConnection:x}=o();let S=0,C;const{x:_,y:M}=eo(e),R=f==null?void 0:f.elementFromPoint(_,M),P=Kj(u,R),L=m==null?void 0:m.getBoundingClientRect();if(!L||!P)return;let U,B=eo(e,L),A=!1,q=null,T=!1,F=null;const O=FH({nodes:N(),nodeId:n,handleId:t,handleType:P}),K=()=>{if(!w)return;const[D,I]=H3(B,L);b({x:D,y:I}),S=requestAnimationFrame(K)};i({connectionPosition:B,connectionStatus:null,connectionNodeId:n,connectionHandleId:t,connectionHandleType:P,connectionStartHandle:{nodeId:n,handleId:t,type:P},connectionEndHandle:null}),j==null||j(e,{nodeId:n,handleId:t,handleType:P});function V(D){const{transform:I}=o();B=eo(D,L);const{handle:W,validHandleResult:Z}=PH(D,f,d1(B,I,!1,[1,1]),v,O,z=>r4(z,p,n,t,a?"target":"source",l,f));if(C=W,A||(K(),A=!0),F=Z.handleDomNode,q=Z.connection,T=Z.isValid,i({connectionPosition:C&&T?Q3({x:C.x,y:C.y},I):B,connectionStatus:BH(!!C,T),connectionEndHandle:Z.endHandle}),!C&&!T&&!F)return Dy(U);q.source!==q.target&&F&&(Dy(U),U=F,F.classList.add("connecting","react-flow__handle-connecting"),F.classList.toggle("valid",T),F.classList.toggle("react-flow__handle-valid",T))}function H(D){var I,W;(C||F)&&q&&T&&(s==null||s(q)),(W=(I=o()).onConnectEnd)==null||W.call(I,D),u&&(h==null||h(D)),Dy(U),x(),cancelAnimationFrame(S),A=!1,T=!1,q=null,F=null,f.removeEventListener("mousemove",V),f.removeEventListener("mouseup",H),f.removeEventListener("touchmove",V),f.removeEventListener("touchend",H)}f.addEventListener("mousemove",V),f.addEventListener("mouseup",H),f.addEventListener("touchmove",V),f.addEventListener("touchend",H)}const SE=()=>!0,qH=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),UH=(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}},o4=g.forwardRef(({type:e="source",position:t=Ye.Top,isValidConnection:n,isConnectable:s=!0,isConnectableStart:a=!0,isConnectableEnd:o=!0,id:i,onConnect:l,children:u,className:h,onMouseDown:f,onTouchStart:p,...m},w)=>{var L,U;const v=i||null,j=e==="target",b=Wt(),N=MH(),{connectOnClick:x,noPanClassName:S}=ht(qH,Qt),{connecting:C,clickConnecting:_}=ht(UH(N,v,e),Qt);N||(U=(L=b.getState()).onError)==null||U.call(L,"010",ca.error010());const M=B=>{const{defaultEdgeOptions:A,onConnect:q,hasDefaultEdges:T}=b.getState(),F={...A,...B};if(T){const{edges:O,setEdges:K}=b.getState();K(OH(F,O))}q==null||q(F),l==null||l(F)},R=B=>{if(!N)return;const A=Y3(B);a&&(A&&B.button===0||!A)&&a4({event:B,handleId:v,nodeId:N,onConnect:M,isTarget:j,getState:b.getState,setState:b.setState,isValidConnection:n||b.getState().isValidConnection||SE}),A?f==null||f(B):p==null||p(B)},P=B=>{const{onClickConnectStart:A,onClickConnectEnd:q,connectionClickStartHandle:T,connectionMode:F,isValidConnection:O}=b.getState();if(!N||!T&&!a)return;if(!T){A==null||A(B,{nodeId:N,handleId:v,handleType:e}),b.setState({connectionClickStartHandle:{nodeId:N,type:e,handleId:v}});return}const K=z3(B.target),V=n||O||SE,{connection:H,isValid:D}=r4({nodeId:N,id:v,type:e},F,T.nodeId,T.handleId||null,T.type,V,K);D&&M(H),q==null||q(B),b.setState({connectionClickStartHandle:null})};return me.createElement("div",{"data-handleid":v,"data-nodeid":N,"data-handlepos":t,"data-id":`${N}-${v}-${e}`,className:un(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",S,h,{source:!j,target:j,connectable:s,connectablestart:a,connectableend:o,connecting:_,connectionindicator:s&&(a&&!C||o&&C)}]),onMouseDown:R,onTouchStart:R,onClick:x?P:void 0,ref:w,...m},u)});o4.displayName="Handle";var fi=g.memo(o4);const i4=({data:e,isConnectable:t,targetPosition:n=Ye.Top,sourcePosition:s=Ye.Bottom})=>me.createElement(me.Fragment,null,me.createElement(fi,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,me.createElement(fi,{type:"source",position:s,isConnectable:t}));i4.displayName="DefaultNode";var h1=g.memo(i4);const l4=({data:e,isConnectable:t,sourcePosition:n=Ye.Bottom})=>me.createElement(me.Fragment,null,e==null?void 0:e.label,me.createElement(fi,{type:"source",position:n,isConnectable:t}));l4.displayName="InputNode";var c4=g.memo(l4);const u4=({data:e,isConnectable:t,targetPosition:n=Ye.Top})=>me.createElement(me.Fragment,null,me.createElement(fi,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label);u4.displayName="OutputNode";var d4=g.memo(u4);const Yj=()=>null;Yj.displayName="GroupNode";const WH=e=>({selectedNodes:e.getNodes().filter(t=>t.selected),selectedEdges:e.edges.filter(t=>t.selected).map(t=>({...t}))}),Kh=e=>e.id;function HH(e,t){return Qt(e.selectedNodes.map(Kh),t.selectedNodes.map(Kh))&&Qt(e.selectedEdges.map(Kh),t.selectedEdges.map(Kh))}const h4=g.memo(({onSelectionChange:e})=>{const t=Wt(),{selectedNodes:n,selectedEdges:s}=ht(WH,HH);return g.useEffect(()=>{const a={nodes:n,edges:s};e==null||e(a),t.getState().onSelectionChange.forEach(o=>o(a))},[n,s,e]),null});h4.displayName="SelectionListener";const zH=e=>!!e.onSelectionChange;function VH({onSelectionChange:e}){const t=ht(zH);return e||t?me.createElement(h4,{onSelectionChange:e}):null}const GH=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 rl(e,t){g.useEffect(()=>{typeof e<"u"&&t(e)},[e])}function lt(e,t,n){g.useEffect(()=>{typeof t<"u"&&n({[e]:t})},[t])}const KH=({nodes:e,edges:t,defaultNodes:n,defaultEdges:s,onConnect:a,onConnectStart:o,onConnectEnd:i,onClickConnectStart:l,onClickConnectEnd:u,nodesDraggable:h,nodesConnectable:f,nodesFocusable:p,edgesFocusable:m,edgesUpdatable:w,elevateNodesOnSelect:v,minZoom:j,maxZoom:b,nodeExtent:N,onNodesChange:x,onEdgesChange:S,elementsSelectable:C,connectionMode:_,snapGrid:M,snapToGrid:R,translateExtent:P,connectOnClick:L,defaultEdgeOptions:U,fitView:B,fitViewOptions:A,onNodesDelete:q,onEdgesDelete:T,onNodeDrag:F,onNodeDragStart:O,onNodeDragStop:K,onSelectionDrag:V,onSelectionDragStart:H,onSelectionDragStop:D,noPanClassName:I,nodeOrigin:W,rfId:Z,autoPanOnConnect:z,autoPanOnNodeDrag:X,onError:Y,connectionRadius:J,isValidConnection:Q,nodeDragThreshold:te})=>{const{setNodes:le,setEdges:de,setDefaultNodesAndEdges:oe,setMinZoom:re,setMaxZoom:he,setTranslateExtent:pe,setNodeExtent:Le,reset:ge}=ht(GH,Qt),ve=Wt();return g.useEffect(()=>{const je=s==null?void 0:s.map(Ee=>({...Ee,...U}));return oe(n,je),()=>{ge()}},[]),lt("defaultEdgeOptions",U,ve.setState),lt("connectionMode",_,ve.setState),lt("onConnect",a,ve.setState),lt("onConnectStart",o,ve.setState),lt("onConnectEnd",i,ve.setState),lt("onClickConnectStart",l,ve.setState),lt("onClickConnectEnd",u,ve.setState),lt("nodesDraggable",h,ve.setState),lt("nodesConnectable",f,ve.setState),lt("nodesFocusable",p,ve.setState),lt("edgesFocusable",m,ve.setState),lt("edgesUpdatable",w,ve.setState),lt("elementsSelectable",C,ve.setState),lt("elevateNodesOnSelect",v,ve.setState),lt("snapToGrid",R,ve.setState),lt("snapGrid",M,ve.setState),lt("onNodesChange",x,ve.setState),lt("onEdgesChange",S,ve.setState),lt("connectOnClick",L,ve.setState),lt("fitViewOnInit",B,ve.setState),lt("fitViewOnInitOptions",A,ve.setState),lt("onNodesDelete",q,ve.setState),lt("onEdgesDelete",T,ve.setState),lt("onNodeDrag",F,ve.setState),lt("onNodeDragStart",O,ve.setState),lt("onNodeDragStop",K,ve.setState),lt("onSelectionDrag",V,ve.setState),lt("onSelectionDragStart",H,ve.setState),lt("onSelectionDragStop",D,ve.setState),lt("noPanClassName",I,ve.setState),lt("nodeOrigin",W,ve.setState),lt("rfId",Z,ve.setState),lt("autoPanOnConnect",z,ve.setState),lt("autoPanOnNodeDrag",X,ve.setState),lt("onError",Y,ve.setState),lt("connectionRadius",J,ve.setState),lt("isValidConnection",Q,ve.setState),lt("nodeDragThreshold",te,ve.setState),rl(e,le),rl(t,de),rl(j,re),rl(b,he),rl(P,pe),rl(N,Le),null},CE={display:"none"},YH={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},f4="react-flow__node-desc",p4="react-flow__edge-desc",XH="react-flow__aria-live",ZH=e=>e.ariaLiveMessage;function JH({rfId:e}){const t=ht(ZH);return me.createElement("div",{id:`${XH}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:YH},t)}function QH({rfId:e,disableKeyboardA11y:t}){return me.createElement(me.Fragment,null,me.createElement("div",{id:`${f4}-${e}`,style:CE},"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."," "),me.createElement("div",{id:`${p4}-${e}`,style:CE},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!t&&me.createElement(JH,{rfId:e}))}var zu=(e=null,t={actInsideInputWithModifier:!0})=>{const[n,s]=g.useState(!1),a=g.useRef(!1),o=g.useRef(new Set([])),[i,l]=g.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 g.useEffect(()=>{const u=typeof document<"u"?document:null,h=(t==null?void 0:t.target)||u;if(e!==null){const f=w=>{if(a.current=w.ctrlKey||w.metaKey||w.shiftKey,(!a.current||a.current&&!t.actInsideInputWithModifier)&&l1(w))return!1;const j=EE(w.code,l);o.current.add(w[j]),_E(i,o.current,!1)&&(w.preventDefault(),s(!0))},p=w=>{if((!a.current||a.current&&!t.actInsideInputWithModifier)&&l1(w))return!1;const j=EE(w.code,l);_E(i,o.current,!0)?(s(!1),o.current.clear()):o.current.delete(w[j]),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 _E(e,t,n){return e.filter(s=>n||s.length===t.size).some(s=>s.every(a=>t.has(a)))}function EE(e,t){return t.includes(e)?"code":"key"}function m4(e,t,n,s){var l,u;const a=e.parentNode||e.parentId;if(!a)return n;const o=t.get(a),i=ri(o,s);return m4(o,t,{x:(n.x??0)+i.x,y:(n.y??0)+i.y,z:(((l=o[Ft])==null?void 0:l.z)??0)>(n.z??0)?((u=o[Ft])==null?void 0:u.z)??0:n.z??0},s)}function g4(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:l,z:u}=m4(s,e,{...s.position,z:((o=s[Ft])==null?void 0:o.z)??0},t);s.positionAbsolute={x:i,y:l},s[Ft].z=u,n!=null&&n[s.id]&&(s[Ft].isParent=!0)}})}function Fy(e,t,n,s){const a=new Map,o={},i=s?1e3:0;return e.forEach(l=>{var w;const u=(ys(l.zIndex)?l.zIndex:0)+(l.selected?i:0),h=t.get(l.id),f={...l,positionAbsolute:{x:l.position.x,y:l.position.y}},p=l.parentNode||l.parentId;p&&(o[p]=!0);const m=(h==null?void 0:h.type)&&(h==null?void 0:h.type)!==l.type;Object.defineProperty(f,Ft,{enumerable:!1,value:{handleBounds:m||(w=h==null?void 0:h[Ft])==null?void 0:w.handleBounds,z:u}}),a.set(l.id,f)}),g4(a,n,o),a}function y4(e,t={}){const{getNodes:n,width:s,height:a,minZoom:o,maxZoom:i,d3Zoom:l,d3Selection:u,fitViewOnInitDone:h,fitViewOnInit:f,nodeOrigin:p}=e(),m=t.initial&&!h&&f;if(l&&u&&(m||!t.initial)){const v=n().filter(b=>{var x;const N=t.includeHiddenNodes?b.width&&b.height:!b.hidden;return(x=t.nodes)!=null&&x.length?N&&t.nodes.some(S=>S.id===b.id):N}),j=v.every(b=>b.width&&b.height);if(v.length>0&&j){const b=Wp(v,p),{x:N,y:x,zoom:S}=n4(b,s,a,t.minZoom??o,t.maxZoom??i,t.padding??.1),C=ra.translate(N,x).scale(S);return typeof t.duration=="number"&&t.duration>0?l.transform(Go(u,t.duration),C):l.transform(u,C),!0}}return!1}function ez(e,t){return e.forEach(n=>{const s=t.get(n.id);s&&t.set(s.id,{...s,[Ft]:s[Ft],selected:n.selected})}),new Map(t)}function tz(e,t){return t.map(n=>{const s=e.find(a=>a.id===n.id);return s&&(n.selected=s.selected),n})}function Yh({changedNodes:e,changedEdges:t,get:n,set:s}){const{nodeInternals:a,edges:o,onNodesChange:i,onEdgesChange:l,hasDefaultNodes:u,hasDefaultEdges:h}=n();e!=null&&e.length&&(u&&s({nodeInternals:ez(e,a)}),i==null||i(e)),t!=null&&t.length&&(h&&s({edges:tz(t,o)}),l==null||l(t))}const al=()=>{},nz={zoomIn:al,zoomOut:al,zoomTo:al,getZoom:()=>1,setViewport:al,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:al,fitBounds:al,project:e=>e,screenToFlowPosition:e=>e,flowToScreenPosition:e=>e,viewportInitialized:!1},sz=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection}),rz=()=>{const e=Wt(),{d3Zoom:t,d3Selection:n}=ht(sz,Qt);return g.useMemo(()=>n&&t?{zoomIn:a=>t.scaleBy(Go(n,a==null?void 0:a.duration),1.2),zoomOut:a=>t.scaleBy(Go(n,a==null?void 0:a.duration),1/1.2),zoomTo:(a,o)=>t.scaleTo(Go(n,o==null?void 0:o.duration),a),getZoom:()=>e.getState().transform[2],setViewport:(a,o)=>{const[i,l,u]=e.getState().transform,h=ra.translate(a.x??i,a.y??l).scale(a.zoom??u);t.transform(Go(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=>y4(e.getState,a),setCenter:(a,o,i)=>{const{width:l,height:u,maxZoom:h}=e.getState(),f=typeof(i==null?void 0:i.zoom)<"u"?i.zoom:h,p=l/2-a*f,m=u/2-o*f,w=ra.translate(p,m).scale(f);t.transform(Go(n,i==null?void 0:i.duration),w)},fitBounds:(a,o)=>{const{width:i,height:l,minZoom:u,maxZoom:h}=e.getState(),{x:f,y:p,zoom:m}=n4(a,i,l,u,h,(o==null?void 0:o.padding)??.1),w=ra.translate(f,p).scale(m);t.transform(Go(n,o==null?void 0:o.duration),w)},project:a=>{const{transform:o,snapToGrid:i,snapGrid:l}=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"),d1(a,o,i,l)},screenToFlowPosition:a=>{const{transform:o,snapToGrid:i,snapGrid:l,domNode:u}=e.getState();if(!u)return a;const{x:h,y:f}=u.getBoundingClientRect(),p={x:a.x-h,y:a.y-f};return d1(p,o,i,l)},flowToScreenPosition:a=>{const{transform:o,domNode:i}=e.getState();if(!i)return a;const{x:l,y:u}=i.getBoundingClientRect(),h=Q3(a,o);return{x:h.x+l,y:h.y+u}},viewportInitialized:!0}:nz,[t,n])};function ec(){const e=rz(),t=Wt(),n=g.useCallback(()=>t.getState().getNodes().map(j=>({...j})),[]),s=g.useCallback(j=>t.getState().nodeInternals.get(j),[]),a=g.useCallback(()=>{const{edges:j=[]}=t.getState();return j.map(b=>({...b}))},[]),o=g.useCallback(j=>{const{edges:b=[]}=t.getState();return b.find(N=>N.id===j)},[]),i=g.useCallback(j=>{const{getNodes:b,setNodes:N,hasDefaultNodes:x,onNodesChange:S}=t.getState(),C=b(),_=typeof j=="function"?j(C):j;if(x)N(_);else if(S){const M=_.length===0?C.map(R=>({type:"remove",id:R.id})):_.map(R=>({item:R,type:"reset"}));S(M)}},[]),l=g.useCallback(j=>{const{edges:b=[],setEdges:N,hasDefaultEdges:x,onEdgesChange:S}=t.getState(),C=typeof j=="function"?j(b):j;if(x)N(C);else if(S){const _=C.length===0?b.map(M=>({type:"remove",id:M.id})):C.map(M=>({item:M,type:"reset"}));S(_)}},[]),u=g.useCallback(j=>{const b=Array.isArray(j)?j:[j],{getNodes:N,setNodes:x,hasDefaultNodes:S,onNodesChange:C}=t.getState();if(S){const M=[...N(),...b];x(M)}else if(C){const _=b.map(M=>({item:M,type:"add"}));C(_)}},[]),h=g.useCallback(j=>{const b=Array.isArray(j)?j:[j],{edges:N=[],setEdges:x,hasDefaultEdges:S,onEdgesChange:C}=t.getState();if(S)x([...N,...b]);else if(C){const _=b.map(M=>({item:M,type:"add"}));C(_)}},[]),f=g.useCallback(()=>{const{getNodes:j,edges:b=[],transform:N}=t.getState(),[x,S,C]=N;return{nodes:j().map(_=>({..._})),edges:b.map(_=>({..._})),viewport:{x,y:S,zoom:C}}},[]),p=g.useCallback(({nodes:j,edges:b})=>{const{nodeInternals:N,getNodes:x,edges:S,hasDefaultNodes:C,hasDefaultEdges:_,onNodesDelete:M,onEdgesDelete:R,onNodesChange:P,onEdgesChange:L}=t.getState(),U=(j||[]).map(F=>F.id),B=(b||[]).map(F=>F.id),A=x().reduce((F,O)=>{const K=O.parentNode||O.parentId,V=!U.includes(O.id)&&K&&F.find(D=>D.id===K);return(typeof O.deletable=="boolean"?O.deletable:!0)&&(U.includes(O.id)||V)&&F.push(O),F},[]),q=S.filter(F=>typeof F.deletable=="boolean"?F.deletable:!0),T=q.filter(F=>B.includes(F.id));if(A||T){const F=t4(A,q),O=[...T,...F],K=O.reduce((V,H)=>(V.includes(H.id)||V.push(H.id),V),[]);if((_||C)&&(_&&t.setState({edges:S.filter(V=>!K.includes(V.id))}),C&&(A.forEach(V=>{N.delete(V.id)}),t.setState({nodeInternals:new Map(N)}))),K.length>0&&(R==null||R(O),L&&L(K.map(V=>({id:V,type:"remove"})))),A.length>0&&(M==null||M(A),P)){const V=A.map(H=>({id:H.id,type:"remove"}));P(V)}}},[]),m=g.useCallback(j=>{const b=NH(j),N=b?null:t.getState().nodeInternals.get(j.id);return!b&&!N?[null,null,b]:[b?j:xE(N),N,b]},[]),w=g.useCallback((j,b=!0,N)=>{const[x,S,C]=m(j);return x?(N||t.getState().getNodes()).filter(_=>{if(!C&&(_.id===S.id||!_.positionAbsolute))return!1;const M=xE(_),R=i1(M,x);return b&&R>0||R>=x.width*x.height}):[]},[]),v=g.useCallback((j,b,N=!0)=>{const[x]=m(j);if(!x)return!1;const S=i1(x,b);return N&&S>0||S>=x.width*x.height},[]);return g.useMemo(()=>({...e,getNodes:n,getNode:s,getEdges:a,getEdge:o,setNodes:i,setEdges:l,addNodes:u,addEdges:h,toObject:f,deleteElements:p,getIntersectingNodes:w,isNodeIntersecting:v}),[e,n,s,a,o,i,l,u,h,f,p,w,v])}const az={actInsideInputWithModifier:!1};var oz=({deleteKeyCode:e,multiSelectionKeyCode:t})=>{const n=Wt(),{deleteElements:s}=ec(),a=zu(e,az),o=zu(t);g.useEffect(()=>{if(a){const{edges:i,getNodes:l}=n.getState(),u=l().filter(f=>f.selected),h=i.filter(f=>f.selected);s({nodes:u,edges:h}),n.setState({nodesSelectionActive:!1})}},[a]),g.useEffect(()=>{n.setState({multiSelectionActive:o})},[o])};function iz(e){const t=Wt();g.useEffect(()=>{let n;const s=()=>{var o,i;if(!e.current)return;const a=qj(e.current);(a.height===0||a.width===0)&&((i=(o=t.getState()).onError)==null||i.call(o,"004",ca.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 Xj={position:"absolute",width:"100%",height:"100%",top:0,left:0},lz=(e,t)=>e.x!==t.x||e.y!==t.y||e.zoom!==t.k,Xh=e=>({x:e.x,y:e.y,zoom:e.k}),ol=(e,t)=>e.target.closest(`.${t}`),TE=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),AE=e=>{const t=e.ctrlKey&&Kf()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t},cz=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),uz=({onMove:e,onMoveStart:t,onMoveEnd:n,onPaneContextMenu:s,zoomOnScroll:a=!0,zoomOnPinch:o=!0,panOnScroll:i=!1,panOnScrollSpeed:l=.5,panOnScrollMode:u=ei.Free,zoomOnDoubleClick:h=!0,elementsSelectable:f,panOnDrag:p=!0,defaultViewport:m,translateExtent:w,minZoom:v,maxZoom:j,zoomActivationKeyCode:b,preventScrolling:N=!0,children:x,noWheelClassName:S,noPanClassName:C})=>{const _=g.useRef(),M=Wt(),R=g.useRef(!1),P=g.useRef(!1),L=g.useRef(null),U=g.useRef({x:0,y:0,zoom:0}),{d3Zoom:B,d3Selection:A,d3ZoomHandler:q,userSelectionActive:T}=ht(cz,Qt),F=zu(b),O=g.useRef(0),K=g.useRef(!1),V=g.useRef();return iz(L),g.useEffect(()=>{if(L.current){const H=L.current.getBoundingClientRect(),D=U3().scaleExtent([v,j]).translateExtent(w),I=gs(L.current).call(D),W=ra.translate(m.x,m.y).scale(Wl(m.zoom,v,j)),Z=[[0,0],[H.width,H.height]],z=D.constrain()(W,Z,w);D.transform(I,z),D.wheelDelta(AE),M.setState({d3Zoom:D,d3Selection:I,d3ZoomHandler:I.on("wheel.zoom"),transform:[z.x,z.y,z.k],domNode:L.current.closest(".react-flow")})}},[]),g.useEffect(()=>{A&&B&&(i&&!F&&!T?A.on("wheel.zoom",H=>{if(ol(H,S))return!1;H.preventDefault(),H.stopImmediatePropagation();const D=A.property("__zoom").k||1;if(H.ctrlKey&&o){const Q=zs(H),te=AE(H),le=D*Math.pow(2,te);B.scaleTo(A,le,Q,H);return}const I=H.deltaMode===1?20:1;let W=u===ei.Vertical?0:H.deltaX*I,Z=u===ei.Horizontal?0:H.deltaY*I;!Kf()&&H.shiftKey&&u!==ei.Vertical&&(W=H.deltaY*I,Z=0),B.translateBy(A,-(W/D)*l,-(Z/D)*l,{internal:!0});const z=Xh(A.property("__zoom")),{onViewportChangeStart:X,onViewportChange:Y,onViewportChangeEnd:J}=M.getState();clearTimeout(V.current),K.current||(K.current=!0,t==null||t(H,z),X==null||X(z)),K.current&&(e==null||e(H,z),Y==null||Y(z),V.current=setTimeout(()=>{n==null||n(H,z),J==null||J(z),K.current=!1},150))},{passive:!1}):typeof q<"u"&&A.on("wheel.zoom",function(H,D){if(!N&&H.type==="wheel"&&!H.ctrlKey||ol(H,S))return null;H.preventDefault(),q.call(this,H,D)},{passive:!1}))},[T,i,u,A,B,q,F,o,N,S,t,e,n]),g.useEffect(()=>{B&&B.on("start",H=>{var W,Z;if(!H.sourceEvent||H.sourceEvent.internal)return null;O.current=(W=H.sourceEvent)==null?void 0:W.button;const{onViewportChangeStart:D}=M.getState(),I=Xh(H.transform);R.current=!0,U.current=I,((Z=H.sourceEvent)==null?void 0:Z.type)==="mousedown"&&M.setState({paneDragging:!0}),D==null||D(I),t==null||t(H.sourceEvent,I)})},[B,t]),g.useEffect(()=>{B&&(T&&!R.current?B.on("zoom",null):T||B.on("zoom",H=>{var I;const{onViewportChange:D}=M.getState();if(M.setState({transform:[H.transform.x,H.transform.y,H.transform.k]}),P.current=!!(s&&TE(p,O.current??0)),(e||D)&&!((I=H.sourceEvent)!=null&&I.internal)){const W=Xh(H.transform);D==null||D(W),e==null||e(H.sourceEvent,W)}}))},[T,B,e,p,s]),g.useEffect(()=>{B&&B.on("end",H=>{if(!H.sourceEvent||H.sourceEvent.internal)return null;const{onViewportChangeEnd:D}=M.getState();if(R.current=!1,M.setState({paneDragging:!1}),s&&TE(p,O.current??0)&&!P.current&&s(H.sourceEvent),P.current=!1,(n||D)&&lz(U.current,H.transform)){const I=Xh(H.transform);U.current=I,clearTimeout(_.current),_.current=setTimeout(()=>{D==null||D(I),n==null||n(H.sourceEvent,I)},i?150:0)}})},[B,i,p,n,s]),g.useEffect(()=>{B&&B.filter(H=>{const D=F||a,I=o&&H.ctrlKey;if((p===!0||Array.isArray(p)&&p.includes(1))&&H.button===1&&H.type==="mousedown"&&(ol(H,"react-flow__node")||ol(H,"react-flow__edge")))return!0;if(!p&&!D&&!i&&!h&&!o||T||!h&&H.type==="dblclick"||ol(H,S)&&H.type==="wheel"||ol(H,C)&&(H.type!=="wheel"||i&&H.type==="wheel"&&!F)||!o&&H.ctrlKey&&H.type==="wheel"||!D&&!i&&!I&&H.type==="wheel"||!p&&(H.type==="mousedown"||H.type==="touchstart")||Array.isArray(p)&&!p.includes(H.button)&&H.type==="mousedown")return!1;const W=Array.isArray(p)&&p.includes(H.button)||!H.button||H.button<=1;return(!H.ctrlKey||H.type==="wheel")&&W})},[T,B,a,o,i,h,p,f,F]),me.createElement("div",{className:"react-flow__renderer",ref:L,style:Xj},x)},dz=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function hz(){const{userSelectionActive:e,userSelectionRect:t}=ht(dz,Qt);return e&&t?me.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 RE(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 fz(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(l=>l.id===a.id);if(o.length===0)return s.push(a),s;const i={...a};for(const l of o)if(l)switch(l.type){case"select":{i.selected=l.selected;break}case"position":{typeof l.position<"u"&&(i.position=l.position),typeof l.positionAbsolute<"u"&&(i.positionAbsolute=l.positionAbsolute),typeof l.dragging<"u"&&(i.dragging=l.dragging),i.expandParent&&RE(s,i);break}case"dimensions":{typeof l.dimensions<"u"&&(i.width=l.dimensions.width,i.height=l.dimensions.height),typeof l.updateStyle<"u"&&(i.style={...i.style||{},...l.dimensions}),typeof l.resizing=="boolean"&&(i.resizing=l.resizing),i.expandParent&&RE(s,i);break}case"remove":return s}return s.push(i),s},n)}function pz(e,t){return fz(e,t)}const Va=(e,t)=>({id:e,type:"select",selected:t});function jl(e,t){return e.reduce((n,s)=>{const a=t.includes(s.id);return!s.selected&&a?(s.selected=!0,n.push(Va(s.id,!0))):s.selected&&!a&&(s.selected=!1,n.push(Va(s.id,!1))),n},[])}const By=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},mz=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),w4=g.memo(({isSelecting:e,selectionMode:t=Hu.Full,panOnDrag:n,onSelectionStart:s,onSelectionEnd:a,onPaneClick:o,onPaneContextMenu:i,onPaneScroll:l,onPaneMouseEnter:u,onPaneMouseMove:h,onPaneMouseLeave:f,children:p})=>{const m=g.useRef(null),w=Wt(),v=g.useRef(0),j=g.useRef(0),b=g.useRef(),{userSelectionActive:N,elementsSelectable:x,dragging:S}=ht(mz,Qt),C=()=>{w.setState({userSelectionActive:!1,userSelectionRect:null}),v.current=0,j.current=0},_=q=>{o==null||o(q),w.getState().resetSelectedElements(),w.setState({nodesSelectionActive:!1})},M=q=>{if(Array.isArray(n)&&(n!=null&&n.includes(2))){q.preventDefault();return}i==null||i(q)},R=l?q=>l(q):void 0,P=q=>{const{resetSelectedElements:T,domNode:F}=w.getState();if(b.current=F==null?void 0:F.getBoundingClientRect(),!x||!e||q.button!==0||q.target!==m.current||!b.current)return;const{x:O,y:K}=eo(q,b.current);T(),w.setState({userSelectionRect:{width:0,height:0,startX:O,startY:K,x:O,y:K}}),s==null||s(q)},L=q=>{const{userSelectionRect:T,nodeInternals:F,edges:O,transform:K,onNodesChange:V,onEdgesChange:H,nodeOrigin:D,getNodes:I}=w.getState();if(!e||!b.current||!T)return;w.setState({userSelectionActive:!0,nodesSelectionActive:!1});const W=eo(q,b.current),Z=T.startX??0,z=T.startY??0,X={...T,x:W.x<Z?W.x:Z,y:W.y<z?W.y:z,width:Math.abs(W.x-Z),height:Math.abs(W.y-z)},Y=I(),J=e4(F,X,K,t===Hu.Partial,!0,D),Q=t4(J,O).map(le=>le.id),te=J.map(le=>le.id);if(v.current!==te.length){v.current=te.length;const le=jl(Y,te);le.length&&(V==null||V(le))}if(j.current!==Q.length){j.current=Q.length;const le=jl(O,Q);le.length&&(H==null||H(le))}w.setState({userSelectionRect:X})},U=q=>{if(q.button!==0)return;const{userSelectionRect:T}=w.getState();!N&&T&&q.target===m.current&&(_==null||_(q)),w.setState({nodesSelectionActive:v.current>0}),C(),a==null||a(q)},B=q=>{N&&(w.setState({nodesSelectionActive:v.current>0}),a==null||a(q)),C()},A=x&&(e||N);return me.createElement("div",{className:un(["react-flow__pane",{dragging:S,selection:e}]),onClick:A?void 0:By(_,m),onContextMenu:By(M,m),onWheel:By(R,m),onMouseEnter:A?void 0:u,onMouseDown:A?P:void 0,onMouseMove:A?L:h,onMouseUp:A?U:void 0,onMouseLeave:A?B:f,ref:m,style:Xj},p,me.createElement(hz,null))});w4.displayName="Pane";function x4(e,t){const n=e.parentNode||e.parentId;if(!n)return!1;const s=t.get(n);return s?s.selected?!0:x4(s,t):!1}function ME(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 gz(e,t,n,s){return Array.from(e.values()).filter(a=>(a.selected||a.id===s)&&(!a.parentNode||a.parentId||!x4(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 yz(e,t){return!t||t==="parent"?t:[t[0],[t[1][0]-(e.width||0),t[1][1]-(e.height||0)]]}function v4(e,t,n,s,a=[0,0],o){const i=yz(e,e.extent||s);let l=i;const u=e.parentNode||e.parentId;if(e.extent==="parent"&&!e.expandParent)if(u&&e.width&&e.height){const p=n.get(u),{x:m,y:w}=ri(p,a).positionAbsolute;l=p&&ys(m)&&ys(w)&&ys(p.width)&&ys(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]]]:l}else o==null||o("005",ca.error005()),l=i;else if(e.extent&&u&&e.extent!=="parent"){const p=n.get(u),{x:m,y:w}=ri(p,a).positionAbsolute;l=[[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(u){const p=n.get(u);h=ri(p,a).positionAbsolute}const f=l&&l!=="parent"?Uj(t,l):t;return{position:{x:f.x-h.x,y:f.y-h.y},positionAbsolute:f}}function qy({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 $E=(e,t,n,s)=>{const a=t.querySelectorAll(e);if(!a||!a.length)return null;const o=Array.from(a),i=t.getBoundingClientRect(),l={x:i.width*s[0],y:i.height*s[1]};return o.map(u=>{const h=u.getBoundingClientRect();return{id:u.getAttribute("data-handleid"),position:u.getAttribute("data-handlepos"),x:(h.left-i.left-l.x)/n,y:(h.top-i.top-l.y)/n,...qj(u)}})};function ru(e,t,n){return n===void 0?n:s=>{const a=t().nodeInternals.get(e);a&&n(s,{...a})}}function f1({id:e,store:t,unselect:n=!1,nodeRef:s}){const{addSelectedNodes:a,unselectNodesAndEdges:o,multiSelectionActive:i,nodeInternals:l,onError:u}=t.getState(),h=l.get(e);if(!h){u==null||u("012",ca.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 wz(){const e=Wt();return g.useCallback(({sourceEvent:n})=>{const{transform:s,snapGrid:a,snapToGrid:o}=e.getState(),i=n.touches?n.touches[0].clientX:n.clientX,l=n.touches?n.touches[0].clientY:n.clientY,u={x:(i-s[0])/s[2],y:(l-s[1])/s[2]};return{xSnapped:o?a[0]*Math.round(u.x/a[0]):u.x,ySnapped:o?a[1]*Math.round(u.y/a[1]):u.y,...u}},[])}function Uy(e){return(t,n,s)=>e==null?void 0:e(t,s)}function b4({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:s,nodeId:a,isSelectable:o,selectNodesOnDrag:i}){const l=Wt(),[u,h]=g.useState(!1),f=g.useRef([]),p=g.useRef({x:null,y:null}),m=g.useRef(0),w=g.useRef(null),v=g.useRef({x:0,y:0}),j=g.useRef(null),b=g.useRef(!1),N=g.useRef(!1),x=g.useRef(!1),S=wz();return g.useEffect(()=>{if(e!=null&&e.current){const C=gs(e.current),_=({x:P,y:L})=>{const{nodeInternals:U,onNodeDrag:B,onSelectionDrag:A,updateNodePositions:q,nodeExtent:T,snapGrid:F,snapToGrid:O,nodeOrigin:K,onError:V}=l.getState();p.current={x:P,y:L};let H=!1,D={x:0,y:0,x2:0,y2:0};if(f.current.length>1&&T){const W=Wp(f.current,K);D=Wu(W)}if(f.current=f.current.map(W=>{const Z={x:P-W.distance.x,y:L-W.distance.y};O&&(Z.x=F[0]*Math.round(Z.x/F[0]),Z.y=F[1]*Math.round(Z.y/F[1]));const z=[[T[0][0],T[0][1]],[T[1][0],T[1][1]]];f.current.length>1&&T&&!W.extent&&(z[0][0]=W.positionAbsolute.x-D.x+T[0][0],z[1][0]=W.positionAbsolute.x+(W.width??0)-D.x2+T[1][0],z[0][1]=W.positionAbsolute.y-D.y+T[0][1],z[1][1]=W.positionAbsolute.y+(W.height??0)-D.y2+T[1][1]);const X=v4(W,Z,U,z,K,V);return H=H||W.position.x!==X.position.x||W.position.y!==X.position.y,W.position=X.position,W.positionAbsolute=X.positionAbsolute,W}),!H)return;q(f.current,!0,!0),h(!0);const I=a?B:Uy(A);if(I&&j.current){const[W,Z]=qy({nodeId:a,dragItems:f.current,nodeInternals:U});I(j.current,W,Z)}},M=()=>{if(!w.current)return;const[P,L]=H3(v.current,w.current);if(P!==0||L!==0){const{transform:U,panBy:B}=l.getState();p.current.x=(p.current.x??0)-P/U[2],p.current.y=(p.current.y??0)-L/U[2],B({x:P,y:L})&&_(p.current)}m.current=requestAnimationFrame(M)},R=P=>{var K;const{nodeInternals:L,multiSelectionActive:U,nodesDraggable:B,unselectNodesAndEdges:A,onNodeDragStart:q,onSelectionDragStart:T}=l.getState();N.current=!0;const F=a?q:Uy(T);(!i||!o)&&!U&&a&&((K=L.get(a))!=null&&K.selected||A()),a&&o&&i&&f1({id:a,store:l,nodeRef:e});const O=S(P);if(p.current=O,f.current=gz(L,B,O,a),F&&f.current){const[V,H]=qy({nodeId:a,dragItems:f.current,nodeInternals:L});F(P.sourceEvent,V,H)}};if(t)C.on(".drag",null);else{const P=EW().on("start",L=>{const{domNode:U,nodeDragThreshold:B}=l.getState();B===0&&R(L),x.current=!1;const A=S(L);p.current=A,w.current=(U==null?void 0:U.getBoundingClientRect())||null,v.current=eo(L.sourceEvent,w.current)}).on("drag",L=>{var q,T;const U=S(L),{autoPanOnNodeDrag:B,nodeDragThreshold:A}=l.getState();if(L.sourceEvent.type==="touchmove"&&L.sourceEvent.touches.length>1&&(x.current=!0),!x.current){if(!b.current&&N.current&&B&&(b.current=!0,M()),!N.current){const F=U.xSnapped-(((q=p==null?void 0:p.current)==null?void 0:q.x)??0),O=U.ySnapped-(((T=p==null?void 0:p.current)==null?void 0:T.y)??0);Math.sqrt(F*F+O*O)>A&&R(L)}(p.current.x!==U.xSnapped||p.current.y!==U.ySnapped)&&f.current&&N.current&&(j.current=L.sourceEvent,v.current=eo(L.sourceEvent,w.current),_(U))}}).on("end",L=>{if(!(!N.current||x.current)&&(h(!1),b.current=!1,N.current=!1,cancelAnimationFrame(m.current),f.current)){const{updateNodePositions:U,nodeInternals:B,onNodeDragStop:A,onSelectionDragStop:q}=l.getState(),T=a?A:Uy(q);if(U(f.current,!1,!1),T){const[F,O]=qy({nodeId:a,dragItems:f.current,nodeInternals:B});T(L.sourceEvent,F,O)}}}).filter(L=>{const U=L.target;return!L.button&&(!n||!ME(U,`.${n}`,e))&&(!s||ME(U,s,e))});return C.call(P),()=>{C.on(".drag",null)}}}},[e,t,n,s,o,l,a,i,S]),u}function k4(){const e=Wt();return g.useCallback(n=>{const{nodeInternals:s,nodeExtent:a,updateNodePositions:o,getNodes:i,snapToGrid:l,snapGrid:u,onError:h,nodesDraggable:f}=e.getState(),p=i().filter(x=>x.selected&&(x.draggable||f&&typeof x.draggable>"u")),m=l?u[0]:5,w=l?u[1]:5,v=n.isShiftPressed?4:1,j=n.x*m*v,b=n.y*w*v,N=p.map(x=>{if(x.positionAbsolute){const S={x:x.positionAbsolute.x+j,y:x.positionAbsolute.y+b};l&&(S.x=u[0]*Math.round(S.x/u[0]),S.y=u[1]*Math.round(S.y/u[1]));const{positionAbsolute:C,position:_}=v4(x,S,s,a,void 0,h);x.position=_,x.positionAbsolute=C}return x});o(N,!0,!1)},[])}const Ml={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var au=e=>{const t=({id:n,type:s,data:a,xPos:o,yPos:i,xPosOrigin:l,yPosOrigin:u,selected:h,onClick:f,onMouseEnter:p,onMouseMove:m,onMouseLeave:w,onContextMenu:v,onDoubleClick:j,style:b,className:N,isDraggable:x,isSelectable:S,isConnectable:C,isFocusable:_,selectNodesOnDrag:M,sourcePosition:R,targetPosition:P,hidden:L,resizeObserver:U,dragHandle:B,zIndex:A,isParent:q,noDragClassName:T,noPanClassName:F,initialized:O,disableKeyboardA11y:K,ariaLabel:V,rfId:H,hasHandleBounds:D})=>{const I=Wt(),W=g.useRef(null),Z=g.useRef(null),z=g.useRef(R),X=g.useRef(P),Y=g.useRef(s),J=S||x||f||p||m||w,Q=k4(),te=ru(n,I.getState,p),le=ru(n,I.getState,m),de=ru(n,I.getState,w),oe=ru(n,I.getState,v),re=ru(n,I.getState,j),he=ge=>{const{nodeDragThreshold:ve}=I.getState();if(S&&(!M||!x||ve>0)&&f1({id:n,store:I,nodeRef:W}),f){const je=I.getState().nodeInternals.get(n);je&&f(ge,{...je})}},pe=ge=>{if(!l1(ge)&&!K)if(K3.includes(ge.key)&&S){const ve=ge.key==="Escape";f1({id:n,store:I,unselect:ve,nodeRef:W})}else x&&h&&Object.prototype.hasOwnProperty.call(Ml,ge.key)&&(I.setState({ariaLiveMessage:`Moved selected node ${ge.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~o}, y: ${~~i}`}),Q({x:Ml[ge.key].x,y:Ml[ge.key].y,isShiftPressed:ge.shiftKey}))};g.useEffect(()=>()=>{Z.current&&(U==null||U.unobserve(Z.current),Z.current=null)},[]),g.useEffect(()=>{if(W.current&&!L){const ge=W.current;(!O||!D||Z.current!==ge)&&(Z.current&&(U==null||U.unobserve(Z.current)),U==null||U.observe(ge),Z.current=ge)}},[L,O,D]),g.useEffect(()=>{const ge=Y.current!==s,ve=z.current!==R,je=X.current!==P;W.current&&(ge||ve||je)&&(ge&&(Y.current=s),ve&&(z.current=R),je&&(X.current=P),I.getState().updateNodeDimensions([{id:n,nodeElement:W.current,forceUpdate:!0}]))},[n,s,R,P]);const Le=b4({nodeRef:W,disabled:L||!x,noDragClassName:T,handleSelector:B,nodeId:n,isSelectable:S,selectNodesOnDrag:M});return L?null:me.createElement("div",{className:un(["react-flow__node",`react-flow__node-${s}`,{[F]:x},N,{selected:h,selectable:S,parent:q,dragging:Le}]),ref:W,style:{zIndex:A,transform:`translate(${l}px,${u}px)`,pointerEvents:J?"all":"none",visibility:O?"visible":"hidden",...b},"data-id":n,"data-testid":`rf__node-${n}`,onMouseEnter:te,onMouseMove:le,onMouseLeave:de,onContextMenu:oe,onClick:he,onDoubleClick:re,onKeyDown:_?pe:void 0,tabIndex:_?0:void 0,role:_?"button":void 0,"aria-describedby":K?void 0:`${f4}-${H}`,"aria-label":V},me.createElement(RH,{value:n},me.createElement(e,{id:n,data:a,type:s,xPos:o,yPos:i,selected:h,isConnectable:C,sourcePosition:R,targetPosition:P,dragging:Le,dragHandle:B,zIndex:A})))};return t.displayName="NodeWrapper",g.memo(t)};const xz=e=>{const t=e.getNodes().filter(n=>n.selected);return{...Wp(t,e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive}};function vz({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const s=Wt(),{width:a,height:o,x:i,y:l,transformString:u,userSelectionActive:h}=ht(xz,Qt),f=k4(),p=g.useRef(null);if(g.useEffect(()=>{var v;n||(v=p.current)==null||v.focus({preventScroll:!0})},[n]),b4({nodeRef:p}),h||!a||!o)return null;const m=e?v=>{const j=s.getState().getNodes().filter(b=>b.selected);e(v,j)}:void 0,w=v=>{Object.prototype.hasOwnProperty.call(Ml,v.key)&&f({x:Ml[v.key].x,y:Ml[v.key].y,isShiftPressed:v.shiftKey})};return me.createElement("div",{className:un(["react-flow__nodesselection","react-flow__container",t]),style:{transform:u}},me.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:l,left:i}}))}var bz=g.memo(vz);const kz=e=>e.nodesSelectionActive,j4=({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:o,onPaneScroll:i,deleteKeyCode:l,onMove:u,onMoveStart:h,onMoveEnd:f,selectionKeyCode:p,selectionOnDrag:m,selectionMode:w,onSelectionStart:v,onSelectionEnd:j,multiSelectionKeyCode:b,panActivationKeyCode:N,zoomActivationKeyCode:x,elementsSelectable:S,zoomOnScroll:C,zoomOnPinch:_,panOnScroll:M,panOnScrollSpeed:R,panOnScrollMode:P,zoomOnDoubleClick:L,panOnDrag:U,defaultViewport:B,translateExtent:A,minZoom:q,maxZoom:T,preventScrolling:F,onSelectionContextMenu:O,noWheelClassName:K,noPanClassName:V,disableKeyboardA11y:H})=>{const D=ht(kz),I=zu(p),W=zu(N),Z=W||U,z=W||M,X=I||m&&Z!==!0;return oz({deleteKeyCode:l,multiSelectionKeyCode:b}),me.createElement(uz,{onMove:u,onMoveStart:h,onMoveEnd:f,onPaneContextMenu:o,elementsSelectable:S,zoomOnScroll:C,zoomOnPinch:_,panOnScroll:z,panOnScrollSpeed:R,panOnScrollMode:P,zoomOnDoubleClick:L,panOnDrag:!I&&Z,defaultViewport:B,translateExtent:A,minZoom:q,maxZoom:T,zoomActivationKeyCode:x,preventScrolling:F,noWheelClassName:K,noPanClassName:V},me.createElement(w4,{onSelectionStart:v,onSelectionEnd:j,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:o,onPaneScroll:i,panOnDrag:Z,isSelecting:!!X,selectionMode:w},e,D&&me.createElement(bz,{onSelectionContextMenu:O,noPanClassName:V,disableKeyboardA11y:H})))};j4.displayName="FlowRenderer";var jz=g.memo(j4);function Nz(e){return ht(g.useCallback(n=>e?e4(n.nodeInternals,{x:0,y:0,width:n.width,height:n.height},n.transform,!0):n.getNodes(),[e]))}function Sz(e){const t={input:au(e.input||c4),default:au(e.default||h1),output:au(e.output||d4),group:au(e.group||Yj)},n={},s=Object.keys(e).filter(a=>!["input","default","output","group"].includes(a)).reduce((a,o)=>(a[o]=au(e[o]||h1),a),n);return{...t,...s}}const Cz=({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]},_z=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),N4=e=>{const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:s,elementsSelectable:a,updateNodeDimensions:o,onError:i}=ht(_z,Qt),l=Nz(e.onlyRenderVisibleElements),u=g.useRef(),h=g.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 u.current=f,f},[]);return g.useEffect(()=>()=>{var f;(f=u==null?void 0:u.current)==null||f.disconnect()},[]),me.createElement("div",{className:"react-flow__nodes",style:Xj},l.map(f=>{var _,M,R;let p=f.type||"default";e.nodeTypes[p]||(i==null||i("003",ca.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"),j=!!(f.connectable||n&&typeof f.connectable>"u"),b=!!(f.focusable||s&&typeof f.focusable>"u"),N=e.nodeExtent?Uj(f.positionAbsolute,e.nodeExtent):f.positionAbsolute,x=(N==null?void 0:N.x)??0,S=(N==null?void 0:N.y)??0,C=Cz({x,y:S,width:f.width??0,height:f.height??0,origin:e.nodeOrigin});return me.createElement(m,{key:f.id,id:f.id,className:f.className,style:f.style,type:p,data:f.data,sourcePosition:f.sourcePosition||Ye.Bottom,targetPosition:f.targetPosition||Ye.Top,hidden:f.hidden,xPos:x,yPos:S,xPosOrigin:C.x,yPosOrigin:C.y,selectNodesOnDrag:e.selectNodesOnDrag,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,selected:!!f.selected,isDraggable:w,isSelectable:v,isConnectable:j,isFocusable:b,resizeObserver:h,dragHandle:f.dragHandle,zIndex:((_=f[Ft])==null?void 0:_.z)??0,isParent:!!((M=f[Ft])!=null&&M.isParent),noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,initialized:!!f.width&&!!f.height,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,ariaLabel:f.ariaLabel,hasHandleBounds:!!((R=f[Ft])!=null&&R.handleBounds)})}))};N4.displayName="NodeRenderer";var Ez=g.memo(N4);const Tz=(e,t,n)=>n===Ye.Left?e-t:n===Ye.Right?e+t:e,Az=(e,t,n)=>n===Ye.Top?e-t:n===Ye.Bottom?e+t:e,LE="react-flow__edgeupdater",IE=({position:e,centerX:t,centerY:n,radius:s=10,onMouseDown:a,onMouseEnter:o,onMouseOut:i,type:l})=>me.createElement("circle",{onMouseDown:a,onMouseEnter:o,onMouseOut:i,className:un([LE,`${LE}-${l}`]),cx:Tz(t,s,e),cy:Az(n,s,e),r:s,stroke:"transparent",fill:"transparent"}),Rz=()=>!0;var il=e=>{const t=({id:n,className:s,type:a,data:o,onClick:i,onEdgeDoubleClick:l,selected:u,animated:h,label:f,labelStyle:p,labelShowBg:m,labelBgStyle:w,labelBgPadding:v,labelBgBorderRadius:j,style:b,source:N,target:x,sourceX:S,sourceY:C,targetX:_,targetY:M,sourcePosition:R,targetPosition:P,elementsSelectable:L,hidden:U,sourceHandleId:B,targetHandleId:A,onContextMenu:q,onMouseEnter:T,onMouseMove:F,onMouseLeave:O,reconnectRadius:K,onReconnect:V,onReconnectStart:H,onReconnectEnd:D,markerEnd:I,markerStart:W,rfId:Z,ariaLabel:z,isFocusable:X,isReconnectable:Y,pathOptions:J,interactionWidth:Q,disableKeyboardA11y:te})=>{const le=g.useRef(null),[de,oe]=g.useState(!1),[re,he]=g.useState(!1),pe=Wt(),Le=g.useMemo(()=>`url('#${u1(W,Z)}')`,[W,Z]),ge=g.useMemo(()=>`url('#${u1(I,Z)}')`,[I,Z]);if(U)return null;const ve=He=>{var fe;const{edges:se,addSelectedEdges:ke,unselectNodesAndEdges:Ae,multiSelectionActive:Oe}=pe.getState(),be=se.find(_e=>_e.id===n);be&&(L&&(pe.setState({nodesSelectionActive:!1}),be.selected&&Oe?(Ae({nodes:[],edges:[be]}),(fe=le.current)==null||fe.blur()):ke([n])),i&&i(He,be))},je=su(n,pe.getState,l),Ee=su(n,pe.getState,q),xe=su(n,pe.getState,T),Ie=su(n,pe.getState,F),De=su(n,pe.getState,O),We=(He,se)=>{if(He.button!==0)return;const{edges:ke,isValidConnection:Ae}=pe.getState(),Oe=se?x:N,be=(se?A:B)||null,fe=se?"target":"source",_e=Ae||Rz,Ve=se,ot=ke.find($t=>$t.id===n);he(!0),H==null||H(He,ot,fe);const tt=$t=>{he(!1),D==null||D($t,ot,fe)};a4({event:He,handleId:be,nodeId:Oe,onConnect:$t=>V==null?void 0:V(ot,$t),isTarget:Ve,getState:pe.getState,setState:pe.setState,isValidConnection:_e,edgeUpdaterType:fe,onReconnectEnd:tt})},Ke=He=>We(He,!0),ye=He=>We(He,!1),Fe=()=>oe(!0),$e=()=>oe(!1),Re=!L&&!i,rt=He=>{var se;if(!te&&K3.includes(He.key)&&L){const{unselectNodesAndEdges:ke,addSelectedEdges:Ae,edges:Oe}=pe.getState();He.key==="Escape"?((se=le.current)==null||se.blur(),ke({edges:[Oe.find(fe=>fe.id===n)]})):Ae([n])}};return me.createElement("g",{className:un(["react-flow__edge",`react-flow__edge-${a}`,s,{selected:u,animated:h,inactive:Re,updating:de}]),onClick:ve,onDoubleClick:je,onContextMenu:Ee,onMouseEnter:xe,onMouseMove:Ie,onMouseLeave:De,onKeyDown:X?rt:void 0,tabIndex:X?0:void 0,role:X?"button":"img","data-testid":`rf__edge-${n}`,"aria-label":z===null?void 0:z||`Edge from ${N} to ${x}`,"aria-describedby":X?`${p4}-${Z}`:void 0,ref:le},!re&&me.createElement(e,{id:n,source:N,target:x,selected:u,animated:h,label:f,labelStyle:p,labelShowBg:m,labelBgStyle:w,labelBgPadding:v,labelBgBorderRadius:j,data:o,style:b,sourceX:S,sourceY:C,targetX:_,targetY:M,sourcePosition:R,targetPosition:P,sourceHandleId:B,targetHandleId:A,markerStart:Le,markerEnd:ge,pathOptions:J,interactionWidth:Q}),Y&&me.createElement(me.Fragment,null,(Y==="source"||Y===!0)&&me.createElement(IE,{position:R,centerX:S,centerY:C,radius:K,onMouseDown:Ke,onMouseEnter:Fe,onMouseOut:$e,type:"source"}),(Y==="target"||Y===!0)&&me.createElement(IE,{position:P,centerX:_,centerY:M,radius:K,onMouseDown:ye,onMouseEnter:Fe,onMouseOut:$e,type:"target"})))};return t.displayName="EdgeWrapper",g.memo(t)};function Mz(e){const t={default:il(e.default||Xf),straight:il(e.bezier||zj),step:il(e.step||Hj),smoothstep:il(e.step||Up),simplebezier:il(e.simplebezier||Wj)},n={},s=Object.keys(e).filter(a=>!["default","bezier"].includes(a)).reduce((a,o)=>(a[o]=il(e[o]||Xf),a),n);return{...t,...s}}function OE(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 Ye.Top:return{x:s+o/2,y:a};case Ye.Right:return{x:s+o,y:a+i/2};case Ye.Bottom:return{x:s+o/2,y:a+i};case Ye.Left:return{x:s,y:a+i/2}}}function PE(e,t){return e?e.length===1||!t?e[0]:t&&e.find(n=>n.id===t)||null:null}const $z=(e,t,n,s,a,o)=>{const i=OE(n,e,t),l=OE(o,s,a);return{sourceX:i.x,sourceY:i.y,targetX:l.x,targetY:l.y}};function Lz({sourcePos:e,targetPos:t,sourceWidth:n,sourceHeight:s,targetWidth:a,targetHeight:o,width:i,height:l,transform:u}){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=Wu({x:(0-u[0])/u[2],y:(0-u[1])/u[2],width:i/u[2],height:l/u[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 DE(e){var s,a,o,i,l;const t=((s=e==null?void 0:e[Ft])==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:((l=e==null?void 0:e.positionAbsolute)==null?void 0:l.y)||0,width:(e==null?void 0:e.width)||0,height:(e==null?void 0:e.height)||0},t,!!n]}const Iz=[{level:0,isMaxLevel:!0,edges:[]}];function Oz(e,t,n=!1){let s=-1;const a=e.reduce((i,l)=>{var f,p;const u=ys(l.zIndex);let h=u?l.zIndex:0;if(n){const m=t.get(l.target),w=t.get(l.source),v=l.selected||(m==null?void 0:m.selected)||(w==null?void 0:w.selected),j=Math.max(((f=w==null?void 0:w[Ft])==null?void 0:f.z)||0,((p=m==null?void 0:m[Ft])==null?void 0:p.z)||0,1e3);h=(u?l.zIndex:0)+(v?j:0)}return i[h]?i[h].push(l):i[h]=[l],s=h>s?h:s,i},{}),o=Object.entries(a).map(([i,l])=>{const u=+i;return{edges:l,level:u,isMaxLevel:u===s}});return o.length===0?Iz:o}function Pz(e,t,n){const s=ht(g.useCallback(a=>e?a.edges.filter(o=>{const i=t.get(o.source),l=t.get(o.target);return(i==null?void 0:i.width)&&(i==null?void 0:i.height)&&(l==null?void 0:l.width)&&(l==null?void 0:l.height)&&Lz({sourcePos:i.positionAbsolute||{x:0,y:0},targetPos:l.positionAbsolute||{x:0,y:0},sourceWidth:i.width,sourceHeight:i.height,targetWidth:l.width,targetHeight:l.height,width:a.width,height:a.height,transform:a.transform})}):a.edges,[e,t]));return Oz(s,t,n)}const Dz=({color:e="none",strokeWidth:t=1})=>me.createElement("polyline",{style:{stroke:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",fill:"none",points:"-5,-4 0,0 -5,4"}),Fz=({color:e="none",strokeWidth:t=1})=>me.createElement("polyline",{style:{stroke:e,fill:e,strokeWidth:t},strokeLinecap:"round",strokeLinejoin:"round",points:"-5,-4 0,0 -5,4 -5,-4"}),FE={[Yf.Arrow]:Dz,[Yf.ArrowClosed]:Fz};function Bz(e){const t=Wt();return g.useMemo(()=>{var a,o;return Object.prototype.hasOwnProperty.call(FE,e)?FE[e]:((o=(a=t.getState()).onError)==null||o.call(a,"009",ca.error009(e)),null)},[e])}const qz=({id:e,type:t,color:n,width:s=12.5,height:a=12.5,markerUnits:o="strokeWidth",strokeWidth:i,orient:l="auto-start-reverse"})=>{const u=Bz(t);return u?me.createElement("marker",{className:"react-flow__arrowhead",id:e,markerWidth:`${s}`,markerHeight:`${a}`,viewBox:"-10 -10 20 20",markerUnits:o,orient:l,refX:"0",refY:"0"},me.createElement(u,{color:n,strokeWidth:i})):null},Uz=({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 l=u1(i,t);s.includes(l)||(a.push({id:l,color:i.color||e,...i}),s.push(l))}}),a),[]).sort((a,o)=>a.id.localeCompare(o.id))},S4=({defaultColor:e,rfId:t})=>{const n=ht(g.useCallback(Uz({defaultColor:e,rfId:t}),[e,t]),(s,a)=>!(s.length!==a.length||s.some((o,i)=>o.id!==a[i].id)));return me.createElement("defs",null,n.map(s=>me.createElement(qz,{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})))};S4.displayName="MarkerDefinitions";var Wz=g.memo(S4);const Hz=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}),C4=({defaultMarkerColor:e,onlyRenderVisibleElements:t,elevateEdgesOnSelect:n,rfId:s,edgeTypes:a,noPanClassName:o,onEdgeContextMenu:i,onEdgeMouseEnter:l,onEdgeMouseMove:u,onEdgeMouseLeave:h,onEdgeClick:f,onEdgeDoubleClick:p,onReconnect:m,onReconnectStart:w,onReconnectEnd:v,reconnectRadius:j,children:b,disableKeyboardA11y:N})=>{const{edgesFocusable:x,edgesUpdatable:S,elementsSelectable:C,width:_,height:M,connectionMode:R,nodeInternals:P,onError:L}=ht(Hz,Qt),U=Pz(t,P,n);return _?me.createElement(me.Fragment,null,U.map(({level:B,edges:A,isMaxLevel:q})=>me.createElement("svg",{key:B,style:{zIndex:B},width:_,height:M,className:"react-flow__edges react-flow__container"},q&&me.createElement(Wz,{defaultColor:e,rfId:s}),me.createElement("g",null,A.map(T=>{const[F,O,K]=DE(P.get(T.source)),[V,H,D]=DE(P.get(T.target));if(!K||!D)return null;let I=T.type||"default";a[I]||(L==null||L("011",ca.error011(I)),I="default");const W=a[I]||a.default,Z=R===hi.Strict?H.target:(H.target??[]).concat(H.source??[]),z=PE(O.source,T.sourceHandle),X=PE(Z,T.targetHandle),Y=(z==null?void 0:z.position)||Ye.Bottom,J=(X==null?void 0:X.position)||Ye.Top,Q=!!(T.focusable||x&&typeof T.focusable>"u"),te=T.reconnectable||T.updatable,le=typeof m<"u"&&(te||S&&typeof te>"u");if(!z||!X)return L==null||L("008",ca.error008(z,T)),null;const{sourceX:de,sourceY:oe,targetX:re,targetY:he}=$z(F,z,Y,V,X,J);return me.createElement(W,{key:T.id,id:T.id,className:un([T.className,o]),type:I,data:T.data,selected:!!T.selected,animated:!!T.animated,hidden:!!T.hidden,label:T.label,labelStyle:T.labelStyle,labelShowBg:T.labelShowBg,labelBgStyle:T.labelBgStyle,labelBgPadding:T.labelBgPadding,labelBgBorderRadius:T.labelBgBorderRadius,style:T.style,source:T.source,target:T.target,sourceHandleId:T.sourceHandle,targetHandleId:T.targetHandle,markerEnd:T.markerEnd,markerStart:T.markerStart,sourceX:de,sourceY:oe,targetX:re,targetY:he,sourcePosition:Y,targetPosition:J,elementsSelectable:C,onContextMenu:i,onMouseEnter:l,onMouseMove:u,onMouseLeave:h,onClick:f,onEdgeDoubleClick:p,onReconnect:m,onReconnectStart:w,onReconnectEnd:v,reconnectRadius:j,rfId:s,ariaLabel:T.ariaLabel,isFocusable:Q,isReconnectable:le,pathOptions:"pathOptions"in T?T.pathOptions:void 0,interactionWidth:T.interactionWidth,disableKeyboardA11y:N})})))),b):null};C4.displayName="EdgeRenderer";var zz=g.memo(C4);const Vz=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function Gz({children:e}){const t=ht(Vz);return me.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:t}},e)}function Kz(e){const t=ec(),n=g.useRef(!1);g.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const Yz={[Ye.Left]:Ye.Right,[Ye.Right]:Ye.Left,[Ye.Top]:Ye.Bottom,[Ye.Bottom]:Ye.Top},_4=({nodeId:e,handleType:t,style:n,type:s=Ka.Bezier,CustomComponent:a,connectionStatus:o})=>{var M,R,P;const{fromNode:i,handleId:l,toX:u,toY:h,connectionMode:f}=ht(g.useCallback(L=>({fromNode:L.nodeInternals.get(e),handleId:L.connectionHandleId,toX:(L.connectionPosition.x-L.transform[0])/L.transform[2],toY:(L.connectionPosition.y-L.transform[1])/L.transform[2],connectionMode:L.connectionMode}),[e]),Qt),p=(M=i==null?void 0:i[Ft])==null?void 0:M.handleBounds;let m=p==null?void 0:p[t];if(f===hi.Loose&&(m=m||(p==null?void 0:p[t==="source"?"target":"source"])),!i||!m)return null;const w=l?m.find(L=>L.id===l):m[0],v=w?w.x+w.width/2:(i.width??0)/2,j=w?w.y+w.height/2:i.height??0,b=(((R=i.positionAbsolute)==null?void 0:R.x)??0)+v,N=(((P=i.positionAbsolute)==null?void 0:P.y)??0)+j,x=w==null?void 0:w.position,S=x?Yz[x]:null;if(!x||!S)return null;if(a)return me.createElement(a,{connectionLineType:s,connectionLineStyle:n,fromNode:i,fromHandle:w,fromX:b,fromY:N,toX:u,toY:h,fromPosition:x,toPosition:S,connectionStatus:o});let C="";const _={sourceX:b,sourceY:N,sourcePosition:x,targetX:u,targetY:h,targetPosition:S};return s===Ka.Bezier?[C]=Vj(_):s===Ka.Step?[C]=c1({..._,borderRadius:0}):s===Ka.SmoothStep?[C]=c1(_):s===Ka.SimpleBezier?[C]=J3(_):C=`M${b},${N} ${u},${h}`,me.createElement("path",{d:C,fill:"none",className:"react-flow__connection-path",style:n})};_4.displayName="ConnectionLine";const Xz=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function Zz({containerStyle:e,style:t,type:n,component:s}){const{nodeId:a,handleType:o,nodesConnectable:i,width:l,height:u,connectionStatus:h}=ht(Xz,Qt);return!(a&&o&&l&&i)?null:me.createElement("svg",{style:e,width:l,height:u,className:"react-flow__edges react-flow__connectionline react-flow__container"},me.createElement("g",{className:un(["react-flow__connection",h])},me.createElement(_4,{nodeId:a,handleType:o,style:t,type:n,CustomComponent:s,connectionStatus:h})))}function BE(e,t){return g.useRef(null),Wt(),g.useMemo(()=>t(e),[e])}const E4=({nodeTypes:e,edgeTypes:t,onMove:n,onMoveStart:s,onMoveEnd:a,onInit:o,onNodeClick:i,onEdgeClick:l,onNodeDoubleClick:u,onEdgeDoubleClick:h,onNodeMouseEnter:f,onNodeMouseMove:p,onNodeMouseLeave:m,onNodeContextMenu:w,onSelectionContextMenu:v,onSelectionStart:j,onSelectionEnd:b,connectionLineType:N,connectionLineStyle:x,connectionLineComponent:S,connectionLineContainerStyle:C,selectionKeyCode:_,selectionOnDrag:M,selectionMode:R,multiSelectionKeyCode:P,panActivationKeyCode:L,zoomActivationKeyCode:U,deleteKeyCode:B,onlyRenderVisibleElements:A,elementsSelectable:q,selectNodesOnDrag:T,defaultViewport:F,translateExtent:O,minZoom:K,maxZoom:V,preventScrolling:H,defaultMarkerColor:D,zoomOnScroll:I,zoomOnPinch:W,panOnScroll:Z,panOnScrollSpeed:z,panOnScrollMode:X,zoomOnDoubleClick:Y,panOnDrag:J,onPaneClick:Q,onPaneMouseEnter:te,onPaneMouseMove:le,onPaneMouseLeave:de,onPaneScroll:oe,onPaneContextMenu:re,onEdgeContextMenu:he,onEdgeMouseEnter:pe,onEdgeMouseMove:Le,onEdgeMouseLeave:ge,onReconnect:ve,onReconnectStart:je,onReconnectEnd:Ee,reconnectRadius:xe,noDragClassName:Ie,noWheelClassName:De,noPanClassName:We,elevateEdgesOnSelect:Ke,disableKeyboardA11y:ye,nodeOrigin:Fe,nodeExtent:$e,rfId:Re})=>{const rt=BE(e,Sz),He=BE(t,Mz);return Kz(o),me.createElement(jz,{onPaneClick:Q,onPaneMouseEnter:te,onPaneMouseMove:le,onPaneMouseLeave:de,onPaneContextMenu:re,onPaneScroll:oe,deleteKeyCode:B,selectionKeyCode:_,selectionOnDrag:M,selectionMode:R,onSelectionStart:j,onSelectionEnd:b,multiSelectionKeyCode:P,panActivationKeyCode:L,zoomActivationKeyCode:U,elementsSelectable:q,onMove:n,onMoveStart:s,onMoveEnd:a,zoomOnScroll:I,zoomOnPinch:W,zoomOnDoubleClick:Y,panOnScroll:Z,panOnScrollSpeed:z,panOnScrollMode:X,panOnDrag:J,defaultViewport:F,translateExtent:O,minZoom:K,maxZoom:V,onSelectionContextMenu:v,preventScrolling:H,noDragClassName:Ie,noWheelClassName:De,noPanClassName:We,disableKeyboardA11y:ye},me.createElement(Gz,null,me.createElement(zz,{edgeTypes:He,onEdgeClick:l,onEdgeDoubleClick:h,onlyRenderVisibleElements:A,onEdgeContextMenu:he,onEdgeMouseEnter:pe,onEdgeMouseMove:Le,onEdgeMouseLeave:ge,onReconnect:ve,onReconnectStart:je,onReconnectEnd:Ee,reconnectRadius:xe,defaultMarkerColor:D,noPanClassName:We,elevateEdgesOnSelect:!!Ke,disableKeyboardA11y:ye,rfId:Re},me.createElement(Zz,{style:x,type:N,component:S,containerStyle:C})),me.createElement("div",{className:"react-flow__edgelabel-renderer"}),me.createElement(Ez,{nodeTypes:rt,onNodeClick:i,onNodeDoubleClick:u,onNodeMouseEnter:f,onNodeMouseMove:p,onNodeMouseLeave:m,onNodeContextMenu:w,selectNodesOnDrag:T,onlyRenderVisibleElements:A,noPanClassName:We,noDragClassName:Ie,disableKeyboardA11y:ye,nodeOrigin:Fe,nodeExtent:$e,rfId:Re})))};E4.displayName="GraphView";var Jz=g.memo(E4);const p1=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],qa={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:p1,nodeExtent:p1,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:hi.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:SH,isValidConnection:void 0},Qz=()=>Bq((e,t)=>({...qa,setNodes:n=>{const{nodeInternals:s,nodeOrigin:a,elevateNodesOnSelect:o}=t();e({nodeInternals:Fy(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?Fy(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:l,domNode:u,nodeOrigin:h}=t(),f=u==null?void 0:u.querySelector(".react-flow__viewport");if(!f)return;const p=window.getComputedStyle(f),{m22:m}=new window.DOMMatrixReadOnly(p.transform),w=n.reduce((j,b)=>{const N=a.get(b.id);if(N!=null&&N.hidden)a.set(N.id,{...N,[Ft]:{...N[Ft],handleBounds:void 0}});else if(N){const x=qj(b.nodeElement);!!(x.width&&x.height&&(N.width!==x.width||N.height!==x.height||b.forceUpdate))&&(a.set(N.id,{...N,[Ft]:{...N[Ft],handleBounds:{source:$E(".source",b.nodeElement,m,h),target:$E(".target",b.nodeElement,m,h)}},...x}),j.push({id:N.id,type:"dimensions",dimensions:x}))}return j},[]);g4(a,h);const v=i||o&&!i&&y4(t,{initial:!0,...l});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(l=>{const u={id:l.id,type:"position",dragging:a};return s&&(u.positionAbsolute=l.positionAbsolute,u.position=l.position),u});o(i)},triggerNodeChanges:n=>{const{onNodesChange:s,nodeInternals:a,hasDefaultNodes:o,nodeOrigin:i,getNodes:l,elevateNodesOnSelect:u}=t();if(n!=null&&n.length){if(o){const h=pz(n,l()),f=Fy(h,a,i,u);e({nodeInternals:f})}s==null||s(n)}},addSelectedNodes:n=>{const{multiSelectionActive:s,edges:a,getNodes:o}=t();let i,l=null;s?i=n.map(u=>Va(u,!0)):(i=jl(o(),n),l=jl(a,[])),Yh({changedNodes:i,changedEdges:l,get:t,set:e})},addSelectedEdges:n=>{const{multiSelectionActive:s,edges:a,getNodes:o}=t();let i,l=null;s?i=n.map(u=>Va(u,!0)):(i=jl(a,n),l=jl(o(),[])),Yh({changedNodes:l,changedEdges:i,get:t,set:e})},unselectNodesAndEdges:({nodes:n,edges:s}={})=>{const{edges:a,getNodes:o}=t(),i=n||o(),l=s||a,u=i.map(f=>(f.selected=!1,Va(f.id,!1))),h=l.map(f=>Va(f.id,!1));Yh({changedNodes:u,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(l=>l.selected).map(l=>Va(l.id,!1)),i=n.filter(l=>l.selected).map(l=>Va(l.id,!1));Yh({changedNodes:o,changedEdges:i,get:t,set:e})},setNodeExtent:n=>{const{nodeInternals:s}=t();s.forEach(a=>{a.positionAbsolute=Uj(a.position,n)}),e({nodeExtent:n,nodeInternals:new Map(s)})},panBy:n=>{const{transform:s,width:a,height:o,d3Zoom:i,d3Selection:l,translateExtent:u}=t();if(!i||!l||!n.x&&!n.y)return!1;const h=ra.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,u);return i.transform(l,p),s[0]!==p.x||s[1]!==p.y||s[2]!==p.k},cancelConnection:()=>e({connectionNodeId:qa.connectionNodeId,connectionHandleId:qa.connectionHandleId,connectionHandleType:qa.connectionHandleType,connectionStatus:qa.connectionStatus,connectionStartHandle:qa.connectionStartHandle,connectionEndHandle:qa.connectionEndHandle}),reset:()=>e({...qa})}),Object.is),Zj=({children:e})=>{const t=g.useRef(null);return t.current||(t.current=Qz()),me.createElement(wH,{value:t.current},e)};Zj.displayName="ReactFlowProvider";const T4=({children:e})=>g.useContext(qp)?me.createElement(me.Fragment,null,e):me.createElement(Zj,null,e);T4.displayName="ReactFlowWrapper";const e9={input:c4,default:h1,output:d4,group:Yj},t9={default:Xf,straight:zj,step:Hj,smoothstep:Up,simplebezier:Wj},n9=[0,0],s9=[15,15],r9={x:0,y:0,zoom:1},a9={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},A4=g.forwardRef(({nodes:e,edges:t,defaultNodes:n,defaultEdges:s,className:a,nodeTypes:o=e9,edgeTypes:i=t9,onNodeClick:l,onEdgeClick:u,onInit:h,onMove:f,onMoveStart:p,onMoveEnd:m,onConnect:w,onConnectStart:v,onConnectEnd:j,onClickConnectStart:b,onClickConnectEnd:N,onNodeMouseEnter:x,onNodeMouseMove:S,onNodeMouseLeave:C,onNodeContextMenu:_,onNodeDoubleClick:M,onNodeDragStart:R,onNodeDrag:P,onNodeDragStop:L,onNodesDelete:U,onEdgesDelete:B,onSelectionChange:A,onSelectionDragStart:q,onSelectionDrag:T,onSelectionDragStop:F,onSelectionContextMenu:O,onSelectionStart:K,onSelectionEnd:V,connectionMode:H=hi.Strict,connectionLineType:D=Ka.Bezier,connectionLineStyle:I,connectionLineComponent:W,connectionLineContainerStyle:Z,deleteKeyCode:z="Backspace",selectionKeyCode:X="Shift",selectionOnDrag:Y=!1,selectionMode:J=Hu.Full,panActivationKeyCode:Q="Space",multiSelectionKeyCode:te=Kf()?"Meta":"Control",zoomActivationKeyCode:le=Kf()?"Meta":"Control",snapToGrid:de=!1,snapGrid:oe=s9,onlyRenderVisibleElements:re=!1,selectNodesOnDrag:he=!0,nodesDraggable:pe,nodesConnectable:Le,nodesFocusable:ge,nodeOrigin:ve=n9,edgesFocusable:je,edgesUpdatable:Ee,elementsSelectable:xe,defaultViewport:Ie=r9,minZoom:De=.5,maxZoom:We=2,translateExtent:Ke=p1,preventScrolling:ye=!0,nodeExtent:Fe,defaultMarkerColor:$e="#b1b1b7",zoomOnScroll:Re=!0,zoomOnPinch:rt=!0,panOnScroll:He=!1,panOnScrollSpeed:se=.5,panOnScrollMode:ke=ei.Free,zoomOnDoubleClick:Ae=!0,panOnDrag:Oe=!0,onPaneClick:be,onPaneMouseEnter:fe,onPaneMouseMove:_e,onPaneMouseLeave:Ve,onPaneScroll:ot,onPaneContextMenu:tt,children:wt,onEdgeContextMenu:$t,onEdgeDoubleClick:Vt,onEdgeMouseEnter:er,onEdgeMouseMove:Ss,onEdgeMouseLeave:Wn,onEdgeUpdate:es,onEdgeUpdateStart:Cs,onEdgeUpdateEnd:yn,onReconnect:Hn,onReconnectStart:Me,onReconnectEnd:qe,reconnectRadius:Je=10,edgeUpdaterRadius:_t=10,onNodesChange:Nt,onEdgesChange:ts,noDragClassName:zn="nodrag",noWheelClassName:wn="nowheel",noPanClassName:Cr="nopan",fitView:xn=!1,fitViewOptions:rn,connectOnClick:_s=!0,attributionPosition:tr,proOptions:ns,defaultEdgeOptions:Es,elevateNodesOnSelect:_r=!0,elevateEdgesOnSelect:Er=!1,disableKeyboardA11y:Ts=!1,autoPanOnConnect:ga=!0,autoPanOnNodeDrag:xt=!0,connectionRadius:ya=20,isValidConnection:As,onError:wa,style:nr,id:Tr,nodeDragThreshold:Ar,...Rs},dn)=>{const Lt=Tr||"1";return me.createElement("div",{...Rs,style:{...nr,...a9},ref:dn,className:un(["react-flow",a]),"data-testid":"rf__wrapper",id:Tr},me.createElement(T4,null,me.createElement(Jz,{onInit:h,onMove:f,onMoveStart:p,onMoveEnd:m,onNodeClick:l,onEdgeClick:u,onNodeMouseEnter:x,onNodeMouseMove:S,onNodeMouseLeave:C,onNodeContextMenu:_,onNodeDoubleClick:M,nodeTypes:o,edgeTypes:i,connectionLineType:D,connectionLineStyle:I,connectionLineComponent:W,connectionLineContainerStyle:Z,selectionKeyCode:X,selectionOnDrag:Y,selectionMode:J,deleteKeyCode:z,multiSelectionKeyCode:te,panActivationKeyCode:Q,zoomActivationKeyCode:le,onlyRenderVisibleElements:re,selectNodesOnDrag:he,defaultViewport:Ie,translateExtent:Ke,minZoom:De,maxZoom:We,preventScrolling:ye,zoomOnScroll:Re,zoomOnPinch:rt,zoomOnDoubleClick:Ae,panOnScroll:He,panOnScrollSpeed:se,panOnScrollMode:ke,panOnDrag:Oe,onPaneClick:be,onPaneMouseEnter:fe,onPaneMouseMove:_e,onPaneMouseLeave:Ve,onPaneScroll:ot,onPaneContextMenu:tt,onSelectionContextMenu:O,onSelectionStart:K,onSelectionEnd:V,onEdgeContextMenu:$t,onEdgeDoubleClick:Vt,onEdgeMouseEnter:er,onEdgeMouseMove:Ss,onEdgeMouseLeave:Wn,onReconnect:Hn??es,onReconnectStart:Me??Cs,onReconnectEnd:qe??yn,reconnectRadius:Je??_t,defaultMarkerColor:$e,noDragClassName:zn,noWheelClassName:wn,noPanClassName:Cr,elevateEdgesOnSelect:Er,rfId:Lt,disableKeyboardA11y:Ts,nodeOrigin:ve,nodeExtent:Fe}),me.createElement(KH,{nodes:e,edges:t,defaultNodes:n,defaultEdges:s,onConnect:w,onConnectStart:v,onConnectEnd:j,onClickConnectStart:b,onClickConnectEnd:N,nodesDraggable:pe,nodesConnectable:Le,nodesFocusable:ge,edgesFocusable:je,edgesUpdatable:Ee,elementsSelectable:xe,elevateNodesOnSelect:_r,minZoom:De,maxZoom:We,nodeExtent:Fe,onNodesChange:Nt,onEdgesChange:ts,snapToGrid:de,snapGrid:oe,connectionMode:H,translateExtent:Ke,connectOnClick:_s,defaultEdgeOptions:Es,fitView:xn,fitViewOptions:rn,onNodesDelete:U,onEdgesDelete:B,onNodeDragStart:R,onNodeDrag:P,onNodeDragStop:L,onSelectionDrag:T,onSelectionDragStart:q,onSelectionDragStop:F,noPanClassName:Cr,nodeOrigin:ve,rfId:Lt,autoPanOnConnect:ga,autoPanOnNodeDrag:xt,onError:wa,connectionRadius:ya,isValidConnection:As,nodeDragThreshold:Ar}),me.createElement(VH,{onSelectionChange:A}),wt,me.createElement(vH,{proOptions:ns,position:tr}),me.createElement(QH,{rfId:Lt,disableKeyboardA11y:Ts})))});A4.displayName="ReactFlow";const o9=e=>({x:e.transform[0],y:e.transform[1],zoom:e.transform[2]});function R4(){return ht(o9,Qt)}const M4=({id:e,x:t,y:n,width:s,height:a,style:o,color:i,strokeColor:l,strokeWidth:u,className:h,borderRadius:f,shapeRendering:p,onClick:m,selected:w})=>{const{background:v,backgroundColor:j}=o||{},b=i||v||j;return me.createElement("rect",{className:un(["react-flow__minimap-node",{selected:w},h]),x:t,y:n,rx:f,ry:f,width:s,height:a,fill:b,stroke:l,strokeWidth:u,shapeRendering:p,onClick:m?N=>m(N,e):void 0})};M4.displayName="MiniMapNode";var i9=g.memo(M4);const l9=e=>e.nodeOrigin,c9=e=>e.getNodes().filter(t=>!t.hidden&&t.width&&t.height),Wy=e=>e instanceof Function?e:()=>e;function u9({nodeStrokeColor:e="transparent",nodeColor:t="#e2e2e2",nodeClassName:n="",nodeBorderRadius:s=5,nodeStrokeWidth:a=2,nodeComponent:o=i9,onClick:i}){const l=ht(c9,Qt),u=ht(l9),h=Wy(t),f=Wy(e),p=Wy(n),m=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return me.createElement(me.Fragment,null,l.map(w=>{const{x:v,y:j}=ri(w,u).positionAbsolute;return me.createElement(o,{key:w.id,x:v,y:j,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 d9=g.memo(u9);const h9=200,f9=150,p9=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?jH(Wp(t,e.nodeOrigin),n):n,rfId:e.rfId}},m9="react-flow__minimap-desc";function $4({style:e,className:t,nodeStrokeColor:n="transparent",nodeColor:s="#e2e2e2",nodeClassName:a="",nodeBorderRadius:o=5,nodeStrokeWidth:i=2,nodeComponent:l,maskColor:u="rgb(240, 240, 240, 0.6)",maskStrokeColor:h="none",maskStrokeWidth:f=1,position:p="bottom-right",onClick:m,onNodeClick:w,pannable:v=!1,zoomable:j=!1,ariaLabel:b="React Flow mini map",inversePan:N=!1,zoomStep:x=10,offsetScale:S=5}){const C=Wt(),_=g.useRef(null),{boundingRect:M,viewBB:R,rfId:P}=ht(p9,Qt),L=(e==null?void 0:e.width)??h9,U=(e==null?void 0:e.height)??f9,B=M.width/L,A=M.height/U,q=Math.max(B,A),T=q*L,F=q*U,O=S*q,K=M.x-(T-M.width)/2-O,V=M.y-(F-M.height)/2-O,H=T+O*2,D=F+O*2,I=`${m9}-${P}`,W=g.useRef(0);W.current=q,g.useEffect(()=>{if(_.current){const X=gs(_.current),Y=te=>{const{transform:le,d3Selection:de,d3Zoom:oe}=C.getState();if(te.sourceEvent.type!=="wheel"||!de||!oe)return;const re=-te.sourceEvent.deltaY*(te.sourceEvent.deltaMode===1?.05:te.sourceEvent.deltaMode?1:.002)*x,he=le[2]*Math.pow(2,re);oe.scaleTo(de,he)},J=te=>{const{transform:le,d3Selection:de,d3Zoom:oe,translateExtent:re,width:he,height:pe}=C.getState();if(te.sourceEvent.type!=="mousemove"||!de||!oe)return;const Le=W.current*Math.max(1,le[2])*(N?-1:1),ge={x:le[0]-te.sourceEvent.movementX*Le,y:le[1]-te.sourceEvent.movementY*Le},ve=[[0,0],[he,pe]],je=ra.translate(ge.x,ge.y).scale(le[2]),Ee=oe.constrain()(je,ve,re);oe.transform(de,Ee)},Q=U3().on("zoom",v?J:null).on("zoom.wheel",j?Y:null);return X.call(Q),()=>{X.on("zoom",null)}}},[v,j,N,x]);const Z=m?X=>{const Y=zs(X);m(X,{x:Y[0],y:Y[1]})}:void 0,z=w?(X,Y)=>{const J=C.getState().nodeInternals.get(Y);w(X,J)}:void 0;return me.createElement(Bj,{position:p,style:e,className:un(["react-flow__minimap",t]),"data-testid":"rf__minimap"},me.createElement("svg",{width:L,height:U,viewBox:`${K} ${V} ${H} ${D}`,role:"img","aria-labelledby":I,ref:_,onClick:Z},b&&me.createElement("title",{id:I},b),me.createElement(d9,{onClick:z,nodeColor:s,nodeStrokeColor:n,nodeBorderRadius:o,nodeClassName:a,nodeStrokeWidth:i,nodeComponent:l}),me.createElement("path",{className:"react-flow__minimap-mask",d:`M${K-O},${V-O}h${H+O*2}v${D+O*2}h${-H-O*2}z
|
|
57
|
+
M${R.x},${R.y}h${R.width}v${R.height}h${-R.width}z`,fill:u,fillRule:"evenodd",stroke:h,strokeWidth:f,pointerEvents:"none"})))}$4.displayName="MiniMap";var g9=g.memo($4);function y9(){return me.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 32"},me.createElement("path",{d:"M32 18.133H18.133V32h-4.266V18.133H0v-4.266h13.867V0h4.266v13.867H32z"}))}function w9(){return me.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},me.createElement("path",{d:"M0 0h32v4.2H0z"}))}function x9(){return me.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 30"},me.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 v9(){return me.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},me.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 b9(){return me.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},me.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 fs=({children:e,className:t,...n})=>me.createElement("button",{type:"button",className:un(["react-flow__controls-button",t]),...n},e);fs.displayName="ControlButton";const k9=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),L4=({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:s=!0,fitViewOptions:a,onZoomIn:o,onZoomOut:i,onFitView:l,onInteractiveChange:u,className:h,children:f,position:p="bottom-left"})=>{const m=Wt(),[w,v]=g.useState(!1),{isInteractive:j,minZoomReached:b,maxZoomReached:N}=ht(k9,Qt),{zoomIn:x,zoomOut:S,fitView:C}=ec();if(g.useEffect(()=>{v(!0)},[]),!w)return null;const _=()=>{x(),o==null||o()},M=()=>{S(),i==null||i()},R=()=>{C(a),l==null||l()},P=()=>{m.setState({nodesDraggable:!j,nodesConnectable:!j,elementsSelectable:!j}),u==null||u(!j)};return me.createElement(Bj,{className:un(["react-flow__controls",h]),position:p,style:e,"data-testid":"rf__controls"},t&&me.createElement(me.Fragment,null,me.createElement(fs,{onClick:_,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:N},me.createElement(y9,null)),me.createElement(fs,{onClick:M,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:b},me.createElement(w9,null))),n&&me.createElement(fs,{className:"react-flow__controls-fitview",onClick:R,title:"fit view","aria-label":"fit view"},me.createElement(x9,null)),s&&me.createElement(fs,{className:"react-flow__controls-interactive",onClick:P,title:"toggle interactivity","aria-label":"toggle interactivity"},j?me.createElement(b9,null):me.createElement(v9,null)),f)};L4.displayName="Controls";var j9=g.memo(L4),Ks;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Ks||(Ks={}));function N9({color:e,dimensions:t,lineWidth:n}){return me.createElement("path",{stroke:e,strokeWidth:n,d:`M${t[0]/2} 0 V${t[1]} M0 ${t[1]/2} H${t[0]}`})}function S9({color:e,radius:t}){return me.createElement("circle",{cx:t,cy:t,r:t,fill:e})}const C9={[Ks.Dots]:"#91919a",[Ks.Lines]:"#eee",[Ks.Cross]:"#e2e2e2"},_9={[Ks.Dots]:1,[Ks.Lines]:1,[Ks.Cross]:6},E9=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function I4({id:e,variant:t=Ks.Dots,gap:n=20,size:s,lineWidth:a=1,offset:o=2,color:i,style:l,className:u}){const h=g.useRef(null),{transform:f,patternId:p}=ht(E9,Qt),m=i||C9[t],w=s||_9[t],v=t===Ks.Dots,j=t===Ks.Cross,b=Array.isArray(n)?n:[n,n],N=[b[0]*f[2]||1,b[1]*f[2]||1],x=w*f[2],S=j?[x,x]:N,C=v?[x/o,x/o]:[S[0]/o,S[1]/o];return me.createElement("svg",{className:un(["react-flow__background",u]),style:{...l,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:h,"data-testid":"rf__background"},me.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(-${C[0]},-${C[1]})`},v?me.createElement(S9,{color:m,radius:x/o}):me.createElement(N9,{dimensions:S,color:m,lineWidth:a})),me.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${p+e})`}))}I4.displayName="Background";var T9=g.memo(I4);function A9(e,t){return e?t==="gone"?"entering":t==="leaving"?"here":t:t==="gone"?"gone":"leaving"}function Za(e){return e!=="gone"}function qE(e,t){return e||Za(t)}function UE(e,t){return!e&&Za(t)}function Nl(e,t){const[n,s]=g.useState(()=>e?"here":"gone"),a=g.useRef(null);return g.useEffect(()=>{s(o=>A9(e,o))},[e]),g.useEffect(()=>{if(n==="leaving")return a.current=window.setTimeout(()=>s("gone"),t),()=>{a.current!=null&&window.clearTimeout(a.current)}},[n,t]),g.useEffect(()=>{n==="entering"&&s("here")},[n]),n}const O4=.2,P4=1.6;function R9(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<O4||a>P4?null:{x:n,y:s,zoom:a}}function m1({durationMs:e,documentHidden:t,reducedMotion:n=pd()}){return t||n?!1:Number.isFinite(e)&&e>0}function pd(){return typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches}function Jj(){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 fa(e,t){return`${e}::${t}`}function tc(e,t){return`${e}\0${t}`}const M9=/[0-9a-f]{16,}/i,$9=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function D4(e){return M9.test(e)||$9.test(e)}function L9(e){if(!e)return;const t=e.replace(/\\/g,"/").split("/").filter(Boolean);for(let n=t.length-1;n>=0;n--)if(!D4(t[n]))return t[n];return t[t.length-1]}function F4(){return{inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0}}function B4(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 Hp(e){const t=B4(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=Hp({...e.longContext,longContext:void 0})),n}function I9(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]=Hp(a);const o=O9(a.speeds);o&&(t[n].bySpeed=o)}return Object.keys(t).length?t:void 0}function O9(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,Hp(s)]);return t.length?Object.fromEntries(t):void 0}function q4(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),...B4(n)};for(const s of Object.values(n)){const a=q4(s,t+1);if(a)return a}return null}function Qj(e){return L9(e)}function eN(e){const t=e.agent_type??e.subagent_type;return t&&!D4(t)?t:"subagent"}function nc(e){return e.agent_id?e.agent_id:e.parent_tool_use_id?e.parent_tool_use_id:null}function pi(e,t){!e.cwd&&t.cwd&&(e.cwd=t.cwd,e.cwdBasename=Qj(t.cwd))}function tN(e,t){e.label==="session"&&t.cwd&&(e.label=Qj(t.cwd)??"session")}function U4(e,t){const n=eN(t);n&&(e.label==="subagent"||!e.label)&&(e.label=n)}function uo(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:F4()},e.agents.set(a,o),o)}function W4(e,t,n,s){const a=fa(t,n),o=e.agents.get(a);return o?(pi(o,s),U4(o,s),o):null}function P9(e,t,n){var h;const s=t.session_id??"unknown",a=nc(t);if(a){const f=W4(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),l=i&&i.length>0?i[i.length-1]:null;if(l){const f=e.agents.get(fa(s,l));if(f)return pi(f,t),f}const u=uo(e,s,n,t.hook_event_name!=="SessionStart");return pi(u,t),tN(u,t),u}function D9(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 F9(e,t,n,s,a){const o=fa(t,n),i=uo(e,t,a,!0);let l=e.agents.get(o);if(l)return pi(l,s),U4(l,s),l;l={id:o,sessionId:t,label:eN(s),kind:"subagent",parentId:i.id,state:"active",startedAt:a,tools:[],prompts:[],cwd:s.cwd,cwdBasename:Qj(s.cwd),toolCount:0,childCount:0,usage:F4()},e.agents.set(o,l);const u=e.pendingSubagentModels.get(o);return u&&(l.model=u,e.pendingSubagentModels.delete(o)),i.childCount+=1,l}function B9(e,t,n){const s=e.activeSubagentStack.get(t)??[];s.includes(n)||(s.push(n),e.activeSubagentStack.set(t,s))}function H4(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 q9=new Set(["PreToolUse","PostToolUse","PostToolUseFailure","Stop","SubagentStop"]),z4=/^[a-z][a-z0-9_-]{0,23}$/i;function U9(e,t){if(t.provider==="codex")return;const n=t.effort&&typeof t.effort=="object"?t.effort.level:void 0;return typeof n=="string"&&z4.test(n)?n:q9.has(e)?null:void 0}function V4(){return{msgsUser:0,msgsAssistant:0,toolUses:0,toolResults:0,systemReminders:0,currentContextTokens:0,memoryFiles:[]}}function nN(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"&&z4.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??V4(),currentContextTokens:t.context_tokens})}}const W9=6e4,WE=64;function G4(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 l=fa(n,o),u=e.agents.get(l);if(u)u.model=i,e.pendingSubagentModels.delete(l);else if(e.pendingSubagentModels.delete(l),e.pendingSubagentModels.set(l,i),e.pendingSubagentModels.size>256){const h=e.pendingSubagentModels.keys().next().value;h!==void 0&&e.pendingSubagentModels.delete(h)}}}function K4(e,t,n){const s=t.context??null;if(s){const a=e.agents.get(n);if(a){const o=a.context??V4(),i=(u,h)=>typeof s[u]=="number"?s[u]:h,l=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:l??o.memoryFiles}}}}function Y4(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 H9(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 X4(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 z9=new Set(["working","blocked","done","failed","stopped"]);function Z4(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"||!z9.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 V9(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 l=(i.outputs??[]).filter(u=>o-u<W9);l.push(o),i.outputs=l.length>WE?l.slice(-WE):l}e.revision+=1}}function sN(e,t,n){const s=t.usage??null;if(s){const a=e.agents.get(n);if(a){const o=Hp(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=I9(t.usageByModel))}}}function Zt(e,t){return Object.hasOwn(e,t)?e[t]:void 0}const G9=/^\s*<task-notification>([\s\S]*?)<\/task-notification>/;function HE(e,t){var n;return((n=new RegExp(`<${t}>([\\s\\S]*?)</${t}>`).exec(e))==null?void 0:n[1].trim())||void 0}const K9={completed:"background task finished",failed:"background task failed",killed:"background task stopped"};function zp(e){const t=G9.exec(e);if(!t)return null;const n=HE(t[1],"status");return{label:(n?Zt(K9,n):void 0)??"background task update",detail:HE(t[1],"summary")}}function J4(e){return e.filter(t=>!zp(t.text))}const zE=2e3;function Y9(e,t,n){for(let s=e.length-1;s>=0;s--){const a=e[s];if(a.at<t-zE)return!1;if(a.text===n&&a.at<=t+zE)return!0}return!1}function X9(e,t,n){if(Y9(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 Zf=2e3;function Z9(e){const t=e.prompts[e.prompts.length-1];return t&&t.at>e.startedAt?t.at:e.startedAt}const VE=["B","KB","MB","GB","TB"];function ea(e){if(e==null||!Number.isFinite(e)||e<0)return"—";if(e===0)return"0 B";let t=e,n=0;for(;n<VE.length-1&&Number(t.toFixed(1))>=1024;)t/=1024,n++;return`${t.toFixed(1)} ${VE[n]}`}const J9=60,Q9=6e3,xs=e=>e!=null&&typeof e=="object"&&!Array.isArray(e),Xn=e=>typeof e=="string"?e:null;function eV(e){return xs(e)&&e.ccdeck_truncated===!0&&typeof e.chars=="number"&&Object.keys(e).length===2?e.chars:null}function Hl(e){const t=eV(e);if(t!=null)return`(too large to show — ${ea(t)}, cut by the hook)`;if(Array.isArray(e)){const n=e.map(Hl);return n.some((s,a)=>s!==e[a])?n:e}if(xs(e)){let n=!1;const s={};for(const[a,o]of Object.entries(e))s[a]=Hl(o),s[a]!==o&&(n=!0);return n?s:e}return e}function mi(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 l=n?`${t}-`:`${t}${o}:`;if(typeof i=="string"&&i.includes(`
|
|
58
|
+
`)){a.push(l);for(const u of i.split(`
|
|
59
|
+
`))a.push(`${t} ${u}`)}else if(i!==null&&typeof i=="object"){const u=mi(i,`${t} `);u==="[]"||u==="{}"?a.push(`${l} ${u}`):a.push(l,u)}else a.push(`${l} ${i===void 0?"(none)":String(i)}`)}return a.join(`
|
|
60
|
+
`)}function tV(e){return e.lines??e.text.split(`
|
|
61
|
+
`).map(t=>({text:t}))}function Q4(e,t){if(t)return{shown:e,cut:!1};const n=[];let s=0;for(const a of e){if(n.length===J9)return{shown:n,cut:!0};const o=Q9-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 nV(e,t){return Q4(e,!1).cut?t?{label:"show less",expanded:!0}:{label:"show all",expanded:!1}:null}const Nn=(e,t,n=!1)=>({...e?{label:e}:{},text:t,...n?{err:!0}:{}}),Zn=(e,t)=>({label:e,text:t,inline:!0}),eP=(e,t)=>({label:e,text:t.map(n=>n.text).join(`
|
|
62
|
+
`),lines:t});function sV(e,t){return[...e.split(`
|
|
63
|
+
`).map(n=>({text:`- ${n}`,tone:"del"})),...t.split(`
|
|
64
|
+
`).map(n=>({text:`+ ${n}`,tone:"add"}))]}function rV(e){if(!Array.isArray(e)||e.length===0)return null;const t=[];for(const n of e){if(!xs(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 GE(e){if(typeof e=="string")return[Nn(void 0,e)];if(!xs(e))return[Nn(void 0,mi(e))];const t=[],n=Xn(e.type);n==="create"&&t.push(Zn("result","created the file"));const s=rV(e.structuredPatch);return s&&t.push(eP("applied",s)),e.userModified===!0&&t.push(Zn("note","the user changed it before it was applied")),t.length?t:[Zn("result",n==="update"?"updated the file":"done")]}function aV(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 oV(e){if(typeof e=="string")return[Nn(void 0,e)];const t=xs(e)&&xs(e.file)?e.file:null,n=Xn(t==null?void 0:t.content);if(t&&n!=null){const a=[],o=Number(t.numLines),i=Number(t.totalLines),l=Number(t.startLine);return Number.isFinite(o)&&Number.isFinite(i)&&i>0&&a.push(Zn("lines",o>=i?`all ${i}`:Number.isFinite(l)?`${l}–${l+o-1} of ${i}`:`${o} of ${i}`)),a.push(Nn("content",n)),a}const s=xs(e)?Xn(e.type):null;return s&&s!=="text"?[Zn("result",`${/^[aeiou]/i.test(s)?"an":"a"} ${s} file`)]:[Nn(void 0,mi(e))]}function iV(e){if(typeof e=="string")return[Nn("output",e)];if(!xs(e))return[Nn(void 0,mi(e))];const t=Xn(e.stdout),n=Xn(e.stderr);if(t==null&&n==null)return[Nn(void 0,mi(e))];const s=[];return t&&s.push(Nn("output",t.replace(/\n$/,""))),n&&s.push(Nn("errors",n.replace(/\n$/,""),!0)),e.interrupted===!0&&s.push(Zn("note","interrupted before it finished")),s.length?s:[Zn("output","none")]}function lV(e,t,n){const s=Hl(t),a=Hl(n),o=xs(s)?s:null;if(o&&(e==="Edit"||e==="MultiEdit")){const i=Xn(o.file_path),l=(e==="MultiEdit"?Array.isArray(o.edits)?o.edits:[]:[o]).filter(xs).filter(u=>Xn(u.old_string)!=null&&Xn(u.new_string)!=null);if(i&&l.length){const u=[Zn("file",i)];return l.forEach((h,f)=>{const p=h.replace_all===!0?", every occurrence":"";u.push(eP(l.length>1?`change ${f+1}${p}`:`change${p}`,sV(h.old_string,h.new_string)))}),{input:u,response:GE(a)}}}if(o&&e==="Write"){const i=Xn(o.file_path),l=Xn(o.content);if(i&&l!=null)return{input:[Zn("file",i),Nn("content",l)],response:GE(a)}}if(o&&e==="Read"){const i=Xn(o.file_path);if(i){const l=aV(o);return{input:l?[Zn("file",i),Zn("lines",l)]:[Zn("file",i)],response:oV(a)}}}if(o&&e==="Bash"){const i=Xn(o.command);if(i!=null){const l=Xn(o.description);return{input:l?[Nn("command",i),Zn("why",l)]:[Nn("command",i)],response:iV(a)}}}return{input:[Nn(void 0,mi(s))],response:[Nn(void 0,mi(a))]}}function KE(e,t,n){const s=Hl(n);if(s==null)return"";if(typeof s=="string")return s;if(xs(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"&&xs(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 cV=new Set(["TodoWrite","update_plan"]),uV=new Set(["TaskCreate","TaskUpdate","TaskList","TaskGet"]);function xu(e){return e==="pending"||e==="in_progress"||e==="completed"?e:null}function ps(e){return typeof e=="string"?e.trim():""}function Ko(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 dV(e,t){const n=Ko(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 l=i,u=ps(e==="TodoWrite"?l.content:l.step),h=xu(l.status);if(!u||!h)continue;const f=ps(l.activeForm??l.active_form);a.push(f?{text:u,status:h,active:f}:{text:u,status:h})}const o=e==="update_plan"?ps(n.explanation):"";return o?{items:a,note:o}:{items:a}}function Ha(e,t,n){return n?{items:e,at:t,note:n}:{items:e,at:t}}function hV(e,t,n,s){if(!t||!cV.has(t)||e.plan&&s<e.plan.at)return;const a=dV(t,n);a&&(e.plan=Ha(a.items,s,a.note))}function ll(e){if(!e)return"";const t=e.taskId??e.id??e.task_id;return typeof t=="number"?String(t):ps(t)}function fV(e,t,n,s,a){var j,b,N,x,S,C,_,M,R,P,L,U,B,A,q;if(!t||!uV.has(t))return;const o=Ko(n),i=Ko(s),l=((j=e.plan)==null?void 0:j.items)??[],u=T=>l.findIndex(F=>F.id===T);if(t==="TaskCreate"){const T=Ko(i==null?void 0:i.task),F=ll(T),O=ps(T==null?void 0:T.subject)||ps(o==null?void 0:o.subject);if(!F||!O)return;const K=ps((o==null?void 0:o.activeForm)??(o==null?void 0:o.active_form)),V=u(F),H={id:F,text:O,status:V>=0?l[V].status:"pending",...K?{active:K}:{}},D=l.slice();V>=0?D[V]=H:D.push(H),e.plan=Ha(D,Math.max(a,((b=e.plan)==null?void 0:b.at)??a),(N=e.plan)==null?void 0:N.note);return}if(t==="TaskUpdate"){if(i&&i.success===!1)return;const T=ll(i)||ll(o);if(!T)return;const F=o==null?void 0:o.status,O=u(T);if(F==="deleted"){if(O<0)return;e.plan=Ha(l.filter((Z,z)=>z!==O),Math.max(a,((x=e.plan)==null?void 0:x.at)??a),(S=e.plan)==null?void 0:S.note);return}const K=ps(o==null?void 0:o.subject),V=ps((o==null?void 0:o.activeForm)??(o==null?void 0:o.active_form)),H=xu(F)??xu((C=Ko(i==null?void 0:i.statusChange))==null?void 0:C.to);if(O<0){if(!K)return;const Z={id:T,text:K,status:H??"pending",...V?{active:V}:{}};e.plan=Ha([...l,Z],Math.max(a,((_=e.plan)==null?void 0:_.at)??a),(M=e.plan)==null?void 0:M.note);return}const I={...l[O],...K?{text:K}:{},...H?{status:H}:{},...V?{active:V}:{}},W=l.slice();W[O]=I,e.plan=Ha(W,Math.max(a,((R=e.plan)==null?void 0:R.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 T=[];for(const F of i.tasks){const O=Ko(F),K=ll(O),V=ps(O==null?void 0:O.subject),H=xu(O==null?void 0:O.status);if(!K||!V||!H)continue;const D=l.find(I=>I.id===K);T.push(D!=null&&D.active?{id:K,text:V,status:H,active:D.active}:{id:K,text:V,status:H})}e.plan=Ha(T,a,(L=e.plan)==null?void 0:L.note);return}const h=i&&"task"in i?Ko(i.task):void 0,f=ll(h??null)||ll(o),p=f?u(f):-1;if(p<0)return;if(h===null){e.plan=Ha(l.filter((T,F)=>F!==p),Math.max(a,((U=e.plan)==null?void 0:U.at)??a),(B=e.plan)==null?void 0:B.note);return}const m=ps(h==null?void 0:h.subject),w=xu(h==null?void 0:h.status);if(!m&&!w)return;const v=l.slice();v[p]={...l[p],...m?{text:m}:{},...w?{status:w}:{}},e.plan=Ha(v,Math.max(a,((A=e.plan)==null?void 0:A.at)??a),(q=e.plan)==null?void 0:q.note)}function jr(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 rN(e){const t=`${e.done}/${e.total}`;return e.allDone||!e.current?`${t} · done`:`${t} · ${e.next?"next: ":""}${e.current}`}function tP(e){const t=`plan ${e.done} of ${e.total} done`;return e.allDone||!e.current?t:`${t}, ${e.next?"next":"now"}: ${e.current}`}function Vp(e){return e.map(t=>`${t.status==="completed"?"✓":t.status==="in_progress"?"▸":"○"} ${t.text}`).join(`
|
|
66
|
+
`)}function pV(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 Vu(e,t=80){const n=Hl(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 YE=200;function nP(e,t,n){const s=t.ok===!1;t.ok=n,e&&s===n&&(e.toolErrorCount=(e.toolErrorCount??0)+(n?-1:1))}function sP(e,t){return t.agentId==null?void 0:e.agents.get(t.agentId)}function Eu(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 mV(e,t,n){var s;return((s=e.get(t))==null?void 0:s.tools.find(a=>a.id===n))??null}const rP=25;function aP(e,t){const n=t.tools;if(n.length>YE){const s=n.splice(0,n.length-YE);for(const a of s)iP(e,t,a)}for(let s=n.length-rP-1;s>=0;s--){const a=n[s];if(a.trimmed)break;a.input=void 0,a.response=void 0,a.trimmed=!0}}function gV(e,t,n){const s=e.toolIndex.get(tc(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 oP(e,t){for(const n of t.tools)iP(e,t,n)}function iP(e,t,n){const s=tc(t.sessionId,n.id);e.toolIndex.get(s)===n&&e.toolIndex.delete(s)}function yV(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,Eu(a,i.name,-1),i.ok===!1&&(a.toolErrorCount=(a.toolErrorCount??0)-1),i.agentId=n.id,n.tools.push(i),n.toolCount+=1,Eu(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),aP(e,n);for(let a=0;a<n.tools.length-rP;a++){const o=n.tools[a];o.trimmed||(o.input=void 0,o.response=void 0,o.trimmed=!0)}}}const wV="no result reached the deck — events were dropped while the deck was paused";function lP(e,t,n,s,a){n.endedAt=s,nP(t,n,!1),n.errorPreview=n.outcomeGap?wV:a,e.toolIndex.delete(tc(t.sessionId,n.id))}function xV(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(tc((n==null?void 0:n.session_id)??"unknown",a))}function vV(e,t,n,s,a){const o=t.tool_use_id?gV(e,s,t.tool_use_id):null;if(o){if(t.tool_name&&o.name==="?"){o.name=t.tool_name;const h=sP(e,o);h&&(Eu(h,"?",-1),Eu(h,o.name,1))}o.endedAt==null&&!o.trimmed&&t.tool_input!==void 0&&(o.input=t.tool_input,o.inputPreview=Vu(t.tool_input));return}const i=t.tool_use_id??`${s.id}:${s.toolCount}`,l=nc(t),u={id:i,name:t.tool_name??"?",input:t.tool_input,inputPreview:Vu(t.tool_input),agentId:s.id,explicitSubagentId:l?fa(n,l):void 0,startedAt:a};s.tools.push(u),s.toolCount+=1,Eu(s,u.name,1),s.state="active",e.toolIndex.set(tc(s.sessionId,i),u),aP(e,s),hV(s,u.name,t.tool_input,a)}function bV(e,t,n,s,a){const o=t.tool_use_id;if(!o)return;const i=tc(s,o);let l=e.toolIndex.get(i),u=!1;if(!l)for(const f of e.agents.values()){if(f.sessionId!==s)continue;const p=f.tools.find(m=>m.id===o);if(p){l=p,u=!0;break}}if(!l||l.outcomeApplied)return;if(l.outcomeApplied=!0,n==="PostToolUse"){const f=e.agents.get(s);f&&fV(f,t.tool_name??l.name,t.tool_input??l.input,t.tool_response,a)}l.outcomeGap=void 0,l.endedAt=a,nP(sP(e,l),l,n==="PostToolUse"),l.trimmed||(l.response=t.tool_response),n==="PostToolUseFailure"?l.errorPreview=Vu(t.tool_response):u&&(l.errorPreview=void 0);const h=q4(t.tool_response);h&&(l.usage=h),e.toolIndex.delete(i)}function kV(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 aN(e,t){e!=null&&e.stopFailure&&t>e.stopFailure.at&&(e.stopFailure=null)}function jV(e,t,n,s){const a=uo(e,n,s,!1);a.synthetic=!1,a.state="active",a.closedAt=void 0,a.endedAt=void 0,aN(a,s),a.startedAt=Math.min(a.startedAt??s,s),pi(a,t),tN(a,t)}function NV(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=uo(e,n,s,!1);a.state="active",a.endedAt=void 0,a.closedAt=void 0,a.exitAt=void 0,aN(a,s);const o=(typeof t.prompt=="string"?t.prompt:typeof t.message=="string"?t.message:"")??"";o&&X9(a.prompts,s,o)&&!a.firstPrompt&&!zp(o)&&(a.firstPrompt=Vu(o,120))}function g1(e,t,n,s,a){const o=uo(e,n,s,!1),i=Z9(o);if(s<i)return;const l=o.lastTurnEndAt;if(!(l!=null&&i>l&&s<=l+Zf)){o.state="done",o.endedAt=s,o.lastTurnEndAt=s,a&&(!o.stopFailure||s>=o.stopFailure.at)&&(o.stopFailure=a.stopFailure);for(const u of o.provider==="codex"?[]:e.agents.values())if(u.sessionId===n)for(const h of u.tools)h.endedAt==null&&h.explicitSubagentId==null&&lP(e,u,h,s,"the turn ended before this call returned");t==="SessionEnd"&&(o.closedAt=s),e.activeSubagentStack.delete(n)}}function SV(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&&(g1(e,t.recovery_session_closed===!0?"SessionEnd":"Stop",s,n),a.restoredFromLog=void 0);return}const o=uo(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,pi(o,t),tN(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=Vu(t.prompt,120))),nN(e,t,s),sN(e,t,s)}function CV(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 l=uo(e,s,n,!0);l.provider="codex",l.parentId=a,pi(l,t);const u=t.agent_nickname||t.agent_role;typeof u=="string"&&u.trim()&&(l.label=u);const h=e.agents.get(a);h&&(h.childCount=[...e.agents.values()].filter(f=>f.parentId===a).length)}const _V=["us-gov","global","apac","us","eu","jp","au"],EV=new RegExp(`^(?:(?:${_V.join("|")})\\.)?anthropic\\.`,"i");function pr(e){return e.replace(EV,"")}const TV=/^(?:claude[-_]|gpt[-_]|o\d|codex[-_])/i,AV=new Set(["tool_input","tool_response"]);function cP(e,t=0){if(!e||typeof e!="object"||t>6)return null;const n=e;if(typeof n.model=="string"&&TV.test(pr(n.model)))return n.model;for(const[s,a]of Object.entries(n)){if(AV.has(s))continue;const o=cP(a,t+1);if(o)return o}return null}const RV=256,Ef={ModelObserved:G4,UsageObserved:sN,ContextObserved:K4,SessionNamed:Y4,ActivityObserved:X4,JobObserved:Z4},Qr=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Zh=e=>typeof e=="string"&&e.trim()!=="",MV=[["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]],$V=new Set(["working","blocked","done","failed","stopped"]),XE=e=>Qr(e)&&typeof e.text=="string"&&e.text.trim()!==""&&Number.isFinite(e.at);function LV(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 MV)o(t[a])||s(a);switch(t.hook_event_name){case"ModelObserved":typeof t.model=="string"&&t.model!==""||s("model"),(Qr(e.subagentModels)||Qr(t.subagentModels))&&(n.subagentModels={...Qr(e.subagentModels)?e.subagentModels:{},...Qr(t.subagentModels)?t.subagentModels:{}});break;case"ContextObserved":{if(!Qr(t.context)){s("context");break}const a=Qr(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=Zh(t.sessionName)?t.sessionName:e.sessionName??null;let o=Zh(t.sessionTitle)?t.sessionTitle:e.sessionTitle??null;Zh(a)&&Zh(o)&&o.trim().toLowerCase()===a.trim().toLowerCase()&&(o=null),n.sessionName=a,n.sessionTitle=o;break}case"ActivityObserved":(!XE(t.activity)||XE(e.activity)&&t.activity.at<e.activity.at)&&s("activity");break;case"JobObserved":t.job===null||Qr(t.job)&&$V.has(t.job.state)||s("job");break;case"UsageObserved":Qr(t.usage)?t.usageByModel===void 0&&delete n.usageByModel:(s("usage"),s("usageByModel"));break}return n}function IV(e,t,n,s){if(!(t in Ef)||e.agents.has(s))return!1;const a=e.parkedEnrichment.get(s)??new Map,o=LV(a.get(t),n);for(a.delete(t),a.set(t,o),e.parkedEnrichment.delete(s),e.parkedEnrichment.set(s,a);e.parkedEnrichment.size>RV;){const i=e.parkedEnrichment.keys().next().value;if(i===void 0)break;e.parkedEnrichment.delete(i)}return!0}function OV(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)nN(e,o,t),(s=Ef[a])==null||s.call(Ef,e,o,t)}}function uP(e,t){e.parkedEnrichment.delete(t)}const PV="StopFailure",ZE=Object.freeze({authentication_failed:"login",rate_limit:"usage-limit"});function DV(e){return typeof e=="string"&&Object.hasOwn(ZE,e)?ZE[e]:"api-error"}const FV=/^[a-z][a-z0-9_]{0,39}$/;function BV(e){const t=e==null?void 0:e.error;return typeof t=="string"&&FV.test(t)?t:"unknown"}const JE=160;function QE(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>JE?`${n.slice(0,JE-1).join("").trimEnd()}…`:t}function qV(e){return QE(e==null?void 0:e.last_assistant_message)||QE(e==null?void 0:e.error_details)}function UV(e,t){if(!e||typeof e!="object"||e.hook_event_name!==PV)return null;const n=BV(e);return{kind:DV(n),error:n,message:qV(e),at:t}}function WV(e,t,n,s){const a=nc(t);if(!a)return;const o=F9(e,n,a,t,s),i=eN(t);i&&(o.label=i);const l=e.subagentTombstones.get(o.id);l!=null&&e.subagentTombstones.delete(o.id);const u=o.endedAt!=null&&s-o.endedAt<=Zf,h=l!=null&&s-l<=Zf;if(u||h){const f=h?l:o.endedAt;o.state="done",o.endedAt=f,o.startedAt=Math.min(o.startedAt,f),H4(e,n,a);return}o.state="active",o.startedAt=o.startedAt||s,o.exitAt=void 0,o.endedAt=void 0,B9(e,n,a)}function HV(e,t,n,s){const a=nc(t);if(!a)return;const o=W4(e,n,a,t);if(!o){for(const[i,l]of e.subagentTombstones)s-l>Zf&&e.subagentTombstones.delete(i);e.subagentTombstones.set(fa(n,a),s);return}o.state="done",o.endedAt=Math.min(o.endedAt??s,s),H4(e,n,a)}const zV=["command","cmd","file_path","path","url","pattern","notebook_path"],eT=120,Hy=e=>e.length>eT?`${e.slice(0,eT-1)}…`:e;function VV(e){if(typeof e=="string")return e.trim()?Hy(e.trim()):null;if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e;for(const n of zV){const s=t[n];if(typeof s=="string"&&s.trim())return Hy(s.trim());if(Array.isArray(s)&&s.length>0&&s.every(a=>typeof a=="string")){const a=s.join(" ").trim();if(a)return Hy(a)}}return null}function GV(e){return e==="permission_prompt"?"permission":e==="agent_needs_input"?"asked":e==="idle_prompt"?"idle":null}const KV=new Set(["Notification","ModelObserved","ContextObserved","UsageObserved","SessionNamed","SessionRecapped","OutputObserved","ActivityObserved","JobObserved"]);function YV(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 XV=3e4;function ZV(e,t){if(!(!e||!e.name)&&!(t-e.startedAt>XV)&&!(e.startedAt>t))return{name:e.name,preview:VV(e.input)??""}}function JV(e,t,n,s,a){if(n!=="permission")return{kind:n,message:s,since:a};const o=YV(e,t),i={kind:n,message:s,since:a};o!=null&&o.explicitSubagentId&&(i.subagentId=o.explicitSubagentId);const l=ZV(o,a);return l&&(i.tool=l),i}function QV(e,t,n){if(e.kind==="idle")return!0;const s=nc(t);return s==null?!0:e.subagentId!=null&&fa(n,s)===e.subagentId}function eG(e,t,n,s){if(!KV.has(t)){const a=e.agents.get(s);a!=null&&a.waiting&&QV(a.waiting,n,s)&&(a.waiting=null)}}function tG(e,t,n,s){const a=GV(t.notification_type);if(!a)return;const o=uo(e,n,s,!1),i=typeof t.message=="string"?t.message:"",l=o.waiting;o.waiting=l&&l.kind===a&&l.message===i?{...l,since:Math.min(l.since,s)}:JV(e,n,a,i,s)}function Gp(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 l=n.get(o.parentId);if(!l||l.provider!=="codex")break;o=l}s.set(a.id,o.sessionId)}return s}function md(e,t){return t&&(e.revision+=1),t}function nG(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=Gp(e.agents.values()),l=new Set([...e.agents.values()].filter(w=>w.provider==="codex"&&!o(w)).map(w=>i.get(w.id))),u=[],h=new Map;for(const[w,v]of e.agents){if(v.parentId!=null){const j=h.get(v.parentId);j?j.push(w):h.set(v.parentId,[w])}o(v)&&!l.has(i.get(w))&&u.push({id:w,endedAt:v.endedAt})}if(u.length===0)return!1;u.sort((w,v)=>w.endedAt-v.endedAt);let f=0;const p=new Set,m=w=>{const v=e.agents.get(w);v&&(oP(e,v),e.agents.delete(w),v.kind==="root"&&uP(e,v.sessionId),p.add(v.sessionId),f++)};for(const w of u){if(e.agents.size<=n)break;if(!e.agents.has(w.id))continue;const v=[],j=new Set([w.id]),b=[...h.get(w.id)??[]];for(;b.length;){const N=b.pop();if(j.has(N))continue;j.add(N);const x=e.agents.get(N);x&&(v.push(x),b.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 md(e,f>0)}function sG(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=Gp(e.agents.values()),l=new Set([...e.agents.values()].filter(m=>m.state!=="done"||m.endedAt==null).map(m=>i.get(m.id))),u=[...o].filter(([m,w])=>!l.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 u){if(f<=0)break;for(const j of w.ids){const b=e.agents.get(j);b&&oP(e,b),e.agents.delete(j)}uP(e,m);const v=fa(m,"");for(const j of e.pendingSubagentModels.keys())j.startsWith(v)&&e.pendingSubagentModels.delete(j);a==null||a(m),f--,p=!0}return md(e,p)}function rG(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 md(e,t)}function aG(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 l of a.tools){const u=Math.max(l.startedAt,i??l.startedAt);l.endedAt==null&&t-u>n&&(lP(e,a,l,u,"session ended before this call returned"),s=!0)}}return md(e,s)}const tT=90*6e4;function oG(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 md(e,s)}function Gu(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 dP(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{...Jj(),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 SV(e,s,a),e;if(o==="CodexThreadLinked")return CV(e,s,a),e;const i=s.session_id??"unknown";if(eG(e,o,s,i),o!=="JobObserved"&&kV(e,i,a),nN(e,s,i),IV(e,o,s,i))return e;switch(o){case"ModelObserved":return G4(e,s,i),e;case"ContextObserved":return K4(e,s,i),e;case"SessionNamed":return Y4(e,s,i),e;case"SessionRecapped":return H9(e,s,i),e;case"ActivityObserved":return X4(e,s,i),e;case"JobObserved":return Z4(e,s,i),e;case"OutputObserved":return V9(e,s,i,a),e;case"UsageObserved":return sN(e,s,i),e}const l=P9(e,s,a),u=e.agents.get(i);u&&a>=(u.recoveryLiveAt??0)&&(u.recoveryLiveAt=a,u.restoredFromLog=void 0),OV(e,i),D9(e,o,s,i)&&yV(e,i),l.provider||(l.provider=s.provider==="codex"?"codex":"claude"),l.provider==="codex"&&(l.childCount=[...e.agents.values()].filter(w=>w.parentId===l.id).length);const h=cP(s),f=nc(s),p=f?fa(i,f):i;h&&l.id===p&&(l.model=h);const m=U9(o,s);switch(m!==void 0&&l.id===p&&(l.effort=m??void 0),(o==="PreToolUse"||o==="PostToolUse"||o==="PostToolUseFailure")&&f==null&&aN(e.agents.get(i),a),o){case"SessionStart":jV(e,s,i,a);break;case"UserPromptSubmit":NV(e,s,i,a);break;case"PreToolUse":vV(e,s,i,l,a);break;case"PostToolUse":case"PostToolUseFailure":bV(e,s,o,i,a);break;case"SubagentStart":WV(e,s,i,a);break;case"SubagentStop":HV(e,s,i,a);break;case"Stop":case"StopFailure":g1(e,o,i,a,{stopFailure:UV(s,a)});break;case"SessionEnd":g1(e,o,i,a);break;case"Notification":tG(e,s,i,a);break}return e}const iG="codex-auto-review",hP="chatgpt-auto-review-free",lG={input:2,output:10,cacheRead:.2,cacheWrite:2.5,cacheWrite1h:4},cG=[{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:lG},{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}}],uG=[{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 fP(e){return e?/^(?:gpt[-_]|codex[-_]|o\d)/i.test(e):!1}function vr(e,t=Date.now(),n=ua){if(!e)return null;if(e===iG&&n===hP)return{input:0,output:0,cacheRead:0,cacheWrite:0};if(n!==ua&&fP(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,l=i===void 0?null:vr(e,t);return l&&i!==void 0?{input:l.input*i,output:l.output*i,cacheRead:l.cacheRead*i,cacheWrite:l.cacheWrite*i}:null}const s=dG.get(n);if(!s)return null;const a=pr(e);for(const o of s)if(o.match.test(a))return typeof o.rates=="function"?o.rates(t):o.rates;return null}const ua="standard",dG=new Map([[ua,cG],["fast",uG]]);function Tu(e,t){return e*t/1e6}function pP(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:Tu(o,t.cacheWrite),usd1h:Tu(n,i)}}function mP(e,t,n=Date.now()){if(!fP(t))return e.inputTokens;const s=vr(t,n),a=((s==null?void 0:s.cacheWrite)??0)>0?Math.max(0,e.cacheCreateTokens):0;return Math.max(0,e.inputTokens-e.cacheReadTokens-a)}function Kp(e,t,n=Date.now()){const s={input:0,output:0,cacheRead:0,cacheWrite:0,total:0};for(const a of gd(e)){const o=Ku(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 Ku(e,t,n,s=Date.now()){const a=vr(t,s,n);if(!a)return{input:0,output:0,cacheRead:0,cacheWrite:0,total:0};const o={input:0,output:0,cacheRead:0,cacheWrite:0,total:0};for(const i of gP(e,t)){const l=i.usage,u=yP(a,i.long);o.input+=Tu(mP(l,t,s),u.input),o.output+=Tu(l.outputTokens,u.output),o.cacheRead+=Tu(l.cacheReadTokens,u.cacheRead);const h=pP(l,u);o.cacheWrite+=h.usd5m+h.usd1h}return o.total=o.input+o.output+o.cacheRead+o.cacheWrite,o}function gP(e,t){if(!e.longContext||!/^claude[-_]haiku[-_]5[-_.]5\b(?![-_.]\d{1,7}(?!\d))/i.test(pr(t??"")))return[{usage:e,long:!1}];const n=e.longContext;return[{usage:oN(e,[n]),long:!1},{usage:n,long:!0}]}function yP(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 gd(e){const t=e.bySpeed?Object.entries(e.bySpeed):[];return t.length===0?[{speed:ua,usage:e}]:[{speed:ua,usage:oN(e,t.map(([,n])=>n))},...t.map(([n,s])=>({speed:n,usage:s}))]}function oN(e,t){const n=o=>t.reduce((i,l)=>i+(o(l)??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=oN(e.longContext,t.flatMap(o=>o.longContext?[o.longContext]:[]))),a}const da="not priced";function Au(e,t,n){const s=e.toFixed(t);return Number(s)<n?s:null}function ct(e){if(e<=0)return"—";if(e<.005)return"<1¢";if(e<1){const t=Au(e*100,e<.1?1:0,100);if(t!==null)return`${t}¢`}if(e<100){const t=Au(e,2,100);if(t!==null)return`$${t}`}if(e<1e4){const t=Au(e,0,1e4);if(t!==null)return`$${t}`}return`$${(e/1e3).toFixed(1)}k`}function iN(e,t){if(e<=0||t<10)return null;const n=e/t,s=n*60;return s>=.01?`${ct(s)}/min`:`${ct(n*3600)}/hr`}function y1(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=y1(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?y1(i,o):o)}n.bySpeed=Object.fromEntries(s)}return n}function hG(e,t){let n=0,s=0,a=0,o=0,i=0,l=0;for(const p of t)n+=p.inputTokens,s+=p.outputTokens,a+=p.cacheReadTokens,o+=p.cacheCreateTokens,i+=p.cacheCreate1hTokens??0,l+=p.cacheCreate5mTokens??0;const u=(p,m)=>Math.max(0,p-m),h={inputTokens:u(e.inputTokens,n),outputTokens:u(e.outputTokens,s),cacheReadTokens:u(e.cacheReadTokens,a),cacheCreateTokens:u(e.cacheCreateTokens,o)};return(e.cacheCreate1hTokens!==void 0||e.cacheCreate5mTokens!==void 0)&&(h.cacheCreate1hTokens=u(e.cacheCreate1hTokens??0,i),h.cacheCreate5mTokens=u(e.cacheCreate5mTokens??0,l)),h.inputTokens+h.outputTokens+h.cacheReadTokens+h.cacheCreateTokens>0?h:null}function sc(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=hG(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:y1(s[o].usage,a)}:s.push({model:e.model,usage:a})}return s}function qn(e,t=Date.now()){const n={input:0,output:0,cacheRead:0,cacheWrite:0,total:0};for(const s of sc(e)){const a=Kp(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 w1(e,t=Date.now()){return sc(e).every(n=>{const s=gd(n.usage).filter(({usage:a})=>a.inputTokens+a.outputTokens+a.cacheReadTokens+a.cacheCreateTokens+(a.cacheCreate1hTokens??0)+(a.cacheCreate5mTokens??0)>0);return s.length>0?s.every(a=>vr(n.model,t,a.speed)!==null):vr(n.model,t)!==null})}function zl(e,t=Date.now()){let n=0;for(const s of sc(e))for(const a of gd(s.usage))vr(s.model,t,a.speed)==null&&(n+=a.usage.inputTokens+a.usage.outputTokens);return n}function wP(e){const t=[];for(const n of sc(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 lN(e){return wP(e).filter(t=>t!==e.model)}function nT(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
|
+
`:"")+fG(e,t)}function fG(e,t){if(!e.bySpeed)return zy(e,t,ua);const n=gd(e).filter(s=>s.speed!==ua||xP(s.usage));return n.length===1?zy(n[0].usage,t,n[0].speed):[...n.map(s=>zy(s.usage,t,s.speed)),"═════════════════════════════════════════",`all speeds = ${ct(Kp(e,t).total)}`].join(`
|
|
68
|
+
`)}function xP(e){return e.inputTokens+e.outputTokens+e.cacheReadTokens+e.cacheCreateTokens>0}function zy(e,t,n){const s=gP(e,t).filter(a=>xP(a.usage));return e.longContext&&s.some(a=>a.long)?[...s.map(a=>sT(a.usage,t,n,a.long)),`all context tiers = ${ct(Ku(e,t,n).total)}`].join(`
|
|
69
|
+
`):sT(e,t,n,!1)}function sT(e,t,n,s){const a=vr(t,Date.now(),n),o=a?yP(a,s):null,i=s?" · prompt >100K":"",l=(n===hP?`model: ${t} · no charge for ChatGPT auto-review`:n===ua?`model: ${t}`:`model: ${t} · ${n}`)+i;if(!o)return`${l}
|
|
70
|
+
no published rate in this build — the tokens are counted, the dollars are not`;const u=j=>j.toLocaleString(),h=j=>`$${j}/MTok`,f=Ku(s?{...e,longContext:e}:{...e,longContext:void 0},t,n),p=pP(e,o),m=p.tokens1h>0?[`cache w5m${u(p.tokens5m).padStart(14)} × ${h(o.cacheWrite).padEnd(11)} = ${ct(p.usd5m)}`,`cache w1h${u(p.tokens1h).padStart(14)} × ${h(o.cacheWrite1h??o.cacheWrite).padEnd(11)} = ${ct(p.usd1h)}`]:[`cache w ${u(p.tokens5m).padStart(14)} × ${h(o.cacheWrite).padEnd(11)} = ${ct(p.usd5m)}`],w=mP(e,t),v=w===e.inputTokens?"input":"uncached";return[l,`${v.padEnd(9)}${u(w).padStart(14)} × ${h(o.input).padEnd(11)} = ${ct(f.input)}`,`output ${u(e.outputTokens).padStart(14)} × ${h(o.output).padEnd(11)} = ${ct(f.output)}`,`cache r ${u(e.cacheReadTokens).padStart(14)} × ${h(o.cacheRead).padEnd(11)} = ${ct(f.cacheRead)}`,...m,"─────────────────────────────────────────",`total = ${ct(f.total)}`].join(`
|
|
71
|
+
`)}function rT(e){const t=sc(e),[n]=t;return t.length<=1?nT(n.usage,n.model):[...t.map(s=>nT(s.usage,s.model)),"═════════════════════════════════════════",`all models = ${ct(qn(e).total)}`].join(`
|
|
72
|
+
`)}function pG(e){if(!e.model)return null;const t=vr(e.model),n=qn(e),s=zl(e);if(!t&&n.total<=0&&s>0)return e.usage.inputTokens+e.usage.outputTokens<=0?null:{kind:"unpriced",tt:rT(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?iN(n.total,a):null,i=rT(e)+(o?`
|
|
73
|
+
burn: ${o}`:"");return{kind:"spent",total:n.total,floor:s>0,tt:i}}const mG=new Set(["untrusted","on-request","on-failure"]);function gG(e){return typeof e!="string"||!e?null:mG.has(e)?!0:e==="never"?!1:null}function vP(e){if(e.provider!=="codex"||e.kind!=="root"||e.waiting||e.state!=="active")return null;const t=gG(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 aT(e){return e[0].toUpperCase()+e.slice(1).toLowerCase()}function no(e){const t=pr(e).replace(/[-_]\d{8}(?!\d)/,""),n=t.match(/^claude[-_](opus|sonnet|haiku|fable|mythos)[-_](\d+(?:[-_.]\d+)*)/i);if(n){const a=aT(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(aT);return[`GPT-${a}`,...o].join(" ")}return e}function Yp(e){const t=pr(e??""),n=t.match(/^claude[-_](opus|sonnet|haiku|fable|mythos)[-_]/i);return n?n[1].toLowerCase():/^gpt[-_]/i.test(t)?"gpt":""}function Xp(e,t){return t?`${no(e)} · ${t}`:no(e)}function Yu(e,t){return t?`${e}
|
|
76
|
+
effort: ${t}`:e}function yG(e){return!e.model&&e.provider!=="codex"?0:e.model&&e.effort?2:1}function wG(e,t){return(t.overflowing||t.folderCut)&&e<t.max?e+1:e}function xG(e){return{kind:e<1,effort:e<2}}function _n(e){return(e==null?void 0:e.kind)==="permission"||(e==null?void 0:e.kind)==="asked"}function x1(e){const t=[];for(const n of e)n.kind==="root"&&_n(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 vG(e,t){if(e.length===0)return null;const n=e.findIndex(s=>s.id===t);return e[(n+1)%e.length]}function bG(e){const t=new Set;for(const n of e)n.state==="active"&&t.add(n.sessionId);return t.size}function Zp(e,t){return`${e}@${t.since}`}function bP(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 kG(e){const t=e.message||"Needs your permission",n=bP(e,t);return n?`${t}
|
|
77
|
+
Likely on: ${n}`:t}function jG(e,t,n,s=!0){if(!s)return[];if(n)return[];const a=[];for(const o of e){if(!_n(o.waiting))continue;const i=Zp(o.id,o.waiting);t.has(i)||a.push({key:i,title:o.label,body:kG(o.waiting),sessionId:o.id})}return a}function NG(e,t,n){const s=new Set;for(const o of e)s.add(Zp(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 Jh(e){return new Set(e.map(t=>Zp(t.id,t.waiting)))}function SG(e,t){return e!==t}function CG(e,t){return!e&&t!=null}function _G(e,t){return e!==null&&t!=null}function cN(e){switch(e){case"login":return"login expired";case"usage-limit":return"usage limit";default:return"API error"}}function kP(e){return`Stopped · ${cN(e.kind)}`}function jP(e){const t=cN(e.kind);return t.charAt(0).toUpperCase()+t.slice(1)}function uN(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 EG(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 TG(e){return e.message?`It said: “${e.message}”`:""}function AG(e,t=!1){return[EG(e),TG(e),uN(e.kind,t)].filter(Boolean).join(`
|
|
78
|
+
`)}function RG(e,t=!1){return`${jP(e)}. ${uN(e.kind,t)}`}function MG(e){return`Claude Code's StopFailure hook${e!=null&&e.message?`: “${e.message}”`:""}`}function $G(e,t=!1){const n=uN(e.kind,t).replace(/\.$/,"");return`stopped, ${cN(e.kind)} — ${n.charAt(0).toLowerCase()}${n.slice(1)}`}function Jp(e){return e.provider==="codex"&&e.parentId?"child session":e.kind==="root"?"session":"subagent"}function Vl(e){return e==="active"?"live":e==="done"?"done":"err"}function Gl(e){return e.message?e.message:e.kind==="permission"?"Needs your permission":"Waiting for your input"}function LG(e){return`${e} subagent${e===1?"":"s"} spawned`}function IG(e){const t=[Jp(e)];if(e.childCount>0&&t.push(`→ ${e.childCount}`),e.kind==="subagent"&&e.cwdBasename&&t.push(e.cwdBasename),e.model){const n=lN(e).length;t.push(`${no(e.model)}${n>0?` +${n}`:""}`)}else e.provider==="codex"&&t.push("Codex");return t.join(" · ")}function OG(e,t=Date.now(),n=!1){const s=e.toolErrorCount??0,a=qn(e,t).total;return[e.label,Jp(e),e.kind==="root"&&e.stopFailure?$G(e.stopFailure,e.job!=null):Vl(e.state),_n(e.waiting)?Gl(e.waiting):null,e.model?no(e.model):null,(()=>{const o=jr(e.plan);return o?tP(o):null})(),`${e.toolCount} ${e.toolCount===1?"tool":"tools"}`,s>0?`${s} failed`:null,a>0?`${ct(a)}${zl(e,t)>0?"+":""}`:null,n?"selected":null].filter(Boolean).join(", ")}function NP(e,t){const n=bP(e,t);return n?`Likely on: ${n}`:null}function Jf(e){return e.kind==="idle"?"Your turn":Gl(e)}function Ct(e){const t=Math.round(e);if(t<1e3)return`${t}`;if(t<1e6){const n=Au(t/1e3,1,1e3);if(n!==null)return`${n}k`}if(t<1e9){const n=Au(t/1e6,2,1e3);if(n!==null)return`${n}M`}return`${(t/1e9).toFixed(2)}B`}function Kl(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 SP(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 Qp(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 oT=2e5,PG=1e6,DG=[/\[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],FG=[{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 BG(e){if(!e)return oT;const t=pr(e);for(const n of DG)if(n.test(t))return PG;for(const n of FG)if(n.match.test(t))return n.window;return oT}function CP(e,t){return typeof e=="number"&&e>0?e:BG(t)}const qG=1;function UG(){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 l=e.indexOf(i);l!==-1&&e.splice(l,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 cn=UG(),dN=e=>e==="Escape";function WG(e){return e.overlayOpen?"dismiss":e.typing?"blur":"clear-selection"}function iT(e){return String(e.tagName??"").toUpperCase()==="BODY"}function lT(e,t){return!e||!e.isConnected||iT(e)?!1:t==null||iT(t)}const Qf="a[href], button, input, select, textarea, summary, [tabindex]";function _P(e){return!e||e.disabled||e.rendered===!1?!1:(e.tabIndex??0)>=0}function HG(e){if(!e||!e.overflowing||e.hasFocusable)return!1;const t=String(e.overflow??"").toLowerCase();return t==="auto"||t==="scroll"}function zG({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 em(e){return e.ctrlKey||e.metaKey||e.altKey}function VG(e){e.key!=="Escape"&&e.key!=="Tab"&&e.stopPropagation()}const GG=new Set(["button","checkbox","color","file","image","radio","range","reset","submit"]),KG=new Set(["INPUT","TEXTAREA","SELECT","OPTION","BUTTON","SUMMARY","A"]),YG=new Set(["button","checkbox","combobox","link","listbox","menu","menubar","menuitem","menuitemcheckbox","menuitemradio","option","radio","searchbox","slider","spinbutton","switch","tab","textbox","treeitem"]);function tm(e){return typeof e.tagName=="string"?e.tagName.toUpperCase():""}function XG(e){return tm(e)==="BUTTON"?!0:(typeof e.role=="string"?e.role.trim().toLowerCase():"").split(/\s+/).includes("button")}function ai(e){if(!e)return!1;if(e.isContentEditable)return!0;const t=tm(e);return t==="TEXTAREA"?!0:t!=="INPUT"?!1:!GG.has(String(e.type??"text").toLowerCase())}function EP(e,t){if(!e)return!1;if(ai(e))return!0;if(t!=null&&(t.length===1||t==="Delete")&&t!==" "&&e.pointerFocused&&XG(e))return!1;if(KG.has(tm(e)))return!0;const n=typeof e.role=="string"?e.role.trim().toLowerCase():"";return n!==""&&n.split(/\s+/).some(s=>YG.has(s))}function ZG({key:e,modalOpen:t,sheetOpen:n}){return t?!(e==="?"&&n):!1}function JG({key:e,sheetOpen:t,target:n}){return t&&e==="?"&&!ai(n)}function QG({target:e,modalOpen:t}){return t?ai(e)||e!=null&&tm(e)==="SELECT":EP(e,"t")}function wl({appModal:e,dialogDepth:t}){return e||t>0}function TP(e){return e?Array.from(e.querySelectorAll("*")).filter(t=>{if(t.matches(Qf))return _P({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)&&HG({overflowing:n,overflow:getComputedStyle(t).overflowY,hasFocusable:t.querySelector(Qf)!=null}):!1}):[]}function eK(e,t){const n=TP(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 gt(e,t={}){const{focusRef:n,restoreFocusFallback:s,layer:a,popover:o}=t,i=o?"popover":"dialog",l=g.useRef(null),u=g.useRef(e);u.current=e;const h=g.useRef(null);h.current===null&&(h.current=()=>u.current());const f=h.current;return g.useEffect(()=>cn.push(f,a,i),[f,a,i]),g.useEffect(()=>{var m;const p=document.activeElement;return(m=(n==null?void 0:n.current)??TP(l.current)[0])==null||m.focus(),()=>{if(lT(p,document.activeElement)&&p.focus(),s&&document.activeElement===document.body){const w=s();lT(w,document.activeElement)&&w.focus()}}},[]),g.useEffect(()=>{const p=m=>{var x;if(m.key!=="Tab"||em(m))return;const w=l.current;if(!w)return;const v=document.activeElement;if(!(v!=null&&w.contains(v))&&!cn.isTop(f))return;const b=eK(w,v),N=zG({count:b.length,index:v?b.indexOf(v):-1,shiftKey:m.shiftKey});N.kind!=="allow"&&(m.preventDefault(),N.kind==="focus"&&((x=b[N.index])==null||x.focus()))};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[f]),l}function yt(e){const t=g.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 tK(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 hs(e){return e.toLocaleString()}const nK=60;function sK(e,t=nK){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 rK({agent:e,onClose:t}){var w;const n=g.useRef(null),s=gt(t,{focusRef:n}),a=yt(t),o=e.context,i=e.usage,l=(o==null?void 0:o.currentContextTokens)??0,u=CP(e.contextWindow,e.model),h=Math.min(100,l/u*100),f=qn(e),p=e.provider==="codex"?i.inputTokens+i.outputTokens:i.inputTokens+i.outputTokens+i.cacheReadTokens+i.cacheCreateTokens,m=tK(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:"modal-head ctx-modal-head",children:[r.jsxs("div",{children:[r.jsxs("div",{className:"modal-tool-name",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:[hs(l)," / ",hs(u)," 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:hs(i.inputTokens)}),r.jsx(Us,{label:"output tokens",val:hs(i.outputTokens)}),r.jsx(Us,{label:"cache reads",val:hs(i.cacheReadTokens)}),r.jsx(Us,{label:"cache writes",val:hs(i.cacheCreateTokens)}),r.jsx(Us,{label:"cumulative total",val:hs(p)}),r.jsx(Us,{label:"estimated cost",val:ct(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:hs((o==null?void 0:o.msgsUser)??0)}),r.jsx(Us,{label:"assistant messages",val:hs((o==null?void 0:o.msgsAssistant)??0)}),r.jsx(Us,{label:"tool uses",val:hs((o==null?void 0:o.toolUses)??0)}),r.jsx(Us,{label:"tool results",val:hs((o==null?void 0:o.toolResults)??0)}),r.jsx(Us,{label:"system-reminders",val:hs((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:sK(v.path)}),r.jsx("span",{className:"ctx-md-size",children:ea(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 aK({currentContextTokens:e,modelId:t,contextWindow:n,size:s=26,onClick:a}){const o=CP(n,t),i=Math.min(1,e/o),l=s/2-3,u=s/2,h=2*Math.PI*l,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:u,cy:u,r:l,stroke:"var(--line)",strokeWidth:"2.5",fill:"none"}),r.jsx("circle",{cx:u,cy:u,r:l,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:u,y:u+3,textAnchor:"middle",fontSize:"8",fill:"var(--text)",fontWeight:"600",children:Math.round(i*100)})]})})}const cT=new Map;function AP(e){let t=cT.get(e);return t||(t={now:Date.now(),listeners:new Set,timer:null},cT.set(e,t)),t}function oK(e,t){const n=AP(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 iK(e){return AP(e).now}const uT=new Map,dT=new Map;function Nr(e=1e3){let t=uT.get(e);t||(t=s=>oK(e,s),uT.set(e,t));let n=dT.get(e);return n||(n=()=>iK(e),dT.set(e,n)),g.useSyncExternalStore(t,n,n)}function lK(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 cK="1",hT="agent-dag.schema",uK=["agent-dag.layout","agent-dag.viewport"];function nt(e){if(typeof window>"u")return null;try{return window.localStorage.getItem(e)}catch{return null}}function st(e,t){if(!(typeof window>"u"))try{window.localStorage.setItem(e,t)}catch{}}function vs(e){if(!(typeof window>"u"))try{window.localStorage.removeItem(e)}catch{}}function mr(){if(typeof window>"u")return null;try{return window.localStorage}catch{return null}}function dK(e,t=cK){let n=null;try{n=e.getItem(hT)}catch{return[]}if(n===t)return[];const s=[];if(n!==null)for(const a of uK)try{e.getItem(a)!==null&&(e.removeItem(a),s.push(a))}catch{}try{e.setItem(hT,t)}catch{}return s}const RP="agent-dag.recapsDismissed",fT=200;function hK(){const e=nt(RP);if(!e)return[];try{const t=JSON.parse(e);return Array.isArray(t)?t.filter(n=>typeof n=="string"):[]}catch{return[]}}let Yl=new Set(hK());const v1=new Set;let MP=0;function $P(e){return v1.add(e),()=>{v1.delete(e)}}function LP(e){Yl=e,MP++;const t=Array.from(e);st(RP,JSON.stringify(t.length>fT?t.slice(-fT):t));for(const n of v1)n()}function fK(e,t){return`${e}@${t}`}function pK(e){return Yl.has(e)}function mK(e){if(Yl.has(e))return;const t=new Set(Yl);t.add(e),LP(t)}function gK(e){const t=new Set(Yl);t.delete(e)||t.add(e),LP(t)}function yK(e){return g.useSyncExternalStore($P,()=>e!=null&&Yl.has(e),()=>!1)}function hN(e){return`recap:${e}`}function wK(e){return e.startsWith("recap:")}function xK(){return g.useSyncExternalStore($P,()=>MP,()=>0)}function rc(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 vK(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 bK(e){let t=null;for(const n of e.prompts)(!t||n.at>t.at)&&(t=n);return t}const pT=160;function kK(e){const t=zp(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>pT?s.slice(0,pT-1).trimEnd()+"…":s}function jK(e){const t=e.stopFailure;if(t)return{kind:"stopped",text:RG(t,e.job!=null),at:t.at,source:"stop",stop:t,key:`${e.sessionId}@stopped:${t.at}`};const n=bK(e),s=(n==null?void 0:n.at)??e.startedAt,a=l=>({...l,key:`${e.sessionId}@${l.kind==="last"?"now":l.kind}:${s}`}),o=e.job?vK(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 l=kK(n.text);if(l){const u={kind:"now",text:l,at:n.at,source:"prompt"};return e.provider==="codex"&&(u.codex=!0),a(u)}}return null}function fN(e){if(e.kind!=="root"||e.closedAt!=null)return null;const t=jK(e);if((t==null?void 0:t.kind)==="stopped")return t;const n=lK(e),s=n?{kind:"recap",text:n.text,at:n.at,source:"recap",key:fK(e.sessionId,n.at)}:null;return t&&s?s.at>t.at?s:t:t??s}function IP(e){const t=fN(e);if(e.kind!=="root"||e.closedAt!=null)return null;const n=jr(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 nm(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 MG(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 NK(e){const t=new Map,n=[...e],s=Gp(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 OP(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 PP(e){return e.live>0?`→ ${e.total} · ${e.live} live`:`→ ${e.total} · done`}function SK(e,t,n){const s=e.kind==="root"?e.waiting:null;if(s&&_n(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:kP(a),short:jP(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=jr(e.plan);if(i&&i.current&&!i.allDone)return{tone:"muted",long:rN(i),short:`${i.done}/${i.total} done`}}if(t&&t.total>0)return{tone:"muted",long:OP(t),short:PP(t)};if(e.state==="active")for(let i=e.tools.length-1;i>=0;i--){const l=e.tools[i];if(l.endedAt!=null)continue;const{name:u,subject:h}=n.describeCall(l);return{tone:"muted",long:h?`${u} · ${h}`:u,short:u}}return null}function CK(e,t){return t?t.includes(e)?t:`${e}
|
|
80
|
+
${t}`:e}function $l(e){return e.kind==="root"&&e.stopFailure&&e.state==="done"?"err":e.state}function b1(e){return e==="active"?"live":e==="done"?"done":"err"}const sm={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"}},_K=Object.fromEntries(Object.entries(sm).map(([e,t])=>[e,t.category])),EK=Object.fromEntries(Object.entries(sm).map(([e,t])=>[e,t.emoji])),TK=Object.fromEntries(Object.entries(sm).map(([e,t])=>[e,t.label])),AK=new Set(Object.entries(sm).filter(([,e])=>e.shell).map(([e])=>e)),RK={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",..._K};function DP(e){return e.startsWith("mcp__")?"mcp":Zt(RK,e)??"other"}const MK=/\btools\.exec_command\s*\(\s*\{[^{}]*?\bcmd\s*:\s*(["'`])((?:\\.|(?!\1)[^\\])*)\1/,$K=/\btools\.([A-Za-z_$][\w$]*)\s*\(/;function LK(e){if(typeof e!="string"||!e)return null;const t=MK.exec(e);if(t){const s=IK(t[2]);if(s.trim())return s}const n=$K.exec(e);return n?n[1]:null}function IK(e){return e.replace(/\\(["'`\\nrt])/g,(t,n)=>n==="n"?`
|
|
81
|
+
`:n==="r"?"\r":n==="t"?" ":n)}const OK={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:"📡",...EK};function mT(e){return e.startsWith("mcp__")?"🔌":Zt(OK,e)??"✨"}const PK={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 FP(e){return/^-(?:Command|c)$/i.test(e)||/^-[a-z]+c$/.test(e)}function BP(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=>FP(o)||/^-(?:NoProfile|NonInteractive)$/i.test(o)))return BP(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 DK(e){if(typeof e=="string")return e;if(!e||typeof e!="object")return null;const t=e;if(typeof t.script=="string"){const n=LK(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(FP);if(s>=0&&s+1<n.length)return n[s+1]}return n.join(" ")}return typeof t.script=="string"?t.script:null}const FK=new Set(["Bash","PowerShell",...AK]);function BK(e,t){if(!FK.has(e))return null;const n=DK(t);if(!n)return null;const s=BP(n);return s?{emoji:Zt(PK,s)??"⚙️",label:s,category:"shell",detail:n}:null}const qK=new Set(["Read","Write","Edit","MultiEdit","NotebookEdit","LS","Glob","apply_patch"]),UK={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:"🗄️"},WK={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 HK(e){const n=e.replace(/\\/g,"/").replace(/\/+$/,""),s=n.lastIndexOf("/");return s>=0?n.slice(s+1):n}function zK(e){const t=e.toLowerCase(),n=Zt(WK,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=Zt(UK,t.slice(s+1));if(a!==void 0)return a}return"📄"}function VK(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 GK(e,t){if(!qK.has(e))return null;const n=VK(e,t);if(!n)return null;const s=HK(n);return s?{emoji:e==="LS"?"📂":zK(s),label:s,category:"file",detail:n}:null}const KK={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 pN(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 YK(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 qP(e){return Zt(KK,e.toLowerCase())}function XK(e,t){const n=pN(e);if(!n)return null;const{server:s,method:a}=n;if(!a)return null;const o=qP(s);return{emoji:(o==null?void 0:o.emoji)??"🔌",label:a,category:"mcp",detail:o?`${o.name} · ${a}`:`${s} · ${a}`}}function UP(e,t){return BK(e,t)??GK(e,t)??XK(e)}function ZK(e,t){var n;return((n=UP(e,t))==null?void 0:n.label)??null}const JK=TK,gT=18;function Qh(e){const t=[...e];return t.length<=gT?e:t.slice(0,gT-1).join("")+"…"}const Vy=13,QK=6;function eY(e,t){const n=[...e];if(n.length<=Vy)return e;const s=n.lastIndexOf("."),a=s>0?n.slice(s):[];return t==="file"&&a.length>1&&a.length<=QK?n.slice(0,Vy-1-a.length).join("")+"…"+a.join(""):n.slice(0,Vy-1).join("")+"…"}function mN(e){const t=pN(e);if(t){const s=qP(t.server);return s?{emoji:s.emoji,label:Qh(s.name)}:{emoji:"🔌",label:Qh(t.server),hue:YK(t.server)}}const n=Zt(JK,e)??"";return n?{emoji:mT(e),label:Qh(n)}:{emoji:mT(e),label:Qh(e)}}function tY(e){let t=null,n="";for(const s of e){const a=pN(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:mN(n)}const k1=6e4,Ll=24,yT=k1/Ll,Gy=132,Tf=14;function nY(e,t,n){const s=new Array(Ll).fill(0);let a=0;const o=m=>{const w=n-m;if(w<0||w>=k1)return;const v=Ll-1-Math.floor(w/yT);v>=0&&v<Ll&&(s[v]+=1,a+=1)};for(const m of e)o(m.startedAt);for(const m of t??[])o(m);const l=Math.max(0,...s)/(yT/1e3),u=e.filter(m=>n-m.startedAt>=0&&n-m.startedAt<k1).length,h=a-u,f=[u>0?`${u} tool ${u===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 ${l.toFixed(1)}/s`;return{counts:s,title:p}}const sY=2;function rY(e){return e===0?1.5:Math.max(1.5,Math.min(1,e/sY)*Tf)}function WP({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 gN(){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 HP(){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 ep({recap:e}){return e?r.jsx(HP,{}):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 ho(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 so(e,t){return{disabled:e!=null&&e!==t,busy:e===t}}function rm(e){return e==null}const j1="self";function Fn(e,t=!1){const n=so(e?j1:null,j1);return{disabled:t||n.disabled,"aria-busy":n.busy}}function Sn(e){return rm(e?j1:null)}const gi=400;function yi({armedFor:e,target:t,armedAt:n,now:s,gapMs:a}){return e!==t?"arm":s-n<a?"ignore":"fire"}function zP(e){return[...e==null?[]:[`#ap-more-${e}`],".accounts-panel .ap-refresh"]}function Un(e){return e==null||e==="BODY"||e==="HTML"}const VP="Continue from where you left off.";function aY(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 GP(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 tp(e){return GP(Math.floor(e/1e3))}function yd(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 oY(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function np(e,t,n){const s=new Date(e),a=tp(t-e);return{label:oY(s,new Date(t))?a:`${a} · ${s.toLocaleDateString(n,{month:"short",day:"numeric"})}`,title:s.toLocaleString(n,{dateStyle:"medium",timeStyle:"medium"})}}function yN(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 iY(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 wN(e,t){const n=tp(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 sp(e){if(!e.ok)return iY(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: “${VP}”${n}`}function KP({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 lY(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 cY(e,t){return[`claude stop ${e}`,`claude --resume ${t} --bg "${VP}"`].join(`
|
|
83
|
+
`)}let to={answer:null,pressing:new Set,pressed:{}};const Ky={current:new Set},N1=new Set;function S1(e){to={...to,...e};for(const t of N1)t()}const uY=e=>(N1.add(e),()=>{N1.delete(e)}),wT=()=>to;function xN(){return g.useSyncExternalStore(uY,wT,wT)}const dY=new Set(["login","usage-limit","api-error"]),vN=e=>typeof e=="number"&&Number.isFinite(e)?e:null,YP=e=>typeof e=="string"?e:"";function hY(e){if(!e||typeof e!="object")return null;const t=e,n=vN(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:YP(t.detail),stopped:t.stopped===!0}}function fY(e){if(!e||typeof e!="object")return null;const t=e;return{ok:t.ok===!0,at:vN(t.at)??0,room:typeof t.room=="boolean"?t.room:null}}function pY(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 l=i,u=l.stop,h=u&&dY.has(u.kind)&&vN(u.at)!=null?{kind:u.kind,at:u.at}:null;s[o]={stop:h,held:l.held===!0,tried:l.tried===!0,last:hY(l.last)}}return{auto:n.auto===!0,login:t?fY(n.login):null,withLogin:t,sessions:s}}async function Af(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=pY(await s.json(),e);if(!a)return;const o=e?a.login:((t=to.answer)==null?void 0:t.login)??null;S1({answer:{...a,login:o,withLogin:e||(((n=to.answer)==null?void 0:n.withLogin)??!1)}})}catch{}}async function mY(e,t){if(!Sn(Ky.current.has(e)))return null;Ky.current.add(e),S1({pressing:new Set([...to.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"?yN((o==null?void 0:o.gate)??null):YP(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}}Ky.current.delete(e);const s=new Set(to.pressing);return s.delete(e),S1({pressing:s,pressed:{...to.pressed,[e]:n}}),Af(!0),n}const XP=30*6e4;function bN(e,t){var l,u,h,f,p;if(e.kind!=="root"||e.provider==="codex")return null;const n=((l=t.answer)==null?void 0:l.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:((u=e.job)==null?void 0:u.id)||null,loaded:((h=t.answer)==null?void 0:h.withLogin)===!0,gate:aY(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 gY=15e3,yY=2*6e4;function wY(e){for(const t of e.agents.values())if(t.kind==="root"&&t.stopFailure)return!0;return!1}function xY({stateRef:e,now:t,enabled:n}){const s=g.useRef(0);n&&wY(e.current)&&(s.current=t);const a=n&&s.current>0&&t-s.current<yY;g.useEffect(()=>{n&&Af(!1)},[n]),g.useEffect(()=>{if(!a)return;Af(!0);const o=window.setInterval(()=>{Af(!0)},gY);return()=>window.clearInterval(o)},[a])}function ZP(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.":yN(e.gate.reason):"Checking for a working login…",e.stop?KP({auto:e.auto,kind:e.stop.kind,held:e.held,tried:e.tried}):"",e.last&&e.stop&&e.last.at>=e.stop.at?`${wN(e.last,t)}. ${sp(e.last)}`:""].filter(Boolean).join(`
|
|
84
|
+
`)}function JP(e,t){return g.useCallback(()=>{!(e!=null&&e.stop)||!e.gate.ready||e.pressing||mY(t,e.stop)},[e,t])}function vY({data:e}){const t=xN(),n=Nr(15e3),s=bN(e,t),a=JP(s,e.sessionId);return!(s!=null&&s.stop)||!s.background?null:r.jsx("button",{type:"button",className:"stop-continue",...Fn(s.pressing,!(s.loaded&&s.gate.ready)),title:ZP(s,n),onClick:o=>{o.stopPropagation(),a()},children:s.pressing?"Continuing…":"Continue"})}function bY({data:e}){const t=xN(),n=Nr(15e3),s=bN(e,t);return!s||s.stop||!s.last||n-s.last.at>XP?null:r.jsxs("div",{className:`continued-row${s.last.ok?"":" failed"}`,title:sp(s.last),children:[r.jsx("span",{className:"waiting-dot","aria-hidden":!0}),r.jsx("span",{className:"continued-said",children:wN(s.last,n)})]})}function kY({agent:e}){const t=xN(),n=Nr(15e3),s=bN(e,t),a=JP(s,e.sessionId),[o,i]=g.useState(null),l=g.useCallback(async(m,w)=>{await ho(w)&&(i(m),window.setTimeout(()=>i(v=>v===m?null:v),1600))},[]);if(!s)return null;const u=s.last&&(!s.stop||s.last.at>=s.stop.at)&&n-s.last.at<=XP?r.jsxs("p",{className:`detail-continue-last${s.last.ok?"":" failed"}`,title:sp(s.last),children:[wN(s.last,n),". ",sp(s.last)]}):null;if(!s.stop)return u?r.jsxs("section",{className:"detail-section",children:[r.jsx("h3",{children:"Continue"}),u]}):null;const h=s.loaded?s.gate.ready?s.stop.kind==="api-error"?"":"A working login with room is active now.":yN(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:lY(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:()=>{l("word","continue")},children:o==="word"?"Copied":"Copy “continue”"})})]});const f=KP({auto:s.auto,kind:s.stop.kind,held:s.held,tried:s.tried}),p=s.jobId?cY(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}),u,r.jsx("div",{className:"detail-continue-actions",children:r.jsx("button",{type:"button",className:"btn primary detail-continue-btn",...Fn(s.pressing,!(s.loaded&&s.gate.ready)),title:ZP(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:()=>{l("commands",p)},children:o==="commands"?"Copied":"Copy"})]})]})}const xT=typeof window>"u"?g.useEffect:g.useLayoutEffect;function jY({data:e}){var B,A;const t=$l(e),n=["agent-node",`state-${t}`,e.synthetic?"synthetic":""].filter(Boolean).join(" "),s=e.tools.filter(q=>!q.endedAt).length,a=e.toolErrorCount??0,o=Gu(e.canvasSessionId??e.sessionId),i=((B=e.context)==null?void 0:B.currentContextTokens)??0,l=e.kind==="root"&&i>0,u=e.sessionTitle?e.cwd?`${e.cwd}
|
|
85
|
+
${e.sessionTitle}`:e.sessionTitle:e.cwd,h=lN(e),f=g.useRef(null),p=g.useRef(null),m=yG(e),[w,v]=g.useState(0),[j,b]=g.useState(null);xT(()=>{v(0)},[e.effort,e.model,h.length,e.cwdBasename,e.childCount,e.kind,m,j]),xT(()=>{const q=f.current;if(!q||w>=m)return;const T=p.current,F=wG(w,{overflowing:q.scrollWidth>q.clientWidth,folderCut:!!T&&T.scrollWidth>T.clientWidth,max:m});F!==w&&v(F)}),g.useEffect(()=>{const q=f.current;if(!q||typeof ResizeObserver>"u")return;let T=q.clientWidth;const F=new ResizeObserver(()=>{q.clientWidth!==T&&(T=q.clientWidth,kt.flushSync(()=>b(T)))});return F.observe(q),()=>F.disconnect()},[]);const N=xG(w),x=e.model&&(h.length>0?`${Yu(e.model,e.effort)}
|
|
86
|
+
spend on this card also covers:
|
|
87
|
+
${h.join(`
|
|
88
|
+
`)}`:Yu(e.model,e.effort)),S=Qp(e.sessionName,e.sessionTitle),C=IP(e),_=(C==null?void 0:C.note)??null,M=C?C.key:null,R=yK(M),P=C!=null&&!R,L=(_==null?void 0:_.kind)==="recap",U=pG(e);return r.jsxs("div",{className:n,style:{"--session-hue":o},children:[r.jsx("span",{className:"accent-stripe"}),r.jsx(fi,{type:"target",position:Ye.Left,style:{background:"transparent",border:"none"}}),r.jsxs("div",{className:"head",children:[r.jsxs("div",{className:"title",children:[r.jsx(EY,{state:t}),r.jsx("span",{className:"label",title:u,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:"?"}),C&&M&&r.jsx("button",{type:"button",className:"glyph-btn recap-pin","aria-label":L?"Claude Code's recap":_?`Session note: ${rc(_.kind)}`:"Session note: plan","aria-expanded":P,title:L?P?"Hide the recap":"Show Claude Code's recap":_?P?"Hide this note":"Show what this session is doing":P?"Hide the plan":"Show the plan",onClick:q=>{q.stopPropagation(),gK(M)},children:r.jsx(ep,{recap:L})})]}),r.jsx("div",{className:"head-right",children:l&&e.onOpenContext&&r.jsx(aK,{currentContextTokens:i,modelId:e.model,contextWindow:e.contextWindow,onClick:()=>e.onOpenContext(e.sessionId)})})]}),r.jsxs("div",{className:"sub",title:IG(e),children:[r.jsxs("span",{className:"sub-details",ref:f,children:[N.kind&&r.jsx("span",{children:Jp(e)}),e.childCount>0&&r.jsxs("span",{className:"spawn-badge",title:LG(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":Yp(e.model),title:x,children:[Xp(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(_Y,{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(TY,{data:e,stop:e.stopFailure}),e.kind==="root"&&!e.stopFailure&&r.jsx(bY,{data:e}),e.waiting&&!(e.stopFailure&&e.waiting.kind==="idle")&&r.jsx(AY,{waiting:e.waiting}),(()=>{const q=vP(e);return q?r.jsxs("div",{className:"approval-blind-row",title:q.detail,children:[r.jsx("span",{className:"approval-blind-dot","aria-hidden":!0}),r.jsx("span",{className:"approval-blind-said",children:q.label})]}):null})(),(()=>{const q=jr(e.plan);return q&&e.plan?r.jsx(SY,{plan:q,items:e.plan.items}):null})(),(e.tools.length>0||(((A=e.outputs)==null?void 0:A.length)??0)>0)&&r.jsx(RY,{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:Ct(e.usage.inputTokens+e.usage.outputTokens)})," tok"]}),(U==null?void 0:U.kind)==="unpriced"&&r.jsx("span",{className:"cost-unpriced",title:U.tt,children:da}),(U==null?void 0:U.kind)==="spent"&&r.jsx("span",{className:"cost-meta",title:U.tt,children:r.jsxs("b",{children:[ct(U.total),U.floor?"+":""]})})]}),r.jsx(CY,{data:e,title:e.kind==="root"?S.face:void 0}),r.jsx(fi,{type:"source",position:Ye.Right,style:{background:"transparent",border:"none"}})]})}const NY=g.memo(jY);function SY({plan:e,items:t}){return r.jsxs("div",{className:e.allDone?"plan-row plan-done":"plan-row",title:Vp(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 CY({data:e,title:t}){const n=e.kind==="root"&&_n(e.waiting),s=SK(e,e.branch,{sayWaiting:Jf,describeCall:a=>({name:mN(a.name).label,subject:ZK(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(WP,{kind:b1($l(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(gN,{})]}),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 _Y({start:e,end:t}){const n=Nr(1e3);return r.jsx(r.Fragment,{children:Kl(e,t,n)})}function EY({state:e}){return r.jsx("span",{className:`state-pill state-${e}`,children:Vl(e)})}function TY({data:e,stop:t}){return r.jsxs("div",{className:"stop-row",title:AG(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:kP(t)}),r.jsx(vY,{data:e})]})}function AY({waiting:e}){const t=Nr(1e3),n=_n(e),s=Gl(e);return r.jsxs("div",{className:n?"waiting-row permission":"waiting-row idle",title:`${s}
|
|
89
|
+
Blocked for ${Kl(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:Jf(e)}),r.jsx("b",{children:Kl(e.since,void 0,t)})]})}function RY({tools:e,outputs:t}){const n=Nr(1e3),{counts:s,title:a}=nY(e,t,n),o=Gy/Ll;return r.jsxs("div",{className:"tool-spark-row",title:a,children:[r.jsx("svg",{className:"tool-spark",width:Gy,height:Tf,viewBox:`0 0 ${Gy} ${Tf}`,"aria-hidden":!0,children:s.map((i,l)=>{const u=rY(i),h=l===Ll-1&&i>0,p=`tool-spark-bar${i>0?" active":""}${h?" latest":""}`;return r.jsx("rect",{x:l*o+.4,y:Tf-u,width:Math.max(.5,o-1),height:u,rx:.8,className:p},h?`landed:${i}`:l)})}),r.jsx("span",{className:"tool-spark-label",children:"60s"})]})}function MY({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 kN="agent-dag.single-key-shortcuts";function QP(e){return e!=="0"}function eD(e){return e.length===1}function $Y(e,t){return!t&&eD(e)}function Cn(e,t,n){return n?`${e} (${t})`:e}let oi=null;const vu=new Set;function tD(){for(const e of vu)e()}function C1(){return oi===null&&(oi=QP(nt(kN))),oi}function LY(e){oi!==e&&(oi=e,st(kN,e?"1":"0"),tD())}function vT(e){if(e.key!==kN)return;const t=QP(e.newValue);t!==oi&&(oi=t,tD())}function IY(e){var t;return vu.add(e),vu.size===1&&typeof window<"u"&&((t=window.addEventListener)==null||t.call(window,"storage",vT)),()=>{var n;vu.delete(e),vu.size===0&&typeof window<"u"&&((n=window.removeEventListener)==null||n.call(window,"storage",vT))}}function rp(e){const t=Math.max(0,Math.floor(e));return`${t} event${t===1?"":"s"}`}const bT=99;function OY(e){const t=Math.max(0,Math.floor(e));return t>bT?`${bT}+`:String(t)}const PY="Pause the canvas";function DY(e){const t=e.singleKeys??!0;if(!e.paused)return Cn("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?Cn(`The pause is full — ${rp(e.held)} held and ${n} older ${n===1?"one":"ones"} already dropped. Resume to follow the canvas again`,"Space",t):e.held<=0?Cn("Nothing has arrived since you paused. Resume to follow the canvas again","Space",t):Cn(`${rp(e.held)} arrived while paused and will be applied in order when you resume`,"Space",t)}function FY(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 nD="paused · full",BY=(e,t)=>t>0?nD:e>0?`paused · ${OY(e)}`:"paused";function qY(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:BY(e.held,t),widest:nD,title:Cn(t>0?`Connected — the pause is full at ${rp(e.held)}; the oldest are being dropped as new ones arrive. Resume to catch up`:e.held>0?`Connected — ${rp(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 Tn(){return g.useSyncExternalStore(IY,C1,C1)}const UY=e=>e.transform[2]>=e.maxZoom,WY=e=>e.transform[2]<=e.minZoom;function HY({autoFitDisabled:e,enableAutoFitAndRefit:t,paused:n,pauseGate:s,togglePause:a,handleRelayout:o,requestClear:i,setKeyHelpOpen:l}){const u=ec(),h=ht(UY),f=ht(WY),p=Tn();return r.jsxs(j9,{showInteractive:!1,showFitView:!1,showZoom:!1,children:[r.jsx(fs,{onClick:()=>{h||u.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(fs,{onClick:()=>{f||u.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(fs,{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(fs,{"data-group-start":"",onClick:a,title:DY({paused:n,held:s.size,dropped:s.dropped,singleKeys:p}),"aria-label":PY,"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(fs,{onClick:o,title:Cn("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(fs,{"data-group-start":"","data-danger":"",onClick:()=>i("button"),title:Cn("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(fs,{"data-group-start":"",onClick:()=>l(m=>!m),title:p?Cn("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 zY="modulepreload",VY=function(e){return"/"+e},kT={},bi=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 l=document.querySelector("meta[property=csp-nonce]"),u=(l==null?void 0:l.nonce)||(l==null?void 0:l.getAttribute("nonce"));a=i(n.map(h=>{if(h=VY(h),h in kT)return;kT[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":zY,f||(m.as="script"),m.crossOrigin="",m.href=h,u&&m.setAttribute("nonce",u),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 l=new Event("vite:preloadError",{cancelable:!0});if(l.payload=i,window.dispatchEvent(l),!l.defaultPrevented)throw i}return a.then(i=>{for(const l of i||[])l.status==="rejected"&&o(l.reason);return t().catch(o)})},jT="agent-dag.fm-custom-stations",NT="agent-dag.fm-muted",_1="custom:",GY=/^UC[A-Za-z0-9_-]{22}$/,KY=/^[A-Za-z0-9_-]{11}$/,sD=/^[A-Za-z0-9_-]{1,80}$/,YY=/\.(mp3|aac|ogg)$/i,XY=/\.m3u8$/i,ZY=2048,rD=80;function Xl(e){return`${_1}${e}`}function am(e){if(!e.startsWith(_1))return null;const t=e.slice(_1.length);return sD.test(t)?t:null}function ST(e){return am(e)??e}function jN(e){var i,l;const t=e.trim();if(t.length>ZY)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 u=(i=/^\/channel\/([^/]+)(?:\/live)?\/?$/.exec(n.pathname))==null?void 0:i[1];if(u&&GY.test(u))return{kind:"youtube-channel",url:s,channel:u};const h=(l=/^\/@([^/]+)\/live\/?$/.exec(n.pathname))==null?void 0:l[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(KY.test(f))return{kind:"youtube-video",url:s,video:f}}return null}return XY.test(n.pathname)?{kind:"direct-audio",url:s,format:"hls"}:YY.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 JY(e){return e==="1"}function QY(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():"",l=typeof a.url=="string"?a.url.trim():"",u=jN(l);if(!sD.test(o)||n.has(o)||!i||i.length>rD||!u)continue;n.add(o);const h=aD(a.radio);s.push({id:o,name:i,url:u.url,...h?{radio:h}:{}})}return s}function eX(e,t,n){const s=am(e??"");return s&&t.some(a=>a.id===s)?Xl(s):n(e)}function tX(e,t){return e===Xl(t)?"claude-fm":e}function aD(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 E1="https://www.youtube-nocookie.com";function nX(e,t,n){const s=new URLSearchParams({...n?{}:{channel:e},enablejsapi:"1",autoplay:"1",playsinline:"1",rel:"0",modestbranding:"1",origin:t});return`${E1}/embed/${n?encodeURIComponent(n):"live_stream"}?${s.toString()}`}function cl(e,t=[]){return JSON.stringify({event:"command",func:e,args:t})}function sX(e="claude-fm"){return JSON.stringify({event:"listening",id:e,channel:"widget"})}const rX=[1],aX=[0,2],oX=[2,5,100,101,150,153];function iX(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:rX.includes(a)?{kind:"playing",playing:!0}:a===3?{kind:"buffering"}:aX.includes(a)?{kind:"playing",playing:!1}:null}return null}const ou=new Set;let CT="";function _T(e){const t=new Date().toISOString().slice(0,10);if(t!==CT&&(ou.clear(),CT=t),!ou.has(e)){ou.add(e);try{const n=typeof navigator>"u"?void 0:navigator;(!n||typeof n.sendBeacon!="function"||!n.sendBeacon("/api/feature",JSON.stringify({name:e})))&&ou.delete(e)}catch{ou.delete(e)}}}const ET=864e5,lX=6e4;function sn(e,t=!0){g.useEffect(()=>{if(!t)return;_T(e);let n;const s=()=>{n=setTimeout(()=>{_T(e),s()},ET-Date.now()%ET+lX)};return s(),()=>clearTimeout(n)},[e,t])}const cX={"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 uX({fetchImpl:e,enabled:t=!0,volume:n,muted:s,source:a,playRequest:o,customStation:i,onAvailabilityChange:l}){var q;const[u,h]=g.useState(null),[f,p]=g.useState(!1),[m,w]=g.useState(!1),[v,j]=g.useState(!1),[b,N]=g.useState(!1);sn("claude-fm",v);const x=g.useRef(o),S=g.useRef(null),C=g.useRef(null),_=g.useRef(void 0),M=g.useRef(null),R=g.useCallback(()=>{var F;clearTimeout(_.current),(F=C.current)==null||F.destroy(),C.current=null;const T=S.current;T&&(T.pause(),T.removeAttribute("src"),T.load(),S.current=null)},[]),P=g.useCallback(T=>{var F,O;(O=(F=M.current)==null?void 0:F.contentWindow)==null||O.postMessage(T,E1)},[]),L=g.useRef(n);L.current=n;const U=g.useRef(s);U.current=s;const B=g.useCallback((T,F,O)=>{R();const K=new Audio;K.preload="none",K.volume=L.current/100,K.muted=U.current,S.current=K,w(!0),j(!1),N(!1);let V=!1;const H=()=>S.current===K,D=()=>{clearTimeout(_.current),R(),w(!1),j(!1),N(!1)},I=()=>{H()&&(D(),p(!0),l==null||l(O,!0))},W=z=>{if(H()&&!(z instanceof DOMException&&z.name==="AbortError")){if(z instanceof DOMException&&z.name==="NotAllowedError"){D();return}I()}};_.current=setTimeout(()=>{H()&&!V&&I()},15e3),K.addEventListener("playing",()=>{H()&&(clearTimeout(_.current),V=!0,j(!0),N(!1),l==null||l(O,!1))});const Z=()=>{H()&&(j(!1),N(V),clearTimeout(_.current),_.current=setTimeout(()=>{H()&&I()},15e3))};K.addEventListener("waiting",Z),K.addEventListener("stalled",Z),K.addEventListener("ended",()=>{H()&&D()}),K.addEventListener("error",I,{once:!0}),F&&!K.canPlayType("application/vnd.apple.mpegurl")?bi(async()=>{const{default:z}=await import("./hls-BFpXDghs.js");return{default:z}},[]).then(({default:z})=>{if(!H())return;if(!z.isSupported()){I();return}const X=new z;C.current=X,X.on(z.Events.ERROR,(Y,J)=>{J.fatal&&I()}),X.on(z.Events.MEDIA_ATTACHED,()=>X.loadSource(T)),X.on(z.Events.MANIFEST_PARSED,()=>{K.play().catch(W)}),X.attachMedia(K)},I):(K.src=T,K.play().catch(W))},[l,R]);g.useEffect(()=>{m&&(P(cl("setVolume",[n])),P(cl(s?"mute":"unMute")),S.current&&(S.current.volume=n/100,S.current.muted=s))},[n,s,m,P]),g.useEffect(()=>{var D;let T=!0;const F=e??fetch,O=x.current!==o;if(x.current=o,h(null),p(!1),N(!1),w(O),j(!1),R(),!t){w(!1),j(!1);return}const K=i&&Xl(i.id)===a?jN(i.url):null;if(K){if(K.kind==="direct-audio"){const I=K.format==="hls"||((D=i==null?void 0:i.radio)==null?void 0:D.hls)===!0;return h({live:!0,channel:"",audio:K.url,hls:I}),l==null||l(a,!1),O&&B(K.url,I,a),()=>{T=!1}}return F(`/api/fm-station?url=${encodeURIComponent(K.url)}`).then(I=>I.ok?I.json():null).then(I=>{T&&(I!=null&&I.channel||I!=null&&I.video?(h({live:!0,channel:I.channel??"",video:I.video??void 0}),l==null||l(a,!1)):(p(!0),w(!1),j(!1),N(!1),l==null||l(a,!0)))}).catch(()=>{T&&(p(!0),w(!1),j(!1),N(!1),l==null||l(a,!0))}),()=>{T=!1}}if(am(a))return p(!0),l==null||l(a,!0),()=>{T=!1};const V=a,H=cX[V];if(H)F(H).then(I=>I.ok?I.json():null).then(I=>{T&&(I!=null&&I.video&&h({live:!0,channel:"",video:I.video}),I!=null&&I.video||(p(!0),w(!1),j(!1)),l==null||l(a,!(I!=null&&I.video)))}).catch(()=>{T&&(p(!0),w(!1),j(!1),l==null||l(a,!0))});else if(V!=="claude-fm"){const I=V.replace("lofi-","");F(`/api/lofi-girl?station=${encodeURIComponent(I)}`).then(W=>W.ok?W.json():null).then(W=>{T&&(W!=null&&W.video&&h({live:!0,channel:"",video:W.video}),W!=null&&W.video||(p(!0),w(!1),j(!1)),l==null||l(a,!(W!=null&&W.video)))}).catch(()=>{T&&(p(!0),w(!1),j(!1),l==null||l(a,!0))})}else F("/api/claude-fm").then(I=>I.ok?I.json():null).then(I=>{if(!T)return;const W=!!(I!=null&&I.live&&(I!=null&&I.channel));W&&h({live:!0,channel:I.channel}),W||(p(!0),w(!1),j(!1)),l==null||l(a,!W)}).catch(()=>{T&&(p(!0),w(!1),j(!1),l==null||l(a,!0))});return()=>{T=!1}},[i==null?void 0:i.id,i==null?void 0:i.url,(q=i==null?void 0:i.radio)==null?void 0:q.hls,t,e,l,o,a,B,R]),g.useEffect(()=>()=>R(),[R]),g.useEffect(()=>{if(!m||u!=null&&u.audio)return;let T;const F=()=>{clearTimeout(T),T=void 0,w(!1),j(!1),N(!1),p(!0),l==null||l(a,!0)},O=()=>{T??(T=setTimeout(F,15e3))};O();const K=V=>{var D;if(V.origin!==E1||V.source!==((D=M.current)==null?void 0:D.contentWindow))return;const H=iX(V.data);if(H){if(H.kind==="ready"){P(cl("setVolume",[L.current])),P(cl(U.current?"mute":"unMute")),P(cl("playVideo"));return}if(H.kind==="blocked"){clearTimeout(T),T=void 0,w(!1),j(!1),N(!1);return}if(H.kind==="buffering"){j(!1),N(!0),O();return}if(H.kind==="playing"){clearTimeout(T),T=void 0,j(H.playing),N(!1),H.playing||w(!1);return}oX.includes(H.code)&&F()}};return window.addEventListener("message",K),()=>{clearTimeout(T),window.removeEventListener("message",K)}},[m,u==null?void 0:u.audio,o,l,P,a]);const A=g.useCallback(()=>{if(u){if(u.audio){if(m){R(),w(!1),j(!1),N(!1);return}B(u.audio,u.hls===!0,a);return}if(!m){w(!0),j(!1),N(!1);return}P(cl("pauseVideo")),w(!1),j(!1),N(!1)}},[u,m,v,a,P,B,R]);return g.useMemo(()=>({probe:u,dead:f,armed:m,playing:v,buffering:b,frame:M,say:P,press:A}),[u,f,m,v,b,P,A])}const TT="agent-dag.radio-favorites",AT="agent-dag.radio-recent",RT="agent-dag.radio-catalogue";function dX(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"?jN(s.url):null,l=aD(s.radio??s);return!/^radio-[a-f0-9]{8}(?:-[a-f0-9]{4}){3}-[a-f0-9]{12}$/i.test(a)||!o||!l||!i||i.kind!=="direct-audio"||t.has(a)?[]:(t.add(a),[{id:a,name:o,url:i.url,radio:l}])})}function MT(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 hX(e,t){return[t,...e.filter(n=>n!==t)].slice(0,50)}function J1e(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 Q1e(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 oD(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 eje(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 tje(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 fX(){const[e,t]=g.useState(()=>MT(nt(TT))),[n,s]=g.useState(()=>MT(nt(AT))),[a,o]=g.useState(()=>{try{return dX(JSON.parse(nt(RT)??"[]"))}catch{return[]}});g.useEffect(()=>{st(TT,JSON.stringify(e))},[e]),g.useEffect(()=>{st(AT,JSON.stringify(n))},[n]);const i=g.useCallback(h=>s(f=>hX(f,h)),[]),l=g.useCallback(h=>t(f=>f.includes(h)?f.filter(p=>p!==h):[...f,h].slice(-100)),[]),u=g.useCallback(h=>{o(h),st(RT,JSON.stringify(h))},[]);return{favorites:e,recent:n,catalogue:a,remember:i,toggleFavorite:l,updateCatalogue:u}}function pX(e,t,n,s){const a=oD(e,t,n);if(!a)return()=>{};const o=setTimeout(()=>{n.add(t),s(a)},1e3);return()=>clearTimeout(o)}const om=148,$T=6e3,mX=16e3,iD=46,Ja=34;function gX(e,t,n=om){let s=-Math.round(t()*n);if(Math.abs(s-e)<Ja){const a=e-Ja>=-n?-Ja:Ja;s=Math.max(-n,Math.min(0,Math.round(e+a)))}return{to:s,ms:Math.round(Math.abs(s-e)*iD)}}function yX(e){return Math.round($T+e()*(mX-$T))}const LT=[{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 wX(e){const t=LT.reduce((s,a)=>s+a.weight,0);let n=e()*t;for(const s of LT)if(n-=s.weight,n<0)return s.kind;return"stroll"}const xX=720,vX=260,bX=620,kX=220,IT=520,lD=1600,OT=7e3,jX=15e3,PT=6e3,NX=14e3;function ul(e,t,n=om){let s=-Math.round(t()*n);if(Math.abs(s-e)<Ja){const a=e-Ja>=-n?-Ja:Ja;s=Math.max(-n,Math.min(0,Math.round(e+a)))}return s}const Jt=(e,t)=>Math.round(Math.abs(t-e)*iD),SX=120,ef=0;function CX(e,t){const n=s=>({kind:"litter",at:t,...s});return[{x:t,prop:n({}),act:"walk",ms:Jt(e,t)},{x:t,prop:n({}),act:"stoop",ms:xX},{x:ef,prop:n({held:!0}),act:"carry",ms:Jt(t,ef)},{x:ef,prop:n({held:!0}),act:"windup",ms:vX},{x:ef,prop:n({held:!0,leaving:!0}),act:"toss",ms:bX}]}function _X(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:Jt(e,s)},{x:s,prop:a(),act:"windup",ms:kX,facing:n>0?"right":"left"},{x:s,prop:a({leaving:!0}),act:"kick",ms:IT,facing:n>0?"right":"left"},{x:s,prop:a({leaving:!0}),act:"stand",ms:lD-IT}]}const cD=640;function EX(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:Jt(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:Jt(s,0)}]}function TX(e,t,n){const s=Math.max(-110,Math.min(-30,t)),a={x:s,prop:null};return[{...a,act:"walk",ms:Jt(e,s)},{...a,act:"skip-ready",ms:500},{...a,act:"skip",ms:cD*(6+Math.floor(n()*5))},{...a,act:"skip-rest",ms:600},{...a,act:"stand",ms:350},{x:0,prop:null,act:"walk",ms:Jt(s,0)}]}function AX(e,t,n){return[{x:t,prop:null,act:"walk",ms:Jt(e,t)},{x:t,prop:null,act:"sit",ms:Math.round(PT+n()*(NX-PT))},{x:t,prop:null,act:"stand",ms:400}]}function RX(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:Jt(e,t)},{x:t,prop:s(),act:"watch",ms:Math.round(OT+n()*(jX-OT))},{x:t,prop:s(),act:"scope-pack",ms:480},{x:t,prop:null,act:"stand",ms:240}]}function Yy(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 MX=1500,$X=e=>Math.round(1e3*Math.sqrt(2*e/MX)),LX=115,IX=e=>Math.round(e/LX*1e3),OX=620,PX=200,DX=760,FX=600,BX=240;function qX(e,t,n){const a=-(t.ledgeSpan??om),o=$X(t.ledgeH),i=IX(t.ledgeH),l=n(),u=n(),h=-Math.round(l*t.floorSpan),f=-Math.round(u*t.floorSpan);return[{x:a,act:"walk",prop:null,ms:Jt(e,a)},{x:a,act:"peer",prop:null,ms:OX},{x:a,act:"fall",prop:null,ms:o,place:"floor"},{x:a,act:"land",prop:null,ms:PX,place:"floor"},{x:h,act:"walk",prop:null,ms:Jt(a,h),place:"floor",floorFrac:l},{x:f,act:"walk",prop:null,ms:Jt(h,f),place:"floor",floorFrac:u},{x:a,act:"walk",prop:null,ms:Jt(f,a),place:"floor"},{x:a,act:"lasso",prop:null,ms:DX,place:"floor"},{x:a,act:"rope-throw",prop:null,ms:FX,place:"floor"},{x:a,act:"rope-catch",prop:null,ms:BX,place:"floor"},{x:a,act:"climb",prop:null,ms:i},{x:a,act:"pull-up",prop:null,ms:480}]}function UX(e,t,n){const s=(n==null?void 0:n.ledgeSpan)??om;switch(wX(t)){case"tidy":return CX(e,ul(e,t,s));case"kick":return _X(e,ul(e,t,s));case"sit":return AX(e,ul(e,t,s),t);case"watch":return RX(e,ul(e,t,s),t);case"fish":return EX(e,ul(e,t,s),t);case"skip":return TX(e,ul(e,t,s),t);case"leave":{if(!n||!(n.ledgeH>0)||!(n.floorSpan>0))break;return qX(e,n,t)}}const o=gX(e,t,s);return[{x:o.to,prop:null,act:"walk",ms:o.ms}]}const WX=420;function HX(e,t,n){const s=t==="right"?n-e-18:e-18;return(t==="right"?1:-1)*Math.min(WX,Math.max(0,s))}const zX=260,VX=200;function GX(e,t,n){const s=(f,p=Jt(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,l=i?n.left:n.right,u=i?n.right:n.left,h={place:"floor",riser:n.height,prop:null};return[s(l,Jt(e,l)),{...h,x:l,act:"mount",ms:zX},{...h,x:u,act:"walk",ms:Jt(l,u)},{x:u,prop:null,act:"dismount",ms:VX,place:"floor"},{x:t,prop:null,act:"walk",ms:Jt(u,t),place:"floor"}]}const uD=["bob","sway","groove"],DT=9e3,KX=16e3,dD=1e3,YX=.08;function XX(e,t){const n=uD.filter(o=>o!==e),s=n[Math.min(n.length-1,Math.floor(t()*n.length))],a=(t()*2-1)*YX;return{dance:s,beatMs:Math.round(dD*(1+a))}}function ZX(e){return Math.round(DT+e()*(KX-DT))}const NN=["......aaaaaa......","....aa......aa....","...a..bbbbbs..a...","...cpcbbbbbscpc...","...cpcbebbescpc...","...cpcbbbbbscpc...","...cpcbbbbbscpc...","....ccbbbbbscc....","....bbbbbbbbbs....","....bbbbbbbbbs....","......bbbbbs......","......bb..bs......","......bb..bs......","......bb..bs......"],FT=18,JX=NN.length,hD="M6 9H4V1H5V0H7V-1H9V1H7V2H5V7H6V8H7V9Z",fD="M12 9H14V6H13V3H11V2H9V4H12Z",SN=new Set(["a","c","p"]);function fo(e=NN){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 QX=[".xx.","xxxx",".xx."],eZ=["..xx..",".xsxx.","xssxxx","xxxxsx",".xxxx.","..xx.."],tZ=["...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:QX,ball:eZ,scope:tZ},nZ=["...hhhhhh...","...hhhhhh...","...kkkkkk...","hhhhhhhhhhhh"],sZ=3,rZ=-1,T1=11,BT=9;function qT(e){let t=null,n=null,s=0,a=0,o=!1;const i=()=>{t!==null&&clearTimeout(t),t=null},l=()=>{o||e.hidden||!n||t!==null||(a=performance.now(),t=setTimeout(()=>{t=null;const h=n;n=null,h==null||h()},s))},u=()=>{e.hidden&&t!==null?(s=Math.max(0,s-(performance.now()-a)),i()):e.hidden||l()};return e.addEventListener("visibilitychange",u),{schedule(h,f){o||(i(),n=h,s=Math.max(0,f),l())},dispose(){o=!0,i(),n=null,e.removeEventListener("visibilitychange",u)}}}function aZ(e,t,n){const[s,a]=g.useState(0),[o,i]=g.useState(0),[l,u]=g.useState(null),[h,f]=g.useState(null),[p,m]=g.useState({x:0,drop:0}),[w,v]=g.useState("ledge"),[j,b]=g.useState("left"),[N,x]=g.useState(0),S=g.useRef(null),[C,_]=g.useState(()=>document.hidden);g.useEffect(()=>{const A=new Set,q=()=>{var T;if(document.hidden){for(const F of((T=S.current)==null?void 0:T.getAnimations({subtree:!0}))??[])if(F.playState==="running"||F.pending){const O=F.currentTime;F.pause(),O!==null&&(F.currentTime=O),A.add(F)}}else{for(const F of A)F.playState==="paused"&&F.play();A.clear()}_(document.hidden)};return q(),document.addEventListener("visibilitychange",q),()=>document.removeEventListener("visibilitychange",q)},[e,t]);const[M,R]=g.useState(null),[P,L]=g.useState(dD),[U,B]=g.useState(()=>{var A;return((A=window.matchMedia)==null?void 0:A.call(window,"(prefers-reduced-motion: reduce)").matches)??!1});return g.useEffect(()=>{var T;const A=(T=window.matchMedia)==null?void 0:T.call(window,"(prefers-reduced-motion: reduce)");if(!A)return;const q=()=>B(A.matches);return q(),A.addEventListener("change",q),()=>A.removeEventListener("change",q)},[]),g.useEffect(()=>{var J;if(!e||t||U)return;const A=qT(document);let q=0;a(Q=>q=Q);let T=null,F=0,O=0;const K=Q=>{var re,he;const[te,...le]=Q;if(!te){T=null,u(null),f(null),z();return}u(te.act),f(te.prop),v(te.place??"ledge"),x(te.riser??0);const de=q,oe=W(te);if(te.act==="kick"){const pe=(he=(re=S.current)==null?void 0:re.querySelector('.fm-prop[data-prop="ball"]'))==null?void 0:he.getBoundingClientRect();pe&&m({x:HX(pe.x,Yy(te,de,"left"),window.innerWidth),drop:Math.max(48,window.innerHeight-pe.y+24)})}O=te.act==="walk"?Math.max(Jt(de,oe),SX):te.ms,te.act==="carry"&&(O=Jt(de,oe)),i(O),b(pe=>Yy({...te,x:oe},de,pe)),a(oe),q=oe,T=te,F=Date.now(),A.schedule(()=>K(le),O)},V=()=>{const Q=S.current,te=Q==null?void 0:Q.querySelector(".fm-sprite"),le=Q==null?void 0:Q.parentElement;if(!Q||!te||!le)return null;const de=Q.getBoundingClientRect(),oe=le.getBoundingClientRect(),re=oe.right-de.right,he=oe.width-re*2-te.offsetWidth;return he>0?he:null},H=()=>{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)},D=()=>{const Q=S.current,te=Q==null?void 0:Q.querySelector(".fm-walker"),le=V();if(!Q||!te||le==null)return;const de=Q.getBoundingClientRect().bottom-te.getBoundingClientRect().bottom;if(de>0)return{ledgeH:de,floorSpan:le,ledgeSpan:H()}},I=()=>{const Q=S.current,te=document.querySelector(".canvas-notices");if(!Q||!te)return null;const le=Q.getBoundingClientRect(),de=te.getBoundingClientRect();return de.width<=0||de.height<=0?null:{left:de.left-le.right,right:de.right-le.right,height:de.height}},W=Q=>{const te=(Q.place??"ledge")==="floor",le=te?V()??H():H(),de=te&&Q.floorFrac!=null?-Math.round(Q.floorFrac*le):Q.x;return Math.max(-le,Math.min(0,de))},Z=()=>{if(!T)return;const Q=W(T);Q!==q&&(i(Math.max(0,F+O-Date.now())),b(te=>Yy({...T,x:Q},q,te)),a(Q),q=Q)},z=()=>{A.schedule(()=>{const Q=UX(q,Math.random,D()),te=Q.some(oe=>oe.place==="floor")?I():null;let le=q;const de=Q.flatMap(oe=>{const re=le;if(le=oe.x,!(oe.place==="floor"&&oe.act==="walk"))return[oe];const he=GX(re,oe.x,te),pe=he.length-1;return oe.floorFrac==null?he:he.map((Le,ge)=>ge===pe?{...Le,floorFrac:oe.floorFrac}:Le)});K(de)},yX(Math.random))},X=(J=S.current)==null?void 0:J.parentElement,Y=typeof ResizeObserver>"u"?null:new ResizeObserver(Z);return X&&Y&&Y.observe(X),z(),()=>{A.dispose(),Y==null||Y.disconnect(),v("ledge"),a(Q=>Math.max(-H(),Math.min(0,Q))),i(0),u(null),f(null),x(0)}},[e,t,U]),g.useEffect(()=>{if(!n||U){R(null);return}const A=qT(document),q=T=>{const F=XX(T,Math.random);R(F.dance),L(F.beatMs),A.schedule(()=>q(F.dance),ZX(Math.random))};return q(null),()=>A.dispose()},[n,U]),{scene:S,suspended:C,x:s,walkMs:o,act:l,prop:h,ballFlight:p,place:w,facing:j,riser:N,dance:M,beatMs:P}}const Zy={e:"fm-eye",s:"fm-shade",p:"fm-pad"},ap=fo().filter(e=>!SN.has(e.cell)),oZ=fo().filter(e=>SN.has(e.cell)),UT=ap.filter(e=>e.cell==="e"),iZ=fo(nZ),lZ=ap.filter(e=>e.y<T1&&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),cZ={left:ap.filter(e=>e.y>=T1&&e.x<BT),right:ap.filter(e=>e.y>=T1&&e.x>=BT)},uZ=g.memo(function({act:t,facing:n}){return r.jsxs("svg",{viewBox:`0 0 ${FT} ${JX}`,shapeRendering:"crispEdges","aria-hidden":!0,children:[r.jsx("g",{className:"fm-gear",children:r.jsx("g",{className:"fm-gear-motion",children:oZ.map(s=>r.jsx("rect",{x:s.x,y:s.y,width:s.w,height:1,className:Zy[s.cell]},`g${s.y}-${s.x}`))})}),r.jsxs("g",{className:"fm-body",children:[UT.map(s=>r.jsx("rect",{x:s.x,y:s.y,width:s.w,height:1,fill:"var(--accent)"},`eye-bed-${s.x}`)),lZ.map(s=>r.jsx("rect",{x:s.x,y:s.y,width:s.w,height:1,className:Zy[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"})]}),UT.map(s=>r.jsx("rect",{x:s.x-(s.x>=FT/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:iZ.map(s=>r.jsx("rect",{x:sZ+s.x,y:rZ+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:hD}),r.jsx("path",{className:"fm-grip-right",d:fD})]}),(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:cZ[s].map(a=>r.jsx("rect",{x:a.x,y:a.y,width:a.w,height:1,className:Zy[a.cell]},`${s}${a.y}-${a.x}`))},s))]})}),dZ=["...o........o.....","...of......fo.....","...owffffffwo.....","...offfffffso.....","...ofefffefso.....","....owwnwwso......",".....wwwww........",".....fwwwfs.......","....ffwwwffs...ww.","....ffwwwffs..wfs.","......fwwfssfffs..","......ff..fsffs...","......ff..fs......","......oo..oo......"],hZ=[".....aaaaaaa......","...aa.......aa....","..a...........a...","..cp.........pc...","..cp.........pc...","..cp.........pc...","..c...........c..."],ur={f:"#d88735",s:"#a55b24",o:"#63351e",w:"#ffe2aa",n:"#372821"},fZ={p:"fm-pad"},Xu=fo(dZ),pZ=fo(hZ);function A1(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 mZ=A1(Xu.filter(e=>e.y>=8),12,18),gZ=Xu.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),WT=Xu.filter(e=>e.cell==="e"),yZ={left:A1(Xu.filter(e=>e.y>=11),0,9),right:A1(Xu.filter(e=>e.y>=11),9,12)},wZ=g.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:mZ.map(i=>r.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,fill:ur[i.cell]},`t${i.y}-${i.x}`))}),r.jsx("g",{className:"fm-gear",children:r.jsx("g",{className:"fm-gear-motion",children:pZ.map(i=>r.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,className:fZ[i.cell]},`g${i.y}-${i.x}`))})}),r.jsxs("g",{className:"fm-body",children:[gZ.map(i=>r.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,fill:ur[i.cell]},`b${i.y}-${i.x}`)),WT.map(i=>r.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,fill:ur.f},`bed${i.x}`)),r.jsxs("g",{className:"fm-arms",fill:ur.f,children:[r.jsx("rect",{x:4,y:8,width:2,height:2}),r.jsx("rect",{x:12,y:8,width:1,height:2})]}),WT.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:ur.n}},`e${i.x}`))]}),s&&r.jsxs("g",{className:"fm-grip",style:{fill:ur.f},children:[r.jsx("path",{className:"fm-grip-left",d:hD}),r.jsx("path",{className:"fm-grip-right",d:fD})]}),a&&r.jsxs("g",{className:"fm-crouch-legs",style:{fill:ur.f},children:[r.jsx("path",{d:"M6 11H8V13H6Z"}),r.jsx("path",{d:"M10 11H12V13H10Z"})]}),o&&r.jsxs("g",{className:"fm-seated-legs",style:{fill:ur.f},children:[r.jsx("path",{className:"fm-seated-far",style:{fill:ur.s},d:"M10 10H12V11H11V14H8V13H9V11H10Z"}),r.jsx("path",{d:"M6 10H9V11H7V15H4V14H5V11H6Z"})]}),["left","right"].map(i=>r.jsx("g",{className:"fm-leg","data-side":i,children:yZ[i].map(l=>r.jsx("rect",{x:l.x,y:l.y,width:l.w,height:1,fill:ur[l.cell]},`${l.y}-${l.x}`))},i))]})}),xZ=[".......dddd.......","......dhhhhd......",".....dhhhhhhd.....","....dhwwhhwwhd....","....dhwewwewhd....","....dhwwbbwwhd....","....dhwwwwwwhd....","....dhwwwwwwhd....","....dhwwwwwwhd....",".....dhwwwwhd.....",".....dhwwwwhd.....","......dhhhhd......","......bb..bb......",".....bbb..bbb....."],Xr={d:"#3b4855",h:"#657b8b",w:"#f4f0df",e:"#19242b",b:"#f0b44b",s:"#c88736"},vZ={p:"fm-pad"},op=fo(xZ),bZ=fo(NN).filter(e=>SN.has(e.cell)),HT=op.filter(e=>e.cell==="e"),kZ=op.filter(e=>e.y<12&&e.cell!=="e"),jZ={left:op.filter(e=>e.y>=12&&e.x<9),right:op.filter(e=>e.y>=12&&e.x>=9)},NZ=g.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:bZ.map(o=>r.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,className:vZ[o.cell]},`g${o.y}-${o.x}`))})}),r.jsxs("g",{className:"fm-body",children:[kZ.map(o=>r.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,fill:Xr[o.cell]},`b${o.y}-${o.x}`)),HT.map(o=>r.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,fill:Xr.w},`bed${o.x}`)),r.jsxs("g",{className:"fm-arms",fill:Xr.d,children:[r.jsx("path",{d:"M4 8H6V10H5V11H4Z"}),r.jsx("path",{d:"M12 8H14V11H13V10H12Z"})]}),HT.map(o=>r.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,className:"fm-eye",style:{fill:Xr.e}},`e${o.x}`))]}),n&&r.jsxs("g",{className:"fm-grip",style:{fill:Xr.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:Xr.b},children:[r.jsx("path",{d:"M5 12H8V13H5Z"}),r.jsx("path",{d:"M10 12H13V13H10Z"})]}),a&&r.jsxs("g",{className:"fm-seated-legs",style:{fill:Xr.b},children:[r.jsx("path",{className:"fm-seated-far",style:{fill:Xr.s},d:"M10 11H12V12H13V14H10V13H11V12H10Z"}),r.jsx("path",{d:"M6 11H8V12H7V13H8V14H4V13H5V12H6Z"})]}),["left","right"].map(o=>r.jsx("g",{className:"fm-leg","data-side":o,children:jZ[o].map(i=>r.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,fill:Xr.b},`${i.y}-${i.x}`))},o))]})});function pD({character:e,act:t,facing:n}){return e==="penguin"?r.jsx(NZ,{act:t,facing:n}):e==="fox"?r.jsx(wZ,{act:t,facing:n}):r.jsx(uZ,{act:t,facing:n})}const SZ={"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 mD(e,t){return t&&Xl(t.id)===e?t.name:am(e)?"Custom FM":SZ[e]}function Jy(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:fo(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 zT={litter:Jy(Xy.litter,"litter"),ball:Jy(Xy.ball,"ball"),scope:Jy(Xy.scope,"scope")};function CZ(e){try{return new URL(e).host}catch{return"the station's server"}}const _Z=g.memo(function({player:t,source:n,customStation:s,character:a="deck"}){const{probe:o,dead:i,playing:l,press:u}=t,{scene:h,suspended:f,x:p,walkMs:m,act:w,prop:v,ballFlight:j,place:b,facing:N,riser:x,dance:S,beatMs:C}=aZ(o,i,l);if(!o||i)return null;const _=mD(n,s),M=o.audio?CZ(o.audio):"YouTube";return r.jsxs("div",{ref:h,className:"fm","data-suspended":f?"":void 0,"data-place":b,style:{"--fm-beat":`${C}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":`${j.x}px`,"--fm-ball-drop":`${j.drop}px`,"--fm-ball-flight-ms":`${lD}ms`,"--fm-ball-turn":N==="right"?"1080deg":"-1080deg"},children:zT[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":b,"data-facing":N,style:{"--fm-x":`${p}px`,"--fm-walk-ms":`${m}ms`,"--fm-riser":`${x}px`,"--fm-skip-beat":`${cD}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:zT[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":l?"":void 0,"data-dance":l?S??uD[0]:void 0,onClick:u,title:l?`Stop ${_}`:`Play ${_} — streams from ${M}`,"aria-label":l?`Stop ${_}`:`Play ${_}`,children:r.jsx(pD,{character:a,act:w,facing:N})})]})]})});function EZ({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:nX(n.channel,window.location.origin,n.video),onLoad:()=>o(sX()),allow:"autoplay; encrypted-media",sandbox:"allow-scripts allow-same-origin allow-presentation"})}):null}const TZ={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 AZ({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:TZ[e]})})}function RZ({opening:e=!1}){const[t,n]=g.useState(()=>document.hidden);return g.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 MZ({onClose:e}){const[t]=g.useState(()=>{var s;return((s=document.activeElement)==null?void 0:s.matches(":focus-visible"))??!1}),n=gt(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:VG,children:[r.jsx("button",{type:"button",className:"icon-btn","aria-label":"Close radio",onClick:e,children:r.jsx(AZ,{name:"close"})}),r.jsx(RZ,{opening:!0})]})}const $Z=g.lazy(()=>bi(()=>import("./RadioPanel-DbmJJPsz.js"),[]));function LZ({fm:e,characterEnabled:t,character:n,open:s,onClose:a}){const[o,i]=g.useState(!1),[l,u]=g.useState("Connecting to the deck…"),h=fX(),[f,p]=g.useState(null),m=g.useRef(new Set);g.useEffect(()=>{const R=new AbortController;return fetch("/api/music-config",{signal:R.signal}).then(P=>P.ok?P.json():null).then(P=>{R.signal.aborted||(i((P==null?void 0:P.enabled)===!0),u(P?"Music is turned off on this deck.":"Cannot reach the deck. Reopen Radio when it reconnects."))}).catch(()=>{R.signal.aborted||u("Cannot reach the deck. Reopen Radio when it reconnects.")}),()=>R.abort()},[s]);const w=e.customFmStations.find(R=>Xl(R.id)===e.fmSource),v=w!=null&&w.radio?w:void 0,j=uX({volume:e.fmVolume,muted:e.fmMuted,source:e.fmSource,playRequest:e.fmPlayRequest,customStation:w,enabled:o,onAvailabilityChange:e.markFmStationAvailability}),b=mD(e.fmSource,w),N=o&&v&&j.dead&&e.fmPlayRequest>0?oD(f??h.catalogue,v.id,m.current):null,{remember:x}=h,S=(w==null?void 0:w.id)??e.fmSource;g.useEffect(()=>{j.playing&&x(S)},[S,j.playing,x]);const C=a,_=yt(a),M=g.useCallback((R,P=!1)=>{var A;if(!o)return;P||m.current.clear();const L=Xl(R.id),U=L===e.fmSource;if(U&&j.armed&&!j.dead){j.press();return}const B=U&&!!w&&(w.url!==R.url||((A=w.radio)==null?void 0:A.hls)!==R.radio.hls);e.addFmStation(R,!0),U&&!j.dead&&!B?j.press():e.pickFmSource(L,B),fetch(`/api/radio-click?id=${encodeURIComponent(R.id)}`).catch(()=>{})},[o,w,e.addFmStation,e.fmSource,e.pickFmSource,j.armed,j.dead,j.press]);return g.useEffect(()=>{j.playing&&!j.dead&&m.current.clear()},[j.playing,j.dead]),g.useEffect(()=>{if(!(!o||!v||!j.dead||e.fmPlayRequest===0))return pX(f??h.catalogue,v.id,m.current,R=>M(R,!0))},[o,v==null?void 0:v.id,j.dead,e.fmPlayRequest,f,h.catalogue,M]),r.jsxs(r.Fragment,{children:[t&&r.jsx(_Z,{character:n,player:j,source:e.fmSource,customStation:w}),r.jsx(EZ,{player:j,label:b}),s&&kt.createPortal(r.jsx("div",{className:"modal-backdrop radio-backdrop",..._,children:r.jsx(g.Suspense,{fallback:r.jsx(MZ,{onClose:C}),children:r.jsx($Z,{fm:e,player:j,library:h,selected:v,label:b,enabled:o,disabledReason:l,autoNext:N==null?void 0:N.name,onPick:M,onQueueChange:p,onClose:C})})}),document.body)]})}function IZ({data:e}){const t=Nr(3e4),n=e.note,s=e.plan??null,a=(n==null?void 0:n.kind)==="recap",o=np((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":""}`,l=a||!n?void 0:nm(n),u=jr(s),h=n?rc(n.kind):`plan ${u?`${u.done}/${u.total}`:""}`.trim();return r.jsxs("div",{className:i,role:"note","aria-label":a?"Claude Code's recap":`Session note: ${h}`,"aria-description":l,style:{"--session-hue":e.hue},children:[r.jsxs("div",{className:"recap-note-head",title:l,children:[r.jsxs("span",{className:"recap-note-mark",children:[r.jsx(ep,{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(),mK(e.noteKey)},children:"×"})]}),n&&r.jsx("p",{className:"recap-note-text",title:CK(n.text,l),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(VT,{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(ep,{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(VT,{plan:s,head:n!=null,face:!0})]}),r.jsx(fi,{type:"source",position:Ye.Right,style:{background:"transparent",border:"none"}})]})}const OZ={completed:"done",in_progress:"now",pending:"to do"};function VT({plan:e,head:t,face:n=!1}){const s=jr(e);if(!s)return null;const a=pV(e.items);return r.jsxs("div",{className:n?"recap-face-plan":"recap-note-plan",title:n?void 0:Vp(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:[OZ[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 ro(){var t;return typeof navigator>"u"?"":((t=navigator.userAgentData)==null?void 0:t.platform)||navigator.platform||""}function po(e){return/mac|iphone|ipad/i.test(e)}const ip=e=>new Map([...e].map(([t,n])=>[t,{x:n.x,y:n.y}]));function PZ(e,t,n){return{positions:ip(e.positions),pinned:ip(e.pinned),provisional:new Set(e.provisional),layoutSig:e.layoutSig.current,stored:{...t},viewport:n?{...n}:null}}function DZ(e,t){t.positions.clear();for(const[n,s]of ip(e.positions))t.positions.set(n,s);t.pinned.clear();for(const[n,s]of ip(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 GT=7e3,FZ=2e3,BZ=140,qZ="Layout re-arranged",UZ="Layout re-arranged. Undo available.",KT="Layout restored.",WZ={set:(e,t)=>setTimeout(e,t),clear:e=>clearTimeout(e),now:()=>Date.now()};function HZ(e,t=WZ){let n=null,s=null,a=0,o=GT;const i=new Set,l=()=>{s!==null&&t.clear(s),s=null},u=()=>{l(),!(n===null||i.size>0)&&(a=t.now()+o,s=t.set(()=>{s=null,h()},o))};function h(){l(),i.clear(),n!==null&&(n=null,e(!1))}return{open(f){const p=n===null;n=f,o=GT,u(),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()),l()),i.add(f))},release(f){!i.delete(f)||i.size>0||n===null||(o=Math.max(o,FZ),u())},get isOpen(){return n!==null},get snapshot(){return n}}}function zZ(e){return(e.key==="z"||e.key==="Z")&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey}function VZ(e){return po(e)?"⌘Z":"Ctrl+Z"}function GZ({undo:e}){const{open:t,said:n,undo:s,dismiss:a,hold:o,release:i}=e,l=Nl(t,BZ),u=g.useRef(null);return g.useEffect(()=>t?cn.push(a,0,"popover"):void 0,[t,a]),g.useEffect(()=>{var f;if(t)return;const h=u.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}),Za(l)&&r.jsxs("div",{ref:u,className:l==="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:qZ}),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:VZ(ro())})]})]})]})}function KZ({sourceX:e,sourceY:t,targetX:n,targetY:s,sourcePosition:a,targetPosition:o,style:i}){const[l]=Vj({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:l,vectorEffect:"non-scaling-stroke"}),r.jsx("path",{className:"recap-tie-beads",d:l,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 R1(e){return e.replace(/[^a-zA-Z0-9]/g,"")}function lp(e,t){const n=R1(e);return n?n.slice(-t):e.slice(-t)}function gD(e,t,n=4){const s=R1(e);if(!s)return lp(e,n);let a=n;for(const o of t){if(o===e)continue;const i=R1(o);let l=0;for(;l<s.length&&l<i.length&&s[s.length-1-l]===i[i.length-1-l];)l++;a=Math.max(a,l+1)}return s.slice(-a)}const Sl=" · ",YZ=32,XZ=/[\u1100-\u115F\u2E80-\u303E\u3041-\u33FF\u3400-\u4DBF\u4E00-\u9FFF\uA000-\uA4CF\uAC00-\uD7A3\uF900-\uFAFF\uFE30-\uFE6F\uFF00-\uFF60\uFFE0-\uFFE6]/;function YT(e){return XZ.test(e)?2:1}function XT(e,t=YZ){const n=[...e];let s=0;for(const i of n)s+=YT(i);if(s<=t)return e;const a=[];let o=0;for(const i of n){const l=YT(i);if(o+l>t-1)break;a.push(i),o+=l}for(;a.length&&/[\s\-_.:/]/.test(a[a.length-1]);)a.pop();return`${a.join("")}…`}function ZZ(e,t,n,s,a=[],{branch:o,plan:i,alarm:l=!1}={}){const u=(t==null?void 0:t.trim())??"",h=s?gD(n,a):void 0,f=[e,u||void 0,h].filter(Boolean),p=[e,i?`plan ${i}`:void 0,o,u||void 0,h].filter(Boolean).join(Sl);return{label:XT(e),name:u?XT(u):void 0,shortId:h,fullLabel:f.join(Sl),title:`${l?"waiting on you: ":""}${p}
|
|
90
|
+
Zoom to this session
|
|
91
|
+
drag the wrapper to move the whole session`}}const ti=18,M1=26,CN=12,Zu=240,_N=130,$1=ti*2+M1+CN,JZ=72,Il=$1+JZ,Rf=24,yD=70,wD=ti*2+Rf,cp=Il;function xD(e,t){var s;let n=Zu;for(const a of e)n=Math.max(n,((s=t.get(a.id))==null?void 0:s.width)??Zu);return n}const Ol=420,Mf=300,up=130,vD=160,bD=1;function QZ(e,t,n,s){return Math.min(bD,n/Math.max(1,e),s/Math.max(1,t))}function En(e){const t=e.data;return(t==null?void 0:t.canvasSessionId)??(t==null?void 0:t.sessionId)??"_default"}function im(e,t=()=>!0){const n=new Map;for(const s of e){if(!t(s))continue;const a=En(s),o=n.get(a);o?o.push(s):n.set(a,[s])}return n}function eJ(e,t){return((t==null?void 0:t.get(e))??0)>0?Ol:0}function tJ(e,t){const n=(t==null?void 0:t.get(e))??0;return n>0?6+n*36:0}function Ju(e,t){const n=t.get(e);return{w:(n==null?void 0:n.width)??Zu,h:(n==null?void 0:n.height)??_N}}function wd(e,t,n){const s=Ju(e,t);return{w:s.w+eJ(e,n),h:Math.max(s.h,tJ(e,n))}}function nJ(e){return[...e.keys()].sort().map(t=>`${t}:${e.get(t)}`).join("|")}const sJ=240,kD=16;function jD(e,t){return(e+sJ)*(t||1)}function rJ(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 aJ(e,t,n,s){return{position:"absolute",left:e.x+kD,top:e.y-CN/(t||1),transform:`scale(${1/(t||1)})`,transformOrigin:"left top",maxWidth:s??jD(e.w,t),"--session-hue":n}}function oJ(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,l=a.position.y,u=i+a.width,h=l+a.height,f=t.get(En(a)),p=o.canvasSessionId&&o.canvasSessionId!==o.sessionId?null:iJ(o);f?(f.minX=Math.min(f.minX,i),f.minY=Math.min(f.minY,l),f.maxX=Math.max(f.maxX,u),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(En(a),{minX:i,minY:l,maxX:u,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)??[],l=i.length>1;s.push({sessionId:a,...ZZ(o.label,o.name,a,l,i,{branch:o.branch,plan:o.planLine,alarm:o.alarm}),x:o.minX-ti,y:o.minY-ti-M1,w:o.maxX-o.minX+ti*2,h:o.maxY-o.minY+ti*2+M1,...o.alarm?{alarm:!0}:null,...o.branch?{branch:o.branch}:null,...o.plan?{plan:o.plan,planLine:o.planLine}:null})}return s}function iJ(e){if(e.kind!=="root")return null;const t=e.branch,n=jr(e.plan);return{label:e.label,name:Qp(e.sessionName,e.sessionTitle).face,alarm:_n(e.waiting),branch:t&&t.total>0?PP(t):void 0,plan:n?`plan ${n.done}/${n.total}`:void 0,planLine:n?rN(n):void 0}}function lJ(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 cJ=20,Zr=4,uJ=64,dJ=".cat-filter-bar, .react-flow__panel, .autofit-chip, .rearrange-undo, .usage-panel, .sysdetail, .detail";function hJ(e,t,n,s){const a=t.zoom||1,o=jD(e.w,a);if(n.width<=0||n.height<=0)return{maxWidth:o,hidden:!1};const i=(e.x+kD)*a+t.x,l=e.y*a+t.y-CN,u=l+cJ;let h=Math.min(o,n.width-Zr-i),f=i<Zr||l<Zr||u>n.height-Zr;for(const p of s)if(!(p.top-Zr>=u||p.bottom+Zr<=l)&&!(p.right+Zr<=i)){if(p.left-Zr<=i){f=!0;break}h=Math.min(h,p.left-Zr-i)}return h<uJ&&(f=!0),{maxWidth:Math.max(0,h),hidden:f}}function fJ(e){const t=e.getBoundingClientRect(),n=[];for(const s of e.ownerDocument.querySelectorAll(dJ)){const a=s.getBoundingClientRect(),o=Math.max(a.left,t.left)-t.left,i=Math.max(a.top,t.top)-t.top,l=Math.min(a.right,t.right)-t.left,u=Math.min(a.bottom,t.bottom)-t.top;l-o<1||u-i<1||n.push({left:Math.round(o),top:Math.round(i),right:Math.round(l),bottom:Math.round(u)})}return n}function pJ(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 mJ=500;function ND({focus:e,setTimeout:t,clearTimeout:n,ms:s=mJ}){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 gJ(e){return oJ(e.nodeInternals.values())}const yJ=e=>e.width,wJ=e=>e.height,xJ=e=>{var t;return((t=e.domNode)==null?void 0:t.querySelector(".react-flow__viewport"))??null};function vJ({onFocusSession:e}){const{x:t,y:n,zoom:s}=R4(),a=ht(gJ,lJ),o=ht(yJ),i=ht(wJ),l={width:o,height:i},u=g.useRef(null),h=ht(xJ),[f,p]=g.useState([]);g.useLayoutEffect(()=>{var M;const S=(M=u.current)==null?void 0:M.parentElement;if(!S)return;const C=fJ(S),_=requestAnimationFrame(()=>{p(R=>pJ(R,C)?R:C)});return()=>cancelAnimationFrame(_)});const m=g.useRef(e);m.current=e;const[w]=g.useState(()=>ND({focus:S=>{var C;return(C=m.current)==null?void 0:C.call(m,S)},setTimeout:(S,C)=>window.setTimeout(S,C),clearTimeout:S=>window.clearTimeout(S)}));if(g.useEffect(()=>()=>w.cancel(),[w]),a.length<=1)return null;const v=S=>{try{e==null||e(S)}catch{}},j=(S,C)=>{S.detail>0&&pd()?w.hold(C):v(C)},b={transform:`translate(${t}px, ${n}px) scale(${s})`},N=r.jsx("div",{className:"session-clusters",style:b,ref:u,children:a.map(S=>{const C=Gu(S.sessionId),_=rJ(S,C);return r.jsx("div",{className:"cluster-card",style:_,"aria-hidden":!0},S.sessionId)})}),x=h&&kt.createPortal(r.jsx("div",{className:"cluster-labels nopan",children:a.map(S=>{const C=Gu(S.sessionId),_=hJ(S,{x:t,y:n,zoom:s},l,f),M=aJ(S,s,C,_.maxWidth);return r.jsxs("button",{type:"button",className:"cluster-label","data-alarm":S.alarm?"":void 0,"data-offpane":_.hidden?"":void 0,style:M,title:S.title,onClick:R=>j(R,S.sessionId),children:[S.alarm?r.jsxs(r.Fragment,{children:[r.jsx(gN,{}),r.jsx("span",{className:"cluster-label-said",children:"waiting on you: "})]}):null,S.label,S.plan?r.jsx("span",{className:"cluster-label-plan",children:Sl+S.plan}):null,S.branch?r.jsx("span",{className:"cluster-label-branch",children:Sl+S.branch}):null,S.name?r.jsx("span",{className:"cluster-label-name",children:Sl+S.name}):null,S.shortId?r.jsx("span",{className:"cluster-label-id",children:Sl+S.shortId}):null]},S.sessionId)})}),h);return r.jsxs(r.Fragment,{children:[N,x]})}function bJ({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 SD=600,kJ=4,jJ=36,dp=14,NJ=60,SJ=6,ZT=220,CJ=96,_J=28;function EJ(e,t){return Math.max(CJ,61+[...t].length*6.8)}function TJ(e){return e.endedAt==null?"inflight":e.ok===!1?"err":"done"}function AJ(e,t){if(t==null)return 1;const n=e-t;return n<0?1:Math.max(0,1-n/SD)}function RJ(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 MJ(e,t,n,s,a,o){const i=[];for(const l of e.values()){if(!t.has(l.id)||l.exitAt!=null&&o-l.exitAt>SD)continue;const u=s.get(l.id)??n.get(l.id);if(!u)continue;const h=RJ(l.tools,kJ);if(h.length===0)continue;const f=l.exitAt??null,p=a.get(l.id),m=Math.max((p==null?void 0:p.width)??ZT,ZT),w=(p==null?void 0:p.height)??130,v=u.x,j=u.y,b=v+m,N=j+w/2;h.forEach((x,S)=>{const C=S*jJ,_=v+m+NJ,M=j+SJ+C,R=AJ(o,f),P=x.inputPreview??"",L=TJ(x),U=R<.999,B=mN(x.name);i.push({id:`${l.id}::${x.id}`,toolId:x.id,agentId:l.id,toolName:x.name,name:B.label,emoji:B.emoji,status:L,category:DP(x.name),mcpHue:B.hue,inputPreview:P,fade:R,fading:U,worldX:_,worldY:M,anchorX:b,anchorY:N,spawnDx:b-_,spawnDy:N-(M+dp)});const A=UP(x.name,x.input);if(A){const q=EJ(x.name,B.label),T=_+q+_J,F=M,O=_+q,K=M+dp;i.push({id:`sub:${l.id}::${x.id}`,toolId:x.id,agentId:l.id,toolName:x.name,name:eY(A.label,A.category),fullName:A.label,emoji:A.emoji,isSub:!0,status:L,category:A.category,inputPreview:A.detail??P,fade:R,fading:U,worldX:T,worldY:F,anchorX:O,anchorY:K,spawnDx:O-T,spawnDy:0})}})}return i}function $J({agents:e,visibleAgentIds:t,positions:n,pinned:s,measured:a,spotlight:o,hiddenCategories:i,now:l,onOpenTool:u}){const h=MJ(e,t,n,s,a,l),f=i&&i.size>0?h.filter(p=>!i.has(p.category)):h;return r.jsx(LJ,{bursts:f,spotlight:o,onOpenTool:u})}function LJ({bursts:e,spotlight:t,onOpenTool:n}){const s=e.map(o=>{const i=o.anchorX,l=o.anchorY,u=o.worldX+6,h=o.worldY+dp,f=Math.max(1,u-i),p=Math.min(1,Math.abs(h-l)/f),m=i+f*(.55-.22*p),w=l+(h-l)*.12,v=u-f*.25,j=t!=null&&!t.has(o.agentId),b=o.fade*(j?.14:1);return r.jsx("path",{d:`M ${i} ${l} C ${m} ${w}, ${v} ${h}, ${u} ${h}`,className:`tool-conn status-${o.status}${o.fading?" fading":""}`,opacity:b,vectorEffect:"non-scaling-stroke"},`l:${o.id}`)}),a=e.map(o=>r.jsx(PJ,{b:o,dim:t!=null&&!t.has(o.agentId),onOpenTool:n},o.id));return r.jsx(IJ,{connectors:s,bubbles:a})}function IJ({connectors:e,bubbles:t}){const{x:n,y:s,zoom:a}=R4();return r.jsxs("div",{className:"tool-bursts-layer","aria-hidden":!0,style:{"--tool-burst-height":`${2*dp}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 OJ(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 PJ=g.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,l=s!=null,u=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":""}${l?" clickable":""}${t.isSub?" sub":""}${h}`,style:u,title:i,onClick:l?()=>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:"×"})]})})},OJ),DJ={width:140,height:105},FJ={agent:NY,sessionGroup:bJ,recapNote:IZ},BJ={recapTie:KZ},JT=400;function qJ({graph:e,layout:t,viewport:n,clicks:s,drag:a,appearance:o,fm:i,radioOpen:l,onRadioClose:u,autoFit:h,pause:f,stateRef:p,measuredRef:m,hiddenCats:w,now:v,openTool:j,focusAgent:b,requestClear:N,setKeyHelpOpen:x}){const{allNodes:S,edges:C,visibleAgentIds:_,spotlightSet:M}=e,{positionsRef:R,pinnedRef:P,handleRelayout:L,rearrangeUndo:U}=t,{restoredViewport:B,onMoveStart:A,onMove:q}=n,{onNodeClick:T,onPaneClick:F,onNodeDoubleClick:O,onNodeMouseEnter:K,onNodeMouseLeave:V}=s,{onNodeDragStart:H,onNodeDrag:D,onNodeDragStop:I}=a,{palette:W,minimapNodeFill:Z,characterEnabled:z}=o,{autoFitDisabled:X,enableAutoFitAndRefit:Y}=h,{paused:J,pauseGate:Q,togglePause:te}=f;return r.jsxs(A4,{nodes:S,edges:C,nodeTypes:FJ,edgesFocusable:!1,edgeTypes:BJ,fitView:!B,fitViewOptions:{padding:.25,duration:m1({durationMs:JT,documentHidden:document.hidden})?JT:0},minZoom:O4,maxZoom:P4,panOnScroll:!0,panActivationKeyCode:null,nodesDraggable:!0,nodesConnectable:!1,selectionOnDrag:!1,nodeDragThreshold:5,disableKeyboardA11y:!0,deleteKeyCode:null,onNodeClick:T,onPaneClick:F,onNodeDoubleClick:O,onNodeMouseEnter:K,onNodeMouseLeave:V,onMoveStart:A,onMove:q,onNodeDragStart:(le,de,oe)=>{U.dismiss(),H(le,de,oe)},onNodeDrag:D,onNodeDragStop:I,children:[r.jsx(T9,{gap:28,size:1,color:W["--grid-line"]}),r.jsx(vJ,{onFocusSession:b}),r.jsx($J,{agents:p.current.agents,visibleAgentIds:_,positions:R.current,pinned:P.current,measured:m.current,spotlight:M,hiddenCategories:w,now:v,onOpenTool:j}),r.jsxs("div",{className:"canvas-notices",children:[X&&r.jsx(MY,{enableAutoFitAndRefit:Y}),r.jsx(GZ,{undo:U})]}),r.jsx(HY,{autoFitDisabled:X,enableAutoFitAndRefit:Y,paused:J,pauseGate:Q,togglePause:te,handleRelayout:L,requestClear:N,setKeyHelpOpen:x}),r.jsx(g9,{style:DJ,zoomable:!0,pannable:!0,nodeColor:Z,nodeStrokeWidth:2,maskColor:W["--minimap-mask"],maskStrokeColor:W["--line"]}),r.jsx(LZ,{fm:i,character:o.character,characterEnabled:z,open:l,onClose:u})]})}function UJ(){const e=window.ccdeckWindow;return g.useEffect(()=>{if(!e)return;const t=()=>{const s=document.querySelector(".topbar");if(!s)return;const a=getComputedStyle(s),o=i=>{var u;const l=(u=i.match(/\d+/g))==null?void 0:u.slice(0,3);return(l==null?void 0:l.length)===3?`#${l.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 WJ(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 l=qn(i);t.input+=l.input,t.output+=l.output,t.cacheRead+=l.cacheRead,t.cacheWrite+=l.cacheWrite,t.total+=l.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 HJ="spend on this board",zJ="on this board",CD=`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
|
+
`,VJ=CD+"Press H for the totals ccusage reads off the logs on disk, which do not forget.";function QT(e){return e?VJ:CD+"Usage history has the totals ccusage reads off the logs on disk, which do not forget."}const _D="session spend",L1="__unknown__",GJ=12;function KJ(e,t=Date.now()){const n=new Map;for(const s of e)for(const a of sc(s)){const o=a.model??L1,i=Kp(a.usage,a.model,t),l=w1({model:a.model,usage:a.usage},t),u=n.get(o);u?(u.inputTokens+=a.usage.inputTokens,u.outputTokens+=a.usage.outputTokens,u.cacheReadTokens+=a.usage.cacheReadTokens,u.cacheCreateTokens+=a.usage.cacheCreateTokens,u.cost.total+=i.total,u.cost.input+=i.input,u.cost.output+=i.output,u.cost.cacheRead+=i.cacheRead,u.cost.cacheWrite+=i.cacheWrite,u.agentCount++,u.priced=u.priced&&l):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:l})}return Array.from(n.values()).sort((s,a)=>a.cost.total-s.cost.total||a.inputTokens+a.outputTokens-(s.inputTokens+s.outputTokens))}function YJ(e,t=Date.now()){const n=[...e],s=[];for(const a of n){if(a.kind!=="root")continue;let o=qn(a,t).total,i=a.usage.inputTokens,l=a.usage.outputTokens,u=zl(a,t),h=w1(a,t);for(const f of n)f.sessionId!==a.sessionId||f.kind==="root"||(o+=qn(f,t).total,i+=f.usage.inputTokens,l+=f.usage.outputTokens,u+=zl(f,t),h=h&&w1(f,t));s.push({priced:h,sessionId:a.sessionId,label:a.label||a.cwdBasename||"session",state:a.state,cost:o,inputTokens:i,outputTokens:l,unpricedTokens:u})}return s.sort((a,o)=>o.cost-a.cost||o.inputTokens+o.outputTokens-(a.inputTokens+a.outputTokens)).slice(0,GJ)}const XJ=600;function lm(e,t){return!(e.exitAt!=null&&t-e.exitAt>XJ||e.kind==="root"&&e.state==="done"&&e.tools.length===0&&e.endedAt!=null&&e.endedAt-e.startedAt<3e3&&!e.stopFailure)}function ZJ(e,t){const n=new Set;for(const s of e.agents.values())lm(s,t)&&n.add(s.id);return n}function JJ(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 QJ(e,t,n=0){if(!e)return!1;for(const s of t)if(JJ(e,s,n))return!0;return!1}function eA(e){return e.waiting?_n(e.waiting)?0:1:e.state==="active"?2:3}function ED(e,t){var s;const n=[];for(const a of e.agents.values()){if(a.kind!=="root")continue;let o=a.toolCount,i=qn(a).total,l=a.endedAt??a.startedAt;for(const p of e.agents.values()){if(p.sessionId!==a.sessionId||p.kind==="root")continue;o+=p.toolCount,i+=qn(p).total;const m=p.endedAt??p.startedAt;m>l&&(l=m)}const u=fN(a),h=(u==null?void 0:u.kind)==="recap"?{text:u.text,at:u.at}:null,f=u&&u.kind!=="recap"?u:null;n.push({sessionId:a.sessionId,label:a.label||a.cwdBasename||"session",cwdBasename:a.cwdBasename,state:$l(a),waiting:a.waiting,recap:h,status:f,modelId:a.model,effort:a.effort,plan:jr(a.plan),planTitle:Vp(((s=a.plan)==null?void 0:s.items)??[]),toolCount:o,cost:i,startedAt:a.startedAt,lastActivity:l})}return n.sort((a,o)=>{const i=eA(a),l=eA(o);return i!==l?i-l:a.waiting&&o.waiting?a.waiting.since-o.waiting.since:o.lastActivity-a.lastActivity}),n}function eQ(e){return[e.text,e.reply?`Suggested reply: ${e.reply}`:"",nm(e)].filter(Boolean).join(`
|
|
94
|
+
`)}function Qu(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 tQ({state:e,now:t,selectedIds:n,onSelect:s,onClose:a,removedIds:o,onBringBackAll:i,leaving:l=!1}){const u=Tn(),h=g.useMemo(()=>ED(e),[e,e.revision,t]),f=h.filter(m=>m.state==="active").length,p=h.filter(m=>_n(m.waiting)).length;return r.jsxs("aside",{className:`session-list${l?" 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:Cn("Hide sidebar","L",u),"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 j;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:Vl(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":Yp(m.modelId),title:Yu(m.modelId,m.effort),children:Xp(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:_D,children:r.jsx("b",{children:ct(m.cost)})}),m.waiting?r.jsxs("span",{className:"sl-waiting",title:[Gl(m.waiting),NP(m.waiting,Gl(m.waiting)),`${_n(m.waiting)?"Blocked":"Your turn"} since ${new Date(m.waiting.since).toLocaleTimeString()} · started ${new Date(m.startedAt).toLocaleString()}`].filter(Boolean).join(`
|
|
95
|
+
`),children:[_n(m.waiting)?"waiting":"your turn"," ",Qu(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:Qu(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:tP(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(HP,{}),m.recap.text]}),m.status&&r.jsxs("span",{className:`sl-status status-${m.status.kind}`,title:eQ(m.status),children:[r.jsx("span",{className:"sl-status-tag",children:rc(m.status.kind)})," ",m.status.text]}),((j=m.status)==null?void 0:j.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&&lm(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 j;return(j=v==null?void 0:v.querySelector(".sl-row"))==null?void 0:j.focus()})},children:["Bring back ",m," removed ",m===1?"card":"cards"]})})})()]})}const nQ={recent:"Recent",sessions:"Sessions",open:"Panels and dialogs",settings:"Settings",actions:"Actions",themes:"Themes"},Qy=["recent","sessions","open","settings","actions","themes"],TD=/[\s\-_./·:,()›]/;function tf(e,t){return t===0||TD.test(e[t-1])}function tA(e,t,n){let s=n;for(const a of e){if(s=t.indexOf(a,s),s<0)return!1;s++}return!0}function sQ(e,t){const n=e.trim().toLowerCase();if(!n)return{score:0,hits:[]};const s=t.toLowerCase(),a=s.indexOf(n);if(a>=0)return{score:1e3-a+(tf(s,a)?200:0)+(a===0?300:0)+(n.length===s.length?500:0),hits:Array.from({length:n.length},(f,p)=>a+p)};const o=n.replace(/\s+/g,"");if(!tA(o,s,0))return null;const i=[];let l=0,u=100;for(let h=0;h<o.length;h++){const f=o[h],p=o.slice(h+1);let m=s.indexOf(f,l);for(let v=m;v>=0&&tA(p,s,v+1);v=s.indexOf(f,v+1))if(tf(s,v)){m=v;break}if(h===0&&!tf(s,m))return null;const w=i[i.length-1];u+=tf(s,m)?12:2,w!==void 0&&m===w+1&&(u+=6),u-=Math.min(m-l,10),i.push(m),l=m+1}return{score:u,hits:i}}function rQ(e,t){const n=e.trim().toLowerCase();if(!n||!t)return 0;let s=0;for(const a of t){const o=a.toLowerCase();o===n?s=Math.max(s,600):o.startsWith(n)?s=Math.max(s,500):o.split(TD).some(i=>i.startsWith(n))&&(s=Math.max(s,400))}return s}const aQ=8,oQ=5,EN=5;function iQ(e,t,n=[]){const s=t.trim();if(!s){const o=new Map(e.map(h=>[h.id,h])),i=n.map(h=>o.get(h)).filter(h=>!!h).slice(0,EN),l=new Set(i.map(h=>h.id)),u=[];i.length&&u.push(ew("recent",i.map(h=>({item:h,hits:[]}))));for(const h of Qy){if(h==="recent")continue;let f=e.filter(p=>p.section===h&&!p.queryOnly&&!l.has(p.id));h==="sessions"&&(f=f.slice(0,oQ)),f.length&&u.push(ew(h,f.map(p=>({item:p,hits:[]}))))}return u}const a=new Map;for(const o of e){const i=sQ(s,o.title),l=rQ(s,o.keywords),u=Math.max((i==null?void 0:i.score)??0,l);if(u<=0)continue;const h=i&&i.score>=l?i.hits:[],f=a.get(o.section)??[];f.push({item:o,hits:h,score:u}),a.set(o.section,f)}return[...a.entries()].map(([o,i])=>(i.sort((l,u)=>u.score-l.score),{key:o,list:i.slice(0,aQ),best:i[0].score})).sort((o,i)=>i.best-o.best||Qy.indexOf(o.key)-Qy.indexOf(i.key)).map(({key:o,list:i})=>ew(o,i.map(({item:l,hits:u})=>({item:l,hits:u}))))}function ew(e,t){return{section:e,title:nQ[e],items:t}}function lQ(e){return e.flatMap(t=>t.items)}function nA(e,t,n){return t<=0?-1:e<0?n>0?0:t-1:((e+n)%t+t)%t}const AD="agent-dag.quickOpenRecent";function RD(){try{const e=JSON.parse(nt(AD)??"[]");return Array.isArray(e)?e.filter(t=>typeof t=="string").slice(0,EN):[]}catch{return[]}}function cQ(e,t){return[t,...e.filter(n=>n!==t)].slice(0,EN)}function uQ(e){st(AD,JSON.stringify(cQ(RD(),e)))}function MD(e,t){const n=e.key==="k"||e.key==="K"||e.code==="KeyK",s=t?e.metaKey&&!e.ctrlKey:e.ctrlKey&&!e.metaKey;return n&&s&&!e.altKey&&!e.shiftKey}function dQ(e){return e?"⌘K":"Ctrl+K"}function jt({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 hQ=()=>r.jsxs(jt,{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"})]}),fQ=()=>r.jsx(jt,{children:r.jsx("g",{transform:"rotate(45 7 7)",children:r.jsx("path",{d:"M7 1v1.5M4.5 2.5h5v1.3a2.5 2.5 0 0 1-5 0zM5.5 7v1.5M8.5 7v1.5M4.5 8.5h5v1.3a2.5 2.5 0 0 1-5 0zM7 12.3V14"})})}),pQ=()=>r.jsxs(jt,{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"})]}),mQ=()=>r.jsxs(jt,{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"})]}),gQ=()=>r.jsxs(jt,{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"})]}),yQ=()=>r.jsxs(jt,{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"})]}),wQ=()=>r.jsxs(jt,{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"})]}),xQ=({watching:e})=>r.jsxs(jt,{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"})]}),vQ=()=>r.jsxs(jt,{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"})]}),bQ=()=>r.jsxs(jt,{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"})]}),$D=()=>r.jsx(jt,{children:r.jsx("path",{d:"M4.6 2.9v8.2L11.1 7Z"})}),kQ=()=>r.jsxs(jt,{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"})]}),jQ=()=>r.jsxs(jt,{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"})]}),NQ=()=>r.jsx(jt,{children:r.jsx("path",{d:"M2 5h10v7H2z M4 5l6-3 M4 8h3 M9 8h1 M4 10h1 M8 10h2"})}),SQ=()=>r.jsxs(jt,{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"})]}),CQ=()=>r.jsxs(jt,{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"})]}),_Q=()=>r.jsxs(jt,{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"})]}),EQ=()=>r.jsxs(jt,{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"})]}),TQ=()=>r.jsxs(jt,{children:[r.jsx("circle",{cx:"7",cy:"7",r:"5"}),r.jsx("path",{d:"M7 3.8V7l2.2 1.4"})]}),AQ=()=>r.jsx(jt,{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"})}),RQ=()=>r.jsx(jt,{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"})}),MQ=()=>r.jsx(jt,{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"})}),LD=()=>r.jsxs(jt,{children:[r.jsx("circle",{cx:"6.1",cy:"6.1",r:"3.9"}),r.jsx("path",{d:"M9 9l3.2 3.2"})]}),$Q=()=>r.jsxs(jt,{children:[r.jsx("path",{d:"M2 5V2.6c0-.3.3-.6.6-.6H5M9 2h2.4c.3 0 .6.3.6.6V5M12 9v2.4c0 .3-.3.6-.6.6H9M5 12H2.6c-.3 0-.6-.3-.6-.6V9"}),r.jsx("circle",{cx:"7",cy:"7",r:"1.6"})]}),LQ=()=>r.jsxs(jt,{children:[r.jsx("rect",{x:"1.8",y:"5.3",width:"3.6",height:"3.4",rx:".7"}),r.jsx("rect",{x:"8.6",y:"1.8",width:"3.6",height:"3.4",rx:".7"}),r.jsx("rect",{x:"8.6",y:"8.8",width:"3.6",height:"3.4",rx:".7"}),r.jsx("path",{d:"M5.4 7h1.6M7 3.5v7M7 3.5h1.6M7 10.5h1.6"})]}),IQ=()=>r.jsx(jt,{children:r.jsx("path",{d:"M5 3v8M9 3v8"})}),OQ=()=>r.jsx(jt,{children:r.jsx("path",{d:"M2.4 3.8h9.2M5.6 3.8V2.6h2.8v1.2M3.6 3.8l.6 7.6c0 .4.4.6.7.6h4.2c.4 0 .7-.3.7-.6l.6-7.6"})}),PQ=120,sA=5;function DQ({text:e,hits:t}){if(!t.length)return r.jsx(r.Fragment,{children:e});const n=new Set(t),s=[];for(let a=0;a<e.length;a++){const o=n.has(a),i=s[s.length-1];i&&i.hit===o?i.text+=e[a]:s.push({text:e[a],hit:o})}return r.jsx(r.Fragment,{children:s.map((a,o)=>a.hit?r.jsx("mark",{className:"qo-hit",children:a.text},o):r.jsx("span",{children:a.text},o))})}function FQ({items:e,onClose:t,onRun:n}){const[s,a]=g.useState(""),[o]=g.useState(RD),[i,l]=g.useState(null),[u,h]=g.useState(!1),f=g.useRef(null),p=g.useRef(null),m=g.useRef(!1),w=g.useRef(null),v=g.useCallback(()=>h(!0),[]),j=g.useCallback(()=>{m.current||(m.current=!0,t())},[t]),b=gt(v,{focusRef:f}),N=yt(v),x=g.useMemo(()=>iQ(e,s,o),[e,s,o]),S=g.useMemo(()=>lQ(x),[x]),C=S.findIndex(A=>A.item.id===i),_=S.length?C>=0?C:0:-1,M=S[_];g.useEffect(()=>{if(!u)return;const A=setTimeout(j,PQ+60);return()=>clearTimeout(A)},[u,j]),g.useEffect(()=>{const A=po(ro()),q=T=>{MD(T,A)&&(T.preventDefault(),T.stopPropagation(),v())};return window.addEventListener("keydown",q,!0),()=>window.removeEventListener("keydown",q,!0)},[v]),g.useLayoutEffect(()=>{var T;const A=p.current;if(!A)return;if(_<=0){A.scrollTop=0;return}const q=A.querySelector(`[data-index="${_}"]`);q&&(q.dataset.first==="true"&&((T=q.closest(".qo-group"))==null||T.scrollIntoView({block:"nearest"})),q.scrollIntoView({block:"nearest"}))},[_,S]);const R=A=>{!A||u||(uQ(A.item.id),n(A.item))},P=A=>{const q=S[A];q&&l(q.item.id)},L=A=>{if(A.nativeEvent.isComposing)return;const q=A.ctrlKey&&!A.metaKey&&!A.altKey;let T=null;if(A.key==="ArrowDown"||q&&(A.key==="n"||A.key==="j"))T=nA(_,S.length,1);else if(A.key==="ArrowUp"||q&&(A.key==="p"||A.key==="k"))T=nA(_,S.length,-1);else if(A.key==="PageDown")T=Math.min(S.length-1,_+sA);else if(A.key==="PageUp")T=Math.max(0,_-sA);else if(A.key==="Enter"){A.preventDefault(),R(M);return}T!==null&&(A.preventDefault(),P(T))},U=(A,q)=>{const T={x:A.clientX,y:A.clientY},F=w.current;w.current=T,!(F&&F.x===T.x&&F.y===T.y)&&q!==(M==null?void 0:M.item.id)&&l(q)};let B=-1;return r.jsx("div",{className:`modal-backdrop qo-backdrop${u?" closing":""}`,...N,role:"presentation",children:r.jsxs("div",{ref:b,className:`qo${u?" closing":""}`,onClick:A=>A.stopPropagation(),onAnimationEnd:A=>{u&&A.target===A.currentTarget&&j()},role:"dialog","aria-modal":"true","aria-label":"Quick open",children:[r.jsxs("div",{className:"qo-field",children:[r.jsx(LD,{}),r.jsx("input",{ref:f,className:"qo-input",type:"text",role:"combobox","aria-expanded":"true","aria-controls":"qo-list","aria-autocomplete":"list","aria-activedescendant":_>=0?`qo-opt-${_}`:void 0,placeholder:"Search panels, sessions, settings…",value:s,onChange:A=>{a(A.target.value),l(null)},onKeyDown:L,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1}),r.jsx("button",{type:"button",className:"qo-esc",onClick:v,"aria-label":"Close",children:"esc"})]}),r.jsxs("div",{ref:p,className:"qo-list",id:"qo-list",role:"listbox","aria-label":"Results",tabIndex:-1,onMouseDown:A=>A.preventDefault(),children:[x.map(A=>r.jsxs("div",{className:"qo-group",role:"group","aria-labelledby":`qo-cap-${A.section}`,children:[r.jsx("div",{className:"qo-caption",id:`qo-cap-${A.section}`,role:"presentation",children:A.title}),A.items.map((q,T)=>{B++;const F=B,{item:O}=q;return r.jsxs("div",{id:`qo-opt-${F}`,className:"qo-row",role:"option","aria-selected":F===_,"data-index":F,"data-first":T===0?"true":void 0,onMouseMove:K=>U(K,O.id),onClick:()=>R(q),children:[r.jsx("span",{className:"qo-icon","aria-hidden":!0,children:O.tone?r.jsx("span",{className:`qo-dot ${O.tone}`}):O.glyph}),r.jsxs("span",{className:"qo-text",children:[r.jsx("span",{className:"qo-title",children:r.jsx(DQ,{text:O.title,hits:q.hits})}),O.subtitle&&r.jsx("span",{className:"qo-sub",children:O.subtitle})]}),O.keyCap&&r.jsx("kbd",{className:"qo-key",children:O.keyCap}),r.jsx("span",{className:"qo-tag",children:O.tag})]},O.id)})]},A.section)),S.length===0&&r.jsxs("div",{className:"qo-empty",children:[r.jsxs("p",{className:"qo-empty-title",children:["Nothing matches “",s.trim(),"”"]}),r.jsx("p",{className:"qo-empty-note",children:"Try the name of a panel, a session, a setting or a theme."})]})]}),r.jsxs("div",{className:"qo-foot","aria-hidden":!0,children:[r.jsx("span",{className:"qo-foot-count",children:S.length===1?"1 result":`${S.length} results`}),r.jsxs("span",{className:"qo-foot-keys",children:[M&&r.jsxs("span",{className:"qo-foot-act",children:[M.item.verb," ",r.jsx("kbd",{children:"↵"})]}),r.jsxs("span",{className:"qo-foot-act",children:["Move ",r.jsx("kbd",{children:"↑"}),r.jsx("kbd",{children:"↓"})]})]})]}),r.jsx("span",{className:"qo-live",role:"status",children:s.trim()?S.length===1?"1 result":`${S.length} results`:""})]})})}function BQ(e,t,n){if(n<=0||em(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 Qa=4,ms=8;function TN(e,t,n){const s=n.width-ms-(e.right+Qa),a=e.left-Qa-ms,o=t.width<=s||s>=a?"right":"left",i=o==="right"?e.right+Qa:e.left-Qa-t.width,l=n.height-ms*2,u=t.height<=l,h=u?t.height:Math.max(0,l),f=Math.max(ms,Math.min(e.top,n.height-ms-h)),p=Math.max(ms,Math.min(i,n.width-ms-t.width));return{top:f,left:p,side:o,maxHeight:u?null:h}}function qQ(e,t,n){const s=n.height-ms-(e.bottom+Qa),a=e.top-Qa-ms,o=t.height<=s||s>=a?"below":"above",i=o==="below"?s:a,l=t.height<=i,u=l?t.height:Math.max(0,i),h=o==="below"?e.bottom+Qa:e.top-Qa-u,f=Math.max(ms,Math.min(e.right-t.width,n.width-ms-t.width));return{top:Math.max(ms,h),left:f,side:o,maxHeight:l?null:u}}function UQ(e,t,n){return!(!e||t!=null&&t.contains(e)||n!=null&&n.contains(e))}function WQ(e,t,n){const s=g.useRef(t);s.current=t;const a=g.useRef(n);a.current=n,g.useEffect(()=>{const o=i=>{UQ(i.target,e.current,s.current())&&a.current()};return window.addEventListener("pointerdown",o,!0),()=>window.removeEventListener("pointerdown",o,!0)},[e])}const ID='[role="menuitem"]';function rA(e){return e?Array.from(e.querySelectorAll(ID)).filter(t=>!t.disabled):[]}function cm({anchorId:e,boundaryId:t,portalRootId:n,id:s,className:a,role:o,labelledBy:i,start:l="first",focusRef:u,fallbackFocus:h,onClose:f,children:p}){const m=g.useRef(f);m.current=f;const w=g.useRef(h);w.current=h;const v=gt(()=>{var S;(S=document.getElementById(e))==null||S.focus(),m.current()},{popover:!0,focusRef:u}),j=g.useCallback(()=>{var P,L,U;const S=v.current;if(!S)return;const C=document.getElementById(e);if(!C){m.current();return}if(C.getClientRects().length===0){S.contains(document.activeElement)&&((L=(P=w.current)==null?void 0:P.call(w))==null||L.focus()),m.current();return}const _=C.getBoundingClientRect(),M=t?(U=document.getElementById(t))==null?void 0:U.getBoundingClientRect():null;if(M&&(_.bottom<=M.top||_.top>=M.bottom)){S.contains(document.activeElement)&&C.focus({preventScroll:!0}),m.current();return}S.style.maxHeight="";const R=qQ(_,{width:S.offsetWidth,height:S.offsetHeight},{width:window.innerWidth,height:window.innerHeight});S.style.top=`${R.top}px`,S.style.left=`${R.left}px`,S.style.maxHeight=R.maxHeight==null?"":`${R.maxHeight}px`,S.dataset.side=R.side},[e,t,v]);g.useLayoutEffect(()=>{j()}),g.useEffect(()=>{const S=C=>{var _;(_=v.current)!=null&&_.contains(C.target)||j()};return window.addEventListener("scroll",S,!0),window.addEventListener("resize",j),()=>{window.removeEventListener("scroll",S,!0),window.removeEventListener("resize",j)}},[j,v]),WQ(v,()=>document.getElementById(e),f),g.useEffect(()=>{var C;if(o!=="menu")return;const S=rA(v.current);(C=l==="last"?S[S.length-1]:S[0])==null||C.focus()},[]);const b=S=>{var C;if(o==="menu"&&S.key==="Tab"){S.stopPropagation(),(C=document.getElementById(e))==null||C.focus(),S.shiftKey&&S.preventDefault(),m.current();return}if(o==="menu"){const _=rA(v.current),M=BQ(S,_.indexOf(document.activeElement),_.length);M.kind==="focus"&&(S.preventDefault(),_[M.index].focus())}S.key.length===1&&S.stopPropagation()},N=S=>{S.target.closest("button, input, select, textarea, code")||S.preventDefault()},x=S=>{if(o!=="menu"||S.pointerType==="touch")return;const C=S.target.closest(ID);C&&!C.disabled&&document.activeElement!==C&&C.focus({preventScroll:!0})};return kt.createPortal(r.jsx("div",{ref:v,id:s,className:`anchored-popover${a?` ${a}`:""}`,role:o,"aria-labelledby":i,onKeyDown:b,onMouseDown:N,onPointerMove:x,children:p}),(n?document.getElementById(n):null)??document.body)}const HQ=450,zQ=400,VQ=100,nf=8,GQ={right:"hint hint-right",left:"hint hint-left",below:"hint hint-below",above:"hint hint-above"},iu=8;let Jr=null,aA=-1/0;function KQ(e,t,n){return n||e-t<zQ}function YQ(e,t,n,s,a=null){const o=Math.max(iu,((a==null?void 0:a.left)??0)+iu),i=Math.min(window.innerWidth,(a==null?void 0:a.right)??1/0)-n-iu,l=p=>Math.max(o,Math.min(p,i)),u=p=>Math.max(iu,Math.min(p,window.innerHeight-s-iu)),h=t.top+t.height/2-s/2,f=t.left+t.width/2-n/2;return e==="right"?{left:t.right+nf,top:u(h)}:e==="left"?{left:t.left-nf-n,top:u(h)}:e==="above"?{left:l(f),top:t.top-nf-s}:{left:l(f),top:t.bottom+nf}}const XQ={chrome:"",dialog:" hint-over-dialog"};function ac(e,t="chrome"){const[n,s]=g.useState(null),a=g.useRef(void 0),o=g.useRef(void 0),i=g.useRef(null),l=g.useCallback(()=>{window.clearTimeout(a.current),window.clearTimeout(o.current),s(w=>(w&&(aA=performance.now()),null))},[]),u=g.useCallback((w,v,j)=>{window.clearTimeout(a.current),window.clearTimeout(o.current);const b=Jr!==null,N=KQ(performance.now(),aA,b),x=()=>{var C;Jr&&Jr!==l&&Jr(),Jr=l;const S=t==="dialog"?((C=w.closest('[role="dialog"]'))==null?void 0:C.getBoundingClientRect())??null:null;s({spec:v,box:w.getBoundingClientRect(),within:S,instant:N})};j||N?x():a.current=window.setTimeout(x,HQ)},[l,t]),h=g.useCallback(()=>{window.clearTimeout(a.current),window.clearTimeout(o.current),o.current=window.setTimeout(l,VQ)},[l]),f=n!==null;g.useEffect(()=>{if(!f)return;const w=cn.push(l,0,"popover");return window.addEventListener("resize",l),window.addEventListener("scroll",l,!0),()=>{w(),window.removeEventListener("resize",l),window.removeEventListener("scroll",l,!0),Jr===l&&(Jr=null)}},[f,l]),g.useEffect(()=>()=>{window.clearTimeout(a.current),window.clearTimeout(o.current),Jr===l&&(Jr=null)},[l]),g.useLayoutEffect(()=>{const w=i.current;if(!w||!n)return;const{width:v,height:j}=w.getBoundingClientRect(),b=YQ(e,n.box,v,j,n.within);w.style.left=`${b.left}px`,w.style.top=`${b.top}px`,w.style.visibility="visible"},[n,e]);const p=g.useCallback(w=>({onPointerEnter:v=>{w&&v.pointerType==="mouse"&&u(v.currentTarget,w,!1)},onPointerLeave:h,onPointerDown:l,onFocus:v=>{w&&v.currentTarget.matches(":focus-visible")&&u(v.currentTarget,w,!0)},onBlur:l}),[u,h,l]),m=n&&kt.createPortal(r.jsxs("span",{ref:i,className:GQ[e]+XQ[t],"data-instant":n.instant||void 0,style:{left:0,top:0,visibility:"hidden"},"aria-hidden":!0,onPointerEnter:()=>window.clearTimeout(o.current),onPointerLeave:l,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 um="(max-width: 640px)",ZQ=600,JQ=588,QQ=40;function eee(e){if(typeof window>"u")return!1;const t=window.innerWidth;return t>0?t-2*QQ-e-JQ<ZQ:!1}function I1(){if(typeof window>"u"||typeof window.matchMedia!="function")return!1;try{return window.matchMedia(um).matches}catch{return!1}}function AN(e,t){return e&&(t||!e.single)?e:void 0}function tee(e,t,n){var i;const s=(i=AN(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 OD={stripe:"rail-btn rail-btn-stripe",dock:"rail-btn rail-btn-dock",bar:"rail-btn rail-btn-bar"},nee={left:"edge-rail edge-rail-left",right:"edge-rail edge-rail-right"},see={vertical:"ArrowDown",horizontal:"ArrowRight"},ree={vertical:"ArrowUp",horizontal:"ArrowLeft"};function PD(e,t){const[n,s]=g.useState(0),a=Math.min(n,Math.max(0,e-1)),o=g.useCallback(i=>{const l=Array.from(i.currentTarget.querySelectorAll("button[data-rail-item]")),u=l.indexOf(document.activeElement);if(u<0)return;let h=-1;i.key===see[t]?h=(u+1)%l.length:i.key===ree[t]?h=(u-1+l.length)%l.length:i.key==="Home"?h=0:i.key==="End"&&(h=l.length-1),!(h<0)&&(i.preventDefault(),i.stopPropagation(),s(h),l[h].focus())},[t]);return{active:a,setCurrent:s,onKeyDown:o}}let xl=null;function RN(e){g.useLayoutEffect(()=>{var a,o;xl&&document.activeElement===document.body&&((o=(a=e.current)==null?void 0:a.querySelector(`[data-rail-item="${xl}"]`))==null||o.focus()),xl=null;const t=i=>{var u;const l=(u=i.target.dataset)==null?void 0:u.railItem;l&&(xl=l)},n=i=>{var l;(l=e.current)!=null&&l.contains(i.relatedTarget)||(xl=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 MN({item:e,index:t,tabbable:n,onFocusIndex:s,hint:a,variant:o}){var h;const i=Tn(),l=a.bind(tee(e,i,o!=="stripe")),u=e.kind==="panel";return r.jsxs("button",{ref:e.buttonRef,type:"button","data-rail-item":e.id,className:OD[o],tabIndex:o==="bar"?void 0:n?0:-1,"aria-label":e.ariaLabel,"aria-keyshortcuts":(h=AN(e.key,i))==null?void 0:h.aria,"aria-expanded":u?e.open===!0:void 0,"aria-controls":u&&e.open?e.controls:void 0,"aria-haspopup":u?void 0:"dialog",...l,onFocus:f=>{s(t),l.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 oA({side:e,label:t,groups:n}){const s=ac(e==="left"?"right":"left"),a=n.filter(u=>u.length>0),o=PD(a.flat().length,"vertical"),i=g.useRef(null);RN(i);let l=0;return r.jsxs("div",{ref:i,className:nee[e],role:"toolbar","aria-label":t,"aria-orientation":"vertical",onKeyDown:o.onKeyDown,children:[a.map(u=>{const h=u.length>1?u[0].group:void 0;return r.jsx("div",{className:"rail-group",role:h?"group":void 0,"aria-label":h,"data-rail-group":u[0].id==="explore-integrations"?"explore":void 0,children:u.map(f=>{const p=l++;return r.jsx(MN,{item:f,index:p,tabbable:p===o.active,onFocusIndex:o.setCurrent,hint:s,variant:"stripe"},f.id)})},u[0].id)}),s.node]})}const sf="dock-more",iA="dock-more-menu";function aee({items:e,tabbable:t,onFocusIndex:n,index:s}){const[a,o]=g.useState(null),i=a!==null,l=e.reduce((h,f)=>h+(f.badge??0),0),u=h=>()=>{var f;(f=document.getElementById(sf))==null||f.focus(),o(null),h.onPress()};return r.jsxs(r.Fragment,{children:[r.jsxs("button",{id:sf,type:"button","data-rail-item":"more",className:OD.dock,tabIndex:t?0:-1,"aria-label":`More: ${e.map(h=>h.ariaLabel).join(", ")}`,"aria-haspopup":"menu","aria-expanded":i,"aria-controls":i?iA: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"}),l>0&&r.jsx("span",{className:"rail-badge","aria-hidden":!0,children:l})]}),i&&r.jsx(cm,{anchorId:sf,id:iA,className:"ap-pop",role:"menu",labelledBy:sf,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:()=>{xl=h.id},onClick:u(h),children:h.badge?`${h.menu??h.label} · ${h.badge} unread`:h.menu??h.label},h.id))})]})}function oee({items:e,more:t}){const n=ac("above"),s=PD(e.length+1,"horizontal"),a=g.useRef(null);return RN(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(MN,{item:o,index:i,tabbable:i===s.active,onFocusIndex:s.setCurrent,hint:n,variant:"dock"},o.id)),r.jsx(aee,{items:t,index:e.length,tabbable:s.active===e.length,onFocusIndex:s.setCurrent}),n.node]})}function iee({items:e,side:t="below"}){const n=ac(t),s=g.useRef(null);return RN(s),r.jsxs("div",{ref:s,className:"utility-run",children:[e.map((a,o)=>r.jsx(MN,{item:a,index:o,tabbable:!0,onFocusIndex:lee,hint:n,variant:"bar"},a.id)),n.node]})}function lee(){}const ed=[{id:"general",label:"General",note:"Session behavior, board preferences, and automatic updates."},{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:"Keyboard shortcuts and single-key controls."},{id:"notifications",label:"Notifications",note:"How the deck reaches you while you are not looking at it."},{id:"sounds",label:"Sounds",note:"Notification tones and custom audio."},{id:"integrations",label:"Integrations",note:"Manage connections to your developer tools."},{id:"data",label:"Data",note:"What the deck keeps on this device."},{id:"claude",label:"Claude Code",note:"Claude Code settings, saved to your settings.json. Most changes reach running sessions."},{id:"radar",label:"Radar",note:"What Claude Code sends to its telemetry collector, watched all the time."},{id:"about",label:"About",note:"The version you are running, and where to say what you think of it."}];function cee(e,t,n=!0){const s=new Set;return e==="none"&&t!=="integrations"&&s.add("integrations"),!n&&t!=="claude"&&s.add("claude"),s.size?ed.filter(a=>!s.has(a.id)):ed}const lA="settings-tab-";function uee(e,t){return e!=null&&e.startsWith(lA)?e===`${lA}${t}`?null:t:null}const dee={open:!1,section:"general"};function hee(e,t,n){const s={open:!0,section:t??e.section};return n?{...s,landOn:n}:s}function Ua(e,t){return()=>{e(),t()}}function fee(e){return e.key===","&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey}function pee(e){return po(e)?"⌘,":"Ctrl+,"}function mee(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 gee="https://code.claude.com/docs/en/settings-reference",DD=[{id:"sessions",title:"Your sessions"},{id:"memory",title:"Memory and history"},{id:"git",title:"Git"},{id:"terminal",title:"Terminal"},{id:"updates",title:"Updates"}],FD=[{id:"crossSessionInbound",key:"crossSessionInbound",group:"sessions",kind:"choice",since:"2.1.224",label:"Messages from other sessions",note:"What a session does when another of your Claude Code sessions sends it a message.",options:[{value:null,label:"Claude Code decides"},{value:"accept",label:"Accept"},{value:"hold",label:"Ask me first"},{value:"refuse",label:"Refuse"}],keywords:["peers","cross-session","sendmessage","inbox","other sessions","messaging"]},{id:"listAgents",key:"permissions.deny",tool:"ListAgents",group:"sessions",kind:"allowTool",since:"2.1.224",label:"Let sessions find each other",note:"On, Claude can list your other sessions, with each one's folder and whether it is busy. Off adds a deny rule for ListAgents.",keywords:["listagents","peers","see other sessions","privacy","isolation","list agents"]},{id:"isolatePeerMachines",key:"isolatePeerMachines",group:"sessions",kind:"switch",unset:!1,since:"2.1.224",label:"Ask before messaging other machines",note:"Claude asks you before a message leaves this computer for a session on another machine or in the cloud.",keywords:["remote control","cloud","cross-machine","approval"]},{id:"autoMemoryEnabled",key:"autoMemoryEnabled",group:"memory",kind:"switch",unset:!0,label:"Auto memory",note:"Claude keeps notes it learns while working and reads them in later sessions. Off, it does neither.",overrides:[{env:"CLAUDE_CODE_DISABLE_AUTO_MEMORY",when:"on",effect:"Off"},{env:"CLAUDE_CODE_DISABLE_AUTO_MEMORY",when:"off",effect:"On"}],keywords:["memory","remember","notes","memory.md"]},{id:"autoCompactEnabled",key:"autoCompactEnabled",group:"memory",kind:"switch",unset:!0,label:"Compact automatically",note:"Claude summarizes a long conversation when it nears the context limit, so the session can go on.",overrides:[{env:"DISABLE_AUTO_COMPACT",when:"on",effect:"Off"}],keywords:["compact","context","summarize","context window"]},{id:"cleanupPeriodDays",key:"cleanupPeriodDays",group:"memory",kind:"days",unset:30,label:"Keep conversations",note:"Older conversations are deleted without a message and leave the resume list.",options:[7,14,30,90,180,365,3650],keywords:["transcripts","history","retention","delete","resume","cleanup"]},{id:"fileCheckpointingEnabled",key:"fileCheckpointingEnabled",group:"memory",kind:"switch",unset:!0,label:"Checkpoints for rewind",note:"Claude keeps a copy of each file before editing it, so a change can be rewound.",overrides:[{env:"CLAUDE_CODE_DISABLE_FILE_CHECKPOINTING",when:"on",effect:"Off"}],keywords:["rewind","checkpoint","restore","revert"]},{id:"attribution",key:"attribution",group:"git",kind:"attribution",since:"2.1.281",label:"Credit Claude in commits and pull requests",note:"Off, Claude adds no Co-Authored-By line to commits and no attribution line to pull requests.",keywords:["co-authored-by","co-author","trailer","generated with","commit message","pull request","attribution"]},{id:"spinnerTipsEnabled",key:"spinnerTipsEnabled",group:"terminal",kind:"switch",unset:!0,label:"Tips while Claude works",note:"The tip under the spinner while a turn is running.",keywords:["spinner","tips","hints"]},{id:"showTurnDuration",key:"showTurnDuration",group:"terminal",kind:"switch",unset:!0,legacy:!0,label:"Show how long a turn took",note:"The line after each turn that says how long Claude worked.",keywords:["duration","time","timer"]},{id:"prefersReducedMotion",key:"prefersReducedMotion",group:"terminal",kind:"switch",unset:!1,label:"Reduce motion",note:"Fewer animations in the terminal, such as the spinner, shimmer and flash effects.",keywords:["animation","motion","accessibility","spinner"]},{id:"autoUpdatesChannel",key:"autoUpdatesChannel",group:"updates",kind:"choice",label:"Update channel",note:"Stable follows a version about a week old and skips releases with major regressions.",overrides:[{env:"DISABLE_UPDATES",when:"on",effect:"Updates are off"},{env:"DISABLE_AUTOUPDATER",when:"on",effect:"Background updates are off"}],options:[{value:null,label:"Latest",also:"latest"},{value:"stable",label:"Stable"}],keywords:["updates","release channel","stable","latest","version"]}];function cA(e){return e===3650?"10 years":e===365?"1 year":e===1?"1 day":`${e} days`}const BD="agent-dag.character",$f=[{id:"deck",name:"Deck companion"},{id:"fox",name:"Fox"},{id:"penguin",name:"Penguin"}];function yee(e){return e==="fox"||e==="penguin"?e:"deck"}function wee(){return yee(nt(BD))}const xee="With no deck tab open, get a notification wherever a sound would have played.",vee="With the ccdeck window closed, get a notification wherever a sound would have played.";function bee(e){return e?vee:xee}const kee="Held off for this run — the deck was started with alerts disabled. Your choice is saved for the next start.",qD=[{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"}],jee="For the Claude and Codex accounts you're on, whether or not the deck is open.",Nee="Held off for this run too.",uA="Get notified when you're away from this tab.";function See(e){switch(e){case"granted":return{status:"Enabled",ask:!1,ok:!0,note:uA};case"default":return{status:null,ask:!0,ok:!1,note:uA};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 Cee=1024*1024,dA=5,UD=.8,O1=24,_ee="agent-dag.soundCustom.done",Eee="agent-dag.soundCustom.needs-input",Ru={done:_ee,"needs-input":Eee};function td(e){if(e.kind!=="audio")return e;const{bytes:t,...n}=e;return n}function hA(e){return!e||!/^[a-zA-Z0-9._-]{1,96}$/.test(e)?null:e}function Tee(e){return{done:hA(e(Ru.done)),"needs-input":hA(e(Ru["needs-input"]))}}function Aee(e,t){return{done:e.done===t?null:e.done,"needs-input":e["needs-input"]===t?null:e["needs-input"]}}function Ree(e){return e.done&&e.done===e["needs-input"]?e.done:null}const Mee={wav:"audio/wav",wave:"audio/wav",mp3:"audio/mpeg",ogg:"audio/ogg",oga:"audio/ogg",webm:"audio/webm",m4a:"audio/mp4",mp4:"audio/mp4"},WD=new Set(["audio/wav","audio/x-wav","audio/mpeg","audio/mp3","audio/ogg","audio/webm","audio/mp4"]);function HD(e,t){const n=t.toLowerCase().split(";")[0].trim();if(WD.has(n))return n;const s=e.toLowerCase().split(".").pop()??"";return Mee[s]??n}function fA(e,t){const n=HD(e.name,e.type);if(!WD.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>Cee)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>dA)return`Audio must be ${dA} seconds or shorter.`}return null}function P1(e){return e>=O1?`There are already ${O1} custom sounds. Delete one first.`:null}function $ee(e,t){const n=e.indexOf(t);return n<0?null:e[n+1]??e[n-1]??null}function Lee(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,UD/t)}function zD(){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 Iee(e,t,n=zD()){var h;const s=((h=e.name)==null?void 0:h.trim())||"Custom sound",a=fA({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 l=fA({name:s,type:e.type,size:e.size},i.duration);if(l)throw new Error(l);const u=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:HD(s,e.type),duration:i.duration,normalizationGain:Lee(u),bytes:o}}function Oee(e,t=zD()){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 Pee="ccdeck-notification-audio",Dee=2,Ys="assets",br="summaries";function xd(){return typeof window<"u"?window.ccdeckNotificationAudio??null:null}function Fee(){return new Promise((e,t)=>{const n=indexedDB.open(Pee,Dee);n.onupgradeneeded=s=>{const a=n.result,o=a.objectStoreNames.contains(Ys)?n.transaction.objectStore(Ys):a.createObjectStore(Ys,{keyPath:"id"});if(a.objectStoreNames.contains(br))return;const i=a.createObjectStore(br,{keyPath:"id"});if(s.oldVersion<1)return;const l=o.openCursor();l.onsuccess=()=>{const u=l.result;u&&(i.put(td(u.value)),u.continue())}},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error??new Error("Could not open local audio storage."))})}async function vd(e,t,n){const s=await Fee();try{return await new Promise((a,o)=>{const i=s.transaction(e,t),l=n(i),u=()=>o(i.error??new Error("Local audio storage failed."));i.oncomplete=()=>a(l?l.result:void 0),i.onerror=u,i.onabort=u})}finally{s.close()}}async function Bee(){const e=xd();return e?e.list():typeof indexedDB>"u"?[]:await vd([br],"readonly",t=>t.objectStore(br).getAll())??[]}async function qee(e){const t=xd();return t?t.get(e):typeof indexedDB>"u"?null:await vd([Ys],"readonly",n=>n.objectStore(Ys).get(e))??null}async function pA(e){const t=xd();if(t){await t.put(e);return}if(typeof indexedDB>"u")throw new Error("Local audio storage is unavailable in this browser.");await vd([Ys,br],"readwrite",n=>{n.objectStore(Ys).put(e),n.objectStore(br).put(td(e))})}async function Uee(e,t){const n=xd();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 vd([Ys,br],"readwrite",s=>{const a=s.objectStore(Ys),o=a.get(e);o.onsuccess=()=>{const i=o.result;if(!i)return;const l={...i,name:t};a.put(l),s.objectStore(br).put(td(l))}})}async function Wee(e){const t=xd();if(t){await t.remove(e);return}typeof indexedDB>"u"||await vd([Ys,br],"readwrite",n=>{n.objectStore(Ys).delete(e),n.objectStore(br).delete(e)})}const Mu=["done","needs-input"],Hee=[{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}]}],zee=[{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}]}],$N={done:Hee,"needs-input":zee},Jn="two";function D1(e,t){const n=$N[e];return n.find(s=>s.id===t)??n.find(s=>s.id===Jn)??n[0]}function VD(e,t){return $N[e].some(s=>s.id===t)?t:Jn}D1("done",Jn).notes,D1("needs-input",Jn).notes;const mA=.04,GD=.24,Lf=0,hp=100,LN=5,wi=50;function dm(e,t=LN){if(!Number.isFinite(e))return wi;const n=Math.round(e/t)*t;return Math.min(hp,Math.max(Lf,n))}function KD(e,t=LN){if(e==null)return wi;const n=e.trim();return/^-?\d+(\.\d+)?$/.test(n)?dm(Number(n),t):wi}function IN(e){const t=dm(e),n=mA+(GD-mA)*(t/hp);return Math.round(n*1e4)/1e4}function Vee(e,t){const n=t.trim,s=typeof n=="number"&&Number.isFinite(n)&&n>0&&n<=1?n:1;return Math.round(IN(e)*s*1e4)/1e4}const Gee=.012,gA=1e-4;function Kee(e){return Math.min(1,IN(e)/GD)}function Yee(e,t){const n=e*(IN(t)/UD);return Math.max(1e-4,n)}const Xee=160,Zee="agent-dag.soundLevel.done",Jee="agent-dag.soundLevel.needs-input",Qee="agent-dag.soundFigure.done",ete="agent-dag.soundFigure.needs-input",YD={done:Zee,"needs-input":Jee},fp={done:Qee,"needs-input":ete},yA={done:{level:wi,figure:Jn},"needs-input":{level:wi,figure:Jn}};function tte(e){const t=n=>({level:KD(e(YD[n])),figure:VD(n,e(fp[n]))});return{done:t("done"),"needs-input":t("needs-input")}}function nte(e,t){return(e??yA)[t]??yA[t]}const ste={Stop:"done",Notification:"needs-input"};function rte(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:Zt(ste,n)??null}const oc={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"}},fr=Object.keys(oc);function ate(e){return fr[(fr.indexOf(e)+1)%fr.length]}const XD="agent-dag.theme";function ote(e,t=!1){return typeof e=="string"&&Object.hasOwn(oc,e)?e:"rider-black"}function ite(){return ote(nt(XD))}const ZD="section:";function hm(e){return e.id.startsWith(ZD)}const lte={general:["behaviour","behavior","preferences"],appearance:["look","style"],reading:["readability","legibility"],keyboard:["shortcuts","hotkeys","keybindings","keys"],notifications:["alerts","notify"],sounds:["audio","tones","chimes"],integrations:["github","gitlab","pull requests","merge requests","pipelines","jira","atlassian","tracker","issues","connect","token","board","sprint"],data:["privacy","local data"],claude:["claude","claude code","cli","settings.json","config","configuration"],radar:["telemetry","collector","monitoring"],about:["information"]},cte={done:"Turn finished","needs-input":"Claude is asking"},ute={done:["done","complete","finished","end of turn","volume","preview","chime","tone"],"needs-input":["question","needs input","permission","waiting","volume","preview","chime","tone"]},dte={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"]},ON=e=>{var t;return((t=ed.find(n=>n.id===e))==null?void 0:t.label)??e};function hte(e){return{id:`${ZD}${e}`,section:e,label:ON(e),keywords:lte[e],...e==="claude"?{claudeOnly:!0}:{}}}function fte(){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"]},...fr.map(t=>({id:`theme-${t}`,section:"appearance",group:"Theme",label:oc[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",...$f.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"]},...qD.map(({kind:t,label:n})=>({id:t,section:"notifications",group:"Accounts",label:n,keywords:dte[t]}))],sounds:[{id:"play-sounds",section:"sounds",label:"Play sounds",keywords:["sound","mute","unmute","silence","quiet"]},...Mu.map(t=>({id:`tone-${t}`,section:"sounds",label:cte[t],keywords:ute[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:"integration-github",section:"integrations",label:"GitHub",keywords:["connect","repositories","pull requests","actions","personal access token"]},{id:"integration-gitlab",section:"integrations",label:"GitLab",keywords:["connect","projects","merge requests","pipelines","self-managed","personal access token"]},{id:"integration-jira",section:"integrations",label:"Jira",keywords:["connect","boards","sprints","issues","atlassian","cloud","server","data center","api token"]},{id:"integrations-add",section:"integrations",label:"Connect development tools",keywords:["connect","add integration","github","gitlab","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","github","gitlab","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"]}],claude:[...FD.map(t=>{var n;return{id:`claude-${t.id}`,claudeOnly:!0,section:"claude",group:(n=DD.find(s=>s.id===t.group))==null?void 0:n.title,label:t.label,keywords:t.keywords}}),{id:"claude-all-settings",claudeOnly:!0,section:"claude",label:"All Claude Code settings",keywords:["every setting","all keys","reference","documentation","lookup","settings.json"]}],radar:[{id:"radar-open",section:"radar",label:"Radar",keywords:["telemetry","collector","monitoring","traffic","background","automatic","packet capture"]}],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 ed.flatMap(({id:t})=>[hte(t),...e[t]])}const F1=fte();function JD(e,t="all",n){return e&&t==="all"&&!n?F1:F1.filter(s=>(e||!s.claudeOnly)&&(!n||!s.id.startsWith("integration-")||n.has(s.id.slice(12)))&&(s.section!=="integrations"||t==="all"||t==="connections"&&(hm(s)||s.id==="integrations-connections")))}function PN(e){if(hm(e))return"Section";const t=ON(e.section);return e.group&&e.group!==e.label?`${t} › ${e.group}`:t}function pte(e){return`${e.label}, ${PN(e).replace(/ › /g,", ")}`}function bu(e){return e.normalize("NFD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/\s+/g," ").trim()}function rf(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 mte(e,t){const n=bu(e.label);if(n.startsWith(t))return 0;if(rf(n,t))return 1;const s=e.keywords.map(bu);if(s.some(i=>rf(i,t)))return 2;const a=[bu(ON(e.section)),...e.group?[bu(e.group)]:[]];if(a.some(i=>rf(i,t)))return 3;const o=t.split(" ");if(o.length>1){const i=[n,...s,...a];if(o.every(l=>i.some(u=>rf(u,l))))return 4}return null}const gte=12;function yte(e,t=F1){const n=bu(e);return n?t.map((s,a)=>({entry:s,at:a,score:mte(s,n)})).filter(s=>s.score!==null).sort((s,a)=>s.score-a.score||s.at-a.at).slice(0,gte).map(s=>s.entry):[]}function QD(e,t){const n=t.trim();return e===0?`No setting matches “${n}”.`:e===1?`1 setting matches “${n}”`:`${e} settings match “${n}”`}function wte(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"}}function fm({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==="claude"&&r.jsxs(r.Fragment,{children:[r.jsx("rect",{x:"1.8",y:"2.6",width:"10.4",height:"8.8",rx:"1.6"}),r.jsx("path",{d:"M4.4 5.6 6 7l-1.6 1.4M7.4 8.6h2.2"})]}),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 xte={"session-list":["sessions","agents"],accounts:["claude","login","switch account"],"account-capacity":["limits","quota","5h","7d"],"reset-calendar":["limits","weekly","reset"],usage:["cost","spend","quota","tokens","money"],machine:["cpu","memory","ram","temperature","system","load"],history:["cost","spend","chart","days"],"tool-activity":["tools","commands","bash","slow"],"skill-activity":["skills"],"browser-watch":["browser","history"],"traffic-radar":["telemetry","network","connections"],radio:["music","fm","stations"],settings:["preferences","options"],feedback:["bug","report","idea","contact"],"explore-integrations":["jira","github","gitlab","connect"]},vte=new Set(["accounts","browser-watch","radar-open","tour","feedback"]);function bte(e,t){var a;const n=r.jsx(fm,{section:e.section});if(hm(e))return{id:`settings:${e.id}`,section:"settings",title:e.label,subtitle:(a=ed.find(o=>o.id===e.section))==null?void 0:a.note,keywords:["settings",...e.keywords],tag:"Settings",verb:"Open in Settings",glyph:n,run:()=>t(e.section)};const s=PN(e);return{id:`settings:${e.id}`,section:"settings",title:e.label,subtitle:s,keywords:[...e.keywords,...s.split(" › ")],tag:"Setting",verb:"Go to setting",glyph:n,queryOnly:!0,run:()=>t(e.section,e.id)}}function kte(e,t){var s,a;const n=e.kind==="panel";return{id:`door:${e.id}`,section:"open",title:e.hint??e.menu??e.label,subtitle:(s=e.detail)==null?void 0:s.split(`
|
|
96
|
+
`)[0],keywords:[e.label,e.short,...xte[e.id]??[],...e.detail?[e.detail]:[]],tag:n?e.open?"Shown":"Panel":"Dialog",verb:n?e.open?"Hide panel":"Show panel":"Open",keyCap:(a=AN(e.key,t))==null?void 0:a.cap,glyph:e.glyph,run:e.onPress}}function jte(e,t){const n=e.cwdBasename&&e.cwdBasename!==e.label?` · ${e.cwdBasename}`:"";return e.waiting&&_n(e.waiting)?{line:`Needs you · ${Qu(e.waiting.since,void 0,t)}${n}`,tone:"waiting"}:e.state==="active"?{line:`Working${n}`,tone:"active"}:e.state==="err"?{line:`Failed${n}`,tone:"err"}:{line:`Done${n}`,tone:"done"}}function Nte(e){const t=a=>e.singleKeys?a:void 0,n=[...e.rails.left,...e.rails.capacity,...e.rails.right.flat(),...e.rails.integrations,...e.rails.explore,...e.rails.utilities],s=[];for(const a of e.sessions){const{line:o,tone:i}=jte(a,e.now);s.push({id:`session:${a.sessionId}`,section:"sessions",title:a.label,subtitle:o,keywords:[a.cwdBasename??"",a.modelId??""].filter(Boolean),tag:"Session",verb:"Go to session",tone:i,run:()=>e.openSession(a.sessionId)})}for(const a of n)s.push(kte(a,e.singleKeys));for(const a of e.settings)a.id.startsWith("theme-")||vte.has(a.id)||s.push(bte(a,e.openSettings));s.push({id:"action:fit",section:"actions",title:"Fit every agent on screen",keywords:["zoom","view","recenter"],tag:"Action",verb:"Run",keyCap:t("F"),glyph:r.jsx($Q,{}),run:e.fit},{id:"action:rearrange",section:"actions",title:"Re-arrange the canvas",keywords:["layout","tidy","pins"],tag:"Action",verb:"Run",keyCap:t("R"),glyph:r.jsx(LQ,{}),run:e.rearrange},{id:"action:pause",section:"actions",title:e.paused?"Resume the stream":"Pause the stream",keywords:["pause","resume","freeze","live"],tag:"Action",verb:"Run",keyCap:t("Space"),glyph:r.jsx(IQ,{}),run:e.togglePause},{id:"action:keys",section:"actions",title:"Keyboard shortcuts",keywords:["keys","help","?"],tag:"Action",verb:"Open",keyCap:t("?"),glyph:r.jsx(fm,{section:"keyboard"}),run:e.keyHelp},{id:"action:tour",section:"actions",title:"Take the tour",keywords:["help","guide","intro","start"],tag:"Action",verb:"Start",glyph:r.jsx($D,{}),run:e.tour}),e.clear&&s.push({id:"action:clear",section:"actions",title:"Clear the canvas…",subtitle:"Asks first",keywords:["clear","reset","empty","delete"],tag:"Action",verb:"Ask first",keyCap:t("C"),glyph:r.jsx(OQ,{}),run:e.clear});for(const a of fr){const o=oc[a];s.push({id:`theme:${a}`,section:"themes",title:o.name,keywords:["theme",o.colorScheme],tag:a===e.theme?"Current":"Theme",verb:"Use theme",queryOnly:!0,glyph:r.jsx("span",{className:"appearance-preview qo-swatch","data-swatch":a}),run:()=>e.setTheme(a)})}return s}const vt=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`:""}`},Ste=e=>e<1024?`${e} B`:e<1048576?`${(e/1024).toLocaleString(void 0,{maximumFractionDigits:1})} KB`:`${(e/1048576).toLocaleString(void 0,{maximumFractionDigits:1})} MB`,Cte=e=>new Date(e).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});async function pp(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 l=()=>{window.clearTimeout(u),i(new DOMException("Cancelled","AbortError"))},u=window.setTimeout(()=>{t.removeEventListener("abort",l),o()},300);t.addEventListener("abort",l,{once:!0}),t.aborted&&l()});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 wA={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 Zl(e){if(Object.hasOwn(wA,e))return wA[e];const t=/^(npm|pnpm|yarn|bun) run (.+)$/.exec(e);if(t)return`Runs the “${t[2]}” script`;const n=e5(e);return n?`From the ${n.server} MCP server`:null}function e5(e){const t=/^mcp__(.+?)__(.+)$/.exec(e);return t?{server:t[1],tool:t[2]}:null}const ao=e=>{var t;return((t=e5(e))==null?void 0:t.tool)??e},_te=[{id:"calls",label:"Most used"},{id:"time",label:"Most time"},{id:"slowest",label:"Slowest"},{id:"failed",label:"Failures"}];function mp(e,t){return t==="calls"?e.calls:t==="time"?e.totalMs:t==="slowest"?e.medianMs:e.failed}const Ete=(e,t)=>{const n=t.trim().toLowerCase();return!n||e.operation.toLowerCase().includes(n)||(Zl(e.operation)??"").toLowerCase().includes(n)};function tw(e,t,n=""){return e.filter(s=>Ete(s,n)).sort((s,a)=>{const o=mp(s,t),i=mp(a,t);return o!==i?o===null?1:i===null?-1:i-o:a.calls-s.calls||s.operation.localeCompare(a.operation)})}const ki=(e,t)=>{const n=e/t*100;return`${n>0&&n<1?"<1":Math.round(n)}%`},pm=e=>e.failed>0&&e.completed>0?ki(e.failed,e.completed):null;function Tte(e,t){const n=[],a=e.filter(l=>l.totalMs!==null&&l.measured>=2).slice().sort((l,u)=>u.totalMs-l.totalMs)[0];a&&t&&a.totalMs>=t*.2&&n.push({kind:"time",operation:a.operation,title:"takes the most time",detail:`${vt(a.totalMs)} over ${bt(a.calls,"call")}, ${ki(a.totalMs,t)} of all tool time.`});const o=e.filter(l=>l.completed>=5&&l.failed>=2&&l.failed/l.completed>=.1).sort((l,u)=>u.failed/u.completed-l.failed/l.completed||u.failed-l.failed)[0];o&&n.push({kind:"failing",operation:o.operation,title:"fails often",detail:`${o.failed.toLocaleString()} of ${bt(o.completed,"call")} failed (${pm(o)}).`});const i=e.filter(l=>l.medianMs!==null&&l.measured>=3&&l.medianMs>=1e4&&l.operation!==(a==null?void 0:a.operation)).sort((l,u)=>u.medianMs-l.medianMs)[0];return i&&n.push({kind:"slow",operation:i.operation,title:"is the slowest",detail:`Usually ${vt(i.medianMs)} per call; the longest took ${vt(i.maxMs)}.`}),n}const bt=(e,t)=>`${e.toLocaleString()} ${t}${e===1?"":"s"}`,nd={1:"24 hours",7:"7 days",30:"30 days",90:"90 days"},Ate={all:"your agents",claude:"Claude",codex:"Codex"};function Rte(e,t,n){return{lead:`In the last ${nd[n]??`${n} days`}, ${Ate[t]} made`,calls:bt(e.total,"tool call"),time:e.totalMs?vt(e.totalMs):null,failed:e.failed,failedShare:e.failed&&e.completed?ki(e.failed,e.completed):null}}const aa=e=>new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric"});function t5(e,t=Date.now()){const n=s=>new Date(s).toDateString();return n(e)===n(t)?"Today":n(e)===n(t-864e5)?"Yesterday":new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric"})}const B1=e=>new Date(e).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"});function mm(e,t=Date.now()){const n=t5(e,t);return n==="Today"||n==="Yesterday"?`${n} ${B1(e)}`:`${n}, ${B1(e)}`}function ic(e){const[t,n]=g.useState(()=>typeof window<"u"&&typeof window.matchMedia=="function"&&window.matchMedia(e).matches);return g.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 Mte({keyboard:e,onClose:t,children:n}){const s=g.useRef(null),a=gt(t,{focusRef:s}),o=yt(t);return g.useEffect(()=>{var i,l;s.current=((i=a.current)==null?void 0:i.querySelector("#tool-operation-heading"))??null,(l=s.current)==null||l.focus({preventScroll:!0})},[a]),kt.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 $te({keyboard:e,itemKey:t,onClose:n,children:s}){const a=g.useRef(null),o=g.useRef(n);return o.current=n,g.useEffect(()=>cn.push(()=>o.current(),0,"popover"),[]),g.useLayoutEffect(()=>{var l,u;a.current&&(a.current.scrollTop=0);const i=document.activeElement;(i===document.body||e&&i instanceof HTMLElement&&(i.dataset.operation??i.dataset.skill)===t)&&((u=(l=a.current)==null?void 0:l.querySelector("#tool-operation-heading"))==null||u.focus({preventScroll:!0}))},[t,e]),g.useLayoutEffect(()=>{var u,h;if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return;const i=(u=a.current)==null?void 0:u.querySelector(".ta-inspector"),l=(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()=>l==null?void 0:l.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 n5(e){return ic("(max-width: 700px)")?r.jsx(Mte,{...e}):r.jsx($te,{...e})}const Ya=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString(void 0,{timeZone:"UTC",month:"short",day:"numeric"});function Lte(e,t){return e.status==="outside-history"?`${Ya(e.date)} · before recording started`:e.calls?`${Ya(e.date)} · ${bt(e.calls,t)}${e.medianMs!=null?` · usually ${vt(e.medianMs)}`:""}`:`${Ya(e.date)} · no ${t}s`}function s5({noun:e="call"}){return r.jsxs("section",{className:"ta-history","aria-hidden":"true",children:[r.jsxs("h4",{children:[e[0].toUpperCase(),e.slice(1),"s per day"]}),r.jsx("div",{className:"ta-history-bars ta-history-skeleton",style:{"--ta-days":7},children:[.35,.6,.25,.8,.45,.3,.7].map((t,n)=>r.jsx("span",{children:r.jsx("i",{className:"ta-skel",style:{"--ta-height":t}})},n))}),r.jsx("div",{className:"ta-history-axis",children:r.jsx("span",{children:" "})}),r.jsx("p",{className:"ta-note ta-history-day",children:r.jsx("i",{className:"ta-skel",style:{width:"9em"}})})]})}function Ite({history:e,noun:t="call"}){const n=e.days,s=[...n].reverse().find(f=>f.calls>0)??n.at(-1),[a,o]=g.useState(null);if(n.length<3||!s)return null;const i=n.find(f=>f.date===a)??s,l=n.reduce((f,p)=>p.calls>f.calls?p:f,n[0]),u=Math.max(1,l.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 ${Ya(n[0].date)} to ${Ya(n.at(-1).date)}. The busiest day was ${Ya(l.date)} with ${bt(l.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/u}})},f.date))}),r.jsxs("div",{className:"ta-history-axis","aria-hidden":"true",children:[r.jsx("span",{children:Ya(n[0].date)}),r.jsx("span",{children:Ya(n.at(-1).date)})]}),r.jsx("p",{className:"ta-note ta-history-day","aria-live":"polite",children:Lte(i,t)})]})}function r5(){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 $u=({width:e="3ch"})=>r.jsx("i",{className:"ta-skel",style:{width:e},"aria-hidden":"true"}),a5=({label:e})=>r.jsx("div",{className:"ta-skel-lines",role:"status","aria-label":e,children:[92,78,86,70,82].map(t=>r.jsx("i",{className:"ta-skel",style:{width:`${t}%`}},t))}),Ote={success:"Done",failed:"Failed",unmatched:"No result"},Pte=({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 Dte(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 Fte({row:e,details:t,loading:n,pending:s=!1,charted:a=!0,error:o,kind:i,setKind:l,onClose:u,onShowSkills:h}){const f=Zl(e.operation),p=(t==null?void 0:t[i])??[],m=Date.now(),w=pm(e),v=(n||s)&&!t,j=b=>s?r.jsx($u,{}):b;return r.jsxs("section",{className:"ta-inspector","aria-label":`${ao(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:ao(e.operation)}),f&&r.jsx("p",{children:f})]}),r.jsx("button",{type:"button",className:"glyph-btn","aria-label":"Close details",onClick:u,children:r.jsx(r5,{})})]}),r.jsxs("dl",{className:"ta-facts","aria-busy":s||void 0,children:[r.jsxs("div",{children:[r.jsx("dt",{children:"Calls"}),r.jsx("dd",{children:j(e.calls.toLocaleString())})]}),r.jsxs("div",{children:[r.jsx("dt",{children:"Total time"}),r.jsx("dd",{children:j(vt(e.totalMs))})]}),r.jsxs("div",{children:[r.jsx("dt",{children:"Usually"}),r.jsx("dd",{children:j(vt(e.medianMs))})]}),r.jsxs("div",{children:[r.jsx("dt",{children:"Failed"}),r.jsx("dd",{"data-bad":!s&&e.failed>0||void 0,children:j(r.jsxs(r.Fragment,{children:[e.failed.toLocaleString(),w&&r.jsx("small",{children:w})]}))})]})]}),r.jsx("p",{className:"ta-note",children:s?r.jsx($u,{width:"14em"}):r.jsxs(r.Fragment,{children:[Dte(e),e.maxMs!==null&&e.measured>1&&r.jsxs(r.Fragment,{children:[" · longest ",vt(e.maxMs)]}),e.unmatched>0&&r.jsxs(r.Fragment,{children:[" · ",bt(e.unmatched,"call")," without a result yet"]})]})}),h&&r.jsx("button",{type:"button",className:"btn ta-show-skills",onClick:h,children:"See which skills ran →"}),o&&r.jsx("p",{className:"ta-message",role:"alert",children:o}),t!=null&&t.history?r.jsx(Ite,{history:t.history},e.operation):v&&a&&r.jsx(s5,{}),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":i==="recent",onClick:()=>l("recent"),children:"Latest"}),r.jsx("button",{type:"button",className:"uh-range-btn","aria-pressed":i==="slowest",onClick:()=>l("slowest"),children:"Slowest"})]})]}),v&&r.jsx(a5,{label:"Reading calls"}),t&&r.jsxs(r.Fragment,{children:[r.jsx("ul",{className:"ta-calls",children:p.map(b=>r.jsxs("li",{"data-state":b.state,children:[r.jsx("span",{className:"ta-call-when",children:mm(b.capturedAt,m)}),r.jsx("span",{className:"ta-call-who",children:b.provider==="claude"?"Claude":"Codex"}),r.jsx("span",{className:"ta-call-took",children:vt(b.durationMs)}),r.jsxs("span",{className:"ta-call-state",children:[r.jsx(Pte,{state:b.state}),Ote[b.state]]})]},b.id))}),!p.length&&r.jsx("p",{className:"ta-note",children:i==="slowest"?"None of these calls was timed.":"No calls in this period."}),t.total>p.length&&p.length>0&&r.jsxs("p",{className:"ta-note",children:["The ",i==="recent"?"latest":"slowest"," ",p.length," of ",t.total.toLocaleString(),"."]})]})]}),r.jsx("p",{className:"ta-note ta-inspector-foot",children:"Times include any wait for your approval."})]})}const q1="agent-dag.text-size",U1="agent-dag.density",xA=["smallest","smaller","default","larger","largest"],vA=["tightest","tighter","compact","default","comfortable"],DN={smallest:-2,smaller:-1,default:0,larger:2,largest:4};function FN(){var e,t;return BN(typeof document>"u"?null:(t=(e=document.documentElement)==null?void 0:e.dataset)==null?void 0:t.textSize)}function BN(e){return e==="smallest"||e==="smaller"||e==="larger"||e==="largest"?e:"default"}function o5(e){return e==="tightest"||e==="tighter"||e==="compact"||e==="comfortable"?e:"default"}const Bte=()=>BN(nt(q1)),qte=()=>o5(nt(U1)),gr={min:320,standard:380,max:1600},Ute=420,Wte=8,i5="agent-dag.tool-activity.details-width";function lu(e,t){const n=Math.max(gr.min,Math.min(gr.max,t-Ute-Wte));return Math.round(Math.min(n,Math.max(gr.min,Number.isFinite(e)?e:gp())))}function gp(){return gr.standard+12*Math.max(0,DN[FN()])}function l5(){const e=Number(nt(i5));return Number.isFinite(e)&&e>=gr.min&&e<=gr.max?Math.round(e):gp()}function c5(e){st(i5,String(Math.round(e)))}function u5({width:e,workspace:t,onCommit:n}){const s=g.useRef(null),a=g.useRef(null),o=()=>{var w;return((w=t.current)==null?void 0:w.clientWidth)??window.innerWidth},i=lu(e,o()),l=w=>{var v,j;(v=t.current)==null||v.style.setProperty("--ta-details-w",`${w}px`),(j=s.current)==null||j.setAttribute("aria-valuenow",String(w))},u=w=>{l(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=lu(v.width+v.x-w.clientX,v.room),l(v.last))},p=()=>{var v;const w=a.current;w&&(a.current=null,(v=t.current)==null||v.removeAttribute("data-resizing"),u(w.last))},m=w=>{const v=w.shiftKey?64:16,j=w.key==="ArrowLeft"?i+v:w.key==="ArrowRight"?i-v:w.key==="Home"?gr.min:w.key==="End"?gr.max:w.key==="Enter"?gp():null;j!==null&&(w.preventDefault(),u(lu(j,o())))};return r.jsx("div",{ref:s,className:"ta-splitter",role:"separator","aria-orientation":"vertical","aria-label":"Details width","aria-controls":"tool-operation-inspector","aria-valuemin":gr.min,"aria-valuemax":lu(gr.max,o()),"aria-valuenow":i,tabIndex:0,title:"Drag to resize · double-click for the standard width",onPointerDown:h,onPointerMove:f,onPointerUp:p,onPointerCancel:p,onLostPointerCapture:p,onDoubleClick:()=>u(lu(gp(),o())),onKeyDown:m})}const d5="(starting tools)",Hte={claude:{label:"Claude",hint:"Nothing was running: the model thinking and writing, the network to it, and Claude Code itself."},machine:{label:"This machine",hint:"Tools and commands running here, and the hooks that start them. Calls that ran at the same time count once."},you:{label:"You",hint:"Claude waiting for your approval or your answer."}};function zte(e){const t={claude:e.claudeMs,machine:e.machineMs,you:e.youMs};return["claude","machine","you"].filter(n=>t[n]>0||n!=="you").map(n=>({id:n,...Hte[n],ms:t[n],share:e.totalMs?ki(t[n],e.totalMs):"0%"}))}const bA=e=>e>=36e5?`${Math.round(e/36e5).toLocaleString()} h`:vt(e);function h5(e,t=.8){const n=e.filter(o=>o.value>0),s=n.reduce((o,i)=>o+i.value,0);if(!s)return[];if(n.length===1)return[{id:n[0].id,from:0,length:100}];let a=0;return n.map(o=>{const i=o.value/s*100,l=a;return a+=i,{id:o.id,from:l+t/2,length:Math.max(.3,i-t)}})}const Vte=(e,t=.8)=>h5(e.map(n=>({id:n.id,value:n.ms})),t);function kA(e,t){if(t==="claude")return e.replies.count?`Usually answers in ${vt(e.replies.medianMs)}`:"Thinking and writing";const n=(t==="machine"?e.machine:e.you)[0];if(!n)return t==="machine"?"Tools and the hooks that start them":"Approvals and answers";const{operation:s}=n;return s===d5?"Mostly starting tools":t==="you"?s==="AskUserQuestion"?"Mostly answering questions":s==="ExitPlanMode"?"Mostly approving plans":`Mostly approving ${ao(s)}`:`Mostly ${ao(s)}`}function Gte(e,t,n=6){const s=t==="machine"?e.machine:e.you,a=t==="machine"?e.machineMs:e.youMs,o=h=>a?ki(h,a):"0%",i=s.length>n+1?s.slice(0,n):s,l=a-i.reduce((h,f)=>h+f.ms,0),u=i.map(h=>({...h,share:o(h.ms),...Kte(h.operation,t)}));return i.length<s.length?u.push({operation:"",ms:l,share:o(l),label:`${s.length-i.length} more`,detail:null,inTable:!1,more:!0}):l>=1e3&&u.push({operation:"",ms:l,share:o(l),label:"Everything else",detail:null,inTable:!1}),u}function Kte(e,t){return e===d5?{label:"Starting tools",detail:"The hooks that run before each call, ccdeck’s among them",inTable:!1}:t==="you"&&e==="AskUserQuestion"?{label:"Answering Claude’s questions",detail:null,inTable:!0}:t==="you"&&e==="ExitPlanMode"?{label:"Approving a plan",detail:null,inTable:!0}:{label:ao(e),detail:t==="you"?"Waiting for your approval":Zl(e),inTable:!0}}function Yte(e){const t=e.replies.medianMs;return t?e.replies.days.filter(n=>n.count>=5&&n.medianMs!==null&&n.medianMs>=t*1.5):[]}const Xte={overloaded:"Claude overloaded",rate_limit:"usage limit",server_error:"server error",authentication_failed:"signed out"};function Zte(e){const t=Object.entries(e).filter(([,s])=>s>0).sort((s,a)=>a[1]-s[1]),n=t.reduce((s,[,a])=>s+a,0);return n?`${n.toLocaleString()} ${n===1?"turn":"turns"} ended on an error: ${t.map(([s,a])=>`${Xte[s]??s.replace(/_/g," ")} ${a.toLocaleString()}`).join(", ")}.`:null}const Wo=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString(void 0,{timeZone:"UTC",month:"short",day:"numeric"}),f5=()=>r.jsx("svg",{className:"tt-caret",width:"10",height:"10",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:r.jsx("path",{d:"m3 5 4 4 4-4"})});function Jte({split:e,since:t,turnsSince:n,selected:s,onPick:a}){const[o,i]=g.useState(null),[l,u]=g.useState(null),[h,f]=g.useState(null),p=zte(e),m=x=>{i(S=>S===x?null:x),u(x)},w=p.find(x=>x.id===l)??null,v=p.find(x=>x.id===(h??o))??null,j=n!==void 0&&n>t,b=`${bt(e.turns,"Claude Code turn")}${j?` since ${aa(n)}`:""}`,N=r.jsxs("div",{className:"tt-head",children:[r.jsx("h3",{id:"tt-title",children:"Where the time went"}),e.turns>0&&r.jsx("span",{className:"tt-scope",children:b})]});return e.turns?r.jsxs(r.Fragment,{children:[r.jsxs("section",{className:"tt","aria-labelledby":"tt-title","data-focus":v==null?void 0:v.id,children:[N,r.jsxs("div",{className:"tt-card",onPointerLeave:()=>f(null),children:[r.jsxs("div",{className:"tt-donut",children:[r.jsx("svg",{viewBox:"0 0 120 120","aria-hidden":"true",children:Vte(p).map(x=>r.jsx("circle",{className:"tt-arc","data-lane":x.id,"data-on":(v==null?void 0:v.id)===x.id||void 0,cx:"60",cy:"60",r:"52",pathLength:100,style:{strokeDasharray:`${x.length} ${100-x.length}`,strokeDashoffset:-x.from},onPointerEnter:()=>f(x.id),onClick:()=>m(x.id)},x.id))}),r.jsx("div",{className:"tt-center","aria-hidden":"true",children:v?r.jsxs(r.Fragment,{children:[r.jsx("strong",{children:v.share}),r.jsx("span",{children:v.label})]}):r.jsxs(r.Fragment,{children:[r.jsx("strong",{children:bA(e.totalMs)}),r.jsx("span",{children:"in total"})]})})]}),r.jsx("ul",{className:"tt-lanes",children:p.map(x=>r.jsx("li",{children:r.jsxs("button",{type:"button",className:"tt-lane","data-lane":x.id,"aria-expanded":o===x.id,"aria-controls":"tt-level","aria-label":`${x.label}: ${x.share}, ${vt(x.ms)}. ${kA(e,x.id)}.`,onClick:()=>m(x.id),onPointerEnter:()=>f(x.id),onFocus:()=>f(x.id),onBlur:()=>f(null),children:[r.jsx("i",{"aria-hidden":"true"}),r.jsx("span",{className:"tt-lane-name",children:x.label}),r.jsx("strong",{children:x.share}),r.jsx("span",{className:"tt-lane-time",children:bA(x.ms)}),r.jsx(f5,{}),r.jsx("span",{className:"tt-lane-fact",children:kA(e,x.id)})]})},x.id))})]})]}),r.jsx("div",{className:"tt-fold","data-open":o?"":void 0,children:r.jsx("div",{className:"tt-level",id:"tt-level",ref:x=>{x&&(x.inert=!o)},"aria-label":w?`${w.label}, in detail`:void 0,role:"region",children:w&&r.jsxs("div",{className:"tt-level-body","data-lane":w.id,children:[r.jsxs("div",{className:"tt-level-head",children:[r.jsx("i",{"aria-hidden":"true"}),r.jsx("strong",{children:w.label}),r.jsxs("span",{children:[vt(w.ms)," · ",w.share," of the time"]})]}),r.jsx("p",{className:"ta-note tt-hint",children:w.hint}),w.id==="claude"?r.jsx(ene,{split:e}):r.jsx(Qte,{split:e,lane:w.id,selected:s,onPick:a})]},w.id)})})]}):r.jsxs("section",{className:"tt","aria-labelledby":"tt-title",children:[N,r.jsx("div",{className:"tt-card",children:r.jsxs("p",{className:"ta-note tt-empty",children:["Shows how long Claude, this machine and you each took, once a Claude Code turn ends",j?` — measured from ${aa(n)}`:"","."]})})]})}function Qte({split:e,lane:t,selected:n,onPick:s}){const[a,o]=g.useState(!1),i=Gte(e,t,a?1/0:6),l=Math.max(1,...i.map(h=>h.ms)),u=t==="you"&&i.some(h=>h.inTable&&!["AskUserQuestion","ExitPlanMode"].includes(h.operation));return r.jsxs(r.Fragment,{children:[r.jsx("ul",{className:"tt-parts",children:i.map(h=>{const f=r.jsxs(r.Fragment,{children:[r.jsxs("span",{className:"tt-part-name",children:[r.jsxs("span",{className:h.inTable?"ta-op":void 0,children:[h.label,h.more&&r.jsx(f5,{})]}),h.detail&&r.jsx("span",{className:"ta-desc",children:h.detail}),r.jsx("span",{className:"tt-part-bar","aria-hidden":"true",style:{"--tt-share":Math.max(.015,h.ms/l)}})]}),r.jsxs("span",{className:"ta-cell",children:[vt(h.ms),r.jsx("small",{children:h.share})]})]});return r.jsx("li",{children:h.inTable?r.jsx("button",{type:"button",className:"tt-part","data-selected":n===h.operation||void 0,"aria-expanded":n===h.operation,"aria-label":`${h.label}: ${vt(h.ms)}, ${h.share} of ${t==="machine"?"this machine’s":"your"} time`,onClick:p=>s(h.operation,p),children:f}):h.more?r.jsx("button",{type:"button",className:"tt-part","data-rest":!0,"aria-expanded":!1,"aria-label":`Show ${h.label}: ${vt(h.ms)}, ${h.share}`,onClick:p=>{const m=p.currentTarget.closest("ul");o(!0),requestAnimationFrame(()=>{var w;return(w=m==null?void 0:m.querySelectorAll(".tt-part")[i.length-1])==null?void 0:w.focus()})},children:f}):r.jsx("div",{className:"tt-part","data-static":!0,children:f})},h.operation||h.label)})}),u&&r.jsx("p",{className:"ta-note tt-tip",children:"Allow a command you trust in Settings › Claude Code, and Claude stops asking for it."})]})}function ene({split:e}){const{replies:t}=e,n=Yte(e),s=Zte(e.stops),a=t.days,o=Math.max(1,...a.map(f=>f.medianMs??0)),[i,l]=g.useState(null),u=a.find(f=>f.date===i),h=new Set(n.map(f=>f.date));return r.jsxs(r.Fragment,{children:[r.jsxs("dl",{className:"ta-facts tt-facts",children:[r.jsxs("div",{children:[r.jsx("dt",{children:"Usually answers in"}),r.jsx("dd",{children:vt(t.medianMs)})]}),r.jsxs("div",{children:[r.jsx("dt",{children:"Slowest 1 in 10"}),r.jsx("dd",{children:t.p90Ms===null?"—":`over ${vt(t.p90Ms)}`})]}),r.jsxs("div",{children:[r.jsx("dt",{children:"Longest"}),r.jsx("dd",{children:vt(t.maxMs)})]}),r.jsxs("div",{children:[r.jsx("dt",{children:"Replies"}),r.jsx("dd",{children:t.count.toLocaleString()})]})]}),a.length>=2&&r.jsxs("div",{className:"tt-days",children:[r.jsxs("div",{className:"tt-days-bars",role:"img",style:{"--ta-days":a.length,"--tt-usual":(t.medianMs??0)/o},onPointerLeave:()=>l(null),"aria-label":`Claude's usual reply per day, from ${Wo(a[0].date)} to ${Wo(a.at(-1).date)}. ${n.length?`Slower than usual on ${n.map(f=>Wo(f.date)).join(", ")}.`:"No day was clearly slower than usual."}`,children:[a.map(f=>r.jsx("span",{"data-slow":h.has(f.date)||void 0,"data-shown":f.date===i||void 0,onPointerEnter:()=>l(f.date),children:r.jsx("i",{style:{"--ta-height":(f.medianMs??0)/o}})},f.date)),r.jsx("b",{className:"tt-usual","aria-hidden":"true"})]}),r.jsxs("div",{className:"ta-history-axis","aria-hidden":"true",children:[r.jsx("span",{children:Wo(a[0].date)}),r.jsx("span",{children:Wo(a.at(-1).date)})]}),r.jsx("p",{className:"ta-note tt-days-note","aria-live":"polite",children:u?`${Wo(u.date)} · ${u.count?`${bt(u.count,"reply")} · usually ${vt(u.medianMs)}`:"no replies"}`:n.length?`Slower than usual on ${n.map(f=>`${Wo(f.date)} (${vt(f.medianMs)})`).join(", ")} — the line is your usual ${vt(t.medianMs)}.`:`No day was clearly slower than your usual ${vt(t.medianMs)}.`})]}),s&&r.jsx("p",{className:"ta-note tt-stops",children:s})]})}const af=864e5,tne=[{id:"uses",label:"Most used"},{id:"recent",label:"Latest"},{id:"name",label:"Name"}];function Jl(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 nw(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"?Jl(a.name).short.localeCompare(Jl(o.name).short)||a.name.localeCompare(o.name):o.uses-a.uses||o.lastAt-a.lastAt||a.name.localeCompare(o.name))}function p5(e){const{claude:t,codex:n}=e.providers;return t&&n?"Claude and Codex":n?"Codex":"Claude"}const bd=["agent","detected","typed"],yp={agent:"Picked by Claude",detected:"Picked by Codex",typed:"Typed by you"},nne=e=>e.origin==="typed"&&e.provider==="codex"?"Typed in Codex":yp[e.origin],m5=e=>bd.filter(t=>e[t]>0).map(t=>({id:t,text:`${e[t].toLocaleString()} ${yp[t][0].toLowerCase()}${yp[t].slice(1)}`})),sne=e=>m5(e).map(t=>t.text).join(", "),g5=(e,t)=>t==="codex"||!e.typedCommands||e.typedCommands==="on";function rne(e,t){const n=e.rows.filter(o=>o.uses>0),s=n.reduce((o,i)=>o+i.uses,0),a=!g5(e,t);return bd.flatMap(o=>{const i=n.reduce((h,f)=>h+f[o],0);if(!i&&!(o==="typed"&&a))return[];const l=n.filter(h=>h[o]>0).sort((h,f)=>f[o]-h[o]||f.lastAt-h.lastAt),u=o==="typed"&&a?i?"Claude’s slash commands are not counted":"Slash commands are not counted":`${l.length===1?"Only":"Mostly"} ${Jl(l[0].name).short}`;return[{id:o,label:yp[o],uses:i,share:s?ki(i,s):"0%",fact:u}]})}function ane(e){const t=bd.filter(a=>e[a]>0).length>1,n=[["Claude",e.agent],["Codex",e.detected]].filter(([,a])=>a>0).map(([a,o])=>t?`${a} ${o.toLocaleString()}`:a).join(", "),s=e.typed?t?`typed by you ${e.typed.toLocaleString()}`:`Typed by you${e.providers.codex&&!e.providers.claude?" in Codex":""}`:"";return[n&&`Picked by ${n}`,s].filter(Boolean).join(" · ")}function one(e,t){const n=e.rows.filter(i=>i.uses>0).sort((i,l)=>l.uses-i.uses||l.lastAt-i.lastAt),s=[],a=(i,l,u,h)=>{i&&!s.some(f=>f.skill===i.name)&&s.push({kind:l,skill:i.name,title:u,detail:h(i)})},o=e.until-Math.max(e.since,e.countedSince);return a(n.filter(i=>i.failed>=2).sort((i,l)=>l.failed-i.failed)[0],"failing","failed to load",i=>`${i.failed.toLocaleString()} of ${bt(i.uses,"use")} failed.`),n.length>=2&&n[0].uses>=3&&n[0].uses>=e.total*.2&&a(n[0],"top","is your go-to",i=>`${i.uses.toLocaleString()} of ${e.total.toLocaleString()} uses (${ki(i.uses,e.total)}), in ${bt(i.sessions,"session")}.`),g5(e,t)&&a(n.filter(i=>i.typed>=3&&!i.agent&&!i.detected).sort((i,l)=>l.typed-i.typed)[0],"typed","is always started by you",i=>`Typed ${bt(i.typed,"time")}, never picked by ${p5(i)==="Codex"?"Codex":"Claude"} on its own. If it should be, its description needs the words you use.`),o>=21*af&&a(n.filter(i=>i.uses>=3&&e.until-i.lastAt>=7*af).sort((i,l)=>l.uses-i.uses)[0],"quiet","has gone quiet",i=>`${bt(i.uses,"use")}, none since ${aa(i.lastAt)}.`),o>=14*af&&a(n.filter(i=>e.until-i.firstAt<7*af).sort((i,l)=>l.uses-i.uses)[0],"new","is new this week",i=>`First used ${aa(i.firstAt)}, ${bt(i.uses,"use")} so far.`),s.slice(0,3)}const ine={all:"your agents",claude:"Claude",codex:"Codex"};function lne(e,t,n){const s=e.rows.filter(a=>a.uses>0).length;return{lead:`In the last ${nd[n]??`${n} days`}, ${ine[t]} used`,skills:bt(s,"skill"),uses:e.total===1?"once":`${e.total.toLocaleString()} times`,failed:e.failed,repeats:e.repeats}}const cne=e=>e.countedSince>e.since;function une(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."}const dl=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString(void 0,{timeZone:"UTC",month:"short",day:"numeric"});function dne({row:e,details:t,loading:n,pending:s=!1,charted:a=!0,error:o,onClose:i,sessionLabel:l,onOpenSession:u}){var _;const{namespace:h,short:f}=Jl(e.name),p=Date.now(),{claude:m,codex:w}=e.providers,v=e.agent+e.detected,j=e.agent&&e.detected?"an agent":e.detected?"Codex":"Claude",b=mm(e.lastAt,p).replace(/^(Today|Yesterday)/,M=>M.toLowerCase()),N=((_=t==null?void 0:t.history)==null?void 0:_.days.filter(M=>M.status!=="outside-history"))??[],x=(n||s)&&!t,S=M=>s?r.jsx($u,{}):M,C=[e.subagent?`${e.subagent.toLocaleString()} in a subagent`:"",e.detected&&e.agent?`${e.detected.toLocaleString()} picked by Codex`:""].filter(Boolean);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:[h&&r.jsx("span",{className:"sa-namespace",children:h}),f]}),r.jsx("p",{children:s?r.jsxs(r.Fragment,{children:[r.jsx($u,{width:"9em"}),r.jsx("br",{}),r.jsx($u,{width:"12em"})]}):r.jsxs(r.Fragment,{children:[m&&w?`${m.toLocaleString()} by Claude, ${w.toLocaleString()} by Codex`:`All by ${p5(e)}`,r.jsx("br",{}),"Last used ",b]})})]}),r.jsx("button",{type:"button",className:"glyph-btn","aria-label":"Close details",onClick:i,children:r.jsx(r5,{})})]}),r.jsxs("dl",{className:"ta-facts","aria-busy":s||void 0,children:[r.jsxs("div",{children:[r.jsx("dt",{children:"Uses"}),r.jsx("dd",{children:S(e.uses.toLocaleString())})]}),!s&&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:"Sessions"}),r.jsx("dd",{children:S(e.sessions.toLocaleString())})]}),r.jsxs("div",{"data-lane":"agent",children:[r.jsxs("dt",{children:["Picked by ",j]}),r.jsx("dd",{children:S(v.toLocaleString())})]}),r.jsxs("div",{"data-lane":"typed",children:[r.jsx("dt",{children:"Typed by you"}),r.jsx("dd",{children:S(e.typed.toLocaleString())})]})]}),!s&&(C.length>0||e.repeats>0)&&r.jsxs("p",{className:"ta-note",children:[C.join(" · "),e.repeats>0&&r.jsxs(r.Fragment,{children:[C.length>0&&" · ",bt(e.repeats,"repeated run")," not counted, such as ",r.jsx("code",{children:"/loop"})," ticks"]})]}),o&&r.jsx("p",{className:"ta-message",role:"alert",children:o}),N.length>=3?r.jsx(hne,{days:N},e.name):x&&a&&r.jsx(s5,{noun:"use"}),t&&(t.projects.length>0||t.projectless>0)&&r.jsx(fne,{details:t}),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"})}),x&&r.jsx(a5,{label:"Reading uses"}),t&&r.jsxs(r.Fragment,{children:[r.jsx(pne,{uses:t.recent,now:p,sessionLabel:l,onOpenSession:u}),!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(),"."]})]})]})]})}function hne({days:e}){const[t,n]=g.useState(null),s=e.reduce((i,l)=>l.uses>i.uses?l:i,e[0]),a=Math.max(1,s.uses),o=e.find(i=>i.date===t)??[...e].reverse().find(i=>i.uses>0)??e.at(-1);return r.jsxs("section",{className:"ta-history","aria-labelledby":"sa-days-title",children:[r.jsx("h4",{id:"sa-days-title",children:"Uses per day"}),r.jsxs("div",{className:"ta-history-bars sa-days-bars",role:"img",onPointerLeave:()=>n(null),style:{"--ta-days":e.length},"aria-label":`Uses per day from ${dl(e[0].date)} to ${dl(e.at(-1).date)}. The busiest day was ${dl(s.date)} with ${bt(s.uses,"use")}${s.uses?`: ${sne(s)}`:""}.`,children:[r.jsx("b",{className:"sa-days-max","aria-hidden":"true",children:bt(a,"use")}),e.map(i=>r.jsx("span",{"data-shown":i.date===o.date||void 0,onPointerEnter:()=>n(i.date),children:bd.filter(l=>i[l]>0).map(l=>r.jsx("i",{"data-lane":l,style:{"--ta-height":i[l]/a}},l))},i.date))]}),r.jsxs("div",{className:"ta-history-axis","aria-hidden":"true",children:[r.jsx("span",{children:dl(e[0].date)}),r.jsx("span",{children:dl(e.at(-1).date)})]}),r.jsxs("p",{className:"ta-note ta-history-day","aria-live":"polite",children:[dl(o.date)," · ",o.uses?r.jsxs(r.Fragment,{children:[bt(o.uses,"use"),": ",m5(o).map((i,l)=>r.jsxs(g.Fragment,{children:[l>0&&", ",r.jsxs("span",{className:"sa-day-part","data-lane":i.id,children:[r.jsx("i",{"aria-hidden":"true"}),i.text]})]},i.id))]}):"no uses"]})]})}function fne({details:e}){const t=[...e.projects.map(s=>({key:s.name,name:s.name,uses:s.uses,rest:!1})),...e.moreProjects.projects>0?[{key:"(more)",name:bt(e.moreProjects.projects,"more project"),uses:e.moreProjects.uses,rest:!0}]:[],...e.projectless>0?[{key:"(none)",name:"No folder recorded",uses:e.projectless,rest:!0}]:[]],n=Math.max(1,e.total);return 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.map(s=>r.jsxs("li",{"data-rest":s.rest||void 0,children:[r.jsx("span",{children:s.name}),r.jsx("span",{children:bt(s.uses,"use")}),r.jsx("b",{"aria-hidden":"true",style:{"--sa-share":Math.max(.02,s.uses/n)}})]},s.key))})]})}function pne({uses:e,now:t,sessionLabel:n,onOpenSession:s}){const a=[];for(const o of e){const i=t5(o.at,t),l=a.at(-1);(l==null?void 0:l.day)===i?l.uses.push(o):a.push({day:i,uses:[o]})}return r.jsx(r.Fragment,{children:a.map(o=>r.jsxs("div",{className:"sa-use-day",children:[r.jsx("p",{className:"sa-use-date",children:o.day}),r.jsx("ul",{className:"ta-calls sa-uses",children:o.uses.map(i=>{const l=(n==null?void 0:n(i.session))??null;return r.jsxs("li",{"data-lane":i.origin,"data-state":i.state==="failed"?"failed":void 0,children:[r.jsx("span",{className:"ta-call-when",children:B1(i.at)}),r.jsxs("span",{className:"sa-use-what",children:[r.jsxs("span",{className:"sa-use-who",children:[r.jsx("i",{"aria-hidden":"true"}),nne(i),i.subagent?" · subagent":"",i.state==="failed"?" · failed":""]}),i.project&&r.jsx("span",{className:"sa-use-project",children:i.project}),l&&s&&r.jsx("button",{type:"button",className:"sa-session",onClick:()=>s(i.session),title:"Show this session on the canvas",children:l})]})]},i.id)})})]},o.day))})}const mne=()=>r.jsx("svg",{className:"tt-caret",width:"10",height:"10",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:r.jsx("path",{d:"M2 3h10L8.5 7.5V11l-3 1.5v-5Z"})});function gne({shares:e,total:t,filter:n,onFilter:s}){const[a,o]=g.useState(null),i=e.find(u=>u.id===(a??n)&&u.uses>0)??null,l=u=>s(n===u?null:u);return r.jsxs("section",{className:"tt","aria-labelledby":"sa-origins-title","data-focus":i==null?void 0:i.id,children:[r.jsxs("div",{className:"tt-head",children:[r.jsx("h3",{id:"sa-origins-title",children:"Who starts your skills"}),r.jsx("span",{className:"tt-scope",children:bt(t,"use")})]}),r.jsxs("div",{className:"tt-card",onPointerLeave:()=>o(null),children:[r.jsxs("div",{className:"tt-donut",children:[r.jsx("svg",{viewBox:"0 0 120 120","aria-hidden":"true",children:h5(e.map(u=>({id:u.id,value:u.uses}))).map(u=>r.jsx("circle",{className:"tt-arc","data-lane":u.id,"data-on":(i==null?void 0:i.id)===u.id||void 0,cx:"60",cy:"60",r:"52",pathLength:100,style:{strokeDasharray:`${u.length} ${100-u.length}`,strokeDashoffset:-u.from},onPointerEnter:()=>o(u.id),onClick:()=>l(u.id)},u.id))}),r.jsx("div",{className:"tt-center","aria-hidden":"true",children:i?r.jsxs(r.Fragment,{children:[r.jsx("strong",{children:i.share}),r.jsx("span",{children:i.label})]}):r.jsxs(r.Fragment,{children:[r.jsx("strong",{children:t.toLocaleString()}),r.jsx("span",{children:t===1?"use":"uses"})]})})]}),r.jsx("ul",{className:"tt-lanes",children:e.map(u=>r.jsx("li",{children:r.jsxs("button",{type:"button",className:"tt-lane","data-lane":u.id,"aria-pressed":n===u.id,disabled:!u.uses,"aria-label":`${u.label}: ${u.uses?`${u.share}, ${bt(u.uses,"use")}`:"not counted"}. ${u.fact}. ${n===u.id?"Showing only these skills.":"Show only these skills."}`,onClick:()=>l(u.id),onPointerEnter:()=>o(u.id),onFocus:()=>o(u.id),onBlur:()=>o(null),children:[r.jsx("i",{"aria-hidden":"true"}),r.jsx("span",{className:"tt-lane-name",children:u.label}),r.jsx("strong",{children:u.uses?u.share:"—"}),r.jsx("span",{className:"tt-lane-time",children:u.uses.toLocaleString()}),u.uses>0&&r.jsx(mne,{}),r.jsx("span",{className:"tt-lane-fact",children:u.fact})]})},u.id))})]})]})}const jA=12,yne=()=>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"})]}),cu=e=>r.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.7",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:e}),wne={failing:cu(r.jsxs(r.Fragment,{children:[r.jsx("circle",{cx:"12",cy:"12",r:"9"}),r.jsx("path",{d:"m9 9 6 6m0-6-6 6"})]})),top:cu(r.jsx("path",{d:"M5 20V11M12 20V4M19 20v-6"})),typed:cu(r.jsxs(r.Fragment,{children:[r.jsx("rect",{x:"3",y:"5",width:"18",height:"14",rx:"2.5"}),r.jsx("path",{d:"m10.5 15 3-6"})]})),quiet:cu(r.jsx("path",{d:"M20 14.5A8 8 0 1 1 9.5 4a6.5 6.5 0 0 0 10.5 10.5Z"})),new:cu(r.jsx("path",{d:"M12 3v4M12 17v4M3 12h4M17 12h4M6 6l2.5 2.5M15.5 15.5 18 18M18 6l-2.5 2.5M8.5 15.5 6 18"}))};function xne(e){return`${e.name}: ${bt(e.uses,"use")}, last used ${mm(e.lastAt)}${e.failed?`, ${e.failed.toLocaleString()} failed`:""}`}function vne({filters:e,provider:t,period:n,setPeriod:s,refresh:a,onStatus:o,sessionLabel:i,onOpenSession:l}){var Ke;sn("skill-activity");const[u,h]=g.useState("uses"),[f,p]=g.useState(""),m=g.useRef(u);m.current=u;const w=g.useRef(f);w.current=f;const v=g.useRef(!1),j=g.useRef(null),[b,N]=g.useState(!1),[x,S]=g.useState(null),[C,_]=g.useState(null),[M,R]=g.useState(!1),P=g.useRef(null),[L,U]=g.useState(null),[B,A]=g.useState(null),[q,T]=g.useState(!0),[F,O]=g.useState(!1),[K,V]=g.useState(""),[H,D]=g.useState(""),I=g.useRef(null),W=g.useRef(!1),Z=g.useRef(null),z=g.useRef(null),X=ic("(min-width: 960px)"),[Y,J]=g.useState(l5),Q=ye=>{J(ye),c5(ye)},te=new URLSearchParams({view:"skills",provider:t,days:n}).toString(),le=g.useRef(o);le.current=o,g.useEffect(()=>{le.current({loading:q,detailLoading:F,capturedAt:(L==null?void 0:L.capturedAt)??null,hasData:!!L})},[q,F,L]),g.useEffect(()=>{const ye=new AbortController;let Fe=!0;const $e=window.setTimeout(()=>ye.abort(),65e3);return V(""),I.current!==te&&(U(null),A(null),N(!1)),W.current=!0,T(!0),(async()=>{try{const Re=await pp(te,ye.signal);if(Fe){I.current=te,U(Re);const rt=!v.current&&nw(Re.rows,m.current,w.current).find(He=>He.uses>0);rt?(v.current=!0,S(rt.name)):S(He=>{var se;return!He||Re.rows.some(ke=>ke.name===He)?He:((se=nw(Re.rows,m.current,w.current).find(ke=>ke.uses>0))==null?void 0:se.name)??null})}}catch(Re){Fe&&V(Re instanceof Error&&Re.name!=="AbortError"?Re.message:"Reading the history took too long. Try again, or keep less history in Settings.")}finally{window.clearTimeout($e),Fe&&(W.current=!1,T(!1))}})(),()=>{Fe=!1,ye.abort(),window.clearTimeout($e),W.current=!1}},[te,a]),g.useEffect(()=>{if(A(Re=>(Re==null?void 0:Re.name)===x&&I.current===te?Re:null),D(""),!x||!L||q||W.current){O(!1);return}let ye=!0;const Fe=new AbortController,$e=window.setTimeout(()=>Fe.abort(),65e3);return O(!0),(async()=>{var Re;try{const rt=await pp(`${te}&skill=${encodeURIComponent(x)}&history=1&timeZone=${encodeURIComponent(Intl.DateTimeFormat().resolvedOptions().timeZone)}`,Fe.signal);ye&&((Re=rt.details)!=null&&Re.row?A(rt.details):S(null))}catch{ye&&D("Could not read the uses of this skill. Close it and open it again to retry.")}finally{window.clearTimeout($e),ye&&O(!1)}})(),()=>{ye=!1,Fe.abort(),window.clearTimeout($e)}},[x,L,q,te]);const de=g.useMemo(()=>L?rne(L,t):[],[L,t]),oe=g.useMemo(()=>L?one(L,t):[],[L,t]),re=C&&de.some(ye=>ye.id===C&&ye.uses>0)?C:null,he=g.useMemo(()=>nw((L==null?void 0:L.rows)??[],u,f).filter(ye=>!re||ye[re]>0),[L,u,f,re]),pe=b||f?he:he.slice(0,jA),Le=he.reduce((ye,Fe)=>Math.max(ye,Fe.uses),0),ge=L==null?void 0:L.rows.find(ye=>ye.name===x);ge&&(j.current=ge);const ve=ge??(x&&!L&&((Ke=j.current)==null?void 0:Ke.name)===x?j.current:void 0),je=!!L&&L.failed>0,Ee=ye=>Fe=>{P.current=Fe.currentTarget,R(Fe.detail===0),S($e=>$e===ye?null:ye)},xe=()=>{const ye=x;S(null),requestAnimationFrame(()=>{var Re,rt;const Fe=P.current,$e=Array.from(((Re=Z.current)==null?void 0:Re.querySelectorAll(".ta-row[data-skill]"))??[]).find(He=>He.dataset.skill===ye);(rt=Fe!=null&&Fe.isConnected&&Fe.checkVisibility()?Fe:$e)==null||rt.focus({preventScroll:!0})})},Ie=L&&lne(L,t,n),De=L&&cne(L),We=L&&une(L,t);return r.jsxs("div",{className:"ta-workspace",ref:z,"data-inspecting":!!ve||void 0,style:{"--ta-details-w":`${Y}px`},children:[r.jsx("div",{className:"ta-body",children:r.jsxs("div",{className:"ta-report-content",children:[e,q&&!L&&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",{})]}),K&&r.jsx("div",{className:"ta-message",role:"alert",children:r.jsxs("p",{children:[L&&"Showing the last numbers. ",K]})}),L&&Ie&&(L.total===0&&L.repeats===0?r.jsxs("div",{className:"ta-empty",children:[r.jsxs("h3",{children:["No skills used in the last ",nd[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 ",aa(L.countedSince),". Sessions from before that are not imported. Use a skill and it shows up here."]}),We&&r.jsx("p",{className:"sa-typed-note",children:We}),n!=="90"&&!De&&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}),L.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:[bt(Ie.repeats,"repeated run"),", such as ",r.jsx("code",{children:"/loop"})," ticks, ",Ie.repeats===1?"is":"are"," left out."]})]}),De&&r.jsxs("p",{className:"ta-note sa-since",children:["Counting started ",aa(L.countedSince),", so the days before it are empty rather than unused."]}),We&&r.jsx("p",{className:"ta-note sa-typed-note",children:We}),(!L.storageOk||L.dropped>0||L.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.",!L.storageOk&&" Check free disk space."]}),(oe.length>0||L.total>0)&&r.jsxs("div",{className:"ta-glance","data-single":!(oe.length>0&&L.total>0)||void 0,children:[oe.length>0&&r.jsxs("section",{className:"ta-highlights","aria-labelledby":"sa-highlights-title",children:[r.jsx("h3",{id:"sa-highlights-title",children:"Worth a look"}),r.jsx("ul",{children:oe.map(ye=>r.jsx("li",{children:r.jsxs("button",{type:"button",className:"ta-highlight","data-kind":ye.kind,"data-skill":ye.skill,"aria-expanded":x===ye.skill,"aria-controls":x===ye.skill?"tool-operation-inspector":void 0,onClick:Ee(ye.skill),children:[r.jsx("span",{className:"ta-highlight-glyph",children:wne[ye.kind]}),r.jsxs("span",{className:"ta-highlight-text",children:[r.jsxs("span",{children:[r.jsx("code",{children:Jl(ye.skill).short})," ",ye.title]}),r.jsx("small",{children:ye.detail})]})]})},ye.kind))})]}),L.total>0&&r.jsx(gne,{shares:de,total:L.total,filter:re,onFilter:_})]}),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:re?`${he.length.toLocaleString()} of ${L.rows.length.toLocaleString()}`:L.rows.length.toLocaleString()})]}),r.jsxs("label",{className:"ta-search",children:[r.jsx(yne,{}),r.jsx("input",{type:"search","aria-label":"Find a skill",placeholder:"Find a skill",value:f,onChange:ye=>p(ye.target.value)})]})]}),r.jsx("div",{className:"uh-range ta-sorts sa-sorts",role:"group","aria-label":"Sort by",children:tne.map(ye=>r.jsx("button",{type:"button",className:"uh-range-btn","aria-pressed":u===ye.id,onClick:()=>h(ye.id),children:ye.label},ye.id))}),r.jsxs("div",{className:"ta-list-head sa-list-head","aria-hidden":"true","data-sort":u,"data-failures":je||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"}),je&&r.jsx("span",{"data-col":"failed",children:"Failed"})]}),r.jsx("ul",{className:"ta-list sa-list",ref:Z,"data-sort":u,"data-failures":je||void 0,children:pe.map(ye=>{const{namespace:Fe,short:$e}=Jl(ye.name);return r.jsx("li",{children:r.jsxs("button",{type:"button",className:"ta-row","data-skill":ye.name,"data-selected":x===ye.name||void 0,"aria-expanded":x===ye.name,"aria-controls":x===ye.name?"tool-operation-inspector":void 0,"aria-label":xne(ye),onClick:Ee(ye.name),children:[r.jsxs("span",{className:"ta-row-name",children:[r.jsxs("span",{className:"ta-op",children:[Fe&&r.jsx("span",{className:"sa-namespace",children:Fe}),$e]}),r.jsx("span",{className:"ta-desc",children:[ane(ye),bt(ye.sessions,"session"),ye.repeats>0&&bt(ye.repeats,"repeat")].filter(Boolean).join(" · ")}),r.jsx("span",{className:"ta-bar","aria-hidden":"true",style:{"--ta-share":Le&&u==="uses"?Math.max(.015,ye.uses/Le):0},children:bd.filter(Re=>ye[Re]>0).map(Re=>r.jsx("i",{"data-lane":Re,style:{flexGrow:ye[Re]}},Re))})]}),r.jsxs("span",{className:"ta-cell","data-col":"uses",children:[ye.uses.toLocaleString(),r.jsxs("span",{className:"ta-unit",children:[" ",ye.uses===1?"use":"uses"]})]}),r.jsxs("span",{className:"ta-cell","data-col":"recent",children:[r.jsx("span",{className:"ta-unit",children:"last "}),mm(ye.lastAt)]}),je&&r.jsx("span",{className:"ta-cell","data-col":"failed","data-bad":ye.failed>0||void 0,children:ye.failed?r.jsxs(r.Fragment,{children:[ye.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"})]})})]})},ye.name)})}),!he.length&&f.trim()&&r.jsxs("p",{className:"ta-note ta-no-match",children:["No skill matches “",f.trim(),"”",re?" among these":"","."]}),!f&&!b&&he.length>jA&&r.jsxs("button",{type:"button",className:"btn ta-more",onClick:()=>N(!0),children:["Show all ",he.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 ",aa(L.countedSince)," and kept with the tool history for ",L.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."]})]})]})]}))]})}),ve&&X&&r.jsx(u5,{width:Y,workspace:z,onCommit:Q}),ve&&r.jsx(n5,{keyboard:M,itemKey:ve.name,onClose:xe,children:r.jsx(dne,{row:(B==null?void 0:B.name)===x&&B.row?B.row:ve,details:(B==null?void 0:B.name)===x?B:null,loading:F,pending:!ge,charted:Number(n)>=7,error:H,onClose:xe,sessionLabel:i,onOpenSession:l})})]})}const NA=12,bne=[{id:"all",label:"All agents"},{id:"claude",label:"Claude"},{id:"codex",label:"Codex"}],SA={tools:"Tool activity",skills:"Skill activity"},kne={tools:"tool-activity",skills:"skill-activity"},jne=()=>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"})}),Nne=()=>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"})]}),Sne={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 Cne(e){const t=e.failed?`${e.failed.toLocaleString()} failed (${pm(e)})`:"none failed",n=e.totalMs===null?"not timed":`${vt(e.totalMs)} in total, usually ${vt(e.medianMs)}`;return`${ao(e.operation)}${Zl(e.operation)?`, ${Zl(e.operation)}`:""}: ${bt(e.calls,"call")}, ${n}, ${t}`}function _ne({view:e="tools",onClose:t,sessionLabel:n,onOpenSession:s}){var be;const[a,o]=g.useState(e),[i,l]=g.useState("all"),[u,h]=g.useState("7"),[f,p]=g.useState(0),[m,w]=g.useState({loading:!0,detailLoading:!1,capturedAt:null,hasData:!1}),[v,j]=g.useState("calls"),[b,N]=g.useState(""),x=g.useRef(v);x.current=v;const S=g.useRef(b);S.current=b;const[C,_]=g.useState(!1),[M,R]=g.useState(null),P=g.useRef(!1),L=g.useRef(null),[U,B]=g.useState(!1),A=g.useRef(M);A.current=M;const q=g.useRef(null),[T,F]=g.useState(null),[O,K]=g.useState(null),[V,H]=g.useState("recent"),[D,I]=g.useState(!0),[W,Z]=g.useState(!1),[z,X]=g.useState(""),[Y,J]=g.useState(""),[Q,te]=g.useState(0),le=g.useRef(!1),de=g.useRef(null),oe=g.useRef(null),re=g.useRef(null),he=ic("(min-width: 960px)"),[pe,Le]=g.useState(l5),ge=fe=>{Le(fe),c5(fe)},[ve]=g.useState(()=>document.activeElement instanceof HTMLElement?document.activeElement:null),je=()=>{t(),requestAnimationFrame(()=>{var Ve;const fe=ve,_e=Array.from(document.querySelectorAll(`[data-rail-item="${kne[e]}"], [data-rail-item="more"]`)).find(ot=>ot.checkVisibility());(Ve=fe&&fe!==document.body&&fe.isConnected&&fe.checkVisibility()?fe:_e)==null||Ve.focus({preventScroll:!0})})},Ee=gt(je,{focusRef:oe}),xe=yt(je),Ie=new URLSearchParams({provider:i,days:u,timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone}).toString();g.useEffect(()=>{if(a!=="tools")return;const fe=new AbortController;let _e=!0;const Ve=window.setTimeout(()=>fe.abort(),65e3);return X(""),de.current!==Ie&&(F(null),K(null),_(!1)),le.current=!0,I(!0),(async()=>{var ot;try{const tt=await pp(Ie,fe.signal);if(_e){de.current=Ie,F(tt);const wt=!P.current&&tw(tt.rows,x.current,S.current)[0];wt?(P.current=!0,R(wt.operation)):A.current&&!tt.rows.some($t=>$t.operation===A.current)&&R(((ot=tw(tt.rows,x.current,S.current)[0])==null?void 0:ot.operation)??null)}}catch(tt){_e&&X(tt instanceof Error&&tt.name!=="AbortError"?tt.message:"Reading the history took too long. Try again, or keep less history in Settings.")}finally{window.clearTimeout(Ve),_e&&(le.current=!1,I(!1))}})(),()=>{_e=!1,fe.abort(),window.clearTimeout(Ve),le.current=!1}},[Ie,Q,a]),g.useEffect(()=>{if(K(ot=>(ot==null?void 0:ot.operation)===M&&de.current===Ie?ot:null),J(""),!M||!T||D||le.current||a!=="tools"){Z(!1);return}let fe=!0;const _e=new AbortController,Ve=window.setTimeout(()=>_e.abort(),65e3);return Z(!0),(async()=>{var ot;try{const tt=await pp(`${Ie}&operation=${encodeURIComponent(M)}&history=1`,_e.signal);fe&&(((ot=tt.details)==null?void 0:ot.measurements)===null?R(null):K(tt.details))}catch{fe&&J("Could not read the calls for this tool. Close it and open it again to retry.")}finally{window.clearTimeout(Ve),fe&&Z(!1)}})(),()=>{fe=!1,_e.abort(),window.clearTimeout(Ve)}},[M,T,D,Ie,a]);const De=g.useMemo(()=>tw((T==null?void 0:T.rows)??[],v,b),[T,v,b]),We=g.useMemo(()=>T?Tte(T.rows,T.totalMs):[],[T]),Ke=C||b?De:De.slice(0,NA),ye=De.length?mp(De[0],v)??0:0,Fe=T==null?void 0:T.rows.find(fe=>fe.operation===M);Fe&&(L.current=Fe);const $e=Fe??(M&&!T&&((be=L.current)==null?void 0:be.operation)===M?L.current:void 0),Re=fe=>_e=>{q.current=_e.currentTarget,B(_e.detail===0),H("recent"),R(Ve=>Ve===fe?null:fe)},rt=()=>{const fe=M;R(null),requestAnimationFrame(()=>{var ot,tt;const _e=q.current,Ve=Array.from(((ot=Ee.current)==null?void 0:ot.querySelectorAll(".ta-row[data-operation]"))??[]).find(wt=>wt.dataset.operation===fe);(tt=_e!=null&&_e.isConnected&&_e.checkVisibility()?_e:Ve??oe.current)==null||tt.focus({preventScroll:!0})})},He=()=>{if(a==="skills"){!m.loading&&!m.detailLoading&&p(fe=>fe+1);return}le.current||W||(le.current=!0,te(fe=>fe+1))},se=T&&Rte(T,i,u),ke=a==="skills"?m.loading:D,Ae=a==="skills"?m.hasData?m.capturedAt:null:(T==null?void 0:T.capturedAt)??null,Oe=r.jsxs("div",{className:"ta-filters",children:[r.jsx("div",{className:"uh-range",role:"group","aria-label":"Period",children:Object.entries(nd).map(([fe,_e])=>r.jsx("button",{type:"button",className:"uh-range-btn","aria-pressed":u===fe,onClick:()=>h(fe),children:_e},fe))}),r.jsx("div",{className:"uh-range",role:"group","aria-label":"Agent",children:bne.map(fe=>r.jsx("button",{type:"button",className:"uh-range-btn","aria-pressed":i===fe.id,onClick:()=>l(fe.id),children:fe.label},fe.id))})]});return kt.createPortal(r.jsx("div",{className:"modal-backdrop",role:"presentation",...xe,children:r.jsxs("div",{className:"modal ta-report",ref:Ee,role:"dialog","aria-modal":"true","aria-labelledby":"tool-audit-title","data-view":a,children:[r.jsxs("header",{className:"modal-head ta-report-header",children:[r.jsx("h2",{id:"tool-audit-title",children:SA[a]}),r.jsxs("div",{className:"ta-actions",children:[r.jsx("span",{className:"ta-freshness",role:"status",children:ke?Ae!==null?"Updating…":"Reading history…":Ae!==null?`Updated ${new Date(Ae).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":ke||void 0,"aria-busy":a==="skills"?m.loading||m.detailLoading:D||W,onClick:He,children:r.jsx(jne,{})}),r.jsx("button",{type:"button",ref:oe,className:"glyph-btn",onClick:je,"aria-label":`Close ${SA[a].toLowerCase()}`,title:"Close (Esc)",children:"×"})]})]}),r.jsx("div",{className:"ta-view-panel",children:a==="skills"?r.jsx(vne,{filters:Oe,provider:i,period:u,setPeriod:h,refresh:f,onStatus:w,sessionLabel:n,onOpenSession:s}):r.jsxs("div",{className:"ta-workspace",ref:re,"data-inspecting":!!$e||void 0,style:{"--ta-details-w":`${pe}px`},children:[r.jsx("div",{className:"ta-body",children:r.jsxs("div",{className:"ta-report-content",children:[Oe,D&&!T&&r.jsxs("div",{className:"ta-loading",role:"status","aria-label":"Reading tool history",children:[r.jsx("i",{}),r.jsx("i",{}),r.jsx("i",{}),r.jsx("i",{}),r.jsx("i",{})]}),z&&r.jsxs("div",{className:"ta-message",role:"alert",children:[r.jsxs("p",{children:[T&&"Showing the last numbers. ",z]}),r.jsx("button",{type:"button",className:"btn",onClick:He,children:"Try again"})]}),T&&se&&(T.total===0?r.jsxs("div",{className:"ta-empty",children:[r.jsxs("h3",{children:["No tool calls in the last ",nd[u]]}),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 ",aa(T.startedAt),". Run a session and the calls show up here."]}),u!=="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:[se.lead," ",r.jsx("strong",{children:se.calls}),se.time&&r.jsxs(r.Fragment,{children:[" and spent ",r.jsx("strong",{children:se.time})," running them"]}),"."," ",se.failed?r.jsxs(r.Fragment,{children:[r.jsxs("strong",{className:"ta-bad",children:[se.failed.toLocaleString()," failed"]})," (",se.failedShare,")."]}):"None failed."]}),(!T.storageOk||T.dropped>0||T.corrupt>0)&&r.jsxs("p",{className:"ta-warning",role:"status",children:["Some calls could not be saved or read, so these numbers may be a little low.",!T.storageOk&&" Check free disk space."]}),(We.length>0||T.split)&&r.jsxs("div",{className:"ta-glance","data-single":!(We.length>0&&T.split)||void 0,children:[We.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:We.map(fe=>r.jsx("li",{children:r.jsxs("button",{type:"button",className:"ta-highlight","data-kind":fe.kind,"data-operation":fe.operation,"aria-expanded":M===fe.operation,"aria-controls":M===fe.operation?"tool-operation-inspector":void 0,onClick:Re(fe.operation),children:[r.jsx("span",{className:"ta-highlight-glyph",children:Sne[fe.kind]}),r.jsxs("span",{className:"ta-highlight-text",children:[r.jsxs("span",{children:[r.jsx("code",{children:ao(fe.operation)})," ",fe.title]}),r.jsx("small",{children:fe.detail})]})]})},fe.kind))})]}),T.split&&r.jsx(Jte,{split:T.split,since:T.since,turnsSince:T.turnsSince,selected:M,onPick:(fe,_e)=>Re(fe)(_e)})]}),r.jsxs("section",{className:"ta-tools","aria-labelledby":"ta-tools-title",children:[r.jsxs("div",{className:"ta-tools-head",children:[r.jsxs("h3",{id:"ta-tools-title",children:["Tools and commands ",r.jsx("span",{className:"ta-count",children:T.rows.length.toLocaleString()})]}),r.jsxs("label",{className:"ta-search",children:[r.jsx(Nne,{}),r.jsx("input",{type:"search","aria-label":"Find a tool or command",placeholder:"Find a tool or command",value:b,onChange:fe=>N(fe.target.value)})]})]}),r.jsx("div",{className:"uh-range ta-sorts",role:"group","aria-label":"Sort by",children:_te.map(fe=>r.jsx("button",{type:"button",className:"uh-range-btn","aria-pressed":v===fe.id,onClick:()=>j(fe.id),children:fe.label},fe.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:Ke.map(fe=>{const _e=mp(fe,v),Ve=Zl(fe.operation);return r.jsx("li",{children:r.jsxs("button",{type:"button",className:"ta-row","data-operation":fe.operation,"data-selected":M===fe.operation||void 0,"aria-expanded":M===fe.operation,"aria-controls":M===fe.operation?"tool-operation-inspector":void 0,"aria-label":Cne(fe),onClick:Re(fe.operation),children:[r.jsxs("span",{className:"ta-row-name",children:[r.jsx("span",{className:"ta-op",children:ao(fe.operation)}),Ve&&r.jsx("span",{className:"ta-desc",children:Ve}),r.jsx("span",{className:"ta-bar","aria-hidden":"true",style:{"--ta-share":ye&&_e?Math.max(.015,_e/ye):0}})]}),r.jsxs("span",{className:"ta-cell","data-col":"calls",children:[fe.calls.toLocaleString(),r.jsxs("span",{className:"ta-unit",children:[" ",fe.calls===1?"call":"calls"]})]}),r.jsxs("span",{className:"ta-cell","data-col":"time",children:[vt(fe.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 "}),vt(fe.medianMs)]}),r.jsx("span",{className:"ta-cell","data-col":"failed","data-bad":fe.failed>0||void 0,children:fe.failed?r.jsxs(r.Fragment,{children:[fe.failed.toLocaleString(),r.jsx("span",{className:"ta-unit",children:" failed"}),r.jsx("small",{children:pm(fe)})]}):r.jsxs("span",{className:"ta-zero",children:["0",r.jsx("span",{className:"ta-unit",children:" failed"})]})})]})},fe.operation)})}),!De.length&&r.jsxs("p",{className:"ta-note ta-no-match",children:["No tool or command matches “",b.trim(),"”."]}),!b&&!C&&De.length>NA&&r.jsxs("button",{type:"button",className:"btn ta-more",onClick:()=>_(!0),children:["Show all ",De.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.jsxs("li",{children:["Where the time went follows each Claude Code turn by the clock, from your prompt until Claude stops: this machine while a tool runs or its hooks start it, you while Claude waits for your approval or answer, and Claude for the rest. Calls that ran together count once, and a pipeline’s time goes to the command feeding it, not to the ",r.jsx("code",{children:"tail"})," reading its output."]}),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 ",aa(T.startedAt)," and kept for ",T.retentionDays," days. Commands are grouped by name; their arguments and output are never saved. Change this in Settings."]})]})]})]}))]})}),$e&&he&&r.jsx(u5,{width:pe,workspace:re,onCommit:ge}),$e&&r.jsx(n5,{keyboard:U,itemKey:$e.operation,onClose:rt,children:r.jsx(Fte,{row:(O==null?void 0:O.operation)===M&&O.measurements?O.measurements:$e,details:(O==null?void 0:O.operation)===M?O:null,loading:W,pending:!Fe,charted:Number(u)>=7,error:Y,kind:V,setKind:H,onClose:rt,onShowSkills:$e.operation==="Skill"?()=>{R(null),o("skills")}:void 0})})]})})]})}),document.body)}const W1={cost:0,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0,unpricedTokens:0,sessions:0};function Ene(e){if(!e.synthetic)return!1;const t=e.usage;return t.inputTokens+t.outputTokens+t.cacheReadTokens+t.cacheCreateTokens<=0}function H1(e,t){const n=new Map;for(const s of e){if(s.kind!=="root"||!s.sessionId||Ene(s))continue;const a=qn(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:zl(s,t)})}return n}function Tne(e,t){if(!e)return W1;const n={...W1};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 z1(e,t=new Date){return new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate()-(e-1))).toISOString().slice(0,10).replace(/-/g,"")}const gm=[{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 Ane(e,t,n=gm.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 Rne(e,t=new Date){return e==="today"?z1(1,t):e==="month"?z1(t.getDate(),t):"20200101"}const jn=e=>typeof e=="number"&&Number.isFinite(e)?e:0,If=e=>typeof e=="string"?e:"";function qN(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=If(o==null?void 0:o.modelName);if(!i)continue;let l=n.get(i);l||(l={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,l)),l.cost+=jn(o==null?void 0:o.cost),typeof(o==null?void 0:o.missingPricing)=="boolean"&&(l.missingPricing=l.missingPricing===!0||o.missingPricing),typeof(o==null?void 0:o.storedCost)=="number"&&Number.isFinite(o.storedCost)&&o.storedCost>=0&&(l.storedCost=(l.storedCost??0)+Math.min(o.storedCost,Math.max(0,jn(o.cost)))),l.inputTokens+=jn(o==null?void 0:o.inputTokens),l.outputTokens+=jn(o==null?void 0:o.outputTokens),l.cacheReadTokens+=jn(o==null?void 0:o.cacheReadTokens),l.cacheCreateTokens+=jn(o==null?void 0:o.cacheCreationTokens)}}return[...n.values()].sort((s,a)=>a.cost-s.cost||a.tokens-s.tokens)}const Mne=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function $ne(e){var t;return((t=Mne.exec(e))==null?void 0:t[0])??e}function Lne(e,t=new Map){const n=Array.isArray(e==null?void 0:e.sessions)?e.sessions:[],s=new Set(qN(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=If(o==null?void 0:o.period);if(!i)continue;const l=$ne(i),u=o==null?void 0:o.metadata,h=typeof(u==null?void 0:u.lastActivity)=="string"?Date.parse(u.lastActivity):NaN,f=Array.isArray(o==null?void 0:o.modelsUsed)?o.modelsUsed.map(If).filter(Boolean):[];a.push({sessionId:l,label:t.get(l)??null,agent:If(o==null?void 0:o.agent)||"claude",cost:jn(o==null?void 0:o.totalCost),priced:f.length>0&&f.every(p=>s.has(p)),tokens:jn(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 Ine(e,t=UN(e).cost){const s=(Array.isArray(e==null?void 0:e.sessions)?e.sessions:[]).reduce((o,i)=>o+jn(i==null?void 0:i.totalCost),0),a=Math.max(.01,t*.01);return{sum:s,total:t,over:s>t+a}}function One(e,t,n){const s=`Sessions with activity ${e}, and what ccusage puts against each one.`;return t.over?`${s}
|
|
97
|
+
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 UN(e){const t=e==null?void 0:e.totals;if(t&&typeof t=="object"){const u=jn(t.cacheReadTokens),h=jn(t.cacheCreationTokens),f=jn(t.inputTokens),p=jn(t.outputTokens);return{cost:jn(t.totalCost),inputTokens:f,outputTokens:p,cacheReadTokens:u,cacheCreateTokens:h,tokens:jn(t.totalTokens)||f+p+u+h}}const n=qN(e),s=u=>n.reduce((h,f)=>h+u(f),0),a=s(u=>u.inputTokens),o=s(u=>u.outputTokens),i=s(u=>u.cacheReadTokens),l=s(u=>u.cacheCreateTokens);return{cost:s(u=>u.cost),inputTokens:a,outputTokens:o,cacheReadTokens:i,cacheCreateTokens:l,tokens:a+o+i+l}}function Pne(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 y5(e,t){var n;return((n=gm.find(s=>s.key===(e??t)))==null?void 0:n.noun)??"today"}function Dne(e,t,n){const s=e!=null,a=UN(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 w5="agent-dag.usagePeriod";function Fne(){const e=nt(w5);return gm.some(t=>t.key===e)?e:"today"}function Bne(e){st(w5,e)}const x5="agent-dag.usageSessionsOpen";function qne(){return nt(x5)==="1"}function Une(e){st(x5,e?"1":"0")}function WN({cost:e,size:t="md"}){const n=e.total;if(n<=0)return null;const s=(o,i,l)=>{if(o<=0)return null;const u=o/n*100;return r.jsx("span",{className:`cb-seg ${i}`,style:{width:`${u}%`},title:`${l}: ${ct(o)} (${u.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 of="https://ccdeck.dev/guides",Wne={localNetwork:{href:`${of}/local-network/#film`,subject:"Local network"},claudeAccounts:{href:`${of}/claude-accounts/#film`,subject:"Claude accounts"},usage:{href:`${of}/cost-and-quota/#film`,subject:"cost and quota"},tour:{href:`${of}/first-run/#film`,subject:"first run"}};function sd({film:e,action:t=!1}){const{href:n,subject:s}=Wne[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 Pt="ccdeck",Hne="/brand/ccdeck-mark-gradient-small-optical.svg",zne="/brand/ccdeck-mark-mono-dark-small-optical.svg",Vne={month:"short",day:"numeric",hour:"numeric",minute:"2-digit",hour12:!0};function v5(e,t){const n=t.nextExpiryAt!=null?` · ${`expires ${new Date(t.nextExpiryAt).toLocaleString("en-US",Vne).replace(/\s+(AM|PM)/,(s,a)=>a.toLowerCase())}`.replace(/\s/g," ")}`:"";return`${t.availableCount} ${e}${t.availableCount!==1?"s":""} available${n}`}const Gne=12*36e5,Kne=new Set(["seven_day","weekly"]);function Yne(e,t=4){return e.filter(n=>Kne.has(n.id)&&n.ended==="reset"&&n.resetAt*1e3-n.t<=Gne).sort((n,s)=>s.resetAt-n.resetAt).slice(0,t)}function Xne(e){if(!e.length)return null;const t=Math.round(e.reduce((n,s)=>n+s.pct,0)/e.length);return`${e.length===1?"Last week":`Last ${e.length} weeks`} ended ${t}% used, ${100-t}% unused`}const Zne=e=>new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric"}),Jne=e=>e<36e5?`${Math.max(1,Math.round(e/6e4))} min`:`${Math.round(e/36e5)} h`;function Qne(e){return[...e.map(t=>`${Zne(t.resetAt*1e3)}: ${Math.round(t.pct)}% used, read ${Jne(t.resetAt*1e3-t.t)} before the reset`),"An average of the weekly window's last reading before each reset"].join(`
|
|
98
|
+
`)}const ese=15*6e4;function CA(e,t){const[n,s]=g.useState([]);return g.useEffect(()=>{if(s([]),!t)return;let a=!0;const o=async()=>{try{const l=await fetch(`/api/quota/closes?provider=${e}&account=${encodeURIComponent(t)}`,{signal:AbortSignal.timeout(12e3)}),u=await l.json();a&&l.ok&&u.ok&&u.account===t&&Array.isArray(u.closed)&&s(Yne(u.closed))}catch{}};o();const i=window.setInterval(()=>{document.visibilityState==="visible"&&o()},ese);return()=>{a=!1,window.clearInterval(i)}},[e,t]),n}function b5(){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 rd(){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 tse({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(rd,{})}),r.jsxs("span",{className:"vis-hidden",children:[", on ",t.host,", opens in a new tab"]})]},t.provider))})}function k5({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(rd,{})}),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 nse(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 l=Math.min(100,i/n*100),u=e-l;if(a||e>=100)return{label:"used up",color:"var(--warn)",expectedPct:l,isDeficit:!0};if(Math.abs(u)<3)return{label:"on pace",color:"var(--ok)",expectedPct:l,isDeficit:!1};if(u>0){const h=100-e,f=i>0?e/i:0,p=f>0?h/f:1/0,m={label:`${Math.round(u)}% over pace`,color:"var(--warn)",expectedPct:l,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(-u)}% under pace`,color:"var(--ok)",expectedPct:l,isDeficit:!1}}function Xa({pct:e,label:t,reset:n,resetAt:s,windowSec:a,limitReached:o,nowSec:i}){const l=!!s&&s<=i,u=e!=null&&!l,h=u?Math.min(100,Math.max(0,e)):0,p=o||h>=90?"var(--err)":h>=70?"var(--warn)":"var(--accent)",m=h<1,w=l?"reset":u?m?"< 1%":`${Math.round(h)}%`:"no reading",v=m?2:h,j=s&&!l?yd(s,i):null,b=u&&s&&a?nse(h,s,a,i,o):null,[N,x]=g.useState(!1),S=g.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&&!l&&r.jsx("span",{className:"qb-limit-badge",title:"Rate limit reached",children:"⛔"})]}),r.jsx("span",{className:"qb-pct",style:{color:u?p:"var(--muted)"},children:w})]}),r.jsxs("div",{className:"qb-track",children:[u&&r.jsx("div",{className:"qb-fill",style:{transform:`scaleX(${v/100})`,background:p,opacity:m?.4:1}}),b&&r.jsx("div",{className:"qb-pace-rail",style:{transform:`translateX(${b.expectedPct}%)`},children:r.jsx("div",{"aria-hidden":!0,className:"qb-pace-marker",style:{background:b.isDeficit?"var(--err)":"var(--ok)"},title:`To last until reset, stay near ${Math.round(b.expectedPct)}% by now`})})]}),r.jsxs("div",{className:"qb-reset-row",children:[l?r.jsx("span",{className:"qb-reset",children:"waiting for a new reading"}):j?r.jsxs("span",{className:"qb-reset",children:["resets in ",j]}):n?r.jsxs("span",{className:"qb-reset",children:["resets ",n]}):null,b&&r.jsxs("button",{type:"button",className:"qb-pace",style:{color:b.color},"aria-expanded":N,"aria-controls":N?S:void 0,onClick:()=>x(C=>!C),children:[r.jsx("i",{className:"qb-pace-key","aria-hidden":!0,style:{background:b.isDeficit?"var(--err)":"var(--ok)"}}),b.runsOutIn?`runs out in ${b.runsOutIn}`:b.label]})]}),N&&b&&r.jsxs("div",{id:S,className:"qb-why",children:["To last until reset, stay near ",Math.round(b.expectedPct),"% by now."]})]})}function j5(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 sse(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 rse(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 ase(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 N5({weeks:e=[]}){const t=Xne(e);return t?r.jsx("div",{className:"up-quota-sub",title:Qne(e),children:t}):null}function ose({quota:e,quotaLoading:t,nowSec:n,incident:s,weekEnds:a}){const o=j5(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",(e==null?void 0:e.ok)&&e.planLabel&&r.jsx("span",{className:"up-plan-badge",children:e.planLabel}),o&&!t&&r.jsxs("span",{className:"up-section-age",title:sse(e==null?void 0:e.source),children:[o,(e==null?void 0:e.stale)&&" · no newer reading"]})]}),r.jsx(k5,{incident:s}),e!=null&&e.ok?r.jsxs("div",{className:"up-quota-bars",children:[e.session5hPct!=null&&r.jsx(Xa,{label:"5-hour window",pct:e.session5hPct,reset:e.session5hReset,resetAt:e.session5hResetAt,windowSec:e.session5hWindowSec,nowSec:n}),r.jsx(Xa,{label:"7-day window",pct:e.week7dPct??null,reset:e.week7dReset,resetAt:e.week7dResetAt,windowSec:e.week7dWindowSec,nowSec:n}),r.jsx(N5,{weeks:a}),e.weekSonnetPct!=null&&r.jsx(Xa,{label:"Sonnet (7d)",pct:e.weekSonnetPct,nowSec:n}),e.weekOpusPct!=null&&r.jsx(Xa,{label:"Opus (7d)",pct:e.weekOpusPct,nowSec:n}),e.extraEnabled&&e.extraUsedCredits!=null&&e.extraMonthlyLimit?r.jsx(Xa,{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 — ${Pt} only reports them`,children:v5("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:rse(e.reason)})]}):r.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]})}function ise({codexQuota:e,codexLoading:t,nowSec:n,incident:s,weekEnds:a}){var i,l;const o=j5(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}),o&&!t&&r.jsx("span",{className:"up-section-age",title:"Fetched from the Codex usage endpoint",children:o})]}),r.jsx(k5,{incident:s}),e!=null&&e.ok?r.jsxs("div",{className:"up-quota-bars",children:[(i=e.windows)==null?void 0:i.map(u=>r.jsx(Xa,{label:u.label,pct:u.pct,reset:u.reset??void 0,resetAt:u.resetAt??void 0,windowSec:u.windowSec??void 0,limitReached:e.limitReached&&u.pct>=100,nowSec:n},u.id)),r.jsx(N5,{weeks:a}),(l=e.extraWindows)==null?void 0:l.map(u=>r.jsx(Xa,{label:u.label,pct:u.pct,reset:u.reset??void 0,resetAt:u.resetAt??void 0,windowSec:u.windowSec??void 0,nowSec:n},u.id)),e.creditLimit&&r.jsx(Xa,{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 — ${Pt} only reports them`,children:v5("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:ase(e.reason)})]}):r.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]})}function V1(e,t){return t&&e<=0?da:ct(e)+(t?"+":"")}const nje="Some models have no known price. Tokens are counted; their cost is missing from the total.";function _A(e,t){if(e==null)return null;const n=Math.min(Math.max(0,e),Math.max(0,t));return`Recorded in logs: ${ct(n)} · other reported cost: ${ct(Math.max(0,t-n))}. Both are included in the total; recorded costs are not a verified bill.`}function lse({fromRange:e,rangeModelRows:t,boardModelRows:n}){const s=t.filter(o=>o.storedCost!==void 0),a=e?_A(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,_A(o.storedCost,o.cost)].filter(Boolean).join(`
|
|
99
|
+
`),children:no(o.model)}),r.jsx("td",{className:"up-num",children:Ct(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:V1(o.cost,!0)}):r.jsx("td",{className:"up-num up-cost-val",children:V1(o.cost)})]},o.model)):n.map(o=>r.jsxs("tr",{children:[r.jsx("td",{className:"up-model-name",title:o.model===L1?"no model reported yet":o.model,children:o.model===L1?"unknown":no(o.model)}),r.jsx("td",{className:"up-num",children:Ct(o.inputTokens+o.outputTokens)}),o.priced?r.jsx("td",{className:"up-num up-cost-val",children:ct(o.cost.total)}):r.jsx("td",{className:"up-num up-unpriced",children:da})]},o.model))})]}),a&&r.jsx("p",{className:"uh-cost-note",children:a})]})}function cse({period:e,rangePending:t,setPeriod:n}){const s=g.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 l;const o=s.current.indexOf(a.target);if(o<0)return;const i=Ane(a.key,o);i!==null&&(a.preventDefault(),(l=s.current[i])==null||l.focus())},children:gm.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 ${y5(e,e)}…`:""})]})}function use(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 dse(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 EA({sessionId:e,agent:t,label:n,onOpen:s,children:a}){return s&&use(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 hse({fromRange:e,rangeSessionRows:t,boardSessionRows:n,boardStates:s,sessionsOpen:a,setSessionsOpen:o,periodNoun:i,sessionScale:l,onOpenSession:u,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:One(i,l,ct),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(EA,{sessionId:p.sessionId,agent:p.agent,label:p.label??lp(p.sessionId,8),onOpen:u,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:Vl(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}
|
|
100
|
+
${p.sessionId}`:p.sessionId,children:p.label??lp(p.sessionId,8)}),r.jsx("span",{className:"up-session-tokens",children:Ct(p.tokens)}),p.cost>0||p.priced?r.jsx("span",{className:"up-session-cost",title:p.models.join(", ")||void 0,children:ct(p.cost)}):r.jsx("span",{className:"up-session-cost up-unpriced",children:da})]},`${p.agent}:${p.sessionId}`)}),!e&&n.map(p=>r.jsxs(EA,{sessionId:p.sessionId,agent:(h==null?void 0:h.get(p.sessionId))??"claude",label:p.label,onOpen:u,children:[r.jsx("span",{className:`sl-dot state-${p.state}`,"aria-hidden":!0}),r.jsx("span",{className:"vis-hidden",children:Vl(p.state)}),r.jsx("span",{className:"up-session-label",children:p.label}),r.jsx("span",{className:"up-session-tokens",children:Ct(p.inputTokens+p.outputTokens)}),p.cost>0||p.priced?r.jsxs("span",{className:"up-session-cost",title:p.unpricedTokens>0?`${Ct(p.unpricedTokens)} tokens in this session are on an unpriced model, so this is a floor`:void 0,children:[ct(p.cost),p.unpricedTokens>0?"+":""]}):r.jsx("span",{className:"up-session-cost up-unpriced",children:da})]},p.sessionId))]})]})}function fse(e){return e.claude&&e.codex?"Claude Code and Codex":e.claude?"Claude Code":e.codex?"Codex":null}const pse={claude:"Claude Code",codex:"Codex",opencode:"OpenCode",openclaw:"OpenClaw",copilot:"GitHub Copilot",pi:"pi-agent",zcode:"ZCode"};function S5(e){const t=e.toLowerCase(),n=Zt(pse,t);return n!==void 0?n:t?t[0].toUpperCase()+t.slice(1):""}function mse(e){return e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function sje(e,t=[]){const n=t.length?mse(t.map(S5)):fse(e);return n?`via ccusage · local ${n} logs`:"via ccusage · local agent logs"}function gse(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 yse(){const[e,t]=g.useState(()=>typeof document<"u"&&document.hidden);return g.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 lf=e=>e.toLocaleString(),TA=e=>new Date(e).toLocaleString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"});function wse({session:e,onClose:t}){var b,N;const[n,s]=g.useState("auto"),[a,o]=g.useState(0),[i,l]=g.useState(null),u=g.useRef(a),h=g.useRef(null),f=gt(t,{focusRef:h}),p=yt(t),m=i!=null&&i.ok&&((b=i.detail)==null?void 0:b.speed)===n?i.detail:void 0;g.useEffect(()=>{const x=new AbortController;l(null);const S=new URLSearchParams({agent:e.agent,id:e.sessionId,speed:n});return a!==u.current&&S.set("refresh","1"),u.current=a,fetch(`/api/ccusage/session?${S}`,{signal:x.signal}).then(async C=>{const _=await C.json();x.signal.aborted||l(_)}).catch(()=>{x.signal.aborted||l({ok:!1})}),()=>x.abort()},[e.agent,e.sessionId,n,a]);const w=(m==null?void 0:m.models.filter(x=>x.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)"}]:[],j=v.reduce((x,S)=>x+S.n,0);return kt.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(x=>x+1),disabled:!i,"aria-label":"Refresh session usage",title:"Refresh session usage",children:r.jsx(b5,{})}),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:S5(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:x=>{l(null),s(x.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(yse,{}),i&&!i.ok&&r.jsxs("p",{className:"su-message",role:"status",title:i.error,children:[dse(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?ct(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:lf(m.totalTokens),children:Ct(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"})]}),j>0&&r.jsx("div",{className:"su-composition","aria-hidden":"true",children:v.filter(x=>x.n>0).map(x=>r.jsx("span",{style:{width:`${x.n/j*100}%`,background:x.color}},x.name))}),r.jsx("dl",{className:"su-tokens",children:v.map(({name:x,n:S,color:C})=>r.jsxs("div",{children:[r.jsxs("dt",{children:[r.jsx("span",{className:"su-key",style:{background:C},"aria-hidden":"true"}),x]}),r.jsxs("dd",{title:lf(S),children:[Ct(S),r.jsx("span",{className:"su-share",children:j>0?`${(S/j*100).toLocaleString(void 0,{maximumFractionDigits:1})}%`:"—"})]})]},x))}),m.reasoningOutputTokens>0&&r.jsxs("p",{className:"su-note su-reasoning",children:[Ct(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(x=>r.jsxs("tr",{children:[r.jsxs("th",{scope:"row",title:x.model,children:[no(x.model),x.missingPricing&&r.jsx("span",{className:"su-unpriced",children:" · not priced"})]}),r.jsx("td",{title:lf(x.totalTokens),children:Ct(x.totalTokens)})]},x.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:TA(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:TA(m.lastActivity)})})]}),m.entries!=null&&r.jsxs("div",{children:[r.jsx("dt",{children:"Usage records"}),r.jsx("dd",{children:lf(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 cf=e=>`${e.id}:${e.windowSec}:${e.resetAt}`;function xse(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 l=(o=a.at(-1))==null?void 0:o.at(-1);(!l||i.t-l.t>10*6e4||i.t<=l.t)&&a.push([]),a.at(-1).push({...i,x:n(i.t),y:s(i.pct)})}return a}function vse(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 HN({kind:e,title:t,note:n,delayed:s=!1}){const[a,o]=g.useState(()=>typeof document<"u"&&document.hidden);return g.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 Pl=e=>new Date(e).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}),AA=e=>new Date(e).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"});function bse({series:e}){const t=xse(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,l)=>`${l?"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:[Pl(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?Pl(n):AA(n)}),r.jsx("span",{children:e.windowSec>86400?Pl(s):AA(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 kse({providers:e,accounts:t,onClose:n,instant:s=!1}){const[a,o]=g.useState(e.claude?"claude":"codex"),[i,l]=g.useState(null),[u,h]=g.useState(!0),[f,p]=g.useState(!1),[m,w]=g.useState(""),[v,j]=g.useState(0),[b,N]=g.useState(Date.now),x=g.useRef(!1),S=g.useRef(null),C=gt(n,{focusRef:S}),_=yt(n),M=t[a];g.useEffect(()=>{let B=!1,A=null;l(null),p(!1);const q=async()=>{if(A)return;if(!M){x.current=!1,h(!1);return}const F=new AbortController;A=F,x.current=!0;const O=window.setTimeout(()=>F.abort(),12e3);h(!0);try{const K=await fetch(`/api/quota/history?provider=${a}&account=${encodeURIComponent(M)}`,{signal:F.signal}),V=await K.json();if(!K.ok||!V.ok||!Array.isArray(V.series))throw new Error("History unavailable");B||(l(V.account===M?V:{...V,series:[]}),p(!1))}catch{B||p(!0)}finally{window.clearTimeout(O),A=null,B||(x.current=!1,h(!1))}};q();const T=window.setInterval(()=>{N(Date.now()),document.visibilityState==="visible"&&q()},6e4);return()=>{B=!0,A==null||A.abort(),window.clearInterval(T)}},[a,M,v]);const R=((i==null?void 0:i.series)??[]).slice().sort((B,A)=>A.resetAt-B.resetAt||B.windowSec-A.windowSec),P=R.find(B=>cf(B)===m)??R.find(B=>B.resetAt*1e3>b&&B.windowSec<=6*3600)??R[0],L=P==null?void 0:P.points.at(-1),U=()=>{Sn(x.current)&&(x.current=!0,j(B=>B+1))};return kt.createPortal(r.jsx("div",{className:"modal-backdrop",role:"presentation",..._,children:r.jsxs("div",{className:"modal qh-modal","data-keyboard-interaction":s||void 0,ref:C,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",...Fn(u),onClick:U,children:u?"…":r.jsx(b5,{})}),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":u,children:[r.jsxs("div",{className:"qh-controls",children:[r.jsx("div",{className:"qh-providers",role:"group","aria-label":"Quota provider",children:["claude","codex"].filter(B=>e[B]).map(B=>r.jsx("button",{type:"button",className:"qh-provider","aria-pressed":a===B,onClick:()=>{o(B),w("")},children:B==="claude"?"Claude":"Codex"},B))}),R.length>0&&r.jsxs("label",{className:"qh-window",children:["Window",r.jsx("select",{"aria-label":"Quota window",value:P?cf(P):"",onChange:B=>w(B.target.value),children:R.map(B=>r.jsxs("option",{value:cf(B),children:[B.label," · ",Pl(B.resetAt*1e3)]},cf(B)))})]})]}),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&&L?r.jsxs("div",{className:"qh-result read-result",children:[r.jsxs("div",{className:"qh-summary",children:[r.jsxs("strong",{children:[Math.round(100-L.pct),"% remaining"]}),r.jsxs("span",{title:Pl(L.t),children:["Captured ",vse(L.t,b),P.resetAt*1e3<=b&&" · window ended"]})]}),r.jsx(bse,{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(B=>r.jsxs("tr",{children:[r.jsx("td",{children:Pl(B.t)}),r.jsxs("td",{children:[(100-B.pct).toLocaleString(void 0,{maximumFractionDigits:1}),"%"]})]},B.t))})]})]})]}):!f&&(u&&M?r.jsx(HN,{kind:"quota",title:"Reading quota history…",note:"Loading this account’s saved quota readings."}):r.jsx("p",{className:"qh-message",role:"status",children:M?"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 jse=6e4,Nse=2e4;function Sse(e){const[t,n]=g.useState(null),[s,a]=g.useState(!1),o=g.useRef(null),i=g.useRef(!1),l=async(h=!1)=>{if(!(h&&!Sn(i.current))){h&&(i.current=!0,a(!0));try{const p=await fetch(h?"/api/quota?refresh=1":"/api/quota",{signal:AbortSignal.timeout(Nse)});p.ok&&n(await p.json())}catch{}finally{h&&(i.current=!1,a(!1))}}};return g.useEffect(()=>{if(e)return l(!0),o.current=window.setInterval(()=>l(!1),jse),()=>{o.current!=null&&window.clearInterval(o.current)}},[e]),{quota:t,loading:s,refresh:()=>{e&&l(!0)}}}const Cse=6e4;function _se(e){const[t,n]=g.useState(null),[s,a]=g.useState(!1),o=g.useRef(null),i=g.useRef(!1),l=async(h=!1)=>{if(!(h&&!Sn(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 g.useEffect(()=>{if(e)return l(!0),o.current=window.setInterval(()=>l(!1),Cse),()=>{o.current!=null&&window.clearInterval(o.current)}},[e]),{data:t,loading:s,refresh:()=>{e&&l(!0)}}}const RA=6e4;function Ese(e,t,n){const[s,a]=g.useState(null),[o,i]=g.useState(!1),[l,u]=g.useState(0),h=g.useRef(0);g.useEffect(()=>{const p=()=>document.visibilityState==="visible",m=()=>{p()&&u(j=>j+1)},w=window.setInterval(m,RA),v=()=>{p()&&Date.now()-h.current>=RA&&u(j=>j+1)};return document.addEventListener("visibilitychange",v),()=>{window.clearInterval(w),document.removeEventListener("visibilitychange",v)}},[]);const f=g.useRef(t);return g.useEffect(()=>{let p=!0;const m=t!==f.current;f.current=t;const w=e,v=Rne(w);return i(!0),fetch(`/api/ccusage?since=${v}${m?"&refresh=1":""}`).then(j=>j.ok?j.json():null).then(j=>{!p||!(j!=null&&j.ok)||(h.current=Date.now(),a({period:w,data:j,baseline:n()}))}).catch(()=>{}).finally(()=>{p&&i(!1)}),()=>{p=!1}},[e,t,l]),{...Pne(s,e),loading:o}}const Tse=e=>1-Math.pow(1-e,5),C5=420;function Ase(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 Rse(e,t,n,s=C5){return n>=s?t:n<=0?e:e+(t-e)*Tse(n/s)}function _5(){return typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches}function MA(e,t,n,s={}){const a=s.now??(()=>performance.now()),o=s.raf??(w=>requestAnimationFrame(w)),i=s.cancel??(w=>cancelAnimationFrame(w)),l=s.reducedMotion??_5,u=s.hidden??(()=>typeof document=="object"&&document.hidden===!0);if(l()||u()||!Ase(e,t))return n(t),()=>{};const h=a();let f=0,p=!0;const m=()=>{if(!p)return;const w=a()-h;n(Rse(e,t,w)),w<C5&&(f=o(m))};return f=o(m),()=>{p=!1,f&&i(f)}}const Mse=typeof window>"u"?g.useEffect:g.useLayoutEffect;function Zo(e,{countIn:t=!1}={}){const[n,s]=g.useState(e),a=g.useRef(e),o=g.useRef(!0);return g.useEffect(()=>{a.current=n},[n]),Mse(()=>{!t||_5()||(a.current=0,s(0))},[]),g.useEffect(()=>{if(o.current){if(o.current=!1,t)return MA(0,e,l=>{a.current=l,s(l)});a.current=e,s(e);return}return MA(a.current,e,l=>{a.current=l,s(l)})},[e]),n}function E5(e,t,n){const s=Lse*Math.max(1,n/A5);let a=0;for(const[o,i]of t){const l=e.get(o);if(l===void 0)continue;const u=i.cost-l.cost;u>0&&u<=s&&(a+=u)}return a}const $A={samples:[],last:new Map,watched:0},T5=10*6e4,$se=6e4,A5=5e3,Lse=20;function Ise(e,t,n){const s=e.samples[e.samples.length-1];if(s&&t-s.t<A5)return e;const a=e.watched+E5(e.last,n,s?t-s.t:0),o=e.samples.filter(i=>t-i.t<=T5);return o.push({t,watched:a}),{samples:o,last:n,watched:a}}function Ose(e,t,n){const s=e.samples[0];if(!s)return null;const a=t-s.t;if(a<$se)return null;const o=e.samples[e.samples.length-1].t,i=e.watched+E5(e.last,n,t-o)-s.watched;return i>0?{spent:i,spanSec:a/1e3,spanMin:Math.min(T5/6e4,Math.ceil(a/6e4))}:null}function Pse(e,t,n){const s=g.useRef($A),a=g.useRef(null);return g.useMemo(()=>{const o=KJ(e.agents.values()),i=WJ(e.agents.values());a.current!==n&&(a.current=n,s.current=$A);const l=H1(e.agents.values(),t);n!=null&&(s.current=Ise(s.current,t,l));const u=n==null?null:Ose(s.current,t,l),h=u?{label:iN(u.spent,u.spanSec),spanMin:u.spanMin}:null;return{byModel:o,totalCost:i.cost,totalTokens:i,burnRate:h}},[e,e.revision,t,n])}const Dse=3e4;function zN(){const[e,t]=g.useState(()=>Math.floor(Date.now()/1e3));return g.useEffect(()=>{const n=window.setInterval(()=>t(Math.floor(Date.now()/1e3)),Dse);return()=>window.clearInterval(n)},[]),e}function LA(e){return(typeof e.cost=="number"?e.cost:e.cost.total)>0||e.inputTokens+e.outputTokens>0}function Fse(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 Bse(e){return e.claude&&e.codex?"Refresh Claude + Codex quota":e.codex?"Refresh Codex quota":"Refresh Claude quota"}function qse(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 Use(e){const t=new Map;for(const n of e)n.kind!=="root"||!n.sessionId||t.set(n.sessionId,n.state);return t}function Wse(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} ${gD(n.sessionId,s)}`}:n})}const R5=120,IA=24,Hse=4,M5={usage:"agent-dag.usagePanelPlace",machine:"agent-dag.machinePanelPlace"};function zse(e,t,n,s){const a=s-e-n;return e+n/2>s/2?{edge:"right",x:Math.round(a),y:Math.round(t)}:{edge:"left",x:Math.round(e),y:Math.round(t)}}function OA(e,t,n){return Math.max(t,Math.min(e,n))}function Vse(e,t){return Math.abs(e.left-t.left)<=IA&&Math.abs(e.top-t.top)<=IA}function Gse(e){if(!e)return null;try{const t=JSON.parse(e);if((t.edge==="left"||t.edge==="right")&&Number.isFinite(t.x)&&Number.isFinite(t.y))return{edge:t.edge,x:t.x,y:t.y}}catch{}return null}const Kse=8;function Yse(e,t){if(e.left>=t.left+t.width||t.left>=e.left+e.width)return null;const[n,s,a]=e.top<=t.top?[e,t,"a"]:[t,e,"b"],o=s.top-n.top-Kse;return o>=R5?{upper:a,cap:o}:null}function G1(){const e=document.querySelector(".usage-panel"),t=document.querySelector(".sysdetail");if(e==null||e.style.removeProperty("max-height"),t==null||t.style.removeProperty("max-height"),!e||!t||window.matchMedia(um).matches)return;const n=a=>({left:a.offsetLeft,top:a.offsetTop,width:a.offsetWidth}),s=Yse(n(e),n(t));s&&((s.upper==="a"?e:t).style.maxHeight=`${s.cap}px`)}let sw=0;function uf(){sw||(sw=requestAnimationFrame(()=>{sw=0,G1()}))}function Xse(e){var n;const t=((n=document.querySelector(".edge-rail-right"))==null?void 0:n.getBoundingClientRect().width)??0;return{w:window.innerWidth,h:window.innerHeight,side:t+8,top:e.top}}function $5(e){const t=ic(um),[n,s]=g.useState(()=>Gse(nt(e))),a=g.useRef(null),o=g.useRef(null),i=g.useRef(null);g.useEffect(()=>()=>{var C;return(C=i.current)==null?void 0:C.call(i)},[]);const l=C=>{C?st(e,JSON.stringify(C)):vs(e),s(C)},u=C=>{const _=a.current;_&&(C?(_.style.left=`${C.left}px`,_.style.top=`${C.top}px`,_.style.right="auto"):(_.style.removeProperty("left"),_.style.removeProperty("top"),_.style.removeProperty("right")),G1())},h=()=>{var _;const C=a.current;C==null||C.removeAttribute("data-moving"),(_=i.current)==null||_.call(i),i.current=null,o.current=null},f=C=>{const _=C.getAttribute("data-place");if(!_)return C.getBoundingClientRect();C.removeAttribute("data-place");const M=C.getBoundingClientRect();return C.setAttribute("data-place",_),M},p=C=>C instanceof Element&&C.closest("button, a, input, select, textarea, [role='button']")!==null,m=C=>{const _=a.current;if(!_||C.button!==0||p(C.target))return;C.preventDefault(),C.currentTarget.setPointerCapture(C.pointerId);const M=_.getBoundingClientRect();o.current={id:C.pointerId,x:C.clientX,y:C.clientY,moved:!1,start:M,home:M,room:null,at:{left:M.left,top:M.top}}},w=C=>{const _=o.current,M=a.current;if(!_||!M||C.pointerId!==_.id)return;const R=C.clientX-_.x,P=C.clientY-_.y;if(!_.moved){if(Math.hypot(R,P)<Hse)return;_.moved=!0,_.home=f(M),_.room=Xse(_.home),document.querySelectorAll("[data-front]").forEach(A=>A.removeAttribute("data-front")),M.setAttribute("data-front",""),M.setAttribute("data-moving","");const B=A=>{A.key==="Escape"&&(A.preventDefault(),A.stopPropagation(),u(null),h())};window.addEventListener("keydown",B,!0),i.current=()=>window.removeEventListener("keydown",B,!0)}const L=_.start.width,U=_.room;_.at={left:OA(_.start.left+R,U.side,U.w-U.side-L),top:OA(_.start.top+P,U.top,U.h-R5)},u(_.at)},v=C=>{const _=o.current;!_||C.pointerId!==_.id||(h(),_.moved&&(u(null),l(Vse(_.at,_.home)?null:zse(_.at.left,_.at.top,_.start.width,_.room.w))))},j=()=>{o.current&&(u(null),h())},b=C=>{p(C.target)||!n||l(null)},N=n&&!t?n:null;g.useLayoutEffect(()=>{G1()},[N==null?void 0:N.edge,N==null?void 0:N.x,N==null?void 0:N.y]),g.useEffect(()=>{window.addEventListener("resize",uf);const C=document.querySelector(".app main"),_=C&&typeof ResizeObserver<"u"?new ResizeObserver(uf):null;return C&&(_==null||_.observe(C)),()=>{window.removeEventListener("resize",uf),_==null||_.disconnect(),uf()}},[]);const x={ref:a,"data-place":N==null?void 0:N.edge,style:N?{"--place-x":`${N.x}px`,"--place-y":`${N.y}px`}:void 0};return{place:N,panel:x,grip:t?{}:{"data-grip":"",title:"Drag to move · double-click to put it back",onPointerDown:m,onPointerMove:w,onPointerUp:v,onPointerCancel:j,onLostPointerCapture:j,onDoubleClick:b}}}function Zse({state:e,now:t,providers:n,incidents:s=[],leaving:a,onClose:o,liveSince:i=null}){const l=Tn(),u=$5(M5.usage),[h,f]=g.useState(null),[p,m]=g.useState(null),w=g.useMemo(()=>new Map([...e.agents.values()].filter($e=>$e.kind==="root").map($e=>[$e.sessionId,$e.provider??"claude"])),[e,e.revision]),{quota:v,loading:j,refresh:b}=Sse(n.claude),{data:N,loading:x,refresh:S}=_se(n.codex),C=CA("claude",n.claude?v==null?void 0:v.historyAccount:void 0),_=CA("codex",n.codex?N==null?void 0:N.historyAccount:void 0),M=zN(),{byModel:R,totalCost:P,totalTokens:L}=Pse(e,t,i),U=g.useMemo(()=>YJ(e.agents.values()),[e,e.revision]),[B,A]=g.useState(Fne);g.useEffect(()=>{Bne(B)},[B]);const[q,T]=g.useState(qne);g.useEffect(()=>{Une(q)},[q]);const[F,O]=g.useState(0),K=g.useRef(()=>new Map);K.current=()=>i==null?null:H1(e.agents.values(),t);const V=g.useCallback(()=>K.current(),[]),{data:H,shown:D,stale:I,loading:W,baseline:Z}=Ese(B,F,V),z=H!=null,X=W&&I,Y=g.useMemo(()=>qse(e.agents.values()),[e,e.revision]),J=g.useMemo(()=>Use(e.agents.values()),[e,e.revision]),Q=g.useMemo(()=>z?qN(H):[],[H,z]),te=g.useMemo(()=>z?Wse(Lne(H,Y).slice(0,12)):[],[H,z,Y]),le=g.useMemo(()=>UN(H),[H]),de=g.useMemo(()=>Ine(H,le.cost),[H,le.cost]),oe=y5(D,B),re=g.useMemo(()=>z?Tne(Z,H1(e.agents.values(),t)):W1,[e,e.revision,Z,z,t]),he=Dne(H,{...L,cost:P},re),pe=he.hasCost,Le=he.tokenSum,ge=Zo(he.cost),ve=Zo(he.inputTokens),je=Zo(he.outputTokens),Ee=Zo(he.cacheReadTokens),xe=Zo(he.cacheCreateTokens),Ie=R.filter(LA),De=U.filter(LA),We=Fse(z,Q,Ie,re.unpricedTokens),Ke=j||x,ye=()=>{b(),S(),O($e=>$e+1)},Fe=Bse(n);return r.jsxs("aside",{className:`usage-panel${a?" leaving":""}`,id:"usage-panel","aria-label":"Usage",...u.panel,children:[r.jsxs("div",{className:"up-header",...u.grip,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=>m($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:ye,...Fn(Ke),"aria-label":Fe,title:Fe,children:Ke?"…":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:Cn("Close","U",l),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(ose,{quota:v,quotaLoading:j,nowSec:M,weekEnds:C,incident:s.find($e=>$e.provider==="claude")}),n.codex&&r.jsx(ise,{codexQuota:N,codexLoading:x,nowSec:M,weekEnds:_,incident:s.find($e=>$e.provider==="codex")}),z&&r.jsx(cse,{period:B,rangePending:X,setPeriod:A}),Le>0?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"up-total",title:z?void 0:QT(l),children:[r.jsx("span",{className:!pe&&We?"up-total-value up-unpriced":"up-total-value",children:pe?r.jsxs(r.Fragment,{children:[ct(ge),We&&"+"]}):V1(0,We)}),pe&&r.jsx("span",{className:"up-total-label",children:z?oe:HJ})]}),pe&&r.jsxs(r.Fragment,{children:[r.jsxs("p",{className:"up-source",children:["Local estimate · ",z?"ccusage":"live sessions"]}),he.showCostBar&&r.jsx(WN,{cost:P})]}),r.jsxs("div",{className:"up-tokens-row",title:z?void 0:QT(l),children:[r.jsxs("span",{className:"up-tok",children:[r.jsx("span",{className:"up-k",children:"in"}),Ct(ve)]}),r.jsxs("span",{className:"up-tok",children:[r.jsx("span",{className:"up-k",children:"out"}),Ct(je)]}),he.cacheReadTokens>0&&r.jsxs("span",{className:"up-tok",children:[r.jsx("span",{className:"up-k",children:"cache r"}),Ct(Ee)]}),he.cacheCreateTokens>0&&r.jsxs("span",{className:"up-tok",children:[r.jsx("span",{className:"up-k",children:"cache c"}),Ct(xe)]}),!pe&&r.jsx("span",{className:"up-tok up-scope",children:z?oe:zJ})]}),(z?Q.length:Ie.length)>0&&r.jsx(lse,{fromRange:z,rangeModelRows:Q,boardModelRows:Ie}),z&&te.length===0&&le.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 ",oe," yet — ccusage dates sessions in UTC, and the totals above are your local day."]})]}),(z?te.length:De.length)>0&&r.jsx(hse,{fromRange:z,rangeSessionRows:te,boardSessionRows:De,boardStates:J,sessionsOpen:q,setSessionsOpen:T,periodNoun:oe,sessionScale:de,onOpenSession:f,boardProviders:w}),We&&r.jsxs("div",{className:"up-hint",children:["“",da,"” 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:z?(D??B)==="all"?r.jsx(r.Fragment,{children:"No usage in any transcript on this machine."}):r.jsxs(r.Fragment,{children:["No usage ",oe,".",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(sd,{film:"usage"})}),h&&r.jsx(wse,{session:h,onClose:()=>f(null)},`${h.agent}:${h.sessionId}`),p&&r.jsx(kse,{providers:n,instant:p==="keyboard",accounts:{claude:v==null?void 0:v.historyAccount,codex:N==null?void 0:N.historyAccount},onClose:()=>m(null)})]})}function rw(e){return e<9.95?e.toFixed(1):String(Math.round(e))}function VN(e){const t=Number.isFinite(e)?Math.max(0,e):0;return t<50?{value:"0",unit:"KB/s"}:t<999500?{value:rw(t/1e3),unit:"KB/s"}:t<9995e5?{value:rw(t/1e6),unit:"MB/s"}:{value:rw(t/1e9),unit:"GB/s"}}function ym(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 ad(e){return e.unit?e.unit==="%"||e.unit==="°C"?`${e.value}${e.unit}`:`${e.value} ${e.unit}`:e.value}const Jse="thermal:Throttling";function GN(e){const t="timeHeld"in e?e.timeHeld:100-e.speedLimit;return Math.max(0,Math.min(100,t))}function Qse(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[Jse]=GN(e.thermal.throttle)),t}function Lu(e,t){return t==="B/s"?ad(VN(e)):t==="ms"?ad(ym(e)):t==="C"?`${Math.round(e)}°`:t==="%"?`${Math.round(e)}%`:e.toFixed(2)}function df(e,t){return t==="B/s"||t==="ms"||!Number.isInteger(e)?Lu(e,t):t==="C"?`${e}°`:t==="%"?`${e}%`:`${e}`}function ere(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 tre(e,t,n){return e>=n?"hot":e>=t?"warn":"calm"}function nre(e,t,n=Date.now()){const s=GN(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 ${PA(t.lastMs,n)}`:`at full speed · held to ${100-t.peak}% ${PA(t.lastMs,n)}`:"running at full speed, and never held back"}}function PA(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 sre(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 rre(e){var s,a;const t=(s=e.thermal)==null?void 0:s.throttle,n=t?GN(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 are(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 ore=3e3;function ire(){const[e,t]=g.useState(null),n=g.useRef(null);return g.useEffect(()=>{let s=!0;const a=async()=>{if(document.visibilityState!=="hidden")try{const u=await fetch("/api/system");if(!u.ok)return;const h=await u.json();s&&(h!=null&&h.ok)&&t(h)}catch{}},o=()=>{n.current==null&&(a(),n.current=window.setInterval(a,ore))},i=()=>{n.current!=null&&(window.clearInterval(n.current),n.current=null)},l=()=>{if(document.visibilityState==="hidden"){i();return}o(),a()};return o(),document.addEventListener("visibilitychange",l),()=>{s=!1,i(),document.removeEventListener("visibilitychange",l)}},[]),e}function lre(e,t){return!e||e.key!==t?"none":e.dir==="asc"?"ascending":"descending"}function vl({col:e,label:t,note:n,sort:s,next:a,onSort:o,className:i}){const l=lre(s,e);return r.jsx("th",{scope:"col","aria-sort":l,className:i,children:r.jsxs("button",{type:"button",className:"sd-sort",title:n?`Sort by ${t}
|
|
101
|
+
|
|
102
|
+
${n}`:`Sort by ${t}`,onClick:()=>o(a(s,e)),children:[t,r.jsx("span",{className:"sd-sort-dir","aria-hidden":!0,children:l==="none"?"":l==="ascending"?"↑":"↓"})]})})}function aw(e,t){return t==="B/s"?VN(e):t==="ms"?ym(e):{value:String(e),unit:t==="C"?"°C":t}}const Yt={l:30,r:6,t:6,b:2},Wa={l:0,r:0,t:2,b:1},wm=104,cre=64;function Gs(e,t=100,n=wm,s=Yt){const a=n-s.t-s.b;return s.t+a*(1-Math.max(0,Math.min(t,e))/t)}function L5(e,t){return t??[e[0].t,e[e.length-1].t]}function KN(e,[t,n],s,a=Yt){const o=s-a.l-a.r,i=n-t;return a.l+(i>0?o*(e-t)/i:o/2)}function I5(e,t,n,s=100,a=wm,o=Yt,i){if(!e.length)return"";const l=L5(e,i),u=p=>KN(p,l,t,o);let h="",f=null;for(const p of e){const m=f&&p.t-f.t<=n*2?"L":"M";h+=`${m}${u(p.t).toFixed(1)} ${Gs(p.v,s,a,o).toFixed(1)}`,f=p}return h}function O5(e,t,n,s=100,a=wm,o=Yt,i){if(e.length<2)return"";const l=a-o.b,u=L5(e,i),h=w=>KN(w,u,t,o);let f="",p=[];const m=()=>{if(p.length>=2){let w=`M${h(p[0].t).toFixed(1)} ${l}`;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)} ${l}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 ure(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 P5(e,t,n){return n!=null&&e>=n?"hot":t!=null&&e>=t?"warn":""}function dre(e,t,n=s=>Ga(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 DA(e,t){return t==null||!Number.isFinite(t)||t<=0||!Number.isFinite(e)||e<0?null:`${(e/t).toFixed(1)}× the core count`}function Ga(e){const t=new Date(e);return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}function YN(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 hre({group:e,title:t,liveNote:n,onClose:s}){const a=gt(s),o=yt(s),[i,l]=g.useState(null);g.useEffect(()=>{let m=!0;const w=async()=>{try{const j=await fetch(`/api/system/history?group=${e}`);if(!j.ok)return;const b=await j.json();m&&(b!=null&&b.ok)&&l(b)}catch{}};w();const v=window.setInterval(w,2e4);return()=>{m=!1,window.clearInterval(v)}},[e]);const u=(i==null?void 0:i.series)??[],[h,f,p]=g.useMemo(()=>{let m=1/0,w=0;for(const v of u)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]},[u,i==null?void 0:i.sinceMs]);return kt.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 ",Ga(h)," · ",YN(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(HN,{kind:"history",title:"Reading sensor history…",note:"Loading the readings recorded on this machine.",delayed:!0}):u.length===0?r.jsx("p",{className:"hist-empty",children:"Nothing has been measured yet."}):r.jsx("div",{className:"read-result",children:u.map(m=>r.jsx(fre,{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 fre({series:e,stepMs:t,domain:n}){const s=g.useRef(null),[a,o]=g.useState(560),[i,l]=g.useState(null),[u,h]=g.useState(null);g.useEffect(()=>{const I=s.current;if(!I||typeof ResizeObserver>"u")return;const W=new ResizeObserver(([Z])=>o(Math.max(160,Z.contentRect.width)));return W.observe(I),()=>W.disconnect()},[]);const{points:f,unit:p,warnAt:m,critAt:w,label:v,top:j,restsAtZero:b,changes:N,cores:x}=e,S=b?cre:wm,{now:C,peak:_}=ure(f),M=C!=null?aw(C,p):null,R=_!=null?aw(_,p):null,P=v==="Throttling"?dre(f,t):null;let L=null;if(_!=null&&f.length>1)for(let I=f.length-1;I>=0&&!L;I--)f[I].v===_&&(L=f[I]);const U=u!=null?f.find(I=>I.t===u)??null:null,B=i!=null?f[i]:U,A=B?DA(B.v,x):null,[q,T]=n??(f.length?[f[0].t,f[f.length-1].t]:[0,0]),F=I=>KN(I,[q,T],a),O=I=>{if(f.length<2)return null;const W=I.currentTarget.getBoundingClientRect(),Z=(I.clientX-W.left-Yt.l)/Math.max(1,W.width-Yt.l-Yt.r),z=q+(T-q)*Math.max(0,Math.min(1,Z));let X=0;for(let Y=1;Y<f.length;Y++)Math.abs(f[Y].t-z)<Math.abs(f[X].t-z)&&(X=Y);return X},K=I=>{const W=O(I);W!=null&&l(W)},V=I=>{const W=O(I);if(W==null)return;const Z=f[W].t;h(z=>z===Z?null:Z)},H=_!=null&&R&&r.jsxs(r.Fragment,{children:[r.jsx("b",{className:P5(_,m,w),children:R.value}),r.jsxs("span",{children:[R.unit," peak"]})]}),D=_!=null?DA(_,x):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:[M&&r.jsxs(r.Fragment,{children:[r.jsx("b",{children:M.value}),r.jsxs("span",{children:[M.unit," now"]})]}),H&&(L?r.jsx("button",{type:"button",className:"hist-peak",onClick:()=>h(L.t),title:"Show when it peaked",children:H}):H)]})]}),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":M==null||R==null?`${v}: nothing measured yet`:`${v}: ${ad(M)} now, peak ${ad(R)}${L?` at ${Ga(L.t)}`:""}${D?` (${D})`:""}, over ${YN(f[0].t,f[f.length-1].t)}`,onPointerMove:K,onPointerLeave:()=>l(null),onClick:V,children:[[["warn",m],["hot",w]].map(([I,W])=>W==null||W>j?null:r.jsxs("g",{children:[r.jsx("line",{className:`hist-rule ${I}`,x1:Yt.l,x2:a-Yt.r,y1:Gs(W,j,S),y2:Gs(W,j,S)}),r.jsx("text",{className:`hist-rule-tag ${I}`,x:2,y:Gs(W,j,S)+3,children:W})]},I)),r.jsx("line",{className:"hist-floor",x1:Yt.l,x2:a-Yt.r,y1:S-Yt.b,y2:S-Yt.b}),(N??[]).filter(I=>I.from!=null&&f.length>1&&I.t>=q&&I.t<=T).map(I=>r.jsx("line",{className:"hist-mark",x1:F(I.t),x2:F(I.t),y1:Yt.t,y2:S-Yt.b},I.t)),r.jsx("path",{className:"hist-area",d:O5(f,a,t,j,S,Yt,[q,T])}),r.jsx("path",{className:"hist-line",d:I5(f,a,t,j,S,Yt,[q,T])}),f.length===1&&r.jsx("circle",{className:"hist-dot",cx:F(f[0].t),cy:Gs(f[0].v,j,S),r:3}),B&&r.jsxs("g",{children:[r.jsx("line",{className:"hist-cross",x1:F(B.t),x2:F(B.t),y1:Yt.t,y2:S-Yt.b}),r.jsx("circle",{className:"hist-dot",cx:F(B.t),cy:Gs(B.v,j,S),r:3})]})]})}),r.jsxs("div",{className:"hist-axis",children:[B?r.jsxs("span",{className:"hist-at",children:[Ga(B.t)," — ",(()=>{const I=aw(B.v,p);return r.jsxs(r.Fragment,{children:[r.jsx("b",{children:I.value}),I.unit==="%"||I.unit==="°C"||!I.unit?I.unit:` ${I.unit}`]})})(),A&&` · ${A}`]}):r.jsxs(r.Fragment,{children:[r.jsx("span",{children:f.length?Ga(q):""}),r.jsx("span",{children:f.length?Ga(T):""})]}),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(I=>r.jsx("div",{className:"hist-note hist-route",children:I.from==null?`Since ${Ga(I.t)} — ${I.label}`:`${Ga(I.t)} — ${I.label.charAt(0).toUpperCase()+I.label.slice(1)}`},I.t))]})}const FA=["cores","memory","load","thermal"],Ho=116,dr=24,pre=60,mre=6e4;function gre(e){return e.points.length?e.restsAtZero?e.points.some(t=>t.v>0):!0:!1}function yre(e){return e.unit==="C"?`${e.label} temp`:e.key==="mem:physical"?"Physical RAM":e.key==="mem:swap"?`${e.label} memory`:e.label}function wre(e,t=pre){return e.points.length<=t?e:{...e,points:e.points.slice(-t)}}function xre({sys:e}){const[t,n]=g.useState({});g.useEffect(()=>{let i=!0;const l=async()=>{const h=await Promise.all(FA.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})};l();const u=setInterval(()=>void l(),mre);return()=>{i=!1,clearInterval(u)}},[]);const s=g.useMemo(()=>Qse(e),[e]),a=g.useMemo(()=>FA.flatMap(i=>{const l=t[i];return l?l.series.filter(gre).map(u=>({series:wre(u),stepMs:l.stepMs})):[]}),[t]),o=g.useMemo(()=>{let i=1/0,l=-1/0;for(const{series:u}of a){const h=u.points;h.length&&(i=Math.min(i,h[0].t),l=Math.max(l,h[h.length-1].t))}return Number.isFinite(i)?YN(i,l):"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:l})=>r.jsx(vre,{series:i,stepMs:l,now:s[i.key],span:o},i.key))}):null}function vre({series:e,stepMs:t,now:n,span:s}){var w;const{points:a,top:o,unit:i,warnAt:l,critAt:u}=e,h=yre(e),f=n??((w=a[a.length-1])==null?void 0:w.v),p=f==null?"":P5(f,l,u),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}`,l!=null?`over ${df(l,i)} is uncomfortable`:"",u!=null?`over ${df(u,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:Ho,height:dr,viewBox:`0 0 ${Ho} ${dr}`,preserveAspectRatio:"none","aria-hidden":!0,children:[r.jsx("line",{className:"pl-spark-floor",x1:0,x2:Ho,y1:dr-Wa.b,y2:dr-Wa.b}),r.jsx("path",{className:"pl-spark-area",d:O5(a,Ho,t,o,dr,Wa)}),l!=null&&r.jsx("line",{className:"pl-rule warn",x1:0,x2:Ho,y1:Gs(l,o,dr,Wa),y2:Gs(l,o,dr,Wa)}),u!=null&&r.jsx("line",{className:"pl-rule hot",x1:0,x2:Ho,y1:Gs(u,o,dr,Wa),y2:Gs(u,o,dr,Wa)}),r.jsx("path",{className:"pl-spark-line",d:I5(a,Ho,t,o,dr,Wa)})]}),r.jsxs("span",{className:"vis-hidden",children:["peak ",Lu(m,i)," over the last ",s,l!=null&&`, uncomfortable over ${df(l,i)}`,u!=null&&`, the machine acts over ${df(u,i)}`]})]})}const D5={key:"cpu",dir:"desc"};function bre(e,t){return e.key===t?{...e,dir:e.dir==="asc"?"desc":"asc"}:{key:t,dir:t==="name"||t==="user"?"asc":"desc"}}function kre(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 l=s(o),u=s(i);return l==null||u==null?l==null?u==null?0:1:-1:n*(l-u)};return[...e].sort((o,i)=>a(o,i)||(i.cpu??-1)-(o.cpu??-1)||i.mem-o.mem||o.pid-i.pid)}const jre=4e3;function Nre(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 Sre(){const[e,t]=g.useState(null);return g.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(l=>Nre(l,i))}catch{}};s();const a=window.setInterval(s,jre);return()=>{n=!1,window.clearInterval(a)}},[]),e}function Cre(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 _re({sys:e,onClose:t}){sn("process-list");const n=gt(t),s=yt(t),[a,o]=g.useState(D5),i=Sre();return kt.createPortal(r.jsx("div",{className:"modal-backdrop",...s,role:"presentation",children:r.jsx("div",{ref:n,className:"modal pl-modal",onClick:l=>l.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"pl-modal-title",children:r.jsx(Ere,{read:i,sort:a,onSort:o,sys:e,onClose:t})})}),document.body)}function Ere({read:e,sort:t,onSort:n,sys:s,onClose:a}){const o=e?kre(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(HN,{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(hl,{col:"cpu",label:"cpu",sort:t,onSort:n}),r.jsx(hl,{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(hl,{col:"threads",label:"threads",sort:t,onSort:n}),r.jsx(hl,{col:"uptime",label:"up",sort:t,onSort:n}),r.jsx(hl,{col:"user",label:"user",sort:t,onSort:n}),r.jsx("th",{scope:"col",className:"pl-pid-h",children:"pid"}),r.jsx(hl,{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:ea(i.rssBytes)}),r.jsx("td",{className:"sd-num sd-dim",children:i.threads??"—"}),r.jsx("td",{className:"sd-num sd-dim",children:Cre(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(xre,{sys:s})]})]})}function hl(e){return r.jsx(vl,{...e,next:(t,n)=>bre(t??D5,n)})}function K1({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 Tre=300;function od({group:e,title:t,action:n,label:s,value:a,hint:o,liveNote:i,children:l}){const[u,h]=g.useState(!1),f=g.useRef(null),p=g.useRef(null),m=()=>{p.current!=null&&window.clearTimeout(p.current),p.current=null};g.useEffect(()=>m,[]);const w=v=>{var j;m(),!(v.detail>1||((j=window.getSelection())==null?void 0:j.isCollapsed)===!1)&&(p.current=window.setTimeout(()=>{var b,N;p.current=null,((b=window.getSelection())==null?void 0:b.isCollapsed)!==!1&&((N=f.current)==null||N.focus({preventScroll:!0}),h(!0))},Tre))};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})]})}),l]}),o&&r.jsx("span",{id:`sd-hint-${e}`,className:"vis-hidden",children:o}),u&&r.jsx(hre,{group:e,title:t,liveNote:i,onClose:()=>h(!1)})]})}function wp({label:e,value:t,pct:n,tone:s="calm",note:a,mark:o,title:i,trackLabel:l}){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:l?"img":void 0,"aria-label":l,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 Are({network:e}){const{down:t,up:n,api:s,route:a}=e,[o,i]=g.useState(!1),l=s&&s.ms!=null?ym(s.ms):null,u=t!=null&&n!=null;return r.jsxs("div",{className:"sd-section",role:"group","aria-label":"Network",children:[r.jsxs(od,{group:"network",title:"Network history",action:"Show network history",label:"Network",children:[(u||l)&&r.jsxs("div",{className:"sd-figs sd-figs-named",children:[u&&[["Download",t],["Upload",n]].map(([h,f])=>{const p=VN(f);return r.jsx(K1,{value:p.value,unit:p.unit,cap:h},h)}),l&&r.jsx(K1,{value:l.value,unit:l.unit,cap:"Claude API"})]}),!u&&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(Rre,{route:a,api:s,onClose:()=>i(!1)})]})]})}function Rre({route:e,api:t,onClose:n}){return r.jsxs(cm,{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 ",are(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`:`${ad(ym(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 BA({usageOpen:e,leaving:t,sub:n,flag:s,onClose:a,children:o}){const i=$5(M5.machine);return r.jsxs("aside",{className:`sysdetail${e?" shifted":""}${t?" leaving":""}`,id:"system-panel","aria-labelledby":"sd-title",...i.panel,children:[r.jsxs("div",{className:"sd-top",...i.grip,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 Mre({usageOpen:e,leaving:t,onClose:n}){const s=ire();if(!s||s.cpu==null||!s.memory)return r.jsx(BA,{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:l,cores:u,uptimeSec:h,platform:f,thermal:p,network:m,cpu:w}=s;return r.jsxs(BA,{usageOpen:e,leaving:t,sub:`up ${sre(h)} · ${u} cores`,flag:rre(s),onClose:n,children:[r.jsx($re,{cpu:w,perCore:i,loadavg:l,cores:u}),r.jsx(Lre,{memory:a,swap:o,platform:f}),m&&r.jsx(Are,{network:m}),r.jsx(Ire,{thermal:p}),r.jsx(Ore,{sys:s})]})}function $re({cpu:e,perCore:t,loadavg:n,cores:s}){const a=ere(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(od,{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,l)=>r.jsx("span",{className:"sd-core",title:`logical core ${l+1} · ${i}% busy`,children:r.jsx("span",{className:"sd-core-fill",style:{transform:`scaleY(${Math.max(2,i)/100})`}})},l))})}),n&&r.jsxs(od,{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,l)=>r.jsx(K1,{value:i.toFixed(2),cap:["1m","5m","15m"][l]},l))}),a&&r.jsx("div",{className:"sd-note",children:a})]})]})}function Lre({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(od,{group:"memory",title:"Memory history",action:"Show memory history",label:"Memory",children:[r.jsx(wp,{label:"Physical",value:r.jsxs(r.Fragment,{children:[r.jsx("b",{children:ea(s)})," of ",ea(e.total)]}),pct:e.usedPct,tone:e.usedPct>=90?"warn":"calm",note:`${ea(e.available)} available`}),t&&t.total>0&&r.jsx(wp,{label:a,value:r.jsxs(r.Fragment,{children:[r.jsx("b",{children:ea(t.used)})," of ",ea(t.total)]}),pct:o,tone:o>=90?"warn":"calm"})]})})}function Ire({thermal:e}){if(!e)return null;const t=e.throttle?nre(e.throttle,e.heldBack):null;return r.jsx("div",{className:"sd-section",role:"group","aria-label":"Thermal",children:r.jsxs(od,{group:"thermal",title:"Thermal history",action:"Show thermal history",label:"Thermal",children:[e.celsius.map(n=>r.jsx(wp,{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:tre(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(wp,{label:"Throttling",value:r.jsx("b",{children:t.value}),pct:t.pct,tone:t.tone,note:t.note})]})})}function Ore({sys:e}){const[t,n]=g.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(_re,{sys:e,onClose:()=>n(!1)})]})}function Pre(){const[e,t]=g.useState(()=>typeof document<"u"&&document.hidden);return g.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 xp(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=xp(e.l));const n=e.s?Object.entries(e.s):[];return n.length>0&&(t.bySpeed=Object.fromEntries(n.map(([s,a])=>[s,xp(a)]))),t}function qA(e){const t=s=>({...s,cacheCreate1hTokens:0,cacheCreate5mTokens:0,...s.longContext?{longContext:{...s.longContext,cacheCreate1hTokens:0,cacheCreate5mTokens:0}}:{}}),n=t(xp(e));return n.bySpeed&&(n.bySpeed=Object.fromEntries(Object.entries(n.bySpeed).map(([s,a])=>[s,t(a)]))),n}function F5(e){return e.i+e.o+e.cr+e.cc}function Y1(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&&Y1(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??{}))Y1((n=e.s??(e.s={}))[s]??(n[s]={i:0,o:0,cr:0,cc:0,c1h:0,c5m:0}),a);return e}function UA(e,t,n){let s=0,a=0,o=0;const i=[];for(const l of gd(e)){if(!vr(t,n,l.speed)){const u=l.usage,h=u.inputTokens+u.outputTokens+u.cacheReadTokens+u.cacheCreateTokens;h>0&&(o+=h,i.push(l.speed));continue}s+=Ku(l.usage,t,l.speed,n).total,a+=Ku({...l.usage,longContext:void 0},t,ua,n).total}return{atSpeed:s,atStandard:a,unpriced:o,unpricedSpeeds:i}}function WA(e){let t=0;for(const n of Object.values(e))t+=F5(n);return t}function Dre(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 l of i){const u=typeof l.modelName=="string"?l.modelName:"";if(!o||!/claude/i.test(u)||l.missingPricing===!0)continue;const h=`${o}|${u}`,f=n.get(h),p=f?f.usage:{inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0,cacheCreate1hTokens:0,cacheCreate5mTokens:0};p.inputTokens+=t(l.inputTokens),p.outputTokens+=t(l.outputTokens),p.cacheReadTokens+=t(l.cacheReadTokens),p.cacheCreateTokens+=t(l.cacheCreationTokens),f?f.cost+=t(l.cost):n.set(h,{cost:t(l.cost),usage:p})}}return n}function Fre(e,t,n,s=Date.now()){const a=new Map;for(const R of e){const P={},L=U=>{for(const[B,A]of Object.entries(U))Y1(P[B]??(P[B]={i:0,o:0,cr:0,cc:0,c1h:0,c5m:0}),A)};for(const U of R.projects)L(U.models);R.unattributed&&L(R.unattributed);for(const[U,B]of Object.entries(P)){if(!B.s&&!B.l)continue;const{atSpeed:A,atStandard:q}=UA(qA(B),U,s);if(!(A>0&&q>0))continue;let T=a.get(R.day);T||(T=new Map,a.set(R.day,T)),T.set(U,A/q),T.has(pr(U))||T.set(pr(U),A/q)}}const o=(R,P)=>{const L=a.get(R);return(L==null?void 0:L.get(P))??(L==null?void 0:L.get(pr(P)))??1},i=new Map;let l=0,u=0;for(const[R,P]of n){const L=R.indexOf("|"),U=R.slice(0,L),B=R.slice(L+1),A=Kp(P.usage,B,s).total*o(U,B);if(!(A>0&&P.cost>0))continue;l+=P.cost,u+=A;let q=i.get(U);q||(q=new Map,i.set(U,q)),q.set(B,P.cost/A)}const h=u>0,f=(R,P)=>{const L=i.get(R);return(L==null?void 0:L.get(P))??(L==null?void 0:L.get(pr(P)))??null},p=new Set,m=(R,P)=>{let L=0,U=0;for(const[B,A]of Object.entries(R)){if(vr(B,s)){const T=P(B),F=UA(T===null?xp(A):qA(A),B,s);L+=T===null?F.atSpeed:F.atSpeed*T,U+=F.unpriced;for(const O of F.unpricedSpeeds)p.add(`${B} (${O})`);continue}const q=F5(A);q>0&&(U+=q,p.add(B))}return{cost:L,unpriced:U}},w=new Map,v=[];for(const R of e){const P=new Map,L=new Map;let U=0;for(const B of R.projects){const{cost:A,unpriced:q}=m(B.models,F=>f(R.day,F));P.set(B.path,(P.get(B.path)??0)+A),q>0&&L.set(B.path,(L.get(B.path)??0)+q),U+=A;let T=w.get(B.path);T||(T={path:B.path,cost:0,tokens:0,unpricedTokens:0},w.set(B.path,T)),T.cost+=A,T.tokens+=WA(B.models),T.unpricedTokens+=q}v.push({day:R.day,total:U,byPath:P,unpricedByPath:L})}const j=[...w.values()].sort((R,P)=>P.cost-R.cost||P.tokens-R.tokens),b=j.reduce((R,P)=>R+P.cost,0),N=j.reduce((R,P)=>R+P.tokens,0),x=j.reduce((R,P)=>R+P.unpricedTokens,0),S=h?l/u:null,C=t?WA(t):0,_=t?m(t,()=>S):{cost:0,unpriced:0},M=_.cost>0||C>0?{cost:_.cost,tokens:C,unpricedTokens:_.unpriced}:null;return{projects:j,totalCost:b,totalTokens:N,unpricedTokens:x,perDay:v,unattributed:M,unpricedModels:[...p].sort(),calibrated:h,reconciled:h&&x===0}}function hr(e,t,n=ct){return t>0?e>0?`${n(e)}+`:da:n(e)}function fl(e){return e>0?`${Ct(e)} of these tokens are on an unpriced model, so this is a floor`:void 0}function Bre(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 ${da}: this build holds no published rate for it, so its tokens are counted and its dollars are not.`:`${n} are ${da}: this build holds no published rate for them, so their tokens are counted and their dollars are not.`}const qre={phase:"running"},Ure={phase:"failed"},Wre={gen:0,report:null,error:null,early:null};function Hre(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:qre;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 zre(e){var t;return((t=e.report)==null?void 0:t.gen)!==e.gen&&e.error===null}function Vre(e){const t=e;return t&&t.ok!==!1?{phase:"ready",range:t}:Ure}function Gre(e){return`${e.getFullYear()}${String(e.getMonth()+1).padStart(2,"0")}${String(e.getDate()).padStart(2,"0")}`}function Kre(e,t,n=Date.now()){const s=t===0?60:t,a=new Date(n),o=z1(s,a),i=Gre(a);return{report:`/api/account-projects?num=${e}&days=${t}`,ccusage:`/api/ccusage?since=${o}&until=${i}`}}function Yre({num:e,days:t,gen:n,dispatch:s,get:a=(i,l)=>fetch(i,l),now:o=Date.now()}){const i=Kre(e,t,o),l={credentials:"same-origin"};a(i.report,l).then(u=>u.ok?u.json():Promise.reject(new Error(`HTTP ${u.status}`))).then(u=>s({type:"report",gen:n,days:t,data:u}),u=>s({type:"reportFailed",gen:n,message:(u==null?void 0:u.message)||"Could not load"})),a(i.ccusage,l).then(u=>u.ok?u.json():null).catch(()=>null).then(u=>s({type:"cost",gen:n,cost:Vre(u)}))}function B5(e){return/^[A-Za-z]:[\\/]$/.test(e)?e:e.replace(/[\\/]+$/,"")}function ow(e){const t=B5(e).replace(/\\/g,"/");return/^[A-Za-z]:\//.test(t)?t.toLowerCase():t}function HA(e){if(!e)return e;const t=B5(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 Xre(e,t){const n=ow(e);let s;for(const a of t){const o=ow(a.path);!o||o===n||!n.startsWith(`${o}/`)||(!s||ow(s.path).length<o.length)&&(s=a)}return s==null?void 0:s.label}function X1(e){return e===0?"all time":e===1?"today":`the last ${e} days`}function Zre(e){return e===1?"No work attributed to this account yet today.":`No work attributed to this account in ${X1(e)}.`}function Jre(e){return e===1?7:e===7?30:e===30?0:null}function Qre(e,t){return e!==1&&t>0}const eae=[{days:1,label:"Today"},{days:7,label:"7d"},{days:30,label:"30d"},{days:0,label:"All"}],pl=["var(--usage-blue)","var(--usage-teal)","var(--usage-lime)","var(--usage-purple)","var(--usage-indigo)","var(--usage-pink)","var(--usage-orange)","var(--usage-zinc)"],tae="var(--usage-zinc)",iw=6,nae=1600;function sae(e){const t=ct(e),n=/^\$(\d{4,})$/.exec(t);return n?`$${Number(n[1]).toLocaleString("en-US")}`:t}function hf(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 rae(e){const t=/^\d{4}-(\d{2})-(\d{2})$/.exec(e);return t?`${Number(t[1])}/${Number(t[2])}`:e}function aae(e){const t=Math.max(1,Math.ceil(e/6));return n=>n===0||n===e-1||n%t===0}function lw(e){if(!e)return"";try{return new Date(e).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return""}}function oae({num:e,name:t,onClose:n}){var O,K,V,H;sn("account-projects");const[s,a]=g.useState(1),[o,i]=g.useReducer(Hre,Wre),l=((O=o.report)==null?void 0:O.data)??null,u=((K=o.report)==null?void 0:K.days)??s,h=((V=o.report)==null?void 0:V.cost.phase)==="ready"?o.report.cost.range:null,f=((H=o.report)==null?void 0:H.cost.phase)==="running",[p,m]=g.useState(null),[w,v]=g.useState(()=>new Set),j=zre(o),b=o.error,[N,x]=g.useState(null),S=g.useRef(void 0),C=g.useRef(!0);g.useEffect(()=>()=>{C.current=!1,window.clearTimeout(S.current)},[]);const _=g.useRef(null),M=gt(n,{focusRef:_}),R=yt(n),P=g.useRef(0);g.useEffect(()=>{const D=++P.current;i({type:"start",gen:D}),m(null),v(new Set),Yre({num:e,days:s,gen:D,dispatch:i})},[e,s]);const L=g.useMemo(()=>{const D=Date.now();if(!l)return null;const I=Fre(l.daily??[],l.unattributed,Dre(h),D),W=je=>je.replace(/[\\/]+$/,"").split(/[\\/]/).pop()||je||"(unknown)",Z=new Map;for(const je of I.projects)Z.set(W(je.path),(Z.get(W(je.path))??0)+1);const z=je=>{const Ee=W(je);if((Z.get(Ee)??0)<=1)return Ee;const xe=je.replace(/[\\/]+$/,"").split(/[\\/]/).slice(-2,-1)[0];return xe?`${xe}/${Ee}`:Ee},X=I.projects.map(je=>({path:je.path,label:z(je.path)})),Y=je=>({path:je.path,label:z(je.path),parentLabel:Xre(je.path,X),cost:je.cost,tokens:je.tokens,unpricedTokens:je.unpricedTokens}),J=pl[iw%pl.length],Q=new Map,te=[],le=I.projects.slice(0,iw),de=I.projects.slice(iw);le.forEach((je,Ee)=>{Q.set(je.path,pl[Ee%pl.length]),te.push({key:je.path,...Y(je),color:pl[Ee%pl.length]})}),de.length&&te.push({key:"__other__",label:`Other · ${de.length} project${de.length>1?"s":""}`,cost:de.reduce((je,Ee)=>je+Ee.cost,0),tokens:de.reduce((je,Ee)=>je+Ee.tokens,0),unpricedTokens:de.reduce((je,Ee)=>je+Ee.unpricedTokens,0),color:J,muted:!0,members:de.map(Y)});const oe=I.totalCost,re=I.totalTokens,he=oe>0&&I.unpricedTokens===0?"cost":"tokens",pe=he==="cost"?oe:re,Le=te.map(je=>je.color),ge=I.perDay.map(je=>{const Ee=new Map;for(const[De,We]of je.byPath){const Ke=Q.get(De)??J;Ee.set(Ke,(Ee.get(Ke)??0)+We)}const xe=new Map;let Ie=0;for(const[De,We]of je.unpricedByPath){const Ke=Q.get(De)??J;xe.set(Ke,(xe.get(Ke)??0)+We),Ie+=We}return{day:je.day,total:je.total,costByColor:Ee,unpricedByColor:xe,unpriced:Ie}}),ve=ge.reduce((je,Ee)=>Math.max(je,Ee.total),0);return{projectCount:I.projects.length,rows:te,totalCost:oe,totalTokens:re,basis:he,denom:pe,un:I.unattributed,chart:ge,maxDay:ve,colorOrder:Le,unpricedTokens:I.unpricedTokens,unpricedNote:Bre(I.unpricedModels),calibrated:I.calibrated,reconciled:I.reconciled}},[l,h]),U=(D,I)=>{ho(D).then(W=>{C.current&&(window.clearTimeout(S.current),x({path:D,label:I,ok:W}),S.current=window.setTimeout(()=>{C.current&&x(null)},nae))})},B=D=>N!=null&&N.ok&&N.path===D?"Copied":"Copy",A=l!=null&&l.trackedSince?`Tracked since ${lw(l.trackedSince)}`:"Tracking starts with this version",q=X1(u),T=Jre(u),F=j&&!!l;return kt.createPortal(r.jsx("div",{className:"modal-backdrop",...R,role:"presentation",children:r.jsxs("div",{ref:M,className:"modal ap-proj-modal",onClick:D=>D.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ap-proj-title ap-proj-sub",children:[r.jsxs("header",{className:"modal-head ap-proj-head",children:[r.jsxs("div",{className:"ap-proj-titlewrap",children:[r.jsx("div",{className:"modal-tool-name",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:eae.map(D=>r.jsx("button",{type:"button",className:"uh-range-btn","aria-pressed":s===D.days,onClick:()=>a(D.days),children:D.label},D.days))}),r.jsx("button",{ref:_,className:"glyph-btn ap-proj-close",onClick:n,"aria-label":"Close",children:"×"})]}),r.jsxs("div",{className:`ap-proj-body${F?" refreshing":""}`,"aria-busy":j,children:[j&&!l&&r.jsx(Pre,{}),!j&&b&&r.jsxs("div",{className:"ap-proj-state ap-proj-error",children:["Couldn’t load this report: ",b]}),!b&&L&&r.jsx("div",{className:"ap-proj-ready",children:L.rows.length===0?r.jsxs("div",{className:"ap-proj-state",children:[F?"Updating…":Zre(u),T!=null&&r.jsx("div",{className:"ap-proj-widen-wrap",children:r.jsxs("button",{type:"button",className:"ap-proj-copy",onClick:()=>a(T),children:["Show ",X1(T)]})}),r.jsxs("div",{className:"ap-proj-note",children:[A,". Only work from this version onward can be tied to an account."]})]}):r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"ap-proj-bar",role:"img","aria-label":`Share of ${L.basis==="cost"?ct(L.totalCost):`${Ct(L.totalTokens)} tokens`} across ${L.projectCount} project${L.projectCount>1?"s":""}`,children:L.rows.map(D=>{const I=L.basis==="cost"?D.cost:D.tokens,W=L.denom>0?I/L.denom*100:0;if(W<=0)return null;const Z=L.basis==="cost"?hf(D.cost,L.totalCost):`${hf(D.tokens,L.totalTokens)} of tokens`;return r.jsx("span",{className:"ap-proj-seg",style:{width:`${W}%`,background:D.color},title:`${D.label} · ${hr(D.cost,D.unpricedTokens)} · ${Z}${D.tokens?` · ${Ct(D.tokens)} tokens`:""}`},D.key)})}),r.jsxs("div",{className:"ap-proj-totals",children:[r.jsx("span",{className:"ap-proj-total-cost",title:fl(L.unpricedTokens),children:hr(L.totalCost,L.unpricedTokens)}),r.jsxs("span",{className:"ap-proj-total-tok",children:[Ct(L.totalTokens)," tokens"]}),r.jsxs("span",{className:"ap-proj-total-win",children:["· ",F?"updating…":q]}),f&&r.jsx("span",{className:"ap-proj-total-pending",children:"Reconciling cost…"})]}),L.unpricedNote&&r.jsx("div",{className:"ap-proj-note",children:L.unpricedNote}),Qre(u,L.chart.length)&&r.jsxs("div",{className:"ap-proj-days",children:[r.jsxs("div",{className:"ap-proj-days-cap",children:["By day",L.chart.length>1?" · click a bar":""]}),r.jsx("div",{className:"ap-proj-days-plot",role:"group","aria-label":`Spend across ${L.chart.length} day${L.chart.length>1?"s":""}`,children:L.chart.map(D=>{const I=L.maxDay>0?D.total/L.maxDay*100:0,W=p===D.day,Z=L.rows.map(X=>({label:X.label,c:D.costByColor.get(X.color)??0,u:D.unpricedByColor.get(X.color)??0})).filter(X=>X.c>0||X.u>0),z=`${lw(Date.parse(`${D.day}T00:00:00`))}, ${hr(D.total,D.unpriced)}. ${Z.map(X=>`${X.label} ${hr(X.c,X.u)}`).join(", ")}`;return r.jsx("button",{type:"button",className:`ap-proj-day${W?" selected":""}`,"aria-pressed":W,"aria-label":z,title:`${D.day} · ${hr(D.total,D.unpriced)}`,onClick:()=>m(X=>X===D.day?null:D.day),children:r.jsx("span",{className:"ap-proj-col",style:{height:`${I}%`},children:L.colorOrder.map((X,Y)=>{const J=D.costByColor.get(X)??0;return J<=0||D.total<=0?null:r.jsx("span",{className:"ap-proj-colseg",style:{height:`${J/D.total*100}%`,background:X}},Y)})})},D.day)})}),(()=>{const D=aae(L.chart.length);return r.jsx("div",{className:"ap-proj-days-axis","aria-hidden":"true",children:L.chart.map((I,W)=>r.jsx("div",{className:"ap-proj-axis-cell",children:D(W)?rae(I.day):""},I.day))})})(),(()=>{const D=p?L.chart.find(W=>W.day===p):null;if(!D)return null;const I=L.rows.map(W=>({r:W,c:D.costByColor.get(W.color)??0,u:D.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:lw(Date.parse(`${D.day}T00:00:00`))}),r.jsx("span",{className:"ap-proj-day-detail-total",title:fl(D.unpriced),children:hr(D.total,D.unpriced)})]}),I.map(({r:W,c:Z,u:z})=>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:fl(z),children:hr(Z,z)})]},W.key))]})})()]}),r.jsx("ul",{className:"ap-proj-list",children:L.rows.map((D,I)=>{const W=L.basis==="cost"?D.cost:D.tokens,Z=L.denom>0?W/L.denom*100:0,z=w.has(D.key),X=`ap-proj-details-${I}`,Y=z&&(!!D.path||!!D.members),J=D.members?`${z?"Hide":"Show"} the ${D.members.length} project${D.members.length>1?"s":""} folded into Other`:`${z?"Hide":"Show"} location for ${D.label}`;return r.jsxs("li",{className:`ap-proj-row${D.muted?" muted":""}${z?" expanded":""}`,children:[r.jsx("span",{className:"ap-proj-dot",style:{background:D.color},"aria-hidden":"true"}),r.jsxs("span",{className:"ap-proj-name",children:[D.label,D.parentLabel&&r.jsxs("span",{className:"ap-proj-parent",children:[" · in ",D.parentLabel]})]}),r.jsx("span",{className:"ap-proj-track",title:L.basis==="cost"?`${hf(D.cost,L.totalCost)} of tracked cost`:`${hf(D.tokens,L.totalTokens)} of tracked tokens`,children:r.jsx("span",{className:"ap-proj-fill",style:{width:`${Z}%`,background:D.color}})}),r.jsx("span",{className:"ap-proj-cost",title:fl(D.unpricedTokens),children:hr(D.cost,D.unpricedTokens)}),r.jsx("span",{className:"ap-proj-tok",children:Ct(D.tokens)}),r.jsx("button",{type:"button",className:"glyph-btn ap-proj-info","aria-expanded":z,"aria-controls":Y?X:void 0,"aria-label":J,onClick:()=>v(Q=>{const te=new Set(Q);return te.has(D.key)?te.delete(D.key):te.add(D.key),te}),children:"ⓘ"}),z&&D.path&&r.jsxs("div",{className:"ap-proj-details",id:X,children:[r.jsx("code",{className:"ap-proj-path",children:HA(D.path)}),r.jsx("button",{type:"button",className:"ap-proj-copy","aria-label":`${B(D.path)} location for ${D.label}`,onClick:()=>U(D.path,D.label),children:B(D.path)})]}),z&&D.members&&r.jsx("div",{className:"ap-proj-details ap-proj-other-members",id:X,children:D.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:HA(Q.path)}),r.jsx("span",{className:"ap-proj-cost",title:fl(Q.unpricedTokens),children:hr(Q.cost,Q.unpricedTokens)}),r.jsx("span",{className:"ap-proj-tok",children:Ct(Q.tokens)}),r.jsx("button",{type:"button",className:"ap-proj-copy","aria-label":`${B(Q.path)} location for ${Q.label}`,onClick:()=>U(Q.path,Q.label),children:B(Q.path)})]},Q.path))})]},D.key)})}),L.un&&r.jsxs("div",{className:"ap-proj-unattributed",children:[r.jsx("span",{className:"ap-proj-dot",style:{background:tae},"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:fl(L.un.unpricedTokens),children:hr(L.un.cost,L.un.unpricedTokens,sae)}),r.jsx("span",{className:"ap-proj-un-tok",children:Ct(L.un.tokens)}),r.jsx("div",{className:"ap-proj-note",children:"Work no account could be tied to — from before tracking, or a gap."})]}),r.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children: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":L.reconciled?"Dollars from ccusage · split by activity":L.calibrated?"Dollars from ccusage for the priced models · split by activity":h?"Dollars estimated · ccusage could not price this window":"Dollars estimated · ccusage unavailable"," · ",A]})]})})]})]})}),document.body)}function ha(e,t){return GP(t-Math.floor(e/1e3))}function iae(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 XN(){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 lae({anchorId:e,boundaryId:t,issue:n,who:s,fetchedAt:a,nowSec:o,onClose:i,onSignIn:l,onReport:u}){const h=g.useRef(null);return r.jsx(cm,{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(XN,{}),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 ${ha(a,o)}`:"never collected"]}),r.jsxs("div",{className:"ap-pop-actions",children:[u&&r.jsx("button",{type:"button",className:"ap-issue-report",onClick:()=>{i(),u()},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),l()},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 cae=5*6e4;function uae(e,t){return typeof e!="string"||!e?!1:e==="::1"||e==="localhost"||e.startsWith("127.")?!0:Array.isArray(t)&&t.includes(e)}function dae(e,t,n=cae){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,l=i!=null&&i.current&&typeof i.current.key=="string"?i.current.key:"";if(!l||typeof i.at!="number"||!Number.isFinite(i.at)||t-i.at>n||i.at-t>n||uae(o.addr,e.addrs))continue;const u=`${l}|${o.peerFp??o.fp}`;a.has(u)||(a.add(u),s.set(l,[...s.get(l)??[],o]))}return s}function q5(e){return e.length<=1?e[0]??"another deck":`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function ku(e){return e.charAt(0).toUpperCase()+e.slice(1)}function hae(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 fae(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 pae(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 zA={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 mae(e){const t=q5(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 xi(e,t,n){var a;const s=yae(e,t);return e.active===!0&&((a=n==null?void 0:n.elsewhere)!=null&&a.length)&&(!s||s.tone!=="warn")?mae(n.elsewhere):!s||!(n!=null&&n.noCopyWorksNearby)||!gae(e)?s:{...s,text:zA.text,hint:zA.hint}}function gae(e){return e.staleCopy?!1:e.stopped?e.collector==="relogin_required":e.error==="invalid_grant"||e.error==="no_refresh_token"}function yae(e,t){if(e.staleCopy){const n=hae(e.repair??null,t);return{text:ku(n.text),hint:n.hint,fix:null,tone:"quiet",blocksSwitch:!1}}if(e.stopped){const n=pae(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:ku(n.text),hint:n.hint,fix:n.fix?ku(n.fix):null,tone:s||e.collector==="keychain_unavailable"?"warn":"quiet",blocksSwitch:s}}if(e.error){const n=fae(e.error);return{text:ku(n.text),hint:n.hint,fix:n.fixable?"Sign in again":null,tone:n.fixable?"warn":"quiet",blocksSwitch:n.fixable}}return null}function VA(e){return typeof e.id=="string"&&e.id.startsWith("scoped-")}function GA(e){const t=e.filter(l=>!VA(l)),n=e.filter(l=>VA(l)),s=t.length?t:n,a=t.length?n:[],o=s.reduce((l,u)=>l&&l.pct>=u.pct?l:u,null);let i=null;for(const l of a)o&&l.pct<=o.pct||(!i||l.pct>i.pct)&&(i=l);return{shown:s,rest:a,fuller:i,peak:i??o}}function id(e,t){return!!e.resetAt&&e.resetAt<=t}function ZN(e,t){return(e.lanes??[]).some(s=>id(s,t))?null:e.headroom}const wae="\0";function ws(e){const t=typeof e.email=="string"?e.email.trim():"";if(!t)return`slot:${e.num}`;const n=typeof e.orgUuid=="string"&&e.orgUuid.trim()?`uuid:${e.orgUuid.trim()}`:typeof e.org=="string"?e.org.trim():"";return`acct:${t}${wae}${n}`}function xae(e,t,n=ws){const s=n(t);return e.includes(s)?e.filter(a=>a!==s):[...e,s]}const xm="slot",JN=[{lane:"five_hour",name:"5h"},{lane:"seven_day",name:"7d"}],U5=e=>e.id.startsWith("scoped-");function vae(e){var t;return((t=JN.find(n=>n.lane===e.id))==null?void 0:t.name)??e.label}function bae(e){if(e==="room")return"room";const t=/^(.+):(full|empty)$/.exec(e);return t?t[1]:null}function W5(e){const t=[...new Set(e.flatMap(s=>(s.lanes??[]).filter(U5).map(a=>a.label)))].sort((s,a)=>s.localeCompare(a)),n=[...JN.map(s=>s.name),...t];return[{id:xm,label:"Slot"},...n.flatMap(s=>[{id:`${s}:full`,label:`${s} · fullest`},{id:`${s}:empty`,label:`${s} · emptiest`}]),{id:"room",label:"Most room"}]}function KA(e,t,n){const s=JN.find(o=>o.name===t),a=(e.lanes??[]).find(o=>s?o.id===s.lane:U5(o)&&o.label===t);return a&&n!=null&&id(a,n)?null:a&&Number.isFinite(a.pct)?a.pct:null}function H5(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:ZN(p,s);return o(YA(a,p=>{const m=f(p);return Number.isFinite(m)?m:null},"desc"))}const i=/^(.+):(full|empty)$/.exec(t);if(!i)return a;const[,l,u]=i;if(!a.some(f=>KA(f,l,s)!=null))return a;const h=YA(a,f=>KA(f,l,s),u==="full"?"desc":"asc");return u==="empty"?o(h):h}function YA(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 z5(e,t){return W5(t).some(n=>n.id===e)?e:xm}function Z1(e,t){if(!t)return[...e];const n=new Map(t.map((o,i)=>[o,i])),s=e.filter(o=>n.has(ws(o))).sort((o,i)=>n.get(ws(o))-n.get(ws(i))),a=e.filter(o=>!n.has(ws(o)));return[...s,...a]}function QN(e){const t=ws(e);return t.startsWith("slot:")?t:`h:${kae(t)}`}function kae(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 J1={mode:"some",keys:[]};function V5(e,t){const n=e.keys.includes(QN(t));return e.mode==="all"?!n:n}function jae(e,t){return{mode:e.mode,keys:xae(e.keys,t,QN)}}function G5(e,t){return t.length>0&&t.every(n=>V5(e,n))}function Nae(e,t){return G5(e,t)?J1:{mode:"all",keys:[]}}function Sae(e,t){if(!Array.isArray(t))return e;const n=new Set(t.map(QN)),s=e.keys.filter(a=>n.has(a));return s.length===e.keys.length?e:{mode:e.mode,keys:s}}const ii=[{id:"five_hour",label:"5h",long:"5-hour"},{id:"seven_day",label:"7d",long:"7-day"}];function XA(e){return e.counted?e.pct:e.why==="login"?null:e.estimate}function Cae(e){const t=XA(e.five_hour),n=XA(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 _ae(e,t){const n=ii.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:ha(e.updatedAt,t),old:!0}}const K5=15*6e4;function vm(e){return e!=null&&e>0&&Number.isFinite(e)&&Number.isFinite(new Date(e).getTime())?e:null}const Y5=e=>e.alias??e.email??`account ${e.num}`;function Iu(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 Q1(e,t,n){const s=ii.find(w=>w.id===t).label,a=(e.lanes??[]).find(w=>w.id===t),o=a&&Number.isFinite(a.pct)?X5(a.pct):null,i=xi(e,n),l=Iu(e,t),u=l!=null&&l<=n,h=Z5(a,e.fetchedAt,n),f=(w,v)=>({counted:!1,why:w,say:v,last:o,estimate:o,resetAt:u?null:Iu(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=vm(e.fetchedAt);return e.stale||e.staleCopy===!0||e.stopped===!0||p==null||n*1e3-p>K5?f("stale",p!=null?`Updated ${ha(p,n)}`:"Never read"):{counted:!0,pct:o,resetAt:Iu(e,t)}}const X5=e=>Math.min(100,Math.max(0,e));function Z5(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=vm(t),a=s!=null?`read ${ha(s,n)}`:"last read";return`Reported reset time passed ${ha(e.resetAt*1e3,n)}, ${oo(X5(e.pct))}% when ${a}`}function Eae(e,t){const n=ii.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 l=i.reduce((h,f)=>!h||f.at<h.at?f:h,null),u=l&&{...l,more:i.filter(h=>h!==l&&h.at-l.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:u}}function eS(e,t){const n=e.map(a=>{const o={five_hour:Q1(a,"five_hour",t),seven_day:Q1(a,"seven_day",t)};return{num:a.num,key:ws(a),name:Y5(a),active:a.active,heldOut:a.disabled===!0,cells:o,resets:{five_hour:Iu(a,"five_hour"),seven_day:Iu(a,"seven_day")},status:Cae(o),updatedAt:vm(a.fetchedAt)}}),s=n.filter(a=>a.status==="ready").length;return{rows:n,windows:ii.map(a=>Eae(n,a.id)),roomInBoth:s}}function uu(e,t){return(e==null?void 0:e.key)===t?{key:t,dir:e.dir==="asc"?"desc":"asc"}:{key:t,dir:"asc"}}const Tae={ready:0,limited:1,exhausted:2,stale:3};function Aae(e){return e.counted?e.pct:e.reset?e.estimate:e.last}function ZA(e,t){return t==="status"?Tae[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:Aae(e.cells[t])}function Rae(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 l=ZA(o,t.key),u=ZA(i,t.key);return l==null||u==null?l==null?u==null?0:1:-1:n*(l-u)};return[...e].sort((o,i)=>a(o,i)||s.get(o.num)-s.get(i.num))}function oo(e){return e>=100?100:Math.min(99,Math.round(e))}function Mae(e){const t=oo(e);return{used:t,available:100-t}}function $ae(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 J5=new Set(["awaiting_url","awaiting_code","registering"]);function Q5(e){return e!=null&&J5.has(e)}function e6(e){return e!=null&&e!=="done"&&!J5.has(e)}const t6="the sign-in ended before it finished — the deck restarted, or it was cancelled in another tab",Lae="the sign-in did not complete";function Iae({state:e,serverError:t,localError:n}){const s=e==="idle";return{title:s?"Sign-in ended":"Sign-in failed",message:n||t||(s?t6:Lae)}}function JA({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 QA({started:e,state:t}){return!e||t==="done"?null:{action:"login-cancel"}}function Oae({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":e6(e==null?void 0:e.state)||n&&t&&!s?"ended":s||Q5(e==null?void 0:e.state)?"asking":"primer"}function tS(e,t){return t?Zt(e,t):void 0}const Pae={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 ${Pt}`,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"},Dae={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"},nS=`claude-swap could not read the login keychain — start ${Pt} from a Terminal window rather than a background service`,Fae={unreadable_here:{short:"Keychain locked on this Mac",long:`${nS}.`},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 vp(e){return e?Zt(Fae,e)??null:null}const n6={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 ej(e,t,n){const s=n==null?null:n6[n];if(s)return s;if((e==null?void 0:e.reason)!=="no_cswap"&&/keychain/i.test(ld(e)))return nS;const a=tS(Dae,e==null?void 0:e.reason);return a||(e==null?void 0:e.reason)||t}function ld(e){return((e==null?void 0:e.output)||(e==null?void 0:e.detail)||(e==null?void 0:e.error)||"").trim()}const Bae={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",fetch_failed:"ccusage could not be downloaded — this machine has no npm, so the deck fetches ccusage from registry.npmjs.org itself. Check this computer can reach that site, then try again",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"},qae="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 Uae(e){return/\bnpx\b/i.test(e)&&/(command not found|not found|not recognized|ENOENT)/i.test(e)}const Wae="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",Hae="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",zae=e=>/\b(?:ERR_)?MODULE_NOT_FOUND\b|cannot find (?:module|package)/i.test(e),Vae=/node_modules[\\/]npm[\\/]bin[\\/]|\bnpm-prefix\.js\b|\bnp[mx][-.][\w.-]*cli\.js\b/i,Gae=/[\\/]_npx[\\/]/i,Kae=`the copy of ccusage ${Pt} installed for itself`;function Yae(e){const t=String((e==null?void 0:e.install)??"").replace(/\s+/g," ").trim();return t.length>240?`${t.slice(0,239)}…`:t}function rje(e,t){const n=Xae(e,t),s=Yae(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 ${du(n)}`:`there is no managed copy of ccusage on this machine, and the npx fallback failed: ${du(n)}`;case"managed":return`${Kae} failed to run: ${du(n)}`;case"path":return e.bin?`the ccusage this deck found at ${e.bin} failed to run: ${du(n)}`:`the ccusage this deck found on your PATH failed to run: ${du(n)}`;default:return n}}const du=e=>/^[A-Z][a-z]/.test(e)?e[0].toLowerCase()+e.slice(1):e;function Xae(e,t){const n=ld(e);if(zae(n)){if(Gae.test(n))return Hae;if(Vae.test(n))return Wae}if(Uae(n))return qae;const s=tS(Bae,e==null?void 0:e.reason);return s||(e==null?void 0:e.reason)||t}function Cl(e,t,n){const s=n==null?null:n6[n];if(s)return s;if(e!=null&&e.detail)return e.detail;if(e!=null&&e.error&&e6(e.state))return e.error;const a=tS(Pae,e==null?void 0:e.reason);return a||(e!=null&&e.error?e.error:(e==null?void 0:e.reason)||t)}function xr(e,t){if(e==null)return"not seen";const n=Math.max(0,Math.round((t-e)/1e3));if(n<90)return"now";const s=Math.round(n/60);if(s<60)return`${s}m ago`;const a=Math.round(s/60);return a<48?`${a}h ago`:`${Math.round(a/24)}d ago`}const Zae={keychain_unavailable:{short:"Keychain locked on the other Mac",long:`the other Mac could not export it. On that Mac: ${nS}. 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 tj(e){return e.why?Zt(Zae,e.why)??vp(e.why):null}const sS={"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"}},Jae={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 eR(e){var s;const t=Qae[e];if(t)return t;const n=(s=/\b(E[A-Z]{3,})\b/.exec(e))==null?void 0:s[1];return n&&Jae[n]||e}const Qae={"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 bm(e,t){var f;if(!e)return null;if(e.error&&((f=e.done)!=null&&f.length)){const p=bm({...e,error:void 0},t),m=` · ${xr(e.at,t)}`;return{...p,text:`${p.text.slice(0,-m.length)}, then ${eR(e.error)}${m}`,tone:"bad"}}if(e.error)return sS[e.error]??{text:eR(e.error),tone:"bad"};const n=e.done??[];if(!n.length)return{text:`all logins fine · ${xr(e.at,t)}`,tone:"idle"};const s=n.filter(p=>p.ok),a=s.length===1?"login":"logins",o=n.map(p=>({d:p,why:tj(p)})).filter(p=>p.why),i=[...new Set(o.map(p=>p.why.short))],l=i.length?`, ${i.join(", ")}`:"",u=o.length?o.map(p=>`${p.d.email}: ${p.why.long}`).join(" "):void 0,h=xr(e.at,t);return s.length===n.length?{text:`${s.length} ${a} arrived${l} · ${h}`,tone:o.length?"warn":"ok",...u?{hint:u}:{}}:{text:`${s.length} of ${n.length} logins arrived${l} · ${h}`,tone:"bad",...u?{hint:u}:{}}}const eoe=9e4;function toe({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 l=s.filter(h=>h.addr===i&&h.port&&h.at>0&&a-h.at<eoe);if(!l.length)return null;const u=[...new Set(l.map(h=>h.port))];if(n!=null&&!u.includes(n)){const h=u.length===1?`port ${u[0]}`:`ports ${u.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??u[0]}.`}function km(e,t){var n,s;return(n=e.last)!=null&&n.error&&!sS[e.last.error]?!1:!!((s=e.last)!=null&&s.at&&t-e.last.at<nj||e.lastSeen!=null&&t-e.lastSeen<nj)}const nj=95e3;function noe(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?s6(p.lastSeen,t):km(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 l=0,u=0,h=0;for(const p of a6(s,m=>aS(m,m.peerFp??m.fp,i).name,m=>m.addr??"")){const m=p.filter(a);if(!m.length){h++;continue}l++,m.every(o)&&u++}if(l&&u===l)return{text:l===1?"1 deck found · waiting for them to accept":`${l} decks found · waiting for them to accept`,tone:"wait"};if(!l)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=l===1?"1 deck ready":`${l} decks ready`;return{text:h?`${f} · ${h} away`:f,tone:"ok"}}function soe(e,t,n){if(n)return"checking…";if(e==null)return"not checked yet";const s=xr(e,t);return s==="now"?"checked just now":`checked ${s}`}function rS(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 s6(e,t){return e!=null&&t-e<nj}function roe(e,t){if(e==null)return{text:"one-way · has not called yet",here:!1};const n=s6(e,t);return{text:n?"online · one-way, it calls in":`one-way · last online ${xr(e,t)}`,here:n}}function tR(e,t,n){return t?"online":e.lastSeen!=null?`last online ${xr(e.lastSeen,n)}`:e.waiting?"has not called yet":"never reached"}function aoe(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(ooe(p,o,t)));const i=[],l=[];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?l.push(ioe(p,m,t)):i.push(loe(p,m,o,t)))}n.push(...doe(i).sort(a),...l.sort(a));const u=[];for(const p of e.strangers??[])!(p!=null&&p.fp)||s.has(p.fp)||(s.add(p.fp),u.push(coe(p,o,e.pairingMode)));n.push(...u.sort(a));const h=[];for(const p of e.declined??[])!(p!=null&&p.fp)||s.has(p.fp)||(s.add(p.fp),h.push(uoe(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 ooe(e,t,n){const s=jm(t,e.fp,e.name||e.fp);return{fp:e.fp,...s,addr:e.addr??"",kind:"asks",state:`wants to pair · ${rS(e.at,n)}`,tone:"wait",here:!0,hint:`${s.name} at ${e.addr}${e.via==="tailscale"?", over Tailscale,":""} is waiting for an answer.`,...Nm(e.via)}}function ioe(e,t,n){var o;const s=bm(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?sj(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.`,...Nm(e.via)}}function loe(e,t,n,s){var w,v,j,b;const a=bm(e.last,s),o=km(e,s),i=e.addr?`${e.addr}:${e.port}`:"",l=e.waiting?roe(e.lastSeen,s):null,u=l?l.here:o,h=!l&&a?u?`online · ${sj(a)}`:`${sj(a)} · ${tR(e,u,s)}`:l?l.text:tR(e,u,s),f=(w=e.last)!=null&&w.error?sS[e.last.error]:null,p=!l&&u&&!((v=e.last)!=null&&v.error)&&!(((j=e.last)==null?void 0:j.done)??[]).length,m=aS(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:u?"ok":"idle",here:l?l.here:o,...Nm(e.via),hint:l?`${m.name} calls this deck, and this deck has no address to call back on — so it can repair its logins from here, and this deck cannot repair from it. ${e.lastSeen==null?"It has not called since this deck started.":`It last called ${xr(e.lastSeen,s)}.`} Add its address through Add a deck, the link at the top of this view, to reach it either way.`:`${m.name}${i?` at ${i}`:""}${(b=e.last)!=null&&b.error?` — ${e.last.error}`:""}${a!=null&&a.hint?` — ${a.hint}`:""}`}}function aS(e,t,n){return e.manual&&!e.met?{name:e.addr?`${e.addr}:${e.port}`:""}:jm(n,t,e.name||t)}function r6(e,t){return aS(e,e.peerFp??e.fp,t).name}function coe(e,t,n){const s=jm(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.`,...Nm(e.via)}}function uoe(e,t){const n=jm(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 jm(e,t,n){const s=t?e[t]:void 0;return s&&s!==n?{name:s,self:n}:{name:n}}function Nm(e){return e==="tailscale"?{via:"tailscale"}:{}}function sj(e){return e.text.replace(/ · .*$/,"")}function doe(e){return a6(e,t=>t.name,t=>t.addr).map(hoe)}function a6(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 l of i)a.push(o.filter(u=>n(u)===l));for(const l of o)n(l)||a.push([l])}else a.push(o)}return a}function hoe(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 nR(e,t){return t?e.map(n=>t[n.fp]?{...n,name:t[n.fp]}:n):e}function cd(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 foe(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 poe(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,l=t||a.length===0,u=l?[...a,...o]:a,h=s.filter(f=>f.kind==="paired").length;return{asks:n,rest:s,live:a,folded:o,troubled:i,showFolded:l,shown:u,paired:h}}function sR(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 moe(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 goe(e,t,n){if(!(t!=null&&t.enabled))return!1;const s=(t.peers??[]).filter(o=>o.paired&&km(o,n));if(s.some(o=>{var i,l,u;return yoe((i=o.offers)==null?void 0:i.current)&&!((u=(l=o.offers)==null?void 0:l.accounts)!=null&&u.some(h=>h.key===e))}))return!1;const a=s.map(o=>{var i,l;return(l=(i=o.offers)==null?void 0:i.accounts)==null?void 0:l.find(u=>u.key===e)}).filter(o=>o!=null);return a.length>0&&a.every(o=>!o.alive)}const yoe=e=>!!e&&typeof e=="object"&&e.hidden===!0;function woe(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 l,u,h,f;if(!o.paired||!km(o,s))return!1;const i=(u=(l=o.offers)==null?void 0:l.accounts)==null?void 0:u.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 xoe(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=>r6(s,t.aliases??{})).filter(Boolean);return[...new Set(n)].sort((s,a)=>s.localeCompare(a))}function voe(e,t,n){const s=dae(t,n).get(e);if(!(s!=null&&s.length))return null;const a=s.map(o=>r6(o,(t==null?void 0:t.aliases)??{})).filter(Boolean);return[...new Set(a)].sort((o,i)=>o.localeCompare(i))}function boe(e,t){return e.flatMap(n=>{const s=xoe(n.key,t);return s?[[n.key,{to:s,inUse:n.inUse===!0}]]:[]})}function rR(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 o6={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 bp(e){return e.length<=1?e.join(""):`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function koe(e,t,{holdOut:n=!1}={}){if(!e||e.level!=="metrics"&&e.level!=="content")return null;const s=e.level==="content"?e.content.map(l=>o6[l]??l):[],a=e.orgName?e.orgName:"This account's organization",o=s.length?`usage data, and your ${bp(s)}`:"usage data",i=e.destinations.length?bp(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 ${ha(e.seenAt,t)}, while this account was active.`+(n?" To keep Auto-switch off it, choose Hold out of rotation in its ⋯ menu.":"")}}function joe(e){if(!e||e.level!=="metrics"&&e.level!=="content")return null;const t=e.level==="content"?e.content.map(o=>o6[o]??o):[],n=t.length?`your ${bp(t)}`:"usage data",s=e.orgName?`${e.orgName}'s telemetry`:"Its organization's telemetry",a=e.destinations.length?` to ${bp(e.destinations)}`:"";return`${s} is on for them: it sends ${n}${a}.`}function Noe(e){return e>=90?"hi":e>=70?"mid":void 0}function Soe({lane:e,nowSec:t,readAt:n,frozen:s,sortedBy:a}){const o=Math.min(100,Math.max(0,e.pct)),i=id(e,t),l=s||i,u=l?"var(--muted)":o>=90?"var(--err)":o>=70?"var(--warn)":"var(--accent)",h=e.resetAt&&!l?yd(e.resetAt,t):null,f=i?Z5(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:u,opacity:o===0||l?.4:1}})}),i?r.jsx("span",{className:"ap-lane-pct",style:{color:u},"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:u},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 Coe({a:e,nowSec:t,lan:n,opened:s,onToggleLanes:a,busy:o,pressProps:i,onSwitch:l,menuOpen:u,onOpenMenu:h,onCloseMenu:f,refusal:p,onDismissRefusal:m,onSignIn:w,switchedHere:v,swapped:j,displaced:b,issueExpanded:N,onOpenIssue:x,sortKey:S=null,home:C=null,rotating:_=!1}){const M=e.lanes.filter(H=>!id(H,t)),{shown:R}=GA(e.lanes),{fuller:P}=GA(M),L=S==="room"?M.reduce((H,D)=>H&&H.pct>=D.pct?H:D,null):S?e.lanes.find(H=>vae(H)===S)??null:null,U=xi(e,t,n),B=e.active||s,A=e.alias??e.email??`account ${e.num}`,q=e.alias&&e.email?`${e.alias} · ${e.email}`:A,T=e.stale||(U==null?void 0:U.blocksSwitch)===!0,F=P?[...R,P]:R,O=e.fetchedAt?ha(e.fetchedAt,t):null,K=koe(e.telemetry,t,{holdOut:_&&!e.active&&!e.disabled}),V=joe(e.telemetry);return r.jsxs("li",{className:`ap-account${e.active?" active":""}`,"aria-current":e.active?"true":void 0,"data-open":B?"":void 0,"data-frozen":T?"":void 0,children:[!e.active&&r.jsx("button",{type:"button",className:"ap-row-open",id:`ap-row-${e.num}`,title:q,"aria-expanded":B,"aria-controls":B?`ap-detail-${e.num}`:void 0,"aria-describedby":[e.alias&&e.email?`ap-email-${e.num}`:null,C?`ap-home-${e.num}`:null,n!=null&&n.sharedTo?`ap-shared-${e.num}`:null,!B&&!(U!=null&&U.blocksSwitch)?`ap-quota-${e.num}`:null,K?`ap-telemetry-${e.num}`:null].filter(Boolean).join(" ")||void 0,onClick:()=>a(),children:r.jsxs("span",{className:"vis-hidden",children:[A,", ",B?"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}),C&&r.jsxs("span",{className:"ap-home",id:`ap-home-${e.num}`,title:C,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:C})]}),(n==null?void 0:n.sharedTo)&&r.jsxs("span",{className:"ap-shared",id:`ap-shared-${e.num}`,title:rR(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:rR(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:()=>l(e.num,A),"aria-label":`Switch to ${A}`,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":u,"aria-controls":u?`ap-menu-${e.num}`:void 0,title:"More actions",onClick:()=>u?f():h(e.num),onKeyDown:H=>{H.key!=="ArrowDown"&&H.key!=="ArrowUp"||(H.preventDefault(),h(e.num,H.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??A}`,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&&V&&r.jsx("p",{className:"ap-switched",children:V}),j&&(()=>{const H=(b==null?void 0:b.alias)??(b==null?void 0:b.email)??"the account that was there";return r.jsxs("p",{className:"ap-note ap-swap-note",title:`Slot ${j.at} was taken, so the two accounts traded places: ${H} now holds slot ${j.displaced}.`,children:["swapped with slot ",j.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:()=>x(e.num,`ap-issue-${e.num}`),children:[U.tone==="warn"&&r.jsx(XN,{}),r.jsx("span",{className:"ap-issue-text",children:U.text})]}),!B&&r.jsx("span",{className:"ap-issue-age",title:"When claude-swap last read this account's usage",children:O??"never collected"})]}),K&&r.jsxs("p",{className:"ap-telemetry",id:`ap-telemetry-${e.num}`,"data-tone":K.tone,title:K.detail,children:[r.jsx("span",{"aria-hidden":!0,children:K.text}),r.jsx("span",{className:"vis-hidden",children:K.detail})]}),!B&&!(U!=null&&U.blocksSwitch)&&r.jsxs("p",{className:"ap-quota",id:`ap-quota-${e.num}`,children:[F.length?F.map(H=>r.jsxs("span",{className:"ap-q","data-sort-key":H.id===(L==null?void 0:L.id)?"":void 0,children:[r.jsx("span",{className:"ap-q-label",children:H.label})," ",id(H,t)?r.jsx("span",{className:"ap-q-pct",title:`${H.label} has reset since this reading`,children:"reset"}):r.jsxs("span",{className:"ap-q-pct","data-level":T?void 0:Noe(H.pct),children:[Math.round(H.pct),"%"]})]},H.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":O?void 0:"",title:"When claude-swap last read this account's usage",children:O??"never collected"})]}),B&&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(H=>r.jsx(Soe,{lane:H,nowSec:t,readAt:e.fetchedAt,frozen:T,sortedBy:H.id===(L==null?void 0:L.id)},H.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 ",ha(e.fetchedAt,t),U!=null&&U.blocksSwitch?"":iae(e.nextAt,t)]}):r.jsx("span",{className:"ap-age ap-stale",title:"claude-swap has not read this account yet",children:"never collected"})})]})]})}function _oe({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 Eoe({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 ${Pt} 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 Toe=[{value:"room",label:"Most room left"},{value:"weekly",label:"Soonest weekly reset"}],Aoe="Uses up quota that resets within 4 days first";function Roe(e){return e==="room"||e==="weekly"}function cw(e,t){return!t||!e.email?!1:e.email.trim().toLowerCase()===t.email.trim().toLowerCase()&&(e.orgUuid??"")===(t.orgUuid??"")}function Moe(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 uw=[70,80,85,90,95],i6="custom",bl=50,kl=99,$oe=`A whole percent from ${bl} to ${kl}.`;function Loe(e){const t=Number(e);return[...Number.isFinite(t)&&t>0&&!uw.includes(t)?[...uw,t]:uw].sort((s,a)=>s-a)}function Ioe(e){const t=e.trim().replace(/\s*%$/,"");if(t==="")return{ok:!1,reason:"empty",message:`Enter a number from ${bl} to ${kl}.`};if(!/^\d+(\.\d*)?$|^\.\d+$/.test(t))return{ok:!1,reason:"not_a_number",message:`Enter a number from ${bl} to ${kl}.`};const n=Number(t);return Number.isInteger(n)?n<bl?{ok:!1,reason:"too_low",message:`The lowest is ${bl}%.`}:n>kl?{ok:!1,reason:"too_high",message:`The highest is ${kl}%.`}:{ok:!0,value:String(n)}:{ok:!1,reason:"not_whole",message:`Use a whole number from ${bl} to ${kl}.`}}const rj={pick:null,custom:null,refusal:null};function Ooe(e,t){switch(t.kind){case"pick":return t.pick===i6?{...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 rj;case"leave":return e.custom&&(e.pick??t.stored)===t.stored?rj:e}}async function Poe(e,t,n){if(!t.sends)return{kind:"unchanged"};const s=Ioe(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 Doe({auto:e,threshold:t,thresholdPick:n,thresholdCtl:s,thresholdSaved:a,thresholdRef:o,thresholdSaveRef:i,thresholdCustom:l,thresholdRefusal:u,thresholdFieldRef:h,proposeThreshold:f,typeThreshold:p,cancelThreshold:m,leaveThreshold:w,doThreshold:v,nextPick:j,nextCtl:b,nextSaved:N,nextRef:x,nextSaveRef:S,proposeNext:C,doNext:_,pressProps:M,post:R,load:P}){const L=g.useId(),U=g.useId(),B=g.useId(),A=g.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",...M("enable"),onClick:()=>R({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:l?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"}),l?r.jsx("form",{className:"ap-threshold-form",noValidate:!0,onSubmit:q=>{q.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":L,"aria-invalid":u?!0:void 0,value:n,...M("threshold"),onChange:q=>p(q.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,...M("threshold"),onChange:q=>f(q.target.value),children:[Loe(t).map(q=>r.jsxs("option",{value:q,children:[q,"%"]},q)),r.jsx("option",{value:i6,children:"Custom…"})]})}),(s.sends||a)&&r.jsx("button",{ref:i,type:"button",className:"ap-manage-btn",...M("threshold"),title:s.title,onClick:()=>v(n,s),children:a&&!s.sends?s.done:s.label})]}),u?r.jsx("p",{id:L,className:"ap-threshold-note",role:"alert","data-tone":"err",children:u},"refusal"):l?r.jsx("p",{id:L,className:"ap-threshold-note",children:$oe},"hint"):null,r.jsxs("div",{className:"ap-policy ap-setting ap-next",children:[r.jsx("label",{className:"ap-setting-label",htmlFor:B,children:"Next account"}),r.jsx("span",{className:"ap-field",children:r.jsx("select",{id:B,ref:x,value:j,"aria-describedby":j==="weekly"?A:void 0,...M("next"),onChange:q=>C(q.target.value),children:Toe.map(q=>r.jsx("option",{value:q.value,children:q.label},q.value))})}),(b.sends||N)&&r.jsx("button",{ref:S,type:"button",className:"ap-manage-btn",...M("next"),title:b.title,onClick:()=>_(),children:N&&!b.sends?b.done:b.label})]}),j==="weekly"&&r.jsx("p",{id:A,className:"ap-threshold-note",children:Aoe}),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 aR=18,Foe=1100,ml=(e,t)=>{const n=Math.sin(e*12.9898+t*78.233)*43758.5453;return n-Math.floor(n)},Boe=Array.from({length:aR},(e,t)=>{const n=-72+144*t/(aR-1)+(ml(t,1)-.5)*9,s=(n-90)*(Math.PI/180),a=(54+32*Math.cos(n*Math.PI/180))*(.74+ml(t,2)*.52);return{dx:Math.cos(s)*a,dy:Math.sin(s)*a,rot:(t%2?1:-1)*(100+ml(t,3)*260),delay:Math.round(ml(t,4)*90),dur:760+Math.round(ml(t,5)*260),scale:.8+ml(t,6)*.45,hue:t%4,round:t%3===0}});function oR({anchor:e}){var a;const[t,n]=g.useState(null),s=typeof window<"u"&&((a=window.matchMedia)==null?void 0:a.call(window,"(prefers-reduced-motion: reduce)").matches);return g.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 l=window.setTimeout(()=>n(null),Foe);return()=>window.clearTimeout(l)},[e,s]),s||!t?null:kt.createPortal(r.jsx("div",{className:"confetti",style:{left:`${t.x}px`,top:`${t.y}px`},"aria-hidden":!0,children:Boe.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 kp=g.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"})]}));kp.displayName="SuccessMark";const qoe={done:", done",active:", in progress",failed:", failed",pending:""};function Uoe({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 Woe({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 l=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(Uoe,{status:i.status}),r.jsxs("span",{className:"aa-stage-label",children:[i.label,r.jsx("span",{className:"vis-hidden",children:qoe[i.status]})]}),l&&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 dw=["link","approve","confirm","save"],iR={confirm:"confirm",save:"save",restore:"save"};function l6(e){return e!=null&&Object.prototype.hasOwnProperty.call(iR,e)?iR[e]:null}function Hoe({state:e,step:t,starting:n}){return e==="registering"?l6(t)??"confirm":e==="awaiting_code"?"approve":e==="awaiting_url"||e==null&&n?"link":null}function zoe({state:e,step:t,url:n,lastLive:s}){return e==="failed"?l6(t)??(n?"approve":"link"):e==="idle"?s??"link":"link"}const Voe={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 Goe(e,t,n){return t==="failed"?c6(e,n):Voe[e][t]}function Koe({live:e=null,failed:t=null,done:n=!1,state:s=null}){const a=n?dw.length:dw.indexOf(t??e);return dw.map((o,i)=>{const l=n||i<a?"done":i>a||a<0?"pending":t?"failed":"active";return{id:o,status:l,label:Goe(o,l,s)}})}function Yoe(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 Xoe={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 c6(e,t){return t==="idle"?"Sign-in ended":Xoe[e]}const Zoe=/^(?:claude|claude-swap|cswap|ccdeck|npm|uv)\b/;function Of(e){const t=String(e??"").trim();if(!t)return"";const n=Zoe.test(t)?t:t[0].toUpperCase()+t.slice(1);return/[.!?…]$/.test(n)?n:`${n}.`}Of(t6);const Joe=1e4,Qoe=1e4,eie=5;function tie({since:e,now:t,expiresAt:n}){if(e==null||t-e<Joe)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<=eie?`${a} — the sign-in stays open ${s} more minute${s===1?"":"s"}.`:`${a}.`}function nie({since:e,now:t}){return e==null||t-e<Qoe?null:"Still importing. claude-swap stops by itself after a minute if it cannot finish."}function sie(e){return e==="registering"?400:1500}const u6=460;function rie({fromStages:e,reducedMotion:t}){return e&&!t?u6:0}function aie({added:e,reducedMotion:t}){return e&&!t}function lR({num:e,added:t}){return t?e!=null&&e!==""?`Account ${e} added`:"Account added":"Credentials refreshed"}function oie(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 iie="done";function lie(){let e=!1;return{shouldAnnounce(t){return t!==iie?(e=!1,!1):e?!1:(e=!0,!0)}}}function oS(e,t,n,s="horizontal"){if(n<=0||em(e))return{kind:"pass"};const a=t>=0&&t<n?t:-1,o=s==="vertical",i=e.key==="ArrowRight"||o&&e.key==="ArrowDown",l=e.key==="ArrowLeft"||o&&e.key==="ArrowUp";if(i)return{kind:"select",index:a===-1?0:(a+1)%n};if(l)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 d6(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 cie(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 uie(e,t){return e.filter(n=>!t.includes(n.num)).map(n=>n.num)}function die(e,t){return e.includes(t)?e.filter(n=>n!==t):[...e,t]}function hie(e){return e.length?{action:"share",accounts:[...e]}:null}function fie(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 aj(e){return`${e.email}|${e.org??""}`}function pie(e,t,n){return e&&e.map(s=>aj(s)===t?n:s)}function mie(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 cR(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 l=n("present");l&&s.push(`${l} already here`);const u=n("failed");u&&s.push(`${u} did not arrive`);const h=[...new Set(e.map(f=>{var p;return(p=vp(f.check))==null?void 0:p.short}).filter(f=>!!f))];return`${s.join(", ")}${h.length?`, ${h.join(", ")}`:""}.`}function gie(e){try{return e?new URL(e).host:""}catch{return""}}const ff=[{id:"login",label:"Sign in"},{id:"paste",label:"Paste a share"}],uR="aa-panel",dR=e=>`aa-tab-${e}`;async function zo(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}function h6({onClose:e,onChanged:t,email:n=null,onSignedIn:s}){sn("add-account");const[a,o]=g.useState("login"),[i,l]=g.useState(null),[u,h]=g.useState(""),[f,p]=g.useState(""),[m,w]=g.useState(!1),[v,j]=g.useState(!1),[b,N]=g.useState(null),[x,S]=g.useState(null),C=m||v,[_,M]=g.useState(null),[R,P]=g.useState(null),[L,U]=g.useState(null),B=g.useRef(""),A=g.useRef(!1),q=g.useRef(!1),T=g.useRef(null),F=g.useRef(null),O=g.useRef(null),K=g.useRef(null),V=g.useRef([]),H=g.useRef(!1),D=g.useRef(0),I=g.useRef(null),W=g.useRef("primer"),Z=g.useRef(null),z=g.useRef(null),X=g.useRef(null),Y=g.useRef(!1),J=g.useState(pd)[0],[Q,te]=g.useState(null),[le,de]=g.useState(!1),[oe,re]=g.useState(()=>Date.now()),[he,pe]=g.useState(null),[Le,ge]=g.useState(null),[ve,je]=g.useState(null),Ee=g.useCallback(()=>{const Me=QA({started:A.current,state:i==null?void 0:i.state});Me&&zo(Me).catch(()=>{}),e()},[e,i==null?void 0:i.state]),xe=gt(Ee,{focusRef:O}),Ie=yt(Ee),De=g.useCallback(async()=>{if(!Sn(q.current))return;const Me=++D.current;q.current=!0,w(!0),N(null),je(null),A.current=!0;let qe=await zo(n?{action:"login",email:n}:{action:"login"}).catch(()=>null);if(n&&(qe==null?void 0:qe.reason)==="bad_email"&&Me===D.current&&(qe=await zo({action:"login"}).catch(()=>null)),Me===D.current){if(q.current=!1,w(!1),!(qe!=null&&qe.ok)){N(Cl(qe,"could not start the sign-in"));return}l(qe)}},[n]);g.useEffect(()=>{if(!Q5(i==null?void 0:i.state))return;const Me=window.setInterval(async()=>{try{const qe=await fetch("/api/claude-accounts/login");qe.ok&&l(await qe.json())}catch{}},sie(i==null?void 0:i.state));return()=>window.clearInterval(Me)},[i]);const We=g.useCallback(async()=>{const Me=QA({started:A.current,state:i==null?void 0:i.state});if(D.current+=1,A.current=!1,q.current=!1,w(!1),N(null),l(null),h(""),de(!1),Y.current=!0,!Me)return;const qe=await zo(Me).catch(()=>null);je(JA({restored:qe==null?void 0:qe.restored,activeAccount:qe==null?void 0:qe.activeAccount}))},[i==null?void 0:i.state]),Ke=g.useCallback(()=>{A.current=!1,l(null),N(null),h(""),de(!1),De()},[De]),ye=g.useRef(t);ye.current=t;const Fe=g.useState(lie)[0];g.useEffect(()=>{Fe.shouldAnnounce(i==null?void 0:i.state)&&ye.current()},[i==null?void 0:i.state,Fe]),g.useEffect(()=>{var Me;le&&((Me=T.current)==null||Me.focus())},[le]);const $e=g.useRef(s);$e.current=s;const Re=g.useRef(null);g.useEffect(()=>{var Je;const Me=(i==null?void 0:i.state)==="done"?i.account:null,qe=Me?`${Me.num??""}|${Me.email}`:null;!Me||Re.current===qe||(Re.current=qe,(Je=$e.current)==null||Je.call($e,Me))},[i]),g.useEffect(()=>{var Me;a==="paste"&&!H.current&&((Me=F.current)==null||Me.focus()),H.current=!1},[a]);const rt=g.useCallback(Me=>{var Je;const qe=oS(Me,ff.findIndex(_t=>_t.id===a),ff.length);qe.kind!=="pass"&&(Me.preventDefault(),H.current=!0,o(ff[qe.index].id),(Je=V.current[qe.index])==null||Je.focus())},[a]),He=g.useCallback(async()=>{var Je;if(!Sn(q.current))return;const Me=D.current;q.current=!0,w(!0),N(null);const qe=await zo({action:"login-code",code:u}).catch(()=>null);if(Me===D.current){if(q.current=!1,w(!1),!(qe!=null&&qe.ok)){N(Cl(qe,"the code was not accepted")),qe!=null&&qe.state&&l(qe),(Je=T.current)==null||Je.select();return}h(""),l(qe)}},[u,i]),se=g.useCallback(async()=>{if(!Sn(q.current))return;q.current=!0,j(!0),S(null);const Me=await zo({action:"import",blob:f}).catch(()=>null);if(q.current=!1,j(!1),!(Me!=null&&Me.ok)){S(Cl(Me,"the import failed"));return}B.current=f,p(""),U(null),M(Me.results??[]),t()},[f,t]),ke=g.useCallback(async Me=>{const qe=aj(Me);if(!Sn(q.current)||!B.current)return;q.current=!0,j(!0),P(qe),U(null);const Je=await zo({action:"import",blob:B.current,force:!0,only:{email:Me.email,org:Me.org??""}}).catch(()=>null);if(q.current=!1,j(!1),P(null),!(Je!=null&&Je.ok)){U({key:qe,text:Cl(Je,"that account could not be updated")});return}const _t=(Je.results??[])[0];_t&&M(Nt=>pie(Nt,qe,_t)),t()},[t]),Ae=(i==null?void 0:i.state)==="done"?i.account:null,Oe=JA({restored:i==null?void 0:i.restored,activeAccount:i==null?void 0:i.activeAccount}),be=Oae({login:i,started:A.current,loginError:b,loginBusy:m}),fe=Iae({state:i==null?void 0:i.state,serverError:i==null?void 0:i.error,localError:b}),_e=be==="asking"||be==="code"?Hoe({state:i==null?void 0:i.state,step:i==null?void 0:i.step,starting:be==="asking"})??"link":null,Ve=be==="ended"?zoe({state:i==null?void 0:i.state,step:i==null?void 0:i.step,url:i==null?void 0:i.url,lastLive:I.current}):null,ot=Ae?`${Ae.num??""}|${Ae.email}`:null,tt=be==="done"&&ot!==Q&&rie({fromStages:W.current==="progress",reducedMotion:J})>0,wt=be==="primer"?"primer":be==="done"&&Ae&&!tt?"done":"progress",$t=Ve?"failed":tt?"resolving":"live",Vt=Koe(tt?{done:!0}:Ve?{failed:Ve,state:i==null?void 0:i.state}:{live:_e}),er=Ve?c6(Ve,i==null?void 0:i.state):"",Ss=Of(fe.message),Wn=_e==="approve"?tie({since:he,now:oe,expiresAt:i==null?void 0:i.expiresAt}):null,es=v?nie({since:Le,now:oe}):null,Cs=a==="login"?wt==="done"&&Ae?`${lR(Ae)}.`:$t==="failed"?`${er}. ${Ss}`:wt==="progress"&&!tt?oie(_e)??"":"":v?"Importing the share.":x?Of(x):_?Of(cR(_)):"";g.useEffect(()=>{_e&&(I.current=_e)},[_e]),g.useEffect(()=>{W.current=wt},[wt]),g.useEffect(()=>{if(!tt||!ot)return;const Me=window.setTimeout(()=>te(ot),u6);return()=>window.clearTimeout(Me)},[tt,ot]);const yn=_e==="approve";g.useEffect(()=>{pe(yn?Date.now():null)},[yn]),g.useEffect(()=>{ge(v?Date.now():null)},[v]);const Hn=yn||v;return g.useEffect(()=>{if(!Hn)return;re(Date.now());const Me=window.setInterval(()=>re(Date.now()),1e3);return()=>window.clearInterval(Me)},[Hn]),g.useEffect(()=>{var qe,Je,_t,Nt;if(a!=="login")return;if(wt==="done"){(qe=z.current)==null||qe.focus();return}if(wt==="primer"){Y.current&&((Je=O.current)==null||Je.focus()),Y.current=!1;return}if($t==="failed"){(_t=X.current)==null||_t.focus();return}const Me=document.activeElement;_e==="approve"&&(!Me||Me===document.body)&&((Nt=Z.current)==null||Nt.focus())},[a,wt,$t,_e]),kt.createPortal(r.jsx("div",{className:"modal-backdrop",...Ie,role:"presentation",children:r.jsxs("div",{ref:xe,className:"modal aa-modal",onClick:Me=>Me.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:rt,children:ff.map((Me,qe)=>r.jsx("button",{type:"button",role:"tab",id:dR(Me.id),ref:Je=>{V.current[qe]=Je},"aria-selected":a===Me.id,"aria-controls":uR,tabIndex:a===Me.id?0:-1,className:`aa-tab${a===Me.id?" on":""}`,onClick:()=>{H.current=!1,o(Me.id)},children:Me.label},Me.id))})}),r.jsx("div",{className:"modal-actions",children:r.jsx("button",{type:"button",className:"glyph-btn",onClick:Ee,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),r.jsxs("section",{className:"modal-body aa-body",id:uR,role:"tabpanel","aria-labelledby":dR(a),children:[a==="login"?wt==="done"&&Ae?r.jsxs("div",{className:`aa-done${Q===ot?" from-orbit":""}`,children:[r.jsx(kp,{ref:K}),aie({added:Ae.added,reducedMotion:J})&&r.jsx(oR,{anchor:K}),r.jsx("h4",{children:lR(Ae)}),r.jsxs("p",{className:"aa-note",children:[r.jsx("strong",{children:Ae.email}),Ae.added?Oe?" 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."]}),Oe?r.jsx("p",{className:"aa-note aa-warn",role:"status",children:Oe}):null,r.jsx("button",{type:"button",ref:z,className:"btn primary",onClick:Ee,children:"Done"})]}):wt==="progress"?r.jsx(Woe,{rows:Vt,phase:$t,detail:$t==="failed"?r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"aa-note aa-reason",children:Ss}),r.jsx("div",{className:"aa-actions",children:r.jsx("button",{type:"button",ref:X,className:"btn primary",onClick:Ke,children:Ve==="link"?"Try again":"Start over"})})]}):_e==="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:[gie(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"})})]})]}),Wn?r.jsx("p",{className:"aa-note aa-arrive",children:Wn}):null,r.jsxs("details",{className:"aa-code",open:le,onToggle:Me=>de(Me.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:T,type:"text",value:u,onChange:Me=>h(Me.target.value),onKeyDown:Me=>{Me.key==="Enter"&&u.trim()&&!C&&He()},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",...Fn(C,!u.trim()||i.state==="registering"),onClick:He,children:"Continue"})]}),(b||i.error)&&r.jsx("p",{className:"aa-err",children:b??i.error}),r.jsx("p",{className:"aa-note",children:"The code goes straight to the claude CLI on this machine. It is never stored or sent anywhere else."})]})]}):_e?r.jsx("p",{className:"aa-note",children:Yoe(_e,i==null?void 0:i.step)}):null,actions:_e==="link"||_e==="approve"?r.jsx("button",{type:"button",className:"btn",onClick:We,children:"Cancel"}):null}):r.jsxs("div",{className:"aa-step aa-primer",children:[ve?r.jsx("p",{className:"aa-note aa-warn",role:"status",children:ve}):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:O,className:"btn primary",...Fn(C),onClick:De,children:"Open the sign-in page"})})]}):_?(()=>{const Me=_.filter(Je=>Je.state==="imported").length,qe=_.some(Je=>vp(Je.check));return r.jsxs("div",{className:"aa-done",children:[!qe&&r.jsx(kp,{ref:K}),Me>0&&!qe&&r.jsx(oR,{anchor:K}),r.jsx("h4",{children:cR(_)}),_.length>0&&r.jsx("ul",{className:"aa-results",children:_.map(Je=>{const _t=aj(Je),Nt=vp(Je.check);return r.jsxs("li",{className:`aa-result ${Je.state}`,children:[r.jsx("span",{className:"aa-result-who",children:Je.email||(Je.num?`slot ${Je.num}`:"an account")}),r.jsx("span",{className:"aa-result-what",children:mie(Je.state)}),Je.state==="present"&&r.jsx("button",{type:"button",className:"aa-result-fix","aria-busy":R===_t,title:`Overwrite the stored login for ${Je.email} with the one in this share. Do this when that account has stopped working here; if it works, leave it.`,onClick:()=>ke(Je),children:R===_t?"updating…":"update anyway"}),Nt&&r.jsx("span",{className:"aa-result-err",children:Nt.long}),(L==null?void 0:L.key)===_t&&r.jsx("span",{className:"aa-result-err",children:L.text})]},_t)})}),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:Ee,children:"Done"}),r.jsx("button",{type:"button",className:"btn",onClick:()=>{B.current="",U(null),M(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:F,type:"text",value:f,onChange:Me=>p(Me.target.value),onKeyDown:Me=>{Me.key==="Enter"&&f.trim()&&!C&&se()},placeholder:"ccdeck2:…",spellCheck:!1,autoComplete:"off","aria-label":"Shared account"}),r.jsx("button",{type:"button",className:"btn primary",...Fn(C,!f.trim()),onClick:se,children:v?"importing…":"Import"})]}),x&&r.jsx("p",{className:"aa-err",children:x}),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:es??"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:Cs})]})]})}),document.body)}function yie(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 wie(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 xie=64;function vie(e,t){const n=e.trim();return{alias:n,commit:n!==(t??"").trim()}}function bie(e,t,n){return t!=null&&e.some(s=>s.slot===t)?t:n}function kie(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 jie(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 Nie(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 Sie({a:e,slots:t,nowSec:n,boundaryId:s,accountMenu:a,busy:o,pressProps:i,onProjects:l,onRotation:u,home:h,onHome:f}){const{menu:p,menuError:m,aliasDraft:w,confirmRemove:v,share:j,shareCopied:b,slotDraft:N,dropMenu:x,closeMenu:S,startRename:C,typeAlias:_,doAlias:M,startMove:R,pickSlot:P,doSlot:L,makeShare:U,copyShare:B,pressRemove:A}=a;if(!p)return null;const q=`ap-pop-title-${e.num}`,T=m&&r.jsx("p",{className:"ap-pop-error",role:"alert",title:m.raw||void 0,children:m.text});return r.jsxs(cm,{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}`:q,start:p.start,onClose:x,children:[p.view==="menu"&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",onClick:()=>C(e.num,e.alias),children:"Rename"}),r.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",onClick:()=>R(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 ${Pt}. 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:()=>l(),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:()=>u(),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:()=>A(e.num),children:o===`rm-${e.num}`?"Removing…":v===e.num?"Confirm":"Remove"}),T]}),p.view==="rename"&&r.jsxs("form",{className:"ap-pop-form",onSubmit:F=>{F.preventDefault(),M(e.num,e.alias)},children:[r.jsx("label",{className:"ap-pop-title",id:q,htmlFor:`ap-alias-${e.num}`,children:"Rename account"}),r.jsx("input",{id:`ap-alias-${e.num}`,className:"ap-manage-input",type:"text",value:w,onChange:F=>_(F.target.value),maxLength:xie,placeholder:"e.g. work",spellCheck:!1,autoComplete:"off",autoFocus:!0,onFocus:F=>F.currentTarget.select()}),T,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 F=yie(t,e.num),O=bie(F,N,e.num),K=kie(F,O,e.num);return r.jsxs("div",{className:"ap-pop-form",children:[r.jsx("label",{className:"ap-pop-title",id:q,htmlFor:`ap-slot-${e.num}`,children:"Move to slot"}),r.jsx("span",{className:"ap-field",children:r.jsx("select",{id:`ap-slot-${e.num}`,value:String(O),...i(`move-${e.num}`),onChange:V=>P(Number(V.target.value)),autoFocus:!0,children:F.map(V=>r.jsx("option",{value:V.slot,children:V.label},V.slot))})}),T,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:K.title,onClick:()=>L(e.num,O,K),children:o===`move-${e.num}`?"…":ku(K.label)})]})]})})(),p.view==="share"&&(j==null?void 0:j.num)===e.num&&(()=>{const F=d6(j.expiresAt,n),O=F.tone==="gone";return r.jsxs("div",{className:"ap-pop-form",children:[r.jsx("p",{className:"ap-pop-title",id:q,children:"Share account"}),r.jsx("code",{className:"ap-share-blob",children:j.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 ${F.tone}`,children:F.text})]}),T,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(O){await U(e.num);return}await B(j.blob)},children:O?"Make a new share":b?"Copied":"Copy"})]})]})})()]})}const Cie=6;function _ie(e,t){const n=e.filter(l=>l.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?Eie(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 Eie(e){const t=e.map(n=>n.headroom).filter(n=>typeof n=="number");return t.length?Math.round(Math.max(...t)):null}function Tie(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,l=o.headroom;return i==null&&l==null?a.name.localeCompare(o.name):i==null?1:l==null?-1:l-i}),n=t.slice(0,Cie),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 f6=160,p6=140;function Aie(){const[e,t]=g.useState(!1),n=g.useRef(0);return g.useEffect(()=>()=>window.clearTimeout(n.current),[]),{peek:e,openPeek:l=>{window.clearTimeout(n.current),n.current=window.setTimeout(()=>t(!0),l)},shutPeek:()=>{window.clearTimeout(n.current),n.current=window.setTimeout(()=>t(!1),p6)},holdPeek:()=>window.clearTimeout(n.current),dropPeek:()=>{window.clearTimeout(n.current),t(!1)}}}function Rie(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:Rie(t),done:!1}}async function Mie(){try{return await(await fetch("/api/prefs/give-back",{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"})).json().catch(()=>null)}catch{return null}}const $ie={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 Lie(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?$ie[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 oj=5e3,m6=6e4;function Xt(e,t){if(t==null)return`Could not ${e} — the deck did not answer.`;const n=t.reason?Pie(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 Iie={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."},Oie=new Set(["EACCES","EPERM"]);function Pie(e,t){const n=Iie[e];if(!n)return;const s=e==="prefs_unreadable"&&t?Die(t):void 0,a=t!=null&&t.code&&t.code!=="BADJSON"?` Error code: ${t.code}.`:"";return(s??n)+a}function Die({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&&!Oie.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 gl(e,t){return(await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).json().catch(()=>null)}function Fie(e,t){const[n,s]=g.useState(null),[a,o]=g.useState([]),[i,l]=g.useState(null),[u,h]=g.useState(null),f=g.useRef(null),p=g.useCallback(B=>rm(f.current)?(f.current=B,l(B),!0):!1,[]),m=g.useCallback(()=>{f.current=null,b.current&&l(null)},[]),w=B=>{const A=so(i,B);return{disabled:A.disabled,"aria-busy":A.busy}},[v,j]=g.useState(()=>Date.now()),b=g.useRef(!0),N=g.useRef(oj),x=g.useCallback(async()=>{var B,A;try{const[q,T]=await Promise.all([fetch("/api/lan").then(F=>F.json()),fetch("/api/prefs").then(F=>F.json())]);if(!b.current)return;q!=null&&q.ok&&s(q),T!=null&&T.ok&&o(Array.isArray((A=(B=T.prefs)==null?void 0:B.lan)==null?void 0:A.manual)?T.prefs.lan.manual:[]),N.current=(q==null?void 0:q.enabled)===!0?oj:m6}catch{}},[]);g.useEffect(()=>{b.current=!0;let B=0;const A=async()=>{j(Date.now()),await x(),b.current&&(B=window.setTimeout(A,N.current))};return A(),()=>{b.current=!1,window.clearTimeout(B)}},[x]);const S=g.useCallback(async()=>{const B=(n==null?void 0:n.enabled)===!0;if(p("switch"))try{const A=await gl("/api/prefs",{lan:{enabled:!B}});if(!b.current)return;A!=null&&A.ok?(h(null),B||t()):h(Hs(Xt(B?"turn this off":"turn this on",A),A)),await x()}catch{b.current&&h(Hs(Xt(B?"turn this off":"turn this on",null)))}finally{m()}},[n==null?void 0:n.enabled,x,p,m,t]),C=g.useCallback(async(B,A,q)=>{if(!p(`${B}:${A}`))return null;let T=null;try{const F=await gl("/api/lan/peer",{action:B,fp:A});if(!b.current)return null;F!=null&&F.ok?(s(F),h(null)):(T=Xt(q,F),h(Hs(T,F))),await x()}catch{T=Xt(q,null),b.current&&h(Hs(T))}finally{m()}return T},[x,p,m]),_=g.useCallback(async B=>{if(!p(`drop:${B}`))return null;let A=null;try{const q=await gl("/api/prefs",{lan:{manual:a.filter(T=>T!==B)}});if(!b.current)return null;q!=null&&q.ok?(h(null),e()):(A=Xt("stop dialling that address",q),h(Hs(A,q))),await x()}catch{A=Xt("stop dialling that address",null),b.current&&h(Hs(A))}finally{m()}return A},[a,x,e,p,m]),M=g.useCallback(async(B,A)=>{if(!p(`alias:${B}`))return"Something else is still being saved. Try again in a moment.";try{const q=await gl("/api/lan/peer",{action:"alias",fp:B,name:A});return b.current?q!=null&&q.ok?(s(q),null):Xt("rename that deck",q):null}catch{return Xt("rename that deck",null)}finally{m()}},[p,m]),R=g.useCallback(async B=>{if(!p(`check:${B}`))return null;try{const A=await gl("/api/lan/sync",{fp:B});return b.current?A!=null&&A.ok?(s(A),e(),null):(A==null?void 0:A.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.":Xt("check that deck",A):null}catch{return Xt("check that deck",null)}finally{m()}},[p,m,e]),P=g.useCallback(async()=>{if(p("check"))try{const B=await gl("/api/lan/sync",{});if(!b.current)return;B!=null&&B.ok?(s(B),h(null)):h(Hs(Xt("check the other decks",B),B)),e()}catch{b.current&&h(Hs(Xt("check the other decks",null)))}finally{m()}},[p,m,e]);return{status:n,manual:a,now:v,busy:i,failure:u,dismissFailure:()=>h(null),answerGiveBack:B=>{h(B),B.done&&(x(),e())},pressProps:w,load:x,toggle:S,answer:C,dropAddress:_,rename:M,checkOne:R,checkNow:P}}function Bie(e){const[t,n]=g.useState(null),s=g.useRef(0);return g.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(),l=yi({armedFor:t,target:o.fp,armedAt:s.current,now:i,gapMs:gi});if(l==="arm"){n(o.fp),s.current=i;return}l!=="ignore"&&(n(null),e("unpair",o.fp,"unpair that deck"))}}}function g6({title:e,steps:t,finish:n,aside:s,onClose:a}){const o=g.useRef(null),i=gt(a,{focusRef:o}),l=yt(a),[u,h]=g.useState(0),f=u===t.length-1,p=t[u],m=j=>h(Math.max(0,Math.min(t.length-1,j)));g.useEffect(()=>{var j,b;Un(((j=document.activeElement)==null?void 0:j.tagName)??null)&&((b=o.current)==null||b.focus())},[u]);const w=j=>{j.key!=="ArrowRight"&&j.key!=="ArrowLeft"||(j.preventDefault(),j.stopPropagation(),m(j.key==="ArrowRight"?u+1:u-1))},v=()=>{if(!f){m(u+1);return}n?n.act():a()};return kt.createPortal(r.jsx("div",{className:"modal-backdrop",...l,role:"presentation",children:r.jsxs("div",{ref:i,className:"modal guide",onClick:j=>j.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:[u+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},u),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((j,b)=>r.jsx("button",{type:"button",className:"glyph-btn guide-dot","aria-label":`Step ${b+1} of ${t.length}`,"aria-current":b===u?"step":void 0,onClick:()=>m(b)},b))}),f&&s&&r.jsx("button",{type:"button",className:"ap-lan-word guide-aside",onClick:s.act,children:s.label}),u>0&&r.jsx("button",{type:"button",className:"btn",onClick:()=>m(u-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 ij={ok:"ga-ok",warn:"ga-warn",accent:"ga-accent",flight:"ga-flight"};function ks({children:e}){return r.jsx("svg",{className:"guide-art",viewBox:"0 0 440 200","aria-hidden":!0,focusable:"false",children:e})}function bs({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:ij[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 ${ij[a]}`,children:s}),o==null?void 0:o.map((i,l)=>r.jsxs("g",{children:[r.jsx("text",{x:e,y:t+40+l*18,className:"ga-s",children:l?"7d":"5h"}),r.jsx("rect",{x:e+22,y:t+35+l*18,width:96,height:4,rx:2,className:"ga-track"}),r.jsx("rect",{x:e+22,y:t+35+l*18,width:96*i/100,height:4,rx:2,className:"ga-accent"}),r.jsxs("text",{x:e+148,y:t+40+l*18,className:"ga-s ga-accent",textAnchor:"end",children:[i,"%"]})]},l))]})}function y6({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 pf({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 hR({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 fR({x:e,y:t,d:n}){return r.jsx("path",{d:n,transform:`translate(${e} ${t})`,className:"ga-glyph"})}function iS({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 lS(){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 _l({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:ij[o]}),r.jsx("text",{x:e+16,y:t+17,className:"ga-t ga-strong",children:s}),r.jsx("text",{x:e+16,y:t+31,className:"ga-s",children:a})]})}function Dl({x:e,y:t,label:n,live:s}){return r.jsxs(r.Fragment,{children:[r.jsx("rect",{x:e,y:t,width:46,height:20,rx:10,className:s?"ga-chip-live":"ga-chip"}),r.jsx("text",{x:e+23,y:t+14,className:"ga-s ga-mono",textAnchor:"middle",children:n})]})}function jp({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(y6,{x:e+118,y:t-13,on:!0})]})}function qie(){return r.jsxs(ks,{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 Uie(){return r.jsxs(ks,{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(_l,{x:20,y:80,w:116,title:"main",sub:"Opus 5 · 9 tools",tone:"accent"}),r.jsx(_l,{x:196,y:18,w:112,title:"explore",sub:"Haiku · 14 tools",tone:"flight"}),r.jsx(_l,{x:196,y:80,w:112,title:"tests",sub:"Sonnet · 6 tools",tone:"flight"}),r.jsx(_l,{x:196,y:142,w:112,title:"review",sub:"done · 38s",tone:"ok"}),r.jsx(Dl,{x:326,y:28,label:"Read"}),r.jsx(Dl,{x:380,y:28,label:"Grep",live:!0}),r.jsx(Dl,{x:326,y:90,label:"Bash",live:!0})]})}function pR({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 Wie(){return r.jsxs(ks,{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(pR,{x:216,y:80,label:"5-hour window",pct:24,note:"resets in 53m"}),r.jsx(pR,{x:216,y:124,label:"7-day window",pct:61,note:"resets in 4d"})]})}function Hie(){return r.jsxs(ks,{children:[r.jsx("rect",{x:14,y:40,width:172,height:120,rx:10,className:"ga-canvas"}),r.jsx(_l,{x:30,y:80,w:140,title:"tests",sub:"Sonnet 5 · 6 tools",tone:"flight"}),r.jsx(iS,{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(bs,{x:200,y:22,w:226,h:160}),r.jsx("text",{x:214,y:46,className:"ga-t ga-strong",children:"tests"}),r.jsx("text",{x:412,y:46,className:"ga-s",textAnchor:"end",children:"Sonnet 5 · 38s"}),r.jsx("line",{x1:200,y1:56,x2:426,y2:56,className:"ga-line"}),r.jsx("text",{x:214,y:76,className:"ga-cap",children:"PROMPT"}),r.jsx("text",{x:214,y:92,className:"ga-t",children:"Run the suite and fix what fails"}),r.jsx("text",{x:214,y:116,className:"ga-cap",children:"TOOLS · 6"}),r.jsx(Dl,{x:214,y:122,label:"Read"}),r.jsx(Dl,{x:266,y:122,label:"Edit"}),r.jsx(Dl,{x:318,y:122,label:"Bash",live:!0}),r.jsx("text",{x:214,y:164,className:"ga-cap",children:"TOKENS"}),r.jsx("text",{x:214,y:178,className:"ga-s ga-mono",children:"41k in · 2.1k out · $0.12"})]})}function zie(){const e=[18,24,28,14,22,26,30,16,24,28,20,26];return r.jsxs(ks,{children:[r.jsx(bs,{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 Vie(){return r.jsxs(ks,{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(_l,{x:278,y:80,w:120,title:"my-project",sub:"Opus 5 · live",tone:"accent"})})]})}function Gie(){return r.jsxs(ks,{children:[r.jsx(bs,{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(fR,{x:196,y:33,d:"M7 2.2v9.6M2.2 7h9.6"}),r.jsx(fR,{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(iS,{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(bs,{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 Kie(){return r.jsxs(ks,{children:[r.jsx(bs,{x:14,label:"THIS MACHINE"}),r.jsx(jp,{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(bs,{x:250,label:"ANOTHER MACHINE"}),r.jsx(jp,{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(lS,{})})]})}const Yie=[{art:r.jsx(qie,{}),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(Uie,{}),line:"Every agent and subagent is a node. Tool calls light up as they run."},{art:r.jsx(Hie,{}),line:"Double-click any node: its prompt, every tool call, tokens and timing."},{art:r.jsx(Wie,{}),line:"What each session costs, and how much quota is left."},{art:r.jsx(zie,{}),line:"Cores, memory and heat while the agents run, and what is hogging them."},{art:r.jsx(Gie,{}),line:"Several Claude accounts: switch, add one, share one to another machine."},{art:r.jsx(Kie,{}),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(Vie,{}),line:"Run claude or codex in any folder. It shows up here on its own."}];function Xie(){return r.jsxs(ks,{children:[r.jsx(bs,{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(bs,{x:250,label:"ANOTHER MACHINE"}),r.jsx(Xs,{x:264,y:64,email:"work@team.dev",state:"working",tone:"ok",bars:[24,61]})]})}function Zie(){return r.jsxs(ks,{children:[r.jsx(bs,{x:14,label:"THIS MACHINE"}),r.jsx(jp,{x:28,y:60}),r.jsx(pf,{x:28,y:92,name:"Ana's MacBook"}),r.jsx(pf,{x:28,y:114,name:"Dorin's PC"}),r.jsx(bs,{x:250,label:"ANOTHER MACHINE"}),r.jsx(jp,{x:264,y:60}),r.jsx(pf,{x:264,y:92,name:"Your MacBook"}),r.jsx(pf,{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 Jie(){return r.jsxs(ks,{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(hR,{x:106,y:88,on:!0}),r.jsx("text",{x:126,y:98,className:"ga-t ga-mono",children:"work@team.dev"}),r.jsx(hR,{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(y6,{x:304,y:157,on:!0}),r.jsx(iS,{x:115,y:97})]})}function Qie(){return r.jsxs(ks,{children:[r.jsx(bs,{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(bs,{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(lS,{})})]})}const ele=[{art:r.jsx(Xie,{}),line:"A login can expire on one machine while it still works on another."},{art:r.jsx(Zie,{}),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(Jie,{}),line:"Tick which logins this machine may hand out. Nothing is shared until you do."},{art:r.jsx(Qie,{}),line:"An expired login is copied from a paired machine within a minute."}];function tle(){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(lS,{})})]})}const nle={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."},sle=1600;function w6({reach:e,where:t}){const[n,s]=g.useState(!1),a=g.useRef(!0);g.useEffect(()=>()=>{a.current=!1},[]);const o=(e==null?void 0:e.steps)??[],i=g.useCallback(async()=>{await ho(o.join(`
|
|
103
|
+
`))&&a.current&&(s(!0),window.setTimeout(()=>{a.current&&s(!1)},sle))},[o]);if(!(e!=null&&e.blocked))return null;const l=e.shell==="sh",u=!!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:nle[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:[u?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."}):l?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(`
|
|
104
|
+
`)})}),r.jsx("button",{type:"button",className:"ap-manage-btn",onClick:()=>void i(),title:l?"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 rle(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 ale(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 hw(e,t){return(await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).json().catch(()=>null)}const ole={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."},ile={not_running:"This deck is not on the network yet. Turn Local network on, then make one."};function mR(e,t,n){return(t==null?void 0:t.reason)&&e[t.reason]||Xt(n,t)}function lle({status:e,manual:t,startWith:n,onClose:s,onChanged:a}){const o=g.useRef(null),i=g.useRef(null),l=g.useRef(null),u=g.useRef(null),h=e.pairingMode==="invite",f=gt(s,{focusRef:h?i:o}),p=yt(s),[m,w]=g.useState(""),[v,j]=g.useState(""),[b,N]=g.useState(null),[x,S]=g.useState(null),[C,_]=g.useState(null),[M,R]=g.useState(null),[P,L]=g.useState(()=>Date.now());g.useEffect(()=>{const Y=window.setInterval(()=>L(Date.now()),1e3);return()=>window.clearInterval(Y)},[]);const U=g.useRef(!0);g.useEffect(()=>()=>{U.current=!1},[]);const B=g.useRef(null),A=g.useRef(null),q=g.useCallback(Y=>rm(B.current)?(B.current=Y,_(Y),!0):!1,[]),T=g.useCallback(()=>{B.current=null,U.current&&_(null)},[]),F=Y=>{const J=so(C,Y);return{disabled:J.disabled,"aria-busy":J.busy}},O=Y=>(b==null?void 0:b.field)===Y?{"aria-invalid":!0,"aria-describedby":"lan-add-failure"}:{},K=Y=>N(J=>J&&J.field===Y?null:J),V=g.useCallback(async()=>{if(h)return;const Y=rle(m);if(!Y){N({text:cle(m),field:"addr"});return}const J=`${Y.addr}:${Y.port}`,Q=e.peers.find(te=>te.addr===Y.addr&&te.port===Y.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(q("add"))try{const te=await hw("/api/prefs",{lan:{manual:[...t,J]}});if(!U.current)return;te!=null&&te.ok?(N(null),w(""),a(),s()):N({text:Xt("add that address",te),field:"addr"})}catch{U.current&&N({text:Xt("add that address",null),field:"addr"})}finally{T()}},[m,h,t,e.peers,a,s,q,T]),H=g.useCallback(async Y=>{if(!q(`invite:${Y}`))return;const J=Y==="make"?"make an invite":"cancel that invite";try{const Q=await hw("/api/lan/invite",{action:Y});if(!U.current)return;Q!=null&&Q.ok?(A.current=Y,N(null),S(null),a()):N({text:mR(ile,Q,J)})}catch{U.current&&N({text:Xt(J,null)})}finally{T()}},[a,q,T]),D=g.useCallback(async()=>{const Y=v.trim();if(!(!Y||!q("join"))){R(null);try{const J=await hw("/api/lan/invite",{action:"join",token:Y});if(!U.current)return;J!=null&&J.ok?(j(""),N(null),a(),s()):(J==null?void 0:J.reason)==="unreachable"&&Array.isArray(J.tried)&&J.tried.length?(R(J.tried),N(null)):(R(null),N({text:mR(ole,J,"use that invite"),field:"join"}))}catch{U.current&&N({text:Xt("use that invite",null),field:"join"})}finally{T()}}},[v,a,s,q,T]),I=g.useCallback(async(Y,J)=>{try{await navigator.clipboard.writeText(Y),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=g.useRef(!1);g.useEffect(()=>{n!=="invite"||Z.current||W||(Z.current=!0,H("make"))},[n,W,H]);const z=g.useRef(!1);g.useEffect(()=>{var Y;n!=="invite"||z.current||!W||(z.current=!0,(Y=l.current)==null||Y.focus())},[n,W]),g.useEffect(()=>{var J,Q;const Y=A.current;!Y||Y==="make"!=!!W||(A.current=null,Un(((J=document.activeElement)==null?void 0:J.tagName)??null)&&((Q=(Y==="make"?l:u).current)==null||Q.focus()))},[W]);const X=e.port!=null?(e.addrs??[]).map(Y=>`${Y}:${e.port}`):[];return kt.createPortal(r.jsx("div",{className:"modal-backdrop",...p,role:"presentation",children:r.jsxs("div",{ref:f,className:"modal lan-add",onClick:Y=>Y.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-add-title",children:[r.jsxs("header",{className:"modal-head",children:[r.jsx("div",{className:"modal-title",children:r.jsx("span",{id:"lan-add-title",className:"modal-tool-name",children:"Add a deck"})}),r.jsx("div",{className:"modal-actions",children:r.jsx("button",{className:"glyph-btn",onClick:s,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),r.jsxs("section",{className:"modal-body",children:[b&&r.jsxs("div",{className:"ap-failure",role:"alert",children:[r.jsx("span",{id:"lan-add-failure",className:"ap-failure-text",children:b.text}),r.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>N(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),r.jsx(w6,{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,...O("addr"),onChange:Y=>{w(Y.target.value),K("addr")},onKeyDown:Y=>{Y.key==="Enter"&&V()}}),m.trim()!==""&&r.jsx("button",{type:"button",className:"ap-manage-btn",...F("add"),onClick:()=>void V(),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&&X.length>0&&r.jsxs("p",{className:"lan-note",children:["They type this deck’s own address into the same field on theirs:"," ",X.map((Y,J)=>r.jsxs("span",{children:[J>0&&" or ",r.jsx("code",{className:"ap-lan-code",children:Y})]},Y)),r.jsx("button",{type:"button",className:"ap-lan-word lan-copy",...F("copy:mine"),onClick:()=>void I(X.join(" "),"mine"),title:"Copy this deck's address, to send to whoever is adding it",children:x==="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:u,...F("invite:make"),onClick:()=>void H("make"),title:"One piece of text you send them. They paste it, and the two decks pair — nobody has to press anything here.",children:C==="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,...O("join"),onChange:Y=>{j(Y.target.value),R(null),K("join")},onKeyDown:Y=>{Y.key==="Enter"&&D()}}),v.trim()!==""&&r.jsx("button",{type:"button",className:"ap-manage-btn",...F("join"),onClick:()=>void D(),title:"Reach that deck and pair with it. Nobody has to press anything there.",children:C==="join"?"joining…":"join"})]}),r.jsx("p",{className:"lan-note",children:"Pasting one pairs both decks on the spot — nobody has to accept."}),M&&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."}),M.map(Y=>r.jsxs("span",{className:"ap-lan-tried-row",children:[r.jsx("code",{className:"ap-lan-code",children:Y.addr}),r.jsx("span",{className:"ap-lan-bad",children:Y.why})]},Y.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:[ale(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:l,...F("copy:invite"),"aria-label":x==="invite"?"Invite copied":"Copy invite","aria-describedby":"lan-invite-left",onClick:()=>void I(W.token,"invite"),title:"Copy it, and send it however you already talk to them",children:x==="invite"?"copied":"copy"}),r.jsx("button",{type:"button",className:"ap-manage-btn",...F("invite:withdraw"),onClick:()=>void H("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 cle(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 ule({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 dle({rows:e,pairingMode:t,armed:n,pressProps:s,answer:a,dropAddress:o,onUnpair:i,onOpenPeer:l,onInvite:u}){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:()=>l(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:u,"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 hle(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 fle({on:e,status:t}){return r.jsxs(r.Fragment,{children:[e&&r.jsx(w6,{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:hle(t)})]})}const gR=["online","offline","loose"],ple={online:0,offline:1,loose:2};function mle(e){return e.kind==="declined"?null:e.kind==="paired"?e.here?"online":"offline":"loose"}const gle=76,yle=62,Np=96,wle={1:[.62],2:[.58,1],3:[.42,.72,1]},xle=.2,vle=.16,ble=.05,kle=20,jle=17,mf=7,Nle=30,Sle=116,Cle=6.6,_le=6,Ele=e=>cS(e,null),Tle=1.5,Ale=80,Rle=.45,yR=40,Mle=64,$le=150,wR=.3,xR=84,vR=8,Lle=1.3,Sp=6,Ile=5.94,bR=7,kR=16,hu=4,jR=.16;function lj(e,t){return Math.PI*(3*(e+t)-Math.sqrt((3*e+t)*(e+3*t)))}function x6(e,t){return t<-Math.abs(e)*.6?"top":"bottom"}function Ole(e,t){if(e<=2)return t%2===0?0:90;const n=360/e;return-90+(t%2===0?0:n/2)}function Ple(e){return e.map((t,n)=>({...t,i:n})).sort((t,n)=>gR.indexOf(t.tier)-gR.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 NR(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 Dle(e,t,n){const s=[...wle[e.length]??[]];for(let a=0;a<s.length;a++){const o=e[a];if(o<2)continue;const i=lj(t*s[a],n*s[a])/o;if(!(i>0)||i>=Np)continue;const l=a+1<s.length?s[a+1]-xle:1;s[a]=Math.max(s[a],Math.min(l,s[a]*(Np/i)*1.02))}return s}const Yo=(e,t)=>e.x0<t.x1&&t.x0<e.x1&&e.y0<t.y1&&t.y0<e.y1,fw={h:16,ch:6.1,maxW:100};function Fle(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 v6(e,t,n,s,a,o){const i=t==="loose"?jle:kle,l=!a||e.kind==="asks",u=l?Nle:fw.h,h=a?fw.ch:Cle,f=l?o.length:0,p=Math.min(a?fw.maxW:Sle,Math.max(2*i,k6(e).length*h,f*_le)),m={x0:n-i,y0:s-i,x1:n+i,y1:s+i},w=x6(n,s)==="top"?{x0:n-p/2,y0:s-i-mf-u,x1:n+p/2,y1:s-i-mf}:{x0:n-p/2,y0:s+i+mf,x1:n+p/2,y1:s+i+mf+u};return[m,w]}const cj=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]},gf=(e,t)=>((e-t)%360+540)%360-180;function SR(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]=cj(f);return v6(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*Tle,v=s.get(f.ring),j=(f.count>2?360/f.count:f.turn)*Rle,b=v[(f.index+1)%f.count],N=v[(f.index-1+f.count)%f.count];return!(b===f||(p>0?gf(b.theta,w)>=j:gf(w,N.theta)>=j))||w<f.lo||w>f.hi?!1:(f.theta=w,!0)},i=([f,p],[m,w])=>Yo(p,m)||Yo(w,f)||Yo(p,w)||Yo(f,m),l=([f,p])=>Yo(f,n)||Yo(p,n);for(let f=0;f<Ale;f++){const p=a();let m=!1;for(let w=0;w<e.length;w++){l(p[w])&&(m=o(e[w],gf(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 j=e[w],b=e[v],N=b.ring.ring>j.ring.ring||b.ring===j.ring&&v>w?b:j,x=N===b?j:b,S=gf(N.theta,x.theta)>=0?1:-1;m=o(N,S)||o(x,-S)||m}}if(!m)break}const u=a();let h=0;for(let f=0;f<u.length;f++){l(u[f])&&h++;for(let p=f+1;p<u.length;p++)i(u[f],u[p])&&h++}return h}const Ble={online:0,offline:1,loose:1};function qle(e,t,n,s="",a=Ele){const o=[];for(const i of[!0,!1]){const l=CR(e,t,n,s,ple,a,i);if(l.clashes===0)return l.named();if(o.push(l),l.layout.rings.length===3){const u=CR(e,t,n,s,Ble,a,i),h={clashes:u.clashes,named:()=>({...u.named(),folded:!0})};if(h.clashes===0)return h.named();o.push(h)}if(!l.layout.zone)break}return o.reduce((i,l)=>l.clashes<i.clashes?l:i).named()}function CR(e,t,n,s,a,o,i=!0){const l=new Map;for(const q of e){const T=mle(q);if(!T)continue;const F=a[T];l.has(F)||l.set(F,[]),l.get(F).push({row:q,tier:T})}const u=[...l.keys()].sort((q,T)=>q-T),h=Math.max(0,t/2-gle),f=Math.max(0,n/2-yle),p=Dle(u.map(q=>l.get(q).length),h,f),m=u.map((q,T)=>({ring:q,rx:h*p[T],ry:f*p[T],count:l.get(q).length})),w=m.reduce((q,T)=>q+T.count,0),v=q=>q.row.via==="tailscale",j=[...l.values()].flat().filter(v).length,b=Math.max(0,...m.map(q=>{const T=l.get(q.ring).filter(v).length,F=lj(q.rx,q.ry);return T>0&&F>0?T*Np*Lle/F*360:0})),N=i&&j>0&&j<w?Math.min($le,Math.max(Mle,j/w*360,b)):0,x=yR-N/2,S=yR+N/2,C=[];let _=!1;m.forEach((q,T)=>{const F=Ple(l.get(q.ring)),O=F.length,K=O>1&&lj(q.rx,q.ry)/O<Np;K&&(_=!0);const V=T===m.length-1,H=V?-jR*(p[T]-(p[T-1]??0)):jR*(p[T+1]-p[T]),D=N>0?[{members:F.filter(W=>W.row.via!=="tailscale"),from:S,width:360-N},{members:F.filter(W=>W.row.via==="tailscale"),from:x+360,width:N}]:[{members:F,from:null,width:360}];let I=0;for(const W of D){const Z=W.members.length;if(Z===0)continue;const z=W.width/Z,X=Z>2;W.members.forEach(({row:Y,tier:J},Q)=>{const te=Ws(Y),le=W.from==null?Ole(Z,T)+z*Q:W.from+z*(Q+.5),de=X?NR(te,1)*vle*z:0,oe=K&&I%2===1?1+H/p[T]:1,re=X?NR(te,2)*ble:0,he=z*.3;C.push({row:Y,tier:J,ring:q,index:I,count:O,theta:le+de,reach:oe*(1+(V?-Math.abs(re):re)),lo:W.from==null?-1/0:W.from+he,hi:W.from==null?1/0:W.from+W.width-he,turn:z,caption:o(Y)}),I++})}});const M=Fle(s);let R=SR(C,_,M);R>0&&!_&&(_=!0,R=SR(C,!0,M));const P=C.map((q,T)=>{const[F,O]=cj(q);return{row:q.row,tier:q.tier,ring:q.ring.ring,x:F,y:O,angle:Ule(Math.atan2(O,F)*180/Math.PI),dist:Math.hypot(F,O),side:x6(F,O),order:T}}),L=m.reduce((q,T,F)=>l.get(T.ring).some(v)?Math.max(q,p[F]):q,0),U=q=>({from:x,to:S,inner:{rx:h*wR,ry:f*wR},outer:{rx:Math.min(t/2-8,h*L+q),ry:Math.min(n/2-8,f*L+q)},count:j}),B={nodes:P,rings:m,dense:_,zone:N>0?{...U(xR),labelAt:null}:null};return{layout:B,clashes:R,named:()=>{if(!B.zone)return B;const q=C.flatMap(O=>{const[K,V]=cj(O);return v6(O.row,O.tier,K,V,_,O.caption)});let T={...B.zone,labelAt:_R(B.zone,q)},F=T.outer;for(let O=xR+vR;T.labelAt==null;O+=vR){const K=U(O);if(K.outer.rx===F.rx&&K.outer.ry===F.ry)break;F=K.outer;const V=_R(K,q);V!=null&&(T={...K,labelAt:V})}return{...B,zone:T}}}}function b6(e){return`Tailscale · ${e} deck${e===1?"":"s"}`}function _R(e,t){const n={rx:e.outer.rx-Sp,ry:e.outer.ry-Sp};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 x=e.to;x>=e.from;x-=s){const S=x*Math.PI/180;a.push([Math.cos(S)*n.rx,Math.sin(S)*n.ry])}const o=bR+hu,i={x0:Math.min(...a.map(x=>x[0]))-o,x1:Math.max(...a.map(x=>x[0]))+o,y0:Math.min(...a.map(x=>x[1]))-o,y1:Math.max(...a.map(x=>x[1]))+o},l=t.map(x=>({x0:x.x0-hu,y0:x.y0-hu,x1:x.x1+hu,y1:x.y1+hu})).filter(x=>Yo(x,i)),u=(x,S)=>l.some(C=>x>C.x0&&x<C.x1&&S>C.y0&&S<C.y1),h=[],f=[];let p=0;a.forEach(([x,S],C)=>{C>0&&(p+=Math.hypot(x-a[C-1][0],S-a[C-1][1]));const _=Math.hypot(x,S)||1;let M=!1;for(let R=0;R<=bR&&!M;R+=1.75)M=u(x-x/_*R,S-S/_*R);h.push(p),f.push((f.at(-1)??0)+(M?1:0))});const m=b6(e.count).length*Ile/2,w=m+kR,v=p-m-kR;if(!(p>0)||v<w)return null;const j=x=>{let S=0,C=h.length;for(;S<C;){const _=S+C>>1;h[_]<x?S=_+1:C=_}return S},b=x=>{const S=j(x-m),C=j(x+m+1e-9)-1;return C<S||f[C]-(S>0?f[S-1]:0)===0},N=p/2;for(let x=0;N-x>=w;x+=2)for(const S of x===0?[N]:[N-x,N+x])if(b(S))return S/p;return null}function Ule(e){return(e%360+360)%360}function Wle(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 Hle(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 cS(e,t){switch(e.kind){case"asks":return"wants to pair";case"nearby":return e.state;case"dialling":return j6(e)?`${e.name.slice(e.addr.length)} · dialling`:"dialling";case"declined":return"declined";case"paired":{if(e.here)return t?zle(t):"online";const n=S6(e);return n?n==="now"?"away · just now":`away · ${n}`:e.state.startsWith("one-way")?"has not called yet":"away"}}}function k6(e){return j6(e)?e.addr:e.name}function j6(e){return e.kind==="dialling"&&!!e.addr&&e.name.startsWith(`${e.addr}:`)}function N6(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=S6(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 S6(e){var t;return((t=/last online (.+)$/.exec(e.state))==null?void 0:t[1])??null}function zle(e){return e.trim().split(/\s+/).slice(0,2).join(" ")}function Vle(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 Gle(e,t){if(e==null)return t;const n=((t-e)%360+540)%360-180;return e+n}function Kle(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} ${C6}`:e.nearby===1?`${n} Open it to ask to pair.`:`${n} Open one to ask to pair.`}return null}const C6="This deck pairs by invite only. Send one from Add a deck.";function Yle(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"?C6:"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 Xle(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 Zle(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 Jle(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 Qle(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 ece(e,t,n,s=null){var u;const a=new Map;for(const h of t)(u=a.get(h.key))!=null&&u.alive||a.set(h.key,h);const o=new Set(n),i=[],l=new Set;for(const h of e??[]){if(l.has(h.key))continue;l.add(h.key);const f=a.get(h.key)??null,p=o.has(h.key),m=Qle(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||l.has(h)||(l.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 tce=1e3;function nce(e,t){const n=new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),s=xr(e,t);return`${n} · ${s==="now"?"just now":s}`}function uj(e){return e&&[e.version,e.os,e.arch].filter(Boolean).join(" · ")||null}const _6={works:"works here",expired:"expired here",missing:"not on this deck",unavailable:"cannot share here",inUse:"in use here"},E6={works:"works there",broken:"broken there",unavailable:"cannot share there",unknown:"not offered by that deck",inUse:"in use there"};function T6(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`${_6[e.here]}, ${E6[e.there]}, ${t}${n}.`}function A6({row:e,source:t,status:n,accounts:s,now:a}){var J,Q,te,le,de;const{peer:o,stranger:i}=t,l=e.kind==="paired",u=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=l?o!=null&&o.waiting?o.lastSeen!=null?"not said — it runs an older version":"not said yet — it says when it next calls":o!=null&&o.offers?"not said — it runs an older version":"not reached yet":"shown once paired",j=uj(n.about),b=uj(m),N=m!=null&&m.version&&w?Jle(m.version,w):null,x=o?bm(o.last,a):null,S=o&&((Q=o.last)!=null&&Q.error)?toe({error:o.last.error,host:o.addr,port:o.port},[...n.strangers??[],...n.pending??[],...(n.peers??[]).filter(oe=>!oe.manual&&oe.addr).map(oe=>({fp:oe.fp,name:oe.name,addr:oe.addr,port:oe.port,at:oe.lastSeen??0}))],a):null,C=(te=o==null?void 0:o.last)!=null&&te.error&&x&&x.text!==o.last.error?o.last.error:null,_=((le=o==null?void 0:o.last)==null?void 0:le.done)??[],M=!!x&&!!C&&!e.quiet&&e.state.startsWith(x.text),R=l||e.kind==="dialling",P=((o==null?void 0:o.via)??e.via)==="tailscale",L=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":l?e.here?"up":"down":"loose",B=(o==null?void 0:o.offers)??null,A=U==="up"?(B==null?void 0:B.current)??null:null,q=A&&"key"in A?A.key:null,T=!!A&&"hidden"in A,F=!!A&&"other"in A,O=(n.shared??[]).filter(oe=>{var re;return!((re=o==null?void 0:o.notOffered)!=null&&re.includes(oe))}),K=l?ece((B==null?void 0:B.accounts)??null,s,O,q):[],V=K.filter(oe=>oe.in==null&&oe.out==="cut"&&oe.here!=="inUse"),H=K.some(oe=>oe.in!=null),D=K.some(oe=>oe.out!=null),I=new Set((n.peers??[]).filter(oe=>oe.paired).flatMap(oe=>oe.notOffered??[])),W=K.some(oe=>oe.out!=null&&I.has(oe.key))?"decks you chose":"every paired deck",Z=new Map(_.map(oe=>[oe.email,oe])),z=_.filter(oe=>!K.some(re=>re.email===oe.email)),X=l?B?B.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.":(de=o==null?void 0:o.last)!=null&&de.error?"What that deck offers is not known — the last attempt to ask it did not get through.":"Nobody has asked that deck what it offers yet. The next round asks it.":null,Y=B&&(o!=null&&o.last)&&o.last.at-B.at>tce?xr(B.at,a):null;return{peer:o,stranger:i,paired:l,own:u,canRename:h,fp:f,where:p,about:m,unsaid:v,hereRuns:j,thereRuns:b,order:N,line:x,silence:S,raw:C,echoed:M,showRound:R,how:L,link:U,hiddenThere:T,otherThere:F,lanes:K,spent:V,taking:H,giving:D,givenTo:W,told:Z,unplaced:z,unknown:X,stale:Y}}function dj(){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 yf({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 sce({view:e,row:t,status:n,asking:s,drawn:a,onSettings:o}){const{peer:i,paired:l,where:u,about:h,unsaid:f,hereRuns:p,thereRuns:m,order:w,line:v,silence:j,raw:b,echoed:N,showRound:x,how:S,link:C,hiddenThere:_,otherThere:M,lanes:R,spent:P,taking:L,giving:U,givenTo:B,told:A,unplaced:q,unknown:T,stale:F}=e;return r.jsxs("div",{className:"lan-map","data-link":C,"data-asking":s||void 0,"data-bus":R.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}),l&&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]}),_&&r.jsx("span",{className:"lan-end-note",children:"current account hidden"}),M&&r.jsx("span",{className:"lan-end-note",children:"on another account"})]})]}),r.jsxs("div",{className:"lan-link",children:[r.jsx(dj,{}),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:u?r.jsx("code",{className:"ap-lan-code",children:u}):"none here — it calls this deck"})]}),r.jsx(dj,{}),(u&&S||x)&&r.jsxs("p",{className:"lan-link-sub",children:[u&&S,u&&S&&x&&" · ",x&&(v?N?r.jsx("code",{className:"ap-lan-code",children:b}):r.jsx("span",{className:"lan-round","data-tone":v.tone,children:v.text.replace(/ · now$/," · just now")}):"not asked yet"),x&&b&&!N&&r.jsx("code",{className:"lan-fact-raw",children:b})]}),q.length>0&&r.jsx("ul",{className:"lan-done",children:q.map(O=>{const K=tj(O);return r.jsxs("li",{"data-ok":O.ok&&!K,children:[O.email," ",r.jsxs("span",{className:"lan-done-what",children:[O.ok?"arrived":"did not arrive",K&&` — ${K.long}`]})]},`${O.email}:${O.action}`)})}),j&&r.jsx("p",{className:"lan-note lan-link-note",children:j}),(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})]}),R.length>0&&r.jsx("ul",{className:"lan-lanes",role:"list","aria-label":`Logins between this deck and ${t.name}`,children:R.map((O,K)=>{const V=A.get(O.email),H=V?tj(V):null,D=O.out==="live"||O.in!=null&&O.in!=="cut";return r.jsxs("li",{role:"listitem",className:"lan-lane","data-tone":O.tone,"data-draw":O.in&&O.out?"both":O.in?"in":"out","data-used-there":O.usedThere||void 0,style:{"--i":K},children:[r.jsx("i",{className:"lan-pip","data-end":"here","data-state":O.here,"aria-hidden":!0}),r.jsxs("span",{className:"lan-track",children:[r.jsxs("span",{className:"lan-wire","data-flow":D?"live":"cut","aria-hidden":!0,children:[(O.in==="live"||O.in==="wait")&&r.jsx("i",{className:"lan-glint","data-dir":"in","data-tone":O.in}),O.out==="live"&&r.jsx("i",{className:"lan-glint","data-dir":"out"})]}),O.in&&O.in!=="cut"&&r.jsx(yf,{dir:"in"}),O.out==="live"&&r.jsx(yf,{dir:"out"}),r.jsx("span",{className:"lan-lane-email",children:O.email})]}),r.jsx("i",{className:"lan-pip","data-end":"there","data-state":O.there,"aria-hidden":!0}),r.jsx("span",{className:"vis-hidden",children:T6(O)}),(O.caption||V)&&r.jsxs("span",{className:"lan-lane-note",children:[O.caption,O.caption&&V&&" · ",V&&r.jsxs("span",{className:"lan-lane-done","data-ok":V.ok&&!H,children:[V.ok?"arrived last round":"did not arrive last round",H&&` — ${H.long}`]})]})]},O.key)})},a),l&&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."]}),T&&r.jsx("p",{className:"lan-empty",children:T}),F&&r.jsxs("p",{className:"lan-stale",children:["As of ",F==="now"?"just now":F,", when it last answered."]}),r.jsxs("div",{className:"lan-legend",children:[L&&r.jsxs("span",{className:"lan-key",children:[r.jsx("span",{className:"lan-key-wire","data-dir":"in","aria-hidden":!0,children:r.jsx(yf,{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(yf,{dir:"out"})}),"from this deck, to ",B]}):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 rce=20,ace=17,ER=34,oce=160,ice=80,lce=200,cce=8,uce=14,dce=10,hce=.61803398875;function fce({status:e,rows:t,accounts:n,now:s,covered:a,onOpenDeck:o,onClose:i}){const l=g.useRef(null),u=gt(i,{focusRef:l}),h=yt(i),f=g.useRef(null),[p,m]=g.useState(null),[w,v]=g.useState(!1),j=g.useRef(null);g.useLayoutEffect(()=>{const re=f.current;if(!re)return;let he=null;const pe=()=>{const ge=Math.round(re.clientWidth),ve=Math.round(re.clientHeight);he&&he.w===ge&&he.h===ve||(he&&(v(!0),j.current!=null&&window.clearTimeout(j.current),j.current=window.setTimeout(()=>v(!1),lce)),he={w:ge,h:ve},m(he))};if(pe(),typeof ResizeObserver>"u")return;const Le=new ResizeObserver(pe);return Le.observe(re),()=>{Le.disconnect(),j.current!=null&&window.clearTimeout(j.current)}},[]);const b=g.useMemo(()=>p?qle(t,p.w,p.h,(e==null?void 0:e.name)??"",re=>{var he,pe;return cS(re,(pe=(he=cd(e,re).peer)==null?void 0:he.about)==null?void 0:pe.os)}):null,[t,p,e]),N=g.useMemo(()=>Wle(t),[t]),x=(b==null?void 0:b.nodes)??[],S=g.useRef(new Map),C=g.useMemo(()=>{const re=new Map;for(const he of x){const pe=Ws(he.row);re.set(pe,Gle(S.current.get(pe),he.angle))}return S.current=re,re},[x]),[_,M]=g.useState(null),[R,P]=g.useState(null),[L,U]=g.useState("none"),B=g.useRef(null),A=g.useCallback((re,he)=>{B.current!==re&&(B.current=re,U(he),P(re))},[]),q=g.useRef(null),T=g.useRef(null),F=g.useCallback(()=>{T.current!=null&&window.clearTimeout(T.current),T.current=null},[]),O=g.useCallback((re,he)=>{if(q.current!=null&&window.clearTimeout(q.current),q.current=null,F(),M(re),he==="keyboard"){A(re,"none");return}T.current=window.setTimeout(()=>A(re,B.current?"swap":"full"),ice)},[A,F]),K=g.useCallback(()=>{q.current!=null&&window.clearTimeout(q.current),F(),q.current=window.setTimeout(()=>M(null),oce)},[F]);g.useEffect(()=>()=>{q.current!=null&&window.clearTimeout(q.current),F()},[F]);const V=_&&x.some(re=>Ws(re.row)===_)?_:null,H=R?t.find(re=>Ws(re)===R)??null:null;g.useEffect(()=>{R&&!H&&A(null,"swap")},[R,H,A]);const[D,I]=g.useState(null),W=g.useRef(new Map),Z=x.findIndex(re=>Ws(re.row)===D),z=Z<0?0:Z,X=re=>{var ge;if(x.length===0)return;const he=re.key==="ArrowRight"||re.key==="ArrowDown"?1:re.key==="ArrowLeft"||re.key==="ArrowUp"?-1:0,pe=re.key==="Home"?0:re.key==="End"?x.length-1:he?(z+he+x.length)%x.length:null;if(pe==null)return;re.preventDefault();const Le=Ws(x[pe].row);I(Le),(ge=W.current.get(Le))==null||ge.focus()},[Y,J]=g.useState(()=>typeof document<"u"&&document.hidden);g.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?Hle(N):"Local network is off":"checking…",le=()=>{F(),A(null,"swap"),M(null)},de=V?x.find(re=>Ws(re.row)===V)??null:null,oe=()=>{var re;R&&((re=W.current.get(R))==null||re.focus()),le()};return kt.createPortal(r.jsx("div",{className:"modal-backdrop",...h,role:"presentation",children:r.jsxs("div",{ref:u,className:"modal nm-modal",onClick:re=>re.stopPropagation(),"data-paused":a||Y||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:l,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":V?"":void 0,"data-focus-via":de==null?void 0:de.row.via,"data-dense":(b==null?void 0:b.dense)||void 0,"data-still":w||void 0,onClick:re=>{re.target===re.currentTarget&&le()},children:p&&b&&r.jsxs(r.Fragment,{children:[r.jsx(pce,{layout:b,w:p.w,h:p.h}),x.map(re=>{const he=Ws(re.row);return r.jsx(yce,{node:re,angle:C.get(he)??re.angle,lit:V===he},he)}),r.jsx(wce,{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, ${x.length}`,"aria-describedby":"nm-ring-hint",onKeyDown:X,children:x.map((re,he)=>{var Le,ge;const pe=Ws(re.row);return r.jsx(xce,{node:re,angle:C.get(pe)??re.angle,os:(ge=(Le=cd(e,re.row).peer)==null?void 0:Le.about)==null?void 0:ge.os,lit:V===pe,shown:R===pe,tabbable:he===z,register:ve=>{ve?W.current.set(pe,ve):W.current.delete(pe)},onHold:ve=>{I(pe),O(pe,ve)},onRelease:K,onOpen:()=>o(re.row.fp)},pe)})}),x.length===0&&r.jsx(vce,{status:e})]})}),r.jsx(bce,{slice:(b==null?void 0:b.zone)!=null})]}),r.jsx("aside",{className:"nm-side","aria-label":"Details",children:H&&e?r.jsx(jce,{row:H,status:e,accounts:n,now:s,entrance:L,onOpen:()=>o(H.fp),onBack:oe},Ws(H)):r.jsx(kce,{status:e,summary:N,entrance:L,slice:(b==null?void 0:b.zone)!=null})})]})]})}),document.body)}function R6(){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 pce({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:gce(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:mce(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:b6(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 TR(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 mce(e,t,n){const s=e.to-e.from>180?1:0,a=(N,x)=>{const S=x*Math.PI/180;return[t+Math.cos(S)*N.rx,n+Math.sin(S)*N.ry]},o=(N,x)=>x/((N.rx+N.ry)/2)*(180/Math.PI),i=(N,x,S)=>{const C=Math.hypot(x[0]-N[0],x[1]-N[1])||1,_=Math.min(.5,S/C);return[N[0]+(x[0]-N[0])*_,N[1]+(x[1]-N[1])*_]},l=([N,x])=>`${N.toFixed(1)},${x.toFixed(1)}`,u=dce,h=uce,f=o(e.inner,u),p=o(e.outer,h),m=a(e.inner,e.from),w=a(e.outer,e.from),v=a(e.outer,e.to),j=a(e.inner,e.to),b=N=>`${N.rx.toFixed(1)},${N.ry.toFixed(1)}`;return[`M${l(a(e.inner,e.from+f))}`,`Q${l(m)} ${l(i(m,w,u))}`,`L${l(i(w,m,h))}`,`Q${l(w)} ${l(a(e.outer,e.from+p))}`,`A${b(e.outer)} 0 ${s} 1 ${l(a(e.outer,e.to-p))}`,`Q${l(v)} ${l(i(v,j,h))}`,`L${l(i(j,v,u))}`,`Q${l(j)} ${l(a(e.inner,e.to-f))}`,`A${b(e.inner)} 0 ${s} 0 ${l(a(e.inner,e.from+f))}`,"Z"].join(" ")}function gce(e,t,n){const s={rx:e.outer.rx-Sp,ry:e.outer.ry-Sp},a=e.to-e.from>180?1:0;return`M${TR(s,t,n,e.to)} A${s.rx.toFixed(1)},${s.ry.toFixed(1)} 0 ${a} 0 ${TR(s,t,n,e.from)}`}function yce({node:e,angle:t,lit:n}){const s=e.row.kind==="paired"&&e.row.here,a=e.order*hce%1*cce;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":`${ER}px`,"--gap":`${ER+(e.tier==="loose"?ace:rce)}px`,"--i":e.order,"--phase":`${a.toFixed(2)}s`},children:s&&r.jsx("i",{className:"nm-glint"})})}function wce({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 xce({node:e,angle:t,os:n,lit:s,shown:a,tabbable:o,register:i,onHold:l,onRelease:u,onOpen:h}){const{row:f}=e,p=`nm-d-${Nce(Ws(f))}`,m=e.angle*Math.PI/180,w=cS(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}: ${N6(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"&&l("pointer")},onPointerLeave:u,onFocus:v=>l(v.currentTarget.matches(":focus-visible")?"keyboard":"pointer"),onBlur:u,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(dj,{}),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:k6(f)}),r.jsx("span",{className:"nm-cap",children:w})]}),e.tier==="online"&&r.jsx("span",{id:p,className:"vis-hidden",children:w})]})}function vce({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 bce({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 M6({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 kce({status:e,summary:t,entrance:n,slice:s}){const a=Vle(e),o=uj(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 l=[{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})}],u=Kle(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:l.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":""]}),u&&r.jsx("p",{className:"nm-next",children:u}),r.jsx(M6,{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 jce({row:e,status:t,accounts:n,now:s,entrance:a,onOpen:o,onBack:i}){var j;const l=A6({row:e,source:cd(t,e),status:t,accounts:n,now:s}),u=[];l.where&&u.push({label:"Address",value:r.jsx("code",{className:"ap-lan-code",children:l.where})}),l.thereRuns&&u.push({label:"Runs",value:`${l.thereRuns}${l.order?` · ${l.order<0?"older than this deck":"newer than this deck"}`:""}`}),l.hiddenThere&&u.push({label:"Signed in to",value:"not said — its owner hides it",quiet:!0}),l.otherThere&&u.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=Yle(e,t.pairingMode),p=Xle(l.lanes),m=p.length,w=Zle(p),v=l.unknown&&((j=l.peer)!=null&&j.waiting)&&!l.peer.offers?"Its side is not known until it next calls.":l.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:N6(e)}),f&&r.jsx("p",{className:"nm-next",children:f}),u.length>0&&r.jsx(M6,{facts:u}),l.paired&&r.jsxs("section",{className:"nm-logins","aria-label":"Logins the two decks share",children:[r.jsx("p",{className:"nm-logins-title",children:w}),m>0&&r.jsx("ul",{className:"nm-lanes",children:p.map((b,N)=>r.jsxs("li",{className:"nm-lane","data-tone":b.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:b.email}),AR(b)&&r.jsx("span",{className:"nm-lane-said","aria-hidden":!0,children:AR(b)}),b.usedThere&&r.jsx("span",{className:"nm-lane-used","aria-hidden":!0,children:"in use there"}),r.jsxs("span",{className:"vis-hidden",children:[b.email,": ",T6(b)]})]},b.key))}),v&&r.jsx("p",{className:"nm-panel-hint",children:v})]})]})}function AR(e){return e.caption?e.caption:e.tone==="ok"?null:`${_6[e.here]} · ${E6[e.there]}`}function Nce(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 Sce=6;function Cce({anchorId:e,id:t,rows:n,onHold:s,onLet:a}){const o=g.useRef(null),i=n.filter(m=>m.kind==="paired"),l=i.filter(m=>m.here),u=l.slice(0,Sce),h=i.length-l.length,f=l.length>u.length?`and ${l.length-u.length} more`:h>0?`${h} not on right now`:null,p=g.useCallback(()=>{const m=o.current,w=document.getElementById(e);if(!m||!w)return;m.style.maxHeight="";const v=TN(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 g.useLayoutEffect(()=>{p()}),g.useEffect(()=>(window.addEventListener("scroll",p,!0),window.addEventListener("resize",p),()=>{window.removeEventListener("scroll",p,!0),window.removeEventListener("resize",p)}),[p]),kt.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:l.length?"On the network now":"Nobody on the network"}),u.length>0&&r.jsx("div",{className:"ap-peek-list",children:u.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 _ce({entry:e,rows:t,onOpen:n,onMap:s,peek:a,openPeek:o,shutPeek:i,holdPeek:l,dropPeek:u}){return r.jsxs(r.Fragment,{children:[r.jsxs("button",{type:"button",id:"ap-lan-entry",className:"ap-nav",onClick:()=>{u(),n()},"aria-describedby":a?"ap-lan-peek":void 0,onPointerEnter:h=>{h.pointerType==="mouse"&&o(f6)},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:()=>{u(),s()},"aria-label":"Show the network map",title:"Network map — every deck this one knows, drawn around it",children:r.jsx(R6,{})}),a&&r.jsx(Cce,{anchorId:"ap-lan-entry",id:"ap-lan-peek",rows:t,onHold:l,onLet:i})]})}function Ece({row:e,run:t,onVerb:n,onUnpair:s}){const[a,o]=g.useState(!1),i=g.useRef(0),[l,u]=g.useState(null);return g.useEffect(()=>{if(!a)return;const p=window.setTimeout(()=>o(!1),4e3);return()=>window.clearTimeout(p)},[a]),g.useEffect(()=>{if(!l)return;const p=window.setTimeout(()=>u(null),4e3);return()=>window.clearTimeout(p)},[l]),{armed:a,armedTwin:l,pressOwn:()=>{const p=Date.now(),m=yi({armedFor:a?e.fp:null,target:e.fp,armedAt:i.current,now:p,gapMs:gi});if(m==="arm"){o(!0),u(null),i.current=p;return}m!=="ignore"&&(o(!1),t(n))},pressTwin:p=>{if(!s)return;const m=Date.now(),w=yi({armedFor:l,target:p,armedAt:i.current,now:m,gapMs:gi});if(w==="arm"){u(p),o(!1),i.current=m;return}w!=="ignore"&&(u(null),t(()=>s(p)))}}}function Tce({row:e,paired:t,peer:n,status:s,busy:a,press:o,checkNow:i,armed:l,pressOwn:u,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${l?" armed":""}`,...o(`unpair:${e.fp}`),onKeyDown:m=>{m.repeat&&m.preventDefault()},onClick:()=>u(),"aria-label":l?`Confirm unpairing ${e.name}`:`Unpair ${e.name}`,title:l?"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…":l?"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 Ace({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((l,u)=>{var v,j,b,N;const h=(v=l.peer)!=null&&v.addr?`${l.peer.addr}:${l.peer.port}`:l.row.addr,f=h||l.row.fp,p=(j=l.peer)!=null&&j.pairedAt?xr(l.peer.pairedAt,t):null,m=[(N=(b=l.peer)==null?void 0:b.about)!=null&&N.version?`runs ${l.peer.about.version}`:null,p?`paired ${p==="now"?"just now":p}`:null,l.row.state].filter(Boolean).join(" · "),w=l.row.fp;return r.jsxs("li",{role:"listitem",className:"lan-twin","data-tone":l.row.tone,children:[r.jsx("i",{className:l.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}),u>0&&i&&r.jsx("button",{type:"button",className:`ap-manage-btn danger lan-twin-do${a===w?" armed":""}`,...s(`unpair:${w}`),onKeyDown:x=>{x.repeat&&x.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:u===0?`${m} · shown above`:m})]},w)})})]})}function Rce(){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 Mce({row:e,source:t,status:n,accounts:s,now:a,busy:o,onClose:i,onRename:l,onCheck:u,onVerb:h,onSettings:f,onInvite:p,twins:m=[],onUnpair:w}){const v=g.useRef(null),j=gt(i,{focusRef:v}),b=yt(i),[N,x]=g.useState(null),[S,C]=g.useState(null),[_,M]=g.useState(!1),[R,P]=g.useState(0),L=g.useRef(null),U=g.useRef(null),B=g.useRef(!0);g.useEffect(()=>()=>{B.current=!1},[]);const A=N!=null;g.useEffect(()=>{var re;A&&((re=L.current)==null||re.select())},[A]);const q=g.useRef(!1);g.useEffect(()=>{var re,he;q.current&&!A&&Un(((re=document.activeElement)==null?void 0:re.tagName)??null)&&((he=U.current)==null||he.focus()),q.current=A},[A]);const T=re=>{const he=so(o,re);return{disabled:he.disabled,"aria-busy":he.busy}},F=async re=>{const he=await re();return B.current&&C(he),he==null},{armed:O,armedTwin:K,pressOwn:V,pressTwin:H}=Ece({row:e,run:F,onVerb:h,onUnpair:w}),D=A6({row:e,source:t,status:n,accounts:s,now:a}),{peer:I,stranger:W,paired:Z,own:z,canRename:X,fp:Y}=D,J=o===`check:${e.fp}`,Q=async re=>{const he=re.trim()===z?"":re;await F(()=>l(he))&&x(null)},te=()=>void F(u).then(re=>{re&&B.current&&P(he=>he+1)}),le=async()=>{if(Y)try{if(await navigator.clipboard.writeText(Y),!B.current)return;M(!0),window.setTimeout(()=>{B.current&&M(!1)},1600)}catch{B.current&&C("Could not copy it — select the fingerprint and copy it by hand.")}},de=[];Z&&(I!=null&&I.pairedAt)?de.push({label:"Paired",value:nce(I.pairedAt,a),tone:"meta"}):e.kind==="declined"&&W&&de.push({label:"Paired",value:`no · you said no ${rS(W.at,a)}`,tone:"meta"}),de.push({label:"Fingerprint",value:Y?r.jsxs("span",{className:"lan-fp",children:[r.jsx("code",{className:"ap-lan-code",children:Y}),r.jsx("button",{type:"button",className:"ap-lan-word lan-copy",onClick:()=>void le(),"aria-label":_?"Fingerprint copied":"Copy the fingerprint",children:_?"copied":"copy"})]}):"not known — nothing has answered there",tone:Y?void 0:"quiet"});const oe=m.length?[{row:e,peer:I??null},...m]:[];return kt.createPortal(r.jsx("div",{className:"modal-backdrop",...b,role:"presentation",children:r.jsxs("div",{ref:j,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:[A?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:L,className:"ap-manage-input lan-peer-input",value:N??"",maxLength:48,placeholder:z,"aria-label":"Name for this deck, shown on this deck only",onChange:re=>x(re.target.value)}),r.jsx("button",{type:"submit",className:"ap-manage-btn",...T(`alias:${e.fp}`),children:"save"}),r.jsx("button",{type:"button",className:"ap-manage-btn",onClick:()=>x(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}),X&&r.jsx("button",{type:"button",className:"glyph-btn lan-peer-rename",ref:U,onClick:()=>{C(null),x(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(Rce,{})})]}),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}),A&&r.jsx("button",{type:"button",className:"ap-lan-word lan-peer-restore",...T(`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:()=>C(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),r.jsx(sce,{view:D,row:e,status:n,asking:J,drawn:R,onSettings:f}),r.jsx("dl",{className:"lan-facts",children:de.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))}),oe.length>1&&r.jsx(Ace,{instances:oe,now:a,busy:o,press:T,armedTwin:K,pressTwin:H,onUnpair:w})]}),r.jsx(Tce,{row:e,paired:Z,peer:I,status:n,busy:o,press:T,checkNow:te,armed:O,pressOwn:V,run:F,onVerb:h,onInvite:p})]})}),document.body)}function ta(e,t){const n=g.useRef(!1);return g.useEffect(()=>{var s,a;!e||!n.current||(n.current=!1,Un(((s=document.activeElement)==null?void 0:s.tagName)??null)&&(typeof t=="function"?t():(a=t.current)==null||a.focus()))},[e]),()=>{n.current=!0}}function $ce(e,t){if(e.length!==t.length)return!1;const n=new Set(e);return t.every(s=>n.has(s))}function Lce(e,t,n,s){const a=new Set(e??t);return s?a.add(n):a.delete(n),[...a]}function RR(e,t,n){return e==null||n!=null&&!n.ok||$ce(e,t)?null:e}function $6({line:e,onDismiss:t,onAnswer:n}){const[s,a]=g.useState(!1),o=g.useRef(!1),i=g.useRef(!0);g.useEffect(()=>(i.current=!0,()=>{i.current=!1}),[]);const l=g.useRef(null),u=g.useRef(null),h=g.useRef(!1);if(g.useEffect(()=>{var p;h.current&&(h.current=!1,e!=null&&e.giveBack||(p=u.current)==null||p.focus())},[e]),!e)return null;const f=async()=>{if(o.current)return;o.current=!0,a(!0);const p=await Mie();o.current=!1,i.current&&(a(!1),h.current=document.activeElement===l.current,n(Lie(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:l,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:u,type:"button",className:"ap-failure-x",onClick:t,"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]})}function Ice(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 wf="Paused while this deck pairs only by invite. Turn that off above to use it.";function Oce({status:e,accounts:t,onClose:n,onChanged:s}){sn("lan-setup");const a=gt(n),o=yt(n),[i,l]=g.useState(null),[u,h]=g.useState(null),[f,p]=g.useState(!1),[m,w]=g.useState(null),v=g.useRef(null),j=D=>{const I=so(m,D);return{disabled:I.disabled,"aria-busy":I.busy}},b=g.useRef(null),N=g.useRef(!0);g.useEffect(()=>()=>{N.current=!1},[]),g.useEffect(()=>{b.current=RR(b.current,e.shared??[],null)},[e.shared]);const x=g.useCallback(async(D,I,W="write")=>{v.current=W,w(W);try{const z=await(await fetch("/api/prefs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({lan:D})})).json().catch(()=>null);return N.current?(z!=null&&z.ok?h(null):h(Hs(Xt(I,z),z)),s(),(z==null?void 0:z.ok)===!0):!1}catch{return N.current&&h(Hs(Xt(I,null))),!1}finally{v.current=null,N.current&&w(null)}},[s]),S=g.useCallback(async D=>{const I=await x({name:D},"save the name","name");return I&&N.current&&l(W=>W===D?null:W),I},[x]),C=g.useRef(null),_=i!=null&&i!==(e.name??""),M=ta(!_,C),R=g.useCallback(async()=>{_&&!await S(i)||n()},[_,i,S,n]),P=async()=>{if(!e.fp)return;const D=await ho(e.fp);if(N.current){if(!D){h(Hs("Could not copy it — select the fingerprint and copy it by hand."));return}p(!0),window.setTimeout(()=>{N.current&&p(!1)},1600)}},L=new Set(b.current??e.shared??[]),U=e.autoAsk!==!1,B=e.autoAccept!==!1,A=e.pairingMode==="invite",q=D=>{const I=j(D);return{...I,disabled:I.disabled||A}},T=e.shareActive!==!1,F=e.sendInUse===!0,O=e.tailscale??null,K=!!(O!=null&&O.on),V=(O==null?void 0:O.ask)!==!1,H=(O==null?void 0:O.accept)!==!1;return kt.createPortal(r.jsx("div",{className:"modal-backdrop",...o,role:"presentation",children:r.jsxs("div",{ref:a,className:"modal lan-modal",onClick:D=>D.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($6,{line:u,onDismiss:()=>h(null),onAnswer:D=>{h(D),D.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:C,className:"ap-manage-input ap-lan-input","aria-label":"This deck's name on the network",value:i??e.name??"",placeholder:"this machine",onChange:D=>l(D.target.value),onKeyDown:D=>{D.key!=="Enter"||i==null||S(i)}}),_&&r.jsx("button",{type:"button",className:"ap-manage-btn",...j("name"),onClick:()=>{M(),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(D=>r.jsxs("label",{className:"ap-lan-pick",title:D.alive?D.inUse?"Offer this account to the decks you have paired with. While this deck is on it, it stays here, and it goes out like the others once this deck switches away. Unticking stops it being offered from now on; it does not take back a copy somebody already has.":"Offer this account to the decks you have paired with, so one whose copy has died can heal from yours. Unticking stops it being offered from now on; it does not take back a copy somebody already has.":"This deck cannot use this login, so it has nothing to offer — a deck that can will heal it",children:[r.jsx("input",{type:"checkbox",checked:L.has(D.key),onChange:I=>{const W=Lce(b.current,e.shared??[],D.key,I.target.checked);b.current=W,x({shared:W},I.target.checked?"share that account":"stop sharing that account").then(Z=>{b.current===W&&(b.current=RR(W,e.shared??[],{ok:Z}))})}}),r.jsx("span",{className:"ap-lan-pick-name",children:D.email}),!D.alive&&r.jsx("span",{className:"ap-lan-dead",children:"not working here"}),D.alive&&D.inUse&&L.has(D.key)&&r.jsx("span",{className:"ap-lan-dead",children:"in use here · not sent"})]},D.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":T,"aria-label":"Show paired decks which of these this deck is using",...j("current"),onClick:()=>void x({shareActive:!T},T?"stop showing which account this deck is using":"show which account this deck is using","current"),title:T?"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",F&&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":F,"aria-label":"Send the login this deck is using too","aria-describedby":F?"lan-send-in-use-detail":void 0,"data-tone":"warn",...j("send-in-use"),onKeyDown:D=>{D.repeat&&D.preventDefault()},onClick:()=>void x({sendInUse:!F},F?"keep the login this deck is using here":"send the login this deck is using","send-in-use"),title:F?"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",A&&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":A,"aria-label":"Pair new decks only by invite","aria-describedby":A?"lan-invite-only-detail":void 0,...j("mode"),onKeyDown:D=>{D.repeat&&D.preventDefault()},onClick:()=>void x({pairingMode:A?"automatic":"invite"},A?"let decks pair on their own again":"pair new decks only by invite","mode"),title:A?"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",A&&r.jsx("span",{className:"lan-sub-state",children:" · paused while pairing is invite-only"})]}),r.jsxs("div",{className:"lan-switches","data-paused":A||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",...q("ask"),onClick:()=>void x({autoAsk:!U},U?"stop asking automatically":"ask every deck this one finds","ask"),title:A?wf: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":B,"aria-label":"Say yes to every deck that asks","data-tone":"warn",...q("accept"),onKeyDown:D=>{D.repeat&&D.preventDefault()},onClick:()=>void x({autoAccept:!B},B?"stop accepting automatically":"accept every deck that asks","accept"),title:A?wf:B?"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"})})]})]})]})]}),(O==null?void 0:O.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:Ice(O)})]}),r.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":K,"aria-label":"Look for my devices over Tailscale","aria-describedby":"lan-ts-detail",...j("tailscale"),onClick:()=>void x({tailscale:!K},K?"stop looking over Tailscale":"look for your devices over Tailscale","tailscale"),title:K?"Stop. Nothing is looked for or answered over the tailnet; decks already paired stay paired.":"Find the decks on your other machines on Tailscale, wherever they are. Only machines signed in to your Tailscale account are asked.",children:r.jsx("span",{className:"switch-knob"})})]}),K&&r.jsxs("div",{className:"lan-auto",role:"group","aria-labelledby":"lan-ts-auto-h",children:[r.jsxs("p",{className:"lan-sub",id:"lan-ts-auto-h",children:["Automatic pairing with my devices",A&&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":A||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":V,"aria-label":"Ask each of my devices it finds over Tailscale",...q("tailscale-ask"),onClick:()=>void x({tailscaleAsk:!V},V?"stop asking your devices automatically":"ask your devices automatically","tailscale-ask"),title:A?wf:V?"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":A||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":H,"aria-label":"Say yes to my devices when they ask over Tailscale","data-tone":"warn",...q("tailscale-accept"),onKeyDown:D=>{D.repeat&&D.preventDefault()},onClick:()=>void x({tailscaleAccept:!H},H?"stop accepting your devices automatically":"accept your devices automatically","tailscale-accept"),title:A?wf:H?"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",...j("name"),onClick:()=>void R(),children:"Done"})]})]})}),document.body)}function Pce({on:e,status:t,paired:n,busy:s,pressProps:a,checkNow:o,setAddOpen:i,setSetupOpen:l,setMapOpen:u,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:()=>u(!0),"aria-label":"Show the network map",title:"Network map — every deck this one knows, drawn around it",children:r.jsx(R6,{})}),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:()=>l(!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 Dce({accounts:e,onChanged:t,onNoCopy:n,onShared:s,onElsewhere:a,view:o,onOpen:i,onBack:l,closeButton:u}){const[h,f]=g.useState(!1),[p,m]=g.useState(!1),[w,v]=g.useState(!1),j=Aie(),[b,N]=g.useState(!1),{status:x,manual:S,now:C,busy:_,failure:M,dismissFailure:R,answerGiveBack:P,pressProps:L,load:U,toggle:B,answer:A,dropAddress:q,rename:T,checkOne:F,checkNow:O}=Fie(t,()=>f(!0)),{armed:K,pressUnpair:V}=Bie(A),[H,D]=g.useState(null),[I,W]=g.useState(!1),Z=g.useMemo(()=>moe(e,x??null),[e,x]),z=g.useMemo(()=>Z.filter(Ee=>goe(Ee.key,x??null,C)).map(Ee=>Ee.key).sort().join(`
|
|
105
|
+
`),[Z,x,C]);g.useEffect(()=>{n==null||n(z?z.split(`
|
|
106
|
+
`):[])},[z,n]);const X=g.useMemo(()=>JSON.stringify(boe(Z,x??null)),[Z,x]);g.useEffect(()=>{s==null||s(new Map(JSON.parse(X)))},[X,s]);const Y=g.useMemo(()=>JSON.stringify(Z.flatMap(Ee=>{const xe=voe(Ee.key,x??null,C);return xe?[[Ee.key,xe]]:[]})),[Z,x,C]);g.useEffect(()=>{a==null||a(new Map(JSON.parse(Y)))},[Y,a]);const J=(x==null?void 0:x.enabled)===!0,Q=g.useMemo(()=>aoe((x==null?void 0:x.pairingMode)==="invite"&&x?{...x,pending:[]}:x,C),[x,C]),te=H?Q.find(Ee=>{var xe;return Ee.fp===H||((xe=Ee.twins)==null?void 0:xe.some(Ie=>Ie.fp===H))})??null:null;g.useEffect(()=>{H&&x&&!te&&D(null)},[H,x,te]);const{asks:le,rest:de,live:oe,folded:re,troubled:he,shown:pe,paired:Le}=poe(Q,b),ge=noe(x,C),ve=foe(x,Q),je=r.jsxs(r.Fragment,{children:[p&&x&&r.jsx(lle,{status:x,manual:S,startWith:p==="invite"?"invite":void 0,onClose:()=>m(!1),onChanged:()=>{U(),t()}}),w&&r.jsx(g6,{title:"How Local network works",steps:ele,finish:J?void 0:{label:"Turn it on",act:()=>{v(!1),B()}},onClose:()=>v(!1)}),h&&x&&r.jsx(Oce,{status:{...x,manualRows:S},accounts:Z,manual:S,onClose:()=>f(!1),onChanged:()=>{U(),t()}}),I&&r.jsx(fce,{status:x,rows:Q,accounts:Z,now:C,covered:!!te||h||!!p||w,onOpenDeck:D,onClose:()=>W(!1)}),te&&x&&r.jsx(Mce,{row:te,source:cd(x,te),status:x,accounts:Z,now:C,busy:_,onClose:()=>D(null),onRename:Ee=>T(te.fp,Ee),onCheck:()=>F(te.fp),onVerb:()=>{switch(te.kind){case"paired":return A("unpair",te.fp,"unpair that deck");case"nearby":return A("accept",te.fp,"reach that deck");case"declined":return A("allow",te.fp,"let that deck ask again");case"dialling":return q(te.fp);default:return Promise.resolve(null)}},onSettings:()=>{D(null),f(!0)},onInvite:()=>{D(null),m("invite")},twins:(te.twins??[]).map(Ee=>({row:Ee,peer:cd(x,Ee).peer??null})),onUnpair:Ee=>A("unpair",Ee,"unpair that deck")})]});return o?r.jsxs("div",{className:"ap-lan-view",children:[r.jsx(Pce,{on:J,status:x,paired:Le,busy:_,pressProps:L,checkNow:O,setAddOpen:m,setSetupOpen:f,setMapOpen:W,onBack:l,closeButton:u}),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",...L("switch"),onClick:()=>void B(),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(fle,{on:J,status:x}),!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(tle,{}),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(sd,{film:"localNetwork"})]}),r.jsx("p",{className:`ap-lan-status ${ge.tone}`,role:"status",children:ge.tone==="ok"?"":ge.text}),r.jsx($6,{line:M,onDismiss:R,onAnswer:P}),J&&r.jsxs(r.Fragment,{children:[le.length>0&&r.jsx(ule,{asks:le,pressProps:L,answer:A}),pe.length>0&&r.jsx(dle,{rows:pe,pairingMode:x==null?void 0:x.pairingMode,armed:K,pressProps:L,answer:A,dropAddress:q,onUnpair:V,onOpenPeer:D,onInvite:()=>m("invite")}),(oe.length>0&&re.length>0||J&&Le>0)&&r.jsxs("div",{className:"ap-lan-tail",children:[oe.length>0&&re.length>0&&r.jsxs("button",{type:"button",className:"ap-lan-word ap-lan-more","aria-expanded":b,onClick:()=>N(Ee=>!Ee),title:b?"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${b?" open":""}`,"aria-hidden":!0,children:"›"}),b?"fewer":`${re.length} more`,!b&&he>0&&r.jsxs("span",{className:"ap-lan-more-bad",children:[" · ",he," not responding"]})]}),J&&Le>0&&r.jsx("span",{className:"ap-lan-checked",children:soe(x==null?void 0:x.checkedAt,C,_==="check")})]}),de.length===0&&le.length===0&&!(x!=null&&x.stalled)&&!(x!=null&&x.deaf)&&!(x!=null&&x.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(sd,{film:"localNetwork"})]})]})]})}),je]}):r.jsxs("div",{className:"ap-foot",children:[r.jsx(_ce,{entry:ve,rows:Q,onOpen:i,onMap:J?()=>W(!0):void 0,...j}),r.jsx("p",{className:"vis-hidden",role:"status",children:ge.tone==="ok"?"":ge.text}),je]})}function Fce({anchorId:e,id:t,peers:n,onHold:s,onLet:a}){const o=g.useRef(null),{title:i,shown:l,rest:u}=Tie(n),h=g.useCallback(()=>{const f=o.current,p=document.getElementById(e);if(!f||!p)return;f.style.maxHeight="";const m=TN(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 g.useLayoutEffect(()=>{h()}),g.useEffect(()=>(window.addEventListener("scroll",h,!0),window.addEventListener("resize",h),()=>{window.removeEventListener("scroll",h,!0),window.removeEventListener("resize",h)}),[h]),kt.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:l.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))}),u&&r.jsx("p",{className:"ap-peek-rest",children:u})]}),document.body)}function Bce({peers:e,strained:t,armed:n,threshold:s,open:a,onToggle:o,order:i,choices:l,onOrder:u,allOpen:h,onToggleAll:f,held:p=!1}){const[m,w]=g.useState(!1),v=g.useRef(0);g.useEffect(()=>()=>window.clearTimeout(v.current),[]),g.useEffect(()=>{a&&(window.clearTimeout(v.current),w(!1))},[a]);const j=C=>{a||(window.clearTimeout(v.current),v.current=window.setTimeout(()=>w(!0),C))},b=()=>{window.clearTimeout(v.current),v.current=window.setTimeout(()=>w(!1),p6)},N=()=>window.clearTimeout(v.current),x=()=>{window.clearTimeout(v.current),w(!1)},S=_ie(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:()=>{x(),o()},onPointerEnter:C=>{C.pointerType==="mouse"&&j(f6)},onPointerLeave:b,onFocus:C=>{C.target.matches(":focus-visible")&&j(0)},onBlur:b,children:[r.jsxs("span",{className:"ap-nav-text",children:[r.jsx("span",{className:"ap-nav-name",children:"Other accounts"}),r.jsx("span",{className:"ap-nav-state","data-tone":S.tone,children:S.text})]}),r.jsx("svg",{className:"ap-nav-chev",width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:r.jsx("path",{d:"M5.6 3.4 9.2 7l-3.6 3.6"})})]}),m&&r.jsx(Fce,{anchorId:"ap-rest-entry",id:"ap-rest-peek",peers:e,onHold:N,onLet:b}),a&&r.jsx(qce,{order:i,choices:l,onOrder:u,allOpen:h,onToggleAll:f,held:p})]})}function qce({order:e,choices:t,onOrder:n,allOpen:s,onToggleAll:a,held:o}){var u;const i=g.useRef(null);g.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 l=((u=t.find(h=>h.id===e))==null?void 0:u.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?`${l} — held where it was while you are in the list`:l,"data-sorted":e===xm?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 Uce(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}const Wce=1800;function Hce({accounts:e,onClose:t,copyText:n}){sn("share-accounts");const[s,a]=g.useState([]),[o,i]=g.useState(null),[l,u]=g.useState(!1),[h,f]=g.useState(null),[p,m]=g.useState(!1),[w,v]=g.useState(()=>Math.floor(Date.now()/1e3)),j=g.useRef(null),b=g.useRef(!1),N=gt(t,{focusRef:j}),x=yt(t),S=ta(o!=null,j),C=ta(o==null,j);g.useEffect(()=>{if(!o)return;v(Math.floor(Date.now()/1e3));const O=window.setInterval(()=>v(Math.floor(Date.now()/1e3)),1e3);return()=>window.clearInterval(O)},[o]);const _=cie(e),M=uie(e,s),R=M.length===e.length,P=O=>a(K=>die(K,O)),L=g.useCallback(async()=>{const O=hie(M);if(!Sn(b.current)||!O)return;b.current=!0,u(!0),f(null),m(!1);const K=await Uce(O).catch(()=>null);if(b.current=!1,u(!1),!(K!=null&&K.ok)){f(Cl(K,"the share could not be made"));return}i({blob:K.blob,expiresAt:K.expiresAt,shared:K.shared??[],failed:K.failed??[]})},[e,M]),U=o?d6(o.expiresAt,w):null,B=(U==null?void 0:U.tone)==="gone",A=(o==null?void 0:o.shared.length)??0,q=B?"This share has expired":A===1?"1 account, ready to paste":`${A} accounts, ready to paste`,T=A===1?"this is the password":`this is ${A} passwords`,F=o?B?q:`${q} — ${T}`:"";return kt.createPortal(r.jsx("div",{className:"modal-backdrop",...x,role:"presentation",children:r.jsxs("div",{ref:N,className:"modal sa-modal",onClick:O=>O.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:F}),o?r.jsxs("div",{className:"sa-step",children:[r.jsx("h4",{children:q}),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:j,onClick:async()=>{if(B){C(),S(),i(null),L();return}await n(o.blob)&&(m(!0),window.setTimeout(()=>m(!1),Wce))},children:B?"make a new share":p?"copied":`copy ${A===1?"the share":"all "+A}`}),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:T})," · ",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(O=>{var V;const K=!!(O.email&&((V=O.detail)!=null&&V.includes(O.email)));return r.jsxs("li",{children:[!K&&r.jsx("span",{className:"sa-who",children:O.email||`account ${O.num}`}),r.jsx("span",{className:"sa-why",children:O.detail||"could not be exported"})]},`${O.num}-${O.email}`)})})]}),r.jsx("p",{className:"sa-note",children:B?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:()=>{C(),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:j,onClick:t,children:"Close"})})]}):r.jsxs("div",{className:"sa-step",children:[r.jsxs("h4",{children:["Which accounts go to the other ",Pt,"?"]}),r.jsx("p",{className:`sa-count${M.length?"":" empty"}`,children:fie(M.length)}),r.jsx("ul",{className:"sa-list sa-pick",children:_.map(O=>r.jsx("li",{children:r.jsxs("label",{className:"sa-row",children:[r.jsx("input",{type:"checkbox",checked:M.includes(O.num),onChange:()=>P(O.num)}),r.jsx("span",{className:"sa-who",children:O.label}),O.sub&&r.jsx("span",{className:"sa-sub",children:O.sub})]})},O.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(R?e.map(O=>O.num):[]),children:R?"Clear all":"Select all"}),r.jsx("button",{type:"button",className:"btn primary",ref:j,...Fn(l,!M.length),onClick:()=>{S(),L()},children:l?"making the share…":M.length===0?"Share":M.length===1?"Share 1 account":`Share ${M.length} accounts`})]})]})]})]})}),document.body)}function uS(e,t){var n;return!e.disabled&&!((n=xi(e,t))!=null&&n.blocksSwitch)}function zce(e,t,n){return e.map(s=>{const a=xi(s,t,n==null?void 0:n(s));return{key:ws(s),name:s.alias??s.email??`account ${s.num}`,ready:uS(s,t),why:s.disabled?"held out":a!=null&&a.blocksSwitch?a.text:null,warn:(a==null?void 0:a.tone)==="warn",headroom:ZN(s,t)}})}function Vce(e,t,n){const s=Number(t),a=e&&(n==null?e.headroom:ZN(e,n));return a!=null&&Number.isFinite(s)&&100-a>=s}function Gce(e){return(e==null?void 0:e.ok)===!0&&(e.enabled||e.external)}const L6="agent-dag.otherAccountsOrder",I6="agent-dag.otherAccountsOpen";function O6(){const e=nt(L6);return typeof e=="string"&&e.length>0&&e.length<=64?e:xm}function Kce(e){st(L6,e)}function Yce(){const e=nt(I6);if(!e)return J1;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 J1}function Xce(e){st(I6,JSON.stringify({mode:e.mode,keys:e.keys.filter(t=>!t.startsWith("slot:"))}))}function Zce(){const[e,t]=g.useState(null),n=g.useRef(null),s=g.useCallback(i=>rm(n.current)?(n.current=i,t(i),!0):!1,[]),a=g.useCallback(()=>{n.current=null,t(null)},[]);return{busy:e,claim:s,release:a,pressProps:(i,l=!1)=>{const u=so(e,i);return{disabled:u.disabled,"aria-busy":u.busy||l}}}}const Jce=8e3,Qce=1800,eue=4e3;function tue({claim:e,release:t,load:n,clearFailure:s,rescueFocus:a,afterRemove:o}){const[i,l]=g.useState(null),u=(i==null?void 0:i.num)??null,h=g.useRef(i);h.current=i;const[f,p]=g.useState(null),[m,w]=g.useState(""),[v,j]=g.useState(null),b=g.useRef(0);g.useEffect(()=>{if(v==null)return;const z=window.setTimeout(()=>j(null),eue);return()=>window.clearTimeout(z)},[v]);const[N,x]=g.useState(null),[S,C]=g.useState(!1),[_,M]=g.useState(null),[R,P]=g.useState(null),L=g.useCallback(async(z,X)=>{if(!e(X))return null;s(),p(null);try{const Y=await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(z)}),J=await Y.json().catch(()=>null);return J!=null&&J.ok||p({text:Cl(J,"command failed",Y.status)}),J}catch{return p({text:"server unreachable"}),null}finally{t()}},[e,t,s]),U=g.useCallback(()=>{l(null),p(null),j(null),x(null),C(!1)},[]),B=(z,X="first")=>{U(),P(null),l({num:z,view:"menu",start:X})},A=g.useCallback(z=>{var J,Q;const X=h.current;if(!X||z!=null&&X.num!==z)return;const Y=document.getElementById(`ap-menu-${X.num}`);(Y!=null&&Y.contains(document.activeElement)||Un(((J=document.activeElement)==null?void 0:J.tagName)??null))&&((Q=document.getElementById(`ap-more-${X.num}`))==null||Q.focus()),U()},[U]),q=g.useCallback(z=>p(z),[]),T=(z,X)=>{w(X??""),p(null),l({num:z,view:"rename"})},F=z=>w(z),O=z=>{P(null),p(null),l({num:z,view:"move"})},K=z=>P(z),V=async z=>{var Y;C(!1);const X=await L({action:"share",account:z},`share-${z}`);!(X!=null&&X.ok)||((Y=h.current)==null?void 0:Y.num)!==z||(x({num:z,blob:X.blob,expiresAt:X.expiresAt}),l({num:z,view:"share"}))},H=async z=>{await ho(z)&&(C(!0),window.setTimeout(()=>C(!1),Qce))},D=async(z,X)=>{const{commit:Y,alias:J}=vie(m,X);if(Y){const Q=await L({action:"alias",account:z,alias:J},`alias-${z}`);if(await n(!0),!(Q!=null&&Q.ok))return}A(z)},I=async(z,X)=>{var Q,te,le;const Y=await L({action:"move",account:z,slot:X},`move-${z}`),J=wie({menuFor:((Q=h.current)==null?void 0:Q.num)??null,shareFor:(N==null?void 0:N.num)??null},z,Y);if(await n(!0),J){if(J.menuFor!=null){const oe=document.getElementById(`ap-menu-${z}`),re=document.getElementById(`ap-more-${J.menuFor}`);re&&(oe!=null&&oe.contains(document.activeElement)||Un(((te=document.activeElement)==null?void 0:te.tagName)??null))&&re.focus()}((le=h.current)==null?void 0:le.num)===z&&U(),j(J.confirmRemove),J.shareFor==null&&(x(null),C(!1)),M(J.swapNote);const de=J.swapNote;de&&window.setTimeout(()=>M(oe=>oe===de?null:oe),Jce),P(null),a(J.menuFor)}return Y};return{menu:i,menuFor:u,menuError:f,aliasDraft:m,confirmRemove:v,share:N,shareCopied:S,slotDraft:R,swapNote:_,showMenu:B,dropMenu:U,closeMenu:A,sayInMenu:q,startRename:T,typeAlias:F,doAlias:D,startMove:O,pickSlot:K,doSlot:async(z,X,Y)=>{if(!Y.sends){A(z);return}await I(z,X)},makeShare:V,copyShare:H,pressRemove:z=>{const X=Date.now(),Y=yi({armedFor:v,target:z,armedAt:b.current,now:X,gapMs:gi});if(Y==="arm"){j(z),b.current=X;return}Y!=="ignore"&&(j(null),L({action:"remove",account:z},`rm-${z}`).then(J=>{var Q;n(!0),J!=null&&J.ok&&(o==null||o(J),((Q=h.current)==null?void 0:Q.num)===z&&U(),a(null))}))}}}function nue(e,t){return!e||!t||t.some(n=>n.num===e.num&&n.active)?e:null}const sue="login_expired";function rue(e,t,n){return(e==null?void 0:e.reason)!==sue?null:{text:`${t}'s login expired · sign in again to use it`,row:n,signIn:!0}}const aue="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 oue(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:aue}}:null}function iue({data:e,claim:t,release:n,load:s,sayFailure:a,clearFailure:o,sayInMenu:i,rescueFocus:l}){const[u,h]=g.useState(null),f=g.useCallback(async(w,v,j="panel")=>{if(!t(v))return null;const b=j==="menu"?i:a;b(null);try{const N=await fetch("/api/cswap-auto",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(w)}),x=await N.json().catch(()=>null);return x!=null&&x.ok||b({text:ej(x,"command failed",N.status),raw:ld(x)}),x}catch{return b({text:"server unreachable"}),null}finally{n()}},[t,n,i,a]);g.useEffect(()=>{!(e!=null&&e.ok)||!e.accounts||h(w=>nue(w,e.accounts))},[e]);const p=async(w,v)=>{if(t(`switch-${w}`)){o(),h(null);try{const b=await(await fetch("/api/claude-accounts/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({account:w})})).json().catch(()=>null),N=rue(b,v,w);N?a(N):b!=null&&b.ok?h({num:w,name:v}):a({text:ej(b,"the switch failed"),raw:ld(b),row:w}),await s(!0)}catch{a({text:"server unreachable",row:w})}finally{n(),l(w)}}},m=g.useCallback((w,v)=>h({num:w,name:v}),[]);return{switched:u,post:f,doSwitch:p,noteSwitched:m}}const lue=1800;function cue({auto:e,post:t,load:n}){var M;const[s,a]=g.useReducer(Ooe,rj),[o,i]=g.useState(!1),l=g.useRef(null),u=g.useRef(null),h=g.useRef(null),f=g.useRef(!1),p=((M=e==null?void 0:e.settings["autoswitch.threshold"])==null?void 0:M.value)??"90",m=s.pick??p,w=Nie(m,p),v=s.custom!=null,j=s.refusal,b=g.useRef(v);return g.useEffect(()=>{var R,P,L;b.current!==v&&(b.current=v,v?((R=h.current)==null||R.focus(),(P=h.current)==null||P.select()):f.current&&((L=l.current)==null||L.focus()),f.current=!1)},[v]),{threshold:p,thresholdPick:m,thresholdCtl:w,thresholdSaved:o,thresholdRef:l,thresholdSaveRef:u,thresholdCustom:v,thresholdRefusal:j,thresholdFieldRef:h,proposeThreshold:R=>a({kind:"pick",pick:R}),typeThreshold:R=>a({kind:"type",text:R}),cancelThreshold:R=>{R.key!=="Escape"||R.nativeEvent.isComposing||!s.custom||(R.preventDefault(),R.stopPropagation(),f.current=!0,a({kind:"cancel"}))},leaveThreshold:()=>a({kind:"leave",stored:p}),doThreshold:async(R,P)=>{const L=await Poe(R,P,t);if(L.kind==="refused"){a({kind:"refuse",message:L.message});return}L.kind==="sent"&&(await n(!0),!L.ok)||(f.current=document.activeElement===h.current,a({kind:"settle"}),i(!0),window.setTimeout(()=>{var U;document.activeElement===u.current&&((U=l.current)==null||U.focus()),i(!1)},lue))}}}const uue=1800;function due({auto:e,post:t,load:n}){var v;const[s,a]=g.useState(null),[o,i]=g.useState(!1),l=g.useRef(null),u=g.useRef(null),h=((v=e==null?void 0:e.choice)==null?void 0:v.next)??"room",f=s??h,p=jie(f,h);return{nextPick:f,nextCtl:p,nextSaved:o,nextRef:l,nextSaveRef:u,proposeNext:j=>a(Roe(j)?j:null),doNext:async()=>{if(!p.sends)return;const j=await t({action:"next",value:f},"next");await n(!0),j!=null&&j.ok&&(a(null),i(!0),window.setTimeout(()=>{var b;document.activeElement===u.current&&((b=l.current)==null||b.focus()),i(!1)},uue))}}}const hue=Object.freeze({text:"couldn't reach the deck server",reload:!0}),fue=Object.freeze({text:"still waiting on the deck server — claude-swap can be slow to answer",reload:!0});async function MR(e){return e.ok?{ok:!0,status:e.status,body:null}:{ok:!1,status:e.status,body:await e.json().catch(()=>null)}}function pue(e){const t=e.find(s=>!s.ok);if(!t)return null;const n=ld(t.body);return{text:ej(t.body,`the deck server answered ${t.status}`),...n?{raw:n}:{},reload:!0}}function pw(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 mw=e=>e!=null&&typeof e=="object"&&!Array.isArray(e),gw=e=>e==null||typeof e=="string",yw=e=>e==null||typeof e=="number"&&Number.isFinite(e)&&e>=0&&Number.isFinite(new Date(e).getTime());function mue(e){if(!mw(e)||typeof e.ok!="boolean")return!1;if(!e.ok)return gw(e.reason)&&gw(e.hint);if(!Array.isArray(e.accounts))return!1;const t=new Set;return e.accounts.every(n=>{if(!mw(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(gw)||![n.active,n.disabled,n.stale].every(a=>typeof a=="boolean")||!yw(n.fetchedAt)||!yw(n.nextAt)||!Array.isArray(n.lanes)))return!1;const s=new Set;return n.lanes.every(a=>!mw(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||!yw(a.resetAt==null?null:typeof a.resetAt=="number"?a.resetAt*1e3:NaN)?!1:(s.add(a.id),!0))})}const P6=15e3,gue=3e4;function D6(e){const[t,n]=g.useState(null),[s,a]=g.useState(null),[o,i]=g.useState(!1),[l,u]=g.useState(null),h=g.useRef(null),f=g.useRef(0),p=g.useRef(!1),m=g.useRef(new Set),w=g.useCallback(async(b=!1)=>{if(!p.current||!b&&m.current.size>0)return;const N=++f.current;b&&i(!0);const x=new AbortController;m.current.add(x);const S=window.setTimeout(()=>x.abort(),gue);try{const[C,_]=await Promise.all([fetch(`/api/claude-accounts${b?"?refresh=1":""}`,{signal:x.signal}),fetch("/api/cswap-auto",{signal:x.signal})]),[M,R]=await Promise.all([C.ok?C.json():null,_.ok?_.json():null]),P=pue([await MR(C),await MR(_)]);if(!p.current||N!==f.current)return;if(M&&!mue(M)){u(L=>pw(L,{text:"the deck server returned unreadable account data",reload:!0}));return}M&&(n(M),e(M)),R&&a(R),u(L=>pw(L,P))}catch{p.current&&N===f.current&&u(C=>pw(C,x.signal.aborted?fue:hue))}finally{window.clearTimeout(S),m.current.delete(x),p.current&&N===f.current&&i(!1)}},[e]);g.useEffect(()=>(p.current=!0,w(!0),h.current=window.setInterval(()=>w(!1),P6),()=>{p.current=!1,f.current++,h.current!=null&&window.clearInterval(h.current);for(const b of m.current)b.abort()}),[w]);const v=g.useCallback(b=>u(b),[]),j=g.useCallback(()=>u(null),[]);return{data:t,auto:s,reloading:o,failure:l,load:w,sayFailure:v,clearFailure:j}}const yue="#ap-rest-entry";function wue(e){return[`#${e}`,yue,...zP(null)]}function xue(e){const t=g.useRef(null),n=a=>{t.current=a.target.id||null},s=a=>{a.target.isConnected&&(t.current=null)};return g.useLayoutEffect(()=>{var o;const a=t.current;if(!(!a||!Un(((o=document.activeElement)==null?void 0:o.tagName)??null)))for(const i of wue(a)){const l=document.querySelector(i);if(l){l.focus();return}}},[e]),{onFocus:n,onBlur:s}}function vue({onClose:e,leaving:t,onReport:n,onRoster:s,lanWanted:a=!1,onLanShown:o}){var ba,Rr,Vn;sn("accounts-panel");const i=Tn(),{busy:l,claim:u,release:h,pressProps:f}=Zce(),[p,m]=g.useState("accounts"),[w,v]=g.useState(!1),[j,b]=g.useState(null),N=g.useRef(j);N.current=j;const[x,S]=g.useState(!1),[C,_]=g.useState(null),[M,R]=g.useState(!1),[P,L]=g.useState(null),[U,B]=g.useState(Yce),[A,q]=g.useState(O6),[T,F]=g.useState(null),[O,K]=g.useState(!1),V=g.useRef(s);V.current=s;const H=g.useCallback(we=>{var et;B(pt=>Sae(pt,we.accounts)),(et=V.current)==null||et.call(V,we)},[]),{data:D,auto:I,reloading:W,failure:Z,load:z,sayFailure:X,clearFailure:Y}=D6(H),J=xue(D),Q=g.useCallback(we=>{window.requestAnimationFrame(()=>{var et;if(Un(((et=document.activeElement)==null?void 0:et.tagName)??null))for(const pt of zP(we)){const Et=document.querySelector(pt);if(Et){Et.focus();return}}})},[]),te=g.useRef(null),le=tue({claim:u,release:h,load:z,clearFailure:Y,rescueFocus:Q,afterRemove:we=>{var et;return(et=te.current)==null?void 0:et.call(te,we)}}),{menu:de,menuFor:oe,swapNote:re,showMenu:he,dropMenu:pe,closeMenu:Le,sayInMenu:ge}=le,{switched:ve,post:je,doSwitch:Ee,noteSwitched:xe}=iue({data:D,claim:u,release:h,load:z,sayFailure:X,clearFailure:Y,sayInMenu:ge,rescueFocus:Q});te.current=we=>{const et=oue(we);et&&"switched"in et?xe(et.switched.num,et.switched.name):et&&X(et.failure)};const Ie=we=>{_(we),S(!0)},{threshold:De,thresholdPick:We,thresholdCtl:Ke,thresholdSaved:ye,thresholdRef:Fe,thresholdSaveRef:$e,thresholdCustom:Re,thresholdRefusal:rt,thresholdFieldRef:He,proposeThreshold:se,typeThreshold:ke,cancelThreshold:Ae,leaveThreshold:Oe,doThreshold:be}=cue({auto:I,post:je,load:z}),{nextPick:fe,nextCtl:_e,nextSaved:Ve,nextRef:ot,nextSaveRef:tt,proposeNext:wt,doNext:$t}=due({auto:I,post:je,load:z}),Vt=zN();g.useEffect(()=>{Xce(U)},[U]),g.useEffect(()=>{Kce(A)},[A]);const[er,Ss]=g.useState(()=>new Set),Wn=g.useCallback(we=>Ss(new Set(we)),[]),[es,Cs]=g.useState(()=>new Map),[yn,Hn]=g.useState(()=>new Map),Me=we=>{const et=sR([we])[0].key,pt=es.get(et);return{noCopyWorksNearby:er.has(et),sharedTo:(pt==null?void 0:pt.to)??null,sharedInUse:(pt==null?void 0:pt.inUse)===!0,elsewhere:yn.get(et)??null}},qe=(ba=D==null?void 0:D.accounts)==null?void 0:ba.find(we=>we.active),Je=qe?xi(qe,Vt,Me(qe)):null,_t=ve?(Rr=D==null?void 0:D.accounts)==null?void 0:Rr.find(we=>we.num===ve.num):void 0,Nt=_t?Me(_t).elsewhere:null,ts=Nt!=null&&Nt.length?`. Also active on ${q5(Nt)}: when one machine renews this login, the other is signed out.`:"",zn=(D==null?void 0:D.accounts)??[],wn=qe?zn.filter(we=>!we.active):[],Cr=W5(wn),xn=z5(A,wn),rn=Z1(H5(wn,xn,we=>uS(we,Vt),Vt),T),_s=g.useRef(!1),tr=g.useRef(!1),ns=g.useRef(!1),Es=g.useCallback(()=>{!_s.current&&!tr.current&&!ns.current&&F(null)},[]),_r=()=>F(we=>we??rn.map(ws)),Er={onPointerEnter:()=>{_s.current=!0,_r()},onPointerLeave:()=>{_s.current=!1,Es()},onFocus:we=>{we.target.matches(":focus-visible")&&(tr.current=!0,_r())},onBlur:we=>{we.currentTarget.contains(we.relatedTarget)||(tr.current=!1,Es())}},Ts=oe!=null&&wn.some(we=>we.num===oe)||j!=null&&wn.some(we=>we.num===j.num);g.useEffect(()=>{ns.current=Ts,Ts||Es()},[Ts,Es]);const ga=O&&wn.length>0;g.useEffect(()=>{ga||(_s.current=tr.current=ns.current=!1,F(null))},[ga]);const xt=g.useRef(!1);g.useEffect(()=>{xt.current&&wn.length===0&&Q(null),xt.current=wn.length>0},[wn.length,Q]);const ya=rn.length?zn.filter(we=>we.active):zn,As=zce(rn,Vt,Me),wa=Vce(qe,De,Vt),nr=Gce(I),Tr=we=>O&&rn.some(et=>et.num===we)?"ap-rest-list":"ap-scroll",Ar=(we,et="first")=>{he(we,et),b(null)},Rs=(we,et)=>{pe(),b(pt=>(pt==null?void 0:pt.anchor)===et?null:{num:we,anchor:et})},dn=g.useCallback((we=!1)=>{var pt;const et=N.current;we&&et&&((pt=document.getElementById(et.anchor))==null||pt.focus()),b(null)},[]),Lt=()=>{pe(),b(null),m("lan")},hn=g.useRef(p);g.useEffect(()=>{hn.current!==p&&(hn.current=p,window.requestAnimationFrame(()=>{var we;(we=document.getElementById(p==="lan"?"ap-lan-back":"ap-lan-entry"))==null||we.focus()}))},[p]),g.useEffect(()=>{D!=null&&D.ok&&v(!0)},[D==null?void 0:D.ok]),g.useEffect(()=>{!a||!w||(Lt(),o==null||o())},[a,w]),g.useEffect(()=>{t&&(pe(),b(null))},[t,pe]),g.useEffect(()=>{de&&(D!=null&&D.accounts)&&!D.accounts.some(we=>we.num===de.num)&&pe(),j&&(D!=null&&D.accounts)&&!D.accounts.some(we=>we.num===j.num)&&b(null)},[D,de,j,pe]),g.useEffect(()=>{P==null||!(D!=null&&D.accounts)||D.accounts.some(we=>we.num===P.num)||(L(null),Q(null))},[D,P,Q]);const xa=r.jsx("button",{type:"button",className:"glyph-btn",onClick:e,"aria-label":"Close accounts panel",title:Cn("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"})})}),go=we=>{var $r;const et=V5(U,we),pt=oe===we.num,Et=(Z==null?void 0:Z.row)===we.num?Z:null,sr=(ve==null?void 0:ve.num)===we.num,Mr=(re==null?void 0:re.at)===we.num?re:null,ss=Mr?zn.find(at=>at.num===Mr.displaced):void 0,fc=(j==null?void 0:j.anchor)===`ap-issue-${we.num}`;return r.jsx(Coe,{a:we,nowSec:Vt,lan:Me(we),opened:et,onToggleLanes:()=>B(at=>jae(at,we)),busy:l,pressProps:f,onSwitch:Ee,menuOpen:pt,onOpenMenu:Ar,onCloseMenu:Le,refusal:Et,onDismissRefusal:()=>Y(),onSignIn:Ie,switchedHere:sr,swapped:Mr,displaced:ss,issueExpanded:fc,onOpenIssue:Rs,sortKey:we.active?null:bae(xn),home:cw(we,($r=I==null?void 0:I.choice)==null?void 0:$r.home)?Moe(we,!!(I!=null&&I.enabled)):null,rotating:!!(I!=null&&I.enabled||I!=null&&I.external)},we.num)},va=D!=null&&D.ok&&(I!=null&&I.ok)?r.jsx(Doe,{auto:I,threshold:De,thresholdPick:We,thresholdCtl:Ke,thresholdSaved:ye,thresholdRef:Fe,thresholdSaveRef:$e,thresholdCustom:Re,thresholdRefusal:rt,thresholdFieldRef:He,proposeThreshold:se,typeThreshold:ke,cancelThreshold:Ae,leaveThreshold:Oe,doThreshold:be,nextPick:fe,nextCtl:_e,nextSaved:Ve,nextRef:ot,nextSaveRef:tt,proposeNext:wt,doNext:$t,pressProps:f,post:je,load:z}):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(Eoe,{canShare:(((Vn=D==null?void 0:D.accounts)==null?void 0:Vn.length)??0)>0,onAdd:()=>S(!0),onShareSet:()=>R(!0),onReload:()=>z(!0),pressProps:f,reloading:W,closeButton:xa}),p==="accounts"&&r.jsxs("div",{className:"ap-scroll",id:"ap-scroll",children:[D==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 ",P6/1e3," seconds."]}),r.jsx("button",{type:"button",className:"ap-fix",...f("reload",W),onClick:()=>z(!0).then(()=>Q(null)),children:W?"trying…":"try again"})]}):r.jsx("div",{className:"ap-empty",children:"Checking…"}):D.ok?r.jsxs(r.Fragment,{children:[qe&&(Je==null?void 0:Je.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":(j==null?void 0:j.anchor)==="ap-notice","aria-controls":(j==null?void 0:j.anchor)==="ap-notice"?"ap-issue-pop":void 0,onClick:()=>Rs(qe.num,"ap-notice"),children:[r.jsx(XN,{}),r.jsx("span",{className:"ap-issue-text",children:"Current account needs attention"})]}),Je.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"})]}),!qe&&D.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:D.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:ya.map(go)}),rn.length>0&&r.jsx(Bce,{peers:As,strained:wa,armed:nr,threshold:I!=null&&I.ok?De:null,open:O,onToggle:()=>K(we=>!we),order:xn,choices:Cr,onOrder:q,allOpen:G5(U,rn),onToggleAll:()=>B(we=>Nae(we,rn)),held:T!=null}),rn.length>0&&O&&r.jsxs("div",{className:"ap-rest-panel",id:"ap-rest-panel",children:[r.jsx("ul",{className:"ap-list ap-others",id:"ap-rest-list",...Er,children:rn.map(go)}),va]}),rn.length===0&&va,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:()=>Y(),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),de&&(()=>{var et,pt;const we=(et=D.accounts)==null?void 0:et.find(Et=>Et.num===de.num);return we?r.jsx(Sie,{a:we,accountMenu:le,slots:(D.accounts??[]).map(Et=>Et.num),boundaryId:Tr(we.num),nowSec:Vt,busy:l,pressProps:f,onProjects:()=>{L({num:we.num,name:we.alias??we.email??`account ${we.num}`}),Le(we.num)},onRotation:()=>je({action:"account",account:we.num,enabled:we.disabled},`rot-${we.num}`,"menu").then(Et=>{z(!0),Et!=null&&Et.ok&&Le(we.num)}),home:cw(we,(pt=I==null?void 0:I.choice)==null?void 0:pt.home),onHome:()=>{var Et;return je({action:"home",account:cw(we,(Et=I==null?void 0:I.choice)==null?void 0:Et.home)?null:we.num},`home-${we.num}`,"menu").then(sr=>{z(!0),sr!=null&&sr.ok&&Le(we.num)})}}):null})(),j&&(()=>{var pt;const we=(pt=D.accounts)==null?void 0:pt.find(Et=>Et.num===j.num),et=we?xi(we,Vt,Me(we)):null;return!we||!et?null:r.jsx(lae,{anchorId:j.anchor,boundaryId:j.anchor==="ap-notice"?"ap-scroll":Tr(we.num),issue:et,who:we.alias??we.email??`account ${we.num}`,fetchedAt:we.fetchedAt,nowSec:Vt,onClose:dn,onSignIn:()=>S(!0),onReport:n&&(()=>n({initialKind:et.tone==="warn"?"bug":"other",initialBody:`Account issue: ${et.text}. ${et.hint}`}))})})()]}):r.jsx(_oe,{data:D}),r.jsx("div",{className:"film-foot",children:r.jsx(sd,{film:"claudeAccounts"})})]}),r.jsxs("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:[ve?`Now active: ${ve.name}`:"",ve?ts:""]}),w&&r.jsx(Dce,{accounts:sR((D==null?void 0:D.accounts)??[]),onChanged:()=>z(!0),onNoCopy:Wn,onShared:Cs,onElsewhere:Hn,view:p==="lan",onOpen:Lt,onBack:()=>m("accounts"),closeButton:xa}),x&&r.jsx(h6,{email:C,onClose:()=>{S(!1),_(null)},onChanged:()=>z(!0)}),M&&r.jsx(Hce,{accounts:((D==null?void 0:D.accounts)??[]).map(we=>({num:we.num,email:we.email,alias:we.alias,org:we.org})),onClose:()=>R(!1),copyText:ho}),P!=null&&(()=>{var et;const we=(et=D==null?void 0:D.accounts)==null?void 0:et.find(pt=>pt.num===P.num);return D!=null&&D.accounts&&!we?null:r.jsx(oae,{num:P.num,name:we?we.alias??we.email??`account ${we.num}`:P.name,onClose:()=>L(null)})})()]})}function $R(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`}function bue(e,t,n=!1){const s=new Date(t*1e3),a=Array.from({length:7},(l,u)=>{const h=new Date(s.getFullYear(),s.getMonth(),s.getDate()+u);return{key:$R(h),date:h,entries:[],scheduled:0,outdated:0}}),o=new Map(a.map(l=>[l.key,l])),i=[];for(const l of e){const u=l.lanes.find(x=>x.id==="seven_day"),h=u==null?void 0:u.resetAt,f=h!=null&&h>0&&Number.isFinite(h)&&Number.isFinite(new Date(h*1e3).getTime())?h:null,p=Q1(l,"seven_day",t),m=xi(l,t),w=vm(l.fetchedAt),v=w==null,j=n||v||l.stale||l.staleCopy===!0||l.stopped===!0||(m==null?void 0:m.blocksSwitch)===!0||t*1e3-w>K5,b=n?"Last saved reading":m!=null&&m.blocksSwitch||l.staleCopy||l.stopped?(m==null?void 0:m.text)??"Not collecting":v?"Never read":j?`${l.stale?"Marked stale · ":""}Read ${ha(w,t)}`:null,N={key:ws(l),name:Y5(l),active:l.active,heldOut:l.disabled,at:f,used:p.counted?p.pct:p.last,stale:j,note:b};if(f==null)i.push({...N,reason:"unknown"});else if(f<=t)i.push({...N,reason:"passed"});else{const x=o.get($R(new Date(f*1e3)));x?(x.entries.push(N),j?x.outdated++:x.scheduled++):i.push({...N,reason:"outside"})}}for(const l of a)l.entries.sort((u,h)=>u.at-h.at);return{days:a,unscheduled:i}}const Pf=e=>e.toLocaleDateString(void 0,{weekday:"short"}),Cp=e=>e.toLocaleDateString(void 0,{month:"short",day:"numeric"}),Ou=e=>e.toLocaleDateString(void 0,{weekday:"long",month:"long",day:"numeric",year:"numeric"}),dS=(e,t)=>e-t<60?"less than 1m":yd(e,t);function Sm({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 Df({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 F6({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(Df,{entry:e}),o]}):s?r.jsxs("span",{className:"ap-reset-summary-content",children:[r.jsx(Df,{entry:e}),r.jsx(B6,{entry:e,older:a})]}):r.jsx(Df,{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 l=t.cells[i],u=l.counted?l.pct:l.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:u==null?"No usage reading":`${e.stale||!l.counted?"Last read: ":""}${oo(u)}% 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 ${dS(h,n)}`," · ",r.jsx(Sm,{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 B6({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: ":""}${oo(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 kue({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(F6,{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:[Cp(new Date(e.at*1e3))," · ",r.jsx(Sm,{at:e.at})]})]}),r.jsx(B6,{entry:e,past:e.reason==="passed"})]})})})}function LR({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":Ou(a.date),children:[r.jsxs("h4",{className:"vis-hidden",children:[Ou(a.date)," · ",o.length," ",o.length===1?"account":"accounts"]}),r.jsx("ul",{children:Array.from(new Set(o.map(i=>i.at))).map((i,l)=>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"}),l===0&&r.jsxs("time",{className:"ap-reset-day-label",dateTime:a.key,children:[Pf(a.date)," · ",Cp(a.date)]}),r.jsx(Sm,{at:i}),!s&&r.jsxs("span",{children:["in ",dS(i,n)]})]}),r.jsx("ul",{children:o.filter(u=>u.at===i).map(u=>r.jsx("li",{className:"ap-reset-entry","data-outdated":u.stale?"":void 0,children:r.jsx(F6,{entry:u,row:t.get(u.key),nowSec:n,withReading:!0,older:s})},u.key))})]},i))})]},a.key):null})})}function jue({accounts:e,nowSec:t,held:n,selectedDate:s=null,onSelect:a=()=>{},scope:o="upcoming",onScope:i=()=>{}}){const{days:l,unscheduled:u}=bue(e,t,n!=null),h=l.find(P=>P.key===s)??null,f=h?[h]:l,p=l.reduce((P,L)=>P+L.scheduled,0),m=f.reduce((P,L)=>P+L.outdated,0),w=l.reduce((P,L)=>P+L.outdated,0),v=h?h.scheduled:p,j=l.flatMap(P=>P.entries).find(P=>!P.stale),b=j?l.flatMap(P=>P.entries).filter(P=>!P.stale&&P.at===j.at):[],N=g.useRef(null),x=g.useRef(null),S=g.useRef(null);g.useEffect(()=>{var L,U;const P=S.current;P&&!P.isConnected&&document.activeElement===document.body&&((U=(L=x.current)==null?void 0:L.querySelector('.ap-reset-coverage-link[aria-pressed="true"]'))==null||U.focus({preventScroll:!0}))});const C=()=>{N.current&&(N.current.scrollTop=0)},_=P=>{C(),a(null),i(P)},M=Intl.DateTimeFormat().resolvedOptions().timeZone,R=new Map(eS(e,t).rows.map(P=>[P.key,P]));return r.jsxs("div",{ref:x,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:j?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"ap-reset-next-identity",children:[r.jsxs("h3",{children:[r.jsx(TQ,{}),"Next reported reset ",r.jsx("span",{className:"ap-reset-global",children:"· all days"})]}),b.length>1?r.jsxs("span",{className:"ap-reset-name",children:[b.length," accounts"]}):r.jsxs("details",{className:"ap-reset-next-account",children:[r.jsxs("summary",{title:j.name,children:[r.jsx(Df,{entry:j}),r.jsx("span",{className:"vis-hidden",children:" · Full account name"})]}),r.jsx("p",{className:"ap-reset-full-name",children:j.name})]}),r.jsxs("p",{children:[Pf(new Date(j.at*1e3)),", ",Cp(new Date(j.at*1e3))," · ",r.jsx(Sm,{at:j.at})]}),r.jsxs("p",{className:"ap-reset-next-note",children:["Reported time · recent reading",b.length>1?"s":j.used!=null?` · ${oo(j.used)}% weekly used`:""]})]}),r.jsxs("p",{className:"ap-reset-countdown",children:[r.jsx("strong",{children:dS(j.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:()=>_("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:()=>_("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:()=>_("other"),children:[r.jsx("b",{children:u.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:M})]}),r.jsx("ol",{className:"ap-reset-week",role:"list","aria-label":"Seven-day reset counts",children:l.map((P,L)=>r.jsx("li",{"data-today":L===0?"":void 0,children:r.jsxs("button",{type:"button",className:"ap-reset-day-button","aria-current":L===0?"date":void 0,"data-active":P.scheduled>0?"":void 0,"aria-pressed":(h==null?void 0:h.key)===P.key,"aria-label":`${Ou(P.date)}: ${P.scheduled} scheduled resets${P.outdated?`, ${P.outdated} readings need updating`:""}`,onClick:()=>{C(),i("upcoming"),a((h==null?void 0:h.key)===P.key?null:P.key)},children:[r.jsxs("time",{dateTime:P.key,title:Ou(P.date),children:[r.jsx("span",{className:"ap-reset-weekday",children:L===0?"Today":Pf(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?`${Pf(h.date)}, ${Cp(h.date)}`:"All upcoming resets"," ",r.jsx("span",{children:v})]}),r.jsx("button",{className:"btn",type:"button","aria-pressed":!h,onClick:()=>{C(),a(null)},children:"All days"})]}),r.jsx("p",{className:"ap-reset-hint",role:"status",children:h?`Showing only ${Ou(h.date)}.`:"All days · select a date to narrow the agenda."}),v>0?r.jsx(LR,{days:f,rows:R,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(LR,{days:f,rows:R,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:[u.length," ",u.length===1?"account":"accounts"," · unknown, elapsed or later"]})]}),u.length>0?r.jsx("ul",{children:u.map(P=>r.jsx(kue,{entry:P,row:R.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 ",M,"; 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 q6(e){return e>=90?"hi":e>=70?"mid":void 0}const U6=(e,t,n)=>`${e} ${e===1?t:n}`;function IR(e){const t=e.more>0?`, and ${U6(e.more,"more account","more accounts")} in the same minute`:"";return`First: ${e.name} (${oo(e.pct)}% used)${t}`}function Nue({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}=Mae(e.used??0),l=Math.round(Zo(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 u=e.nextReset?yd(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:[l,"%"]})," average remaining"]}),r.jsx("div",{className:"ap-report-meter","data-level":q6(o),"aria-hidden":!0,children:r.jsx("i",{style:{"--left":i/100}})}),u&&e.nextReset&&r.jsxs("p",{className:"ap-report-reset",title:IR(e.nextReset),children:[r.jsxs("span",{children:["Next reported reset in ",r.jsx("span",{className:"ap-report-num",children:u})]}),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:[". ",IR(e.nextReset)]})]}),a]})}function Sue({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"})]}):`${oo(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":q6(e.pct),children:[oo(e.pct),"%"]})]})}function Cue({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=yd(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 _ue={ready:"Ready",limited:"Limited",exhausted:"Exhausted",stale:"Stale"};function Eue({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}),_ue[e.status]]}),Object.values(e.cells).some(t=>!t.counted&&t.reset)&&r.jsx("span",{className:"ap-report-state-note",children:"Awaiting read"})]})}function Tue({row:e,nowSec:t}){const n=_ae(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 Aue(){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 Rue({accounts:e,nowSec:t,held:n,sort:s=null,onSort:a=()=>{}}){const o=eS(e,t),i=o.rows.length,l=Math.round(Zo(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:l})," of ",U6(i,"Claude account","Claude accounts")," ready"]}),r.jsxs("p",{className:"ap-report-confidence",children:["Based on last readings",o.rows.some(u=>Object.values(u.cells).some(h=>!h.counted&&h.reset))&&" · elapsed reset times need fresh readings",o.rows.some(u=>u.heldOut)&&` · ${o.rows.filter(u=>u.heldOut).length} held out of rotation`]})]}),r.jsx("div",{className:"ap-report-sums",children:o.windows.map(u=>r.jsx(Nue,{w:u,nowSec:t},u.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",{}),ii.map(u=>r.jsxs(g.Fragment,{children:[r.jsx("col",{className:"ap-report-col-win"}),r.jsx("col",{className:"ap-report-col-reset"})]},u.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(vl,{col:"account",label:"Account",sort:s,next:uu,onSort:a}),ii.map(u=>r.jsxs(g.Fragment,{children:[r.jsx(vl,{col:u.id,label:`${u.label} used`,sort:s,next:uu,onSort:a}),r.jsx(vl,{col:`${u.id}_reset`,label:`${u.label} reset`,sort:s,next:uu,onSort:a})]},u.id)),r.jsx(vl,{col:"status",label:"Status",sort:s,next:uu,onSort:a}),r.jsx(vl,{col:"updated",label:"Updated",className:"ap-report-upd-h",sort:s,next:uu,onSort:a})]})}),r.jsx("tbody",{children:o.rows.map((u,h)=>r.jsxs("tr",{"data-active":u.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:u.name,children:u.name}),u.active&&r.jsx("span",{className:"ap-report-current",children:"Current"}),u.heldOut&&r.jsx("span",{className:"ap-report-tag",children:"held out"})]})}),ii.map(f=>r.jsxs(g.Fragment,{children:[r.jsx(Sue,{cell:u.cells[f.id],label:f.label}),r.jsx(Cue,{at:u.resets[f.id],nowSec:t,label:f.label})]},f.id)),r.jsx(Eue,{row:u}),r.jsx(Tue,{row:u,nowSec:t})]},u.num))})]})}),r.jsxs("details",{className:"ap-report-how",children:[r.jsxs("summary",{children:[r.jsx(Aue,{}),"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 Mue={accounts:"Account capacity",calendar:"Reset calendar"};function $ue({accounts:e,order:t,failed:n,nowSec:s,onClose:a,view:o}){const i=g.useRef(null),l=gt(a,{focusRef:i}),u=yt(a),[h,f]=g.useState("upcoming"),[p,m]=g.useState(null),[w,v]=g.useState(e??[]);g.useEffect(()=>{e!=null&&v(e)},[e]);const j=$ae(n,e==null,w.length>0),[b,N]=g.useState(null),x=Z1(w,(b==null?void 0:b.order)??t),S=C=>{const _=eS(Z1(w,t),s).rows;N({sort:C,order:Rae(_,C).map(M=>M.key)})};return kt.createPortal(r.jsx("div",{className:"modal-backdrop",...u,role:"presentation",children:r.jsxs("div",{ref:l,className:"modal ap-report-modal","data-view":o,onClick:C=>C.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ap-report-title",children:[r.jsxs("header",{className:"modal-head ap-proj-head",children:[r.jsx("div",{className:"ap-proj-titlewrap",children:r.jsx("h2",{id:"ap-report-title",children:Mue[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:j??""}),o==="accounts"?r.jsx(Rue,{accounts:x,nowSec:s,held:j,sort:(b==null?void 0:b.sort)??null,onSort:S}):r.jsx(jue,{accounts:x,nowSec:s,held:j,selectedDate:p,onSelect:m,scope:h,onScope:f})]})}),document.body)}function Lue(e,t,n){const s=e.filter(o=>o.active);if(s.length===0)return e.map(ws);const a=e.filter(o=>!o.active);return[...s,...H5(a,z5(t,a),o=>uS(o,n),n)].map(ws)}function Iue(){}function Oue({view:e,onClose:t}){const{data:n,failure:s}=D6(Iue),a=zN(),[o,i]=g.useState(null);return g.useEffect(()=>{o==null&&n&&i(Lue(n.accounts??[],O6(),a))},[n,o,a]),o==null&&s==null?null:r.jsx($ue,{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 Pue({width:e,children:t}){const n=g.useRef(null);return g.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 Due=16,Fue=120;function Bue(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 que(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 Uue(e,t){return Bue(e,t,Due)?"over":que(e,t)<=Fue?"near":"far"}function Wue(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 Hue(){const[e,t]=g.useState(!1),[n,s]=g.useState(""),[a,o]=g.useState("far"),i=g.useRef(null),l=Nl(e,140),u=g.useCallback(m=>{var j;const w=(j=i.current)==null?void 0:j.getBoundingClientRect(),v=Wue(m);return w&&v?Uue(v,w):"far"},[]),h=g.useCallback(m=>{m!==null&&(s(m),t(!0)),o("far")},[]),f=g.useCallback(m=>{o(u(m))},[u]),p=g.useCallback((m,w)=>{const v=w&&u(m)==="over";return t(!1),v},[u]);return{trashDragging:e,trashLabel:n,trashState:a,trashZoneRef:i,trashPhase:l,beginTrashDrag:h,trackTrashDrag:f,endTrashDrag:p}}const zue=420;function Vue(){const[e,t]=g.useState(!1),n=g.useRef(null),s=g.useCallback(()=>{n.current&&(window.clearTimeout(n.current),n.current=null),t(!1)},[]),a=g.useCallback(o=>{o.length!==0&&queueMicrotask(()=>{t(!0),n.current&&window.clearTimeout(n.current),n.current=window.setTimeout(()=>t(!1),zue+80)})},[]);return g.useEffect(()=>()=>{n.current&&window.clearTimeout(n.current)},[]),{bubbling:e,endBubble:s,onBubble:a}}const hS=11;function W6(e=0){return hS+Math.min(0,e)}const H6=7.2,z6=6.6,Gue={width:104,height:48},OR={width:96,height:44},V6={width:220,height:103};function Kue(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)?V6:{width:Math.max(160,t),height:Math.max(72,n)}}function ww(e,t,n){return e.width*t>=n.width&&e.height*t>=n.height}function Yue(e,t,n=V6,s=hS){if(!Number.isFinite(t)||t<=0)return e??"detail";const a=s*t;return e==="detail"?a>=z6?"detail":ww(n,t,OR)?"compact":"overview":a>=H6?"detail":e==="compact"?ww(n,t,OR)?"compact":"overview":ww(n,t,Gue)?"compact":"overview"}function Xue(e,t,n=hS){return e>=H6/n?e:Math.max(e,Math.min(t,z6/n-.001))}const Zue=.8,Jue=1;function Que({stateRef:e,measuredRef:t,measuredVersionRef:n,canvasRef:s}){const[a,o]=g.useState("detail"),i=g.useRef(null),l=g.useRef(null),u=g.useCallback(()=>{var w;const f=n.current;if(((w=l.current)==null?void 0:w.version)===f)return l.current.card;const p=[];for(const v of e.current.agents.keys()){const j=t.current.get(v);j&&p.push(j)}const m=Kue(p);return l.current={version:f,card:m},m},[]),h=g.useCallback(f=>{var m;const p=Yue(i.current,f,u(),W6(DN[FN()]));return p===i.current?null:(i.current=p,(m=s.current)==null||m.setAttribute("data-lod",p),o(p),p)},[u,s]);return{lod:a,lodRef:i,applyZoom:h}}const ede=40,tde=120;function nde(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)},l=(u,h,f)=>{if(n!=null){if(s<=u)return;i()}const p=Math.min(f,Math.max(0,u-h));s=u,n=t.setTimeout(o,p)};return{live(u=ede){const h=t.now(),f=Math.max(a+u,h);if(f<=h){i(),o();return}l(f,h,u)},replay(u=tde){i(),s=t.now()+u,n=t.setTimeout(o,u)},flush(){i(),o()},cancel(){i()}}}const sde=6,rde="ccdeck-tabs";function ade(e){return e>=sde}function ode(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,l)=>setTimeout(i,l)){return new Promise(i=>{const l=new Set,u=h=>{const f=h.data;(f==null?void 0:f.kind)==="here"&&f.to===t&&f.streaming&&l.add(f.from)};e.addEventListener("message",u),e.postMessage({kind:"who",from:t}),o(()=>{e.removeEventListener("message",u),i(l.size)},a)})},leave(){var a;e.removeEventListener("message",s),(a=e.close)==null||a.call(e)}}}function ide({stateRef:e,rerender:t,pauseGate:n,chimesRef:s,desktopUpdateRef:a}){const[o,i]=g.useState(!1),[l,u]=g.useState(!1),[h,f]=g.useState(!1),p=g.useRef(!0),[m,w]=g.useState(null);return g.useEffect(()=>{const v=new EventSource("/events"),j=nde(t,{now:()=>Date.now(),setTimeout:(S,C)=>window.setTimeout(S,C),clearTimeout:S=>window.clearTimeout(S)});let b=!1;const N=typeof BroadcastChannel=="function"?ode(new BroadcastChannel(rde),Math.random().toString(36).slice(2),()=>b):null,x=window.setInterval(()=>{b||!N||N.ask(600).then(S=>{b||u(ade(S))})},3e3);return v.addEventListener("open",()=>{i(!0),f(!0)}),v.addEventListener("error",()=>{i(!1),w(null)}),v.addEventListener("open",()=>{b=!0,u(!1)}),v.addEventListener("error",()=>{b=!1}),v.addEventListener("replay-end",()=>{p.current=!1,j.flush(),w(Date.now())}),v.addEventListener("desktop-update",S=>a.current(S.data)),v.addEventListener("hook",S=>{var C;try{const _=JSON.parse(S.data);if(!n.accept(_))return;e.current=dP(e.current,_);const M=_.replay===!0||p.current||Date.now()-_.receivedAt>3e4;M?j.replay():j.live();const R=rte(_,M);R&&((C=s.current)==null||C.play(R))}catch{}}),()=>{v.close(),j.cancel(),window.clearInterval(x),N==null||N.leave()}},[t]),{live:o,tabCapped:l,everConnected:h,liveSince:m}}const lde=200,cde=5*6e4,ude=6,dde=2*6e4;function xf(e,t){if(t.size!==0)for(const n of Array.from(e.keys()))t.has(n)||e.delete(n)}function hde(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 fde(e){const t=new Set;for(const n of e)t.add(n.id),t.add(`group:${n.sessionId}`),n.kind==="root"&&t.add(hN(n.id));return t}function pde(e){const t=new Set;for(const n of e)t.add(n.id),n.kind==="root"&&t.add(hN(n.id));return t}function mde(e,t){let n=aG(e,t,tT);oG(e,t,tT)&&(n=!0);const s=[],a=o=>{s.push(o)};return nG(e,t,lde,cde,a)&&(n=!0),sG(e,t,ude,dde,a)&&(n=!0),{changed:n,forgotten:s}}function gde(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 yde(e,t){const[n,s]=g.useState(()=>({ids:new Set,primary:null})),{ids:a,primary:o}=n,i=g.useCallback((h,f,p=!f)=>{s(m=>gde(m,h,f)),!f&&p&&t(!0)},[]),l=g.useCallback(()=>{s({ids:new Set,primary:null})},[]),u=g.useCallback(()=>{s(h=>{const f=hde(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:l,pruneSelectionToBoard:u}}function wde({stateRef:e,rerender:t,pruneSelectionToBoard:n,setContextFor:s,setSummaryFor:a}){const[o,i]=g.useState(Date.now());return g.useEffect(()=>{const l=setInterval(()=>{const u=Date.now();i(u);const{changed:h,forgotten:f}=mde(e.current,u);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(l)},[t]),o}function fS(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 xw,PR;function xde(){if(PR)return xw;PR=1;function e(){this.__data__=[],this.size=0}return xw=e,xw}var vw,DR;function lc(){if(DR)return vw;DR=1;function e(t,n){return t===n||t!==t&&n!==n}return vw=e,vw}var bw,FR;function Cm(){if(FR)return bw;FR=1;var e=lc();function t(n,s){for(var a=n.length;a--;)if(e(n[a][0],s))return a;return-1}return bw=t,bw}var kw,BR;function vde(){if(BR)return kw;BR=1;var e=Cm(),t=Array.prototype,n=t.splice;function s(a){var o=this.__data__,i=e(o,a);if(i<0)return!1;var l=o.length-1;return i==l?o.pop():n.call(o,i,1),--this.size,!0}return kw=s,kw}var jw,qR;function bde(){if(qR)return jw;qR=1;var e=Cm();function t(n){var s=this.__data__,a=e(s,n);return a<0?void 0:s[a][1]}return jw=t,jw}var Nw,UR;function kde(){if(UR)return Nw;UR=1;var e=Cm();function t(n){return e(this.__data__,n)>-1}return Nw=t,Nw}var Sw,WR;function jde(){if(WR)return Sw;WR=1;var e=Cm();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 Sw=t,Sw}var Cw,HR;function _m(){if(HR)return Cw;HR=1;var e=xde(),t=vde(),n=bde(),s=kde(),a=jde();function o(i){var l=-1,u=i==null?0:i.length;for(this.clear();++l<u;){var h=i[l];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,Cw=o,Cw}var _w,zR;function Nde(){if(zR)return _w;zR=1;var e=_m();function t(){this.__data__=new e,this.size=0}return _w=t,_w}var Ew,VR;function Sde(){if(VR)return Ew;VR=1;function e(t){var n=this.__data__,s=n.delete(t);return this.size=n.size,s}return Ew=e,Ew}var Tw,GR;function Cde(){if(GR)return Tw;GR=1;function e(t){return this.__data__.get(t)}return Tw=e,Tw}var Aw,KR;function _de(){if(KR)return Aw;KR=1;function e(t){return this.__data__.has(t)}return Aw=e,Aw}var Rw,YR;function G6(){if(YR)return Rw;YR=1;var e=typeof Bh=="object"&&Bh&&Bh.Object===Object&&Bh;return Rw=e,Rw}var Mw,XR;function Qs(){if(XR)return Mw;XR=1;var e=G6(),t=typeof self=="object"&&self&&self.Object===Object&&self,n=e||t||Function("return this")();return Mw=n,Mw}var $w,ZR;function cc(){if(ZR)return $w;ZR=1;var e=Qs(),t=e.Symbol;return $w=t,$w}var Lw,JR;function Ede(){if(JR)return Lw;JR=1;var e=cc(),t=Object.prototype,n=t.hasOwnProperty,s=t.toString,a=e?e.toStringTag:void 0;function o(i){var l=n.call(i,a),u=i[a];try{i[a]=void 0;var h=!0}catch{}var f=s.call(i);return h&&(l?i[a]=u:delete i[a]),f}return Lw=o,Lw}var Iw,QR;function Tde(){if(QR)return Iw;QR=1;var e=Object.prototype,t=e.toString;function n(s){return t.call(s)}return Iw=n,Iw}var Ow,e2;function ji(){if(e2)return Ow;e2=1;var e=cc(),t=Ede(),n=Tde(),s="[object Null]",a="[object Undefined]",o=e?e.toStringTag:void 0;function i(l){return l==null?l===void 0?a:s:o&&o in Object(l)?t(l):n(l)}return Ow=i,Ow}var Pw,t2;function js(){if(t2)return Pw;t2=1;function e(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}return Pw=e,Pw}var Dw,n2;function kd(){if(n2)return Dw;n2=1;var e=ji(),t=js(),n="[object AsyncFunction]",s="[object Function]",a="[object GeneratorFunction]",o="[object Proxy]";function i(l){if(!t(l))return!1;var u=e(l);return u==s||u==a||u==n||u==o}return Dw=i,Dw}var Fw,s2;function Ade(){if(s2)return Fw;s2=1;var e=Qs(),t=e["__core-js_shared__"];return Fw=t,Fw}var Bw,r2;function Rde(){if(r2)return Bw;r2=1;var e=Ade(),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 Bw=n,Bw}var qw,a2;function K6(){if(a2)return qw;a2=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 qw=n,qw}var Uw,o2;function Mde(){if(o2)return Uw;o2=1;var e=kd(),t=Rde(),n=js(),s=K6(),a=/[\\^$.*+?()[\]{}|]/g,o=/^\[object .+?Constructor\]$/,i=Function.prototype,l=Object.prototype,u=i.toString,h=l.hasOwnProperty,f=RegExp("^"+u.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 Uw=p,Uw}var Ww,i2;function $de(){if(i2)return Ww;i2=1;function e(t,n){return t==null?void 0:t[n]}return Ww=e,Ww}var Hw,l2;function Ni(){if(l2)return Hw;l2=1;var e=Mde(),t=$de();function n(s,a){var o=t(s,a);return e(o)?o:void 0}return Hw=n,Hw}var zw,c2;function pS(){if(c2)return zw;c2=1;var e=Ni(),t=Qs(),n=e(t,"Map");return zw=n,zw}var Vw,u2;function Em(){if(u2)return Vw;u2=1;var e=Ni(),t=e(Object,"create");return Vw=t,Vw}var Gw,d2;function Lde(){if(d2)return Gw;d2=1;var e=Em();function t(){this.__data__=e?e(null):{},this.size=0}return Gw=t,Gw}var Kw,h2;function Ide(){if(h2)return Kw;h2=1;function e(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n}return Kw=e,Kw}var Yw,f2;function Ode(){if(f2)return Yw;f2=1;var e=Em(),t="__lodash_hash_undefined__",n=Object.prototype,s=n.hasOwnProperty;function a(o){var i=this.__data__;if(e){var l=i[o];return l===t?void 0:l}return s.call(i,o)?i[o]:void 0}return Yw=a,Yw}var Xw,p2;function Pde(){if(p2)return Xw;p2=1;var e=Em(),t=Object.prototype,n=t.hasOwnProperty;function s(a){var o=this.__data__;return e?o[a]!==void 0:n.call(o,a)}return Xw=s,Xw}var Zw,m2;function Dde(){if(m2)return Zw;m2=1;var e=Em(),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 Zw=n,Zw}var Jw,g2;function Fde(){if(g2)return Jw;g2=1;var e=Lde(),t=Ide(),n=Ode(),s=Pde(),a=Dde();function o(i){var l=-1,u=i==null?0:i.length;for(this.clear();++l<u;){var h=i[l];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,Jw=o,Jw}var Qw,y2;function Bde(){if(y2)return Qw;y2=1;var e=Fde(),t=_m(),n=pS();function s(){this.size=0,this.__data__={hash:new e,map:new(n||t),string:new e}}return Qw=s,Qw}var ex,w2;function qde(){if(w2)return ex;w2=1;function e(t){var n=typeof t;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?t!=="__proto__":t===null}return ex=e,ex}var tx,x2;function Tm(){if(x2)return tx;x2=1;var e=qde();function t(n,s){var a=n.__data__;return e(s)?a[typeof s=="string"?"string":"hash"]:a.map}return tx=t,tx}var nx,v2;function Ude(){if(v2)return nx;v2=1;var e=Tm();function t(n){var s=e(this,n).delete(n);return this.size-=s?1:0,s}return nx=t,nx}var sx,b2;function Wde(){if(b2)return sx;b2=1;var e=Tm();function t(n){return e(this,n).get(n)}return sx=t,sx}var rx,k2;function Hde(){if(k2)return rx;k2=1;var e=Tm();function t(n){return e(this,n).has(n)}return rx=t,rx}var ax,j2;function zde(){if(j2)return ax;j2=1;var e=Tm();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 ax=t,ax}var ox,N2;function mS(){if(N2)return ox;N2=1;var e=Bde(),t=Ude(),n=Wde(),s=Hde(),a=zde();function o(i){var l=-1,u=i==null?0:i.length;for(this.clear();++l<u;){var h=i[l];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,ox=o,ox}var ix,S2;function Vde(){if(S2)return ix;S2=1;var e=_m(),t=pS(),n=mS(),s=200;function a(o,i){var l=this.__data__;if(l instanceof e){var u=l.__data__;if(!t||u.length<s-1)return u.push([o,i]),this.size=++l.size,this;l=this.__data__=new n(u)}return l.set(o,i),this.size=l.size,this}return ix=a,ix}var lx,C2;function Am(){if(C2)return lx;C2=1;var e=_m(),t=Nde(),n=Sde(),s=Cde(),a=_de(),o=Vde();function i(l){var u=this.__data__=new e(l);this.size=u.size}return i.prototype.clear=t,i.prototype.delete=n,i.prototype.get=s,i.prototype.has=a,i.prototype.set=o,lx=i,lx}var cx,_2;function gS(){if(_2)return cx;_2=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 cx=e,cx}var ux,E2;function Y6(){if(E2)return ux;E2=1;var e=Ni(),t=(function(){try{var n=e(Object,"defineProperty");return n({},"",{}),n}catch{}})();return ux=t,ux}var dx,T2;function Rm(){if(T2)return dx;T2=1;var e=Y6();function t(n,s,a){s=="__proto__"&&e?e(n,s,{configurable:!0,enumerable:!0,value:a,writable:!0}):n[s]=a}return dx=t,dx}var hx,A2;function Mm(){if(A2)return hx;A2=1;var e=Rm(),t=lc(),n=Object.prototype,s=n.hasOwnProperty;function a(o,i,l){var u=o[i];(!(s.call(o,i)&&t(u,l))||l===void 0&&!(i in o))&&e(o,i,l)}return hx=a,hx}var fx,R2;function jd(){if(R2)return fx;R2=1;var e=Mm(),t=Rm();function n(s,a,o,i){var l=!o;o||(o={});for(var u=-1,h=a.length;++u<h;){var f=a[u],p=i?i(o[f],s[f],f,o,s):void 0;p===void 0&&(p=s[f]),l?t(o,f,p):e(o,f,p)}return o}return fx=n,fx}var px,M2;function Gde(){if(M2)return px;M2=1;function e(t,n){for(var s=-1,a=Array(t);++s<t;)a[s]=n(s);return a}return px=e,px}var mx,$2;function Sr(){if($2)return mx;$2=1;function e(t){return t!=null&&typeof t=="object"}return mx=e,mx}var gx,L2;function Kde(){if(L2)return gx;L2=1;var e=ji(),t=Sr(),n="[object Arguments]";function s(a){return t(a)&&e(a)==n}return gx=s,gx}var yx,I2;function Nd(){if(I2)return yx;I2=1;var e=Kde(),t=Sr(),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 yx=o,yx}var wx,O2;function zt(){if(O2)return wx;O2=1;var e=Array.isArray;return wx=e,wx}var ju={exports:{}},xx,P2;function Yde(){if(P2)return xx;P2=1;function e(){return!1}return xx=e,xx}ju.exports;var D2;function uc(){return D2||(D2=1,(function(e,t){var n=Qs(),s=Yde(),a=t&&!t.nodeType&&t,o=a&&!0&&e&&!e.nodeType&&e,i=o&&o.exports===a,l=i?n.Buffer:void 0,u=l?l.isBuffer:void 0,h=u||s;e.exports=h})(ju,ju.exports)),ju.exports}var vx,F2;function $m(){if(F2)return vx;F2=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 vx=n,vx}var bx,B2;function yS(){if(B2)return bx;B2=1;var e=9007199254740991;function t(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=e}return bx=t,bx}var kx,q2;function Xde(){if(q2)return kx;q2=1;var e=ji(),t=yS(),n=Sr(),s="[object Arguments]",a="[object Array]",o="[object Boolean]",i="[object Date]",l="[object Error]",u="[object Function]",h="[object Map]",f="[object Number]",p="[object Object]",m="[object RegExp]",w="[object Set]",v="[object String]",j="[object WeakMap]",b="[object ArrayBuffer]",N="[object DataView]",x="[object Float32Array]",S="[object Float64Array]",C="[object Int8Array]",_="[object Int16Array]",M="[object Int32Array]",R="[object Uint8Array]",P="[object Uint8ClampedArray]",L="[object Uint16Array]",U="[object Uint32Array]",B={};B[x]=B[S]=B[C]=B[_]=B[M]=B[R]=B[P]=B[L]=B[U]=!0,B[s]=B[a]=B[b]=B[o]=B[N]=B[i]=B[l]=B[u]=B[h]=B[f]=B[p]=B[m]=B[w]=B[v]=B[j]=!1;function A(q){return n(q)&&t(q.length)&&!!B[e(q)]}return kx=A,kx}var jx,U2;function Lm(){if(U2)return jx;U2=1;function e(t){return function(n){return t(n)}}return jx=e,jx}var Nu={exports:{}};Nu.exports;var W2;function wS(){return W2||(W2=1,(function(e,t){var n=G6(),s=t&&!t.nodeType&&t,a=s&&!0&&e&&!e.nodeType&&e,o=a&&a.exports===s,i=o&&n.process,l=(function(){try{var u=a&&a.require&&a.require("util").types;return u||i&&i.binding&&i.binding("util")}catch{}})();e.exports=l})(Nu,Nu.exports)),Nu.exports}var Nx,H2;function Sd(){if(H2)return Nx;H2=1;var e=Xde(),t=Lm(),n=wS(),s=n&&n.isTypedArray,a=s?t(s):e;return Nx=a,Nx}var Sx,z2;function X6(){if(z2)return Sx;z2=1;var e=Gde(),t=Nd(),n=zt(),s=uc(),a=$m(),o=Sd(),i=Object.prototype,l=i.hasOwnProperty;function u(h,f){var p=n(h),m=!p&&t(h),w=!p&&!m&&s(h),v=!p&&!m&&!w&&o(h),j=p||m||w||v,b=j?e(h.length,String):[],N=b.length;for(var x in h)(f||l.call(h,x))&&!(j&&(x=="length"||w&&(x=="offset"||x=="parent")||v&&(x=="buffer"||x=="byteLength"||x=="byteOffset")||a(x,N)))&&b.push(x);return b}return Sx=u,Sx}var Cx,V2;function Im(){if(V2)return Cx;V2=1;var e=Object.prototype;function t(n){var s=n&&n.constructor,a=typeof s=="function"&&s.prototype||e;return n===a}return Cx=t,Cx}var _x,G2;function Z6(){if(G2)return _x;G2=1;function e(t,n){return function(s){return t(n(s))}}return _x=e,_x}var Ex,K2;function Zde(){if(K2)return Ex;K2=1;var e=Z6(),t=e(Object.keys,Object);return Ex=t,Ex}var Tx,Y2;function xS(){if(Y2)return Tx;Y2=1;var e=Im(),t=Zde(),n=Object.prototype,s=n.hasOwnProperty;function a(o){if(!e(o))return t(o);var i=[];for(var l in Object(o))s.call(o,l)&&l!="constructor"&&i.push(l);return i}return Tx=a,Tx}var Ax,X2;function pa(){if(X2)return Ax;X2=1;var e=kd(),t=yS();function n(s){return s!=null&&t(s.length)&&!e(s)}return Ax=n,Ax}var Rx,Z2;function mo(){if(Z2)return Rx;Z2=1;var e=X6(),t=xS(),n=pa();function s(a){return n(a)?e(a):t(a)}return Rx=s,Rx}var Mx,J2;function Jde(){if(J2)return Mx;J2=1;var e=jd(),t=mo();function n(s,a){return s&&e(a,t(a),s)}return Mx=n,Mx}var $x,Q2;function Qde(){if(Q2)return $x;Q2=1;function e(t){var n=[];if(t!=null)for(var s in Object(t))n.push(s);return n}return $x=e,$x}var Lx,eM;function ehe(){if(eM)return Lx;eM=1;var e=js(),t=Im(),n=Qde(),s=Object.prototype,a=s.hasOwnProperty;function o(i){if(!e(i))return n(i);var l=t(i),u=[];for(var h in i)h=="constructor"&&(l||!a.call(i,h))||u.push(h);return u}return Lx=o,Lx}var Ix,tM;function Si(){if(tM)return Ix;tM=1;var e=X6(),t=ehe(),n=pa();function s(a){return n(a)?e(a,!0):t(a)}return Ix=s,Ix}var Ox,nM;function the(){if(nM)return Ox;nM=1;var e=jd(),t=Si();function n(s,a){return s&&e(a,t(a),s)}return Ox=n,Ox}var Su={exports:{}};Su.exports;var sM;function J6(){return sM||(sM=1,(function(e,t){var n=Qs(),s=t&&!t.nodeType&&t,a=s&&!0&&e&&!e.nodeType&&e,o=a&&a.exports===s,i=o?n.Buffer:void 0,l=i?i.allocUnsafe:void 0;function u(h,f){if(f)return h.slice();var p=h.length,m=l?l(p):new h.constructor(p);return h.copy(m),m}e.exports=u})(Su,Su.exports)),Su.exports}var Px,rM;function Q6(){if(rM)return Px;rM=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 Px=e,Px}var Dx,aM;function eF(){if(aM)return Dx;aM=1;function e(t,n){for(var s=-1,a=t==null?0:t.length,o=0,i=[];++s<a;){var l=t[s];n(l,s,t)&&(i[o++]=l)}return i}return Dx=e,Dx}var Fx,oM;function tF(){if(oM)return Fx;oM=1;function e(){return[]}return Fx=e,Fx}var Bx,iM;function vS(){if(iM)return Bx;iM=1;var e=eF(),t=tF(),n=Object.prototype,s=n.propertyIsEnumerable,a=Object.getOwnPropertySymbols,o=a?function(i){return i==null?[]:(i=Object(i),e(a(i),function(l){return s.call(i,l)}))}:t;return Bx=o,Bx}var qx,lM;function nhe(){if(lM)return qx;lM=1;var e=jd(),t=vS();function n(s,a){return e(s,t(s),a)}return qx=n,qx}var Ux,cM;function bS(){if(cM)return Ux;cM=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 Ux=e,Ux}var Wx,uM;function Om(){if(uM)return Wx;uM=1;var e=Z6(),t=e(Object.getPrototypeOf,Object);return Wx=t,Wx}var Hx,dM;function nF(){if(dM)return Hx;dM=1;var e=bS(),t=Om(),n=vS(),s=tF(),a=Object.getOwnPropertySymbols,o=a?function(i){for(var l=[];i;)e(l,n(i)),i=t(i);return l}:s;return Hx=o,Hx}var zx,hM;function she(){if(hM)return zx;hM=1;var e=jd(),t=nF();function n(s,a){return e(s,t(s),a)}return zx=n,zx}var Vx,fM;function sF(){if(fM)return Vx;fM=1;var e=bS(),t=zt();function n(s,a,o){var i=a(s);return t(s)?i:e(i,o(s))}return Vx=n,Vx}var Gx,pM;function rF(){if(pM)return Gx;pM=1;var e=sF(),t=vS(),n=mo();function s(a){return e(a,n,t)}return Gx=s,Gx}var Kx,mM;function rhe(){if(mM)return Kx;mM=1;var e=sF(),t=nF(),n=Si();function s(a){return e(a,n,t)}return Kx=s,Kx}var Yx,gM;function ahe(){if(gM)return Yx;gM=1;var e=Ni(),t=Qs(),n=e(t,"DataView");return Yx=n,Yx}var Xx,yM;function ohe(){if(yM)return Xx;yM=1;var e=Ni(),t=Qs(),n=e(t,"Promise");return Xx=n,Xx}var Zx,wM;function aF(){if(wM)return Zx;wM=1;var e=Ni(),t=Qs(),n=e(t,"Set");return Zx=n,Zx}var Jx,xM;function ihe(){if(xM)return Jx;xM=1;var e=Ni(),t=Qs(),n=e(t,"WeakMap");return Jx=n,Jx}var Qx,vM;function dc(){if(vM)return Qx;vM=1;var e=ahe(),t=pS(),n=ohe(),s=aF(),a=ihe(),o=ji(),i=K6(),l="[object Map]",u="[object Object]",h="[object Promise]",f="[object Set]",p="[object WeakMap]",m="[object DataView]",w=i(e),v=i(t),j=i(n),b=i(s),N=i(a),x=o;return(e&&x(new e(new ArrayBuffer(1)))!=m||t&&x(new t)!=l||n&&x(n.resolve())!=h||s&&x(new s)!=f||a&&x(new a)!=p)&&(x=function(S){var C=o(S),_=C==u?S.constructor:void 0,M=_?i(_):"";if(M)switch(M){case w:return m;case v:return l;case j:return h;case b:return f;case N:return p}return C}),Qx=x,Qx}var ev,bM;function lhe(){if(bM)return ev;bM=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 ev=n,ev}var tv,kM;function oF(){if(kM)return tv;kM=1;var e=Qs(),t=e.Uint8Array;return tv=t,tv}var nv,jM;function kS(){if(jM)return nv;jM=1;var e=oF();function t(n){var s=new n.constructor(n.byteLength);return new e(s).set(new e(n)),s}return nv=t,nv}var sv,NM;function che(){if(NM)return sv;NM=1;var e=kS();function t(n,s){var a=s?e(n.buffer):n.buffer;return new n.constructor(a,n.byteOffset,n.byteLength)}return sv=t,sv}var rv,SM;function uhe(){if(SM)return rv;SM=1;var e=/\w*$/;function t(n){var s=new n.constructor(n.source,e.exec(n));return s.lastIndex=n.lastIndex,s}return rv=t,rv}var av,CM;function dhe(){if(CM)return av;CM=1;var e=cc(),t=e?e.prototype:void 0,n=t?t.valueOf:void 0;function s(a){return n?Object(n.call(a)):{}}return av=s,av}var ov,_M;function iF(){if(_M)return ov;_M=1;var e=kS();function t(n,s){var a=s?e(n.buffer):n.buffer;return new n.constructor(a,n.byteOffset,n.length)}return ov=t,ov}var iv,EM;function hhe(){if(EM)return iv;EM=1;var e=kS(),t=che(),n=uhe(),s=dhe(),a=iF(),o="[object Boolean]",i="[object Date]",l="[object Map]",u="[object Number]",h="[object RegExp]",f="[object Set]",p="[object String]",m="[object Symbol]",w="[object ArrayBuffer]",v="[object DataView]",j="[object Float32Array]",b="[object Float64Array]",N="[object Int8Array]",x="[object Int16Array]",S="[object Int32Array]",C="[object Uint8Array]",_="[object Uint8ClampedArray]",M="[object Uint16Array]",R="[object Uint32Array]";function P(L,U,B){var A=L.constructor;switch(U){case w:return e(L);case o:case i:return new A(+L);case v:return t(L,B);case j:case b:case N:case x:case S:case C:case _:case M:case R:return a(L,B);case l:return new A;case u:case p:return new A(L);case h:return n(L);case f:return new A;case m:return s(L)}}return iv=P,iv}var lv,TM;function lF(){if(TM)return lv;TM=1;var e=js(),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 lv=n,lv}var cv,AM;function cF(){if(AM)return cv;AM=1;var e=lF(),t=Om(),n=Im();function s(a){return typeof a.constructor=="function"&&!n(a)?e(t(a)):{}}return cv=s,cv}var uv,RM;function fhe(){if(RM)return uv;RM=1;var e=dc(),t=Sr(),n="[object Map]";function s(a){return t(a)&&e(a)==n}return uv=s,uv}var dv,MM;function phe(){if(MM)return dv;MM=1;var e=fhe(),t=Lm(),n=wS(),s=n&&n.isMap,a=s?t(s):e;return dv=a,dv}var hv,$M;function mhe(){if($M)return hv;$M=1;var e=dc(),t=Sr(),n="[object Set]";function s(a){return t(a)&&e(a)==n}return hv=s,hv}var fv,LM;function ghe(){if(LM)return fv;LM=1;var e=mhe(),t=Lm(),n=wS(),s=n&&n.isSet,a=s?t(s):e;return fv=a,fv}var pv,IM;function uF(){if(IM)return pv;IM=1;var e=Am(),t=gS(),n=Mm(),s=Jde(),a=the(),o=J6(),i=Q6(),l=nhe(),u=she(),h=rF(),f=rhe(),p=dc(),m=lhe(),w=hhe(),v=cF(),j=zt(),b=uc(),N=phe(),x=js(),S=ghe(),C=mo(),_=Si(),M=1,R=2,P=4,L="[object Arguments]",U="[object Array]",B="[object Boolean]",A="[object Date]",q="[object Error]",T="[object Function]",F="[object GeneratorFunction]",O="[object Map]",K="[object Number]",V="[object Object]",H="[object RegExp]",D="[object Set]",I="[object String]",W="[object Symbol]",Z="[object WeakMap]",z="[object ArrayBuffer]",X="[object DataView]",Y="[object Float32Array]",J="[object Float64Array]",Q="[object Int8Array]",te="[object Int16Array]",le="[object Int32Array]",de="[object Uint8Array]",oe="[object Uint8ClampedArray]",re="[object Uint16Array]",he="[object Uint32Array]",pe={};pe[L]=pe[U]=pe[z]=pe[X]=pe[B]=pe[A]=pe[Y]=pe[J]=pe[Q]=pe[te]=pe[le]=pe[O]=pe[K]=pe[V]=pe[H]=pe[D]=pe[I]=pe[W]=pe[de]=pe[oe]=pe[re]=pe[he]=!0,pe[q]=pe[T]=pe[Z]=!1;function Le(ge,ve,je,Ee,xe,Ie){var De,We=ve&M,Ke=ve&R,ye=ve&P;if(je&&(De=xe?je(ge,Ee,xe,Ie):je(ge)),De!==void 0)return De;if(!x(ge))return ge;var Fe=j(ge);if(Fe){if(De=m(ge),!We)return i(ge,De)}else{var $e=p(ge),Re=$e==T||$e==F;if(b(ge))return o(ge,We);if($e==V||$e==L||Re&&!xe){if(De=Ke||Re?{}:v(ge),!We)return Ke?u(ge,a(De,ge)):l(ge,s(De,ge))}else{if(!pe[$e])return xe?ge:{};De=w(ge,$e,We)}}Ie||(Ie=new e);var rt=Ie.get(ge);if(rt)return rt;Ie.set(ge,De),S(ge)?ge.forEach(function(ke){De.add(Le(ke,ve,je,ke,ge,Ie))}):N(ge)&&ge.forEach(function(ke,Ae){De.set(Ae,Le(ke,ve,je,Ae,ge,Ie))});var He=ye?Ke?f:h:Ke?_:C,se=Fe?void 0:He(ge);return t(se||ge,function(ke,Ae){se&&(Ae=ke,ke=ge[Ae]),n(De,Ae,Le(ke,ve,je,Ae,ge,Ie))}),De}return pv=Le,pv}var mv,OM;function yhe(){if(OM)return mv;OM=1;var e=uF(),t=4;function n(s){return e(s,t)}return mv=n,mv}var gv,PM;function jS(){if(PM)return gv;PM=1;function e(t){return function(){return t}}return gv=e,gv}var yv,DM;function whe(){if(DM)return yv;DM=1;function e(t){return function(n,s,a){for(var o=-1,i=Object(n),l=a(n),u=l.length;u--;){var h=l[t?u:++o];if(s(i[h],h,i)===!1)break}return n}}return yv=e,yv}var wv,FM;function NS(){if(FM)return wv;FM=1;var e=whe(),t=e();return wv=t,wv}var xv,BM;function SS(){if(BM)return xv;BM=1;var e=NS(),t=mo();function n(s,a){return s&&e(s,a,t)}return xv=n,xv}var vv,qM;function xhe(){if(qM)return vv;qM=1;var e=pa();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,l=s?i:-1,u=Object(a);(s?l--:++l<i)&&o(u[l],l,u)!==!1;);return a}}return vv=t,vv}var bv,UM;function Pm(){if(UM)return bv;UM=1;var e=SS(),t=xhe(),n=t(e);return bv=n,bv}var kv,WM;function Ci(){if(WM)return kv;WM=1;function e(t){return t}return kv=e,kv}var jv,HM;function dF(){if(HM)return jv;HM=1;var e=Ci();function t(n){return typeof n=="function"?n:e}return jv=t,jv}var Nv,zM;function hF(){if(zM)return Nv;zM=1;var e=gS(),t=Pm(),n=dF(),s=zt();function a(o,i){var l=s(o)?e:t;return l(o,n(i))}return Nv=a,Nv}var Sv,VM;function fF(){return VM||(VM=1,Sv=hF()),Sv}var Cv,GM;function vhe(){if(GM)return Cv;GM=1;var e=Pm();function t(n,s){var a=[];return e(n,function(o,i,l){s(o,i,l)&&a.push(o)}),a}return Cv=t,Cv}var _v,KM;function bhe(){if(KM)return _v;KM=1;var e="__lodash_hash_undefined__";function t(n){return this.__data__.set(n,e),this}return _v=t,_v}var Ev,YM;function khe(){if(YM)return Ev;YM=1;function e(t){return this.__data__.has(t)}return Ev=e,Ev}var Tv,XM;function pF(){if(XM)return Tv;XM=1;var e=mS(),t=bhe(),n=khe();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,Tv=s,Tv}var Av,ZM;function jhe(){if(ZM)return Av;ZM=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 Av=e,Av}var Rv,JM;function mF(){if(JM)return Rv;JM=1;function e(t,n){return t.has(n)}return Rv=e,Rv}var Mv,QM;function gF(){if(QM)return Mv;QM=1;var e=pF(),t=jhe(),n=mF(),s=1,a=2;function o(i,l,u,h,f,p){var m=u&s,w=i.length,v=l.length;if(w!=v&&!(m&&v>w))return!1;var j=p.get(i),b=p.get(l);if(j&&b)return j==l&&b==i;var N=-1,x=!0,S=u&a?new e:void 0;for(p.set(i,l),p.set(l,i);++N<w;){var C=i[N],_=l[N];if(h)var M=m?h(_,C,N,l,i,p):h(C,_,N,i,l,p);if(M!==void 0){if(M)continue;x=!1;break}if(S){if(!t(l,function(R,P){if(!n(S,P)&&(C===R||f(C,R,u,h,p)))return S.push(P)})){x=!1;break}}else if(!(C===_||f(C,_,u,h,p))){x=!1;break}}return p.delete(i),p.delete(l),x}return Mv=o,Mv}var $v,e$;function Nhe(){if(e$)return $v;e$=1;function e(t){var n=-1,s=Array(t.size);return t.forEach(function(a,o){s[++n]=[o,a]}),s}return $v=e,$v}var Lv,t$;function CS(){if(t$)return Lv;t$=1;function e(t){var n=-1,s=Array(t.size);return t.forEach(function(a){s[++n]=a}),s}return Lv=e,Lv}var Iv,n$;function She(){if(n$)return Iv;n$=1;var e=cc(),t=oF(),n=lc(),s=gF(),a=Nhe(),o=CS(),i=1,l=2,u="[object Boolean]",h="[object Date]",f="[object Error]",p="[object Map]",m="[object Number]",w="[object RegExp]",v="[object Set]",j="[object String]",b="[object Symbol]",N="[object ArrayBuffer]",x="[object DataView]",S=e?e.prototype:void 0,C=S?S.valueOf:void 0;function _(M,R,P,L,U,B,A){switch(P){case x:if(M.byteLength!=R.byteLength||M.byteOffset!=R.byteOffset)return!1;M=M.buffer,R=R.buffer;case N:return!(M.byteLength!=R.byteLength||!B(new t(M),new t(R)));case u:case h:case m:return n(+M,+R);case f:return M.name==R.name&&M.message==R.message;case w:case j:return M==R+"";case p:var q=a;case v:var T=L&i;if(q||(q=o),M.size!=R.size&&!T)return!1;var F=A.get(M);if(F)return F==R;L|=l,A.set(M,R);var O=s(q(M),q(R),L,U,B,A);return A.delete(M),O;case b:if(C)return C.call(M)==C.call(R)}return!1}return Iv=_,Iv}var Ov,s$;function Che(){if(s$)return Ov;s$=1;var e=rF(),t=1,n=Object.prototype,s=n.hasOwnProperty;function a(o,i,l,u,h,f){var p=l&t,m=e(o),w=m.length,v=e(i),j=v.length;if(w!=j&&!p)return!1;for(var b=w;b--;){var N=m[b];if(!(p?N in i:s.call(i,N)))return!1}var x=f.get(o),S=f.get(i);if(x&&S)return x==i&&S==o;var C=!0;f.set(o,i),f.set(i,o);for(var _=p;++b<w;){N=m[b];var M=o[N],R=i[N];if(u)var P=p?u(R,M,N,i,o,f):u(M,R,N,o,i,f);if(!(P===void 0?M===R||h(M,R,l,u,f):P)){C=!1;break}_||(_=N=="constructor")}if(C&&!_){var L=o.constructor,U=i.constructor;L!=U&&"constructor"in o&&"constructor"in i&&!(typeof L=="function"&&L instanceof L&&typeof U=="function"&&U instanceof U)&&(C=!1)}return f.delete(o),f.delete(i),C}return Ov=a,Ov}var Pv,r$;function _he(){if(r$)return Pv;r$=1;var e=Am(),t=gF(),n=She(),s=Che(),a=dc(),o=zt(),i=uc(),l=Sd(),u=1,h="[object Arguments]",f="[object Array]",p="[object Object]",m=Object.prototype,w=m.hasOwnProperty;function v(j,b,N,x,S,C){var _=o(j),M=o(b),R=_?f:a(j),P=M?f:a(b);R=R==h?p:R,P=P==h?p:P;var L=R==p,U=P==p,B=R==P;if(B&&i(j)){if(!i(b))return!1;_=!0,L=!1}if(B&&!L)return C||(C=new e),_||l(j)?t(j,b,N,x,S,C):n(j,b,R,N,x,S,C);if(!(N&u)){var A=L&&w.call(j,"__wrapped__"),q=U&&w.call(b,"__wrapped__");if(A||q){var T=A?j.value():j,F=q?b.value():b;return C||(C=new e),S(T,F,N,x,C)}}return B?(C||(C=new e),s(j,b,N,x,S,C)):!1}return Pv=v,Pv}var Dv,a$;function yF(){if(a$)return Dv;a$=1;var e=_he(),t=Sr();function n(s,a,o,i,l){return s===a?!0:s==null||a==null||!t(s)&&!t(a)?s!==s&&a!==a:e(s,a,o,i,n,l)}return Dv=n,Dv}var Fv,o$;function Ehe(){if(o$)return Fv;o$=1;var e=Am(),t=yF(),n=1,s=2;function a(o,i,l,u){var h=l.length,f=h,p=!u;if(o==null)return!f;for(o=Object(o);h--;){var m=l[h];if(p&&m[2]?m[1]!==o[m[0]]:!(m[0]in o))return!1}for(;++h<f;){m=l[h];var w=m[0],v=o[w],j=m[1];if(p&&m[2]){if(v===void 0&&!(w in o))return!1}else{var b=new e;if(u)var N=u(v,j,w,o,i,b);if(!(N===void 0?t(j,v,n|s,u,b):N))return!1}}return!0}return Fv=a,Fv}var Bv,i$;function wF(){if(i$)return Bv;i$=1;var e=js();function t(n){return n===n&&!e(n)}return Bv=t,Bv}var qv,l$;function The(){if(l$)return qv;l$=1;var e=wF(),t=mo();function n(s){for(var a=t(s),o=a.length;o--;){var i=a[o],l=s[i];a[o]=[i,l,e(l)]}return a}return qv=n,qv}var Uv,c$;function xF(){if(c$)return Uv;c$=1;function e(t,n){return function(s){return s==null?!1:s[t]===n&&(n!==void 0||t in Object(s))}}return Uv=e,Uv}var Wv,u$;function Ahe(){if(u$)return Wv;u$=1;var e=Ehe(),t=The(),n=xF();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 Wv=s,Wv}var Hv,d$;function hc(){if(d$)return Hv;d$=1;var e=ji(),t=Sr(),n="[object Symbol]";function s(a){return typeof a=="symbol"||t(a)&&e(a)==n}return Hv=s,Hv}var zv,h$;function _S(){if(h$)return zv;h$=1;var e=zt(),t=hc(),n=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,s=/^\w*$/;function a(o,i){if(e(o))return!1;var l=typeof o;return l=="number"||l=="symbol"||l=="boolean"||o==null||t(o)?!0:s.test(o)||!n.test(o)||i!=null&&o in Object(i)}return zv=a,zv}var Vv,f$;function Rhe(){if(f$)return Vv;f$=1;var e=mS(),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,l=a?a.apply(this,i):i[0],u=o.cache;if(u.has(l))return u.get(l);var h=s.apply(this,i);return o.cache=u.set(l,h)||u,h};return o.cache=new(n.Cache||e),o}return n.Cache=e,Vv=n,Vv}var Gv,p$;function Mhe(){if(p$)return Gv;p$=1;var e=Rhe(),t=500;function n(s){var a=e(s,function(i){return o.size===t&&o.clear(),i}),o=a.cache;return a}return Gv=n,Gv}var Kv,m$;function $he(){if(m$)return Kv;m$=1;var e=Mhe(),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,l,u,h){o.push(u?h.replace(n,"$1"):l||i)}),o});return Kv=s,Kv}var Yv,g$;function Dm(){if(g$)return Yv;g$=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 Yv=e,Yv}var Xv,y$;function Lhe(){if(y$)return Xv;y$=1;var e=cc(),t=Dm(),n=zt(),s=hc(),a=e?e.prototype:void 0,o=a?a.toString:void 0;function i(l){if(typeof l=="string")return l;if(n(l))return t(l,i)+"";if(s(l))return o?o.call(l):"";var u=l+"";return u=="0"&&1/l==-1/0?"-0":u}return Xv=i,Xv}var Zv,w$;function vF(){if(w$)return Zv;w$=1;var e=Lhe();function t(n){return n==null?"":e(n)}return Zv=t,Zv}var Jv,x$;function Fm(){if(x$)return Jv;x$=1;var e=zt(),t=_S(),n=$he(),s=vF();function a(o,i){return e(o)?o:t(o,i)?[o]:n(s(o))}return Jv=a,Jv}var Qv,v$;function Cd(){if(v$)return Qv;v$=1;var e=hc();function t(n){if(typeof n=="string"||e(n))return n;var s=n+"";return s=="0"&&1/n==-1/0?"-0":s}return Qv=t,Qv}var eb,b$;function Bm(){if(b$)return eb;b$=1;var e=Fm(),t=Cd();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 eb=n,eb}var tb,k$;function Ihe(){if(k$)return tb;k$=1;var e=Bm();function t(n,s,a){var o=n==null?void 0:e(n,s);return o===void 0?a:o}return tb=t,tb}var nb,j$;function Ohe(){if(j$)return nb;j$=1;function e(t,n){return t!=null&&n in Object(t)}return nb=e,nb}var sb,N$;function bF(){if(N$)return sb;N$=1;var e=Fm(),t=Nd(),n=zt(),s=$m(),a=yS(),o=Cd();function i(l,u,h){u=e(u,l);for(var f=-1,p=u.length,m=!1;++f<p;){var w=o(u[f]);if(!(m=l!=null&&h(l,w)))break;l=l[w]}return m||++f!=p?m:(p=l==null?0:l.length,!!p&&a(p)&&s(w,p)&&(n(l)||t(l)))}return sb=i,sb}var rb,S$;function kF(){if(S$)return rb;S$=1;var e=Ohe(),t=bF();function n(s,a){return s!=null&&t(s,a,e)}return rb=n,rb}var ab,C$;function Phe(){if(C$)return ab;C$=1;var e=yF(),t=Ihe(),n=kF(),s=_S(),a=wF(),o=xF(),i=Cd(),l=1,u=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,l|u)}}return ab=h,ab}var ob,_$;function jF(){if(_$)return ob;_$=1;function e(t){return function(n){return n==null?void 0:n[t]}}return ob=e,ob}var ib,E$;function Dhe(){if(E$)return ib;E$=1;var e=Bm();function t(n){return function(s){return e(s,n)}}return ib=t,ib}var lb,T$;function Fhe(){if(T$)return lb;T$=1;var e=jF(),t=Dhe(),n=_S(),s=Cd();function a(o){return n(o)?e(s(o)):t(o)}return lb=a,lb}var cb,A$;function ma(){if(A$)return cb;A$=1;var e=Ahe(),t=Phe(),n=Ci(),s=zt(),a=Fhe();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 cb=o,cb}var ub,R$;function NF(){if(R$)return ub;R$=1;var e=eF(),t=vhe(),n=ma(),s=zt();function a(o,i){var l=s(o)?e:t;return l(o,n(i,3))}return ub=a,ub}var db,M$;function Bhe(){if(M$)return db;M$=1;var e=Object.prototype,t=e.hasOwnProperty;function n(s,a){return s!=null&&t.call(s,a)}return db=n,db}var hb,$$;function SF(){if($$)return hb;$$=1;var e=Bhe(),t=bF();function n(s,a){return s!=null&&t(s,a,e)}return hb=n,hb}var fb,L$;function qhe(){if(L$)return fb;L$=1;var e=xS(),t=dc(),n=Nd(),s=zt(),a=pa(),o=uc(),i=Im(),l=Sd(),u="[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)||l(w)||n(w)))return!w.length;var v=t(w);if(v==u||v==h)return!w.size;if(i(w))return!e(w).length;for(var j in w)if(p.call(w,j))return!1;return!0}return fb=m,fb}var pb,I$;function CF(){if(I$)return pb;I$=1;function e(t){return t===void 0}return pb=e,pb}var mb,O$;function _F(){if(O$)return mb;O$=1;var e=Pm(),t=pa();function n(s,a){var o=-1,i=t(s)?Array(s.length):[];return e(s,function(l,u,h){i[++o]=a(l,u,h)}),i}return mb=n,mb}var gb,P$;function EF(){if(P$)return gb;P$=1;var e=Dm(),t=ma(),n=_F(),s=zt();function a(o,i){var l=s(o)?e:n;return l(o,t(i,3))}return gb=a,gb}var yb,D$;function Uhe(){if(D$)return yb;D$=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 yb=e,yb}var wb,F$;function Whe(){if(F$)return wb;F$=1;function e(t,n,s,a,o){return o(t,function(i,l,u){s=a?(a=!1,i):n(s,i,l,u)}),s}return wb=e,wb}var xb,B$;function TF(){if(B$)return xb;B$=1;var e=Uhe(),t=Pm(),n=ma(),s=Whe(),a=zt();function o(i,l,u){var h=a(i)?e:s,f=arguments.length<3;return h(i,n(l,4),u,f,t)}return xb=o,xb}var vb,q$;function Hhe(){if(q$)return vb;q$=1;var e=ji(),t=zt(),n=Sr(),s="[object String]";function a(o){return typeof o=="string"||!t(o)&&n(o)&&e(o)==s}return vb=a,vb}var bb,U$;function zhe(){if(U$)return bb;U$=1;var e=jF(),t=e("length");return bb=t,bb}var kb,W$;function Vhe(){if(W$)return kb;W$=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",s="\\u20d0-\\u20ff",a=t+n+s,o="\\ufe0e\\ufe0f",i="\\u200d",l=RegExp("["+i+e+a+o+"]");function u(h){return l.test(h)}return kb=u,kb}var jb,H$;function Ghe(){if(H$)return jb;H$=1;var e="\\ud800-\\udfff",t="\\u0300-\\u036f",n="\\ufe20-\\ufe2f",s="\\u20d0-\\u20ff",a=t+n+s,o="\\ufe0e\\ufe0f",i="["+e+"]",l="["+a+"]",u="\\ud83c[\\udffb-\\udfff]",h="(?:"+l+"|"+u+")",f="[^"+e+"]",p="(?:\\ud83c[\\udde6-\\uddff]){2}",m="[\\ud800-\\udbff][\\udc00-\\udfff]",w="\\u200d",v=h+"?",j="["+o+"]?",b="(?:"+w+"(?:"+[f,p,m].join("|")+")"+j+v+")*",N=j+v+b,x="(?:"+[f+l+"?",l,p,m,i].join("|")+")",S=RegExp(u+"(?="+u+")|"+x+N,"g");function C(_){for(var M=S.lastIndex=0;S.test(_);)++M;return M}return jb=C,jb}var Nb,z$;function Khe(){if(z$)return Nb;z$=1;var e=zhe(),t=Vhe(),n=Ghe();function s(a){return t(a)?n(a):e(a)}return Nb=s,Nb}var Sb,V$;function Yhe(){if(V$)return Sb;V$=1;var e=xS(),t=dc(),n=pa(),s=Hhe(),a=Khe(),o="[object Map]",i="[object Set]";function l(u){if(u==null)return 0;if(n(u))return s(u)?a(u):u.length;var h=t(u);return h==o||h==i?u.size:e(u).length}return Sb=l,Sb}var Cb,G$;function Xhe(){if(G$)return Cb;G$=1;var e=gS(),t=lF(),n=SS(),s=ma(),a=Om(),o=zt(),i=uc(),l=kd(),u=js(),h=Sd();function f(p,m,w){var v=o(p),j=v||i(p)||h(p);if(m=s(m,4),w==null){var b=p&&p.constructor;j?w=v?new b:[]:u(p)?w=l(b)?t(a(p)):{}:w={}}return(j?e:n)(p,function(N,x,S){return m(w,N,x,S)}),w}return Cb=f,Cb}var _b,K$;function Zhe(){if(K$)return _b;K$=1;var e=cc(),t=Nd(),n=zt(),s=e?e.isConcatSpreadable:void 0;function a(o){return n(o)||t(o)||!!(s&&o&&o[s])}return _b=a,_b}var Eb,Y$;function ES(){if(Y$)return Eb;Y$=1;var e=bS(),t=Zhe();function n(s,a,o,i,l){var u=-1,h=s.length;for(o||(o=t),l||(l=[]);++u<h;){var f=s[u];a>0&&o(f)?a>1?n(f,a-1,o,i,l):e(l,f):i||(l[l.length]=f)}return l}return Eb=n,Eb}var Tb,X$;function Jhe(){if(X$)return Tb;X$=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 Tb=e,Tb}var Ab,Z$;function AF(){if(Z$)return Ab;Z$=1;var e=Jhe(),t=Math.max;function n(s,a,o){return a=t(a===void 0?s.length-1:a,0),function(){for(var i=arguments,l=-1,u=t(i.length-a,0),h=Array(u);++l<u;)h[l]=i[a+l];l=-1;for(var f=Array(a+1);++l<a;)f[l]=i[l];return f[a]=o(h),e(s,this,f)}}return Ab=n,Ab}var Rb,J$;function Qhe(){if(J$)return Rb;J$=1;var e=jS(),t=Y6(),n=Ci(),s=t?function(a,o){return t(a,"toString",{configurable:!0,enumerable:!1,value:e(o),writable:!0})}:n;return Rb=s,Rb}var Mb,Q$;function efe(){if(Q$)return Mb;Q$=1;var e=800,t=16,n=Date.now;function s(a){var o=0,i=0;return function(){var l=n(),u=t-(l-i);if(i=l,u>0){if(++o>=e)return arguments[0]}else o=0;return a.apply(void 0,arguments)}}return Mb=s,Mb}var $b,eL;function RF(){if(eL)return $b;eL=1;var e=Qhe(),t=efe(),n=t(e);return $b=n,$b}var Lb,tL;function qm(){if(tL)return Lb;tL=1;var e=Ci(),t=AF(),n=RF();function s(a,o){return n(t(a,o,e),a+"")}return Lb=s,Lb}var Ib,nL;function MF(){if(nL)return Ib;nL=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 Ib=e,Ib}var Ob,sL;function tfe(){if(sL)return Ob;sL=1;function e(t){return t!==t}return Ob=e,Ob}var Pb,rL;function nfe(){if(rL)return Pb;rL=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 Pb=e,Pb}var Db,aL;function sfe(){if(aL)return Db;aL=1;var e=MF(),t=tfe(),n=nfe();function s(a,o,i){return o===o?n(a,o,i):e(a,t,i)}return Db=s,Db}var Fb,oL;function rfe(){if(oL)return Fb;oL=1;var e=sfe();function t(n,s){var a=n==null?0:n.length;return!!a&&e(n,s,0)>-1}return Fb=t,Fb}var Bb,iL;function afe(){if(iL)return Bb;iL=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 Bb=e,Bb}var qb,lL;function ofe(){if(lL)return qb;lL=1;function e(){}return qb=e,qb}var Ub,cL;function ife(){if(cL)return Ub;cL=1;var e=aF(),t=ofe(),n=CS(),s=1/0,a=e&&1/n(new e([,-0]))[1]==s?function(o){return new e(o)}:t;return Ub=a,Ub}var Wb,uL;function lfe(){if(uL)return Wb;uL=1;var e=pF(),t=rfe(),n=afe(),s=mF(),a=ife(),o=CS(),i=200;function l(u,h,f){var p=-1,m=t,w=u.length,v=!0,j=[],b=j;if(f)v=!1,m=n;else if(w>=i){var N=h?null:a(u);if(N)return o(N);v=!1,m=s,b=new e}else b=h?[]:j;e:for(;++p<w;){var x=u[p],S=h?h(x):x;if(x=f||x!==0?x:0,v&&S===S){for(var C=b.length;C--;)if(b[C]===S)continue e;h&&b.push(S),j.push(x)}else m(b,S,f)||(b!==j&&b.push(S),j.push(x))}return j}return Wb=l,Wb}var Hb,dL;function $F(){if(dL)return Hb;dL=1;var e=pa(),t=Sr();function n(s){return t(s)&&e(s)}return Hb=n,Hb}var zb,hL;function cfe(){if(hL)return zb;hL=1;var e=ES(),t=qm(),n=lfe(),s=$F(),a=t(function(o){return n(e(o,1,s,!0))});return zb=a,zb}var Vb,fL;function ufe(){if(fL)return Vb;fL=1;var e=Dm();function t(n,s){return e(s,function(a){return n[a]})}return Vb=t,Vb}var Gb,pL;function LF(){if(pL)return Gb;pL=1;var e=ufe(),t=mo();function n(s){return s==null?[]:e(s,t(s))}return Gb=n,Gb}var Kb,mL;function Ns(){if(mL)return Kb;mL=1;var e;if(typeof fS=="function")try{e={clone:yhe(),constant:jS(),each:fF(),filter:NF(),has:SF(),isArray:zt(),isEmpty:qhe(),isFunction:kd(),isUndefined:CF(),keys:mo(),map:EF(),reduce:TF(),size:Yhe(),transform:Xhe(),union:cfe(),values:LF()}}catch{}return e||(e=window._),Kb=e,Kb}var Yb,gL;function TS(){if(gL)return Yb;gL=1;var e=Ns();Yb=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(j,b){f(b)&&p.setNode(b,j)}),e.each(this._edgeObjs,function(j){p.hasNode(j.v)&&p.hasNode(j.w)&&p.setEdge(j,m.edge(j))});var w={};function v(j){var b=m.parent(j);return b===void 0||p.hasNode(b)?(w[j]=b,b):b in w?w[b]:v(b)}return this._isCompound&&e.each(p.nodes(),function(j){p.setParent(j,v(j))}),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,j){return w.length>1?m.setEdge(v,j,p):m.setEdge(v,j),j}),this},a.prototype.setEdge=function(){var f,p,m,w,v=!1,j=arguments[0];typeof j=="object"&&j!==null&&"v"in j?(f=j.v,p=j.w,m=j.name,arguments.length===2&&(w=arguments[1],v=!0)):(f=j,p=arguments[1],m=arguments[3],arguments.length>2&&(w=arguments[2],v=!0)),f=""+f,p=""+p,e.isUndefined(m)||(m=""+m);var b=l(this._isDirected,f,p,m);if(e.has(this._edgeLabels,b))return v&&(this._edgeLabels[b]=w),this;if(!e.isUndefined(m)&&!this._isMultigraph)throw new Error("Cannot set a named edge when isMultigraph = false");this.setNode(f),this.setNode(p),this._edgeLabels[b]=v?w:this._defaultEdgeLabelFn(f,p,m);var N=u(this._isDirected,f,p,m);return f=N.v,p=N.w,Object.freeze(N),this._edgeObjs[b]=N,o(this._preds[p],f),o(this._sucs[f],p),this._in[p][b]=N,this._out[f][b]=N,this._edgeCount++,this},a.prototype.edge=function(f,p,m){var w=arguments.length===1?h(this._isDirected,arguments[0]):l(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]):l(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]):l(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 l(f,p,m,w){var v=""+p,j=""+m;if(!f&&v>j){var b=v;v=j,j=b}return v+s+j+s+(e.isUndefined(w)?t:w)}function u(f,p,m,w){var v=""+p,j=""+m;if(!f&&v>j){var b=v;v=j,j=b}var N={v,w:j};return w&&(N.name=w),N}function h(f,p){return l(f,p.v,p.w,p.name)}return Yb}var Xb,yL;function dfe(){return yL||(yL=1,Xb="2.1.8"),Xb}var Zb,wL;function hfe(){return wL||(wL=1,Zb={Graph:TS(),version:dfe()}),Zb}var Jb,xL;function ffe(){if(xL)return Jb;xL=1;var e=Ns(),t=TS();Jb={write:n,read:o};function n(i){var l={options:{directed:i.isDirected(),multigraph:i.isMultigraph(),compound:i.isCompound()},nodes:s(i),edges:a(i)};return e.isUndefined(i.graph())||(l.value=e.clone(i.graph())),l}function s(i){return e.map(i.nodes(),function(l){var u=i.node(l),h=i.parent(l),f={v:l};return e.isUndefined(u)||(f.value=u),e.isUndefined(h)||(f.parent=h),f})}function a(i){return e.map(i.edges(),function(l){var u=i.edge(l),h={v:l.v,w:l.w};return e.isUndefined(l.name)||(h.name=l.name),e.isUndefined(u)||(h.value=u),h})}function o(i){var l=new t(i.options).setGraph(i.value);return e.each(i.nodes,function(u){l.setNode(u.v,u.value),u.parent&&l.setParent(u.v,u.parent)}),e.each(i.edges,function(u){l.setEdge({v:u.v,w:u.w,name:u.name},u.value)}),l}return Jb}var Qb,vL;function pfe(){if(vL)return Qb;vL=1;var e=Ns();Qb=t;function t(n){var s={},a=[],o;function i(l){e.has(s,l)||(s[l]=!0,o.push(l),e.each(n.successors(l),i),e.each(n.predecessors(l),i))}return e.each(n.nodes(),function(l){o=[],i(l),o.length&&a.push(o)}),a}return Qb}var ek,bL;function IF(){if(bL)return ek;bL=1;var e=Ns();ek=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],l=a[s];a[n]=l,a[s]=i,o[l.key]=n,o[i.key]=s},ek}var tk,kL;function OF(){if(kL)return tk;kL=1;var e=Ns(),t=IF();tk=s;var n=e.constant(1);function s(o,i,l,u){return a(o,String(i),l||n,u||function(h){return o.outEdges(h)})}function a(o,i,l,u){var h={},f=new t,p,m,w=function(v){var j=v.v!==p?v.v:v.w,b=h[j],N=l(v),x=m.distance+N;if(N<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+v+" Weight: "+N);x<b.distance&&(b.distance=x,b.predecessor=p,f.decrease(j,x))};for(o.nodes().forEach(function(v){var j=v===i?0:Number.POSITIVE_INFINITY;h[v]={distance:j},f.add(v,j)});f.size()>0&&(p=f.removeMin(),m=h[p],m.distance!==Number.POSITIVE_INFINITY);)u(p).forEach(w);return h}return tk}var nk,jL;function mfe(){if(jL)return nk;jL=1;var e=OF(),t=Ns();nk=n;function n(s,a,o){return t.transform(s.nodes(),function(i,l){i[l]=e(s,l,a,o)},{})}return nk}var sk,NL;function PF(){if(NL)return sk;NL=1;var e=Ns();sk=t;function t(n){var s=0,a=[],o={},i=[];function l(u){var h=o[u]={onStack:!0,lowlink:s,index:s++};if(a.push(u),n.successors(u).forEach(function(m){e.has(o,m)?o[m].onStack&&(h.lowlink=Math.min(h.lowlink,o[m].index)):(l(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(u!==p);i.push(f)}}return n.nodes().forEach(function(u){e.has(o,u)||l(u)}),i}return sk}var rk,SL;function gfe(){if(SL)return rk;SL=1;var e=Ns(),t=PF();rk=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 rk}var ak,CL;function yfe(){if(CL)return ak;CL=1;var e=Ns();ak=n;var t=e.constant(1);function n(a,o,i){return s(a,o||t,i||function(l){return a.outEdges(l)})}function s(a,o,i){var l={},u=a.nodes();return u.forEach(function(h){l[h]={},l[h][h]={distance:0},u.forEach(function(f){h!==f&&(l[h][f]={distance:Number.POSITIVE_INFINITY})}),i(h).forEach(function(f){var p=f.v===h?f.w:f.v,m=o(f);l[h][p]={distance:m,predecessor:h}})}),u.forEach(function(h){var f=l[h];u.forEach(function(p){var m=l[p];u.forEach(function(w){var v=m[h],j=f[w],b=m[w],N=v.distance+j.distance;N<b.distance&&(b.distance=N,b.predecessor=j.predecessor)})})}),l}return ak}var ok,_L;function DF(){if(_L)return ok;_L=1;var e=Ns();ok=t,t.CycleException=n;function t(s){var a={},o={},i=[];function l(u){if(e.has(o,u))throw new n;e.has(a,u)||(o[u]=!0,a[u]=!0,e.each(s.predecessors(u),l),delete o[u],i.push(u))}if(e.each(s.sinks(),l),e.size(a)!==s.nodeCount())throw new n;return i}function n(){}return n.prototype=new Error,ok}var ik,EL;function wfe(){if(EL)return ik;EL=1;var e=DF();ik=t;function t(n){try{e(n)}catch(s){if(s instanceof e.CycleException)return!1;throw s}return!0}return ik}var lk,TL;function FF(){if(TL)return lk;TL=1;var e=Ns();lk=t;function t(s,a,o){e.isArray(a)||(a=[a]);var i=(s.isDirected()?s.successors:s.neighbors).bind(s),l=[],u={};return e.each(a,function(h){if(!s.hasNode(h))throw new Error("Graph does not have node: "+h);n(s,h,o==="post",u,i,l)}),l}function n(s,a,o,i,l,u){e.has(i,a)||(i[a]=!0,o||u.push(a),e.each(l(a),function(h){n(s,h,o,i,l,u)}),o&&u.push(a))}return lk}var ck,AL;function xfe(){if(AL)return ck;AL=1;var e=FF();ck=t;function t(n,s){return e(n,s,"post")}return ck}var uk,RL;function vfe(){if(RL)return uk;RL=1;var e=FF();uk=t;function t(n,s){return e(n,s,"pre")}return uk}var dk,ML;function bfe(){if(ML)return dk;ML=1;var e=Ns(),t=TS(),n=IF();dk=s;function s(a,o){var i=new t,l={},u=new n,h;function f(m){var w=m.v===h?m.w:m.v,v=u.priority(w);if(v!==void 0){var j=o(m);j<v&&(l[w]=h,u.decrease(w,j))}}if(a.nodeCount()===0)return i;e.each(a.nodes(),function(m){u.add(m,Number.POSITIVE_INFINITY),i.setNode(m)}),u.decrease(a.nodes()[0],0);for(var p=!1;u.size()>0;){if(h=u.removeMin(),e.has(l,h))i.setEdge(h,l[h]);else{if(p)throw new Error("Input graph is not connected: "+a);p=!0}a.nodeEdges(h).forEach(f)}return i}return dk}var hk,$L;function kfe(){return $L||($L=1,hk={components:pfe(),dijkstra:OF(),dijkstraAll:mfe(),findCycles:gfe(),floydWarshall:yfe(),isAcyclic:wfe(),postorder:xfe(),preorder:vfe(),prim:bfe(),tarjan:PF(),topsort:DF()}),hk}var fk,LL;function jfe(){if(LL)return fk;LL=1;var e=hfe();return fk={Graph:e.Graph,json:ffe(),alg:kfe(),version:e.version},fk}var pk,IL;function Zs(){if(IL)return pk;IL=1;var e;if(typeof fS=="function")try{e=jfe()}catch{}return e||(e=window.graphlib),pk=e,pk}var mk,OL;function Nfe(){if(OL)return mk;OL=1;var e=uF(),t=1,n=4;function s(a){return e(a,t|n)}return mk=s,mk}var gk,PL;function Um(){if(PL)return gk;PL=1;var e=lc(),t=pa(),n=$m(),s=js();function a(o,i,l){if(!s(l))return!1;var u=typeof i;return(u=="number"?t(l)&&n(i,l.length):u=="string"&&i in l)?e(l[i],o):!1}return gk=a,gk}var yk,DL;function Sfe(){if(DL)return yk;DL=1;var e=qm(),t=lc(),n=Um(),s=Si(),a=Object.prototype,o=a.hasOwnProperty,i=e(function(l,u){l=Object(l);var h=-1,f=u.length,p=f>2?u[2]:void 0;for(p&&n(u[0],u[1],p)&&(f=1);++h<f;)for(var m=u[h],w=s(m),v=-1,j=w.length;++v<j;){var b=w[v],N=l[b];(N===void 0||t(N,a[b])&&!o.call(l,b))&&(l[b]=m[b])}return l});return yk=i,yk}var wk,FL;function Cfe(){if(FL)return wk;FL=1;var e=ma(),t=pa(),n=mo();function s(a){return function(o,i,l){var u=Object(o);if(!t(o)){var h=e(i,3);o=n(o),i=function(p){return h(u[p],p,u)}}var f=a(o,i,l);return f>-1?u[h?o[f]:f]:void 0}}return wk=s,wk}var xk,BL;function _fe(){if(BL)return xk;BL=1;var e=/\s/;function t(n){for(var s=n.length;s--&&e.test(n.charAt(s)););return s}return xk=t,xk}var vk,qL;function Efe(){if(qL)return vk;qL=1;var e=_fe(),t=/^\s+/;function n(s){return s&&s.slice(0,e(s)+1).replace(t,"")}return vk=n,vk}var bk,UL;function Tfe(){if(UL)return bk;UL=1;var e=Efe(),t=js(),n=hc(),s=NaN,a=/^[-+]0x[0-9a-f]+$/i,o=/^0b[01]+$/i,i=/^0o[0-7]+$/i,l=parseInt;function u(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)?l(h.slice(2),p?2:8):a.test(h)?s:+h}return bk=u,bk}var kk,WL;function BF(){if(WL)return kk;WL=1;var e=Tfe(),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 kk=s,kk}var jk,HL;function Afe(){if(HL)return jk;HL=1;var e=BF();function t(n){var s=e(n),a=s%1;return s===s?a?s-a:s:0}return jk=t,jk}var Nk,zL;function Rfe(){if(zL)return Nk;zL=1;var e=MF(),t=ma(),n=Afe(),s=Math.max;function a(o,i,l){var u=o==null?0:o.length;if(!u)return-1;var h=l==null?0:n(l);return h<0&&(h=s(u+h,0)),e(o,t(i,3),h)}return Nk=a,Nk}var Sk,VL;function Mfe(){if(VL)return Sk;VL=1;var e=Cfe(),t=Rfe(),n=e(t);return Sk=n,Sk}var Ck,GL;function qF(){if(GL)return Ck;GL=1;var e=ES();function t(n){var s=n==null?0:n.length;return s?e(n,1):[]}return Ck=t,Ck}var _k,KL;function $fe(){if(KL)return _k;KL=1;var e=NS(),t=dF(),n=Si();function s(a,o){return a==null?a:e(a,t(o),n)}return _k=s,_k}var Ek,YL;function Lfe(){if(YL)return Ek;YL=1;function e(t){var n=t==null?0:t.length;return n?t[n-1]:void 0}return Ek=e,Ek}var Tk,XL;function Ife(){if(XL)return Tk;XL=1;var e=Rm(),t=SS(),n=ma();function s(a,o){var i={};return o=n(o,3),t(a,function(l,u,h){e(i,u,o(l,u,h))}),i}return Tk=s,Tk}var Ak,ZL;function AS(){if(ZL)return Ak;ZL=1;var e=hc();function t(n,s,a){for(var o=-1,i=n.length;++o<i;){var l=n[o],u=s(l);if(u!=null&&(h===void 0?u===u&&!e(u):a(u,h)))var h=u,f=l}return f}return Ak=t,Ak}var Rk,JL;function Ofe(){if(JL)return Rk;JL=1;function e(t,n){return t>n}return Rk=e,Rk}var Mk,QL;function Pfe(){if(QL)return Mk;QL=1;var e=AS(),t=Ofe(),n=Ci();function s(a){return a&&a.length?e(a,n,t):void 0}return Mk=s,Mk}var $k,eI;function UF(){if(eI)return $k;eI=1;var e=Rm(),t=lc();function n(s,a,o){(o!==void 0&&!t(s[a],o)||o===void 0&&!(a in s))&&e(s,a,o)}return $k=n,$k}var Lk,tI;function Dfe(){if(tI)return Lk;tI=1;var e=ji(),t=Om(),n=Sr(),s="[object Object]",a=Function.prototype,o=Object.prototype,i=a.toString,l=o.hasOwnProperty,u=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=l.call(p,"constructor")&&p.constructor;return typeof m=="function"&&m instanceof m&&i.call(m)==u}return Lk=h,Lk}var Ik,nI;function WF(){if(nI)return Ik;nI=1;function e(t,n){if(!(n==="constructor"&&typeof t[n]=="function")&&n!="__proto__")return t[n]}return Ik=e,Ik}var Ok,sI;function Ffe(){if(sI)return Ok;sI=1;var e=jd(),t=Si();function n(s){return e(s,t(s))}return Ok=n,Ok}var Pk,rI;function Bfe(){if(rI)return Pk;rI=1;var e=UF(),t=J6(),n=iF(),s=Q6(),a=cF(),o=Nd(),i=zt(),l=$F(),u=uc(),h=kd(),f=js(),p=Dfe(),m=Sd(),w=WF(),v=Ffe();function j(b,N,x,S,C,_,M){var R=w(b,x),P=w(N,x),L=M.get(P);if(L){e(b,x,L);return}var U=_?_(R,P,x+"",b,N,M):void 0,B=U===void 0;if(B){var A=i(P),q=!A&&u(P),T=!A&&!q&&m(P);U=P,A||q||T?i(R)?U=R:l(R)?U=s(R):q?(B=!1,U=t(P,!0)):T?(B=!1,U=n(P,!0)):U=[]:p(P)||o(P)?(U=R,o(R)?U=v(R):(!f(R)||h(R))&&(U=a(P))):B=!1}B&&(M.set(P,U),C(U,P,S,_,M),M.delete(P)),e(b,x,U)}return Pk=j,Pk}var Dk,aI;function qfe(){if(aI)return Dk;aI=1;var e=Am(),t=UF(),n=NS(),s=Bfe(),a=js(),o=Si(),i=WF();function l(u,h,f,p,m){u!==h&&n(h,function(w,v){if(m||(m=new e),a(w))s(u,h,v,f,l,p,m);else{var j=p?p(i(u,v),w,v+"",u,h,m):void 0;j===void 0&&(j=w),t(u,v,j)}},o)}return Dk=l,Dk}var Fk,oI;function Ufe(){if(oI)return Fk;oI=1;var e=qm(),t=Um();function n(s){return e(function(a,o){var i=-1,l=o.length,u=l>1?o[l-1]:void 0,h=l>2?o[2]:void 0;for(u=s.length>3&&typeof u=="function"?(l--,u):void 0,h&&t(o[0],o[1],h)&&(u=l<3?void 0:u,l=1),a=Object(a);++i<l;){var f=o[i];f&&s(a,f,i,u)}return a})}return Fk=n,Fk}var Bk,iI;function Wfe(){if(iI)return Bk;iI=1;var e=qfe(),t=Ufe(),n=t(function(s,a,o){e(s,a,o)});return Bk=n,Bk}var qk,lI;function HF(){if(lI)return qk;lI=1;function e(t,n){return t<n}return qk=e,qk}var Uk,cI;function Hfe(){if(cI)return Uk;cI=1;var e=AS(),t=HF(),n=Ci();function s(a){return a&&a.length?e(a,n,t):void 0}return Uk=s,Uk}var Wk,uI;function zfe(){if(uI)return Wk;uI=1;var e=AS(),t=ma(),n=HF();function s(a,o){return a&&a.length?e(a,t(o,2),n):void 0}return Wk=s,Wk}var Hk,dI;function Vfe(){if(dI)return Hk;dI=1;var e=Qs(),t=function(){return e.Date.now()};return Hk=t,Hk}var zk,hI;function Gfe(){if(hI)return zk;hI=1;var e=Mm(),t=Fm(),n=$m(),s=js(),a=Cd();function o(i,l,u,h){if(!s(i))return i;l=t(l,i);for(var f=-1,p=l.length,m=p-1,w=i;w!=null&&++f<p;){var v=a(l[f]),j=u;if(v==="__proto__"||v==="constructor"||v==="prototype")return i;if(f!=m){var b=w[v];j=h?h(b,v,w):void 0,j===void 0&&(j=s(b)?b:n(l[f+1])?[]:{})}e(w,v,j),w=w[v]}return i}return zk=o,zk}var Vk,fI;function Kfe(){if(fI)return Vk;fI=1;var e=Bm(),t=Gfe(),n=Fm();function s(a,o,i){for(var l=-1,u=o.length,h={};++l<u;){var f=o[l],p=e(a,f);i(p,f)&&t(h,n(f,a),p)}return h}return Vk=s,Vk}var Gk,pI;function Yfe(){if(pI)return Gk;pI=1;var e=Kfe(),t=kF();function n(s,a){return e(s,a,function(o,i){return t(s,i)})}return Gk=n,Gk}var Kk,mI;function Xfe(){if(mI)return Kk;mI=1;var e=qF(),t=AF(),n=RF();function s(a){return n(t(a,void 0,e),a+"")}return Kk=s,Kk}var Yk,gI;function Zfe(){if(gI)return Yk;gI=1;var e=Yfe(),t=Xfe(),n=t(function(s,a){return s==null?{}:e(s,a)});return Yk=n,Yk}var Xk,yI;function Jfe(){if(yI)return Xk;yI=1;var e=Math.ceil,t=Math.max;function n(s,a,o,i){for(var l=-1,u=t(e((a-s)/(o||1)),0),h=Array(u);u--;)h[i?u:++l]=s,s+=o;return h}return Xk=n,Xk}var Zk,wI;function Qfe(){if(wI)return Zk;wI=1;var e=Jfe(),t=Um(),n=BF();function s(a){return function(o,i,l){return l&&typeof l!="number"&&t(o,i,l)&&(i=l=void 0),o=n(o),i===void 0?(i=o,o=0):i=n(i),l=l===void 0?o<i?1:-1:n(l),e(o,i,l,a)}}return Zk=s,Zk}var Jk,xI;function epe(){if(xI)return Jk;xI=1;var e=Qfe(),t=e();return Jk=t,Jk}var Qk,vI;function tpe(){if(vI)return Qk;vI=1;function e(t,n){var s=t.length;for(t.sort(n);s--;)t[s]=t[s].value;return t}return Qk=e,Qk}var e0,bI;function npe(){if(bI)return e0;bI=1;var e=hc();function t(n,s){if(n!==s){var a=n!==void 0,o=n===null,i=n===n,l=e(n),u=s!==void 0,h=s===null,f=s===s,p=e(s);if(!h&&!p&&!l&&n>s||l&&u&&f&&!h&&!p||o&&u&&f||!a&&f||!i)return 1;if(!o&&!l&&!p&&n<s||p&&a&&i&&!o&&!l||h&&a&&i||!u&&i||!f)return-1}return 0}return e0=t,e0}var t0,kI;function spe(){if(kI)return t0;kI=1;var e=npe();function t(n,s,a){for(var o=-1,i=n.criteria,l=s.criteria,u=i.length,h=a.length;++o<u;){var f=e(i[o],l[o]);if(f){if(o>=h)return f;var p=a[o];return f*(p=="desc"?-1:1)}}return n.index-s.index}return t0=t,t0}var n0,jI;function rpe(){if(jI)return n0;jI=1;var e=Dm(),t=Bm(),n=ma(),s=_F(),a=tpe(),o=Lm(),i=spe(),l=Ci(),u=zt();function h(f,p,m){p.length?p=e(p,function(j){return u(j)?function(b){return t(b,j.length===1?j[0]:j)}:j}):p=[l];var w=-1;p=e(p,o(n));var v=s(f,function(j,b,N){var x=e(p,function(S){return S(j)});return{criteria:x,index:++w,value:j}});return a(v,function(j,b){return i(j,b,m)})}return n0=h,n0}var s0,NI;function ape(){if(NI)return s0;NI=1;var e=ES(),t=rpe(),n=qm(),s=Um(),a=n(function(o,i){if(o==null)return[];var l=i.length;return l>1&&s(o,i[0],i[1])?i=[]:l>2&&s(i[0],i[1],i[2])&&(i=[i[0]]),t(o,e(i,1),[])});return s0=a,s0}var r0,SI;function ope(){if(SI)return r0;SI=1;var e=vF(),t=0;function n(s){var a=++t;return e(s)+a}return r0=n,r0}var a0,CI;function ipe(){if(CI)return a0;CI=1;function e(t,n,s){for(var a=-1,o=t.length,i=n.length,l={};++a<o;){var u=a<i?n[a]:void 0;s(l,t[a],u)}return l}return a0=e,a0}var o0,_I;function lpe(){if(_I)return o0;_I=1;var e=Mm(),t=ipe();function n(s,a){return t(s||[],a||[],e)}return o0=n,o0}var i0,EI;function Mt(){if(EI)return i0;EI=1;var e;if(typeof fS=="function")try{e={cloneDeep:Nfe(),constant:jS(),defaults:Sfe(),each:fF(),filter:NF(),find:Mfe(),flatten:qF(),forEach:hF(),forIn:$fe(),has:SF(),isUndefined:CF(),last:Lfe(),map:EF(),mapValues:Ife(),max:Pfe(),merge:Wfe(),min:Hfe(),minBy:zfe(),now:Vfe(),pick:Zfe(),range:epe(),reduce:TF(),sortBy:ape(),uniqueId:ope(),values:LF(),zipObject:lpe()}}catch{}return e||(e=window._),i0=e,i0}var l0,TI;function cpe(){if(TI)return l0;TI=1,l0=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 l0}var c0,AI;function upe(){if(AI)return c0;AI=1;var e=Mt(),t=Zs().Graph,n=cpe();c0=a;var s=e.constant(1);function a(h,f){if(h.nodeCount()<=1)return[];var p=l(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],j;h.nodeCount();){for(;j=v.dequeue();)i(h,f,p,j);for(;j=w.dequeue();)i(h,f,p,j);if(h.nodeCount()){for(var b=f.length-2;b>0;--b)if(j=f[b].dequeue(),j){m=m.concat(i(h,f,p,j,!0));break}}}return m}function i(h,f,p,m,w){var v=w?[]:void 0;return e.forEach(h.inEdges(m.v),function(j){var b=h.edge(j),N=h.node(j.v);w&&v.push({v:j.v,w:j.w}),N.out-=b,u(f,p,N)}),e.forEach(h.outEdges(m.v),function(j){var b=h.edge(j),N=j.w,x=h.node(N);x.in-=b,u(f,p,x)}),h.removeNode(m.v),v}function l(h,f){var p=new t,m=0,w=0;e.forEach(h.nodes(),function(b){p.setNode(b,{v:b,in:0,out:0})}),e.forEach(h.edges(),function(b){var N=p.edge(b.v,b.w)||0,x=f(b),S=N+x;p.setEdge(b.v,b.w,S),w=Math.max(w,p.node(b.v).out+=x),m=Math.max(m,p.node(b.w).in+=x)});var v=e.range(w+m+3).map(function(){return new n}),j=m+1;return e.forEach(p.nodes(),function(b){u(v,j,p.node(b))}),{graph:p,buckets:v,zeroIdx:j}}function u(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 c0}var u0,RI;function dpe(){if(RI)return u0;RI=1;var e=Mt(),t=upe();u0={run:n,undo:a};function n(o){var i=o.graph().acyclicer==="greedy"?t(o,l(o)):s(o);e.forEach(i,function(u){var h=o.edge(u);o.removeEdge(u),h.forwardName=u.name,h.reversed=!0,o.setEdge(u.w,u.v,h,e.uniqueId("rev"))});function l(u){return function(h){return u.edge(h).weight}}}function s(o){var i=[],l={},u={};function h(f){e.has(u,f)||(u[f]=!0,l[f]=!0,e.forEach(o.outEdges(f),function(p){e.has(l,p.w)?i.push(p):h(p.w)}),delete l[f])}return e.forEach(o.nodes(),h),i}function a(o){e.forEach(o.edges(),function(i){var l=o.edge(i);if(l.reversed){o.removeEdge(i);var u=l.forwardName;delete l.reversed,delete l.forwardName,o.setEdge(i.w,i.v,l,u)}})}return u0}var d0,MI;function Bn(){if(MI)return d0;MI=1;var e=Mt(),t=Zs().Graph;d0={addDummyNode:n,simplify:s,asNonCompoundGraph:a,successorWeights:o,predecessorWeights:i,intersectRect:l,buildLayerMatrix:u,normalizeRanks:h,removeEmptyRanks:f,addBorderNode:p,maxRank:m,partition:w,time:v,notime:j};function n(b,N,x,S){var C;do C=e.uniqueId(S);while(b.hasNode(C));return x.dummy=N,b.setNode(C,x),C}function s(b){var N=new t().setGraph(b.graph());return e.forEach(b.nodes(),function(x){N.setNode(x,b.node(x))}),e.forEach(b.edges(),function(x){var S=N.edge(x.v,x.w)||{weight:0,minlen:1},C=b.edge(x);N.setEdge(x.v,x.w,{weight:S.weight+C.weight,minlen:Math.max(S.minlen,C.minlen)})}),N}function a(b){var N=new t({multigraph:b.isMultigraph()}).setGraph(b.graph());return e.forEach(b.nodes(),function(x){b.children(x).length||N.setNode(x,b.node(x))}),e.forEach(b.edges(),function(x){N.setEdge(x,b.edge(x))}),N}function o(b){var N=e.map(b.nodes(),function(x){var S={};return e.forEach(b.outEdges(x),function(C){S[C.w]=(S[C.w]||0)+b.edge(C).weight}),S});return e.zipObject(b.nodes(),N)}function i(b){var N=e.map(b.nodes(),function(x){var S={};return e.forEach(b.inEdges(x),function(C){S[C.v]=(S[C.v]||0)+b.edge(C).weight}),S});return e.zipObject(b.nodes(),N)}function l(b,N){var x=b.x,S=b.y,C=N.x-x,_=N.y-S,M=b.width/2,R=b.height/2;if(!C&&!_)throw new Error("Not possible to find intersection inside of the rectangle");var P,L;return Math.abs(_)*M>Math.abs(C)*R?(_<0&&(R=-R),P=R*C/_,L=R):(C<0&&(M=-M),P=M,L=M*_/C),{x:x+P,y:S+L}}function u(b){var N=e.map(e.range(m(b)+1),function(){return[]});return e.forEach(b.nodes(),function(x){var S=b.node(x),C=S.rank;e.isUndefined(C)||(N[C][S.order]=x)}),N}function h(b){var N=e.min(e.map(b.nodes(),function(x){return b.node(x).rank}));e.forEach(b.nodes(),function(x){var S=b.node(x);e.has(S,"rank")&&(S.rank-=N)})}function f(b){var N=e.min(e.map(b.nodes(),function(_){return b.node(_).rank})),x=[];e.forEach(b.nodes(),function(_){var M=b.node(_).rank-N;x[M]||(x[M]=[]),x[M].push(_)});var S=0,C=b.graph().nodeRankFactor;e.forEach(x,function(_,M){e.isUndefined(_)&&M%C!==0?--S:S&&e.forEach(_,function(R){b.node(R).rank+=S})})}function p(b,N,x,S){var C={width:0,height:0};return arguments.length>=4&&(C.rank=x,C.order=S),n(b,"border",C,N)}function m(b){return e.max(e.map(b.nodes(),function(N){var x=b.node(N).rank;if(!e.isUndefined(x))return x}))}function w(b,N){var x={lhs:[],rhs:[]};return e.forEach(b,function(S){N(S)?x.lhs.push(S):x.rhs.push(S)}),x}function v(b,N){var x=e.now();try{return N()}finally{console.log(b+" time: "+(e.now()-x)+"ms")}}function j(b,N){return N()}return d0}var h0,$I;function hpe(){if($I)return h0;$I=1;var e=Mt(),t=Bn();h0={run:n,undo:a};function n(o){o.graph().dummyChains=[],e.forEach(o.edges(),function(i){s(o,i)})}function s(o,i){var l=i.v,u=o.node(l).rank,h=i.w,f=o.node(h).rank,p=i.name,m=o.edge(i),w=m.labelRank;if(f!==u+1){o.removeEdge(i);var v,j,b;for(b=0,++u;u<f;++b,++u)m.points=[],j={width:0,height:0,edgeLabel:m,edgeObj:i,rank:u},v=t.addDummyNode(o,"edge",j,"_d"),u===w&&(j.width=m.width,j.height=m.height,j.dummy="edge-label",j.labelpos=m.labelpos),o.setEdge(l,v,{weight:m.weight},p),b===0&&o.graph().dummyChains.push(v),l=v;o.setEdge(l,h,{weight:m.weight},p)}}function a(o){e.forEach(o.graph().dummyChains,function(i){var l=o.node(i),u=l.edgeLabel,h;for(o.setEdge(l.edgeObj,u);l.dummy;)h=o.successors(i)[0],o.removeNode(i),u.points.push({x:l.x,y:l.y}),l.dummy==="edge-label"&&(u.x=l.x,u.y=l.y,u.width=l.width,u.height=l.height),i=h,l=o.node(i)})}return h0}var f0,LI;function _p(){if(LI)return f0;LI=1;var e=Mt();f0={longestPath:t,slack:n};function t(s){var a={};function o(i){var l=s.node(i);if(e.has(a,i))return l.rank;a[i]=!0;var u=e.min(e.map(s.outEdges(i),function(h){return o(h.w)-s.edge(h).minlen}));return(u===Number.POSITIVE_INFINITY||u===void 0||u===null)&&(u=0),l.rank=u}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 f0}var p0,II;function zF(){if(II)return p0;II=1;var e=Mt(),t=Zs().Graph,n=_p().slack;p0=s;function s(l){var u=new t({directed:!1}),h=l.nodes()[0],f=l.nodeCount();u.setNode(h,{});for(var p,m;a(u,l)<f;)p=o(u,l),m=u.hasNode(p.v)?n(l,p):-n(l,p),i(u,l,m);return u}function a(l,u){function h(f){e.forEach(u.nodeEdges(f),function(p){var m=p.v,w=f===m?p.w:m;!l.hasNode(w)&&!n(u,p)&&(l.setNode(w,{}),l.setEdge(f,w,{}),h(w))})}return e.forEach(l.nodes(),h),l.nodeCount()}function o(l,u){return e.minBy(u.edges(),function(h){if(l.hasNode(h.v)!==l.hasNode(h.w))return n(u,h)})}function i(l,u,h){e.forEach(l.nodes(),function(f){u.node(f).rank+=h})}return p0}var m0,OI;function fpe(){if(OI)return m0;OI=1;var e=Mt(),t=zF(),n=_p().slack,s=_p().longestPath,a=Zs().alg.preorder,o=Zs().alg.postorder,i=Bn().simplify;m0=l,l.initLowLimValues=p,l.initCutValues=u,l.calcCutValue=f,l.leaveEdge=w,l.enterEdge=v,l.exchangeEdges=j;function l(S){S=i(S),s(S);var C=t(S);p(C),u(C,S);for(var _,M;_=w(C);)M=v(C,S,_),j(C,S,_,M)}function u(S,C){var _=o(S,S.nodes());_=_.slice(0,_.length-1),e.forEach(_,function(M){h(S,C,M)})}function h(S,C,_){var M=S.node(_),R=M.parent;S.edge(_,R).cutvalue=f(S,C,_)}function f(S,C,_){var M=S.node(_),R=M.parent,P=!0,L=C.edge(_,R),U=0;return L||(P=!1,L=C.edge(R,_)),U=L.weight,e.forEach(C.nodeEdges(_),function(B){var A=B.v===_,q=A?B.w:B.v;if(q!==R){var T=A===P,F=C.edge(B).weight;if(U+=T?F:-F,N(S,_,q)){var O=S.edge(_,q).cutvalue;U+=T?-O:O}}}),U}function p(S,C){arguments.length<2&&(C=S.nodes()[0]),m(S,{},1,C)}function m(S,C,_,M,R){var P=_,L=S.node(M);return C[M]=!0,e.forEach(S.neighbors(M),function(U){e.has(C,U)||(_=m(S,C,_,U,M))}),L.low=P,L.lim=_++,R?L.parent=R:delete L.parent,_}function w(S){return e.find(S.edges(),function(C){return S.edge(C).cutvalue<0})}function v(S,C,_){var M=_.v,R=_.w;C.hasEdge(M,R)||(M=_.w,R=_.v);var P=S.node(M),L=S.node(R),U=P,B=!1;P.lim>L.lim&&(U=L,B=!0);var A=e.filter(C.edges(),function(q){return B===x(S,S.node(q.v),U)&&B!==x(S,S.node(q.w),U)});return e.minBy(A,function(q){return n(C,q)})}function j(S,C,_,M){var R=_.v,P=_.w;S.removeEdge(R,P),S.setEdge(M.v,M.w,{}),p(S),u(S,C),b(S,C)}function b(S,C){var _=e.find(S.nodes(),function(R){return!C.node(R).parent}),M=a(S,_);M=M.slice(1),e.forEach(M,function(R){var P=S.node(R).parent,L=C.edge(R,P),U=!1;L||(L=C.edge(P,R),U=!0),C.node(R).rank=C.node(P).rank+(U?L.minlen:-L.minlen)})}function N(S,C,_){return S.hasEdge(C,_)}function x(S,C,_){return _.low<=C.lim&&C.lim<=_.lim}return m0}var g0,PI;function ppe(){if(PI)return g0;PI=1;var e=_p(),t=e.longestPath,n=zF(),s=fpe();g0=a;function a(u){switch(u.graph().ranker){case"network-simplex":l(u);break;case"tight-tree":i(u);break;case"longest-path":o(u);break;default:l(u)}}var o=t;function i(u){t(u),n(u)}function l(u){s(u)}return g0}var y0,DI;function mpe(){if(DI)return y0;DI=1;var e=Mt();y0=t;function t(a){var o=s(a);e.forEach(a.graph().dummyChains,function(i){for(var l=a.node(i),u=l.edgeObj,h=n(a,o,u.v,u.w),f=h.path,p=h.lca,m=0,w=f[m],v=!0;i!==u.w;){if(l=a.node(i),v){for(;(w=f[m])!==p&&a.node(w).maxRank<l.rank;)m++;w===p&&(v=!1)}if(!v){for(;m<f.length-1&&a.node(w=f[m+1]).minRank<=l.rank;)m++;w=f[m]}a.setParent(i,w),i=a.successors(i)[0]}})}function n(a,o,i,l){var u=[],h=[],f=Math.min(o[i].low,o[l].low),p=Math.max(o[i].lim,o[l].lim),m,w;m=i;do m=a.parent(m),u.push(m);while(m&&(o[m].low>f||p>o[m].lim));for(w=m,m=l;(m=a.parent(m))!==w;)h.push(m);return{path:u.concat(h.reverse()),lca:w}}function s(a){var o={},i=0;function l(u){var h=i;e.forEach(a.children(u),l),o[u]={low:h,lim:i++}}return e.forEach(a.children(),l),o}return y0}var w0,FI;function gpe(){if(FI)return w0;FI=1;var e=Mt(),t=Bn();w0={run:n,cleanup:i};function n(l){var u=t.addDummyNode(l,"root",{},"_root"),h=a(l),f=e.max(e.values(h))-1,p=2*f+1;l.graph().nestingRoot=u,e.forEach(l.edges(),function(w){l.edge(w).minlen*=p});var m=o(l)+1;e.forEach(l.children(),function(w){s(l,u,p,m,f,h,w)}),l.graph().nodeRankFactor=p}function s(l,u,h,f,p,m,w){var v=l.children(w);if(!v.length){w!==u&&l.setEdge(u,w,{weight:0,minlen:h});return}var j=t.addBorderNode(l,"_bt"),b=t.addBorderNode(l,"_bb"),N=l.node(w);l.setParent(j,w),N.borderTop=j,l.setParent(b,w),N.borderBottom=b,e.forEach(v,function(x){s(l,u,h,f,p,m,x);var S=l.node(x),C=S.borderTop?S.borderTop:x,_=S.borderBottom?S.borderBottom:x,M=S.borderTop?f:2*f,R=C!==_?1:p-m[w]+1;l.setEdge(j,C,{weight:M,minlen:R,nestingEdge:!0}),l.setEdge(_,b,{weight:M,minlen:R,nestingEdge:!0})}),l.parent(w)||l.setEdge(u,j,{weight:0,minlen:p+m[w]})}function a(l){var u={};function h(f,p){var m=l.children(f);m&&m.length&&e.forEach(m,function(w){h(w,p+1)}),u[f]=p}return e.forEach(l.children(),function(f){h(f,1)}),u}function o(l){return e.reduce(l.edges(),function(u,h){return u+l.edge(h).weight},0)}function i(l){var u=l.graph();l.removeNode(u.nestingRoot),delete u.nestingRoot,e.forEach(l.edges(),function(h){var f=l.edge(h);f.nestingEdge&&l.removeEdge(h)})}return w0}var x0,BI;function ype(){if(BI)return x0;BI=1;var e=Mt(),t=Bn();x0=n;function n(a){function o(i){var l=a.children(i),u=a.node(i);if(l.length&&e.forEach(l,o),e.has(u,"minRank")){u.borderLeft=[],u.borderRight=[];for(var h=u.minRank,f=u.maxRank+1;h<f;++h)s(a,"borderLeft","_bl",i,u,h),s(a,"borderRight","_br",i,u,h)}}e.forEach(a.children(),o)}function s(a,o,i,l,u,h){var f={width:0,height:0,rank:h,borderType:o},p=u[o][h-1],m=t.addDummyNode(a,"border",f,i);u[o][h]=m,a.setParent(m,l),p&&a.setEdge(p,m,{weight:1})}return x0}var v0,qI;function wpe(){if(qI)return v0;qI=1;var e=Mt();v0={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")&&(l(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 l(h){e.forEach(h.nodes(),function(f){u(h.node(f))}),e.forEach(h.edges(),function(f){var p=h.edge(f);e.forEach(p.points,u),e.has(p,"x")&&u(p)})}function u(h){var f=h.x;h.x=h.y,h.y=f}return v0}var b0,UI;function xpe(){if(UI)return b0;UI=1;var e=Mt();b0=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 l(h){if(!e.has(s,h)){s[h]=!0;var f=n.node(h);i[f.rank].push(h),e.forEach(n.successors(h),l)}}var u=e.sortBy(a,function(h){return n.node(h).rank});return e.forEach(u,l),i}return b0}var k0,WI;function vpe(){if(WI)return k0;WI=1;var e=Mt();k0=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})),l=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),u=1;u<o.length;)u<<=1;var h=2*u-1;u-=1;var f=e.map(new Array(h),function(){return 0}),p=0;return e.forEach(l.forEach(function(m){var w=m.pos+u;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 k0}var j0,HI;function bpe(){if(HI)return j0;HI=1;var e=Mt();j0=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(l,u){var h=n.edge(u),f=n.node(u.v);return{sum:l.sum+h.weight*f.order,weight:l.weight+h.weight}},{sum:0,weight:0});return{v:a,barycenter:i.sum/i.weight,weight:i.weight}}else return{v:a}})}return j0}var N0,zI;function kpe(){if(zI)return N0;zI=1;var e=Mt();N0=t;function t(a,o){var i={};e.forEach(a,function(u,h){var f=i[u.v]={indegree:0,in:[],out:[],vs:[u.v],i:h};e.isUndefined(u.barycenter)||(f.barycenter=u.barycenter,f.weight=u.weight)}),e.forEach(o.edges(),function(u){var h=i[u.v],f=i[u.w];!e.isUndefined(h)&&!e.isUndefined(f)&&(f.indegree++,h.out.push(i[u.w]))});var l=e.filter(i,function(u){return!u.indegree});return n(l)}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 l(h){return function(f){f.in.push(h),--f.indegree===0&&a.push(f)}}for(;a.length;){var u=a.pop();o.push(u),e.forEach(u.in.reverse(),i(u)),e.forEach(u.out,l(u))}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,l=0;a.weight&&(i+=a.barycenter*a.weight,l+=a.weight),o.weight&&(i+=o.barycenter*o.weight,l+=o.weight),a.vs=o.vs.concat(a.vs),a.barycenter=i/l,a.weight=l,a.i=Math.min(o.i,a.i),o.merged=!0}return N0}var S0,VI;function jpe(){if(VI)return S0;VI=1;var e=Mt(),t=Bn();S0=n;function n(o,i){var l=t.partition(o,function(j){return e.has(j,"barycenter")}),u=l.lhs,h=e.sortBy(l.rhs,function(j){return-j.i}),f=[],p=0,m=0,w=0;u.sort(a(!!i)),w=s(f,h,w),e.forEach(u,function(j){w+=j.vs.length,f.push(j.vs),p+=j.barycenter*j.weight,m+=j.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,l){for(var u;i.length&&(u=e.last(i)).i<=l;)i.pop(),o.push(u.vs),l++;return l}function a(o){return function(i,l){return i.barycenter<l.barycenter?-1:i.barycenter>l.barycenter?1:o?l.i-i.i:i.i-l.i}}return S0}var C0,GI;function Npe(){if(GI)return C0;GI=1;var e=Mt(),t=bpe(),n=kpe(),s=jpe();C0=a;function a(l,u,h,f){var p=l.children(u),m=l.node(u),w=m?m.borderLeft:void 0,v=m?m.borderRight:void 0,j={};w&&(p=e.filter(p,function(_){return _!==w&&_!==v}));var b=t(l,p);e.forEach(b,function(_){if(l.children(_.v).length){var M=a(l,_.v,h,f);j[_.v]=M,e.has(M,"barycenter")&&i(_,M)}});var N=n(b,h);o(N,j);var x=s(N,f);if(w&&(x.vs=e.flatten([w,x.vs,v],!0),l.predecessors(w).length)){var S=l.node(l.predecessors(w)[0]),C=l.node(l.predecessors(v)[0]);e.has(x,"barycenter")||(x.barycenter=0,x.weight=0),x.barycenter=(x.barycenter*x.weight+S.order+C.order)/(x.weight+2),x.weight+=2}return x}function o(l,u){e.forEach(l,function(h){h.vs=e.flatten(h.vs.map(function(f){return u[f]?u[f].vs:f}),!0)})}function i(l,u){e.isUndefined(l.barycenter)?(l.barycenter=u.barycenter,l.weight=u.weight):(l.barycenter=(l.barycenter*l.weight+u.barycenter*u.weight)/(l.weight+u.weight),l.weight+=u.weight)}return C0}var _0,KI;function Spe(){if(KI)return _0;KI=1;var e=Mt(),t=Zs().Graph;_0=n;function n(a,o,i){var l=s(a),u=new t({compound:!0}).setGraph({root:l}).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)&&(u.setNode(h),u.setParent(h,p||l),e.forEach(a[i](h),function(m){var w=m.v===h?m.w:m.v,v=u.edge(w,h),j=e.isUndefined(v)?0:v.weight;u.setEdge(w,h,{weight:a.edge(m).weight+j})}),e.has(f,"minRank")&&u.setNode(h,{borderLeft:f.borderLeft[o],borderRight:f.borderRight[o]}))}),u}function s(a){for(var o;a.hasNode(o=e.uniqueId("_root")););return o}return _0}var E0,YI;function Cpe(){if(YI)return E0;YI=1;var e=Mt();E0=t;function t(n,s,a){var o={},i;e.forEach(a,function(l){for(var u=n.parent(l),h,f;u;){if(h=n.parent(u),h?(f=o[h],o[h]=u):(f=i,i=u),f&&f!==u){s.setEdge(f,u);return}u=h}})}return E0}var T0,XI;function _pe(){if(XI)return T0;XI=1;var e=Mt(),t=xpe(),n=vpe(),s=Npe(),a=Spe(),o=Cpe(),i=Zs().Graph,l=Bn();T0=u;function u(m){var w=l.maxRank(m),v=h(m,e.range(1,w+1),"inEdges"),j=h(m,e.range(w-1,-1,-1),"outEdges"),b=t(m);p(m,b);for(var N=Number.POSITIVE_INFINITY,x,S=0,C=0;C<4;++S,++C){f(S%2?v:j,S%4>=2),b=l.buildLayerMatrix(m);var _=n(m,b);_<N&&(C=0,x=e.cloneDeep(b),N=_)}p(m,x)}function h(m,w,v){return e.map(w,function(j){return a(m,j,v)})}function f(m,w){var v=new i;e.forEach(m,function(j){var b=j.graph().root,N=s(j,b,v,w);e.forEach(N.vs,function(x,S){j.node(x).order=S}),o(j,v,N.vs)})}function p(m,w){e.forEach(w,function(v){e.forEach(v,function(j,b){m.node(j).order=b})})}return T0}var A0,ZI;function Epe(){if(ZI)return A0;ZI=1;var e=Mt(),t=Zs().Graph,n=Bn();A0={positionX:v,findType1Conflicts:s,findType2Conflicts:a,addConflict:i,hasConflict:l,verticalAlignment:u,horizontalCompaction:h,alignCoordinates:m,findSmallestWidthAlignment:p,balance:w};function s(N,x){var S={};function C(_,M){var R=0,P=0,L=_.length,U=e.last(M);return e.forEach(M,function(B,A){var q=o(N,B),T=q?N.node(q).order:L;(q||B===U)&&(e.forEach(M.slice(P,A+1),function(F){e.forEach(N.predecessors(F),function(O){var K=N.node(O),V=K.order;(V<R||T<V)&&!(K.dummy&&N.node(F).dummy)&&i(S,O,F)})}),P=A+1,R=T)}),M}return e.reduce(x,C),S}function a(N,x){var S={};function C(M,R,P,L,U){var B;e.forEach(e.range(R,P),function(A){B=M[A],N.node(B).dummy&&e.forEach(N.predecessors(B),function(q){var T=N.node(q);T.dummy&&(T.order<L||T.order>U)&&i(S,q,B)})})}function _(M,R){var P=-1,L,U=0;return e.forEach(R,function(B,A){if(N.node(B).dummy==="border"){var q=N.predecessors(B);q.length&&(L=N.node(q[0]).order,C(R,U,A,P,L),U=A,P=L)}C(R,U,R.length,L,M.length)}),R}return e.reduce(x,_),S}function o(N,x){if(N.node(x).dummy)return e.find(N.predecessors(x),function(S){return N.node(S).dummy})}function i(N,x,S){if(x>S){var C=x;x=S,S=C}var _=N[x];_||(N[x]=_={}),_[S]=!0}function l(N,x,S){if(x>S){var C=x;x=S,S=C}return e.has(N[x],S)}function u(N,x,S,C){var _={},M={},R={};return e.forEach(x,function(P){e.forEach(P,function(L,U){_[L]=L,M[L]=L,R[L]=U})}),e.forEach(x,function(P){var L=-1;e.forEach(P,function(U){var B=C(U);if(B.length){B=e.sortBy(B,function(O){return R[O]});for(var A=(B.length-1)/2,q=Math.floor(A),T=Math.ceil(A);q<=T;++q){var F=B[q];M[U]===U&&L<R[F]&&!l(S,U,F)&&(M[F]=U,M[U]=_[U]=_[F],L=R[F])}}})}),{root:_,align:M}}function h(N,x,S,C,_){var M={},R=f(N,x,S,_),P=_?"borderLeft":"borderRight";function L(A,q){for(var T=R.nodes(),F=T.pop(),O={};F;)O[F]?A(F):(O[F]=!0,T.push(F),T=T.concat(q(F))),F=T.pop()}function U(A){M[A]=R.inEdges(A).reduce(function(q,T){return Math.max(q,M[T.v]+R.edge(T))},0)}function B(A){var q=R.outEdges(A).reduce(function(F,O){return Math.min(F,M[O.w]-R.edge(O))},Number.POSITIVE_INFINITY),T=N.node(A);q!==Number.POSITIVE_INFINITY&&T.borderType!==P&&(M[A]=Math.max(M[A],q))}return L(U,R.predecessors.bind(R)),L(B,R.successors.bind(R)),e.forEach(C,function(A){M[A]=M[S[A]]}),M}function f(N,x,S,C){var _=new t,M=N.graph(),R=j(M.nodesep,M.edgesep,C);return e.forEach(x,function(P){var L;e.forEach(P,function(U){var B=S[U];if(_.setNode(B),L){var A=S[L],q=_.edge(A,B);_.setEdge(A,B,Math.max(R(N,U,L),q||0))}L=U})}),_}function p(N,x){return e.minBy(e.values(x),function(S){var C=Number.NEGATIVE_INFINITY,_=Number.POSITIVE_INFINITY;return e.forIn(S,function(M,R){var P=b(N,R)/2;C=Math.max(M+P,C),_=Math.min(M-P,_)}),C-_})}function m(N,x){var S=e.values(x),C=e.min(S),_=e.max(S);e.forEach(["u","d"],function(M){e.forEach(["l","r"],function(R){var P=M+R,L=N[P],U;if(L!==x){var B=e.values(L);U=R==="l"?C-e.min(B):_-e.max(B),U&&(N[P]=e.mapValues(L,function(A){return A+U}))}})})}function w(N,x){return e.mapValues(N.ul,function(S,C){if(x)return N[x.toLowerCase()][C];var _=e.sortBy(e.map(N,C));return(_[1]+_[2])/2})}function v(N){var x=n.buildLayerMatrix(N),S=e.merge(s(N,x),a(N,x)),C={},_;e.forEach(["u","d"],function(R){_=R==="u"?x:e.values(x).reverse(),e.forEach(["l","r"],function(P){P==="r"&&(_=e.map(_,function(A){return e.values(A).reverse()}));var L=(R==="u"?N.predecessors:N.successors).bind(N),U=u(N,_,S,L),B=h(N,_,U.root,U.align,P==="r");P==="r"&&(B=e.mapValues(B,function(A){return-A})),C[R+P]=B})});var M=p(N,C);return m(C,M),w(C,N.graph().align)}function j(N,x,S){return function(C,_,M){var R=C.node(_),P=C.node(M),L=0,U;if(L+=R.width/2,e.has(R,"labelpos"))switch(R.labelpos.toLowerCase()){case"l":U=-R.width/2;break;case"r":U=R.width/2;break}if(U&&(L+=S?U:-U),U=0,L+=(R.dummy?x:N)/2,L+=(P.dummy?x:N)/2,L+=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&&(L+=S?U:-U),U=0,L}}function b(N,x){return N.node(x).width}return A0}var R0,JI;function Tpe(){if(JI)return R0;JI=1;var e=Mt(),t=Bn(),n=Epe().positionX;R0=s;function s(o){o=t.asNonCompoundGraph(o),a(o),e.forEach(n(o),function(i,l){o.node(l).x=i})}function a(o){var i=t.buildLayerMatrix(o),l=o.graph().ranksep,u=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=u+f/2}),u+=f+l})}return R0}var M0,QI;function Ape(){if(QI)return M0;QI=1;var e=Mt(),t=dpe(),n=hpe(),s=ppe(),a=Bn().normalizeRanks,o=mpe(),i=Bn().removeEmptyRanks,l=gpe(),u=ype(),h=wpe(),f=_pe(),p=Tpe(),m=Bn(),w=Zs().Graph;M0=v;function v(z,X){var Y=X&&X.debugTiming?m.time:m.notime;Y("layout",function(){var J=Y(" buildLayoutGraph",function(){return L(z)});Y(" runLayout",function(){j(J,Y)}),Y(" updateInputGraph",function(){b(z,J)})})}function j(z,X){X(" makeSpaceForEdgeLabels",function(){U(z)}),X(" removeSelfEdges",function(){H(z)}),X(" acyclic",function(){t.run(z)}),X(" nestingGraph.run",function(){l.run(z)}),X(" rank",function(){s(m.asNonCompoundGraph(z))}),X(" injectEdgeLabelProxies",function(){B(z)}),X(" removeEmptyRanks",function(){i(z)}),X(" nestingGraph.cleanup",function(){l.cleanup(z)}),X(" normalizeRanks",function(){a(z)}),X(" assignRankMinMax",function(){A(z)}),X(" removeEdgeLabelProxies",function(){q(z)}),X(" normalize.run",function(){n.run(z)}),X(" parentDummyChains",function(){o(z)}),X(" addBorderSegments",function(){u(z)}),X(" order",function(){f(z)}),X(" insertSelfEdges",function(){D(z)}),X(" adjustCoordinateSystem",function(){h.adjust(z)}),X(" position",function(){p(z)}),X(" positionSelfEdges",function(){I(z)}),X(" removeBorderNodes",function(){V(z)}),X(" normalize.undo",function(){n.undo(z)}),X(" fixupEdgeLabelCoords",function(){O(z)}),X(" undoCoordinateSystem",function(){h.undo(z)}),X(" translateGraph",function(){T(z)}),X(" assignNodeIntersects",function(){F(z)}),X(" reversePoints",function(){K(z)}),X(" acyclic.undo",function(){t.undo(z)})}function b(z,X){e.forEach(z.nodes(),function(Y){var J=z.node(Y),Q=X.node(Y);J&&(J.x=Q.x,J.y=Q.y,X.children(Y).length&&(J.width=Q.width,J.height=Q.height))}),e.forEach(z.edges(),function(Y){var J=z.edge(Y),Q=X.edge(Y);J.points=Q.points,e.has(Q,"x")&&(J.x=Q.x,J.y=Q.y)}),z.graph().width=X.graph().width,z.graph().height=X.graph().height}var N=["nodesep","edgesep","ranksep","marginx","marginy"],x={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},S=["acyclicer","ranker","rankdir","align"],C=["width","height"],_={width:0,height:0},M=["minlen","weight","width","height","labeloffset"],R={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},P=["labelpos"];function L(z){var X=new w({multigraph:!0,compound:!0}),Y=Z(z.graph());return X.setGraph(e.merge({},x,W(Y,N),e.pick(Y,S))),e.forEach(z.nodes(),function(J){var Q=Z(z.node(J));X.setNode(J,e.defaults(W(Q,C),_)),X.setParent(J,z.parent(J))}),e.forEach(z.edges(),function(J){var Q=Z(z.edge(J));X.setEdge(J,e.merge({},R,W(Q,M),e.pick(Q,P)))}),X}function U(z){var X=z.graph();X.ranksep/=2,e.forEach(z.edges(),function(Y){var J=z.edge(Y);J.minlen*=2,J.labelpos.toLowerCase()!=="c"&&(X.rankdir==="TB"||X.rankdir==="BT"?J.width+=J.labeloffset:J.height+=J.labeloffset)})}function B(z){e.forEach(z.edges(),function(X){var Y=z.edge(X);if(Y.width&&Y.height){var J=z.node(X.v),Q=z.node(X.w),te={rank:(Q.rank-J.rank)/2+J.rank,e:X};m.addDummyNode(z,"edge-proxy",te,"_ep")}})}function A(z){var X=0;e.forEach(z.nodes(),function(Y){var J=z.node(Y);J.borderTop&&(J.minRank=z.node(J.borderTop).rank,J.maxRank=z.node(J.borderBottom).rank,X=e.max(X,J.maxRank))}),z.graph().maxRank=X}function q(z){e.forEach(z.nodes(),function(X){var Y=z.node(X);Y.dummy==="edge-proxy"&&(z.edge(Y.e).labelRank=Y.rank,z.removeNode(X))})}function T(z){var X=Number.POSITIVE_INFINITY,Y=0,J=Number.POSITIVE_INFINITY,Q=0,te=z.graph(),le=te.marginx||0,de=te.marginy||0;function oe(re){var he=re.x,pe=re.y,Le=re.width,ge=re.height;X=Math.min(X,he-Le/2),Y=Math.max(Y,he+Le/2),J=Math.min(J,pe-ge/2),Q=Math.max(Q,pe+ge/2)}e.forEach(z.nodes(),function(re){oe(z.node(re))}),e.forEach(z.edges(),function(re){var he=z.edge(re);e.has(he,"x")&&oe(he)}),X-=le,J-=de,e.forEach(z.nodes(),function(re){var he=z.node(re);he.x-=X,he.y-=J}),e.forEach(z.edges(),function(re){var he=z.edge(re);e.forEach(he.points,function(pe){pe.x-=X,pe.y-=J}),e.has(he,"x")&&(he.x-=X),e.has(he,"y")&&(he.y-=J)}),te.width=Y-X+le,te.height=Q-J+de}function F(z){e.forEach(z.edges(),function(X){var Y=z.edge(X),J=z.node(X.v),Q=z.node(X.w),te,le;Y.points?(te=Y.points[0],le=Y.points[Y.points.length-1]):(Y.points=[],te=Q,le=J),Y.points.unshift(m.intersectRect(J,te)),Y.points.push(m.intersectRect(Q,le))})}function O(z){e.forEach(z.edges(),function(X){var Y=z.edge(X);if(e.has(Y,"x"))switch((Y.labelpos==="l"||Y.labelpos==="r")&&(Y.width-=Y.labeloffset),Y.labelpos){case"l":Y.x-=Y.width/2+Y.labeloffset;break;case"r":Y.x+=Y.width/2+Y.labeloffset;break}})}function K(z){e.forEach(z.edges(),function(X){var Y=z.edge(X);Y.reversed&&Y.points.reverse()})}function V(z){e.forEach(z.nodes(),function(X){if(z.children(X).length){var Y=z.node(X),J=z.node(Y.borderTop),Q=z.node(Y.borderBottom),te=z.node(e.last(Y.borderLeft)),le=z.node(e.last(Y.borderRight));Y.width=Math.abs(le.x-te.x),Y.height=Math.abs(Q.y-J.y),Y.x=te.x+Y.width/2,Y.y=J.y+Y.height/2}}),e.forEach(z.nodes(),function(X){z.node(X).dummy==="border"&&z.removeNode(X)})}function H(z){e.forEach(z.edges(),function(X){if(X.v===X.w){var Y=z.node(X.v);Y.selfEdges||(Y.selfEdges=[]),Y.selfEdges.push({e:X,label:z.edge(X)}),z.removeEdge(X)}})}function D(z){var X=m.buildLayerMatrix(z);e.forEach(X,function(Y){var J=0;e.forEach(Y,function(Q,te){var le=z.node(Q);le.order=te+J,e.forEach(le.selfEdges,function(de){m.addDummyNode(z,"selfedge",{width:de.label.width,height:de.label.height,rank:le.rank,order:te+ ++J,e:de.e,label:de.label},"_se")}),delete le.selfEdges})})}function I(z){e.forEach(z.nodes(),function(X){var Y=z.node(X);if(Y.dummy==="selfedge"){var J=z.node(Y.e.v),Q=J.x+J.width/2,te=J.y,le=Y.x-Q,de=J.height/2;z.setEdge(Y.e,Y.label),z.removeNode(X),Y.label.points=[{x:Q+2*le/3,y:te-de},{x:Q+5*le/6,y:te-de},{x:Q+le,y:te},{x:Q+5*le/6,y:te+de},{x:Q+2*le/3,y:te+de}],Y.label.x=Y.x,Y.label.y=Y.y}})}function W(z,X){return e.mapValues(e.pick(z,X),Number)}function Z(z){var X={};return e.forEach(z,function(Y,J){X[J.toLowerCase()]=Y}),X}return M0}var $0,eO;function Rpe(){if(eO)return $0;eO=1;var e=Mt(),t=Bn(),n=Zs().Graph;$0={debugOrdering:s};function s(a){var o=t.buildLayerMatrix(a),i=new n({compound:!0,multigraph:!0}).setGraph({});return e.forEach(a.nodes(),function(l){i.setNode(l,{label:l}),i.setParent(l,"layer"+a.node(l).rank)}),e.forEach(a.edges(),function(l){i.setEdge(l.v,l.w,{},l.name)}),e.forEach(o,function(l,u){var h="layer"+u;i.setNode(h,{rank:"same"}),e.reduce(l,function(f,p){return i.setEdge(f,p,{style:"invis"}),p})}),i}return $0}var L0,tO;function Mpe(){return tO||(tO=1,L0="0.8.5"),L0}var I0,nO;function $pe(){return nO||(nO=1,I0={graphlib:Zs(),layout:Ape(),debug:Rpe(),util:{time:Bn().time,notime:Bn().notime},version:Mpe()}),I0}var Lpe=$pe();const sO=$j(Lpe),rO=e=>{var t;return(t=e.data)==null?void 0:t.parentId};function Ipe(e,t,n,s){const a=im(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)??_N},i=new Map(e.map(f=>[f.id,f.position])),l=new Map,u=f=>t.has(f)?void 0:l.get(f)??n(f),h=e.filter(f=>!t.has(f.id)&&!n(f.id)&&a.has(En(f))).sort((f,p)=>f.position.x-p.position.x||f.position.y-p.position.y);for(const f of h){const p=En(f),m=rO(f),w=m?u(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},x={x:f.position.x+N.x,y:f.position.y+N.y};let S=null;for(const C of e){if(C.id===f.id||C.type==="recapNote"||rO(C)!==m||En(C)!==p)continue;const _=u(C.id);if(!_||Math.abs(_.x-x.x)>Ol||_.x<=w.x)continue;const M=_.y+o(C.id);(!S||M>S.bottom)&&(S={at:_,bottom:M})}if(S){l.set(f.id,{x:S.at.x,y:S.bottom+yD});continue}}const v=a.get(p)[0].id,j=w??n(v),b=i.get(w?m:v);l.set(f.id,{x:f.position.x+j.x-b.x,y:f.position.y+j.y-b.y})}return l.size===0?e:e.map(f=>{const p=l.get(f.id);return p?{...f,position:p}:f})}const O0=e=>e.type==="recapNote";function Ope(e,t,n,s,a,o,i){const l=S=>wd(S,s,o),u=S=>n.get(S)??t.get(S),h=S=>{const{w:C,h:_}=Ju(S,s);return{cw:C,ch:_}},f=i!=null&&i.width>0&&i.height>0,p=im(e,S=>u(S.id)!=null&&!O0(S)),m=new Set;for(const[S,C]of p)C.every(_=>a.has(_.id)&&!n.has(_.id))&&m.add(S);const w=new Map,v=[];for(const S of e){const C=u(S.id);if(!C)continue;const{w:_,h:M}=l(S.id),R=En(S);m.has(R)?O0(S)||(w.get(R)??w.set(R,[]).get(R)).push(S):v.push({sid:R,x:C.x,y:C.y,w:_,h:M,...h(S.id),note:O0(S)})}if(w.size===0||f&&v.length===0)return[];const j=cp,b=(S,C,_,M)=>v.some(R=>S<R.x+R.w+$1&&R.x<S+_+$1&&C<R.y+R.h+j&&R.y<C+M+j),N=xD(e,s),x=[];for(const S of[...w.keys()].sort()){const C=w.get(S);let _=1/0,M=1/0,R=-1/0,P=-1/0,L=-1/0,U=-1/0;for(const D of C){const I=u(D.id),{w:W,h:Z}=l(D.id),{cw:z,ch:X}=h(D.id);_=Math.min(_,I.x),M=Math.min(M,I.y),R=Math.max(R,I.x+W),P=Math.max(P,I.y+Z),L=Math.max(L,I.x+z),U=Math.max(U,I.y+X)}const B=P-M,A=C.some(D=>{var I;return((I=D.data)==null?void 0:I.kind)==="root"})?Mf+vD:0,q=Math.max(R,L+Ol)-_,T=(D,I)=>!b(D-A,I,A+q,B),F=new Map;for(const D of v)D.note||F.set(D.sid,Math.min(F.get(D.sid)??1/0,D.x));const O=[...new Set([...F.values()].map(D=>Math.round(D)))].sort((D,I)=>D-I),K=O.length?O:[_],V=[0,...v.map(D=>D.y+D.h+j)].sort((D,I)=>D-I);let H=null;if(f){let D=1/0,I=1/0,W=-1/0,Z=-1/0;for(const te of v)D=Math.min(D,te.x),I=Math.min(I,te.y),W=Math.max(W,te.x+te.cw),Z=Math.max(Z,te.y+te.ch);const z=(te,le)=>{const de=i.width/(Math.max(W,te+L-_)-Math.min(D,te-A)+Ol),oe=i.height/(Math.max(Z,le+U-M)-Math.min(I,le));return[Math.min(bD,de,oe),Math.min(de,oe),Math.max(de,oe)]},X=(te,le)=>{for(let de=0;de<te.length;de++){if(te[de]>le[de]+1e-9)return!0;if(te[de]<le[de]-1e-9)return!1}return!1},Y=Math.round(W+Ol+N+A),J=[...new Set([...V,I])].sort((te,le)=>te-le);let Q=null;for(const te of[...K,Y])for(const le of J){if(!T(te,le))continue;const de=z(te,le);(Q===null||X(de,Q))&&(Q=de,H={x:te,y:le})}H&&H.x===_&&H.y===M&&(H=null)}else e:for(const D of K)for(const I of V){if(I>=M)break;if(T(D,I)){H={x:D,y:I};break e}}if(H){const D=H.x-_,I=H.y-M;for(const W of C){const Z=u(W.id);t.set(W.id,{x:Z.x+D,y:Z.y+I})}x.push(S)}for(const D of C){const I=u(D.id),{w:W,h:Z}=l(D.id);v.push({sid:S,x:I.x,y:I.y,w:W,h:Z,...h(D.id),note:!1})}if(A>0){const D=_+(H?H.x-_:0),I=M+(H?H.y-M:0);v.push({sid:S,x:D-A,y:I,w:Mf,h:up,cw:Mf,ch:up,note:!0})}}return x}function Ppe(e,t,n,s,a,o){const i=m=>wd(m,s,a),l=new Map(e.map(m=>[m.id,En(m)])),u=[],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:j}=i(m);u.push({x:w.x,y:w.y,w:v,h:j,sid:l.get(m)??"_default"})}const p=[];for(const{id:m,pos:w}of h){if(f(m))continue;const{w:v,h:j}=i(m),b=l.get(m)??"_default";if(n.has(m)){u.push({x:w.x,y:w.y,w:v,h:j,sid:b});continue}let N=w.y;for(let x=0;x<u.length+1;x++){const S=u.find(C=>{const _=C.sid===b?Rf:wD,M=C.sid===b?Rf:cp;return w.x<C.x+C.w+_&&C.x<w.x+v+_&&N<C.y+C.h+M&&C.y<N+j+M});if(!S)break;N=S.y+S.h+(S.sid===b?Rf:cp)}N!==w.y&&(t.set(m,{x:w.x,y:N}),p.push(m)),u.push({x:w.x,y:N,w:v,h:j,sid:b})}return p}function Dpe(e,t,n,s,a,o=!1,i){const u=wD+1,h=cp+1,f=8,p=1.75,m=200,w=.7,v=.01,j=A=>wd(A,s,i),b=A=>n.get(A)??t.get(A),N=im(e,A=>b(A.id)!=null),x=[],S=new Set,C=new Set,_=a.size===0;for(const A of[...N.keys()].sort()){const q=N.get(A);let T=1/0,F=1/0,O=-1/0,K=-1/0,V=!1;for(const W of q){const Z=b(W.id),{w:z,h:X}=j(W.id);T=Math.min(T,Z.x),F=Math.min(F,Z.y),O=Math.max(O,Z.x+z),K=Math.max(K,Z.y+X),n.has(W.id)&&(V=!0)}const H=O-T,D=K-F;C.add(A);const I=a.get(A);I&&(H>I.w+f||D>I.h+f)&&S.add(A),a.set(A,{w:H,h:D}),x.push({sid:A,members:q.map(W=>W.id),x:T,y:F,w:H,h:D,anchored:V,mass:1})}for(const A of[...a.keys()])C.has(A)||a.delete(A);if(o||_)return[];let M=!1;for(let A=0;A<x.length&&!M;A++)for(let q=A+1;q<x.length;q++){const T=x[A],F=x[q];if(!(T.anchored&&F.anchored)&&Math.abs(T.x+T.w/2-(F.x+F.w/2))<(T.w+F.w)/2+u&&Math.abs(T.y+T.h/2-(F.y+F.h/2))<(T.h+F.h)/2+h){M=!0;break}}if(S.size===0&&!M)return[];if(S.size>0)for(const A of x)S.has(A.sid)&&(A.mass=8);else for(const A of x)A.mass=Math.max(1,A.w*A.h/(Zu*_N));const R=new Map(x.map(A=>[A.sid,A.x])),P=new Map(x.map(A=>[A.sid,A.y])),L=new Map(x.map(A=>[A.sid,Math.min(0,A.x)])),U=new Map(x.map(A=>[A.sid,Math.min(0,A.y)]));for(let A=0;A<m;A++){const q=new Map,T=new Map;let F=0;for(let O=0;O<x.length;O++)for(let K=O+1;K<x.length;K++){const V=x[O],H=x[K];if(V.anchored&&H.anchored)continue;const D=V.x+V.w/2,I=V.y+V.h/2,W=H.x+H.w/2,Z=H.y+H.h/2,z=(V.w+H.w)/2+u-Math.abs(D-W),X=(V.h+H.h)/2+h-Math.abs(I-Z);if(z<=0||X<=0)continue;const Y=(Ke,ye)=>!Ke.anchored&&!(ye<0&&Ke.x<=L.get(Ke.sid)),J=(Ke,ye)=>!Ke.anchored&&!(ye<0&&Ke.y<=U.get(Ke.sid)),Q=(Ke,ye,Fe)=>{const $e=Ke===ye,Re=$e?V.sid<H.sid?-1:1:Math.sign(Ke-ye);return Fe(V,Re)||Fe(H,-Re)?Re:$e&&(Fe(V,-Re)||Fe(H,Re))?-Re:0},te=Q(D,W,Y),le=Q(I,Z,J),de=te!==0,oe=le!==0;if(!de&&!oe)continue;const re=de&&(!oe||z*p<X),[he,pe,Le,ge]=re?[te,z,q,Y]:[le,X,T,J],ve=ge(V,he),je=ge(H,-he),Ee=V.mass,xe=H.mass,Ie=ve?je?xe/(Ee+xe):1:0,De=je?ve?Ee/(Ee+xe):1:0,We=pe*w;Le.set(V.sid,(Le.get(V.sid)??0)+he*We*Ie),Le.set(H.sid,(Le.get(H.sid)??0)-he*We*De),F+=We}for(const O of x)O.anchored||(O.x=Math.max(L.get(O.sid),O.x+(q.get(O.sid)??0)),O.y=Math.max(U.get(O.sid),O.y+(T.get(O.sid)??0)));if(F<v)break}const B=[];for(const A of x){const q=A.x-R.get(A.sid),T=A.y-P.get(A.sid);if(!(Math.abs(q)<1&&Math.abs(T)<1)){for(const F of A.members){if(n.has(F))continue;const O=t.get(F);O&&t.set(F,{x:O.x+q,y:O.y+T})}B.push(A.sid)}}return B}const VF=160,Fpe=40,Bpe=80;function aO(e,t,n){const s=Ju(e,t),a=wd(e,t,n),o=a.w-s.w,i=Fpe+(t.has(e)?0:Bpe);return o>0?{w:s.w+Math.max(0,o+i-VF),h:a.h}:a}function qpe(e,t,n,s,a,o){const i=new sO.graphlib.Graph;i.setDefaultEdgeLabel(()=>({})),i.setGraph({rankdir:n,marginx:0,marginy:0,nodesep:yD,ranksep:VF,edgesep:30});const l=e.filter(N=>!a.has(N)),u=new Set(l);for(const N of l){const{w:x,h:S}=aO(N,s,o);i.setNode(N,{width:x,height:S})}for(const N of t)u.has(N.source)&&u.has(N.target)&&i.setEdge(N.source,N.target);sO.layout(i);const h=new Map;let f=1/0,p=1/0,m=-1/0,w=-1/0;for(const N of l){const x=i.node(N);if(!x)continue;const{w:S,h:C}=Ju(N,s),_=aO(N,s,o),M=x.x-_.w/2,R=x.y-_.h/2;h.set(N,{x:M,y:R}),M<f&&(f=M),R<p&&(p=R),M+S>m&&(m=M+S),R+C>w&&(w=R+C)}if(Number.isFinite(f)&&Number.isFinite(p))for(const[N,x]of h)h.set(N,{x:x.x-f,y:x.y-p});const v=Number.isFinite(m)?m-f:0,j=Number.isFinite(w)?w-p:0;let b=null;for(const N of e){const x=a.get(N);if(!x)continue;const{w:S,h:C}=Ju(N,s);b=b===null?{minX:x.x,minY:x.y,maxX:x.x+S,maxY:x.y+C}:{minX:Math.min(b.minX,x.x),minY:Math.min(b.minY,x.y),maxX:Math.max(b.maxX,x.x+S),maxY:Math.max(b.maxY,x.y+C)}}return{positions:h,width:v,height:j,pinnedBox:b}}function GF(e,t,n){const s=n.direction??"LR",a=n.pinned??new Map,o=n.measured??new Map,i=n.lanes,l=im(e);return{laid:Array.from(l.keys()).sort().map(f=>({sid:f,...qpe(l.get(f).map(p=>p.id),t,s,o,a,i)})),gap:xD(e,o)}}const KF=e=>e.reduce((t,n)=>Math.max(t,n.width),0)+Ol,Upe=e=>e.reduce((t,n)=>t+n.height,0)+Il*Math.max(0,e.length-1);function hj(e,t,n,s){const a=u=>{const h=[[]];let f=0;for(const p of e)f>0&&f+p.height>u&&(h.push([]),f=0),h[h.length-1].push(p),f+=p.height+Il;return h},o=[];for(let u=0;u<e.length;u++){let h=-Il;for(let f=u;f<e.length;f++)o.push(h+=e[f].height+Il)}o.sort((u,h)=>u-h);const i=u=>{let h=0,f=o.length-1;for(;h<f;){const p=h+f>>1;a(o[p]).length<=u?f=p:h=p+1}return a(o[h])};let l=[e];if(n>0&&s>0){const u=f=>QZ(f.reduce((p,m)=>p+KF(m),0)+t*(f.length-1),Math.max(...f.map(Upe)),n,s);let h=u(l);for(let f=2;f<=e.length;f++){const p=i(f),m=u(p);m>h+1e-9&&(h=m,l=p)}}return l}function Wpe(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}=GF(e,t,n);return o.length<2?!1:hj(o,i,s.width,s.height).length!==hj(o,i,a.width,a.height).length}function Hpe(e,t,n={}){const s=n.pinned??new Map,{laid:a,gap:o}=GF(e,t,n),i=hj(a,o,n.availableWidth??0,n.availableHeight??0),l=new Map;let u=0;for(const h of i){const f=KF(h);let p=0;for(const{positions:m,height:w,pinnedBox:v}of h){for(const[b,N]of m)l.set(b,{x:N.x+u,y:N.y+p});let j=p+w;v&&v.maxY>j&&v.minX<u+f&&u<v.maxX&&(j=v.maxY),p=j+Il}u+=f+o}return e.map(h=>{const f=s.get(h.id);if(f)return{...h,position:f};const p=l.get(h.id);return p?{...h,position:p}:h})}function Ff(e,t,n){return!t.has(e)||n.has(e)}function zpe(e,t,n,s){return!t.has(e)&&Ff(e,n,s)}function Vpe(e,t,n){const s={x:0,y:0};return t.set(e,s),n.add(e),s}function oO(e,t,n,s){n.set(e,t),s.delete(e)}const iO=new WeakMap;function Gpe(e,t){let n=iO.get(e);(!n||n.revision!==e.revision||n.open!==t)&&(n={revision:e.revision,open:t,byId:new Map,branches:NK(e.agents.values()),groups:Gp(e.agents.values())},iO.set(e,n));const{byId:s,branches:a,groups:o}=n;return i=>{let l=s.get(i.id);if(!l){const u=i.kind==="root"?a.get(i.sessionId):void 0;l=u?{...i,onOpenContext:t,branch:u}:{...i,onOpenContext:t},l.canvasSessionId=o.get(i.id),s.set(i.id,l)}return l}}function RS(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 Kpe(e,t){const n=i=>En(i),s=new Map;for(const i of e){const l=n(i),u=i.position.x+(i.width??Zu),h=s.get(l);h?(h.minX=Math.min(h.minX,i.position.x),h.maxX=Math.max(h.maxX,u),h.minY=Math.min(h.minY,i.position.y)):s.set(l,{minX:i.position.x,maxX:u,minY:i.position.y})}const a=[];for(const[i,l]of[...s].sort((u,h)=>u[1].minX-h[1].minX)){const u=a[a.length-1];u&&l.minX<u.maxX?(u.maxX=Math.max(u.maxX,l.maxX),u.sessions.push({sid:i,top:l.minY})):a.push({maxX:l.maxX,sessions:[{sid:i,top:l.minY}]})}const o=new Map;for(const i of a)for(const{sid:l}of i.sessions.sort((u,h)=>u.top-h.top))o.set(l,o.size);return e.slice().sort((i,l)=>o.get(n(i))-o.get(n(l))||t(i)-t(l)||i.position.y-l.position.y||i.position.x-l.position.x)}function Ype(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 Xpe(e,t,n,s,a,o,i,l,u,h,f,p,m,w,v,j,b,N,x,S){var V,H,D,I;const C=[],_=[],M=Gpe(e,N);for(const W of e.agents.values()){if(!b.has(W.id))continue;const Z=W.exitAt!=null,z=j!=null&&!j.has(W.id),X=[Z?"rf-exiting":"",z?"rf-spotlit-out":"",v.has(W.id)?"rf-selected":""].filter(Boolean).join(" ")||void 0,Y=o.get(W.id);if(C.push({id:W.id,type:"agent",position:{x:0,y:0},data:M(W),className:X,ariaLabel:OG(W,t,v.has(W.id)),...Y?{width:Y.width,height:Y.height}:null}),W.parentId&&b.has(W.parentId)){const le=Gu(W.sessionId),de=Z,oe=v.size>0&&(v.has(W.id)||v.has(W.parentId)),re=j!=null&&!j.has(W.id)&&!j.has(W.parentId),he=W.state==="active"?2:1.5,pe=oe?he+1.5:he,Le=de?.2:re?.12:1,ge=["sess-edge",W.state==="active"?"sess-live":"sess-idle",de?"rf-edge-exiting":"",oe?"rf-edge-selected":""].filter(Boolean).join(" ");_.push({id:`e:${W.parentId}->${W.id}`,source:W.parentId,target:W.id,animated:(W.state==="active"||oe)&&!de,type:"smoothstep",style:{"--session-hue":le,strokeWidth:`calc(${pe}px * var(--edge-k, 1))`,opacity:Le,transition:"var(--edge-transition)"},className:ge})}const J=W.kind==="root"?IP(W):null,Q=(J==null?void 0:J.note)??null,te=J?J.key:null;if(J&&te&&!pK(te)){const le=hN(W.id),de=Gu(W.sessionId),oe=o.get(le);C.push({id:le,type:"recapNote",position:{x:0,y:0},data:{sessionId:W.sessionId,canvasSessionId:M(W).canvasSessionId,parentId:W.id,note:Q,plan:J.plan,noteKey:te,hue:de},className:z?"rf-spotlit-out":void 0,selectable:!1,focusable:!1,ariaLabel:Q?Q.kind==="recap"?`Claude Code's recap for ${W.label}`:`${W.label}: ${rc(Q.kind)}`:`${W.label}: plan`,...oe?{width:oe.width,height:oe.height}:null}),_.push({id:`e:recap:${W.id}`,source:le,target:W.id,type:"recapTie",className:"recap-edge",focusable:!1,style:{"--session-hue":de}})}}const R=RS(e),P=S.size>0&&!(u&&x);P||S.clear();const L=C.filter(W=>W.data.provider==="codex"&&W.data.parentId).map(W=>`${W.id}:${En(W)}:${W.data.parentId}`).sort().join("|"),U=`${m}${L?`#codex:${L}`:""}#lanes:${nJ(R)}${P?"#held":""}`,B=new Set(C.filter(W=>W.type==="recapNote").map(W=>W.id));for(const W of Array.from(f.keys()))x&&wK(W)&&!B.has(W)&&!a.has(W)&&(f.delete(W),p.delete(W));const A=C.filter(W=>zpe(W.id,a,f,p));if(A.length>0||U!==w.current){if(A.length>0){for(const Z of A)S.delete(Z.id);const W=Ipe(Hpe(C,_,{direction:"LR",pinned:a,measured:o,availableWidth:n,availableHeight:s,lanes:R}),a,Z=>Ff(Z,f,p)?void 0:f.get(Z),Z=>wd(Z,o,R));for(const Z of W)Ff(Z.id,f,p)&&oO(Z.id,Z.position,f,p);Ope(C,f,a,o,new Set(A.filter(Z=>Z.type!=="recapNote").map(Z=>Z.id)),R,{width:n,height:s});for(const Z of A){if(Z.type!=="recapNote")continue;const z=(V=Z.data)==null?void 0:V.parentId;if(!z)continue;const X=a.get(z)??(Ff(z,f,p)?void 0:f.get(z));if(!X)continue;const Y=((H=o.get(Z.id))==null?void 0:H.width)??Mf,J=((D=o.get(Z.id))==null?void 0:D.height)??up,Q=((I=o.get(z))==null?void 0:I.height)??up;oO(Z.id,{x:X.x-vD-Y,y:X.y+(Q-J)/2},f,p)}}Ppe(C,f,a,o,R,P?S:void 0),w.current=U}const q=Dpe(C,f,a,o,i,!u||h,R);q.length>0&&l(q);const T=pde(e.agents.values());x&&xf(f,T),xf(p,T),x&&xf(a,T),xf(o,fde(e.agents.values()));const F=[];let O=!1;for(const W of C){let Z=a.get(W.id)??f.get(W.id);Z||(Z=Vpe(W.id,f,p),O=!0),F.push({...W,position:Z})}return O&&(w.current=""),{nodes:Kpe(F,W=>{if(W.type==="recapNote")return-1;const Z=e.agents.get(W.id);return Z?Ype(e,Z):0}),edges:_}}function Zpe(e){return e.slice().sort((t,n)=>t.y-n.y||t.x-n.x)}function Jpe(e,t,n){var i;if(e.length===0)return null;const s=Zpe(e),a=t?s.findIndex(l=>l.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 Qpe=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Escape","Backspace"]);function eme(e,t){return t==null?{kind:"deck",nodeId:null}:e.key==="Enter"||e.key===" "?{kind:"activate",nodeId:t,additive:e.shiftKey}:Qpe.has(e.key)?{kind:"node",nodeId:t}:{kind:"deck",nodeId:t}}const tme=new Set(["","BODY","HTML","#DOCUMENT"]);function nme(e){return!e||ai(e)?!1:!tme.has(String(e.tagName??"").toUpperCase())}const YF="react-flow__node";function MS(e){var t,n;return!!e&&((n=(t=e.classList)==null?void 0:t.contains)==null?void 0:n.call(t,YF))===!0}function XF(e){try{const t=document.querySelector(`.${YF}[data-id="${CSS.escape(e)}"]`);t==null||t.focus({preventScroll:!0})}catch{}}let li=null,El=null;const fj=new Set,pj=()=>{for(const e of fj)e()},sme=e=>(fj.add(e),()=>{fj.delete(e)}),lO=()=>li,rme=90;function ZF(e){!El||e!=null&&El.at.id!==e||(clearTimeout(El.timer),El=null)}function JF(e,t,n="pointer"){ZF();const s={id:e,anchor:t,by:n};if(li||n==="focus"){li=s,pj();return}El={at:s,timer:setTimeout(()=>{El=null,li=s,pj()},rme)}}function io(e){ZF(e),!(!li||e!=null&&li.id!==e)&&(li=null,pj())}function ame({agentFor:e,recapFor:t,labelFor:n,bounds:s}){const a=g.useSyncExternalStore(sme,lO,lO),o=a?e(a.id):void 0,i=a&&!o?t(a.id):void 0,l=a!=null&&(!o&&!i||!a.anchor.isConnected);return g.useEffect(()=>{l&&a&&io(a.id)},[l,a]),!a||l?null:o?r.jsx(ime,{a:o,anchor:a.anchor,parentLabel:o.parentId?n(o.parentId):void 0,bounds:s},a.id):i?r.jsx(ome,{r:i,anchor:a.anchor,bounds:s},a.id):null}function QF(e,t){const n=g.useRef(null),s=g.useCallback(()=>{const a=n.current;if(!a||!e.isConnected)return;a.style.maxHeight="";const o=TN(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 g.useLayoutEffect(()=>{s()}),n}function ome({r:e,anchor:t,bounds:n}){var h;const s=QF(t,n),a=Nr(3e4),o=e.note,i=jr(e.plan),l=(o==null?void 0:o.kind)==="recap",u=np((o==null?void 0:o.at)??((h=e.plan)==null?void 0:h.at)??a,a);return kt.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(ep,{recap:l}),o?rc(o.kind):"plan"]}),r.jsx("span",{className:"node-peek-time",title:u.title,children:u.label})]}),e.sessionLabel&&r.jsx("div",{className:"node-peek-kind",children:r.jsxs("span",{children:[o?`${nm(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 ",rN(i),i.allDone?"":`
|
|
107
|
+
${Vp(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 ime({a:e,anchor:t,parentLabel:n,bounds:s}){const a=QF(t,s),o=Nr(1e3),i=Qp(e.sessionName,e.sessionTitle),l=e.toolErrorCount??0,u=e.tools.filter(j=>!j.endedAt).length,h=qn(e,o).total,f=e.usage.inputTokens+e.usage.outputTokens,p=e.kind==="root"&&_n(e.waiting),m=vP(e),w=e.kind==="root"?"session":n?`subagent of ${n}`:"subagent",v=[`${e.toolCount} ${e.toolCount===1?"tool":"tools"}`,u>0?`${u} in-flight`:null,f>0?`${Ct(f)} tok`:null,h>0?`${ct(h)}${zl(e,o)>0?"+":""}`:null].filter(Boolean).join(" · ");return kt.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?"≥ ":"",Kl(e.startedAt,e.endedAt,o)]})]}),r.jsxs("div",{className:"node-peek-kind",children:[r.jsxs("span",{className:"node-peek-state","data-kind":b1($l(e)),children:[r.jsx(WP,{kind:b1($l(e))}),Vl($l(e))]}),r.jsx("span",{children:w}),e.model?r.jsx("span",{children:Xp(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(gN,{}),r.jsxs("span",{className:"node-peek-said",title:Jf(e.waiting),children:[r.jsx("span",{className:"node-peek-since",children:r.jsx("b",{children:Kl(e.waiting.since,void 0,o)})}),Jf(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,l>0&&r.jsxs("span",{className:"node-peek-failed",children:[" · ",l," failed"]})]}),e.branch&&e.branch.total>0&&r.jsx("p",{className:"node-peek-branch",children:OP(e.branch)}),r.jsx("p",{className:"node-peek-hint",children:"Click to go to the session · double-click for details"})]}),document.body)}function lme(e){const t=e.minZoom??Zue,n=e.maxZoom??Jue,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),l=Math.max(1,e.pane.height-e.insets.top-e.insets.bottom),u=e.context,h=e.anchor,f=Math.min(i/Math.max(1,u.width),l/Math.max(1,u.height))*s,p=Math.max(t,Math.min(n,f)),m=(w,v,j,b,N,x)=>{let S=w+(v-b*p)/2-j*p;const C=N*p+S,_=(N+x)*p+S;return x*p<=v?C<w?S+=w-C:_>w+v&&(S-=_-(w+v)):S+=w-C,S};return{x:m(a,i,u.x,u.width,h.x,h.width),y:m(o,l,u.y,u.height,h.y,h.height),zoom:p}}function cme(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 Dn(e){const t=g.useRef(e);return t.current=e,t}const mj=80,gj=.86;function e8(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 ume({canvasRef:e,canvasSize:t,machinePhase:n,usagePhase:s,usagePanelOpen:a,detailShown:o}){const[i,l]=g.useState(0);g.useEffect(()=>{const p=e8(e.current);l(m=>Math.abs(m-p)>40?p:m)},[n,s,a,o,t.w]);const u=Dn(i),h=t.w>0?Math.max(0,(t.w-i-mj*2)*gj):0,f=t.h>0?Math.max(0,(t.h-mj*2)*gj):0;return{railInsetRef:u,availableWidth:h,availableHeight:f}}const cO=1e-6;function Pu(e){return Number.isFinite(e[0])&&Number.isFinite(e[1])&&Number.isFinite(e[2])&&e[2]>0}function uO(e,t,n){return Math.abs(e[2]-t[2])<=cO*t[2]&&Math.hypot(e[0]-t[0],e[1]-t[1])<=cO*n}function dme(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 hme(e,t,n){const s=e(0),a=e(.5),o=e(1);if(!Pu(s)||!Pu(a)||!Pu(o))return!1;const i=Math.max(t[2],n[2]);return uO(s,t,i)&&uO(o,n,i)}function fme(e){return(t,n)=>{const s=e(t,n),a=hme(s,t,n)?s:dme(t,n);let o=Pu(t)?t:n;return i=>{const l=a(i);return Pu(l)&&(o=l),o}}}function pme(e){return Number.isFinite(e.x)&&Number.isFinite(e.y)&&Number.isFinite(e.zoom)&&e.zoom>0}const dO=new WeakSet,t8=420;function mme(){const e=ec(),t=Wt(),n=g.useCallback((h,f)=>{if(!pme(h))return;if(m1({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]);g.useEffect(()=>{const h=f=>{!f||dO.has(f)||(dO.add(f),f.interpolate(fme(f.interpolate())))};return h(t.getState().d3Zoom),t.subscribe(f=>h(f.d3Zoom))},[t]);const s=g.useRef(null),a=g.useRef(0),o=g.useRef(0),i=g.useCallback((h,f)=>{const p=++a.current;return o.current=Date.now(),n(h,f),s.current=m1({durationMs:f,documentHidden:document.hidden})?{target:h,until:Date.now()+f+60}:null,p},[n]),l=g.useCallback((h=500)=>{const f=mj,p=1,m=.2,w=gj;try{const v=document.querySelector(".canvas-wrap"),j=Array.from(document.querySelectorAll(".react-flow__node")).filter(F=>F.offsetWidth>0);if(!v||j.length===0)return;const b=v.getBoundingClientRect(),N=e.getViewport();if(!Number.isFinite(N.zoom)||N.zoom<=0)return;const x=new Map(e.getNodes().map(F=>[F.id,F])),S=j.flatMap(F=>{const O=x.get(F.dataset.id??"");if(!O)return[];const K=O.positionAbsolute??O.position,V=O.width??F.offsetWidth,H=O.height??F.offsetHeight;return V>0&&H>0?[{left:K.x,right:K.x+V,top:K.y,bottom:K.y+H}]:[]});if(S.length===0)return;const C=Math.min(...S.map(F=>F.left)),_=Math.max(...S.map(F=>F.right)),M=Math.min(...S.map(F=>F.top)),R=Math.max(...S.map(F=>F.bottom)),P=_-C,L=R-M;if(!(P>0&&L>0))return;const U=e8(v),B=F=>Math.max(m,Math.min(p,(b.width-U-f*2)/(P+F)*w,(b.height-f*2)/L*w)),A=Xue(B(t8),B(0),W6(DN[FN()])),q={x:f-C*A,y:(b.height>b.width-U?f:Math.max(f,(b.height-L*A)/2))-M*A,zoom:A},T=i(q,h);window.setTimeout(()=>{var F;try{if(((F=s.current)==null?void 0:F.target)===q&&(s.current=null),a.current!==T)return;const O=e.getViewport();(Math.abs(O.zoom-A)>.01||Math.abs(O.x-q.x)>2||Math.abs(O.y-q.y)>2)&&n(q,0)}catch{}},h+60)}catch{}},[e,n,i]);g.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 u=g.useCallback(()=>e.getViewport(),[e]);return{applyViewport:n,moveCamera:i,fitLeft:l,currentViewport:u,cameraEpochRef:a,lastFitTimeRef:o}}const gme=450;function yme({canvasRef:e,stateRef:t,measuredRef:n,nodesRef:s,railInsetRef:a,moveCamera:o,disableAutoFit:i,lastFocusRef:l,focusAgentRef:u,selectAgent:h,primarySelectedIdRef:f}){const p=g.useCallback(v=>{const j=e.current,b=t.current.agents.get(v);if(!j||!b)return;const N=RS(t.current),x=(P,L)=>{const U=n.current.get(P.id);if(!U)return null;const B=L&&N.has(P.id)?t8:0;return{x:P.position.x,y:P.position.y,width:U.width+B,height:U.height}},S=s.current.find(P=>P.id===v),C=S?x(S,!1):null;if(!C)return;const _=[];for(const P of s.current){if(P.type!=="agent"&&P.type!=="recapNote"||En(P)!==En(S))continue;const L=x(P,P.type==="agent");L&&_.push(L)}const M=j.getBoundingClientRect(),R=lme({pane:{width:M.width,height:M.height},insets:{top:56,left:72,bottom:32,right:a.current+32},context:cme(_)??C,anchor:C});io(),i(),l.current={id:v,at:Date.now()},o(R,gme)},[o,i]);u.current=p;const m=g.useCallback(v=>{const j=s.current.filter(S=>S.type==="agent"),b=Jpe(j.map(S=>({id:S.id,x:S.position.x,y:S.position.y})),f.current,v),N=b?j.find(S=>S.id===b):void 0;if(!N)return;const x=MS(document.activeElement);h(N.id,!1),window.setTimeout(()=>{try{p(N.id)}catch{}x&&XF(N.id)},30)},[h,p]),w=g.useCallback(v=>{h(v,!1),window.setTimeout(()=>{try{p(v)}catch{}},60)},[h,p]);return{focusAgent:p,stepAgent:m,focusSession:w}}function wme({nodesRef:e,stateRef:t,canvasRef:n,railInsetRef:s}){const a=g.useCallback(u=>{const h=e.current.find(f=>f.id===u&&f.type==="agent");return h?h.data:void 0},[]),o=g.useCallback(u=>{var h;return(h=t.current.agents.get(u))==null?void 0:h.label},[]),i=g.useCallback(u=>{var p;const h=e.current.find(m=>m.id===u&&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}},[]),l=g.useCallback(()=>{var f;const u=(f=n.current)==null?void 0:f.getBoundingClientRect(),h=document.documentElement;return u?{width:u.right-s.current,height:u.bottom}:{width:h.clientWidth,height:h.clientHeight}},[]);return{peekAgent:a,peekLabel:o,peekRecap:i,peekBounds:l}}function xme(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 hO(e){return Object.entries(e??{}).filter(([,t])=>t&&typeof t.x=="number"&&typeof t.y=="number")}function vme(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=hO(n);return{positions:a,pins:a.map(([o])=>o)}}const s=n;return{positions:hO(s.positions),pins:Array.isArray(s.pins)?s.pins:[]}}function bme(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 kme(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 _d="agent-dag.layout",Ed="agent-dag.layoutFrame",Td="agent-dag.viewport";function jme(){return vme(nt(_d))}function Fl(e,t){st(_d,bme(e,t))}function Nme(){return kme(nt(Ed))}function n8(e){st(Ed,JSON.stringify(e))}function Sme(){return R9(nt(Td))}function Cme(e){st(Td,JSON.stringify(e))}function _me(){return{layout:nt(_d),frame:nt(Ed),viewport:nt(Td)}}function Eme(e){const t=(n,s)=>s===null?vs(n):st(n,s);t(_d,e.layout),t(Ed,e.frame),t(Td,e.viewport)}function s8(){vs(_d),vs(Td),vs(Ed)}function Tme({fitLeft:e,moveCamera:t,currentViewport:n}){const s=g.useState(()=>xme(jme()))[0],a=g.useRef(s.pinned),o=g.useRef(s.positions),i=g.useRef(new Set),l=g.useRef(""),[u,h]=g.useState(0),f=g.useState(Nme)[0],p=g.useRef(f),[m,w]=g.useState(!1),[v,j]=g.useState(""),b=g.useState(()=>HZ(L=>{w(L),L||j(U=>U===KT?U:"")}))[0];g.useEffect(()=>()=>b.close(),[b]),g.useEffect(()=>{if(typeof document>"u")return;const L=()=>document.hidden?b.hold("hidden"):b.release("hidden");return document.addEventListener("visibilitychange",L),()=>document.removeEventListener("visibilitychange",L)},[b]);const N=g.useRef(null),x=()=>({positions:o.current,pinned:a.current,provisional:i.current,layoutSig:l}),S=g.useCallback(()=>{b.open(b.snapshot??PZ(x(),_me(),n())),j(UZ),a.current.clear(),o.current.clear(),l.current="",s8(),h(L=>L+1),N.current!=null&&window.clearTimeout(N.current),N.current=window.setTimeout(()=>{N.current=null,Fl(o.current,a.current),p.current&&n8(p.current),e(500)},80)},[e,n,b]),C=g.useCallback(()=>{const L=b.take();return L?(N.current!=null&&window.clearTimeout(N.current),N.current=null,DZ(L,x()),Eme(L.stored),h(U=>U+1),L.viewport&&t(L.viewport,500),j(KT),!0):!1},[t,b]),_=g.useCallback(()=>b.close(),[b]),M=g.useCallback(L=>b.hold(L),[b]),R=g.useCallback(L=>b.release(L),[b]);return{restoredLayout:s,pinnedRef:a,positionsRef:o,provisionalRef:i,lastLayoutSigRef:l,layoutEpoch:u,setLayoutEpoch:h,lastLayoutFrameRef:p,handleRelayout:S,rearrangeUndo:{open:m,said:v,undo:C,dismiss:_,hold:M,release:R}}}function Ame(e,t){const{positionsRef:n,pinnedRef:s}=t,a=g.useRef(null);g.useEffect(()=>(a.current!=null&&window.clearTimeout(a.current),a.current=window.setTimeout(()=>{Fl(n.current,s.current)},1500),()=>{a.current!=null&&window.clearTimeout(a.current)}),[e])}function Rme({nodes:e,edges:t,settled:n,dragging:s,availableWidth:a,availableHeight:o,layout:i,camera:l,rf:u,measuredRef:h,stateRef:f,lastFocusRef:p,primarySelectedIdRef:m,focusAgentRef:w,autoFitDisabledRef:v}){const{lastLayoutFrameRef:j,pinnedRef:b,positionsRef:N,provisionalRef:x,lastLayoutSigRef:S,setLayoutEpoch:C}=i,{applyViewport:_,fitLeft:M,cameraEpochRef:R,lastFitTimeRef:P}=l;g.useEffect(()=>{if(!n||s)return;const L={width:a,height:o};if(!(L.width>0&&L.height>0))return;const U=j.current;if(j.current=L,n8(L),!U||U.width===L.width&&U.height===L.height)return;const B={direction:"LR",pinned:b.current,measured:h.current,lanes:RS(f.current)},A=p.current&&Date.now()-p.current.at<1500?p.current.id:null;if(!Wpe(e,t,B,U,L)){const F=R.current,O=window.setTimeout(()=>{var K;R.current===F&&(v.current?A&&((K=p.current)==null?void 0:K.id)===A&&w.current(A):M(500))},80);return()=>window.clearTimeout(O)}const q=A??m.current,T=q?b.current.get(q)??N.current.get(q):void 0;for(const F of Array.from(N.current.keys()))b.current.has(F)||N.current.delete(F);x.current.clear(),S.current="",C(F=>F+1),window.setTimeout(()=>{if(Fl(N.current,b.current),v.current){if(A){w.current(A);return}const F=q?b.current.get(q)??N.current.get(q):void 0;if(T&&F&&(F.x!==T.x||F.y!==T.y)){const O=u.getViewport();R.current+=1,_({x:O.x-(F.x-T.x)*O.zoom,y:O.y-(F.y-T.y)*O.zoom,zoom:O.zoom},0),P.current=Date.now()}return}M(500)},80)},[a,o,n,s,M,u,_])}function Mme(e,t,n,s,a){const o=[];for(const i of e)!lm(i,t)||n.has(i.id)||o.push(i.id+(i.parentId?`>${i.parentId}`:""));return o.sort(),`${o.join("|")}#sv${s}.${a}`}const $S="agent-dag.removedNodes";function $me(e){try{const t=JSON.parse((e==null?void 0:e.getItem($S))??"[]");return new Set(Array.isArray(t)?t.filter(n=>typeof n=="string"):[])}catch{return new Set}}function P0(e,t){try{e==null||e.setItem($S,JSON.stringify([...t]))}catch{}}function r8(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 l=n.get(o);for(;l&&!i.has(l);){if(s.has(l))return s.add(o),!0;i.add(l),l=n.get(l)}return!1};return o=>a(o.id)||a(o.sessionId??o.id)}function Lme(e,t){if(t.size===0)return new Set;const n=[...e],s=r8(n,t);return new Set(n.filter(s).map(a=>a.id))}function Ime(e,t,n){const s=l=>({id:l.id,parentId:l.data.parentId,sessionId:l.data.sessionId}),a=r8(e.map(s),n),o=e.filter(l=>!a(s(l))),i=new Set(o.map(l=>l.id));return{nodes:o,edges:t.filter(l=>i.has(l.source)&&i.has(l.target))}}function Ome(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 Pme(e,t){return t.size===0?[]:[...e].filter(n=>t.has(n.id)).map(n=>n.id)}function Dme(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 Fme(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 Bme(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 l=e.get(i);if(!l)continue;const u=Dme(l);if(u<=a)continue;const h=[],f=new Set,p=w=>{var v;for(let j=w;j&&!f.has(j);j=(v=e.get(j))==null?void 0:v.parentId)f.add(j),n.has(j)&&h.push(j)};p(l.id),p(l.sessionId);let m=-1/0;for(const w of h)m=Math.max(m,s.get(w)??1/0);if(u>m)for(const w of h)o.add(w)}return[...o]}const Ep="sessionGroup";function qme(e,t){var s,a;if(e.type===Ep)return"transparent";if(_n((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 vf=ti;function Ume(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 l=s.position.x,u=s.position.y,h=l+o,f=u+i,p=t.get(En(s));p?(p.minX=Math.min(p.minX,l),p.minY=Math.min(p.minY,u),p.maxX=Math.max(p.maxX,h),p.maxY=Math.max(p.maxY,f)):t.set(En(s),{minX:l,minY:u,maxX:h,maxY:f})}const n=[];for(const[s,a]of t){const o=a.maxX-a.minX+vf*2,i=a.maxY-a.minY+vf*2;n.push({id:`group:${s}`,type:Ep,position:{x:a.minX-vf,y:a.minY-vf},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 Wme(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 Hme(e,t){const n=new Set;for(const s of t){const a=Wme(e,s);if(a)for(const o of a)n.add(o)}return n.size>0?n:null}function zme({stateRef:e,now:t,removedAgentIds:n,sizeVersion:s,domSizeVersion:a}){return g.useMemo(()=>Mme(e.current.agents.values(),t,n,s,a),[e.current,e.current.revision,t,s,a,n])}function Vme({stateRef:e,now:t,availableWidth:n,availableHeight:s,layout:a,measuredRef:o,onBubble:i,settled:l,dragging:u,layoutSig:h,selectedIds:f,openContext:p,historyReplayed:m,removedNodes:w,removedAgentIds:v,dragTick:j,dragPatchRef:b,dragMoveTick:N}){const{pinnedRef:x,positionsRef:S,provisionalRef:C,lastLayoutSigRef:_,restoredLayout:M,layoutEpoch:R}=a,P=g.useMemo(()=>Hme(e.current,f),[e.current,e.current.revision,f]),L=g.useMemo(()=>{const O=ZJ(e.current,t);for(const K of v)O.delete(K);return O},[e.current,e.current.revision,t,v]),U=g.useRef(new Map),B=xK(),{nodes:A,edges:q}=g.useMemo(()=>{const O=Xpe(e.current,t,n,s,x.current,o.current,U.current,i,l,u,S.current,C.current,h,_,f,P,L,p,m,M.restored);return Ime(O.nodes,O.edges,w)},[e.current,e.current.revision,t,n,s,l,u,h,f,P,L,p,j,B,w,R,m]),T=g.useMemo(()=>Ume(A),[A]),F=g.useMemo(()=>{const O=[...T,...A],K=b.current;return!K||K.size===0?O:O.map(V=>{const H=K.get(V.id);return H?{...V,position:H}:V})},[T,A,N]);return{spotlightSet:P,visibleAgentIds:L,nodes:A,edges:q,allNodes:F}}function Gme(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 Kme({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,Gme(a,t,e))return!1;return s}function Yme({layoutSig:e,rf:t,stateRef:n,measuredRef:s,pinnedRef:a,positionsRef:o,paneSizeRef:i,lastInteractRef:l,autoFitDisabledRef:u,lastFitTimeRef:h,fitLeft:f}){const p=g.useRef(null),m=g.useRef("");g.useEffect(()=>{const w=setInterval(()=>{if(u.current||Date.now()-l.current<800)return;const v=n.current,j=Date.now(),b=[];for(const x of v.agents.values())lm(x,j)&&b.push({id:x.id});if(b.length===0)return;const N=[];for(const{id:x}of b){const S=s.current.get(x),C=a.current.get(x)??o.current.get(x);!S||!C||N.push({x:C.x,y:C.y,width:S.width,height:S.height})}Kme({pane:i.current,viewport:t.getViewport(),boxes:N})&&f(600)},1500);return()=>clearInterval(w)},[t]),g.useEffect(()=>{if(m.current===e)return;const w=m.current;if(m.current=e,!w||u.current)return;Date.now()-h.current>1200&&f(400),p.current&&window.clearTimeout(p.current),p.current=window.setTimeout(()=>{u.current||f(500)},280)},[e,t,f])}function Xme({stateRef:e,pinnedRef:t,positionsRef:n,canvasRef:s,clearSelection:a,primarySelectedId:o}){const[i,l]=g.useState(()=>$me(mr())),[u,h]=g.useState(null),f=g.useMemo(()=>Lme(e.current.agents.values(),i),[e.current,e.current.revision,i]),p=g.useCallback(x=>{const S=e.current.agents.get(x);S&&(l(C=>{const _=new Set(C);return _.add(x),P0(mr(),_),_}),h({id:x,label:S.label}),t.current.delete(x),n.current.delete(x),a())},[a]),m=g.useCallback(()=>{o&&p(o)},[o,p]),w=u&&i.has(u.id)?u:null;g.useEffect(()=>{var x;u&&((x=s.current)==null||x.focus())},[u]);const v=g.useCallback(x=>{const S=[...x];l(C=>{let _=null;for(const M of S)C.has(M)||(_??(_=new Set(C)),_.add(M));return _?(P0(mr(),_),_):C});for(const C of S)t.current.delete(C),n.current.delete(C)},[]),j=g.useCallback(x=>{const S=[...x];l(C=>{const _=Ome(C,S);return _!==C&&P0(mr(),_),_})},[]),b=g.useCallback(()=>{j([...i]),h(null)},[j,i]),N=g.useCallback(()=>{l(new Set),h(null),vs($S)},[]);return{removedNodes:i,lastRemoval:u,removedAgentIds:f,removeNode:p,removeSelectedNode:m,removalNotice:w,hideSessions:v,bringBack:j,bringBackAll:b,forgetRemovals:N}}function Zme({stateRef:e,waitingSessions:t,removedAgentIds:n,removedNodes:s,bringBack:a}){const o=g.useRef(new Map);g.useEffect(()=>{o.current=Fme(o.current,s,Date.now());const i=[...Pme(t,n),...Bme(e.current.agents,n,s,o.current)];i.length>0&&a(i)},[t,n,s,a])}const a8=[0,5,15,30,60],LS="agent-dag.hide-finished-after",o8="agent-dag.hide-finished-turns",Jme=300,Qme=1e4;function IS(e){const t=Number(e);return a8.includes(t)?t:0}function ege(e){return e===0?"Never":`${e} min`}let ci=null;const Cu=new Set;function i8(){for(const e of Cu)e()}function fO(){return ci===null&&(ci=IS(nt(LS))),ci}function tge(e){const t=IS(String(e));ci!==t&&(ci=t,st(LS,String(t)),i8())}function pO(e){if(e.key!==LS)return;const t=IS(e.newValue);t!==ci&&(ci=t,i8())}function nge(e){var t;return Cu.add(e),Cu.size===1&&typeof window<"u"&&((t=window.addEventListener)==null||t.call(window,"storage",pO)),()=>{var n;Cu.delete(e),Cu.size===0&&typeof window<"u"&&((n=window.removeEventListener)==null||n.call(window,"storage",pO))}}function sge(e){try{const t=JSON.parse((e==null?void 0:e.getItem(o8))??"{}");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 mO(e,t){const n=[...t].sort((s,a)=>a[1]-s[1]).slice(0,Jme);try{e==null||e.setItem(o8,JSON.stringify(Object.fromEntries(n)))}catch{}}function l8(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"&&_n(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 rge(e,{afterMs:t,now:n,removed:s,handled:a,keep:o}){if(t<=0)return[];const i=[];for(const[l,u]of l8(e))n-u<t||s.has(l)||l===o||a.get(l)!==u&&i.push({id:l,endedAt:u});return i}function age(e,t,n,s){const a=[...t].filter(l=>!n.has(l));if(a.length===0)return e;const o=l8(s);let i=null;for(const l of a){const u=o.get(l);u==null||e.get(l)===u||(i??(i=new Map(e)),i.set(l,u))}return i??e}function c8(){return g.useSyncExternalStore(nge,fO,fO)}function oge({stateRef:e,removedNodes:t,hideSessions:n,keepSessionId:s,ready:a}){const o=c8(),[i]=g.useState(()=>sge(mr())),l=g.useRef(i),u=g.useRef(t);g.useEffect(()=>{const h=age(l.current,u.current,t,e.current.agents.values());u.current=t,h!==l.current&&(l.current=h,mO(mr(),h))},[t]),g.useEffect(()=>{if(!a||o===0)return;const h=()=>{const p=rge(e.current.agents.values(),{afterMs:o*6e4,now:Date.now(),removed:t,handled:l.current,keep:s});if(p.length===0)return;const m=new Map(l.current);for(const{id:w,endedAt:v}of p)m.set(w,v);l.current=m,mO(mr(),m),n(p.map(w=>w.id))};h();const f=window.setInterval(h,Qme);return()=>window.clearInterval(f)},[a,o,t,s,n])}function ige({waiting:e,running:t,connected:n=!0}){return{title:e>0?`(${e}) ${Pt}`:Pt,icon:n?e>0?"waiting":t>0?"running":"idle":"offline"}}const u8=Object.freeze({offline:"/state/favicon-error.svg",waiting:"/state/favicon-waiting.svg",running:"/state/favicon-syncing.svg",idle:"/favicon.svg"}),d8=Object.freeze({offline:"/state/favicon-error-32.png",waiting:"/state/favicon-waiting-32.png",running:"/state/favicon-syncing-32.png",idle:"/favicon.ico"}),lge=Object.freeze([...new Set([...Object.values(u8),...Object.values(d8)])]),yj=new Map;function gO(e){return yj.get(e)??e}async function cge(e,t=n=>fetch(n)){await Promise.all(e.map(async n=>{if(!yj.has(n))try{const s=await t(n),a=(s.headers.get("Content-Type")??"").split(";")[0].trim();if(!s.ok||!a.startsWith("image/"))return;yj.set(n,`data:${a};base64,${uge(new Uint8Array(await s.arrayBuffer()))}`)}catch{}}))}function uge(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function dge({stateRef:e,waitingSessions:t,live:n}){const s=g.useMemo(()=>bG(e.current.agents.values()),[e.current,e.current.revision]),a=g.useRef(null);g.useEffect(()=>{n&&cge(lge)},[n]),g.useEffect(()=>{const o=ige({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&&h8(o.icon)},[t.length,s,n])}function h8(e){const t=document.querySelector('link[rel="icon"][type="image/svg+xml"]');t&&(t.href=gO(u8[e]));const n=document.querySelector('link[rel="icon"][sizes="32x32"]');n&&(n.href=gO(d8[e]))}const hge=1200,fge=1e3;function D0(e){return e.lastDeckFitAt>0&&e.at-e.lastDeckFitAt<hge?!1:e.hasSourceEvent?!0:e.lastCanvasInputAt>0&&e.at-e.lastCanvasInputAt<fge}function pge({applyViewport:e,lastFitTimeRef:t,cameraEpochRef:n,disableAutoFit:s,markInteract:a,canvasRef:o,applyZoom:i}){const l=g.useState(()=>Sme())[0];g.useEffect(()=>{if(!l)return;const v=window.setTimeout(()=>{try{e(l,0)}catch{}t.current=Date.now()},60);return()=>window.clearTimeout(v)},[e,l]);const u=g.useRef(null),h=g.useRef(0),f=g.useCallback(()=>{h.current=Date.now()},[]),p=g.useCallback(v=>({hasSourceEvent:!!v,at:Date.now(),lastDeckFitAt:t.current,lastCanvasInputAt:h.current}),[]);return{restoredViewport:l,markCanvasInput:f,onMoveStart:v=>{io(),D0(p(v))&&(n.current+=1),D0(p(v))&&s()},onMove:(v,j)=>{var b;a(),D0(p(v))&&s(),(b=o.current)==null||b.style.setProperty("--zoom",String(j.zoom)),i(j.zoom)==="detail"&&io(),u.current&&window.clearTimeout(u.current),u.current=window.setTimeout(()=>Cme(j),250)}}}function mge({clearSelection:e,selectAgent:t,detailOpen:n,setDetailOpen:s,detailShown:a,focusAgent:o,draggingRef:i,lodRef:l}){const u=g.useRef(o);u.current=o;const[h]=g.useState(()=>ND({focus:j=>u.current(j),setTimeout:(j,b)=>window.setTimeout(j,b),clearTimeout:j=>window.clearTimeout(j)}));return g.useEffect(()=>()=>h.cancel(),[h]),{onNodeClick:(j,b)=>{if(b.type==="sessionGroup"){h.cancel(),e();return}const N=b.type==="recapNote"?b.data.parentId:b.id;t(N,j.shiftKey,!1),!j.shiftKey&&(n&&s(!1),pd()?h.hold(N):a?window.setTimeout(()=>{try{o(N)}catch{}},80):o(N))},onPaneClick:()=>{h.cancel(),io(),e()},onNodeDoubleClick:(j,b)=>{if(b.type!=="agent"&&b.type!=="recapNote")return;h.cancel();const N=b.type==="recapNote"?b.data.parentId:b.id;t(N,!1),window.setTimeout(()=>{try{o(N)}catch{}},80)},onNodeMouseEnter:(j,b)=>{b.type!=="agent"&&b.type!=="recapNote"||i.current||l.current==null||l.current==="detail"||JF(b.id,j.currentTarget)},onNodeMouseLeave:(j,b)=>io(b.id)}}function gge({settleAt:e,now:t,take:n,schedule:s,cancel:a}){let o=null;const i=()=>{o!=null&&a(o),o=null};return{read(l,u){i();const h=e()-t();if(h>0){o=s(()=>{o=null,n(l,u)},h);return}n(l,u)},dispose:i}}function yge(e){const t=g.useRef(null),n=g.useRef(null),[s,a]=g.useState({w:0,h:0});return g.useEffect(()=>{const o=n.current;if(!o||typeof ResizeObserver>"u")return;const i=gge({settleAt:()=>(e==null?void 0:e.current)??0,now:()=>performance.now(),take:(u,h)=>a(f=>Math.abs(f.w-u)>40||Math.abs(f.h-h)>40?{w:u,h}:f),schedule:(u,h)=>window.setTimeout(u,h),cancel:u=>window.clearTimeout(u)}),l=new ResizeObserver(u=>{var f;const h=(f=u[0])==null?void 0:f.contentRect;h&&(t.current={width:h.width,height:h.height},i.read(h.width,h.height))});return l.observe(o),t.current={width:o.clientWidth,height:o.clientHeight},a({w:o.clientWidth,h:o.clientHeight}),()=>{l.disconnect(),i.dispose()}},[]),{canvasRef:n,canvasSize:s,paneSizeRef:t}}function wge(e){const t=Wt(),n=g.useRef(new Map),s=g.useRef(0),a=g.useRef(new Map),[o,i]=g.useState(0),[l,u]=g.useState(0),h=g.useRef(null),f=g.useCallback(()=>{h.current=null;let m=!1;for(const v of t.getState().nodeInternals.values()){if(v.type===Ep)continue;const j=v.width,b=v.height;if(j==null||b==null)continue;const N=a.current.get(v.id);(!N||Math.abs(N.width-j)>4||Math.abs(N.height-b)>4)&&(a.current.set(v.id,{width:j,height:b}),n.current.set(v.id,{width:j,height:b}),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-${Ep}`))continue;const j=v.getAttribute("data-id");if(!j)continue;const b=v.offsetWidth,N=v.offsetHeight;if(!b||!N)continue;const x=n.current.get(j);(!x||Math.abs(x.width-b)>4||Math.abs(x.height-N)>4)&&(n.current.set(j,{width:b,height:N}),w=!0)}w&&u(v=>v+1)},[t,e]),p=g.useCallback(()=>{h.current||(h.current=document.visibilityState==="hidden"?{frame:0,timer:window.setTimeout(f,32)}:{frame:requestAnimationFrame(f),timer:0})},[f]);return g.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]),g.useEffect(p),{measuredRef:n,measuredVersionRef:s,sizeVersion:o,domSizeVersion:l}}function xge(){const[e,t]=g.useState(!1);return g.useEffect(()=>{const n=window.setTimeout(()=>t(!0),2500);return()=>window.clearTimeout(n)},[]),e}function vge(){const e=g.useRef(null);return g.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}function bge({pointerFocusRef:e,nodesRef:t,stateRef:n,primarySelectedIdRef:s,providersRef:a,soundOnRef:o,keyHelpOpenRef:i,modalOpenRef:l,waitingCursorRef:u,removeSelectedRef:h,activateSoundRef:f,clearSelection:p,selectAgent:m,focusAgent:w,stepAgent:v,focusSession:j,requestClear:b,handleRelayout:N,undoRearrange:x,handleFit:S,togglePause:C,toggleSessionList:_,toggleAccountsPanel:M,setDetailOpen:R,setUsageHistoryOpen:P,setUsagePanelOpen:L,setMachinePanelOpen:U,setBrowserWatchOpen:B,setKeyHelpOpen:A,setTheme:q,openSettings:T,openIntegrationRef:F,openQuickOpen:O}){g.useEffect(()=>{const K=V=>{var z,X;const H=V.target,D={tagName:H==null?void 0:H.tagName,isContentEditable:H==null?void 0:H.isContentEditable,role:(z=H==null?void 0:H.getAttribute)==null?void 0:z.call(H,"role"),type:H==null?void 0:H.type,pointerFocused:H!=null&&H===e.current};if(V.key==="Escape"){const Y=WG({overlayOpen:cn.depth()>0,typing:ai(D)});Y==="dismiss"?cn.dismissTop():Y==="blur"?H==null||H.blur():(nme(D)&&(H==null||H.blur()),p());return}if(MD(V,po(ro()))){if(wl({appModal:l.current,dialogDepth:cn.dialogDepth()}))return;V.preventDefault(),V.repeat||O();return}if(V.key===","&&fee(V)){if(ai(D)||wl({appModal:l.current,dialogDepth:cn.dialogDepth()}))return;V.preventDefault(),V.repeat||T();return}if(zZ(V)){if(ai(D)||wl({appModal:l.current,dialogDepth:cn.dialogDepth()}))return;!V.repeat&&x()&&V.preventDefault();return}if(em(V))return;const I=MS(H)?(X=H==null?void 0:H.getAttribute)==null?void 0:X.call(H,"data-id"):null,W=I&&t.current.some(Y=>Y.id===I)?I:null,Z=eme(V,W);if(Z.kind==="activate"){V.preventDefault(),m(Z.nodeId,Z.additive);return}if(Z.kind!=="node"&&!$Y(V.key,C1())){if(JG({key:V.key,sheetOpen:i.current,target:D})){V.repeat||A(!1);return}if(V.key==="t"||V.key==="T"){const Y=wl({appModal:l.current,dialogDepth:cn.dialogDepth()});if(Z.nodeId==null&&QG({target:D,modalOpen:Y}))return;V.repeat||q(ate);return}if(!(Z.nodeId==null&&EP(D,V.key))&&!ZG({key:V.key,modalOpen:wl({appModal:l.current,dialogDepth:cn.dialogDepth()}),sheetOpen:i.current})&&!(V.repeat&&!/^[ jkJK]$/.test(V.key))){if(V.key===" "&&(V.preventDefault(),V.repeat||C()),(V.key==="c"||V.key==="C")&&b("shortcut"),(V.key==="r"||V.key==="R")&&N(),(V.key==="f"||V.key==="F")&&S(),(V.key==="z"||V.key==="Z")&&s.current&&w(s.current),V.key==="Delete"&&h.current(),(V.key==="l"||V.key==="L")&&_(),V.key==="d"||V.key==="D")if(s.current)R(Y=>!Y);else{const Y=x1(n.current.agents.values());Y.length>0?j(Y[0].id):v(1)}if((V.key==="h"||V.key==="H")&&P(Y=>!Y),(V.key==="u"||V.key==="U")&&L(Y=>!Y),(V.key==="a"||V.key==="A")&&a.current.claude&&M(),(V.key==="j"||V.key==="J")&&v(1),(V.key==="k"||V.key==="K")&&v(-1),V.key==="w"||V.key==="W"){const Y=vG(x1(n.current.agents.values()),u.current);Y&&(u.current=Y.id,j(Y.id))}(V.key==="m"||V.key==="M")&&o.current!==null&&f.current(V.shiftKey),(V.key==="s"||V.key==="S")&&U(Y=>!Y),(V.key==="b"||V.key==="B")&&B(Y=>!Y),(V.key==="v"||V.key==="V")&&T("sounds"),(V.key==="i"||V.key==="I")&&(F==null||F.current("jira")),V.key==="?"&&A(Y=>!Y)}}};return window.addEventListener("keydown",K),()=>window.removeEventListener("keydown",K)},[b,N,x,S,p,m,v,j,w,C])}function kge(){var e,t;return((t=(e=document.activeElement)==null?void 0:e.matches)==null?void 0:t.call(e,":focus-visible"))===!0}function jge({sessionListShown:e,usageShown:t,machineShown:n,accountsShown:s,detailShown:a,primarySelectedId:o,canvasRef:i}){const l={sessionList:g.useRef(null),usage:g.useRef(null),accounts:g.useRef(null),machine:g.useRef(null)},u=h=>()=>{kge()&&h()};return{toggles:l,sessionList:u(ta(!e,l.sessionList)),usage:u(ta(!t,l.usage)),machine:u(ta(!n,l.machine)),accounts:u(ta(!s,l.accounts)),detail:u(ta(!a,()=>{var h,f;o&&XF(o),Un(((h=document.activeElement)==null?void 0:h.tagName)??null)&&((f=i.current)==null||f.focus({preventScroll:!0}))}))}}function Nge({nodes:e,stateRef:t,pinnedRef:n,positionsRef:s,draggingRef:a,dragPatchRef:o,setDragging:i,setDragMoveTick:l,setDragTick:u,endBubble:h,markInteract:f,disableAutoFit:p,beginTrashDrag:m,trackTrashDrag:w,endTrashDrag:v,removeNode:j}){const b=g.useRef(null);return{onNodeDragStart:(C,_)=>{var M,R;if(_){if(io(),h(),a.current=!0,o.current=new Map,i(!0),f(),p(),_.type==="sessionGroup"){const P=(M=_.data)==null?void 0:M.sessionId,L=new Map,U=new Map;if(P)for(const A of e)!A.data||En(A)!==P||(L.set(A.id,{x:A.position.x,y:A.position.y}),U.set(A.id,n.current.get(A.id)));b.current={sessionId:P,start:{x:_.position.x,y:_.position.y},members:L,pinsBefore:U};const B=P?t.current.agents.get(P):void 0;m(B?B.label:null);return}m(_.type==="agent"?((R=t.current.agents.get(_.id))==null?void 0:R.label)??"":null),n.current.set(_.id,{x:_.position.x,y:_.position.y})}},onNodeDrag:(C,_)=>{var M;if(_){if(f(),(_.type==="agent"||_.type==="sessionGroup")&&w(C),_.type==="sessionGroup"){const R=b.current;if(!R)return;const P=_.position.x-R.start.x,L=_.position.y-R.start.y;for(const[B,A]of R.members){const q={x:A.x+P,y:A.y+L};n.current.set(B,q),s.current.set(B,q)}const U=o.current;if(U){for(const[B,A]of R.members)U.set(B,{x:A.x+P,y:A.y+L});U.set(_.id,{x:_.position.x,y:_.position.y})}l(B=>B+1);return}n.current.set(_.id,{x:_.position.x,y:_.position.y}),s.current.set(_.id,{x:_.position.x,y:_.position.y}),(M=o.current)==null||M.set(_.id,{x:_.position.x,y:_.position.y}),l(R=>R+1)}},onNodeDragStop:(C,_)=>{f();const M=v(C,(_==null?void 0:_.type)==="agent"||(_==null?void 0:_.type)==="sessionGroup");if(a.current=!1,o.current=null,i(!1),u(R=>R+1),!_){b.current=null,Fl(s.current,n.current);return}if(_.type==="sessionGroup"){const R=b.current;if(R&&M&&R.sessionId){for(const[P,L]of R.members){const U=R.pinsBefore.get(P);U?n.current.set(P,U):n.current.delete(P),s.current.set(P,L)}b.current=null,j(R.sessionId);return}if(R){const P=_.position.x-R.start.x,L=_.position.y-R.start.y;for(const[U,B]of R.members){const A={x:B.x+P,y:B.y+L};n.current.set(U,A),s.current.set(U,A)}}b.current=null,Fl(s.current,n.current),u(P=>P+1);return}if(n.current.set(_.id,{x:_.position.x,y:_.position.y}),s.current.set(_.id,{x:_.position.x,y:_.position.y}),M){j(_.id);return}Fl(s.current,n.current)}}}function Sge(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 f8({active:e=!1}){const[t,n]=g.useState(()=>typeof document>"u"||!document.hidden);return g.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 Cge({reservedRight:e=0}){return r.jsx("div",{className:"empty-stage",style:{right:e},children:r.jsxs("div",{className:"empty-hero",children:[r.jsx(f8,{}),r.jsxs("h2",{children:["Too many ",Pt," tabs are open"]}),r.jsxs("p",{children:["This browser keeps at most six live connections to one address, and other ",r.jsx("code",{children:Pt})," tabs are holding them. Close one and this tab connects on its own."]})]})})}function _ge({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(f8,{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:Pt}),". Check that it is still running in your terminal — the page picks up again on its own."]})]}):Ege(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(sd,{film:"tour",action:!0})]})]})})}function Ege(e,t){const n=Sge(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?"}),gse(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 Tge=1;function Age(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 Rge(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:Tge,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(Age)}))}}function Mge(e,t){const n=(e||"session").replace(/[^a-z0-9._-]/gi,"_");return`${Pt}-${n}-${lp(t,8)}.json`}const p8={file:"📁",shell:"⚡",web:"🌐",agent:"🤖",task:"📋",plan:"🧭",mcp:"🔌",other:"✨"},$ge={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 Lge({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:$ge[e]})})}const Tp={file:"file",shell:"shell",web:"web",agent:"agent",task:"task",plan:"plan",mcp:"mcp",other:"other"},m8=DP;function Ige({agent:e,now:t,onOpenTool:n,onShowSummary:s,onExportSession:a,onRemove:o,singleKeys:i=!0}){var b;const l=`${e.synthetic?"≥ ":""}${Kl(e.startedAt,e.endedAt,t)}`,u=qn(e),h=u.total>0,f=e.usage.inputTokens+e.usage.outputTokens,p=new Map;for(const[N,x]of e.toolCountByName??[]){const S=m8(N);p.set(S,(p.get(S)??0)+x)}const m=e.toolErrorCount??0,w=e.tools.filter(N=>!N.endedAt).length,v=Array.from(p.entries()).sort((N,x)=>x[1]-N[1]),j=p.has("mcp")?tY(((b=e.toolCountByName)==null?void 0:b.keys())??[]):null;return r.jsxs(r.Fragment,{children:[r.jsxs("header",{className:"detail-hero",children:[r.jsxs("div",{className:"hero-line",children:[r.jsx("span",{className:`state-pill state-${e.state}`,children:e.state==="active"?"live":e.state}),r.jsx("h2",{className:"hero-title",title:e.cwd??e.label,children:e.label})]}),r.jsxs("div",{className:"hero-meta",children:[r.jsx("span",{className:"hero-meta-item",children:Jp(e)}),r.jsx("span",{className:"hero-sep",children:"·"}),r.jsx("span",{className:"hero-meta-item",title:`started ${new Date(e.startedAt).toLocaleString()}`,children:l}),e.model&&(()=>{const N=lN(e);return r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"hero-sep",children:"·"}),r.jsxs("span",{className:"model-chip","data-family":Yp(e.model),title:N.length>0?`${Yu(e.model,e.effort)}
|
|
108
|
+
spend on this panel also covers:
|
|
109
|
+
${N.join(`
|
|
110
|
+
`)}`:Yu(e.model,e.effort),children:[Xp(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:ct(u.total)}),r.jsx("span",{className:"hero-cost-label",children:"spend"})]}),r.jsx(WN,{cost:u})]}),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; ${Cn("the session list","L",i)} brings it back`:`Take this card and the ones under it off the board (Delete). ${Cn("The session list","L",i)} brings it back`,children:"Remove from board"})]})]}),r.jsx(kY,{agent:e}),(()=>{const N=fN(e);if(!N)return null;const x=np(N.at,t),S=N.kind==="recap"?"Recap":rc(N.kind).replace(/^./,C=>C.toUpperCase());return r.jsxs("section",{className:"detail-section",children:[r.jsxs("h3",{children:[S," ",r.jsx("span",{className:"section-count",title:x.title,children:x.label})]}),r.jsx("p",{className:"detail-recap",title:nm(N),children:N.text}),N.reply&&r.jsxs("p",{className:"detail-recap detail-note-reply",children:["Suggested reply: “",N.reply,"”"]})]})})(),(()=>{const N=jr(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((x,S)=>r.jsxs("li",{className:"plan-item","data-status":x.status,children:[r.jsx("span",{className:"plan-mark","aria-hidden":!0}),r.jsxs("span",{className:"vis-hidden",children:[Fge[x.status],": "]}),r.jsx("span",{className:"plan-text",children:x.status==="in_progress"&&x.active?x.active:x.text}),x.status==="in_progress"&&r.jsx("span",{className:"plan-now","aria-hidden":!0,children:"now"})]},x.id??`${S}:${x.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,x])=>{const S=N==="mcp"?j:null,C=S==null?void 0:S.hue,_=`${x} ${Tp[N]} call${x===1?"":"s"}`;return r.jsxs("span",{className:`cat-chip cat-${N}${C!=null?" mcp-hue":""}`,style:C!=null?{"--mcp-hue":C}:void 0,title:S?`${_}, all to ${S.label}`:_,children:[r.jsx("span",{className:"cat-emoji","aria-hidden":!0,children:p8[N]}),r.jsx("span",{className:"cat-name",children:Tp[N]}),r.jsx("span",{className:"cat-count",children:x}),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:Ct(e.usage.inputTokens)})]}),r.jsxs("div",{children:[r.jsx("span",{className:"k",children:"out"}),r.jsx("b",{title:e.usage.outputTokens.toLocaleString(),children:Ct(e.usage.outputTokens)})]}),r.jsxs("div",{children:[r.jsx("span",{className:"k",children:"cache r"}),r.jsx("b",{title:e.usage.cacheReadTokens.toLocaleString(),children:Ct(e.usage.cacheReadTokens)})]}),r.jsxs("div",{children:[r.jsx("span",{className:"k",children:"cache c"}),r.jsx("b",{title:e.usage.cacheCreateTokens.toLocaleString(),children:Ct(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:J4(e.prompts).length})]}),r.jsx("div",{className:"prompts",children:Oge(e.prompts).reverse().map(({pr:N,key:x})=>{const S=np(N.at,t),C=zp(N.text);return C?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:C.label})]}),C.detail&&r.jsx("div",{className:"prompt-injected-detail",children:C.detail})]},x):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})]},x)})})]}),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(Dge,{t:N,onClick:()=>n(e.id,N.id)},N.id))})]})]})}function Oge(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 Pge={inflight:"in-flight",done:"done",err:"error"};function Dge({t:e,onClick:t}){const n=e.endedAt==null?"inflight":e.ok===!1?"err":"done",s=SP(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:Pge[n]}),e.name]}),r.jsx("span",{style:{color:"var(--muted)"},children:s})]})}const Fge={completed:"done",in_progress:"now",pending:"to do"};function Bge(e,t){const n=Rge(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=Mge(n.label,t),document.body.appendChild(i),i.click(),document.body.removeChild(i),setTimeout(()=>URL.revokeObjectURL(o),1e3)}function qge({selected:e,now:t,openTool:n,setSummaryFor:s,onClose:a,stateRef:o,removeSelectedNode:i}){sn("detail-panel");const l=Tn();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(Ige,{agent:e,now:t,onOpenTool:n,onShowSummary:s,onExportSession:u=>Bge(o.current,u),onRemove:i,singleKeys:l})]})}function Uge(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}
|
|
111
|
+
${t} unread`:n}function bf(e,t){return t.map(n=>({...n,group:e}))}function Wge({providers:e,sessionListOpen:t,toggleSessionList:n,accountsPanelOpen:s,toggleAccountsPanel:a,usagePanelOpen:o,setUsagePanelOpen:i,machinePanelOpen:l,setMachinePanelOpen:u,setUsageHistoryOpen:h,watchOn:f,watchUnseen:p,setBrowserWatchOpen:m,setTrafficRadarOpen:w,setRadioOpen:v,openToolActivity:j,openSettings:b,onFeedback:N,toggles:x,openCapacity:S,integrations:C=[],openExploreIntegrations:_,openQuickOpen:M}){const R=pee(ro()),P=po(ro()),L={id:"session-list",label:"Session list",short:"Sessions",key:{cap:"L",aria:"L",single:!0},ariaLabel:"Session list",glyph:r.jsx(hQ,{}),kind:"panel",open:t,controls:"session-list",onPress:n,buttonRef:x.sessionList},U={id:"accounts",label:"Accounts",short:"Accounts",key:{cap:"A",aria:"A",single:!0},ariaLabel:"Accounts",hint:"Claude accounts",glyph:r.jsx(pQ,{}),kind:"panel",open:s,controls:"accounts-panel",onPress:a,buttonRef:x.accounts},B=S?[{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(_Q,{}),kind:"dialog",onPress:()=>S("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(EQ,{}),kind:"dialog",onPress:()=>S("calendar")}]:[],A={id:"usage",label:"Usage",short:"Usage",key:{cap:"U",aria:"U",single:!0},ariaLabel:"Usage",glyph:r.jsx(mQ,{}),kind:"panel",open:o,controls:"usage-panel",onPress:()=>i(W=>!W),buttonRef:x.usage},q={id:"machine",label:"Machine",short:"Machine",key:{cap:"S",aria:"S",single:!0},ariaLabel:"Machine",hint:"This machine",glyph:r.jsx(yQ,{}),kind:"panel",open:l,controls:"system-panel",onPress:()=>u(W=>!W),buttonRef:x.machine},T={id:"history",label:"Usage history",short:"History",key:{cap:"H",aria:"H",single:!0},ariaLabel:"Usage history",glyph:r.jsx(gQ,{}),kind:"dialog",onPress:()=>h(W=>!W)},F={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:Uge(f,p),glyph:r.jsx(xQ,{watching:f===!0||p>0}),kind:"dialog",onPress:()=>m(W=>!W),badge:p},O={id:"settings",label:"Settings",short:"Settings",key:{cap:R,aria:"Control+, Meta+,",single:!1},ariaLabel:"Settings",glyph:r.jsx(vQ,{}),kind:"dialog",onPress:()=>b()},K={id:"quick-open",label:"Search",short:"Search",key:{cap:dQ(P),aria:P?"Meta+K":"Control+K",single:!1},ariaLabel:"Search",detail:"Panels, sessions, settings, actions and themes",glyph:r.jsx(LD,{}),kind:"dialog",onPress:M},V={id:"feedback",label:"Feedback",short:"Feedback",menu:"Send feedback",ariaLabel:"Send feedback",glyph:r.jsx(bQ,{}),kind:"dialog",onPress:N},H=j?[{id:"tool-activity",label:"Tool activity",short:"Tools",ariaLabel:"Tool activity",glyph:r.jsx(SQ,{}),kind:"dialog",detail:"Which tools your agents run, how long they take and what fails",onPress:()=>j("tools")},{id:"skill-activity",label:"Skill activity",short:"Skills",ariaLabel:"Skill activity",glyph:r.jsx(CQ,{}),kind:"dialog",detail:"Which skills your agents use, whether you typed them or the agent called them",onPress:()=>j("skills")}]:[],D=w?[{id:"traffic-radar",label:"Telemetry Radar",short:"Radar",ariaLabel:"Telemetry Radar",glyph:r.jsx(wQ,{}),kind:"dialog",detail:"Claude telemetry configuration and observed connections",onPress:()=>w(!0)}]:[],I=v?[{id:"radio",label:"Radio",short:"Radio",ariaLabel:"Radio",glyph:r.jsx(NQ,{}),kind:"dialog",detail:"Explore stations around the world",onPress:()=>v(!0)}]:[];return{left:e.claude?[U,L]:[L],leftStripe:e.claude?[bf("Claude accounts",[U,...B]),[L]]:[[L]],capacity:e.claude?B:[],right:[bf("Usage and machine",[A,q]),bf("Activity history",[T,...H]),bf("Watchers",[F,...D]),I].filter(W=>W.length>0),utilities:[O,V],search:K,explore:_?[{id:"explore-integrations",label:"Explore integrations",short:"Integrations",ariaLabel:"Explore integrations",glyph:r.jsx(fQ,{}),kind:"dialog",onPress:_}]:[],integrations:C.map(({provider:W,onPress:Z})=>({id:`integration-${W.kind}`,label:W.label,short:W.label,ariaLabel:W.label,detail:W.detail,key:W.shortcut?{cap:W.shortcut.toUpperCase(),aria:W.shortcut.toUpperCase(),single:!0}:void 0,glyph:r.jsx(W.Glyph,{}),kind:"dialog",onPress:Z}))}}const Ap=[{value:"bug",label:"Bug",question:"What happened?",placeholder:`I was trying to…
|
|
112
|
+
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 g8(e){return Ap.find(t=>t.value===e)??Ap[0]}const wj=3,F0=120,y8=1e4,w8=200,Hge="Write something first.";function yO(e){return e.trim()!==""}function zge(e){var o;const t=e.trim();if(t==="")return"";const n=wO(t.split(/\r?\n/,1)[0]),s=((o=/^(.+?[.!?])(?=\s|$)/.exec(n))==null?void 0:o[1])??n,a=B0(s).length>=wj?B0(s):B0(n);return Gge(a.length>=wj?a:wO(t))}function Vge(e,t){const n=zge(t);return n.length>=wj?n:`${g8(e).label}: ${n}`}function wO(e){return e.replace(/\s+/g," ").trim()}function B0(e){return/[^.]\.$/.test(e)?e.slice(0,-1):e}function Gge(e){if(e.length<=F0)return e;const t=e.slice(0,F0-1),n=t.lastIndexOf(" ");return`${(n>=F0/2?t.slice(0,n):t).replace(/[\uD800-\uDBFF]$/,"").replace(/[\s,;:.\-–—]+$/,"")}…`}function Kge({kind:e,body:t,contact:n}){const s={kind:e,title:Vge(e,t),body:t.trim()};return n.trim()!==""&&(s.contact=n.trim()),s}function Yge(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 Xge={darwin:"macOS",win32:"Windows",linux:"Linux"};function Zge(e){const t=e.indexOf("-"),n=t===-1?e:e.slice(0,t),s=t===-1?"":e.slice(t+1),a=Xge[n]??n;return s?`${a} · ${s}`:a}function Jge(e){return e?`ccdeck ${e.appVersion} · ${Zge(e.platform)}`:null}const Qge="sent with it",eye="Your ccdeck version and system are sent with it.",tye="Add details",nye="How to reach you",sye="Email or GitHub @name",rye="Only if you would like an answer.",aye=["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 oye(e){return e.key==="Enter"&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey&&!e.isComposing}function OS(e){return e.key==="Enter"&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey&&!e.isComposing}function iye(e){return po(e)?["⌘","Enter"]:["Ctrl","Enter"]}function lye(e){return[...e].length===1}const x8="Thanks — feedback sent.";function xO(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 cye(e){return e==="sending"?"Sending…":e==="sent"?x8:""}const vO=1400,uye=160,v8=g.createContext({values:{}});function b8(){return g.useContext(v8)}function dye(e,t){const n=e.variants;return n?{...e,...n.by[t[n.field]??""]??{}}:e}const bO=(e,t)=>!e.when||e.when.is.includes(t[e.when.field]??"");function hye({def:e,existing:t,busy:n,error:s,onSubmit:a,onCancel:o,onDirtyChange:i}){var q,T;const l=g.useId(),[u,h]=g.useState(()=>Object.fromEntries(e.fields.map(F=>{var O,K,V;return[F.name,F.secret?"":((O=F.initial)==null?void 0:O.call(F,t))??(F.type==="choice"?((V=(K=F.options)==null?void 0:K[0])==null?void 0:V.value)??"":"")]}))),[f,p]=g.useState((t==null?void 0:t.name)??""),m=g.useRef(null),w=g.useRef(new Map),v=!!t,j=g.useRef(u),b=g.useRef(f);g.useEffect(()=>{i==null||i(f!==b.current||Object.keys(u).some(F=>u[F]!==j.current[F]))},[f,u,i]);const N=e.fields.filter(F=>F.type==="choice").every(F=>u[F.name]===j.current[F.name]),x=v&&t.tokenSaved&&N,S=(F,O)=>{n||h(K=>({...K,[F]:O}))},C=F=>{var K;if(F.preventDefault(),n)return;const O={};for(const V of e.fields)bO(V,u)&&(O[V.name]=(u[V.name]??"").trim());(K=F.currentTarget.querySelector('button[type="submit"]'))==null||K.focus(),a(O,f.trim()),h(V=>Object.fromEntries(Object.entries(V).map(([H,D])=>{var I;return[H,(I=e.fields.find(W=>W.name===H))!=null&&I.secret?"":D]})))},_=g.useMemo(()=>{const F=u.baseUrl??"";try{return F?new URL(/^[a-z]+:\/\//i.test(F)?F:`https://${F}`).host:""}catch{return""}},[u.baseUrl]),M=g.useMemo(()=>({values:u,existing:t}),[u,t]),R=e.fields.filter(F=>bO(F,u)),P=(q=R.find(F=>!F.secret&&F.type!=="choice"))==null?void 0:q.name,L=(T=R.find(F=>F.secret))==null?void 0:T.name,U=s!=null&&s.field&&R.some(F=>F.name===s.field&&F.type!=="choice")?s.field:null,B=`${l}-error`;g.useEffect(()=>{var O,K,V;const F=v?L:P??L;F&&((O=w.current.get(F))==null||O.focus()),(V=(K=m.current)==null?void 0:K.scrollIntoView)==null||V.call(K,{block:"nearest"})},[v]),g.useEffect(()=>{var F;U&&((F=w.current.get(U))==null||F.focus())},[s,U]);const A=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(v8.Provider,{value:M,children:r.jsxs("form",{ref:m,className:"ig-form",onSubmit:C,"aria-labelledby":`${l}-title`,noValidate:!0,children:[r.jsxs("header",{className:"ig-managed-header",children:[r.jsx("span",{className:"ig-provider-glyph","aria-hidden":!0,children:r.jsx(e.Glyph,{})}),r.jsxs("div",{className:"ig-managed-identity",children:[r.jsx("h2",{className:"ig-form-title",id:`${l}-title`,children:v?`Edit ${t.name}`:`Connect ${e.label}`}),v&&r.jsxs("p",{children:[e.label," connection"]})]})]}),R.map(F=>{const O=dye(F,u),K=(s==null?void 0:s.field)===O.name,V=[O.hint?`${l}-${O.name}-hint`:"",K?B:""].filter(Boolean).join(" ")||void 0;if(O.type==="choice")return r.jsxs("fieldset",{className:"fb-kinds","aria-invalid":K||void 0,children:[r.jsx("legend",{className:"vis-hidden",children:O.label}),(O.options??[]).map(I=>r.jsxs("label",{className:"fb-kind",children:[r.jsx("input",{type:"radio",name:`${l}-${O.name}`,value:I.value,checked:u[O.name]===I.value,"aria-disabled":n||void 0,onChange:()=>S(O.name,I.value),onKeyDown:W=>{OS(W.nativeEvent)&&W.preventDefault()}}),I.label]},I.value))]},O.name);const H=O.secret&&x,D=`${l}-${O.name}`;return r.jsxs("div",{className:"fb-field",children:[r.jsxs("label",{className:"fb-field-label",htmlFor:D,children:[O.label,O.optional&&r.jsx("span",{className:"fb-optional",children:" optional"})]}),r.jsx("input",{id:D,className:`ap-manage-input ig-input${O.secret?" ig-mono":""}`,ref:I=>{I?w.current.set(O.name,I):w.current.delete(O.name)},type:O.type,inputMode:O.type==="url"?"url":O.type==="email"?"email":void 0,autoComplete:O.autoComplete??"off",spellCheck:!1,value:u[O.name]??"",onChange:I=>S(O.name,I.target.value),placeholder:H?"Saved. Leave blank to keep it":O.placeholder,readOnly:n,"aria-invalid":K||void 0,"aria-describedby":V,"aria-required":!O.optional&&!H||void 0}),O.hint&&r.jsx("span",{className:"ig-hint",id:`${l}-${O.name}-hint`,children:O.hint}),K&&U===O.name&&r.jsx("span",{className:"ig-form-error",id:B,role:"alert",children:A})]},O.name)}),r.jsxs("details",{className:"ig-help ig-token-help",children:[r.jsxs("summary",{children:["How to create a ",e.label," token"]}),e.tokenHelp]}),r.jsxs("div",{className:"fb-field",children:[r.jsxs("label",{className:"fb-field-label",htmlFor:`${l}-name`,children:["Name ",r.jsx("span",{className:"fb-optional",children:"optional"})]}),r.jsx("input",{id:`${l}-name`,className:"ap-manage-input ig-input",type:"text",autoComplete:"off",maxLength:120,readOnly:n,value:f,onChange:F=>p(F.target.value),placeholder:_||e.label})]}),s&&!U&&r.jsx("p",{className:"ig-form-error",id:B,role:"alert",children:A}),r.jsxs("div",{className:"ig-form-actions",children:[r.jsx("button",{type:"submit",className:"btn primary","aria-disabled":n,"aria-busy":n,children:n?"Checking…":v?"Save":"Connect"}),r.jsx("button",{type:"button",className:"btn","aria-disabled":n||void 0,onClick:()=>{n||o()},children:"Cancel"})]})]})})}const fye="https://id.atlassian.com/manage-profile/security/api-tokens",pye="https://support.atlassian.com/atlassian-account/docs/manage-api-tokens-for-your-atlassian-account/",mye="https://confluence.atlassian.com/enterprise/using-personal-access-tokens-1026032365.html",gye=[{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 yye(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 wye(){const{values:e}=b8(),t=e.deployment==="cloud",n=t?null:yye(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:fye,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:gye.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:pye,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:mye,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 q0(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 U0({href:e,children:t}){return e?r.jsxs("a",{className:"fg-token-link",href:e,target:"_blank",rel:"noreferrer noopener",children:[t," ",r.jsx(rd,{})]}):null}function k8({kind:e,baseUrl:t}){const{values:n}=b8();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(U0,{href:q0("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(U0,{href:q0("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=q0("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(U0,{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 j8={name:"token",label:"Personal access token",type:"password",secret:!0,placeholder:"Paste the token"},xye=[j8],kO=e=>{try{return e?new URL(e.baseUrl).host!=="gitlab.com":!1}catch{return!1}},vye=[{name:"where",label:"Which GitLab",type:"choice",options:[{value:"cloud",label:"GitLab.com"},{value:"self",label:"Self-managed"}],initial:e=>kO(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=>kO(e)?e.baseUrl:""},j8],bye=g.createElement(k8,{kind:"github"}),kye=g.createElement(k8,{kind:"gitlab"}),jye=e=>{var t;return((t=e==null?void 0:e.meta)==null?void 0:t.deployment)==="cloud"?"cloud":"server"},Nye={kind:"jira",label:"Jira",Glyph:AQ,shortcut:"I",detail:"Boards, sprints, and issues",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:jye},{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:g.createElement(wye)},Sye={kind:"github",label:"GitHub",Glyph:RQ,detail:"Repositories, pull requests, and Actions",blurb:"github.com, read-only, with a personal access token.",fields:xye,tokenHelp:bye},Cye={kind:"gitlab",label:"GitLab",Glyph:MQ,detail:"Projects, merge requests, and pipelines",blurb:"GitLab.com or your own instance, read-only.",fields:vye,tokenHelp:kye},xj={jira:Nye,github:Sye,gitlab:Cye},PS=()=>Object.values(xj).filter(e=>!!e);function _u(e){return(Object.hasOwn(xj,e)?xj[e]:void 0)??null}function Wm(e,t){const n=s=>typeof t=="string"?t:t(s);return g.lazy(()=>e().catch(s=>(console.warn(`ccdeck could not load ${typeof t=="string"?t:"a dialog"}`,s),{default:a=>r.jsx(_ye,{name:n(a),onClose:a.onClose})})))}function _ye({name:e,onClose:t}){const n=g.useRef(null),s=gt(t,{focusRef:n}),a=yt(t);return r.jsx("div",{className:"modal-backdrop",...a,role:"presentation",children:r.jsxs("div",{ref:s,className:"modal dialog-missing",onClick:o=>o.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"dialog-missing-title",children:[r.jsxs("header",{className:"modal-head",children:[r.jsx("div",{className:"modal-title",children:r.jsx("span",{id:"dialog-missing-title",className:"modal-tool-name",children:e})}),r.jsx("div",{className:"modal-actions",children:r.jsx("button",{type:"button",className:"glyph-btn",onClick:t,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),r.jsxs("section",{className:"modal-body",children:[r.jsxs("p",{className:"dm-note",children:[e," did not load. The deck has most likely been updated since this tab opened, and a reload picks up the new version."]}),r.jsxs("div",{className:"dm-actions",children:[r.jsx("button",{type:"button",className:"btn",onClick:t,children:"Close"}),r.jsx("button",{type:"button",ref:n,className:"btn primary",onClick:()=>window.location.reload(),children:"Reload"})]})]})]})})}const N8=()=>bi(()=>import("./IntegrationModal-8tTi25gA.js"),[]);function Eye(){N8().catch(()=>{})}const Tye=Wm(N8,e=>{var t;return((t=_u(e.kind))==null?void 0:t.label)??"The tracker"});function Aye({onClose:e}){return g.useEffect(()=>cn.push(e,0,"dialog"),[e]),null}function Rye(e){return r.jsx(g.Suspense,{fallback:r.jsx(Aye,{onClose:e.onClose}),children:r.jsx(Tye,{...e})})}class yr extends Error{constructor(n,s,a={}){super(s);Ba(this,"kind");Ba(this,"status");Ba(this,"retryAfter");Ba(this,"field");Ba(this,"detail");this.name="IntegrationFailure",this.kind=n,Object.assign(this,a)}}async function S8(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 yr(n.kind,n.message,{status:n.status,retryAfter:n.retryAfter,field:n.field,detail:n.detail})}catch{}return new yr(e.status===401?"auth":"upstream",`The deck answered ${e.status}.`)}async function Ad(e,t={}){const{timeoutMs:n=3e4,...s}=t,a=new AbortController,o=window.setTimeout(()=>a.abort(),n),i=s.signal,l=()=>a.abort();i==null||i.addEventListener("abort",l,{once:!0});let u;try{u=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 yr("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",l)}if(!u.ok)throw await S8(u);return u.json()}const C8=e=>`/api/integrations/${encodeURIComponent(e.kind)}/${encodeURIComponent(e.id)}/`;function aje(e){const t=C8(e);return(n,s)=>fetch(`${t}${n.replace(/^\/+/,"")}`,s)}function oje(e){const t=C8(e);return n=>`${t}asset?url=${encodeURIComponent(n)}`}function ije(e,t){if(!t)return null;try{const n=new URL(t);return n.username||n.password||n.protocol!=="https:"&&n.protocol!=="http:"?null:n.origin===new URL(e.baseUrl).origin?n.href:null}catch{return null}}function lje(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 cje(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 l;try{l=await e(t,{signal:a.signal,headers:{Accept:"application/json"}})}catch(u){throw n!=null&&n.aborted?u:new yr("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(!l.ok)throw await S8(l);try{return await l.json()}catch{throw new yr("upstream","The deck answered with something that is not JSON.")}}let oa={connections:null,providers:[],error:""};const Tl=new Set;let kf=null,fu=null,Bl=null,jO=0;const Mye=5e3,$ye=3;function Rp(e){oa={...oa,...e},Tl.forEach(t=>t(oa))}function Hm(){return fu||(fu=(async()=>{try{const e=await Ad("/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 yr("upstream","The deck answered with something that is not the list of connections.");Rp({connections:t,providers:n,error:""})}catch(e){Rp({error:e instanceof Error?e.message:"Could not read the connections."}),oa.connections===null&&Tl.size>0&&Bl===null&&jO<$ye&&(Bl=window.setTimeout(()=>{Bl=null,Hm()},Mye*2**jO++))}finally{fu=null}})(),fu)}function Lye(e){return e.connections===null||e.providers.length>0||e.connections.length>0}function NO(){Lye(oa)&&Hm()}function DS(e){const t=oa.connections??[],n=t.findIndex(s=>s.id===e.id);Rp({connections:n<0?[...t,e]:t.map(s=>s.id===e.id?e:s)})}function Iye(e){Rp({connections:(oa.connections??[]).filter(t=>t.id!==e)})}function Rd(){const[e,t]=g.useState(oa);return g.useEffect(()=>{Tl.add(t),t(oa);const n=()=>{document.visibilityState==="visible"&&NO()};return Tl.size===1&&(Hm(),kf=window.setInterval(NO,6e4),document.addEventListener("visibilitychange",n)),()=>{Tl.delete(t),Tl.size===0&&(kf!==null&&window.clearInterval(kf),kf=null,Bl!==null&&window.clearTimeout(Bl),Bl=null,document.removeEventListener("visibilitychange",n))}},[]),e}function Mp(e,t){return(e.connections??[]).filter(n=>n.kind===t)}function Md(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 sa(e,t){return Md(e).has(t)}function vj(e,t){return sa(e,t)&&Mp(e,t).length>0}function FS(e){return Md(e).size>0?"all":(e.connections??[]).length>0?"connections":"none"}async function Oye(e,t,n){const s=await Ad("/api/integrations/connections",{method:"POST",body:JSON.stringify({kind:e,name:n,input:t}),timeoutMs:6e4});return DS(s.connection),s.connection}async function Pye(e,t){const n=await Ad(`/api/integrations/connections/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t),timeoutMs:6e4});return DS(n.connection),n}async function Dye(e){const t=await Ad(`/api/integrations/connections/${encodeURIComponent(e)}/test`,{method:"POST",body:"{}",timeoutMs:6e4});return DS(t.connection),t.connection}async function Fye(e){await Ad(`/api/integrations/connections/${encodeURIComponent(e)}`,{method:"DELETE"}),Iye(e)}function Vo(e){try{return new URL(e.baseUrl).host}catch{return e.baseUrl}}function uje(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 $p=null,Lp=null;function SO(e){Lp=null,$p=e}function Bye(e){$p=null,Lp=e}function qye(){const e=Lp;return Lp=null,e}function Uye(){const e=$p;return $p=null,e}const Wye={jira:"Boards, sprints, backlog and issues",github:"Repositories, pull requests and Actions",gitlab:"Projects, merge requests and pipelines"};function Hye(){return Array.from(document.querySelectorAll('[data-rail-item="explore-integrations"], [data-rail-item="more"]')).find(e=>e.checkVisibility?e.checkVisibility():e.getClientRects().length>0)??null}function zye({integrations:e,onClose:t,onOpen:n,onConnect:s,onManage:a}){const o=gt(t,{restoreFocusFallback:Hye}),i=yt(t),l=PS().filter(f=>e.providers.some(p=>p.kind===f.kind)||Mp(e,f.kind).length>0),u=l.filter(f=>vj(e,f.kind)).length,h=f=>{t(),f()};return kt.createPortal(r.jsx("div",{className:"modal-backdrop",role:"presentation",...i,children:r.jsxs("div",{ref:o,className:"modal explore-integrations",role:"dialog","aria-modal":"true","aria-labelledby":"explore-integrations-title","aria-describedby":"explore-integrations-description",children:[r.jsxs("div",{className:"modal-head explore-head",children:[r.jsx("h2",{id:"explore-integrations-title",children:"Explore integrations"}),r.jsx("button",{type:"button",className:"glyph-btn","aria-label":"Close Explore integrations",title:"Close (Esc)",onClick:t,children:"×"})]}),r.jsxs("div",{className:"explore-body",children:[r.jsx("p",{id:"explore-integrations-description",className:"explore-intro",children:"Connect your project tools and keep the work behind each agent close by."}),e.error&&r.jsxs("p",{className:"explore-status",role:"alert",children:[e.error," Connection status may be out of date. Manage connections in Settings."]}),e.connections===null?r.jsx("p",{className:"explore-status",role:"status",children:e.error?"Connection status is unavailable.":"Reading integrations…"}):l.length===0?r.jsx("p",{className:"explore-status",role:"status",children:"No integrations are available on this deck."}):r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"explore-caption",children:[r.jsx("span",{children:"Available integrations"}),r.jsxs("span",{children:[u," connected"]})]}),r.jsx("ul",{className:"explore-providers",children:l.map(f=>{const p=sa(e,f.kind),m=vj(e,f.kind),w=Mp(e,f.kind)[0];return r.jsxs("li",{className:"explore-provider",children:[r.jsx("span",{className:"explore-glyph","aria-hidden":!0,children:r.jsx(f.Glyph,{})}),r.jsxs("div",{className:"explore-info",children:[r.jsx("h3",{children:f.label}),r.jsx("p",{children:Wye[f.kind]}),r.jsxs("span",{className:"explore-connection","data-connected":m||void 0,children:[p?m?"Connected":"Not connected":"Unavailable on this deck"," · Read only"]})]}),r.jsx("div",{className:"explore-actions",children:m?r.jsxs(r.Fragment,{children:[r.jsxs("button",{type:"button",className:"btn","aria-label":`Open ${f.label}`,onClick:()=>h(()=>n(f.kind)),children:["Open ",r.jsx(rd,{})]}),r.jsx("button",{type:"button",className:"btn explore-text-action","aria-label":`Manage ${f.label}`,onClick:()=>h(()=>a(w==null?void 0:w.id)),children:"Manage"})]}):p?r.jsx("button",{type:"button",className:"btn primary","aria-label":`Connect ${f.label}`,onClick:()=>h(()=>s(f.kind)),children:"Connect"}):w?r.jsx("button",{type:"button",className:"btn explore-text-action","aria-label":`Manage ${f.label}`,onClick:()=>h(()=>a(w.id)),children:"Manage"}):r.jsx("span",{className:"explore-unavailable",children:"Not available"})})]},f.kind)})})]})]}),r.jsxs("div",{className:"explore-footer",children:[r.jsx("span",{children:"Read only · Tokens stay on this machine"}),r.jsxs("button",{type:"button",className:"btn explore-text-action",onClick:()=>h(()=>a()),children:["Manage in Settings ",r.jsx(rd,{})]})]})]})}),document.body)}function Vye({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 l=i+1<e.length?n+s:0;if(a+l>t)break;o=i+1}return o}function _8(e){return e.tool?e.tool.name:e.kind==="asked"?"question":"permission"}const Gye=20;function Kye(e,t=Gye){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 Yye(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 Xye(e,t,n){const s=t.tool?`on ${t.tool.name}`:t.kind==="asked"?"for an answer":"for permission";return`${e}, waiting ${Yye(n)} ${s}; go to session`}function Zye(e){const t=Gl(e),n=NP(e,t);return n?`${t}
|
|
113
|
+
${n}`:t}const Jye=new Set(["idle","checking","current","downloading","ready","error"]);function CO(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.status!="string"||!Jye.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 Qye(e){return(e==null?void 0:e.status)==="ready"&&e.version?{version:e.version}:null}function E8(e=typeof navigator>"u"?"":navigator.userAgent){var t;return((t=/\bccdeck-desktop\/(\d[^\s]*)/.exec(e))==null?void 0:t[1])??null}const Ql="Restart to update",T8=3e4;function A8(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 ewe(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 ${Ql} comes first`}}function R8(e,t=!1){return{text:t?"Restarting…":Ql,label:t?void 0:`${Ql} 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 twe(e){const t=e==null?void 0:e.reason;return t==="app_disconnected"||t==="update_not_ready"?t:"refused"}function M8(e,t,n=typeof navigator>"u"?"":navigator.userAgent){const s=A8(n),a=`Use ${Ql} 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, ${Ql} is in ${s}.`;case"timeout":return`ccdeck has not restarted after ${T8/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 nwe="Update checks are off (AGENTS_DECK_NO_UPDATE_CHECK=1)",W0="click for what's new";function swe(e){if(e.checkDisabled)return`${nwe} · ${W0}`;if(e.checking)return`Asking npm for the newest release… · ${W0}`;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 · ${W0}, and to check npm now`}function rwe(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 awe(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 $8(e){return e?`${e.kind}:${e.to}`:""}function owe(e,t){return e!=null&&t!==$8(e)}function iwe({readyAppUpdate:e,notice:t,noticeOpen:n,version:s,chipVersion:a,versionChecking:o,now:i,openReleaseNotes:l,showNotice:u,loadVersion:h,restartToUpdate:f,updateRestarting:p=!1}){return r.jsx(r.Fragment,{children:e?(()=>{const m=ewe(E8()??a,e.version),w=f&&R8(e.version,p);return r.jsxs(r.Fragment,{children:[r.jsxs("button",{type:"button",className:"v ready",onClick:l,"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:()=>{l(),u()},"aria-haspopup":"dialog","aria-label":awe({...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?tp(i-s.checkedAt):null,checkFailedAgo:s!=null&&s.checkFailedAt&&s.checkFailedAt>(s.checkedAt??0)?tp(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:()=>{l(),h(!0)},"aria-busy":o||void 0,"aria-haspopup":"dialog","aria-label":rwe(m),title:swe(m),children:["v",m.running]})})()})}function lwe({live:e,paused:t,pauseGate:n}){const s=Tn();return r.jsx("span",{className:"status",children:(()=>{const a=qY({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 cwe(e,t){return`${e.label} — ${_8(e.waiting)} · ${Qu(e.waiting.since,void 0,t)}`}function L8(e,t){const n=e.slice(0,6).map(s=>cwe(s,t));return e.length>6&&n.push(`and ${e.length-6} more`),n.join(`
|
|
114
|
+
`)}function uwe({waitingSessions:e,waitingCursorRef:t,focusSession:n,now:s,named:a}){const o=Tn(),i=ac("below"),l=e.slice(a),u=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":`${u} session${u===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:l.length>0?L8(l,s):void 0}),children:[r.jsx("span",{className:"ap-pulse","aria-hidden":!0}),r.jsx("b",{children:u})," waiting"]}),i.node]})}function _O({w:e,now:t}){return r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"we-name",children:Kye(e.label)}),r.jsx("span",{className:"we-wait",children:Qu(e.waiting.since,void 0,t)}),r.jsxs("span",{className:"we-what",children:["· ",_8(e.waiting)]})]})}const dwe=12,hwe=2e3,fwe=4;function pwe({waitingSessions:e,waitingCursorRef:t,focusSession:n,now:s,onFit:a,onMore:o}){const i=Tn(),l=ac("below"),u=g.useRef(null),h=g.useRef(null),[f,p]=g.useState(0),m=e.map(b=>b.id).join(`
|
|
115
|
+
`);g.useLayoutEffect(()=>{const b=u.current,N=h.current;if(!b||!N)return;const x=()=>{const C=Array.from(N.children),_=C.pop();p(Vye({widths:C.map(M=>M.getBoundingClientRect().width),room:b.clientWidth-dwe,gap:fwe,more:(_==null?void 0:_.getBoundingClientRect().width)??0}))};if(x(),typeof ResizeObserver>"u")return;const S=new ResizeObserver(x);return S.observe(b),S.observe(N),()=>S.disconnect()},[m]);const w=e.slice(0,f),v=e.slice(f);g.useEffect(()=>{a(w.length)},[w.length,a]);const j=b=>{t.current=b,n(b)};return r.jsxs("div",{className:"wait-names",ref:u,children:[r.jsxs("ul",{className:"wait-list",children:[w.map(b=>r.jsx("li",{"data-fresh":s-b.waiting.since<hwe||void 0,children:r.jsx("button",{type:"button",className:"wait-entry",onClick:()=>j(b.id),"aria-label":Xye(b.label,b.waiting,s-b.waiting.since),...l.bind({label:b.label,detail:Zye(b.waiting)}),children:r.jsx(_O,{w:b,now:s})})},b.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,...l.bind({label:"Open the session list",keys:i?"L":void 0,detail:L8(v,s)}),children:["+",v.length," more"]})})]}),e.length>0&&r.jsxs("span",{className:"wait-ruler",ref:h,"aria-hidden":!0,children:[e.map(b=>r.jsx("span",{className:"wait-entry",children:r.jsx(_O,{w:b,now:s})},b.id)),r.jsxs("span",{className:"wait-more",children:["+",e.length," more"]})]}),l.node]})}const bj={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 mwe(e){return e==="on"?`Notifications on. ${bj.on}.`:e==="blocked"?`${bj.blocked}.`:""}function gwe({notifySaid:e}){return r.jsx("span",{className:e==="on"?"notify-said":"notify-said notify-said-blocked","aria-hidden":!0,title:bj[e],children:e==="on"?"notifications on":"notifications blocked"})}function ywe({versionCheck:e,welcome:t,desktopUpdate:n,pause:s,announcements:a,notify:o,waitingSessions:i,waitingCursorRef:l,focusSession:u,live:h,now:f,incidents:p,queueNamed:m}){const{version:w,notice:v,noticeOpen:j,showNotice:b,versionChecking:N,loadVersion:x}=e,{chipVersion:S,openReleaseNotes:C}=t,{readyAppUpdate:_,desktopUpdateRestarting:M,desktopUpdateFailure:R,askDesktopUpdateRestart:P}=n,L=g.useRef(!1);g.useEffect(()=>{M||!L.current||(L.current=!1,R&&C())},[M,R,C]);const U=K=>{L.current=!0,P(K)},{paused:B,pauseGate:A}=s,{blockedSaid:q,watchSaid:T,incidentSaid:F}=a,{notifySaid:O}=o;return r.jsxs("div",{className:"readout",children:[r.jsxs("div",{className:"brand",children:[r.jsx("img",{className:"logo logo-on-dark",src:Hne,width:19,height:16,alt:""}),r.jsx("img",{className:"logo logo-on-light",src:zne,width:19,height:16,alt:""}),r.jsx("h1",{children:Pt}),r.jsx(iwe,{readyAppUpdate:_,notice:v,noticeOpen:j,version:w,chipVersion:S,versionChecking:N,now:f,openReleaseNotes:C,showNotice:b,loadVersion:x,restartToUpdate:U,updateRestarting:M})]}),r.jsx(lwe,{live:h,paused:B,pauseGate:A}),r.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:q}),r.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:T}),r.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:F}),r.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:mwe(O)}),r.jsx(tse,{incidents:p}),i.length>0&&r.jsx(uwe,{waitingSessions:i,waitingCursorRef:l,focusSession:u,now:f,named:m}),O&&r.jsx(gwe,{notifySaid:O})]})}function wwe({selected:e,now:t,selectedIds:n,focusAgent:s,clearSelection:a}){const o=Tn(),i=qn(e),l=Math.max(0,((e.endedAt??t)-e.startedAt)/1e3),u=e.state==="active"&&!e.synthetic?iN(i.total,l):null,h=n.size-1;return r.jsxs("button",{type:"button",className:"selected-ribbon",title:`${Cn(`Zoom to ${e.label} and its session`,"Z",o)}${i.total>0?`
|
|
116
|
+
${ct(i.total)} spent${u?` · ${u}`:""}`:""}`,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:[ct(i.total),u?r.jsxs("span",{className:"selected-rate",children:[" · ",u]}):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 xwe({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"} ${Tp[o]} tools`,children:[r.jsx(Lge,{cat:o}),r.jsx("span",{className:"cat-name",children:Tp[o]})]},o)})})}const vwe=["a[href]","button:not(:disabled)","input:not(:disabled)","select:not(:disabled)","textarea:not(:disabled)","summary","[tabindex]"].join(",");function bwe(e){var n,s;const t=e.target;!(t!=null&&t.closest)||t.closest(vwe)!==e.currentTarget||(e.preventDefault(),(s=(n=document.activeElement)==null?void 0:n.blur)==null||s.call(n))}function kwe({trashZoneRef:e,trashState:t,trashPhase:n,trashLabel:s}){const a=Tn();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"?`${Cn("The session list","L",a)} brings it back`:"The session keeps running"})]})]})}function jwe({canvasRef:e,bubbling:t,dragging:n,trash:s,zoom:a,viewport:o,stateRef:i,peek:l,children:u}){const{trashDragging:h,trashState:f,trashPhase:p,trashZoneRef:m,trashLabel:w}=s,{lod:v,lodRef:j}=a,{markCanvasInput:b}=o,{peekAgent:N,peekLabel:x,peekRecap:S,peekBounds:C}=l;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:bwe,onPointerDownCapture:b,onPointerUpCapture:b,onWheelCapture:b,onFocusCapture:_=>{const M=_.target;if(!MS(M)||j.current==null||j.current==="detail")return;const R=M.getAttribute("data-id");R&&i.current.agents.has(R)&&M.matches(":focus-visible")&&JF(R,M,"focus")},onBlurCapture:_=>{var R,P;const M=(P=(R=_.target).getAttribute)==null?void 0:P.call(R,"data-id");M&&io(M)},children:[u,Za(p)&&r.jsx(kwe,{trashZoneRef:m,trashState:f,trashPhase:p,trashLabel:w}),r.jsx(ame,{agentFor:N,recapFor:S,labelFor:x,bounds:C})]})}function Nwe({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 ${Pt}…`:(()=>{const a=FY({connected:n,paused:s});return r.jsxs(r.Fragment,{children:[`Lost connection to the ${Pt} server. Reconnecting…`,a&&r.jsx("span",{className:"conn-sub",children:a})]})})()]})}function Swe({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 ",Pt," 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 I8="Thanks — that helps.",Cwe=Array.from({length:11},(e,t)=>t);function _we(e){return e===0?"0 out of 10, not useful":e===10?"10 out of 10, extremely useful":`${e} out of 10`}const Ewe=6;function Twe(e){const t=g.useRef(null);return g.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 Awe(){var e;(e=document.getElementById("canvas"))==null||e.focus()}function Rwe({phase:e,score:t,onAnswer:n,onLater:s,onClose:a,onFeedback:o,onHold:i}){const l=Twe(e),u=g.useRef(null),h=g.useRef(null),f=g.useRef(!1);g.useEffect(()=>{var m,w;e!=="thanks"||!f.current||(f.current=!1,Un(((m=document.activeElement)==null?void 0:m.tagName)??null)&&((w=u.current??h.current)==null||w.focus()))},[e]);const p=m=>{var w;(w=l.current)!=null&&w.contains(document.activeElement)&&Awe(),m()};return e==="thanks"?r.jsxs("div",{ref:l,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:I8}),t!==null&&t<=Ewe?r.jsx("button",{ref:u,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:l,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:Cwe.map(m=>r.jsx("button",{type:"button",className:"rating-pick","aria-label":_we(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 Mwe=3e4;function $we({bundle:e,running:t,lastTried:n}){return!t||e===t?!1:n!==t}function Lwe({bundle:e,running:t,pending:n,lastTried:s}){return t?$we({bundle:e,running:t,lastTried:s})?"reload":n==null||n&&n!==t?"wait":"confirm":"wait"}function Iwe(e){return!e||e.state!=="failed"?null:`${typeof e.at=="number"?e.at:0}:${e.error??""}`}function Owe({asked:e,reported:t}){return t?t!==e:!1}function O8(e){const t=e.thresholdMs??Mwe;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 Pwe(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 Dwe(e,t){return e?t==null?"auto when idle":`auto in ${Pwe(t)}`:"auto-restart off"}function EO(e){let t=0;for(const n of e)n.state==="active"&&t++;return t}function Fwe(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 Bwe(e){const t=O8(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 kj={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 qwe({notice:e,version:t,dismissNotice:n,upgradeState:s,startUpgrade:a,copyCommand:o,cmdCopied:i,autoRestart:l,toggleAutoRestart:u,askRestart:h,restartCopy:f,restartFuseMs:p,restarting:m}){var w,v,j;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(),...Fn(m),title:`Stop this process and bring it back on the same port. The canvas replays from the event log.
|
|
117
|
+
|
|
118
|
+
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":l,onClick:u,"aria-label":"Auto-restart when idle",title:l?"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:Dwe(l,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:[Pt," 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,...Fn(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}),...Fn(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",": ",((j=t==null?void 0:t.upgrade)==null?void 0:j.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:":kj.npx}):t!=null&&t.upgradeBlocked?r.jsx("span",{className:"ver-sub",children:Zt(kj,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 Uwe({restart:e,versionCheck:t,upgrade:n,oldNameNotice:s,rating:a,onFeedback:o,everConnected:i,live:l,paused:u}){const{autoRestart:h,toggleAutoRestart:f,restarting:p,restartMode:m,restartedTo:w,askRestart:v,restartCopy:j,restartFuseMs:b}=e,{version:N,notice:x,noticeOpen:S,dismissNotice:C}=t,{upgradeState:_,startUpgrade:M,copyCommand:R,cmdCopied:P}=n,{oldName:L,oldNameOpen:U,dismissOldName:B}=s,{ratingPhase:A,ratingScore:q,answerRating:T,rateLater:F,closeRating:O,holdThanks:K}=a,V=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&&!l?r.jsx(Nwe,{restarting:p,restartMode:m,live:l,paused:u}):S&&x?r.jsx(qwe,{notice:x,version:N,dismissNotice:C,upgradeState:_,startUpgrade:M,copyCommand:R,cmdCopied:P,autoRestart:h,toggleAutoRestart:f,askRestart:v,restartCopy:j,restartFuseMs:b,restarting:p}):U&&L?r.jsx(Swe,{oldName:L,version:N,dismissOldName:B}):A!=="hidden"?r.jsx(Rwe,{phase:A,score:q,onAnswer:T,onLater:F,onClose:O,onFeedback:o,onHold:K}):null;return r.jsxs(r.Fragment,{children:[V,r.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:A==="thanks"?I8:""})]})}function Wwe(e,t){return e==="confirmation"?t.confirmOpen?"clear":"ignore":t.modalOpen||t.confirmOpen?"ignore":"confirm"}function Hwe(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 zwe(e){return e<=0?null:e===1?"the one agent":`all ${e} agents`}function Vwe(e,t){const n=zwe(e),s=(...i)=>[n?`${n} on the canvas`:null,...i,"layout, pins and selection"].filter(l=>l!==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`,l=t.decks>2?`, one of ${t.decks} decks sharing it`:"";return{goes:s(),stays:[`the event log — ${i}${l}`,"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 Gwe({agentCount:e,onConfirm:t,onCancel:n}){const s=g.useRef(null),a=gt(n,{focusRef:s,layer:qG}),o=yt(n),[i,l]=g.useState(null);g.useEffect(()=>{let m=!1;return fetch("/api/clear").then(w=>w.ok?w.json():null).then(w=>{m||l(Hwe(w))}).catch(()=>{}),()=>{m=!0}},[]);const{goes:u,stays:h,final:f,confirm:p}=Vwe(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:u.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 Kwe({kind:e,onChange:t}){return r.jsxs("fieldset",{className:"fb-kinds",children:[r.jsx("legend",{className:"vis-hidden",children:"Kind of feedback"}),Ap.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=>{OS(s.nativeEvent)&&s.preventDefault()}}),n.label]},n.value))]})}const P8="fb-details";function Ywe({open:e,onToggle:t}){return r.jsxs("button",{type:"button",className:"fb-tool fb-more","aria-expanded":e,"aria-controls":P8,onClick:t,children:[tye,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 Xwe({open:e,contact:t,onContact:n}){const s=g.useId();return r.jsx("div",{id:P8,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:[nye,r.jsx("span",{className:"fb-optional",children:"optional"})]}),r.jsx("input",{id:"fb-contact",className:"ap-manage-input",type:"text",value:t,maxLength:w8,autoComplete:"email",placeholder:sye,"aria-describedby":s,onChange:a=>n(a.target.value),onKeyDown:a=>{OS(a.nativeEvent)&&a.preventDefault()}}),r.jsx("p",{id:s,className:"fb-hint",children:rye})]}),r.jsx("div",{className:"fb-where",children:aye.map(a=>r.jsx("p",{children:a},a))})]})})})}const ni=3,Zwe=5*1024*1024,Jwe=12*1024*1024,jj=8192,Qwe=64*1024,exe=256*1024,txe=.92,nxe=640,D8=.9,sxe=.85,rxe=6,axe=512*1024,Ip={png:"image/png",jpeg:"image/jpeg"},oxe={png:"png",jpeg:"jpg"},ixe=[137,80,78,71,13,10,26,10],lxe=[255,216,255];function F8(e){const t=n=>e.length>=n.length&&n.every((s,a)=>e[a]===s);return t(ixe)?"png":t(lxe)?"jpeg":null}function cxe(e){const t=F8(e);return t==="png"?uxe(e):t==="jpeg"?hxe(e):null}function uxe(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 dxe(e){return e>=192&&e<=207&&e!==196&&e!==200&&e!==204}function hxe(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(dxe(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 TO(e,t){return e.bytes>t||e.width>jj||e.height>jj}function fxe(e){return Math.min(Zwe,Jwe-Qwe-e)}function B8(e,t){return{width:Math.max(1,Math.floor(e.width*t)),height:Math.max(1,Math.floor(e.height*t))}}function pxe(e,t){const n=jj/Math.max(e.width,e.height),s=e.bytes>t?Math.sqrt(t/e.bytes)*D8:1;return B8(e,Math.min(1,n,s))}async function mxe(e,t,n){let s=pxe(e,t),a=e.format;for(let o=0;o<rxe;o++){const i=await n(s,a,a==="jpeg"?txe:void 0);if(!i)return null;if(i.size<=t)return{...s,blob:i,format:a};if(a==="png"){a="jpeg";continue}if(s=B8(s,Math.min(sxe,Math.sqrt(t/i.size)*D8)),Math.max(s.width,s.height)<nxe)return null}return null}async function gxe(e,t,n){const s=new Uint8Array(await e.slice(0,axe).arrayBuffer()),a=F8(s);if(!a)return{ok:!1,problem:"type"};if(t<exe)return{ok:!1,problem:"no_room"};const o=e.type===Ip[a]?e:new Blob([e],{type:Ip[a]}),i=cxe(s);if(i&&!TO({...i,bytes:e.size},t))return{ok:!0,blob:o,resized:null};const l=await n(e).catch(()=>null);if(!l)return{ok:!1,problem:"unreadable"};try{const u={width:l.width,height:l.height,bytes:e.size,format:a};if(!TO(u,t))return{ok:!0,blob:o,resized:null};const h=await mxe(u,t,l.encoder);return h?{ok:!0,blob:h.blob,resized:{width:h.width,height:h.height}}:{ok:!1,problem:"too_large"}}finally{l.release()}}function yxe(e){return({width:t,height:n},s,a)=>new Promise(o=>{const i=document.createElement("canvas");i.width=t,i.height=n;const l=i.getContext("2d");if(!l)return o(null);s==="jpeg"&&(l.fillStyle="white",l.fillRect(0,0,t,n)),l.imageSmoothingQuality="high",l.drawImage(e,0,0,t,n),i.toBlob(u=>{i.width=0,i.height=0,o(u)},Ip[s],a)})}const wxe=async e=>{const t=await createImageBitmap(e);return{width:t.width,height:t.height,encoder:yxe(t),release:()=>t.close()}};function xxe(e){return e.includes("Files")}function vxe({files:e,hasText:t,intoTextField:n}){return e>0&&(!t||!n)}function bxe(e,t){const n=e.indexOf(t);return e[n+1]??e[n-1]??null}function kxe(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===Ip.jpeg?"jpeg":"png";n.append("images",s,`image-${a+1}.${oxe[o]}`)}),{method:"POST",body:n}}const jxe="Add screenshot",AO="PNG or JPEG, up to three. You can also paste one, or drop it on this dialog.",Nxe="A screenshot can show emails, costs and paths. Crop out what should not be seen.",RO="Three images at most. Remove one to add another.",Sxe="An image could not be attached, so nothing was sent. Check the images and send again; your text is still here.";function Cxe(e,t,n){const s=n?`, resized to ${n.width} × ${n.height} to fit`:"";return`Replace image ${e+1}: ${t}${s}`}function _xe(e,t){const n=`${e} of ${ni}`;return t>0?`${n} · ${t} resized to fit`:n}function Exe(e){return`Three images at most, so ${e===1?"one was":`${e} were`} left out.`}function Txe(e){return`“${e.length>40?`${e.slice(0,30)}…${e.slice(-9)}`:e}”`}function Axe(e,t){const n=Txe(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 q8="image/png,image/jpeg";function U8({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 Rxe({images:e,buttonRef:t}){const n=g.useRef(null),s=e.shots.length>=ni;return r.jsxs(r.Fragment,{children:[r.jsxs("button",{ref:t,type:"button",className:"fb-tool",title:AO,"aria-describedby":"fb-attach-hint",onClick:()=>{var a;return s?e.sayFull():(a=n.current)==null?void 0:a.click()},children:[r.jsx(U8,{}),jxe]}),r.jsx("span",{id:"fb-attach-hint",hidden:!0,children:AO}),r.jsx("input",{ref:n,type:"file",accept:q8,multiple:!0,hidden:!0,onChange:a=>{e.add(Array.from(a.target.files??[])),a.target.value=""}})]})}function Mxe({images:e,addRef:t}){const n=g.useRef(new Map),s=g.useRef(null),a=g.useRef(null),o=g.useRef(null),[i,l]=g.useState(null),{shots:u}=e,h=_xe(u.length,u.filter(m=>m.resized).length);g.useLayoutEffect(()=>{var m;i!==null&&((m=i==="add"?t.current:n.current.get(i))==null||m.focus(),l(null))},[i,t]),g.useEffect(()=>{var m;e.problem&&((m=s.current)==null||m.scrollIntoView({block:"nearest"}))},[e.problem,e.problemId]);function f(m){l(bxe(u.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:q8,hidden:!0,onChange:m=>{const w=o.current;w!==null&&e.replace(w,Array.from(m.target.files??[])),o.current=null,m.target.value=""}}),u.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:u.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":Cxe(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:Nxe})]}),e.problem&&r.jsx("p",{ref:s,className:"fb-error",role:"alert",children:e.problem},e.problemId)]})}function $xe(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 Lxe(e,t,n){return n?e.map(s=>s.id===t.id?t:s):[...e,t]}function Ixe(e,t,n){return n?e.map(s=>s.id===t?n:s):e.filter(s=>s.id!==t)}function Oxe(e){const[t,n]=g.useState(()=>$xe((e==null?void 0:e.ready)??[],1)),[s,a]=g.useState({problem:"",id:0}),o=g.useRef(0),i=g.useCallback(A=>{A&&o.current++,a(q=>A?{problem:A,id:q.id+1}:q.problem?{problem:"",id:q.id}:q)},[]),[l,u]=g.useState(""),h=g.useRef(t),f=g.useRef(null),p=g.useRef(t.length),m=g.useRef(!0),w=g.useRef(new Map),v=g.useRef([]),j=g.useRef(0),b=g.useCallback(A=>{h.current=A(h.current),n(h.current)},[]);g.useEffect(()=>(m.current=!0,()=>{m.current=!1;for(const A of h.current)URL.revokeObjectURL(A.url)}),[]);const N=g.useCallback(async(A,q)=>{const T=h.current.reduce((Z,z)=>{var X;return Z+(z.id===(q==null?void 0:q.id)?0:((X=z.blob)==null?void 0:X.size)??0)},0),F=(q==null?void 0:q.id)??++p.current,O=URL.createObjectURL(A),K={id:F,name:A.name||"image",url:O,blob:null,resized:null},V=j.current;w.current.set(F,A);let H=!1;const D=()=>{H||(H=!0,b(Z=>Lxe(Z,K,q!==void 0)))},I=await gxe(A,fxe(T),async Z=>(D(),wxe(Z))).catch(()=>({ok:!1,problem:"unreadable"})),W=h.current.some(Z=>Z.id===F);return!m.current||j.current!==V||!W&&(H||q)?(URL.revokeObjectURL(O),q&&URL.revokeObjectURL(q.url),m.current&&w.current.delete(F),""):(w.current.delete(F),I.ok?(D(),q&&URL.revokeObjectURL(q.url),b(Z=>Z.map(z=>z.id===F?{...z,blob:I.blob,resized:I.resized}:z)),""):(URL.revokeObjectURL(O),H&&b(Z=>Ixe(Z,F,q)),Axe(I.problem,A.name||"image")))},[b]),x=g.useCallback(async A=>{i("");const q=j.current,T=[];let F=0,O=0;for(const V of A){if(!m.current||j.current!==q)return;const H=v.current.indexOf(V);if(H!==-1&&v.current.splice(H,1),h.current.length>=ni){F++;continue}const D=h.current.length,I=await N(V);I&&T.push(I),h.current.length>D&&O++}if(!m.current||j.current!==q)return;F>0&&T.push(O===0&&T.length===0?RO:Exe(F)),i(T.join(" "));const K=h.current.length;O>0&&u(`${O===1?"Image":`${O} images`} added, ${K} of ${ni}.`)},[N,i]),S=g.useCallback(async(A,q)=>{i("");const T=h.current.find(K=>K.id===A);if(!T)return x([q]);const F=await N(q,T);if(!m.current)return;i(F);const O=h.current.findIndex(K=>K.id===A);!F&&O!==-1&&u(`Image ${O+1} replaced, ${h.current.length} of ${ni}.`)},[x,N,i]),C=g.useCallback(A=>{const q=j.current;f.current=(f.current??Promise.resolve()).then(()=>j.current===q?A():void 0).catch(()=>{})},[]),_=g.useCallback(A=>{A.length!==0&&(v.current.push(...A),C(()=>x(A)))},[x,C]);g.useEffect(()=>{e&&e.waiting.length>0&&_(e.waiting)},[]);const M=g.useCallback((A,q)=>{const T=q[0];T&&C(()=>S(A,T))},[C,S]),R=g.useCallback(A=>{const q=h.current.find(T=>T.id===A);q&&(URL.revokeObjectURL(q.url),w.current.delete(A),b(T=>T.filter(F=>F.id!==A)),i(""),u(`Image removed, ${h.current.length} of ${ni}.`))},[b,i]),P=g.useCallback(()=>i(RO),[i]),L=g.useCallback(async()=>{const A=o.current;return await f.current,o.current!==A?null:h.current.flatMap(q=>q.blob?[q.blob]:[])},[]),U=g.useCallback(()=>({ready:h.current.flatMap(A=>A.blob&&!w.current.has(A.id)?[{name:A.name,blob:A.blob,resized:A.resized}]:[]),waiting:[...w.current.values(),...v.current]}),[]),B=g.useCallback(()=>{j.current++;for(const A of h.current)URL.revokeObjectURL(A.url);w.current.clear(),v.current=[],b(()=>[]),i("")},[b,i]);return{shots:t,problem:s.problem,problemId:s.id,announcement:l,add:_,replace:M,remove:R,sayFull:P,ready:L,kept:U,clear:B}}function Pxe(){const[e,t]=g.useState(null);return g.useEffect(()=>{let n=!0;return fetch("/api/feedback").then(s=>s.ok?s.json():null).then(s=>{n&&t(Yge(s))}).catch(()=>{}),()=>{n=!1}},[]),e}function Dxe(e){const[t,n]=g.useState({state:"idle"}),s=g.useRef(!1),a=g.useRef(null);g.useEffect(()=>()=>{var l;return(l=a.current)==null?void 0:l.abort()},[]);async function o(l){if(!Sn(s.current))return;s.current=!0;const{signal:u}=a.current=new AbortController;n({state:"sending"});try{const h=await e.ready();if(u.aborted)return;if(!h){n({state:"failed",message:Sxe});return}const f=await fetch("/api/feedback",{...kxe(Kge(l),h),signal:u}),p=await f.json().catch(()=>null);n(f.ok&&(p!=null&&p.ok)?{state:"sent"}:{state:"failed",message:xO(f.status,p==null?void 0:p.reason,p==null?void 0:p.errors)})}catch{u.aborted||n({state:"failed",message:xO(0,null)})}finally{s.current=!1}}const i=()=>n(l=>l.state==="failed"?{state:"idle"}:l);return{outcome:t,sending:t.state==="sending",send:o,clearFailure:i}}function Fxe(e,t){const[n,s]=g.useState(!1),a=g.useRef(t);return a.current=t,g.useEffect(()=>{if(!e)return;const o=window.setTimeout(()=>s(!0),vO),i=window.setTimeout(()=>a.current(),vO+uye);return()=>{window.clearTimeout(o),window.clearTimeout(i)}},[e]),n}const H0="agent-dag.feedbackDrafts",MO=4;function Bxe({initialKind:e,initialBody:t}){return{kind:e??"bug",body:t??""}}function qxe(e){return JSON.stringify([e.kind,e.body])}function Uxe(e){return e.ready.length+e.waiting.length}function W8(e,t){return e.body.trim()!==t.body.trim()||e.contact.trim()!==""||e.images>0}function Wxe(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 Hxe="Discard",zxe="Confirm discard",Vxe="Clear the message, the screenshots and the contact",$O="Press again to clear this draft. It cannot be brought back.",Gxe={ready:[],waiting:[]};function Kxe(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!Ap.some(i=>i.value===n)||typeof s!="string"||s.length>y8||typeof a!="string"||a.length>w8||typeof o!="number"||!Number.isInteger(o)||o<0||o>ni?null:[e[0],{kind:n,body:s,contact:a,images:o}]}function Yxe(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(H0),l=i?JSON.parse(i):[];if(Array.isArray(l))for(const u of l.slice(-MO)){const h=Kxe(u);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(([l,u])=>[l,{kind:u.kind,body:u.body,contact:u.contact,images:u.imageCount}]);i.length===0?o.removeItem(H0):o.setItem(H0,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??Gxe,imagesLost:i.images?0:i.imageCount}:null},keep(o,i,l){const u=Uxe(i.images);if(!W8({body:i.body,contact:i.contact,images:u},l)){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:u});for(const f of h.keys()){if(h.size<=MO)break;h.delete(f)}s()},forget:a}}function Xxe(){try{return typeof window>"u"?null:window.sessionStorage}catch{return null}}const Nj=Yxe(Xxe),Zxe=4e3;function Jxe(e,t,n,s,a){const o=g.useRef(null);o.current={key:e,seed:t,words:n,images:s,sent:a};const i=g.useCallback(()=>{const l=o.current;!l||l.sent||Nj.keep(l.key,{...l.words,images:l.images.kept()},l.seed)},[]);g.useEffect(i,[i,n.kind,n.body,n.contact,s.shots]),g.useEffect(()=>i,[i]),g.useEffect(()=>{a&&Nj.forget(e)},[a,e])}const LO="draft";function Qxe(e){const[t,n]=g.useState(!1),s=g.useRef(0);g.useEffect(()=>{if(!t)return;const o=window.setTimeout(()=>n(!1),Zxe);return()=>window.clearTimeout(o)},[t]);function a(){const o=Date.now(),i=yi({armedFor:t?LO:null,target:LO,armedAt:s.current,now:o,gapMs:gi});if(i==="arm"){n(!0),s.current=o;return}i!=="ignore"&&(n(!1),e())}return{armed:t,press:a}}function H8({onClose:e,initialKind:t,initialBody:n}){const s=g.useRef(null),a=g.useRef(null),o=g.useRef(null),i=g.useRef(null),l=g.useRef(null),u=g.useRef(null),h=g.useRef(null),f=g.useRef(null),p=g.useRef(0),m=gt(e,{focusRef:s}),w=yt(e),v=Bxe({initialKind:t,initialBody:n}),j=qxe(v),[b]=g.useState(()=>Nj.read(j)),[N,x]=g.useState((b==null?void 0:b.kind)??v.kind),[S,C]=g.useState((b==null?void 0:b.body)??v.body),[_,M]=g.useState((b==null?void 0:b.contact)??""),[R,P]=g.useState((b==null?void 0:b.imagesLost)??0),[L,U]=g.useState(!1),[B,A]=g.useState(!1),[q,T]=g.useState(!1),F=Oxe(b==null?void 0:b.images),O=Jge(Pxe()),{outcome:K,sending:V,send:H,clearFailure:D}=Dxe(F),I=K.state==="sent",W=Fxe(I,e);Jxe(j,v,{kind:N,body:S,contact:_},F,I);const Z=W8({body:S,contact:_,images:F.shots.length},v),z=Qxe(()=>{var xe;x(v.kind),C(v.body),M(""),P(0),A(!1),F.clear(),D(),(xe=s.current)==null||xe.focus()}),X=g8(N),Y=B&&!yO(S),J=R>0&&F.shots.length===0,Q=[Y&&"fb-body-error",J&&"fb-images-lost"].filter(Boolean).join(" ")||void 0,[te,le]=iye(ro());g.useEffect(()=>{var De,We;const xe=i.current;if(!xe)return;const Ie=xe.contains(document.activeElement)||Un(((De=document.activeElement)==null?void 0:De.tagName)??null);xe.inert=I,I&&Ie&&((We=a.current)==null||We.focus())},[I]),g.useEffect(()=>{var Ke,ye;const xe=l.current;if(!xe)return;const Ie=h.current;if(V){const Fe=document.activeElement,$e=Fe!=null&&(xe.contains(Fe)||Fe===Ie);f.current=$e?Fe:null,xe.inert=!0,Ie&&(Ie.inert=!0),f.current&&((Ke=u.current)==null||Ke.focus());return}xe.inert=!1,Ie&&(Ie.inert=!1);const De=f.current;f.current=null;const We=document.activeElement===u.current||Un(((ye=document.activeElement)==null?void 0:ye.tagName)??null);!I&&De&&We&&De.focus()},[V,I]);function de(xe){var Ie;if(xe.preventDefault(),!yO(S)){A(!0),(Ie=s.current)==null||Ie.focus();return}H({kind:N,body:S,contact:_})}const oe=!I&&!V,re=xe=>xxe(Array.from(xe.dataTransfer.types));function he(xe){!re(xe)||!oe||(xe.preventDefault(),p.current++,T(!0))}function pe(xe){re(xe)&&(xe.preventDefault(),xe.dataTransfer.dropEffect=oe?"copy":"none")}function Le(xe){re(xe)&&(p.current=Math.max(0,p.current-1),p.current===0&&T(!1))}function ge(xe){re(xe)&&(xe.preventDefault(),p.current=0,T(!1),oe&&F.add(Array.from(xe.dataTransfer.files)))}function ve(xe){xe.target!==xe.currentTarget||!re(xe)||(xe.preventDefault(),xe.dataTransfer.dropEffect="none")}function je(xe){re(xe)&&xe.preventDefault()}function Ee(xe){if(!oe)return;const Ie=Array.from(xe.clipboardData.files),De=xe.target,We=De instanceof HTMLTextAreaElement||De instanceof HTMLInputElement,Ke=Array.from(xe.clipboardData.types).includes("text/plain");vxe({files:Ie.length,hasText:Ke,intoTextField:We})&&(xe.preventDefault(),F.add(Ie))}return r.jsx("div",{className:"modal-backdrop",...w,role:"presentation",onDragOver:ve,onDrop:je,"data-leaving":W||void 0,children:r.jsxs("div",{ref:m,className:"modal feedback-dialog",onClick:xe=>xe.stopPropagation(),onDragEnter:he,onDragOver:pe,onDragLeave:Le,onDrop:ge,onPaste:Ee,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:z.armed?$O:cye(K.state)}),r.jsxs("div",{className:"fb-stage",children:[r.jsxs("form",{ref:i,className:"fb-form",onSubmit:de,onKeyDown:xe=>{oye(xe.nativeEvent)&&(xe.preventDefault(),xe.currentTarget.requestSubmit())},noValidate:!0,children:[r.jsxs("section",{ref:l,className:"modal-body fb-body",children:[r.jsx(Kwe,{kind:N,onChange:x}),r.jsxs("div",{className:"fb-compose",children:[r.jsx("label",{className:"fb-label",htmlFor:"fb-body",children:X.question}),r.jsx("textarea",{ref:s,id:"fb-body",className:"ap-manage-input fb-message",value:S,maxLength:y8,rows:5,placeholder:X.placeholder,onChange:xe=>C(xe.target.value),"aria-invalid":Y||void 0,"aria-describedby":Q,required:!0}),Y&&r.jsx("p",{id:"fb-body-error",className:"fb-error",children:Hge}),r.jsx(Mxe,{images:F,addRef:o}),J&&r.jsx("p",{id:"fb-images-lost",className:"fb-hint",children:Wxe(R)}),r.jsxs("div",{className:"fb-tools",children:[r.jsx(Rxe,{images:F,buttonRef:o}),r.jsx(Ywe,{open:L,onToggle:()=>U(xe=>!xe)})]}),r.jsx(Xwe,{open:L,contact:_,onContact:M})]}),r.jsx("p",{className:"fb-facts",children:O?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"fb-facts-value",children:O})," — ",Qge]}):eye}),K.state==="failed"&&r.jsx("p",{className:"fb-error",role:"alert",children:K.message})]}),r.jsxs("div",{className:"fb-foot",children:[Z&&r.jsx("button",{ref:h,type:"button",className:`btn danger fb-discard${z.armed?" armed":""}`,onKeyDown:xe=>{xe.repeat&&xe.preventDefault()},onClick:z.press,title:z.armed?$O:Vxe,children:z.armed?zxe:Hxe}),r.jsxs("span",{className:"fb-shortcut","aria-hidden":"true",children:[r.jsx("kbd",{"data-symbol":lye(te)||void 0,children:te}),r.jsx("kbd",{children:le})," to send"]}),r.jsx("button",{type:"button",className:"btn",onClick:e,children:"Cancel"}),r.jsx("button",{ref:u,type:"submit",className:"btn primary fb-send","aria-keyshortcuts":"Meta+Enter Control+Enter",...Fn(V),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…"})]})})]})]}),I&&r.jsxs("div",{className:"fb-done",children:[r.jsx(kp,{}),r.jsx("p",{className:"fb-done-line",children:x8})]})]}),r.jsx("div",{className:"fb-drop","aria-hidden":"true","data-active":q||void 0,children:r.jsxs("div",{className:"fb-drop-frame",children:[r.jsx(U8,{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 z8="Press Esc first if a key does nothing.",z0=[{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:"Ctrl + K",macCap:"⌘ K",action:"search panels, sessions, settings, actions and themes",binds:["k","K"],chord:!0},{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:"next 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:[]}]}],eve=/ \([A-Z?]\)/g;function V8(e,t=()=>!0){const n=s=>s.integration===void 0||t(s.integration);return e&&z0.every(s=>s.rows.every(n))?z0:z0.map(s=>({...s,rows:s.rows.filter(n).filter(a=>e||a.chord||!a.binds.some(eD)).map(a=>e?a:{...a,action:a.action.replace(eve,"")})})).filter(s=>s.rows.length>0)}const tve="Single-key shortcuts are off.",G8="Settings › Keyboard",nve=`Single-key shortcuts can be turned off in ${G8}.`;function sve({onClose:e,onTour:t,onSettings:n}){const s=gt(e),a=yt(e),o=po(ro()),i=Tn(),l=Rd(),u=V8(i,h=>sa(l,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:tve})," Turn them back on in"," ",r.jsx("span",{className:"kh-place",children:G8}),". 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:u.map(h=>r.jsxs(g.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:[z8," ",nve]})]})]})})}function rve(e,t){return`${e}#${t}`}function ave(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 l=rve(i.key,i.since);if(s.has(l)||woe(i.key,o.email,t,n))continue;const u=o.email??"";a.push({id:l,key:i.key,since:i.since,num:o.num,email:u,name:u||o.alias||`Account ${o.num}`,alias:u&&o.alias?o.alias:null})}return a}function ove(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 K8({rows:e,ours:t,dialogs:n}){return e===0?!1:t||n===0}function ive(e){return e===1?"Account needs your attention":"Accounts need your attention"}function lve(e){return`${e===1?"One Claude account needs":`${e} Claude accounts need`} you to sign in again.`}const cve="Login expired",uve="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.",dve="The account stays marked in the Accounts panel. This will not ask again until it has worked and stopped again.";function hve(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 fve({request:e,waiting:t,busy:n,now:s,onAccept:a,onDecline:o,onLater:i}){const l=g.useRef(null),u=gt(i,{focusRef:l}),h=yt(i),f=so(n,"accept"),p=so(n,"dismiss");return r.jsx("div",{className:"modal-backdrop",...h,role:"presentation",children:r.jsxs("div",{ref:u,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 ",rS(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:l,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 pve(e){const t=g.useRef(!1),n=mve(e),s=K8({rows:n?1:0,ours:t.current,dialogs:cn.dialogDepth()});return t.current=s,s?n:null}function mve({lanPending:e,lanDeferred:t,lanBusy:n,answerLanPair:s,deferLanPair:a}){const{request:o,waiting:i}=hve(e,t.current);return o?r.jsx(fve,{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 gve({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:uve})]}):r.jsxs(r.Fragment,{children:[r.jsx("p",{id:"reauth-lead",className:"reauth-lead",children:lve(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:cve}),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:dve,onClick:n,children:"Not now"}),a&&r.jsx("button",{type:"button",className:"btn primary",ref:s,onClick:()=>t(a),children:"Sign in again"})]})]})}function yve({rows:e,onSignIn:t,onLater:n}){const s=g.useRef(null),a=gt(n,{focusRef:s}),o=yt(n);return r.jsx("div",{className:"modal-backdrop",...o,role:"presentation",children:r.jsxs("div",{ref:a,className:"modal reauth-ask",onClick:i=>i.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"reauth-title","aria-describedby":"reauth-lead",children:[r.jsxs("header",{className:"modal-head",children:[r.jsx("div",{className:"modal-title",children:r.jsx("span",{id:"reauth-title",className:"modal-tool-name",children:ive(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(gve,{rows:e,onSignIn:t,onLater:n,firstRef:s})]})})}function wve({rows:e,signingIn:t,signIn:n,signedIn:s,refresh:a,closeSignIn:o,later:i,pairing:l=!1}){const u=g.useRef(!1),h=cn.dialogDepth()+(l?1:0),f=t!=null||K8({rows:e.length,ours:u.current,dialogs:h});return u.current=f,t?r.jsx(h6,{email:t.email||null,onClose:o,onChanged:a,onSignedIn:s}):f?r.jsx(yve,{rows:e,onSignIn:n,onLater:i},e.length===1?"one":"many"):null}const xve={"//":["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.47.0":[{title:"⌨️ Quick open: Cmd/Ctrl+K reaches any panel, setting, session or theme by name",body:"Type a few letters to open a panel, land on a setting inside Settings, jump to a session or switch the theme. It is also Search on the bar."},{title:"⚙️ Settings › Claude Code changes Claude Code's own settings from the deck",body:"Twelve settings in five groups, from auto memory and compaction to the Co-Authored-By credit and the update channel, written to your settings.json on this computer."},{title:"📡 Radar monitors all the time, and packet capture is one explained step",body:"There is no Start or Stop any more: Radar finds Claude Code's collector by itself. Where capture needs a permission, Allow packet capture once asks for it on your press only."},{title:"⏱️ Tool activity shows where the time went, and Skill activity who starts your skills",body:"Tool activity splits the turns' time between Claude, this machine and you. Skill activity shows how many skill uses Claude, Codex or you started, overall and per skill."},{title:"📊 Usage remembers how full each quota week ended, and names your Claude plan",body:"Under each 7-day bar a line says how full the last weeks were at their reset. The Claude quota card shows your plan beside its title, as the Codex card does."},{title:"🗂️ Stripes, dialogs and floating panels are organized more evenly",body:"The doors on both edge stripes sit in named groups, dialogs share one frame, and T switches the theme inside any dialog too."},{title:"🪟 The desktop app works on a first run without Node, and integrations got fixes",body:"Usage no longer needs npm, and Claude Code installed while the app is open is picked up. Jira and GitLab avatars load, and panels reopen where you left them."}],"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.
|
|
119
|
+
|
|
120
|
+
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.
|
|
121
|
+
|
|
122
|
+
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.
|
|
123
|
+
|
|
124
|
+
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.
|
|
125
|
+
|
|
126
|
+
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.
|
|
127
|
+
|
|
128
|
+
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.
|
|
129
|
+
|
|
130
|
+
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".
|
|
131
|
+
|
|
132
|
+
**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.
|
|
133
|
+
|
|
134
|
+
\`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.
|
|
135
|
+
|
|
136
|
+
**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.
|
|
137
|
+
|
|
138
|
+
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.
|
|
139
|
+
|
|
140
|
+
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.
|
|
141
|
+
|
|
142
|
+
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.
|
|
143
|
+
|
|
144
|
+
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.
|
|
145
|
+
|
|
146
|
+
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.
|
|
147
|
+
|
|
148
|
+
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.
|
|
149
|
+
|
|
150
|
+
What you are reading is the first version that does not.
|
|
151
|
+
|
|
152
|
+
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.
|
|
153
|
+
|
|
154
|
+
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.
|
|
155
|
+
|
|
156
|
+
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.
|
|
157
|
+
|
|
158
|
+
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.
|
|
159
|
+
|
|
160
|
+
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.
|
|
161
|
+
|
|
162
|
+
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.
|
|
163
|
+
|
|
164
|
+
The count of what is behind it is on the heading's tooltip, so collapsing it does not hide how much there is.
|
|
165
|
+
|
|
166
|
+
**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.
|
|
167
|
+
|
|
168
|
+
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.
|
|
169
|
+
|
|
170
|
+
\`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.
|
|
171
|
+
|
|
172
|
+
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.
|
|
173
|
+
|
|
174
|
+
**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.
|
|
175
|
+
|
|
176
|
+
**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.
|
|
177
|
+
|
|
178
|
+
**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.
|
|
179
|
+
|
|
180
|
+
**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.
|
|
181
|
+
|
|
182
|
+
**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.
|
|
183
|
+
|
|
184
|
+
**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.
|
|
185
|
+
|
|
186
|
+
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.
|
|
187
|
+
|
|
188
|
+
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.
|
|
189
|
+
|
|
190
|
+
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.
|
|
191
|
+
|
|
192
|
+
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.
|
|
193
|
+
|
|
194
|
+
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.
|
|
195
|
+
|
|
196
|
+
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.
|
|
197
|
+
|
|
198
|
+
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.
|
|
199
|
+
|
|
200
|
+
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.
|
|
201
|
+
|
|
202
|
+
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.
|
|
203
|
+
|
|
204
|
+
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.
|
|
205
|
+
|
|
206
|
+
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.
|
|
207
|
+
|
|
208
|
+
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.
|
|
209
|
+
|
|
210
|
+
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.
|
|
211
|
+
|
|
212
|
+
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.
|
|
213
|
+
|
|
214
|
+
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.
|
|
215
|
+
|
|
216
|
+
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.
|
|
217
|
+
|
|
218
|
+
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.
|
|
219
|
+
|
|
220
|
+
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.
|
|
221
|
+
|
|
222
|
+
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.
|
|
223
|
+
|
|
224
|
+
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.
|
|
225
|
+
|
|
226
|
+
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.
|
|
227
|
+
|
|
228
|
+
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.
|
|
229
|
+
|
|
230
|
+
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.
|
|
231
|
+
|
|
232
|
+
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.
|
|
233
|
+
|
|
234
|
+
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.
|
|
235
|
+
|
|
236
|
+
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.
|
|
237
|
+
|
|
238
|
+
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.
|
|
239
|
+
|
|
240
|
+
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.
|
|
241
|
+
|
|
242
|
+
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.
|
|
243
|
+
|
|
244
|
+
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.
|
|
245
|
+
|
|
246
|
+
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.
|
|
247
|
+
|
|
248
|
+
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.
|
|
249
|
+
|
|
250
|
+
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.
|
|
251
|
+
|
|
252
|
+
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.
|
|
253
|
+
|
|
254
|
+
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.
|
|
255
|
+
|
|
256
|
+
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.
|
|
257
|
+
|
|
258
|
+
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.
|
|
259
|
+
|
|
260
|
+
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.
|
|
261
|
+
|
|
262
|
+
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.
|
|
263
|
+
|
|
264
|
+
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".
|
|
265
|
+
|
|
266
|
+
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.
|
|
267
|
+
|
|
268
|
+
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.
|
|
269
|
+
|
|
270
|
+
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.
|
|
271
|
+
|
|
272
|
+
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.
|
|
273
|
+
|
|
274
|
+
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.
|
|
275
|
+
|
|
276
|
+
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.
|
|
277
|
+
|
|
278
|
+
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.
|
|
279
|
+
|
|
280
|
+
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.
|
|
281
|
+
|
|
282
|
+
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.
|
|
283
|
+
|
|
284
|
+
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.
|
|
285
|
+
|
|
286
|
+
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.
|
|
287
|
+
|
|
288
|
+
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.
|
|
289
|
+
|
|
290
|
+
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.
|
|
291
|
+
|
|
292
|
+
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.
|
|
293
|
+
|
|
294
|
+
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.
|
|
295
|
+
|
|
296
|
+
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.
|
|
297
|
+
|
|
298
|
+
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.
|
|
299
|
+
|
|
300
|
+
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.
|
|
301
|
+
|
|
302
|
+
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.
|
|
303
|
+
|
|
304
|
+
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.
|
|
305
|
+
|
|
306
|
+
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.
|
|
307
|
+
|
|
308
|
+
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.
|
|
309
|
+
|
|
310
|
+
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.
|
|
311
|
+
|
|
312
|
+
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.
|
|
313
|
+
|
|
314
|
+
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.`}]},BS="agent-dag.releaseNotesSeen";function IO(e){return e.split(/[.\-+]/).map(t=>parseInt(t,10)).map(t=>Number.isNaN(t)?0:t)}function vi(e,t){const n=IO(e),s=IO(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 lo(e){return typeof e=="string"&&/^\d+\.\d+\.\d+/.test(e)}function vve(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 bve(e){if(!e||typeof e!="object")return[];const t=[];for(const[n,s]of Object.entries(e)){if(!lo(n)||!Array.isArray(s))continue;const a=s.filter(vve);a.length&&t.push({version:n,notes:a})}return t.sort((n,s)=>vi(s.version,n.version))}const OO=bve(xve);function Y8(e,t,n){return e.filter(s=>vi(s.version,n)<=0&&(t===null||vi(s.version,t)>0))}function kve(e,t){return e.filter(n=>vi(n.version,t)===0)}function jve(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 Nve({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&&lo(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(!lo(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=vi(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 Sve=new RegExp("^(?:\\p{Extended_Pictographic}|\\p{Emoji_Modifier}|\\p{Regional_Indicator}|[\\u200D\\uFE0F])+(?= \\S)","u");function Cve(e){const t=Sve.exec(e);return t?{icon:t[0],rest:e.slice(t[0].length)}:{icon:null,rest:e}}function _ve(e){if(!e)return null;let t=null;try{t=e.getItem(BS)}catch{return null}return lo(t)?t:null}function Eve(e){if(!e)return!1;try{return e.getItem(BS),!0}catch{return!1}}function Tve(e,t){if(!e)return!1;try{return e.setItem(BS,t),!0}catch{return!1}}const X8="agent-dag.tourSeen";function Ave(e){if(!e)return!1;try{return e.getItem(X8)==="1"}catch{return!1}}function Rve(e){if(!e)return!1;try{return e.setItem(X8,"1"),!0}catch{return!1}}function Mve({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 $ve({stored:e,running:t,notes:n,remembers:s=!0}){if(!lo(t))return{show:[],record:null,reason:"no-version"};if(!lo(e)){if(!s)return{show:[],record:t,reason:"cannot-remember"};const i=kve(n,t);return i.length?{show:i,record:t,reason:"welcome"}:{show:[],record:t,reason:"first-run"}}const a=vi(e,t);if(a===0)return{show:[],record:null,reason:"seen"};if(a>0)return{show:[],record:null,reason:"ahead"};const o=Y8(n,e,t);return o.length?{show:o,record:t,reason:"new-notes"}:{show:[],record:t,reason:"nothing-new"}}function Lve(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 Z8(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=Lve(e,o);if(i>0){a(),n.push({kind:"bold",kids:Z8(e.slice(o+2,i),!1)}),o=i+2;continue}}s+=e[o],o+=1}return a(),n}function co(e=typeof navigator>"u"?"":navigator.userAgent){return/\bccdeck-desktop\/\d/.test(e)}function dje(e,t,n){if(e===null)return null;const s=e+t-n;return s>0?s:null}function hje(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 Ive(e){return(e??[]).filter(t=>t.installed&&t.profiles>0)}function fje(e){return!Number.isFinite(e)||e<=0?"empty":ea(e)}function pje(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 Ove(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 mje(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=Ive(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 Pve="Check for updates",J8="Ask npm now whether a newer ccdeck is out.",PO="Checking…",Dve="Couldn't reach npm. Try again.",Fve="Couldn't reach the deck. Try again.",Q8="Update checks are off on this deck (AGENTS_DECK_NO_UPDATE_CHECK or AGENTS_DECK_NO_INSTALL).",Bve="The deck looks again in five minutes.";function qve(e,t,n,s){const a=s?t.npx:n?Zt(t,n):void 0;return a?`${e} is out, but ${a}`:`${e} is out. Run:`}const On=(e,t={})=>({said:e,tone:"answer",age:null,command:null,action:null,...t}),Xo=e=>On(e,{tone:"note"});function DO(e,t){return Ove(e,t)??"just now"}function Uve(e,t){const n=e.update;return(n==null?void 0:n.status)==="ready"?Xo(`${n.version} is ready. Restart to update.`):(n==null?void 0:n.status)==="checking"?Xo("The app is checking for updates…"):(n==null?void 0:n.status)==="downloading"?Xo(n.version?`${n.version} is out. The app is downloading it.`:"The app is downloading an update."):(n==null?void 0:n.status)==="current"?Xo(`You're on the latest, ${e.version??t}. You can check again here.`):(n==null?void 0:n.status)==="error"?Xo("The app's last update check failed. Try Check for updates again."):Xo("The app keeps itself up to date. Check for updates here.")}function Wve(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 On(`${t} is installed.`);const l=e.upgradeState==="running",u=`Runs ${((i=s.upgrade)==null?void 0:i.command)??s.command} here, then restarts once nothing is running.`;return On(l?`Installing ${t}…`:`${t} is out.`,{action:{kind:"install",label:"Update now",busy:l,why:u}})}if((s==null?void 0:s.upgradeMode)==="npx"&&s.canRestart){const l=e.upgradeState==="failed";return On(l?`The last update to ${t} came back on ${e.running}.`:`${t} is out.`,{action:{kind:"npx",label:l?"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:`:qve(t,n,s==null?void 0:s.upgradeBlocked,(s==null?void 0:s.upgradeMode)==="npx"),o=(s==null?void 0:s.command)??null;return On(a,{command:o,action:o?{kind:"copy",label:e.copied?"Copied":"Copy",busy:!1}:null})}function Hve(e){const t=e.version;if(e.unreachable)return On(Fve,{tone:"warn"});const n=t!=null&&t.checkFailedAt&&t.checkFailedAt>(t.checkedAt??0)?t.checkFailedAt:null;if(n)return On(Dve,{tone:"warn",age:e.answered?null:`Last tried ${DO(n,e.now)}.`});const s=t!=null&&t.latestPending&&t.latestPending!==e.running?t.latestPending:null;if(s)return On(`${s} is tagged on npm but can't be installed yet. ${Bve}`);const a=t!=null&&t.checkedAt?DO(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 On(o,{age:a?`Checked ${a}.`:null})}return On("",{age:a?`Last checked ${a}.`:null})}function zve(e,t){var a,o;const n=e.version;if((a=e.app)!=null&&a.inApp&&(n!=null&&n.checkDisabled)){const i=Uve(e.app,e.running);return i&&{canCheck:!0,checking:e.checking||((o=e.app.update)==null?void 0:o.status)==="checking",line:e.unreachable?On("The desktop updater did not accept the check. Try the ccdeck menu or update the desktop app.",{tone:"warn"}):e.checking?On(PO):i}}if(n!=null&&n.checkDisabled)return{canCheck:!1,checking:!1,line:Xo(Q8)};const s=(n==null?void 0:n.notice)??null;if((s==null?void 0:s.kind)==="upgrade")return{canCheck:!0,checking:e.checking,line:Wve(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:On(i)}}return e.checking?{canCheck:!0,checking:!0,line:On(PO)}:{canCheck:!0,checking:!1,line:Hve(e)}}const eB=450;async function Vve(e,t=n=>new Promise(s=>setTimeout(s,n))){const[n]=await Promise.all([e(!0),t(eB)]);return n?"answered":"unreachable"}async function Gve(e=fetch){try{const[t]=await Promise.all([e("/api/desktop-update/check",{method:"POST",signal:AbortSignal.timeout(8e3)}),new Promise(n=>setTimeout(n,eB))]);return t.ok?"answered":"unreachable"}catch{return"unreachable"}}const Sj="Eight pictures of what the deck shows.",FO="Restart the deck. Sessions, settings and pairings come back as they were.";function Kve(e){var M;const t=(e==null?void 0:e.versionCheck.versionChecking)??!1,n=Nr(3e4),[s,a]=g.useState(!1),o=g.useRef(!1),[i,l]=g.useState(!1),[u,h]=g.useState(!1),f=g.useRef(t);if(g.useEffect(()=>{f.current&&!t&&h(!0),f.current=t},[t]),!e)return null;const{versionCheck:p,upgrade:m,restart:w,desktopUpdate:v,running:j,onHandOff:b}=e,N=zve({version:p.version,running:j,checking:s||t,answered:u,unreachable:i,now:n,upgradeState:m.upgradeState,copied:m.cmdCopied,restarting:w.restarting,app:{inApp:co(),update:v.appUpdate,version:E8(),menu:A8()}},kj);if(!N)return null;const x=co()&&((M=p.version)==null?void 0:M.checkDisabled);return{state:N,check:async()=>{var P;if(!Sn(o.current||t)||x&&((P=v.appUpdate)==null?void 0:P.status)==="checking")return;o.current=!0,a(!0);const R=x?await Gve():await Vve(p.loadVersion);o.current=!1,a(!1),l(R==="unreachable"),h(!0)},act:R=>{if(R.kind==="copy")return void m.copyCommand();b(),p.showNotice(),R.kind==="install"?m.startUpgrade():w.askRestart({upgrade:!0})},checkWhy:x?"Ask the desktop app whether a newer ccdeck is out.":J8}}function Yve({onTour:e,onRestart:t,updateCheck:n}){var h,f;const s=ac("above","dialog"),a=Kve(n),o=g.useId(),i=(a==null?void 0:a.state.canCheck)??!1,u=((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&&!u&&!a?null:r.jsxs("div",{className:"rn-actions",children:[(e||i||u)&&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:Sj}),children:[r.jsx($D,{}),"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(kQ,{}),Pve]}),u&&r.jsxs("button",{type:"button",className:"btn rn-act rn-act-restart",onClick:u,"aria-describedby":`${o}-restart`,...s.bind({label:FO}),children:[r.jsx(jQ,{}),"Restart"]})]}),a&&r.jsx(Xve,{line:a.state.line,onAct:a.act,bindHint:s.bind,whyId:`${o}-act`}),r.jsx("span",{hidden:!0,id:`${o}-tour`,children:Sj}),r.jsx("span",{hidden:!0,id:`${o}-check`,children:(a==null?void 0:a.checkWhy)??J8}),r.jsx("span",{hidden:!0,id:`${o}-restart`,children:FO}),s.node]})}function Xve({line:e,onAct:t,bindHint:n,whyId:s}){const{action:a}=e,o=a&&r.jsx(Zve,{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 Zve({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 Jve({entries:e,since:t,running:n,firstRun:s,onClose:a,onTour:o,updateVersion:i,updateBusy:l,onUpdateRestart:u,updateFailure:h,onRestart:f,updateCheck:p}){const m=gt(a),w=yt(a),v=jve(e);return r.jsx("div",{className:"modal-backdrop",...w,role:"presentation",children:r.jsxs("div",{ref:m,className:"modal release-notes",onClick:j=>j.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&&u&&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:u,"aria-busy":l||void 0,children:l?"Restarting…":Ql})]}),r.jsx("p",{className:"rn-update-said",role:"status",children:h})]}),r.jsx("p",{className:"modal-note",children:Nve({since:t,running:n,firstRun:s,entries:e})}),r.jsx(Yve,{onTour:i?void 0:o,onRestart:f,updateCheck:p}),e.map(j=>r.jsxs("section",{className:"modal-section",children:[r.jsxs("h3",{className:"rn-version",children:["v",j.version]}),r.jsx("ul",{className:"rn-notes",children:j.notes.map((b,N)=>{const{icon:x,rest:S}=Cve(b.title);return r.jsxs("li",{className:"rn-note",children:[r.jsxs("p",{className:"rn-note-title",children:[x&&r.jsx("span",{className:"rn-note-icon",children:x}),S]}),r.jsx("p",{className:"rn-note-body",children:tB(Z8(b.body))})]},N)})})]},j.version))]})]})})}function tB(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:tB(t.kids)},n))}function Qve({state:e,sessionId:t,onClose:n}){const s=g.useMemo(()=>ebe(e,t),[e,e.revision,t]),a=g.useRef(null),o=gt(n,{focusRef:a}),i=yt(n);return s?r.jsx("div",{className:"modal-backdrop",...i,role:"presentation",children:r.jsxs("div",{ref:o,className:"modal session-summary",onClick:l=>l.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:_D}),r.jsx("div",{className:"ss-cost",children:ct(s.cost.total)}),s.modelChips.length>0&&r.jsx("div",{className:"ss-models",children:s.modelChips.map(l=>r.jsx("span",{className:"model-chip","data-family":Yp(l),title:l,children:no(l)},l))})]}),r.jsx("div",{className:"ss-hero-right",children:s.cost.total>0&&r.jsxs(r.Fragment,{children:[r.jsx(WN,{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:ct(s.cost.input)})]}),r.jsxs("span",{className:"ssl ssl-out",children:["output ",r.jsx("b",{children:ct(s.cost.output)})]}),r.jsxs("span",{className:"ssl ssl-cr",children:["cache r ",r.jsx("b",{children:ct(s.cost.cacheRead)})]}),r.jsxs("span",{className:"ssl ssl-cw",children:["cache w ",r.jsx("b",{children:ct(s.cost.cacheWrite)})]})]})]})})]}),r.jsxs("section",{className:"ss-stats",children:[r.jsx(yl,{label:"agents",value:s.agentCount}),r.jsx(yl,{label:"subagents",value:s.subagentCount}),r.jsx(yl,{label:"tool calls",value:s.toolCount}),r.jsx(yl,{label:"prompts",value:s.promptCount}),r.jsx(yl,{label:"tokens",value:s.tokensSum.toLocaleString()}),s.errCount>0&&r.jsx(yl,{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(([l,u])=>r.jsxs("div",{className:"ss-tt",children:[r.jsx("span",{className:"ss-tt-name",children:l}),r.jsx("span",{className:"ss-tt-bar",children:r.jsx("span",{className:"ss-tt-bar-fill",style:{width:`${u/s.topTools[0][1]*100}%`}})}),r.jsx("span",{className:"ss-tt-count",children:u})]},l))})]}),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 yl({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 ebe(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 l=0,u=0,h=0,f=0,p=0,m,w=1/0,v=0;for(const S of s){const C=qn(S);a.input+=C.input,a.output+=C.output,a.cacheRead+=C.cacheRead,a.cacheWrite+=C.cacheWrite,a.total+=C.total;for(const M of wP(S))o.add(M);S.model&&o.add(S.model),S.kind==="subagent"&&p++;const _=J4(S.prompts);u+=_.length,!m&&_.length>0&&(m=_[0].text),h+=S.usage.inputTokens+S.usage.outputTokens,l+=S.toolCount,f+=S.toolErrorCount??0;for(const[M,R]of S.toolCountByName??[])i.set(M,(i.get(M)??0)+R);w=Math.min(w,S.startedAt),v=Math.max(v,S.endedAt??Date.now())}const j=Math.max(0,v-w),b=Math.floor(j/1e3),N=b<60?`${b}s`:b<3600?`${Math.floor(b/60)}m ${String(b%60).padStart(2,"0")}s`:`${Math.floor(b/3600)}h ${Math.floor(b%3600/60)}m`,x=Array.from(i.entries()).sort((S,C)=>C[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:l,promptCount:u,tokensSum:h,errCount:f,topTools:x,firstPrompt:m}}function Bt({id:e,title:t,note:n,noteId:s,aside:a,list:o=!0,settingId:i,className:l,children:u}){const h=l?`settings-group ${l}`:"settings-group",f=o?r.jsx("div",{className:"settings-list",children:u}):u;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 mt({name:e,nameId:t,note:n,noteId:s,control:a,as:o="label",settingId:i,className:l,details:u,children:h}){const f=o,p=r.jsxs(f,{className:l?`settings-row ${l}`:"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}),h]});return u?r.jsxs("div",{className:"settings-row-with-details",children:[p,r.jsxs("details",{className:"settings-row-details",children:[r.jsxs("summary",{children:["Details",r.jsxs("span",{className:"vis-hidden",children:[" about ",e]})]}),r.jsx("div",{children:u})]})]}):p}function nB(e,t){const[n,s]=g.useState(null),[a,o]=g.useState(!1),[i,l]=g.useState(""),u=g.useRef(!1),h=p=>typeof p=="boolean"?p:t;return g.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&&l("Could not read this setting. Reopen Settings to retry.")}),()=>{p=!1}},[e]),{enabled:n,busy:a,error:i,change:async()=>{if(!(n===null||!Sn(u.current))){u.current=!0,o(!0),l("");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{l("Could not save this setting. Try again.")}finally{u.current=!1,o(!1)}}}}}function BO({provider:e}){const t=e==="Codex"?"recoverCodexSessions":"recoverClaudeSessions",n=`${e.toLowerCase()}-session-recovery`,s=nB(t,!0);return r.jsxs(Bt,{id:`${n}-title`,title:`${e} sessions`,children:[r.jsx(mt,{settingId:n,name:"Restore unfinished sessions",note:e==="Codex"?"Restore recent unfinished turns on startup; their processes may have stopped.":"Restore verified busy sessions on the next start.",details: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,...Fn(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(tbe,{})]})}function tbe(){const e=nB("continueStopped",!1);return r.jsxs(r.Fragment,{children:[r.jsx(mt,{settingId:"claude-continue-stopped",name:"Continue stopped background sessions",note:"Resume once a working login with room becomes available.",details:"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,...Fn(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 nbe="Hide finished sessions after",sbe="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 rbe(){const e=c8();return r.jsx(Bt,{id:"settings-board-caption",title:"Board",children:r.jsx(mt,{settingId:"hide-finished",name:nbe,nameId:"settings-hide-finished-label",note:"Hidden sessions stay available in the session list.",details:sbe,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=>tge(Number(t.target.value)),children:a8.map(t=>r.jsx("option",{value:t,children:ege(t)},t))})})})}const abe="Accounts and auto-switch",obe="Your Claude accounts, and Auto-switch, which moves Claude Code to another one before the account in use runs out.",ibe="Local network",lbe="Pairing with the decks on your other machines, so a login that expires on one is repaired from another.",cbe="Browser Watch",ube="Whether something drove your browser while you were away, and what the deck does about it.";function dbe({claudeHere:e,singleKeys:t,doors:n}){return r.jsxs(Bt,{id:"settings-elsewhere-caption",title:"Elsewhere on the deck",children:[e&&r.jsx(V0,{settingId:"accounts",name:abe,note:obe,onOpen:n.accounts,cap:t?{key:"A",title:"Press A anywhere to show or hide the accounts panel"}:null}),e&&r.jsx(V0,{settingId:"local-network",name:ibe,note:lbe,onOpen:n.localNetwork,cap:null}),r.jsx(V0,{settingId:"browser-watch",name:cbe,note:ube,onOpen:n.browserWatch,dialog:!0,cap:t?{key:"B",title:"Press B anywhere to open or close Browser Watch"}:null})]})}function V0({settingId:e,name:t,note:n,onOpen:s,cap:a,dialog:o=!1}){const i=`settings-${e}`;return r.jsx(mt,{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 hbe="Single-key shortcuts",fbe="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 pbe(e){const t=e.binds.includes("?")?"the keyboard shortcuts sheet":e.action;return t.charAt(0).toUpperCase()+t.slice(1)}function mbe(e,t){const n=t.trim().toLowerCase();return n?[e.action,e.cap,e.macCap??""].some(s=>s.toLowerCase().includes(n)):!0}function gbe({singleKeys:e,onToggleSingleKeys:t}){const n=po(ro()),[s,a]=g.useState(""),o=g.useId(),i=Rd(),l=V8(e,u=>sa(i,u)).map(u=>({...u,rows:u.rows.filter(h=>mbe(h,s))})).filter(u=>u.rows.length>0);return r.jsxs(r.Fragment,{children:[r.jsx(Bt,{children:r.jsx(mt,{settingId:"single-keys",name:hbe,nameId:"settings-single-keys-label",note:fbe,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:u=>a(u.target.value),onKeyDown:u=>{dN(u.key)&&s&&(u.stopPropagation(),a(""))}})]}),l.map(u=>{const h=`settings-keys-${u.title.toLowerCase().replace(/[^a-z]+/g,"-")}`;return r.jsx(Bt,{id:h,title:u.title,className:"settings-keys",children:u.rows.map(f=>r.jsx(mt,{as:"div",name:pbe(f),control:r.jsx("kbd",{className:"settings-key",children:n&&f.macCap?f.macCap:f.cap})},`${f.cap}:${f.action}`))},u.title)}),l.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:z8})]})}function ybe({notifyOn:e,onToggleNotify:t,notifyVetoed:n,notifyPermission:s,onAskNotify:a,accountNotify:o,onToggleAccountNotify:i}){const l=See(s),u=co(),h=e&&!n&&!u,f=g.useRef(null),p=ta(!l.ask,f);return r.jsxs(r.Fragment,{children:[r.jsxs(Bt,{id:"sm-closed-caption",title:"While the deck is closed",children:[r.jsx(mt,{settingId:"notify-closed",name:"Notifications while closed",nameId:"sm-notify-label",note:n?kee:bee(u),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(mt,{as:"div",name:"Browser notifications",nameId:"sm-channel-name",note:l.note,control:l.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":l.ok||void 0,children:[l.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"})}),l.status]})})]}),r.jsx(Bt,{id:"sm-accounts-caption",title:"Accounts",note:n?Nee:jee,children:qD.map(({kind:m,label:w,title:v})=>r.jsx(mt,{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))})]})}const wbe=["audio/webm;codecs=opus","audio/ogg;codecs=opus","audio/mp4"];function xbe(e){return wbe.find(t=>e(t))}const vbe=4400;function bbe(e){const t=e.split(";")[0];return{name:`Recorded voice.${t==="audio/mp4"?"m4a":t==="audio/ogg"?"ogg":"webm"}`,type:t}}function kbe({full:e,setCustomError:t,runCustom:n,onImportCustom:s}){const[a,o]=g.useState(!1),i=g.useRef(null),l=g.useRef(null),u=g.useRef(!1),h=()=>{var p;l.current!==null&&clearTimeout(l.current),l.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{u.current||t("Microphone access was denied or unavailable.");return}if(u.current||i.current){p.getTracks().forEach(w=>w.stop());return}try{const w=xbe(b=>MediaRecorder.isTypeSupported(b)),v=new MediaRecorder(p,w?{mimeType:w}:void 0),j=[];i.current=v,v.ondataavailable=b=>{b.data.size&&j.push(b.data)},v.onerror=()=>t("Recording failed. Please try again."),v.onstop=()=>{p.getTracks().forEach(S=>S.stop()),l.current!==null&&clearTimeout(l.current),l.current=null;const b=i.current===v;if(b&&(i.current=null),o(!1),!b||!j.length)return;const N=bbe(v.mimeType),x=new File(j,N.name,{type:N.type});n(()=>s(x))},v.start(200),o(!0),l.current=setTimeout(h,vbe)}catch{i.current=null,p.getTracks().forEach(w=>w.stop()),t("This browser cannot record a supported audio format.")}};return g.useEffect(()=>(u.current=!1,()=>{u.current=!0,l.current!==null&&clearTimeout(l.current);const p=i.current;i.current=null,(p==null?void 0:p.state)==="recording"&&p.stop()}),[]),{recording:a,startRecording:f,stopRecording:h}}function jbe({full:e,fullProps:t,runCustom:n,onCreateVoice:s}){const[a,o]=g.useState("Custom voice"),[i,l]=g.useState("Your turn"),[u,h]=g.useState(""),[f,p]=g.useState("1"),[m,w]=g.useState("1"),[v,j]=g.useState([]);return g.useEffect(()=>{if(typeof window>"u"||!("speechSynthesis"in window))return;const b=()=>{j(window.speechSynthesis.getVoices())};return b(),window.speechSynthesis.addEventListener("voiceschanged",b),()=>window.speechSynthesis.removeEventListener("voiceschanged",b)},[]),r.jsxs("details",{className:"sm-voice",children:[r.jsxs("summary",{className:"settings-row",...t,onClick:b=>{const N=b.currentTarget.parentElement;e&&N&&!N.open&&b.preventDefault()},children:[r.jsx("span",{className:"settings-row-name",children:"Spoken voice"}),r.jsx("span",{className:"settings-row-note",children:"Create from text"}),r.jsx("span",{className:"settings-row-control",children:r.jsx("svg",{className:"sm-voice-chevron",width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:r.jsx("path",{d:"M5.5 3.5 9 7l-3.5 3.5"})})})]}),r.jsxs("div",{className:"sm-voice-fields",children:[r.jsxs("label",{children:[r.jsx("span",{children:"Name"}),r.jsx("input",{className:"ap-manage-input",value:a,maxLength:80,onChange:b=>o(b.target.value)})]}),r.jsxs("label",{children:[r.jsx("span",{children:"Text"}),r.jsx("input",{className:"ap-manage-input",value:i,maxLength:180,onChange:b=>l(b.target.value)})]}),r.jsxs("label",{children:[r.jsx("span",{children:"Voice"}),r.jsxs("select",{className:"sm-select",value:u,onChange:b=>h(b.target.value),children:[r.jsx("option",{value:"",children:"System default"}),v.map(b=>r.jsx("option",{value:b.voiceURI,children:b.name},b.voiceURI))]})]}),r.jsxs("div",{className:"sm-voice-pair",children:[r.jsxs("label",{children:[r.jsx("span",{children:"Rate"}),r.jsx("input",{className:"ap-manage-input",type:"number",min:"0.5",max:"2",step:"0.1",value:f,onChange:b=>p(b.target.value)})]}),r.jsxs("label",{children:[r.jsx("span",{children:"Pitch"}),r.jsx("input",{className:"ap-manage-input",type:"number",min:"0.5",max:"2",step:"0.1",value:m,onChange:b=>w(b.target.value)})]})]}),r.jsx("button",{type:"button",className:"btn sm-custom-action",...t,onClick:()=>{e||n(async()=>{await s({name:a,text:i,voiceURI:u,rate:parseFloat(f),pitch:parseFloat(m)}),l("Your turn")})},children:"Add spoken voice"})]})]})}function Nbe({customAssets:e,onImportCustom:t,onCreateVoice:n,onRenameCustom:s,onPreviewCustom:a,onDeleteCustom:o}){const[i,l]=g.useState(""),u=e.length,h=P1(u),f=h!==null,p=f?{"aria-disabled":!0,"aria-describedby":"sm-custom-full"}:{},[m,w]=g.useState(null),v=g.useRef(0),j=g.useRef(new Map),b=g.useRef(null),N=g.useRef(null);g.useEffect(()=>{if(!m)return;const R=window.setTimeout(()=>w(null),4e3);return()=>window.clearTimeout(R)},[m]);const x=async R=>{l("");try{await R()}catch(P){l(P instanceof Error?P.message:"Custom audio could not be saved.")}},S=(R,P)=>{const L=Date.now(),U=yi({armedFor:m,target:R,armedAt:v.current,now:L,gapMs:gi});if(U==="arm"){w(R),v.current=L;return}if(U==="ignore")return;w(null);const B=$ee(e.map(A=>A.id),R);x(async()=>{var q;await o(R);const A=document.activeElement;A!==P&&!Un((A==null?void 0:A.tagName)??null)||(q=B?j.current.get(B):b.current)==null||q.focus()})},{recording:C,startRecording:_,stopRecording:M}=kbe({full:f,setCustomError:l,runCustom:x,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:[u," of ",O1]}),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(mt,{as:"div",settingId:"custom-import",name:"Import audio",note:"WAV, MP3 or OGG",control:r.jsx("button",{ref:b,type:"button",className:"btn sm-custom-action",...p,onClick:()=>{var R;f||(R=N.current)==null||R.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:R=>{var L;const P=(L=R.target.files)==null?void 0:L[0];R.currentTarget.value="",P&&!f&&x(()=>t(P))}})}),r.jsx(mt,{as:"div",settingId:"custom-record",name:"Record a clip",note:C?"Recording…":"Up to 5 seconds",control:C?r.jsx("button",{type:"button",className:"btn sm-custom-action",onClick:M,children:"Stop & save"}):r.jsx("button",{type:"button",className:"btn sm-custom-action",...p,onClick:()=>void _(),children:"Record"})}),r.jsx(jbe,{full:f,fullProps:p,runCustom:x,onCreateVoice:n}),e.map(R=>r.jsxs("div",{className:"sm-custom-item",children:[r.jsx("input",{className:"ap-manage-input","aria-label":`Rename ${R.name}`,defaultValue:R.name,maxLength:80,onBlur:P=>{if(!P.target.value.trim()){P.target.value=R.name;return}x(()=>s(R.id,P.target.value))},onKeyDown:P=>{P.key==="Enter"&&P.currentTarget.blur()}}),r.jsx("span",{children:R.kind==="audio"?`${R.duration.toFixed(1)}s`:"Voice"}),r.jsx("button",{type:"button",className:"btn sm-custom-icon","aria-label":`Play ${R.name}`,onClick:()=>a(R.id),children:"Play"}),r.jsx("button",{type:"button",ref:P=>{P?j.current.set(R.id,P):j.current.delete(R.id)},className:`btn sm-custom-icon${m===R.id?" armed":""}`,onKeyDown:P=>{P.repeat&&P.preventDefault()},onClick:P=>S(R.id,P.currentTarget),"aria-label":m===R.id?`Confirm deleting ${R.name}`:`Delete ${R.name}`,title:m===R.id?"Press again to delete this sound. It cannot be brought back.":"Delete this sound",children:m===R.id?"Confirm":"Delete"})]},R.id)),i&&r.jsx("p",{className:"settings-row settings-row-status sm-custom-error",role:"alert",children:i})]})}const Sbe="A tone when a turn finishes, and when Claude asks for something.";function Cbe({soundOn:e,onToggleSound:t}){const n=g.useId(),s=Tn(),a=g.useId();return r.jsx(Bt,{children:r.jsx(mt,{settingId:"play-sounds",name:"Play sounds",nameId:n,note:Sbe,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 Cj="custom:";function qO(e){return`${Cj}${e}`}function _be(e){return e.startsWith(Cj)?e.slice(Cj.length):null}function Ebe({id:e,label:t="Volume",value:n,step:s=LN,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:Lf,max:hp,step:s,value:n,"aria-describedby":o,onChange:i=>a(Number(i.target.value)),style:{"--sm-level":`${(n-Lf)/(hp-Lf)*100}%`}}),r.jsxs("span",{className:"sm-read",children:[n,"%"]})]})}const UO={done:"Turn finished","needs-input":"Claude is asking"},Tbe={done:"Plays when Claude or Codex finishes a turn.","needs-input":"Available in Claude Code only."};function Abe({chime:e,tone:t,soundOn:n,customAssets:s,customSelections:a,onLevel:o,onFigure:i,onPreview:l,onBuiltInSelected:u,onCustomSelected:h}){const f=`sm-level-${e}`,p=`sm-figure-${e}`,m=a[e];return r.jsxs(Bt,{id:`sm-name-${e}`,title:UO[e],note:Tbe[e],settingId:`tone-${e}`,aside:r.jsxs("button",{type:"button",className:"btn sm-hear",onClick:()=>l(e),"aria-label":`Hear the ${UO[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(Ebe,{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?qO(m):t.figure,onChange:w=>{const v=w.target.value,j=_be(v);j!==null?h(e,j):(u(e),i(e,v))},children:[$N[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:qO(w.id),children:w.name},w.id))})]})]})]})}const Rbe="Claude Code isn't on this machine, so only Turn finished plays here — for Codex turns.";function Mbe({soundOn:e,onToggleSound:t,prefs:n,claudeHere:s,onLevel:a,onFigure:o,onPreview:i,customAssets:l,customSelections:u,onBuiltInSelected:h,onCustomSelected:f,onImportCustom:p,onCreateVoice:m,onRenameCustom:w,onPreviewCustom:v,onDeleteCustom:j}){var S;const b=Ree(u),N=((S=l.find(C=>C.id===b))==null?void 0:S.name)??"the same custom sound",x=b?`Both tones use “${N}”. They may be harder to tell apart.`:"";return r.jsxs("div",{className:"sm-sounds",children:[r.jsx(Cbe,{soundOn:e,onToggleSound:t}),!s&&r.jsx("p",{className:"sm-note",children:Rbe}),!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:Mu.map(C=>r.jsx(Abe,{chime:C,tone:n[C],soundOn:e,customAssets:l,customSelections:u,onLevel:a,onFigure:o,onPreview:i,onBuiltInSelected:h,onCustomSelected:f},C))}),x&&r.jsx("p",{className:"sm-note","aria-hidden":!0,children:x}),r.jsx("p",{className:"vis-hidden",role:"status",children:x}),r.jsx(Nbe,{customAssets:l,onImportCustom:p,onCreateVoice:m,onRenameCustom:w,onPreviewCustom:v,onDeleteCustom:j})]})}const $be="Watches the telemetry Claude Code sends to its collector, always and in the background, even while Radar is closed. What it reads stays on this machine.";function Lbe({onOpen:e}){return r.jsx(Bt,{children:r.jsx(mt,{as:"div",settingId:"radar-open",name:"Radar",nameId:"settings-radar-open-name",note:$be,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"})})})}const Ibe=6500,Obe=1e4;let ui={reading:null,saving:null,error:"",undone:null};const Bf=new Set;let pu=null,mu=null,ia=null,G0=!1,qf=0;const Jo=e=>{ui={...ui,...e},Bf.forEach(t=>t(ui))};function sB(e){const t=e;return!!t&&t.ok===!0&&Array.isArray(t.settings)&&typeof t.present=="object"}async function rB(e){const t=await fetch("/api/claude-settings",{signal:e}),n=await t.json();if(!t.ok||!sB(n))throw new Error;return n}async function _j(){if(G0||ui.saving)return;G0=!0;const e=qf,t=new AbortController;ia=t;let n=!1;const s=setTimeout(()=>{n=!0,t.abort()},5e3);try{const a=await rB(t.signal);e===qf&&!t.signal.aborted&&Jo({reading:a,error:""})}catch{e===qf&&(n||!t.signal.aborted)&&Jo({error:"Could not read Claude Code settings. Try again."})}finally{clearTimeout(s),G0=!1,ia===t&&(ia=null)}}function WO(e,t){var n;return(n=e==null?void 0:e.settings.find(s=>s.id===t))==null?void 0:n.value}async function HO(e,t){if(ui.saving)return;qf++,ia==null||ia.abort(),mu&&(clearTimeout(mu),mu=null),Jo({saving:e,error:"",undone:null});const n=new AbortController,s=setTimeout(()=>n.abort(),15e3);try{const a=await fetch("/api/claude-settings",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({id:e,value:t}),signal:n.signal}),o=await a.json().catch(()=>null);if(!a.ok||!sB(o))throw new Error(typeof(o==null?void 0:o.error)=="string"?o.error:"Could not save the change. Try again.");Jo({reading:o});const i=WO(o,e);mu=setTimeout(()=>{mu=null;const l=new AbortController,u=setTimeout(()=>l.abort(),5e3);rB(l.signal).then(h=>{Jo({reading:h,undone:WO(h,e)===i?null:{id:e}})}).catch(()=>{}).finally(()=>clearTimeout(u))},Ibe)}catch(a){Jo({error:a instanceof Error&&a.message?a.message:"Could not save the change. Try again."})}finally{clearTimeout(s),Jo({saving:null})}}function Pbe(){const[e,t]=g.useState(ui);return g.useEffect(()=>(Bf.add(t),t(ui),pu||(_j(),pu=setInterval(()=>void _j(),Obe)),()=>{Bf.delete(t),Bf.size||(pu&&clearInterval(pu),pu=null,ia==null||ia.abort())}),[]),e}const K0=40,Dbe={boolean:"on or off",choice:"a choice",number:"a number",text:"text",structured:"a list or object"};function Fbe(e){const t=e.scope==="Global config"?"kept in ~/.claude.json":e.scope==="Managed"?"managed settings only":null;return[e.topic,Dbe[e.kind],t,e.since?`Claude Code ${e.since}+`:null].filter(Boolean).join(" · ")}function Bbe(e,t){const n=t.trim().toLowerCase();if(!n)return[];const s=e.filter(o=>o.key.toLowerCase().includes(n)),a=e.filter(o=>!s.includes(o)&&(o.topic??"").toLowerCase().includes(n));return[...s,...a]}let aB=null;const qbe=()=>aB??(aB=bi(()=>import("./claude-settings-index-1Qg1AUda.js"),[]).then(e=>e.default.keys));function Ube({present:e,noFile:t=!1}){const[n,s]=g.useState(null),[a,o]=g.useState(""),i=g.useId();g.useEffect(()=>{let f=!0;return qbe().then(p=>{f&&s(p)},()=>{aB=null}),()=>{f=!1}},[]);const l=g.useMemo(()=>{if(!n)return[];if(a.trim())return Bbe(n,a);if(!e)return[];const f=n.filter(m=>Object.hasOwn(e,m.key)),p=Object.keys(e).filter(m=>!n.some(w=>w.key===m)).sort().map(m=>({key:m,topic:"Not in Claude Code's reference",scope:null,kind:"structured",default:null,since:null,anchor:""}));return[...f,...p]},[n,e,a]),u=l.slice(0,K0),h=a.trim()!=="";return r.jsxs(Bt,{id:"claude-group-all",settingId:"claude-all-settings",title:"All Claude Code settings",note:h?void 0:e&&!t?"The keys your settings.json sets. Filter to look up any of them, and open the reference for what each does.":"Filter to look up any setting Claude Code documents, and open the reference for what each does.",aside:n?r.jsx("span",{className:"settings-caption-count",children:n.length}):void 0,list:!1,children:[r.jsxs("div",{className:"settings-filter",children:[r.jsx("label",{className:"vis-hidden",htmlFor:i,children:"Filter Claude Code settings"}),r.jsx("input",{id:i,type:"search",className:"settings-filter-field",placeholder:n?`Filter ${n.length} settings`:"Filter settings",autoComplete:"off",spellCheck:!1,value:a,onChange:f=>o(f.target.value),onKeyDown:f=>{dN(f.key)&&a&&(f.stopPropagation(),o(""))}})]}),u.length>0&&r.jsx("div",{className:"settings-list settings-keys",children:u.map(f=>{const p=e&&Object.hasOwn(e,f.key)?e[f.key]:null;return r.jsx(mt,{as:"div",name:r.jsx("code",{className:"claude-key",children:f.key}),note:Fbe(f),control:r.jsxs(r.Fragment,{children:[p!==null&&r.jsx("span",{className:"settings-read",title:"In your settings.json",children:p}),f.anchor&&r.jsx("a",{className:"settings-link",href:`${gee}#${f.anchor}`,target:"_blank",rel:"noreferrer","aria-label":`${f.key} in Claude Code's settings reference`,children:"Reference"})]})},f.key)})}),h&&l.length===0&&n&&r.jsxs("p",{className:"settings-empty",role:"status",children:["No setting matches “",a.trim(),"”."]}),l.length>K0&&r.jsxs("p",{className:"settings-foot",role:"status",children:[l.length-K0," more. Type more of the name to narrow the list."]}),!h&&e&&!t&&n&&l.length===0&&r.jsx("p",{className:"settings-empty",children:"Your settings.json sets nothing yet."})]})}const Wbe="Changed back after saving, most likely by a running Claude Code session. Set it again to keep it.",Hbe="There is no settings.json yet, so Claude Code uses its defaults. The first change here creates it.";function zbe(e){return`Saved in ${e??"your settings.json"}. A project's own .claude/settings.json, and policies set through MDM or the Windows registry, can override these rows and are not shown here.`}function Vbe(e){const t=`${e.env}=${e.value}`;return e.where==="environment"?`${e.effect} in sessions started with ${t}, as ccdeck was.`:`${e.effect} in every session: ${e.where==="user"?"your settings.json":"your organization"} sets ${t}.`}const zO="\0custom";function Gbe({entry:e,row:t,saving:n,nameId:s,noteId:a}){const o=!!t&&t.editable&&!n,i=!t||n===e.id,l=t?!t.editable:void 0;if(e.kind==="choice"||e.kind==="days"){const h=e.kind==="days"?e.options.map(m=>({value:String(m),label:cA(m)})):e.options,f=t?t.custom?zO:t.value===null?"":String(t.value):"",p=e.kind==="days"&&t&&!t.custom&&!h.some(m=>m.value===f)?[...h,{value:f,label:cA(Number(f))}].sort((m,w)=>Number(m.value)-Number(w.value)):h;return r.jsxs("select",{className:"sm-select","aria-labelledby":s,"aria-describedby":a,"aria-busy":i,disabled:l,value:f,onChange:m=>{if(!o)return;const w=m.target.value;HO(e.id,e.kind==="days"?Number(w):w===""?null:w)},children:[(t==null?void 0:t.custom)&&r.jsx("option",{value:zO,disabled:!0,children:"Custom value"}),p.map(m=>r.jsx("option",{value:m.value??"",children:m.label},m.value??""))]})}const u=(t==null?void 0:t.value)===!0;return r.jsx("button",{type:"button",className:"switch",role:"switch","aria-checked":u,"aria-labelledby":s,"aria-describedby":a,"aria-busy":i,disabled:l,onClick:()=>{o&&HO(e.id,!u)},children:r.jsx("span",{className:"switch-knob"})})}function Kbe(e){if(!(e!=null&&e.settings.length)||e.settings.some(n=>n.editable))return null;const t=new Set(e.settings.map(n=>n.reason));return t.size===1?[...t][0]??null:null}function Ybe(){return r.jsx(Xbe,{state:Pbe()})}function Xbe({state:e}){const{reading:t,saving:n,error:s,undone:a}=e,o=Kbe(t),i=(t==null?void 0:t.userFile)==="absent",l=t?t.userFile!=="invalid"&&t.userFile!=="unreadable":!s;return r.jsxs(r.Fragment,{children:[(t===null||s||o||i)&&r.jsxs(Bt,{children:[t===null&&!s&&r.jsx("p",{className:"settings-row settings-row-status",role:"status",children:"Reading Claude Code settings…"}),o&&r.jsx("p",{className:"settings-row settings-row-status",role:"status",children:o}),i&&!o&&r.jsx("p",{className:"settings-row settings-row-status",role:"status",children:Hbe}),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 _j(),children:"Retry"})})]})]}),l&&DD.map(u=>r.jsx(Bt,{id:`claude-group-${u.id}`,title:u.title,children:FD.filter(h=>h.group===u.id).map(h=>{const f=t==null?void 0:t.settings.find(v=>v.id===h.id),p=`claude-${h.id}-label`,m=`claude-${h.id}-note`,w=f&&!f.editable&&!o?f.reason:(a==null?void 0:a.id)===h.id?Wbe:f!=null&&f.override?Vbe(f.override):"";return r.jsx(mt,{settingId:`claude-${h.id}`,name:h.label,nameId:p,note:h.note,noteId:m,control:r.jsx(Gbe,{entry:h,row:f,saving:n,nameId:p,noteId:m}),children:r.jsx("span",{className:"settings-row-said settings-row-said-quiet",role:"status",children:w})},h.id)})},u.id)),l&&r.jsx("p",{className:"settings-foot",children:zbe(t==null?void 0:t.fileShown)}),r.jsx(Ube,{present:(t==null?void 0:t.present)??null,noFile:i})]})}const Zbe="Local statistics for Claude and Codex on this device. Commands are grouped by operation; raw arguments and outputs are not saved.";function Jbe(){const[e,t]=g.useState(null),[n,s]=g.useState(""),[a,o]=g.useState(!1),[i,l]=g.useState(null),[u,h]=g.useState(""),f=g.useRef(!1),p=g.useRef(!0),m=async()=>{if(f.current)return;f.current=!0,o(!0),s("");const j=new AbortController,b=window.setTimeout(()=>j.abort(),12e3);try{const N=await fetch("/api/tool-audit/storage",{signal:j.signal}),x=await N.json();if(!N.ok||!x.ok)throw new Error;p.current&&t(x)}catch{p.current&&s("Could not read tool history storage. Try again.")}finally{window.clearTimeout(b),f.current=!1,p.current&&o(!1)}};g.useEffect(()=>(p.current=!0,m(),()=>{p.current=!1}),[]);const w=async(j,b)=>{if(f.current)return;f.current=!0,o(!0),s(""),h("");let N=!1;const x=new AbortController,S=window.setTimeout(()=>x.abort(),15e3);try{const C=await fetch("/api/tool-audit/storage",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(j==="clear"?{action:j,confirm:!0}:{action:j,days:b}),signal:x.signal}),_=await C.json();if(!C.ok||!_.ok)throw new Error;N=!0,p.current&&(l(null),h(j==="clear"?"Tool history cleared. New calls will continue to be recorded.":`Retention changed to ${b} days.`))}catch{p.current&&s("Could not update tool history. Check storage permissions and try again.")}finally{window.clearTimeout(S),f.current=!1,p.current&&(o(!1),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||l(null)},children:"Cancel"})]})]});return r.jsxs(Bt,{id:"tool-history-settings-title",title:"Tool history",note:Zbe,className:"ta-settings",children:[e?r.jsxs(r.Fragment,{children:[r.jsx(mt,{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:j=>{if(f.current)return;const b=Number(j.target.value);b<e.retentionDays?l(b):w("retention",b)},children:[30,60,90].map(j=>r.jsxs("option",{value:j,children:[j," days"]},j))})}),typeof i=="number"&&v,r.jsx(mt,{as:"div",settingId:"tool-history-size",name:"Space used",note:`Collected since ${Cte(e.startedAt)}`,control:r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"settings-read",children:Ste(e.bytes)}),r.jsx("button",{type:"button",className:"btn","aria-busy":a,onClick:()=>{m()},children:"Refresh"})]})}),r.jsx(mt,{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||l("clear")},children:"Clear…"})}),i==="clear"&&v,!e.storageOk&&r.jsx(mt,{as:"div",name:"Some calls could not be saved",note:"Check free space and storage permissions."})]}):r.jsx(mt,{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"})})]}),u&&r.jsx("p",{className:"settings-row settings-row-status",role:"status",children:u})]})}const Ej="agent-dag.integrations.active",qS=(e,t)=>`agent-dag.integrations.prefs.${e}:${t}`,Qbe=32e3;function VO(e,t){const n=nt(qS(e,t));if(!n)return{};try{const s=JSON.parse(n);return s&&typeof s=="object"&&!Array.isArray(s)?s:{}}catch{return{}}}function gje(e,t){return{read(n,s){const a=VO(e,t)[n];return s(a)?a:void 0},write(n,s){const a=VO(e,t);s===void 0?delete a[n]:a[n]=s;const o=JSON.stringify(a);o.length<=Qbe&&st(qS(e,t),o)}}}function eke(e,t){vs(qS(e,t))}function yje(e){const t=nt(Ej);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 wje(e,t){let n={};try{const s=nt(Ej),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,st(Ej,JSON.stringify(n))}function Tj(e){var s;const t=(s=e.meta)==null?void 0:s.checkedAt;if(!t)return null;const n=new Date(String(t));return Number.isNaN(n.getTime())?null:n.toLocaleString(void 0,{month:"short",day:"numeric",hour:"numeric",minute:"2-digit",...n.getFullYear()!==new Date().getFullYear()?{year:"numeric"}:{}})}function Aj(e){const t=e.meta??{};return e.kind==="gitlab"?typeof t.serverVersion=="string"&&t.serverVersion?`GitLab ${t.serverVersion}`:null:e.kind!=="jira"?null:t.deploymentType==="Cloud"?"Jira Cloud":t.deploymentType?`Jira ${t.deploymentType==="DataCenter"?"Data Center":String(t.deploymentType)}${t.serverVersion?` ${t.serverVersion}`:""}`:null}function tke({connection:e,provider:t,available:n,busy:s,armed:a,note:o,headingRef:i,onTest:l,onEdit:u,onDisconnect:h,onCancelDisconnect:f}){var C;const p=g.useRef(null),m=(t==null?void 0:t.label)??e.kind,w=e.account.name||e.account.login||"No account read yet",v=e.account.name&&e.account.login!==e.account.name?e.account.login:"",j=Tj(e),b=Aj(e),N=Array.isArray((C=e.meta)==null?void 0:C.warnings)?e.meta.warnings.filter(_=>typeof _=="string"):[],x=s===`test:${e.id}`,S=s===`delete:${e.id}`;return r.jsxs("section",{className:"ig-connection-details","aria-labelledby":"ig-managed-title",children:[r.jsxs("header",{className:"ig-managed-header",children:[t&&r.jsx("span",{className:"ig-provider-glyph","aria-hidden":!0,children:r.jsx(t.Glyph,{})}),r.jsxs("div",{className:"ig-managed-identity",children:[r.jsx("h2",{ref:i,tabIndex:-1,id:"ig-managed-title",className:"ig-managed-title",children:e.name||e.baseUrl}),r.jsxs("p",{children:[m," · Saved connection"]})]})]}),r.jsxs("dl",{className:"ig-detail-facts",children:[r.jsxs("div",{children:[r.jsx("dt",{children:"Host"}),r.jsx("dd",{children:e.baseUrl})]}),r.jsxs("div",{children:[r.jsx("dt",{children:"Account"}),r.jsxs("dd",{children:[w,v?` (${v})`:""]})]}),r.jsxs("div",{children:[r.jsx("dt",{children:"Last verified"}),r.jsx("dd",{children:j??"No verification time available"})]}),r.jsxs("div",{children:[r.jsx("dt",{children:"Credentials"}),r.jsx("dd",{children:e.tokenSaved?"Stored locally":"No token saved"})]}),b&&r.jsxs("div",{children:[r.jsx("dt",{children:"Server"}),r.jsx("dd",{children:b})]})]}),!n&&r.jsxs("p",{className:"ig-stranded",children:[m," is not available on this deck. Disconnect deletes this connection and its saved token."]}),N.length>0&&r.jsx("ul",{className:"ig-warnings",children:N.map(_=>r.jsx("li",{children:_},_))}),n&&r.jsxs("div",{className:"ig-manage-actions",children:[r.jsx("button",{type:"button",className:"btn","aria-busy":x,"aria-disabled":s!==null||void 0,onClick:l,children:x?"Testing…":"Test connection"}),r.jsx("button",{type:"button",className:"btn","aria-disabled":s!==null||void 0,onClick:_=>{s===null&&u(_.currentTarget)},children:"Edit connection"})]}),o&&o.scope!=="disconnect"&&r.jsx("p",{className:"ig-note","data-tone":o.tone,role:o.tone==="err"?"alert":"status",children:o.text}),r.jsxs("div",{className:"ig-disconnect-section",children:[r.jsx("h3",{children:"Remove connection"}),r.jsx("p",{children:"Remove this connection and its saved token from this machine."}),r.jsxs("div",{className:"ig-manage-actions","data-integration-disconnect-actions":!0,onBlur:_=>{a&&!_.currentTarget.contains(_.relatedTarget)&&f()},children:[r.jsx("button",{ref:p,type:"button","data-integration-disconnect":!0,className:`btn danger${a?" armed":""}`,"aria-busy":S,"aria-disabled":s!==null||void 0,onKeyDown:_=>{_.repeat&&_.preventDefault()},"aria-label":a?`Confirm disconnecting ${e.name}`:`Disconnect ${e.name}`,onClick:_=>h(_.currentTarget),children:S?"Disconnecting…":a?"Confirm disconnect":"Disconnect"}),a&&r.jsx("button",{type:"button",className:"btn","aria-disabled":s!==null||void 0,"aria-label":"Cancel disconnect",onClick:()=>{var _;s===null&&(f(),(_=p.current)==null||_.focus())},children:"Cancel"})]}),a&&r.jsx("p",{className:"ig-note",role:"status",children:"Press Confirm disconnect to delete this connection and its saved token, or Cancel to keep it."}),(o==null?void 0:o.scope)==="disconnect"&&r.jsx("p",{className:"ig-note","data-tone":o.tone,role:o.tone==="err"?"alert":"status",children:o.text})]})]})}function nke({onBeforeLeaveChange:e}={}){var He;const t=Rd(),{connections:n,error:s}=t,[a,o]=g.useState(null),i=g.useRef(null),l=g.useRef(new Map),u=g.useRef(null),h=g.useRef(0),[f,p]=g.useState(null),[m,w]=g.useState(""),v=g.useRef(null),j=g.useRef(null),[b,N]=g.useState(null),[x,S]=g.useState(null),C=g.useRef(null),[_,M]=g.useState(null),[R,P]=g.useState([]),[L,U]=g.useState(null),B=g.useRef(0),[A,q]=g.useState(null),T=g.useRef(null),F=g.useRef(new Map),O=g.useRef(null),K=g.useRef(0),[V,H]=g.useState(!1),[D,I]=g.useState(null),W=g.useRef(null),Z=g.useRef(new Map),z=g.useRef(new Map);g.useEffect(()=>{const se=Uye();se&&(O.current=Z.current.get(se)??null,p(se),q(se),N({mode:"edit",id:se}));const ke=qye();ke&&N({mode:"add",kind:ke})},[]),g.useEffect(()=>{var se,ke;!A||!n||(ke=(se=z.current.get(A))==null?void 0:se.scrollIntoView)==null||ke.call(se,{block:"nearest"})},[A,n]),g.useEffect(()=>{if(!L)return;const se=()=>{var Oe,be;((Oe=document.activeElement)==null?void 0:Oe.getAttribute("aria-label"))==="Cancel disconnect"&&((be=document.querySelector(".ig-manage-view [data-integration-disconnect]"))==null||be.focus()),U(null)},ke=()=>{document.hidden&&se()},Ae=window.setTimeout(()=>{var Oe;(Oe=document.querySelector("[data-integration-disconnect-actions]"))!=null&&Oe.contains(document.activeElement)||se()},4e3);return window.addEventListener("blur",se),document.addEventListener("visibilitychange",ke),()=>{window.clearTimeout(Ae),window.removeEventListener("blur",se),document.removeEventListener("visibilitychange",ke)}},[L]);const X=(se,ke,Ae,Oe)=>P(be=>[...be.filter(fe=>fe.id!==se),{id:se,tone:ke,text:Ae,scope:Oe}]),Y=se=>P(ke=>ke.filter(Ae=>Ae.id!==se)),J=async(se,ke)=>{if(!C.current){C.current=se,S(se);try{await ke()}finally{C.current=null,S(null)}}},Q=se=>(ke,Ae)=>void J("form",async()=>{M(null);try{const Oe=await Oye(se,ke,Ae||void 0);N(null),I(null),H(!1),p(null),o(null),w("Connection added."),X(Oe.id,"ok",`Connection saved and tested as ${Oe.account.name||Oe.account.login}.`),q(Oe.id),T.current=()=>{var fe;const be=l.current.get(Oe.kind)??Z.current.get(Oe.id);return(fe=be==null?void 0:be.scrollIntoView)==null||fe.call(be,{block:"nearest"}),be}}catch(Oe){M(Oe instanceof yr?Oe:new yr("upstream","The connection could not be saved."))}}),te=se=>(ke,Ae)=>void J("form",async()=>{M(null);try{const{connection:Oe,validated:be}=await Pye(se.id,{name:Ae,input:ke});N(null),I(null),H(!1),T.current=()=>j.current??(f?v.current:Z.current.get(Oe.id)),X(Oe.id,"ok",be?`Saved. Connection test passed as ${Oe.account.name||Oe.account.login}.`:"Saved.")}catch(Oe){M(Oe instanceof yr?Oe:new yr("upstream","The change could not be saved."))}}),le=se=>void J(`test:${se.id}`,async()=>{U(null),Y(se.id);try{const ke=await Dye(se.id);X(se.id,"ok",`Connection test passed. Signed in as ${ke.account.name||ke.account.login}.`)}catch(ke){X(se.id,"err",ke instanceof Error?ke.message:"The test failed.")}}),de=(se,ke)=>{if(C.current)return;const Ae=Date.now(),Oe=yi({armedFor:L,target:se.id,armedAt:B.current,now:Ae,gapMs:gi});if(Oe==="arm"){ke.focus({preventScroll:!0}),U(se.id),B.current=Ae;return}Oe!=="ignore"&&(U(null),J(`delete:${se.id}`,async()=>{try{await Fye(se.id),eke(se.kind,se.id),Y(se.id),(b==null?void 0:b.mode)==="edit"&&b.id===se.id&&N(null),p(null);const be=(n??[]).filter(_e=>_e.kind===se.kind&&_e.id!==se.id);(!a||be.length===0)&&o(null),w("Connection disconnected.");const fe=document.activeElement;(fe===ke||Un((fe==null?void 0:fe.tagName)??null))&&(T.current=()=>{var Ve;const _e=(a&&be[0]?Z.current.get(be[0].id):l.current.get(se.kind))??F.current.get(se.kind)??document.getElementById("settings-tab-integrations");return(Ve=_e==null?void 0:_e.scrollIntoView)==null||Ve.call(_e,{block:"nearest"}),_e})}catch(be){X(se.id,"err",be instanceof Error?be.message:"The connection could not be removed. Try again.","disconnect")}}))};g.useEffect(()=>{if(x!==null||D||!T.current)return;const se=T.current();T.current=null,se!=null&&se.isConnected&&(se.checkVisibility?se.checkVisibility():se.getClientRects().length>0)&&se.focus({preventScroll:!0})},[n,f,a,b,x,D]);const oe=n??[],re=Md(t),he=["github","gitlab","jira"],pe=PS().filter(se=>re.has(se.kind)||oe.some(ke=>ke.kind===se.kind)).sort((se,ke)=>he.indexOf(se.kind)-he.indexOf(ke.kind)),Le=FS(t),ge=g.useCallback(()=>{N(null),p(null),o(null),H(!1),I(null),M(null),U(null),T.current=()=>{const se=O.current,ke=se==null?void 0:se.closest(".settings-pane");return ke&&(ke.scrollTop=K.current),se!=null&&se.isConnected?se:document.getElementById("settings-tab-integrations")}},[]),ve=g.useCallback(()=>{if(!a){ge();return}p(null),N(null),H(!1),I(null),M(null),U(null),T.current=()=>{var Ae;const se=(Ae=u.current)!=null&&Ae.isConnected?u.current:i.current,ke=se==null?void 0:se.closest(".settings-pane");return ke&&(ke.scrollTop=se===i.current?0:h.current),se}},[a,ge]),je=g.useCallback(()=>{if(!f&&!a){ge();return}N(null),H(!1),I(null),M(null),T.current=()=>j.current??(f?v.current:i.current)},[f,a,ge]),Ee=g.useCallback((se,ke=!1)=>{if(C.current)return;if(D&&ke){I(null),requestAnimationFrame(()=>{var Oe;return(Oe=document.querySelector(".ig-config-view input:not([disabled])"))==null?void 0:Oe.focus()});return}const Ae=ke?b?je:f?ve:ge:()=>{N(null),p(null),o(null),se()};V?I(()=>Ae):(H(!1),Ae())},[V,D,b,f,je,ve,ge]);g.useEffect(()=>(e==null||e(b||f||a?Ee:null),()=>e==null?void 0:e(null)),[b,f,a,Ee,e]),g.useEffect(()=>{var se;D&&((se=W.current)==null||se.focus())},[D]),g.useEffect(()=>{var se;f&&((se=v.current)==null||se.focus())},[f]),g.useEffect(()=>{var se;a&&((se=i.current)==null||se.focus())},[a]);const xe=(se,ke)=>{var Oe;if(C.current)return;T.current=null,I(null),w(""),U(null),f||a?j.current=ke:(K.current=((Oe=ke.closest(".settings-pane"))==null?void 0:Oe.scrollTop)??0,O.current=ke,j.current=null),H(!1),M(null),N(se);const Ae=ke.closest(".settings-pane");Ae&&(Ae.scrollTop=0)},Ie=(se,ke)=>{var Oe,be;if(C.current)return;T.current=null,a?(u.current=ke,h.current=((Oe=ke.closest(".settings-pane"))==null?void 0:Oe.scrollTop)??0):(K.current=((be=ke.closest(".settings-pane"))==null?void 0:be.scrollTop)??0,O.current=ke),j.current=null,w(""),U(null),p(se.id);const Ae=ke.closest(".settings-pane");Ae&&(Ae.scrollTop=0)},De=(se,ke)=>{var be;const Ae=oe.filter(fe=>fe.kind===se);if(Ae.length===1){Ie(Ae[0],ke);return}if(C.current)return;T.current=null,K.current=((be=ke.closest(".settings-pane"))==null?void 0:be.scrollTop)??0,O.current=ke,u.current=null,h.current=0,w(""),U(null),o(se);const Oe=ke.closest(".settings-pane");Oe&&(Oe.scrollTop=0)},We=(se,ke=!1)=>{const Ae=_u(se.kind),Oe=!sa(t,se.kind),be=Tj(se),fe=se.account.login||se.account.name,_e=se.kind==="jira"?Aj(se):null;return r.jsx("div",{className:"ig-conn",ref:Ve=>{Ve?z.current.set(se.id,Ve):z.current.delete(se.id)},children:r.jsxs("div",{className:"ig-summary-row",children:[r.jsxs("div",{className:"ig-summary-text",children:[r.jsx("span",{className:"ig-conn-name",children:ke&&se.name||Vo(se)}),r.jsx("span",{className:"ig-conn-line",children:[ke&&se.name!==Vo(se)?Vo(se):"",fe,_e||(be?`Last verified ${be}`:"Not verified yet")].filter(Boolean).join(" · ")||"No account read yet"}),!se.tokenSaved&&r.jsx("span",{className:"ig-bad",children:"No token saved"}),Oe&&r.jsxs("span",{className:"ig-stranded",children:[(Ae==null?void 0:Ae.label)??se.kind," is not available on this deck. Manage this connection to disconnect it."]})]}),r.jsxs("button",{type:"button",className:"btn ig-manage",ref:Ve=>{Ve?Z.current.set(se.id,Ve):Z.current.delete(se.id)},"aria-label":`Manage ${(Ae==null?void 0:Ae.label)??se.kind}: ${se.name} (${fe||Vo(se)})`,onClick:Ve=>Ie(se,Ve.currentTarget),children:["Manage ",r.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5","aria-hidden":"true",children:r.jsx("path",{d:"m6 4 4 4-4 4"})})]})]})},se.id)},Ke=oe.filter(se=>!pe.some(ke=>ke.kind===se.kind)),ye=a?_u(a):null,Fe=oe.filter(se=>se.kind===a),$e=oe.find(se=>se.id===f),Re=(b==null?void 0:b.mode)==="edit"?oe.find(se=>se.id===b.id):void 0,rt=(b==null?void 0:b.mode)==="add"?pe.find(se=>re.has(se.kind)&&se.kind===b.kind):Re&&pe.find(se=>re.has(se.kind)&&se.kind===Re.kind);return r.jsxs("div",{className:"ig-settings","data-view":b?"form":f?"connection":a?"provider":"overview",children:[b&&r.jsxs("div",{className:"ig-config-view",children:[r.jsxs("button",{type:"button",className:"btn ig-back-to-overview","aria-disabled":x!==null||void 0,onClick:()=>Ee(je,!0),children:[r.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5","aria-hidden":"true",children:r.jsx("path",{d:"m7 3-5 5 5 5M2 8h12"})}),f?"Back to connection":a?`Back to ${(ye==null?void 0:ye.label)??a} connections`:"All integrations"]}),D&&r.jsxs("div",{className:"ig-leave-confirm",role:"group","aria-labelledby":"ig-leave-title",children:[r.jsx("strong",{id:"ig-leave-title",children:"Discard unsaved changes?"}),r.jsx("p",{children:"Your changes have not been saved. Discarding clears this form, including any token you entered."}),r.jsxs("div",{className:"ig-form-actions",children:[r.jsx("button",{ref:W,type:"button",className:"btn",onClick:()=>{I(null),requestAnimationFrame(()=>{var se;return(se=document.querySelector(".ig-config-view input:not([disabled])"))==null?void 0:se.focus()})},children:"Keep editing"}),r.jsx("button",{type:"button",className:"btn danger",onClick:()=>{const se=D;I(null),H(!1),N(null),se()},children:"Discard changes"})]})]}),r.jsx("div",{hidden:!!D,children:rt?r.jsx(hye,{def:rt,existing:Re,busy:x==="form",error:_,onDirtyChange:H,onSubmit:b.mode==="add"?Q(b.kind):te(Re),onCancel:()=>Ee(je,!0)},b.mode==="add"?b.kind:b.id):r.jsxs("div",{role:"status",children:[r.jsx("p",{children:"This provider or connection is no longer available."}),r.jsx("button",{type:"button",className:"btn",onClick:je,children:"Back to integrations"})]})})]}),a&&r.jsxs("div",{className:"ig-provider-view",hidden:b!==null||f!==null,children:[r.jsxs("div",{className:"ig-manage-navigation",children:[r.jsxs("button",{type:"button",className:"btn ig-back-to-overview","aria-disabled":x!==null||void 0,onClick:()=>Ee(ge,!0),children:[r.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5","aria-hidden":"true",children:r.jsx("path",{d:"m7 3-5 5 5 5M2 8h12"})}),"All integrations"]}),sa(t,a)&&r.jsxs("button",{type:"button",className:"btn","aria-disabled":x!==null||void 0,onClick:se=>xe({mode:"add",kind:a},se.currentTarget),children:["Add ",(ye==null?void 0:ye.label)??a," connection"]})]}),r.jsxs("h2",{ref:i,tabIndex:-1,className:"ig-managed-title",children:[(ye==null?void 0:ye.label)??a," connections"]}),m&&r.jsx("p",{className:"ig-note",role:"status",children:m}),Fe.length?r.jsx("div",{className:"ig-provider-connections",children:Fe.map(se=>We(se,!0))}):r.jsx("p",{role:"status",children:"No saved connections."})]}),f&&r.jsxs("div",{className:"ig-manage-view",hidden:b!==null,children:[r.jsxs("div",{className:"ig-manage-navigation",children:[r.jsxs("button",{type:"button",className:"btn ig-back-to-overview","aria-disabled":x!==null||void 0,onClick:()=>Ee(ve,!0),children:[r.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5","aria-hidden":"true",children:r.jsx("path",{d:"m7 3-5 5 5 5M2 8h12"})}),a?`Back to ${(ye==null?void 0:ye.label)??a} connections`:"All integrations"]}),$e&&sa(t,$e.kind)&&r.jsxs("button",{type:"button",className:"btn","aria-disabled":x!==null||void 0,onClick:se=>xe({mode:"add",kind:$e.kind},se.currentTarget),children:["Add ",((He=_u($e.kind))==null?void 0:He.label)??$e.kind," connection"]})]}),$e?r.jsx(tke,{connection:$e,provider:_u($e.kind),available:sa(t,$e.kind),busy:x,armed:L===f,note:R.find(se=>se.id===f),headingRef:v,onTest:()=>le($e),onEdit:se=>xe({mode:"edit",id:$e.id},se),onDisconnect:se=>de($e,se),onCancelDisconnect:()=>U(null)}):r.jsx("p",{role:"status",children:"This connection is no longer saved."})]}),r.jsxs("div",{className:"ig-overview",hidden:b!==null||f!==null||a!==null,children:[s&&r.jsxs("div",{className:"ig-list-error",role:"alert",children:[r.jsx("p",{children:s}),r.jsx("button",{type:"button",className:"btn",onClick:()=>void Hm(),children:"Retry"})]}),n===null&&!s&&r.jsx("p",{role:"status",children:"Reading connections…"}),m&&r.jsx("p",{className:"ig-note",role:"status",children:m}),r.jsxs("div",{className:"ig-connection-list","data-setting":"integrations-connections",children:[n!==null&&r.jsx("div",{className:"ig-providers","data-setting":"integrations-add",id:Le==="all"?"integrations-add-title":void 0,children:pe.map(se=>{const ke=oe.filter(_e=>_e.kind===se.kind),Ae=ke.length===1?ke[0]:null,Oe=[...new Set(ke.map(Vo))],be=Ae&&Tj(Ae),fe=(Ae==null?void 0:Ae.kind)==="jira"?Aj(Ae):null;return r.jsxs("section",{className:"ig-provider",id:`ig-provider-${se.kind}`,"aria-labelledby":`ig-provider-name-${se.kind}`,"data-setting":`integration-${se.kind}`,children:[r.jsx("span",{className:"ig-provider-glyph","aria-hidden":!0,children:r.jsx(se.Glyph,{})}),r.jsxs("div",{className:"ig-summary-text ig-provider-content",children:[r.jsx("h3",{id:`ig-provider-name-${se.kind}`,children:se.label}),ke.length===0?r.jsx("span",{className:"ig-conn-line",children:"Not connected"}):Ae?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"ig-conn-name",children:Vo(Ae)}),r.jsx("span",{className:"ig-conn-line",children:[Ae.account.login||Ae.account.name,fe||(be?`Last verified ${be}`:"Not verified yet")].filter(Boolean).join(" · ")}),!Ae.tokenSaved&&r.jsx("span",{className:"ig-bad",children:"No token saved"})]}):r.jsxs(r.Fragment,{children:[r.jsxs("span",{className:"ig-conn-name",children:[ke.length," saved connections"]}),r.jsxs("span",{className:"ig-conn-line",children:[Oe.slice(0,2).join(" · "),Oe.length>2?` · +${Oe.length-2} more instances`:""]})]}),!re.has(se.kind)&&r.jsxs("span",{className:"ig-stranded",children:[se.label," is not available on this deck."]})]}),r.jsx("button",{type:"button",className:`btn ig-manage${ke.length?"":" primary"}`,"aria-disabled":x!==null||void 0,ref:_e=>{const Ve=ke.length?l.current:F.current;_e?Ve.set(se.kind,_e):Ve.delete(se.kind)},"aria-label":`${ke.length?"Manage":"Connect"} ${se.label}`,onClick:_e=>ke.length?De(se.kind,_e.currentTarget):xe({mode:"add",kind:se.kind},_e.currentTarget),children:ke.length?r.jsxs(r.Fragment,{children:["Manage ",r.jsx("svg",{width:"12",height:"12",viewBox:"0 0 16 16",fill:"none",stroke:"currentColor",strokeWidth:"1.5","aria-hidden":"true",children:r.jsx("path",{d:"m6 4 4 4-4 4"})})]}):"Connect"})]},se.kind)})}),(Ke.length>0||pe.length===0&&Le!=="all"&&n!==null)&&r.jsxs(Bt,{id:"integrations-list-title",title:"Connections",aside:r.jsx("span",{className:"settings-caption-count",children:Ke.length}),children:[Ke.map(se=>We(se,!0)),oe.length===0&&r.jsx("p",{className:"settings-row settings-row-status",children:"Nothing connected."})]})]}),Le==="all"&&r.jsx(r.Fragment,{children:r.jsx("div",{className:"ig-overview-info",children:r.jsxs("details",{className:"ig-access",children:[r.jsx("summary",{children:"Access and token storage"}),r.jsx("p",{children:"ccdeck only reads from connected services. Tokens stay on this machine and are never shown again or shared with paired decks."})]})})})]})]})}function ske({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 rke({theme:e,onTheme:t,singleKeys:n}){const s=i=>{var f,p;if(!["ArrowLeft","ArrowRight","ArrowUp","ArrowDown"].includes(i.key))return;i.preventDefault();const l=(f=i.target.closest("[data-theme-choice]"))==null?void 0:f.dataset.themeChoice,h=(fr.indexOf(l??e)+(i.key==="ArrowLeft"||i.key==="ArrowUp"?-1:1)+fr.length)%fr.length;t(fr[h]),(p=i.currentTarget.querySelectorAll('[role="radio"]')[h])==null||p.focus()},a=g.useRef(null),o=g.useRef(e);return g.useEffect(()=>{var u,h;const i=o.current;o.current=e;const l=document.activeElement;i===e||!l||!((u=a.current)!=null&&u.contains(l))||l.dataset.themeChoice!==i||(h=a.current.querySelector(`[data-theme-choice="${e}"]`))==null||h.focus()},[e]),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",{ref:a,className:"appearance-themes",role:"radiogroup","aria-labelledby":"appearance-theme-caption","aria-keyshortcuts":n?"T":void 0,onKeyDown:s,children:fr.map(i=>r.jsxs("button",{type:"button",className:"appearance-theme",role:"radio","data-theme-choice":i,"data-setting":`theme-${i}`,"aria-checked":e===i,tabIndex:e===i?0:-1,onClick:()=>t(i),children:[r.jsx(ske,{theme:i}),r.jsxs("span",{className:"appearance-theme-name",children:[oc[i].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"})})]})]},i))})})}const ake=[["smallest","Smallest","11 px"],["smaller","Smaller","12 px"],["default","Default","13 px"],["larger","Larger","15 px"],["largest","Largest","17 px"]],oke=[["tightest","Tightest","30%"],["tighter","Tighter","50%"],["compact","Compact","70%"],["default","Default","100%"],["comfortable","Comfortable","140%"]];function GO(){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 ike({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 lke({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":xA.length,"--reading-selected":xA.indexOf(e)},children:ake.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(GO,{})]},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":vA.length,"--reading-selected":vA.indexOf(t)},children:oke.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(GO,{})]},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 cke="AGPL-3.0-only",uke="GNU Affero General Public License, version 3 only.",dke="https://github.com/BarganConstantin/ccdeck",hke="What changed in each release, newest first.",fke="Tell the people who make ccdeck what works and what does not.";function pke(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 mke(e,t){return lo(e)&&lo(t)&&vi(e,t)<0}function gke(e,t){return e?{kind:"ready",to:e.version,name:"Update ready",note:`${Pt} 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:`${Pt} v${t.to} is out — you are on v${t.from}.`}:null}function yke({version:e,notice:t,readyAppUpdate:n,updateRestarting:s,updateFailure:a,onUpdateRestart:o,doors:i,bundle:l="3.47.0"}){const u=(e==null?void 0:e.running)??l,h=gke(n,t);return r.jsxs(r.Fragment,{children:[r.jsxs(Bt,{id:"settings-about-caption",title:Pt,children:[r.jsx(mt,{as:"div",settingId:"version",name:"Version",note:mke(l,e==null?void 0:e.running)?pke(l):void 0,control:r.jsx("span",{className:"settings-read",children:u})}),h&&r.jsx(wke,{offer:h,restarting:s,failure:a,onRestart:o,onUpdate:i.update}),r.jsx(mt,{as:"div",settingId:"whats-new",name:"What's new",note:hke,control:r.jsx("button",{type:"button",className:"btn","aria-haspopup":"dialog","aria-label":"Open What's new",onClick:i.whatsNew,children:"Open"})}),r.jsx(mt,{as:"div",settingId:"licence",name:"Licence",note:uke,control:r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"settings-read",children:cke}),r.jsxs("a",{className:"settings-link",href:dke,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(mt,{as:"div",settingId:"tour",name:"Take the tour",note:Sj,control:r.jsx("button",{type:"button",className:"btn","aria-haspopup":"dialog","aria-label":"Start the tour",onClick:i.tour,children:"Start"})}),r.jsx(mt,{as:"div",settingId:"feedback",name:"Send feedback",note:fke,control:r.jsx("button",{type:"button",className:"btn","aria-haspopup":"dialog","aria-label":"Open the feedback dialog",onClick:i.feedback,children:"Open"})})]})]})}function wke({offer:e,restarting:t,failure:n,onRestart:s,onUpdate:a}){if(e.kind==="notice")return r.jsx(mt,{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=R8(e.to,t),i=n&&n.version===e.to?M8(n.failure,n.version):"";return r.jsx(mt,{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 xke="Update when idle",vke="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.",bke=`${Q8} 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.`,kke="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.",jke="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 Nke(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 Ske={plain:vke,"checks-off":bke,"no-restart":kke};function Cke({autoRestart:e,onToggleAutoRestart:t,version:n,inApp:s=co()}){const a=Nke(n,s);return r.jsx(Bt,{id:"settings-updates-caption",title:"Updates",children:a==="app"?r.jsx(mt,{as:"div",settingId:"auto-update",name:"Updates",note:jke}):r.jsx(mt,{settingId:"auto-update",name:xke,nameId:"settings-auto-update-label",note:a==="no-restart"?"Automatic updates are unavailable in this session. Your choice is saved for the next start.":a==="checks-off"?"Update checks are disabled. Only versions installed another way can be applied.":"Restart into a newer version after 30 seconds without active agents.",details:Ske[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 _ke({character:e,onCharacter:t}){const n=g.useRef([]);function s(a,o){var l;const i=oS(a,o,$f.length,"vertical");i.kind==="select"&&(a.preventDefault(),t($f[i.index].id),(l=n.current[i.index])==null||l.focus())}return r.jsx("div",{className:"character-picker",role:"radiogroup","aria-label":"Choose character","data-setting":"character-choice",children:$f.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(pD,{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 Eke="Stands beside the minimap. Press it to play the radio.";function Tke({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(mt,{settingId:"character",name:"Show the character",nameId:"appearance-character-label",note:Eke,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(_ke,{character:n,onCharacter:s})]})}const KO="settings-search-field",oB="settings-search-results",Rj=e=>`settings-result-${e}`;function Ake({inputRef:e,query:t,onQuery:n,results:s,active:a,onActive:o,onOpen:i}){const l=t.trim()!=="",u=l&&s.length>0,h=f=>{if(f.nativeEvent.isComposing)return;const p=wte(f.key,t,l?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:KO,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:KO,type:"search",className:"settings-filter-field settings-search-field",placeholder:"Search settings",autoComplete:"off",spellCheck:!1,role:"combobox","aria-autocomplete":"list","aria-expanded":u,"aria-controls":u?oB:void 0,"aria-activedescendant":u?Rj(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 Rke({query:e,results:t,active:n,onOpen:s}){const a=QD(t.length,e);return g.useEffect(()=>{var o,i;(i=(o=document.getElementById(Rj(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:oB,role:"listbox","aria-label":"Matching settings",children:t.map((o,i)=>r.jsxs("button",{type:"button",role:"option",id:Rj(i),className:"settings-result",tabIndex:-1,"aria-selected":i===n,"aria-label":pte(o),"data-highlighted":i===n,onMouseDown:l=>l.preventDefault(),onClick:()=>s(o),children:[r.jsx(fm,{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:PN(o)})]})]},o.id))})})]})}function Mke({query:e,count:t}){return r.jsx("p",{className:"vis-hidden",role:"status",children:e.trim()?QD(t,e):""})}const $ke=1500,Lke=3e3,Ike=e=>e.checkVisibility?e.checkVisibility():e.getClientRects().length>0;function Oke(e){if(e.matches(Qf)&&!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(Qf)).filter(s=>_P({disabled:s.disabled,tabIndex:s.tabIndex,rendered:Ike(s)}));return n.find(s=>s.closest(".settings-list")!=null)??n[0]??null}function Pke(e,t,n){const[s,a]=g.useState(null),o=g.useRef(void 0),i=g.useRef(null);return g.useEffect(()=>()=>{var l;window.clearTimeout(o.current),(l=i.current)==null||l.removeAttribute("data-jumped")},[]),g.useEffect(()=>{const l=e.current;if(!s||!t||!l)return;const u=()=>l.querySelector(`[data-setting="${CSS.escape(s)}"]`),h=w=>{var j,b;a(null);const v=w.offsetHeight>l.clientHeight-48;w.scrollIntoView({block:v?"start":"center"}),(j=Oke(w))==null||j.focus({preventScroll:!0}),window.clearTimeout(o.current),(b=i.current)==null||b.removeAttribute("data-jumped"),w.offsetWidth,w.setAttribute("data-jumped",""),i.current=w,o.current=window.setTimeout(()=>{w.removeAttribute("data-jumped"),i.current===w&&(i.current=null)},$ke)},f=u();if(f){h(f);return}const p=new MutationObserver(()=>{const w=u();w&&(p.disconnect(),window.clearTimeout(m),h(w))});p.observe(l,{childList:!0,subtree:!0});const m=window.setTimeout(()=>{p.disconnect(),a(null)},Lke);return()=>{p.disconnect(),window.clearTimeout(m)}},[e,s,t,n]),a}function Dke({section:e,landOn:t,onSection:n,onClose:s,providers:a,sound:o,tones:i,customTones:l,notify:u,appearance:h,versionCheck:f,desktopUpdate:p,restart:m,doors:w}){const v=g.useRef(null),j=g.useCallback(be=>{v.current=be},[]);function b(be,fe=!1){v.current?(D(""),v.current(be,fe),requestAnimationFrame(()=>{var _e,Ve;return(Ve=(_e=x.current)==null?void 0:_e.scrollIntoView)==null?void 0:Ve.call(_e,{block:"nearest",inline:"nearest"})})):be()}const N=()=>b(s,!0),x=g.useRef(null),S=gt(N,{focusRef:x}),C=yt(()=>b(s)),_=g.useRef([]),M=Rd(),R=FS(M),P=cee(R,e,a.claude),L=Math.max(0,P.findIndex(be=>be.id===e)),U=ic("(max-width: 640px)"),[B,A]=g.useState(""),[q,T]=g.useState(0),F=g.useRef(null),O=g.useRef(null),K=B.trim()!=="",V=g.useMemo(()=>yte(B,JD(a.claude,R,Md(M))),[B,a.claude,R,M]),H=Pke(O,!K,e),D=be=>{A(be),T(0)};g.useEffect(()=>{t&&H(t)},[t,H]);const I=be=>{b(()=>{D(""),n(be),requestAnimationFrame(()=>{var fe;return(fe=document.getElementById(`settings-tab-${be}`))==null?void 0:fe.focus()})})},W=be=>{b(()=>{D(""),n(be.section),hm(be)||H(be.id)})};g.useEffect(()=>{const be=fe=>{var ot,tt;if(!mee(fe))return;const _e=S.current,Ve=fe.target;!_e||!(Ve===document.body||Ve===document.documentElement||Ve&&_e.contains(Ve))||(fe.preventDefault(),(ot=F.current)==null||ot.focus(),(tt=F.current)==null||tt.select())};return window.addEventListener("keydown",be),()=>window.removeEventListener("keydown",be)},[S]),g.useEffect(()=>{var be,fe,_e,Ve;uee((be=document.activeElement)==null?void 0:be.id,e)&&((fe=x.current)==null||fe.focus()),(Ve=(_e=x.current)==null?void 0:_e.scrollIntoView)==null||Ve.call(_e,{block:"nearest",inline:"nearest"})},[e]);const{theme:Z,setTheme:z,characterEnabled:X,setCharacterEnabled:Y,character:J,setCharacter:Q}=h,te=Tn(),le=be=>{const fe=oS(be,L,P.length,"vertical");fe.kind!=="pass"&&(be.preventDefault(),b(()=>{var _e;D(""),n(P[fe.index].id),(_e=_.current[fe.index])==null||_e.focus()}))},de=be=>{be.key===" "&&be.stopPropagation()},{soundOn:oe,toggleSound:re}=o,{tonePrefs:he,previewTone:pe,changeTone:Le}=i,{customSelections:ge,customAssets:ve,clearCustomOnly:je,selectCustomTone:Ee,importNotificationAudio:xe,createNotificationVoice:Ie,renameCustomAsset:De,deleteCustomAsset:We,previewCustomAsset:Ke}=l,{notifyPermission:ye,notifyOn:Fe,notifyVetoed:$e,toggleNotify:Re,notifySupported:rt,askForNotifications:He,accountNotify:se,toggleAccountNotify:ke}=u,Ae=(()=>{switch(e){case"radar":return r.jsx(Lbe,{onOpen:w.radar});case"claude":return r.jsx(Ybe,{});case"appearance":return r.jsxs(r.Fragment,{children:[r.jsx(rke,{theme:Z,onTheme:z,singleKeys:te}),r.jsx(Tke,{characterEnabled:X,character:J,onCharacter:Q,onToggleCharacter:()=>Y(be=>!be)})]});case"reading":return r.jsx(lke,{textSize:h.textSize,density:h.density,onTextSize:h.setTextSize,onDensity:h.setDensity});case"keyboard":return r.jsx(gbe,{singleKeys:te,onToggleSingleKeys:()=>LY(!te)});case"notifications":return r.jsx(ybe,{notifyOn:Fe,onToggleNotify:Re,notifyVetoed:$e,notifyPermission:rt?ye:"unsupported",onAskNotify:He,accountNotify:se,onToggleAccountNotify:ke});case"sounds":return r.jsx(Mbe,{soundOn:oe===!0,onToggleSound:re,prefs:he,claudeHere:a.claude,onLevel:(be,fe)=>Le(be,{level:fe}),onFigure:(be,fe)=>Le(be,{figure:fe}),onPreview:be=>pe(be),customAssets:ve,customSelections:ge,onBuiltInSelected:je,onCustomSelected:Ee,onImportCustom:xe,onCreateVoice:Ie,onRenameCustom:De,onPreviewCustom:Ke,onDeleteCustom:We});case"integrations":return r.jsx(nke,{onBeforeLeaveChange:j});case"data":return r.jsx(Jbe,{});case"about":return r.jsx(yke,{version:f.version,notice:f.notice,readyAppUpdate:p.readyAppUpdate,updateRestarting:p.desktopUpdateRestarting,updateFailure:p.desktopUpdateFailure,onUpdateRestart:be=>{p.askDesktopUpdateRestart(be)},doors:w});default:return r.jsxs(r.Fragment,{children:[r.jsx(rbe,{}),r.jsx(BO,{provider:"Codex"}),a.claude&&r.jsx(BO,{provider:"Claude"}),r.jsx(Cke,{autoRestart:m.autoRestart,onToggleAutoRestart:m.toggleAutoRestart,version:f.version}),r.jsx(dbe,{claudeHere:a.claude,singleKeys:te,doors:w})]})}})(),Oe=e==="reading"?r.jsx(ike,{textSize:h.textSize,density:h.density,onTextSize:h.setTextSize,onDensity:h.setDensity}):e==="integrations"&&M.connections!==null?r.jsxs("span",{className:"ig-total",children:[M.connections.length," saved connection",M.connections.length===1?"":"s"]}):null;return r.jsx("div",{className:"modal-backdrop",...C,role:"presentation",children:r.jsxs("div",{ref:S,id:"settings",className:"modal settings-modal",role:"dialog","aria-modal":"true","aria-labelledby":"settings-title",onClick:be=>be.stopPropagation(),onKeyDown:de,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:()=>b(s),"aria-label":"Close settings",title:"Close (Esc)",children:"×"})})]}),r.jsxs("div",{className:"settings-body",children:[r.jsxs("div",{className:"settings-side",children:[r.jsx(Ake,{inputRef:F,query:B,onQuery:D,results:V,active:q,onActive:T,onOpen:W}),r.jsx(Mke,{query:B,count:V.length}),r.jsx("div",{className:"settings-nav",role:"tablist","aria-label":"Settings sections","aria-orientation":U?"horizontal":"vertical",onKeyDown:le,children:P.map((be,fe)=>r.jsxs("button",{ref:_e=>{_.current[fe]=_e,be.id===e&&(x.current=_e)},type:"button",role:"tab",id:`settings-tab-${be.id}`,className:"settings-tab","aria-selected":be.id===e,"aria-controls":"settings-pane",tabIndex:be.id===e?0:-1,onClick:()=>I(be.id),children:[r.jsx(fm,{section:be.id}),r.jsx("span",{className:"settings-tab-label",children:be.label})]},be.id))})]}),r.jsxs("div",{ref:O,className:"settings-pane",role:"tabpanel",id:"settings-pane","aria-labelledby":`settings-tab-${e}`,hidden:K||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:P[L].label}),r.jsx("p",{className:"settings-pane-note",children:P[L].note})]}),Oe]}),Ae]},e),K&&r.jsx(Rke,{query:B,results:V,active:q,onOpen:W})]})]})})}function Fke({tool:e,onClose:t}){const n=gt(t),s=yt(t),a=e.endedAt==null?"inflight":e.ok===!1?"err":"done",o=g.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,l=o.current.response??e.errorPreview,u=e.trimmed===!0&&o.current.input===void 0&&o.current.response===void 0,h=g.useMemo(()=>{const f=lV(e.name,i,l);return{input:f.input.map((p,m)=>r.jsx(YO,{block:p},m)),response:f.response.map((p,m)=>r.jsx(YO,{block:p},m)),copyInput:KE(e.name,"input",i),copyResponse:KE(e.name,"response",l)}},[e.name,i,l]);return r.jsx("div",{className:"modal-backdrop",...s,role:"presentation",children:r.jsxs("div",{ref:n,className:"modal tool-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:SP(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:[u&&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(XO,{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(XO,{text:h.copyResponse,what:"response"})]}),e.endedAt==null?r.jsx("pre",{children:"(waiting…)"}):h.response]})]})]})})}const Bke={del:"tm-del",add:"tm-add",ctx:"tm-ctx"};function YO({block:e}){const[t,n]=g.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=g.useMemo(()=>tV(e),[e]),{shown:a}=Q4(s,t),o=nV(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,l)=>r.jsxs("span",{className:i.tone?Bke[i.tone]:void 0,children:[i.text,l<a.length-1?`
|
|
315
|
+
`:""]},l)):a.map(i=>i.text).join(`
|
|
316
|
+
`)}),o&&r.jsx("button",{type:"button",className:"btn tm-more","aria-expanded":o.expanded,onClick:()=>n(i=>!i),children:o.label})]})}function XO({text:e,what:t}){const[n,s]=g.useState(!1),a=g.useRef(!0);return g.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 ho(e).then(o=>{!o||!a.current||(s(!0),window.setTimeout(()=>{a.current&&s(!1)},1600))}),children:n?"copied":"copy"})}const qke=Wm(()=>bi(()=>import("./UsageHistoryModal-qfmvXdWJ.js"),[]),"Usage history"),Uke=Wm(()=>bi(()=>import("./BrowserWatchModal-Bau0ttnH.js"),[]),"Browser Watch"),Wke=Wm(()=>bi(()=>import("./TrafficRadar-CPjAXd5e.js"),[]),"Telemetry Radar");function Hke({dialogs:e,welcome:t,desktopUpdate:n,versionCheck:s,restart:a,upgrade:o,lanPairs:i,attention:l,clearFlow:u,watchBadge:h,announcements:f,appearance:p,providers:m,stateRef:w,agentCount:v,menus:j,sound:b,tones:N,customTones:x,notify:S,panelDoors:C}){const{openedTool:_,setOpenedToolKey:M,usageHistoryOpen:R,setUsageHistoryOpen:P,browserWatchOpen:L,setBrowserWatchOpen:U,contextAgent:B,setContextFor:A,summaryFor:q,setSummaryFor:T,keyHelpOpen:F,setKeyHelpOpen:O,feedbackOpen:K,setFeedbackOpen:V,feedbackPrefill:H,setFeedbackPrefill:D,openFeedback:I}=e,{trafficRadarOpen:W,setTrafficRadarOpen:Z}=e,{tourOpen:z,openTour:X,closeTour:Y,releaseNotes:J,closeReleaseNotes:Q,chipVersion:te,openReleaseNotes:le}=t,{desktopUpdateRestarting:de,desktopUpdateFailure:oe,readyAppUpdate:re,askDesktopUpdateRestart:he}=n,{version:pe,showNotice:Le}=s,{askRestart:ge}=a,{clearConfirmOpen:ve,setClearConfirmOpen:je,requestClear:Ee}=u,{setWatchOn:xe,markWatchSeen:Ie}=h,{setWatchSaid:De}=f,{palette:We}=p,{settingsOpen:Ke,settingsSection:ye,settingsLandOn:Fe,showSection:$e,closeSettings:Re,openSettings:rt}=j;return r.jsxs(r.Fragment,{children:[_&&r.jsx(Fke,{tool:_,onClose:()=>M(null)}),R&&r.jsx(g.Suspense,{fallback:null,children:r.jsx(qke,{providers:m,onClose:()=>P(!1)})}),L&&r.jsx(g.Suspense,{fallback:null,children:r.jsx(Uke,{onClose:()=>U(!1),onSeen:He=>{De(""),Ie(He)},onWatching:xe,palette:We})}),B&&r.jsx(rK,{agent:B,onClose:()=>A(null)}),W&&r.jsx(g.Suspense,{fallback:null,children:r.jsx(Wke,{sessions:[...w.current.agents.values()].filter(He=>He.kind==="root"&&He.provider!=="codex").map(He=>({id:He.sessionId,label:Qp(He.sessionName,He.sessionTitle).face??He.cwdBasename??He.label,project:He.cwdBasename??He.label,workspace:He.cwd})),onClose:()=>Z(!1)})}),K&&r.jsx(H8,{initialKind:H==null?void 0:H.initialKind,initialBody:H==null?void 0:H.initialBody,onClose:()=>{V(!1),D(null)}}),q&&r.jsx(Qve,{state:w.current,sessionId:q,onClose:()=>T(null)}),Ke&&r.jsx(Dke,{section:ye,landOn:Fe,onSection:$e,onClose:Re,providers:m,sound:b,tones:N,customTones:x,notify:S,appearance:p,versionCheck:s,desktopUpdate:n,restart:a,doors:{whatsNew:Ua(Re,le),update:Ua(Re,()=>{le(),Le()}),tour:Ua(Re,X),feedback:Ua(Re,()=>I()),accounts:Ua(Re,C.accounts),localNetwork:Ua(Re,C.localNetwork),browserWatch:Ua(Re,()=>U(!0)),radar:Ua(Re,()=>Z(!0))}}),J&&r.jsx(Jve,{entries:J.entries,since:J.since,firstRun:J.firstRun,running:te,onClose:Q,onTour:()=>{Q(),X()},updateVersion:re==null?void 0:re.version,updateBusy:de,updateFailure:oe&&(!re||re.version===oe.version)?M8(oe.failure,oe.version):void 0,onUpdateRestart:re?()=>{he(re.version)}:void 0,onRestart:!re&&(pe!=null&&pe.canRestart)?()=>{Q(),ge()}:void 0,updateCheck:{versionCheck:s,upgrade:o,restart:a,desktopUpdate:n,running:te,onHandOff:Q}}),r.jsx(zke,{lanPairs:i,attention:l}),F&&r.jsx(sve,{onClose:()=>O(!1),onTour:()=>{O(!1),X()},onSettings:()=>{O(!1),rt("keyboard")}}),z&&r.jsx(g6,{title:"What the deck shows you",steps:Yie,onClose:Y}),ve&&r.jsx(Gwe,{agentCount:v,onConfirm:()=>Ee("confirmation"),onCancel:()=>je(!1)})]})}function zke({lanPairs:e,attention:t}){const n=pve(e);return r.jsxs(r.Fragment,{children:[n,r.jsx(wve,{...t,pairing:n!=null})]})}const Vke=10,iB=500,lB=4e3,Gke=[/ResizeObserver loop/i,/^Script error\.?$/i],ZO=/^(?:[a-z][\w+.-]*-extension|webkit-masked-url):\/\//i,Kke=/[a-z][\w+.-]*:\/\/[^\s()]+/gi;function Yke(e,t){const n=typeof e=="string"?e.split(`
|
|
317
|
+
`):[],s=n.some(o=>/^\s*at\s/.test(o)),a=n.flatMap(o=>!s||/^\s*at\s/.test(o)?o.match(Kke)??[]:[]);return a.length?a.every(o=>ZO.test(o)):typeof t=="string"&&ZO.test(t)}const Op=String.raw`[^\s\\/:'"\`<>|?*;,]`,Xke=String.raw`${Op}(?:[^\\/\r\n:'"\`<>|?*;,]*${Op})?[\\/]`,Zke=String.raw`[^\s\\/:'"\`<>|?*;,()]+`,gu=String.raw`(?:${Xke})*(?:${Zke})?`,Jke=String.raw`(?<![\w.~/\\\]-]|<(?:deck|host)>)(?:file://(?:/[A-Za-z]:)?[^\s:'"\`<>()]*|~[\\/]${gu}|[A-Za-z]:[\\/]${gu}|\\\\(?:[?.]\\)?(?:[A-Za-z]:\\)?${gu}|/(?=${Op})${gu}|(?<!:)//(?=${Op})${gu})`,Qke=String.raw`(?<![\w-])(?:[A-Za-z]--|-[A-Za-z0-9][\w.]*-)[\w.-]*`,e0e=new Set([".claude",".codex"]);function t0e(e){if(!e.startsWith("~"))return"<path>";const t=e[1],[n,...s]=e.slice(2).split(/[\\/]/);return n?e0e.has(n)?s.join("")?`~${t}${n}${t}<path>`:e:`~${t}<path>`:e}const n0e=String.raw`\b(https?|wss?)://[^\s/?#\\'"\x60<>(),;]+(?=(/assets/)?)`;function s0e(e,t,n){return n?"<deck>":`${t}://<host>`}const JO=String.raw`(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)`,cB=String.raw`${JO}(?:\.${JO}){3}`,Y0=String.raw`[0-9A-Fa-f]{1,4}`,QO=String.raw`(?=[0-9A-Fa-f:]*\d)(?=[0-9A-Fa-f:]*::|(?:${Y0}:){7})(?:(?:${Y0})?:)+(?:${cB}|${Y0})?`,e3=String.raw`%[\w-]+(?:\.[\w-]+)*`,t3=String.raw`(?:::1?|::ffff:(?:127(?:\.\d{1,3}){3}|0\.0\.0\.0))`,r0e=String.raw`(?<![\w:.%-])(?:\[(?!${t3}\])${QO}(?:${e3})?\]|(?!${t3}(?::\d{1,5})?(?![\w:%]|\.\d))${QO}(?:${e3})?(?![\w%]|\.\d))|(?<![\w./-])(?!127\.|0\.0\.0\.0\b)${cB}(?![\w-]|\.\d)`,X0=String.raw`(?=[\w.-]*[A-Za-z])[A-Za-z0-9][\w-]*(?:\.[\w-]+)*`,a0e=String.raw`(?<![\w.@/\\%-])(?!localhost(?![\w-]|\.\w))(?:(?<=\b(?:(?:getaddrinfo|connect) E[A-Z_]+|ENOTFOUND|EAI_AGAIN) )${X0}|${X0}(?=:\d{1,5}(?![\w:-]|\.\w))|${X0}\.(?:local|lan|home|internal|ts\.net)(?![\w-]|\.\w))`;function n3(e){return String(e??"").replace(/\/(?:home|Users)\/[^/\s:'"]+/g,"~").replace(/[A-Za-z]:\\(?:Users|Documents and Settings)\\[^\\\r\n:'"]+/gi,"~").replace(new RegExp(Jke,"g"),t0e).replace(new RegExp(Qke,"g"),"<project>").replace(new RegExp(n0e,"g"),s0e).replace(new RegExp(r0e,"g"),"<host>").replace(new RegExp(a0e,"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 uB=e=>{fetch("/api/client-error",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e),keepalive:!0}).catch(()=>{})};function o0e(e,t,n=uB){const s=String(e??"").slice(0,iB).trim();s&&n({message:s,stack:typeof t=="string"?t.slice(0,lB):void 0})}function i0e(e,t=window,n=uB){let s=0;const a=new Set,o=(u,h,f)=>{const p=String(u??"").slice(0,iB).trim();!e()||!p||s>=Vke||a.has(p)||Gke.some(m=>m.test(p))||Yke(h,f)||(a.add(p),s++,n({message:p,stack:typeof h=="string"?h.slice(0,lB):void 0}))},i=u=>{var h,f;return o(((h=u.error)==null?void 0:h.message)??u.message,(f=u.error)==null?void 0:f.stack,u.filename)},l=u=>typeof u.reason=="object"&&u.reason!==null?o(u.reason.message,u.reason.stack):o(u.reason,void 0);return t.addEventListener("error",i),t.addEventListener("unhandledrejection",l),()=>{t.removeEventListener("error",i),t.removeEventListener("unhandledrejection",l)}}const l0e=12;function c0e(e,t){const n=[n3(e).trim()||"The deck threw an error with no message."],s=t==null?void 0:t.trim();if(s){const a=s.split(`
|
|
318
|
+
`).slice(0,l0e).join(`
|
|
319
|
+
`);n.push("",n3(a).trim())}return n.join(`
|
|
320
|
+
`)}class u0e extends g.Component{constructor(){super(...arguments);Ba(this,"state",{error:null,componentStack:null,reportOpen:!1});Ba(this,"onKey",n=>{dN(n.key)&&cn.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}),o0e(n.message,n.stack),h8("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(H8,{initialKind:"bug",initialBody:c0e(n.message,s),onClose:()=>this.setState({reportOpen:!1})})]}):this.props.children}}const d0e=1e3;function h0e(e={}){const t=Math.max(1,Math.floor(e.limit??d0e)),n=e.protect;let s=!1,a=[],o=new Set,i=0,l=0,u=null;return{get paused(){return s},get size(){return a.length},get dropped(){return i},get overflowed(){return i>0},get through(){return l},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!==u;m&&(u=p,l=0);const w=f!==null&&!m&&f<=l;if(f!==null&&f>l&&(l=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[j]=a.splice(v,1);o.delete(j),i++}return!1},setPaused(h){if(s=h,h)return[];const f=a;return a=[],o=new Set,i=0,f}}}function f0e(e){const t=g.useState(()=>h0e({protect:o=>xV(e.current,o)}))[0],[n,s]=g.useState(!1),a=g.useCallback(()=>{const o=t.paused&&t.dropped>0,i=t.setPaused(!t.paused);o&&rG(e.current);for(const l of i)e.current=dP(e.current,l);s(t.paused)},[t,e]);return{pauseGate:t,paused:n,togglePause:a}}const Mj={kind:"assumed",claude:!0,codex:!0};function p0e(e){if(!e||typeof e!="object")return Mj;const t=e.providers;if(!t||typeof t!="object")return Mj;const n=t;return{kind:"reported",claude:n.claude!==!1,codex:n.codex!==!1}}function m0e(e){const[t,n]=g.useState(null),[s,a]=g.useState(Mj);g.useEffect(()=>{let i=!1;return fetch("/api/health").then(l=>l.ok?l.json():null).then(l=>{i||(a(p0e(l)),!(!l||typeof l.workspace!="string")&&n(l.workspace))}).catch(()=>{}),()=>{i=!0}},[e]);const o=Dn(s);return{workspace:t,providers:s,providersRef:o}}const dB=3*6e4,g0e=2e4;function y0e({fetchReport:e,visible:t,now:n,onReport:s}){let a=0,o=!0;const i=async()=>{if(!t())return;const l=await e();!o||!l||(a=n(),s(l))};return{tick:i,wake:async()=>{t()&&n()-a>=dB&&await i()},stop:()=>{o=!1}}}async function w0e(){try{const e=await fetch("/api/provider-status",{signal:AbortSignal.timeout(g0e)});return e.ok?await e.json():null}catch{return null}}function x0e(e){const[t,n]=g.useState(null);return g.useEffect(()=>{if(!e){n(null);return}const s=y0e({fetchReport:w0e,visible:()=>document.visibilityState==="visible",now:()=>Date.now(),onReport:n});s.tick();const a=window.setInterval(s.tick,dB),o=()=>{s.wake()};return document.addEventListener("visibilitychange",o),()=>{s.stop(),window.clearInterval(a),document.removeEventListener("visibilitychange",o)}},[e]),t}const v0e={degraded:"degraded performance",partial_outage:"partial outage",major_outage:"major outage",maintenance:"maintenance"},b0e={degraded:"degraded",partial_outage:"partial outage",major_outage:"major outage",maintenance:"maintenance"},k0e={degraded:"degraded",partial_outage:"outage",major_outage:"outage",maintenance:"maint."},j0e={claude:"Claude",codex:"Codex"},N0e=new Set(["status.claude.com","status.openai.com"]),S0e=30*6e4,C0e=10*6e4;function _0e(e){if(typeof e!="string")return null;try{const t=new URL(e);return t.protocol==="https:"&&N0e.has(t.hostname)?t:null}catch{return null}}function s3(e){return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hourCycle:"h23"})}function E0e(e){const t=Math.floor(e/6e4);return t<1?"just now":t<60?`${t} min ago`:`${Math.floor(t/60)} h ago`}function T0e(e,t){if(!e||typeof e!="object")return null;const n=Zt(v0e,e.state),s=Zt(j0e,e.provider);if(!n||!s||typeof e.checkedAt!="number"||t-e.checkedAt>S0e)return null;const a=_0e(e.statusPageUrl);if(!a)return null;const o=Array.isArray(e.components)?e.components:[],i=e.stale===!0||t-e.checkedAt>C0e,l=[`${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 ${s3(e.checkedAt)}; this is the last thing it said`:`Reported by ${a.hostname}, checked ${E0e(t-e.checkedAt)}`,"Opens the status page"],u=i?s3(e.checkedAt):null;return{provider:e.provider,state:e.state,name:s,label:`${s} · ${n}${u?` · as of ${u}`:""}`,words:n,chipWords:Zt(b0e,e.state)??n,shortWords:Zt(k0e,e.state)??n,asOf:u,what:e.summary||(o.length>0?o.join(", "):null),href:a.href,host:a.hostname,stale:i,detail:l.filter(Boolean).join(`
|
|
321
|
+
`)}}function A0e(e,t){return!(e!=null&&e.ok)||e.disabled||!Array.isArray(e.providers)?[]:e.providers.map(n=>T0e(n,t)).filter(n=>n!==null)}function R0e(e){return e.map(t=>`${t.name}'s status page reports ${t.state.endsWith("outage")?`a ${t.words}`:t.words}.`).join(" ")}const M0e="The providers' status pages report no incident.";function $0e({version:e,loadVersion:t}){var h;const[n,s]=g.useState(!1),a=((h=e==null?void 0:e.upgrade)==null?void 0:h.state)??"idle",o=Iwe(e==null?void 0:e.upgrade),i=g.useRef(!1),l=g.useCallback(async()=>{if(Sn(i.current||a==="running")){i.current=!0;try{await fetch("/api/upgrade",{method:"POST"})}catch{}await t(),i.current=!1}},[a,t]);g.useEffect(()=>{if(a!=="running")return;const f=window.setInterval(t,3e3);return()=>window.clearInterval(f)},[a,t]);const u=g.useCallback(async()=>{const f=e==null?void 0:e.command;!f||!await ho(f)||(s(!0),window.setTimeout(()=>s(!1),1600))},[e==null?void 0:e.command]);return{upgradeState:a,upgradeFailure:o,startUpgrade:l,copyCommand:u,cmdCopied:n}}const r3="agent-dag.browserWatch.seenMs";function L0e(e,t){return e.filter(n=>n.startMs>t)}function I0e(){const[e,t]=g.useState(()=>Number(nt(r3))||0),[n,s]=g.useState([]),[a,o]=g.useState(!1);g.useEffect(()=>{let u=!0;const h=()=>{fetch("/api/browser-watch?live=0").then(p=>p.ok?p.json():null).then(p=>{var m;!u||!(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()=>{u=!1,clearInterval(f)}},[]);const i=g.useMemo(()=>L0e(n,e).length,[n,e]),l=g.useCallback(u=>{t(u),st(r3,String(u))},[]);return{watchOn:a,setWatchOn:o,watchUnseen:i,markWatchSeen:l}}const hB="agent-dag.character-enabled",fB="agent-dag.fm-volume",O0e=1,a3="agent-dag.fm-source",xje=[{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 P0e(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 D0e(e){return e!=="0"}function F0e(){return D0e(nt(hB))}function B0e(e){return KD(e,O0e)}function q0e(){return B0e(nt(fB))}const pB=["--err","--inflight","--ok","--warn","--muted","--grid-line","--minimap-mask","--panel","--line","--accent","--text-dim","--bg"];function o3(e){const t={};for(const n of pB)t[n]=e(n);return t}function U0e(e){return t=>e[t]??""}function W0e(e,t){return pB.every(n=>e[n]===t[n])}function H0e(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 l=!1;const u=()=>{i!==s||l||(l=!0,o())};if(!e.startViewTransition||e.hidden||t()){u();return}e.documentElement.dataset.themeTransition="true";try{const h=e.startViewTransition(u);n=h,h.ready.catch(()=>{}),h.updateCallbackDone.catch(()=>{u()}),h.finished.then(()=>{n===h&&(n=null,delete e.documentElement.dataset.themeTransition)},()=>{n===h&&(u(),n=null,delete e.documentElement.dataset.themeTransition)})}catch{delete e.documentElement.dataset.themeTransition,u()}}}}function i3(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}function z0e(){const[e,t]=g.useState(Bte),[n,s]=g.useState(qte),[a,o]=g.useState(ite),i=g.useRef(a),[l]=g.useState(()=>H0e(document,()=>{try{return window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!0}})),u=g.useCallback(N=>{const x=typeof N=="function"?N(i.current):N;x!==i.current&&(i.current=x,l.run(()=>kt.flushSync(()=>o(x))))},[l]);g.useEffect(()=>()=>l.cancel(),[l]);const[h,f]=g.useState(F0e),[p,m]=g.useState(wee),[w,v]=g.useState(()=>o3(i3)),j=g.useMemo(()=>U0e(w),[w]),b=g.useCallback(N=>qme(N,j),[j]);return g.useEffect(()=>{document.documentElement.dataset.textSize=e,st(q1,e)},[e]),g.useEffect(()=>{document.documentElement.dataset.density=n,st(U1,n)},[n]),g.useEffect(()=>{const N=x=>{x.storageArea===mr()&&((x.key===q1||x.key===null)&&t(BN(x.newValue)),(x.key===U1||x.key===null)&&s(o5(x.newValue)))};return window.addEventListener("storage",N),()=>window.removeEventListener("storage",N)},[]),g.useLayoutEffect(()=>{document.documentElement.dataset.theme=a,document.documentElement.dataset.colorScheme=oc[a].colorScheme,st(XD,a),v(N=>{const x=o3(i3);return W0e(N,x)?N:x})},[a]),g.useEffect(()=>{st(hB,h?"1":"0")},[h]),g.useEffect(()=>{st(BD,p)},[p]),g.useEffect(()=>{const N=document.querySelector('meta[name="theme-color"]'),x=w["--panel"];N&&x&&N.setAttribute("content",x)},[w]),{textSize:e,setTextSize:t,density:n,setDensity:s,theme:a,setTheme:u,characterEnabled:h,setCharacterEnabled:f,character:p,setCharacter:m,palette:w,minimapNodeFill:b}}function V0e(e){const t=g.useRef(null),[n,s]=g.useState(!1),[a,o]=g.useState(()=>new Set),i=g.useMemo(()=>{const u=new Set;for(const h of e.current.agents.values())for(const f of h.tools)u.add(m8(f.name));return Object.keys(p8).filter(h=>u.has(h))},[e.current,e.current.revision]);g.useEffect(()=>{if(i.length<=1){s(!1);return}let u=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=QJ(p,m,8);s(v=>v===w?v:w)}u=window.setTimeout(h,300)};return h(),()=>window.clearTimeout(u)},[i.length]);const l=g.useCallback(u=>{o(h=>{const f=new Set(h);return f.has(u)?f.delete(u):f.add(u),f})},[]);return{presentCats:i,hiddenCats:a,toggleCat:l,catBarRef:t,catBarOccluded:n}}function G0e(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 l(m,w,v=w.figure){if(!n||n.state!=="running")return!1;const j=D1(m,v),b=Vee(w.level,j),N=n.currentTime;for(const x of j.notes){const S=n.createOscillator(),C=n.createGain();S.type=j.type??"sine",S.frequency.value=x.hz;const _=N+x.at,M=_+x.ms/1e3;C.gain.setValueAtTime(gA,_),C.gain.exponentialRampToValueAtTime(b,_+Gee),C.gain.exponentialRampToValueAtTime(gA,M),S.connect(C).connect(n.destination),S.start(_),S.stop(M+.02)}return!0}async function u(m,w){var b;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),x=window.speechSynthesis.getVoices();N.voice=x.find(S=>S.voiceURI===v.voiceURI)??null,N.rate=v.rate,N.pitch=v.pitch,N.volume=Kee(w.level);try{return window.speechSynthesis.cancel(),window.speechSynthesis.speak(N),"played"}catch{return"unavailable"}}if(!n||n.state!=="running")return"locked";let j;try{j=await n.decodeAudioData(v.bytes.slice(0))}catch{return"broken"}try{const N=n.createBufferSource(),x=n.createGain();return N.buffer=j,x.gain.setValueAtTime(Yee(v.normalizationGain,w.level),n.currentTime),N.connect(x).connect(n.destination),s.add(N),(b=N.addEventListener)==null||b.call(N,"ended",()=>s.delete(N)),N.start(n.currentTime),"played"}catch{return"unavailable"}}function h(m,w=!1){var b,N;if(!w&&!e.enabled())return!1;const v=nte((b=e.prefs)==null?void 0:b.call(e),m),j=((N=e.customSelection)==null?void 0:N.call(e)[m])??null;return j&&e.loadCustom?(u(j,v).then(x=>{var S;x==="played"||x==="locked"||((x==="missing"||x==="broken")&&((S=e.onCustomFailure)==null||S.call(e,m,j)),l(m,{...v,figure:Jn},Jn))}),!0):!n||n.state!=="running"?!1:l(m,v)}function f(m,w=wi){return u(m,{level:dm(w),figure:Jn}),!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 K0e({chimesRef:e,soundOnRef:t,tonePrefsRef:n,customSelectionsRef:s,fallbackCustomRef:a}){g.useEffect(()=>{const o=G0e({enabled:()=>t.current===!0,prefs:()=>n.current,customSelection:()=>s.current,loadCustom:qee,onCustomFailure:(h,f)=>a.current(h,f)});e.current=o;const i=["pointerdown","pointerup","keydown"],l=()=>{for(const h of i)window.removeEventListener(h,u,{capture:!0})},u=()=>{var h;o.unlock(),((h=o.context)==null?void 0:h.state)==="running"&&l()};for(const h of i)window.addEventListener(h,u,{capture:!0});return l},[])}function Y0e(){const[e,t]=g.useState(q0e),[n,s]=g.useState(()=>QY(nt(jT))),[a,o]=g.useState(()=>JY(nt(NT))),[i,l]=g.useState(()=>eX(nt(a3),n,P0e)),[u,h]=g.useState(()=>new Set),[f,p]=g.useState(0);g.useEffect(()=>{st(fB,String(e))},[e]),g.useEffect(()=>{st(NT,a?"1":"0")},[a]),g.useEffect(()=>{st(jT,JSON.stringify(n))},[n]),g.useEffect(()=>{st(a3,i)},[i]);const m=g.useCallback((N,x=!1)=>{s(S=>{const C=S.find(_=>_.id===N.id);return C?!x||!N.radio||!C.radio||C.url===N.url&&JSON.stringify(C.radio)===JSON.stringify(N.radio)?S:S.map(_=>_.id===N.id?{..._,url:N.url,radio:N.radio}:_):[...S,N]}),h(S=>{if(!S.has(N.id))return S;const C=new Set(S);return C.delete(N.id),C})},[]),w=g.useCallback((N,x)=>{const S=x.trim();!S||S.length>rD||s(C=>C.map(_=>_.id===N?{..._,name:S}:_))},[]),v=g.useCallback(N=>{s(x=>x.filter(S=>S.id!==N)),l(x=>tX(x,N)),h(x=>{if(!x.has(N))return x;const S=new Set(x);return S.delete(N),S})},[]),j=g.useCallback((N,x=!1)=>{const S=ST(N),C=u.has(S);N===i&&!C&&!x||(C&&h(_=>{const M=new Set(_);return M.delete(S),M}),l(N),p(_=>_+1))},[i,u]),b=g.useCallback((N,x)=>{const S=ST(N);h(C=>{if(C.has(S)===x)return C;const M=new Set(C);return x?M.add(S):M.delete(S),M})},[]);return{fmVolume:e,setFmVolume:t,fmMuted:a,setFmMuted:o,fmSource:i,customFmStations:n,unavailableFmStations:u,fmPlayRequest:f,addFmStation:m,renameFmStation:w,removeFmStation:v,pickFmSource:j,markFmStationAvailability:b}}function X0e(e){const[t,n]=g.useState(null),[s,a]=g.useState(!1),[o,i]=g.useState(null),l=g.useRef(0);g.useEffect(()=>{if(!e||!co())return;let v=!1;const j=l.current;return fetch("/api/desktop-update").then(b=>b.ok?b.json():null).then(b=>{if(v||l.current!==j)return;const N=CO(b);N&&n(N)}).catch(()=>{}),()=>{v=!0}},[e]);const u=Qye(t),h=g.useRef(!1),f=g.useRef(0),p=g.useRef(0);g.useEffect(()=>()=>window.clearTimeout(f.current),[]);const m=g.useCallback(async v=>{if(!Sn(h.current))return;const j=++p.current;window.clearTimeout(f.current),h.current=!0,a(!0),i(null);const b=N=>{j===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 b(twe(await N.json().catch(()=>null)))}catch{return b("unreachable")}j===p.current&&(f.current=window.setTimeout(()=>b("timeout"),T8))},[]),w=g.useCallback(v=>{if(co())try{const j=CO(JSON.parse(v));j&&(l.current++,n(j),j.status!=="ready"&&(p.current++,window.clearTimeout(f.current),h.current=!1,a(!1)))}catch{}},[]);return{desktopUpdateRestarting:s,desktopUpdateFailure:o,readyAppUpdate:u,appUpdate:t,askDesktopUpdateRestart:m,onDesktopUpdateEvent:w}}const jf="agent-dag.autoRestart",l3="agent-dag.bundleReloadedFor";function Z0e({now:e,stateRef:t,version:n,notice:s,noticeOpen:a,upgradeFailure:o,paused:i}){const[l,u]=g.useState(()=>nt(jf)!=="0"),h=g.useRef(!1),f=g.useCallback(()=>{const U=!l;h.current=!0,vs(jf),u(U),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:U})}).then(B=>B.ok?B.json():null).then(B=>{var A;B!=null&&B.ok&&u(((A=B.prefs)==null?void 0:A.autoUpdate)!==!1)}).catch(()=>{})},[l]),[p,m]=g.useState(!1),[w,v]=g.useState("restart"),[j,b]=g.useState(null),N=g.useRef(!1),x=g.useRef(null),S=g.useRef(0),C=g.useRef(null),_=g.useCallback(async U=>{if(!Sn(N.current))return;const B=(U==null?void 0:U.upgrade)===!0,A=(U==null?void 0:U.whenIdle)===!0;N.current=!0,x.current=o;const q=++S.current,T=()=>{v(B?"npx":"restart"),m(!0)};A||T();try{window.sessionStorage.setItem("agent-dag.restartPending",(s==null?void 0:s.to)??"")}catch{}let F=!1;try{const O=await fetch("/api/restart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(A?{upgrade:B,whenIdle:A}:{upgrade:B})});F=A&&O.status===409}catch{}if(F){N.current=!1,C.current=null;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}return}A&&T(),window.setTimeout(()=>{if(S.current===q&&N.current){N.current=!1,m(!1);try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}}},B?18e4:3e4)},[s==null?void 0:s.to,o]);g.useEffect(()=>{const U=EO(t.current.agents.values())>0,B=Bwe({enabled:l,kind:s==null?void 0:s.kind,canRestart:(n==null?void 0:n.canRestart)===!0,noticeOpen:a,visible:document.visibilityState==="visible",busy:U,idleSince:C.current,now:e});C.current=B.idleSince,B.restart&&_({whenIdle:!0})},[l,s==null?void 0:s.kind,n==null?void 0:n.canRestart,a,e,_]);const M=EO(t.current.agents.values()),R=Fwe(M,i),P=O8({enabled:l,kind:s==null?void 0:s.kind,canRestart:(n==null?void 0:n.canRestart)===!0,noticeOpen:a,visible:document.visibilityState==="visible",busy:M>0,idleSince:C.current,now:e});g.useEffect(()=>{const U=n==null?void 0:n.running;let B=null,A=null;try{B=window.sessionStorage.getItem("agent-dag.restartPending"),A=window.sessionStorage.getItem(l3)}catch{return}const q=Lwe({bundle:"3.47.0",running:U,pending:B,lastTried:A});if(q==="reload"){try{window.sessionStorage.setItem(l3,U??"")}catch{return}window.location.reload();return}if(q!=="confirm")return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}N.current=!1,m(!1),b(U??null);const T=window.setTimeout(()=>b(null),6e3);return()=>window.clearTimeout(T)},[n==null?void 0:n.running]),g.useEffect(()=>{if(p&&Owe({asked:x.current,reported:o})){try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}N.current=!1,m(!1)}},[p,o]);const L=g.useCallback(U=>{var B,A;if(!h.current){const q=nt(jf)==="0";vs(jf),q&&((B=U.prefs)==null?void 0:B.autoUpdate)!==!1?(u(!1),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:!1})}).catch(()=>{})):u(((A=U.prefs)==null?void 0:A.autoUpdate)!==!1)}},[]);return{autoRestart:l,toggleAutoRestart:f,restarting:p,restartMode:w,restartedTo:j,askRestart:_,restartCopy:R,restartFuseMs:P,loadAutoRestartPrefs:L}}function J0e(){const[e,t]=g.useState([]),n=g.useRef(new Set),[s,a]=g.useState(null),[o,i]=g.useState(void 0);g.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(nR(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?oj:m6))})};return p(),()=>{h=!1,window.clearTimeout(f)}},[]);const l=g.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(nR(m.pending,m.aliases)):t(w=>w.filter(v=>v.fp!==f))}catch{}finally{a(null)}}},[s]),u=g.useCallback(h=>{s||(n.current.add(h),t(f=>[...f]))},[s]);return{lanPending:e,lanDeferred:n,lanBusy:s,answerLanPair:l,deferLanPair:u,lanStatus:o}}const Q0e=6e4;function e1e({enabled:e,lanStatus:t,now:n}){const[s,a]=g.useState(null),[o,i]=g.useState(()=>new Set),[l,u]=g.useState(null),h=g.useCallback(N=>{N!=null&&N.ok&&Array.isArray(N.accounts)&&a(N.accounts)},[]),f=g.useCallback(async N=>{try{const x=await fetch(`/api/claude-accounts${N?"?refresh=1":""}`);x.ok&&h(await x.json())}catch{}},[h]);g.useEffect(()=>{e&&f(!1)},[e,f]),g.useEffect(()=>{if(!e)return;let N=Date.now();const x=()=>{document.visibilityState!=="visible"||Date.now()-N<Q0e||(N=Date.now(),f(!1))};return document.addEventListener("visibilitychange",x),window.addEventListener("focus",x),()=>{document.removeEventListener("visibilitychange",x),window.removeEventListener("focus",x)}},[e,f]);const p=g.useMemo(()=>e?ave(s,{lan:t,now:n,closed:o}):[],[e,s,t,n,o]),m=g.useRef(p);m.current=p;const w=g.useCallback(N=>{N.length&&i(x=>new Set([...x,...N]))},[]),v=g.useCallback(()=>{const N=m.current;N.length&&(w(N.map(x=>x.id)),fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"reauth-later",incidents:N.map(x=>({key:x.key,since:x.since}))})}).catch(()=>{}))},[w]),j=g.useRef(l);j.current=l;const b=g.useCallback(N=>{const x=j.current;w(ove(x?[x,...m.current]:m.current,N))},[w]);return{rows:p,signingIn:l,observe:h,signIn:u,signedIn:b,refresh:g.useCallback(()=>{f(!0)},[f]),closeSignIn:g.useCallback(()=>u(null),[]),later:v}}const mB=288,t1e=mB;function n1e(e,t,n){return e?"session-list":t||n?"accounts":null}function c3(e){return e==="session-list"?t1e:e==="accounts"?mB:0}const s1e=240,r1e=20;function a1e(e){const t=g.useRef(0),n=g.useRef(e);return g.useLayoutEffect(()=>{n.current!==e&&(n.current=e,t.current=pd()?0:performance.now()+s1e+r1e)},[e]),t}const gB="agent-dag.sessionListOpen",yB="agent-dag.accountsPanelOpen";function o1e(){return nt(gB)==="1"}function i1e(e){st(gB,e?"1":"0")}function l1e(){const e=nt(yB);return e===null?!0:e==="1"}function c1e(){const e=g.useRef(!1),t=g.useRef(!1),[n,s]=g.useState(()=>{const v=o1e();return v&&I1()?(e.current=!0,!1):v});g.useEffect(()=>{if(n)e.current=!1;else if(e.current)return;i1e(n)},[n]);const a=g.useRef(!1),[o,i]=g.useState(()=>{const v=l1e();return v&&n?(a.current=!0,!1):v&&I1()?(t.current=!0,!1):v});g.useEffect(()=>{if(o)t.current=!1;else if(t.current)return;!o&&a.current||st(yB,o?"1":"0")},[o]),g.useEffect(()=>{!n&&a.current&&(a.current=!1,i(!0))},[n]);const l=g.useCallback(()=>{s(v=>(v||i(j=>(j&&(a.current=!0),!1)),!v))},[]),u=g.useCallback(()=>{a.current=!1,i(v=>(v||s(!1),!v))},[]),h=g.useCallback(()=>{a.current=!1,i(v=>(v||s(!1),!0))},[]),f=g.useCallback(()=>s(!1),[]),p=g.useCallback(()=>{a.current=!1,s(!1)},[]),m=g.useCallback(()=>i(!1),[]),w=n1e(n,o,a.current);return{sessionListOpen:n,accountsPanelOpen:o,panel:w,toggleSessionList:l,toggleAccountsPanel:u,openAccountsPanel:h,closeSessionList:f,closeSessionListToCanvas:p,closeAccountsPanel:m}}const wB="agent-dag.detailOpen",xB="agent-dag.usagePanelOpen",vB="agent-dag.systemPanelOpen";function u1e(){return nt(wB)==="1"}function d1e(e){st(wB,e?"1":"0")}function h1e(){const e=nt(xB);return e===null?!0:e==="1"}function f1e(e){st(xB,e?"1":"0")}function p1e(){const e=nt(vB);return e===null?!0:e==="1"}function m1e(e){st(vB,e?"1":"0")}function g1e(e=0){const[t,n]=g.useState(u1e);g.useEffect(()=>{d1e(t)},[t]);const[s,a]=g.useState(h1e);g.useEffect(()=>{f1e(s)},[s]);const o=g.useRef(!1),[i,l]=g.useState(()=>{const u=p1e();return u&&s&&(I1()||eee(e))?(o.current=!0,!1):u});return g.useEffect(()=>{if(i)o.current=!1;else if(o.current)return;m1e(i)},[i]),sn("usage-panel",s),sn("machine-panel",i),{detailOpen:t,setDetailOpen:n,usagePanelOpen:s,setUsagePanelOpen:a,machinePanelOpen:i,setMachinePanelOpen:l}}const y1e={permission:"your permission",asked:"your answer"},w1e="No sessions are waiting for you.";function x1e(e){if(e.length===0)return"";const[t,...n]=e,s=t.waiting.kind,a=n.every(i=>i.waiting.kind===s)?y1e[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 Z0(e,t,n=w1e){return t!==""?t:e===""?"":n}function v1e({waitingSessions:e,watchUnseen:t,incidents:n=[]}){const[s,a]=g.useState(""),o=x1e(e);g.useEffect(()=>{a(m=>Z0(m,o))},[o]);const[i,l]=g.useState(""),u=t>0?`Browser watch has ${t} unread ${t===1?"finding":"findings"}.`:"";g.useEffect(()=>{l(m=>Z0(m,u,"Browser watch has no unread findings."))},[u]);const[h,f]=g.useState(""),p=R0e(n);return g.useEffect(()=>{f(m=>Z0(m,p,M0e))},[p]),{blockedSaid:s,watchSaid:i,setWatchSaid:l,incidentSaid:h}}const b1e="/icon-192.png",bB=Object.freeze({notifySwap:!0,notifyQuota:!1,notifyReset:!1,notifyStopped:!0,notifyElsewhere:!0});function u3(e){const t=n=>typeof(e==null?void 0:e[n])=="boolean"?e[n]:bB[n];return{notifySwap:t("notifySwap"),notifyQuota:t("notifyQuota"),notifyReset:t("notifyReset"),notifyStopped:t("notifyStopped"),notifyElsewhere:t("notifyElsewhere")}}function k1e({waitingSessions:e,liveSince:t,focusSession:n}){const[s,a]=g.useState(()=>typeof Notification>"u"?"denied":Notification.permission),[o,i]=g.useState(null),[l,u]=g.useState(!1),[h,f]=g.useState(!1),[p,m]=g.useState(bB),w=g.useCallback(P=>{const L=!p[P];m(U=>({...U,[P]:L})),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({[P]:L})}).then(U=>U.ok?U.json():null).then(U=>{U!=null&&U.ok&&m(u3(U.prefs))}).catch(()=>{})},[p]),v=g.useRef(()=>{}),j=g.useRef(new Set),b=Dn(e),N=g.useCallback(()=>{const P=!l;u(P),P&&(j.current=Jh(b.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(L=>L.ok?L.json():null).then(L=>{var U;L!=null&&L.ok&&(u(((U=L.prefs)==null?void 0:U.notifications)===!0),f(L.notificationsVetoed===!0))}).catch(()=>{})},[l]),x=typeof Notification<"u";g.useEffect(()=>{if(!o)return;const L=setTimeout(()=>i(null),o==="blocked"?8e3:4e3);return()=>clearTimeout(L)},[o]);const S=g.useCallback(()=>{typeof Notification>"u"||Notification.requestPermission().then(P=>{const L=P;a(L),L==="granted"?i("on"):L==="denied"&&i("blocked")})},[]);v.current=S;const C=g.useRef(null),_=e.map(P=>Zp(P.id,P.waiting)).join("|");g.useEffect(()=>{SG(C.current,s)&&(C.current=s,j.current=Jh(e))},[s]);const M=g.useRef(!1);g.useEffect(()=>{CG(M.current,t)&&(M.current=!0,j.current=Jh(e))},[t]),g.useEffect(()=>{if(typeof Notification>"u"||Notification.permission!=="granted"||!_G(C.current,t))return;const P=typeof document>"u"||!document.hidden,L=jG(e,j.current,P,l);for(const U of L)try{const B=new Notification(U.title,{body:U.body,tag:U.key,icon:b1e});B.onclick=()=>{window.focus(),n(U.sessionId),B.close()}}catch{}j.current=P?Jh(e):NG(e,L,j.current)},[_,t]);const R=g.useCallback(P=>{var L;u(((L=P.prefs)==null?void 0:L.notifications)===!0),f(P.notificationsVetoed===!0),m(u3(P.prefs))},[]);return{notifyPermission:s,notifySaid:o,notifyOn:l,notifyVetoed:h,toggleNotify:N,notifySupported:x,askForNotifications:S,loadNotifyPrefs:R,accountNotify:p,toggleAccountNotify:w}}function j1e({openedTool:e,usageHistoryOpen:t,contextFor:n,tourOpen:s,summaryFor:a,browserWatchOpen:o,keyHelpOpen:i,releaseNotes:l,feedbackOpen:u,trafficRadarOpen:h=!1}){const f=Dn(i),p=g.useRef(!1);return p.current=e!=null||t||n!=null||s||a!=null||o||i||l!=null||u||h,{keyHelpOpenRef:f,modalOpenRef:p}}function N1e({stateRef:e,tourOpen:t,releaseNotes:n}){const[s,a]=g.useState(null),o=g.useCallback((A,q)=>a({agentId:A,toolId:q}),[]),[i,l]=g.useState(null),[u,h]=g.useState(null),f=g.useCallback(A=>h(A),[]),[p,m]=g.useState(!1),[w,v]=g.useState(!1),[j,b]=g.useState(!1),[N,x]=g.useState(!1),[S,C]=g.useState(!1),[_,M]=g.useState(null),R=g.useCallback(A=>{M(A??null),C(!0)},[]);sn("tool-detail",s!==null),sn("session-summary",i!==null),sn("context-window",u!==null),sn("keyboard-help",p),sn("usage-history",w),sn("browser-watch",j),sn("feedback",S);const P=s?mV(e.current.agents,s.agentId,s.toolId):null,L=u?e.current.agents.get(u):void 0,{keyHelpOpenRef:U,modalOpenRef:B}=j1e({openedTool:P,usageHistoryOpen:w,contextFor:u,tourOpen:t,summaryFor:i,browserWatchOpen:j,keyHelpOpen:p,releaseNotes:n,feedbackOpen:S,trafficRadarOpen:N});return{setOpenedToolKey:a,openTool:o,openedTool:P,summaryFor:i,setSummaryFor:l,contextFor:u,setContextFor:h,openContext:f,contextAgent:L,keyHelpOpen:p,setKeyHelpOpen:m,usageHistoryOpen:w,setUsageHistoryOpen:v,browserWatchOpen:j,setBrowserWatchOpen:b,trafficRadarOpen:N,setTrafficRadarOpen:x,feedbackOpen:S,setFeedbackOpen:C,feedbackPrefill:_,setFeedbackPrefill:M,openFeedback:R,keyHelpOpenRef:U,modalOpenRef:B}}function S1e({stateRef:e,pinnedRef:t,measuredRef:n,positionsRef:s,lastLayoutSigRef:a,forgetRemovals:o,clearSelection:i,rerender:l,modalOpenRef:u}){const[h,f]=g.useState(!1),p=g.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}e.current=Jj(),t.current.clear(),n.current.clear(),s.current.clear(),a.current="",s8(),o(),i(),l()},[l,i,o]),m=Dn(h),w=g.useCallback(v=>{const j=Wwe(v,{confirmOpen:m.current,modalOpen:u.current});j==="confirm"?f(!0):j==="clear"&&(f(!1),p())},[p]);return{clearConfirmOpen:h,setClearConfirmOpen:f,requestClear:w}}const d3="agent-dag.oldNameNoticeDismissed";function C1e(e){const[t,n]=g.useState(()=>nt(d3)??""),s=e!=null&&e.invokedAs&&e.invokedAs!==Pt?e.invokedAs:null,a=s!=null&&t!==s,o=g.useCallback(()=>{s&&(n(s),st(d3,s))},[s]);return{oldName:s,oldNameOpen:a,dismissOldName:o}}const _1e=300*1e3,E1e=1800*1e3,T1e=8e3,A1e=3e4;function h3(e){return fetch("/api/rating",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)}).catch(()=>null)}function R1e({modalOpenRef:e}){const t=g.useCallback(()=>wl({appModal:e.current,dialogDepth:cn.dialogDepth()}),[e]),[n,s]=g.useState("hidden"),[a,o]=g.useState(null),[i,l]=g.useState(!1),u=g.useRef(n);u.current=n,g.useEffect(()=>{let w=!1;const v=async()=>{if(u.current==="thanks"||u.current==="hidden"&&(document.hidden||t()))return;const N=await fetch("/api/rating").then(x=>x.ok?x.json():null).catch(()=>null);w||!N||s(x=>x==="thanks"?x:N.ask===!0?"asking":"hidden")},j=window.setTimeout(v,_1e),b=window.setInterval(v,E1e);return()=>{w=!0,window.clearTimeout(j),window.clearInterval(b)}},[t]),g.useEffect(()=>{if(n!=="thanks"||i)return;const w=a!==null&&a<=6?A1e:T1e;let v=0;const j=()=>{t()?v=window.setTimeout(j,w):s("hidden")};return v=window.setTimeout(j,w),()=>window.clearTimeout(v)},[n,a,i,t]);const h=g.useCallback(w=>{o(w),l(!1),s("thanks"),h3({score:w})},[]),f=g.useCallback(w=>l(w),[]),p=g.useCallback(()=>{s("hidden"),h3({later:!0})},[]),m=g.useCallback(()=>s("hidden"),[]);return{ratingPhase:n,ratingScore:a,answerRating:h,rateLater:p,closeRating:m,holdThanks:f}}function M1e({chimesRef:e,setTonePrefs:t,tonePrefsRef:n,previewTone:s}){const[a,o]=g.useState(()=>Tee(nt)),i=Dn(a),[l,u]=g.useState([]),h=g.useCallback(x=>{o(S=>{const C={...S,[x]:null};return i.current=C,C}),vs(Ru[x])},[]),f=g.useCallback((x,S)=>{const C=i.current[x];S&&C!==S||(h(x),t(_=>{const M={..._,[x]:{..._[x],figure:Jn}};return n.current=M,M}),st(fp[x],Jn))},[h]),p=Dn(f);g.useEffect(()=>{let x=!0;return Bee().then(S=>{if(!x)return;u(S);const C=new Set(S.map(_=>_.id));for(const _ of Mu){const M=i.current[_];M&&!C.has(M)&&p.current(_,M)}},()=>{}),()=>{x=!1}},[]);const m=g.useCallback((x,S)=>{if(!l.some(_=>_.id===S))return;const C={...i.current,[x]:S};i.current=C,o(C),st(Ru[x],S),s(x,!0)},[l,s]),w=g.useCallback(async x=>{var M;const S=P1(l.length);if(S)throw new Error(S);const C=window.AudioContext??window.webkitAudioContext;if(!C)throw new Error("This browser cannot decode audio files.");const _=new C;try{const R=await Iee(x,L=>_.decodeAudioData(L));await pA(R);const P=td(R);u(L=>[...L.filter(U=>U.id!==P.id),P])}finally{(M=_.close)==null||M.call(_)}},[l.length]),v=g.useCallback(async x=>{const S=P1(l.length);if(S)throw new Error(S);const C=Oee(x);await pA(C);const _=td(C);u(M=>[...M.filter(R=>R.id!==_.id),_])},[l.length]),j=g.useCallback(async(x,S)=>{const C=l.find(M=>M.id===x),_=S.trim().slice(0,80);!C||!_||_===C.name||(await Uee(x,_),u(M=>M.map(R=>R.id===x?{...R,name:_}:R)))},[l]),b=g.useCallback(async x=>{await Wee(x),u(M=>M.filter(R=>R.id!==x));const S=i.current,C=Aee(S,x);i.current=C,o(C);const _=Mu.filter(M=>S[M]===x);for(const M of _)vs(Ru[M]),st(fp[M],Jn);_.length>0&&t(M=>{const R={...M};for(const P of _)R[P]={...R[P],figure:Jn};return n.current=R,R})},[]),N=g.useCallback(x=>{var _,M;const S=Mu.find(R=>i.current[R]===x),C=S?n.current[S].level:wi;(_=e.current)==null||_.unlock(),(M=e.current)==null||M.previewCustom(x,C)},[]);return{customSelections:a,customSelectionsRef:i,customAssets:l,clearCustomOnly:h,fallbackCustomRef:p,selectCustomTone:m,importNotificationAudio:w,createNotificationVoice:v,renameCustomAsset:j,deleteCustomAsset:b,previewCustomAsset:N}}function $1e(e){const[t,n]=g.useState(()=>tte(nt)),s=Dn(t),a=g.useRef(null),o=g.useCallback((l,u=!1)=>{var h,f;if((h=e.current)==null||h.unlock(),a.current!==null&&clearTimeout(a.current),a.current=null,!u){(f=e.current)==null||f.play(l,!0);return}a.current=setTimeout(()=>{var p;a.current=null,(p=e.current)==null||p.play(l,!0)},Xee)},[]),i=g.useCallback((l,u)=>{n(h=>{const f={level:dm(u.level??h[l].level),figure:VD(l,u.figure??h[l].figure)};return st(YD[l],String(f.level)),st(fp[l],f.figure),{...h,[l]:f}}),o(l,!0)},[o]);return g.useEffect(()=>()=>{a.current!==null&&clearTimeout(a.current)},[]),{tonePrefs:t,setTonePrefs:n,tonePrefsRef:s,previewTone:o,changeTone:i}}const L1e=15e3;function I1e(e){return e.visibilityState==="visible"&&e.hasFocus()}function O1e(e,t){return t||e===!0}function P1e(){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 D1e(){g.useEffect(()=>{const e=P1e();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=I1e(document);O1e(t,i)&&n(i),t=i},a=()=>{t&&n(!1),t=!1};s();const o=window.setInterval(s,L1e);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 F1e({loadAutoRestartPrefs:e,loadNotifyPrefs:t,loadReportsPrefs:n}){g.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 J0="agent-dag.versionNoticeDismissed",B1e=15*6e4;function q1e(e){const[t,n]=g.useState(null),[s,a]=g.useState(()=>nt(J0)??""),o=g.useRef(0),[i,l]=g.useState(!1),u=g.useCallback((j=!1)=>(j&&(o.current=Date.now(),l(!0)),fetch(j?"/api/version?refresh=1":"/api/version").then(b=>b.ok?b.json():null).then(b=>(b&&n(b),b??null)).catch(()=>null).finally(()=>{j&&l(!1)})),[]),h=g.useCallback(()=>{u(Date.now()-o.current>=B1e)},[u]);g.useEffect(()=>{u();const j=window.setInterval(h,5*6e4),b=()=>{document.visibilityState==="visible"&&h()};return document.addEventListener("visibilitychange",b),()=>{window.clearInterval(j),document.removeEventListener("visibilitychange",b)}},[u,h]),g.useEffect(()=>{e&&u()},[e,u]);const f=(t==null?void 0:t.notice)??null,p=$8(f),m=owe(f,s),w=g.useCallback(()=>{a(""),st(J0,"")},[]),v=g.useCallback(()=>{f&&(a(p),st(J0,p))},[f,p]);return{version:t,notice:f,noticeOpen:m,showNotice:w,dismissNotice:v,versionChecking:i,loadVersion:u}}function U1e({version:e,readyAppUpdate:t}){const[n,s]=g.useState(!1),a=g.useRef(null),[o,i]=g.useState(null),l=o&&t?t.version:null,u=g.useRef(null);g.useEffect(()=>{!l||u.current===l||(u.current=l,fetch("/api/desktop-update/seen",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({version:l})}).catch(()=>{}))},[l]);const h=g.useRef(!1);g.useEffect(()=>{if(h.current)return;const b=mr(),N=_ve(b),x=$ve({stored:N,running:(e==null?void 0:e.running)??null,notes:OO,remembers:Eve(b)});if(x.reason==="no-version")return;h.current=!0,x.record&&Tve(b,x.record);let S=!0;return(async()=>{var P;let _=Ave(b);if(co())try{const L=await fetch("/api/prefs");if(!L.ok)throw new Error("desktop tour preferences unavailable");const U=await L.json();if(!(U!=null&&U.ok))throw new Error("desktop tour preferences unavailable");const B=((P=U.prefs)==null?void 0:P.tourSeen)===!0;_&&!B&&fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tourSeen:!0}),keepalive:!0}).catch(()=>{}),_=_||B}catch{_=!0}if(!S)return;const M=Mve({tourSeen:_,decision:x}),R=x.show.length?{entries:x.show,since:N,firstRun:!1}:null;M.tour&&s(!0),M.notes==="now"?i(R):M.notes==="after"&&(a.current=R)})(),()=>{S=!1}},[e==null?void 0:e.running]);const f=(e==null?void 0:e.running)??"3.47.0",p=g.useMemo(()=>Y8(OO,null,f),[f]),m=g.useCallback(()=>{i({entries:p,since:null,firstRun:!1})},[p]),w=g.useCallback(()=>s(!0),[]),v=g.useCallback(()=>i(null),[]),j=g.useCallback(()=>{s(!1),Rve(mr()),co()&&fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tourSeen:!0}),keepalive:!0}).catch(()=>{});const b=a.current;a.current=null,b&&i(b)},[]);return{tourOpen:n,openTour:w,closeTour:j,releaseNotes:o,closeReleaseNotes:v,chipVersion:f,openReleaseNotes:m}}function W1e(){const[e,t]=g.useState(void 0),[n,s]=g.useState(!1),a=g.useRef(!1);return a.current=e===!0&&!n,g.useEffect(()=>i0e(()=>a.current),[]),{loadReportsPrefs:g.useCallback(i=>{var l;t(((l=i.prefs)==null?void 0:l.reports)!==!1),s(i.reportsVetoed===!0)},[])}}function H1e(e){const[t,n]=g.useState(null);g.useEffect(()=>{const l=nt("agent-dag.sound");n(l===null?!0:l==="on")},[]);const s=g.useCallback(()=>{n(l=>{var h,f;const u=l!==!0;return st("agent-dag.sound",u?"on":"off"),u?(h=e.current)==null||h.unlock():(f=e.current)==null||f.silence(),u})},[]),a=g.useCallback(l=>{s()},[s]),o=Dn(a),i=Dn(t);return{soundOn:t,toggleSound:s,activateSoundRef:o,soundOnRef:i}}function z1e(){const[e,t]=g.useState(dee),n=g.useCallback((o,i)=>{t(l=>hee(l,o,i))},[]),s=g.useCallback(()=>t(o=>({...o,open:!1})),[]),a=g.useCallback(o=>t(i=>({...i,section:o})),[]);return{settingsOpen:e.open,settingsSection:e.section,settingsLandOn:e.landOn,openSettings:n,closeSettings:s,showSection:a}}const V1e="agent-dag.autoFitDisabled";function G1e(e){const t=g.useRef(!1),[n,s]=g.useState(!1);g.useEffect(()=>{vs(V1e)},[]);const a=g.useCallback(()=>{t.current||(t.current=!0,s(!0))},[]),o=g.useCallback(()=>{t.current=!1,s(!1),e(400)},[e]);return{autoFitDisabled:n,autoFitDisabledRef:t,disableAutoFit:a,enableAutoFitAndRefit:o}}function K1e(){return r.jsx(Zj,{children:r.jsx(u0e,{children:r.jsx(Y1e,{})})})}function Y1e(){var Mc;const e=ec(),t=g.useState(Jj)[0],n=g.useRef(t),[,s]=g.useState(0),a=g.useCallback(()=>s(ut=>ut+1),[]),{sessionListOpen:o,accountsPanelOpen:i,panel:l,toggleSessionList:u,toggleAccountsPanel:h,openAccountsPanel:f,closeSessionList:p,closeSessionListToCanvas:m,closeAccountsPanel:w}=c1e(),{detailOpen:v,setDetailOpen:j,usagePanelOpen:b,setUsagePanelOpen:N,machinePanelOpen:x,setMachinePanelOpen:S}=g1e(c3(l)),{selectedIds:C,primarySelectedId:_,selectAgent:M,clearSelection:R,pruneSelectionToBoard:P}=yde(n,j),L=Nl(i,200),U=Nl(o,200),B=qE(o,U),A=Nl(b,130),q=Nl(x,130),T=g.useRef(null),F=H1e(T),{activateSoundRef:O,soundOnRef:K}=F,V=$1e(T),{setTonePrefs:H,tonePrefsRef:D,previewTone:I}=V,W=M1e({chimesRef:T,setTonePrefs:H,tonePrefsRef:D,previewTone:I}),{customSelectionsRef:Z,fallbackCustomRef:z}=W,X=z1e(),{openSettings:Y}=X;K0e({chimesRef:T,soundOnRef:K,tonePrefsRef:D,customSelectionsRef:Z,fallbackCustomRef:z});const J=f0e(n),{pauseGate:Q,paused:te,togglePause:le}=J,de=g.useRef(()=>{}),{live:oe,tabCapped:re,everConnected:he,liveSince:pe}=ide({stateRef:n,rerender:a,pauseGate:Q,chimesRef:T,desktopUpdateRef:de}),Le=q1e(oe),{version:ge,notice:ve,noticeOpen:je,loadVersion:Ee}=Le,xe=X0e(oe),{readyAppUpdate:Ie,onDesktopUpdateEvent:De}=xe;de.current=De,D1e();const We=U1e({version:ge,readyAppUpdate:Ie}),{tourOpen:Ke,openTour:ye,releaseNotes:Fe}=We,{workspace:$e,providers:Re,providersRef:rt}=m0e(oe),He=c3(l==="accounts"&&!Re.claude?null:l),se=a1e(He),ke=qE(i,L)&&Re.claude,[Ae,Oe]=g.useState(!1),be=g.useCallback(()=>{f(),Oe(!0)},[f]);g.useEffect(()=>{i||Oe(!1)},[i]);const fe=g.useCallback(()=>Oe(!1),[]),_e=C1e(ge),Ve=$0e({version:ge,loadVersion:Ee}),{upgradeFailure:ot}=Ve,tt=N1e({stateRef:n,tourOpen:Ke,releaseNotes:Fe}),wt=R1e({modalOpenRef:tt.modalOpenRef}),{openTool:$t,setSummaryFor:Vt,setContextFor:er,openContext:Ss,setKeyHelpOpen:Wn,setUsageHistoryOpen:es,setBrowserWatchOpen:Cs,keyHelpOpenRef:yn,modalOpenRef:Hn}=tt,Me=W1e(),qe=I0e(),{watchOn:Je,watchUnseen:_t}=qe,Nt=Rd(),[ts,zn]=g.useState(null),[wn,Cr]=g.useState(!1),xn=g.useCallback(()=>Cr(!1),[]),rn=ut=>{Bye(ut),Y("integrations")},_s=ut=>{ut&&SO(ut),Y("integrations")},tr=g.useCallback(()=>zn(null),[]),ns=PS().filter(ut=>vj(Nt,ut.kind)),Es=Dn(ut=>{const Br=ns.find(ig=>ig.kind===ut);Br&&zn(Br.kind)}),_r=g.useCallback(ut=>{SO(ut),Y("integrations")},[Y]),Er=ns.length>0;g.useEffect(()=>{Er&&Eye()},[Er]);const Ts=J0e(),[ga,xt]=g.useState(0),{presentCats:ya,hiddenCats:As,toggleCat:wa,catBarRef:nr,catBarOccluded:Tr}=V0e(n),Ar=g.useRef(null),[Rs,dn]=g.useState(0),Lt=wde({stateRef:n,rerender:a,pruneSelectionToBoard:P,setContextFor:er,setSummaryFor:Vt});xY({stateRef:n,now:Lt,enabled:Re.claude});const hn=x0e(Re.claude||Re.codex),xa=A0e(hn,Lt),go=e1e({enabled:Re.claude,lanStatus:Ts.lanStatus,now:Lt}),va=Z0e({now:Lt,stateRef:n,version:ge,notice:ve,noticeOpen:je,upgradeFailure:ot,paused:J.paused}),{askRestart:ba,loadAutoRestartPrefs:Rr}=va,Vn=z0e(),{setTheme:we,palette:et}=Vn,pt=Y0e(),Et=mme(),{applyViewport:sr,moveCamera:Mr,fitLeft:ss,cameraEpochRef:fc,lastFitTimeRef:$r}=Et,at=Tme(Et),{pinnedRef:yo,positionsRef:wo,lastLayoutSigRef:pc,handleRelayout:mc,rearrangeUndo:$d}=at,gc=g.useRef(null),_i=g.useRef(()=>{}),xo=pe!==null,Ms=g.useRef(0),$s=g.useCallback(()=>{Ms.current=Date.now()},[]),{canvasRef:an,canvasSize:vo,paneSizeRef:bo}=yge(se),Ls=G1e(ss),{autoFitDisabledRef:Ld,disableAutoFit:Ei}=Ls,Lr=g.useRef(!1),{measuredRef:Ir,measuredVersionRef:Id,sizeVersion:Ti,domSizeVersion:Od}=wge(Lr),{removedNodes:yc,removedAgentIds:rs,removeNode:ko,removeSelectedNode:Or,removalNotice:jo,hideSessions:zm,bringBack:wc,bringBackAll:xc,forgetRemovals:Ai}=Xme({stateRef:n,pinnedRef:yo,positionsRef:wo,canvasRef:an,clearSelection:R,primarySelectedId:_});oge({stateRef:n,removedNodes:yc,hideSessions:zm,ready:xo,keepSessionId:_?((Mc=n.current.agents.get(_))==null?void 0:Mc.sessionId)??_:null});const No=zme({stateRef:n,now:Lt,removedAgentIds:rs,sizeVersion:Ti,domSizeVersion:Od});Ame(No,at),Yme({layoutSig:No,rf:e,stateRef:n,measuredRef:Ir,pinnedRef:yo,positionsRef:wo,paneSizeRef:bo,lastInteractRef:Ms,autoFitDisabledRef:Ld,lastFitTimeRef:$r,fitLeft:ss});const vc=xge(),{bubbling:rr,endBubble:bc,onBubble:Ri}=Vue(),[Mi,$i]=g.useState(!1),So=Hue(),{beginTrashDrag:Pd,trackTrashDrag:vn,endTrashDrag:ka}=So,Li=Que({stateRef:n,measuredRef:Ir,measuredVersionRef:Id,canvasRef:an}),{lodRef:Co,applyZoom:Vm}=Li,Ii=pge({applyViewport:sr,lastFitTimeRef:$r,cameraEpochRef:fc,disableAutoFit:Ei,markInteract:$s,canvasRef:an,applyZoom:Vm}),Pr=_?n.current.agents.get(_):null,Dr=v&&Pr!=null,Is=jge({sessionListShown:B,usageShown:Za(A),machineShown:Za(q),accountsShown:ke,detailShown:Dr,primarySelectedId:_,canvasRef:an}),{railInsetRef:_o,availableWidth:Dd,availableHeight:Fd}=ume({canvasRef:an,canvasSize:vo,machinePhase:q,usagePhase:A,usagePanelOpen:b,detailShown:Dr}),Bd=Vme({stateRef:n,now:Lt,availableWidth:Dd,availableHeight:Fd,layout:at,measuredRef:Ir,onBubble:Ri,settled:vc,dragging:Mi,layoutSig:No,selectedIds:C,openContext:Ss,historyReplayed:xo,removedNodes:yc,removedAgentIds:rs,dragTick:ga,dragPatchRef:Ar,dragMoveTick:Rs}),{nodes:Eo,edges:Gm}=Bd,kc=Dn(_);Rme({nodes:Eo,edges:Gm,settled:vc,dragging:Mi,availableWidth:Dd,availableHeight:Fd,layout:at,camera:Et,rf:e,measuredRef:Ir,stateRef:n,lastFocusRef:gc,primarySelectedIdRef:kc,focusAgentRef:_i,autoFitDisabledRef:Ld});const qd=S1e({stateRef:n,pinnedRef:yo,measuredRef:Ir,positionsRef:wo,lastLayoutSigRef:pc,forgetRemovals:Ai,clearSelection:R,rerender:a,modalOpenRef:Hn}),{requestClear:jc}=qd,Km=Nge({nodes:Eo,stateRef:n,pinnedRef:yo,positionsRef:wo,draggingRef:Lr,dragPatchRef:Ar,setDragging:$i,setDragMoveTick:dn,setDragTick:xt,endBubble:bc,markInteract:$s,disableAutoFit:Ei,beginTrashDrag:Pd,trackTrashDrag:vn,endTrashDrag:ka,removeNode:ko}),Nc=g.useCallback(()=>ss(500),[ss]),Sc=Dn(Eo),{focusAgent:Oi,stepAgent:Ym,focusSession:ja}=yme({canvasRef:an,stateRef:n,measuredRef:Ir,nodesRef:Sc,railInsetRef:_o,moveCamera:Mr,disableAutoFit:Ei,lastFocusRef:gc,focusAgentRef:_i,selectAgent:M,primarySelectedIdRef:kc}),Cc=mge({clearSelection:R,selectAgent:M,detailOpen:v,setDetailOpen:j,detailShown:Dr,focusAgent:Oi,draggingRef:Lr,lodRef:Co}),Xm=wme({nodesRef:Sc,stateRef:n,canvasRef:an,railInsetRef:_o}),Zm=Dn(Or),_c=g.useRef(null),To=g.useCallback(ut=>{rs.has(ut)&&wc([ut]),ja(ut)},[rs,wc,ja]),Jm=vge(),[Qm,Ec]=g.useState(!1),Ud=g.useCallback(()=>Ec(!0),[]),eg=g.useCallback(()=>Ec(!1),[]),tg=g.useCallback(ut=>{Ec(!1),ut.run()},[]),ng=Tn();bge({pointerFocusRef:Jm,nodesRef:Sc,stateRef:n,primarySelectedIdRef:kc,providersRef:rt,soundOnRef:K,keyHelpOpenRef:yn,modalOpenRef:Hn,waitingCursorRef:_c,removeSelectedRef:Zm,activateSoundRef:O,clearSelection:R,selectAgent:M,focusAgent:Oi,stepAgent:Ym,focusSession:ja,requestClear:jc,handleRelayout:mc,undoRearrange:$d.undo,handleFit:Nc,togglePause:le,toggleSessionList:u,toggleAccountsPanel:h,setDetailOpen:j,setUsageHistoryOpen:es,setUsagePanelOpen:N,setMachinePanelOpen:S,setBrowserWatchOpen:Cs,setKeyHelpOpen:Wn,setTheme:we,openSettings:Y,openIntegrationRef:Es,openQuickOpen:Ud});const Ao=n.current.agents.size,as=g.useMemo(()=>x1(n.current.agents.values()),[n.current,n.current.revision]);Zme({stateRef:n,waitingSessions:as,removedAgentIds:rs,removedNodes:yc,bringBack:wc}),dge({stateRef:n,waitingSessions:as,live:oe});const Wd=v1e({waitingSessions:as,watchUnseen:_t,incidents:xa}),Pi=k1e({waitingSessions:as,liveSince:pe,focusSession:ja}),{loadNotifyPrefs:Hd}=Pi;F1e({loadAutoRestartPrefs:Rr,loadNotifyPrefs:Hd,loadReportsPrefs:Me.loadReportsPrefs});const ar=ic(um),[zd,Tc]=g.useState(!1),[Fr,Ac]=g.useState(null),sg=g.useCallback(()=>Ac(null),[]),rg=g.useCallback(ut=>{const Br=n.current.agents.get(ut);return Br?Br.label||Br.cwdBasename||"session":null},[]),Vd=g.useCallback(ut=>{Ac(null),To(ut)},[To]),Gd=g.useCallback(()=>Tc(!1),[]),[Na,Sa]=g.useState(null),ag=g.useCallback(()=>Sa(null),[]),qt=Wge({providers:Re,sessionListOpen:o,toggleSessionList:u,accountsPanelOpen:i,toggleAccountsPanel:h,usagePanelOpen:b,setUsagePanelOpen:N,machinePanelOpen:x,setMachinePanelOpen:S,setUsageHistoryOpen:es,watchOn:Je,watchUnseen:_t,setBrowserWatchOpen:Cs,setTrafficRadarOpen:tt.setTrafficRadarOpen,openSettings:Y,onFeedback:tt.openFeedback,setRadioOpen:Tc,openToolActivity:Ac,openCapacity:Sa,toggles:Is.toggles,integrations:ns.map(ut=>({provider:ut,onPress:()=>zn(ut.kind)})),openExploreIntegrations:()=>Cr(!0),openQuickOpen:Ud}),[og,Kd]=g.useState(0),Di=g.useCallback(ut=>{To(ut),ar&&m()},[To,ar,m]),Rc=g.useCallback(()=>{o||u(),requestAnimationFrame(()=>{var ut;return(ut=document.querySelector("#session-list .sl-row"))==null?void 0:ut.focus()})},[o,u]);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(UJ,{}),r.jsx(ywe,{versionCheck:Le,welcome:We,desktopUpdate:xe,pause:J,announcements:Wd,notify:Pi,waitingSessions:as,waitingCursorRef:_c,focusSession:ja,live:oe,now:Lt,incidents:xa,queueNamed:ar?0:og}),!ar&&r.jsx(pwe,{waitingSessions:as,waitingCursorRef:_c,focusSession:ja,now:Lt,onFit:Kd,onMore:Rc}),Pr&&r.jsx(wwe,{selected:Pr,now:Lt,selectedIds:C,focusAgent:Oi,clearSelection:R}),!ar&&r.jsx("div",{className:"actions",children:r.jsx(iee,{items:[qt.search,...qt.utilities]})})]}),ar?r.jsx(oee,{items:[...qt.left,...qt.right[0],qt.utilities[0]],more:[qt.search,...qt.capacity,...qt.right.slice(1).flat(),...qt.integrations,...qt.explore,qt.utilities[1]]}):r.jsx(oA,{side:"left",label:"Accounts and sessions",groups:[...qt.leftStripe,qt.integrations,qt.explore]}),r.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:jo?`${jo.label} removed from the board.`:""}),r.jsx(Uwe,{restart:va,versionCheck:Le,upgrade:Ve,oldNameNotice:_e,rating:wt,onFeedback:tt.openFeedback,everConnected:he,live:oe,paused:te}),(B||ke)&&r.jsxs(Pue,{width:He,children:[ke&&r.jsx(vue,{leaving:UE(i,L),onReport:tt.openFeedback,onRoster:go.observe,onClose:()=>{Is.accounts(),w()},lanWanted:Ae,onLanShown:fe}),B&&r.jsx(tQ,{leaving:UE(o,U),state:n.current,now:Lt,selectedIds:C,onSelect:Di,onClose:()=>{Is.sessionList(),p()},removedIds:rs,onBringBackAll:xc})]}),r.jsxs(jwe,{canvasRef:an,bubbling:rr,dragging:Mi,trash:So,zoom:Li,viewport:Ii,stateRef:n,peek:Xm,children:[Ao===0&&(!oe&&re?r.jsx(Cge,{reservedRight:_o.current}):r.jsx(_ge,{live:oe,everConnected:he,providers:Re,workspace:$e,onTour:ye,reservedRight:_o.current})),(ya.length>1||As.size>0)&&r.jsx(xwe,{catBarRef:nr,catBarOccluded:Tr,presentCats:ya,hiddenCats:As,toggleCat:wa}),r.jsx(qJ,{graph:Bd,layout:at,viewport:Ii,clicks:Cc,drag:Km,appearance:Vn,fm:pt,radioOpen:zd,onRadioClose:Gd,autoFit:Ls,pause:J,stateRef:n,measuredRef:Ir,hiddenCats:As,now:Lt,openTool:$t,focusAgent:Oi,requestClear:jc,setKeyHelpOpen:Wn})]}),!ar&&r.jsx(oA,{side:"right",label:"Usage and activity",groups:qt.right}),Fr&&r.jsx(_ne,{view:Fr,onClose:sg,sessionLabel:rg,onOpenSession:Vd}),Na&&r.jsx(Oue,{view:Na,onClose:ag}),ts&&r.jsx(Rye,{kind:ts,connections:sa(Nt,ts)?Mp(Nt,ts):[],onClose:tr,onReconnect:_r}),wn&&r.jsx(zye,{integrations:Nt,onClose:xn,onOpen:zn,onConnect:rn,onManage:_s}),Qm&&r.jsx(FQ,{onClose:eg,onRun:tg,items:Nte({rails:qt,sessions:ED(n.current),now:Lt,openSession:Di,settings:JD(Re.claude,FS(Nt),Md(Nt)),openSettings:Y,singleKeys:ng,fit:Nc,rearrange:mc,paused:te,togglePause:le,clear:Ao>0?()=>jc("button"):void 0,keyHelp:()=>Wn(!0),tour:ye,theme:Vn.theme,setTheme:we})}),Za(A)&&r.jsx(Zse,{state:n.current,now:Lt,providers:Re,incidents:xa,liveSince:pe,leaving:A==="leaving",onClose:()=>{Is.usage(),N(!1)}}),Za(q)&&r.jsx(Mre,{usageOpen:b,leaving:q==="leaving",onClose:()=>{Is.machine(),S(!1)}}),v&&Pr?r.jsx(qge,{selected:Pr,now:Lt,openTool:$t,setSummaryFor:Vt,stateRef:n,removeSelectedNode:Or,onClose:()=>{Is.detail(),j(!1)}}):null,r.jsx(Hke,{dialogs:tt,welcome:We,desktopUpdate:xe,versionCheck:Le,restart:va,upgrade:Ve,lanPairs:Ts,attention:go,clearFlow:qd,watchBadge:qe,announcements:Wd,appearance:Vn,providers:Re,stateRef:n,agentCount:Ao,menus:X,sound:F,tones:V,customTones:W,notify:Pi,panelDoors:{accounts:f,localNetwork:be}})]})}try{dK(window.localStorage)}catch{}const X1e=Eq.createRoot(document.getElementById("root"));window.ccdeckWindow&&(document.documentElement.dataset.desktopChrome="true",document.documentElement.dataset.desktopPlatform=window.ccdeckWindow.platform);X1e.render(r.jsx(K1e,{}));export{Ive as $,cm as A,kt as B,_u as C,wje as D,rd as E,S5 as F,ct as G,z1 as H,yr as I,_A as J,V1 as K,Ct as L,nje as M,no as N,ta as O,sje as P,rje as Q,b5 as R,ld as S,Qf as T,Un as U,$ee as V,dje as W,pje as X,Ove as Y,hje as Z,fje as _,vs as a,mje as a0,rm as a1,me as a2,yi as a3,so as a4,AZ as a5,xje as a6,jN as a7,Xl as a8,dX as a9,tje as aa,Q1e as ab,eje as ac,am as ad,VG as ae,Ebe as af,O0e as ag,J1e as ah,RZ as ai,g as b,cje as c,Fn as d,tp as e,Vo as f,ho as g,oS as h,uje as i,r as j,_P as k,gt as l,cn as m,yt as n,sn as o,pd as p,lje as q,nt as r,Sn as s,ije as t,ic as u,yje as v,st as w,gje as x,oje as y,aje as z};
|