ccdeck 3.48.0 → 3.49.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.
@@ -1,321 +0,0 @@
1
- var bq=Object.defineProperty;var kq=(e,t,n)=>t in e?bq(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var qa=(e,t,n)=>kq(e,typeof t!="symbol"?t+"":t,n);var Uh=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Fj(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Ey={exports:{}},eu={},Ty={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 W_;function jq(){if(W_)return it;W_=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(){}},b=Object.assign,k={};function v(I,U,Z){this.props=I,this.context=U,this.refs=k,this.updater=Z||w}v.prototype.isReactComponent={},v.prototype.setState=function(I,U){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,U,"setState")},v.prototype.forceUpdate=function(I){this.updater.enqueueForceUpdate(this,I,"forceUpdate")};function N(){}N.prototype=v.prototype;function x(I,U,Z){this.props=I,this.context=U,this.refs=k,this.updater=Z||w}var C=x.prototype=new N;C.constructor=x,b(C,v.prototype),C.isPureReactComponent=!0;var S=Array.isArray,_=Object.prototype.hasOwnProperty,$={current:null},A={key:!0,ref:!0,__self:!0,__source:!0};function O(I,U,Z){var z,X={},Y=null,J=null;if(U!=null)for(z in U.ref!==void 0&&(J=U.ref),U.key!==void 0&&(Y=""+U.key),U)_.call(U,z)&&!A.hasOwnProperty(z)&&(X[z]=U[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:$.current}}function M(I,U){return{$$typeof:e,type:I.type,key:U,ref:I.ref,props:I.props,_owner:I._owner}}function W(I){return typeof I=="object"&&I!==null&&I.$$typeof===e}function B(I){var U={"=":"=0",":":"=2"};return"$"+I.replace(/[=:]/g,function(Z){return U[Z]})}var R=/\/+/g;function q(I,U){return typeof I=="object"&&I!==null&&I.key!=null?B(""+I.key):U.toString(36)}function T(I,U,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,S(X)?(Z="",I!=null&&(Z=I.replace(R,"$&/")+"/"),T(X,U,Z,"",function(le){return le})):X!=null&&(W(X)&&(X=M(X,Z+(!X.key||J&&J.key===X.key?"":(""+X.key).replace(R,"$&/")+"/")+I)),U.push(X)),1;if(J=0,z=z===""?".":z+":",S(I))for(var Q=0;Q<I.length;Q++){Y=I[Q];var te=z+q(Y,Q);J+=T(Y,U,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,U,Z,te,X);else if(Y==="object")throw U=String(I),Error("Objects are not valid as a React child (found: "+(U==="[object Object]"?"object with keys {"+Object.keys(I).join(", ")+"}":U)+"). If you meant to render a collection of children, use an array instead.");return J}function F(I,U,Z){if(I==null)return I;var z=[],X=0;return T(I,z,"","",function(Y){return U.call(Z,Y,X++)}),z}function D(I){if(I._status===-1){var U=I._result;U=U(),U.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=U)}if(I._status===1)return I._result.default;throw I._result}var K={current:null},V={transition:null},H={ReactCurrentDispatcher:K,ReactCurrentBatchConfig:V,ReactCurrentOwner:$};function P(){throw Error("act(...) is not supported in production builds of React.")}return it.Children={map:F,forEach:function(I,U,Z){F(I,function(){U.apply(this,arguments)},Z)},count:function(I){var U=0;return F(I,function(){U++}),U},toArray:function(I){return F(I,function(U){return U})||[]},only:function(I){if(!W(I))throw Error("React.Children.only expected to receive a single React element child.");return I}},it.Component=v,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=P,it.cloneElement=function(I,U,Z){if(I==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+I+".");var z=b({},I.props),X=I.key,Y=I.ref,J=I._owner;if(U!=null){if(U.ref!==void 0&&(Y=U.ref,J=$.current),U.key!==void 0&&(X=""+U.key),I.type&&I.type.defaultProps)var Q=I.type.defaultProps;for(te in U)_.call(U,te)&&!A.hasOwnProperty(te)&&(z[te]=U[te]===void 0&&Q!==void 0?Q[te]:U[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=O,it.createFactory=function(I){var U=O.bind(null,I);return U.type=I,U},it.createRef=function(){return{current:null}},it.forwardRef=function(I){return{$$typeof:l,render:I}},it.isValidElement=W,it.lazy=function(I){return{$$typeof:f,_payload:{_status:-1,_result:I},_init:D}},it.memo=function(I,U){return{$$typeof:h,type:I,compare:U===void 0?null:U}},it.startTransition=function(I){var U=V.transition;V.transition={};try{I()}finally{V.transition=U}},it.unstable_act=P,it.useCallback=function(I,U){return K.current.useCallback(I,U)},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,U){return K.current.useEffect(I,U)},it.useId=function(){return K.current.useId()},it.useImperativeHandle=function(I,U,Z){return K.current.useImperativeHandle(I,U,Z)},it.useInsertionEffect=function(I,U){return K.current.useInsertionEffect(I,U)},it.useLayoutEffect=function(I,U){return K.current.useLayoutEffect(I,U)},it.useMemo=function(I,U){return K.current.useMemo(I,U)},it.useReducer=function(I,U,Z){return K.current.useReducer(I,U,Z)},it.useRef=function(I){return K.current.useRef(I)},it.useState=function(I){return K.current.useState(I)},it.useSyncExternalStore=function(I,U,Z){return K.current.useSyncExternalStore(I,U,Z)},it.useTransition=function(){return K.current.useTransition()},it.version="18.3.1",it}var H_;function dd(){return H_||(H_=1,Ty.exports=jq()),Ty.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 z_;function Nq(){if(z_)return eu;z_=1;var e=dd(),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 V_;function Sq(){return V_||(V_=1,Ey.exports=Nq()),Ey.exports}var r=Sq(),Wh={},Ay={exports:{}},On={},Ry={exports:{}},My={};/**
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 G_;function Cq(){return G_||(G_=1,(function(e){function t(V,H){var P=V.length;V.push(H);e:for(;0<P;){var I=P-1>>>1,U=V[I];if(0<a(U,H))V[I]=H,V[P]=U,P=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],P=V.pop();if(P!==H){V[0]=P;e:for(var I=0,U=V.length,Z=U>>>1;I<Z;){var z=2*(I+1)-1,X=V[z],Y=z+1,J=V[Y];if(0>a(X,P))Y<U&&0>a(J,X)?(V[I]=J,V[Y]=P,I=Y):(V[I]=X,V[z]=P,I=z);else if(Y<U&&0>a(J,P))V[I]=J,V[Y]=P,I=Y;else break e}}return H}function a(V,H){var P=V.sortIndex-H.sortIndex;return P!==0?P: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,b=!1,k=!1,v=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 C(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 S(V){if(k=!1,C(V),!b)if(n(u)!==null)b=!0,D(_);else{var H=n(h);H!==null&&K(S,H.startTime-V)}}function _(V,H){b=!1,k&&(k=!1,N(O),O=-1),w=!0;var P=m;try{for(C(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 U=I(p.expirationTime<=H);H=e.unstable_now(),typeof U=="function"?p.callback=U:p===n(u)&&s(u),C(H)}else s(u);p=n(u)}if(p!==null)var Z=!0;else{var z=n(h);z!==null&&K(S,z.startTime-H),Z=!1}return Z}finally{p=null,m=P,w=!1}}var $=!1,A=null,O=-1,M=5,W=-1;function B(){return!(e.unstable_now()-W<M)}function R(){if(A!==null){var V=e.unstable_now();W=V;var H=!0;try{H=A(!0,V)}finally{H?q():($=!1,A=null)}}else $=!1}var q;if(typeof x=="function")q=function(){x(R)};else if(typeof MessageChannel<"u"){var T=new MessageChannel,F=T.port2;T.port1.onmessage=R,q=function(){F.postMessage(null)}}else q=function(){v(R,0)};function D(V){A=V,$||($=!0,q())}function K(V,H){O=v(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(){b||w||(b=!0,D(_))},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"):M=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 P=m;m=H;try{return V()}finally{m=P}},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 P=m;m=V;try{return H()}finally{m=P}},e.unstable_scheduleCallback=function(V,H,P){var I=e.unstable_now();switch(typeof P=="object"&&P!==null?(P=P.delay,P=typeof P=="number"&&0<P?I+P:I):P=I,V){case 1:var U=-1;break;case 2:U=250;break;case 5:U=1073741823;break;case 4:U=1e4;break;default:U=5e3}return U=P+U,V={id:f++,callback:H,priorityLevel:V,startTime:P,expirationTime:U,sortIndex:-1},P>I?(V.sortIndex=P,t(h,V),n(u)===null&&V===n(h)&&(k?(N(O),O=-1):k=!0,K(S,P-I))):(V.sortIndex=U,t(u,V),b||w||(b=!0,D(_))),V},e.unstable_shouldYield=B,e.unstable_wrapCallback=function(V){var H=m;return function(){var P=m;m=H;try{return V.apply(this,arguments)}finally{m=P}}}})(My)),My}var K_;function _q(){return K_||(K_=1,Ry.exports=Cq()),Ry.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 Y_;function Eq(){if(Y_)return On;Y_=1;var e=dd(),t=_q();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,j){if(y!==null&&y.type===0)return!1;switch(typeof d){case"function":case"symbol":return!0;case"boolean":return j?!1:y!==null?!y.acceptsBooleans:(c=c.toLowerCase().slice(0,5),c!=="data-"&&c!=="aria-");default:return!1}}function b(c,d,y,j){if(d===null||typeof d>"u"||w(c,d,y,j))return!0;if(j)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 k(c,d,y,j,E,L,G){this.acceptsBooleans=d===2||d===3||d===4,this.attributeName=j,this.attributeNamespace=E,this.mustUseProperty=y,this.propertyName=c,this.type=d,this.sanitizeURL=L,this.removeEmptyString=G}var v={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(c){v[c]=new k(c,0,!1,c,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(c){var d=c[0];v[d]=new k(d,1,!1,c[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(c){v[c]=new k(c,2,!1,c.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(c){v[c]=new k(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){v[c]=new k(c,3,!1,c.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(c){v[c]=new k(c,3,!0,c,null,!1,!1)}),["capture","download"].forEach(function(c){v[c]=new k(c,4,!1,c,null,!1,!1)}),["cols","rows","size","span"].forEach(function(c){v[c]=new k(c,6,!1,c,null,!1,!1)}),["rowSpan","start"].forEach(function(c){v[c]=new k(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);v[d]=new k(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);v[d]=new k(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);v[d]=new k(d,1,!1,c,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(c){v[c]=new k(c,1,!1,c.toLowerCase(),null,!1,!1)}),v.xlinkHref=new k("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(c){v[c]=new k(c,1,!1,c.toLowerCase(),null,!0,!0)});function C(c,d,y,j){var E=v.hasOwnProperty(d)?v[d]:null;(E!==null?E.type!==0:j||!(2<d.length)||d[0]!=="o"&&d[0]!=="O"||d[1]!=="n"&&d[1]!=="N")&&(b(d,y,E,j)&&(y=null),j||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,j=E.attributeNamespace,y===null?c.removeAttribute(d):(E=E.type,y=E===3||E===4&&y===!0?"":""+y,j?c.setAttributeNS(j,d,y):c.setAttribute(d,y))))}var S=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,_=Symbol.for("react.element"),$=Symbol.for("react.portal"),A=Symbol.for("react.fragment"),O=Symbol.for("react.strict_mode"),M=Symbol.for("react.profiler"),W=Symbol.for("react.provider"),B=Symbol.for("react.context"),R=Symbol.for("react.forward_ref"),q=Symbol.for("react.suspense"),T=Symbol.for("react.suspense_list"),F=Symbol.for("react.memo"),D=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 P=Object.assign,I;function U(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 j=ue}Reflect.construct(c,[],d)}else{try{d.call()}catch(ue){j=ue}c.call(d.prototype)}else{try{throw Error()}catch(ue){j=ue}c()}}catch(ue){if(ue&&j&&typeof ue.stack=="string"){for(var E=ue.stack.split(`
35
- `),L=j.stack.split(`
36
- `),G=E.length-1,ee=L.length-1;1<=G&&0<=ee&&E[G]!==L[ee];)ee--;for(;1<=G&&0<=ee;G--,ee--)if(E[G]!==L[ee]){if(G!==1||ee!==1)do if(G--,ee--,0>ee||E[G]!==L[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:"")?U(c):""}function X(c){switch(c.tag){case 5:return U(c.type);case 16:return U("Lazy");case 13:return U("Suspense");case 19:return U("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 A:return"Fragment";case $:return"Portal";case M:return"Profiler";case O: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 W:return(c._context.displayName||"Context")+".Provider";case R: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 D: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===O?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof 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),j=""+c[d];if(!c.hasOwnProperty(d)&&typeof y<"u"&&typeof y.get=="function"&&typeof y.set=="function"){var E=y.get,L=y.set;return Object.defineProperty(c,d,{configurable:!0,get:function(){return E.call(this)},set:function(G){j=""+G,L.call(this,G)}}),Object.defineProperty(c,d,{enumerable:y.enumerable}),{getValue:function(){return j},setValue:function(G){j=""+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(),j="";return c&&(j=te(c)?c.checked?"true":"false":c.value),c=j,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 P({},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,j=d.checked!=null?d.checked:d.defaultChecked;y=Q(d.value!=null?d.value:y),c._wrapperState={initialChecked:j,initialValue:y,controlled:d.type==="checkbox"||d.type==="radio"?d.checked!=null:d.value!=null}}function Le(c,d){d=d.checked,d!=null&&C(c,"checked",d,!1)}function ge(c,d){Le(c,d);var y=Q(d.value),j=d.type;if(y!=null)j==="number"?(y===0&&c.value===""||c.value!=y)&&(c.value=""+y):c.value!==""+y&&(c.value=""+y);else if(j==="submit"||j==="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 j=d.type;if(!(j!=="submit"&&j!=="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,j){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&&j&&(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,j&&(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 P({},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),j=Q(d.defaultValue);y!=null&&(y=""+y,y!==c.value&&(c.value=y),d.defaultValue==null&&c.defaultValue!==y&&(c.defaultValue=y)),j!=null&&(c.defaultValue=""+j)}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,j,E){MSApp.execUnsafeLocalFunction(function(){return c(d,y,j,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 j=y.indexOf("--")===0,E=ke(y,d[y],j);y==="float"&&(y="cssFloat"),j?c.setProperty(y,E):c[y]=E}}var Oe=P({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=sh(d),ot(c.stateNode,c.type,d))}}function Gt(c){tt?wt?wt.push(c):wt=[c]:tt=c}function nr(){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 _s(c,d){return c(d)}function Hn(){}var ns=!1;function Es(c,d,y){if(ns)return c(d,y);ns=!0;try{return _s(c,d,y)}finally{ns=!1,(tt!==null||wt!==null)&&(Hn(),nr())}}function wn(c,d){var y=c.stateNode;if(y===null)return null;var j=sh(y);if(j===null)return null;y=j[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":(j=!j.disabled)||(c=c.type,j=!(c==="button"||c==="input"||c==="select"||c==="textarea")),c=!j;break e;default:c=!1}if(c)return null;if(y&&typeof y!="function")throw Error(n(231,d,typeof y));return y}var zn=!1;if(l)try{var Me={};Object.defineProperty(Me,"passive",{get:function(){zn=!0}}),window.addEventListener("test",Me,Me),window.removeEventListener("test",Me,Me)}catch{zn=!1}function qe(c,d,y,j,E,L,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,ss=null,Vn={onError:function(c){Je=!0,_t=c}};function xn(c,d,y,j,E,L,G,ee,ne){Je=!1,_t=null,qe.apply(Vn,arguments)}function Tr(c,d,y,j,E,L,G,ee,ne){if(xn.apply(this,arguments),Je){if(Je){var ue=_t;Je=!1,_t=null}else throw Error(n(198));Nt||(Nt=!0,ss=ue)}}function vn(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 on(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 Ts(c){if(vn(c)!==c)throw Error(n(188))}function sr(c){var d=c.alternate;if(!d){if(d=vn(c),d===null)throw Error(n(188));return d!==c?null:c}for(var y=c,j=d;;){var E=y.return;if(E===null)break;var L=E.alternate;if(L===null){if(j=E.return,j!==null){y=j;continue}break}if(E.child===L.child){for(L=E.child;L;){if(L===y)return Ts(E),c;if(L===j)return Ts(E),d;L=L.sibling}throw Error(n(188))}if(y.return!==j.return)y=E,j=L;else{for(var G=!1,ee=E.child;ee;){if(ee===y){G=!0,y=E,j=L;break}if(ee===j){G=!0,j=E,y=L;break}ee=ee.sibling}if(!G){for(ee=L.child;ee;){if(ee===y){G=!0,y=L,j=E;break}if(ee===j){G=!0,j=L,y=E;break}ee=ee.sibling}if(!G)throw Error(n(189))}}if(y.alternate!==j)throw Error(n(190))}if(y.tag!==3)throw Error(n(188));return y.stateNode.current===y?c:d}function rs(c){return c=sr(c),c!==null?As(c):null}function As(c){if(c.tag===5||c.tag===6)return c;for(c=c.child;c!==null;){var d=As(c);if(d!==null)return d;c=c.sibling}return null}var Ar=t.unstable_scheduleCallback,Rr=t.unstable_cancelCallback,Rs=t.unstable_shouldYield,ya=t.unstable_requestPaint,xt=t.unstable_now,wa=t.unstable_getCurrentPriorityLevel,Ms=t.unstable_ImmediatePriority,xa=t.unstable_UserBlockingPriority,rr=t.unstable_NormalPriority,ar=t.unstable_LowPriority,Mr=t.unstable_IdlePriority,$s=null,hn=null;function Lt(c){if(hn&&typeof hn.onCommitFiberRoot=="function")try{hn.onCommitFiberRoot($s,c,void 0,(c.current.flags&128)===128)}catch{}}var fn=Math.clz32?Math.clz32:ba,va=Math.log,go=Math.LN2;function ba(c){return c>>>=0,c===0?32:31-(va(c)/go|0)|0}var ka=64,$r=4194304;function Gn(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 j=0,E=c.suspendedLanes,L=c.pingedLanes,G=y&268435455;if(G!==0){var ee=G&~E;ee!==0?j=Gn(ee):(L&=G,L!==0&&(j=Gn(L)))}else G=y&~E,G!==0?j=Gn(G):L!==0&&(j=Gn(L));if(j===0)return 0;if(d!==0&&d!==j&&(d&E)===0&&(E=j&-j,L=d&-d,E>=L||E===16&&(L&4194240)!==0))return d;if((j&4)!==0&&(j|=y&16),d=c.entangledLanes,d!==0)for(c=c.entanglements,d&=j;0<d;)y=31-fn(d),E=1<<y,j|=c[y],d&=~E;return j}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,j=c.pingedLanes,E=c.expirationTimes,L=c.pendingLanes;0<L;){var G=31-fn(L),ee=1<<G,ne=E[G];ne===-1?((ee&y)===0||(ee&j)!==0)&&(E[G]=et(ee,d)):ne<=d&&(c.expiredLanes|=ee),L&=~ee}}function Et(c){return c=c.pendingLanes&-1073741825,c!==0?c:c&1073741824?1073741824:0}function or(){var c=ka;return ka<<=1,(ka&4194240)===0&&(ka=64),c}function Lr(c){for(var d=[],y=0;31>y;y++)d.push(c);return d}function as(c,d,y){c.pendingLanes|=d,d!==536870912&&(c.suspendedLanes=0,c.pingedLanes=0),c=c.eventTimes,d=31-fn(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 j=c.eventTimes;for(c=c.expirationTimes;0<y;){var E=31-fn(y),L=1<<E;d[E]=0,j[E]=-1,c[E]=-1,y&=~L}}function Ir(c,d){var y=c.entangledLanes|=d;for(c=c.entanglements;y;){var j=31-fn(y),E=1<<j;E&d|c[j]&d&&(c[j]|=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,Id,gc,_i=!1,xo=[],Ls=null,Is=null,ln=null,vo=new Map,bo=new Map,Os=[],Od="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":Ls=null;break;case"dragenter":case"dragleave":Is=null;break;case"mouseover":case"mouseout":ln=null;break;case"pointerover":case"pointerout":vo.delete(d.pointerId);break;case"gotpointercapture":case"lostpointercapture":bo.delete(d.pointerId)}}function Or(c,d,y,j,E,L){return c===null||c.nativeEvent!==L?(c={blockedOn:d,domEventName:y,eventSystemFlags:j,nativeEvent:L,targetContainers:[E]},d!==null&&(d=Fc(d),d!==null&&pc(d)),c):(c.eventSystemFlags|=j,d=c.targetContainers,E!==null&&d.indexOf(E)===-1&&d.push(E),c)}function Pr(c,d,y,j,E){switch(d){case"focusin":return Ls=Or(Ls,c,d,y,j,E),!0;case"dragenter":return Is=Or(Is,c,d,y,j,E),!0;case"mouseover":return ln=Or(ln,c,d,y,j,E),!0;case"pointerover":var L=E.pointerId;return vo.set(L,Or(vo.get(L)||null,c,d,y,j,E)),!0;case"gotpointercapture":return L=E.pointerId,bo.set(L,Or(bo.get(L)||null,c,d,y,j,E)),!0}return!1}function Pd(c){var d=Ro(c.target);if(d!==null){var y=vn(d);if(y!==null){if(d=y.tag,d===13){if(d=on(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 j=new y.constructor(y.type,y);_e=j,y.target.dispatchEvent(j),_e=null}else return d=Fc(y),d!==null&&pc(d),c.blockedOn=y,!1;d.shift()}return!0}function Dd(c,d,y){Ti(c)&&y.delete(d)}function yc(){_i=!1,Ls!==null&&Ti(Ls)&&(Ls=null),Is!==null&&Ti(Is)&&(Is=null),ln!==null&&Ti(ln)&&(ln=null),vo.forEach(Dd),bo.forEach(Dd)}function os(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 os(E,c)}if(0<xo.length){os(xo[0],c);for(var y=1;y<xo.length;y++){var j=xo[y];j.blockedOn===c&&(j.blockedOn=null)}}for(Ls!==null&&os(Ls,c),Is!==null&&os(Is,c),ln!==null&&os(ln,c),vo.forEach(d),bo.forEach(d),y=0;y<Os.length;y++)j=Os[y],j.blockedOn===c&&(j.blockedOn=null);for(;0<Os.length&&(y=Os[0],y.blockedOn===null);)Pd(y),y.blockedOn===null&&Os.shift()}var Dr=S.ReactCurrentBatchConfig,jo=!0;function Km(c,d,y,j){var E=at,L=Dr.transition;Dr.transition=null;try{at=1,xc(c,d,y,j)}finally{at=E,Dr.transition=L}}function wc(c,d,y,j){var E=at,L=Dr.transition;Dr.transition=null;try{at=4,xc(c,d,y,j)}finally{at=E,Dr.transition=L}}function xc(c,d,y,j){if(jo){var E=No(c,d,y,j);if(E===null)wg(c,d,j,Ai,y),Ei(c,j);else if(Pr(E,c,d,y,j))j.stopPropagation();else if(Ei(c,j),d&4&&-1<Od.indexOf(c)){for(;E!==null;){var L=Fc(E);if(L!==null&&wo(L),L=No(c,d,y,j),L===null&&wg(c,d,j,Ai,y),L===E)break;E=L}E!==null&&j.stopPropagation()}else wg(c,d,j,null,y)}}var Ai=null;function No(c,d,y,j){if(Ai=null,c=Ve(j),c=Ro(c),c!==null)if(d=vn(c),d===null)c=null;else if(y=d.tag,y===13){if(c=on(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(wa()){case Ms:return 1;case xa:return 4;case rr:case ar:return 16;case Mr:return 536870912;default:return 16}default:return 16}}var ir=null,bc=null,Ri=null;function Mi(){if(Ri)return Ri;var c,d=bc,y=d.length,j,E="value"in ir?ir.value:ir.textContent,L=E.length;for(c=0;c<y&&d[c]===E[c];c++);var G=y-c;for(j=1;j<=G&&d[y-j]===E[L-j];j++);return Ri=E.slice(c,1<j?1-j: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 Fd(){return!1}function bn(c){function d(y,j,E,L,G){this._reactName=y,this._targetInst=E,this.type=j,this.nativeEvent=L,this.target=G,this.currentTarget=null;for(var ee in c)c.hasOwnProperty(ee)&&(y=c[ee],this[ee]=y?y(L):L[ee]);return this.isDefaultPrevented=(L.defaultPrevented!=null?L.defaultPrevented:L.returnValue===!1)?So:Fd,this.isPropagationStopped=Fd,this}return P(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 ja={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(c){return c.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Li=bn(ja),Co=P({},ja,{view:0,detail:0}),Ym=bn(Co),Ii,Fr,Br,Ps=P({},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!==Br&&(Br&&c.type==="mousemove"?(Ii=c.screenX-Br.screenX,Fr=c.screenY-Br.screenY):Fr=Ii=0,Br=c),Ii)},movementY:function(c){return"movementY"in c?c.movementY:Fr}}),_o=bn(Ps),Bd=P({},Ps,{dataTransfer:0}),qd=bn(Bd),Ud=P({},Co,{relatedTarget:0}),Eo=bn(Ud),Xm=P({},ja,{animationName:0,elapsedTime:0,pseudoElement:0}),kc=bn(Xm),Wd=P({},ja,{clipboardData:function(c){return"clipboardData"in c?c.clipboardData:window.clipboardData}}),jc=bn(Wd),Zm=P({},ja,{data:0}),Nc=bn(Zm),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"},Jm={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function Na(c){var d=this.nativeEvent;return d.getModifierState?d.getModifierState(c):(c=Jm[c])?!!d[c]:!1}function Cc(){return Na}var Qm=P({},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}}),eg=bn(Qm),_c=P({},Ps,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),To=bn(_c),tg=P({},Co,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:Cc}),ng=bn(tg),Ec=P({},ja,{propertyName:0,elapsedTime:0,pseudoElement:0}),Hd=bn(Ec),sg=P({},Ps,{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}),rg=bn(sg),ag=[9,13,27,32],Ao=l&&"CompositionEvent"in window,is=null;l&&"documentMode"in document&&(is=document.documentMode);var zd=l&&"TextEvent"in window&&!is,Pi=l&&(!Ao||is&&8<is&&11>=is),Vd=" ",lr=!1;function Gd(c,d){switch(c){case"keyup":return ag.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 qr=!1;function Ac(c,d){switch(c){case"compositionend":return Tc(d);case"keypress":return d.which!==32?null:(lr=!0,Vd);case"textInput":return c=d.data,c===Vd&&lr?null:c;default:return null}}function og(c,d){if(qr)return c==="compositionend"||!Ao&&Gd(c,d)?(c=Mi(),Ri=bc=ir=null,qr=!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 ig={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 Kd(c){var d=c&&c.nodeName&&c.nodeName.toLowerCase();return d==="input"?!!ig[c.type]:d==="textarea"}function Yd(c,d,y,j){Gt(j),d=eh(d,"onChange"),0<d.length&&(y=new Li("onChange","change",null,y,j),c.push({event:y,listeners:d}))}var Sa=null,Ca=null;function lg(c){aC(c,0)}function qt(c){var d=Wi(c);if(oe(d))return c}function cg(c,d){if(c==="change")return d}var Xd=!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;Xd=Di&&(!document.documentMode||9<document.documentMode)}function ut(){Sa&&(Sa.detachEvent("onpropertychange",Ur),Ca=Sa=null)}function Ur(c){if(c.propertyName==="value"&&qt(Ca)){var d=[];Yd(d,Ca,c,Ve(c)),Es(lg,d)}}function ug(c,d,y){c==="focusin"?(ut(),Sa=d,Ca=y,Sa.attachEvent("onpropertychange",Ur)):c==="focusout"&&ut()}function NB(c){if(c==="selectionchange"||c==="keyup"||c==="keydown")return qt(Ca)}function SB(c,d){if(c==="click")return qt(d)}function CB(c,d){if(c==="input"||c==="change")return qt(d)}function _B(c,d){return c===d&&(c!==0||1/c===1/d)||c!==c&&d!==d}var Ds=typeof Object.is=="function"?Object.is:_B;function $c(c,d){if(Ds(c,d))return!0;if(typeof c!="object"||c===null||typeof d!="object"||d===null)return!1;var y=Object.keys(c),j=Object.keys(d);if(y.length!==j.length)return!1;for(j=0;j<y.length;j++){var E=y[j];if(!u.call(d,E)||!Ds(c[E],d[E]))return!1}return!0}function VS(c){for(;c&&c.firstChild;)c=c.firstChild;return c}function GS(c,d){var y=VS(c);c=0;for(var j;y;){if(y.nodeType===3){if(j=c+y.textContent.length,c<=d&&j>=d)return{node:y,offset:d-c};c=j}e:{for(;y;){if(y.nextSibling){y=y.nextSibling;break e}y=y.parentNode}y=void 0}y=VS(y)}}function KS(c,d){return c&&d?c===d?!0:c&&c.nodeType===3?!1:d&&d.nodeType===3?KS(c,d.parentNode):"contains"in c?c.contains(d):c.compareDocumentPosition?!!(c.compareDocumentPosition(d)&16):!1:!1}function YS(){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 dg(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 EB(c){var d=YS(),y=c.focusedElem,j=c.selectionRange;if(d!==y&&y&&y.ownerDocument&&KS(y.ownerDocument.documentElement,y)){if(j!==null&&dg(y)){if(d=j.start,c=j.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,L=Math.min(j.start,E);j=j.end===void 0?L:Math.min(j.end,E),!c.extend&&L>j&&(E=j,j=L,L=E),E=GS(y,L);var G=GS(y,j);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(),L>j?(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 TB=l&&"documentMode"in document&&11>=document.documentMode,Fi=null,hg=null,Lc=null,fg=!1;function XS(c,d,y){var j=y.window===y?y.document:y.nodeType===9?y:y.ownerDocument;fg||Fi==null||Fi!==re(j)||(j=Fi,"selectionStart"in j&&dg(j)?j={start:j.selectionStart,end:j.selectionEnd}:(j=(j.ownerDocument&&j.ownerDocument.defaultView||window).getSelection(),j={anchorNode:j.anchorNode,anchorOffset:j.anchorOffset,focusNode:j.focusNode,focusOffset:j.focusOffset}),Lc&&$c(Lc,j)||(Lc=j,j=eh(hg,"onSelect"),0<j.length&&(d=new Li("onSelect","select",null,d,y),c.push({event:d,listeners:j}),d.target=Fi)))}function Zd(c,d){var y={};return y[c.toLowerCase()]=d.toLowerCase(),y["Webkit"+c]="webkit"+d,y["Moz"+c]="moz"+d,y}var Bi={animationend:Zd("Animation","AnimationEnd"),animationiteration:Zd("Animation","AnimationIteration"),animationstart:Zd("Animation","AnimationStart"),transitionend:Zd("Transition","TransitionEnd")},pg={},ZS={};l&&(ZS=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 Jd(c){if(pg[c])return pg[c];if(!Bi[c])return c;var d=Bi[c],y;for(y in d)if(d.hasOwnProperty(y)&&y in ZS)return pg[c]=d[y];return c}var JS=Jd("animationend"),QS=Jd("animationiteration"),eC=Jd("animationstart"),tC=Jd("transitionend"),nC=new Map,sC="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 _a(c,d){nC.set(c,d),o(d,[c])}for(var mg=0;mg<sC.length;mg++){var gg=sC[mg],AB=gg.toLowerCase(),RB=gg[0].toUpperCase()+gg.slice(1);_a(AB,"on"+RB)}_a(JS,"onAnimationEnd"),_a(QS,"onAnimationIteration"),_a(eC,"onAnimationStart"),_a("dblclick","onDoubleClick"),_a("focusin","onFocus"),_a("focusout","onBlur"),_a(tC,"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(" "),MB=new Set("cancel close invalid load scroll toggle".split(" ").concat(Ic));function rC(c,d,y){var j=c.type||"unknown-event";c.currentTarget=y,Tr(j,d,void 0,c),c.currentTarget=null}function aC(c,d){d=(d&4)!==0;for(var y=0;y<c.length;y++){var j=c[y],E=j.event;j=j.listeners;e:{var L=void 0;if(d)for(var G=j.length-1;0<=G;G--){var ee=j[G],ne=ee.instance,ue=ee.currentTarget;if(ee=ee.listener,ne!==L&&E.isPropagationStopped())break e;rC(E,ee,ue),L=ne}else for(G=0;G<j.length;G++){if(ee=j[G],ne=ee.instance,ue=ee.currentTarget,ee=ee.listener,ne!==L&&E.isPropagationStopped())break e;rC(E,ee,ue),L=ne}}}if(Nt)throw c=ss,Nt=!1,ss=null,c}function Tt(c,d){var y=d[Ng];y===void 0&&(y=d[Ng]=new Set);var j=c+"__bubble";y.has(j)||(oC(d,c,2,!1),y.add(j))}function yg(c,d,y){var j=0;d&&(j|=4),oC(y,c,j,d)}var Qd="_reactListening"+Math.random().toString(36).slice(2);function Oc(c){if(!c[Qd]){c[Qd]=!0,s.forEach(function(y){y!=="selectionchange"&&(MB.has(y)||yg(y,!1,c),yg(y,!0,c))});var d=c.nodeType===9?c:c.ownerDocument;d===null||d[Qd]||(d[Qd]=!0,yg("selectionchange",!1,d))}}function oC(c,d,y,j){switch(vc(d)){case 1:var E=Km;break;case 4:E=wc;break;default:E=xc}y=E.bind(null,d,y,c),E=void 0,!zn||d!=="touchstart"&&d!=="touchmove"&&d!=="wheel"||(E=!0),j?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 wg(c,d,y,j,E){var L=j;if((d&1)===0&&(d&2)===0&&j!==null)e:for(;;){if(j===null)return;var G=j.tag;if(G===3||G===4){var ee=j.stateNode.containerInfo;if(ee===E||ee.nodeType===8&&ee.parentNode===E)break;if(G===4)for(G=j.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){j=L=G;continue e}ee=ee.parentNode}}j=j.return}Es(function(){var ue=L,Se=Ve(y),Ce=[];e:{var Ne=nC.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=eg;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=qd;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Pe=ng;break;case JS:case QS:case eC:Pe=kc;break;case tC:Pe=Hd;break;case"scroll":Pe=Ym;break;case"wheel":Pe=rg;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=wn(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[Wr]))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=vn(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&&iC(Ce,Ne,Pe,ze,!1),Ue!==null&&Ut!==null&&iC(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=cg;else if(Kd(Ne))if(Xd)Ge=CB;else{Ge=NB;var Xe=ug}else(Pe=Ne.nodeName)&&Pe.toLowerCase()==="input"&&(Ne.type==="checkbox"||Ne.type==="radio")&&(Ge=SB);if(Ge&&(Ge=Ge(c,ue))){Yd(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":(Kd(Xe)||Xe.contentEditable==="true")&&(Fi=Xe,hg=ue,Lc=null);break;case"focusout":Lc=hg=Fi=null;break;case"mousedown":fg=!0;break;case"contextmenu":case"mouseup":case"dragend":fg=!1,XS(Ce,y,Se);break;case"selectionchange":if(TB)break;case"keydown":case"keyup":XS(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 qr?Gd(c,y)&&(Qe="onCompositionEnd"):c==="keydown"&&y.keyCode===229&&(Qe="onCompositionStart");Qe&&(Pi&&y.locale!=="ko"&&(qr||Qe!=="onCompositionStart"?Qe==="onCompositionEnd"&&qr&&(Ze=Mi()):(ir=Se,bc="value"in ir?ir.value:ir.textContent,qr=!0)),Xe=eh(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=zd?Ac(c,y):og(c,y))&&(ue=eh(ue,"onBeforeInput"),0<ue.length&&(Se=new Nc("onBeforeInput","beforeinput",null,y,Se),Ce.push({event:Se,listeners:ue}),Se.data=Ze))}aC(Ce,d)})}function Pc(c,d,y){return{instance:c,listener:d,currentTarget:y}}function eh(c,d){for(var y=d+"Capture",j=[];c!==null;){var E=c,L=E.stateNode;E.tag===5&&L!==null&&(E=L,L=wn(c,y),L!=null&&j.unshift(Pc(c,L,E)),L=wn(c,d),L!=null&&j.push(Pc(c,L,E))),c=c.return}return j}function qi(c){if(c===null)return null;do c=c.return;while(c&&c.tag!==5);return c||null}function iC(c,d,y,j,E){for(var L=d._reactName,G=[];y!==null&&y!==j;){var ee=y,ne=ee.alternate,ue=ee.stateNode;if(ne!==null&&ne===j)break;ee.tag===5&&ue!==null&&(ee=ue,E?(ne=wn(y,L),ne!=null&&G.unshift(Pc(y,ne,ee))):E||(ne=wn(y,L),ne!=null&&G.push(Pc(y,ne,ee)))),y=y.return}G.length!==0&&c.push({event:d,listeners:G})}var $B=/\r\n?/g,LB=/\u0000|\uFFFD/g;function lC(c){return(typeof c=="string"?c:""+c).replace($B,`
38
- `).replace(LB,"")}function th(c,d,y){if(d=lC(d),lC(c)!==d&&y)throw Error(n(425))}function nh(){}var xg=null,vg=null;function bg(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 kg=typeof setTimeout=="function"?setTimeout:void 0,IB=typeof clearTimeout=="function"?clearTimeout:void 0,cC=typeof Promise=="function"?Promise:void 0,OB=typeof queueMicrotask=="function"?queueMicrotask:typeof cC<"u"?function(c){return cC.resolve(null).then(c).catch(PB)}:kg;function PB(c){setTimeout(function(){throw c})}function jg(c,d){var y=d,j=0;do{var E=y.nextSibling;if(c.removeChild(y),E&&E.nodeType===8)if(y=E.data,y==="/$"){if(j===0){c.removeChild(E),ko(d);return}j--}else y!=="$"&&y!=="$?"&&y!=="$!"||j++;y=E}while(y);ko(d)}function Ea(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 uC(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),cr="__reactFiber$"+Ui,Dc="__reactProps$"+Ui,Wr="__reactContainer$"+Ui,Ng="__reactEvents$"+Ui,DB="__reactListeners$"+Ui,FB="__reactHandles$"+Ui;function Ro(c){var d=c[cr];if(d)return d;for(var y=c.parentNode;y;){if(d=y[Wr]||y[cr]){if(y=d.alternate,d.child!==null||y!==null&&y.child!==null)for(c=uC(c);c!==null;){if(y=c[cr])return y;c=uC(c)}return d}c=y,y=c.parentNode}return null}function Fc(c){return c=c[cr]||c[Wr],!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 sh(c){return c[Dc]||null}var Sg=[],Hi=-1;function Ta(c){return{current:c}}function At(c){0>Hi||(c.current=Sg[Hi],Sg[Hi]=null,Hi--)}function St(c,d){Hi++,Sg[Hi]=c.current,c.current=d}var Aa={},pn=Ta(Aa),Rn=Ta(!1),Mo=Aa;function zi(c,d){var y=c.type.contextTypes;if(!y)return Aa;var j=c.stateNode;if(j&&j.__reactInternalMemoizedUnmaskedChildContext===d)return j.__reactInternalMemoizedMaskedChildContext;var E={},L;for(L in y)E[L]=d[L];return j&&(c=c.stateNode,c.__reactInternalMemoizedUnmaskedChildContext=d,c.__reactInternalMemoizedMaskedChildContext=E),E}function Mn(c){return c=c.childContextTypes,c!=null}function rh(){At(Rn),At(pn)}function dC(c,d,y){if(pn.current!==Aa)throw Error(n(168));St(pn,d),St(Rn,y)}function hC(c,d,y){var j=c.stateNode;if(d=d.childContextTypes,typeof j.getChildContext!="function")return y;j=j.getChildContext();for(var E in j)if(!(E in d))throw Error(n(108,J(c)||"Unknown",E));return P({},y,j)}function ah(c){return c=(c=c.stateNode)&&c.__reactInternalMemoizedMergedChildContext||Aa,Mo=pn.current,St(pn,c),St(Rn,Rn.current),!0}function fC(c,d,y){var j=c.stateNode;if(!j)throw Error(n(169));y?(c=hC(c,d,Mo),j.__reactInternalMemoizedMergedChildContext=c,At(Rn),At(pn),St(pn,c)):At(Rn),St(Rn,y)}var Hr=null,oh=!1,Cg=!1;function pC(c){Hr===null?Hr=[c]:Hr.push(c)}function BB(c){oh=!0,pC(c)}function Ra(){if(!Cg&&Hr!==null){Cg=!0;var c=0,d=at;try{var y=Hr;for(at=1;c<y.length;c++){var j=y[c];do j=j(!0);while(j!==null)}Hr=null,oh=!1}catch(E){throw Hr!==null&&(Hr=Hr.slice(c+1)),Ar(Ms,Ra),E}finally{at=d,Cg=!1}}return null}var Vi=[],Gi=0,ih=null,lh=0,ls=[],cs=0,$o=null,zr=1,Vr="";function Lo(c,d){Vi[Gi++]=lh,Vi[Gi++]=ih,ih=c,lh=d}function mC(c,d,y){ls[cs++]=zr,ls[cs++]=Vr,ls[cs++]=$o,$o=c;var j=zr;c=Vr;var E=32-fn(j)-1;j&=~(1<<E),y+=1;var L=32-fn(d)+E;if(30<L){var G=E-E%5;L=(j&(1<<G)-1).toString(32),j>>=G,E-=G,zr=1<<32-fn(d)+E|y<<E|j,Vr=L+c}else zr=1<<L|y<<E|j,Vr=c}function _g(c){c.return!==null&&(Lo(c,1),mC(c,1,0))}function Eg(c){for(;c===ih;)ih=Vi[--Gi],Vi[Gi]=null,lh=Vi[--Gi],Vi[Gi]=null;for(;c===$o;)$o=ls[--cs],ls[cs]=null,Vr=ls[--cs],ls[cs]=null,zr=ls[--cs],ls[cs]=null}var Kn=null,Yn=null,Rt=!1,Fs=null;function gC(c,d){var y=fs(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 yC(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,Kn=c,Yn=Ea(d.firstChild),!0):!1;case 6:return d=c.pendingProps===""||d.nodeType!==3?null:d,d!==null?(c.stateNode=d,Kn=c,Yn=null,!0):!1;case 13:return d=d.nodeType!==8?null:d,d!==null?(y=$o!==null?{id:zr,overflow:Vr}:null,c.memoizedState={dehydrated:d,treeContext:y,retryLane:1073741824},y=fs(18,null,null,0),y.stateNode=d,y.return=c,c.child=y,Kn=c,Yn=null,!0):!1;default:return!1}}function Tg(c){return(c.mode&1)!==0&&(c.flags&128)===0}function Ag(c){if(Rt){var d=Yn;if(d){var y=d;if(!yC(c,d)){if(Tg(c))throw Error(n(418));d=Ea(y.nextSibling);var j=Kn;d&&yC(c,d)?gC(j,y):(c.flags=c.flags&-4097|2,Rt=!1,Kn=c)}}else{if(Tg(c))throw Error(n(418));c.flags=c.flags&-4097|2,Rt=!1,Kn=c}}}function wC(c){for(c=c.return;c!==null&&c.tag!==5&&c.tag!==3&&c.tag!==13;)c=c.return;Kn=c}function ch(c){if(c!==Kn)return!1;if(!Rt)return wC(c),Rt=!0,!1;var d;if((d=c.tag!==3)&&!(d=c.tag!==5)&&(d=c.type,d=d!=="head"&&d!=="body"&&!bg(c.type,c.memoizedProps)),d&&(d=Yn)){if(Tg(c))throw xC(),Error(n(418));for(;d;)gC(c,d),d=Ea(d.nextSibling)}if(wC(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){Yn=Ea(c.nextSibling);break e}d--}else y!=="$"&&y!=="$!"&&y!=="$?"||d++}c=c.nextSibling}Yn=null}}else Yn=Kn?Ea(c.stateNode.nextSibling):null;return!0}function xC(){for(var c=Yn;c;)c=Ea(c.nextSibling)}function Ki(){Yn=Kn=null,Rt=!1}function Rg(c){Fs===null?Fs=[c]:Fs.push(c)}var qB=S.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 j=y.stateNode}if(!j)throw Error(n(147,c));var E=j,L=""+c;return d!==null&&d.ref!==null&&typeof d.ref=="function"&&d.ref._stringRef===L?d.ref:(d=function(G){var ee=E.refs;G===null?delete ee[L]:ee[L]=G},d._stringRef=L,d)}if(typeof c!="string")throw Error(n(284));if(!y._owner)throw Error(n(290,c))}return c}function uh(c,d){throw c=Object.prototype.toString.call(d),Error(n(31,c==="[object Object]"?"object with keys {"+Object.keys(d).join(", ")+"}":c))}function vC(c){var d=c._init;return d(c._payload)}function bC(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 j(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=Fa(ie,ae),ie.index=0,ie.sibling=null,ie}function L(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=ky(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===A?Se(ie,ae,ce.props.children,Te,ce.key):ae!==null&&(ae.elementType===Ge||typeof Ge=="object"&&Ge!==null&&Ge.$$typeof===D&&vC(Ge)===ae.type)?(Te=E(ae,ce.props),Te.ref=Bc(ie,ae,ce),Te.return=ie,Te):(Te=Lh(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=jy(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=ky(""+ae,ie.mode,ce),ae.return=ie,ae;if(typeof ae=="object"&&ae!==null){switch(ae.$$typeof){case _:return ce=Lh(ae.type,ae.key,ae.props,null,ie.mode,ce),ce.ref=Bc(ie,null,ae),ce.return=ie,ce;case $:return ae=jy(ae,ie.mode,ce),ae.return=ie,ae;case D: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;uh(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 $:return ce.key===Ge?ue(ie,ae,ce,Te):null;case D: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);uh(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 $:return ie=ie.get(Te.key===null?ce:Te.key)||null,ue(ae,ie,Te,Ge);case D: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);uh(ae,Te)}return null}function Ue(ie,ae,ce,Te){for(var Ge=null,Xe=null,Ze=ae,Qe=ae=0,sn=null;Ze!==null&&Qe<ce.length;Qe++){Ze.index>Qe?(sn=Ze,Ze=null):sn=Ze.sibling;var ft=Ne(ie,Ze,ce[Qe],Te);if(ft===null){Ze===null&&(Ze=sn);break}c&&Ze&&ft.alternate===null&&d(ie,Ze),ae=L(ft,ae,Qe),Xe===null?Ge=ft:Xe.sibling=ft,Xe=ft,Ze=sn}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=L(Ze,ae,Qe),Xe===null?Ge=Ze:Xe.sibling=Ze,Xe=Ze);return Rt&&Lo(ie,Qe),Ge}for(Ze=j(ie,Ze);Qe<ce.length;Qe++)sn=Pe(Ze,ie,Qe,ce[Qe],Te),sn!==null&&(c&&sn.alternate!==null&&Ze.delete(sn.key===null?Qe:sn.key),ae=L(sn,ae,Qe),Xe===null?Ge=sn:Xe.sibling=sn,Xe=sn);return c&&Ze.forEach(function(Ba){return d(ie,Ba)}),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,sn=null,ft=ce.next();Ze!==null&&!ft.done;Qe++,ft=ce.next()){Ze.index>Qe?(sn=Ze,Ze=null):sn=Ze.sibling;var Ba=Ne(ie,Ze,ft.value,Te);if(Ba===null){Ze===null&&(Ze=sn);break}c&&Ze&&Ba.alternate===null&&d(ie,Ze),ae=L(Ba,ae,Qe),Xe===null?Ge=Ba:Xe.sibling=Ba,Xe=Ba,Ze=sn}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=L(ft,ae,Qe),Xe===null?Ge=ft:Xe.sibling=ft,Xe=ft);return Rt&&Lo(ie,Qe),Ge}for(Ze=j(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=L(ft,ae,Qe),Xe===null?Ge=ft:Xe.sibling=ft,Xe=ft);return c&&Ze.forEach(function(vq){return d(ie,vq)}),Rt&&Lo(ie,Qe),Ge}function Ut(ie,ae,ce,Te){if(typeof ce=="object"&&ce!==null&&ce.type===A&&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===A){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===D&&vC(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===A?(ae=Uo(ce.props.children,ie.mode,Te,ce.key),ae.return=ie,ie=ae):(Te=Lh(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 $: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=jy(ce,ie.mode,Te),ae.return=ie,ie=ae}return G(ie);case D: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);uh(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=ky(ce,ie.mode,Te),ae.return=ie,ie=ae),G(ie)):y(ie,ae)}return Ut}var Yi=bC(!0),kC=bC(!1),dh=Ta(null),hh=null,Xi=null,Mg=null;function $g(){Mg=Xi=hh=null}function Lg(c){var d=dh.current;At(dh),c._currentValue=d}function Ig(c,d,y){for(;c!==null;){var j=c.alternate;if((c.childLanes&d)!==d?(c.childLanes|=d,j!==null&&(j.childLanes|=d)):j!==null&&(j.childLanes&d)!==d&&(j.childLanes|=d),c===y)break;c=c.return}}function Zi(c,d){hh=c,Mg=Xi=null,c=c.dependencies,c!==null&&c.firstContext!==null&&((c.lanes&d)!==0&&($n=!0),c.firstContext=null)}function us(c){var d=c._currentValue;if(Mg!==c)if(c={context:c,memoizedValue:d,next:null},Xi===null){if(hh===null)throw Error(n(308));Xi=c,hh.dependencies={lanes:0,firstContext:c}}else Xi=Xi.next=c;return d}var Io=null;function Og(c){Io===null?Io=[c]:Io.push(c)}function jC(c,d,y,j){var E=d.interleaved;return E===null?(y.next=y,Og(d)):(y.next=E.next,E.next=y),d.interleaved=y,Gr(c,j)}function Gr(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 Ma=!1;function Pg(c){c.updateQueue={baseState:c.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function NC(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 Kr(c,d){return{eventTime:c,lane:d,tag:0,payload:null,callback:null,next:null}}function $a(c,d,y){var j=c.updateQueue;if(j===null)return null;if(j=j.shared,(dt&2)!==0){var E=j.pending;return E===null?d.next=d:(d.next=E.next,E.next=d),j.pending=d,Gr(c,y)}return E=j.interleaved,E===null?(d.next=d,Og(j)):(d.next=E.next,E.next=d),j.interleaved=d,Gr(c,y)}function fh(c,d,y){if(d=d.updateQueue,d!==null&&(d=d.shared,(y&4194240)!==0)){var j=d.lanes;j&=c.pendingLanes,y|=j,d.lanes=y,Ir(c,y)}}function SC(c,d){var y=c.updateQueue,j=c.alternate;if(j!==null&&(j=j.updateQueue,y===j)){var E=null,L=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};L===null?E=L=G:L=L.next=G,y=y.next}while(y!==null);L===null?E=L=d:L=L.next=d}else E=L=d;y={baseState:j.baseState,firstBaseUpdate:E,lastBaseUpdate:L,shared:j.shared,effects:j.effects},c.updateQueue=y;return}c=y.lastBaseUpdate,c===null?y.firstBaseUpdate=d:c.next=d,y.lastBaseUpdate=d}function ph(c,d,y,j){var E=c.updateQueue;Ma=!1;var L=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?L=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(L!==null){var Ce=E.baseState;G=0,Se=ue=ne=null,ee=L;do{var Ne=ee.lane,Pe=ee.eventTime;if((j&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=P({},Ce,Ne);break e;case 2:Ma=!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 L===null&&(E.shared.lanes=0);Do|=G,c.lanes=G,c.memoizedState=Ce}}function CC(c,d,y){if(c=d.effects,d.effects=null,c!==null)for(d=0;d<c.length;d++){var j=c[d],E=j.callback;if(E!==null){if(j.callback=null,j=y,typeof E!="function")throw Error(n(191,E));E.call(j)}}}var qc={},ur=Ta(qc),Uc=Ta(qc),Wc=Ta(qc);function Oo(c){if(c===qc)throw Error(n(174));return c}function Dg(c,d){switch(St(Wc,d),St(Uc,c),St(ur,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(ur),St(ur,d)}function Ji(){At(ur),At(Uc),At(Wc)}function _C(c){Oo(Wc.current);var d=Oo(ur.current),y=Fe(d,c.type);d!==y&&(St(Uc,c),St(ur,y))}function Fg(c){Uc.current===c&&(At(ur),At(Uc))}var It=Ta(0);function mh(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 Bg=[];function qg(){for(var c=0;c<Bg.length;c++)Bg[c]._workInProgressVersionPrimary=null;Bg.length=0}var gh=S.ReactCurrentDispatcher,Ug=S.ReactCurrentBatchConfig,Po=0,Ot=null,Kt=null,tn=null,yh=!1,Hc=!1,zc=0,UB=0;function mn(){throw Error(n(321))}function Wg(c,d){if(d===null)return!1;for(var y=0;y<d.length&&y<c.length;y++)if(!Ds(c[y],d[y]))return!1;return!0}function Hg(c,d,y,j,E,L){if(Po=L,Ot=d,d.memoizedState=null,d.updateQueue=null,d.lanes=0,gh.current=c===null||c.memoizedState===null?VB:GB,c=y(j,E),Hc){L=0;do{if(Hc=!1,zc=0,25<=L)throw Error(n(301));L+=1,tn=Kt=null,d.updateQueue=null,gh.current=KB,c=y(j,E)}while(Hc)}if(gh.current=vh,d=Kt!==null&&Kt.next!==null,Po=0,tn=Kt=Ot=null,yh=!1,d)throw Error(n(300));return c}function zg(){var c=zc!==0;return zc=0,c}function dr(){var c={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return tn===null?Ot.memoizedState=tn=c:tn=tn.next=c,tn}function ds(){if(Kt===null){var c=Ot.alternate;c=c!==null?c.memoizedState:null}else c=Kt.next;var d=tn===null?Ot.memoizedState:tn.next;if(d!==null)tn=d,Kt=c;else{if(c===null)throw Error(n(310));Kt=c,c={memoizedState:Kt.memoizedState,baseState:Kt.baseState,baseQueue:Kt.baseQueue,queue:Kt.queue,next:null},tn===null?Ot.memoizedState=tn=c:tn=tn.next=c}return tn}function Vc(c,d){return typeof d=="function"?d(c):d}function Vg(c){var d=ds(),y=d.queue;if(y===null)throw Error(n(311));y.lastRenderedReducer=c;var j=Kt,E=j.baseQueue,L=y.pending;if(L!==null){if(E!==null){var G=E.next;E.next=L.next,L.next=G}j.baseQueue=E=L,y.pending=null}if(E!==null){L=E.next,j=j.baseState;var ee=G=null,ne=null,ue=L;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}),j=ue.hasEagerState?ue.eagerState:c(j,ue.action);else{var Ce={lane:Se,action:ue.action,hasEagerState:ue.hasEagerState,eagerState:ue.eagerState,next:null};ne===null?(ee=ne=Ce,G=j):ne=ne.next=Ce,Ot.lanes|=Se,Do|=Se}ue=ue.next}while(ue!==null&&ue!==L);ne===null?G=j:ne.next=ee,Ds(j,d.memoizedState)||($n=!0),d.memoizedState=j,d.baseState=G,d.baseQueue=ne,y.lastRenderedState=j}if(c=y.interleaved,c!==null){E=c;do L=E.lane,Ot.lanes|=L,Do|=L,E=E.next;while(E!==c)}else E===null&&(y.lanes=0);return[d.memoizedState,y.dispatch]}function Gg(c){var d=ds(),y=d.queue;if(y===null)throw Error(n(311));y.lastRenderedReducer=c;var j=y.dispatch,E=y.pending,L=d.memoizedState;if(E!==null){y.pending=null;var G=E=E.next;do L=c(L,G.action),G=G.next;while(G!==E);Ds(L,d.memoizedState)||($n=!0),d.memoizedState=L,d.baseQueue===null&&(d.baseState=L),y.lastRenderedState=L}return[L,j]}function EC(){}function TC(c,d){var y=Ot,j=ds(),E=d(),L=!Ds(j.memoizedState,E);if(L&&(j.memoizedState=E,$n=!0),j=j.queue,Kg(MC.bind(null,y,j,c),[c]),j.getSnapshot!==d||L||tn!==null&&tn.memoizedState.tag&1){if(y.flags|=2048,Gc(9,RC.bind(null,y,j,E,d),void 0,null),nn===null)throw Error(n(349));(Po&30)!==0||AC(y,d,E)}return E}function AC(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 RC(c,d,y,j){d.value=y,d.getSnapshot=j,$C(d)&&LC(c)}function MC(c,d,y){return y(function(){$C(d)&&LC(c)})}function $C(c){var d=c.getSnapshot;c=c.value;try{var y=d();return!Ds(c,y)}catch{return!0}}function LC(c){var d=Gr(c,1);d!==null&&Ws(d,c,1,-1)}function IC(c){var d=dr();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=zB.bind(null,Ot,c),[d.memoizedState,c]}function Gc(c,d,y,j){return c={tag:c,create:d,destroy:y,deps:j,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:(j=y.next,y.next=c,c.next=j,d.lastEffect=c)),c}function OC(){return ds().memoizedState}function wh(c,d,y,j){var E=dr();Ot.flags|=c,E.memoizedState=Gc(1|d,y,void 0,j===void 0?null:j)}function xh(c,d,y,j){var E=ds();j=j===void 0?null:j;var L=void 0;if(Kt!==null){var G=Kt.memoizedState;if(L=G.destroy,j!==null&&Wg(j,G.deps)){E.memoizedState=Gc(d,y,L,j);return}}Ot.flags|=c,E.memoizedState=Gc(1|d,y,L,j)}function PC(c,d){return wh(8390656,8,c,d)}function Kg(c,d){return xh(2048,8,c,d)}function DC(c,d){return xh(4,2,c,d)}function FC(c,d){return xh(4,4,c,d)}function BC(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 qC(c,d,y){return y=y!=null?y.concat([c]):null,xh(4,4,BC.bind(null,d,c),y)}function Yg(){}function UC(c,d){var y=ds();d=d===void 0?null:d;var j=y.memoizedState;return j!==null&&d!==null&&Wg(d,j[1])?j[0]:(y.memoizedState=[c,d],c)}function WC(c,d){var y=ds();d=d===void 0?null:d;var j=y.memoizedState;return j!==null&&d!==null&&Wg(d,j[1])?j[0]:(c=c(),y.memoizedState=[c,d],c)}function HC(c,d,y){return(Po&21)===0?(c.baseState&&(c.baseState=!1,$n=!0),c.memoizedState=y):(Ds(y,d)||(y=or(),Ot.lanes|=y,Do|=y,c.baseState=!0),d)}function WB(c,d){var y=at;at=y!==0&&4>y?y:4,c(!0);var j=Ug.transition;Ug.transition={};try{c(!1),d()}finally{at=y,Ug.transition=j}}function zC(){return ds().memoizedState}function HB(c,d,y){var j=Pa(c);if(y={lane:j,action:y,hasEagerState:!1,eagerState:null,next:null},VC(c))GC(d,y);else if(y=jC(c,d,y,j),y!==null){var E=jn();Ws(y,c,j,E),KC(y,d,j)}}function zB(c,d,y){var j=Pa(c),E={lane:j,action:y,hasEagerState:!1,eagerState:null,next:null};if(VC(c))GC(d,E);else{var L=c.alternate;if(c.lanes===0&&(L===null||L.lanes===0)&&(L=d.lastRenderedReducer,L!==null))try{var G=d.lastRenderedState,ee=L(G,y);if(E.hasEagerState=!0,E.eagerState=ee,Ds(ee,G)){var ne=d.interleaved;ne===null?(E.next=E,Og(d)):(E.next=ne.next,ne.next=E),d.interleaved=E;return}}catch{}finally{}y=jC(c,d,E,j),y!==null&&(E=jn(),Ws(y,c,j,E),KC(y,d,j))}}function VC(c){var d=c.alternate;return c===Ot||d!==null&&d===Ot}function GC(c,d){Hc=yh=!0;var y=c.pending;y===null?d.next=d:(d.next=y.next,y.next=d),c.pending=d}function KC(c,d,y){if((y&4194240)!==0){var j=d.lanes;j&=c.pendingLanes,y|=j,d.lanes=y,Ir(c,y)}}var vh={readContext:us,useCallback:mn,useContext:mn,useEffect:mn,useImperativeHandle:mn,useInsertionEffect:mn,useLayoutEffect:mn,useMemo:mn,useReducer:mn,useRef:mn,useState:mn,useDebugValue:mn,useDeferredValue:mn,useTransition:mn,useMutableSource:mn,useSyncExternalStore:mn,useId:mn,unstable_isNewReconciler:!1},VB={readContext:us,useCallback:function(c,d){return dr().memoizedState=[c,d===void 0?null:d],c},useContext:us,useEffect:PC,useImperativeHandle:function(c,d,y){return y=y!=null?y.concat([c]):null,wh(4194308,4,BC.bind(null,d,c),y)},useLayoutEffect:function(c,d){return wh(4194308,4,c,d)},useInsertionEffect:function(c,d){return wh(4,2,c,d)},useMemo:function(c,d){var y=dr();return d=d===void 0?null:d,c=c(),y.memoizedState=[c,d],c},useReducer:function(c,d,y){var j=dr();return d=y!==void 0?y(d):d,j.memoizedState=j.baseState=d,c={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:c,lastRenderedState:d},j.queue=c,c=c.dispatch=HB.bind(null,Ot,c),[j.memoizedState,c]},useRef:function(c){var d=dr();return c={current:c},d.memoizedState=c},useState:IC,useDebugValue:Yg,useDeferredValue:function(c){return dr().memoizedState=c},useTransition:function(){var c=IC(!1),d=c[0];return c=WB.bind(null,c[1]),dr().memoizedState=c,[d,c]},useMutableSource:function(){},useSyncExternalStore:function(c,d,y){var j=Ot,E=dr();if(Rt){if(y===void 0)throw Error(n(407));y=y()}else{if(y=d(),nn===null)throw Error(n(349));(Po&30)!==0||AC(j,d,y)}E.memoizedState=y;var L={value:y,getSnapshot:d};return E.queue=L,PC(MC.bind(null,j,L,c),[c]),j.flags|=2048,Gc(9,RC.bind(null,j,L,y,d),void 0,null),y},useId:function(){var c=dr(),d=nn.identifierPrefix;if(Rt){var y=Vr,j=zr;y=(j&~(1<<32-fn(j)-1)).toString(32)+y,d=":"+d+"R"+y,y=zc++,0<y&&(d+="H"+y.toString(32)),d+=":"}else y=UB++,d=":"+d+"r"+y.toString(32)+":";return c.memoizedState=d},unstable_isNewReconciler:!1},GB={readContext:us,useCallback:UC,useContext:us,useEffect:Kg,useImperativeHandle:qC,useInsertionEffect:DC,useLayoutEffect:FC,useMemo:WC,useReducer:Vg,useRef:OC,useState:function(){return Vg(Vc)},useDebugValue:Yg,useDeferredValue:function(c){var d=ds();return HC(d,Kt.memoizedState,c)},useTransition:function(){var c=Vg(Vc)[0],d=ds().memoizedState;return[c,d]},useMutableSource:EC,useSyncExternalStore:TC,useId:zC,unstable_isNewReconciler:!1},KB={readContext:us,useCallback:UC,useContext:us,useEffect:Kg,useImperativeHandle:qC,useInsertionEffect:DC,useLayoutEffect:FC,useMemo:WC,useReducer:Gg,useRef:OC,useState:function(){return Gg(Vc)},useDebugValue:Yg,useDeferredValue:function(c){var d=ds();return Kt===null?d.memoizedState=c:HC(d,Kt.memoizedState,c)},useTransition:function(){var c=Gg(Vc)[0],d=ds().memoizedState;return[c,d]},useMutableSource:EC,useSyncExternalStore:TC,useId:zC,unstable_isNewReconciler:!1};function Bs(c,d){if(c&&c.defaultProps){d=P({},d),c=c.defaultProps;for(var y in c)d[y]===void 0&&(d[y]=c[y]);return d}return d}function Xg(c,d,y,j){d=c.memoizedState,y=y(j,d),y=y==null?d:P({},d,y),c.memoizedState=y,c.lanes===0&&(c.updateQueue.baseState=y)}var bh={isMounted:function(c){return(c=c._reactInternals)?vn(c)===c:!1},enqueueSetState:function(c,d,y){c=c._reactInternals;var j=jn(),E=Pa(c),L=Kr(j,E);L.payload=d,y!=null&&(L.callback=y),d=$a(c,L,E),d!==null&&(Ws(d,c,E,j),fh(d,c,E))},enqueueReplaceState:function(c,d,y){c=c._reactInternals;var j=jn(),E=Pa(c),L=Kr(j,E);L.tag=1,L.payload=d,y!=null&&(L.callback=y),d=$a(c,L,E),d!==null&&(Ws(d,c,E,j),fh(d,c,E))},enqueueForceUpdate:function(c,d){c=c._reactInternals;var y=jn(),j=Pa(c),E=Kr(y,j);E.tag=2,d!=null&&(E.callback=d),d=$a(c,E,j),d!==null&&(Ws(d,c,j,y),fh(d,c,j))}};function YC(c,d,y,j,E,L,G){return c=c.stateNode,typeof c.shouldComponentUpdate=="function"?c.shouldComponentUpdate(j,L,G):d.prototype&&d.prototype.isPureReactComponent?!$c(y,j)||!$c(E,L):!0}function XC(c,d,y){var j=!1,E=Aa,L=d.contextType;return typeof L=="object"&&L!==null?L=us(L):(E=Mn(d)?Mo:pn.current,j=d.contextTypes,L=(j=j!=null)?zi(c,E):Aa),d=new d(y,L),c.memoizedState=d.state!==null&&d.state!==void 0?d.state:null,d.updater=bh,c.stateNode=d,d._reactInternals=c,j&&(c=c.stateNode,c.__reactInternalMemoizedUnmaskedChildContext=E,c.__reactInternalMemoizedMaskedChildContext=L),d}function ZC(c,d,y,j){c=d.state,typeof d.componentWillReceiveProps=="function"&&d.componentWillReceiveProps(y,j),typeof d.UNSAFE_componentWillReceiveProps=="function"&&d.UNSAFE_componentWillReceiveProps(y,j),d.state!==c&&bh.enqueueReplaceState(d,d.state,null)}function Zg(c,d,y,j){var E=c.stateNode;E.props=y,E.state=c.memoizedState,E.refs={},Pg(c);var L=d.contextType;typeof L=="object"&&L!==null?E.context=us(L):(L=Mn(d)?Mo:pn.current,E.context=zi(c,L)),E.state=c.memoizedState,L=d.getDerivedStateFromProps,typeof L=="function"&&(Xg(c,d,L,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&&bh.enqueueReplaceState(E,E.state,null),ph(c,y,E,j),E.state=c.memoizedState),typeof E.componentDidMount=="function"&&(c.flags|=4194308)}function Qi(c,d){try{var y="",j=d;do y+=X(j),j=j.return;while(j);var E=y}catch(L){E=`
39
- Error generating stack: `+L.message+`
40
- `+L.stack}return{value:c,source:d,stack:E,digest:null}}function Jg(c,d,y){return{value:c,source:null,stack:y??null,digest:d??null}}function Qg(c,d){try{console.error(d.value)}catch(y){setTimeout(function(){throw y})}}var YB=typeof WeakMap=="function"?WeakMap:Map;function JC(c,d,y){y=Kr(-1,y),y.tag=3,y.payload={element:null};var j=d.value;return y.callback=function(){Eh||(Eh=!0,py=j),Qg(c,d)},y}function QC(c,d,y){y=Kr(-1,y),y.tag=3;var j=c.type.getDerivedStateFromError;if(typeof j=="function"){var E=d.value;y.payload=function(){return j(E)},y.callback=function(){Qg(c,d)}}var L=c.stateNode;return L!==null&&typeof L.componentDidCatch=="function"&&(y.callback=function(){Qg(c,d),typeof j!="function"&&(Ia===null?Ia=new Set([this]):Ia.add(this));var G=d.stack;this.componentDidCatch(d.value,{componentStack:G!==null?G:""})}),y}function e_(c,d,y){var j=c.pingCache;if(j===null){j=c.pingCache=new YB;var E=new Set;j.set(d,E)}else E=j.get(d),E===void 0&&(E=new Set,j.set(d,E));E.has(y)||(E.add(y),c=cq.bind(null,c,d,y),d.then(c,c))}function t_(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 n_(c,d,y,j,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=Kr(-1,1),d.tag=2,$a(y,d,1))),y.lanes|=1),c):(c.flags|=65536,c.lanes=E,c)}var XB=S.ReactCurrentOwner,$n=!1;function kn(c,d,y,j){d.child=c===null?kC(d,null,y,j):Yi(d,c.child,y,j)}function s_(c,d,y,j,E){y=y.render;var L=d.ref;return Zi(d,E),j=Hg(c,d,y,j,L,E),y=zg(),c!==null&&!$n?(d.updateQueue=c.updateQueue,d.flags&=-2053,c.lanes&=~E,Yr(c,d,E)):(Rt&&y&&_g(d),d.flags|=1,kn(c,d,j,E),d.child)}function r_(c,d,y,j,E){if(c===null){var L=y.type;return typeof L=="function"&&!by(L)&&L.defaultProps===void 0&&y.compare===null&&y.defaultProps===void 0?(d.tag=15,d.type=L,a_(c,d,L,j,E)):(c=Lh(y.type,null,j,d,d.mode,E),c.ref=d.ref,c.return=d,d.child=c)}if(L=c.child,(c.lanes&E)===0){var G=L.memoizedProps;if(y=y.compare,y=y!==null?y:$c,y(G,j)&&c.ref===d.ref)return Yr(c,d,E)}return d.flags|=1,c=Fa(L,j),c.ref=d.ref,c.return=d,d.child=c}function a_(c,d,y,j,E){if(c!==null){var L=c.memoizedProps;if($c(L,j)&&c.ref===d.ref)if($n=!1,d.pendingProps=j=L,(c.lanes&E)!==0)(c.flags&131072)!==0&&($n=!0);else return d.lanes=c.lanes,Yr(c,d,E)}return ey(c,d,y,j,E)}function o_(c,d,y){var j=d.pendingProps,E=j.children,L=c!==null?c.memoizedState:null;if(j.mode==="hidden")if((d.mode&1)===0)d.memoizedState={baseLanes:0,cachePool:null,transitions:null},St(tl,Xn),Xn|=y;else{if((y&1073741824)===0)return c=L!==null?L.baseLanes|y:y,d.lanes=d.childLanes=1073741824,d.memoizedState={baseLanes:c,cachePool:null,transitions:null},d.updateQueue=null,St(tl,Xn),Xn|=c,null;d.memoizedState={baseLanes:0,cachePool:null,transitions:null},j=L!==null?L.baseLanes:y,St(tl,Xn),Xn|=j}else L!==null?(j=L.baseLanes|y,d.memoizedState=null):j=y,St(tl,Xn),Xn|=j;return kn(c,d,E,y),d.child}function i_(c,d){var y=d.ref;(c===null&&y!==null||c!==null&&c.ref!==y)&&(d.flags|=512,d.flags|=2097152)}function ey(c,d,y,j,E){var L=Mn(y)?Mo:pn.current;return L=zi(d,L),Zi(d,E),y=Hg(c,d,y,j,L,E),j=zg(),c!==null&&!$n?(d.updateQueue=c.updateQueue,d.flags&=-2053,c.lanes&=~E,Yr(c,d,E)):(Rt&&j&&_g(d),d.flags|=1,kn(c,d,y,E),d.child)}function l_(c,d,y,j,E){if(Mn(y)){var L=!0;ah(d)}else L=!1;if(Zi(d,E),d.stateNode===null)jh(c,d),XC(d,y,j),Zg(d,y,j,E),j=!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=us(ue):(ue=Mn(y)?Mo:pn.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!==j||ne!==ue)&&ZC(d,G,j,ue),Ma=!1;var Ne=d.memoizedState;G.state=Ne,ph(d,j,G,E),ne=d.memoizedState,ee!==j||Ne!==ne||Rn.current||Ma?(typeof Se=="function"&&(Xg(d,y,Se,j),ne=d.memoizedState),(ee=Ma||YC(d,y,ee,j,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=j,d.memoizedState=ne),G.props=j,G.state=ne,G.context=ue,j=ee):(typeof G.componentDidMount=="function"&&(d.flags|=4194308),j=!1)}else{G=d.stateNode,NC(c,d),ee=d.memoizedProps,ue=d.type===d.elementType?ee:Bs(d.type,ee),G.props=ue,Ce=d.pendingProps,Ne=G.context,ne=y.contextType,typeof ne=="object"&&ne!==null?ne=us(ne):(ne=Mn(y)?Mo:pn.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)&&ZC(d,G,j,ne),Ma=!1,Ne=d.memoizedState,G.state=Ne,ph(d,j,G,E);var Ue=d.memoizedState;ee!==Ce||Ne!==Ue||Rn.current||Ma?(typeof Pe=="function"&&(Xg(d,y,Pe,j),Ue=d.memoizedState),(ue=Ma||YC(d,y,ue,j,Ne,Ue,ne)||!1)?(Se||typeof G.UNSAFE_componentWillUpdate!="function"&&typeof G.componentWillUpdate!="function"||(typeof G.componentWillUpdate=="function"&&G.componentWillUpdate(j,Ue,ne),typeof G.UNSAFE_componentWillUpdate=="function"&&G.UNSAFE_componentWillUpdate(j,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=j,d.memoizedState=Ue),G.props=j,G.state=Ue,G.context=ne,j=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),j=!1)}return ty(c,d,y,j,L,E)}function ty(c,d,y,j,E,L){i_(c,d);var G=(d.flags&128)!==0;if(!j&&!G)return E&&fC(d,y,!1),Yr(c,d,L);j=d.stateNode,XB.current=d;var ee=G&&typeof y.getDerivedStateFromError!="function"?null:j.render();return d.flags|=1,c!==null&&G?(d.child=Yi(d,c.child,null,L),d.child=Yi(d,null,ee,L)):kn(c,d,ee,L),d.memoizedState=j.state,E&&fC(d,y,!0),d.child}function c_(c){var d=c.stateNode;d.pendingContext?dC(c,d.pendingContext,d.pendingContext!==d.context):d.context&&dC(c,d.context,!1),Dg(c,d.containerInfo)}function u_(c,d,y,j,E){return Ki(),Rg(E),d.flags|=256,kn(c,d,y,j),d.child}var ny={dehydrated:null,treeContext:null,retryLane:0};function sy(c){return{baseLanes:c,cachePool:null,transitions:null}}function d_(c,d,y){var j=d.pendingProps,E=It.current,L=!1,G=(d.flags&128)!==0,ee;if((ee=G)||(ee=c!==null&&c.memoizedState===null?!1:(E&2)!==0),ee?(L=!0,d.flags&=-129):(c===null||c.memoizedState!==null)&&(E|=1),St(It,E&1),c===null)return Ag(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=j.children,c=j.fallback,L?(j=d.mode,L=d.child,G={mode:"hidden",children:G},(j&1)===0&&L!==null?(L.childLanes=0,L.pendingProps=G):L=Ih(G,j,0,null),c=Uo(c,j,y,null),L.return=d,c.return=d,L.sibling=c,d.child=L,d.child.memoizedState=sy(y),d.memoizedState=ny,c):ry(d,G));if(E=c.memoizedState,E!==null&&(ee=E.dehydrated,ee!==null))return ZB(c,d,G,j,ee,E,y);if(L){L=j.fallback,G=d.mode,E=c.child,ee=E.sibling;var ne={mode:"hidden",children:j.children};return(G&1)===0&&d.child!==E?(j=d.child,j.childLanes=0,j.pendingProps=ne,d.deletions=null):(j=Fa(E,ne),j.subtreeFlags=E.subtreeFlags&14680064),ee!==null?L=Fa(ee,L):(L=Uo(L,G,y,null),L.flags|=2),L.return=d,j.return=d,j.sibling=L,d.child=j,j=L,L=d.child,G=c.child.memoizedState,G=G===null?sy(y):{baseLanes:G.baseLanes|y,cachePool:null,transitions:G.transitions},L.memoizedState=G,L.childLanes=c.childLanes&~y,d.memoizedState=ny,j}return L=c.child,c=L.sibling,j=Fa(L,{mode:"visible",children:j.children}),(d.mode&1)===0&&(j.lanes=y),j.return=d,j.sibling=null,c!==null&&(y=d.deletions,y===null?(d.deletions=[c],d.flags|=16):y.push(c)),d.child=j,d.memoizedState=null,j}function ry(c,d){return d=Ih({mode:"visible",children:d},c.mode,0,null),d.return=c,c.child=d}function kh(c,d,y,j){return j!==null&&Rg(j),Yi(d,c.child,null,y),c=ry(d,d.pendingProps.children),c.flags|=2,d.memoizedState=null,c}function ZB(c,d,y,j,E,L,G){if(y)return d.flags&256?(d.flags&=-257,j=Jg(Error(n(422))),kh(c,d,G,j)):d.memoizedState!==null?(d.child=c.child,d.flags|=128,null):(L=j.fallback,E=d.mode,j=Ih({mode:"visible",children:j.children},E,0,null),L=Uo(L,E,G,null),L.flags|=2,j.return=d,L.return=d,j.sibling=L,d.child=j,(d.mode&1)!==0&&Yi(d,c.child,null,G),d.child.memoizedState=sy(G),d.memoizedState=ny,L);if((d.mode&1)===0)return kh(c,d,G,null);if(E.data==="$!"){if(j=E.nextSibling&&E.nextSibling.dataset,j)var ee=j.dgst;return j=ee,L=Error(n(419)),j=Jg(L,j,void 0),kh(c,d,G,j)}if(ee=(G&c.childLanes)!==0,$n||ee){if(j=nn,j!==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&(j.suspendedLanes|G))!==0?0:E,E!==0&&E!==L.retryLane&&(L.retryLane=E,Gr(c,E),Ws(j,c,E,-1))}return vy(),j=Jg(Error(n(421))),kh(c,d,G,j)}return E.data==="$?"?(d.flags|=128,d.child=c.child,d=uq.bind(null,c),E._reactRetry=d,null):(c=L.treeContext,Yn=Ea(E.nextSibling),Kn=d,Rt=!0,Fs=null,c!==null&&(ls[cs++]=zr,ls[cs++]=Vr,ls[cs++]=$o,zr=c.id,Vr=c.overflow,$o=d),d=ry(d,j.children),d.flags|=4096,d)}function h_(c,d,y){c.lanes|=d;var j=c.alternate;j!==null&&(j.lanes|=d),Ig(c.return,d,y)}function ay(c,d,y,j,E){var L=c.memoizedState;L===null?c.memoizedState={isBackwards:d,rendering:null,renderingStartTime:0,last:j,tail:y,tailMode:E}:(L.isBackwards=d,L.rendering=null,L.renderingStartTime=0,L.last=j,L.tail=y,L.tailMode=E)}function f_(c,d,y){var j=d.pendingProps,E=j.revealOrder,L=j.tail;if(kn(c,d,j.children,y),j=It.current,(j&2)!==0)j=j&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&&h_(c,y,d);else if(c.tag===19)h_(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}j&=1}if(St(It,j),(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&&mh(c)===null&&(E=y),y=y.sibling;y=E,y===null?(E=d.child,d.child=null):(E=y.sibling,y.sibling=null),ay(d,!1,E,y,L);break;case"backwards":for(y=null,E=d.child,d.child=null;E!==null;){if(c=E.alternate,c!==null&&mh(c)===null){d.child=E;break}c=E.sibling,E.sibling=y,y=E,E=c}ay(d,!0,y,null,L);break;case"together":ay(d,!1,null,null,void 0);break;default:d.memoizedState=null}return d.child}function jh(c,d){(d.mode&1)===0&&c!==null&&(c.alternate=null,d.alternate=null,d.flags|=2)}function Yr(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=Fa(c,c.pendingProps),d.child=y,y.return=d;c.sibling!==null;)c=c.sibling,y=y.sibling=Fa(c,c.pendingProps),y.return=d;y.sibling=null}return d.child}function JB(c,d,y){switch(d.tag){case 3:c_(d),Ki();break;case 5:_C(d);break;case 1:Mn(d.type)&&ah(d);break;case 4:Dg(d,d.stateNode.containerInfo);break;case 10:var j=d.type._context,E=d.memoizedProps.value;St(dh,j._currentValue),j._currentValue=E;break;case 13:if(j=d.memoizedState,j!==null)return j.dehydrated!==null?(St(It,It.current&1),d.flags|=128,null):(y&d.child.childLanes)!==0?d_(c,d,y):(St(It,It.current&1),c=Yr(c,d,y),c!==null?c.sibling:null);St(It,It.current&1);break;case 19:if(j=(y&d.childLanes)!==0,(c.flags&128)!==0){if(j)return f_(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),j)break;return null;case 22:case 23:return d.lanes=0,o_(c,d,y)}return Yr(c,d,y)}var p_,oy,m_,g_;p_=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}},oy=function(){},m_=function(c,d,y,j){var E=c.memoizedProps;if(E!==j){c=d.stateNode,Oo(ur.current);var L=null;switch(y){case"input":E=he(c,E),j=he(c,j),L=[];break;case"select":E=P({},E,{value:void 0}),j=P({},j,{value:void 0}),L=[];break;case"textarea":E=Ie(c,E),j=Ie(c,j),L=[];break;default:typeof E.onClick!="function"&&typeof j.onClick=="function"&&(c.onclick=nh)}be(y,j);var G;y=null;for(ue in E)if(!j.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)?L||(L=[]):(L=L||[]).push(ue,null));for(ue in j){var ne=j[ue];if(ee=E!=null?E[ue]:void 0,j.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||(L||(L=[]),L.push(ue,y)),y=ne;else ue==="dangerouslySetInnerHTML"?(ne=ne?ne.__html:void 0,ee=ee?ee.__html:void 0,ne!=null&&ee!==ne&&(L=L||[]).push(ue,ne)):ue==="children"?typeof ne!="string"&&typeof ne!="number"||(L=L||[]).push(ue,""+ne):ue!=="suppressContentEditableWarning"&&ue!=="suppressHydrationWarning"&&(a.hasOwnProperty(ue)?(ne!=null&&ue==="onScroll"&&Tt("scroll",c),L||ee===ne||(L=[])):(L=L||[]).push(ue,ne))}y&&(L=L||[]).push("style",y);var ue=L;(d.updateQueue=ue)&&(d.flags|=4)}},g_=function(c,d,y,j){y!==j&&(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 j=null;y!==null;)y.alternate!==null&&(j=y),y=y.sibling;j===null?d||c.tail===null?c.tail=null:c.tail.sibling=null:j.sibling=null}}function gn(c){var d=c.alternate!==null&&c.alternate.child===c.child,y=0,j=0;if(d)for(var E=c.child;E!==null;)y|=E.lanes|E.childLanes,j|=E.subtreeFlags&14680064,j|=E.flags&14680064,E.return=c,E=E.sibling;else for(E=c.child;E!==null;)y|=E.lanes|E.childLanes,j|=E.subtreeFlags,j|=E.flags,E.return=c,E=E.sibling;return c.subtreeFlags|=j,c.childLanes=y,d}function QB(c,d,y){var j=d.pendingProps;switch(Eg(d),d.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return gn(d),null;case 1:return Mn(d.type)&&rh(),gn(d),null;case 3:return j=d.stateNode,Ji(),At(Rn),At(pn),qg(),j.pendingContext&&(j.context=j.pendingContext,j.pendingContext=null),(c===null||c.child===null)&&(ch(d)?d.flags|=4:c===null||c.memoizedState.isDehydrated&&(d.flags&256)===0||(d.flags|=1024,Fs!==null&&(yy(Fs),Fs=null))),oy(c,d),gn(d),null;case 5:Fg(d);var E=Oo(Wc.current);if(y=d.type,c!==null&&d.stateNode!=null)m_(c,d,y,j,E),c.ref!==d.ref&&(d.flags|=512,d.flags|=2097152);else{if(!j){if(d.stateNode===null)throw Error(n(166));return gn(d),null}if(c=Oo(ur.current),ch(d)){j=d.stateNode,y=d.type;var L=d.memoizedProps;switch(j[cr]=d,j[Dc]=L,c=(d.mode&1)!==0,y){case"dialog":Tt("cancel",j),Tt("close",j);break;case"iframe":case"object":case"embed":Tt("load",j);break;case"video":case"audio":for(E=0;E<Ic.length;E++)Tt(Ic[E],j);break;case"source":Tt("error",j);break;case"img":case"image":case"link":Tt("error",j),Tt("load",j);break;case"details":Tt("toggle",j);break;case"input":pe(j,L),Tt("invalid",j);break;case"select":j._wrapperState={wasMultiple:!!L.multiple},Tt("invalid",j);break;case"textarea":De(j,L),Tt("invalid",j)}be(y,L),E=null;for(var G in L)if(L.hasOwnProperty(G)){var ee=L[G];G==="children"?typeof ee=="string"?j.textContent!==ee&&(L.suppressHydrationWarning!==!0&&th(j.textContent,ee,c),E=["children",ee]):typeof ee=="number"&&j.textContent!==""+ee&&(L.suppressHydrationWarning!==!0&&th(j.textContent,ee,c),E=["children",""+ee]):a.hasOwnProperty(G)&&ee!=null&&G==="onScroll"&&Tt("scroll",j)}switch(y){case"input":de(j),ve(j,L,!0);break;case"textarea":de(j),Ke(j);break;case"select":case"option":break;default:typeof L.onClick=="function"&&(j.onclick=nh)}j=E,d.updateQueue=j,j!==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 j.is=="string"?c=G.createElement(y,{is:j.is}):(c=G.createElement(y),y==="select"&&(G=c,j.multiple?G.multiple=!0:j.size&&(G.size=j.size))):c=G.createElementNS(c,y),c[cr]=d,c[Dc]=j,p_(c,d,!1,!1),d.stateNode=c;e:{switch(G=fe(y,j),y){case"dialog":Tt("cancel",c),Tt("close",c),E=j;break;case"iframe":case"object":case"embed":Tt("load",c),E=j;break;case"video":case"audio":for(E=0;E<Ic.length;E++)Tt(Ic[E],c);E=j;break;case"source":Tt("error",c),E=j;break;case"img":case"image":case"link":Tt("error",c),Tt("load",c),E=j;break;case"details":Tt("toggle",c),E=j;break;case"input":pe(c,j),E=he(c,j),Tt("invalid",c);break;case"option":E=j;break;case"select":c._wrapperState={wasMultiple:!!j.multiple},E=P({},j,{value:void 0}),Tt("invalid",c);break;case"textarea":De(c,j),E=Ie(c,j),Tt("invalid",c);break;default:E=j}be(y,E),ee=E;for(L in ee)if(ee.hasOwnProperty(L)){var ne=ee[L];L==="style"?Ae(c,ne):L==="dangerouslySetInnerHTML"?(ne=ne?ne.__html:void 0,ne!=null&&Re(c,ne)):L==="children"?typeof ne=="string"?(y!=="textarea"||ne!=="")&&rt(c,ne):typeof ne=="number"&&rt(c,""+ne):L!=="suppressContentEditableWarning"&&L!=="suppressHydrationWarning"&&L!=="autoFocus"&&(a.hasOwnProperty(L)?ne!=null&&L==="onScroll"&&Tt("scroll",c):ne!=null&&C(c,L,ne,G))}switch(y){case"input":de(c),ve(c,j,!1);break;case"textarea":de(c),Ke(c);break;case"option":j.value!=null&&c.setAttribute("value",""+Q(j.value));break;case"select":c.multiple=!!j.multiple,L=j.value,L!=null?xe(c,!!j.multiple,L,!1):j.defaultValue!=null&&xe(c,!!j.multiple,j.defaultValue,!0);break;default:typeof E.onClick=="function"&&(c.onclick=nh)}switch(y){case"button":case"input":case"select":case"textarea":j=!!j.autoFocus;break e;case"img":j=!0;break e;default:j=!1}}j&&(d.flags|=4)}d.ref!==null&&(d.flags|=512,d.flags|=2097152)}return gn(d),null;case 6:if(c&&d.stateNode!=null)g_(c,d,c.memoizedProps,j);else{if(typeof j!="string"&&d.stateNode===null)throw Error(n(166));if(y=Oo(Wc.current),Oo(ur.current),ch(d)){if(j=d.stateNode,y=d.memoizedProps,j[cr]=d,(L=j.nodeValue!==y)&&(c=Kn,c!==null))switch(c.tag){case 3:th(j.nodeValue,y,(c.mode&1)!==0);break;case 5:c.memoizedProps.suppressHydrationWarning!==!0&&th(j.nodeValue,y,(c.mode&1)!==0)}L&&(d.flags|=4)}else j=(y.nodeType===9?y:y.ownerDocument).createTextNode(j),j[cr]=d,d.stateNode=j}return gn(d),null;case 13:if(At(It),j=d.memoizedState,c===null||c.memoizedState!==null&&c.memoizedState.dehydrated!==null){if(Rt&&Yn!==null&&(d.mode&1)!==0&&(d.flags&128)===0)xC(),Ki(),d.flags|=98560,L=!1;else if(L=ch(d),j!==null&&j.dehydrated!==null){if(c===null){if(!L)throw Error(n(318));if(L=d.memoizedState,L=L!==null?L.dehydrated:null,!L)throw Error(n(317));L[cr]=d}else Ki(),(d.flags&128)===0&&(d.memoizedState=null),d.flags|=4;gn(d),L=!1}else Fs!==null&&(yy(Fs),Fs=null),L=!0;if(!L)return d.flags&65536?d:null}return(d.flags&128)!==0?(d.lanes=y,d):(j=j!==null,j!==(c!==null&&c.memoizedState!==null)&&j&&(d.child.flags|=8192,(d.mode&1)!==0&&(c===null||(It.current&1)!==0?Yt===0&&(Yt=3):vy())),d.updateQueue!==null&&(d.flags|=4),gn(d),null);case 4:return Ji(),oy(c,d),c===null&&Oc(d.stateNode.containerInfo),gn(d),null;case 10:return Lg(d.type._context),gn(d),null;case 17:return Mn(d.type)&&rh(),gn(d),null;case 19:if(At(It),L=d.memoizedState,L===null)return gn(d),null;if(j=(d.flags&128)!==0,G=L.rendering,G===null)if(j)Kc(L,!1);else{if(Yt!==0||c!==null&&(c.flags&128)!==0)for(c=d.child;c!==null;){if(G=mh(c),G!==null){for(d.flags|=128,Kc(L,!1),j=G.updateQueue,j!==null&&(d.updateQueue=j,d.flags|=4),d.subtreeFlags=0,j=y,y=d.child;y!==null;)L=y,c=j,L.flags&=14680066,G=L.alternate,G===null?(L.childLanes=0,L.lanes=c,L.child=null,L.subtreeFlags=0,L.memoizedProps=null,L.memoizedState=null,L.updateQueue=null,L.dependencies=null,L.stateNode=null):(L.childLanes=G.childLanes,L.lanes=G.lanes,L.child=G.child,L.subtreeFlags=0,L.deletions=null,L.memoizedProps=G.memoizedProps,L.memoizedState=G.memoizedState,L.updateQueue=G.updateQueue,L.type=G.type,c=G.dependencies,L.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}L.tail!==null&&xt()>nl&&(d.flags|=128,j=!0,Kc(L,!1),d.lanes=4194304)}else{if(!j)if(c=mh(G),c!==null){if(d.flags|=128,j=!0,y=c.updateQueue,y!==null&&(d.updateQueue=y,d.flags|=4),Kc(L,!0),L.tail===null&&L.tailMode==="hidden"&&!G.alternate&&!Rt)return gn(d),null}else 2*xt()-L.renderingStartTime>nl&&y!==1073741824&&(d.flags|=128,j=!0,Kc(L,!1),d.lanes=4194304);L.isBackwards?(G.sibling=d.child,d.child=G):(y=L.last,y!==null?y.sibling=G:d.child=G,L.last=G)}return L.tail!==null?(d=L.tail,L.rendering=d,L.tail=d.sibling,L.renderingStartTime=xt(),d.sibling=null,y=It.current,St(It,j?y&1|2:y&1),d):(gn(d),null);case 22:case 23:return xy(),j=d.memoizedState!==null,c!==null&&c.memoizedState!==null!==j&&(d.flags|=8192),j&&(d.mode&1)!==0?(Xn&1073741824)!==0&&(gn(d),d.subtreeFlags&6&&(d.flags|=8192)):gn(d),null;case 24:return null;case 25:return null}throw Error(n(156,d.tag))}function eq(c,d){switch(Eg(d),d.tag){case 1:return Mn(d.type)&&rh(),c=d.flags,c&65536?(d.flags=c&-65537|128,d):null;case 3:return Ji(),At(Rn),At(pn),qg(),c=d.flags,(c&65536)!==0&&(c&128)===0?(d.flags=c&-65537|128,d):null;case 5:return Fg(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 Lg(d.type._context),null;case 22:case 23:return xy(),null;case 24:return null;default:return null}}var Nh=!1,yn=!1,tq=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(j){Dt(c,d,j)}else y.current=null}function iy(c,d,y){try{y()}catch(j){Dt(c,d,j)}}var y_=!1;function nq(c,d){if(xg=jo,c=YS(),dg(c)){if("selectionStart"in c)var y={start:c.selectionStart,end:c.selectionEnd};else e:{y=(y=c.ownerDocument)&&y.defaultView||window;var j=y.getSelection&&y.getSelection();if(j&&j.rangeCount!==0){y=j.anchorNode;var E=j.anchorOffset,L=j.focusNode;j=j.focusOffset;try{y.nodeType,L.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!==L||j!==0&&Ce.nodeType!==3||(ne=G+j),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===L&&++Se===j&&(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(vg={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:Bs(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=y_,y_=!1,Ue}function Yc(c,d,y){var j=d.updateQueue;if(j=j!==null?j.lastEffect:null,j!==null){var E=j=j.next;do{if((E.tag&c)===c){var L=E.destroy;E.destroy=void 0,L!==void 0&&iy(d,y,L)}E=E.next}while(E!==j)}}function Sh(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 j=y.create;y.destroy=j()}y=y.next}while(y!==d)}}function ly(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 w_(c){var d=c.alternate;d!==null&&(c.alternate=null,w_(d)),c.child=null,c.deletions=null,c.sibling=null,c.tag===5&&(d=c.stateNode,d!==null&&(delete d[cr],delete d[Dc],delete d[Ng],delete d[DB],delete d[FB])),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 x_(c){return c.tag===5||c.tag===3||c.tag===4}function v_(c){e:for(;;){for(;c.sibling===null;){if(c.return===null||x_(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 cy(c,d,y){var j=c.tag;if(j===5||j===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=nh));else if(j!==4&&(c=c.child,c!==null))for(cy(c,d,y),c=c.sibling;c!==null;)cy(c,d,y),c=c.sibling}function uy(c,d,y){var j=c.tag;if(j===5||j===6)c=c.stateNode,d?y.insertBefore(c,d):y.appendChild(c);else if(j!==4&&(c=c.child,c!==null))for(uy(c,d,y),c=c.sibling;c!==null;)uy(c,d,y),c=c.sibling}var cn=null,qs=!1;function La(c,d,y){for(y=y.child;y!==null;)b_(c,d,y),y=y.sibling}function b_(c,d,y){if(hn&&typeof hn.onCommitFiberUnmount=="function")try{hn.onCommitFiberUnmount($s,y)}catch{}switch(y.tag){case 5:yn||el(y,d);case 6:var j=cn,E=qs;cn=null,La(c,d,y),cn=j,qs=E,cn!==null&&(qs?(c=cn,y=y.stateNode,c.nodeType===8?c.parentNode.removeChild(y):c.removeChild(y)):cn.removeChild(y.stateNode));break;case 18:cn!==null&&(qs?(c=cn,y=y.stateNode,c.nodeType===8?jg(c.parentNode,y):c.nodeType===1&&jg(c,y),ko(c)):jg(cn,y.stateNode));break;case 4:j=cn,E=qs,cn=y.stateNode.containerInfo,qs=!0,La(c,d,y),cn=j,qs=E;break;case 0:case 11:case 14:case 15:if(!yn&&(j=y.updateQueue,j!==null&&(j=j.lastEffect,j!==null))){E=j=j.next;do{var L=E,G=L.destroy;L=L.tag,G!==void 0&&((L&2)!==0||(L&4)!==0)&&iy(y,d,G),E=E.next}while(E!==j)}La(c,d,y);break;case 1:if(!yn&&(el(y,d),j=y.stateNode,typeof j.componentWillUnmount=="function"))try{j.props=y.memoizedProps,j.state=y.memoizedState,j.componentWillUnmount()}catch(ee){Dt(y,d,ee)}La(c,d,y);break;case 21:La(c,d,y);break;case 22:y.mode&1?(yn=(j=yn)||y.memoizedState!==null,La(c,d,y),yn=j):La(c,d,y);break;default:La(c,d,y)}}function k_(c){var d=c.updateQueue;if(d!==null){c.updateQueue=null;var y=c.stateNode;y===null&&(y=c.stateNode=new tq),d.forEach(function(j){var E=dq.bind(null,c,j);y.has(j)||(y.add(j),j.then(E,E))})}}function Us(c,d){var y=d.deletions;if(y!==null)for(var j=0;j<y.length;j++){var E=y[j];try{var L=c,G=d,ee=G;e:for(;ee!==null;){switch(ee.tag){case 5:cn=ee.stateNode,qs=!1;break e;case 3:cn=ee.stateNode.containerInfo,qs=!0;break e;case 4:cn=ee.stateNode.containerInfo,qs=!0;break e}ee=ee.return}if(cn===null)throw Error(n(160));b_(L,G,E),cn=null,qs=!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;)j_(d,c),d=d.sibling}function j_(c,d){var y=c.alternate,j=c.flags;switch(c.tag){case 0:case 11:case 14:case 15:if(Us(d,c),hr(c),j&4){try{Yc(3,c,c.return),Sh(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:Us(d,c),hr(c),j&512&&y!==null&&el(y,y.return);break;case 5:if(Us(d,c),hr(c),j&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(j&4&&(E=c.stateNode,E!=null)){var L=c.memoizedProps,G=y!==null?y.memoizedProps:L,ee=c.type,ne=c.updateQueue;if(c.updateQueue=null,ne!==null)try{ee==="input"&&L.type==="radio"&&L.name!=null&&Le(E,L),fe(ee,G);var ue=fe(ee,L);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):C(E,Se,Ce,ue)}switch(ee){case"input":ge(E,L);break;case"textarea":We(E,L);break;case"select":var Ne=E._wrapperState.wasMultiple;E._wrapperState.wasMultiple=!!L.multiple;var Pe=L.value;Pe!=null?xe(E,!!L.multiple,Pe,!1):Ne!==!!L.multiple&&(L.defaultValue!=null?xe(E,!!L.multiple,L.defaultValue,!0):xe(E,!!L.multiple,L.multiple?[]:"",!1))}E[Dc]=L}catch(ze){Dt(c,c.return,ze)}}break;case 6:if(Us(d,c),hr(c),j&4){if(c.stateNode===null)throw Error(n(162));E=c.stateNode,L=c.memoizedProps;try{E.nodeValue=L}catch(ze){Dt(c,c.return,ze)}}break;case 3:if(Us(d,c),hr(c),j&4&&y!==null&&y.memoizedState.isDehydrated)try{ko(d.containerInfo)}catch(ze){Dt(c,c.return,ze)}break;case 4:Us(d,c),hr(c);break;case 13:Us(d,c),hr(c),E=c.child,E.flags&8192&&(L=E.memoizedState!==null,E.stateNode.isHidden=L,!L||E.alternate!==null&&E.alternate.memoizedState!==null||(fy=xt())),j&4&&k_(c);break;case 22:if(Se=y!==null&&y.memoizedState!==null,c.mode&1?(yn=(ue=yn)||Se,Us(d,c),yn=ue):Us(d,c),hr(c),j&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"){j=Ne,y=Ne.return;try{d=j,Ue.props=d.memoizedProps,Ue.state=d.memoizedState,Ue.componentWillUnmount()}catch(ze){Dt(j,y,ze)}}break;case 5:el(Ne,Ne.return);break;case 22:if(Ne.memoizedState!==null){C_(Ce);continue}}Pe!==null?(Pe.return=Ne,Be=Pe):C_(Ce)}Se=Se.sibling}e:for(Se=null,Ce=c;;){if(Ce.tag===5){if(Se===null){Se=Ce;try{E=Ce.stateNode,ue?(L=E.style,typeof L.setProperty=="function"?L.setProperty("display","none","important"):L.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:Us(d,c),hr(c),j&4&&k_(c);break;case 21:break;default:Us(d,c),hr(c)}}function hr(c){var d=c.flags;if(d&2){try{e:{for(var y=c.return;y!==null;){if(x_(y)){var j=y;break e}y=y.return}throw Error(n(160))}switch(j.tag){case 5:var E=j.stateNode;j.flags&32&&(rt(E,""),j.flags&=-33);var L=v_(c);uy(c,L,E);break;case 3:case 4:var G=j.stateNode.containerInfo,ee=v_(c);cy(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 sq(c,d,y){Be=c,N_(c)}function N_(c,d,y){for(var j=(c.mode&1)!==0;Be!==null;){var E=Be,L=E.child;if(E.tag===22&&j){var G=E.memoizedState!==null||Nh;if(!G){var ee=E.alternate,ne=ee!==null&&ee.memoizedState!==null||yn;ee=Nh;var ue=yn;if(Nh=G,(yn=ne)&&!ue)for(Be=E;Be!==null;)G=Be,ne=G.child,G.tag===22&&G.memoizedState!==null?__(E):ne!==null?(ne.return=G,Be=ne):__(E);for(;L!==null;)Be=L,N_(L),L=L.sibling;Be=E,Nh=ee,yn=ue}S_(c)}else(E.subtreeFlags&8772)!==0&&L!==null?(L.return=E,Be=L):S_(c)}}function S_(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:yn||Sh(5,d);break;case 1:var j=d.stateNode;if(d.flags&4&&!yn)if(y===null)j.componentDidMount();else{var E=d.elementType===d.type?y.memoizedProps:Bs(d.type,y.memoizedProps);j.componentDidUpdate(E,y.memoizedState,j.__reactInternalSnapshotBeforeUpdate)}var L=d.updateQueue;L!==null&&CC(d,L,j);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}CC(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))}yn||d.flags&512&&ly(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 C_(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 __(c){for(;Be!==null;){var d=Be;try{switch(d.tag){case 0:case 11:case 15:var y=d.return;try{Sh(4,d)}catch(ne){Dt(d,y,ne)}break;case 1:var j=d.stateNode;if(typeof j.componentDidMount=="function"){var E=d.return;try{j.componentDidMount()}catch(ne){Dt(d,E,ne)}}var L=d.return;try{ly(d)}catch(ne){Dt(d,L,ne)}break;case 5:var G=d.return;try{ly(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 rq=Math.ceil,Ch=S.ReactCurrentDispatcher,dy=S.ReactCurrentOwner,hs=S.ReactCurrentBatchConfig,dt=0,nn=null,Ht=null,un=0,Xn=0,tl=Ta(0),Yt=0,Xc=null,Do=0,_h=0,hy=0,Zc=null,Ln=null,fy=0,nl=1/0,Xr=null,Eh=!1,py=null,Ia=null,Th=!1,Oa=null,Ah=0,Jc=0,my=null,Rh=-1,Mh=0;function jn(){return(dt&6)!==0?xt():Rh!==-1?Rh:Rh=xt()}function Pa(c){return(c.mode&1)===0?1:(dt&2)!==0&&un!==0?un&-un:qB.transition!==null?(Mh===0&&(Mh=or()),Mh):(c=at,c!==0||(c=window.event,c=c===void 0?16:vc(c.type)),c)}function Ws(c,d,y,j){if(50<Jc)throw Jc=0,my=null,Error(n(185));as(c,y,j),((dt&2)===0||c!==nn)&&(c===nn&&((dt&2)===0&&(_h|=y),Yt===4&&Da(c,un)),In(c,j),y===1&&dt===0&&(d.mode&1)===0&&(nl=xt()+500,oh&&Ra()))}function In(c,d){var y=c.callbackNode;pt(c,d);var j=we(c,c===nn?un:0);if(j===0)y!==null&&Rr(y),c.callbackNode=null,c.callbackPriority=0;else if(d=j&-j,c.callbackPriority!==d){if(y!=null&&Rr(y),d===1)c.tag===0?BB(T_.bind(null,c)):pC(T_.bind(null,c)),OB(function(){(dt&6)===0&&Ra()}),y=null;else{switch(yo(j)){case 1:y=Ms;break;case 4:y=xa;break;case 16:y=rr;break;case 536870912:y=Mr;break;default:y=rr}y=P_(y,E_.bind(null,c))}c.callbackPriority=d,c.callbackNode=y}}function E_(c,d){if(Rh=-1,Mh=0,(dt&6)!==0)throw Error(n(327));var y=c.callbackNode;if(sl()&&c.callbackNode!==y)return null;var j=we(c,c===nn?un:0);if(j===0)return null;if((j&30)!==0||(j&c.expiredLanes)!==0||d)d=$h(c,j);else{d=j;var E=dt;dt|=2;var L=R_();(nn!==c||un!==d)&&(Xr=null,nl=xt()+500,Bo(c,d));do try{iq();break}catch(ee){A_(c,ee)}while(!0);$g(),Ch.current=L,dt=E,Ht!==null?d=0:(nn=null,un=0,d=Yt)}if(d!==0){if(d===2&&(E=Et(c),E!==0&&(j=E,d=gy(c,E))),d===1)throw y=Xc,Bo(c,0),Da(c,j),In(c,xt()),y;if(d===6)Da(c,j);else{if(E=c.current.alternate,(j&30)===0&&!aq(E)&&(d=$h(c,j),d===2&&(L=Et(c),L!==0&&(j=L,d=gy(c,L))),d===1))throw y=Xc,Bo(c,0),Da(c,j),In(c,xt()),y;switch(c.finishedWork=E,c.finishedLanes=j,d){case 0:case 1:throw Error(n(345));case 2:qo(c,Ln,Xr);break;case 3:if(Da(c,j),(j&130023424)===j&&(d=fy+500-xt(),10<d)){if(we(c,0)!==0)break;if(E=c.suspendedLanes,(E&j)!==j){jn(),c.pingedLanes|=c.suspendedLanes&E;break}c.timeoutHandle=kg(qo.bind(null,c,Ln,Xr),d);break}qo(c,Ln,Xr);break;case 4:if(Da(c,j),(j&4194240)===j)break;for(d=c.eventTimes,E=-1;0<j;){var G=31-fn(j);L=1<<G,G=d[G],G>E&&(E=G),j&=~L}if(j=E,j=xt()-j,j=(120>j?120:480>j?480:1080>j?1080:1920>j?1920:3e3>j?3e3:4320>j?4320:1960*rq(j/1960))-j,10<j){c.timeoutHandle=kg(qo.bind(null,c,Ln,Xr),j);break}qo(c,Ln,Xr);break;case 5:qo(c,Ln,Xr);break;default:throw Error(n(329))}}}return In(c,xt()),c.callbackNode===y?E_.bind(null,c):null}function gy(c,d){var y=Zc;return c.current.memoizedState.isDehydrated&&(Bo(c,d).flags|=256),c=$h(c,d),c!==2&&(d=Ln,Ln=y,d!==null&&yy(d)),c}function yy(c){Ln===null?Ln=c:Ln.push.apply(Ln,c)}function aq(c){for(var d=c;;){if(d.flags&16384){var y=d.updateQueue;if(y!==null&&(y=y.stores,y!==null))for(var j=0;j<y.length;j++){var E=y[j],L=E.getSnapshot;E=E.value;try{if(!Ds(L(),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 Da(c,d){for(d&=~hy,d&=~_h,c.suspendedLanes|=d,c.pingedLanes&=~d,c=c.expirationTimes;0<d;){var y=31-fn(d),j=1<<y;c[y]=-1,d&=~j}}function T_(c){if((dt&6)!==0)throw Error(n(327));sl();var d=we(c,0);if((d&1)===0)return In(c,xt()),null;var y=$h(c,d);if(c.tag!==0&&y===2){var j=Et(c);j!==0&&(d=j,y=gy(c,j))}if(y===1)throw y=Xc,Bo(c,0),Da(c,d),In(c,xt()),y;if(y===6)throw Error(n(345));return c.finishedWork=c.current.alternate,c.finishedLanes=d,qo(c,Ln,Xr),In(c,xt()),null}function wy(c,d){var y=dt;dt|=1;try{return c(d)}finally{dt=y,dt===0&&(nl=xt()+500,oh&&Ra())}}function Fo(c){Oa!==null&&Oa.tag===0&&(dt&6)===0&&sl();var d=dt;dt|=1;var y=hs.transition,j=at;try{if(hs.transition=null,at=1,c)return c()}finally{at=j,hs.transition=y,dt=d,(dt&6)===0&&Ra()}}function xy(){Xn=tl.current,At(tl)}function Bo(c,d){c.finishedWork=null,c.finishedLanes=0;var y=c.timeoutHandle;if(y!==-1&&(c.timeoutHandle=-1,IB(y)),Ht!==null)for(y=Ht.return;y!==null;){var j=y;switch(Eg(j),j.tag){case 1:j=j.type.childContextTypes,j!=null&&rh();break;case 3:Ji(),At(Rn),At(pn),qg();break;case 5:Fg(j);break;case 4:Ji();break;case 13:At(It);break;case 19:At(It);break;case 10:Lg(j.type._context);break;case 22:case 23:xy()}y=y.return}if(nn=c,Ht=c=Fa(c.current,null),un=Xn=d,Yt=0,Xc=null,hy=_h=Do=0,Ln=Zc=null,Io!==null){for(d=0;d<Io.length;d++)if(y=Io[d],j=y.interleaved,j!==null){y.interleaved=null;var E=j.next,L=y.pending;if(L!==null){var G=L.next;L.next=E,j.next=G}y.pending=j}Io=null}return c}function A_(c,d){do{var y=Ht;try{if($g(),gh.current=vh,yh){for(var j=Ot.memoizedState;j!==null;){var E=j.queue;E!==null&&(E.pending=null),j=j.next}yh=!1}if(Po=0,tn=Kt=Ot=null,Hc=!1,zc=0,dy.current=null,y===null||y.return===null){Yt=1,Xc=d,Ht=null;break}e:{var L=c,G=y.return,ee=y,ne=d;if(d=un,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=t_(G);if(Pe!==null){Pe.flags&=-257,n_(Pe,G,ee,L,d),Pe.mode&1&&e_(L,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){e_(L,ue,d),vy();break e}ne=Error(n(426))}}else if(Rt&&ee.mode&1){var Ut=t_(G);if(Ut!==null){(Ut.flags&65536)===0&&(Ut.flags|=256),n_(Ut,G,ee,L,d),Rg(Qi(ne,ee));break e}}L=ne=Qi(ne,ee),Yt!==4&&(Yt=2),Zc===null?Zc=[L]:Zc.push(L),L=G;do{switch(L.tag){case 3:L.flags|=65536,d&=-d,L.lanes|=d;var ie=JC(L,ne,d);SC(L,ie);break e;case 1:ee=ne;var ae=L.type,ce=L.stateNode;if((L.flags&128)===0&&(typeof ae.getDerivedStateFromError=="function"||ce!==null&&typeof ce.componentDidCatch=="function"&&(Ia===null||!Ia.has(ce)))){L.flags|=65536,d&=-d,L.lanes|=d;var Te=QC(L,ee,d);SC(L,Te);break e}}L=L.return}while(L!==null)}$_(y)}catch(Ge){d=Ge,Ht===y&&y!==null&&(Ht=y=y.return);continue}break}while(!0)}function R_(){var c=Ch.current;return Ch.current=vh,c===null?vh:c}function vy(){(Yt===0||Yt===3||Yt===2)&&(Yt=4),nn===null||(Do&268435455)===0&&(_h&268435455)===0||Da(nn,un)}function $h(c,d){var y=dt;dt|=2;var j=R_();(nn!==c||un!==d)&&(Xr=null,Bo(c,d));do try{oq();break}catch(E){A_(c,E)}while(!0);if($g(),dt=y,Ch.current=j,Ht!==null)throw Error(n(261));return nn=null,un=0,Yt}function oq(){for(;Ht!==null;)M_(Ht)}function iq(){for(;Ht!==null&&!Rs();)M_(Ht)}function M_(c){var d=O_(c.alternate,c,Xn);c.memoizedProps=c.pendingProps,d===null?$_(c):Ht=d,dy.current=null}function $_(c){var d=c;do{var y=d.alternate;if(c=d.return,(d.flags&32768)===0){if(y=QB(y,d,Xn),y!==null){Ht=y;return}}else{if(y=eq(y,d),y!==null){y.flags&=32767,Ht=y;return}if(c!==null)c.flags|=32768,c.subtreeFlags=0,c.deletions=null;else{Yt=6,Ht=null;return}}if(d=d.sibling,d!==null){Ht=d;return}Ht=d=c}while(d!==null);Yt===0&&(Yt=5)}function qo(c,d,y){var j=at,E=hs.transition;try{hs.transition=null,at=1,lq(c,d,y,j)}finally{hs.transition=E,at=j}return null}function lq(c,d,y,j){do sl();while(Oa!==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 L=y.lanes|y.childLanes;if(fc(c,L),c===nn&&(Ht=nn=null,un=0),(y.subtreeFlags&2064)===0&&(y.flags&2064)===0||Th||(Th=!0,P_(rr,function(){return sl(),null})),L=(y.flags&15990)!==0,(y.subtreeFlags&15990)!==0||L){L=hs.transition,hs.transition=null;var G=at;at=1;var ee=dt;dt|=4,dy.current=null,nq(c,y),j_(y,c),EB(vg),jo=!!xg,vg=xg=null,c.current=y,sq(y),ya(),dt=ee,at=G,hs.transition=L}else c.current=y;if(Th&&(Th=!1,Oa=c,Ah=E),L=c.pendingLanes,L===0&&(Ia=null),Lt(y.stateNode),In(c,xt()),d!==null)for(j=c.onRecoverableError,y=0;y<d.length;y++)E=d[y],j(E.value,{componentStack:E.stack,digest:E.digest});if(Eh)throw Eh=!1,c=py,py=null,c;return(Ah&1)!==0&&c.tag!==0&&sl(),L=c.pendingLanes,(L&1)!==0?c===my?Jc++:(Jc=0,my=c):Jc=0,Ra(),null}function sl(){if(Oa!==null){var c=yo(Ah),d=hs.transition,y=at;try{if(hs.transition=null,at=16>c?16:c,Oa===null)var j=!1;else{if(c=Oa,Oa=null,Ah=0,(dt&6)!==0)throw Error(n(331));var E=dt;for(dt|=4,Be=c.current;Be!==null;){var L=Be,G=L.child;if((Be.flags&16)!==0){var ee=L.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,L)}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(w_(Se),Se===ue){Be=null;break}if(Ne!==null){Ne.return=Pe,Be=Ne;break}Be=Pe}}}var Ue=L.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=L}}if((L.subtreeFlags&2064)!==0&&G!==null)G.return=L,Be=G;else e:for(;Be!==null;){if(L=Be,(L.flags&2048)!==0)switch(L.tag){case 0:case 11:case 15:Yc(9,L,L.return)}var ie=L.sibling;if(ie!==null){ie.return=L.return,Be=ie;break e}Be=L.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:Sh(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,Ra(),hn&&typeof hn.onPostCommitFiberRoot=="function")try{hn.onPostCommitFiberRoot($s,c)}catch{}j=!0}return j}finally{at=y,hs.transition=d}}return!1}function L_(c,d,y){d=Qi(y,d),d=JC(c,d,1),c=$a(c,d,1),d=jn(),c!==null&&(as(c,1,d),In(c,d))}function Dt(c,d,y){if(c.tag===3)L_(c,c,y);else for(;d!==null;){if(d.tag===3){L_(d,c,y);break}else if(d.tag===1){var j=d.stateNode;if(typeof d.type.getDerivedStateFromError=="function"||typeof j.componentDidCatch=="function"&&(Ia===null||!Ia.has(j))){c=Qi(y,c),c=QC(d,c,1),d=$a(d,c,1),c=jn(),d!==null&&(as(d,1,c),In(d,c));break}}d=d.return}}function cq(c,d,y){var j=c.pingCache;j!==null&&j.delete(d),d=jn(),c.pingedLanes|=c.suspendedLanes&y,nn===c&&(un&y)===y&&(Yt===4||Yt===3&&(un&130023424)===un&&500>xt()-fy?Bo(c,0):hy|=y),In(c,d)}function I_(c,d){d===0&&((c.mode&1)===0?d=1:(d=$r,$r<<=1,($r&130023424)===0&&($r=4194304)));var y=jn();c=Gr(c,d),c!==null&&(as(c,d,y),In(c,y))}function uq(c){var d=c.memoizedState,y=0;d!==null&&(y=d.retryLane),I_(c,y)}function dq(c,d){var y=0;switch(c.tag){case 13:var j=c.stateNode,E=c.memoizedState;E!==null&&(y=E.retryLane);break;case 19:j=c.stateNode;break;default:throw Error(n(314))}j!==null&&j.delete(d),I_(c,y)}var O_;O_=function(c,d,y){if(c!==null)if(c.memoizedProps!==d.pendingProps||Rn.current)$n=!0;else{if((c.lanes&y)===0&&(d.flags&128)===0)return $n=!1,JB(c,d,y);$n=(c.flags&131072)!==0}else $n=!1,Rt&&(d.flags&1048576)!==0&&mC(d,lh,d.index);switch(d.lanes=0,d.tag){case 2:var j=d.type;jh(c,d),c=d.pendingProps;var E=zi(d,pn.current);Zi(d,y),E=Hg(null,d,j,c,E,y);var L=zg();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,Mn(j)?(L=!0,ah(d)):L=!1,d.memoizedState=E.state!==null&&E.state!==void 0?E.state:null,Pg(d),E.updater=bh,d.stateNode=E,E._reactInternals=d,Zg(d,j,c,y),d=ty(null,d,j,!0,L,y)):(d.tag=0,Rt&&L&&_g(d),kn(null,d,E,y),d=d.child),d;case 16:j=d.elementType;e:{switch(jh(c,d),c=d.pendingProps,E=j._init,j=E(j._payload),d.type=j,E=d.tag=fq(j),c=Bs(j,c),E){case 0:d=ey(null,d,j,c,y);break e;case 1:d=l_(null,d,j,c,y);break e;case 11:d=s_(null,d,j,c,y);break e;case 14:d=r_(null,d,j,Bs(j.type,c),y);break e}throw Error(n(306,j,""))}return d;case 0:return j=d.type,E=d.pendingProps,E=d.elementType===j?E:Bs(j,E),ey(c,d,j,E,y);case 1:return j=d.type,E=d.pendingProps,E=d.elementType===j?E:Bs(j,E),l_(c,d,j,E,y);case 3:e:{if(c_(d),c===null)throw Error(n(387));j=d.pendingProps,L=d.memoizedState,E=L.element,NC(c,d),ph(d,j,null,y);var G=d.memoizedState;if(j=G.element,L.isDehydrated)if(L={element:j,isDehydrated:!1,cache:G.cache,pendingSuspenseBoundaries:G.pendingSuspenseBoundaries,transitions:G.transitions},d.updateQueue.baseState=L,d.memoizedState=L,d.flags&256){E=Qi(Error(n(423)),d),d=u_(c,d,j,y,E);break e}else if(j!==E){E=Qi(Error(n(424)),d),d=u_(c,d,j,y,E);break e}else for(Yn=Ea(d.stateNode.containerInfo.firstChild),Kn=d,Rt=!0,Fs=null,y=kC(d,null,j,y),d.child=y;y;)y.flags=y.flags&-3|4096,y=y.sibling;else{if(Ki(),j===E){d=Yr(c,d,y);break e}kn(c,d,j,y)}d=d.child}return d;case 5:return _C(d),c===null&&Ag(d),j=d.type,E=d.pendingProps,L=c!==null?c.memoizedProps:null,G=E.children,bg(j,E)?G=null:L!==null&&bg(j,L)&&(d.flags|=32),i_(c,d),kn(c,d,G,y),d.child;case 6:return c===null&&Ag(d),null;case 13:return d_(c,d,y);case 4:return Dg(d,d.stateNode.containerInfo),j=d.pendingProps,c===null?d.child=Yi(d,null,j,y):kn(c,d,j,y),d.child;case 11:return j=d.type,E=d.pendingProps,E=d.elementType===j?E:Bs(j,E),s_(c,d,j,E,y);case 7:return kn(c,d,d.pendingProps,y),d.child;case 8:return kn(c,d,d.pendingProps.children,y),d.child;case 12:return kn(c,d,d.pendingProps.children,y),d.child;case 10:e:{if(j=d.type._context,E=d.pendingProps,L=d.memoizedProps,G=E.value,St(dh,j._currentValue),j._currentValue=G,L!==null)if(Ds(L.value,G)){if(L.children===E.children&&!Rn.current){d=Yr(c,d,y);break e}}else for(L=d.child,L!==null&&(L.return=d);L!==null;){var ee=L.dependencies;if(ee!==null){G=L.child;for(var ne=ee.firstContext;ne!==null;){if(ne.context===j){if(L.tag===1){ne=Kr(-1,y&-y),ne.tag=2;var ue=L.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}}L.lanes|=y,ne=L.alternate,ne!==null&&(ne.lanes|=y),Ig(L.return,y,d),ee.lanes|=y;break}ne=ne.next}}else if(L.tag===10)G=L.type===d.type?null:L.child;else if(L.tag===18){if(G=L.return,G===null)throw Error(n(341));G.lanes|=y,ee=G.alternate,ee!==null&&(ee.lanes|=y),Ig(G,y,d),G=L.sibling}else G=L.child;if(G!==null)G.return=L;else for(G=L;G!==null;){if(G===d){G=null;break}if(L=G.sibling,L!==null){L.return=G.return,G=L;break}G=G.return}L=G}kn(c,d,E.children,y),d=d.child}return d;case 9:return E=d.type,j=d.pendingProps.children,Zi(d,y),E=us(E),j=j(E),d.flags|=1,kn(c,d,j,y),d.child;case 14:return j=d.type,E=Bs(j,d.pendingProps),E=Bs(j.type,E),r_(c,d,j,E,y);case 15:return a_(c,d,d.type,d.pendingProps,y);case 17:return j=d.type,E=d.pendingProps,E=d.elementType===j?E:Bs(j,E),jh(c,d),d.tag=1,Mn(j)?(c=!0,ah(d)):c=!1,Zi(d,y),XC(d,j,E),Zg(d,j,E,y),ty(null,d,j,!0,c,y);case 19:return f_(c,d,y);case 22:return o_(c,d,y)}throw Error(n(156,d.tag))};function P_(c,d){return Ar(c,d)}function hq(c,d,y,j){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=j,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function fs(c,d,y,j){return new hq(c,d,y,j)}function by(c){return c=c.prototype,!(!c||!c.isReactComponent)}function fq(c){if(typeof c=="function")return by(c)?1:0;if(c!=null){if(c=c.$$typeof,c===R)return 11;if(c===F)return 14}return 2}function Fa(c,d){var y=c.alternate;return y===null?(y=fs(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 Lh(c,d,y,j,E,L){var G=2;if(j=c,typeof c=="function")by(c)&&(G=1);else if(typeof c=="string")G=5;else e:switch(c){case A:return Uo(y.children,E,L,d);case O:G=8,E|=8;break;case M:return c=fs(12,y,d,E|2),c.elementType=M,c.lanes=L,c;case q:return c=fs(13,y,d,E),c.elementType=q,c.lanes=L,c;case T:return c=fs(19,y,d,E),c.elementType=T,c.lanes=L,c;case K:return Ih(y,E,L,d);default:if(typeof c=="object"&&c!==null)switch(c.$$typeof){case W:G=10;break e;case B:G=9;break e;case R:G=11;break e;case F:G=14;break e;case D:G=16,j=null;break e}throw Error(n(130,c==null?c:typeof c,""))}return d=fs(G,y,d,E),d.elementType=c,d.type=j,d.lanes=L,d}function Uo(c,d,y,j){return c=fs(7,c,j,d),c.lanes=y,c}function Ih(c,d,y,j){return c=fs(22,c,j,d),c.elementType=K,c.lanes=y,c.stateNode={isHidden:!1},c}function ky(c,d,y){return c=fs(6,c,null,d),c.lanes=y,c}function jy(c,d,y){return d=fs(4,c.children!==null?c.children:[],c.key,d),d.lanes=y,d.stateNode={containerInfo:c.containerInfo,pendingChildren:null,implementation:c.implementation},d}function pq(c,d,y,j,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=Lr(0),this.expirationTimes=Lr(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=Lr(0),this.identifierPrefix=j,this.onRecoverableError=E,this.mutableSourceEagerHydrationData=null}function Ny(c,d,y,j,E,L,G,ee,ne){return c=new pq(c,d,y,ee,ne),d===1?(d=1,L===!0&&(d|=8)):d=0,L=fs(3,null,null,d),c.current=L,L.stateNode=c,L.memoizedState={element:j,isDehydrated:y,cache:null,transitions:null,pendingSuspenseBoundaries:null},Pg(L),c}function mq(c,d,y){var j=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:$,key:j==null?null:""+j,children:c,containerInfo:d,implementation:y}}function D_(c){if(!c)return Aa;c=c._reactInternals;e:{if(vn(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(Mn(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(Mn(y))return hC(c,y,d)}return d}function F_(c,d,y,j,E,L,G,ee,ne){return c=Ny(y,j,!0,c,E,L,G,ee,ne),c.context=D_(null),y=c.current,j=jn(),E=Pa(y),L=Kr(j,E),L.callback=d??null,$a(y,L,E),c.current.lanes=E,as(c,E,j),In(c,j),c}function Oh(c,d,y,j){var E=d.current,L=jn(),G=Pa(E);return y=D_(y),d.context===null?d.context=y:d.pendingContext=y,d=Kr(L,G),d.payload={element:c},j=j===void 0?null:j,j!==null&&(d.callback=j),c=$a(E,d,G),c!==null&&(Ws(c,E,G,L),fh(c,E,G)),G}function Ph(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 B_(c,d){if(c=c.memoizedState,c!==null&&c.dehydrated!==null){var y=c.retryLane;c.retryLane=y!==0&&y<d?y:d}}function Sy(c,d){B_(c,d),(c=c.alternate)&&B_(c,d)}function gq(){return null}var q_=typeof reportError=="function"?reportError:function(c){console.error(c)};function Cy(c){this._internalRoot=c}Dh.prototype.render=Cy.prototype.render=function(c){var d=this._internalRoot;if(d===null)throw Error(n(409));Oh(c,d,null,null)},Dh.prototype.unmount=Cy.prototype.unmount=function(){var c=this._internalRoot;if(c!==null){this._internalRoot=null;var d=c.containerInfo;Fo(function(){Oh(null,c,null,null)}),d[Wr]=null}};function Dh(c){this._internalRoot=c}Dh.prototype.unstable_scheduleHydration=function(c){if(c){var d=Id();c={blockedOn:null,target:c,priority:d};for(var y=0;y<Os.length&&d!==0&&d<Os[y].priority;y++);Os.splice(y,0,c),y===0&&Pd(c)}};function _y(c){return!(!c||c.nodeType!==1&&c.nodeType!==9&&c.nodeType!==11)}function Fh(c){return!(!c||c.nodeType!==1&&c.nodeType!==9&&c.nodeType!==11&&(c.nodeType!==8||c.nodeValue!==" react-mount-point-unstable "))}function U_(){}function yq(c,d,y,j,E){if(E){if(typeof j=="function"){var L=j;j=function(){var ue=Ph(G);L.call(ue)}}var G=F_(d,j,c,0,null,!1,!1,"",U_);return c._reactRootContainer=G,c[Wr]=G.current,Oc(c.nodeType===8?c.parentNode:c),Fo(),G}for(;E=c.lastChild;)c.removeChild(E);if(typeof j=="function"){var ee=j;j=function(){var ue=Ph(ne);ee.call(ue)}}var ne=Ny(c,0,!1,null,null,!1,!1,"",U_);return c._reactRootContainer=ne,c[Wr]=ne.current,Oc(c.nodeType===8?c.parentNode:c),Fo(function(){Oh(d,ne,y,j)}),ne}function Bh(c,d,y,j,E){var L=y._reactRootContainer;if(L){var G=L;if(typeof E=="function"){var ee=E;E=function(){var ne=Ph(G);ee.call(ne)}}Oh(d,G,c,E)}else G=yq(y,d,c,E,j);return Ph(G)}wo=function(c){switch(c.tag){case 3:var d=c.stateNode;if(d.current.memoizedState.isDehydrated){var y=Gn(d.pendingLanes);y!==0&&(Ir(d,y|1),In(d,xt()),(dt&6)===0&&(nl=xt()+500,Ra()))}break;case 13:Fo(function(){var j=Gr(c,1);if(j!==null){var E=jn();Ws(j,c,1,E)}}),Sy(c,1)}},pc=function(c){if(c.tag===13){var d=Gr(c,134217728);if(d!==null){var y=jn();Ws(d,c,134217728,y)}Sy(c,134217728)}},mc=function(c){if(c.tag===13){var d=Pa(c),y=Gr(c,d);if(y!==null){var j=jn();Ws(y,c,d,j)}Sy(c,d)}},Id=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 j=y[d];if(j!==c&&j.form===c.form){var E=sh(j);if(!E)throw Error(n(90));oe(j),ge(j,E)}}}break;case"textarea":We(c,y);break;case"select":d=y.value,d!=null&&xe(c,!!y.multiple,d,!1)}},_s=wy,Hn=Fo;var wq={usingClientEntryPoint:!1,Events:[Fc,Wi,sh,Gt,nr,wy]},Qc={findFiberByHostInstance:Ro,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},xq={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:S.ReactCurrentDispatcher,findHostInstanceByFiber:function(c){return c=rs(c),c===null?null:c.stateNode},findFiberByHostInstance:Qc.findFiberByHostInstance||gq,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 qh=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!qh.isDisabled&&qh.supportsFiber)try{$s=qh.inject(xq),hn=qh}catch{}}return On.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=wq,On.createPortal=function(c,d){var y=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!_y(d))throw Error(n(200));return mq(c,d,null,y)},On.createRoot=function(c,d){if(!_y(c))throw Error(n(299));var y=!1,j="",E=q_;return d!=null&&(d.unstable_strictMode===!0&&(y=!0),d.identifierPrefix!==void 0&&(j=d.identifierPrefix),d.onRecoverableError!==void 0&&(E=d.onRecoverableError)),d=Ny(c,1,!1,null,null,y,!1,j,E),c[Wr]=d.current,Oc(c.nodeType===8?c.parentNode:c),new Cy(d)},On.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=rs(d),c=c===null?null:c.stateNode,c},On.flushSync=function(c){return Fo(c)},On.hydrate=function(c,d,y){if(!Fh(d))throw Error(n(200));return Bh(null,c,d,!0,y)},On.hydrateRoot=function(c,d,y){if(!_y(c))throw Error(n(405));var j=y!=null&&y.hydratedSources||null,E=!1,L="",G=q_;if(y!=null&&(y.unstable_strictMode===!0&&(E=!0),y.identifierPrefix!==void 0&&(L=y.identifierPrefix),y.onRecoverableError!==void 0&&(G=y.onRecoverableError)),d=F_(d,null,c,1,y??null,E,!1,L,G),c[Wr]=d.current,Oc(c),j)for(c=0;c<j.length;c++)y=j[c],E=y._getVersion,E=E(y._source),d.mutableSourceEagerHydrationData==null?d.mutableSourceEagerHydrationData=[y,E]:d.mutableSourceEagerHydrationData.push(y,E);return new Dh(d)},On.render=function(c,d,y){if(!Fh(d))throw Error(n(200));return Bh(null,c,d,!1,y)},On.unmountComponentAtNode=function(c){if(!Fh(c))throw Error(n(40));return c._reactRootContainer?(Fo(function(){Bh(null,null,c,!1,function(){c._reactRootContainer=null,c[Wr]=null})}),!0):!1},On.unstable_batchedUpdates=wy,On.unstable_renderSubtreeIntoContainer=function(c,d,y,j){if(!Fh(y))throw Error(n(200));if(c==null||c._reactInternals===void 0)throw Error(n(38));return Bh(c,d,y,!1,j)},On.version="18.3.1-next-f1338f8080-20240426",On}var X_;function g3(){if(X_)return Ay.exports;X_=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(),Ay.exports=Eq(),Ay.exports}var Z_;function Tq(){if(Z_)return Wh;Z_=1;var e=g3();return Wh.createRoot=e.createRoot,Wh.hydrateRoot=e.hydrateRoot,Wh}var Aq=Tq(),g=dd();const me=Fj(g);function dn(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=dn(e[n]))!==""&&(t+=(t&&" ")+s);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var $y={exports:{}},Ly={},Iy={exports:{}},Oy={};/**
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 J_;function Rq(){if(J_)return Oy;J_=1;var e=dd();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(),b=s({inst:{value:w,getSnapshot:m}}),k=b[0].inst,v=b[1];return o(function(){k.value=w,k.getSnapshot=m,u(k)&&v({inst:k})},[p,w,m]),a(function(){return u(k)&&v({inst:k}),p(function(){u(k)&&v({inst:k})})},[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 Oy.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:f,Oy}var Q_;function Mq(){return Q_||(Q_=1,Iy.exports=Rq()),Iy.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 eE;function $q(){if(eE)return Ly;eE=1;var e=dd(),t=Mq();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 Ly.useSyncExternalStoreWithSelector=function(h,f,p,m,w){var b=o(null);if(b.current===null){var k={hasValue:!1,value:null};b.current=k}else k=b.current;b=l(function(){function N($){if(!x){if(x=!0,C=$,$=m($),w!==void 0&&k.hasValue){var A=k.value;if(w(A,$))return S=A}return S=$}if(A=S,s(C,$))return A;var O=m($);return w!==void 0&&w(A,O)?(C=$,A):(C=$,S=O)}var x=!1,C,S,_=p===void 0?null:p;return[function(){return N(f())},_===null?void 0:function(){return N(_())}]},[f,p,m,w]);var v=a(h,b[0],b[1]);return i(function(){k.hasValue=!0,k.value=v},[v]),u(v),v},Ly}var tE;function Lq(){return tE||(tE=1,$y.exports=$q()),$y.exports}var Iq=Lq();const Oq=Fj(Iq),Pq={},nE=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(b=>b(t,w))}},a=()=>t,u={setState:s,getState:a,getInitialState:()=>h,subscribe:f=>(n.add(f),()=>n.delete(f)),destroy:()=>{(Pq?"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},Dq=e=>e?nE(e):nE,{useDebugValue:Fq}=me,{useSyncExternalStoreWithSelector:Bq}=Oq,qq=e=>e;function y3(e,t=qq,n){const s=Bq(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return Fq(s),s}const sE=(e,t)=>{const n=Dq(e),s=(a,o=t)=>y3(n,a,o);return Object.assign(s,n),s},Uq=(e,t)=>e?sE(e,t):sE;function en(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 Wq={value:()=>{}};function Fp(){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 _f(n)}function _f(e){this._=e}function Hq(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}})}_f.prototype=Fp.prototype={constructor:_f,on:function(e,t){var n=this._,s=Hq(e+"",n),a,o=-1,i=s.length;if(arguments.length<2){for(;++o<i;)if((a=(e=s[o]).type)&&(a=zq(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]=rE(n[a],e.name,t);else if(t==null)for(a in n)n[a]=rE(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 _f(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 zq(e,t){for(var n=0,s=e.length,a;n<s;++n)if((a=e[n]).name===t)return a.value}function rE(e,t,n){for(var s=0,a=e.length;s<a;++s)if(e[s].name===t){e[s]=Wq,e=e.slice(0,s).concat(e.slice(s+1));break}return n!=null&&e.push({name:t,value:n}),e}var r1="http://www.w3.org/1999/xhtml";const aE={svg:"http://www.w3.org/2000/svg",xhtml:r1,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Bp(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),aE.hasOwnProperty(t)?{space:aE[t],local:e}:e}function Vq(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===r1&&t.documentElement.namespaceURI===r1?t.createElement(e):t.createElementNS(n,e)}}function Gq(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function w3(e){var t=Bp(e);return(t.local?Gq:Vq)(t)}function Kq(){}function Bj(e){return e==null?Kq:function(){return this.querySelector(e)}}function Yq(e){typeof e!="function"&&(e=Bj(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 ts(s,this._parents)}function Xq(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function Zq(){return[]}function x3(e){return e==null?Zq:function(){return this.querySelectorAll(e)}}function Jq(e){return function(){return Xq(e.apply(this,arguments))}}function Qq(e){typeof e=="function"?e=Jq(e):e=x3(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 ts(s,a)}function v3(e){return function(){return this.matches(e)}}function b3(e){return function(t){return t.matches(e)}}var eU=Array.prototype.find;function tU(e){return function(){return eU.call(this.children,e)}}function nU(){return this.firstElementChild}function sU(e){return this.select(e==null?nU:tU(typeof e=="function"?e:b3(e)))}var rU=Array.prototype.filter;function aU(){return Array.from(this.children)}function oU(e){return function(){return rU.call(this.children,e)}}function iU(e){return this.selectAll(e==null?aU:oU(typeof e=="function"?e:b3(e)))}function lU(e){typeof e!="function"&&(e=v3(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 ts(s,this._parents)}function k3(e){return new Array(e.length)}function cU(){return new ts(this._enter||this._groups.map(k3),this._parents)}function zf(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}zf.prototype={constructor:zf,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 uU(e){return function(){return e}}function dU(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 zf(e,o[i]);for(;i<u;++i)(l=t[i])&&(a[i]=l)}function hU(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 zf(e,o[l]);for(l=0;l<f;++l)(u=t[l])&&h.get(m[l])===u&&(a[l]=u)}function fU(e){return e.__data__}function pU(e,t){if(!arguments.length)return Array.from(this,fU);var n=t?hU:dU,s=this._parents,a=this._groups;typeof e!="function"&&(e=uU(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=mU(e.call(f,f&&f.__data__,h,s)),b=w.length,k=l[h]=new Array(b),v=i[h]=new Array(b),N=u[h]=new Array(m);n(f,p,k,v,N,w,t);for(var x=0,C=0,S,_;x<b;++x)if(S=k[x]){for(x>=C&&(C=x+1);!(_=v[C])&&++C<b;);S._next=_||null}}return i=new ts(i,s),i._enter=l,i._exit=u,i}function mU(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function gU(){return new ts(this._exit||this._groups.map(k3),this._parents)}function yU(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 wU(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,b=0;b<p;++b)(w=h[b]||f[b])&&(m[b]=w);for(;u<a;++u)l[u]=n[u];return new ts(l,this._parents)}function xU(){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 vU(e){e||(e=bU);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 ts(a,this._parents).order()}function bU(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function kU(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function jU(){return Array.from(this)}function NU(){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 SU(){let e=0;for(const t of this)++e;return e}function CU(){return!this.node()}function _U(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 EU(e){return function(){this.removeAttribute(e)}}function TU(e){return function(){this.removeAttributeNS(e.space,e.local)}}function AU(e,t){return function(){this.setAttribute(e,t)}}function RU(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function MU(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function $U(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 LU(e,t){var n=Bp(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?TU:EU:typeof t=="function"?n.local?$U:MU:n.local?RU:AU)(n,t))}function j3(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function IU(e){return function(){this.style.removeProperty(e)}}function OU(e,t,n){return function(){this.style.setProperty(e,t,n)}}function PU(e,t,n){return function(){var s=t.apply(this,arguments);s==null?this.style.removeProperty(e):this.style.setProperty(e,s,n)}}function DU(e,t,n){return arguments.length>1?this.each((t==null?IU:typeof t=="function"?PU:OU)(e,t,n??"")):ql(this.node(),e)}function ql(e,t){return e.style.getPropertyValue(t)||j3(e).getComputedStyle(e,null).getPropertyValue(t)}function FU(e){return function(){delete this[e]}}function BU(e,t){return function(){this[e]=t}}function qU(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function UU(e,t){return arguments.length>1?this.each((t==null?FU:typeof t=="function"?qU:BU)(e,t)):this.node()[e]}function N3(e){return e.trim().split(/^|\s+/)}function qj(e){return e.classList||new S3(e)}function S3(e){this._node=e,this._names=N3(e.getAttribute("class")||"")}S3.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 C3(e,t){for(var n=qj(e),s=-1,a=t.length;++s<a;)n.add(t[s])}function _3(e,t){for(var n=qj(e),s=-1,a=t.length;++s<a;)n.remove(t[s])}function WU(e){return function(){C3(this,e)}}function HU(e){return function(){_3(this,e)}}function zU(e,t){return function(){(t.apply(this,arguments)?C3:_3)(this,e)}}function VU(e,t){var n=N3(e+"");if(arguments.length<2){for(var s=qj(this.node()),a=-1,o=n.length;++a<o;)if(!s.contains(n[a]))return!1;return!0}return this.each((typeof t=="function"?zU:t?WU:HU)(n,t))}function GU(){this.textContent=""}function KU(e){return function(){this.textContent=e}}function YU(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function XU(e){return arguments.length?this.each(e==null?GU:(typeof e=="function"?YU:KU)(e)):this.node().textContent}function ZU(){this.innerHTML=""}function JU(e){return function(){this.innerHTML=e}}function QU(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function eW(e){return arguments.length?this.each(e==null?ZU:(typeof e=="function"?QU:JU)(e)):this.node().innerHTML}function tW(){this.nextSibling&&this.parentNode.appendChild(this)}function nW(){return this.each(tW)}function sW(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function rW(){return this.each(sW)}function aW(e){var t=typeof e=="function"?e:w3(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function oW(){return null}function iW(e,t){var n=typeof e=="function"?e:w3(e),s=t==null?oW:typeof t=="function"?t:Bj(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),s.apply(this,arguments)||null)})}function lW(){var e=this.parentNode;e&&e.removeChild(this)}function cW(){return this.each(lW)}function uW(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function dW(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function hW(e){return this.select(e?dW:uW)}function fW(e){return arguments.length?this.property("__data__",e):this.node().__data__}function pW(e){return function(t){e.call(this,t,this.__data__)}}function mW(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 gW(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 yW(e,t,n){return function(){var s=this.__on,a,o=pW(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 wW(e,t,n){var s=mW(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?yW:gW,a=0;a<o;++a)this.each(l(s[a],t,n));return this}function E3(e,t,n){var s=j3(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 xW(e,t){return function(){return E3(this,e,t)}}function vW(e,t){return function(){return E3(this,e,t.apply(this,arguments))}}function bW(e,t){return this.each((typeof t=="function"?vW:xW)(e,t))}function*kW(){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 T3=[null];function ts(e,t){this._groups=e,this._parents=t}function hd(){return new ts([[document.documentElement]],T3)}function jW(){return this}ts.prototype=hd.prototype={constructor:ts,select:Yq,selectAll:Qq,selectChild:sU,selectChildren:iU,filter:lU,data:pU,enter:cU,exit:gU,join:yU,merge:wU,selection:jW,order:xU,sort:vU,call:kU,nodes:jU,node:NU,size:SU,empty:CU,each:_U,attr:LU,style:DU,property:UU,classed:VU,text:XU,html:eW,raise:nW,lower:rW,append:aW,insert:iW,remove:cW,clone:hW,datum:fW,on:wW,dispatch:bW,[Symbol.iterator]:kW};function ys(e){return typeof e=="string"?new ts([[document.querySelector(e)]],[document.documentElement]):new ts([[e]],T3)}function NW(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Gs(e,t){if(e=NW(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 SW={passive:!1},Du={capture:!0,passive:!1};function Py(e){e.stopImmediatePropagation()}function Al(e){e.preventDefault(),e.stopImmediatePropagation()}function A3(e){var t=e.document.documentElement,n=ys(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 R3(e,t){var n=e.document.documentElement,s=ys(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 Hh=e=>()=>e;function a1(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}})}a1.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function CW(e){return!e.ctrlKey&&!e.button}function _W(){return this.parentNode}function EW(e,t){return t??{x:e.x,y:e.y}}function TW(){return navigator.maxTouchPoints||"ontouchstart"in this}function AW(){var e=CW,t=_W,n=EW,s=TW,a={},o=Fp("start","drag","end"),i=0,l,u,h,f,p=0;function m(S){S.on("mousedown.drag",w).filter(s).on("touchstart.drag",v).on("touchmove.drag",N,SW).on("touchend.drag touchcancel.drag",x).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function w(S,_){if(!(f||!e.call(this,S,_))){var $=C(this,t.call(this,S,_),S,_,"mouse");$&&(ys(S.view).on("mousemove.drag",b,Du).on("mouseup.drag",k,Du),A3(S.view),Py(S),h=!1,l=S.clientX,u=S.clientY,$("start",S))}}function b(S){if(Al(S),!h){var _=S.clientX-l,$=S.clientY-u;h=_*_+$*$>p}a.mouse("drag",S)}function k(S){ys(S.view).on("mousemove.drag mouseup.drag",null),R3(S.view,h),Al(S),a.mouse("end",S)}function v(S,_){if(e.call(this,S,_)){var $=S.changedTouches,A=t.call(this,S,_),O=$.length,M,W;for(M=0;M<O;++M)(W=C(this,A,S,_,$[M].identifier,$[M]))&&(Py(S),W("start",S,$[M]))}}function N(S){var _=S.changedTouches,$=_.length,A,O;for(A=0;A<$;++A)(O=a[_[A].identifier])&&(Al(S),O("drag",S,_[A]))}function x(S){var _=S.changedTouches,$=_.length,A,O;for(f&&clearTimeout(f),f=setTimeout(function(){f=null},500),A=0;A<$;++A)(O=a[_[A].identifier])&&(Py(S),O("end",S,_[A]))}function C(S,_,$,A,O,M){var W=o.copy(),B=Gs(M||$,_),R,q,T;if((T=n.call(S,new a1("beforestart",{sourceEvent:$,target:m,identifier:O,active:i,x:B[0],y:B[1],dx:0,dy:0,dispatch:W}),A))!=null)return R=T.x-B[0]||0,q=T.y-B[1]||0,function F(D,K,V){var H=B,P;switch(D){case"start":a[O]=F,P=i++;break;case"end":delete a[O],--i;case"drag":B=Gs(V||K,_),P=i;break}W.call(D,S,new a1(D,{sourceEvent:K,subject:T,target:m,identifier:O,active:P,x:B[0]+R,y:B[1]+q,dx:B[0]-H[0],dy:B[1]-H[1],dispatch:W}),A)}}return m.filter=function(S){return arguments.length?(e=typeof S=="function"?S:Hh(!!S),m):e},m.container=function(S){return arguments.length?(t=typeof S=="function"?S:Hh(S),m):t},m.subject=function(S){return arguments.length?(n=typeof S=="function"?S:Hh(S),m):n},m.touchable=function(S){return arguments.length?(s=typeof S=="function"?S:Hh(!!S),m):s},m.on=function(){var S=o.on.apply(o,arguments);return S===o?m:S},m.clickDistance=function(S){return arguments.length?(p=(S=+S)*S,m):Math.sqrt(p)},m}function Uj(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function M3(e,t){var n=Object.create(e.prototype);for(var s in t)n[s]=t[s];return n}function fd(){}var Fu=.7,Vf=1/Fu,Rl="\\s*([+-]?\\d+)\\s*",Bu="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",br="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",RW=/^#([0-9a-f]{3,8})$/,MW=new RegExp(`^rgb\\(${Rl},${Rl},${Rl}\\)$`),$W=new RegExp(`^rgb\\(${br},${br},${br}\\)$`),LW=new RegExp(`^rgba\\(${Rl},${Rl},${Rl},${Bu}\\)$`),IW=new RegExp(`^rgba\\(${br},${br},${br},${Bu}\\)$`),OW=new RegExp(`^hsl\\(${Bu},${br},${br}\\)$`),PW=new RegExp(`^hsla\\(${Bu},${br},${br},${Bu}\\)$`),oE={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};Uj(fd,qu,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:iE,formatHex:iE,formatHex8:DW,formatHsl:FW,formatRgb:lE,toString:lE});function iE(){return this.rgb().formatHex()}function DW(){return this.rgb().formatHex8()}function FW(){return $3(this).formatHsl()}function lE(){return this.rgb().formatRgb()}function qu(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=RW.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?cE(t):n===3?new Dn(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?zh(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?zh(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=MW.exec(e))?new Dn(t[1],t[2],t[3],1):(t=$W.exec(e))?new Dn(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=LW.exec(e))?zh(t[1],t[2],t[3],t[4]):(t=IW.exec(e))?zh(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=OW.exec(e))?hE(t[1],t[2]/100,t[3]/100,1):(t=PW.exec(e))?hE(t[1],t[2]/100,t[3]/100,t[4]):oE.hasOwnProperty(e)?cE(oE[e]):e==="transparent"?new Dn(NaN,NaN,NaN,0):null}function cE(e){return new Dn(e>>16&255,e>>8&255,e&255,1)}function zh(e,t,n,s){return s<=0&&(e=t=n=NaN),new Dn(e,t,n,s)}function BW(e){return e instanceof fd||(e=qu(e)),e?(e=e.rgb(),new Dn(e.r,e.g,e.b,e.opacity)):new Dn}function o1(e,t,n,s){return arguments.length===1?BW(e):new Dn(e,t,n,s??1)}function Dn(e,t,n,s){this.r=+e,this.g=+t,this.b=+n,this.opacity=+s}Uj(Dn,o1,M3(fd,{brighter(e){return e=e==null?Vf:Math.pow(Vf,e),new Dn(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Fu:Math.pow(Fu,e),new Dn(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Dn(si(this.r),si(this.g),si(this.b),Gf(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:uE,formatHex:uE,formatHex8:qW,formatRgb:dE,toString:dE}));function uE(){return`#${Qo(this.r)}${Qo(this.g)}${Qo(this.b)}`}function qW(){return`#${Qo(this.r)}${Qo(this.g)}${Qo(this.b)}${Qo((isNaN(this.opacity)?1:this.opacity)*255)}`}function dE(){const e=Gf(this.opacity);return`${e===1?"rgb(":"rgba("}${si(this.r)}, ${si(this.g)}, ${si(this.b)}${e===1?")":`, ${e})`}`}function Gf(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 hE(e,t,n,s){return s<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Ks(e,t,n,s)}function $3(e){if(e instanceof Ks)return new Ks(e.h,e.s,e.l,e.opacity);if(e instanceof fd||(e=qu(e)),!e)return new Ks;if(e instanceof Ks)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 Ks(i,l,u,e.opacity)}function UW(e,t,n,s){return arguments.length===1?$3(e):new Ks(e,t,n,s??1)}function Ks(e,t,n,s){this.h=+e,this.s=+t,this.l=+n,this.opacity=+s}Uj(Ks,UW,M3(fd,{brighter(e){return e=e==null?Vf:Math.pow(Vf,e),new Ks(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Fu:Math.pow(Fu,e),new Ks(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 Dn(Dy(e>=240?e-240:e+120,a,s),Dy(e,a,s),Dy(e<120?e+240:e-120,a,s),this.opacity)},clamp(){return new Ks(fE(this.h),Vh(this.s),Vh(this.l),Gf(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=Gf(this.opacity);return`${e===1?"hsl(":"hsla("}${fE(this.h)}, ${Vh(this.s)*100}%, ${Vh(this.l)*100}%${e===1?")":`, ${e})`}`}}));function fE(e){return e=(e||0)%360,e<0?e+360:e}function Vh(e){return Math.max(0,Math.min(1,e||0))}function Dy(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 L3=e=>()=>e;function WW(e,t){return function(n){return e+n*t}}function HW(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 zW(e){return(e=+e)==1?I3:function(t,n){return n-t?HW(t,n,e):L3(isNaN(t)?n:t)}}function I3(e,t){var n=t-e;return n?WW(e,n):L3(isNaN(e)?t:e)}const pE=(function e(t){var n=zW(t);function s(a,o){var i=n((a=o1(a)).r,(o=o1(o)).r),l=n(a.g,o.g),u=n(a.b,o.b),h=I3(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 Va(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var i1=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Fy=new RegExp(i1.source,"g");function VW(e){return function(){return e}}function GW(e){return function(t){return e(t)+""}}function KW(e,t){var n=i1.lastIndex=Fy.lastIndex=0,s,a,o,i=-1,l=[],u=[];for(e=e+"",t=t+"";(s=i1.exec(e))&&(a=Fy.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:Va(s,a)})),n=Fy.lastIndex;return n<t.length&&(o=t.slice(n),l[i]?l[i]+=o:l[++i]=o),l.length<2?u[0]?GW(u[0].x):VW(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 mE=180/Math.PI,l1={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function O3(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)*mE,skewX:Math.atan(u)*mE,scaleX:i,scaleY:l}}var Gh;function YW(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?l1:O3(t.a,t.b,t.c,t.d,t.e,t.f)}function XW(e){return e==null||(Gh||(Gh=document.createElementNS("http://www.w3.org/2000/svg","g")),Gh.setAttribute("transform",e),!(e=Gh.transform.baseVal.consolidate()))?l1:(e=e.matrix,O3(e.a,e.b,e.c,e.d,e.e,e.f))}function P3(e,t,n,s){function a(h){return h.length?h.pop()+" ":""}function o(h,f,p,m,w,b){if(h!==p||f!==m){var k=w.push("translate(",null,t,null,n);b.push({i:k-4,x:Va(h,p)},{i:k-2,x:Va(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:Va(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:Va(h,f)}):f&&p.push(a(p)+"skewX("+f+s)}function u(h,f,p,m,w,b){if(h!==p||f!==m){var k=w.push(a(w)+"scale(",null,",",null,")");b.push({i:k-4,x:Va(h,p)},{i:k-2,x:Va(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 b=-1,k=m.length,v;++b<k;)p[(v=m[b]).i]=v.x(w);return p.join("")}}}var ZW=P3(YW,"px, ","px)","deg)"),JW=P3(XW,", ",")",")"),QW=1e-12;function gE(e){return((e=Math.exp(e))+1/e)/2}function eH(e){return((e=Math.exp(e))-1/e)/2}function tH(e){return((e=Math.exp(2*e))-1)/(e+1)}const nH=(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,b=p-u,k=w*w+b*b,v,N;if(k<QW)N=Math.log(m/h)/t,v=function(A){return[l+A*w,u+A*b,h*Math.exp(t*A*N)]};else{var x=Math.sqrt(k),C=(m*m-h*h+s*k)/(2*h*n*x),S=(m*m-h*h-s*k)/(2*m*n*x),_=Math.log(Math.sqrt(C*C+1)-C),$=Math.log(Math.sqrt(S*S+1)-S);N=($-_)/t,v=function(A){var O=A*N,M=gE(_),W=h/(n*x)*(M*tH(t*O+_)-eH(_));return[l+W*w,u+W*b,h*M/gE(t*O+_)]}}return v.duration=N*1e3*t/Math.SQRT2,v}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,D3=1e3,Kf,wu,Yf=0,di=0,qp=0,Uu=typeof performance=="object"&&performance.now?performance:Date,F3=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Wj(){return di||(F3(sH),di=Uu.now()+qp)}function sH(){di=0}function Xf(){this._call=this._time=this._next=null}Xf.prototype=B3.prototype={constructor:Xf,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Wj():+n)+(t==null?0:+t),!this._next&&wu!==this&&(wu?wu._next=this:Kf=this,wu=this),this._call=e,this._time=n,c1()},stop:function(){this._call&&(this._call=null,this._time=1/0,c1())}};function B3(e,t,n){var s=new Xf;return s.restart(e,t,n),s}function rH(){Wj(),++Ul;for(var e=Kf,t;e;)(t=di-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Ul}function yE(){di=(Yf=Uu.now())+qp,Ul=yu=0;try{rH()}finally{Ul=0,oH(),di=0}}function aH(){var e=Uu.now(),t=e-Yf;t>D3&&(qp-=t,Yf=e)}function oH(){for(var e,t=Kf,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:Kf=n);wu=e,c1(s)}function c1(e){if(!Ul){yu&&(yu=clearTimeout(yu));var t=e-di;t>24?(e<1/0&&(yu=setTimeout(yE,e-Uu.now()-qp)),tu&&(tu=clearInterval(tu))):(tu||(Yf=Uu.now(),tu=setInterval(aH,D3)),Ul=1,F3(yE))}}function wE(e,t,n){var s=new Xf;return t=t==null?0:+t,s.restart(a=>{s.stop(),e(a+t)},t,n),s}var iH=Fp("start","end","cancel","interrupt"),lH=[],q3=0,xE=1,u1=2,Ef=3,vE=4,d1=5,Tf=6;function Up(e,t,n,s,a,o){var i=e.__transition;if(!i)e.__transition={};else if(n in i)return;cH(e,n,{name:t,index:s,group:a,on:iH,tween:lH,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:q3})}function Hj(e,t){var n=er(e,t);if(n.state>q3)throw new Error("too late; already scheduled");return n}function Sr(e,t){var n=er(e,t);if(n.state>Ef)throw new Error("too late; already running");return n}function er(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function cH(e,t,n){var s=e.__transition,a;s[t]=n,n.timer=B3(o,0,n.time);function o(h){n.state=xE,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!==xE)return u();for(f in s)if(w=s[f],w.name===n.name){if(w.state===Ef)return wE(i);w.state===vE?(w.state=Tf,w.timer.stop(),w.on.call("interrupt",e,e.__data__,w.index,w.group),delete s[f]):+f<t&&(w.state=Tf,w.timer.stop(),w.on.call("cancel",e,e.__data__,w.index,w.group),delete s[f])}if(wE(function(){n.state===Ef&&(n.state=vE,n.timer.restart(l,n.delay,n.time),l(h))}),n.state=u1,n.on.call("start",e,e.__data__,n.index,n.group),n.state===u1){for(n.state=Ef,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=d1,1),p=-1,m=a.length;++p<m;)a[p].call(e,f);n.state===d1&&(n.on.call("end",e,e.__data__,n.index,n.group),u())}function u(){n.state=Tf,n.timer.stop(),delete s[t];for(var h in s)return;delete e.__transition}}function Af(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>u1&&s.state<d1,s.state=Tf,s.timer.stop(),s.on.call(a?"interrupt":"cancel",e,e.__data__,s.index,s.group),delete n[i]}o&&delete e.__transition}}function uH(e){return this.each(function(){Af(this,e)})}function dH(e,t){var n,s;return function(){var a=Sr(this,e),o=a.tween;if(o!==n){s=n=o;for(var i=0,l=s.length;i<l;++i)if(s[i].name===t){s=s.slice(),s.splice(i,1);break}}a.tween=s}}function hH(e,t,n){var s,a;if(typeof n!="function")throw new Error;return function(){var o=Sr(this,e),i=o.tween;if(i!==s){a=(s=i).slice();for(var 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 fH(e,t){var n=this._id;if(e+="",arguments.length<2){for(var s=er(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?dH:hH)(n,e,t))}function zj(e,t,n){var s=e._id;return e.each(function(){var a=Sr(this,s);(a.value||(a.value={}))[t]=n.apply(this,arguments)}),function(a){return er(a,s).value[t]}}function U3(e,t){var n;return(typeof t=="number"?Va:t instanceof qu?pE:(n=qu(t))?(t=n,pE):KW)(e,t)}function pH(e){return function(){this.removeAttribute(e)}}function mH(e){return function(){this.removeAttributeNS(e.space,e.local)}}function gH(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 yH(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 wH(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 xH(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 vH(e,t){var n=Bp(e),s=n==="transform"?JW:U3;return this.attrTween(e,typeof t=="function"?(n.local?xH:wH)(n,s,zj(this,"attr."+e,t)):t==null?(n.local?mH:pH)(n):(n.local?yH:gH)(n,s,t))}function bH(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function kH(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function jH(e,t){var n,s;function a(){var o=t.apply(this,arguments);return o!==s&&(n=(s=o)&&kH(e,o)),n}return a._value=t,a}function NH(e,t){var n,s;function a(){var o=t.apply(this,arguments);return o!==s&&(n=(s=o)&&bH(e,o)),n}return a._value=t,a}function SH(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=Bp(e);return this.tween(n,(s.local?jH:NH)(s,t))}function CH(e,t){return function(){Hj(this,e).delay=+t.apply(this,arguments)}}function _H(e,t){return t=+t,function(){Hj(this,e).delay=t}}function EH(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?CH:_H)(t,e)):er(this.node(),t).delay}function TH(e,t){return function(){Sr(this,e).duration=+t.apply(this,arguments)}}function AH(e,t){return t=+t,function(){Sr(this,e).duration=t}}function RH(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?TH:AH)(t,e)):er(this.node(),t).duration}function MH(e,t){if(typeof t!="function")throw new Error;return function(){Sr(this,e).ease=t}}function $H(e){var t=this._id;return arguments.length?this.each(MH(t,e)):er(this.node(),t).ease}function LH(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;Sr(this,e).ease=n}}function IH(e){if(typeof e!="function")throw new Error;return this.each(LH(this._id,e))}function OH(e){typeof e!="function"&&(e=v3(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 ca(s,this._parents,this._name,this._id)}function PH(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 ca(i,this._parents,this._name,this._id)}function DH(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 FH(e,t,n){var s,a,o=DH(t)?Hj:Sr;return function(){var i=o(this,e),l=i.on;l!==s&&(a=(s=l).copy()).on(t,n),i.on=a}}function BH(e,t){var n=this._id;return arguments.length<2?er(this.node(),n).on.on(e):this.each(FH(n,e,t))}function qH(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function UH(){return this.on("end.remove",qH(this._id))}function WH(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Bj(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,Up(h[m],t,n,m,h,er(f,n)));return new ca(o,this._parents,t,n)}function HH(e){var t=this._name,n=this._id;typeof e!="function"&&(e=x3(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,b=er(f,n),k=0,v=m.length;k<v;++k)(w=m[k])&&Up(w,t,n,k,m,b);o.push(m),i.push(f)}return new ca(o,i,t,n)}var zH=hd.prototype.constructor;function VH(){return new zH(this._groups,this._parents)}function GH(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 W3(e){return function(){this.style.removeProperty(e)}}function KH(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 YH(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 XH(e,t){var n,s,a,o="style."+t,i="end."+o,l;return function(){var u=Sr(this,e),h=u.on,f=u.value[o]==null?l||(l=W3(t)):void 0;(h!==n||a!==f)&&(s=(n=h).copy()).on(i,a=f),u.on=s}}function ZH(e,t,n){var s=(e+="")=="transform"?ZW:U3;return t==null?this.styleTween(e,GH(e,s)).on("end.style."+e,W3(e)):typeof t=="function"?this.styleTween(e,YH(e,s,zj(this,"style."+e,t))).each(XH(this._id,e)):this.styleTween(e,KH(e,s,t),n).on("end.style."+e,null)}function JH(e,t,n){return function(s){this.style.setProperty(e,t.call(this,s),n)}}function QH(e,t,n){var s,a;function o(){var i=t.apply(this,arguments);return i!==a&&(s=(a=i)&&JH(e,i,n)),s}return o._value=t,o}function e7(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,QH(e,t,n??""))}function t7(e){return function(){this.textContent=e}}function n7(e){return function(){var t=e(this);this.textContent=t??""}}function s7(e){return this.tween("text",typeof e=="function"?n7(zj(this,"text",e)):t7(e==null?"":e+""))}function r7(e){return function(t){this.textContent=e.call(this,t)}}function a7(e){var t,n;function s(){var a=e.apply(this,arguments);return a!==n&&(t=(n=a)&&r7(a)),t}return s._value=e,s}function o7(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,a7(e))}function i7(){for(var e=this._name,t=this._id,n=H3(),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=er(u,t);Up(u,e,n,h,i,{time:f.time+f.delay+f.duration,delay:0,duration:f.duration,ease:f.ease})}return new ca(s,this._parents,e,n)}function l7(){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=Sr(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 c7=0;function ca(e,t,n,s){this._groups=e,this._parents=t,this._name=n,this._id=s}function H3(){return++c7}var Zr=hd.prototype;ca.prototype={constructor:ca,select:WH,selectAll:HH,selectChild:Zr.selectChild,selectChildren:Zr.selectChildren,filter:OH,merge:PH,selection:VH,transition:i7,call:Zr.call,nodes:Zr.nodes,node:Zr.node,size:Zr.size,empty:Zr.empty,each:Zr.each,on:BH,attr:vH,attrTween:SH,style:ZH,styleTween:e7,text:s7,textTween:o7,remove:UH,tween:fH,delay:EH,duration:RH,ease:$H,easeVarying:IH,end:l7,[Symbol.iterator]:Zr[Symbol.iterator]};function u7(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var d7={time:null,delay:0,duration:250,ease:u7};function h7(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 f7(e){var t,n;e instanceof ca?(t=e._id,e=e._name):(t=H3(),(n=d7).time=Wj(),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])&&Up(u,e,t,h,i,n||h7(u,t));return new ca(s,this._parents,e,t)}hd.prototype.interrupt=uH;hd.prototype.transition=f7;const Kh=e=>()=>e;function p7(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 sa(e,t,n){this.k=e,this.x=t,this.y=n}sa.prototype={constructor:sa,scale:function(e){return e===1?this:new sa(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new sa(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 aa=new sa(1,0,0);sa.prototype;function By(e){e.stopImmediatePropagation()}function nu(e){e.preventDefault(),e.stopImmediatePropagation()}function m7(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function g7(){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 bE(){return this.__zoom||aa}function y7(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function w7(){return navigator.maxTouchPoints||"ontouchstart"in this}function x7(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 z3(){var e=m7,t=g7,n=x7,s=y7,a=w7,o=[0,1/0],i=[[-1/0,-1/0],[1/0,1/0]],l=250,u=nH,h=Fp("start","zoom","end"),f,p,m,w=500,b=150,k=0,v=10;function N(T){T.property("__zoom",bE).on("wheel.zoom",O,{passive:!1}).on("mousedown.zoom",M).on("dblclick.zoom",W).filter(a).on("touchstart.zoom",B).on("touchmove.zoom",R).on("touchend.zoom touchcancel.zoom",q).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}N.transform=function(T,F,D,K){var V=T.selection?T.selection():T;V.property("__zoom",bE),T!==V?_(T,F,D,K):V.interrupt().each(function(){$(this,arguments).event(K).start().zoom(null,typeof F=="function"?F.apply(this,arguments):F).end()})},N.scaleBy=function(T,F,D,K){N.scaleTo(T,function(){var V=this.__zoom.k,H=typeof F=="function"?F.apply(this,arguments):F;return V*H},D,K)},N.scaleTo=function(T,F,D,K){N.transform(T,function(){var V=t.apply(this,arguments),H=this.__zoom,P=D==null?S(V):typeof D=="function"?D.apply(this,arguments):D,I=H.invert(P),U=typeof F=="function"?F.apply(this,arguments):F;return n(C(x(H,U),P,I),V,i)},D,K)},N.translateBy=function(T,F,D,K){N.transform(T,function(){return n(this.__zoom.translate(typeof F=="function"?F.apply(this,arguments):F,typeof D=="function"?D.apply(this,arguments):D),t.apply(this,arguments),i)},null,K)},N.translateTo=function(T,F,D,K,V){N.transform(T,function(){var H=t.apply(this,arguments),P=this.__zoom,I=K==null?S(H):typeof K=="function"?K.apply(this,arguments):K;return n(aa.translate(I[0],I[1]).scale(P.k).translate(typeof F=="function"?-F.apply(this,arguments):-F,typeof D=="function"?-D.apply(this,arguments):-D),H,i)},K,V)};function x(T,F){return F=Math.max(o[0],Math.min(o[1],F)),F===T.k?T:new sa(F,T.x,T.y)}function C(T,F,D){var K=F[0]-D[0]*T.k,V=F[1]-D[1]*T.k;return K===T.x&&V===T.y?T:new sa(T.k,K,V)}function S(T){return[(+T[0][0]+ +T[1][0])/2,(+T[0][1]+ +T[1][1])/2]}function _(T,F,D,K){T.on("start.zoom",function(){$(this,arguments).event(K).start()}).on("interrupt.zoom end.zoom",function(){$(this,arguments).event(K).end()}).tween("zoom",function(){var V=this,H=arguments,P=$(V,H).event(K),I=t.apply(V,H),U=D==null?S(I):typeof D=="function"?D.apply(V,H):D,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(U).concat(Z/z.k),X.invert(U).concat(Z/X.k));return function(J){if(J===1)J=X;else{var Q=Y(J),te=Z/Q[2];J=new sa(te,U[0]-Q[0]*te,U[1]-Q[1]*te)}P.zoom(null,J)}})}function $(T,F,D){return!D&&T.__zooming||new A(T,F)}function A(T,F){this.that=T,this.args=F,this.active=0,this.sourceEvent=null,this.extent=t.apply(T,F),this.taps=0}A.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=ys(this.that).datum();h.call(T,this.that,new p7(T,{sourceEvent:this.sourceEvent,target:N,transform:this.that.__zoom,dispatch:h}),F)}};function O(T,...F){if(!e.apply(this,arguments))return;var D=$(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=Gs(T);if(D.wheel)(D.mouse[0][0]!==H[0]||D.mouse[0][1]!==H[1])&&(D.mouse[1]=K.invert(D.mouse[0]=H)),clearTimeout(D.wheel);else{if(K.k===V)return;D.mouse=[H,K.invert(H)],Af(this),D.start()}nu(T),D.wheel=setTimeout(P,b),D.zoom("mouse",n(C(x(K,V),D.mouse[0],D.mouse[1]),D.extent,i));function P(){D.wheel=null,D.end()}}function M(T,...F){if(m||!e.apply(this,arguments))return;var D=T.currentTarget,K=$(this,F,!0).event(T),V=ys(T.view).on("mousemove.zoom",U,!0).on("mouseup.zoom",Z,!0),H=Gs(T,D),P=T.clientX,I=T.clientY;A3(T.view),By(T),K.mouse=[H,this.__zoom.invert(H)],Af(this),K.start();function U(z){if(nu(z),!K.moved){var X=z.clientX-P,Y=z.clientY-I;K.moved=X*X+Y*Y>k}K.event(z).zoom("mouse",n(C(K.that.__zoom,K.mouse[0]=Gs(z,D),K.mouse[1]),K.extent,i))}function Z(z){V.on("mousemove.zoom mouseup.zoom",null),R3(z.view,K.moved),nu(z),K.event(z).end()}}function W(T,...F){if(e.apply(this,arguments)){var D=this.__zoom,K=Gs(T.changedTouches?T.changedTouches[0]:T,this),V=D.invert(K),H=D.k*(T.shiftKey?.5:2),P=n(C(x(D,H),K,V),t.apply(this,F),i);nu(T),l>0?ys(this).transition().duration(l).call(_,P,K,T):ys(this).call(N.transform,P,K,T)}}function B(T,...F){if(e.apply(this,arguments)){var D=T.touches,K=D.length,V=$(this,F,T.changedTouches.length===K).event(T),H,P,I,U;for(By(T),P=0;P<K;++P)I=D[P],U=Gs(I,this),U=[U,this.__zoom.invert(U),I.identifier],V.touch0?!V.touch1&&V.touch0[2]!==U[2]&&(V.touch1=U,V.taps=0):(V.touch0=U,H=!0,V.taps=1+!!f);f&&(f=clearTimeout(f)),H&&(V.taps<2&&(p=U[0],f=setTimeout(function(){f=null},w)),Af(this),V.start())}}function R(T,...F){if(this.__zooming){var D=$(this,F).event(T),K=T.changedTouches,V=K.length,H,P,I,U;for(nu(T),H=0;H<V;++H)P=K[H],I=Gs(P,this),D.touch0&&D.touch0[2]===P.identifier?D.touch0[0]=I:D.touch1&&D.touch1[2]===P.identifier&&(D.touch1[0]=I);if(P=D.that.__zoom,D.touch1){var Z=D.touch0[0],z=D.touch0[1],X=D.touch1[0],Y=D.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;P=x(P,Math.sqrt(J/Q)),I=[(Z[0]+X[0])/2,(Z[1]+X[1])/2],U=[(z[0]+Y[0])/2,(z[1]+Y[1])/2]}else if(D.touch0)I=D.touch0[0],U=D.touch0[1];else return;D.zoom("touch",n(C(P,I,U),D.extent,i))}}function q(T,...F){if(this.__zooming){var D=$(this,F).event(T),K=T.changedTouches,V=K.length,H,P;for(By(T),m&&clearTimeout(m),m=setTimeout(function(){m=null},w),H=0;H<V;++H)P=K[H],D.touch0&&D.touch0[2]===P.identifier?delete D.touch0:D.touch1&&D.touch1[2]===P.identifier&&delete D.touch1;if(D.touch1&&!D.touch0&&(D.touch0=D.touch1,delete D.touch1),D.touch0)D.touch0[1]=this.__zoom.invert(D.touch0[0]);else if(D.end(),D.taps===2&&(P=Gs(P,this),Math.hypot(p[0]-P[0],p[1]-P[1])<v)){var I=ys(this).on("dblclick.zoom");I&&I.apply(this,arguments)}}}return N.wheelDelta=function(T){return arguments.length?(s=typeof T=="function"?T:Kh(+T),N):s},N.filter=function(T){return arguments.length?(e=typeof T=="function"?T:Kh(!!T),N):e},N.touchable=function(T){return arguments.length?(a=typeof T=="function"?T:Kh(!!T),N):a},N.extent=function(T){return arguments.length?(t=typeof T=="function"?T:Kh([[+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?(k=(T=+T)*T,N):Math.sqrt(k)},N.tapDistance=function(T){return arguments.length?(v=+T,N):v},N}var vt=g3();const Wp=g.createContext(null),v7=Wp.Provider,ua={error001:()=>"[React Flow]: Seems like you have not used zustand provider as an ancestor. Help: https://reactflow.dev/error#001",error002:()=>"It looks like you've created a new nodeTypes or edgeTypes object. If this wasn't on purpose please define the nodeTypes/edgeTypes outside of the component or memoize them.",error003:e=>`Node type "${e}" not found. Using fallback type "default".`,error004:()=>"The React Flow parent container needs a width and a height to render the graph.",error005:()=>"Only child nodes can use a parent extent.",error006:()=>"Can't create edge. An edge needs a source and a target.",error007:e=>`The old edge with id=${e} does not exist.`,error009:e=>`Marker type "${e}" doesn't exist.`,error008:(e,t)=>`Couldn't create edge for ${e?"target":"source"} handle id: "${e?t.targetHandle:t.sourceHandle}", edge id: ${t.id}.`,error010:()=>"Handle: No node id found. Make sure to only use a Handle inside a custom Node.",error011:e=>`Edge type "${e}" not found. Using fallback type "default".`,error012:e=>`Node with id "${e}" does not exist, it may have been removed. This can happen when a node is deleted before the "onNodeClick" handler is called.`},V3=ua.error001();function ht(e,t){const n=g.useContext(Wp);if(n===null)throw new Error(V3);return y3(n,e,t)}const Wt=()=>{const e=g.useContext(Wp);if(e===null)throw new Error(V3);return g.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy}),[e])},b7=e=>e.userSelectionActive?"none":"all";function Vj({position:e,children:t,className:n,style:s,...a}){const o=ht(b7),i=`${e}`.split("-");return me.createElement("div",{className:dn(["react-flow__panel",n,...i]),style:{...s,pointerEvents:o},...a},t)}function k7({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:me.createElement(Vj,{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 j7=({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}),b=dn(["react-flow__edge-textwrapper",h]);return g.useEffect(()=>{if(p.current){const k=p.current.getBBox();w({x:k.x,y:k.y,width:k.width,height:k.height})}},[n]),typeof n>"u"||!n?null:me.createElement("g",{transform:`translate(${e-m.width/2} ${t-m.height/2})`,className:b,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 N7=g.memo(j7);const Gj=e=>({width:e.offsetWidth,height:e.offsetHeight}),Wl=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Kj=(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])}),kE=(e,t,n)=>e<t?Wl(Math.abs(e-t),1,50)/50:e>n?-Wl(Math.abs(e-n),1,50)/50:0,G3=(e,t)=>{const n=kE(e.x,35,t.width-35)*20,s=kE(e.y,35,t.height-35)*20;return[n,s]},K3=e=>{var t;return((t=e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},Y3=(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}),X3=({x:e,y:t,x2:n,y2:s})=>({x:e,y:t,width:n-e,height:s-t}),jE=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),S7=(e,t)=>X3(Y3(Wu(e),Wu(t))),h1=(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)},C7=e=>ws(e.width)&&ws(e.height)&&ws(e.x)&&ws(e.y),ws=e=>!isNaN(e)&&isFinite(e),Ft=Symbol.for("internals"),Z3=["Enter"," ","Escape"],_7=(e,t)=>{},E7=e=>"nativeEvent"in e;function f1(e){var a,o;const t=E7(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 J3=e=>"clientX"in e,eo=(e,t)=>{var o,i;const n=J3(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)}},Zf=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0},pd=({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&&ws(n)&&ws(s)?me.createElement(N7,{x:n,y:s,label:a,labelStyle:o,labelShowBg:i,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:h}):null);pd.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 Q3({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 e4({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 Ya;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Ya||(Ya={}));var Jf;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(Jf||(Jf={}));var Ye;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Ye||(Ye={}));function NE({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 t4({sourceX:e,sourceY:t,sourcePosition:n=Ye.Bottom,targetX:s,targetY:a,targetPosition:o=Ye.Top}){const[i,l]=NE({pos:n,x1:e,y1:t,x2:s,y2:a}),[u,h]=NE({pos:o,x1:s,y1:a,x2:e,y2:t}),[f,p,m,w]=e4({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 Yj=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:b,interactionWidth:k})=>{const[v,N,x]=t4({sourceX:e,sourceY:t,sourcePosition:a,targetX:n,targetY:s,targetPosition:o});return me.createElement(pd,{path:v,labelX:N,labelY:x,label:i,labelStyle:l,labelShowBg:u,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:w,markerStart:b,interactionWidth:k})});Yj.displayName="SimpleBezierEdge";const SE={[Ye.Left]:{x:-1,y:0},[Ye.Right]:{x:1,y:0},[Ye.Top]:{x:0,y:-1},[Ye.Bottom]:{x:0,y:1}},T7=({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},CE=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function A7({source:e,sourcePosition:t=Ye.Bottom,target:n,targetPosition:s=Ye.Top,center:a,offset:o}){const i=SE[t],l=SE[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=T7({source:u,sourcePosition:t,target:h}),p=f.x!==0?"x":"y",m=f[p];let w=[],b,k;const v={x:0,y:0},N={x:0,y:0},[x,C,S,_]=Q3({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(i[p]*l[p]===-1){b=a.x??x,k=a.y??C;const A=[{x:b,y:u.y},{x:b,y:h.y}],O=[{x:u.x,y:k},{x:h.x,y:k}];i[p]===m?w=p==="x"?A:O:w=p==="x"?O:A}else{const A=[{x:u.x,y:h.y}],O=[{x:h.x,y:u.y}];if(p==="x"?w=i.x===m?O:A:w=i.y===m?A:O,t===s){const q=Math.abs(e[p]-n[p]);if(q<=o){const T=Math.min(o-1,o-q);i[p]===m?v[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],D=u[q]<h[q];(i[p]===1&&(!T&&F||T&&D)||i[p]!==1&&(!T&&D||T&&F))&&(w=p==="x"?A:O)}const M={x:u.x+v.x,y:u.y+v.y},W={x:h.x+N.x,y:h.y+N.y},B=Math.max(Math.abs(M.x-w[0].x),Math.abs(W.x-w[0].x)),R=Math.max(Math.abs(M.y-w[0].y),Math.abs(W.y-w[0].y));B>=R?(b=(M.x+W.x)/2,k=w[0].y):(b=w[0].x,k=(M.y+W.y)/2)}return[[e,{x:u.x+v.x,y:u.y+v.y},...w,{x:h.x+N.x,y:h.y+N.y},n],b,k,S,_]}function R7(e,t,n,s){const a=Math.min(CE(e,t)/2,CE(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 p1({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,b]=A7({source:{x:e,y:t},sourcePosition:n,target:{x:s,y:a},targetPosition:o,center:{x:l,y:u},offset:h});return[f.reduce((v,N,x)=>{let C="";return x>0&&x<f.length-1?C=R7(f[x-1],N,f[x+1],i):C=`${x===0?"M":"L"}${N.x} ${N.y}`,v+=C,v},""),p,m,w,b]}const Hp=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:b,pathOptions:k,interactionWidth:v})=>{const[N,x,C]=p1({sourceX:e,sourceY:t,sourcePosition:p,targetX:n,targetY:s,targetPosition:m,borderRadius:k==null?void 0:k.borderRadius,offset:k==null?void 0:k.offset});return me.createElement(pd,{path:N,labelX:x,labelY:C,label:a,labelStyle:o,labelShowBg:i,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:h,style:f,markerEnd:w,markerStart:b,interactionWidth:v})});Hp.displayName="SmoothStepEdge";const Xj=g.memo(e=>{var t;return me.createElement(Hp,{...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])})});Xj.displayName="StepEdge";function M7({sourceX:e,sourceY:t,targetX:n,targetY:s}){const[a,o,i,l]=Q3({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[b,k,v]=M7({sourceX:e,sourceY:t,targetX:n,targetY:s});return me.createElement(pd,{path:b,labelX:k,labelY:v,label:a,labelStyle:o,labelShowBg:i,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:h,style:f,markerEnd:p,markerStart:m,interactionWidth:w})});Zj.displayName="StraightEdge";function Yh(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function _E({pos:e,x1:t,y1:n,x2:s,y2:a,c:o}){switch(e){case Ye.Left:return[t-Yh(t-s,o),n];case Ye.Right:return[t+Yh(s-t,o),n];case Ye.Top:return[t,n-Yh(n-a,o)];case Ye.Bottom:return[t,n+Yh(a-n,o)]}}function Jj({sourceX:e,sourceY:t,sourcePosition:n=Ye.Bottom,targetX:s,targetY:a,targetPosition:o=Ye.Top,curvature:i=.25}){const[l,u]=_E({pos:n,x1:e,y1:t,x2:s,y2:a,c:i}),[h,f]=_E({pos:o,x1:s,y1:a,x2:e,y2:t,c:i}),[p,m,w,b]=e4({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,b]}const Qf=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:b,pathOptions:k,interactionWidth:v})=>{const[N,x,C]=Jj({sourceX:e,sourceY:t,sourcePosition:a,targetX:n,targetY:s,targetPosition:o,curvature:k==null?void 0:k.curvature});return me.createElement(pd,{path:N,labelX:x,labelY:C,label:i,labelStyle:l,labelShowBg:u,labelBgStyle:h,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:w,markerStart:b,interactionWidth:v})});Qf.displayName="BezierEdge";const Qj=g.createContext(null),$7=Qj.Provider;Qj.Consumer;const L7=()=>g.useContext(Qj),I7=e=>"id"in e&&"source"in e&&"target"in e,O7=({source:e,sourceHandle:t,target:n,targetHandle:s})=>`reactflow__edge-${e}${t||""}-${n}${s||""}`,m1=(e,t)=>typeof e>"u"?"":typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(s=>`${s}=${e[s]}`).join("&")}`,P7=(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)),D7=(e,t)=>{if(!e.source||!e.target)return t;let n;return I7(e)?n={...e}:n={...e,id:O7(e)},P7(n,t)?t:t.concat(n)},g1=({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},n4=({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}},zp=(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 Y3(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 X3(n)},s4=(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:b=!1}=f;if(i&&!w||b)return!1;const{positionAbsolute:k}=ri(f,l),v={x:k.x,y:k.y,width:p||0,height:m||0},N=h1(u,v),x=typeof p>"u"||typeof m>"u"||p===null||m===null,C=o&&N>0,S=(p||0)*(m||0);(x||C||N>=S||f.dragging)&&h.push(f)}),h},r4=(e,t)=>{const n=e.map(s=>s.id);return t.filter(s=>n.includes(s.source)||n.includes(s.target))},a4=(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 EE(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 F7(e,t,n,s,a,o){const{x:i,y:l}=eo(e),h=t.elementsFromPoint(i,l).find(b=>b.classList.contains("react-flow__handle"));if(h){const b=h.getAttribute("data-nodeid");if(b){const k=eN(void 0,h),v=h.getAttribute("data-handleid"),N=o({nodeId:b,id:v,type:k});if(N){const x=a.find(C=>C.nodeId===b&&C.type===k&&C.id===v);return{handle:{id:v,type:k,nodeId:b,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(b=>{const k=Math.sqrt((b.x-n.x)**2+(b.y-n.y)**2);if(k<=s){const v=o(b);k<=p&&(k<p?f=[{handle:b,validHandleResult:v}]:k===p&&f.push({handle:b,validHandleResult:v}),p=k)}}),!f.length)return{handle:null,validHandleResult:o4()};if(f.length===1)return f[0];const m=f.some(({validHandleResult:b})=>b.isValid),w=f.some(({handle:b})=>b.type==="target");return f.find(({handle:b,validHandleResult:k})=>w?b.type==="target":m?k.isValid:!0)||f[0]}const B7={source:null,target:null,sourceHandle:null,targetHandle:null},o4=()=>({handleDomNode:null,isValid:!1,connection:B7,endHandle:null});function i4(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={...o4(),handleDomNode:u};if(u){const f=eN(void 0,u),p=u.getAttribute("data-nodeid"),m=u.getAttribute("data-handleid"),w=u.classList.contains("connectable"),b=u.classList.contains("connectableend"),k={source:l?p:n,sourceHandle:l?m:s,target:l?n:p,targetHandle:l?s:m};h.connection=k,w&&b&&(t===hi.Strict?l&&f==="source"||!l&&f==="target":p!==n||m!==s)&&(h.endHandle={nodeId:p,handleId:m,type:f},h.isValid=o(k))}return h}function q7({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=EE(o,i,"source",`${t}-${n}-${s}`),u=EE(o,i,"target",`${t}-${n}-${s}`)),a.push(...l,...u)}return a},[])}function eN(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function qy(e){e==null||e.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function U7(e,t){let n=null;return t?n="valid":e&&!t&&(n="invalid"),n}function l4({event:e,handleId:t,nodeId:n,onConnect:s,isTarget:a,getState:o,setState:i,isValidConnection:l,edgeUpdaterType:u,onReconnectEnd:h}){const f=K3(e.target),{connectionMode:p,domNode:m,autoPanOnConnect:w,connectionRadius:b,onConnectStart:k,panBy:v,getNodes:N,cancelConnection:x}=o();let C=0,S;const{x:_,y:$}=eo(e),A=f==null?void 0:f.elementFromPoint(_,$),O=eN(u,A),M=m==null?void 0:m.getBoundingClientRect();if(!M||!O)return;let W,B=eo(e,M),R=!1,q=null,T=!1,F=null;const D=q7({nodes:N(),nodeId:n,handleId:t,handleType:O}),K=()=>{if(!w)return;const[P,I]=G3(B,M);v({x:P,y:I}),C=requestAnimationFrame(K)};i({connectionPosition:B,connectionStatus:null,connectionNodeId:n,connectionHandleId:t,connectionHandleType:O,connectionStartHandle:{nodeId:n,handleId:t,type:O},connectionEndHandle:null}),k==null||k(e,{nodeId:n,handleId:t,handleType:O});function V(P){const{transform:I}=o();B=eo(P,M);const{handle:U,validHandleResult:Z}=F7(P,f,g1(B,I,!1,[1,1]),b,D,z=>i4(z,p,n,t,a?"target":"source",l,f));if(S=U,R||(K(),R=!0),F=Z.handleDomNode,q=Z.connection,T=Z.isValid,i({connectionPosition:S&&T?n4({x:S.x,y:S.y},I):B,connectionStatus:U7(!!S,T),connectionEndHandle:Z.endHandle}),!S&&!T&&!F)return qy(W);q.source!==q.target&&F&&(qy(W),W=F,F.classList.add("connecting","react-flow__handle-connecting"),F.classList.toggle("valid",T),F.classList.toggle("react-flow__handle-valid",T))}function H(P){var I,U;(S||F)&&q&&T&&(s==null||s(q)),(U=(I=o()).onConnectEnd)==null||U.call(I,P),u&&(h==null||h(P)),qy(W),x(),cancelAnimationFrame(C),R=!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 TE=()=>!0,W7=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),H7=(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}},c4=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 M,W;const b=i||null,k=e==="target",v=Wt(),N=L7(),{connectOnClick:x,noPanClassName:C}=ht(W7,en),{connecting:S,clickConnecting:_}=ht(H7(N,b,e),en);N||(W=(M=v.getState()).onError)==null||W.call(M,"010",ua.error010());const $=B=>{const{defaultEdgeOptions:R,onConnect:q,hasDefaultEdges:T}=v.getState(),F={...R,...B};if(T){const{edges:D,setEdges:K}=v.getState();K(D7(F,D))}q==null||q(F),l==null||l(F)},A=B=>{if(!N)return;const R=J3(B);a&&(R&&B.button===0||!R)&&l4({event:B,handleId:b,nodeId:N,onConnect:$,isTarget:k,getState:v.getState,setState:v.setState,isValidConnection:n||v.getState().isValidConnection||TE}),R?f==null||f(B):p==null||p(B)},O=B=>{const{onClickConnectStart:R,onClickConnectEnd:q,connectionClickStartHandle:T,connectionMode:F,isValidConnection:D}=v.getState();if(!N||!T&&!a)return;if(!T){R==null||R(B,{nodeId:N,handleId:b,handleType:e}),v.setState({connectionClickStartHandle:{nodeId:N,type:e,handleId:b}});return}const K=K3(B.target),V=n||D||TE,{connection:H,isValid:P}=i4({nodeId:N,id:b,type:e},F,T.nodeId,T.handleId||null,T.type,V,K);P&&$(H),q==null||q(B),v.setState({connectionClickStartHandle:null})};return me.createElement("div",{"data-handleid":b,"data-nodeid":N,"data-handlepos":t,"data-id":`${N}-${b}-${e}`,className:dn(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",C,h,{source:!k,target:k,connectable:s,connectablestart:a,connectableend:o,connecting:_,connectionindicator:s&&(a&&!S||o&&S)}]),onMouseDown:A,onTouchStart:A,onClick:x?O:void 0,ref:w,...m},u)});c4.displayName="Handle";var fi=g.memo(c4);const u4=({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}));u4.displayName="DefaultNode";var y1=g.memo(u4);const d4=({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}));d4.displayName="InputNode";var h4=g.memo(d4);const f4=({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);f4.displayName="OutputNode";var p4=g.memo(f4);const tN=()=>null;tN.displayName="GroupNode";const z7=e=>({selectedNodes:e.getNodes().filter(t=>t.selected),selectedEdges:e.edges.filter(t=>t.selected).map(t=>({...t}))}),Xh=e=>e.id;function V7(e,t){return en(e.selectedNodes.map(Xh),t.selectedNodes.map(Xh))&&en(e.selectedEdges.map(Xh),t.selectedEdges.map(Xh))}const m4=g.memo(({onSelectionChange:e})=>{const t=Wt(),{selectedNodes:n,selectedEdges:s}=ht(z7,V7);return g.useEffect(()=>{const a={nodes:n,edges:s};e==null||e(a),t.getState().onSelectionChange.forEach(o=>o(a))},[n,s,e]),null});m4.displayName="SelectionListener";const G7=e=>!!e.onSelectionChange;function K7({onSelectionChange:e}){const t=ht(G7);return e||t?me.createElement(m4,{onSelectionChange:e}):null}const Y7=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 X7=({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:b,minZoom:k,maxZoom:v,nodeExtent:N,onNodesChange:x,onEdgesChange:C,elementsSelectable:S,connectionMode:_,snapGrid:$,snapToGrid:A,translateExtent:O,connectOnClick:M,defaultEdgeOptions:W,fitView:B,fitViewOptions:R,onNodesDelete:q,onEdgesDelete:T,onNodeDrag:F,onNodeDragStart:D,onNodeDragStop:K,onSelectionDrag:V,onSelectionDragStart:H,onSelectionDragStop:P,noPanClassName:I,nodeOrigin:U,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(Y7,en),ve=Wt();return g.useEffect(()=>{const je=s==null?void 0:s.map(Ee=>({...Ee,...W}));return oe(n,je),()=>{ge()}},[]),lt("defaultEdgeOptions",W,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",S,ve.setState),lt("elevateNodesOnSelect",b,ve.setState),lt("snapToGrid",A,ve.setState),lt("snapGrid",$,ve.setState),lt("onNodesChange",x,ve.setState),lt("onEdgesChange",C,ve.setState),lt("connectOnClick",M,ve.setState),lt("fitViewOnInit",B,ve.setState),lt("fitViewOnInitOptions",R,ve.setState),lt("onNodesDelete",q,ve.setState),lt("onEdgesDelete",T,ve.setState),lt("onNodeDrag",F,ve.setState),lt("onNodeDragStart",D,ve.setState),lt("onNodeDragStop",K,ve.setState),lt("onSelectionDrag",V,ve.setState),lt("onSelectionDragStart",H,ve.setState),lt("onSelectionDragStop",P,ve.setState),lt("noPanClassName",I,ve.setState),lt("nodeOrigin",U,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(k,re),rl(v,he),rl(O,pe),rl(N,Le),null},AE={display:"none"},Z7={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},g4="react-flow__node-desc",y4="react-flow__edge-desc",J7="react-flow__aria-live",Q7=e=>e.ariaLiveMessage;function ez({rfId:e}){const t=ht(Q7);return me.createElement("div",{id:`${J7}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:Z7},t)}function tz({rfId:e,disableKeyboardA11y:t}){return me.createElement(me.Fragment,null,me.createElement("div",{id:`${g4}-${e}`,style:AE},"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:`${y4}-${e}`,style:AE},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!t&&me.createElement(ez,{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)&&f1(w))return!1;const k=ME(w.code,l);o.current.add(w[k]),RE(i,o.current,!1)&&(w.preventDefault(),s(!0))},p=w=>{if((!a.current||a.current&&!t.actInsideInputWithModifier)&&f1(w))return!1;const k=ME(w.code,l);RE(i,o.current,!0)?(s(!1),o.current.clear()):o.current.delete(w[k]),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 RE(e,t,n){return e.filter(s=>n||s.length===t.size).some(s=>s.every(a=>t.has(a)))}function ME(e,t){return t.includes(e)?"code":"key"}function w4(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 w4(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 x4(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}=w4(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 Uy(e,t,n,s){const a=new Map,o={},i=s?1e3:0;return e.forEach(l=>{var w;const u=(ws(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)}),x4(a,n,o),a}function v4(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 b=n().filter(v=>{var x;const N=t.includeHiddenNodes?v.width&&v.height:!v.hidden;return(x=t.nodes)!=null&&x.length?N&&t.nodes.some(C=>C.id===v.id):N}),k=b.every(v=>v.width&&v.height);if(b.length>0&&k){const v=zp(b,p),{x:N,y:x,zoom:C}=a4(v,s,a,t.minZoom??o,t.maxZoom??i,t.padding??.1),S=aa.translate(N,x).scale(C);return typeof t.duration=="number"&&t.duration>0?l.transform(Go(u,t.duration),S):l.transform(u,S),!0}}return!1}function nz(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 sz(e,t){return t.map(n=>{const s=e.find(a=>a.id===n.id);return s&&(n.selected=s.selected),n})}function Zh({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:nz(e,a)}),i==null||i(e)),t!=null&&t.length&&(h&&s({edges:sz(t,o)}),l==null||l(t))}const al=()=>{},rz={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},az=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection}),oz=()=>{const e=Wt(),{d3Zoom:t,d3Selection:n}=ht(az,en);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=aa.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=>v4(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=aa.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}=a4(a,i,l,u,h,(o==null?void 0:o.padding)??.1),w=aa.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"),g1(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 g1(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=n4(a,o);return{x:h.x+l,y:h.y+u}},viewportInitialized:!0}:rz,[t,n])};function ec(){const e=oz(),t=Wt(),n=g.useCallback(()=>t.getState().getNodes().map(k=>({...k})),[]),s=g.useCallback(k=>t.getState().nodeInternals.get(k),[]),a=g.useCallback(()=>{const{edges:k=[]}=t.getState();return k.map(v=>({...v}))},[]),o=g.useCallback(k=>{const{edges:v=[]}=t.getState();return v.find(N=>N.id===k)},[]),i=g.useCallback(k=>{const{getNodes:v,setNodes:N,hasDefaultNodes:x,onNodesChange:C}=t.getState(),S=v(),_=typeof k=="function"?k(S):k;if(x)N(_);else if(C){const $=_.length===0?S.map(A=>({type:"remove",id:A.id})):_.map(A=>({item:A,type:"reset"}));C($)}},[]),l=g.useCallback(k=>{const{edges:v=[],setEdges:N,hasDefaultEdges:x,onEdgesChange:C}=t.getState(),S=typeof k=="function"?k(v):k;if(x)N(S);else if(C){const _=S.length===0?v.map($=>({type:"remove",id:$.id})):S.map($=>({item:$,type:"reset"}));C(_)}},[]),u=g.useCallback(k=>{const v=Array.isArray(k)?k:[k],{getNodes:N,setNodes:x,hasDefaultNodes:C,onNodesChange:S}=t.getState();if(C){const $=[...N(),...v];x($)}else if(S){const _=v.map($=>({item:$,type:"add"}));S(_)}},[]),h=g.useCallback(k=>{const v=Array.isArray(k)?k:[k],{edges:N=[],setEdges:x,hasDefaultEdges:C,onEdgesChange:S}=t.getState();if(C)x([...N,...v]);else if(S){const _=v.map($=>({item:$,type:"add"}));S(_)}},[]),f=g.useCallback(()=>{const{getNodes:k,edges:v=[],transform:N}=t.getState(),[x,C,S]=N;return{nodes:k().map(_=>({..._})),edges:v.map(_=>({..._})),viewport:{x,y:C,zoom:S}}},[]),p=g.useCallback(({nodes:k,edges:v})=>{const{nodeInternals:N,getNodes:x,edges:C,hasDefaultNodes:S,hasDefaultEdges:_,onNodesDelete:$,onEdgesDelete:A,onNodesChange:O,onEdgesChange:M}=t.getState(),W=(k||[]).map(F=>F.id),B=(v||[]).map(F=>F.id),R=x().reduce((F,D)=>{const K=D.parentNode||D.parentId,V=!W.includes(D.id)&&K&&F.find(P=>P.id===K);return(typeof D.deletable=="boolean"?D.deletable:!0)&&(W.includes(D.id)||V)&&F.push(D),F},[]),q=C.filter(F=>typeof F.deletable=="boolean"?F.deletable:!0),T=q.filter(F=>B.includes(F.id));if(R||T){const F=r4(R,q),D=[...T,...F],K=D.reduce((V,H)=>(V.includes(H.id)||V.push(H.id),V),[]);if((_||S)&&(_&&t.setState({edges:C.filter(V=>!K.includes(V.id))}),S&&(R.forEach(V=>{N.delete(V.id)}),t.setState({nodeInternals:new Map(N)}))),K.length>0&&(A==null||A(D),M&&M(K.map(V=>({id:V,type:"remove"})))),R.length>0&&($==null||$(R),O)){const V=R.map(H=>({id:H.id,type:"remove"}));O(V)}}},[]),m=g.useCallback(k=>{const v=C7(k),N=v?null:t.getState().nodeInternals.get(k.id);return!v&&!N?[null,null,v]:[v?k:jE(N),N,v]},[]),w=g.useCallback((k,v=!0,N)=>{const[x,C,S]=m(k);return x?(N||t.getState().getNodes()).filter(_=>{if(!S&&(_.id===C.id||!_.positionAbsolute))return!1;const $=jE(_),A=h1($,x);return v&&A>0||A>=x.width*x.height}):[]},[]),b=g.useCallback((k,v,N=!0)=>{const[x]=m(k);if(!x)return!1;const C=h1(x,v);return N&&C>0||C>=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:b}),[e,n,s,a,o,i,l,u,h,f,p,w,b])}const iz={actInsideInputWithModifier:!1};var lz=({deleteKeyCode:e,multiSelectionKeyCode:t})=>{const n=Wt(),{deleteElements:s}=ec(),a=zu(e,iz),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 cz(e){const t=Wt();g.useEffect(()=>{let n;const s=()=>{var o,i;if(!e.current)return;const a=Gj(e.current);(a.height===0||a.width===0)&&((i=(o=t.getState()).onError)==null||i.call(o,"004",ua.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 nN={position:"absolute",width:"100%",height:"100%",top:0,left:0},uz=(e,t)=>e.x!==t.x||e.y!==t.y||e.zoom!==t.k,Jh=e=>({x:e.x,y:e.y,zoom:e.k}),ol=(e,t)=>e.target.closest(`.${t}`),$E=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),LE=e=>{const t=e.ctrlKey&&Zf()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t},dz=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),hz=({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:b,maxZoom:k,zoomActivationKeyCode:v,preventScrolling:N=!0,children:x,noWheelClassName:C,noPanClassName:S})=>{const _=g.useRef(),$=Wt(),A=g.useRef(!1),O=g.useRef(!1),M=g.useRef(null),W=g.useRef({x:0,y:0,zoom:0}),{d3Zoom:B,d3Selection:R,d3ZoomHandler:q,userSelectionActive:T}=ht(dz,en),F=zu(v),D=g.useRef(0),K=g.useRef(!1),V=g.useRef();return cz(M),g.useEffect(()=>{if(M.current){const H=M.current.getBoundingClientRect(),P=z3().scaleExtent([b,k]).translateExtent(w),I=ys(M.current).call(P),U=aa.translate(m.x,m.y).scale(Wl(m.zoom,b,k)),Z=[[0,0],[H.width,H.height]],z=P.constrain()(U,Z,w);P.transform(I,z),P.wheelDelta(LE),$.setState({d3Zoom:P,d3Selection:I,d3ZoomHandler:I.on("wheel.zoom"),transform:[z.x,z.y,z.k],domNode:M.current.closest(".react-flow")})}},[]),g.useEffect(()=>{R&&B&&(i&&!F&&!T?R.on("wheel.zoom",H=>{if(ol(H,C))return!1;H.preventDefault(),H.stopImmediatePropagation();const P=R.property("__zoom").k||1;if(H.ctrlKey&&o){const Q=Gs(H),te=LE(H),le=P*Math.pow(2,te);B.scaleTo(R,le,Q,H);return}const I=H.deltaMode===1?20:1;let U=u===ei.Vertical?0:H.deltaX*I,Z=u===ei.Horizontal?0:H.deltaY*I;!Zf()&&H.shiftKey&&u!==ei.Vertical&&(U=H.deltaY*I,Z=0),B.translateBy(R,-(U/P)*l,-(Z/P)*l,{internal:!0});const z=Jh(R.property("__zoom")),{onViewportChangeStart:X,onViewportChange:Y,onViewportChangeEnd:J}=$.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"&&R.on("wheel.zoom",function(H,P){if(!N&&H.type==="wheel"&&!H.ctrlKey||ol(H,C))return null;H.preventDefault(),q.call(this,H,P)},{passive:!1}))},[T,i,u,R,B,q,F,o,N,C,t,e,n]),g.useEffect(()=>{B&&B.on("start",H=>{var U,Z;if(!H.sourceEvent||H.sourceEvent.internal)return null;D.current=(U=H.sourceEvent)==null?void 0:U.button;const{onViewportChangeStart:P}=$.getState(),I=Jh(H.transform);A.current=!0,W.current=I,((Z=H.sourceEvent)==null?void 0:Z.type)==="mousedown"&&$.setState({paneDragging:!0}),P==null||P(I),t==null||t(H.sourceEvent,I)})},[B,t]),g.useEffect(()=>{B&&(T&&!A.current?B.on("zoom",null):T||B.on("zoom",H=>{var I;const{onViewportChange:P}=$.getState();if($.setState({transform:[H.transform.x,H.transform.y,H.transform.k]}),O.current=!!(s&&$E(p,D.current??0)),(e||P)&&!((I=H.sourceEvent)!=null&&I.internal)){const U=Jh(H.transform);P==null||P(U),e==null||e(H.sourceEvent,U)}}))},[T,B,e,p,s]),g.useEffect(()=>{B&&B.on("end",H=>{if(!H.sourceEvent||H.sourceEvent.internal)return null;const{onViewportChangeEnd:P}=$.getState();if(A.current=!1,$.setState({paneDragging:!1}),s&&$E(p,D.current??0)&&!O.current&&s(H.sourceEvent),O.current=!1,(n||P)&&uz(W.current,H.transform)){const I=Jh(H.transform);W.current=I,clearTimeout(_.current),_.current=setTimeout(()=>{P==null||P(I),n==null||n(H.sourceEvent,I)},i?150:0)}})},[B,i,p,n,s]),g.useEffect(()=>{B&&B.filter(H=>{const P=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&&!P&&!i&&!h&&!o||T||!h&&H.type==="dblclick"||ol(H,C)&&H.type==="wheel"||ol(H,S)&&(H.type!=="wheel"||i&&H.type==="wheel"&&!F)||!o&&H.ctrlKey&&H.type==="wheel"||!P&&!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 U=Array.isArray(p)&&p.includes(H.button)||!H.button||H.button<=1;return(!H.ctrlKey||H.type==="wheel")&&U})},[T,B,a,o,i,h,p,f,F]),me.createElement("div",{className:"react-flow__renderer",ref:M,style:nN},x)},fz=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function pz(){const{userSelectionActive:e,userSelectionRect:t}=ht(fz,en);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 IE(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 mz(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&&IE(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&&IE(s,i);break}case"remove":return s}return s.push(i),s},n)}function gz(e,t){return mz(e,t)}const Ga=(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(Ga(s.id,!0))):s.selected&&!a&&(s.selected=!1,n.push(Ga(s.id,!1))),n},[])}const Wy=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},yz=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),b4=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(),b=g.useRef(0),k=g.useRef(0),v=g.useRef(),{userSelectionActive:N,elementsSelectable:x,dragging:C}=ht(yz,en),S=()=>{w.setState({userSelectionActive:!1,userSelectionRect:null}),b.current=0,k.current=0},_=q=>{o==null||o(q),w.getState().resetSelectedElements(),w.setState({nodesSelectionActive:!1})},$=q=>{if(Array.isArray(n)&&(n!=null&&n.includes(2))){q.preventDefault();return}i==null||i(q)},A=l?q=>l(q):void 0,O=q=>{const{resetSelectedElements:T,domNode:F}=w.getState();if(v.current=F==null?void 0:F.getBoundingClientRect(),!x||!e||q.button!==0||q.target!==m.current||!v.current)return;const{x:D,y:K}=eo(q,v.current);T(),w.setState({userSelectionRect:{width:0,height:0,startX:D,startY:K,x:D,y:K}}),s==null||s(q)},M=q=>{const{userSelectionRect:T,nodeInternals:F,edges:D,transform:K,onNodesChange:V,onEdgesChange:H,nodeOrigin:P,getNodes:I}=w.getState();if(!e||!v.current||!T)return;w.setState({userSelectionActive:!0,nodesSelectionActive:!1});const U=eo(q,v.current),Z=T.startX??0,z=T.startY??0,X={...T,x:U.x<Z?U.x:Z,y:U.y<z?U.y:z,width:Math.abs(U.x-Z),height:Math.abs(U.y-z)},Y=I(),J=s4(F,X,K,t===Hu.Partial,!0,P),Q=r4(J,D).map(le=>le.id),te=J.map(le=>le.id);if(b.current!==te.length){b.current=te.length;const le=jl(Y,te);le.length&&(V==null||V(le))}if(k.current!==Q.length){k.current=Q.length;const le=jl(D,Q);le.length&&(H==null||H(le))}w.setState({userSelectionRect:X})},W=q=>{if(q.button!==0)return;const{userSelectionRect:T}=w.getState();!N&&T&&q.target===m.current&&(_==null||_(q)),w.setState({nodesSelectionActive:b.current>0}),S(),a==null||a(q)},B=q=>{N&&(w.setState({nodesSelectionActive:b.current>0}),a==null||a(q)),S()},R=x&&(e||N);return me.createElement("div",{className:dn(["react-flow__pane",{dragging:C,selection:e}]),onClick:R?void 0:Wy(_,m),onContextMenu:Wy($,m),onWheel:Wy(A,m),onMouseEnter:R?void 0:u,onMouseDown:R?O:void 0,onMouseMove:R?M:h,onMouseUp:R?W:void 0,onMouseLeave:R?B:f,ref:m,style:nN},p,me.createElement(pz,null))});b4.displayName="Pane";function k4(e,t){const n=e.parentNode||e.parentId;if(!n)return!1;const s=t.get(n);return s?s.selected?!0:k4(s,t):!1}function OE(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 wz(e,t,n,s){return Array.from(e.values()).filter(a=>(a.selected||a.id===s)&&(!a.parentNode||a.parentId||!k4(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 xz(e,t){return!t||t==="parent"?t:[t[0],[t[1][0]-(e.width||0),t[1][1]-(e.height||0)]]}function j4(e,t,n,s,a=[0,0],o){const i=xz(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&&ws(m)&&ws(w)&&ws(p.width)&&ws(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",ua.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"?Kj(t,l):t;return{position:{x:f.x-h.x,y:f.y-h.y},positionAbsolute:f}}function Hy({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 PE=(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,...Gj(u)}})};function ru(e,t,n){return n===void 0?n:s=>{const a=t().nodeInternals.get(e);a&&n(s,{...a})}}function w1({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",ua.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 vz(){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 zy(e){return(t,n,s)=>e==null?void 0:e(t,s)}function N4({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),b=g.useRef({x:0,y:0}),k=g.useRef(null),v=g.useRef(!1),N=g.useRef(!1),x=g.useRef(!1),C=vz();return g.useEffect(()=>{if(e!=null&&e.current){const S=ys(e.current),_=({x:O,y:M})=>{const{nodeInternals:W,onNodeDrag:B,onSelectionDrag:R,updateNodePositions:q,nodeExtent:T,snapGrid:F,snapToGrid:D,nodeOrigin:K,onError:V}=l.getState();p.current={x:O,y:M};let H=!1,P={x:0,y:0,x2:0,y2:0};if(f.current.length>1&&T){const U=zp(f.current,K);P=Wu(U)}if(f.current=f.current.map(U=>{const Z={x:O-U.distance.x,y:M-U.distance.y};D&&(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&&!U.extent&&(z[0][0]=U.positionAbsolute.x-P.x+T[0][0],z[1][0]=U.positionAbsolute.x+(U.width??0)-P.x2+T[1][0],z[0][1]=U.positionAbsolute.y-P.y+T[0][1],z[1][1]=U.positionAbsolute.y+(U.height??0)-P.y2+T[1][1]);const X=j4(U,Z,W,z,K,V);return H=H||U.position.x!==X.position.x||U.position.y!==X.position.y,U.position=X.position,U.positionAbsolute=X.positionAbsolute,U}),!H)return;q(f.current,!0,!0),h(!0);const I=a?B:zy(R);if(I&&k.current){const[U,Z]=Hy({nodeId:a,dragItems:f.current,nodeInternals:W});I(k.current,U,Z)}},$=()=>{if(!w.current)return;const[O,M]=G3(b.current,w.current);if(O!==0||M!==0){const{transform:W,panBy:B}=l.getState();p.current.x=(p.current.x??0)-O/W[2],p.current.y=(p.current.y??0)-M/W[2],B({x:O,y:M})&&_(p.current)}m.current=requestAnimationFrame($)},A=O=>{var K;const{nodeInternals:M,multiSelectionActive:W,nodesDraggable:B,unselectNodesAndEdges:R,onNodeDragStart:q,onSelectionDragStart:T}=l.getState();N.current=!0;const F=a?q:zy(T);(!i||!o)&&!W&&a&&((K=M.get(a))!=null&&K.selected||R()),a&&o&&i&&w1({id:a,store:l,nodeRef:e});const D=C(O);if(p.current=D,f.current=wz(M,B,D,a),F&&f.current){const[V,H]=Hy({nodeId:a,dragItems:f.current,nodeInternals:M});F(O.sourceEvent,V,H)}};if(t)S.on(".drag",null);else{const O=AW().on("start",M=>{const{domNode:W,nodeDragThreshold:B}=l.getState();B===0&&A(M),x.current=!1;const R=C(M);p.current=R,w.current=(W==null?void 0:W.getBoundingClientRect())||null,b.current=eo(M.sourceEvent,w.current)}).on("drag",M=>{var q,T;const W=C(M),{autoPanOnNodeDrag:B,nodeDragThreshold:R}=l.getState();if(M.sourceEvent.type==="touchmove"&&M.sourceEvent.touches.length>1&&(x.current=!0),!x.current){if(!v.current&&N.current&&B&&(v.current=!0,$()),!N.current){const F=W.xSnapped-(((q=p==null?void 0:p.current)==null?void 0:q.x)??0),D=W.ySnapped-(((T=p==null?void 0:p.current)==null?void 0:T.y)??0);Math.sqrt(F*F+D*D)>R&&A(M)}(p.current.x!==W.xSnapped||p.current.y!==W.ySnapped)&&f.current&&N.current&&(k.current=M.sourceEvent,b.current=eo(M.sourceEvent,w.current),_(W))}}).on("end",M=>{if(!(!N.current||x.current)&&(h(!1),v.current=!1,N.current=!1,cancelAnimationFrame(m.current),f.current)){const{updateNodePositions:W,nodeInternals:B,onNodeDragStop:R,onSelectionDragStop:q}=l.getState(),T=a?R:zy(q);if(W(f.current,!1,!1),T){const[F,D]=Hy({nodeId:a,dragItems:f.current,nodeInternals:B});T(M.sourceEvent,F,D)}}}).filter(M=>{const W=M.target;return!M.button&&(!n||!OE(W,`.${n}`,e))&&(!s||OE(W,s,e))});return S.call(O),()=>{S.on(".drag",null)}}}},[e,t,n,s,o,l,a,i,C]),u}function S4(){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,b=n.isShiftPressed?4:1,k=n.x*m*b,v=n.y*w*b,N=p.map(x=>{if(x.positionAbsolute){const C={x:x.positionAbsolute.x+k,y:x.positionAbsolute.y+v};l&&(C.x=u[0]*Math.round(C.x/u[0]),C.y=u[1]*Math.round(C.y/u[1]));const{positionAbsolute:S,position:_}=j4(x,C,s,a,void 0,h);x.position=_,x.positionAbsolute=S}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:b,onDoubleClick:k,style:v,className:N,isDraggable:x,isSelectable:C,isConnectable:S,isFocusable:_,selectNodesOnDrag:$,sourcePosition:A,targetPosition:O,hidden:M,resizeObserver:W,dragHandle:B,zIndex:R,isParent:q,noDragClassName:T,noPanClassName:F,initialized:D,disableKeyboardA11y:K,ariaLabel:V,rfId:H,hasHandleBounds:P})=>{const I=Wt(),U=g.useRef(null),Z=g.useRef(null),z=g.useRef(A),X=g.useRef(O),Y=g.useRef(s),J=C||x||f||p||m||w,Q=S4(),te=ru(n,I.getState,p),le=ru(n,I.getState,m),de=ru(n,I.getState,w),oe=ru(n,I.getState,b),re=ru(n,I.getState,k),he=ge=>{const{nodeDragThreshold:ve}=I.getState();if(C&&(!$||!x||ve>0)&&w1({id:n,store:I,nodeRef:U}),f){const je=I.getState().nodeInternals.get(n);je&&f(ge,{...je})}},pe=ge=>{if(!f1(ge)&&!K)if(Z3.includes(ge.key)&&C){const ve=ge.key==="Escape";w1({id:n,store:I,unselect:ve,nodeRef:U})}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&&(W==null||W.unobserve(Z.current),Z.current=null)},[]),g.useEffect(()=>{if(U.current&&!M){const ge=U.current;(!D||!P||Z.current!==ge)&&(Z.current&&(W==null||W.unobserve(Z.current)),W==null||W.observe(ge),Z.current=ge)}},[M,D,P]),g.useEffect(()=>{const ge=Y.current!==s,ve=z.current!==A,je=X.current!==O;U.current&&(ge||ve||je)&&(ge&&(Y.current=s),ve&&(z.current=A),je&&(X.current=O),I.getState().updateNodeDimensions([{id:n,nodeElement:U.current,forceUpdate:!0}]))},[n,s,A,O]);const Le=N4({nodeRef:U,disabled:M||!x,noDragClassName:T,handleSelector:B,nodeId:n,isSelectable:C,selectNodesOnDrag:$});return M?null:me.createElement("div",{className:dn(["react-flow__node",`react-flow__node-${s}`,{[F]:x},N,{selected:h,selectable:C,parent:q,dragging:Le}]),ref:U,style:{zIndex:R,transform:`translate(${l}px,${u}px)`,pointerEvents:J?"all":"none",visibility:D?"visible":"hidden",...v},"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:`${g4}-${H}`,"aria-label":V},me.createElement($7,{value:n},me.createElement(e,{id:n,data:a,type:s,xPos:o,yPos:i,selected:h,isConnectable:S,sourcePosition:A,targetPosition:O,dragging:Le,dragHandle:B,zIndex:R})))};return t.displayName="NodeWrapper",g.memo(t)};const bz=e=>{const t=e.getNodes().filter(n=>n.selected);return{...zp(t,e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive}};function kz({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const s=Wt(),{width:a,height:o,x:i,y:l,transformString:u,userSelectionActive:h}=ht(bz,en),f=S4(),p=g.useRef(null);if(g.useEffect(()=>{var b;n||(b=p.current)==null||b.focus({preventScroll:!0})},[n]),N4({nodeRef:p}),h||!a||!o)return null;const m=e?b=>{const k=s.getState().getNodes().filter(v=>v.selected);e(b,k)}:void 0,w=b=>{Object.prototype.hasOwnProperty.call(Ml,b.key)&&f({x:Ml[b.key].x,y:Ml[b.key].y,isShiftPressed:b.shiftKey})};return me.createElement("div",{className:dn(["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 jz=g.memo(kz);const Nz=e=>e.nodesSelectionActive,C4=({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:b,onSelectionEnd:k,multiSelectionKeyCode:v,panActivationKeyCode:N,zoomActivationKeyCode:x,elementsSelectable:C,zoomOnScroll:S,zoomOnPinch:_,panOnScroll:$,panOnScrollSpeed:A,panOnScrollMode:O,zoomOnDoubleClick:M,panOnDrag:W,defaultViewport:B,translateExtent:R,minZoom:q,maxZoom:T,preventScrolling:F,onSelectionContextMenu:D,noWheelClassName:K,noPanClassName:V,disableKeyboardA11y:H})=>{const P=ht(Nz),I=zu(p),U=zu(N),Z=U||W,z=U||$,X=I||m&&Z!==!0;return lz({deleteKeyCode:l,multiSelectionKeyCode:v}),me.createElement(hz,{onMove:u,onMoveStart:h,onMoveEnd:f,onPaneContextMenu:o,elementsSelectable:C,zoomOnScroll:S,zoomOnPinch:_,panOnScroll:z,panOnScrollSpeed:A,panOnScrollMode:O,zoomOnDoubleClick:M,panOnDrag:!I&&Z,defaultViewport:B,translateExtent:R,minZoom:q,maxZoom:T,zoomActivationKeyCode:x,preventScrolling:F,noWheelClassName:K,noPanClassName:V},me.createElement(b4,{onSelectionStart:b,onSelectionEnd:k,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:o,onPaneScroll:i,panOnDrag:Z,isSelecting:!!X,selectionMode:w},e,P&&me.createElement(jz,{onSelectionContextMenu:D,noPanClassName:V,disableKeyboardA11y:H})))};C4.displayName="FlowRenderer";var Sz=g.memo(C4);function Cz(e){return ht(g.useCallback(n=>e?s4(n.nodeInternals,{x:0,y:0,width:n.width,height:n.height},n.transform,!0):n.getNodes(),[e]))}function _z(e){const t={input:au(e.input||h4),default:au(e.default||y1),output:au(e.output||p4),group:au(e.group||tN)},n={},s=Object.keys(e).filter(a=>!["input","default","output","group"].includes(a)).reduce((a,o)=>(a[o]=au(e[o]||y1),a),n);return{...t,...s}}const Ez=({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]},Tz=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),_4=e=>{const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:s,elementsSelectable:a,updateNodeDimensions:o,onError:i}=ht(Tz,en),l=Cz(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:nN},l.map(f=>{var _,$,A;let p=f.type||"default";e.nodeTypes[p]||(i==null||i("003",ua.error003(p)),p="default");const m=e.nodeTypes[p]||e.nodeTypes.default,w=!!(f.draggable||t&&typeof f.draggable>"u"),b=!!(f.selectable||a&&typeof f.selectable>"u"),k=!!(f.connectable||n&&typeof f.connectable>"u"),v=!!(f.focusable||s&&typeof f.focusable>"u"),N=e.nodeExtent?Kj(f.positionAbsolute,e.nodeExtent):f.positionAbsolute,x=(N==null?void 0:N.x)??0,C=(N==null?void 0:N.y)??0,S=Ez({x,y:C,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:C,xPosOrigin:S.x,yPosOrigin:S.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:b,isConnectable:k,isFocusable:v,resizeObserver:h,dragHandle:f.dragHandle,zIndex:((_=f[Ft])==null?void 0:_.z)??0,isParent:!!(($=f[Ft])!=null&&$.isParent),noDragClassName:e.noDragClassName,noPanClassName:e.noPanClassName,initialized:!!f.width&&!!f.height,rfId:e.rfId,disableKeyboardA11y:e.disableKeyboardA11y,ariaLabel:f.ariaLabel,hasHandleBounds:!!((A=f[Ft])!=null&&A.handleBounds)})}))};_4.displayName="NodeRenderer";var Az=g.memo(_4);const Rz=(e,t,n)=>n===Ye.Left?e-t:n===Ye.Right?e+t:e,Mz=(e,t,n)=>n===Ye.Top?e-t:n===Ye.Bottom?e+t:e,DE="react-flow__edgeupdater",FE=({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:dn([DE,`${DE}-${l}`]),cx:Rz(t,s,e),cy:Mz(n,s,e),r:s,stroke:"transparent",fill:"transparent"}),$z=()=>!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:b,labelBgBorderRadius:k,style:v,source:N,target:x,sourceX:C,sourceY:S,targetX:_,targetY:$,sourcePosition:A,targetPosition:O,elementsSelectable:M,hidden:W,sourceHandleId:B,targetHandleId:R,onContextMenu:q,onMouseEnter:T,onMouseMove:F,onMouseLeave:D,reconnectRadius:K,onReconnect:V,onReconnectStart:H,onReconnectEnd:P,markerEnd:I,markerStart:U,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('#${m1(U,Z)}')`,[U,Z]),ge=g.useMemo(()=>`url('#${m1(I,Z)}')`,[I,Z]);if(W)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&&(M&&(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,D),We=(He,se)=>{if(He.button!==0)return;const{edges:ke,isValidConnection:Ae}=pe.getState(),Oe=se?x:N,be=(se?R:B)||null,fe=se?"target":"source",_e=Ae||$z,Ve=se,ot=ke.find($t=>$t.id===n);he(!0),H==null||H(He,ot,fe);const tt=$t=>{he(!1),P==null||P($t,ot,fe)};l4({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=!M&&!i,rt=He=>{var se;if(!te&&Z3.includes(He.key)&&M){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:dn(["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?`${y4}-${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:b,labelBgBorderRadius:k,data:o,style:v,sourceX:C,sourceY:S,targetX:_,targetY:$,sourcePosition:A,targetPosition:O,sourceHandleId:B,targetHandleId:R,markerStart:Le,markerEnd:ge,pathOptions:J,interactionWidth:Q}),Y&&me.createElement(me.Fragment,null,(Y==="source"||Y===!0)&&me.createElement(FE,{position:A,centerX:C,centerY:S,radius:K,onMouseDown:Ke,onMouseEnter:Fe,onMouseOut:$e,type:"source"}),(Y==="target"||Y===!0)&&me.createElement(FE,{position:O,centerX:_,centerY:$,radius:K,onMouseDown:ye,onMouseEnter:Fe,onMouseOut:$e,type:"target"})))};return t.displayName="EdgeWrapper",g.memo(t)};function Lz(e){const t={default:il(e.default||Qf),straight:il(e.bezier||Zj),step:il(e.step||Xj),smoothstep:il(e.step||Hp),simplebezier:il(e.simplebezier||Yj)},n={},s=Object.keys(e).filter(a=>!["default","bezier"].includes(a)).reduce((a,o)=>(a[o]=il(e[o]||Qf),a),n);return{...t,...s}}function BE(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 qE(e,t){return e?e.length===1||!t?e[0]:t&&e.find(n=>n.id===t)||null:null}const Iz=(e,t,n,s,a,o)=>{const i=BE(n,e,t),l=BE(o,s,a);return{sourceX:i.x,sourceY:i.y,targetX:l.x,targetY:l.y}};function Oz({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 UE(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 Pz=[{level:0,isMaxLevel:!0,edges:[]}];function Dz(e,t,n=!1){let s=-1;const a=e.reduce((i,l)=>{var f,p;const u=ws(l.zIndex);let h=u?l.zIndex:0;if(n){const m=t.get(l.target),w=t.get(l.source),b=l.selected||(m==null?void 0:m.selected)||(w==null?void 0:w.selected),k=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)+(b?k: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?Pz:o}function Fz(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)&&Oz({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 Dz(s,t,n)}const Bz=({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"}),qz=({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"}),WE={[Jf.Arrow]:Bz,[Jf.ArrowClosed]:qz};function Uz(e){const t=Wt();return g.useMemo(()=>{var a,o;return Object.prototype.hasOwnProperty.call(WE,e)?WE[e]:((o=(a=t.getState()).onError)==null||o.call(a,"009",ua.error009(e)),null)},[e])}const Wz=({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=Uz(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},Hz=({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=m1(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))},E4=({defaultColor:e,rfId:t})=>{const n=ht(g.useCallback(Hz({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(Wz,{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})))};E4.displayName="MarkerDefinitions";var zz=g.memo(E4);const Vz=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}),T4=({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:b,reconnectRadius:k,children:v,disableKeyboardA11y:N})=>{const{edgesFocusable:x,edgesUpdatable:C,elementsSelectable:S,width:_,height:$,connectionMode:A,nodeInternals:O,onError:M}=ht(Vz,en),W=Fz(t,O,n);return _?me.createElement(me.Fragment,null,W.map(({level:B,edges:R,isMaxLevel:q})=>me.createElement("svg",{key:B,style:{zIndex:B},width:_,height:$,className:"react-flow__edges react-flow__container"},q&&me.createElement(zz,{defaultColor:e,rfId:s}),me.createElement("g",null,R.map(T=>{const[F,D,K]=UE(O.get(T.source)),[V,H,P]=UE(O.get(T.target));if(!K||!P)return null;let I=T.type||"default";a[I]||(M==null||M("011",ua.error011(I)),I="default");const U=a[I]||a.default,Z=A===hi.Strict?H.target:(H.target??[]).concat(H.source??[]),z=qE(D.source,T.sourceHandle),X=qE(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||C&&typeof te>"u");if(!z||!X)return M==null||M("008",ua.error008(z,T)),null;const{sourceX:de,sourceY:oe,targetX:re,targetY:he}=Iz(F,z,Y,V,X,J);return me.createElement(U,{key:T.id,id:T.id,className:dn([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:S,onContextMenu:i,onMouseEnter:l,onMouseMove:u,onMouseLeave:h,onClick:f,onEdgeDoubleClick:p,onReconnect:m,onReconnectStart:w,onReconnectEnd:b,reconnectRadius:k,rfId:s,ariaLabel:T.ariaLabel,isFocusable:Q,isReconnectable:le,pathOptions:"pathOptions"in T?T.pathOptions:void 0,interactionWidth:T.interactionWidth,disableKeyboardA11y:N})})))),v):null};T4.displayName="EdgeRenderer";var Gz=g.memo(T4);const Kz=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function Yz({children:e}){const t=ht(Kz);return me.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:t}},e)}function Xz(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 Zz={[Ye.Left]:Ye.Right,[Ye.Right]:Ye.Left,[Ye.Top]:Ye.Bottom,[Ye.Bottom]:Ye.Top},A4=({nodeId:e,handleType:t,style:n,type:s=Ya.Bezier,CustomComponent:a,connectionStatus:o})=>{var $,A,O;const{fromNode:i,handleId:l,toX:u,toY:h,connectionMode:f}=ht(g.useCallback(M=>({fromNode:M.nodeInternals.get(e),handleId:M.connectionHandleId,toX:(M.connectionPosition.x-M.transform[0])/M.transform[2],toY:(M.connectionPosition.y-M.transform[1])/M.transform[2],connectionMode:M.connectionMode}),[e]),en),p=($=i==null?void 0:i[Ft])==null?void 0:$.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(M=>M.id===l):m[0],b=w?w.x+w.width/2:(i.width??0)/2,k=w?w.y+w.height/2:i.height??0,v=(((A=i.positionAbsolute)==null?void 0:A.x)??0)+b,N=(((O=i.positionAbsolute)==null?void 0:O.y)??0)+k,x=w==null?void 0:w.position,C=x?Zz[x]:null;if(!x||!C)return null;if(a)return me.createElement(a,{connectionLineType:s,connectionLineStyle:n,fromNode:i,fromHandle:w,fromX:v,fromY:N,toX:u,toY:h,fromPosition:x,toPosition:C,connectionStatus:o});let S="";const _={sourceX:v,sourceY:N,sourcePosition:x,targetX:u,targetY:h,targetPosition:C};return s===Ya.Bezier?[S]=Jj(_):s===Ya.Step?[S]=p1({..._,borderRadius:0}):s===Ya.SmoothStep?[S]=p1(_):s===Ya.SimpleBezier?[S]=t4(_):S=`M${v},${N} ${u},${h}`,me.createElement("path",{d:S,fill:"none",className:"react-flow__connection-path",style:n})};A4.displayName="ConnectionLine";const Jz=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function Qz({containerStyle:e,style:t,type:n,component:s}){const{nodeId:a,handleType:o,nodesConnectable:i,width:l,height:u,connectionStatus:h}=ht(Jz,en);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:dn(["react-flow__connection",h])},me.createElement(A4,{nodeId:a,handleType:o,style:t,type:n,CustomComponent:s,connectionStatus:h})))}function HE(e,t){return g.useRef(null),Wt(),g.useMemo(()=>t(e),[e])}const R4=({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:b,onSelectionStart:k,onSelectionEnd:v,connectionLineType:N,connectionLineStyle:x,connectionLineComponent:C,connectionLineContainerStyle:S,selectionKeyCode:_,selectionOnDrag:$,selectionMode:A,multiSelectionKeyCode:O,panActivationKeyCode:M,zoomActivationKeyCode:W,deleteKeyCode:B,onlyRenderVisibleElements:R,elementsSelectable:q,selectNodesOnDrag:T,defaultViewport:F,translateExtent:D,minZoom:K,maxZoom:V,preventScrolling:H,defaultMarkerColor:P,zoomOnScroll:I,zoomOnPinch:U,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=HE(e,_z),He=HE(t,Lz);return Xz(o),me.createElement(Sz,{onPaneClick:Q,onPaneMouseEnter:te,onPaneMouseMove:le,onPaneMouseLeave:de,onPaneContextMenu:re,onPaneScroll:oe,deleteKeyCode:B,selectionKeyCode:_,selectionOnDrag:$,selectionMode:A,onSelectionStart:k,onSelectionEnd:v,multiSelectionKeyCode:O,panActivationKeyCode:M,zoomActivationKeyCode:W,elementsSelectable:q,onMove:n,onMoveStart:s,onMoveEnd:a,zoomOnScroll:I,zoomOnPinch:U,zoomOnDoubleClick:Y,panOnScroll:Z,panOnScrollSpeed:z,panOnScrollMode:X,panOnDrag:J,defaultViewport:F,translateExtent:D,minZoom:K,maxZoom:V,onSelectionContextMenu:b,preventScrolling:H,noDragClassName:Ie,noWheelClassName:De,noPanClassName:We,disableKeyboardA11y:ye},me.createElement(Yz,null,me.createElement(Gz,{edgeTypes:He,onEdgeClick:l,onEdgeDoubleClick:h,onlyRenderVisibleElements:R,onEdgeContextMenu:he,onEdgeMouseEnter:pe,onEdgeMouseMove:Le,onEdgeMouseLeave:ge,onReconnect:ve,onReconnectStart:je,onReconnectEnd:Ee,reconnectRadius:xe,defaultMarkerColor:P,noPanClassName:We,elevateEdgesOnSelect:!!Ke,disableKeyboardA11y:ye,rfId:Re},me.createElement(Qz,{style:x,type:N,component:C,containerStyle:S})),me.createElement("div",{className:"react-flow__edgelabel-renderer"}),me.createElement(Az,{nodeTypes:rt,onNodeClick:i,onNodeDoubleClick:u,onNodeMouseEnter:f,onNodeMouseMove:p,onNodeMouseLeave:m,onNodeContextMenu:w,selectNodesOnDrag:T,onlyRenderVisibleElements:R,noPanClassName:We,noDragClassName:Ie,disableKeyboardA11y:ye,nodeOrigin:Fe,nodeExtent:$e,rfId:Re})))};R4.displayName="GraphView";var e9=g.memo(R4);const x1=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Ua={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:x1,nodeExtent:x1,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:_7,isValidConnection:void 0},t9=()=>Uq((e,t)=>({...Ua,setNodes:n=>{const{nodeInternals:s,nodeOrigin:a,elevateNodesOnSelect:o}=t();e({nodeInternals:Uy(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?Uy(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((k,v)=>{const N=a.get(v.id);if(N!=null&&N.hidden)a.set(N.id,{...N,[Ft]:{...N[Ft],handleBounds:void 0}});else if(N){const x=Gj(v.nodeElement);!!(x.width&&x.height&&(N.width!==x.width||N.height!==x.height||v.forceUpdate))&&(a.set(N.id,{...N,[Ft]:{...N[Ft],handleBounds:{source:PE(".source",v.nodeElement,m,h),target:PE(".target",v.nodeElement,m,h)}},...x}),k.push({id:N.id,type:"dimensions",dimensions:x}))}return k},[]);x4(a,h);const b=i||o&&!i&&v4(t,{initial:!0,...l});e({nodeInternals:new Map(a),fitViewOnInitDone:b}),(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=gz(n,l()),f=Uy(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=>Ga(u,!0)):(i=jl(o(),n),l=jl(a,[])),Zh({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=>Ga(u,!0)):(i=jl(a,n),l=jl(o(),[])),Zh({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,Ga(f.id,!1))),h=l.map(f=>Ga(f.id,!1));Zh({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=>Ga(l.id,!1)),i=n.filter(l=>l.selected).map(l=>Ga(l.id,!1));Zh({changedNodes:o,changedEdges:i,get:t,set:e})},setNodeExtent:n=>{const{nodeInternals:s}=t();s.forEach(a=>{a.positionAbsolute=Kj(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=aa.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:Ua.connectionNodeId,connectionHandleId:Ua.connectionHandleId,connectionHandleType:Ua.connectionHandleType,connectionStatus:Ua.connectionStatus,connectionStartHandle:Ua.connectionStartHandle,connectionEndHandle:Ua.connectionEndHandle}),reset:()=>e({...Ua})}),Object.is),sN=({children:e})=>{const t=g.useRef(null);return t.current||(t.current=t9()),me.createElement(v7,{value:t.current},e)};sN.displayName="ReactFlowProvider";const M4=({children:e})=>g.useContext(Wp)?me.createElement(me.Fragment,null,e):me.createElement(sN,null,e);M4.displayName="ReactFlowWrapper";const n9={input:h4,default:y1,output:p4,group:tN},s9={default:Qf,straight:Zj,step:Xj,smoothstep:Hp,simplebezier:Yj},r9=[0,0],a9=[15,15],o9={x:0,y:0,zoom:1},i9={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},$4=g.forwardRef(({nodes:e,edges:t,defaultNodes:n,defaultEdges:s,className:a,nodeTypes:o=n9,edgeTypes:i=s9,onNodeClick:l,onEdgeClick:u,onInit:h,onMove:f,onMoveStart:p,onMoveEnd:m,onConnect:w,onConnectStart:b,onConnectEnd:k,onClickConnectStart:v,onClickConnectEnd:N,onNodeMouseEnter:x,onNodeMouseMove:C,onNodeMouseLeave:S,onNodeContextMenu:_,onNodeDoubleClick:$,onNodeDragStart:A,onNodeDrag:O,onNodeDragStop:M,onNodesDelete:W,onEdgesDelete:B,onSelectionChange:R,onSelectionDragStart:q,onSelectionDrag:T,onSelectionDragStop:F,onSelectionContextMenu:D,onSelectionStart:K,onSelectionEnd:V,connectionMode:H=hi.Strict,connectionLineType:P=Ya.Bezier,connectionLineStyle:I,connectionLineComponent:U,connectionLineContainerStyle:Z,deleteKeyCode:z="Backspace",selectionKeyCode:X="Shift",selectionOnDrag:Y=!1,selectionMode:J=Hu.Full,panActivationKeyCode:Q="Space",multiSelectionKeyCode:te=Zf()?"Meta":"Control",zoomActivationKeyCode:le=Zf()?"Meta":"Control",snapToGrid:de=!1,snapGrid:oe=a9,onlyRenderVisibleElements:re=!1,selectNodesOnDrag:he=!0,nodesDraggable:pe,nodesConnectable:Le,nodesFocusable:ge,nodeOrigin:ve=r9,edgesFocusable:je,edgesUpdatable:Ee,elementsSelectable:xe,defaultViewport:Ie=o9,minZoom:De=.5,maxZoom:We=2,translateExtent:Ke=x1,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:Gt,onEdgeMouseEnter:nr,onEdgeMouseMove:_s,onEdgeMouseLeave:Hn,onEdgeUpdate:ns,onEdgeUpdateStart:Es,onEdgeUpdateEnd:wn,onReconnect:zn,onReconnectStart:Me,onReconnectEnd:qe,reconnectRadius:Je=10,edgeUpdaterRadius:_t=10,onNodesChange:Nt,onEdgesChange:ss,noDragClassName:Vn="nodrag",noWheelClassName:xn="nowheel",noPanClassName:Tr="nopan",fitView:vn=!1,fitViewOptions:on,connectOnClick:Ts=!0,attributionPosition:sr,proOptions:rs,defaultEdgeOptions:As,elevateNodesOnSelect:Ar=!0,elevateEdgesOnSelect:Rr=!1,disableKeyboardA11y:Rs=!1,autoPanOnConnect:ya=!0,autoPanOnNodeDrag:xt=!0,connectionRadius:wa=20,isValidConnection:Ms,onError:xa,style:rr,id:ar,nodeDragThreshold:Mr,...$s},hn)=>{const Lt=ar||"1";return me.createElement("div",{...$s,style:{...rr,...i9},ref:hn,className:dn(["react-flow",a]),"data-testid":"rf__wrapper",id:ar},me.createElement(M4,null,me.createElement(e9,{onInit:h,onMove:f,onMoveStart:p,onMoveEnd:m,onNodeClick:l,onEdgeClick:u,onNodeMouseEnter:x,onNodeMouseMove:C,onNodeMouseLeave:S,onNodeContextMenu:_,onNodeDoubleClick:$,nodeTypes:o,edgeTypes:i,connectionLineType:P,connectionLineStyle:I,connectionLineComponent:U,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:D,onSelectionStart:K,onSelectionEnd:V,onEdgeContextMenu:$t,onEdgeDoubleClick:Gt,onEdgeMouseEnter:nr,onEdgeMouseMove:_s,onEdgeMouseLeave:Hn,onReconnect:zn??ns,onReconnectStart:Me??Es,onReconnectEnd:qe??wn,reconnectRadius:Je??_t,defaultMarkerColor:$e,noDragClassName:Vn,noWheelClassName:xn,noPanClassName:Tr,elevateEdgesOnSelect:Rr,rfId:Lt,disableKeyboardA11y:Rs,nodeOrigin:ve,nodeExtent:Fe}),me.createElement(X7,{nodes:e,edges:t,defaultNodes:n,defaultEdges:s,onConnect:w,onConnectStart:b,onConnectEnd:k,onClickConnectStart:v,onClickConnectEnd:N,nodesDraggable:pe,nodesConnectable:Le,nodesFocusable:ge,edgesFocusable:je,edgesUpdatable:Ee,elementsSelectable:xe,elevateNodesOnSelect:Ar,minZoom:De,maxZoom:We,nodeExtent:Fe,onNodesChange:Nt,onEdgesChange:ss,snapToGrid:de,snapGrid:oe,connectionMode:H,translateExtent:Ke,connectOnClick:Ts,defaultEdgeOptions:As,fitView:vn,fitViewOptions:on,onNodesDelete:W,onEdgesDelete:B,onNodeDragStart:A,onNodeDrag:O,onNodeDragStop:M,onSelectionDrag:T,onSelectionDragStart:q,onSelectionDragStop:F,noPanClassName:Tr,nodeOrigin:ve,rfId:Lt,autoPanOnConnect:ya,autoPanOnNodeDrag:xt,onError:xa,connectionRadius:wa,isValidConnection:Ms,nodeDragThreshold:Mr}),me.createElement(K7,{onSelectionChange:R}),wt,me.createElement(k7,{proOptions:rs,position:sr}),me.createElement(tz,{rfId:Lt,disableKeyboardA11y:Rs})))});$4.displayName="ReactFlow";const l9=e=>({x:e.transform[0],y:e.transform[1],zoom:e.transform[2]});function L4(){return ht(l9,en)}const I4=({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:b,backgroundColor:k}=o||{},v=i||b||k;return me.createElement("rect",{className:dn(["react-flow__minimap-node",{selected:w},h]),x:t,y:n,rx:f,ry:f,width:s,height:a,fill:v,stroke:l,strokeWidth:u,shapeRendering:p,onClick:m?N=>m(N,e):void 0})};I4.displayName="MiniMapNode";var c9=g.memo(I4);const u9=e=>e.nodeOrigin,d9=e=>e.getNodes().filter(t=>!t.hidden&&t.width&&t.height),Vy=e=>e instanceof Function?e:()=>e;function h9({nodeStrokeColor:e="transparent",nodeColor:t="#e2e2e2",nodeClassName:n="",nodeBorderRadius:s=5,nodeStrokeWidth:a=2,nodeComponent:o=c9,onClick:i}){const l=ht(d9,en),u=ht(u9),h=Vy(t),f=Vy(e),p=Vy(n),m=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return me.createElement(me.Fragment,null,l.map(w=>{const{x:b,y:k}=ri(w,u).positionAbsolute;return me.createElement(o,{key:w.id,x:b,y:k,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 f9=g.memo(h9);const p9=200,m9=150,g9=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?S7(zp(t,e.nodeOrigin),n):n,rfId:e.rfId}},y9="react-flow__minimap-desc";function O4({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:b=!1,zoomable:k=!1,ariaLabel:v="React Flow mini map",inversePan:N=!1,zoomStep:x=10,offsetScale:C=5}){const S=Wt(),_=g.useRef(null),{boundingRect:$,viewBB:A,rfId:O}=ht(g9,en),M=(e==null?void 0:e.width)??p9,W=(e==null?void 0:e.height)??m9,B=$.width/M,R=$.height/W,q=Math.max(B,R),T=q*M,F=q*W,D=C*q,K=$.x-(T-$.width)/2-D,V=$.y-(F-$.height)/2-D,H=T+D*2,P=F+D*2,I=`${y9}-${O}`,U=g.useRef(0);U.current=q,g.useEffect(()=>{if(_.current){const X=ys(_.current),Y=te=>{const{transform:le,d3Selection:de,d3Zoom:oe}=S.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}=S.getState();if(te.sourceEvent.type!=="mousemove"||!de||!oe)return;const Le=U.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=aa.translate(ge.x,ge.y).scale(le[2]),Ee=oe.constrain()(je,ve,re);oe.transform(de,Ee)},Q=z3().on("zoom",b?J:null).on("zoom.wheel",k?Y:null);return X.call(Q),()=>{X.on("zoom",null)}}},[b,k,N,x]);const Z=m?X=>{const Y=Gs(X);m(X,{x:Y[0],y:Y[1]})}:void 0,z=w?(X,Y)=>{const J=S.getState().nodeInternals.get(Y);w(X,J)}:void 0;return me.createElement(Vj,{position:p,style:e,className:dn(["react-flow__minimap",t]),"data-testid":"rf__minimap"},me.createElement("svg",{width:M,height:W,viewBox:`${K} ${V} ${H} ${P}`,role:"img","aria-labelledby":I,ref:_,onClick:Z},v&&me.createElement("title",{id:I},v),me.createElement(f9,{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-D},${V-D}h${H+D*2}v${P+D*2}h${-H-D*2}z
57
- M${A.x},${A.y}h${A.width}v${A.height}h${-A.width}z`,fill:u,fillRule:"evenodd",stroke:h,strokeWidth:f,pointerEvents:"none"})))}O4.displayName="MiniMap";var w9=g.memo(O4);function x9(){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 v9(){return me.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},me.createElement("path",{d:"M0 0h32v4.2H0z"}))}function b9(){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 k9(){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 j9(){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 ms=({children:e,className:t,...n})=>me.createElement("button",{type:"button",className:dn(["react-flow__controls-button",t]),...n},e);ms.displayName="ControlButton";const N9=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),P4=({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,b]=g.useState(!1),{isInteractive:k,minZoomReached:v,maxZoomReached:N}=ht(N9,en),{zoomIn:x,zoomOut:C,fitView:S}=ec();if(g.useEffect(()=>{b(!0)},[]),!w)return null;const _=()=>{x(),o==null||o()},$=()=>{C(),i==null||i()},A=()=>{S(a),l==null||l()},O=()=>{m.setState({nodesDraggable:!k,nodesConnectable:!k,elementsSelectable:!k}),u==null||u(!k)};return me.createElement(Vj,{className:dn(["react-flow__controls",h]),position:p,style:e,"data-testid":"rf__controls"},t&&me.createElement(me.Fragment,null,me.createElement(ms,{onClick:_,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:N},me.createElement(x9,null)),me.createElement(ms,{onClick:$,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:v},me.createElement(v9,null))),n&&me.createElement(ms,{className:"react-flow__controls-fitview",onClick:A,title:"fit view","aria-label":"fit view"},me.createElement(b9,null)),s&&me.createElement(ms,{className:"react-flow__controls-interactive",onClick:O,title:"toggle interactivity","aria-label":"toggle interactivity"},k?me.createElement(j9,null):me.createElement(k9,null)),f)};P4.displayName="Controls";var S9=g.memo(P4),Xs;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Xs||(Xs={}));function C9({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 _9({color:e,radius:t}){return me.createElement("circle",{cx:t,cy:t,r:t,fill:e})}const E9={[Xs.Dots]:"#91919a",[Xs.Lines]:"#eee",[Xs.Cross]:"#e2e2e2"},T9={[Xs.Dots]:1,[Xs.Lines]:1,[Xs.Cross]:6},A9=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function D4({id:e,variant:t=Xs.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(A9,en),m=i||E9[t],w=s||T9[t],b=t===Xs.Dots,k=t===Xs.Cross,v=Array.isArray(n)?n:[n,n],N=[v[0]*f[2]||1,v[1]*f[2]||1],x=w*f[2],C=k?[x,x]:N,S=b?[x/o,x/o]:[C[0]/o,C[1]/o];return me.createElement("svg",{className:dn(["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(-${S[0]},-${S[1]})`},b?me.createElement(_9,{color:m,radius:x/o}):me.createElement(C9,{dimensions:C,color:m,lineWidth:a})),me.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${p+e})`}))}D4.displayName="Background";var R9=g.memo(D4);function M9(e,t){return e?t==="gone"?"entering":t==="leaving"?"here":t:t==="gone"?"gone":"leaving"}function Ja(e){return e!=="gone"}function zE(e,t){return e||Ja(t)}function VE(e,t){return!e&&Ja(t)}function Nl(e,t){const[n,s]=g.useState(()=>e?"here":"gone"),a=g.useRef(null);return g.useEffect(()=>{s(o=>M9(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 F4=.2,B4=1.6;function $9(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<F4||a>B4?null:{x:n,y:s,zoom:a}}function v1({durationMs:e,documentHidden:t,reducedMotion:n=md()}){return t||n?!1:Number.isFinite(e)&&e>0}function md(){return typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches}function rN(){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 pa(e,t){return`${e}::${t}`}function tc(e,t){return`${e}\0${t}`}const L9=/[0-9a-f]{16,}/i,I9=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function q4(e){return L9.test(e)||I9.test(e)}function O9(e){if(!e)return;const t=e.replace(/\\/g,"/").split("/").filter(Boolean);for(let n=t.length-1;n>=0;n--)if(!q4(t[n]))return t[n];return t[t.length-1]}function U4(){return{inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0}}function W4(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 Vp(e){const t=W4(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=Vp({...e.longContext,longContext:void 0})),n}function P9(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]=Vp(a);const o=D9(a.speeds);o&&(t[n].bySpeed=o)}return Object.keys(t).length?t:void 0}function D9(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,Vp(s)]);return t.length?Object.fromEntries(t):void 0}function H4(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),...W4(n)};for(const s of Object.values(n)){const a=H4(s,t+1);if(a)return a}return null}function aN(e){return O9(e)}function oN(e){const t=e.agent_type??e.subagent_type;return t&&!q4(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=aN(t.cwd))}function iN(e,t){e.label==="session"&&t.cwd&&(e.label=aN(t.cwd)??"session")}function z4(e,t){const n=oN(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:U4()},e.agents.set(a,o),o)}function V4(e,t,n,s){const a=pa(t,n),o=e.agents.get(a);return o?(pi(o,s),z4(o,s),o):null}function F9(e,t,n){var h;const s=t.session_id??"unknown",a=nc(t);if(a){const f=V4(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(pa(s,l));if(f)return pi(f,t),f}const u=uo(e,s,n,t.hook_event_name!=="SessionStart");return pi(u,t),iN(u,t),u}function B9(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 q9(e,t,n,s,a){const o=pa(t,n),i=uo(e,t,a,!0);let l=e.agents.get(o);if(l)return pi(l,s),z4(l,s),l;l={id:o,sessionId:t,label:oN(s),kind:"subagent",parentId:i.id,state:"active",startedAt:a,tools:[],prompts:[],cwd:s.cwd,cwdBasename:aN(s.cwd),toolCount:0,childCount:0,usage:U4()},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 U9(e,t,n){const s=e.activeSubagentStack.get(t)??[];s.includes(n)||(s.push(n),e.activeSubagentStack.set(t,s))}function G4(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 W9=new Set(["PreToolUse","PostToolUse","PostToolUseFailure","Stop","SubagentStop"]),K4=/^[a-z][a-z0-9_-]{0,23}$/i;function H9(e,t){if(t.provider==="codex")return;const n=t.effort&&typeof t.effort=="object"?t.effort.level:void 0;return typeof n=="string"&&K4.test(n)?n:W9.has(e)?null:void 0}function Y4(){return{msgsUser:0,msgsAssistant:0,toolUses:0,toolResults:0,systemReminders:0,currentContextTokens:0,memoryFiles:[]}}function lN(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"&&K4.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??Y4(),currentContextTokens:t.context_tokens})}}const z9=6e4,GE=64;function X4(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=pa(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 Z4(e,t,n){const s=t.context??null;if(s){const a=e.agents.get(n);if(a){const o=a.context??Y4(),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 J4(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 V9(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 Q4(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 G9=new Set(["working","blocked","done","failed","stopped"]);function eP(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"||!G9.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 K9(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<z9);l.push(o),i.outputs=l.length>GE?l.slice(-GE):l}e.revision+=1}}function cN(e,t,n){const s=t.usage??null;if(s){const a=e.agents.get(n);if(a){const o=Vp(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=P9(t.usageByModel))}}}function Jt(e,t){return Object.hasOwn(e,t)?e[t]:void 0}const Y9=/^\s*<task-notification>([\s\S]*?)<\/task-notification>/;function KE(e,t){var n;return((n=new RegExp(`<${t}>([\\s\\S]*?)</${t}>`).exec(e))==null?void 0:n[1].trim())||void 0}const X9={completed:"background task finished",failed:"background task failed",killed:"background task stopped"};function Gp(e){const t=Y9.exec(e);if(!t)return null;const n=KE(t[1],"status");return{label:(n?Jt(X9,n):void 0)??"background task update",detail:KE(t[1],"summary")}}function tP(e){return e.filter(t=>!Gp(t.text))}const YE=2e3;function Z9(e,t,n){for(let s=e.length-1;s>=0;s--){const a=e[s];if(a.at<t-YE)return!1;if(a.text===n&&a.at<=t+YE)return!0}return!1}function J9(e,t,n){if(Z9(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 ep=2e3;function Q9(e){const t=e.prompts[e.prompts.length-1];return t&&t.at>e.startedAt?t.at:e.startedAt}const XE=["B","KB","MB","GB","TB"];function Qn(e){if(e==null||!Number.isFinite(e)||e<0)return"—";if(e===0)return"0 B";let t=e,n=0;for(;n<XE.length-1&&Number(t.toFixed(1))>=1024;)t/=1024,n++;return`${t.toFixed(1)} ${XE[n]}`}const eV=60,tV=6e3,bs=e=>e!=null&&typeof e=="object"&&!Array.isArray(e),Zn=e=>typeof e=="string"?e:null;function nV(e){return bs(e)&&e.ccdeck_truncated===!0&&typeof e.chars=="number"&&Object.keys(e).length===2?e.chars:null}function Hl(e){const t=nV(e);if(t!=null)return`(too large to show — ${Qn(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(bs(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 sV(e){return e.lines??e.text.split(`
61
- `).map(t=>({text:t}))}function nP(e,t){if(t)return{shown:e,cut:!1};const n=[];let s=0;for(const a of e){if(n.length===eV)return{shown:n,cut:!0};const o=tV-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 rV(e,t){return nP(e,!1).cut?t?{label:"show less",expanded:!0}:{label:"show all",expanded:!1}:null}const Sn=(e,t,n=!1)=>({...e?{label:e}:{},text:t,...n?{err:!0}:{}}),Jn=(e,t)=>({label:e,text:t,inline:!0}),sP=(e,t)=>({label:e,text:t.map(n=>n.text).join(`
62
- `),lines:t});function aV(e,t){return[...e.split(`
63
- `).map(n=>({text:`- ${n}`,tone:"del"})),...t.split(`
64
- `).map(n=>({text:`+ ${n}`,tone:"add"}))]}function oV(e){if(!Array.isArray(e)||e.length===0)return null;const t=[];for(const n of e){if(!bs(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 ZE(e){if(typeof e=="string")return[Sn(void 0,e)];if(!bs(e))return[Sn(void 0,mi(e))];const t=[],n=Zn(e.type);n==="create"&&t.push(Jn("result","created the file"));const s=oV(e.structuredPatch);return s&&t.push(sP("applied",s)),e.userModified===!0&&t.push(Jn("note","the user changed it before it was applied")),t.length?t:[Jn("result",n==="update"?"updated the file":"done")]}function iV(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 lV(e){if(typeof e=="string")return[Sn(void 0,e)];const t=bs(e)&&bs(e.file)?e.file:null,n=Zn(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(Jn("lines",o>=i?`all ${i}`:Number.isFinite(l)?`${l}–${l+o-1} of ${i}`:`${o} of ${i}`)),a.push(Sn("content",n)),a}const s=bs(e)?Zn(e.type):null;return s&&s!=="text"?[Jn("result",`${/^[aeiou]/i.test(s)?"an":"a"} ${s} file`)]:[Sn(void 0,mi(e))]}function cV(e){if(typeof e=="string")return[Sn("output",e)];if(!bs(e))return[Sn(void 0,mi(e))];const t=Zn(e.stdout),n=Zn(e.stderr);if(t==null&&n==null)return[Sn(void 0,mi(e))];const s=[];return t&&s.push(Sn("output",t.replace(/\n$/,""))),n&&s.push(Sn("errors",n.replace(/\n$/,""),!0)),e.interrupted===!0&&s.push(Jn("note","interrupted before it finished")),s.length?s:[Jn("output","none")]}function uV(e,t,n){const s=Hl(t),a=Hl(n),o=bs(s)?s:null;if(o&&(e==="Edit"||e==="MultiEdit")){const i=Zn(o.file_path),l=(e==="MultiEdit"?Array.isArray(o.edits)?o.edits:[]:[o]).filter(bs).filter(u=>Zn(u.old_string)!=null&&Zn(u.new_string)!=null);if(i&&l.length){const u=[Jn("file",i)];return l.forEach((h,f)=>{const p=h.replace_all===!0?", every occurrence":"";u.push(sP(l.length>1?`change ${f+1}${p}`:`change${p}`,aV(h.old_string,h.new_string)))}),{input:u,response:ZE(a)}}}if(o&&e==="Write"){const i=Zn(o.file_path),l=Zn(o.content);if(i&&l!=null)return{input:[Jn("file",i),Sn("content",l)],response:ZE(a)}}if(o&&e==="Read"){const i=Zn(o.file_path);if(i){const l=iV(o);return{input:l?[Jn("file",i),Jn("lines",l)]:[Jn("file",i)],response:lV(a)}}}if(o&&e==="Bash"){const i=Zn(o.command);if(i!=null){const l=Zn(o.description);return{input:l?[Sn("command",i),Jn("why",l)]:[Sn("command",i)],response:cV(a)}}}return{input:[Sn(void 0,mi(s))],response:[Sn(void 0,mi(a))]}}function JE(e,t,n){const s=Hl(n);if(s==null)return"";if(typeof s=="string")return s;if(bs(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"&&bs(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 dV=new Set(["TodoWrite","update_plan"]),hV=new Set(["TaskCreate","TaskUpdate","TaskList","TaskGet"]);function xu(e){return e==="pending"||e==="in_progress"||e==="completed"?e:null}function gs(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 fV(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=gs(e==="TodoWrite"?l.content:l.step),h=xu(l.status);if(!u||!h)continue;const f=gs(l.activeForm??l.active_form);a.push(f?{text:u,status:h,active:f}:{text:u,status:h})}const o=e==="update_plan"?gs(n.explanation):"";return o?{items:a,note:o}:{items:a}}function za(e,t,n){return n?{items:e,at:t,note:n}:{items:e,at:t}}function pV(e,t,n,s){if(!t||!dV.has(t)||e.plan&&s<e.plan.at)return;const a=fV(t,n);a&&(e.plan=za(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):gs(t)}function mV(e,t,n,s,a){var k,v,N,x,C,S,_,$,A,O,M,W,B,R,q;if(!t||!hV.has(t))return;const o=Ko(n),i=Ko(s),l=((k=e.plan)==null?void 0:k.items)??[],u=T=>l.findIndex(F=>F.id===T);if(t==="TaskCreate"){const T=Ko(i==null?void 0:i.task),F=ll(T),D=gs(T==null?void 0:T.subject)||gs(o==null?void 0:o.subject);if(!F||!D)return;const K=gs((o==null?void 0:o.activeForm)??(o==null?void 0:o.active_form)),V=u(F),H={id:F,text:D,status:V>=0?l[V].status:"pending",...K?{active:K}:{}},P=l.slice();V>=0?P[V]=H:P.push(H),e.plan=za(P,Math.max(a,((v=e.plan)==null?void 0:v.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,D=u(T);if(F==="deleted"){if(D<0)return;e.plan=za(l.filter((Z,z)=>z!==D),Math.max(a,((x=e.plan)==null?void 0:x.at)??a),(C=e.plan)==null?void 0:C.note);return}const K=gs(o==null?void 0:o.subject),V=gs((o==null?void 0:o.activeForm)??(o==null?void 0:o.active_form)),H=xu(F)??xu((S=Ko(i==null?void 0:i.statusChange))==null?void 0:S.to);if(D<0){if(!K)return;const Z={id:T,text:K,status:H??"pending",...V?{active:V}:{}};e.plan=za([...l,Z],Math.max(a,((_=e.plan)==null?void 0:_.at)??a),($=e.plan)==null?void 0:$.note);return}const I={...l[D],...K?{text:K}:{},...H?{status:H}:{},...V?{active:V}:{}},U=l.slice();U[D]=I,e.plan=za(U,Math.max(a,((A=e.plan)==null?void 0:A.at)??a),(O=e.plan)==null?void 0:O.note);return}if(t==="TaskList"){if(!i||!Array.isArray(i.tasks)||e.plan&&a<e.plan.at)return;const T=[];for(const F of i.tasks){const D=Ko(F),K=ll(D),V=gs(D==null?void 0:D.subject),H=xu(D==null?void 0:D.status);if(!K||!V||!H)continue;const P=l.find(I=>I.id===K);T.push(P!=null&&P.active?{id:K,text:V,status:H,active:P.active}:{id:K,text:V,status:H})}e.plan=za(T,a,(M=e.plan)==null?void 0:M.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=za(l.filter((T,F)=>F!==p),Math.max(a,((W=e.plan)==null?void 0:W.at)??a),(B=e.plan)==null?void 0:B.note);return}const m=gs(h==null?void 0:h.subject),w=xu(h==null?void 0:h.status);if(!m&&!w)return;const b=l.slice();b[p]={...l[p],...m?{text:m}:{},...w?{status:w}:{}},e.plan=za(b,Math.max(a,((R=e.plan)==null?void 0:R.at)??a),(q=e.plan)==null?void 0:q.note)}function Cr(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 uN(e){const t=`${e.done}/${e.total}`;return e.allDone||!e.current?`${t} · done`:`${t} · ${e.next?"next: ":""}${e.current}`}function rP(e){const t=`plan ${e.done} of ${e.total} done`;return e.allDone||!e.current?t:`${t}, ${e.next?"next":"now"}: ${e.current}`}function Kp(e){return e.map(t=>`${t.status==="completed"?"✓":t.status==="in_progress"?"▸":"○"} ${t.text}`).join(`
66
- `)}function gV(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 QE=200;function aP(e,t,n){const s=t.ok===!1;t.ok=n,e&&s===n&&(e.toolErrorCount=(e.toolErrorCount??0)+(n?-1:1))}function oP(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 yV(e,t,n){var s;return((s=e.get(t))==null?void 0:s.tools.find(a=>a.id===n))??null}const iP=25;function lP(e,t){const n=t.tools;if(n.length>QE){const s=n.splice(0,n.length-QE);for(const a of s)uP(e,t,a)}for(let s=n.length-iP-1;s>=0;s--){const a=n[s];if(a.trimmed)break;a.input=void 0,a.response=void 0,a.trimmed=!0}}function wV(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 cP(e,t){for(const n of t.tools)uP(e,t,n)}function uP(e,t,n){const s=tc(t.sessionId,n.id);e.toolIndex.get(s)===n&&e.toolIndex.delete(s)}function xV(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),lP(e,n);for(let a=0;a<n.tools.length-iP;a++){const o=n.tools[a];o.trimmed||(o.input=void 0,o.response=void 0,o.trimmed=!0)}}}const vV="no result reached the deck — events were dropped while the deck was paused";function dP(e,t,n,s,a){n.endedAt=s,aP(t,n,!1),n.errorPreview=n.outcomeGap?vV:a,e.toolIndex.delete(tc(t.sessionId,n.id))}function bV(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 kV(e,t,n,s,a){const o=t.tool_use_id?wV(e,s,t.tool_use_id):null;if(o){if(t.tool_name&&o.name==="?"){o.name=t.tool_name;const h=oP(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?pa(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),lP(e,s),pV(s,u.name,t.tool_input,a)}function jV(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&&mV(f,t.tool_name??l.name,t.tool_input??l.input,t.tool_response,a)}l.outcomeGap=void 0,l.endedAt=a,aP(oP(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=H4(t.tool_response);h&&(l.usage=h),e.toolIndex.delete(i)}function NV(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 dN(e,t){e!=null&&e.stopFailure&&t>e.stopFailure.at&&(e.stopFailure=null)}function SV(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,dN(a,s),a.startedAt=Math.min(a.startedAt??s,s),pi(a,t),iN(a,t)}function CV(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,dN(a,s);const o=(typeof t.prompt=="string"?t.prompt:typeof t.message=="string"?t.message:"")??"";o&&J9(a.prompts,s,o)&&!a.firstPrompt&&!Gp(o)&&(a.firstPrompt=Vu(o,120))}function b1(e,t,n,s,a){const o=uo(e,n,s,!1),i=Q9(o);if(s<i)return;const l=o.lastTurnEndAt;if(!(l!=null&&i>l&&s<=l+ep)){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&&dP(e,u,h,s,"the turn ended before this call returned");t==="SessionEnd"&&(o.closedAt=s),e.activeSubagentStack.delete(n)}}function _V(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&&(b1(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),iN(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))),lN(e,t,s),cN(e,t,s)}function EV(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 TV=["us-gov","global","apac","us","eu","jp","au"],AV=new RegExp(`^(?:(?:${TV.join("|")})\\.)?anthropic\\.`,"i");function yr(e){return e.replace(AV,"")}const RV=/^(?:claude[-_]|gpt[-_]|o\d|codex[-_])/i,MV=new Set(["tool_input","tool_response"]);function hP(e,t=0){if(!e||typeof e!="object"||t>6)return null;const n=e;if(typeof n.model=="string"&&RV.test(yr(n.model)))return n.model;for(const[s,a]of Object.entries(n)){if(MV.has(s))continue;const o=hP(a,t+1);if(o)return o}return null}const $V=256,Rf={ModelObserved:X4,UsageObserved:cN,ContextObserved:Z4,SessionNamed:J4,ActivityObserved:Q4,JobObserved:eP},ta=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),Qh=e=>typeof e=="string"&&e.trim()!=="",LV=[["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]],IV=new Set(["working","blocked","done","failed","stopped"]),eT=e=>ta(e)&&typeof e.text=="string"&&e.text.trim()!==""&&Number.isFinite(e.at);function OV(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 LV)o(t[a])||s(a);switch(t.hook_event_name){case"ModelObserved":typeof t.model=="string"&&t.model!==""||s("model"),(ta(e.subagentModels)||ta(t.subagentModels))&&(n.subagentModels={...ta(e.subagentModels)?e.subagentModels:{},...ta(t.subagentModels)?t.subagentModels:{}});break;case"ContextObserved":{if(!ta(t.context)){s("context");break}const a=ta(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=Qh(t.sessionName)?t.sessionName:e.sessionName??null;let o=Qh(t.sessionTitle)?t.sessionTitle:e.sessionTitle??null;Qh(a)&&Qh(o)&&o.trim().toLowerCase()===a.trim().toLowerCase()&&(o=null),n.sessionName=a,n.sessionTitle=o;break}case"ActivityObserved":(!eT(t.activity)||eT(e.activity)&&t.activity.at<e.activity.at)&&s("activity");break;case"JobObserved":t.job===null||ta(t.job)&&IV.has(t.job.state)||s("job");break;case"UsageObserved":ta(t.usage)?t.usageByModel===void 0&&delete n.usageByModel:(s("usage"),s("usageByModel"));break}return n}function PV(e,t,n,s){if(!(t in Rf)||e.agents.has(s))return!1;const a=e.parkedEnrichment.get(s)??new Map,o=OV(a.get(t),n);for(a.delete(t),a.set(t,o),e.parkedEnrichment.delete(s),e.parkedEnrichment.set(s,a);e.parkedEnrichment.size>$V;){const i=e.parkedEnrichment.keys().next().value;if(i===void 0)break;e.parkedEnrichment.delete(i)}return!0}function DV(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)lN(e,o,t),(s=Rf[a])==null||s.call(Rf,e,o,t)}}function fP(e,t){e.parkedEnrichment.delete(t)}const FV="StopFailure",tT=Object.freeze({authentication_failed:"login",rate_limit:"usage-limit"});function BV(e){return typeof e=="string"&&Object.hasOwn(tT,e)?tT[e]:"api-error"}const qV=/^[a-z][a-z0-9_]{0,39}$/;function UV(e){const t=e==null?void 0:e.error;return typeof t=="string"&&qV.test(t)?t:"unknown"}const nT=160;function sT(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>nT?`${n.slice(0,nT-1).join("").trimEnd()}…`:t}function WV(e){return sT(e==null?void 0:e.last_assistant_message)||sT(e==null?void 0:e.error_details)}function HV(e,t){if(!e||typeof e!="object"||e.hook_event_name!==FV)return null;const n=UV(e);return{kind:BV(n),error:n,message:WV(e),at:t}}function zV(e,t,n,s){const a=nc(t);if(!a)return;const o=q9(e,n,a,t,s),i=oN(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<=ep,h=l!=null&&s-l<=ep;if(u||h){const f=h?l:o.endedAt;o.state="done",o.endedAt=f,o.startedAt=Math.min(o.startedAt,f),G4(e,n,a);return}o.state="active",o.startedAt=o.startedAt||s,o.exitAt=void 0,o.endedAt=void 0,U9(e,n,a)}function VV(e,t,n,s){const a=nc(t);if(!a)return;const o=V4(e,n,a,t);if(!o){for(const[i,l]of e.subagentTombstones)s-l>ep&&e.subagentTombstones.delete(i);e.subagentTombstones.set(pa(n,a),s);return}o.state="done",o.endedAt=Math.min(o.endedAt??s,s),G4(e,n,a)}const GV=["command","cmd","file_path","path","url","pattern","notebook_path"],rT=120,Gy=e=>e.length>rT?`${e.slice(0,rT-1)}…`:e;function KV(e){if(typeof e=="string")return e.trim()?Gy(e.trim()):null;if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e;for(const n of GV){const s=t[n];if(typeof s=="string"&&s.trim())return Gy(s.trim());if(Array.isArray(s)&&s.length>0&&s.every(a=>typeof a=="string")){const a=s.join(" ").trim();if(a)return Gy(a)}}return null}function YV(e){return e==="permission_prompt"?"permission":e==="agent_needs_input"?"asked":e==="idle_prompt"?"idle":null}const XV=new Set(["Notification","ModelObserved","ContextObserved","UsageObserved","SessionNamed","SessionRecapped","OutputObserved","ActivityObserved","JobObserved"]);function ZV(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 JV=3e4;function QV(e,t){if(!(!e||!e.name)&&!(t-e.startedAt>JV)&&!(e.startedAt>t))return{name:e.name,preview:KV(e.input)??""}}function eG(e,t,n,s,a){if(n!=="permission")return{kind:n,message:s,since:a};const o=ZV(e,t),i={kind:n,message:s,since:a};o!=null&&o.explicitSubagentId&&(i.subagentId=o.explicitSubagentId);const l=QV(o,a);return l&&(i.tool=l),i}function tG(e,t,n){if(e.kind==="idle")return!0;const s=nc(t);return s==null?!0:e.subagentId!=null&&pa(n,s)===e.subagentId}function nG(e,t,n,s){if(!XV.has(t)){const a=e.agents.get(s);a!=null&&a.waiting&&tG(a.waiting,n,s)&&(a.waiting=null)}}function sG(e,t,n,s){const a=YV(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)}:eG(e,n,a,i,s)}function Yp(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 gd(e,t){return t&&(e.revision+=1),t}function rG(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=Yp(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,b]of e.agents){if(b.parentId!=null){const k=h.get(b.parentId);k?k.push(w):h.set(b.parentId,[w])}o(b)&&!l.has(i.get(w))&&u.push({id:w,endedAt:b.endedAt})}if(u.length===0)return!1;u.sort((w,b)=>w.endedAt-b.endedAt);let f=0;const p=new Set,m=w=>{const b=e.agents.get(w);b&&(cP(e,b),e.agents.delete(w),b.kind==="root"&&fP(e,b.sessionId),p.add(b.sessionId),f++)};for(const w of u){if(e.agents.size<=n)break;if(!e.agents.has(w.id))continue;const b=[],k=new Set([w.id]),v=[...h.get(w.id)??[]];for(;v.length;){const N=v.pop();if(k.has(N))continue;k.add(N);const x=e.agents.get(N);x&&(b.push(x),v.push(...h.get(N)??[]))}if(!b.some(N=>!o(N))){for(const N of b.reverse())m(N.id);m(w.id)}}if(a&&p.size>0){const w=new Set;for(const b of e.agents.values())w.add(b.sessionId);for(const b of p)w.has(b)||a(b)}return gd(e,f>0)}function aG(e,t,n,s,a){const o=new Map;for(const[m,w]of e.agents){let b=o.get(w.sessionId);b||(b={ids:[],endedAt:0,live:!1,closed:!1},o.set(w.sessionId,b)),b.ids.push(m),w.kind==="root"&&w.closedAt!=null&&(b.closed=!0),w.state==="done"&&w.endedAt!=null?b.endedAt=Math.max(b.endedAt,w.endedAt):b.live=!0}const i=Yp(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 k of w.ids){const v=e.agents.get(k);v&&cP(e,v),e.agents.delete(k)}fP(e,m);const b=pa(m,"");for(const k of e.pendingSubagentModels.keys())k.startsWith(b)&&e.pendingSubagentModels.delete(k);a==null||a(m),f--,p=!0}return gd(e,p)}function oG(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 gd(e,t)}function iG(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&&(dP(e,a,l,u,"session ended before this call returned"),s=!0)}}return gd(e,s)}const aT=90*6e4;function lG(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 gd(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 pP(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{...rN(),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 _V(e,s,a),e;if(o==="CodexThreadLinked")return EV(e,s,a),e;const i=s.session_id??"unknown";if(nG(e,o,s,i),o!=="JobObserved"&&NV(e,i,a),lN(e,s,i),PV(e,o,s,i))return e;switch(o){case"ModelObserved":return X4(e,s,i),e;case"ContextObserved":return Z4(e,s,i),e;case"SessionNamed":return J4(e,s,i),e;case"SessionRecapped":return V9(e,s,i),e;case"ActivityObserved":return Q4(e,s,i),e;case"JobObserved":return eP(e,s,i),e;case"OutputObserved":return K9(e,s,i,a),e;case"UsageObserved":return cN(e,s,i),e}const l=F9(e,s,a),u=e.agents.get(i);u&&a>=(u.recoveryLiveAt??0)&&(u.recoveryLiveAt=a,u.restoredFromLog=void 0),DV(e,i),B9(e,o,s,i)&&xV(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=hP(s),f=nc(s),p=f?pa(i,f):i;h&&l.id===p&&(l.model=h);const m=H9(o,s);switch(m!==void 0&&l.id===p&&(l.effort=m??void 0),(o==="PreToolUse"||o==="PostToolUse"||o==="PostToolUseFailure")&&f==null&&dN(e.agents.get(i),a),o){case"SessionStart":SV(e,s,i,a);break;case"UserPromptSubmit":CV(e,s,i,a);break;case"PreToolUse":kV(e,s,i,l,a);break;case"PostToolUse":case"PostToolUseFailure":jV(e,s,o,i,a);break;case"SubagentStart":zV(e,s,i,a);break;case"SubagentStop":VV(e,s,i,a);break;case"Stop":case"StopFailure":b1(e,o,i,a,{stopFailure:HV(s,a)});break;case"SessionEnd":b1(e,o,i,a);break;case"Notification":sG(e,s,i,a);break}return e}const cG="codex-auto-review",mP="chatgpt-auto-review-free",uG={input:2,output:10,cacheRead:.2,cacheWrite:2.5,cacheWrite1h:4},dG=[{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:uG},{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}}],hG=[{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 gP(e){return e?/^(?:gpt[-_]|codex[-_]|o\d)/i.test(e):!1}function jr(e,t=Date.now(),n=da){if(!e)return null;if(e===cG&&n===mP)return{input:0,output:0,cacheRead:0,cacheWrite:0};if(n!==da&&gP(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:jr(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=fG.get(n);if(!s)return null;const a=yr(e);for(const o of s)if(o.match.test(a))return typeof o.rates=="function"?o.rates(t):o.rates;return null}const da="standard",fG=new Map([[da,dG],["fast",hG]]);function Tu(e,t){return e*t/1e6}function yP(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 wP(e,t,n=Date.now()){if(!gP(t))return e.inputTokens;const s=jr(t,n),a=((s==null?void 0:s.cacheWrite)??0)>0?Math.max(0,e.cacheCreateTokens):0;return Math.max(0,e.inputTokens-e.cacheReadTokens-a)}function Xp(e,t,n=Date.now()){const s={input:0,output:0,cacheRead:0,cacheWrite:0,total:0};for(const a of yd(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=jr(t,s,n);if(!a)return{input:0,output:0,cacheRead:0,cacheWrite:0,total:0};const o={input:0,output:0,cacheRead:0,cacheWrite:0,total:0};for(const i of xP(e,t)){const l=i.usage,u=vP(a,i.long);o.input+=Tu(wP(l,t,s),u.input),o.output+=Tu(l.outputTokens,u.output),o.cacheRead+=Tu(l.cacheReadTokens,u.cacheRead);const h=yP(l,u);o.cacheWrite+=h.usd5m+h.usd1h}return o.total=o.input+o.output+o.cacheRead+o.cacheWrite,o}function xP(e,t){if(!e.longContext||!/^claude[-_]haiku[-_]5[-_.]5\b(?![-_.]\d{1,7}(?!\d))/i.test(yr(t??"")))return[{usage:e,long:!1}];const n=e.longContext;return[{usage:hN(e,[n]),long:!1},{usage:n,long:!0}]}function vP(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 yd(e){const t=e.bySpeed?Object.entries(e.bySpeed):[];return t.length===0?[{speed:da,usage:e}]:[{speed:da,usage:hN(e,t.map(([,n])=>n))},...t.map(([n,s])=>({speed:n,usage:s}))]}function hN(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=hN(e.longContext,t.flatMap(o=>o.longContext?[o.longContext]:[]))),a}const ha="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 fN(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 k1(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=k1(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?k1(i,o):o)}n.bySpeed=Object.fromEntries(s)}return n}function pG(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=pG(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:k1(s[o].usage,a)}:s.push({model:e.model,usage:a})}return s}function Un(e,t=Date.now()){const n={input:0,output:0,cacheRead:0,cacheWrite:0,total:0};for(const s of sc(e)){const a=Xp(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 j1(e,t=Date.now()){return sc(e).every(n=>{const s=yd(n.usage).filter(({usage:a})=>a.inputTokens+a.outputTokens+a.cacheReadTokens+a.cacheCreateTokens+(a.cacheCreate1hTokens??0)+(a.cacheCreate5mTokens??0)>0);return s.length>0?s.every(a=>jr(n.model,t,a.speed)!==null):jr(n.model,t)!==null})}function zl(e,t=Date.now()){let n=0;for(const s of sc(e))for(const a of yd(s.usage))jr(s.model,t,a.speed)==null&&(n+=a.usage.inputTokens+a.usage.outputTokens);return n}function bP(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 pN(e){return bP(e).filter(t=>t!==e.model)}function oT(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
- `:"")+mG(e,t)}function mG(e,t){if(!e.bySpeed)return Ky(e,t,da);const n=yd(e).filter(s=>s.speed!==da||kP(s.usage));return n.length===1?Ky(n[0].usage,t,n[0].speed):[...n.map(s=>Ky(s.usage,t,s.speed)),"═════════════════════════════════════════",`all speeds = ${ct(Xp(e,t).total)}`].join(`
68
- `)}function kP(e){return e.inputTokens+e.outputTokens+e.cacheReadTokens+e.cacheCreateTokens>0}function Ky(e,t,n){const s=xP(e,t).filter(a=>kP(a.usage));return e.longContext&&s.some(a=>a.long)?[...s.map(a=>iT(a.usage,t,n,a.long)),`all context tiers = ${ct(Ku(e,t,n).total)}`].join(`
69
- `):iT(e,t,n,!1)}function iT(e,t,n,s){const a=jr(t,Date.now(),n),o=a?vP(a,s):null,i=s?" · prompt >100K":"",l=(n===mP?`model: ${t} · no charge for ChatGPT auto-review`:n===da?`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=k=>k.toLocaleString(),h=k=>`$${k}/MTok`,f=Ku(s?{...e,longContext:e}:{...e,longContext:void 0},t,n),p=yP(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=wP(e,t),b=w===e.inputTokens?"input":"uncached";return[l,`${b.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 lT(e){const t=sc(e),[n]=t;return t.length<=1?oT(n.usage,n.model):[...t.map(s=>oT(s.usage,s.model)),"═════════════════════════════════════════",`all models = ${ct(Un(e).total)}`].join(`
72
- `)}function gG(e){if(!e.model)return null;const t=jr(e.model),n=Un(e),s=zl(e);if(!t&&n.total<=0&&s>0)return e.usage.inputTokens+e.usage.outputTokens<=0?null:{kind:"unpriced",tt:lT(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?fN(n.total,a):null,i=lT(e)+(o?`
73
- burn: ${o}`:"");return{kind:"spent",total:n.total,floor:s>0,tt:i}}const yG=new Set(["untrusted","on-request","on-failure"]);function wG(e){return typeof e!="string"||!e?null:yG.has(e)?!0:e==="never"?!1:null}function jP(e){if(e.provider!=="codex"||e.kind!=="root"||e.waiting||e.state!=="active")return null;const t=wG(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 cT(e){return e[0].toUpperCase()+e.slice(1).toLowerCase()}function no(e){const t=yr(e).replace(/[-_]\d{8}(?!\d)/,""),n=t.match(/^claude[-_](opus|sonnet|haiku|fable|mythos)[-_](\d+(?:[-_.]\d+)*)/i);if(n){const a=cT(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(cT);return[`GPT-${a}`,...o].join(" ")}return e}function Zp(e){const t=yr(e??""),n=t.match(/^claude[-_](opus|sonnet|haiku|fable|mythos)[-_]/i);return n?n[1].toLowerCase():/^gpt[-_]/i.test(t)?"gpt":""}function Jp(e,t){return t?`${no(e)} · ${t}`:no(e)}function Yu(e,t){return t?`${e}
76
- effort: ${t}`:e}function xG(e){return!e.model&&e.provider!=="codex"?0:e.model&&e.effort?2:1}function vG(e,t){return(t.overflowing||t.folderCut)&&e<t.max?e+1:e}function bG(e){return{kind:e<1,effort:e<2}}function En(e){return(e==null?void 0:e.kind)==="permission"||(e==null?void 0:e.kind)==="asked"}function N1(e){const t=[];for(const n of e)n.kind==="root"&&En(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 kG(e,t){if(e.length===0)return null;const n=e.findIndex(s=>s.id===t);return e[(n+1)%e.length]}function jG(e){const t=new Set;for(const n of e)n.state==="active"&&t.add(n.sessionId);return t.size}function Qp(e,t){return`${e}@${t.since}`}function NP(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 NG(e){const t=e.message||"Needs your permission",n=NP(e,t);return n?`${t}
77
- Likely on: ${n}`:t}function SG(e,t,n,s=!0){if(!s)return[];if(n)return[];const a=[];for(const o of e){if(!En(o.waiting))continue;const i=Qp(o.id,o.waiting);t.has(i)||a.push({key:i,title:o.label,body:NG(o.waiting),sessionId:o.id})}return a}function CG(e,t,n){const s=new Set;for(const o of e)s.add(Qp(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 ef(e){return new Set(e.map(t=>Qp(t.id,t.waiting)))}function _G(e,t){return e!==t}function EG(e,t){return!e&&t!=null}function TG(e,t){return e!==null&&t!=null}function mN(e){switch(e){case"login":return"login expired";case"usage-limit":return"usage limit";default:return"API error"}}function SP(e){return`Stopped · ${mN(e.kind)}`}function CP(e){const t=mN(e.kind);return t.charAt(0).toUpperCase()+t.slice(1)}function gN(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 AG(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 RG(e){return e.message?`It said: “${e.message}”`:""}function MG(e,t=!1){return[AG(e),RG(e),gN(e.kind,t)].filter(Boolean).join(`
78
- `)}function $G(e,t=!1){return`${CP(e)}. ${gN(e.kind,t)}`}function LG(e){return`Claude Code's StopFailure hook${e!=null&&e.message?`: “${e.message}”`:""}`}function IG(e,t=!1){const n=gN(e.kind,t).replace(/\.$/,"");return`stopped, ${mN(e.kind)} — ${n.charAt(0).toLowerCase()}${n.slice(1)}`}function em(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 OG(e){return`${e} subagent${e===1?"":"s"} spawned`}function PG(e){const t=[em(e)];if(e.childCount>0&&t.push(`→ ${e.childCount}`),e.kind==="subagent"&&e.cwdBasename&&t.push(e.cwdBasename),e.model){const n=pN(e).length;t.push(`${no(e.model)}${n>0?` +${n}`:""}`)}else e.provider==="codex"&&t.push("Codex");return t.join(" · ")}function DG(e,t=Date.now(),n=!1){const s=e.toolErrorCount??0,a=Un(e,t).total;return[e.label,em(e),e.kind==="root"&&e.stopFailure?IG(e.stopFailure,e.job!=null):Vl(e.state),En(e.waiting)?Gl(e.waiting):null,e.model?no(e.model):null,(()=>{const o=Cr(e.plan);return o?rP(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 _P(e,t){const n=NP(e,t);return n?`Likely on: ${n}`:null}function tp(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 EP(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 tm(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 uT=2e5,FG=1e6,BG=[/\[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],qG=[{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 UG(e){if(!e)return uT;const t=yr(e);for(const n of BG)if(n.test(t))return FG;for(const n of qG)if(n.match.test(t))return n.window;return uT}function TP(e,t){return typeof e=="number"&&e>0?e:UG(t)}const WG=1;function HG(){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 rn=HG(),nm=e=>e==="Escape";function zG(e){return e.overlayOpen?"dismiss":e.typing?"blur":"clear-selection"}function dT(e){return String(e.tagName??"").toUpperCase()==="BODY"}function hT(e,t){return!e||!e.isConnected||dT(e)?!1:t==null||dT(t)}const np="a[href], button, input, select, textarea, summary, [tabindex]";function AP(e){return!e||e.disabled||e.rendered===!1?!1:(e.tabIndex??0)>=0}function VG(e){if(!e||!e.overflowing||e.hasFocusable)return!1;const t=String(e.overflow??"").toLowerCase();return t==="auto"||t==="scroll"}function GG({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 sm(e){return e.ctrlKey||e.metaKey||e.altKey}function KG(e){e.key!=="Escape"&&e.key!=="Tab"&&e.stopPropagation()}const YG=new Set(["button","checkbox","color","file","image","radio","range","reset","submit"]),XG=new Set(["INPUT","TEXTAREA","SELECT","OPTION","BUTTON","SUMMARY","A"]),ZG=new Set(["button","checkbox","combobox","link","listbox","menu","menubar","menuitem","menuitemcheckbox","menuitemradio","option","radio","searchbox","slider","spinbutton","switch","tab","textbox","treeitem"]);function rm(e){return typeof e.tagName=="string"?e.tagName.toUpperCase():""}function JG(e){return rm(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=rm(e);return t==="TEXTAREA"?!0:t!=="INPUT"?!1:!YG.has(String(e.type??"text").toLowerCase())}function RP(e,t){if(!e)return!1;if(ai(e))return!0;if(t!=null&&(t.length===1||t==="Delete")&&t!==" "&&e.pointerFocused&&JG(e))return!1;if(XG.has(rm(e)))return!0;const n=typeof e.role=="string"?e.role.trim().toLowerCase():"";return n!==""&&n.split(/\s+/).some(s=>ZG.has(s))}function QG({key:e,modalOpen:t,sheetOpen:n}){return t?!(e==="?"&&n):!1}function eK({key:e,sheetOpen:t,target:n}){return t&&e==="?"&&!ai(n)}function tK({target:e,modalOpen:t}){return t?ai(e)||e!=null&&rm(e)==="SELECT":RP(e,"t")}function wl({appModal:e,dialogDepth:t}){return e||t>0}function MP(e){return e?Array.from(e.querySelectorAll("*")).filter(t=>{if(t.matches(np))return AP({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)&&VG({overflowing:n,overflow:getComputedStyle(t).overflowY,hasFocusable:t.querySelector(np)!=null}):!1}):[]}function nK(e,t){const n=MP(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(()=>rn.push(f,a,i),[f,a,i]),g.useEffect(()=>{var m;const p=document.activeElement;return(m=(n==null?void 0:n.current)??MP(l.current)[0])==null||m.focus(),()=>{if(hT(p,document.activeElement)&&p.focus(),s&&document.activeElement===document.body){const w=s();hT(w,document.activeElement)&&w.focus()}}},[]),g.useEffect(()=>{const p=m=>{var x;if(m.key!=="Tab"||sm(m))return;const w=l.current;if(!w)return;const b=document.activeElement;if(!(b!=null&&w.contains(b))&&!rn.isTop(f))return;const v=nK(w,b),N=GG({count:v.length,index:b?v.indexOf(b):-1,shiftKey:m.shiftKey});N.kind!=="allow"&&(m.preventDefault(),N.kind==="focus"&&((x=v[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 sK(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 ps(e){return e.toLocaleString()}const rK=60;function aK(e,t=rK){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 oK({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=TP(e.contextWindow,e.model),h=Math.min(100,l/u*100),f=Un(e),p=e.provider==="codex"?i.inputTokens+i.outputTokens:i.inputTokens+i.outputTokens+i.cacheReadTokens+i.cacheCreateTokens,m=sK(e.provider);return r.jsx("div",{className:"modal-backdrop",...a,role:"presentation",children:r.jsxs("div",{ref:s,className:"modal ctx-modal",onClick:b=>b.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:[ps(l)," / ",ps(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(Hs,{label:"input tokens",val:ps(i.inputTokens)}),r.jsx(Hs,{label:"output tokens",val:ps(i.outputTokens)}),r.jsx(Hs,{label:"cache reads",val:ps(i.cacheReadTokens)}),r.jsx(Hs,{label:"cache writes",val:ps(i.cacheCreateTokens)}),r.jsx(Hs,{label:"cumulative total",val:ps(p)}),r.jsx(Hs,{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(Hs,{label:"user messages",val:ps((o==null?void 0:o.msgsUser)??0)}),r.jsx(Hs,{label:"assistant messages",val:ps((o==null?void 0:o.msgsAssistant)??0)}),r.jsx(Hs,{label:"tool uses",val:ps((o==null?void 0:o.toolUses)??0)}),r.jsx(Hs,{label:"tool results",val:ps((o==null?void 0:o.toolResults)??0)}),r.jsx(Hs,{label:"system-reminders",val:ps((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(b=>r.jsxs("li",{children:[r.jsx("span",{className:"ctx-md-path",title:b.path,children:aK(b.path)}),r.jsx("span",{className:"ctx-md-size",children:Qn(b.bytes)})]},b.path))})]})})}function Hs({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 iK({currentContextTokens:e,modelId:t,contextWindow:n,size:s=26,onClick:a}){const o=TP(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 fT=new Map;function $P(e){let t=fT.get(e);return t||(t={now:Date.now(),listeners:new Set,timer:null},fT.set(e,t)),t}function lK(e,t){const n=$P(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 cK(e){return $P(e).now}const pT=new Map,mT=new Map;function _r(e=1e3){let t=pT.get(e);t||(t=s=>lK(e,s),pT.set(e,t));let n=mT.get(e);return n||(n=()=>cK(e),mT.set(e,n)),g.useSyncExternalStore(t,n,n)}function uK(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 dK="1",gT="agent-dag.schema",hK=["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 ks(e){if(!(typeof window>"u"))try{window.localStorage.removeItem(e)}catch{}}function wr(){if(typeof window>"u")return null;try{return window.localStorage}catch{return null}}function fK(e,t=dK){let n=null;try{n=e.getItem(gT)}catch{return[]}if(n===t)return[];const s=[];if(n!==null)for(const a of hK)try{e.getItem(a)!==null&&(e.removeItem(a),s.push(a))}catch{}try{e.setItem(gT,t)}catch{}return s}const LP="agent-dag.recapsDismissed",yT=200;function pK(){const e=nt(LP);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(pK());const S1=new Set;let IP=0;function OP(e){return S1.add(e),()=>{S1.delete(e)}}function PP(e){Yl=e,IP++;const t=Array.from(e);st(LP,JSON.stringify(t.length>yT?t.slice(-yT):t));for(const n of S1)n()}function mK(e,t){return`${e}@${t}`}function gK(e){return Yl.has(e)}function yK(e){if(Yl.has(e))return;const t=new Set(Yl);t.add(e),PP(t)}function wK(e){const t=new Set(Yl);t.delete(e)||t.add(e),PP(t)}function xK(e){return g.useSyncExternalStore(OP,()=>e!=null&&Yl.has(e),()=>!1)}function yN(e){return`recap:${e}`}function vK(e){return e.startsWith("recap:")}function bK(){return g.useSyncExternalStore(OP,()=>IP,()=>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 kK(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 jK(e){let t=null;for(const n of e.prompts)(!t||n.at>t.at)&&(t=n);return t}const wT=160;function NK(e){const t=Gp(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>wT?s.slice(0,wT-1).trimEnd()+"…":s}function SK(e){const t=e.stopFailure;if(t)return{kind:"stopped",text:$G(t,e.job!=null),at:t.at,source:"stop",stop:t,key:`${e.sessionId}@stopped:${t.at}`};const n=jK(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?kK(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=NK(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 wN(e){if(e.kind!=="root"||e.closedAt!=null)return null;const t=SK(e);if((t==null?void 0:t.kind)==="stopped")return t;const n=uK(e),s=n?{kind:"recap",text:n.text,at:n.at,source:"recap",key:mK(e.sessionId,n.at)}:null;return t&&s?s.at>t.at?s:t:t??s}function DP(e){const t=wN(e);if(e.kind!=="root"||e.closedAt!=null)return null;const n=Cr(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 am(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 LG(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 CK(e){const t=new Map,n=[...e],s=Yp(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 FP(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 BP(e){return e.live>0?`→ ${e.total} · ${e.live} live`:`→ ${e.total} · done`}function _K(e,t,n){const s=e.kind==="root"?e.waiting:null;if(s&&En(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:SP(a),short:CP(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=Cr(e.plan);if(i&&i.current&&!i.allDone)return{tone:"muted",long:uN(i),short:`${i.done}/${i.total} done`}}if(t&&t.total>0)return{tone:"muted",long:FP(t),short:BP(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 EK(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 C1(e){return e==="active"?"live":e==="done"?"done":"err"}const om={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"}},TK=Object.fromEntries(Object.entries(om).map(([e,t])=>[e,t.category])),AK=Object.fromEntries(Object.entries(om).map(([e,t])=>[e,t.emoji])),RK=Object.fromEntries(Object.entries(om).map(([e,t])=>[e,t.label])),MK=new Set(Object.entries(om).filter(([,e])=>e.shell).map(([e])=>e)),$K={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",...TK};function qP(e){return e.startsWith("mcp__")?"mcp":Jt($K,e)??"other"}const LK=/\btools\.exec_command\s*\(\s*\{[^{}]*?\bcmd\s*:\s*(["'`])((?:\\.|(?!\1)[^\\])*)\1/,IK=/\btools\.([A-Za-z_$][\w$]*)\s*\(/;function OK(e){if(typeof e!="string"||!e)return null;const t=LK.exec(e);if(t){const s=PK(t[2]);if(s.trim())return s}const n=IK.exec(e);return n?n[1]:null}function PK(e){return e.replace(/\\(["'`\\nrt])/g,(t,n)=>n==="n"?`
81
- `:n==="r"?"\r":n==="t"?" ":n)}const DK={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:"📡",...AK};function xT(e){return e.startsWith("mcp__")?"🔌":Jt(DK,e)??"✨"}const FK={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 UP(e){return/^-(?:Command|c)$/i.test(e)||/^-[a-z]+c$/.test(e)}function WP(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=>UP(o)||/^-(?:NoProfile|NonInteractive)$/i.test(o)))return WP(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 BK(e){if(typeof e=="string")return e;if(!e||typeof e!="object")return null;const t=e;if(typeof t.script=="string"){const n=OK(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(UP);if(s>=0&&s+1<n.length)return n[s+1]}return n.join(" ")}return typeof t.script=="string"?t.script:null}const qK=new Set(["Bash","PowerShell",...MK]);function UK(e,t){if(!qK.has(e))return null;const n=BK(t);if(!n)return null;const s=WP(n);return s?{emoji:Jt(FK,s)??"⚙️",label:s,category:"shell",detail:n}:null}const WK=new Set(["Read","Write","Edit","MultiEdit","NotebookEdit","LS","Glob","apply_patch"]),HK={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:"🗄️"},zK={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 VK(e){const n=e.replace(/\\/g,"/").replace(/\/+$/,""),s=n.lastIndexOf("/");return s>=0?n.slice(s+1):n}function GK(e){const t=e.toLowerCase(),n=Jt(zK,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=Jt(HK,t.slice(s+1));if(a!==void 0)return a}return"📄"}function KK(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 YK(e,t){if(!WK.has(e))return null;const n=KK(e,t);if(!n)return null;const s=VK(n);return s?{emoji:e==="LS"?"📂":GK(s),label:s,category:"file",detail:n}:null}const XK={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 xN(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 ZK(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 HP(e){return Jt(XK,e.toLowerCase())}function JK(e,t){const n=xN(e);if(!n)return null;const{server:s,method:a}=n;if(!a)return null;const o=HP(s);return{emoji:(o==null?void 0:o.emoji)??"🔌",label:a,category:"mcp",detail:o?`${o.name} · ${a}`:`${s} · ${a}`}}function zP(e,t){return UK(e,t)??YK(e,t)??JK(e)}function QK(e,t){var n;return((n=zP(e,t))==null?void 0:n.label)??null}const eY=RK,vT=18;function tf(e){const t=[...e];return t.length<=vT?e:t.slice(0,vT-1).join("")+"…"}const Yy=13,tY=6;function nY(e,t){const n=[...e];if(n.length<=Yy)return e;const s=n.lastIndexOf("."),a=s>0?n.slice(s):[];return t==="file"&&a.length>1&&a.length<=tY?n.slice(0,Yy-1-a.length).join("")+"…"+a.join(""):n.slice(0,Yy-1).join("")+"…"}function vN(e){const t=xN(e);if(t){const s=HP(t.server);return s?{emoji:s.emoji,label:tf(s.name)}:{emoji:"🔌",label:tf(t.server),hue:ZK(t.server)}}const n=Jt(eY,e)??"";return n?{emoji:xT(e),label:tf(n)}:{emoji:xT(e),label:tf(e)}}function sY(e){let t=null,n="";for(const s of e){const a=xN(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:vN(n)}const _1=6e4,Ll=24,bT=_1/Ll,Xy=132,Mf=14;function rY(e,t,n){const s=new Array(Ll).fill(0);let a=0;const o=m=>{const w=n-m;if(w<0||w>=_1)return;const b=Ll-1-Math.floor(w/bT);b>=0&&b<Ll&&(s[b]+=1,a+=1)};for(const m of e)o(m.startedAt);for(const m of t??[])o(m);const l=Math.max(0,...s)/(bT/1e3),u=e.filter(m=>n-m.startedAt>=0&&n-m.startedAt<_1).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 aY=2;function oY(e){return e===0?1.5:Math.max(1.5,Math.min(1,e/aY)*Mf)}function VP({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 bN(){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 GP(){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 sp({recap:e}){return e?r.jsx(GP,{}):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 im(e){return e==null}const E1="self";function Bn(e,t=!1){const n=so(e?E1:null,E1);return{disabled:t||n.disabled,"aria-busy":n.busy}}function Cn(e){return im(e?E1: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 KP(e){return[...e==null?[]:[`#ap-more-${e}`],".accounts-panel .ap-refresh"]}function Wn(e){return e==null||e==="BODY"||e==="HTML"}const YP="Continue from where you left off.";function iY(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 XP(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 rp(e){return XP(Math.floor(e/1e3))}function wd(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 lY(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function ap(e,t,n){const s=new Date(e),a=rp(t-e);return{label:lY(s,new Date(t))?a:`${a} · ${s.toLocaleDateString(n,{month:"short",day:"numeric"})}`,title:s.toLocaleString(n,{dateStyle:"medium",timeStyle:"medium"})}}function kN(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 cY(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 jN(e,t){const n=rp(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 op(e){if(!e.ok)return cY(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: “${YP}”${n}`}function ZP({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 uY(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 dY(e,t){return[`claude stop ${e}`,`claude --resume ${t} --bg "${YP}"`].join(`
83
- `)}let to={answer:null,pressing:new Set,pressed:{}};const Zy={current:new Set},T1=new Set;function A1(e){to={...to,...e};for(const t of T1)t()}const hY=e=>(T1.add(e),()=>{T1.delete(e)}),kT=()=>to;function NN(){return g.useSyncExternalStore(hY,kT,kT)}const fY=new Set(["login","usage-limit","api-error"]),SN=e=>typeof e=="number"&&Number.isFinite(e)?e:null,JP=e=>typeof e=="string"?e:"";function pY(e){if(!e||typeof e!="object")return null;const t=e,n=SN(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:JP(t.detail),stopped:t.stopped===!0}}function mY(e){if(!e||typeof e!="object")return null;const t=e;return{ok:t.ok===!0,at:SN(t.at)??0,room:typeof t.room=="boolean"?t.room:null}}function gY(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&&fY.has(u.kind)&&SN(u.at)!=null?{kind:u.kind,at:u.at}:null;s[o]={stop:h,held:l.held===!0,tried:l.tried===!0,last:pY(l.last)}}return{auto:n.auto===!0,login:t?mY(n.login):null,withLogin:t,sessions:s}}async function $f(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=gY(await s.json(),e);if(!a)return;const o=e?a.login:((t=to.answer)==null?void 0:t.login)??null;A1({answer:{...a,login:o,withLogin:e||(((n=to.answer)==null?void 0:n.withLogin)??!1)}})}catch{}}async function yY(e,t){if(!Cn(Zy.current.has(e)))return null;Zy.current.add(e),A1({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"?kN((o==null?void 0:o.gate)??null):JP(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}}Zy.current.delete(e);const s=new Set(to.pressing);return s.delete(e),A1({pressing:s,pressed:{...to.pressed,[e]:n}}),$f(!0),n}const QP=30*6e4;function CN(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:iY(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 wY=15e3,xY=2*6e4;function vY(e){for(const t of e.agents.values())if(t.kind==="root"&&t.stopFailure)return!0;return!1}function bY({stateRef:e,now:t,enabled:n}){const s=g.useRef(0);n&&vY(e.current)&&(s.current=t);const a=n&&s.current>0&&t-s.current<xY;g.useEffect(()=>{n&&$f(!1)},[n]),g.useEffect(()=>{if(!a)return;$f(!0);const o=window.setInterval(()=>{$f(!0)},wY);return()=>window.clearInterval(o)},[a])}function eD(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.":kN(e.gate.reason):"Checking for a working login…",e.stop?ZP({auto:e.auto,kind:e.stop.kind,held:e.held,tried:e.tried}):"",e.last&&e.stop&&e.last.at>=e.stop.at?`${jN(e.last,t)}. ${op(e.last)}`:""].filter(Boolean).join(`
84
- `)}function tD(e,t){return g.useCallback(()=>{!(e!=null&&e.stop)||!e.gate.ready||e.pressing||yY(t,e.stop)},[e,t])}function kY({data:e}){const t=NN(),n=_r(15e3),s=CN(e,t),a=tD(s,e.sessionId);return!(s!=null&&s.stop)||!s.background?null:r.jsx("button",{type:"button",className:"stop-continue",...Bn(s.pressing,!(s.loaded&&s.gate.ready)),title:eD(s,n),onClick:o=>{o.stopPropagation(),a()},children:s.pressing?"Continuing…":"Continue"})}function jY({data:e}){const t=NN(),n=_r(15e3),s=CN(e,t);return!s||s.stop||!s.last||n-s.last.at>QP?null:r.jsxs("div",{className:`continued-row${s.last.ok?"":" failed"}`,title:op(s.last),children:[r.jsx("span",{className:"waiting-dot","aria-hidden":!0}),r.jsx("span",{className:"continued-said",children:jN(s.last,n)})]})}function NY({agent:e}){const t=NN(),n=_r(15e3),s=CN(e,t),a=tD(s,e.sessionId),[o,i]=g.useState(null),l=g.useCallback(async(m,w)=>{await ho(w)&&(i(m),window.setTimeout(()=>i(b=>b===m?null:b),1600))},[]);if(!s)return null;const u=s.last&&(!s.stop||s.last.at>=s.stop.at)&&n-s.last.at<=QP?r.jsxs("p",{className:`detail-continue-last${s.last.ok?"":" failed"}`,title:op(s.last),children:[jN(s.last,n),". ",op(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.":kN(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:uY(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=ZP({auto:s.auto,kind:s.stop.kind,held:s.held,tried:s.tried}),p=s.jobId?dY(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",...Bn(s.pressing,!(s.loaded&&s.gate.ready)),title:eD(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 jT=typeof window>"u"?g.useEffect:g.useLayoutEffect;function SY({data:e}){var B,R;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=pN(e),f=g.useRef(null),p=g.useRef(null),m=xG(e),[w,b]=g.useState(0),[k,v]=g.useState(null);jT(()=>{b(0)},[e.effort,e.model,h.length,e.cwdBasename,e.childCount,e.kind,m,k]),jT(()=>{const q=f.current;if(!q||w>=m)return;const T=p.current,F=vG(w,{overflowing:q.scrollWidth>q.clientWidth,folderCut:!!T&&T.scrollWidth>T.clientWidth,max:m});F!==w&&b(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,vt.flushSync(()=>v(T)))});return F.observe(q),()=>F.disconnect()},[]);const N=bG(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)),C=tm(e.sessionName,e.sessionTitle),S=DP(e),_=(S==null?void 0:S.note)??null,$=S?S.key:null,A=xK($),O=S!=null&&!A,M=(_==null?void 0:_.kind)==="recap",W=gG(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(AY,{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:"?"}),S&&$&&r.jsx("button",{type:"button",className:"glyph-btn recap-pin","aria-label":M?"Claude Code's recap":_?`Session note: ${rc(_.kind)}`:"Session note: plan","aria-expanded":O,title:M?O?"Hide the recap":"Show Claude Code's recap":_?O?"Hide this note":"Show what this session is doing":O?"Hide the plan":"Show the plan",onClick:q=>{q.stopPropagation(),wK($)},children:r.jsx(sp,{recap:M})})]}),r.jsx("div",{className:"head-right",children:l&&e.onOpenContext&&r.jsx(iK,{currentContextTokens:i,modelId:e.model,contextWindow:e.contextWindow,onClick:()=>e.onOpenContext(e.sessionId)})})]}),r.jsxs("div",{className:"sub",title:PG(e),children:[r.jsxs("span",{className:"sub-details",ref:f,children:[N.kind&&r.jsx("span",{children:em(e)}),e.childCount>0&&r.jsxs("span",{className:"spawn-badge",title:OG(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":Zp(e.model),title:x,children:[Jp(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(TY,{start:e.startedAt,end:e.endedAt})]})]}),e.kind==="root"&&C.face&&r.jsx("div",{className:"session-name",title:C.tooltip,children:C.face}),e.kind==="root"&&e.stopFailure&&r.jsx(RY,{data:e,stop:e.stopFailure}),e.kind==="root"&&!e.stopFailure&&r.jsx(jY,{data:e}),e.waiting&&!(e.stopFailure&&e.waiting.kind==="idle")&&r.jsx(MY,{waiting:e.waiting}),(()=>{const q=jP(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=Cr(e.plan);return q&&e.plan?r.jsx(_Y,{plan:q,items:e.plan.items}):null})(),(e.tools.length>0||(((R=e.outputs)==null?void 0:R.length)??0)>0)&&r.jsx($Y,{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"]}),(W==null?void 0:W.kind)==="unpriced"&&r.jsx("span",{className:"cost-unpriced",title:W.tt,children:ha}),(W==null?void 0:W.kind)==="spent"&&r.jsx("span",{className:"cost-meta",title:W.tt,children:r.jsxs("b",{children:[ct(W.total),W.floor?"+":""]})})]}),r.jsx(EY,{data:e,title:e.kind==="root"?C.face:void 0}),r.jsx(fi,{type:"source",position:Ye.Right,style:{background:"transparent",border:"none"}})]})}const CY=g.memo(SY);function _Y({plan:e,items:t}){return r.jsxs("div",{className:e.allDone?"plan-row plan-done":"plan-row",title:Kp(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 EY({data:e,title:t}){const n=e.kind==="root"&&En(e.waiting),s=_K(e,e.branch,{sayWaiting:tp,describeCall:a=>({name:vN(a.name).label,subject:QK(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(VP,{kind:C1($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(bN,{})]}),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 TY({start:e,end:t}){const n=_r(1e3);return r.jsx(r.Fragment,{children:Kl(e,t,n)})}function AY({state:e}){return r.jsx("span",{className:`state-pill state-${e}`,children:Vl(e)})}function RY({data:e,stop:t}){return r.jsxs("div",{className:"stop-row",title:MG(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:SP(t)}),r.jsx(kY,{data:e})]})}function MY({waiting:e}){const t=_r(1e3),n=En(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:tp(e)}),r.jsx("b",{children:Kl(e.since,void 0,t)})]})}function $Y({tools:e,outputs:t}){const n=_r(1e3),{counts:s,title:a}=rY(e,t,n),o=Xy/Ll;return r.jsxs("div",{className:"tool-spark-row",title:a,children:[r.jsx("svg",{className:"tool-spark",width:Xy,height:Mf,viewBox:`0 0 ${Xy} ${Mf}`,"aria-hidden":!0,children:s.map((i,l)=>{const u=oY(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:Mf-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 LY({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 _N="agent-dag.single-key-shortcuts";function nD(e){return e!=="0"}function sD(e){return e.length===1}function IY(e,t){return!t&&sD(e)}function _n(e,t,n){return n?`${e} (${t})`:e}let oi=null;const vu=new Set;function rD(){for(const e of vu)e()}function R1(){return oi===null&&(oi=nD(nt(_N))),oi}function OY(e){oi!==e&&(oi=e,st(_N,e?"1":"0"),rD())}function NT(e){if(e.key!==_N)return;const t=nD(e.newValue);t!==oi&&(oi=t,rD())}function PY(e){var t;return vu.add(e),vu.size===1&&typeof window<"u"&&((t=window.addEventListener)==null||t.call(window,"storage",NT)),()=>{var n;vu.delete(e),vu.size===0&&typeof window<"u"&&((n=window.removeEventListener)==null||n.call(window,"storage",NT))}}function ip(e){const t=Math.max(0,Math.floor(e));return`${t} event${t===1?"":"s"}`}const ST=99;function DY(e){const t=Math.max(0,Math.floor(e));return t>ST?`${ST}+`:String(t)}const FY="Pause the canvas";function BY(e){const t=e.singleKeys??!0;if(!e.paused)return _n("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?_n(`The pause is full — ${ip(e.held)} held and ${n} older ${n===1?"one":"ones"} already dropped. Resume to follow the canvas again`,"Space",t):e.held<=0?_n("Nothing has arrived since you paused. Resume to follow the canvas again","Space",t):_n(`${ip(e.held)} arrived while paused and will be applied in order when you resume`,"Space",t)}function qY(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 aD="paused · full",UY=(e,t)=>t>0?aD:e>0?`paused · ${DY(e)}`:"paused";function WY(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:UY(e.held,t),widest:aD,title:_n(t>0?`Connected — the pause is full at ${ip(e.held)}; the oldest are being dropped as new ones arrive. Resume to catch up`:e.held>0?`Connected — ${ip(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 An(){return g.useSyncExternalStore(PY,R1,R1)}const HY=e=>e.transform[2]>=e.maxZoom,zY=e=>e.transform[2]<=e.minZoom;function VY({autoFitDisabled:e,enableAutoFitAndRefit:t,paused:n,pauseGate:s,togglePause:a,handleRelayout:o,requestClear:i,setKeyHelpOpen:l}){const u=ec(),h=ht(HY),f=ht(zY),p=An();return r.jsxs(S9,{showInteractive:!1,showFitView:!1,showZoom:!1,children:[r.jsx(ms,{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(ms,{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(ms,{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(ms,{"data-group-start":"",onClick:a,title:BY({paused:n,held:s.size,dropped:s.dropped,singleKeys:p}),"aria-label":FY,"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(ms,{onClick:o,title:_n("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(ms,{"data-group-start":"","data-danger":"",onClick:()=>i("button"),title:_n("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(ms,{"data-group-start":"",onClick:()=>l(m=>!m),title:p?_n("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 GY="modulepreload",KY=function(e){return"/"+e},CT={},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=KY(h),h in CT)return;CT[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":GY,f||(m.as="script"),m.crossOrigin="",m.href=h,u&&m.setAttribute("nonce",u),document.head.appendChild(m),f)return new Promise((w,b)=>{m.addEventListener("load",w),m.addEventListener("error",()=>b(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)})},_T="agent-dag.fm-custom-stations",ET="agent-dag.fm-muted",M1="custom:",YY=/^UC[A-Za-z0-9_-]{22}$/,XY=/^[A-Za-z0-9_-]{11}$/,oD=/^[A-Za-z0-9_-]{1,80}$/,ZY=/\.(mp3|aac|ogg)$/i,JY=/\.m3u8$/i,QY=2048,iD=80;function Xl(e){return`${M1}${e}`}function lm(e){if(!e.startsWith(M1))return null;const t=e.slice(M1.length);return oD.test(t)?t:null}function TT(e){return lm(e)??e}function EN(e){var i,l;const t=e.trim();if(t.length>QY)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&&YY.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(XY.test(f))return{kind:"youtube-video",url:s,video:f}}return null}return JY.test(n.pathname)?{kind:"direct-audio",url:s,format:"hls"}:ZY.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 eX(e){return e==="1"}function tX(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=EN(l);if(!oD.test(o)||n.has(o)||!i||i.length>iD||!u)continue;n.add(o);const h=lD(a.radio);s.push({id:o,name:i,url:u.url,...h?{radio:h}:{}})}return s}function nX(e,t,n){const s=lm(e??"");return s&&t.some(a=>a.id===s)?Xl(s):n(e)}function sX(e,t){return e===Xl(t)?"claude-fm":e}function lD(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 $1="https://www.youtube-nocookie.com";function rX(e,t,n){const s=new URLSearchParams({...n?{}:{channel:e},enablejsapi:"1",autoplay:"1",playsinline:"1",rel:"0",modestbranding:"1",origin:t});return`${$1}/embed/${n?encodeURIComponent(n):"live_stream"}?${s.toString()}`}function cl(e,t=[]){return JSON.stringify({event:"command",func:e,args:t})}function aX(e="claude-fm"){return JSON.stringify({event:"listening",id:e,channel:"widget"})}const oX=[1],iX=[0,2],lX=[2,5,100,101,150,153];function cX(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:oX.includes(a)?{kind:"playing",playing:!0}:a===3?{kind:"buffering"}:iX.includes(a)?{kind:"playing",playing:!1}:null}return null}const ou=new Set;let AT="";function RT(e){const t=new Date().toISOString().slice(0,10);if(t!==AT&&(ou.clear(),AT=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 MT=864e5,uX=6e4;function an(e,t=!0){g.useEffect(()=>{if(!t)return;RT(e);let n;const s=()=>{n=setTimeout(()=>{RT(e),s()},MT-Date.now()%MT+uX)};return s(),()=>clearTimeout(n)},[e,t])}const dX={"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 hX({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),[b,k]=g.useState(!1),[v,N]=g.useState(!1);an("claude-fm",b);const x=g.useRef(o),C=g.useRef(null),S=g.useRef(null),_=g.useRef(void 0),$=g.useRef(null),A=g.useCallback(()=>{var F;clearTimeout(_.current),(F=S.current)==null||F.destroy(),S.current=null;const T=C.current;T&&(T.pause(),T.removeAttribute("src"),T.load(),C.current=null)},[]),O=g.useCallback(T=>{var F,D;(D=(F=$.current)==null?void 0:F.contentWindow)==null||D.postMessage(T,$1)},[]),M=g.useRef(n);M.current=n;const W=g.useRef(s);W.current=s;const B=g.useCallback((T,F,D)=>{A();const K=new Audio;K.preload="none",K.volume=M.current/100,K.muted=W.current,C.current=K,w(!0),k(!1),N(!1);let V=!1;const H=()=>C.current===K,P=()=>{clearTimeout(_.current),A(),w(!1),k(!1),N(!1)},I=()=>{H()&&(P(),p(!0),l==null||l(D,!0))},U=z=>{if(H()&&!(z instanceof DOMException&&z.name==="AbortError")){if(z instanceof DOMException&&z.name==="NotAllowedError"){P();return}I()}};_.current=setTimeout(()=>{H()&&!V&&I()},15e3),K.addEventListener("playing",()=>{H()&&(clearTimeout(_.current),V=!0,k(!0),N(!1),l==null||l(D,!1))});const Z=()=>{H()&&(k(!1),N(V),clearTimeout(_.current),_.current=setTimeout(()=>{H()&&I()},15e3))};K.addEventListener("waiting",Z),K.addEventListener("stalled",Z),K.addEventListener("ended",()=>{H()&&P()}),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;S.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(U)}),X.attachMedia(K)},I):(K.src=T,K.play().catch(U))},[l,A]);g.useEffect(()=>{m&&(O(cl("setVolume",[n])),O(cl(s?"mute":"unMute")),C.current&&(C.current.volume=n/100,C.current.muted=s))},[n,s,m,O]),g.useEffect(()=>{var P;let T=!0;const F=e??fetch,D=x.current!==o;if(x.current=o,h(null),p(!1),N(!1),w(D),k(!1),A(),!t){w(!1),k(!1);return}const K=i&&Xl(i.id)===a?EN(i.url):null;if(K){if(K.kind==="direct-audio"){const I=K.format==="hls"||((P=i==null?void 0:i.radio)==null?void 0:P.hls)===!0;return h({live:!0,channel:"",audio:K.url,hls:I}),l==null||l(a,!1),D&&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),k(!1),N(!1),l==null||l(a,!0)))}).catch(()=>{T&&(p(!0),w(!1),k(!1),N(!1),l==null||l(a,!0))}),()=>{T=!1}}if(lm(a))return p(!0),l==null||l(a,!0),()=>{T=!1};const V=a,H=dX[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),k(!1)),l==null||l(a,!(I!=null&&I.video)))}).catch(()=>{T&&(p(!0),w(!1),k(!1),l==null||l(a,!0))});else if(V!=="claude-fm"){const I=V.replace("lofi-","");F(`/api/lofi-girl?station=${encodeURIComponent(I)}`).then(U=>U.ok?U.json():null).then(U=>{T&&(U!=null&&U.video&&h({live:!0,channel:"",video:U.video}),U!=null&&U.video||(p(!0),w(!1),k(!1)),l==null||l(a,!(U!=null&&U.video)))}).catch(()=>{T&&(p(!0),w(!1),k(!1),l==null||l(a,!0))})}else F("/api/claude-fm").then(I=>I.ok?I.json():null).then(I=>{if(!T)return;const U=!!(I!=null&&I.live&&(I!=null&&I.channel));U&&h({live:!0,channel:I.channel}),U||(p(!0),w(!1),k(!1)),l==null||l(a,!U)}).catch(()=>{T&&(p(!0),w(!1),k(!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,A]),g.useEffect(()=>()=>A(),[A]),g.useEffect(()=>{if(!m||u!=null&&u.audio)return;let T;const F=()=>{clearTimeout(T),T=void 0,w(!1),k(!1),N(!1),p(!0),l==null||l(a,!0)},D=()=>{T??(T=setTimeout(F,15e3))};D();const K=V=>{var P;if(V.origin!==$1||V.source!==((P=$.current)==null?void 0:P.contentWindow))return;const H=cX(V.data);if(H){if(H.kind==="ready"){O(cl("setVolume",[M.current])),O(cl(W.current?"mute":"unMute")),O(cl("playVideo"));return}if(H.kind==="blocked"){clearTimeout(T),T=void 0,w(!1),k(!1),N(!1);return}if(H.kind==="buffering"){k(!1),N(!0),D();return}if(H.kind==="playing"){clearTimeout(T),T=void 0,k(H.playing),N(!1),H.playing||w(!1);return}lX.includes(H.code)&&F()}};return window.addEventListener("message",K),()=>{clearTimeout(T),window.removeEventListener("message",K)}},[m,u==null?void 0:u.audio,o,l,O,a]);const R=g.useCallback(()=>{if(u){if(u.audio){if(m){A(),w(!1),k(!1),N(!1);return}B(u.audio,u.hls===!0,a);return}if(!m){w(!0),k(!1),N(!1);return}O(cl("pauseVideo")),w(!1),k(!1),N(!1)}},[u,m,b,a,O,B,A]);return g.useMemo(()=>({probe:u,dead:f,armed:m,playing:b,buffering:v,frame:$,say:O,press:R}),[u,f,m,b,v,O,R])}const $T="agent-dag.radio-favorites",LT="agent-dag.radio-recent",IT="agent-dag.radio-catalogue";function fX(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"?EN(s.url):null,l=lD(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 OT(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 pX(e,t){return[t,...e.filter(n=>n!==t)].slice(0,50)}function rje(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 aje(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 cD(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 oje(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 ije(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 mX(){const[e,t]=g.useState(()=>OT(nt($T))),[n,s]=g.useState(()=>OT(nt(LT))),[a,o]=g.useState(()=>{try{return fX(JSON.parse(nt(IT)??"[]"))}catch{return[]}});g.useEffect(()=>{st($T,JSON.stringify(e))},[e]),g.useEffect(()=>{st(LT,JSON.stringify(n))},[n]);const i=g.useCallback(h=>s(f=>pX(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(IT,JSON.stringify(h))},[]);return{favorites:e,recent:n,catalogue:a,remember:i,toggleFavorite:l,updateCatalogue:u}}function gX(e,t,n,s){const a=cD(e,t,n);if(!a)return()=>{};const o=setTimeout(()=>{n.add(t),s(a)},1e3);return()=>clearTimeout(o)}const cm=148,PT=6e3,yX=16e3,uD=46,Qa=34;function wX(e,t,n=cm){let s=-Math.round(t()*n);if(Math.abs(s-e)<Qa){const a=e-Qa>=-n?-Qa:Qa;s=Math.max(-n,Math.min(0,Math.round(e+a)))}return{to:s,ms:Math.round(Math.abs(s-e)*uD)}}function xX(e){return Math.round(PT+e()*(yX-PT))}const DT=[{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 vX(e){const t=DT.reduce((s,a)=>s+a.weight,0);let n=e()*t;for(const s of DT)if(n-=s.weight,n<0)return s.kind;return"stroll"}const bX=720,kX=260,jX=620,NX=220,FT=520,dD=1600,BT=7e3,SX=15e3,qT=6e3,CX=14e3;function ul(e,t,n=cm){let s=-Math.round(t()*n);if(Math.abs(s-e)<Qa){const a=e-Qa>=-n?-Qa:Qa;s=Math.max(-n,Math.min(0,Math.round(e+a)))}return s}const Qt=(e,t)=>Math.round(Math.abs(t-e)*uD),_X=120,nf=0;function EX(e,t){const n=s=>({kind:"litter",at:t,...s});return[{x:t,prop:n({}),act:"walk",ms:Qt(e,t)},{x:t,prop:n({}),act:"stoop",ms:bX},{x:nf,prop:n({held:!0}),act:"carry",ms:Qt(t,nf)},{x:nf,prop:n({held:!0}),act:"windup",ms:kX},{x:nf,prop:n({held:!0,leaving:!0}),act:"toss",ms:jX}]}function TX(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:Qt(e,s)},{x:s,prop:a(),act:"windup",ms:NX,facing:n>0?"right":"left"},{x:s,prop:a({leaving:!0}),act:"kick",ms:FT,facing:n>0?"right":"left"},{x:s,prop:a({leaving:!0}),act:"stand",ms:dD-FT}]}const hD=640;function AX(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:Qt(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:Qt(s,0)}]}function RX(e,t,n){const s=Math.max(-110,Math.min(-30,t)),a={x:s,prop:null};return[{...a,act:"walk",ms:Qt(e,s)},{...a,act:"skip-ready",ms:500},{...a,act:"skip",ms:hD*(6+Math.floor(n()*5))},{...a,act:"skip-rest",ms:600},{...a,act:"stand",ms:350},{x:0,prop:null,act:"walk",ms:Qt(s,0)}]}function MX(e,t,n){return[{x:t,prop:null,act:"walk",ms:Qt(e,t)},{x:t,prop:null,act:"sit",ms:Math.round(qT+n()*(CX-qT))},{x:t,prop:null,act:"stand",ms:400}]}function $X(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:Qt(e,t)},{x:t,prop:s(),act:"watch",ms:Math.round(BT+n()*(SX-BT))},{x:t,prop:s(),act:"scope-pack",ms:480},{x:t,prop:null,act:"stand",ms:240}]}function Jy(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 LX=1500,IX=e=>Math.round(1e3*Math.sqrt(2*e/LX)),OX=115,PX=e=>Math.round(e/OX*1e3),DX=620,FX=200,BX=760,qX=600,UX=240;function WX(e,t,n){const a=-(t.ledgeSpan??cm),o=IX(t.ledgeH),i=PX(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:Qt(e,a)},{x:a,act:"peer",prop:null,ms:DX},{x:a,act:"fall",prop:null,ms:o,place:"floor"},{x:a,act:"land",prop:null,ms:FX,place:"floor"},{x:h,act:"walk",prop:null,ms:Qt(a,h),place:"floor",floorFrac:l},{x:f,act:"walk",prop:null,ms:Qt(h,f),place:"floor",floorFrac:u},{x:a,act:"walk",prop:null,ms:Qt(f,a),place:"floor"},{x:a,act:"lasso",prop:null,ms:BX,place:"floor"},{x:a,act:"rope-throw",prop:null,ms:qX,place:"floor"},{x:a,act:"rope-catch",prop:null,ms:UX,place:"floor"},{x:a,act:"climb",prop:null,ms:i},{x:a,act:"pull-up",prop:null,ms:480}]}function HX(e,t,n){const s=(n==null?void 0:n.ledgeSpan)??cm;switch(vX(t)){case"tidy":return EX(e,ul(e,t,s));case"kick":return TX(e,ul(e,t,s));case"sit":return MX(e,ul(e,t,s),t);case"watch":return $X(e,ul(e,t,s),t);case"fish":return AX(e,ul(e,t,s),t);case"skip":return RX(e,ul(e,t,s),t);case"leave":{if(!n||!(n.ledgeH>0)||!(n.floorSpan>0))break;return WX(e,n,t)}}const o=wX(e,t,s);return[{x:o.to,prop:null,act:"walk",ms:o.ms}]}const zX=420;function VX(e,t,n){const s=t==="right"?n-e-18:e-18;return(t==="right"?1:-1)*Math.min(zX,Math.max(0,s))}const GX=260,KX=200;function YX(e,t,n){const s=(f,p=Qt(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,Qt(e,l)),{...h,x:l,act:"mount",ms:GX},{...h,x:u,act:"walk",ms:Qt(l,u)},{x:u,prop:null,act:"dismount",ms:KX,place:"floor"},{x:t,prop:null,act:"walk",ms:Qt(u,t),place:"floor"}]}const fD=["bob","sway","groove"],UT=9e3,XX=16e3,pD=1e3,ZX=.08;function JX(e,t){const n=fD.filter(o=>o!==e),s=n[Math.min(n.length-1,Math.floor(t()*n.length))],a=(t()*2-1)*ZX;return{dance:s,beatMs:Math.round(pD*(1+a))}}function QX(e){return Math.round(UT+e()*(XX-UT))}const TN=["......aaaaaa......","....aa......aa....","...a..bbbbbs..a...","...cpcbbbbbscpc...","...cpcbebbescpc...","...cpcbbbbbscpc...","...cpcbbbbbscpc...","....ccbbbbbscc....","....bbbbbbbbbs....","....bbbbbbbbbs....","......bbbbbs......","......bb..bs......","......bb..bs......","......bb..bs......"],WT=18,eZ=TN.length,mD="M6 9H4V1H5V0H7V-1H9V1H7V2H5V7H6V8H7V9Z",gD="M12 9H14V6H13V3H11V2H9V4H12Z",AN=new Set(["a","c","p"]);function fo(e=TN){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 tZ=[".xx.","xxxx",".xx."],nZ=["..xx..",".xsxx.","xssxxx","xxxxsx",".xxxx.","..xx.."],sZ=["...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."],Qy={litter:tZ,ball:nZ,scope:sZ},rZ=["...hhhhhh...","...hhhhhh...","...kkkkkk...","hhhhhhhhhhhh"],aZ=3,oZ=-1,L1=11,HT=9;function zT(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 iZ(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,b]=g.useState("ledge"),[k,v]=g.useState("left"),[N,x]=g.useState(0),C=g.useRef(null),[S,_]=g.useState(()=>document.hidden);g.useEffect(()=>{const R=new Set,q=()=>{var T;if(document.hidden){for(const F of((T=C.current)==null?void 0:T.getAnimations({subtree:!0}))??[])if(F.playState==="running"||F.pending){const D=F.currentTime;F.pause(),D!==null&&(F.currentTime=D),R.add(F)}}else{for(const F of R)F.playState==="paused"&&F.play();R.clear()}_(document.hidden)};return q(),document.addEventListener("visibilitychange",q),()=>document.removeEventListener("visibilitychange",q)},[e,t]);const[$,A]=g.useState(null),[O,M]=g.useState(pD),[W,B]=g.useState(()=>{var R;return((R=window.matchMedia)==null?void 0:R.call(window,"(prefers-reduced-motion: reduce)").matches)??!1});return g.useEffect(()=>{var T;const R=(T=window.matchMedia)==null?void 0:T.call(window,"(prefers-reduced-motion: reduce)");if(!R)return;const q=()=>B(R.matches);return q(),R.addEventListener("change",q),()=>R.removeEventListener("change",q)},[]),g.useEffect(()=>{var J;if(!e||t||W)return;const R=zT(document);let q=0;a(Q=>q=Q);let T=null,F=0,D=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),b(te.place??"ledge"),x(te.riser??0);const de=q,oe=U(te);if(te.act==="kick"){const pe=(he=(re=C.current)==null?void 0:re.querySelector('.fm-prop[data-prop="ball"]'))==null?void 0:he.getBoundingClientRect();pe&&m({x:VX(pe.x,Jy(te,de,"left"),window.innerWidth),drop:Math.max(48,window.innerHeight-pe.y+24)})}D=te.act==="walk"?Math.max(Qt(de,oe),_X):te.ms,te.act==="carry"&&(D=Qt(de,oe)),i(D),v(pe=>Jy({...te,x:oe},de,pe)),a(oe),q=oe,T=te,F=Date.now(),R.schedule(()=>K(le),D)},V=()=>{const Q=C.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=C.current,te=Q==null?void 0:Q.querySelector(".fm-sprite");return!Q||!te?0:Math.max(0,Q.getBoundingClientRect().width-te.offsetWidth)},P=()=>{const Q=C.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=C.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}},U=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=U(T);Q!==q&&(i(Math.max(0,F+D-Date.now())),v(te=>Jy({...T,x:Q},q,te)),a(Q),q=Q)},z=()=>{R.schedule(()=>{const Q=HX(q,Math.random,P()),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=YX(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)},xX(Math.random))},X=(J=C.current)==null?void 0:J.parentElement,Y=typeof ResizeObserver>"u"?null:new ResizeObserver(Z);return X&&Y&&Y.observe(X),z(),()=>{R.dispose(),Y==null||Y.disconnect(),b("ledge"),a(Q=>Math.max(-H(),Math.min(0,Q))),i(0),u(null),f(null),x(0)}},[e,t,W]),g.useEffect(()=>{if(!n||W){A(null);return}const R=zT(document),q=T=>{const F=JX(T,Math.random);A(F.dance),M(F.beatMs),R.schedule(()=>q(F.dance),QX(Math.random))};return q(null),()=>R.dispose()},[n,W]),{scene:C,suspended:S,x:s,walkMs:o,act:l,prop:h,ballFlight:p,place:w,facing:k,riser:N,dance:$,beatMs:O}}const ew={e:"fm-eye",s:"fm-shade",p:"fm-pad"},lp=fo().filter(e=>!AN.has(e.cell)),lZ=fo().filter(e=>AN.has(e.cell)),VT=lp.filter(e=>e.cell==="e"),cZ=fo(rZ),uZ=lp.filter(e=>e.y<L1&&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),dZ={left:lp.filter(e=>e.y>=L1&&e.x<HT),right:lp.filter(e=>e.y>=L1&&e.x>=HT)},hZ=g.memo(function({act:t,facing:n}){return r.jsxs("svg",{viewBox:`0 0 ${WT} ${eZ}`,shapeRendering:"crispEdges","aria-hidden":!0,children:[r.jsx("g",{className:"fm-gear",children:r.jsx("g",{className:"fm-gear-motion",children:lZ.map(s=>r.jsx("rect",{x:s.x,y:s.y,width:s.w,height:1,className:ew[s.cell]},`g${s.y}-${s.x}`))})}),r.jsxs("g",{className:"fm-body",children:[VT.map(s=>r.jsx("rect",{x:s.x,y:s.y,width:s.w,height:1,fill:"var(--accent)"},`eye-bed-${s.x}`)),uZ.map(s=>r.jsx("rect",{x:s.x,y:s.y,width:s.w,height:1,className:ew[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"})]}),VT.map(s=>r.jsx("rect",{x:s.x-(s.x>=WT/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:cZ.map(s=>r.jsx("rect",{x:aZ+s.x,y:oZ+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:mD}),r.jsx("path",{className:"fm-grip-right",d:gD})]}),(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:dZ[s].map(a=>r.jsx("rect",{x:a.x,y:a.y,width:a.w,height:1,className:ew[a.cell]},`${s}${a.y}-${a.x}`))},s))]})}),fZ=["...o........o.....","...of......fo.....","...owffffffwo.....","...offfffffso.....","...ofefffefso.....","....owwnwwso......",".....wwwww........",".....fwwwfs.......","....ffwwwffs...ww.","....ffwwwffs..wfs.","......fwwfssfffs..","......ff..fsffs...","......ff..fs......","......oo..oo......"],pZ=[".....aaaaaaa......","...aa.......aa....","..a...........a...","..cp.........pc...","..cp.........pc...","..cp.........pc...","..c...........c..."],fr={f:"#d88735",s:"#a55b24",o:"#63351e",w:"#ffe2aa",n:"#372821"},mZ={p:"fm-pad"},Xu=fo(fZ),gZ=fo(pZ);function I1(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 yZ=I1(Xu.filter(e=>e.y>=8),12,18),wZ=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),GT=Xu.filter(e=>e.cell==="e"),xZ={left:I1(Xu.filter(e=>e.y>=11),0,9),right:I1(Xu.filter(e=>e.y>=11),9,12)},vZ=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:yZ.map(i=>r.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,fill:fr[i.cell]},`t${i.y}-${i.x}`))}),r.jsx("g",{className:"fm-gear",children:r.jsx("g",{className:"fm-gear-motion",children:gZ.map(i=>r.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,className:mZ[i.cell]},`g${i.y}-${i.x}`))})}),r.jsxs("g",{className:"fm-body",children:[wZ.map(i=>r.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,fill:fr[i.cell]},`b${i.y}-${i.x}`)),GT.map(i=>r.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,fill:fr.f},`bed${i.x}`)),r.jsxs("g",{className:"fm-arms",fill:fr.f,children:[r.jsx("rect",{x:4,y:8,width:2,height:2}),r.jsx("rect",{x:12,y:8,width:1,height:2})]}),GT.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:fr.n}},`e${i.x}`))]}),s&&r.jsxs("g",{className:"fm-grip",style:{fill:fr.f},children:[r.jsx("path",{className:"fm-grip-left",d:mD}),r.jsx("path",{className:"fm-grip-right",d:gD})]}),a&&r.jsxs("g",{className:"fm-crouch-legs",style:{fill:fr.f},children:[r.jsx("path",{d:"M6 11H8V13H6Z"}),r.jsx("path",{d:"M10 11H12V13H10Z"})]}),o&&r.jsxs("g",{className:"fm-seated-legs",style:{fill:fr.f},children:[r.jsx("path",{className:"fm-seated-far",style:{fill:fr.s},d:"M10 10H12V11H11V14H8V13H9V11H10Z"}),r.jsx("path",{d:"M6 10H9V11H7V15H4V14H5V11H6Z"})]}),["left","right"].map(i=>r.jsx("g",{className:"fm-leg","data-side":i,children:xZ[i].map(l=>r.jsx("rect",{x:l.x,y:l.y,width:l.w,height:1,fill:fr[l.cell]},`${l.y}-${l.x}`))},i))]})}),bZ=[".......dddd.......","......dhhhhd......",".....dhhhhhhd.....","....dhwwhhwwhd....","....dhwewwewhd....","....dhwwbbwwhd....","....dhwwwwwwhd....","....dhwwwwwwhd....","....dhwwwwwwhd....",".....dhwwwwhd.....",".....dhwwwwhd.....","......dhhhhd......","......bb..bb......",".....bbb..bbb....."],Jr={d:"#3b4855",h:"#657b8b",w:"#f4f0df",e:"#19242b",b:"#f0b44b",s:"#c88736"},kZ={p:"fm-pad"},cp=fo(bZ),jZ=fo(TN).filter(e=>AN.has(e.cell)),KT=cp.filter(e=>e.cell==="e"),NZ=cp.filter(e=>e.y<12&&e.cell!=="e"),SZ={left:cp.filter(e=>e.y>=12&&e.x<9),right:cp.filter(e=>e.y>=12&&e.x>=9)},CZ=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:jZ.map(o=>r.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,className:kZ[o.cell]},`g${o.y}-${o.x}`))})}),r.jsxs("g",{className:"fm-body",children:[NZ.map(o=>r.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,fill:Jr[o.cell]},`b${o.y}-${o.x}`)),KT.map(o=>r.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,fill:Jr.w},`bed${o.x}`)),r.jsxs("g",{className:"fm-arms",fill:Jr.d,children:[r.jsx("path",{d:"M4 8H6V10H5V11H4Z"}),r.jsx("path",{d:"M12 8H14V11H13V10H12Z"})]}),KT.map(o=>r.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,className:"fm-eye",style:{fill:Jr.e}},`e${o.x}`))]}),n&&r.jsxs("g",{className:"fm-grip",style:{fill:Jr.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:Jr.b},children:[r.jsx("path",{d:"M5 12H8V13H5Z"}),r.jsx("path",{d:"M10 12H13V13H10Z"})]}),a&&r.jsxs("g",{className:"fm-seated-legs",style:{fill:Jr.b},children:[r.jsx("path",{className:"fm-seated-far",style:{fill:Jr.s},d:"M10 11H12V12H13V14H10V13H11V12H10Z"}),r.jsx("path",{d:"M6 11H8V12H7V13H8V14H4V13H5V12H6Z"})]}),["left","right"].map(o=>r.jsx("g",{className:"fm-leg","data-side":o,children:SZ[o].map(i=>r.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,fill:Jr.b},`${i.y}-${i.x}`))},o))]})});function yD({character:e,act:t,facing:n}){return e==="penguin"?r.jsx(CZ,{act:t,facing:n}):e==="fox"?r.jsx(vZ,{act:t,facing:n}):r.jsx(hZ,{act:t,facing:n})}const _Z={"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 wD(e,t){return t&&Xl(t.id)===e?t.name:lm(e)?"Custom FM":_Z[e]}function tw(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 YT={litter:tw(Qy.litter,"litter"),ball:tw(Qy.ball,"ball"),scope:tw(Qy.scope,"scope")};function EZ(e){try{return new URL(e).host}catch{return"the station's server"}}const TZ=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:b,ballFlight:k,place:v,facing:N,riser:x,dance:C,beatMs:S}=iZ(o,i,l);if(!o||i)return null;const _=wD(n,s),$=o.audio?EZ(o.audio):"YouTube";return r.jsxs("div",{ref:h,className:"fm","data-suspended":f?"":void 0,"data-place":v,style:{"--fm-beat":`${S}ms`},children:[b&&!b.held&&r.jsx("div",{className:"fm-prop","data-prop":b.kind,"data-leaving":b.leaving?"":void 0,style:{"--fm-prop-x":`${b.at}px`,"--fm-roll-to":`${k.x}px`,"--fm-ball-drop":`${k.drop}px`,"--fm-ball-flight-ms":`${dD}ms`,"--fm-ball-turn":N==="right"?"1080deg":"-1080deg"},children:YT[b.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":v,"data-facing":N,style:{"--fm-x":`${p}px`,"--fm-walk-ms":`${m}ms`,"--fm-riser":`${x}px`,"--fm-skip-beat":`${hD}ms`},children:[(b==null?void 0:b.held)&&r.jsx("div",{className:"fm-held","data-prop":b.kind,"data-toss":b.leaving?"":void 0,children:YT[b.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?C??fD[0]:void 0,onClick:u,title:l?`Stop ${_}`:`Play ${_} — streams from ${$}`,"aria-label":l?`Stop ${_}`:`Play ${_}`,children:r.jsx(yD,{character:a,act:w,facing:N})})]})]})});function AZ({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:rX(n.channel,window.location.origin,n.video),onLoad:()=>o(aX()),allow:"autoplay; encrypted-media",sandbox:"allow-scripts allow-same-origin allow-presentation"})}):null}const RZ={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 MZ({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:RZ[e]})})}function $Z({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 LZ({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:KG,children:[r.jsx("button",{type:"button",className:"icon-btn","aria-label":"Close radio",onClick:e,children:r.jsx(MZ,{name:"close"})}),r.jsx($Z,{opening:!0})]})}const IZ=g.lazy(()=>bi(()=>import("./RadioPanel-Cn3WvPUG.js"),[]));function OZ({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=mX(),[f,p]=g.useState(null),m=g.useRef(new Set);g.useEffect(()=>{const A=new AbortController;return fetch("/api/music-config",{signal:A.signal}).then(O=>O.ok?O.json():null).then(O=>{A.signal.aborted||(i((O==null?void 0:O.enabled)===!0),u(O?"Music is turned off on this deck.":"Cannot reach the deck. Reopen Radio when it reconnects."))}).catch(()=>{A.signal.aborted||u("Cannot reach the deck. Reopen Radio when it reconnects.")}),()=>A.abort()},[s]);const w=e.customFmStations.find(A=>Xl(A.id)===e.fmSource),b=w!=null&&w.radio?w:void 0,k=hX({volume:e.fmVolume,muted:e.fmMuted,source:e.fmSource,playRequest:e.fmPlayRequest,customStation:w,enabled:o,onAvailabilityChange:e.markFmStationAvailability}),v=wD(e.fmSource,w),N=o&&b&&k.dead&&e.fmPlayRequest>0?cD(f??h.catalogue,b.id,m.current):null,{remember:x}=h,C=(w==null?void 0:w.id)??e.fmSource;g.useEffect(()=>{k.playing&&x(C)},[C,k.playing,x]);const S=a,_=yt(a),$=g.useCallback((A,O=!1)=>{var R;if(!o)return;O||m.current.clear();const M=Xl(A.id),W=M===e.fmSource;if(W&&k.armed&&!k.dead){k.press();return}const B=W&&!!w&&(w.url!==A.url||((R=w.radio)==null?void 0:R.hls)!==A.radio.hls);e.addFmStation(A,!0),W&&!k.dead&&!B?k.press():e.pickFmSource(M,B),fetch(`/api/radio-click?id=${encodeURIComponent(A.id)}`).catch(()=>{})},[o,w,e.addFmStation,e.fmSource,e.pickFmSource,k.armed,k.dead,k.press]);return g.useEffect(()=>{k.playing&&!k.dead&&m.current.clear()},[k.playing,k.dead]),g.useEffect(()=>{if(!(!o||!b||!k.dead||e.fmPlayRequest===0))return gX(f??h.catalogue,b.id,m.current,A=>$(A,!0))},[o,b==null?void 0:b.id,k.dead,e.fmPlayRequest,f,h.catalogue,$]),r.jsxs(r.Fragment,{children:[t&&r.jsx(TZ,{character:n,player:k,source:e.fmSource,customStation:w}),r.jsx(AZ,{player:k,label:v}),s&&vt.createPortal(r.jsx("div",{className:"modal-backdrop radio-backdrop",..._,children:r.jsx(g.Suspense,{fallback:r.jsx(LZ,{onClose:S}),children:r.jsx(IZ,{fm:e,player:k,library:h,selected:b,label:v,enabled:o,disabledReason:l,autoNext:N==null?void 0:N.name,onPick:$,onQueueChange:p,onClose:S})})}),document.body)]})}function PZ({data:e}){const t=_r(3e4),n=e.note,s=e.plan??null,a=(n==null?void 0:n.kind)==="recap",o=ap((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:am(n),u=Cr(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(sp,{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(),yK(e.noteKey)},children:"×"})]}),n&&r.jsx("p",{className:"recap-note-text",title:EK(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(XT,{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(sp,{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(XT,{plan:s,head:n!=null,face:!0})]}),r.jsx(fi,{type:"source",position:Ye.Right,style:{background:"transparent",border:"none"}})]})}const DZ={completed:"done",in_progress:"now",pending:"to do"};function XT({plan:e,head:t,face:n=!1}){const s=Cr(e);if(!s)return null;const a=gV(e.items);return r.jsxs("div",{className:n?"recap-face-plan":"recap-note-plan",title:n?void 0:Kp(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:[DZ[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 up=e=>new Map([...e].map(([t,n])=>[t,{x:n.x,y:n.y}]));function FZ(e,t,n){return{positions:up(e.positions),pinned:up(e.pinned),provisional:new Set(e.provisional),layoutSig:e.layoutSig.current,stored:{...t},viewport:n?{...n}:null}}function BZ(e,t){t.positions.clear();for(const[n,s]of up(e.positions))t.positions.set(n,s);t.pinned.clear();for(const[n,s]of up(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 ZT=7e3,qZ=2e3,UZ=140,WZ="Layout re-arranged",HZ="Layout re-arranged. Undo available.",JT="Layout restored.",zZ={set:(e,t)=>setTimeout(e,t),clear:e=>clearTimeout(e),now:()=>Date.now()};function VZ(e,t=zZ){let n=null,s=null,a=0,o=ZT;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=ZT,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,qZ),u())},get isOpen(){return n!==null},get snapshot(){return n}}}function GZ(e){return(e.key==="z"||e.key==="Z")&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey}function KZ(e){return po(e)?"⌘Z":"Ctrl+Z"}function YZ({undo:e}){const{open:t,said:n,undo:s,dismiss:a,hold:o,release:i}=e,l=Nl(t,UZ),u=g.useRef(null);return g.useEffect(()=>t?rn.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}),Ja(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:WZ}),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:KZ(ro())})]})]})]})}function XZ({sourceX:e,sourceY:t,targetX:n,targetY:s,sourcePosition:a,targetPosition:o,style:i}){const[l]=Jj({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 O1(e){return e.replace(/[^a-zA-Z0-9]/g,"")}function dp(e,t){const n=O1(e);return n?n.slice(-t):e.slice(-t)}function xD(e,t,n=4){const s=O1(e);if(!s)return dp(e,n);let a=n;for(const o of t){if(o===e)continue;const i=O1(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=" · ",ZZ=32,JZ=/[\u1100-\u115F\u2E80-\u303E\u3041-\u33FF\u3400-\u4DBF\u4E00-\u9FFF\uA000-\uA4CF\uAC00-\uD7A3\uF900-\uFAFF\uFE30-\uFE6F\uFF00-\uFF60\uFFE0-\uFFE6]/;function QT(e){return JZ.test(e)?2:1}function eA(e,t=ZZ){const n=[...e];let s=0;for(const i of n)s+=QT(i);if(s<=t)return e;const a=[];let o=0;for(const i of n){const l=QT(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 QZ(e,t,n,s,a=[],{branch:o,plan:i,alarm:l=!1}={}){const u=(t==null?void 0:t.trim())??"",h=s?xD(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:eA(e),name:u?eA(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,P1=26,RN=12,Zu=240,MN=130,D1=ti*2+P1+RN,eJ=72,Il=D1+eJ,Lf=24,vD=70,bD=ti*2+Lf,hp=Il;function kD(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,If=300,fp=130,jD=160,ND=1;function tJ(e,t,n,s){return Math.min(ND,n/Math.max(1,e),s/Math.max(1,t))}function Tn(e){const t=e.data;return(t==null?void 0:t.canvasSessionId)??(t==null?void 0:t.sessionId)??"_default"}function um(e,t=()=>!0){const n=new Map;for(const s of e){if(!t(s))continue;const a=Tn(s),o=n.get(a);o?o.push(s):n.set(a,[s])}return n}function nJ(e,t){return((t==null?void 0:t.get(e))??0)>0?Ol:0}function sJ(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)??MN}}function xd(e,t,n){const s=Ju(e,t);return{w:s.w+nJ(e,n),h:Math.max(s.h,sJ(e,n))}}function rJ(e){return[...e.keys()].sort().map(t=>`${t}:${e.get(t)}`).join("|")}const aJ=240,SD=16;function CD(e,t){return(e+aJ)*(t||1)}function oJ(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 iJ(e,t,n,s){return{position:"absolute",left:e.x+SD,top:e.y-RN/(t||1),transform:`scale(${1/(t||1)})`,transformOrigin:"left top",maxWidth:s??CD(e.w,t),"--session-hue":n}}function lJ(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(Tn(a)),p=o.canvasSessionId&&o.canvasSessionId!==o.sessionId?null:cJ(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(Tn(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,...QZ(o.label,o.name,a,l,i,{branch:o.branch,plan:o.planLine,alarm:o.alarm}),x:o.minX-ti,y:o.minY-ti-P1,w:o.maxX-o.minX+ti*2,h:o.maxY-o.minY+ti*2+P1,...o.alarm?{alarm:!0}:null,...o.branch?{branch:o.branch}:null,...o.plan?{plan:o.plan,planLine:o.planLine}:null})}return s}function cJ(e){if(e.kind!=="root")return null;const t=e.branch,n=Cr(e.plan);return{label:e.label,name:tm(e.sessionName,e.sessionTitle).face,alarm:En(e.waiting),branch:t&&t.total>0?BP(t):void 0,plan:n?`plan ${n.done}/${n.total}`:void 0,planLine:n?uN(n):void 0}}function uJ(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 dJ=20,Qr=4,hJ=64,fJ=".cat-filter-bar, .react-flow__panel, .autofit-chip, .rearrange-undo, .usage-panel, .sysdetail, .detail";function pJ(e,t,n,s){const a=t.zoom||1,o=CD(e.w,a);if(n.width<=0||n.height<=0)return{maxWidth:o,hidden:!1};const i=(e.x+SD)*a+t.x,l=e.y*a+t.y-RN,u=l+dJ;let h=Math.min(o,n.width-Qr-i),f=i<Qr||l<Qr||u>n.height-Qr;for(const p of s)if(!(p.top-Qr>=u||p.bottom+Qr<=l)&&!(p.right+Qr<=i)){if(p.left-Qr<=i){f=!0;break}h=Math.min(h,p.left-Qr-i)}return h<hJ&&(f=!0),{maxWidth:Math.max(0,h),hidden:f}}function mJ(e){const t=e.getBoundingClientRect(),n=[];for(const s of e.ownerDocument.querySelectorAll(fJ)){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 gJ(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 yJ=500;function _D({focus:e,setTimeout:t,clearTimeout:n,ms:s=yJ}){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 wJ(e){return lJ(e.nodeInternals.values())}const xJ=e=>e.width,vJ=e=>e.height,bJ=e=>{var t;return((t=e.domNode)==null?void 0:t.querySelector(".react-flow__viewport"))??null};function kJ({onFocusSession:e}){const{x:t,y:n,zoom:s}=L4(),a=ht(wJ,uJ),o=ht(xJ),i=ht(vJ),l={width:o,height:i},u=g.useRef(null),h=ht(bJ),[f,p]=g.useState([]);g.useLayoutEffect(()=>{var $;const C=($=u.current)==null?void 0:$.parentElement;if(!C)return;const S=mJ(C),_=requestAnimationFrame(()=>{p(A=>gJ(A,S)?A:S)});return()=>cancelAnimationFrame(_)});const m=g.useRef(e);m.current=e;const[w]=g.useState(()=>_D({focus:C=>{var S;return(S=m.current)==null?void 0:S.call(m,C)},setTimeout:(C,S)=>window.setTimeout(C,S),clearTimeout:C=>window.clearTimeout(C)}));if(g.useEffect(()=>()=>w.cancel(),[w]),a.length<=1)return null;const b=C=>{try{e==null||e(C)}catch{}},k=(C,S)=>{C.detail>0&&md()?w.hold(S):b(S)},v={transform:`translate(${t}px, ${n}px) scale(${s})`},N=r.jsx("div",{className:"session-clusters",style:v,ref:u,children:a.map(C=>{const S=Gu(C.sessionId),_=oJ(C,S);return r.jsx("div",{className:"cluster-card",style:_,"aria-hidden":!0},C.sessionId)})}),x=h&&vt.createPortal(r.jsx("div",{className:"cluster-labels nopan",children:a.map(C=>{const S=Gu(C.sessionId),_=pJ(C,{x:t,y:n,zoom:s},l,f),$=iJ(C,s,S,_.maxWidth);return r.jsxs("button",{type:"button",className:"cluster-label","data-alarm":C.alarm?"":void 0,"data-offpane":_.hidden?"":void 0,style:$,title:C.title,onClick:A=>k(A,C.sessionId),children:[C.alarm?r.jsxs(r.Fragment,{children:[r.jsx(bN,{}),r.jsx("span",{className:"cluster-label-said",children:"waiting on you: "})]}):null,C.label,C.plan?r.jsx("span",{className:"cluster-label-plan",children:Sl+C.plan}):null,C.branch?r.jsx("span",{className:"cluster-label-branch",children:Sl+C.branch}):null,C.name?r.jsx("span",{className:"cluster-label-name",children:Sl+C.name}):null,C.shortId?r.jsx("span",{className:"cluster-label-id",children:Sl+C.shortId}):null]},C.sessionId)})}),h);return r.jsxs(r.Fragment,{children:[N,x]})}function jJ({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 ED=600,NJ=4,SJ=36,pp=14,CJ=60,_J=6,tA=220,EJ=96,TJ=28;function AJ(e,t){return Math.max(EJ,61+[...t].length*6.8)}function RJ(e){return e.endedAt==null?"inflight":e.ok===!1?"err":"done"}function MJ(e,t){if(t==null)return 1;const n=e-t;return n<0?1:Math.max(0,1-n/ED)}function $J(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 LJ(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>ED)continue;const u=s.get(l.id)??n.get(l.id);if(!u)continue;const h=$J(l.tools,NJ);if(h.length===0)continue;const f=l.exitAt??null,p=a.get(l.id),m=Math.max((p==null?void 0:p.width)??tA,tA),w=(p==null?void 0:p.height)??130,b=u.x,k=u.y,v=b+m,N=k+w/2;h.forEach((x,C)=>{const S=C*SJ,_=b+m+CJ,$=k+_J+S,A=MJ(o,f),O=x.inputPreview??"",M=RJ(x),W=A<.999,B=vN(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:M,category:qP(x.name),mcpHue:B.hue,inputPreview:O,fade:A,fading:W,worldX:_,worldY:$,anchorX:v,anchorY:N,spawnDx:v-_,spawnDy:N-($+pp)});const R=zP(x.name,x.input);if(R){const q=AJ(x.name,B.label),T=_+q+TJ,F=$,D=_+q,K=$+pp;i.push({id:`sub:${l.id}::${x.id}`,toolId:x.id,agentId:l.id,toolName:x.name,name:nY(R.label,R.category),fullName:R.label,emoji:R.emoji,isSub:!0,status:M,category:R.category,inputPreview:R.detail??O,fade:A,fading:W,worldX:T,worldY:F,anchorX:D,anchorY:K,spawnDx:D-T,spawnDy:0})}})}return i}function IJ({agents:e,visibleAgentIds:t,positions:n,pinned:s,measured:a,spotlight:o,hiddenCategories:i,now:l,onOpenTool:u}){const h=LJ(e,t,n,s,a,l),f=i&&i.size>0?h.filter(p=>!i.has(p.category)):h;return r.jsx(OJ,{bursts:f,spotlight:o,onOpenTool:u})}function OJ({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+pp,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,b=u-f*.25,k=t!=null&&!t.has(o.agentId),v=o.fade*(k?.14:1);return r.jsx("path",{d:`M ${i} ${l} C ${m} ${w}, ${b} ${h}, ${u} ${h}`,className:`tool-conn status-${o.status}${o.fading?" fading":""}`,opacity:v,vectorEffect:"non-scaling-stroke"},`l:${o.id}`)}),a=e.map(o=>r.jsx(FJ,{b:o,dim:t!=null&&!t.has(o.agentId),onOpenTool:n},o.id));return r.jsx(PJ,{connectors:s,bubbles:a})}function PJ({connectors:e,bubbles:t}){const{x:n,y:s,zoom:a}=L4();return r.jsxs("div",{className:"tool-bursts-layer","aria-hidden":!0,style:{"--tool-burst-height":`${2*pp}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 DJ(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 FJ=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:"×"})]})})},DJ),BJ={width:140,height:105},qJ={agent:CY,sessionGroup:jJ,recapNote:PZ},UJ={recapTie:XZ},nA=400;function WJ({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:b,openTool:k,focusAgent:v,requestClear:N,setKeyHelpOpen:x}){const{allNodes:C,edges:S,visibleAgentIds:_,spotlightSet:$}=e,{positionsRef:A,pinnedRef:O,handleRelayout:M,rearrangeUndo:W}=t,{restoredViewport:B,onMoveStart:R,onMove:q}=n,{onNodeClick:T,onPaneClick:F,onNodeDoubleClick:D,onNodeMouseEnter:K,onNodeMouseLeave:V}=s,{onNodeDragStart:H,onNodeDrag:P,onNodeDragStop:I}=a,{palette:U,minimapNodeFill:Z,characterEnabled:z}=o,{autoFitDisabled:X,enableAutoFitAndRefit:Y}=h,{paused:J,pauseGate:Q,togglePause:te}=f;return r.jsxs($4,{nodes:C,edges:S,nodeTypes:qJ,edgesFocusable:!1,edgeTypes:UJ,fitView:!B,fitViewOptions:{padding:.25,duration:v1({durationMs:nA,documentHidden:document.hidden})?nA:0},minZoom:F4,maxZoom:B4,panOnScroll:!0,panActivationKeyCode:null,nodesDraggable:!0,nodesConnectable:!1,selectionOnDrag:!1,nodeDragThreshold:5,disableKeyboardA11y:!0,deleteKeyCode:null,onNodeClick:T,onPaneClick:F,onNodeDoubleClick:D,onNodeMouseEnter:K,onNodeMouseLeave:V,onMoveStart:R,onMove:q,onNodeDragStart:(le,de,oe)=>{W.dismiss(),H(le,de,oe)},onNodeDrag:P,onNodeDragStop:I,children:[r.jsx(R9,{gap:28,size:1,color:U["--grid-line"]}),r.jsx(kJ,{onFocusSession:v}),r.jsx(IJ,{agents:p.current.agents,visibleAgentIds:_,positions:A.current,pinned:O.current,measured:m.current,spotlight:$,hiddenCategories:w,now:b,onOpenTool:k}),r.jsxs("div",{className:"canvas-notices",children:[X&&r.jsx(LY,{enableAutoFitAndRefit:Y}),r.jsx(YZ,{undo:W})]}),r.jsx(VY,{autoFitDisabled:X,enableAutoFitAndRefit:Y,paused:J,pauseGate:Q,togglePause:te,handleRelayout:M,requestClear:N,setKeyHelpOpen:x}),r.jsx(w9,{style:BJ,zoomable:!0,pannable:!0,nodeColor:Z,nodeStrokeWidth:2,maskColor:U["--minimap-mask"],maskStrokeColor:U["--line"]}),r.jsx(OZ,{fm:i,character:o.character,characterEnabled:z,open:l,onClose:u})]})}function HJ(){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 zJ(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=Un(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 VJ="spend on this board",GJ="on this board",TD=`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
- `,KJ=TD+"Press H for the totals ccusage reads off the logs on disk, which do not forget.";function sA(e){return e?KJ:TD+"Usage history has the totals ccusage reads off the logs on disk, which do not forget."}const AD="session spend",F1="__unknown__",YJ=12;function XJ(e,t=Date.now()){const n=new Map;for(const s of e)for(const a of sc(s)){const o=a.model??F1,i=Xp(a.usage,a.model,t),l=j1({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 ZJ(e,t=Date.now()){const n=[...e],s=[];for(const a of n){if(a.kind!=="root")continue;let o=Un(a,t).total,i=a.usage.inputTokens,l=a.usage.outputTokens,u=zl(a,t),h=j1(a,t);for(const f of n)f.sessionId!==a.sessionId||f.kind==="root"||(o+=Un(f,t).total,i+=f.usage.inputTokens,l+=f.usage.outputTokens,u+=zl(f,t),h=h&&j1(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,YJ)}const JJ=600;function dm(e,t){return!(e.exitAt!=null&&t-e.exitAt>JJ||e.kind==="root"&&e.state==="done"&&e.tools.length===0&&e.endedAt!=null&&e.endedAt-e.startedAt<3e3&&!e.stopFailure)}function QJ(e,t){const n=new Set;for(const s of e.agents.values())dm(s,t)&&n.add(s.id);return n}function eQ(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 tQ(e,t,n=0){if(!e)return!1;for(const s of t)if(eQ(e,s,n))return!0;return!1}function rA(e){return e.waiting?En(e.waiting)?0:1:e.state==="active"?2:3}function RD(e,t){var s;const n=[];for(const a of e.agents.values()){if(a.kind!=="root")continue;let o=a.toolCount,i=Un(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+=Un(p).total;const m=p.endedAt??p.startedAt;m>l&&(l=m)}const u=wN(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:Cr(a.plan),planTitle:Kp(((s=a.plan)==null?void 0:s.items)??[]),toolCount:o,cost:i,startedAt:a.startedAt,lastActivity:l})}return n.sort((a,o)=>{const i=rA(a),l=rA(o);return i!==l?i-l:a.waiting&&o.waiting?a.waiting.since-o.waiting.since:o.lastActivity-a.lastActivity}),n}function nQ(e){return[e.text,e.reply?`Suggested reply: ${e.reply}`:"",am(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 sQ({state:e,now:t,selectedIds:n,onSelect:s,onClose:a,removedIds:o,onBringBackAll:i,leaving:l=!1}){const u=An(),h=g.useMemo(()=>RD(e),[e,e.revision,t]),f=h.filter(m=>m.state==="active").length,p=h.filter(m=>En(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:_n("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 k;const w=n.has(m.sessionId),b=(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":""}${b?" removed":""}`,"aria-current":w?"true":void 0,onClick:()=>s(m.sessionId),title:b?`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}),b&&r.jsx("span",{className:"sl-removed",children:"off the board"}),m.modelId&&r.jsx("span",{className:"model-chip","data-family":Zp(m.modelId),title:Yu(m.modelId,m.effort),children:Jp(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:AD,children:r.jsx("b",{children:ct(m.cost)})}),m.waiting?r.jsxs("span",{className:"sl-waiting",title:[Gl(m.waiting),_P(m.waiting,Gl(m.waiting)),`${En(m.waiting)?"Blocked":"Your turn"} since ${new Date(m.waiting.since).toLocaleTimeString()} · started ${new Date(m.startedAt).toLocaleString()}`].filter(Boolean).join(`
95
- `),children:[En(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:rP(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(GP,{}),m.recap.text]}),m.status&&r.jsxs("span",{className:`sl-status status-${m.status.kind}`,title:nQ(m.status),children:[r.jsx("span",{className:"sl-status-tag",children:rc(m.status.kind)})," ",m.status.text]}),((k=m.status)==null?void 0:k.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 b=e.agents.get(w);b&&dm(b,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 b=w.currentTarget.closest(".session-list");i(),requestAnimationFrame(()=>{var k;return(k=b==null?void 0:b.querySelector(".sl-row"))==null?void 0:k.focus()})},children:["Bring back ",m," removed ",m===1?"card":"cards"]})})})()]})}const rQ={recent:"Recent",sessions:"Sessions",open:"Panels and dialogs",settings:"Settings",actions:"Actions",themes:"Themes"},nw=["recent","sessions","open","settings","actions","themes"],MD=/[\s\-_./·:,()›]/;function sf(e,t){return t===0||MD.test(e[t-1])}function aA(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 aQ(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+(sf(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(!aA(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 b=m;b>=0&&aA(p,s,b+1);b=s.indexOf(f,b+1))if(sf(s,b)){m=b;break}if(h===0&&!sf(s,m))return null;const w=i[i.length-1];u+=sf(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 oQ(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(MD).some(i=>i.startsWith(n))&&(s=Math.max(s,400))}return s}const iQ=8,lQ=5,$N=5;function cQ(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,$N),l=new Set(i.map(h=>h.id)),u=[];i.length&&u.push(sw("recent",i.map(h=>({item:h,hits:[]}))));for(const h of nw){if(h==="recent")continue;let f=e.filter(p=>p.section===h&&!p.queryOnly&&!l.has(p.id));h==="sessions"&&(f=f.slice(0,lQ)),f.length&&u.push(sw(h,f.map(p=>({item:p,hits:[]}))))}return u}const a=new Map;for(const o of e){const i=aQ(s,o.title),l=oQ(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,iQ),best:i[0].score})).sort((o,i)=>i.best-o.best||nw.indexOf(o.key)-nw.indexOf(i.key)).map(({key:o,list:i})=>sw(o,i.map(({item:l,hits:u})=>({item:l,hits:u}))))}function sw(e,t){return{section:e,title:rQ[e],items:t}}function uQ(e){return e.flatMap(t=>t.items)}function oA(e,t,n){return t<=0?-1:e<0?n>0?0:t-1:((e+n)%t+t)%t}const $D="agent-dag.quickOpenRecent";function LD(){try{const e=JSON.parse(nt($D)??"[]");return Array.isArray(e)?e.filter(t=>typeof t=="string").slice(0,$N):[]}catch{return[]}}function dQ(e,t){return[t,...e.filter(n=>n!==t)].slice(0,$N)}function hQ(e){st($D,JSON.stringify(dQ(LD(),e)))}function ID(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 fQ(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 pQ=()=>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"})]}),mQ=()=>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"})})}),gQ=()=>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"})]}),yQ=()=>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"})]}),wQ=()=>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"})]}),xQ=()=>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"})]}),vQ=()=>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"})]}),bQ=({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"})]}),kQ=()=>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"})]}),jQ=()=>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"})]}),OD=()=>r.jsx(jt,{children:r.jsx("path",{d:"M4.6 2.9v8.2L11.1 7Z"})}),NQ=()=>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"})]}),SQ=()=>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"})]}),CQ=()=>r.jsx(jt,{children:r.jsx("path",{d:"M2 5h10v7H2z M4 5l6-3 M4 8h3 M9 8h1 M4 10h1 M8 10h2"})}),_Q=()=>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"})]}),EQ=()=>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"})]}),TQ=()=>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"})]}),AQ=()=>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"})]}),RQ=()=>r.jsxs(jt,{children:[r.jsx("circle",{cx:"7",cy:"7",r:"5"}),r.jsx("path",{d:"M7 3.8V7l2.2 1.4"})]}),MQ=()=>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"})}),$Q=()=>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"})}),LQ=()=>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"})}),PD=()=>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"})]}),IQ=()=>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"})]}),OQ=()=>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"})]}),PQ=()=>r.jsx(jt,{children:r.jsx("path",{d:"M5 3v8M9 3v8"})}),DQ=()=>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"})}),FQ=120,iA=5;function BQ({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 qQ({items:e,onClose:t,onRun:n}){const[s,a]=g.useState(""),[o]=g.useState(LD),[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),b=g.useCallback(()=>h(!0),[]),k=g.useCallback(()=>{m.current||(m.current=!0,t())},[t]),v=gt(b,{focusRef:f}),N=yt(b),x=g.useMemo(()=>cQ(e,s,o),[e,s,o]),C=g.useMemo(()=>uQ(x),[x]),S=C.findIndex(R=>R.item.id===i),_=C.length?S>=0?S:0:-1,$=C[_];g.useEffect(()=>{if(!u)return;const R=setTimeout(k,FQ+60);return()=>clearTimeout(R)},[u,k]),g.useEffect(()=>{const R=po(ro()),q=T=>{ID(T,R)&&(T.preventDefault(),T.stopPropagation(),b())};return window.addEventListener("keydown",q,!0),()=>window.removeEventListener("keydown",q,!0)},[b]),g.useLayoutEffect(()=>{var T;const R=p.current;if(!R)return;if(_<=0){R.scrollTop=0;return}const q=R.querySelector(`[data-index="${_}"]`);q&&(q.dataset.first==="true"&&((T=q.closest(".qo-group"))==null||T.scrollIntoView({block:"nearest"})),q.scrollIntoView({block:"nearest"}))},[_,C]);const A=R=>{!R||u||(hQ(R.item.id),n(R.item))},O=R=>{const q=C[R];q&&l(q.item.id)},M=R=>{if(R.nativeEvent.isComposing)return;const q=R.ctrlKey&&!R.metaKey&&!R.altKey;let T=null;if(R.key==="ArrowDown"||q&&(R.key==="n"||R.key==="j"))T=oA(_,C.length,1);else if(R.key==="ArrowUp"||q&&(R.key==="p"||R.key==="k"))T=oA(_,C.length,-1);else if(R.key==="PageDown")T=Math.min(C.length-1,_+iA);else if(R.key==="PageUp")T=Math.max(0,_-iA);else if(R.key==="Enter"){R.preventDefault(),A($);return}T!==null&&(R.preventDefault(),O(T))},W=(R,q)=>{const T={x:R.clientX,y:R.clientY},F=w.current;w.current=T,!(F&&F.x===T.x&&F.y===T.y)&&q!==($==null?void 0:$.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:v,className:`qo${u?" closing":""}`,onClick:R=>R.stopPropagation(),onAnimationEnd:R=>{u&&R.target===R.currentTarget&&k()},role:"dialog","aria-modal":"true","aria-label":"Quick open",children:[r.jsxs("div",{className:"qo-field",children:[r.jsx(PD,{}),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:R=>{a(R.target.value),l(null)},onKeyDown:M,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1}),r.jsx("button",{type:"button",className:"qo-esc",onClick:b,"aria-label":"Close",children:"esc"})]}),r.jsxs("div",{ref:p,className:"qo-list",id:"qo-list",role:"listbox","aria-label":"Results",tabIndex:-1,onMouseDown:R=>R.preventDefault(),children:[x.map(R=>r.jsxs("div",{className:"qo-group",role:"group","aria-labelledby":`qo-cap-${R.section}`,children:[r.jsx("div",{className:"qo-caption",id:`qo-cap-${R.section}`,role:"presentation",children:R.title}),R.items.map((q,T)=>{B++;const F=B,{item:D}=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=>W(K,D.id),onClick:()=>A(q),children:[r.jsx("span",{className:"qo-icon","aria-hidden":!0,children:D.tone?r.jsx("span",{className:`qo-dot ${D.tone}`}):D.glyph}),r.jsxs("span",{className:"qo-text",children:[r.jsx("span",{className:"qo-title",children:r.jsx(BQ,{text:D.title,hits:q.hits})}),D.subtitle&&r.jsx("span",{className:"qo-sub",children:D.subtitle})]}),D.keyCap&&r.jsx("kbd",{className:"qo-key",children:D.keyCap}),r.jsx("span",{className:"qo-tag",children:D.tag})]},D.id)})]},R.section)),C.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:C.length===1?"1 result":`${C.length} results`}),r.jsxs("span",{className:"qo-foot-keys",children:[$&&r.jsxs("span",{className:"qo-foot-act",children:[$.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()?C.length===1?"1 result":`${C.length} results`:""})]})})}function UQ(e,t,n){if(n<=0||sm(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 xs=4,zt=8;function hm(e,t,n){const s=n.width-zt-(e.right+xs),a=e.left-xs-zt,o=t.width<=s||s>=a?"right":"left",i=o==="right"?e.right+xs:e.left-xs-t.width,l=n.height-zt*2,u=t.height<=l,h=u?t.height:Math.max(0,l),f=Math.max(zt,Math.min(e.top,n.height-zt-h)),p=Math.max(zt,Math.min(i,n.width-zt-t.width));return{top:f,left:p,side:o,maxHeight:u?null:h}}function WQ(e,t,n,s=0){const a=n.width-zt-e.right-xs,o=e.left-xs-zt;if(t.width<=Math.max(a,o))return hm(e,t,n);const i=Math.max(0,Math.min(e.top-xs,n.height-zt)-zt);if(i<=0||i<Math.min(t.height,s))return null;const l=Math.min(t.height,i);return{side:"above",top:Math.max(zt,Math.min(e.top-xs,n.height-zt)-l),left:Math.max(zt,Math.min(e.right-t.width,n.width-zt-t.width)),maxHeight:l<t.height?l:null}}function DD(e,t,n,s="end"){const a=n.height-zt-(e.bottom+xs),o=e.top-xs-zt,i=t.height<=a||a>=o?"below":"above",l=i==="below"?a:o,u=t.height<=l,h=u?t.height:Math.max(0,l),f=i==="below"?e.bottom+xs:e.top-xs-h,p=Math.max(zt,Math.min(s==="start"?e.left:e.right-t.width,n.width-zt-t.width));return{top:Math.max(zt,f),left:p,side:i,maxHeight:u?null:h}}function HQ(e,t,n){return!(!e||t!=null&&t.contains(e)||n!=null&&n.contains(e))}function zQ(e,t,n){const s=g.useRef(t);s.current=t;const a=g.useRef(n);a.current=n,g.useEffect(()=>{const o=i=>{HQ(i.target,e.current,s.current())&&a.current()};return window.addEventListener("pointerdown",o,!0),()=>window.removeEventListener("pointerdown",o,!0)},[e])}const FD='[role="menuitem"]';function lA(e){return e?Array.from(e.querySelectorAll(FD)).filter(t=>!t.disabled):[]}function vd({anchorId:e,align:t="end",boundaryId:n,portalRootId:s,id:a,className:o,role:i,labelledBy:l,start:u="first",focusRef:h,fallbackFocus:f,onClose:p,children:m}){const w=g.useRef(p);w.current=p;const b=g.useRef(f);b.current=f;const k=gt(()=>{var S;(S=document.getElementById(e))==null||S.focus(),w.current()},{popover:!0,focusRef:h}),v=g.useCallback(()=>{var M,W,B;const S=k.current;if(!S)return;const _=document.getElementById(e);if(!_){w.current();return}if(_.getClientRects().length===0){S.contains(document.activeElement)&&((W=(M=b.current)==null?void 0:M.call(b))==null||W.focus()),w.current();return}const $=_.getBoundingClientRect(),A=n?(B=document.getElementById(n))==null?void 0:B.getBoundingClientRect():null;if(A&&($.bottom<=A.top||$.top>=A.bottom)){S.contains(document.activeElement)&&_.focus({preventScroll:!0}),w.current();return}S.style.maxHeight="";const O=DD($,{width:S.offsetWidth,height:S.offsetHeight},{width:window.innerWidth,height:window.innerHeight},t);S.style.top=`${O.top}px`,S.style.left=`${O.left}px`,S.style.maxHeight=O.maxHeight==null?"":`${O.maxHeight}px`,S.dataset.side=O.side},[e,t,n,k]);g.useLayoutEffect(()=>{v()}),g.useEffect(()=>{const S=_=>{var $;($=k.current)!=null&&$.contains(_.target)||v()};return window.addEventListener("scroll",S,!0),window.addEventListener("resize",v),()=>{window.removeEventListener("scroll",S,!0),window.removeEventListener("resize",v)}},[v,k]),zQ(k,()=>document.getElementById(e),p),g.useEffect(()=>{var _;if(i!=="menu")return;const S=lA(k.current);(_=u==="last"?S[S.length-1]:S[0])==null||_.focus()},[]);const N=S=>{var _;if(i==="menu"&&S.key==="Tab"){S.stopPropagation(),(_=document.getElementById(e))==null||_.focus(),S.shiftKey&&S.preventDefault(),w.current();return}if(i==="menu"){const $=lA(k.current),A=UQ(S,$.indexOf(document.activeElement),$.length);A.kind==="focus"&&(S.preventDefault(),$[A.index].focus())}S.key.length===1&&S.stopPropagation()},x=S=>{S.target.closest("button, input, select, textarea, code")||S.preventDefault()},C=S=>{if(i!=="menu"||S.pointerType==="touch")return;const _=S.target.closest(FD);_&&!_.disabled&&document.activeElement!==_&&_.focus({preventScroll:!0})};return vt.createPortal(r.jsx("div",{ref:k,id:a,className:`anchored-popover${o?` ${o}`:""}`,role:i,"aria-labelledby":l,onKeyDown:N,onMouseDown:x,onPointerMove:C,children:m}),(s?document.getElementById(s):null)??document.body)}const VQ=450,GQ=400,KQ=100,rf=8,YQ={right:"hint hint-right",left:"hint hint-left",below:"hint hint-below",above:"hint hint-above"},iu=8;let ea=null,cA=-1/0;function XQ(e,t,n){return n||e-t<GQ}function ZQ(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+rf,top:u(h)}:e==="left"?{left:t.left-rf-n,top:u(h)}:e==="above"?{left:l(f),top:t.top-rf-s}:{left:l(f),top:t.bottom+rf}}const JQ={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&&(cA=performance.now()),null))},[]),u=g.useCallback((w,b,k)=>{window.clearTimeout(a.current),window.clearTimeout(o.current);const v=ea!==null,N=XQ(performance.now(),cA,v),x=()=>{var S;ea&&ea!==l&&ea(),ea=l;const C=t==="dialog"?((S=w.closest('[role="dialog"]'))==null?void 0:S.getBoundingClientRect())??null:null;s({spec:b,box:w.getBoundingClientRect(),within:C,instant:N})};k||N?x():a.current=window.setTimeout(x,VQ)},[l,t]),h=g.useCallback(()=>{window.clearTimeout(a.current),window.clearTimeout(o.current),o.current=window.setTimeout(l,KQ)},[l]),f=n!==null;g.useEffect(()=>{if(!f)return;const w=rn.push(l,0,"popover");return window.addEventListener("resize",l),window.addEventListener("scroll",l,!0),()=>{w(),window.removeEventListener("resize",l),window.removeEventListener("scroll",l,!0),ea===l&&(ea=null)}},[f,l]),g.useEffect(()=>()=>{window.clearTimeout(a.current),window.clearTimeout(o.current),ea===l&&(ea=null)},[l]),g.useLayoutEffect(()=>{const w=i.current;if(!w||!n)return;const{width:b,height:k}=w.getBoundingClientRect(),v=ZQ(e,n.box,b,k,n.within);w.style.left=`${v.left}px`,w.style.top=`${v.top}px`,w.style.visibility="visible"},[n,e]);const p=g.useCallback(w=>({onPointerEnter:b=>{w&&b.pointerType==="mouse"&&u(b.currentTarget,w,!1)},onPointerLeave:h,onPointerDown:l,onFocus:b=>{w&&b.currentTarget.matches(":focus-visible")&&u(b.currentTarget,w,!0)},onBlur:l}),[u,h,l]),m=n&&vt.createPortal(r.jsxs("span",{ref:i,className:YQ[e]+JQ[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 fm="(max-width: 640px)",QQ=600,eee=588,tee=40;function nee(e){if(typeof window>"u")return!1;const t=window.innerWidth;return t>0?t-2*tee-e-eee<QQ:!1}function B1(){if(typeof window>"u"||typeof window.matchMedia!="function")return!1;try{return window.matchMedia(fm).matches}catch{return!1}}function LN(e,t){return e&&(t||!e.single)?e:void 0}function see(e,t,n){var i;const s=(i=LN(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 BD={stripe:"rail-btn rail-btn-stripe",dock:"rail-btn rail-btn-dock",bar:"rail-btn rail-btn-bar"},ree={left:"edge-rail edge-rail-left",right:"edge-rail edge-rail-right"},aee={vertical:"ArrowDown",horizontal:"ArrowRight"},oee={vertical:"ArrowUp",horizontal:"ArrowLeft"};function qD(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===aee[t]?h=(u+1)%l.length:i.key===oee[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 IN(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 ON({item:e,index:t,tabbable:n,onFocusIndex:s,hint:a,variant:o}){var h;const i=An(),l=a.bind(see(e,i,o!=="stripe")),u=e.kind==="panel";return r.jsxs("button",{ref:e.buttonRef,type:"button","data-rail-item":e.id,className:BD[o],tabIndex:o==="bar"?void 0:n?0:-1,"aria-label":e.ariaLabel,"aria-keyshortcuts":(h=LN(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 uA({side:e,label:t,groups:n}){const s=ac(e==="left"?"right":"left"),a=n.filter(u=>u.length>0),o=qD(a.flat().length,"vertical"),i=g.useRef(null);IN(i);let l=0;return r.jsxs("div",{ref:i,className:ree[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(ON,{item:f,index:p,tabbable:p===o.active,onFocusIndex:o.setCurrent,hint:s,variant:"stripe"},f.id)})},u[0].id)}),s.node]})}const af="dock-more",dA="dock-more-menu";function iee({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(af))==null||f.focus(),o(null),h.onPress()};return r.jsxs(r.Fragment,{children:[r.jsxs("button",{id:af,type:"button","data-rail-item":"more",className:BD.dock,tabIndex:t?0:-1,"aria-label":`More: ${e.map(h=>h.ariaLabel).join(", ")}`,"aria-haspopup":"menu","aria-expanded":i,"aria-controls":i?dA: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(vd,{anchorId:af,id:dA,className:"ap-pop",role:"menu",labelledBy:af,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 lee({items:e,more:t}){const n=ac("above"),s=qD(e.length+1,"horizontal"),a=g.useRef(null);return IN(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(ON,{item:o,index:i,tabbable:i===s.active,onFocusIndex:s.setCurrent,hint:n,variant:"dock"},o.id)),r.jsx(iee,{items:t,index:e.length,tabbable:s.active===e.length,onFocusIndex:s.setCurrent}),n.node]})}function cee({items:e,side:t="below"}){const n=ac(t),s=g.useRef(null);return IN(s),r.jsxs("div",{ref:s,className:"utility-run",children:[e.map((a,o)=>r.jsx(ON,{item:a,index:o,tabbable:!0,onFocusIndex:uee,hint:n,variant:"bar"},a.id)),n.node]})}function uee(){}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 dee(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 hA="settings-tab-";function hee(e,t){return e!=null&&e.startsWith(hA)?e===`${hA}${t}`?null:t:null}const fee={open:!1,section:"general"};function pee(e,t,n){const s={open:!0,section:t??e.section};return n?{...s,landOn:n}:s}function Wa(e,t){return()=>{e(),t()}}function mee(e){return e.key===","&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey}function gee(e){return po(e)?"⌘,":"Ctrl+,"}function yee(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 wee="https://code.claude.com/docs/en/settings-reference",UD=[{id:"sessions",title:"Your sessions"},{id:"memory",title:"Memory and history"},{id:"git",title:"Git"},{id:"terminal",title:"Terminal"},{id:"updates",title:"Updates"}],WD=[{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 fA(e){return e===3650?"10 years":e===365?"1 year":e===1?"1 day":`${e} days`}const HD="agent-dag.character",Of=[{id:"deck",name:"Deck companion"},{id:"fox",name:"Fox"},{id:"penguin",name:"Penguin"}];function xee(e){return e==="fox"||e==="penguin"?e:"deck"}function vee(){return xee(nt(HD))}const bee="With no deck tab open, get a notification wherever a sound would have played.",kee="With the ccdeck window closed, get a notification wherever a sound would have played.";function jee(e){return e?kee:bee}const Nee="Held off for this run — the deck was started with alerts disabled. Your choice is saved for the next start.",zD=[{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"}],See="For the Claude and Codex accounts you're on, whether or not the deck is open.",Cee="Held off for this run too.",pA="Get notified when you're away from this tab.";function _ee(e){switch(e){case"granted":return{status:"Enabled",ask:!1,ok:!0,note:pA};case"default":return{status:null,ask:!0,ok:!1,note:pA};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 Eee=1024*1024,mA=5,VD=.8,q1=24,Tee="agent-dag.soundCustom.done",Aee="agent-dag.soundCustom.needs-input",Ru={done:Tee,"needs-input":Aee};function td(e){if(e.kind!=="audio")return e;const{bytes:t,...n}=e;return n}function gA(e){return!e||!/^[a-zA-Z0-9._-]{1,96}$/.test(e)?null:e}function Ree(e){return{done:gA(e(Ru.done)),"needs-input":gA(e(Ru["needs-input"]))}}function Mee(e,t){return{done:e.done===t?null:e.done,"needs-input":e["needs-input"]===t?null:e["needs-input"]}}function $ee(e){return e.done&&e.done===e["needs-input"]?e.done:null}const Lee={wav:"audio/wav",wave:"audio/wav",mp3:"audio/mpeg",ogg:"audio/ogg",oga:"audio/ogg",webm:"audio/webm",m4a:"audio/mp4",mp4:"audio/mp4"},GD=new Set(["audio/wav","audio/x-wav","audio/mpeg","audio/mp3","audio/ogg","audio/webm","audio/mp4"]);function KD(e,t){const n=t.toLowerCase().split(";")[0].trim();if(GD.has(n))return n;const s=e.toLowerCase().split(".").pop()??"";return Lee[s]??n}function yA(e,t){const n=KD(e.name,e.type);if(!GD.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>Eee)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>mA)return`Audio must be ${mA} seconds or shorter.`}return null}function U1(e){return e>=q1?`There are already ${q1} custom sounds. Delete one first.`:null}function Iee(e,t){const n=e.indexOf(t);return n<0?null:e[n+1]??e[n-1]??null}function Oee(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,VD/t)}function YD(){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 Pee(e,t,n=YD()){var h;const s=((h=e.name)==null?void 0:h.trim())||"Custom sound",a=yA({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=yA({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:KD(s,e.type),duration:i.duration,normalizationGain:Oee(u),bytes:o}}function Dee(e,t=YD()){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 Fee="ccdeck-notification-audio",Bee=2,Zs="assets",Nr="summaries";function bd(){return typeof window<"u"?window.ccdeckNotificationAudio??null:null}function qee(){return new Promise((e,t)=>{const n=indexedDB.open(Fee,Bee);n.onupgradeneeded=s=>{const a=n.result,o=a.objectStoreNames.contains(Zs)?n.transaction.objectStore(Zs):a.createObjectStore(Zs,{keyPath:"id"});if(a.objectStoreNames.contains(Nr))return;const i=a.createObjectStore(Nr,{keyPath:"id"});if(s.oldVersion<1)return;const 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 kd(e,t,n){const s=await qee();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 Uee(){const e=bd();return e?e.list():typeof indexedDB>"u"?[]:await kd([Nr],"readonly",t=>t.objectStore(Nr).getAll())??[]}async function Wee(e){const t=bd();return t?t.get(e):typeof indexedDB>"u"?null:await kd([Zs],"readonly",n=>n.objectStore(Zs).get(e))??null}async function wA(e){const t=bd();if(t){await t.put(e);return}if(typeof indexedDB>"u")throw new Error("Local audio storage is unavailable in this browser.");await kd([Zs,Nr],"readwrite",n=>{n.objectStore(Zs).put(e),n.objectStore(Nr).put(td(e))})}async function Hee(e,t){const n=bd();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 kd([Zs,Nr],"readwrite",s=>{const a=s.objectStore(Zs),o=a.get(e);o.onsuccess=()=>{const i=o.result;if(!i)return;const l={...i,name:t};a.put(l),s.objectStore(Nr).put(td(l))}})}async function zee(e){const t=bd();if(t){await t.remove(e);return}typeof indexedDB>"u"||await kd([Zs,Nr],"readwrite",n=>{n.objectStore(Zs).delete(e),n.objectStore(Nr).delete(e)})}const Mu=["done","needs-input"],Vee=[{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}]}],Gee=[{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}]}],PN={done:Vee,"needs-input":Gee},es="two";function W1(e,t){const n=PN[e];return n.find(s=>s.id===t)??n.find(s=>s.id===es)??n[0]}function XD(e,t){return PN[e].some(s=>s.id===t)?t:es}W1("done",es).notes,W1("needs-input",es).notes;const xA=.04,ZD=.24,Pf=0,mp=100,DN=5,wi=50;function pm(e,t=DN){if(!Number.isFinite(e))return wi;const n=Math.round(e/t)*t;return Math.min(mp,Math.max(Pf,n))}function JD(e,t=DN){if(e==null)return wi;const n=e.trim();return/^-?\d+(\.\d+)?$/.test(n)?pm(Number(n),t):wi}function FN(e){const t=pm(e),n=xA+(ZD-xA)*(t/mp);return Math.round(n*1e4)/1e4}function Kee(e,t){const n=t.trim,s=typeof n=="number"&&Number.isFinite(n)&&n>0&&n<=1?n:1;return Math.round(FN(e)*s*1e4)/1e4}const Yee=.012,vA=1e-4;function Xee(e){return Math.min(1,FN(e)/ZD)}function Zee(e,t){const n=e*(FN(t)/VD);return Math.max(1e-4,n)}const Jee=160,Qee="agent-dag.soundLevel.done",ete="agent-dag.soundLevel.needs-input",tte="agent-dag.soundFigure.done",nte="agent-dag.soundFigure.needs-input",QD={done:Qee,"needs-input":ete},gp={done:tte,"needs-input":nte},bA={done:{level:wi,figure:es},"needs-input":{level:wi,figure:es}};function ste(e){const t=n=>({level:JD(e(QD[n])),figure:XD(n,e(gp[n]))});return{done:t("done"),"needs-input":t("needs-input")}}function rte(e,t){return(e??bA)[t]??bA[t]}const ate={Stop:"done",Notification:"needs-input"};function ote(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:Jt(ate,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"}},gr=Object.keys(oc);function ite(e){return gr[(gr.indexOf(e)+1)%gr.length]}const e5="agent-dag.theme";function lte(e,t=!1){return typeof e=="string"&&Object.hasOwn(oc,e)?e:"rider-black"}function cte(){return lte(nt(e5))}const t5="section:";function mm(e){return e.id.startsWith(t5)}const ute={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"]},dte={done:"Turn finished","needs-input":"Claude is asking"},hte={done:["done","complete","finished","end of turn","volume","preview","chime","tone"],"needs-input":["question","needs input","permission","waiting","volume","preview","chime","tone"]},fte={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"]},BN=e=>{var t;return((t=ed.find(n=>n.id===e))==null?void 0:t.label)??e};function pte(e){return{id:`${t5}${e}`,section:e,label:BN(e),keywords:ute[e],...e==="claude"?{claudeOnly:!0}:{}}}function mte(){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"]},...gr.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",...Of.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"]},...zD.map(({kind:t,label:n})=>({id:t,section:"notifications",group:"Accounts",label:n,keywords:fte[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:dte[t],keywords:hte[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:[...WD.map(t=>{var n;return{id:`claude-${t.id}`,claudeOnly:!0,section:"claude",group:(n=UD.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})=>[pte(t),...e[t]])}const H1=mte();function n5(e,t="all",n){return e&&t==="all"&&!n?H1:H1.filter(s=>(e||!s.claudeOnly)&&(!n||!s.id.startsWith("integration-")||n.has(s.id.slice(12)))&&(s.section!=="integrations"||t==="all"||t==="connections"&&(mm(s)||s.id==="integrations-connections")))}function qN(e){if(mm(e))return"Section";const t=BN(e.section);return e.group&&e.group!==e.label?`${t} › ${e.group}`:t}function gte(e){return`${e.label}, ${qN(e).replace(/ › /g,", ")}`}function bu(e){return e.normalize("NFD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/\s+/g," ").trim()}function of(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 yte(e,t){const n=bu(e.label);if(n.startsWith(t))return 0;if(of(n,t))return 1;const s=e.keywords.map(bu);if(s.some(i=>of(i,t)))return 2;const a=[bu(BN(e.section)),...e.group?[bu(e.group)]:[]];if(a.some(i=>of(i,t)))return 3;const o=t.split(" ");if(o.length>1){const i=[n,...s,...a];if(o.every(l=>i.some(u=>of(u,l))))return 4}return null}const wte=12;function xte(e,t=H1){const n=bu(e);return n?t.map((s,a)=>({entry:s,at:a,score:yte(s,n)})).filter(s=>s.score!==null).sort((s,a)=>s.score-a.score||s.at-a.at).slice(0,wte).map(s=>s.entry):[]}function s5(e,t){const n=t.trim();return e===0?`No setting matches “${n}”.`:e===1?`1 setting matches “${n}”`:`${e} settings match “${n}”`}function vte(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 gm({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 bte={"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"]},kte=new Set(["accounts","browser-watch","radar-open","tour","feedback"]);function jte(e,t){var a;const n=r.jsx(gm,{section:e.section});if(mm(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=qN(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 Nte(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,...bte[e.id]??[],...e.detail?[e.detail]:[]],tag:n?e.open?"Shown":"Panel":"Dialog",verb:n?e.open?"Hide panel":"Show panel":"Open",keyCap:(a=LN(e.key,t))==null?void 0:a.cap,glyph:e.glyph,run:e.onPress}}function Ste(e,t){const n=e.cwdBasename&&e.cwdBasename!==e.label?` · ${e.cwdBasename}`:"";return e.waiting&&En(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 Cte(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}=Ste(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(Nte(a,e.singleKeys));for(const a of e.settings)a.id.startsWith("theme-")||kte.has(a.id)||s.push(jte(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(IQ,{}),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(OQ,{}),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(PQ,{}),run:e.togglePause},{id:"action:keys",section:"actions",title:"Keyboard shortcuts",keywords:["keys","help","?"],tag:"Action",verb:"Open",keyCap:t("?"),glyph:r.jsx(gm,{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(OD,{}),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(DQ,{}),run:e.clear});for(const a of gr){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 bt=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`:""}`},_te=e=>e<1024?`${e} B`:e<1048576?`${(e/1024).toLocaleString(void 0,{maximumFractionDigits:1})} KB`:`${(e/1048576).toLocaleString(void 0,{maximumFractionDigits:1})} MB`,Ete=e=>new Date(e).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});async function yp(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 kA={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(kA,e))return kA[e];const t=/^(npm|pnpm|yarn|bun) run (.+)$/.exec(e);if(t)return`Runs the “${t[2]}” script`;const n=r5(e);return n?`From the ${n.server} MCP server`:null}function r5(e){const t=/^mcp__(.+?)__(.+)$/.exec(e);return t?{server:t[1],tool:t[2]}:null}const ao=e=>{var t;return((t=r5(e))==null?void 0:t.tool)??e},Tte=[{id:"calls",label:"Most used"},{id:"time",label:"Most time"},{id:"slowest",label:"Slowest"},{id:"failed",label:"Failures"}];function wp(e,t){return t==="calls"?e.calls:t==="time"?e.totalMs:t==="slowest"?e.medianMs:e.failed}const Ate=(e,t)=>{const n=t.trim().toLowerCase();return!n||e.operation.toLowerCase().includes(n)||(Zl(e.operation)??"").toLowerCase().includes(n)};function rw(e,t,n=""){return e.filter(s=>Ate(s,n)).sort((s,a)=>{const o=wp(s,t),i=wp(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)}%`},ym=e=>e.failed>0&&e.completed>0?ki(e.failed,e.completed):null;function Rte(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:`${bt(a.totalMs)} over ${kt(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 ${kt(o.completed,"call")} failed (${ym(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 ${bt(i.medianMs)} per call; the longest took ${bt(i.maxMs)}.`}),n}const kt=(e,t)=>`${e.toLocaleString()} ${t}${e===1?"":"s"}`,nd={1:"24 hours",7:"7 days",30:"30 days",90:"90 days"},Mte={all:"your agents",claude:"Claude",codex:"Codex"};function $te(e,t,n){return{lead:`In the last ${nd[n]??`${n} days`}, ${Mte[t]} made`,calls:kt(e.total,"tool call"),time:e.totalMs?bt(e.totalMs):null,failed:e.failed,failedShare:e.failed&&e.completed?ki(e.failed,e.completed):null}}const oa=e=>new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric"});function a5(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 z1=e=>new Date(e).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"});function wm(e,t=Date.now()){const n=a5(e,t);return n==="Today"||n==="Yesterday"?`${n} ${z1(e)}`:`${n}, ${z1(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 Lte({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]),vt.createPortal(r.jsx("div",{className:"ta-drawer-backdrop",role:"presentation",...o,children:r.jsx("div",{className:"ta-drawer","data-keyboard":e||void 0,ref:a,role:"dialog","aria-modal":"true","aria-labelledby":"tool-operation-heading",children:n})}),document.body)}function Ite({keyboard:e,itemKey:t,onClose:n,children:s}){const a=g.useRef(null),o=g.useRef(n);return o.current=n,g.useEffect(()=>rn.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 o5(e){return ic("(max-width: 700px)")?r.jsx(Lte,{...e}):r.jsx(Ite,{...e})}const Xa=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString(void 0,{timeZone:"UTC",month:"short",day:"numeric"});function Ote(e,t){return e.status==="outside-history"?`${Xa(e.date)} · before recording started`:e.calls?`${Xa(e.date)} · ${kt(e.calls,t)}${e.medianMs!=null?` · usually ${bt(e.medianMs)}`:""}`:`${Xa(e.date)} · no ${t}s`}function i5({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 Pte({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 ${Xa(n[0].date)} to ${Xa(n.at(-1).date)}. The busiest day was ${Xa(l.date)} with ${kt(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:Xa(n[0].date)}),r.jsx("span",{children:Xa(n.at(-1).date)})]}),r.jsx("p",{className:"ta-note ta-history-day","aria-live":"polite",children:Ote(i,t)})]})}function l5(){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"}),c5=({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))}),Dte={success:"Done",failed:"Failed",unmatched:"No result"},Fte=({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 Bte(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 qte({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=ym(e),b=(n||s)&&!t,k=v=>s?r.jsx($u,{}):v;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(l5,{})})]}),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:k(e.calls.toLocaleString())})]}),r.jsxs("div",{children:[r.jsx("dt",{children:"Total time"}),r.jsx("dd",{children:k(bt(e.totalMs))})]}),r.jsxs("div",{children:[r.jsx("dt",{children:"Usually"}),r.jsx("dd",{children:k(bt(e.medianMs))})]}),r.jsxs("div",{children:[r.jsx("dt",{children:"Failed"}),r.jsx("dd",{"data-bad":!s&&e.failed>0||void 0,children:k(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:[Bte(e),e.maxMs!==null&&e.measured>1&&r.jsxs(r.Fragment,{children:[" · longest ",bt(e.maxMs)]}),e.unmatched>0&&r.jsxs(r.Fragment,{children:[" · ",kt(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(Pte,{history:t.history},e.operation):b&&a&&r.jsx(i5,{}),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"})]})]}),b&&r.jsx(c5,{label:"Reading calls"}),t&&r.jsxs(r.Fragment,{children:[r.jsx("ul",{className:"ta-calls",children:p.map(v=>r.jsxs("li",{"data-state":v.state,children:[r.jsx("span",{className:"ta-call-when",children:wm(v.capturedAt,m)}),r.jsx("span",{className:"ta-call-who",children:v.provider==="claude"?"Claude":"Codex"}),r.jsx("span",{className:"ta-call-took",children:bt(v.durationMs)}),r.jsxs("span",{className:"ta-call-state",children:[r.jsx(Fte,{state:v.state}),Dte[v.state]]})]},v.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 V1="agent-dag.text-size",G1="agent-dag.density",jA=["smallest","smaller","default","larger","largest"],NA=["tightest","tighter","compact","default","comfortable"],UN={smallest:-2,smaller:-1,default:0,larger:2,largest:4};function WN(){var e,t;return HN(typeof document>"u"?null:(t=(e=document.documentElement)==null?void 0:e.dataset)==null?void 0:t.textSize)}function HN(e){return e==="smallest"||e==="smaller"||e==="larger"||e==="largest"?e:"default"}function u5(e){return e==="tightest"||e==="tighter"||e==="compact"||e==="comfortable"?e:"default"}const Ute=()=>HN(nt(V1)),Wte=()=>u5(nt(G1)),xr={min:320,standard:380,max:1600},Hte=420,zte=8,d5="agent-dag.tool-activity.details-width";function lu(e,t){const n=Math.max(xr.min,Math.min(xr.max,t-Hte-zte));return Math.round(Math.min(n,Math.max(xr.min,Number.isFinite(e)?e:xp())))}function xp(){return xr.standard+12*Math.max(0,UN[WN()])}function h5(){const e=Number(nt(d5));return Number.isFinite(e)&&e>=xr.min&&e<=xr.max?Math.round(e):xp()}function f5(e){st(d5,String(Math.round(e)))}function p5({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 b,k;(b=t.current)==null||b.style.setProperty("--ta-details-w",`${w}px`),(k=s.current)==null||k.setAttribute("aria-valuenow",String(w))},u=w=>{l(w),n(w)},h=w=>{var b;w.button===0&&(w.preventDefault(),w.currentTarget.setPointerCapture(w.pointerId),a.current={x:w.clientX,width:i,room:o(),last:i},(b=t.current)==null||b.setAttribute("data-resizing",""))},f=w=>{const b=a.current;b&&(b.last=lu(b.width+b.x-w.clientX,b.room),l(b.last))},p=()=>{var b;const w=a.current;w&&(a.current=null,(b=t.current)==null||b.removeAttribute("data-resizing"),u(w.last))},m=w=>{const b=w.shiftKey?64:16,k=w.key==="ArrowLeft"?i+b:w.key==="ArrowRight"?i-b:w.key==="Home"?xr.min:w.key==="End"?xr.max:w.key==="Enter"?xp():null;k!==null&&(w.preventDefault(),u(lu(k,o())))};return r.jsx("div",{ref:s,className:"ta-splitter",role:"separator","aria-orientation":"vertical","aria-label":"Details width","aria-controls":"tool-operation-inspector","aria-valuemin":xr.min,"aria-valuemax":lu(xr.max,o()),"aria-valuenow":i,tabIndex:0,title:"Drag to resize · double-click for the standard width",onPointerDown:h,onPointerMove:f,onPointerUp:p,onPointerCancel:p,onLostPointerCapture:p,onDoubleClick:()=>u(lu(xp(),o())),onKeyDown:m})}const m5="(starting tools)",Vte={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 Gte(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,...Vte[n],ms:t[n],share:e.totalMs?ki(t[n],e.totalMs):"0%"}))}const SA=e=>e>=36e5?`${Math.round(e/36e5).toLocaleString()} h`:bt(e);function g5(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 Kte=(e,t=.8)=>g5(e.map(n=>({id:n.id,value:n.ms})),t);function CA(e,t){if(t==="claude")return e.replies.count?`Usually answers in ${bt(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===m5?"Mostly starting tools":t==="you"?s==="AskUserQuestion"?"Mostly answering questions":s==="ExitPlanMode"?"Mostly approving plans":`Mostly approving ${ao(s)}`:`Mostly ${ao(s)}`}function Yte(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),...Xte(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 Xte(e,t){return e===m5?{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 Zte(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 Jte={overloaded:"Claude overloaded",rate_limit:"usage limit",server_error:"server error",authentication_failed:"signed out"};function Qte(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])=>`${Jte[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"}),y5=()=>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 ene({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=Gte(e),m=x=>{i(C=>C===x?null:x),u(x)},w=p.find(x=>x.id===l)??null,b=p.find(x=>x.id===(h??o))??null,k=n!==void 0&&n>t,v=`${kt(e.turns,"Claude Code turn")}${k?` since ${oa(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:v})]});return e.turns?r.jsxs(r.Fragment,{children:[r.jsxs("section",{className:"tt","aria-labelledby":"tt-title","data-focus":b==null?void 0:b.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:Kte(p).map(x=>r.jsx("circle",{className:"tt-arc","data-lane":x.id,"data-on":(b==null?void 0:b.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:b?r.jsxs(r.Fragment,{children:[r.jsx("strong",{children:b.share}),r.jsx("span",{children:b.label})]}):r.jsxs(r.Fragment,{children:[r.jsx("strong",{children:SA(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}, ${bt(x.ms)}. ${CA(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:SA(x.ms)}),r.jsx(y5,{}),r.jsx("span",{className:"tt-lane-fact",children:CA(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:[bt(w.ms)," · ",w.share," of the time"]})]}),r.jsx("p",{className:"ta-note tt-hint",children:w.hint}),w.id==="claude"?r.jsx(nne,{split:e}):r.jsx(tne,{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",k?` — measured from ${oa(n)}`:"","."]})})]})}function tne({split:e,lane:t,selected:n,onPick:s}){const[a,o]=g.useState(!1),i=Yte(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(y5,{})]}),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:[bt(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}: ${bt(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}: ${bt(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 nne({split:e}){const{replies:t}=e,n=Zte(e),s=Qte(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:bt(t.medianMs)})]}),r.jsxs("div",{children:[r.jsx("dt",{children:"Slowest 1 in 10"}),r.jsx("dd",{children:t.p90Ms===null?"—":`over ${bt(t.p90Ms)}`})]}),r.jsxs("div",{children:[r.jsx("dt",{children:"Longest"}),r.jsx("dd",{children:bt(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?`${kt(u.count,"reply")} · usually ${bt(u.medianMs)}`:"no replies"}`:n.length?`Slower than usual on ${n.map(f=>`${Wo(f.date)} (${bt(f.medianMs)})`).join(", ")} — the line is your usual ${bt(t.medianMs)}.`:`No day was clearly slower than your usual ${bt(t.medianMs)}.`})]}),s&&r.jsx("p",{className:"ta-note tt-stops",children:s})]})}const lf=864e5,sne=[{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 aw(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 w5(e){const{claude:t,codex:n}=e.providers;return t&&n?"Claude and Codex":n?"Codex":"Claude"}const jd=["agent","detected","typed"],vp={agent:"Picked by Claude",detected:"Picked by Codex",typed:"Typed by you"},rne=e=>e.origin==="typed"&&e.provider==="codex"?"Typed in Codex":vp[e.origin],x5=e=>jd.filter(t=>e[t]>0).map(t=>({id:t,text:`${e[t].toLocaleString()} ${vp[t][0].toLowerCase()}${vp[t].slice(1)}`})),ane=e=>x5(e).map(t=>t.text).join(", "),v5=(e,t)=>t==="codex"||!e.typedCommands||e.typedCommands==="on";function one(e,t){const n=e.rows.filter(o=>o.uses>0),s=n.reduce((o,i)=>o+i.uses,0),a=!v5(e,t);return jd.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:vp[o],uses:i,share:s?ki(i,s):"0%",fact:u}]})}function ine(e){const t=jd.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 lne(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 ${kt(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 ${kt(i.sessions,"session")}.`),v5(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 ${kt(i.typed,"time")}, never picked by ${w5(i)==="Codex"?"Codex":"Claude"} on its own. If it should be, its description needs the words you use.`),o>=21*lf&&a(n.filter(i=>i.uses>=3&&e.until-i.lastAt>=7*lf).sort((i,l)=>l.uses-i.uses)[0],"quiet","has gone quiet",i=>`${kt(i.uses,"use")}, none since ${oa(i.lastAt)}.`),o>=14*lf&&a(n.filter(i=>e.until-i.firstAt<7*lf).sort((i,l)=>l.uses-i.uses)[0],"new","is new this week",i=>`First used ${oa(i.firstAt)}, ${kt(i.uses,"use")} so far.`),s.slice(0,3)}const cne={all:"your agents",claude:"Claude",codex:"Codex"};function une(e,t,n){const s=e.rows.filter(a=>a.uses>0).length;return{lead:`In the last ${nd[n]??`${n} days`}, ${cne[t]} used`,skills:kt(s,"skill"),uses:e.total===1?"once":`${e.total.toLocaleString()} times`,failed:e.failed,repeats:e.repeats}}const dne=e=>e.countedSince>e.since;function hne(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 fne({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,b=e.agent+e.detected,k=e.agent&&e.detected?"an agent":e.detected?"Codex":"Claude",v=wm(e.lastAt,p).replace(/^(Today|Yesterday)/,$=>$.toLowerCase()),N=((_=t==null?void 0:t.history)==null?void 0:_.days.filter($=>$.status!=="outside-history"))??[],x=(n||s)&&!t,C=$=>s?r.jsx($u,{}):$,S=[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 ${w5(e)}`,r.jsx("br",{}),"Last used ",v]})})]}),r.jsx("button",{type:"button",className:"glyph-btn","aria-label":"Close details",onClick:i,children:r.jsx(l5,{})})]}),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:C(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:C(e.sessions.toLocaleString())})]}),r.jsxs("div",{"data-lane":"agent",children:[r.jsxs("dt",{children:["Picked by ",k]}),r.jsx("dd",{children:C(b.toLocaleString())})]}),r.jsxs("div",{"data-lane":"typed",children:[r.jsx("dt",{children:"Typed by you"}),r.jsx("dd",{children:C(e.typed.toLocaleString())})]})]}),!s&&(S.length>0||e.repeats>0)&&r.jsxs("p",{className:"ta-note",children:[S.join(" · "),e.repeats>0&&r.jsxs(r.Fragment,{children:[S.length>0&&" · ",kt(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(pne,{days:N},e.name):x&&a&&r.jsx(i5,{noun:"use"}),t&&(t.projects.length>0||t.projectless>0)&&r.jsx(mne,{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(c5,{label:"Reading uses"}),t&&r.jsxs(r.Fragment,{children:[r.jsx(gne,{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 pne({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 ${kt(s.uses,"use")}${s.uses?`: ${ane(s)}`:""}.`,children:[r.jsx("b",{className:"sa-days-max","aria-hidden":"true",children:kt(a,"use")}),e.map(i=>r.jsx("span",{"data-shown":i.date===o.date||void 0,onPointerEnter:()=>n(i.date),children:jd.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:[kt(o.uses,"use"),": ",x5(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 mne({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:kt(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:kt(s.uses,"use")}),r.jsx("b",{"aria-hidden":"true",style:{"--sa-share":Math.max(.02,s.uses/n)}})]},s.key))})]})}function gne({uses:e,now:t,sessionLabel:n,onOpenSession:s}){const a=[];for(const o of e){const i=a5(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:z1(i.at)}),r.jsxs("span",{className:"sa-use-what",children:[r.jsxs("span",{className:"sa-use-who",children:[r.jsx("i",{"aria-hidden":"true"}),rne(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 yne=()=>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 wne({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:kt(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:g5(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}, ${kt(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(yne,{}),r.jsx("span",{className:"tt-lane-fact",children:u.fact})]})},u.id))})]})]})}const _A=12,xne=()=>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}),vne={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 bne(e){return`${e.name}: ${kt(e.uses,"use")}, last used ${wm(e.lastAt)}${e.failed?`, ${e.failed.toLocaleString()} failed`:""}`}function kne({filters:e,provider:t,period:n,setPeriod:s,refresh:a,onStatus:o,sessionLabel:i,onOpenSession:l}){var Ke;an("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 b=g.useRef(!1),k=g.useRef(null),[v,N]=g.useState(!1),[x,C]=g.useState(null),[S,_]=g.useState(null),[$,A]=g.useState(!1),O=g.useRef(null),[M,W]=g.useState(null),[B,R]=g.useState(null),[q,T]=g.useState(!0),[F,D]=g.useState(!1),[K,V]=g.useState(""),[H,P]=g.useState(""),I=g.useRef(null),U=g.useRef(!1),Z=g.useRef(null),z=g.useRef(null),X=ic("(min-width: 960px)"),[Y,J]=g.useState(h5),Q=ye=>{J(ye),f5(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:(M==null?void 0:M.capturedAt)??null,hasData:!!M})},[q,F,M]),g.useEffect(()=>{const ye=new AbortController;let Fe=!0;const $e=window.setTimeout(()=>ye.abort(),65e3);return V(""),I.current!==te&&(W(null),R(null),N(!1)),U.current=!0,T(!0),(async()=>{try{const Re=await yp(te,ye.signal);if(Fe){I.current=te,W(Re);const rt=!b.current&&aw(Re.rows,m.current,w.current).find(He=>He.uses>0);rt?(b.current=!0,C(rt.name)):C(He=>{var se;return!He||Re.rows.some(ke=>ke.name===He)?He:((se=aw(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&&(U.current=!1,T(!1))}})(),()=>{Fe=!1,ye.abort(),window.clearTimeout($e),U.current=!1}},[te,a]),g.useEffect(()=>{if(R(Re=>(Re==null?void 0:Re.name)===x&&I.current===te?Re:null),P(""),!x||!M||q||U.current){D(!1);return}let ye=!0;const Fe=new AbortController,$e=window.setTimeout(()=>Fe.abort(),65e3);return D(!0),(async()=>{var Re;try{const rt=await yp(`${te}&skill=${encodeURIComponent(x)}&history=1&timeZone=${encodeURIComponent(Intl.DateTimeFormat().resolvedOptions().timeZone)}`,Fe.signal);ye&&((Re=rt.details)!=null&&Re.row?R(rt.details):C(null))}catch{ye&&P("Could not read the uses of this skill. Close it and open it again to retry.")}finally{window.clearTimeout($e),ye&&D(!1)}})(),()=>{ye=!1,Fe.abort(),window.clearTimeout($e)}},[x,M,q,te]);const de=g.useMemo(()=>M?one(M,t):[],[M,t]),oe=g.useMemo(()=>M?lne(M,t):[],[M,t]),re=S&&de.some(ye=>ye.id===S&&ye.uses>0)?S:null,he=g.useMemo(()=>aw((M==null?void 0:M.rows)??[],u,f).filter(ye=>!re||ye[re]>0),[M,u,f,re]),pe=v||f?he:he.slice(0,_A),Le=he.reduce((ye,Fe)=>Math.max(ye,Fe.uses),0),ge=M==null?void 0:M.rows.find(ye=>ye.name===x);ge&&(k.current=ge);const ve=ge??(x&&!M&&((Ke=k.current)==null?void 0:Ke.name)===x?k.current:void 0),je=!!M&&M.failed>0,Ee=ye=>Fe=>{O.current=Fe.currentTarget,A(Fe.detail===0),C($e=>$e===ye?null:ye)},xe=()=>{const ye=x;C(null),requestAnimationFrame(()=>{var Re,rt;const Fe=O.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=M&&une(M,t,n),De=M&&dne(M),We=M&&hne(M,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&&!M&&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:[M&&"Showing the last numbers. ",K]})}),M&&Ie&&(M.total===0&&M.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 ",oa(M.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}),M.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:[kt(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 ",oa(M.countedSince),", so the days before it are empty rather than unused."]}),We&&r.jsx("p",{className:"ta-note sa-typed-note",children:We}),(!M.storageOk||M.dropped>0||M.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.",!M.storageOk&&" Check free disk space."]}),(oe.length>0||M.total>0)&&r.jsxs("div",{className:"ta-glance","data-single":!(oe.length>0&&M.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:vne[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))})]}),M.total>0&&r.jsx(wne,{shares:de,total:M.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 ${M.rows.length.toLocaleString()}`:M.rows.length.toLocaleString()})]}),r.jsxs("label",{className:"ta-search",children:[r.jsx(xne,{}),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:sne.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":bne(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:[ine(ye),kt(ye.sessions,"session"),ye.repeats>0&&kt(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:jd.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 "}),wm(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&&!v&&he.length>_A&&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 ",oa(M.countedSince)," and kept with the tool history for ",M.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(p5,{width:Y,workspace:z,onCommit:Q}),ve&&r.jsx(o5,{keyboard:$,itemKey:ve.name,onClose:xe,children:r.jsx(fne,{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 EA=12,jne=[{id:"all",label:"All agents"},{id:"claude",label:"Claude"},{id:"codex",label:"Codex"}],TA={tools:"Tool activity",skills:"Skill activity"},Nne={tools:"tool-activity",skills:"skill-activity"},Sne=()=>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"})}),Cne=()=>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"})]}),_ne={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 Ene(e){const t=e.failed?`${e.failed.toLocaleString()} failed (${ym(e)})`:"none failed",n=e.totalMs===null?"not timed":`${bt(e.totalMs)} in total, usually ${bt(e.medianMs)}`;return`${ao(e.operation)}${Zl(e.operation)?`, ${Zl(e.operation)}`:""}: ${kt(e.calls,"call")}, ${n}, ${t}`}function Tne({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}),[b,k]=g.useState("calls"),[v,N]=g.useState(""),x=g.useRef(b);x.current=b;const C=g.useRef(v);C.current=v;const[S,_]=g.useState(!1),[$,A]=g.useState(null),O=g.useRef(!1),M=g.useRef(null),[W,B]=g.useState(!1),R=g.useRef($);R.current=$;const q=g.useRef(null),[T,F]=g.useState(null),[D,K]=g.useState(null),[V,H]=g.useState("recent"),[P,I]=g.useState(!0),[U,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(h5),ge=fe=>{Le(fe),f5(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="${Nne[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 yp(Ie,fe.signal);if(_e){de.current=Ie,F(tt);const wt=!O.current&&rw(tt.rows,x.current,C.current)[0];wt?(O.current=!0,A(wt.operation)):R.current&&!tt.rows.some($t=>$t.operation===R.current)&&A(((ot=rw(tt.rows,x.current,C.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)===$&&de.current===Ie?ot:null),J(""),!$||!T||P||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 yp(`${Ie}&operation=${encodeURIComponent($)}&history=1`,_e.signal);fe&&(((ot=tt.details)==null?void 0:ot.measurements)===null?A(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)}},[$,T,P,Ie,a]);const De=g.useMemo(()=>rw((T==null?void 0:T.rows)??[],b,v),[T,b,v]),We=g.useMemo(()=>T?Rte(T.rows,T.totalMs):[],[T]),Ke=S||v?De:De.slice(0,EA),ye=De.length?wp(De[0],b)??0:0,Fe=T==null?void 0:T.rows.find(fe=>fe.operation===$);Fe&&(M.current=Fe);const $e=Fe??($&&!T&&((be=M.current)==null?void 0:be.operation)===$?M.current:void 0),Re=fe=>_e=>{q.current=_e.currentTarget,B(_e.detail===0),H("recent"),A(Ve=>Ve===fe?null:fe)},rt=()=>{const fe=$;A(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||U||(le.current=!0,te(fe=>fe+1))},se=T&&$te(T,i,u),ke=a==="skills"?m.loading:P,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:jne.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 vt.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:TA[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:P||U,onClick:He,children:r.jsx(Sne,{})}),r.jsx("button",{type:"button",ref:oe,className:"glyph-btn",onClick:je,"aria-label":`Close ${TA[a].toLowerCase()}`,title:"Close (Esc)",children:"×"})]})]}),r.jsx("div",{className:"ta-view-panel",children:a==="skills"?r.jsx(kne,{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,P&&!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 ",oa(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":$===fe.operation,"aria-controls":$===fe.operation?"tool-operation-inspector":void 0,onClick:Re(fe.operation),children:[r.jsx("span",{className:"ta-highlight-glyph",children:_ne[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(ene,{split:T.split,since:T.since,turnsSince:T.turnsSince,selected:$,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(Cne,{}),r.jsx("input",{type:"search","aria-label":"Find a tool or command",placeholder:"Find a tool or command",value:v,onChange:fe=>N(fe.target.value)})]})]}),r.jsx("div",{className:"uh-range ta-sorts",role:"group","aria-label":"Sort by",children:Tte.map(fe=>r.jsx("button",{type:"button",className:"uh-range-btn","aria-pressed":b===fe.id,onClick:()=>k(fe.id),children:fe.label},fe.id))}),r.jsxs("div",{className:"ta-list-head","aria-hidden":"true","data-sort":b,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":b,children:Ke.map(fe=>{const _e=wp(fe,b),Ve=Zl(fe.operation);return r.jsx("li",{children:r.jsxs("button",{type:"button",className:"ta-row","data-operation":fe.operation,"data-selected":$===fe.operation||void 0,"aria-expanded":$===fe.operation,"aria-controls":$===fe.operation?"tool-operation-inspector":void 0,"aria-label":Ene(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:[bt(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 "}),bt(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:ym(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 “",v.trim(),"”."]}),!v&&!S&&De.length>EA&&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 ",oa(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(p5,{width:pe,workspace:re,onCommit:ge}),$e&&r.jsx(o5,{keyboard:W,itemKey:$e.operation,onClose:rt,children:r.jsx(qte,{row:(D==null?void 0:D.operation)===$&&D.measurements?D.measurements:$e,details:(D==null?void 0:D.operation)===$?D:null,loading:U,pending:!Fe,charted:Number(u)>=7,error:Y,kind:V,setKind:H,onClose:rt,onShowSkills:$e.operation==="Skill"?()=>{A(null),o("skills")}:void 0})})]})})]})}),document.body)}const K1={cost:0,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0,unpricedTokens:0,sessions:0};function Ane(e){if(!e.synthetic)return!1;const t=e.usage;return t.inputTokens+t.outputTokens+t.cacheReadTokens+t.cacheCreateTokens<=0}function Y1(e,t){const n=new Map;for(const s of e){if(s.kind!=="root"||!s.sessionId||Ane(s))continue;const a=Un(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 Rne(e,t){if(!e)return K1;const n={...K1};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 X1(e,t=new Date){return new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate()-(e-1))).toISOString().slice(0,10).replace(/-/g,"")}const xm=[{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 Mne(e,t,n=xm.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 $ne(e,t=new Date){return e==="today"?X1(1,t):e==="month"?X1(t.getDate(),t):"20200101"}const Nn=e=>typeof e=="number"&&Number.isFinite(e)?e:0,Df=e=>typeof e=="string"?e:"";function zN(e){const t=Array.isArray(e==null?void 0:e.days)?e.days:[],n=new Map;for(const s of t){const a=Array.isArray(s==null?void 0:s.modelBreakdowns)?s.modelBreakdowns:[];for(const o of a){const i=Df(o==null?void 0:o.modelName);if(!i)continue;let 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+=Nn(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,Nn(o.cost)))),l.inputTokens+=Nn(o==null?void 0:o.inputTokens),l.outputTokens+=Nn(o==null?void 0:o.outputTokens),l.cacheReadTokens+=Nn(o==null?void 0:o.cacheReadTokens),l.cacheCreateTokens+=Nn(o==null?void 0:o.cacheCreationTokens)}}return[...n.values()].sort((s,a)=>a.cost-s.cost||a.tokens-s.tokens)}const Lne=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Ine(e){var t;return((t=Lne.exec(e))==null?void 0:t[0])??e}function One(e,t=new Map){const n=Array.isArray(e==null?void 0:e.sessions)?e.sessions:[],s=new Set(zN(e).filter(o=>!(o.missingPricing===!0||o.missingPricing===void 0&&o.cost<=0&&o.tokens>0)).map(o=>o.model)),a=[];for(const o of n){const i=Df(o==null?void 0:o.period);if(!i)continue;const l=Ine(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(Df).filter(Boolean):[];a.push({sessionId:l,label:t.get(l)??null,agent:Df(o==null?void 0:o.agent)||"claude",cost:Nn(o==null?void 0:o.totalCost),priced:f.length>0&&f.every(p=>s.has(p)),tokens:Nn(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 Pne(e,t=VN(e).cost){const s=(Array.isArray(e==null?void 0:e.sessions)?e.sessions:[]).reduce((o,i)=>o+Nn(i==null?void 0:i.totalCost),0),a=Math.max(.01,t*.01);return{sum:s,total:t,over:s>t+a}}function Dne(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 VN(e){const t=e==null?void 0:e.totals;if(t&&typeof t=="object"){const u=Nn(t.cacheReadTokens),h=Nn(t.cacheCreationTokens),f=Nn(t.inputTokens),p=Nn(t.outputTokens);return{cost:Nn(t.totalCost),inputTokens:f,outputTokens:p,cacheReadTokens:u,cacheCreateTokens:h,tokens:Nn(t.totalTokens)||f+p+u+h}}const n=zN(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 Fne(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 b5(e,t){var n;return((n=xm.find(s=>s.key===(e??t)))==null?void 0:n.noun)??"today"}function Bne(e,t,n){const s=e!=null,a=VN(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 k5="agent-dag.usagePeriod";function qne(){const e=nt(k5);return xm.some(t=>t.key===e)?e:"today"}function Une(e){st(k5,e)}const j5="agent-dag.usageSessionsOpen";function Wne(){return nt(j5)==="1"}function Hne(e){st(j5,e?"1":"0")}function GN({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 cf="https://ccdeck.dev/guides",zne={localNetwork:{href:`${cf}/local-network/#film`,subject:"Local network"},claudeAccounts:{href:`${cf}/claude-accounts/#film`,subject:"Claude accounts"},usage:{href:`${cf}/cost-and-quota/#film`,subject:"cost and quota"},tour:{href:`${cf}/first-run/#film`,subject:"first run"}};function sd({film:e,action:t=!1}){const{href:n,subject:s}=zne[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",Vne="/brand/ccdeck-mark-gradient-small-optical.svg",Gne="/brand/ccdeck-mark-mono-dark-small-optical.svg",Kne={month:"short",day:"numeric",hour:"numeric",minute:"2-digit",hour12:!0};function N5(e,t){const n=t.nextExpiryAt!=null?` · ${`expires ${new Date(t.nextExpiryAt).toLocaleString("en-US",Kne).replace(/\s+(AM|PM)/,(s,a)=>a.toLowerCase())}`.replace(/\s/g," ")}`:"";return`${t.availableCount} ${e}${t.availableCount!==1?"s":""} available${n}`}const Yne=12*36e5,Xne=new Set(["seven_day","weekly"]);function Zne(e,t=4){return e.filter(n=>Xne.has(n.id)&&n.ended==="reset"&&n.resetAt*1e3-n.t<=Yne).sort((n,s)=>s.resetAt-n.resetAt).slice(0,t)}function Jne(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 Qne=e=>new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric"}),ese=e=>e<36e5?`${Math.max(1,Math.round(e/6e4))} min`:`${Math.round(e/36e5)} h`;function tse(e){return[...e.map(t=>`${Qne(t.resetAt*1e3)}: ${Math.round(t.pct)}% used, read ${ese(t.resetAt*1e3-t.t)} before the reset`),"An average of the weekly window's last reading before each reset"].join(`
98
- `)}const nse=15*6e4;function AA(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(Zne(u.closed))}catch{}};o();const i=window.setInterval(()=>{document.visibilityState==="visible"&&o()},nse);return()=>{a=!1,window.clearInterval(i)}},[e,t]),n}function S5(){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 sse({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 C5({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 rse(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),b=Math.floor(p%3600/60);m.runsOutIn=w>0?`${w}h ${b}m`:`${b}m`}return m}return{label:`${Math.round(-u)}% under pace`,color:"var(--ok)",expectedPct:l,isDeficit:!1}}function Za({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",b=m?2:h,k=s&&!l?wd(s,i):null,v=u&&s&&a?rse(h,s,a,i,o):null,[N,x]=g.useState(!1),C=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(${b/100})`,background:p,opacity:m?.4:1}}),v&&r.jsx("div",{className:"qb-pace-rail",style:{transform:`translateX(${v.expectedPct}%)`},children:r.jsx("div",{"aria-hidden":!0,className:"qb-pace-marker",style:{background:v.isDeficit?"var(--err)":"var(--ok)"},title:`To last until reset, stay near ${Math.round(v.expectedPct)}% by now`})})]}),r.jsxs("div",{className:"qb-reset-row",children:[l?r.jsx("span",{className:"qb-reset",children:"waiting for a new reading"}):k?r.jsxs("span",{className:"qb-reset",children:["resets in ",k]}):n?r.jsxs("span",{className:"qb-reset",children:["resets ",n]}):null,v&&r.jsxs("button",{type:"button",className:"qb-pace",style:{color:v.color},"aria-expanded":N,"aria-controls":N?C:void 0,onClick:()=>x(S=>!S),children:[r.jsx("i",{className:"qb-pace-key","aria-hidden":!0,style:{background:v.isDeficit?"var(--err)":"var(--ok)"}}),v.runsOutIn?`runs out in ${v.runsOutIn}`:v.label]})]}),N&&v&&r.jsxs("div",{id:C,className:"qb-why",children:["To last until reset, stay near ",Math.round(v.expectedPct),"% by now."]})]})}function _5(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 ase(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 ose(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 ise(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 E5({weeks:e=[]}){const t=Jne(e);return t?r.jsx("div",{className:"up-quota-sub",title:tse(e),children:t}):null}function lse({quota:e,quotaLoading:t,nowSec:n,incident:s,weekEnds:a}){const o=_5(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:ase(e==null?void 0:e.source),children:[o,(e==null?void 0:e.stale)&&" · no newer reading"]})]}),r.jsx(C5,{incident:s}),e!=null&&e.ok?r.jsxs("div",{className:"up-quota-bars",children:[e.session5hPct!=null&&r.jsx(Za,{label:"5-hour window",pct:e.session5hPct,reset:e.session5hReset,resetAt:e.session5hResetAt,windowSec:e.session5hWindowSec,nowSec:n}),r.jsx(Za,{label:"7-day window",pct:e.week7dPct??null,reset:e.week7dReset,resetAt:e.week7dResetAt,windowSec:e.week7dWindowSec,nowSec:n}),r.jsx(E5,{weeks:a}),e.weekSonnetPct!=null&&r.jsx(Za,{label:"Sonnet (7d)",pct:e.weekSonnetPct,nowSec:n}),e.weekOpusPct!=null&&r.jsx(Za,{label:"Opus (7d)",pct:e.weekOpusPct,nowSec:n}),e.extraEnabled&&e.extraUsedCredits!=null&&e.extraMonthlyLimit?r.jsx(Za,{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:N5("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:ose(e.reason)})]}):r.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]})}function cse({codexQuota:e,codexLoading:t,nowSec:n,incident:s,weekEnds:a}){var i,l;const o=_5(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(C5,{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(Za,{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(E5,{weeks:a}),(l=e.extraWindows)==null?void 0:l.map(u=>r.jsx(Za,{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(Za,{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:N5("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:ise(e.reason)})]}):r.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]})}function Z1(e,t){return t&&e<=0?ha:ct(e)+(t?"+":"")}const lje="Some models have no known price. Tokens are counted; their cost is missing from the total.";function RA(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 use({fromRange:e,rangeModelRows:t,boardModelRows:n}){const s=t.filter(o=>o.storedCost!==void 0),a=e?RA(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,RA(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:Z1(o.cost,!0)}):r.jsx("td",{className:"up-num up-cost-val",children:Z1(o.cost)})]},o.model)):n.map(o=>r.jsxs("tr",{children:[r.jsx("td",{className:"up-model-name",title:o.model===F1?"no model reported yet":o.model,children:o.model===F1?"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:ha})]},o.model))})]}),a&&r.jsx("p",{className:"uh-cost-note",children:a})]})}function dse({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=Mne(a.key,o);i!==null&&(a.preventDefault(),(l=s.current[i])==null||l.focus())},children:xm.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 ${b5(e,e)}…`:""})]})}function hse(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 fse(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 MA({sessionId:e,agent:t,label:n,onOpen:s,children:a}){return s&&hse(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 pse({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:Dne(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(MA,{sessionId:p.sessionId,agent:p.agent,label:p.label??dp(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??dp(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:ha})]},`${p.agent}:${p.sessionId}`)}),!e&&n.map(p=>r.jsxs(MA,{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:ha})]},p.sessionId))]})]})}function mse(e){return e.claude&&e.codex?"Claude Code and Codex":e.claude?"Claude Code":e.codex?"Codex":null}const gse={claude:"Claude Code",codex:"Codex",opencode:"OpenCode",openclaw:"OpenClaw",copilot:"GitHub Copilot",pi:"pi-agent",zcode:"ZCode"};function T5(e){const t=e.toLowerCase(),n=Jt(gse,t);return n!==void 0?n:t?t[0].toUpperCase()+t.slice(1):""}function yse(e){return e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function cje(e,t=[]){const n=t.length?yse(t.map(T5)):mse(e);return n?`via ccusage · local ${n} logs`:"via ccusage · local agent logs"}function wse(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 xse(){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 uf=e=>e.toLocaleString(),$A=e=>new Date(e).toLocaleString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"});function vse({session:e,onClose:t}){var v,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&&((v=i.detail)==null?void 0:v.speed)===n?i.detail:void 0;g.useEffect(()=>{const x=new AbortController;l(null);const C=new URLSearchParams({agent:e.agent,id:e.sessionId,speed:n});return a!==u.current&&C.set("refresh","1"),u.current=a,fetch(`/api/ccusage/session?${C}`,{signal:x.signal}).then(async S=>{const _=await S.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))??[],b=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)"}]:[],k=b.reduce((x,C)=>x+C.n,0);return vt.createPortal(r.jsx("div",{className:"modal-backdrop",...p,role:"presentation",children:r.jsxs("div",{className:"modal su-modal",ref:f,role:"dialog","aria-modal":"true","aria-labelledby":"session-usage-title",children:[r.jsxs("header",{className:"modal-head",children:[r.jsxs("div",{className:"su-title",children:[r.jsx("h2",{id:"session-usage-title",children:"Session usage"}),r.jsx("span",{title:e.label,children:e.label})]}),r.jsxs("div",{className:"modal-actions",children:[r.jsx("button",{type:"button",className:"glyph-btn",onClick:()=>o(x=>x+1),disabled:!i,"aria-label":"Refresh session usage",title:"Refresh session usage",children:r.jsx(S5,{})}),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:T5(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(xse,{}),i&&!i.ok&&r.jsxs("p",{className:"su-message",role:"status",title:i.error,children:[fse(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:uf(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"})]}),k>0&&r.jsx("div",{className:"su-composition","aria-hidden":"true",children:b.filter(x=>x.n>0).map(x=>r.jsx("span",{style:{width:`${x.n/k*100}%`,background:x.color}},x.name))}),r.jsx("dl",{className:"su-tokens",children:b.map(({name:x,n:C,color:S})=>r.jsxs("div",{children:[r.jsxs("dt",{children:[r.jsx("span",{className:"su-key",style:{background:S},"aria-hidden":"true"}),x]}),r.jsxs("dd",{title:uf(C),children:[Ct(C),r.jsx("span",{className:"su-share",children:k>0?`${(C/k*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:uf(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:$A(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:$A(m.lastActivity)})})]}),m.entries!=null&&r.jsxs("div",{children:[r.jsx("dt",{children:"Usage records"}),r.jsx("dd",{children:uf(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 df=e=>`${e.id}:${e.windowSec}:${e.resetAt}`;function bse(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 kse(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 KN({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"}),LA=e=>new Date(e).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"});function jse({series:e}){const t=bse(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):LA(n)}),r.jsx("span",{children:e.windowSec>86400?Pl(s):LA(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 Nse({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(""),[b,k]=g.useState(0),[v,N]=g.useState(Date.now),x=g.useRef(!1),C=g.useRef(null),S=gt(n,{focusRef:C}),_=yt(n),$=t[a];g.useEffect(()=>{let B=!1,R=null;l(null),p(!1);const q=async()=>{if(R)return;if(!$){x.current=!1,h(!1);return}const F=new AbortController;R=F,x.current=!0;const D=window.setTimeout(()=>F.abort(),12e3);h(!0);try{const K=await fetch(`/api/quota/history?provider=${a}&account=${encodeURIComponent($)}`,{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===$?V:{...V,series:[]}),p(!1))}catch{B||p(!0)}finally{window.clearTimeout(D),R=null,B||(x.current=!1,h(!1))}};q();const T=window.setInterval(()=>{N(Date.now()),document.visibilityState==="visible"&&q()},6e4);return()=>{B=!0,R==null||R.abort(),window.clearInterval(T)}},[a,$,b]);const A=((i==null?void 0:i.series)??[]).slice().sort((B,R)=>R.resetAt-B.resetAt||B.windowSec-R.windowSec),O=A.find(B=>df(B)===m)??A.find(B=>B.resetAt*1e3>v&&B.windowSec<=6*3600)??A[0],M=O==null?void 0:O.points.at(-1),W=()=>{Cn(x.current)&&(x.current=!0,k(B=>B+1))};return vt.createPortal(r.jsx("div",{className:"modal-backdrop",role:"presentation",..._,children:r.jsxs("div",{className:"modal qh-modal","data-keyboard-interaction":s||void 0,ref:S,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",...Bn(u),onClick:W,children:u?"…":r.jsx(S5,{})}),r.jsx("button",{type:"button",ref:C,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))}),A.length>0&&r.jsxs("label",{className:"qh-window",children:["Window",r.jsx("select",{"aria-label":"Quota window",value:O?df(O):"",onChange:B=>w(B.target.value),children:A.map(B=>r.jsxs("option",{value:df(B),children:[B.label," · ",Pl(B.resetAt*1e3)]},df(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."]}),O&&M?r.jsxs("div",{className:"qh-result read-result",children:[r.jsxs("div",{className:"qh-summary",children:[r.jsxs("strong",{children:[Math.round(100-M.pct),"% remaining"]}),r.jsxs("span",{title:Pl(M.t),children:["Captured ",kse(M.t,v),O.resetAt*1e3<=v&&" · window ended"]})]}),r.jsx(jse,{series:O}),r.jsx("p",{className:"qh-note",children:"Recorded quota readings. The dashed guide shows even use until reset; it is not a forecast. Gaps are left unconnected."}),r.jsxs("details",{className:"qh-readings",children:[r.jsxs("summary",{children:["Recorded readings (",O.points.length,")"]}),r.jsxs("table",{children:[r.jsx("caption",{children:O.points.length>50?"Latest 50 readings":"Recorded readings"}),r.jsx("thead",{children:r.jsxs("tr",{children:[r.jsx("th",{scope:"col",children:"Captured"}),r.jsx("th",{scope:"col",children:"Remaining"})]})}),r.jsx("tbody",{children:O.points.slice(-50).reverse().map(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&&$?r.jsx(KN,{kind:"quota",title:"Reading quota history…",note:"Loading this account’s saved quota readings."}):r.jsx("p",{className:"qh-message",role:"status",children:$?"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 Sse=6e4,Cse=2e4;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&&!Cn(i.current))){h&&(i.current=!0,a(!0));try{const p=await fetch(h?"/api/quota?refresh=1":"/api/quota",{signal:AbortSignal.timeout(Cse)});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),Sse),()=>{o.current!=null&&window.clearInterval(o.current)}},[e]),{quota:t,loading:s,refresh:()=>{e&&l(!0)}}}const Ese=6e4;function Tse(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&&!Cn(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),Ese),()=>{o.current!=null&&window.clearInterval(o.current)}},[e]),{data:t,loading:s,refresh:()=>{e&&l(!0)}}}const IA=6e4;function Ase(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(k=>k+1)},w=window.setInterval(m,IA),b=()=>{p()&&Date.now()-h.current>=IA&&u(k=>k+1)};return document.addEventListener("visibilitychange",b),()=>{window.clearInterval(w),document.removeEventListener("visibilitychange",b)}},[]);const f=g.useRef(t);return g.useEffect(()=>{let p=!0;const m=t!==f.current;f.current=t;const w=e,b=$ne(w);return i(!0),fetch(`/api/ccusage?since=${b}${m?"&refresh=1":""}`).then(k=>k.ok?k.json():null).then(k=>{!p||!(k!=null&&k.ok)||(h.current=Date.now(),a({period:w,data:k,baseline:n()}))}).catch(()=>{}).finally(()=>{p&&i(!1)}),()=>{p=!1}},[e,t,l]),{...Fne(s,e),loading:o}}const Rse=e=>1-Math.pow(1-e,5),A5=420;function Mse(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 $se(e,t,n,s=A5){return n>=s?t:n<=0?e:e+(t-e)*Rse(n/s)}function R5(){return typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches}function OA(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??R5,u=s.hidden??(()=>typeof document=="object"&&document.hidden===!0);if(l()||u()||!Mse(e,t))return n(t),()=>{};const h=a();let f=0,p=!0;const m=()=>{if(!p)return;const w=a()-h;n($se(e,t,w)),w<A5&&(f=o(m))};return f=o(m),()=>{p=!1,f&&i(f)}}const Lse=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]),Lse(()=>{!t||R5()||(a.current=0,s(0))},[]),g.useEffect(()=>{if(o.current){if(o.current=!1,t)return OA(0,e,l=>{a.current=l,s(l)});a.current=e,s(e);return}return OA(a.current,e,l=>{a.current=l,s(l)})},[e]),n}function M5(e,t,n){const s=Ose*Math.max(1,n/L5);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 PA={samples:[],last:new Map,watched:0},$5=10*6e4,Ise=6e4,L5=5e3,Ose=20;function Pse(e,t,n){const s=e.samples[e.samples.length-1];if(s&&t-s.t<L5)return e;const a=e.watched+M5(e.last,n,s?t-s.t:0),o=e.samples.filter(i=>t-i.t<=$5);return o.push({t,watched:a}),{samples:o,last:n,watched:a}}function Dse(e,t,n){const s=e.samples[0];if(!s)return null;const a=t-s.t;if(a<Ise)return null;const o=e.samples[e.samples.length-1].t,i=e.watched+M5(e.last,n,t-o)-s.watched;return i>0?{spent:i,spanSec:a/1e3,spanMin:Math.min($5/6e4,Math.ceil(a/6e4))}:null}function Fse(e,t,n){const s=g.useRef(PA),a=g.useRef(null);return g.useMemo(()=>{const o=XJ(e.agents.values()),i=zJ(e.agents.values());a.current!==n&&(a.current=n,s.current=PA);const l=Y1(e.agents.values(),t);n!=null&&(s.current=Pse(s.current,t,l));const u=n==null?null:Dse(s.current,t,l),h=u?{label:fN(u.spent,u.spanSec),spanMin:u.spanMin}:null;return{byModel:o,totalCost:i.cost,totalTokens:i,burnRate:h}},[e,e.revision,t,n])}const Bse=3e4;function YN(){const[e,t]=g.useState(()=>Math.floor(Date.now()/1e3));return g.useEffect(()=>{const n=window.setInterval(()=>t(Math.floor(Date.now()/1e3)),Bse);return()=>window.clearInterval(n)},[]),e}function DA(e){return(typeof e.cost=="number"?e.cost:e.cost.total)>0||e.inputTokens+e.outputTokens>0}function qse(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 Use(e){return e.claude&&e.codex?"Refresh Claude + Codex quota":e.codex?"Refresh Codex quota":"Refresh Claude quota"}function Wse(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 Hse(e){const t=new Map;for(const n of e)n.kind!=="root"||!n.sessionId||t.set(n.sessionId,n.state);return t}function zse(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} ${xD(n.sessionId,s)}`}:n})}const I5=120,FA=24,Vse=4,O5={usage:"agent-dag.usagePanelPlace",machine:"agent-dag.machinePanelPlace"};function Gse(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 BA(e,t,n){return Math.max(t,Math.min(e,n))}function Kse(e,t){return Math.abs(e.left-t.left)<=FA&&Math.abs(e.top-t.top)<=FA}function Yse(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 Xse=8;function Zse(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-Xse;return o>=I5?{upper:a,cap:o}:null}function J1(){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(fm).matches)return;const n=a=>({left:a.offsetLeft,top:a.offsetTop,width:a.offsetWidth}),s=Zse(n(e),n(t));s&&((s.upper==="a"?e:t).style.maxHeight=`${s.cap}px`)}let ow=0;function hf(){ow||(ow=requestAnimationFrame(()=>{ow=0,J1()}))}function Jse(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 P5(e){const t=ic(fm),[n,s]=g.useState(()=>Yse(nt(e))),a=g.useRef(null),o=g.useRef(null),i=g.useRef(null);g.useEffect(()=>()=>{var S;return(S=i.current)==null?void 0:S.call(i)},[]);const l=S=>{S?st(e,JSON.stringify(S)):ks(e),s(S)},u=S=>{const _=a.current;_&&(S?(_.style.left=`${S.left}px`,_.style.top=`${S.top}px`,_.style.right="auto"):(_.style.removeProperty("left"),_.style.removeProperty("top"),_.style.removeProperty("right")),J1())},h=()=>{var _;const S=a.current;S==null||S.removeAttribute("data-moving"),(_=i.current)==null||_.call(i),i.current=null,o.current=null},f=S=>{const _=S.getAttribute("data-place");if(!_)return S.getBoundingClientRect();S.removeAttribute("data-place");const $=S.getBoundingClientRect();return S.setAttribute("data-place",_),$},p=S=>S instanceof Element&&S.closest("button, a, input, select, textarea, [role='button']")!==null,m=S=>{const _=a.current;if(!_||S.button!==0||p(S.target))return;S.preventDefault(),S.currentTarget.setPointerCapture(S.pointerId);const $=_.getBoundingClientRect();o.current={id:S.pointerId,x:S.clientX,y:S.clientY,moved:!1,start:$,home:$,room:null,at:{left:$.left,top:$.top}}},w=S=>{const _=o.current,$=a.current;if(!_||!$||S.pointerId!==_.id)return;const A=S.clientX-_.x,O=S.clientY-_.y;if(!_.moved){if(Math.hypot(A,O)<Vse)return;_.moved=!0,_.home=f($),_.room=Jse(_.home),document.querySelectorAll("[data-front]").forEach(R=>R.removeAttribute("data-front")),$.setAttribute("data-front",""),$.setAttribute("data-moving","");const B=R=>{R.key==="Escape"&&(R.preventDefault(),R.stopPropagation(),u(null),h())};window.addEventListener("keydown",B,!0),i.current=()=>window.removeEventListener("keydown",B,!0)}const M=_.start.width,W=_.room;_.at={left:BA(_.start.left+A,W.side,W.w-W.side-M),top:BA(_.start.top+O,W.top,W.h-I5)},u(_.at)},b=S=>{const _=o.current;!_||S.pointerId!==_.id||(h(),_.moved&&(u(null),l(Kse(_.at,_.home)?null:Gse(_.at.left,_.at.top,_.start.width,_.room.w))))},k=()=>{o.current&&(u(null),h())},v=S=>{p(S.target)||!n||l(null)},N=n&&!t?n:null;g.useLayoutEffect(()=>{J1()},[N==null?void 0:N.edge,N==null?void 0:N.x,N==null?void 0:N.y]),g.useEffect(()=>{window.addEventListener("resize",hf);const S=document.querySelector(".app main"),_=S&&typeof ResizeObserver<"u"?new ResizeObserver(hf):null;return S&&(_==null||_.observe(S)),()=>{window.removeEventListener("resize",hf),_==null||_.disconnect(),hf()}},[]);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:b,onPointerCancel:k,onLostPointerCapture:k,onDoubleClick:v}}}function Qse({state:e,now:t,providers:n,incidents:s=[],leaving:a,onClose:o,liveSince:i=null}){const l=An(),u=P5(O5.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:b,loading:k,refresh:v}=_se(n.claude),{data:N,loading:x,refresh:C}=Tse(n.codex),S=AA("claude",n.claude?b==null?void 0:b.historyAccount:void 0),_=AA("codex",n.codex?N==null?void 0:N.historyAccount:void 0),$=YN(),{byModel:A,totalCost:O,totalTokens:M}=Fse(e,t,i),W=g.useMemo(()=>ZJ(e.agents.values()),[e,e.revision]),[B,R]=g.useState(qne);g.useEffect(()=>{Une(B)},[B]);const[q,T]=g.useState(Wne);g.useEffect(()=>{Hne(q)},[q]);const[F,D]=g.useState(0),K=g.useRef(()=>new Map);K.current=()=>i==null?null:Y1(e.agents.values(),t);const V=g.useCallback(()=>K.current(),[]),{data:H,shown:P,stale:I,loading:U,baseline:Z}=Ase(B,F,V),z=H!=null,X=U&&I,Y=g.useMemo(()=>Wse(e.agents.values()),[e,e.revision]),J=g.useMemo(()=>Hse(e.agents.values()),[e,e.revision]),Q=g.useMemo(()=>z?zN(H):[],[H,z]),te=g.useMemo(()=>z?zse(One(H,Y).slice(0,12)):[],[H,z,Y]),le=g.useMemo(()=>VN(H),[H]),de=g.useMemo(()=>Pne(H,le.cost),[H,le.cost]),oe=b5(P,B),re=g.useMemo(()=>z?Rne(Z,Y1(e.agents.values(),t)):K1,[e,e.revision,Z,z,t]),he=Bne(H,{...M,cost:O},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=A.filter(DA),De=W.filter(DA),We=qse(z,Q,Ie,re.unpricedTokens),Ke=k||x,ye=()=>{v(),C(),D($e=>$e+1)},Fe=Use(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,...Bn(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:_n("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(lse,{quota:b,quotaLoading:k,nowSec:$,weekEnds:S,incident:s.find($e=>$e.provider==="claude")}),n.codex&&r.jsx(cse,{codexQuota:N,codexLoading:x,nowSec:$,weekEnds:_,incident:s.find($e=>$e.provider==="codex")}),z&&r.jsx(dse,{period:B,rangePending:X,setPeriod:R}),Le>0?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"up-total",title:z?void 0:sA(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&&"+"]}):Z1(0,We)}),pe&&r.jsx("span",{className:"up-total-label",children:z?oe:VJ})]}),pe&&r.jsxs(r.Fragment,{children:[r.jsxs("p",{className:"up-source",children:["Local estimate · ",z?"ccusage":"live sessions"]}),he.showCostBar&&r.jsx(GN,{cost:O})]}),r.jsxs("div",{className:"up-tokens-row",title:z?void 0:sA(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:GJ})]}),(z?Q.length:Ie.length)>0&&r.jsx(use,{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(pse,{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:["“",ha,"” 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?(P??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(vse,{session:h,onClose:()=>f(null)},`${h.agent}:${h.sessionId}`),p&&r.jsx(Nse,{providers:n,instant:p==="keyboard",accounts:{claude:b==null?void 0:b.historyAccount,codex:N==null?void 0:N.historyAccount},onClose:()=>m(null)})]})}function iw(e){return e<9.95?e.toFixed(1):String(Math.round(e))}function XN(e){const t=Number.isFinite(e)?Math.max(0,e):0;return t<50?{value:"0",unit:"KB/s"}:t<999500?{value:iw(t/1e3),unit:"KB/s"}:t<9995e5?{value:iw(t/1e6),unit:"MB/s"}:{value:iw(t/1e9),unit:"GB/s"}}function vm(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 ere="thermal:Throttling";function ZN(e){const t="timeHeld"in e?e.timeHeld:100-e.speedLimit;return Math.max(0,Math.min(100,t))}function tre(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[ere]=ZN(e.thermal.throttle)),t}function Lu(e,t){return t==="B/s"?ad(XN(e)):t==="ms"?ad(vm(e)):t==="C"?`${Math.round(e)}°`:t==="%"?`${Math.round(e)}%`:e.toFixed(2)}function ff(e,t){return t==="B/s"||t==="ms"||!Number.isInteger(e)?Lu(e,t):t==="C"?`${e}°`:t==="%"?`${e}%`:`${e}`}function nre(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 sre(e,t,n){return e>=n?"hot":e>=t?"warn":"calm"}function rre(e,t,n=Date.now()){const s=ZN(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 ${qA(t.lastMs,n)}`:`at full speed · held to ${100-t.peak}% ${qA(t.lastMs,n)}`:"running at full speed, and never held back"}}function qA(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 are(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 ore(e){var s,a;const t=(s=e.thermal)==null?void 0:s.throttle,n=t?ZN(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 ire(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 lre=3e3;function cre(){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,lre))},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 ure(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=ure(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 lw(e,t){return t==="B/s"?XN(e):t==="ms"?vm(e):{value:String(e),unit:t==="C"?"°C":t}}const Xt={l:30,r:6,t:6,b:2},Ha={l:0,r:0,t:2,b:1},bm=104,dre=64;function Ys(e,t=100,n=bm,s=Xt){const a=n-s.t-s.b;return s.t+a*(1-Math.max(0,Math.min(t,e))/t)}function D5(e,t){return t??[e[0].t,e[e.length-1].t]}function JN(e,[t,n],s,a=Xt){const o=s-a.l-a.r,i=n-t;return a.l+(i>0?o*(e-t)/i:o/2)}function F5(e,t,n,s=100,a=bm,o=Xt,i){if(!e.length)return"";const l=D5(e,i),u=p=>JN(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)} ${Ys(p.v,s,a,o).toFixed(1)}`,f=p}return h}function B5(e,t,n,s=100,a=bm,o=Xt,i){if(e.length<2)return"";const l=a-o.b,u=D5(e,i),h=w=>JN(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 b of p)w+=`L${h(b.t).toFixed(1)} ${Ys(b.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 hre(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 q5(e,t,n){return n!=null&&e>=n?"hot":t!=null&&e>=t?"warn":""}function fre(e,t,n=s=>Ka(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 UA(e,t){return t==null||!Number.isFinite(t)||t<=0||!Number.isFinite(e)||e<0?null:`${(e/t).toFixed(1)}× the core count`}function Ka(e){const t=new Date(e);return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}function QN(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 pre({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 k=await fetch(`/api/system/history?group=${e}`);if(!k.ok)return;const v=await k.json();m&&(v!=null&&v.ok)&&l(v)}catch{}};w();const b=window.setInterval(w,2e4);return()=>{m=!1,window.clearInterval(b)}},[e]);const u=(i==null?void 0:i.series)??[],[h,f,p]=g.useMemo(()=>{let m=1/0,w=0;for(const b of u)b.points.length&&(m=Math.min(m,b.points[0].t),w=Math.max(w,b.points[b.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 vt.createPortal(r.jsx("div",{className:"modal-backdrop",...o,role:"presentation",children:r.jsxs("div",{ref:a,className:"modal hist-modal",onClick:m=>m.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"hist-modal-title",children:[r.jsxs("div",{className:"modal-head",children:[r.jsx("span",{className:"modal-title",id:"hist-modal-title",children:t}),i&&h>0&&r.jsxs("span",{className:"hist-since",children:["since ",Ka(h)," · ",QN(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(KN,{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(mre,{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 mre({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 U=new ResizeObserver(([Z])=>o(Math.max(160,Z.contentRect.width)));return U.observe(I),()=>U.disconnect()},[]);const{points:f,unit:p,warnAt:m,critAt:w,label:b,top:k,restsAtZero:v,changes:N,cores:x}=e,C=v?dre:bm,{now:S,peak:_}=hre(f),$=S!=null?lw(S,p):null,A=_!=null?lw(_,p):null,O=b==="Throttling"?fre(f,t):null;let M=null;if(_!=null&&f.length>1)for(let I=f.length-1;I>=0&&!M;I--)f[I].v===_&&(M=f[I]);const W=u!=null?f.find(I=>I.t===u)??null:null,B=i!=null?f[i]:W,R=B?UA(B.v,x):null,[q,T]=n??(f.length?[f[0].t,f[f.length-1].t]:[0,0]),F=I=>JN(I,[q,T],a),D=I=>{if(f.length<2)return null;const U=I.currentTarget.getBoundingClientRect(),Z=(I.clientX-U.left-Xt.l)/Math.max(1,U.width-Xt.l-Xt.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 U=D(I);U!=null&&l(U)},V=I=>{const U=D(I);if(U==null)return;const Z=f[U].t;h(z=>z===Z?null:Z)},H=_!=null&&A&&r.jsxs(r.Fragment,{children:[r.jsx("b",{className:q5(_,m,w),children:A.value}),r.jsxs("span",{children:[A.unit," peak"]})]}),P=_!=null?UA(_,x):null;return r.jsxs("section",{className:"hist-series","aria-label":`${b} history`,children:[r.jsxs("div",{className:"hist-head",children:[r.jsx("span",{className:"hist-label",children:b}),r.jsxs("span",{className:"hist-stats",children:[$&&r.jsxs(r.Fragment,{children:[r.jsx("b",{children:$.value}),r.jsxs("span",{children:[$.unit," now"]})]}),H&&(M?r.jsx("button",{type:"button",className:"hist-peak",onClick:()=>h(M.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:C,viewBox:`0 0 ${a} ${C}`,preserveAspectRatio:"none",role:"img","aria-label":$==null||A==null?`${b}: nothing measured yet`:`${b}: ${ad($)} now, peak ${ad(A)}${M?` at ${Ka(M.t)}`:""}${P?` (${P})`:""}, over ${QN(f[0].t,f[f.length-1].t)}`,onPointerMove:K,onPointerLeave:()=>l(null),onClick:V,children:[[["warn",m],["hot",w]].map(([I,U])=>U==null||U>k?null:r.jsxs("g",{children:[r.jsx("line",{className:`hist-rule ${I}`,x1:Xt.l,x2:a-Xt.r,y1:Ys(U,k,C),y2:Ys(U,k,C)}),r.jsx("text",{className:`hist-rule-tag ${I}`,x:2,y:Ys(U,k,C)+3,children:U})]},I)),r.jsx("line",{className:"hist-floor",x1:Xt.l,x2:a-Xt.r,y1:C-Xt.b,y2:C-Xt.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:Xt.t,y2:C-Xt.b},I.t)),r.jsx("path",{className:"hist-area",d:B5(f,a,t,k,C,Xt,[q,T])}),r.jsx("path",{className:"hist-line",d:F5(f,a,t,k,C,Xt,[q,T])}),f.length===1&&r.jsx("circle",{className:"hist-dot",cx:F(f[0].t),cy:Ys(f[0].v,k,C),r:3}),B&&r.jsxs("g",{children:[r.jsx("line",{className:"hist-cross",x1:F(B.t),x2:F(B.t),y1:Xt.t,y2:C-Xt.b}),r.jsx("circle",{className:"hist-dot",cx:F(B.t),cy:Ys(B.v,k,C),r:3})]})]})}),r.jsxs("div",{className:"hist-axis",children:[B?r.jsxs("span",{className:"hist-at",children:[Ka(B.t)," — ",(()=>{const I=lw(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}`]})})(),R&&` · ${R}`]}):r.jsxs(r.Fragment,{children:[r.jsx("span",{children:f.length?Ka(q):""}),r.jsx("span",{children:f.length?Ka(T):""})]}),W&&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:"×"})]}),O&&r.jsx("div",{className:"hist-note",children:O}),N==null?void 0:N.slice(-3).map(I=>r.jsx("div",{className:"hist-note hist-route",children:I.from==null?`Since ${Ka(I.t)} — ${I.label}`:`${Ka(I.t)} — ${I.label.charAt(0).toUpperCase()+I.label.slice(1)}`},I.t))]})}const WA=["cores","memory","load","thermal"],Ho=116,pr=24,gre=60,yre=6e4;function wre(e){return e.points.length?e.restsAtZero?e.points.some(t=>t.v>0):!0:!1}function xre(e){return e.unit==="C"?`${e.label} temp`:e.key==="mem:physical"?"Physical RAM":e.key==="mem:swap"?`${e.label} memory`:e.label}function vre(e,t=gre){return e.points.length<=t?e:{...e,points:e.points.slice(-t)}}function bre({sys:e}){const[t,n]=g.useState({});g.useEffect(()=>{let i=!0;const l=async()=>{const h=await Promise.all(WA.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(),yre);return()=>{i=!1,clearInterval(u)}},[]);const s=g.useMemo(()=>tre(e),[e]),a=g.useMemo(()=>WA.flatMap(i=>{const l=t[i];return l?l.series.filter(wre).map(u=>({series:vre(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)?QN(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(kre,{series:i,stepMs:l,now:s[i.key],span:o},i.key))}):null}function kre({series:e,stepMs:t,now:n,span:s}){var w;const{points:a,top:o,unit:i,warnAt:l,critAt:u}=e,h=xre(e),f=n??((w=a[a.length-1])==null?void 0:w.v),p=f==null?"":q5(f,l,u),m=Math.max(...a.map(b=>b.v));return r.jsxs("div",{className:`pl-cell${p?` ${p}`:""}`,title:[`${h} · peak ${Lu(m,i)} over the last ${s}`,l!=null?`over ${ff(l,i)} is uncomfortable`:"",u!=null?`over ${ff(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:pr,viewBox:`0 0 ${Ho} ${pr}`,preserveAspectRatio:"none","aria-hidden":!0,children:[r.jsx("line",{className:"pl-spark-floor",x1:0,x2:Ho,y1:pr-Ha.b,y2:pr-Ha.b}),r.jsx("path",{className:"pl-spark-area",d:B5(a,Ho,t,o,pr,Ha)}),l!=null&&r.jsx("line",{className:"pl-rule warn",x1:0,x2:Ho,y1:Ys(l,o,pr,Ha),y2:Ys(l,o,pr,Ha)}),u!=null&&r.jsx("line",{className:"pl-rule hot",x1:0,x2:Ho,y1:Ys(u,o,pr,Ha),y2:Ys(u,o,pr,Ha)}),r.jsx("path",{className:"pl-spark-line",d:F5(a,Ho,t,o,pr,Ha)})]}),r.jsxs("span",{className:"vis-hidden",children:["peak ",Lu(m,i)," over the last ",s,l!=null&&`, uncomfortable over ${ff(l,i)}`,u!=null&&`, the machine acts over ${ff(u,i)}`]})]})}const U5={key:"cpu",dir:"desc"};function jre(e,t){return e.key===t?{...e,dir:e.dir==="asc"?"desc":"asc"}:{key:t,dir:t==="name"||t==="user"?"asc":"desc"}}function Nre(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 Sre=4e3;function Cre(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 _re(){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=>Cre(l,i))}catch{}};s();const a=window.setInterval(s,Sre);return()=>{n=!1,window.clearInterval(a)}},[]),e}function Ere(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 Tre({sys:e,onClose:t}){an("process-list");const n=gt(t),s=yt(t),[a,o]=g.useState(U5),i=_re();return vt.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(Are,{read:i,sort:a,onSort:o,sys:e,onClose:t})})}),document.body)}function Are({read:e,sort:t,onSort:n,sys:s,onClose:a}){const o=e?Nre(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(KN,{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:Qn(i.rssBytes)}),r.jsx("td",{className:"sd-num sd-dim",children:i.threads??"—"}),r.jsx("td",{className:"sd-num sd-dim",children:Ere(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(bre,{sys:s})]})]})}function hl(e){return r.jsx(vl,{...e,next:(t,n)=>jre(t??U5,n)})}function Q1({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 Rre=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=b=>{var k;m(),!(b.detail>1||((k=window.getSelection())==null?void 0:k.isCollapsed)===!1)&&(p.current=window.setTimeout(()=>{var v,N;p.current=null,((v=window.getSelection())==null?void 0:v.isCollapsed)!==!1&&((N=f.current)==null||N.focus({preventScroll:!0}),h(!0))},Rre))};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:b=>{b.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(pre,{group:e,title:t,liveNote:i,onClose:()=>h(!1)})]})}function id({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 Mre({network:e}){const{down:t,up:n,api:s,route:a}=e,[o,i]=g.useState(!1),l=s&&s.ms!=null?vm(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=XN(f);return r.jsx(Q1,{value:p.value,unit:p.unit,cap:h},h)}),l&&r.jsx(Q1,{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($re,{route:a,api:s,onClose:()=>i(!1)})]})]})}function $re({route:e,api:t,onClose:n}){return r.jsxs(vd,{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 ",ire(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(vm(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 pf({label:e,value:t,pct:n}){return n!=null?r.jsx(id,{label:e,value:r.jsx("b",{children:t}),pct:n}):r.jsx("div",{className:"sd-row",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})]})})}function Lre({devices:e}){return r.jsx(r.Fragment,{children:e.map((t,n)=>{const s=t.memoryUsed,a=t.memoryTotal,o=s!=null&&a!=null?`${Qn(s)} of ${Qn(a)}`:s!=null?`${Qn(s)} used`:a!=null?`${Qn(a)} total · used unavailable`:"Unavailable";return r.jsxs("section",{className:"sd-section","aria-label":`GPU ${n+1}: ${t.name}`,children:[r.jsxs("h3",{className:"sd-sub sd-gpu-name",children:["GPU ",n+1," · ",t.name]}),r.jsx(pf,{label:"Utilization",value:t.utilization==null?"Unavailable":`${t.utilization}%`,pct:t.utilization??void 0}),r.jsx(pf,{label:"Video memory",value:o,pct:s!=null&&a!=null&&a>0?s/a*100:void 0}),r.jsx(pf,{label:"Temperature",value:t.temperature==null?"Unavailable":`${t.temperature} °C`}),r.jsx(pf,{label:"Power",value:t.power==null?"Unavailable":`${t.power.toFixed(1)} W`})]},t.id)})})}function HA({usageOpen:e,leaving:t,sub:n,flag:s,onClose:a,children:o}){const i=P5(O5.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 Ire({usageOpen:e,leaving:t,onClose:n}){const s=cre();if(!s||s.cpu==null||!s.memory)return r.jsx(HA,{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(HA,{usageOpen:e,leaving:t,sub:`up ${are(h)} · ${u} cores`,flag:ore(s),onClose:n,children:[r.jsx(Ore,{cpu:w,perCore:i,loadavg:l,cores:u}),r.jsx(Pre,{memory:a,swap:o,platform:f}),m&&r.jsx(Mre,{network:m}),r.jsx(Lre,{devices:s.gpus??[]}),r.jsx(Dre,{thermal:p}),r.jsx(Fre,{sys:s})]})}function Ore({cpu:e,perCore:t,loadavg:n,cores:s}){const a=nre(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(Q1,{value:i.toFixed(2),cap:["1m","5m","15m"][l]},l))}),a&&r.jsx("div",{className:"sd-note",children:a})]})]})}function Pre({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(id,{label:"Physical",value:r.jsxs(r.Fragment,{children:[r.jsx("b",{children:Qn(s)})," of ",Qn(e.total)]}),pct:e.usedPct,tone:e.usedPct>=90?"warn":"calm",note:`${Qn(e.available)} available`}),t&&t.total>0&&r.jsx(id,{label:a,value:r.jsxs(r.Fragment,{children:[r.jsx("b",{children:Qn(t.used)})," of ",Qn(t.total)]}),pct:o,tone:o>=90?"warn":"calm"})]})})}function Dre({thermal:e}){if(!e)return null;const t=e.throttle?rre(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(id,{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:sre(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(id,{label:"Throttling",value:r.jsx("b",{children:t.value}),pct:t.pct,tone:t.tone,note:t.note})]})})}function Fre({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(Tre,{sys:e,onClose:()=>n(!1)})]})}function Bre(){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 bp(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=bp(e.l));const n=e.s?Object.entries(e.s):[];return n.length>0&&(t.bySpeed=Object.fromEntries(n.map(([s,a])=>[s,bp(a)]))),t}function zA(e){const t=s=>({...s,cacheCreate1hTokens:0,cacheCreate5mTokens:0,...s.longContext?{longContext:{...s.longContext,cacheCreate1hTokens:0,cacheCreate5mTokens:0}}:{}}),n=t(bp(e));return n.bySpeed&&(n.bySpeed=Object.fromEntries(Object.entries(n.bySpeed).map(([s,a])=>[s,t(a)]))),n}function W5(e){return e.i+e.o+e.cr+e.cc}function ej(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&&ej(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??{}))ej((n=e.s??(e.s={}))[s]??(n[s]={i:0,o:0,cr:0,cc:0,c1h:0,c5m:0}),a);return e}function VA(e,t,n){let s=0,a=0,o=0;const i=[];for(const l of yd(e)){if(!jr(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,da,n).total}return{atSpeed:s,atStandard:a,unpriced:o,unpricedSpeeds:i}}function GA(e){let t=0;for(const n of Object.values(e))t+=W5(n);return t}function qre(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 Ure(e,t,n,s=Date.now()){const a=new Map;for(const A of e){const O={},M=W=>{for(const[B,R]of Object.entries(W))ej(O[B]??(O[B]={i:0,o:0,cr:0,cc:0,c1h:0,c5m:0}),R)};for(const W of A.projects)M(W.models);A.unattributed&&M(A.unattributed);for(const[W,B]of Object.entries(O)){if(!B.s&&!B.l)continue;const{atSpeed:R,atStandard:q}=VA(zA(B),W,s);if(!(R>0&&q>0))continue;let T=a.get(A.day);T||(T=new Map,a.set(A.day,T)),T.set(W,R/q),T.has(yr(W))||T.set(yr(W),R/q)}}const o=(A,O)=>{const M=a.get(A);return(M==null?void 0:M.get(O))??(M==null?void 0:M.get(yr(O)))??1},i=new Map;let l=0,u=0;for(const[A,O]of n){const M=A.indexOf("|"),W=A.slice(0,M),B=A.slice(M+1),R=Xp(O.usage,B,s).total*o(W,B);if(!(R>0&&O.cost>0))continue;l+=O.cost,u+=R;let q=i.get(W);q||(q=new Map,i.set(W,q)),q.set(B,O.cost/R)}const h=u>0,f=(A,O)=>{const M=i.get(A);return(M==null?void 0:M.get(O))??(M==null?void 0:M.get(yr(O)))??null},p=new Set,m=(A,O)=>{let M=0,W=0;for(const[B,R]of Object.entries(A)){if(jr(B,s)){const T=O(B),F=VA(T===null?bp(R):zA(R),B,s);M+=T===null?F.atSpeed:F.atSpeed*T,W+=F.unpriced;for(const D of F.unpricedSpeeds)p.add(`${B} (${D})`);continue}const q=W5(R);q>0&&(W+=q,p.add(B))}return{cost:M,unpriced:W}},w=new Map,b=[];for(const A of e){const O=new Map,M=new Map;let W=0;for(const B of A.projects){const{cost:R,unpriced:q}=m(B.models,F=>f(A.day,F));O.set(B.path,(O.get(B.path)??0)+R),q>0&&M.set(B.path,(M.get(B.path)??0)+q),W+=R;let T=w.get(B.path);T||(T={path:B.path,cost:0,tokens:0,unpricedTokens:0},w.set(B.path,T)),T.cost+=R,T.tokens+=GA(B.models),T.unpricedTokens+=q}b.push({day:A.day,total:W,byPath:O,unpricedByPath:M})}const k=[...w.values()].sort((A,O)=>O.cost-A.cost||O.tokens-A.tokens),v=k.reduce((A,O)=>A+O.cost,0),N=k.reduce((A,O)=>A+O.tokens,0),x=k.reduce((A,O)=>A+O.unpricedTokens,0),C=h?l/u:null,S=t?GA(t):0,_=t?m(t,()=>C):{cost:0,unpriced:0},$=_.cost>0||S>0?{cost:_.cost,tokens:S,unpricedTokens:_.unpriced}:null;return{projects:k,totalCost:v,totalTokens:N,unpricedTokens:x,perDay:b,unattributed:$,unpricedModels:[...p].sort(),calibrated:h,reconciled:h&&x===0}}function mr(e,t,n=ct){return t>0?e>0?`${n(e)}+`:ha: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 Wre(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 ${ha}: this build holds no published rate for it, so its tokens are counted and its dollars are not.`:`${n} are ${ha}: this build holds no published rate for them, so their tokens are counted and their dollars are not.`}const Hre={phase:"running"},zre={phase:"failed"},Vre={gen:0,report:null,error:null,early:null};function Gre(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:Hre;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 Kre(e){var t;return((t=e.report)==null?void 0:t.gen)!==e.gen&&e.error===null}function Yre(e){const t=e;return t&&t.ok!==!1?{phase:"ready",range:t}:zre}function Xre(e){return`${e.getFullYear()}${String(e.getMonth()+1).padStart(2,"0")}${String(e.getDate()).padStart(2,"0")}`}function Zre(e,t,n=Date.now()){const s=t===0?60:t,a=new Date(n),o=X1(s,a),i=Xre(a);return{report:`/api/account-projects?num=${e}&days=${t}`,ccusage:`/api/ccusage?since=${o}&until=${i}`}}function Jre({num:e,days:t,gen:n,dispatch:s,get:a=(i,l)=>fetch(i,l),now:o=Date.now()}){const i=Zre(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:Yre(u)}))}function H5(e){return/^[A-Za-z]:[\\/]$/.test(e)?e:e.replace(/[\\/]+$/,"")}function cw(e){const t=H5(e).replace(/\\/g,"/");return/^[A-Za-z]:\//.test(t)?t.toLowerCase():t}function KA(e){if(!e)return e;const t=H5(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 Qre(e,t){const n=cw(e);let s;for(const a of t){const o=cw(a.path);!o||o===n||!n.startsWith(`${o}/`)||(!s||cw(s.path).length<o.length)&&(s=a)}return s==null?void 0:s.label}function tj(e){return e===0?"all time":e===1?"today":`the last ${e} days`}function eae(e){return e===1?"No work attributed to this account yet today.":`No work attributed to this account in ${tj(e)}.`}function tae(e){return e===1?7:e===7?30:e===30?0:null}function nae(e,t){return e!==1&&t>0}const sae=[{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)"],rae="var(--usage-zinc)",uw=6,aae=1600;function oae(e){const t=ct(e),n=/^\$(\d{4,})$/.exec(t);return n?`$${Number(n[1]).toLocaleString("en-US")}`:t}function mf(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 iae(e){const t=/^\d{4}-(\d{2})-(\d{2})$/.exec(e);return t?`${Number(t[1])}/${Number(t[2])}`:e}function lae(e){const t=Math.max(1,Math.ceil(e/6));return n=>n===0||n===e-1||n%t===0}function dw(e){if(!e)return"";try{return new Date(e).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return""}}function cae({num:e,name:t,onClose:n}){var D,K,V,H;an("account-projects");const[s,a]=g.useState(1),[o,i]=g.useReducer(Gre,Vre),l=((D=o.report)==null?void 0:D.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,b]=g.useState(()=>new Set),k=Kre(o),v=o.error,[N,x]=g.useState(null),C=g.useRef(void 0),S=g.useRef(!0);g.useEffect(()=>()=>{S.current=!1,window.clearTimeout(C.current)},[]);const _=g.useRef(null),$=gt(n,{focusRef:_}),A=yt(n),O=g.useRef(0);g.useEffect(()=>{const P=++O.current;i({type:"start",gen:P}),m(null),b(new Set),Jre({num:e,days:s,gen:P,dispatch:i})},[e,s]);const M=g.useMemo(()=>{const P=Date.now();if(!l)return null;const I=Ure(l.daily??[],l.unattributed,qre(h),P),U=je=>je.replace(/[\\/]+$/,"").split(/[\\/]/).pop()||je||"(unknown)",Z=new Map;for(const je of I.projects)Z.set(U(je.path),(Z.get(U(je.path))??0)+1);const z=je=>{const Ee=U(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:Qre(je.path,X),cost:je.cost,tokens:je.tokens,unpricedTokens:je.unpricedTokens}),J=pl[uw%pl.length],Q=new Map,te=[],le=I.projects.slice(0,uw),de=I.projects.slice(uw);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:Wre(I.unpricedModels),calibrated:I.calibrated,reconciled:I.reconciled}},[l,h]),W=(P,I)=>{ho(P).then(U=>{S.current&&(window.clearTimeout(C.current),x({path:P,label:I,ok:U}),C.current=window.setTimeout(()=>{S.current&&x(null)},aae))})},B=P=>N!=null&&N.ok&&N.path===P?"Copied":"Copy",R=l!=null&&l.trackedSince?`Tracked since ${dw(l.trackedSince)}`:"Tracking starts with this version",q=tj(u),T=tae(u),F=k&&!!l;return vt.createPortal(r.jsx("div",{className:"modal-backdrop",...A,role:"presentation",children:r.jsxs("div",{ref:$,className:"modal ap-proj-modal",onClick:P=>P.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:sae.map(P=>r.jsx("button",{type:"button",className:"uh-range-btn","aria-pressed":s===P.days,onClick:()=>a(P.days),children:P.label},P.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":k,children:[k&&!l&&r.jsx(Bre,{}),!k&&v&&r.jsxs("div",{className:"ap-proj-state ap-proj-error",children:["Couldn’t load this report: ",v]}),!v&&M&&r.jsx("div",{className:"ap-proj-ready",children:M.rows.length===0?r.jsxs("div",{className:"ap-proj-state",children:[F?"Updating…":eae(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 ",tj(T)]})}),r.jsxs("div",{className:"ap-proj-note",children:[R,". 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 ${M.basis==="cost"?ct(M.totalCost):`${Ct(M.totalTokens)} tokens`} across ${M.projectCount} project${M.projectCount>1?"s":""}`,children:M.rows.map(P=>{const I=M.basis==="cost"?P.cost:P.tokens,U=M.denom>0?I/M.denom*100:0;if(U<=0)return null;const Z=M.basis==="cost"?mf(P.cost,M.totalCost):`${mf(P.tokens,M.totalTokens)} of tokens`;return r.jsx("span",{className:"ap-proj-seg",style:{width:`${U}%`,background:P.color},title:`${P.label} · ${mr(P.cost,P.unpricedTokens)} · ${Z}${P.tokens?` · ${Ct(P.tokens)} tokens`:""}`},P.key)})}),r.jsxs("div",{className:"ap-proj-totals",children:[r.jsx("span",{className:"ap-proj-total-cost",title:fl(M.unpricedTokens),children:mr(M.totalCost,M.unpricedTokens)}),r.jsxs("span",{className:"ap-proj-total-tok",children:[Ct(M.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…"})]}),M.unpricedNote&&r.jsx("div",{className:"ap-proj-note",children:M.unpricedNote}),nae(u,M.chart.length)&&r.jsxs("div",{className:"ap-proj-days",children:[r.jsxs("div",{className:"ap-proj-days-cap",children:["By day",M.chart.length>1?" · click a bar":""]}),r.jsx("div",{className:"ap-proj-days-plot",role:"group","aria-label":`Spend across ${M.chart.length} day${M.chart.length>1?"s":""}`,children:M.chart.map(P=>{const I=M.maxDay>0?P.total/M.maxDay*100:0,U=p===P.day,Z=M.rows.map(X=>({label:X.label,c:P.costByColor.get(X.color)??0,u:P.unpricedByColor.get(X.color)??0})).filter(X=>X.c>0||X.u>0),z=`${dw(Date.parse(`${P.day}T00:00:00`))}, ${mr(P.total,P.unpriced)}. ${Z.map(X=>`${X.label} ${mr(X.c,X.u)}`).join(", ")}`;return r.jsx("button",{type:"button",className:`ap-proj-day${U?" selected":""}`,"aria-pressed":U,"aria-label":z,title:`${P.day} · ${mr(P.total,P.unpriced)}`,onClick:()=>m(X=>X===P.day?null:P.day),children:r.jsx("span",{className:"ap-proj-col",style:{height:`${I}%`},children:M.colorOrder.map((X,Y)=>{const J=P.costByColor.get(X)??0;return J<=0||P.total<=0?null:r.jsx("span",{className:"ap-proj-colseg",style:{height:`${J/P.total*100}%`,background:X}},Y)})})},P.day)})}),(()=>{const P=lae(M.chart.length);return r.jsx("div",{className:"ap-proj-days-axis","aria-hidden":"true",children:M.chart.map((I,U)=>r.jsx("div",{className:"ap-proj-axis-cell",children:P(U)?iae(I.day):""},I.day))})})(),(()=>{const P=p?M.chart.find(U=>U.day===p):null;if(!P)return null;const I=M.rows.map(U=>({r:U,c:P.costByColor.get(U.color)??0,u:P.unpricedByColor.get(U.color)??0})).filter(U=>U.c>0||U.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:dw(Date.parse(`${P.day}T00:00:00`))}),r.jsx("span",{className:"ap-proj-day-detail-total",title:fl(P.unpriced),children:mr(P.total,P.unpriced)})]}),I.map(({r:U,c:Z,u:z})=>r.jsxs("div",{className:"ap-proj-day-detail-row",children:[r.jsx("span",{className:"ap-proj-dot",style:{background:U.color},"aria-hidden":"true"}),r.jsx("span",{className:"ap-proj-day-detail-name",children:U.label}),r.jsx("span",{className:"ap-proj-day-detail-cost",title:fl(z),children:mr(Z,z)})]},U.key))]})})()]}),r.jsx("ul",{className:"ap-proj-list",children:M.rows.map((P,I)=>{const U=M.basis==="cost"?P.cost:P.tokens,Z=M.denom>0?U/M.denom*100:0,z=w.has(P.key),X=`ap-proj-details-${I}`,Y=z&&(!!P.path||!!P.members),J=P.members?`${z?"Hide":"Show"} the ${P.members.length} project${P.members.length>1?"s":""} folded into Other`:`${z?"Hide":"Show"} location for ${P.label}`;return r.jsxs("li",{className:`ap-proj-row${P.muted?" muted":""}${z?" expanded":""}`,children:[r.jsx("span",{className:"ap-proj-dot",style:{background:P.color},"aria-hidden":"true"}),r.jsxs("span",{className:"ap-proj-name",children:[P.label,P.parentLabel&&r.jsxs("span",{className:"ap-proj-parent",children:[" · in ",P.parentLabel]})]}),r.jsx("span",{className:"ap-proj-track",title:M.basis==="cost"?`${mf(P.cost,M.totalCost)} of tracked cost`:`${mf(P.tokens,M.totalTokens)} of tracked tokens`,children:r.jsx("span",{className:"ap-proj-fill",style:{width:`${Z}%`,background:P.color}})}),r.jsx("span",{className:"ap-proj-cost",title:fl(P.unpricedTokens),children:mr(P.cost,P.unpricedTokens)}),r.jsx("span",{className:"ap-proj-tok",children:Ct(P.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:()=>b(Q=>{const te=new Set(Q);return te.has(P.key)?te.delete(P.key):te.add(P.key),te}),children:"ⓘ"}),z&&P.path&&r.jsxs("div",{className:"ap-proj-details",id:X,children:[r.jsx("code",{className:"ap-proj-path",children:KA(P.path)}),r.jsx("button",{type:"button",className:"ap-proj-copy","aria-label":`${B(P.path)} location for ${P.label}`,onClick:()=>W(P.path,P.label),children:B(P.path)})]}),z&&P.members&&r.jsx("div",{className:"ap-proj-details ap-proj-other-members",id:X,children:P.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:KA(Q.path)}),r.jsx("span",{className:"ap-proj-cost",title:fl(Q.unpricedTokens),children:mr(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:()=>W(Q.path,Q.label),children:B(Q.path)})]},Q.path))})]},P.key)})}),M.un&&r.jsxs("div",{className:"ap-proj-unattributed",children:[r.jsx("span",{className:"ap-proj-dot",style:{background:rae},"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(M.un.unpricedTokens),children:mr(M.un.cost,M.un.unpricedTokens,oae)}),r.jsx("span",{className:"ap-proj-un-tok",children:Ct(M.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":M.reconciled?"Dollars from ccusage · split by activity":M.calibrated?"Dollars from ccusage for the priced models · split by activity":h?"Dollars estimated · ccusage could not price this window":"Dollars estimated · ccusage unavailable"," · ",R]})]})})]})]})}),document.body)}function fa(e,t){return XP(t-Math.floor(e/1e3))}function uae(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 eS(){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 dae({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(vd,{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(eS,{}),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 ${fa(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 hae=typeof window>"u"?g.useEffect:g.useLayoutEffect,hw="ccdeck:account-hint";function fae(e,t,n){return n?[...new Set([...(e==null?void 0:e.split(/\s+/).filter(Boolean))??[],t])].join(" "):e}function pae({children:e,detail:t,disabled:n=!1,className:s,portalRootId:a,focusDelay:o=0,shouldShow:i,placement:l="popover"}){const u=g.useId(),h=e.props.id??u,f=`${h}-hint`,[p,m]=g.useState(!1),w=g.useRef(0),b=g.useRef(null),k=g.useRef(n),v=g.useRef(i);k.current=n,v.current=i;const N=()=>window.clearTimeout(w.current),x=()=>{N(),m(!1)},C=()=>{var M;const A=document.getElementById(h);if(!A||!A.getClientRects().length||((M=A.checkVisibility)==null?void 0:M.call(A))===!1)return null;const O=A.getBoundingClientRect();return O.bottom<=0||O.top>=innerHeight||O.right<=0||O.left>=innerWidth?null:A},S=()=>{var O;N();const A=C();k.current||!A||((O=v.current)==null?void 0:O.call(v,A))===!1||(document.dispatchEvent(new CustomEvent(hw,{detail:f})),m(!0))},_=()=>{N(),w.current=window.setTimeout(()=>m(!1),140)};g.useEffect(()=>()=>window.clearTimeout(w.current),[]),g.useEffect(()=>{n&&(window.clearTimeout(w.current),m(!1))},[n]),hae(()=>{if(!p||n)return;const A=()=>{var I,U,Z;const R=b.current,q=C();if(!R||!q||((I=v.current)==null?void 0:I.call(v,q))===!1){m(!1);return}R.style.maxHeight="";const T={width:R.offsetWidth,height:R.offsetHeight},F={width:innerWidth,height:innerHeight},D=R.getBoundingClientRect(),K=(U=R.firstElementChild)==null?void 0:U.getBoundingClientRect(),V=(Z=R.lastElementChild)==null?void 0:Z.getBoundingClientRect(),H=K&&V?K.top-D.top+K.height+D.bottom-V.bottom:T.height,P=l==="reading"?WQ(q.getBoundingClientRect(),T,F,H):DD(q.getBoundingClientRect(),T,F);if(!P){m(!1);return}R.style.left=`${P.left}px`,R.style.top=`${P.top}px`,R.style.maxHeight=P.maxHeight==null?"":`${P.maxHeight}px`},O=R=>{var T,F;const q=R.target;!((T=b.current)!=null&&T.contains(q))&&!((F=document.getElementById(h))!=null&&F.contains(q))&&x()},M=R=>{var q;(q=b.current)!=null&&q.contains(R.target)||x()},W=R=>{R.detail!==f&&x()};A();const B=rn.push(x,0,"popover");return window.addEventListener("resize",A),window.addEventListener("scroll",M,!0),document.addEventListener("pointerdown",O,!0),document.addEventListener(hw,W),()=>{window.removeEventListener("resize",A),window.removeEventListener("scroll",M,!0),B(),document.removeEventListener("pointerdown",O,!0),document.removeEventListener(hw,W)}},[p,n,h,t,i,a,l]);const $=fae(e.props["aria-describedby"],f,p&&!n);return r.jsxs(r.Fragment,{children:[g.cloneElement(e,{id:h,title:void 0,tabIndex:e.props.tabIndex??0,"aria-describedby":$,onPointerEnter:A=>{var O,M;(M=(O=e.props).onPointerEnter)==null||M.call(O,A),A.pointerType==="mouse"&&(N(),w.current=window.setTimeout(S,300))},onPointerLeave:A=>{var O,M;(M=(O=e.props).onPointerLeave)==null||M.call(O,A),_()},onFocus:A=>{var O,M;(M=(O=e.props).onFocus)==null||M.call(O,A),N(),o>0?w.current=window.setTimeout(S,o):S()},onBlur:A=>{var O,M;(M=(O=e.props).onBlur)==null||M.call(O,A),x()},onClick:A=>{var O,M;x(),(M=(O=e.props).onClick)==null||M.call(O,A)},onContextMenu:A=>{var O,M;x(),(M=(O=e.props).onContextMenu)==null||M.call(O,A)},onDragStart:A=>{var O,M;x(),(M=(O=e.props).onDragStart)==null||M.call(O,A)},onKeyDown:A=>{var O,M;nm(A.key)||x(),(M=(O=e.props).onKeyDown)==null||M.call(O,A)}}),p&&!n&&vt.createPortal(r.jsx("div",{ref:b,id:f,className:s,role:"tooltip",onPointerEnter:N,onPointerLeave:_,children:t}),(a?document.getElementById(a):null)??document.body)]})}function nj({children:e,detail:t,disabled:n=!1}){return r.jsx(pae,{className:"ap-peek ap-account-hint",detail:t,disabled:n,children:e})}function mae({num:e,name:t,telemetry:n,boundaryId:s="ap-scroll"}){const[a,o]=g.useState(!1),i=`ap-telemetry-mark-${e}`,l=`ap-telemetry-pop-${e}`;return r.jsxs(r.Fragment,{children:[r.jsx(nj,{detail:n.detail,disabled:a,children:r.jsx("button",{type:"button",id:i,className:"ap-more ap-telemetry","data-tone":n.tone,title:n.detail,"aria-label":`Organization telemetry for ${t}`,"aria-describedby":`ap-telemetry-${e}`,"aria-haspopup":"dialog","aria-expanded":a,"aria-controls":a?l:void 0,onClick:()=>o(u=>!u),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:"M7 1.5 11.5 3v3.4c0 2.7-1.8 4.8-4.5 6.1-2.7-1.3-4.5-3.4-4.5-6.1V3Z"}),r.jsx("path",{d:"M7 4.4v3M7 9.3v.05"})]})})}),r.jsx("span",{className:"vis-hidden",id:`ap-telemetry-${e}`,children:n.detail}),a&&r.jsx(vd,{anchorId:i,boundaryId:s,id:l,className:"ap-pop ap-issue-pop ap-telemetry-pop",role:"dialog",labelledBy:`${l}-title`,onClose:()=>o(!1),children:r.jsxs("div",{className:"ap-pop-form",children:[r.jsx("p",{className:"ap-pop-title",id:`${l}-title`,children:"Organization telemetry"}),r.jsx("p",{className:"ap-pop-note",children:n.detail}),r.jsx("div",{className:"ap-pop-actions",children:r.jsx("button",{type:"button",className:"btn",onClick:()=>o(!1),children:"Done"})})]})})]})}const gae=5*6e4;function yae(e,t){return typeof e!="string"||!e?!1:e==="::1"||e==="localhost"||e.startsWith("127.")?!0:Array.isArray(t)&&t.includes(e)}function wae(e,t,n=gae){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||yae(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 z5(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 xae(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 vae(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 bae(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 YA={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 kae(e){const t=z5(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=Nae(e,t);return e.active===!0&&((a=n==null?void 0:n.elsewhere)!=null&&a.length)&&(!s||s.tone!=="warn")?kae(n.elsewhere):!s||!(n!=null&&n.noCopyWorksNearby)||!jae(e)?s:{...s,text:YA.text,hint:YA.hint}}function jae(e){return e.staleCopy?!1:e.stopped?e.collector==="relogin_required":e.error==="invalid_grant"||e.error==="no_refresh_token"}function Nae(e,t){if(e.staleCopy){const n=xae(e.repair??null,t);return{text:ku(n.text),hint:n.hint,fix:null,tone:"quiet",blocksSwitch:!1}}if(e.stopped){const n=bae(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=vae(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 XA(e){return typeof e.id=="string"&&e.id.startsWith("scoped-")}function ZA(e){const t=e.filter(l=>!XA(l)),n=e.filter(l=>XA(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 ld(e,t){return!!e.resetAt&&e.resetAt<=t}function tS(e,t){return(e.lanes??[]).some(s=>ld(s,t))?null:e.headroom}const Sae="\0";function vs(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}${Sae}${n}`}function Cae(e,t,n=vs){const s=n(t);return e.includes(s)?e.filter(a=>a!==s):[...e,s]}const km="slot",nS=[{lane:"five_hour",name:"5h"},{lane:"seven_day",name:"7d"}],V5=e=>e.id.startsWith("scoped-");function _ae(e){var t;return((t=nS.find(n=>n.lane===e.id))==null?void 0:t.name)??e.label}function Eae(e){if(e==="room")return"room";const t=/^(.+):(full|empty)$/.exec(e);return t?t[1]:null}function G5(e){const t=[...new Set(e.flatMap(s=>(s.lanes??[]).filter(V5).map(a=>a.label)))].sort((s,a)=>s.localeCompare(a)),n=[...nS.map(s=>s.name),...t];return[{id:km,label:"Slot"},...n.flatMap(s=>[{id:`${s}:full`,label:`${s} · fullest`},{id:`${s}:empty`,label:`${s} · emptiest`}]),{id:"room",label:"Most room"}]}function JA(e,t,n){const s=nS.find(o=>o.name===t),a=(e.lanes??[]).find(o=>s?o.id===s.lane:V5(o)&&o.label===t);return a&&n!=null&&ld(a,n)?null:a&&Number.isFinite(a.pct)?a.pct:null}function K5(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:tS(p,s);return o(QA(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=>JA(f,l,s)!=null))return a;const h=QA(a,f=>JA(f,l,s),u==="full"?"desc":"asc");return u==="empty"?o(h):h}function QA(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 Y5(e,t){return G5(t).some(n=>n.id===e)?e:km}function sj(e,t){if(!t)return[...e];const n=new Map(t.map((o,i)=>[o,i])),s=e.filter(o=>n.has(vs(o))).sort((o,i)=>n.get(vs(o))-n.get(vs(i))),a=e.filter(o=>!n.has(vs(o)));return[...s,...a]}function sS(e){const t=vs(e);return t.startsWith("slot:")?t:`h:${Tae(t)}`}function Tae(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 rj={mode:"some",keys:[]};function X5(e,t){const n=e.keys.includes(sS(t));return e.mode==="all"?!n:n}function Aae(e,t){return{mode:e.mode,keys:Cae(e.keys,t,sS)}}function Z5(e,t){return t.length>0&&t.every(n=>X5(e,n))}function Rae(e,t){return Z5(e,t)?rj:{mode:"all",keys:[]}}function Mae(e,t){if(!Array.isArray(t))return e;const n=new Set(t.map(sS)),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 eR(e){return e.counted?e.pct:e.why==="login"?null:e.estimate}function $ae(e){const t=eR(e.five_hour),n=eR(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 Lae(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:fa(e.updatedAt,t),old:!0}}const J5=15*6e4;function jm(e){return e!=null&&e>0&&Number.isFinite(e)&&Number.isFinite(new Date(e).getTime())?e:null}const Q5=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 aj(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)?e6(a.pct):null,i=xi(e,n),l=Iu(e,t),u=l!=null&&l<=n,h=t6(a,e.fetchedAt,n),f=(w,b)=>({counted:!1,why:w,say:b,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=jm(e.fetchedAt);return e.stale||e.staleCopy===!0||e.stopped===!0||p==null||n*1e3-p>J5?f("stale",p!=null?`Updated ${fa(p,n)}`:"Never read"):{counted:!0,pct:o,resetAt:Iu(e,t)}}const e6=e=>Math.min(100,Math.max(0,e));function t6(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=jm(t),a=s!=null?`read ${fa(s,n)}`:"last read";return`Reported reset time passed ${fa(e.resetAt*1e3,n)}, ${oo(e6(e.pct))}% when ${a}`}function Iae(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 rS(e,t){const n=e.map(a=>{const o={five_hour:aj(a,"five_hour",t),seven_day:aj(a,"seven_day",t)};return{num:a.num,key:vs(a),name:Q5(a),active:a.active,heldOut:a.disabled===!0,cells:o,resets:{five_hour:Iu(a,"five_hour"),seven_day:Iu(a,"seven_day")},status:$ae(o),updatedAt:jm(a.fetchedAt)}}),s=n.filter(a=>a.status==="ready").length;return{rows:n,windows:ii.map(a=>Iae(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 Oae={ready:0,limited:1,exhausted:2,stale:3};function Pae(e){return e.counted?e.pct:e.reset?e.estimate:e.last}function tR(e,t){return t==="status"?Oae[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:Pae(e.cells[t])}function Dae(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=tR(o,t.key),u=tR(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 Fae(e){const t=oo(e);return{used:t,available:100-t}}function Bae(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 n6=new Set(["awaiting_url","awaiting_code","registering"]);function s6(e){return e!=null&&n6.has(e)}function r6(e){return e!=null&&e!=="done"&&!n6.has(e)}const a6="the sign-in ended before it finished — the deck restarted, or it was cancelled in another tab",qae="the sign-in did not complete";function Uae({state:e,serverError:t,localError:n}){const s=e==="idle";return{title:s?"Sign-in ended":"Sign-in failed",message:n||t||(s?a6:qae)}}function nR({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 sR({started:e,state:t}){return!e||t==="done"?null:{action:"login-cancel"}}function Wae({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":r6(e==null?void 0:e.state)||n&&t&&!s?"ended":s||s6(e==null?void 0:e.state)?"asking":"primer"}function aS(e,t){return t?Jt(e,t):void 0}const Hae={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"},zae={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"},oS=`claude-swap could not read the login keychain — start ${Pt} from a Terminal window rather than a background service`,Vae={unreadable_here:{short:"Keychain locked on this Mac",long:`${oS}.`},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 kp(e){return e?Jt(Vae,e)??null:null}const o6={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 oj(e,t,n){const s=n==null?null:o6[n];if(s)return s;if((e==null?void 0:e.reason)!=="no_cswap"&&/keychain/i.test(cd(e)))return oS;const a=aS(zae,e==null?void 0:e.reason);return a||(e==null?void 0:e.reason)||t}function cd(e){return((e==null?void 0:e.output)||(e==null?void 0:e.detail)||(e==null?void 0:e.error)||"").trim()}const Gae={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"},Kae="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 Yae(e){return/\bnpx\b/i.test(e)&&/(command not found|not found|not recognized|ENOENT)/i.test(e)}const Xae="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",Zae="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",Jae=e=>/\b(?:ERR_)?MODULE_NOT_FOUND\b|cannot find (?:module|package)/i.test(e),Qae=/node_modules[\\/]npm[\\/]bin[\\/]|\bnpm-prefix\.js\b|\bnp[mx][-.][\w.-]*cli\.js\b/i,eoe=/[\\/]_npx[\\/]/i,toe=`the copy of ccusage ${Pt} installed for itself`;function noe(e){const t=String((e==null?void 0:e.install)??"").replace(/\s+/g," ").trim();return t.length>240?`${t.slice(0,239)}…`:t}function uje(e,t){const n=soe(e,t),s=noe(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`${toe} 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 soe(e,t){const n=cd(e);if(Jae(n)){if(eoe.test(n))return Zae;if(Qae.test(n))return Xae}if(Yae(n))return Kae;const s=aS(Gae,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:o6[n];if(s)return s;if(e!=null&&e.detail)return e.detail;if(e!=null&&e.error&&r6(e.state))return e.error;const a=aS(Hae,e==null?void 0:e.reason);return a||(e!=null&&e.error?e.error:(e==null?void 0:e.reason)||t)}function kr(e,t){if(e==null)return"not seen";const n=Math.max(0,Math.round((t-e)/1e3));if(n<90)return"now";const s=Math.round(n/60);if(s<60)return`${s}m ago`;const a=Math.round(s/60);return a<48?`${a}h ago`:`${Math.round(a/24)}d ago`}const roe={keychain_unavailable:{short:"Keychain locked on the other Mac",long:`the other Mac could not export it. On that Mac: ${oS}. 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 ij(e){return e.why?Jt(roe,e.why)??kp(e.why):null}const iS={"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"}},aoe={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 rR(e){var s;const t=ooe[e];if(t)return t;const n=(s=/\b(E[A-Z]{3,})\b/.exec(e))==null?void 0:s[1];return n&&aoe[n]||e}const ooe={"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 Nm(e,t){var f;if(!e)return null;if(e.error&&((f=e.done)!=null&&f.length)){const p=Nm({...e,error:void 0},t),m=` · ${kr(e.at,t)}`;return{...p,text:`${p.text.slice(0,-m.length)}, then ${rR(e.error)}${m}`,tone:"bad"}}if(e.error)return iS[e.error]??{text:rR(e.error),tone:"bad"};const n=e.done??[];if(!n.length)return{text:`all logins fine · ${kr(e.at,t)}`,tone:"idle"};const s=n.filter(p=>p.ok),a=s.length===1?"login":"logins",o=n.map(p=>({d:p,why:ij(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=kr(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 ioe=9e4;function loe({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<ioe);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 Sm(e,t){var n,s;return(n=e.last)!=null&&n.error&&!iS[e.last.error]?!1:!!((s=e.last)!=null&&s.at&&t-e.last.at<lj||e.lastSeen!=null&&t-e.lastSeen<lj)}const lj=95e3;function coe(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?i6(p.lastSeen,t):Sm(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 c6(s,m=>cS(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 uoe(e,t,n){if(n)return"checking…";if(e==null)return"not checked yet";const s=kr(e,t);return s==="now"?"checked just now":`checked ${s}`}function lS(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 i6(e,t){return e!=null&&t-e<lj}function doe(e,t){if(e==null)return{text:"one-way · has not called yet",here:!1};const n=i6(e,t);return{text:n?"online · one-way, it calls in":`one-way · last online ${kr(e,t)}`,here:n}}function aR(e,t,n){return t?"online":e.lastSeen!=null?`last online ${kr(e.lastSeen,n)}`:e.waiting?"has not called yet":"never reached"}function hoe(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(foe(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(poe(p,m,t)):i.push(moe(p,m,o,t)))}n.push(...woe(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(goe(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(yoe(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 foe(e,t,n){const s=Cm(t,e.fp,e.name||e.fp);return{fp:e.fp,...s,addr:e.addr??"",kind:"asks",state:`wants to pair · ${lS(e.at,n)}`,tone:"wait",here:!0,hint:`${s.name} at ${e.addr}${e.via==="tailscale"?", over Tailscale,":""} is waiting for an answer.`,..._m(e.via)}}function poe(e,t,n){var o;const s=Nm(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?cj(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.`,..._m(e.via)}}function moe(e,t,n,s){var w,b,k,v;const a=Nm(e.last,s),o=Sm(e,s),i=e.addr?`${e.addr}:${e.port}`:"",l=e.waiting?doe(e.lastSeen,s):null,u=l?l.here:o,h=!l&&a?u?`online · ${cj(a)}`:`${cj(a)} · ${aR(e,u,s)}`:l?l.text:aR(e,u,s),f=(w=e.last)!=null&&w.error?iS[e.last.error]:null,p=!l&&u&&!((b=e.last)!=null&&b.error)&&!(((k=e.last)==null?void 0:k.done)??[]).length,m=cS(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,..._m(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 ${kr(e.lastSeen,s)}.`} Add its address through Add a deck, the link at the top of this view, to reach it either way.`:`${m.name}${i?` at ${i}`:""}${(v=e.last)!=null&&v.error?` — ${e.last.error}`:""}${a!=null&&a.hint?` — ${a.hint}`:""}`}}function cS(e,t,n){return e.manual&&!e.met?{name:e.addr?`${e.addr}:${e.port}`:""}:Cm(n,t,e.name||t)}function l6(e,t){return cS(e,e.peerFp??e.fp,t).name}function goe(e,t,n){const s=Cm(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.`,..._m(e.via)}}function yoe(e,t){const n=Cm(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 Cm(e,t,n){const s=t?e[t]:void 0;return s&&s!==n?{name:s,self:n}:{name:n}}function _m(e){return e==="tailscale"?{via:"tailscale"}:{}}function cj(e){return e.text.replace(/ · .*$/,"")}function woe(e){return c6(e,t=>t.name,t=>t.addr).map(xoe)}function c6(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 xoe(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 oR(e,t){return t?e.map(n=>t[n.fp]?{...n,name:t[n.fp]}:n):e}function ud(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 voe(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 boe(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 iR(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 koe(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 joe(e,t,n){if(!(t!=null&&t.enabled))return!1;const s=(t.peers??[]).filter(o=>o.paired&&Sm(o,n));if(s.some(o=>{var i,l,u;return Noe((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 Noe=e=>!!e&&typeof e=="object"&&e.hidden===!0;function Soe(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||!Sm(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 Coe(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=>l6(s,t.aliases??{})).filter(Boolean);return[...new Set(n)].sort((s,a)=>s.localeCompare(a))}function _oe(e,t,n){const s=wae(t,n).get(e);if(!(s!=null&&s.length))return null;const a=s.map(o=>l6(o,(t==null?void 0:t.aliases)??{})).filter(Boolean);return[...new Set(a)].sort((o,i)=>o.localeCompare(i))}function Eoe(e,t){return e.flatMap(n=>{const s=Coe(n.key,t);return s?[[n.key,{to:s,inUse:n.inUse===!0}]]:[]})}function fw(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 u6={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 jp(e){return e.length<=1?e.join(""):`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function Toe(e,t,{holdOut:n=!1}={}){if(!e||e.level!=="metrics"&&e.level!=="content")return null;const s=e.level==="content"?e.content.map(l=>u6[l]??l):[],a=e.orgName?e.orgName:"This account's organization",o=s.length?`usage data, and your ${jp(s)}`:"usage data",i=e.destinations.length?jp(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 ${fa(e.seenAt,t)}, while this account was active.`+(n?" To keep Auto-switch off it, choose Hold out of rotation in its ⋯ menu.":"")}}function Aoe(e){if(!e||e.level!=="metrics"&&e.level!=="content")return null;const t=e.level==="content"?e.content.map(o=>u6[o]??o):[],n=t.length?`your ${jp(t)}`:"usage data",s=e.orgName?`${e.orgName}'s telemetry`:"Its organization's telemetry",a=e.destinations.length?` to ${jp(e.destinations)}`:"";return`${s} is on for them: it sends ${n}${a}.`}function Roe(e){return e>=90?"hi":e>=70?"mid":void 0}function Moe({lane:e,nowSec:t,readAt:n,frozen:s,sortedBy:a}){const o=Math.min(100,Math.max(0,e.pct)),i=ld(e,t),l=s||i,u=l?"var(--muted)":o>=90?"var(--err)":o>=70?"var(--warn)":"var(--accent)",h=e.resetAt&&!l?wd(e.resetAt,t):null,f=i?t6(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 $oe({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:b,swapped:k,displaced:v,issueExpanded:N,onOpenIssue:x,sortKey:C=null,home:S=null,rotating:_=!1,telemetryBoundaryId:$}){const A=e.lanes.filter(P=>!ld(P,t)),{shown:O}=ZA(e.lanes),{fuller:M}=ZA(A),W=C==="room"?A.reduce((P,I)=>P&&P.pct>=I.pct?P:I,null):C?e.lanes.find(P=>_ae(P)===C)??null:null,B=xi(e,t,n),R=e.active||s,q=e.alias??e.email??`account ${e.num}`,T=e.alias&&e.email?`${e.alias} · ${e.email}`:q,F=e.stale||(B==null?void 0:B.blocksSwitch)===!0,D=M?[...O,M]:O,K=e.fetchedAt?fa(e.fetchedAt,t):null,V=Toe(e.telemetry,t,{holdOut:_&&!e.active&&!e.disabled}),H=Aoe(e.telemetry);return r.jsxs("li",{className:`ap-account${e.active?" active":""}`,"aria-current":e.active?"true":void 0,"data-open":R?"":void 0,"data-frozen":F?"":void 0,children:[!e.active&&r.jsx("button",{type:"button",className:"ap-row-open",id:`ap-row-${e.num}`,title:T,"aria-expanded":R,"aria-controls":R?`ap-detail-${e.num}`:void 0,"aria-describedby":[e.alias&&e.email?`ap-email-${e.num}`:null,S?`ap-home-${e.num}`:null,n!=null&&n.sharedTo?`ap-shared-${e.num}`:null,!R&&!(B!=null&&B.blocksSwitch)?`ap-quota-${e.num}`:null,V?`ap-telemetry-${e.num}`:null].filter(Boolean).join(" ")||void 0,onClick:()=>a(),children:r.jsxs("span",{className:"vis-hidden",children:[q,", ",R?"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}),V&&r.jsx(mae,{num:e.num,name:q,telemetry:V,boundaryId:$}),S&&r.jsx(nj,{detail:S,children:r.jsxs("span",{className:"ap-home",id:`ap-home-${e.num}`,title:S,role:"img","aria-label":"Home account",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:S})]})}),(n==null?void 0:n.sharedTo)&&r.jsx(nj,{detail:fw(n.sharedTo,n.sharedInUse),children:r.jsxs("span",{className:"ap-shared",id:`ap-shared-${e.num}`,title:fw(n.sharedTo,n.sharedInUse),role:"img","aria-label":"Account sharing",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:fw(n.sharedTo,n.sharedInUse)})]})}),e.disabled&&r.jsx("span",{className:"ap-held",children:"held out"}),!e.active&&!e.disabled&&!(B!=null&&B.blocksSwitch)&&r.jsx("button",{type:"button",className:"ap-switch",...i(`switch-${e.num}`),onClick:()=>l(e.num,q),"aria-label":`Switch to ${q}`,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:P=>{P.key!=="ArrowDown"&&P.key!=="ArrowUp"||(P.preventDefault(),h(e.num,P.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??q}`,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&&b&&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&&b&&H&&r.jsx("p",{className:"ap-switched",children:H}),k&&(()=>{const P=(v==null?void 0:v.alias)??(v==null?void 0:v.email)??"the account that was there";return r.jsxs("p",{className:"ap-note ap-swap-note",title:`Slot ${k.at} was taken, so the two accounts traded places: ${P} now holds slot ${k.displaced}.`,children:["swapped with slot ",k.displaced]})})(),B&&r.jsxs("div",{className:"ap-issue-line",children:[r.jsxs("button",{type:"button",id:`ap-issue-${e.num}`,className:"ap-issue","data-tone":B.tone,"aria-haspopup":"dialog","aria-expanded":N,"aria-controls":N?"ap-issue-pop":void 0,onClick:()=>x(e.num,`ap-issue-${e.num}`),children:[B.tone==="warn"&&r.jsx(eS,{}),r.jsx("span",{className:"ap-issue-text",children:B.text})]}),B.fix&&w&&r.jsx("button",{type:"button",className:"ap-sign-in","aria-label":`${B.fix} as ${e.email??q}`,title:B.hint,onClick:()=>w(e.email),children:"Sign in"}),!R&&r.jsx("span",{className:"ap-issue-age",title:"When claude-swap last read this account's usage",children:K??"never collected"})]}),!R&&!(B!=null&&B.blocksSwitch)&&r.jsxs("p",{className:"ap-quota",id:`ap-quota-${e.num}`,children:[D.length?D.map(P=>r.jsxs("span",{className:"ap-q","data-sort-key":P.id===(W==null?void 0:W.id)?"":void 0,children:[r.jsx("span",{className:"ap-q-label",children:P.label})," ",ld(P,t)?r.jsx("span",{className:"ap-q-pct",title:`${P.label} has reset since this reading`,children:"reset"}):r.jsxs("span",{className:"ap-q-pct","data-level":F?void 0:Roe(P.pct),children:[Math.round(P.pct),"%"]})]},P.id)):r.jsx("span",{className:"ap-q-label",children:"no usage recorded yet"}),e.stale&&!B&&r.jsx("span",{className:"ap-q-age","data-never":K?void 0:"",title:"When claude-swap last read this account's usage",children:K??"never collected"})]}),R&&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(P=>r.jsx(Moe,{lane:P,nowSec:t,readAt:e.fetchedAt,frozen:F,sortedBy:P.id===(W==null?void 0:W.id)},P.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&&!B?" 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 ",fa(e.fetchedAt,t),B!=null&&B.blocksSwitch?"":uae(e.nextAt,t)]}):r.jsx("span",{className:"ap-age ap-stale",title:"claude-swap has not read this account yet",children:"never collected"})})]})]})}function Loe({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 Ioe({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 Ooe=[{value:"room",label:"Most room left"},{value:"weekly",label:"Soonest weekly reset"}],Poe="Uses up quota that resets within 4 days first";function Doe(e){return e==="room"||e==="weekly"}function pw(e,t){return!t||!e.email?!1:e.email.trim().toLowerCase()===t.email.trim().toLowerCase()&&(e.orgUuid??"")===(t.orgUuid??"")}function Foe(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 mw=[70,80,85,90,95],d6="custom",bl=50,kl=99,Boe=`A whole percent from ${bl} to ${kl}.`;function qoe(e){const t=Number(e);return[...Number.isFinite(t)&&t>0&&!mw.includes(t)?[...mw,t]:mw].sort((s,a)=>s-a)}function Uoe(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 uj={pick:null,custom:null,refusal:null};function Woe(e,t){switch(t.kind){case"pick":return t.pick===d6?{...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 uj;case"leave":return e.custom&&(e.pick??t.stored)===t.stored?uj:e}}async function Hoe(e,t,n){if(!t.sends)return{kind:"unchanged"};const s=Uoe(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 zoe({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:b,nextPick:k,nextCtl:v,nextSaved:N,nextRef:x,nextSaveRef:C,proposeNext:S,doNext:_,pressProps:$,post:A,load:O}){const M=g.useId(),W=g.useId(),B=g.useId(),R=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",...$("enable"),onClick:()=>A({action:"enable",enabled:!e.enabled},"enable").then(()=>O(!0)),title:e.enabled?"Stop switching accounts automatically":"Switch accounts automatically when the active one nears its limit",children:r.jsx("span",{className:"switch-knob"})})]}),r.jsxs("div",{className:"ap-policy ap-setting",onKeyDown:l?m:void 0,children:[r.jsx("label",{className:"ap-setting-label",htmlFor:W,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(),b(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:W,className:"ap-manage-input ap-threshold-input",type:"text",inputMode:"numeric","aria-describedby":M,"aria-invalid":u?!0:void 0,value:n,...$("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:W,value:n,...$("threshold"),onChange:q=>f(q.target.value),children:[qoe(t).map(q=>r.jsxs("option",{value:q,children:[q,"%"]},q)),r.jsx("option",{value:d6,children:"Custom…"})]})}),(s.sends||a)&&r.jsx("button",{ref:i,type:"button",className:"ap-manage-btn",...$("threshold"),title:s.title,onClick:()=>b(n,s),children:a&&!s.sends?s.done:s.label})]}),u?r.jsx("p",{id:M,className:"ap-threshold-note",role:"alert","data-tone":"err",children:u},"refusal"):l?r.jsx("p",{id:M,className:"ap-threshold-note",children:Boe},"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:k,"aria-describedby":k==="weekly"?R:void 0,...$("next"),onChange:q=>S(q.target.value),children:Ooe.map(q=>r.jsx("option",{value:q.value,children:q.label},q.value))})}),(v.sends||N)&&r.jsx("button",{ref:C,type:"button",className:"ap-manage-btn",...$("next"),title:v.title,onClick:()=>_(),children:N&&!v.sends?v.done:v.label})]}),k==="weekly"&&r.jsx("p",{id:R,className:"ap-threshold-note",children:Poe}),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 lR=18,Voe=1100,ml=(e,t)=>{const n=Math.sin(e*12.9898+t*78.233)*43758.5453;return n-Math.floor(n)},Goe=Array.from({length:lR},(e,t)=>{const n=-72+144*t/(lR-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 cR({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),Voe);return()=>window.clearTimeout(l)},[e,s]),s||!t?null:vt.createPortal(r.jsx("div",{className:"confetti",style:{left:`${t.x}px`,top:`${t.y}px`},"aria-hidden":!0,children:Goe.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 Np=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"})]}));Np.displayName="SuccessMark";const Koe={done:", done",active:", in progress",failed:", failed",pending:""};function Yoe({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 Xoe({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(Yoe,{status:i.status}),r.jsxs("span",{className:"aa-stage-label",children:[i.label,r.jsx("span",{className:"vis-hidden",children:Koe[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 gw=["link","approve","confirm","save"],uR={confirm:"confirm",save:"save",restore:"save"};function h6(e){return e!=null&&Object.prototype.hasOwnProperty.call(uR,e)?uR[e]:null}function Zoe({state:e,step:t,starting:n}){return e==="registering"?h6(t)??"confirm":e==="awaiting_code"?"approve":e==="awaiting_url"||e==null&&n?"link":null}function Joe({state:e,step:t,url:n,lastLive:s}){return e==="failed"?h6(t)??(n?"approve":"link"):e==="idle"?s??"link":"link"}const Qoe={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 eie(e,t,n){return t==="failed"?f6(e,n):Qoe[e][t]}function tie({live:e=null,failed:t=null,done:n=!1,state:s=null}){const a=n?gw.length:gw.indexOf(t??e);return gw.map((o,i)=>{const l=n||i<a?"done":i>a||a<0?"pending":t?"failed":"active";return{id:o,status:l,label:eie(o,l,s)}})}function nie(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 sie={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 f6(e,t){return t==="idle"?"Sign-in ended":sie[e]}const rie=/^(?:claude|claude-swap|cswap|ccdeck|npm|uv)\b/;function Ff(e){const t=String(e??"").trim();if(!t)return"";const n=rie.test(t)?t:t[0].toUpperCase()+t.slice(1);return/[.!?…]$/.test(n)?n:`${n}.`}Ff(a6);const aie=1e4,oie=1e4,iie=5;function lie({since:e,now:t,expiresAt:n}){if(e==null||t-e<aie)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<=iie?`${a} — the sign-in stays open ${s} more minute${s===1?"":"s"}.`:`${a}.`}function cie({since:e,now:t}){return e==null||t-e<oie?null:"Still importing. claude-swap stops by itself after a minute if it cannot finish."}function uie(e){return e==="registering"?400:1500}const p6=460;function die({fromStages:e,reducedMotion:t}){return e&&!t?p6:0}function hie({added:e,reducedMotion:t}){return e&&!t}function dR({num:e,added:t}){return t?e!=null&&e!==""?`Account ${e} added`:"Account added":"Credentials refreshed"}function fie(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 pie="done";function mie(){let e=!1;return{shouldAnnounce(t){return t!==pie?(e=!1,!1):e?!1:(e=!0,!0)}}}function uS(e,t,n,s="horizontal"){if(n<=0||sm(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 m6(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 gie(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 yie(e,t){return e.filter(n=>!t.includes(n.num)).map(n=>n.num)}function wie(e,t){return e.includes(t)?e.filter(n=>n!==t):[...e,t]}function xie(e){return e.length?{action:"share",accounts:[...e]}:null}function vie(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 dj(e){return`${e.email}|${e.org??""}`}function bie(e,t,n){return e&&e.map(s=>dj(s)===t?n:s)}function kie(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 hR(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=kp(f.check))==null?void 0:p.short}).filter(f=>!!f))];return`${s.join(", ")}${h.length?`, ${h.join(", ")}`:""}.`}function jie(e){try{return e?new URL(e).host:""}catch{return""}}const gf=[{id:"login",label:"Sign in"},{id:"paste",label:"Paste a share"}],fR="aa-panel",pR=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 g6({onClose:e,onChanged:t,email:n=null,onSignedIn:s}){an("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),[b,k]=g.useState(!1),[v,N]=g.useState(null),[x,C]=g.useState(null),S=m||b,[_,$]=g.useState(null),[A,O]=g.useState(null),[M,W]=g.useState(null),B=g.useRef(""),R=g.useRef(!1),q=g.useRef(!1),T=g.useRef(null),F=g.useRef(null),D=g.useRef(null),K=g.useRef(null),V=g.useRef([]),H=g.useRef(!1),P=g.useRef(0),I=g.useRef(null),U=g.useRef("primer"),Z=g.useRef(null),z=g.useRef(null),X=g.useRef(null),Y=g.useRef(!1),J=g.useState(md)[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=sR({started:R.current,state:i==null?void 0:i.state});Me&&zo(Me).catch(()=>{}),e()},[e,i==null?void 0:i.state]),xe=gt(Ee,{focusRef:D}),Ie=yt(Ee),De=g.useCallback(async()=>{if(!Cn(q.current))return;const Me=++P.current;q.current=!0,w(!0),N(null),je(null),R.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===P.current&&(qe=await zo({action:"login"}).catch(()=>null)),Me===P.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(!s6(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{}},uie(i==null?void 0:i.state));return()=>window.clearInterval(Me)},[i]);const We=g.useCallback(async()=>{const Me=sR({started:R.current,state:i==null?void 0:i.state});if(P.current+=1,R.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(nR({restored:qe==null?void 0:qe.restored,activeAccount:qe==null?void 0:qe.activeAccount}))},[i==null?void 0:i.state]),Ke=g.useCallback(()=>{R.current=!1,l(null),N(null),h(""),de(!1),De()},[De]),ye=g.useRef(t);ye.current=t;const Fe=g.useState(mie)[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=uS(Me,gf.findIndex(_t=>_t.id===a),gf.length);qe.kind!=="pass"&&(Me.preventDefault(),H.current=!0,o(gf[qe.index].id),(Je=V.current[qe.index])==null||Je.focus())},[a]),He=g.useCallback(async()=>{var Je;if(!Cn(q.current))return;const Me=P.current;q.current=!0,w(!0),N(null);const qe=await zo({action:"login-code",code:u}).catch(()=>null);if(Me===P.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(!Cn(q.current))return;q.current=!0,k(!0),C(null);const Me=await zo({action:"import",blob:f}).catch(()=>null);if(q.current=!1,k(!1),!(Me!=null&&Me.ok)){C(Cl(Me,"the import failed"));return}B.current=f,p(""),W(null),$(Me.results??[]),t()},[f,t]),ke=g.useCallback(async Me=>{const qe=dj(Me);if(!Cn(q.current)||!B.current)return;q.current=!0,k(!0),O(qe),W(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,k(!1),O(null),!(Je!=null&&Je.ok)){W({key:qe,text:Cl(Je,"that account could not be updated")});return}const _t=(Je.results??[])[0];_t&&$(Nt=>bie(Nt,qe,_t)),t()},[t]),Ae=(i==null?void 0:i.state)==="done"?i.account:null,Oe=nR({restored:i==null?void 0:i.restored,activeAccount:i==null?void 0:i.activeAccount}),be=Wae({login:i,started:R.current,loginError:v,loginBusy:m}),fe=Uae({state:i==null?void 0:i.state,serverError:i==null?void 0:i.error,localError:v}),_e=be==="asking"||be==="code"?Zoe({state:i==null?void 0:i.state,step:i==null?void 0:i.step,starting:be==="asking"})??"link":null,Ve=be==="ended"?Joe({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&&die({fromStages:U.current==="progress",reducedMotion:J})>0,wt=be==="primer"?"primer":be==="done"&&Ae&&!tt?"done":"progress",$t=Ve?"failed":tt?"resolving":"live",Gt=tie(tt?{done:!0}:Ve?{failed:Ve,state:i==null?void 0:i.state}:{live:_e}),nr=Ve?f6(Ve,i==null?void 0:i.state):"",_s=Ff(fe.message),Hn=_e==="approve"?lie({since:he,now:oe,expiresAt:i==null?void 0:i.expiresAt}):null,ns=b?cie({since:Le,now:oe}):null,Es=a==="login"?wt==="done"&&Ae?`${dR(Ae)}.`:$t==="failed"?`${nr}. ${_s}`:wt==="progress"&&!tt?fie(_e)??"":"":b?"Importing the share.":x?Ff(x):_?Ff(hR(_)):"";g.useEffect(()=>{_e&&(I.current=_e)},[_e]),g.useEffect(()=>{U.current=wt},[wt]),g.useEffect(()=>{if(!tt||!ot)return;const Me=window.setTimeout(()=>te(ot),p6);return()=>window.clearTimeout(Me)},[tt,ot]);const wn=_e==="approve";g.useEffect(()=>{pe(wn?Date.now():null)},[wn]),g.useEffect(()=>{ge(b?Date.now():null)},[b]);const zn=wn||b;return g.useEffect(()=>{if(!zn)return;re(Date.now());const Me=window.setInterval(()=>re(Date.now()),1e3);return()=>window.clearInterval(Me)},[zn]),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=D.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]),vt.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:gf.map((Me,qe)=>r.jsx("button",{type:"button",role:"tab",id:pR(Me.id),ref:Je=>{V.current[qe]=Je},"aria-selected":a===Me.id,"aria-controls":fR,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:fR,role:"tabpanel","aria-labelledby":pR(a),children:[a==="login"?wt==="done"&&Ae?r.jsxs("div",{className:`aa-done${Q===ot?" from-orbit":""}`,children:[r.jsx(Np,{ref:K}),hie({added:Ae.added,reducedMotion:J})&&r.jsx(cR,{anchor:K}),r.jsx("h4",{children:dR(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(Xoe,{rows:Gt,phase:$t,detail:$t==="failed"?r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"aa-note aa-reason",children:_s}),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:[jie(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"})})]})]}),Hn?r.jsx("p",{className:"aa-note aa-arrive",children:Hn}):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()&&!S&&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",...Bn(S,!u.trim()||i.state==="registering"),onClick:He,children:"Continue"})]}),(v||i.error)&&r.jsx("p",{className:"aa-err",children:v??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:nie(_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:D,className:"btn primary",...Bn(S),onClick:De,children:"Open the sign-in page"})})]}):_?(()=>{const Me=_.filter(Je=>Je.state==="imported").length,qe=_.some(Je=>kp(Je.check));return r.jsxs("div",{className:"aa-done",children:[!qe&&r.jsx(Np,{ref:K}),Me>0&&!qe&&r.jsx(cR,{anchor:K}),r.jsx("h4",{children:hR(_)}),_.length>0&&r.jsx("ul",{className:"aa-results",children:_.map(Je=>{const _t=dj(Je),Nt=kp(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:kie(Je.state)}),Je.state==="present"&&r.jsx("button",{type:"button",className:"aa-result-fix","aria-busy":A===_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:A===_t?"updating…":"update anyway"}),Nt&&r.jsx("span",{className:"aa-result-err",children:Nt.long}),(M==null?void 0:M.key)===_t&&r.jsx("span",{className:"aa-result-err",children:M.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="",W(null),$(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()&&!S&&se()},placeholder:"ccdeck2:…",spellCheck:!1,autoComplete:"off","aria-label":"Shared account"}),r.jsx("button",{type:"button",className:"btn primary",...Bn(S,!f.trim()),onClick:se,children:b?"importing…":"Import"})]}),x&&r.jsx("p",{className:"aa-err",children:x}),b?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:ns??"claude-swap is adding the accounts in this share. Any already here are left as they are."})]}):null,r.jsxs("p",{className:"aa-note",children:["Use ",r.jsx("strong",{children:"share"})," on one account in the other deck, or ",r.jsx("strong",{children:"↗"})," above its list to send several at once. A share carries a live login for every account in it and expires ten minutes after it is made."]})]}),r.jsx("p",{className:"vis-hidden",role:"status","aria-live":"polite",children:Es})]})]})}),document.body)}function Nie(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 Sie(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 Cie=64;function _ie(e,t){const n=e.trim();return{alias:n,commit:n!==(t??"").trim()}}function Eie(e,t,n){return t!=null&&e.some(s=>s.slot===t)?t:n}function Tie(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 Aie(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 Rie(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 Mie({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:b,share:k,shareCopied:v,slotDraft:N,dropMenu:x,closeMenu:C,startRename:S,typeAlias:_,doAlias:$,startMove:A,pickSlot:O,doSlot:M,makeShare:W,copyShare:B,pressRemove:R}=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(vd,{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:()=>S(e.num,e.alias),children:"Rename"}),r.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",onClick:()=>A(e.num),children:"Move to slot…"}),r.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",...i(`share-${e.num}`),title:`Copy this account to another ${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:()=>W(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${b===e.num?" armed":""}`,...i(`rm-${e.num}`),"aria-label":b===e.num?"Confirm remove":void 0,title:b===e.num?"This deletes the stored credentials for this account":"Remove this account from claude-swap",onClick:()=>R(e.num),children:o===`rm-${e.num}`?"Removing…":b===e.num?"Confirm":"Remove"}),T]}),p.view==="rename"&&r.jsxs("form",{className:"ap-pop-form",onSubmit:F=>{F.preventDefault(),$(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:Cie,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:()=>C(),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=Nie(t,e.num),D=Eie(F,N,e.num),K=Tie(F,D,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(D),...i(`move-${e.num}`),onChange:V=>O(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:()=>C(),children:"Cancel"}),r.jsx("button",{type:"button",className:"btn primary",...i(`move-${e.num}`),title:K.title,onClick:()=>M(e.num,D,K),children:o===`move-${e.num}`?"…":ku(K.label)})]})]})})(),p.view==="share"&&(k==null?void 0:k.num)===e.num&&(()=>{const F=m6(k.expiresAt,n),D=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:k.blob}),r.jsxs("p",{className:"ap-pop-note",title:"This text is the account's password. It is base64 of plain JSON — the expiry inside it is not signed, so anyone holding a copy can change it, and the login itself is in there in the clear either way. The countdown only says how long another deck's import dialog will still accept it. If a copy escapes, sign the account out and back in.",children:[r.jsx("span",{className:"ap-share-warn",children:"This is the password"})," · ",r.jsx("span",{className:`ap-share-expiry ${F.tone}`,children:F.text})]}),T,r.jsxs("div",{className:"ap-pop-actions",children:[r.jsx("button",{type:"button",className:"btn",onClick:()=>C(),children:"Done"}),r.jsx("button",{type:"button",className:"btn primary",...i(`share-${e.num}`),autoFocus:!0,onClick:async()=>{if(D){await W(e.num);return}await B(k.blob)},children:D?"Make a new share":v?"Copied":"Copy"})]})]})})()]})}const $ie=6;function Lie(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?Iie(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 Iie(e){const t=e.map(n=>n.headroom).filter(n=>typeof n=="number");return t.length?Math.round(Math.max(...t)):null}function Oie(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,$ie),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 y6=160,w6=140;function Pie(){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),w6)},holdPeek:()=>window.clearTimeout(n.current),dropPeek:()=>{window.clearTimeout(n.current),t(!1)}}}function Die(e){var t;return((t=e==null?void 0:e.detail)==null?void 0:t.fix)==="give_back"}function Vs(e,t){return{text:e,giveBack:Die(t),done:!1}}async function Fie(){try{return await(await fetch("/api/prefs/give-back",{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"})).json().catch(()=>null)}catch{return null}}const Bie={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 qie(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?Bie[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 hj=5e3,x6=6e4;function Zt(e,t){if(t==null)return`Could not ${e} — the deck did not answer.`;const n=t.reason?Hie(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 Uie={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."},Wie=new Set(["EACCES","EPERM"]);function Hie(e,t){const n=Uie[e];if(!n)return;const s=e==="prefs_unreadable"&&t?zie(t):void 0,a=t!=null&&t.code&&t.code!=="BADJSON"?` Error code: ${t.code}.`:"";return(s??n)+a}function zie({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&&!Wie.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 Vie(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=>im(f.current)?(f.current=B,l(B),!0):!1,[]),m=g.useCallback(()=>{f.current=null,v.current&&l(null)},[]),w=B=>{const R=so(i,B);return{disabled:R.disabled,"aria-busy":R.busy}},[b,k]=g.useState(()=>Date.now()),v=g.useRef(!0),N=g.useRef(hj),x=g.useCallback(async()=>{var B,R;try{const[q,T]=await Promise.all([fetch("/api/lan").then(F=>F.json()),fetch("/api/prefs").then(F=>F.json())]);if(!v.current)return;q!=null&&q.ok&&s(q),T!=null&&T.ok&&o(Array.isArray((R=(B=T.prefs)==null?void 0:B.lan)==null?void 0:R.manual)?T.prefs.lan.manual:[]),N.current=(q==null?void 0:q.enabled)===!0?hj:x6}catch{}},[]);g.useEffect(()=>{v.current=!0;let B=0;const R=async()=>{k(Date.now()),await x(),v.current&&(B=window.setTimeout(R,N.current))};return R(),()=>{v.current=!1,window.clearTimeout(B)}},[x]);const C=g.useCallback(async()=>{const B=(n==null?void 0:n.enabled)===!0;if(p("switch"))try{const R=await gl("/api/prefs",{lan:{enabled:!B}});if(!v.current)return;R!=null&&R.ok?(h(null),B||t()):h(Vs(Zt(B?"turn this off":"turn this on",R),R)),await x()}catch{v.current&&h(Vs(Zt(B?"turn this off":"turn this on",null)))}finally{m()}},[n==null?void 0:n.enabled,x,p,m,t]),S=g.useCallback(async(B,R,q)=>{if(!p(`${B}:${R}`))return null;let T=null;try{const F=await gl("/api/lan/peer",{action:B,fp:R});if(!v.current)return null;F!=null&&F.ok?(s(F),h(null)):(T=Zt(q,F),h(Vs(T,F))),await x()}catch{T=Zt(q,null),v.current&&h(Vs(T))}finally{m()}return T},[x,p,m]),_=g.useCallback(async B=>{if(!p(`drop:${B}`))return null;let R=null;try{const q=await gl("/api/prefs",{lan:{manual:a.filter(T=>T!==B)}});if(!v.current)return null;q!=null&&q.ok?(h(null),e()):(R=Zt("stop dialling that address",q),h(Vs(R,q))),await x()}catch{R=Zt("stop dialling that address",null),v.current&&h(Vs(R))}finally{m()}return R},[a,x,e,p,m]),$=g.useCallback(async(B,R)=>{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:R});return v.current?q!=null&&q.ok?(s(q),null):Zt("rename that deck",q):null}catch{return Zt("rename that deck",null)}finally{m()}},[p,m]),A=g.useCallback(async B=>{if(!p(`check:${B}`))return null;try{const R=await gl("/api/lan/sync",{fp:B});return v.current?R!=null&&R.ok?(s(R),e(),null):(R==null?void 0:R.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.":Zt("check that deck",R):null}catch{return Zt("check that deck",null)}finally{m()}},[p,m,e]),O=g.useCallback(async()=>{if(p("check"))try{const B=await gl("/api/lan/sync",{});if(!v.current)return;B!=null&&B.ok?(s(B),h(null)):h(Vs(Zt("check the other decks",B),B)),e()}catch{v.current&&h(Vs(Zt("check the other decks",null)))}finally{m()}},[p,m,e]);return{status:n,manual:a,now:b,busy:i,failure:u,dismissFailure:()=>h(null),answerGiveBack:B=>{h(B),B.done&&(x(),e())},pressProps:w,load:x,toggle:C,answer:S,dropAddress:_,rename:$,checkOne:A,checkNow:O}}function Gie(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 v6({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=k=>h(Math.max(0,Math.min(t.length-1,k)));g.useEffect(()=>{var k,v;Wn(((k=document.activeElement)==null?void 0:k.tagName)??null)&&((v=o.current)==null||v.focus())},[u]);const w=k=>{k.key!=="ArrowRight"&&k.key!=="ArrowLeft"||(k.preventDefault(),k.stopPropagation(),m(k.key==="ArrowRight"?u+1:u-1))},b=()=>{if(!f){m(u+1);return}n?n.act():a()};return vt.createPortal(r.jsx("div",{className:"modal-backdrop",...l,role:"presentation",children:r.jsxs("div",{ref:i,className:"modal guide",onClick:k=>k.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((k,v)=>r.jsx("button",{type:"button",className:"glyph-btn guide-dot","aria-label":`Step ${v+1} of ${t.length}`,"aria-current":v===u?"step":void 0,onClick:()=>m(v)},v))}),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:b,children:f?(n==null?void 0:n.label)??"Done":"Next"})]})]})]})}),document.body)}const fj={ok:"ga-ok",warn:"ga-warn",accent:"ga-accent",flight:"ga-flight"};function Ns({children:e}){return r.jsx("svg",{className:"guide-art",viewBox:"0 0 440 200","aria-hidden":!0,focusable:"false",children:e})}function js({x:e,y:t=34,w:n=176,h:s=132,label:a}){return r.jsxs(r.Fragment,{children:[a&&r.jsx("text",{x:e+2,y:t-9,className:"ga-cap",children:a}),r.jsx("rect",{x:e,y:t,width:n,height:s,rx:10,className:"ga-screen"})]})}function Js({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:fj[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 ${fj[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 b6({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 yf({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 mR({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 gR({x:e,y:t,d:n}){return r.jsx("path",{d:n,transform:`translate(${e} ${t})`,className:"ga-glyph"})}function dS({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 hS(){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:fj[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 Sp({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(b6,{x:e+118,y:t-13,on:!0})]})}function Kie(){return r.jsxs(Ns,{children:[r.jsx("rect",{x:14,y:14,width:206,height:172,rx:10,className:"ga-screen"}),r.jsx("text",{x:28,y:38,className:"ga-t ga-strong",children:"Sessions"}),r.jsx("text",{x:206,y:38,className:"ga-s ga-warn",textAnchor:"end",children:"1 waiting"}),r.jsx("rect",{x:20,y:50,width:194,height:42,rx:6,className:"ga-bed-warn"}),r.jsx("circle",{cx:33,cy:64,r:7,className:"ga-ring-warn ga-ping"}),r.jsx("circle",{cx:33,cy:64,r:3.5,className:"ga-warn"}),r.jsx("text",{x:44,y:68,className:"ga-t",children:"api-server"}),r.jsx("text",{x:44,y:83,className:"ga-s ga-warn",children:"waiting 6m · Bash"}),r.jsx("circle",{cx:33,cy:108,r:3.5,className:"ga-flight"}),r.jsx("text",{x:44,y:112,className:"ga-t",children:"docs-site"}),r.jsx("text",{x:44,y:127,className:"ga-s",children:"running · 12 tools"}),r.jsx("circle",{cx:33,cy:150,r:3.5,className:"ga-ok"}),r.jsx("text",{x:44,y:154,className:"ga-t",children:"billing"}),r.jsx("text",{x:44,y:169,className:"ga-s",children:"done · $0.84"}),r.jsx("path",{d:"M216 71C234 71 230 100 244 100",className:"ga-arc"}),r.jsx("path",{d:"M239 96l5 4-5 4",className:"ga-arrow"}),r.jsx("rect",{x:248,y:44,width:178,height:112,rx:10,className:"ga-screen"}),r.jsx("text",{x:262,y:64,className:"ga-cap",children:"API-SERVER"}),r.jsx("line",{x1:248,y1:74,x2:426,y2:74,className:"ga-line"}),r.jsx("text",{x:262,y:96,className:"ga-s ga-mono",children:"Bash(npm test)"}),r.jsx("text",{x:262,y:116,className:"ga-t ga-mono ga-warn",children:"Allow this command?"}),r.jsx("text",{x:262,y:136,className:"ga-s ga-mono",children:"> 1. Yes 2. No"})]})}function Yie(){return r.jsxs(Ns,{children:[r.jsx("path",{d:"M136 100C166 100 166 38 196 38",className:"ga-edge ga-flow"}),r.jsx("path",{d:"M136 100H196",className:"ga-edge ga-flow"}),r.jsx("path",{d:"M136 100C166 100 166 162 196 162",className:"ga-edge-done"}),r.jsx("path",{d:"M308 38H326M308 100H326",className:"ga-edge"}),r.jsx(_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 yR({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 Xie(){return r.jsxs(Ns,{children:[r.jsx("rect",{x:14,y:30,width:172,height:140,rx:10,className:"ga-screen"}),r.jsx("text",{x:30,y:56,className:"ga-cap",children:"THIS SESSION"}),r.jsx("text",{x:30,y:98,className:"ga-big",children:"$3.66"}),r.jsx("text",{x:30,y:122,className:"ga-s",children:"Opus 5 · 1.2M tokens"}),r.jsx("text",{x:30,y:150,className:"ga-s",children:"$21.40 today"}),r.jsx("rect",{x:200,y:30,width:226,height:140,rx:10,className:"ga-screen"}),r.jsx("text",{x:216,y:56,className:"ga-cap",children:"CLAUDE QUOTA"}),r.jsx(yR,{x:216,y:80,label:"5-hour window",pct:24,note:"resets in 53m"}),r.jsx(yR,{x:216,y:124,label:"7-day window",pct:61,note:"resets in 4d"})]})}function Zie(){return r.jsxs(Ns,{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(dS,{x:156,y:106}),r.jsx("path",{d:"M170 92C186 92 184 60 200 60",className:"ga-arc"}),r.jsx("path",{d:"M195 56l5 4-5 4",className:"ga-arrow"}),r.jsx(js,{x:200,y:22,w:226,h:160}),r.jsx("text",{x:214,y:46,className:"ga-t ga-strong",children:"tests"}),r.jsx("text",{x:412,y:46,className:"ga-s",textAnchor:"end",children:"Sonnet 5 · 38s"}),r.jsx("line",{x1:200,y1:56,x2:426,y2:56,className:"ga-line"}),r.jsx("text",{x:214,y:76,className:"ga-cap",children:"PROMPT"}),r.jsx("text",{x:214,y:92,className:"ga-t",children:"Run the suite and fix what fails"}),r.jsx("text",{x:214,y:116,className:"ga-cap",children:"TOOLS · 6"}),r.jsx(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 Jie(){const e=[18,24,28,14,22,26,30,16,24,28,20,26];return r.jsxs(Ns,{children:[r.jsx(js,{x:14,y:20,w:412,h:160}),r.jsx("text",{x:28,y:44,className:"ga-t ga-strong",children:"This machine"}),r.jsx("text",{x:412,y:44,className:"ga-s",textAnchor:"end",children:"12 cores · up 10d"}),r.jsx("line",{x1:14,y1:56,x2:426,y2:56,className:"ga-line"}),r.jsx("text",{x:28,y:76,className:"ga-cap",children:"CORES"}),e.map((t,n)=>r.jsxs("g",{children:[r.jsx("rect",{x:28+n*15,y:82,width:10,height:30,rx:2,className:"ga-track"}),r.jsx("rect",{x:28+n*15,y:112-t,width:10,height:t,rx:2,className:"ga-accent"})]},n)),r.jsx("text",{x:28,y:136,className:"ga-cap",children:"MEMORY"}),r.jsx("rect",{x:28,y:143,width:178,height:5,rx:2.5,className:"ga-track"}),r.jsx("rect",{x:28,y:143,width:105,height:5,rx:2.5,className:"ga-accent"}),r.jsx("text",{x:28,y:165,className:"ga-s",children:"18.9 GB of 32.0 GB"}),r.jsx("text",{x:240,y:76,className:"ga-cap",children:"THERMAL"}),r.jsx("text",{x:240,y:100,className:"ga-big",children:"66 °C"}),r.jsx("text",{x:240,y:118,className:"ga-s ga-ok",children:"running at full speed"}),r.jsx("text",{x:240,y:142,className:"ga-cap",children:"BUSIEST PROCESSES"}),r.jsx("text",{x:240,y:160,className:"ga-s ga-mono",children:"node · claude"}),r.jsx("text",{x:412,y:160,className:"ga-s ga-mono",textAnchor:"end",children:"38%"}),r.jsx("text",{x:240,y:176,className:"ga-s ga-mono",children:"esbuild"}),r.jsx("text",{x:412,y:176,className:"ga-s ga-mono",textAnchor:"end",children:"21%"})]})}function Qie(){return r.jsxs(Ns,{children:[r.jsx("rect",{x:14,y:40,width:188,height:120,rx:10,className:"ga-screen"}),r.jsx("text",{x:28,y:60,className:"ga-cap",children:"~/MY-PROJECT"}),r.jsx("line",{x1:14,y1:70,x2:202,y2:70,className:"ga-line"}),r.jsxs("text",{x:28,y:100,className:"ga-t ga-mono",children:[r.jsx("tspan",{className:"ga-accent",children:"$"})," claude"]}),r.jsx("rect",{x:86,y:90,width:7,height:13,className:"ga-caret ga-blink"}),r.jsx("text",{x:28,y:130,className:"ga-s ga-mono",children:"or: codex"}),r.jsx("path",{d:"M210 100H238",className:"ga-arc"}),r.jsx("path",{d:"M233 95l6 5-6 5",className:"ga-arrow"}),r.jsx("rect",{x:250,y:40,width:176,height:120,rx:10,className:"ga-canvas"}),r.jsx("g",{className:"ga-pop",children:r.jsx(_l,{x:278,y:80,w:120,title:"my-project",sub:"Opus 5 · live",tone:"accent"})})]})}function ele(){return r.jsxs(Ns,{children:[r.jsx(js,{x:14,y:16,w:232,h:170}),r.jsx("text",{x:28,y:40,className:"ga-t ga-strong",children:"Claude accounts"}),r.jsx(gR,{x:196,y:33,d:"M7 2.2v9.6M2.2 7h9.6"}),r.jsx(gR,{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(Js,{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(Js,{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(dS,{x:221,y:161}),r.jsx("path",{d:"M250 40C270 40 262 78 282 78",className:"ga-arc"}),r.jsx("path",{d:"M277 74l5 4-5 4",className:"ga-arrow"}),r.jsx(js,{x:282,y:62,w:144,h:64,label:"ANOTHER MACHINE"}),r.jsx("g",{className:"ga-pop",children:r.jsx(Js,{x:296,y:92,email:"work@team.dev",state:"shared here",tone:"ok"})})]})}function tle(){return r.jsxs(Ns,{children:[r.jsx(js,{x:14,label:"THIS MACHINE"}),r.jsx(Sp,{x:28,y:60}),r.jsx("g",{className:"ga-swap-out",children:r.jsx(Js,{x:28,y:98,email:"work@team.dev",state:"login expired",tone:"warn"})}),r.jsx("g",{className:"ga-swap-in",children:r.jsx(Js,{x:28,y:98,email:"work@team.dev",state:"working again",tone:"ok",bars:[24,61]})}),r.jsx(js,{x:250,label:"ANOTHER MACHINE"}),r.jsx(Sp,{x:264,y:60}),r.jsx(Js,{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(hS,{})})]})}const nle=[{art:r.jsx(Kie,{}),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(Yie,{}),line:"Every agent and subagent is a node. Tool calls light up as they run."},{art:r.jsx(Zie,{}),line:"Double-click any node: its prompt, every tool call, tokens and timing."},{art:r.jsx(Xie,{}),line:"What each session costs, and how much quota is left."},{art:r.jsx(Jie,{}),line:"Cores, memory and heat while the agents run, and what is hogging them."},{art:r.jsx(ele,{}),line:"Several Claude accounts: switch, add one, share one to another machine."},{art:r.jsx(tle,{}),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(Qie,{}),line:"Run claude or codex in any folder. It shows up here on its own."}];function sle(){return r.jsxs(Ns,{children:[r.jsx(js,{x:14,label:"THIS MACHINE"}),r.jsx(Js,{x:28,y:64,email:"work@team.dev",state:"login expired",tone:"warn"}),r.jsx("rect",{x:40,y:94,width:86,height:20,rx:10,className:"ga-pill-warn"}),r.jsx("text",{x:83,y:108,className:"ga-s ga-warn",textAnchor:"middle",children:"sign in again"}),r.jsx("line",{x1:198,y1:100,x2:242,y2:100,className:"ga-off"}),r.jsx(js,{x:250,label:"ANOTHER MACHINE"}),r.jsx(Js,{x:264,y:64,email:"work@team.dev",state:"working",tone:"ok",bars:[24,61]})]})}function rle(){return r.jsxs(Ns,{children:[r.jsx(js,{x:14,label:"THIS MACHINE"}),r.jsx(Sp,{x:28,y:60}),r.jsx(yf,{x:28,y:92,name:"Ana's MacBook"}),r.jsx(yf,{x:28,y:114,name:"Dorin's PC"}),r.jsx(js,{x:250,label:"ANOTHER MACHINE"}),r.jsx(Sp,{x:264,y:60}),r.jsx(yf,{x:264,y:92,name:"Your MacBook"}),r.jsx(yf,{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 ale(){return r.jsxs(Ns,{children:[r.jsx("rect",{x:90,y:18,width:260,height:164,rx:10,className:"ga-screen"}),r.jsx("text",{x:106,y:42,className:"ga-t ga-strong",children:"This deck on the network"}),r.jsx("line",{x1:90,y1:54,x2:350,y2:54,className:"ga-line"}),r.jsx("text",{x:106,y:76,className:"ga-cap",children:"SHARE THESE ACCOUNTS"}),r.jsx(mR,{x:106,y:88,on:!0}),r.jsx("text",{x:126,y:98,className:"ga-t ga-mono",children:"work@team.dev"}),r.jsx(mR,{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(b6,{x:304,y:157,on:!0}),r.jsx(dS,{x:115,y:97})]})}function ole(){return r.jsxs(Ns,{children:[r.jsx(js,{x:14,label:"THIS MACHINE"}),r.jsx("g",{className:"ga-swap-out",children:r.jsx(Js,{x:28,y:64,email:"work@team.dev",state:"login expired",tone:"warn"})}),r.jsx("g",{className:"ga-swap-in",children:r.jsx(Js,{x:28,y:64,email:"work@team.dev",state:"working again",tone:"ok",bars:[24,61]})}),r.jsx(js,{x:250,label:"ANOTHER MACHINE"}),r.jsx(Js,{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(hS,{})})]})}const ile=[{art:r.jsx(sle,{}),line:"A login can expire on one machine while it still works on another."},{art:r.jsx(rle,{}),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(ale,{}),line:"Tick which logins this machine may hand out. Nothing is shared until you do."},{art:r.jsx(ole,{}),line:"An expired login is copied from a paired machine within a minute."}];function lle(){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(hS,{})})]})}const cle={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."},ule=1600;function k6({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)},ule))},[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:cle[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 dle(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 hle(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 yw(e,t){return(await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).json().catch(()=>null)}const fle={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."},ple={not_running:"This deck is not on the network yet. Turn Local network on, then make one."};function wR(e,t,n){return(t==null?void 0:t.reason)&&e[t.reason]||Zt(n,t)}function mle({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(""),[b,k]=g.useState(""),[v,N]=g.useState(null),[x,C]=g.useState(null),[S,_]=g.useState(null),[$,A]=g.useState(null),[O,M]=g.useState(()=>Date.now());g.useEffect(()=>{const Y=window.setInterval(()=>M(Date.now()),1e3);return()=>window.clearInterval(Y)},[]);const W=g.useRef(!0);g.useEffect(()=>()=>{W.current=!1},[]);const B=g.useRef(null),R=g.useRef(null),q=g.useCallback(Y=>im(B.current)?(B.current=Y,_(Y),!0):!1,[]),T=g.useCallback(()=>{B.current=null,W.current&&_(null)},[]),F=Y=>{const J=so(S,Y);return{disabled:J.disabled,"aria-busy":J.busy}},D=Y=>(v==null?void 0:v.field)===Y?{"aria-invalid":!0,"aria-describedby":"lan-add-failure"}:{},K=Y=>N(J=>J&&J.field===Y?null:J),V=g.useCallback(async()=>{if(h)return;const Y=dle(m);if(!Y){N({text:gle(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 yw("/api/prefs",{lan:{manual:[...t,J]}});if(!W.current)return;te!=null&&te.ok?(N(null),w(""),a(),s()):N({text:Zt("add that address",te),field:"addr"})}catch{W.current&&N({text:Zt("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 yw("/api/lan/invite",{action:Y});if(!W.current)return;Q!=null&&Q.ok?(R.current=Y,N(null),C(null),a()):N({text:wR(ple,Q,J)})}catch{W.current&&N({text:Zt(J,null)})}finally{T()}},[a,q,T]),P=g.useCallback(async()=>{const Y=b.trim();if(!(!Y||!q("join"))){A(null);try{const J=await yw("/api/lan/invite",{action:"join",token:Y});if(!W.current)return;J!=null&&J.ok?(k(""),N(null),a(),s()):(J==null?void 0:J.reason)==="unreachable"&&Array.isArray(J.tried)&&J.tried.length?(A(J.tried),N(null)):(A(null),N({text:wR(fle,J,"use that invite"),field:"join"}))}catch{W.current&&N({text:Zt("use that invite",null),field:"join"})}finally{T()}}},[b,a,s,q,T]),I=g.useCallback(async(Y,J)=>{try{await navigator.clipboard.writeText(Y),C(J),window.setTimeout(()=>{W.current&&C(Q=>Q===J?null:Q)},1600)}catch{N({text:"Could not copy it — select the text and copy it by hand."})}},[]),U=e.invite&&e.invite.expiresAt>O?e.invite:null,Z=g.useRef(!1);g.useEffect(()=>{n!=="invite"||Z.current||U||(Z.current=!0,H("make"))},[n,U,H]);const z=g.useRef(!1);g.useEffect(()=>{var Y;n!=="invite"||z.current||!U||(z.current=!0,(Y=l.current)==null||Y.focus())},[n,U]),g.useEffect(()=>{var J,Q;const Y=R.current;!Y||Y==="make"!=!!U||(R.current=null,Wn(((J=document.activeElement)==null?void 0:J.tagName)??null)&&((Q=(Y==="make"?l:u).current)==null||Q.focus()))},[U]);const X=e.port!=null?(e.addrs??[]).map(Y=>`${Y}:${e.port}`):[];return vt.createPortal(r.jsx("div",{className:"modal-backdrop",...p,role:"presentation",children:r.jsxs("div",{ref:f,className:"modal lan-add",onClick: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:[v&&r.jsxs("div",{className:"ap-failure",role:"alert",children:[r.jsx("span",{id:"lan-add-failure",className:"ap-failure-text",children:v.text}),r.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>N(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),r.jsx(k6,{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,...D("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",!U&&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:S==="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:b,placeholder:"paste one you were sent",spellCheck:!1,...D("join"),onChange:Y=>{k(Y.target.value),A(null),K("join")},onKeyDown:Y=>{Y.key==="Enter"&&P()}}),b.trim()!==""&&r.jsx("button",{type:"button",className:"ap-manage-btn",...F("join"),onClick:()=>void P(),title:"Reach that deck and pair with it. Nobody has to press anything there.",children:S==="join"?"joining…":"join"})]}),r.jsx("p",{className:"lan-note",children:"Pasting one pairs both decks on the spot — nobody has to accept."}),$&&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."}),$.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))]}),U&&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:[hle(U.expiresAt,O)," left"]})]}),r.jsx("code",{className:"ap-lan-token",children:U.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(U.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 gle(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 yle({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 wle({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 xle(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 vle({on:e,status:t}){return r.jsxs(r.Fragment,{children:[e&&r.jsx(k6,{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:xle(t)})]})}const xR=["online","offline","loose"],ble={online:0,offline:1,loose:2};function kle(e){return e.kind==="declined"?null:e.kind==="paired"?e.here?"online":"offline":"loose"}const jle=76,Nle=62,Cp=96,Sle={1:[.62],2:[.58,1],3:[.42,.72,1]},Cle=.2,_le=.16,Ele=.05,Tle=20,Ale=17,wf=7,Rle=30,Mle=116,$le=6.6,Lle=6,Ile=e=>fS(e,null),Ole=1.5,Ple=80,Dle=.45,vR=40,Fle=64,Ble=150,bR=.3,kR=84,jR=8,qle=1.3,_p=6,Ule=5.94,NR=7,SR=16,hu=4,CR=.16;function pj(e,t){return Math.PI*(3*(e+t)-Math.sqrt((3*e+t)*(e+3*t)))}function j6(e,t){return t<-Math.abs(e)*.6?"top":"bottom"}function Wle(e,t){if(e<=2)return t%2===0?0:90;const n=360/e;return-90+(t%2===0?0:n/2)}function Hle(e){return e.map((t,n)=>({...t,i:n})).sort((t,n)=>xR.indexOf(t.tier)-xR.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 _R(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 zle(e,t,n){const s=[...Sle[e.length]??[]];for(let a=0;a<s.length;a++){const o=e[a];if(o<2)continue;const i=pj(t*s[a],n*s[a])/o;if(!(i>0)||i>=Cp)continue;const l=a+1<s.length?s[a+1]-Cle:1;s[a]=Math.max(s[a],Math.min(l,s[a]*(Cp/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,ww={h:16,ch:6.1,maxW:100};function Vle(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 N6(e,t,n,s,a,o){const i=t==="loose"?Ale:Tle,l=!a||e.kind==="asks",u=l?Rle:ww.h,h=a?ww.ch:$le,f=l?o.length:0,p=Math.min(a?ww.maxW:Mle,Math.max(2*i,C6(e).length*h,f*Lle)),m={x0:n-i,y0:s-i,x1:n+i,y1:s+i},w=j6(n,s)==="top"?{x0:n-p/2,y0:s-i-wf-u,x1:n+p/2,y1:s-i-wf}:{x0:n-p/2,y0:s+i+wf,x1:n+p/2,y1:s+i+wf+u};return[m,w]}const mj=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]},xf=(e,t)=>((e-t)%360+540)%360-180;function ER(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]=mj(f);return N6(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*Ole,b=s.get(f.ring),k=(f.count>2?360/f.count:f.turn)*Dle,v=b[(f.index+1)%f.count],N=b[(f.index-1+f.count)%f.count];return!(v===f||(p>0?xf(v.theta,w)>=k:xf(w,N.theta)>=k))||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<Ple;f++){const p=a();let m=!1;for(let w=0;w<e.length;w++){l(p[w])&&(m=o(e[w],xf(e[w].theta,90)>=0?1:-1,!0)||m);for(let b=w+1;b<e.length;b++){if(!i(p[w],p[b]))continue;const k=e[w],v=e[b],N=v.ring.ring>k.ring.ring||v.ring===k.ring&&b>w?v:k,x=N===v?k:v,C=xf(N.theta,x.theta)>=0?1:-1;m=o(N,C)||o(x,-C)||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 Gle={online:0,offline:1,loose:1};function Kle(e,t,n,s="",a=Ile){const o=[];for(const i of[!0,!1]){const l=TR(e,t,n,s,ble,a,i);if(l.clashes===0)return l.named();if(o.push(l),l.layout.rings.length===3){const u=TR(e,t,n,s,Gle,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 TR(e,t,n,s,a,o,i=!0){const l=new Map;for(const q of e){const T=kle(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-jle),f=Math.max(0,n/2-Nle),p=zle(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),b=q=>q.row.via==="tailscale",k=[...l.values()].flat().filter(b).length,v=Math.max(0,...m.map(q=>{const T=l.get(q.ring).filter(b).length,F=pj(q.rx,q.ry);return T>0&&F>0?T*Cp*qle/F*360:0})),N=i&&k>0&&k<w?Math.min(Ble,Math.max(Fle,k/w*360,v)):0,x=vR-N/2,C=vR+N/2,S=[];let _=!1;m.forEach((q,T)=>{const F=Hle(l.get(q.ring)),D=F.length,K=D>1&&pj(q.rx,q.ry)/D<Cp;K&&(_=!0);const V=T===m.length-1,H=V?-CR*(p[T]-(p[T-1]??0)):CR*(p[T+1]-p[T]),P=N>0?[{members:F.filter(U=>U.row.via!=="tailscale"),from:C,width:360-N},{members:F.filter(U=>U.row.via==="tailscale"),from:x+360,width:N}]:[{members:F,from:null,width:360}];let I=0;for(const U of P){const Z=U.members.length;if(Z===0)continue;const z=U.width/Z,X=Z>2;U.members.forEach(({row:Y,tier:J},Q)=>{const te=zs(Y),le=U.from==null?Wle(Z,T)+z*Q:U.from+z*(Q+.5),de=X?_R(te,1)*_le*z:0,oe=K&&I%2===1?1+H/p[T]:1,re=X?_R(te,2)*Ele:0,he=z*.3;S.push({row:Y,tier:J,ring:q,index:I,count:D,theta:le+de,reach:oe*(1+(V?-Math.abs(re):re)),lo:U.from==null?-1/0:U.from+he,hi:U.from==null?1/0:U.from+U.width-he,turn:z,caption:o(Y)}),I++})}});const $=Vle(s);let A=ER(S,_,$);A>0&&!_&&(_=!0,A=ER(S,!0,$));const O=S.map((q,T)=>{const[F,D]=mj(q);return{row:q.row,tier:q.tier,ring:q.ring.ring,x:F,y:D,angle:Yle(Math.atan2(D,F)*180/Math.PI),dist:Math.hypot(F,D),side:j6(F,D),order:T}}),M=m.reduce((q,T,F)=>l.get(T.ring).some(b)?Math.max(q,p[F]):q,0),W=q=>({from:x,to:C,inner:{rx:h*bR,ry:f*bR},outer:{rx:Math.min(t/2-8,h*M+q),ry:Math.min(n/2-8,f*M+q)},count:k}),B={nodes:O,rings:m,dense:_,zone:N>0?{...W(kR),labelAt:null}:null};return{layout:B,clashes:A,named:()=>{if(!B.zone)return B;const q=S.flatMap(D=>{const[K,V]=mj(D);return N6(D.row,D.tier,K,V,_,D.caption)});let T={...B.zone,labelAt:AR(B.zone,q)},F=T.outer;for(let D=kR+jR;T.labelAt==null;D+=jR){const K=W(D);if(K.outer.rx===F.rx&&K.outer.ry===F.ry)break;F=K.outer;const V=AR(K,q);V!=null&&(T={...K,labelAt:V})}return{...B,zone:T}}}}function S6(e){return`Tailscale · ${e} deck${e===1?"":"s"}`}function AR(e,t){const n={rx:e.outer.rx-_p,ry:e.outer.ry-_p};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 C=x*Math.PI/180;a.push([Math.cos(C)*n.rx,Math.sin(C)*n.ry])}const o=NR+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,C)=>l.some(S=>x>S.x0&&x<S.x1&&C>S.y0&&C<S.y1),h=[],f=[];let p=0;a.forEach(([x,C],S)=>{S>0&&(p+=Math.hypot(x-a[S-1][0],C-a[S-1][1]));const _=Math.hypot(x,C)||1;let $=!1;for(let A=0;A<=NR&&!$;A+=1.75)$=u(x-x/_*A,C-C/_*A);h.push(p),f.push((f.at(-1)??0)+($?1:0))});const m=S6(e.count).length*Ule/2,w=m+SR,b=p-m-SR;if(!(p>0)||b<w)return null;const k=x=>{let C=0,S=h.length;for(;C<S;){const _=C+S>>1;h[_]<x?C=_+1:S=_}return C},v=x=>{const C=k(x-m),S=k(x+m+1e-9)-1;return S<C||f[S]-(C>0?f[C-1]:0)===0},N=p/2;for(let x=0;N-x>=w;x+=2)for(const C of x===0?[N]:[N-x,N+x])if(v(C))return C/p;return null}function Yle(e){return(e%360+360)%360}function Xle(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 Zle(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 fS(e,t){switch(e.kind){case"asks":return"wants to pair";case"nearby":return e.state;case"dialling":return _6(e)?`${e.name.slice(e.addr.length)} · dialling`:"dialling";case"declined":return"declined";case"paired":{if(e.here)return t?Jle(t):"online";const n=T6(e);return n?n==="now"?"away · just now":`away · ${n}`:e.state.startsWith("one-way")?"has not called yet":"away"}}}function C6(e){return _6(e)?e.addr:e.name}function _6(e){return e.kind==="dialling"&&!!e.addr&&e.name.startsWith(`${e.addr}:`)}function E6(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=T6(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 T6(e){var t;return((t=/last online (.+)$/.exec(e.state))==null?void 0:t[1])??null}function Jle(e){return e.trim().split(/\s+/).slice(0,2).join(" ")}function Qle(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 zs(e){let t=e.fp;for(const n of e.twins??[])n.fp<t&&(t=n.fp);return t}function ece(e,t){if(e==null)return t;const n=((t-e)%360+540)%360-180;return e+n}function tce(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} ${A6}`:e.nearby===1?`${n} Open it to ask to pair.`:`${n} Open one to ask to pair.`}return null}const A6="This deck pairs by invite only. Send one from Add a deck.";function nce(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"?A6:"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 sce(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 rce(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 ace(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 oce(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 ice(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=oce(h,f),w=f?f.alive?f.shareable===!1?f.inUse?"inUse":"unavailable":"works":"expired":"missing",b=!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:b,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 lce=1e3;function cce(e,t){const n=new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),s=kr(e,t);return`${n} · ${s==="now"?"just now":s}`}function gj(e){return e&&[e.version,e.os,e.arch].filter(Boolean).join(" · ")||null}const R6={works:"works here",expired:"expired here",missing:"not on this deck",unavailable:"cannot share here",inUse:"in use here"},M6={works:"works there",broken:"broken there",unavailable:"cannot share there",unknown:"not offered by that deck",inUse:"in use there"};function $6(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`${R6[e.here]}, ${M6[e.there]}, ${t}${n}.`}function L6({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,b=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",k=gj(n.about),v=gj(m),N=m!=null&&m.version&&w?ace(m.version,w):null,x=o?Nm(o.last,a):null,C=o&&((Q=o.last)!=null&&Q.error)?loe({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,S=(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)??[],$=!!x&&!!S&&!e.quiet&&e.state.startsWith(x.text),A=l||e.kind==="dialling",O=((o==null?void 0:o.via)??e.via)==="tailscale",M=o?o.waiting?null:o.manual?O?"added by its Tailscale address":"added by address":O?"over Tailscale":"on this network":e.kind==="nearby"?O?"heard over Tailscale":"heard on this network":O?"asked this deck to pair, over Tailscale":"asked this deck to pair",W=e.tone==="bad"?"bad":l?e.here?"up":"down":"loose",B=(o==null?void 0:o.offers)??null,R=W==="up"?(B==null?void 0:B.current)??null:null,q=R&&"key"in R?R.key:null,T=!!R&&"hidden"in R,F=!!R&&"other"in R,D=(n.shared??[]).filter(oe=>{var re;return!((re=o==null?void 0:o.notOffered)!=null&&re.includes(oe))}),K=l?ice((B==null?void 0:B.accounts)??null,s,D,q):[],V=K.filter(oe=>oe.in==null&&oe.out==="cut"&&oe.here!=="inUse"),H=K.some(oe=>oe.in!=null),P=K.some(oe=>oe.out!=null),I=new Set((n.peers??[]).filter(oe=>oe.paired).flatMap(oe=>oe.notOffered??[])),U=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>lce?kr(B.at,a):null;return{peer:o,stranger:i,paired:l,own:u,canRename:h,fp:f,where:p,about:m,unsaid:b,hereRuns:k,thereRuns:v,order:N,line:x,silence:C,raw:S,echoed:$,showRound:A,how:M,link:W,hiddenThere:T,otherThere:F,lanes:K,spent:V,taking:H,giving:P,givenTo:U,told:Z,unplaced:z,unknown:X,stale:Y}}function yj(){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 vf({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 uce({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:b,silence:k,raw:v,echoed:N,showRound:x,how:C,link:S,hiddenThere:_,otherThere:$,lanes:A,spent:O,taking:M,giving:W,givenTo:B,told:R,unplaced:q,unknown:T,stale:F}=e;return r.jsxs("div",{className:"lan-map","data-link":S,"data-asking":s||void 0,"data-bus":A.length>0||void 0,children:[r.jsxs("div",{className:"lan-ends",children:[r.jsxs("p",{className:"lan-end",children:[r.jsx("span",{className:"lan-end-name",children:"This deck"}),p&&r.jsx("span",{className:"lan-end-runs",children:p}),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"}),$&&r.jsx("span",{className:"lan-end-note",children:"on another account"})]})]}),r.jsxs("div",{className:"lan-link",children:[r.jsx(yj,{}),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(yj,{}),(u&&C||x)&&r.jsxs("p",{className:"lan-link-sub",children:[u&&C,u&&C&&x&&" · ",x&&(b?N?r.jsx("code",{className:"ap-lan-code",children:v}):r.jsx("span",{className:"lan-round","data-tone":b.tone,children:b.text.replace(/ · now$/," · just now")}):"not asked yet"),x&&v&&!N&&r.jsx("code",{className:"lan-fact-raw",children:v})]}),q.length>0&&r.jsx("ul",{className:"lan-done",children:q.map(D=>{const K=ij(D);return r.jsxs("li",{"data-ok":D.ok&&!K,children:[D.email," ",r.jsxs("span",{className:"lan-done-what",children:[D.ok?"arrived":"did not arrive",K&&` — ${K.long}`]})]},`${D.email}:${D.action}`)})}),k&&r.jsx("p",{className:"lan-note lan-link-note",children:k}),(i==null?void 0:i.waiting)&&r.jsx("p",{className:"lan-note lan-link-note",children:t.hint}),(b==null?void 0:b.hint)&&r.jsx("p",{className:"lan-note lan-link-note",children:b.hint})]}),A.length>0&&r.jsx("ul",{className:"lan-lanes",role:"list","aria-label":`Logins between this deck and ${t.name}`,children:A.map((D,K)=>{const V=R.get(D.email),H=V?ij(V):null,P=D.out==="live"||D.in!=null&&D.in!=="cut";return r.jsxs("li",{role:"listitem",className:"lan-lane","data-tone":D.tone,"data-draw":D.in&&D.out?"both":D.in?"in":"out","data-used-there":D.usedThere||void 0,style:{"--i":K},children:[r.jsx("i",{className:"lan-pip","data-end":"here","data-state":D.here,"aria-hidden":!0}),r.jsxs("span",{className:"lan-track",children:[r.jsxs("span",{className:"lan-wire","data-flow":P?"live":"cut","aria-hidden":!0,children:[(D.in==="live"||D.in==="wait")&&r.jsx("i",{className:"lan-glint","data-dir":"in","data-tone":D.in}),D.out==="live"&&r.jsx("i",{className:"lan-glint","data-dir":"out"})]}),D.in&&D.in!=="cut"&&r.jsx(vf,{dir:"in"}),D.out==="live"&&r.jsx(vf,{dir:"out"}),r.jsx("span",{className:"lan-lane-email",children:D.email})]}),r.jsx("i",{className:"lan-pip","data-end":"there","data-state":D.there,"aria-hidden":!0}),r.jsx("span",{className:"vis-hidden",children:$6(D)}),(D.caption||V)&&r.jsxs("span",{className:"lan-lane-note",children:[D.caption,D.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}`]})]})]},D.key)})},a),l&&r.jsxs(r.Fragment,{children:[O.length>0&&r.jsxs("p",{className:"lan-spent",children:["Paired decks get nothing from ",O.length===1?O[0].email:"the expired ones"," until you sign in again here."]}),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:[M&&r.jsxs("span",{className:"lan-key",children:[r.jsx("span",{className:"lan-key-wire","data-dir":"in","aria-hidden":!0,children:r.jsx(vf,{dir:"in"})}),"from ",t.name]}),W?r.jsxs("span",{className:"lan-key",children:[r.jsx("span",{className:"lan-key-wire","data-dir":"out","aria-hidden":!0,children:r.jsx(vf,{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 dce=20,hce=17,RR=34,fce=160,pce=80,mce=200,gce=8,yce=14,wce=10,xce=.61803398875;function vce({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,b]=g.useState(!1),k=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&&(b(!0),k.current!=null&&window.clearTimeout(k.current),k.current=window.setTimeout(()=>b(!1),mce)),he={w:ge,h:ve},m(he))};if(pe(),typeof ResizeObserver>"u")return;const Le=new ResizeObserver(pe);return Le.observe(re),()=>{Le.disconnect(),k.current!=null&&window.clearTimeout(k.current)}},[]);const v=g.useMemo(()=>p?Kle(t,p.w,p.h,(e==null?void 0:e.name)??"",re=>{var he,pe;return fS(re,(pe=(he=ud(e,re).peer)==null?void 0:he.about)==null?void 0:pe.os)}):null,[t,p,e]),N=g.useMemo(()=>Xle(t),[t]),x=(v==null?void 0:v.nodes)??[],C=g.useRef(new Map),S=g.useMemo(()=>{const re=new Map;for(const he of x){const pe=zs(he.row);re.set(pe,ece(C.current.get(pe),he.angle))}return C.current=re,re},[x]),[_,$]=g.useState(null),[A,O]=g.useState(null),[M,W]=g.useState("none"),B=g.useRef(null),R=g.useCallback((re,he)=>{B.current!==re&&(B.current=re,W(he),O(re))},[]),q=g.useRef(null),T=g.useRef(null),F=g.useCallback(()=>{T.current!=null&&window.clearTimeout(T.current),T.current=null},[]),D=g.useCallback((re,he)=>{if(q.current!=null&&window.clearTimeout(q.current),q.current=null,F(),$(re),he==="keyboard"){R(re,"none");return}T.current=window.setTimeout(()=>R(re,B.current?"swap":"full"),pce)},[R,F]),K=g.useCallback(()=>{q.current!=null&&window.clearTimeout(q.current),F(),q.current=window.setTimeout(()=>$(null),fce)},[F]);g.useEffect(()=>()=>{q.current!=null&&window.clearTimeout(q.current),F()},[F]);const V=_&&x.some(re=>zs(re.row)===_)?_:null,H=A?t.find(re=>zs(re)===A)??null:null;g.useEffect(()=>{A&&!H&&R(null,"swap")},[A,H,R]);const[P,I]=g.useState(null),U=g.useRef(new Map),Z=x.findIndex(re=>zs(re.row)===P),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=zs(x[pe].row);I(Le),(ge=U.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?Zle(N):"Local network is off":"checking…",le=()=>{F(),R(null,"swap"),$(null)},de=V?x.find(re=>zs(re.row)===V)??null:null,oe=()=>{var re;A&&((re=U.current.get(A))==null||re.focus()),le()};return vt.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":(v==null?void 0:v.dense)||void 0,"data-still":w||void 0,onClick:re=>{re.target===re.currentTarget&&le()},children:p&&v&&r.jsxs(r.Fragment,{children:[r.jsx(bce,{layout:v,w:p.w,h:p.h}),x.map(re=>{const he=zs(re.row);return r.jsx(Nce,{node:re,angle:S.get(he)??re.angle,lit:V===he},he)}),r.jsx(Sce,{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=zs(re.row);return r.jsx(Cce,{node:re,angle:S.get(pe)??re.angle,os:(ge=(Le=ud(e,re.row).peer)==null?void 0:Le.about)==null?void 0:ge.os,lit:V===pe,shown:A===pe,tabbable:he===z,register:ve=>{ve?U.current.set(pe,ve):U.current.delete(pe)},onHold:ve=>{I(pe),D(pe,ve)},onRelease:K,onOpen:()=>o(re.row.fp)},pe)})}),x.length===0&&r.jsx(_ce,{status:e})]})}),r.jsx(Ece,{slice:(v==null?void 0:v.zone)!=null})]}),r.jsx("aside",{className:"nm-side","aria-label":"Details",children:H&&e?r.jsx(Ace,{row:H,status:e,accounts:n,now:s,entrance:M,onOpen:()=>o(H.fp),onBack:oe},zs(H)):r.jsx(Tce,{status:e,summary:N,entrance:M,slice:(v==null?void 0:v.zone)!=null})})]})]})}),document.body)}function I6(){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 bce({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:jce(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:kce(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:S6(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 MR(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 kce(e,t,n){const s=e.to-e.from>180?1:0,a=(N,x)=>{const C=x*Math.PI/180;return[t+Math.cos(C)*N.rx,n+Math.sin(C)*N.ry]},o=(N,x)=>x/((N.rx+N.ry)/2)*(180/Math.PI),i=(N,x,C)=>{const S=Math.hypot(x[0]-N[0],x[1]-N[1])||1,_=Math.min(.5,C/S);return[N[0]+(x[0]-N[0])*_,N[1]+(x[1]-N[1])*_]},l=([N,x])=>`${N.toFixed(1)},${x.toFixed(1)}`,u=wce,h=yce,f=o(e.inner,u),p=o(e.outer,h),m=a(e.inner,e.from),w=a(e.outer,e.from),b=a(e.outer,e.to),k=a(e.inner,e.to),v=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${v(e.outer)} 0 ${s} 1 ${l(a(e.outer,e.to-p))}`,`Q${l(b)} ${l(i(b,k,h))}`,`L${l(i(k,b,u))}`,`Q${l(k)} ${l(a(e.inner,e.to-f))}`,`A${v(e.inner)} 0 ${s} 0 ${l(a(e.inner,e.from+f))}`,"Z"].join(" ")}function jce(e,t,n){const s={rx:e.outer.rx-_p,ry:e.outer.ry-_p},a=e.to-e.from>180?1:0;return`M${MR(s,t,n,e.to)} A${s.rx.toFixed(1)},${s.ry.toFixed(1)} 0 ${a} 0 ${MR(s,t,n,e.from)}`}function Nce({node:e,angle:t,lit:n}){const s=e.row.kind==="paired"&&e.row.here,a=e.order*xce%1*gce;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":`${RR}px`,"--gap":`${RR+(e.tier==="loose"?hce:dce)}px`,"--i":e.order,"--phase":`${a.toFixed(2)}s`},children:s&&r.jsx("i",{className:"nm-glint"})})}function Sce({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 Cce({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-${Rce(zs(f))}`,m=e.angle*Math.PI/180,w=fS(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}: ${E6(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:b=>{b.pointerType==="mouse"&&l("pointer")},onPointerLeave:u,onFocus:b=>l(b.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(yj,{}),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:C6(f)}),r.jsx("span",{className:"nm-cap",children:w})]}),e.tier==="online"&&r.jsx("span",{id:p,className:"vis-hidden",children:w})]})}function _ce({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 Ece({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 O6({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 Tce({status:e,summary:t,entrance:n,slice:s}){const a=Qle(e),o=gj(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=tce(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(O6,{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 Ace({row:e,status:t,accounts:n,now:s,entrance:a,onOpen:o,onBack:i}){var k;const l=L6({row:e,source:ud(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=nce(e,t.pairingMode),p=sce(l.lanes),m=p.length,w=rce(p),b=l.unknown&&((k=l.peer)!=null&&k.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:E6(e)}),f&&r.jsx("p",{className:"nm-next",children:f}),u.length>0&&r.jsx(O6,{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((v,N)=>r.jsxs("li",{className:"nm-lane","data-tone":v.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:v.email}),$R(v)&&r.jsx("span",{className:"nm-lane-said","aria-hidden":!0,children:$R(v)}),v.usedThere&&r.jsx("span",{className:"nm-lane-used","aria-hidden":!0,children:"in use there"}),r.jsxs("span",{className:"vis-hidden",children:[v.email,": ",$6(v)]})]},v.key))}),b&&r.jsx("p",{className:"nm-panel-hint",children:b})]})]})}function $R(e){return e.caption?e.caption:e.tone==="ok"?null:`${R6[e.here]} · ${M6[e.there]}`}function Rce(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 Mce=6;function $ce({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,Mce),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 b=hm(w.getBoundingClientRect(),{width:m.offsetWidth,height:m.offsetHeight},{width:window.innerWidth,height:window.innerHeight});m.style.top=`${b.top}px`,m.style.left=`${b.left}px`,m.style.maxHeight=b.maxHeight==null?"":`${b.maxHeight}px`,m.dataset.side=b.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]),vt.createPortal(r.jsxs("div",{ref:o,id:t,className:"ap-peek",role:"tooltip",onPointerEnter:s,onPointerLeave:a,children:[r.jsx("p",{className:"ap-peek-title",children: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 Lce({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(y6)},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}),r.jsx("span",{children: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(I6,{})}),a&&r.jsx($ce,{anchorId:"ap-lan-entry",id:"ap-lan-peek",rows:t,onHold:l,onLet:i})]})}function Ice({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 Oce({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 Pce({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 b,k,v,N;const h=(b=l.peer)!=null&&b.addr?`${l.peer.addr}:${l.peer.port}`:l.row.addr,f=h||l.row.fp,p=(k=l.peer)!=null&&k.pairedAt?kr(l.peer.pairedAt,t):null,m=[(N=(v=l.peer)==null?void 0:v.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 Dce(){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 Fce({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 b=g.useRef(null),k=gt(i,{focusRef:b}),v=yt(i),[N,x]=g.useState(null),[C,S]=g.useState(null),[_,$]=g.useState(!1),[A,O]=g.useState(0),M=g.useRef(null),W=g.useRef(null),B=g.useRef(!0);g.useEffect(()=>()=>{B.current=!1},[]);const R=N!=null;g.useEffect(()=>{var re;R&&((re=M.current)==null||re.select())},[R]);const q=g.useRef(!1);g.useEffect(()=>{var re,he;q.current&&!R&&Wn(((re=document.activeElement)==null?void 0:re.tagName)??null)&&((he=W.current)==null||he.focus()),q.current=R},[R]);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&&S(he),he==null},{armed:D,armedTwin:K,pressOwn:V,pressTwin:H}=Ice({row:e,run:F,onVerb:h,onUnpair:w}),P=L6({row:e,source:t,status:n,accounts:s,now:a}),{peer:I,stranger:U,paired:Z,own:z,canRename:X,fp:Y}=P,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&&O(he=>he+1)}),le=async()=>{if(Y)try{if(await navigator.clipboard.writeText(Y),!B.current)return;$(!0),window.setTimeout(()=>{B.current&&$(!1)},1600)}catch{B.current&&S("Could not copy it — select the fingerprint and copy it by hand.")}},de=[];Z&&(I!=null&&I.pairedAt)?de.push({label:"Paired",value:cce(I.pairedAt,a),tone:"meta"}):e.kind==="declined"&&U&&de.push({label:"Paired",value:`no · you said no ${lS(U.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 vt.createPortal(r.jsx("div",{className:"modal-backdrop",...v,role:"presentation",children:r.jsxs("div",{ref:k,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:[R?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:M,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:W,onClick:()=>{S(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(Dce,{})})]}),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}),R&&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:b,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:[C&&r.jsxs("div",{className:"ap-failure",role:"alert",children:[r.jsx("span",{className:"ap-failure-text",children:C}),r.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>S(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),r.jsx(uce,{view:P,row:e,status:n,asking:J,drawn:A,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(Pce,{instances:oe,now:a,busy:o,press:T,armedTwin:K,pressTwin:H,onUnpair:w})]}),r.jsx(Oce,{row:e,paired:Z,peer:I,status:n,busy:o,press:T,checkNow:te,armed:D,pressOwn:V,run:F,onVerb:h,onInvite:p})]})}),document.body)}function na(e,t){const n=g.useRef(!1);return g.useEffect(()=>{var s,a;!e||!n.current||(n.current=!1,Wn(((s=document.activeElement)==null?void 0:s.tagName)??null)&&(typeof t=="function"?t():(a=t.current)==null||a.focus()))},[e]),()=>{n.current=!0}}function Bce(e,t){if(e.length!==t.length)return!1;const n=new Set(e);return t.every(s=>n.has(s))}function qce(e,t,n,s){const a=new Set(e??t);return s?a.add(n):a.delete(n),[...a]}function LR(e,t,n){return e==null||n!=null&&!n.ok||Bce(e,t)?null:e}function P6({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 Fie();o.current=!1,i.current&&(a(!1),h.current=document.activeElement===l.current,n(qie(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 Uce(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 bf="Paused while this deck pairs only by invite. Turn that off above to use it.";function Wce({status:e,accounts:t,onClose:n,onChanged:s}){an("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),b=g.useRef(null),k=P=>{const I=so(m,P);return{disabled:I.disabled,"aria-busy":I.busy}},v=g.useRef(null),N=g.useRef(!0);g.useEffect(()=>()=>{N.current=!1},[]),g.useEffect(()=>{v.current=LR(v.current,e.shared??[],null)},[e.shared]);const x=g.useCallback(async(P,I,U="write")=>{b.current=U,w(U);try{const z=await(await fetch("/api/prefs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({lan:P})})).json().catch(()=>null);return N.current?(z!=null&&z.ok?h(null):h(Vs(Zt(I,z),z)),s(),(z==null?void 0:z.ok)===!0):!1}catch{return N.current&&h(Vs(Zt(I,null))),!1}finally{b.current=null,N.current&&w(null)}},[s]),C=g.useCallback(async P=>{const I=await x({name:P},"save the name","name");return I&&N.current&&l(U=>U===P?null:U),I},[x]),S=g.useRef(null),_=i!=null&&i!==(e.name??""),$=na(!_,S),A=g.useCallback(async()=>{_&&!await C(i)||n()},[_,i,C,n]),O=async()=>{if(!e.fp)return;const P=await ho(e.fp);if(N.current){if(!P){h(Vs("Could not copy it — select the fingerprint and copy it by hand."));return}p(!0),window.setTimeout(()=>{N.current&&p(!1)},1600)}},M=new Set(v.current??e.shared??[]),W=e.autoAsk!==!1,B=e.autoAccept!==!1,R=e.pairingMode==="invite",q=P=>{const I=k(P);return{...I,disabled:I.disabled||R}},T=e.shareActive!==!1,F=e.sendInUse===!0,D=e.tailscale??null,K=!!(D!=null&&D.on),V=(D==null?void 0:D.ask)!==!1,H=(D==null?void 0:D.accept)!==!1;return vt.createPortal(r.jsx("div",{className:"modal-backdrop",...o,role:"presentation",children:r.jsxs("div",{ref:a,className:"modal lan-modal",onClick:P=>P.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(P6,{line:u,onDismiss:()=>h(null),onAnswer:P=>{h(P),P.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:S,className:"ap-manage-input ap-lan-input","aria-label":"This deck's name on the network",value:i??e.name??"",placeholder:"this machine",onChange:P=>l(P.target.value),onKeyDown:P=>{P.key!=="Enter"||i==null||C(i)}}),_&&r.jsx("button",{type:"button",className:"ap-manage-btn",...k("name"),onClick:()=>{$(),C(i)},title:"Save it. This is the name other decks show for this one.",children:"save"})]}),r.jsxs("div",{className:"ap-lan-row",children:[r.jsx("span",{className:"ap-lan-label",children:"fingerprint"}),e.fp?r.jsxs("span",{className:"lan-fp",children:[r.jsx("code",{className:"ap-lan-code",children:e.fp}),r.jsx("button",{type:"button",className:"ap-lan-word lan-copy",onClick:()=>void O(),"aria-label":f?"Fingerprint copied":"Copy this deck's fingerprint",children:f?"copied":"copy"})]}):r.jsx("span",{className:"ap-lan-label",children:"not known yet"})]})]}),r.jsxs("div",{className:"modal-section",children:[r.jsx("h3",{className:"lan-h",children:"Share these accounts"}),r.jsxs("div",{className:"ap-lan-picks",children:[t.length===0&&r.jsx("span",{className:"ap-lan-empty",children:"No Claude accounts on this deck yet — add one with + at the top of this panel."}),t.map(P=>r.jsxs("label",{className:"ap-lan-pick",title:P.alive?P.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:M.has(P.key),onChange:I=>{const U=qce(v.current,e.shared??[],P.key,I.target.checked);v.current=U,x({shared:U},I.target.checked?"share that account":"stop sharing that account").then(Z=>{v.current===U&&(v.current=LR(U,e.shared??[],{ok:Z}))})}}),r.jsx("span",{className:"ap-lan-pick-name",children:P.email}),!P.alive&&r.jsx("span",{className:"ap-lan-dead",children:"not working here"}),P.alive&&P.inUse&&M.has(P.key)&&r.jsx("span",{className:"ap-lan-dead",children:"in use here · not sent"})]},P.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",...k("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",...k("send-in-use"),onKeyDown:P=>{P.repeat&&P.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",R&&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":R,"aria-label":"Pair new decks only by invite","aria-describedby":R?"lan-invite-only-detail":void 0,...k("mode"),onKeyDown:P=>{P.repeat&&P.preventDefault()},onClick:()=>void x({pairingMode:R?"automatic":"invite"},R?"let decks pair on their own again":"pair new decks only by invite","mode"),title:R?"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",R&&r.jsx("span",{className:"lan-sub-state",children:" · paused while pairing is invite-only"})]}),r.jsxs("div",{className:"lan-switches","data-paused":R||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":W,"aria-label":"Ask every deck this one finds",...q("ask"),onClick:()=>void x({autoAsk:!W},W?"stop asking automatically":"ask every deck this one finds","ask"),title:R?bf:W?"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:P=>{P.repeat&&P.preventDefault()},onClick:()=>void x({autoAccept:!B},B?"stop accepting automatically":"accept every deck that asks","accept"),title:R?bf: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"})})]})]})]})]}),(D==null?void 0:D.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:Uce(D)})]}),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",...k("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",R&&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":R||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:R?bf: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":R||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:P=>{P.repeat&&P.preventDefault()},onClick:()=>void x({tailscaleAccept:!H},H?"stop accepting your devices automatically":"accept your devices automatically","tailscale-accept"),title:R?bf: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",...k("name"),onClick:()=>void A(),children:"Done"})]})]})}),document.body)}function Hce({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(I6,{})}),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 zce({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,b]=g.useState(!1),k=Pie(),[v,N]=g.useState(!1),{status:x,manual:C,now:S,busy:_,failure:$,dismissFailure:A,answerGiveBack:O,pressProps:M,load:W,toggle:B,answer:R,dropAddress:q,rename:T,checkOne:F,checkNow:D}=Vie(t,()=>f(!0)),{armed:K,pressUnpair:V}=Gie(R),[H,P]=g.useState(null),[I,U]=g.useState(!1),Z=g.useMemo(()=>koe(e,x??null),[e,x]),z=g.useMemo(()=>Z.filter(Ee=>joe(Ee.key,x??null,S)).map(Ee=>Ee.key).sort().join(`
105
- `),[Z,x,S]);g.useEffect(()=>{n==null||n(z?z.split(`
106
- `):[])},[z,n]);const X=g.useMemo(()=>JSON.stringify(Eoe(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=_oe(Ee.key,x??null,S);return xe?[[Ee.key,xe]]:[]})),[Z,x,S]);g.useEffect(()=>{a==null||a(new Map(JSON.parse(Y)))},[Y,a]);const J=(x==null?void 0:x.enabled)===!0,Q=g.useMemo(()=>hoe((x==null?void 0:x.pairingMode)==="invite"&&x?{...x,pending:[]}:x,S),[x,S]),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&&P(null)},[H,x,te]);const{asks:le,rest:de,live:oe,folded:re,troubled:he,shown:pe,paired:Le}=boe(Q,v),ge=coe(x,S),ve=voe(x,Q),je=r.jsxs(r.Fragment,{children:[p&&x&&r.jsx(mle,{status:x,manual:C,startWith:p==="invite"?"invite":void 0,onClose:()=>m(!1),onChanged:()=>{W(),t()}}),w&&r.jsx(v6,{title:"How Local network works",steps:ile,finish:J?void 0:{label:"Turn it on",act:()=>{b(!1),B()}},onClose:()=>b(!1)}),h&&x&&r.jsx(Wce,{status:{...x,manualRows:C},accounts:Z,manual:C,onClose:()=>f(!1),onChanged:()=>{W(),t()}}),I&&r.jsx(vce,{status:x,rows:Q,accounts:Z,now:S,covered:!!te||h||!!p||w,onOpenDeck:P,onClose:()=>U(!1)}),te&&x&&r.jsx(Fce,{row:te,source:ud(x,te),status:x,accounts:Z,now:S,busy:_,onClose:()=>P(null),onRename:Ee=>T(te.fp,Ee),onCheck:()=>F(te.fp),onVerb:()=>{switch(te.kind){case"paired":return R("unpair",te.fp,"unpair that deck");case"nearby":return R("accept",te.fp,"reach that deck");case"declined":return R("allow",te.fp,"let that deck ask again");case"dialling":return q(te.fp);default:return Promise.resolve(null)}},onSettings:()=>{P(null),f(!0)},onInvite:()=>{P(null),m("invite")},twins:(te.twins??[]).map(Ee=>({row:Ee,peer:ud(x,Ee).peer??null})),onUnpair:Ee=>R("unpair",Ee,"unpair that deck")})]});return o?r.jsxs("div",{className:"ap-lan-view",children:[r.jsx(Hce,{on:J,status:x,paired:Le,busy:_,pressProps:M,checkNow:D,setAddOpen:m,setSetupOpen:f,setMapOpen:U,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",...M("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(vle,{on:J,status:x}),!J&&r.jsxs("div",{className:"ap-lan-intro-row",children:[r.jsxs("button",{type:"button",className:"ap-lan-intro",onClick:()=>b(!0),title:"Four pictures: what this does, and what to do on each machine",children:[r.jsx(lle,{}),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(P6,{line:$,onDismiss:A,onAnswer:O}),J&&r.jsxs(r.Fragment,{children:[le.length>0&&r.jsx(yle,{asks:le,pressProps:M,answer:R}),pe.length>0&&r.jsx(wle,{rows:pe,pairingMode:x==null?void 0:x.pairingMode,armed:K,pressProps:M,answer:R,dropAddress:q,onUnpair:V,onOpenPeer:P,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":v,onClick:()=>N(Ee=>!Ee),title:v?"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${v?" open":""}`,"aria-hidden":!0,children:"›"}),v?"fewer":`${re.length} more`,!v&&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:uoe(x==null?void 0:x.checkedAt,S,_==="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:()=>b(!0),children:"How it works"}),r.jsx(sd,{film:"localNetwork"})]})]})]})}),je]}):r.jsxs("div",{className:"ap-foot",children:[r.jsx(Lce,{entry:ve,rows:Q,onOpen:i,onMap:J?()=>U(!0):void 0,...k}),r.jsx("p",{className:"vis-hidden",role:"status",children:ge.tone==="ok"?"":ge.text}),je]})}function Vce({anchorId:e,id:t,peers:n,onHold:s,onLet:a}){const o=g.useRef(null),{title:i,shown:l,rest:u}=Oie(n),h=g.useCallback(()=>{const f=o.current,p=document.getElementById(e);if(!f||!p)return;f.style.maxHeight="";const m=hm(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]),vt.createPortal(r.jsxs("div",{ref:o,id:t,className:"ap-peek ap-fold-peek",role:"tooltip",onPointerEnter:s,onPointerLeave:a,children:[r.jsx("p",{className:"ap-peek-title",children:i}),r.jsx("div",{className:"ap-peek-list",children: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 Gce({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),b=g.useRef(0);g.useEffect(()=>()=>window.clearTimeout(b.current),[]),g.useEffect(()=>{a&&(window.clearTimeout(b.current),w(!1))},[a]);const k=S=>{a||(window.clearTimeout(b.current),b.current=window.setTimeout(()=>w(!0),S))},v=()=>{window.clearTimeout(b.current),b.current=window.setTimeout(()=>w(!1),w6)},N=()=>window.clearTimeout(b.current),x=()=>{window.clearTimeout(b.current),w(!1)},C=Lie(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:S=>{S.pointerType==="mouse"&&k(y6)},onPointerLeave:v,onFocus:S=>{S.target.matches(":focus-visible")&&k(0)},onBlur:v,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":C.tone,children:C.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(Vce,{anchorId:"ap-rest-entry",id:"ap-rest-peek",peers:e,onHold:N,onLet:v}),a&&r.jsx(Kce,{order:i,choices:l,onOrder:u,allOpen:h,onToggleAll:f,held:p})]})}function Kce({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===km?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 Yce(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}const Xce=1800;function Zce({accounts:e,onClose:t,copyText:n}){an("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,b]=g.useState(()=>Math.floor(Date.now()/1e3)),k=g.useRef(null),v=g.useRef(!1),N=gt(t,{focusRef:k}),x=yt(t),C=na(o!=null,k),S=na(o==null,k);g.useEffect(()=>{if(!o)return;b(Math.floor(Date.now()/1e3));const D=window.setInterval(()=>b(Math.floor(Date.now()/1e3)),1e3);return()=>window.clearInterval(D)},[o]);const _=gie(e),$=yie(e,s),A=$.length===e.length,O=D=>a(K=>wie(K,D)),M=g.useCallback(async()=>{const D=xie($);if(!Cn(v.current)||!D)return;v.current=!0,u(!0),f(null),m(!1);const K=await Yce(D).catch(()=>null);if(v.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,$]),W=o?m6(o.expiresAt,w):null,B=(W==null?void 0:W.tone)==="gone",R=(o==null?void 0:o.shared.length)??0,q=B?"This share has expired":R===1?"1 account, ready to paste":`${R} accounts, ready to paste`,T=R===1?"this is the password":`this is ${R} passwords`,F=o?B?q:`${q} — ${T}`:"";return vt.createPortal(r.jsx("div",{className:"modal-backdrop",...x,role:"presentation",children:r.jsxs("div",{ref:N,className:"modal sa-modal",onClick:D=>D.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:k,onClick:async()=>{if(B){S(),C(),i(null),M();return}await n(o.blob)&&(m(!0),window.setTimeout(()=>m(!1),Xce))},children:B?"make a new share":p?"copied":`copy ${R===1?"the share":"all "+R}`}),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 ${W==null?void 0:W.tone}`,children:W==null?void 0:W.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(D=>{var V;const K=!!(D.email&&((V=D.detail)!=null&&V.includes(D.email)));return r.jsxs("li",{children:[!K&&r.jsx("span",{className:"sa-who",children:D.email||`account ${D.num}`}),r.jsx("span",{className:"sa-why",children:D.detail||"could not be exported"})]},`${D.num}-${D.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:()=>{S(),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:k,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${$.length?"":" empty"}`,children:vie($.length)}),r.jsx("ul",{className:"sa-list sa-pick",children:_.map(D=>r.jsx("li",{children:r.jsxs("label",{className:"sa-row",children:[r.jsx("input",{type:"checkbox",checked:$.includes(D.num),onChange:()=>O(D.num)}),r.jsx("span",{className:"sa-who",children:D.label}),D.sub&&r.jsx("span",{className:"sa-sub",children:D.sub})]})},D.num))}),h&&r.jsx("p",{className:"aa-err",role:"alert",children:h}),r.jsxs("div",{className:"sa-actions",children:[r.jsx("button",{type:"button",className:"btn",onClick:()=>a(A?e.map(D=>D.num):[]),children:A?"Clear all":"Select all"}),r.jsx("button",{type:"button",className:"btn primary",ref:k,...Bn(l,!$.length),onClick:()=>{C(),M()},children:l?"making the share…":$.length===0?"Share":$.length===1?"Share 1 account":`Share ${$.length} accounts`})]})]})]})]})}),document.body)}function pS(e,t){var n;return!e.disabled&&!((n=xi(e,t))!=null&&n.blocksSwitch)}function Jce(e,t,n){return e.map(s=>{const a=xi(s,t,n==null?void 0:n(s));return{key:vs(s),name:s.alias??s.email??`account ${s.num}`,ready:pS(s,t),why:s.disabled?"held out":a!=null&&a.blocksSwitch?a.text:null,warn:(a==null?void 0:a.tone)==="warn",headroom:tS(s,t)}})}function Qce(e,t,n){const s=Number(t),a=e&&(n==null?e.headroom:tS(e,n));return a!=null&&Number.isFinite(s)&&100-a>=s}function eue(e){return(e==null?void 0:e.ok)===!0&&(e.enabled||e.external)}const D6="agent-dag.otherAccountsOrder",F6="agent-dag.otherAccountsOpen";function B6(){const e=nt(D6);return typeof e=="string"&&e.length>0&&e.length<=64?e:km}function tue(e){st(D6,e)}function nue(){const e=nt(F6);if(!e)return rj;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 rj}function sue(e){st(F6,JSON.stringify({mode:e.mode,keys:e.keys.filter(t=>!t.startsWith("slot:"))}))}function rue(){const[e,t]=g.useState(null),n=g.useRef(null),s=g.useCallback(i=>im(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 aue=8e3,oue=1800,iue=4e3;function lue({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(""),[b,k]=g.useState(null),v=g.useRef(0);g.useEffect(()=>{if(b==null)return;const z=window.setTimeout(()=>k(null),iue);return()=>window.clearTimeout(z)},[b]);const[N,x]=g.useState(null),[C,S]=g.useState(!1),[_,$]=g.useState(null),[A,O]=g.useState(null),M=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]),W=g.useCallback(()=>{l(null),p(null),k(null),x(null),S(!1)},[]),B=(z,X="first")=>{W(),O(null),l({num:z,view:"menu",start:X})},R=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)||Wn(((J=document.activeElement)==null?void 0:J.tagName)??null))&&((Q=document.getElementById(`ap-more-${X.num}`))==null||Q.focus()),W()},[W]),q=g.useCallback(z=>p(z),[]),T=(z,X)=>{w(X??""),p(null),l({num:z,view:"rename"})},F=z=>w(z),D=z=>{O(null),p(null),l({num:z,view:"move"})},K=z=>O(z),V=async z=>{var Y;S(!1);const X=await M({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)&&(S(!0),window.setTimeout(()=>S(!1),oue))},P=async(z,X)=>{const{commit:Y,alias:J}=_ie(m,X);if(Y){const Q=await M({action:"alias",account:z,alias:J},`alias-${z}`);if(await n(!0),!(Q!=null&&Q.ok))return}R(z)},I=async(z,X)=>{var Q,te,le;const Y=await M({action:"move",account:z,slot:X},`move-${z}`),J=Sie({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)||Wn(((te=document.activeElement)==null?void 0:te.tagName)??null))&&re.focus()}((le=h.current)==null?void 0:le.num)===z&&W(),k(J.confirmRemove),J.shareFor==null&&(x(null),S(!1)),$(J.swapNote);const de=J.swapNote;de&&window.setTimeout(()=>$(oe=>oe===de?null:oe),aue),O(null),a(J.menuFor)}return Y};return{menu:i,menuFor:u,menuError:f,aliasDraft:m,confirmRemove:b,share:N,shareCopied:C,slotDraft:A,swapNote:_,showMenu:B,dropMenu:W,closeMenu:R,sayInMenu:q,startRename:T,typeAlias:F,doAlias:P,startMove:D,pickSlot:K,doSlot:async(z,X,Y)=>{if(!Y.sends){R(z);return}await I(z,X)},makeShare:V,copyShare:H,pressRemove:z=>{const X=Date.now(),Y=yi({armedFor:b,target:z,armedAt:v.current,now:X,gapMs:gi});if(Y==="arm"){k(z),v.current=X;return}Y!=="ignore"&&(k(null),M({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&&W(),a(null))}))}}}function cue(e,t){return!e||!t||t.some(n=>n.num===e.num&&n.active)?e:null}const uue="login_expired";function due(e,t,n){return(e==null?void 0:e.reason)!==uue?null:{text:`${t}'s login expired · sign in again to use it`,row:n,signIn:!0}}const hue="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 fue(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:hue}}:null}function pue({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,b,k="panel")=>{if(!t(b))return null;const v=k==="menu"?i:a;v(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||v({text:oj(x,"command failed",N.status),raw:cd(x)}),x}catch{return v({text:"server unreachable"}),null}finally{n()}},[t,n,i,a]);g.useEffect(()=>{!(e!=null&&e.ok)||!e.accounts||h(w=>cue(w,e.accounts))},[e]);const p=async(w,b)=>{if(t(`switch-${w}`)){o(),h(null);try{const v=await(await fetch("/api/claude-accounts/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({account:w})})).json().catch(()=>null),N=due(v,b,w);N?a(N):v!=null&&v.ok?h({num:w,name:b}):a({text:oj(v,"the switch failed"),raw:cd(v),row:w}),await s(!0)}catch{a({text:"server unreachable",row:w})}finally{n(),l(w)}}},m=g.useCallback((w,b)=>h({num:w,name:b}),[]);return{switched:u,post:f,doSwitch:p,noteSwitched:m}}const mue=1800;function gue({auto:e,post:t,load:n}){var $;const[s,a]=g.useReducer(Woe,uj),[o,i]=g.useState(!1),l=g.useRef(null),u=g.useRef(null),h=g.useRef(null),f=g.useRef(!1),p=(($=e==null?void 0:e.settings["autoswitch.threshold"])==null?void 0:$.value)??"90",m=s.pick??p,w=Rie(m,p),b=s.custom!=null,k=s.refusal,v=g.useRef(b);return g.useEffect(()=>{var A,O,M;v.current!==b&&(v.current=b,b?((A=h.current)==null||A.focus(),(O=h.current)==null||O.select()):f.current&&((M=l.current)==null||M.focus()),f.current=!1)},[b]),{threshold:p,thresholdPick:m,thresholdCtl:w,thresholdSaved:o,thresholdRef:l,thresholdSaveRef:u,thresholdCustom:b,thresholdRefusal:k,thresholdFieldRef:h,proposeThreshold:A=>a({kind:"pick",pick:A}),typeThreshold:A=>a({kind:"type",text:A}),cancelThreshold:A=>{A.key!=="Escape"||A.nativeEvent.isComposing||!s.custom||(A.preventDefault(),A.stopPropagation(),f.current=!0,a({kind:"cancel"}))},leaveThreshold:()=>a({kind:"leave",stored:p}),doThreshold:async(A,O)=>{const M=await Hoe(A,O,t);if(M.kind==="refused"){a({kind:"refuse",message:M.message});return}M.kind==="sent"&&(await n(!0),!M.ok)||(f.current=document.activeElement===h.current,a({kind:"settle"}),i(!0),window.setTimeout(()=>{var W;document.activeElement===u.current&&((W=l.current)==null||W.focus()),i(!1)},mue))}}}const yue=1800;function wue({auto:e,post:t,load:n}){var b;const[s,a]=g.useState(null),[o,i]=g.useState(!1),l=g.useRef(null),u=g.useRef(null),h=((b=e==null?void 0:e.choice)==null?void 0:b.next)??"room",f=s??h,p=Aie(f,h);return{nextPick:f,nextCtl:p,nextSaved:o,nextRef:l,nextSaveRef:u,proposeNext:k=>a(Doe(k)?k:null),doNext:async()=>{if(!p.sends)return;const k=await t({action:"next",value:f},"next");await n(!0),k!=null&&k.ok&&(a(null),i(!0),window.setTimeout(()=>{var v;document.activeElement===u.current&&((v=l.current)==null||v.focus()),i(!1)},yue))}}}const xue=Object.freeze({text:"couldn't reach the deck server",reload:!0}),vue=Object.freeze({text:"still waiting on the deck server — claude-swap can be slow to answer",reload:!0});async function IR(e){return e.ok?{ok:!0,status:e.status,body:null}:{ok:!1,status:e.status,body:await e.json().catch(()=>null)}}function bue(e){const t=e.find(s=>!s.ok);if(!t)return null;const n=cd(t.body);return{text:oj(t.body,`the deck server answered ${t.status}`),...n?{raw:n}:{},reload:!0}}function xw(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 vw=e=>e!=null&&typeof e=="object"&&!Array.isArray(e),bw=e=>e==null||typeof e=="string",kw=e=>e==null||typeof e=="number"&&Number.isFinite(e)&&e>=0&&Number.isFinite(new Date(e).getTime());function kue(e){if(!vw(e)||typeof e.ok!="boolean")return!1;if(!e.ok)return bw(e.reason)&&bw(e.hint);if(!Array.isArray(e.accounts))return!1;const t=new Set;return e.accounts.every(n=>{if(!vw(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(bw)||![n.active,n.disabled,n.stale].every(a=>typeof a=="boolean")||!kw(n.fetchedAt)||!kw(n.nextAt)||!Array.isArray(n.lanes)))return!1;const s=new Set;return n.lanes.every(a=>!vw(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||!kw(a.resetAt==null?null:typeof a.resetAt=="number"?a.resetAt*1e3:NaN)?!1:(s.add(a.id),!0))})}const q6=15e3,jue=3e4;function U6(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(v=!1)=>{if(!p.current||!v&&m.current.size>0)return;const N=++f.current;v&&i(!0);const x=new AbortController;m.current.add(x);const C=window.setTimeout(()=>x.abort(),jue);try{const[S,_]=await Promise.all([`/api/claude-accounts${v?"?refresh=1":""}`,"/api/cswap-auto"].map(async M=>fetch(M,{signal:x.signal}))),[$,A]=await Promise.all([S.ok?S.json():null,_.ok?_.json():null]),O=bue([await IR(S),await IR(_)]);if(!p.current||N!==f.current)return;if($&&!kue($)){u(M=>xw(M,{text:"the deck server returned unreadable account data",reload:!0}));return}$&&(n($),e($)),A&&a(A),u(M=>xw(M,O))}catch{if(p.current&&N===f.current){const S=x.signal.aborted?vue:xue;u(_=>xw(_,S))}x.abort()}finally{window.clearTimeout(C),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),q6),()=>{p.current=!1,f.current++,h.current!=null&&window.clearInterval(h.current);for(const v of m.current)v.abort()}),[w]);const b=g.useCallback(v=>u(v),[]),k=g.useCallback(()=>u(null),[]);return{data:t,auto:s,reloading:o,failure:l,load:w,sayFailure:b,clearFailure:k}}const Nue="#ap-rest-entry";function Sue(e){return[`#${e}`,Nue,...KP(null)]}function Cue(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||!Wn(((o=document.activeElement)==null?void 0:o.tagName)??null)))for(const i of Sue(a)){const l=document.querySelector(i);if(l){l.focus();return}}},[e]),{onFocus:n,onBlur:s}}function _ue({onClose:e,leaving:t,onReport:n,onRoster:s,lanWanted:a=!1,onLanShown:o}){var ka,$r,Gn;an("accounts-panel");const i=An(),{busy:l,claim:u,release:h,pressProps:f}=rue(),[p,m]=g.useState("accounts"),[w,b]=g.useState(!1),[k,v]=g.useState(null),N=g.useRef(k);N.current=k;const[x,C]=g.useState(!1),[S,_]=g.useState(null),[$,A]=g.useState(!1),[O,M]=g.useState(null),[W,B]=g.useState(nue),[R,q]=g.useState(B6),[T,F]=g.useState(null),[D,K]=g.useState(!1),V=g.useRef(s);V.current=s;const H=g.useCallback(we=>{var et;B(pt=>Mae(pt,we.accounts)),(et=V.current)==null||et.call(V,we)},[]),{data:P,auto:I,reloading:U,failure:Z,load:z,sayFailure:X,clearFailure:Y}=U6(H),J=Cue(P),Q=g.useCallback(we=>{window.requestAnimationFrame(()=>{var et;if(Wn(((et=document.activeElement)==null?void 0:et.tagName)??null))for(const pt of KP(we)){const Et=document.querySelector(pt);if(Et){Et.focus();return}}})},[]),te=g.useRef(null),le=lue({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}=pue({data:P,claim:u,release:h,load:z,sayFailure:X,clearFailure:Y,sayInMenu:ge,rescueFocus:Q});te.current=we=>{const et=fue(we);et&&"switched"in et?xe(et.switched.num,et.switched.name):et&&X(et.failure)};const Ie=we=>{_(we),C(!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}=gue({auto:I,post:je,load:z}),{nextPick:fe,nextCtl:_e,nextSaved:Ve,nextRef:ot,nextSaveRef:tt,proposeNext:wt,doNext:$t}=wue({auto:I,post:je,load:z}),Gt=YN();g.useEffect(()=>{sue(W)},[W]),g.useEffect(()=>{tue(R)},[R]);const[nr,_s]=g.useState(()=>new Set),Hn=g.useCallback(we=>_s(new Set(we)),[]),[ns,Es]=g.useState(()=>new Map),[wn,zn]=g.useState(()=>new Map),Me=we=>{const et=iR([we])[0].key,pt=ns.get(et);return{noCopyWorksNearby:nr.has(et),sharedTo:(pt==null?void 0:pt.to)??null,sharedInUse:(pt==null?void 0:pt.inUse)===!0,elsewhere:wn.get(et)??null}},qe=(ka=P==null?void 0:P.accounts)==null?void 0:ka.find(we=>we.active),Je=qe?xi(qe,Gt,Me(qe)):null,_t=ve?($r=P==null?void 0:P.accounts)==null?void 0:$r.find(we=>we.num===ve.num):void 0,Nt=_t?Me(_t).elsewhere:null,ss=Nt!=null&&Nt.length?`. Also active on ${z5(Nt)}: when one machine renews this login, the other is signed out.`:"",Vn=(P==null?void 0:P.accounts)??[],xn=qe?Vn.filter(we=>!we.active):[],Tr=G5(xn),vn=Y5(R,xn),on=sj(K5(xn,vn,we=>pS(we,Gt),Gt),T),Ts=g.useRef(!1),sr=g.useRef(!1),rs=g.useRef(!1),As=g.useCallback(()=>{!Ts.current&&!sr.current&&!rs.current&&F(null)},[]),Ar=()=>F(we=>we??on.map(vs)),Rr={onPointerEnter:()=>{Ts.current=!0,Ar()},onPointerLeave:()=>{Ts.current=!1,As()},onFocus:we=>{we.target.matches(":focus-visible")&&(sr.current=!0,Ar())},onBlur:we=>{we.currentTarget.contains(we.relatedTarget)||(sr.current=!1,As())}},Rs=oe!=null&&xn.some(we=>we.num===oe)||k!=null&&xn.some(we=>we.num===k.num);g.useEffect(()=>{rs.current=Rs,Rs||As()},[Rs,As]);const ya=D&&xn.length>0;g.useEffect(()=>{ya||(Ts.current=sr.current=rs.current=!1,F(null))},[ya]);const xt=g.useRef(!1);g.useEffect(()=>{xt.current&&xn.length===0&&Q(null),xt.current=xn.length>0},[xn.length,Q]);const wa=on.length?Vn.filter(we=>we.active):Vn,Ms=Jce(on,Gt,Me),xa=Qce(qe,De,Gt),rr=eue(I),ar=we=>D&&on.some(et=>et.num===we)?"ap-rest-list":"ap-scroll",Mr=(we,et="first")=>{he(we,et),v(null)},$s=(we,et)=>{pe(),v(pt=>(pt==null?void 0:pt.anchor)===et?null:{num:we,anchor:et})},hn=g.useCallback((we=!1)=>{var pt;const et=N.current;we&&et&&((pt=document.getElementById(et.anchor))==null||pt.focus()),v(null)},[]),Lt=()=>{pe(),v(null),m("lan")},fn=g.useRef(p);g.useEffect(()=>{fn.current!==p&&(fn.current=p,window.requestAnimationFrame(()=>{var we;(we=document.getElementById(p==="lan"?"ap-lan-back":"ap-lan-entry"))==null||we.focus()}))},[p]),g.useEffect(()=>{P!=null&&P.ok&&b(!0)},[P==null?void 0:P.ok]),g.useEffect(()=>{!a||!w||(Lt(),o==null||o())},[a,w]),g.useEffect(()=>{t&&(pe(),v(null))},[t,pe]),g.useEffect(()=>{de&&(P!=null&&P.accounts)&&!P.accounts.some(we=>we.num===de.num)&&pe(),k&&(P!=null&&P.accounts)&&!P.accounts.some(we=>we.num===k.num)&&v(null)},[P,de,k,pe]),g.useEffect(()=>{O==null||!(P!=null&&P.accounts)||P.accounts.some(we=>we.num===O.num)||(M(null),Q(null))},[P,O,Q]);const va=r.jsx("button",{type:"button",className:"glyph-btn",onClick:e,"aria-label":"Close accounts panel",title:_n("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 Ir;const et=X5(W,we),pt=oe===we.num,Et=(Z==null?void 0:Z.row)===we.num?Z:null,or=(ve==null?void 0:ve.num)===we.num,Lr=(re==null?void 0:re.at)===we.num?re:null,as=Lr?Vn.find(at=>at.num===Lr.displaced):void 0,fc=(k==null?void 0:k.anchor)===`ap-issue-${we.num}`;return r.jsx($oe,{a:we,nowSec:Gt,lan:Me(we),opened:et,onToggleLanes:()=>B(at=>Aae(at,we)),busy:l,pressProps:f,onSwitch:Ee,menuOpen:pt,onOpenMenu:Mr,onCloseMenu:Le,refusal:Et,onDismissRefusal:()=>Y(),onSignIn:Ie,switchedHere:or,swapped:Lr,displaced:as,issueExpanded:fc,onOpenIssue:$s,telemetryBoundaryId:ar(we.num),sortKey:we.active?null:Eae(vn),home:pw(we,(Ir=I==null?void 0:I.choice)==null?void 0:Ir.home)?Foe(we,!!(I!=null&&I.enabled)):null,rotating:!!(I!=null&&I.enabled||I!=null&&I.external)},we.num)},ba=P!=null&&P.ok&&(I!=null&&I.ok)?r.jsx(zoe,{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(Ioe,{canShare:(((Gn=P==null?void 0:P.accounts)==null?void 0:Gn.length)??0)>0,onAdd:()=>C(!0),onShareSet:()=>A(!0),onReload:()=>z(!0),pressProps:f,reloading:U,closeButton:va}),p==="accounts"&&r.jsxs("div",{className:"ap-scroll",id:"ap-scroll",children:[P==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 ",q6/1e3," seconds."]}),r.jsx("button",{type:"button",className:"ap-fix",...f("reload",U),onClick:()=>z(!0).then(()=>Q(null)),children:U?"trying…":"try again"})]}):r.jsx("div",{className:"ap-empty",children:"Checking…"}):P.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":(k==null?void 0:k.anchor)==="ap-notice","aria-controls":(k==null?void 0:k.anchor)==="ap-notice"?"ap-issue-pop":void 0,onClick:()=>$s(qe.num,"ap-notice"),children:[r.jsx(eS,{}),r.jsx("span",{className:"ap-issue-text",children:"Current account needs attention"})]}),Je.fix&&r.jsx("button",{type:"button",className:"ap-notice-fix",onClick:()=>C(!0),title:"Open the sign-in dialog. Signing in as this account replaces its stored login in place.",children:"Sign in"})]}),!qe&&P.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:P.unlistedLogin}),", which isn't in your accounts."]}),r.jsx("button",{type:"button",className:"ap-notice-fix",onClick:()=>C(!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:wa.map(go)}),on.length>0&&r.jsx(Gce,{peers:Ms,strained:xa,armed:rr,threshold:I!=null&&I.ok?De:null,open:D,onToggle:()=>K(we=>!we),order:vn,choices:Tr,onOrder:q,allOpen:Z5(W,on),onToggleAll:()=>B(we=>Rae(we,on)),held:T!=null}),on.length>0&&D&&r.jsxs("div",{className:"ap-rest-panel",id:"ap-rest-panel",children:[r.jsx("ul",{className:"ap-list ap-others",id:"ap-rest-list",...Rr,children:on.map(go)}),ba]}),on.length===0&&ba,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=P.accounts)==null?void 0:et.find(Et=>Et.num===de.num);return we?r.jsx(Mie,{a:we,accountMenu:le,slots:(P.accounts??[]).map(Et=>Et.num),boundaryId:ar(we.num),nowSec:Gt,busy:l,pressProps:f,onProjects:()=>{M({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:pw(we,(pt=I==null?void 0:I.choice)==null?void 0:pt.home),onHome:()=>{var Et;return je({action:"home",account:pw(we,(Et=I==null?void 0:I.choice)==null?void 0:Et.home)?null:we.num},`home-${we.num}`,"menu").then(or=>{z(!0),or!=null&&or.ok&&Le(we.num)})}}):null})(),k&&(()=>{var pt;const we=(pt=P.accounts)==null?void 0:pt.find(Et=>Et.num===k.num),et=we?xi(we,Gt,Me(we)):null;return!we||!et?null:r.jsx(dae,{anchorId:k.anchor,boundaryId:k.anchor==="ap-notice"?"ap-scroll":ar(we.num),issue:et,who:we.alias??we.email??`account ${we.num}`,fetchedAt:we.fetchedAt,nowSec:Gt,onClose:hn,onSignIn:()=>C(!0),onReport:n&&(()=>n({initialKind:et.tone==="warn"?"bug":"other",initialBody:`Account issue: ${et.text}. ${et.hint}`}))})})()]}):r.jsx(Loe,{data:P}),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?ss:""]}),w&&r.jsx(zce,{accounts:iR((P==null?void 0:P.accounts)??[]),onChanged:()=>z(!0),onNoCopy:Hn,onShared:Es,onElsewhere:zn,view:p==="lan",onOpen:Lt,onBack:()=>m("accounts"),closeButton:va}),x&&r.jsx(g6,{email:S,onClose:()=>{C(!1),_(null)},onChanged:()=>z(!0)}),$&&r.jsx(Zce,{accounts:((P==null?void 0:P.accounts)??[]).map(we=>({num:we.num,email:we.email,alias:we.alias,org:we.org})),onClose:()=>A(!1),copyText:ho}),O!=null&&(()=>{var et;const we=(et=P==null?void 0:P.accounts)==null?void 0:et.find(pt=>pt.num===O.num);return P!=null&&P.accounts&&!we?null:r.jsx(cae,{num:O.num,name:we?we.alias??we.email??`account ${we.num}`:O.name,onClose:()=>M(null)})})()]})}function OR(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`}function Eue(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:OR(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=aj(l,"seven_day",t),m=xi(l,t),w=jm(l.fetchedAt),b=w==null,k=n||b||l.stale||l.staleCopy===!0||l.stopped===!0||(m==null?void 0:m.blocksSwitch)===!0||t*1e3-w>J5,v=n?"Last saved reading":m!=null&&m.blocksSwitch||l.staleCopy||l.stopped?(m==null?void 0:m.text)??"Not collecting":b?"Never read":k?`${l.stale?"Marked stale · ":""}Read ${fa(w,t)}`:null,N={key:vs(l),name:Q5(l),active:l.active,heldOut:l.disabled,at:f,used:p.counted?p.pct:p.last,stale:k,note:v};if(f==null)i.push({...N,reason:"unknown"});else if(f<=t)i.push({...N,reason:"passed"});else{const x=o.get(OR(new Date(f*1e3)));x?(x.entries.push(N),k?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 Bf=e=>e.toLocaleDateString(void 0,{weekday:"short"}),Ep=e=>e.toLocaleDateString(void 0,{month:"short",day:"numeric"}),Ou=e=>e.toLocaleDateString(void 0,{weekday:"long",month:"long",day:"numeric",year:"numeric"}),mS=(e,t)=>e-t<60?"less than 1m":wd(e,t);function Em({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 qf({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 W6({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(qf,{entry:e}),o]}):s?r.jsxs("span",{className:"ap-reset-summary-content",children:[r.jsx(qf,{entry:e}),r.jsx(H6,{entry:e,older:a})]}):r.jsx(qf,{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 ${mS(h,n)}`," · ",r.jsx(Em,{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 H6({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 Tue({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(W6,{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:[Ep(new Date(e.at*1e3))," · ",r.jsx(Em,{at:e.at})]})]}),r.jsx(H6,{entry:e,past:e.reason==="passed"})]})})})}function PR({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:[Bf(a.date)," · ",Ep(a.date)]}),r.jsx(Em,{at:i}),!s&&r.jsxs("span",{children:["in ",mS(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(W6,{entry:u,row:t.get(u.key),nowSec:n,withReading:!0,older:s})},u.key))})]},i))})]},a.key):null})})}function Aue({accounts:e,nowSec:t,held:n,selectedDate:s=null,onSelect:a=()=>{},scope:o="upcoming",onScope:i=()=>{}}){const{days:l,unscheduled:u}=Eue(e,t,n!=null),h=l.find(O=>O.key===s)??null,f=h?[h]:l,p=l.reduce((O,M)=>O+M.scheduled,0),m=f.reduce((O,M)=>O+M.outdated,0),w=l.reduce((O,M)=>O+M.outdated,0),b=h?h.scheduled:p,k=l.flatMap(O=>O.entries).find(O=>!O.stale),v=k?l.flatMap(O=>O.entries).filter(O=>!O.stale&&O.at===k.at):[],N=g.useRef(null),x=g.useRef(null),C=g.useRef(null);g.useEffect(()=>{var M,W;const O=C.current;O&&!O.isConnected&&document.activeElement===document.body&&((W=(M=x.current)==null?void 0:M.querySelector('.ap-reset-coverage-link[aria-pressed="true"]'))==null||W.focus({preventScroll:!0}))});const S=()=>{N.current&&(N.current.scrollTop=0)},_=O=>{S(),a(null),i(O)},$=Intl.DateTimeFormat().resolvedOptions().timeZone,A=new Map(rS(e,t).rows.map(O=>[O.key,O]));return r.jsxs("div",{ref:x,onFocusCapture:O=>{C.current=O.target},className:"ap-proj-body ap-report-body ap-reset-body",role:"region","aria-label":"Weekly reset calendar",children:[n&&r.jsx("p",{className:"ap-report-held",children:n}),r.jsxs("div",{className:"ap-reset-overview",children:[r.jsxs("div",{className:"ap-reset-command",children:[r.jsx("section",{className:"ap-reset-next","aria-label":"Next weekly reset",children:k?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"ap-reset-next-identity",children:[r.jsxs("h3",{children:[r.jsx(RQ,{}),"Next reported reset ",r.jsx("span",{className:"ap-reset-global",children:"· all days"})]}),v.length>1?r.jsxs("span",{className:"ap-reset-name",children:[v.length," accounts"]}):r.jsxs("details",{className:"ap-reset-next-account",children:[r.jsxs("summary",{title:k.name,children:[r.jsx(qf,{entry:k}),r.jsx("span",{className:"vis-hidden",children:" · Full account name"})]}),r.jsx("p",{className:"ap-reset-full-name",children:k.name})]}),r.jsxs("p",{children:[Bf(new Date(k.at*1e3)),", ",Ep(new Date(k.at*1e3))," · ",r.jsx(Em,{at:k.at})]}),r.jsxs("p",{className:"ap-reset-next-note",children:["Reported time · recent reading",v.length>1?"s":k.used!=null?` · ${oo(k.used)}% weekly used`:""]})]}),r.jsxs("p",{className:"ap-reset-countdown",children:[r.jsx("strong",{children:mS(k.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:$})]}),r.jsx("ol",{className:"ap-reset-week",role:"list","aria-label":"Seven-day reset counts",children:l.map((O,M)=>r.jsx("li",{"data-today":M===0?"":void 0,children:r.jsxs("button",{type:"button",className:"ap-reset-day-button","aria-current":M===0?"date":void 0,"data-active":O.scheduled>0?"":void 0,"aria-pressed":(h==null?void 0:h.key)===O.key,"aria-label":`${Ou(O.date)}: ${O.scheduled} scheduled resets${O.outdated?`, ${O.outdated} readings need updating`:""}`,onClick:()=>{S(),i("upcoming"),a((h==null?void 0:h.key)===O.key?null:O.key)},children:[r.jsxs("time",{dateTime:O.key,title:Ou(O.date),children:[r.jsx("span",{className:"ap-reset-weekday",children:M===0?"Today":Bf(O.date)}),r.jsx("span",{className:"ap-reset-date",children:O.date.getDate()})]}),r.jsxs("span",{className:"ap-reset-count",children:[r.jsx("b",{children:O.scheduled||"—"}),r.jsxs("span",{children:[" ",O.scheduled===1?"reset":"resets"]})]})]})},O.key))})]})]}),r.jsxs("div",{ref: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?`${Bf(h.date)}, ${Ep(h.date)}`:"All upcoming resets"," ",r.jsx("span",{children:b})]}),r.jsx("button",{className:"btn",type:"button","aria-pressed":!h,onClick:()=>{S(),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."}),b>0?r.jsx(PR,{days:f,rows:A,nowSec:t}):r.jsx("p",{className:"ap-reset-empty",children:h?"No upcoming resets on this day. Choose another date or All days.":"The schedule updates with new account readings. No weekly recurrence is assumed."})]}),r.jsxs("section",{className:"ap-reset-disclosure",hidden:o!=="older","aria-label":"Accounts needing fresh readings",children:[r.jsxs("h3",{children:["Needs a fresh reading ",r.jsxs("span",{children:[m," ",m===1?"account":"accounts"," · excluded from counts"]})]}),r.jsx("p",{className:"ap-reset-explain",children:"These weekly schedules need a fresh reading. Other reset times may also contain stale readings. Last reported times and usage remain visible until updated."}),m>0?r.jsx(PR,{days:f,rows:A,nowSec:t,outdated:!0}):r.jsx("p",{className:"ap-reset-empty",children:"No older schedules in these seven days. Unknown or elapsed times are listed in Other reset times."})]}),r.jsxs("section",{className:"ap-reset-disclosure ap-reset-unplaced",hidden:o!=="other","aria-label":"Other reset times",children:[r.jsxs("h3",{children:["Other reset times ",r.jsxs("span",{children:[u.length," ",u.length===1?"account":"accounts"," · unknown, elapsed or later"]})]}),u.length>0?r.jsx("ul",{children:u.map(O=>r.jsx(Tue,{entry:O,row:A.get(O.key),nowSec:t},O.key))}):r.jsx("p",{className:"ap-reset-empty",children:"All reported reset times fall within the upcoming week."})]}),r.jsxs("details",{className:"ap-reset-about",children:[r.jsx("summary",{children:"How to read this schedule"}),r.jsxs("p",{className:"ap-reset-explain",children:["Counts are reported weekly account resets, not token amounts. Zero means no upcoming reset on that day, not zero usage. Held-out accounts still appear in the schedule. A timestamp passing does not confirm renewed capacity. Older readings are excluded from upcoming counts. Times use ",$,"; 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 z6(e){return e>=90?"hi":e>=70?"mid":void 0}const V6=(e,t,n)=>`${e} ${e===1?t:n}`;function DR(e){const t=e.more>0?`, and ${V6(e.more,"more account","more accounts")} in the same minute`:"";return`First: ${e.name} (${oo(e.pct)}% used)${t}`}function Rue({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}=Fae(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?wd(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":z6(o),"aria-hidden":!0,children:r.jsx("i",{style:{"--left":i/100}})}),u&&e.nextReset&&r.jsxs("p",{className:"ap-report-reset",title:DR(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:[". ",DR(e.nextReset)]})]}),a]})}function Mue({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":z6(e.pct),children:[oo(e.pct),"%"]})]})}function $ue({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=wd(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 Lue={ready:"Ready",limited:"Limited",exhausted:"Exhausted",stale:"Stale"};function Iue({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}),Lue[e.status]]}),Object.values(e.cells).some(t=>!t.counted&&t.reset)&&r.jsx("span",{className:"ap-report-state-note",children:"Awaiting read"})]})}function Oue({row:e,nowSec:t}){const n=Lae(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 Pue(){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 Due({accounts:e,nowSec:t,held:n,sort:s=null,onSort:a=()=>{}}){const o=rS(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 ",V6(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(Rue,{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(Mue,{cell:u.cells[f.id],label:f.label}),r.jsx($ue,{at:u.resets[f.id],nowSec:t,label:f.label})]},f.id)),r.jsx(Iue,{row:u}),r.jsx(Oue,{row:u,nowSec:t})]},u.num))})]})}),r.jsxs("details",{className:"ap-report-how",children:[r.jsxs("summary",{children:[r.jsx(Pue,{}),"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 Fue={accounts:"Account capacity",calendar:"Reset calendar"};function Bue({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,b]=g.useState(e??[]);g.useEffect(()=>{e!=null&&b(e)},[e]);const k=Bae(n,e==null,w.length>0),[v,N]=g.useState(null),x=sj(w,(v==null?void 0:v.order)??t),C=S=>{const _=rS(sj(w,t),s).rows;N({sort:S,order:Dae(_,S).map($=>$.key)})};return vt.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:S=>S.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:Fue[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:k??""}),o==="accounts"?r.jsx(Due,{accounts:x,nowSec:s,held:k,sort:(v==null?void 0:v.sort)??null,onSort:C}):r.jsx(Aue,{accounts:x,nowSec:s,held:k,selectedDate:p,onSelect:m,scope:h,onScope:f})]})}),document.body)}function que(e,t,n){const s=e.filter(o=>o.active);if(s.length===0)return e.map(vs);const a=e.filter(o=>!o.active);return[...s,...K5(a,Y5(t,a),o=>pS(o,n),n)].map(vs)}function Uue(){}function Wue({view:e,onClose:t}){const{data:n,failure:s}=U6(Uue),a=YN(),[o,i]=g.useState(null);return g.useEffect(()=>{o==null&&n&&i(que(n.accounts??[],B6(),a))},[n,o,a]),o==null&&s==null?null:r.jsx(Bue,{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 Hue({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 zue=16,Vue=120;function Gue(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 Kue(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 Yue(e,t){return Gue(e,t,zue)?"over":Kue(e,t)<=Vue?"near":"far"}function Xue(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 Zue(){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 k;const w=(k=i.current)==null?void 0:k.getBoundingClientRect(),b=Xue(m);return w&&b?Yue(b,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 b=w&&u(m)==="over";return t(!1),b},[u]);return{trashDragging:e,trashLabel:n,trashState:a,trashZoneRef:i,trashPhase:l,beginTrashDrag:h,trackTrashDrag:f,endTrashDrag:p}}const Jue=420;function Que(){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),Jue+80)})},[]);return g.useEffect(()=>()=>{n.current&&window.clearTimeout(n.current)},[]),{bubbling:e,endBubble:s,onBubble:a}}const gS=11;function G6(e=0){return gS+Math.min(0,e)}const K6=7.2,Y6=6.6,ede={width:104,height:48},FR={width:96,height:44},X6={width:220,height:103};function tde(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)?X6:{width:Math.max(160,t),height:Math.max(72,n)}}function jw(e,t,n){return e.width*t>=n.width&&e.height*t>=n.height}function nde(e,t,n=X6,s=gS){if(!Number.isFinite(t)||t<=0)return e??"detail";const a=s*t;return e==="detail"?a>=Y6?"detail":jw(n,t,FR)?"compact":"overview":a>=K6?"detail":e==="compact"?jw(n,t,FR)?"compact":"overview":jw(n,t,ede)?"compact":"overview"}function sde(e,t,n=gS){return e>=K6/n?e:Math.max(e,Math.min(t,Y6/n-.001))}const rde=.8,ade=1;function ode({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 b of e.current.agents.keys()){const k=t.current.get(b);k&&p.push(k)}const m=tde(p);return l.current={version:f,card:m},m},[]),h=g.useCallback(f=>{var m;const p=nde(i.current,f,u(),G6(UN[WN()]));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 ide=40,lde=120;function cde(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=ide){const h=t.now(),f=Math.max(a+u,h);if(f<=h){i(),o();return}l(f,h,u)},replay(u=lde){i(),s=t.now()+u,n=t.setTimeout(o,u)},flush(){i(),o()},cancel(){i()}}}const ude=6,dde="ccdeck-tabs";function hde(e){return e>=ude}function fde(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 pde({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 b=new EventSource("/events"),k=cde(t,{now:()=>Date.now(),setTimeout:(C,S)=>window.setTimeout(C,S),clearTimeout:C=>window.clearTimeout(C)});let v=!1;const N=typeof BroadcastChannel=="function"?fde(new BroadcastChannel(dde),Math.random().toString(36).slice(2),()=>v):null,x=window.setInterval(()=>{v||!N||N.ask(600).then(C=>{v||u(hde(C))})},3e3);return b.addEventListener("open",()=>{i(!0),f(!0)}),b.addEventListener("error",()=>{i(!1),w(null)}),b.addEventListener("open",()=>{v=!0,u(!1)}),b.addEventListener("error",()=>{v=!1}),b.addEventListener("replay-end",()=>{p.current=!1,k.flush(),w(Date.now())}),b.addEventListener("desktop-update",C=>a.current(C.data)),b.addEventListener("hook",C=>{var S;try{const _=JSON.parse(C.data);if(!n.accept(_))return;e.current=pP(e.current,_);const $=_.replay===!0||p.current||Date.now()-_.receivedAt>3e4;$?k.replay():k.live();const A=ote(_,$);A&&((S=s.current)==null||S.play(A))}catch{}}),()=>{b.close(),k.cancel(),window.clearInterval(x),N==null||N.leave()}},[t]),{live:o,tabCapped:l,everConnected:h,liveSince:m}}const mde=200,gde=5*6e4,yde=6,wde=2*6e4;function kf(e,t){if(t.size!==0)for(const n of Array.from(e.keys()))t.has(n)||e.delete(n)}function xde(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 vde(e){const t=new Set;for(const n of e)t.add(n.id),t.add(`group:${n.sessionId}`),n.kind==="root"&&t.add(yN(n.id));return t}function bde(e){const t=new Set;for(const n of e)t.add(n.id),n.kind==="root"&&t.add(yN(n.id));return t}function kde(e,t){let n=iG(e,t,aT);lG(e,t,aT)&&(n=!0);const s=[],a=o=>{s.push(o)};return rG(e,t,mde,gde,a)&&(n=!0),aG(e,t,yde,wde,a)&&(n=!0),{changed:n,forgotten:s}}function jde(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 Nde(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=>jde(m,h,f)),!f&&p&&t(!0)},[]),l=g.useCallback(()=>{s({ids:new Set,primary:null})},[]),u=g.useCallback(()=>{s(h=>{const f=xde(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 Sde({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}=kde(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 yS(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 Nw,BR;function Cde(){if(BR)return Nw;BR=1;function e(){this.__data__=[],this.size=0}return Nw=e,Nw}var Sw,qR;function lc(){if(qR)return Sw;qR=1;function e(t,n){return t===n||t!==t&&n!==n}return Sw=e,Sw}var Cw,UR;function Tm(){if(UR)return Cw;UR=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 Cw=t,Cw}var _w,WR;function _de(){if(WR)return _w;WR=1;var e=Tm(),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 _w=s,_w}var Ew,HR;function Ede(){if(HR)return Ew;HR=1;var e=Tm();function t(n){var s=this.__data__,a=e(s,n);return a<0?void 0:s[a][1]}return Ew=t,Ew}var Tw,zR;function Tde(){if(zR)return Tw;zR=1;var e=Tm();function t(n){return e(this.__data__,n)>-1}return Tw=t,Tw}var Aw,VR;function Ade(){if(VR)return Aw;VR=1;var e=Tm();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 Aw=t,Aw}var Rw,GR;function Am(){if(GR)return Rw;GR=1;var e=Cde(),t=_de(),n=Ede(),s=Tde(),a=Ade();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,Rw=o,Rw}var Mw,KR;function Rde(){if(KR)return Mw;KR=1;var e=Am();function t(){this.__data__=new e,this.size=0}return Mw=t,Mw}var $w,YR;function Mde(){if(YR)return $w;YR=1;function e(t){var n=this.__data__,s=n.delete(t);return this.size=n.size,s}return $w=e,$w}var Lw,XR;function $de(){if(XR)return Lw;XR=1;function e(t){return this.__data__.get(t)}return Lw=e,Lw}var Iw,ZR;function Lde(){if(ZR)return Iw;ZR=1;function e(t){return this.__data__.has(t)}return Iw=e,Iw}var Ow,JR;function Z6(){if(JR)return Ow;JR=1;var e=typeof Uh=="object"&&Uh&&Uh.Object===Object&&Uh;return Ow=e,Ow}var Pw,QR;function tr(){if(QR)return Pw;QR=1;var e=Z6(),t=typeof self=="object"&&self&&self.Object===Object&&self,n=e||t||Function("return this")();return Pw=n,Pw}var Dw,e2;function cc(){if(e2)return Dw;e2=1;var e=tr(),t=e.Symbol;return Dw=t,Dw}var Fw,t2;function Ide(){if(t2)return Fw;t2=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 Fw=o,Fw}var Bw,n2;function Ode(){if(n2)return Bw;n2=1;var e=Object.prototype,t=e.toString;function n(s){return t.call(s)}return Bw=n,Bw}var qw,s2;function ji(){if(s2)return qw;s2=1;var e=cc(),t=Ide(),n=Ode(),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 qw=i,qw}var Uw,r2;function Ss(){if(r2)return Uw;r2=1;function e(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}return Uw=e,Uw}var Ww,a2;function Nd(){if(a2)return Ww;a2=1;var e=ji(),t=Ss(),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 Ww=i,Ww}var Hw,o2;function Pde(){if(o2)return Hw;o2=1;var e=tr(),t=e["__core-js_shared__"];return Hw=t,Hw}var zw,i2;function Dde(){if(i2)return zw;i2=1;var e=Pde(),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 zw=n,zw}var Vw,l2;function J6(){if(l2)return Vw;l2=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 Vw=n,Vw}var Gw,c2;function Fde(){if(c2)return Gw;c2=1;var e=Nd(),t=Dde(),n=Ss(),s=J6(),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 Gw=p,Gw}var Kw,u2;function Bde(){if(u2)return Kw;u2=1;function e(t,n){return t==null?void 0:t[n]}return Kw=e,Kw}var Yw,d2;function Ni(){if(d2)return Yw;d2=1;var e=Fde(),t=Bde();function n(s,a){var o=t(s,a);return e(o)?o:void 0}return Yw=n,Yw}var Xw,h2;function wS(){if(h2)return Xw;h2=1;var e=Ni(),t=tr(),n=e(t,"Map");return Xw=n,Xw}var Zw,f2;function Rm(){if(f2)return Zw;f2=1;var e=Ni(),t=e(Object,"create");return Zw=t,Zw}var Jw,p2;function qde(){if(p2)return Jw;p2=1;var e=Rm();function t(){this.__data__=e?e(null):{},this.size=0}return Jw=t,Jw}var Qw,m2;function Ude(){if(m2)return Qw;m2=1;function e(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n}return Qw=e,Qw}var ex,g2;function Wde(){if(g2)return ex;g2=1;var e=Rm(),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 ex=a,ex}var tx,y2;function Hde(){if(y2)return tx;y2=1;var e=Rm(),t=Object.prototype,n=t.hasOwnProperty;function s(a){var o=this.__data__;return e?o[a]!==void 0:n.call(o,a)}return tx=s,tx}var nx,w2;function zde(){if(w2)return nx;w2=1;var e=Rm(),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 nx=n,nx}var sx,x2;function Vde(){if(x2)return sx;x2=1;var e=qde(),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,sx=o,sx}var rx,v2;function Gde(){if(v2)return rx;v2=1;var e=Vde(),t=Am(),n=wS();function s(){this.size=0,this.__data__={hash:new e,map:new(n||t),string:new e}}return rx=s,rx}var ax,b2;function Kde(){if(b2)return ax;b2=1;function e(t){var n=typeof t;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?t!=="__proto__":t===null}return ax=e,ax}var ox,k2;function Mm(){if(k2)return ox;k2=1;var e=Kde();function t(n,s){var a=n.__data__;return e(s)?a[typeof s=="string"?"string":"hash"]:a.map}return ox=t,ox}var ix,j2;function Yde(){if(j2)return ix;j2=1;var e=Mm();function t(n){var s=e(this,n).delete(n);return this.size-=s?1:0,s}return ix=t,ix}var lx,N2;function Xde(){if(N2)return lx;N2=1;var e=Mm();function t(n){return e(this,n).get(n)}return lx=t,lx}var cx,S2;function Zde(){if(S2)return cx;S2=1;var e=Mm();function t(n){return e(this,n).has(n)}return cx=t,cx}var ux,C2;function Jde(){if(C2)return ux;C2=1;var e=Mm();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 ux=t,ux}var dx,_2;function xS(){if(_2)return dx;_2=1;var e=Gde(),t=Yde(),n=Xde(),s=Zde(),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,dx=o,dx}var hx,E2;function Qde(){if(E2)return hx;E2=1;var e=Am(),t=wS(),n=xS(),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 hx=a,hx}var fx,T2;function $m(){if(T2)return fx;T2=1;var e=Am(),t=Rde(),n=Mde(),s=$de(),a=Lde(),o=Qde();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,fx=i,fx}var px,A2;function vS(){if(A2)return px;A2=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 px=e,px}var mx,R2;function Q6(){if(R2)return mx;R2=1;var e=Ni(),t=(function(){try{var n=e(Object,"defineProperty");return n({},"",{}),n}catch{}})();return mx=t,mx}var gx,M2;function Lm(){if(M2)return gx;M2=1;var e=Q6();function t(n,s,a){s=="__proto__"&&e?e(n,s,{configurable:!0,enumerable:!0,value:a,writable:!0}):n[s]=a}return gx=t,gx}var yx,$2;function Im(){if($2)return yx;$2=1;var e=Lm(),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 yx=a,yx}var wx,L2;function Sd(){if(L2)return wx;L2=1;var e=Im(),t=Lm();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 wx=n,wx}var xx,I2;function ehe(){if(I2)return xx;I2=1;function e(t,n){for(var s=-1,a=Array(t);++s<t;)a[s]=n(s);return a}return xx=e,xx}var vx,O2;function Er(){if(O2)return vx;O2=1;function e(t){return t!=null&&typeof t=="object"}return vx=e,vx}var bx,P2;function the(){if(P2)return bx;P2=1;var e=ji(),t=Er(),n="[object Arguments]";function s(a){return t(a)&&e(a)==n}return bx=s,bx}var kx,D2;function Cd(){if(D2)return kx;D2=1;var e=the(),t=Er(),n=Object.prototype,s=n.hasOwnProperty,a=n.propertyIsEnumerable,o=e((function(){return arguments})())?e:function(i){return t(i)&&s.call(i,"callee")&&!a.call(i,"callee")};return kx=o,kx}var jx,F2;function Vt(){if(F2)return jx;F2=1;var e=Array.isArray;return jx=e,jx}var ju={exports:{}},Nx,B2;function nhe(){if(B2)return Nx;B2=1;function e(){return!1}return Nx=e,Nx}ju.exports;var q2;function uc(){return q2||(q2=1,(function(e,t){var n=tr(),s=nhe(),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 Sx,U2;function Om(){if(U2)return Sx;U2=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 Sx=n,Sx}var Cx,W2;function bS(){if(W2)return Cx;W2=1;var e=9007199254740991;function t(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=e}return Cx=t,Cx}var _x,H2;function she(){if(H2)return _x;H2=1;var e=ji(),t=bS(),n=Er(),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]",b="[object String]",k="[object WeakMap]",v="[object ArrayBuffer]",N="[object DataView]",x="[object Float32Array]",C="[object Float64Array]",S="[object Int8Array]",_="[object Int16Array]",$="[object Int32Array]",A="[object Uint8Array]",O="[object Uint8ClampedArray]",M="[object Uint16Array]",W="[object Uint32Array]",B={};B[x]=B[C]=B[S]=B[_]=B[$]=B[A]=B[O]=B[M]=B[W]=!0,B[s]=B[a]=B[v]=B[o]=B[N]=B[i]=B[l]=B[u]=B[h]=B[f]=B[p]=B[m]=B[w]=B[b]=B[k]=!1;function R(q){return n(q)&&t(q.length)&&!!B[e(q)]}return _x=R,_x}var Ex,z2;function Pm(){if(z2)return Ex;z2=1;function e(t){return function(n){return t(n)}}return Ex=e,Ex}var Nu={exports:{}};Nu.exports;var V2;function kS(){return V2||(V2=1,(function(e,t){var n=Z6(),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 Tx,G2;function _d(){if(G2)return Tx;G2=1;var e=she(),t=Pm(),n=kS(),s=n&&n.isTypedArray,a=s?t(s):e;return Tx=a,Tx}var Ax,K2;function eF(){if(K2)return Ax;K2=1;var e=ehe(),t=Cd(),n=Vt(),s=uc(),a=Om(),o=_d(),i=Object.prototype,l=i.hasOwnProperty;function u(h,f){var p=n(h),m=!p&&t(h),w=!p&&!m&&s(h),b=!p&&!m&&!w&&o(h),k=p||m||w||b,v=k?e(h.length,String):[],N=v.length;for(var x in h)(f||l.call(h,x))&&!(k&&(x=="length"||w&&(x=="offset"||x=="parent")||b&&(x=="buffer"||x=="byteLength"||x=="byteOffset")||a(x,N)))&&v.push(x);return v}return Ax=u,Ax}var Rx,Y2;function Dm(){if(Y2)return Rx;Y2=1;var e=Object.prototype;function t(n){var s=n&&n.constructor,a=typeof s=="function"&&s.prototype||e;return n===a}return Rx=t,Rx}var Mx,X2;function tF(){if(X2)return Mx;X2=1;function e(t,n){return function(s){return t(n(s))}}return Mx=e,Mx}var $x,Z2;function rhe(){if(Z2)return $x;Z2=1;var e=tF(),t=e(Object.keys,Object);return $x=t,$x}var Lx,J2;function jS(){if(J2)return Lx;J2=1;var e=Dm(),t=rhe(),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 Lx=a,Lx}var Ix,Q2;function ma(){if(Q2)return Ix;Q2=1;var e=Nd(),t=bS();function n(s){return s!=null&&t(s.length)&&!e(s)}return Ix=n,Ix}var Ox,eM;function mo(){if(eM)return Ox;eM=1;var e=eF(),t=jS(),n=ma();function s(a){return n(a)?e(a):t(a)}return Ox=s,Ox}var Px,tM;function ahe(){if(tM)return Px;tM=1;var e=Sd(),t=mo();function n(s,a){return s&&e(a,t(a),s)}return Px=n,Px}var Dx,nM;function ohe(){if(nM)return Dx;nM=1;function e(t){var n=[];if(t!=null)for(var s in Object(t))n.push(s);return n}return Dx=e,Dx}var Fx,sM;function ihe(){if(sM)return Fx;sM=1;var e=Ss(),t=Dm(),n=ohe(),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 Fx=o,Fx}var Bx,rM;function Si(){if(rM)return Bx;rM=1;var e=eF(),t=ihe(),n=ma();function s(a){return n(a)?e(a,!0):t(a)}return Bx=s,Bx}var qx,aM;function lhe(){if(aM)return qx;aM=1;var e=Sd(),t=Si();function n(s,a){return s&&e(a,t(a),s)}return qx=n,qx}var Su={exports:{}};Su.exports;var oM;function nF(){return oM||(oM=1,(function(e,t){var n=tr(),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 Ux,iM;function sF(){if(iM)return Ux;iM=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 Ux=e,Ux}var Wx,lM;function rF(){if(lM)return Wx;lM=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 Wx=e,Wx}var Hx,cM;function aF(){if(cM)return Hx;cM=1;function e(){return[]}return Hx=e,Hx}var zx,uM;function NS(){if(uM)return zx;uM=1;var e=rF(),t=aF(),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 zx=o,zx}var Vx,dM;function che(){if(dM)return Vx;dM=1;var e=Sd(),t=NS();function n(s,a){return e(s,t(s),a)}return Vx=n,Vx}var Gx,hM;function SS(){if(hM)return Gx;hM=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 Gx=e,Gx}var Kx,fM;function Fm(){if(fM)return Kx;fM=1;var e=tF(),t=e(Object.getPrototypeOf,Object);return Kx=t,Kx}var Yx,pM;function oF(){if(pM)return Yx;pM=1;var e=SS(),t=Fm(),n=NS(),s=aF(),a=Object.getOwnPropertySymbols,o=a?function(i){for(var l=[];i;)e(l,n(i)),i=t(i);return l}:s;return Yx=o,Yx}var Xx,mM;function uhe(){if(mM)return Xx;mM=1;var e=Sd(),t=oF();function n(s,a){return e(s,t(s),a)}return Xx=n,Xx}var Zx,gM;function iF(){if(gM)return Zx;gM=1;var e=SS(),t=Vt();function n(s,a,o){var i=a(s);return t(s)?i:e(i,o(s))}return Zx=n,Zx}var Jx,yM;function lF(){if(yM)return Jx;yM=1;var e=iF(),t=NS(),n=mo();function s(a){return e(a,n,t)}return Jx=s,Jx}var Qx,wM;function dhe(){if(wM)return Qx;wM=1;var e=iF(),t=oF(),n=Si();function s(a){return e(a,n,t)}return Qx=s,Qx}var ev,xM;function hhe(){if(xM)return ev;xM=1;var e=Ni(),t=tr(),n=e(t,"DataView");return ev=n,ev}var tv,vM;function fhe(){if(vM)return tv;vM=1;var e=Ni(),t=tr(),n=e(t,"Promise");return tv=n,tv}var nv,bM;function cF(){if(bM)return nv;bM=1;var e=Ni(),t=tr(),n=e(t,"Set");return nv=n,nv}var sv,kM;function phe(){if(kM)return sv;kM=1;var e=Ni(),t=tr(),n=e(t,"WeakMap");return sv=n,sv}var rv,jM;function dc(){if(jM)return rv;jM=1;var e=hhe(),t=wS(),n=fhe(),s=cF(),a=phe(),o=ji(),i=J6(),l="[object Map]",u="[object Object]",h="[object Promise]",f="[object Set]",p="[object WeakMap]",m="[object DataView]",w=i(e),b=i(t),k=i(n),v=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(C){var S=o(C),_=S==u?C.constructor:void 0,$=_?i(_):"";if($)switch($){case w:return m;case b:return l;case k:return h;case v:return f;case N:return p}return S}),rv=x,rv}var av,NM;function mhe(){if(NM)return av;NM=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 av=n,av}var ov,SM;function uF(){if(SM)return ov;SM=1;var e=tr(),t=e.Uint8Array;return ov=t,ov}var iv,CM;function CS(){if(CM)return iv;CM=1;var e=uF();function t(n){var s=new n.constructor(n.byteLength);return new e(s).set(new e(n)),s}return iv=t,iv}var lv,_M;function ghe(){if(_M)return lv;_M=1;var e=CS();function t(n,s){var a=s?e(n.buffer):n.buffer;return new n.constructor(a,n.byteOffset,n.byteLength)}return lv=t,lv}var cv,EM;function yhe(){if(EM)return cv;EM=1;var e=/\w*$/;function t(n){var s=new n.constructor(n.source,e.exec(n));return s.lastIndex=n.lastIndex,s}return cv=t,cv}var uv,TM;function whe(){if(TM)return uv;TM=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 uv=s,uv}var dv,AM;function dF(){if(AM)return dv;AM=1;var e=CS();function t(n,s){var a=s?e(n.buffer):n.buffer;return new n.constructor(a,n.byteOffset,n.length)}return dv=t,dv}var hv,RM;function xhe(){if(RM)return hv;RM=1;var e=CS(),t=ghe(),n=yhe(),s=whe(),a=dF(),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]",b="[object DataView]",k="[object Float32Array]",v="[object Float64Array]",N="[object Int8Array]",x="[object Int16Array]",C="[object Int32Array]",S="[object Uint8Array]",_="[object Uint8ClampedArray]",$="[object Uint16Array]",A="[object Uint32Array]";function O(M,W,B){var R=M.constructor;switch(W){case w:return e(M);case o:case i:return new R(+M);case b:return t(M,B);case k:case v:case N:case x:case C:case S:case _:case $:case A:return a(M,B);case l:return new R;case u:case p:return new R(M);case h:return n(M);case f:return new R;case m:return s(M)}}return hv=O,hv}var fv,MM;function hF(){if(MM)return fv;MM=1;var e=Ss(),t=Object.create,n=(function(){function s(){}return function(a){if(!e(a))return{};if(t)return t(a);s.prototype=a;var o=new s;return s.prototype=void 0,o}})();return fv=n,fv}var pv,$M;function fF(){if($M)return pv;$M=1;var e=hF(),t=Fm(),n=Dm();function s(a){return typeof a.constructor=="function"&&!n(a)?e(t(a)):{}}return pv=s,pv}var mv,LM;function vhe(){if(LM)return mv;LM=1;var e=dc(),t=Er(),n="[object Map]";function s(a){return t(a)&&e(a)==n}return mv=s,mv}var gv,IM;function bhe(){if(IM)return gv;IM=1;var e=vhe(),t=Pm(),n=kS(),s=n&&n.isMap,a=s?t(s):e;return gv=a,gv}var yv,OM;function khe(){if(OM)return yv;OM=1;var e=dc(),t=Er(),n="[object Set]";function s(a){return t(a)&&e(a)==n}return yv=s,yv}var wv,PM;function jhe(){if(PM)return wv;PM=1;var e=khe(),t=Pm(),n=kS(),s=n&&n.isSet,a=s?t(s):e;return wv=a,wv}var xv,DM;function pF(){if(DM)return xv;DM=1;var e=$m(),t=vS(),n=Im(),s=ahe(),a=lhe(),o=nF(),i=sF(),l=che(),u=uhe(),h=lF(),f=dhe(),p=dc(),m=mhe(),w=xhe(),b=fF(),k=Vt(),v=uc(),N=bhe(),x=Ss(),C=jhe(),S=mo(),_=Si(),$=1,A=2,O=4,M="[object Arguments]",W="[object Array]",B="[object Boolean]",R="[object Date]",q="[object Error]",T="[object Function]",F="[object GeneratorFunction]",D="[object Map]",K="[object Number]",V="[object Object]",H="[object RegExp]",P="[object Set]",I="[object String]",U="[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[M]=pe[W]=pe[z]=pe[X]=pe[B]=pe[R]=pe[Y]=pe[J]=pe[Q]=pe[te]=pe[le]=pe[D]=pe[K]=pe[V]=pe[H]=pe[P]=pe[I]=pe[U]=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&$,Ke=ve&A,ye=ve&O;if(je&&(De=xe?je(ge,Ee,xe,Ie):je(ge)),De!==void 0)return De;if(!x(ge))return ge;var Fe=k(ge);if(Fe){if(De=m(ge),!We)return i(ge,De)}else{var $e=p(ge),Re=$e==T||$e==F;if(v(ge))return o(ge,We);if($e==V||$e==M||Re&&!xe){if(De=Ke||Re?{}:b(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),C(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?_:S,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 xv=Le,xv}var vv,FM;function Nhe(){if(FM)return vv;FM=1;var e=pF(),t=4;function n(s){return e(s,t)}return vv=n,vv}var bv,BM;function _S(){if(BM)return bv;BM=1;function e(t){return function(){return t}}return bv=e,bv}var kv,qM;function She(){if(qM)return kv;qM=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 kv=e,kv}var jv,UM;function ES(){if(UM)return jv;UM=1;var e=She(),t=e();return jv=t,jv}var Nv,WM;function TS(){if(WM)return Nv;WM=1;var e=ES(),t=mo();function n(s,a){return s&&e(s,a,t)}return Nv=n,Nv}var Sv,HM;function Che(){if(HM)return Sv;HM=1;var e=ma();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 Sv=t,Sv}var Cv,zM;function Bm(){if(zM)return Cv;zM=1;var e=TS(),t=Che(),n=t(e);return Cv=n,Cv}var _v,VM;function Ci(){if(VM)return _v;VM=1;function e(t){return t}return _v=e,_v}var Ev,GM;function mF(){if(GM)return Ev;GM=1;var e=Ci();function t(n){return typeof n=="function"?n:e}return Ev=t,Ev}var Tv,KM;function gF(){if(KM)return Tv;KM=1;var e=vS(),t=Bm(),n=mF(),s=Vt();function a(o,i){var l=s(o)?e:t;return l(o,n(i))}return Tv=a,Tv}var Av,YM;function yF(){return YM||(YM=1,Av=gF()),Av}var Rv,XM;function _he(){if(XM)return Rv;XM=1;var e=Bm();function t(n,s){var a=[];return e(n,function(o,i,l){s(o,i,l)&&a.push(o)}),a}return Rv=t,Rv}var Mv,ZM;function Ehe(){if(ZM)return Mv;ZM=1;var e="__lodash_hash_undefined__";function t(n){return this.__data__.set(n,e),this}return Mv=t,Mv}var $v,JM;function The(){if(JM)return $v;JM=1;function e(t){return this.__data__.has(t)}return $v=e,$v}var Lv,QM;function wF(){if(QM)return Lv;QM=1;var e=xS(),t=Ehe(),n=The();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,Lv=s,Lv}var Iv,e$;function Ahe(){if(e$)return Iv;e$=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 Iv=e,Iv}var Ov,t$;function xF(){if(t$)return Ov;t$=1;function e(t,n){return t.has(n)}return Ov=e,Ov}var Pv,n$;function vF(){if(n$)return Pv;n$=1;var e=wF(),t=Ahe(),n=xF(),s=1,a=2;function o(i,l,u,h,f,p){var m=u&s,w=i.length,b=l.length;if(w!=b&&!(m&&b>w))return!1;var k=p.get(i),v=p.get(l);if(k&&v)return k==l&&v==i;var N=-1,x=!0,C=u&a?new e:void 0;for(p.set(i,l),p.set(l,i);++N<w;){var S=i[N],_=l[N];if(h)var $=m?h(_,S,N,l,i,p):h(S,_,N,i,l,p);if($!==void 0){if($)continue;x=!1;break}if(C){if(!t(l,function(A,O){if(!n(C,O)&&(S===A||f(S,A,u,h,p)))return C.push(O)})){x=!1;break}}else if(!(S===_||f(S,_,u,h,p))){x=!1;break}}return p.delete(i),p.delete(l),x}return Pv=o,Pv}var Dv,s$;function Rhe(){if(s$)return Dv;s$=1;function e(t){var n=-1,s=Array(t.size);return t.forEach(function(a,o){s[++n]=[o,a]}),s}return Dv=e,Dv}var Fv,r$;function AS(){if(r$)return Fv;r$=1;function e(t){var n=-1,s=Array(t.size);return t.forEach(function(a){s[++n]=a}),s}return Fv=e,Fv}var Bv,a$;function Mhe(){if(a$)return Bv;a$=1;var e=cc(),t=uF(),n=lc(),s=vF(),a=Rhe(),o=AS(),i=1,l=2,u="[object Boolean]",h="[object Date]",f="[object Error]",p="[object Map]",m="[object Number]",w="[object RegExp]",b="[object Set]",k="[object String]",v="[object Symbol]",N="[object ArrayBuffer]",x="[object DataView]",C=e?e.prototype:void 0,S=C?C.valueOf:void 0;function _($,A,O,M,W,B,R){switch(O){case x:if($.byteLength!=A.byteLength||$.byteOffset!=A.byteOffset)return!1;$=$.buffer,A=A.buffer;case N:return!($.byteLength!=A.byteLength||!B(new t($),new t(A)));case u:case h:case m:return n(+$,+A);case f:return $.name==A.name&&$.message==A.message;case w:case k:return $==A+"";case p:var q=a;case b:var T=M&i;if(q||(q=o),$.size!=A.size&&!T)return!1;var F=R.get($);if(F)return F==A;M|=l,R.set($,A);var D=s(q($),q(A),M,W,B,R);return R.delete($),D;case v:if(S)return S.call($)==S.call(A)}return!1}return Bv=_,Bv}var qv,o$;function $he(){if(o$)return qv;o$=1;var e=lF(),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,b=e(i),k=b.length;if(w!=k&&!p)return!1;for(var v=w;v--;){var N=m[v];if(!(p?N in i:s.call(i,N)))return!1}var x=f.get(o),C=f.get(i);if(x&&C)return x==i&&C==o;var S=!0;f.set(o,i),f.set(i,o);for(var _=p;++v<w;){N=m[v];var $=o[N],A=i[N];if(u)var O=p?u(A,$,N,i,o,f):u($,A,N,o,i,f);if(!(O===void 0?$===A||h($,A,l,u,f):O)){S=!1;break}_||(_=N=="constructor")}if(S&&!_){var M=o.constructor,W=i.constructor;M!=W&&"constructor"in o&&"constructor"in i&&!(typeof M=="function"&&M instanceof M&&typeof W=="function"&&W instanceof W)&&(S=!1)}return f.delete(o),f.delete(i),S}return qv=a,qv}var Uv,i$;function Lhe(){if(i$)return Uv;i$=1;var e=$m(),t=vF(),n=Mhe(),s=$he(),a=dc(),o=Vt(),i=uc(),l=_d(),u=1,h="[object Arguments]",f="[object Array]",p="[object Object]",m=Object.prototype,w=m.hasOwnProperty;function b(k,v,N,x,C,S){var _=o(k),$=o(v),A=_?f:a(k),O=$?f:a(v);A=A==h?p:A,O=O==h?p:O;var M=A==p,W=O==p,B=A==O;if(B&&i(k)){if(!i(v))return!1;_=!0,M=!1}if(B&&!M)return S||(S=new e),_||l(k)?t(k,v,N,x,C,S):n(k,v,A,N,x,C,S);if(!(N&u)){var R=M&&w.call(k,"__wrapped__"),q=W&&w.call(v,"__wrapped__");if(R||q){var T=R?k.value():k,F=q?v.value():v;return S||(S=new e),C(T,F,N,x,S)}}return B?(S||(S=new e),s(k,v,N,x,C,S)):!1}return Uv=b,Uv}var Wv,l$;function bF(){if(l$)return Wv;l$=1;var e=Lhe(),t=Er();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 Wv=n,Wv}var Hv,c$;function Ihe(){if(c$)return Hv;c$=1;var e=$m(),t=bF(),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],b=o[w],k=m[1];if(p&&m[2]){if(b===void 0&&!(w in o))return!1}else{var v=new e;if(u)var N=u(b,k,w,o,i,v);if(!(N===void 0?t(k,b,n|s,u,v):N))return!1}}return!0}return Hv=a,Hv}var zv,u$;function kF(){if(u$)return zv;u$=1;var e=Ss();function t(n){return n===n&&!e(n)}return zv=t,zv}var Vv,d$;function Ohe(){if(d$)return Vv;d$=1;var e=kF(),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 Vv=n,Vv}var Gv,h$;function jF(){if(h$)return Gv;h$=1;function e(t,n){return function(s){return s==null?!1:s[t]===n&&(n!==void 0||t in Object(s))}}return Gv=e,Gv}var Kv,f$;function Phe(){if(f$)return Kv;f$=1;var e=Ihe(),t=Ohe(),n=jF();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 Kv=s,Kv}var Yv,p$;function hc(){if(p$)return Yv;p$=1;var e=ji(),t=Er(),n="[object Symbol]";function s(a){return typeof a=="symbol"||t(a)&&e(a)==n}return Yv=s,Yv}var Xv,m$;function RS(){if(m$)return Xv;m$=1;var e=Vt(),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 Xv=a,Xv}var Zv,g$;function Dhe(){if(g$)return Zv;g$=1;var e=xS(),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,Zv=n,Zv}var Jv,y$;function Fhe(){if(y$)return Jv;y$=1;var e=Dhe(),t=500;function n(s){var a=e(s,function(i){return o.size===t&&o.clear(),i}),o=a.cache;return a}return Jv=n,Jv}var Qv,w$;function Bhe(){if(w$)return Qv;w$=1;var e=Fhe(),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 Qv=s,Qv}var eb,x$;function qm(){if(x$)return eb;x$=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 eb=e,eb}var tb,v$;function qhe(){if(v$)return tb;v$=1;var e=cc(),t=qm(),n=Vt(),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 tb=i,tb}var nb,b$;function NF(){if(b$)return nb;b$=1;var e=qhe();function t(n){return n==null?"":e(n)}return nb=t,nb}var sb,k$;function Um(){if(k$)return sb;k$=1;var e=Vt(),t=RS(),n=Bhe(),s=NF();function a(o,i){return e(o)?o:t(o,i)?[o]:n(s(o))}return sb=a,sb}var rb,j$;function Ed(){if(j$)return rb;j$=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 rb=t,rb}var ab,N$;function Wm(){if(N$)return ab;N$=1;var e=Um(),t=Ed();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 ab=n,ab}var ob,S$;function Uhe(){if(S$)return ob;S$=1;var e=Wm();function t(n,s,a){var o=n==null?void 0:e(n,s);return o===void 0?a:o}return ob=t,ob}var ib,C$;function Whe(){if(C$)return ib;C$=1;function e(t,n){return t!=null&&n in Object(t)}return ib=e,ib}var lb,_$;function SF(){if(_$)return lb;_$=1;var e=Um(),t=Cd(),n=Vt(),s=Om(),a=bS(),o=Ed();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 lb=i,lb}var cb,E$;function CF(){if(E$)return cb;E$=1;var e=Whe(),t=SF();function n(s,a){return s!=null&&t(s,a,e)}return cb=n,cb}var ub,T$;function Hhe(){if(T$)return ub;T$=1;var e=bF(),t=Uhe(),n=CF(),s=RS(),a=kF(),o=jF(),i=Ed(),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 ub=h,ub}var db,A$;function _F(){if(A$)return db;A$=1;function e(t){return function(n){return n==null?void 0:n[t]}}return db=e,db}var hb,R$;function zhe(){if(R$)return hb;R$=1;var e=Wm();function t(n){return function(s){return e(s,n)}}return hb=t,hb}var fb,M$;function Vhe(){if(M$)return fb;M$=1;var e=_F(),t=zhe(),n=RS(),s=Ed();function a(o){return n(o)?e(s(o)):t(o)}return fb=a,fb}var pb,$$;function ga(){if($$)return pb;$$=1;var e=Phe(),t=Hhe(),n=Ci(),s=Vt(),a=Vhe();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 pb=o,pb}var mb,L$;function EF(){if(L$)return mb;L$=1;var e=rF(),t=_he(),n=ga(),s=Vt();function a(o,i){var l=s(o)?e:t;return l(o,n(i,3))}return mb=a,mb}var gb,I$;function Ghe(){if(I$)return gb;I$=1;var e=Object.prototype,t=e.hasOwnProperty;function n(s,a){return s!=null&&t.call(s,a)}return gb=n,gb}var yb,O$;function TF(){if(O$)return yb;O$=1;var e=Ghe(),t=SF();function n(s,a){return s!=null&&t(s,a,e)}return yb=n,yb}var wb,P$;function Khe(){if(P$)return wb;P$=1;var e=jS(),t=dc(),n=Cd(),s=Vt(),a=ma(),o=uc(),i=Dm(),l=_d(),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 b=t(w);if(b==u||b==h)return!w.size;if(i(w))return!e(w).length;for(var k in w)if(p.call(w,k))return!1;return!0}return wb=m,wb}var xb,D$;function AF(){if(D$)return xb;D$=1;function e(t){return t===void 0}return xb=e,xb}var vb,F$;function RF(){if(F$)return vb;F$=1;var e=Bm(),t=ma();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 vb=n,vb}var bb,B$;function MF(){if(B$)return bb;B$=1;var e=qm(),t=ga(),n=RF(),s=Vt();function a(o,i){var l=s(o)?e:n;return l(o,t(i,3))}return bb=a,bb}var kb,q$;function Yhe(){if(q$)return kb;q$=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 kb=e,kb}var jb,U$;function Xhe(){if(U$)return jb;U$=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 jb=e,jb}var Nb,W$;function $F(){if(W$)return Nb;W$=1;var e=Yhe(),t=Bm(),n=ga(),s=Xhe(),a=Vt();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 Nb=o,Nb}var Sb,H$;function Zhe(){if(H$)return Sb;H$=1;var e=ji(),t=Vt(),n=Er(),s="[object String]";function a(o){return typeof o=="string"||!t(o)&&n(o)&&e(o)==s}return Sb=a,Sb}var Cb,z$;function Jhe(){if(z$)return Cb;z$=1;var e=_F(),t=e("length");return Cb=t,Cb}var _b,V$;function Qhe(){if(V$)return _b;V$=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 _b=u,_b}var Eb,G$;function efe(){if(G$)return Eb;G$=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",b=h+"?",k="["+o+"]?",v="(?:"+w+"(?:"+[f,p,m].join("|")+")"+k+b+")*",N=k+b+v,x="(?:"+[f+l+"?",l,p,m,i].join("|")+")",C=RegExp(u+"(?="+u+")|"+x+N,"g");function S(_){for(var $=C.lastIndex=0;C.test(_);)++$;return $}return Eb=S,Eb}var Tb,K$;function tfe(){if(K$)return Tb;K$=1;var e=Jhe(),t=Qhe(),n=efe();function s(a){return t(a)?n(a):e(a)}return Tb=s,Tb}var Ab,Y$;function nfe(){if(Y$)return Ab;Y$=1;var e=jS(),t=dc(),n=ma(),s=Zhe(),a=tfe(),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 Ab=l,Ab}var Rb,X$;function sfe(){if(X$)return Rb;X$=1;var e=vS(),t=hF(),n=TS(),s=ga(),a=Fm(),o=Vt(),i=uc(),l=Nd(),u=Ss(),h=_d();function f(p,m,w){var b=o(p),k=b||i(p)||h(p);if(m=s(m,4),w==null){var v=p&&p.constructor;k?w=b?new v:[]:u(p)?w=l(v)?t(a(p)):{}:w={}}return(k?e:n)(p,function(N,x,C){return m(w,N,x,C)}),w}return Rb=f,Rb}var Mb,Z$;function rfe(){if(Z$)return Mb;Z$=1;var e=cc(),t=Cd(),n=Vt(),s=e?e.isConcatSpreadable:void 0;function a(o){return n(o)||t(o)||!!(s&&o&&o[s])}return Mb=a,Mb}var $b,J$;function MS(){if(J$)return $b;J$=1;var e=SS(),t=rfe();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 $b=n,$b}var Lb,Q$;function afe(){if(Q$)return Lb;Q$=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 Lb=e,Lb}var Ib,eL;function LF(){if(eL)return Ib;eL=1;var e=afe(),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 Ib=n,Ib}var Ob,tL;function ofe(){if(tL)return Ob;tL=1;var e=_S(),t=Q6(),n=Ci(),s=t?function(a,o){return t(a,"toString",{configurable:!0,enumerable:!1,value:e(o),writable:!0})}:n;return Ob=s,Ob}var Pb,nL;function ife(){if(nL)return Pb;nL=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 Pb=s,Pb}var Db,sL;function IF(){if(sL)return Db;sL=1;var e=ofe(),t=ife(),n=t(e);return Db=n,Db}var Fb,rL;function Hm(){if(rL)return Fb;rL=1;var e=Ci(),t=LF(),n=IF();function s(a,o){return n(t(a,o,e),a+"")}return Fb=s,Fb}var Bb,aL;function OF(){if(aL)return Bb;aL=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 Bb=e,Bb}var qb,oL;function lfe(){if(oL)return qb;oL=1;function e(t){return t!==t}return qb=e,qb}var Ub,iL;function cfe(){if(iL)return Ub;iL=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 Ub=e,Ub}var Wb,lL;function ufe(){if(lL)return Wb;lL=1;var e=OF(),t=lfe(),n=cfe();function s(a,o,i){return o===o?n(a,o,i):e(a,t,i)}return Wb=s,Wb}var Hb,cL;function dfe(){if(cL)return Hb;cL=1;var e=ufe();function t(n,s){var a=n==null?0:n.length;return!!a&&e(n,s,0)>-1}return Hb=t,Hb}var zb,uL;function hfe(){if(uL)return zb;uL=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 zb=e,zb}var Vb,dL;function ffe(){if(dL)return Vb;dL=1;function e(){}return Vb=e,Vb}var Gb,hL;function pfe(){if(hL)return Gb;hL=1;var e=cF(),t=ffe(),n=AS(),s=1/0,a=e&&1/n(new e([,-0]))[1]==s?function(o){return new e(o)}:t;return Gb=a,Gb}var Kb,fL;function mfe(){if(fL)return Kb;fL=1;var e=wF(),t=dfe(),n=hfe(),s=xF(),a=pfe(),o=AS(),i=200;function l(u,h,f){var p=-1,m=t,w=u.length,b=!0,k=[],v=k;if(f)b=!1,m=n;else if(w>=i){var N=h?null:a(u);if(N)return o(N);b=!1,m=s,v=new e}else v=h?[]:k;e:for(;++p<w;){var x=u[p],C=h?h(x):x;if(x=f||x!==0?x:0,b&&C===C){for(var S=v.length;S--;)if(v[S]===C)continue e;h&&v.push(C),k.push(x)}else m(v,C,f)||(v!==k&&v.push(C),k.push(x))}return k}return Kb=l,Kb}var Yb,pL;function PF(){if(pL)return Yb;pL=1;var e=ma(),t=Er();function n(s){return t(s)&&e(s)}return Yb=n,Yb}var Xb,mL;function gfe(){if(mL)return Xb;mL=1;var e=MS(),t=Hm(),n=mfe(),s=PF(),a=t(function(o){return n(e(o,1,s,!0))});return Xb=a,Xb}var Zb,gL;function yfe(){if(gL)return Zb;gL=1;var e=qm();function t(n,s){return e(s,function(a){return n[a]})}return Zb=t,Zb}var Jb,yL;function DF(){if(yL)return Jb;yL=1;var e=yfe(),t=mo();function n(s){return s==null?[]:e(s,t(s))}return Jb=n,Jb}var Qb,wL;function Cs(){if(wL)return Qb;wL=1;var e;if(typeof yS=="function")try{e={clone:Nhe(),constant:_S(),each:yF(),filter:EF(),has:TF(),isArray:Vt(),isEmpty:Khe(),isFunction:Nd(),isUndefined:AF(),keys:mo(),map:MF(),reduce:$F(),size:nfe(),transform:sfe(),union:gfe(),values:DF()}}catch{}return e||(e=window._),Qb=e,Qb}var ek,xL;function $S(){if(xL)return ek;xL=1;var e=Cs();ek=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(b){m.length>1?w.setNode(b,p):w.setNode(b)}),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(k,v){f(v)&&p.setNode(v,k)}),e.each(this._edgeObjs,function(k){p.hasNode(k.v)&&p.hasNode(k.w)&&p.setEdge(k,m.edge(k))});var w={};function b(k){var v=m.parent(k);return v===void 0||p.hasNode(v)?(w[k]=v,v):v in w?w[v]:b(v)}return this._isCompound&&e.each(p.nodes(),function(k){p.setParent(k,b(k))}),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(b,k){return w.length>1?m.setEdge(b,k,p):m.setEdge(b,k),k}),this},a.prototype.setEdge=function(){var f,p,m,w,b=!1,k=arguments[0];typeof k=="object"&&k!==null&&"v"in k?(f=k.v,p=k.w,m=k.name,arguments.length===2&&(w=arguments[1],b=!0)):(f=k,p=arguments[1],m=arguments[3],arguments.length>2&&(w=arguments[2],b=!0)),f=""+f,p=""+p,e.isUndefined(m)||(m=""+m);var v=l(this._isDirected,f,p,m);if(e.has(this._edgeLabels,v))return b&&(this._edgeLabels[v]=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[v]=b?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[v]=N,o(this._preds[p],f),o(this._sucs[f],p),this._in[p][v]=N,this._out[f][v]=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),b=this._edgeObjs[w];return b&&(f=b.v,p=b.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(b){return b.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(b){return b.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 b=""+p,k=""+m;if(!f&&b>k){var v=b;b=k,k=v}return b+s+k+s+(e.isUndefined(w)?t:w)}function u(f,p,m,w){var b=""+p,k=""+m;if(!f&&b>k){var v=b;b=k,k=v}var N={v:b,w:k};return w&&(N.name=w),N}function h(f,p){return l(f,p.v,p.w,p.name)}return ek}var tk,vL;function wfe(){return vL||(vL=1,tk="2.1.8"),tk}var nk,bL;function xfe(){return bL||(bL=1,nk={Graph:$S(),version:wfe()}),nk}var sk,kL;function vfe(){if(kL)return sk;kL=1;var e=Cs(),t=$S();sk={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 sk}var rk,jL;function bfe(){if(jL)return rk;jL=1;var e=Cs();rk=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 rk}var ak,NL;function FF(){if(NL)return ak;NL=1;var e=Cs();ak=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},ak}var ok,SL;function BF(){if(SL)return ok;SL=1;var e=Cs(),t=FF();ok=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(b){var k=b.v!==p?b.v:b.w,v=h[k],N=l(b),x=m.distance+N;if(N<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+b+" Weight: "+N);x<v.distance&&(v.distance=x,v.predecessor=p,f.decrease(k,x))};for(o.nodes().forEach(function(b){var k=b===i?0:Number.POSITIVE_INFINITY;h[b]={distance:k},f.add(b,k)});f.size()>0&&(p=f.removeMin(),m=h[p],m.distance!==Number.POSITIVE_INFINITY);)u(p).forEach(w);return h}return ok}var ik,CL;function kfe(){if(CL)return ik;CL=1;var e=BF(),t=Cs();ik=n;function n(s,a,o){return t.transform(s.nodes(),function(i,l){i[l]=e(s,l,a,o)},{})}return ik}var lk,_L;function qF(){if(_L)return lk;_L=1;var e=Cs();lk=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 lk}var ck,EL;function jfe(){if(EL)return ck;EL=1;var e=Cs(),t=qF();ck=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 ck}var uk,TL;function Nfe(){if(TL)return uk;TL=1;var e=Cs();uk=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 b=m[h],k=f[w],v=m[w],N=b.distance+k.distance;N<v.distance&&(v.distance=N,v.predecessor=k.predecessor)})})}),l}return uk}var dk,AL;function UF(){if(AL)return dk;AL=1;var e=Cs();dk=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,dk}var hk,RL;function Sfe(){if(RL)return hk;RL=1;var e=UF();hk=t;function t(n){try{e(n)}catch(s){if(s instanceof e.CycleException)return!1;throw s}return!0}return hk}var fk,ML;function WF(){if(ML)return fk;ML=1;var e=Cs();fk=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 fk}var pk,$L;function Cfe(){if($L)return pk;$L=1;var e=WF();pk=t;function t(n,s){return e(n,s,"post")}return pk}var mk,LL;function _fe(){if(LL)return mk;LL=1;var e=WF();mk=t;function t(n,s){return e(n,s,"pre")}return mk}var gk,IL;function Efe(){if(IL)return gk;IL=1;var e=Cs(),t=$S(),n=FF();gk=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,b=u.priority(w);if(b!==void 0){var k=o(m);k<b&&(l[w]=h,u.decrease(w,k))}}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 gk}var yk,OL;function Tfe(){return OL||(OL=1,yk={components:bfe(),dijkstra:BF(),dijkstraAll:kfe(),findCycles:jfe(),floydWarshall:Nfe(),isAcyclic:Sfe(),postorder:Cfe(),preorder:_fe(),prim:Efe(),tarjan:qF(),topsort:UF()}),yk}var wk,PL;function Afe(){if(PL)return wk;PL=1;var e=xfe();return wk={Graph:e.Graph,json:vfe(),alg:Tfe(),version:e.version},wk}var xk,DL;function Qs(){if(DL)return xk;DL=1;var e;if(typeof yS=="function")try{e=Afe()}catch{}return e||(e=window.graphlib),xk=e,xk}var vk,FL;function Rfe(){if(FL)return vk;FL=1;var e=pF(),t=1,n=4;function s(a){return e(a,t|n)}return vk=s,vk}var bk,BL;function zm(){if(BL)return bk;BL=1;var e=lc(),t=ma(),n=Om(),s=Ss();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 bk=a,bk}var kk,qL;function Mfe(){if(qL)return kk;qL=1;var e=Hm(),t=lc(),n=zm(),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),b=-1,k=w.length;++b<k;){var v=w[b],N=l[v];(N===void 0||t(N,a[v])&&!o.call(l,v))&&(l[v]=m[v])}return l});return kk=i,kk}var jk,UL;function $fe(){if(UL)return jk;UL=1;var e=ga(),t=ma(),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 jk=s,jk}var Nk,WL;function Lfe(){if(WL)return Nk;WL=1;var e=/\s/;function t(n){for(var s=n.length;s--&&e.test(n.charAt(s)););return s}return Nk=t,Nk}var Sk,HL;function Ife(){if(HL)return Sk;HL=1;var e=Lfe(),t=/^\s+/;function n(s){return s&&s.slice(0,e(s)+1).replace(t,"")}return Sk=n,Sk}var Ck,zL;function Ofe(){if(zL)return Ck;zL=1;var e=Ife(),t=Ss(),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 Ck=u,Ck}var _k,VL;function HF(){if(VL)return _k;VL=1;var e=Ofe(),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 _k=s,_k}var Ek,GL;function Pfe(){if(GL)return Ek;GL=1;var e=HF();function t(n){var s=e(n),a=s%1;return s===s?a?s-a:s:0}return Ek=t,Ek}var Tk,KL;function Dfe(){if(KL)return Tk;KL=1;var e=OF(),t=ga(),n=Pfe(),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 Tk=a,Tk}var Ak,YL;function Ffe(){if(YL)return Ak;YL=1;var e=$fe(),t=Dfe(),n=e(t);return Ak=n,Ak}var Rk,XL;function zF(){if(XL)return Rk;XL=1;var e=MS();function t(n){var s=n==null?0:n.length;return s?e(n,1):[]}return Rk=t,Rk}var Mk,ZL;function Bfe(){if(ZL)return Mk;ZL=1;var e=ES(),t=mF(),n=Si();function s(a,o){return a==null?a:e(a,t(o),n)}return Mk=s,Mk}var $k,JL;function qfe(){if(JL)return $k;JL=1;function e(t){var n=t==null?0:t.length;return n?t[n-1]:void 0}return $k=e,$k}var Lk,QL;function Ufe(){if(QL)return Lk;QL=1;var e=Lm(),t=TS(),n=ga();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 Lk=s,Lk}var Ik,eI;function LS(){if(eI)return Ik;eI=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 Ik=t,Ik}var Ok,tI;function Wfe(){if(tI)return Ok;tI=1;function e(t,n){return t>n}return Ok=e,Ok}var Pk,nI;function Hfe(){if(nI)return Pk;nI=1;var e=LS(),t=Wfe(),n=Ci();function s(a){return a&&a.length?e(a,n,t):void 0}return Pk=s,Pk}var Dk,sI;function VF(){if(sI)return Dk;sI=1;var e=Lm(),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 Dk=n,Dk}var Fk,rI;function zfe(){if(rI)return Fk;rI=1;var e=ji(),t=Fm(),n=Er(),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 Fk=h,Fk}var Bk,aI;function GF(){if(aI)return Bk;aI=1;function e(t,n){if(!(n==="constructor"&&typeof t[n]=="function")&&n!="__proto__")return t[n]}return Bk=e,Bk}var qk,oI;function Vfe(){if(oI)return qk;oI=1;var e=Sd(),t=Si();function n(s){return e(s,t(s))}return qk=n,qk}var Uk,iI;function Gfe(){if(iI)return Uk;iI=1;var e=VF(),t=nF(),n=dF(),s=sF(),a=fF(),o=Cd(),i=Vt(),l=PF(),u=uc(),h=Nd(),f=Ss(),p=zfe(),m=_d(),w=GF(),b=Vfe();function k(v,N,x,C,S,_,$){var A=w(v,x),O=w(N,x),M=$.get(O);if(M){e(v,x,M);return}var W=_?_(A,O,x+"",v,N,$):void 0,B=W===void 0;if(B){var R=i(O),q=!R&&u(O),T=!R&&!q&&m(O);W=O,R||q||T?i(A)?W=A:l(A)?W=s(A):q?(B=!1,W=t(O,!0)):T?(B=!1,W=n(O,!0)):W=[]:p(O)||o(O)?(W=A,o(A)?W=b(A):(!f(A)||h(A))&&(W=a(O))):B=!1}B&&($.set(O,W),S(W,O,C,_,$),$.delete(O)),e(v,x,W)}return Uk=k,Uk}var Wk,lI;function Kfe(){if(lI)return Wk;lI=1;var e=$m(),t=VF(),n=ES(),s=Gfe(),a=Ss(),o=Si(),i=GF();function l(u,h,f,p,m){u!==h&&n(h,function(w,b){if(m||(m=new e),a(w))s(u,h,b,f,l,p,m);else{var k=p?p(i(u,b),w,b+"",u,h,m):void 0;k===void 0&&(k=w),t(u,b,k)}},o)}return Wk=l,Wk}var Hk,cI;function Yfe(){if(cI)return Hk;cI=1;var e=Hm(),t=zm();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 Hk=n,Hk}var zk,uI;function Xfe(){if(uI)return zk;uI=1;var e=Kfe(),t=Yfe(),n=t(function(s,a,o){e(s,a,o)});return zk=n,zk}var Vk,dI;function KF(){if(dI)return Vk;dI=1;function e(t,n){return t<n}return Vk=e,Vk}var Gk,hI;function Zfe(){if(hI)return Gk;hI=1;var e=LS(),t=KF(),n=Ci();function s(a){return a&&a.length?e(a,n,t):void 0}return Gk=s,Gk}var Kk,fI;function Jfe(){if(fI)return Kk;fI=1;var e=LS(),t=ga(),n=KF();function s(a,o){return a&&a.length?e(a,t(o,2),n):void 0}return Kk=s,Kk}var Yk,pI;function Qfe(){if(pI)return Yk;pI=1;var e=tr(),t=function(){return e.Date.now()};return Yk=t,Yk}var Xk,mI;function epe(){if(mI)return Xk;mI=1;var e=Im(),t=Um(),n=Om(),s=Ss(),a=Ed();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 b=a(l[f]),k=u;if(b==="__proto__"||b==="constructor"||b==="prototype")return i;if(f!=m){var v=w[b];k=h?h(v,b,w):void 0,k===void 0&&(k=s(v)?v:n(l[f+1])?[]:{})}e(w,b,k),w=w[b]}return i}return Xk=o,Xk}var Zk,gI;function tpe(){if(gI)return Zk;gI=1;var e=Wm(),t=epe(),n=Um();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 Zk=s,Zk}var Jk,yI;function npe(){if(yI)return Jk;yI=1;var e=tpe(),t=CF();function n(s,a){return e(s,a,function(o,i){return t(s,i)})}return Jk=n,Jk}var Qk,wI;function spe(){if(wI)return Qk;wI=1;var e=zF(),t=LF(),n=IF();function s(a){return n(t(a,void 0,e),a+"")}return Qk=s,Qk}var e0,xI;function rpe(){if(xI)return e0;xI=1;var e=npe(),t=spe(),n=t(function(s,a){return s==null?{}:e(s,a)});return e0=n,e0}var t0,vI;function ape(){if(vI)return t0;vI=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 t0=n,t0}var n0,bI;function ope(){if(bI)return n0;bI=1;var e=ape(),t=zm(),n=HF();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 n0=s,n0}var s0,kI;function ipe(){if(kI)return s0;kI=1;var e=ope(),t=e();return s0=t,s0}var r0,jI;function lpe(){if(jI)return r0;jI=1;function e(t,n){var s=t.length;for(t.sort(n);s--;)t[s]=t[s].value;return t}return r0=e,r0}var a0,NI;function cpe(){if(NI)return a0;NI=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 a0=t,a0}var o0,SI;function upe(){if(SI)return o0;SI=1;var e=cpe();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 o0=t,o0}var i0,CI;function dpe(){if(CI)return i0;CI=1;var e=qm(),t=Wm(),n=ga(),s=RF(),a=lpe(),o=Pm(),i=upe(),l=Ci(),u=Vt();function h(f,p,m){p.length?p=e(p,function(k){return u(k)?function(v){return t(v,k.length===1?k[0]:k)}:k}):p=[l];var w=-1;p=e(p,o(n));var b=s(f,function(k,v,N){var x=e(p,function(C){return C(k)});return{criteria:x,index:++w,value:k}});return a(b,function(k,v){return i(k,v,m)})}return i0=h,i0}var l0,_I;function hpe(){if(_I)return l0;_I=1;var e=MS(),t=dpe(),n=Hm(),s=zm(),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 l0=a,l0}var c0,EI;function fpe(){if(EI)return c0;EI=1;var e=NF(),t=0;function n(s){var a=++t;return e(s)+a}return c0=n,c0}var u0,TI;function ppe(){if(TI)return u0;TI=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 u0=e,u0}var d0,AI;function mpe(){if(AI)return d0;AI=1;var e=Im(),t=ppe();function n(s,a){return t(s||[],a||[],e)}return d0=n,d0}var h0,RI;function Mt(){if(RI)return h0;RI=1;var e;if(typeof yS=="function")try{e={cloneDeep:Rfe(),constant:_S(),defaults:Mfe(),each:yF(),filter:EF(),find:Ffe(),flatten:zF(),forEach:gF(),forIn:Bfe(),has:TF(),isUndefined:AF(),last:qfe(),map:MF(),mapValues:Ufe(),max:Hfe(),merge:Xfe(),min:Zfe(),minBy:Jfe(),now:Qfe(),pick:rpe(),range:ipe(),reduce:$F(),sortBy:hpe(),uniqueId:fpe(),values:DF(),zipObject:mpe()}}catch{}return e||(e=window._),h0=e,h0}var f0,MI;function gpe(){if(MI)return f0;MI=1,f0=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 f0}var p0,$I;function ype(){if($I)return p0;$I=1;var e=Mt(),t=Qs().Graph,n=gpe();p0=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],b=f[0],k;h.nodeCount();){for(;k=b.dequeue();)i(h,f,p,k);for(;k=w.dequeue();)i(h,f,p,k);if(h.nodeCount()){for(var v=f.length-2;v>0;--v)if(k=f[v].dequeue(),k){m=m.concat(i(h,f,p,k,!0));break}}}return m}function i(h,f,p,m,w){var b=w?[]:void 0;return e.forEach(h.inEdges(m.v),function(k){var v=h.edge(k),N=h.node(k.v);w&&b.push({v:k.v,w:k.w}),N.out-=v,u(f,p,N)}),e.forEach(h.outEdges(m.v),function(k){var v=h.edge(k),N=k.w,x=h.node(N);x.in-=v,u(f,p,x)}),h.removeNode(m.v),b}function l(h,f){var p=new t,m=0,w=0;e.forEach(h.nodes(),function(v){p.setNode(v,{v,in:0,out:0})}),e.forEach(h.edges(),function(v){var N=p.edge(v.v,v.w)||0,x=f(v),C=N+x;p.setEdge(v.v,v.w,C),w=Math.max(w,p.node(v.v).out+=x),m=Math.max(m,p.node(v.w).in+=x)});var b=e.range(w+m+3).map(function(){return new n}),k=m+1;return e.forEach(p.nodes(),function(v){u(b,k,p.node(v))}),{graph:p,buckets:b,zeroIdx:k}}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 p0}var m0,LI;function wpe(){if(LI)return m0;LI=1;var e=Mt(),t=ype();m0={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 m0}var g0,II;function qn(){if(II)return g0;II=1;var e=Mt(),t=Qs().Graph;g0={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:b,notime:k};function n(v,N,x,C){var S;do S=e.uniqueId(C);while(v.hasNode(S));return x.dummy=N,v.setNode(S,x),S}function s(v){var N=new t().setGraph(v.graph());return e.forEach(v.nodes(),function(x){N.setNode(x,v.node(x))}),e.forEach(v.edges(),function(x){var C=N.edge(x.v,x.w)||{weight:0,minlen:1},S=v.edge(x);N.setEdge(x.v,x.w,{weight:C.weight+S.weight,minlen:Math.max(C.minlen,S.minlen)})}),N}function a(v){var N=new t({multigraph:v.isMultigraph()}).setGraph(v.graph());return e.forEach(v.nodes(),function(x){v.children(x).length||N.setNode(x,v.node(x))}),e.forEach(v.edges(),function(x){N.setEdge(x,v.edge(x))}),N}function o(v){var N=e.map(v.nodes(),function(x){var C={};return e.forEach(v.outEdges(x),function(S){C[S.w]=(C[S.w]||0)+v.edge(S).weight}),C});return e.zipObject(v.nodes(),N)}function i(v){var N=e.map(v.nodes(),function(x){var C={};return e.forEach(v.inEdges(x),function(S){C[S.v]=(C[S.v]||0)+v.edge(S).weight}),C});return e.zipObject(v.nodes(),N)}function l(v,N){var x=v.x,C=v.y,S=N.x-x,_=N.y-C,$=v.width/2,A=v.height/2;if(!S&&!_)throw new Error("Not possible to find intersection inside of the rectangle");var O,M;return Math.abs(_)*$>Math.abs(S)*A?(_<0&&(A=-A),O=A*S/_,M=A):(S<0&&($=-$),O=$,M=$*_/S),{x:x+O,y:C+M}}function u(v){var N=e.map(e.range(m(v)+1),function(){return[]});return e.forEach(v.nodes(),function(x){var C=v.node(x),S=C.rank;e.isUndefined(S)||(N[S][C.order]=x)}),N}function h(v){var N=e.min(e.map(v.nodes(),function(x){return v.node(x).rank}));e.forEach(v.nodes(),function(x){var C=v.node(x);e.has(C,"rank")&&(C.rank-=N)})}function f(v){var N=e.min(e.map(v.nodes(),function(_){return v.node(_).rank})),x=[];e.forEach(v.nodes(),function(_){var $=v.node(_).rank-N;x[$]||(x[$]=[]),x[$].push(_)});var C=0,S=v.graph().nodeRankFactor;e.forEach(x,function(_,$){e.isUndefined(_)&&$%S!==0?--C:C&&e.forEach(_,function(A){v.node(A).rank+=C})})}function p(v,N,x,C){var S={width:0,height:0};return arguments.length>=4&&(S.rank=x,S.order=C),n(v,"border",S,N)}function m(v){return e.max(e.map(v.nodes(),function(N){var x=v.node(N).rank;if(!e.isUndefined(x))return x}))}function w(v,N){var x={lhs:[],rhs:[]};return e.forEach(v,function(C){N(C)?x.lhs.push(C):x.rhs.push(C)}),x}function b(v,N){var x=e.now();try{return N()}finally{console.log(v+" time: "+(e.now()-x)+"ms")}}function k(v,N){return N()}return g0}var y0,OI;function xpe(){if(OI)return y0;OI=1;var e=Mt(),t=qn();y0={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 b,k,v;for(v=0,++u;u<f;++v,++u)m.points=[],k={width:0,height:0,edgeLabel:m,edgeObj:i,rank:u},b=t.addDummyNode(o,"edge",k,"_d"),u===w&&(k.width=m.width,k.height=m.height,k.dummy="edge-label",k.labelpos=m.labelpos),o.setEdge(l,b,{weight:m.weight},p),v===0&&o.graph().dummyChains.push(b),l=b;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 y0}var w0,PI;function Tp(){if(PI)return w0;PI=1;var e=Mt();w0={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 w0}var x0,DI;function YF(){if(DI)return x0;DI=1;var e=Mt(),t=Qs().Graph,n=Tp().slack;x0=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 x0}var v0,FI;function vpe(){if(FI)return v0;FI=1;var e=Mt(),t=YF(),n=Tp().slack,s=Tp().longestPath,a=Qs().alg.preorder,o=Qs().alg.postorder,i=qn().simplify;v0=l,l.initLowLimValues=p,l.initCutValues=u,l.calcCutValue=f,l.leaveEdge=w,l.enterEdge=b,l.exchangeEdges=k;function l(C){C=i(C),s(C);var S=t(C);p(S),u(S,C);for(var _,$;_=w(S);)$=b(S,C,_),k(S,C,_,$)}function u(C,S){var _=o(C,C.nodes());_=_.slice(0,_.length-1),e.forEach(_,function($){h(C,S,$)})}function h(C,S,_){var $=C.node(_),A=$.parent;C.edge(_,A).cutvalue=f(C,S,_)}function f(C,S,_){var $=C.node(_),A=$.parent,O=!0,M=S.edge(_,A),W=0;return M||(O=!1,M=S.edge(A,_)),W=M.weight,e.forEach(S.nodeEdges(_),function(B){var R=B.v===_,q=R?B.w:B.v;if(q!==A){var T=R===O,F=S.edge(B).weight;if(W+=T?F:-F,N(C,_,q)){var D=C.edge(_,q).cutvalue;W+=T?-D:D}}}),W}function p(C,S){arguments.length<2&&(S=C.nodes()[0]),m(C,{},1,S)}function m(C,S,_,$,A){var O=_,M=C.node($);return S[$]=!0,e.forEach(C.neighbors($),function(W){e.has(S,W)||(_=m(C,S,_,W,$))}),M.low=O,M.lim=_++,A?M.parent=A:delete M.parent,_}function w(C){return e.find(C.edges(),function(S){return C.edge(S).cutvalue<0})}function b(C,S,_){var $=_.v,A=_.w;S.hasEdge($,A)||($=_.w,A=_.v);var O=C.node($),M=C.node(A),W=O,B=!1;O.lim>M.lim&&(W=M,B=!0);var R=e.filter(S.edges(),function(q){return B===x(C,C.node(q.v),W)&&B!==x(C,C.node(q.w),W)});return e.minBy(R,function(q){return n(S,q)})}function k(C,S,_,$){var A=_.v,O=_.w;C.removeEdge(A,O),C.setEdge($.v,$.w,{}),p(C),u(C,S),v(C,S)}function v(C,S){var _=e.find(C.nodes(),function(A){return!S.node(A).parent}),$=a(C,_);$=$.slice(1),e.forEach($,function(A){var O=C.node(A).parent,M=S.edge(A,O),W=!1;M||(M=S.edge(O,A),W=!0),S.node(A).rank=S.node(O).rank+(W?M.minlen:-M.minlen)})}function N(C,S,_){return C.hasEdge(S,_)}function x(C,S,_){return _.low<=S.lim&&S.lim<=_.lim}return v0}var b0,BI;function bpe(){if(BI)return b0;BI=1;var e=Tp(),t=e.longestPath,n=YF(),s=vpe();b0=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 b0}var k0,qI;function kpe(){if(qI)return k0;qI=1;var e=Mt();k0=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],b=!0;i!==u.w;){if(l=a.node(i),b){for(;(w=f[m])!==p&&a.node(w).maxRank<l.rank;)m++;w===p&&(b=!1)}if(!b){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 k0}var j0,UI;function jpe(){if(UI)return j0;UI=1;var e=Mt(),t=qn();j0={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 b=l.children(w);if(!b.length){w!==u&&l.setEdge(u,w,{weight:0,minlen:h});return}var k=t.addBorderNode(l,"_bt"),v=t.addBorderNode(l,"_bb"),N=l.node(w);l.setParent(k,w),N.borderTop=k,l.setParent(v,w),N.borderBottom=v,e.forEach(b,function(x){s(l,u,h,f,p,m,x);var C=l.node(x),S=C.borderTop?C.borderTop:x,_=C.borderBottom?C.borderBottom:x,$=C.borderTop?f:2*f,A=S!==_?1:p-m[w]+1;l.setEdge(k,S,{weight:$,minlen:A,nestingEdge:!0}),l.setEdge(_,v,{weight:$,minlen:A,nestingEdge:!0})}),l.parent(w)||l.setEdge(u,k,{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 j0}var N0,WI;function Npe(){if(WI)return N0;WI=1;var e=Mt(),t=qn();N0=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 N0}var S0,HI;function Spe(){if(HI)return S0;HI=1;var e=Mt();S0={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 S0}var C0,zI;function Cpe(){if(zI)return C0;zI=1;var e=Mt();C0=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 C0}var _0,VI;function _pe(){if(VI)return _0;VI=1;var e=Mt();_0=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 b=0;w>0;)w%2&&(b+=f[w+1]),w=w-1>>1,f[w]+=m.weight;p+=m.weight*b})),p}return _0}var E0,GI;function Epe(){if(GI)return E0;GI=1;var e=Mt();E0=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 E0}var T0,KI;function Tpe(){if(KI)return T0;KI=1;var e=Mt();T0=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 T0}var A0,YI;function Ape(){if(YI)return A0;YI=1;var e=Mt(),t=qn();A0=n;function n(o,i){var l=t.partition(o,function(k){return e.has(k,"barycenter")}),u=l.lhs,h=e.sortBy(l.rhs,function(k){return-k.i}),f=[],p=0,m=0,w=0;u.sort(a(!!i)),w=s(f,h,w),e.forEach(u,function(k){w+=k.vs.length,f.push(k.vs),p+=k.barycenter*k.weight,m+=k.weight,w=s(f,h,w)});var b={vs:e.flatten(f,!0)};return m&&(b.barycenter=p/m,b.weight=m),b}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 A0}var R0,XI;function Rpe(){if(XI)return R0;XI=1;var e=Mt(),t=Epe(),n=Tpe(),s=Ape();R0=a;function a(l,u,h,f){var p=l.children(u),m=l.node(u),w=m?m.borderLeft:void 0,b=m?m.borderRight:void 0,k={};w&&(p=e.filter(p,function(_){return _!==w&&_!==b}));var v=t(l,p);e.forEach(v,function(_){if(l.children(_.v).length){var $=a(l,_.v,h,f);k[_.v]=$,e.has($,"barycenter")&&i(_,$)}});var N=n(v,h);o(N,k);var x=s(N,f);if(w&&(x.vs=e.flatten([w,x.vs,b],!0),l.predecessors(w).length)){var C=l.node(l.predecessors(w)[0]),S=l.node(l.predecessors(b)[0]);e.has(x,"barycenter")||(x.barycenter=0,x.weight=0),x.barycenter=(x.barycenter*x.weight+C.order+S.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 R0}var M0,ZI;function Mpe(){if(ZI)return M0;ZI=1;var e=Mt(),t=Qs().Graph;M0=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,b=u.edge(w,h),k=e.isUndefined(b)?0:b.weight;u.setEdge(w,h,{weight:a.edge(m).weight+k})}),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 M0}var $0,JI;function $pe(){if(JI)return $0;JI=1;var e=Mt();$0=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 $0}var L0,QI;function Lpe(){if(QI)return L0;QI=1;var e=Mt(),t=Cpe(),n=_pe(),s=Rpe(),a=Mpe(),o=$pe(),i=Qs().Graph,l=qn();L0=u;function u(m){var w=l.maxRank(m),b=h(m,e.range(1,w+1),"inEdges"),k=h(m,e.range(w-1,-1,-1),"outEdges"),v=t(m);p(m,v);for(var N=Number.POSITIVE_INFINITY,x,C=0,S=0;S<4;++C,++S){f(C%2?b:k,C%4>=2),v=l.buildLayerMatrix(m);var _=n(m,v);_<N&&(S=0,x=e.cloneDeep(v),N=_)}p(m,x)}function h(m,w,b){return e.map(w,function(k){return a(m,k,b)})}function f(m,w){var b=new i;e.forEach(m,function(k){var v=k.graph().root,N=s(k,v,b,w);e.forEach(N.vs,function(x,C){k.node(x).order=C}),o(k,b,N.vs)})}function p(m,w){e.forEach(w,function(b){e.forEach(b,function(k,v){m.node(k).order=v})})}return L0}var I0,eO;function Ipe(){if(eO)return I0;eO=1;var e=Mt(),t=Qs().Graph,n=qn();I0={positionX:b,findType1Conflicts:s,findType2Conflicts:a,addConflict:i,hasConflict:l,verticalAlignment:u,horizontalCompaction:h,alignCoordinates:m,findSmallestWidthAlignment:p,balance:w};function s(N,x){var C={};function S(_,$){var A=0,O=0,M=_.length,W=e.last($);return e.forEach($,function(B,R){var q=o(N,B),T=q?N.node(q).order:M;(q||B===W)&&(e.forEach($.slice(O,R+1),function(F){e.forEach(N.predecessors(F),function(D){var K=N.node(D),V=K.order;(V<A||T<V)&&!(K.dummy&&N.node(F).dummy)&&i(C,D,F)})}),O=R+1,A=T)}),$}return e.reduce(x,S),C}function a(N,x){var C={};function S($,A,O,M,W){var B;e.forEach(e.range(A,O),function(R){B=$[R],N.node(B).dummy&&e.forEach(N.predecessors(B),function(q){var T=N.node(q);T.dummy&&(T.order<M||T.order>W)&&i(C,q,B)})})}function _($,A){var O=-1,M,W=0;return e.forEach(A,function(B,R){if(N.node(B).dummy==="border"){var q=N.predecessors(B);q.length&&(M=N.node(q[0]).order,S(A,W,R,O,M),W=R,O=M)}S(A,W,A.length,M,$.length)}),A}return e.reduce(x,_),C}function o(N,x){if(N.node(x).dummy)return e.find(N.predecessors(x),function(C){return N.node(C).dummy})}function i(N,x,C){if(x>C){var S=x;x=C,C=S}var _=N[x];_||(N[x]=_={}),_[C]=!0}function l(N,x,C){if(x>C){var S=x;x=C,C=S}return e.has(N[x],C)}function u(N,x,C,S){var _={},$={},A={};return e.forEach(x,function(O){e.forEach(O,function(M,W){_[M]=M,$[M]=M,A[M]=W})}),e.forEach(x,function(O){var M=-1;e.forEach(O,function(W){var B=S(W);if(B.length){B=e.sortBy(B,function(D){return A[D]});for(var R=(B.length-1)/2,q=Math.floor(R),T=Math.ceil(R);q<=T;++q){var F=B[q];$[W]===W&&M<A[F]&&!l(C,W,F)&&($[F]=W,$[W]=_[W]=_[F],M=A[F])}}})}),{root:_,align:$}}function h(N,x,C,S,_){var $={},A=f(N,x,C,_),O=_?"borderLeft":"borderRight";function M(R,q){for(var T=A.nodes(),F=T.pop(),D={};F;)D[F]?R(F):(D[F]=!0,T.push(F),T=T.concat(q(F))),F=T.pop()}function W(R){$[R]=A.inEdges(R).reduce(function(q,T){return Math.max(q,$[T.v]+A.edge(T))},0)}function B(R){var q=A.outEdges(R).reduce(function(F,D){return Math.min(F,$[D.w]-A.edge(D))},Number.POSITIVE_INFINITY),T=N.node(R);q!==Number.POSITIVE_INFINITY&&T.borderType!==O&&($[R]=Math.max($[R],q))}return M(W,A.predecessors.bind(A)),M(B,A.successors.bind(A)),e.forEach(S,function(R){$[R]=$[C[R]]}),$}function f(N,x,C,S){var _=new t,$=N.graph(),A=k($.nodesep,$.edgesep,S);return e.forEach(x,function(O){var M;e.forEach(O,function(W){var B=C[W];if(_.setNode(B),M){var R=C[M],q=_.edge(R,B);_.setEdge(R,B,Math.max(A(N,W,M),q||0))}M=W})}),_}function p(N,x){return e.minBy(e.values(x),function(C){var S=Number.NEGATIVE_INFINITY,_=Number.POSITIVE_INFINITY;return e.forIn(C,function($,A){var O=v(N,A)/2;S=Math.max($+O,S),_=Math.min($-O,_)}),S-_})}function m(N,x){var C=e.values(x),S=e.min(C),_=e.max(C);e.forEach(["u","d"],function($){e.forEach(["l","r"],function(A){var O=$+A,M=N[O],W;if(M!==x){var B=e.values(M);W=A==="l"?S-e.min(B):_-e.max(B),W&&(N[O]=e.mapValues(M,function(R){return R+W}))}})})}function w(N,x){return e.mapValues(N.ul,function(C,S){if(x)return N[x.toLowerCase()][S];var _=e.sortBy(e.map(N,S));return(_[1]+_[2])/2})}function b(N){var x=n.buildLayerMatrix(N),C=e.merge(s(N,x),a(N,x)),S={},_;e.forEach(["u","d"],function(A){_=A==="u"?x:e.values(x).reverse(),e.forEach(["l","r"],function(O){O==="r"&&(_=e.map(_,function(R){return e.values(R).reverse()}));var M=(A==="u"?N.predecessors:N.successors).bind(N),W=u(N,_,C,M),B=h(N,_,W.root,W.align,O==="r");O==="r"&&(B=e.mapValues(B,function(R){return-R})),S[A+O]=B})});var $=p(N,S);return m(S,$),w(S,N.graph().align)}function k(N,x,C){return function(S,_,$){var A=S.node(_),O=S.node($),M=0,W;if(M+=A.width/2,e.has(A,"labelpos"))switch(A.labelpos.toLowerCase()){case"l":W=-A.width/2;break;case"r":W=A.width/2;break}if(W&&(M+=C?W:-W),W=0,M+=(A.dummy?x:N)/2,M+=(O.dummy?x:N)/2,M+=O.width/2,e.has(O,"labelpos"))switch(O.labelpos.toLowerCase()){case"l":W=O.width/2;break;case"r":W=-O.width/2;break}return W&&(M+=C?W:-W),W=0,M}}function v(N,x){return N.node(x).width}return I0}var O0,tO;function Ope(){if(tO)return O0;tO=1;var e=Mt(),t=qn(),n=Ipe().positionX;O0=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 O0}var P0,nO;function Ppe(){if(nO)return P0;nO=1;var e=Mt(),t=wpe(),n=xpe(),s=bpe(),a=qn().normalizeRanks,o=kpe(),i=qn().removeEmptyRanks,l=jpe(),u=Npe(),h=Spe(),f=Lpe(),p=Ope(),m=qn(),w=Qs().Graph;P0=b;function b(z,X){var Y=X&&X.debugTiming?m.time:m.notime;Y("layout",function(){var J=Y(" buildLayoutGraph",function(){return M(z)});Y(" runLayout",function(){k(J,Y)}),Y(" updateInputGraph",function(){v(z,J)})})}function k(z,X){X(" makeSpaceForEdgeLabels",function(){W(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(){R(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(){P(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(){D(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 v(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"},C=["acyclicer","ranker","rankdir","align"],S=["width","height"],_={width:0,height:0},$=["minlen","weight","width","height","labeloffset"],A={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},O=["labelpos"];function M(z){var X=new w({multigraph:!0,compound:!0}),Y=Z(z.graph());return X.setGraph(e.merge({},x,U(Y,N),e.pick(Y,C))),e.forEach(z.nodes(),function(J){var Q=Z(z.node(J));X.setNode(J,e.defaults(U(Q,S),_)),X.setParent(J,z.parent(J))}),e.forEach(z.edges(),function(J){var Q=Z(z.edge(J));X.setEdge(J,e.merge({},A,U(Q,$),e.pick(Q,O)))}),X}function W(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 R(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 D(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 P(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 U(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 P0}var D0,sO;function Dpe(){if(sO)return D0;sO=1;var e=Mt(),t=qn(),n=Qs().Graph;D0={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 D0}var F0,rO;function Fpe(){return rO||(rO=1,F0="0.8.5"),F0}var B0,aO;function Bpe(){return aO||(aO=1,B0={graphlib:Qs(),layout:Ppe(),debug:Dpe(),util:{time:qn().time,notime:qn().notime},version:Fpe()}),B0}var qpe=Bpe();const oO=Fj(qpe),iO=e=>{var t;return(t=e.data)==null?void 0:t.parentId};function Upe(e,t,n,s){const a=um(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)??MN},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(Tn(f))).sort((f,p)=>f.position.x-p.position.x||f.position.y-p.position.y);for(const f of h){const p=Tn(f),m=iO(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 C=null;for(const S of e){if(S.id===f.id||S.type==="recapNote"||iO(S)!==m||Tn(S)!==p)continue;const _=u(S.id);if(!_||Math.abs(_.x-x.x)>Ol||_.x<=w.x)continue;const $=_.y+o(S.id);(!C||$>C.bottom)&&(C={at:_,bottom:$})}if(C){l.set(f.id,{x:C.at.x,y:C.bottom+vD});continue}}const b=a.get(p)[0].id,k=w??n(b),v=i.get(w?m:b);l.set(f.id,{x:f.position.x+k.x-v.x,y:f.position.y+k.y-v.y})}return l.size===0?e:e.map(f=>{const p=l.get(f.id);return p?{...f,position:p}:f})}const q0=e=>e.type==="recapNote";function Wpe(e,t,n,s,a,o,i){const l=C=>xd(C,s,o),u=C=>n.get(C)??t.get(C),h=C=>{const{w:S,h:_}=Ju(C,s);return{cw:S,ch:_}},f=i!=null&&i.width>0&&i.height>0,p=um(e,C=>u(C.id)!=null&&!q0(C)),m=new Set;for(const[C,S]of p)S.every(_=>a.has(_.id)&&!n.has(_.id))&&m.add(C);const w=new Map,b=[];for(const C of e){const S=u(C.id);if(!S)continue;const{w:_,h:$}=l(C.id),A=Tn(C);m.has(A)?q0(C)||(w.get(A)??w.set(A,[]).get(A)).push(C):b.push({sid:A,x:S.x,y:S.y,w:_,h:$,...h(C.id),note:q0(C)})}if(w.size===0||f&&b.length===0)return[];const k=hp,v=(C,S,_,$)=>b.some(A=>C<A.x+A.w+D1&&A.x<C+_+D1&&S<A.y+A.h+k&&A.y<S+$+k),N=kD(e,s),x=[];for(const C of[...w.keys()].sort()){const S=w.get(C);let _=1/0,$=1/0,A=-1/0,O=-1/0,M=-1/0,W=-1/0;for(const P of S){const I=u(P.id),{w:U,h:Z}=l(P.id),{cw:z,ch:X}=h(P.id);_=Math.min(_,I.x),$=Math.min($,I.y),A=Math.max(A,I.x+U),O=Math.max(O,I.y+Z),M=Math.max(M,I.x+z),W=Math.max(W,I.y+X)}const B=O-$,R=S.some(P=>{var I;return((I=P.data)==null?void 0:I.kind)==="root"})?If+jD:0,q=Math.max(A,M+Ol)-_,T=(P,I)=>!v(P-R,I,R+q,B),F=new Map;for(const P of b)P.note||F.set(P.sid,Math.min(F.get(P.sid)??1/0,P.x));const D=[...new Set([...F.values()].map(P=>Math.round(P)))].sort((P,I)=>P-I),K=D.length?D:[_],V=[0,...b.map(P=>P.y+P.h+k)].sort((P,I)=>P-I);let H=null;if(f){let P=1/0,I=1/0,U=-1/0,Z=-1/0;for(const te of b)P=Math.min(P,te.x),I=Math.min(I,te.y),U=Math.max(U,te.x+te.cw),Z=Math.max(Z,te.y+te.ch);const z=(te,le)=>{const de=i.width/(Math.max(U,te+M-_)-Math.min(P,te-R)+Ol),oe=i.height/(Math.max(Z,le+W-$)-Math.min(I,le));return[Math.min(ND,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(U+Ol+N+R),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===$&&(H=null)}else e:for(const P of K)for(const I of V){if(I>=$)break;if(T(P,I)){H={x:P,y:I};break e}}if(H){const P=H.x-_,I=H.y-$;for(const U of S){const Z=u(U.id);t.set(U.id,{x:Z.x+P,y:Z.y+I})}x.push(C)}for(const P of S){const I=u(P.id),{w:U,h:Z}=l(P.id);b.push({sid:C,x:I.x,y:I.y,w:U,h:Z,...h(P.id),note:!1})}if(R>0){const P=_+(H?H.x-_:0),I=$+(H?H.y-$:0);b.push({sid:C,x:P-R,y:I,w:If,h:fp,cw:If,ch:fp,note:!0})}}return x}function Hpe(e,t,n,s,a,o){const i=m=>xd(m,s,a),l=new Map(e.map(m=>[m.id,Tn(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:b,h:k}=i(m);u.push({x:w.x,y:w.y,w:b,h:k,sid:l.get(m)??"_default"})}const p=[];for(const{id:m,pos:w}of h){if(f(m))continue;const{w:b,h:k}=i(m),v=l.get(m)??"_default";if(n.has(m)){u.push({x:w.x,y:w.y,w:b,h:k,sid:v});continue}let N=w.y;for(let x=0;x<u.length+1;x++){const C=u.find(S=>{const _=S.sid===v?Lf:bD,$=S.sid===v?Lf:hp;return w.x<S.x+S.w+_&&S.x<w.x+b+_&&N<S.y+S.h+$&&S.y<N+k+$});if(!C)break;N=C.y+C.h+(C.sid===v?Lf:hp)}N!==w.y&&(t.set(m,{x:w.x,y:N}),p.push(m)),u.push({x:w.x,y:N,w:b,h:k,sid:v})}return p}function zpe(e,t,n,s,a,o=!1,i){const u=bD+1,h=hp+1,f=8,p=1.75,m=200,w=.7,b=.01,k=R=>xd(R,s,i),v=R=>n.get(R)??t.get(R),N=um(e,R=>v(R.id)!=null),x=[],C=new Set,S=new Set,_=a.size===0;for(const R of[...N.keys()].sort()){const q=N.get(R);let T=1/0,F=1/0,D=-1/0,K=-1/0,V=!1;for(const U of q){const Z=v(U.id),{w:z,h:X}=k(U.id);T=Math.min(T,Z.x),F=Math.min(F,Z.y),D=Math.max(D,Z.x+z),K=Math.max(K,Z.y+X),n.has(U.id)&&(V=!0)}const H=D-T,P=K-F;S.add(R);const I=a.get(R);I&&(H>I.w+f||P>I.h+f)&&C.add(R),a.set(R,{w:H,h:P}),x.push({sid:R,members:q.map(U=>U.id),x:T,y:F,w:H,h:P,anchored:V,mass:1})}for(const R of[...a.keys()])S.has(R)||a.delete(R);if(o||_)return[];let $=!1;for(let R=0;R<x.length&&!$;R++)for(let q=R+1;q<x.length;q++){const T=x[R],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){$=!0;break}}if(C.size===0&&!$)return[];if(C.size>0)for(const R of x)C.has(R.sid)&&(R.mass=8);else for(const R of x)R.mass=Math.max(1,R.w*R.h/(Zu*MN));const A=new Map(x.map(R=>[R.sid,R.x])),O=new Map(x.map(R=>[R.sid,R.y])),M=new Map(x.map(R=>[R.sid,Math.min(0,R.x)])),W=new Map(x.map(R=>[R.sid,Math.min(0,R.y)]));for(let R=0;R<m;R++){const q=new Map,T=new Map;let F=0;for(let D=0;D<x.length;D++)for(let K=D+1;K<x.length;K++){const V=x[D],H=x[K];if(V.anchored&&H.anchored)continue;const P=V.x+V.w/2,I=V.y+V.h/2,U=H.x+H.w/2,Z=H.y+H.h/2,z=(V.w+H.w)/2+u-Math.abs(P-U),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<=M.get(Ke.sid)),J=(Ke,ye)=>!Ke.anchored&&!(ye<0&&Ke.y<=W.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(P,U,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 D of x)D.anchored||(D.x=Math.max(M.get(D.sid),D.x+(q.get(D.sid)??0)),D.y=Math.max(W.get(D.sid),D.y+(T.get(D.sid)??0)));if(F<b)break}const B=[];for(const R of x){const q=R.x-A.get(R.sid),T=R.y-O.get(R.sid);if(!(Math.abs(q)<1&&Math.abs(T)<1)){for(const F of R.members){if(n.has(F))continue;const D=t.get(F);D&&t.set(F,{x:D.x+q,y:D.y+T})}B.push(R.sid)}}return B}const XF=160,Vpe=40,Gpe=80;function lO(e,t,n){const s=Ju(e,t),a=xd(e,t,n),o=a.w-s.w,i=Vpe+(t.has(e)?0:Gpe);return o>0?{w:s.w+Math.max(0,o+i-XF),h:a.h}:a}function Kpe(e,t,n,s,a,o){const i=new oO.graphlib.Graph;i.setDefaultEdgeLabel(()=>({})),i.setGraph({rankdir:n,marginx:0,marginy:0,nodesep:vD,ranksep:XF,edgesep:30});const l=e.filter(N=>!a.has(N)),u=new Set(l);for(const N of l){const{w:x,h:C}=lO(N,s,o);i.setNode(N,{width:x,height:C})}for(const N of t)u.has(N.source)&&u.has(N.target)&&i.setEdge(N.source,N.target);oO.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:C,h:S}=Ju(N,s),_=lO(N,s,o),$=x.x-_.w/2,A=x.y-_.h/2;h.set(N,{x:$,y:A}),$<f&&(f=$),A<p&&(p=A),$+C>m&&(m=$+C),A+S>w&&(w=A+S)}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 b=Number.isFinite(m)?m-f:0,k=Number.isFinite(w)?w-p:0;let v=null;for(const N of e){const x=a.get(N);if(!x)continue;const{w:C,h:S}=Ju(N,s);v=v===null?{minX:x.x,minY:x.y,maxX:x.x+C,maxY:x.y+S}:{minX:Math.min(v.minX,x.x),minY:Math.min(v.minY,x.y),maxX:Math.max(v.maxX,x.x+C),maxY:Math.max(v.maxY,x.y+S)}}return{positions:h,width:b,height:k,pinnedBox:v}}function ZF(e,t,n){const s=n.direction??"LR",a=n.pinned??new Map,o=n.measured??new Map,i=n.lanes,l=um(e);return{laid:Array.from(l.keys()).sort().map(f=>({sid:f,...Kpe(l.get(f).map(p=>p.id),t,s,o,a,i)})),gap:kD(e,o)}}const JF=e=>e.reduce((t,n)=>Math.max(t,n.width),0)+Ol,Ype=e=>e.reduce((t,n)=>t+n.height,0)+Il*Math.max(0,e.length-1);function wj(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=>tJ(f.reduce((p,m)=>p+JF(m),0)+t*(f.length-1),Math.max(...f.map(Ype)),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 Xpe(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}=ZF(e,t,n);return o.length<2?!1:wj(o,i,s.width,s.height).length!==wj(o,i,a.width,a.height).length}function Zpe(e,t,n={}){const s=n.pinned??new Map,{laid:a,gap:o}=ZF(e,t,n),i=wj(a,o,n.availableWidth??0,n.availableHeight??0),l=new Map;let u=0;for(const h of i){const f=JF(h);let p=0;for(const{positions:m,height:w,pinnedBox:b}of h){for(const[v,N]of m)l.set(v,{x:N.x+u,y:N.y+p});let k=p+w;b&&b.maxY>k&&b.minX<u+f&&u<b.maxX&&(k=b.maxY),p=k+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 Uf(e,t,n){return!t.has(e)||n.has(e)}function Jpe(e,t,n,s){return!t.has(e)&&Uf(e,n,s)}function Qpe(e,t,n){const s={x:0,y:0};return t.set(e,s),n.add(e),s}function cO(e,t,n,s){n.set(e,t),s.delete(e)}const uO=new WeakMap;function eme(e,t){let n=uO.get(e);(!n||n.revision!==e.revision||n.open!==t)&&(n={revision:e.revision,open:t,byId:new Map,branches:CK(e.agents.values()),groups:Yp(e.agents.values())},uO.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 IS(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 tme(e,t){const n=i=>Tn(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 nme(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 sme(e,t,n,s,a,o,i,l,u,h,f,p,m,w,b,k,v,N,x,C){var V,H,P,I;const S=[],_=[],$=eme(e,N);for(const U of e.agents.values()){if(!v.has(U.id))continue;const Z=U.exitAt!=null,z=k!=null&&!k.has(U.id),X=[Z?"rf-exiting":"",z?"rf-spotlit-out":"",b.has(U.id)?"rf-selected":""].filter(Boolean).join(" ")||void 0,Y=o.get(U.id);if(S.push({id:U.id,type:"agent",position:{x:0,y:0},data:$(U),className:X,ariaLabel:DG(U,t,b.has(U.id)),...Y?{width:Y.width,height:Y.height}:null}),U.parentId&&v.has(U.parentId)){const le=Gu(U.sessionId),de=Z,oe=b.size>0&&(b.has(U.id)||b.has(U.parentId)),re=k!=null&&!k.has(U.id)&&!k.has(U.parentId),he=U.state==="active"?2:1.5,pe=oe?he+1.5:he,Le=de?.2:re?.12:1,ge=["sess-edge",U.state==="active"?"sess-live":"sess-idle",de?"rf-edge-exiting":"",oe?"rf-edge-selected":""].filter(Boolean).join(" ");_.push({id:`e:${U.parentId}->${U.id}`,source:U.parentId,target:U.id,animated:(U.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=U.kind==="root"?DP(U):null,Q=(J==null?void 0:J.note)??null,te=J?J.key:null;if(J&&te&&!gK(te)){const le=yN(U.id),de=Gu(U.sessionId),oe=o.get(le);S.push({id:le,type:"recapNote",position:{x:0,y:0},data:{sessionId:U.sessionId,canvasSessionId:$(U).canvasSessionId,parentId:U.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 ${U.label}`:`${U.label}: ${rc(Q.kind)}`:`${U.label}: plan`,...oe?{width:oe.width,height:oe.height}:null}),_.push({id:`e:recap:${U.id}`,source:le,target:U.id,type:"recapTie",className:"recap-edge",focusable:!1,style:{"--session-hue":de}})}}const A=IS(e),O=C.size>0&&!(u&&x);O||C.clear();const M=S.filter(U=>U.data.provider==="codex"&&U.data.parentId).map(U=>`${U.id}:${Tn(U)}:${U.data.parentId}`).sort().join("|"),W=`${m}${M?`#codex:${M}`:""}#lanes:${rJ(A)}${O?"#held":""}`,B=new Set(S.filter(U=>U.type==="recapNote").map(U=>U.id));for(const U of Array.from(f.keys()))x&&vK(U)&&!B.has(U)&&!a.has(U)&&(f.delete(U),p.delete(U));const R=S.filter(U=>Jpe(U.id,a,f,p));if(R.length>0||W!==w.current){if(R.length>0){for(const Z of R)C.delete(Z.id);const U=Upe(Zpe(S,_,{direction:"LR",pinned:a,measured:o,availableWidth:n,availableHeight:s,lanes:A}),a,Z=>Uf(Z,f,p)?void 0:f.get(Z),Z=>xd(Z,o,A));for(const Z of U)Uf(Z.id,f,p)&&cO(Z.id,Z.position,f,p);Wpe(S,f,a,o,new Set(R.filter(Z=>Z.type!=="recapNote").map(Z=>Z.id)),A,{width:n,height:s});for(const Z of R){if(Z.type!=="recapNote")continue;const z=(V=Z.data)==null?void 0:V.parentId;if(!z)continue;const X=a.get(z)??(Uf(z,f,p)?void 0:f.get(z));if(!X)continue;const Y=((H=o.get(Z.id))==null?void 0:H.width)??If,J=((P=o.get(Z.id))==null?void 0:P.height)??fp,Q=((I=o.get(z))==null?void 0:I.height)??fp;cO(Z.id,{x:X.x-jD-Y,y:X.y+(Q-J)/2},f,p)}}Hpe(S,f,a,o,A,O?C:void 0),w.current=W}const q=zpe(S,f,a,o,i,!u||h,A);q.length>0&&l(q);const T=bde(e.agents.values());x&&kf(f,T),kf(p,T),x&&kf(a,T),kf(o,vde(e.agents.values()));const F=[];let D=!1;for(const U of S){let Z=a.get(U.id)??f.get(U.id);Z||(Z=Qpe(U.id,f,p),D=!0),F.push({...U,position:Z})}return D&&(w.current=""),{nodes:tme(F,U=>{if(U.type==="recapNote")return-1;const Z=e.agents.get(U.id);return Z?nme(e,Z):0}),edges:_}}function rme(e){return e.slice().sort((t,n)=>t.y-n.y||t.x-n.x)}function ame(e,t,n){var i;if(e.length===0)return null;const s=rme(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 ome=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Escape","Backspace"]);function ime(e,t){return t==null?{kind:"deck",nodeId:null}:e.key==="Enter"||e.key===" "?{kind:"activate",nodeId:t,additive:e.shiftKey}:ome.has(e.key)?{kind:"node",nodeId:t}:{kind:"deck",nodeId:t}}const lme=new Set(["","BODY","HTML","#DOCUMENT"]);function cme(e){return!e||ai(e)?!1:!lme.has(String(e.tagName??"").toUpperCase())}const QF="react-flow__node";function OS(e){var t,n;return!!e&&((n=(t=e.classList)==null?void 0:t.contains)==null?void 0:n.call(t,QF))===!0}function e8(e){try{const t=document.querySelector(`.${QF}[data-id="${CSS.escape(e)}"]`);t==null||t.focus({preventScroll:!0})}catch{}}let li=null,El=null;const xj=new Set,vj=()=>{for(const e of xj)e()},ume=e=>(xj.add(e),()=>{xj.delete(e)}),dO=()=>li,dme=90;function t8(e){!El||e!=null&&El.at.id!==e||(clearTimeout(El.timer),El=null)}function n8(e,t,n="pointer"){t8();const s={id:e,anchor:t,by:n};if(li||n==="focus"){li=s,vj();return}El={at:s,timer:setTimeout(()=>{El=null,li=s,vj()},dme)}}function io(e){t8(e),!(!li||e!=null&&li.id!==e)&&(li=null,vj())}function hme({agentFor:e,recapFor:t,labelFor:n,bounds:s}){const a=g.useSyncExternalStore(ume,dO,dO),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(pme,{a:o,anchor:a.anchor,parentLabel:o.parentId?n(o.parentId):void 0,bounds:s},a.id):i?r.jsx(fme,{r:i,anchor:a.anchor,bounds:s},a.id):null}function s8(e,t){const n=g.useRef(null),s=g.useCallback(()=>{const a=n.current;if(!a||!e.isConnected)return;a.style.maxHeight="";const o=hm(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 fme({r:e,anchor:t,bounds:n}){var h;const s=s8(t,n),a=_r(3e4),o=e.note,i=Cr(e.plan),l=(o==null?void 0:o.kind)==="recap",u=ap((o==null?void 0:o.at)??((h=e.plan)==null?void 0:h.at)??a,a);return vt.createPortal(r.jsxs("div",{ref:s,className:"ap-peek node-peek recap-peek",role:"tooltip",id:"node-peek",style:{"--session-hue":e.hue},children:[r.jsxs("div",{className:"node-peek-head",children:[r.jsxs("span",{className:"recap-peek-mark",children:[r.jsx(sp,{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?`${am(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 ",uN(i),i.allDone?"":`
107
- ${Kp(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 pme({a:e,anchor:t,parentLabel:n,bounds:s}){const a=s8(t,s),o=_r(1e3),i=tm(e.sessionName,e.sessionTitle),l=e.toolErrorCount??0,u=e.tools.filter(k=>!k.endedAt).length,h=Un(e,o).total,f=e.usage.inputTokens+e.usage.outputTokens,p=e.kind==="root"&&En(e.waiting),m=jP(e),w=e.kind==="root"?"session":n?`subagent of ${n}`:"subagent",b=[`${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 vt.createPortal(r.jsxs("div",{ref:a,className:"ap-peek node-peek",role:"tooltip",id:"node-peek",children:[r.jsxs("div",{className:"node-peek-head",children:[r.jsx("span",{className:"node-peek-name",title:e.label,children:e.label}),r.jsxs("span",{className:"node-peek-time",children:[e.synthetic?"≥ ":"",Kl(e.startedAt,e.endedAt,o)]})]}),r.jsxs("div",{className:"node-peek-kind",children:[r.jsxs("span",{className:"node-peek-state","data-kind":C1($l(e)),children:[r.jsx(VP,{kind:C1($l(e))}),Vl($l(e))]}),r.jsx("span",{children:w}),e.model?r.jsx("span",{children:Jp(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(bN,{}),r.jsxs("span",{className:"node-peek-said",title:tp(e.waiting),children:[r.jsx("span",{className:"node-peek-since",children:r.jsx("b",{children:Kl(e.waiting.since,void 0,o)})}),tp(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:[b,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:FP(e.branch)}),r.jsx("p",{className:"node-peek-hint",children:"Click to go to the session · double-click for details"})]}),document.body)}function mme(e){const t=e.minZoom??rde,n=e.maxZoom??ade,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,b,k,v,N,x)=>{let C=w+(b-v*p)/2-k*p;const S=N*p+C,_=(N+x)*p+C;return x*p<=b?S<w?C+=w-S:_>w+b&&(C-=_-(w+b)):C+=w-S,C};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 gme(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 Fn(e){const t=g.useRef(e);return t.current=e,t}const bj=80,kj=.86;function r8(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 yme({canvasRef:e,canvasSize:t,machinePhase:n,usagePhase:s,usagePanelOpen:a,detailShown:o}){const[i,l]=g.useState(0);g.useEffect(()=>{const p=r8(e.current);l(m=>Math.abs(m-p)>40?p:m)},[n,s,a,o,t.w]);const u=Fn(i),h=t.w>0?Math.max(0,(t.w-i-bj*2)*kj):0,f=t.h>0?Math.max(0,(t.h-bj*2)*kj):0;return{railInsetRef:u,availableWidth:h,availableHeight:f}}const hO=1e-6;function Pu(e){return Number.isFinite(e[0])&&Number.isFinite(e[1])&&Number.isFinite(e[2])&&e[2]>0}function fO(e,t,n){return Math.abs(e[2]-t[2])<=hO*t[2]&&Math.hypot(e[0]-t[0],e[1]-t[1])<=hO*n}function wme(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 xme(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 fO(s,t,i)&&fO(o,n,i)}function vme(e){return(t,n)=>{const s=e(t,n),a=xme(s,t,n)?s:wme(t,n);let o=Pu(t)?t:n;return i=>{const l=a(i);return Pu(l)&&(o=l),o}}}function bme(e){return Number.isFinite(e.x)&&Number.isFinite(e.y)&&Number.isFinite(e.zoom)&&e.zoom>0}const pO=new WeakSet,a8=420;function kme(){const e=ec(),t=Wt(),n=g.useCallback((h,f)=>{if(!bme(h))return;if(v1({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||pO.has(f)||(pO.add(f),f.interpolate(vme(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=v1({durationMs:f,documentHidden:document.hidden})?{target:h,until:Date.now()+f+60}:null,p},[n]),l=g.useCallback((h=500)=>{const f=bj,p=1,m=.2,w=kj;try{const b=document.querySelector(".canvas-wrap"),k=Array.from(document.querySelectorAll(".react-flow__node")).filter(F=>F.offsetWidth>0);if(!b||k.length===0)return;const v=b.getBoundingClientRect(),N=e.getViewport();if(!Number.isFinite(N.zoom)||N.zoom<=0)return;const x=new Map(e.getNodes().map(F=>[F.id,F])),C=k.flatMap(F=>{const D=x.get(F.dataset.id??"");if(!D)return[];const K=D.positionAbsolute??D.position,V=D.width??F.offsetWidth,H=D.height??F.offsetHeight;return V>0&&H>0?[{left:K.x,right:K.x+V,top:K.y,bottom:K.y+H}]:[]});if(C.length===0)return;const S=Math.min(...C.map(F=>F.left)),_=Math.max(...C.map(F=>F.right)),$=Math.min(...C.map(F=>F.top)),A=Math.max(...C.map(F=>F.bottom)),O=_-S,M=A-$;if(!(O>0&&M>0))return;const W=r8(b),B=F=>Math.max(m,Math.min(p,(v.width-W-f*2)/(O+F)*w,(v.height-f*2)/M*w)),R=sde(B(a8),B(0),G6(UN[WN()])),q={x:f-S*R,y:(v.height>v.width-W?f:Math.max(f,(v.height-M*R)/2))-$*R,zoom:R},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 D=e.getViewport();(Math.abs(D.zoom-R)>.01||Math.abs(D.x-q.x)>2||Math.abs(D.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 jme=450;function Nme({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(b=>{const k=e.current,v=t.current.agents.get(b);if(!k||!v)return;const N=IS(t.current),x=(O,M)=>{const W=n.current.get(O.id);if(!W)return null;const B=M&&N.has(O.id)?a8:0;return{x:O.position.x,y:O.position.y,width:W.width+B,height:W.height}},C=s.current.find(O=>O.id===b),S=C?x(C,!1):null;if(!S)return;const _=[];for(const O of s.current){if(O.type!=="agent"&&O.type!=="recapNote"||Tn(O)!==Tn(C))continue;const M=x(O,O.type==="agent");M&&_.push(M)}const $=k.getBoundingClientRect(),A=mme({pane:{width:$.width,height:$.height},insets:{top:56,left:72,bottom:32,right:a.current+32},context:gme(_)??S,anchor:S});io(),i(),l.current={id:b,at:Date.now()},o(A,jme)},[o,i]);u.current=p;const m=g.useCallback(b=>{const k=s.current.filter(C=>C.type==="agent"),v=ame(k.map(C=>({id:C.id,x:C.position.x,y:C.position.y})),f.current,b),N=v?k.find(C=>C.id===v):void 0;if(!N)return;const x=OS(document.activeElement);h(N.id,!1),window.setTimeout(()=>{try{p(N.id)}catch{}x&&e8(N.id)},30)},[h,p]),w=g.useCallback(b=>{h(b,!1),window.setTimeout(()=>{try{p(b)}catch{}},60)},[h,p]);return{focusAgent:p,stepAgent:m,focusSession:w}}function Sme({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 Cme(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 mO(e){return Object.entries(e??{}).filter(([,t])=>t&&typeof t.x=="number"&&typeof t.y=="number")}function _me(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=mO(n);return{positions:a,pins:a.map(([o])=>o)}}const s=n;return{positions:mO(s.positions),pins:Array.isArray(s.pins)?s.pins:[]}}function Eme(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 Tme(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 Td="agent-dag.layout",Ad="agent-dag.layoutFrame",Rd="agent-dag.viewport";function Ame(){return _me(nt(Td))}function Fl(e,t){st(Td,Eme(e,t))}function Rme(){return Tme(nt(Ad))}function o8(e){st(Ad,JSON.stringify(e))}function Mme(){return $9(nt(Rd))}function $me(e){st(Rd,JSON.stringify(e))}function Lme(){return{layout:nt(Td),frame:nt(Ad),viewport:nt(Rd)}}function Ime(e){const t=(n,s)=>s===null?ks(n):st(n,s);t(Td,e.layout),t(Ad,e.frame),t(Rd,e.viewport)}function i8(){ks(Td),ks(Rd),ks(Ad)}function Ome({fitLeft:e,moveCamera:t,currentViewport:n}){const s=g.useState(()=>Cme(Ame()))[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(Rme)[0],p=g.useRef(f),[m,w]=g.useState(!1),[b,k]=g.useState(""),v=g.useState(()=>VZ(M=>{w(M),M||k(W=>W===JT?W:"")}))[0];g.useEffect(()=>()=>v.close(),[v]),g.useEffect(()=>{if(typeof document>"u")return;const M=()=>document.hidden?v.hold("hidden"):v.release("hidden");return document.addEventListener("visibilitychange",M),()=>document.removeEventListener("visibilitychange",M)},[v]);const N=g.useRef(null),x=()=>({positions:o.current,pinned:a.current,provisional:i.current,layoutSig:l}),C=g.useCallback(()=>{v.open(v.snapshot??FZ(x(),Lme(),n())),k(HZ),a.current.clear(),o.current.clear(),l.current="",i8(),h(M=>M+1),N.current!=null&&window.clearTimeout(N.current),N.current=window.setTimeout(()=>{N.current=null,Fl(o.current,a.current),p.current&&o8(p.current),e(500)},80)},[e,n,v]),S=g.useCallback(()=>{const M=v.take();return M?(N.current!=null&&window.clearTimeout(N.current),N.current=null,BZ(M,x()),Ime(M.stored),h(W=>W+1),M.viewport&&t(M.viewport,500),k(JT),!0):!1},[t,v]),_=g.useCallback(()=>v.close(),[v]),$=g.useCallback(M=>v.hold(M),[v]),A=g.useCallback(M=>v.release(M),[v]);return{restoredLayout:s,pinnedRef:a,positionsRef:o,provisionalRef:i,lastLayoutSigRef:l,layoutEpoch:u,setLayoutEpoch:h,lastLayoutFrameRef:p,handleRelayout:C,rearrangeUndo:{open:m,said:b,undo:S,dismiss:_,hold:$,release:A}}}function Pme(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 Dme({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:b}){const{lastLayoutFrameRef:k,pinnedRef:v,positionsRef:N,provisionalRef:x,lastLayoutSigRef:C,setLayoutEpoch:S}=i,{applyViewport:_,fitLeft:$,cameraEpochRef:A,lastFitTimeRef:O}=l;g.useEffect(()=>{if(!n||s)return;const M={width:a,height:o};if(!(M.width>0&&M.height>0))return;const W=k.current;if(k.current=M,o8(M),!W||W.width===M.width&&W.height===M.height)return;const B={direction:"LR",pinned:v.current,measured:h.current,lanes:IS(f.current)},R=p.current&&Date.now()-p.current.at<1500?p.current.id:null;if(!Xpe(e,t,B,W,M)){const F=A.current,D=window.setTimeout(()=>{var K;A.current===F&&(b.current?R&&((K=p.current)==null?void 0:K.id)===R&&w.current(R):$(500))},80);return()=>window.clearTimeout(D)}const q=R??m.current,T=q?v.current.get(q)??N.current.get(q):void 0;for(const F of Array.from(N.current.keys()))v.current.has(F)||N.current.delete(F);x.current.clear(),C.current="",S(F=>F+1),window.setTimeout(()=>{if(Fl(N.current,v.current),b.current){if(R){w.current(R);return}const F=q?v.current.get(q)??N.current.get(q):void 0;if(T&&F&&(F.x!==T.x||F.y!==T.y)){const D=u.getViewport();A.current+=1,_({x:D.x-(F.x-T.x)*D.zoom,y:D.y-(F.y-T.y)*D.zoom,zoom:D.zoom},0),O.current=Date.now()}return}$(500)},80)},[a,o,n,s,$,u,_])}function Fme(e,t,n,s,a){const o=[];for(const i of e)!dm(i,t)||n.has(i.id)||o.push(i.id+(i.parentId?`>${i.parentId}`:""));return o.sort(),`${o.join("|")}#sv${s}.${a}`}const PS="agent-dag.removedNodes";function Bme(e){try{const t=JSON.parse((e==null?void 0:e.getItem(PS))??"[]");return new Set(Array.isArray(t)?t.filter(n=>typeof n=="string"):[])}catch{return new Set}}function U0(e,t){try{e==null||e.setItem(PS,JSON.stringify([...t]))}catch{}}function l8(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 qme(e,t){if(t.size===0)return new Set;const n=[...e],s=l8(n,t);return new Set(n.filter(s).map(a=>a.id))}function Ume(e,t,n){const s=l=>({id:l.id,parentId:l.data.parentId,sessionId:l.data.sessionId}),a=l8(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 Wme(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 Hme(e,t){return t.size===0?[]:[...e].filter(n=>t.has(n.id)).map(n=>n.id)}function zme(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 Vme(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 Gme(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=zme(l);if(u<=a)continue;const h=[],f=new Set,p=w=>{var b;for(let k=w;k&&!f.has(k);k=(b=e.get(k))==null?void 0:b.parentId)f.add(k),n.has(k)&&h.push(k)};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 Ap="sessionGroup";function Kme(e,t){var s,a;if(e.type===Ap)return"transparent";if(En((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 jf=ti;function Yme(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(Tn(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(Tn(s),{minX:l,minY:u,maxX:h,maxY:f})}const n=[];for(const[s,a]of t){const o=a.maxX-a.minX+jf*2,i=a.maxY-a.minY+jf*2;n.push({id:`group:${s}`,type:Ap,position:{x:a.minX-jf,y:a.minY-jf},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 Xme(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 Zme(e,t){const n=new Set;for(const s of t){const a=Xme(e,s);if(a)for(const o of a)n.add(o)}return n.size>0?n:null}function Jme({stateRef:e,now:t,removedAgentIds:n,sizeVersion:s,domSizeVersion:a}){return g.useMemo(()=>Fme(e.current.agents.values(),t,n,s,a),[e.current,e.current.revision,t,s,a,n])}function Qme({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:b,dragTick:k,dragPatchRef:v,dragMoveTick:N}){const{pinnedRef:x,positionsRef:C,provisionalRef:S,lastLayoutSigRef:_,restoredLayout:$,layoutEpoch:A}=a,O=g.useMemo(()=>Zme(e.current,f),[e.current,e.current.revision,f]),M=g.useMemo(()=>{const D=QJ(e.current,t);for(const K of b)D.delete(K);return D},[e.current,e.current.revision,t,b]),W=g.useRef(new Map),B=bK(),{nodes:R,edges:q}=g.useMemo(()=>{const D=sme(e.current,t,n,s,x.current,o.current,W.current,i,l,u,C.current,S.current,h,_,f,O,M,p,m,$.restored);return Ume(D.nodes,D.edges,w)},[e.current,e.current.revision,t,n,s,l,u,h,f,O,M,p,k,B,w,A,m]),T=g.useMemo(()=>Yme(R),[R]),F=g.useMemo(()=>{const D=[...T,...R],K=v.current;return!K||K.size===0?D:D.map(V=>{const H=K.get(V.id);return H?{...V,position:H}:V})},[T,R,N]);return{spotlightSet:O,visibleAgentIds:M,nodes:R,edges:q,allNodes:F}}function ege(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 tge({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,ege(a,t,e))return!1;return s}function nge({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 b=n.current,k=Date.now(),v=[];for(const x of b.agents.values())dm(x,k)&&v.push({id:x.id});if(v.length===0)return;const N=[];for(const{id:x}of v){const C=s.current.get(x),S=a.current.get(x)??o.current.get(x);!C||!S||N.push({x:S.x,y:S.y,width:C.width,height:C.height})}tge({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 sge({stateRef:e,pinnedRef:t,positionsRef:n,canvasRef:s,clearSelection:a,primarySelectedId:o}){const[i,l]=g.useState(()=>Bme(wr())),[u,h]=g.useState(null),f=g.useMemo(()=>qme(e.current.agents.values(),i),[e.current,e.current.revision,i]),p=g.useCallback(x=>{const C=e.current.agents.get(x);C&&(l(S=>{const _=new Set(S);return _.add(x),U0(wr(),_),_}),h({id:x,label:C.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 b=g.useCallback(x=>{const C=[...x];l(S=>{let _=null;for(const $ of C)S.has($)||(_??(_=new Set(S)),_.add($));return _?(U0(wr(),_),_):S});for(const S of C)t.current.delete(S),n.current.delete(S)},[]),k=g.useCallback(x=>{const C=[...x];l(S=>{const _=Wme(S,C);return _!==S&&U0(wr(),_),_})},[]),v=g.useCallback(()=>{k([...i]),h(null)},[k,i]),N=g.useCallback(()=>{l(new Set),h(null),ks(PS)},[]);return{removedNodes:i,lastRemoval:u,removedAgentIds:f,removeNode:p,removeSelectedNode:m,removalNotice:w,hideSessions:b,bringBack:k,bringBackAll:v,forgetRemovals:N}}function rge({stateRef:e,waitingSessions:t,removedAgentIds:n,removedNodes:s,bringBack:a}){const o=g.useRef(new Map);g.useEffect(()=>{o.current=Vme(o.current,s,Date.now());const i=[...Hme(t,n),...Gme(e.current.agents,n,s,o.current)];i.length>0&&a(i)},[t,n,s,a])}const c8=[0,5,15,30,60],DS="agent-dag.hide-finished-after",u8="agent-dag.hide-finished-turns",age=300,oge=1e4;function FS(e){const t=Number(e);return c8.includes(t)?t:0}function ige(e){return e===0?"Never":`${e} min`}let ci=null;const Cu=new Set;function d8(){for(const e of Cu)e()}function gO(){return ci===null&&(ci=FS(nt(DS))),ci}function lge(e){const t=FS(String(e));ci!==t&&(ci=t,st(DS,String(t)),d8())}function yO(e){if(e.key!==DS)return;const t=FS(e.newValue);t!==ci&&(ci=t,d8())}function cge(e){var t;return Cu.add(e),Cu.size===1&&typeof window<"u"&&((t=window.addEventListener)==null||t.call(window,"storage",yO)),()=>{var n;Cu.delete(e),Cu.size===0&&typeof window<"u"&&((n=window.removeEventListener)==null||n.call(window,"storage",yO))}}function uge(e){try{const t=JSON.parse((e==null?void 0:e.getItem(u8))??"{}");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 wO(e,t){const n=[...t].sort((s,a)=>a[1]-s[1]).slice(0,age);try{e==null||e.setItem(u8,JSON.stringify(Object.fromEntries(n)))}catch{}}function h8(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"&&En(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 dge(e,{afterMs:t,now:n,removed:s,handled:a,keep:o}){if(t<=0)return[];const i=[];for(const[l,u]of h8(e))n-u<t||s.has(l)||l===o||a.get(l)!==u&&i.push({id:l,endedAt:u});return i}function hge(e,t,n,s){const a=[...t].filter(l=>!n.has(l));if(a.length===0)return e;const o=h8(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 f8(){return g.useSyncExternalStore(cge,gO,gO)}function fge({stateRef:e,removedNodes:t,hideSessions:n,keepSessionId:s,ready:a}){const o=f8(),[i]=g.useState(()=>uge(wr())),l=g.useRef(i),u=g.useRef(t);g.useEffect(()=>{const h=hge(l.current,u.current,t,e.current.agents.values());u.current=t,h!==l.current&&(l.current=h,wO(wr(),h))},[t]),g.useEffect(()=>{if(!a||o===0)return;const h=()=>{const p=dge(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:b}of p)m.set(w,b);l.current=m,wO(wr(),m),n(p.map(w=>w.id))};h();const f=window.setInterval(h,oge);return()=>window.clearInterval(f)},[a,o,t,s,n])}function pge({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 p8=Object.freeze({offline:"/state/favicon-error.svg",waiting:"/state/favicon-waiting.svg",running:"/state/favicon-syncing.svg",idle:"/favicon.svg"}),m8=Object.freeze({offline:"/state/favicon-error-32.png",waiting:"/state/favicon-waiting-32.png",running:"/state/favicon-syncing-32.png",idle:"/favicon.ico"}),mge=Object.freeze([...new Set([...Object.values(p8),...Object.values(m8)])]),jj=new Map;function xO(e){return jj.get(e)??e}async function gge(e,t=n=>fetch(n)){await Promise.all(e.map(async n=>{if(!jj.has(n))try{const s=await t(n),a=(s.headers.get("Content-Type")??"").split(";")[0].trim();if(!s.ok||!a.startsWith("image/"))return;jj.set(n,`data:${a};base64,${yge(new Uint8Array(await s.arrayBuffer()))}`)}catch{}}))}function yge(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function wge({stateRef:e,waitingSessions:t,live:n}){const s=g.useMemo(()=>jG(e.current.agents.values()),[e.current,e.current.revision]),a=g.useRef(null);g.useEffect(()=>{n&&gge(mge)},[n]),g.useEffect(()=>{const o=pge({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&&g8(o.icon)},[t.length,s,n])}function g8(e){const t=document.querySelector('link[rel="icon"][type="image/svg+xml"]');t&&(t.href=xO(p8[e]));const n=document.querySelector('link[rel="icon"][sizes="32x32"]');n&&(n.href=xO(m8[e]))}const xge=1200,vge=1e3;function W0(e){return e.lastDeckFitAt>0&&e.at-e.lastDeckFitAt<xge?!1:e.hasSourceEvent?!0:e.lastCanvasInputAt>0&&e.at-e.lastCanvasInputAt<vge}function bge({applyViewport:e,lastFitTimeRef:t,cameraEpochRef:n,disableAutoFit:s,markInteract:a,canvasRef:o,applyZoom:i}){const l=g.useState(()=>Mme())[0];g.useEffect(()=>{if(!l)return;const b=window.setTimeout(()=>{try{e(l,0)}catch{}t.current=Date.now()},60);return()=>window.clearTimeout(b)},[e,l]);const u=g.useRef(null),h=g.useRef(0),f=g.useCallback(()=>{h.current=Date.now()},[]),p=g.useCallback(b=>({hasSourceEvent:!!b,at:Date.now(),lastDeckFitAt:t.current,lastCanvasInputAt:h.current}),[]);return{restoredViewport:l,markCanvasInput:f,onMoveStart:b=>{io(),W0(p(b))&&(n.current+=1),W0(p(b))&&s()},onMove:(b,k)=>{var v;a(),W0(p(b))&&s(),(v=o.current)==null||v.style.setProperty("--zoom",String(k.zoom)),i(k.zoom)==="detail"&&io(),u.current&&window.clearTimeout(u.current),u.current=window.setTimeout(()=>$me(k),250)}}}function kge({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(()=>_D({focus:k=>u.current(k),setTimeout:(k,v)=>window.setTimeout(k,v),clearTimeout:k=>window.clearTimeout(k)}));return g.useEffect(()=>()=>h.cancel(),[h]),{onNodeClick:(k,v)=>{if(v.type==="sessionGroup"){h.cancel(),e();return}const N=v.type==="recapNote"?v.data.parentId:v.id;t(N,k.shiftKey,!1),!k.shiftKey&&(n&&s(!1),md()?h.hold(N):a?window.setTimeout(()=>{try{o(N)}catch{}},80):o(N))},onPaneClick:()=>{h.cancel(),io(),e()},onNodeDoubleClick:(k,v)=>{if(v.type!=="agent"&&v.type!=="recapNote")return;h.cancel();const N=v.type==="recapNote"?v.data.parentId:v.id;t(N,!1),window.setTimeout(()=>{try{o(N)}catch{}},80)},onNodeMouseEnter:(k,v)=>{v.type!=="agent"&&v.type!=="recapNote"||i.current||l.current==null||l.current==="detail"||n8(v.id,k.currentTarget)},onNodeMouseLeave:(k,v)=>io(v.id)}}function jge({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 Nge(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=jge({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 Sge(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 b of t.getState().nodeInternals.values()){if(b.type===Ap)continue;const k=b.width,v=b.height;if(k==null||v==null)continue;const N=a.current.get(b.id);(!N||Math.abs(N.width-k)>4||Math.abs(N.height-v)>4)&&(a.current.set(b.id,{width:k,height:v}),n.current.set(b.id,{width:k,height:v}),m=!0)}if(m&&(s.current+=1,i(s.current)),e.current)return;let w=!1;for(const b of document.querySelectorAll(".react-flow__node[data-id]")){if(b.classList.contains(`react-flow__node-${Ap}`))continue;const k=b.getAttribute("data-id");if(!k)continue;const v=b.offsetWidth,N=b.offsetHeight;if(!v||!N)continue;const x=n.current.get(k);(!x||Math.abs(x.width-v)>4||Math.abs(x.height-N)>4)&&(n.current.set(k,{width:v,height:N}),w=!0)}w&&u(b=>b+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 Cge(){const[e,t]=g.useState(!1);return g.useEffect(()=>{const n=window.setTimeout(()=>t(!0),2500);return()=>window.clearTimeout(n)},[]),e}function _ge(){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 Ege({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:b,focusSession:k,requestClear:v,handleRelayout:N,undoRearrange:x,handleFit:C,togglePause:S,toggleSessionList:_,toggleAccountsPanel:$,setDetailOpen:A,setUsageHistoryOpen:O,setUsagePanelOpen:M,setMachinePanelOpen:W,setBrowserWatchOpen:B,setKeyHelpOpen:R,setTheme:q,openSettings:T,openIntegrationRef:F,openQuickOpen:D}){g.useEffect(()=>{const K=V=>{var z,X;const H=V.target,P={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=zG({overlayOpen:rn.depth()>0,typing:ai(P)});Y==="dismiss"?rn.dismissTop():Y==="blur"?H==null||H.blur():(cme(P)&&(H==null||H.blur()),p());return}if(ID(V,po(ro()))){if(wl({appModal:l.current,dialogDepth:rn.dialogDepth()}))return;V.preventDefault(),V.repeat||D();return}if(V.key===","&&mee(V)){if(ai(P)||wl({appModal:l.current,dialogDepth:rn.dialogDepth()}))return;V.preventDefault(),V.repeat||T();return}if(GZ(V)){if(ai(P)||wl({appModal:l.current,dialogDepth:rn.dialogDepth()}))return;!V.repeat&&x()&&V.preventDefault();return}if(sm(V))return;const I=OS(H)?(X=H==null?void 0:H.getAttribute)==null?void 0:X.call(H,"data-id"):null,U=I&&t.current.some(Y=>Y.id===I)?I:null,Z=ime(V,U);if(Z.kind==="activate"){V.preventDefault(),m(Z.nodeId,Z.additive);return}if(Z.kind!=="node"&&!IY(V.key,R1())){if(eK({key:V.key,sheetOpen:i.current,target:P})){V.repeat||R(!1);return}if(V.key==="t"||V.key==="T"){const Y=wl({appModal:l.current,dialogDepth:rn.dialogDepth()});if(Z.nodeId==null&&tK({target:P,modalOpen:Y}))return;V.repeat||q(ite);return}if(!(Z.nodeId==null&&RP(P,V.key))&&!QG({key:V.key,modalOpen:wl({appModal:l.current,dialogDepth:rn.dialogDepth()}),sheetOpen:i.current})&&!(V.repeat&&!/^[ jkJK]$/.test(V.key))){if(V.key===" "&&(V.preventDefault(),V.repeat||S()),(V.key==="c"||V.key==="C")&&v("shortcut"),(V.key==="r"||V.key==="R")&&N(),(V.key==="f"||V.key==="F")&&C(),(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)A(Y=>!Y);else{const Y=N1(n.current.agents.values());Y.length>0?k(Y[0].id):b(1)}if((V.key==="h"||V.key==="H")&&O(Y=>!Y),(V.key==="u"||V.key==="U")&&M(Y=>!Y),(V.key==="a"||V.key==="A")&&a.current.claude&&$(),(V.key==="j"||V.key==="J")&&b(1),(V.key==="k"||V.key==="K")&&b(-1),V.key==="w"||V.key==="W"){const Y=kG(N1(n.current.agents.values()),u.current);Y&&(u.current=Y.id,k(Y.id))}(V.key==="m"||V.key==="M")&&o.current!==null&&f.current(V.shiftKey),(V.key==="s"||V.key==="S")&&W(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==="?"&&R(Y=>!Y)}}};return window.addEventListener("keydown",K),()=>window.removeEventListener("keydown",K)},[v,N,x,C,p,m,b,k,w,S])}function Tge(){var e,t;return((t=(e=document.activeElement)==null?void 0:e.matches)==null?void 0:t.call(e,":focus-visible"))===!0}function Age({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=>()=>{Tge()&&h()};return{toggles:l,sessionList:u(na(!e,l.sessionList)),usage:u(na(!t,l.usage)),machine:u(na(!n,l.machine)),accounts:u(na(!s,l.accounts)),detail:u(na(!a,()=>{var h,f;o&&e8(o),Wn(((h=document.activeElement)==null?void 0:h.tagName)??null)&&((f=i.current)==null||f.focus({preventScroll:!0}))}))}}function Rge({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:b,removeNode:k}){const v=g.useRef(null);return{onNodeDragStart:(S,_)=>{var $,A;if(_){if(io(),h(),a.current=!0,o.current=new Map,i(!0),f(),p(),_.type==="sessionGroup"){const O=($=_.data)==null?void 0:$.sessionId,M=new Map,W=new Map;if(O)for(const R of e)!R.data||Tn(R)!==O||(M.set(R.id,{x:R.position.x,y:R.position.y}),W.set(R.id,n.current.get(R.id)));v.current={sessionId:O,start:{x:_.position.x,y:_.position.y},members:M,pinsBefore:W};const B=O?t.current.agents.get(O):void 0;m(B?B.label:null);return}m(_.type==="agent"?((A=t.current.agents.get(_.id))==null?void 0:A.label)??"":null),n.current.set(_.id,{x:_.position.x,y:_.position.y})}},onNodeDrag:(S,_)=>{var $;if(_){if(f(),(_.type==="agent"||_.type==="sessionGroup")&&w(S),_.type==="sessionGroup"){const A=v.current;if(!A)return;const O=_.position.x-A.start.x,M=_.position.y-A.start.y;for(const[B,R]of A.members){const q={x:R.x+O,y:R.y+M};n.current.set(B,q),s.current.set(B,q)}const W=o.current;if(W){for(const[B,R]of A.members)W.set(B,{x:R.x+O,y:R.y+M});W.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}),($=o.current)==null||$.set(_.id,{x:_.position.x,y:_.position.y}),l(A=>A+1)}},onNodeDragStop:(S,_)=>{f();const $=b(S,(_==null?void 0:_.type)==="agent"||(_==null?void 0:_.type)==="sessionGroup");if(a.current=!1,o.current=null,i(!1),u(A=>A+1),!_){v.current=null,Fl(s.current,n.current);return}if(_.type==="sessionGroup"){const A=v.current;if(A&&$&&A.sessionId){for(const[O,M]of A.members){const W=A.pinsBefore.get(O);W?n.current.set(O,W):n.current.delete(O),s.current.set(O,M)}v.current=null,k(A.sessionId);return}if(A){const O=_.position.x-A.start.x,M=_.position.y-A.start.y;for(const[W,B]of A.members){const R={x:B.x+O,y:B.y+M};n.current.set(W,R),s.current.set(W,R)}}v.current=null,Fl(s.current,n.current),u(O=>O+1);return}if(n.current.set(_.id,{x:_.position.x,y:_.position.y}),s.current.set(_.id,{x:_.position.x,y:_.position.y}),$){k(_.id);return}Fl(s.current,n.current)}}}function Mge(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 y8({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 $ge({reservedRight:e=0}){return r.jsx("div",{className:"empty-stage",style:{right:e},children:r.jsxs("div",{className:"empty-hero",children:[r.jsx(y8,{}),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 Lge({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(y8,{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."]})]}):Ige(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 Ige(e,t){const n=Mge(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?"}),wse(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 Oge=1;function Pge(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 Dge(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:Oge,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(Pge)}))}}function Fge(e,t){const n=(e||"session").replace(/[^a-z0-9._-]/gi,"_");return`${Pt}-${n}-${dp(t,8)}.json`}const w8={file:"📁",shell:"⚡",web:"🌐",agent:"🤖",task:"📋",plan:"🧭",mcp:"🔌",other:"✨"},Bge={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 qge({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:Bge[e]})})}const Rp={file:"file",shell:"shell",web:"web",agent:"agent",task:"task",plan:"plan",mcp:"mcp",other:"other"},x8=qP;function Uge({agent:e,now:t,onOpenTool:n,onShowSummary:s,onExportSession:a,onRemove:o,singleKeys:i=!0}){var v;const l=`${e.synthetic?"≥ ":""}${Kl(e.startedAt,e.endedAt,t)}`,u=Un(e),h=u.total>0,f=e.usage.inputTokens+e.usage.outputTokens,p=new Map;for(const[N,x]of e.toolCountByName??[]){const C=x8(N);p.set(C,(p.get(C)??0)+x)}const m=e.toolErrorCount??0,w=e.tools.filter(N=>!N.endedAt).length,b=Array.from(p.entries()).sort((N,x)=>x[1]-N[1]),k=p.has("mcp")?sY(((v=e.toolCountByName)==null?void 0:v.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:em(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=pN(e);return r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"hero-sep",children:"·"}),r.jsxs("span",{className:"model-chip","data-family":Zp(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:[Jp(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(GN,{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; ${_n("the session list","L",i)} brings it back`:`Take this card and the ones under it off the board (Delete). ${_n("The session list","L",i)} brings it back`,children:"Remove from board"})]})]}),r.jsx(NY,{agent:e}),(()=>{const N=wN(e);if(!N)return null;const x=ap(N.at,t),C=N.kind==="recap"?"Recap":rc(N.kind).replace(/^./,S=>S.toUpperCase());return r.jsxs("section",{className:"detail-section",children:[r.jsxs("h3",{children:[C," ",r.jsx("span",{className:"section-count",title:x.title,children:x.label})]}),r.jsx("p",{className:"detail-recap",title:am(N),children:N.text}),N.reply&&r.jsxs("p",{className:"detail-recap detail-note-reply",children:["Suggested reply: “",N.reply,"”"]})]})})(),(()=>{const N=Cr(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,C)=>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:[Vge[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??`${C}:${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:b.map(([N,x])=>{const C=N==="mcp"?k:null,S=C==null?void 0:C.hue,_=`${x} ${Rp[N]} call${x===1?"":"s"}`;return r.jsxs("span",{className:`cat-chip cat-${N}${S!=null?" mcp-hue":""}`,style:S!=null?{"--mcp-hue":S}:void 0,title:C?`${_}, all to ${C.label}`:_,children:[r.jsx("span",{className:"cat-emoji","aria-hidden":!0,children:w8[N]}),r.jsx("span",{className:"cat-name",children:Rp[N]}),r.jsx("span",{className:"cat-count",children:x}),C&&r.jsx("span",{className:"cat-server",children:C.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:tP(e.prompts).length})]}),r.jsx("div",{className:"prompts",children:Wge(e.prompts).reverse().map(({pr:N,key:x})=>{const C=ap(N.at,t),S=Gp(N.text);return S?r.jsxs("details",{className:"prompt-entry prompt-injected",children:[r.jsxs("summary",{children:[r.jsx("span",{className:"prompt-time",title:C.title,children:C.label}),r.jsx("span",{className:"prompt-injected-label",children:S.label})]}),S.detail&&r.jsx("div",{className:"prompt-injected-detail",children:S.detail})]},x):r.jsxs("div",{className:"prompt-entry",children:[r.jsx("div",{className:"prompt-time",title:C.title,children:C.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(zge,{t:N,onClick:()=>n(e.id,N.id)},N.id))})]})]})}function Wge(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 Hge={inflight:"in-flight",done:"done",err:"error"};function zge({t:e,onClick:t}){const n=e.endedAt==null?"inflight":e.ok===!1?"err":"done",s=EP(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:Hge[n]}),e.name]}),r.jsx("span",{style:{color:"var(--muted)"},children:s})]})}const Vge={completed:"done",in_progress:"now",pending:"to do"};function Gge(e,t){const n=Dge(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=Fge(n.label,t),document.body.appendChild(i),i.click(),document.body.removeChild(i),setTimeout(()=>URL.revokeObjectURL(o),1e3)}function Kge({selected:e,now:t,openTool:n,setSummaryFor:s,onClose:a,stateRef:o,removeSelectedNode:i}){an("detail-panel");const l=An();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(Uge,{agent:e,now:t,onOpenTool:n,onShowSummary:s,onExportSession:u=>Gge(o.current,u),onRemove:i,singleKeys:l})]})}function Yge(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 Nf(e,t){return t.map(n=>({...n,group:e}))}function Xge({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:b,openToolActivity:k,openSettings:v,onFeedback:N,toggles:x,openCapacity:C,integrations:S=[],openExploreIntegrations:_,openQuickOpen:$}){const A=gee(ro()),O=po(ro()),M={id:"session-list",label:"Session list",short:"Sessions",key:{cap:"L",aria:"L",single:!0},ariaLabel:"Session list",glyph:r.jsx(pQ,{}),kind:"panel",open:t,controls:"session-list",onPress:n,buttonRef:x.sessionList},W={id:"accounts",label:"Accounts",short:"Accounts",key:{cap:"A",aria:"A",single:!0},ariaLabel:"Accounts",hint:"Claude accounts",glyph:r.jsx(gQ,{}),kind:"panel",open:s,controls:"accounts-panel",onPress:a,buttonRef:x.accounts},B=C?[{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(TQ,{}),kind:"dialog",onPress:()=>C("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(AQ,{}),kind:"dialog",onPress:()=>C("calendar")}]:[],R={id:"usage",label:"Usage",short:"Usage",key:{cap:"U",aria:"U",single:!0},ariaLabel:"Usage",glyph:r.jsx(yQ,{}),kind:"panel",open:o,controls:"usage-panel",onPress:()=>i(U=>!U),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(xQ,{}),kind:"panel",open:l,controls:"system-panel",onPress:()=>u(U=>!U),buttonRef:x.machine},T={id:"history",label:"Usage history",short:"History",key:{cap:"H",aria:"H",single:!0},ariaLabel:"Usage history",glyph:r.jsx(wQ,{}),kind:"dialog",onPress:()=>h(U=>!U)},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:Yge(f,p),glyph:r.jsx(bQ,{watching:f===!0||p>0}),kind:"dialog",onPress:()=>m(U=>!U),badge:p},D={id:"settings",label:"Settings",short:"Settings",key:{cap:A,aria:"Control+, Meta+,",single:!1},ariaLabel:"Settings",glyph:r.jsx(kQ,{}),kind:"dialog",onPress:()=>v()},K={id:"quick-open",label:"Search",short:"Search",key:{cap:fQ(O),aria:O?"Meta+K":"Control+K",single:!1},ariaLabel:"Search",detail:"Panels, sessions, settings, actions and themes",glyph:r.jsx(PD,{}),kind:"dialog",onPress:$},V={id:"feedback",label:"Feedback",short:"Feedback",menu:"Send feedback",ariaLabel:"Send feedback",glyph:r.jsx(jQ,{}),kind:"dialog",onPress:N},H=k?[{id:"tool-activity",label:"Tool activity",short:"Tools",ariaLabel:"Tool activity",glyph:r.jsx(_Q,{}),kind:"dialog",detail:"Which tools your agents run, how long they take and what fails",onPress:()=>k("tools")},{id:"skill-activity",label:"Skill activity",short:"Skills",ariaLabel:"Skill activity",glyph:r.jsx(EQ,{}),kind:"dialog",detail:"Which skills your agents use, whether you typed them or the agent called them",onPress:()=>k("skills")}]:[],P=w?[{id:"traffic-radar",label:"Telemetry Radar",short:"Radar",ariaLabel:"Telemetry Radar",glyph:r.jsx(vQ,{}),kind:"dialog",detail:"Claude telemetry configuration and observed connections",onPress:()=>w(!0)}]:[],I=b?[{id:"radio",label:"Radio",short:"Radio",ariaLabel:"Radio",glyph:r.jsx(CQ,{}),kind:"dialog",detail:"Explore stations around the world",onPress:()=>b(!0)}]:[];return{left:e.claude?[W,M]:[M],leftStripe:e.claude?[Nf("Claude accounts",[W,...B]),[M]]:[[M]],capacity:e.claude?B:[],right:[Nf("Usage and machine",[R,q]),Nf("Activity history",[T,...H]),Nf("Watchers",[F,...P]),I].filter(U=>U.length>0),utilities:[D,V],search:K,explore:_?[{id:"explore-integrations",label:"Explore integrations",short:"Integrations",ariaLabel:"Explore integrations",glyph:r.jsx(mQ,{}),kind:"dialog",onPress:_}]:[],integrations:S.map(({provider:U,onPress:Z})=>({id:`integration-${U.kind}`,label:U.label,short:U.label,ariaLabel:U.label,detail:U.detail,key:U.shortcut?{cap:U.shortcut.toUpperCase(),aria:U.shortcut.toUpperCase(),single:!0}:void 0,glyph:r.jsx(U.Glyph,{}),kind:"dialog",onPress:Z}))}}const Mp=[{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 v8(e){return Mp.find(t=>t.value===e)??Mp[0]}const Nj=3,H0=120,b8=1e4,k8=200,Zge="Write something first.";function vO(e){return e.trim()!==""}function Jge(e){var o;const t=e.trim();if(t==="")return"";const n=bO(t.split(/\r?\n/,1)[0]),s=((o=/^(.+?[.!?])(?=\s|$)/.exec(n))==null?void 0:o[1])??n,a=z0(s).length>=Nj?z0(s):z0(n);return eye(a.length>=Nj?a:bO(t))}function Qge(e,t){const n=Jge(t);return n.length>=Nj?n:`${v8(e).label}: ${n}`}function bO(e){return e.replace(/\s+/g," ").trim()}function z0(e){return/[^.]\.$/.test(e)?e.slice(0,-1):e}function eye(e){if(e.length<=H0)return e;const t=e.slice(0,H0-1),n=t.lastIndexOf(" ");return`${(n>=H0/2?t.slice(0,n):t).replace(/[\uD800-\uDBFF]$/,"").replace(/[\s,;:.\-–—]+$/,"")}…`}function tye({kind:e,body:t,contact:n}){const s={kind:e,title:Qge(e,t),body:t.trim()};return n.trim()!==""&&(s.contact=n.trim()),s}function nye(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 sye={darwin:"macOS",win32:"Windows",linux:"Linux"};function rye(e){const t=e.indexOf("-"),n=t===-1?e:e.slice(0,t),s=t===-1?"":e.slice(t+1),a=sye[n]??n;return s?`${a} · ${s}`:a}function aye(e){return e?`ccdeck ${e.appVersion} · ${rye(e.platform)}`:null}const oye="sent with it",iye="Your ccdeck version and system are sent with it.",lye="Add details",cye="How to reach you",uye="Email or GitHub @name",dye="Only if you would like an answer.",hye=["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 fye(e){return e.key==="Enter"&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey&&!e.isComposing}function BS(e){return e.key==="Enter"&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey&&!e.isComposing}function pye(e){return po(e)?["⌘","Enter"]:["Ctrl","Enter"]}function mye(e){return[...e].length===1}const j8="Thanks — feedback sent.";function kO(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 gye(e){return e==="sending"?"Sending…":e==="sent"?j8:""}const jO=1400,yye=160,N8=g.createContext({values:{}});function S8(){return g.useContext(N8)}function wye(e,t){const n=e.variants;return n?{...e,...n.by[t[n.field]??""]??{}}:e}const NO=(e,t)=>!e.when||e.when.is.includes(t[e.when.field]??"");function xye({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 D,K,V;return[F.name,F.secret?"":((D=F.initial)==null?void 0:D.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),b=!!t,k=g.useRef(u),v=g.useRef(f);g.useEffect(()=>{i==null||i(f!==v.current||Object.keys(u).some(F=>u[F]!==k.current[F]))},[f,u,i]);const N=e.fields.filter(F=>F.type==="choice").every(F=>u[F.name]===k.current[F.name]),x=b&&t.tokenSaved&&N,C=(F,D)=>{n||h(K=>({...K,[F]:D}))},S=F=>{var K;if(F.preventDefault(),n)return;const D={};for(const V of e.fields)NO(V,u)&&(D[V.name]=(u[V.name]??"").trim());(K=F.currentTarget.querySelector('button[type="submit"]'))==null||K.focus(),a(D,f.trim()),h(V=>Object.fromEntries(Object.entries(V).map(([H,P])=>{var I;return[H,(I=e.fields.find(U=>U.name===H))!=null&&I.secret?"":P]})))},_=g.useMemo(()=>{const F=u.baseUrl??"";try{return F?new URL(/^[a-z]+:\/\//i.test(F)?F:`https://${F}`).host:""}catch{return""}},[u.baseUrl]),$=g.useMemo(()=>({values:u,existing:t}),[u,t]),A=e.fields.filter(F=>NO(F,u)),O=(q=A.find(F=>!F.secret&&F.type!=="choice"))==null?void 0:q.name,M=(T=A.find(F=>F.secret))==null?void 0:T.name,W=s!=null&&s.field&&A.some(F=>F.name===s.field&&F.type!=="choice")?s.field:null,B=`${l}-error`;g.useEffect(()=>{var D,K,V;const F=b?M:O??M;F&&((D=w.current.get(F))==null||D.focus()),(V=(K=m.current)==null?void 0:K.scrollIntoView)==null||V.call(K,{block:"nearest"})},[b]),g.useEffect(()=>{var F;W&&((F=w.current.get(W))==null||F.focus())},[s,W]);const R=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(N8.Provider,{value:$,children:r.jsxs("form",{ref:m,className:"ig-form",onSubmit:S,"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:b?`Edit ${t.name}`:`Connect ${e.label}`}),b&&r.jsxs("p",{children:[e.label," connection"]})]})]}),A.map(F=>{const D=wye(F,u),K=(s==null?void 0:s.field)===D.name,V=[D.hint?`${l}-${D.name}-hint`:"",K?B:""].filter(Boolean).join(" ")||void 0;if(D.type==="choice")return r.jsxs("fieldset",{className:"fb-kinds","aria-invalid":K||void 0,children:[r.jsx("legend",{className:"vis-hidden",children:D.label}),(D.options??[]).map(I=>r.jsxs("label",{className:"fb-kind",children:[r.jsx("input",{type:"radio",name:`${l}-${D.name}`,value:I.value,checked:u[D.name]===I.value,"aria-disabled":n||void 0,onChange:()=>C(D.name,I.value),onKeyDown:U=>{BS(U.nativeEvent)&&U.preventDefault()}}),I.label]},I.value))]},D.name);const H=D.secret&&x,P=`${l}-${D.name}`;return r.jsxs("div",{className:"fb-field",children:[r.jsxs("label",{className:"fb-field-label",htmlFor:P,children:[D.label,D.optional&&r.jsx("span",{className:"fb-optional",children:" optional"})]}),r.jsx("input",{id:P,className:`ap-manage-input ig-input${D.secret?" ig-mono":""}`,ref:I=>{I?w.current.set(D.name,I):w.current.delete(D.name)},type:D.type,inputMode:D.type==="url"?"url":D.type==="email"?"email":void 0,autoComplete:D.autoComplete??"off",spellCheck:!1,value:u[D.name]??"",onChange:I=>C(D.name,I.target.value),placeholder:H?"Saved. Leave blank to keep it":D.placeholder,readOnly:n,"aria-invalid":K||void 0,"aria-describedby":V,"aria-required":!D.optional&&!H||void 0}),D.hint&&r.jsx("span",{className:"ig-hint",id:`${l}-${D.name}-hint`,children:D.hint}),K&&W===D.name&&r.jsx("span",{className:"ig-form-error",id:B,role:"alert",children:R})]},D.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&&!W&&r.jsx("p",{className:"ig-form-error",id:B,role:"alert",children:R}),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…":b?"Save":"Connect"}),r.jsx("button",{type:"button",className:"btn","aria-disabled":n||void 0,onClick:()=>{n||o()},children:"Cancel"})]})]})})}const vye="https://id.atlassian.com/manage-profile/security/api-tokens",bye="https://support.atlassian.com/atlassian-account/docs/manage-api-tokens-for-your-atlassian-account/",kye="https://confluence.atlassian.com/enterprise/using-personal-access-tokens-1026032365.html",jye=[{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 Nye(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 Sye(){const{values:e}=S8(),t=e.deployment==="cloud",n=t?null:Nye(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:vye,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:jye.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:bye,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:kye,target:"_blank",rel:"noreferrer noopener",children:"How personal access tokens work"})})]}),r.jsx("p",{className:"ig-dim",children:"Browsing only reads Jira. Dragging an issue or confirming Move saves its sprint and rank in Jira, using your account’s permissions. The token stays on this machine and is never shown again."}),t&&r.jsxs("p",{className:"ig-dim",children:["For moving with a scoped Cloud token, also allow ",r.jsx("code",{children:"write:issue:jira-software"})," (rank), ",r.jsx("code",{children:"write:sprint:jira-software"})," (sprint) and ",r.jsx("code",{children:"write:board-scope:jira-software"})," (backlog). Read-only tokens can still browse."]})]})}function V0(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 G0({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 C8({kind:e,baseUrl:t}){const{values:n}=S8();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(G0,{href:V0("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(G0,{href:V0("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=V0("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(G0,{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 _8={name:"token",label:"Personal access token",type:"password",secret:!0,placeholder:"Paste the token"},Cye=[_8],SO=e=>{try{return e?new URL(e.baseUrl).host!=="gitlab.com":!1}catch{return!1}},_ye=[{name:"where",label:"Which GitLab",type:"choice",options:[{value:"cloud",label:"GitLab.com"},{value:"self",label:"Self-managed"}],initial:e=>SO(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=>SO(e)?e.baseUrl:""},_8],Eye=g.createElement(C8,{kind:"github"}),Tye=g.createElement(C8,{kind:"gitlab"}),Aye=e=>{var t;return((t=e==null?void 0:e.meta)==null?void 0:t.deployment)==="cloud"?"cloud":"server"},Rye={kind:"jira",label:"Jira",Glyph:MQ,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:Aye},{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(Sye)},Mye={kind:"github",label:"GitHub",Glyph:$Q,detail:"Repositories, pull requests, and Actions",blurb:"github.com, read-only, with a personal access token.",fields:Cye,tokenHelp:Eye},$ye={kind:"gitlab",label:"GitLab",Glyph:LQ,detail:"Projects, merge requests, and pipelines",blurb:"GitLab.com or your own instance, read-only.",fields:_ye,tokenHelp:Tye},Sj={jira:Rye,github:Mye,gitlab:$ye},qS=()=>Object.values(Sj).filter(e=>!!e);function _u(e){return(Object.hasOwn(Sj,e)?Sj[e]:void 0)??null}function Vm(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(Lye,{name:n(a),onClose:a.onClose})})))}function Lye({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 E8=()=>bi(()=>import("./IntegrationModal-CszT-tts.js"),[]);function Iye(){E8().catch(()=>{})}const Oye=Vm(E8,e=>{var t;return((t=_u(e.kind))==null?void 0:t.label)??"The tracker"});function Pye({onClose:e}){return g.useEffect(()=>rn.push(e,0,"dialog"),[e]),null}function Dye(e){return r.jsx(g.Suspense,{fallback:r.jsx(Pye,{onClose:e.onClose}),children:r.jsx(Oye,{...e})})}class vr extends Error{constructor(n,s,a={}){super(s);qa(this,"kind");qa(this,"status");qa(this,"retryAfter");qa(this,"field");qa(this,"detail");this.name="IntegrationFailure",this.kind=n,Object.assign(this,a)}}async function T8(e){try{const t=await e.json(),n=t==null?void 0:t.error;if(n&&typeof n.kind=="string"&&typeof n.message=="string")return new vr(n.kind,n.message,{status:n.status,retryAfter:n.retryAfter,field:n.field,detail:n.detail})}catch{}return new vr(e.status===401?"auth":"upstream",`The deck answered ${e.status}.`)}async function Md(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 vr("network",a.signal.aborted?"The deck took too long to answer.":"The deck could not be reached.")}finally{window.clearTimeout(o),i==null||i.removeEventListener("abort",l)}if(!u.ok)throw await T8(u);return u.json()}const A8=e=>`/api/integrations/${encodeURIComponent(e.kind)}/${encodeURIComponent(e.id)}/`;function dje(e){const t=A8(e);return(n,s)=>fetch(`${t}${n.replace(/^\/+/,"")}`,s)}function hje(e){const t=A8(e);return n=>`${t}asset?url=${encodeURIComponent(n)}`}function fje(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 pje(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 mje(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 vr("network",a.signal.aborted?"The deck took too long to answer.":"The deck could not be reached.")}finally{window.clearTimeout(o),n==null||n.removeEventListener("abort",i)}if(!l.ok)throw await T8(l);try{return await l.json()}catch{throw new vr("upstream","The deck answered with something that is not JSON.")}}let ia={connections:null,providers:[],error:""};const Tl=new Set;let Sf=null,fu=null,Bl=null,CO=0;const Fye=5e3,Bye=3;function $p(e){ia={...ia,...e},Tl.forEach(t=>t(ia))}function Gm(){return fu||(fu=(async()=>{try{const e=await Md("/api/integrations",{timeoutMs:1e4}),t=e==null?void 0:e.connections,n=e==null?void 0:e.providers;if(!Array.isArray(t)||!Array.isArray(n))throw new vr("upstream","The deck answered with something that is not the list of connections.");$p({connections:t,providers:n,error:""})}catch(e){$p({error:e instanceof Error?e.message:"Could not read the connections."}),ia.connections===null&&Tl.size>0&&Bl===null&&CO<Bye&&(Bl=window.setTimeout(()=>{Bl=null,Gm()},Fye*2**CO++))}finally{fu=null}})(),fu)}function qye(e){return e.connections===null||e.providers.length>0||e.connections.length>0}function _O(){qye(ia)&&Gm()}function US(e){const t=ia.connections??[],n=t.findIndex(s=>s.id===e.id);$p({connections:n<0?[...t,e]:t.map(s=>s.id===e.id?e:s)})}function Uye(e){$p({connections:(ia.connections??[]).filter(t=>t.id!==e)})}function $d(){const[e,t]=g.useState(ia);return g.useEffect(()=>{Tl.add(t),t(ia);const n=()=>{document.visibilityState==="visible"&&_O()};return Tl.size===1&&(Gm(),Sf=window.setInterval(_O,6e4),document.addEventListener("visibilitychange",n)),()=>{Tl.delete(t),Tl.size===0&&(Sf!==null&&window.clearInterval(Sf),Sf=null,Bl!==null&&window.clearTimeout(Bl),Bl=null,document.removeEventListener("visibilitychange",n))}},[]),e}function Lp(e,t){return(e.connections??[]).filter(n=>n.kind===t)}function Ld(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 ra(e,t){return Ld(e).has(t)}function Cj(e,t){return ra(e,t)&&Lp(e,t).length>0}function WS(e){return Ld(e).size>0?"all":(e.connections??[]).length>0?"connections":"none"}async function Wye(e,t,n){const s=await Md("/api/integrations/connections",{method:"POST",body:JSON.stringify({kind:e,name:n,input:t}),timeoutMs:6e4});return US(s.connection),s.connection}async function Hye(e,t){const n=await Md(`/api/integrations/connections/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t),timeoutMs:6e4});return US(n.connection),n}async function zye(e){const t=await Md(`/api/integrations/connections/${encodeURIComponent(e)}/test`,{method:"POST",body:"{}",timeoutMs:6e4});return US(t.connection),t.connection}async function Vye(e){await Md(`/api/integrations/connections/${encodeURIComponent(e)}`,{method:"DELETE"}),Uye(e)}function Vo(e){try{return new URL(e.baseUrl).host}catch{return e.baseUrl}}function gje(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 Ip=null,Op=null;function EO(e){Op=null,Ip=e}function Gye(e){Ip=null,Op=e}function Kye(){const e=Op;return Op=null,e}function Yye(){const e=Ip;return Ip=null,e}const Xye={jira:"Boards, sprints, backlog and issues",github:"Repositories, pull requests and Actions",gitlab:"Projects, merge requests and pipelines"};function Zye(){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 Jye({integrations:e,onClose:t,onOpen:n,onConnect:s,onManage:a}){const o=gt(t,{restoreFocusFallback:Zye}),i=yt(t),l=qS().filter(f=>e.providers.some(p=>p.kind===f.kind)||Lp(e,f.kind).length>0),u=l.filter(f=>Cj(e,f.kind)).length,h=f=>{t(),f()};return vt.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=ra(e,f.kind),m=Cj(e,f.kind),w=Lp(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:Xye[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 Qye({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 R8(e){return e.tool?e.tool.name:e.kind==="asked"?"question":"permission"}const ewe=20;function twe(e,t=ewe){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 nwe(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 swe(e,t,n){const s=t.tool?`on ${t.tool.name}`:t.kind==="asked"?"for an answer":"for permission";return`${e}, waiting ${nwe(n)} ${s}; go to session`}function rwe(e){const t=Gl(e),n=_P(e,t);return n?`${t}
113
- ${n}`:t}const awe=new Set(["idle","checking","current","downloading","ready","error"]);function TO(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.status!="string"||!awe.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 owe(e){return(e==null?void 0:e.status)==="ready"&&e.version?{version:e.version}:null}function M8(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",$8=3e4;function L8(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 iwe(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 I8(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 lwe(e){const t=e==null?void 0:e.reason;return t==="app_disconnected"||t==="update_not_ready"?t:"refused"}function O8(e,t,n=typeof navigator>"u"?"":navigator.userAgent){const s=L8(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 ${$8/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 cwe="Update checks are off (AGENTS_DECK_NO_UPDATE_CHECK=1)",K0="click for what's new";function uwe(e){if(e.checkDisabled)return`${cwe} · ${K0}`;if(e.checking)return`Asking npm for the newest release… · ${K0}`;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 · ${K0}, and to check npm now`}function dwe(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 hwe(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 P8(e){return e?`${e.kind}:${e.to}`:""}function fwe(e,t){return e!=null&&t!==P8(e)}function pwe({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=iwe(M8()??a,e.version),w=f&&I8(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":hwe({...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?rp(i-s.checkedAt):null,checkFailedAgo:s!=null&&s.checkFailedAt&&s.checkFailedAt>(s.checkedAt??0)?rp(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":dwe(m),title:uwe(m),children:["v",m.running]})})()})}function mwe({live:e,paused:t,pauseGate:n}){const s=An();return r.jsx("span",{className:"status",children:(()=>{const a=WY({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 gwe(e,t){return`${e.label} — ${R8(e.waiting)} · ${Qu(e.waiting.since,void 0,t)}`}function D8(e,t){const n=e.slice(0,6).map(s=>gwe(s,t));return e.length>6&&n.push(`and ${e.length-6} more`),n.join(`
114
- `)}function ywe({waitingSessions:e,waitingCursorRef:t,focusSession:n,now:s,named:a}){const o=An(),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?D8(l,s):void 0}),children:[r.jsx("span",{className:"ap-pulse","aria-hidden":!0}),r.jsx("b",{children:u})," waiting"]}),i.node]})}function AO({w:e,now:t}){return r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"we-name",children:twe(e.label)}),r.jsx("span",{className:"we-wait",children:Qu(e.waiting.since,void 0,t)}),r.jsxs("span",{className:"we-what",children:["· ",R8(e.waiting)]})]})}const wwe=12,xwe=2e3,vwe=4;function bwe({waitingSessions:e,waitingCursorRef:t,focusSession:n,now:s,onFit:a,onMore:o}){const i=An(),l=ac("below"),u=g.useRef(null),h=g.useRef(null),[f,p]=g.useState(0),m=e.map(v=>v.id).join(`
115
- `);g.useLayoutEffect(()=>{const v=u.current,N=h.current;if(!v||!N)return;const x=()=>{const S=Array.from(N.children),_=S.pop();p(Qye({widths:S.map($=>$.getBoundingClientRect().width),room:v.clientWidth-wwe,gap:vwe,more:(_==null?void 0:_.getBoundingClientRect().width)??0}))};if(x(),typeof ResizeObserver>"u")return;const C=new ResizeObserver(x);return C.observe(v),C.observe(N),()=>C.disconnect()},[m]);const w=e.slice(0,f),b=e.slice(f);g.useEffect(()=>{a(w.length)},[w.length,a]);const k=v=>{t.current=v,n(v)};return r.jsxs("div",{className:"wait-names",ref:u,children:[r.jsxs("ul",{className:"wait-list",children:[w.map(v=>r.jsx("li",{"data-fresh":s-v.waiting.since<xwe||void 0,children:r.jsx("button",{type:"button",className:"wait-entry",onClick:()=>k(v.id),"aria-label":swe(v.label,v.waiting,s-v.waiting.since),...l.bind({label:v.label,detail:rwe(v.waiting)}),children:r.jsx(AO,{w:v,now:s})})},v.id)),w.length>0&&b.length>0&&r.jsx("li",{children:r.jsxs("button",{type:"button",className:"wait-more",onClick:o,"aria-label":`${b.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:D8(b,s)}),children:["+",b.length," more"]})})]}),e.length>0&&r.jsxs("span",{className:"wait-ruler",ref:h,"aria-hidden":!0,children:[e.map(v=>r.jsx("span",{className:"wait-entry",children:r.jsx(AO,{w:v,now:s})},v.id)),r.jsxs("span",{className:"wait-more",children:["+",e.length," more"]})]}),l.node]})}const _j={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 kwe(e){return e==="on"?`Notifications on. ${_j.on}.`:e==="blocked"?`${_j.blocked}.`:""}function jwe({notifySaid:e}){return r.jsx("span",{className:e==="on"?"notify-said":"notify-said notify-said-blocked","aria-hidden":!0,title:_j[e],children:e==="on"?"notifications on":"notifications blocked"})}function Nwe({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:b,noticeOpen:k,showNotice:v,versionChecking:N,loadVersion:x}=e,{chipVersion:C,openReleaseNotes:S}=t,{readyAppUpdate:_,desktopUpdateRestarting:$,desktopUpdateFailure:A,askDesktopUpdateRestart:O}=n,M=g.useRef(!1);g.useEffect(()=>{$||!M.current||(M.current=!1,A&&S())},[$,A,S]);const W=K=>{M.current=!0,O(K)},{paused:B,pauseGate:R}=s,{blockedSaid:q,watchSaid:T,incidentSaid:F}=a,{notifySaid:D}=o;return r.jsxs("div",{className:"readout",children:[r.jsxs("div",{className:"brand",children:[r.jsx("img",{className:"logo logo-on-dark",src:Vne,width:19,height:16,alt:""}),r.jsx("img",{className:"logo logo-on-light",src:Gne,width:19,height:16,alt:""}),r.jsx("h1",{children:Pt}),r.jsx(pwe,{readyAppUpdate:_,notice:b,noticeOpen:k,version:w,chipVersion:C,versionChecking:N,now:f,openReleaseNotes:S,showNotice:v,loadVersion:x,restartToUpdate:W,updateRestarting:$})]}),r.jsx(mwe,{live:h,paused:B,pauseGate:R}),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:kwe(D)}),r.jsx(sse,{incidents:p}),i.length>0&&r.jsx(ywe,{waitingSessions:i,waitingCursorRef:l,focusSession:u,now:f,named:m}),D&&r.jsx(jwe,{notifySaid:D})]})}function Swe({selected:e,now:t,selectedIds:n,focusAgent:s,clearSelection:a}){const o=An(),i=Un(e),l=Math.max(0,((e.endedAt??t)-e.startedAt)/1e3),u=e.state==="active"&&!e.synthetic?fN(i.total,l):null,h=n.size-1;return r.jsxs("button",{type:"button",className:"selected-ribbon",title:`${_n(`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 Cwe({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"} ${Rp[o]} tools`,children:[r.jsx(qge,{cat:o}),r.jsx("span",{className:"cat-name",children:Rp[o]})]},o)})})}const _we=["a[href]","button:not(:disabled)","input:not(:disabled)","select:not(:disabled)","textarea:not(:disabled)","summary","[tabindex]"].join(",");function Ewe(e){var n,s;const t=e.target;!(t!=null&&t.closest)||t.closest(_we)!==e.currentTarget||(e.preventDefault(),(s=(n=document.activeElement)==null?void 0:n.blur)==null||s.call(n))}function Twe({trashZoneRef:e,trashState:t,trashPhase:n,trashLabel:s}){const a=An();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"?`${_n("The session list","L",a)} brings it back`:"The session keeps running"})]})]})}function Awe({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:b,lodRef:k}=a,{markCanvasInput:v}=o,{peekAgent:N,peekLabel:x,peekRecap:C,peekBounds:S}=l;return r.jsxs("main",{id:"canvas",tabIndex:-1,className:`canvas-wrap${t?" bubbling":""}${n?" dragging-any":""}${h&&f==="over"?" trash-hover":""}`,"data-lod":b,ref:e,onMouseDownCapture:Ewe,onPointerDownCapture:v,onPointerUpCapture:v,onWheelCapture:v,onFocusCapture:_=>{const $=_.target;if(!OS($)||k.current==null||k.current==="detail")return;const A=$.getAttribute("data-id");A&&i.current.agents.has(A)&&$.matches(":focus-visible")&&n8(A,$,"focus")},onBlurCapture:_=>{var A,O;const $=(O=(A=_.target).getAttribute)==null?void 0:O.call(A,"data-id");$&&io($)},children:[u,Ja(p)&&r.jsx(Twe,{trashZoneRef:m,trashState:f,trashPhase:p,trashLabel:w}),r.jsx(hme,{agentFor:N,recapFor:C,labelFor:x,bounds:S})]})}function Rwe({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=qY({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 Mwe({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 F8="Thanks — that helps.",$we=Array.from({length:11},(e,t)=>t);function Lwe(e){return e===0?"0 out of 10, not useful":e===10?"10 out of 10, extremely useful":`${e} out of 10`}const Iwe=6;function Owe(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 Pwe(){var e;(e=document.getElementById("canvas"))==null||e.focus()}function Dwe({phase:e,score:t,onAnswer:n,onLater:s,onClose:a,onFeedback:o,onHold:i}){const l=Owe(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,Wn(((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)&&Pwe(),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:F8}),t!==null&&t<=Iwe?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:$we.map(m=>r.jsx("button",{type:"button",className:"rating-pick","aria-label":Lwe(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 Fwe=3e4;function Bwe({bundle:e,running:t,lastTried:n}){return!t||e===t?!1:n!==t}function qwe({bundle:e,running:t,pending:n,lastTried:s}){return t?Bwe({bundle:e,running:t,lastTried:s})?"reload":n==null||n&&n!==t?"wait":"confirm":"wait"}function Uwe(e){return!e||e.state!=="failed"?null:`${typeof e.at=="number"?e.at:0}:${e.error??""}`}function Wwe({asked:e,reported:t}){return t?t!==e:!1}function B8(e){const t=e.thresholdMs??Fwe;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 Hwe(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 zwe(e,t){return e?t==null?"auto when idle":`auto in ${Hwe(t)}`:"auto-restart off"}function RO(e){let t=0;for(const n of e)n.state==="active"&&t++;return t}function Vwe(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 Gwe(e){const t=B8(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 Ej={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 Kwe({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,b,k;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(),...Bn(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:zwe(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,...Bn(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}),...Bn(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:((b=t==null?void 0:t.upgrade)==null?void 0:b.error)??"",children:[(t==null?void 0:t.upgradeMode)==="npx"?"update failed":"install failed",": ",((k=t==null?void 0:t.upgrade)==null?void 0:k.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:":Ej.npx}):t!=null&&t.upgradeBlocked?r.jsx("span",{className:"ver-sub",children:Jt(Ej,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 Ywe({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:b,restartCopy:k,restartFuseMs:v}=e,{version:N,notice:x,noticeOpen:C,dismissNotice:S}=t,{upgradeState:_,startUpgrade:$,copyCommand:A,cmdCopied:O}=n,{oldName:M,oldNameOpen:W,dismissOldName:B}=s,{ratingPhase:R,ratingScore:q,answerRating:T,rateLater:F,closeRating:D,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(Rwe,{restarting:p,restartMode:m,live:l,paused:u}):C&&x?r.jsx(Kwe,{notice:x,version:N,dismissNotice:S,upgradeState:_,startUpgrade:$,copyCommand:A,cmdCopied:O,autoRestart:h,toggleAutoRestart:f,askRestart:b,restartCopy:k,restartFuseMs:v,restarting:p}):W&&M?r.jsx(Mwe,{oldName:M,version:N,dismissOldName:B}):R!=="hidden"?r.jsx(Dwe,{phase:R,score:q,onAnswer:T,onLater:F,onClose:D,onFeedback:o,onHold:K}):null;return r.jsxs(r.Fragment,{children:[V,r.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:R==="thanks"?F8:""})]})}function Xwe(e,t){return e==="confirmation"?t.confirmOpen?"clear":"ignore":t.modalOpen||t.confirmOpen?"ignore":"confirm"}function Zwe(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 Jwe(e){return e<=0?null:e===1?"the one agent":`all ${e} agents`}function Qwe(e,t){const n=Jwe(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 exe({agentCount:e,onConfirm:t,onCancel:n}){const s=g.useRef(null),a=gt(n,{focusRef:s,layer:WG}),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(Zwe(w))}).catch(()=>{}),()=>{m=!0}},[]);const{goes:u,stays:h,final:f,confirm:p}=Qwe(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 txe({kind:e,onChange:t}){return r.jsxs("fieldset",{className:"fb-kinds",children:[r.jsx("legend",{className:"vis-hidden",children:"Kind of feedback"}),Mp.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=>{BS(s.nativeEvent)&&s.preventDefault()}}),n.label]},n.value))]})}const q8="fb-details";function nxe({open:e,onToggle:t}){return r.jsxs("button",{type:"button",className:"fb-tool fb-more","aria-expanded":e,"aria-controls":q8,onClick:t,children:[lye,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 sxe({open:e,contact:t,onContact:n}){const s=g.useId();return r.jsx("div",{id:q8,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:[cye,r.jsx("span",{className:"fb-optional",children:"optional"})]}),r.jsx("input",{id:"fb-contact",className:"ap-manage-input",type:"text",value:t,maxLength:k8,autoComplete:"email",placeholder:uye,"aria-describedby":s,onChange:a=>n(a.target.value),onKeyDown:a=>{BS(a.nativeEvent)&&a.preventDefault()}}),r.jsx("p",{id:s,className:"fb-hint",children:dye})]}),r.jsx("div",{className:"fb-where",children:hye.map(a=>r.jsx("p",{children:a},a))})]})})})}const ni=3,rxe=5*1024*1024,axe=12*1024*1024,Tj=8192,oxe=64*1024,ixe=256*1024,lxe=.92,cxe=640,U8=.9,uxe=.85,dxe=6,hxe=512*1024,Pp={png:"image/png",jpeg:"image/jpeg"},fxe={png:"png",jpeg:"jpg"},pxe=[137,80,78,71,13,10,26,10],mxe=[255,216,255];function W8(e){const t=n=>e.length>=n.length&&n.every((s,a)=>e[a]===s);return t(pxe)?"png":t(mxe)?"jpeg":null}function gxe(e){const t=W8(e);return t==="png"?yxe(e):t==="jpeg"?xxe(e):null}function yxe(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 wxe(e){return e>=192&&e<=207&&e!==196&&e!==200&&e!==204}function xxe(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(wxe(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 MO(e,t){return e.bytes>t||e.width>Tj||e.height>Tj}function vxe(e){return Math.min(rxe,axe-oxe-e)}function H8(e,t){return{width:Math.max(1,Math.floor(e.width*t)),height:Math.max(1,Math.floor(e.height*t))}}function bxe(e,t){const n=Tj/Math.max(e.width,e.height),s=e.bytes>t?Math.sqrt(t/e.bytes)*U8:1;return H8(e,Math.min(1,n,s))}async function kxe(e,t,n){let s=bxe(e,t),a=e.format;for(let o=0;o<dxe;o++){const i=await n(s,a,a==="jpeg"?lxe:void 0);if(!i)return null;if(i.size<=t)return{...s,blob:i,format:a};if(a==="png"){a="jpeg";continue}if(s=H8(s,Math.min(uxe,Math.sqrt(t/i.size)*U8)),Math.max(s.width,s.height)<cxe)return null}return null}async function jxe(e,t,n){const s=new Uint8Array(await e.slice(0,hxe).arrayBuffer()),a=W8(s);if(!a)return{ok:!1,problem:"type"};if(t<ixe)return{ok:!1,problem:"no_room"};const o=e.type===Pp[a]?e:new Blob([e],{type:Pp[a]}),i=gxe(s);if(i&&!MO({...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(!MO(u,t))return{ok:!0,blob:o,resized:null};const h=await kxe(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 Nxe(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)},Pp[s],a)})}const Sxe=async e=>{const t=await createImageBitmap(e);return{width:t.width,height:t.height,encoder:Nxe(t),release:()=>t.close()}};function Cxe(e){return e.includes("Files")}function _xe({files:e,hasText:t,intoTextField:n}){return e>0&&(!t||!n)}function Exe(e,t){const n=e.indexOf(t);return e[n+1]??e[n-1]??null}function Txe(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===Pp.jpeg?"jpeg":"png";n.append("images",s,`image-${a+1}.${fxe[o]}`)}),{method:"POST",body:n}}const Axe="Add screenshot",$O="PNG or JPEG, up to three. You can also paste one, or drop it on this dialog.",Rxe="A screenshot can show emails, costs and paths. Crop out what should not be seen.",LO="Three images at most. Remove one to add another.",Mxe="An image could not be attached, so nothing was sent. Check the images and send again; your text is still here.";function $xe(e,t,n){const s=n?`, resized to ${n.width} × ${n.height} to fit`:"";return`Replace image ${e+1}: ${t}${s}`}function Lxe(e,t){const n=`${e} of ${ni}`;return t>0?`${n} · ${t} resized to fit`:n}function Ixe(e){return`Three images at most, so ${e===1?"one was":`${e} were`} left out.`}function Oxe(e){return`“${e.length>40?`${e.slice(0,30)}…${e.slice(-9)}`:e}”`}function Pxe(e,t){const n=Oxe(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 z8="image/png,image/jpeg";function V8({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 Dxe({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:$O,"aria-describedby":"fb-attach-hint",onClick:()=>{var a;return s?e.sayFull():(a=n.current)==null?void 0:a.click()},children:[r.jsx(V8,{}),Axe]}),r.jsx("span",{id:"fb-attach-hint",hidden:!0,children:$O}),r.jsx("input",{ref:n,type:"file",accept:z8,multiple:!0,hidden:!0,onChange:a=>{e.add(Array.from(a.target.files??[])),a.target.value=""}})]})}function Fxe({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=Lxe(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(Exe(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:z8,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":$xe(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:b=>{b?n.current.set(m.id,b):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:Rxe})]}),e.problem&&r.jsx("p",{ref:s,className:"fb-error",role:"alert",children:e.problem},e.problemId)]})}function Bxe(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 qxe(e,t,n){return n?e.map(s=>s.id===t.id?t:s):[...e,t]}function Uxe(e,t,n){return n?e.map(s=>s.id===t?n:s):e.filter(s=>s.id!==t)}function Wxe(e){const[t,n]=g.useState(()=>Bxe((e==null?void 0:e.ready)??[],1)),[s,a]=g.useState({problem:"",id:0}),o=g.useRef(0),i=g.useCallback(R=>{R&&o.current++,a(q=>R?{problem:R,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),b=g.useRef([]),k=g.useRef(0),v=g.useCallback(R=>{h.current=R(h.current),n(h.current)},[]);g.useEffect(()=>(m.current=!0,()=>{m.current=!1;for(const R of h.current)URL.revokeObjectURL(R.url)}),[]);const N=g.useCallback(async(R,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,D=URL.createObjectURL(R),K={id:F,name:R.name||"image",url:D,blob:null,resized:null},V=k.current;w.current.set(F,R);let H=!1;const P=()=>{H||(H=!0,v(Z=>qxe(Z,K,q!==void 0)))},I=await jxe(R,vxe(T),async Z=>(P(),Sxe(Z))).catch(()=>({ok:!1,problem:"unreadable"})),U=h.current.some(Z=>Z.id===F);return!m.current||k.current!==V||!U&&(H||q)?(URL.revokeObjectURL(D),q&&URL.revokeObjectURL(q.url),m.current&&w.current.delete(F),""):(w.current.delete(F),I.ok?(P(),q&&URL.revokeObjectURL(q.url),v(Z=>Z.map(z=>z.id===F?{...z,blob:I.blob,resized:I.resized}:z)),""):(URL.revokeObjectURL(D),H&&v(Z=>Uxe(Z,F,q)),Pxe(I.problem,R.name||"image")))},[v]),x=g.useCallback(async R=>{i("");const q=k.current,T=[];let F=0,D=0;for(const V of R){if(!m.current||k.current!==q)return;const H=b.current.indexOf(V);if(H!==-1&&b.current.splice(H,1),h.current.length>=ni){F++;continue}const P=h.current.length,I=await N(V);I&&T.push(I),h.current.length>P&&D++}if(!m.current||k.current!==q)return;F>0&&T.push(D===0&&T.length===0?LO:Ixe(F)),i(T.join(" "));const K=h.current.length;D>0&&u(`${D===1?"Image":`${D} images`} added, ${K} of ${ni}.`)},[N,i]),C=g.useCallback(async(R,q)=>{i("");const T=h.current.find(K=>K.id===R);if(!T)return x([q]);const F=await N(q,T);if(!m.current)return;i(F);const D=h.current.findIndex(K=>K.id===R);!F&&D!==-1&&u(`Image ${D+1} replaced, ${h.current.length} of ${ni}.`)},[x,N,i]),S=g.useCallback(R=>{const q=k.current;f.current=(f.current??Promise.resolve()).then(()=>k.current===q?R():void 0).catch(()=>{})},[]),_=g.useCallback(R=>{R.length!==0&&(b.current.push(...R),S(()=>x(R)))},[x,S]);g.useEffect(()=>{e&&e.waiting.length>0&&_(e.waiting)},[]);const $=g.useCallback((R,q)=>{const T=q[0];T&&S(()=>C(R,T))},[S,C]),A=g.useCallback(R=>{const q=h.current.find(T=>T.id===R);q&&(URL.revokeObjectURL(q.url),w.current.delete(R),v(T=>T.filter(F=>F.id!==R)),i(""),u(`Image removed, ${h.current.length} of ${ni}.`))},[v,i]),O=g.useCallback(()=>i(LO),[i]),M=g.useCallback(async()=>{const R=o.current;return await f.current,o.current!==R?null:h.current.flatMap(q=>q.blob?[q.blob]:[])},[]),W=g.useCallback(()=>({ready:h.current.flatMap(R=>R.blob&&!w.current.has(R.id)?[{name:R.name,blob:R.blob,resized:R.resized}]:[]),waiting:[...w.current.values(),...b.current]}),[]),B=g.useCallback(()=>{k.current++;for(const R of h.current)URL.revokeObjectURL(R.url);w.current.clear(),b.current=[],v(()=>[]),i("")},[v,i]);return{shots:t,problem:s.problem,problemId:s.id,announcement:l,add:_,replace:$,remove:A,sayFull:O,ready:M,kept:W,clear:B}}function Hxe(){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(nye(s))}).catch(()=>{}),()=>{n=!1}},[]),e}function zxe(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(!Cn(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:Mxe});return}const f=await fetch("/api/feedback",{...Txe(tye(l),h),signal:u}),p=await f.json().catch(()=>null);n(f.ok&&(p!=null&&p.ok)?{state:"sent"}:{state:"failed",message:kO(f.status,p==null?void 0:p.reason,p==null?void 0:p.errors)})}catch{u.aborted||n({state:"failed",message:kO(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 Vxe(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),jO),i=window.setTimeout(()=>a.current(),jO+yye);return()=>{window.clearTimeout(o),window.clearTimeout(i)}},[e]),n}const Y0="agent-dag.feedbackDrafts",IO=4;function Gxe({initialKind:e,initialBody:t}){return{kind:e??"bug",body:t??""}}function Kxe(e){return JSON.stringify([e.kind,e.body])}function Yxe(e){return e.ready.length+e.waiting.length}function G8(e,t){return e.body.trim()!==t.body.trim()||e.contact.trim()!==""||e.images>0}function Xxe(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 Zxe="Discard",Jxe="Confirm discard",Qxe="Clear the message, the screenshots and the contact",OO="Press again to clear this draft. It cannot be brought back.",eve={ready:[],waiting:[]};function tve(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!Mp.some(i=>i.value===n)||typeof s!="string"||s.length>b8||typeof a!="string"||a.length>k8||typeof o!="number"||!Number.isInteger(o)||o<0||o>ni?null:[e[0],{kind:n,body:s,contact:a,images:o}]}function nve(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(Y0),l=i?JSON.parse(i):[];if(Array.isArray(l))for(const u of l.slice(-IO)){const h=tve(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(Y0):o.setItem(Y0,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??eve,imagesLost:i.images?0:i.imageCount}:null},keep(o,i,l){const u=Yxe(i.images);if(!G8({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<=IO)break;h.delete(f)}s()},forget:a}}function sve(){try{return typeof window>"u"?null:window.sessionStorage}catch{return null}}const Aj=nve(sve),rve=4e3;function ave(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||Aj.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&&Aj.forget(e)},[a,e])}const PO="draft";function ove(e){const[t,n]=g.useState(!1),s=g.useRef(0);g.useEffect(()=>{if(!t)return;const o=window.setTimeout(()=>n(!1),rve);return()=>window.clearTimeout(o)},[t]);function a(){const o=Date.now(),i=yi({armedFor:t?PO:null,target:PO,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 K8({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),b=Gxe({initialKind:t,initialBody:n}),k=Kxe(b),[v]=g.useState(()=>Aj.read(k)),[N,x]=g.useState((v==null?void 0:v.kind)??b.kind),[C,S]=g.useState((v==null?void 0:v.body)??b.body),[_,$]=g.useState((v==null?void 0:v.contact)??""),[A,O]=g.useState((v==null?void 0:v.imagesLost)??0),[M,W]=g.useState(!1),[B,R]=g.useState(!1),[q,T]=g.useState(!1),F=Wxe(v==null?void 0:v.images),D=aye(Hxe()),{outcome:K,sending:V,send:H,clearFailure:P}=zxe(F),I=K.state==="sent",U=Vxe(I,e);ave(k,b,{kind:N,body:C,contact:_},F,I);const Z=G8({body:C,contact:_,images:F.shots.length},b),z=ove(()=>{var xe;x(b.kind),S(b.body),$(""),O(0),R(!1),F.clear(),P(),(xe=s.current)==null||xe.focus()}),X=v8(N),Y=B&&!vO(C),J=A>0&&F.shots.length===0,Q=[Y&&"fb-body-error",J&&"fb-images-lost"].filter(Boolean).join(" ")||void 0,[te,le]=pye(ro());g.useEffect(()=>{var De,We;const xe=i.current;if(!xe)return;const Ie=xe.contains(document.activeElement)||Wn(((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||Wn(((ye=document.activeElement)==null?void 0:ye.tagName)??null);!I&&De&&We&&De.focus()},[V,I]);function de(xe){var Ie;if(xe.preventDefault(),!vO(C)){R(!0),(Ie=s.current)==null||Ie.focus();return}H({kind:N,body:C,contact:_})}const oe=!I&&!V,re=xe=>Cxe(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");_xe({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":U||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?OO:gye(K.state)}),r.jsxs("div",{className:"fb-stage",children:[r.jsxs("form",{ref:i,className:"fb-form",onSubmit:de,onKeyDown:xe=>{fye(xe.nativeEvent)&&(xe.preventDefault(),xe.currentTarget.requestSubmit())},noValidate:!0,children:[r.jsxs("section",{ref:l,className:"modal-body fb-body",children:[r.jsx(txe,{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:C,maxLength:b8,rows:5,placeholder:X.placeholder,onChange:xe=>S(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:Zge}),r.jsx(Fxe,{images:F,addRef:o}),J&&r.jsx("p",{id:"fb-images-lost",className:"fb-hint",children:Xxe(A)}),r.jsxs("div",{className:"fb-tools",children:[r.jsx(Dxe,{images:F,buttonRef:o}),r.jsx(nxe,{open:M,onToggle:()=>W(xe=>!xe)})]}),r.jsx(sxe,{open:M,contact:_,onContact:$})]}),r.jsx("p",{className:"fb-facts",children:D?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"fb-facts-value",children:D})," — ",oye]}):iye}),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?OO:Qxe,children:z.armed?Jxe:Zxe}),r.jsxs("span",{className:"fb-shortcut","aria-hidden":"true",children:[r.jsx("kbd",{"data-symbol":mye(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",...Bn(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(Np,{}),r.jsx("p",{className:"fb-done-line",children:j8})]})]}),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(V8,{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 Y8="Press Esc first if a key does nothing.",X0=[{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:[]}]}],ive=/ \([A-Z?]\)/g;function X8(e,t=()=>!0){const n=s=>s.integration===void 0||t(s.integration);return e&&X0.every(s=>s.rows.every(n))?X0:X0.map(s=>({...s,rows:s.rows.filter(n).filter(a=>e||a.chord||!a.binds.some(sD)).map(a=>e?a:{...a,action:a.action.replace(ive,"")})})).filter(s=>s.rows.length>0)}const lve="Single-key shortcuts are off.",Z8="Settings › Keyboard",cve=`Single-key shortcuts can be turned off in ${Z8}.`;function uve({onClose:e,onTour:t,onSettings:n}){const s=gt(e),a=yt(e),o=po(ro()),i=An(),l=$d(),u=X8(i,h=>ra(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:lve})," Turn them back on in"," ",r.jsx("span",{className:"kh-place",children:Z8}),". 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:[Y8," ",cve]})]})]})})}function dve(e,t){return`${e}#${t}`}function hve(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=dve(i.key,i.since);if(s.has(l)||Soe(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 fve(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 J8({rows:e,ours:t,dialogs:n}){return e===0?!1:t||n===0}function pve(e){return e===1?"Account needs your attention":"Accounts need your attention"}function mve(e){return`${e===1?"One Claude account needs":`${e} Claude accounts need`} you to sign in again.`}const gve="Login expired",yve="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.",wve="The account stays marked in the Accounts panel. This will not ask again until it has worked and stopped again.";function xve(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 vve({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 ",lS(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 bve(e){const t=g.useRef(!1),n=kve(e),s=J8({rows:n?1:0,ours:t.current,dialogs:rn.dialogDepth()});return t.current=s,s?n:null}function kve({lanPending:e,lanDeferred:t,lanBusy:n,answerLanPair:s,deferLanPair:a}){const{request:o,waiting:i}=xve(e,t.current);return o?r.jsx(vve,{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 jve({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:yve})]}):r.jsxs(r.Fragment,{children:[r.jsx("p",{id:"reauth-lead",className:"reauth-lead",children:mve(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:gve}),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:wve,onClick:n,children:"Not now"}),a&&r.jsx("button",{type:"button",className:"btn primary",ref:s,onClick:()=>t(a),children:"Sign in again"})]})]})}function Nve({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:pve(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(jve,{rows:e,onSignIn:t,onLater:n,firstRef:s})]})})}function Sve({rows:e,signingIn:t,signIn:n,signedIn:s,refresh:a,closeSignIn:o,later:i,pairing:l=!1}){const u=g.useRef(!1),h=rn.dialogDepth()+(l?1:0),f=t!=null||J8({rows:e.length,ours:u.current,dialogs:h});return u.current=f,t?r.jsx(g6,{email:t.email||null,onClose:o,onChanged:a,onSignedIn:s}):f?r.jsx(Nve,{rows:e,onSignIn:n,onLater:i},e.length===1?"one":"many"):null}const Cve={"//":["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 one line the deck shows them, so it has to stand on","its own; `body` is the fuller account, kept here for the release text.","","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.48.0":[{title:"🗂️ Jira: move issues between sprints and the backlog",body:"On a Scrum board ordered by Rank, drag issues or use Move to reorder them or send them to another sprint or the backlog, one at a time or up to 50 together. Browsing still only reads."},{title:"🔎 The Jira list is easier to scan",body:"Titles keep more room, a row's preview no longer covers the next row, the issue key shows once in the detail, and Clear filters stays in reach on a phone."},{title:"⌨️ ccdeck tui keeps your Claude accounts on one screen over SSH",body:"Switch accounts, turn Auto-switch on or off, and sign an account in with a link you open in any browser, all from the terminal."},{title:"🎮 Machine shows NVIDIA GPU readings",body:"On Linux and Windows with nvidia-smi: each GPU's utilization, video memory, temperature and power."},{title:"👤 Claude accounts are quieter, and an expired login has a Sign in button",body:"Telemetry is a small shield explained on hover or focus, and an account whose login expired shows Sign in on its own row."},{title:"🩹 Fewer page errors from browser extensions and translation",body:"The Accounts panel recovers when an extension breaks its requests, and Local network keeps working while the browser translates the page."}],"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.`}]},HS="agent-dag.releaseNotesSeen";function DO(e){return e.split(/[.\-+]/).map(t=>parseInt(t,10)).map(t=>Number.isNaN(t)?0:t)}function vi(e,t){const n=DO(e),s=DO(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 _ve(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 Eve(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(_ve);a.length&&t.push({version:n,notes:a})}return t.sort((n,s)=>vi(s.version,n.version))}const FO=Eve(Cve);function Q8(e,t,n){return e.filter(s=>vi(s.version,n)<=0&&(t===null||vi(s.version,t)>0))}function Tve(e,t){return e.filter(n=>vi(n.version,t)===0)}function Ave(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 Rve({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 Mve=new RegExp("^(?:\\p{Extended_Pictographic}|\\p{Emoji_Modifier}|\\p{Regional_Indicator}|[\\u200D\\uFE0F])+(?= \\S)","u");function $ve(e){const t=Mve.exec(e);return t?{icon:t[0],rest:e.slice(t[0].length)}:{icon:null,rest:e}}function Lve(e){if(!e)return null;let t=null;try{t=e.getItem(HS)}catch{return null}return lo(t)?t:null}function Ive(e){if(!e)return!1;try{return e.getItem(HS),!0}catch{return!1}}function Ove(e,t){if(!e)return!1;try{return e.setItem(HS,t),!0}catch{return!1}}const eB="agent-dag.tourSeen";function Pve(e){if(!e)return!1;try{return e.getItem(eB)==="1"}catch{return!1}}function Dve(e){if(!e)return!1;try{return e.setItem(eB,"1"),!0}catch{return!1}}function Fve({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 Bve({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=Tve(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=Q8(n,e,t);return o.length?{show:o,record:t,reason:"new-notes"}:{show:[],record:t,reason:"nothing-new"}}function co(e=typeof navigator>"u"?"":navigator.userAgent){return/\bccdeck-desktop\/\d/.test(e)}function yje(e,t,n){if(e===null)return null;const s=e+t-n;return s>0?s:null}function wje(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 qve(e){return(e??[]).filter(t=>t.installed&&t.profiles>0)}function xje(e){return!Number.isFinite(e)||e<=0?"empty":Qn(e)}function vje(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 Uve(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 bje(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=qve(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 Wve="Check for updates",tB="Ask npm now whether a newer ccdeck is out.",BO="Checking…",Hve="Couldn't reach npm. Try again.",zve="Couldn't reach the deck. Try again.",nB="Update checks are off on this deck (AGENTS_DECK_NO_UPDATE_CHECK or AGENTS_DECK_NO_INSTALL).",Vve="The deck looks again in five minutes.";function Gve(e,t,n,s){const a=s?t.npx:n?Jt(t,n):void 0;return a?`${e} is out, but ${a}`:`${e} is out. Run:`}const Pn=(e,t={})=>({said:e,tone:"answer",age:null,command:null,action:null,...t}),Xo=e=>Pn(e,{tone:"note"});function qO(e,t){return Uve(e,t)??"just now"}function Kve(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 Yve(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 Pn(`${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 Pn(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 Pn(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:`:Gve(t,n,s==null?void 0:s.upgradeBlocked,(s==null?void 0:s.upgradeMode)==="npx"),o=(s==null?void 0:s.command)??null;return Pn(a,{command:o,action:o?{kind:"copy",label:e.copied?"Copied":"Copy",busy:!1}:null})}function Xve(e){const t=e.version;if(e.unreachable)return Pn(zve,{tone:"warn"});const n=t!=null&&t.checkFailedAt&&t.checkFailedAt>(t.checkedAt??0)?t.checkFailedAt:null;if(n)return Pn(Hve,{tone:"warn",age:e.answered?null:`Last tried ${qO(n,e.now)}.`});const s=t!=null&&t.latestPending&&t.latestPending!==e.running?t.latestPending:null;if(s)return Pn(`${s} is tagged on npm but can't be installed yet. ${Vve}`);const a=t!=null&&t.checkedAt?qO(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 Pn(o,{age:a?`Checked ${a}.`:null})}return Pn("",{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=Kve(e.app,e.running);return i&&{canCheck:!0,checking:e.checking||((o=e.app.update)==null?void 0:o.status)==="checking",line:e.unreachable?Pn("The desktop updater did not accept the check. Try the ccdeck menu or update the desktop app.",{tone:"warn"}):e.checking?Pn(BO):i}}if(n!=null&&n.checkDisabled)return{canCheck:!1,checking:!1,line:Xo(nB)};const s=(n==null?void 0:n.notice)??null;if((s==null?void 0:s.kind)==="upgrade")return{canCheck:!0,checking:e.checking,line:Yve(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:Pn(i)}}return e.checking?{canCheck:!0,checking:!0,line:Pn(BO)}:{canCheck:!0,checking:!1,line:Xve(e)}}const sB=450;async function Jve(e,t=n=>new Promise(s=>setTimeout(s,n))){const[n]=await Promise.all([e(!0),t(sB)]);return n?"answered":"unreachable"}async function Qve(e=fetch){try{const[t]=await Promise.all([e("/api/desktop-update/check",{method:"POST",signal:AbortSignal.timeout(8e3)}),new Promise(n=>setTimeout(n,sB))]);return t.ok?"answered":"unreachable"}catch{return"unreachable"}}const Rj="Eight pictures of what the deck shows.",UO="Restart the deck. Sessions, settings and pairings come back as they were.";function ebe(e){var $;const t=(e==null?void 0:e.versionCheck.versionChecking)??!1,n=_r(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:b,running:k,onHandOff:v}=e,N=Zve({version:p.version,running:k,checking:s||t,answered:u,unreachable:i,now:n,upgradeState:m.upgradeState,copied:m.cmdCopied,restarting:w.restarting,app:{inApp:co(),update:b.appUpdate,version:M8(),menu:L8()}},Ej);if(!N)return null;const x=co()&&(($=p.version)==null?void 0:$.checkDisabled);return{state:N,check:async()=>{var O;if(!Cn(o.current||t)||x&&((O=b.appUpdate)==null?void 0:O.status)==="checking")return;o.current=!0,a(!0);const A=x?await Qve():await Jve(p.loadVersion);o.current=!1,a(!1),l(A==="unreachable"),h(!0)},act:A=>{if(A.kind==="copy")return void m.copyCommand();v(),p.showNotice(),A.kind==="install"?m.startUpgrade():w.askRestart({upgrade:!0})},checkWhy:x?"Ask the desktop app whether a newer ccdeck is out.":tB}}function tbe({onTour:e,onRestart:t,updateCheck:n}){var h,f;const s=ac("above","dialog"),a=ebe(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:Rj}),children:[r.jsx(OD,{}),"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(NQ,{}),Wve]}),u&&r.jsxs("button",{type:"button",className:"btn rn-act rn-act-restart",onClick:u,"aria-describedby":`${o}-restart`,...s.bind({label:UO}),children:[r.jsx(SQ,{}),"Restart"]})]}),a&&r.jsx(nbe,{line:a.state.line,onAct:a.act,bindHint:s.bind,whyId:`${o}-act`}),r.jsx("span",{hidden:!0,id:`${o}-tour`,children:Rj}),r.jsx("span",{hidden:!0,id:`${o}-check`,children:(a==null?void 0:a.checkWhy)??tB}),r.jsx("span",{hidden:!0,id:`${o}-restart`,children:UO}),s.node]})}function nbe({line:e,onAct:t,bindHint:n,whyId:s}){const{action:a}=e,o=a&&r.jsx(sbe,{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 sbe({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 rbe({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),b=Ave(e);return r.jsx("div",{className:"modal-backdrop",...w,role:"presentation",children:r.jsxs("div",{ref:m,className:"modal release-notes",onClick:k=>k.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"}),b&&r.jsx("span",{className:"modal-tool-id",children:b})]}),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:Rve({since:t,running:n,firstRun:s,entries:e})}),r.jsx(tbe,{onTour:i?void 0:o,onRestart:f,updateCheck:p}),e.map(k=>r.jsxs("section",{className:"modal-section",children:[r.jsxs("h3",{className:"rn-version",children:["v",k.version]}),r.jsx("ul",{className:"rn-notes",children:k.notes.map((v,N)=>{const{icon:x,rest:C}=$ve(v.title);return r.jsx("li",{className:"rn-note",children:r.jsxs("p",{className:"rn-note-title",children:[x&&r.jsx("span",{className:"rn-note-icon",children:x}),C]})},N)})})]},k.version))]})]})})}function abe({state:e,sessionId:t,onClose:n}){const s=g.useMemo(()=>obe(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:AD}),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":Zp(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(GN,{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 obe(e,t){const n=e.agents.get(t);if(!n)return null;const s=[];for(const C of e.agents.values())C.sessionId===t&&s.push(C);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,b=0;for(const C of s){const S=Un(C);a.input+=S.input,a.output+=S.output,a.cacheRead+=S.cacheRead,a.cacheWrite+=S.cacheWrite,a.total+=S.total;for(const $ of bP(C))o.add($);C.model&&o.add(C.model),C.kind==="subagent"&&p++;const _=tP(C.prompts);u+=_.length,!m&&_.length>0&&(m=_[0].text),h+=C.usage.inputTokens+C.usage.outputTokens,l+=C.toolCount,f+=C.toolErrorCount??0;for(const[$,A]of C.toolCountByName??[])i.set($,(i.get($)??0)+A);w=Math.min(w,C.startedAt),b=Math.max(b,C.endedAt??Date.now())}const k=Math.max(0,b-w),v=Math.floor(k/1e3),N=v<60?`${v}s`:v<3600?`${Math.floor(v/60)}m ${String(v%60).padStart(2,"0")}s`:`${Math.floor(v/3600)}h ${Math.floor(v%3600/60)}m`,x=Array.from(i.entries()).sort((C,S)=>S[1]-C[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 rB(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||!Cn(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 WO({provider:e}){const t=e==="Codex"?"recoverCodexSessions":"recoverClaudeSessions",n=`${e.toLowerCase()}-session-recovery`,s=rB(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,...Bn(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(ibe,{})]})}function ibe(){const e=rB("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,...Bn(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 lbe="Hide finished sessions after",cbe="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 ube(){const e=f8();return r.jsx(Bt,{id:"settings-board-caption",title:"Board",children:r.jsx(mt,{settingId:"hide-finished",name:lbe,nameId:"settings-hide-finished-label",note:"Hidden sessions stay available in the session list.",details:cbe,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=>lge(Number(t.target.value)),children:c8.map(t=>r.jsx("option",{value:t,children:ige(t)},t))})})})}const dbe="Accounts and auto-switch",hbe="Your Claude accounts, and Auto-switch, which moves Claude Code to another one before the account in use runs out.",fbe="Local network",pbe="Pairing with the decks on your other machines, so a login that expires on one is repaired from another.",mbe="Browser Watch",gbe="Whether something drove your browser while you were away, and what the deck does about it.";function ybe({claudeHere:e,singleKeys:t,doors:n}){return r.jsxs(Bt,{id:"settings-elsewhere-caption",title:"Elsewhere on the deck",children:[e&&r.jsx(Z0,{settingId:"accounts",name:dbe,note:hbe,onOpen:n.accounts,cap:t?{key:"A",title:"Press A anywhere to show or hide the accounts panel"}:null}),e&&r.jsx(Z0,{settingId:"local-network",name:fbe,note:pbe,onOpen:n.localNetwork,cap:null}),r.jsx(Z0,{settingId:"browser-watch",name:mbe,note:gbe,onOpen:n.browserWatch,dialog:!0,cap:t?{key:"B",title:"Press B anywhere to open or close Browser Watch"}:null})]})}function Z0({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 wbe="Single-key shortcuts",xbe="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 vbe(e){const t=e.binds.includes("?")?"the keyboard shortcuts sheet":e.action;return t.charAt(0).toUpperCase()+t.slice(1)}function bbe(e,t){const n=t.trim().toLowerCase();return n?[e.action,e.cap,e.macCap??""].some(s=>s.toLowerCase().includes(n)):!0}function kbe({singleKeys:e,onToggleSingleKeys:t}){const n=po(ro()),[s,a]=g.useState(""),o=g.useId(),i=$d(),l=X8(e,u=>ra(i,u)).map(u=>({...u,rows:u.rows.filter(h=>bbe(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:wbe,nameId:"settings-single-keys-label",note:xbe,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=>{nm(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:vbe(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:Y8})]})}function jbe({notifyOn:e,onToggleNotify:t,notifyVetoed:n,notifyPermission:s,onAskNotify:a,accountNotify:o,onToggleAccountNotify:i}){const l=_ee(s),u=co(),h=e&&!n&&!u,f=g.useRef(null),p=na(!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?Nee:jee(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?Cee:See,children:zD.map(({kind:m,label:w,title:b})=>r.jsx(mt,{settingId:m,name:w,nameId:`sm-${m}-label`,note:b,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 Nbe=["audio/webm;codecs=opus","audio/ogg;codecs=opus","audio/mp4"];function Sbe(e){return Nbe.find(t=>e(t))}const Cbe=4400;function _be(e){const t=e.split(";")[0];return{name:`Recorded voice.${t==="audio/mp4"?"m4a":t==="audio/ogg"?"ogg":"webm"}`,type:t}}function Ebe({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=Sbe(v=>MediaRecorder.isTypeSupported(v)),b=new MediaRecorder(p,w?{mimeType:w}:void 0),k=[];i.current=b,b.ondataavailable=v=>{v.data.size&&k.push(v.data)},b.onerror=()=>t("Recording failed. Please try again."),b.onstop=()=>{p.getTracks().forEach(C=>C.stop()),l.current!==null&&clearTimeout(l.current),l.current=null;const v=i.current===b;if(v&&(i.current=null),o(!1),!v||!k.length)return;const N=_be(b.mimeType),x=new File(k,N.name,{type:N.type});n(()=>s(x))},b.start(200),o(!0),l.current=setTimeout(h,Cbe)}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 Tbe({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"),[b,k]=g.useState([]);return g.useEffect(()=>{if(typeof window>"u"||!("speechSynthesis"in window))return;const v=()=>{k(window.speechSynthesis.getVoices())};return v(),window.speechSynthesis.addEventListener("voiceschanged",v),()=>window.speechSynthesis.removeEventListener("voiceschanged",v)},[]),r.jsxs("details",{className:"sm-voice",children:[r.jsxs("summary",{className:"settings-row",...t,onClick:v=>{const N=v.currentTarget.parentElement;e&&N&&!N.open&&v.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:v=>o(v.target.value)})]}),r.jsxs("label",{children:[r.jsx("span",{children:"Text"}),r.jsx("input",{className:"ap-manage-input",value:i,maxLength:180,onChange:v=>l(v.target.value)})]}),r.jsxs("label",{children:[r.jsx("span",{children:"Voice"}),r.jsxs("select",{className:"sm-select",value:u,onChange:v=>h(v.target.value),children:[r.jsx("option",{value:"",children:"System default"}),b.map(v=>r.jsx("option",{value:v.voiceURI,children:v.name},v.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:v=>p(v.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:v=>w(v.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 Abe({customAssets:e,onImportCustom:t,onCreateVoice:n,onRenameCustom:s,onPreviewCustom:a,onDeleteCustom:o}){const[i,l]=g.useState(""),u=e.length,h=U1(u),f=h!==null,p=f?{"aria-disabled":!0,"aria-describedby":"sm-custom-full"}:{},[m,w]=g.useState(null),b=g.useRef(0),k=g.useRef(new Map),v=g.useRef(null),N=g.useRef(null);g.useEffect(()=>{if(!m)return;const A=window.setTimeout(()=>w(null),4e3);return()=>window.clearTimeout(A)},[m]);const x=async A=>{l("");try{await A()}catch(O){l(O instanceof Error?O.message:"Custom audio could not be saved.")}},C=(A,O)=>{const M=Date.now(),W=yi({armedFor:m,target:A,armedAt:b.current,now:M,gapMs:gi});if(W==="arm"){w(A),b.current=M;return}if(W==="ignore")return;w(null);const B=Iee(e.map(R=>R.id),A);x(async()=>{var q;await o(A);const R=document.activeElement;R!==O&&!Wn((R==null?void 0:R.tagName)??null)||(q=B?k.current.get(B):v.current)==null||q.focus()})},{recording:S,startRecording:_,stopRecording:$}=Ebe({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 ",q1]}),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:v,type:"button",className:"btn sm-custom-action",...p,onClick:()=>{var A;f||(A=N.current)==null||A.click()},children:"Choose file"}),children:r.jsx("input",{ref:N,type:"file",hidden:!0,accept:"audio/wav,audio/x-wav,audio/mpeg,audio/mp3,audio/ogg,.wav,.mp3,.ogg",onChange:A=>{var M;const O=(M=A.target.files)==null?void 0:M[0];A.currentTarget.value="",O&&!f&&x(()=>t(O))}})}),r.jsx(mt,{as:"div",settingId:"custom-record",name:"Record a clip",note:S?"Recording…":"Up to 5 seconds",control:S?r.jsx("button",{type:"button",className:"btn sm-custom-action",onClick:$,children:"Stop & save"}):r.jsx("button",{type:"button",className:"btn sm-custom-action",...p,onClick:()=>void _(),children:"Record"})}),r.jsx(Tbe,{full:f,fullProps:p,runCustom:x,onCreateVoice:n}),e.map(A=>r.jsxs("div",{className:"sm-custom-item",children:[r.jsx("input",{className:"ap-manage-input","aria-label":`Rename ${A.name}`,defaultValue:A.name,maxLength:80,onBlur:O=>{if(!O.target.value.trim()){O.target.value=A.name;return}x(()=>s(A.id,O.target.value))},onKeyDown:O=>{O.key==="Enter"&&O.currentTarget.blur()}}),r.jsx("span",{children:A.kind==="audio"?`${A.duration.toFixed(1)}s`:"Voice"}),r.jsx("button",{type:"button",className:"btn sm-custom-icon","aria-label":`Play ${A.name}`,onClick:()=>a(A.id),children:"Play"}),r.jsx("button",{type:"button",ref:O=>{O?k.current.set(A.id,O):k.current.delete(A.id)},className:`btn sm-custom-icon${m===A.id?" armed":""}`,onKeyDown:O=>{O.repeat&&O.preventDefault()},onClick:O=>C(A.id,O.currentTarget),"aria-label":m===A.id?`Confirm deleting ${A.name}`:`Delete ${A.name}`,title:m===A.id?"Press again to delete this sound. It cannot be brought back.":"Delete this sound",children:m===A.id?"Confirm":"Delete"})]},A.id)),i&&r.jsx("p",{className:"settings-row settings-row-status sm-custom-error",role:"alert",children:i})]})}const Rbe="A tone when a turn finishes, and when Claude asks for something.";function Mbe({soundOn:e,onToggleSound:t}){const n=g.useId(),s=An(),a=g.useId();return r.jsx(Bt,{children:r.jsx(mt,{settingId:"play-sounds",name:"Play sounds",nameId:n,note:Rbe,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 Mj="custom:";function HO(e){return`${Mj}${e}`}function $be(e){return e.startsWith(Mj)?e.slice(Mj.length):null}function Lbe({id:e,label:t="Volume",value:n,step:s=DN,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:Pf,max:mp,step:s,value:n,"aria-describedby":o,onChange:i=>a(Number(i.target.value)),style:{"--sm-level":`${(n-Pf)/(mp-Pf)*100}%`}}),r.jsxs("span",{className:"sm-read",children:[n,"%"]})]})}const zO={done:"Turn finished","needs-input":"Claude is asking"},Ibe={done:"Plays when Claude or Codex finishes a turn.","needs-input":"Available in Claude Code only."};function Obe({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:zO[e],note:Ibe[e],settingId:`tone-${e}`,aside:r.jsxs("button",{type:"button",className:"btn sm-hear",onClick:()=>l(e),"aria-label":`Hear the ${zO[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(Lbe,{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?HO(m):t.figure,onChange:w=>{const b=w.target.value,k=$be(b);k!==null?h(e,k):(u(e),i(e,b))},children:[PN[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:HO(w.id),children:w.name},w.id))})]})]})]})}const Pbe="Claude Code isn't on this machine, so only Turn finished plays here — for Codex turns.";function Dbe({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:b,onDeleteCustom:k}){var C;const v=$ee(u),N=((C=l.find(S=>S.id===v))==null?void 0:C.name)??"the same custom sound",x=v?`Both tones use “${N}”. They may be harder to tell apart.`:"";return r.jsxs("div",{className:"sm-sounds",children:[r.jsx(Mbe,{soundOn:e,onToggleSound:t}),!s&&r.jsx("p",{className:"sm-note",children:Pbe}),!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(S=>r.jsx(Obe,{chime:S,tone:n[S],soundOn:e,customAssets:l,customSelections:u,onLevel:a,onFigure:o,onPreview:i,onBuiltInSelected:h,onCustomSelected:f},S))}),x&&r.jsx("p",{className:"sm-note","aria-hidden":!0,children:x}),r.jsx("p",{className:"vis-hidden",role:"status",children:x}),r.jsx(Abe,{customAssets:l,onImportCustom:p,onCreateVoice:m,onRenameCustom:w,onPreviewCustom:b,onDeleteCustom:k})]})}const Fbe="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 Bbe({onOpen:e}){return r.jsx(Bt,{children:r.jsx(mt,{as:"div",settingId:"radar-open",name:"Radar",nameId:"settings-radar-open-name",note:Fbe,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 qbe=6500,Ube=1e4;let ui={reading:null,saving:null,error:"",undone:null};const Wf=new Set;let pu=null,mu=null,la=null,J0=!1,Hf=0;const Jo=e=>{ui={...ui,...e},Wf.forEach(t=>t(ui))};function aB(e){const t=e;return!!t&&t.ok===!0&&Array.isArray(t.settings)&&typeof t.present=="object"}async function oB(e){const t=await fetch("/api/claude-settings",{signal:e}),n=await t.json();if(!t.ok||!aB(n))throw new Error;return n}async function $j(){if(J0||ui.saving)return;J0=!0;const e=Hf,t=new AbortController;la=t;let n=!1;const s=setTimeout(()=>{n=!0,t.abort()},5e3);try{const a=await oB(t.signal);e===Hf&&!t.signal.aborted&&Jo({reading:a,error:""})}catch{e===Hf&&(n||!t.signal.aborted)&&Jo({error:"Could not read Claude Code settings. Try again."})}finally{clearTimeout(s),J0=!1,la===t&&(la=null)}}function VO(e,t){var n;return(n=e==null?void 0:e.settings.find(s=>s.id===t))==null?void 0:n.value}async function GO(e,t){if(ui.saving)return;Hf++,la==null||la.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||!aB(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=VO(o,e);mu=setTimeout(()=>{mu=null;const l=new AbortController,u=setTimeout(()=>l.abort(),5e3);oB(l.signal).then(h=>{Jo({reading:h,undone:VO(h,e)===i?null:{id:e}})}).catch(()=>{}).finally(()=>clearTimeout(u))},qbe)}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 Wbe(){const[e,t]=g.useState(ui);return g.useEffect(()=>(Wf.add(t),t(ui),pu||($j(),pu=setInterval(()=>void $j(),Ube)),()=>{Wf.delete(t),Wf.size||(pu&&clearInterval(pu),pu=null,la==null||la.abort())}),[]),e}const Q0=40,Hbe={boolean:"on or off",choice:"a choice",number:"a number",text:"text",structured:"a list or object"};function zbe(e){const t=e.scope==="Global config"?"kept in ~/.claude.json":e.scope==="Managed"?"managed settings only":null;return[e.topic,Hbe[e.kind],t,e.since?`Claude Code ${e.since}+`:null].filter(Boolean).join(" · ")}function Vbe(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 iB=null;const Gbe=()=>iB??(iB=bi(()=>import("./claude-settings-index-1Qg1AUda.js"),[]).then(e=>e.default.keys));function Kbe({present:e,noFile:t=!1}){const[n,s]=g.useState(null),[a,o]=g.useState(""),i=g.useId();g.useEffect(()=>{let f=!0;return Gbe().then(p=>{f&&s(p)},()=>{iB=null}),()=>{f=!1}},[]);const l=g.useMemo(()=>{if(!n)return[];if(a.trim())return Vbe(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,Q0),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=>{nm(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:zbe(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:`${wee}#${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>Q0&&r.jsxs("p",{className:"settings-foot",role:"status",children:[l.length-Q0," 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 Ybe="Changed back after saving, most likely by a running Claude Code session. Set it again to keep it.",Xbe="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 Jbe(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 KO="\0custom";function Qbe({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:fA(m)})):e.options,f=t?t.custom?KO:t.value===null?"":String(t.value):"",p=e.kind==="days"&&t&&!t.custom&&!h.some(m=>m.value===f)?[...h,{value:f,label:fA(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;GO(e.id,e.kind==="days"?Number(w):w===""?null:w)},children:[(t==null?void 0:t.custom)&&r.jsx("option",{value:KO,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&&GO(e.id,!u)},children:r.jsx("span",{className:"switch-knob"})})}function eke(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 tke(){return r.jsx(nke,{state:Wbe()})}function nke({state:e}){const{reading:t,saving:n,error:s,undone:a}=e,o=eke(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:Xbe}),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&&UD.map(u=>r.jsx(Bt,{id:`claude-group-${u.id}`,title:u.title,children:WD.filter(h=>h.group===u.id).map(h=>{const f=t==null?void 0:t.settings.find(b=>b.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?Ybe:f!=null&&f.override?Jbe(f.override):"";return r.jsx(mt,{settingId:`claude-${h.id}`,name:h.label,nameId:p,note:h.note,noteId:m,control:r.jsx(Qbe,{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(Kbe,{present:(t==null?void 0:t.present)??null,noFile:i})]})}const ske="Local statistics for Claude and Codex on this device. Commands are grouped by operation; raw arguments and outputs are not saved.";function rke(){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 k=new AbortController,v=window.setTimeout(()=>k.abort(),12e3);try{const N=await fetch("/api/tool-audit/storage",{signal:k.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(v),f.current=!1,p.current&&o(!1)}};g.useEffect(()=>(p.current=!0,m(),()=>{p.current=!1}),[]);const w=async(k,v)=>{if(f.current)return;f.current=!0,o(!0),s(""),h("");let N=!1;const x=new AbortController,C=window.setTimeout(()=>x.abort(),15e3);try{const S=await fetch("/api/tool-audit/storage",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(k==="clear"?{action:k,confirm:!0}:{action:k,days:v}),signal:x.signal}),_=await S.json();if(!S.ok||!_.ok)throw new Error;N=!0,p.current&&(l(null),h(k==="clear"?"Tool history cleared. New calls will continue to be recorded.":`Retention changed to ${v} days.`))}catch{p.current&&s("Could not update tool history. Check storage permissions and try again.")}finally{window.clearTimeout(C),f.current=!1,p.current&&(o(!1),N&&m())}},b=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:ske,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:k=>{if(f.current)return;const v=Number(k.target.value);v<e.retentionDays?l(v):w("retention",v)},children:[30,60,90].map(k=>r.jsxs("option",{value:k,children:[k," days"]},k))})}),typeof i=="number"&&b,r.jsx(mt,{as:"div",settingId:"tool-history-size",name:"Space used",note:`Collected since ${Ete(e.startedAt)}`,control:r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"settings-read",children:_te(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"&&b,!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 Lj="agent-dag.integrations.active",zS=(e,t)=>`agent-dag.integrations.prefs.${e}:${t}`,ake=32e3;function YO(e,t){const n=nt(zS(e,t));if(!n)return{};try{const s=JSON.parse(n);return s&&typeof s=="object"&&!Array.isArray(s)?s:{}}catch{return{}}}function kje(e,t){return{read(n,s){const a=YO(e,t)[n];return s(a)?a:void 0},write(n,s){const a=YO(e,t);s===void 0?delete a[n]:a[n]=s;const o=JSON.stringify(a);o.length<=ake&&st(zS(e,t),o)}}}function oke(e,t){ks(zS(e,t))}function jje(e){const t=nt(Lj);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 Nje(e,t){let n={};try{const s=nt(Lj),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(Lj,JSON.stringify(n))}function Ij(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 Oj(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 ike({connection:e,provider:t,available:n,busy:s,armed:a,note:o,headingRef:i,onTest:l,onEdit:u,onDisconnect:h,onCancelDisconnect:f}){var S;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",b=e.account.name&&e.account.login!==e.account.name?e.account.login:"",k=Ij(e),v=Oj(e),N=Array.isArray((S=e.meta)==null?void 0:S.warnings)?e.meta.warnings.filter(_=>typeof _=="string"):[],x=s===`test:${e.id}`,C=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,b?` (${b})`:""]})]}),r.jsxs("div",{children:[r.jsx("dt",{children:"Last verified"}),r.jsx("dd",{children:k??"No verification time available"})]}),r.jsxs("div",{children:[r.jsx("dt",{children:"Credentials"}),r.jsx("dd",{children:e.tokenSaved?"Stored locally":"No token saved"})]}),v&&r.jsxs("div",{children:[r.jsx("dt",{children:"Server"}),r.jsx("dd",{children:v})]})]}),!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":C,"aria-disabled":s!==null||void 0,onKeyDown:_=>{_.repeat&&_.preventDefault()},"aria-label":a?`Confirm disconnecting ${e.name}`:`Disconnect ${e.name}`,onClick:_=>h(_.currentTarget),children:C?"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 lke({onBeforeLeaveChange:e}={}){var He;const t=$d(),{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(""),b=g.useRef(null),k=g.useRef(null),[v,N]=g.useState(null),[x,C]=g.useState(null),S=g.useRef(null),[_,$]=g.useState(null),[A,O]=g.useState([]),[M,W]=g.useState(null),B=g.useRef(0),[R,q]=g.useState(null),T=g.useRef(null),F=g.useRef(new Map),D=g.useRef(null),K=g.useRef(0),[V,H]=g.useState(!1),[P,I]=g.useState(null),U=g.useRef(null),Z=g.useRef(new Map),z=g.useRef(new Map);g.useEffect(()=>{const se=Yye();se&&(D.current=Z.current.get(se)??null,p(se),q(se),N({mode:"edit",id:se}));const ke=Kye();ke&&N({mode:"add",kind:ke})},[]),g.useEffect(()=>{var se,ke;!R||!n||(ke=(se=z.current.get(R))==null?void 0:se.scrollIntoView)==null||ke.call(se,{block:"nearest"})},[R,n]),g.useEffect(()=>{if(!M)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()),W(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)}},[M]);const X=(se,ke,Ae,Oe)=>O(be=>[...be.filter(fe=>fe.id!==se),{id:se,tone:ke,text:Ae,scope:Oe}]),Y=se=>O(ke=>ke.filter(Ae=>Ae.id!==se)),J=async(se,ke)=>{if(!S.current){S.current=se,C(se);try{await ke()}finally{S.current=null,C(null)}}},Q=se=>(ke,Ae)=>void J("form",async()=>{$(null);try{const Oe=await Wye(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){$(Oe instanceof vr?Oe:new vr("upstream","The connection could not be saved."))}}),te=se=>(ke,Ae)=>void J("form",async()=>{$(null);try{const{connection:Oe,validated:be}=await Hye(se.id,{name:Ae,input:ke});N(null),I(null),H(!1),T.current=()=>k.current??(f?b.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){$(Oe instanceof vr?Oe:new vr("upstream","The change could not be saved."))}}),le=se=>void J(`test:${se.id}`,async()=>{W(null),Y(se.id);try{const ke=await zye(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(S.current)return;const Ae=Date.now(),Oe=yi({armedFor:M,target:se.id,armedAt:B.current,now:Ae,gapMs:gi});if(Oe==="arm"){ke.focus({preventScroll:!0}),W(se.id),B.current=Ae;return}Oe!=="ignore"&&(W(null),J(`delete:${se.id}`,async()=>{try{await Vye(se.id),oke(se.kind,se.id),Y(se.id),(v==null?void 0:v.mode)==="edit"&&v.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||Wn((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||P||!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,v,x,P]);const oe=n??[],re=Ld(t),he=["github","gitlab","jira"],pe=qS().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=WS(t),ge=g.useCallback(()=>{N(null),p(null),o(null),H(!1),I(null),$(null),W(null),T.current=()=>{const se=D.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),$(null),W(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),$(null),T.current=()=>k.current??(f?b.current:i.current)},[f,a,ge]),Ee=g.useCallback((se,ke=!1)=>{if(S.current)return;if(P&&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?v?je:f?ve:ge:()=>{N(null),p(null),o(null),se()};V?I(()=>Ae):(H(!1),Ae())},[V,P,v,f,je,ve,ge]);g.useEffect(()=>(e==null||e(v||f||a?Ee:null),()=>e==null?void 0:e(null)),[v,f,a,Ee,e]),g.useEffect(()=>{var se;P&&((se=U.current)==null||se.focus())},[P]),g.useEffect(()=>{var se;f&&((se=b.current)==null||se.focus())},[f]),g.useEffect(()=>{var se;a&&((se=i.current)==null||se.focus())},[a]);const xe=(se,ke)=>{var Oe;if(S.current)return;T.current=null,I(null),w(""),W(null),f||a?k.current=ke:(K.current=((Oe=ke.closest(".settings-pane"))==null?void 0:Oe.scrollTop)??0,D.current=ke,k.current=null),H(!1),$(null),N(se);const Ae=ke.closest(".settings-pane");Ae&&(Ae.scrollTop=0)},Ie=(se,ke)=>{var Oe,be;if(S.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,D.current=ke),k.current=null,w(""),W(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(S.current)return;T.current=null,K.current=((be=ke.closest(".settings-pane"))==null?void 0:be.scrollTop)??0,D.current=ke,u.current=null,h.current=0,w(""),W(null),o(se);const Oe=ke.closest(".settings-pane");Oe&&(Oe.scrollTop=0)},We=(se,ke=!1)=>{const Ae=_u(se.kind),Oe=!ra(t,se.kind),be=Ij(se),fe=se.account.login||se.account.name,_e=se.kind==="jira"?Oj(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=(v==null?void 0:v.mode)==="edit"?oe.find(se=>se.id===v.id):void 0,rt=(v==null?void 0:v.mode)==="add"?pe.find(se=>re.has(se.kind)&&se.kind===v.kind):Re&&pe.find(se=>re.has(se.kind)&&se.kind===Re.kind);return r.jsxs("div",{className:"ig-settings","data-view":v?"form":f?"connection":a?"provider":"overview",children:[v&&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"]}),P&&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:U,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=P;I(null),H(!1),N(null),se()},children:"Discard changes"})]})]}),r.jsx("div",{hidden:!!P,children:rt?r.jsx(xye,{def:rt,existing:Re,busy:x==="form",error:_,onDirtyChange:H,onSubmit:v.mode==="add"?Q(v.kind):te(Re),onCancel:()=>Ee(je,!0)},v.mode==="add"?v.kind:v.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:v!==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"]}),ra(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:v!==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&&ra(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(ike,{connection:$e,provider:_u($e.kind),available:ra(t,$e.kind),busy:x,armed:M===f,note:A.find(se=>se.id===f),headingRef:b,onTest:()=>le($e),onEdit:se=>xe({mode:"edit",id:$e.id},se),onDisconnect:se=>de($e,se),onCancelDisconnect:()=>W(null)}):r.jsx("p",{role:"status",children:"This connection is no longer saved."})]}),r.jsxs("div",{className:"ig-overview",hidden:v!==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 Gm(),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&&Ij(Ae),fe=(Ae==null?void 0:Ae.kind)==="jira"?Oj(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:"Browsing integrations only reads. Jira also saves sprint and rank changes when you drag an issue or confirm Move, subject to your Jira permissions. GitHub and GitLab remain read-only. Tokens stay on this machine and are never shown again or shared with paired decks."})]})})})]})]})}function cke({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 uke({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=(gr.indexOf(l??e)+(i.key==="ArrowLeft"||i.key==="ArrowUp"?-1:1)+gr.length)%gr.length;t(gr[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:gr.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(cke,{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 dke=[["smallest","Smallest","11 px"],["smaller","Smaller","12 px"],["default","Default","13 px"],["larger","Larger","15 px"],["largest","Largest","17 px"]],hke=[["tightest","Tightest","30%"],["tighter","Tighter","50%"],["compact","Compact","70%"],["default","Default","100%"],["comfortable","Comfortable","140%"]];function XO(){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 fke({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 pke({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":jA.length,"--reading-selected":jA.indexOf(e)},children:dke.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(XO,{})]},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":NA.length,"--reading-selected":NA.indexOf(t)},children:hke.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(XO,{})]},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 mke="AGPL-3.0-only",gke="GNU Affero General Public License, version 3 only.",yke="https://github.com/BarganConstantin/ccdeck",wke="What changed in each release, newest first.",xke="Tell the people who make ccdeck what works and what does not.";function vke(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 bke(e,t){return lo(e)&&lo(t)&&vi(e,t)<0}function kke(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 jke({version:e,notice:t,readyAppUpdate:n,updateRestarting:s,updateFailure:a,onUpdateRestart:o,doors:i,bundle:l="3.48.0"}){const u=(e==null?void 0:e.running)??l,h=kke(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:bke(l,e==null?void 0:e.running)?vke(l):void 0,control:r.jsx("span",{className:"settings-read",children:u})}),h&&r.jsx(Nke,{offer:h,restarting:s,failure:a,onRestart:o,onUpdate:i.update}),r.jsx(mt,{as:"div",settingId:"whats-new",name:"What's new",note:wke,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:gke,control:r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"settings-read",children:mke}),r.jsxs("a",{className:"settings-link",href:yke,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:Rj,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:xke,control:r.jsx("button",{type:"button",className:"btn","aria-haspopup":"dialog","aria-label":"Open the feedback dialog",onClick:i.feedback,children:"Open"})})]})]})}function Nke({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=I8(e.to,t),i=n&&n.version===e.to?O8(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 Ske="Update when idle",Cke="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.",_ke=`${nB} 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.`,Eke="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.",Tke="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 Ake(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 Rke={plain:Cke,"checks-off":_ke,"no-restart":Eke};function Mke({autoRestart:e,onToggleAutoRestart:t,version:n,inApp:s=co()}){const a=Ake(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:Tke}):r.jsx(mt,{settingId:"auto-update",name:Ske,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:Rke[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=uS(a,o,Of.length,"vertical");i.kind==="select"&&(a.preventDefault(),t(Of[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:Of.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(yD,{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 Lke="Stands beside the minimap. Press it to play the radio.";function Ike({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:Lke,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 ZO="settings-search-field",lB="settings-search-results",Pj=e=>`settings-result-${e}`;function Oke({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=vte(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:ZO,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:ZO,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?lB:void 0,"aria-activedescendant":u?Pj(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 Pke({query:e,results:t,active:n,onOpen:s}){const a=s5(t.length,e);return g.useEffect(()=>{var o,i;(i=(o=document.getElementById(Pj(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:lB,role:"listbox","aria-label":"Matching settings",children:t.map((o,i)=>r.jsxs("button",{type:"button",role:"option",id:Pj(i),className:"settings-result",tabIndex:-1,"aria-selected":i===n,"aria-label":gte(o),"data-highlighted":i===n,onMouseDown:l=>l.preventDefault(),onClick:()=>s(o),children:[r.jsx(gm,{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:qN(o)})]})]},o.id))})})]})}function Dke({query:e,count:t}){return r.jsx("p",{className:"vis-hidden",role:"status",children:e.trim()?s5(t,e):""})}const Fke=1500,Bke=3e3,qke=e=>e.checkVisibility?e.checkVisibility():e.getClientRects().length>0;function Uke(e){if(e.matches(np)&&!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(np)).filter(s=>AP({disabled:s.disabled,tabIndex:s.tabIndex,rendered:qke(s)}));return n.find(s=>s.closest(".settings-list")!=null)??n[0]??null}function Wke(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 k,v;a(null);const b=w.offsetHeight>l.clientHeight-48;w.scrollIntoView({block:b?"start":"center"}),(k=Uke(w))==null||k.focus({preventScroll:!0}),window.clearTimeout(o.current),(v=i.current)==null||v.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)},Fke)},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)},Bke);return()=>{p.disconnect(),window.clearTimeout(m)}},[e,s,t,n]),a}function Hke({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 b=g.useRef(null),k=g.useCallback(be=>{b.current=be},[]);function v(be,fe=!1){b.current?(P(""),b.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=()=>v(s,!0),x=g.useRef(null),C=gt(N,{focusRef:x}),S=yt(()=>v(s)),_=g.useRef([]),$=$d(),A=WS($),O=dee(A,e,a.claude),M=Math.max(0,O.findIndex(be=>be.id===e)),W=ic("(max-width: 640px)"),[B,R]=g.useState(""),[q,T]=g.useState(0),F=g.useRef(null),D=g.useRef(null),K=B.trim()!=="",V=g.useMemo(()=>xte(B,n5(a.claude,A,Ld($))),[B,a.claude,A,$]),H=Wke(D,!K,e),P=be=>{R(be),T(0)};g.useEffect(()=>{t&&H(t)},[t,H]);const I=be=>{v(()=>{P(""),n(be),requestAnimationFrame(()=>{var fe;return(fe=document.getElementById(`settings-tab-${be}`))==null?void 0:fe.focus()})})},U=be=>{v(()=>{P(""),n(be.section),mm(be)||H(be.id)})};g.useEffect(()=>{const be=fe=>{var ot,tt;if(!yee(fe))return;const _e=C.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)},[C]),g.useEffect(()=>{var be,fe,_e,Ve;hee((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=An(),le=be=>{const fe=uS(be,M,O.length,"vertical");fe.kind!=="pass"&&(be.preventDefault(),v(()=>{var _e;P(""),n(O[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(Bbe,{onOpen:w.radar});case"claude":return r.jsx(tke,{});case"appearance":return r.jsxs(r.Fragment,{children:[r.jsx(uke,{theme:Z,onTheme:z,singleKeys:te}),r.jsx(Ike,{characterEnabled:X,character:J,onCharacter:Q,onToggleCharacter:()=>Y(be=>!be)})]});case"reading":return r.jsx(pke,{textSize:h.textSize,density:h.density,onTextSize:h.setTextSize,onDensity:h.setDensity});case"keyboard":return r.jsx(kbe,{singleKeys:te,onToggleSingleKeys:()=>OY(!te)});case"notifications":return r.jsx(jbe,{notifyOn:Fe,onToggleNotify:Re,notifyVetoed:$e,notifyPermission:rt?ye:"unsupported",onAskNotify:He,accountNotify:se,onToggleAccountNotify:ke});case"sounds":return r.jsx(Dbe,{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(lke,{onBeforeLeaveChange:k});case"data":return r.jsx(rke,{});case"about":return r.jsx(jke,{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(ube,{}),r.jsx(WO,{provider:"Codex"}),a.claude&&r.jsx(WO,{provider:"Claude"}),r.jsx(Mke,{autoRestart:m.autoRestart,onToggleAutoRestart:m.toggleAutoRestart,version:f.version}),r.jsx(ybe,{claudeHere:a.claude,singleKeys:te,doors:w})]})}})(),Oe=e==="reading"?r.jsx(fke,{textSize:h.textSize,density:h.density,onTextSize:h.setTextSize,onDensity:h.setDensity}):e==="integrations"&&$.connections!==null?r.jsxs("span",{className:"ig-total",children:[$.connections.length," saved connection",$.connections.length===1?"":"s"]}):null;return r.jsx("div",{className:"modal-backdrop",...S,role:"presentation",children:r.jsxs("div",{ref:C,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:()=>v(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(Oke,{inputRef:F,query:B,onQuery:P,results:V,active:q,onActive:T,onOpen:U}),r.jsx(Dke,{query:B,count:V.length}),r.jsx("div",{className:"settings-nav",role:"tablist","aria-label":"Settings sections","aria-orientation":W?"horizontal":"vertical",onKeyDown:le,children:O.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(gm,{section:be.id}),r.jsx("span",{className:"settings-tab-label",children:be.label})]},be.id))})]}),r.jsxs("div",{ref:D,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:O[M].label}),r.jsx("p",{className:"settings-pane-note",children:O[M].note})]}),Oe]}),Ae]},e),K&&r.jsx(Pke,{query:B,results:V,active:q,onOpen:U})]})]})})}function zke({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=uV(e.name,i,l);return{input:f.input.map((p,m)=>r.jsx(JO,{block:p},m)),response:f.response.map((p,m)=>r.jsx(JO,{block:p},m)),copyInput:JE(e.name,"input",i),copyResponse:JE(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:EP(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(QO,{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(QO,{text:h.copyResponse,what:"response"})]}),e.endedAt==null?r.jsx("pre",{children:"(waiting…)"}):h.response]})]})]})})}const Vke={del:"tm-del",add:"tm-add",ctx:"tm-ctx"};function JO({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(()=>sV(e),[e]),{shown:a}=nP(s,t),o=rV(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?Vke[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 QO({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 Gke=Vm(()=>bi(()=>import("./UsageHistoryModal-MgZJLXbF.js"),[]),"Usage history"),Kke=Vm(()=>bi(()=>import("./BrowserWatchModal-DuopT2Oa.js"),[]),"Browser Watch"),Yke=Vm(()=>bi(()=>import("./TrafficRadar-DZA8XSi7.js"),[]),"Telemetry Radar");function Xke({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:b,menus:k,sound:v,tones:N,customTones:x,notify:C,panelDoors:S}){const{openedTool:_,setOpenedToolKey:$,usageHistoryOpen:A,setUsageHistoryOpen:O,browserWatchOpen:M,setBrowserWatchOpen:W,contextAgent:B,setContextFor:R,summaryFor:q,setSummaryFor:T,keyHelpOpen:F,setKeyHelpOpen:D,feedbackOpen:K,setFeedbackOpen:V,feedbackPrefill:H,setFeedbackPrefill:P,openFeedback:I}=e,{trafficRadarOpen:U,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}=k;return r.jsxs(r.Fragment,{children:[_&&r.jsx(zke,{tool:_,onClose:()=>$(null)}),A&&r.jsx(g.Suspense,{fallback:null,children:r.jsx(Gke,{providers:m,onClose:()=>O(!1)})}),M&&r.jsx(g.Suspense,{fallback:null,children:r.jsx(Kke,{onClose:()=>W(!1),onSeen:He=>{De(""),Ie(He)},onWatching:xe,palette:We})}),B&&r.jsx(oK,{agent:B,onClose:()=>R(null)}),U&&r.jsx(g.Suspense,{fallback:null,children:r.jsx(Yke,{sessions:[...w.current.agents.values()].filter(He=>He.kind==="root"&&He.provider!=="codex").map(He=>({id:He.sessionId,label:tm(He.sessionName,He.sessionTitle).face??He.cwdBasename??He.label,project:He.cwdBasename??He.label,workspace:He.cwd})),onClose:()=>Z(!1)})}),K&&r.jsx(K8,{initialKind:H==null?void 0:H.initialKind,initialBody:H==null?void 0:H.initialBody,onClose:()=>{V(!1),P(null)}}),q&&r.jsx(abe,{state:w.current,sessionId:q,onClose:()=>T(null)}),Ke&&r.jsx(Hke,{section:ye,landOn:Fe,onSection:$e,onClose:Re,providers:m,sound:v,tones:N,customTones:x,notify:C,appearance:p,versionCheck:s,desktopUpdate:n,restart:a,doors:{whatsNew:Wa(Re,le),update:Wa(Re,()=>{le(),Le()}),tour:Wa(Re,X),feedback:Wa(Re,()=>I()),accounts:Wa(Re,S.accounts),localNetwork:Wa(Re,S.localNetwork),browserWatch:Wa(Re,()=>W(!0)),radar:Wa(Re,()=>Z(!0))}}),J&&r.jsx(rbe,{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)?O8(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(uve,{onClose:()=>D(!1),onTour:()=>{D(!1),X()},onSettings:()=>{D(!1),rt("keyboard")}}),z&&r.jsx(v6,{title:"What the deck shows you",steps:nle,onClose:Y}),ve&&r.jsx(exe,{agentCount:b,onConfirm:()=>Ee("confirmation"),onCancel:()=>je(!1)})]})}function Zke({lanPairs:e,attention:t}){const n=bve(e);return r.jsxs(r.Fragment,{children:[n,r.jsx(Sve,{...t,pairing:n!=null})]})}const Jke=10,cB=500,uB=4e3,Qke=[/ResizeObserver loop/i,/^Script error\.?$/i],e3=/^(?:[a-z][\w+.-]*-extension|webkit-masked-url):\/\//i,e0e=/[a-z][\w+.-]*:\/\/[^\s()]+/gi;function t0e(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(e0e)??[]:[]);return a.length?a.every(o=>e3.test(o)):typeof t=="string"&&e3.test(t)}const Dp=String.raw`[^\s\\/:'"\`<>|?*;,]`,n0e=String.raw`${Dp}(?:[^\\/\r\n:'"\`<>|?*;,]*${Dp})?[\\/]`,s0e=String.raw`[^\s\\/:'"\`<>|?*;,()]+`,gu=String.raw`(?:${n0e})*(?:${s0e})?`,r0e=String.raw`(?<![\w.~/\\\]-]|<(?:deck|host)>)(?:file://(?:/[A-Za-z]:)?[^\s:'"\`<>()]*|~[\\/]${gu}|[A-Za-z]:[\\/]${gu}|\\\\(?:[?.]\\)?(?:[A-Za-z]:\\)?${gu}|/(?=${Dp})${gu}|(?<!:)//(?=${Dp})${gu})`,a0e=String.raw`(?<![\w-])(?:[A-Za-z]--|-[A-Za-z0-9][\w.]*-)[\w.-]*`,o0e=new Set([".claude",".codex"]);function i0e(e){if(!e.startsWith("~"))return"<path>";const t=e[1],[n,...s]=e.slice(2).split(/[\\/]/);return n?o0e.has(n)?s.join("")?`~${t}${n}${t}<path>`:e:`~${t}<path>`:e}const l0e=String.raw`\b(https?|wss?)://[^\s/?#\\'"\x60<>(),;]+(?=(/assets/)?)`;function c0e(e,t,n){return n?"<deck>":`${t}://<host>`}const t3=String.raw`(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)`,dB=String.raw`${t3}(?:\.${t3}){3}`,e1=String.raw`[0-9A-Fa-f]{1,4}`,n3=String.raw`(?=[0-9A-Fa-f:]*\d)(?=[0-9A-Fa-f:]*::|(?:${e1}:){7})(?:(?:${e1})?:)+(?:${dB}|${e1})?`,s3=String.raw`%[\w-]+(?:\.[\w-]+)*`,r3=String.raw`(?:::1?|::ffff:(?:127(?:\.\d{1,3}){3}|0\.0\.0\.0))`,u0e=String.raw`(?<![\w:.%-])(?:\[(?!${r3}\])${n3}(?:${s3})?\]|(?!${r3}(?::\d{1,5})?(?![\w:%]|\.\d))${n3}(?:${s3})?(?![\w%]|\.\d))|(?<![\w./-])(?!127\.|0\.0\.0\.0\b)${dB}(?![\w-]|\.\d)`,t1=String.raw`(?=[\w.-]*[A-Za-z])[A-Za-z0-9][\w-]*(?:\.[\w-]+)*`,d0e=String.raw`(?<![\w.@/\\%-])(?!localhost(?![\w-]|\.\w))(?:(?<=\b(?:(?:getaddrinfo|connect) E[A-Z_]+|ENOTFOUND|EAI_AGAIN) )${t1}|${t1}(?=:\d{1,5}(?![\w:-]|\.\w))|${t1}\.(?:local|lan|home|internal|ts\.net)(?![\w-]|\.\w))`;function a3(e){return String(e??"").replace(/\/(?:home|Users)\/[^/\s:'"]+/g,"~").replace(/[A-Za-z]:\\(?:Users|Documents and Settings)\\[^\\\r\n:'"]+/gi,"~").replace(new RegExp(r0e,"g"),i0e).replace(new RegExp(a0e,"g"),"<project>").replace(new RegExp(l0e,"g"),c0e).replace(new RegExp(u0e,"g"),"<host>").replace(new RegExp(d0e,"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 hB=e=>{fetch("/api/client-error",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e),keepalive:!0}).catch(()=>{})};function h0e(e,t,n=hB){const s=String(e??"").slice(0,cB).trim();s&&n({message:s,stack:typeof t=="string"?t.slice(0,uB):void 0})}function f0e(e,t=window,n=hB){let s=0;const a=new Set,o=(u,h,f)=>{const p=String(u??"").slice(0,cB).trim();!e()||!p||s>=Jke||a.has(p)||Qke.some(m=>m.test(p))||t0e(h,f)||(a.add(p),s++,n({message:p,stack:typeof h=="string"?h.slice(0,uB):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 p0e=12;function m0e(e,t){const n=[a3(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,p0e).join(`
319
- `);n.push("",a3(a).trim())}return n.join(`
320
- `)}class g0e extends g.Component{constructor(){super(...arguments);qa(this,"state",{error:null,componentStack:null,reportOpen:!1});qa(this,"onKey",n=>{nm(n.key)&&rn.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}),h0e(n.message,n.stack),g8("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(K8,{initialKind:"bug",initialBody:m0e(n.message,s),onClose:()=>this.setState({reportOpen:!1})})]}):this.props.children}}const y0e=1e3;function w0e(e={}){const t=Math.max(1,Math.floor(e.limit??y0e)),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 b=0;if(o.size<a.length)for(;o.has(a[b]);)b++;const[k]=a.splice(b,1);o.delete(k),i++}return!1},setPaused(h){if(s=h,h)return[];const f=a;return a=[],o=new Set,i=0,f}}}function x0e(e){const t=g.useState(()=>w0e({protect:o=>bV(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&&oG(e.current);for(const l of i)e.current=pP(e.current,l);s(t.paused)},[t,e]);return{pauseGate:t,paused:n,togglePause:a}}const Dj={kind:"assumed",claude:!0,codex:!0};function v0e(e){if(!e||typeof e!="object")return Dj;const t=e.providers;if(!t||typeof t!="object")return Dj;const n=t;return{kind:"reported",claude:n.claude!==!1,codex:n.codex!==!1}}function b0e(e){const[t,n]=g.useState(null),[s,a]=g.useState(Dj);g.useEffect(()=>{let i=!1;return fetch("/api/health").then(l=>l.ok?l.json():null).then(l=>{i||(a(v0e(l)),!(!l||typeof l.workspace!="string")&&n(l.workspace))}).catch(()=>{}),()=>{i=!0}},[e]);const o=Fn(s);return{workspace:t,providers:s,providersRef:o}}const fB=3*6e4,k0e=2e4;function j0e({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>=fB&&await i()},stop:()=>{o=!1}}}async function N0e(){try{const e=await fetch("/api/provider-status",{signal:AbortSignal.timeout(k0e)});return e.ok?await e.json():null}catch{return null}}function S0e(e){const[t,n]=g.useState(null);return g.useEffect(()=>{if(!e){n(null);return}const s=j0e({fetchReport:N0e,visible:()=>document.visibilityState==="visible",now:()=>Date.now(),onReport:n});s.tick();const a=window.setInterval(s.tick,fB),o=()=>{s.wake()};return document.addEventListener("visibilitychange",o),()=>{s.stop(),window.clearInterval(a),document.removeEventListener("visibilitychange",o)}},[e]),t}const C0e={degraded:"degraded performance",partial_outage:"partial outage",major_outage:"major outage",maintenance:"maintenance"},_0e={degraded:"degraded",partial_outage:"partial outage",major_outage:"major outage",maintenance:"maintenance"},E0e={degraded:"degraded",partial_outage:"outage",major_outage:"outage",maintenance:"maint."},T0e={claude:"Claude",codex:"Codex"},A0e=new Set(["status.claude.com","status.openai.com"]),R0e=30*6e4,M0e=10*6e4;function $0e(e){if(typeof e!="string")return null;try{const t=new URL(e);return t.protocol==="https:"&&A0e.has(t.hostname)?t:null}catch{return null}}function o3(e){return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hourCycle:"h23"})}function L0e(e){const t=Math.floor(e/6e4);return t<1?"just now":t<60?`${t} min ago`:`${Math.floor(t/60)} h ago`}function I0e(e,t){if(!e||typeof e!="object")return null;const n=Jt(C0e,e.state),s=Jt(T0e,e.provider);if(!n||!s||typeof e.checkedAt!="number"||t-e.checkedAt>R0e)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>M0e,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 ${o3(e.checkedAt)}; this is the last thing it said`:`Reported by ${a.hostname}, checked ${L0e(t-e.checkedAt)}`,"Opens the status page"],u=i?o3(e.checkedAt):null;return{provider:e.provider,state:e.state,name:s,label:`${s} · ${n}${u?` · as of ${u}`:""}`,words:n,chipWords:Jt(_0e,e.state)??n,shortWords:Jt(E0e,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 O0e(e,t){return!(e!=null&&e.ok)||e.disabled||!Array.isArray(e.providers)?[]:e.providers.map(n=>I0e(n,t)).filter(n=>n!==null)}function P0e(e){return e.map(t=>`${t.name}'s status page reports ${t.state.endsWith("outage")?`a ${t.words}`:t.words}.`).join(" ")}const D0e="The providers' status pages report no incident.";function F0e({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=Uwe(e==null?void 0:e.upgrade),i=g.useRef(!1),l=g.useCallback(async()=>{if(Cn(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 i3="agent-dag.browserWatch.seenMs";function B0e(e,t){return e.filter(n=>n.startMs>t)}function q0e(){const[e,t]=g.useState(()=>Number(nt(i3))||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(()=>B0e(n,e).length,[n,e]),l=g.useCallback(u=>{t(u),st(i3,String(u))},[]);return{watchOn:a,setWatchOn:o,watchUnseen:i,markWatchSeen:l}}const pB="agent-dag.character-enabled",mB="agent-dag.fm-volume",U0e=1,l3="agent-dag.fm-source",Sje=[{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 W0e(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 H0e(e){return e!=="0"}function z0e(){return H0e(nt(pB))}function V0e(e){return JD(e,U0e)}function G0e(){return V0e(nt(mB))}const gB=["--err","--inflight","--ok","--warn","--muted","--grid-line","--minimap-mask","--panel","--line","--accent","--text-dim","--bg"];function c3(e){const t={};for(const n of gB)t[n]=e(n);return t}function K0e(e){return t=>e[t]??""}function Y0e(e,t){return gB.every(n=>e[n]===t[n])}function X0e(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 u3(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}function Z0e(){const[e,t]=g.useState(Ute),[n,s]=g.useState(Wte),[a,o]=g.useState(cte),i=g.useRef(a),[l]=g.useState(()=>X0e(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(()=>vt.flushSync(()=>o(x))))},[l]);g.useEffect(()=>()=>l.cancel(),[l]);const[h,f]=g.useState(z0e),[p,m]=g.useState(vee),[w,b]=g.useState(()=>c3(u3)),k=g.useMemo(()=>K0e(w),[w]),v=g.useCallback(N=>Kme(N,k),[k]);return g.useEffect(()=>{document.documentElement.dataset.textSize=e,st(V1,e)},[e]),g.useEffect(()=>{document.documentElement.dataset.density=n,st(G1,n)},[n]),g.useEffect(()=>{const N=x=>{x.storageArea===wr()&&((x.key===V1||x.key===null)&&t(HN(x.newValue)),(x.key===G1||x.key===null)&&s(u5(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(e5,a),b(N=>{const x=c3(u3);return Y0e(N,x)?N:x})},[a]),g.useEffect(()=>{st(pB,h?"1":"0")},[h]),g.useEffect(()=>{st(HD,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:v}}function J0e(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(x8(f.name));return Object.keys(w8).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(b=>b.getBoundingClientRect()),w=tQ(p,m,8);s(b=>b===w?b: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 Q0e(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,b=w.figure){if(!n||n.state!=="running")return!1;const k=W1(m,b),v=Kee(w.level,k),N=n.currentTime;for(const x of k.notes){const C=n.createOscillator(),S=n.createGain();C.type=k.type??"sine",C.frequency.value=x.hz;const _=N+x.at,$=_+x.ms/1e3;S.gain.setValueAtTime(vA,_),S.gain.exponentialRampToValueAtTime(v,_+Yee),S.gain.exponentialRampToValueAtTime(vA,$),C.connect(S).connect(n.destination),C.start(_),C.stop($+.02)}return!0}async function u(m,w){var v;if(!e.loadCustom)return"unavailable";let b;try{b=await e.loadCustom(m)}catch{return"unavailable"}if(!b)return"missing";if(b.kind==="tts"){if(typeof window>"u"||!("speechSynthesis"in window)||typeof SpeechSynthesisUtterance>"u")return"unavailable";const N=new SpeechSynthesisUtterance(b.text),x=window.speechSynthesis.getVoices();N.voice=x.find(C=>C.voiceURI===b.voiceURI)??null,N.rate=b.rate,N.pitch=b.pitch,N.volume=Xee(w.level);try{return window.speechSynthesis.cancel(),window.speechSynthesis.speak(N),"played"}catch{return"unavailable"}}if(!n||n.state!=="running")return"locked";let k;try{k=await n.decodeAudioData(b.bytes.slice(0))}catch{return"broken"}try{const N=n.createBufferSource(),x=n.createGain();return N.buffer=k,x.gain.setValueAtTime(Zee(b.normalizationGain,w.level),n.currentTime),N.connect(x).connect(n.destination),s.add(N),(v=N.addEventListener)==null||v.call(N,"ended",()=>s.delete(N)),N.start(n.currentTime),"played"}catch{return"unavailable"}}function h(m,w=!1){var v,N;if(!w&&!e.enabled())return!1;const b=rte((v=e.prefs)==null?void 0:v.call(e),m),k=((N=e.customSelection)==null?void 0:N.call(e)[m])??null;return k&&e.loadCustom?(u(k,b).then(x=>{var C;x==="played"||x==="locked"||((x==="missing"||x==="broken")&&((C=e.onCustomFailure)==null||C.call(e,m,k)),l(m,{...b,figure:es},es))}),!0):!n||n.state!=="running"?!1:l(m,b)}function f(m,w=wi){return u(m,{level:pm(w),figure:es}),!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 e1e({chimesRef:e,soundOnRef:t,tonePrefsRef:n,customSelectionsRef:s,fallbackCustomRef:a}){g.useEffect(()=>{const o=Q0e({enabled:()=>t.current===!0,prefs:()=>n.current,customSelection:()=>s.current,loadCustom:Wee,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 t1e(){const[e,t]=g.useState(G0e),[n,s]=g.useState(()=>tX(nt(_T))),[a,o]=g.useState(()=>eX(nt(ET))),[i,l]=g.useState(()=>nX(nt(l3),n,W0e)),[u,h]=g.useState(()=>new Set),[f,p]=g.useState(0);g.useEffect(()=>{st(mB,String(e))},[e]),g.useEffect(()=>{st(ET,a?"1":"0")},[a]),g.useEffect(()=>{st(_T,JSON.stringify(n))},[n]),g.useEffect(()=>{st(l3,i)},[i]);const m=g.useCallback((N,x=!1)=>{s(C=>{const S=C.find(_=>_.id===N.id);return S?!x||!N.radio||!S.radio||S.url===N.url&&JSON.stringify(S.radio)===JSON.stringify(N.radio)?C:C.map(_=>_.id===N.id?{..._,url:N.url,radio:N.radio}:_):[...C,N]}),h(C=>{if(!C.has(N.id))return C;const S=new Set(C);return S.delete(N.id),S})},[]),w=g.useCallback((N,x)=>{const C=x.trim();!C||C.length>iD||s(S=>S.map(_=>_.id===N?{..._,name:C}:_))},[]),b=g.useCallback(N=>{s(x=>x.filter(C=>C.id!==N)),l(x=>sX(x,N)),h(x=>{if(!x.has(N))return x;const C=new Set(x);return C.delete(N),C})},[]),k=g.useCallback((N,x=!1)=>{const C=TT(N),S=u.has(C);N===i&&!S&&!x||(S&&h(_=>{const $=new Set(_);return $.delete(C),$}),l(N),p(_=>_+1))},[i,u]),v=g.useCallback((N,x)=>{const C=TT(N);h(S=>{if(S.has(C)===x)return S;const $=new Set(S);return x?$.add(C):$.delete(C),$})},[]);return{fmVolume:e,setFmVolume:t,fmMuted:a,setFmMuted:o,fmSource:i,customFmStations:n,unavailableFmStations:u,fmPlayRequest:f,addFmStation:m,renameFmStation:w,removeFmStation:b,pickFmSource:k,markFmStationAvailability:v}}function n1e(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 b=!1;const k=l.current;return fetch("/api/desktop-update").then(v=>v.ok?v.json():null).then(v=>{if(b||l.current!==k)return;const N=TO(v);N&&n(N)}).catch(()=>{}),()=>{b=!0}},[e]);const u=owe(t),h=g.useRef(!1),f=g.useRef(0),p=g.useRef(0);g.useEffect(()=>()=>window.clearTimeout(f.current),[]);const m=g.useCallback(async b=>{if(!Cn(h.current))return;const k=++p.current;window.clearTimeout(f.current),h.current=!0,a(!0),i(null);const v=N=>{k===p.current&&(window.clearTimeout(f.current),h.current=!1,a(!1),i({failure:N,version:b}))};try{const N=await fetch("/api/desktop-update/restart",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({version:b})});if(!N.ok)return v(lwe(await N.json().catch(()=>null)))}catch{return v("unreachable")}k===p.current&&(f.current=window.setTimeout(()=>v("timeout"),$8))},[]),w=g.useCallback(b=>{if(co())try{const k=TO(JSON.parse(b));k&&(l.current++,n(k),k.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 Cf="agent-dag.autoRestart",d3="agent-dag.bundleReloadedFor";function s1e({now:e,stateRef:t,version:n,notice:s,noticeOpen:a,upgradeFailure:o,paused:i}){const[l,u]=g.useState(()=>nt(Cf)!=="0"),h=g.useRef(!1),f=g.useCallback(()=>{const W=!l;h.current=!0,ks(Cf),u(W),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:W})}).then(B=>B.ok?B.json():null).then(B=>{var R;B!=null&&B.ok&&u(((R=B.prefs)==null?void 0:R.autoUpdate)!==!1)}).catch(()=>{})},[l]),[p,m]=g.useState(!1),[w,b]=g.useState("restart"),[k,v]=g.useState(null),N=g.useRef(!1),x=g.useRef(null),C=g.useRef(0),S=g.useRef(null),_=g.useCallback(async W=>{if(!Cn(N.current))return;const B=(W==null?void 0:W.upgrade)===!0,R=(W==null?void 0:W.whenIdle)===!0;N.current=!0,x.current=o;const q=++C.current,T=()=>{b(B?"npx":"restart"),m(!0)};R||T();try{window.sessionStorage.setItem("agent-dag.restartPending",(s==null?void 0:s.to)??"")}catch{}let F=!1;try{const D=await fetch("/api/restart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(R?{upgrade:B,whenIdle:R}:{upgrade:B})});F=R&&D.status===409}catch{}if(F){N.current=!1,S.current=null;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}return}R&&T(),window.setTimeout(()=>{if(C.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 W=RO(t.current.agents.values())>0,B=Gwe({enabled:l,kind:s==null?void 0:s.kind,canRestart:(n==null?void 0:n.canRestart)===!0,noticeOpen:a,visible:document.visibilityState==="visible",busy:W,idleSince:S.current,now:e});S.current=B.idleSince,B.restart&&_({whenIdle:!0})},[l,s==null?void 0:s.kind,n==null?void 0:n.canRestart,a,e,_]);const $=RO(t.current.agents.values()),A=Vwe($,i),O=B8({enabled:l,kind:s==null?void 0:s.kind,canRestart:(n==null?void 0:n.canRestart)===!0,noticeOpen:a,visible:document.visibilityState==="visible",busy:$>0,idleSince:S.current,now:e});g.useEffect(()=>{const W=n==null?void 0:n.running;let B=null,R=null;try{B=window.sessionStorage.getItem("agent-dag.restartPending"),R=window.sessionStorage.getItem(d3)}catch{return}const q=qwe({bundle:"3.48.0",running:W,pending:B,lastTried:R});if(q==="reload"){try{window.sessionStorage.setItem(d3,W??"")}catch{return}window.location.reload();return}if(q!=="confirm")return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}N.current=!1,m(!1),v(W??null);const T=window.setTimeout(()=>v(null),6e3);return()=>window.clearTimeout(T)},[n==null?void 0:n.running]),g.useEffect(()=>{if(p&&Wwe({asked:x.current,reported:o})){try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}N.current=!1,m(!1)}},[p,o]);const M=g.useCallback(W=>{var B,R;if(!h.current){const q=nt(Cf)==="0";ks(Cf),q&&((B=W.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(((R=W.prefs)==null?void 0:R.autoUpdate)!==!1)}},[]);return{autoRestart:l,toggleAutoRestart:f,restarting:p,restartMode:w,restartedTo:k,askRestart:_,restartCopy:A,restartFuseMs:O,loadAutoRestartPrefs:M}}function r1e(){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(oR(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?hj:x6))})};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(oR(m.pending,m.aliases)):t(w=>w.filter(b=>b.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 a1e=6e4;function o1e({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<a1e||(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?hve(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]))},[]),b=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]),k=g.useRef(l);k.current=l;const v=g.useCallback(N=>{const x=k.current;w(fve(x?[x,...m.current]:m.current,N))},[w]);return{rows:p,signingIn:l,observe:h,signIn:u,signedIn:v,refresh:g.useCallback(()=>{f(!0)},[f]),closeSignIn:g.useCallback(()=>u(null),[]),later:b}}const yB=288,i1e=yB;function l1e(e,t,n){return e?"session-list":t||n?"accounts":null}function h3(e){return e==="session-list"?i1e:e==="accounts"?yB:0}const c1e=240,u1e=20;function d1e(e){const t=g.useRef(0),n=g.useRef(e);return g.useLayoutEffect(()=>{n.current!==e&&(n.current=e,t.current=md()?0:performance.now()+c1e+u1e)},[e]),t}const wB="agent-dag.sessionListOpen",xB="agent-dag.accountsPanelOpen";function h1e(){return nt(wB)==="1"}function f1e(e){st(wB,e?"1":"0")}function p1e(){const e=nt(xB);return e===null?!0:e==="1"}function m1e(){const e=g.useRef(!1),t=g.useRef(!1),[n,s]=g.useState(()=>{const b=h1e();return b&&B1()?(e.current=!0,!1):b});g.useEffect(()=>{if(n)e.current=!1;else if(e.current)return;f1e(n)},[n]);const a=g.useRef(!1),[o,i]=g.useState(()=>{const b=p1e();return b&&n?(a.current=!0,!1):b&&B1()?(t.current=!0,!1):b});g.useEffect(()=>{if(o)t.current=!1;else if(t.current)return;!o&&a.current||st(xB,o?"1":"0")},[o]),g.useEffect(()=>{!n&&a.current&&(a.current=!1,i(!0))},[n]);const l=g.useCallback(()=>{s(b=>(b||i(k=>(k&&(a.current=!0),!1)),!b))},[]),u=g.useCallback(()=>{a.current=!1,i(b=>(b||s(!1),!b))},[]),h=g.useCallback(()=>{a.current=!1,i(b=>(b||s(!1),!0))},[]),f=g.useCallback(()=>s(!1),[]),p=g.useCallback(()=>{a.current=!1,s(!1)},[]),m=g.useCallback(()=>i(!1),[]),w=l1e(n,o,a.current);return{sessionListOpen:n,accountsPanelOpen:o,panel:w,toggleSessionList:l,toggleAccountsPanel:u,openAccountsPanel:h,closeSessionList:f,closeSessionListToCanvas:p,closeAccountsPanel:m}}const vB="agent-dag.detailOpen",bB="agent-dag.usagePanelOpen",kB="agent-dag.systemPanelOpen";function g1e(){return nt(vB)==="1"}function y1e(e){st(vB,e?"1":"0")}function w1e(){const e=nt(bB);return e===null?!0:e==="1"}function x1e(e){st(bB,e?"1":"0")}function v1e(){const e=nt(kB);return e===null?!0:e==="1"}function b1e(e){st(kB,e?"1":"0")}function k1e(e=0){const[t,n]=g.useState(g1e);g.useEffect(()=>{y1e(t)},[t]);const[s,a]=g.useState(w1e);g.useEffect(()=>{x1e(s)},[s]);const o=g.useRef(!1),[i,l]=g.useState(()=>{const u=v1e();return u&&s&&(B1()||nee(e))?(o.current=!0,!1):u});return g.useEffect(()=>{if(i)o.current=!1;else if(o.current)return;b1e(i)},[i]),an("usage-panel",s),an("machine-panel",i),{detailOpen:t,setDetailOpen:n,usagePanelOpen:s,setUsagePanelOpen:a,machinePanelOpen:i,setMachinePanelOpen:l}}const j1e={permission:"your permission",asked:"your answer"},N1e="No sessions are waiting for you.";function S1e(e){if(e.length===0)return"";const[t,...n]=e,s=t.waiting.kind,a=n.every(i=>i.waiting.kind===s)?j1e[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 n1(e,t,n=N1e){return t!==""?t:e===""?"":n}function C1e({waitingSessions:e,watchUnseen:t,incidents:n=[]}){const[s,a]=g.useState(""),o=S1e(e);g.useEffect(()=>{a(m=>n1(m,o))},[o]);const[i,l]=g.useState(""),u=t>0?`Browser watch has ${t} unread ${t===1?"finding":"findings"}.`:"";g.useEffect(()=>{l(m=>n1(m,u,"Browser watch has no unread findings."))},[u]);const[h,f]=g.useState(""),p=P0e(n);return g.useEffect(()=>{f(m=>n1(m,p,D0e))},[p]),{blockedSaid:s,watchSaid:i,setWatchSaid:l,incidentSaid:h}}const _1e="/icon-192.png",jB=Object.freeze({notifySwap:!0,notifyQuota:!1,notifyReset:!1,notifyStopped:!0,notifyElsewhere:!0});function f3(e){const t=n=>typeof(e==null?void 0:e[n])=="boolean"?e[n]:jB[n];return{notifySwap:t("notifySwap"),notifyQuota:t("notifyQuota"),notifyReset:t("notifyReset"),notifyStopped:t("notifyStopped"),notifyElsewhere:t("notifyElsewhere")}}function E1e({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(jB),w=g.useCallback(O=>{const M=!p[O];m(W=>({...W,[O]:M})),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({[O]:M})}).then(W=>W.ok?W.json():null).then(W=>{W!=null&&W.ok&&m(f3(W.prefs))}).catch(()=>{})},[p]),b=g.useRef(()=>{}),k=g.useRef(new Set),v=Fn(e),N=g.useCallback(()=>{const O=!l;u(O),O&&(k.current=ef(v.current)),O&&typeof Notification<"u"&&Notification.permission==="default"&&b.current(),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({notifications:O})}).then(M=>M.ok?M.json():null).then(M=>{var W;M!=null&&M.ok&&(u(((W=M.prefs)==null?void 0:W.notifications)===!0),f(M.notificationsVetoed===!0))}).catch(()=>{})},[l]),x=typeof Notification<"u";g.useEffect(()=>{if(!o)return;const M=setTimeout(()=>i(null),o==="blocked"?8e3:4e3);return()=>clearTimeout(M)},[o]);const C=g.useCallback(()=>{typeof Notification>"u"||Notification.requestPermission().then(O=>{const M=O;a(M),M==="granted"?i("on"):M==="denied"&&i("blocked")})},[]);b.current=C;const S=g.useRef(null),_=e.map(O=>Qp(O.id,O.waiting)).join("|");g.useEffect(()=>{_G(S.current,s)&&(S.current=s,k.current=ef(e))},[s]);const $=g.useRef(!1);g.useEffect(()=>{EG($.current,t)&&($.current=!0,k.current=ef(e))},[t]),g.useEffect(()=>{if(typeof Notification>"u"||Notification.permission!=="granted"||!TG(S.current,t))return;const O=typeof document>"u"||!document.hidden,M=SG(e,k.current,O,l);for(const W of M)try{const B=new Notification(W.title,{body:W.body,tag:W.key,icon:_1e});B.onclick=()=>{window.focus(),n(W.sessionId),B.close()}}catch{}k.current=O?ef(e):CG(e,M,k.current)},[_,t]);const A=g.useCallback(O=>{var M;u(((M=O.prefs)==null?void 0:M.notifications)===!0),f(O.notificationsVetoed===!0),m(f3(O.prefs))},[]);return{notifyPermission:s,notifySaid:o,notifyOn:l,notifyVetoed:h,toggleNotify:N,notifySupported:x,askForNotifications:C,loadNotifyPrefs:A,accountNotify:p,toggleAccountNotify:w}}function T1e({openedTool:e,usageHistoryOpen:t,contextFor:n,tourOpen:s,summaryFor:a,browserWatchOpen:o,keyHelpOpen:i,releaseNotes:l,feedbackOpen:u,trafficRadarOpen:h=!1}){const f=Fn(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 A1e({stateRef:e,tourOpen:t,releaseNotes:n}){const[s,a]=g.useState(null),o=g.useCallback((R,q)=>a({agentId:R,toolId:q}),[]),[i,l]=g.useState(null),[u,h]=g.useState(null),f=g.useCallback(R=>h(R),[]),[p,m]=g.useState(!1),[w,b]=g.useState(!1),[k,v]=g.useState(!1),[N,x]=g.useState(!1),[C,S]=g.useState(!1),[_,$]=g.useState(null),A=g.useCallback(R=>{$(R??null),S(!0)},[]);an("tool-detail",s!==null),an("session-summary",i!==null),an("context-window",u!==null),an("keyboard-help",p),an("usage-history",w),an("browser-watch",k),an("feedback",C);const O=s?yV(e.current.agents,s.agentId,s.toolId):null,M=u?e.current.agents.get(u):void 0,{keyHelpOpenRef:W,modalOpenRef:B}=T1e({openedTool:O,usageHistoryOpen:w,contextFor:u,tourOpen:t,summaryFor:i,browserWatchOpen:k,keyHelpOpen:p,releaseNotes:n,feedbackOpen:C,trafficRadarOpen:N});return{setOpenedToolKey:a,openTool:o,openedTool:O,summaryFor:i,setSummaryFor:l,contextFor:u,setContextFor:h,openContext:f,contextAgent:M,keyHelpOpen:p,setKeyHelpOpen:m,usageHistoryOpen:w,setUsageHistoryOpen:b,browserWatchOpen:k,setBrowserWatchOpen:v,trafficRadarOpen:N,setTrafficRadarOpen:x,feedbackOpen:C,setFeedbackOpen:S,feedbackPrefill:_,setFeedbackPrefill:$,openFeedback:A,keyHelpOpenRef:W,modalOpenRef:B}}function R1e({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=rN(),t.current.clear(),n.current.clear(),s.current.clear(),a.current="",i8(),o(),i(),l()},[l,i,o]),m=Fn(h),w=g.useCallback(b=>{const k=Xwe(b,{confirmOpen:m.current,modalOpen:u.current});k==="confirm"?f(!0):k==="clear"&&(f(!1),p())},[p]);return{clearConfirmOpen:h,setClearConfirmOpen:f,requestClear:w}}const p3="agent-dag.oldNameNoticeDismissed";function M1e(e){const[t,n]=g.useState(()=>nt(p3)??""),s=e!=null&&e.invokedAs&&e.invokedAs!==Pt?e.invokedAs:null,a=s!=null&&t!==s,o=g.useCallback(()=>{s&&(n(s),st(p3,s))},[s]);return{oldName:s,oldNameOpen:a,dismissOldName:o}}const $1e=300*1e3,L1e=1800*1e3,I1e=8e3,O1e=3e4;function m3(e){return fetch("/api/rating",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)}).catch(()=>null)}function P1e({modalOpenRef:e}){const t=g.useCallback(()=>wl({appModal:e.current,dialogDepth:rn.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 b=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")},k=window.setTimeout(b,$1e),v=window.setInterval(b,L1e);return()=>{w=!0,window.clearTimeout(k),window.clearInterval(v)}},[t]),g.useEffect(()=>{if(n!=="thanks"||i)return;const w=a!==null&&a<=6?O1e:I1e;let b=0;const k=()=>{t()?b=window.setTimeout(k,w):s("hidden")};return b=window.setTimeout(k,w),()=>window.clearTimeout(b)},[n,a,i,t]);const h=g.useCallback(w=>{o(w),l(!1),s("thanks"),m3({score:w})},[]),f=g.useCallback(w=>l(w),[]),p=g.useCallback(()=>{s("hidden"),m3({later:!0})},[]),m=g.useCallback(()=>s("hidden"),[]);return{ratingPhase:n,ratingScore:a,answerRating:h,rateLater:p,closeRating:m,holdThanks:f}}function D1e({chimesRef:e,setTonePrefs:t,tonePrefsRef:n,previewTone:s}){const[a,o]=g.useState(()=>Ree(nt)),i=Fn(a),[l,u]=g.useState([]),h=g.useCallback(x=>{o(C=>{const S={...C,[x]:null};return i.current=S,S}),ks(Ru[x])},[]),f=g.useCallback((x,C)=>{const S=i.current[x];C&&S!==C||(h(x),t(_=>{const $={..._,[x]:{..._[x],figure:es}};return n.current=$,$}),st(gp[x],es))},[h]),p=Fn(f);g.useEffect(()=>{let x=!0;return Uee().then(C=>{if(!x)return;u(C);const S=new Set(C.map(_=>_.id));for(const _ of Mu){const $=i.current[_];$&&!S.has($)&&p.current(_,$)}},()=>{}),()=>{x=!1}},[]);const m=g.useCallback((x,C)=>{if(!l.some(_=>_.id===C))return;const S={...i.current,[x]:C};i.current=S,o(S),st(Ru[x],C),s(x,!0)},[l,s]),w=g.useCallback(async x=>{var $;const C=U1(l.length);if(C)throw new Error(C);const S=window.AudioContext??window.webkitAudioContext;if(!S)throw new Error("This browser cannot decode audio files.");const _=new S;try{const A=await Pee(x,M=>_.decodeAudioData(M));await wA(A);const O=td(A);u(M=>[...M.filter(W=>W.id!==O.id),O])}finally{($=_.close)==null||$.call(_)}},[l.length]),b=g.useCallback(async x=>{const C=U1(l.length);if(C)throw new Error(C);const S=Dee(x);await wA(S);const _=td(S);u($=>[...$.filter(A=>A.id!==_.id),_])},[l.length]),k=g.useCallback(async(x,C)=>{const S=l.find($=>$.id===x),_=C.trim().slice(0,80);!S||!_||_===S.name||(await Hee(x,_),u($=>$.map(A=>A.id===x?{...A,name:_}:A)))},[l]),v=g.useCallback(async x=>{await zee(x),u($=>$.filter(A=>A.id!==x));const C=i.current,S=Mee(C,x);i.current=S,o(S);const _=Mu.filter($=>C[$]===x);for(const $ of _)ks(Ru[$]),st(gp[$],es);_.length>0&&t($=>{const A={...$};for(const O of _)A[O]={...A[O],figure:es};return n.current=A,A})},[]),N=g.useCallback(x=>{var _,$;const C=Mu.find(A=>i.current[A]===x),S=C?n.current[C].level:wi;(_=e.current)==null||_.unlock(),($=e.current)==null||$.previewCustom(x,S)},[]);return{customSelections:a,customSelectionsRef:i,customAssets:l,clearCustomOnly:h,fallbackCustomRef:p,selectCustomTone:m,importNotificationAudio:w,createNotificationVoice:b,renameCustomAsset:k,deleteCustomAsset:v,previewCustomAsset:N}}function F1e(e){const[t,n]=g.useState(()=>ste(nt)),s=Fn(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)},Jee)},[]),i=g.useCallback((l,u)=>{n(h=>{const f={level:pm(u.level??h[l].level),figure:XD(l,u.figure??h[l].figure)};return st(QD[l],String(f.level)),st(gp[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 B1e=15e3;function q1e(e){return e.visibilityState==="visible"&&e.hasFocus()}function U1e(e,t){return t||e===!0}function W1e(){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 H1e(){g.useEffect(()=>{const e=W1e();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=q1e(document);U1e(t,i)&&n(i),t=i},a=()=>{t&&n(!1),t=!1};s();const o=window.setInterval(s,B1e);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 z1e({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 s1="agent-dag.versionNoticeDismissed",V1e=15*6e4;function G1e(e){const[t,n]=g.useState(null),[s,a]=g.useState(()=>nt(s1)??""),o=g.useRef(0),[i,l]=g.useState(!1),u=g.useCallback((k=!1)=>(k&&(o.current=Date.now(),l(!0)),fetch(k?"/api/version?refresh=1":"/api/version").then(v=>v.ok?v.json():null).then(v=>(v&&n(v),v??null)).catch(()=>null).finally(()=>{k&&l(!1)})),[]),h=g.useCallback(()=>{u(Date.now()-o.current>=V1e)},[u]);g.useEffect(()=>{u();const k=window.setInterval(h,5*6e4),v=()=>{document.visibilityState==="visible"&&h()};return document.addEventListener("visibilitychange",v),()=>{window.clearInterval(k),document.removeEventListener("visibilitychange",v)}},[u,h]),g.useEffect(()=>{e&&u()},[e,u]);const f=(t==null?void 0:t.notice)??null,p=P8(f),m=fwe(f,s),w=g.useCallback(()=>{a(""),st(s1,"")},[]),b=g.useCallback(()=>{f&&(a(p),st(s1,p))},[f,p]);return{version:t,notice:f,noticeOpen:m,showNotice:w,dismissNotice:b,versionChecking:i,loadVersion:u}}function K1e({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 v=wr(),N=Lve(v),x=Bve({stored:N,running:(e==null?void 0:e.running)??null,notes:FO,remembers:Ive(v)});if(x.reason==="no-version")return;h.current=!0,x.record&&Ove(v,x.record);let C=!0;return(async()=>{var O;let _=Pve(v);if(co())try{const M=await fetch("/api/prefs");if(!M.ok)throw new Error("desktop tour preferences unavailable");const W=await M.json();if(!(W!=null&&W.ok))throw new Error("desktop tour preferences unavailable");const B=((O=W.prefs)==null?void 0:O.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(!C)return;const $=Fve({tourSeen:_,decision:x}),A=x.show.length?{entries:x.show,since:N,firstRun:!1}:null;$.tour&&s(!0),$.notes==="now"?i(A):$.notes==="after"&&(a.current=A)})(),()=>{C=!1}},[e==null?void 0:e.running]);const f=(e==null?void 0:e.running)??"3.48.0",p=g.useMemo(()=>Q8(FO,null,f),[f]),m=g.useCallback(()=>{i({entries:p,since:null,firstRun:!1})},[p]),w=g.useCallback(()=>s(!0),[]),b=g.useCallback(()=>i(null),[]),k=g.useCallback(()=>{s(!1),Dve(wr()),co()&&fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tourSeen:!0}),keepalive:!0}).catch(()=>{});const v=a.current;a.current=null,v&&i(v)},[]);return{tourOpen:n,openTour:w,closeTour:k,releaseNotes:o,closeReleaseNotes:b,chipVersion:f,openReleaseNotes:m}}function Y1e(){const[e,t]=g.useState(void 0),[n,s]=g.useState(!1),a=g.useRef(!1);return a.current=e===!0&&!n,g.useEffect(()=>f0e(()=>a.current),[]),{loadReportsPrefs:g.useCallback(i=>{var l;t(((l=i.prefs)==null?void 0:l.reports)!==!1),s(i.reportsVetoed===!0)},[])}}function X1e(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=Fn(a),i=Fn(t);return{soundOn:t,toggleSound:s,activateSoundRef:o,soundOnRef:i}}function Z1e(){const[e,t]=g.useState(fee),n=g.useCallback((o,i)=>{t(l=>pee(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 J1e="agent-dag.autoFitDisabled";function Q1e(e){const t=g.useRef(!1),[n,s]=g.useState(!1);g.useEffect(()=>{ks(J1e)},[]);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 eje(){return r.jsx(sN,{children:r.jsx(g0e,{children:r.jsx(tje,{})})})}function tje(){var Mc;const e=ec(),t=g.useState(rN)[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}=m1e(),{detailOpen:b,setDetailOpen:k,usagePanelOpen:v,setUsagePanelOpen:N,machinePanelOpen:x,setMachinePanelOpen:C}=k1e(h3(l)),{selectedIds:S,primarySelectedId:_,selectAgent:$,clearSelection:A,pruneSelectionToBoard:O}=Nde(n,k),M=Nl(i,200),W=Nl(o,200),B=zE(o,W),R=Nl(v,130),q=Nl(x,130),T=g.useRef(null),F=X1e(T),{activateSoundRef:D,soundOnRef:K}=F,V=F1e(T),{setTonePrefs:H,tonePrefsRef:P,previewTone:I}=V,U=D1e({chimesRef:T,setTonePrefs:H,tonePrefsRef:P,previewTone:I}),{customSelectionsRef:Z,fallbackCustomRef:z}=U,X=Z1e(),{openSettings:Y}=X;e1e({chimesRef:T,soundOnRef:K,tonePrefsRef:P,customSelectionsRef:Z,fallbackCustomRef:z});const J=x0e(n),{pauseGate:Q,paused:te,togglePause:le}=J,de=g.useRef(()=>{}),{live:oe,tabCapped:re,everConnected:he,liveSince:pe}=pde({stateRef:n,rerender:a,pauseGate:Q,chimesRef:T,desktopUpdateRef:de}),Le=G1e(oe),{version:ge,notice:ve,noticeOpen:je,loadVersion:Ee}=Le,xe=n1e(oe),{readyAppUpdate:Ie,onDesktopUpdateEvent:De}=xe;de.current=De,H1e();const We=K1e({version:ge,readyAppUpdate:Ie}),{tourOpen:Ke,openTour:ye,releaseNotes:Fe}=We,{workspace:$e,providers:Re,providersRef:rt}=b0e(oe),He=h3(l==="accounts"&&!Re.claude?null:l),se=d1e(He),ke=zE(i,M)&&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=M1e(ge),Ve=F0e({version:ge,loadVersion:Ee}),{upgradeFailure:ot}=Ve,tt=A1e({stateRef:n,tourOpen:Ke,releaseNotes:Fe}),wt=P1e({modalOpenRef:tt.modalOpenRef}),{openTool:$t,setSummaryFor:Gt,setContextFor:nr,openContext:_s,setKeyHelpOpen:Hn,setUsageHistoryOpen:ns,setBrowserWatchOpen:Es,keyHelpOpenRef:wn,modalOpenRef:zn}=tt,Me=Y1e(),qe=q0e(),{watchOn:Je,watchUnseen:_t}=qe,Nt=$d(),[ss,Vn]=g.useState(null),[xn,Tr]=g.useState(!1),vn=g.useCallback(()=>Tr(!1),[]),on=ut=>{Gye(ut),Y("integrations")},Ts=ut=>{ut&&EO(ut),Y("integrations")},sr=g.useCallback(()=>Vn(null),[]),rs=qS().filter(ut=>Cj(Nt,ut.kind)),As=Fn(ut=>{const Ur=rs.find(ug=>ug.kind===ut);Ur&&Vn(Ur.kind)}),Ar=g.useCallback(ut=>{EO(ut),Y("integrations")},[Y]),Rr=rs.length>0;g.useEffect(()=>{Rr&&Iye()},[Rr]);const Rs=r1e(),[ya,xt]=g.useState(0),{presentCats:wa,hiddenCats:Ms,toggleCat:xa,catBarRef:rr,catBarOccluded:ar}=J0e(n),Mr=g.useRef(null),[$s,hn]=g.useState(0),Lt=Sde({stateRef:n,rerender:a,pruneSelectionToBoard:O,setContextFor:nr,setSummaryFor:Gt});bY({stateRef:n,now:Lt,enabled:Re.claude});const fn=S0e(Re.claude||Re.codex),va=O0e(fn,Lt),go=o1e({enabled:Re.claude,lanStatus:Rs.lanStatus,now:Lt}),ba=s1e({now:Lt,stateRef:n,version:ge,notice:ve,noticeOpen:je,upgradeFailure:ot,paused:J.paused}),{askRestart:ka,loadAutoRestartPrefs:$r}=ba,Gn=Z0e(),{setTheme:we,palette:et}=Gn,pt=t1e(),Et=kme(),{applyViewport:or,moveCamera:Lr,fitLeft:as,cameraEpochRef:fc,lastFitTimeRef:Ir}=Et,at=Ome(Et),{pinnedRef:yo,positionsRef:wo,lastLayoutSigRef:pc,handleRelayout:mc,rearrangeUndo:Id}=at,gc=g.useRef(null),_i=g.useRef(()=>{}),xo=pe!==null,Ls=g.useRef(0),Is=g.useCallback(()=>{Ls.current=Date.now()},[]),{canvasRef:ln,canvasSize:vo,paneSizeRef:bo}=Nge(se),Os=Q1e(as),{autoFitDisabledRef:Od,disableAutoFit:Ei}=Os,Or=g.useRef(!1),{measuredRef:Pr,measuredVersionRef:Pd,sizeVersion:Ti,domSizeVersion:Dd}=Sge(Or),{removedNodes:yc,removedAgentIds:os,removeNode:ko,removeSelectedNode:Dr,removalNotice:jo,hideSessions:Km,bringBack:wc,bringBackAll:xc,forgetRemovals:Ai}=sge({stateRef:n,pinnedRef:yo,positionsRef:wo,canvasRef:ln,clearSelection:A,primarySelectedId:_});fge({stateRef:n,removedNodes:yc,hideSessions:Km,ready:xo,keepSessionId:_?((Mc=n.current.agents.get(_))==null?void 0:Mc.sessionId)??_:null});const No=Jme({stateRef:n,now:Lt,removedAgentIds:os,sizeVersion:Ti,domSizeVersion:Dd});Pme(No,at),nge({layoutSig:No,rf:e,stateRef:n,measuredRef:Pr,pinnedRef:yo,positionsRef:wo,paneSizeRef:bo,lastInteractRef:Ls,autoFitDisabledRef:Od,lastFitTimeRef:Ir,fitLeft:as});const vc=Cge(),{bubbling:ir,endBubble:bc,onBubble:Ri}=Que(),[Mi,$i]=g.useState(!1),So=Zue(),{beginTrashDrag:Fd,trackTrashDrag:bn,endTrashDrag:ja}=So,Li=ode({stateRef:n,measuredRef:Pr,measuredVersionRef:Pd,canvasRef:ln}),{lodRef:Co,applyZoom:Ym}=Li,Ii=bge({applyViewport:or,lastFitTimeRef:Ir,cameraEpochRef:fc,disableAutoFit:Ei,markInteract:Is,canvasRef:ln,applyZoom:Ym}),Fr=_?n.current.agents.get(_):null,Br=b&&Fr!=null,Ps=Age({sessionListShown:B,usageShown:Ja(R),machineShown:Ja(q),accountsShown:ke,detailShown:Br,primarySelectedId:_,canvasRef:ln}),{railInsetRef:_o,availableWidth:Bd,availableHeight:qd}=yme({canvasRef:ln,canvasSize:vo,machinePhase:q,usagePhase:R,usagePanelOpen:v,detailShown:Br}),Ud=Qme({stateRef:n,now:Lt,availableWidth:Bd,availableHeight:qd,layout:at,measuredRef:Pr,onBubble:Ri,settled:vc,dragging:Mi,layoutSig:No,selectedIds:S,openContext:_s,historyReplayed:xo,removedNodes:yc,removedAgentIds:os,dragTick:ya,dragPatchRef:Mr,dragMoveTick:$s}),{nodes:Eo,edges:Xm}=Ud,kc=Fn(_);Dme({nodes:Eo,edges:Xm,settled:vc,dragging:Mi,availableWidth:Bd,availableHeight:qd,layout:at,camera:Et,rf:e,measuredRef:Pr,stateRef:n,lastFocusRef:gc,primarySelectedIdRef:kc,focusAgentRef:_i,autoFitDisabledRef:Od});const Wd=R1e({stateRef:n,pinnedRef:yo,measuredRef:Pr,positionsRef:wo,lastLayoutSigRef:pc,forgetRemovals:Ai,clearSelection:A,rerender:a,modalOpenRef:zn}),{requestClear:jc}=Wd,Zm=Rge({nodes:Eo,stateRef:n,pinnedRef:yo,positionsRef:wo,draggingRef:Or,dragPatchRef:Mr,setDragging:$i,setDragMoveTick:hn,setDragTick:xt,endBubble:bc,markInteract:Is,disableAutoFit:Ei,beginTrashDrag:Fd,trackTrashDrag:bn,endTrashDrag:ja,removeNode:ko}),Nc=g.useCallback(()=>as(500),[as]),Sc=Fn(Eo),{focusAgent:Oi,stepAgent:Jm,focusSession:Na}=Nme({canvasRef:ln,stateRef:n,measuredRef:Pr,nodesRef:Sc,railInsetRef:_o,moveCamera:Lr,disableAutoFit:Ei,lastFocusRef:gc,focusAgentRef:_i,selectAgent:$,primarySelectedIdRef:kc}),Cc=kge({clearSelection:A,selectAgent:$,detailOpen:b,setDetailOpen:k,detailShown:Br,focusAgent:Oi,draggingRef:Or,lodRef:Co}),Qm=Sme({nodesRef:Sc,stateRef:n,canvasRef:ln,railInsetRef:_o}),eg=Fn(Dr),_c=g.useRef(null),To=g.useCallback(ut=>{os.has(ut)&&wc([ut]),Na(ut)},[os,wc,Na]),tg=_ge(),[ng,Ec]=g.useState(!1),Hd=g.useCallback(()=>Ec(!0),[]),sg=g.useCallback(()=>Ec(!1),[]),rg=g.useCallback(ut=>{Ec(!1),ut.run()},[]),ag=An();Ege({pointerFocusRef:tg,nodesRef:Sc,stateRef:n,primarySelectedIdRef:kc,providersRef:rt,soundOnRef:K,keyHelpOpenRef:wn,modalOpenRef:zn,waitingCursorRef:_c,removeSelectedRef:eg,activateSoundRef:D,clearSelection:A,selectAgent:$,focusAgent:Oi,stepAgent:Jm,focusSession:Na,requestClear:jc,handleRelayout:mc,undoRearrange:Id.undo,handleFit:Nc,togglePause:le,toggleSessionList:u,toggleAccountsPanel:h,setDetailOpen:k,setUsageHistoryOpen:ns,setUsagePanelOpen:N,setMachinePanelOpen:C,setBrowserWatchOpen:Es,setKeyHelpOpen:Hn,setTheme:we,openSettings:Y,openIntegrationRef:As,openQuickOpen:Hd});const Ao=n.current.agents.size,is=g.useMemo(()=>N1(n.current.agents.values()),[n.current,n.current.revision]);rge({stateRef:n,waitingSessions:is,removedAgentIds:os,removedNodes:yc,bringBack:wc}),wge({stateRef:n,waitingSessions:is,live:oe});const zd=C1e({waitingSessions:is,watchUnseen:_t,incidents:va}),Pi=E1e({waitingSessions:is,liveSince:pe,focusSession:Na}),{loadNotifyPrefs:Vd}=Pi;z1e({loadAutoRestartPrefs:$r,loadNotifyPrefs:Vd,loadReportsPrefs:Me.loadReportsPrefs});const lr=ic(fm),[Gd,Tc]=g.useState(!1),[qr,Ac]=g.useState(null),og=g.useCallback(()=>Ac(null),[]),ig=g.useCallback(ut=>{const Ur=n.current.agents.get(ut);return Ur?Ur.label||Ur.cwdBasename||"session":null},[]),Kd=g.useCallback(ut=>{Ac(null),To(ut)},[To]),Yd=g.useCallback(()=>Tc(!1),[]),[Sa,Ca]=g.useState(null),lg=g.useCallback(()=>Ca(null),[]),qt=Xge({providers:Re,sessionListOpen:o,toggleSessionList:u,accountsPanelOpen:i,toggleAccountsPanel:h,usagePanelOpen:v,setUsagePanelOpen:N,machinePanelOpen:x,setMachinePanelOpen:C,setUsageHistoryOpen:ns,watchOn:Je,watchUnseen:_t,setBrowserWatchOpen:Es,setTrafficRadarOpen:tt.setTrafficRadarOpen,openSettings:Y,onFeedback:tt.openFeedback,setRadioOpen:Tc,openToolActivity:Ac,openCapacity:Ca,toggles:Ps.toggles,integrations:rs.map(ut=>({provider:ut,onPress:()=>Vn(ut.kind)})),openExploreIntegrations:()=>Tr(!0),openQuickOpen:Hd}),[cg,Xd]=g.useState(0),Di=g.useCallback(ut=>{To(ut),lr&&m()},[To,lr,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(HJ,{}),r.jsx(Nwe,{versionCheck:Le,welcome:We,desktopUpdate:xe,pause:J,announcements:zd,notify:Pi,waitingSessions:is,waitingCursorRef:_c,focusSession:Na,live:oe,now:Lt,incidents:va,queueNamed:lr?0:cg}),!lr&&r.jsx(bwe,{waitingSessions:is,waitingCursorRef:_c,focusSession:Na,now:Lt,onFit:Xd,onMore:Rc}),Fr&&r.jsx(Swe,{selected:Fr,now:Lt,selectedIds:S,focusAgent:Oi,clearSelection:A}),!lr&&r.jsx("div",{className:"actions",children:r.jsx(cee,{items:[qt.search,...qt.utilities]})})]}),lr?r.jsx(lee,{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(uA,{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(Ywe,{restart:ba,versionCheck:Le,upgrade:Ve,oldNameNotice:_e,rating:wt,onFeedback:tt.openFeedback,everConnected:he,live:oe,paused:te}),(B||ke)&&r.jsxs(Hue,{width:He,children:[ke&&r.jsx(_ue,{leaving:VE(i,M),onReport:tt.openFeedback,onRoster:go.observe,onClose:()=>{Ps.accounts(),w()},lanWanted:Ae,onLanShown:fe}),B&&r.jsx(sQ,{leaving:VE(o,W),state:n.current,now:Lt,selectedIds:S,onSelect:Di,onClose:()=>{Ps.sessionList(),p()},removedIds:os,onBringBackAll:xc})]}),r.jsxs(Awe,{canvasRef:ln,bubbling:ir,dragging:Mi,trash:So,zoom:Li,viewport:Ii,stateRef:n,peek:Qm,children:[Ao===0&&(!oe&&re?r.jsx($ge,{reservedRight:_o.current}):r.jsx(Lge,{live:oe,everConnected:he,providers:Re,workspace:$e,onTour:ye,reservedRight:_o.current})),(wa.length>1||Ms.size>0)&&r.jsx(Cwe,{catBarRef:rr,catBarOccluded:ar,presentCats:wa,hiddenCats:Ms,toggleCat:xa}),r.jsx(WJ,{graph:Ud,layout:at,viewport:Ii,clicks:Cc,drag:Zm,appearance:Gn,fm:pt,radioOpen:Gd,onRadioClose:Yd,autoFit:Os,pause:J,stateRef:n,measuredRef:Pr,hiddenCats:Ms,now:Lt,openTool:$t,focusAgent:Oi,requestClear:jc,setKeyHelpOpen:Hn})]}),!lr&&r.jsx(uA,{side:"right",label:"Usage and activity",groups:qt.right}),qr&&r.jsx(Tne,{view:qr,onClose:og,sessionLabel:ig,onOpenSession:Kd}),Sa&&r.jsx(Wue,{view:Sa,onClose:lg}),ss&&r.jsx(Dye,{kind:ss,connections:ra(Nt,ss)?Lp(Nt,ss):[],onClose:sr,onReconnect:Ar}),xn&&r.jsx(Jye,{integrations:Nt,onClose:vn,onOpen:Vn,onConnect:on,onManage:Ts}),ng&&r.jsx(qQ,{onClose:sg,onRun:rg,items:Cte({rails:qt,sessions:RD(n.current),now:Lt,openSession:Di,settings:n5(Re.claude,WS(Nt),Ld(Nt)),openSettings:Y,singleKeys:ag,fit:Nc,rearrange:mc,paused:te,togglePause:le,clear:Ao>0?()=>jc("button"):void 0,keyHelp:()=>Hn(!0),tour:ye,theme:Gn.theme,setTheme:we})}),Ja(R)&&r.jsx(Qse,{state:n.current,now:Lt,providers:Re,incidents:va,liveSince:pe,leaving:R==="leaving",onClose:()=>{Ps.usage(),N(!1)}}),Ja(q)&&r.jsx(Ire,{usageOpen:v,leaving:q==="leaving",onClose:()=>{Ps.machine(),C(!1)}}),b&&Fr?r.jsx(Kge,{selected:Fr,now:Lt,openTool:$t,setSummaryFor:Gt,stateRef:n,removeSelectedNode:Dr,onClose:()=>{Ps.detail(),k(!1)}}):null,r.jsx(Xke,{dialogs:tt,welcome:We,desktopUpdate:xe,versionCheck:Le,restart:ba,upgrade:Ve,lanPairs:Rs,attention:go,clearFlow:Wd,watchBadge:qe,announcements:zd,appearance:Gn,providers:Re,stateRef:n,agentCount:Ao,menus:X,sound:F,tones:V,customTones:U,notify:Pi,panelDoors:{accounts:f,localNetwork:be}})]})}try{fK(window.localStorage)}catch{}const nje=Aq.createRoot(document.getElementById("root"));window.ccdeckWindow&&(document.documentElement.dataset.desktopChrome="true",document.documentElement.dataset.desktopPlatform=window.ccdeckWindow.platform);nje.render(r.jsx(eje,{}));export{wje as $,vd as A,dje as B,vt as C,_u as D,rd as E,Nje as F,T5 as G,pae as H,vr as I,ct as J,X1 as K,RA as L,Z1 as M,lje as N,Ct as O,no as P,na as Q,S5 as R,cje as S,np as T,uje as U,cd as V,Wn as W,Iee as X,yje as Y,vje as Z,Uve as _,ks as a,xje as a0,qve as a1,bje as a2,im as a3,me as a4,yi as a5,so as a6,MZ as a7,Sje as a8,EN as a9,Xl as aa,fX as ab,ije as ac,aje as ad,oje as ae,lm as af,KG as ag,Lbe as ah,U0e as ai,rje as aj,$Z as ak,g as b,mje as c,Bn as d,rp as e,T8 as f,Vo as g,ho as h,gje as i,r as j,uS as k,AP as l,rn as m,gt as n,yt as o,md as p,pje as q,nt as r,Cn as s,fje as t,ic as u,an as v,st as w,jje as x,kje as y,hje as z};