ccdeck 3.48.1 → 3.49.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -17
- package/dist/web/assets/{BrowserWatchModal-Dfsuy2cT.js → BrowserWatchModal-CCARqAMn.js} +1 -1
- package/dist/web/assets/{IntegrationModal-CcSR7YB-.js → IntegrationModal-B8t53aE5.js} +1 -1
- package/dist/web/assets/{RadioPanel-s7WXdS6v.js → RadioPanel-gFYxdsBg.js} +1 -1
- package/dist/web/assets/{TrafficRadar-C5GXMIwi.js → TrafficRadar-B9MfKca4.js} +2 -2
- package/dist/web/assets/{UsageHistoryModal-CiExD9wF.js → UsageHistoryModal-DvYWhsYv.js} +1 -1
- package/dist/web/assets/app-D2NP6IPl.js +321 -0
- package/dist/web/assets/app-DfGYllmZ.css +1 -0
- package/dist/web/assets/{index-ByovgZ_7.js → index-Be6Ox-74.js} +1 -1
- package/dist/web/index.html +3 -3
- package/package.json +1 -1
- package/release-notes.json +93 -12
- package/src/server/account-notify.mjs +2 -54
- package/src/server/account-watch.mjs +0 -47
- package/src/server/deck-prefs.mjs +9 -14
- package/src/server/integrations/store.mjs +21 -0
- package/src/server/lan-deck.mjs +0 -7
- package/src/server/login-service.mjs +3 -0
- package/src/server/reports.mjs +25 -2
- package/dist/web/assets/app-BFaxhiED.js +0 -321
- package/dist/web/assets/app-DjlHxWHg.css +0 -1
- package/src/server/lan-elsewhere.d.mts +0 -30
- package/src/server/lan-elsewhere.mjs +0 -137
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
var Sq=Object.defineProperty;var Cq=(e,t,n)=>t in e?Sq(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n;var Da=(e,t,n)=>Cq(e,typeof t!="symbol"?t+"":t,n);var Vh=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{};function Wj(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var Ry={exports:{}},tu={},My={exports:{}},ot={};/**
|
|
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 G_;function _q(){if(G_)return ot;G_=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"),d=Symbol.for("react.memo"),f=Symbol.for("react.lazy"),p=Symbol.iterator;function m(O){return O===null||typeof O!="object"?null:(O=p&&O[p]||O["@@iterator"],typeof O=="function"?O:null)}var w={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},x=Object.assign,b={};function j(O,V,Z){this.props=O,this.context=V,this.refs=b,this.updater=Z||w}j.prototype.isReactComponent={},j.prototype.setState=function(O,V){if(typeof O!="object"&&typeof O!="function"&&O!=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,O,V,"setState")},j.prototype.forceUpdate=function(O){this.updater.enqueueForceUpdate(this,O,"forceUpdate")};function k(){}k.prototype=j.prototype;function v(O,V,Z){this.props=O,this.context=V,this.refs=b,this.updater=Z||w}var S=v.prototype=new k;S.constructor=v,x(S,j.prototype),S.isPureReactComponent=!0;var C=Array.isArray,_=Object.prototype.hasOwnProperty,R={current:null},A={key:!0,ref:!0,__self:!0,__source:!0};function I(O,V,Z){var W,X={},Y=null,J=null;if(V!=null)for(W in V.ref!==void 0&&(J=V.ref),V.key!==void 0&&(Y=""+V.key),V)_.call(V,W)&&!A.hasOwnProperty(W)&&(X[W]=V[W]);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(O&&O.defaultProps)for(W in Q=O.defaultProps,Q)X[W]===void 0&&(X[W]=Q[W]);return{$$typeof:e,type:O,key:Y,ref:J,props:X,_owner:R.current}}function $(O,V){return{$$typeof:e,type:O.type,key:V,ref:O.ref,props:O.props,_owner:O._owner}}function U(O){return typeof O=="object"&&O!==null&&O.$$typeof===e}function F(O){var V={"=":"=0",":":"=2"};return"$"+O.replace(/[=:]/g,function(Z){return V[Z]})}var M=/\/+/g;function B(O,V){return typeof O=="object"&&O!==null&&O.key!=null?F(""+O.key):V.toString(36)}function T(O,V,Z,W,X){var Y=typeof O;(Y==="undefined"||Y==="boolean")&&(O=null);var J=!1;if(O===null)J=!0;else switch(Y){case"string":case"number":J=!0;break;case"object":switch(O.$$typeof){case e:case t:J=!0}}if(J)return J=O,X=X(J),O=W===""?"."+B(J,0):W,C(X)?(Z="",O!=null&&(Z=O.replace(M,"$&/")+"/"),T(X,V,Z,"",function(le){return le})):X!=null&&(U(X)&&(X=$(X,Z+(!X.key||J&&J.key===X.key?"":(""+X.key).replace(M,"$&/")+"/")+O)),V.push(X)),1;if(J=0,W=W===""?".":W+":",C(O))for(var Q=0;Q<O.length;Q++){Y=O[Q];var te=W+B(Y,Q);J+=T(Y,V,Z,te,X)}else if(te=m(O),typeof te=="function")for(O=te.call(O),Q=0;!(Y=O.next()).done;)Y=Y.value,te=W+B(Y,Q++),J+=T(Y,V,Z,te,X);else if(Y==="object")throw V=String(O),Error("Objects are not valid as a React child (found: "+(V==="[object Object]"?"object with keys {"+Object.keys(O).join(", ")+"}":V)+"). If you meant to render a collection of children, use an array instead.");return J}function P(O,V,Z){if(O==null)return O;var W=[],X=0;return T(O,W,"","",function(Y){return V.call(Z,Y,X++)}),W}function q(O){if(O._status===-1){var V=O._result;V=V(),V.then(function(Z){(O._status===0||O._status===-1)&&(O._status=1,O._result=Z)},function(Z){(O._status===0||O._status===-1)&&(O._status=2,O._result=Z)}),O._status===-1&&(O._status=0,O._result=V)}if(O._status===1)return O._result.default;throw O._result}var K={current:null},z={transition:null},H={ReactCurrentDispatcher:K,ReactCurrentBatchConfig:z,ReactCurrentOwner:R};function D(){throw Error("act(...) is not supported in production builds of React.")}return ot.Children={map:P,forEach:function(O,V,Z){P(O,function(){V.apply(this,arguments)},Z)},count:function(O){var V=0;return P(O,function(){V++}),V},toArray:function(O){return P(O,function(V){return V})||[]},only:function(O){if(!U(O))throw Error("React.Children.only expected to receive a single React element child.");return O}},ot.Component=j,ot.Fragment=n,ot.Profiler=a,ot.PureComponent=v,ot.StrictMode=s,ot.Suspense=u,ot.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=H,ot.act=D,ot.cloneElement=function(O,V,Z){if(O==null)throw Error("React.cloneElement(...): The argument must be a React element, but you passed "+O+".");var W=x({},O.props),X=O.key,Y=O.ref,J=O._owner;if(V!=null){if(V.ref!==void 0&&(Y=V.ref,J=R.current),V.key!==void 0&&(X=""+V.key),O.type&&O.type.defaultProps)var Q=O.type.defaultProps;for(te in V)_.call(V,te)&&!A.hasOwnProperty(te)&&(W[te]=V[te]===void 0&&Q!==void 0?Q[te]:V[te])}var te=arguments.length-2;if(te===1)W.children=Z;else if(1<te){Q=Array(te);for(var le=0;le<te;le++)Q[le]=arguments[le+2];W.children=Q}return{$$typeof:e,type:O.type,key:X,ref:Y,props:W,_owner:J}},ot.createContext=function(O){return O={$$typeof:i,_currentValue:O,_currentValue2:O,_threadCount:0,Provider:null,Consumer:null,_defaultValue:null,_globalName:null},O.Provider={$$typeof:o,_context:O},O.Consumer=O},ot.createElement=I,ot.createFactory=function(O){var V=I.bind(null,O);return V.type=O,V},ot.createRef=function(){return{current:null}},ot.forwardRef=function(O){return{$$typeof:l,render:O}},ot.isValidElement=U,ot.lazy=function(O){return{$$typeof:f,_payload:{_status:-1,_result:O},_init:q}},ot.memo=function(O,V){return{$$typeof:d,type:O,compare:V===void 0?null:V}},ot.startTransition=function(O){var V=z.transition;z.transition={};try{O()}finally{z.transition=V}},ot.unstable_act=D,ot.useCallback=function(O,V){return K.current.useCallback(O,V)},ot.useContext=function(O){return K.current.useContext(O)},ot.useDebugValue=function(){},ot.useDeferredValue=function(O){return K.current.useDeferredValue(O)},ot.useEffect=function(O,V){return K.current.useEffect(O,V)},ot.useId=function(){return K.current.useId()},ot.useImperativeHandle=function(O,V,Z){return K.current.useImperativeHandle(O,V,Z)},ot.useInsertionEffect=function(O,V){return K.current.useInsertionEffect(O,V)},ot.useLayoutEffect=function(O,V){return K.current.useLayoutEffect(O,V)},ot.useMemo=function(O,V){return K.current.useMemo(O,V)},ot.useReducer=function(O,V,Z){return K.current.useReducer(O,V,Z)},ot.useRef=function(O){return K.current.useRef(O)},ot.useState=function(O){return K.current.useState(O)},ot.useSyncExternalStore=function(O,V,Z){return K.current.useSyncExternalStore(O,V,Z)},ot.useTransition=function(){return K.current.useTransition()},ot.version="18.3.1",ot}var K_;function md(){return K_||(K_=1,My.exports=_q()),My.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 Y_;function Eq(){if(Y_)return tu;Y_=1;var e=md(),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,d){var f,p={},m=null,w=null;d!==void 0&&(m=""+d),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 tu.Fragment=n,tu.jsx=i,tu.jsxs=i,tu}var X_;function Tq(){return X_||(X_=1,Ry.exports=Eq()),Ry.exports}var r=Tq(),Gh={},$y={exports:{}},Pn={},Ly={exports:{}},Iy={};/**
|
|
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 Z_;function Aq(){return Z_||(Z_=1,(function(e){function t(z,H){var D=z.length;z.push(H);e:for(;0<D;){var O=D-1>>>1,V=z[O];if(0<a(V,H))z[O]=H,z[D]=V,D=O;else break e}}function n(z){return z.length===0?null:z[0]}function s(z){if(z.length===0)return null;var H=z[0],D=z.pop();if(D!==H){z[0]=D;e:for(var O=0,V=z.length,Z=V>>>1;O<Z;){var W=2*(O+1)-1,X=z[W],Y=W+1,J=z[Y];if(0>a(X,D))Y<V&&0>a(J,X)?(z[O]=J,z[Y]=D,O=Y):(z[O]=X,z[W]=D,O=W);else if(Y<V&&0>a(J,D))z[O]=J,z[Y]=D,O=Y;else break e}}return H}function a(z,H){var D=z.sortIndex-H.sortIndex;return D!==0?D:z.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=[],d=[],f=1,p=null,m=3,w=!1,x=!1,b=!1,j=typeof setTimeout=="function"?setTimeout:null,k=typeof clearTimeout=="function"?clearTimeout:null,v=typeof setImmediate<"u"?setImmediate:null;typeof navigator<"u"&&navigator.scheduling!==void 0&&navigator.scheduling.isInputPending!==void 0&&navigator.scheduling.isInputPending.bind(navigator.scheduling);function S(z){for(var H=n(d);H!==null;){if(H.callback===null)s(d);else if(H.startTime<=z)s(d),H.sortIndex=H.expirationTime,t(u,H);else break;H=n(d)}}function C(z){if(b=!1,S(z),!x)if(n(u)!==null)x=!0,q(_);else{var H=n(d);H!==null&&K(C,H.startTime-z)}}function _(z,H){x=!1,b&&(b=!1,k(I),I=-1),w=!0;var D=m;try{for(S(H),p=n(u);p!==null&&(!(p.expirationTime>H)||z&&!F());){var O=p.callback;if(typeof O=="function"){p.callback=null,m=p.priorityLevel;var V=O(p.expirationTime<=H);H=e.unstable_now(),typeof V=="function"?p.callback=V:p===n(u)&&s(u),S(H)}else s(u);p=n(u)}if(p!==null)var Z=!0;else{var W=n(d);W!==null&&K(C,W.startTime-H),Z=!1}return Z}finally{p=null,m=D,w=!1}}var R=!1,A=null,I=-1,$=5,U=-1;function F(){return!(e.unstable_now()-U<$)}function M(){if(A!==null){var z=e.unstable_now();U=z;var H=!0;try{H=A(!0,z)}finally{H?B():(R=!1,A=null)}}else R=!1}var B;if(typeof v=="function")B=function(){v(M)};else if(typeof MessageChannel<"u"){var T=new MessageChannel,P=T.port2;T.port1.onmessage=M,B=function(){P.postMessage(null)}}else B=function(){j(M,0)};function q(z){A=z,R||(R=!0,B())}function K(z,H){I=j(function(){z(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(z){z.callback=null},e.unstable_continueExecution=function(){x||w||(x=!0,q(_))},e.unstable_forceFrameRate=function(z){0>z||125<z?console.error("forceFrameRate takes a positive int between 0 and 125, forcing frame rates higher than 125 fps is not supported"):$=0<z?Math.floor(1e3/z):5},e.unstable_getCurrentPriorityLevel=function(){return m},e.unstable_getFirstCallbackNode=function(){return n(u)},e.unstable_next=function(z){switch(m){case 1:case 2:case 3:var H=3;break;default:H=m}var D=m;m=H;try{return z()}finally{m=D}},e.unstable_pauseExecution=function(){},e.unstable_requestPaint=function(){},e.unstable_runWithPriority=function(z,H){switch(z){case 1:case 2:case 3:case 4:case 5:break;default:z=3}var D=m;m=z;try{return H()}finally{m=D}},e.unstable_scheduleCallback=function(z,H,D){var O=e.unstable_now();switch(typeof D=="object"&&D!==null?(D=D.delay,D=typeof D=="number"&&0<D?O+D:O):D=O,z){case 1:var V=-1;break;case 2:V=250;break;case 5:V=1073741823;break;case 4:V=1e4;break;default:V=5e3}return V=D+V,z={id:f++,callback:H,priorityLevel:z,startTime:D,expirationTime:V,sortIndex:-1},D>O?(z.sortIndex=D,t(d,z),n(u)===null&&z===n(d)&&(b?(k(I),I=-1):b=!0,K(C,D-O))):(z.sortIndex=V,t(u,z),x||w||(x=!0,q(_))),z},e.unstable_shouldYield=F,e.unstable_wrapCallback=function(z){var H=m;return function(){var D=m;m=H;try{return z.apply(this,arguments)}finally{m=D}}}})(Iy)),Iy}var J_;function Rq(){return J_||(J_=1,Ly.exports=Aq()),Ly.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 Q_;function Mq(){if(Q_)return Pn;Q_=1;var e=md(),t=Rq();function n(c){for(var h="https://reactjs.org/docs/error-decoder.html?invariant="+c,y=1;y<arguments.length;y++)h+="&args[]="+encodeURIComponent(arguments[y]);return"Minified React error #"+c+"; visit "+h+" 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,h){i(c,h),i(c+"Capture",h)}function i(c,h){for(a[c]=h,c=0;c<h.length;c++)s.add(h[c])}var l=!(typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"),u=Object.prototype.hasOwnProperty,d=/^[: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:d.test(c)?p[c]=!0:(f[c]=!0,!1)}function w(c,h,y,N){if(y!==null&&y.type===0)return!1;switch(typeof h){case"function":case"symbol":return!0;case"boolean":return N?!1:y!==null?!y.acceptsBooleans:(c=c.toLowerCase().slice(0,5),c!=="data-"&&c!=="aria-");default:return!1}}function x(c,h,y,N){if(h===null||typeof h>"u"||w(c,h,y,N))return!0;if(N)return!1;if(y!==null)switch(y.type){case 3:return!h;case 4:return h===!1;case 5:return isNaN(h);case 6:return isNaN(h)||1>h}return!1}function b(c,h,y,N,E,L,G){this.acceptsBooleans=h===2||h===3||h===4,this.attributeName=N,this.attributeNamespace=E,this.mustUseProperty=y,this.propertyName=c,this.type=h,this.sanitizeURL=L,this.removeEmptyString=G}var j={};"children dangerouslySetInnerHTML defaultValue defaultChecked innerHTML suppressContentEditableWarning suppressHydrationWarning style".split(" ").forEach(function(c){j[c]=new b(c,0,!1,c,null,!1,!1)}),[["acceptCharset","accept-charset"],["className","class"],["htmlFor","for"],["httpEquiv","http-equiv"]].forEach(function(c){var h=c[0];j[h]=new b(h,1,!1,c[1],null,!1,!1)}),["contentEditable","draggable","spellCheck","value"].forEach(function(c){j[c]=new b(c,2,!1,c.toLowerCase(),null,!1,!1)}),["autoReverse","externalResourcesRequired","focusable","preserveAlpha"].forEach(function(c){j[c]=new b(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){j[c]=new b(c,3,!1,c.toLowerCase(),null,!1,!1)}),["checked","multiple","muted","selected"].forEach(function(c){j[c]=new b(c,3,!0,c,null,!1,!1)}),["capture","download"].forEach(function(c){j[c]=new b(c,4,!1,c,null,!1,!1)}),["cols","rows","size","span"].forEach(function(c){j[c]=new b(c,6,!1,c,null,!1,!1)}),["rowSpan","start"].forEach(function(c){j[c]=new b(c,5,!1,c.toLowerCase(),null,!1,!1)});var k=/[\-:]([a-z])/g;function v(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 h=c.replace(k,v);j[h]=new b(h,1,!1,c,null,!1,!1)}),"xlink:actuate xlink:arcrole xlink:role xlink:show xlink:title xlink:type".split(" ").forEach(function(c){var h=c.replace(k,v);j[h]=new b(h,1,!1,c,"http://www.w3.org/1999/xlink",!1,!1)}),["xml:base","xml:lang","xml:space"].forEach(function(c){var h=c.replace(k,v);j[h]=new b(h,1,!1,c,"http://www.w3.org/XML/1998/namespace",!1,!1)}),["tabIndex","crossOrigin"].forEach(function(c){j[c]=new b(c,1,!1,c.toLowerCase(),null,!1,!1)}),j.xlinkHref=new b("xlinkHref",1,!1,"xlink:href","http://www.w3.org/1999/xlink",!0,!1),["src","href","action","formAction"].forEach(function(c){j[c]=new b(c,1,!1,c.toLowerCase(),null,!0,!0)});function S(c,h,y,N){var E=j.hasOwnProperty(h)?j[h]:null;(E!==null?E.type!==0:N||!(2<h.length)||h[0]!=="o"&&h[0]!=="O"||h[1]!=="n"&&h[1]!=="N")&&(x(h,y,E,N)&&(y=null),N||E===null?m(h)&&(y===null?c.removeAttribute(h):c.setAttribute(h,""+y)):E.mustUseProperty?c[E.propertyName]=y===null?E.type===3?!1:"":y:(h=E.attributeName,N=E.attributeNamespace,y===null?c.removeAttribute(h):(E=E.type,y=E===3||E===4&&y===!0?"":""+y,N?c.setAttributeNS(N,h,y):c.setAttribute(h,y))))}var C=e.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED,_=Symbol.for("react.element"),R=Symbol.for("react.portal"),A=Symbol.for("react.fragment"),I=Symbol.for("react.strict_mode"),$=Symbol.for("react.profiler"),U=Symbol.for("react.provider"),F=Symbol.for("react.context"),M=Symbol.for("react.forward_ref"),B=Symbol.for("react.suspense"),T=Symbol.for("react.suspense_list"),P=Symbol.for("react.memo"),q=Symbol.for("react.lazy"),K=Symbol.for("react.offscreen"),z=Symbol.iterator;function H(c){return c===null||typeof c!="object"?null:(c=z&&c[z]||c["@@iterator"],typeof c=="function"?c:null)}var D=Object.assign,O;function V(c){if(O===void 0)try{throw Error()}catch(y){var h=y.stack.trim().match(/\n( *(at )?)/);O=h&&h[1]||""}return`
|
|
34
|
+
`+O+c}var Z=!1;function W(c,h){if(!c||Z)return"";Z=!0;var y=Error.prepareStackTrace;Error.prepareStackTrace=void 0;try{if(h)if(h=function(){throw Error()},Object.defineProperty(h.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(h,[])}catch(ue){var N=ue}Reflect.construct(c,[],h)}else{try{h.call()}catch(ue){N=ue}c.call(h.prototype)}else{try{throw Error()}catch(ue){N=ue}c()}}catch(ue){if(ue&&N&&typeof ue.stack=="string"){for(var E=ue.stack.split(`
|
|
35
|
+
`),L=N.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:"")?V(c):""}function X(c){switch(c.tag){case 5:return V(c.type);case 16:return V("Lazy");case 13:return V("Suspense");case 19:return V("SuspenseList");case 0:case 2:case 15:return c=W(c.type,!1),c;case 11:return c=W(c.type.render,!1),c;case 1:return c=W(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 R:return"Portal";case $:return"Profiler";case I:return"StrictMode";case B:return"Suspense";case T:return"SuspenseList"}if(typeof c=="object")switch(c.$$typeof){case F:return(c.displayName||"Context")+".Consumer";case U:return(c._context.displayName||"Context")+".Provider";case M:var h=c.render;return c=c.displayName,c||(c=h.displayName||h.name||"",c=c!==""?"ForwardRef("+c+")":"ForwardRef"),c;case P:return h=c.displayName||null,h!==null?h:Y(c.type)||"Memo";case q:h=c._payload,c=c._init;try{return Y(c(h))}catch{}}return null}function J(c){var h=c.type;switch(c.tag){case 24:return"Cache";case 9:return(h.displayName||"Context")+".Consumer";case 10:return(h._context.displayName||"Context")+".Provider";case 18:return"DehydratedFragment";case 11:return c=h.render,c=c.displayName||c.name||"",h.displayName||(c!==""?"ForwardRef("+c+")":"ForwardRef");case 7:return"Fragment";case 5:return h;case 4:return"Portal";case 3:return"Root";case 6:return"Text";case 16:return Y(h);case 8:return h===I?"StrictMode":"Mode";case 22:return"Offscreen";case 12:return"Profiler";case 21:return"Scope";case 13:return"Suspense";case 19:return"SuspenseList";case 25:return"TracingMarker";case 1:case 0:case 17:case 2:case 14:case 15:if(typeof h=="function")return h.displayName||h.name||null;if(typeof h=="string")return h}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 h=c.type;return(c=c.nodeName)&&c.toLowerCase()==="input"&&(h==="checkbox"||h==="radio")}function le(c){var h=te(c)?"checked":"value",y=Object.getOwnPropertyDescriptor(c.constructor.prototype,h),N=""+c[h];if(!c.hasOwnProperty(h)&&typeof y<"u"&&typeof y.get=="function"&&typeof y.set=="function"){var E=y.get,L=y.set;return Object.defineProperty(c,h,{configurable:!0,get:function(){return E.call(this)},set:function(G){N=""+G,L.call(this,G)}}),Object.defineProperty(c,h,{enumerable:y.enumerable}),{getValue:function(){return N},setValue:function(G){N=""+G},stopTracking:function(){c._valueTracker=null,delete c[h]}}}}function de(c){c._valueTracker||(c._valueTracker=le(c))}function oe(c){if(!c)return!1;var h=c._valueTracker;if(!h)return!0;var y=h.getValue(),N="";return c&&(N=te(c)?c.checked?"true":"false":c.value),c=N,c!==y?(h.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,h){var y=h.checked;return D({},h,{defaultChecked:void 0,defaultValue:void 0,value:void 0,checked:y??c._wrapperState.initialChecked})}function fe(c,h){var y=h.defaultValue==null?"":h.defaultValue,N=h.checked!=null?h.checked:h.defaultChecked;y=Q(h.value!=null?h.value:y),c._wrapperState={initialChecked:N,initialValue:y,controlled:h.type==="checkbox"||h.type==="radio"?h.checked!=null:h.value!=null}}function $e(c,h){h=h.checked,h!=null&&S(c,"checked",h,!1)}function ye(c,h){$e(c,h);var y=Q(h.value),N=h.type;if(y!=null)N==="number"?(y===0&&c.value===""||c.value!=y)&&(c.value=""+y):c.value!==""+y&&(c.value=""+y);else if(N==="submit"||N==="reset"){c.removeAttribute("value");return}h.hasOwnProperty("value")?je(c,h.type,y):h.hasOwnProperty("defaultValue")&&je(c,h.type,Q(h.defaultValue)),h.checked==null&&h.defaultChecked!=null&&(c.defaultChecked=!!h.defaultChecked)}function ge(c,h,y){if(h.hasOwnProperty("value")||h.hasOwnProperty("defaultValue")){var N=h.type;if(!(N!=="submit"&&N!=="reset"||h.value!==void 0&&h.value!==null))return;h=""+c._wrapperState.initialValue,y||h===c.value||(c.value=h),c.defaultValue=h}y=c.name,y!==""&&(c.name=""),c.defaultChecked=!!c._wrapperState.initialChecked,y!==""&&(c.name=y)}function je(c,h,y){(h!=="number"||re(c.ownerDocument)!==c)&&(y==null?c.defaultValue=""+c._wrapperState.initialValue:c.defaultValue!==""+y&&(c.defaultValue=""+y))}var Le=Array.isArray;function ke(c,h,y,N){if(c=c.options,h){h={};for(var E=0;E<y.length;E++)h["$"+y[E]]=!0;for(y=0;y<c.length;y++)E=h.hasOwnProperty("$"+c[y].value),c[y].selected!==E&&(c[y].selected=E),E&&N&&(c[y].defaultSelected=!0)}else{for(y=""+Q(y),h=null,E=0;E<c.length;E++){if(c[E].value===y){c[E].selected=!0,N&&(c[E].defaultSelected=!0);return}h!==null||c[E].disabled||(h=c[E])}h!==null&&(h.selected=!0)}}function Ie(c,h){if(h.dangerouslySetInnerHTML!=null)throw Error(n(91));return D({},h,{value:void 0,defaultValue:void 0,children:""+c._wrapperState.initialValue})}function De(c,h){var y=h.value;if(y==null){if(y=h.children,h=h.defaultValue,y!=null){if(h!=null)throw Error(n(92));if(Le(y)){if(1<y.length)throw Error(n(93));y=y[0]}h=y}h==null&&(h=""),y=h}c._wrapperState={initialValue:Q(y)}}function Ue(c,h){var y=Q(h.value),N=Q(h.defaultValue);y!=null&&(y=""+y,y!==c.value&&(c.value=y),h.defaultValue==null&&c.defaultValue!==y&&(c.defaultValue=y)),N!=null&&(c.defaultValue=""+N)}function Ke(c){var h=c.textContent;h===c._wrapperState.initialValue&&h!==""&&h!==null&&(c.value=h)}function we(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,h){return c==null||c==="http://www.w3.org/1999/xhtml"?we(h):c==="http://www.w3.org/2000/svg"&&h==="foreignObject"?"http://www.w3.org/1999/xhtml":c}var Re,Ae=(function(c){return typeof MSApp<"u"&&MSApp.execUnsafeLocalFunction?function(h,y,N,E){MSApp.execUnsafeLocalFunction(function(){return c(h,y,N,E)})}:c})(function(c,h){if(c.namespaceURI!=="http://www.w3.org/2000/svg"||"innerHTML"in c)c.innerHTML=h;else{for(Re=Re||document.createElement("div"),Re.innerHTML="<svg>"+h.valueOf().toString()+"</svg>",h=Re.firstChild;c.firstChild;)c.removeChild(c.firstChild);for(;h.firstChild;)c.appendChild(h.firstChild)}});function rt(c,h){if(h){var y=c.firstChild;if(y&&y===c.lastChild&&y.nodeType===3){y.nodeValue=h;return}}c.textContent=h}var We={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(We).forEach(function(c){se.forEach(function(h){h=h+c.charAt(0).toUpperCase()+c.substring(1),We[h]=We[c]})});function be(c,h,y){return h==null||typeof h=="boolean"||h===""?"":y||typeof h!="number"||h===0||We.hasOwnProperty(c)&&We[c]?(""+h).trim():h+"px"}function Te(c,h){c=c.style;for(var y in h)if(h.hasOwnProperty(y)){var N=y.indexOf("--")===0,E=be(y,h[y],N);y==="float"&&(y="cssFloat"),N?c.setProperty(y,E):c[y]=E}}var Oe=D({menuitem:!0},{area:!0,base:!0,br:!0,col:!0,embed:!0,hr:!0,img:!0,input:!0,keygen:!0,link:!0,meta:!0,param:!0,source:!0,track:!0,wbr:!0});function ve(c,h){if(h){if(Oe[c]&&(h.children!=null||h.dangerouslySetInnerHTML!=null))throw Error(n(137,c));if(h.dangerouslySetInnerHTML!=null){if(h.children!=null)throw Error(n(60));if(typeof h.dangerouslySetInnerHTML!="object"||!("__html"in h.dangerouslySetInnerHTML))throw Error(n(61))}if(h.style!=null&&typeof h.style!="object")throw Error(n(62))}}function pe(c,h){if(c.indexOf("-")===-1)return typeof h.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 ze(c){return c=c.target||c.srcElement||window,c.correspondingUseElement&&(c=c.correspondingUseElement),c.nodeType===3?c.parentNode:c}var at=null,tt=null,xt=null;function Mt(c){if(c=Bc(c)){if(typeof at!="function")throw Error(n(280));var h=c.stateNode;h&&(h=ih(h),at(c.stateNode,c.type,h))}}function Xt(c){tt?xt?xt.push(c):xt=[c]:tt=c}function tr(){if(tt){var c=tt,h=xt;if(xt=tt=null,Mt(c),h)for(c=0;c<h.length;c++)Mt(h[c])}}function Cs(c,h){return c(h)}function zn(){}var ts=!1;function _s(c,h,y){if(ts)return c(h,y);ts=!0;try{return Cs(c,h,y)}finally{ts=!1,(tt!==null||xt!==null)&&(zn(),tr())}}function sn(c,h){var y=c.stateNode;if(y===null)return null;var N=ih(y);if(N===null)return null;y=N[h];e:switch(h){case"onClick":case"onClickCapture":case"onDoubleClick":case"onDoubleClickCapture":case"onMouseDown":case"onMouseDownCapture":case"onMouseMove":case"onMouseMoveCapture":case"onMouseUp":case"onMouseUpCapture":case"onMouseEnter":(N=!N.disabled)||(c=c.type,N=!(c==="button"||c==="input"||c==="select"||c==="textarea")),c=!N;break e;default:c=!1}if(c)return null;if(y&&typeof y!="function")throw Error(n(231,h,typeof y));return y}var zt=!1;if(l)try{var Me={};Object.defineProperty(Me,"passive",{get:function(){zt=!0}}),window.addEventListener("test",Me,Me),window.removeEventListener("test",Me,Me)}catch{zt=!1}function Ve(c,h,y,N,E,L,G,ee,ne){var ue=Array.prototype.slice.call(arguments,3);try{h.apply(y,ue)}catch(Se){this.onError(Se)}}var Xe=!1,Tt=null,Ct=!1,qt=null,Vn={onError:function(c){Xe=!0,Tt=c}};function nr(c,h,y,N,E,L,G,ee,ne){Xe=!1,Tt=null,Ve.apply(Vn,arguments)}function Es(c,h,y,N,E,L,G,ee,ne){if(nr.apply(this,arguments),Xe){if(Xe){var ue=Tt;Xe=!1,Tt=null}else throw Error(n(198));Ct||(Ct=!0,qt=ue)}}function gn(c){var h=c,y=c;if(c.alternate)for(;h.return;)h=h.return;else{c=h;do h=c,(h.flags&4098)!==0&&(y=h.return),c=h.return;while(c)}return h.tag===3?y:null}function _r(c){if(c.tag===13){var h=c.memoizedState;if(h===null&&(c=c.alternate,c!==null&&(h=c.memoizedState)),h!==null)return h.dehydrated}return null}function ga(c){if(gn(c)!==c)throw Error(n(188))}function Er(c){var h=c.alternate;if(!h){if(h=gn(c),h===null)throw Error(n(188));return h!==c?null:c}for(var y=c,N=h;;){var E=y.return;if(E===null)break;var L=E.alternate;if(L===null){if(N=E.return,N!==null){y=N;continue}break}if(E.child===L.child){for(L=E.child;L;){if(L===y)return ga(E),c;if(L===N)return ga(E),h;L=L.sibling}throw Error(n(188))}if(y.return!==N.return)y=E,N=L;else{for(var G=!1,ee=E.child;ee;){if(ee===y){G=!0,y=E,N=L;break}if(ee===N){G=!0,N=E,y=L;break}ee=ee.sibling}if(!G){for(ee=L.child;ee;){if(ee===y){G=!0,y=L,N=E;break}if(ee===N){G=!0,N=L,y=E;break}ee=ee.sibling}if(!G)throw Error(n(189))}}if(y.alternate!==N)throw Error(n(190))}if(y.tag!==3)throw Error(n(188));return y.stateNode.current===y?c:h}function Ts(c){return c=Er(c),c!==null?Tr(c):null}function Tr(c){if(c.tag===5||c.tag===6)return c;for(c=c.child;c!==null;){var h=Tr(c);if(h!==null)return h;c=c.sibling}return null}var ya=t.unstable_scheduleCallback,Ar=t.unstable_cancelCallback,Rr=t.unstable_shouldYield,ho=t.unstable_requestPaint,yt=t.unstable_now,wa=t.unstable_getCurrentPriorityLevel,ns=t.unstable_ImmediatePriority,xa=t.unstable_UserBlockingPriority,As=t.unstable_NormalPriority,Mr=t.unstable_LowPriority,sr=t.unstable_IdlePriority,Rs=null,dn=null;function $t(c){if(dn&&typeof dn.onCommitFiberRoot=="function")try{dn.onCommitFiberRoot(Rs,c,void 0,(c.current.flags&128)===128)}catch{}}var yn=Math.clz32?Math.clz32:ut,xe=Math.log,Qe=Math.LN2;function ut(c){return c>>>=0,c===0?32:31-(xe(c)/Qe|0)|0}var Lt=64,ss=4194304;function Rn(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 $r(c,h){var y=c.pendingLanes;if(y===0)return 0;var N=0,E=c.suspendedLanes,L=c.pingedLanes,G=y&268435455;if(G!==0){var ee=G&~E;ee!==0?N=Rn(ee):(L&=G,L!==0&&(N=Rn(L)))}else G=y&~E,G!==0?N=Rn(G):L!==0&&(N=Rn(L));if(N===0)return 0;if(h!==0&&h!==N&&(h&E)===0&&(E=N&-N,L=h&-h,E>=L||E===16&&(L&4194240)!==0))return h;if((N&4)!==0&&(N|=y&16),h=c.entangledLanes,h!==0)for(c=c.entanglements,h&=N;0<h;)y=31-yn(h),E=1<<y,N|=c[y],h&=~E;return N}function Pd(c,h){switch(c){case 1:case 2:case 4:return h+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 h+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 ki(c,h){for(var y=c.suspendedLanes,N=c.pingedLanes,E=c.expirationTimes,L=c.pendingLanes;0<L;){var G=31-yn(L),ee=1<<G,ne=E[G];ne===-1?((ee&y)===0||(ee&N)!==0)&&(E[G]=Pd(ee,h)):ne<=h&&(c.expiredLanes|=ee),L&=~ee}}function Ms(c){return c=c.pendingLanes&-1073741825,c!==0?c:c&1073741824?1073741824:0}function Dd(){var c=Lt;return Lt<<=1,(Lt&4194240)===0&&(Lt=64),c}function pc(c){for(var h=[],y=0;31>y;y++)h.push(c);return h}function rr(c,h,y){c.pendingLanes|=h,h!==536870912&&(c.suspendedLanes=0,c.pingedLanes=0),c=c.eventTimes,h=31-yn(h),c[h]=y}function Xm(c,h){var y=c.pendingLanes&~h;c.pendingLanes=h,c.suspendedLanes=0,c.pingedLanes=0,c.expiredLanes&=h,c.mutableReadLanes&=h,c.entangledLanes&=h,h=c.entanglements;var N=c.eventTimes;for(c=c.expirationTimes;0<y;){var E=31-yn(y),L=1<<E;h[E]=0,N[E]=-1,c[E]=-1,y&=~L}}function ji(c,h){var y=c.entangledLanes|=h;for(c=c.entanglements;y;){var N=31-yn(y),E=1<<N;E&h|c[N]&h&&(c[N]|=h),y&=~E}}var ct=0;function fo(c){return c&=-c,1<c?4<c?(c&268435455)!==0?16:536870912:4:1}var po,mc,gc,Fd,yc,Ni=!1,mo=[],$s=null,Ls=null,hn=null,go=new Map,yo=new Map,Is=[],Bd="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 Si(c,h){switch(c){case"focusin":case"focusout":$s=null;break;case"dragenter":case"dragleave":Ls=null;break;case"mouseover":case"mouseout":hn=null;break;case"pointerover":case"pointerout":go.delete(h.pointerId);break;case"gotpointercapture":case"lostpointercapture":yo.delete(h.pointerId)}}function Lr(c,h,y,N,E,L){return c===null||c.nativeEvent!==L?(c={blockedOn:h,domEventName:y,eventSystemFlags:N,nativeEvent:L,targetContainers:[E]},h!==null&&(h=Bc(h),h!==null&&mc(h)),c):(c.eventSystemFlags|=N,h=c.targetContainers,E!==null&&h.indexOf(E)===-1&&h.push(E),c)}function Ir(c,h,y,N,E){switch(h){case"focusin":return $s=Lr($s,c,h,y,N,E),!0;case"dragenter":return Ls=Lr(Ls,c,h,y,N,E),!0;case"mouseover":return hn=Lr(hn,c,h,y,N,E),!0;case"pointerover":var L=E.pointerId;return go.set(L,Lr(go.get(L)||null,c,h,y,N,E)),!0;case"gotpointercapture":return L=E.pointerId,yo.set(L,Lr(yo.get(L)||null,c,h,y,N,E)),!0}return!1}function qd(c){var h=_o(c.target);if(h!==null){var y=gn(h);if(y!==null){if(h=y.tag,h===13){if(h=_r(y),h!==null){c.blockedOn=h,yc(c.priority,function(){gc(y)});return}}else if(h===3&&y.stateNode.current.memoizedState.isDehydrated){c.blockedOn=y.tag===3?y.stateNode.containerInfo:null;return}}}c.blockedOn=null}function Ci(c){if(c.blockedOn!==null)return!1;for(var h=c.targetContainers;0<h.length;){var y=vo(c.domEventName,c.eventSystemFlags,h[0],c.nativeEvent);if(y===null){y=c.nativeEvent;var N=new y.constructor(y.type,y);_e=N,y.target.dispatchEvent(N),_e=null}else return h=Bc(y),h!==null&&mc(h),c.blockedOn=y,!1;h.shift()}return!0}function Ud(c,h,y){Ci(c)&&y.delete(h)}function wc(){Ni=!1,$s!==null&&Ci($s)&&($s=null),Ls!==null&&Ci(Ls)&&(Ls=null),hn!==null&&Ci(hn)&&(hn=null),go.forEach(Ud),yo.forEach(Ud)}function rs(c,h){c.blockedOn===h&&(c.blockedOn=null,Ni||(Ni=!0,t.unstable_scheduleCallback(t.unstable_NormalPriority,wc)))}function wo(c){function h(E){return rs(E,c)}if(0<mo.length){rs(mo[0],c);for(var y=1;y<mo.length;y++){var N=mo[y];N.blockedOn===c&&(N.blockedOn=null)}}for($s!==null&&rs($s,c),Ls!==null&&rs(Ls,c),hn!==null&&rs(hn,c),go.forEach(h),yo.forEach(h),y=0;y<Is.length;y++)N=Is[y],N.blockedOn===c&&(N.blockedOn=null);for(;0<Is.length&&(y=Is[0],y.blockedOn===null);)qd(y),y.blockedOn===null&&Is.shift()}var Or=C.ReactCurrentBatchConfig,xo=!0;function Zm(c,h,y,N){var E=ct,L=Or.transition;Or.transition=null;try{ct=1,vc(c,h,y,N)}finally{ct=E,Or.transition=L}}function xc(c,h,y,N){var E=ct,L=Or.transition;Or.transition=null;try{ct=4,vc(c,h,y,N)}finally{ct=E,Or.transition=L}}function vc(c,h,y,N){if(xo){var E=vo(c,h,y,N);if(E===null)bg(c,h,N,_i,y),Si(c,N);else if(Ir(E,c,h,y,N))N.stopPropagation();else if(Si(c,N),h&4&&-1<Bd.indexOf(c)){for(;E!==null;){var L=Bc(E);if(L!==null&&po(L),L=vo(c,h,y,N),L===null&&bg(c,h,N,_i,y),L===E)break;E=L}E!==null&&N.stopPropagation()}else bg(c,h,N,null,y)}}var _i=null;function vo(c,h,y,N){if(_i=null,c=ze(N),c=_o(c),c!==null)if(h=gn(c),h===null)c=null;else if(y=h.tag,y===13){if(c=_r(h),c!==null)return c;c=null}else if(y===3){if(h.stateNode.current.memoizedState.isDehydrated)return h.tag===3?h.stateNode.containerInfo:null;c=null}else h!==c&&(c=null);return _i=c,null}function bc(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 ns:return 1;case xa:return 4;case As:case Mr:return 16;case sr:return 536870912;default:return 16}default:return 16}}var ar=null,kc=null,Ei=null;function Ti(){if(Ei)return Ei;var c,h=kc,y=h.length,N,E="value"in ar?ar.value:ar.textContent,L=E.length;for(c=0;c<y&&h[c]===E[c];c++);var G=y-c;for(N=1;N<=G&&h[y-N]===E[L-N];N++);return Ei=E.slice(c,1<N?1-N:void 0)}function Ai(c){var h=c.keyCode;return"charCode"in c?(c=c.charCode,c===0&&h===13&&(c=13)):c=h,c===10&&(c=13),32<=c||c===13?c:0}function bo(){return!0}function Wd(){return!1}function kn(c){function h(y,N,E,L,G){this._reactName=y,this._targetInst=E,this.type=N,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)?bo:Wd,this.isPropagationStopped=Wd,this}return D(h.prototype,{preventDefault:function(){this.defaultPrevented=!0;var y=this.nativeEvent;y&&(y.preventDefault?y.preventDefault():typeof y.returnValue!="unknown"&&(y.returnValue=!1),this.isDefaultPrevented=bo)},stopPropagation:function(){var y=this.nativeEvent;y&&(y.stopPropagation?y.stopPropagation():typeof y.cancelBubble!="unknown"&&(y.cancelBubble=!0),this.isPropagationStopped=bo)},persist:function(){},isPersistent:bo}),h}var va={eventPhase:0,bubbles:0,cancelable:0,timeStamp:function(c){return c.timeStamp||Date.now()},defaultPrevented:0,isTrusted:0},Ri=kn(va),ko=D({},va,{view:0,detail:0}),Jm=kn(ko),Mi,Pr,Dr,Os=D({},ko,{screenX:0,screenY:0,clientX:0,clientY:0,pageX:0,pageY:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,getModifierState:_c,button:0,buttons:0,relatedTarget:function(c){return c.relatedTarget===void 0?c.fromElement===c.srcElement?c.toElement:c.fromElement:c.relatedTarget},movementX:function(c){return"movementX"in c?c.movementX:(c!==Dr&&(Dr&&c.type==="mousemove"?(Mi=c.screenX-Dr.screenX,Pr=c.screenY-Dr.screenY):Pr=Mi=0,Dr=c),Mi)},movementY:function(c){return"movementY"in c?c.movementY:Pr}}),jo=kn(Os),Hd=D({},Os,{dataTransfer:0}),zd=kn(Hd),Vd=D({},ko,{relatedTarget:0}),No=kn(Vd),Qm=D({},va,{animationName:0,elapsedTime:0,pseudoElement:0}),jc=kn(Qm),Gd=D({},va,{clipboardData:function(c){return"clipboardData"in c?c.clipboardData:window.clipboardData}}),Nc=kn(Gd),eg=D({},va,{data:0}),Sc=kn(eg),Cc={Esc:"Escape",Spacebar:" ",Left:"ArrowLeft",Up:"ArrowUp",Right:"ArrowRight",Down:"ArrowDown",Del:"Delete",Win:"OS",Menu:"ContextMenu",Apps:"ContextMenu",Scroll:"ScrollLock",MozPrintableKey:"Unidentified"},$i={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"},tg={Alt:"altKey",Control:"ctrlKey",Meta:"metaKey",Shift:"shiftKey"};function ba(c){var h=this.nativeEvent;return h.getModifierState?h.getModifierState(c):(c=tg[c])?!!h[c]:!1}function _c(){return ba}var ng=D({},ko,{key:function(c){if(c.key){var h=Cc[c.key]||c.key;if(h!=="Unidentified")return h}return c.type==="keypress"?(c=Ai(c),c===13?"Enter":String.fromCharCode(c)):c.type==="keydown"||c.type==="keyup"?$i[c.keyCode]||"Unidentified":""},code:0,location:0,ctrlKey:0,shiftKey:0,altKey:0,metaKey:0,repeat:0,locale:0,getModifierState:_c,charCode:function(c){return c.type==="keypress"?Ai(c):0},keyCode:function(c){return c.type==="keydown"||c.type==="keyup"?c.keyCode:0},which:function(c){return c.type==="keypress"?Ai(c):c.type==="keydown"||c.type==="keyup"?c.keyCode:0}}),sg=kn(ng),Ec=D({},Os,{pointerId:0,width:0,height:0,pressure:0,tangentialPressure:0,tiltX:0,tiltY:0,twist:0,pointerType:0,isPrimary:0}),So=kn(Ec),rg=D({},ko,{touches:0,targetTouches:0,changedTouches:0,altKey:0,metaKey:0,ctrlKey:0,shiftKey:0,getModifierState:_c}),ag=kn(rg),Tc=D({},va,{propertyName:0,elapsedTime:0,pseudoElement:0}),Kd=kn(Tc),og=D({},Os,{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}),ig=kn(og),lg=[9,13,27,32],Co=l&&"CompositionEvent"in window,as=null;l&&"documentMode"in document&&(as=document.documentMode);var Yd=l&&"TextEvent"in window&&!as,Li=l&&(!Co||as&&8<as&&11>=as),Xd=" ",or=!1;function Zd(c,h){switch(c){case"keyup":return lg.indexOf(h.keyCode)!==-1;case"keydown":return h.keyCode!==229;case"keypress":case"mousedown":case"focusout":return!0;default:return!1}}function Ac(c){return c=c.detail,typeof c=="object"&&"data"in c?c.data:null}var Fr=!1;function Rc(c,h){switch(c){case"compositionend":return Ac(h);case"keypress":return h.which!==32?null:(or=!0,Xd);case"textInput":return c=h.data,c===Xd&&or?null:c;default:return null}}function cg(c,h){if(Fr)return c==="compositionend"||!Co&&Zd(c,h)?(c=Ti(),Ei=kc=ar=null,Fr=!1,c):null;switch(c){case"paste":return null;case"keypress":if(!(h.ctrlKey||h.altKey||h.metaKey)||h.ctrlKey&&h.altKey){if(h.char&&1<h.char.length)return h.char;if(h.which)return String.fromCharCode(h.which)}return null;case"compositionend":return Li&&h.locale!=="ko"?null:h.data;default:return null}}var ug={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 Jd(c){var h=c&&c.nodeName&&c.nodeName.toLowerCase();return h==="input"?!!ug[c.type]:h==="textarea"}function Qd(c,h,y,N){Xt(N),h=rh(h,"onChange"),0<h.length&&(y=new Ri("onChange","change",null,y,N),c.push({event:y,listeners:h}))}var ka=null,ja=null;function dg(c){cC(c,0)}function Ut(c){var h=Bi(c);if(oe(h))return c}function hg(c,h){if(c==="change")return h}var eh=!1;if(l){var Ii;if(l){var Mc="oninput"in document;if(!Mc){var $c=document.createElement("div");$c.setAttribute("oninput","return;"),Mc=typeof $c.oninput=="function"}Ii=Mc}else Ii=!1;eh=Ii&&(!document.documentMode||9<document.documentMode)}function dt(){ka&&(ka.detachEvent("onpropertychange",Br),ja=ka=null)}function Br(c){if(c.propertyName==="value"&&Ut(ja)){var h=[];Qd(h,ja,c,ze(c)),_s(dg,h)}}function fg(c,h,y){c==="focusin"?(dt(),ka=h,ja=y,ka.attachEvent("onpropertychange",Br)):c==="focusout"&&dt()}function EB(c){if(c==="selectionchange"||c==="keyup"||c==="keydown")return Ut(ja)}function TB(c,h){if(c==="click")return Ut(h)}function AB(c,h){if(c==="input"||c==="change")return Ut(h)}function RB(c,h){return c===h&&(c!==0||1/c===1/h)||c!==c&&h!==h}var Ps=typeof Object.is=="function"?Object.is:RB;function Lc(c,h){if(Ps(c,h))return!0;if(typeof c!="object"||c===null||typeof h!="object"||h===null)return!1;var y=Object.keys(c),N=Object.keys(h);if(y.length!==N.length)return!1;for(N=0;N<y.length;N++){var E=y[N];if(!u.call(h,E)||!Ps(c[E],h[E]))return!1}return!0}function XS(c){for(;c&&c.firstChild;)c=c.firstChild;return c}function ZS(c,h){var y=XS(c);c=0;for(var N;y;){if(y.nodeType===3){if(N=c+y.textContent.length,c<=h&&N>=h)return{node:y,offset:h-c};c=N}e:{for(;y;){if(y.nextSibling){y=y.nextSibling;break e}y=y.parentNode}y=void 0}y=XS(y)}}function JS(c,h){return c&&h?c===h?!0:c&&c.nodeType===3?!1:h&&h.nodeType===3?JS(c,h.parentNode):"contains"in c?c.contains(h):c.compareDocumentPosition?!!(c.compareDocumentPosition(h)&16):!1:!1}function QS(){for(var c=window,h=re();h instanceof c.HTMLIFrameElement;){try{var y=typeof h.contentWindow.location.href=="string"}catch{y=!1}if(y)c=h.contentWindow;else break;h=re(c.document)}return h}function pg(c){var h=c&&c.nodeName&&c.nodeName.toLowerCase();return h&&(h==="input"&&(c.type==="text"||c.type==="search"||c.type==="tel"||c.type==="url"||c.type==="password")||h==="textarea"||c.contentEditable==="true")}function MB(c){var h=QS(),y=c.focusedElem,N=c.selectionRange;if(h!==y&&y&&y.ownerDocument&&JS(y.ownerDocument.documentElement,y)){if(N!==null&&pg(y)){if(h=N.start,c=N.end,c===void 0&&(c=h),"selectionStart"in y)y.selectionStart=h,y.selectionEnd=Math.min(c,y.value.length);else if(c=(h=y.ownerDocument||document)&&h.defaultView||window,c.getSelection){c=c.getSelection();var E=y.textContent.length,L=Math.min(N.start,E);N=N.end===void 0?L:Math.min(N.end,E),!c.extend&&L>N&&(E=N,N=L,L=E),E=ZS(y,L);var G=ZS(y,N);E&&G&&(c.rangeCount!==1||c.anchorNode!==E.node||c.anchorOffset!==E.offset||c.focusNode!==G.node||c.focusOffset!==G.offset)&&(h=h.createRange(),h.setStart(E.node,E.offset),c.removeAllRanges(),L>N?(c.addRange(h),c.extend(G.node,G.offset)):(h.setEnd(G.node,G.offset),c.addRange(h)))}}for(h=[],c=y;c=c.parentNode;)c.nodeType===1&&h.push({element:c,left:c.scrollLeft,top:c.scrollTop});for(typeof y.focus=="function"&&y.focus(),y=0;y<h.length;y++)c=h[y],c.element.scrollLeft=c.left,c.element.scrollTop=c.top}}var $B=l&&"documentMode"in document&&11>=document.documentMode,Oi=null,mg=null,Ic=null,gg=!1;function eC(c,h,y){var N=y.window===y?y.document:y.nodeType===9?y:y.ownerDocument;gg||Oi==null||Oi!==re(N)||(N=Oi,"selectionStart"in N&&pg(N)?N={start:N.selectionStart,end:N.selectionEnd}:(N=(N.ownerDocument&&N.ownerDocument.defaultView||window).getSelection(),N={anchorNode:N.anchorNode,anchorOffset:N.anchorOffset,focusNode:N.focusNode,focusOffset:N.focusOffset}),Ic&&Lc(Ic,N)||(Ic=N,N=rh(mg,"onSelect"),0<N.length&&(h=new Ri("onSelect","select",null,h,y),c.push({event:h,listeners:N}),h.target=Oi)))}function th(c,h){var y={};return y[c.toLowerCase()]=h.toLowerCase(),y["Webkit"+c]="webkit"+h,y["Moz"+c]="moz"+h,y}var Pi={animationend:th("Animation","AnimationEnd"),animationiteration:th("Animation","AnimationIteration"),animationstart:th("Animation","AnimationStart"),transitionend:th("Transition","TransitionEnd")},yg={},tC={};l&&(tC=document.createElement("div").style,"AnimationEvent"in window||(delete Pi.animationend.animation,delete Pi.animationiteration.animation,delete Pi.animationstart.animation),"TransitionEvent"in window||delete Pi.transitionend.transition);function nh(c){if(yg[c])return yg[c];if(!Pi[c])return c;var h=Pi[c],y;for(y in h)if(h.hasOwnProperty(y)&&y in tC)return yg[c]=h[y];return c}var nC=nh("animationend"),sC=nh("animationiteration"),rC=nh("animationstart"),aC=nh("transitionend"),oC=new Map,iC="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 Na(c,h){oC.set(c,h),o(h,[c])}for(var wg=0;wg<iC.length;wg++){var xg=iC[wg],LB=xg.toLowerCase(),IB=xg[0].toUpperCase()+xg.slice(1);Na(LB,"on"+IB)}Na(nC,"onAnimationEnd"),Na(sC,"onAnimationIteration"),Na(rC,"onAnimationStart"),Na("dblclick","onDoubleClick"),Na("focusin","onFocus"),Na("focusout","onBlur"),Na(aC,"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 Oc="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(" "),OB=new Set("cancel close invalid load scroll toggle".split(" ").concat(Oc));function lC(c,h,y){var N=c.type||"unknown-event";c.currentTarget=y,Es(N,h,void 0,c),c.currentTarget=null}function cC(c,h){h=(h&4)!==0;for(var y=0;y<c.length;y++){var N=c[y],E=N.event;N=N.listeners;e:{var L=void 0;if(h)for(var G=N.length-1;0<=G;G--){var ee=N[G],ne=ee.instance,ue=ee.currentTarget;if(ee=ee.listener,ne!==L&&E.isPropagationStopped())break e;lC(E,ee,ue),L=ne}else for(G=0;G<N.length;G++){if(ee=N[G],ne=ee.instance,ue=ee.currentTarget,ee=ee.listener,ne!==L&&E.isPropagationStopped())break e;lC(E,ee,ue),L=ne}}}if(Ct)throw c=qt,Ct=!1,qt=null,c}function _t(c,h){var y=h[_g];y===void 0&&(y=h[_g]=new Set);var N=c+"__bubble";y.has(N)||(uC(h,c,2,!1),y.add(N))}function vg(c,h,y){var N=0;h&&(N|=4),uC(y,c,N,h)}var sh="_reactListening"+Math.random().toString(36).slice(2);function Pc(c){if(!c[sh]){c[sh]=!0,s.forEach(function(y){y!=="selectionchange"&&(OB.has(y)||vg(y,!1,c),vg(y,!0,c))});var h=c.nodeType===9?c:c.ownerDocument;h===null||h[sh]||(h[sh]=!0,vg("selectionchange",!1,h))}}function uC(c,h,y,N){switch(bc(h)){case 1:var E=Zm;break;case 4:E=xc;break;default:E=vc}y=E.bind(null,h,y,c),E=void 0,!zt||h!=="touchstart"&&h!=="touchmove"&&h!=="wheel"||(E=!0),N?E!==void 0?c.addEventListener(h,y,{capture:!0,passive:E}):c.addEventListener(h,y,!0):E!==void 0?c.addEventListener(h,y,{passive:E}):c.addEventListener(h,y,!1)}function bg(c,h,y,N,E){var L=N;if((h&1)===0&&(h&2)===0&&N!==null)e:for(;;){if(N===null)return;var G=N.tag;if(G===3||G===4){var ee=N.stateNode.containerInfo;if(ee===E||ee.nodeType===8&&ee.parentNode===E)break;if(G===4)for(G=N.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=_o(ee),G===null)return;if(ne=G.tag,ne===5||ne===6){N=L=G;continue e}ee=ee.parentNode}}N=N.return}_s(function(){var ue=L,Se=ze(y),Ce=[];e:{var Ne=oC.get(c);if(Ne!==void 0){var Pe=Ri,qe=c;switch(c){case"keypress":if(Ai(y)===0)break e;case"keydown":case"keyup":Pe=sg;break;case"focusin":qe="focus",Pe=No;break;case"focusout":qe="blur",Pe=No;break;case"beforeblur":case"afterblur":Pe=No;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=jo;break;case"drag":case"dragend":case"dragenter":case"dragexit":case"dragleave":case"dragover":case"dragstart":case"drop":Pe=zd;break;case"touchcancel":case"touchend":case"touchmove":case"touchstart":Pe=ag;break;case nC:case sC:case rC:Pe=jc;break;case aC:Pe=Kd;break;case"scroll":Pe=Jm;break;case"wheel":Pe=ig;break;case"copy":case"cut":case"paste":Pe=Nc;break;case"gotpointercapture":case"lostpointercapture":case"pointercancel":case"pointerdown":case"pointermove":case"pointerout":case"pointerover":case"pointerup":Pe=So}var He=(h&4)!==0,Wt=!He&&c==="scroll",ie=He?Ne!==null?Ne+"Capture":null:Ne;He=[];for(var ae=ue,ce;ae!==null;){ce=ae;var Ee=ce.stateNode;if(ce.tag===5&&Ee!==null&&(ce=Ee,ie!==null&&(Ee=sn(ae,ie),Ee!=null&&He.push(Dc(ae,Ee,ce)))),Wt)break;ae=ae.return}0<He.length&&(Ne=new Pe(Ne,qe,null,y,Se),Ce.push({event:Ne,listeners:He}))}}if((h&7)===0){e:{if(Ne=c==="mouseover"||c==="pointerover",Pe=c==="mouseout"||c==="pointerout",Ne&&y!==_e&&(qe=y.relatedTarget||y.fromElement)&&(_o(qe)||qe[qr]))break e;if((Pe||Ne)&&(Ne=Se.window===Se?Se:(Ne=Se.ownerDocument)?Ne.defaultView||Ne.parentWindow:window,Pe?(qe=y.relatedTarget||y.toElement,Pe=ue,qe=qe?_o(qe):null,qe!==null&&(Wt=gn(qe),qe!==Wt||qe.tag!==5&&qe.tag!==6)&&(qe=null)):(Pe=null,qe=ue),Pe!==qe)){if(He=jo,Ee="onMouseLeave",ie="onMouseEnter",ae="mouse",(c==="pointerout"||c==="pointerover")&&(He=So,Ee="onPointerLeave",ie="onPointerEnter",ae="pointer"),Wt=Pe==null?Ne:Bi(Pe),ce=qe==null?Ne:Bi(qe),Ne=new He(Ee,ae+"leave",Pe,y,Se),Ne.target=Wt,Ne.relatedTarget=ce,Ee=null,_o(Se)===ue&&(He=new He(ie,ae+"enter",qe,y,Se),He.target=ce,He.relatedTarget=Wt,Ee=He),Wt=Ee,Pe&&qe)t:{for(He=Pe,ie=qe,ae=0,ce=He;ce;ce=Di(ce))ae++;for(ce=0,Ee=ie;Ee;Ee=Di(Ee))ce++;for(;0<ae-ce;)He=Di(He),ae--;for(;0<ce-ae;)ie=Di(ie),ce--;for(;ae--;){if(He===ie||ie!==null&&He===ie.alternate)break t;He=Di(He),ie=Di(ie)}He=null}else He=null;Pe!==null&&dC(Ce,Ne,Pe,He,!1),qe!==null&&Wt!==null&&dC(Ce,Wt,qe,He,!0)}}e:{if(Ne=ue?Bi(ue):window,Pe=Ne.nodeName&&Ne.nodeName.toLowerCase(),Pe==="select"||Pe==="input"&&Ne.type==="file")var Ge=hg;else if(Jd(Ne))if(eh)Ge=AB;else{Ge=EB;var Ze=fg}else(Pe=Ne.nodeName)&&Pe.toLowerCase()==="input"&&(Ne.type==="checkbox"||Ne.type==="radio")&&(Ge=TB);if(Ge&&(Ge=Ge(c,ue))){Qd(Ce,Ge,y,Se);break e}Ze&&Ze(c,Ne,ue),c==="focusout"&&(Ze=Ne._wrapperState)&&Ze.controlled&&Ne.type==="number"&&je(Ne,"number",Ne.value)}switch(Ze=ue?Bi(ue):window,c){case"focusin":(Jd(Ze)||Ze.contentEditable==="true")&&(Oi=Ze,mg=ue,Ic=null);break;case"focusout":Ic=mg=Oi=null;break;case"mousedown":gg=!0;break;case"contextmenu":case"mouseup":case"dragend":gg=!1,eC(Ce,y,Se);break;case"selectionchange":if($B)break;case"keydown":case"keyup":eC(Ce,y,Se)}var Je;if(Co)e:{switch(c){case"compositionstart":var et="onCompositionStart";break e;case"compositionend":et="onCompositionEnd";break e;case"compositionupdate":et="onCompositionUpdate";break e}et=void 0}else Fr?Zd(c,y)&&(et="onCompositionEnd"):c==="keydown"&&y.keyCode===229&&(et="onCompositionStart");et&&(Li&&y.locale!=="ko"&&(Fr||et!=="onCompositionStart"?et==="onCompositionEnd"&&Fr&&(Je=Ti()):(ar=Se,kc="value"in ar?ar.value:ar.textContent,Fr=!0)),Ze=rh(ue,et),0<Ze.length&&(et=new Sc(et,c,null,y,Se),Ce.push({event:et,listeners:Ze}),Je?et.data=Je:(Je=Ac(y),Je!==null&&(et.data=Je)))),(Je=Yd?Rc(c,y):cg(c,y))&&(ue=rh(ue,"onBeforeInput"),0<ue.length&&(Se=new Sc("onBeforeInput","beforeinput",null,y,Se),Ce.push({event:Se,listeners:ue}),Se.data=Je))}cC(Ce,h)})}function Dc(c,h,y){return{instance:c,listener:h,currentTarget:y}}function rh(c,h){for(var y=h+"Capture",N=[];c!==null;){var E=c,L=E.stateNode;E.tag===5&&L!==null&&(E=L,L=sn(c,y),L!=null&&N.unshift(Dc(c,L,E)),L=sn(c,h),L!=null&&N.push(Dc(c,L,E))),c=c.return}return N}function Di(c){if(c===null)return null;do c=c.return;while(c&&c.tag!==5);return c||null}function dC(c,h,y,N,E){for(var L=h._reactName,G=[];y!==null&&y!==N;){var ee=y,ne=ee.alternate,ue=ee.stateNode;if(ne!==null&&ne===N)break;ee.tag===5&&ue!==null&&(ee=ue,E?(ne=sn(y,L),ne!=null&&G.unshift(Dc(y,ne,ee))):E||(ne=sn(y,L),ne!=null&&G.push(Dc(y,ne,ee)))),y=y.return}G.length!==0&&c.push({event:h,listeners:G})}var PB=/\r\n?/g,DB=/\u0000|\uFFFD/g;function hC(c){return(typeof c=="string"?c:""+c).replace(PB,`
|
|
38
|
+
`).replace(DB,"")}function ah(c,h,y){if(h=hC(h),hC(c)!==h&&y)throw Error(n(425))}function oh(){}var kg=null,jg=null;function Ng(c,h){return c==="textarea"||c==="noscript"||typeof h.children=="string"||typeof h.children=="number"||typeof h.dangerouslySetInnerHTML=="object"&&h.dangerouslySetInnerHTML!==null&&h.dangerouslySetInnerHTML.__html!=null}var Sg=typeof setTimeout=="function"?setTimeout:void 0,FB=typeof clearTimeout=="function"?clearTimeout:void 0,fC=typeof Promise=="function"?Promise:void 0,BB=typeof queueMicrotask=="function"?queueMicrotask:typeof fC<"u"?function(c){return fC.resolve(null).then(c).catch(qB)}:Sg;function qB(c){setTimeout(function(){throw c})}function Cg(c,h){var y=h,N=0;do{var E=y.nextSibling;if(c.removeChild(y),E&&E.nodeType===8)if(y=E.data,y==="/$"){if(N===0){c.removeChild(E),wo(h);return}N--}else y!=="$"&&y!=="$?"&&y!=="$!"||N++;y=E}while(y);wo(h)}function Sa(c){for(;c!=null;c=c.nextSibling){var h=c.nodeType;if(h===1||h===3)break;if(h===8){if(h=c.data,h==="$"||h==="$!"||h==="$?")break;if(h==="/$")return null}}return c}function pC(c){c=c.previousSibling;for(var h=0;c;){if(c.nodeType===8){var y=c.data;if(y==="$"||y==="$!"||y==="$?"){if(h===0)return c;h--}else y==="/$"&&h++}c=c.previousSibling}return null}var Fi=Math.random().toString(36).slice(2),ir="__reactFiber$"+Fi,Fc="__reactProps$"+Fi,qr="__reactContainer$"+Fi,_g="__reactEvents$"+Fi,UB="__reactListeners$"+Fi,WB="__reactHandles$"+Fi;function _o(c){var h=c[ir];if(h)return h;for(var y=c.parentNode;y;){if(h=y[qr]||y[ir]){if(y=h.alternate,h.child!==null||y!==null&&y.child!==null)for(c=pC(c);c!==null;){if(y=c[ir])return y;c=pC(c)}return h}c=y,y=c.parentNode}return null}function Bc(c){return c=c[ir]||c[qr],!c||c.tag!==5&&c.tag!==6&&c.tag!==13&&c.tag!==3?null:c}function Bi(c){if(c.tag===5||c.tag===6)return c.stateNode;throw Error(n(33))}function ih(c){return c[Fc]||null}var Eg=[],qi=-1;function Ca(c){return{current:c}}function Et(c){0>qi||(c.current=Eg[qi],Eg[qi]=null,qi--)}function Nt(c,h){qi++,Eg[qi]=c.current,c.current=h}var _a={},wn=Ca(_a),Mn=Ca(!1),Eo=_a;function Ui(c,h){var y=c.type.contextTypes;if(!y)return _a;var N=c.stateNode;if(N&&N.__reactInternalMemoizedUnmaskedChildContext===h)return N.__reactInternalMemoizedMaskedChildContext;var E={},L;for(L in y)E[L]=h[L];return N&&(c=c.stateNode,c.__reactInternalMemoizedUnmaskedChildContext=h,c.__reactInternalMemoizedMaskedChildContext=E),E}function $n(c){return c=c.childContextTypes,c!=null}function lh(){Et(Mn),Et(wn)}function mC(c,h,y){if(wn.current!==_a)throw Error(n(168));Nt(wn,h),Nt(Mn,y)}function gC(c,h,y){var N=c.stateNode;if(h=h.childContextTypes,typeof N.getChildContext!="function")return y;N=N.getChildContext();for(var E in N)if(!(E in h))throw Error(n(108,J(c)||"Unknown",E));return D({},y,N)}function ch(c){return c=(c=c.stateNode)&&c.__reactInternalMemoizedMergedChildContext||_a,Eo=wn.current,Nt(wn,c),Nt(Mn,Mn.current),!0}function yC(c,h,y){var N=c.stateNode;if(!N)throw Error(n(169));y?(c=gC(c,h,Eo),N.__reactInternalMemoizedMergedChildContext=c,Et(Mn),Et(wn),Nt(wn,c)):Et(Mn),Nt(Mn,y)}var Ur=null,uh=!1,Tg=!1;function wC(c){Ur===null?Ur=[c]:Ur.push(c)}function HB(c){uh=!0,wC(c)}function Ea(){if(!Tg&&Ur!==null){Tg=!0;var c=0,h=ct;try{var y=Ur;for(ct=1;c<y.length;c++){var N=y[c];do N=N(!0);while(N!==null)}Ur=null,uh=!1}catch(E){throw Ur!==null&&(Ur=Ur.slice(c+1)),ya(ns,Ea),E}finally{ct=h,Tg=!1}}return null}var Wi=[],Hi=0,dh=null,hh=0,os=[],is=0,To=null,Wr=1,Hr="";function Ao(c,h){Wi[Hi++]=hh,Wi[Hi++]=dh,dh=c,hh=h}function xC(c,h,y){os[is++]=Wr,os[is++]=Hr,os[is++]=To,To=c;var N=Wr;c=Hr;var E=32-yn(N)-1;N&=~(1<<E),y+=1;var L=32-yn(h)+E;if(30<L){var G=E-E%5;L=(N&(1<<G)-1).toString(32),N>>=G,E-=G,Wr=1<<32-yn(h)+E|y<<E|N,Hr=L+c}else Wr=1<<L|y<<E|N,Hr=c}function Ag(c){c.return!==null&&(Ao(c,1),xC(c,1,0))}function Rg(c){for(;c===dh;)dh=Wi[--Hi],Wi[Hi]=null,hh=Wi[--Hi],Wi[Hi]=null;for(;c===To;)To=os[--is],os[is]=null,Hr=os[--is],os[is]=null,Wr=os[--is],os[is]=null}var Gn=null,Kn=null,At=!1,Ds=null;function vC(c,h){var y=ds(5,null,null,0);y.elementType="DELETED",y.stateNode=h,y.return=c,h=c.deletions,h===null?(c.deletions=[y],c.flags|=16):h.push(y)}function bC(c,h){switch(c.tag){case 5:var y=c.type;return h=h.nodeType!==1||y.toLowerCase()!==h.nodeName.toLowerCase()?null:h,h!==null?(c.stateNode=h,Gn=c,Kn=Sa(h.firstChild),!0):!1;case 6:return h=c.pendingProps===""||h.nodeType!==3?null:h,h!==null?(c.stateNode=h,Gn=c,Kn=null,!0):!1;case 13:return h=h.nodeType!==8?null:h,h!==null?(y=To!==null?{id:Wr,overflow:Hr}:null,c.memoizedState={dehydrated:h,treeContext:y,retryLane:1073741824},y=ds(18,null,null,0),y.stateNode=h,y.return=c,c.child=y,Gn=c,Kn=null,!0):!1;default:return!1}}function Mg(c){return(c.mode&1)!==0&&(c.flags&128)===0}function $g(c){if(At){var h=Kn;if(h){var y=h;if(!bC(c,h)){if(Mg(c))throw Error(n(418));h=Sa(y.nextSibling);var N=Gn;h&&bC(c,h)?vC(N,y):(c.flags=c.flags&-4097|2,At=!1,Gn=c)}}else{if(Mg(c))throw Error(n(418));c.flags=c.flags&-4097|2,At=!1,Gn=c}}}function kC(c){for(c=c.return;c!==null&&c.tag!==5&&c.tag!==3&&c.tag!==13;)c=c.return;Gn=c}function fh(c){if(c!==Gn)return!1;if(!At)return kC(c),At=!0,!1;var h;if((h=c.tag!==3)&&!(h=c.tag!==5)&&(h=c.type,h=h!=="head"&&h!=="body"&&!Ng(c.type,c.memoizedProps)),h&&(h=Kn)){if(Mg(c))throw jC(),Error(n(418));for(;h;)vC(c,h),h=Sa(h.nextSibling)}if(kC(c),c.tag===13){if(c=c.memoizedState,c=c!==null?c.dehydrated:null,!c)throw Error(n(317));e:{for(c=c.nextSibling,h=0;c;){if(c.nodeType===8){var y=c.data;if(y==="/$"){if(h===0){Kn=Sa(c.nextSibling);break e}h--}else y!=="$"&&y!=="$!"&&y!=="$?"||h++}c=c.nextSibling}Kn=null}}else Kn=Gn?Sa(c.stateNode.nextSibling):null;return!0}function jC(){for(var c=Kn;c;)c=Sa(c.nextSibling)}function zi(){Kn=Gn=null,At=!1}function Lg(c){Ds===null?Ds=[c]:Ds.push(c)}var zB=C.ReactCurrentBatchConfig;function qc(c,h,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 N=y.stateNode}if(!N)throw Error(n(147,c));var E=N,L=""+c;return h!==null&&h.ref!==null&&typeof h.ref=="function"&&h.ref._stringRef===L?h.ref:(h=function(G){var ee=E.refs;G===null?delete ee[L]:ee[L]=G},h._stringRef=L,h)}if(typeof c!="string")throw Error(n(284));if(!y._owner)throw Error(n(290,c))}return c}function ph(c,h){throw c=Object.prototype.toString.call(h),Error(n(31,c==="[object Object]"?"object with keys {"+Object.keys(h).join(", ")+"}":c))}function NC(c){var h=c._init;return h(c._payload)}function SC(c){function h(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;)h(ie,ae),ae=ae.sibling;return null}function N(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=Oa(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,Ee){return ae===null||ae.tag!==6?(ae=Sy(ce,ie.mode,Ee),ae.return=ie,ae):(ae=E(ae,ce),ae.return=ie,ae)}function ne(ie,ae,ce,Ee){var Ge=ce.type;return Ge===A?Se(ie,ae,ce.props.children,Ee,ce.key):ae!==null&&(ae.elementType===Ge||typeof Ge=="object"&&Ge!==null&&Ge.$$typeof===q&&NC(Ge)===ae.type)?(Ee=E(ae,ce.props),Ee.ref=qc(ie,ae,ce),Ee.return=ie,Ee):(Ee=Dh(ce.type,ce.key,ce.props,null,ie.mode,Ee),Ee.ref=qc(ie,ae,ce),Ee.return=ie,Ee)}function ue(ie,ae,ce,Ee){return ae===null||ae.tag!==4||ae.stateNode.containerInfo!==ce.containerInfo||ae.stateNode.implementation!==ce.implementation?(ae=Cy(ce,ie.mode,Ee),ae.return=ie,ae):(ae=E(ae,ce.children||[]),ae.return=ie,ae)}function Se(ie,ae,ce,Ee,Ge){return ae===null||ae.tag!==7?(ae=Do(ce,ie.mode,Ee,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=Sy(""+ae,ie.mode,ce),ae.return=ie,ae;if(typeof ae=="object"&&ae!==null){switch(ae.$$typeof){case _:return ce=Dh(ae.type,ae.key,ae.props,null,ie.mode,ce),ce.ref=qc(ie,null,ae),ce.return=ie,ce;case R:return ae=Cy(ae,ie.mode,ce),ae.return=ie,ae;case q:var Ee=ae._init;return Ce(ie,Ee(ae._payload),ce)}if(Le(ae)||H(ae))return ae=Do(ae,ie.mode,ce,null),ae.return=ie,ae;ph(ie,ae)}return null}function Ne(ie,ae,ce,Ee){var Ge=ae!==null?ae.key:null;if(typeof ce=="string"&&ce!==""||typeof ce=="number")return Ge!==null?null:ee(ie,ae,""+ce,Ee);if(typeof ce=="object"&&ce!==null){switch(ce.$$typeof){case _:return ce.key===Ge?ne(ie,ae,ce,Ee):null;case R:return ce.key===Ge?ue(ie,ae,ce,Ee):null;case q:return Ge=ce._init,Ne(ie,ae,Ge(ce._payload),Ee)}if(Le(ce)||H(ce))return Ge!==null?null:Se(ie,ae,ce,Ee,null);ph(ie,ce)}return null}function Pe(ie,ae,ce,Ee,Ge){if(typeof Ee=="string"&&Ee!==""||typeof Ee=="number")return ie=ie.get(ce)||null,ee(ae,ie,""+Ee,Ge);if(typeof Ee=="object"&&Ee!==null){switch(Ee.$$typeof){case _:return ie=ie.get(Ee.key===null?ce:Ee.key)||null,ne(ae,ie,Ee,Ge);case R:return ie=ie.get(Ee.key===null?ce:Ee.key)||null,ue(ae,ie,Ee,Ge);case q:var Ze=Ee._init;return Pe(ie,ae,ce,Ze(Ee._payload),Ge)}if(Le(Ee)||H(Ee))return ie=ie.get(ce)||null,Se(ae,ie,Ee,Ge,null);ph(ae,Ee)}return null}function qe(ie,ae,ce,Ee){for(var Ge=null,Ze=null,Je=ae,et=ae=0,on=null;Je!==null&&et<ce.length;et++){Je.index>et?(on=Je,Je=null):on=Je.sibling;var pt=Ne(ie,Je,ce[et],Ee);if(pt===null){Je===null&&(Je=on);break}c&&Je&&pt.alternate===null&&h(ie,Je),ae=L(pt,ae,et),Ze===null?Ge=pt:Ze.sibling=pt,Ze=pt,Je=on}if(et===ce.length)return y(ie,Je),At&&Ao(ie,et),Ge;if(Je===null){for(;et<ce.length;et++)Je=Ce(ie,ce[et],Ee),Je!==null&&(ae=L(Je,ae,et),Ze===null?Ge=Je:Ze.sibling=Je,Ze=Je);return At&&Ao(ie,et),Ge}for(Je=N(ie,Je);et<ce.length;et++)on=Pe(Je,ie,et,ce[et],Ee),on!==null&&(c&&on.alternate!==null&&Je.delete(on.key===null?et:on.key),ae=L(on,ae,et),Ze===null?Ge=on:Ze.sibling=on,Ze=on);return c&&Je.forEach(function(Pa){return h(ie,Pa)}),At&&Ao(ie,et),Ge}function He(ie,ae,ce,Ee){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 Ze=Ge=null,Je=ae,et=ae=0,on=null,pt=ce.next();Je!==null&&!pt.done;et++,pt=ce.next()){Je.index>et?(on=Je,Je=null):on=Je.sibling;var Pa=Ne(ie,Je,pt.value,Ee);if(Pa===null){Je===null&&(Je=on);break}c&&Je&&Pa.alternate===null&&h(ie,Je),ae=L(Pa,ae,et),Ze===null?Ge=Pa:Ze.sibling=Pa,Ze=Pa,Je=on}if(pt.done)return y(ie,Je),At&&Ao(ie,et),Ge;if(Je===null){for(;!pt.done;et++,pt=ce.next())pt=Ce(ie,pt.value,Ee),pt!==null&&(ae=L(pt,ae,et),Ze===null?Ge=pt:Ze.sibling=pt,Ze=pt);return At&&Ao(ie,et),Ge}for(Je=N(ie,Je);!pt.done;et++,pt=ce.next())pt=Pe(Je,ie,et,pt.value,Ee),pt!==null&&(c&&pt.alternate!==null&&Je.delete(pt.key===null?et:pt.key),ae=L(pt,ae,et),Ze===null?Ge=pt:Ze.sibling=pt,Ze=pt);return c&&Je.forEach(function(Nq){return h(ie,Nq)}),At&&Ao(ie,et),Ge}function Wt(ie,ae,ce,Ee){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,Ze=ae;Ze!==null;){if(Ze.key===Ge){if(Ge=ce.type,Ge===A){if(Ze.tag===7){y(ie,Ze.sibling),ae=E(Ze,ce.props.children),ae.return=ie,ie=ae;break e}}else if(Ze.elementType===Ge||typeof Ge=="object"&&Ge!==null&&Ge.$$typeof===q&&NC(Ge)===Ze.type){y(ie,Ze.sibling),ae=E(Ze,ce.props),ae.ref=qc(ie,Ze,ce),ae.return=ie,ie=ae;break e}y(ie,Ze);break}else h(ie,Ze);Ze=Ze.sibling}ce.type===A?(ae=Do(ce.props.children,ie.mode,Ee,ce.key),ae.return=ie,ie=ae):(Ee=Dh(ce.type,ce.key,ce.props,null,ie.mode,Ee),Ee.ref=qc(ie,ae,ce),Ee.return=ie,ie=Ee)}return G(ie);case R:e:{for(Ze=ce.key;ae!==null;){if(ae.key===Ze)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 h(ie,ae);ae=ae.sibling}ae=Cy(ce,ie.mode,Ee),ae.return=ie,ie=ae}return G(ie);case q:return Ze=ce._init,Wt(ie,ae,Ze(ce._payload),Ee)}if(Le(ce))return qe(ie,ae,ce,Ee);if(H(ce))return He(ie,ae,ce,Ee);ph(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=Sy(ce,ie.mode,Ee),ae.return=ie,ie=ae),G(ie)):y(ie,ae)}return Wt}var Vi=SC(!0),CC=SC(!1),mh=Ca(null),gh=null,Gi=null,Ig=null;function Og(){Ig=Gi=gh=null}function Pg(c){var h=mh.current;Et(mh),c._currentValue=h}function Dg(c,h,y){for(;c!==null;){var N=c.alternate;if((c.childLanes&h)!==h?(c.childLanes|=h,N!==null&&(N.childLanes|=h)):N!==null&&(N.childLanes&h)!==h&&(N.childLanes|=h),c===y)break;c=c.return}}function Ki(c,h){gh=c,Ig=Gi=null,c=c.dependencies,c!==null&&c.firstContext!==null&&((c.lanes&h)!==0&&(Ln=!0),c.firstContext=null)}function ls(c){var h=c._currentValue;if(Ig!==c)if(c={context:c,memoizedValue:h,next:null},Gi===null){if(gh===null)throw Error(n(308));Gi=c,gh.dependencies={lanes:0,firstContext:c}}else Gi=Gi.next=c;return h}var Ro=null;function Fg(c){Ro===null?Ro=[c]:Ro.push(c)}function _C(c,h,y,N){var E=h.interleaved;return E===null?(y.next=y,Fg(h)):(y.next=E.next,E.next=y),h.interleaved=y,zr(c,N)}function zr(c,h){c.lanes|=h;var y=c.alternate;for(y!==null&&(y.lanes|=h),y=c,c=c.return;c!==null;)c.childLanes|=h,y=c.alternate,y!==null&&(y.childLanes|=h),y=c,c=c.return;return y.tag===3?y.stateNode:null}var Ta=!1;function Bg(c){c.updateQueue={baseState:c.memoizedState,firstBaseUpdate:null,lastBaseUpdate:null,shared:{pending:null,interleaved:null,lanes:0},effects:null}}function EC(c,h){c=c.updateQueue,h.updateQueue===c&&(h.updateQueue={baseState:c.baseState,firstBaseUpdate:c.firstBaseUpdate,lastBaseUpdate:c.lastBaseUpdate,shared:c.shared,effects:c.effects})}function Vr(c,h){return{eventTime:c,lane:h,tag:0,payload:null,callback:null,next:null}}function Aa(c,h,y){var N=c.updateQueue;if(N===null)return null;if(N=N.shared,(ht&2)!==0){var E=N.pending;return E===null?h.next=h:(h.next=E.next,E.next=h),N.pending=h,zr(c,y)}return E=N.interleaved,E===null?(h.next=h,Fg(N)):(h.next=E.next,E.next=h),N.interleaved=h,zr(c,y)}function yh(c,h,y){if(h=h.updateQueue,h!==null&&(h=h.shared,(y&4194240)!==0)){var N=h.lanes;N&=c.pendingLanes,y|=N,h.lanes=y,ji(c,y)}}function TC(c,h){var y=c.updateQueue,N=c.alternate;if(N!==null&&(N=N.updateQueue,y===N)){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=h:L=L.next=h}else E=L=h;y={baseState:N.baseState,firstBaseUpdate:E,lastBaseUpdate:L,shared:N.shared,effects:N.effects},c.updateQueue=y;return}c=y.lastBaseUpdate,c===null?y.firstBaseUpdate=h:c.next=h,y.lastBaseUpdate=h}function wh(c,h,y,N){var E=c.updateQueue;Ta=!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((N&Ne)===Ne){Se!==null&&(Se=Se.next={eventTime:Pe,lane:0,tag:ee.tag,payload:ee.payload,callback:ee.callback,next:null});e:{var qe=c,He=ee;switch(Ne=h,Pe=y,He.tag){case 1:if(qe=He.payload,typeof qe=="function"){Ce=qe.call(Pe,Ce,Ne);break e}Ce=qe;break e;case 3:qe.flags=qe.flags&-65537|128;case 0:if(qe=He.payload,Ne=typeof qe=="function"?qe.call(Pe,Ce,Ne):qe,Ne==null)break e;Ce=D({},Ce,Ne);break e;case 2:Ta=!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,h=E.shared.interleaved,h!==null){E=h;do G|=E.lane,E=E.next;while(E!==h)}else L===null&&(E.shared.lanes=0);Lo|=G,c.lanes=G,c.memoizedState=Ce}}function AC(c,h,y){if(c=h.effects,h.effects=null,c!==null)for(h=0;h<c.length;h++){var N=c[h],E=N.callback;if(E!==null){if(N.callback=null,N=y,typeof E!="function")throw Error(n(191,E));E.call(N)}}}var Uc={},lr=Ca(Uc),Wc=Ca(Uc),Hc=Ca(Uc);function Mo(c){if(c===Uc)throw Error(n(174));return c}function qg(c,h){switch(Nt(Hc,h),Nt(Wc,c),Nt(lr,Uc),c=h.nodeType,c){case 9:case 11:h=(h=h.documentElement)?h.namespaceURI:Fe(null,"");break;default:c=c===8?h.parentNode:h,h=c.namespaceURI||null,c=c.tagName,h=Fe(h,c)}Et(lr),Nt(lr,h)}function Yi(){Et(lr),Et(Wc),Et(Hc)}function RC(c){Mo(Hc.current);var h=Mo(lr.current),y=Fe(h,c.type);h!==y&&(Nt(Wc,c),Nt(lr,y))}function Ug(c){Wc.current===c&&(Et(lr),Et(Wc))}var It=Ca(0);function xh(c){for(var h=c;h!==null;){if(h.tag===13){var y=h.memoizedState;if(y!==null&&(y=y.dehydrated,y===null||y.data==="$?"||y.data==="$!"))return h}else if(h.tag===19&&h.memoizedProps.revealOrder!==void 0){if((h.flags&128)!==0)return h}else if(h.child!==null){h.child.return=h,h=h.child;continue}if(h===c)break;for(;h.sibling===null;){if(h.return===null||h.return===c)return null;h=h.return}h.sibling.return=h.return,h=h.sibling}return null}var Wg=[];function Hg(){for(var c=0;c<Wg.length;c++)Wg[c]._workInProgressVersionPrimary=null;Wg.length=0}var vh=C.ReactCurrentDispatcher,zg=C.ReactCurrentBatchConfig,$o=0,Ot=null,Zt=null,rn=null,bh=!1,zc=!1,Vc=0,VB=0;function xn(){throw Error(n(321))}function Vg(c,h){if(h===null)return!1;for(var y=0;y<h.length&&y<c.length;y++)if(!Ps(c[y],h[y]))return!1;return!0}function Gg(c,h,y,N,E,L){if($o=L,Ot=h,h.memoizedState=null,h.updateQueue=null,h.lanes=0,vh.current=c===null||c.memoizedState===null?XB:ZB,c=y(N,E),zc){L=0;do{if(zc=!1,Vc=0,25<=L)throw Error(n(301));L+=1,rn=Zt=null,h.updateQueue=null,vh.current=JB,c=y(N,E)}while(zc)}if(vh.current=Nh,h=Zt!==null&&Zt.next!==null,$o=0,rn=Zt=Ot=null,bh=!1,h)throw Error(n(300));return c}function Kg(){var c=Vc!==0;return Vc=0,c}function cr(){var c={memoizedState:null,baseState:null,baseQueue:null,queue:null,next:null};return rn===null?Ot.memoizedState=rn=c:rn=rn.next=c,rn}function cs(){if(Zt===null){var c=Ot.alternate;c=c!==null?c.memoizedState:null}else c=Zt.next;var h=rn===null?Ot.memoizedState:rn.next;if(h!==null)rn=h,Zt=c;else{if(c===null)throw Error(n(310));Zt=c,c={memoizedState:Zt.memoizedState,baseState:Zt.baseState,baseQueue:Zt.baseQueue,queue:Zt.queue,next:null},rn===null?Ot.memoizedState=rn=c:rn=rn.next=c}return rn}function Gc(c,h){return typeof h=="function"?h(c):h}function Yg(c){var h=cs(),y=h.queue;if(y===null)throw Error(n(311));y.lastRenderedReducer=c;var N=Zt,E=N.baseQueue,L=y.pending;if(L!==null){if(E!==null){var G=E.next;E.next=L.next,L.next=G}N.baseQueue=E=L,y.pending=null}if(E!==null){L=E.next,N=N.baseState;var ee=G=null,ne=null,ue=L;do{var Se=ue.lane;if(($o&Se)===Se)ne!==null&&(ne=ne.next={lane:0,action:ue.action,hasEagerState:ue.hasEagerState,eagerState:ue.eagerState,next:null}),N=ue.hasEagerState?ue.eagerState:c(N,ue.action);else{var Ce={lane:Se,action:ue.action,hasEagerState:ue.hasEagerState,eagerState:ue.eagerState,next:null};ne===null?(ee=ne=Ce,G=N):ne=ne.next=Ce,Ot.lanes|=Se,Lo|=Se}ue=ue.next}while(ue!==null&&ue!==L);ne===null?G=N:ne.next=ee,Ps(N,h.memoizedState)||(Ln=!0),h.memoizedState=N,h.baseState=G,h.baseQueue=ne,y.lastRenderedState=N}if(c=y.interleaved,c!==null){E=c;do L=E.lane,Ot.lanes|=L,Lo|=L,E=E.next;while(E!==c)}else E===null&&(y.lanes=0);return[h.memoizedState,y.dispatch]}function Xg(c){var h=cs(),y=h.queue;if(y===null)throw Error(n(311));y.lastRenderedReducer=c;var N=y.dispatch,E=y.pending,L=h.memoizedState;if(E!==null){y.pending=null;var G=E=E.next;do L=c(L,G.action),G=G.next;while(G!==E);Ps(L,h.memoizedState)||(Ln=!0),h.memoizedState=L,h.baseQueue===null&&(h.baseState=L),y.lastRenderedState=L}return[L,N]}function MC(){}function $C(c,h){var y=Ot,N=cs(),E=h(),L=!Ps(N.memoizedState,E);if(L&&(N.memoizedState=E,Ln=!0),N=N.queue,Zg(OC.bind(null,y,N,c),[c]),N.getSnapshot!==h||L||rn!==null&&rn.memoizedState.tag&1){if(y.flags|=2048,Kc(9,IC.bind(null,y,N,E,h),void 0,null),an===null)throw Error(n(349));($o&30)!==0||LC(y,h,E)}return E}function LC(c,h,y){c.flags|=16384,c={getSnapshot:h,value:y},h=Ot.updateQueue,h===null?(h={lastEffect:null,stores:null},Ot.updateQueue=h,h.stores=[c]):(y=h.stores,y===null?h.stores=[c]:y.push(c))}function IC(c,h,y,N){h.value=y,h.getSnapshot=N,PC(h)&&DC(c)}function OC(c,h,y){return y(function(){PC(h)&&DC(c)})}function PC(c){var h=c.getSnapshot;c=c.value;try{var y=h();return!Ps(c,y)}catch{return!0}}function DC(c){var h=zr(c,1);h!==null&&Us(h,c,1,-1)}function FC(c){var h=cr();return typeof c=="function"&&(c=c()),h.memoizedState=h.baseState=c,c={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:Gc,lastRenderedState:c},h.queue=c,c=c.dispatch=YB.bind(null,Ot,c),[h.memoizedState,c]}function Kc(c,h,y,N){return c={tag:c,create:h,destroy:y,deps:N,next:null},h=Ot.updateQueue,h===null?(h={lastEffect:null,stores:null},Ot.updateQueue=h,h.lastEffect=c.next=c):(y=h.lastEffect,y===null?h.lastEffect=c.next=c:(N=y.next,y.next=c,c.next=N,h.lastEffect=c)),c}function BC(){return cs().memoizedState}function kh(c,h,y,N){var E=cr();Ot.flags|=c,E.memoizedState=Kc(1|h,y,void 0,N===void 0?null:N)}function jh(c,h,y,N){var E=cs();N=N===void 0?null:N;var L=void 0;if(Zt!==null){var G=Zt.memoizedState;if(L=G.destroy,N!==null&&Vg(N,G.deps)){E.memoizedState=Kc(h,y,L,N);return}}Ot.flags|=c,E.memoizedState=Kc(1|h,y,L,N)}function qC(c,h){return kh(8390656,8,c,h)}function Zg(c,h){return jh(2048,8,c,h)}function UC(c,h){return jh(4,2,c,h)}function WC(c,h){return jh(4,4,c,h)}function HC(c,h){if(typeof h=="function")return c=c(),h(c),function(){h(null)};if(h!=null)return c=c(),h.current=c,function(){h.current=null}}function zC(c,h,y){return y=y!=null?y.concat([c]):null,jh(4,4,HC.bind(null,h,c),y)}function Jg(){}function VC(c,h){var y=cs();h=h===void 0?null:h;var N=y.memoizedState;return N!==null&&h!==null&&Vg(h,N[1])?N[0]:(y.memoizedState=[c,h],c)}function GC(c,h){var y=cs();h=h===void 0?null:h;var N=y.memoizedState;return N!==null&&h!==null&&Vg(h,N[1])?N[0]:(c=c(),y.memoizedState=[c,h],c)}function KC(c,h,y){return($o&21)===0?(c.baseState&&(c.baseState=!1,Ln=!0),c.memoizedState=y):(Ps(y,h)||(y=Dd(),Ot.lanes|=y,Lo|=y,c.baseState=!0),h)}function GB(c,h){var y=ct;ct=y!==0&&4>y?y:4,c(!0);var N=zg.transition;zg.transition={};try{c(!1),h()}finally{ct=y,zg.transition=N}}function YC(){return cs().memoizedState}function KB(c,h,y){var N=La(c);if(y={lane:N,action:y,hasEagerState:!1,eagerState:null,next:null},XC(c))ZC(h,y);else if(y=_C(c,h,y,N),y!==null){var E=Nn();Us(y,c,N,E),JC(y,h,N)}}function YB(c,h,y){var N=La(c),E={lane:N,action:y,hasEagerState:!1,eagerState:null,next:null};if(XC(c))ZC(h,E);else{var L=c.alternate;if(c.lanes===0&&(L===null||L.lanes===0)&&(L=h.lastRenderedReducer,L!==null))try{var G=h.lastRenderedState,ee=L(G,y);if(E.hasEagerState=!0,E.eagerState=ee,Ps(ee,G)){var ne=h.interleaved;ne===null?(E.next=E,Fg(h)):(E.next=ne.next,ne.next=E),h.interleaved=E;return}}catch{}finally{}y=_C(c,h,E,N),y!==null&&(E=Nn(),Us(y,c,N,E),JC(y,h,N))}}function XC(c){var h=c.alternate;return c===Ot||h!==null&&h===Ot}function ZC(c,h){zc=bh=!0;var y=c.pending;y===null?h.next=h:(h.next=y.next,y.next=h),c.pending=h}function JC(c,h,y){if((y&4194240)!==0){var N=h.lanes;N&=c.pendingLanes,y|=N,h.lanes=y,ji(c,y)}}var Nh={readContext:ls,useCallback:xn,useContext:xn,useEffect:xn,useImperativeHandle:xn,useInsertionEffect:xn,useLayoutEffect:xn,useMemo:xn,useReducer:xn,useRef:xn,useState:xn,useDebugValue:xn,useDeferredValue:xn,useTransition:xn,useMutableSource:xn,useSyncExternalStore:xn,useId:xn,unstable_isNewReconciler:!1},XB={readContext:ls,useCallback:function(c,h){return cr().memoizedState=[c,h===void 0?null:h],c},useContext:ls,useEffect:qC,useImperativeHandle:function(c,h,y){return y=y!=null?y.concat([c]):null,kh(4194308,4,HC.bind(null,h,c),y)},useLayoutEffect:function(c,h){return kh(4194308,4,c,h)},useInsertionEffect:function(c,h){return kh(4,2,c,h)},useMemo:function(c,h){var y=cr();return h=h===void 0?null:h,c=c(),y.memoizedState=[c,h],c},useReducer:function(c,h,y){var N=cr();return h=y!==void 0?y(h):h,N.memoizedState=N.baseState=h,c={pending:null,interleaved:null,lanes:0,dispatch:null,lastRenderedReducer:c,lastRenderedState:h},N.queue=c,c=c.dispatch=KB.bind(null,Ot,c),[N.memoizedState,c]},useRef:function(c){var h=cr();return c={current:c},h.memoizedState=c},useState:FC,useDebugValue:Jg,useDeferredValue:function(c){return cr().memoizedState=c},useTransition:function(){var c=FC(!1),h=c[0];return c=GB.bind(null,c[1]),cr().memoizedState=c,[h,c]},useMutableSource:function(){},useSyncExternalStore:function(c,h,y){var N=Ot,E=cr();if(At){if(y===void 0)throw Error(n(407));y=y()}else{if(y=h(),an===null)throw Error(n(349));($o&30)!==0||LC(N,h,y)}E.memoizedState=y;var L={value:y,getSnapshot:h};return E.queue=L,qC(OC.bind(null,N,L,c),[c]),N.flags|=2048,Kc(9,IC.bind(null,N,L,y,h),void 0,null),y},useId:function(){var c=cr(),h=an.identifierPrefix;if(At){var y=Hr,N=Wr;y=(N&~(1<<32-yn(N)-1)).toString(32)+y,h=":"+h+"R"+y,y=Vc++,0<y&&(h+="H"+y.toString(32)),h+=":"}else y=VB++,h=":"+h+"r"+y.toString(32)+":";return c.memoizedState=h},unstable_isNewReconciler:!1},ZB={readContext:ls,useCallback:VC,useContext:ls,useEffect:Zg,useImperativeHandle:zC,useInsertionEffect:UC,useLayoutEffect:WC,useMemo:GC,useReducer:Yg,useRef:BC,useState:function(){return Yg(Gc)},useDebugValue:Jg,useDeferredValue:function(c){var h=cs();return KC(h,Zt.memoizedState,c)},useTransition:function(){var c=Yg(Gc)[0],h=cs().memoizedState;return[c,h]},useMutableSource:MC,useSyncExternalStore:$C,useId:YC,unstable_isNewReconciler:!1},JB={readContext:ls,useCallback:VC,useContext:ls,useEffect:Zg,useImperativeHandle:zC,useInsertionEffect:UC,useLayoutEffect:WC,useMemo:GC,useReducer:Xg,useRef:BC,useState:function(){return Xg(Gc)},useDebugValue:Jg,useDeferredValue:function(c){var h=cs();return Zt===null?h.memoizedState=c:KC(h,Zt.memoizedState,c)},useTransition:function(){var c=Xg(Gc)[0],h=cs().memoizedState;return[c,h]},useMutableSource:MC,useSyncExternalStore:$C,useId:YC,unstable_isNewReconciler:!1};function Fs(c,h){if(c&&c.defaultProps){h=D({},h),c=c.defaultProps;for(var y in c)h[y]===void 0&&(h[y]=c[y]);return h}return h}function Qg(c,h,y,N){h=c.memoizedState,y=y(N,h),y=y==null?h:D({},h,y),c.memoizedState=y,c.lanes===0&&(c.updateQueue.baseState=y)}var Sh={isMounted:function(c){return(c=c._reactInternals)?gn(c)===c:!1},enqueueSetState:function(c,h,y){c=c._reactInternals;var N=Nn(),E=La(c),L=Vr(N,E);L.payload=h,y!=null&&(L.callback=y),h=Aa(c,L,E),h!==null&&(Us(h,c,E,N),yh(h,c,E))},enqueueReplaceState:function(c,h,y){c=c._reactInternals;var N=Nn(),E=La(c),L=Vr(N,E);L.tag=1,L.payload=h,y!=null&&(L.callback=y),h=Aa(c,L,E),h!==null&&(Us(h,c,E,N),yh(h,c,E))},enqueueForceUpdate:function(c,h){c=c._reactInternals;var y=Nn(),N=La(c),E=Vr(y,N);E.tag=2,h!=null&&(E.callback=h),h=Aa(c,E,N),h!==null&&(Us(h,c,N,y),yh(h,c,N))}};function QC(c,h,y,N,E,L,G){return c=c.stateNode,typeof c.shouldComponentUpdate=="function"?c.shouldComponentUpdate(N,L,G):h.prototype&&h.prototype.isPureReactComponent?!Lc(y,N)||!Lc(E,L):!0}function e_(c,h,y){var N=!1,E=_a,L=h.contextType;return typeof L=="object"&&L!==null?L=ls(L):(E=$n(h)?Eo:wn.current,N=h.contextTypes,L=(N=N!=null)?Ui(c,E):_a),h=new h(y,L),c.memoizedState=h.state!==null&&h.state!==void 0?h.state:null,h.updater=Sh,c.stateNode=h,h._reactInternals=c,N&&(c=c.stateNode,c.__reactInternalMemoizedUnmaskedChildContext=E,c.__reactInternalMemoizedMaskedChildContext=L),h}function t_(c,h,y,N){c=h.state,typeof h.componentWillReceiveProps=="function"&&h.componentWillReceiveProps(y,N),typeof h.UNSAFE_componentWillReceiveProps=="function"&&h.UNSAFE_componentWillReceiveProps(y,N),h.state!==c&&Sh.enqueueReplaceState(h,h.state,null)}function ey(c,h,y,N){var E=c.stateNode;E.props=y,E.state=c.memoizedState,E.refs={},Bg(c);var L=h.contextType;typeof L=="object"&&L!==null?E.context=ls(L):(L=$n(h)?Eo:wn.current,E.context=Ui(c,L)),E.state=c.memoizedState,L=h.getDerivedStateFromProps,typeof L=="function"&&(Qg(c,h,L,y),E.state=c.memoizedState),typeof h.getDerivedStateFromProps=="function"||typeof E.getSnapshotBeforeUpdate=="function"||typeof E.UNSAFE_componentWillMount!="function"&&typeof E.componentWillMount!="function"||(h=E.state,typeof E.componentWillMount=="function"&&E.componentWillMount(),typeof E.UNSAFE_componentWillMount=="function"&&E.UNSAFE_componentWillMount(),h!==E.state&&Sh.enqueueReplaceState(E,E.state,null),wh(c,y,E,N),E.state=c.memoizedState),typeof E.componentDidMount=="function"&&(c.flags|=4194308)}function Xi(c,h){try{var y="",N=h;do y+=X(N),N=N.return;while(N);var E=y}catch(L){E=`
|
|
39
|
+
Error generating stack: `+L.message+`
|
|
40
|
+
`+L.stack}return{value:c,source:h,stack:E,digest:null}}function ty(c,h,y){return{value:c,source:null,stack:y??null,digest:h??null}}function ny(c,h){try{console.error(h.value)}catch(y){setTimeout(function(){throw y})}}var QB=typeof WeakMap=="function"?WeakMap:Map;function n_(c,h,y){y=Vr(-1,y),y.tag=3,y.payload={element:null};var N=h.value;return y.callback=function(){Mh||(Mh=!0,yy=N),ny(c,h)},y}function s_(c,h,y){y=Vr(-1,y),y.tag=3;var N=c.type.getDerivedStateFromError;if(typeof N=="function"){var E=h.value;y.payload=function(){return N(E)},y.callback=function(){ny(c,h)}}var L=c.stateNode;return L!==null&&typeof L.componentDidCatch=="function"&&(y.callback=function(){ny(c,h),typeof N!="function"&&(Ma===null?Ma=new Set([this]):Ma.add(this));var G=h.stack;this.componentDidCatch(h.value,{componentStack:G!==null?G:""})}),y}function r_(c,h,y){var N=c.pingCache;if(N===null){N=c.pingCache=new QB;var E=new Set;N.set(h,E)}else E=N.get(h),E===void 0&&(E=new Set,N.set(h,E));E.has(y)||(E.add(y),c=fq.bind(null,c,h,y),h.then(c,c))}function a_(c){do{var h;if((h=c.tag===13)&&(h=c.memoizedState,h=h!==null?h.dehydrated!==null:!0),h)return c;c=c.return}while(c!==null);return null}function o_(c,h,y,N,E){return(c.mode&1)===0?(c===h?c.flags|=65536:(c.flags|=128,y.flags|=131072,y.flags&=-52805,y.tag===1&&(y.alternate===null?y.tag=17:(h=Vr(-1,1),h.tag=2,Aa(y,h,1))),y.lanes|=1),c):(c.flags|=65536,c.lanes=E,c)}var eq=C.ReactCurrentOwner,Ln=!1;function jn(c,h,y,N){h.child=c===null?CC(h,null,y,N):Vi(h,c.child,y,N)}function i_(c,h,y,N,E){y=y.render;var L=h.ref;return Ki(h,E),N=Gg(c,h,y,N,L,E),y=Kg(),c!==null&&!Ln?(h.updateQueue=c.updateQueue,h.flags&=-2053,c.lanes&=~E,Gr(c,h,E)):(At&&y&&Ag(h),h.flags|=1,jn(c,h,N,E),h.child)}function l_(c,h,y,N,E){if(c===null){var L=y.type;return typeof L=="function"&&!Ny(L)&&L.defaultProps===void 0&&y.compare===null&&y.defaultProps===void 0?(h.tag=15,h.type=L,c_(c,h,L,N,E)):(c=Dh(y.type,null,N,h,h.mode,E),c.ref=h.ref,c.return=h,h.child=c)}if(L=c.child,(c.lanes&E)===0){var G=L.memoizedProps;if(y=y.compare,y=y!==null?y:Lc,y(G,N)&&c.ref===h.ref)return Gr(c,h,E)}return h.flags|=1,c=Oa(L,N),c.ref=h.ref,c.return=h,h.child=c}function c_(c,h,y,N,E){if(c!==null){var L=c.memoizedProps;if(Lc(L,N)&&c.ref===h.ref)if(Ln=!1,h.pendingProps=N=L,(c.lanes&E)!==0)(c.flags&131072)!==0&&(Ln=!0);else return h.lanes=c.lanes,Gr(c,h,E)}return sy(c,h,y,N,E)}function u_(c,h,y){var N=h.pendingProps,E=N.children,L=c!==null?c.memoizedState:null;if(N.mode==="hidden")if((h.mode&1)===0)h.memoizedState={baseLanes:0,cachePool:null,transitions:null},Nt(Ji,Yn),Yn|=y;else{if((y&1073741824)===0)return c=L!==null?L.baseLanes|y:y,h.lanes=h.childLanes=1073741824,h.memoizedState={baseLanes:c,cachePool:null,transitions:null},h.updateQueue=null,Nt(Ji,Yn),Yn|=c,null;h.memoizedState={baseLanes:0,cachePool:null,transitions:null},N=L!==null?L.baseLanes:y,Nt(Ji,Yn),Yn|=N}else L!==null?(N=L.baseLanes|y,h.memoizedState=null):N=y,Nt(Ji,Yn),Yn|=N;return jn(c,h,E,y),h.child}function d_(c,h){var y=h.ref;(c===null&&y!==null||c!==null&&c.ref!==y)&&(h.flags|=512,h.flags|=2097152)}function sy(c,h,y,N,E){var L=$n(y)?Eo:wn.current;return L=Ui(h,L),Ki(h,E),y=Gg(c,h,y,N,L,E),N=Kg(),c!==null&&!Ln?(h.updateQueue=c.updateQueue,h.flags&=-2053,c.lanes&=~E,Gr(c,h,E)):(At&&N&&Ag(h),h.flags|=1,jn(c,h,y,E),h.child)}function h_(c,h,y,N,E){if($n(y)){var L=!0;ch(h)}else L=!1;if(Ki(h,E),h.stateNode===null)_h(c,h),e_(h,y,N),ey(h,y,N,E),N=!0;else if(c===null){var G=h.stateNode,ee=h.memoizedProps;G.props=ee;var ne=G.context,ue=y.contextType;typeof ue=="object"&&ue!==null?ue=ls(ue):(ue=$n(y)?Eo:wn.current,ue=Ui(h,ue));var Se=y.getDerivedStateFromProps,Ce=typeof Se=="function"||typeof G.getSnapshotBeforeUpdate=="function";Ce||typeof G.UNSAFE_componentWillReceiveProps!="function"&&typeof G.componentWillReceiveProps!="function"||(ee!==N||ne!==ue)&&t_(h,G,N,ue),Ta=!1;var Ne=h.memoizedState;G.state=Ne,wh(h,N,G,E),ne=h.memoizedState,ee!==N||Ne!==ne||Mn.current||Ta?(typeof Se=="function"&&(Qg(h,y,Se,N),ne=h.memoizedState),(ee=Ta||QC(h,y,ee,N,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"&&(h.flags|=4194308)):(typeof G.componentDidMount=="function"&&(h.flags|=4194308),h.memoizedProps=N,h.memoizedState=ne),G.props=N,G.state=ne,G.context=ue,N=ee):(typeof G.componentDidMount=="function"&&(h.flags|=4194308),N=!1)}else{G=h.stateNode,EC(c,h),ee=h.memoizedProps,ue=h.type===h.elementType?ee:Fs(h.type,ee),G.props=ue,Ce=h.pendingProps,Ne=G.context,ne=y.contextType,typeof ne=="object"&&ne!==null?ne=ls(ne):(ne=$n(y)?Eo:wn.current,ne=Ui(h,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)&&t_(h,G,N,ne),Ta=!1,Ne=h.memoizedState,G.state=Ne,wh(h,N,G,E);var qe=h.memoizedState;ee!==Ce||Ne!==qe||Mn.current||Ta?(typeof Pe=="function"&&(Qg(h,y,Pe,N),qe=h.memoizedState),(ue=Ta||QC(h,y,ue,N,Ne,qe,ne)||!1)?(Se||typeof G.UNSAFE_componentWillUpdate!="function"&&typeof G.componentWillUpdate!="function"||(typeof G.componentWillUpdate=="function"&&G.componentWillUpdate(N,qe,ne),typeof G.UNSAFE_componentWillUpdate=="function"&&G.UNSAFE_componentWillUpdate(N,qe,ne)),typeof G.componentDidUpdate=="function"&&(h.flags|=4),typeof G.getSnapshotBeforeUpdate=="function"&&(h.flags|=1024)):(typeof G.componentDidUpdate!="function"||ee===c.memoizedProps&&Ne===c.memoizedState||(h.flags|=4),typeof G.getSnapshotBeforeUpdate!="function"||ee===c.memoizedProps&&Ne===c.memoizedState||(h.flags|=1024),h.memoizedProps=N,h.memoizedState=qe),G.props=N,G.state=qe,G.context=ne,N=ue):(typeof G.componentDidUpdate!="function"||ee===c.memoizedProps&&Ne===c.memoizedState||(h.flags|=4),typeof G.getSnapshotBeforeUpdate!="function"||ee===c.memoizedProps&&Ne===c.memoizedState||(h.flags|=1024),N=!1)}return ry(c,h,y,N,L,E)}function ry(c,h,y,N,E,L){d_(c,h);var G=(h.flags&128)!==0;if(!N&&!G)return E&&yC(h,y,!1),Gr(c,h,L);N=h.stateNode,eq.current=h;var ee=G&&typeof y.getDerivedStateFromError!="function"?null:N.render();return h.flags|=1,c!==null&&G?(h.child=Vi(h,c.child,null,L),h.child=Vi(h,null,ee,L)):jn(c,h,ee,L),h.memoizedState=N.state,E&&yC(h,y,!0),h.child}function f_(c){var h=c.stateNode;h.pendingContext?mC(c,h.pendingContext,h.pendingContext!==h.context):h.context&&mC(c,h.context,!1),qg(c,h.containerInfo)}function p_(c,h,y,N,E){return zi(),Lg(E),h.flags|=256,jn(c,h,y,N),h.child}var ay={dehydrated:null,treeContext:null,retryLane:0};function oy(c){return{baseLanes:c,cachePool:null,transitions:null}}function m_(c,h,y){var N=h.pendingProps,E=It.current,L=!1,G=(h.flags&128)!==0,ee;if((ee=G)||(ee=c!==null&&c.memoizedState===null?!1:(E&2)!==0),ee?(L=!0,h.flags&=-129):(c===null||c.memoizedState!==null)&&(E|=1),Nt(It,E&1),c===null)return $g(h),c=h.memoizedState,c!==null&&(c=c.dehydrated,c!==null)?((h.mode&1)===0?h.lanes=1:c.data==="$!"?h.lanes=8:h.lanes=1073741824,null):(G=N.children,c=N.fallback,L?(N=h.mode,L=h.child,G={mode:"hidden",children:G},(N&1)===0&&L!==null?(L.childLanes=0,L.pendingProps=G):L=Fh(G,N,0,null),c=Do(c,N,y,null),L.return=h,c.return=h,L.sibling=c,h.child=L,h.child.memoizedState=oy(y),h.memoizedState=ay,c):iy(h,G));if(E=c.memoizedState,E!==null&&(ee=E.dehydrated,ee!==null))return tq(c,h,G,N,ee,E,y);if(L){L=N.fallback,G=h.mode,E=c.child,ee=E.sibling;var ne={mode:"hidden",children:N.children};return(G&1)===0&&h.child!==E?(N=h.child,N.childLanes=0,N.pendingProps=ne,h.deletions=null):(N=Oa(E,ne),N.subtreeFlags=E.subtreeFlags&14680064),ee!==null?L=Oa(ee,L):(L=Do(L,G,y,null),L.flags|=2),L.return=h,N.return=h,N.sibling=L,h.child=N,N=L,L=h.child,G=c.child.memoizedState,G=G===null?oy(y):{baseLanes:G.baseLanes|y,cachePool:null,transitions:G.transitions},L.memoizedState=G,L.childLanes=c.childLanes&~y,h.memoizedState=ay,N}return L=c.child,c=L.sibling,N=Oa(L,{mode:"visible",children:N.children}),(h.mode&1)===0&&(N.lanes=y),N.return=h,N.sibling=null,c!==null&&(y=h.deletions,y===null?(h.deletions=[c],h.flags|=16):y.push(c)),h.child=N,h.memoizedState=null,N}function iy(c,h){return h=Fh({mode:"visible",children:h},c.mode,0,null),h.return=c,c.child=h}function Ch(c,h,y,N){return N!==null&&Lg(N),Vi(h,c.child,null,y),c=iy(h,h.pendingProps.children),c.flags|=2,h.memoizedState=null,c}function tq(c,h,y,N,E,L,G){if(y)return h.flags&256?(h.flags&=-257,N=ty(Error(n(422))),Ch(c,h,G,N)):h.memoizedState!==null?(h.child=c.child,h.flags|=128,null):(L=N.fallback,E=h.mode,N=Fh({mode:"visible",children:N.children},E,0,null),L=Do(L,E,G,null),L.flags|=2,N.return=h,L.return=h,N.sibling=L,h.child=N,(h.mode&1)!==0&&Vi(h,c.child,null,G),h.child.memoizedState=oy(G),h.memoizedState=ay,L);if((h.mode&1)===0)return Ch(c,h,G,null);if(E.data==="$!"){if(N=E.nextSibling&&E.nextSibling.dataset,N)var ee=N.dgst;return N=ee,L=Error(n(419)),N=ty(L,N,void 0),Ch(c,h,G,N)}if(ee=(G&c.childLanes)!==0,Ln||ee){if(N=an,N!==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&(N.suspendedLanes|G))!==0?0:E,E!==0&&E!==L.retryLane&&(L.retryLane=E,zr(c,E),Us(N,c,E,-1))}return jy(),N=ty(Error(n(421))),Ch(c,h,G,N)}return E.data==="$?"?(h.flags|=128,h.child=c.child,h=pq.bind(null,c),E._reactRetry=h,null):(c=L.treeContext,Kn=Sa(E.nextSibling),Gn=h,At=!0,Ds=null,c!==null&&(os[is++]=Wr,os[is++]=Hr,os[is++]=To,Wr=c.id,Hr=c.overflow,To=h),h=iy(h,N.children),h.flags|=4096,h)}function g_(c,h,y){c.lanes|=h;var N=c.alternate;N!==null&&(N.lanes|=h),Dg(c.return,h,y)}function ly(c,h,y,N,E){var L=c.memoizedState;L===null?c.memoizedState={isBackwards:h,rendering:null,renderingStartTime:0,last:N,tail:y,tailMode:E}:(L.isBackwards=h,L.rendering=null,L.renderingStartTime=0,L.last=N,L.tail=y,L.tailMode=E)}function y_(c,h,y){var N=h.pendingProps,E=N.revealOrder,L=N.tail;if(jn(c,h,N.children,y),N=It.current,(N&2)!==0)N=N&1|2,h.flags|=128;else{if(c!==null&&(c.flags&128)!==0)e:for(c=h.child;c!==null;){if(c.tag===13)c.memoizedState!==null&&g_(c,y,h);else if(c.tag===19)g_(c,y,h);else if(c.child!==null){c.child.return=c,c=c.child;continue}if(c===h)break e;for(;c.sibling===null;){if(c.return===null||c.return===h)break e;c=c.return}c.sibling.return=c.return,c=c.sibling}N&=1}if(Nt(It,N),(h.mode&1)===0)h.memoizedState=null;else switch(E){case"forwards":for(y=h.child,E=null;y!==null;)c=y.alternate,c!==null&&xh(c)===null&&(E=y),y=y.sibling;y=E,y===null?(E=h.child,h.child=null):(E=y.sibling,y.sibling=null),ly(h,!1,E,y,L);break;case"backwards":for(y=null,E=h.child,h.child=null;E!==null;){if(c=E.alternate,c!==null&&xh(c)===null){h.child=E;break}c=E.sibling,E.sibling=y,y=E,E=c}ly(h,!0,y,null,L);break;case"together":ly(h,!1,null,null,void 0);break;default:h.memoizedState=null}return h.child}function _h(c,h){(h.mode&1)===0&&c!==null&&(c.alternate=null,h.alternate=null,h.flags|=2)}function Gr(c,h,y){if(c!==null&&(h.dependencies=c.dependencies),Lo|=h.lanes,(y&h.childLanes)===0)return null;if(c!==null&&h.child!==c.child)throw Error(n(153));if(h.child!==null){for(c=h.child,y=Oa(c,c.pendingProps),h.child=y,y.return=h;c.sibling!==null;)c=c.sibling,y=y.sibling=Oa(c,c.pendingProps),y.return=h;y.sibling=null}return h.child}function nq(c,h,y){switch(h.tag){case 3:f_(h),zi();break;case 5:RC(h);break;case 1:$n(h.type)&&ch(h);break;case 4:qg(h,h.stateNode.containerInfo);break;case 10:var N=h.type._context,E=h.memoizedProps.value;Nt(mh,N._currentValue),N._currentValue=E;break;case 13:if(N=h.memoizedState,N!==null)return N.dehydrated!==null?(Nt(It,It.current&1),h.flags|=128,null):(y&h.child.childLanes)!==0?m_(c,h,y):(Nt(It,It.current&1),c=Gr(c,h,y),c!==null?c.sibling:null);Nt(It,It.current&1);break;case 19:if(N=(y&h.childLanes)!==0,(c.flags&128)!==0){if(N)return y_(c,h,y);h.flags|=128}if(E=h.memoizedState,E!==null&&(E.rendering=null,E.tail=null,E.lastEffect=null),Nt(It,It.current),N)break;return null;case 22:case 23:return h.lanes=0,u_(c,h,y)}return Gr(c,h,y)}var w_,cy,x_,v_;w_=function(c,h){for(var y=h.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===h)break;for(;y.sibling===null;){if(y.return===null||y.return===h)return;y=y.return}y.sibling.return=y.return,y=y.sibling}},cy=function(){},x_=function(c,h,y,N){var E=c.memoizedProps;if(E!==N){c=h.stateNode,Mo(lr.current);var L=null;switch(y){case"input":E=he(c,E),N=he(c,N),L=[];break;case"select":E=D({},E,{value:void 0}),N=D({},N,{value:void 0}),L=[];break;case"textarea":E=Ie(c,E),N=Ie(c,N),L=[];break;default:typeof E.onClick!="function"&&typeof N.onClick=="function"&&(c.onclick=oh)}ve(y,N);var G;y=null;for(ue in E)if(!N.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 N){var ne=N[ue];if(ee=E!=null?E[ue]:void 0,N.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"&&_t("scroll",c),L||ee===ne||(L=[])):(L=L||[]).push(ue,ne))}y&&(L=L||[]).push("style",y);var ue=L;(h.updateQueue=ue)&&(h.flags|=4)}},v_=function(c,h,y,N){y!==N&&(h.flags|=4)};function Yc(c,h){if(!At)switch(c.tailMode){case"hidden":h=c.tail;for(var y=null;h!==null;)h.alternate!==null&&(y=h),h=h.sibling;y===null?c.tail=null:y.sibling=null;break;case"collapsed":y=c.tail;for(var N=null;y!==null;)y.alternate!==null&&(N=y),y=y.sibling;N===null?h||c.tail===null?c.tail=null:c.tail.sibling=null:N.sibling=null}}function vn(c){var h=c.alternate!==null&&c.alternate.child===c.child,y=0,N=0;if(h)for(var E=c.child;E!==null;)y|=E.lanes|E.childLanes,N|=E.subtreeFlags&14680064,N|=E.flags&14680064,E.return=c,E=E.sibling;else for(E=c.child;E!==null;)y|=E.lanes|E.childLanes,N|=E.subtreeFlags,N|=E.flags,E.return=c,E=E.sibling;return c.subtreeFlags|=N,c.childLanes=y,h}function sq(c,h,y){var N=h.pendingProps;switch(Rg(h),h.tag){case 2:case 16:case 15:case 0:case 11:case 7:case 8:case 12:case 9:case 14:return vn(h),null;case 1:return $n(h.type)&&lh(),vn(h),null;case 3:return N=h.stateNode,Yi(),Et(Mn),Et(wn),Hg(),N.pendingContext&&(N.context=N.pendingContext,N.pendingContext=null),(c===null||c.child===null)&&(fh(h)?h.flags|=4:c===null||c.memoizedState.isDehydrated&&(h.flags&256)===0||(h.flags|=1024,Ds!==null&&(vy(Ds),Ds=null))),cy(c,h),vn(h),null;case 5:Ug(h);var E=Mo(Hc.current);if(y=h.type,c!==null&&h.stateNode!=null)x_(c,h,y,N,E),c.ref!==h.ref&&(h.flags|=512,h.flags|=2097152);else{if(!N){if(h.stateNode===null)throw Error(n(166));return vn(h),null}if(c=Mo(lr.current),fh(h)){N=h.stateNode,y=h.type;var L=h.memoizedProps;switch(N[ir]=h,N[Fc]=L,c=(h.mode&1)!==0,y){case"dialog":_t("cancel",N),_t("close",N);break;case"iframe":case"object":case"embed":_t("load",N);break;case"video":case"audio":for(E=0;E<Oc.length;E++)_t(Oc[E],N);break;case"source":_t("error",N);break;case"img":case"image":case"link":_t("error",N),_t("load",N);break;case"details":_t("toggle",N);break;case"input":fe(N,L),_t("invalid",N);break;case"select":N._wrapperState={wasMultiple:!!L.multiple},_t("invalid",N);break;case"textarea":De(N,L),_t("invalid",N)}ve(y,L),E=null;for(var G in L)if(L.hasOwnProperty(G)){var ee=L[G];G==="children"?typeof ee=="string"?N.textContent!==ee&&(L.suppressHydrationWarning!==!0&&ah(N.textContent,ee,c),E=["children",ee]):typeof ee=="number"&&N.textContent!==""+ee&&(L.suppressHydrationWarning!==!0&&ah(N.textContent,ee,c),E=["children",""+ee]):a.hasOwnProperty(G)&&ee!=null&&G==="onScroll"&&_t("scroll",N)}switch(y){case"input":de(N),ge(N,L,!0);break;case"textarea":de(N),Ke(N);break;case"select":case"option":break;default:typeof L.onClick=="function"&&(N.onclick=oh)}N=E,h.updateQueue=N,N!==null&&(h.flags|=4)}else{G=E.nodeType===9?E:E.ownerDocument,c==="http://www.w3.org/1999/xhtml"&&(c=we(y)),c==="http://www.w3.org/1999/xhtml"?y==="script"?(c=G.createElement("div"),c.innerHTML="<script><\/script>",c=c.removeChild(c.firstChild)):typeof N.is=="string"?c=G.createElement(y,{is:N.is}):(c=G.createElement(y),y==="select"&&(G=c,N.multiple?G.multiple=!0:N.size&&(G.size=N.size))):c=G.createElementNS(c,y),c[ir]=h,c[Fc]=N,w_(c,h,!1,!1),h.stateNode=c;e:{switch(G=pe(y,N),y){case"dialog":_t("cancel",c),_t("close",c),E=N;break;case"iframe":case"object":case"embed":_t("load",c),E=N;break;case"video":case"audio":for(E=0;E<Oc.length;E++)_t(Oc[E],c);E=N;break;case"source":_t("error",c),E=N;break;case"img":case"image":case"link":_t("error",c),_t("load",c),E=N;break;case"details":_t("toggle",c),E=N;break;case"input":fe(c,N),E=he(c,N),_t("invalid",c);break;case"option":E=N;break;case"select":c._wrapperState={wasMultiple:!!N.multiple},E=D({},N,{value:void 0}),_t("invalid",c);break;case"textarea":De(c,N),E=Ie(c,N),_t("invalid",c);break;default:E=N}ve(y,E),ee=E;for(L in ee)if(ee.hasOwnProperty(L)){var ne=ee[L];L==="style"?Te(c,ne):L==="dangerouslySetInnerHTML"?(ne=ne?ne.__html:void 0,ne!=null&&Ae(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"&&_t("scroll",c):ne!=null&&S(c,L,ne,G))}switch(y){case"input":de(c),ge(c,N,!1);break;case"textarea":de(c),Ke(c);break;case"option":N.value!=null&&c.setAttribute("value",""+Q(N.value));break;case"select":c.multiple=!!N.multiple,L=N.value,L!=null?ke(c,!!N.multiple,L,!1):N.defaultValue!=null&&ke(c,!!N.multiple,N.defaultValue,!0);break;default:typeof E.onClick=="function"&&(c.onclick=oh)}switch(y){case"button":case"input":case"select":case"textarea":N=!!N.autoFocus;break e;case"img":N=!0;break e;default:N=!1}}N&&(h.flags|=4)}h.ref!==null&&(h.flags|=512,h.flags|=2097152)}return vn(h),null;case 6:if(c&&h.stateNode!=null)v_(c,h,c.memoizedProps,N);else{if(typeof N!="string"&&h.stateNode===null)throw Error(n(166));if(y=Mo(Hc.current),Mo(lr.current),fh(h)){if(N=h.stateNode,y=h.memoizedProps,N[ir]=h,(L=N.nodeValue!==y)&&(c=Gn,c!==null))switch(c.tag){case 3:ah(N.nodeValue,y,(c.mode&1)!==0);break;case 5:c.memoizedProps.suppressHydrationWarning!==!0&&ah(N.nodeValue,y,(c.mode&1)!==0)}L&&(h.flags|=4)}else N=(y.nodeType===9?y:y.ownerDocument).createTextNode(N),N[ir]=h,h.stateNode=N}return vn(h),null;case 13:if(Et(It),N=h.memoizedState,c===null||c.memoizedState!==null&&c.memoizedState.dehydrated!==null){if(At&&Kn!==null&&(h.mode&1)!==0&&(h.flags&128)===0)jC(),zi(),h.flags|=98560,L=!1;else if(L=fh(h),N!==null&&N.dehydrated!==null){if(c===null){if(!L)throw Error(n(318));if(L=h.memoizedState,L=L!==null?L.dehydrated:null,!L)throw Error(n(317));L[ir]=h}else zi(),(h.flags&128)===0&&(h.memoizedState=null),h.flags|=4;vn(h),L=!1}else Ds!==null&&(vy(Ds),Ds=null),L=!0;if(!L)return h.flags&65536?h:null}return(h.flags&128)!==0?(h.lanes=y,h):(N=N!==null,N!==(c!==null&&c.memoizedState!==null)&&N&&(h.child.flags|=8192,(h.mode&1)!==0&&(c===null||(It.current&1)!==0?Jt===0&&(Jt=3):jy())),h.updateQueue!==null&&(h.flags|=4),vn(h),null);case 4:return Yi(),cy(c,h),c===null&&Pc(h.stateNode.containerInfo),vn(h),null;case 10:return Pg(h.type._context),vn(h),null;case 17:return $n(h.type)&&lh(),vn(h),null;case 19:if(Et(It),L=h.memoizedState,L===null)return vn(h),null;if(N=(h.flags&128)!==0,G=L.rendering,G===null)if(N)Yc(L,!1);else{if(Jt!==0||c!==null&&(c.flags&128)!==0)for(c=h.child;c!==null;){if(G=xh(c),G!==null){for(h.flags|=128,Yc(L,!1),N=G.updateQueue,N!==null&&(h.updateQueue=N,h.flags|=4),h.subtreeFlags=0,N=y,y=h.child;y!==null;)L=y,c=N,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 Nt(It,It.current&1|2),h.child}c=c.sibling}L.tail!==null&&yt()>Qi&&(h.flags|=128,N=!0,Yc(L,!1),h.lanes=4194304)}else{if(!N)if(c=xh(G),c!==null){if(h.flags|=128,N=!0,y=c.updateQueue,y!==null&&(h.updateQueue=y,h.flags|=4),Yc(L,!0),L.tail===null&&L.tailMode==="hidden"&&!G.alternate&&!At)return vn(h),null}else 2*yt()-L.renderingStartTime>Qi&&y!==1073741824&&(h.flags|=128,N=!0,Yc(L,!1),h.lanes=4194304);L.isBackwards?(G.sibling=h.child,h.child=G):(y=L.last,y!==null?y.sibling=G:h.child=G,L.last=G)}return L.tail!==null?(h=L.tail,L.rendering=h,L.tail=h.sibling,L.renderingStartTime=yt(),h.sibling=null,y=It.current,Nt(It,N?y&1|2:y&1),h):(vn(h),null);case 22:case 23:return ky(),N=h.memoizedState!==null,c!==null&&c.memoizedState!==null!==N&&(h.flags|=8192),N&&(h.mode&1)!==0?(Yn&1073741824)!==0&&(vn(h),h.subtreeFlags&6&&(h.flags|=8192)):vn(h),null;case 24:return null;case 25:return null}throw Error(n(156,h.tag))}function rq(c,h){switch(Rg(h),h.tag){case 1:return $n(h.type)&&lh(),c=h.flags,c&65536?(h.flags=c&-65537|128,h):null;case 3:return Yi(),Et(Mn),Et(wn),Hg(),c=h.flags,(c&65536)!==0&&(c&128)===0?(h.flags=c&-65537|128,h):null;case 5:return Ug(h),null;case 13:if(Et(It),c=h.memoizedState,c!==null&&c.dehydrated!==null){if(h.alternate===null)throw Error(n(340));zi()}return c=h.flags,c&65536?(h.flags=c&-65537|128,h):null;case 19:return Et(It),null;case 4:return Yi(),null;case 10:return Pg(h.type._context),null;case 22:case 23:return ky(),null;case 24:return null;default:return null}}var Eh=!1,bn=!1,aq=typeof WeakSet=="function"?WeakSet:Set,Be=null;function Zi(c,h){var y=c.ref;if(y!==null)if(typeof y=="function")try{y(null)}catch(N){Dt(c,h,N)}else y.current=null}function uy(c,h,y){try{y()}catch(N){Dt(c,h,N)}}var b_=!1;function oq(c,h){if(kg=xo,c=QS(),pg(c)){if("selectionStart"in c)var y={start:c.selectionStart,end:c.selectionEnd};else e:{y=(y=c.ownerDocument)&&y.defaultView||window;var N=y.getSelection&&y.getSelection();if(N&&N.rangeCount!==0){y=N.anchorNode;var E=N.anchorOffset,L=N.focusNode;N=N.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||N!==0&&Ce.nodeType!==3||(ne=G+N),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===N&&(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(jg={focusedElem:c,selectionRange:y},xo=!1,Be=h;Be!==null;)if(h=Be,c=h.child,(h.subtreeFlags&1028)!==0&&c!==null)c.return=h,Be=c;else for(;Be!==null;){h=Be;try{var qe=h.alternate;if((h.flags&1024)!==0)switch(h.tag){case 0:case 11:case 15:break;case 1:if(qe!==null){var He=qe.memoizedProps,Wt=qe.memoizedState,ie=h.stateNode,ae=ie.getSnapshotBeforeUpdate(h.elementType===h.type?He:Fs(h.type,He),Wt);ie.__reactInternalSnapshotBeforeUpdate=ae}break;case 3:var ce=h.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(Ee){Dt(h,h.return,Ee)}if(c=h.sibling,c!==null){c.return=h.return,Be=c;break}Be=h.return}return qe=b_,b_=!1,qe}function Xc(c,h,y){var N=h.updateQueue;if(N=N!==null?N.lastEffect:null,N!==null){var E=N=N.next;do{if((E.tag&c)===c){var L=E.destroy;E.destroy=void 0,L!==void 0&&uy(h,y,L)}E=E.next}while(E!==N)}}function Th(c,h){if(h=h.updateQueue,h=h!==null?h.lastEffect:null,h!==null){var y=h=h.next;do{if((y.tag&c)===c){var N=y.create;y.destroy=N()}y=y.next}while(y!==h)}}function dy(c){var h=c.ref;if(h!==null){var y=c.stateNode;switch(c.tag){case 5:c=y;break;default:c=y}typeof h=="function"?h(c):h.current=c}}function k_(c){var h=c.alternate;h!==null&&(c.alternate=null,k_(h)),c.child=null,c.deletions=null,c.sibling=null,c.tag===5&&(h=c.stateNode,h!==null&&(delete h[ir],delete h[Fc],delete h[_g],delete h[UB],delete h[WB])),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 j_(c){return c.tag===5||c.tag===3||c.tag===4}function N_(c){e:for(;;){for(;c.sibling===null;){if(c.return===null||j_(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 hy(c,h,y){var N=c.tag;if(N===5||N===6)c=c.stateNode,h?y.nodeType===8?y.parentNode.insertBefore(c,h):y.insertBefore(c,h):(y.nodeType===8?(h=y.parentNode,h.insertBefore(c,y)):(h=y,h.appendChild(c)),y=y._reactRootContainer,y!=null||h.onclick!==null||(h.onclick=oh));else if(N!==4&&(c=c.child,c!==null))for(hy(c,h,y),c=c.sibling;c!==null;)hy(c,h,y),c=c.sibling}function fy(c,h,y){var N=c.tag;if(N===5||N===6)c=c.stateNode,h?y.insertBefore(c,h):y.appendChild(c);else if(N!==4&&(c=c.child,c!==null))for(fy(c,h,y),c=c.sibling;c!==null;)fy(c,h,y),c=c.sibling}var fn=null,Bs=!1;function Ra(c,h,y){for(y=y.child;y!==null;)S_(c,h,y),y=y.sibling}function S_(c,h,y){if(dn&&typeof dn.onCommitFiberUnmount=="function")try{dn.onCommitFiberUnmount(Rs,y)}catch{}switch(y.tag){case 5:bn||Zi(y,h);case 6:var N=fn,E=Bs;fn=null,Ra(c,h,y),fn=N,Bs=E,fn!==null&&(Bs?(c=fn,y=y.stateNode,c.nodeType===8?c.parentNode.removeChild(y):c.removeChild(y)):fn.removeChild(y.stateNode));break;case 18:fn!==null&&(Bs?(c=fn,y=y.stateNode,c.nodeType===8?Cg(c.parentNode,y):c.nodeType===1&&Cg(c,y),wo(c)):Cg(fn,y.stateNode));break;case 4:N=fn,E=Bs,fn=y.stateNode.containerInfo,Bs=!0,Ra(c,h,y),fn=N,Bs=E;break;case 0:case 11:case 14:case 15:if(!bn&&(N=y.updateQueue,N!==null&&(N=N.lastEffect,N!==null))){E=N=N.next;do{var L=E,G=L.destroy;L=L.tag,G!==void 0&&((L&2)!==0||(L&4)!==0)&&uy(y,h,G),E=E.next}while(E!==N)}Ra(c,h,y);break;case 1:if(!bn&&(Zi(y,h),N=y.stateNode,typeof N.componentWillUnmount=="function"))try{N.props=y.memoizedProps,N.state=y.memoizedState,N.componentWillUnmount()}catch(ee){Dt(y,h,ee)}Ra(c,h,y);break;case 21:Ra(c,h,y);break;case 22:y.mode&1?(bn=(N=bn)||y.memoizedState!==null,Ra(c,h,y),bn=N):Ra(c,h,y);break;default:Ra(c,h,y)}}function C_(c){var h=c.updateQueue;if(h!==null){c.updateQueue=null;var y=c.stateNode;y===null&&(y=c.stateNode=new aq),h.forEach(function(N){var E=mq.bind(null,c,N);y.has(N)||(y.add(N),N.then(E,E))})}}function qs(c,h){var y=h.deletions;if(y!==null)for(var N=0;N<y.length;N++){var E=y[N];try{var L=c,G=h,ee=G;e:for(;ee!==null;){switch(ee.tag){case 5:fn=ee.stateNode,Bs=!1;break e;case 3:fn=ee.stateNode.containerInfo,Bs=!0;break e;case 4:fn=ee.stateNode.containerInfo,Bs=!0;break e}ee=ee.return}if(fn===null)throw Error(n(160));S_(L,G,E),fn=null,Bs=!1;var ne=E.alternate;ne!==null&&(ne.return=null),E.return=null}catch(ue){Dt(E,h,ue)}}if(h.subtreeFlags&12854)for(h=h.child;h!==null;)__(h,c),h=h.sibling}function __(c,h){var y=c.alternate,N=c.flags;switch(c.tag){case 0:case 11:case 14:case 15:if(qs(h,c),ur(c),N&4){try{Xc(3,c,c.return),Th(3,c)}catch(He){Dt(c,c.return,He)}try{Xc(5,c,c.return)}catch(He){Dt(c,c.return,He)}}break;case 1:qs(h,c),ur(c),N&512&&y!==null&&Zi(y,y.return);break;case 5:if(qs(h,c),ur(c),N&512&&y!==null&&Zi(y,y.return),c.flags&32){var E=c.stateNode;try{rt(E,"")}catch(He){Dt(c,c.return,He)}}if(N&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&&$e(E,L),pe(ee,G);var ue=pe(ee,L);for(G=0;G<ne.length;G+=2){var Se=ne[G],Ce=ne[G+1];Se==="style"?Te(E,Ce):Se==="dangerouslySetInnerHTML"?Ae(E,Ce):Se==="children"?rt(E,Ce):S(E,Se,Ce,ue)}switch(ee){case"input":ye(E,L);break;case"textarea":Ue(E,L);break;case"select":var Ne=E._wrapperState.wasMultiple;E._wrapperState.wasMultiple=!!L.multiple;var Pe=L.value;Pe!=null?ke(E,!!L.multiple,Pe,!1):Ne!==!!L.multiple&&(L.defaultValue!=null?ke(E,!!L.multiple,L.defaultValue,!0):ke(E,!!L.multiple,L.multiple?[]:"",!1))}E[Fc]=L}catch(He){Dt(c,c.return,He)}}break;case 6:if(qs(h,c),ur(c),N&4){if(c.stateNode===null)throw Error(n(162));E=c.stateNode,L=c.memoizedProps;try{E.nodeValue=L}catch(He){Dt(c,c.return,He)}}break;case 3:if(qs(h,c),ur(c),N&4&&y!==null&&y.memoizedState.isDehydrated)try{wo(h.containerInfo)}catch(He){Dt(c,c.return,He)}break;case 4:qs(h,c),ur(c);break;case 13:qs(h,c),ur(c),E=c.child,E.flags&8192&&(L=E.memoizedState!==null,E.stateNode.isHidden=L,!L||E.alternate!==null&&E.alternate.memoizedState!==null||(gy=yt())),N&4&&C_(c);break;case 22:if(Se=y!==null&&y.memoizedState!==null,c.mode&1?(bn=(ue=bn)||Se,qs(h,c),bn=ue):qs(h,c),ur(c),N&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:Xc(4,Ne,Ne.return);break;case 1:Zi(Ne,Ne.return);var qe=Ne.stateNode;if(typeof qe.componentWillUnmount=="function"){N=Ne,y=Ne.return;try{h=N,qe.props=h.memoizedProps,qe.state=h.memoizedState,qe.componentWillUnmount()}catch(He){Dt(N,y,He)}}break;case 5:Zi(Ne,Ne.return);break;case 22:if(Ne.memoizedState!==null){A_(Ce);continue}}Pe!==null?(Pe.return=Ne,Be=Pe):A_(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=be("display",G))}catch(He){Dt(c,c.return,He)}}}else if(Ce.tag===6){if(Se===null)try{Ce.stateNode.nodeValue=ue?"":Ce.memoizedProps}catch(He){Dt(c,c.return,He)}}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:qs(h,c),ur(c),N&4&&C_(c);break;case 21:break;default:qs(h,c),ur(c)}}function ur(c){var h=c.flags;if(h&2){try{e:{for(var y=c.return;y!==null;){if(j_(y)){var N=y;break e}y=y.return}throw Error(n(160))}switch(N.tag){case 5:var E=N.stateNode;N.flags&32&&(rt(E,""),N.flags&=-33);var L=N_(c);fy(c,L,E);break;case 3:case 4:var G=N.stateNode.containerInfo,ee=N_(c);hy(c,ee,G);break;default:throw Error(n(161))}}catch(ne){Dt(c,c.return,ne)}c.flags&=-3}h&4096&&(c.flags&=-4097)}function iq(c,h,y){Be=c,E_(c)}function E_(c,h,y){for(var N=(c.mode&1)!==0;Be!==null;){var E=Be,L=E.child;if(E.tag===22&&N){var G=E.memoizedState!==null||Eh;if(!G){var ee=E.alternate,ne=ee!==null&&ee.memoizedState!==null||bn;ee=Eh;var ue=bn;if(Eh=G,(bn=ne)&&!ue)for(Be=E;Be!==null;)G=Be,ne=G.child,G.tag===22&&G.memoizedState!==null?R_(E):ne!==null?(ne.return=G,Be=ne):R_(E);for(;L!==null;)Be=L,E_(L),L=L.sibling;Be=E,Eh=ee,bn=ue}T_(c)}else(E.subtreeFlags&8772)!==0&&L!==null?(L.return=E,Be=L):T_(c)}}function T_(c){for(;Be!==null;){var h=Be;if((h.flags&8772)!==0){var y=h.alternate;try{if((h.flags&8772)!==0)switch(h.tag){case 0:case 11:case 15:bn||Th(5,h);break;case 1:var N=h.stateNode;if(h.flags&4&&!bn)if(y===null)N.componentDidMount();else{var E=h.elementType===h.type?y.memoizedProps:Fs(h.type,y.memoizedProps);N.componentDidUpdate(E,y.memoizedState,N.__reactInternalSnapshotBeforeUpdate)}var L=h.updateQueue;L!==null&&AC(h,L,N);break;case 3:var G=h.updateQueue;if(G!==null){if(y=null,h.child!==null)switch(h.child.tag){case 5:y=h.child.stateNode;break;case 1:y=h.child.stateNode}AC(h,G,y)}break;case 5:var ee=h.stateNode;if(y===null&&h.flags&4){y=ee;var ne=h.memoizedProps;switch(h.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(h.memoizedState===null){var ue=h.alternate;if(ue!==null){var Se=ue.memoizedState;if(Se!==null){var Ce=Se.dehydrated;Ce!==null&&wo(Ce)}}}break;case 19:case 17:case 21:case 22:case 23:case 25:break;default:throw Error(n(163))}bn||h.flags&512&&dy(h)}catch(Ne){Dt(h,h.return,Ne)}}if(h===c){Be=null;break}if(y=h.sibling,y!==null){y.return=h.return,Be=y;break}Be=h.return}}function A_(c){for(;Be!==null;){var h=Be;if(h===c){Be=null;break}var y=h.sibling;if(y!==null){y.return=h.return,Be=y;break}Be=h.return}}function R_(c){for(;Be!==null;){var h=Be;try{switch(h.tag){case 0:case 11:case 15:var y=h.return;try{Th(4,h)}catch(ne){Dt(h,y,ne)}break;case 1:var N=h.stateNode;if(typeof N.componentDidMount=="function"){var E=h.return;try{N.componentDidMount()}catch(ne){Dt(h,E,ne)}}var L=h.return;try{dy(h)}catch(ne){Dt(h,L,ne)}break;case 5:var G=h.return;try{dy(h)}catch(ne){Dt(h,G,ne)}}}catch(ne){Dt(h,h.return,ne)}if(h===c){Be=null;break}var ee=h.sibling;if(ee!==null){ee.return=h.return,Be=ee;break}Be=h.return}}var lq=Math.ceil,Ah=C.ReactCurrentDispatcher,py=C.ReactCurrentOwner,us=C.ReactCurrentBatchConfig,ht=0,an=null,Vt=null,pn=0,Yn=0,Ji=Ca(0),Jt=0,Zc=null,Lo=0,Rh=0,my=0,Jc=null,In=null,gy=0,Qi=1/0,Kr=null,Mh=!1,yy=null,Ma=null,$h=!1,$a=null,Lh=0,Qc=0,wy=null,Ih=-1,Oh=0;function Nn(){return(ht&6)!==0?yt():Ih!==-1?Ih:Ih=yt()}function La(c){return(c.mode&1)===0?1:(ht&2)!==0&&pn!==0?pn&-pn:zB.transition!==null?(Oh===0&&(Oh=Dd()),Oh):(c=ct,c!==0||(c=window.event,c=c===void 0?16:bc(c.type)),c)}function Us(c,h,y,N){if(50<Qc)throw Qc=0,wy=null,Error(n(185));rr(c,y,N),((ht&2)===0||c!==an)&&(c===an&&((ht&2)===0&&(Rh|=y),Jt===4&&Ia(c,pn)),On(c,N),y===1&&ht===0&&(h.mode&1)===0&&(Qi=yt()+500,uh&&Ea()))}function On(c,h){var y=c.callbackNode;ki(c,h);var N=$r(c,c===an?pn:0);if(N===0)y!==null&&Ar(y),c.callbackNode=null,c.callbackPriority=0;else if(h=N&-N,c.callbackPriority!==h){if(y!=null&&Ar(y),h===1)c.tag===0?HB($_.bind(null,c)):wC($_.bind(null,c)),BB(function(){(ht&6)===0&&Ea()}),y=null;else{switch(fo(N)){case 1:y=ns;break;case 4:y=xa;break;case 16:y=As;break;case 536870912:y=sr;break;default:y=As}y=q_(y,M_.bind(null,c))}c.callbackPriority=h,c.callbackNode=y}}function M_(c,h){if(Ih=-1,Oh=0,(ht&6)!==0)throw Error(n(327));var y=c.callbackNode;if(el()&&c.callbackNode!==y)return null;var N=$r(c,c===an?pn:0);if(N===0)return null;if((N&30)!==0||(N&c.expiredLanes)!==0||h)h=Ph(c,N);else{h=N;var E=ht;ht|=2;var L=I_();(an!==c||pn!==h)&&(Kr=null,Qi=yt()+500,Oo(c,h));do try{dq();break}catch(ee){L_(c,ee)}while(!0);Og(),Ah.current=L,ht=E,Vt!==null?h=0:(an=null,pn=0,h=Jt)}if(h!==0){if(h===2&&(E=Ms(c),E!==0&&(N=E,h=xy(c,E))),h===1)throw y=Zc,Oo(c,0),Ia(c,N),On(c,yt()),y;if(h===6)Ia(c,N);else{if(E=c.current.alternate,(N&30)===0&&!cq(E)&&(h=Ph(c,N),h===2&&(L=Ms(c),L!==0&&(N=L,h=xy(c,L))),h===1))throw y=Zc,Oo(c,0),Ia(c,N),On(c,yt()),y;switch(c.finishedWork=E,c.finishedLanes=N,h){case 0:case 1:throw Error(n(345));case 2:Po(c,In,Kr);break;case 3:if(Ia(c,N),(N&130023424)===N&&(h=gy+500-yt(),10<h)){if($r(c,0)!==0)break;if(E=c.suspendedLanes,(E&N)!==N){Nn(),c.pingedLanes|=c.suspendedLanes&E;break}c.timeoutHandle=Sg(Po.bind(null,c,In,Kr),h);break}Po(c,In,Kr);break;case 4:if(Ia(c,N),(N&4194240)===N)break;for(h=c.eventTimes,E=-1;0<N;){var G=31-yn(N);L=1<<G,G=h[G],G>E&&(E=G),N&=~L}if(N=E,N=yt()-N,N=(120>N?120:480>N?480:1080>N?1080:1920>N?1920:3e3>N?3e3:4320>N?4320:1960*lq(N/1960))-N,10<N){c.timeoutHandle=Sg(Po.bind(null,c,In,Kr),N);break}Po(c,In,Kr);break;case 5:Po(c,In,Kr);break;default:throw Error(n(329))}}}return On(c,yt()),c.callbackNode===y?M_.bind(null,c):null}function xy(c,h){var y=Jc;return c.current.memoizedState.isDehydrated&&(Oo(c,h).flags|=256),c=Ph(c,h),c!==2&&(h=In,In=y,h!==null&&vy(h)),c}function vy(c){In===null?In=c:In.push.apply(In,c)}function cq(c){for(var h=c;;){if(h.flags&16384){var y=h.updateQueue;if(y!==null&&(y=y.stores,y!==null))for(var N=0;N<y.length;N++){var E=y[N],L=E.getSnapshot;E=E.value;try{if(!Ps(L(),E))return!1}catch{return!1}}}if(y=h.child,h.subtreeFlags&16384&&y!==null)y.return=h,h=y;else{if(h===c)break;for(;h.sibling===null;){if(h.return===null||h.return===c)return!0;h=h.return}h.sibling.return=h.return,h=h.sibling}}return!0}function Ia(c,h){for(h&=~my,h&=~Rh,c.suspendedLanes|=h,c.pingedLanes&=~h,c=c.expirationTimes;0<h;){var y=31-yn(h),N=1<<y;c[y]=-1,h&=~N}}function $_(c){if((ht&6)!==0)throw Error(n(327));el();var h=$r(c,0);if((h&1)===0)return On(c,yt()),null;var y=Ph(c,h);if(c.tag!==0&&y===2){var N=Ms(c);N!==0&&(h=N,y=xy(c,N))}if(y===1)throw y=Zc,Oo(c,0),Ia(c,h),On(c,yt()),y;if(y===6)throw Error(n(345));return c.finishedWork=c.current.alternate,c.finishedLanes=h,Po(c,In,Kr),On(c,yt()),null}function by(c,h){var y=ht;ht|=1;try{return c(h)}finally{ht=y,ht===0&&(Qi=yt()+500,uh&&Ea())}}function Io(c){$a!==null&&$a.tag===0&&(ht&6)===0&&el();var h=ht;ht|=1;var y=us.transition,N=ct;try{if(us.transition=null,ct=1,c)return c()}finally{ct=N,us.transition=y,ht=h,(ht&6)===0&&Ea()}}function ky(){Yn=Ji.current,Et(Ji)}function Oo(c,h){c.finishedWork=null,c.finishedLanes=0;var y=c.timeoutHandle;if(y!==-1&&(c.timeoutHandle=-1,FB(y)),Vt!==null)for(y=Vt.return;y!==null;){var N=y;switch(Rg(N),N.tag){case 1:N=N.type.childContextTypes,N!=null&&lh();break;case 3:Yi(),Et(Mn),Et(wn),Hg();break;case 5:Ug(N);break;case 4:Yi();break;case 13:Et(It);break;case 19:Et(It);break;case 10:Pg(N.type._context);break;case 22:case 23:ky()}y=y.return}if(an=c,Vt=c=Oa(c.current,null),pn=Yn=h,Jt=0,Zc=null,my=Rh=Lo=0,In=Jc=null,Ro!==null){for(h=0;h<Ro.length;h++)if(y=Ro[h],N=y.interleaved,N!==null){y.interleaved=null;var E=N.next,L=y.pending;if(L!==null){var G=L.next;L.next=E,N.next=G}y.pending=N}Ro=null}return c}function L_(c,h){do{var y=Vt;try{if(Og(),vh.current=Nh,bh){for(var N=Ot.memoizedState;N!==null;){var E=N.queue;E!==null&&(E.pending=null),N=N.next}bh=!1}if($o=0,rn=Zt=Ot=null,zc=!1,Vc=0,py.current=null,y===null||y.return===null){Jt=1,Zc=h,Vt=null;break}e:{var L=c,G=y.return,ee=y,ne=h;if(h=pn,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=a_(G);if(Pe!==null){Pe.flags&=-257,o_(Pe,G,ee,L,h),Pe.mode&1&&r_(L,ue,h),h=Pe,ne=ue;var qe=h.updateQueue;if(qe===null){var He=new Set;He.add(ne),h.updateQueue=He}else qe.add(ne);break e}else{if((h&1)===0){r_(L,ue,h),jy();break e}ne=Error(n(426))}}else if(At&&ee.mode&1){var Wt=a_(G);if(Wt!==null){(Wt.flags&65536)===0&&(Wt.flags|=256),o_(Wt,G,ee,L,h),Lg(Xi(ne,ee));break e}}L=ne=Xi(ne,ee),Jt!==4&&(Jt=2),Jc===null?Jc=[L]:Jc.push(L),L=G;do{switch(L.tag){case 3:L.flags|=65536,h&=-h,L.lanes|=h;var ie=n_(L,ne,h);TC(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"&&(Ma===null||!Ma.has(ce)))){L.flags|=65536,h&=-h,L.lanes|=h;var Ee=s_(L,ee,h);TC(L,Ee);break e}}L=L.return}while(L!==null)}P_(y)}catch(Ge){h=Ge,Vt===y&&y!==null&&(Vt=y=y.return);continue}break}while(!0)}function I_(){var c=Ah.current;return Ah.current=Nh,c===null?Nh:c}function jy(){(Jt===0||Jt===3||Jt===2)&&(Jt=4),an===null||(Lo&268435455)===0&&(Rh&268435455)===0||Ia(an,pn)}function Ph(c,h){var y=ht;ht|=2;var N=I_();(an!==c||pn!==h)&&(Kr=null,Oo(c,h));do try{uq();break}catch(E){L_(c,E)}while(!0);if(Og(),ht=y,Ah.current=N,Vt!==null)throw Error(n(261));return an=null,pn=0,Jt}function uq(){for(;Vt!==null;)O_(Vt)}function dq(){for(;Vt!==null&&!Rr();)O_(Vt)}function O_(c){var h=B_(c.alternate,c,Yn);c.memoizedProps=c.pendingProps,h===null?P_(c):Vt=h,py.current=null}function P_(c){var h=c;do{var y=h.alternate;if(c=h.return,(h.flags&32768)===0){if(y=sq(y,h,Yn),y!==null){Vt=y;return}}else{if(y=rq(y,h),y!==null){y.flags&=32767,Vt=y;return}if(c!==null)c.flags|=32768,c.subtreeFlags=0,c.deletions=null;else{Jt=6,Vt=null;return}}if(h=h.sibling,h!==null){Vt=h;return}Vt=h=c}while(h!==null);Jt===0&&(Jt=5)}function Po(c,h,y){var N=ct,E=us.transition;try{us.transition=null,ct=1,hq(c,h,y,N)}finally{us.transition=E,ct=N}return null}function hq(c,h,y,N){do el();while($a!==null);if((ht&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(Xm(c,L),c===an&&(Vt=an=null,pn=0),(y.subtreeFlags&2064)===0&&(y.flags&2064)===0||$h||($h=!0,q_(As,function(){return el(),null})),L=(y.flags&15990)!==0,(y.subtreeFlags&15990)!==0||L){L=us.transition,us.transition=null;var G=ct;ct=1;var ee=ht;ht|=4,py.current=null,oq(c,y),__(y,c),MB(jg),xo=!!kg,jg=kg=null,c.current=y,iq(y),ho(),ht=ee,ct=G,us.transition=L}else c.current=y;if($h&&($h=!1,$a=c,Lh=E),L=c.pendingLanes,L===0&&(Ma=null),$t(y.stateNode),On(c,yt()),h!==null)for(N=c.onRecoverableError,y=0;y<h.length;y++)E=h[y],N(E.value,{componentStack:E.stack,digest:E.digest});if(Mh)throw Mh=!1,c=yy,yy=null,c;return(Lh&1)!==0&&c.tag!==0&&el(),L=c.pendingLanes,(L&1)!==0?c===wy?Qc++:(Qc=0,wy=c):Qc=0,Ea(),null}function el(){if($a!==null){var c=fo(Lh),h=us.transition,y=ct;try{if(us.transition=null,ct=16>c?16:c,$a===null)var N=!1;else{if(c=$a,$a=null,Lh=0,(ht&6)!==0)throw Error(n(331));var E=ht;for(ht|=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:Xc(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(k_(Se),Se===ue){Be=null;break}if(Ne!==null){Ne.return=Pe,Be=Ne;break}Be=Pe}}}var qe=L.alternate;if(qe!==null){var He=qe.child;if(He!==null){qe.child=null;do{var Wt=He.sibling;He.sibling=null,He=Wt}while(He!==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:Xc(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:Th(9,ee)}}catch(Ge){Dt(ee,ee.return,Ge)}if(ee===G){Be=null;break e}var Ee=ee.sibling;if(Ee!==null){Ee.return=ee.return,Be=Ee;break e}Be=ee.return}}if(ht=E,Ea(),dn&&typeof dn.onPostCommitFiberRoot=="function")try{dn.onPostCommitFiberRoot(Rs,c)}catch{}N=!0}return N}finally{ct=y,us.transition=h}}return!1}function D_(c,h,y){h=Xi(y,h),h=n_(c,h,1),c=Aa(c,h,1),h=Nn(),c!==null&&(rr(c,1,h),On(c,h))}function Dt(c,h,y){if(c.tag===3)D_(c,c,y);else for(;h!==null;){if(h.tag===3){D_(h,c,y);break}else if(h.tag===1){var N=h.stateNode;if(typeof h.type.getDerivedStateFromError=="function"||typeof N.componentDidCatch=="function"&&(Ma===null||!Ma.has(N))){c=Xi(y,c),c=s_(h,c,1),h=Aa(h,c,1),c=Nn(),h!==null&&(rr(h,1,c),On(h,c));break}}h=h.return}}function fq(c,h,y){var N=c.pingCache;N!==null&&N.delete(h),h=Nn(),c.pingedLanes|=c.suspendedLanes&y,an===c&&(pn&y)===y&&(Jt===4||Jt===3&&(pn&130023424)===pn&&500>yt()-gy?Oo(c,0):my|=y),On(c,h)}function F_(c,h){h===0&&((c.mode&1)===0?h=1:(h=ss,ss<<=1,(ss&130023424)===0&&(ss=4194304)));var y=Nn();c=zr(c,h),c!==null&&(rr(c,h,y),On(c,y))}function pq(c){var h=c.memoizedState,y=0;h!==null&&(y=h.retryLane),F_(c,y)}function mq(c,h){var y=0;switch(c.tag){case 13:var N=c.stateNode,E=c.memoizedState;E!==null&&(y=E.retryLane);break;case 19:N=c.stateNode;break;default:throw Error(n(314))}N!==null&&N.delete(h),F_(c,y)}var B_;B_=function(c,h,y){if(c!==null)if(c.memoizedProps!==h.pendingProps||Mn.current)Ln=!0;else{if((c.lanes&y)===0&&(h.flags&128)===0)return Ln=!1,nq(c,h,y);Ln=(c.flags&131072)!==0}else Ln=!1,At&&(h.flags&1048576)!==0&&xC(h,hh,h.index);switch(h.lanes=0,h.tag){case 2:var N=h.type;_h(c,h),c=h.pendingProps;var E=Ui(h,wn.current);Ki(h,y),E=Gg(null,h,N,c,E,y);var L=Kg();return h.flags|=1,typeof E=="object"&&E!==null&&typeof E.render=="function"&&E.$$typeof===void 0?(h.tag=1,h.memoizedState=null,h.updateQueue=null,$n(N)?(L=!0,ch(h)):L=!1,h.memoizedState=E.state!==null&&E.state!==void 0?E.state:null,Bg(h),E.updater=Sh,h.stateNode=E,E._reactInternals=h,ey(h,N,c,y),h=ry(null,h,N,!0,L,y)):(h.tag=0,At&&L&&Ag(h),jn(null,h,E,y),h=h.child),h;case 16:N=h.elementType;e:{switch(_h(c,h),c=h.pendingProps,E=N._init,N=E(N._payload),h.type=N,E=h.tag=yq(N),c=Fs(N,c),E){case 0:h=sy(null,h,N,c,y);break e;case 1:h=h_(null,h,N,c,y);break e;case 11:h=i_(null,h,N,c,y);break e;case 14:h=l_(null,h,N,Fs(N.type,c),y);break e}throw Error(n(306,N,""))}return h;case 0:return N=h.type,E=h.pendingProps,E=h.elementType===N?E:Fs(N,E),sy(c,h,N,E,y);case 1:return N=h.type,E=h.pendingProps,E=h.elementType===N?E:Fs(N,E),h_(c,h,N,E,y);case 3:e:{if(f_(h),c===null)throw Error(n(387));N=h.pendingProps,L=h.memoizedState,E=L.element,EC(c,h),wh(h,N,null,y);var G=h.memoizedState;if(N=G.element,L.isDehydrated)if(L={element:N,isDehydrated:!1,cache:G.cache,pendingSuspenseBoundaries:G.pendingSuspenseBoundaries,transitions:G.transitions},h.updateQueue.baseState=L,h.memoizedState=L,h.flags&256){E=Xi(Error(n(423)),h),h=p_(c,h,N,y,E);break e}else if(N!==E){E=Xi(Error(n(424)),h),h=p_(c,h,N,y,E);break e}else for(Kn=Sa(h.stateNode.containerInfo.firstChild),Gn=h,At=!0,Ds=null,y=CC(h,null,N,y),h.child=y;y;)y.flags=y.flags&-3|4096,y=y.sibling;else{if(zi(),N===E){h=Gr(c,h,y);break e}jn(c,h,N,y)}h=h.child}return h;case 5:return RC(h),c===null&&$g(h),N=h.type,E=h.pendingProps,L=c!==null?c.memoizedProps:null,G=E.children,Ng(N,E)?G=null:L!==null&&Ng(N,L)&&(h.flags|=32),d_(c,h),jn(c,h,G,y),h.child;case 6:return c===null&&$g(h),null;case 13:return m_(c,h,y);case 4:return qg(h,h.stateNode.containerInfo),N=h.pendingProps,c===null?h.child=Vi(h,null,N,y):jn(c,h,N,y),h.child;case 11:return N=h.type,E=h.pendingProps,E=h.elementType===N?E:Fs(N,E),i_(c,h,N,E,y);case 7:return jn(c,h,h.pendingProps,y),h.child;case 8:return jn(c,h,h.pendingProps.children,y),h.child;case 12:return jn(c,h,h.pendingProps.children,y),h.child;case 10:e:{if(N=h.type._context,E=h.pendingProps,L=h.memoizedProps,G=E.value,Nt(mh,N._currentValue),N._currentValue=G,L!==null)if(Ps(L.value,G)){if(L.children===E.children&&!Mn.current){h=Gr(c,h,y);break e}}else for(L=h.child,L!==null&&(L.return=h);L!==null;){var ee=L.dependencies;if(ee!==null){G=L.child;for(var ne=ee.firstContext;ne!==null;){if(ne.context===N){if(L.tag===1){ne=Vr(-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),Dg(L.return,y,h),ee.lanes|=y;break}ne=ne.next}}else if(L.tag===10)G=L.type===h.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),Dg(G,y,h),G=L.sibling}else G=L.child;if(G!==null)G.return=L;else for(G=L;G!==null;){if(G===h){G=null;break}if(L=G.sibling,L!==null){L.return=G.return,G=L;break}G=G.return}L=G}jn(c,h,E.children,y),h=h.child}return h;case 9:return E=h.type,N=h.pendingProps.children,Ki(h,y),E=ls(E),N=N(E),h.flags|=1,jn(c,h,N,y),h.child;case 14:return N=h.type,E=Fs(N,h.pendingProps),E=Fs(N.type,E),l_(c,h,N,E,y);case 15:return c_(c,h,h.type,h.pendingProps,y);case 17:return N=h.type,E=h.pendingProps,E=h.elementType===N?E:Fs(N,E),_h(c,h),h.tag=1,$n(N)?(c=!0,ch(h)):c=!1,Ki(h,y),e_(h,N,E),ey(h,N,E,y),ry(null,h,N,!0,c,y);case 19:return y_(c,h,y);case 22:return u_(c,h,y)}throw Error(n(156,h.tag))};function q_(c,h){return ya(c,h)}function gq(c,h,y,N){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=h,this.dependencies=this.memoizedState=this.updateQueue=this.memoizedProps=null,this.mode=N,this.subtreeFlags=this.flags=0,this.deletions=null,this.childLanes=this.lanes=0,this.alternate=null}function ds(c,h,y,N){return new gq(c,h,y,N)}function Ny(c){return c=c.prototype,!(!c||!c.isReactComponent)}function yq(c){if(typeof c=="function")return Ny(c)?1:0;if(c!=null){if(c=c.$$typeof,c===M)return 11;if(c===P)return 14}return 2}function Oa(c,h){var y=c.alternate;return y===null?(y=ds(c.tag,h,c.key,c.mode),y.elementType=c.elementType,y.type=c.type,y.stateNode=c.stateNode,y.alternate=c,c.alternate=y):(y.pendingProps=h,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,h=c.dependencies,y.dependencies=h===null?null:{lanes:h.lanes,firstContext:h.firstContext},y.sibling=c.sibling,y.index=c.index,y.ref=c.ref,y}function Dh(c,h,y,N,E,L){var G=2;if(N=c,typeof c=="function")Ny(c)&&(G=1);else if(typeof c=="string")G=5;else e:switch(c){case A:return Do(y.children,E,L,h);case I:G=8,E|=8;break;case $:return c=ds(12,y,h,E|2),c.elementType=$,c.lanes=L,c;case B:return c=ds(13,y,h,E),c.elementType=B,c.lanes=L,c;case T:return c=ds(19,y,h,E),c.elementType=T,c.lanes=L,c;case K:return Fh(y,E,L,h);default:if(typeof c=="object"&&c!==null)switch(c.$$typeof){case U:G=10;break e;case F:G=9;break e;case M:G=11;break e;case P:G=14;break e;case q:G=16,N=null;break e}throw Error(n(130,c==null?c:typeof c,""))}return h=ds(G,y,h,E),h.elementType=c,h.type=N,h.lanes=L,h}function Do(c,h,y,N){return c=ds(7,c,N,h),c.lanes=y,c}function Fh(c,h,y,N){return c=ds(22,c,N,h),c.elementType=K,c.lanes=y,c.stateNode={isHidden:!1},c}function Sy(c,h,y){return c=ds(6,c,null,h),c.lanes=y,c}function Cy(c,h,y){return h=ds(4,c.children!==null?c.children:[],c.key,h),h.lanes=y,h.stateNode={containerInfo:c.containerInfo,pendingChildren:null,implementation:c.implementation},h}function wq(c,h,y,N,E){this.tag=h,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=pc(0),this.expirationTimes=pc(-1),this.entangledLanes=this.finishedLanes=this.mutableReadLanes=this.expiredLanes=this.pingedLanes=this.suspendedLanes=this.pendingLanes=0,this.entanglements=pc(0),this.identifierPrefix=N,this.onRecoverableError=E,this.mutableSourceEagerHydrationData=null}function _y(c,h,y,N,E,L,G,ee,ne){return c=new wq(c,h,y,ee,ne),h===1?(h=1,L===!0&&(h|=8)):h=0,L=ds(3,null,null,h),c.current=L,L.stateNode=c,L.memoizedState={element:N,isDehydrated:y,cache:null,transitions:null,pendingSuspenseBoundaries:null},Bg(L),c}function xq(c,h,y){var N=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:R,key:N==null?null:""+N,children:c,containerInfo:h,implementation:y}}function U_(c){if(!c)return _a;c=c._reactInternals;e:{if(gn(c)!==c||c.tag!==1)throw Error(n(170));var h=c;do{switch(h.tag){case 3:h=h.stateNode.context;break e;case 1:if($n(h.type)){h=h.stateNode.__reactInternalMemoizedMergedChildContext;break e}}h=h.return}while(h!==null);throw Error(n(171))}if(c.tag===1){var y=c.type;if($n(y))return gC(c,y,h)}return h}function W_(c,h,y,N,E,L,G,ee,ne){return c=_y(y,N,!0,c,E,L,G,ee,ne),c.context=U_(null),y=c.current,N=Nn(),E=La(y),L=Vr(N,E),L.callback=h??null,Aa(y,L,E),c.current.lanes=E,rr(c,E,N),On(c,N),c}function Bh(c,h,y,N){var E=h.current,L=Nn(),G=La(E);return y=U_(y),h.context===null?h.context=y:h.pendingContext=y,h=Vr(L,G),h.payload={element:c},N=N===void 0?null:N,N!==null&&(h.callback=N),c=Aa(E,h,G),c!==null&&(Us(c,E,G,L),yh(c,E,G)),G}function qh(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 H_(c,h){if(c=c.memoizedState,c!==null&&c.dehydrated!==null){var y=c.retryLane;c.retryLane=y!==0&&y<h?y:h}}function Ey(c,h){H_(c,h),(c=c.alternate)&&H_(c,h)}function vq(){return null}var z_=typeof reportError=="function"?reportError:function(c){console.error(c)};function Ty(c){this._internalRoot=c}Uh.prototype.render=Ty.prototype.render=function(c){var h=this._internalRoot;if(h===null)throw Error(n(409));Bh(c,h,null,null)},Uh.prototype.unmount=Ty.prototype.unmount=function(){var c=this._internalRoot;if(c!==null){this._internalRoot=null;var h=c.containerInfo;Io(function(){Bh(null,c,null,null)}),h[qr]=null}};function Uh(c){this._internalRoot=c}Uh.prototype.unstable_scheduleHydration=function(c){if(c){var h=Fd();c={blockedOn:null,target:c,priority:h};for(var y=0;y<Is.length&&h!==0&&h<Is[y].priority;y++);Is.splice(y,0,c),y===0&&qd(c)}};function Ay(c){return!(!c||c.nodeType!==1&&c.nodeType!==9&&c.nodeType!==11)}function Wh(c){return!(!c||c.nodeType!==1&&c.nodeType!==9&&c.nodeType!==11&&(c.nodeType!==8||c.nodeValue!==" react-mount-point-unstable "))}function V_(){}function bq(c,h,y,N,E){if(E){if(typeof N=="function"){var L=N;N=function(){var ue=qh(G);L.call(ue)}}var G=W_(h,N,c,0,null,!1,!1,"",V_);return c._reactRootContainer=G,c[qr]=G.current,Pc(c.nodeType===8?c.parentNode:c),Io(),G}for(;E=c.lastChild;)c.removeChild(E);if(typeof N=="function"){var ee=N;N=function(){var ue=qh(ne);ee.call(ue)}}var ne=_y(c,0,!1,null,null,!1,!1,"",V_);return c._reactRootContainer=ne,c[qr]=ne.current,Pc(c.nodeType===8?c.parentNode:c),Io(function(){Bh(h,ne,y,N)}),ne}function Hh(c,h,y,N,E){var L=y._reactRootContainer;if(L){var G=L;if(typeof E=="function"){var ee=E;E=function(){var ne=qh(G);ee.call(ne)}}Bh(h,G,c,E)}else G=bq(y,h,c,E,N);return qh(G)}po=function(c){switch(c.tag){case 3:var h=c.stateNode;if(h.current.memoizedState.isDehydrated){var y=Rn(h.pendingLanes);y!==0&&(ji(h,y|1),On(h,yt()),(ht&6)===0&&(Qi=yt()+500,Ea()))}break;case 13:Io(function(){var N=zr(c,1);if(N!==null){var E=Nn();Us(N,c,1,E)}}),Ey(c,1)}},mc=function(c){if(c.tag===13){var h=zr(c,134217728);if(h!==null){var y=Nn();Us(h,c,134217728,y)}Ey(c,134217728)}},gc=function(c){if(c.tag===13){var h=La(c),y=zr(c,h);if(y!==null){var N=Nn();Us(y,c,h,N)}Ey(c,h)}},Fd=function(){return ct},yc=function(c,h){var y=ct;try{return ct=c,h()}finally{ct=y}},at=function(c,h,y){switch(h){case"input":if(ye(c,y),h=y.name,y.type==="radio"&&h!=null){for(y=c;y.parentNode;)y=y.parentNode;for(y=y.querySelectorAll("input[name="+JSON.stringify(""+h)+'][type="radio"]'),h=0;h<y.length;h++){var N=y[h];if(N!==c&&N.form===c.form){var E=ih(N);if(!E)throw Error(n(90));oe(N),ye(N,E)}}}break;case"textarea":Ue(c,y);break;case"select":h=y.value,h!=null&&ke(c,!!y.multiple,h,!1)}},Cs=by,zn=Io;var kq={usingClientEntryPoint:!1,Events:[Bc,Bi,ih,Xt,tr,by]},eu={findFiberByHostInstance:_o,bundleType:0,version:"18.3.1",rendererPackageName:"react-dom"},jq={bundleType:eu.bundleType,version:eu.version,rendererPackageName:eu.rendererPackageName,rendererConfig:eu.rendererConfig,overrideHookState:null,overrideHookStateDeletePath:null,overrideHookStateRenamePath:null,overrideProps:null,overridePropsDeletePath:null,overridePropsRenamePath:null,setErrorHandler:null,setSuspenseHandler:null,scheduleUpdate:null,currentDispatcherRef:C.ReactCurrentDispatcher,findHostInstanceByFiber:function(c){return c=Ts(c),c===null?null:c.stateNode},findFiberByHostInstance:eu.findFiberByHostInstance||vq,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 zh=__REACT_DEVTOOLS_GLOBAL_HOOK__;if(!zh.isDisabled&&zh.supportsFiber)try{Rs=zh.inject(jq),dn=zh}catch{}}return Pn.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED=kq,Pn.createPortal=function(c,h){var y=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Ay(h))throw Error(n(200));return xq(c,h,null,y)},Pn.createRoot=function(c,h){if(!Ay(c))throw Error(n(299));var y=!1,N="",E=z_;return h!=null&&(h.unstable_strictMode===!0&&(y=!0),h.identifierPrefix!==void 0&&(N=h.identifierPrefix),h.onRecoverableError!==void 0&&(E=h.onRecoverableError)),h=_y(c,1,!1,null,null,y,!1,N,E),c[qr]=h.current,Pc(c.nodeType===8?c.parentNode:c),new Ty(h)},Pn.findDOMNode=function(c){if(c==null)return null;if(c.nodeType===1)return c;var h=c._reactInternals;if(h===void 0)throw typeof c.render=="function"?Error(n(188)):(c=Object.keys(c).join(","),Error(n(268,c)));return c=Ts(h),c=c===null?null:c.stateNode,c},Pn.flushSync=function(c){return Io(c)},Pn.hydrate=function(c,h,y){if(!Wh(h))throw Error(n(200));return Hh(null,c,h,!0,y)},Pn.hydrateRoot=function(c,h,y){if(!Ay(c))throw Error(n(405));var N=y!=null&&y.hydratedSources||null,E=!1,L="",G=z_;if(y!=null&&(y.unstable_strictMode===!0&&(E=!0),y.identifierPrefix!==void 0&&(L=y.identifierPrefix),y.onRecoverableError!==void 0&&(G=y.onRecoverableError)),h=W_(h,null,c,1,y??null,E,!1,L,G),c[qr]=h.current,Pc(c),N)for(c=0;c<N.length;c++)y=N[c],E=y._getVersion,E=E(y._source),h.mutableSourceEagerHydrationData==null?h.mutableSourceEagerHydrationData=[y,E]:h.mutableSourceEagerHydrationData.push(y,E);return new Uh(h)},Pn.render=function(c,h,y){if(!Wh(h))throw Error(n(200));return Hh(null,c,h,!1,y)},Pn.unmountComponentAtNode=function(c){if(!Wh(c))throw Error(n(40));return c._reactRootContainer?(Io(function(){Hh(null,null,c,!1,function(){c._reactRootContainer=null,c[qr]=null})}),!0):!1},Pn.unstable_batchedUpdates=by,Pn.unstable_renderSubtreeIntoContainer=function(c,h,y,N){if(!Wh(y))throw Error(n(200));if(c==null||c._reactInternals===void 0)throw Error(n(38));return Hh(c,h,y,!1,N)},Pn.version="18.3.1-next-f1338f8080-20240426",Pn}var eE;function v3(){if(eE)return $y.exports;eE=1;function e(){if(!(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!="function"))try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(e)}catch(t){console.error(t)}}return e(),$y.exports=Mq(),$y.exports}var tE;function $q(){if(tE)return Gh;tE=1;var e=v3();return Gh.createRoot=e.createRoot,Gh.hydrateRoot=e.hydrateRoot,Gh}var Lq=$q(),g=md();const me=Wj(g);function mn(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=mn(e[n]))!==""&&(t+=(t&&" ")+s);else for(let n in e)e[n]&&(t+=(t&&" ")+n);return t}var Oy={exports:{}},Py={},Dy={exports:{}},Fy={};/**
|
|
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 nE;function Iq(){if(nE)return Fy;nE=1;var e=md();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(),x=s({inst:{value:w,getSnapshot:m}}),b=x[0].inst,j=x[1];return o(function(){b.value=w,b.getSnapshot=m,u(b)&&j({inst:b})},[p,w,m]),a(function(){return u(b)&&j({inst:b}),p(function(){u(b)&&j({inst:b})})},[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 d(p,m){return m()}var f=typeof window>"u"||typeof window.document>"u"||typeof window.document.createElement>"u"?d:l;return Fy.useSyncExternalStore=e.useSyncExternalStore!==void 0?e.useSyncExternalStore:f,Fy}var sE;function Oq(){return sE||(sE=1,Dy.exports=Iq()),Dy.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 rE;function Pq(){if(rE)return Py;rE=1;var e=md(),t=Oq();function n(d,f){return d===f&&(d!==0||1/d===1/f)||d!==d&&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 Py.useSyncExternalStoreWithSelector=function(d,f,p,m,w){var x=o(null);if(x.current===null){var b={hasValue:!1,value:null};x.current=b}else b=x.current;x=l(function(){function k(R){if(!v){if(v=!0,S=R,R=m(R),w!==void 0&&b.hasValue){var A=b.value;if(w(A,R))return C=A}return C=R}if(A=C,s(S,R))return A;var I=m(R);return w!==void 0&&w(A,I)?(S=R,A):(S=R,C=I)}var v=!1,S,C,_=p===void 0?null:p;return[function(){return k(f())},_===null?void 0:function(){return k(_())}]},[f,p,m,w]);var j=a(d,x[0],x[1]);return i(function(){b.hasValue=!0,b.value=j},[j]),u(j),j},Py}var aE;function Dq(){return aE||(aE=1,Oy.exports=Pq()),Oy.exports}var Fq=Dq();const Bq=Wj(Fq),qq={},oE=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(x=>x(t,w))}},a=()=>t,u={setState:s,getState:a,getInitialState:()=>d,subscribe:f=>(n.add(f),()=>n.delete(f)),destroy:()=>{(qq?"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()}},d=t=e(s,a,u);return u},Uq=e=>e?oE(e):oE,{useDebugValue:Wq}=me,{useSyncExternalStoreWithSelector:Hq}=Bq,zq=e=>e;function b3(e,t=zq,n){const s=Hq(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,n);return Wq(s),s}const iE=(e,t)=>{const n=Uq(e),s=(a,o=t)=>b3(n,a,o);return Object.assign(s,n),s},Vq=(e,t)=>e?iE(e,t):iE;function nn(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 Gq={value:()=>{}};function qp(){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 Af(n)}function Af(e){this._=e}function Kq(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}})}Af.prototype=qp.prototype={constructor:Af,on:function(e,t){var n=this._,s=Kq(e+"",n),a,o=-1,i=s.length;if(arguments.length<2){for(;++o<i;)if((a=(e=s[o]).type)&&(a=Yq(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]=lE(n[a],e.name,t);else if(t==null)for(a in n)n[a]=lE(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 Af(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 Yq(e,t){for(var n=0,s=e.length,a;n<s;++n)if((a=e[n]).name===t)return a.value}function lE(e,t,n){for(var s=0,a=e.length;s<a;++s)if(e[s].name===t){e[s]=Gq,e=e.slice(0,s).concat(e.slice(s+1));break}return n!=null&&e.push({name:t,value:n}),e}var c1="http://www.w3.org/1999/xhtml";const cE={svg:"http://www.w3.org/2000/svg",xhtml:c1,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function Up(e){var t=e+="",n=t.indexOf(":");return n>=0&&(t=e.slice(0,n))!=="xmlns"&&(e=e.slice(n+1)),cE.hasOwnProperty(t)?{space:cE[t],local:e}:e}function Xq(e){return function(){var t=this.ownerDocument,n=this.namespaceURI;return n===c1&&t.documentElement.namespaceURI===c1?t.createElement(e):t.createElementNS(n,e)}}function Zq(e){return function(){return this.ownerDocument.createElementNS(e.space,e.local)}}function k3(e){var t=Up(e);return(t.local?Zq:Xq)(t)}function Jq(){}function Hj(e){return e==null?Jq:function(){return this.querySelector(e)}}function Qq(e){typeof e!="function"&&(e=Hj(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,d,f=0;f<i;++f)(u=o[f])&&(d=e.call(u,u.__data__,f,o))&&("__data__"in u&&(d.__data__=u.__data__),l[f]=d);return new es(s,this._parents)}function eU(e){return e==null?[]:Array.isArray(e)?e:Array.from(e)}function tU(){return[]}function j3(e){return e==null?tU:function(){return this.querySelectorAll(e)}}function nU(e){return function(){return eU(e.apply(this,arguments))}}function sU(e){typeof e=="function"?e=nU(e):e=j3(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,d=0;d<l;++d)(u=i[d])&&(s.push(e.call(u,u.__data__,d,i)),a.push(u));return new es(s,a)}function N3(e){return function(){return this.matches(e)}}function S3(e){return function(t){return t.matches(e)}}var rU=Array.prototype.find;function aU(e){return function(){return rU.call(this.children,e)}}function oU(){return this.firstElementChild}function iU(e){return this.select(e==null?oU:aU(typeof e=="function"?e:S3(e)))}var lU=Array.prototype.filter;function cU(){return Array.from(this.children)}function uU(e){return function(){return lU.call(this.children,e)}}function dU(e){return this.selectAll(e==null?cU:uU(typeof e=="function"?e:S3(e)))}function hU(e){typeof e!="function"&&(e=N3(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,d=0;d<i;++d)(u=o[d])&&e.call(u,u.__data__,d,o)&&l.push(u);return new es(s,this._parents)}function C3(e){return new Array(e.length)}function fU(){return new es(this._enter||this._groups.map(C3),this._parents)}function Gf(e,t){this.ownerDocument=e.ownerDocument,this.namespaceURI=e.namespaceURI,this._next=null,this._parent=e,this.__data__=t}Gf.prototype={constructor:Gf,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 pU(e){return function(){return e}}function mU(e,t,n,s,a,o){for(var i=0,l,u=t.length,d=o.length;i<d;++i)(l=t[i])?(l.__data__=o[i],s[i]=l):n[i]=new Gf(e,o[i]);for(;i<u;++i)(l=t[i])&&(a[i]=l)}function gU(e,t,n,s,a,o,i){var l,u,d=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)+"",d.has(w)?a[l]=u:d.set(w,u));for(l=0;l<p;++l)w=i.call(e,o[l],l,o)+"",(u=d.get(w))?(s[l]=u,u.__data__=o[l],d.delete(w)):n[l]=new Gf(e,o[l]);for(l=0;l<f;++l)(u=t[l])&&d.get(m[l])===u&&(a[l]=u)}function yU(e){return e.__data__}function wU(e,t){if(!arguments.length)return Array.from(this,yU);var n=t?gU:mU,s=this._parents,a=this._groups;typeof e!="function"&&(e=pU(e));for(var o=a.length,i=new Array(o),l=new Array(o),u=new Array(o),d=0;d<o;++d){var f=s[d],p=a[d],m=p.length,w=xU(e.call(f,f&&f.__data__,d,s)),x=w.length,b=l[d]=new Array(x),j=i[d]=new Array(x),k=u[d]=new Array(m);n(f,p,b,j,k,w,t);for(var v=0,S=0,C,_;v<x;++v)if(C=b[v]){for(v>=S&&(S=v+1);!(_=j[S])&&++S<x;);C._next=_||null}}return i=new es(i,s),i._enter=l,i._exit=u,i}function xU(e){return typeof e=="object"&&"length"in e?e:Array.from(e)}function vU(){return new es(this._exit||this._groups.map(C3),this._parents)}function bU(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 kU(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 d=n[u],f=s[u],p=d.length,m=l[u]=new Array(p),w,x=0;x<p;++x)(w=d[x]||f[x])&&(m[x]=w);for(;u<a;++u)l[u]=n[u];return new es(l,this._parents)}function jU(){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 NU(e){e||(e=SU);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),d,f=0;f<l;++f)(d=i[f])&&(u[f]=d);u.sort(t)}return new es(a,this._parents).order()}function SU(e,t){return e<t?-1:e>t?1:e>=t?0:NaN}function CU(){var e=arguments[0];return arguments[0]=this,e.apply(null,arguments),this}function _U(){return Array.from(this)}function EU(){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 TU(){let e=0;for(const t of this)++e;return e}function AU(){return!this.node()}function RU(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 MU(e){return function(){this.removeAttribute(e)}}function $U(e){return function(){this.removeAttributeNS(e.space,e.local)}}function LU(e,t){return function(){this.setAttribute(e,t)}}function IU(e,t){return function(){this.setAttributeNS(e.space,e.local,t)}}function OU(e,t){return function(){var n=t.apply(this,arguments);n==null?this.removeAttribute(e):this.setAttribute(e,n)}}function PU(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 DU(e,t){var n=Up(e);if(arguments.length<2){var s=this.node();return n.local?s.getAttributeNS(n.space,n.local):s.getAttribute(n)}return this.each((t==null?n.local?$U:MU:typeof t=="function"?n.local?PU:OU:n.local?IU:LU)(n,t))}function _3(e){return e.ownerDocument&&e.ownerDocument.defaultView||e.document&&e||e.defaultView}function FU(e){return function(){this.style.removeProperty(e)}}function BU(e,t,n){return function(){this.style.setProperty(e,t,n)}}function qU(e,t,n){return function(){var s=t.apply(this,arguments);s==null?this.style.removeProperty(e):this.style.setProperty(e,s,n)}}function UU(e,t,n){return arguments.length>1?this.each((t==null?FU:typeof t=="function"?qU:BU)(e,t,n??"")):Dl(this.node(),e)}function Dl(e,t){return e.style.getPropertyValue(t)||_3(e).getComputedStyle(e,null).getPropertyValue(t)}function WU(e){return function(){delete this[e]}}function HU(e,t){return function(){this[e]=t}}function zU(e,t){return function(){var n=t.apply(this,arguments);n==null?delete this[e]:this[e]=n}}function VU(e,t){return arguments.length>1?this.each((t==null?WU:typeof t=="function"?zU:HU)(e,t)):this.node()[e]}function E3(e){return e.trim().split(/^|\s+/)}function zj(e){return e.classList||new T3(e)}function T3(e){this._node=e,this._names=E3(e.getAttribute("class")||"")}T3.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 A3(e,t){for(var n=zj(e),s=-1,a=t.length;++s<a;)n.add(t[s])}function R3(e,t){for(var n=zj(e),s=-1,a=t.length;++s<a;)n.remove(t[s])}function GU(e){return function(){A3(this,e)}}function KU(e){return function(){R3(this,e)}}function YU(e,t){return function(){(t.apply(this,arguments)?A3:R3)(this,e)}}function XU(e,t){var n=E3(e+"");if(arguments.length<2){for(var s=zj(this.node()),a=-1,o=n.length;++a<o;)if(!s.contains(n[a]))return!1;return!0}return this.each((typeof t=="function"?YU:t?GU:KU)(n,t))}function ZU(){this.textContent=""}function JU(e){return function(){this.textContent=e}}function QU(e){return function(){var t=e.apply(this,arguments);this.textContent=t??""}}function eW(e){return arguments.length?this.each(e==null?ZU:(typeof e=="function"?QU:JU)(e)):this.node().textContent}function tW(){this.innerHTML=""}function nW(e){return function(){this.innerHTML=e}}function sW(e){return function(){var t=e.apply(this,arguments);this.innerHTML=t??""}}function rW(e){return arguments.length?this.each(e==null?tW:(typeof e=="function"?sW:nW)(e)):this.node().innerHTML}function aW(){this.nextSibling&&this.parentNode.appendChild(this)}function oW(){return this.each(aW)}function iW(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function lW(){return this.each(iW)}function cW(e){var t=typeof e=="function"?e:k3(e);return this.select(function(){return this.appendChild(t.apply(this,arguments))})}function uW(){return null}function dW(e,t){var n=typeof e=="function"?e:k3(e),s=t==null?uW:typeof t=="function"?t:Hj(t);return this.select(function(){return this.insertBefore(n.apply(this,arguments),s.apply(this,arguments)||null)})}function hW(){var e=this.parentNode;e&&e.removeChild(this)}function fW(){return this.each(hW)}function pW(){var e=this.cloneNode(!1),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function mW(){var e=this.cloneNode(!0),t=this.parentNode;return t?t.insertBefore(e,this.nextSibling):e}function gW(e){return this.select(e?mW:pW)}function yW(e){return arguments.length?this.property("__data__",e):this.node().__data__}function wW(e){return function(t){e.call(this,t,this.__data__)}}function xW(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 vW(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 bW(e,t,n){return function(){var s=this.__on,a,o=wW(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 kW(e,t,n){var s=xW(e+""),a,o=s.length,i;if(arguments.length<2){var l=this.node().__on;if(l){for(var u=0,d=l.length,f;u<d;++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?bW:vW,a=0;a<o;++a)this.each(l(s[a],t,n));return this}function M3(e,t,n){var s=_3(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 jW(e,t){return function(){return M3(this,e,t)}}function NW(e,t){return function(){return M3(this,e,t.apply(this,arguments))}}function SW(e,t){return this.each((typeof t=="function"?NW:jW)(e,t))}function*CW(){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 $3=[null];function es(e,t){this._groups=e,this._parents=t}function gd(){return new es([[document.documentElement]],$3)}function _W(){return this}es.prototype=gd.prototype={constructor:es,select:Qq,selectAll:sU,selectChild:iU,selectChildren:dU,filter:hU,data:wU,enter:fU,exit:vU,join:bU,merge:kU,selection:_W,order:jU,sort:NU,call:CU,nodes:_U,node:EU,size:TU,empty:AU,each:RU,attr:DU,style:UU,property:VU,classed:XU,text:eW,html:rW,raise:oW,lower:lW,append:cW,insert:dW,remove:fW,clone:gW,datum:yW,on:kW,dispatch:SW,[Symbol.iterator]:CW};function ms(e){return typeof e=="string"?new es([[document.querySelector(e)]],[document.documentElement]):new es([[e]],$3)}function EW(e){let t;for(;t=e.sourceEvent;)e=t;return e}function Vs(e,t){if(e=EW(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 TW={passive:!1},Wu={capture:!0,passive:!1};function By(e){e.stopImmediatePropagation()}function _l(e){e.preventDefault(),e.stopImmediatePropagation()}function L3(e){var t=e.document.documentElement,n=ms(e).on("dragstart.drag",_l,Wu);"onselectstart"in t?n.on("selectstart.drag",_l,Wu):(t.__noselect=t.style.MozUserSelect,t.style.MozUserSelect="none")}function I3(e,t){var n=e.document.documentElement,s=ms(e).on("dragstart.drag",null);t&&(s.on("click.drag",_l,Wu),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 Kh=e=>()=>e;function u1(e,{sourceEvent:t,subject:n,target:s,identifier:a,active:o,x:i,y:l,dx:u,dy:d,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:d,enumerable:!0,configurable:!0},_:{value:f}})}u1.prototype.on=function(){var e=this._.on.apply(this._,arguments);return e===this._?this:e};function AW(e){return!e.ctrlKey&&!e.button}function RW(){return this.parentNode}function MW(e,t){return t??{x:e.x,y:e.y}}function $W(){return navigator.maxTouchPoints||"ontouchstart"in this}function LW(){var e=AW,t=RW,n=MW,s=$W,a={},o=qp("start","drag","end"),i=0,l,u,d,f,p=0;function m(C){C.on("mousedown.drag",w).filter(s).on("touchstart.drag",j).on("touchmove.drag",k,TW).on("touchend.drag touchcancel.drag",v).style("touch-action","none").style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}function w(C,_){if(!(f||!e.call(this,C,_))){var R=S(this,t.call(this,C,_),C,_,"mouse");R&&(ms(C.view).on("mousemove.drag",x,Wu).on("mouseup.drag",b,Wu),L3(C.view),By(C),d=!1,l=C.clientX,u=C.clientY,R("start",C))}}function x(C){if(_l(C),!d){var _=C.clientX-l,R=C.clientY-u;d=_*_+R*R>p}a.mouse("drag",C)}function b(C){ms(C.view).on("mousemove.drag mouseup.drag",null),I3(C.view,d),_l(C),a.mouse("end",C)}function j(C,_){if(e.call(this,C,_)){var R=C.changedTouches,A=t.call(this,C,_),I=R.length,$,U;for($=0;$<I;++$)(U=S(this,A,C,_,R[$].identifier,R[$]))&&(By(C),U("start",C,R[$]))}}function k(C){var _=C.changedTouches,R=_.length,A,I;for(A=0;A<R;++A)(I=a[_[A].identifier])&&(_l(C),I("drag",C,_[A]))}function v(C){var _=C.changedTouches,R=_.length,A,I;for(f&&clearTimeout(f),f=setTimeout(function(){f=null},500),A=0;A<R;++A)(I=a[_[A].identifier])&&(By(C),I("end",C,_[A]))}function S(C,_,R,A,I,$){var U=o.copy(),F=Vs($||R,_),M,B,T;if((T=n.call(C,new u1("beforestart",{sourceEvent:R,target:m,identifier:I,active:i,x:F[0],y:F[1],dx:0,dy:0,dispatch:U}),A))!=null)return M=T.x-F[0]||0,B=T.y-F[1]||0,function P(q,K,z){var H=F,D;switch(q){case"start":a[I]=P,D=i++;break;case"end":delete a[I],--i;case"drag":F=Vs(z||K,_),D=i;break}U.call(q,C,new u1(q,{sourceEvent:K,subject:T,target:m,identifier:I,active:D,x:F[0]+M,y:F[1]+B,dx:F[0]-H[0],dy:F[1]-H[1],dispatch:U}),A)}}return m.filter=function(C){return arguments.length?(e=typeof C=="function"?C:Kh(!!C),m):e},m.container=function(C){return arguments.length?(t=typeof C=="function"?C:Kh(C),m):t},m.subject=function(C){return arguments.length?(n=typeof C=="function"?C:Kh(C),m):n},m.touchable=function(C){return arguments.length?(s=typeof C=="function"?C:Kh(!!C),m):s},m.on=function(){var C=o.on.apply(o,arguments);return C===o?m:C},m.clickDistance=function(C){return arguments.length?(p=(C=+C)*C,m):Math.sqrt(p)},m}function Vj(e,t,n){e.prototype=t.prototype=n,n.constructor=e}function O3(e,t){var n=Object.create(e.prototype);for(var s in t)n[s]=t[s];return n}function yd(){}var Hu=.7,Kf=1/Hu,El="\\s*([+-]?\\d+)\\s*",zu="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",xr="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",IW=/^#([0-9a-f]{3,8})$/,OW=new RegExp(`^rgb\\(${El},${El},${El}\\)$`),PW=new RegExp(`^rgb\\(${xr},${xr},${xr}\\)$`),DW=new RegExp(`^rgba\\(${El},${El},${El},${zu}\\)$`),FW=new RegExp(`^rgba\\(${xr},${xr},${xr},${zu}\\)$`),BW=new RegExp(`^hsl\\(${zu},${xr},${xr}\\)$`),qW=new RegExp(`^hsla\\(${zu},${xr},${xr},${zu}\\)$`),uE={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};Vj(yd,Vu,{copy(e){return Object.assign(new this.constructor,this,e)},displayable(){return this.rgb().displayable()},hex:dE,formatHex:dE,formatHex8:UW,formatHsl:WW,formatRgb:hE,toString:hE});function dE(){return this.rgb().formatHex()}function UW(){return this.rgb().formatHex8()}function WW(){return P3(this).formatHsl()}function hE(){return this.rgb().formatRgb()}function Vu(e){var t,n;return e=(e+"").trim().toLowerCase(),(t=IW.exec(e))?(n=t[1].length,t=parseInt(t[1],16),n===6?fE(t):n===3?new Fn(t>>8&15|t>>4&240,t>>4&15|t&240,(t&15)<<4|t&15,1):n===8?Yh(t>>24&255,t>>16&255,t>>8&255,(t&255)/255):n===4?Yh(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=OW.exec(e))?new Fn(t[1],t[2],t[3],1):(t=PW.exec(e))?new Fn(t[1]*255/100,t[2]*255/100,t[3]*255/100,1):(t=DW.exec(e))?Yh(t[1],t[2],t[3],t[4]):(t=FW.exec(e))?Yh(t[1]*255/100,t[2]*255/100,t[3]*255/100,t[4]):(t=BW.exec(e))?gE(t[1],t[2]/100,t[3]/100,1):(t=qW.exec(e))?gE(t[1],t[2]/100,t[3]/100,t[4]):uE.hasOwnProperty(e)?fE(uE[e]):e==="transparent"?new Fn(NaN,NaN,NaN,0):null}function fE(e){return new Fn(e>>16&255,e>>8&255,e&255,1)}function Yh(e,t,n,s){return s<=0&&(e=t=n=NaN),new Fn(e,t,n,s)}function HW(e){return e instanceof yd||(e=Vu(e)),e?(e=e.rgb(),new Fn(e.r,e.g,e.b,e.opacity)):new Fn}function d1(e,t,n,s){return arguments.length===1?HW(e):new Fn(e,t,n,s??1)}function Fn(e,t,n,s){this.r=+e,this.g=+t,this.b=+n,this.opacity=+s}Vj(Fn,d1,O3(yd,{brighter(e){return e=e==null?Kf:Math.pow(Kf,e),new Fn(this.r*e,this.g*e,this.b*e,this.opacity)},darker(e){return e=e==null?Hu:Math.pow(Hu,e),new Fn(this.r*e,this.g*e,this.b*e,this.opacity)},rgb(){return this},clamp(){return new Fn(Qo(this.r),Qo(this.g),Qo(this.b),Yf(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:pE,formatHex:pE,formatHex8:zW,formatRgb:mE,toString:mE}));function pE(){return`#${Yo(this.r)}${Yo(this.g)}${Yo(this.b)}`}function zW(){return`#${Yo(this.r)}${Yo(this.g)}${Yo(this.b)}${Yo((isNaN(this.opacity)?1:this.opacity)*255)}`}function mE(){const e=Yf(this.opacity);return`${e===1?"rgb(":"rgba("}${Qo(this.r)}, ${Qo(this.g)}, ${Qo(this.b)}${e===1?")":`, ${e})`}`}function Yf(e){return isNaN(e)?1:Math.max(0,Math.min(1,e))}function Qo(e){return Math.max(0,Math.min(255,Math.round(e)||0))}function Yo(e){return e=Qo(e),(e<16?"0":"")+e.toString(16)}function gE(e,t,n,s){return s<=0?e=t=n=NaN:n<=0||n>=1?e=t=NaN:t<=0&&(e=NaN),new Gs(e,t,n,s)}function P3(e){if(e instanceof Gs)return new Gs(e.h,e.s,e.l,e.opacity);if(e instanceof yd||(e=Vu(e)),!e)return new Gs;if(e instanceof Gs)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 Gs(i,l,u,e.opacity)}function VW(e,t,n,s){return arguments.length===1?P3(e):new Gs(e,t,n,s??1)}function Gs(e,t,n,s){this.h=+e,this.s=+t,this.l=+n,this.opacity=+s}Vj(Gs,VW,O3(yd,{brighter(e){return e=e==null?Kf:Math.pow(Kf,e),new Gs(this.h,this.s,this.l*e,this.opacity)},darker(e){return e=e==null?Hu:Math.pow(Hu,e),new Gs(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 Fn(qy(e>=240?e-240:e+120,a,s),qy(e,a,s),qy(e<120?e+240:e-120,a,s),this.opacity)},clamp(){return new Gs(yE(this.h),Xh(this.s),Xh(this.l),Yf(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=Yf(this.opacity);return`${e===1?"hsl(":"hsla("}${yE(this.h)}, ${Xh(this.s)*100}%, ${Xh(this.l)*100}%${e===1?")":`, ${e})`}`}}));function yE(e){return e=(e||0)%360,e<0?e+360:e}function Xh(e){return Math.max(0,Math.min(1,e||0))}function qy(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 D3=e=>()=>e;function GW(e,t){return function(n){return e+n*t}}function KW(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 YW(e){return(e=+e)==1?F3:function(t,n){return n-t?KW(t,n,e):D3(isNaN(t)?n:t)}}function F3(e,t){var n=t-e;return n?GW(e,n):D3(isNaN(e)?t:e)}const wE=(function e(t){var n=YW(t);function s(a,o){var i=n((a=d1(a)).r,(o=d1(o)).r),l=n(a.g,o.g),u=n(a.b,o.b),d=F3(a.opacity,o.opacity);return function(f){return a.r=i(f),a.g=l(f),a.b=u(f),a.opacity=d(f),a+""}}return s.gamma=e,s})(1);function Wa(e,t){return e=+e,t=+t,function(n){return e*(1-n)+t*n}}var h1=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Uy=new RegExp(h1.source,"g");function XW(e){return function(){return e}}function ZW(e){return function(t){return e(t)+""}}function JW(e,t){var n=h1.lastIndex=Uy.lastIndex=0,s,a,o,i=-1,l=[],u=[];for(e=e+"",t=t+"";(s=h1.exec(e))&&(a=Uy.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:Wa(s,a)})),n=Uy.lastIndex;return n<t.length&&(o=t.slice(n),l[i]?l[i]+=o:l[++i]=o),l.length<2?u[0]?ZW(u[0].x):XW(t):(t=u.length,function(d){for(var f=0,p;f<t;++f)l[(p=u[f]).i]=p.x(d);return l.join("")})}var xE=180/Math.PI,f1={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function B3(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)*xE,skewX:Math.atan(u)*xE,scaleX:i,scaleY:l}}var Zh;function QW(e){const t=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(e+"");return t.isIdentity?f1:B3(t.a,t.b,t.c,t.d,t.e,t.f)}function eH(e){return e==null||(Zh||(Zh=document.createElementNS("http://www.w3.org/2000/svg","g")),Zh.setAttribute("transform",e),!(e=Zh.transform.baseVal.consolidate()))?f1:(e=e.matrix,B3(e.a,e.b,e.c,e.d,e.e,e.f))}function q3(e,t,n,s){function a(d){return d.length?d.pop()+" ":""}function o(d,f,p,m,w,x){if(d!==p||f!==m){var b=w.push("translate(",null,t,null,n);x.push({i:b-4,x:Wa(d,p)},{i:b-2,x:Wa(f,m)})}else(p||m)&&w.push("translate("+p+t+m+n)}function i(d,f,p,m){d!==f?(d-f>180?f+=360:f-d>180&&(d+=360),m.push({i:p.push(a(p)+"rotate(",null,s)-2,x:Wa(d,f)})):f&&p.push(a(p)+"rotate("+f+s)}function l(d,f,p,m){d!==f?m.push({i:p.push(a(p)+"skewX(",null,s)-2,x:Wa(d,f)}):f&&p.push(a(p)+"skewX("+f+s)}function u(d,f,p,m,w,x){if(d!==p||f!==m){var b=w.push(a(w)+"scale(",null,",",null,")");x.push({i:b-4,x:Wa(d,p)},{i:b-2,x:Wa(f,m)})}else(p!==1||m!==1)&&w.push(a(w)+"scale("+p+","+m+")")}return function(d,f){var p=[],m=[];return d=e(d),f=e(f),o(d.translateX,d.translateY,f.translateX,f.translateY,p,m),i(d.rotate,f.rotate,p,m),l(d.skewX,f.skewX,p,m),u(d.scaleX,d.scaleY,f.scaleX,f.scaleY,p,m),d=f=null,function(w){for(var x=-1,b=m.length,j;++x<b;)p[(j=m[x]).i]=j.x(w);return p.join("")}}}var tH=q3(QW,"px, ","px)","deg)"),nH=q3(eH,", ",")",")"),sH=1e-12;function vE(e){return((e=Math.exp(e))+1/e)/2}function rH(e){return((e=Math.exp(e))-1/e)/2}function aH(e){return((e=Math.exp(2*e))-1)/(e+1)}const oH=(function e(t,n,s){function a(o,i){var l=o[0],u=o[1],d=o[2],f=i[0],p=i[1],m=i[2],w=f-l,x=p-u,b=w*w+x*x,j,k;if(b<sH)k=Math.log(m/d)/t,j=function(A){return[l+A*w,u+A*x,d*Math.exp(t*A*k)]};else{var v=Math.sqrt(b),S=(m*m-d*d+s*b)/(2*d*n*v),C=(m*m-d*d-s*b)/(2*m*n*v),_=Math.log(Math.sqrt(S*S+1)-S),R=Math.log(Math.sqrt(C*C+1)-C);k=(R-_)/t,j=function(A){var I=A*k,$=vE(_),U=d/(n*v)*($*aH(t*I+_)-rH(_));return[l+U*w,u+U*x,d*$/vE(t*I+_)]}}return j.duration=k*1e3*t/Math.SQRT2,j}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 Fl=0,xu=0,nu=0,U3=1e3,Xf,vu,Zf=0,ii=0,Wp=0,Gu=typeof performance=="object"&&performance.now?performance:Date,W3=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(e){setTimeout(e,17)};function Gj(){return ii||(W3(iH),ii=Gu.now()+Wp)}function iH(){ii=0}function Jf(){this._call=this._time=this._next=null}Jf.prototype=H3.prototype={constructor:Jf,restart:function(e,t,n){if(typeof e!="function")throw new TypeError("callback is not a function");n=(n==null?Gj():+n)+(t==null?0:+t),!this._next&&vu!==this&&(vu?vu._next=this:Xf=this,vu=this),this._call=e,this._time=n,p1()},stop:function(){this._call&&(this._call=null,this._time=1/0,p1())}};function H3(e,t,n){var s=new Jf;return s.restart(e,t,n),s}function lH(){Gj(),++Fl;for(var e=Xf,t;e;)(t=ii-e._time)>=0&&e._call.call(void 0,t),e=e._next;--Fl}function bE(){ii=(Zf=Gu.now())+Wp,Fl=xu=0;try{lH()}finally{Fl=0,uH(),ii=0}}function cH(){var e=Gu.now(),t=e-Zf;t>U3&&(Wp-=t,Zf=e)}function uH(){for(var e,t=Xf,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:Xf=n);vu=e,p1(s)}function p1(e){if(!Fl){xu&&(xu=clearTimeout(xu));var t=e-ii;t>24?(e<1/0&&(xu=setTimeout(bE,e-Gu.now()-Wp)),nu&&(nu=clearInterval(nu))):(nu||(Zf=Gu.now(),nu=setInterval(cH,U3)),Fl=1,W3(bE))}}function kE(e,t,n){var s=new Jf;return t=t==null?0:+t,s.restart(a=>{s.stop(),e(a+t)},t,n),s}var dH=qp("start","end","cancel","interrupt"),hH=[],z3=0,jE=1,m1=2,Rf=3,NE=4,g1=5,Mf=6;function Hp(e,t,n,s,a,o){var i=e.__transition;if(!i)e.__transition={};else if(n in i)return;fH(e,n,{name:t,index:s,group:a,on:dH,tween:hH,time:o.time,delay:o.delay,duration:o.duration,ease:o.ease,timer:null,state:z3})}function Kj(e,t){var n=Qs(e,t);if(n.state>z3)throw new Error("too late; already scheduled");return n}function jr(e,t){var n=Qs(e,t);if(n.state>Rf)throw new Error("too late; already running");return n}function Qs(e,t){var n=e.__transition;if(!n||!(n=n[t]))throw new Error("transition not found");return n}function fH(e,t,n){var s=e.__transition,a;s[t]=n,n.timer=H3(o,0,n.time);function o(d){n.state=jE,n.timer.restart(i,n.delay,n.time),n.delay<=d&&i(d-n.delay)}function i(d){var f,p,m,w;if(n.state!==jE)return u();for(f in s)if(w=s[f],w.name===n.name){if(w.state===Rf)return kE(i);w.state===NE?(w.state=Mf,w.timer.stop(),w.on.call("interrupt",e,e.__data__,w.index,w.group),delete s[f]):+f<t&&(w.state=Mf,w.timer.stop(),w.on.call("cancel",e,e.__data__,w.index,w.group),delete s[f])}if(kE(function(){n.state===Rf&&(n.state=NE,n.timer.restart(l,n.delay,n.time),l(d))}),n.state=m1,n.on.call("start",e,e.__data__,n.index,n.group),n.state===m1){for(n.state=Rf,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(d){for(var f=d<n.duration?n.ease.call(null,d/n.duration):(n.timer.restart(u),n.state=g1,1),p=-1,m=a.length;++p<m;)a[p].call(e,f);n.state===g1&&(n.on.call("end",e,e.__data__,n.index,n.group),u())}function u(){n.state=Mf,n.timer.stop(),delete s[t];for(var d in s)return;delete e.__transition}}function $f(e,t){var n=e.__transition,s,a,o=!0,i;if(n){t=t==null?null:t+"";for(i in n){if((s=n[i]).name!==t){o=!1;continue}a=s.state>m1&&s.state<g1,s.state=Mf,s.timer.stop(),s.on.call(a?"interrupt":"cancel",e,e.__data__,s.index,s.group),delete n[i]}o&&delete e.__transition}}function pH(e){return this.each(function(){$f(this,e)})}function mH(e,t){var n,s;return function(){var a=jr(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 gH(e,t,n){var s,a;if(typeof n!="function")throw new Error;return function(){var o=jr(this,e),i=o.tween;if(i!==s){a=(s=i).slice();for(var l={name:t,value:n},u=0,d=a.length;u<d;++u)if(a[u].name===t){a[u]=l;break}u===d&&a.push(l)}o.tween=a}}function yH(e,t){var n=this._id;if(e+="",arguments.length<2){for(var s=Qs(this.node(),n).tween,a=0,o=s.length,i;a<o;++a)if((i=s[a]).name===e)return i.value;return null}return this.each((t==null?mH:gH)(n,e,t))}function Yj(e,t,n){var s=e._id;return e.each(function(){var a=jr(this,s);(a.value||(a.value={}))[t]=n.apply(this,arguments)}),function(a){return Qs(a,s).value[t]}}function V3(e,t){var n;return(typeof t=="number"?Wa:t instanceof Vu?wE:(n=Vu(t))?(t=n,wE):JW)(e,t)}function wH(e){return function(){this.removeAttribute(e)}}function xH(e){return function(){this.removeAttributeNS(e.space,e.local)}}function vH(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 bH(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 kH(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 jH(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 NH(e,t){var n=Up(e),s=n==="transform"?nH:V3;return this.attrTween(e,typeof t=="function"?(n.local?jH:kH)(n,s,Yj(this,"attr."+e,t)):t==null?(n.local?xH:wH)(n):(n.local?bH:vH)(n,s,t))}function SH(e,t){return function(n){this.setAttribute(e,t.call(this,n))}}function CH(e,t){return function(n){this.setAttributeNS(e.space,e.local,t.call(this,n))}}function _H(e,t){var n,s;function a(){var o=t.apply(this,arguments);return o!==s&&(n=(s=o)&&CH(e,o)),n}return a._value=t,a}function EH(e,t){var n,s;function a(){var o=t.apply(this,arguments);return o!==s&&(n=(s=o)&&SH(e,o)),n}return a._value=t,a}function TH(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=Up(e);return this.tween(n,(s.local?_H:EH)(s,t))}function AH(e,t){return function(){Kj(this,e).delay=+t.apply(this,arguments)}}function RH(e,t){return t=+t,function(){Kj(this,e).delay=t}}function MH(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?AH:RH)(t,e)):Qs(this.node(),t).delay}function $H(e,t){return function(){jr(this,e).duration=+t.apply(this,arguments)}}function LH(e,t){return t=+t,function(){jr(this,e).duration=t}}function IH(e){var t=this._id;return arguments.length?this.each((typeof e=="function"?$H:LH)(t,e)):Qs(this.node(),t).duration}function OH(e,t){if(typeof t!="function")throw new Error;return function(){jr(this,e).ease=t}}function PH(e){var t=this._id;return arguments.length?this.each(OH(t,e)):Qs(this.node(),t).ease}function DH(e,t){return function(){var n=t.apply(this,arguments);if(typeof n!="function")throw new Error;jr(this,e).ease=n}}function FH(e){if(typeof e!="function")throw new Error;return this.each(DH(this._id,e))}function BH(e){typeof e!="function"&&(e=N3(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,d=0;d<i;++d)(u=o[d])&&e.call(u,u.__data__,d,o)&&l.push(u);return new ia(s,this._parents,this._name,this._id)}function qH(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],d=n[l],f=u.length,p=i[l]=new Array(f),m,w=0;w<f;++w)(m=u[w]||d[w])&&(p[w]=m);for(;l<s;++l)i[l]=t[l];return new ia(i,this._parents,this._name,this._id)}function UH(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 WH(e,t,n){var s,a,o=UH(t)?Kj:jr;return function(){var i=o(this,e),l=i.on;l!==s&&(a=(s=l).copy()).on(t,n),i.on=a}}function HH(e,t){var n=this._id;return arguments.length<2?Qs(this.node(),n).on.on(e):this.each(WH(n,e,t))}function zH(e){return function(){var t=this.parentNode;for(var n in this.__transition)if(+n!==e)return;t&&t.removeChild(this)}}function VH(){return this.on("end.remove",zH(this._id))}function GH(e){var t=this._name,n=this._id;typeof e!="function"&&(e=Hj(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,d=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__),d[m]=p,Hp(d[m],t,n,m,d,Qs(f,n)));return new ia(o,this._parents,t,n)}function KH(e){var t=this._name,n=this._id;typeof e!="function"&&(e=j3(e));for(var s=this._groups,a=s.length,o=[],i=[],l=0;l<a;++l)for(var u=s[l],d=u.length,f,p=0;p<d;++p)if(f=u[p]){for(var m=e.call(f,f.__data__,p,u),w,x=Qs(f,n),b=0,j=m.length;b<j;++b)(w=m[b])&&Hp(w,t,n,b,m,x);o.push(m),i.push(f)}return new ia(o,i,t,n)}var YH=gd.prototype.constructor;function XH(){return new YH(this._groups,this._parents)}function ZH(e,t){var n,s,a;return function(){var o=Dl(this,e),i=(this.style.removeProperty(e),Dl(this,e));return o===i?null:o===n&&i===s?a:a=t(n=o,s=i)}}function G3(e){return function(){this.style.removeProperty(e)}}function JH(e,t,n){var s,a=n+"",o;return function(){var i=Dl(this,e);return i===a?null:i===s?o:o=t(s=i,n)}}function QH(e,t,n){var s,a,o;return function(){var i=Dl(this,e),l=n(this),u=l+"";return l==null&&(u=l=(this.style.removeProperty(e),Dl(this,e))),i===u?null:i===s&&u===a?o:(a=u,o=t(s=i,l))}}function e7(e,t){var n,s,a,o="style."+t,i="end."+o,l;return function(){var u=jr(this,e),d=u.on,f=u.value[o]==null?l||(l=G3(t)):void 0;(d!==n||a!==f)&&(s=(n=d).copy()).on(i,a=f),u.on=s}}function t7(e,t,n){var s=(e+="")=="transform"?tH:V3;return t==null?this.styleTween(e,ZH(e,s)).on("end.style."+e,G3(e)):typeof t=="function"?this.styleTween(e,QH(e,s,Yj(this,"style."+e,t))).each(e7(this._id,e)):this.styleTween(e,JH(e,s,t),n).on("end.style."+e,null)}function n7(e,t,n){return function(s){this.style.setProperty(e,t.call(this,s),n)}}function s7(e,t,n){var s,a;function o(){var i=t.apply(this,arguments);return i!==a&&(s=(a=i)&&n7(e,i,n)),s}return o._value=t,o}function r7(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,s7(e,t,n??""))}function a7(e){return function(){this.textContent=e}}function o7(e){return function(){var t=e(this);this.textContent=t??""}}function i7(e){return this.tween("text",typeof e=="function"?o7(Yj(this,"text",e)):a7(e==null?"":e+""))}function l7(e){return function(t){this.textContent=e.call(this,t)}}function c7(e){var t,n;function s(){var a=e.apply(this,arguments);return a!==n&&(t=(n=a)&&l7(a)),t}return s._value=e,s}function u7(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,c7(e))}function d7(){for(var e=this._name,t=this._id,n=K3(),s=this._groups,a=s.length,o=0;o<a;++o)for(var i=s[o],l=i.length,u,d=0;d<l;++d)if(u=i[d]){var f=Qs(u,t);Hp(u,e,n,d,i,{time:f.time+f.delay+f.duration,delay:0,duration:f.duration,ease:f.ease})}return new ia(s,this._parents,e,n)}function h7(){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 d=jr(this,s),f=d.on;f!==e&&(t=(e=f).copy(),t._.cancel.push(l),t._.interrupt.push(l),t._.end.push(u)),d.on=t}),a===0&&o()})}var f7=0;function ia(e,t,n,s){this._groups=e,this._parents=t,this._name=n,this._id=s}function K3(){return++f7}var Yr=gd.prototype;ia.prototype={constructor:ia,select:GH,selectAll:KH,selectChild:Yr.selectChild,selectChildren:Yr.selectChildren,filter:BH,merge:qH,selection:XH,transition:d7,call:Yr.call,nodes:Yr.nodes,node:Yr.node,size:Yr.size,empty:Yr.empty,each:Yr.each,on:HH,attr:NH,attrTween:TH,style:t7,styleTween:r7,text:i7,textTween:u7,remove:VH,tween:yH,delay:MH,duration:IH,ease:PH,easeVarying:FH,end:h7,[Symbol.iterator]:Yr[Symbol.iterator]};function p7(e){return((e*=2)<=1?e*e*e:(e-=2)*e*e+2)/2}var m7={time:null,delay:0,duration:250,ease:p7};function g7(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 y7(e){var t,n;e instanceof ia?(t=e._id,e=e._name):(t=K3(),(n=m7).time=Gj(),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,d=0;d<l;++d)(u=i[d])&&Hp(u,e,t,d,i,n||g7(u,t));return new ia(s,this._parents,e,t)}gd.prototype.interrupt=pH;gd.prototype.transition=y7;const Jh=e=>()=>e;function w7(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 ta(e,t,n){this.k=e,this.x=t,this.y=n}ta.prototype={constructor:ta,scale:function(e){return e===1?this:new ta(this.k*e,this.x,this.y)},translate:function(e,t){return e===0&t===0?this:new ta(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 sa=new ta(1,0,0);ta.prototype;function Wy(e){e.stopImmediatePropagation()}function su(e){e.preventDefault(),e.stopImmediatePropagation()}function x7(e){return(!e.ctrlKey||e.type==="wheel")&&!e.button}function v7(){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 SE(){return this.__zoom||sa}function b7(e){return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*(e.ctrlKey?10:1)}function k7(){return navigator.maxTouchPoints||"ontouchstart"in this}function j7(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 Y3(){var e=x7,t=v7,n=j7,s=b7,a=k7,o=[0,1/0],i=[[-1/0,-1/0],[1/0,1/0]],l=250,u=oH,d=qp("start","zoom","end"),f,p,m,w=500,x=150,b=0,j=10;function k(T){T.property("__zoom",SE).on("wheel.zoom",I,{passive:!1}).on("mousedown.zoom",$).on("dblclick.zoom",U).filter(a).on("touchstart.zoom",F).on("touchmove.zoom",M).on("touchend.zoom touchcancel.zoom",B).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}k.transform=function(T,P,q,K){var z=T.selection?T.selection():T;z.property("__zoom",SE),T!==z?_(T,P,q,K):z.interrupt().each(function(){R(this,arguments).event(K).start().zoom(null,typeof P=="function"?P.apply(this,arguments):P).end()})},k.scaleBy=function(T,P,q,K){k.scaleTo(T,function(){var z=this.__zoom.k,H=typeof P=="function"?P.apply(this,arguments):P;return z*H},q,K)},k.scaleTo=function(T,P,q,K){k.transform(T,function(){var z=t.apply(this,arguments),H=this.__zoom,D=q==null?C(z):typeof q=="function"?q.apply(this,arguments):q,O=H.invert(D),V=typeof P=="function"?P.apply(this,arguments):P;return n(S(v(H,V),D,O),z,i)},q,K)},k.translateBy=function(T,P,q,K){k.transform(T,function(){return n(this.__zoom.translate(typeof P=="function"?P.apply(this,arguments):P,typeof q=="function"?q.apply(this,arguments):q),t.apply(this,arguments),i)},null,K)},k.translateTo=function(T,P,q,K,z){k.transform(T,function(){var H=t.apply(this,arguments),D=this.__zoom,O=K==null?C(H):typeof K=="function"?K.apply(this,arguments):K;return n(sa.translate(O[0],O[1]).scale(D.k).translate(typeof P=="function"?-P.apply(this,arguments):-P,typeof q=="function"?-q.apply(this,arguments):-q),H,i)},K,z)};function v(T,P){return P=Math.max(o[0],Math.min(o[1],P)),P===T.k?T:new ta(P,T.x,T.y)}function S(T,P,q){var K=P[0]-q[0]*T.k,z=P[1]-q[1]*T.k;return K===T.x&&z===T.y?T:new ta(T.k,K,z)}function C(T){return[(+T[0][0]+ +T[1][0])/2,(+T[0][1]+ +T[1][1])/2]}function _(T,P,q,K){T.on("start.zoom",function(){R(this,arguments).event(K).start()}).on("interrupt.zoom end.zoom",function(){R(this,arguments).event(K).end()}).tween("zoom",function(){var z=this,H=arguments,D=R(z,H).event(K),O=t.apply(z,H),V=q==null?C(O):typeof q=="function"?q.apply(z,H):q,Z=Math.max(O[1][0]-O[0][0],O[1][1]-O[0][1]),W=z.__zoom,X=typeof P=="function"?P.apply(z,H):P,Y=u(W.invert(V).concat(Z/W.k),X.invert(V).concat(Z/X.k));return function(J){if(J===1)J=X;else{var Q=Y(J),te=Z/Q[2];J=new ta(te,V[0]-Q[0]*te,V[1]-Q[1]*te)}D.zoom(null,J)}})}function R(T,P,q){return!q&&T.__zooming||new A(T,P)}function A(T,P){this.that=T,this.args=P,this.active=0,this.sourceEvent=null,this.extent=t.apply(T,P),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,P){return this.mouse&&T!=="mouse"&&(this.mouse[1]=P.invert(this.mouse[0])),this.touch0&&T!=="touch"&&(this.touch0[1]=P.invert(this.touch0[0])),this.touch1&&T!=="touch"&&(this.touch1[1]=P.invert(this.touch1[0])),this.that.__zoom=P,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(T){var P=ms(this.that).datum();d.call(T,this.that,new w7(T,{sourceEvent:this.sourceEvent,target:k,transform:this.that.__zoom,dispatch:d}),P)}};function I(T,...P){if(!e.apply(this,arguments))return;var q=R(this,P).event(T),K=this.__zoom,z=Math.max(o[0],Math.min(o[1],K.k*Math.pow(2,s.apply(this,arguments)))),H=Vs(T);if(q.wheel)(q.mouse[0][0]!==H[0]||q.mouse[0][1]!==H[1])&&(q.mouse[1]=K.invert(q.mouse[0]=H)),clearTimeout(q.wheel);else{if(K.k===z)return;q.mouse=[H,K.invert(H)],$f(this),q.start()}su(T),q.wheel=setTimeout(D,x),q.zoom("mouse",n(S(v(K,z),q.mouse[0],q.mouse[1]),q.extent,i));function D(){q.wheel=null,q.end()}}function $(T,...P){if(m||!e.apply(this,arguments))return;var q=T.currentTarget,K=R(this,P,!0).event(T),z=ms(T.view).on("mousemove.zoom",V,!0).on("mouseup.zoom",Z,!0),H=Vs(T,q),D=T.clientX,O=T.clientY;L3(T.view),Wy(T),K.mouse=[H,this.__zoom.invert(H)],$f(this),K.start();function V(W){if(su(W),!K.moved){var X=W.clientX-D,Y=W.clientY-O;K.moved=X*X+Y*Y>b}K.event(W).zoom("mouse",n(S(K.that.__zoom,K.mouse[0]=Vs(W,q),K.mouse[1]),K.extent,i))}function Z(W){z.on("mousemove.zoom mouseup.zoom",null),I3(W.view,K.moved),su(W),K.event(W).end()}}function U(T,...P){if(e.apply(this,arguments)){var q=this.__zoom,K=Vs(T.changedTouches?T.changedTouches[0]:T,this),z=q.invert(K),H=q.k*(T.shiftKey?.5:2),D=n(S(v(q,H),K,z),t.apply(this,P),i);su(T),l>0?ms(this).transition().duration(l).call(_,D,K,T):ms(this).call(k.transform,D,K,T)}}function F(T,...P){if(e.apply(this,arguments)){var q=T.touches,K=q.length,z=R(this,P,T.changedTouches.length===K).event(T),H,D,O,V;for(Wy(T),D=0;D<K;++D)O=q[D],V=Vs(O,this),V=[V,this.__zoom.invert(V),O.identifier],z.touch0?!z.touch1&&z.touch0[2]!==V[2]&&(z.touch1=V,z.taps=0):(z.touch0=V,H=!0,z.taps=1+!!f);f&&(f=clearTimeout(f)),H&&(z.taps<2&&(p=V[0],f=setTimeout(function(){f=null},w)),$f(this),z.start())}}function M(T,...P){if(this.__zooming){var q=R(this,P).event(T),K=T.changedTouches,z=K.length,H,D,O,V;for(su(T),H=0;H<z;++H)D=K[H],O=Vs(D,this),q.touch0&&q.touch0[2]===D.identifier?q.touch0[0]=O:q.touch1&&q.touch1[2]===D.identifier&&(q.touch1[0]=O);if(D=q.that.__zoom,q.touch1){var Z=q.touch0[0],W=q.touch0[1],X=q.touch1[0],Y=q.touch1[1],J=(J=X[0]-Z[0])*J+(J=X[1]-Z[1])*J,Q=(Q=Y[0]-W[0])*Q+(Q=Y[1]-W[1])*Q;D=v(D,Math.sqrt(J/Q)),O=[(Z[0]+X[0])/2,(Z[1]+X[1])/2],V=[(W[0]+Y[0])/2,(W[1]+Y[1])/2]}else if(q.touch0)O=q.touch0[0],V=q.touch0[1];else return;q.zoom("touch",n(S(D,O,V),q.extent,i))}}function B(T,...P){if(this.__zooming){var q=R(this,P).event(T),K=T.changedTouches,z=K.length,H,D;for(Wy(T),m&&clearTimeout(m),m=setTimeout(function(){m=null},w),H=0;H<z;++H)D=K[H],q.touch0&&q.touch0[2]===D.identifier?delete q.touch0:q.touch1&&q.touch1[2]===D.identifier&&delete q.touch1;if(q.touch1&&!q.touch0&&(q.touch0=q.touch1,delete q.touch1),q.touch0)q.touch0[1]=this.__zoom.invert(q.touch0[0]);else if(q.end(),q.taps===2&&(D=Vs(D,this),Math.hypot(p[0]-D[0],p[1]-D[1])<j)){var O=ms(this).on("dblclick.zoom");O&&O.apply(this,arguments)}}}return k.wheelDelta=function(T){return arguments.length?(s=typeof T=="function"?T:Jh(+T),k):s},k.filter=function(T){return arguments.length?(e=typeof T=="function"?T:Jh(!!T),k):e},k.touchable=function(T){return arguments.length?(a=typeof T=="function"?T:Jh(!!T),k):a},k.extent=function(T){return arguments.length?(t=typeof T=="function"?T:Jh([[+T[0][0],+T[0][1]],[+T[1][0],+T[1][1]]]),k):t},k.scaleExtent=function(T){return arguments.length?(o[0]=+T[0],o[1]=+T[1],k):[o[0],o[1]]},k.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],k):[[i[0][0],i[0][1]],[i[1][0],i[1][1]]]},k.constrain=function(T){return arguments.length?(n=T,k):n},k.duration=function(T){return arguments.length?(l=+T,k):l},k.interpolate=function(T){return arguments.length?(u=T,k):u},k.on=function(){var T=d.on.apply(d,arguments);return T===d?k:T},k.clickDistance=function(T){return arguments.length?(b=(T=+T)*T,k):Math.sqrt(b)},k.tapDistance=function(T){return arguments.length?(j=+T,k):j},k}var vt=v3();const zp=g.createContext(null),N7=zp.Provider,la={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.`},X3=la.error001();function ft(e,t){const n=g.useContext(zp);if(n===null)throw new Error(X3);return b3(n,e,t)}const Ht=()=>{const e=g.useContext(zp);if(e===null)throw new Error(X3);return g.useMemo(()=>({getState:e.getState,setState:e.setState,subscribe:e.subscribe,destroy:e.destroy}),[e])},S7=e=>e.userSelectionActive?"none":"all";function Xj({position:e,children:t,className:n,style:s,...a}){const o=ft(S7),i=`${e}`.split("-");return me.createElement("div",{className:mn(["react-flow__panel",n,...i]),style:{...s,pointerEvents:o},...a},t)}function C7({proOptions:e,position:t="bottom-right"}){return e!=null&&e.hideAttribution?null:me.createElement(Xj,{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 _7=({x:e,y:t,label:n,labelStyle:s={},labelShowBg:a=!0,labelBgStyle:o={},labelBgPadding:i=[2,4],labelBgBorderRadius:l=2,children:u,className:d,...f})=>{const p=g.useRef(null),[m,w]=g.useState({x:0,y:0,width:0,height:0}),x=mn(["react-flow__edge-textwrapper",d]);return g.useEffect(()=>{if(p.current){const b=p.current.getBBox();w({x:b.x,y:b.y,width:b.width,height:b.height})}},[n]),typeof n>"u"||!n?null:me.createElement("g",{transform:`translate(${e-m.width/2} ${t-m.height/2})`,className:x,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 E7=g.memo(_7);const Zj=e=>({width:e.offsetWidth,height:e.offsetHeight}),Bl=(e,t=0,n=1)=>Math.min(Math.max(e,t),n),Jj=(e={x:0,y:0},t)=>({x:Bl(e.x,t[0][0],t[1][0]),y:Bl(e.y,t[0][1],t[1][1])}),CE=(e,t,n)=>e<t?Bl(Math.abs(e-t),1,50)/50:e>n?-Bl(Math.abs(e-n),1,50)/50:0,Z3=(e,t)=>{const n=CE(e.x,35,t.width-35)*20,s=CE(e.y,35,t.height-35)*20;return[n,s]},J3=e=>{var t;return((t=e.getRootNode)==null?void 0:t.call(e))||(window==null?void 0:window.document)},Q3=(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)}),Ku=({x:e,y:t,width:n,height:s})=>({x:e,y:t,x2:e+n,y2:t+s}),e4=({x:e,y:t,x2:n,y2:s})=>({x:e,y:t,width:n-e,height:s-t}),_E=e=>({...e.positionAbsolute||{x:0,y:0},width:e.width||0,height:e.height||0}),T7=(e,t)=>e4(Q3(Ku(e),Ku(t))),y1=(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)},A7=e=>gs(e.width)&&gs(e.height)&&gs(e.x)&&gs(e.y),gs=e=>!isNaN(e)&&isFinite(e),Ft=Symbol.for("internals"),t4=["Enter"," ","Escape"],R7=(e,t)=>{},M7=e=>"nativeEvent"in e;function w1(e){var a,o;const t=M7(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 n4=e=>"clientX"in e,Za=(e,t)=>{var o,i;const n=n4(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)}},Qf=()=>{var e;return typeof navigator<"u"&&((e=navigator==null?void 0:navigator.userAgent)==null?void 0:e.indexOf("Mac"))>=0},wd=({id:e,path:t,labelX:n,labelY:s,label:a,labelStyle:o,labelShowBg:i,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,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&&gs(n)&&gs(s)?me.createElement(E7,{x:n,y:s,label:a,labelStyle:o,labelShowBg:i,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d}):null);wd.displayName="BaseEdge";function ru(e,t,n){return n===void 0?n:s=>{const a=t().edges.find(o=>o.id===e);a&&n(s,{...a})}}function s4({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 r4({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,d=t*.125+o*.375+l*.375+s*.125,f=Math.abs(u-e),p=Math.abs(d-t);return[u,d,f,p]}var li;(function(e){e.Strict="strict",e.Loose="loose"})(li||(li={}));var Xo;(function(e){e.Free="free",e.Vertical="vertical",e.Horizontal="horizontal"})(Xo||(Xo={}));var Yu;(function(e){e.Partial="partial",e.Full="full"})(Yu||(Yu={}));var Va;(function(e){e.Bezier="default",e.Straight="straight",e.Step="step",e.SmoothStep="smoothstep",e.SimpleBezier="simplebezier"})(Va||(Va={}));var ep;(function(e){e.Arrow="arrow",e.ArrowClosed="arrowclosed"})(ep||(ep={}));var Ye;(function(e){e.Left="left",e.Top="top",e.Right="right",e.Bottom="bottom"})(Ye||(Ye={}));function EE({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 a4({sourceX:e,sourceY:t,sourcePosition:n=Ye.Bottom,targetX:s,targetY:a,targetPosition:o=Ye.Top}){const[i,l]=EE({pos:n,x1:e,y1:t,x2:s,y2:a}),[u,d]=EE({pos:o,x1:s,y1:a,x2:e,y2:t}),[f,p,m,w]=r4({sourceX:e,sourceY:t,targetX:s,targetY:a,sourceControlX:i,sourceControlY:l,targetControlX:u,targetControlY:d});return[`M${e},${t} C${i},${l} ${u},${d} ${s},${a}`,f,p,m,w]}const Qj=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:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:w,markerStart:x,interactionWidth:b})=>{const[j,k,v]=a4({sourceX:e,sourceY:t,sourcePosition:a,targetX:n,targetY:s,targetPosition:o});return me.createElement(wd,{path:j,labelX:k,labelY:v,label:i,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:w,markerStart:x,interactionWidth:b})});Qj.displayName="SimpleBezierEdge";const TE={[Ye.Left]:{x:-1,y:0},[Ye.Right]:{x:1,y:0},[Ye.Top]:{x:0,y:-1},[Ye.Bottom]:{x:0,y:1}},$7=({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},AE=(e,t)=>Math.sqrt(Math.pow(t.x-e.x,2)+Math.pow(t.y-e.y,2));function L7({source:e,sourcePosition:t=Ye.Bottom,target:n,targetPosition:s=Ye.Top,center:a,offset:o}){const i=TE[t],l=TE[s],u={x:e.x+i.x*o,y:e.y+i.y*o},d={x:n.x+l.x*o,y:n.y+l.y*o},f=$7({source:u,sourcePosition:t,target:d}),p=f.x!==0?"x":"y",m=f[p];let w=[],x,b;const j={x:0,y:0},k={x:0,y:0},[v,S,C,_]=s4({sourceX:e.x,sourceY:e.y,targetX:n.x,targetY:n.y});if(i[p]*l[p]===-1){x=a.x??v,b=a.y??S;const A=[{x,y:u.y},{x,y:d.y}],I=[{x:u.x,y:b},{x:d.x,y:b}];i[p]===m?w=p==="x"?A:I:w=p==="x"?I:A}else{const A=[{x:u.x,y:d.y}],I=[{x:d.x,y:u.y}];if(p==="x"?w=i.x===m?I:A:w=i.y===m?A:I,t===s){const B=Math.abs(e[p]-n[p]);if(B<=o){const T=Math.min(o-1,o-B);i[p]===m?j[p]=(u[p]>e[p]?-1:1)*T:k[p]=(d[p]>n[p]?-1:1)*T}}if(t!==s){const B=p==="x"?"y":"x",T=i[p]===l[B],P=u[B]>d[B],q=u[B]<d[B];(i[p]===1&&(!T&&P||T&&q)||i[p]!==1&&(!T&&q||T&&P))&&(w=p==="x"?A:I)}const $={x:u.x+j.x,y:u.y+j.y},U={x:d.x+k.x,y:d.y+k.y},F=Math.max(Math.abs($.x-w[0].x),Math.abs(U.x-w[0].x)),M=Math.max(Math.abs($.y-w[0].y),Math.abs(U.y-w[0].y));F>=M?(x=($.x+U.x)/2,b=w[0].y):(x=w[0].x,b=($.y+U.y)/2)}return[[e,{x:u.x+j.x,y:u.y+j.y},...w,{x:d.x+k.x,y:d.y+k.y},n],x,b,C,_]}function I7(e,t,n,s){const a=Math.min(AE(e,t)/2,AE(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 d=e.x<n.x?-1:1,f=e.y<n.y?1:-1;return`L ${o+a*d},${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 x1({sourceX:e,sourceY:t,sourcePosition:n=Ye.Bottom,targetX:s,targetY:a,targetPosition:o=Ye.Top,borderRadius:i=5,centerX:l,centerY:u,offset:d=20}){const[f,p,m,w,x]=L7({source:{x:e,y:t},sourcePosition:n,target:{x:s,y:a},targetPosition:o,center:{x:l,y:u},offset:d});return[f.reduce((j,k,v)=>{let S="";return v>0&&v<f.length-1?S=I7(f[v-1],k,f[v+1],i):S=`${v===0?"M":"L"}${k.x} ${k.y}`,j+=S,j},""),p,m,w,x]}const Vp=g.memo(({sourceX:e,sourceY:t,targetX:n,targetY:s,label:a,labelStyle:o,labelShowBg:i,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,sourcePosition:p=Ye.Bottom,targetPosition:m=Ye.Top,markerEnd:w,markerStart:x,pathOptions:b,interactionWidth:j})=>{const[k,v,S]=x1({sourceX:e,sourceY:t,sourcePosition:p,targetX:n,targetY:s,targetPosition:m,borderRadius:b==null?void 0:b.borderRadius,offset:b==null?void 0:b.offset});return me.createElement(wd,{path:k,labelX:v,labelY:S,label:a,labelStyle:o,labelShowBg:i,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:w,markerStart:x,interactionWidth:j})});Vp.displayName="SmoothStepEdge";const eN=g.memo(e=>{var t;return me.createElement(Vp,{...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])})});eN.displayName="StepEdge";function O7({sourceX:e,sourceY:t,targetX:n,targetY:s}){const[a,o,i,l]=s4({sourceX:e,sourceY:t,targetX:n,targetY:s});return[`M ${e},${t}L ${n},${s}`,a,o,i,l]}const tN=g.memo(({sourceX:e,sourceY:t,targetX:n,targetY:s,label:a,labelStyle:o,labelShowBg:i,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:m,interactionWidth:w})=>{const[x,b,j]=O7({sourceX:e,sourceY:t,targetX:n,targetY:s});return me.createElement(wd,{path:x,labelX:b,labelY:j,label:a,labelStyle:o,labelShowBg:i,labelBgStyle:l,labelBgPadding:u,labelBgBorderRadius:d,style:f,markerEnd:p,markerStart:m,interactionWidth:w})});tN.displayName="StraightEdge";function Qh(e,t){return e>=0?.5*e:t*25*Math.sqrt(-e)}function RE({pos:e,x1:t,y1:n,x2:s,y2:a,c:o}){switch(e){case Ye.Left:return[t-Qh(t-s,o),n];case Ye.Right:return[t+Qh(s-t,o),n];case Ye.Top:return[t,n-Qh(n-a,o)];case Ye.Bottom:return[t,n+Qh(a-n,o)]}}function nN({sourceX:e,sourceY:t,sourcePosition:n=Ye.Bottom,targetX:s,targetY:a,targetPosition:o=Ye.Top,curvature:i=.25}){const[l,u]=RE({pos:n,x1:e,y1:t,x2:s,y2:a,c:i}),[d,f]=RE({pos:o,x1:s,y1:a,x2:e,y2:t,c:i}),[p,m,w,x]=r4({sourceX:e,sourceY:t,targetX:s,targetY:a,sourceControlX:l,sourceControlY:u,targetControlX:d,targetControlY:f});return[`M${e},${t} C${l},${u} ${d},${f} ${s},${a}`,p,m,w,x]}const tp=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:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:w,markerStart:x,pathOptions:b,interactionWidth:j})=>{const[k,v,S]=nN({sourceX:e,sourceY:t,sourcePosition:a,targetX:n,targetY:s,targetPosition:o,curvature:b==null?void 0:b.curvature});return me.createElement(wd,{path:k,labelX:v,labelY:S,label:i,labelStyle:l,labelShowBg:u,labelBgStyle:d,labelBgPadding:f,labelBgBorderRadius:p,style:m,markerEnd:w,markerStart:x,interactionWidth:j})});tp.displayName="BezierEdge";const sN=g.createContext(null),P7=sN.Provider;sN.Consumer;const D7=()=>g.useContext(sN),F7=e=>"id"in e&&"source"in e&&"target"in e,B7=({source:e,sourceHandle:t,target:n,targetHandle:s})=>`reactflow__edge-${e}${t||""}-${n}${s||""}`,v1=(e,t)=>typeof e>"u"?"":typeof e=="string"?e:`${t?`${t}__`:""}${Object.keys(e).sort().map(s=>`${s}=${e[s]}`).join("&")}`,q7=(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)),U7=(e,t)=>{if(!e.source||!e.target)return t;let n;return F7(e)?n={...e}:n={...e,id:B7(e)},q7(n,t)?t:t.concat(n)},b1=({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},o4=({x:e,y:t},[n,s,a])=>({x:e*a+n,y:t*a+s}),ei=(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}},Gp=(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}=ei(a,t).positionAbsolute;return Q3(s,Ku({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 e4(n)},i4=(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},d=[];return e.forEach(f=>{const{width:p,height:m,selectable:w=!0,hidden:x=!1}=f;if(i&&!w||x)return!1;const{positionAbsolute:b}=ei(f,l),j={x:b.x,y:b.y,width:p||0,height:m||0},k=y1(u,j),v=typeof p>"u"||typeof m>"u"||p===null||m===null,S=o&&k>0,C=(p||0)*(m||0);(v||S||k>=C||f.dragging)&&d.push(f)}),d},l4=(e,t)=>{const n=e.map(s=>s.id);return t.filter(s=>n.includes(s.source)||n.includes(s.target))},c4=(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),d=Bl(u,s,a),f=e.x+e.width/2,p=e.y+e.height/2,m=t/2-f*d,w=n/2-p*d;return{x:m,y:w,zoom:d}},Wo=(e,t=0)=>e.transition().duration(t);function ME(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 W7(e,t,n,s,a,o){const{x:i,y:l}=Za(e),d=t.elementsFromPoint(i,l).find(x=>x.classList.contains("react-flow__handle"));if(d){const x=d.getAttribute("data-nodeid");if(x){const b=rN(void 0,d),j=d.getAttribute("data-handleid"),k=o({nodeId:x,id:j,type:b});if(k){const v=a.find(S=>S.nodeId===x&&S.type===b&&S.id===j);return{handle:{id:j,type:b,nodeId:x,x:(v==null?void 0:v.x)||n.x,y:(v==null?void 0:v.y)||n.y},validHandleResult:k}}}}let f=[],p=1/0;if(a.forEach(x=>{const b=Math.sqrt((x.x-n.x)**2+(x.y-n.y)**2);if(b<=s){const j=o(x);b<=p&&(b<p?f=[{handle:x,validHandleResult:j}]:b===p&&f.push({handle:x,validHandleResult:j}),p=b)}}),!f.length)return{handle:null,validHandleResult:u4()};if(f.length===1)return f[0];const m=f.some(({validHandleResult:x})=>x.isValid),w=f.some(({handle:x})=>x.type==="target");return f.find(({handle:x,validHandleResult:b})=>w?x.type==="target":m?b.isValid:!0)||f[0]}const H7={source:null,target:null,sourceHandle:null,targetHandle:null},u4=()=>({handleDomNode:null,isValid:!1,connection:H7,endHandle:null});function d4(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}"]`),d={...u4(),handleDomNode:u};if(u){const f=rN(void 0,u),p=u.getAttribute("data-nodeid"),m=u.getAttribute("data-handleid"),w=u.classList.contains("connectable"),x=u.classList.contains("connectableend"),b={source:l?p:n,sourceHandle:l?m:s,target:l?n:p,targetHandle:l?s:m};d.connection=b,w&&x&&(t===li.Strict?l&&f==="source"||!l&&f==="target":p!==n||m!==s)&&(d.endHandle={nodeId:p,handleId:m,type:f},d.isValid=o(b))}return d}function z7({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=ME(o,i,"source",`${t}-${n}-${s}`),u=ME(o,i,"target",`${t}-${n}-${s}`)),a.push(...l,...u)}return a},[])}function rN(e,t){return e||(t!=null&&t.classList.contains("target")?"target":t!=null&&t.classList.contains("source")?"source":null)}function Hy(e){e==null||e.classList.remove("valid","connecting","react-flow__handle-valid","react-flow__handle-connecting")}function V7(e,t){let n=null;return t?n="valid":e&&!t&&(n="invalid"),n}function h4({event:e,handleId:t,nodeId:n,onConnect:s,isTarget:a,getState:o,setState:i,isValidConnection:l,edgeUpdaterType:u,onReconnectEnd:d}){const f=J3(e.target),{connectionMode:p,domNode:m,autoPanOnConnect:w,connectionRadius:x,onConnectStart:b,panBy:j,getNodes:k,cancelConnection:v}=o();let S=0,C;const{x:_,y:R}=Za(e),A=f==null?void 0:f.elementFromPoint(_,R),I=rN(u,A),$=m==null?void 0:m.getBoundingClientRect();if(!$||!I)return;let U,F=Za(e,$),M=!1,B=null,T=!1,P=null;const q=z7({nodes:k(),nodeId:n,handleId:t,handleType:I}),K=()=>{if(!w)return;const[D,O]=Z3(F,$);j({x:D,y:O}),S=requestAnimationFrame(K)};i({connectionPosition:F,connectionStatus:null,connectionNodeId:n,connectionHandleId:t,connectionHandleType:I,connectionStartHandle:{nodeId:n,handleId:t,type:I},connectionEndHandle:null}),b==null||b(e,{nodeId:n,handleId:t,handleType:I});function z(D){const{transform:O}=o();F=Za(D,$);const{handle:V,validHandleResult:Z}=W7(D,f,b1(F,O,!1,[1,1]),x,q,W=>d4(W,p,n,t,a?"target":"source",l,f));if(C=V,M||(K(),M=!0),P=Z.handleDomNode,B=Z.connection,T=Z.isValid,i({connectionPosition:C&&T?o4({x:C.x,y:C.y},O):F,connectionStatus:V7(!!C,T),connectionEndHandle:Z.endHandle}),!C&&!T&&!P)return Hy(U);B.source!==B.target&&P&&(Hy(U),U=P,P.classList.add("connecting","react-flow__handle-connecting"),P.classList.toggle("valid",T),P.classList.toggle("react-flow__handle-valid",T))}function H(D){var O,V;(C||P)&&B&&T&&(s==null||s(B)),(V=(O=o()).onConnectEnd)==null||V.call(O,D),u&&(d==null||d(D)),Hy(U),v(),cancelAnimationFrame(S),M=!1,T=!1,B=null,P=null,f.removeEventListener("mousemove",z),f.removeEventListener("mouseup",H),f.removeEventListener("touchmove",z),f.removeEventListener("touchend",H)}f.addEventListener("mousemove",z),f.addEventListener("mouseup",H),f.addEventListener("touchmove",z),f.addEventListener("touchend",H)}const $E=()=>!0,G7=e=>({connectionStartHandle:e.connectionStartHandle,connectOnClick:e.connectOnClick,noPanClassName:e.noPanClassName}),K7=(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}},f4=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:d,onMouseDown:f,onTouchStart:p,...m},w)=>{var $,U;const x=i||null,b=e==="target",j=Ht(),k=D7(),{connectOnClick:v,noPanClassName:S}=ft(G7,nn),{connecting:C,clickConnecting:_}=ft(K7(k,x,e),nn);k||(U=($=j.getState()).onError)==null||U.call($,"010",la.error010());const R=F=>{const{defaultEdgeOptions:M,onConnect:B,hasDefaultEdges:T}=j.getState(),P={...M,...F};if(T){const{edges:q,setEdges:K}=j.getState();K(U7(P,q))}B==null||B(P),l==null||l(P)},A=F=>{if(!k)return;const M=n4(F);a&&(M&&F.button===0||!M)&&h4({event:F,handleId:x,nodeId:k,onConnect:R,isTarget:b,getState:j.getState,setState:j.setState,isValidConnection:n||j.getState().isValidConnection||$E}),M?f==null||f(F):p==null||p(F)},I=F=>{const{onClickConnectStart:M,onClickConnectEnd:B,connectionClickStartHandle:T,connectionMode:P,isValidConnection:q}=j.getState();if(!k||!T&&!a)return;if(!T){M==null||M(F,{nodeId:k,handleId:x,handleType:e}),j.setState({connectionClickStartHandle:{nodeId:k,type:e,handleId:x}});return}const K=J3(F.target),z=n||q||$E,{connection:H,isValid:D}=d4({nodeId:k,id:x,type:e},P,T.nodeId,T.handleId||null,T.type,z,K);D&&R(H),B==null||B(F),j.setState({connectionClickStartHandle:null})};return me.createElement("div",{"data-handleid":x,"data-nodeid":k,"data-handlepos":t,"data-id":`${k}-${x}-${e}`,className:mn(["react-flow__handle",`react-flow__handle-${t}`,"nodrag",S,d,{source:!b,target:b,connectable:s,connectablestart:a,connectableend:o,connecting:_,connectionindicator:s&&(a&&!C||o&&C)}]),onMouseDown:A,onTouchStart:A,onClick:v?I:void 0,ref:w,...m},u)});f4.displayName="Handle";var ci=g.memo(f4);const p4=({data:e,isConnectable:t,targetPosition:n=Ye.Top,sourcePosition:s=Ye.Bottom})=>me.createElement(me.Fragment,null,me.createElement(ci,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label,me.createElement(ci,{type:"source",position:s,isConnectable:t}));p4.displayName="DefaultNode";var k1=g.memo(p4);const m4=({data:e,isConnectable:t,sourcePosition:n=Ye.Bottom})=>me.createElement(me.Fragment,null,e==null?void 0:e.label,me.createElement(ci,{type:"source",position:n,isConnectable:t}));m4.displayName="InputNode";var g4=g.memo(m4);const y4=({data:e,isConnectable:t,targetPosition:n=Ye.Top})=>me.createElement(me.Fragment,null,me.createElement(ci,{type:"target",position:n,isConnectable:t}),e==null?void 0:e.label);y4.displayName="OutputNode";var w4=g.memo(y4);const aN=()=>null;aN.displayName="GroupNode";const Y7=e=>({selectedNodes:e.getNodes().filter(t=>t.selected),selectedEdges:e.edges.filter(t=>t.selected).map(t=>({...t}))}),ef=e=>e.id;function X7(e,t){return nn(e.selectedNodes.map(ef),t.selectedNodes.map(ef))&&nn(e.selectedEdges.map(ef),t.selectedEdges.map(ef))}const x4=g.memo(({onSelectionChange:e})=>{const t=Ht(),{selectedNodes:n,selectedEdges:s}=ft(Y7,X7);return g.useEffect(()=>{const a={nodes:n,edges:s};e==null||e(a),t.getState().onSelectionChange.forEach(o=>o(a))},[n,s,e]),null});x4.displayName="SelectionListener";const Z7=e=>!!e.onSelectionChange;function J7({onSelectionChange:e}){const t=ft(Z7);return e||t?me.createElement(x4,{onSelectionChange:e}):null}const Q7=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 tl(e,t){g.useEffect(()=>{typeof e<"u"&&t(e)},[e])}function it(e,t,n){g.useEffect(()=>{typeof t<"u"&&n({[e]:t})},[t])}const ez=({nodes:e,edges:t,defaultNodes:n,defaultEdges:s,onConnect:a,onConnectStart:o,onConnectEnd:i,onClickConnectStart:l,onClickConnectEnd:u,nodesDraggable:d,nodesConnectable:f,nodesFocusable:p,edgesFocusable:m,edgesUpdatable:w,elevateNodesOnSelect:x,minZoom:b,maxZoom:j,nodeExtent:k,onNodesChange:v,onEdgesChange:S,elementsSelectable:C,connectionMode:_,snapGrid:R,snapToGrid:A,translateExtent:I,connectOnClick:$,defaultEdgeOptions:U,fitView:F,fitViewOptions:M,onNodesDelete:B,onEdgesDelete:T,onNodeDrag:P,onNodeDragStart:q,onNodeDragStop:K,onSelectionDrag:z,onSelectionDragStart:H,onSelectionDragStop:D,noPanClassName:O,nodeOrigin:V,rfId:Z,autoPanOnConnect:W,autoPanOnNodeDrag:X,onError:Y,connectionRadius:J,isValidConnection:Q,nodeDragThreshold:te})=>{const{setNodes:le,setEdges:de,setDefaultNodesAndEdges:oe,setMinZoom:re,setMaxZoom:he,setTranslateExtent:fe,setNodeExtent:$e,reset:ye}=ft(Q7,nn),ge=Ht();return g.useEffect(()=>{const je=s==null?void 0:s.map(Le=>({...Le,...U}));return oe(n,je),()=>{ye()}},[]),it("defaultEdgeOptions",U,ge.setState),it("connectionMode",_,ge.setState),it("onConnect",a,ge.setState),it("onConnectStart",o,ge.setState),it("onConnectEnd",i,ge.setState),it("onClickConnectStart",l,ge.setState),it("onClickConnectEnd",u,ge.setState),it("nodesDraggable",d,ge.setState),it("nodesConnectable",f,ge.setState),it("nodesFocusable",p,ge.setState),it("edgesFocusable",m,ge.setState),it("edgesUpdatable",w,ge.setState),it("elementsSelectable",C,ge.setState),it("elevateNodesOnSelect",x,ge.setState),it("snapToGrid",A,ge.setState),it("snapGrid",R,ge.setState),it("onNodesChange",v,ge.setState),it("onEdgesChange",S,ge.setState),it("connectOnClick",$,ge.setState),it("fitViewOnInit",F,ge.setState),it("fitViewOnInitOptions",M,ge.setState),it("onNodesDelete",B,ge.setState),it("onEdgesDelete",T,ge.setState),it("onNodeDrag",P,ge.setState),it("onNodeDragStart",q,ge.setState),it("onNodeDragStop",K,ge.setState),it("onSelectionDrag",z,ge.setState),it("onSelectionDragStart",H,ge.setState),it("onSelectionDragStop",D,ge.setState),it("noPanClassName",O,ge.setState),it("nodeOrigin",V,ge.setState),it("rfId",Z,ge.setState),it("autoPanOnConnect",W,ge.setState),it("autoPanOnNodeDrag",X,ge.setState),it("onError",Y,ge.setState),it("connectionRadius",J,ge.setState),it("isValidConnection",Q,ge.setState),it("nodeDragThreshold",te,ge.setState),tl(e,le),tl(t,de),tl(b,re),tl(j,he),tl(I,fe),tl(k,$e),null},LE={display:"none"},tz={position:"absolute",width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0px, 0px, 0px, 0px)",clipPath:"inset(100%)"},v4="react-flow__node-desc",b4="react-flow__edge-desc",nz="react-flow__aria-live",sz=e=>e.ariaLiveMessage;function rz({rfId:e}){const t=ft(sz);return me.createElement("div",{id:`${nz}-${e}`,"aria-live":"assertive","aria-atomic":"true",style:tz},t)}function az({rfId:e,disableKeyboardA11y:t}){return me.createElement(me.Fragment,null,me.createElement("div",{id:`${v4}-${e}`,style:LE},"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:`${b4}-${e}`,style:LE},"Press enter or space to select an edge. You can then press delete to remove it or escape to cancel."),!t&&me.createElement(rz,{rfId:e}))}var Xu=(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 d=(Array.isArray(e)?e:[e]).filter(p=>typeof p=="string").map(p=>p.split("+")),f=d.reduce((p,m)=>p.concat(...m),[]);return[d,f]}return[[],[]]},[e]);return g.useEffect(()=>{const u=typeof document<"u"?document:null,d=(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)&&w1(w))return!1;const b=OE(w.code,l);o.current.add(w[b]),IE(i,o.current,!1)&&(w.preventDefault(),s(!0))},p=w=>{if((!a.current||a.current&&!t.actInsideInputWithModifier)&&w1(w))return!1;const b=OE(w.code,l);IE(i,o.current,!0)?(s(!1),o.current.clear()):o.current.delete(w[b]),w.key==="Meta"&&o.current.clear(),a.current=!1},m=()=>{o.current.clear(),s(!1)};return d==null||d.addEventListener("keydown",f),d==null||d.addEventListener("keyup",p),window.addEventListener("blur",m),()=>{d==null||d.removeEventListener("keydown",f),d==null||d.removeEventListener("keyup",p),window.removeEventListener("blur",m)}}},[e,s]),n};function IE(e,t,n){return e.filter(s=>n||s.length===t.size).some(s=>s.every(a=>t.has(a)))}function OE(e,t){return t.includes(e)?"code":"key"}function k4(e,t,n,s){var l,u;const a=e.parentNode||e.parentId;if(!a)return n;const o=t.get(a),i=ei(o,s);return k4(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 j4(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}=k4(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 zy(e,t,n,s){const a=new Map,o={},i=s?1e3:0;return e.forEach(l=>{var w;const u=(gs(l.zIndex)?l.zIndex:0)+(l.selected?i:0),d=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=(d==null?void 0:d.type)&&(d==null?void 0:d.type)!==l.type;Object.defineProperty(f,Ft,{enumerable:!1,value:{handleBounds:m||(w=d==null?void 0:d[Ft])==null?void 0:w.handleBounds,z:u}}),a.set(l.id,f)}),j4(a,n,o),a}function N4(e,t={}){const{getNodes:n,width:s,height:a,minZoom:o,maxZoom:i,d3Zoom:l,d3Selection:u,fitViewOnInitDone:d,fitViewOnInit:f,nodeOrigin:p}=e(),m=t.initial&&!d&&f;if(l&&u&&(m||!t.initial)){const x=n().filter(j=>{var v;const k=t.includeHiddenNodes?j.width&&j.height:!j.hidden;return(v=t.nodes)!=null&&v.length?k&&t.nodes.some(S=>S.id===j.id):k}),b=x.every(j=>j.width&&j.height);if(x.length>0&&b){const j=Gp(x,p),{x:k,y:v,zoom:S}=c4(j,s,a,t.minZoom??o,t.maxZoom??i,t.padding??.1),C=sa.translate(k,v).scale(S);return typeof t.duration=="number"&&t.duration>0?l.transform(Wo(u,t.duration),C):l.transform(u,C),!0}}return!1}function oz(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 iz(e,t){return t.map(n=>{const s=e.find(a=>a.id===n.id);return s&&(n.selected=s.selected),n})}function tf({changedNodes:e,changedEdges:t,get:n,set:s}){const{nodeInternals:a,edges:o,onNodesChange:i,onEdgesChange:l,hasDefaultNodes:u,hasDefaultEdges:d}=n();e!=null&&e.length&&(u&&s({nodeInternals:oz(e,a)}),i==null||i(e)),t!=null&&t.length&&(d&&s({edges:iz(t,o)}),l==null||l(t))}const nl=()=>{},lz={zoomIn:nl,zoomOut:nl,zoomTo:nl,getZoom:()=>1,setViewport:nl,getViewport:()=>({x:0,y:0,zoom:1}),fitView:()=>!1,setCenter:nl,fitBounds:nl,project:e=>e,screenToFlowPosition:e=>e,flowToScreenPosition:e=>e,viewportInitialized:!1},cz=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection}),uz=()=>{const e=Ht(),{d3Zoom:t,d3Selection:n}=ft(cz,nn);return g.useMemo(()=>n&&t?{zoomIn:a=>t.scaleBy(Wo(n,a==null?void 0:a.duration),1.2),zoomOut:a=>t.scaleBy(Wo(n,a==null?void 0:a.duration),1/1.2),zoomTo:(a,o)=>t.scaleTo(Wo(n,o==null?void 0:o.duration),a),getZoom:()=>e.getState().transform[2],setViewport:(a,o)=>{const[i,l,u]=e.getState().transform,d=sa.translate(a.x??i,a.y??l).scale(a.zoom??u);t.transform(Wo(n,o==null?void 0:o.duration),d)},getViewport:()=>{const[a,o,i]=e.getState().transform;return{x:a,y:o,zoom:i}},fitView:a=>N4(e.getState,a),setCenter:(a,o,i)=>{const{width:l,height:u,maxZoom:d}=e.getState(),f=typeof(i==null?void 0:i.zoom)<"u"?i.zoom:d,p=l/2-a*f,m=u/2-o*f,w=sa.translate(p,m).scale(f);t.transform(Wo(n,i==null?void 0:i.duration),w)},fitBounds:(a,o)=>{const{width:i,height:l,minZoom:u,maxZoom:d}=e.getState(),{x:f,y:p,zoom:m}=c4(a,i,l,u,d,(o==null?void 0:o.padding)??.1),w=sa.translate(f,p).scale(m);t.transform(Wo(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"),b1(a,o,i,l)},screenToFlowPosition:a=>{const{transform:o,snapToGrid:i,snapGrid:l,domNode:u}=e.getState();if(!u)return a;const{x:d,y:f}=u.getBoundingClientRect(),p={x:a.x-d,y:a.y-f};return b1(p,o,i,l)},flowToScreenPosition:a=>{const{transform:o,domNode:i}=e.getState();if(!i)return a;const{x:l,y:u}=i.getBoundingClientRect(),d=o4(a,o);return{x:d.x+l,y:d.y+u}},viewportInitialized:!0}:lz,[t,n])};function Ql(){const e=uz(),t=Ht(),n=g.useCallback(()=>t.getState().getNodes().map(b=>({...b})),[]),s=g.useCallback(b=>t.getState().nodeInternals.get(b),[]),a=g.useCallback(()=>{const{edges:b=[]}=t.getState();return b.map(j=>({...j}))},[]),o=g.useCallback(b=>{const{edges:j=[]}=t.getState();return j.find(k=>k.id===b)},[]),i=g.useCallback(b=>{const{getNodes:j,setNodes:k,hasDefaultNodes:v,onNodesChange:S}=t.getState(),C=j(),_=typeof b=="function"?b(C):b;if(v)k(_);else if(S){const R=_.length===0?C.map(A=>({type:"remove",id:A.id})):_.map(A=>({item:A,type:"reset"}));S(R)}},[]),l=g.useCallback(b=>{const{edges:j=[],setEdges:k,hasDefaultEdges:v,onEdgesChange:S}=t.getState(),C=typeof b=="function"?b(j):b;if(v)k(C);else if(S){const _=C.length===0?j.map(R=>({type:"remove",id:R.id})):C.map(R=>({item:R,type:"reset"}));S(_)}},[]),u=g.useCallback(b=>{const j=Array.isArray(b)?b:[b],{getNodes:k,setNodes:v,hasDefaultNodes:S,onNodesChange:C}=t.getState();if(S){const R=[...k(),...j];v(R)}else if(C){const _=j.map(R=>({item:R,type:"add"}));C(_)}},[]),d=g.useCallback(b=>{const j=Array.isArray(b)?b:[b],{edges:k=[],setEdges:v,hasDefaultEdges:S,onEdgesChange:C}=t.getState();if(S)v([...k,...j]);else if(C){const _=j.map(R=>({item:R,type:"add"}));C(_)}},[]),f=g.useCallback(()=>{const{getNodes:b,edges:j=[],transform:k}=t.getState(),[v,S,C]=k;return{nodes:b().map(_=>({..._})),edges:j.map(_=>({..._})),viewport:{x:v,y:S,zoom:C}}},[]),p=g.useCallback(({nodes:b,edges:j})=>{const{nodeInternals:k,getNodes:v,edges:S,hasDefaultNodes:C,hasDefaultEdges:_,onNodesDelete:R,onEdgesDelete:A,onNodesChange:I,onEdgesChange:$}=t.getState(),U=(b||[]).map(P=>P.id),F=(j||[]).map(P=>P.id),M=v().reduce((P,q)=>{const K=q.parentNode||q.parentId,z=!U.includes(q.id)&&K&&P.find(D=>D.id===K);return(typeof q.deletable=="boolean"?q.deletable:!0)&&(U.includes(q.id)||z)&&P.push(q),P},[]),B=S.filter(P=>typeof P.deletable=="boolean"?P.deletable:!0),T=B.filter(P=>F.includes(P.id));if(M||T){const P=l4(M,B),q=[...T,...P],K=q.reduce((z,H)=>(z.includes(H.id)||z.push(H.id),z),[]);if((_||C)&&(_&&t.setState({edges:S.filter(z=>!K.includes(z.id))}),C&&(M.forEach(z=>{k.delete(z.id)}),t.setState({nodeInternals:new Map(k)}))),K.length>0&&(A==null||A(q),$&&$(K.map(z=>({id:z,type:"remove"})))),M.length>0&&(R==null||R(M),I)){const z=M.map(H=>({id:H.id,type:"remove"}));I(z)}}},[]),m=g.useCallback(b=>{const j=A7(b),k=j?null:t.getState().nodeInternals.get(b.id);return!j&&!k?[null,null,j]:[j?b:_E(k),k,j]},[]),w=g.useCallback((b,j=!0,k)=>{const[v,S,C]=m(b);return v?(k||t.getState().getNodes()).filter(_=>{if(!C&&(_.id===S.id||!_.positionAbsolute))return!1;const R=_E(_),A=y1(R,v);return j&&A>0||A>=v.width*v.height}):[]},[]),x=g.useCallback((b,j,k=!0)=>{const[v]=m(b);if(!v)return!1;const S=y1(v,j);return k&&S>0||S>=v.width*v.height},[]);return g.useMemo(()=>({...e,getNodes:n,getNode:s,getEdges:a,getEdge:o,setNodes:i,setEdges:l,addNodes:u,addEdges:d,toObject:f,deleteElements:p,getIntersectingNodes:w,isNodeIntersecting:x}),[e,n,s,a,o,i,l,u,d,f,p,w,x])}const dz={actInsideInputWithModifier:!1};var hz=({deleteKeyCode:e,multiSelectionKeyCode:t})=>{const n=Ht(),{deleteElements:s}=Ql(),a=Xu(e,dz),o=Xu(t);g.useEffect(()=>{if(a){const{edges:i,getNodes:l}=n.getState(),u=l().filter(f=>f.selected),d=i.filter(f=>f.selected);s({nodes:u,edges:d}),n.setState({nodesSelectionActive:!1})}},[a]),g.useEffect(()=>{n.setState({multiSelectionActive:o})},[o])};function fz(e){const t=Ht();g.useEffect(()=>{let n;const s=()=>{var o,i;if(!e.current)return;const a=Zj(e.current);(a.height===0||a.width===0)&&((i=(o=t.getState()).onError)==null||i.call(o,"004",la.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 oN={position:"absolute",width:"100%",height:"100%",top:0,left:0},pz=(e,t)=>e.x!==t.x||e.y!==t.y||e.zoom!==t.k,nf=e=>({x:e.x,y:e.y,zoom:e.k}),sl=(e,t)=>e.target.closest(`.${t}`),PE=(e,t)=>t===2&&Array.isArray(e)&&e.includes(2),DE=e=>{const t=e.ctrlKey&&Qf()?10:1;return-e.deltaY*(e.deltaMode===1?.05:e.deltaMode?1:.002)*t},mz=e=>({d3Zoom:e.d3Zoom,d3Selection:e.d3Selection,d3ZoomHandler:e.d3ZoomHandler,userSelectionActive:e.userSelectionActive}),gz=({onMove:e,onMoveStart:t,onMoveEnd:n,onPaneContextMenu:s,zoomOnScroll:a=!0,zoomOnPinch:o=!0,panOnScroll:i=!1,panOnScrollSpeed:l=.5,panOnScrollMode:u=Xo.Free,zoomOnDoubleClick:d=!0,elementsSelectable:f,panOnDrag:p=!0,defaultViewport:m,translateExtent:w,minZoom:x,maxZoom:b,zoomActivationKeyCode:j,preventScrolling:k=!0,children:v,noWheelClassName:S,noPanClassName:C})=>{const _=g.useRef(),R=Ht(),A=g.useRef(!1),I=g.useRef(!1),$=g.useRef(null),U=g.useRef({x:0,y:0,zoom:0}),{d3Zoom:F,d3Selection:M,d3ZoomHandler:B,userSelectionActive:T}=ft(mz,nn),P=Xu(j),q=g.useRef(0),K=g.useRef(!1),z=g.useRef();return fz($),g.useEffect(()=>{if($.current){const H=$.current.getBoundingClientRect(),D=Y3().scaleExtent([x,b]).translateExtent(w),O=ms($.current).call(D),V=sa.translate(m.x,m.y).scale(Bl(m.zoom,x,b)),Z=[[0,0],[H.width,H.height]],W=D.constrain()(V,Z,w);D.transform(O,W),D.wheelDelta(DE),R.setState({d3Zoom:D,d3Selection:O,d3ZoomHandler:O.on("wheel.zoom"),transform:[W.x,W.y,W.k],domNode:$.current.closest(".react-flow")})}},[]),g.useEffect(()=>{M&&F&&(i&&!P&&!T?M.on("wheel.zoom",H=>{if(sl(H,S))return!1;H.preventDefault(),H.stopImmediatePropagation();const D=M.property("__zoom").k||1;if(H.ctrlKey&&o){const Q=Vs(H),te=DE(H),le=D*Math.pow(2,te);F.scaleTo(M,le,Q,H);return}const O=H.deltaMode===1?20:1;let V=u===Xo.Vertical?0:H.deltaX*O,Z=u===Xo.Horizontal?0:H.deltaY*O;!Qf()&&H.shiftKey&&u!==Xo.Vertical&&(V=H.deltaY*O,Z=0),F.translateBy(M,-(V/D)*l,-(Z/D)*l,{internal:!0});const W=nf(M.property("__zoom")),{onViewportChangeStart:X,onViewportChange:Y,onViewportChangeEnd:J}=R.getState();clearTimeout(z.current),K.current||(K.current=!0,t==null||t(H,W),X==null||X(W)),K.current&&(e==null||e(H,W),Y==null||Y(W),z.current=setTimeout(()=>{n==null||n(H,W),J==null||J(W),K.current=!1},150))},{passive:!1}):typeof B<"u"&&M.on("wheel.zoom",function(H,D){if(!k&&H.type==="wheel"&&!H.ctrlKey||sl(H,S))return null;H.preventDefault(),B.call(this,H,D)},{passive:!1}))},[T,i,u,M,F,B,P,o,k,S,t,e,n]),g.useEffect(()=>{F&&F.on("start",H=>{var V,Z;if(!H.sourceEvent||H.sourceEvent.internal)return null;q.current=(V=H.sourceEvent)==null?void 0:V.button;const{onViewportChangeStart:D}=R.getState(),O=nf(H.transform);A.current=!0,U.current=O,((Z=H.sourceEvent)==null?void 0:Z.type)==="mousedown"&&R.setState({paneDragging:!0}),D==null||D(O),t==null||t(H.sourceEvent,O)})},[F,t]),g.useEffect(()=>{F&&(T&&!A.current?F.on("zoom",null):T||F.on("zoom",H=>{var O;const{onViewportChange:D}=R.getState();if(R.setState({transform:[H.transform.x,H.transform.y,H.transform.k]}),I.current=!!(s&&PE(p,q.current??0)),(e||D)&&!((O=H.sourceEvent)!=null&&O.internal)){const V=nf(H.transform);D==null||D(V),e==null||e(H.sourceEvent,V)}}))},[T,F,e,p,s]),g.useEffect(()=>{F&&F.on("end",H=>{if(!H.sourceEvent||H.sourceEvent.internal)return null;const{onViewportChangeEnd:D}=R.getState();if(A.current=!1,R.setState({paneDragging:!1}),s&&PE(p,q.current??0)&&!I.current&&s(H.sourceEvent),I.current=!1,(n||D)&&pz(U.current,H.transform)){const O=nf(H.transform);U.current=O,clearTimeout(_.current),_.current=setTimeout(()=>{D==null||D(O),n==null||n(H.sourceEvent,O)},i?150:0)}})},[F,i,p,n,s]),g.useEffect(()=>{F&&F.filter(H=>{const D=P||a,O=o&&H.ctrlKey;if((p===!0||Array.isArray(p)&&p.includes(1))&&H.button===1&&H.type==="mousedown"&&(sl(H,"react-flow__node")||sl(H,"react-flow__edge")))return!0;if(!p&&!D&&!i&&!d&&!o||T||!d&&H.type==="dblclick"||sl(H,S)&&H.type==="wheel"||sl(H,C)&&(H.type!=="wheel"||i&&H.type==="wheel"&&!P)||!o&&H.ctrlKey&&H.type==="wheel"||!D&&!i&&!O&&H.type==="wheel"||!p&&(H.type==="mousedown"||H.type==="touchstart")||Array.isArray(p)&&!p.includes(H.button)&&H.type==="mousedown")return!1;const V=Array.isArray(p)&&p.includes(H.button)||!H.button||H.button<=1;return(!H.ctrlKey||H.type==="wheel")&&V})},[T,F,a,o,i,d,p,f,P]),me.createElement("div",{className:"react-flow__renderer",ref:$,style:oN},v)},yz=e=>({userSelectionActive:e.userSelectionActive,userSelectionRect:e.userSelectionRect});function wz(){const{userSelectionActive:e,userSelectionRect:t}=ft(yz,nn);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 FE(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 xz(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&&FE(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&&FE(s,i);break}case"remove":return s}return s.push(i),s},n)}function vz(e,t){return xz(e,t)}const Ha=(e,t)=>({id:e,type:"select",selected:t});function vl(e,t){return e.reduce((n,s)=>{const a=t.includes(s.id);return!s.selected&&a?(s.selected=!0,n.push(Ha(s.id,!0))):s.selected&&!a&&(s.selected=!1,n.push(Ha(s.id,!1))),n},[])}const Vy=(e,t)=>n=>{n.target===t.current&&(e==null||e(n))},bz=e=>({userSelectionActive:e.userSelectionActive,elementsSelectable:e.elementsSelectable,dragging:e.paneDragging}),S4=g.memo(({isSelecting:e,selectionMode:t=Yu.Full,panOnDrag:n,onSelectionStart:s,onSelectionEnd:a,onPaneClick:o,onPaneContextMenu:i,onPaneScroll:l,onPaneMouseEnter:u,onPaneMouseMove:d,onPaneMouseLeave:f,children:p})=>{const m=g.useRef(null),w=Ht(),x=g.useRef(0),b=g.useRef(0),j=g.useRef(),{userSelectionActive:k,elementsSelectable:v,dragging:S}=ft(bz,nn),C=()=>{w.setState({userSelectionActive:!1,userSelectionRect:null}),x.current=0,b.current=0},_=B=>{o==null||o(B),w.getState().resetSelectedElements(),w.setState({nodesSelectionActive:!1})},R=B=>{if(Array.isArray(n)&&(n!=null&&n.includes(2))){B.preventDefault();return}i==null||i(B)},A=l?B=>l(B):void 0,I=B=>{const{resetSelectedElements:T,domNode:P}=w.getState();if(j.current=P==null?void 0:P.getBoundingClientRect(),!v||!e||B.button!==0||B.target!==m.current||!j.current)return;const{x:q,y:K}=Za(B,j.current);T(),w.setState({userSelectionRect:{width:0,height:0,startX:q,startY:K,x:q,y:K}}),s==null||s(B)},$=B=>{const{userSelectionRect:T,nodeInternals:P,edges:q,transform:K,onNodesChange:z,onEdgesChange:H,nodeOrigin:D,getNodes:O}=w.getState();if(!e||!j.current||!T)return;w.setState({userSelectionActive:!0,nodesSelectionActive:!1});const V=Za(B,j.current),Z=T.startX??0,W=T.startY??0,X={...T,x:V.x<Z?V.x:Z,y:V.y<W?V.y:W,width:Math.abs(V.x-Z),height:Math.abs(V.y-W)},Y=O(),J=i4(P,X,K,t===Yu.Partial,!0,D),Q=l4(J,q).map(le=>le.id),te=J.map(le=>le.id);if(x.current!==te.length){x.current=te.length;const le=vl(Y,te);le.length&&(z==null||z(le))}if(b.current!==Q.length){b.current=Q.length;const le=vl(q,Q);le.length&&(H==null||H(le))}w.setState({userSelectionRect:X})},U=B=>{if(B.button!==0)return;const{userSelectionRect:T}=w.getState();!k&&T&&B.target===m.current&&(_==null||_(B)),w.setState({nodesSelectionActive:x.current>0}),C(),a==null||a(B)},F=B=>{k&&(w.setState({nodesSelectionActive:x.current>0}),a==null||a(B)),C()},M=v&&(e||k);return me.createElement("div",{className:mn(["react-flow__pane",{dragging:S,selection:e}]),onClick:M?void 0:Vy(_,m),onContextMenu:Vy(R,m),onWheel:Vy(A,m),onMouseEnter:M?void 0:u,onMouseDown:M?I:void 0,onMouseMove:M?$:d,onMouseUp:M?U:void 0,onMouseLeave:M?F:f,ref:m,style:oN},p,me.createElement(wz,null))});S4.displayName="Pane";function C4(e,t){const n=e.parentNode||e.parentId;if(!n)return!1;const s=t.get(n);return s?s.selected?!0:C4(s,t):!1}function BE(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 kz(e,t,n,s){return Array.from(e.values()).filter(a=>(a.selected||a.id===s)&&(!a.parentNode||a.parentId||!C4(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 jz(e,t){return!t||t==="parent"?t:[t[0],[t[1][0]-(e.width||0),t[1][1]-(e.height||0)]]}function _4(e,t,n,s,a=[0,0],o){const i=jz(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}=ei(p,a).positionAbsolute;l=p&&gs(m)&&gs(w)&&gs(p.width)&&gs(p.height)?[[m+e.width*a[0],w+e.height*a[1]],[m+p.width-e.width+e.width*a[0],w+p.height-e.height+e.height*a[1]]]:l}else o==null||o("005",la.error005()),l=i;else if(e.extent&&u&&e.extent!=="parent"){const p=n.get(u),{x:m,y:w}=ei(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 d={x:0,y:0};if(u){const p=n.get(u);d=ei(p,a).positionAbsolute}const f=l&&l!=="parent"?Jj(t,l):t;return{position:{x:f.x-d.x,y:f.y-d.y},positionAbsolute:f}}function Gy({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 qE=(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 d=u.getBoundingClientRect();return{id:u.getAttribute("data-handleid"),position:u.getAttribute("data-handlepos"),x:(d.left-i.left-l.x)/n,y:(d.top-i.top-l.y)/n,...Zj(u)}})};function au(e,t,n){return n===void 0?n:s=>{const a=t().nodeInternals.get(e);a&&n(s,{...a})}}function j1({id:e,store:t,unselect:n=!1,nodeRef:s}){const{addSelectedNodes:a,unselectNodesAndEdges:o,multiSelectionActive:i,nodeInternals:l,onError:u}=t.getState(),d=l.get(e);if(!d){u==null||u("012",la.error012(e));return}t.setState({nodesSelectionActive:!1}),d.selected?(n||d.selected&&i)&&(o({nodes:[d],edges:[]}),requestAnimationFrame(()=>{var f;return(f=s==null?void 0:s.current)==null?void 0:f.blur()})):a([e])}function Nz(){const e=Ht();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 Ky(e){return(t,n,s)=>e==null?void 0:e(t,s)}function E4({nodeRef:e,disabled:t=!1,noDragClassName:n,handleSelector:s,nodeId:a,isSelectable:o,selectNodesOnDrag:i}){const l=Ht(),[u,d]=g.useState(!1),f=g.useRef([]),p=g.useRef({x:null,y:null}),m=g.useRef(0),w=g.useRef(null),x=g.useRef({x:0,y:0}),b=g.useRef(null),j=g.useRef(!1),k=g.useRef(!1),v=g.useRef(!1),S=Nz();return g.useEffect(()=>{if(e!=null&&e.current){const C=ms(e.current),_=({x:I,y:$})=>{const{nodeInternals:U,onNodeDrag:F,onSelectionDrag:M,updateNodePositions:B,nodeExtent:T,snapGrid:P,snapToGrid:q,nodeOrigin:K,onError:z}=l.getState();p.current={x:I,y:$};let H=!1,D={x:0,y:0,x2:0,y2:0};if(f.current.length>1&&T){const V=Gp(f.current,K);D=Ku(V)}if(f.current=f.current.map(V=>{const Z={x:I-V.distance.x,y:$-V.distance.y};q&&(Z.x=P[0]*Math.round(Z.x/P[0]),Z.y=P[1]*Math.round(Z.y/P[1]));const W=[[T[0][0],T[0][1]],[T[1][0],T[1][1]]];f.current.length>1&&T&&!V.extent&&(W[0][0]=V.positionAbsolute.x-D.x+T[0][0],W[1][0]=V.positionAbsolute.x+(V.width??0)-D.x2+T[1][0],W[0][1]=V.positionAbsolute.y-D.y+T[0][1],W[1][1]=V.positionAbsolute.y+(V.height??0)-D.y2+T[1][1]);const X=_4(V,Z,U,W,K,z);return H=H||V.position.x!==X.position.x||V.position.y!==X.position.y,V.position=X.position,V.positionAbsolute=X.positionAbsolute,V}),!H)return;B(f.current,!0,!0),d(!0);const O=a?F:Ky(M);if(O&&b.current){const[V,Z]=Gy({nodeId:a,dragItems:f.current,nodeInternals:U});O(b.current,V,Z)}},R=()=>{if(!w.current)return;const[I,$]=Z3(x.current,w.current);if(I!==0||$!==0){const{transform:U,panBy:F}=l.getState();p.current.x=(p.current.x??0)-I/U[2],p.current.y=(p.current.y??0)-$/U[2],F({x:I,y:$})&&_(p.current)}m.current=requestAnimationFrame(R)},A=I=>{var K;const{nodeInternals:$,multiSelectionActive:U,nodesDraggable:F,unselectNodesAndEdges:M,onNodeDragStart:B,onSelectionDragStart:T}=l.getState();k.current=!0;const P=a?B:Ky(T);(!i||!o)&&!U&&a&&((K=$.get(a))!=null&&K.selected||M()),a&&o&&i&&j1({id:a,store:l,nodeRef:e});const q=S(I);if(p.current=q,f.current=kz($,F,q,a),P&&f.current){const[z,H]=Gy({nodeId:a,dragItems:f.current,nodeInternals:$});P(I.sourceEvent,z,H)}};if(t)C.on(".drag",null);else{const I=LW().on("start",$=>{const{domNode:U,nodeDragThreshold:F}=l.getState();F===0&&A($),v.current=!1;const M=S($);p.current=M,w.current=(U==null?void 0:U.getBoundingClientRect())||null,x.current=Za($.sourceEvent,w.current)}).on("drag",$=>{var B,T;const U=S($),{autoPanOnNodeDrag:F,nodeDragThreshold:M}=l.getState();if($.sourceEvent.type==="touchmove"&&$.sourceEvent.touches.length>1&&(v.current=!0),!v.current){if(!j.current&&k.current&&F&&(j.current=!0,R()),!k.current){const P=U.xSnapped-(((B=p==null?void 0:p.current)==null?void 0:B.x)??0),q=U.ySnapped-(((T=p==null?void 0:p.current)==null?void 0:T.y)??0);Math.sqrt(P*P+q*q)>M&&A($)}(p.current.x!==U.xSnapped||p.current.y!==U.ySnapped)&&f.current&&k.current&&(b.current=$.sourceEvent,x.current=Za($.sourceEvent,w.current),_(U))}}).on("end",$=>{if(!(!k.current||v.current)&&(d(!1),j.current=!1,k.current=!1,cancelAnimationFrame(m.current),f.current)){const{updateNodePositions:U,nodeInternals:F,onNodeDragStop:M,onSelectionDragStop:B}=l.getState(),T=a?M:Ky(B);if(U(f.current,!1,!1),T){const[P,q]=Gy({nodeId:a,dragItems:f.current,nodeInternals:F});T($.sourceEvent,P,q)}}}).filter($=>{const U=$.target;return!$.button&&(!n||!BE(U,`.${n}`,e))&&(!s||BE(U,s,e))});return C.call(I),()=>{C.on(".drag",null)}}}},[e,t,n,s,o,l,a,i,S]),u}function T4(){const e=Ht();return g.useCallback(n=>{const{nodeInternals:s,nodeExtent:a,updateNodePositions:o,getNodes:i,snapToGrid:l,snapGrid:u,onError:d,nodesDraggable:f}=e.getState(),p=i().filter(v=>v.selected&&(v.draggable||f&&typeof v.draggable>"u")),m=l?u[0]:5,w=l?u[1]:5,x=n.isShiftPressed?4:1,b=n.x*m*x,j=n.y*w*x,k=p.map(v=>{if(v.positionAbsolute){const S={x:v.positionAbsolute.x+b,y:v.positionAbsolute.y+j};l&&(S.x=u[0]*Math.round(S.x/u[0]),S.y=u[1]*Math.round(S.y/u[1]));const{positionAbsolute:C,position:_}=_4(v,S,s,a,void 0,d);v.position=_,v.positionAbsolute=C}return v});o(k,!0,!1)},[])}const Tl={ArrowUp:{x:0,y:-1},ArrowDown:{x:0,y:1},ArrowLeft:{x:-1,y:0},ArrowRight:{x:1,y:0}};var ou=e=>{const t=({id:n,type:s,data:a,xPos:o,yPos:i,xPosOrigin:l,yPosOrigin:u,selected:d,onClick:f,onMouseEnter:p,onMouseMove:m,onMouseLeave:w,onContextMenu:x,onDoubleClick:b,style:j,className:k,isDraggable:v,isSelectable:S,isConnectable:C,isFocusable:_,selectNodesOnDrag:R,sourcePosition:A,targetPosition:I,hidden:$,resizeObserver:U,dragHandle:F,zIndex:M,isParent:B,noDragClassName:T,noPanClassName:P,initialized:q,disableKeyboardA11y:K,ariaLabel:z,rfId:H,hasHandleBounds:D})=>{const O=Ht(),V=g.useRef(null),Z=g.useRef(null),W=g.useRef(A),X=g.useRef(I),Y=g.useRef(s),J=S||v||f||p||m||w,Q=T4(),te=au(n,O.getState,p),le=au(n,O.getState,m),de=au(n,O.getState,w),oe=au(n,O.getState,x),re=au(n,O.getState,b),he=ye=>{const{nodeDragThreshold:ge}=O.getState();if(S&&(!R||!v||ge>0)&&j1({id:n,store:O,nodeRef:V}),f){const je=O.getState().nodeInternals.get(n);je&&f(ye,{...je})}},fe=ye=>{if(!w1(ye)&&!K)if(t4.includes(ye.key)&&S){const ge=ye.key==="Escape";j1({id:n,store:O,unselect:ge,nodeRef:V})}else v&&d&&Object.prototype.hasOwnProperty.call(Tl,ye.key)&&(O.setState({ariaLiveMessage:`Moved selected node ${ye.key.replace("Arrow","").toLowerCase()}. New position, x: ${~~o}, y: ${~~i}`}),Q({x:Tl[ye.key].x,y:Tl[ye.key].y,isShiftPressed:ye.shiftKey}))};g.useEffect(()=>()=>{Z.current&&(U==null||U.unobserve(Z.current),Z.current=null)},[]),g.useEffect(()=>{if(V.current&&!$){const ye=V.current;(!q||!D||Z.current!==ye)&&(Z.current&&(U==null||U.unobserve(Z.current)),U==null||U.observe(ye),Z.current=ye)}},[$,q,D]),g.useEffect(()=>{const ye=Y.current!==s,ge=W.current!==A,je=X.current!==I;V.current&&(ye||ge||je)&&(ye&&(Y.current=s),ge&&(W.current=A),je&&(X.current=I),O.getState().updateNodeDimensions([{id:n,nodeElement:V.current,forceUpdate:!0}]))},[n,s,A,I]);const $e=E4({nodeRef:V,disabled:$||!v,noDragClassName:T,handleSelector:F,nodeId:n,isSelectable:S,selectNodesOnDrag:R});return $?null:me.createElement("div",{className:mn(["react-flow__node",`react-flow__node-${s}`,{[P]:v},k,{selected:d,selectable:S,parent:B,dragging:$e}]),ref:V,style:{zIndex:M,transform:`translate(${l}px,${u}px)`,pointerEvents:J?"all":"none",visibility:q?"visible":"hidden",...j},"data-id":n,"data-testid":`rf__node-${n}`,onMouseEnter:te,onMouseMove:le,onMouseLeave:de,onContextMenu:oe,onClick:he,onDoubleClick:re,onKeyDown:_?fe:void 0,tabIndex:_?0:void 0,role:_?"button":void 0,"aria-describedby":K?void 0:`${v4}-${H}`,"aria-label":z},me.createElement(P7,{value:n},me.createElement(e,{id:n,data:a,type:s,xPos:o,yPos:i,selected:d,isConnectable:C,sourcePosition:A,targetPosition:I,dragging:$e,dragHandle:F,zIndex:M})))};return t.displayName="NodeWrapper",g.memo(t)};const Sz=e=>{const t=e.getNodes().filter(n=>n.selected);return{...Gp(t,e.nodeOrigin),transformString:`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`,userSelectionActive:e.userSelectionActive}};function Cz({onSelectionContextMenu:e,noPanClassName:t,disableKeyboardA11y:n}){const s=Ht(),{width:a,height:o,x:i,y:l,transformString:u,userSelectionActive:d}=ft(Sz,nn),f=T4(),p=g.useRef(null);if(g.useEffect(()=>{var x;n||(x=p.current)==null||x.focus({preventScroll:!0})},[n]),E4({nodeRef:p}),d||!a||!o)return null;const m=e?x=>{const b=s.getState().getNodes().filter(j=>j.selected);e(x,b)}:void 0,w=x=>{Object.prototype.hasOwnProperty.call(Tl,x.key)&&f({x:Tl[x.key].x,y:Tl[x.key].y,isShiftPressed:x.shiftKey})};return me.createElement("div",{className:mn(["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 _z=g.memo(Cz);const Ez=e=>e.nodesSelectionActive,A4=({children:e,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:o,onPaneScroll:i,deleteKeyCode:l,onMove:u,onMoveStart:d,onMoveEnd:f,selectionKeyCode:p,selectionOnDrag:m,selectionMode:w,onSelectionStart:x,onSelectionEnd:b,multiSelectionKeyCode:j,panActivationKeyCode:k,zoomActivationKeyCode:v,elementsSelectable:S,zoomOnScroll:C,zoomOnPinch:_,panOnScroll:R,panOnScrollSpeed:A,panOnScrollMode:I,zoomOnDoubleClick:$,panOnDrag:U,defaultViewport:F,translateExtent:M,minZoom:B,maxZoom:T,preventScrolling:P,onSelectionContextMenu:q,noWheelClassName:K,noPanClassName:z,disableKeyboardA11y:H})=>{const D=ft(Ez),O=Xu(p),V=Xu(k),Z=V||U,W=V||R,X=O||m&&Z!==!0;return hz({deleteKeyCode:l,multiSelectionKeyCode:j}),me.createElement(gz,{onMove:u,onMoveStart:d,onMoveEnd:f,onPaneContextMenu:o,elementsSelectable:S,zoomOnScroll:C,zoomOnPinch:_,panOnScroll:W,panOnScrollSpeed:A,panOnScrollMode:I,zoomOnDoubleClick:$,panOnDrag:!O&&Z,defaultViewport:F,translateExtent:M,minZoom:B,maxZoom:T,zoomActivationKeyCode:v,preventScrolling:P,noWheelClassName:K,noPanClassName:z},me.createElement(S4,{onSelectionStart:x,onSelectionEnd:b,onPaneClick:t,onPaneMouseEnter:n,onPaneMouseMove:s,onPaneMouseLeave:a,onPaneContextMenu:o,onPaneScroll:i,panOnDrag:Z,isSelecting:!!X,selectionMode:w},e,D&&me.createElement(_z,{onSelectionContextMenu:q,noPanClassName:z,disableKeyboardA11y:H})))};A4.displayName="FlowRenderer";var Tz=g.memo(A4);function Az(e){return ft(g.useCallback(n=>e?i4(n.nodeInternals,{x:0,y:0,width:n.width,height:n.height},n.transform,!0):n.getNodes(),[e]))}function Rz(e){const t={input:ou(e.input||g4),default:ou(e.default||k1),output:ou(e.output||w4),group:ou(e.group||aN)},n={},s=Object.keys(e).filter(a=>!["input","default","output","group"].includes(a)).reduce((a,o)=>(a[o]=ou(e[o]||k1),a),n);return{...t,...s}}const Mz=({x:e,y:t,width:n,height:s,origin:a})=>!n||!s?{x:e,y:t}:a[0]<0||a[1]<0||a[0]>1||a[1]>1?{x:e,y:t}:{x:e-n*a[0],y:t-s*a[1]},$z=e=>({nodesDraggable:e.nodesDraggable,nodesConnectable:e.nodesConnectable,nodesFocusable:e.nodesFocusable,elementsSelectable:e.elementsSelectable,updateNodeDimensions:e.updateNodeDimensions,onError:e.onError}),R4=e=>{const{nodesDraggable:t,nodesConnectable:n,nodesFocusable:s,elementsSelectable:a,updateNodeDimensions:o,onError:i}=ft($z,nn),l=Az(e.onlyRenderVisibleElements),u=g.useRef(),d=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:oN},l.map(f=>{var _,R,A;let p=f.type||"default";e.nodeTypes[p]||(i==null||i("003",la.error003(p)),p="default");const m=e.nodeTypes[p]||e.nodeTypes.default,w=!!(f.draggable||t&&typeof f.draggable>"u"),x=!!(f.selectable||a&&typeof f.selectable>"u"),b=!!(f.connectable||n&&typeof f.connectable>"u"),j=!!(f.focusable||s&&typeof f.focusable>"u"),k=e.nodeExtent?Jj(f.positionAbsolute,e.nodeExtent):f.positionAbsolute,v=(k==null?void 0:k.x)??0,S=(k==null?void 0:k.y)??0,C=Mz({x:v,y:S,width:f.width??0,height:f.height??0,origin:e.nodeOrigin});return me.createElement(m,{key:f.id,id:f.id,className:f.className,style:f.style,type:p,data:f.data,sourcePosition:f.sourcePosition||Ye.Bottom,targetPosition:f.targetPosition||Ye.Top,hidden:f.hidden,xPos:v,yPos:S,xPosOrigin:C.x,yPosOrigin:C.y,selectNodesOnDrag:e.selectNodesOnDrag,onClick:e.onNodeClick,onMouseEnter:e.onNodeMouseEnter,onMouseMove:e.onNodeMouseMove,onMouseLeave:e.onNodeMouseLeave,onContextMenu:e.onNodeContextMenu,onDoubleClick:e.onNodeDoubleClick,selected:!!f.selected,isDraggable:w,isSelectable:x,isConnectable:b,isFocusable:j,resizeObserver:d,dragHandle:f.dragHandle,zIndex:((_=f[Ft])==null?void 0:_.z)??0,isParent:!!((R=f[Ft])!=null&&R.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)})}))};R4.displayName="NodeRenderer";var Lz=g.memo(R4);const Iz=(e,t,n)=>n===Ye.Left?e-t:n===Ye.Right?e+t:e,Oz=(e,t,n)=>n===Ye.Top?e-t:n===Ye.Bottom?e+t:e,UE="react-flow__edgeupdater",WE=({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:mn([UE,`${UE}-${l}`]),cx:Iz(t,s,e),cy:Oz(n,s,e),r:s,stroke:"transparent",fill:"transparent"}),Pz=()=>!0;var rl=e=>{const t=({id:n,className:s,type:a,data:o,onClick:i,onEdgeDoubleClick:l,selected:u,animated:d,label:f,labelStyle:p,labelShowBg:m,labelBgStyle:w,labelBgPadding:x,labelBgBorderRadius:b,style:j,source:k,target:v,sourceX:S,sourceY:C,targetX:_,targetY:R,sourcePosition:A,targetPosition:I,elementsSelectable:$,hidden:U,sourceHandleId:F,targetHandleId:M,onContextMenu:B,onMouseEnter:T,onMouseMove:P,onMouseLeave:q,reconnectRadius:K,onReconnect:z,onReconnectStart:H,onReconnectEnd:D,markerEnd:O,markerStart:V,rfId:Z,ariaLabel:W,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),fe=Ht(),$e=g.useMemo(()=>`url('#${v1(V,Z)}')`,[V,Z]),ye=g.useMemo(()=>`url('#${v1(O,Z)}')`,[O,Z]);if(U)return null;const ge=We=>{var pe;const{edges:se,addSelectedEdges:be,unselectNodesAndEdges:Te,multiSelectionActive:Oe}=fe.getState(),ve=se.find(_e=>_e.id===n);ve&&($&&(fe.setState({nodesSelectionActive:!1}),ve.selected&&Oe?(Te({nodes:[],edges:[ve]}),(pe=le.current)==null||pe.blur()):be([n])),i&&i(We,ve))},je=ru(n,fe.getState,l),Le=ru(n,fe.getState,B),ke=ru(n,fe.getState,T),Ie=ru(n,fe.getState,P),De=ru(n,fe.getState,q),Ue=(We,se)=>{if(We.button!==0)return;const{edges:be,isValidConnection:Te}=fe.getState(),Oe=se?v:k,ve=(se?M:F)||null,pe=se?"target":"source",_e=Te||Pz,ze=se,at=be.find(Mt=>Mt.id===n);he(!0),H==null||H(We,at,pe);const tt=Mt=>{he(!1),D==null||D(Mt,at,pe)};h4({event:We,handleId:ve,nodeId:Oe,onConnect:Mt=>z==null?void 0:z(at,Mt),isTarget:ze,getState:fe.getState,setState:fe.setState,isValidConnection:_e,edgeUpdaterType:pe,onReconnectEnd:tt})},Ke=We=>Ue(We,!0),we=We=>Ue(We,!1),Fe=()=>oe(!0),Re=()=>oe(!1),Ae=!$&&!i,rt=We=>{var se;if(!te&&t4.includes(We.key)&&$){const{unselectNodesAndEdges:be,addSelectedEdges:Te,edges:Oe}=fe.getState();We.key==="Escape"?((se=le.current)==null||se.blur(),be({edges:[Oe.find(pe=>pe.id===n)]})):Te([n])}};return me.createElement("g",{className:mn(["react-flow__edge",`react-flow__edge-${a}`,s,{selected:u,animated:d,inactive:Ae,updating:de}]),onClick:ge,onDoubleClick:je,onContextMenu:Le,onMouseEnter:ke,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":W===null?void 0:W||`Edge from ${k} to ${v}`,"aria-describedby":X?`${b4}-${Z}`:void 0,ref:le},!re&&me.createElement(e,{id:n,source:k,target:v,selected:u,animated:d,label:f,labelStyle:p,labelShowBg:m,labelBgStyle:w,labelBgPadding:x,labelBgBorderRadius:b,data:o,style:j,sourceX:S,sourceY:C,targetX:_,targetY:R,sourcePosition:A,targetPosition:I,sourceHandleId:F,targetHandleId:M,markerStart:$e,markerEnd:ye,pathOptions:J,interactionWidth:Q}),Y&&me.createElement(me.Fragment,null,(Y==="source"||Y===!0)&&me.createElement(WE,{position:A,centerX:S,centerY:C,radius:K,onMouseDown:Ke,onMouseEnter:Fe,onMouseOut:Re,type:"source"}),(Y==="target"||Y===!0)&&me.createElement(WE,{position:I,centerX:_,centerY:R,radius:K,onMouseDown:we,onMouseEnter:Fe,onMouseOut:Re,type:"target"})))};return t.displayName="EdgeWrapper",g.memo(t)};function Dz(e){const t={default:rl(e.default||tp),straight:rl(e.bezier||tN),step:rl(e.step||eN),smoothstep:rl(e.step||Vp),simplebezier:rl(e.simplebezier||Qj)},n={},s=Object.keys(e).filter(a=>!["default","bezier"].includes(a)).reduce((a,o)=>(a[o]=rl(e[o]||tp),a),n);return{...t,...s}}function HE(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 zE(e,t){return e?e.length===1||!t?e[0]:t&&e.find(n=>n.id===t)||null:null}const Fz=(e,t,n,s,a,o)=>{const i=HE(n,e,t),l=HE(o,s,a);return{sourceX:i.x,sourceY:i.y,targetX:l.x,targetY:l.y}};function Bz({sourcePos:e,targetPos:t,sourceWidth:n,sourceHeight:s,targetWidth:a,targetHeight:o,width:i,height:l,transform:u}){const d={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)};d.x===d.x2&&(d.x2+=1),d.y===d.y2&&(d.y2+=1);const f=Ku({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,d.x2)-Math.max(f.x,d.x)),m=Math.max(0,Math.min(f.y2,d.y2)-Math.max(f.y,d.y));return Math.ceil(p*m)>0}function VE(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 qz=[{level:0,isMaxLevel:!0,edges:[]}];function Uz(e,t,n=!1){let s=-1;const a=e.reduce((i,l)=>{var f,p;const u=gs(l.zIndex);let d=u?l.zIndex:0;if(n){const m=t.get(l.target),w=t.get(l.source),x=l.selected||(m==null?void 0:m.selected)||(w==null?void 0:w.selected),b=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);d=(u?l.zIndex:0)+(x?b:0)}return i[d]?i[d].push(l):i[d]=[l],s=d>s?d:s,i},{}),o=Object.entries(a).map(([i,l])=>{const u=+i;return{edges:l,level:u,isMaxLevel:u===s}});return o.length===0?qz:o}function Wz(e,t,n){const s=ft(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)&&Bz({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 Uz(s,t,n)}const Hz=({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"}),zz=({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"}),GE={[ep.Arrow]:Hz,[ep.ArrowClosed]:zz};function Vz(e){const t=Ht();return g.useMemo(()=>{var a,o;return Object.prototype.hasOwnProperty.call(GE,e)?GE[e]:((o=(a=t.getState()).onError)==null||o.call(a,"009",la.error009(e)),null)},[e])}const Gz=({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=Vz(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},Kz=({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=v1(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))},M4=({defaultColor:e,rfId:t})=>{const n=ft(g.useCallback(Kz({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(Gz,{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})))};M4.displayName="MarkerDefinitions";var Yz=g.memo(M4);const Xz=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}),$4=({defaultMarkerColor:e,onlyRenderVisibleElements:t,elevateEdgesOnSelect:n,rfId:s,edgeTypes:a,noPanClassName:o,onEdgeContextMenu:i,onEdgeMouseEnter:l,onEdgeMouseMove:u,onEdgeMouseLeave:d,onEdgeClick:f,onEdgeDoubleClick:p,onReconnect:m,onReconnectStart:w,onReconnectEnd:x,reconnectRadius:b,children:j,disableKeyboardA11y:k})=>{const{edgesFocusable:v,edgesUpdatable:S,elementsSelectable:C,width:_,height:R,connectionMode:A,nodeInternals:I,onError:$}=ft(Xz,nn),U=Wz(t,I,n);return _?me.createElement(me.Fragment,null,U.map(({level:F,edges:M,isMaxLevel:B})=>me.createElement("svg",{key:F,style:{zIndex:F},width:_,height:R,className:"react-flow__edges react-flow__container"},B&&me.createElement(Yz,{defaultColor:e,rfId:s}),me.createElement("g",null,M.map(T=>{const[P,q,K]=VE(I.get(T.source)),[z,H,D]=VE(I.get(T.target));if(!K||!D)return null;let O=T.type||"default";a[O]||($==null||$("011",la.error011(O)),O="default");const V=a[O]||a.default,Z=A===li.Strict?H.target:(H.target??[]).concat(H.source??[]),W=zE(q.source,T.sourceHandle),X=zE(Z,T.targetHandle),Y=(W==null?void 0:W.position)||Ye.Bottom,J=(X==null?void 0:X.position)||Ye.Top,Q=!!(T.focusable||v&&typeof T.focusable>"u"),te=T.reconnectable||T.updatable,le=typeof m<"u"&&(te||S&&typeof te>"u");if(!W||!X)return $==null||$("008",la.error008(W,T)),null;const{sourceX:de,sourceY:oe,targetX:re,targetY:he}=Fz(P,W,Y,z,X,J);return me.createElement(V,{key:T.id,id:T.id,className:mn([T.className,o]),type:O,data:T.data,selected:!!T.selected,animated:!!T.animated,hidden:!!T.hidden,label:T.label,labelStyle:T.labelStyle,labelShowBg:T.labelShowBg,labelBgStyle:T.labelBgStyle,labelBgPadding:T.labelBgPadding,labelBgBorderRadius:T.labelBgBorderRadius,style:T.style,source:T.source,target:T.target,sourceHandleId:T.sourceHandle,targetHandleId:T.targetHandle,markerEnd:T.markerEnd,markerStart:T.markerStart,sourceX:de,sourceY:oe,targetX:re,targetY:he,sourcePosition:Y,targetPosition:J,elementsSelectable:C,onContextMenu:i,onMouseEnter:l,onMouseMove:u,onMouseLeave:d,onClick:f,onEdgeDoubleClick:p,onReconnect:m,onReconnectStart:w,onReconnectEnd:x,reconnectRadius:b,rfId:s,ariaLabel:T.ariaLabel,isFocusable:Q,isReconnectable:le,pathOptions:"pathOptions"in T?T.pathOptions:void 0,interactionWidth:T.interactionWidth,disableKeyboardA11y:k})})))),j):null};$4.displayName="EdgeRenderer";var Zz=g.memo($4);const Jz=e=>`translate(${e.transform[0]}px,${e.transform[1]}px) scale(${e.transform[2]})`;function Qz({children:e}){const t=ft(Jz);return me.createElement("div",{className:"react-flow__viewport react-flow__container",style:{transform:t}},e)}function e9(e){const t=Ql(),n=g.useRef(!1);g.useEffect(()=>{!n.current&&t.viewportInitialized&&e&&(setTimeout(()=>e(t),1),n.current=!0)},[e,t.viewportInitialized])}const t9={[Ye.Left]:Ye.Right,[Ye.Right]:Ye.Left,[Ye.Top]:Ye.Bottom,[Ye.Bottom]:Ye.Top},L4=({nodeId:e,handleType:t,style:n,type:s=Va.Bezier,CustomComponent:a,connectionStatus:o})=>{var R,A,I;const{fromNode:i,handleId:l,toX:u,toY:d,connectionMode:f}=ft(g.useCallback($=>({fromNode:$.nodeInternals.get(e),handleId:$.connectionHandleId,toX:($.connectionPosition.x-$.transform[0])/$.transform[2],toY:($.connectionPosition.y-$.transform[1])/$.transform[2],connectionMode:$.connectionMode}),[e]),nn),p=(R=i==null?void 0:i[Ft])==null?void 0:R.handleBounds;let m=p==null?void 0:p[t];if(f===li.Loose&&(m=m||(p==null?void 0:p[t==="source"?"target":"source"])),!i||!m)return null;const w=l?m.find($=>$.id===l):m[0],x=w?w.x+w.width/2:(i.width??0)/2,b=w?w.y+w.height/2:i.height??0,j=(((A=i.positionAbsolute)==null?void 0:A.x)??0)+x,k=(((I=i.positionAbsolute)==null?void 0:I.y)??0)+b,v=w==null?void 0:w.position,S=v?t9[v]:null;if(!v||!S)return null;if(a)return me.createElement(a,{connectionLineType:s,connectionLineStyle:n,fromNode:i,fromHandle:w,fromX:j,fromY:k,toX:u,toY:d,fromPosition:v,toPosition:S,connectionStatus:o});let C="";const _={sourceX:j,sourceY:k,sourcePosition:v,targetX:u,targetY:d,targetPosition:S};return s===Va.Bezier?[C]=nN(_):s===Va.Step?[C]=x1({..._,borderRadius:0}):s===Va.SmoothStep?[C]=x1(_):s===Va.SimpleBezier?[C]=a4(_):C=`M${j},${k} ${u},${d}`,me.createElement("path",{d:C,fill:"none",className:"react-flow__connection-path",style:n})};L4.displayName="ConnectionLine";const n9=e=>({nodeId:e.connectionNodeId,handleType:e.connectionHandleType,nodesConnectable:e.nodesConnectable,connectionStatus:e.connectionStatus,width:e.width,height:e.height});function s9({containerStyle:e,style:t,type:n,component:s}){const{nodeId:a,handleType:o,nodesConnectable:i,width:l,height:u,connectionStatus:d}=ft(n9,nn);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:mn(["react-flow__connection",d])},me.createElement(L4,{nodeId:a,handleType:o,style:t,type:n,CustomComponent:s,connectionStatus:d})))}function KE(e,t){return g.useRef(null),Ht(),g.useMemo(()=>t(e),[e])}const I4=({nodeTypes:e,edgeTypes:t,onMove:n,onMoveStart:s,onMoveEnd:a,onInit:o,onNodeClick:i,onEdgeClick:l,onNodeDoubleClick:u,onEdgeDoubleClick:d,onNodeMouseEnter:f,onNodeMouseMove:p,onNodeMouseLeave:m,onNodeContextMenu:w,onSelectionContextMenu:x,onSelectionStart:b,onSelectionEnd:j,connectionLineType:k,connectionLineStyle:v,connectionLineComponent:S,connectionLineContainerStyle:C,selectionKeyCode:_,selectionOnDrag:R,selectionMode:A,multiSelectionKeyCode:I,panActivationKeyCode:$,zoomActivationKeyCode:U,deleteKeyCode:F,onlyRenderVisibleElements:M,elementsSelectable:B,selectNodesOnDrag:T,defaultViewport:P,translateExtent:q,minZoom:K,maxZoom:z,preventScrolling:H,defaultMarkerColor:D,zoomOnScroll:O,zoomOnPinch:V,panOnScroll:Z,panOnScrollSpeed:W,panOnScrollMode:X,zoomOnDoubleClick:Y,panOnDrag:J,onPaneClick:Q,onPaneMouseEnter:te,onPaneMouseMove:le,onPaneMouseLeave:de,onPaneScroll:oe,onPaneContextMenu:re,onEdgeContextMenu:he,onEdgeMouseEnter:fe,onEdgeMouseMove:$e,onEdgeMouseLeave:ye,onReconnect:ge,onReconnectStart:je,onReconnectEnd:Le,reconnectRadius:ke,noDragClassName:Ie,noWheelClassName:De,noPanClassName:Ue,elevateEdgesOnSelect:Ke,disableKeyboardA11y:we,nodeOrigin:Fe,nodeExtent:Re,rfId:Ae})=>{const rt=KE(e,Rz),We=KE(t,Dz);return e9(o),me.createElement(Tz,{onPaneClick:Q,onPaneMouseEnter:te,onPaneMouseMove:le,onPaneMouseLeave:de,onPaneContextMenu:re,onPaneScroll:oe,deleteKeyCode:F,selectionKeyCode:_,selectionOnDrag:R,selectionMode:A,onSelectionStart:b,onSelectionEnd:j,multiSelectionKeyCode:I,panActivationKeyCode:$,zoomActivationKeyCode:U,elementsSelectable:B,onMove:n,onMoveStart:s,onMoveEnd:a,zoomOnScroll:O,zoomOnPinch:V,zoomOnDoubleClick:Y,panOnScroll:Z,panOnScrollSpeed:W,panOnScrollMode:X,panOnDrag:J,defaultViewport:P,translateExtent:q,minZoom:K,maxZoom:z,onSelectionContextMenu:x,preventScrolling:H,noDragClassName:Ie,noWheelClassName:De,noPanClassName:Ue,disableKeyboardA11y:we},me.createElement(Qz,null,me.createElement(Zz,{edgeTypes:We,onEdgeClick:l,onEdgeDoubleClick:d,onlyRenderVisibleElements:M,onEdgeContextMenu:he,onEdgeMouseEnter:fe,onEdgeMouseMove:$e,onEdgeMouseLeave:ye,onReconnect:ge,onReconnectStart:je,onReconnectEnd:Le,reconnectRadius:ke,defaultMarkerColor:D,noPanClassName:Ue,elevateEdgesOnSelect:!!Ke,disableKeyboardA11y:we,rfId:Ae},me.createElement(s9,{style:v,type:k,component:S,containerStyle:C})),me.createElement("div",{className:"react-flow__edgelabel-renderer"}),me.createElement(Lz,{nodeTypes:rt,onNodeClick:i,onNodeDoubleClick:u,onNodeMouseEnter:f,onNodeMouseMove:p,onNodeMouseLeave:m,onNodeContextMenu:w,selectNodesOnDrag:T,onlyRenderVisibleElements:M,noPanClassName:Ue,noDragClassName:Ie,disableKeyboardA11y:we,nodeOrigin:Fe,nodeExtent:Re,rfId:Ae})))};I4.displayName="GraphView";var r9=g.memo(I4);const N1=[[Number.NEGATIVE_INFINITY,Number.NEGATIVE_INFINITY],[Number.POSITIVE_INFINITY,Number.POSITIVE_INFINITY]],Fa={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:N1,nodeExtent:N1,nodesSelectionActive:!1,userSelectionActive:!1,userSelectionRect:null,connectionNodeId:null,connectionHandleId:null,connectionHandleType:"source",connectionPosition:{x:0,y:0},connectionStatus:null,connectionMode:li.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:R7,isValidConnection:void 0},a9=()=>Vq((e,t)=>({...Fa,setNodes:n=>{const{nodeInternals:s,nodeOrigin:a,elevateNodesOnSelect:o}=t();e({nodeInternals:zy(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?zy(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:d}=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((b,j)=>{const k=a.get(j.id);if(k!=null&&k.hidden)a.set(k.id,{...k,[Ft]:{...k[Ft],handleBounds:void 0}});else if(k){const v=Zj(j.nodeElement);!!(v.width&&v.height&&(k.width!==v.width||k.height!==v.height||j.forceUpdate))&&(a.set(k.id,{...k,[Ft]:{...k[Ft],handleBounds:{source:qE(".source",j.nodeElement,m,d),target:qE(".target",j.nodeElement,m,d)}},...v}),b.push({id:k.id,type:"dimensions",dimensions:v}))}return b},[]);j4(a,d);const x=i||o&&!i&&N4(t,{initial:!0,...l});e({nodeInternals:new Map(a),fitViewOnInitDone:x}),(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 d=vz(n,l()),f=zy(d,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=>Ha(u,!0)):(i=vl(o(),n),l=vl(a,[])),tf({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=>Ha(u,!0)):(i=vl(a,n),l=vl(o(),[])),tf({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,Ha(f.id,!1))),d=l.map(f=>Ha(f.id,!1));tf({changedNodes:u,changedEdges:d,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=>Ha(l.id,!1)),i=n.filter(l=>l.selected).map(l=>Ha(l.id,!1));tf({changedNodes:o,changedEdges:i,get:t,set:e})},setNodeExtent:n=>{const{nodeInternals:s}=t();s.forEach(a=>{a.positionAbsolute=Jj(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 d=sa.translate(s[0]+n.x,s[1]+n.y).scale(s[2]),f=[[0,0],[a,o]],p=i==null?void 0:i.constrain()(d,f,u);return i.transform(l,p),s[0]!==p.x||s[1]!==p.y||s[2]!==p.k},cancelConnection:()=>e({connectionNodeId:Fa.connectionNodeId,connectionHandleId:Fa.connectionHandleId,connectionHandleType:Fa.connectionHandleType,connectionStatus:Fa.connectionStatus,connectionStartHandle:Fa.connectionStartHandle,connectionEndHandle:Fa.connectionEndHandle}),reset:()=>e({...Fa})}),Object.is),iN=({children:e})=>{const t=g.useRef(null);return t.current||(t.current=a9()),me.createElement(N7,{value:t.current},e)};iN.displayName="ReactFlowProvider";const O4=({children:e})=>g.useContext(zp)?me.createElement(me.Fragment,null,e):me.createElement(iN,null,e);O4.displayName="ReactFlowWrapper";const o9={input:g4,default:k1,output:w4,group:aN},i9={default:tp,straight:tN,step:eN,smoothstep:Vp,simplebezier:Qj},l9=[0,0],c9=[15,15],u9={x:0,y:0,zoom:1},d9={width:"100%",height:"100%",overflow:"hidden",position:"relative",zIndex:0},P4=g.forwardRef(({nodes:e,edges:t,defaultNodes:n,defaultEdges:s,className:a,nodeTypes:o=o9,edgeTypes:i=i9,onNodeClick:l,onEdgeClick:u,onInit:d,onMove:f,onMoveStart:p,onMoveEnd:m,onConnect:w,onConnectStart:x,onConnectEnd:b,onClickConnectStart:j,onClickConnectEnd:k,onNodeMouseEnter:v,onNodeMouseMove:S,onNodeMouseLeave:C,onNodeContextMenu:_,onNodeDoubleClick:R,onNodeDragStart:A,onNodeDrag:I,onNodeDragStop:$,onNodesDelete:U,onEdgesDelete:F,onSelectionChange:M,onSelectionDragStart:B,onSelectionDrag:T,onSelectionDragStop:P,onSelectionContextMenu:q,onSelectionStart:K,onSelectionEnd:z,connectionMode:H=li.Strict,connectionLineType:D=Va.Bezier,connectionLineStyle:O,connectionLineComponent:V,connectionLineContainerStyle:Z,deleteKeyCode:W="Backspace",selectionKeyCode:X="Shift",selectionOnDrag:Y=!1,selectionMode:J=Yu.Full,panActivationKeyCode:Q="Space",multiSelectionKeyCode:te=Qf()?"Meta":"Control",zoomActivationKeyCode:le=Qf()?"Meta":"Control",snapToGrid:de=!1,snapGrid:oe=c9,onlyRenderVisibleElements:re=!1,selectNodesOnDrag:he=!0,nodesDraggable:fe,nodesConnectable:$e,nodesFocusable:ye,nodeOrigin:ge=l9,edgesFocusable:je,edgesUpdatable:Le,elementsSelectable:ke,defaultViewport:Ie=u9,minZoom:De=.5,maxZoom:Ue=2,translateExtent:Ke=N1,preventScrolling:we=!0,nodeExtent:Fe,defaultMarkerColor:Re="#b1b1b7",zoomOnScroll:Ae=!0,zoomOnPinch:rt=!0,panOnScroll:We=!1,panOnScrollSpeed:se=.5,panOnScrollMode:be=Xo.Free,zoomOnDoubleClick:Te=!0,panOnDrag:Oe=!0,onPaneClick:ve,onPaneMouseEnter:pe,onPaneMouseMove:_e,onPaneMouseLeave:ze,onPaneScroll:at,onPaneContextMenu:tt,children:xt,onEdgeContextMenu:Mt,onEdgeDoubleClick:Xt,onEdgeMouseEnter:tr,onEdgeMouseMove:Cs,onEdgeMouseLeave:zn,onEdgeUpdate:ts,onEdgeUpdateStart:_s,onEdgeUpdateEnd:sn,onReconnect:zt,onReconnectStart:Me,onReconnectEnd:Ve,reconnectRadius:Xe=10,edgeUpdaterRadius:Tt=10,onNodesChange:Ct,onEdgesChange:qt,noDragClassName:Vn="nodrag",noWheelClassName:nr="nowheel",noPanClassName:Es="nopan",fitView:gn=!1,fitViewOptions:_r,connectOnClick:ga=!0,attributionPosition:Er,proOptions:Ts,defaultEdgeOptions:Tr,elevateNodesOnSelect:ya=!0,elevateEdgesOnSelect:Ar=!1,disableKeyboardA11y:Rr=!1,autoPanOnConnect:ho=!0,autoPanOnNodeDrag:yt=!0,connectionRadius:wa=20,isValidConnection:ns,onError:xa,style:As,id:Mr,nodeDragThreshold:sr,...Rs},dn)=>{const $t=Mr||"1";return me.createElement("div",{...Rs,style:{...As,...d9},ref:dn,className:mn(["react-flow",a]),"data-testid":"rf__wrapper",id:Mr},me.createElement(O4,null,me.createElement(r9,{onInit:d,onMove:f,onMoveStart:p,onMoveEnd:m,onNodeClick:l,onEdgeClick:u,onNodeMouseEnter:v,onNodeMouseMove:S,onNodeMouseLeave:C,onNodeContextMenu:_,onNodeDoubleClick:R,nodeTypes:o,edgeTypes:i,connectionLineType:D,connectionLineStyle:O,connectionLineComponent:V,connectionLineContainerStyle:Z,selectionKeyCode:X,selectionOnDrag:Y,selectionMode:J,deleteKeyCode:W,multiSelectionKeyCode:te,panActivationKeyCode:Q,zoomActivationKeyCode:le,onlyRenderVisibleElements:re,selectNodesOnDrag:he,defaultViewport:Ie,translateExtent:Ke,minZoom:De,maxZoom:Ue,preventScrolling:we,zoomOnScroll:Ae,zoomOnPinch:rt,zoomOnDoubleClick:Te,panOnScroll:We,panOnScrollSpeed:se,panOnScrollMode:be,panOnDrag:Oe,onPaneClick:ve,onPaneMouseEnter:pe,onPaneMouseMove:_e,onPaneMouseLeave:ze,onPaneScroll:at,onPaneContextMenu:tt,onSelectionContextMenu:q,onSelectionStart:K,onSelectionEnd:z,onEdgeContextMenu:Mt,onEdgeDoubleClick:Xt,onEdgeMouseEnter:tr,onEdgeMouseMove:Cs,onEdgeMouseLeave:zn,onReconnect:zt??ts,onReconnectStart:Me??_s,onReconnectEnd:Ve??sn,reconnectRadius:Xe??Tt,defaultMarkerColor:Re,noDragClassName:Vn,noWheelClassName:nr,noPanClassName:Es,elevateEdgesOnSelect:Ar,rfId:$t,disableKeyboardA11y:Rr,nodeOrigin:ge,nodeExtent:Fe}),me.createElement(ez,{nodes:e,edges:t,defaultNodes:n,defaultEdges:s,onConnect:w,onConnectStart:x,onConnectEnd:b,onClickConnectStart:j,onClickConnectEnd:k,nodesDraggable:fe,nodesConnectable:$e,nodesFocusable:ye,edgesFocusable:je,edgesUpdatable:Le,elementsSelectable:ke,elevateNodesOnSelect:ya,minZoom:De,maxZoom:Ue,nodeExtent:Fe,onNodesChange:Ct,onEdgesChange:qt,snapToGrid:de,snapGrid:oe,connectionMode:H,translateExtent:Ke,connectOnClick:ga,defaultEdgeOptions:Tr,fitView:gn,fitViewOptions:_r,onNodesDelete:U,onEdgesDelete:F,onNodeDragStart:A,onNodeDrag:I,onNodeDragStop:$,onSelectionDrag:T,onSelectionDragStart:B,onSelectionDragStop:P,noPanClassName:Es,nodeOrigin:ge,rfId:$t,autoPanOnConnect:ho,autoPanOnNodeDrag:yt,onError:xa,connectionRadius:wa,isValidConnection:ns,nodeDragThreshold:sr}),me.createElement(J7,{onSelectionChange:M}),xt,me.createElement(C7,{proOptions:Ts,position:Er}),me.createElement(az,{rfId:$t,disableKeyboardA11y:Rr})))});P4.displayName="ReactFlow";const h9=e=>({x:e.transform[0],y:e.transform[1],zoom:e.transform[2]});function D4(){return ft(h9,nn)}const F4=({id:e,x:t,y:n,width:s,height:a,style:o,color:i,strokeColor:l,strokeWidth:u,className:d,borderRadius:f,shapeRendering:p,onClick:m,selected:w})=>{const{background:x,backgroundColor:b}=o||{},j=i||x||b;return me.createElement("rect",{className:mn(["react-flow__minimap-node",{selected:w},d]),x:t,y:n,rx:f,ry:f,width:s,height:a,fill:j,stroke:l,strokeWidth:u,shapeRendering:p,onClick:m?k=>m(k,e):void 0})};F4.displayName="MiniMapNode";var f9=g.memo(F4);const p9=e=>e.nodeOrigin,m9=e=>e.getNodes().filter(t=>!t.hidden&&t.width&&t.height),Yy=e=>e instanceof Function?e:()=>e;function g9({nodeStrokeColor:e="transparent",nodeColor:t="#e2e2e2",nodeClassName:n="",nodeBorderRadius:s=5,nodeStrokeWidth:a=2,nodeComponent:o=f9,onClick:i}){const l=ft(m9,nn),u=ft(p9),d=Yy(t),f=Yy(e),p=Yy(n),m=typeof window>"u"||window.chrome?"crispEdges":"geometricPrecision";return me.createElement(me.Fragment,null,l.map(w=>{const{x,y:b}=ei(w,u).positionAbsolute;return me.createElement(o,{key:w.id,x,y:b,width:w.width,height:w.height,style:w.style,selected:w.selected,className:p(w),color:d(w),borderRadius:s,strokeColor:f(w),strokeWidth:a,shapeRendering:m,onClick:i,id:w.id})}))}var y9=g.memo(g9);const w9=200,x9=150,v9=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?T7(Gp(t,e.nodeOrigin),n):n,rfId:e.rfId}},b9="react-flow__minimap-desc";function B4({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:d="none",maskStrokeWidth:f=1,position:p="bottom-right",onClick:m,onNodeClick:w,pannable:x=!1,zoomable:b=!1,ariaLabel:j="React Flow mini map",inversePan:k=!1,zoomStep:v=10,offsetScale:S=5}){const C=Ht(),_=g.useRef(null),{boundingRect:R,viewBB:A,rfId:I}=ft(v9,nn),$=(e==null?void 0:e.width)??w9,U=(e==null?void 0:e.height)??x9,F=R.width/$,M=R.height/U,B=Math.max(F,M),T=B*$,P=B*U,q=S*B,K=R.x-(T-R.width)/2-q,z=R.y-(P-R.height)/2-q,H=T+q*2,D=P+q*2,O=`${b9}-${I}`,V=g.useRef(0);V.current=B,g.useEffect(()=>{if(_.current){const X=ms(_.current),Y=te=>{const{transform:le,d3Selection:de,d3Zoom:oe}=C.getState();if(te.sourceEvent.type!=="wheel"||!de||!oe)return;const re=-te.sourceEvent.deltaY*(te.sourceEvent.deltaMode===1?.05:te.sourceEvent.deltaMode?1:.002)*v,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:fe}=C.getState();if(te.sourceEvent.type!=="mousemove"||!de||!oe)return;const $e=V.current*Math.max(1,le[2])*(k?-1:1),ye={x:le[0]-te.sourceEvent.movementX*$e,y:le[1]-te.sourceEvent.movementY*$e},ge=[[0,0],[he,fe]],je=sa.translate(ye.x,ye.y).scale(le[2]),Le=oe.constrain()(je,ge,re);oe.transform(de,Le)},Q=Y3().on("zoom",x?J:null).on("zoom.wheel",b?Y:null);return X.call(Q),()=>{X.on("zoom",null)}}},[x,b,k,v]);const Z=m?X=>{const Y=Vs(X);m(X,{x:Y[0],y:Y[1]})}:void 0,W=w?(X,Y)=>{const J=C.getState().nodeInternals.get(Y);w(X,J)}:void 0;return me.createElement(Xj,{position:p,style:e,className:mn(["react-flow__minimap",t]),"data-testid":"rf__minimap"},me.createElement("svg",{width:$,height:U,viewBox:`${K} ${z} ${H} ${D}`,role:"img","aria-labelledby":O,ref:_,onClick:Z},j&&me.createElement("title",{id:O},j),me.createElement(y9,{onClick:W,nodeColor:s,nodeStrokeColor:n,nodeBorderRadius:o,nodeClassName:a,nodeStrokeWidth:i,nodeComponent:l}),me.createElement("path",{className:"react-flow__minimap-mask",d:`M${K-q},${z-q}h${H+q*2}v${D+q*2}h${-H-q*2}z
|
|
57
|
+
M${A.x},${A.y}h${A.width}v${A.height}h${-A.width}z`,fill:u,fillRule:"evenodd",stroke:d,strokeWidth:f,pointerEvents:"none"})))}B4.displayName="MiniMap";var k9=g.memo(B4);function j9(){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 N9(){return me.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 32 5"},me.createElement("path",{d:"M0 0h32v4.2H0z"}))}function S9(){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 C9(){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 _9(){return me.createElement("svg",{xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 25 32"},me.createElement("path",{d:"M21.333 10.667H19.81V7.619C19.81 3.429 16.38 0 12.19 0c-4.114 1.828-1.37 2.133.305 2.438 1.676.305 4.42 2.59 4.42 5.181v3.048H3.047A3.056 3.056 0 000 13.714v15.238A3.056 3.056 0 003.048 32h18.285a3.056 3.056 0 003.048-3.048V13.714a3.056 3.056 0 00-3.048-3.047zM12.19 24.533a3.056 3.056 0 01-3.047-3.047 3.056 3.056 0 013.047-3.048 3.056 3.056 0 013.048 3.048 3.056 3.056 0 01-3.048 3.047z"}))}const fs=({children:e,className:t,...n})=>me.createElement("button",{type:"button",className:mn(["react-flow__controls-button",t]),...n},e);fs.displayName="ControlButton";const E9=e=>({isInteractive:e.nodesDraggable||e.nodesConnectable||e.elementsSelectable,minZoomReached:e.transform[2]<=e.minZoom,maxZoomReached:e.transform[2]>=e.maxZoom}),q4=({style:e,showZoom:t=!0,showFitView:n=!0,showInteractive:s=!0,fitViewOptions:a,onZoomIn:o,onZoomOut:i,onFitView:l,onInteractiveChange:u,className:d,children:f,position:p="bottom-left"})=>{const m=Ht(),[w,x]=g.useState(!1),{isInteractive:b,minZoomReached:j,maxZoomReached:k}=ft(E9,nn),{zoomIn:v,zoomOut:S,fitView:C}=Ql();if(g.useEffect(()=>{x(!0)},[]),!w)return null;const _=()=>{v(),o==null||o()},R=()=>{S(),i==null||i()},A=()=>{C(a),l==null||l()},I=()=>{m.setState({nodesDraggable:!b,nodesConnectable:!b,elementsSelectable:!b}),u==null||u(!b)};return me.createElement(Xj,{className:mn(["react-flow__controls",d]),position:p,style:e,"data-testid":"rf__controls"},t&&me.createElement(me.Fragment,null,me.createElement(fs,{onClick:_,className:"react-flow__controls-zoomin",title:"zoom in","aria-label":"zoom in",disabled:k},me.createElement(j9,null)),me.createElement(fs,{onClick:R,className:"react-flow__controls-zoomout",title:"zoom out","aria-label":"zoom out",disabled:j},me.createElement(N9,null))),n&&me.createElement(fs,{className:"react-flow__controls-fitview",onClick:A,title:"fit view","aria-label":"fit view"},me.createElement(S9,null)),s&&me.createElement(fs,{className:"react-flow__controls-interactive",onClick:I,title:"toggle interactivity","aria-label":"toggle interactivity"},b?me.createElement(_9,null):me.createElement(C9,null)),f)};q4.displayName="Controls";var T9=g.memo(q4),Ys;(function(e){e.Lines="lines",e.Dots="dots",e.Cross="cross"})(Ys||(Ys={}));function A9({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 R9({color:e,radius:t}){return me.createElement("circle",{cx:t,cy:t,r:t,fill:e})}const M9={[Ys.Dots]:"#91919a",[Ys.Lines]:"#eee",[Ys.Cross]:"#e2e2e2"},$9={[Ys.Dots]:1,[Ys.Lines]:1,[Ys.Cross]:6},L9=e=>({transform:e.transform,patternId:`pattern-${e.rfId}`});function U4({id:e,variant:t=Ys.Dots,gap:n=20,size:s,lineWidth:a=1,offset:o=2,color:i,style:l,className:u}){const d=g.useRef(null),{transform:f,patternId:p}=ft(L9,nn),m=i||M9[t],w=s||$9[t],x=t===Ys.Dots,b=t===Ys.Cross,j=Array.isArray(n)?n:[n,n],k=[j[0]*f[2]||1,j[1]*f[2]||1],v=w*f[2],S=b?[v,v]:k,C=x?[v/o,v/o]:[S[0]/o,S[1]/o];return me.createElement("svg",{className:mn(["react-flow__background",u]),style:{...l,position:"absolute",width:"100%",height:"100%",top:0,left:0},ref:d,"data-testid":"rf__background"},me.createElement("pattern",{id:p+e,x:f[0]%k[0],y:f[1]%k[1],width:k[0],height:k[1],patternUnits:"userSpaceOnUse",patternTransform:`translate(-${C[0]},-${C[1]})`},x?me.createElement(R9,{color:m,radius:v/o}):me.createElement(A9,{dimensions:S,color:m,lineWidth:a})),me.createElement("rect",{x:"0",y:"0",width:"100%",height:"100%",fill:`url(#${p+e})`}))}U4.displayName="Background";var I9=g.memo(U4);function O9(e,t){return e?t==="gone"?"entering":t==="leaving"?"here":t:t==="gone"?"gone":"leaving"}function Ya(e){return e!=="gone"}function YE(e,t){return e||Ya(t)}function XE(e,t){return!e&&Ya(t)}function bl(e,t){const[n,s]=g.useState(()=>e?"here":"gone"),a=g.useRef(null);return g.useEffect(()=>{s(o=>O9(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 W4=.2,H4=1.6;function P9(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<W4||a>H4?null:{x:n,y:s,zoom:a}}function S1({durationMs:e,documentHidden:t,reducedMotion:n=xd()}){return t||n?!1:Number.isFinite(e)&&e>0}function xd(){return typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches}function lN(){return{agents:new Map,toolIndex:new Map,activeSubagentStack:new Map,subagentTombstones:new Map,parkedEnrichment:new Map,pendingSubagentModels:new Map,lastSeq:0,seqEpoch:null,totalEvents:0,revision:0}}function fa(e,t){return`${e}::${t}`}function ec(e,t){return`${e}\0${t}`}const D9=/[0-9a-f]{16,}/i,F9=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function z4(e){return D9.test(e)||F9.test(e)}function B9(e){if(!e)return;const t=e.replace(/\\/g,"/").split("/").filter(Boolean);for(let n=t.length-1;n>=0;n--)if(!z4(t[n]))return t[n];return t[t.length-1]}function V4(){return{inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0}}function G4(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 Kp(e){const t=G4(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=Kp({...e.longContext,longContext:void 0})),n}function q9(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]=Kp(a);const o=U9(a.speeds);o&&(t[n].bySpeed=o)}return Object.keys(t).length?t:void 0}function U9(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,Kp(s)]);return t.length?Object.fromEntries(t):void 0}function K4(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),...G4(n)};for(const s of Object.values(n)){const a=K4(s,t+1);if(a)return a}return null}function cN(e){return B9(e)}function uN(e){const t=e.agent_type??e.subagent_type;return t&&!z4(t)?t:"subagent"}function tc(e){return e.agent_id?e.agent_id:e.parent_tool_use_id?e.parent_tool_use_id:null}function ui(e,t){!e.cwd&&t.cwd&&(e.cwd=t.cwd,e.cwdBasename=cN(t.cwd))}function dN(e,t){e.label==="session"&&t.cwd&&(e.label=cN(t.cwd)??"session")}function Y4(e,t){const n=uN(t);n&&(e.label==="subagent"||!e.label)&&(e.label=n)}function oo(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:V4()},e.agents.set(a,o),o)}function X4(e,t,n,s){const a=fa(t,n),o=e.agents.get(a);return o?(ui(o,s),Y4(o,s),o):null}function W9(e,t,n){var d;const s=t.session_id??"unknown",a=tc(t);if(a){const f=X4(e,s,a,t);if(f)return f}const i=((d=e.agents.get(s))==null?void 0:d.keyedSubagents)===!0?void 0:e.activeSubagentStack.get(s),l=i&&i.length>0?i[i.length-1]:null;if(l){const f=e.agents.get(fa(s,l));if(f)return ui(f,t),f}const u=oo(e,s,n,t.hook_event_name!=="SessionStart");return ui(u,t),dN(u,t),u}function H9(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 z9(e,t,n,s,a){const o=fa(t,n),i=oo(e,t,a,!0);let l=e.agents.get(o);if(l)return ui(l,s),Y4(l,s),l;l={id:o,sessionId:t,label:uN(s),kind:"subagent",parentId:i.id,state:"active",startedAt:a,tools:[],prompts:[],cwd:s.cwd,cwdBasename:cN(s.cwd),toolCount:0,childCount:0,usage:V4()},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 V9(e,t,n){const s=e.activeSubagentStack.get(t)??[];s.includes(n)||(s.push(n),e.activeSubagentStack.set(t,s))}function Z4(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 G9=new Set(["PreToolUse","PostToolUse","PostToolUseFailure","Stop","SubagentStop"]),J4=/^[a-z][a-z0-9_-]{0,23}$/i;function K9(e,t){if(t.provider==="codex")return;const n=t.effort&&typeof t.effort=="object"?t.effort.level:void 0;return typeof n=="string"&&J4.test(n)?n:G9.has(e)?null:void 0}function Q4(){return{msgsUser:0,msgsAssistant:0,toolUses:0,toolResults:0,systemReminders:0,currentContextTokens:0,memoryFiles:[]}}function hN(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"&&J4.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??Q4(),currentContextTokens:t.context_tokens})}}const Y9=6e4,ZE=64;function eP(e,t,n){const s=typeof t.model=="string"?t.model:null;if(s){const o=e.agents.get(n);o&&(o.model=s)}const a=t.subagentModels;if(a&&typeof a=="object")for(const[o,i]of Object.entries(a)){if(typeof i!="string")continue;const l=fa(n,o),u=e.agents.get(l);if(u)u.model=i,e.pendingSubagentModels.delete(l);else if(e.pendingSubagentModels.delete(l),e.pendingSubagentModels.set(l,i),e.pendingSubagentModels.size>256){const d=e.pendingSubagentModels.keys().next().value;d!==void 0&&e.pendingSubagentModels.delete(d)}}}function tP(e,t,n){const s=t.context??null;if(s){const a=e.agents.get(n);if(a){const o=a.context??Q4(),i=(u,d)=>typeof s[u]=="number"?s[u]:d,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 nP(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 X9(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 sP(e,t,n){const s=e.agents.get(n),a=t.activity;!s||!a||typeof a.text!="string"||!a.text.trim()||!Number.isFinite(a.at)||s.activity&&a.at<s.activity.at||(s.activity={text:a.text.trim(),source:a.source==="said"?"said":"tool",at:a.at})}const Z9=new Set(["working","blocked","done","failed","stopped"]);function rP(e,t,n){const s=e.agents.get(n);if(!s)return;const a=t.job;if(a===null){s.job=void 0;return}if(!a||typeof a!="object"||!Z9.has(a.state))return;const o=i=>typeof i=="string"&&i.trim()?i.trim():void 0;s.job={id:o(a.id)??"",state:a.state,detail:o(a.detail)??"",needs:o(a.needs),suggestedReply:o(a.suggestedReply),result:o(a.result),updatedAt:Number.isFinite(a.updatedAt)?a.updatedAt:0}}function J9(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<Y9);l.push(o),i.outputs=l.length>ZE?l.slice(-ZE):l}e.revision+=1}}function fN(e,t,n){const s=t.usage??null;if(s){const a=e.agents.get(n);if(a){const o=Kp(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=q9(t.usageByModel))}}}function Kt(e,t){return Object.hasOwn(e,t)?e[t]:void 0}const Q9=/^\s*<task-notification>([\s\S]*?)<\/task-notification>/;function JE(e,t){var n;return((n=new RegExp(`<${t}>([\\s\\S]*?)</${t}>`).exec(e))==null?void 0:n[1].trim())||void 0}const eV={completed:"background task finished",failed:"background task failed",killed:"background task stopped"};function Yp(e){const t=Q9.exec(e);if(!t)return null;const n=JE(t[1],"status");return{label:(n?Kt(eV,n):void 0)??"background task update",detail:JE(t[1],"summary")}}function aP(e){return e.filter(t=>!Yp(t.text))}const QE=2e3;function tV(e,t,n){for(let s=e.length-1;s>=0;s--){const a=e[s];if(a.at<t-QE)return!1;if(a.text===n&&a.at<=t+QE)return!0}return!1}function nV(e,t,n){if(tV(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 np=2e3;function sV(e){const t=e.prompts[e.prompts.length-1];return t&&t.at>e.startedAt?t.at:e.startedAt}const eT=["B","KB","MB","GB","TB"];function Jn(e){if(e==null||!Number.isFinite(e)||e<0)return"—";if(e===0)return"0 B";let t=e,n=0;for(;n<eT.length-1&&Number(t.toFixed(1))>=1024;)t/=1024,n++;return`${t.toFixed(1)} ${eT[n]}`}const rV=60,aV=6e3,xs=e=>e!=null&&typeof e=="object"&&!Array.isArray(e),Xn=e=>typeof e=="string"?e:null;function oV(e){return xs(e)&&e.ccdeck_truncated===!0&&typeof e.chars=="number"&&Object.keys(e).length===2?e.chars:null}function ql(e){const t=oV(e);if(t!=null)return`(too large to show — ${Jn(t)}, cut by the hook)`;if(Array.isArray(e)){const n=e.map(ql);return n.some((s,a)=>s!==e[a])?n:e}if(xs(e)){let n=!1;const s={};for(const[a,o]of Object.entries(e))s[a]=ql(o),s[a]!==o&&(n=!0);return n?s:e}return e}function di(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=di(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 iV(e){return e.lines??e.text.split(`
|
|
61
|
+
`).map(t=>({text:t}))}function oP(e,t){if(t)return{shown:e,cut:!1};const n=[];let s=0;for(const a of e){if(n.length===rV)return{shown:n,cut:!0};const o=aV-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 lV(e,t){return oP(e,!1).cut?t?{label:"show less",expanded:!0}:{label:"show all",expanded:!1}:null}const Cn=(e,t,n=!1)=>({...e?{label:e}:{},text:t,...n?{err:!0}:{}}),Zn=(e,t)=>({label:e,text:t,inline:!0}),iP=(e,t)=>({label:e,text:t.map(n=>n.text).join(`
|
|
62
|
+
`),lines:t});function cV(e,t){return[...e.split(`
|
|
63
|
+
`).map(n=>({text:`- ${n}`,tone:"del"})),...t.split(`
|
|
64
|
+
`).map(n=>({text:`+ ${n}`,tone:"add"}))]}function uV(e){if(!Array.isArray(e)||e.length===0)return null;const t=[];for(const n of e){if(!xs(n)||!Array.isArray(n.lines))return null;t.push({text:`@@ -${n.oldStart},${n.oldLines} +${n.newStart},${n.newLines} @@`,tone:"ctx"});for(const s of n.lines){const a=String(s);t.push(a.startsWith("+")?{text:a,tone:"add"}:a.startsWith("-")?{text:a,tone:"del"}:{text:a})}}return t}function tT(e){if(typeof e=="string")return[Cn(void 0,e)];if(!xs(e))return[Cn(void 0,di(e))];const t=[],n=Xn(e.type);n==="create"&&t.push(Zn("result","created the file"));const s=uV(e.structuredPatch);return s&&t.push(iP("applied",s)),e.userModified===!0&&t.push(Zn("note","the user changed it before it was applied")),t.length?t:[Zn("result",n==="update"?"updated the file":"done")]}function dV(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 hV(e){if(typeof e=="string")return[Cn(void 0,e)];const t=xs(e)&&xs(e.file)?e.file:null,n=Xn(t==null?void 0:t.content);if(t&&n!=null){const a=[],o=Number(t.numLines),i=Number(t.totalLines),l=Number(t.startLine);return Number.isFinite(o)&&Number.isFinite(i)&&i>0&&a.push(Zn("lines",o>=i?`all ${i}`:Number.isFinite(l)?`${l}–${l+o-1} of ${i}`:`${o} of ${i}`)),a.push(Cn("content",n)),a}const s=xs(e)?Xn(e.type):null;return s&&s!=="text"?[Zn("result",`${/^[aeiou]/i.test(s)?"an":"a"} ${s} file`)]:[Cn(void 0,di(e))]}function fV(e){if(typeof e=="string")return[Cn("output",e)];if(!xs(e))return[Cn(void 0,di(e))];const t=Xn(e.stdout),n=Xn(e.stderr);if(t==null&&n==null)return[Cn(void 0,di(e))];const s=[];return t&&s.push(Cn("output",t.replace(/\n$/,""))),n&&s.push(Cn("errors",n.replace(/\n$/,""),!0)),e.interrupted===!0&&s.push(Zn("note","interrupted before it finished")),s.length?s:[Zn("output","none")]}function pV(e,t,n){const s=ql(t),a=ql(n),o=xs(s)?s:null;if(o&&(e==="Edit"||e==="MultiEdit")){const i=Xn(o.file_path),l=(e==="MultiEdit"?Array.isArray(o.edits)?o.edits:[]:[o]).filter(xs).filter(u=>Xn(u.old_string)!=null&&Xn(u.new_string)!=null);if(i&&l.length){const u=[Zn("file",i)];return l.forEach((d,f)=>{const p=d.replace_all===!0?", every occurrence":"";u.push(iP(l.length>1?`change ${f+1}${p}`:`change${p}`,cV(d.old_string,d.new_string)))}),{input:u,response:tT(a)}}}if(o&&e==="Write"){const i=Xn(o.file_path),l=Xn(o.content);if(i&&l!=null)return{input:[Zn("file",i),Cn("content",l)],response:tT(a)}}if(o&&e==="Read"){const i=Xn(o.file_path);if(i){const l=dV(o);return{input:l?[Zn("file",i),Zn("lines",l)]:[Zn("file",i)],response:hV(a)}}}if(o&&e==="Bash"){const i=Xn(o.command);if(i!=null){const l=Xn(o.description);return{input:l?[Cn("command",i),Zn("why",l)]:[Cn("command",i)],response:fV(a)}}}return{input:[Cn(void 0,di(s))],response:[Cn(void 0,di(a))]}}function nT(e,t,n){const s=ql(n);if(s==null)return"";if(typeof s=="string")return s;if(xs(s)){if(e==="Bash"&&t==="input"&&typeof s.command=="string")return s.command;if(e==="Bash"&&t==="response"&&(typeof s.stdout=="string"||typeof s.stderr=="string"))return[s.stdout,s.stderr].filter(a=>typeof a=="string"&&a!=="").join(`
|
|
65
|
+
`);if(e==="Read"&&t==="response"&&xs(s.file)&&typeof s.file.content=="string")return s.file.content}try{return JSON.stringify(s,null,2)??String(s)}catch{return String(s)}}const mV=new Set(["TodoWrite","update_plan"]),gV=new Set(["TaskCreate","TaskUpdate","TaskList","TaskGet"]);function bu(e){return e==="pending"||e==="in_progress"||e==="completed"?e:null}function ps(e){return typeof e=="string"?e.trim():""}function Ho(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 yV(e,t){const n=Ho(t);if(!n)return null;const s=e==="TodoWrite"?n.todos:n.plan;if(!Array.isArray(s))return null;const a=[];for(const i of s){if(!i||typeof i!="object")continue;const l=i,u=ps(e==="TodoWrite"?l.content:l.step),d=bu(l.status);if(!u||!d)continue;const f=ps(l.activeForm??l.active_form);a.push(f?{text:u,status:d,active:f}:{text:u,status:d})}const o=e==="update_plan"?ps(n.explanation):"";return o?{items:a,note:o}:{items:a}}function Ua(e,t,n){return n?{items:e,at:t,note:n}:{items:e,at:t}}function wV(e,t,n,s){if(!t||!mV.has(t)||e.plan&&s<e.plan.at)return;const a=yV(t,n);a&&(e.plan=Ua(a.items,s,a.note))}function al(e){if(!e)return"";const t=e.taskId??e.id??e.task_id;return typeof t=="number"?String(t):ps(t)}function xV(e,t,n,s,a){var b,j,k,v,S,C,_,R,A,I,$,U,F,M,B;if(!t||!gV.has(t))return;const o=Ho(n),i=Ho(s),l=((b=e.plan)==null?void 0:b.items)??[],u=T=>l.findIndex(P=>P.id===T);if(t==="TaskCreate"){const T=Ho(i==null?void 0:i.task),P=al(T),q=ps(T==null?void 0:T.subject)||ps(o==null?void 0:o.subject);if(!P||!q)return;const K=ps((o==null?void 0:o.activeForm)??(o==null?void 0:o.active_form)),z=u(P),H={id:P,text:q,status:z>=0?l[z].status:"pending",...K?{active:K}:{}},D=l.slice();z>=0?D[z]=H:D.push(H),e.plan=Ua(D,Math.max(a,((j=e.plan)==null?void 0:j.at)??a),(k=e.plan)==null?void 0:k.note);return}if(t==="TaskUpdate"){if(i&&i.success===!1)return;const T=al(i)||al(o);if(!T)return;const P=o==null?void 0:o.status,q=u(T);if(P==="deleted"){if(q<0)return;e.plan=Ua(l.filter((Z,W)=>W!==q),Math.max(a,((v=e.plan)==null?void 0:v.at)??a),(S=e.plan)==null?void 0:S.note);return}const K=ps(o==null?void 0:o.subject),z=ps((o==null?void 0:o.activeForm)??(o==null?void 0:o.active_form)),H=bu(P)??bu((C=Ho(i==null?void 0:i.statusChange))==null?void 0:C.to);if(q<0){if(!K)return;const Z={id:T,text:K,status:H??"pending",...z?{active:z}:{}};e.plan=Ua([...l,Z],Math.max(a,((_=e.plan)==null?void 0:_.at)??a),(R=e.plan)==null?void 0:R.note);return}const O={...l[q],...K?{text:K}:{},...H?{status:H}:{},...z?{active:z}:{}},V=l.slice();V[q]=O,e.plan=Ua(V,Math.max(a,((A=e.plan)==null?void 0:A.at)??a),(I=e.plan)==null?void 0:I.note);return}if(t==="TaskList"){if(!i||!Array.isArray(i.tasks)||e.plan&&a<e.plan.at)return;const T=[];for(const P of i.tasks){const q=Ho(P),K=al(q),z=ps(q==null?void 0:q.subject),H=bu(q==null?void 0:q.status);if(!K||!z||!H)continue;const D=l.find(O=>O.id===K);T.push(D!=null&&D.active?{id:K,text:z,status:H,active:D.active}:{id:K,text:z,status:H})}e.plan=Ua(T,a,($=e.plan)==null?void 0:$.note);return}const d=i&&"task"in i?Ho(i.task):void 0,f=al(d??null)||al(o),p=f?u(f):-1;if(p<0)return;if(d===null){e.plan=Ua(l.filter((T,P)=>P!==p),Math.max(a,((U=e.plan)==null?void 0:U.at)??a),(F=e.plan)==null?void 0:F.note);return}const m=ps(d==null?void 0:d.subject),w=bu(d==null?void 0:d.status);if(!m&&!w)return;const x=l.slice();x[p]={...l[p],...m?{text:m}:{},...w?{status:w}:{}},e.plan=Ua(x,Math.max(a,((M=e.plan)==null?void 0:M.at)??a),(B=e.plan)==null?void 0:B.note)}function Nr(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 pN(e){const t=`${e.done}/${e.total}`;return e.allDone||!e.current?`${t} · done`:`${t} · ${e.next?"next: ":""}${e.current}`}function lP(e){const t=`plan ${e.done} of ${e.total} done`;return e.allDone||!e.current?t:`${t}, ${e.next?"next":"now"}: ${e.current}`}function Xp(e){return e.map(t=>`${t.status==="completed"?"✓":t.status==="in_progress"?"▸":"○"} ${t.text}`).join(`
|
|
66
|
+
`)}function vV(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 Zu(e,t=80){const n=ql(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 sT=200;function cP(e,t,n){const s=t.ok===!1;t.ok=n,e&&s===n&&(e.toolErrorCount=(e.toolErrorCount??0)+(n?-1:1))}function uP(e,t){return t.agentId==null?void 0:e.agents.get(t.agentId)}function Au(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 bV(e,t,n){var s;return((s=e.get(t))==null?void 0:s.tools.find(a=>a.id===n))??null}const dP=25;function hP(e,t){const n=t.tools;if(n.length>sT){const s=n.splice(0,n.length-sT);for(const a of s)pP(e,t,a)}for(let s=n.length-dP-1;s>=0;s--){const a=n[s];if(a.trimmed)break;a.input=void 0,a.response=void 0,a.trimmed=!0}}function kV(e,t,n){const s=e.toolIndex.get(ec(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 fP(e,t){for(const n of t.tools)pP(e,t,n)}function pP(e,t,n){const s=ec(t.sessionId,n.id);e.toolIndex.get(s)===n&&e.toolIndex.delete(s)}function jV(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,Au(a,i.name,-1),i.ok===!1&&(a.toolErrorCount=(a.toolErrorCount??0)-1),i.agentId=n.id,n.tools.push(i),n.toolCount+=1,Au(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),hP(e,n);for(let a=0;a<n.tools.length-dP;a++){const o=n.tools[a];o.trimmed||(o.input=void 0,o.response=void 0,o.trimmed=!0)}}}const NV="no result reached the deck — events were dropped while the deck was paused";function mP(e,t,n,s,a){n.endedAt=s,cP(t,n,!1),n.errorPreview=n.outcomeGap?NV:a,e.toolIndex.delete(ec(t.sessionId,n.id))}function SV(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(ec((n==null?void 0:n.session_id)??"unknown",a))}function CV(e,t,n,s,a){const o=t.tool_use_id?kV(e,s,t.tool_use_id):null;if(o){if(t.tool_name&&o.name==="?"){o.name=t.tool_name;const d=uP(e,o);d&&(Au(d,"?",-1),Au(d,o.name,1))}o.endedAt==null&&!o.trimmed&&t.tool_input!==void 0&&(o.input=t.tool_input,o.inputPreview=Zu(t.tool_input));return}const i=t.tool_use_id??`${s.id}:${s.toolCount}`,l=tc(t),u={id:i,name:t.tool_name??"?",input:t.tool_input,inputPreview:Zu(t.tool_input),agentId:s.id,explicitSubagentId:l?fa(n,l):void 0,startedAt:a};s.tools.push(u),s.toolCount+=1,Au(s,u.name,1),s.state="active",e.toolIndex.set(ec(s.sessionId,i),u),hP(e,s),wV(s,u.name,t.tool_input,a)}function _V(e,t,n,s,a){const o=t.tool_use_id;if(!o)return;const i=ec(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&&xV(f,t.tool_name??l.name,t.tool_input??l.input,t.tool_response,a)}l.outcomeGap=void 0,l.endedAt=a,cP(uP(e,l),l,n==="PostToolUse"),l.trimmed||(l.response=t.tool_response),n==="PostToolUseFailure"?l.errorPreview=Zu(t.tool_response):u&&(l.errorPreview=void 0);const d=K4(t.tool_response);d&&(l.usage=d),e.toolIndex.delete(i)}function EV(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 mN(e,t){e!=null&&e.stopFailure&&t>e.stopFailure.at&&(e.stopFailure=null)}function TV(e,t,n,s){const a=oo(e,n,s,!1);a.synthetic=!1,a.state="active",a.closedAt=void 0,a.endedAt=void 0,mN(a,s),a.startedAt=Math.min(a.startedAt??s,s),ui(a,t),dN(a,t)}function AV(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=oo(e,n,s,!1);a.state="active",a.endedAt=void 0,a.closedAt=void 0,a.exitAt=void 0,mN(a,s);const o=(typeof t.prompt=="string"?t.prompt:typeof t.message=="string"?t.message:"")??"";o&&nV(a.prompts,s,o)&&!a.firstPrompt&&!Yp(o)&&(a.firstPrompt=Zu(o,120))}function C1(e,t,n,s,a){const o=oo(e,n,s,!1),i=sV(o);if(s<i)return;const l=o.lastTurnEndAt;if(!(l!=null&&i>l&&s<=l+np)){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 d of u.tools)d.endedAt==null&&d.explicitSubagentId==null&&mP(e,u,d,s,"the turn ended before this call returned");t==="SessionEnd"&&(o.closedAt=s),e.activeSubagentStack.delete(n)}}function RV(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&&(C1(e,t.recovery_session_closed===!0?"SessionEnd":"Stop",s,n),a.restoredFromLog=void 0);return}const o=oo(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,ui(o,t),dN(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=Zu(t.prompt,120))),hN(e,t,s),fN(e,t,s)}function MV(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=oo(e,s,n,!0);l.provider="codex",l.parentId=a,ui(l,t);const u=t.agent_nickname||t.agent_role;typeof u=="string"&&u.trim()&&(l.label=u);const d=e.agents.get(a);d&&(d.childCount=[...e.agents.values()].filter(f=>f.parentId===a).length)}const $V=["us-gov","global","apac","us","eu","jp","au"],LV=new RegExp(`^(?:(?:${$V.join("|")})\\.)?anthropic\\.`,"i");function mr(e){return e.replace(LV,"")}const IV=/^(?:claude[-_]|gpt[-_]|o\d|codex[-_])/i,OV=new Set(["tool_input","tool_response"]);function gP(e,t=0){if(!e||typeof e!="object"||t>6)return null;const n=e;if(typeof n.model=="string"&&IV.test(mr(n.model)))return n.model;for(const[s,a]of Object.entries(n)){if(OV.has(s))continue;const o=gP(a,t+1);if(o)return o}return null}const PV=256,Lf={ModelObserved:eP,UsageObserved:fN,ContextObserved:tP,SessionNamed:nP,ActivityObserved:sP,JobObserved:rP},Qr=e=>e!==null&&typeof e=="object"&&!Array.isArray(e),sf=e=>typeof e=="string"&&e.trim()!=="",DV=[["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]],FV=new Set(["working","blocked","done","failed","stopped"]),rT=e=>Qr(e)&&typeof e.text=="string"&&e.text.trim()!==""&&Number.isFinite(e.at);function BV(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 DV)o(t[a])||s(a);switch(t.hook_event_name){case"ModelObserved":typeof t.model=="string"&&t.model!==""||s("model"),(Qr(e.subagentModels)||Qr(t.subagentModels))&&(n.subagentModels={...Qr(e.subagentModels)?e.subagentModels:{},...Qr(t.subagentModels)?t.subagentModels:{}});break;case"ContextObserved":{if(!Qr(t.context)){s("context");break}const a=Qr(e.context)?{...e.context}:{};for(const[o,i]of Object.entries(t.context))(typeof i=="number"||Array.isArray(i))&&(a[o]=i);n.context=a;break}case"SessionNamed":{const a=sf(t.sessionName)?t.sessionName:e.sessionName??null;let o=sf(t.sessionTitle)?t.sessionTitle:e.sessionTitle??null;sf(a)&&sf(o)&&o.trim().toLowerCase()===a.trim().toLowerCase()&&(o=null),n.sessionName=a,n.sessionTitle=o;break}case"ActivityObserved":(!rT(t.activity)||rT(e.activity)&&t.activity.at<e.activity.at)&&s("activity");break;case"JobObserved":t.job===null||Qr(t.job)&&FV.has(t.job.state)||s("job");break;case"UsageObserved":Qr(t.usage)?t.usageByModel===void 0&&delete n.usageByModel:(s("usage"),s("usageByModel"));break}return n}function qV(e,t,n,s){if(!(t in Lf)||e.agents.has(s))return!1;const a=e.parkedEnrichment.get(s)??new Map,o=BV(a.get(t),n);for(a.delete(t),a.set(t,o),e.parkedEnrichment.delete(s),e.parkedEnrichment.set(s,a);e.parkedEnrichment.size>PV;){const i=e.parkedEnrichment.keys().next().value;if(i===void 0)break;e.parkedEnrichment.delete(i)}return!0}function UV(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)hN(e,o,t),(s=Lf[a])==null||s.call(Lf,e,o,t)}}function yP(e,t){e.parkedEnrichment.delete(t)}const WV="StopFailure",aT=Object.freeze({authentication_failed:"login",rate_limit:"usage-limit"});function HV(e){return typeof e=="string"&&Object.hasOwn(aT,e)?aT[e]:"api-error"}const zV=/^[a-z][a-z0-9_]{0,39}$/;function VV(e){const t=e==null?void 0:e.error;return typeof t=="string"&&zV.test(t)?t:"unknown"}const oT=160;function iT(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>oT?`${n.slice(0,oT-1).join("").trimEnd()}…`:t}function GV(e){return iT(e==null?void 0:e.last_assistant_message)||iT(e==null?void 0:e.error_details)}function KV(e,t){if(!e||typeof e!="object"||e.hook_event_name!==WV)return null;const n=VV(e);return{kind:HV(n),error:n,message:GV(e),at:t}}function YV(e,t,n,s){const a=tc(t);if(!a)return;const o=z9(e,n,a,t,s),i=uN(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<=np,d=l!=null&&s-l<=np;if(u||d){const f=d?l:o.endedAt;o.state="done",o.endedAt=f,o.startedAt=Math.min(o.startedAt,f),Z4(e,n,a);return}o.state="active",o.startedAt=o.startedAt||s,o.exitAt=void 0,o.endedAt=void 0,V9(e,n,a)}function XV(e,t,n,s){const a=tc(t);if(!a)return;const o=X4(e,n,a,t);if(!o){for(const[i,l]of e.subagentTombstones)s-l>np&&e.subagentTombstones.delete(i);e.subagentTombstones.set(fa(n,a),s);return}o.state="done",o.endedAt=Math.min(o.endedAt??s,s),Z4(e,n,a)}const ZV=["command","cmd","file_path","path","url","pattern","notebook_path"],lT=120,Xy=e=>e.length>lT?`${e.slice(0,lT-1)}…`:e;function JV(e){if(typeof e=="string")return e.trim()?Xy(e.trim()):null;if(!e||typeof e!="object"||Array.isArray(e))return null;const t=e;for(const n of ZV){const s=t[n];if(typeof s=="string"&&s.trim())return Xy(s.trim());if(Array.isArray(s)&&s.length>0&&s.every(a=>typeof a=="string")){const a=s.join(" ").trim();if(a)return Xy(a)}}return null}function QV(e){return e==="permission_prompt"?"permission":e==="agent_needs_input"?"asked":e==="idle_prompt"?"idle":null}const eG=new Set(["Notification","ModelObserved","ContextObserved","UsageObserved","SessionNamed","SessionRecapped","OutputObserved","ActivityObserved","JobObserved"]);function tG(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 nG=3e4;function sG(e,t){if(!(!e||!e.name)&&!(t-e.startedAt>nG)&&!(e.startedAt>t))return{name:e.name,preview:JV(e.input)??""}}function rG(e,t,n,s,a){if(n!=="permission")return{kind:n,message:s,since:a};const o=tG(e,t),i={kind:n,message:s,since:a};o!=null&&o.explicitSubagentId&&(i.subagentId=o.explicitSubagentId);const l=sG(o,a);return l&&(i.tool=l),i}function aG(e,t,n){if(e.kind==="idle")return!0;const s=tc(t);return s==null?!0:e.subagentId!=null&&fa(n,s)===e.subagentId}function oG(e,t,n,s){if(!eG.has(t)){const a=e.agents.get(s);a!=null&&a.waiting&&aG(a.waiting,n,s)&&(a.waiting=null)}}function iG(e,t,n,s){const a=QV(t.notification_type);if(!a)return;const o=oo(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)}:rG(e,n,a,i,s)}function Zp(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 vd(e,t){return t&&(e.revision+=1),t}function lG(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=Zp(e.agents.values()),l=new Set([...e.agents.values()].filter(w=>w.provider==="codex"&&!o(w)).map(w=>i.get(w.id))),u=[],d=new Map;for(const[w,x]of e.agents){if(x.parentId!=null){const b=d.get(x.parentId);b?b.push(w):d.set(x.parentId,[w])}o(x)&&!l.has(i.get(w))&&u.push({id:w,endedAt:x.endedAt})}if(u.length===0)return!1;u.sort((w,x)=>w.endedAt-x.endedAt);let f=0;const p=new Set,m=w=>{const x=e.agents.get(w);x&&(fP(e,x),e.agents.delete(w),x.kind==="root"&&yP(e,x.sessionId),p.add(x.sessionId),f++)};for(const w of u){if(e.agents.size<=n)break;if(!e.agents.has(w.id))continue;const x=[],b=new Set([w.id]),j=[...d.get(w.id)??[]];for(;j.length;){const k=j.pop();if(b.has(k))continue;b.add(k);const v=e.agents.get(k);v&&(x.push(v),j.push(...d.get(k)??[]))}if(!x.some(k=>!o(k))){for(const k of x.reverse())m(k.id);m(w.id)}}if(a&&p.size>0){const w=new Set;for(const x of e.agents.values())w.add(x.sessionId);for(const x of p)w.has(x)||a(x)}return vd(e,f>0)}function cG(e,t,n,s,a){const o=new Map;for(const[m,w]of e.agents){let x=o.get(w.sessionId);x||(x={ids:[],endedAt:0,live:!1,closed:!1},o.set(w.sessionId,x)),x.ids.push(m),w.kind==="root"&&w.closedAt!=null&&(x.closed=!0),w.state==="done"&&w.endedAt!=null?x.endedAt=Math.max(x.endedAt,w.endedAt):x.live=!0}const i=Zp(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 b of w.ids){const j=e.agents.get(b);j&&fP(e,j),e.agents.delete(b)}yP(e,m);const x=fa(m,"");for(const b of e.pendingSubagentModels.keys())b.startsWith(x)&&e.pendingSubagentModels.delete(b);a==null||a(m),f--,p=!0}return vd(e,p)}function uG(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 vd(e,t)}function dG(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&&(mP(e,a,l,u,"session ended before this call returned"),s=!0)}}return vd(e,s)}const cT=90*6e4;function hG(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 vd(e,s)}function Ju(e){let t=5381;for(let n=0;n<e.length;n++)t=(t<<5)+t^e.charCodeAt(n);return Math.abs(t)%360}function wP(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{...lN(),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 RV(e,s,a),e;if(o==="CodexThreadLinked")return MV(e,s,a),e;const i=s.session_id??"unknown";if(oG(e,o,s,i),o!=="JobObserved"&&EV(e,i,a),hN(e,s,i),qV(e,o,s,i))return e;switch(o){case"ModelObserved":return eP(e,s,i),e;case"ContextObserved":return tP(e,s,i),e;case"SessionNamed":return nP(e,s,i),e;case"SessionRecapped":return X9(e,s,i),e;case"ActivityObserved":return sP(e,s,i),e;case"JobObserved":return rP(e,s,i),e;case"OutputObserved":return J9(e,s,i,a),e;case"UsageObserved":return fN(e,s,i),e}const l=W9(e,s,a),u=e.agents.get(i);u&&a>=(u.recoveryLiveAt??0)&&(u.recoveryLiveAt=a,u.restoredFromLog=void 0),UV(e,i),H9(e,o,s,i)&&jV(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 d=gP(s),f=tc(s),p=f?fa(i,f):i;d&&l.id===p&&(l.model=d);const m=K9(o,s);switch(m!==void 0&&l.id===p&&(l.effort=m??void 0),(o==="PreToolUse"||o==="PostToolUse"||o==="PostToolUseFailure")&&f==null&&mN(e.agents.get(i),a),o){case"SessionStart":TV(e,s,i,a);break;case"UserPromptSubmit":AV(e,s,i,a);break;case"PreToolUse":CV(e,s,i,l,a);break;case"PostToolUse":case"PostToolUseFailure":_V(e,s,o,i,a);break;case"SubagentStart":YV(e,s,i,a);break;case"SubagentStop":XV(e,s,i,a);break;case"Stop":case"StopFailure":C1(e,o,i,a,{stopFailure:KV(s,a)});break;case"SessionEnd":C1(e,o,i,a);break;case"Notification":iG(e,s,i,a);break}return e}const fG="codex-auto-review",xP="chatgpt-auto-review-free",pG={input:2,output:10,cacheRead:.2,cacheWrite:2.5,cacheWrite1h:4},mG=[{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:pG},{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}}],gG=[{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 vP(e){return e?/^(?:gpt[-_]|codex[-_]|o\d)/i.test(e):!1}function br(e,t=Date.now(),n=ca){if(!e)return null;if(e===fG&&n===xP)return{input:0,output:0,cacheRead:0,cacheWrite:0};if(n!==ca&&vP(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:br(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=yG.get(n);if(!s)return null;const a=mr(e);for(const o of s)if(o.match.test(a))return typeof o.rates=="function"?o.rates(t):o.rates;return null}const ca="standard",yG=new Map([[ca,mG],["fast",gG]]);function Ru(e,t){return e*t/1e6}function bP(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:Ru(o,t.cacheWrite),usd1h:Ru(n,i)}}function kP(e,t,n=Date.now()){if(!vP(t))return e.inputTokens;const s=br(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 Jp(e,t,n=Date.now()){const s={input:0,output:0,cacheRead:0,cacheWrite:0,total:0};for(const a of bd(e)){const o=Qu(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 Qu(e,t,n,s=Date.now()){const a=br(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 jP(e,t)){const l=i.usage,u=NP(a,i.long);o.input+=Ru(kP(l,t,s),u.input),o.output+=Ru(l.outputTokens,u.output),o.cacheRead+=Ru(l.cacheReadTokens,u.cacheRead);const d=bP(l,u);o.cacheWrite+=d.usd5m+d.usd1h}return o.total=o.input+o.output+o.cacheRead+o.cacheWrite,o}function jP(e,t){if(!e.longContext||!/^claude[-_]haiku[-_]5[-_.]5\b(?![-_.]\d{1,7}(?!\d))/i.test(mr(t??"")))return[{usage:e,long:!1}];const n=e.longContext;return[{usage:gN(e,[n]),long:!1},{usage:n,long:!0}]}function NP(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 bd(e){const t=e.bySpeed?Object.entries(e.bySpeed):[];return t.length===0?[{speed:ca,usage:e}]:[{speed:ca,usage:gN(e,t.map(([,n])=>n))},...t.map(([n,s])=>({speed:n,usage:s}))]}function gN(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=gN(e.longContext,t.flatMap(o=>o.longContext?[o.longContext]:[]))),a}const ua="not priced";function Mu(e,t,n){const s=e.toFixed(t);return Number(s)<n?s:null}function lt(e){if(e<=0)return"—";if(e<.005)return"<1¢";if(e<1){const t=Mu(e*100,e<.1?1:0,100);if(t!==null)return`${t}¢`}if(e<100){const t=Mu(e,2,100);if(t!==null)return`$${t}`}if(e<1e4){const t=Mu(e,0,1e4);if(t!==null)return`$${t}`}return`$${(e/1e3).toFixed(1)}k`}function yN(e,t){if(e<=0||t<10)return null;const n=e/t,s=n*60;return s>=.01?`${lt(s)}/min`:`${lt(n*3600)}/hr`}function _1(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=_1(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?_1(i,o):o)}n.bySpeed=Object.fromEntries(s)}return n}function wG(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),d={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)&&(d.cacheCreate1hTokens=u(e.cacheCreate1hTokens??0,i),d.cacheCreate5mTokens=u(e.cacheCreate5mTokens??0,l)),d.inputTokens+d.outputTokens+d.cacheReadTokens+d.cacheCreateTokens>0?d:null}function nc(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=wG(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:_1(s[o].usage,a)}:s.push({model:e.model,usage:a})}return s}function Wn(e,t=Date.now()){const n={input:0,output:0,cacheRead:0,cacheWrite:0,total:0};for(const s of nc(e)){const a=Jp(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 E1(e,t=Date.now()){return nc(e).every(n=>{const s=bd(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=>br(n.model,t,a.speed)!==null):br(n.model,t)!==null})}function Ul(e,t=Date.now()){let n=0;for(const s of nc(e))for(const a of bd(s.usage))br(s.model,t,a.speed)==null&&(n+=a.usage.inputTokens+a.usage.outputTokens);return n}function SP(e){const t=[];for(const n of nc(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 wN(e){return SP(e).filter(t=>t!==e.model)}function uT(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
|
+
`:"")+xG(e,t)}function xG(e,t){if(!e.bySpeed)return Zy(e,t,ca);const n=bd(e).filter(s=>s.speed!==ca||CP(s.usage));return n.length===1?Zy(n[0].usage,t,n[0].speed):[...n.map(s=>Zy(s.usage,t,s.speed)),"═════════════════════════════════════════",`all speeds = ${lt(Jp(e,t).total)}`].join(`
|
|
68
|
+
`)}function CP(e){return e.inputTokens+e.outputTokens+e.cacheReadTokens+e.cacheCreateTokens>0}function Zy(e,t,n){const s=jP(e,t).filter(a=>CP(a.usage));return e.longContext&&s.some(a=>a.long)?[...s.map(a=>dT(a.usage,t,n,a.long)),`all context tiers = ${lt(Qu(e,t,n).total)}`].join(`
|
|
69
|
+
`):dT(e,t,n,!1)}function dT(e,t,n,s){const a=br(t,Date.now(),n),o=a?NP(a,s):null,i=s?" · prompt >100K":"",l=(n===xP?`model: ${t} · no charge for ChatGPT auto-review`:n===ca?`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=b=>b.toLocaleString(),d=b=>`$${b}/MTok`,f=Qu(s?{...e,longContext:e}:{...e,longContext:void 0},t,n),p=bP(e,o),m=p.tokens1h>0?[`cache w5m${u(p.tokens5m).padStart(14)} × ${d(o.cacheWrite).padEnd(11)} = ${lt(p.usd5m)}`,`cache w1h${u(p.tokens1h).padStart(14)} × ${d(o.cacheWrite1h??o.cacheWrite).padEnd(11)} = ${lt(p.usd1h)}`]:[`cache w ${u(p.tokens5m).padStart(14)} × ${d(o.cacheWrite).padEnd(11)} = ${lt(p.usd5m)}`],w=kP(e,t),x=w===e.inputTokens?"input":"uncached";return[l,`${x.padEnd(9)}${u(w).padStart(14)} × ${d(o.input).padEnd(11)} = ${lt(f.input)}`,`output ${u(e.outputTokens).padStart(14)} × ${d(o.output).padEnd(11)} = ${lt(f.output)}`,`cache r ${u(e.cacheReadTokens).padStart(14)} × ${d(o.cacheRead).padEnd(11)} = ${lt(f.cacheRead)}`,...m,"─────────────────────────────────────────",`total = ${lt(f.total)}`].join(`
|
|
71
|
+
`)}function hT(e){const t=nc(e),[n]=t;return t.length<=1?uT(n.usage,n.model):[...t.map(s=>uT(s.usage,s.model)),"═════════════════════════════════════════",`all models = ${lt(Wn(e).total)}`].join(`
|
|
72
|
+
`)}function vG(e){if(!e.model)return null;const t=br(e.model),n=Wn(e),s=Ul(e);if(!t&&n.total<=0&&s>0)return e.usage.inputTokens+e.usage.outputTokens<=0?null:{kind:"unpriced",tt:hT(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?yN(n.total,a):null,i=hT(e)+(o?`
|
|
73
|
+
burn: ${o}`:"");return{kind:"spent",total:n.total,floor:s>0,tt:i}}const bG=new Set(["untrusted","on-request","on-failure"]);function kG(e){return typeof e!="string"||!e?null:bG.has(e)?!0:e==="never"?!1:null}function _P(e){if(e.provider!=="codex"||e.kind!=="root"||e.waiting||e.state!=="active")return null;const t=kG(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 fT(e){return e[0].toUpperCase()+e.slice(1).toLowerCase()}function Qa(e){const t=mr(e).replace(/[-_]\d{8}(?!\d)/,""),n=t.match(/^claude[-_](opus|sonnet|haiku|fable|mythos)[-_](\d+(?:[-_.]\d+)*)/i);if(n){const a=fT(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(fT);return[`GPT-${a}`,...o].join(" ")}return e}function Qp(e){const t=mr(e??""),n=t.match(/^claude[-_](opus|sonnet|haiku|fable|mythos)[-_]/i);return n?n[1].toLowerCase():/^gpt[-_]/i.test(t)?"gpt":""}function em(e,t){return t?`${Qa(e)} · ${t}`:Qa(e)}function ed(e,t){return t?`${e}
|
|
76
|
+
effort: ${t}`:e}function jG(e){return!e.model&&e.provider!=="codex"?0:e.model&&e.effort?2:1}function NG(e,t){return(t.overflowing||t.folderCut)&&e<t.max?e+1:e}function SG(e){return{kind:e<1,effort:e<2}}function Tn(e){return(e==null?void 0:e.kind)==="permission"||(e==null?void 0:e.kind)==="asked"}function T1(e){const t=[];for(const n of e)n.kind==="root"&&Tn(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 CG(e,t){if(e.length===0)return null;const n=e.findIndex(s=>s.id===t);return e[(n+1)%e.length]}function _G(e){const t=new Set;for(const n of e)n.state==="active"&&t.add(n.sessionId);return t.size}function tm(e,t){return`${e}@${t.since}`}function EP(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 EG(e){const t=e.message||"Needs your permission",n=EP(e,t);return n?`${t}
|
|
77
|
+
Likely on: ${n}`:t}function TG(e,t,n,s=!0){if(!s)return[];if(n)return[];const a=[];for(const o of e){if(!Tn(o.waiting))continue;const i=tm(o.id,o.waiting);t.has(i)||a.push({key:i,title:o.label,body:EG(o.waiting),sessionId:o.id})}return a}function AG(e,t,n){const s=new Set;for(const o of e)s.add(tm(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 rf(e){return new Set(e.map(t=>tm(t.id,t.waiting)))}function RG(e,t){return e!==t}function MG(e,t){return!e&&t!=null}function $G(e,t){return e!==null&&t!=null}function xN(e){switch(e){case"login":return"login expired";case"usage-limit":return"usage limit";default:return"API error"}}function TP(e){return`Stopped · ${xN(e.kind)}`}function AP(e){const t=xN(e.kind);return t.charAt(0).toUpperCase()+t.slice(1)}function vN(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 LG(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 IG(e){return e.message?`It said: “${e.message}”`:""}function OG(e,t=!1){return[LG(e),IG(e),vN(e.kind,t)].filter(Boolean).join(`
|
|
78
|
+
`)}function PG(e,t=!1){return`${AP(e)}. ${vN(e.kind,t)}`}function DG(e){return`Claude Code's StopFailure hook${e!=null&&e.message?`: “${e.message}”`:""}`}function FG(e,t=!1){const n=vN(e.kind,t).replace(/\.$/,"");return`stopped, ${xN(e.kind)} — ${n.charAt(0).toLowerCase()}${n.slice(1)}`}function nm(e){return e.provider==="codex"&&e.parentId?"child session":e.kind==="root"?"session":"subagent"}function Wl(e){return e==="active"?"live":e==="done"?"done":"err"}function Hl(e){return e.message?e.message:e.kind==="permission"?"Needs your permission":"Waiting for your input"}function BG(e){return`${e} subagent${e===1?"":"s"} spawned`}function qG(e){const t=[nm(e)];if(e.childCount>0&&t.push(`→ ${e.childCount}`),e.kind==="subagent"&&e.cwdBasename&&t.push(e.cwdBasename),e.model){const n=wN(e).length;t.push(`${Qa(e.model)}${n>0?` +${n}`:""}`)}else e.provider==="codex"&&t.push("Codex");return t.join(" · ")}function UG(e,t=Date.now(),n=!1){const s=e.toolErrorCount??0,a=Wn(e,t).total;return[e.label,nm(e),e.kind==="root"&&e.stopFailure?FG(e.stopFailure,e.job!=null):Wl(e.state),Tn(e.waiting)?Hl(e.waiting):null,e.model?Qa(e.model):null,(()=>{const o=Nr(e.plan);return o?lP(o):null})(),`${e.toolCount} ${e.toolCount===1?"tool":"tools"}`,s>0?`${s} failed`:null,a>0?`${lt(a)}${Ul(e,t)>0?"+":""}`:null,n?"selected":null].filter(Boolean).join(", ")}function RP(e,t){const n=EP(e,t);return n?`Likely on: ${n}`:null}function sp(e){return e.kind==="idle"?"Your turn":Hl(e)}function St(e){const t=Math.round(e);if(t<1e3)return`${t}`;if(t<1e6){const n=Mu(t/1e3,1,1e3);if(n!==null)return`${n}k`}if(t<1e9){const n=Mu(t/1e6,2,1e3);if(n!==null)return`${n}M`}return`${(t/1e9).toFixed(2)}B`}function zl(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 MP(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 sm(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 pT=2e5,WG=1e6,HG=[/\[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],zG=[{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 VG(e){if(!e)return pT;const t=mr(e);for(const n of HG)if(n.test(t))return WG;for(const n of zG)if(n.match.test(t))return n.window;return pT}function $P(e,t){return typeof e=="number"&&e>0?e:VG(t)}const GG=1;function KG(){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 ln=KG(),rm=e=>e==="Escape";function YG(e){return e.overlayOpen?"dismiss":e.typing?"blur":"clear-selection"}function mT(e){return String(e.tagName??"").toUpperCase()==="BODY"}function gT(e,t){return!e||!e.isConnected||mT(e)?!1:t==null||mT(t)}const rp="a[href], button, input, select, textarea, summary, [tabindex]";function LP(e){return!e||e.disabled||e.rendered===!1?!1:(e.tabIndex??0)>=0}function XG(e){if(!e||!e.overflowing||e.hasFocusable)return!1;const t=String(e.overflow??"").toLowerCase();return t==="auto"||t==="scroll"}function ZG({count:e,index:t,shiftKey:n}){return e<=0?{kind:"hold"}:t<0||t>=e?{kind:"focus",index:n?e-1:0}:!n&&t===e-1?{kind:"focus",index:0}:n&&t===0?{kind:"focus",index:e-1}:{kind:"allow"}}function am(e){return e.ctrlKey||e.metaKey||e.altKey}function JG(e){e.key!=="Escape"&&e.key!=="Tab"&&e.stopPropagation()}const QG=new Set(["button","checkbox","color","file","image","radio","range","reset","submit"]),eK=new Set(["INPUT","TEXTAREA","SELECT","OPTION","BUTTON","SUMMARY","A"]),tK=new Set(["button","checkbox","combobox","link","listbox","menu","menubar","menuitem","menuitemcheckbox","menuitemradio","option","radio","searchbox","slider","spinbutton","switch","tab","textbox","treeitem"]);function om(e){return typeof e.tagName=="string"?e.tagName.toUpperCase():""}function nK(e){return om(e)==="BUTTON"?!0:(typeof e.role=="string"?e.role.trim().toLowerCase():"").split(/\s+/).includes("button")}function ti(e){if(!e)return!1;if(e.isContentEditable)return!0;const t=om(e);return t==="TEXTAREA"?!0:t!=="INPUT"?!1:!QG.has(String(e.type??"text").toLowerCase())}function IP(e,t){if(!e)return!1;if(ti(e))return!0;if(t!=null&&(t.length===1||t==="Delete")&&t!==" "&&e.pointerFocused&&nK(e))return!1;if(eK.has(om(e)))return!0;const n=typeof e.role=="string"?e.role.trim().toLowerCase():"";return n!==""&&n.split(/\s+/).some(s=>tK.has(s))}function sK({key:e,modalOpen:t,sheetOpen:n}){return t?!(e==="?"&&n):!1}function rK({key:e,sheetOpen:t,target:n}){return t&&e==="?"&&!ti(n)}function aK({target:e,modalOpen:t}){return t?ti(e)||e!=null&&om(e)==="SELECT":IP(e,"t")}function ml({appModal:e,dialogDepth:t}){return e||t>0}function OP(e){return e?Array.from(e.querySelectorAll("*")).filter(t=>{if(t.matches(rp))return LP({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)&&XG({overflowing:n,overflow:getComputedStyle(t).overflowY,hasFocusable:t.querySelector(rp)!=null}):!1}):[]}function oK(e,t){const n=OP(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 d=g.useRef(null);d.current===null&&(d.current=()=>u.current());const f=d.current;return g.useEffect(()=>ln.push(f,a,i),[f,a,i]),g.useEffect(()=>{var m;const p=document.activeElement;return(m=(n==null?void 0:n.current)??OP(l.current)[0])==null||m.focus(),()=>{if(gT(p,document.activeElement)&&p.focus(),s&&document.activeElement===document.body){const w=s();gT(w,document.activeElement)&&w.focus()}}},[]),g.useEffect(()=>{const p=m=>{var v;if(m.key!=="Tab"||am(m))return;const w=l.current;if(!w)return;const x=document.activeElement;if(!(x!=null&&w.contains(x))&&!ln.isTop(f))return;const j=oK(w,x),k=ZG({count:j.length,index:x?j.indexOf(x):-1,shiftKey:m.shiftKey});k.kind!=="allow"&&(m.preventDefault(),k.kind==="focus"&&((v=j[k.index])==null||v.focus()))};return window.addEventListener("keydown",p),()=>window.removeEventListener("keydown",p)},[f]),l}function wt(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 iK(e){return e==="codex"?{subtitle:"reported by the Codex CLI — as of its most recent request",windowScope:"last request",compositionCounted:!1,compositionUncounted:"Not counted for Codex — the deck reconstructs the session from its rollout file and skips whatever was written before it attached, so a message and tool-call breakdown here would be short by an unknown amount. The window figure above is the CLI's own and is unaffected.",memoryHeading:"AGENTS.md files in scope",memoryEmpty:"No AGENTS.md files found on the path from cwd to the filesystem root, or in $CODEX_HOME."}:{subtitle:"approximation — CC's /context isn't hook-exposed",windowScope:"current turn",compositionCounted:!0,compositionUncounted:"",memoryHeading:"CLAUDE.md files in scope",memoryEmpty:"No CLAUDE.md files found on the path from cwd to ~/.claude."}}function hs(e){return e.toLocaleString()}const lK=60;function cK(e,t=lK){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 uK({agent:e,onClose:t}){var w;const n=g.useRef(null),s=gt(t,{focusRef:n}),a=wt(t),o=e.context,i=e.usage,l=(o==null?void 0:o.currentContextTokens)??0,u=$P(e.contextWindow,e.model),d=Math.min(100,l/u*100),f=Wn(e),p=e.provider==="codex"?i.inputTokens+i.outputTokens:i.inputTokens+i.outputTokens+i.cacheReadTokens+i.cacheCreateTokens,m=iK(e.provider);return r.jsx("div",{className:"modal-backdrop",...a,role:"presentation",children:r.jsxs("div",{ref:s,className:"modal ctx-modal",onClick:x=>x.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(d),children:r.jsx("div",{className:"ctx-window-fill",style:{transform:`scaleX(${Math.min(100,Math.max(0,d))/100})`}})}),r.jsxs("div",{className:"ctx-window-meta",children:[r.jsxs("span",{className:"ctx-window-pct",children:[d.toFixed(1),"%"]}),r.jsxs("span",{children:[hs(l)," / ",hs(u)," tok (",m.windowScope,")"]})]})]}),r.jsx("h3",{className:"ctx-section-title",children:"Cumulative usage · whole session"}),r.jsxs("div",{className:"ctx-grid",children:[r.jsx(Ws,{label:"input tokens",val:hs(i.inputTokens)}),r.jsx(Ws,{label:"output tokens",val:hs(i.outputTokens)}),r.jsx(Ws,{label:"cache reads",val:hs(i.cacheReadTokens)}),r.jsx(Ws,{label:"cache writes",val:hs(i.cacheCreateTokens)}),r.jsx(Ws,{label:"cumulative total",val:hs(p)}),r.jsx(Ws,{label:"estimated cost",val:lt(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(Ws,{label:"user messages",val:hs((o==null?void 0:o.msgsUser)??0)}),r.jsx(Ws,{label:"assistant messages",val:hs((o==null?void 0:o.msgsAssistant)??0)}),r.jsx(Ws,{label:"tool uses",val:hs((o==null?void 0:o.toolUses)??0)}),r.jsx(Ws,{label:"tool results",val:hs((o==null?void 0:o.toolResults)??0)}),r.jsx(Ws,{label:"system-reminders",val:hs((o==null?void 0:o.systemReminders)??0)})]}):r.jsx("div",{className:"ctx-empty",children:m.compositionUncounted}),r.jsx("h3",{className:"ctx-section-title",children:m.memoryHeading}),(((w=o==null?void 0:o.memoryFiles)==null?void 0:w.length)??0)===0?r.jsx("div",{className:"ctx-empty",children:m.memoryEmpty}):r.jsx("ul",{className:"ctx-md-list",children:o.memoryFiles.map(x=>r.jsxs("li",{children:[r.jsx("span",{className:"ctx-md-path",title:x.path,children:cK(x.path)}),r.jsx("span",{className:"ctx-md-size",children:Jn(x.bytes)})]},x.path))})]})})}function Ws({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 dK({currentContextTokens:e,modelId:t,contextWindow:n,size:s=26,onClick:a}){const o=$P(n,t),i=Math.min(1,e/o),l=s/2-3,u=s/2,d=2*Math.PI*l,f=d*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} ${d-f}`,strokeDashoffset:d/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 yT=new Map;function PP(e){let t=yT.get(e);return t||(t={now:Date.now(),listeners:new Set,timer:null},yT.set(e,t)),t}function hK(e,t){const n=PP(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 fK(e){return PP(e).now}const wT=new Map,xT=new Map;function Sr(e=1e3){let t=wT.get(e);t||(t=s=>hK(e,s),wT.set(e,t));let n=xT.get(e);return n||(n=()=>fK(e),xT.set(e,n)),g.useSyncExternalStore(t,n,n)}function pK(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 mK="1",vT="agent-dag.schema",gK=["agent-dag.layout","agent-dag.viewport"];function nt(e){if(typeof window>"u")return null;try{return window.localStorage.getItem(e)}catch{return null}}function st(e,t){if(!(typeof window>"u"))try{window.localStorage.setItem(e,t)}catch{}}function vs(e){if(!(typeof window>"u"))try{window.localStorage.removeItem(e)}catch{}}function gr(){if(typeof window>"u")return null;try{return window.localStorage}catch{return null}}function yK(e,t=mK){let n=null;try{n=e.getItem(vT)}catch{return[]}if(n===t)return[];const s=[];if(n!==null)for(const a of gK)try{e.getItem(a)!==null&&(e.removeItem(a),s.push(a))}catch{}try{e.setItem(vT,t)}catch{}return s}const DP="agent-dag.recapsDismissed",bT=200;function wK(){const e=nt(DP);if(!e)return[];try{const t=JSON.parse(e);return Array.isArray(t)?t.filter(n=>typeof n=="string"):[]}catch{return[]}}let Vl=new Set(wK());const A1=new Set;let FP=0;function BP(e){return A1.add(e),()=>{A1.delete(e)}}function qP(e){Vl=e,FP++;const t=Array.from(e);st(DP,JSON.stringify(t.length>bT?t.slice(-bT):t));for(const n of A1)n()}function xK(e,t){return`${e}@${t}`}function vK(e){return Vl.has(e)}function bK(e){if(Vl.has(e))return;const t=new Set(Vl);t.add(e),qP(t)}function kK(e){const t=new Set(Vl);t.delete(e)||t.add(e),qP(t)}function jK(e){return g.useSyncExternalStore(BP,()=>e!=null&&Vl.has(e),()=>!1)}function bN(e){return`recap:${e}`}function NK(e){return e.startsWith("recap:")}function SK(){return g.useSyncExternalStore(BP,()=>FP,()=>0)}function sc(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 CK(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 _K(e){let t=null;for(const n of e.prompts)(!t||n.at>t.at)&&(t=n);return t}const kT=160;function EK(e){const t=Yp(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>kT?s.slice(0,kT-1).trimEnd()+"…":s}function TK(e){const t=e.stopFailure;if(t)return{kind:"stopped",text:PG(t,e.job!=null),at:t.at,source:"stop",stop:t,key:`${e.sessionId}@stopped:${t.at}`};const n=_K(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?CK(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=EK(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 kN(e){if(e.kind!=="root"||e.closedAt!=null)return null;const t=TK(e);if((t==null?void 0:t.kind)==="stopped")return t;const n=pK(e),s=n?{kind:"recap",text:n.text,at:n.at,source:"recap",key:xK(e.sessionId,n.at)}:null;return t&&s?s.at>t.at?s:t:t??s}function UP(e){const t=kN(e);if(e.kind!=="root"||e.closedAt!=null)return null;const n=Nr(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 im(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 DG(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 AK(e){const t=new Map,n=[...e],s=Zp(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 WP(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 HP(e){return e.live>0?`→ ${e.total} · ${e.live} live`:`→ ${e.total} · done`}function RK(e,t,n){const s=e.kind==="root"?e.waiting:null;if(s&&Tn(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:TP(a),short:AP(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=Nr(e.plan);if(i&&i.current&&!i.allDone)return{tone:"muted",long:pN(i),short:`${i.done}/${i.total} done`}}if(t&&t.total>0)return{tone:"muted",long:WP(t),short:HP(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:d}=n.describeCall(l);return{tone:"muted",long:d?`${u} · ${d}`:u,short:u}}return null}function MK(e,t){return t?t.includes(e)?t:`${e}
|
|
80
|
+
${t}`:e}function Al(e){return e.kind==="root"&&e.stopFailure&&e.state==="done"?"err":e.state}function R1(e){return e==="active"?"live":e==="done"?"done":"err"}const lm={exec:{category:"shell",emoji:"⚡",label:"Shell",shell:!0},shell:{category:"shell",emoji:"⚡",label:"Shell",shell:!0},exec_command:{category:"shell",emoji:"⚡",label:"Shell",shell:!0},shell_command:{category:"shell",emoji:"⚡",label:"Shell",shell:!0},write_stdin:{category:"shell",emoji:"💻",label:"stdin",shell:!0},wait:{category:"shell",emoji:"⏳",label:"wait",shell:!0},apply_patch:{category:"file",emoji:"🩹",label:"Edit"},update_plan:{category:"task",emoji:"📋",label:"Plan"},run:{category:"web",emoji:"🌐",label:"Web"}},$K=Object.fromEntries(Object.entries(lm).map(([e,t])=>[e,t.category])),LK=Object.fromEntries(Object.entries(lm).map(([e,t])=>[e,t.emoji])),IK=Object.fromEntries(Object.entries(lm).map(([e,t])=>[e,t.label])),OK=new Set(Object.entries(lm).filter(([,e])=>e.shell).map(([e])=>e)),PK={Read:"file",Write:"file",Edit:"file",MultiEdit:"file",Glob:"file",Grep:"file",LS:"file",NotebookEdit:"file",Bash:"shell",PowerShell:"shell",WebFetch:"web",WebSearch:"web",Task:"agent",Agent:"agent",TodoWrite:"task",TaskCreate:"task",TaskUpdate:"task",TaskList:"task",TaskGet:"task",TaskOutput:"task",TaskStop:"task",EnterPlanMode:"plan",ExitPlanMode:"plan",AskUserQuestion:"plan",Skill:"plan",Workflow:"plan",...$K};function zP(e){return e.startsWith("mcp__")?"mcp":Kt(PK,e)??"other"}const DK=/\btools\.exec_command\s*\(\s*\{[^{}]*?\bcmd\s*:\s*(["'`])((?:\\.|(?!\1)[^\\])*)\1/,FK=/\btools\.([A-Za-z_$][\w$]*)\s*\(/;function BK(e){if(typeof e!="string"||!e)return null;const t=DK.exec(e);if(t){const s=qK(t[2]);if(s.trim())return s}const n=FK.exec(e);return n?n[1]:null}function qK(e){return e.replace(/\\(["'`\\nrt])/g,(t,n)=>n==="n"?`
|
|
81
|
+
`:n==="r"?"\r":n==="t"?" ":n)}const UK={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:"📡",...LK};function jT(e){return e.startsWith("mcp__")?"🔌":Kt(UK,e)??"✨"}const WK={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 VP(e){return/^-(?:Command|c)$/i.test(e)||/^-[a-z]+c$/.test(e)}function GP(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=>VP(o)||/^-(?:NoProfile|NonInteractive)$/i.test(o)))return GP(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 HK(e){if(typeof e=="string")return e;if(!e||typeof e!="object")return null;const t=e;if(typeof t.script=="string"){const n=BK(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(VP);if(s>=0&&s+1<n.length)return n[s+1]}return n.join(" ")}return typeof t.script=="string"?t.script:null}const zK=new Set(["Bash","PowerShell",...OK]);function VK(e,t){if(!zK.has(e))return null;const n=HK(t);if(!n)return null;const s=GP(n);return s?{emoji:Kt(WK,s)??"⚙️",label:s,category:"shell",detail:n}:null}const GK=new Set(["Read","Write","Edit","MultiEdit","NotebookEdit","LS","Glob","apply_patch"]),KK={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:"🗄️"},YK={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 XK(e){const n=e.replace(/\\/g,"/").replace(/\/+$/,""),s=n.lastIndexOf("/");return s>=0?n.slice(s+1):n}function ZK(e){const t=e.toLowerCase(),n=Kt(YK,t);if(n!==void 0)return n;if(t.startsWith("dockerfile."))return"🐳";if(/\.(test|spec)\.[a-z]+$/.test(t))return"🧪";const s=t.lastIndexOf(".");if(s>0&&s<t.length-1){const a=Kt(KK,t.slice(s+1));if(a!==void 0)return a}return"📄"}function JK(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 QK(e,t){if(!GK.has(e))return null;const n=JK(e,t);if(!n)return null;const s=XK(n);return s?{emoji:e==="LS"?"📂":ZK(s),label:s,category:"file",detail:n}:null}const eY={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 jN(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 tY(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 KP(e){return Kt(eY,e.toLowerCase())}function nY(e,t){const n=jN(e);if(!n)return null;const{server:s,method:a}=n;if(!a)return null;const o=KP(s);return{emoji:(o==null?void 0:o.emoji)??"🔌",label:a,category:"mcp",detail:o?`${o.name} · ${a}`:`${s} · ${a}`}}function YP(e,t){return VK(e,t)??QK(e,t)??nY(e)}function sY(e,t){var n;return((n=YP(e,t))==null?void 0:n.label)??null}const rY=IK,NT=18;function af(e){const t=[...e];return t.length<=NT?e:t.slice(0,NT-1).join("")+"…"}const Jy=13,aY=6;function oY(e,t){const n=[...e];if(n.length<=Jy)return e;const s=n.lastIndexOf("."),a=s>0?n.slice(s):[];return t==="file"&&a.length>1&&a.length<=aY?n.slice(0,Jy-1-a.length).join("")+"…"+a.join(""):n.slice(0,Jy-1).join("")+"…"}function NN(e){const t=jN(e);if(t){const s=KP(t.server);return s?{emoji:s.emoji,label:af(s.name)}:{emoji:"🔌",label:af(t.server),hue:tY(t.server)}}const n=Kt(rY,e)??"";return n?{emoji:jT(e),label:af(n)}:{emoji:jT(e),label:af(e)}}function iY(e){let t=null,n="";for(const s of e){const a=jN(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:NN(n)}const M1=6e4,Rl=24,ST=M1/Rl,Qy=132,If=14;function lY(e,t,n){const s=new Array(Rl).fill(0);let a=0;const o=m=>{const w=n-m;if(w<0||w>=M1)return;const x=Rl-1-Math.floor(w/ST);x>=0&&x<Rl&&(s[x]+=1,a+=1)};for(const m of e)o(m.startedAt);for(const m of t??[])o(m);const l=Math.max(0,...s)/(ST/1e3),u=e.filter(m=>n-m.startedAt>=0&&n-m.startedAt<M1).length,d=a-u,f=[u>0?`${u} tool ${u===1?"call":"calls"}`:"",d>0?`${d} ${d===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 cY=2;function uY(e){return e===0?1.5:Math.max(1.5,Math.min(1,e/cY)*If)}function XP({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 SN(){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 ZP(){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 ap({recap:e}){return e?r.jsx(ZP,{}):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 io(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 eo(e,t){return{disabled:e!=null&&e!==t,busy:e===t}}function cm(e){return e==null}const $1="self";function qn(e,t=!1){const n=eo(e?$1:null,$1);return{disabled:t||n.disabled,"aria-busy":n.busy}}function _n(e){return cm(e?$1:null)}const hi=400;function fi({armedFor:e,target:t,armedAt:n,now:s,gapMs:a}){return e!==t?"arm":s-n<a?"ignore":"fire"}function JP(e){return[...e==null?[]:[`#ap-more-${e}`],".accounts-panel .ap-refresh"]}function Hn(e){return e==null||e==="BODY"||e==="HTML"}const QP="Continue from where you left off.";function dY(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 eD(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 op(e){return eD(Math.floor(e/1e3))}function kd(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 hY(e,t){return e.getFullYear()===t.getFullYear()&&e.getMonth()===t.getMonth()&&e.getDate()===t.getDate()}function ip(e,t,n){const s=new Date(e),a=op(t-e);return{label:hY(s,new Date(t))?a:`${a} · ${s.toLocaleDateString(n,{month:"short",day:"numeric"})}`,title:s.toLocaleString(n,{dateStyle:"medium",timeStyle:"medium"})}}function CN(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 fY(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 _N(e,t){const n=op(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 lp(e){if(!e.ok)return fY(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: “${QP}”${n}`}function tD({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 pY(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 mY(e,t){return[`claude stop ${e}`,`claude --resume ${t} --bg "${QP}"`].join(`
|
|
83
|
+
`)}let Ja={answer:null,pressing:new Set,pressed:{}};const ew={current:new Set},L1=new Set;function I1(e){Ja={...Ja,...e};for(const t of L1)t()}const gY=e=>(L1.add(e),()=>{L1.delete(e)}),CT=()=>Ja;function EN(){return g.useSyncExternalStore(gY,CT,CT)}const yY=new Set(["login","usage-limit","api-error"]),TN=e=>typeof e=="number"&&Number.isFinite(e)?e:null,nD=e=>typeof e=="string"?e:"";function wY(e){if(!e||typeof e!="object")return null;const t=e,n=TN(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:nD(t.detail),stopped:t.stopped===!0}}function xY(e){if(!e||typeof e!="object")return null;const t=e;return{ok:t.ok===!0,at:TN(t.at)??0,room:typeof t.room=="boolean"?t.room:null}}function vY(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,d=u&&yY.has(u.kind)&&TN(u.at)!=null?{kind:u.kind,at:u.at}:null;s[o]={stop:d,held:l.held===!0,tried:l.tried===!0,last:wY(l.last)}}return{auto:n.auto===!0,login:t?xY(n.login):null,withLogin:t,sessions:s}}async function Of(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=vY(await s.json(),e);if(!a)return;const o=e?a.login:((t=Ja.answer)==null?void 0:t.login)??null;I1({answer:{...a,login:o,withLogin:e||(((n=Ja.answer)==null?void 0:n.withLogin)??!1)}})}catch{}}async function bY(e,t){if(!_n(ew.current.has(e)))return null;ew.current.add(e),I1({pressing:new Set([...Ja.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"?CN((o==null?void 0:o.gate)??null):nD(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}}ew.current.delete(e);const s=new Set(Ja.pressing);return s.delete(e),I1({pressing:s,pressed:{...Ja.pressed,[e]:n}}),Of(!0),n}const sD=30*6e4;function AN(e,t){var l,u,d,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:((d=t.answer)==null?void 0:d.withLogin)===!0,gate:dY(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 kY=15e3,jY=2*6e4;function NY(e){for(const t of e.agents.values())if(t.kind==="root"&&t.stopFailure)return!0;return!1}function SY({stateRef:e,now:t,enabled:n}){const s=g.useRef(0);n&&NY(e.current)&&(s.current=t);const a=n&&s.current>0&&t-s.current<jY;g.useEffect(()=>{n&&Of(!1)},[n]),g.useEffect(()=>{if(!a)return;Of(!0);const o=window.setInterval(()=>{Of(!0)},kY);return()=>window.clearInterval(o)},[a])}function rD(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.":CN(e.gate.reason):"Checking for a working login…",e.stop?tD({auto:e.auto,kind:e.stop.kind,held:e.held,tried:e.tried}):"",e.last&&e.stop&&e.last.at>=e.stop.at?`${_N(e.last,t)}. ${lp(e.last)}`:""].filter(Boolean).join(`
|
|
84
|
+
`)}function aD(e,t){return g.useCallback(()=>{!(e!=null&&e.stop)||!e.gate.ready||e.pressing||bY(t,e.stop)},[e,t])}function CY({data:e}){const t=EN(),n=Sr(15e3),s=AN(e,t),a=aD(s,e.sessionId);return!(s!=null&&s.stop)||!s.background?null:r.jsx("button",{type:"button",className:"stop-continue",...qn(s.pressing,!(s.loaded&&s.gate.ready)),title:rD(s,n),onClick:o=>{o.stopPropagation(),a()},children:s.pressing?"Continuing…":"Continue"})}function _Y({data:e}){const t=EN(),n=Sr(15e3),s=AN(e,t);return!s||s.stop||!s.last||n-s.last.at>sD?null:r.jsxs("div",{className:`continued-row${s.last.ok?"":" failed"}`,title:lp(s.last),children:[r.jsx("span",{className:"waiting-dot","aria-hidden":!0}),r.jsx("span",{className:"continued-said",children:_N(s.last,n)})]})}function EY({agent:e}){const t=EN(),n=Sr(15e3),s=AN(e,t),a=aD(s,e.sessionId),[o,i]=g.useState(null),l=g.useCallback(async(m,w)=>{await io(w)&&(i(m),window.setTimeout(()=>i(x=>x===m?null:x),1600))},[]);if(!s)return null;const u=s.last&&(!s.stop||s.last.at>=s.stop.at)&&n-s.last.at<=sD?r.jsxs("p",{className:`detail-continue-last${s.last.ok?"":" failed"}`,title:lp(s.last),children:[_N(s.last,n),". ",lp(s.last)]}):null;if(!s.stop)return u?r.jsxs("section",{className:"detail-section",children:[r.jsx("h3",{children:"Continue"}),u]}):null;const d=s.loaded?s.gate.ready?s.stop.kind==="api-error"?"":"A working login with room is active now.":CN(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:pY(s.stop.kind)}),d&&r.jsx("p",{className:"detail-continue-state",children:d}),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=tD({auto:s.auto,kind:s.stop.kind,held:s.held,tried:s.tried}),p=s.jobId?mY(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."}),d&&r.jsx("p",{className:"detail-continue-state",children:d}),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",...qn(s.pressing,!(s.loaded&&s.gate.ready)),title:rD(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 _T=typeof window>"u"?g.useEffect:g.useLayoutEffect;function TY({data:e}){var F,M;const t=Al(e),n=["agent-node",`state-${t}`,e.synthetic?"synthetic":""].filter(Boolean).join(" "),s=e.tools.filter(B=>!B.endedAt).length,a=e.toolErrorCount??0,o=Ju(e.canvasSessionId??e.sessionId),i=((F=e.context)==null?void 0:F.currentContextTokens)??0,l=e.kind==="root"&&i>0,u=e.sessionTitle?e.cwd?`${e.cwd}
|
|
85
|
+
${e.sessionTitle}`:e.sessionTitle:e.cwd,d=wN(e),f=g.useRef(null),p=g.useRef(null),m=jG(e),[w,x]=g.useState(0),[b,j]=g.useState(null);_T(()=>{x(0)},[e.effort,e.model,d.length,e.cwdBasename,e.childCount,e.kind,m,b]),_T(()=>{const B=f.current;if(!B||w>=m)return;const T=p.current,P=NG(w,{overflowing:B.scrollWidth>B.clientWidth,folderCut:!!T&&T.scrollWidth>T.clientWidth,max:m});P!==w&&x(P)}),g.useEffect(()=>{const B=f.current;if(!B||typeof ResizeObserver>"u")return;let T=B.clientWidth;const P=new ResizeObserver(()=>{B.clientWidth!==T&&(T=B.clientWidth,vt.flushSync(()=>j(T)))});return P.observe(B),()=>P.disconnect()},[]);const k=SG(w),v=e.model&&(d.length>0?`${ed(e.model,e.effort)}
|
|
86
|
+
spend on this card also covers:
|
|
87
|
+
${d.join(`
|
|
88
|
+
`)}`:ed(e.model,e.effort)),S=sm(e.sessionName,e.sessionTitle),C=UP(e),_=(C==null?void 0:C.note)??null,R=C?C.key:null,A=jK(R),I=C!=null&&!A,$=(_==null?void 0:_.kind)==="recap",U=vG(e);return r.jsxs("div",{className:n,style:{"--session-hue":o},children:[r.jsx("span",{className:"accent-stripe"}),r.jsx(ci,{type:"target",position:Ye.Left,style:{background:"transparent",border:"none"}}),r.jsxs("div",{className:"head",children:[r.jsxs("div",{className:"title",children:[r.jsx(LY,{state:t}),r.jsx("span",{className:"label",title:u,children:e.label}),e.restoredFromLog&&r.jsx("span",{className:"synth-tag",title:e.provider==="claude"?"Restored from Claude’s busy-session registry after verifying the process identity. Earlier tool history is partial.":"Restored from a log with no recorded ending. Process status is not confirmed.",children:"restored"}),e.synthetic&&r.jsx("span",{className:"synth-tag",title:"No SessionStart captured — synthesised",children:"?"}),C&&R&&r.jsx("button",{type:"button",className:"glyph-btn recap-pin","aria-label":$?"Claude Code's recap":_?`Session note: ${sc(_.kind)}`:"Session note: plan","aria-expanded":I,title:$?I?"Hide the recap":"Show Claude Code's recap":_?I?"Hide this note":"Show what this session is doing":I?"Hide the plan":"Show the plan",onClick:B=>{B.stopPropagation(),kK(R)},children:r.jsx(ap,{recap:$})})]}),r.jsx("div",{className:"head-right",children:l&&e.onOpenContext&&r.jsx(dK,{currentContextTokens:i,modelId:e.model,contextWindow:e.contextWindow,onClick:()=>e.onOpenContext(e.sessionId)})})]}),r.jsxs("div",{className:"sub",title:qG(e),children:[r.jsxs("span",{className:"sub-details",ref:f,children:[k.kind&&r.jsx("span",{children:nm(e)}),e.childCount>0&&r.jsxs("span",{className:"spawn-badge",title:BG(e.childCount),children:["→ ",e.childCount]}),e.cwdBasename&&e.kind==="subagent"&&r.jsxs("span",{className:"sub-folder",ref:p,children:[k.kind?"· ":"",e.cwdBasename]}),e.model?r.jsxs("span",{className:"model-chip","data-family":Qp(e.model),title:v,children:[em(e.model,k.effort?e.effort:void 0),d.length>0?` +${d.length}`:""]}):e.provider==="codex"?r.jsx("span",{className:"model-chip",title:"OpenAI Codex — no model reported yet",children:"Codex"}):null]}),r.jsxs("span",{className:"time",title:e.synthetic?`The deck joined this session after it began, so it has run at least this long — first seen ${new Date(e.startedAt).toLocaleTimeString()}`:`Started ${new Date(e.startedAt).toLocaleTimeString()}`,children:[e.synthetic?"≥ ":"",r.jsx($Y,{start:e.startedAt,end:e.endedAt})]})]}),e.kind==="root"&&S.face&&r.jsx("div",{className:"session-name",title:S.tooltip,children:S.face}),e.kind==="root"&&e.stopFailure&&r.jsx(IY,{data:e,stop:e.stopFailure}),e.kind==="root"&&!e.stopFailure&&r.jsx(_Y,{data:e}),e.waiting&&!(e.stopFailure&&e.waiting.kind==="idle")&&r.jsx(OY,{waiting:e.waiting}),(()=>{const B=_P(e);return B?r.jsxs("div",{className:"approval-blind-row",title:B.detail,children:[r.jsx("span",{className:"approval-blind-dot","aria-hidden":!0}),r.jsx("span",{className:"approval-blind-said",children:B.label})]}):null})(),(()=>{const B=Nr(e.plan);return B&&e.plan?r.jsx(RY,{plan:B,items:e.plan.items}):null})(),(e.tools.length>0||(((M=e.outputs)==null?void 0:M.length)??0)>0)&&r.jsx(PY,{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:St(e.usage.inputTokens+e.usage.outputTokens)})," tok"]}),(U==null?void 0:U.kind)==="unpriced"&&r.jsx("span",{className:"cost-unpriced",title:U.tt,children:ua}),(U==null?void 0:U.kind)==="spent"&&r.jsx("span",{className:"cost-meta",title:U.tt,children:r.jsxs("b",{children:[lt(U.total),U.floor?"+":""]})})]}),r.jsx(MY,{data:e,title:e.kind==="root"?S.face:void 0}),r.jsx(ci,{type:"source",position:Ye.Right,style:{background:"transparent",border:"none"}})]})}const AY=g.memo(TY);function RY({plan:e,items:t}){return r.jsxs("div",{className:e.allDone?"plan-row plan-done":"plan-row",title:Xp(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 MY({data:e,title:t}){const n=e.kind==="root"&&Tn(e.waiting),s=RK(e,e.branch,{sayWaiting:sp,describeCall:a=>({name:NN(a.name).label,subject:sY(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(XP,{kind:R1(Al(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(SN,{})]}),t&&r.jsx("div",{className:"lod-title",children:t}),s&&r.jsxs("div",{className:"lod-signal","data-tone":s.tone,children:[r.jsx("span",{className:"lod-long",children:s.long}),r.jsx("span",{className:"lod-short",children:s.short})]})]})}function $Y({start:e,end:t}){const n=Sr(1e3);return r.jsx(r.Fragment,{children:zl(e,t,n)})}function LY({state:e}){return r.jsx("span",{className:`state-pill state-${e}`,children:Wl(e)})}function IY({data:e,stop:t}){return r.jsxs("div",{className:"stop-row",title:OG(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:TP(t)}),r.jsx(CY,{data:e})]})}function OY({waiting:e}){const t=Sr(1e3),n=Tn(e),s=Hl(e);return r.jsxs("div",{className:n?"waiting-row permission":"waiting-row idle",title:`${s}
|
|
89
|
+
Blocked for ${zl(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:sp(e)}),r.jsx("b",{children:zl(e.since,void 0,t)})]})}function PY({tools:e,outputs:t}){const n=Sr(1e3),{counts:s,title:a}=lY(e,t,n),o=Qy/Rl;return r.jsxs("div",{className:"tool-spark-row",title:a,children:[r.jsx("svg",{className:"tool-spark",width:Qy,height:If,viewBox:`0 0 ${Qy} ${If}`,"aria-hidden":!0,children:s.map((i,l)=>{const u=uY(i),d=l===Rl-1&&i>0,p=`tool-spark-bar${i>0?" active":""}${d?" latest":""}`;return r.jsx("rect",{x:l*o+.4,y:If-u,width:Math.max(.5,o-1),height:u,rx:.8,className:p},d?`landed:${i}`:l)})}),r.jsx("span",{className:"tool-spark-label",children:"60s"})]})}function DY({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 RN="agent-dag.single-key-shortcuts";function oD(e){return e!=="0"}function iD(e){return e.length===1}function FY(e,t){return!t&&iD(e)}function En(e,t,n){return n?`${e} (${t})`:e}let ni=null;const ku=new Set;function lD(){for(const e of ku)e()}function O1(){return ni===null&&(ni=oD(nt(RN))),ni}function BY(e){ni!==e&&(ni=e,st(RN,e?"1":"0"),lD())}function ET(e){if(e.key!==RN)return;const t=oD(e.newValue);t!==ni&&(ni=t,lD())}function qY(e){var t;return ku.add(e),ku.size===1&&typeof window<"u"&&((t=window.addEventListener)==null||t.call(window,"storage",ET)),()=>{var n;ku.delete(e),ku.size===0&&typeof window<"u"&&((n=window.removeEventListener)==null||n.call(window,"storage",ET))}}function cp(e){const t=Math.max(0,Math.floor(e));return`${t} event${t===1?"":"s"}`}const TT=99;function UY(e){const t=Math.max(0,Math.floor(e));return t>TT?`${TT}+`:String(t)}const WY="Pause the canvas";function HY(e){const t=e.singleKeys??!0;if(!e.paused)return En("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?En(`The pause is full — ${cp(e.held)} held and ${n} older ${n===1?"one":"ones"} already dropped. Resume to follow the canvas again`,"Space",t):e.held<=0?En("Nothing has arrived since you paused. Resume to follow the canvas again","Space",t):En(`${cp(e.held)} arrived while paused and will be applied in order when you resume`,"Space",t)}function zY(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 cD="paused · full",VY=(e,t)=>t>0?cD:e>0?`paused · ${UY(e)}`:"paused";function GY(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:VY(e.held,t),widest:cD,title:En(t>0?`Connected — the pause is full at ${cp(e.held)}; the oldest are being dropped as new ones arrive. Resume to catch up`:e.held>0?`Connected — ${cp(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(qY,O1,O1)}const KY=e=>e.transform[2]>=e.maxZoom,YY=e=>e.transform[2]<=e.minZoom;function XY({autoFitDisabled:e,enableAutoFitAndRefit:t,paused:n,pauseGate:s,togglePause:a,handleRelayout:o,requestClear:i,setKeyHelpOpen:l}){const u=Ql(),d=ft(KY),f=ft(YY),p=An();return r.jsxs(T9,{showInteractive:!1,showFitView:!1,showZoom:!1,children:[r.jsx(fs,{onClick:()=>{d||u.zoomIn()},title:"Zoom in","aria-label":"Zoom in","aria-disabled":d||void 0,children:r.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:r.jsx("path",{d:"M12 5v14M5 12h14",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})})}),r.jsx(fs,{onClick:()=>{f||u.zoomOut()},title:"Zoom out","aria-label":"Zoom out","aria-disabled":f||void 0,children:r.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:r.jsx("path",{d:"M5 12h14",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})})}),r.jsx(fs,{onClick:t,title:e?"Recenter view + re-enable autofit":"Recenter view (autofit already on)","aria-label":"Recenter view","data-nudge":e?"":void 0,children:r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[r.jsx("circle",{cx:"12",cy:"12",r:"3.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),r.jsx("path",{d:"M12 2v4M12 18v4M2 12h4M18 12h4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})]})}),r.jsx(fs,{"data-group-start":"",onClick:a,title:HY({paused:n,held:s.size,dropped:s.dropped,singleKeys:p}),"aria-label":WY,"aria-pressed":n,children:r.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:r.jsx("path",{d:"M9 5.5v13M15 5.5v13",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})})}),r.jsx(fs,{onClick:o,title:En("Auto-arrange — clear pins","R",p),"aria-label":"Re-arrange the canvas",children:r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[r.jsx("rect",{x:"8.5",y:"2",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),r.jsx("rect",{x:"1.5",y:"17",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),r.jsx("rect",{x:"15.5",y:"17",width:"7",height:"5",rx:"1.5",fill:"none",stroke:"currentColor",strokeWidth:"2"}),r.jsx("path",{d:"M12 7v6.5M5 17v-3.5h14V17",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"})]})}),r.jsx(fs,{"data-group-start":"","data-danger":"",onClick:()=>i("button"),title:En("Clear the canvas and the server's event log — asks first","C",p),"aria-label":"Clear the canvas",children:r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[r.jsx("path",{d:"M4 6.2h16",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"}),r.jsx("path",{d:"M9 6.2V4.4a1.6 1.6 0 0 1 1.6-1.6h2.8a1.6 1.6 0 0 1 1.6 1.6v1.8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),r.jsx("path",{d:"M17.4 6.4 16.7 20a2 2 0 0 1-2 1.9H9.3a2 2 0 0 1-2-1.9L6.6 6.4",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),r.jsx("path",{d:"M10.3 10.6v6.8M13.7 10.6v6.8",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",fill:"none"})]})}),r.jsx(fs,{"data-group-start":"",onClick:()=>l(m=>!m),title:p?En("Keyboard shortcuts","?",!0):"Keyboard shortcuts — the single-key ones are off","aria-label":"Open the keyboard shortcuts","aria-haspopup":"dialog",children:r.jsxs("svg",{width:"14",height:"14",viewBox:"0 0 24 24","aria-hidden":!0,children:[r.jsx("path",{d:"M8.6 8.4a3.5 3.5 0 1 1 4.6 3.35c-.85.3-1.2 1-1.2 1.85v1",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round",fill:"none"}),r.jsx("path",{d:"M12 18.4v.2",stroke:"currentColor",strokeWidth:"2.4",strokeLinecap:"round",fill:"none"})]})})]})}const ZY="modulepreload",JY=function(e){return"/"+e},AT={},gi=function(t,n,s){let a=Promise.resolve();if(n&&n.length>0){let i=function(d){return Promise.all(d.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(d=>{if(d=JY(d),d in AT)return;AT[d]=!0;const f=d.endsWith(".css"),p=f?'[rel="stylesheet"]':"";if(document.querySelector(`link[href="${d}"]${p}`))return;const m=document.createElement("link");if(m.rel=f?"stylesheet":ZY,f||(m.as="script"),m.crossOrigin="",m.href=d,u&&m.setAttribute("nonce",u),document.head.appendChild(m),f)return new Promise((w,x)=>{m.addEventListener("load",w),m.addEventListener("error",()=>x(new Error(`Unable to preload CSS for ${d}`)))})}))}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)})},RT="agent-dag.fm-custom-stations",MT="agent-dag.fm-muted",P1="custom:",QY=/^UC[A-Za-z0-9_-]{22}$/,eX=/^[A-Za-z0-9_-]{11}$/,uD=/^[A-Za-z0-9_-]{1,80}$/,tX=/\.(mp3|aac|ogg)$/i,nX=/\.m3u8$/i,sX=2048,dD=80;function Gl(e){return`${P1}${e}`}function um(e){if(!e.startsWith(P1))return null;const t=e.slice(P1.length);return uD.test(t)?t:null}function $T(e){return um(e)??e}function MN(e){var i,l;const t=e.trim();if(t.length>sX)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&&QY.test(u))return{kind:"youtube-channel",url:s,channel:u};const d=(l=/^\/@([^/]+)\/live\/?$/.exec(n.pathname))==null?void 0:l[1];if(d&&/^[A-Za-z0-9._-]{1,64}$/.test(d))return{kind:"youtube-handle",url:s,handle:d};if(n.pathname==="/watch"){const f=n.searchParams.get("v")??"";if(eX.test(f))return{kind:"youtube-video",url:s,video:f}}return null}return nX.test(n.pathname)?{kind:"direct-audio",url:s,format:"hls"}:tX.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 rX(e){return e==="1"}function aX(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=MN(l);if(!uD.test(o)||n.has(o)||!i||i.length>dD||!u)continue;n.add(o);const d=hD(a.radio);s.push({id:o,name:i,url:u.url,...d?{radio:d}:{}})}return s}function oX(e,t,n){const s=um(e??"");return s&&t.some(a=>a.id===s)?Gl(s):n(e)}function iX(e,t){return e===Gl(t)?"claude-fm":e}function hD(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 D1="https://www.youtube-nocookie.com";function lX(e,t,n){const s=new URLSearchParams({...n?{}:{channel:e},enablejsapi:"1",autoplay:"1",playsinline:"1",rel:"0",modestbranding:"1",origin:t});return`${D1}/embed/${n?encodeURIComponent(n):"live_stream"}?${s.toString()}`}function ol(e,t=[]){return JSON.stringify({event:"command",func:e,args:t})}function cX(e="claude-fm"){return JSON.stringify({event:"listening",id:e,channel:"widget"})}const uX=[1],dX=[0,2],hX=[2,5,100,101,150,153];function fX(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:uX.includes(a)?{kind:"playing",playing:!0}:a===3?{kind:"buffering"}:dX.includes(a)?{kind:"playing",playing:!1}:null}return null}const iu=new Set;let LT="";function IT(e){const t=new Date().toISOString().slice(0,10);if(t!==LT&&(iu.clear(),LT=t),!iu.has(e)){iu.add(e);try{const n=typeof navigator>"u"?void 0:navigator;(!n||typeof n.sendBeacon!="function"||!n.sendBeacon("/api/feature",JSON.stringify({name:e})))&&iu.delete(e)}catch{iu.delete(e)}}}const OT=864e5,pX=6e4;function cn(e,t=!0){g.useEffect(()=>{if(!t)return;IT(e);let n;const s=()=>{n=setTimeout(()=>{IT(e),s()},OT-Date.now()%OT+pX)};return s(),()=>clearTimeout(n)},[e,t])}const mX={"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 gX({fetchImpl:e,enabled:t=!0,volume:n,muted:s,source:a,playRequest:o,customStation:i,onAvailabilityChange:l}){var B;const[u,d]=g.useState(null),[f,p]=g.useState(!1),[m,w]=g.useState(!1),[x,b]=g.useState(!1),[j,k]=g.useState(!1);cn("claude-fm",x);const v=g.useRef(o),S=g.useRef(null),C=g.useRef(null),_=g.useRef(void 0),R=g.useRef(null),A=g.useCallback(()=>{var P;clearTimeout(_.current),(P=C.current)==null||P.destroy(),C.current=null;const T=S.current;T&&(T.pause(),T.removeAttribute("src"),T.load(),S.current=null)},[]),I=g.useCallback(T=>{var P,q;(q=(P=R.current)==null?void 0:P.contentWindow)==null||q.postMessage(T,D1)},[]),$=g.useRef(n);$.current=n;const U=g.useRef(s);U.current=s;const F=g.useCallback((T,P,q)=>{A();const K=new Audio;K.preload="none",K.volume=$.current/100,K.muted=U.current,S.current=K,w(!0),b(!1),k(!1);let z=!1;const H=()=>S.current===K,D=()=>{clearTimeout(_.current),A(),w(!1),b(!1),k(!1)},O=()=>{H()&&(D(),p(!0),l==null||l(q,!0))},V=W=>{if(H()&&!(W instanceof DOMException&&W.name==="AbortError")){if(W instanceof DOMException&&W.name==="NotAllowedError"){D();return}O()}};_.current=setTimeout(()=>{H()&&!z&&O()},15e3),K.addEventListener("playing",()=>{H()&&(clearTimeout(_.current),z=!0,b(!0),k(!1),l==null||l(q,!1))});const Z=()=>{H()&&(b(!1),k(z),clearTimeout(_.current),_.current=setTimeout(()=>{H()&&O()},15e3))};K.addEventListener("waiting",Z),K.addEventListener("stalled",Z),K.addEventListener("ended",()=>{H()&&D()}),K.addEventListener("error",O,{once:!0}),P&&!K.canPlayType("application/vnd.apple.mpegurl")?gi(async()=>{const{default:W}=await import("./hls-BFpXDghs.js");return{default:W}},[]).then(({default:W})=>{if(!H())return;if(!W.isSupported()){O();return}const X=new W;C.current=X,X.on(W.Events.ERROR,(Y,J)=>{J.fatal&&O()}),X.on(W.Events.MEDIA_ATTACHED,()=>X.loadSource(T)),X.on(W.Events.MANIFEST_PARSED,()=>{K.play().catch(V)}),X.attachMedia(K)},O):(K.src=T,K.play().catch(V))},[l,A]);g.useEffect(()=>{m&&(I(ol("setVolume",[n])),I(ol(s?"mute":"unMute")),S.current&&(S.current.volume=n/100,S.current.muted=s))},[n,s,m,I]),g.useEffect(()=>{var D;let T=!0;const P=e??fetch,q=v.current!==o;if(v.current=o,d(null),p(!1),k(!1),w(q),b(!1),A(),!t){w(!1),b(!1);return}const K=i&&Gl(i.id)===a?MN(i.url):null;if(K){if(K.kind==="direct-audio"){const O=K.format==="hls"||((D=i==null?void 0:i.radio)==null?void 0:D.hls)===!0;return d({live:!0,channel:"",audio:K.url,hls:O}),l==null||l(a,!1),q&&F(K.url,O,a),()=>{T=!1}}return P(`/api/fm-station?url=${encodeURIComponent(K.url)}`).then(O=>O.ok?O.json():null).then(O=>{T&&(O!=null&&O.channel||O!=null&&O.video?(d({live:!0,channel:O.channel??"",video:O.video??void 0}),l==null||l(a,!1)):(p(!0),w(!1),b(!1),k(!1),l==null||l(a,!0)))}).catch(()=>{T&&(p(!0),w(!1),b(!1),k(!1),l==null||l(a,!0))}),()=>{T=!1}}if(um(a))return p(!0),l==null||l(a,!0),()=>{T=!1};const z=a,H=mX[z];if(H)P(H).then(O=>O.ok?O.json():null).then(O=>{T&&(O!=null&&O.video&&d({live:!0,channel:"",video:O.video}),O!=null&&O.video||(p(!0),w(!1),b(!1)),l==null||l(a,!(O!=null&&O.video)))}).catch(()=>{T&&(p(!0),w(!1),b(!1),l==null||l(a,!0))});else if(z!=="claude-fm"){const O=z.replace("lofi-","");P(`/api/lofi-girl?station=${encodeURIComponent(O)}`).then(V=>V.ok?V.json():null).then(V=>{T&&(V!=null&&V.video&&d({live:!0,channel:"",video:V.video}),V!=null&&V.video||(p(!0),w(!1),b(!1)),l==null||l(a,!(V!=null&&V.video)))}).catch(()=>{T&&(p(!0),w(!1),b(!1),l==null||l(a,!0))})}else P("/api/claude-fm").then(O=>O.ok?O.json():null).then(O=>{if(!T)return;const V=!!(O!=null&&O.live&&(O!=null&&O.channel));V&&d({live:!0,channel:O.channel}),V||(p(!0),w(!1),b(!1)),l==null||l(a,!V)}).catch(()=>{T&&(p(!0),w(!1),b(!1),l==null||l(a,!0))});return()=>{T=!1}},[i==null?void 0:i.id,i==null?void 0:i.url,(B=i==null?void 0:i.radio)==null?void 0:B.hls,t,e,l,o,a,F,A]),g.useEffect(()=>()=>A(),[A]),g.useEffect(()=>{if(!m||u!=null&&u.audio)return;let T;const P=()=>{clearTimeout(T),T=void 0,w(!1),b(!1),k(!1),p(!0),l==null||l(a,!0)},q=()=>{T??(T=setTimeout(P,15e3))};q();const K=z=>{var D;if(z.origin!==D1||z.source!==((D=R.current)==null?void 0:D.contentWindow))return;const H=fX(z.data);if(H){if(H.kind==="ready"){I(ol("setVolume",[$.current])),I(ol(U.current?"mute":"unMute")),I(ol("playVideo"));return}if(H.kind==="blocked"){clearTimeout(T),T=void 0,w(!1),b(!1),k(!1);return}if(H.kind==="buffering"){b(!1),k(!0),q();return}if(H.kind==="playing"){clearTimeout(T),T=void 0,b(H.playing),k(!1),H.playing||w(!1);return}hX.includes(H.code)&&P()}};return window.addEventListener("message",K),()=>{clearTimeout(T),window.removeEventListener("message",K)}},[m,u==null?void 0:u.audio,o,l,I,a]);const M=g.useCallback(()=>{if(u){if(u.audio){if(m){A(),w(!1),b(!1),k(!1);return}F(u.audio,u.hls===!0,a);return}if(!m){w(!0),b(!1),k(!1);return}I(ol("pauseVideo")),w(!1),b(!1),k(!1)}},[u,m,x,a,I,F,A]);return g.useMemo(()=>({probe:u,dead:f,armed:m,playing:x,buffering:j,frame:R,say:I,press:M}),[u,f,m,x,j,I,M])}const PT="agent-dag.radio-favorites",DT="agent-dag.radio-recent",FT="agent-dag.radio-catalogue";function yX(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"?MN(s.url):null,l=hD(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 BT(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 wX(e,t){return[t,...e.filter(n=>n!==t)].slice(0,50)}function hje(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 fje(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 fD(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 pje(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 mje(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 xX(){const[e,t]=g.useState(()=>BT(nt(PT))),[n,s]=g.useState(()=>BT(nt(DT))),[a,o]=g.useState(()=>{try{return yX(JSON.parse(nt(FT)??"[]"))}catch{return[]}});g.useEffect(()=>{st(PT,JSON.stringify(e))},[e]),g.useEffect(()=>{st(DT,JSON.stringify(n))},[n]);const i=g.useCallback(d=>s(f=>wX(f,d)),[]),l=g.useCallback(d=>t(f=>f.includes(d)?f.filter(p=>p!==d):[...f,d].slice(-100)),[]),u=g.useCallback(d=>{o(d),st(FT,JSON.stringify(d))},[]);return{favorites:e,recent:n,catalogue:a,remember:i,toggleFavorite:l,updateCatalogue:u}}function vX(e,t,n,s){const a=fD(e,t,n);if(!a)return()=>{};const o=setTimeout(()=>{n.add(t),s(a)},1e3);return()=>clearTimeout(o)}const dm=148,qT=6e3,bX=16e3,pD=46,Xa=34;function kX(e,t,n=dm){let s=-Math.round(t()*n);if(Math.abs(s-e)<Xa){const a=e-Xa>=-n?-Xa:Xa;s=Math.max(-n,Math.min(0,Math.round(e+a)))}return{to:s,ms:Math.round(Math.abs(s-e)*pD)}}function jX(e){return Math.round(qT+e()*(bX-qT))}const UT=[{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 NX(e){const t=UT.reduce((s,a)=>s+a.weight,0);let n=e()*t;for(const s of UT)if(n-=s.weight,n<0)return s.kind;return"stroll"}const SX=720,CX=260,_X=620,EX=220,WT=520,mD=1600,HT=7e3,TX=15e3,zT=6e3,AX=14e3;function il(e,t,n=dm){let s=-Math.round(t()*n);if(Math.abs(s-e)<Xa){const a=e-Xa>=-n?-Xa:Xa;s=Math.max(-n,Math.min(0,Math.round(e+a)))}return s}const tn=(e,t)=>Math.round(Math.abs(t-e)*pD),RX=120,of=0;function MX(e,t){const n=s=>({kind:"litter",at:t,...s});return[{x:t,prop:n({}),act:"walk",ms:tn(e,t)},{x:t,prop:n({}),act:"stoop",ms:SX},{x:of,prop:n({held:!0}),act:"carry",ms:tn(t,of)},{x:of,prop:n({held:!0}),act:"windup",ms:CX},{x:of,prop:n({held:!0,leaving:!0}),act:"toss",ms:_X}]}function $X(e,t){const n=t>e?1:-1,s=t-n*Math.min(15,Math.abs(t-e)),a=(o={})=>({kind:"ball",at:t,...o});return[{x:s,prop:a(),act:"walk",ms:tn(e,s)},{x:s,prop:a(),act:"windup",ms:EX,facing:n>0?"right":"left"},{x:s,prop:a({leaving:!0}),act:"kick",ms:WT,facing:n>0?"right":"left"},{x:s,prop:a({leaving:!0}),act:"stand",ms:mD-WT}]}const gD=640;function LX(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:tn(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:tn(s,0)}]}function IX(e,t,n){const s=Math.max(-110,Math.min(-30,t)),a={x:s,prop:null};return[{...a,act:"walk",ms:tn(e,s)},{...a,act:"skip-ready",ms:500},{...a,act:"skip",ms:gD*(6+Math.floor(n()*5))},{...a,act:"skip-rest",ms:600},{...a,act:"stand",ms:350},{x:0,prop:null,act:"walk",ms:tn(s,0)}]}function OX(e,t,n){return[{x:t,prop:null,act:"walk",ms:tn(e,t)},{x:t,prop:null,act:"sit",ms:Math.round(zT+n()*(AX-zT))},{x:t,prop:null,act:"stand",ms:400}]}function PX(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:tn(e,t)},{x:t,prop:s(),act:"watch",ms:Math.round(HT+n()*(TX-HT))},{x:t,prop:s(),act:"scope-pack",ms:480},{x:t,prop:null,act:"stand",ms:240}]}function tw(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 DX=1500,FX=e=>Math.round(1e3*Math.sqrt(2*e/DX)),BX=115,qX=e=>Math.round(e/BX*1e3),UX=620,WX=200,HX=760,zX=600,VX=240;function GX(e,t,n){const a=-(t.ledgeSpan??dm),o=FX(t.ledgeH),i=qX(t.ledgeH),l=n(),u=n(),d=-Math.round(l*t.floorSpan),f=-Math.round(u*t.floorSpan);return[{x:a,act:"walk",prop:null,ms:tn(e,a)},{x:a,act:"peer",prop:null,ms:UX},{x:a,act:"fall",prop:null,ms:o,place:"floor"},{x:a,act:"land",prop:null,ms:WX,place:"floor"},{x:d,act:"walk",prop:null,ms:tn(a,d),place:"floor",floorFrac:l},{x:f,act:"walk",prop:null,ms:tn(d,f),place:"floor",floorFrac:u},{x:a,act:"walk",prop:null,ms:tn(f,a),place:"floor"},{x:a,act:"lasso",prop:null,ms:HX,place:"floor"},{x:a,act:"rope-throw",prop:null,ms:zX,place:"floor"},{x:a,act:"rope-catch",prop:null,ms:VX,place:"floor"},{x:a,act:"climb",prop:null,ms:i},{x:a,act:"pull-up",prop:null,ms:480}]}function KX(e,t,n){const s=(n==null?void 0:n.ledgeSpan)??dm;switch(NX(t)){case"tidy":return MX(e,il(e,t,s));case"kick":return $X(e,il(e,t,s));case"sit":return OX(e,il(e,t,s),t);case"watch":return PX(e,il(e,t,s),t);case"fish":return LX(e,il(e,t,s),t);case"skip":return IX(e,il(e,t,s),t);case"leave":{if(!n||!(n.ledgeH>0)||!(n.floorSpan>0))break;return GX(e,n,t)}}const o=kX(e,t,s);return[{x:o.to,prop:null,act:"walk",ms:o.ms}]}const YX=420;function XX(e,t,n){const s=t==="right"?n-e-18:e-18;return(t==="right"?1:-1)*Math.min(YX,Math.max(0,s))}const ZX=260,JX=200;function QX(e,t,n){const s=(f,p=tn(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,d={place:"floor",riser:n.height,prop:null};return[s(l,tn(e,l)),{...d,x:l,act:"mount",ms:ZX},{...d,x:u,act:"walk",ms:tn(l,u)},{x:u,prop:null,act:"dismount",ms:JX,place:"floor"},{x:t,prop:null,act:"walk",ms:tn(u,t),place:"floor"}]}const yD=["bob","sway","groove"],VT=9e3,eZ=16e3,wD=1e3,tZ=.08;function nZ(e,t){const n=yD.filter(o=>o!==e),s=n[Math.min(n.length-1,Math.floor(t()*n.length))],a=(t()*2-1)*tZ;return{dance:s,beatMs:Math.round(wD*(1+a))}}function sZ(e){return Math.round(VT+e()*(eZ-VT))}const $N=["......aaaaaa......","....aa......aa....","...a..bbbbbs..a...","...cpcbbbbbscpc...","...cpcbebbescpc...","...cpcbbbbbscpc...","...cpcbbbbbscpc...","....ccbbbbbscc....","....bbbbbbbbbs....","....bbbbbbbbbs....","......bbbbbs......","......bb..bs......","......bb..bs......","......bb..bs......"],GT=18,rZ=$N.length,xD="M6 9H4V1H5V0H7V-1H9V1H7V2H5V7H6V8H7V9Z",vD="M12 9H14V6H13V3H11V2H9V4H12Z",LN=new Set(["a","c","p"]);function lo(e=$N){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 aZ=[".xx.","xxxx",".xx."],oZ=["..xx..",".xsxx.","xssxxx","xxxxsx",".xxxx.","..xx.."],iZ=["...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."],nw={litter:aZ,ball:oZ,scope:iZ},lZ=["...hhhhhh...","...hhhhhh...","...kkkkkk...","hhhhhhhhhhhh"],cZ=3,uZ=-1,F1=11,KT=9;function YT(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 d=n;n=null,d==null||d()},s))},u=()=>{e.hidden&&t!==null?(s=Math.max(0,s-(performance.now()-a)),i()):e.hidden||l()};return e.addEventListener("visibilitychange",u),{schedule(d,f){o||(i(),n=d,s=Math.max(0,f),l())},dispose(){o=!0,i(),n=null,e.removeEventListener("visibilitychange",u)}}}function dZ(e,t,n){const[s,a]=g.useState(0),[o,i]=g.useState(0),[l,u]=g.useState(null),[d,f]=g.useState(null),[p,m]=g.useState({x:0,drop:0}),[w,x]=g.useState("ledge"),[b,j]=g.useState("left"),[k,v]=g.useState(0),S=g.useRef(null),[C,_]=g.useState(()=>document.hidden);g.useEffect(()=>{const M=new Set,B=()=>{var T;if(document.hidden){for(const P of((T=S.current)==null?void 0:T.getAnimations({subtree:!0}))??[])if(P.playState==="running"||P.pending){const q=P.currentTime;P.pause(),q!==null&&(P.currentTime=q),M.add(P)}}else{for(const P of M)P.playState==="paused"&&P.play();M.clear()}_(document.hidden)};return B(),document.addEventListener("visibilitychange",B),()=>document.removeEventListener("visibilitychange",B)},[e,t]);const[R,A]=g.useState(null),[I,$]=g.useState(wD),[U,F]=g.useState(()=>{var M;return((M=window.matchMedia)==null?void 0:M.call(window,"(prefers-reduced-motion: reduce)").matches)??!1});return g.useEffect(()=>{var T;const M=(T=window.matchMedia)==null?void 0:T.call(window,"(prefers-reduced-motion: reduce)");if(!M)return;const B=()=>F(M.matches);return B(),M.addEventListener("change",B),()=>M.removeEventListener("change",B)},[]),g.useEffect(()=>{var J;if(!e||t||U)return;const M=YT(document);let B=0;a(Q=>B=Q);let T=null,P=0,q=0;const K=Q=>{var re,he;const[te,...le]=Q;if(!te){T=null,u(null),f(null),W();return}u(te.act),f(te.prop),x(te.place??"ledge"),v(te.riser??0);const de=B,oe=V(te);if(te.act==="kick"){const fe=(he=(re=S.current)==null?void 0:re.querySelector('.fm-prop[data-prop="ball"]'))==null?void 0:he.getBoundingClientRect();fe&&m({x:XX(fe.x,tw(te,de,"left"),window.innerWidth),drop:Math.max(48,window.innerHeight-fe.y+24)})}q=te.act==="walk"?Math.max(tn(de,oe),RX):te.ms,te.act==="carry"&&(q=tn(de,oe)),i(q),j(fe=>tw({...te,x:oe},de,fe)),a(oe),B=oe,T=te,P=Date.now(),M.schedule(()=>K(le),q)},z=()=>{const Q=S.current,te=Q==null?void 0:Q.querySelector(".fm-sprite"),le=Q==null?void 0:Q.parentElement;if(!Q||!te||!le)return null;const de=Q.getBoundingClientRect(),oe=le.getBoundingClientRect(),re=oe.right-de.right,he=oe.width-re*2-te.offsetWidth;return he>0?he:null},H=()=>{const Q=S.current,te=Q==null?void 0:Q.querySelector(".fm-sprite");return!Q||!te?0:Math.max(0,Q.getBoundingClientRect().width-te.offsetWidth)},D=()=>{const Q=S.current,te=Q==null?void 0:Q.querySelector(".fm-walker"),le=z();if(!Q||!te||le==null)return;const de=Q.getBoundingClientRect().bottom-te.getBoundingClientRect().bottom;if(de>0)return{ledgeH:de,floorSpan:le,ledgeSpan:H()}},O=()=>{const Q=S.current,te=document.querySelector(".canvas-notices");if(!Q||!te)return null;const le=Q.getBoundingClientRect(),de=te.getBoundingClientRect();return de.width<=0||de.height<=0?null:{left:de.left-le.right,right:de.right-le.right,height:de.height}},V=Q=>{const te=(Q.place??"ledge")==="floor",le=te?z()??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=V(T);Q!==B&&(i(Math.max(0,P+q-Date.now())),j(te=>tw({...T,x:Q},B,te)),a(Q),B=Q)},W=()=>{M.schedule(()=>{const Q=KX(B,Math.random,D()),te=Q.some(oe=>oe.place==="floor")?O():null;let le=B;const de=Q.flatMap(oe=>{const re=le;if(le=oe.x,!(oe.place==="floor"&&oe.act==="walk"))return[oe];const he=QX(re,oe.x,te),fe=he.length-1;return oe.floorFrac==null?he:he.map(($e,ye)=>ye===fe?{...$e,floorFrac:oe.floorFrac}:$e)});K(de)},jX(Math.random))},X=(J=S.current)==null?void 0:J.parentElement,Y=typeof ResizeObserver>"u"?null:new ResizeObserver(Z);return X&&Y&&Y.observe(X),W(),()=>{M.dispose(),Y==null||Y.disconnect(),x("ledge"),a(Q=>Math.max(-H(),Math.min(0,Q))),i(0),u(null),f(null),v(0)}},[e,t,U]),g.useEffect(()=>{if(!n||U){A(null);return}const M=YT(document),B=T=>{const P=nZ(T,Math.random);A(P.dance),$(P.beatMs),M.schedule(()=>B(P.dance),sZ(Math.random))};return B(null),()=>M.dispose()},[n,U]),{scene:S,suspended:C,x:s,walkMs:o,act:l,prop:d,ballFlight:p,place:w,facing:b,riser:k,dance:R,beatMs:I}}const sw={e:"fm-eye",s:"fm-shade",p:"fm-pad"},up=lo().filter(e=>!LN.has(e.cell)),hZ=lo().filter(e=>LN.has(e.cell)),XT=up.filter(e=>e.cell==="e"),fZ=lo(lZ),pZ=up.filter(e=>e.y<F1&&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),mZ={left:up.filter(e=>e.y>=F1&&e.x<KT),right:up.filter(e=>e.y>=F1&&e.x>=KT)},gZ=g.memo(function({act:t,facing:n}){return r.jsxs("svg",{viewBox:`0 0 ${GT} ${rZ}`,shapeRendering:"crispEdges","aria-hidden":!0,children:[r.jsx("g",{className:"fm-gear",children:r.jsx("g",{className:"fm-gear-motion",children:hZ.map(s=>r.jsx("rect",{x:s.x,y:s.y,width:s.w,height:1,className:sw[s.cell]},`g${s.y}-${s.x}`))})}),r.jsxs("g",{className:"fm-body",children:[XT.map(s=>r.jsx("rect",{x:s.x,y:s.y,width:s.w,height:1,fill:"var(--accent)"},`eye-bed-${s.x}`)),pZ.map(s=>r.jsx("rect",{x:s.x,y:s.y,width:s.w,height:1,className:sw[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"})]}),XT.map(s=>r.jsx("rect",{x:s.x-(s.x>=GT/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:fZ.map(s=>r.jsx("rect",{x:cZ+s.x,y:uZ+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:xD}),r.jsx("path",{className:"fm-grip-right",d:vD})]}),(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:mZ[s].map(a=>r.jsx("rect",{x:a.x,y:a.y,width:a.w,height:1,className:sw[a.cell]},`${s}${a.y}-${a.x}`))},s))]})}),yZ=["...o........o.....","...of......fo.....","...owffffffwo.....","...offfffffso.....","...ofefffefso.....","....owwnwwso......",".....wwwww........",".....fwwwfs.......","....ffwwwffs...ww.","....ffwwwffs..wfs.","......fwwfssfffs..","......ff..fsffs...","......ff..fs......","......oo..oo......"],wZ=[".....aaaaaaa......","...aa.......aa....","..a...........a...","..cp.........pc...","..cp.........pc...","..cp.........pc...","..c...........c..."],dr={f:"#d88735",s:"#a55b24",o:"#63351e",w:"#ffe2aa",n:"#372821"},xZ={p:"fm-pad"},td=lo(yZ),vZ=lo(wZ);function B1(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 bZ=B1(td.filter(e=>e.y>=8),12,18),kZ=td.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),ZT=td.filter(e=>e.cell==="e"),jZ={left:B1(td.filter(e=>e.y>=11),0,9),right:B1(td.filter(e=>e.y>=11),9,12)},NZ=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:bZ.map(i=>r.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,fill:dr[i.cell]},`t${i.y}-${i.x}`))}),r.jsx("g",{className:"fm-gear",children:r.jsx("g",{className:"fm-gear-motion",children:vZ.map(i=>r.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,className:xZ[i.cell]},`g${i.y}-${i.x}`))})}),r.jsxs("g",{className:"fm-body",children:[kZ.map(i=>r.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,fill:dr[i.cell]},`b${i.y}-${i.x}`)),ZT.map(i=>r.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,fill:dr.f},`bed${i.x}`)),r.jsxs("g",{className:"fm-arms",fill:dr.f,children:[r.jsx("rect",{x:4,y:8,width:2,height:2}),r.jsx("rect",{x:12,y:8,width:1,height:2})]}),ZT.map(i=>r.jsx("rect",{x:i.x+(n==="right"?1:0)-(i.x>=9?1:0),y:i.y,width:i.w,height:1,className:"fm-eye",style:{fill:dr.n}},`e${i.x}`))]}),s&&r.jsxs("g",{className:"fm-grip",style:{fill:dr.f},children:[r.jsx("path",{className:"fm-grip-left",d:xD}),r.jsx("path",{className:"fm-grip-right",d:vD})]}),a&&r.jsxs("g",{className:"fm-crouch-legs",style:{fill:dr.f},children:[r.jsx("path",{d:"M6 11H8V13H6Z"}),r.jsx("path",{d:"M10 11H12V13H10Z"})]}),o&&r.jsxs("g",{className:"fm-seated-legs",style:{fill:dr.f},children:[r.jsx("path",{className:"fm-seated-far",style:{fill:dr.s},d:"M10 10H12V11H11V14H8V13H9V11H10Z"}),r.jsx("path",{d:"M6 10H9V11H7V15H4V14H5V11H6Z"})]}),["left","right"].map(i=>r.jsx("g",{className:"fm-leg","data-side":i,children:jZ[i].map(l=>r.jsx("rect",{x:l.x,y:l.y,width:l.w,height:1,fill:dr[l.cell]},`${l.y}-${l.x}`))},i))]})}),SZ=[".......dddd.......","......dhhhhd......",".....dhhhhhhd.....","....dhwwhhwwhd....","....dhwewwewhd....","....dhwwbbwwhd....","....dhwwwwwwhd....","....dhwwwwwwhd....","....dhwwwwwwhd....",".....dhwwwwhd.....",".....dhwwwwhd.....","......dhhhhd......","......bb..bb......",".....bbb..bbb....."],Xr={d:"#3b4855",h:"#657b8b",w:"#f4f0df",e:"#19242b",b:"#f0b44b",s:"#c88736"},CZ={p:"fm-pad"},dp=lo(SZ),_Z=lo($N).filter(e=>LN.has(e.cell)),JT=dp.filter(e=>e.cell==="e"),EZ=dp.filter(e=>e.y<12&&e.cell!=="e"),TZ={left:dp.filter(e=>e.y>=12&&e.x<9),right:dp.filter(e=>e.y>=12&&e.x>=9)},AZ=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:_Z.map(o=>r.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,className:CZ[o.cell]},`g${o.y}-${o.x}`))})}),r.jsxs("g",{className:"fm-body",children:[EZ.map(o=>r.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,fill:Xr[o.cell]},`b${o.y}-${o.x}`)),JT.map(o=>r.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,fill:Xr.w},`bed${o.x}`)),r.jsxs("g",{className:"fm-arms",fill:Xr.d,children:[r.jsx("path",{d:"M4 8H6V10H5V11H4Z"}),r.jsx("path",{d:"M12 8H14V11H13V10H12Z"})]}),JT.map(o=>r.jsx("rect",{x:o.x,y:o.y,width:o.w,height:1,className:"fm-eye",style:{fill:Xr.e}},`e${o.x}`))]}),n&&r.jsxs("g",{className:"fm-grip",style:{fill:Xr.h},children:[r.jsx("path",{className:"fm-grip-left",d:"M5 10H4V4H5V2H6V1H7V0H9V2H7V3H6V10Z"}),r.jsx("path",{className:"fm-grip-right",d:"M12 10H14V6H13V3H11V2H9V4H12Z"})]}),s&&r.jsxs("g",{className:"fm-crouch-legs",style:{fill:Xr.b},children:[r.jsx("path",{d:"M5 12H8V13H5Z"}),r.jsx("path",{d:"M10 12H13V13H10Z"})]}),a&&r.jsxs("g",{className:"fm-seated-legs",style:{fill:Xr.b},children:[r.jsx("path",{className:"fm-seated-far",style:{fill:Xr.s},d:"M10 11H12V12H13V14H10V13H11V12H10Z"}),r.jsx("path",{d:"M6 11H8V12H7V13H8V14H4V13H5V12H6Z"})]}),["left","right"].map(o=>r.jsx("g",{className:"fm-leg","data-side":o,children:TZ[o].map(i=>r.jsx("rect",{x:i.x,y:i.y,width:i.w,height:1,fill:Xr.b},`${i.y}-${i.x}`))},o))]})});function bD({character:e,act:t,facing:n}){return e==="penguin"?r.jsx(AZ,{act:t,facing:n}):e==="fox"?r.jsx(NZ,{act:t,facing:n}):r.jsx(gZ,{act:t,facing:n})}const RZ={"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 kD(e,t){return t&&Gl(t.id)===e?t.name:um(e)?"Custom FM":RZ[e]}function rw(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:lo(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 QT={litter:rw(nw.litter,"litter"),ball:rw(nw.ball,"ball"),scope:rw(nw.scope,"scope")};function MZ(e){try{return new URL(e).host}catch{return"the station's server"}}const $Z=g.memo(function({player:t,source:n,customStation:s,character:a="deck"}){const{probe:o,dead:i,playing:l,press:u}=t,{scene:d,suspended:f,x:p,walkMs:m,act:w,prop:x,ballFlight:b,place:j,facing:k,riser:v,dance:S,beatMs:C}=dZ(o,i,l);if(!o||i)return null;const _=kD(n,s),R=o.audio?MZ(o.audio):"YouTube";return r.jsxs("div",{ref:d,className:"fm","data-suspended":f?"":void 0,"data-place":j,style:{"--fm-beat":`${C}ms`},children:[x&&!x.held&&r.jsx("div",{className:"fm-prop","data-prop":x.kind,"data-leaving":x.leaving?"":void 0,style:{"--fm-prop-x":`${x.at}px`,"--fm-roll-to":`${b.x}px`,"--fm-ball-drop":`${b.drop}px`,"--fm-ball-flight-ms":`${mD}ms`,"--fm-ball-turn":k==="right"?"1080deg":"-1080deg"},children:QT[x.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":j,"data-facing":k,style:{"--fm-x":`${p}px`,"--fm-walk-ms":`${m}ms`,"--fm-riser":`${v}px`,"--fm-skip-beat":`${gD}ms`},children:[(x==null?void 0:x.held)&&r.jsx("div",{className:"fm-held","data-prop":x.kind,"data-toss":x.leaving?"":void 0,children:QT[x.kind]}),["cast","fish","reel","stow"].includes(w)&&r.jsxs("svg",{className:"fm-fishing",viewBox:"0 0 24 32",shapeRendering:"crispEdges","aria-hidden":!0,children:[r.jsxs("g",{children:[r.jsx("path",{d:"M24 11H22V9H20V7H18V5H16V3H13V2H8"}),r.jsx("rect",{className:"fm-fishing-grip",x:"21",y:"9",width:"3",height:"3"})]}),r.jsxs("g",{className:"fm-fishing-line",children:[r.jsx("path",{d:"M8 2V26"}),r.jsxs("g",{className:"fm-float",children:[r.jsx("rect",{x:"7",y:"25",width:"3",height:"2"}),r.jsx("rect",{x:"8",y:"24",width:"1",height:"1"})]})]}),r.jsx("path",{className:"fm-ripple",d:"M3 28H6M10 28H14M5 30H12"})]}),["skip-ready","skip","skip-rest"].includes(w)&&r.jsxs("svg",{className:"fm-skipping-rope",viewBox:"0 0 26 26",shapeRendering:"crispEdges","aria-hidden":!0,children:[r.jsx("path",{className:"fm-skip-back",d:"M5 18H3V8H5V5H8V2H18V5H21V8H23V18H21"}),r.jsx("path",{className:"fm-skip-forward",d:"M5 18H3V14H5V11H8V9H18V11H21V14H23V18H21"}),r.jsx("path",{className:"fm-skip-front",d:"M5 18H3V21H5V23H8V25H18V23H21V21H23V18H21"}),r.jsx("path",{className:"fm-skip-return",d:"M5 18H3V19H8V20H18V19H23V18H21"}),r.jsx("path",{className:"fm-skip-handles",d:"M5 17V19M21 17V19"})]}),r.jsx("button",{type:"button",className:"fm-sprite","data-playing":l?"":void 0,"data-dance":l?S??yD[0]:void 0,onClick:u,title:l?`Stop ${_}`:`Play ${_} — streams from ${R}`,"aria-label":l?`Stop ${_}`:`Play ${_}`,children:r.jsx(bD,{character:a,act:w,facing:k})})]})]})});function LZ({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:lX(n.channel,window.location.origin,n.video),onLoad:()=>o(cX()),allow:"autoplay; encrypted-media",sandbox:"allow-scripts allow-same-origin allow-presentation"})}):null}const IZ={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 OZ({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:IZ[e]})})}function PZ({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 DZ({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:JG,children:[r.jsx("button",{type:"button",className:"icon-btn","aria-label":"Close radio",onClick:e,children:r.jsx(OZ,{name:"close"})}),r.jsx(PZ,{opening:!0})]})}const FZ=g.lazy(()=>gi(()=>import("./RadioPanel-gFYxdsBg.js"),[]));function BZ({fm:e,characterEnabled:t,character:n,open:s,onClose:a}){const[o,i]=g.useState(!1),[l,u]=g.useState("Connecting to the deck…"),d=xX(),[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(I=>I.ok?I.json():null).then(I=>{A.signal.aborted||(i((I==null?void 0:I.enabled)===!0),u(I?"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=>Gl(A.id)===e.fmSource),x=w!=null&&w.radio?w:void 0,b=gX({volume:e.fmVolume,muted:e.fmMuted,source:e.fmSource,playRequest:e.fmPlayRequest,customStation:w,enabled:o,onAvailabilityChange:e.markFmStationAvailability}),j=kD(e.fmSource,w),k=o&&x&&b.dead&&e.fmPlayRequest>0?fD(f??d.catalogue,x.id,m.current):null,{remember:v}=d,S=(w==null?void 0:w.id)??e.fmSource;g.useEffect(()=>{b.playing&&v(S)},[S,b.playing,v]);const C=a,_=wt(a),R=g.useCallback((A,I=!1)=>{var M;if(!o)return;I||m.current.clear();const $=Gl(A.id),U=$===e.fmSource;if(U&&b.armed&&!b.dead){b.press();return}const F=U&&!!w&&(w.url!==A.url||((M=w.radio)==null?void 0:M.hls)!==A.radio.hls);e.addFmStation(A,!0),U&&!b.dead&&!F?b.press():e.pickFmSource($,F),fetch(`/api/radio-click?id=${encodeURIComponent(A.id)}`).catch(()=>{})},[o,w,e.addFmStation,e.fmSource,e.pickFmSource,b.armed,b.dead,b.press]);return g.useEffect(()=>{b.playing&&!b.dead&&m.current.clear()},[b.playing,b.dead]),g.useEffect(()=>{if(!(!o||!x||!b.dead||e.fmPlayRequest===0))return vX(f??d.catalogue,x.id,m.current,A=>R(A,!0))},[o,x==null?void 0:x.id,b.dead,e.fmPlayRequest,f,d.catalogue,R]),r.jsxs(r.Fragment,{children:[t&&r.jsx($Z,{character:n,player:b,source:e.fmSource,customStation:w}),r.jsx(LZ,{player:b,label:j}),s&&vt.createPortal(r.jsx("div",{className:"modal-backdrop radio-backdrop",..._,children:r.jsx(g.Suspense,{fallback:r.jsx(DZ,{onClose:C}),children:r.jsx(FZ,{fm:e,player:b,library:d,selected:x,label:j,enabled:o,disabledReason:l,autoNext:k==null?void 0:k.name,onPick:R,onQueueChange:p,onClose:C})})}),document.body)]})}function qZ({data:e}){const t=Sr(3e4),n=e.note,s=e.plan??null,a=(n==null?void 0:n.kind)==="recap",o=ip((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:im(n),u=Nr(s),d=n?sc(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: ${d}`,"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(ap,{recap:a}),d]}),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(),bK(e.noteKey)},children:"×"})]}),n&&r.jsx("p",{className:"recap-note-text",title:MK(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(eA,{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(ap,{recap:a}),d]}),r.jsx("span",{className:"recap-face-age",children:o.label})]}),n&&r.jsx("p",{className:"recap-face-text",children:n.text}),s&&r.jsx(eA,{plan:s,head:n!=null,face:!0})]}),r.jsx(ci,{type:"source",position:Ye.Right,style:{background:"transparent",border:"none"}})]})}const UZ={completed:"done",in_progress:"now",pending:"to do"};function eA({plan:e,head:t,face:n=!1}){const s=Nr(e);if(!s)return null;const a=vV(e.items);return r.jsxs("div",{className:n?"recap-face-plan":"recap-note-plan",title:n?void 0:Xp(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:[UZ[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 to(){var t;return typeof navigator>"u"?"":((t=navigator.userAgentData)==null?void 0:t.platform)||navigator.platform||""}function co(e){return/mac|iphone|ipad/i.test(e)}const hp=e=>new Map([...e].map(([t,n])=>[t,{x:n.x,y:n.y}]));function WZ(e,t,n){return{positions:hp(e.positions),pinned:hp(e.pinned),provisional:new Set(e.provisional),layoutSig:e.layoutSig.current,stored:{...t},viewport:n?{...n}:null}}function HZ(e,t){t.positions.clear();for(const[n,s]of hp(e.positions))t.positions.set(n,s);t.pinned.clear();for(const[n,s]of hp(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 tA=7e3,zZ=2e3,VZ=140,GZ="Layout re-arranged",KZ="Layout re-arranged. Undo available.",nA="Layout restored.",YZ={set:(e,t)=>setTimeout(e,t),clear:e=>clearTimeout(e),now:()=>Date.now()};function XZ(e,t=YZ){let n=null,s=null,a=0,o=tA;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,d()},o))};function d(){l(),i.clear(),n!==null&&(n=null,e(!1))}return{open(f){const p=n===null;n=f,o=tA,u(),p&&e(!0)},take(){const f=n;return d(),f},close:d,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,zZ),u())},get isOpen(){return n!==null},get snapshot(){return n}}}function ZZ(e){return(e.key==="z"||e.key==="Z")&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey}function JZ(e){return co(e)?"⌘Z":"Ctrl+Z"}function QZ({undo:e}){const{open:t,said:n,undo:s,dismiss:a,hold:o,release:i}=e,l=bl(t,VZ),u=g.useRef(null);return g.useEffect(()=>t?ln.push(a,0,"popover"):void 0,[t,a]),g.useEffect(()=>{var f;if(t)return;const d=u.current;d&&d.contains(document.activeElement)&&((f=d.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}),Ya(l)&&r.jsxs("div",{ref:u,className:l==="leaving"?"rearrange-undo leaving":"rearrange-undo",onPointerEnter:()=>o("hover"),onPointerLeave:()=>i("hover"),onFocus:()=>o("focus"),onBlur:d=>{d.currentTarget.contains(d.relatedTarget)||i("focus")},children:[r.jsx("span",{id:"rearrange-undo-state",className:"rearrange-undo-state",children:GZ}),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:JZ(to())})]})]})]})}function eJ({sourceX:e,sourceY:t,targetX:n,targetY:s,sourcePosition:a,targetPosition:o,style:i}){const[l]=nN({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 q1(e){return e.replace(/[^a-zA-Z0-9]/g,"")}function fp(e,t){const n=q1(e);return n?n.slice(-t):e.slice(-t)}function jD(e,t,n=4){const s=q1(e);if(!s)return fp(e,n);let a=n;for(const o of t){if(o===e)continue;const i=q1(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 kl=" · ",tJ=32,nJ=/[\u1100-\u115F\u2E80-\u303E\u3041-\u33FF\u3400-\u4DBF\u4E00-\u9FFF\uA000-\uA4CF\uAC00-\uD7A3\uF900-\uFAFF\uFE30-\uFE6F\uFF00-\uFF60\uFFE0-\uFFE6]/;function sA(e){return nJ.test(e)?2:1}function rA(e,t=tJ){const n=[...e];let s=0;for(const i of n)s+=sA(i);if(s<=t)return e;const a=[];let o=0;for(const i of n){const l=sA(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 sJ(e,t,n,s,a=[],{branch:o,plan:i,alarm:l=!1}={}){const u=(t==null?void 0:t.trim())??"",d=s?jD(n,a):void 0,f=[e,u||void 0,d].filter(Boolean),p=[e,i?`plan ${i}`:void 0,o,u||void 0,d].filter(Boolean).join(kl);return{label:rA(e),name:u?rA(u):void 0,shortId:d,fullLabel:f.join(kl),title:`${l?"waiting on you: ":""}${p}
|
|
90
|
+
Zoom to this session
|
|
91
|
+
drag the wrapper to move the whole session`}}const Zo=18,U1=26,IN=12,nd=240,ON=130,W1=Zo*2+U1+IN,rJ=72,Ml=W1+rJ,Pf=24,ND=70,pp=Zo*2+Pf,Kl=Ml;function SD(e,t){var s;let n=nd;for(const a of e)n=Math.max(n,((s=t.get(a.id))==null?void 0:s.width)??nd);return n}const $l=420,Df=300,mp=130,CD=160,_D=1;function aJ(e,t,n,s){return Math.min(_D,n/Math.max(1,e),s/Math.max(1,t))}function un(e){const t=e.data;return(t==null?void 0:t.canvasSessionId)??(t==null?void 0:t.sessionId)??"_default"}function hm(e,t=()=>!0){const n=new Map;for(const s of e){if(!t(s))continue;const a=un(s),o=n.get(a);o?o.push(s):n.set(a,[s])}return n}function oJ(e,t){return((t==null?void 0:t.get(e))??0)>0?$l:0}function iJ(e,t){const n=(t==null?void 0:t.get(e))??0;return n>0?6+n*36:0}function sd(e,t){const n=t.get(e);return{w:(n==null?void 0:n.width)??nd,h:(n==null?void 0:n.height)??ON}}function rc(e,t,n){const s=sd(e,t);return{w:s.w+oJ(e,n),h:Math.max(s.h,iJ(e,n))}}function lJ(e){return[...e.keys()].sort().map(t=>`${t}:${e.get(t)}`).join("|")}const cJ=240,ED=16;function TD(e,t){return(e+cJ)*(t||1)}function uJ(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 dJ(e,t,n,s){return{position:"absolute",left:e.x+ED,top:e.y-IN/(t||1),transform:`scale(${1/(t||1)})`,transformOrigin:"left top",maxWidth:s??TD(e.w,t),"--session-hue":n}}function hJ(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,d=l+a.height,f=t.get(un(a)),p=o.canvasSessionId&&o.canvasSessionId!==o.sessionId?null:fJ(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,d),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(un(a),{minX:i,minY:l,maxX:u,maxY:d,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,...sJ(o.label,o.name,a,l,i,{branch:o.branch,plan:o.planLine,alarm:o.alarm}),x:o.minX-Zo,y:o.minY-Zo-U1,w:o.maxX-o.minX+Zo*2,h:o.maxY-o.minY+Zo*2+U1,...o.alarm?{alarm:!0}:null,...o.branch?{branch:o.branch}:null,...o.plan?{plan:o.plan,planLine:o.planLine}:null})}return s}function fJ(e){if(e.kind!=="root")return null;const t=e.branch,n=Nr(e.plan);return{label:e.label,name:sm(e.sessionName,e.sessionTitle).face,alarm:Tn(e.waiting),branch:t&&t.total>0?HP(t):void 0,plan:n?`plan ${n.done}/${n.total}`:void 0,planLine:n?pN(n):void 0}}function pJ(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 mJ=20,Zr=4,gJ=64,yJ=".cat-filter-bar, .react-flow__panel, .autofit-chip, .rearrange-undo, .usage-panel, .sysdetail, .detail";function wJ(e,t,n,s){const a=t.zoom||1,o=TD(e.w,a);if(n.width<=0||n.height<=0)return{maxWidth:o,hidden:!1};const i=(e.x+ED)*a+t.x,l=e.y*a+t.y-IN,u=l+mJ;let d=Math.min(o,n.width-Zr-i),f=i<Zr||l<Zr||u>n.height-Zr;for(const p of s)if(!(p.top-Zr>=u||p.bottom+Zr<=l)&&!(p.right+Zr<=i)){if(p.left-Zr<=i){f=!0;break}d=Math.min(d,p.left-Zr-i)}return d<gJ&&(f=!0),{maxWidth:Math.max(0,d),hidden:f}}function xJ(e){const t=e.getBoundingClientRect(),n=[];for(const s of e.ownerDocument.querySelectorAll(yJ)){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 vJ(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 bJ=500;function AD({focus:e,setTimeout:t,clearTimeout:n,ms:s=bJ}){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 kJ(e){return hJ(e.nodeInternals.values())}const jJ=e=>e.width,NJ=e=>e.height,SJ=e=>{var t;return((t=e.domNode)==null?void 0:t.querySelector(".react-flow__viewport"))??null};function CJ({onFocusSession:e}){const{x:t,y:n,zoom:s}=D4(),a=ft(kJ,pJ),o=ft(jJ),i=ft(NJ),l={width:o,height:i},u=g.useRef(null),d=ft(SJ),[f,p]=g.useState([]);g.useLayoutEffect(()=>{var R;const S=(R=u.current)==null?void 0:R.parentElement;if(!S)return;const C=xJ(S),_=requestAnimationFrame(()=>{p(A=>vJ(A,C)?A:C)});return()=>cancelAnimationFrame(_)});const m=g.useRef(e);m.current=e;const[w]=g.useState(()=>AD({focus:S=>{var C;return(C=m.current)==null?void 0:C.call(m,S)},setTimeout:(S,C)=>window.setTimeout(S,C),clearTimeout:S=>window.clearTimeout(S)}));if(g.useEffect(()=>()=>w.cancel(),[w]),a.length<=1)return null;const x=S=>{try{e==null||e(S)}catch{}},b=(S,C)=>{S.detail>0&&xd()?w.hold(C):x(C)},j={transform:`translate(${t}px, ${n}px) scale(${s})`},k=r.jsx("div",{className:"session-clusters",style:j,ref:u,children:a.map(S=>{const C=Ju(S.sessionId),_=uJ(S,C);return r.jsx("div",{className:"cluster-card",style:_,"aria-hidden":!0},S.sessionId)})}),v=d&&vt.createPortal(r.jsx("div",{className:"cluster-labels nopan",children:a.map(S=>{const C=Ju(S.sessionId),_=wJ(S,{x:t,y:n,zoom:s},l,f),R=dJ(S,s,C,_.maxWidth);return r.jsxs("button",{type:"button",className:"cluster-label","data-alarm":S.alarm?"":void 0,"data-offpane":_.hidden?"":void 0,style:R,title:S.title,onClick:A=>b(A,S.sessionId),children:[S.alarm?r.jsxs(r.Fragment,{children:[r.jsx(SN,{}),r.jsx("span",{className:"cluster-label-said",children:"waiting on you: "})]}):null,S.label,S.plan?r.jsx("span",{className:"cluster-label-plan",children:kl+S.plan}):null,S.branch?r.jsx("span",{className:"cluster-label-branch",children:kl+S.branch}):null,S.name?r.jsx("span",{className:"cluster-label-name",children:kl+S.name}):null,S.shortId?r.jsx("span",{className:"cluster-label-id",children:kl+S.shortId}):null]},S.sessionId)})}),d);return r.jsxs(r.Fragment,{children:[k,v]})}function _J({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 RD=600,EJ=4,TJ=36,gp=14,AJ=60,RJ=6,aA=220,MJ=96,$J=28;function LJ(e,t){return Math.max(MJ,61+[...t].length*6.8)}function IJ(e){return e.endedAt==null?"inflight":e.ok===!1?"err":"done"}function OJ(e,t){if(t==null)return 1;const n=e-t;return n<0?1:Math.max(0,1-n/RD)}function PJ(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 DJ(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>RD)continue;const u=s.get(l.id)??n.get(l.id);if(!u)continue;const d=PJ(l.tools,EJ);if(d.length===0)continue;const f=l.exitAt??null,p=a.get(l.id),m=Math.max((p==null?void 0:p.width)??aA,aA),w=(p==null?void 0:p.height)??130,x=u.x,b=u.y,j=x+m,k=b+w/2;d.forEach((v,S)=>{const C=S*TJ,_=x+m+AJ,R=b+RJ+C,A=OJ(o,f),I=v.inputPreview??"",$=IJ(v),U=A<.999,F=NN(v.name);i.push({id:`${l.id}::${v.id}`,toolId:v.id,agentId:l.id,toolName:v.name,name:F.label,emoji:F.emoji,status:$,category:zP(v.name),mcpHue:F.hue,inputPreview:I,fade:A,fading:U,worldX:_,worldY:R,anchorX:j,anchorY:k,spawnDx:j-_,spawnDy:k-(R+gp)});const M=YP(v.name,v.input);if(M){const B=LJ(v.name,F.label),T=_+B+$J,P=R,q=_+B,K=R+gp;i.push({id:`sub:${l.id}::${v.id}`,toolId:v.id,agentId:l.id,toolName:v.name,name:oY(M.label,M.category),fullName:M.label,emoji:M.emoji,isSub:!0,status:$,category:M.category,inputPreview:M.detail??I,fade:A,fading:U,worldX:T,worldY:P,anchorX:q,anchorY:K,spawnDx:q-T,spawnDy:0})}})}return i}function FJ({agents:e,visibleAgentIds:t,positions:n,pinned:s,measured:a,spotlight:o,hiddenCategories:i,now:l,onOpenTool:u}){const d=DJ(e,t,n,s,a,l),f=i&&i.size>0?d.filter(p=>!i.has(p.category)):d;return r.jsx(BJ,{bursts:f,spotlight:o,onOpenTool:u})}function BJ({bursts:e,spotlight:t,onOpenTool:n}){const s=e.map(o=>{const i=o.anchorX,l=o.anchorY,u=o.worldX+6,d=o.worldY+gp,f=Math.max(1,u-i),p=Math.min(1,Math.abs(d-l)/f),m=i+f*(.55-.22*p),w=l+(d-l)*.12,x=u-f*.25,b=t!=null&&!t.has(o.agentId),j=o.fade*(b?.14:1);return r.jsx("path",{d:`M ${i} ${l} C ${m} ${w}, ${x} ${d}, ${u} ${d}`,className:`tool-conn status-${o.status}${o.fading?" fading":""}`,opacity:j,vectorEffect:"non-scaling-stroke"},`l:${o.id}`)}),a=e.map(o=>r.jsx(WJ,{b:o,dim:t!=null&&!t.has(o.agentId),onOpenTool:n},o.id));return r.jsx(qJ,{connectors:s,bubbles:a})}function qJ({connectors:e,bubbles:t}){const{x:n,y:s,zoom:a}=D4();return r.jsxs("div",{className:"tool-bursts-layer","aria-hidden":!0,style:{"--tool-burst-height":`${2*gp}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 UJ(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 WJ=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}:{},d=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":""}${d}`,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:"×"})]})})},UJ),HJ={width:140,height:105},zJ={agent:AY,sessionGroup:_J,recapNote:qZ},VJ={recapTie:eJ},oA=400;function GJ({graph:e,layout:t,viewport:n,clicks:s,drag:a,appearance:o,fm:i,radioOpen:l,onRadioClose:u,autoFit:d,pause:f,stateRef:p,measuredRef:m,hiddenCats:w,now:x,openTool:b,focusAgent:j,requestClear:k,setKeyHelpOpen:v}){const{allNodes:S,edges:C,visibleAgentIds:_,spotlightSet:R}=e,{positionsRef:A,pinnedRef:I,handleRelayout:$,rearrangeUndo:U}=t,{restoredViewport:F,onMoveStart:M,onMove:B}=n,{onNodeClick:T,onPaneClick:P,onNodeDoubleClick:q,onNodeMouseEnter:K,onNodeMouseLeave:z}=s,{onNodeDragStart:H,onNodeDrag:D,onNodeDragStop:O}=a,{palette:V,minimapNodeFill:Z,characterEnabled:W}=o,{autoFitDisabled:X,enableAutoFitAndRefit:Y}=d,{paused:J,pauseGate:Q,togglePause:te}=f;return r.jsxs(P4,{nodes:S,edges:C,nodeTypes:zJ,edgesFocusable:!1,edgeTypes:VJ,fitView:!F,fitViewOptions:{padding:.25,duration:S1({durationMs:oA,documentHidden:document.hidden})?oA:0},minZoom:W4,maxZoom:H4,panOnScroll:!0,panActivationKeyCode:null,nodesDraggable:!0,nodesConnectable:!1,selectionOnDrag:!1,nodeDragThreshold:5,disableKeyboardA11y:!0,deleteKeyCode:null,onNodeClick:T,onPaneClick:P,onNodeDoubleClick:q,onNodeMouseEnter:K,onNodeMouseLeave:z,onMoveStart:M,onMove:B,onNodeDragStart:(le,de,oe)=>{U.dismiss(),H(le,de,oe)},onNodeDrag:D,onNodeDragStop:O,children:[r.jsx(I9,{gap:28,size:1,color:V["--grid-line"]}),r.jsx(CJ,{onFocusSession:j}),r.jsx(FJ,{agents:p.current.agents,visibleAgentIds:_,positions:A.current,pinned:I.current,measured:m.current,spotlight:R,hiddenCategories:w,now:x,onOpenTool:b}),r.jsxs("div",{className:"canvas-notices",children:[X&&r.jsx(DY,{enableAutoFitAndRefit:Y}),r.jsx(QZ,{undo:U})]}),r.jsx(XY,{autoFitDisabled:X,enableAutoFitAndRefit:Y,paused:J,pauseGate:Q,togglePause:te,handleRelayout:$,requestClear:k,setKeyHelpOpen:v}),r.jsx(k9,{style:HJ,zoomable:!0,pannable:!0,nodeColor:Z,nodeStrokeWidth:2,maskColor:V["--minimap-mask"],maskStrokeColor:V["--line"]}),r.jsx(BZ,{fm:i,character:o.character,characterEnabled:W,open:l,onClose:u})]})}function KJ(){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(d=>Number(d).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 YJ(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=Wn(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 XJ="spend on this board",ZJ="on this board",MD=`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
|
+
`,JJ=MD+"Press H for the totals ccusage reads off the logs on disk, which do not forget.";function iA(e){return e?JJ:MD+"Usage history has the totals ccusage reads off the logs on disk, which do not forget."}const $D="session spend",H1="__unknown__",QJ=12;function eQ(e,t=Date.now()){const n=new Map;for(const s of e)for(const a of nc(s)){const o=a.model??H1,i=Jp(a.usage,a.model,t),l=E1({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 tQ(e,t=Date.now()){const n=[...e],s=[];for(const a of n){if(a.kind!=="root")continue;let o=Wn(a,t).total,i=a.usage.inputTokens,l=a.usage.outputTokens,u=Ul(a,t),d=E1(a,t);for(const f of n)f.sessionId!==a.sessionId||f.kind==="root"||(o+=Wn(f,t).total,i+=f.usage.inputTokens,l+=f.usage.outputTokens,u+=Ul(f,t),d=d&&E1(f,t));s.push({priced:d,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,QJ)}const nQ=600;function fm(e,t){return!(e.exitAt!=null&&t-e.exitAt>nQ||e.kind==="root"&&e.state==="done"&&e.tools.length===0&&e.endedAt!=null&&e.endedAt-e.startedAt<3e3&&!e.stopFailure)}function sQ(e,t){const n=new Set;for(const s of e.agents.values())fm(s,t)&&n.add(s.id);return n}function rQ(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 aQ(e,t,n=0){if(!e)return!1;for(const s of t)if(rQ(e,s,n))return!0;return!1}function lA(e){return e.waiting?Tn(e.waiting)?0:1:e.state==="active"?2:3}function LD(e,t){var s;const n=[];for(const a of e.agents.values()){if(a.kind!=="root")continue;let o=a.toolCount,i=Wn(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+=Wn(p).total;const m=p.endedAt??p.startedAt;m>l&&(l=m)}const u=kN(a),d=(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:Al(a),waiting:a.waiting,recap:d,status:f,modelId:a.model,effort:a.effort,plan:Nr(a.plan),planTitle:Xp(((s=a.plan)==null?void 0:s.items)??[]),toolCount:o,cost:i,startedAt:a.startedAt,lastActivity:l})}return n.sort((a,o)=>{const i=lA(a),l=lA(o);return i!==l?i-l:a.waiting&&o.waiting?a.waiting.since-o.waiting.since:o.lastActivity-a.lastActivity}),n}function oQ(e){return[e.text,e.reply?`Suggested reply: ${e.reply}`:"",im(e)].filter(Boolean).join(`
|
|
94
|
+
`)}function rd(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 iQ({state:e,now:t,selectedIds:n,onSelect:s,onClose:a,removedIds:o,onBringBackAll:i,leaving:l=!1}){const u=An(),d=g.useMemo(()=>LD(e),[e,e.revision,t]),f=d.filter(m=>m.state==="active").length,p=d.filter(m=>Tn(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:d.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:En("Hide sidebar","L",u),"aria-label":"Hide session list",children:"‹"})]}),r.jsxs("ul",{className:"sl-rows",children:[d.length===0&&r.jsx("li",{className:"sl-empty",children:"No sessions yet."}),d.map(m=>{var b;const w=n.has(m.sessionId),x=(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":""}${x?" removed":""}`,"aria-current":w?"true":void 0,onClick:()=>s(m.sessionId),title:x?`Bring ${m.label} back to the board`:`Focus ${m.label}`,children:[r.jsx("span",{className:`sl-dot state-${m.state}`,"aria-hidden":!0}),r.jsx("span",{className:"vis-hidden",children:Wl(m.state)}),r.jsxs("div",{className:"sl-row-body",children:[r.jsxs("div",{className:"sl-row-head",children:[r.jsx("span",{className:"sl-label",children:m.label}),x&&r.jsx("span",{className:"sl-removed",children:"off the board"}),m.modelId&&r.jsx("span",{className:"model-chip","data-family":Qp(m.modelId),title:ed(m.modelId,m.effort),children:em(m.modelId,m.effort)})]}),r.jsxs("div",{className:"sl-row-meta",children:[r.jsxs("span",{title:"tool calls",children:[r.jsx("b",{children:m.toolCount})," ",m.toolCount===1?"tool":"tools"]}),m.cost>0&&r.jsx("span",{className:"sl-cost",title:$D,children:r.jsx("b",{children:lt(m.cost)})}),m.waiting?r.jsxs("span",{className:"sl-waiting",title:[Hl(m.waiting),RP(m.waiting,Hl(m.waiting)),`${Tn(m.waiting)?"Blocked":"Your turn"} since ${new Date(m.waiting.since).toLocaleTimeString()} · started ${new Date(m.startedAt).toLocaleString()}`].filter(Boolean).join(`
|
|
95
|
+
`),children:[Tn(m.waiting)?"waiting":"your turn"," ",rd(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:rd(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:lP(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(ZP,{}),m.recap.text]}),m.status&&r.jsxs("span",{className:`sl-status status-${m.status.kind}`,title:oQ(m.status),children:[r.jsx("span",{className:"sl-status-tag",children:sc(m.status.kind)})," ",m.status.text]}),((b=m.status)==null?void 0:b.reply)&&r.jsxs("span",{className:"sl-status-reply",title:`suggested reply “${m.status.reply}”`,children:["suggested reply “",m.status.reply,"”"]})]})]})},m.sessionId)})]}),(()=>{let m=0;for(const w of o??[]){const x=e.agents.get(w);x&&fm(x,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 x=w.currentTarget.closest(".session-list");i(),requestAnimationFrame(()=>{var b;return(b=x==null?void 0:x.querySelector(".sl-row"))==null?void 0:b.focus()})},children:["Bring back ",m," removed ",m===1?"card":"cards"]})})})()]})}const lQ={recent:"Recent",sessions:"Sessions",open:"Panels and dialogs",settings:"Settings",actions:"Actions",themes:"Themes"},aw=["recent","sessions","open","settings","actions","themes"],ID=/[\s\-_./·:,()›]/;function lf(e,t){return t===0||ID.test(e[t-1])}function cA(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 cQ(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+(lf(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(!cA(o,s,0))return null;const i=[];let l=0,u=100;for(let d=0;d<o.length;d++){const f=o[d],p=o.slice(d+1);let m=s.indexOf(f,l);for(let x=m;x>=0&&cA(p,s,x+1);x=s.indexOf(f,x+1))if(lf(s,x)){m=x;break}if(d===0&&!lf(s,m))return null;const w=i[i.length-1];u+=lf(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 uQ(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(ID).some(i=>i.startsWith(n))&&(s=Math.max(s,400))}return s}const dQ=8,hQ=5,PN=5;function fQ(e,t,n=[]){const s=t.trim();if(!s){const o=new Map(e.map(d=>[d.id,d])),i=n.map(d=>o.get(d)).filter(d=>!!d).slice(0,PN),l=new Set(i.map(d=>d.id)),u=[];i.length&&u.push(ow("recent",i.map(d=>({item:d,hits:[]}))));for(const d of aw){if(d==="recent")continue;let f=e.filter(p=>p.section===d&&!p.queryOnly&&!l.has(p.id));d==="sessions"&&(f=f.slice(0,hQ)),f.length&&u.push(ow(d,f.map(p=>({item:p,hits:[]}))))}return u}const a=new Map;for(const o of e){const i=cQ(s,o.title),l=uQ(s,o.keywords),u=Math.max((i==null?void 0:i.score)??0,l);if(u<=0)continue;const d=i&&i.score>=l?i.hits:[],f=a.get(o.section)??[];f.push({item:o,hits:d,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,dQ),best:i[0].score})).sort((o,i)=>i.best-o.best||aw.indexOf(o.key)-aw.indexOf(i.key)).map(({key:o,list:i})=>ow(o,i.map(({item:l,hits:u})=>({item:l,hits:u}))))}function ow(e,t){return{section:e,title:lQ[e],items:t}}function pQ(e){return e.flatMap(t=>t.items)}function uA(e,t,n){return t<=0?-1:e<0?n>0?0:t-1:((e+n)%t+t)%t}const OD="agent-dag.quickOpenRecent";function PD(){try{const e=JSON.parse(nt(OD)??"[]");return Array.isArray(e)?e.filter(t=>typeof t=="string").slice(0,PN):[]}catch{return[]}}function mQ(e,t){return[t,...e.filter(n=>n!==t)].slice(0,PN)}function gQ(e){st(OD,JSON.stringify(mQ(PD(),e)))}function DD(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 yQ(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 FD=()=>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"})]}),wQ=()=>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"})})}),BD=()=>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"})]}),xQ=()=>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"})]}),vQ=()=>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"})]}),bQ=()=>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"})]}),kQ=()=>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"})]}),jQ=({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"})]}),NQ=()=>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"})]}),SQ=()=>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"})]}),CQ=()=>r.jsx(jt,{children:r.jsx("path",{d:"M4.6 2.9v8.2L11.1 7Z"})}),_Q=()=>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"})]}),EQ=()=>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"})]}),TQ=()=>r.jsx(jt,{children:r.jsx("path",{d:"M2 5h10v7H2z M4 5l6-3 M4 8h3 M9 8h1 M4 10h1 M8 10h2"})}),AQ=()=>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"})]}),qD=()=>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"})]}),RQ=()=>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"})]}),MQ=()=>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"})]}),$Q=()=>r.jsxs(jt,{children:[r.jsx("circle",{cx:"7",cy:"7",r:"5"}),r.jsx("path",{d:"M7 3.8V7l2.2 1.4"})]}),LQ=()=>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"})}),IQ=()=>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"})}),OQ=()=>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"})}),UD=()=>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"})]}),PQ=()=>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"})]}),DQ=()=>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"})]}),FQ=()=>r.jsx(jt,{children:r.jsx("path",{d:"M5 3v8M9 3v8"})}),BQ=()=>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"})}),qQ=120,dA=5;function UQ({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 WQ({items:e,onClose:t,onRun:n}){const[s,a]=g.useState(""),[o]=g.useState(PD),[i,l]=g.useState(null),[u,d]=g.useState(!1),f=g.useRef(null),p=g.useRef(null),m=g.useRef(!1),w=g.useRef(null),x=g.useCallback(()=>d(!0),[]),b=g.useCallback(()=>{m.current||(m.current=!0,t())},[t]),j=gt(x,{focusRef:f}),k=wt(x),v=g.useMemo(()=>fQ(e,s,o),[e,s,o]),S=g.useMemo(()=>pQ(v),[v]),C=S.findIndex(M=>M.item.id===i),_=S.length?C>=0?C:0:-1,R=S[_];g.useEffect(()=>{if(!u)return;const M=setTimeout(b,qQ+60);return()=>clearTimeout(M)},[u,b]),g.useEffect(()=>{const M=co(to()),B=T=>{DD(T,M)&&(T.preventDefault(),T.stopPropagation(),x())};return window.addEventListener("keydown",B,!0),()=>window.removeEventListener("keydown",B,!0)},[x]),g.useLayoutEffect(()=>{var T;const M=p.current;if(!M)return;if(_<=0){M.scrollTop=0;return}const B=M.querySelector(`[data-index="${_}"]`);B&&(B.dataset.first==="true"&&((T=B.closest(".qo-group"))==null||T.scrollIntoView({block:"nearest"})),B.scrollIntoView({block:"nearest"}))},[_,S]);const A=M=>{!M||u||(gQ(M.item.id),n(M.item))},I=M=>{const B=S[M];B&&l(B.item.id)},$=M=>{if(M.nativeEvent.isComposing)return;const B=M.ctrlKey&&!M.metaKey&&!M.altKey;let T=null;if(M.key==="ArrowDown"||B&&(M.key==="n"||M.key==="j"))T=uA(_,S.length,1);else if(M.key==="ArrowUp"||B&&(M.key==="p"||M.key==="k"))T=uA(_,S.length,-1);else if(M.key==="PageDown")T=Math.min(S.length-1,_+dA);else if(M.key==="PageUp")T=Math.max(0,_-dA);else if(M.key==="Enter"){M.preventDefault(),A(R);return}T!==null&&(M.preventDefault(),I(T))},U=(M,B)=>{const T={x:M.clientX,y:M.clientY},P=w.current;w.current=T,!(P&&P.x===T.x&&P.y===T.y)&&B!==(R==null?void 0:R.item.id)&&l(B)};let F=-1;return r.jsx("div",{className:`modal-backdrop qo-backdrop${u?" closing":""}`,...k,role:"presentation",children:r.jsxs("div",{ref:j,className:`qo${u?" closing":""}`,onClick:M=>M.stopPropagation(),onAnimationEnd:M=>{u&&M.target===M.currentTarget&&b()},role:"dialog","aria-modal":"true","aria-label":"Quick open",children:[r.jsxs("div",{className:"qo-field",children:[r.jsx(UD,{}),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:M=>{a(M.target.value),l(null)},onKeyDown:$,autoComplete:"off",autoCorrect:"off",autoCapitalize:"off",spellCheck:!1}),r.jsx("button",{type:"button",className:"qo-esc",onClick:x,"aria-label":"Close",children:"esc"})]}),r.jsxs("div",{ref:p,className:"qo-list",id:"qo-list",role:"listbox","aria-label":"Results",tabIndex:-1,onMouseDown:M=>M.preventDefault(),children:[v.map(M=>r.jsxs("div",{className:"qo-group",role:"group","aria-labelledby":`qo-cap-${M.section}`,children:[r.jsx("div",{className:"qo-caption",id:`qo-cap-${M.section}`,role:"presentation",children:M.title}),M.items.map((B,T)=>{F++;const P=F,{item:q}=B;return r.jsxs("div",{id:`qo-opt-${P}`,className:"qo-row",role:"option","aria-selected":P===_,"data-index":P,"data-first":T===0?"true":void 0,onMouseMove:K=>U(K,q.id),onClick:()=>A(B),children:[r.jsx("span",{className:"qo-icon","aria-hidden":!0,children:q.tone?r.jsx("span",{className:`qo-dot ${q.tone}`}):q.glyph}),r.jsxs("span",{className:"qo-text",children:[r.jsx("span",{className:"qo-title",children:r.jsx(UQ,{text:q.title,hits:B.hits})}),q.subtitle&&r.jsx("span",{className:"qo-sub",children:q.subtitle})]}),q.keyCap&&r.jsx("kbd",{className:"qo-key",children:q.keyCap}),r.jsx("span",{className:"qo-tag",children:q.tag})]},q.id)})]},M.section)),S.length===0&&r.jsxs("div",{className:"qo-empty",children:[r.jsxs("p",{className:"qo-empty-title",children:["Nothing matches “",s.trim(),"”"]}),r.jsx("p",{className:"qo-empty-note",children:"Try the name of a panel, a session, a setting or a theme."})]})]}),r.jsxs("div",{className:"qo-foot","aria-hidden":!0,children:[r.jsx("span",{className:"qo-foot-count",children:S.length===1?"1 result":`${S.length} results`}),r.jsxs("span",{className:"qo-foot-keys",children:[R&&r.jsxs("span",{className:"qo-foot-act",children:[R.item.verb," ",r.jsx("kbd",{children:"↵"})]}),r.jsxs("span",{className:"qo-foot-act",children:["Move ",r.jsx("kbd",{children:"↑"}),r.jsx("kbd",{children:"↓"})]})]})]}),r.jsx("span",{className:"qo-live",role:"status",children:s.trim()?S.length===1?"1 result":`${S.length} results`:""})]})})}function HQ(e,t,n){if(n<=0||am(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 ys=4,Gt=8;function pm(e,t,n){const s=n.width-Gt-(e.right+ys),a=e.left-ys-Gt,o=t.width<=s||s>=a?"right":"left",i=o==="right"?e.right+ys:e.left-ys-t.width,l=n.height-Gt*2,u=t.height<=l,d=u?t.height:Math.max(0,l),f=Math.max(Gt,Math.min(e.top,n.height-Gt-d)),p=Math.max(Gt,Math.min(i,n.width-Gt-t.width));return{top:f,left:p,side:o,maxHeight:u?null:d}}function zQ(e,t,n,s=0){const a=n.width-Gt-e.right-ys,o=e.left-ys-Gt;if(t.width<=Math.max(a,o))return pm(e,t,n);const i=Math.max(0,Math.min(e.top-ys,n.height-Gt)-Gt);if(i<=0||i<Math.min(t.height,s))return null;const l=Math.min(t.height,i);return{side:"above",top:Math.max(Gt,Math.min(e.top-ys,n.height-Gt)-l),left:Math.max(Gt,Math.min(e.right-t.width,n.width-Gt-t.width)),maxHeight:l<t.height?l:null}}function WD(e,t,n,s="end"){const a=n.height-Gt-(e.bottom+ys),o=e.top-ys-Gt,i=t.height<=a||a>=o?"below":"above",l=i==="below"?a:o,u=t.height<=l,d=u?t.height:Math.max(0,l),f=i==="below"?e.bottom+ys:e.top-ys-d,p=Math.max(Gt,Math.min(s==="start"?e.left:e.right-t.width,n.width-Gt-t.width));return{top:Math.max(Gt,f),left:p,side:i,maxHeight:u?null:d}}function VQ(e,t,n){return!(!e||t!=null&&t.contains(e)||n!=null&&n.contains(e))}function GQ(e,t,n){const s=g.useRef(t);s.current=t;const a=g.useRef(n);a.current=n,g.useEffect(()=>{const o=i=>{VQ(i.target,e.current,s.current())&&a.current()};return window.addEventListener("pointerdown",o,!0),()=>window.removeEventListener("pointerdown",o,!0)},[e])}const HD='[role="menuitem"]';function hA(e){return e?Array.from(e.querySelectorAll(HD)).filter(t=>!t.disabled):[]}function ac({anchorId:e,align:t="end",boundaryId:n,portalRootId:s,id:a,className:o,role:i,labelledBy:l,start:u="first",focusRef:d,fallbackFocus:f,onClose:p,children:m}){const w=g.useRef(p);w.current=p;const x=g.useRef(f);x.current=f;const b=gt(()=>{var C;(C=document.getElementById(e))==null||C.focus(),w.current()},{popover:!0,focusRef:d}),j=g.useCallback(()=>{var $,U,F;const C=b.current;if(!C)return;const _=document.getElementById(e);if(!_){w.current();return}if(_.getClientRects().length===0){C.contains(document.activeElement)&&((U=($=x.current)==null?void 0:$.call(x))==null||U.focus()),w.current();return}const R=_.getBoundingClientRect(),A=n?(F=document.getElementById(n))==null?void 0:F.getBoundingClientRect():null;if(A&&(R.bottom<=A.top||R.top>=A.bottom)){C.contains(document.activeElement)&&_.focus({preventScroll:!0}),w.current();return}C.style.maxHeight="";const I=WD(R,{width:C.offsetWidth,height:C.offsetHeight},{width:window.innerWidth,height:window.innerHeight},t);C.style.top=`${I.top}px`,C.style.left=`${I.left}px`,C.style.maxHeight=I.maxHeight==null?"":`${I.maxHeight}px`,C.dataset.side=I.side},[e,t,n,b]);g.useLayoutEffect(()=>{j()}),g.useEffect(()=>{const C=_=>{var R;(R=b.current)!=null&&R.contains(_.target)||j()};return window.addEventListener("scroll",C,!0),window.addEventListener("resize",j),()=>{window.removeEventListener("scroll",C,!0),window.removeEventListener("resize",j)}},[j,b]),GQ(b,()=>document.getElementById(e),p),g.useEffect(()=>{var _;if(i!=="menu")return;const C=hA(b.current);(_=u==="last"?C[C.length-1]:C[0])==null||_.focus()},[]);const k=C=>{var _;if(i==="menu"&&C.key==="Tab"){C.stopPropagation(),(_=document.getElementById(e))==null||_.focus(),C.shiftKey&&C.preventDefault(),w.current();return}if(i==="menu"){const R=hA(b.current),A=HQ(C,R.indexOf(document.activeElement),R.length);A.kind==="focus"&&(C.preventDefault(),R[A.index].focus())}C.key.length===1&&C.stopPropagation()},v=C=>{C.target.closest("button, input, select, textarea, code")||C.preventDefault()},S=C=>{if(i!=="menu"||C.pointerType==="touch")return;const _=C.target.closest(HD);_&&!_.disabled&&document.activeElement!==_&&_.focus({preventScroll:!0})};return vt.createPortal(r.jsx("div",{ref:b,id:a,className:`anchored-popover${o?` ${o}`:""}`,role:i,"aria-labelledby":l,onKeyDown:k,onMouseDown:v,onPointerMove:S,children:m}),(s?document.getElementById(s):null)??document.body)}const KQ=450,YQ=400,XQ=100,cf=8,ZQ={right:"hint hint-right",left:"hint hint-left",below:"hint hint-below",above:"hint hint-above"},lu=8;let Jr=null,fA=-1/0;function JQ(e,t,n){return n||e-t<YQ}function QQ(e,t,n,s,a=null){const o=Math.max(lu,((a==null?void 0:a.left)??0)+lu),i=Math.min(window.innerWidth,(a==null?void 0:a.right)??1/0)-n-lu,l=p=>Math.max(o,Math.min(p,i)),u=p=>Math.max(lu,Math.min(p,window.innerHeight-s-lu)),d=t.top+t.height/2-s/2,f=t.left+t.width/2-n/2;return e==="right"?{left:t.right+cf,top:u(d)}:e==="left"?{left:t.left-cf-n,top:u(d)}:e==="above"?{left:l(f),top:t.top-cf-s}:{left:l(f),top:t.bottom+cf}}const eee={chrome:"",dialog:" hint-over-dialog"};function oc(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&&(fA=performance.now()),null))},[]),u=g.useCallback((w,x,b)=>{window.clearTimeout(a.current),window.clearTimeout(o.current);const j=Jr!==null,k=JQ(performance.now(),fA,j),v=()=>{var C;Jr&&Jr!==l&&Jr(),Jr=l;const S=t==="dialog"?((C=w.closest('[role="dialog"]'))==null?void 0:C.getBoundingClientRect())??null:null;s({spec:x,box:w.getBoundingClientRect(),within:S,instant:k})};b||k?v():a.current=window.setTimeout(v,KQ)},[l,t]),d=g.useCallback(()=>{window.clearTimeout(a.current),window.clearTimeout(o.current),o.current=window.setTimeout(l,XQ)},[l]),f=n!==null;g.useEffect(()=>{if(!f)return;const w=ln.push(l,0,"popover");return window.addEventListener("resize",l),window.addEventListener("scroll",l,!0),()=>{w(),window.removeEventListener("resize",l),window.removeEventListener("scroll",l,!0),Jr===l&&(Jr=null)}},[f,l]),g.useEffect(()=>()=>{window.clearTimeout(a.current),window.clearTimeout(o.current),Jr===l&&(Jr=null)},[l]),g.useLayoutEffect(()=>{const w=i.current;if(!w||!n)return;const{width:x,height:b}=w.getBoundingClientRect(),j=QQ(e,n.box,x,b,n.within);w.style.left=`${j.left}px`,w.style.top=`${j.top}px`,w.style.visibility="visible"},[n,e]);const p=g.useCallback(w=>({onPointerEnter:x=>{w&&x.pointerType==="mouse"&&u(x.currentTarget,w,!1)},onPointerLeave:d,onPointerDown:l,onFocus:x=>{w&&x.currentTarget.matches(":focus-visible")&&u(x.currentTarget,w,!0)},onBlur:l}),[u,d,l]),m=n&&vt.createPortal(r.jsxs("span",{ref:i,className:ZQ[e]+eee[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 mm="(max-width: 640px)",tee=600,nee=588,see=40;function ree(e){if(typeof window>"u")return!1;const t=window.innerWidth;return t>0?t-2*see-e-nee<tee:!1}function z1(){if(typeof window>"u"||typeof window.matchMedia!="function")return!1;try{return window.matchMedia(mm).matches}catch{return!1}}function DN(e,t){return e&&(t||!e.single)?e:void 0}function aee(e,t,n){var i;const s=(i=DN(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 zD={stripe:"rail-btn rail-btn-stripe",dock:"rail-btn rail-btn-dock",bar:"rail-btn rail-btn-bar"},oee={left:"edge-rail edge-rail-left",right:"edge-rail edge-rail-right"},iee={vertical:"ArrowDown",horizontal:"ArrowRight"},lee={vertical:"ArrowUp",horizontal:"ArrowLeft"};function VD(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 d=-1;i.key===iee[t]?d=(u+1)%l.length:i.key===lee[t]?d=(u-1+l.length)%l.length:i.key==="Home"?d=0:i.key==="End"&&(d=l.length-1),!(d<0)&&(i.preventDefault(),i.stopPropagation(),s(d),l[d].focus())},[t]);return{active:a,setCurrent:s,onKeyDown:o}}let gl=null;function FN(e){g.useLayoutEffect(()=>{var a,o;gl&&document.activeElement===document.body&&((o=(a=e.current)==null?void 0:a.querySelector(`[data-rail-item="${gl}"]`))==null||o.focus()),gl=null;const t=i=>{var u;const l=(u=i.target.dataset)==null?void 0:u.railItem;l&&(gl=l)},n=i=>{var l;(l=e.current)!=null&&l.contains(i.relatedTarget)||(gl=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 BN({item:e,index:t,tabbable:n,onFocusIndex:s,hint:a,variant:o}){var d;const i=An(),l=a.bind(aee(e,i,o!=="stripe")),u=e.kind==="panel";return r.jsxs("button",{ref:e.buttonRef,type:"button","data-rail-item":e.id,className:zD[o],tabIndex:o==="bar"?void 0:n?0:-1,"aria-label":e.ariaLabel,"aria-keyshortcuts":(d=DN(e.key,i))==null?void 0:d.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 pA({side:e,label:t,groups:n}){const s=oc(e==="left"?"right":"left"),a=n.filter(u=>u.length>0),o=VD(a.flat().length,"vertical"),i=g.useRef(null);FN(i);let l=0;return r.jsxs("div",{ref:i,className:oee[e],role:"toolbar","aria-label":t,"aria-orientation":"vertical",onKeyDown:o.onKeyDown,children:[a.map(u=>{const d=u.length>1?u[0].group:void 0;return r.jsx("div",{className:"rail-group",role:d?"group":void 0,"aria-label":d,"data-rail-group":u[0].id==="explore-integrations"?"explore":void 0,children:u.map(f=>{const p=l++;return r.jsx(BN,{item:f,index:p,tabbable:p===o.active,onFocusIndex:o.setCurrent,hint:s,variant:"stripe"},f.id)})},u[0].id)}),s.node]})}const uf="dock-more",mA="dock-more-menu";function cee({items:e,tabbable:t,onFocusIndex:n,index:s}){const[a,o]=g.useState(null),i=a!==null,l=e.reduce((d,f)=>d+(f.badge??0),0),u=d=>()=>{var f;(f=document.getElementById(uf))==null||f.focus(),o(null),d.onPress()};return r.jsxs(r.Fragment,{children:[r.jsxs("button",{id:uf,type:"button","data-rail-item":"more",className:zD.dock,tabIndex:t?0:-1,"aria-label":`More: ${e.map(d=>d.ariaLabel).join(", ")}`,"aria-haspopup":"menu","aria-expanded":i,"aria-controls":i?mA:void 0,onFocus:()=>n(s),onKeyDown:d=>{d.key!=="ArrowDown"&&d.key!=="ArrowUp"||(d.preventDefault(),o(d.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(ac,{anchorId:uf,id:mA,className:"ap-pop",role:"menu",labelledBy:uf,start:a,onClose:()=>o(null),children:e.map(d=>r.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item","data-rail-item":d.id,onFocus:()=>{gl=d.id},onClick:u(d),children:d.badge?`${d.menu??d.label} · ${d.badge} unread`:d.menu??d.label},d.id))})]})}function uee({items:e,more:t}){const n=oc("above"),s=VD(e.length+1,"horizontal"),a=g.useRef(null);return FN(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(BN,{item:o,index:i,tabbable:i===s.active,onFocusIndex:s.setCurrent,hint:n,variant:"dock"},o.id)),r.jsx(cee,{items:t,index:e.length,tabbable:s.active===e.length,onFocusIndex:s.setCurrent}),n.node]})}function dee({items:e,side:t="below"}){const n=oc(t),s=g.useRef(null);return FN(s),r.jsxs("div",{ref:s,className:"utility-run",children:[e.map((a,o)=>r.jsx(BN,{item:a,index:o,tabbable:!0,onFocusIndex:hee,hint:n,variant:"bar"},a.id)),n.node]})}function hee(){}const ad=[{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 fee(e,t,n=!0){const s=new Set;return e==="none"&&t!=="integrations"&&s.add("integrations"),!n&&t!=="claude"&&s.add("claude"),s.size?ad.filter(a=>!s.has(a.id)):ad}const gA="settings-tab-";function pee(e,t){return e!=null&&e.startsWith(gA)?e===`${gA}${t}`?null:t:null}const mee={open:!1,section:"general"};function gee(e,t,n){const s={open:!0,section:t??e.section};return n?{...s,landOn:n}:s}function Ba(e,t){return()=>{e(),t()}}function yee(e){return e.key===","&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey}function wee(e){return co(e)?"⌘,":"Ctrl+,"}function xee(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 vee="https://code.claude.com/docs/en/settings-reference",GD=[{id:"sessions",title:"Your sessions"},{id:"memory",title:"Memory and history"},{id:"git",title:"Git"},{id:"terminal",title:"Terminal"},{id:"updates",title:"Updates"}],KD=[{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 yA(e){return e===3650?"10 years":e===365?"1 year":e===1?"1 day":`${e} days`}const YD="agent-dag.character",Ff=[{id:"deck",name:"Deck companion"},{id:"fox",name:"Fox"},{id:"penguin",name:"Penguin"}];function bee(e){return e==="fox"||e==="penguin"?e:"deck"}function kee(){return bee(nt(YD))}const jee="With no deck tab open, get a notification wherever a sound would have played.",Nee="With the ccdeck window closed, get a notification wherever a sound would have played.";function See(e){return e?Nee:jee}const Cee="Held off for this run — the deck was started with alerts disabled. Your choice is saved for the next start.",XD=[{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"}],_ee="For the Claude and Codex accounts you're on, whether or not the deck is open.",Eee="Held off for this run too.",wA="Get notified when you're away from this tab.";function Tee(e){switch(e){case"granted":return{status:"Enabled",ask:!1,ok:!0,note:wA};case"default":return{status:null,ask:!0,ok:!1,note:wA};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 Aee=1024*1024,xA=5,ZD=.8,V1=24,Ree="agent-dag.soundCustom.done",Mee="agent-dag.soundCustom.needs-input",$u={done:Ree,"needs-input":Mee};function od(e){if(e.kind!=="audio")return e;const{bytes:t,...n}=e;return n}function vA(e){return!e||!/^[a-zA-Z0-9._-]{1,96}$/.test(e)?null:e}function $ee(e){return{done:vA(e($u.done)),"needs-input":vA(e($u["needs-input"]))}}function Lee(e,t){return{done:e.done===t?null:e.done,"needs-input":e["needs-input"]===t?null:e["needs-input"]}}function Iee(e){return e.done&&e.done===e["needs-input"]?e.done:null}const Oee={wav:"audio/wav",wave:"audio/wav",mp3:"audio/mpeg",ogg:"audio/ogg",oga:"audio/ogg",webm:"audio/webm",m4a:"audio/mp4",mp4:"audio/mp4"},JD=new Set(["audio/wav","audio/x-wav","audio/mpeg","audio/mp3","audio/ogg","audio/webm","audio/mp4"]);function QD(e,t){const n=t.toLowerCase().split(";")[0].trim();if(JD.has(n))return n;const s=e.toLowerCase().split(".").pop()??"";return Oee[s]??n}function bA(e,t){const n=QD(e.name,e.type);if(!JD.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>Aee)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>xA)return`Audio must be ${xA} seconds or shorter.`}return null}function G1(e){return e>=V1?`There are already ${V1} custom sounds. Delete one first.`:null}function Pee(e,t){const n=e.indexOf(t);return n<0?null:e[n+1]??e[n-1]??null}function Dee(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,ZD/t)}function e5(){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 Fee(e,t,n=e5()){var d;const s=((d=e.name)==null?void 0:d.trim())||"Custom sound",a=bA({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=bA({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:QD(s,e.type),duration:i.duration,normalizationGain:Dee(u),bytes:o}}function Bee(e,t=e5()){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 qee="ccdeck-notification-audio",Uee=2,Xs="assets",kr="summaries";function jd(){return typeof window<"u"?window.ccdeckNotificationAudio??null:null}function Wee(){return new Promise((e,t)=>{const n=indexedDB.open(qee,Uee);n.onupgradeneeded=s=>{const a=n.result,o=a.objectStoreNames.contains(Xs)?n.transaction.objectStore(Xs):a.createObjectStore(Xs,{keyPath:"id"});if(a.objectStoreNames.contains(kr))return;const i=a.createObjectStore(kr,{keyPath:"id"});if(s.oldVersion<1)return;const l=o.openCursor();l.onsuccess=()=>{const u=l.result;u&&(i.put(od(u.value)),u.continue())}},n.onsuccess=()=>e(n.result),n.onerror=()=>t(n.error??new Error("Could not open local audio storage."))})}async function Nd(e,t,n){const s=await Wee();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 Hee(){const e=jd();return e?e.list():typeof indexedDB>"u"?[]:await Nd([kr],"readonly",t=>t.objectStore(kr).getAll())??[]}async function zee(e){const t=jd();return t?t.get(e):typeof indexedDB>"u"?null:await Nd([Xs],"readonly",n=>n.objectStore(Xs).get(e))??null}async function kA(e){const t=jd();if(t){await t.put(e);return}if(typeof indexedDB>"u")throw new Error("Local audio storage is unavailable in this browser.");await Nd([Xs,kr],"readwrite",n=>{n.objectStore(Xs).put(e),n.objectStore(kr).put(od(e))})}async function Vee(e,t){const n=jd();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 Nd([Xs,kr],"readwrite",s=>{const a=s.objectStore(Xs),o=a.get(e);o.onsuccess=()=>{const i=o.result;if(!i)return;const l={...i,name:t};a.put(l),s.objectStore(kr).put(od(l))}})}async function Gee(e){const t=jd();if(t){await t.remove(e);return}typeof indexedDB>"u"||await Nd([Xs,kr],"readwrite",n=>{n.objectStore(Xs).delete(e),n.objectStore(kr).delete(e)})}const Lu=["done","needs-input"],Kee=[{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}]}],Yee=[{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}]}],qN={done:Kee,"needs-input":Yee},Qn="two";function K1(e,t){const n=qN[e];return n.find(s=>s.id===t)??n.find(s=>s.id===Qn)??n[0]}function t5(e,t){return qN[e].some(s=>s.id===t)?t:Qn}K1("done",Qn).notes,K1("needs-input",Qn).notes;const jA=.04,n5=.24,Bf=0,yp=100,UN=5,pi=50;function gm(e,t=UN){if(!Number.isFinite(e))return pi;const n=Math.round(e/t)*t;return Math.min(yp,Math.max(Bf,n))}function s5(e,t=UN){if(e==null)return pi;const n=e.trim();return/^-?\d+(\.\d+)?$/.test(n)?gm(Number(n),t):pi}function WN(e){const t=gm(e),n=jA+(n5-jA)*(t/yp);return Math.round(n*1e4)/1e4}function Xee(e,t){const n=t.trim,s=typeof n=="number"&&Number.isFinite(n)&&n>0&&n<=1?n:1;return Math.round(WN(e)*s*1e4)/1e4}const Zee=.012,NA=1e-4;function Jee(e){return Math.min(1,WN(e)/n5)}function Qee(e,t){const n=e*(WN(t)/ZD);return Math.max(1e-4,n)}const ete=160,tte="agent-dag.soundLevel.done",nte="agent-dag.soundLevel.needs-input",ste="agent-dag.soundFigure.done",rte="agent-dag.soundFigure.needs-input",r5={done:tte,"needs-input":nte},wp={done:ste,"needs-input":rte},SA={done:{level:pi,figure:Qn},"needs-input":{level:pi,figure:Qn}};function ate(e){const t=n=>({level:s5(e(r5[n])),figure:t5(n,e(wp[n]))});return{done:t("done"),"needs-input":t("needs-input")}}function ote(e,t){return(e??SA)[t]??SA[t]}const ite={Stop:"done",Notification:"needs-input"};function lte(e,t){var s;if(t)return null;const n=(s=e==null?void 0:e.payload)==null?void 0:s.hook_event_name;return typeof n!="string"?null:Kt(ite,n)??null}const ic={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"}},pr=Object.keys(ic);function cte(e){return pr[(pr.indexOf(e)+1)%pr.length]}const a5="agent-dag.theme";function ute(e,t=!1){return typeof e=="string"&&Object.hasOwn(ic,e)?e:"rider-black"}function dte(){return ute(nt(a5))}const o5="section:";function ym(e){return e.id.startsWith(o5)}const hte={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"]},fte={done:"Turn finished","needs-input":"Claude is asking"},pte={done:["done","complete","finished","end of turn","volume","preview","chime","tone"],"needs-input":["question","needs input","permission","waiting","volume","preview","chime","tone"]},mte={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"]},HN=e=>{var t;return((t=ad.find(n=>n.id===e))==null?void 0:t.label)??e};function gte(e){return{id:`${o5}${e}`,section:e,label:HN(e),keywords:hte[e],...e==="claude"?{claudeOnly:!0}:{}}}function yte(){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"]},...pr.map(t=>({id:`theme-${t}`,section:"appearance",group:"Theme",label:ic[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",...Ff.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"]},...XD.map(({kind:t,label:n})=>({id:t,section:"notifications",group:"Accounts",label:n,keywords:mte[t]}))],sounds:[{id:"play-sounds",section:"sounds",label:"Play sounds",keywords:["sound","mute","unmute","silence","quiet"]},...Lu.map(t=>({id:`tone-${t}`,section:"sounds",label:fte[t],keywords:pte[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:[...KD.map(t=>{var n;return{id:`claude-${t.id}`,claudeOnly:!0,section:"claude",group:(n=GD.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 ad.flatMap(({id:t})=>[gte(t),...e[t]])}const Y1=yte();function i5(e,t="all",n){return e&&t==="all"&&!n?Y1:Y1.filter(s=>(e||!s.claudeOnly)&&(!n||!s.id.startsWith("integration-")||n.has(s.id.slice(12)))&&(s.section!=="integrations"||t==="all"||t==="connections"&&(ym(s)||s.id==="integrations-connections")))}function zN(e){if(ym(e))return"Section";const t=HN(e.section);return e.group&&e.group!==e.label?`${t} › ${e.group}`:t}function wte(e){return`${e.label}, ${zN(e).replace(/ › /g,", ")}`}function ju(e){return e.normalize("NFD").replace(/[̀-ͯ]/g,"").toLowerCase().replace(/\s+/g," ").trim()}function df(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 xte(e,t){const n=ju(e.label);if(n.startsWith(t))return 0;if(df(n,t))return 1;const s=e.keywords.map(ju);if(s.some(i=>df(i,t)))return 2;const a=[ju(HN(e.section)),...e.group?[ju(e.group)]:[]];if(a.some(i=>df(i,t)))return 3;const o=t.split(" ");if(o.length>1){const i=[n,...s,...a];if(o.every(l=>i.some(u=>df(u,l))))return 4}return null}const vte=12;function bte(e,t=Y1){const n=ju(e);return n?t.map((s,a)=>({entry:s,at:a,score:xte(s,n)})).filter(s=>s.score!==null).sort((s,a)=>s.score-a.score||s.at-a.at).slice(0,vte).map(s=>s.entry):[]}function l5(e,t){const n=t.trim();return e===0?`No setting matches “${n}”.`:e===1?`1 setting matches “${n}”`:`${e} settings match “${n}”`}function kte(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 wm({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 jte={"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"]},Nte=new Set(["accounts","browser-watch","radar-open","tour","feedback"]);function Ste(e,t){var a;const n=r.jsx(wm,{section:e.section});if(ym(e))return{id:`settings:${e.id}`,section:"settings",title:e.label,subtitle:(a=ad.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=zN(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 Cte(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,...jte[e.id]??[],...e.detail?[e.detail]:[]],tag:n?e.open?"Shown":"Panel":"Dialog",verb:n?e.open?"Hide panel":"Show panel":"Open",keyCap:(a=DN(e.key,t))==null?void 0:a.cap,glyph:e.glyph,run:e.onPress}}function _te(e,t){const n=e.cwdBasename&&e.cwdBasename!==e.label?` · ${e.cwdBasename}`:"";return e.waiting&&Tn(e.waiting)?{line:`Needs you · ${rd(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 Ete(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}=_te(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(Cte(a,e.singleKeys));for(const a of e.settings)a.id.startsWith("theme-")||Nte.has(a.id)||s.push(Ste(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(PQ,{}),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(DQ,{}),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(FQ,{}),run:e.togglePause},{id:"action:keys",section:"actions",title:"Keyboard shortcuts",keywords:["keys","help","?"],tag:"Action",verb:"Open",keyCap:t("?"),glyph:r.jsx(wm,{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(CQ,{}),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(BQ,{}),run:e.clear});for(const a of pr){const o=ic[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`:""}`},Tte=e=>e<1024?`${e} B`:e<1048576?`${(e/1024).toLocaleString(void 0,{maximumFractionDigits:1})} KB`:`${(e/1048576).toLocaleString(void 0,{maximumFractionDigits:1})} MB`,Ate=e=>new Date(e).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"});async function xp(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 CA={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 Yl(e){if(Object.hasOwn(CA,e))return CA[e];const t=/^(npm|pnpm|yarn|bun) run (.+)$/.exec(e);if(t)return`Runs the “${t[2]}” script`;const n=c5(e);return n?`From the ${n.server} MCP server`:null}function c5(e){const t=/^mcp__(.+?)__(.+)$/.exec(e);return t?{server:t[1],tool:t[2]}:null}const no=e=>{var t;return((t=c5(e))==null?void 0:t.tool)??e},Rte=[{id:"calls",label:"Most used"},{id:"time",label:"Most time"},{id:"slowest",label:"Slowest"},{id:"failed",label:"Failures"}];function vp(e,t){return t==="calls"?e.calls:t==="time"?e.totalMs:t==="slowest"?e.medianMs:e.failed}const Mte=(e,t)=>{const n=t.trim().toLowerCase();return!n||e.operation.toLowerCase().includes(n)||(Yl(e.operation)??"").toLowerCase().includes(n)};function iw(e,t,n=""){return e.filter(s=>Mte(s,n)).sort((s,a)=>{const o=vp(s,t),i=vp(a,t);return o!==i?o===null?1:i===null?-1:i-o:a.calls-s.calls||s.operation.localeCompare(a.operation)})}const yi=(e,t)=>{const n=e/t*100;return`${n>0&&n<1?"<1":Math.round(n)}%`},xm=e=>e.failed>0&&e.completed>0?yi(e.failed,e.completed):null;function $te(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")}, ${yi(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 (${xm(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"}`,id={1:"24 hours",7:"7 days",30:"30 days",90:"90 days"},Lte={all:"your agents",claude:"Claude",codex:"Codex"};function Ite(e,t,n){return{lead:`In the last ${id[n]??`${n} days`}, ${Lte[t]} made`,calls:kt(e.total,"tool call"),time:e.totalMs?bt(e.totalMs):null,failed:e.failed,failedShare:e.failed&&e.completed?yi(e.failed,e.completed):null}}const ra=e=>new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric"});function u5(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 X1=e=>new Date(e).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"});function vm(e,t=Date.now()){const n=u5(e,t);return n==="Today"||n==="Yesterday"?`${n} ${X1(e)}`:`${n}, ${X1(e)}`}function lc(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 Ote({keyboard:e,onClose:t,children:n}){const s=g.useRef(null),a=gt(t,{focusRef:s}),o=wt(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 Pte({keyboard:e,itemKey:t,onClose:n,children:s}){const a=g.useRef(null),o=g.useRef(n);return o.current=n,g.useEffect(()=>ln.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,d;if(window.matchMedia("(prefers-reduced-motion: reduce)").matches)return;const i=(u=a.current)==null?void 0:u.querySelector(".ta-inspector"),l=(d=i==null?void 0:i.animate)==null?void 0:d.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 d5(e){return lc("(max-width: 700px)")?r.jsx(Ote,{...e}):r.jsx(Pte,{...e})}const Ga=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString(void 0,{timeZone:"UTC",month:"short",day:"numeric"});function Dte(e,t){return e.status==="outside-history"?`${Ga(e.date)} · before recording started`:e.calls?`${Ga(e.date)} · ${kt(e.calls,t)}${e.medianMs!=null?` · usually ${bt(e.medianMs)}`:""}`:`${Ga(e.date)} · no ${t}s`}function h5({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 Fte({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),d=`${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:[d," per day"]}),r.jsx("div",{className:"ta-history-bars",role:"img","aria-label":`${d} per day from ${Ga(n[0].date)} to ${Ga(n.at(-1).date)}. The busiest day was ${Ga(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:Ga(n[0].date)}),r.jsx("span",{children:Ga(n.at(-1).date)})]}),r.jsx("p",{className:"ta-note ta-history-day","aria-live":"polite",children:Dte(i,t)})]})}function f5(){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 Iu=({width:e="3ch"})=>r.jsx("i",{className:"ta-skel",style:{width:e},"aria-hidden":"true"}),p5=({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))}),Bte={success:"Done",failed:"Failed",unmatched:"No result"},qte=({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 Ute(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 Wte({row:e,details:t,loading:n,pending:s=!1,charted:a=!0,error:o,kind:i,setKind:l,onClose:u,onShowSkills:d}){const f=Yl(e.operation),p=(t==null?void 0:t[i])??[],m=Date.now(),w=xm(e),x=(n||s)&&!t,b=j=>s?r.jsx(Iu,{}):j;return r.jsxs("section",{className:"ta-inspector","aria-label":`${no(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:no(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(f5,{})})]}),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:b(e.calls.toLocaleString())})]}),r.jsxs("div",{children:[r.jsx("dt",{children:"Total time"}),r.jsx("dd",{children:b(bt(e.totalMs))})]}),r.jsxs("div",{children:[r.jsx("dt",{children:"Usually"}),r.jsx("dd",{children:b(bt(e.medianMs))})]}),r.jsxs("div",{children:[r.jsx("dt",{children:"Failed"}),r.jsx("dd",{"data-bad":!s&&e.failed>0||void 0,children:b(r.jsxs(r.Fragment,{children:[e.failed.toLocaleString(),w&&r.jsx("small",{children:w})]}))})]})]}),r.jsx("p",{className:"ta-note",children:s?r.jsx(Iu,{width:"14em"}):r.jsxs(r.Fragment,{children:[Ute(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"]})]})}),d&&r.jsx("button",{type:"button",className:"btn ta-show-skills",onClick:d,children:"See which skills ran →"}),o&&r.jsx("p",{className:"ta-message",role:"alert",children:o}),t!=null&&t.history?r.jsx(Fte,{history:t.history},e.operation):x&&a&&r.jsx(h5,{}),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"})]})]}),x&&r.jsx(p5,{label:"Reading calls"}),t&&r.jsxs(r.Fragment,{children:[r.jsx("ul",{className:"ta-calls",children:p.map(j=>r.jsxs("li",{"data-state":j.state,children:[r.jsx("span",{className:"ta-call-when",children:vm(j.capturedAt,m)}),r.jsx("span",{className:"ta-call-who",children:j.provider==="claude"?"Claude":"Codex"}),r.jsx("span",{className:"ta-call-took",children:bt(j.durationMs)}),r.jsxs("span",{className:"ta-call-state",children:[r.jsx(qte,{state:j.state}),Bte[j.state]]})]},j.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 Z1="agent-dag.text-size",J1="agent-dag.density",_A=["smallest","smaller","default","larger","largest"],EA=["tightest","tighter","compact","default","comfortable"],VN={smallest:-2,smaller:-1,default:0,larger:2,largest:4};function GN(){var e,t;return KN(typeof document>"u"?null:(t=(e=document.documentElement)==null?void 0:e.dataset)==null?void 0:t.textSize)}function KN(e){return e==="smallest"||e==="smaller"||e==="larger"||e==="largest"?e:"default"}function m5(e){return e==="tightest"||e==="tighter"||e==="compact"||e==="comfortable"?e:"default"}const Hte=()=>KN(nt(Z1)),zte=()=>m5(nt(J1)),yr={min:320,standard:380,max:1600},Vte=420,Gte=8,g5="agent-dag.tool-activity.details-width";function cu(e,t){const n=Math.max(yr.min,Math.min(yr.max,t-Vte-Gte));return Math.round(Math.min(n,Math.max(yr.min,Number.isFinite(e)?e:bp())))}function bp(){return yr.standard+12*Math.max(0,VN[GN()])}function y5(){const e=Number(nt(g5));return Number.isFinite(e)&&e>=yr.min&&e<=yr.max?Math.round(e):bp()}function w5(e){st(g5,String(Math.round(e)))}function x5({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=cu(e,o()),l=w=>{var x,b;(x=t.current)==null||x.style.setProperty("--ta-details-w",`${w}px`),(b=s.current)==null||b.setAttribute("aria-valuenow",String(w))},u=w=>{l(w),n(w)},d=w=>{var x;w.button===0&&(w.preventDefault(),w.currentTarget.setPointerCapture(w.pointerId),a.current={x:w.clientX,width:i,room:o(),last:i},(x=t.current)==null||x.setAttribute("data-resizing",""))},f=w=>{const x=a.current;x&&(x.last=cu(x.width+x.x-w.clientX,x.room),l(x.last))},p=()=>{var x;const w=a.current;w&&(a.current=null,(x=t.current)==null||x.removeAttribute("data-resizing"),u(w.last))},m=w=>{const x=w.shiftKey?64:16,b=w.key==="ArrowLeft"?i+x:w.key==="ArrowRight"?i-x:w.key==="Home"?yr.min:w.key==="End"?yr.max:w.key==="Enter"?bp():null;b!==null&&(w.preventDefault(),u(cu(b,o())))};return r.jsx("div",{ref:s,className:"ta-splitter",role:"separator","aria-orientation":"vertical","aria-label":"Details width","aria-controls":"tool-operation-inspector","aria-valuemin":yr.min,"aria-valuemax":cu(yr.max,o()),"aria-valuenow":i,tabIndex:0,title:"Drag to resize · double-click for the standard width",onPointerDown:d,onPointerMove:f,onPointerUp:p,onPointerCancel:p,onLostPointerCapture:p,onDoubleClick:()=>u(cu(bp(),o())),onKeyDown:m})}const v5="(starting tools)",Kte={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 Yte(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,...Kte[n],ms:t[n],share:e.totalMs?yi(t[n],e.totalMs):"0%"}))}const TA=e=>e>=36e5?`${Math.round(e/36e5).toLocaleString()} h`:bt(e);function b5(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 Xte=(e,t=.8)=>b5(e.map(n=>({id:n.id,value:n.ms})),t);function AA(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===v5?"Mostly starting tools":t==="you"?s==="AskUserQuestion"?"Mostly answering questions":s==="ExitPlanMode"?"Mostly approving plans":`Mostly approving ${no(s)}`:`Mostly ${no(s)}`}function Zte(e,t,n=6){const s=t==="machine"?e.machine:e.you,a=t==="machine"?e.machineMs:e.youMs,o=d=>a?yi(d,a):"0%",i=s.length>n+1?s.slice(0,n):s,l=a-i.reduce((d,f)=>d+f.ms,0),u=i.map(d=>({...d,share:o(d.ms),...Jte(d.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 Jte(e,t){return e===v5?{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:no(e),detail:t==="you"?"Waiting for your approval":Yl(e),inTable:!0}}function Qte(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 ene={overloaded:"Claude overloaded",rate_limit:"usage limit",server_error:"server error",authentication_failed:"signed out"};function tne(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])=>`${ene[s]??s.replace(/_/g," ")} ${a.toLocaleString()}`).join(", ")}.`:null}const Fo=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString(void 0,{timeZone:"UTC",month:"short",day:"numeric"}),k5=()=>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 nne({split:e,since:t,turnsSince:n,selected:s,onPick:a}){const[o,i]=g.useState(null),[l,u]=g.useState(null),[d,f]=g.useState(null),p=Yte(e),m=v=>{i(S=>S===v?null:v),u(v)},w=p.find(v=>v.id===l)??null,x=p.find(v=>v.id===(d??o))??null,b=n!==void 0&&n>t,j=`${kt(e.turns,"Claude Code turn")}${b?` since ${ra(n)}`:""}`,k=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:j})]});return e.turns?r.jsxs(r.Fragment,{children:[r.jsxs("section",{className:"tt","aria-labelledby":"tt-title","data-focus":x==null?void 0:x.id,children:[k,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:Xte(p).map(v=>r.jsx("circle",{className:"tt-arc","data-lane":v.id,"data-on":(x==null?void 0:x.id)===v.id||void 0,cx:"60",cy:"60",r:"52",pathLength:100,style:{strokeDasharray:`${v.length} ${100-v.length}`,strokeDashoffset:-v.from},onPointerEnter:()=>f(v.id),onClick:()=>m(v.id)},v.id))}),r.jsx("div",{className:"tt-center","aria-hidden":"true",children:x?r.jsxs(r.Fragment,{children:[r.jsx("strong",{children:x.share}),r.jsx("span",{children:x.label})]}):r.jsxs(r.Fragment,{children:[r.jsx("strong",{children:TA(e.totalMs)}),r.jsx("span",{children:"in total"})]})})]}),r.jsx("ul",{className:"tt-lanes",children:p.map(v=>r.jsx("li",{children:r.jsxs("button",{type:"button",className:"tt-lane","data-lane":v.id,"aria-expanded":o===v.id,"aria-controls":"tt-level","aria-label":`${v.label}: ${v.share}, ${bt(v.ms)}. ${AA(e,v.id)}.`,onClick:()=>m(v.id),onPointerEnter:()=>f(v.id),onFocus:()=>f(v.id),onBlur:()=>f(null),children:[r.jsx("i",{"aria-hidden":"true"}),r.jsx("span",{className:"tt-lane-name",children:v.label}),r.jsx("strong",{children:v.share}),r.jsx("span",{className:"tt-lane-time",children:TA(v.ms)}),r.jsx(k5,{}),r.jsx("span",{className:"tt-lane-fact",children:AA(e,v.id)})]})},v.id))})]})]}),r.jsx("div",{className:"tt-fold","data-open":o?"":void 0,children:r.jsx("div",{className:"tt-level",id:"tt-level",ref:v=>{v&&(v.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(rne,{split:e}):r.jsx(sne,{split:e,lane:w.id,selected:s,onPick:a})]},w.id)})})]}):r.jsxs("section",{className:"tt","aria-labelledby":"tt-title",children:[k,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",b?` — measured from ${ra(n)}`:"","."]})})]})}function sne({split:e,lane:t,selected:n,onPick:s}){const[a,o]=g.useState(!1),i=Zte(e,t,a?1/0:6),l=Math.max(1,...i.map(d=>d.ms)),u=t==="you"&&i.some(d=>d.inTable&&!["AskUserQuestion","ExitPlanMode"].includes(d.operation));return r.jsxs(r.Fragment,{children:[r.jsx("ul",{className:"tt-parts",children:i.map(d=>{const f=r.jsxs(r.Fragment,{children:[r.jsxs("span",{className:"tt-part-name",children:[r.jsxs("span",{className:d.inTable?"ta-op":void 0,children:[d.label,d.more&&r.jsx(k5,{})]}),d.detail&&r.jsx("span",{className:"ta-desc",children:d.detail}),r.jsx("span",{className:"tt-part-bar","aria-hidden":"true",style:{"--tt-share":Math.max(.015,d.ms/l)}})]}),r.jsxs("span",{className:"ta-cell",children:[bt(d.ms),r.jsx("small",{children:d.share})]})]});return r.jsx("li",{children:d.inTable?r.jsx("button",{type:"button",className:"tt-part","data-selected":n===d.operation||void 0,"aria-expanded":n===d.operation,"aria-label":`${d.label}: ${bt(d.ms)}, ${d.share} of ${t==="machine"?"this machine’s":"your"} time`,onClick:p=>s(d.operation,p),children:f}):d.more?r.jsx("button",{type:"button",className:"tt-part","data-rest":!0,"aria-expanded":!1,"aria-label":`Show ${d.label}: ${bt(d.ms)}, ${d.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})},d.operation||d.label)})}),u&&r.jsx("p",{className:"ta-note tt-tip",children:"Allow a command you trust with /permissions in Claude Code, and Claude stops asking for it."})]})}function rne({split:e}){const{replies:t}=e,n=Qte(e),s=tne(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),d=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 ${Fo(a[0].date)} to ${Fo(a.at(-1).date)}. ${n.length?`Slower than usual on ${n.map(f=>Fo(f.date)).join(", ")}.`:"No day was clearly slower than usual."}`,children:[a.map(f=>r.jsx("span",{"data-slow":d.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:Fo(a[0].date)}),r.jsx("span",{children:Fo(a.at(-1).date)})]}),r.jsx("p",{className:"ta-note tt-days-note","aria-live":"polite",children:u?`${Fo(u.date)} · ${u.count?`${kt(u.count,"reply")} · usually ${bt(u.medianMs)}`:"no replies"}`:n.length?`Slower than usual on ${n.map(f=>`${Fo(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 hf=864e5,ane=[{id:"uses",label:"Most used"},{id:"recent",label:"Latest"},{id:"name",label:"Name"}];function Xl(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 lw(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"?Xl(a.name).short.localeCompare(Xl(o.name).short)||a.name.localeCompare(o.name):o.uses-a.uses||o.lastAt-a.lastAt||a.name.localeCompare(o.name))}function j5(e){const{claude:t,codex:n}=e.providers;return t&&n?"Claude and Codex":n?"Codex":"Claude"}const Sd=["agent","detected","typed"],kp={agent:"Picked by Claude",detected:"Picked by Codex",typed:"Typed by you"},one=e=>e.origin==="typed"&&e.provider==="codex"?"Typed in Codex":kp[e.origin],N5=e=>Sd.filter(t=>e[t]>0).map(t=>({id:t,text:`${e[t].toLocaleString()} ${kp[t][0].toLowerCase()}${kp[t].slice(1)}`})),ine=e=>N5(e).map(t=>t.text).join(", "),S5=(e,t)=>t==="codex"||!e.typedCommands||e.typedCommands==="on";function lne(e,t){const n=e.rows.filter(o=>o.uses>0),s=n.reduce((o,i)=>o+i.uses,0),a=!S5(e,t);return Sd.flatMap(o=>{const i=n.reduce((d,f)=>d+f[o],0);if(!i&&!(o==="typed"&&a))return[];const l=n.filter(d=>d[o]>0).sort((d,f)=>f[o]-d[o]||f.lastAt-d.lastAt),u=o==="typed"&&a?i?"Claude’s slash commands are not counted":"Slash commands are not counted":`${l.length===1?"Only":"Mostly"} ${Xl(l[0].name).short}`;return[{id:o,label:kp[o],uses:i,share:s?yi(i,s):"0%",fact:u}]})}function cne(e){const t=Sd.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 une(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,d)=>{i&&!s.some(f=>f.skill===i.name)&&s.push({kind:l,skill:i.name,title:u,detail:d(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 (${yi(i.uses,e.total)}), in ${kt(i.sessions,"session")}.`),S5(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 ${j5(i)==="Codex"?"Codex":"Claude"} on its own. If it should be, its description needs the words you use.`),o>=21*hf&&a(n.filter(i=>i.uses>=3&&e.until-i.lastAt>=7*hf).sort((i,l)=>l.uses-i.uses)[0],"quiet","has gone quiet",i=>`${kt(i.uses,"use")}, none since ${ra(i.lastAt)}.`),o>=14*hf&&a(n.filter(i=>e.until-i.firstAt<7*hf).sort((i,l)=>l.uses-i.uses)[0],"new","is new this week",i=>`First used ${ra(i.firstAt)}, ${kt(i.uses,"use")} so far.`),s.slice(0,3)}const dne={all:"your agents",claude:"Claude",codex:"Codex"};function hne(e,t,n){const s=e.rows.filter(a=>a.uses>0).length;return{lead:`In the last ${id[n]??`${n} days`}, ${dne[t]} used`,skills:kt(s,"skill"),uses:e.total===1?"once":`${e.total.toLocaleString()} times`,failed:e.failed,repeats:e.repeats}}const fne=e=>e.countedSince>e.since;function pne(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 ll=e=>new Date(`${e}T12:00:00Z`).toLocaleDateString(void 0,{timeZone:"UTC",month:"short",day:"numeric"});function mne({row:e,details:t,loading:n,pending:s=!1,charted:a=!0,error:o,onClose:i,sessionLabel:l,onOpenSession:u}){var _;const{namespace:d,short:f}=Xl(e.name),p=Date.now(),{claude:m,codex:w}=e.providers,x=e.agent+e.detected,b=e.agent&&e.detected?"an agent":e.detected?"Codex":"Claude",j=vm(e.lastAt,p).replace(/^(Today|Yesterday)/,R=>R.toLowerCase()),k=((_=t==null?void 0:t.history)==null?void 0:_.days.filter(R=>R.status!=="outside-history"))??[],v=(n||s)&&!t,S=R=>s?r.jsx(Iu,{}):R,C=[e.subagent?`${e.subagent.toLocaleString()} in a subagent`:"",e.detected&&e.agent?`${e.detected.toLocaleString()} picked by Codex`:""].filter(Boolean);return r.jsxs("section",{className:"ta-inspector","aria-label":`${e.name} details`,id:"tool-operation-inspector",children:[r.jsxs("header",{className:"ta-inspector-head",children:[r.jsxs("div",{children:[r.jsxs("h3",{tabIndex:-1,id:"tool-operation-heading",children:[d&&r.jsx("span",{className:"sa-namespace",children:d}),f]}),r.jsx("p",{children:s?r.jsxs(r.Fragment,{children:[r.jsx(Iu,{width:"9em"}),r.jsx("br",{}),r.jsx(Iu,{width:"12em"})]}):r.jsxs(r.Fragment,{children:[m&&w?`${m.toLocaleString()} by Claude, ${w.toLocaleString()} by Codex`:`All by ${j5(e)}`,r.jsx("br",{}),"Last used ",j]})})]}),r.jsx("button",{type:"button",className:"glyph-btn","aria-label":"Close details",onClick:i,children:r.jsx(f5,{})})]}),r.jsxs("dl",{className:"ta-facts","aria-busy":s||void 0,children:[r.jsxs("div",{children:[r.jsx("dt",{children:"Uses"}),r.jsx("dd",{children:S(e.uses.toLocaleString())})]}),!s&&e.failed>0?r.jsxs("div",{children:[r.jsx("dt",{children:"Failed"}),r.jsx("dd",{"data-bad":!0,children:e.failed.toLocaleString()})]}):r.jsxs("div",{children:[r.jsx("dt",{children:"Sessions"}),r.jsx("dd",{children:S(e.sessions.toLocaleString())})]}),r.jsxs("div",{"data-lane":"agent",children:[r.jsxs("dt",{children:["Picked by ",b]}),r.jsx("dd",{children:S(x.toLocaleString())})]}),r.jsxs("div",{"data-lane":"typed",children:[r.jsx("dt",{children:"Typed by you"}),r.jsx("dd",{children:S(e.typed.toLocaleString())})]})]}),!s&&(C.length>0||e.repeats>0)&&r.jsxs("p",{className:"ta-note",children:[C.join(" · "),e.repeats>0&&r.jsxs(r.Fragment,{children:[C.length>0&&" · ",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}),k.length>=3?r.jsx(gne,{days:k},e.name):v&&a&&r.jsx(h5,{noun:"use"}),t&&(t.projects.length>0||t.projectless>0)&&r.jsx(yne,{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"})}),v&&r.jsx(p5,{label:"Reading uses"}),t&&r.jsxs(r.Fragment,{children:[r.jsx(wne,{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 gne({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 ${ll(e[0].date)} to ${ll(e.at(-1).date)}. The busiest day was ${ll(s.date)} with ${kt(s.uses,"use")}${s.uses?`: ${ine(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:Sd.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:ll(e[0].date)}),r.jsx("span",{children:ll(e.at(-1).date)})]}),r.jsxs("p",{className:"ta-note ta-history-day","aria-live":"polite",children:[ll(o.date)," · ",o.uses?r.jsxs(r.Fragment,{children:[kt(o.uses,"use"),": ",N5(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 yne({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 wne({uses:e,now:t,sessionLabel:n,onOpenSession:s}){const a=[];for(const o of e){const i=u5(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:X1(i.at)}),r.jsxs("span",{className:"sa-use-what",children:[r.jsxs("span",{className:"sa-use-who",children:[r.jsx("i",{"aria-hidden":"true"}),one(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 xne=()=>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 vne({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:b5(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(xne,{}),r.jsx("span",{className:"tt-lane-fact",children:u.fact})]})},u.id))})]})]})}const RA=12,bne=()=>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"})]}),uu=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}),kne={failing:uu(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:uu(r.jsx("path",{d:"M5 20V11M12 20V4M19 20v-6"})),typed:uu(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:uu(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:uu(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 jne(e){return`${e.name}: ${kt(e.uses,"use")}, last used ${vm(e.lastAt)}${e.failed?`, ${e.failed.toLocaleString()} failed`:""}`}function Nne({filters:e,provider:t,period:n,setPeriod:s,refresh:a,onStatus:o,sessionLabel:i,onOpenSession:l}){var Ke;cn("skill-activity");const[u,d]=g.useState("uses"),[f,p]=g.useState(""),m=g.useRef(u);m.current=u;const w=g.useRef(f);w.current=f;const x=g.useRef(!1),b=g.useRef(null),[j,k]=g.useState(!1),[v,S]=g.useState(null),[C,_]=g.useState(null),[R,A]=g.useState(!1),I=g.useRef(null),[$,U]=g.useState(null),[F,M]=g.useState(null),[B,T]=g.useState(!0),[P,q]=g.useState(!1),[K,z]=g.useState(""),[H,D]=g.useState(""),O=g.useRef(null),V=g.useRef(!1),Z=g.useRef(null),W=g.useRef(null),X=lc("(min-width: 960px)"),[Y,J]=g.useState(y5),Q=we=>{J(we),w5(we)},te=new URLSearchParams({view:"skills",provider:t,days:n}).toString(),le=g.useRef(o);le.current=o,g.useEffect(()=>{le.current({loading:B,detailLoading:P,capturedAt:($==null?void 0:$.capturedAt)??null,hasData:!!$})},[B,P,$]),g.useEffect(()=>{const we=new AbortController;let Fe=!0;const Re=window.setTimeout(()=>we.abort(),65e3);return z(""),O.current!==te&&(U(null),M(null),k(!1)),V.current=!0,T(!0),(async()=>{try{const Ae=await xp(te,we.signal);if(Fe){O.current=te,U(Ae);const rt=!x.current&&lw(Ae.rows,m.current,w.current).find(We=>We.uses>0);rt?(x.current=!0,S(rt.name)):S(We=>{var se;return!We||Ae.rows.some(be=>be.name===We)?We:((se=lw(Ae.rows,m.current,w.current).find(be=>be.uses>0))==null?void 0:se.name)??null})}}catch(Ae){Fe&&z(Ae instanceof Error&&Ae.name!=="AbortError"?Ae.message:"Reading the history took too long. Try again, or keep less history in Settings.")}finally{window.clearTimeout(Re),Fe&&(V.current=!1,T(!1))}})(),()=>{Fe=!1,we.abort(),window.clearTimeout(Re),V.current=!1}},[te,a]),g.useEffect(()=>{if(M(Ae=>(Ae==null?void 0:Ae.name)===v&&O.current===te?Ae:null),D(""),!v||!$||B||V.current){q(!1);return}let we=!0;const Fe=new AbortController,Re=window.setTimeout(()=>Fe.abort(),65e3);return q(!0),(async()=>{var Ae;try{const rt=await xp(`${te}&skill=${encodeURIComponent(v)}&history=1&timeZone=${encodeURIComponent(Intl.DateTimeFormat().resolvedOptions().timeZone)}`,Fe.signal);we&&((Ae=rt.details)!=null&&Ae.row?M(rt.details):S(null))}catch{we&&D("Could not read the uses of this skill. Close it and open it again to retry.")}finally{window.clearTimeout(Re),we&&q(!1)}})(),()=>{we=!1,Fe.abort(),window.clearTimeout(Re)}},[v,$,B,te]);const de=g.useMemo(()=>$?lne($,t):[],[$,t]),oe=g.useMemo(()=>$?une($,t):[],[$,t]),re=C&&de.some(we=>we.id===C&&we.uses>0)?C:null,he=g.useMemo(()=>lw(($==null?void 0:$.rows)??[],u,f).filter(we=>!re||we[re]>0),[$,u,f,re]),fe=j||f?he:he.slice(0,RA),$e=he.reduce((we,Fe)=>Math.max(we,Fe.uses),0),ye=$==null?void 0:$.rows.find(we=>we.name===v);ye&&(b.current=ye);const ge=ye??(v&&!$&&((Ke=b.current)==null?void 0:Ke.name)===v?b.current:void 0),je=!!$&&$.failed>0,Le=we=>Fe=>{I.current=Fe.currentTarget,A(Fe.detail===0),S(Re=>Re===we?null:we)},ke=()=>{const we=v;S(null),requestAnimationFrame(()=>{var Ae,rt;const Fe=I.current,Re=Array.from(((Ae=Z.current)==null?void 0:Ae.querySelectorAll(".ta-row[data-skill]"))??[]).find(We=>We.dataset.skill===we);(rt=Fe!=null&&Fe.isConnected&&Fe.checkVisibility()?Fe:Re)==null||rt.focus({preventScroll:!0})})},Ie=$&&hne($,t,n),De=$&&fne($),Ue=$&&pne($,t);return r.jsxs("div",{className:"ta-workspace",ref:W,"data-inspecting":!!ge||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,B&&!$&&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:[$&&"Showing the last numbers. ",K]})}),$&&Ie&&($.total===0&&$.repeats===0?r.jsxs("div",{className:"ta-empty",children:[r.jsxs("h3",{children:["No skills used in the last ",id[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 ",ra($.countedSince),". Sessions from before that are not imported. Use a skill and it shows up here."]}),Ue&&r.jsx("p",{className:"sa-typed-note",children:Ue}),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}),$.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 ",ra($.countedSince),", so the days before it are empty rather than unused."]}),Ue&&r.jsx("p",{className:"ta-note sa-typed-note",children:Ue}),(!$.storageOk||$.dropped>0||$.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.",!$.storageOk&&" Check free disk space."]}),(oe.length>0||$.total>0)&&r.jsxs("div",{className:"ta-glance","data-single":!(oe.length>0&&$.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(we=>r.jsx("li",{children:r.jsxs("button",{type:"button",className:"ta-highlight","data-kind":we.kind,"data-skill":we.skill,"aria-expanded":v===we.skill,"aria-controls":v===we.skill?"tool-operation-inspector":void 0,onClick:Le(we.skill),children:[r.jsx("span",{className:"ta-highlight-glyph",children:kne[we.kind]}),r.jsxs("span",{className:"ta-highlight-text",children:[r.jsxs("span",{children:[r.jsx("code",{children:Xl(we.skill).short})," ",we.title]}),r.jsx("small",{children:we.detail})]})]})},we.kind))})]}),$.total>0&&r.jsx(vne,{shares:de,total:$.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 ${$.rows.length.toLocaleString()}`:$.rows.length.toLocaleString()})]}),r.jsxs("label",{className:"ta-search",children:[r.jsx(bne,{}),r.jsx("input",{type:"search","aria-label":"Find a skill",placeholder:"Find a skill",value:f,onChange:we=>p(we.target.value)})]})]}),r.jsx("div",{className:"uh-range ta-sorts sa-sorts",role:"group","aria-label":"Sort by",children:ane.map(we=>r.jsx("button",{type:"button",className:"uh-range-btn","aria-pressed":u===we.id,onClick:()=>d(we.id),children:we.label},we.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:fe.map(we=>{const{namespace:Fe,short:Re}=Xl(we.name);return r.jsx("li",{children:r.jsxs("button",{type:"button",className:"ta-row","data-skill":we.name,"data-selected":v===we.name||void 0,"aria-expanded":v===we.name,"aria-controls":v===we.name?"tool-operation-inspector":void 0,"aria-label":jne(we),onClick:Le(we.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}),Re]}),r.jsx("span",{className:"ta-desc",children:[cne(we),kt(we.sessions,"session"),we.repeats>0&&kt(we.repeats,"repeat")].filter(Boolean).join(" · ")}),r.jsx("span",{className:"ta-bar","aria-hidden":"true",style:{"--ta-share":$e&&u==="uses"?Math.max(.015,we.uses/$e):0},children:Sd.filter(Ae=>we[Ae]>0).map(Ae=>r.jsx("i",{"data-lane":Ae,style:{flexGrow:we[Ae]}},Ae))})]}),r.jsxs("span",{className:"ta-cell","data-col":"uses",children:[we.uses.toLocaleString(),r.jsxs("span",{className:"ta-unit",children:[" ",we.uses===1?"use":"uses"]})]}),r.jsxs("span",{className:"ta-cell","data-col":"recent",children:[r.jsx("span",{className:"ta-unit",children:"last "}),vm(we.lastAt)]}),je&&r.jsx("span",{className:"ta-cell","data-col":"failed","data-bad":we.failed>0||void 0,children:we.failed?r.jsxs(r.Fragment,{children:[we.failed.toLocaleString(),r.jsx("span",{className:"ta-unit",children:" failed"})]}):r.jsxs("span",{className:"ta-zero",children:["0",r.jsx("span",{className:"ta-unit",children:" failed"})]})})]})},we.name)})}),!he.length&&f.trim()&&r.jsxs("p",{className:"ta-note ta-no-match",children:["No skill matches “",f.trim(),"”",re?" among these":"","."]}),!f&&!j&&he.length>RA&&r.jsxs("button",{type:"button",className:"btn ta-more",onClick:()=>k(!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 Picked by Codex."]}),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 ",ra($.countedSince)," and kept with the tool history for ",$.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."]})]})]})]}))]})}),ge&&X&&r.jsx(x5,{width:Y,workspace:W,onCommit:Q}),ge&&r.jsx(d5,{keyboard:R,itemKey:ge.name,onClose:ke,children:r.jsx(mne,{row:(F==null?void 0:F.name)===v&&F.row?F.row:ge,details:(F==null?void 0:F.name)===v?F:null,loading:P,pending:!ye,charted:Number(n)>=7,error:H,onClose:ke,sessionLabel:i,onOpenSession:l})})]})}const MA=12,Sne=[{id:"all",label:"All agents"},{id:"claude",label:"Claude"},{id:"codex",label:"Codex"}],$A={tools:"Tool activity",skills:"Skill activity"},Cne={tools:"tool-activity",skills:"skill-activity"},_ne=()=>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"})}),Ene=()=>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"})]}),Tne={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 Ane(e){const t=e.failed?`${e.failed.toLocaleString()} failed (${xm(e)})`:"none failed",n=e.totalMs===null?"not timed":`${bt(e.totalMs)} in total, usually ${bt(e.medianMs)}`;return`${no(e.operation)}${Yl(e.operation)?`, ${Yl(e.operation)}`:""}: ${kt(e.calls,"call")}, ${n}, ${t}`}function Rne({view:e="tools",onClose:t,sessionLabel:n,onOpenSession:s}){var ve;const[a,o]=g.useState(e),[i,l]=g.useState("all"),[u,d]=g.useState("7"),[f,p]=g.useState(0),[m,w]=g.useState({loading:!0,detailLoading:!1,capturedAt:null,hasData:!1}),[x,b]=g.useState("calls"),[j,k]=g.useState(""),v=g.useRef(x);v.current=x;const S=g.useRef(j);S.current=j;const[C,_]=g.useState(!1),[R,A]=g.useState(null),I=g.useRef(!1),$=g.useRef(null),[U,F]=g.useState(!1),M=g.useRef(R);M.current=R;const B=g.useRef(null),[T,P]=g.useState(null),[q,K]=g.useState(null),[z,H]=g.useState("recent"),[D,O]=g.useState(!0),[V,Z]=g.useState(!1),[W,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=lc("(min-width: 960px)"),[fe,$e]=g.useState(y5),ye=pe=>{$e(pe),w5(pe)},[ge]=g.useState(()=>document.activeElement instanceof HTMLElement?document.activeElement:null),je=()=>{t(),requestAnimationFrame(()=>{var ze;const pe=ge,_e=Array.from(document.querySelectorAll(`[data-rail-item="${Cne[e]}"], [data-rail-item="more"]`)).find(at=>at.checkVisibility());(ze=pe&&pe!==document.body&&pe.isConnected&&pe.checkVisibility()?pe:_e)==null||ze.focus({preventScroll:!0})})},Le=gt(je,{focusRef:oe}),ke=wt(je),Ie=new URLSearchParams({provider:i,days:u,timeZone:Intl.DateTimeFormat().resolvedOptions().timeZone}).toString();g.useEffect(()=>{if(a!=="tools")return;const pe=new AbortController;let _e=!0;const ze=window.setTimeout(()=>pe.abort(),65e3);return X(""),de.current!==Ie&&(P(null),K(null),_(!1)),le.current=!0,O(!0),(async()=>{var at;try{const tt=await xp(Ie,pe.signal);if(_e){de.current=Ie,P(tt);const xt=!I.current&&iw(tt.rows,v.current,S.current)[0];xt?(I.current=!0,A(xt.operation)):M.current&&!tt.rows.some(Mt=>Mt.operation===M.current)&&A(((at=iw(tt.rows,v.current,S.current)[0])==null?void 0:at.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(ze),_e&&(le.current=!1,O(!1))}})(),()=>{_e=!1,pe.abort(),window.clearTimeout(ze),le.current=!1}},[Ie,Q,a]),g.useEffect(()=>{if(K(at=>(at==null?void 0:at.operation)===R&&de.current===Ie?at:null),J(""),!R||!T||D||le.current||a!=="tools"){Z(!1);return}let pe=!0;const _e=new AbortController,ze=window.setTimeout(()=>_e.abort(),65e3);return Z(!0),(async()=>{var at;try{const tt=await xp(`${Ie}&operation=${encodeURIComponent(R)}&history=1`,_e.signal);pe&&(((at=tt.details)==null?void 0:at.measurements)===null?A(null):K(tt.details))}catch{pe&&J("Could not read the calls for this tool. Close it and open it again to retry.")}finally{window.clearTimeout(ze),pe&&Z(!1)}})(),()=>{pe=!1,_e.abort(),window.clearTimeout(ze)}},[R,T,D,Ie,a]);const De=g.useMemo(()=>iw((T==null?void 0:T.rows)??[],x,j),[T,x,j]),Ue=g.useMemo(()=>T?$te(T.rows,T.totalMs):[],[T]),Ke=C||j?De:De.slice(0,MA),we=De.length?vp(De[0],x)??0:0,Fe=T==null?void 0:T.rows.find(pe=>pe.operation===R);Fe&&($.current=Fe);const Re=Fe??(R&&!T&&((ve=$.current)==null?void 0:ve.operation)===R?$.current:void 0),Ae=pe=>_e=>{B.current=_e.currentTarget,F(_e.detail===0),H("recent"),A(ze=>ze===pe?null:pe)},rt=()=>{const pe=R;A(null),requestAnimationFrame(()=>{var at,tt;const _e=B.current,ze=Array.from(((at=Le.current)==null?void 0:at.querySelectorAll(".ta-row[data-operation]"))??[]).find(xt=>xt.dataset.operation===pe);(tt=_e!=null&&_e.isConnected&&_e.checkVisibility()?_e:ze??oe.current)==null||tt.focus({preventScroll:!0})})},We=()=>{if(a==="skills"){!m.loading&&!m.detailLoading&&p(pe=>pe+1);return}le.current||V||(le.current=!0,te(pe=>pe+1))},se=T&&Ite(T,i,u),be=a==="skills"?m.loading:D,Te=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(id).map(([pe,_e])=>r.jsx("button",{type:"button",className:"uh-range-btn","aria-pressed":u===pe,onClick:()=>d(pe),children:_e},pe))}),r.jsx("div",{className:"uh-range",role:"group","aria-label":"Agent",children:Sne.map(pe=>r.jsx("button",{type:"button",className:"uh-range-btn","aria-pressed":i===pe.id,onClick:()=>l(pe.id),children:pe.label},pe.id))})]});return vt.createPortal(r.jsx("div",{className:"modal-backdrop",role:"presentation",...ke,children:r.jsxs("div",{className:"modal ta-report",ref:Le,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:$A[a]}),r.jsxs("div",{className:"ta-actions",children:[r.jsx("span",{className:"ta-freshness",role:"status",children:be?Te!==null?"Updating…":"Reading history…":Te!==null?`Updated ${new Date(Te).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":be||void 0,"aria-busy":a==="skills"?m.loading||m.detailLoading:D||V,onClick:We,children:r.jsx(_ne,{})}),r.jsx("button",{type:"button",ref:oe,className:"glyph-btn",onClick:je,"aria-label":`Close ${$A[a].toLowerCase()}`,title:"Close (Esc)",children:"×"})]})]}),r.jsx("div",{className:"ta-view-panel",children:a==="skills"?r.jsx(Nne,{filters:Oe,provider:i,period:u,setPeriod:d,refresh:f,onStatus:w,sessionLabel:n,onOpenSession:s}):r.jsxs("div",{className:"ta-workspace",ref:re,"data-inspecting":!!Re||void 0,style:{"--ta-details-w":`${fe}px`},children:[r.jsx("div",{className:"ta-body",children:r.jsxs("div",{className:"ta-report-content",children:[Oe,D&&!T&&r.jsxs("div",{className:"ta-loading",role:"status","aria-label":"Reading tool history",children:[r.jsx("i",{}),r.jsx("i",{}),r.jsx("i",{}),r.jsx("i",{}),r.jsx("i",{})]}),W&&r.jsxs("div",{className:"ta-message",role:"alert",children:[r.jsxs("p",{children:[T&&"Showing the last numbers. ",W]}),r.jsx("button",{type:"button",className:"btn",onClick:We,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 ",id[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 ",ra(T.startedAt),". Run a session and the calls show up here."]}),u!=="90"&&r.jsx("button",{type:"button",className:"btn",onClick:()=>d("90"),children:"Show the last 90 days"})]}):r.jsxs(r.Fragment,{children:[r.jsxs("p",{className:"ta-summary",children:[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."]}),(Ue.length>0||T.split)&&r.jsxs("div",{className:"ta-glance","data-single":!(Ue.length>0&&T.split)||void 0,children:[Ue.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:Ue.map(pe=>r.jsx("li",{children:r.jsxs("button",{type:"button",className:"ta-highlight","data-kind":pe.kind,"data-operation":pe.operation,"aria-expanded":R===pe.operation,"aria-controls":R===pe.operation?"tool-operation-inspector":void 0,onClick:Ae(pe.operation),children:[r.jsx("span",{className:"ta-highlight-glyph",children:Tne[pe.kind]}),r.jsxs("span",{className:"ta-highlight-text",children:[r.jsxs("span",{children:[r.jsx("code",{children:no(pe.operation)})," ",pe.title]}),r.jsx("small",{children:pe.detail})]})]})},pe.kind))})]}),T.split&&r.jsx(nne,{split:T.split,since:T.since,turnsSince:T.turnsSince,selected:R,onPick:(pe,_e)=>Ae(pe)(_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(Ene,{}),r.jsx("input",{type:"search","aria-label":"Find a tool or command",placeholder:"Find a tool or command",value:j,onChange:pe=>k(pe.target.value)})]})]}),r.jsx("div",{className:"uh-range ta-sorts",role:"group","aria-label":"Sort by",children:Rte.map(pe=>r.jsx("button",{type:"button",className:"uh-range-btn","aria-pressed":x===pe.id,onClick:()=>b(pe.id),children:pe.label},pe.id))}),r.jsxs("div",{className:"ta-list-head","aria-hidden":"true","data-sort":x,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":x,children:Ke.map(pe=>{const _e=vp(pe,x),ze=Yl(pe.operation);return r.jsx("li",{children:r.jsxs("button",{type:"button",className:"ta-row","data-operation":pe.operation,"data-selected":R===pe.operation||void 0,"aria-expanded":R===pe.operation,"aria-controls":R===pe.operation?"tool-operation-inspector":void 0,"aria-label":Ane(pe),onClick:Ae(pe.operation),children:[r.jsxs("span",{className:"ta-row-name",children:[r.jsx("span",{className:"ta-op",children:no(pe.operation)}),ze&&r.jsx("span",{className:"ta-desc",children:ze}),r.jsx("span",{className:"ta-bar","aria-hidden":"true",style:{"--ta-share":we&&_e?Math.max(.015,_e/we):0}})]}),r.jsxs("span",{className:"ta-cell","data-col":"calls",children:[pe.calls.toLocaleString(),r.jsxs("span",{className:"ta-unit",children:[" ",pe.calls===1?"call":"calls"]})]}),r.jsxs("span",{className:"ta-cell","data-col":"time",children:[bt(pe.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(pe.medianMs)]}),r.jsx("span",{className:"ta-cell","data-col":"failed","data-bad":pe.failed>0||void 0,children:pe.failed?r.jsxs(r.Fragment,{children:[pe.failed.toLocaleString(),r.jsx("span",{className:"ta-unit",children:" failed"}),r.jsx("small",{children:xm(pe)})]}):r.jsxs("span",{className:"ta-zero",children:["0",r.jsx("span",{className:"ta-unit",children:" failed"})]})})]})},pe.operation)})}),!De.length&&r.jsxs("p",{className:"ta-note ta-no-match",children:["No tool or command matches “",j.trim(),"”."]}),!j&&!C&&De.length>MA&&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 ",ra(T.startedAt)," and kept for ",T.retentionDays," days. Commands are grouped by name; their arguments and output are never saved. Change this in Settings."]})]})]})]}))]})}),Re&&he&&r.jsx(x5,{width:fe,workspace:re,onCommit:ye}),Re&&r.jsx(d5,{keyboard:U,itemKey:Re.operation,onClose:rt,children:r.jsx(Wte,{row:(q==null?void 0:q.operation)===R&&q.measurements?q.measurements:Re,details:(q==null?void 0:q.operation)===R?q:null,loading:V,pending:!Fe,charted:Number(u)>=7,error:Y,kind:z,setKind:H,onClose:rt,onShowSkills:Re.operation==="Skill"?()=>{A(null),o("skills")}:void 0})})]})})]})}),document.body)}const Q1={cost:0,inputTokens:0,outputTokens:0,cacheReadTokens:0,cacheCreateTokens:0,unpricedTokens:0,sessions:0};function Mne(e){if(!e.synthetic)return!1;const t=e.usage;return t.inputTokens+t.outputTokens+t.cacheReadTokens+t.cacheCreateTokens<=0}function ej(e,t){const n=new Map;for(const s of e){if(s.kind!=="root"||!s.sessionId||Mne(s))continue;const a=Wn(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:Ul(s,t)})}return n}function $ne(e,t){if(!e)return Q1;const n={...Q1};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 tj(e,t=new Date){return new Date(Date.UTC(t.getFullYear(),t.getMonth(),t.getDate()-(e-1))).toISOString().slice(0,10).replace(/-/g,"")}const bm=[{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 Lne(e,t,n=bm.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 Ine(e,t=new Date){return e==="today"?tj(1,t):e==="month"?tj(t.getDate(),t):"20200101"}const Sn=e=>typeof e=="number"&&Number.isFinite(e)?e:0,qf=e=>typeof e=="string"?e:"";function YN(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=qf(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+=Sn(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,Sn(o.cost)))),l.inputTokens+=Sn(o==null?void 0:o.inputTokens),l.outputTokens+=Sn(o==null?void 0:o.outputTokens),l.cacheReadTokens+=Sn(o==null?void 0:o.cacheReadTokens),l.cacheCreateTokens+=Sn(o==null?void 0:o.cacheCreationTokens)}}return[...n.values()].sort((s,a)=>a.cost-s.cost||a.tokens-s.tokens)}const One=/[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;function Pne(e){var t;return((t=One.exec(e))==null?void 0:t[0])??e}function Dne(e,t=new Map){const n=Array.isArray(e==null?void 0:e.sessions)?e.sessions:[],s=new Set(YN(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=qf(o==null?void 0:o.period);if(!i)continue;const l=Pne(i),u=o==null?void 0:o.metadata,d=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(qf).filter(Boolean):[];a.push({sessionId:l,label:t.get(l)??null,agent:qf(o==null?void 0:o.agent)||"claude",cost:Sn(o==null?void 0:o.totalCost),priced:f.length>0&&f.every(p=>s.has(p)),tokens:Sn(o==null?void 0:o.totalTokens),models:f,lastActivityMs:Number.isFinite(d)?d:null})}return a.sort((o,i)=>i.cost-o.cost||i.tokens-o.tokens)}function Fne(e,t=XN(e).cost){const s=(Array.isArray(e==null?void 0:e.sessions)?e.sessions:[]).reduce((o,i)=>o+Sn(i==null?void 0:i.totalCost),0),a=Math.max(.01,t*.01);return{sum:s,total:t,over:s>t+a}}function Bne(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 XN(e){const t=e==null?void 0:e.totals;if(t&&typeof t=="object"){const u=Sn(t.cacheReadTokens),d=Sn(t.cacheCreationTokens),f=Sn(t.inputTokens),p=Sn(t.outputTokens);return{cost:Sn(t.totalCost),inputTokens:f,outputTokens:p,cacheReadTokens:u,cacheCreateTokens:d,tokens:Sn(t.totalTokens)||f+p+u+d}}const n=YN(e),s=u=>n.reduce((d,f)=>d+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 qne(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 C5(e,t){var n;return((n=bm.find(s=>s.key===(e??t)))==null?void 0:n.noun)??"today"}function Une(e,t,n){const s=e!=null,a=XN(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 _5="agent-dag.usagePeriod";function Wne(){const e=nt(_5);return bm.some(t=>t.key===e)?e:"today"}function Hne(e){st(_5,e)}const E5="agent-dag.usageSessionsOpen";function zne(){return nt(E5)==="1"}function Vne(e){st(E5,e?"1":"0")}function ZN({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}: ${lt(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 ff="https://ccdeck.dev/guides",Gne={localNetwork:{href:`${ff}/local-network/#film`,subject:"Local network"},claudeAccounts:{href:`${ff}/claude-accounts/#film`,subject:"Claude accounts"},usage:{href:`${ff}/cost-and-quota/#film`,subject:"cost and quota"},tour:{href:`${ff}/first-run/#film`,subject:"first run"}};function ld({film:e,action:t=!1}){const{href:n,subject:s}=Gne[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",Kne="/brand/ccdeck-mark-gradient-small-optical.svg",Yne="/brand/ccdeck-mark-mono-dark-small-optical.svg",Xne={month:"short",day:"numeric",hour:"numeric",minute:"2-digit",hour12:!0};function T5(e,t){const n=t.nextExpiryAt!=null?` · ${`expires ${new Date(t.nextExpiryAt).toLocaleString("en-US",Xne).replace(/\s+(AM|PM)/,(s,a)=>a.toLowerCase())}`.replace(/\s/g," ")}`:"";return`${t.availableCount} ${e}${t.availableCount!==1?"s":""} available${n}`}const Zne=12*36e5,Jne=new Set(["seven_day","weekly"]);function Qne(e,t=4){return e.filter(n=>Jne.has(n.id)&&n.ended==="reset"&&n.resetAt*1e3-n.t<=Zne).sort((n,s)=>s.resetAt-n.resetAt).slice(0,t)}function ese(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 tse=e=>new Date(e).toLocaleDateString(void 0,{month:"short",day:"numeric"}),nse=e=>e<36e5?`${Math.max(1,Math.round(e/6e4))} min`:`${Math.round(e/36e5)} h`;function sse(e){return[...e.map(t=>`${tse(t.resetAt*1e3)}: ${Math.round(t.pct)}% used, read ${nse(t.resetAt*1e3-t.t)} before the reset`),"An average of the weekly window's last reading before each reset"].join(`
|
|
98
|
+
`)}const rse=15*6e4;function LA(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(Qne(u.closed))}catch{}};o();const i=window.setInterval(()=>{document.visibilityState==="visible"&&o()},rse);return()=>{a=!1,window.clearInterval(i)}},[e,t]),n}function A5(){return r.jsxs("svg",{width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:[r.jsx("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 Zl(){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 ase({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(Zl,{})}),r.jsxs("span",{className:"vis-hidden",children:[", on ",t.host,", opens in a new tab"]})]},t.provider))})}function R5({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(Zl,{})}),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 ose(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 d=100-e,f=i>0?e/i:0,p=f>0?d/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),x=Math.floor(p%3600/60);m.runsOutIn=w>0?`${w}h ${x}m`:`${x}m`}return m}return{label:`${Math.round(-u)}% under pace`,color:"var(--ok)",expectedPct:l,isDeficit:!1}}function Ka({pct:e,label:t,reset:n,resetAt:s,windowSec:a,limitReached:o,nowSec:i}){const l=!!s&&s<=i,u=e!=null&&!l,d=u?Math.min(100,Math.max(0,e)):0,p=o||d>=90?"var(--err)":d>=70?"var(--warn)":"var(--accent)",m=d<1,w=l?"reset":u?m?"< 1%":`${Math.round(d)}%`:"no reading",x=m?2:d,b=s&&!l?kd(s,i):null,j=u&&s&&a?ose(d,s,a,i,o):null,[k,v]=g.useState(!1),S=g.useId();return r.jsxs("div",{className:"qb-row",children:[r.jsxs("div",{className:"qb-meta",children:[r.jsxs("span",{className:"qb-label",children:[t,o&&!l&&r.jsx("span",{className:"qb-limit-badge",title:"Rate limit reached",children:"⛔"})]}),r.jsx("span",{className:"qb-pct",style:{color:u?p:"var(--muted)"},children:w})]}),r.jsxs("div",{className:"qb-track",children:[u&&r.jsx("div",{className:"qb-fill",style:{transform:`scaleX(${x/100})`,background:p,opacity:m?.4:1}}),j&&r.jsx("div",{className:"qb-pace-rail",style:{transform:`translateX(${j.expectedPct}%)`},children:r.jsx("div",{"aria-hidden":!0,className:"qb-pace-marker",style:{background:j.isDeficit?"var(--err)":"var(--ok)"},title:`To last until reset, stay near ${Math.round(j.expectedPct)}% by now`})})]}),r.jsxs("div",{className:"qb-reset-row",children:[l?r.jsx("span",{className:"qb-reset",children:"waiting for a new reading"}):b?r.jsxs("span",{className:"qb-reset",children:["resets in ",b]}):n?r.jsxs("span",{className:"qb-reset",children:["resets ",n]}):null,j&&r.jsxs("button",{type:"button",className:"qb-pace",style:{color:j.color},"aria-expanded":k,"aria-controls":k?S:void 0,onClick:()=>v(C=>!C),children:[r.jsx("i",{className:"qb-pace-key","aria-hidden":!0,style:{background:j.isDeficit?"var(--err)":"var(--ok)"}}),j.runsOutIn?`runs out in ${j.runsOutIn}`:j.label]})]}),k&&j&&r.jsxs("div",{id:S,className:"qb-why",children:["To last until reset, stay near ",Math.round(j.expectedPct),"% by now."]})]})}function M5(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 ise(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 lse(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 cse(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 $5({weeks:e=[]}){const t=ese(e);return t?r.jsx("div",{className:"up-quota-sub",title:sse(e),children:t}):null}function use({quota:e,quotaLoading:t,nowSec:n,incident:s,weekEnds:a}){const o=M5(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:ise(e==null?void 0:e.source),children:[o,(e==null?void 0:e.stale)&&" · no newer reading"]})]}),r.jsx(R5,{incident:s}),e!=null&&e.ok?r.jsxs("div",{className:"up-quota-bars",children:[e.session5hPct!=null&&r.jsx(Ka,{label:"5-hour window",pct:e.session5hPct,reset:e.session5hReset,resetAt:e.session5hResetAt,windowSec:e.session5hWindowSec,nowSec:n}),r.jsx(Ka,{label:"7-day window",pct:e.week7dPct??null,reset:e.week7dReset,resetAt:e.week7dResetAt,windowSec:e.week7dWindowSec,nowSec:n}),r.jsx($5,{weeks:a}),e.weekSonnetPct!=null&&r.jsx(Ka,{label:"Sonnet (7d)",pct:e.weekSonnetPct,nowSec:n}),e.weekOpusPct!=null&&r.jsx(Ka,{label:"Opus (7d)",pct:e.weekOpusPct,nowSec:n}),e.extraEnabled&&e.extraUsedCredits!=null&&e.extraMonthlyLimit?r.jsx(Ka,{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:T5("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:lse(e.reason)})]}):r.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]})}function dse({codexQuota:e,codexLoading:t,nowSec:n,incident:s,weekEnds:a}){var i,l;const o=M5(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(R5,{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(Ka,{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($5,{weeks:a}),(l=e.extraWindows)==null?void 0:l.map(u=>r.jsx(Ka,{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(Ka,{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:T5("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:cse(e.reason)})]}):r.jsx("div",{className:"up-quota-na up-quota-loading",children:"Checking…"})]})}function nj(e,t){return t&&e<=0?ua:lt(e)+(t?"+":"")}const gje="Some models have no known price. Tokens are counted; their cost is missing from the total.";function IA(e,t){if(e==null)return null;const n=Math.min(Math.max(0,e),Math.max(0,t));return`Recorded in logs: ${lt(n)} · other reported cost: ${lt(Math.max(0,t-n))}. Both are included in the total; recorded costs are not a verified bill.`}function hse({fromRange:e,rangeModelRows:t,boardModelRows:n}){const s=t.filter(o=>o.storedCost!==void 0),a=e?IA(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,IA(o.storedCost,o.cost)].filter(Boolean).join(`
|
|
99
|
+
`),children:Qa(o.model)}),r.jsx("td",{className:"up-num",children:St(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:nj(o.cost,!0)}):r.jsx("td",{className:"up-num up-cost-val",children:nj(o.cost)})]},o.model)):n.map(o=>r.jsxs("tr",{children:[r.jsx("td",{className:"up-model-name",title:o.model===H1?"no model reported yet":o.model,children:o.model===H1?"unknown":Qa(o.model)}),r.jsx("td",{className:"up-num",children:St(o.inputTokens+o.outputTokens)}),o.priced?r.jsx("td",{className:"up-num up-cost-val",children:lt(o.cost.total)}):r.jsx("td",{className:"up-num up-unpriced",children:ua})]},o.model))})]}),a&&r.jsx("p",{className:"uh-cost-note",children:a})]})}function fse({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=Lne(a.key,o);i!==null&&(a.preventDefault(),(l=s.current[i])==null||l.focus())},children:bm.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 ${C5(e,e)}…`:""})]})}function pse(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 mse(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 OA({sessionId:e,agent:t,label:n,onOpen:s,children:a}){return s&&pse(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 gse({fromRange:e,rangeSessionRows:t,boardSessionRows:n,boardStates:s,sessionsOpen:a,setSessionsOpen:o,periodNoun:i,sessionScale:l,onOpenSession:u,boardProviders:d}){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:Bne(i,l,lt),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(OA,{sessionId:p.sessionId,agent:p.agent,label:p.label??fp(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:Wl(m)})]}):r.jsx("span",{className:"sl-dot up-dot-past","aria-hidden":!0}),r.jsx("span",{className:`up-session-label${p.label?"":" up-session-id"}`,title:p.label?`${p.label}
|
|
100
|
+
${p.sessionId}`:p.sessionId,children:p.label??fp(p.sessionId,8)}),r.jsx("span",{className:"up-session-tokens",children:St(p.tokens)}),p.cost>0||p.priced?r.jsx("span",{className:"up-session-cost",title:p.models.join(", ")||void 0,children:lt(p.cost)}):r.jsx("span",{className:"up-session-cost up-unpriced",children:ua})]},`${p.agent}:${p.sessionId}`)}),!e&&n.map(p=>r.jsxs(OA,{sessionId:p.sessionId,agent:(d==null?void 0:d.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:Wl(p.state)}),r.jsx("span",{className:"up-session-label",children:p.label}),r.jsx("span",{className:"up-session-tokens",children:St(p.inputTokens+p.outputTokens)}),p.cost>0||p.priced?r.jsxs("span",{className:"up-session-cost",title:p.unpricedTokens>0?`${St(p.unpricedTokens)} tokens in this session are on an unpriced model, so this is a floor`:void 0,children:[lt(p.cost),p.unpricedTokens>0?"+":""]}):r.jsx("span",{className:"up-session-cost up-unpriced",children:ua})]},p.sessionId))]})]})}function yse(e){return e.claude&&e.codex?"Claude Code and Codex":e.claude?"Claude Code":e.codex?"Codex":null}const wse={claude:"Claude Code",codex:"Codex",opencode:"OpenCode",openclaw:"OpenClaw",copilot:"GitHub Copilot",pi:"pi-agent",zcode:"ZCode"};function L5(e){const t=e.toLowerCase(),n=Kt(wse,t);return n!==void 0?n:t?t[0].toUpperCase()+t.slice(1):""}function xse(e){return e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function yje(e,t=[]){const n=t.length?xse(t.map(L5)):yse(e);return n?`via ccusage · local ${n} logs`:"via ccusage · local agent logs"}function vse(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 bse(){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 pf=e=>e.toLocaleString(),PA=e=>new Date(e).toLocaleString(void 0,{month:"short",day:"numeric",year:"numeric",hour:"numeric",minute:"2-digit"});function kse({session:e,onClose:t}){var j,k;const[n,s]=g.useState("auto"),[a,o]=g.useState(0),[i,l]=g.useState(null),u=g.useRef(a),d=g.useRef(null),f=gt(t,{focusRef:d}),p=wt(t),m=i!=null&&i.ok&&((j=i.detail)==null?void 0:j.speed)===n?i.detail:void 0;g.useEffect(()=>{const v=new AbortController;l(null);const S=new URLSearchParams({agent:e.agent,id:e.sessionId,speed:n});return a!==u.current&&S.set("refresh","1"),u.current=a,fetch(`/api/ccusage/session?${S}`,{signal:v.signal}).then(async C=>{const _=await C.json();v.signal.aborted||l(_)}).catch(()=>{v.signal.aborted||l({ok:!1})}),()=>v.abort()},[e.agent,e.sessionId,n,a]);const w=(m==null?void 0:m.models.filter(v=>v.missingPricing))??[],x=m?[{name:"Input",n:m.inputTokens,color:"var(--usage-blue)"},{name:"Output",n:m.outputTokens,color:"var(--usage-purple)"},{name:"Cache read",n:m.cacheReadTokens,color:"var(--usage-teal)"},{name:"Cache write",n:m.cacheCreationTokens,color:"var(--usage-orange)"}]:[],b=x.reduce((v,S)=>v+S.n,0);return vt.createPortal(r.jsx("div",{className:"modal-backdrop",...p,role:"presentation",children:r.jsxs("div",{className:"modal su-modal",ref:f,role:"dialog","aria-modal":"true","aria-labelledby":"session-usage-title",children:[r.jsxs("header",{className:"modal-head",children:[r.jsxs("div",{className:"su-title",children:[r.jsx("h2",{id:"session-usage-title",children:"Session usage"}),r.jsx("span",{title:e.label,children:e.label})]}),r.jsxs("div",{className:"modal-actions",children:[r.jsx("button",{type:"button",className:"glyph-btn",onClick:()=>o(v=>v+1),disabled:!i,"aria-label":"Refresh session usage",title:"Refresh session usage",children:r.jsx(A5,{})}),r.jsx("button",{type:"button",className:"glyph-btn",ref:d,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:L5(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:v=>{l(null),s(v.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(bse,{}),i&&!i.ok&&r.jsxs("p",{className:"su-message",role:"status",title:i.error,children:[mse(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?lt(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:pf(m.totalTokens),children:St(m.totalTokens)})]})]}),r.jsxs("section",{"aria-labelledby":"session-tokens-title",children:[r.jsx("div",{className:"su-section-head",children:r.jsx("h3",{id:"session-tokens-title",children:"Token breakdown"})}),r.jsxs("div",{className:"su-cache-reuse",children:[r.jsx("span",{children:"Cached input reuse"}),r.jsx("strong",{children:((k=m.cacheReuse)==null?void 0:k.pct)!=null?`${m.cacheReuse.pct.toLocaleString(void 0,{maximumFractionDigits:1})}%`:"—"}),r.jsx("span",{className:"su-note",children:m.cacheReuse&&m.cacheReuse.measured>0?`${m.cacheReuse.measured} of ${m.cacheReuse.total} ${m.cacheReuse.unit} measured${m.cacheReuse.pct==null?" · no input tokens":""}`:"No cache measurements available"})]}),b>0&&r.jsx("div",{className:"su-composition","aria-hidden":"true",children:x.filter(v=>v.n>0).map(v=>r.jsx("span",{style:{width:`${v.n/b*100}%`,background:v.color}},v.name))}),r.jsx("dl",{className:"su-tokens",children:x.map(({name:v,n:S,color:C})=>r.jsxs("div",{children:[r.jsxs("dt",{children:[r.jsx("span",{className:"su-key",style:{background:C},"aria-hidden":"true"}),v]}),r.jsxs("dd",{title:pf(S),children:[St(S),r.jsx("span",{className:"su-share",children:b>0?`${(S/b*100).toLocaleString(void 0,{maximumFractionDigits:1})}%`:"—"})]})]},v))}),m.reasoningOutputTokens>0&&r.jsxs("p",{className:"su-note su-reasoning",children:[St(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(v=>r.jsxs("tr",{children:[r.jsxs("th",{scope:"row",title:v.model,children:[Qa(v.model),v.missingPricing&&r.jsx("span",{className:"su-unpriced",children:" · not priced"})]}),r.jsx("td",{title:pf(v.totalTokens),children:St(v.totalTokens)})]},v.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:PA(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:PA(m.lastActivity)})})]}),m.entries!=null&&r.jsxs("div",{children:[r.jsx("dt",{children:"Usage records"}),r.jsx("dd",{children:pf(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 mf=e=>`${e.id}:${e.windowSec}:${e.resetAt}`;function jse(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 Nse(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 JN({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 Ll=e=>new Date(e).toLocaleString(void 0,{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"}),DA=e=>new Date(e).toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit"});function Sse({series:e}){const t=jse(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:[Ll(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?Ll(n):DA(n)}),r.jsx("span",{children:e.windowSec>86400?Ll(s):DA(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 Cse({providers:e,accounts:t,onClose:n,instant:s=!1}){const[a,o]=g.useState(e.claude?"claude":"codex"),[i,l]=g.useState(null),[u,d]=g.useState(!0),[f,p]=g.useState(!1),[m,w]=g.useState(""),[x,b]=g.useState(0),[j,k]=g.useState(Date.now),v=g.useRef(!1),S=g.useRef(null),C=gt(n,{focusRef:S}),_=wt(n),R=t[a];g.useEffect(()=>{let F=!1,M=null;l(null),p(!1);const B=async()=>{if(M)return;if(!R){v.current=!1,d(!1);return}const P=new AbortController;M=P,v.current=!0;const q=window.setTimeout(()=>P.abort(),12e3);d(!0);try{const K=await fetch(`/api/quota/history?provider=${a}&account=${encodeURIComponent(R)}`,{signal:P.signal}),z=await K.json();if(!K.ok||!z.ok||!Array.isArray(z.series))throw new Error("History unavailable");F||(l(z.account===R?z:{...z,series:[]}),p(!1))}catch{F||p(!0)}finally{window.clearTimeout(q),M=null,F||(v.current=!1,d(!1))}};B();const T=window.setInterval(()=>{k(Date.now()),document.visibilityState==="visible"&&B()},6e4);return()=>{F=!0,M==null||M.abort(),window.clearInterval(T)}},[a,R,x]);const A=((i==null?void 0:i.series)??[]).slice().sort((F,M)=>M.resetAt-F.resetAt||F.windowSec-M.windowSec),I=A.find(F=>mf(F)===m)??A.find(F=>F.resetAt*1e3>j&&F.windowSec<=6*3600)??A[0],$=I==null?void 0:I.points.at(-1),U=()=>{_n(v.current)&&(v.current=!0,b(F=>F+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:C,role:"dialog","aria-modal":"true","aria-labelledby":"quota-history-title",children:[r.jsxs("header",{className:"modal-head",children:[r.jsx("h2",{id:"quota-history-title",children:"Quota history"}),r.jsxs("div",{className:"qh-header-actions",children:[r.jsx("button",{type:"button",className:"glyph-btn","aria-label":"Refresh quota history",title:"Read recorded quota history",...qn(u),onClick:U,children:u?"…":r.jsx(A5,{})}),r.jsx("button",{type:"button",ref:S,className:"glyph-btn",onClick:n,"aria-label":"Close quota history",children:"×"})]})]}),r.jsxs("div",{className:"modal-body qh-body","aria-busy":u,children:[r.jsxs("div",{className:"qh-controls",children:[r.jsx("div",{className:"qh-providers",role:"group","aria-label":"Quota provider",children:["claude","codex"].filter(F=>e[F]).map(F=>r.jsx("button",{type:"button",className:"qh-provider","aria-pressed":a===F,onClick:()=>{o(F),w("")},children:F==="claude"?"Claude":"Codex"},F))}),A.length>0&&r.jsxs("label",{className:"qh-window",children:["Window",r.jsx("select",{"aria-label":"Quota window",value:I?mf(I):"",onChange:F=>w(F.target.value),children:A.map(F=>r.jsxs("option",{value:mf(F),children:[F.label," · ",Ll(F.resetAt*1e3)]},mf(F)))})]})]}),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."]}),I&&$?r.jsxs("div",{className:"qh-result read-result",children:[r.jsxs("div",{className:"qh-summary",children:[r.jsxs("strong",{children:[Math.round(100-$.pct),"% remaining"]}),r.jsxs("span",{title:Ll($.t),children:["Captured ",Nse($.t,j),I.resetAt*1e3<=j&&" · window ended"]})]}),r.jsx(Sse,{series:I}),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 (",I.points.length,")"]}),r.jsxs("table",{children:[r.jsx("caption",{children:I.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:I.points.slice(-50).reverse().map(F=>r.jsxs("tr",{children:[r.jsx("td",{children:Ll(F.t)}),r.jsxs("td",{children:[(100-F.pct).toLocaleString(void 0,{maximumFractionDigits:1}),"%"]})]},F.t))})]})]})]}):!f&&(u&&R?r.jsx(JN,{kind:"quota",title:"Reading quota history…",note:"Loading this account’s saved quota readings."}):r.jsx("p",{className:"qh-message",role:"status",children:R?"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 _se=6e4,Ese=2e4;function Tse(e){const[t,n]=g.useState(null),[s,a]=g.useState(!1),o=g.useRef(null),i=g.useRef(!1),l=async(d=!1)=>{if(!(d&&!_n(i.current))){d&&(i.current=!0,a(!0));try{const p=await fetch(d?"/api/quota?refresh=1":"/api/quota",{signal:AbortSignal.timeout(Ese)});p.ok&&n(await p.json())}catch{}finally{d&&(i.current=!1,a(!1))}}};return g.useEffect(()=>{if(e)return l(!0),o.current=window.setInterval(()=>l(!1),_se),()=>{o.current!=null&&window.clearInterval(o.current)}},[e]),{quota:t,loading:s,refresh:()=>{e&&l(!0)}}}const Ase=6e4;function Rse(e){const[t,n]=g.useState(null),[s,a]=g.useState(!1),o=g.useRef(null),i=g.useRef(!1),l=async(d=!1)=>{if(!(d&&!_n(i.current))){d&&(i.current=!0,a(!0));try{const p=await fetch(d?"/api/codex-quota?refresh=1":"/api/codex-quota");p.ok&&n(await p.json())}catch{}finally{d&&(i.current=!1,a(!1))}}};return g.useEffect(()=>{if(e)return l(!0),o.current=window.setInterval(()=>l(!1),Ase),()=>{o.current!=null&&window.clearInterval(o.current)}},[e]),{data:t,loading:s,refresh:()=>{e&&l(!0)}}}const FA=6e4;function Mse(e,t,n){const[s,a]=g.useState(null),[o,i]=g.useState(!1),[l,u]=g.useState(0),d=g.useRef(0);g.useEffect(()=>{const p=()=>document.visibilityState==="visible",m=()=>{p()&&u(b=>b+1)},w=window.setInterval(m,FA),x=()=>{p()&&Date.now()-d.current>=FA&&u(b=>b+1)};return document.addEventListener("visibilitychange",x),()=>{window.clearInterval(w),document.removeEventListener("visibilitychange",x)}},[]);const f=g.useRef(t);return g.useEffect(()=>{let p=!0;const m=t!==f.current;f.current=t;const w=e,x=Ine(w);return i(!0),fetch(`/api/ccusage?since=${x}${m?"&refresh=1":""}`).then(b=>b.ok?b.json():null).then(b=>{!p||!(b!=null&&b.ok)||(d.current=Date.now(),a({period:w,data:b,baseline:n()}))}).catch(()=>{}).finally(()=>{p&&i(!1)}),()=>{p=!1}},[e,t,l]),{...qne(s,e),loading:o}}const $se=e=>1-Math.pow(1-e,5),I5=420;function Lse(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 Ise(e,t,n,s=I5){return n>=s?t:n<=0?e:e+(t-e)*$se(n/s)}function O5(){return typeof matchMedia=="function"&&matchMedia("(prefers-reduced-motion: reduce)").matches}function BA(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??O5,u=s.hidden??(()=>typeof document=="object"&&document.hidden===!0);if(l()||u()||!Lse(e,t))return n(t),()=>{};const d=a();let f=0,p=!0;const m=()=>{if(!p)return;const w=a()-d;n(Ise(e,t,w)),w<I5&&(f=o(m))};return f=o(m),()=>{p=!1,f&&i(f)}}const Ose=typeof window>"u"?g.useEffect:g.useLayoutEffect;function Go(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]),Ose(()=>{!t||O5()||(a.current=0,s(0))},[]),g.useEffect(()=>{if(o.current){if(o.current=!1,t)return BA(0,e,l=>{a.current=l,s(l)});a.current=e,s(e);return}return BA(a.current,e,l=>{a.current=l,s(l)})},[e]),n}function P5(e,t,n){const s=Dse*Math.max(1,n/F5);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 qA={samples:[],last:new Map,watched:0},D5=10*6e4,Pse=6e4,F5=5e3,Dse=20;function Fse(e,t,n){const s=e.samples[e.samples.length-1];if(s&&t-s.t<F5)return e;const a=e.watched+P5(e.last,n,s?t-s.t:0),o=e.samples.filter(i=>t-i.t<=D5);return o.push({t,watched:a}),{samples:o,last:n,watched:a}}function Bse(e,t,n){const s=e.samples[0];if(!s)return null;const a=t-s.t;if(a<Pse)return null;const o=e.samples[e.samples.length-1].t,i=e.watched+P5(e.last,n,t-o)-s.watched;return i>0?{spent:i,spanSec:a/1e3,spanMin:Math.min(D5/6e4,Math.ceil(a/6e4))}:null}function qse(e,t,n){const s=g.useRef(qA),a=g.useRef(null);return g.useMemo(()=>{const o=eQ(e.agents.values()),i=YJ(e.agents.values());a.current!==n&&(a.current=n,s.current=qA);const l=ej(e.agents.values(),t);n!=null&&(s.current=Fse(s.current,t,l));const u=n==null?null:Bse(s.current,t,l),d=u?{label:yN(u.spent,u.spanSec),spanMin:u.spanMin}:null;return{byModel:o,totalCost:i.cost,totalTokens:i,burnRate:d}},[e,e.revision,t,n])}const Use=3e4;function QN(){const[e,t]=g.useState(()=>Math.floor(Date.now()/1e3));return g.useEffect(()=>{const n=window.setInterval(()=>t(Math.floor(Date.now()/1e3)),Use);return()=>window.clearInterval(n)},[]),e}function UA(e){return(typeof e.cost=="number"?e.cost:e.cost.total)>0||e.inputTokens+e.outputTokens>0}function Wse(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 Hse(e){return e.claude&&e.codex?"Refresh Claude + Codex quota":e.codex?"Refresh Codex quota":"Refresh Claude quota"}function zse(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 Vse(e){const t=new Map;for(const n of e)n.kind!=="root"||!n.sessionId||t.set(n.sessionId,n.state);return t}function Gse(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} ${jD(n.sessionId,s)}`}:n})}const B5=120,WA=24,Kse=4,q5={usage:"agent-dag.usagePanelPlace",machine:"agent-dag.machinePanelPlace"};function Yse(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 HA(e,t,n){return Math.max(t,Math.min(e,n))}function Xse(e,t){return Math.abs(e.left-t.left)<=WA&&Math.abs(e.top-t.top)<=WA}function Zse(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 Jse=8;function Qse(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-Jse;return o>=B5?{upper:a,cap:o}:null}function sj(){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(mm).matches)return;const n=a=>({left:a.offsetLeft,top:a.offsetTop,width:a.offsetWidth}),s=Qse(n(e),n(t));s&&((s.upper==="a"?e:t).style.maxHeight=`${s.cap}px`)}let cw=0;function gf(){cw||(cw=requestAnimationFrame(()=>{cw=0,sj()}))}function ere(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 U5(e){const t=lc(mm),[n,s]=g.useState(()=>Zse(nt(e))),a=g.useRef(null),o=g.useRef(null),i=g.useRef(null);g.useEffect(()=>()=>{var C;return(C=i.current)==null?void 0:C.call(i)},[]);const l=C=>{C?st(e,JSON.stringify(C)):vs(e),s(C)},u=C=>{const _=a.current;_&&(C?(_.style.left=`${C.left}px`,_.style.top=`${C.top}px`,_.style.right="auto"):(_.style.removeProperty("left"),_.style.removeProperty("top"),_.style.removeProperty("right")),sj())},d=()=>{var _;const C=a.current;C==null||C.removeAttribute("data-moving"),(_=i.current)==null||_.call(i),i.current=null,o.current=null},f=C=>{const _=C.getAttribute("data-place");if(!_)return C.getBoundingClientRect();C.removeAttribute("data-place");const R=C.getBoundingClientRect();return C.setAttribute("data-place",_),R},p=C=>C instanceof Element&&C.closest("button, a, input, select, textarea, [role='button']")!==null,m=C=>{const _=a.current;if(!_||C.button!==0||p(C.target))return;C.preventDefault(),C.currentTarget.setPointerCapture(C.pointerId);const R=_.getBoundingClientRect();o.current={id:C.pointerId,x:C.clientX,y:C.clientY,moved:!1,start:R,home:R,room:null,at:{left:R.left,top:R.top}}},w=C=>{const _=o.current,R=a.current;if(!_||!R||C.pointerId!==_.id)return;const A=C.clientX-_.x,I=C.clientY-_.y;if(!_.moved){if(Math.hypot(A,I)<Kse)return;_.moved=!0,_.home=f(R),_.room=ere(_.home),document.querySelectorAll("[data-front]").forEach(M=>M.removeAttribute("data-front")),R.setAttribute("data-front",""),R.setAttribute("data-moving","");const F=M=>{M.key==="Escape"&&(M.preventDefault(),M.stopPropagation(),u(null),d())};window.addEventListener("keydown",F,!0),i.current=()=>window.removeEventListener("keydown",F,!0)}const $=_.start.width,U=_.room;_.at={left:HA(_.start.left+A,U.side,U.w-U.side-$),top:HA(_.start.top+I,U.top,U.h-B5)},u(_.at)},x=C=>{const _=o.current;!_||C.pointerId!==_.id||(d(),_.moved&&(u(null),l(Xse(_.at,_.home)?null:Yse(_.at.left,_.at.top,_.start.width,_.room.w))))},b=()=>{o.current&&(u(null),d())},j=C=>{p(C.target)||!n||l(null)},k=n&&!t?n:null;g.useLayoutEffect(()=>{sj()},[k==null?void 0:k.edge,k==null?void 0:k.x,k==null?void 0:k.y]),g.useEffect(()=>{window.addEventListener("resize",gf);const C=document.querySelector(".app main"),_=C&&typeof ResizeObserver<"u"?new ResizeObserver(gf):null;return C&&(_==null||_.observe(C)),()=>{window.removeEventListener("resize",gf),_==null||_.disconnect(),gf()}},[]);const v={ref:a,"data-place":k==null?void 0:k.edge,style:k?{"--place-x":`${k.x}px`,"--place-y":`${k.y}px`}:void 0};return{place:k,panel:v,grip:t?{}:{"data-grip":"",title:"Drag to move · double-click to put it back",onPointerDown:m,onPointerMove:w,onPointerUp:x,onPointerCancel:b,onLostPointerCapture:b,onDoubleClick:j}}}function tre({state:e,now:t,providers:n,incidents:s=[],leaving:a,onClose:o,liveSince:i=null}){const l=An(),u=U5(q5.usage),[d,f]=g.useState(null),[p,m]=g.useState(null),w=g.useMemo(()=>new Map([...e.agents.values()].filter(Re=>Re.kind==="root").map(Re=>[Re.sessionId,Re.provider??"claude"])),[e,e.revision]),{quota:x,loading:b,refresh:j}=Tse(n.claude),{data:k,loading:v,refresh:S}=Rse(n.codex),C=LA("claude",n.claude?x==null?void 0:x.historyAccount:void 0),_=LA("codex",n.codex?k==null?void 0:k.historyAccount:void 0),R=QN(),{byModel:A,totalCost:I,totalTokens:$}=qse(e,t,i),U=g.useMemo(()=>tQ(e.agents.values()),[e,e.revision]),[F,M]=g.useState(Wne);g.useEffect(()=>{Hne(F)},[F]);const[B,T]=g.useState(zne);g.useEffect(()=>{Vne(B)},[B]);const[P,q]=g.useState(0),K=g.useRef(()=>new Map);K.current=()=>i==null?null:ej(e.agents.values(),t);const z=g.useCallback(()=>K.current(),[]),{data:H,shown:D,stale:O,loading:V,baseline:Z}=Mse(F,P,z),W=H!=null,X=V&&O,Y=g.useMemo(()=>zse(e.agents.values()),[e,e.revision]),J=g.useMemo(()=>Vse(e.agents.values()),[e,e.revision]),Q=g.useMemo(()=>W?YN(H):[],[H,W]),te=g.useMemo(()=>W?Gse(Dne(H,Y).slice(0,12)):[],[H,W,Y]),le=g.useMemo(()=>XN(H),[H]),de=g.useMemo(()=>Fne(H,le.cost),[H,le.cost]),oe=C5(D,F),re=g.useMemo(()=>W?$ne(Z,ej(e.agents.values(),t)):Q1,[e,e.revision,Z,W,t]),he=Une(H,{...$,cost:I},re),fe=he.hasCost,$e=he.tokenSum,ye=Go(he.cost),ge=Go(he.inputTokens),je=Go(he.outputTokens),Le=Go(he.cacheReadTokens),ke=Go(he.cacheCreateTokens),Ie=A.filter(UA),De=U.filter(UA),Ue=Wse(W,Q,Ie,re.unpricedTokens),Ke=b||v,we=()=>{j(),S(),q(Re=>Re+1)},Fe=Hse(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:Re=>m(Re.detail===0?"keyboard":"pointer"),children:r.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"1.6",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:r.jsx("path",{d:"M4 4v16h16M8 8l4 4 4-3 4 7"})})}),(n.claude||n.codex)&&r.jsx("button",{type:"button",className:"glyph-btn up-refresh-btn",onClick:we,...qn(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:En("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(use,{quota:x,quotaLoading:b,nowSec:R,weekEnds:C,incident:s.find(Re=>Re.provider==="claude")}),n.codex&&r.jsx(dse,{codexQuota:k,codexLoading:v,nowSec:R,weekEnds:_,incident:s.find(Re=>Re.provider==="codex")}),W&&r.jsx(fse,{period:F,rangePending:X,setPeriod:M}),$e>0?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"up-total",title:W?void 0:iA(l),children:[r.jsx("span",{className:!fe&&Ue?"up-total-value up-unpriced":"up-total-value",children:fe?r.jsxs(r.Fragment,{children:[lt(ye),Ue&&"+"]}):nj(0,Ue)}),fe&&r.jsx("span",{className:"up-total-label",children:W?oe:XJ})]}),fe&&r.jsxs(r.Fragment,{children:[r.jsxs("p",{className:"up-source",children:["Local estimate · ",W?"ccusage":"live sessions"]}),he.showCostBar&&r.jsx(ZN,{cost:I})]}),r.jsxs("div",{className:"up-tokens-row",title:W?void 0:iA(l),children:[r.jsxs("span",{className:"up-tok",children:[r.jsx("span",{className:"up-k",children:"in"}),St(ge)]}),r.jsxs("span",{className:"up-tok",children:[r.jsx("span",{className:"up-k",children:"out"}),St(je)]}),he.cacheReadTokens>0&&r.jsxs("span",{className:"up-tok",children:[r.jsx("span",{className:"up-k",children:"cache r"}),St(Le)]}),he.cacheCreateTokens>0&&r.jsxs("span",{className:"up-tok",children:[r.jsx("span",{className:"up-k",children:"cache c"}),St(ke)]}),!fe&&r.jsx("span",{className:"up-tok up-scope",children:W?oe:ZJ})]}),(W?Q.length:Ie.length)>0&&r.jsx(hse,{fromRange:W,rangeModelRows:Q,boardModelRows:Ie}),W&&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."]})]}),(W?te.length:De.length)>0&&r.jsx(gse,{fromRange:W,rangeSessionRows:te,boardSessionRows:De,boardStates:J,sessionsOpen:B,setSessionsOpen:T,periodNoun:oe,sessionScale:de,onOpenSession:f,boardProviders:w}),Ue&&r.jsxs("div",{className:"up-hint",children:["“",ua,"” 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:W?(D??F)==="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(ld,{film:"usage"})}),d&&r.jsx(kse,{session:d,onClose:()=>f(null)},`${d.agent}:${d.sessionId}`),p&&r.jsx(Cse,{providers:n,instant:p==="keyboard",accounts:{claude:x==null?void 0:x.historyAccount,codex:k==null?void 0:k.historyAccount},onClose:()=>m(null)})]})}function uw(e){return e<9.95?e.toFixed(1):String(Math.round(e))}function eS(e){const t=Number.isFinite(e)?Math.max(0,e):0;return t<50?{value:"0",unit:"KB/s"}:t<999500?{value:uw(t/1e3),unit:"KB/s"}:t<9995e5?{value:uw(t/1e6),unit:"MB/s"}:{value:uw(t/1e9),unit:"GB/s"}}function km(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 cd(e){return e.unit?e.unit==="%"||e.unit==="°C"?`${e.value}${e.unit}`:`${e.value} ${e.unit}`:e.value}const nre="thermal:Throttling";function tS(e){const t="timeHeld"in e?e.timeHeld:100-e.speedLimit;return Math.max(0,Math.min(100,t))}function sre(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[nre]=tS(e.thermal.throttle)),t}function Ou(e,t){return t==="B/s"?cd(eS(e)):t==="ms"?cd(km(e)):t==="C"?`${Math.round(e)}°`:t==="%"?`${Math.round(e)}%`:e.toFixed(2)}function yf(e,t){return t==="B/s"||t==="ms"||!Number.isInteger(e)?Ou(e,t):t==="C"?`${e}°`:t==="%"?`${e}%`:`${e}`}function rre(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 are(e,t,n){return e>=n?"hot":e>=t?"warn":"calm"}function ore(e,t,n=Date.now()){const s=tS(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 ${zA(t.lastMs,n)}`:`at full speed · held to ${100-t.peak}% ${zA(t.lastMs,n)}`:"running at full speed, and never held back"}}function zA(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 ire(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 lre(e){var s,a;const t=(s=e.thermal)==null?void 0:s.throttle,n=t?tS(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 cre(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 ure=3e3;function dre(){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 d=await u.json();s&&(d!=null&&d.ok)&&t(d)}catch{}},o=()=>{n.current==null&&(a(),n.current=window.setInterval(a,ure))},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 hre(e,t){return!e||e.key!==t?"none":e.dir==="asc"?"ascending":"descending"}function yl({col:e,label:t,note:n,sort:s,next:a,onSort:o,className:i}){const l=hre(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 dw(e,t){return t==="B/s"?eS(e):t==="ms"?km(e):{value:String(e),unit:t==="C"?"°C":t}}const Qt={l:30,r:6,t:6,b:2},qa={l:0,r:0,t:2,b:1},jm=104,fre=64;function Ks(e,t=100,n=jm,s=Qt){const a=n-s.t-s.b;return s.t+a*(1-Math.max(0,Math.min(t,e))/t)}function W5(e,t){return t??[e[0].t,e[e.length-1].t]}function nS(e,[t,n],s,a=Qt){const o=s-a.l-a.r,i=n-t;return a.l+(i>0?o*(e-t)/i:o/2)}function H5(e,t,n,s=100,a=jm,o=Qt,i){if(!e.length)return"";const l=W5(e,i),u=p=>nS(p,l,t,o);let d="",f=null;for(const p of e){const m=f&&p.t-f.t<=n*2?"L":"M";d+=`${m}${u(p.t).toFixed(1)} ${Ks(p.v,s,a,o).toFixed(1)}`,f=p}return d}function z5(e,t,n,s=100,a=jm,o=Qt,i){if(e.length<2)return"";const l=a-o.b,u=W5(e,i),d=w=>nS(w,u,t,o);let f="",p=[];const m=()=>{if(p.length>=2){let w=`M${d(p[0].t).toFixed(1)} ${l}`;for(const x of p)w+=`L${d(x.t).toFixed(1)} ${Ks(x.v,s,a,o).toFixed(1)}`;f+=`${w}L${d(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 pre(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 V5(e,t,n){return n!=null&&e>=n?"hot":t!=null&&e>=t?"warn":""}function mre(e,t,n=s=>za(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 VA(e,t){return t==null||!Number.isFinite(t)||t<=0||!Number.isFinite(e)||e<0?null:`${(e/t).toFixed(1)}× the core count`}function za(e){const t=new Date(e);return`${String(t.getHours()).padStart(2,"0")}:${String(t.getMinutes()).padStart(2,"0")}`}function sS(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 gre({group:e,title:t,liveNote:n,onClose:s}){const a=gt(s),o=wt(s),[i,l]=g.useState(null);g.useEffect(()=>{let m=!0;const w=async()=>{try{const b=await fetch(`/api/system/history?group=${e}`);if(!b.ok)return;const j=await b.json();m&&(j!=null&&j.ok)&&l(j)}catch{}};w();const x=window.setInterval(w,2e4);return()=>{m=!1,window.clearInterval(x)}},[e]);const u=(i==null?void 0:i.series)??[],[d,f,p]=g.useMemo(()=>{let m=1/0,w=0;for(const x of u)x.points.length&&(m=Math.min(m,x.points[0].t),w=Math.max(w,x.points[x.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&&d>0&&r.jsxs("span",{className:"hist-since",children:["since ",za(d)," · ",sS(d,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(JN,{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(yre,{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 yre({series:e,stepMs:t,domain:n}){const s=g.useRef(null),[a,o]=g.useState(560),[i,l]=g.useState(null),[u,d]=g.useState(null);g.useEffect(()=>{const O=s.current;if(!O||typeof ResizeObserver>"u")return;const V=new ResizeObserver(([Z])=>o(Math.max(160,Z.contentRect.width)));return V.observe(O),()=>V.disconnect()},[]);const{points:f,unit:p,warnAt:m,critAt:w,label:x,top:b,restsAtZero:j,changes:k,cores:v}=e,S=j?fre:jm,{now:C,peak:_}=pre(f),R=C!=null?dw(C,p):null,A=_!=null?dw(_,p):null,I=x==="Throttling"?mre(f,t):null;let $=null;if(_!=null&&f.length>1)for(let O=f.length-1;O>=0&&!$;O--)f[O].v===_&&($=f[O]);const U=u!=null?f.find(O=>O.t===u)??null:null,F=i!=null?f[i]:U,M=F?VA(F.v,v):null,[B,T]=n??(f.length?[f[0].t,f[f.length-1].t]:[0,0]),P=O=>nS(O,[B,T],a),q=O=>{if(f.length<2)return null;const V=O.currentTarget.getBoundingClientRect(),Z=(O.clientX-V.left-Qt.l)/Math.max(1,V.width-Qt.l-Qt.r),W=B+(T-B)*Math.max(0,Math.min(1,Z));let X=0;for(let Y=1;Y<f.length;Y++)Math.abs(f[Y].t-W)<Math.abs(f[X].t-W)&&(X=Y);return X},K=O=>{const V=q(O);V!=null&&l(V)},z=O=>{const V=q(O);if(V==null)return;const Z=f[V].t;d(W=>W===Z?null:Z)},H=_!=null&&A&&r.jsxs(r.Fragment,{children:[r.jsx("b",{className:V5(_,m,w),children:A.value}),r.jsxs("span",{children:[A.unit," peak"]})]}),D=_!=null?VA(_,v):null;return r.jsxs("section",{className:"hist-series","aria-label":`${x} history`,children:[r.jsxs("div",{className:"hist-head",children:[r.jsx("span",{className:"hist-label",children:x}),r.jsxs("span",{className:"hist-stats",children:[R&&r.jsxs(r.Fragment,{children:[r.jsx("b",{children:R.value}),r.jsxs("span",{children:[R.unit," now"]})]}),H&&($?r.jsx("button",{type:"button",className:"hist-peak",onClick:()=>d($.t),title:"Show when it peaked",children:H}):H)]})]}),r.jsx("div",{className:"hist-plot",ref:s,children:r.jsxs("svg",{className:"hist-chart",width:"100%",height:S,viewBox:`0 0 ${a} ${S}`,preserveAspectRatio:"none",role:"img","aria-label":R==null||A==null?`${x}: nothing measured yet`:`${x}: ${cd(R)} now, peak ${cd(A)}${$?` at ${za($.t)}`:""}${D?` (${D})`:""}, over ${sS(f[0].t,f[f.length-1].t)}`,onPointerMove:K,onPointerLeave:()=>l(null),onClick:z,children:[[["warn",m],["hot",w]].map(([O,V])=>V==null||V>b?null:r.jsxs("g",{children:[r.jsx("line",{className:`hist-rule ${O}`,x1:Qt.l,x2:a-Qt.r,y1:Ks(V,b,S),y2:Ks(V,b,S)}),r.jsx("text",{className:`hist-rule-tag ${O}`,x:2,y:Ks(V,b,S)+3,children:V})]},O)),r.jsx("line",{className:"hist-floor",x1:Qt.l,x2:a-Qt.r,y1:S-Qt.b,y2:S-Qt.b}),(k??[]).filter(O=>O.from!=null&&f.length>1&&O.t>=B&&O.t<=T).map(O=>r.jsx("line",{className:"hist-mark",x1:P(O.t),x2:P(O.t),y1:Qt.t,y2:S-Qt.b},O.t)),r.jsx("path",{className:"hist-area",d:z5(f,a,t,b,S,Qt,[B,T])}),r.jsx("path",{className:"hist-line",d:H5(f,a,t,b,S,Qt,[B,T])}),f.length===1&&r.jsx("circle",{className:"hist-dot",cx:P(f[0].t),cy:Ks(f[0].v,b,S),r:3}),F&&r.jsxs("g",{children:[r.jsx("line",{className:"hist-cross",x1:P(F.t),x2:P(F.t),y1:Qt.t,y2:S-Qt.b}),r.jsx("circle",{className:"hist-dot",cx:P(F.t),cy:Ks(F.v,b,S),r:3})]})]})}),r.jsxs("div",{className:"hist-axis",children:[F?r.jsxs("span",{className:"hist-at",children:[za(F.t)," — ",(()=>{const O=dw(F.v,p);return r.jsxs(r.Fragment,{children:[r.jsx("b",{children:O.value}),O.unit==="%"||O.unit==="°C"||!O.unit?O.unit:` ${O.unit}`]})})(),M&&` · ${M}`]}):r.jsxs(r.Fragment,{children:[r.jsx("span",{children:f.length?za(B):""}),r.jsx("span",{children:f.length?za(T):""})]}),U&&r.jsx("button",{type:"button",className:"glyph-btn hist-unpin",onClick:()=>d(null),"aria-label":"Stop showing this reading",title:"Stop showing this reading",children:"×"})]}),I&&r.jsx("div",{className:"hist-note",children:I}),k==null?void 0:k.slice(-3).map(O=>r.jsx("div",{className:"hist-note hist-route",children:O.from==null?`Since ${za(O.t)} — ${O.label}`:`${za(O.t)} — ${O.label.charAt(0).toUpperCase()+O.label.slice(1)}`},O.t))]})}const GA=["cores","memory","load","thermal"],Bo=116,hr=24,wre=60,xre=6e4;function vre(e){return e.points.length?e.restsAtZero?e.points.some(t=>t.v>0):!0:!1}function bre(e){return e.unit==="C"?`${e.label} temp`:e.key==="mem:physical"?"Physical RAM":e.key==="mem:swap"?`${e.label} memory`:e.label}function kre(e,t=wre){return e.points.length<=t?e:{...e,points:e.points.slice(-t)}}function jre({sys:e}){const[t,n]=g.useState({});g.useEffect(()=>{let i=!0;const l=async()=>{const d=await Promise.all(GA.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 d)w!=null&&w.ok&&(p[m]=w);return p})};l();const u=setInterval(()=>void l(),xre);return()=>{i=!1,clearInterval(u)}},[]);const s=g.useMemo(()=>sre(e),[e]),a=g.useMemo(()=>GA.flatMap(i=>{const l=t[i];return l?l.series.filter(vre).map(u=>({series:kre(u),stepMs:l.stepMs})):[]}),[t]),o=g.useMemo(()=>{let i=1/0,l=-1/0;for(const{series:u}of a){const d=u.points;d.length&&(i=Math.min(i,d[0].t),l=Math.max(l,d[d.length-1].t))}return Number.isFinite(i)?sS(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(Nre,{series:i,stepMs:l,now:s[i.key],span:o},i.key))}):null}function Nre({series:e,stepMs:t,now:n,span:s}){var w;const{points:a,top:o,unit:i,warnAt:l,critAt:u}=e,d=bre(e),f=n??((w=a[a.length-1])==null?void 0:w.v),p=f==null?"":V5(f,l,u),m=Math.max(...a.map(x=>x.v));return r.jsxs("div",{className:`pl-cell${p?` ${p}`:""}`,title:[`${d} · peak ${Ou(m,i)} over the last ${s}`,l!=null?`over ${yf(l,i)} is uncomfortable`:"",u!=null?`over ${yf(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:d}),r.jsx("span",{className:"pl-cell-now",children:f==null?"—":Ou(f,i)})]}),r.jsxs("svg",{className:"pl-spark",width:Bo,height:hr,viewBox:`0 0 ${Bo} ${hr}`,preserveAspectRatio:"none","aria-hidden":!0,children:[r.jsx("line",{className:"pl-spark-floor",x1:0,x2:Bo,y1:hr-qa.b,y2:hr-qa.b}),r.jsx("path",{className:"pl-spark-area",d:z5(a,Bo,t,o,hr,qa)}),l!=null&&r.jsx("line",{className:"pl-rule warn",x1:0,x2:Bo,y1:Ks(l,o,hr,qa),y2:Ks(l,o,hr,qa)}),u!=null&&r.jsx("line",{className:"pl-rule hot",x1:0,x2:Bo,y1:Ks(u,o,hr,qa),y2:Ks(u,o,hr,qa)}),r.jsx("path",{className:"pl-spark-line",d:H5(a,Bo,t,o,hr,qa)})]}),r.jsxs("span",{className:"vis-hidden",children:["peak ",Ou(m,i)," over the last ",s,l!=null&&`, uncomfortable over ${yf(l,i)}`,u!=null&&`, the machine acts over ${yf(u,i)}`]})]})}const G5={key:"cpu",dir:"desc"};function Sre(e,t){return e.key===t?{...e,dir:e.dir==="asc"?"desc":"asc"}:{key:t,dir:t==="name"||t==="user"?"asc":"desc"}}function Cre(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 d=o.user??"",f=i.user??"";return!d||!f?d===f?0:d?-1:1:n*d.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 _re=4e3;function Ere(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 Tre(){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=>Ere(l,i))}catch{}};s();const a=window.setInterval(s,_re);return()=>{n=!1,window.clearInterval(a)}},[]),e}function Are(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 Rre({sys:e,onClose:t}){cn("process-list");const n=gt(t),s=wt(t),[a,o]=g.useState(G5),i=Tre();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(Mre,{read:i,sort:a,onSort:o,sys:e,onClose:t})})}),document.body)}function Mre({read:e,sort:t,onSort:n,sys:s,onClose:a}){const o=e?Cre(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(JN,{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(cl,{col:"cpu",label:"cpu",sort:t,onSort:n}),r.jsx(cl,{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(cl,{col:"threads",label:"threads",sort:t,onSort:n}),r.jsx(cl,{col:"uptime",label:"up",sort:t,onSort:n}),r.jsx(cl,{col:"user",label:"user",sort:t,onSort:n}),r.jsx("th",{scope:"col",className:"pl-pid-h",children:"pid"}),r.jsx(cl,{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:Jn(i.rssBytes)}),r.jsx("td",{className:"sd-num sd-dim",children:i.threads??"—"}),r.jsx("td",{className:"sd-num sd-dim",children:Are(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(jre,{sys:s})]})]})}function cl(e){return r.jsx(yl,{...e,next:(t,n)=>Sre(t??G5,n)})}function rj({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 $re=300;function ud({group:e,title:t,action:n,label:s,value:a,hint:o,liveNote:i,children:l}){const[u,d]=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=x=>{var b;m(),!(x.detail>1||((b=window.getSelection())==null?void 0:b.isCollapsed)===!1)&&(p.current=window.setTimeout(()=>{var j,k;p.current=null,((j=window.getSelection())==null?void 0:j.isCollapsed)!==!1&&((k=f.current)==null||k.focus({preventScroll:!0}),d(!0))},$re))};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:x=>{x.stopPropagation(),m(),d(!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(gre,{group:e,title:t,liveNote:i,onClose:()=>d(!1)})]})}function dd({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 Lre({network:e}){const{down:t,up:n,api:s,route:a}=e,[o,i]=g.useState(!1),l=s&&s.ms!=null?km(s.ms):null,u=t!=null&&n!=null;return r.jsxs("div",{className:"sd-section",role:"group","aria-label":"Network",children:[r.jsxs(ud,{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(([d,f])=>{const p=eS(f);return r.jsx(rj,{value:p.value,unit:p.unit,cap:d},d)}),l&&r.jsx(rj,{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(d=>!d),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(Ire,{route:a,api:s,onClose:()=>i(!1)})]})]})}function Ire({route:e,api:t,onClose:n}){return r.jsxs(ac,{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 ",cre(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`:`${cd(km(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 wf({label:e,value:t,pct:n}){return n!=null?r.jsx(dd,{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 Ore({devices:e}){return r.jsx(r.Fragment,{children:e.map((t,n)=>{const s=t.memoryUsed,a=t.memoryTotal,o=s!=null&&a!=null?`${Jn(s)} of ${Jn(a)}`:s!=null?`${Jn(s)} used`:a!=null?`${Jn(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(wf,{label:"Utilization",value:t.utilization==null?"Unavailable":`${t.utilization}%`,pct:t.utilization??void 0}),r.jsx(wf,{label:"Video memory",value:o,pct:s!=null&&a!=null&&a>0?s/a*100:void 0}),r.jsx(wf,{label:"Temperature",value:t.temperature==null?"Unavailable":`${t.temperature} °C`}),r.jsx(wf,{label:"Power",value:t.power==null?"Unavailable":`${t.power.toFixed(1)} W`})]},t.id)})})}function KA({usageOpen:e,leaving:t,sub:n,flag:s,onClose:a,children:o}){const i=U5(q5.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 Pre({usageOpen:e,leaving:t,onClose:n}){const s=dre();if(!s||s.cpu==null||!s.memory)return r.jsx(KA,{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:d,platform:f,thermal:p,network:m,cpu:w}=s;return r.jsxs(KA,{usageOpen:e,leaving:t,sub:`up ${ire(d)} · ${u} cores`,flag:lre(s),onClose:n,children:[r.jsx(Dre,{cpu:w,perCore:i,loadavg:l,cores:u}),r.jsx(Fre,{memory:a,swap:o,platform:f}),m&&r.jsx(Lre,{network:m}),r.jsx(Ore,{devices:s.gpus??[]}),r.jsx(Bre,{thermal:p}),r.jsx(qre,{sys:s})]})}function Dre({cpu:e,perCore:t,loadavg:n,cores:s}){const a=rre(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(ud,{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(ud,{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(rj,{value:i.toFixed(2),cap:["1m","5m","15m"][l]},l))}),a&&r.jsx("div",{className:"sd-note",children:a})]})]})}function Fre({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(ud,{group:"memory",title:"Memory history",action:"Show memory history",label:"Memory",children:[r.jsx(dd,{label:"Physical",value:r.jsxs(r.Fragment,{children:[r.jsx("b",{children:Jn(s)})," of ",Jn(e.total)]}),pct:e.usedPct,tone:e.usedPct>=90?"warn":"calm",note:`${Jn(e.available)} available`}),t&&t.total>0&&r.jsx(dd,{label:a,value:r.jsxs(r.Fragment,{children:[r.jsx("b",{children:Jn(t.used)})," of ",Jn(t.total)]}),pct:o,tone:o>=90?"warn":"calm"})]})})}function Bre({thermal:e}){if(!e)return null;const t=e.throttle?ore(e.throttle,e.heldBack):null;return r.jsx("div",{className:"sd-section",role:"group","aria-label":"Thermal",children:r.jsxs(ud,{group:"thermal",title:"Thermal history",action:"Show thermal history",label:"Thermal",children:[e.celsius.map(n=>r.jsx(dd,{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:are(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(dd,{label:"Throttling",value:r.jsx("b",{children:t.value}),pct:t.pct,tone:t.tone,note:t.note})]})})}function qre({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(Rre,{sys:e,onClose:()=>n(!1)})]})}function Ure(){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 jp(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=jp(e.l));const n=e.s?Object.entries(e.s):[];return n.length>0&&(t.bySpeed=Object.fromEntries(n.map(([s,a])=>[s,jp(a)]))),t}function YA(e){const t=s=>({...s,cacheCreate1hTokens:0,cacheCreate5mTokens:0,...s.longContext?{longContext:{...s.longContext,cacheCreate1hTokens:0,cacheCreate5mTokens:0}}:{}}),n=t(jp(e));return n.bySpeed&&(n.bySpeed=Object.fromEntries(Object.entries(n.bySpeed).map(([s,a])=>[s,t(a)]))),n}function K5(e){return e.i+e.o+e.cr+e.cc}function aj(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&&aj(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??{}))aj((n=e.s??(e.s={}))[s]??(n[s]={i:0,o:0,cr:0,cc:0,c1h:0,c5m:0}),a);return e}function XA(e,t,n){let s=0,a=0,o=0;const i=[];for(const l of bd(e)){if(!br(t,n,l.speed)){const u=l.usage,d=u.inputTokens+u.outputTokens+u.cacheReadTokens+u.cacheCreateTokens;d>0&&(o+=d,i.push(l.speed));continue}s+=Qu(l.usage,t,l.speed,n).total,a+=Qu({...l.usage,longContext:void 0},t,ca,n).total}return{atSpeed:s,atStandard:a,unpriced:o,unpricedSpeeds:i}}function ZA(e){let t=0;for(const n of Object.values(e))t+=K5(n);return t}function Wre(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 d=`${o}|${u}`,f=n.get(d),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(d,{cost:t(l.cost),usage:p})}}return n}function Hre(e,t,n,s=Date.now()){const a=new Map;for(const A of e){const I={},$=U=>{for(const[F,M]of Object.entries(U))aj(I[F]??(I[F]={i:0,o:0,cr:0,cc:0,c1h:0,c5m:0}),M)};for(const U of A.projects)$(U.models);A.unattributed&&$(A.unattributed);for(const[U,F]of Object.entries(I)){if(!F.s&&!F.l)continue;const{atSpeed:M,atStandard:B}=XA(YA(F),U,s);if(!(M>0&&B>0))continue;let T=a.get(A.day);T||(T=new Map,a.set(A.day,T)),T.set(U,M/B),T.has(mr(U))||T.set(mr(U),M/B)}}const o=(A,I)=>{const $=a.get(A);return($==null?void 0:$.get(I))??($==null?void 0:$.get(mr(I)))??1},i=new Map;let l=0,u=0;for(const[A,I]of n){const $=A.indexOf("|"),U=A.slice(0,$),F=A.slice($+1),M=Jp(I.usage,F,s).total*o(U,F);if(!(M>0&&I.cost>0))continue;l+=I.cost,u+=M;let B=i.get(U);B||(B=new Map,i.set(U,B)),B.set(F,I.cost/M)}const d=u>0,f=(A,I)=>{const $=i.get(A);return($==null?void 0:$.get(I))??($==null?void 0:$.get(mr(I)))??null},p=new Set,m=(A,I)=>{let $=0,U=0;for(const[F,M]of Object.entries(A)){if(br(F,s)){const T=I(F),P=XA(T===null?jp(M):YA(M),F,s);$+=T===null?P.atSpeed:P.atSpeed*T,U+=P.unpriced;for(const q of P.unpricedSpeeds)p.add(`${F} (${q})`);continue}const B=K5(M);B>0&&(U+=B,p.add(F))}return{cost:$,unpriced:U}},w=new Map,x=[];for(const A of e){const I=new Map,$=new Map;let U=0;for(const F of A.projects){const{cost:M,unpriced:B}=m(F.models,P=>f(A.day,P));I.set(F.path,(I.get(F.path)??0)+M),B>0&&$.set(F.path,($.get(F.path)??0)+B),U+=M;let T=w.get(F.path);T||(T={path:F.path,cost:0,tokens:0,unpricedTokens:0},w.set(F.path,T)),T.cost+=M,T.tokens+=ZA(F.models),T.unpricedTokens+=B}x.push({day:A.day,total:U,byPath:I,unpricedByPath:$})}const b=[...w.values()].sort((A,I)=>I.cost-A.cost||I.tokens-A.tokens),j=b.reduce((A,I)=>A+I.cost,0),k=b.reduce((A,I)=>A+I.tokens,0),v=b.reduce((A,I)=>A+I.unpricedTokens,0),S=d?l/u:null,C=t?ZA(t):0,_=t?m(t,()=>S):{cost:0,unpriced:0},R=_.cost>0||C>0?{cost:_.cost,tokens:C,unpricedTokens:_.unpriced}:null;return{projects:b,totalCost:j,totalTokens:k,unpricedTokens:v,perDay:x,unattributed:R,unpricedModels:[...p].sort(),calibrated:d,reconciled:d&&v===0}}function fr(e,t,n=lt){return t>0?e>0?`${n(e)}+`:ua:n(e)}function ul(e){return e>0?`${St(e)} of these tokens are on an unpriced model, so this is a floor`:void 0}function zre(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 ${ua}: this build holds no published rate for it, so its tokens are counted and its dollars are not.`:`${n} are ${ua}: this build holds no published rate for them, so their tokens are counted and their dollars are not.`}const Vre={phase:"running"},Gre={phase:"failed"},Kre={gen:0,report:null,error:null,early:null};function Yre(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:Vre;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 Xre(e){var t;return((t=e.report)==null?void 0:t.gen)!==e.gen&&e.error===null}function Zre(e){const t=e;return t&&t.ok!==!1?{phase:"ready",range:t}:Gre}function Jre(e){return`${e.getFullYear()}${String(e.getMonth()+1).padStart(2,"0")}${String(e.getDate()).padStart(2,"0")}`}function Qre(e,t,n=Date.now()){const s=t===0?60:t,a=new Date(n),o=tj(s,a),i=Jre(a);return{report:`/api/account-projects?num=${e}&days=${t}`,ccusage:`/api/ccusage?since=${o}&until=${i}`}}function eae({num:e,days:t,gen:n,dispatch:s,get:a=(i,l)=>fetch(i,l),now:o=Date.now()}){const i=Qre(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:Zre(u)}))}function Y5(e){return/^[A-Za-z]:[\\/]$/.test(e)?e:e.replace(/[\\/]+$/,"")}function hw(e){const t=Y5(e).replace(/\\/g,"/");return/^[A-Za-z]:\//.test(t)?t.toLowerCase():t}function JA(e){if(!e)return e;const t=Y5(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 tae(e,t){const n=hw(e);let s;for(const a of t){const o=hw(a.path);!o||o===n||!n.startsWith(`${o}/`)||(!s||hw(s.path).length<o.length)&&(s=a)}return s==null?void 0:s.label}function oj(e){return e===0?"all time":e===1?"today":`the last ${e} days`}function nae(e){return e===1?"No work attributed to this account yet today.":`No work attributed to this account in ${oj(e)}.`}function sae(e){return e===1?7:e===7?30:e===30?0:null}function rae(e,t){return e!==1&&t>0}const aae=[{days:1,label:"Today"},{days:7,label:"7d"},{days:30,label:"30d"},{days:0,label:"All"}],dl=["var(--usage-blue)","var(--usage-teal)","var(--usage-lime)","var(--usage-purple)","var(--usage-indigo)","var(--usage-pink)","var(--usage-orange)","var(--usage-zinc)"],oae="var(--usage-zinc)",fw=6,iae=1600;function lae(e){const t=lt(e),n=/^\$(\d{4,})$/.exec(t);return n?`$${Number(n[1]).toLocaleString("en-US")}`:t}function xf(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 cae(e){const t=/^\d{4}-(\d{2})-(\d{2})$/.exec(e);return t?`${Number(t[1])}/${Number(t[2])}`:e}function uae(e){const t=Math.max(1,Math.ceil(e/6));return n=>n===0||n===e-1||n%t===0}function pw(e){if(!e)return"";try{return new Date(e).toLocaleDateString(void 0,{year:"numeric",month:"short",day:"numeric"})}catch{return""}}function dae({num:e,name:t,onClose:n}){var q,K,z,H;cn("account-projects");const[s,a]=g.useState(1),[o,i]=g.useReducer(Yre,Kre),l=((q=o.report)==null?void 0:q.data)??null,u=((K=o.report)==null?void 0:K.days)??s,d=((z=o.report)==null?void 0:z.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,x]=g.useState(()=>new Set),b=Xre(o),j=o.error,[k,v]=g.useState(null),S=g.useRef(void 0),C=g.useRef(!0);g.useEffect(()=>()=>{C.current=!1,window.clearTimeout(S.current)},[]);const _=g.useRef(null),R=gt(n,{focusRef:_}),A=wt(n),I=g.useRef(0);g.useEffect(()=>{const D=++I.current;i({type:"start",gen:D}),m(null),x(new Set),eae({num:e,days:s,gen:D,dispatch:i})},[e,s]);const $=g.useMemo(()=>{const D=Date.now();if(!l)return null;const O=Hre(l.daily??[],l.unattributed,Wre(d),D),V=je=>je.replace(/[\\/]+$/,"").split(/[\\/]/).pop()||je||"(unknown)",Z=new Map;for(const je of O.projects)Z.set(V(je.path),(Z.get(V(je.path))??0)+1);const W=je=>{const Le=V(je);if((Z.get(Le)??0)<=1)return Le;const ke=je.replace(/[\\/]+$/,"").split(/[\\/]/).slice(-2,-1)[0];return ke?`${ke}/${Le}`:Le},X=O.projects.map(je=>({path:je.path,label:W(je.path)})),Y=je=>({path:je.path,label:W(je.path),parentLabel:tae(je.path,X),cost:je.cost,tokens:je.tokens,unpricedTokens:je.unpricedTokens}),J=dl[fw%dl.length],Q=new Map,te=[],le=O.projects.slice(0,fw),de=O.projects.slice(fw);le.forEach((je,Le)=>{Q.set(je.path,dl[Le%dl.length]),te.push({key:je.path,...Y(je),color:dl[Le%dl.length]})}),de.length&&te.push({key:"__other__",label:`Other · ${de.length} project${de.length>1?"s":""}`,cost:de.reduce((je,Le)=>je+Le.cost,0),tokens:de.reduce((je,Le)=>je+Le.tokens,0),unpricedTokens:de.reduce((je,Le)=>je+Le.unpricedTokens,0),color:J,muted:!0,members:de.map(Y)});const oe=O.totalCost,re=O.totalTokens,he=oe>0&&O.unpricedTokens===0?"cost":"tokens",fe=he==="cost"?oe:re,$e=te.map(je=>je.color),ye=O.perDay.map(je=>{const Le=new Map;for(const[De,Ue]of je.byPath){const Ke=Q.get(De)??J;Le.set(Ke,(Le.get(Ke)??0)+Ue)}const ke=new Map;let Ie=0;for(const[De,Ue]of je.unpricedByPath){const Ke=Q.get(De)??J;ke.set(Ke,(ke.get(Ke)??0)+Ue),Ie+=Ue}return{day:je.day,total:je.total,costByColor:Le,unpricedByColor:ke,unpriced:Ie}}),ge=ye.reduce((je,Le)=>Math.max(je,Le.total),0);return{projectCount:O.projects.length,rows:te,totalCost:oe,totalTokens:re,basis:he,denom:fe,un:O.unattributed,chart:ye,maxDay:ge,colorOrder:$e,unpricedTokens:O.unpricedTokens,unpricedNote:zre(O.unpricedModels),calibrated:O.calibrated,reconciled:O.reconciled}},[l,d]),U=(D,O)=>{io(D).then(V=>{C.current&&(window.clearTimeout(S.current),v({path:D,label:O,ok:V}),S.current=window.setTimeout(()=>{C.current&&v(null)},iae))})},F=D=>k!=null&&k.ok&&k.path===D?"Copied":"Copy",M=l!=null&&l.trackedSince?`Tracked since ${pw(l.trackedSince)}`:"Tracking starts with this version",B=oj(u),T=sae(u),P=b&&!!l;return vt.createPortal(r.jsx("div",{className:"modal-backdrop",...A,role:"presentation",children:r.jsxs("div",{ref:R,className:"modal ap-proj-modal",onClick:D=>D.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ap-proj-title ap-proj-sub",children:[r.jsxs("header",{className:"modal-head ap-proj-head",children:[r.jsxs("div",{className:"ap-proj-titlewrap",children:[r.jsx("div",{className:"modal-tool-name",id:"ap-proj-title",children:"Projects"}),r.jsx("div",{className:"ap-proj-sub",id:"ap-proj-sub",title:t,children:t})]}),r.jsx("div",{className:"uh-range",role:"group","aria-label":"Range",children:aae.map(D=>r.jsx("button",{type:"button",className:"uh-range-btn","aria-pressed":s===D.days,onClick:()=>a(D.days),children:D.label},D.days))}),r.jsx("button",{ref:_,className:"glyph-btn ap-proj-close",onClick:n,"aria-label":"Close",children:"×"})]}),r.jsxs("div",{className:`ap-proj-body${P?" refreshing":""}`,"aria-busy":b,children:[b&&!l&&r.jsx(Ure,{}),!b&&j&&r.jsxs("div",{className:"ap-proj-state ap-proj-error",children:["Couldn’t load this report: ",j]}),!j&&$&&r.jsx("div",{className:"ap-proj-ready",children:$.rows.length===0?r.jsxs("div",{className:"ap-proj-state",children:[P?"Updating…":nae(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 ",oj(T)]})}),r.jsxs("div",{className:"ap-proj-note",children:[M,". Only work from this version onward can be tied to an account."]})]}):r.jsxs(r.Fragment,{children:[r.jsx("div",{className:"ap-proj-bar",role:"img","aria-label":`Share of ${$.basis==="cost"?lt($.totalCost):`${St($.totalTokens)} tokens`} across ${$.projectCount} project${$.projectCount>1?"s":""}`,children:$.rows.map(D=>{const O=$.basis==="cost"?D.cost:D.tokens,V=$.denom>0?O/$.denom*100:0;if(V<=0)return null;const Z=$.basis==="cost"?xf(D.cost,$.totalCost):`${xf(D.tokens,$.totalTokens)} of tokens`;return r.jsx("span",{className:"ap-proj-seg",style:{width:`${V}%`,background:D.color},title:`${D.label} · ${fr(D.cost,D.unpricedTokens)} · ${Z}${D.tokens?` · ${St(D.tokens)} tokens`:""}`},D.key)})}),r.jsxs("div",{className:"ap-proj-totals",children:[r.jsx("span",{className:"ap-proj-total-cost",title:ul($.unpricedTokens),children:fr($.totalCost,$.unpricedTokens)}),r.jsxs("span",{className:"ap-proj-total-tok",children:[St($.totalTokens)," tokens"]}),r.jsxs("span",{className:"ap-proj-total-win",children:["· ",P?"updating…":B]}),f&&r.jsx("span",{className:"ap-proj-total-pending",children:"Reconciling cost…"})]}),$.unpricedNote&&r.jsx("div",{className:"ap-proj-note",children:$.unpricedNote}),rae(u,$.chart.length)&&r.jsxs("div",{className:"ap-proj-days",children:[r.jsxs("div",{className:"ap-proj-days-cap",children:["By day",$.chart.length>1?" · click a bar":""]}),r.jsx("div",{className:"ap-proj-days-plot",role:"group","aria-label":`Spend across ${$.chart.length} day${$.chart.length>1?"s":""}`,children:$.chart.map(D=>{const O=$.maxDay>0?D.total/$.maxDay*100:0,V=p===D.day,Z=$.rows.map(X=>({label:X.label,c:D.costByColor.get(X.color)??0,u:D.unpricedByColor.get(X.color)??0})).filter(X=>X.c>0||X.u>0),W=`${pw(Date.parse(`${D.day}T00:00:00`))}, ${fr(D.total,D.unpriced)}. ${Z.map(X=>`${X.label} ${fr(X.c,X.u)}`).join(", ")}`;return r.jsx("button",{type:"button",className:`ap-proj-day${V?" selected":""}`,"aria-pressed":V,"aria-label":W,title:`${D.day} · ${fr(D.total,D.unpriced)}`,onClick:()=>m(X=>X===D.day?null:D.day),children:r.jsx("span",{className:"ap-proj-col",style:{height:`${O}%`},children:$.colorOrder.map((X,Y)=>{const J=D.costByColor.get(X)??0;return J<=0||D.total<=0?null:r.jsx("span",{className:"ap-proj-colseg",style:{height:`${J/D.total*100}%`,background:X}},Y)})})},D.day)})}),(()=>{const D=uae($.chart.length);return r.jsx("div",{className:"ap-proj-days-axis","aria-hidden":"true",children:$.chart.map((O,V)=>r.jsx("div",{className:"ap-proj-axis-cell",children:D(V)?cae(O.day):""},O.day))})})(),(()=>{const D=p?$.chart.find(V=>V.day===p):null;if(!D)return null;const O=$.rows.map(V=>({r:V,c:D.costByColor.get(V.color)??0,u:D.unpricedByColor.get(V.color)??0})).filter(V=>V.c>0||V.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:pw(Date.parse(`${D.day}T00:00:00`))}),r.jsx("span",{className:"ap-proj-day-detail-total",title:ul(D.unpriced),children:fr(D.total,D.unpriced)})]}),O.map(({r:V,c:Z,u:W})=>r.jsxs("div",{className:"ap-proj-day-detail-row",children:[r.jsx("span",{className:"ap-proj-dot",style:{background:V.color},"aria-hidden":"true"}),r.jsx("span",{className:"ap-proj-day-detail-name",children:V.label}),r.jsx("span",{className:"ap-proj-day-detail-cost",title:ul(W),children:fr(Z,W)})]},V.key))]})})()]}),r.jsx("ul",{className:"ap-proj-list",children:$.rows.map((D,O)=>{const V=$.basis==="cost"?D.cost:D.tokens,Z=$.denom>0?V/$.denom*100:0,W=w.has(D.key),X=`ap-proj-details-${O}`,Y=W&&(!!D.path||!!D.members),J=D.members?`${W?"Hide":"Show"} the ${D.members.length} project${D.members.length>1?"s":""} folded into Other`:`${W?"Hide":"Show"} location for ${D.label}`;return r.jsxs("li",{className:`ap-proj-row${D.muted?" muted":""}${W?" expanded":""}`,children:[r.jsx("span",{className:"ap-proj-dot",style:{background:D.color},"aria-hidden":"true"}),r.jsxs("span",{className:"ap-proj-name",children:[D.label,D.parentLabel&&r.jsxs("span",{className:"ap-proj-parent",children:[" · in ",D.parentLabel]})]}),r.jsx("span",{className:"ap-proj-track",title:$.basis==="cost"?`${xf(D.cost,$.totalCost)} of tracked cost`:`${xf(D.tokens,$.totalTokens)} of tracked tokens`,children:r.jsx("span",{className:"ap-proj-fill",style:{width:`${Z}%`,background:D.color}})}),r.jsx("span",{className:"ap-proj-cost",title:ul(D.unpricedTokens),children:fr(D.cost,D.unpricedTokens)}),r.jsx("span",{className:"ap-proj-tok",children:St(D.tokens)}),r.jsx("button",{type:"button",className:"glyph-btn ap-proj-info","aria-expanded":W,"aria-controls":Y?X:void 0,"aria-label":J,onClick:()=>x(Q=>{const te=new Set(Q);return te.has(D.key)?te.delete(D.key):te.add(D.key),te}),children:"ⓘ"}),W&&D.path&&r.jsxs("div",{className:"ap-proj-details",id:X,children:[r.jsx("code",{className:"ap-proj-path",children:JA(D.path)}),r.jsx("button",{type:"button",className:"ap-proj-copy","aria-label":`${F(D.path)} location for ${D.label}`,onClick:()=>U(D.path,D.label),children:F(D.path)})]}),W&&D.members&&r.jsx("div",{className:"ap-proj-details ap-proj-other-members",id:X,children:D.members.map(Q=>r.jsxs("div",{className:"ap-proj-other-member",children:[r.jsxs("div",{className:"ap-proj-other-name",children:[Q.label,Q.parentLabel&&r.jsxs("span",{className:"ap-proj-parent",children:[" · in ",Q.parentLabel]})]}),r.jsx("code",{className:"ap-proj-path",children:JA(Q.path)}),r.jsx("span",{className:"ap-proj-cost",title:ul(Q.unpricedTokens),children:fr(Q.cost,Q.unpricedTokens)}),r.jsx("span",{className:"ap-proj-tok",children:St(Q.tokens)}),r.jsx("button",{type:"button",className:"ap-proj-copy","aria-label":`${F(Q.path)} location for ${Q.label}`,onClick:()=>U(Q.path,Q.label),children:F(Q.path)})]},Q.path))})]},D.key)})}),$.un&&r.jsxs("div",{className:"ap-proj-unattributed",children:[r.jsx("span",{className:"ap-proj-dot",style:{background:oae},"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:ul($.un.unpricedTokens),children:fr($.un.cost,$.un.unpricedTokens,lae)}),r.jsx("span",{className:"ap-proj-un-tok",children:St($.un.tokens)}),r.jsx("div",{className:"ap-proj-note",children:"Work no account could be tied to — from before tracking, or a gap."})]}),r.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:k&&(k.ok?`Copied the location of ${k.label}`:`Could not copy the location of ${k.label} — select it and copy it by hand`)}),r.jsxs("div",{className:"ap-proj-foot",children:[f?"Dollars estimated · ccusage still running":$.reconciled?"Dollars from ccusage · split by activity":$.calibrated?"Dollars from ccusage for the priced models · split by activity":d?"Dollars estimated · ccusage could not price this window":"Dollars estimated · ccusage unavailable"," · ",M]})]})})]})]})}),document.body)}function da(e,t){return eD(t-Math.floor(e/1e3))}function hae(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 rS(){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 fae({anchorId:e,boundaryId:t,issue:n,who:s,fetchedAt:a,nowSec:o,onClose:i,onSignIn:l,onReport:u}){const d=g.useRef(null);return r.jsx(ac,{anchorId:e,boundaryId:t,id:"ap-issue-pop",className:"ap-pop ap-issue-pop",role:"dialog",labelledBy:"ap-issue-title",focusRef:d,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(rS,{}),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 ${da(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:d,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 pae=typeof window>"u"?g.useEffect:g.useLayoutEffect,mw="ccdeck:account-hint";function mae(e,t,n){return n?[...new Set([...(e==null?void 0:e.split(/\s+/).filter(Boolean))??[],t])].join(" "):e}function gae({children:e,detail:t,disabled:n=!1,className:s,portalRootId:a,focusDelay:o=0,shouldShow:i,placement:l="popover"}){const u=g.useId(),d=e.props.id??u,f=`${d}-hint`,[p,m]=g.useState(!1),w=g.useRef(0),x=g.useRef(null),b=g.useRef(n),j=g.useRef(i);b.current=n,j.current=i;const k=()=>window.clearTimeout(w.current),v=()=>{k(),m(!1)},S=()=>{var $;const A=document.getElementById(d);if(!A||!A.getClientRects().length||(($=A.checkVisibility)==null?void 0:$.call(A))===!1)return null;const I=A.getBoundingClientRect();return I.bottom<=0||I.top>=innerHeight||I.right<=0||I.left>=innerWidth?null:A},C=()=>{var I;k();const A=S();b.current||!A||((I=j.current)==null?void 0:I.call(j,A))===!1||(document.dispatchEvent(new CustomEvent(mw,{detail:f})),m(!0))},_=()=>{k(),w.current=window.setTimeout(()=>m(!1),140)};g.useEffect(()=>()=>window.clearTimeout(w.current),[]),g.useEffect(()=>{n&&(window.clearTimeout(w.current),m(!1))},[n]),pae(()=>{if(!p||n)return;const A=()=>{var O,V,Z;const M=x.current,B=S();if(!M||!B||((O=j.current)==null?void 0:O.call(j,B))===!1){m(!1);return}M.style.maxHeight="";const T={width:M.offsetWidth,height:M.offsetHeight},P={width:innerWidth,height:innerHeight},q=M.getBoundingClientRect(),K=(V=M.firstElementChild)==null?void 0:V.getBoundingClientRect(),z=(Z=M.lastElementChild)==null?void 0:Z.getBoundingClientRect(),H=K&&z?K.top-q.top+K.height+q.bottom-z.bottom:T.height,D=l==="reading"?zQ(B.getBoundingClientRect(),T,P,H):WD(B.getBoundingClientRect(),T,P);if(!D){m(!1);return}M.style.left=`${D.left}px`,M.style.top=`${D.top}px`,M.style.maxHeight=D.maxHeight==null?"":`${D.maxHeight}px`},I=M=>{var T,P;const B=M.target;!((T=x.current)!=null&&T.contains(B))&&!((P=document.getElementById(d))!=null&&P.contains(B))&&v()},$=M=>{var B;(B=x.current)!=null&&B.contains(M.target)||v()},U=M=>{M.detail!==f&&v()};A();const F=ln.push(v,0,"popover");return window.addEventListener("resize",A),window.addEventListener("scroll",$,!0),document.addEventListener("pointerdown",I,!0),document.addEventListener(mw,U),()=>{window.removeEventListener("resize",A),window.removeEventListener("scroll",$,!0),F(),document.removeEventListener("pointerdown",I,!0),document.removeEventListener(mw,U)}},[p,n,d,t,i,a,l]);const R=mae(e.props["aria-describedby"],f,p&&!n);return r.jsxs(r.Fragment,{children:[g.cloneElement(e,{id:d,title:void 0,tabIndex:e.props.tabIndex??0,"aria-describedby":R,onPointerEnter:A=>{var I,$;($=(I=e.props).onPointerEnter)==null||$.call(I,A),A.pointerType==="mouse"&&(k(),w.current=window.setTimeout(C,300))},onPointerLeave:A=>{var I,$;($=(I=e.props).onPointerLeave)==null||$.call(I,A),_()},onFocus:A=>{var I,$;($=(I=e.props).onFocus)==null||$.call(I,A),k(),o>0?w.current=window.setTimeout(C,o):C()},onBlur:A=>{var I,$;($=(I=e.props).onBlur)==null||$.call(I,A),v()},onClick:A=>{var I,$;v(),($=(I=e.props).onClick)==null||$.call(I,A)},onContextMenu:A=>{var I,$;v(),($=(I=e.props).onContextMenu)==null||$.call(I,A)},onDragStart:A=>{var I,$;v(),($=(I=e.props).onDragStart)==null||$.call(I,A)},onKeyDown:A=>{var I,$;rm(A.key)||v(),($=(I=e.props).onKeyDown)==null||$.call(I,A)}}),p&&!n&&vt.createPortal(r.jsx("div",{ref:x,id:f,className:s,role:"tooltip",onPointerEnter:k,onPointerLeave:_,children:t}),(a?document.getElementById(a):null)??document.body)]})}function ij({children:e,detail:t,disabled:n=!1}){return r.jsx(gae,{className:"ap-peek ap-account-hint",detail:t,disabled:n,children:e})}function yae({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(ij,{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(ac,{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"})})]})})]})}function Nu(e){return e.charAt(0).toUpperCase()+e.slice(1)}function wae(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 xae(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 vae(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 QA={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 mi(e,t,n){const s=kae(e,t);return!s||!(n!=null&&n.noCopyWorksNearby)||!bae(e)?s:{...s,text:QA.text,hint:QA.hint}}function bae(e){return e.staleCopy?!1:e.stopped?e.collector==="relogin_required":e.error==="invalid_grant"||e.error==="no_refresh_token"}function kae(e,t){if(e.staleCopy){const n=wae(e.repair??null,t);return{text:Nu(n.text),hint:n.hint,fix:null,tone:"quiet",blocksSwitch:!1}}if(e.stopped){const n=vae(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:Nu(n.text),hint:n.hint,fix:n.fix?Nu(n.fix):null,tone:s||e.collector==="keychain_unavailable"?"warn":"quiet",blocksSwitch:s}}if(e.error){const n=xae(e.error);return{text:Nu(n.text),hint:n.hint,fix:n.fixable?"Sign in again":null,tone:n.fixable?"warn":"quiet",blocksSwitch:n.fixable}}return null}function eR(e){return typeof e.id=="string"&&e.id.startsWith("scoped-")}function tR(e){const t=e.filter(l=>!eR(l)),n=e.filter(l=>eR(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 hd(e,t){return!!e.resetAt&&e.resetAt<=t}function aS(e,t){return(e.lanes??[]).some(s=>hd(s,t))?null:e.headroom}const jae="\0";function ws(e){const t=typeof e.email=="string"?e.email.trim():"";if(!t)return`slot:${e.num}`;const n=typeof e.orgUuid=="string"&&e.orgUuid.trim()?`uuid:${e.orgUuid.trim()}`:typeof e.org=="string"?e.org.trim():"";return`acct:${t}${jae}${n}`}function Nae(e,t,n=ws){const s=n(t);return e.includes(s)?e.filter(a=>a!==s):[...e,s]}const Nm="slot",oS=[{lane:"five_hour",name:"5h"},{lane:"seven_day",name:"7d"}],X5=e=>e.id.startsWith("scoped-");function Sae(e){var t;return((t=oS.find(n=>n.lane===e.id))==null?void 0:t.name)??e.label}function Cae(e){if(e==="room")return"room";const t=/^(.+):(full|empty)$/.exec(e);return t?t[1]:null}function Z5(e){const t=[...new Set(e.flatMap(s=>(s.lanes??[]).filter(X5).map(a=>a.label)))].sort((s,a)=>s.localeCompare(a)),n=[...oS.map(s=>s.name),...t];return[{id:Nm,label:"Slot"},...n.flatMap(s=>[{id:`${s}:full`,label:`${s} · fullest`},{id:`${s}:empty`,label:`${s} · emptiest`}]),{id:"room",label:"Most room"}]}function nR(e,t,n){const s=oS.find(o=>o.name===t),a=(e.lanes??[]).find(o=>s?o.id===s.lane:X5(o)&&o.label===t);return a&&n!=null&&hd(a,n)?null:a&&Number.isFinite(a.pct)?a.pct:null}function J5(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:aS(p,s);return o(sR(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=>nR(f,l,s)!=null))return a;const d=sR(a,f=>nR(f,l,s),u==="full"?"desc":"asc");return u==="empty"?o(d):d}function sR(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 Q5(e,t){return Z5(t).some(n=>n.id===e)?e:Nm}function lj(e,t){if(!t)return[...e];const n=new Map(t.map((o,i)=>[o,i])),s=e.filter(o=>n.has(ws(o))).sort((o,i)=>n.get(ws(o))-n.get(ws(i))),a=e.filter(o=>!n.has(ws(o)));return[...s,...a]}function iS(e){const t=ws(e);return t.startsWith("slot:")?t:`h:${_ae(t)}`}function _ae(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 cj={mode:"some",keys:[]};function e6(e,t){const n=e.keys.includes(iS(t));return e.mode==="all"?!n:n}function Eae(e,t){return{mode:e.mode,keys:Nae(e.keys,t,iS)}}function t6(e,t){return t.length>0&&t.every(n=>e6(e,n))}function Tae(e,t){return t6(e,t)?cj:{mode:"all",keys:[]}}function Aae(e,t){if(!Array.isArray(t))return e;const n=new Set(t.map(iS)),s=e.keys.filter(a=>n.has(a));return s.length===e.keys.length?e:{mode:e.mode,keys:s}}const si=[{id:"five_hour",label:"5h",long:"5-hour"},{id:"seven_day",label:"7d",long:"7-day"}];function rR(e){return e.counted?e.pct:e.why==="login"?null:e.estimate}function Rae(e){const t=rR(e.five_hour),n=rR(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 Mae(e,t){const n=si.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:da(e.updatedAt,t),old:!0}}const n6=15*6e4;function Sm(e){return e!=null&&e>0&&Number.isFinite(e)&&Number.isFinite(new Date(e).getTime())?e:null}const s6=e=>e.alias??e.email??`account ${e.num}`;function Pu(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 uj(e,t,n){const s=si.find(w=>w.id===t).label,a=(e.lanes??[]).find(w=>w.id===t),o=a&&Number.isFinite(a.pct)?r6(a.pct):null,i=mi(e,n),l=Pu(e,t),u=l!=null&&l<=n,d=a6(a,e.fetchedAt,n),f=(w,x)=>({counted:!1,why:w,say:x,last:o,estimate:o,resetAt:u?null:Pu(e,t),reset:d});if(i!=null&&i.blocksSwitch)return f("login",i.text);if(o==null)return f("none",`No ${s} reading`);if(d)return f("reset",d);const p=Sm(e.fetchedAt);return e.stale||e.staleCopy===!0||e.stopped===!0||p==null||n*1e3-p>n6?f("stale",p!=null?`Updated ${da(p,n)}`:"Never read"):{counted:!0,pct:o,resetAt:Pu(e,t)}}const r6=e=>Math.min(100,Math.max(0,e));function a6(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=Sm(t),a=s!=null?`read ${da(s,n)}`:"last read";return`Reported reset time passed ${da(e.resetAt*1e3,n)}, ${so(r6(e.pct))}% when ${a}`}function $ae(e,t){const n=si.find(d=>d.id===t);let s=0,a=0,o=0;const i=[];for(const d of e){const f=d.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:d.name,pct:p}))}const l=i.reduce((d,f)=>!d||f.at<d.at?f:d,null),u=l&&{...l,more:i.filter(d=>d!==l&&d.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 lS(e,t){const n=e.map(a=>{const o={five_hour:uj(a,"five_hour",t),seven_day:uj(a,"seven_day",t)};return{num:a.num,key:ws(a),name:s6(a),active:a.active,heldOut:a.disabled===!0,cells:o,resets:{five_hour:Pu(a,"five_hour"),seven_day:Pu(a,"seven_day")},status:Rae(o),updatedAt:Sm(a.fetchedAt)}}),s=n.filter(a=>a.status==="ready").length;return{rows:n,windows:si.map(a=>$ae(n,a.id)),roomInBoth:s}}function du(e,t){return(e==null?void 0:e.key)===t?{key:t,dir:e.dir==="asc"?"desc":"asc"}:{key:t,dir:"asc"}}const Lae={ready:0,limited:1,exhausted:2,stale:3};function Iae(e){return e.counted?e.pct:e.reset?e.estimate:e.last}function aR(e,t){return t==="status"?Lae[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:Iae(e.cells[t])}function Oae(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=aR(o,t.key),u=aR(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 so(e){return e>=100?100:Math.min(99,Math.round(e))}function Pae(e){const t=so(e);return{used:t,available:100-t}}function Dae(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 o6=new Set(["awaiting_url","awaiting_code","registering"]);function i6(e){return e!=null&&o6.has(e)}function l6(e){return e!=null&&e!=="done"&&!o6.has(e)}const c6="the sign-in ended before it finished — the deck restarted, or it was cancelled in another tab",Fae="the sign-in did not complete";function Bae({state:e,serverError:t,localError:n}){const s=e==="idle";return{title:s?"Sign-in ended":"Sign-in failed",message:n||t||(s?c6:Fae)}}function oR({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 iR({started:e,state:t}){return!e||t==="done"?null:{action:"login-cancel"}}function qae({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":l6(e==null?void 0:e.state)||n&&t&&!s?"ended":s||i6(e==null?void 0:e.state)?"asking":"primer"}function cS(e,t){return t?Kt(e,t):void 0}const Uae={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"},Wae={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"},uS=`claude-swap could not read the login keychain — start ${Pt} from a Terminal window rather than a background service`,Hae={unreadable_here:{short:"Keychain locked on this Mac",long:`${uS}.`},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 Np(e){return e?Kt(Hae,e)??null:null}const u6={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 dj(e,t,n){const s=n==null?null:u6[n];if(s)return s;if((e==null?void 0:e.reason)!=="no_cswap"&&/keychain/i.test(fd(e)))return uS;const a=cS(Wae,e==null?void 0:e.reason);return a||(e==null?void 0:e.reason)||t}function fd(e){return((e==null?void 0:e.output)||(e==null?void 0:e.detail)||(e==null?void 0:e.error)||"").trim()}const zae={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"},Vae="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 Gae(e){return/\bnpx\b/i.test(e)&&/(command not found|not found|not recognized|ENOENT)/i.test(e)}const Kae="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",Yae="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",Xae=e=>/\b(?:ERR_)?MODULE_NOT_FOUND\b|cannot find (?:module|package)/i.test(e),Zae=/node_modules[\\/]npm[\\/]bin[\\/]|\bnpm-prefix\.js\b|\bnp[mx][-.][\w.-]*cli\.js\b/i,Jae=/[\\/]_npx[\\/]/i,Qae=`the copy of ccusage ${Pt} installed for itself`;function eoe(e){const t=String((e==null?void 0:e.install)??"").replace(/\s+/g," ").trim();return t.length>240?`${t.slice(0,239)}…`:t}function wje(e,t){const n=toe(e,t),s=eoe(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 ${hu(n)}`:`there is no managed copy of ccusage on this machine, and the npx fallback failed: ${hu(n)}`;case"managed":return`${Qae} failed to run: ${hu(n)}`;case"path":return e.bin?`the ccusage this deck found at ${e.bin} failed to run: ${hu(n)}`:`the ccusage this deck found on your PATH failed to run: ${hu(n)}`;default:return n}}const hu=e=>/^[A-Z][a-z]/.test(e)?e[0].toLowerCase()+e.slice(1):e;function toe(e,t){const n=fd(e);if(Xae(n)){if(Jae.test(n))return Yae;if(Zae.test(n))return Kae}if(Gae(n))return Vae;const s=cS(zae,e==null?void 0:e.reason);return s||(e==null?void 0:e.reason)||t}function jl(e,t,n){const s=n==null?null:u6[n];if(s)return s;if(e!=null&&e.detail)return e.detail;if(e!=null&&e.error&&l6(e.state))return e.error;const a=cS(Uae,e==null?void 0:e.reason);return a||(e!=null&&e.error?e.error:(e==null?void 0:e.reason)||t)}function vr(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 noe={keychain_unavailable:{short:"Keychain locked on the other Mac",long:`the other Mac could not export it. On that Mac: ${uS}. 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 hj(e){return e.why?Kt(noe,e.why)??Np(e.why):null}const dS={"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"}},soe={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 lR(e){var s;const t=roe[e];if(t)return t;const n=(s=/\b(E[A-Z]{3,})\b/.exec(e))==null?void 0:s[1];return n&&soe[n]||e}const roe={"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 Cm(e,t){var f;if(!e)return null;if(e.error&&((f=e.done)!=null&&f.length)){const p=Cm({...e,error:void 0},t),m=` · ${vr(e.at,t)}`;return{...p,text:`${p.text.slice(0,-m.length)}, then ${lR(e.error)}${m}`,tone:"bad"}}if(e.error)return dS[e.error]??{text:lR(e.error),tone:"bad"};const n=e.done??[];if(!n.length)return{text:`all logins fine · ${vr(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:hj(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,d=vr(e.at,t);return s.length===n.length?{text:`${s.length} ${a} arrived${l} · ${d}`,tone:o.length?"warn":"ok",...u?{hint:u}:{}}:{text:`${s.length} of ${n.length} logins arrived${l} · ${d}`,tone:"bad",...u?{hint:u}:{}}}const aoe=9e4;function ooe({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(d=>d.addr===i&&d.port&&d.at>0&&a-d.at<aoe);if(!l.length)return null;const u=[...new Set(l.map(d=>d.port))];if(n!=null&&!u.includes(n)){const d=u.length===1?`port ${u[0]}`:`ports ${u.join(" and ")}`;return`A deck at ${i} is announcing itself on ${d}, 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 _m(e,t){var n,s;return(n=e.last)!=null&&n.error&&!dS[e.last.error]?!1:!!((s=e.last)!=null&&s.at&&t-e.last.at<fj||e.lastSeen!=null&&t-e.lastSeen<fj)}const fj=95e3;function ioe(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?d6(p.lastSeen,t):_m(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,d=0;for(const p of h6(s,m=>fS(m,m.peerFp??m.fp,i).name,m=>m.addr??"")){const m=p.filter(a);if(!m.length){d++;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:d===1?"this deck cannot reach the one it is paired with":`this deck cannot reach any of its ${d} decks`,tone:"bad"};const f=l===1?"1 deck ready":`${l} decks ready`;return{text:d?`${f} · ${d} away`:f,tone:"ok"}}function loe(e,t,n){if(n)return"checking…";if(e==null)return"not checked yet";const s=vr(e,t);return s==="now"?"checked just now":`checked ${s}`}function hS(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 d6(e,t){return e!=null&&t-e<fj}function coe(e,t){if(e==null)return{text:"one-way · has not called yet",here:!1};const n=d6(e,t);return{text:n?"online · one-way, it calls in":`one-way · last online ${vr(e,t)}`,here:n}}function cR(e,t,n){return t?"online":e.lastSeen!=null?`last online ${vr(e.lastSeen,n)}`:e.waiting?"has not called yet":"never reached"}function uoe(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(doe(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(hoe(p,m,t)):i.push(foe(p,m,o,t)))}n.push(...yoe(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(moe(p,o,e.pairingMode)));n.push(...u.sort(a));const d=[];for(const p of e.declined??[])!(p!=null&&p.fp)||s.has(p.fp)||(s.add(p.fp),d.push(goe(p,o)));n.push(...d.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 doe(e,t,n){const s=Em(t,e.fp,e.name||e.fp);return{fp:e.fp,...s,addr:e.addr??"",kind:"asks",state:`wants to pair · ${hS(e.at,n)}`,tone:"wait",here:!0,hint:`${s.name} at ${e.addr}${e.via==="tailscale"?", over Tailscale,":""} is waiting for an answer.`,...Tm(e.via)}}function hoe(e,t,n){var o;const s=Cm(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?pj(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.`,...Tm(e.via)}}function foe(e,t,n,s){var w,x,b,j;const a=Cm(e.last,s),o=_m(e,s),i=e.addr?`${e.addr}:${e.port}`:"",l=e.waiting?coe(e.lastSeen,s):null,u=l?l.here:o,d=!l&&a?u?`online · ${pj(a)}`:`${pj(a)} · ${cR(e,u,s)}`:l?l.text:cR(e,u,s),f=(w=e.last)!=null&&w.error?dS[e.last.error]:null,p=!l&&u&&!((x=e.last)!=null&&x.error)&&!(((b=e.last)==null?void 0:b.done)??[]).length,m=fS(e,t,n);return{fp:t,...m,addr:e.addr??"",kind:"paired",state:d,quiet:p,tone:f?f.tone==="bad"?"bad":"wait":a?a.tone:u?"ok":"idle",here:l?l.here:o,...Tm(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 ${vr(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}`:""}${(j=e.last)!=null&&j.error?` — ${e.last.error}`:""}${a!=null&&a.hint?` — ${a.hint}`:""}`}}function fS(e,t,n){return e.manual&&!e.met?{name:e.addr?`${e.addr}:${e.port}`:""}:Em(n,t,e.name||t)}function poe(e,t){return fS(e,e.peerFp??e.fp,t).name}function moe(e,t,n){const s=Em(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.`,...Tm(e.via)}}function goe(e,t){const n=Em(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 Em(e,t,n){const s=t?e[t]:void 0;return s&&s!==n?{name:s,self:n}:{name:n}}function Tm(e){return e==="tailscale"?{via:"tailscale"}:{}}function pj(e){return e.text.replace(/ · .*$/,"")}function yoe(e){return h6(e,t=>t.name,t=>t.addr).map(woe)}function h6(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 woe(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 uR(e,t){return t?e.map(n=>t[n.fp]?{...n,name:t[n.fp]}:n):e}function pd(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 xoe(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 voe(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,d=s.filter(f=>f.kind==="paired").length;return{asks:n,rest:s,live:a,folded:o,troubled:i,showFolded:l,shown:u,paired:d}}function dR(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 boe(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 koe(e,t,n){if(!(t!=null&&t.enabled))return!1;const s=(t.peers??[]).filter(o=>o.paired&&_m(o,n));if(s.some(o=>{var i,l,u;return joe((i=o.offers)==null?void 0:i.current)&&!((u=(l=o.offers)==null?void 0:l.accounts)!=null&&u.some(d=>d.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 joe=e=>!!e&&typeof e=="object"&&e.hidden===!0;function Noe(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,d,f;if(!o.paired||!_m(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=(d=o.last)==null?void 0:d.done)!=null&&f.some(p=>p.action==="heal"&&String(p.email??"").trim().toLowerCase()===a))})}function Soe(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=>poe(s,t.aliases??{})).filter(Boolean);return[...new Set(n)].sort((s,a)=>s.localeCompare(a))}function Coe(e,t){return e.flatMap(n=>{const s=Soe(n.key,t);return s?[[n.key,{to:s,inUse:n.inUse===!0}]]:[]})}function gw(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 f6={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 Sp(e){return e.length<=1?e.join(""):`${e.slice(0,-1).join(", ")} and ${e[e.length-1]}`}function _oe(e,t,{holdOut:n=!1}={}){if(!e||e.level!=="metrics"&&e.level!=="content")return null;const s=e.level==="content"?e.content.map(l=>f6[l]??l):[],a=e.orgName?e.orgName:"This account's organization",o=s.length?`usage data, and your ${Sp(s)}`:"usage data",i=e.destinations.length?Sp(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 ${da(e.seenAt,t)}, while this account was active.`+(n?" To keep Auto-switch off it, choose Hold out of rotation in its ⋯ menu.":"")}}function Eoe(e){if(!e||e.level!=="metrics"&&e.level!=="content")return null;const t=e.level==="content"?e.content.map(o=>f6[o]??o):[],n=t.length?`your ${Sp(t)}`:"usage data",s=e.orgName?`${e.orgName}'s telemetry`:"Its organization's telemetry",a=e.destinations.length?` to ${Sp(e.destinations)}`:"";return`${s} is on for them: it sends ${n}${a}.`}function Toe(e){return e>=90?"hi":e>=70?"mid":void 0}function Aoe({lane:e,nowSec:t,readAt:n,frozen:s,sortedBy:a}){const o=Math.min(100,Math.max(0,e.pct)),i=hd(e,t),l=s||i,u=l?"var(--muted)":o>=90?"var(--err)":o>=70?"var(--warn)":"var(--accent)",d=e.resetAt&&!l?kd(e.resetAt,t):null,f=i?a6(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:d?`${e.label} resets in ${d}`:void 0,children:d&&r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"vis-hidden",children:"resets in "}),d]})})]})}function Roe({a:e,nowSec:t,lan:n,opened:s,onToggleLanes:a,busy:o,pressProps:i,onSwitch:l,menuOpen:u,onOpenMenu:d,onCloseMenu:f,refusal:p,onDismissRefusal:m,onSignIn:w,switchedHere:x,swapped:b,displaced:j,issueExpanded:k,onOpenIssue:v,sortKey:S=null,home:C=null,rotating:_=!1,telemetryBoundaryId:R}){const A=e.lanes.filter(D=>!hd(D,t)),{shown:I}=tR(e.lanes),{fuller:$}=tR(A),U=S==="room"?A.reduce((D,O)=>D&&D.pct>=O.pct?D:O,null):S?e.lanes.find(D=>Sae(D)===S)??null:null,F=mi(e,t,n),M=e.active||s,B=e.alias??e.email??`account ${e.num}`,T=e.alias&&e.email?`${e.alias} · ${e.email}`:B,P=e.stale||(F==null?void 0:F.blocksSwitch)===!0,q=$?[...I,$]:I,K=e.fetchedAt?da(e.fetchedAt,t):null,z=_oe(e.telemetry,t,{holdOut:_&&!e.active&&!e.disabled}),H=Eoe(e.telemetry);return r.jsxs("li",{className:`ap-account${e.active?" active":""}`,"aria-current":e.active?"true":void 0,"data-open":M?"":void 0,"data-frozen":P?"":void 0,children:[!e.active&&r.jsx("button",{type:"button",className:"ap-row-open",id:`ap-row-${e.num}`,title:T,"aria-expanded":M,"aria-controls":M?`ap-detail-${e.num}`:void 0,"aria-describedby":[e.alias&&e.email?`ap-email-${e.num}`:null,C?`ap-home-${e.num}`:null,n!=null&&n.sharedTo?`ap-shared-${e.num}`:null,!M&&!(F!=null&&F.blocksSwitch)?`ap-quota-${e.num}`:null,z?`ap-telemetry-${e.num}`:null].filter(Boolean).join(" ")||void 0,onClick:()=>a(),children:r.jsxs("span",{className:"vis-hidden",children:[B,", ",M?"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}),z&&r.jsx(yae,{num:e.num,name:B,telemetry:z,boundaryId:R}),C&&r.jsx(ij,{detail:C,children:r.jsxs("span",{className:"ap-home",id:`ap-home-${e.num}`,title:C,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:C})]})}),(n==null?void 0:n.sharedTo)&&r.jsx(ij,{detail:gw(n.sharedTo,n.sharedInUse),children:r.jsxs("span",{className:"ap-shared",id:`ap-shared-${e.num}`,title:gw(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:gw(n.sharedTo,n.sharedInUse)})]})}),e.disabled&&r.jsx("span",{className:"ap-held",children:"held out"}),!e.active&&!e.disabled&&!(F!=null&&F.blocksSwitch)&&r.jsx("button",{type:"button",className:"ap-switch",...i(`switch-${e.num}`),onClick:()=>l(e.num,B),"aria-label":`Switch to ${B}`,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():d(e.num),onKeyDown:D=>{D.key!=="ArrowDown"&&D.key!=="ArrowUp"||(D.preventDefault(),d(e.num,D.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??B}`,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&&x&&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&&x&&H&&r.jsx("p",{className:"ap-switched",children:H}),b&&(()=>{const D=(j==null?void 0:j.alias)??(j==null?void 0:j.email)??"the account that was there";return r.jsxs("p",{className:"ap-note ap-swap-note",title:`Slot ${b.at} was taken, so the two accounts traded places: ${D} now holds slot ${b.displaced}.`,children:["swapped with slot ",b.displaced]})})(),F&&r.jsxs("div",{className:"ap-issue-line",children:[r.jsxs("button",{type:"button",id:`ap-issue-${e.num}`,className:"ap-issue","data-tone":F.tone,"aria-haspopup":"dialog","aria-expanded":k,"aria-controls":k?"ap-issue-pop":void 0,onClick:()=>v(e.num,`ap-issue-${e.num}`),children:[F.tone==="warn"&&r.jsx(rS,{}),r.jsx("span",{className:"ap-issue-text",children:F.text})]}),F.fix&&w&&r.jsx("button",{type:"button",className:"ap-sign-in","aria-label":`${F.fix} as ${e.email??B}`,title:F.hint,onClick:()=>w(e.email),children:"Sign in"}),!M&&r.jsx("span",{className:"ap-issue-age",title:"When claude-swap last read this account's usage",children:K??"never collected"})]}),!M&&!(F!=null&&F.blocksSwitch)&&r.jsxs("p",{className:"ap-quota",id:`ap-quota-${e.num}`,children:[q.length?q.map(D=>r.jsxs("span",{className:"ap-q","data-sort-key":D.id===(U==null?void 0:U.id)?"":void 0,children:[r.jsx("span",{className:"ap-q-label",children:D.label})," ",hd(D,t)?r.jsx("span",{className:"ap-q-pct",title:`${D.label} has reset since this reading`,children:"reset"}):r.jsxs("span",{className:"ap-q-pct","data-level":P?void 0:Toe(D.pct),children:[Math.round(D.pct),"%"]})]},D.id)):r.jsx("span",{className:"ap-q-label",children:"no usage recorded yet"}),e.stale&&!F&&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"})]}),M&&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(D=>r.jsx(Aoe,{lane:D,nowSec:t,readAt:e.fetchedAt,frozen:P,sortedBy:D.id===(U==null?void 0:U.id)},D.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&&!F?" 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 ",da(e.fetchedAt,t),F!=null&&F.blocksSwitch?"":hae(e.nextAt,t)]}):r.jsx("span",{className:"ap-age ap-stale",title:"claude-swap has not read this account yet",children:"never collected"})})]})]})}function Moe({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 $oe({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 Loe=[{value:"room",label:"Most room left"},{value:"weekly",label:"Soonest weekly reset"}],Ioe="Uses up quota that resets within 4 days first";function Ooe(e){return e==="room"||e==="weekly"}function yw(e,t){return!t||!e.email?!1:e.email.trim().toLowerCase()===t.email.trim().toLowerCase()&&(e.orgUuid??"")===(t.orgUuid??"")}function Poe(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 ww=[70,80,85,90,95],p6="custom",wl=50,xl=99,Doe=`A whole percent from ${wl} to ${xl}.`;function Foe(e){const t=Number(e);return[...Number.isFinite(t)&&t>0&&!ww.includes(t)?[...ww,t]:ww].sort((s,a)=>s-a)}function Boe(e){const t=e.trim().replace(/\s*%$/,"");if(t==="")return{ok:!1,reason:"empty",message:`Enter a number from ${wl} to ${xl}.`};if(!/^\d+(\.\d*)?$|^\.\d+$/.test(t))return{ok:!1,reason:"not_a_number",message:`Enter a number from ${wl} to ${xl}.`};const n=Number(t);return Number.isInteger(n)?n<wl?{ok:!1,reason:"too_low",message:`The lowest is ${wl}%.`}:n>xl?{ok:!1,reason:"too_high",message:`The highest is ${xl}%.`}:{ok:!0,value:String(n)}:{ok:!1,reason:"not_whole",message:`Use a whole number from ${wl} to ${xl}.`}}const mj={pick:null,custom:null,refusal:null};function qoe(e,t){switch(t.kind){case"pick":return t.pick===p6?{...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 mj;case"leave":return e.custom&&(e.pick??t.stored)===t.stored?mj:e}}async function Uoe(e,t,n){if(!t.sends)return{kind:"unchanged"};const s=Boe(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 Woe({auto:e,threshold:t,thresholdPick:n,thresholdCtl:s,thresholdSaved:a,thresholdRef:o,thresholdSaveRef:i,thresholdCustom:l,thresholdRefusal:u,thresholdFieldRef:d,proposeThreshold:f,typeThreshold:p,cancelThreshold:m,leaveThreshold:w,doThreshold:x,nextPick:b,nextCtl:j,nextSaved:k,nextRef:v,nextSaveRef:S,proposeNext:C,doNext:_,pressProps:R,post:A,load:I}){const $=g.useId(),U=g.useId(),F=g.useId(),M=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",...R("enable"),onClick:()=>A({action:"enable",enabled:!e.enabled},"enable").then(()=>I(!0)),title:e.enabled?"Stop switching accounts automatically":"Switch accounts automatically when the active one nears its limit",children:r.jsx("span",{className:"switch-knob"})})]}),r.jsxs("div",{className:"ap-policy ap-setting",onKeyDown:l?m:void 0,children:[r.jsx("label",{className:"ap-setting-label",htmlFor:U,title:"Switch once the active account passes this much of its limit",children:"Switch at"}),l?r.jsx("form",{className:"ap-threshold-form",noValidate:!0,onSubmit:B=>{B.preventDefault(),x(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:d,id:U,className:"ap-manage-input ap-threshold-input",type:"text",inputMode:"numeric","aria-describedby":$,"aria-invalid":u?!0:void 0,value:n,...R("threshold"),onChange:B=>p(B.target.value),onBlur:()=>w(),autoComplete:"off",spellCheck:!1}),r.jsx("span",{className:"ap-threshold-unit","aria-hidden":!0,children:"%"})]})}):r.jsx("span",{className:"ap-field",title:"Switch once the active account passes this much of its limit",children:r.jsxs("select",{ref:o,id:U,value:n,...R("threshold"),onChange:B=>f(B.target.value),children:[Foe(t).map(B=>r.jsxs("option",{value:B,children:[B,"%"]},B)),r.jsx("option",{value:p6,children:"Custom…"})]})}),(s.sends||a)&&r.jsx("button",{ref:i,type:"button",className:"ap-manage-btn",...R("threshold"),title:s.title,onClick:()=>x(n,s),children:a&&!s.sends?s.done:s.label})]}),u?r.jsx("p",{id:$,className:"ap-threshold-note",role:"alert","data-tone":"err",children:u},"refusal"):l?r.jsx("p",{id:$,className:"ap-threshold-note",children:Doe},"hint"):null,r.jsxs("div",{className:"ap-policy ap-setting ap-next",children:[r.jsx("label",{className:"ap-setting-label",htmlFor:F,children:"Next account"}),r.jsx("span",{className:"ap-field",children:r.jsx("select",{id:F,ref:v,value:b,"aria-describedby":b==="weekly"?M:void 0,...R("next"),onChange:B=>C(B.target.value),children:Loe.map(B=>r.jsx("option",{value:B.value,children:B.label},B.value))})}),(j.sends||k)&&r.jsx("button",{ref:S,type:"button",className:"ap-manage-btn",...R("next"),title:j.title,onClick:()=>_(),children:k&&!j.sends?j.done:j.label})]}),b==="weekly"&&r.jsx("p",{id:M,className:"ap-threshold-note",children:Ioe}),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 hR=18,Hoe=1100,hl=(e,t)=>{const n=Math.sin(e*12.9898+t*78.233)*43758.5453;return n-Math.floor(n)},zoe=Array.from({length:hR},(e,t)=>{const n=-72+144*t/(hR-1)+(hl(t,1)-.5)*9,s=(n-90)*(Math.PI/180),a=(54+32*Math.cos(n*Math.PI/180))*(.74+hl(t,2)*.52);return{dx:Math.cos(s)*a,dy:Math.sin(s)*a,rot:(t%2?1:-1)*(100+hl(t,3)*260),delay:Math.round(hl(t,4)*90),dur:760+Math.round(hl(t,5)*260),scale:.8+hl(t,6)*.45,hue:t%4,round:t%3===0}});function fR({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),Hoe);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:zoe.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 Cp=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"})]}));Cp.displayName="SuccessMark";const Voe={done:", done",active:", in progress",failed:", failed",pending:""};function Goe({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 Koe({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(Goe,{status:i.status}),r.jsxs("span",{className:"aa-stage-label",children:[i.label,r.jsx("span",{className:"vis-hidden",children:Voe[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 xw=["link","approve","confirm","save"],pR={confirm:"confirm",save:"save",restore:"save"};function m6(e){return e!=null&&Object.prototype.hasOwnProperty.call(pR,e)?pR[e]:null}function Yoe({state:e,step:t,starting:n}){return e==="registering"?m6(t)??"confirm":e==="awaiting_code"?"approve":e==="awaiting_url"||e==null&&n?"link":null}function Xoe({state:e,step:t,url:n,lastLive:s}){return e==="failed"?m6(t)??(n?"approve":"link"):e==="idle"?s??"link":"link"}const Zoe={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 Joe(e,t,n){return t==="failed"?g6(e,n):Zoe[e][t]}function Qoe({live:e=null,failed:t=null,done:n=!1,state:s=null}){const a=n?xw.length:xw.indexOf(t??e);return xw.map((o,i)=>{const l=n||i<a?"done":i>a||a<0?"pending":t?"failed":"active";return{id:o,status:l,label:Joe(o,l,s)}})}function eie(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 tie={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 g6(e,t){return t==="idle"?"Sign-in ended":tie[e]}const nie=/^(?:claude|claude-swap|cswap|ccdeck|npm|uv)\b/;function Uf(e){const t=String(e??"").trim();if(!t)return"";const n=nie.test(t)?t:t[0].toUpperCase()+t.slice(1);return/[.!?…]$/.test(n)?n:`${n}.`}Uf(c6);const sie=1e4,rie=1e4,aie=5;function oie({since:e,now:t,expiresAt:n}){if(e==null||t-e<sie)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<=aie?`${a} — the sign-in stays open ${s} more minute${s===1?"":"s"}.`:`${a}.`}function iie({since:e,now:t}){return e==null||t-e<rie?null:"Still importing. claude-swap stops by itself after a minute if it cannot finish."}function lie(e){return e==="registering"?400:1500}const y6=460;function cie({fromStages:e,reducedMotion:t}){return e&&!t?y6:0}function uie({added:e,reducedMotion:t}){return e&&!t}function mR({num:e,added:t}){return t?e!=null&&e!==""?`Account ${e} added`:"Account added":"Credentials refreshed"}function die(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 hie="done";function fie(){let e=!1;return{shouldAnnounce(t){return t!==hie?(e=!1,!1):e?!1:(e=!0,!0)}}}function pS(e,t,n,s="horizontal"){if(n<=0||am(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 w6(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 pie(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 mie(e,t){return e.filter(n=>!t.includes(n.num)).map(n=>n.num)}function gie(e,t){return e.includes(t)?e.filter(n=>n!==t):[...e,t]}function yie(e){return e.length?{action:"share",accounts:[...e]}:null}function wie(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 gj(e){return`${e.email}|${e.org??""}`}function xie(e,t,n){return e&&e.map(s=>gj(s)===t?n:s)}function vie(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 gR(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 d=[...new Set(e.map(f=>{var p;return(p=Np(f.check))==null?void 0:p.short}).filter(f=>!!f))];return`${s.join(", ")}${d.length?`, ${d.join(", ")}`:""}.`}function bie(e){try{return e?new URL(e).host:""}catch{return""}}const vf=[{id:"login",label:"Sign in"},{id:"paste",label:"Paste a share"}],yR="aa-panel",wR=e=>`aa-tab-${e}`;async function qo(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}function x6({onClose:e,onChanged:t,email:n=null,onSignedIn:s}){cn("add-account");const[a,o]=g.useState("login"),[i,l]=g.useState(null),[u,d]=g.useState(""),[f,p]=g.useState(""),[m,w]=g.useState(!1),[x,b]=g.useState(!1),[j,k]=g.useState(null),[v,S]=g.useState(null),C=m||x,[_,R]=g.useState(null),[A,I]=g.useState(null),[$,U]=g.useState(null),F=g.useRef(""),M=g.useRef(!1),B=g.useRef(!1),T=g.useRef(null),P=g.useRef(null),q=g.useRef(null),K=g.useRef(null),z=g.useRef([]),H=g.useRef(!1),D=g.useRef(0),O=g.useRef(null),V=g.useRef("primer"),Z=g.useRef(null),W=g.useRef(null),X=g.useRef(null),Y=g.useRef(!1),J=g.useState(xd)[0],[Q,te]=g.useState(null),[le,de]=g.useState(!1),[oe,re]=g.useState(()=>Date.now()),[he,fe]=g.useState(null),[$e,ye]=g.useState(null),[ge,je]=g.useState(null),Le=g.useCallback(()=>{const Me=iR({started:M.current,state:i==null?void 0:i.state});Me&&qo(Me).catch(()=>{}),e()},[e,i==null?void 0:i.state]),ke=gt(Le,{focusRef:q}),Ie=wt(Le),De=g.useCallback(async()=>{if(!_n(B.current))return;const Me=++D.current;B.current=!0,w(!0),k(null),je(null),M.current=!0;let Ve=await qo(n?{action:"login",email:n}:{action:"login"}).catch(()=>null);if(n&&(Ve==null?void 0:Ve.reason)==="bad_email"&&Me===D.current&&(Ve=await qo({action:"login"}).catch(()=>null)),Me===D.current){if(B.current=!1,w(!1),!(Ve!=null&&Ve.ok)){k(jl(Ve,"could not start the sign-in"));return}l(Ve)}},[n]);g.useEffect(()=>{if(!i6(i==null?void 0:i.state))return;const Me=window.setInterval(async()=>{try{const Ve=await fetch("/api/claude-accounts/login");Ve.ok&&l(await Ve.json())}catch{}},lie(i==null?void 0:i.state));return()=>window.clearInterval(Me)},[i]);const Ue=g.useCallback(async()=>{const Me=iR({started:M.current,state:i==null?void 0:i.state});if(D.current+=1,M.current=!1,B.current=!1,w(!1),k(null),l(null),d(""),de(!1),Y.current=!0,!Me)return;const Ve=await qo(Me).catch(()=>null);je(oR({restored:Ve==null?void 0:Ve.restored,activeAccount:Ve==null?void 0:Ve.activeAccount}))},[i==null?void 0:i.state]),Ke=g.useCallback(()=>{M.current=!1,l(null),k(null),d(""),de(!1),De()},[De]),we=g.useRef(t);we.current=t;const Fe=g.useState(fie)[0];g.useEffect(()=>{Fe.shouldAnnounce(i==null?void 0:i.state)&&we.current()},[i==null?void 0:i.state,Fe]),g.useEffect(()=>{var Me;le&&((Me=T.current)==null||Me.focus())},[le]);const Re=g.useRef(s);Re.current=s;const Ae=g.useRef(null);g.useEffect(()=>{var Xe;const Me=(i==null?void 0:i.state)==="done"?i.account:null,Ve=Me?`${Me.num??""}|${Me.email}`:null;!Me||Ae.current===Ve||(Ae.current=Ve,(Xe=Re.current)==null||Xe.call(Re,Me))},[i]),g.useEffect(()=>{var Me;a==="paste"&&!H.current&&((Me=P.current)==null||Me.focus()),H.current=!1},[a]);const rt=g.useCallback(Me=>{var Xe;const Ve=pS(Me,vf.findIndex(Tt=>Tt.id===a),vf.length);Ve.kind!=="pass"&&(Me.preventDefault(),H.current=!0,o(vf[Ve.index].id),(Xe=z.current[Ve.index])==null||Xe.focus())},[a]),We=g.useCallback(async()=>{var Xe;if(!_n(B.current))return;const Me=D.current;B.current=!0,w(!0),k(null);const Ve=await qo({action:"login-code",code:u}).catch(()=>null);if(Me===D.current){if(B.current=!1,w(!1),!(Ve!=null&&Ve.ok)){k(jl(Ve,"the code was not accepted")),Ve!=null&&Ve.state&&l(Ve),(Xe=T.current)==null||Xe.select();return}d(""),l(Ve)}},[u,i]),se=g.useCallback(async()=>{if(!_n(B.current))return;B.current=!0,b(!0),S(null);const Me=await qo({action:"import",blob:f}).catch(()=>null);if(B.current=!1,b(!1),!(Me!=null&&Me.ok)){S(jl(Me,"the import failed"));return}F.current=f,p(""),U(null),R(Me.results??[]),t()},[f,t]),be=g.useCallback(async Me=>{const Ve=gj(Me);if(!_n(B.current)||!F.current)return;B.current=!0,b(!0),I(Ve),U(null);const Xe=await qo({action:"import",blob:F.current,force:!0,only:{email:Me.email,org:Me.org??""}}).catch(()=>null);if(B.current=!1,b(!1),I(null),!(Xe!=null&&Xe.ok)){U({key:Ve,text:jl(Xe,"that account could not be updated")});return}const Tt=(Xe.results??[])[0];Tt&&R(Ct=>xie(Ct,Ve,Tt)),t()},[t]),Te=(i==null?void 0:i.state)==="done"?i.account:null,Oe=oR({restored:i==null?void 0:i.restored,activeAccount:i==null?void 0:i.activeAccount}),ve=qae({login:i,started:M.current,loginError:j,loginBusy:m}),pe=Bae({state:i==null?void 0:i.state,serverError:i==null?void 0:i.error,localError:j}),_e=ve==="asking"||ve==="code"?Yoe({state:i==null?void 0:i.state,step:i==null?void 0:i.step,starting:ve==="asking"})??"link":null,ze=ve==="ended"?Xoe({state:i==null?void 0:i.state,step:i==null?void 0:i.step,url:i==null?void 0:i.url,lastLive:O.current}):null,at=Te?`${Te.num??""}|${Te.email}`:null,tt=ve==="done"&&at!==Q&&cie({fromStages:V.current==="progress",reducedMotion:J})>0,xt=ve==="primer"?"primer":ve==="done"&&Te&&!tt?"done":"progress",Mt=ze?"failed":tt?"resolving":"live",Xt=Qoe(tt?{done:!0}:ze?{failed:ze,state:i==null?void 0:i.state}:{live:_e}),tr=ze?g6(ze,i==null?void 0:i.state):"",Cs=Uf(pe.message),zn=_e==="approve"?oie({since:he,now:oe,expiresAt:i==null?void 0:i.expiresAt}):null,ts=x?iie({since:$e,now:oe}):null,_s=a==="login"?xt==="done"&&Te?`${mR(Te)}.`:Mt==="failed"?`${tr}. ${Cs}`:xt==="progress"&&!tt?die(_e)??"":"":x?"Importing the share.":v?Uf(v):_?Uf(gR(_)):"";g.useEffect(()=>{_e&&(O.current=_e)},[_e]),g.useEffect(()=>{V.current=xt},[xt]),g.useEffect(()=>{if(!tt||!at)return;const Me=window.setTimeout(()=>te(at),y6);return()=>window.clearTimeout(Me)},[tt,at]);const sn=_e==="approve";g.useEffect(()=>{fe(sn?Date.now():null)},[sn]),g.useEffect(()=>{ye(x?Date.now():null)},[x]);const zt=sn||x;return g.useEffect(()=>{if(!zt)return;re(Date.now());const Me=window.setInterval(()=>re(Date.now()),1e3);return()=>window.clearInterval(Me)},[zt]),g.useEffect(()=>{var Ve,Xe,Tt,Ct;if(a!=="login")return;if(xt==="done"){(Ve=W.current)==null||Ve.focus();return}if(xt==="primer"){Y.current&&((Xe=q.current)==null||Xe.focus()),Y.current=!1;return}if(Mt==="failed"){(Tt=X.current)==null||Tt.focus();return}const Me=document.activeElement;_e==="approve"&&(!Me||Me===document.body)&&((Ct=Z.current)==null||Ct.focus())},[a,xt,Mt,_e]),vt.createPortal(r.jsx("div",{className:"modal-backdrop",...Ie,role:"presentation",children:r.jsxs("div",{ref:ke,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:vf.map((Me,Ve)=>r.jsx("button",{type:"button",role:"tab",id:wR(Me.id),ref:Xe=>{z.current[Ve]=Xe},"aria-selected":a===Me.id,"aria-controls":yR,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:Le,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),r.jsxs("section",{className:"modal-body aa-body",id:yR,role:"tabpanel","aria-labelledby":wR(a),children:[a==="login"?xt==="done"&&Te?r.jsxs("div",{className:`aa-done${Q===at?" from-orbit":""}`,children:[r.jsx(Cp,{ref:K}),uie({added:Te.added,reducedMotion:J})&&r.jsx(fR,{anchor:K}),r.jsx("h4",{children:mR(Te)}),r.jsxs("p",{className:"aa-note",children:[r.jsx("strong",{children:Te.email}),Te.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:W,className:"btn primary",onClick:Le,children:"Done"})]}):xt==="progress"?r.jsx(Koe,{rows:Xt,phase:Mt,detail:Mt==="failed"?r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"aa-note aa-reason",children:Cs}),r.jsx("div",{className:"aa-actions",children:r.jsx("button",{type:"button",ref:X,className:"btn primary",onClick:Ke,children:ze==="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:[bie(i.url),r.jsx("svg",{width:"9",height:"9",viewBox:"0 0 10 10",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:r.jsx("path",{d:"M3 7 7 3M3.6 3H7v3.4"})})]})]}),zn?r.jsx("p",{className:"aa-note aa-arrive",children:zn}):null,r.jsxs("details",{className:"aa-code",open: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=>d(Me.target.value),onKeyDown:Me=>{Me.key==="Enter"&&u.trim()&&!C&&We()},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",...qn(C,!u.trim()||i.state==="registering"),onClick:We,children:"Continue"})]}),(j||i.error)&&r.jsx("p",{className:"aa-err",children:j??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:eie(_e,i==null?void 0:i.step)}):null,actions:_e==="link"||_e==="approve"?r.jsx("button",{type:"button",className:"btn",onClick:Ue,children:"Cancel"}):null}):r.jsxs("div",{className:"aa-step aa-primer",children:[ge?r.jsx("p",{className:"aa-note aa-warn",role:"status",children:ge}):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:q,className:"btn primary",...qn(C),onClick:De,children:"Open the sign-in page"})})]}):_?(()=>{const Me=_.filter(Xe=>Xe.state==="imported").length,Ve=_.some(Xe=>Np(Xe.check));return r.jsxs("div",{className:"aa-done",children:[!Ve&&r.jsx(Cp,{ref:K}),Me>0&&!Ve&&r.jsx(fR,{anchor:K}),r.jsx("h4",{children:gR(_)}),_.length>0&&r.jsx("ul",{className:"aa-results",children:_.map(Xe=>{const Tt=gj(Xe),Ct=Np(Xe.check);return r.jsxs("li",{className:`aa-result ${Xe.state}`,children:[r.jsx("span",{className:"aa-result-who",children:Xe.email||(Xe.num?`slot ${Xe.num}`:"an account")}),r.jsx("span",{className:"aa-result-what",children:vie(Xe.state)}),Xe.state==="present"&&r.jsx("button",{type:"button",className:"aa-result-fix","aria-busy":A===Tt,title:`Overwrite the stored login for ${Xe.email} with the one in this share. Do this when that account has stopped working here; if it works, leave it.`,onClick:()=>be(Xe),children:A===Tt?"updating…":"update anyway"}),Ct&&r.jsx("span",{className:"aa-result-err",children:Ct.long}),($==null?void 0:$.key)===Tt&&r.jsx("span",{className:"aa-result-err",children:$.text})]},Tt)})}),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:Le,children:"Done"}),r.jsx("button",{type:"button",className:"btn",onClick:()=>{F.current="",U(null),R(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:P,type:"text",value:f,onChange:Me=>p(Me.target.value),onKeyDown:Me=>{Me.key==="Enter"&&f.trim()&&!C&&se()},placeholder:"ccdeck2:…",spellCheck:!1,autoComplete:"off","aria-label":"Shared account"}),r.jsx("button",{type:"button",className:"btn primary",...qn(C,!f.trim()),onClick:se,children:x?"importing…":"Import"})]}),v&&r.jsx("p",{className:"aa-err",children:v}),x?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:ts??"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:_s})]})]})}),document.body)}function kie(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 jie(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 Nie=64;function Sie(e,t){const n=e.trim();return{alias:n,commit:n!==(t??"").trim()}}function Cie(e,t,n){return t!=null&&e.some(s=>s.slot===t)?t:n}function _ie(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 Eie(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 Tie(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 Aie({a:e,slots:t,nowSec:n,boundaryId:s,accountMenu:a,busy:o,pressProps:i,onProjects:l,onRotation:u,home:d,onHome:f}){const{menu:p,menuError:m,aliasDraft:w,confirmRemove:x,share:b,shareCopied:j,slotDraft:k,dropMenu:v,closeMenu:S,startRename:C,typeAlias:_,doAlias:R,startMove:A,pickSlot:I,doSlot:$,makeShare:U,copyShare:F,pressRemove:M}=a;if(!p)return null;const B=`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(ac,{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}`:B,start:p.start,onClose:v,children:[p.view==="menu"&&r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",onClick:()=>C(e.num,e.alias),children:"Rename"}),r.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",onClick:()=>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:()=>U(e.num),children:o===`share-${e.num}`?"Sharing…":"Share"}),r.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",title:"See how much this account worked in each project",onClick:()=>l(),children:"Projects"}),(!e.active||e.disabled)&&r.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",...i(`rot-${e.num}`),title:e.disabled?"Return this account to auto-rotation":"Hold this account out of auto-rotation",onClick:()=>u(),children:e.disabled?"Put back in rotation":"Hold out of rotation"}),(d||e.email)&&r.jsx("button",{type:"button",role:"menuitem",className:"ap-menu-item",...i(`home-${e.num}`),title:d?"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:d?"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${x===e.num?" armed":""}`,...i(`rm-${e.num}`),"aria-label":x===e.num?"Confirm remove":void 0,title:x===e.num?"This deletes the stored credentials for this account":"Remove this account from claude-swap",onClick:()=>M(e.num),children:o===`rm-${e.num}`?"Removing…":x===e.num?"Confirm":"Remove"}),T]}),p.view==="rename"&&r.jsxs("form",{className:"ap-pop-form",onSubmit:P=>{P.preventDefault(),R(e.num,e.alias)},children:[r.jsx("label",{className:"ap-pop-title",id:B,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:P=>_(P.target.value),maxLength:Nie,placeholder:"e.g. work",spellCheck:!1,autoComplete:"off",autoFocus:!0,onFocus:P=>P.currentTarget.select()}),T,r.jsxs("div",{className:"ap-pop-actions",children:[r.jsx("button",{type:"button",className:"btn",onClick:()=>S(),children:"Cancel"}),r.jsx("button",{type:"submit",className:"btn primary",...i(`alias-${e.num}`),title:"A short name to show instead of the email",children:o===`alias-${e.num}`?"…":"Save"})]})]}),p.view==="move"&&(()=>{const P=kie(t,e.num),q=Cie(P,k,e.num),K=_ie(P,q,e.num);return r.jsxs("div",{className:"ap-pop-form",children:[r.jsx("label",{className:"ap-pop-title",id:B,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(q),...i(`move-${e.num}`),onChange:z=>I(Number(z.target.value)),autoFocus:!0,children:P.map(z=>r.jsx("option",{value:z.slot,children:z.label},z.slot))})}),T,r.jsxs("div",{className:"ap-pop-actions",children:[r.jsx("button",{type:"button",className:"btn",onClick:()=>S(),children:"Cancel"}),r.jsx("button",{type:"button",className:"btn primary",...i(`move-${e.num}`),title:K.title,onClick:()=>$(e.num,q,K),children:o===`move-${e.num}`?"…":Nu(K.label)})]})]})})(),p.view==="share"&&(b==null?void 0:b.num)===e.num&&(()=>{const P=w6(b.expiresAt,n),q=P.tone==="gone";return r.jsxs("div",{className:"ap-pop-form",children:[r.jsx("p",{className:"ap-pop-title",id:B,children:"Share account"}),r.jsx("code",{className:"ap-share-blob",children:b.blob}),r.jsxs("p",{className:"ap-pop-note",title:"This text is the account's password. It is base64 of plain JSON — the expiry inside it is not signed, so anyone holding a copy can change it, and the login itself is in there in the clear either way. The countdown only says how long another deck's import dialog will still accept it. If a copy escapes, sign the account out and back in.",children:[r.jsx("span",{className:"ap-share-warn",children:"This is the password"})," · ",r.jsx("span",{className:`ap-share-expiry ${P.tone}`,children:P.text})]}),T,r.jsxs("div",{className:"ap-pop-actions",children:[r.jsx("button",{type:"button",className:"btn",onClick:()=>S(),children:"Done"}),r.jsx("button",{type:"button",className:"btn primary",...i(`share-${e.num}`),autoFocus:!0,onClick:async()=>{if(q){await U(e.num);return}await F(b.blob)},children:q?"Make a new share":j?"Copied":"Copy"})]})]})})()]})}const Rie=6;function Mie(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?$ie(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 $ie(e){const t=e.map(n=>n.headroom).filter(n=>typeof n=="number");return t.length?Math.round(Math.max(...t)):null}function Lie(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,Rie),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 v6=160,b6=140;function Iie(){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),b6)},holdPeek:()=>window.clearTimeout(n.current),dropPeek:()=>{window.clearTimeout(n.current),t(!1)}}}function Oie(e){var t;return((t=e==null?void 0:e.detail)==null?void 0:t.fix)==="give_back"}function zs(e,t){return{text:e,giveBack:Oie(t),done:!1}}async function Pie(){try{return await(await fetch("/api/prefs/give-back",{method:"POST",headers:{"Content-Type":"application/json"},body:"{}"})).json().catch(()=>null)}catch{return null}}const Die={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 Fie(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?Die[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 yj=5e3,k6=6e4;function en(e,t){if(t==null)return`Could not ${e} — the deck did not answer.`;const n=t.reason?Uie(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 Bie={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."},qie=new Set(["EACCES","EPERM"]);function Uie(e,t){const n=Bie[e];if(!n)return;const s=e==="prefs_unreadable"&&t?Wie(t):void 0,a=t!=null&&t.code&&t.code!=="BADJSON"?` Error code: ${t.code}.`:"";return(s??n)+a}function Wie({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&&!qie.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 fl(e,t){return(await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).json().catch(()=>null)}function Hie(e,t){const[n,s]=g.useState(null),[a,o]=g.useState([]),[i,l]=g.useState(null),[u,d]=g.useState(null),f=g.useRef(null),p=g.useCallback(F=>cm(f.current)?(f.current=F,l(F),!0):!1,[]),m=g.useCallback(()=>{f.current=null,j.current&&l(null)},[]),w=F=>{const M=eo(i,F);return{disabled:M.disabled,"aria-busy":M.busy}},[x,b]=g.useState(()=>Date.now()),j=g.useRef(!0),k=g.useRef(yj),v=g.useCallback(async()=>{var F,M;try{const[B,T]=await Promise.all([fetch("/api/lan").then(P=>P.json()),fetch("/api/prefs").then(P=>P.json())]);if(!j.current)return;B!=null&&B.ok&&s(B),T!=null&&T.ok&&o(Array.isArray((M=(F=T.prefs)==null?void 0:F.lan)==null?void 0:M.manual)?T.prefs.lan.manual:[]),k.current=(B==null?void 0:B.enabled)===!0?yj:k6}catch{}},[]);g.useEffect(()=>{j.current=!0;let F=0;const M=async()=>{b(Date.now()),await v(),j.current&&(F=window.setTimeout(M,k.current))};return M(),()=>{j.current=!1,window.clearTimeout(F)}},[v]);const S=g.useCallback(async()=>{const F=(n==null?void 0:n.enabled)===!0;if(p("switch"))try{const M=await fl("/api/prefs",{lan:{enabled:!F}});if(!j.current)return;M!=null&&M.ok?(d(null),F||t()):d(zs(en(F?"turn this off":"turn this on",M),M)),await v()}catch{j.current&&d(zs(en(F?"turn this off":"turn this on",null)))}finally{m()}},[n==null?void 0:n.enabled,v,p,m,t]),C=g.useCallback(async(F,M,B)=>{if(!p(`${F}:${M}`))return null;let T=null;try{const P=await fl("/api/lan/peer",{action:F,fp:M});if(!j.current)return null;P!=null&&P.ok?(s(P),d(null)):(T=en(B,P),d(zs(T,P))),await v()}catch{T=en(B,null),j.current&&d(zs(T))}finally{m()}return T},[v,p,m]),_=g.useCallback(async F=>{if(!p(`drop:${F}`))return null;let M=null;try{const B=await fl("/api/prefs",{lan:{manual:a.filter(T=>T!==F)}});if(!j.current)return null;B!=null&&B.ok?(d(null),e()):(M=en("stop dialling that address",B),d(zs(M,B))),await v()}catch{M=en("stop dialling that address",null),j.current&&d(zs(M))}finally{m()}return M},[a,v,e,p,m]),R=g.useCallback(async(F,M)=>{if(!p(`alias:${F}`))return"Something else is still being saved. Try again in a moment.";try{const B=await fl("/api/lan/peer",{action:"alias",fp:F,name:M});return j.current?B!=null&&B.ok?(s(B),null):en("rename that deck",B):null}catch{return en("rename that deck",null)}finally{m()}},[p,m]),A=g.useCallback(async F=>{if(!p(`check:${F}`))return null;try{const M=await fl("/api/lan/sync",{fp:F});return j.current?M!=null&&M.ok?(s(M),e(),null):(M==null?void 0:M.reason)==="no_address"?"There is no address here to call it on. It calls this deck, and it is up to date each time it does.":en("check that deck",M):null}catch{return en("check that deck",null)}finally{m()}},[p,m,e]),I=g.useCallback(async()=>{if(p("check"))try{const F=await fl("/api/lan/sync",{});if(!j.current)return;F!=null&&F.ok?(s(F),d(null)):d(zs(en("check the other decks",F),F)),e()}catch{j.current&&d(zs(en("check the other decks",null)))}finally{m()}},[p,m,e]);return{status:n,manual:a,now:x,busy:i,failure:u,dismissFailure:()=>d(null),answerGiveBack:F=>{d(F),F.done&&(v(),e())},pressProps:w,load:v,toggle:S,answer:C,dropAddress:_,rename:R,checkOne:A,checkNow:I}}function zie(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=fi({armedFor:t,target:o.fp,armedAt:s.current,now:i,gapMs:hi});if(l==="arm"){n(o.fp),s.current=i;return}l!=="ignore"&&(n(null),e("unpair",o.fp,"unpair that deck"))}}}function j6({title:e,steps:t,finish:n,aside:s,onClose:a}){const o=g.useRef(null),i=gt(a,{focusRef:o}),l=wt(a),[u,d]=g.useState(0),f=u===t.length-1,p=t[u],m=b=>d(Math.max(0,Math.min(t.length-1,b)));g.useEffect(()=>{var b,j;Hn(((b=document.activeElement)==null?void 0:b.tagName)??null)&&((j=o.current)==null||j.focus())},[u]);const w=b=>{b.key!=="ArrowRight"&&b.key!=="ArrowLeft"||(b.preventDefault(),b.stopPropagation(),m(b.key==="ArrowRight"?u+1:u-1))},x=()=>{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:b=>b.stopPropagation(),onKeyDown:w,role:"dialog","aria-modal":"true","aria-labelledby":"guide-title",children:[r.jsxs("header",{className:"modal-head",children:[r.jsxs("div",{className:"modal-title",children:[r.jsx("span",{id:"guide-title",className:"modal-tool-name",children:e}),r.jsxs("span",{className:"modal-tool-id",children:[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((b,j)=>r.jsx("button",{type:"button",className:"glyph-btn guide-dot","aria-label":`Step ${j+1} of ${t.length}`,"aria-current":j===u?"step":void 0,onClick:()=>m(j)},j))}),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:x,children:f?(n==null?void 0:n.label)??"Done":"Next"})]})]})]})}),document.body)}const wj={ok:"ga-ok",warn:"ga-warn",accent:"ga-accent",flight:"ga-flight"};function js({children:e}){return r.jsx("svg",{className:"guide-art",viewBox:"0 0 440 200","aria-hidden":!0,focusable:"false",children:e})}function bs({x:e,y:t=34,w:n=176,h:s=132,label:a}){return r.jsxs(r.Fragment,{children:[a&&r.jsx("text",{x:e+2,y:t-9,className:"ga-cap",children:a}),r.jsx("rect",{x:e,y:t,width:n,height:s,rx:10,className:"ga-screen"})]})}function Zs({x:e,y:t,email:n,state:s,tone:a,bars:o}){return r.jsxs(r.Fragment,{children:[r.jsx("circle",{cx:e+3,cy:t-4,r:3,className:wj[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 ${wj[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 N6({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 bf({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 xR({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 vR({x:e,y:t,d:n}){return r.jsx("path",{d:n,transform:`translate(${e} ${t})`,className:"ga-glyph"})}function mS({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 gS(){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 Nl({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:wj[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 Il({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 _p({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(N6,{x:e+118,y:t-13,on:!0})]})}function Vie(){return r.jsxs(js,{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 Gie(){return r.jsxs(js,{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(Nl,{x:20,y:80,w:116,title:"main",sub:"Opus 5 · 9 tools",tone:"accent"}),r.jsx(Nl,{x:196,y:18,w:112,title:"explore",sub:"Haiku · 14 tools",tone:"flight"}),r.jsx(Nl,{x:196,y:80,w:112,title:"tests",sub:"Sonnet · 6 tools",tone:"flight"}),r.jsx(Nl,{x:196,y:142,w:112,title:"review",sub:"done · 38s",tone:"ok"}),r.jsx(Il,{x:326,y:28,label:"Read"}),r.jsx(Il,{x:380,y:28,label:"Grep",live:!0}),r.jsx(Il,{x:326,y:90,label:"Bash",live:!0})]})}function bR({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 Kie(){return r.jsxs(js,{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(bR,{x:216,y:80,label:"5-hour window",pct:24,note:"resets in 53m"}),r.jsx(bR,{x:216,y:124,label:"7-day window",pct:61,note:"resets in 4d"})]})}function Yie(){return r.jsxs(js,{children:[r.jsx("rect",{x:14,y:40,width:172,height:120,rx:10,className:"ga-canvas"}),r.jsx(Nl,{x:30,y:80,w:140,title:"tests",sub:"Sonnet 5 · 6 tools",tone:"flight"}),r.jsx(mS,{x:156,y:106}),r.jsx("path",{d:"M170 92C186 92 184 60 200 60",className:"ga-arc"}),r.jsx("path",{d:"M195 56l5 4-5 4",className:"ga-arrow"}),r.jsx(bs,{x:200,y:22,w:226,h:160}),r.jsx("text",{x:214,y:46,className:"ga-t ga-strong",children:"tests"}),r.jsx("text",{x:412,y:46,className:"ga-s",textAnchor:"end",children:"Sonnet 5 · 38s"}),r.jsx("line",{x1:200,y1:56,x2:426,y2:56,className:"ga-line"}),r.jsx("text",{x:214,y:76,className:"ga-cap",children:"PROMPT"}),r.jsx("text",{x:214,y:92,className:"ga-t",children:"Run the suite and fix what fails"}),r.jsx("text",{x:214,y:116,className:"ga-cap",children:"TOOLS · 6"}),r.jsx(Il,{x:214,y:122,label:"Read"}),r.jsx(Il,{x:266,y:122,label:"Edit"}),r.jsx(Il,{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 Xie(){const e=[18,24,28,14,22,26,30,16,24,28,20,26];return r.jsxs(js,{children:[r.jsx(bs,{x:14,y:20,w:412,h:160}),r.jsx("text",{x:28,y:44,className:"ga-t ga-strong",children:"This machine"}),r.jsx("text",{x:412,y:44,className:"ga-s",textAnchor:"end",children:"12 cores · up 10d"}),r.jsx("line",{x1:14,y1:56,x2:426,y2:56,className:"ga-line"}),r.jsx("text",{x:28,y:76,className:"ga-cap",children:"CORES"}),e.map((t,n)=>r.jsxs("g",{children:[r.jsx("rect",{x:28+n*15,y:82,width:10,height:30,rx:2,className:"ga-track"}),r.jsx("rect",{x:28+n*15,y:112-t,width:10,height:t,rx:2,className:"ga-accent"})]},n)),r.jsx("text",{x:28,y:136,className:"ga-cap",children:"MEMORY"}),r.jsx("rect",{x:28,y:143,width:178,height:5,rx:2.5,className:"ga-track"}),r.jsx("rect",{x:28,y:143,width:105,height:5,rx:2.5,className:"ga-accent"}),r.jsx("text",{x:28,y:165,className:"ga-s",children:"18.9 GB of 32.0 GB"}),r.jsx("text",{x:240,y:76,className:"ga-cap",children:"THERMAL"}),r.jsx("text",{x:240,y:100,className:"ga-big",children:"66 °C"}),r.jsx("text",{x:240,y:118,className:"ga-s ga-ok",children:"running at full speed"}),r.jsx("text",{x:240,y:142,className:"ga-cap",children:"BUSIEST PROCESSES"}),r.jsx("text",{x:240,y:160,className:"ga-s ga-mono",children:"node · claude"}),r.jsx("text",{x:412,y:160,className:"ga-s ga-mono",textAnchor:"end",children:"38%"}),r.jsx("text",{x:240,y:176,className:"ga-s ga-mono",children:"esbuild"}),r.jsx("text",{x:412,y:176,className:"ga-s ga-mono",textAnchor:"end",children:"21%"})]})}function Zie(){return r.jsxs(js,{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(Nl,{x:278,y:80,w:120,title:"my-project",sub:"Opus 5 · live",tone:"accent"})})]})}function Jie(){return r.jsxs(js,{children:[r.jsx(bs,{x:14,y:16,w:232,h:170}),r.jsx("text",{x:28,y:40,className:"ga-t ga-strong",children:"Claude accounts"}),r.jsx(vR,{x:196,y:33,d:"M7 2.2v9.6M2.2 7h9.6"}),r.jsx(vR,{x:220,y:33,d:"M3.3 10.7L10.7 3.3M5.2 3.3h5.5v5.5"}),r.jsx("line",{x1:14,y1:52,x2:246,y2:52,className:"ga-line"}),r.jsx(Zs,{x:28,y:74,email:"work@team.dev",state:"working",tone:"ok",bars:[24,61]}),r.jsx("rect",{x:190,y:62,width:44,height:18,rx:9,className:"ga-accent"}),r.jsx("text",{x:212,y:74,className:"ga-s ga-on-accent",textAnchor:"middle",children:"active"}),r.jsx("line",{x1:14,y1:140,x2:246,y2:140,className:"ga-line"}),r.jsx(Zs,{x:28,y:160,email:"personal@me.dev",state:"signed in",tone:"ok"}),r.jsx("rect",{x:188,y:148,width:46,height:18,rx:9,className:"ga-chip"}),r.jsx("text",{x:211,y:160,className:"ga-s",textAnchor:"middle",children:"switch"}),r.jsx(mS,{x:221,y:161}),r.jsx("path",{d:"M250 40C270 40 262 78 282 78",className:"ga-arc"}),r.jsx("path",{d:"M277 74l5 4-5 4",className:"ga-arrow"}),r.jsx(bs,{x:282,y:62,w:144,h:64,label:"ANOTHER MACHINE"}),r.jsx("g",{className:"ga-pop",children:r.jsx(Zs,{x:296,y:92,email:"work@team.dev",state:"shared here",tone:"ok"})})]})}function Qie(){return r.jsxs(js,{children:[r.jsx(bs,{x:14,label:"THIS MACHINE"}),r.jsx(_p,{x:28,y:60}),r.jsx("g",{className:"ga-swap-out",children:r.jsx(Zs,{x:28,y:98,email:"work@team.dev",state:"login expired",tone:"warn"})}),r.jsx("g",{className:"ga-swap-in",children:r.jsx(Zs,{x:28,y:98,email:"work@team.dev",state:"working again",tone:"ok",bars:[24,61]})}),r.jsx(bs,{x:250,label:"ANOTHER MACHINE"}),r.jsx(_p,{x:264,y:60}),r.jsx(Zs,{x:264,y:98,email:"work@team.dev",state:"working",tone:"ok",bars:[24,61]}),r.jsx("path",{d:"M246 120C234 80 206 80 194 120",className:"ga-arc"}),r.jsx("g",{className:"ga-travel ga-travel-low",transform:"translate(220 90)",children:r.jsx(gS,{})})]})}const ele=[{art:r.jsx(Vie,{}),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(Gie,{}),line:"Every agent and subagent is a node. Tool calls light up as they run."},{art:r.jsx(Yie,{}),line:"Double-click any node: its prompt, every tool call, tokens and timing."},{art:r.jsx(Kie,{}),line:"What each session costs, and how much quota is left."},{art:r.jsx(Xie,{}),line:"Cores, memory and heat while the agents run, and what is hogging them."},{art:r.jsx(Jie,{}),line:"Several Claude accounts: switch, add one, share one to another machine."},{art:r.jsx(Qie,{}),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(Zie,{}),line:"Run claude or codex in any folder. It shows up here on its own."}];function tle(){return r.jsxs(js,{children:[r.jsx(bs,{x:14,label:"THIS MACHINE"}),r.jsx(Zs,{x:28,y:64,email:"work@team.dev",state:"login expired",tone:"warn"}),r.jsx("rect",{x:40,y:94,width:86,height:20,rx:10,className:"ga-pill-warn"}),r.jsx("text",{x:83,y:108,className:"ga-s ga-warn",textAnchor:"middle",children:"sign in again"}),r.jsx("line",{x1:198,y1:100,x2:242,y2:100,className:"ga-off"}),r.jsx(bs,{x:250,label:"ANOTHER MACHINE"}),r.jsx(Zs,{x:264,y:64,email:"work@team.dev",state:"working",tone:"ok",bars:[24,61]})]})}function nle(){return r.jsxs(js,{children:[r.jsx(bs,{x:14,label:"THIS MACHINE"}),r.jsx(_p,{x:28,y:60}),r.jsx(bf,{x:28,y:92,name:"Ana's MacBook"}),r.jsx(bf,{x:28,y:114,name:"Dorin's PC"}),r.jsx(bs,{x:250,label:"ANOTHER MACHINE"}),r.jsx(_p,{x:264,y:60}),r.jsx(bf,{x:264,y:92,name:"Your MacBook"}),r.jsx(bf,{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 sle(){return r.jsxs(js,{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(xR,{x:106,y:88,on:!0}),r.jsx("text",{x:126,y:98,className:"ga-t ga-mono",children:"work@team.dev"}),r.jsx(xR,{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(N6,{x:304,y:157,on:!0}),r.jsx(mS,{x:115,y:97})]})}function rle(){return r.jsxs(js,{children:[r.jsx(bs,{x:14,label:"THIS MACHINE"}),r.jsx("g",{className:"ga-swap-out",children:r.jsx(Zs,{x:28,y:64,email:"work@team.dev",state:"login expired",tone:"warn"})}),r.jsx("g",{className:"ga-swap-in",children:r.jsx(Zs,{x:28,y:64,email:"work@team.dev",state:"working again",tone:"ok",bars:[24,61]})}),r.jsx(bs,{x:250,label:"ANOTHER MACHINE"}),r.jsx(Zs,{x:264,y:64,email:"work@team.dev",state:"working",tone:"ok",bars:[24,61]}),r.jsx("path",{d:"M246 96C234 56 206 56 194 96",className:"ga-arc"}),r.jsx("g",{className:"ga-travel",transform:"translate(220 66)",children:r.jsx(gS,{})})]})}const ale=[{art:r.jsx(tle,{}),line:"A login can expire on one machine while it still works on another."},{art:r.jsx(nle,{}),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(sle,{}),line:"Tick which logins this machine may hand out. Nothing is shared until you do."},{art:r.jsx(rle,{}),line:"An expired login is copied from a paired machine within a minute."}];function ole(){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(gS,{})})]})}const ile={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."},lle=1600;function S6({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 io(o.join(`
|
|
103
|
+
`))&&a.current&&(s(!0),window.setTimeout(()=>{a.current&&s(!1)},lle))},[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:ile[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 cle(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 ule(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 vw(e,t){return(await fetch(e,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(t)})).json().catch(()=>null)}const dle={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."},hle={not_running:"This deck is not on the network yet. Turn Local network on, then make one."};function kR(e,t,n){return(t==null?void 0:t.reason)&&e[t.reason]||en(n,t)}function fle({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),d=e.pairingMode==="invite",f=gt(s,{focusRef:d?i:o}),p=wt(s),[m,w]=g.useState(""),[x,b]=g.useState(""),[j,k]=g.useState(null),[v,S]=g.useState(null),[C,_]=g.useState(null),[R,A]=g.useState(null),[I,$]=g.useState(()=>Date.now());g.useEffect(()=>{const Y=window.setInterval(()=>$(Date.now()),1e3);return()=>window.clearInterval(Y)},[]);const U=g.useRef(!0);g.useEffect(()=>()=>{U.current=!1},[]);const F=g.useRef(null),M=g.useRef(null),B=g.useCallback(Y=>cm(F.current)?(F.current=Y,_(Y),!0):!1,[]),T=g.useCallback(()=>{F.current=null,U.current&&_(null)},[]),P=Y=>{const J=eo(C,Y);return{disabled:J.disabled,"aria-busy":J.busy}},q=Y=>(j==null?void 0:j.field)===Y?{"aria-invalid":!0,"aria-describedby":"lan-add-failure"}:{},K=Y=>k(J=>J&&J.field===Y?null:J),z=g.useCallback(async()=>{if(d)return;const Y=cle(m);if(!Y){k({text:ple(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){k({text:`Already paired with ${Q.name} at that address.`,field:"addr"});return}if(t.includes(J)){k({text:"This deck already calls that address.",field:"addr"});return}if(B("add"))try{const te=await vw("/api/prefs",{lan:{manual:[...t,J]}});if(!U.current)return;te!=null&&te.ok?(k(null),w(""),a(),s()):k({text:en("add that address",te),field:"addr"})}catch{U.current&&k({text:en("add that address",null),field:"addr"})}finally{T()}},[m,d,t,e.peers,a,s,B,T]),H=g.useCallback(async Y=>{if(!B(`invite:${Y}`))return;const J=Y==="make"?"make an invite":"cancel that invite";try{const Q=await vw("/api/lan/invite",{action:Y});if(!U.current)return;Q!=null&&Q.ok?(M.current=Y,k(null),S(null),a()):k({text:kR(hle,Q,J)})}catch{U.current&&k({text:en(J,null)})}finally{T()}},[a,B,T]),D=g.useCallback(async()=>{const Y=x.trim();if(!(!Y||!B("join"))){A(null);try{const J=await vw("/api/lan/invite",{action:"join",token:Y});if(!U.current)return;J!=null&&J.ok?(b(""),k(null),a(),s()):(J==null?void 0:J.reason)==="unreachable"&&Array.isArray(J.tried)&&J.tried.length?(A(J.tried),k(null)):(A(null),k({text:kR(dle,J,"use that invite"),field:"join"}))}catch{U.current&&k({text:en("use that invite",null),field:"join"})}finally{T()}}},[x,a,s,B,T]),O=g.useCallback(async(Y,J)=>{try{await navigator.clipboard.writeText(Y),S(J),window.setTimeout(()=>{U.current&&S(Q=>Q===J?null:Q)},1600)}catch{k({text:"Could not copy it — select the text and copy it by hand."})}},[]),V=e.invite&&e.invite.expiresAt>I?e.invite:null,Z=g.useRef(!1);g.useEffect(()=>{n!=="invite"||Z.current||V||(Z.current=!0,H("make"))},[n,V,H]);const W=g.useRef(!1);g.useEffect(()=>{var Y;n!=="invite"||W.current||!V||(W.current=!0,(Y=l.current)==null||Y.focus())},[n,V]),g.useEffect(()=>{var J,Q;const Y=M.current;!Y||Y==="make"!=!!V||(M.current=null,Hn(((J=document.activeElement)==null?void 0:J.tagName)??null)&&((Q=(Y==="make"?l:u).current)==null||Q.focus()))},[V]);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:[j&&r.jsxs("div",{className:"ap-failure",role:"alert",children:[r.jsx("span",{id:"lan-add-failure",className:"ap-failure-text",children:j.text}),r.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>k(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),r.jsx(S6,{reach:e.reach,where:"dialog"}),d&&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."})}),!d&&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,...q("addr"),onChange:Y=>{w(Y.target.value),K("addr")},onKeyDown:Y=>{Y.key==="Enter"&&z()}}),m.trim()!==""&&r.jsx("button",{type:"button",className:"ap-manage-btn",...P("add"),onClick:()=>void z(),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",...P("copy:mine"),onClick:()=>void O(X.join(" "),"mine"),title:"Copy this deck's address, to send to whoever is adding it",children:v==="mine"?"copied":"copy"})]})]}),r.jsxs("div",{className:"modal-section",children:[r.jsxs("h3",{className:"lan-h",children:["With an invite",!V&&r.jsx("button",{type:"button",className:"ap-lan-word lan-h-act",ref:u,...P("invite:make"),onClick:()=>void H("make"),title:"One piece of text you send them. They paste it, and the two decks pair — nobody has to press anything here.",children:C==="invite:make"?"making…":"make one to send"})]}),r.jsxs("div",{className:"ap-lan-row",children:[r.jsx("input",{ref:i,className:"ap-manage-input ap-lan-input","aria-label":"An invite you were sent",value:x,placeholder:"paste one you were sent",spellCheck:!1,...q("join"),onChange:Y=>{b(Y.target.value),A(null),K("join")},onKeyDown:Y=>{Y.key==="Enter"&&D()}}),x.trim()!==""&&r.jsx("button",{type:"button",className:"ap-manage-btn",...P("join"),onClick:()=>void D(),title:"Reach that deck and pair with it. Nobody has to press anything there.",children:C==="join"?"joining…":"join"})]}),r.jsx("p",{className:"lan-note",children:"Pasting one pairs both decks on the spot — nobody has to accept."}),R&&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."}),R.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))]}),V&&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:[ule(V.expiresAt,I)," left"]})]}),r.jsx("code",{className:"ap-lan-token",children:V.token}),r.jsxs("div",{className:"ap-lan-acts",children:[r.jsx("button",{type:"button",className:"ap-manage-btn",ref:l,...P("copy:invite"),"aria-label":v==="invite"?"Invite copied":"Copy invite","aria-describedby":"lan-invite-left",onClick:()=>void O(V.token,"invite"),title:"Copy it, and send it however you already talk to them",children:v==="invite"?"copied":"copy"}),r.jsx("button",{type:"button",className:"ap-manage-btn",...P("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 ple(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 mle({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 gle({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((d,f)=>r.jsxs("li",{className:"ap-lan-who","data-tone":d.tone,children:[r.jsx("i",{className:d.here?"ap-pulse":"ap-dot","aria-hidden":!0}),r.jsxs("span",{className:"ap-lan-who-name","aria-hidden":!0,children:[d.name,d.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(d.fp),children:r.jsxs("span",{className:"vis-hidden",children:[d.name,d.via==="tailscale"?", over Tailscale":"",", details"]})}),r.jsx("span",{id:`lan-who-state-${f}`,className:d.quiet?"vis-hidden":"ap-lan-who-when",children:d.state}),d.kind==="nearby"&&t!=="invite"&&r.jsx("button",{type:"button",className:"ap-manage-btn ap-lan-do",...s(`accept:${d.fp}`),onClick:()=>void a("accept",d.fp,"reach that deck"),"aria-label":`Ask ${d.name} to pair`,title:`Send ${d.name} a request. Somebody at that machine has to accept it before anything is shared. Its fingerprint is ${d.fp}.`,children:"ask"}),(d.kind==="nearby"||d.kind==="declined")&&t==="invite"&&r.jsx("button",{type:"button",className:"ap-manage-btn ap-lan-do","aria-haspopup":"dialog",onClick:u,"aria-label":`Invite ${d.name} to pair`,title:`This deck pairs only by invite. Make one and send it to whoever is at ${d.name}.`,children:"invite"}),d.kind==="paired"&&r.jsx("button",{type:"button",className:`ap-manage-btn ap-lan-do danger${n===d.fp?" armed":""}`,...s(`unpair:${d.fp}`),onClick:()=>i(d),"aria-label":n===d.fp?`Confirm unpairing ${d.name}`:`Unpair ${d.name}`,title:n===d.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===d.fp?"confirm":"unpair"}),d.kind==="dialling"&&r.jsx("button",{type:"button",className:"ap-manage-btn ap-lan-do",...s(`drop:${d.fp}`),onClick:()=>void o(d.fp),"aria-label":`Stop dialling ${d.name}`,title:"Stop trying this address. Nothing was ever paired here.",children:"stop"}),d.kind==="declined"&&t!=="invite"&&r.jsx("button",{type:"button",className:"ap-manage-btn ap-lan-do",...s(`allow:${d.fp}`),onClick:()=>void a("allow",d.fp,"let that deck ask again"),"aria-label":`Let ${d.name} ask again`,title:"Take the no back. That deck is still trying, so the request comes round again on its own.",children:"allow"})]},`${d.kind}:${d.fp}`))})}function yle(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 wle({on:e,status:t}){return r.jsxs(r.Fragment,{children:[e&&r.jsx(S6,{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:yle(t)})]})}const jR=["online","offline","loose"],xle={online:0,offline:1,loose:2};function vle(e){return e.kind==="declined"?null:e.kind==="paired"?e.here?"online":"offline":"loose"}const ble=76,kle=62,Ep=96,jle={1:[.62],2:[.58,1],3:[.42,.72,1]},Nle=.2,Sle=.16,Cle=.05,_le=20,Ele=17,kf=7,Tle=30,Ale=116,Rle=6.6,Mle=6,$le=e=>yS(e,null),Lle=1.5,Ile=80,Ole=.45,NR=40,Ple=64,Dle=150,SR=.3,CR=84,_R=8,Fle=1.3,Tp=6,Ble=5.94,ER=7,TR=16,fu=4,AR=.16;function xj(e,t){return Math.PI*(3*(e+t)-Math.sqrt((3*e+t)*(e+3*t)))}function C6(e,t){return t<-Math.abs(e)*.6?"top":"bottom"}function qle(e,t){if(e<=2)return t%2===0?0:90;const n=360/e;return-90+(t%2===0?0:n/2)}function Ule(e){return e.map((t,n)=>({...t,i:n})).sort((t,n)=>jR.indexOf(t.tier)-jR.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 RR(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 Wle(e,t,n){const s=[...jle[e.length]??[]];for(let a=0;a<s.length;a++){const o=e[a];if(o<2)continue;const i=xj(t*s[a],n*s[a])/o;if(!(i>0)||i>=Ep)continue;const l=a+1<s.length?s[a+1]-Nle:1;s[a]=Math.max(s[a],Math.min(l,s[a]*(Ep/i)*1.02))}return s}const zo=(e,t)=>e.x0<t.x1&&t.x0<e.x1&&e.y0<t.y1&&t.y0<e.y1,bw={h:16,ch:6.1,maxW:100};function Hle(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 _6(e,t,n,s,a,o){const i=t==="loose"?Ele:_le,l=!a||e.kind==="asks",u=l?Tle:bw.h,d=a?bw.ch:Rle,f=l?o.length:0,p=Math.min(a?bw.maxW:Ale,Math.max(2*i,T6(e).length*d,f*Mle)),m={x0:n-i,y0:s-i,x1:n+i,y1:s+i},w=C6(n,s)==="top"?{x0:n-p/2,y0:s-i-kf-u,x1:n+p/2,y1:s-i-kf}:{x0:n-p/2,y0:s+i+kf,x1:n+p/2,y1:s+i+kf+u};return[m,w]}const vj=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]},jf=(e,t)=>((e-t)%360+540)%360-180;function MR(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]=vj(f);return _6(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*Lle,x=s.get(f.ring),b=(f.count>2?360/f.count:f.turn)*Ole,j=x[(f.index+1)%f.count],k=x[(f.index-1+f.count)%f.count];return!(j===f||(p>0?jf(j.theta,w)>=b:jf(w,k.theta)>=b))||w<f.lo||w>f.hi?!1:(f.theta=w,!0)},i=([f,p],[m,w])=>zo(p,m)||zo(w,f)||zo(p,w)||zo(f,m),l=([f,p])=>zo(f,n)||zo(p,n);for(let f=0;f<Ile;f++){const p=a();let m=!1;for(let w=0;w<e.length;w++){l(p[w])&&(m=o(e[w],jf(e[w].theta,90)>=0?1:-1,!0)||m);for(let x=w+1;x<e.length;x++){if(!i(p[w],p[x]))continue;const b=e[w],j=e[x],k=j.ring.ring>b.ring.ring||j.ring===b.ring&&x>w?j:b,v=k===j?b:j,S=jf(k.theta,v.theta)>=0?1:-1;m=o(k,S)||o(v,-S)||m}}if(!m)break}const u=a();let d=0;for(let f=0;f<u.length;f++){l(u[f])&&d++;for(let p=f+1;p<u.length;p++)i(u[f],u[p])&&d++}return d}const zle={online:0,offline:1,loose:1};function Vle(e,t,n,s="",a=$le){const o=[];for(const i of[!0,!1]){const l=$R(e,t,n,s,xle,a,i);if(l.clashes===0)return l.named();if(o.push(l),l.layout.rings.length===3){const u=$R(e,t,n,s,zle,a,i),d={clashes:u.clashes,named:()=>({...u.named(),folded:!0})};if(d.clashes===0)return d.named();o.push(d)}if(!l.layout.zone)break}return o.reduce((i,l)=>l.clashes<i.clashes?l:i).named()}function $R(e,t,n,s,a,o,i=!0){const l=new Map;for(const B of e){const T=vle(B);if(!T)continue;const P=a[T];l.has(P)||l.set(P,[]),l.get(P).push({row:B,tier:T})}const u=[...l.keys()].sort((B,T)=>B-T),d=Math.max(0,t/2-ble),f=Math.max(0,n/2-kle),p=Wle(u.map(B=>l.get(B).length),d,f),m=u.map((B,T)=>({ring:B,rx:d*p[T],ry:f*p[T],count:l.get(B).length})),w=m.reduce((B,T)=>B+T.count,0),x=B=>B.row.via==="tailscale",b=[...l.values()].flat().filter(x).length,j=Math.max(0,...m.map(B=>{const T=l.get(B.ring).filter(x).length,P=xj(B.rx,B.ry);return T>0&&P>0?T*Ep*Fle/P*360:0})),k=i&&b>0&&b<w?Math.min(Dle,Math.max(Ple,b/w*360,j)):0,v=NR-k/2,S=NR+k/2,C=[];let _=!1;m.forEach((B,T)=>{const P=Ule(l.get(B.ring)),q=P.length,K=q>1&&xj(B.rx,B.ry)/q<Ep;K&&(_=!0);const z=T===m.length-1,H=z?-AR*(p[T]-(p[T-1]??0)):AR*(p[T+1]-p[T]),D=k>0?[{members:P.filter(V=>V.row.via!=="tailscale"),from:S,width:360-k},{members:P.filter(V=>V.row.via==="tailscale"),from:v+360,width:k}]:[{members:P,from:null,width:360}];let O=0;for(const V of D){const Z=V.members.length;if(Z===0)continue;const W=V.width/Z,X=Z>2;V.members.forEach(({row:Y,tier:J},Q)=>{const te=Hs(Y),le=V.from==null?qle(Z,T)+W*Q:V.from+W*(Q+.5),de=X?RR(te,1)*Sle*W:0,oe=K&&O%2===1?1+H/p[T]:1,re=X?RR(te,2)*Cle:0,he=W*.3;C.push({row:Y,tier:J,ring:B,index:O,count:q,theta:le+de,reach:oe*(1+(z?-Math.abs(re):re)),lo:V.from==null?-1/0:V.from+he,hi:V.from==null?1/0:V.from+V.width-he,turn:W,caption:o(Y)}),O++})}});const R=Hle(s);let A=MR(C,_,R);A>0&&!_&&(_=!0,A=MR(C,!0,R));const I=C.map((B,T)=>{const[P,q]=vj(B);return{row:B.row,tier:B.tier,ring:B.ring.ring,x:P,y:q,angle:Gle(Math.atan2(q,P)*180/Math.PI),dist:Math.hypot(P,q),side:C6(P,q),order:T}}),$=m.reduce((B,T,P)=>l.get(T.ring).some(x)?Math.max(B,p[P]):B,0),U=B=>({from:v,to:S,inner:{rx:d*SR,ry:f*SR},outer:{rx:Math.min(t/2-8,d*$+B),ry:Math.min(n/2-8,f*$+B)},count:b}),F={nodes:I,rings:m,dense:_,zone:k>0?{...U(CR),labelAt:null}:null};return{layout:F,clashes:A,named:()=>{if(!F.zone)return F;const B=C.flatMap(q=>{const[K,z]=vj(q);return _6(q.row,q.tier,K,z,_,q.caption)});let T={...F.zone,labelAt:LR(F.zone,B)},P=T.outer;for(let q=CR+_R;T.labelAt==null;q+=_R){const K=U(q);if(K.outer.rx===P.rx&&K.outer.ry===P.ry)break;P=K.outer;const z=LR(K,B);z!=null&&(T={...K,labelAt:z})}return{...F,zone:T}}}}function E6(e){return`Tailscale · ${e} deck${e===1?"":"s"}`}function LR(e,t){const n={rx:e.outer.rx-Tp,ry:e.outer.ry-Tp};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 v=e.to;v>=e.from;v-=s){const S=v*Math.PI/180;a.push([Math.cos(S)*n.rx,Math.sin(S)*n.ry])}const o=ER+fu,i={x0:Math.min(...a.map(v=>v[0]))-o,x1:Math.max(...a.map(v=>v[0]))+o,y0:Math.min(...a.map(v=>v[1]))-o,y1:Math.max(...a.map(v=>v[1]))+o},l=t.map(v=>({x0:v.x0-fu,y0:v.y0-fu,x1:v.x1+fu,y1:v.y1+fu})).filter(v=>zo(v,i)),u=(v,S)=>l.some(C=>v>C.x0&&v<C.x1&&S>C.y0&&S<C.y1),d=[],f=[];let p=0;a.forEach(([v,S],C)=>{C>0&&(p+=Math.hypot(v-a[C-1][0],S-a[C-1][1]));const _=Math.hypot(v,S)||1;let R=!1;for(let A=0;A<=ER&&!R;A+=1.75)R=u(v-v/_*A,S-S/_*A);d.push(p),f.push((f.at(-1)??0)+(R?1:0))});const m=E6(e.count).length*Ble/2,w=m+TR,x=p-m-TR;if(!(p>0)||x<w)return null;const b=v=>{let S=0,C=d.length;for(;S<C;){const _=S+C>>1;d[_]<v?S=_+1:C=_}return S},j=v=>{const S=b(v-m),C=b(v+m+1e-9)-1;return C<S||f[C]-(S>0?f[S-1]:0)===0},k=p/2;for(let v=0;k-v>=w;v+=2)for(const S of v===0?[k]:[k-v,k+v])if(j(S))return S/p;return null}function Gle(e){return(e%360+360)%360}function Kle(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 Yle(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 yS(e,t){switch(e.kind){case"asks":return"wants to pair";case"nearby":return e.state;case"dialling":return A6(e)?`${e.name.slice(e.addr.length)} · dialling`:"dialling";case"declined":return"declined";case"paired":{if(e.here)return t?Xle(t):"online";const n=M6(e);return n?n==="now"?"away · just now":`away · ${n}`:e.state.startsWith("one-way")?"has not called yet":"away"}}}function T6(e){return A6(e)?e.addr:e.name}function A6(e){return e.kind==="dialling"&&!!e.addr&&e.name.startsWith(`${e.addr}:`)}function R6(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=M6(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 M6(e){var t;return((t=/last online (.+)$/.exec(e.state))==null?void 0:t[1])??null}function Xle(e){return e.trim().split(/\s+/).slice(0,2).join(" ")}function Zle(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 Hs(e){let t=e.fp;for(const n of e.twins??[])n.fp<t&&(t=n.fp);return t}function Jle(e,t){if(e==null)return t;const n=((t-e)%360+540)%360-180;return e+n}function Qle(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} ${$6}`:e.nearby===1?`${n} Open it to ask to pair.`:`${n} Open one to ask to pair.`}return null}const $6="This deck pairs by invite only. Send one from Add a deck.";function ece(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"?$6:"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 tce(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 nce(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 sce(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 rce(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 ace(e,t,n,s=null){var u;const a=new Map;for(const d of t)(u=a.get(d.key))!=null&&u.alive||a.set(d.key,d);const o=new Set(n),i=[],l=new Set;for(const d of e??[]){if(l.has(d.key))continue;l.add(d.key);const f=a.get(d.key)??null,p=o.has(d.key),m=rce(d,f),w=f?f.alive?f.shareable===!1?f.inUse?"inUse":"unavailable":"works":"expired":"missing",x=!d.alive&&f&&!f.alive?m.note:[w==="works"?null:m.here,d.alive&&d.shareable!==!1?null:m.there,m.note].filter(Boolean).join(" · ")||null;i.push({key:d.key,email:d.email,here:w,there:d.alive?d.shareable===!1?d.inUse?"inUse":"unavailable":"works":"broken",in:!d.alive||d.shareable===!1?"cut":m.tone==="wait"?"wait":"live",out:p&&f?f.alive&&f.shareable!==!1?"live":"cut":null,caption:x,tone:m.tone,usedThere:s===d.key})}for(const d of n){const f=a.get(d);!f||l.has(d)||(l.add(d),i.push({key:d,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 oce=1e3;function ice(e,t){const n=new Date(e).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric"}),s=vr(e,t);return`${n} · ${s==="now"?"just now":s}`}function bj(e){return e&&[e.version,e.os,e.arch].filter(Boolean).join(" · ")||null}const L6={works:"works here",expired:"expired here",missing:"not on this deck",unavailable:"cannot share here",inUse:"in use here"},I6={works:"works there",broken:"broken there",unavailable:"cannot share there",unknown:"not offered by that deck",inUse:"in use there"};function O6(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`${L6[e.here]}, ${I6[e.there]}, ${t}${n}.`}function P6({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,d=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,x=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",b=bj(n.about),j=bj(m),k=m!=null&&m.version&&w?sce(m.version,w):null,v=o?Cm(o.last,a):null,S=o&&((Q=o.last)!=null&&Q.error)?ooe({error:o.last.error,host:o.addr,port:o.port},[...n.strangers??[],...n.pending??[],...(n.peers??[]).filter(oe=>!oe.manual&&oe.addr).map(oe=>({fp:oe.fp,name:oe.name,addr:oe.addr,port:oe.port,at:oe.lastSeen??0}))],a):null,C=(te=o==null?void 0:o.last)!=null&&te.error&&v&&v.text!==o.last.error?o.last.error:null,_=((le=o==null?void 0:o.last)==null?void 0:le.done)??[],R=!!v&&!!C&&!e.quiet&&e.state.startsWith(v.text),A=l||e.kind==="dialling",I=((o==null?void 0:o.via)??e.via)==="tailscale",$=o?o.waiting?null:o.manual?I?"added by its Tailscale address":"added by address":I?"over Tailscale":"on this network":e.kind==="nearby"?I?"heard over Tailscale":"heard on this network":I?"asked this deck to pair, over Tailscale":"asked this deck to pair",U=e.tone==="bad"?"bad":l?e.here?"up":"down":"loose",F=(o==null?void 0:o.offers)??null,M=U==="up"?(F==null?void 0:F.current)??null:null,B=M&&"key"in M?M.key:null,T=!!M&&"hidden"in M,P=!!M&&"other"in M,q=(n.shared??[]).filter(oe=>{var re;return!((re=o==null?void 0:o.notOffered)!=null&&re.includes(oe))}),K=l?ace((F==null?void 0:F.accounts)??null,s,q,B):[],z=K.filter(oe=>oe.in==null&&oe.out==="cut"&&oe.here!=="inUse"),H=K.some(oe=>oe.in!=null),D=K.some(oe=>oe.out!=null),O=new Set((n.peers??[]).filter(oe=>oe.paired).flatMap(oe=>oe.notOffered??[])),V=K.some(oe=>oe.out!=null&&O.has(oe.key))?"decks you chose":"every paired deck",Z=new Map(_.map(oe=>[oe.email,oe])),W=_.filter(oe=>!K.some(re=>re.email===oe.email)),X=l?F?F.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=F&&(o!=null&&o.last)&&o.last.at-F.at>oce?vr(F.at,a):null;return{peer:o,stranger:i,paired:l,own:u,canRename:d,fp:f,where:p,about:m,unsaid:x,hereRuns:b,thereRuns:j,order:k,line:v,silence:S,raw:C,echoed:R,showRound:A,how:$,link:U,hiddenThere:T,otherThere:P,lanes:K,spent:z,taking:H,giving:D,givenTo:V,told:Z,unplaced:W,unknown:X,stale:Y}}function kj(){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 Nf({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 lce({view:e,row:t,status:n,asking:s,drawn:a,onSettings:o}){const{peer:i,paired:l,where:u,about:d,unsaid:f,hereRuns:p,thereRuns:m,order:w,line:x,silence:b,raw:j,echoed:k,showRound:v,how:S,link:C,hiddenThere:_,otherThere:R,lanes:A,spent:I,taking:$,giving:U,givenTo:F,told:M,unplaced:B,unknown:T,stale:P}=e;return r.jsxs("div",{className:"lan-map","data-link":C,"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??(d?"not said":f),w?` · ${w<0?"older":"newer"}`:null]}),_&&r.jsx("span",{className:"lan-end-note",children:"current account hidden"}),R&&r.jsx("span",{className:"lan-end-note",children:"on another account"})]})]}),r.jsxs("div",{className:"lan-link",children:[r.jsx(kj,{}),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(kj,{}),(u&&S||v)&&r.jsxs("p",{className:"lan-link-sub",children:[u&&S,u&&S&&v&&" · ",v&&(x?k?r.jsx("code",{className:"ap-lan-code",children:j}):r.jsx("span",{className:"lan-round","data-tone":x.tone,children:x.text.replace(/ · now$/," · just now")}):"not asked yet"),v&&j&&!k&&r.jsx("code",{className:"lan-fact-raw",children:j})]}),B.length>0&&r.jsx("ul",{className:"lan-done",children:B.map(q=>{const K=hj(q);return r.jsxs("li",{"data-ok":q.ok&&!K,children:[q.email," ",r.jsxs("span",{className:"lan-done-what",children:[q.ok?"arrived":"did not arrive",K&&` — ${K.long}`]})]},`${q.email}:${q.action}`)})}),b&&r.jsx("p",{className:"lan-note lan-link-note",children:b}),(i==null?void 0:i.waiting)&&r.jsx("p",{className:"lan-note lan-link-note",children:t.hint}),(x==null?void 0:x.hint)&&r.jsx("p",{className:"lan-note lan-link-note",children:x.hint})]}),A.length>0&&r.jsx("ul",{className:"lan-lanes",role:"list","aria-label":`Logins between this deck and ${t.name}`,children:A.map((q,K)=>{const z=M.get(q.email),H=z?hj(z):null,D=q.out==="live"||q.in!=null&&q.in!=="cut";return r.jsxs("li",{role:"listitem",className:"lan-lane","data-tone":q.tone,"data-draw":q.in&&q.out?"both":q.in?"in":"out","data-used-there":q.usedThere||void 0,style:{"--i":K},children:[r.jsx("i",{className:"lan-pip","data-end":"here","data-state":q.here,"aria-hidden":!0}),r.jsxs("span",{className:"lan-track",children:[r.jsxs("span",{className:"lan-wire","data-flow":D?"live":"cut","aria-hidden":!0,children:[(q.in==="live"||q.in==="wait")&&r.jsx("i",{className:"lan-glint","data-dir":"in","data-tone":q.in}),q.out==="live"&&r.jsx("i",{className:"lan-glint","data-dir":"out"})]}),q.in&&q.in!=="cut"&&r.jsx(Nf,{dir:"in"}),q.out==="live"&&r.jsx(Nf,{dir:"out"}),r.jsx("span",{className:"lan-lane-email",children:q.email})]}),r.jsx("i",{className:"lan-pip","data-end":"there","data-state":q.there,"aria-hidden":!0}),r.jsx("span",{className:"vis-hidden",children:O6(q)}),(q.caption||z)&&r.jsxs("span",{className:"lan-lane-note",children:[q.caption,q.caption&&z&&" · ",z&&r.jsxs("span",{className:"lan-lane-done","data-ok":z.ok&&!H,children:[z.ok?"arrived last round":"did not arrive last round",H&&` — ${H.long}`]})]})]},q.key)})},a),l&&r.jsxs(r.Fragment,{children:[I.length>0&&r.jsxs("p",{className:"lan-spent",children:["Paired decks get nothing from ",I.length===1?I[0].email:"the expired ones"," until you sign in again here."]}),T&&r.jsx("p",{className:"lan-empty",children:T}),P&&r.jsxs("p",{className:"lan-stale",children:["As of ",P==="now"?"just now":P,", when it last answered."]}),r.jsxs("div",{className:"lan-legend",children:[$&&r.jsxs("span",{className:"lan-key",children:[r.jsx("span",{className:"lan-key-wire","data-dir":"in","aria-hidden":!0,children:r.jsx(Nf,{dir:"in"})}),"from ",t.name]}),U?r.jsxs("span",{className:"lan-key",children:[r.jsx("span",{className:"lan-key-wire","data-dir":"out","aria-hidden":!0,children:r.jsx(Nf,{dir:"out"})}),"from this deck, to ",F]}):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 cce=20,uce=17,IR=34,dce=160,hce=80,fce=200,pce=8,mce=14,gce=10,yce=.61803398875;function wce({status:e,rows:t,accounts:n,now:s,covered:a,onOpenDeck:o,onClose:i}){const l=g.useRef(null),u=gt(i,{focusRef:l}),d=wt(i),f=g.useRef(null),[p,m]=g.useState(null),[w,x]=g.useState(!1),b=g.useRef(null);g.useLayoutEffect(()=>{const re=f.current;if(!re)return;let he=null;const fe=()=>{const ye=Math.round(re.clientWidth),ge=Math.round(re.clientHeight);he&&he.w===ye&&he.h===ge||(he&&(x(!0),b.current!=null&&window.clearTimeout(b.current),b.current=window.setTimeout(()=>x(!1),fce)),he={w:ye,h:ge},m(he))};if(fe(),typeof ResizeObserver>"u")return;const $e=new ResizeObserver(fe);return $e.observe(re),()=>{$e.disconnect(),b.current!=null&&window.clearTimeout(b.current)}},[]);const j=g.useMemo(()=>p?Vle(t,p.w,p.h,(e==null?void 0:e.name)??"",re=>{var he,fe;return yS(re,(fe=(he=pd(e,re).peer)==null?void 0:he.about)==null?void 0:fe.os)}):null,[t,p,e]),k=g.useMemo(()=>Kle(t),[t]),v=(j==null?void 0:j.nodes)??[],S=g.useRef(new Map),C=g.useMemo(()=>{const re=new Map;for(const he of v){const fe=Hs(he.row);re.set(fe,Jle(S.current.get(fe),he.angle))}return S.current=re,re},[v]),[_,R]=g.useState(null),[A,I]=g.useState(null),[$,U]=g.useState("none"),F=g.useRef(null),M=g.useCallback((re,he)=>{F.current!==re&&(F.current=re,U(he),I(re))},[]),B=g.useRef(null),T=g.useRef(null),P=g.useCallback(()=>{T.current!=null&&window.clearTimeout(T.current),T.current=null},[]),q=g.useCallback((re,he)=>{if(B.current!=null&&window.clearTimeout(B.current),B.current=null,P(),R(re),he==="keyboard"){M(re,"none");return}T.current=window.setTimeout(()=>M(re,F.current?"swap":"full"),hce)},[M,P]),K=g.useCallback(()=>{B.current!=null&&window.clearTimeout(B.current),P(),B.current=window.setTimeout(()=>R(null),dce)},[P]);g.useEffect(()=>()=>{B.current!=null&&window.clearTimeout(B.current),P()},[P]);const z=_&&v.some(re=>Hs(re.row)===_)?_:null,H=A?t.find(re=>Hs(re)===A)??null:null;g.useEffect(()=>{A&&!H&&M(null,"swap")},[A,H,M]);const[D,O]=g.useState(null),V=g.useRef(new Map),Z=v.findIndex(re=>Hs(re.row)===D),W=Z<0?0:Z,X=re=>{var ye;if(v.length===0)return;const he=re.key==="ArrowRight"||re.key==="ArrowDown"?1:re.key==="ArrowLeft"||re.key==="ArrowUp"?-1:0,fe=re.key==="Home"?0:re.key==="End"?v.length-1:he?(W+he+v.length)%v.length:null;if(fe==null)return;re.preventDefault();const $e=Hs(v[fe].row);O($e),(ye=V.current.get($e))==null||ye.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?Yle(k):"Local network is off":"checking…",le=()=>{P(),M(null,"swap"),R(null)},de=z?v.find(re=>Hs(re.row)===z)??null:null,oe=()=>{var re;A&&((re=V.current.get(A))==null||re.focus()),le()};return vt.createPortal(r.jsx("div",{className:"modal-backdrop",...d,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":z?"":void 0,"data-focus-via":de==null?void 0:de.row.via,"data-dense":(j==null?void 0:j.dense)||void 0,"data-still":w||void 0,onClick:re=>{re.target===re.currentTarget&&le()},children:p&&j&&r.jsxs(r.Fragment,{children:[r.jsx(xce,{layout:j,w:p.w,h:p.h}),v.map(re=>{const he=Hs(re.row);return r.jsx(kce,{node:re,angle:C.get(he)??re.angle,lit:z===he},he)}),r.jsx(jce,{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, ${v.length}`,"aria-describedby":"nm-ring-hint",onKeyDown:X,children:v.map((re,he)=>{var $e,ye;const fe=Hs(re.row);return r.jsx(Nce,{node:re,angle:C.get(fe)??re.angle,os:(ye=($e=pd(e,re.row).peer)==null?void 0:$e.about)==null?void 0:ye.os,lit:z===fe,shown:A===fe,tabbable:he===W,register:ge=>{ge?V.current.set(fe,ge):V.current.delete(fe)},onHold:ge=>{O(fe),q(fe,ge)},onRelease:K,onOpen:()=>o(re.row.fp)},fe)})}),v.length===0&&r.jsx(Sce,{status:e})]})}),r.jsx(Cce,{slice:(j==null?void 0:j.zone)!=null})]}),r.jsx("aside",{className:"nm-side","aria-label":"Details",children:H&&e?r.jsx(Ece,{row:H,status:e,accounts:n,now:s,entrance:$,onOpen:()=>o(H.fp),onBack:oe},Hs(H)):r.jsx(_ce,{status:e,summary:k,entrance:$,slice:(j==null?void 0:j.zone)!=null})})]})]})}),document.body)}function D6(){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 xce({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:bce(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:vce(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:E6(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 OR(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 vce(e,t,n){const s=e.to-e.from>180?1:0,a=(k,v)=>{const S=v*Math.PI/180;return[t+Math.cos(S)*k.rx,n+Math.sin(S)*k.ry]},o=(k,v)=>v/((k.rx+k.ry)/2)*(180/Math.PI),i=(k,v,S)=>{const C=Math.hypot(v[0]-k[0],v[1]-k[1])||1,_=Math.min(.5,S/C);return[k[0]+(v[0]-k[0])*_,k[1]+(v[1]-k[1])*_]},l=([k,v])=>`${k.toFixed(1)},${v.toFixed(1)}`,u=gce,d=mce,f=o(e.inner,u),p=o(e.outer,d),m=a(e.inner,e.from),w=a(e.outer,e.from),x=a(e.outer,e.to),b=a(e.inner,e.to),j=k=>`${k.rx.toFixed(1)},${k.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,d))}`,`Q${l(w)} ${l(a(e.outer,e.from+p))}`,`A${j(e.outer)} 0 ${s} 1 ${l(a(e.outer,e.to-p))}`,`Q${l(x)} ${l(i(x,b,d))}`,`L${l(i(b,x,u))}`,`Q${l(b)} ${l(a(e.inner,e.to-f))}`,`A${j(e.inner)} 0 ${s} 0 ${l(a(e.inner,e.from+f))}`,"Z"].join(" ")}function bce(e,t,n){const s={rx:e.outer.rx-Tp,ry:e.outer.ry-Tp},a=e.to-e.from>180?1:0;return`M${OR(s,t,n,e.to)} A${s.rx.toFixed(1)},${s.ry.toFixed(1)} 0 ${a} 0 ${OR(s,t,n,e.from)}`}function kce({node:e,angle:t,lit:n}){const s=e.row.kind==="paired"&&e.row.here,a=e.order*yce%1*pce;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":`${IR}px`,"--gap":`${IR+(e.tier==="loose"?uce:cce)}px`,"--i":e.order,"--phase":`${a.toFixed(2)}s`},children:s&&r.jsx("i",{className:"nm-glint"})})}function jce({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 Nce({node:e,angle:t,os:n,lit:s,shown:a,tabbable:o,register:i,onHold:l,onRelease:u,onOpen:d}){const{row:f}=e,p=`nm-d-${Tce(Hs(f))}`,m=e.angle*Math.PI/180,w=yS(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}: ${R6(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:x=>{x.pointerType==="mouse"&&l("pointer")},onPointerLeave:u,onFocus:x=>l(x.currentTarget.matches(":focus-visible")?"keyboard":"pointer"),onBlur:u,onClick:d,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(kj,{}),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:T6(f)}),r.jsx("span",{className:"nm-cap",children:w})]}),e.tier==="online"&&r.jsx("span",{id:p,className:"vis-hidden",children:w})]})}function Sce({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 Cce({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 F6({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 _ce({status:e,summary:t,entrance:n,slice:s}){const a=Zle(e),o=bj(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(d=>r.jsx("code",{className:"ap-lan-code",children:d},d))}):"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=Qle(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(d=>d.n>0).map(d=>r.jsxs("li",{"data-count":d.key,children:[d.mark,r.jsx("span",{className:"nm-count-n",children:d.n}),r.jsx("span",{className:"nm-count-words",children:d.words})]},d.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(F6,{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 Ece({row:e,status:t,accounts:n,now:s,entrance:a,onOpen:o,onBack:i}){var b;const l=P6({row:e,source:pd(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 d=e.kind==="paired"&&e.here||e.kind==="asks",f=ece(e,t.pairingMode),p=tce(l.lanes),m=p.length,w=nce(p),x=l.unknown&&((b=l.peer)!=null&&b.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:d?"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:R6(e)}),f&&r.jsx("p",{className:"nm-next",children:f}),u.length>0&&r.jsx(F6,{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((j,k)=>r.jsxs("li",{className:"nm-lane","data-tone":j.tone,style:{"--k":k},children:[r.jsx("i",{className:"nm-lane-dot","aria-hidden":!0}),r.jsx("span",{className:"nm-lane-email","aria-hidden":!0,children:j.email}),PR(j)&&r.jsx("span",{className:"nm-lane-said","aria-hidden":!0,children:PR(j)}),j.usedThere&&r.jsx("span",{className:"nm-lane-used","aria-hidden":!0,children:"in use there"}),r.jsxs("span",{className:"vis-hidden",children:[j.email,": ",O6(j)]})]},j.key))}),x&&r.jsx("p",{className:"nm-panel-hint",children:x})]})]})}function PR(e){return e.caption?e.caption:e.tone==="ok"?null:`${L6[e.here]} · ${I6[e.there]}`}function Tce(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 Ace=6;function Rce({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,Ace),d=i.length-l.length,f=l.length>u.length?`and ${l.length-u.length} more`:d>0?`${d} not on right now`:null,p=g.useCallback(()=>{const m=o.current,w=document.getElementById(e);if(!m||!w)return;m.style.maxHeight="";const x=pm(w.getBoundingClientRect(),{width:m.offsetWidth,height:m.offsetHeight},{width:window.innerWidth,height:window.innerHeight});m.style.top=`${x.top}px`,m.style.left=`${x.left}px`,m.style.maxHeight=x.maxHeight==null?"":`${x.maxHeight}px`,m.dataset.side=x.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 Mce({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:d=>{d.pointerType==="mouse"&&o(v6)},onPointerLeave:i,onFocus:d=>{d.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(D6,{})}),a&&r.jsx(Rce,{anchorId:"ap-lan-entry",id:"ap-lan-peek",rows:t,onHold:l,onLet:i})]})}function $ce({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=fi({armedFor:a?e.fp:null,target:e.fp,armedAt:i.current,now:p,gapMs:hi});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=fi({armedFor:l,target:p,armedAt:i.current,now:m,gapMs:hi});if(w==="arm"){u(p),o(!1),i.current=m;return}w!=="ignore"&&(u(null),t(()=>s(p)))}}}function Lce({row:e,paired:t,peer:n,status:s,busy:a,press:o,checkNow:i,armed:l,pressOwn:u,run:d,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 d(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 d(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 d(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 Ice({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 x,b,j,k;const d=(x=l.peer)!=null&&x.addr?`${l.peer.addr}:${l.peer.port}`:l.row.addr,f=d||l.row.fp,p=(b=l.peer)!=null&&b.pairedAt?vr(l.peer.pairedAt,t):null,m=[(k=(j=l.peer)==null?void 0:j.about)!=null&&k.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}),d?r.jsx("code",{className:"ap-lan-code lan-twin-at",children:d}):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:v=>{v.repeat&&v.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 Oce(){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 Pce({row:e,source:t,status:n,accounts:s,now:a,busy:o,onClose:i,onRename:l,onCheck:u,onVerb:d,onSettings:f,onInvite:p,twins:m=[],onUnpair:w}){const x=g.useRef(null),b=gt(i,{focusRef:x}),j=wt(i),[k,v]=g.useState(null),[S,C]=g.useState(null),[_,R]=g.useState(!1),[A,I]=g.useState(0),$=g.useRef(null),U=g.useRef(null),F=g.useRef(!0);g.useEffect(()=>()=>{F.current=!1},[]);const M=k!=null;g.useEffect(()=>{var re;M&&((re=$.current)==null||re.select())},[M]);const B=g.useRef(!1);g.useEffect(()=>{var re,he;B.current&&!M&&Hn(((re=document.activeElement)==null?void 0:re.tagName)??null)&&((he=U.current)==null||he.focus()),B.current=M},[M]);const T=re=>{const he=eo(o,re);return{disabled:he.disabled,"aria-busy":he.busy}},P=async re=>{const he=await re();return F.current&&C(he),he==null},{armed:q,armedTwin:K,pressOwn:z,pressTwin:H}=$ce({row:e,run:P,onVerb:d,onUnpair:w}),D=P6({row:e,source:t,status:n,accounts:s,now:a}),{peer:O,stranger:V,paired:Z,own:W,canRename:X,fp:Y}=D,J=o===`check:${e.fp}`,Q=async re=>{const he=re.trim()===W?"":re;await P(()=>l(he))&&v(null)},te=()=>void P(u).then(re=>{re&&F.current&&I(he=>he+1)}),le=async()=>{if(Y)try{if(await navigator.clipboard.writeText(Y),!F.current)return;R(!0),window.setTimeout(()=>{F.current&&R(!1)},1600)}catch{F.current&&C("Could not copy it — select the fingerprint and copy it by hand.")}},de=[];Z&&(O!=null&&O.pairedAt)?de.push({label:"Paired",value:ice(O.pairedAt,a),tone:"meta"}):e.kind==="declined"&&V&&de.push({label:"Paired",value:`no · you said no ${hS(V.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:O??null},...m]:[];return vt.createPortal(r.jsx("div",{className:"modal-backdrop",...j,role:"presentation",children:r.jsxs("div",{ref:b,className:"modal lan-peer","data-tone":e.tone,onClick:re=>re.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-peer-title","aria-describedby":"lan-peer-sub",children:[r.jsxs("header",{className:"modal-head lan-peer-head",children:[r.jsx("i",{className:e.here?"ap-pulse":"ap-dot","aria-hidden":!0}),r.jsxs("div",{className:"lan-peer-id",children:[M?r.jsxs("form",{className:"lan-peer-edit",onSubmit:re=>{re.preventDefault(),Q(k??"")},children:[r.jsx("span",{id:"lan-peer-title",className:"vis-hidden",children:e.name}),r.jsx("input",{ref:$,className:"ap-manage-input lan-peer-input",value:k??"",maxLength:48,placeholder:W,"aria-label":"Name for this deck, shown on this deck only",onChange:re=>v(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:()=>v(null),children:"cancel"})]}):r.jsxs("span",{className:"lan-peer-title",children:[r.jsx("span",{id:"lan-peer-title",className:"lan-peer-name",children:e.name}),X&&r.jsx("button",{type:"button",className:"glyph-btn lan-peer-rename",ref:U,onClick:()=>{C(null),v(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(Oce,{})})]}),r.jsxs("p",{id:"lan-peer-sub",className:"lan-peer-sub",children:[e.self&&r.jsxs(r.Fragment,{children:["calls itself ",r.jsx("span",{className:"lan-peer-self",children:e.self}),M&&r.jsx("button",{type:"button",className:"ap-lan-word lan-peer-restore",...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:x,type:"button",className:"glyph-btn",onClick:i,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),r.jsxs("section",{className:"modal-body lan-peer-body",children:[S&&r.jsxs("div",{className:"ap-failure",role:"alert",children:[r.jsx("span",{className:"ap-failure-text",children:S}),r.jsx("button",{type:"button",className:"ap-failure-x",onClick:()=>C(null),"aria-label":"Dismiss this message",title:"Dismiss",children:"×"})]}),r.jsx(lce,{view:D,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(Ice,{instances:oe,now:a,busy:o,press:T,armedTwin:K,pressTwin:H,onUnpair:w})]}),r.jsx(Lce,{row:e,paired:Z,peer:O,status:n,busy:o,press:T,checkNow:te,armed:q,pressOwn:z,run:P,onVerb:d,onInvite:p})]})}),document.body)}function ea(e,t){const n=g.useRef(!1);return g.useEffect(()=>{var s,a;!e||!n.current||(n.current=!1,Hn(((s=document.activeElement)==null?void 0:s.tagName)??null)&&(typeof t=="function"?t():(a=t.current)==null||a.focus()))},[e]),()=>{n.current=!0}}function Dce(e,t){if(e.length!==t.length)return!1;const n=new Set(e);return t.every(s=>n.has(s))}function Fce(e,t,n,s){const a=new Set(e??t);return s?a.add(n):a.delete(n),[...a]}function DR(e,t,n){return e==null||n!=null&&!n.ok||Dce(e,t)?null:e}function B6({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),d=g.useRef(!1);if(g.useEffect(()=>{var p;d.current&&(d.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 Pie();o.current=!1,i.current&&(a(!1),d.current=document.activeElement===l.current,n(Fie(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 Bce(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 Sf="Paused while this deck pairs only by invite. Turn that off above to use it.";function qce({status:e,accounts:t,onClose:n,onChanged:s}){cn("lan-setup");const a=gt(n),o=wt(n),[i,l]=g.useState(null),[u,d]=g.useState(null),[f,p]=g.useState(!1),[m,w]=g.useState(null),x=g.useRef(null),b=D=>{const O=eo(m,D);return{disabled:O.disabled,"aria-busy":O.busy}},j=g.useRef(null),k=g.useRef(!0);g.useEffect(()=>()=>{k.current=!1},[]),g.useEffect(()=>{j.current=DR(j.current,e.shared??[],null)},[e.shared]);const v=g.useCallback(async(D,O,V="write")=>{x.current=V,w(V);try{const W=await(await fetch("/api/prefs",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({lan:D})})).json().catch(()=>null);return k.current?(W!=null&&W.ok?d(null):d(zs(en(O,W),W)),s(),(W==null?void 0:W.ok)===!0):!1}catch{return k.current&&d(zs(en(O,null))),!1}finally{x.current=null,k.current&&w(null)}},[s]),S=g.useCallback(async D=>{const O=await v({name:D},"save the name","name");return O&&k.current&&l(V=>V===D?null:V),O},[v]),C=g.useRef(null),_=i!=null&&i!==(e.name??""),R=ea(!_,C),A=g.useCallback(async()=>{_&&!await S(i)||n()},[_,i,S,n]),I=async()=>{if(!e.fp)return;const D=await io(e.fp);if(k.current){if(!D){d(zs("Could not copy it — select the fingerprint and copy it by hand."));return}p(!0),window.setTimeout(()=>{k.current&&p(!1)},1600)}},$=new Set(j.current??e.shared??[]),U=e.autoAsk!==!1,F=e.autoAccept!==!1,M=e.pairingMode==="invite",B=D=>{const O=b(D);return{...O,disabled:O.disabled||M}},T=e.shareActive!==!1,P=e.sendInUse===!0,q=e.tailscale??null,K=!!(q!=null&&q.on),z=(q==null?void 0:q.ask)!==!1,H=(q==null?void 0:q.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:D=>D.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"lan-modal-title",children:[r.jsxs("header",{className:"modal-head",children:[r.jsx("div",{className:"modal-title",children:r.jsx("span",{id:"lan-modal-title",className:"modal-tool-name",children:"This deck on the network"})}),r.jsx("div",{className:"modal-actions",children:r.jsx("button",{className:"glyph-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),r.jsxs("section",{className:"modal-body",children:[r.jsx(B6,{line:u,onDismiss:()=>d(null),onAnswer:D=>{d(D),D.done&&s()}}),r.jsxs("div",{className:"modal-section",children:[r.jsx("h3",{className:"lan-h",children:"Name"}),r.jsxs("div",{className:"ap-lan-row",children:[r.jsx("span",{className:"ap-lan-label",children:"appear as"}),r.jsx("input",{ref:C,className:"ap-manage-input ap-lan-input","aria-label":"This deck's name on the network",value:i??e.name??"",placeholder:"this machine",onChange:D=>l(D.target.value),onKeyDown:D=>{D.key!=="Enter"||i==null||S(i)}}),_&&r.jsx("button",{type:"button",className:"ap-manage-btn",...b("name"),onClick:()=>{R(),S(i)},title:"Save it. This is the name other decks show for this one.",children:"save"})]}),r.jsxs("div",{className:"ap-lan-row",children:[r.jsx("span",{className:"ap-lan-label",children:"fingerprint"}),e.fp?r.jsxs("span",{className:"lan-fp",children:[r.jsx("code",{className:"ap-lan-code",children:e.fp}),r.jsx("button",{type:"button",className:"ap-lan-word lan-copy",onClick:()=>void I(),"aria-label":f?"Fingerprint copied":"Copy this deck's fingerprint",children:f?"copied":"copy"})]}):r.jsx("span",{className:"ap-lan-label",children:"not known yet"})]})]}),r.jsxs("div",{className:"modal-section",children:[r.jsx("h3",{className:"lan-h",children:"Share these accounts"}),r.jsxs("div",{className:"ap-lan-picks",children:[t.length===0&&r.jsx("span",{className:"ap-lan-empty",children:"No Claude accounts on this deck yet — add one with + at the top of this panel."}),t.map(D=>r.jsxs("label",{className:"ap-lan-pick",title:D.alive?D.inUse?"Offer this account to the decks you have paired with. While this deck is on it, it stays here, and it goes out like the others once this deck switches away. Unticking stops it being offered from now on; it does not take back a copy somebody already has.":"Offer this account to the decks you have paired with, so one whose copy has died can heal from yours. Unticking stops it being offered from now on; it does not take back a copy somebody already has.":"This deck cannot use this login, so it has nothing to offer — a deck that can will heal it",children:[r.jsx("input",{type:"checkbox",checked:$.has(D.key),onChange:O=>{const V=Fce(j.current,e.shared??[],D.key,O.target.checked);j.current=V,v({shared:V},O.target.checked?"share that account":"stop sharing that account").then(Z=>{j.current===V&&(j.current=DR(V,e.shared??[],{ok:Z}))})}}),r.jsx("span",{className:"ap-lan-pick-name",children:D.email}),!D.alive&&r.jsx("span",{className:"ap-lan-dead",children:"not working here"}),D.alive&&D.inUse&&$.has(D.key)&&r.jsx("span",{className:"ap-lan-dead",children:"in use here · not sent"})]},D.key))]}),t.length>0&&r.jsxs("div",{className:"lan-switches",children:[r.jsxs("div",{className:"lan-switch",children:[r.jsx("span",{className:"lan-switch-what",children:"Show paired decks which of these this deck is using"}),r.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":T,"aria-label":"Show paired decks which of these this deck is using",...b("current"),onClick:()=>void v({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",P&&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":P,"aria-label":"Send the login this deck is using too","aria-describedby":P?"lan-send-in-use-detail":void 0,"data-tone":"warn",...b("send-in-use"),onKeyDown:D=>{D.repeat&&D.preventDefault()},onClick:()=>void v({sendInUse:!P},P?"keep the login this deck is using here":"send the login this deck is using","send-in-use"),title:P?"Keep the account this deck is signed in to here while it is. It goes out like the others once this deck switches away.":"Also hand out the account this deck is signed in to right now. Two machines on one login race to renew it, and the one that renews it second is signed out (“Login expired · Please run /login”).",children:r.jsx("span",{className:"switch-knob"})})]})]})]}),r.jsxs("div",{className:"modal-section",children:[r.jsx("h3",{className:"lan-h",id:"lan-pairing-h",children:"Pairing"}),r.jsx("div",{className:"lan-switches lan-switches-lead",role:"group","aria-labelledby":"lan-pairing-h",children:r.jsxs("div",{className:"lan-switch",children:[r.jsxs("span",{className:"lan-switch-what",children:["Pair new decks only by invite",M&&r.jsx("span",{id:"lan-invite-only-detail",className:"lan-switch-detail",children:"A new deck needs an invite from Add a deck, the link at the top of Local network. Paired decks stay paired."})]}),r.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":M,"aria-label":"Pair new decks only by invite","aria-describedby":M?"lan-invite-only-detail":void 0,...b("mode"),onKeyDown:D=>{D.repeat&&D.preventDefault()},onClick:()=>void v({pairingMode:M?"automatic":"invite"},M?"let decks pair on their own again":"pair new decks only by invite","mode"),title:M?"Let decks on this network pair as the two switches below say again.":"Only a deck you send an invite to can pair with this one. Nearby decks can't ask, and requests waiting now are turned away.",children:r.jsx("span",{className:"switch-knob"})})]})}),r.jsxs("div",{className:"lan-auto",role:"group","aria-labelledby":"lan-auto-h",children:[r.jsxs("p",{className:"lan-sub",id:"lan-auto-h",children:["Automatic pairing",M&&r.jsx("span",{className:"lan-sub-state",children:" · paused while pairing is invite-only"})]}),r.jsxs("div",{className:"lan-switches","data-paused":M||void 0,children:[r.jsxs("div",{className:"lan-switch",children:[r.jsx("span",{className:"lan-switch-what",children:"Ask every deck this one finds"}),r.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":U,"aria-label":"Ask every deck this one finds",...B("ask"),onClick:()=>void v({autoAsk:!U},U?"stop asking automatically":"ask every deck this one finds","ask"),title:M?Sf:U?"Stop sending requests on their own. You press ask on the row instead.":"Send a pairing request to every deck heard on this network. Somebody over there still has to say yes.",children:r.jsx("span",{className:"switch-knob"})})]}),r.jsxs("div",{className:"lan-switch",children:[r.jsx("span",{className:"lan-switch-what",children:"Say yes to every deck that asks"}),r.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":F,"aria-label":"Say yes to every deck that asks","data-tone":"warn",...B("accept"),onKeyDown:D=>{D.repeat&&D.preventDefault()},onClick:()=>void v({autoAccept:!F},F?"stop accepting automatically":"accept every deck that asks","accept"),title:M?Sf:F?"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"})})]})]})]})]}),(q==null?void 0:q.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:Bce(q)})]}),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",...b("tailscale"),onClick:()=>void v({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",M&&r.jsx("span",{className:"lan-sub-state",children:" · paused while pairing is invite-only"})]}),r.jsxs("div",{className:"lan-switches",children:[r.jsxs("div",{className:"lan-switch","data-paused":M||void 0,children:[r.jsx("span",{className:"lan-switch-what",children:"Ask each device it finds"}),r.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":z,"aria-label":"Ask each of my devices it finds over Tailscale",...B("tailscale-ask"),onClick:()=>void v({tailscaleAsk:!z},z?"stop asking your devices automatically":"ask your devices automatically","tailscale-ask"),title:M?Sf:z?"Stop sending requests on their own. You press ask on the row instead.":"Send a pairing request to every deck found on your devices over Tailscale.",children:r.jsx("span",{className:"switch-knob"})})]}),r.jsxs("div",{className:"lan-switch","data-paused":M||void 0,children:[r.jsx("span",{className:"lan-switch-what",children:"Say yes to each device that asks"}),r.jsx("button",{type:"button",className:"switch ap-auto-state",role:"switch","aria-checked":H,"aria-label":"Say yes to my devices when they ask over Tailscale","data-tone":"warn",...B("tailscale-accept"),onKeyDown:D=>{D.repeat&&D.preventDefault()},onClick:()=>void v({tailscaleAccept:!H},H?"stop accepting your devices automatically":"accept your devices automatically","tailscale-accept"),title:M?Sf: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",...b("name"),onClick:()=>void A(),children:"Done"})]})]})}),document.body)}function Uce({on:e,status:t,paired:n,busy:s,pressProps:a,checkNow:o,setAddOpen:i,setSetupOpen:l,setMapOpen:u,onBack:d,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:d,"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(D6,{})}),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 Wce({accounts:e,onChanged:t,onNoCopy:n,onShared:s,view:a,onOpen:o,onBack:i,closeButton:l}){const[u,d]=g.useState(!1),[f,p]=g.useState(!1),[m,w]=g.useState(!1),x=Iie(),[b,j]=g.useState(!1),{status:k,manual:v,now:S,busy:C,failure:_,dismissFailure:R,answerGiveBack:A,pressProps:I,load:$,toggle:U,answer:F,dropAddress:M,rename:B,checkOne:T,checkNow:P}=Hie(t,()=>d(!0)),{armed:q,pressUnpair:K}=zie(F),[z,H]=g.useState(null),[D,O]=g.useState(!1),V=g.useMemo(()=>boe(e,k??null),[e,k]),Z=g.useMemo(()=>V.filter(ge=>koe(ge.key,k??null,S)).map(ge=>ge.key).sort().join(`
|
|
105
|
+
`),[V,k,S]);g.useEffect(()=>{n==null||n(Z?Z.split(`
|
|
106
|
+
`):[])},[Z,n]);const W=g.useMemo(()=>JSON.stringify(Coe(V,k??null)),[V,k]);g.useEffect(()=>{s==null||s(new Map(JSON.parse(W)))},[W,s]);const X=(k==null?void 0:k.enabled)===!0,Y=g.useMemo(()=>uoe((k==null?void 0:k.pairingMode)==="invite"&&k?{...k,pending:[]}:k,S),[k,S]),J=z?Y.find(ge=>{var je;return ge.fp===z||((je=ge.twins)==null?void 0:je.some(Le=>Le.fp===z))})??null:null;g.useEffect(()=>{z&&k&&!J&&H(null)},[z,k,J]);const{asks:Q,rest:te,live:le,folded:de,troubled:oe,shown:re,paired:he}=voe(Y,b),fe=ioe(k,S),$e=xoe(k,Y),ye=r.jsxs(r.Fragment,{children:[f&&k&&r.jsx(fle,{status:k,manual:v,startWith:f==="invite"?"invite":void 0,onClose:()=>p(!1),onChanged:()=>{$(),t()}}),m&&r.jsx(j6,{title:"How Local network works",steps:ale,finish:X?void 0:{label:"Turn it on",act:()=>{w(!1),U()}},onClose:()=>w(!1)}),u&&k&&r.jsx(qce,{status:{...k,manualRows:v},accounts:V,manual:v,onClose:()=>d(!1),onChanged:()=>{$(),t()}}),D&&r.jsx(wce,{status:k,rows:Y,accounts:V,now:S,covered:!!J||u||!!f||m,onOpenDeck:H,onClose:()=>O(!1)}),J&&k&&r.jsx(Pce,{row:J,source:pd(k,J),status:k,accounts:V,now:S,busy:C,onClose:()=>H(null),onRename:ge=>B(J.fp,ge),onCheck:()=>T(J.fp),onVerb:()=>{switch(J.kind){case"paired":return F("unpair",J.fp,"unpair that deck");case"nearby":return F("accept",J.fp,"reach that deck");case"declined":return F("allow",J.fp,"let that deck ask again");case"dialling":return M(J.fp);default:return Promise.resolve(null)}},onSettings:()=>{H(null),d(!0)},onInvite:()=>{H(null),p("invite")},twins:(J.twins??[]).map(ge=>({row:ge,peer:pd(k,ge).peer??null})),onUnpair:ge=>F("unpair",ge,"unpair that deck")})]});return a?r.jsxs("div",{className:"ap-lan-view",children:[r.jsx(Uce,{on:X,status:k,paired:he,busy:C,pressProps:I,checkNow:P,setAddOpen:p,setSetupOpen:d,setMapOpen:O,onBack:i,closeButton:l}),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":X,"aria-label":"Sync with paired decks",...I("switch"),onClick:()=>void U(),title:X?"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(wle,{on:X,status:k}),!X&&r.jsxs("div",{className:"ap-lan-intro-row",children:[r.jsxs("button",{type:"button",className:"ap-lan-intro",onClick:()=>w(!0),title:"Four pictures: what this does, and what to do on each machine",children:[r.jsx(ole,{}),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(ld,{film:"localNetwork"})]}),r.jsx("p",{className:`ap-lan-status ${fe.tone}`,role:"status",children:fe.tone==="ok"?"":fe.text}),r.jsx(B6,{line:_,onDismiss:R,onAnswer:A}),X&&r.jsxs(r.Fragment,{children:[Q.length>0&&r.jsx(mle,{asks:Q,pressProps:I,answer:F}),re.length>0&&r.jsx(gle,{rows:re,pairingMode:k==null?void 0:k.pairingMode,armed:q,pressProps:I,answer:F,dropAddress:M,onUnpair:K,onOpenPeer:H,onInvite:()=>p("invite")}),(le.length>0&&de.length>0||X&&he>0)&&r.jsxs("div",{className:"ap-lan-tail",children:[le.length>0&&de.length>0&&r.jsxs("button",{type:"button",className:"ap-lan-word ap-lan-more","aria-expanded":b,onClick:()=>j(ge=>!ge),title:b?"Show only the decks that are on":`Show the ${de.length} deck${de.length===1?"":"s"} that are not responding right now`,children:[r.jsx("span",{className:`ap-lan-chev${b?" open":""}`,"aria-hidden":!0,children:"›"}),b?"fewer":`${de.length} more`,!b&&oe>0&&r.jsxs("span",{className:"ap-lan-more-bad",children:[" · ",oe," not responding"]})]}),X&&he>0&&r.jsx("span",{className:"ap-lan-checked",children:loe(k==null?void 0:k.checkedAt,S,C==="check")})]}),te.length===0&&Q.length===0&&!(k!=null&&k.stalled)&&!(k!=null&&k.deaf)&&!(k!=null&&k.lanTunneled)&&r.jsxs(r.Fragment,{children:[r.jsx("p",{className:"ap-lan-fine",children:"No other deck yet. Decks on one network usually find each other on their own; when that has not happened, the link at the top of this view reaches one by address or by invite."}),r.jsx("button",{type:"button",className:"ap-lan-word ap-lan-how",onClick:()=>w(!0),children:"How it works"}),r.jsx(ld,{film:"localNetwork"})]})]})]})}),ye]}):r.jsxs("div",{className:"ap-foot",children:[r.jsx(Mce,{entry:$e,rows:Y,onOpen:o,onMap:X?()=>O(!0):void 0,...x}),r.jsx("p",{className:"vis-hidden",role:"status",children:fe.tone==="ok"?"":fe.text}),ye]})}function Hce({anchorId:e,id:t,peers:n,onHold:s,onLet:a}){const o=g.useRef(null),{title:i,shown:l,rest:u}=Lie(n),d=g.useCallback(()=>{const f=o.current,p=document.getElementById(e);if(!f||!p)return;f.style.maxHeight="";const m=pm(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(()=>{d()}),g.useEffect(()=>(window.addEventListener("scroll",d,!0),window.addEventListener("resize",d),()=>{window.removeEventListener("scroll",d,!0),window.removeEventListener("resize",d)}),[d]),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 zce({peers:e,strained:t,armed:n,threshold:s,open:a,onToggle:o,order:i,choices:l,onOrder:u,allOpen:d,onToggleAll:f,held:p=!1}){const[m,w]=g.useState(!1),x=g.useRef(0);g.useEffect(()=>()=>window.clearTimeout(x.current),[]),g.useEffect(()=>{a&&(window.clearTimeout(x.current),w(!1))},[a]);const b=C=>{a||(window.clearTimeout(x.current),x.current=window.setTimeout(()=>w(!0),C))},j=()=>{window.clearTimeout(x.current),x.current=window.setTimeout(()=>w(!1),b6)},k=()=>window.clearTimeout(x.current),v=()=>{window.clearTimeout(x.current),w(!1)},S=Mie(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:()=>{v(),o()},onPointerEnter:C=>{C.pointerType==="mouse"&&b(v6)},onPointerLeave:j,onFocus:C=>{C.target.matches(":focus-visible")&&b(0)},onBlur:j,children:[r.jsxs("span",{className:"ap-nav-text",children:[r.jsx("span",{className:"ap-nav-name",children:"Other accounts"}),r.jsx("span",{className:"ap-nav-state","data-tone":S.tone,children:S.text})]}),r.jsx("svg",{className:"ap-nav-chev",width:"13",height:"13",viewBox:"0 0 14 14",fill:"none",stroke:"currentColor",strokeWidth:"1.3",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":!0,children:r.jsx("path",{d:"M5.6 3.4 9.2 7l-3.6 3.6"})})]}),m&&r.jsx(Hce,{anchorId:"ap-rest-entry",id:"ap-rest-peek",peers:e,onHold:k,onLet:j}),a&&r.jsx(Vce,{order:i,choices:l,onOrder:u,allOpen:d,onToggleAll:f,held:p})]})}function Vce({order:e,choices:t,onOrder:n,allOpen:s,onToggleAll:a,held:o}){var u;const i=g.useRef(null);g.useLayoutEffect(()=>{const d=i.current,f=d==null?void 0:d.parentElement;if(!d||!f)return;const p=()=>f.style.setProperty("--rest-tools-w",`${Math.ceil(d.offsetWidth)}px`);if(p(),typeof ResizeObserver>"u")return;const m=new ResizeObserver(p);return m.observe(d),()=>{m.disconnect(),f.style.removeProperty("--rest-tools-w")}},[]);const l=((u=t.find(d=>d.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:d=>n(d.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===Nm?void 0:"","data-held":o?"":void 0,children:t.map(d=>r.jsx("option",{value:d.id,children:d.label},d.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 Gce(e){return(await fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)})).json().catch(()=>null)}const Kce=1800;function Yce({accounts:e,onClose:t,copyText:n}){cn("share-accounts");const[s,a]=g.useState([]),[o,i]=g.useState(null),[l,u]=g.useState(!1),[d,f]=g.useState(null),[p,m]=g.useState(!1),[w,x]=g.useState(()=>Math.floor(Date.now()/1e3)),b=g.useRef(null),j=g.useRef(!1),k=gt(t,{focusRef:b}),v=wt(t),S=ea(o!=null,b),C=ea(o==null,b);g.useEffect(()=>{if(!o)return;x(Math.floor(Date.now()/1e3));const q=window.setInterval(()=>x(Math.floor(Date.now()/1e3)),1e3);return()=>window.clearInterval(q)},[o]);const _=pie(e),R=mie(e,s),A=R.length===e.length,I=q=>a(K=>gie(K,q)),$=g.useCallback(async()=>{const q=yie(R);if(!_n(j.current)||!q)return;j.current=!0,u(!0),f(null),m(!1);const K=await Gce(q).catch(()=>null);if(j.current=!1,u(!1),!(K!=null&&K.ok)){f(jl(K,"the share could not be made"));return}i({blob:K.blob,expiresAt:K.expiresAt,shared:K.shared??[],failed:K.failed??[]})},[e,R]),U=o?w6(o.expiresAt,w):null,F=(U==null?void 0:U.tone)==="gone",M=(o==null?void 0:o.shared.length)??0,B=F?"This share has expired":M===1?"1 account, ready to paste":`${M} accounts, ready to paste`,T=M===1?"this is the password":`this is ${M} passwords`,P=o?F?B:`${B} — ${T}`:"";return vt.createPortal(r.jsx("div",{className:"modal-backdrop",...v,role:"presentation",children:r.jsxs("div",{ref:k,className:"modal sa-modal",onClick:q=>q.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:P}),o?r.jsxs("div",{className:"sa-step",children:[r.jsx("h4",{children:B}),r.jsx("code",{className:"ap-share-blob",children:o.blob}),r.jsxs("div",{className:"ap-share-foot",children:[r.jsx("button",{type:"button",className:"ap-manage-btn",ref:b,onClick:async()=>{if(F){C(),S(),i(null),$();return}await n(o.blob)&&(m(!0),window.setTimeout(()=>m(!1),Kce))},children:F?"make a new share":p?"copied":`copy ${M===1?"the share":"all "+M}`}),r.jsxs("span",{className:"ap-manage-hint",title:"This text is the sign-in for every account in it. It is base64 of plain JSON — the expiry inside it is not signed, so anyone holding a copy can change it, and the logins themselves are in there in the clear either way. The countdown only says how long another deck's import dialog will still accept it. If a copy escapes, sign those accounts out and back in.",children:[r.jsx("span",{className:"ap-share-warn",children:T})," · ",r.jsx("span",{className:`ap-share-expiry ${U==null?void 0:U.tone}`,children:U==null?void 0:U.text})]})]}),o.failed.length>0&&r.jsxs("div",{className:"sa-failed",role:"alert",children:[r.jsx("p",{className:"sa-failed-head",children:o.failed.length===1?"One account is not in this bundle:":`${o.failed.length} accounts are not in this bundle:`}),r.jsx("ul",{className:"sa-list",children:o.failed.map(q=>{var z;const K=!!(q.email&&((z=q.detail)!=null&&z.includes(q.email)));return r.jsxs("li",{children:[!K&&r.jsx("span",{className:"sa-who",children:q.email||`account ${q.num}`}),r.jsx("span",{className:"sa-why",children:q.detail||"could not be exported"})]},`${q.num}-${q.email}`)})})]}),r.jsx("p",{className:"sa-note",children:F?r.jsx(r.Fragment,{children:"Another deck will refuse this text now. Make a new one — the same accounts are still picked."}):r.jsxs(r.Fragment,{children:["Paste it into the other deck with ",r.jsx("strong",{children:"+"})," → ",r.jsx("strong",{children:"Paste a share"}),". Accounts it already holds are left exactly as they are."]})}),r.jsxs("div",{className:"sa-actions",children:[r.jsx("button",{type:"button",className:"btn",onClick:()=>{C(),i(null),m(!1)},children:"Pick again"}),r.jsx("button",{type:"button",className:"btn primary",onClick:t,children:"Done"})]})]}):e.length===0?r.jsxs("div",{className:"sa-step",children:[r.jsx("h4",{children:"Nothing to share"}),r.jsxs("p",{className:"sa-note",children:["This deck is not holding any accounts right now. Sign one in with ",r.jsx("strong",{children:"+"}),", or wait — the panel is still reading the store."]}),r.jsx("div",{className:"sa-actions",children:r.jsx("button",{type:"button",className:"btn primary",ref:b,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${R.length?"":" empty"}`,children:wie(R.length)}),r.jsx("ul",{className:"sa-list sa-pick",children:_.map(q=>r.jsx("li",{children:r.jsxs("label",{className:"sa-row",children:[r.jsx("input",{type:"checkbox",checked:R.includes(q.num),onChange:()=>I(q.num)}),r.jsx("span",{className:"sa-who",children:q.label}),q.sub&&r.jsx("span",{className:"sa-sub",children:q.sub})]})},q.num))}),d&&r.jsx("p",{className:"aa-err",role:"alert",children:d}),r.jsxs("div",{className:"sa-actions",children:[r.jsx("button",{type:"button",className:"btn",onClick:()=>a(A?e.map(q=>q.num):[]),children:A?"Clear all":"Select all"}),r.jsx("button",{type:"button",className:"btn primary",ref:b,...qn(l,!R.length),onClick:()=>{S(),$()},children:l?"making the share…":R.length===0?"Share":R.length===1?"Share 1 account":`Share ${R.length} accounts`})]})]})]})]})}),document.body)}function wS(e,t){var n;return!e.disabled&&!((n=mi(e,t))!=null&&n.blocksSwitch)}function Xce(e,t,n){return e.map(s=>{const a=mi(s,t,n==null?void 0:n(s));return{key:ws(s),name:s.alias??s.email??`account ${s.num}`,ready:wS(s,t),why:s.disabled?"held out":a!=null&&a.blocksSwitch?a.text:null,warn:(a==null?void 0:a.tone)==="warn",headroom:aS(s,t)}})}function Zce(e,t,n){const s=Number(t),a=e&&(n==null?e.headroom:aS(e,n));return a!=null&&Number.isFinite(s)&&100-a>=s}function Jce(e){return(e==null?void 0:e.ok)===!0&&(e.enabled||e.external)}const q6="agent-dag.otherAccountsOrder",U6="agent-dag.otherAccountsOpen";function W6(){const e=nt(q6);return typeof e=="string"&&e.length>0&&e.length<=64?e:Nm}function Qce(e){st(q6,e)}function eue(){const e=nt(U6);if(!e)return cj;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 cj}function tue(e){st(U6,JSON.stringify({mode:e.mode,keys:e.keys.filter(t=>!t.startsWith("slot:"))}))}function nue(){const[e,t]=g.useState(null),n=g.useRef(null),s=g.useCallback(i=>cm(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=eo(e,i);return{disabled:u.disabled,"aria-busy":u.busy||l}}}}const sue=8e3,rue=1800,aue=4e3;function oue({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,d=g.useRef(i);d.current=i;const[f,p]=g.useState(null),[m,w]=g.useState(""),[x,b]=g.useState(null),j=g.useRef(0);g.useEffect(()=>{if(x==null)return;const W=window.setTimeout(()=>b(null),aue);return()=>window.clearTimeout(W)},[x]);const[k,v]=g.useState(null),[S,C]=g.useState(!1),[_,R]=g.useState(null),[A,I]=g.useState(null),$=g.useCallback(async(W,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(W)}),J=await Y.json().catch(()=>null);return J!=null&&J.ok||p({text:jl(J,"command failed",Y.status)}),J}catch{return p({text:"server unreachable"}),null}finally{t()}},[e,t,s]),U=g.useCallback(()=>{l(null),p(null),b(null),v(null),C(!1)},[]),F=(W,X="first")=>{U(),I(null),l({num:W,view:"menu",start:X})},M=g.useCallback(W=>{var J,Q;const X=d.current;if(!X||W!=null&&X.num!==W)return;const Y=document.getElementById(`ap-menu-${X.num}`);(Y!=null&&Y.contains(document.activeElement)||Hn(((J=document.activeElement)==null?void 0:J.tagName)??null))&&((Q=document.getElementById(`ap-more-${X.num}`))==null||Q.focus()),U()},[U]),B=g.useCallback(W=>p(W),[]),T=(W,X)=>{w(X??""),p(null),l({num:W,view:"rename"})},P=W=>w(W),q=W=>{I(null),p(null),l({num:W,view:"move"})},K=W=>I(W),z=async W=>{var Y;C(!1);const X=await $({action:"share",account:W},`share-${W}`);!(X!=null&&X.ok)||((Y=d.current)==null?void 0:Y.num)!==W||(v({num:W,blob:X.blob,expiresAt:X.expiresAt}),l({num:W,view:"share"}))},H=async W=>{await io(W)&&(C(!0),window.setTimeout(()=>C(!1),rue))},D=async(W,X)=>{const{commit:Y,alias:J}=Sie(m,X);if(Y){const Q=await $({action:"alias",account:W,alias:J},`alias-${W}`);if(await n(!0),!(Q!=null&&Q.ok))return}M(W)},O=async(W,X)=>{var Q,te,le;const Y=await $({action:"move",account:W,slot:X},`move-${W}`),J=jie({menuFor:((Q=d.current)==null?void 0:Q.num)??null,shareFor:(k==null?void 0:k.num)??null},W,Y);if(await n(!0),J){if(J.menuFor!=null){const oe=document.getElementById(`ap-menu-${W}`),re=document.getElementById(`ap-more-${J.menuFor}`);re&&(oe!=null&&oe.contains(document.activeElement)||Hn(((te=document.activeElement)==null?void 0:te.tagName)??null))&&re.focus()}((le=d.current)==null?void 0:le.num)===W&&U(),b(J.confirmRemove),J.shareFor==null&&(v(null),C(!1)),R(J.swapNote);const de=J.swapNote;de&&window.setTimeout(()=>R(oe=>oe===de?null:oe),sue),I(null),a(J.menuFor)}return Y};return{menu:i,menuFor:u,menuError:f,aliasDraft:m,confirmRemove:x,share:k,shareCopied:S,slotDraft:A,swapNote:_,showMenu:F,dropMenu:U,closeMenu:M,sayInMenu:B,startRename:T,typeAlias:P,doAlias:D,startMove:q,pickSlot:K,doSlot:async(W,X,Y)=>{if(!Y.sends){M(W);return}await O(W,X)},makeShare:z,copyShare:H,pressRemove:W=>{const X=Date.now(),Y=fi({armedFor:x,target:W,armedAt:j.current,now:X,gapMs:hi});if(Y==="arm"){b(W),j.current=X;return}Y!=="ignore"&&(b(null),$({action:"remove",account:W},`rm-${W}`).then(J=>{var Q;n(!0),J!=null&&J.ok&&(o==null||o(J),((Q=d.current)==null?void 0:Q.num)===W&&U(),a(null))}))}}}function iue(e,t){return!e||!t||t.some(n=>n.num===e.num&&n.active)?e:null}const lue="login_expired";function cue(e,t,n){return(e==null?void 0:e.reason)!==lue?null:{text:`${t}'s login expired · sign in again to use it`,row:n,signIn:!0}}const uue="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 due(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:uue}}:null}function hue({data:e,claim:t,release:n,load:s,sayFailure:a,clearFailure:o,sayInMenu:i,rescueFocus:l}){const[u,d]=g.useState(null),f=g.useCallback(async(w,x,b="panel")=>{if(!t(x))return null;const j=b==="menu"?i:a;j(null);try{const k=await fetch("/api/cswap-auto",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(w)}),v=await k.json().catch(()=>null);return v!=null&&v.ok||j({text:dj(v,"command failed",k.status),raw:fd(v)}),v}catch{return j({text:"server unreachable"}),null}finally{n()}},[t,n,i,a]);g.useEffect(()=>{!(e!=null&&e.ok)||!e.accounts||d(w=>iue(w,e.accounts))},[e]);const p=async(w,x)=>{if(t(`switch-${w}`)){o(),d(null);try{const j=await(await fetch("/api/claude-accounts/switch",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({account:w})})).json().catch(()=>null),k=cue(j,x,w);k?a(k):j!=null&&j.ok?d({num:w,name:x}):a({text:dj(j,"the switch failed"),raw:fd(j),row:w}),await s(!0)}catch{a({text:"server unreachable",row:w})}finally{n(),l(w)}}},m=g.useCallback((w,x)=>d({num:w,name:x}),[]);return{switched:u,post:f,doSwitch:p,noteSwitched:m}}const fue=1800;function pue({auto:e,post:t,load:n}){var R;const[s,a]=g.useReducer(qoe,mj),[o,i]=g.useState(!1),l=g.useRef(null),u=g.useRef(null),d=g.useRef(null),f=g.useRef(!1),p=((R=e==null?void 0:e.settings["autoswitch.threshold"])==null?void 0:R.value)??"90",m=s.pick??p,w=Tie(m,p),x=s.custom!=null,b=s.refusal,j=g.useRef(x);return g.useEffect(()=>{var A,I,$;j.current!==x&&(j.current=x,x?((A=d.current)==null||A.focus(),(I=d.current)==null||I.select()):f.current&&(($=l.current)==null||$.focus()),f.current=!1)},[x]),{threshold:p,thresholdPick:m,thresholdCtl:w,thresholdSaved:o,thresholdRef:l,thresholdSaveRef:u,thresholdCustom:x,thresholdRefusal:b,thresholdFieldRef:d,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,I)=>{const $=await Uoe(A,I,t);if($.kind==="refused"){a({kind:"refuse",message:$.message});return}$.kind==="sent"&&(await n(!0),!$.ok)||(f.current=document.activeElement===d.current,a({kind:"settle"}),i(!0),window.setTimeout(()=>{var U;document.activeElement===u.current&&((U=l.current)==null||U.focus()),i(!1)},fue))}}}const mue=1800;function gue({auto:e,post:t,load:n}){var x;const[s,a]=g.useState(null),[o,i]=g.useState(!1),l=g.useRef(null),u=g.useRef(null),d=((x=e==null?void 0:e.choice)==null?void 0:x.next)??"room",f=s??d,p=Eie(f,d);return{nextPick:f,nextCtl:p,nextSaved:o,nextRef:l,nextSaveRef:u,proposeNext:b=>a(Ooe(b)?b:null),doNext:async()=>{if(!p.sends)return;const b=await t({action:"next",value:f},"next");await n(!0),b!=null&&b.ok&&(a(null),i(!0),window.setTimeout(()=>{var j;document.activeElement===u.current&&((j=l.current)==null||j.focus()),i(!1)},mue))}}}const yue=Object.freeze({text:"couldn't reach the deck server",reload:!0}),wue=Object.freeze({text:"still waiting on the deck server — claude-swap can be slow to answer",reload:!0});async function FR(e){return e.ok?{ok:!0,status:e.status,body:null}:{ok:!1,status:e.status,body:await e.json().catch(()=>null)}}function xue(e){const t=e.find(s=>!s.ok);if(!t)return null;const n=fd(t.body);return{text:dj(t.body,`the deck server answered ${t.status}`),...n?{raw:n}:{},reload:!0}}function kw(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 jw=e=>e!=null&&typeof e=="object"&&!Array.isArray(e),Nw=e=>e==null||typeof e=="string",Sw=e=>e==null||typeof e=="number"&&Number.isFinite(e)&&e>=0&&Number.isFinite(new Date(e).getTime());function vue(e){if(!jw(e)||typeof e.ok!="boolean")return!1;if(!e.ok)return Nw(e.reason)&&Nw(e.hint);if(!Array.isArray(e.accounts))return!1;const t=new Set;return e.accounts.every(n=>{if(!jw(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(Nw)||![n.active,n.disabled,n.stale].every(a=>typeof a=="boolean")||!Sw(n.fetchedAt)||!Sw(n.nextAt)||!Array.isArray(n.lanes)))return!1;const s=new Set;return n.lanes.every(a=>!jw(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||!Sw(a.resetAt==null?null:typeof a.resetAt=="number"?a.resetAt*1e3:NaN)?!1:(s.add(a.id),!0))})}const H6=15e3,bue=3e4;function z6(e){const[t,n]=g.useState(null),[s,a]=g.useState(null),[o,i]=g.useState(!1),[l,u]=g.useState(null),d=g.useRef(null),f=g.useRef(0),p=g.useRef(!1),m=g.useRef(new Set),w=g.useCallback(async(j=!1)=>{if(!p.current||!j&&m.current.size>0)return;const k=++f.current;j&&i(!0);const v=new AbortController;m.current.add(v);const S=window.setTimeout(()=>v.abort(),bue);try{const[C,_]=await Promise.all([`/api/claude-accounts${j?"?refresh=1":""}`,"/api/cswap-auto"].map(async $=>fetch($,{signal:v.signal}))),[R,A]=await Promise.all([C.ok?C.json():null,_.ok?_.json():null]),I=xue([await FR(C),await FR(_)]);if(!p.current||k!==f.current)return;if(R&&!vue(R)){u($=>kw($,{text:"the deck server returned unreadable account data",reload:!0}));return}R&&(n(R),e(R)),A&&a(A),u($=>kw($,I))}catch{if(p.current&&k===f.current){const C=v.signal.aborted?wue:yue;u(_=>kw(_,C))}v.abort()}finally{window.clearTimeout(S),m.current.delete(v),p.current&&k===f.current&&i(!1)}},[e]);g.useEffect(()=>(p.current=!0,w(!0),d.current=window.setInterval(()=>w(!1),H6),()=>{p.current=!1,f.current++,d.current!=null&&window.clearInterval(d.current);for(const j of m.current)j.abort()}),[w]);const x=g.useCallback(j=>u(j),[]),b=g.useCallback(()=>u(null),[]);return{data:t,auto:s,reloading:o,failure:l,load:w,sayFailure:x,clearFailure:b}}const kue="#ap-rest-entry";function jue(e){return[`#${e}`,kue,...JP(null)]}function Nue(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||!Hn(((o=document.activeElement)==null?void 0:o.tagName)??null)))for(const i of jue(a)){const l=document.querySelector(i);if(l){l.focus();return}}},[e]),{onFocus:n,onBlur:s}}function Sue({onClose:e,leaving:t,onReport:n,onRoster:s,lanWanted:a=!1,onLanShown:o}){var $t,yn;cn("accounts-panel");const i=An(),{busy:l,claim:u,release:d,pressProps:f}=nue(),[p,m]=g.useState("accounts"),[w,x]=g.useState(!1),[b,j]=g.useState(null),k=g.useRef(b);k.current=b;const[v,S]=g.useState(!1),[C,_]=g.useState(null),[R,A]=g.useState(!1),[I,$]=g.useState(null),[U,F]=g.useState(eue),[M,B]=g.useState(W6),[T,P]=g.useState(null),[q,K]=g.useState(!1),z=g.useRef(s);z.current=s;const H=g.useCallback(xe=>{var Qe;F(ut=>Aae(ut,xe.accounts)),(Qe=z.current)==null||Qe.call(z,xe)},[]),{data:D,auto:O,reloading:V,failure:Z,load:W,sayFailure:X,clearFailure:Y}=z6(H),J=Nue(D),Q=g.useCallback(xe=>{window.requestAnimationFrame(()=>{var Qe;if(Hn(((Qe=document.activeElement)==null?void 0:Qe.tagName)??null))for(const ut of JP(xe)){const Lt=document.querySelector(ut);if(Lt){Lt.focus();return}}})},[]),te=g.useRef(null),le=oue({claim:u,release:d,load:W,clearFailure:Y,rescueFocus:Q,afterRemove:xe=>{var Qe;return(Qe=te.current)==null?void 0:Qe.call(te,xe)}}),{menu:de,menuFor:oe,swapNote:re,showMenu:he,dropMenu:fe,closeMenu:$e,sayInMenu:ye}=le,{switched:ge,post:je,doSwitch:Le,noteSwitched:ke}=hue({data:D,claim:u,release:d,load:W,sayFailure:X,clearFailure:Y,sayInMenu:ye,rescueFocus:Q});te.current=xe=>{const Qe=due(xe);Qe&&"switched"in Qe?ke(Qe.switched.num,Qe.switched.name):Qe&&X(Qe.failure)};const Ie=xe=>{_(xe),S(!0)},{threshold:De,thresholdPick:Ue,thresholdCtl:Ke,thresholdSaved:we,thresholdRef:Fe,thresholdSaveRef:Re,thresholdCustom:Ae,thresholdRefusal:rt,thresholdFieldRef:We,proposeThreshold:se,typeThreshold:be,cancelThreshold:Te,leaveThreshold:Oe,doThreshold:ve}=pue({auto:O,post:je,load:W}),{nextPick:pe,nextCtl:_e,nextSaved:ze,nextRef:at,nextSaveRef:tt,proposeNext:xt,doNext:Mt}=gue({auto:O,post:je,load:W}),Xt=QN();g.useEffect(()=>{tue(U)},[U]),g.useEffect(()=>{Qce(M)},[M]);const[tr,Cs]=g.useState(()=>new Set),zn=g.useCallback(xe=>Cs(new Set(xe)),[]),[ts,_s]=g.useState(()=>new Map),sn=xe=>{const Qe=dR([xe])[0].key,ut=ts.get(Qe);return{noCopyWorksNearby:tr.has(Qe),sharedTo:(ut==null?void 0:ut.to)??null,sharedInUse:(ut==null?void 0:ut.inUse)===!0}},zt=($t=D==null?void 0:D.accounts)==null?void 0:$t.find(xe=>xe.active),Me=zt?mi(zt,Xt,sn(zt)):null,Ve=(D==null?void 0:D.accounts)??[],Xe=zt?Ve.filter(xe=>!xe.active):[],Tt=Z5(Xe),Ct=Q5(M,Xe),qt=lj(J5(Xe,Ct,xe=>wS(xe,Xt),Xt),T),Vn=g.useRef(!1),nr=g.useRef(!1),Es=g.useRef(!1),gn=g.useCallback(()=>{!Vn.current&&!nr.current&&!Es.current&&P(null)},[]),_r=()=>P(xe=>xe??qt.map(ws)),ga={onPointerEnter:()=>{Vn.current=!0,_r()},onPointerLeave:()=>{Vn.current=!1,gn()},onFocus:xe=>{xe.target.matches(":focus-visible")&&(nr.current=!0,_r())},onBlur:xe=>{xe.currentTarget.contains(xe.relatedTarget)||(nr.current=!1,gn())}},Er=oe!=null&&Xe.some(xe=>xe.num===oe)||b!=null&&Xe.some(xe=>xe.num===b.num);g.useEffect(()=>{Es.current=Er,Er||gn()},[Er,gn]);const Ts=q&&Xe.length>0;g.useEffect(()=>{Ts||(Vn.current=nr.current=Es.current=!1,P(null))},[Ts]);const Tr=g.useRef(!1);g.useEffect(()=>{Tr.current&&Xe.length===0&&Q(null),Tr.current=Xe.length>0},[Xe.length,Q]);const ya=qt.length?Ve.filter(xe=>xe.active):Ve,Ar=Xce(qt,Xt,sn),Rr=Zce(zt,De,Xt),ho=Jce(O),yt=xe=>q&&qt.some(Qe=>Qe.num===xe)?"ap-rest-list":"ap-scroll",wa=(xe,Qe="first")=>{he(xe,Qe),j(null)},ns=(xe,Qe)=>{fe(),j(ut=>(ut==null?void 0:ut.anchor)===Qe?null:{num:xe,anchor:Qe})},xa=g.useCallback((xe=!1)=>{var ut;const Qe=k.current;xe&&Qe&&((ut=document.getElementById(Qe.anchor))==null||ut.focus()),j(null)},[]),As=()=>{fe(),j(null),m("lan")},Mr=g.useRef(p);g.useEffect(()=>{Mr.current!==p&&(Mr.current=p,window.requestAnimationFrame(()=>{var xe;(xe=document.getElementById(p==="lan"?"ap-lan-back":"ap-lan-entry"))==null||xe.focus()}))},[p]),g.useEffect(()=>{D!=null&&D.ok&&x(!0)},[D==null?void 0:D.ok]),g.useEffect(()=>{!a||!w||(As(),o==null||o())},[a,w]),g.useEffect(()=>{t&&(fe(),j(null))},[t,fe]),g.useEffect(()=>{de&&(D!=null&&D.accounts)&&!D.accounts.some(xe=>xe.num===de.num)&&fe(),b&&(D!=null&&D.accounts)&&!D.accounts.some(xe=>xe.num===b.num)&&j(null)},[D,de,b,fe]),g.useEffect(()=>{I==null||!(D!=null&&D.accounts)||D.accounts.some(xe=>xe.num===I.num)||($(null),Q(null))},[D,I,Q]);const sr=r.jsx("button",{type:"button",className:"glyph-btn",onClick:e,"aria-label":"Close accounts panel",title:En("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"})})}),Rs=xe=>{var ki;const Qe=e6(U,xe),ut=oe===xe.num,Lt=(Z==null?void 0:Z.row)===xe.num?Z:null,ss=(ge==null?void 0:ge.num)===xe.num,Rn=(re==null?void 0:re.at)===xe.num?re:null,$r=Rn?Ve.find(Ms=>Ms.num===Rn.displaced):void 0,Pd=(b==null?void 0:b.anchor)===`ap-issue-${xe.num}`;return r.jsx(Roe,{a:xe,nowSec:Xt,lan:sn(xe),opened:Qe,onToggleLanes:()=>F(Ms=>Eae(Ms,xe)),busy:l,pressProps:f,onSwitch:Le,menuOpen:ut,onOpenMenu:wa,onCloseMenu:$e,refusal:Lt,onDismissRefusal:()=>Y(),onSignIn:Ie,switchedHere:ss,swapped:Rn,displaced:$r,issueExpanded:Pd,onOpenIssue:ns,telemetryBoundaryId:yt(xe.num),sortKey:xe.active?null:Cae(Ct),home:yw(xe,(ki=O==null?void 0:O.choice)==null?void 0:ki.home)?Poe(xe,!!(O!=null&&O.enabled)):null,rotating:!!(O!=null&&O.enabled||O!=null&&O.external)},xe.num)},dn=D!=null&&D.ok&&(O!=null&&O.ok)?r.jsx(Woe,{auto:O,threshold:De,thresholdPick:Ue,thresholdCtl:Ke,thresholdSaved:we,thresholdRef:Fe,thresholdSaveRef:Re,thresholdCustom:Ae,thresholdRefusal:rt,thresholdFieldRef:We,proposeThreshold:se,typeThreshold:be,cancelThreshold:Te,leaveThreshold:Oe,doThreshold:ve,nextPick:pe,nextCtl:_e,nextSaved:ze,nextRef:at,nextSaveRef:tt,proposeNext:xt,doNext:Mt,pressProps:f,post:je,load:W}):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($oe,{canShare:(((yn=D==null?void 0:D.accounts)==null?void 0:yn.length)??0)>0,onAdd:()=>S(!0),onShareSet:()=>A(!0),onReload:()=>W(!0),pressProps:f,reloading:V,closeButton:sr}),p==="accounts"&&r.jsxs("div",{className:"ap-scroll",id:"ap-scroll",children:[D==null?Z?r.jsxs("div",{className:"ap-empty",role:"alert",children:[r.jsx("span",{title:Z.raw||void 0,children:Z.text}),r.jsxs("span",{className:"ap-hint",children:["No accounts have arrived, so there is nothing to show yet. The panel keeps trying every ",H6/1e3," seconds."]}),r.jsx("button",{type:"button",className:"ap-fix",...f("reload",V),onClick:()=>W(!0).then(()=>Q(null)),children:V?"trying…":"try again"})]}):r.jsx("div",{className:"ap-empty",children:"Checking…"}):D.ok?r.jsxs(r.Fragment,{children:[zt&&(Me==null?void 0:Me.tone)==="warn"&&r.jsxs("div",{className:"ap-notice",children:[r.jsxs("button",{type:"button",id:"ap-notice",className:"ap-issue","data-tone":"warn","aria-haspopup":"dialog","aria-expanded":(b==null?void 0:b.anchor)==="ap-notice","aria-controls":(b==null?void 0:b.anchor)==="ap-notice"?"ap-issue-pop":void 0,onClick:()=>ns(zt.num,"ap-notice"),children:[r.jsx(rS,{}),r.jsx("span",{className:"ap-issue-text",children:"Current account needs attention"})]}),Me.fix&&r.jsx("button",{type:"button",className:"ap-notice-fix",onClick:()=>S(!0),title:"Open the sign-in dialog. Signing in as this account replaces its stored login in place.",children:"Sign in"})]}),!zt&&D.unlistedLogin&&r.jsxs("div",{className:"ap-notice",children:[r.jsxs("span",{className:"ap-notice-text",children:["Claude Code is signed in to ",r.jsx("strong",{children:D.unlistedLogin}),", which isn't in your accounts."]}),r.jsx("button",{type:"button",className:"ap-notice-fix",onClick:()=>S(!0),title:"Open the add dialog. Once this login is one of your accounts, the deck can switch to it and back.",children:"Add account"})]}),r.jsx("ul",{className:"ap-list",children:ya.map(Rs)}),qt.length>0&&r.jsx(zce,{peers:Ar,strained:Rr,armed:ho,threshold:O!=null&&O.ok?De:null,open:q,onToggle:()=>K(xe=>!xe),order:Ct,choices:Tt,onOrder:B,allOpen:t6(U,qt),onToggleAll:()=>F(xe=>Tae(xe,qt)),held:T!=null}),qt.length>0&&q&&r.jsxs("div",{className:"ap-rest-panel",id:"ap-rest-panel",children:[r.jsx("ul",{className:"ap-list ap-others",id:"ap-rest-list",...ga,children:qt.map(Rs)}),dn]}),qt.length===0&&dn,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 Qe,ut;const xe=(Qe=D.accounts)==null?void 0:Qe.find(Lt=>Lt.num===de.num);return xe?r.jsx(Aie,{a:xe,accountMenu:le,slots:(D.accounts??[]).map(Lt=>Lt.num),boundaryId:yt(xe.num),nowSec:Xt,busy:l,pressProps:f,onProjects:()=>{$({num:xe.num,name:xe.alias??xe.email??`account ${xe.num}`}),$e(xe.num)},onRotation:()=>je({action:"account",account:xe.num,enabled:xe.disabled},`rot-${xe.num}`,"menu").then(Lt=>{W(!0),Lt!=null&&Lt.ok&&$e(xe.num)}),home:yw(xe,(ut=O==null?void 0:O.choice)==null?void 0:ut.home),onHome:()=>{var Lt;return je({action:"home",account:yw(xe,(Lt=O==null?void 0:O.choice)==null?void 0:Lt.home)?null:xe.num},`home-${xe.num}`,"menu").then(ss=>{W(!0),ss!=null&&ss.ok&&$e(xe.num)})}}):null})(),b&&(()=>{var ut;const xe=(ut=D.accounts)==null?void 0:ut.find(Lt=>Lt.num===b.num),Qe=xe?mi(xe,Xt,sn(xe)):null;return!xe||!Qe?null:r.jsx(fae,{anchorId:b.anchor,boundaryId:b.anchor==="ap-notice"?"ap-scroll":yt(xe.num),issue:Qe,who:xe.alias??xe.email??`account ${xe.num}`,fetchedAt:xe.fetchedAt,nowSec:Xt,onClose:xa,onSignIn:()=>S(!0),onReport:n&&(()=>n({initialKind:Qe.tone==="warn"?"bug":"other",initialBody:`Account issue: ${Qe.text}. ${Qe.hint}`}))})})()]}):r.jsx(Moe,{data:D}),r.jsx("div",{className:"film-foot",children:r.jsx(ld,{film:"claudeAccounts"})})]}),r.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:ge?`Now active: ${ge.name}`:""}),w&&r.jsx(Wce,{accounts:dR((D==null?void 0:D.accounts)??[]),onChanged:()=>W(!0),onNoCopy:zn,onShared:_s,view:p==="lan",onOpen:As,onBack:()=>m("accounts"),closeButton:sr}),v&&r.jsx(x6,{email:C,onClose:()=>{S(!1),_(null)},onChanged:()=>W(!0)}),R&&r.jsx(Yce,{accounts:((D==null?void 0:D.accounts)??[]).map(xe=>({num:xe.num,email:xe.email,alias:xe.alias,org:xe.org})),onClose:()=>A(!1),copyText:io}),I!=null&&(()=>{var Qe;const xe=(Qe=D==null?void 0:D.accounts)==null?void 0:Qe.find(ut=>ut.num===I.num);return D!=null&&D.accounts&&!xe?null:r.jsx(dae,{num:I.num,name:xe?xe.alias??xe.email??`account ${xe.num}`:I.name,onClose:()=>$(null)})})()]})}function BR(e){return`${e.getFullYear()}-${String(e.getMonth()+1).padStart(2,"0")}-${String(e.getDate()).padStart(2,"0")}`}function Cue(e,t,n=!1){const s=new Date(t*1e3),a=Array.from({length:7},(l,u)=>{const d=new Date(s.getFullYear(),s.getMonth(),s.getDate()+u);return{key:BR(d),date:d,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(v=>v.id==="seven_day"),d=u==null?void 0:u.resetAt,f=d!=null&&d>0&&Number.isFinite(d)&&Number.isFinite(new Date(d*1e3).getTime())?d:null,p=uj(l,"seven_day",t),m=mi(l,t),w=Sm(l.fetchedAt),x=w==null,b=n||x||l.stale||l.staleCopy===!0||l.stopped===!0||(m==null?void 0:m.blocksSwitch)===!0||t*1e3-w>n6,j=n?"Last saved reading":m!=null&&m.blocksSwitch||l.staleCopy||l.stopped?(m==null?void 0:m.text)??"Not collecting":x?"Never read":b?`${l.stale?"Marked stale · ":""}Read ${da(w,t)}`:null,k={key:ws(l),name:s6(l),active:l.active,heldOut:l.disabled,at:f,used:p.counted?p.pct:p.last,stale:b,note:j};if(f==null)i.push({...k,reason:"unknown"});else if(f<=t)i.push({...k,reason:"passed"});else{const v=o.get(BR(new Date(f*1e3)));v?(v.entries.push(k),b?v.outdated++:v.scheduled++):i.push({...k,reason:"outside"})}}for(const l of a)l.entries.sort((u,d)=>u.at-d.at);return{days:a,unscheduled:i}}const Wf=e=>e.toLocaleDateString(void 0,{weekday:"short"}),Ap=e=>e.toLocaleDateString(void 0,{month:"short",day:"numeric"}),Du=e=>e.toLocaleDateString(void 0,{weekday:"long",month:"long",day:"numeric",year:"numeric"}),xS=(e,t)=>e-t<60?"less than 1m":kd(e,t);function Am({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 Hf({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 V6({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(Hf,{entry:e}),o]}):s?r.jsxs("span",{className:"ap-reset-summary-content",children:[r.jsx(Hf,{entry:e}),r.jsx(G6,{entry:e,older:a})]}):r.jsx(Hf,{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,d=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: ":""}${so(u)}% used`}),r.jsx("span",{children:d==null?"Reset time unknown":d<=n?"Reported time passed · awaiting a new reading":r.jsxs(r.Fragment,{children:[e.stale?"Last reported reset":`Reset in ${xS(d,n)}`," · ",r.jsx(Am,{at:d})]})})]},i)}),r.jsx("p",{children:e.heldOut?"Excluded from automatic rotation.":"A weekly reset does not remove a separate 5-hour limit."})]})]})}function G6({entry:e,past:t=!1,older:n=!1}){return r.jsxs("span",{className:"ap-reset-reading","data-level":e.stale||t?"older":e.used!=null&&e.used>=70?"limited":void 0,children:[r.jsx("span",{className:"ap-reset-usage",children:e.used==null?"Usage unavailable":`${e.stale||t?"Last read: ":""}${so(e.used)}% used`}),e.used!=null&&!e.stale&&!t&&r.jsx("span",{className:"ap-reset-meter","data-level":e.used>=90?"hi":e.used>=70?"mid":void 0,"aria-hidden":"true",children:r.jsx("span",{style:{"--reset-used":Math.min(100,Math.max(0,e.used))/100}})}),e.stale&&r.jsxs("span",{className:"ap-reset-old",children:[!n&&"Needs a fresh reading · ",e.note]})]})}function _ue({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(V6,{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:[Ap(new Date(e.at*1e3))," · ",r.jsx(Am,{at:e.at})]})]}),r.jsx(G6,{entry:e,past:e.reason==="passed"})]})})})}function qR({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":Du(a.date),children:[r.jsxs("h4",{className:"vis-hidden",children:[Du(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:[Wf(a.date)," · ",Ap(a.date)]}),r.jsx(Am,{at:i}),!s&&r.jsxs("span",{children:["in ",xS(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(V6,{entry:u,row:t.get(u.key),nowSec:n,withReading:!0,older:s})},u.key))})]},i))})]},a.key):null})})}function Eue({accounts:e,nowSec:t,held:n,selectedDate:s=null,onSelect:a=()=>{},scope:o="upcoming",onScope:i=()=>{}}){const{days:l,unscheduled:u}=Cue(e,t,n!=null),d=l.find(I=>I.key===s)??null,f=d?[d]:l,p=l.reduce((I,$)=>I+$.scheduled,0),m=f.reduce((I,$)=>I+$.outdated,0),w=l.reduce((I,$)=>I+$.outdated,0),x=d?d.scheduled:p,b=l.flatMap(I=>I.entries).find(I=>!I.stale),j=b?l.flatMap(I=>I.entries).filter(I=>!I.stale&&I.at===b.at):[],k=g.useRef(null),v=g.useRef(null),S=g.useRef(null);g.useEffect(()=>{var $,U;const I=S.current;I&&!I.isConnected&&document.activeElement===document.body&&((U=($=v.current)==null?void 0:$.querySelector('.ap-reset-coverage-link[aria-pressed="true"]'))==null||U.focus({preventScroll:!0}))});const C=()=>{k.current&&(k.current.scrollTop=0)},_=I=>{C(),a(null),i(I)},R=Intl.DateTimeFormat().resolvedOptions().timeZone,A=new Map(lS(e,t).rows.map(I=>[I.key,I]));return r.jsxs("div",{ref:v,onFocusCapture:I=>{S.current=I.target},className:"ap-proj-body ap-report-body ap-reset-body",role:"region","aria-label":"Weekly reset calendar",children:[n&&r.jsx("p",{className:"ap-report-held",children:n}),r.jsxs("div",{className:"ap-reset-overview",children:[r.jsxs("div",{className:"ap-reset-command",children:[r.jsx("section",{className:"ap-reset-next","aria-label":"Next weekly reset",children:b?r.jsxs(r.Fragment,{children:[r.jsxs("div",{className:"ap-reset-next-identity",children:[r.jsxs("h3",{children:[r.jsx($Q,{}),"Next reported reset ",r.jsx("span",{className:"ap-reset-global",children:"· all days"})]}),j.length>1?r.jsxs("span",{className:"ap-reset-name",children:[j.length," accounts"]}):r.jsxs("details",{className:"ap-reset-next-account",children:[r.jsxs("summary",{title:b.name,children:[r.jsx(Hf,{entry:b}),r.jsx("span",{className:"vis-hidden",children:" · Full account name"})]}),r.jsx("p",{className:"ap-reset-full-name",children:b.name})]}),r.jsxs("p",{children:[Wf(new Date(b.at*1e3)),", ",Ap(new Date(b.at*1e3))," · ",r.jsx(Am,{at:b.at})]}),r.jsxs("p",{className:"ap-reset-next-note",children:["Reported time · recent reading",j.length>1?"s":b.used!=null?` · ${so(b.used)}% weekly used`:""]})]}),r.jsxs("p",{className:"ap-reset-countdown",children:[r.jsx("strong",{children:xS(b.at,t)}),r.jsxs("span",{children:[r.jsx("span",{className:"vis-hidden",children:"until "}),"reported reset"]})]})]}):r.jsxs("div",{className:"ap-reset-next-identity",children:[r.jsx("h3",{children:"No upcoming weekly resets"}),r.jsx("p",{children:w?"Some schedules need a fresh reading. Check the last reported times below.":"No reported weekly resets in these seven days. Unknown and elapsed times remain below."})]})}),r.jsxs("div",{className:"ap-reset-coverage",role:"group","aria-label":"Schedule data",children:[r.jsxs("button",{type:"button",className:"ap-reset-coverage-link","data-scope":"upcoming","aria-pressed":o==="upcoming",onClick:()=>_("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})]}),r.jsx("ol",{className:"ap-reset-week",role:"list","aria-label":"Seven-day reset counts",children:l.map((I,$)=>r.jsx("li",{"data-today":$===0?"":void 0,children:r.jsxs("button",{type:"button",className:"ap-reset-day-button","aria-current":$===0?"date":void 0,"data-active":I.scheduled>0?"":void 0,"aria-pressed":(d==null?void 0:d.key)===I.key,"aria-label":`${Du(I.date)}: ${I.scheduled} scheduled resets${I.outdated?`, ${I.outdated} readings need updating`:""}`,onClick:()=>{C(),i("upcoming"),a((d==null?void 0:d.key)===I.key?null:I.key)},children:[r.jsxs("time",{dateTime:I.key,title:Du(I.date),children:[r.jsx("span",{className:"ap-reset-weekday",children:$===0?"Today":Wf(I.date)}),r.jsx("span",{className:"ap-reset-date",children:I.date.getDate()})]}),r.jsxs("span",{className:"ap-reset-count",children:[r.jsx("b",{children:I.scheduled||"—"}),r.jsxs("span",{children:[" ",I.scheduled===1?"reset":"resets"]})]})]})},I.key))})]})]}),r.jsxs("div",{ref:k,className:"ap-reset-results",children:[r.jsxs("section",{className:"ap-reset-scheduled",hidden:o!=="upcoming","aria-label":"Scheduled weekly resets",children:[r.jsxs("div",{className:"ap-reset-list-head",children:[r.jsxs("h3",{children:[d?`${Wf(d.date)}, ${Ap(d.date)}`:"All upcoming resets"," ",r.jsx("span",{children:x})]}),r.jsx("button",{className:"btn",type:"button","aria-pressed":!d,onClick:()=>{C(),a(null)},children:"All days"})]}),r.jsx("p",{className:"ap-reset-hint",role:"status",children:d?`Showing only ${Du(d.date)}.`:"All days · select a date to narrow the agenda."}),x>0?r.jsx(qR,{days:f,rows:A,nowSec:t}):r.jsx("p",{className:"ap-reset-empty",children:d?"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(qR,{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(I=>r.jsx(_ue,{entry:I,row:A.get(I.key),nowSec:t},I.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 ",R,"; 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 K6(e){return e>=90?"hi":e>=70?"mid":void 0}const Y6=(e,t,n)=>`${e} ${e===1?t:n}`;function UR(e){const t=e.more>0?`, and ${Y6(e.more,"more account","more accounts")} in the same minute`:"";return`First: ${e.name} (${so(e.pct)}% used)${t}`}function Tue({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}=Pae(e.used??0),l=Math.round(Go(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?kd(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":K6(o),"aria-hidden":!0,children:r.jsx("i",{style:{"--left":i/100}})}),u&&e.nextReset&&r.jsxs("p",{className:"ap-report-reset",title:UR(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:[". ",UR(e.nextReset)]})]}),a]})}function Aue({cell:e,label:t}){if(!e.counted){const n=e.estimate==null?", not counted":", last reading, counted as is";return r.jsxs("td",{className:"ap-report-cell","data-uncounted":"",title:e.reset??void 0,children:[r.jsxs("span",{className:"ap-report-mobile-label","aria-hidden":"true",children:[t," used"]}),r.jsx("span",{className:"ap-report-pct",children:e.last==null?r.jsxs(r.Fragment,{children:[r.jsx("span",{"aria-hidden":!0,children:"—"}),r.jsx("span",{className:"vis-hidden",children:"no reading"})]}):`${so(e.last)}%`}),r.jsx("span",{className:"vis-hidden",children:e.reset?`. ${e.reset}. Awaiting a fresh reading${n}.`:n})]})}return r.jsxs("td",{className:"ap-report-cell",children:[r.jsxs("span",{className:"ap-report-mobile-label","aria-hidden":"true",children:[t," used"]}),r.jsxs("span",{className:"ap-report-pct","data-level":K6(e.pct),children:[so(e.pct),"%"]})]})}function Rue({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=kd(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 Mue={ready:"Ready",limited:"Limited",exhausted:"Exhausted",stale:"Stale"};function $ue({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}),Mue[e.status]]}),Object.values(e.cells).some(t=>!t.counted&&t.reset)&&r.jsx("span",{className:"ap-report-state-note",children:"Awaiting read"})]})}function Lue({row:e,nowSec:t}){const n=Mae(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 Iue(){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 Oue({accounts:e,nowSec:t,held:n,sort:s=null,onSort:a=()=>{}}){const o=lS(e,t),i=o.rows.length,l=Math.round(Go(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 ",Y6(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(d=>!d.counted&&d.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(Tue,{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",{}),si.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(yl,{col:"account",label:"Account",sort:s,next:du,onSort:a}),si.map(u=>r.jsxs(g.Fragment,{children:[r.jsx(yl,{col:u.id,label:`${u.label} used`,sort:s,next:du,onSort:a}),r.jsx(yl,{col:`${u.id}_reset`,label:`${u.label} reset`,sort:s,next:du,onSort:a})]},u.id)),r.jsx(yl,{col:"status",label:"Status",sort:s,next:du,onSort:a}),r.jsx(yl,{col:"updated",label:"Updated",className:"ap-report-upd-h",sort:s,next:du,onSort:a})]})}),r.jsx("tbody",{children:o.rows.map((u,d)=>r.jsxs("tr",{"data-active":u.active?"":void 0,style:{"--row":d},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"})]})}),si.map(f=>r.jsxs(g.Fragment,{children:[r.jsx(Aue,{cell:u.cells[f.id],label:f.label}),r.jsx(Rue,{at:u.resets[f.id],nowSec:t,label:f.label})]},f.id)),r.jsx($ue,{row:u}),r.jsx(Lue,{row:u,nowSec:t})]},u.num))})]})}),r.jsxs("details",{className:"ap-report-how",children:[r.jsxs("summary",{children:[r.jsx(Iue,{}),"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 Pue={accounts:"Account capacity",calendar:"Reset calendar"};function Due({accounts:e,order:t,failed:n,nowSec:s,onClose:a,view:o}){const i=g.useRef(null),l=gt(a,{focusRef:i}),u=wt(a),[d,f]=g.useState("upcoming"),[p,m]=g.useState(null),[w,x]=g.useState(e??[]);g.useEffect(()=>{e!=null&&x(e)},[e]);const b=Dae(n,e==null,w.length>0),[j,k]=g.useState(null),v=lj(w,(j==null?void 0:j.order)??t),S=C=>{const _=lS(lj(w,t),s).rows;k({sort:C,order:Oae(_,C).map(R=>R.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:C=>C.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ap-report-title",children:[r.jsxs("header",{className:"modal-head ap-proj-head",children:[r.jsx("div",{className:"ap-proj-titlewrap",children:r.jsx("h2",{id:"ap-report-title",children:Pue[o]})}),r.jsx("button",{ref:i,type:"button",className:"glyph-btn ap-proj-close",onClick:a,"aria-label":"Close",children:"×"})]}),r.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:b??""}),o==="accounts"?r.jsx(Oue,{accounts:v,nowSec:s,held:b,sort:(j==null?void 0:j.sort)??null,onSort:S}):r.jsx(Eue,{accounts:v,nowSec:s,held:b,selectedDate:p,onSelect:m,scope:d,onScope:f})]})}),document.body)}function Fue(e,t,n){const s=e.filter(o=>o.active);if(s.length===0)return e.map(ws);const a=e.filter(o=>!o.active);return[...s,...J5(a,Q5(t,a),o=>wS(o,n),n)].map(ws)}function Bue(){}function que({view:e,onClose:t}){const{data:n,failure:s}=z6(Bue),a=QN(),[o,i]=g.useState(null);return g.useEffect(()=>{o==null&&n&&i(Fue(n.accounts??[],W6(),a))},[n,o,a]),o==null&&s==null?null:r.jsx(Due,{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 Uue({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 Wue=16,Hue=120;function zue(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 Vue(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 Gue(e,t){return zue(e,t,Wue)?"over":Vue(e,t)<=Hue?"near":"far"}function Kue(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 Yue(){const[e,t]=g.useState(!1),[n,s]=g.useState(""),[a,o]=g.useState("far"),i=g.useRef(null),l=bl(e,140),u=g.useCallback(m=>{var b;const w=(b=i.current)==null?void 0:b.getBoundingClientRect(),x=Kue(m);return w&&x?Gue(x,w):"far"},[]),d=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 x=w&&u(m)==="over";return t(!1),x},[u]);return{trashDragging:e,trashLabel:n,trashState:a,trashZoneRef:i,trashPhase:l,beginTrashDrag:d,trackTrashDrag:f,endTrashDrag:p}}const Xue=420;function Zue(){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),Xue+80)})},[]);return g.useEffect(()=>()=>{n.current&&window.clearTimeout(n.current)},[]),{bubbling:e,endBubble:s,onBubble:a}}const vS=11;function X6(e=0){return vS+Math.min(0,e)}const Z6=7.2,J6=6.6,Jue={width:104,height:48},WR={width:96,height:44},Q6={width:220,height:103};function Que(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)?Q6:{width:Math.max(160,t),height:Math.max(72,n)}}function Cw(e,t,n){return e.width*t>=n.width&&e.height*t>=n.height}function ede(e,t,n=Q6,s=vS){if(!Number.isFinite(t)||t<=0)return e??"detail";const a=s*t;return e==="detail"?a>=J6?"detail":Cw(n,t,WR)?"compact":"overview":a>=Z6?"detail":e==="compact"?Cw(n,t,WR)?"compact":"overview":Cw(n,t,Jue)?"compact":"overview"}function tde(e,t,n=vS){return e>=Z6/n?e:Math.max(e,Math.min(t,J6/n-.001))}const nde=.8,sde=1;function rde({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 x of e.current.agents.keys()){const b=t.current.get(x);b&&p.push(b)}const m=Que(p);return l.current={version:f,card:m},m},[]),d=g.useCallback(f=>{var m;const p=ede(i.current,f,u(),X6(VN[GN()]));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:d}}const ade=40,ode=120;function ide(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,d,f)=>{if(n!=null){if(s<=u)return;i()}const p=Math.min(f,Math.max(0,u-d));s=u,n=t.setTimeout(o,p)};return{live(u=ade){const d=t.now(),f=Math.max(a+u,d);if(f<=d){i(),o();return}l(f,d,u)},replay(u=ode){i(),s=t.now()+u,n=t.setTimeout(o,u)},flush(){i(),o()},cancel(){i()}}}const lde=6,cde="ccdeck-tabs";function ude(e){return e>=lde}function dde(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=d=>{const f=d.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 hde({stateRef:e,rerender:t,pauseGate:n,chimesRef:s,desktopUpdateRef:a}){const[o,i]=g.useState(!1),[l,u]=g.useState(!1),[d,f]=g.useState(!1),p=g.useRef(!0),[m,w]=g.useState(null);return g.useEffect(()=>{const x=new EventSource("/events"),b=ide(t,{now:()=>Date.now(),setTimeout:(S,C)=>window.setTimeout(S,C),clearTimeout:S=>window.clearTimeout(S)});let j=!1;const k=typeof BroadcastChannel=="function"?dde(new BroadcastChannel(cde),Math.random().toString(36).slice(2),()=>j):null,v=window.setInterval(()=>{j||!k||k.ask(600).then(S=>{j||u(ude(S))})},3e3);return x.addEventListener("open",()=>{i(!0),f(!0)}),x.addEventListener("error",()=>{i(!1),w(null)}),x.addEventListener("open",()=>{j=!0,u(!1)}),x.addEventListener("error",()=>{j=!1}),x.addEventListener("replay-end",()=>{p.current=!1,b.flush(),w(Date.now())}),x.addEventListener("desktop-update",S=>a.current(S.data)),x.addEventListener("hook",S=>{var C;try{const _=JSON.parse(S.data);if(!n.accept(_))return;e.current=wP(e.current,_);const R=_.replay===!0||p.current||Date.now()-_.receivedAt>3e4;R?b.replay():b.live();const A=lte(_,R);A&&((C=s.current)==null||C.play(A))}catch{}}),()=>{x.close(),b.cancel(),window.clearInterval(v),k==null||k.leave()}},[t]),{live:o,tabCapped:l,everConnected:d,liveSince:m}}const fde=200,pde=5*6e4,mde=6,gde=2*6e4;function pu(e,t){if(t.size!==0)for(const n of Array.from(e.keys()))t.has(n)||e.delete(n)}function yde(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 wde(e){const t=new Set;for(const n of e)t.add(n.id),t.add(`group:${n.sessionId}`),n.kind==="root"&&t.add(bN(n.id));return t}function xde(e){const t=new Set;for(const n of e)t.add(n.id),n.kind==="root"&&t.add(bN(n.id));return t}function vde(e,t){let n=dG(e,t,cT);hG(e,t,cT)&&(n=!0);const s=[],a=o=>{s.push(o)};return lG(e,t,fde,pde,a)&&(n=!0),cG(e,t,mde,gde,a)&&(n=!0),{changed:n,forgotten:s}}function bde(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 kde(e,t){const[n,s]=g.useState(()=>({ids:new Set,primary:null})),{ids:a,primary:o}=n,i=g.useCallback((d,f,p=!f)=>{s(m=>bde(m,d,f)),!f&&p&&t(!0)},[]),l=g.useCallback(()=>{s({ids:new Set,primary:null})},[]),u=g.useCallback(()=>{s(d=>{const f=yde(d.ids,e.current.agents),p=d.primary!=null&&!e.current.agents.has(d.primary)?null:d.primary;return f===d.ids&&p===d.primary?d:{ids:f,primary:p}})},[e]);return{selectedIds:a,primarySelectedId:o,selectAgent:i,clearSelection:l,pruneSelectionToBoard:u}}function jde({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:d,forgotten:f}=vde(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),d&&t()},250);return()=>clearInterval(l)},[t]),o}function bS(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 _w,HR;function Nde(){if(HR)return _w;HR=1;function e(){this.__data__=[],this.size=0}return _w=e,_w}var Ew,zR;function cc(){if(zR)return Ew;zR=1;function e(t,n){return t===n||t!==t&&n!==n}return Ew=e,Ew}var Tw,VR;function Rm(){if(VR)return Tw;VR=1;var e=cc();function t(n,s){for(var a=n.length;a--;)if(e(n[a][0],s))return a;return-1}return Tw=t,Tw}var Aw,GR;function Sde(){if(GR)return Aw;GR=1;var e=Rm(),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 Aw=s,Aw}var Rw,KR;function Cde(){if(KR)return Rw;KR=1;var e=Rm();function t(n){var s=this.__data__,a=e(s,n);return a<0?void 0:s[a][1]}return Rw=t,Rw}var Mw,YR;function _de(){if(YR)return Mw;YR=1;var e=Rm();function t(n){return e(this.__data__,n)>-1}return Mw=t,Mw}var $w,XR;function Ede(){if(XR)return $w;XR=1;var e=Rm();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 $w=t,$w}var Lw,ZR;function Mm(){if(ZR)return Lw;ZR=1;var e=Nde(),t=Sde(),n=Cde(),s=_de(),a=Ede();function o(i){var l=-1,u=i==null?0:i.length;for(this.clear();++l<u;){var d=i[l];this.set(d[0],d[1])}}return o.prototype.clear=e,o.prototype.delete=t,o.prototype.get=n,o.prototype.has=s,o.prototype.set=a,Lw=o,Lw}var Iw,JR;function Tde(){if(JR)return Iw;JR=1;var e=Mm();function t(){this.__data__=new e,this.size=0}return Iw=t,Iw}var Ow,QR;function Ade(){if(QR)return Ow;QR=1;function e(t){var n=this.__data__,s=n.delete(t);return this.size=n.size,s}return Ow=e,Ow}var Pw,e2;function Rde(){if(e2)return Pw;e2=1;function e(t){return this.__data__.get(t)}return Pw=e,Pw}var Dw,t2;function Mde(){if(t2)return Dw;t2=1;function e(t){return this.__data__.has(t)}return Dw=e,Dw}var Fw,n2;function eF(){if(n2)return Fw;n2=1;var e=typeof Vh=="object"&&Vh&&Vh.Object===Object&&Vh;return Fw=e,Fw}var Bw,s2;function er(){if(s2)return Bw;s2=1;var e=eF(),t=typeof self=="object"&&self&&self.Object===Object&&self,n=e||t||Function("return this")();return Bw=n,Bw}var qw,r2;function uc(){if(r2)return qw;r2=1;var e=er(),t=e.Symbol;return qw=t,qw}var Uw,a2;function $de(){if(a2)return Uw;a2=1;var e=uc(),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 d=!0}catch{}var f=s.call(i);return d&&(l?i[a]=u:delete i[a]),f}return Uw=o,Uw}var Ww,o2;function Lde(){if(o2)return Ww;o2=1;var e=Object.prototype,t=e.toString;function n(s){return t.call(s)}return Ww=n,Ww}var Hw,i2;function wi(){if(i2)return Hw;i2=1;var e=uc(),t=$de(),n=Lde(),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 Hw=i,Hw}var zw,l2;function Ns(){if(l2)return zw;l2=1;function e(t){var n=typeof t;return t!=null&&(n=="object"||n=="function")}return zw=e,zw}var Vw,c2;function Cd(){if(c2)return Vw;c2=1;var e=wi(),t=Ns(),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 Vw=i,Vw}var Gw,u2;function Ide(){if(u2)return Gw;u2=1;var e=er(),t=e["__core-js_shared__"];return Gw=t,Gw}var Kw,d2;function Ode(){if(d2)return Kw;d2=1;var e=Ide(),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 Kw=n,Kw}var Yw,h2;function tF(){if(h2)return Yw;h2=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 Yw=n,Yw}var Xw,f2;function Pde(){if(f2)return Xw;f2=1;var e=Cd(),t=Ode(),n=Ns(),s=tF(),a=/[\\^$.*+?()[\]{}|]/g,o=/^\[object .+?Constructor\]$/,i=Function.prototype,l=Object.prototype,u=i.toString,d=l.hasOwnProperty,f=RegExp("^"+u.call(d).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 Xw=p,Xw}var Zw,p2;function Dde(){if(p2)return Zw;p2=1;function e(t,n){return t==null?void 0:t[n]}return Zw=e,Zw}var Jw,m2;function xi(){if(m2)return Jw;m2=1;var e=Pde(),t=Dde();function n(s,a){var o=t(s,a);return e(o)?o:void 0}return Jw=n,Jw}var Qw,g2;function kS(){if(g2)return Qw;g2=1;var e=xi(),t=er(),n=e(t,"Map");return Qw=n,Qw}var ex,y2;function $m(){if(y2)return ex;y2=1;var e=xi(),t=e(Object,"create");return ex=t,ex}var tx,w2;function Fde(){if(w2)return tx;w2=1;var e=$m();function t(){this.__data__=e?e(null):{},this.size=0}return tx=t,tx}var nx,x2;function Bde(){if(x2)return nx;x2=1;function e(t){var n=this.has(t)&&delete this.__data__[t];return this.size-=n?1:0,n}return nx=e,nx}var sx,v2;function qde(){if(v2)return sx;v2=1;var e=$m(),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 sx=a,sx}var rx,b2;function Ude(){if(b2)return rx;b2=1;var e=$m(),t=Object.prototype,n=t.hasOwnProperty;function s(a){var o=this.__data__;return e?o[a]!==void 0:n.call(o,a)}return rx=s,rx}var ax,k2;function Wde(){if(k2)return ax;k2=1;var e=$m(),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 ax=n,ax}var ox,j2;function Hde(){if(j2)return ox;j2=1;var e=Fde(),t=Bde(),n=qde(),s=Ude(),a=Wde();function o(i){var l=-1,u=i==null?0:i.length;for(this.clear();++l<u;){var d=i[l];this.set(d[0],d[1])}}return o.prototype.clear=e,o.prototype.delete=t,o.prototype.get=n,o.prototype.has=s,o.prototype.set=a,ox=o,ox}var ix,N2;function zde(){if(N2)return ix;N2=1;var e=Hde(),t=Mm(),n=kS();function s(){this.size=0,this.__data__={hash:new e,map:new(n||t),string:new e}}return ix=s,ix}var lx,S2;function Vde(){if(S2)return lx;S2=1;function e(t){var n=typeof t;return n=="string"||n=="number"||n=="symbol"||n=="boolean"?t!=="__proto__":t===null}return lx=e,lx}var cx,C2;function Lm(){if(C2)return cx;C2=1;var e=Vde();function t(n,s){var a=n.__data__;return e(s)?a[typeof s=="string"?"string":"hash"]:a.map}return cx=t,cx}var ux,_2;function Gde(){if(_2)return ux;_2=1;var e=Lm();function t(n){var s=e(this,n).delete(n);return this.size-=s?1:0,s}return ux=t,ux}var dx,E2;function Kde(){if(E2)return dx;E2=1;var e=Lm();function t(n){return e(this,n).get(n)}return dx=t,dx}var hx,T2;function Yde(){if(T2)return hx;T2=1;var e=Lm();function t(n){return e(this,n).has(n)}return hx=t,hx}var fx,A2;function Xde(){if(A2)return fx;A2=1;var e=Lm();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 fx=t,fx}var px,R2;function jS(){if(R2)return px;R2=1;var e=zde(),t=Gde(),n=Kde(),s=Yde(),a=Xde();function o(i){var l=-1,u=i==null?0:i.length;for(this.clear();++l<u;){var d=i[l];this.set(d[0],d[1])}}return o.prototype.clear=e,o.prototype.delete=t,o.prototype.get=n,o.prototype.has=s,o.prototype.set=a,px=o,px}var mx,M2;function Zde(){if(M2)return mx;M2=1;var e=Mm(),t=kS(),n=jS(),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 mx=a,mx}var gx,$2;function Im(){if($2)return gx;$2=1;var e=Mm(),t=Tde(),n=Ade(),s=Rde(),a=Mde(),o=Zde();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,gx=i,gx}var yx,L2;function NS(){if(L2)return yx;L2=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 yx=e,yx}var wx,I2;function nF(){if(I2)return wx;I2=1;var e=xi(),t=(function(){try{var n=e(Object,"defineProperty");return n({},"",{}),n}catch{}})();return wx=t,wx}var xx,O2;function Om(){if(O2)return xx;O2=1;var e=nF();function t(n,s,a){s=="__proto__"&&e?e(n,s,{configurable:!0,enumerable:!0,value:a,writable:!0}):n[s]=a}return xx=t,xx}var vx,P2;function Pm(){if(P2)return vx;P2=1;var e=Om(),t=cc(),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 vx=a,vx}var bx,D2;function _d(){if(D2)return bx;D2=1;var e=Pm(),t=Om();function n(s,a,o,i){var l=!o;o||(o={});for(var u=-1,d=a.length;++u<d;){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 bx=n,bx}var kx,F2;function Jde(){if(F2)return kx;F2=1;function e(t,n){for(var s=-1,a=Array(t);++s<t;)a[s]=n(s);return a}return kx=e,kx}var jx,B2;function Cr(){if(B2)return jx;B2=1;function e(t){return t!=null&&typeof t=="object"}return jx=e,jx}var Nx,q2;function Qde(){if(q2)return Nx;q2=1;var e=wi(),t=Cr(),n="[object Arguments]";function s(a){return t(a)&&e(a)==n}return Nx=s,Nx}var Sx,U2;function Ed(){if(U2)return Sx;U2=1;var e=Qde(),t=Cr(),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 Sx=o,Sx}var Cx,W2;function Yt(){if(W2)return Cx;W2=1;var e=Array.isArray;return Cx=e,Cx}var Su={exports:{}},_x,H2;function ehe(){if(H2)return _x;H2=1;function e(){return!1}return _x=e,_x}Su.exports;var z2;function dc(){return z2||(z2=1,(function(e,t){var n=er(),s=ehe(),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,d=u||s;e.exports=d})(Su,Su.exports)),Su.exports}var Ex,V2;function Dm(){if(V2)return Ex;V2=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 Ex=n,Ex}var Tx,G2;function SS(){if(G2)return Tx;G2=1;var e=9007199254740991;function t(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=e}return Tx=t,Tx}var Ax,K2;function the(){if(K2)return Ax;K2=1;var e=wi(),t=SS(),n=Cr(),s="[object Arguments]",a="[object Array]",o="[object Boolean]",i="[object Date]",l="[object Error]",u="[object Function]",d="[object Map]",f="[object Number]",p="[object Object]",m="[object RegExp]",w="[object Set]",x="[object String]",b="[object WeakMap]",j="[object ArrayBuffer]",k="[object DataView]",v="[object Float32Array]",S="[object Float64Array]",C="[object Int8Array]",_="[object Int16Array]",R="[object Int32Array]",A="[object Uint8Array]",I="[object Uint8ClampedArray]",$="[object Uint16Array]",U="[object Uint32Array]",F={};F[v]=F[S]=F[C]=F[_]=F[R]=F[A]=F[I]=F[$]=F[U]=!0,F[s]=F[a]=F[j]=F[o]=F[k]=F[i]=F[l]=F[u]=F[d]=F[f]=F[p]=F[m]=F[w]=F[x]=F[b]=!1;function M(B){return n(B)&&t(B.length)&&!!F[e(B)]}return Ax=M,Ax}var Rx,Y2;function Fm(){if(Y2)return Rx;Y2=1;function e(t){return function(n){return t(n)}}return Rx=e,Rx}var Cu={exports:{}};Cu.exports;var X2;function CS(){return X2||(X2=1,(function(e,t){var n=eF(),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})(Cu,Cu.exports)),Cu.exports}var Mx,Z2;function Td(){if(Z2)return Mx;Z2=1;var e=the(),t=Fm(),n=CS(),s=n&&n.isTypedArray,a=s?t(s):e;return Mx=a,Mx}var $x,J2;function sF(){if(J2)return $x;J2=1;var e=Jde(),t=Ed(),n=Yt(),s=dc(),a=Dm(),o=Td(),i=Object.prototype,l=i.hasOwnProperty;function u(d,f){var p=n(d),m=!p&&t(d),w=!p&&!m&&s(d),x=!p&&!m&&!w&&o(d),b=p||m||w||x,j=b?e(d.length,String):[],k=j.length;for(var v in d)(f||l.call(d,v))&&!(b&&(v=="length"||w&&(v=="offset"||v=="parent")||x&&(v=="buffer"||v=="byteLength"||v=="byteOffset")||a(v,k)))&&j.push(v);return j}return $x=u,$x}var Lx,Q2;function Bm(){if(Q2)return Lx;Q2=1;var e=Object.prototype;function t(n){var s=n&&n.constructor,a=typeof s=="function"&&s.prototype||e;return n===a}return Lx=t,Lx}var Ix,eM;function rF(){if(eM)return Ix;eM=1;function e(t,n){return function(s){return t(n(s))}}return Ix=e,Ix}var Ox,tM;function nhe(){if(tM)return Ox;tM=1;var e=rF(),t=e(Object.keys,Object);return Ox=t,Ox}var Px,nM;function _S(){if(nM)return Px;nM=1;var e=Bm(),t=nhe(),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 Px=a,Px}var Dx,sM;function pa(){if(sM)return Dx;sM=1;var e=Cd(),t=SS();function n(s){return s!=null&&t(s.length)&&!e(s)}return Dx=n,Dx}var Fx,rM;function uo(){if(rM)return Fx;rM=1;var e=sF(),t=_S(),n=pa();function s(a){return n(a)?e(a):t(a)}return Fx=s,Fx}var Bx,aM;function she(){if(aM)return Bx;aM=1;var e=_d(),t=uo();function n(s,a){return s&&e(a,t(a),s)}return Bx=n,Bx}var qx,oM;function rhe(){if(oM)return qx;oM=1;function e(t){var n=[];if(t!=null)for(var s in Object(t))n.push(s);return n}return qx=e,qx}var Ux,iM;function ahe(){if(iM)return Ux;iM=1;var e=Ns(),t=Bm(),n=rhe(),s=Object.prototype,a=s.hasOwnProperty;function o(i){if(!e(i))return n(i);var l=t(i),u=[];for(var d in i)d=="constructor"&&(l||!a.call(i,d))||u.push(d);return u}return Ux=o,Ux}var Wx,lM;function vi(){if(lM)return Wx;lM=1;var e=sF(),t=ahe(),n=pa();function s(a){return n(a)?e(a,!0):t(a)}return Wx=s,Wx}var Hx,cM;function ohe(){if(cM)return Hx;cM=1;var e=_d(),t=vi();function n(s,a){return s&&e(a,t(a),s)}return Hx=n,Hx}var _u={exports:{}};_u.exports;var uM;function aF(){return uM||(uM=1,(function(e,t){var n=er(),s=t&&!t.nodeType&&t,a=s&&!0&&e&&!e.nodeType&&e,o=a&&a.exports===s,i=o?n.Buffer:void 0,l=i?i.allocUnsafe:void 0;function u(d,f){if(f)return d.slice();var p=d.length,m=l?l(p):new d.constructor(p);return d.copy(m),m}e.exports=u})(_u,_u.exports)),_u.exports}var zx,dM;function oF(){if(dM)return zx;dM=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 zx=e,zx}var Vx,hM;function iF(){if(hM)return Vx;hM=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 Vx=e,Vx}var Gx,fM;function lF(){if(fM)return Gx;fM=1;function e(){return[]}return Gx=e,Gx}var Kx,pM;function ES(){if(pM)return Kx;pM=1;var e=iF(),t=lF(),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 Kx=o,Kx}var Yx,mM;function ihe(){if(mM)return Yx;mM=1;var e=_d(),t=ES();function n(s,a){return e(s,t(s),a)}return Yx=n,Yx}var Xx,gM;function TS(){if(gM)return Xx;gM=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 Xx=e,Xx}var Zx,yM;function qm(){if(yM)return Zx;yM=1;var e=rF(),t=e(Object.getPrototypeOf,Object);return Zx=t,Zx}var Jx,wM;function cF(){if(wM)return Jx;wM=1;var e=TS(),t=qm(),n=ES(),s=lF(),a=Object.getOwnPropertySymbols,o=a?function(i){for(var l=[];i;)e(l,n(i)),i=t(i);return l}:s;return Jx=o,Jx}var Qx,xM;function lhe(){if(xM)return Qx;xM=1;var e=_d(),t=cF();function n(s,a){return e(s,t(s),a)}return Qx=n,Qx}var ev,vM;function uF(){if(vM)return ev;vM=1;var e=TS(),t=Yt();function n(s,a,o){var i=a(s);return t(s)?i:e(i,o(s))}return ev=n,ev}var tv,bM;function dF(){if(bM)return tv;bM=1;var e=uF(),t=ES(),n=uo();function s(a){return e(a,n,t)}return tv=s,tv}var nv,kM;function che(){if(kM)return nv;kM=1;var e=uF(),t=cF(),n=vi();function s(a){return e(a,n,t)}return nv=s,nv}var sv,jM;function uhe(){if(jM)return sv;jM=1;var e=xi(),t=er(),n=e(t,"DataView");return sv=n,sv}var rv,NM;function dhe(){if(NM)return rv;NM=1;var e=xi(),t=er(),n=e(t,"Promise");return rv=n,rv}var av,SM;function hF(){if(SM)return av;SM=1;var e=xi(),t=er(),n=e(t,"Set");return av=n,av}var ov,CM;function hhe(){if(CM)return ov;CM=1;var e=xi(),t=er(),n=e(t,"WeakMap");return ov=n,ov}var iv,_M;function hc(){if(_M)return iv;_M=1;var e=uhe(),t=kS(),n=dhe(),s=hF(),a=hhe(),o=wi(),i=tF(),l="[object Map]",u="[object Object]",d="[object Promise]",f="[object Set]",p="[object WeakMap]",m="[object DataView]",w=i(e),x=i(t),b=i(n),j=i(s),k=i(a),v=o;return(e&&v(new e(new ArrayBuffer(1)))!=m||t&&v(new t)!=l||n&&v(n.resolve())!=d||s&&v(new s)!=f||a&&v(new a)!=p)&&(v=function(S){var C=o(S),_=C==u?S.constructor:void 0,R=_?i(_):"";if(R)switch(R){case w:return m;case x:return l;case b:return d;case j:return f;case k:return p}return C}),iv=v,iv}var lv,EM;function fhe(){if(EM)return lv;EM=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 lv=n,lv}var cv,TM;function fF(){if(TM)return cv;TM=1;var e=er(),t=e.Uint8Array;return cv=t,cv}var uv,AM;function AS(){if(AM)return uv;AM=1;var e=fF();function t(n){var s=new n.constructor(n.byteLength);return new e(s).set(new e(n)),s}return uv=t,uv}var dv,RM;function phe(){if(RM)return dv;RM=1;var e=AS();function t(n,s){var a=s?e(n.buffer):n.buffer;return new n.constructor(a,n.byteOffset,n.byteLength)}return dv=t,dv}var hv,MM;function mhe(){if(MM)return hv;MM=1;var e=/\w*$/;function t(n){var s=new n.constructor(n.source,e.exec(n));return s.lastIndex=n.lastIndex,s}return hv=t,hv}var fv,$M;function ghe(){if($M)return fv;$M=1;var e=uc(),t=e?e.prototype:void 0,n=t?t.valueOf:void 0;function s(a){return n?Object(n.call(a)):{}}return fv=s,fv}var pv,LM;function pF(){if(LM)return pv;LM=1;var e=AS();function t(n,s){var a=s?e(n.buffer):n.buffer;return new n.constructor(a,n.byteOffset,n.length)}return pv=t,pv}var mv,IM;function yhe(){if(IM)return mv;IM=1;var e=AS(),t=phe(),n=mhe(),s=ghe(),a=pF(),o="[object Boolean]",i="[object Date]",l="[object Map]",u="[object Number]",d="[object RegExp]",f="[object Set]",p="[object String]",m="[object Symbol]",w="[object ArrayBuffer]",x="[object DataView]",b="[object Float32Array]",j="[object Float64Array]",k="[object Int8Array]",v="[object Int16Array]",S="[object Int32Array]",C="[object Uint8Array]",_="[object Uint8ClampedArray]",R="[object Uint16Array]",A="[object Uint32Array]";function I($,U,F){var M=$.constructor;switch(U){case w:return e($);case o:case i:return new M(+$);case x:return t($,F);case b:case j:case k:case v:case S:case C:case _:case R:case A:return a($,F);case l:return new M;case u:case p:return new M($);case d:return n($);case f:return new M;case m:return s($)}}return mv=I,mv}var gv,OM;function mF(){if(OM)return gv;OM=1;var e=Ns(),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 gv=n,gv}var yv,PM;function gF(){if(PM)return yv;PM=1;var e=mF(),t=qm(),n=Bm();function s(a){return typeof a.constructor=="function"&&!n(a)?e(t(a)):{}}return yv=s,yv}var wv,DM;function whe(){if(DM)return wv;DM=1;var e=hc(),t=Cr(),n="[object Map]";function s(a){return t(a)&&e(a)==n}return wv=s,wv}var xv,FM;function xhe(){if(FM)return xv;FM=1;var e=whe(),t=Fm(),n=CS(),s=n&&n.isMap,a=s?t(s):e;return xv=a,xv}var vv,BM;function vhe(){if(BM)return vv;BM=1;var e=hc(),t=Cr(),n="[object Set]";function s(a){return t(a)&&e(a)==n}return vv=s,vv}var bv,qM;function bhe(){if(qM)return bv;qM=1;var e=vhe(),t=Fm(),n=CS(),s=n&&n.isSet,a=s?t(s):e;return bv=a,bv}var kv,UM;function yF(){if(UM)return kv;UM=1;var e=Im(),t=NS(),n=Pm(),s=she(),a=ohe(),o=aF(),i=oF(),l=ihe(),u=lhe(),d=dF(),f=che(),p=hc(),m=fhe(),w=yhe(),x=gF(),b=Yt(),j=dc(),k=xhe(),v=Ns(),S=bhe(),C=uo(),_=vi(),R=1,A=2,I=4,$="[object Arguments]",U="[object Array]",F="[object Boolean]",M="[object Date]",B="[object Error]",T="[object Function]",P="[object GeneratorFunction]",q="[object Map]",K="[object Number]",z="[object Object]",H="[object RegExp]",D="[object Set]",O="[object String]",V="[object Symbol]",Z="[object WeakMap]",W="[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]",fe={};fe[$]=fe[U]=fe[W]=fe[X]=fe[F]=fe[M]=fe[Y]=fe[J]=fe[Q]=fe[te]=fe[le]=fe[q]=fe[K]=fe[z]=fe[H]=fe[D]=fe[O]=fe[V]=fe[de]=fe[oe]=fe[re]=fe[he]=!0,fe[B]=fe[T]=fe[Z]=!1;function $e(ye,ge,je,Le,ke,Ie){var De,Ue=ge&R,Ke=ge&A,we=ge&I;if(je&&(De=ke?je(ye,Le,ke,Ie):je(ye)),De!==void 0)return De;if(!v(ye))return ye;var Fe=b(ye);if(Fe){if(De=m(ye),!Ue)return i(ye,De)}else{var Re=p(ye),Ae=Re==T||Re==P;if(j(ye))return o(ye,Ue);if(Re==z||Re==$||Ae&&!ke){if(De=Ke||Ae?{}:x(ye),!Ue)return Ke?u(ye,a(De,ye)):l(ye,s(De,ye))}else{if(!fe[Re])return ke?ye:{};De=w(ye,Re,Ue)}}Ie||(Ie=new e);var rt=Ie.get(ye);if(rt)return rt;Ie.set(ye,De),S(ye)?ye.forEach(function(be){De.add($e(be,ge,je,be,ye,Ie))}):k(ye)&&ye.forEach(function(be,Te){De.set(Te,$e(be,ge,je,Te,ye,Ie))});var We=we?Ke?f:d:Ke?_:C,se=Fe?void 0:We(ye);return t(se||ye,function(be,Te){se&&(Te=be,be=ye[Te]),n(De,Te,$e(be,ge,je,Te,ye,Ie))}),De}return kv=$e,kv}var jv,WM;function khe(){if(WM)return jv;WM=1;var e=yF(),t=4;function n(s){return e(s,t)}return jv=n,jv}var Nv,HM;function RS(){if(HM)return Nv;HM=1;function e(t){return function(){return t}}return Nv=e,Nv}var Sv,zM;function jhe(){if(zM)return Sv;zM=1;function e(t){return function(n,s,a){for(var o=-1,i=Object(n),l=a(n),u=l.length;u--;){var d=l[t?u:++o];if(s(i[d],d,i)===!1)break}return n}}return Sv=e,Sv}var Cv,VM;function MS(){if(VM)return Cv;VM=1;var e=jhe(),t=e();return Cv=t,Cv}var _v,GM;function $S(){if(GM)return _v;GM=1;var e=MS(),t=uo();function n(s,a){return s&&e(s,a,t)}return _v=n,_v}var Ev,KM;function Nhe(){if(KM)return Ev;KM=1;var e=pa();function t(n,s){return function(a,o){if(a==null)return a;if(!e(a))return n(a,o);for(var i=a.length,l=s?i:-1,u=Object(a);(s?l--:++l<i)&&o(u[l],l,u)!==!1;);return a}}return Ev=t,Ev}var Tv,YM;function Um(){if(YM)return Tv;YM=1;var e=$S(),t=Nhe(),n=t(e);return Tv=n,Tv}var Av,XM;function bi(){if(XM)return Av;XM=1;function e(t){return t}return Av=e,Av}var Rv,ZM;function wF(){if(ZM)return Rv;ZM=1;var e=bi();function t(n){return typeof n=="function"?n:e}return Rv=t,Rv}var Mv,JM;function xF(){if(JM)return Mv;JM=1;var e=NS(),t=Um(),n=wF(),s=Yt();function a(o,i){var l=s(o)?e:t;return l(o,n(i))}return Mv=a,Mv}var $v,QM;function vF(){return QM||(QM=1,$v=xF()),$v}var Lv,e$;function She(){if(e$)return Lv;e$=1;var e=Um();function t(n,s){var a=[];return e(n,function(o,i,l){s(o,i,l)&&a.push(o)}),a}return Lv=t,Lv}var Iv,t$;function Che(){if(t$)return Iv;t$=1;var e="__lodash_hash_undefined__";function t(n){return this.__data__.set(n,e),this}return Iv=t,Iv}var Ov,n$;function _he(){if(n$)return Ov;n$=1;function e(t){return this.__data__.has(t)}return Ov=e,Ov}var Pv,s$;function bF(){if(s$)return Pv;s$=1;var e=jS(),t=Che(),n=_he();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,Pv=s,Pv}var Dv,r$;function Ehe(){if(r$)return Dv;r$=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 Dv=e,Dv}var Fv,a$;function kF(){if(a$)return Fv;a$=1;function e(t,n){return t.has(n)}return Fv=e,Fv}var Bv,o$;function jF(){if(o$)return Bv;o$=1;var e=bF(),t=Ehe(),n=kF(),s=1,a=2;function o(i,l,u,d,f,p){var m=u&s,w=i.length,x=l.length;if(w!=x&&!(m&&x>w))return!1;var b=p.get(i),j=p.get(l);if(b&&j)return b==l&&j==i;var k=-1,v=!0,S=u&a?new e:void 0;for(p.set(i,l),p.set(l,i);++k<w;){var C=i[k],_=l[k];if(d)var R=m?d(_,C,k,l,i,p):d(C,_,k,i,l,p);if(R!==void 0){if(R)continue;v=!1;break}if(S){if(!t(l,function(A,I){if(!n(S,I)&&(C===A||f(C,A,u,d,p)))return S.push(I)})){v=!1;break}}else if(!(C===_||f(C,_,u,d,p))){v=!1;break}}return p.delete(i),p.delete(l),v}return Bv=o,Bv}var qv,i$;function The(){if(i$)return qv;i$=1;function e(t){var n=-1,s=Array(t.size);return t.forEach(function(a,o){s[++n]=[o,a]}),s}return qv=e,qv}var Uv,l$;function LS(){if(l$)return Uv;l$=1;function e(t){var n=-1,s=Array(t.size);return t.forEach(function(a){s[++n]=a}),s}return Uv=e,Uv}var Wv,c$;function Ahe(){if(c$)return Wv;c$=1;var e=uc(),t=fF(),n=cc(),s=jF(),a=The(),o=LS(),i=1,l=2,u="[object Boolean]",d="[object Date]",f="[object Error]",p="[object Map]",m="[object Number]",w="[object RegExp]",x="[object Set]",b="[object String]",j="[object Symbol]",k="[object ArrayBuffer]",v="[object DataView]",S=e?e.prototype:void 0,C=S?S.valueOf:void 0;function _(R,A,I,$,U,F,M){switch(I){case v:if(R.byteLength!=A.byteLength||R.byteOffset!=A.byteOffset)return!1;R=R.buffer,A=A.buffer;case k:return!(R.byteLength!=A.byteLength||!F(new t(R),new t(A)));case u:case d:case m:return n(+R,+A);case f:return R.name==A.name&&R.message==A.message;case w:case b:return R==A+"";case p:var B=a;case x:var T=$&i;if(B||(B=o),R.size!=A.size&&!T)return!1;var P=M.get(R);if(P)return P==A;$|=l,M.set(R,A);var q=s(B(R),B(A),$,U,F,M);return M.delete(R),q;case j:if(C)return C.call(R)==C.call(A)}return!1}return Wv=_,Wv}var Hv,u$;function Rhe(){if(u$)return Hv;u$=1;var e=dF(),t=1,n=Object.prototype,s=n.hasOwnProperty;function a(o,i,l,u,d,f){var p=l&t,m=e(o),w=m.length,x=e(i),b=x.length;if(w!=b&&!p)return!1;for(var j=w;j--;){var k=m[j];if(!(p?k in i:s.call(i,k)))return!1}var v=f.get(o),S=f.get(i);if(v&&S)return v==i&&S==o;var C=!0;f.set(o,i),f.set(i,o);for(var _=p;++j<w;){k=m[j];var R=o[k],A=i[k];if(u)var I=p?u(A,R,k,i,o,f):u(R,A,k,o,i,f);if(!(I===void 0?R===A||d(R,A,l,u,f):I)){C=!1;break}_||(_=k=="constructor")}if(C&&!_){var $=o.constructor,U=i.constructor;$!=U&&"constructor"in o&&"constructor"in i&&!(typeof $=="function"&&$ instanceof $&&typeof U=="function"&&U instanceof U)&&(C=!1)}return f.delete(o),f.delete(i),C}return Hv=a,Hv}var zv,d$;function Mhe(){if(d$)return zv;d$=1;var e=Im(),t=jF(),n=Ahe(),s=Rhe(),a=hc(),o=Yt(),i=dc(),l=Td(),u=1,d="[object Arguments]",f="[object Array]",p="[object Object]",m=Object.prototype,w=m.hasOwnProperty;function x(b,j,k,v,S,C){var _=o(b),R=o(j),A=_?f:a(b),I=R?f:a(j);A=A==d?p:A,I=I==d?p:I;var $=A==p,U=I==p,F=A==I;if(F&&i(b)){if(!i(j))return!1;_=!0,$=!1}if(F&&!$)return C||(C=new e),_||l(b)?t(b,j,k,v,S,C):n(b,j,A,k,v,S,C);if(!(k&u)){var M=$&&w.call(b,"__wrapped__"),B=U&&w.call(j,"__wrapped__");if(M||B){var T=M?b.value():b,P=B?j.value():j;return C||(C=new e),S(T,P,k,v,C)}}return F?(C||(C=new e),s(b,j,k,v,S,C)):!1}return zv=x,zv}var Vv,h$;function NF(){if(h$)return Vv;h$=1;var e=Mhe(),t=Cr();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 Vv=n,Vv}var Gv,f$;function $he(){if(f$)return Gv;f$=1;var e=Im(),t=NF(),n=1,s=2;function a(o,i,l,u){var d=l.length,f=d,p=!u;if(o==null)return!f;for(o=Object(o);d--;){var m=l[d];if(p&&m[2]?m[1]!==o[m[0]]:!(m[0]in o))return!1}for(;++d<f;){m=l[d];var w=m[0],x=o[w],b=m[1];if(p&&m[2]){if(x===void 0&&!(w in o))return!1}else{var j=new e;if(u)var k=u(x,b,w,o,i,j);if(!(k===void 0?t(b,x,n|s,u,j):k))return!1}}return!0}return Gv=a,Gv}var Kv,p$;function SF(){if(p$)return Kv;p$=1;var e=Ns();function t(n){return n===n&&!e(n)}return Kv=t,Kv}var Yv,m$;function Lhe(){if(m$)return Yv;m$=1;var e=SF(),t=uo();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 Yv=n,Yv}var Xv,g$;function CF(){if(g$)return Xv;g$=1;function e(t,n){return function(s){return s==null?!1:s[t]===n&&(n!==void 0||t in Object(s))}}return Xv=e,Xv}var Zv,y$;function Ihe(){if(y$)return Zv;y$=1;var e=$he(),t=Lhe(),n=CF();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 Zv=s,Zv}var Jv,w$;function fc(){if(w$)return Jv;w$=1;var e=wi(),t=Cr(),n="[object Symbol]";function s(a){return typeof a=="symbol"||t(a)&&e(a)==n}return Jv=s,Jv}var Qv,x$;function IS(){if(x$)return Qv;x$=1;var e=Yt(),t=fc(),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 Qv=a,Qv}var eb,v$;function Ohe(){if(v$)return eb;v$=1;var e=jS(),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 d=s.apply(this,i);return o.cache=u.set(l,d)||u,d};return o.cache=new(n.Cache||e),o}return n.Cache=e,eb=n,eb}var tb,b$;function Phe(){if(b$)return tb;b$=1;var e=Ohe(),t=500;function n(s){var a=e(s,function(i){return o.size===t&&o.clear(),i}),o=a.cache;return a}return tb=n,tb}var nb,k$;function Dhe(){if(k$)return nb;k$=1;var e=Phe(),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,d){o.push(u?d.replace(n,"$1"):l||i)}),o});return nb=s,nb}var sb,j$;function Wm(){if(j$)return sb;j$=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 sb=e,sb}var rb,N$;function Fhe(){if(N$)return rb;N$=1;var e=uc(),t=Wm(),n=Yt(),s=fc(),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 rb=i,rb}var ab,S$;function _F(){if(S$)return ab;S$=1;var e=Fhe();function t(n){return n==null?"":e(n)}return ab=t,ab}var ob,C$;function Hm(){if(C$)return ob;C$=1;var e=Yt(),t=IS(),n=Dhe(),s=_F();function a(o,i){return e(o)?o:t(o,i)?[o]:n(s(o))}return ob=a,ob}var ib,_$;function Ad(){if(_$)return ib;_$=1;var e=fc();function t(n){if(typeof n=="string"||e(n))return n;var s=n+"";return s=="0"&&1/n==-1/0?"-0":s}return ib=t,ib}var lb,E$;function zm(){if(E$)return lb;E$=1;var e=Hm(),t=Ad();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 lb=n,lb}var cb,T$;function Bhe(){if(T$)return cb;T$=1;var e=zm();function t(n,s,a){var o=n==null?void 0:e(n,s);return o===void 0?a:o}return cb=t,cb}var ub,A$;function qhe(){if(A$)return ub;A$=1;function e(t,n){return t!=null&&n in Object(t)}return ub=e,ub}var db,R$;function EF(){if(R$)return db;R$=1;var e=Hm(),t=Ed(),n=Yt(),s=Dm(),a=SS(),o=Ad();function i(l,u,d){u=e(u,l);for(var f=-1,p=u.length,m=!1;++f<p;){var w=o(u[f]);if(!(m=l!=null&&d(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 db=i,db}var hb,M$;function TF(){if(M$)return hb;M$=1;var e=qhe(),t=EF();function n(s,a){return s!=null&&t(s,a,e)}return hb=n,hb}var fb,$$;function Uhe(){if($$)return fb;$$=1;var e=NF(),t=Bhe(),n=TF(),s=IS(),a=SF(),o=CF(),i=Ad(),l=1,u=2;function d(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 fb=d,fb}var pb,L$;function AF(){if(L$)return pb;L$=1;function e(t){return function(n){return n==null?void 0:n[t]}}return pb=e,pb}var mb,I$;function Whe(){if(I$)return mb;I$=1;var e=zm();function t(n){return function(s){return e(s,n)}}return mb=t,mb}var gb,O$;function Hhe(){if(O$)return gb;O$=1;var e=AF(),t=Whe(),n=IS(),s=Ad();function a(o){return n(o)?e(s(o)):t(o)}return gb=a,gb}var yb,P$;function ma(){if(P$)return yb;P$=1;var e=Ihe(),t=Uhe(),n=bi(),s=Yt(),a=Hhe();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 yb=o,yb}var wb,D$;function RF(){if(D$)return wb;D$=1;var e=iF(),t=She(),n=ma(),s=Yt();function a(o,i){var l=s(o)?e:t;return l(o,n(i,3))}return wb=a,wb}var xb,F$;function zhe(){if(F$)return xb;F$=1;var e=Object.prototype,t=e.hasOwnProperty;function n(s,a){return s!=null&&t.call(s,a)}return xb=n,xb}var vb,B$;function MF(){if(B$)return vb;B$=1;var e=zhe(),t=EF();function n(s,a){return s!=null&&t(s,a,e)}return vb=n,vb}var bb,q$;function Vhe(){if(q$)return bb;q$=1;var e=_S(),t=hc(),n=Ed(),s=Yt(),a=pa(),o=dc(),i=Bm(),l=Td(),u="[object Map]",d="[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 x=t(w);if(x==u||x==d)return!w.size;if(i(w))return!e(w).length;for(var b in w)if(p.call(w,b))return!1;return!0}return bb=m,bb}var kb,U$;function $F(){if(U$)return kb;U$=1;function e(t){return t===void 0}return kb=e,kb}var jb,W$;function LF(){if(W$)return jb;W$=1;var e=Um(),t=pa();function n(s,a){var o=-1,i=t(s)?Array(s.length):[];return e(s,function(l,u,d){i[++o]=a(l,u,d)}),i}return jb=n,jb}var Nb,H$;function IF(){if(H$)return Nb;H$=1;var e=Wm(),t=ma(),n=LF(),s=Yt();function a(o,i){var l=s(o)?e:n;return l(o,t(i,3))}return Nb=a,Nb}var Sb,z$;function Ghe(){if(z$)return Sb;z$=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 Sb=e,Sb}var Cb,V$;function Khe(){if(V$)return Cb;V$=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 Cb=e,Cb}var _b,G$;function OF(){if(G$)return _b;G$=1;var e=Ghe(),t=Um(),n=ma(),s=Khe(),a=Yt();function o(i,l,u){var d=a(i)?e:s,f=arguments.length<3;return d(i,n(l,4),u,f,t)}return _b=o,_b}var Eb,K$;function Yhe(){if(K$)return Eb;K$=1;var e=wi(),t=Yt(),n=Cr(),s="[object String]";function a(o){return typeof o=="string"||!t(o)&&n(o)&&e(o)==s}return Eb=a,Eb}var Tb,Y$;function Xhe(){if(Y$)return Tb;Y$=1;var e=AF(),t=e("length");return Tb=t,Tb}var Ab,X$;function Zhe(){if(X$)return Ab;X$=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(d){return l.test(d)}return Ab=u,Ab}var Rb,Z$;function Jhe(){if(Z$)return Rb;Z$=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]",d="(?:"+l+"|"+u+")",f="[^"+e+"]",p="(?:\\ud83c[\\udde6-\\uddff]){2}",m="[\\ud800-\\udbff][\\udc00-\\udfff]",w="\\u200d",x=d+"?",b="["+o+"]?",j="(?:"+w+"(?:"+[f,p,m].join("|")+")"+b+x+")*",k=b+x+j,v="(?:"+[f+l+"?",l,p,m,i].join("|")+")",S=RegExp(u+"(?="+u+")|"+v+k,"g");function C(_){for(var R=S.lastIndex=0;S.test(_);)++R;return R}return Rb=C,Rb}var Mb,J$;function Qhe(){if(J$)return Mb;J$=1;var e=Xhe(),t=Zhe(),n=Jhe();function s(a){return t(a)?n(a):e(a)}return Mb=s,Mb}var $b,Q$;function efe(){if(Q$)return $b;Q$=1;var e=_S(),t=hc(),n=pa(),s=Yhe(),a=Qhe(),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 d=t(u);return d==o||d==i?u.size:e(u).length}return $b=l,$b}var Lb,eL;function tfe(){if(eL)return Lb;eL=1;var e=NS(),t=mF(),n=$S(),s=ma(),a=qm(),o=Yt(),i=dc(),l=Cd(),u=Ns(),d=Td();function f(p,m,w){var x=o(p),b=x||i(p)||d(p);if(m=s(m,4),w==null){var j=p&&p.constructor;b?w=x?new j:[]:u(p)?w=l(j)?t(a(p)):{}:w={}}return(b?e:n)(p,function(k,v,S){return m(w,k,v,S)}),w}return Lb=f,Lb}var Ib,tL;function nfe(){if(tL)return Ib;tL=1;var e=uc(),t=Ed(),n=Yt(),s=e?e.isConcatSpreadable:void 0;function a(o){return n(o)||t(o)||!!(s&&o&&o[s])}return Ib=a,Ib}var Ob,nL;function OS(){if(nL)return Ob;nL=1;var e=TS(),t=nfe();function n(s,a,o,i,l){var u=-1,d=s.length;for(o||(o=t),l||(l=[]);++u<d;){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 Ob=n,Ob}var Pb,sL;function sfe(){if(sL)return Pb;sL=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 Pb=e,Pb}var Db,rL;function PF(){if(rL)return Db;rL=1;var e=sfe(),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),d=Array(u);++l<u;)d[l]=i[a+l];l=-1;for(var f=Array(a+1);++l<a;)f[l]=i[l];return f[a]=o(d),e(s,this,f)}}return Db=n,Db}var Fb,aL;function rfe(){if(aL)return Fb;aL=1;var e=RS(),t=nF(),n=bi(),s=t?function(a,o){return t(a,"toString",{configurable:!0,enumerable:!1,value:e(o),writable:!0})}:n;return Fb=s,Fb}var Bb,oL;function afe(){if(oL)return Bb;oL=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 Bb=s,Bb}var qb,iL;function DF(){if(iL)return qb;iL=1;var e=rfe(),t=afe(),n=t(e);return qb=n,qb}var Ub,lL;function Vm(){if(lL)return Ub;lL=1;var e=bi(),t=PF(),n=DF();function s(a,o){return n(t(a,o,e),a+"")}return Ub=s,Ub}var Wb,cL;function FF(){if(cL)return Wb;cL=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 Wb=e,Wb}var Hb,uL;function ofe(){if(uL)return Hb;uL=1;function e(t){return t!==t}return Hb=e,Hb}var zb,dL;function ife(){if(dL)return zb;dL=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 zb=e,zb}var Vb,hL;function lfe(){if(hL)return Vb;hL=1;var e=FF(),t=ofe(),n=ife();function s(a,o,i){return o===o?n(a,o,i):e(a,t,i)}return Vb=s,Vb}var Gb,fL;function cfe(){if(fL)return Gb;fL=1;var e=lfe();function t(n,s){var a=n==null?0:n.length;return!!a&&e(n,s,0)>-1}return Gb=t,Gb}var Kb,pL;function ufe(){if(pL)return Kb;pL=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 Kb=e,Kb}var Yb,mL;function dfe(){if(mL)return Yb;mL=1;function e(){}return Yb=e,Yb}var Xb,gL;function hfe(){if(gL)return Xb;gL=1;var e=hF(),t=dfe(),n=LS(),s=1/0,a=e&&1/n(new e([,-0]))[1]==s?function(o){return new e(o)}:t;return Xb=a,Xb}var Zb,yL;function ffe(){if(yL)return Zb;yL=1;var e=bF(),t=cfe(),n=ufe(),s=kF(),a=hfe(),o=LS(),i=200;function l(u,d,f){var p=-1,m=t,w=u.length,x=!0,b=[],j=b;if(f)x=!1,m=n;else if(w>=i){var k=d?null:a(u);if(k)return o(k);x=!1,m=s,j=new e}else j=d?[]:b;e:for(;++p<w;){var v=u[p],S=d?d(v):v;if(v=f||v!==0?v:0,x&&S===S){for(var C=j.length;C--;)if(j[C]===S)continue e;d&&j.push(S),b.push(v)}else m(j,S,f)||(j!==b&&j.push(S),b.push(v))}return b}return Zb=l,Zb}var Jb,wL;function BF(){if(wL)return Jb;wL=1;var e=pa(),t=Cr();function n(s){return t(s)&&e(s)}return Jb=n,Jb}var Qb,xL;function pfe(){if(xL)return Qb;xL=1;var e=OS(),t=Vm(),n=ffe(),s=BF(),a=t(function(o){return n(e(o,1,s,!0))});return Qb=a,Qb}var ek,vL;function mfe(){if(vL)return ek;vL=1;var e=Wm();function t(n,s){return e(s,function(a){return n[a]})}return ek=t,ek}var tk,bL;function qF(){if(bL)return tk;bL=1;var e=mfe(),t=uo();function n(s){return s==null?[]:e(s,t(s))}return tk=n,tk}var nk,kL;function Ss(){if(kL)return nk;kL=1;var e;if(typeof bS=="function")try{e={clone:khe(),constant:RS(),each:vF(),filter:RF(),has:MF(),isArray:Yt(),isEmpty:Vhe(),isFunction:Cd(),isUndefined:$F(),keys:uo(),map:IF(),reduce:OF(),size:efe(),transform:tfe(),union:pfe(),values:qF()}}catch{}return e||(e=window._),nk=e,nk}var sk,jL;function PS(){if(jL)return sk;jL=1;var e=Ss();sk=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(x){m.length>1?w.setNode(x,p):w.setNode(x)}),this},a.prototype.setNode=function(f,p){return e.has(this._nodes,f)?(arguments.length>1&&(this._nodes[f]=p),this):(this._nodes[f]=arguments.length>1?p:this._defaultNodeLabelFn(f),this._isCompound&&(this._parent[f]=n,this._children[f]={},this._children[n][f]=!0),this._in[f]={},this._preds[f]={},this._out[f]={},this._sucs[f]={},++this._nodeCount,this)},a.prototype.node=function(f){return this._nodes[f]},a.prototype.hasNode=function(f){return e.has(this._nodes,f)},a.prototype.removeNode=function(f){var p=this;if(e.has(this._nodes,f)){var m=function(w){p.removeEdge(p._edgeObjs[w])};delete this._nodes[f],this._isCompound&&(this._removeFromParentsChildList(f),delete this._parent[f],e.each(this.children(f),function(w){p.setParent(w)}),delete this._children[f]),e.each(e.keys(this._in[f]),m),delete this._in[f],delete this._preds[f],e.each(e.keys(this._out[f]),m),delete this._out[f],delete this._sucs[f],--this._nodeCount}return this},a.prototype.setParent=function(f,p){if(!this._isCompound)throw new Error("Cannot set parent in a non-compound graph");if(e.isUndefined(p))p=n;else{p+="";for(var m=p;!e.isUndefined(m);m=this.parent(m))if(m===f)throw new Error("Setting "+p+" as parent of "+f+" would create a cycle");this.setNode(p)}return this.setNode(f),this._removeFromParentsChildList(f),this._parent[f]=p,this._children[p][f]=!0,this},a.prototype._removeFromParentsChildList=function(f){delete this._children[this._parent[f]][f]},a.prototype.parent=function(f){if(this._isCompound){var p=this._parent[f];if(p!==n)return p}},a.prototype.children=function(f){if(e.isUndefined(f)&&(f=n),this._isCompound){var p=this._children[f];if(p)return e.keys(p)}else{if(f===n)return this.nodes();if(this.hasNode(f))return[]}},a.prototype.predecessors=function(f){var p=this._preds[f];if(p)return e.keys(p)},a.prototype.successors=function(f){var p=this._sucs[f];if(p)return e.keys(p)},a.prototype.neighbors=function(f){var p=this.predecessors(f);if(p)return e.union(p,this.successors(f))},a.prototype.isLeaf=function(f){var p;return this.isDirected()?p=this.successors(f):p=this.neighbors(f),p.length===0},a.prototype.filterNodes=function(f){var p=new this.constructor({directed:this._isDirected,multigraph:this._isMultigraph,compound:this._isCompound});p.setGraph(this.graph());var m=this;e.each(this._nodes,function(b,j){f(j)&&p.setNode(j,b)}),e.each(this._edgeObjs,function(b){p.hasNode(b.v)&&p.hasNode(b.w)&&p.setEdge(b,m.edge(b))});var w={};function x(b){var j=m.parent(b);return j===void 0||p.hasNode(j)?(w[b]=j,j):j in w?w[j]:x(j)}return this._isCompound&&e.each(p.nodes(),function(b){p.setParent(b,x(b))}),p},a.prototype.setDefaultEdgeLabel=function(f){return e.isFunction(f)||(f=e.constant(f)),this._defaultEdgeLabelFn=f,this},a.prototype.edgeCount=function(){return this._edgeCount},a.prototype.edges=function(){return e.values(this._edgeObjs)},a.prototype.setPath=function(f,p){var m=this,w=arguments;return e.reduce(f,function(x,b){return w.length>1?m.setEdge(x,b,p):m.setEdge(x,b),b}),this},a.prototype.setEdge=function(){var f,p,m,w,x=!1,b=arguments[0];typeof b=="object"&&b!==null&&"v"in b?(f=b.v,p=b.w,m=b.name,arguments.length===2&&(w=arguments[1],x=!0)):(f=b,p=arguments[1],m=arguments[3],arguments.length>2&&(w=arguments[2],x=!0)),f=""+f,p=""+p,e.isUndefined(m)||(m=""+m);var j=l(this._isDirected,f,p,m);if(e.has(this._edgeLabels,j))return x&&(this._edgeLabels[j]=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[j]=x?w:this._defaultEdgeLabelFn(f,p,m);var k=u(this._isDirected,f,p,m);return f=k.v,p=k.w,Object.freeze(k),this._edgeObjs[j]=k,o(this._preds[p],f),o(this._sucs[f],p),this._in[p][j]=k,this._out[f][j]=k,this._edgeCount++,this},a.prototype.edge=function(f,p,m){var w=arguments.length===1?d(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?d(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?d(this._isDirected,arguments[0]):l(this._isDirected,f,p,m),x=this._edgeObjs[w];return x&&(f=x.v,p=x.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(x){return x.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(x){return x.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 x=""+p,b=""+m;if(!f&&x>b){var j=x;x=b,b=j}return x+s+b+s+(e.isUndefined(w)?t:w)}function u(f,p,m,w){var x=""+p,b=""+m;if(!f&&x>b){var j=x;x=b,b=j}var k={v:x,w:b};return w&&(k.name=w),k}function d(f,p){return l(f,p.v,p.w,p.name)}return sk}var rk,NL;function gfe(){return NL||(NL=1,rk="2.1.8"),rk}var ak,SL;function yfe(){return SL||(SL=1,ak={Graph:PS(),version:gfe()}),ak}var ok,CL;function wfe(){if(CL)return ok;CL=1;var e=Ss(),t=PS();ok={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),d=i.parent(l),f={v:l};return e.isUndefined(u)||(f.value=u),e.isUndefined(d)||(f.parent=d),f})}function a(i){return e.map(i.edges(),function(l){var u=i.edge(l),d={v:l.v,w:l.w};return e.isUndefined(l.name)||(d.name=l.name),e.isUndefined(u)||(d.value=u),d})}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 ok}var ik,_L;function xfe(){if(_L)return ik;_L=1;var e=Ss();ik=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 ik}var lk,EL;function UF(){if(EL)return lk;EL=1;var e=Ss();lk=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},lk}var ck,TL;function WF(){if(TL)return ck;TL=1;var e=Ss(),t=UF();ck=s;var n=e.constant(1);function s(o,i,l,u){return a(o,String(i),l||n,u||function(d){return o.outEdges(d)})}function a(o,i,l,u){var d={},f=new t,p,m,w=function(x){var b=x.v!==p?x.v:x.w,j=d[b],k=l(x),v=m.distance+k;if(k<0)throw new Error("dijkstra does not allow negative edge weights. Bad edge: "+x+" Weight: "+k);v<j.distance&&(j.distance=v,j.predecessor=p,f.decrease(b,v))};for(o.nodes().forEach(function(x){var b=x===i?0:Number.POSITIVE_INFINITY;d[x]={distance:b},f.add(x,b)});f.size()>0&&(p=f.removeMin(),m=d[p],m.distance!==Number.POSITIVE_INFINITY);)u(p).forEach(w);return d}return ck}var uk,AL;function vfe(){if(AL)return uk;AL=1;var e=WF(),t=Ss();uk=n;function n(s,a,o){return t.transform(s.nodes(),function(i,l){i[l]=e(s,l,a,o)},{})}return uk}var dk,RL;function HF(){if(RL)return dk;RL=1;var e=Ss();dk=t;function t(n){var s=0,a=[],o={},i=[];function l(u){var d=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&&(d.lowlink=Math.min(d.lowlink,o[m].index)):(l(m),d.lowlink=Math.min(d.lowlink,o[m].lowlink))}),d.lowlink===d.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 dk}var hk,ML;function bfe(){if(ML)return hk;ML=1;var e=Ss(),t=HF();hk=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 hk}var fk,$L;function kfe(){if($L)return fk;$L=1;var e=Ss();fk=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(d){l[d]={},l[d][d]={distance:0},u.forEach(function(f){d!==f&&(l[d][f]={distance:Number.POSITIVE_INFINITY})}),i(d).forEach(function(f){var p=f.v===d?f.w:f.v,m=o(f);l[d][p]={distance:m,predecessor:d}})}),u.forEach(function(d){var f=l[d];u.forEach(function(p){var m=l[p];u.forEach(function(w){var x=m[d],b=f[w],j=m[w],k=x.distance+b.distance;k<j.distance&&(j.distance=k,j.predecessor=b.predecessor)})})}),l}return fk}var pk,LL;function zF(){if(LL)return pk;LL=1;var e=Ss();pk=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,pk}var mk,IL;function jfe(){if(IL)return mk;IL=1;var e=zF();mk=t;function t(n){try{e(n)}catch(s){if(s instanceof e.CycleException)return!1;throw s}return!0}return mk}var gk,OL;function VF(){if(OL)return gk;OL=1;var e=Ss();gk=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(d){if(!s.hasNode(d))throw new Error("Graph does not have node: "+d);n(s,d,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(d){n(s,d,o,i,l,u)}),o&&u.push(a))}return gk}var yk,PL;function Nfe(){if(PL)return yk;PL=1;var e=VF();yk=t;function t(n,s){return e(n,s,"post")}return yk}var wk,DL;function Sfe(){if(DL)return wk;DL=1;var e=VF();wk=t;function t(n,s){return e(n,s,"pre")}return wk}var xk,FL;function Cfe(){if(FL)return xk;FL=1;var e=Ss(),t=PS(),n=UF();xk=s;function s(a,o){var i=new t,l={},u=new n,d;function f(m){var w=m.v===d?m.w:m.v,x=u.priority(w);if(x!==void 0){var b=o(m);b<x&&(l[w]=d,u.decrease(w,b))}}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(d=u.removeMin(),e.has(l,d))i.setEdge(d,l[d]);else{if(p)throw new Error("Input graph is not connected: "+a);p=!0}a.nodeEdges(d).forEach(f)}return i}return xk}var vk,BL;function _fe(){return BL||(BL=1,vk={components:xfe(),dijkstra:WF(),dijkstraAll:vfe(),findCycles:bfe(),floydWarshall:kfe(),isAcyclic:jfe(),postorder:Nfe(),preorder:Sfe(),prim:Cfe(),tarjan:HF(),topsort:zF()}),vk}var bk,qL;function Efe(){if(qL)return bk;qL=1;var e=yfe();return bk={Graph:e.Graph,json:wfe(),alg:_fe(),version:e.version},bk}var kk,UL;function Js(){if(UL)return kk;UL=1;var e;if(typeof bS=="function")try{e=Efe()}catch{}return e||(e=window.graphlib),kk=e,kk}var jk,WL;function Tfe(){if(WL)return jk;WL=1;var e=yF(),t=1,n=4;function s(a){return e(a,t|n)}return jk=s,jk}var Nk,HL;function Gm(){if(HL)return Nk;HL=1;var e=cc(),t=pa(),n=Dm(),s=Ns();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 Nk=a,Nk}var Sk,zL;function Afe(){if(zL)return Sk;zL=1;var e=Vm(),t=cc(),n=Gm(),s=vi(),a=Object.prototype,o=a.hasOwnProperty,i=e(function(l,u){l=Object(l);var d=-1,f=u.length,p=f>2?u[2]:void 0;for(p&&n(u[0],u[1],p)&&(f=1);++d<f;)for(var m=u[d],w=s(m),x=-1,b=w.length;++x<b;){var j=w[x],k=l[j];(k===void 0||t(k,a[j])&&!o.call(l,j))&&(l[j]=m[j])}return l});return Sk=i,Sk}var Ck,VL;function Rfe(){if(VL)return Ck;VL=1;var e=ma(),t=pa(),n=uo();function s(a){return function(o,i,l){var u=Object(o);if(!t(o)){var d=e(i,3);o=n(o),i=function(p){return d(u[p],p,u)}}var f=a(o,i,l);return f>-1?u[d?o[f]:f]:void 0}}return Ck=s,Ck}var _k,GL;function Mfe(){if(GL)return _k;GL=1;var e=/\s/;function t(n){for(var s=n.length;s--&&e.test(n.charAt(s)););return s}return _k=t,_k}var Ek,KL;function $fe(){if(KL)return Ek;KL=1;var e=Mfe(),t=/^\s+/;function n(s){return s&&s.slice(0,e(s)+1).replace(t,"")}return Ek=n,Ek}var Tk,YL;function Lfe(){if(YL)return Tk;YL=1;var e=$fe(),t=Ns(),n=fc(),s=NaN,a=/^[-+]0x[0-9a-f]+$/i,o=/^0b[01]+$/i,i=/^0o[0-7]+$/i,l=parseInt;function u(d){if(typeof d=="number")return d;if(n(d))return s;if(t(d)){var f=typeof d.valueOf=="function"?d.valueOf():d;d=t(f)?f+"":f}if(typeof d!="string")return d===0?d:+d;d=e(d);var p=o.test(d);return p||i.test(d)?l(d.slice(2),p?2:8):a.test(d)?s:+d}return Tk=u,Tk}var Ak,XL;function GF(){if(XL)return Ak;XL=1;var e=Lfe(),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 Ak=s,Ak}var Rk,ZL;function Ife(){if(ZL)return Rk;ZL=1;var e=GF();function t(n){var s=e(n),a=s%1;return s===s?a?s-a:s:0}return Rk=t,Rk}var Mk,JL;function Ofe(){if(JL)return Mk;JL=1;var e=FF(),t=ma(),n=Ife(),s=Math.max;function a(o,i,l){var u=o==null?0:o.length;if(!u)return-1;var d=l==null?0:n(l);return d<0&&(d=s(u+d,0)),e(o,t(i,3),d)}return Mk=a,Mk}var $k,QL;function Pfe(){if(QL)return $k;QL=1;var e=Rfe(),t=Ofe(),n=e(t);return $k=n,$k}var Lk,eI;function KF(){if(eI)return Lk;eI=1;var e=OS();function t(n){var s=n==null?0:n.length;return s?e(n,1):[]}return Lk=t,Lk}var Ik,tI;function Dfe(){if(tI)return Ik;tI=1;var e=MS(),t=wF(),n=vi();function s(a,o){return a==null?a:e(a,t(o),n)}return Ik=s,Ik}var Ok,nI;function Ffe(){if(nI)return Ok;nI=1;function e(t){var n=t==null?0:t.length;return n?t[n-1]:void 0}return Ok=e,Ok}var Pk,sI;function Bfe(){if(sI)return Pk;sI=1;var e=Om(),t=$S(),n=ma();function s(a,o){var i={};return o=n(o,3),t(a,function(l,u,d){e(i,u,o(l,u,d))}),i}return Pk=s,Pk}var Dk,rI;function DS(){if(rI)return Dk;rI=1;var e=fc();function t(n,s,a){for(var o=-1,i=n.length;++o<i;){var l=n[o],u=s(l);if(u!=null&&(d===void 0?u===u&&!e(u):a(u,d)))var d=u,f=l}return f}return Dk=t,Dk}var Fk,aI;function qfe(){if(aI)return Fk;aI=1;function e(t,n){return t>n}return Fk=e,Fk}var Bk,oI;function Ufe(){if(oI)return Bk;oI=1;var e=DS(),t=qfe(),n=bi();function s(a){return a&&a.length?e(a,n,t):void 0}return Bk=s,Bk}var qk,iI;function YF(){if(iI)return qk;iI=1;var e=Om(),t=cc();function n(s,a,o){(o!==void 0&&!t(s[a],o)||o===void 0&&!(a in s))&&e(s,a,o)}return qk=n,qk}var Uk,lI;function Wfe(){if(lI)return Uk;lI=1;var e=wi(),t=qm(),n=Cr(),s="[object Object]",a=Function.prototype,o=Object.prototype,i=a.toString,l=o.hasOwnProperty,u=i.call(Object);function d(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 Uk=d,Uk}var Wk,cI;function XF(){if(cI)return Wk;cI=1;function e(t,n){if(!(n==="constructor"&&typeof t[n]=="function")&&n!="__proto__")return t[n]}return Wk=e,Wk}var Hk,uI;function Hfe(){if(uI)return Hk;uI=1;var e=_d(),t=vi();function n(s){return e(s,t(s))}return Hk=n,Hk}var zk,dI;function zfe(){if(dI)return zk;dI=1;var e=YF(),t=aF(),n=pF(),s=oF(),a=gF(),o=Ed(),i=Yt(),l=BF(),u=dc(),d=Cd(),f=Ns(),p=Wfe(),m=Td(),w=XF(),x=Hfe();function b(j,k,v,S,C,_,R){var A=w(j,v),I=w(k,v),$=R.get(I);if($){e(j,v,$);return}var U=_?_(A,I,v+"",j,k,R):void 0,F=U===void 0;if(F){var M=i(I),B=!M&&u(I),T=!M&&!B&&m(I);U=I,M||B||T?i(A)?U=A:l(A)?U=s(A):B?(F=!1,U=t(I,!0)):T?(F=!1,U=n(I,!0)):U=[]:p(I)||o(I)?(U=A,o(A)?U=x(A):(!f(A)||d(A))&&(U=a(I))):F=!1}F&&(R.set(I,U),C(U,I,S,_,R),R.delete(I)),e(j,v,U)}return zk=b,zk}var Vk,hI;function Vfe(){if(hI)return Vk;hI=1;var e=Im(),t=YF(),n=MS(),s=zfe(),a=Ns(),o=vi(),i=XF();function l(u,d,f,p,m){u!==d&&n(d,function(w,x){if(m||(m=new e),a(w))s(u,d,x,f,l,p,m);else{var b=p?p(i(u,x),w,x+"",u,d,m):void 0;b===void 0&&(b=w),t(u,x,b)}},o)}return Vk=l,Vk}var Gk,fI;function Gfe(){if(fI)return Gk;fI=1;var e=Vm(),t=Gm();function n(s){return e(function(a,o){var i=-1,l=o.length,u=l>1?o[l-1]:void 0,d=l>2?o[2]:void 0;for(u=s.length>3&&typeof u=="function"?(l--,u):void 0,d&&t(o[0],o[1],d)&&(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 Gk=n,Gk}var Kk,pI;function Kfe(){if(pI)return Kk;pI=1;var e=Vfe(),t=Gfe(),n=t(function(s,a,o){e(s,a,o)});return Kk=n,Kk}var Yk,mI;function ZF(){if(mI)return Yk;mI=1;function e(t,n){return t<n}return Yk=e,Yk}var Xk,gI;function Yfe(){if(gI)return Xk;gI=1;var e=DS(),t=ZF(),n=bi();function s(a){return a&&a.length?e(a,n,t):void 0}return Xk=s,Xk}var Zk,yI;function Xfe(){if(yI)return Zk;yI=1;var e=DS(),t=ma(),n=ZF();function s(a,o){return a&&a.length?e(a,t(o,2),n):void 0}return Zk=s,Zk}var Jk,wI;function Zfe(){if(wI)return Jk;wI=1;var e=er(),t=function(){return e.Date.now()};return Jk=t,Jk}var Qk,xI;function Jfe(){if(xI)return Qk;xI=1;var e=Pm(),t=Hm(),n=Dm(),s=Ns(),a=Ad();function o(i,l,u,d){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 x=a(l[f]),b=u;if(x==="__proto__"||x==="constructor"||x==="prototype")return i;if(f!=m){var j=w[x];b=d?d(j,x,w):void 0,b===void 0&&(b=s(j)?j:n(l[f+1])?[]:{})}e(w,x,b),w=w[x]}return i}return Qk=o,Qk}var e0,vI;function Qfe(){if(vI)return e0;vI=1;var e=zm(),t=Jfe(),n=Hm();function s(a,o,i){for(var l=-1,u=o.length,d={};++l<u;){var f=o[l],p=e(a,f);i(p,f)&&t(d,n(f,a),p)}return d}return e0=s,e0}var t0,bI;function epe(){if(bI)return t0;bI=1;var e=Qfe(),t=TF();function n(s,a){return e(s,a,function(o,i){return t(s,i)})}return t0=n,t0}var n0,kI;function tpe(){if(kI)return n0;kI=1;var e=KF(),t=PF(),n=DF();function s(a){return n(t(a,void 0,e),a+"")}return n0=s,n0}var s0,jI;function npe(){if(jI)return s0;jI=1;var e=epe(),t=tpe(),n=t(function(s,a){return s==null?{}:e(s,a)});return s0=n,s0}var r0,NI;function spe(){if(NI)return r0;NI=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),d=Array(u);u--;)d[i?u:++l]=s,s+=o;return d}return r0=n,r0}var a0,SI;function rpe(){if(SI)return a0;SI=1;var e=spe(),t=Gm(),n=GF();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 a0=s,a0}var o0,CI;function ape(){if(CI)return o0;CI=1;var e=rpe(),t=e();return o0=t,o0}var i0,_I;function ope(){if(_I)return i0;_I=1;function e(t,n){var s=t.length;for(t.sort(n);s--;)t[s]=t[s].value;return t}return i0=e,i0}var l0,EI;function ipe(){if(EI)return l0;EI=1;var e=fc();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,d=s===null,f=s===s,p=e(s);if(!d&&!p&&!l&&n>s||l&&u&&f&&!d&&!p||o&&u&&f||!a&&f||!i)return 1;if(!o&&!l&&!p&&n<s||p&&a&&i&&!o&&!l||d&&a&&i||!u&&i||!f)return-1}return 0}return l0=t,l0}var c0,TI;function lpe(){if(TI)return c0;TI=1;var e=ipe();function t(n,s,a){for(var o=-1,i=n.criteria,l=s.criteria,u=i.length,d=a.length;++o<u;){var f=e(i[o],l[o]);if(f){if(o>=d)return f;var p=a[o];return f*(p=="desc"?-1:1)}}return n.index-s.index}return c0=t,c0}var u0,AI;function cpe(){if(AI)return u0;AI=1;var e=Wm(),t=zm(),n=ma(),s=LF(),a=ope(),o=Fm(),i=lpe(),l=bi(),u=Yt();function d(f,p,m){p.length?p=e(p,function(b){return u(b)?function(j){return t(j,b.length===1?b[0]:b)}:b}):p=[l];var w=-1;p=e(p,o(n));var x=s(f,function(b,j,k){var v=e(p,function(S){return S(b)});return{criteria:v,index:++w,value:b}});return a(x,function(b,j){return i(b,j,m)})}return u0=d,u0}var d0,RI;function upe(){if(RI)return d0;RI=1;var e=OS(),t=cpe(),n=Vm(),s=Gm(),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 d0=a,d0}var h0,MI;function dpe(){if(MI)return h0;MI=1;var e=_F(),t=0;function n(s){var a=++t;return e(s)+a}return h0=n,h0}var f0,$I;function hpe(){if($I)return f0;$I=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 f0=e,f0}var p0,LI;function fpe(){if(LI)return p0;LI=1;var e=Pm(),t=hpe();function n(s,a){return t(s||[],a||[],e)}return p0=n,p0}var m0,II;function Rt(){if(II)return m0;II=1;var e;if(typeof bS=="function")try{e={cloneDeep:Tfe(),constant:RS(),defaults:Afe(),each:vF(),filter:RF(),find:Pfe(),flatten:KF(),forEach:xF(),forIn:Dfe(),has:MF(),isUndefined:$F(),last:Ffe(),map:IF(),mapValues:Bfe(),max:Ufe(),merge:Kfe(),min:Yfe(),minBy:Xfe(),now:Zfe(),pick:npe(),range:ape(),reduce:OF(),sortBy:upe(),uniqueId:dpe(),values:qF(),zipObject:fpe()}}catch{}return e||(e=window._),m0=e,m0}var g0,OI;function ppe(){if(OI)return g0;OI=1,g0=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 g0}var y0,PI;function mpe(){if(PI)return y0;PI=1;var e=Rt(),t=Js().Graph,n=ppe();y0=a;var s=e.constant(1);function a(d,f){if(d.nodeCount()<=1)return[];var p=l(d,f||s),m=o(p.graph,p.buckets,p.zeroIdx);return e.flatten(e.map(m,function(w){return d.outEdges(w.v,w.w)}),!0)}function o(d,f,p){for(var m=[],w=f[f.length-1],x=f[0],b;d.nodeCount();){for(;b=x.dequeue();)i(d,f,p,b);for(;b=w.dequeue();)i(d,f,p,b);if(d.nodeCount()){for(var j=f.length-2;j>0;--j)if(b=f[j].dequeue(),b){m=m.concat(i(d,f,p,b,!0));break}}}return m}function i(d,f,p,m,w){var x=w?[]:void 0;return e.forEach(d.inEdges(m.v),function(b){var j=d.edge(b),k=d.node(b.v);w&&x.push({v:b.v,w:b.w}),k.out-=j,u(f,p,k)}),e.forEach(d.outEdges(m.v),function(b){var j=d.edge(b),k=b.w,v=d.node(k);v.in-=j,u(f,p,v)}),d.removeNode(m.v),x}function l(d,f){var p=new t,m=0,w=0;e.forEach(d.nodes(),function(j){p.setNode(j,{v:j,in:0,out:0})}),e.forEach(d.edges(),function(j){var k=p.edge(j.v,j.w)||0,v=f(j),S=k+v;p.setEdge(j.v,j.w,S),w=Math.max(w,p.node(j.v).out+=v),m=Math.max(m,p.node(j.w).in+=v)});var x=e.range(w+m+3).map(function(){return new n}),b=m+1;return e.forEach(p.nodes(),function(j){u(x,b,p.node(j))}),{graph:p,buckets:x,zeroIdx:b}}function u(d,f,p){p.out?p.in?d[p.out-p.in+f].enqueue(p):d[d.length-1].enqueue(p):d[0].enqueue(p)}return y0}var w0,DI;function gpe(){if(DI)return w0;DI=1;var e=Rt(),t=mpe();w0={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 d=o.edge(u);o.removeEdge(u),d.forwardName=u.name,d.reversed=!0,o.setEdge(u.w,u.v,d,e.uniqueId("rev"))});function l(u){return function(d){return u.edge(d).weight}}}function s(o){var i=[],l={},u={};function d(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):d(p.w)}),delete l[f])}return e.forEach(o.nodes(),d),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 w0}var x0,FI;function Un(){if(FI)return x0;FI=1;var e=Rt(),t=Js().Graph;x0={addDummyNode:n,simplify:s,asNonCompoundGraph:a,successorWeights:o,predecessorWeights:i,intersectRect:l,buildLayerMatrix:u,normalizeRanks:d,removeEmptyRanks:f,addBorderNode:p,maxRank:m,partition:w,time:x,notime:b};function n(j,k,v,S){var C;do C=e.uniqueId(S);while(j.hasNode(C));return v.dummy=k,j.setNode(C,v),C}function s(j){var k=new t().setGraph(j.graph());return e.forEach(j.nodes(),function(v){k.setNode(v,j.node(v))}),e.forEach(j.edges(),function(v){var S=k.edge(v.v,v.w)||{weight:0,minlen:1},C=j.edge(v);k.setEdge(v.v,v.w,{weight:S.weight+C.weight,minlen:Math.max(S.minlen,C.minlen)})}),k}function a(j){var k=new t({multigraph:j.isMultigraph()}).setGraph(j.graph());return e.forEach(j.nodes(),function(v){j.children(v).length||k.setNode(v,j.node(v))}),e.forEach(j.edges(),function(v){k.setEdge(v,j.edge(v))}),k}function o(j){var k=e.map(j.nodes(),function(v){var S={};return e.forEach(j.outEdges(v),function(C){S[C.w]=(S[C.w]||0)+j.edge(C).weight}),S});return e.zipObject(j.nodes(),k)}function i(j){var k=e.map(j.nodes(),function(v){var S={};return e.forEach(j.inEdges(v),function(C){S[C.v]=(S[C.v]||0)+j.edge(C).weight}),S});return e.zipObject(j.nodes(),k)}function l(j,k){var v=j.x,S=j.y,C=k.x-v,_=k.y-S,R=j.width/2,A=j.height/2;if(!C&&!_)throw new Error("Not possible to find intersection inside of the rectangle");var I,$;return Math.abs(_)*R>Math.abs(C)*A?(_<0&&(A=-A),I=A*C/_,$=A):(C<0&&(R=-R),I=R,$=R*_/C),{x:v+I,y:S+$}}function u(j){var k=e.map(e.range(m(j)+1),function(){return[]});return e.forEach(j.nodes(),function(v){var S=j.node(v),C=S.rank;e.isUndefined(C)||(k[C][S.order]=v)}),k}function d(j){var k=e.min(e.map(j.nodes(),function(v){return j.node(v).rank}));e.forEach(j.nodes(),function(v){var S=j.node(v);e.has(S,"rank")&&(S.rank-=k)})}function f(j){var k=e.min(e.map(j.nodes(),function(_){return j.node(_).rank})),v=[];e.forEach(j.nodes(),function(_){var R=j.node(_).rank-k;v[R]||(v[R]=[]),v[R].push(_)});var S=0,C=j.graph().nodeRankFactor;e.forEach(v,function(_,R){e.isUndefined(_)&&R%C!==0?--S:S&&e.forEach(_,function(A){j.node(A).rank+=S})})}function p(j,k,v,S){var C={width:0,height:0};return arguments.length>=4&&(C.rank=v,C.order=S),n(j,"border",C,k)}function m(j){return e.max(e.map(j.nodes(),function(k){var v=j.node(k).rank;if(!e.isUndefined(v))return v}))}function w(j,k){var v={lhs:[],rhs:[]};return e.forEach(j,function(S){k(S)?v.lhs.push(S):v.rhs.push(S)}),v}function x(j,k){var v=e.now();try{return k()}finally{console.log(j+" time: "+(e.now()-v)+"ms")}}function b(j,k){return k()}return x0}var v0,BI;function ype(){if(BI)return v0;BI=1;var e=Rt(),t=Un();v0={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,d=i.w,f=o.node(d).rank,p=i.name,m=o.edge(i),w=m.labelRank;if(f!==u+1){o.removeEdge(i);var x,b,j;for(j=0,++u;u<f;++j,++u)m.points=[],b={width:0,height:0,edgeLabel:m,edgeObj:i,rank:u},x=t.addDummyNode(o,"edge",b,"_d"),u===w&&(b.width=m.width,b.height=m.height,b.dummy="edge-label",b.labelpos=m.labelpos),o.setEdge(l,x,{weight:m.weight},p),j===0&&o.graph().dummyChains.push(x),l=x;o.setEdge(l,d,{weight:m.weight},p)}}function a(o){e.forEach(o.graph().dummyChains,function(i){var l=o.node(i),u=l.edgeLabel,d;for(o.setEdge(l.edgeObj,u);l.dummy;)d=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=d,l=o.node(i)})}return v0}var b0,qI;function Rp(){if(qI)return b0;qI=1;var e=Rt();b0={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(d){return o(d.w)-s.edge(d).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 b0}var k0,UI;function JF(){if(UI)return k0;UI=1;var e=Rt(),t=Js().Graph,n=Rp().slack;k0=s;function s(l){var u=new t({directed:!1}),d=l.nodes()[0],f=l.nodeCount();u.setNode(d,{});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 d(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,{}),d(w))})}return e.forEach(l.nodes(),d),l.nodeCount()}function o(l,u){return e.minBy(u.edges(),function(d){if(l.hasNode(d.v)!==l.hasNode(d.w))return n(u,d)})}function i(l,u,d){e.forEach(l.nodes(),function(f){u.node(f).rank+=d})}return k0}var j0,WI;function wpe(){if(WI)return j0;WI=1;var e=Rt(),t=JF(),n=Rp().slack,s=Rp().longestPath,a=Js().alg.preorder,o=Js().alg.postorder,i=Un().simplify;j0=l,l.initLowLimValues=p,l.initCutValues=u,l.calcCutValue=f,l.leaveEdge=w,l.enterEdge=x,l.exchangeEdges=b;function l(S){S=i(S),s(S);var C=t(S);p(C),u(C,S);for(var _,R;_=w(C);)R=x(C,S,_),b(C,S,_,R)}function u(S,C){var _=o(S,S.nodes());_=_.slice(0,_.length-1),e.forEach(_,function(R){d(S,C,R)})}function d(S,C,_){var R=S.node(_),A=R.parent;S.edge(_,A).cutvalue=f(S,C,_)}function f(S,C,_){var R=S.node(_),A=R.parent,I=!0,$=C.edge(_,A),U=0;return $||(I=!1,$=C.edge(A,_)),U=$.weight,e.forEach(C.nodeEdges(_),function(F){var M=F.v===_,B=M?F.w:F.v;if(B!==A){var T=M===I,P=C.edge(F).weight;if(U+=T?P:-P,k(S,_,B)){var q=S.edge(_,B).cutvalue;U+=T?-q:q}}}),U}function p(S,C){arguments.length<2&&(C=S.nodes()[0]),m(S,{},1,C)}function m(S,C,_,R,A){var I=_,$=S.node(R);return C[R]=!0,e.forEach(S.neighbors(R),function(U){e.has(C,U)||(_=m(S,C,_,U,R))}),$.low=I,$.lim=_++,A?$.parent=A:delete $.parent,_}function w(S){return e.find(S.edges(),function(C){return S.edge(C).cutvalue<0})}function x(S,C,_){var R=_.v,A=_.w;C.hasEdge(R,A)||(R=_.w,A=_.v);var I=S.node(R),$=S.node(A),U=I,F=!1;I.lim>$.lim&&(U=$,F=!0);var M=e.filter(C.edges(),function(B){return F===v(S,S.node(B.v),U)&&F!==v(S,S.node(B.w),U)});return e.minBy(M,function(B){return n(C,B)})}function b(S,C,_,R){var A=_.v,I=_.w;S.removeEdge(A,I),S.setEdge(R.v,R.w,{}),p(S),u(S,C),j(S,C)}function j(S,C){var _=e.find(S.nodes(),function(A){return!C.node(A).parent}),R=a(S,_);R=R.slice(1),e.forEach(R,function(A){var I=S.node(A).parent,$=C.edge(A,I),U=!1;$||($=C.edge(I,A),U=!0),C.node(A).rank=C.node(I).rank+(U?$.minlen:-$.minlen)})}function k(S,C,_){return S.hasEdge(C,_)}function v(S,C,_){return _.low<=C.lim&&C.lim<=_.lim}return j0}var N0,HI;function xpe(){if(HI)return N0;HI=1;var e=Rp(),t=e.longestPath,n=JF(),s=wpe();N0=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 N0}var S0,zI;function vpe(){if(zI)return S0;zI=1;var e=Rt();S0=t;function t(a){var o=s(a);e.forEach(a.graph().dummyChains,function(i){for(var l=a.node(i),u=l.edgeObj,d=n(a,o,u.v,u.w),f=d.path,p=d.lca,m=0,w=f[m],x=!0;i!==u.w;){if(l=a.node(i),x){for(;(w=f[m])!==p&&a.node(w).maxRank<l.rank;)m++;w===p&&(x=!1)}if(!x){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=[],d=[],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;)d.push(m);return{path:u.concat(d.reverse()),lca:w}}function s(a){var o={},i=0;function l(u){var d=i;e.forEach(a.children(u),l),o[u]={low:d,lim:i++}}return e.forEach(a.children(),l),o}return S0}var C0,VI;function bpe(){if(VI)return C0;VI=1;var e=Rt(),t=Un();C0={run:n,cleanup:i};function n(l){var u=t.addDummyNode(l,"root",{},"_root"),d=a(l),f=e.max(e.values(d))-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,d,w)}),l.graph().nodeRankFactor=p}function s(l,u,d,f,p,m,w){var x=l.children(w);if(!x.length){w!==u&&l.setEdge(u,w,{weight:0,minlen:d});return}var b=t.addBorderNode(l,"_bt"),j=t.addBorderNode(l,"_bb"),k=l.node(w);l.setParent(b,w),k.borderTop=b,l.setParent(j,w),k.borderBottom=j,e.forEach(x,function(v){s(l,u,d,f,p,m,v);var S=l.node(v),C=S.borderTop?S.borderTop:v,_=S.borderBottom?S.borderBottom:v,R=S.borderTop?f:2*f,A=C!==_?1:p-m[w]+1;l.setEdge(b,C,{weight:R,minlen:A,nestingEdge:!0}),l.setEdge(_,j,{weight:R,minlen:A,nestingEdge:!0})}),l.parent(w)||l.setEdge(u,b,{weight:0,minlen:p+m[w]})}function a(l){var u={};function d(f,p){var m=l.children(f);m&&m.length&&e.forEach(m,function(w){d(w,p+1)}),u[f]=p}return e.forEach(l.children(),function(f){d(f,1)}),u}function o(l){return e.reduce(l.edges(),function(u,d){return u+l.edge(d).weight},0)}function i(l){var u=l.graph();l.removeNode(u.nestingRoot),delete u.nestingRoot,e.forEach(l.edges(),function(d){var f=l.edge(d);f.nestingEdge&&l.removeEdge(d)})}return C0}var _0,GI;function kpe(){if(GI)return _0;GI=1;var e=Rt(),t=Un();_0=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 d=u.minRank,f=u.maxRank+1;d<f;++d)s(a,"borderLeft","_bl",i,u,d),s(a,"borderRight","_br",i,u,d)}}e.forEach(a.children(),o)}function s(a,o,i,l,u,d){var f={width:0,height:0,rank:d,borderType:o},p=u[o][d-1],m=t.addDummyNode(a,"border",f,i);u[o][d]=m,a.setParent(m,l),p&&a.setEdge(p,m,{weight:1})}return _0}var E0,KI;function jpe(){if(KI)return E0;KI=1;var e=Rt();E0={adjust:t,undo:n};function t(d){var f=d.graph().rankdir.toLowerCase();(f==="lr"||f==="rl")&&s(d)}function n(d){var f=d.graph().rankdir.toLowerCase();(f==="bt"||f==="rl")&&o(d),(f==="lr"||f==="rl")&&(l(d),s(d))}function s(d){e.forEach(d.nodes(),function(f){a(d.node(f))}),e.forEach(d.edges(),function(f){a(d.edge(f))})}function a(d){var f=d.width;d.width=d.height,d.height=f}function o(d){e.forEach(d.nodes(),function(f){i(d.node(f))}),e.forEach(d.edges(),function(f){var p=d.edge(f);e.forEach(p.points,i),e.has(p,"y")&&i(p)})}function i(d){d.y=-d.y}function l(d){e.forEach(d.nodes(),function(f){u(d.node(f))}),e.forEach(d.edges(),function(f){var p=d.edge(f);e.forEach(p.points,u),e.has(p,"x")&&u(p)})}function u(d){var f=d.x;d.x=d.y,d.y=f}return E0}var T0,YI;function Npe(){if(YI)return T0;YI=1;var e=Rt();T0=t;function t(n){var s={},a=e.filter(n.nodes(),function(d){return!n.children(d).length}),o=e.max(e.map(a,function(d){return n.node(d).rank})),i=e.map(e.range(o+1),function(){return[]});function l(d){if(!e.has(s,d)){s[d]=!0;var f=n.node(d);i[f.rank].push(d),e.forEach(n.successors(d),l)}}var u=e.sortBy(a,function(d){return n.node(d).rank});return e.forEach(u,l),i}return T0}var A0,XI;function Spe(){if(XI)return A0;XI=1;var e=Rt();A0=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 d=2*u-1;u-=1;var f=e.map(new Array(d),function(){return 0}),p=0;return e.forEach(l.forEach(function(m){var w=m.pos+u;f[w]+=m.weight;for(var x=0;w>0;)w%2&&(x+=f[w+1]),w=w-1>>1,f[w]+=m.weight;p+=m.weight*x})),p}return A0}var R0,ZI;function Cpe(){if(ZI)return R0;ZI=1;var e=Rt();R0=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 d=n.edge(u),f=n.node(u.v);return{sum:l.sum+d.weight*f.order,weight:l.weight+d.weight}},{sum:0,weight:0});return{v:a,barycenter:i.sum/i.weight,weight:i.weight}}else return{v:a}})}return R0}var M0,JI;function _pe(){if(JI)return M0;JI=1;var e=Rt();M0=t;function t(a,o){var i={};e.forEach(a,function(u,d){var f=i[u.v]={indegree:0,in:[],out:[],vs:[u.v],i:d};e.isUndefined(u.barycenter)||(f.barycenter=u.barycenter,f.weight=u.weight)}),e.forEach(o.edges(),function(u){var d=i[u.v],f=i[u.w];!e.isUndefined(d)&&!e.isUndefined(f)&&(f.indegree++,d.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(d){return function(f){f.merged||(e.isUndefined(f.barycenter)||e.isUndefined(d.barycenter)||f.barycenter>=d.barycenter)&&s(d,f)}}function l(d){return function(f){f.in.push(d),--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(d){return!d.merged}),function(d){return e.pick(d,["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 M0}var $0,QI;function Epe(){if(QI)return $0;QI=1;var e=Rt(),t=Un();$0=n;function n(o,i){var l=t.partition(o,function(b){return e.has(b,"barycenter")}),u=l.lhs,d=e.sortBy(l.rhs,function(b){return-b.i}),f=[],p=0,m=0,w=0;u.sort(a(!!i)),w=s(f,d,w),e.forEach(u,function(b){w+=b.vs.length,f.push(b.vs),p+=b.barycenter*b.weight,m+=b.weight,w=s(f,d,w)});var x={vs:e.flatten(f,!0)};return m&&(x.barycenter=p/m,x.weight=m),x}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 $0}var L0,eO;function Tpe(){if(eO)return L0;eO=1;var e=Rt(),t=Cpe(),n=_pe(),s=Epe();L0=a;function a(l,u,d,f){var p=l.children(u),m=l.node(u),w=m?m.borderLeft:void 0,x=m?m.borderRight:void 0,b={};w&&(p=e.filter(p,function(_){return _!==w&&_!==x}));var j=t(l,p);e.forEach(j,function(_){if(l.children(_.v).length){var R=a(l,_.v,d,f);b[_.v]=R,e.has(R,"barycenter")&&i(_,R)}});var k=n(j,d);o(k,b);var v=s(k,f);if(w&&(v.vs=e.flatten([w,v.vs,x],!0),l.predecessors(w).length)){var S=l.node(l.predecessors(w)[0]),C=l.node(l.predecessors(x)[0]);e.has(v,"barycenter")||(v.barycenter=0,v.weight=0),v.barycenter=(v.barycenter*v.weight+S.order+C.order)/(v.weight+2),v.weight+=2}return v}function o(l,u){e.forEach(l,function(d){d.vs=e.flatten(d.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 L0}var I0,tO;function Ape(){if(tO)return I0;tO=1;var e=Rt(),t=Js().Graph;I0=n;function n(a,o,i){var l=s(a),u=new t({compound:!0}).setGraph({root:l}).setDefaultNodeLabel(function(d){return a.node(d)});return e.forEach(a.nodes(),function(d){var f=a.node(d),p=a.parent(d);(f.rank===o||f.minRank<=o&&o<=f.maxRank)&&(u.setNode(d),u.setParent(d,p||l),e.forEach(a[i](d),function(m){var w=m.v===d?m.w:m.v,x=u.edge(w,d),b=e.isUndefined(x)?0:x.weight;u.setEdge(w,d,{weight:a.edge(m).weight+b})}),e.has(f,"minRank")&&u.setNode(d,{borderLeft:f.borderLeft[o],borderRight:f.borderRight[o]}))}),u}function s(a){for(var o;a.hasNode(o=e.uniqueId("_root")););return o}return I0}var O0,nO;function Rpe(){if(nO)return O0;nO=1;var e=Rt();O0=t;function t(n,s,a){var o={},i;e.forEach(a,function(l){for(var u=n.parent(l),d,f;u;){if(d=n.parent(u),d?(f=o[d],o[d]=u):(f=i,i=u),f&&f!==u){s.setEdge(f,u);return}u=d}})}return O0}var P0,sO;function Mpe(){if(sO)return P0;sO=1;var e=Rt(),t=Npe(),n=Spe(),s=Tpe(),a=Ape(),o=Rpe(),i=Js().Graph,l=Un();P0=u;function u(m){var w=l.maxRank(m),x=d(m,e.range(1,w+1),"inEdges"),b=d(m,e.range(w-1,-1,-1),"outEdges"),j=t(m);p(m,j);for(var k=Number.POSITIVE_INFINITY,v,S=0,C=0;C<4;++S,++C){f(S%2?x:b,S%4>=2),j=l.buildLayerMatrix(m);var _=n(m,j);_<k&&(C=0,v=e.cloneDeep(j),k=_)}p(m,v)}function d(m,w,x){return e.map(w,function(b){return a(m,b,x)})}function f(m,w){var x=new i;e.forEach(m,function(b){var j=b.graph().root,k=s(b,j,x,w);e.forEach(k.vs,function(v,S){b.node(v).order=S}),o(b,x,k.vs)})}function p(m,w){e.forEach(w,function(x){e.forEach(x,function(b,j){m.node(b).order=j})})}return P0}var D0,rO;function $pe(){if(rO)return D0;rO=1;var e=Rt(),t=Js().Graph,n=Un();D0={positionX:x,findType1Conflicts:s,findType2Conflicts:a,addConflict:i,hasConflict:l,verticalAlignment:u,horizontalCompaction:d,alignCoordinates:m,findSmallestWidthAlignment:p,balance:w};function s(k,v){var S={};function C(_,R){var A=0,I=0,$=_.length,U=e.last(R);return e.forEach(R,function(F,M){var B=o(k,F),T=B?k.node(B).order:$;(B||F===U)&&(e.forEach(R.slice(I,M+1),function(P){e.forEach(k.predecessors(P),function(q){var K=k.node(q),z=K.order;(z<A||T<z)&&!(K.dummy&&k.node(P).dummy)&&i(S,q,P)})}),I=M+1,A=T)}),R}return e.reduce(v,C),S}function a(k,v){var S={};function C(R,A,I,$,U){var F;e.forEach(e.range(A,I),function(M){F=R[M],k.node(F).dummy&&e.forEach(k.predecessors(F),function(B){var T=k.node(B);T.dummy&&(T.order<$||T.order>U)&&i(S,B,F)})})}function _(R,A){var I=-1,$,U=0;return e.forEach(A,function(F,M){if(k.node(F).dummy==="border"){var B=k.predecessors(F);B.length&&($=k.node(B[0]).order,C(A,U,M,I,$),U=M,I=$)}C(A,U,A.length,$,R.length)}),A}return e.reduce(v,_),S}function o(k,v){if(k.node(v).dummy)return e.find(k.predecessors(v),function(S){return k.node(S).dummy})}function i(k,v,S){if(v>S){var C=v;v=S,S=C}var _=k[v];_||(k[v]=_={}),_[S]=!0}function l(k,v,S){if(v>S){var C=v;v=S,S=C}return e.has(k[v],S)}function u(k,v,S,C){var _={},R={},A={};return e.forEach(v,function(I){e.forEach(I,function($,U){_[$]=$,R[$]=$,A[$]=U})}),e.forEach(v,function(I){var $=-1;e.forEach(I,function(U){var F=C(U);if(F.length){F=e.sortBy(F,function(q){return A[q]});for(var M=(F.length-1)/2,B=Math.floor(M),T=Math.ceil(M);B<=T;++B){var P=F[B];R[U]===U&&$<A[P]&&!l(S,U,P)&&(R[P]=U,R[U]=_[U]=_[P],$=A[P])}}})}),{root:_,align:R}}function d(k,v,S,C,_){var R={},A=f(k,v,S,_),I=_?"borderLeft":"borderRight";function $(M,B){for(var T=A.nodes(),P=T.pop(),q={};P;)q[P]?M(P):(q[P]=!0,T.push(P),T=T.concat(B(P))),P=T.pop()}function U(M){R[M]=A.inEdges(M).reduce(function(B,T){return Math.max(B,R[T.v]+A.edge(T))},0)}function F(M){var B=A.outEdges(M).reduce(function(P,q){return Math.min(P,R[q.w]-A.edge(q))},Number.POSITIVE_INFINITY),T=k.node(M);B!==Number.POSITIVE_INFINITY&&T.borderType!==I&&(R[M]=Math.max(R[M],B))}return $(U,A.predecessors.bind(A)),$(F,A.successors.bind(A)),e.forEach(C,function(M){R[M]=R[S[M]]}),R}function f(k,v,S,C){var _=new t,R=k.graph(),A=b(R.nodesep,R.edgesep,C);return e.forEach(v,function(I){var $;e.forEach(I,function(U){var F=S[U];if(_.setNode(F),$){var M=S[$],B=_.edge(M,F);_.setEdge(M,F,Math.max(A(k,U,$),B||0))}$=U})}),_}function p(k,v){return e.minBy(e.values(v),function(S){var C=Number.NEGATIVE_INFINITY,_=Number.POSITIVE_INFINITY;return e.forIn(S,function(R,A){var I=j(k,A)/2;C=Math.max(R+I,C),_=Math.min(R-I,_)}),C-_})}function m(k,v){var S=e.values(v),C=e.min(S),_=e.max(S);e.forEach(["u","d"],function(R){e.forEach(["l","r"],function(A){var I=R+A,$=k[I],U;if($!==v){var F=e.values($);U=A==="l"?C-e.min(F):_-e.max(F),U&&(k[I]=e.mapValues($,function(M){return M+U}))}})})}function w(k,v){return e.mapValues(k.ul,function(S,C){if(v)return k[v.toLowerCase()][C];var _=e.sortBy(e.map(k,C));return(_[1]+_[2])/2})}function x(k){var v=n.buildLayerMatrix(k),S=e.merge(s(k,v),a(k,v)),C={},_;e.forEach(["u","d"],function(A){_=A==="u"?v:e.values(v).reverse(),e.forEach(["l","r"],function(I){I==="r"&&(_=e.map(_,function(M){return e.values(M).reverse()}));var $=(A==="u"?k.predecessors:k.successors).bind(k),U=u(k,_,S,$),F=d(k,_,U.root,U.align,I==="r");I==="r"&&(F=e.mapValues(F,function(M){return-M})),C[A+I]=F})});var R=p(k,C);return m(C,R),w(C,k.graph().align)}function b(k,v,S){return function(C,_,R){var A=C.node(_),I=C.node(R),$=0,U;if($+=A.width/2,e.has(A,"labelpos"))switch(A.labelpos.toLowerCase()){case"l":U=-A.width/2;break;case"r":U=A.width/2;break}if(U&&($+=S?U:-U),U=0,$+=(A.dummy?v:k)/2,$+=(I.dummy?v:k)/2,$+=I.width/2,e.has(I,"labelpos"))switch(I.labelpos.toLowerCase()){case"l":U=I.width/2;break;case"r":U=-I.width/2;break}return U&&($+=S?U:-U),U=0,$}}function j(k,v){return k.node(v).width}return D0}var F0,aO;function Lpe(){if(aO)return F0;aO=1;var e=Rt(),t=Un(),n=$pe().positionX;F0=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(d){var f=e.max(e.map(d,function(p){return o.node(p).height}));e.forEach(d,function(p){o.node(p).y=u+f/2}),u+=f+l})}return F0}var B0,oO;function Ipe(){if(oO)return B0;oO=1;var e=Rt(),t=gpe(),n=ype(),s=xpe(),a=Un().normalizeRanks,o=vpe(),i=Un().removeEmptyRanks,l=bpe(),u=kpe(),d=jpe(),f=Mpe(),p=Lpe(),m=Un(),w=Js().Graph;B0=x;function x(W,X){var Y=X&&X.debugTiming?m.time:m.notime;Y("layout",function(){var J=Y(" buildLayoutGraph",function(){return $(W)});Y(" runLayout",function(){b(J,Y)}),Y(" updateInputGraph",function(){j(W,J)})})}function b(W,X){X(" makeSpaceForEdgeLabels",function(){U(W)}),X(" removeSelfEdges",function(){H(W)}),X(" acyclic",function(){t.run(W)}),X(" nestingGraph.run",function(){l.run(W)}),X(" rank",function(){s(m.asNonCompoundGraph(W))}),X(" injectEdgeLabelProxies",function(){F(W)}),X(" removeEmptyRanks",function(){i(W)}),X(" nestingGraph.cleanup",function(){l.cleanup(W)}),X(" normalizeRanks",function(){a(W)}),X(" assignRankMinMax",function(){M(W)}),X(" removeEdgeLabelProxies",function(){B(W)}),X(" normalize.run",function(){n.run(W)}),X(" parentDummyChains",function(){o(W)}),X(" addBorderSegments",function(){u(W)}),X(" order",function(){f(W)}),X(" insertSelfEdges",function(){D(W)}),X(" adjustCoordinateSystem",function(){d.adjust(W)}),X(" position",function(){p(W)}),X(" positionSelfEdges",function(){O(W)}),X(" removeBorderNodes",function(){z(W)}),X(" normalize.undo",function(){n.undo(W)}),X(" fixupEdgeLabelCoords",function(){q(W)}),X(" undoCoordinateSystem",function(){d.undo(W)}),X(" translateGraph",function(){T(W)}),X(" assignNodeIntersects",function(){P(W)}),X(" reversePoints",function(){K(W)}),X(" acyclic.undo",function(){t.undo(W)})}function j(W,X){e.forEach(W.nodes(),function(Y){var J=W.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(W.edges(),function(Y){var J=W.edge(Y),Q=X.edge(Y);J.points=Q.points,e.has(Q,"x")&&(J.x=Q.x,J.y=Q.y)}),W.graph().width=X.graph().width,W.graph().height=X.graph().height}var k=["nodesep","edgesep","ranksep","marginx","marginy"],v={ranksep:50,edgesep:20,nodesep:50,rankdir:"tb"},S=["acyclicer","ranker","rankdir","align"],C=["width","height"],_={width:0,height:0},R=["minlen","weight","width","height","labeloffset"],A={minlen:1,weight:1,width:0,height:0,labeloffset:10,labelpos:"r"},I=["labelpos"];function $(W){var X=new w({multigraph:!0,compound:!0}),Y=Z(W.graph());return X.setGraph(e.merge({},v,V(Y,k),e.pick(Y,S))),e.forEach(W.nodes(),function(J){var Q=Z(W.node(J));X.setNode(J,e.defaults(V(Q,C),_)),X.setParent(J,W.parent(J))}),e.forEach(W.edges(),function(J){var Q=Z(W.edge(J));X.setEdge(J,e.merge({},A,V(Q,R),e.pick(Q,I)))}),X}function U(W){var X=W.graph();X.ranksep/=2,e.forEach(W.edges(),function(Y){var J=W.edge(Y);J.minlen*=2,J.labelpos.toLowerCase()!=="c"&&(X.rankdir==="TB"||X.rankdir==="BT"?J.width+=J.labeloffset:J.height+=J.labeloffset)})}function F(W){e.forEach(W.edges(),function(X){var Y=W.edge(X);if(Y.width&&Y.height){var J=W.node(X.v),Q=W.node(X.w),te={rank:(Q.rank-J.rank)/2+J.rank,e:X};m.addDummyNode(W,"edge-proxy",te,"_ep")}})}function M(W){var X=0;e.forEach(W.nodes(),function(Y){var J=W.node(Y);J.borderTop&&(J.minRank=W.node(J.borderTop).rank,J.maxRank=W.node(J.borderBottom).rank,X=e.max(X,J.maxRank))}),W.graph().maxRank=X}function B(W){e.forEach(W.nodes(),function(X){var Y=W.node(X);Y.dummy==="edge-proxy"&&(W.edge(Y.e).labelRank=Y.rank,W.removeNode(X))})}function T(W){var X=Number.POSITIVE_INFINITY,Y=0,J=Number.POSITIVE_INFINITY,Q=0,te=W.graph(),le=te.marginx||0,de=te.marginy||0;function oe(re){var he=re.x,fe=re.y,$e=re.width,ye=re.height;X=Math.min(X,he-$e/2),Y=Math.max(Y,he+$e/2),J=Math.min(J,fe-ye/2),Q=Math.max(Q,fe+ye/2)}e.forEach(W.nodes(),function(re){oe(W.node(re))}),e.forEach(W.edges(),function(re){var he=W.edge(re);e.has(he,"x")&&oe(he)}),X-=le,J-=de,e.forEach(W.nodes(),function(re){var he=W.node(re);he.x-=X,he.y-=J}),e.forEach(W.edges(),function(re){var he=W.edge(re);e.forEach(he.points,function(fe){fe.x-=X,fe.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 P(W){e.forEach(W.edges(),function(X){var Y=W.edge(X),J=W.node(X.v),Q=W.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 q(W){e.forEach(W.edges(),function(X){var Y=W.edge(X);if(e.has(Y,"x"))switch((Y.labelpos==="l"||Y.labelpos==="r")&&(Y.width-=Y.labeloffset),Y.labelpos){case"l":Y.x-=Y.width/2+Y.labeloffset;break;case"r":Y.x+=Y.width/2+Y.labeloffset;break}})}function K(W){e.forEach(W.edges(),function(X){var Y=W.edge(X);Y.reversed&&Y.points.reverse()})}function z(W){e.forEach(W.nodes(),function(X){if(W.children(X).length){var Y=W.node(X),J=W.node(Y.borderTop),Q=W.node(Y.borderBottom),te=W.node(e.last(Y.borderLeft)),le=W.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(W.nodes(),function(X){W.node(X).dummy==="border"&&W.removeNode(X)})}function H(W){e.forEach(W.edges(),function(X){if(X.v===X.w){var Y=W.node(X.v);Y.selfEdges||(Y.selfEdges=[]),Y.selfEdges.push({e:X,label:W.edge(X)}),W.removeEdge(X)}})}function D(W){var X=m.buildLayerMatrix(W);e.forEach(X,function(Y){var J=0;e.forEach(Y,function(Q,te){var le=W.node(Q);le.order=te+J,e.forEach(le.selfEdges,function(de){m.addDummyNode(W,"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 O(W){e.forEach(W.nodes(),function(X){var Y=W.node(X);if(Y.dummy==="selfedge"){var J=W.node(Y.e.v),Q=J.x+J.width/2,te=J.y,le=Y.x-Q,de=J.height/2;W.setEdge(Y.e,Y.label),W.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 V(W,X){return e.mapValues(e.pick(W,X),Number)}function Z(W){var X={};return e.forEach(W,function(Y,J){X[J.toLowerCase()]=Y}),X}return B0}var q0,iO;function Ope(){if(iO)return q0;iO=1;var e=Rt(),t=Un(),n=Js().Graph;q0={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 d="layer"+u;i.setNode(d,{rank:"same"}),e.reduce(l,function(f,p){return i.setEdge(f,p,{style:"invis"}),p})}),i}return q0}var U0,lO;function Ppe(){return lO||(lO=1,U0="0.8.5"),U0}var W0,cO;function Dpe(){return cO||(cO=1,W0={graphlib:Js(),layout:Ipe(),debug:Ope(),util:{time:Un().time,notime:Un().notime},version:Ppe()}),W0}var Fpe=Dpe();const uO=Wj(Fpe),dO=e=>{var t;return(t=e.data)==null?void 0:t.parentId};function Bpe(e,t,n,s){const a=hm(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)??ON},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),d=e.filter(f=>!t.has(f.id)&&!n(f.id)&&a.has(un(f))).sort((f,p)=>f.position.x-p.position.x||f.position.y-p.position.y);for(const f of d){const p=un(f),m=dO(f),w=m?u(m):void 0;if(m&&w&&f.type!=="recapNote"){const k={x:w.x-i.get(m).x,y:w.y-i.get(m).y},v={x:f.position.x+k.x,y:f.position.y+k.y};let S=null;for(const C of e){if(C.id===f.id||C.type==="recapNote"||dO(C)!==m||un(C)!==p)continue;const _=u(C.id);if(!_||Math.abs(_.x-v.x)>$l||_.x<=w.x)continue;const R=_.y+o(C.id);(!S||R>S.bottom)&&(S={at:_,bottom:R})}if(S){l.set(f.id,{x:S.at.x,y:S.bottom+ND});continue}}const x=a.get(p)[0].id,b=w??n(x),j=i.get(w?m:x);l.set(f.id,{x:f.position.x+b.x-j.x,y:f.position.y+b.y-j.y})}return l.size===0?e:e.map(f=>{const p=l.get(f.id);return p?{...f,position:p}:f})}const H0=e=>e.type==="recapNote";function qpe(e,t,n,s,a,o,i){const l=S=>rc(S,s,o),u=S=>n.get(S)??t.get(S),d=S=>{const{w:C,h:_}=sd(S,s);return{cw:C,ch:_}},f=i!=null&&i.width>0&&i.height>0,p=hm(e,S=>u(S.id)!=null&&!H0(S)),m=new Set;for(const[S,C]of p)C.every(_=>a.has(_.id)&&!n.has(_.id))&&m.add(S);const w=new Map,x=[];for(const S of e){const C=u(S.id);if(!C)continue;const{w:_,h:R}=l(S.id),A=un(S);m.has(A)?H0(S)||(w.get(A)??w.set(A,[]).get(A)).push(S):x.push({sid:A,x:C.x,y:C.y,w:_,h:R,...d(S.id),note:H0(S)})}if(w.size===0||f&&x.length===0)return[];const b=Kl,j=(S,C,_,R)=>x.some(A=>S<A.x+A.w+W1&&A.x<S+_+W1&&C<A.y+A.h+b&&A.y<C+R+b),k=SD(e,s),v=[];for(const S of[...w.keys()].sort()){const C=w.get(S);let _=1/0,R=1/0,A=-1/0,I=-1/0,$=-1/0,U=-1/0;for(const D of C){const O=u(D.id),{w:V,h:Z}=l(D.id),{cw:W,ch:X}=d(D.id);_=Math.min(_,O.x),R=Math.min(R,O.y),A=Math.max(A,O.x+V),I=Math.max(I,O.y+Z),$=Math.max($,O.x+W),U=Math.max(U,O.y+X)}const F=I-R,M=C.some(D=>{var O;return((O=D.data)==null?void 0:O.kind)==="root"})?Df+CD:0,B=Math.max(A,$+$l)-_,T=(D,O)=>!j(D-M,O,M+B,F),P=new Map;for(const D of x)D.note||P.set(D.sid,Math.min(P.get(D.sid)??1/0,D.x));const q=[...new Set([...P.values()].map(D=>Math.round(D)))].sort((D,O)=>D-O),K=q.length?q:[_],z=[0,...x.map(D=>D.y+D.h+b)].sort((D,O)=>D-O);let H=null;if(f){let D=1/0,O=1/0,V=-1/0,Z=-1/0;for(const te of x)D=Math.min(D,te.x),O=Math.min(O,te.y),V=Math.max(V,te.x+te.cw),Z=Math.max(Z,te.y+te.ch);const W=(te,le)=>{const de=i.width/(Math.max(V,te+$-_)-Math.min(D,te-M)+$l),oe=i.height/(Math.max(Z,le+U-R)-Math.min(O,le));return[Math.min(_D,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(V+$l+k+M),J=[...new Set([...z,O])].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=W(te,le);(Q===null||X(de,Q))&&(Q=de,H={x:te,y:le})}H&&H.x===_&&H.y===R&&(H=null)}else e:for(const D of K)for(const O of z){if(O>=R)break;if(T(D,O)){H={x:D,y:O};break e}}if(H){const D=H.x-_,O=H.y-R;for(const V of C){const Z=u(V.id);t.set(V.id,{x:Z.x+D,y:Z.y+O})}v.push(S)}for(const D of C){const O=u(D.id),{w:V,h:Z}=l(D.id);x.push({sid:S,x:O.x,y:O.y,w:V,h:Z,...d(D.id),note:!1})}if(M>0){const D=_+(H?H.x-_:0),O=R+(H?H.y-R:0);x.push({sid:S,x:D-M,y:O,w:Df,h:mp,cw:Df,ch:mp,note:!0})}}return v}function Upe(e,t,n,s,a,o){const i=m=>rc(m,s,a),l=new Map(e.map(m=>[m.id,un(m)])),u=[],d=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 d){if(!f(m))continue;const{w:x,h:b}=i(m);u.push({x:w.x,y:w.y,w:x,h:b,sid:l.get(m)??"_default"})}const p=[];for(const{id:m,pos:w}of d){if(f(m))continue;const{w:x,h:b}=i(m),j=l.get(m)??"_default";if(n.has(m)){u.push({x:w.x,y:w.y,w:x,h:b,sid:j});continue}let k=w.y;for(let v=0;v<u.length+1;v++){const S=u.find(C=>{const _=C.sid===j?Pf:pp,R=C.sid===j?Pf:Kl;return w.x<C.x+C.w+_&&C.x<w.x+x+_&&k<C.y+C.h+R&&C.y<k+b+R});if(!S)break;k=S.y+S.h+(S.sid===j?Pf:Kl)}k!==w.y&&(t.set(m,{x:w.x,y:k}),p.push(m)),u.push({x:w.x,y:k,w:x,h:b,sid:j})}return p}function Wpe(e,t,n,s,a,o=!1,i){const u=pp+1,d=Kl+1,f=8,p=1.75,m=200,w=.7,x=.01,b=M=>rc(M,s,i),j=M=>n.get(M)??t.get(M),k=hm(e,M=>j(M.id)!=null),v=[],S=new Set,C=new Set,_=a.size===0;for(const M of[...k.keys()].sort()){const B=k.get(M);let T=1/0,P=1/0,q=-1/0,K=-1/0,z=!1;for(const V of B){const Z=j(V.id),{w:W,h:X}=b(V.id);T=Math.min(T,Z.x),P=Math.min(P,Z.y),q=Math.max(q,Z.x+W),K=Math.max(K,Z.y+X),n.has(V.id)&&(z=!0)}const H=q-T,D=K-P;C.add(M);const O=a.get(M);O&&(H>O.w+f||D>O.h+f)&&S.add(M),a.set(M,{w:H,h:D}),v.push({sid:M,members:B.map(V=>V.id),x:T,y:P,w:H,h:D,anchored:z,mass:1})}for(const M of[...a.keys()])C.has(M)||a.delete(M);if(o||_)return[];let R=!1;for(let M=0;M<v.length&&!R;M++)for(let B=M+1;B<v.length;B++){const T=v[M],P=v[B];if(!(T.anchored&&P.anchored)&&Math.abs(T.x+T.w/2-(P.x+P.w/2))<(T.w+P.w)/2+u&&Math.abs(T.y+T.h/2-(P.y+P.h/2))<(T.h+P.h)/2+d){R=!0;break}}if(S.size===0&&!R)return[];if(S.size>0)for(const M of v)S.has(M.sid)&&(M.mass=8);else for(const M of v)M.mass=Math.max(1,M.w*M.h/(nd*ON));const A=new Map(v.map(M=>[M.sid,M.x])),I=new Map(v.map(M=>[M.sid,M.y])),$=new Map(v.map(M=>[M.sid,Math.min(0,M.x)])),U=new Map(v.map(M=>[M.sid,Math.min(0,M.y)]));for(let M=0;M<m;M++){const B=new Map,T=new Map;let P=0;for(let q=0;q<v.length;q++)for(let K=q+1;K<v.length;K++){const z=v[q],H=v[K];if(z.anchored&&H.anchored)continue;const D=z.x+z.w/2,O=z.y+z.h/2,V=H.x+H.w/2,Z=H.y+H.h/2,W=(z.w+H.w)/2+u-Math.abs(D-V),X=(z.h+H.h)/2+d-Math.abs(O-Z);if(W<=0||X<=0)continue;const Y=(Ke,we)=>!Ke.anchored&&!(we<0&&Ke.x<=$.get(Ke.sid)),J=(Ke,we)=>!Ke.anchored&&!(we<0&&Ke.y<=U.get(Ke.sid)),Q=(Ke,we,Fe)=>{const Re=Ke===we,Ae=Re?z.sid<H.sid?-1:1:Math.sign(Ke-we);return Fe(z,Ae)||Fe(H,-Ae)?Ae:Re&&(Fe(z,-Ae)||Fe(H,Ae))?-Ae:0},te=Q(D,V,Y),le=Q(O,Z,J),de=te!==0,oe=le!==0;if(!de&&!oe)continue;const re=de&&(!oe||W*p<X),[he,fe,$e,ye]=re?[te,W,B,Y]:[le,X,T,J],ge=ye(z,he),je=ye(H,-he),Le=z.mass,ke=H.mass,Ie=ge?je?ke/(Le+ke):1:0,De=je?ge?Le/(Le+ke):1:0,Ue=fe*w;$e.set(z.sid,($e.get(z.sid)??0)+he*Ue*Ie),$e.set(H.sid,($e.get(H.sid)??0)-he*Ue*De),P+=Ue}for(const q of v)q.anchored||(q.x=Math.max($.get(q.sid),q.x+(B.get(q.sid)??0)),q.y=Math.max(U.get(q.sid),q.y+(T.get(q.sid)??0)));if(P<x)break}const F=[];for(const M of v){const B=M.x-A.get(M.sid),T=M.y-I.get(M.sid);if(!(Math.abs(B)<1&&Math.abs(T)<1)){for(const P of M.members){if(n.has(P))continue;const q=t.get(P);q&&t.set(P,{x:q.x+B,y:q.y+T})}F.push(M.sid)}}return F}const QF=160,Hpe=40,zpe=80;function hO(e,t,n){const s=sd(e,t),a=rc(e,t,n),o=a.w-s.w,i=Hpe+(t.has(e)?0:zpe);return o>0?{w:s.w+Math.max(0,o+i-QF),h:a.h}:a}function Vpe(e,t,n,s,a,o){const i=new uO.graphlib.Graph;i.setDefaultEdgeLabel(()=>({})),i.setGraph({rankdir:n,marginx:0,marginy:0,nodesep:ND,ranksep:QF,edgesep:30});const l=e.filter(k=>!a.has(k)),u=new Set(l);for(const k of l){const{w:v,h:S}=hO(k,s,o);i.setNode(k,{width:v,height:S})}for(const k of t)u.has(k.source)&&u.has(k.target)&&i.setEdge(k.source,k.target);uO.layout(i);const d=new Map;let f=1/0,p=1/0,m=-1/0,w=-1/0;for(const k of l){const v=i.node(k);if(!v)continue;const{w:S,h:C}=sd(k,s),_=hO(k,s,o),R=v.x-_.w/2,A=v.y-_.h/2;d.set(k,{x:R,y:A}),R<f&&(f=R),A<p&&(p=A),R+S>m&&(m=R+S),A+C>w&&(w=A+C)}if(Number.isFinite(f)&&Number.isFinite(p))for(const[k,v]of d)d.set(k,{x:v.x-f,y:v.y-p});const x=Number.isFinite(m)?m-f:0,b=Number.isFinite(w)?w-p:0;let j=null;for(const k of e){const v=a.get(k);if(!v)continue;const{w:S,h:C}=sd(k,s);j=j===null?{minX:v.x,minY:v.y,maxX:v.x+S,maxY:v.y+C}:{minX:Math.min(j.minX,v.x),minY:Math.min(j.minY,v.y),maxX:Math.max(j.maxX,v.x+S),maxY:Math.max(j.maxY,v.y+C)}}return{positions:d,width:x,height:b,pinnedBox:j}}function e8(e,t,n){const s=n.direction??"LR",a=n.pinned??new Map,o=n.measured??new Map,i=n.lanes,l=hm(e);return{laid:Array.from(l.keys()).sort().map(f=>({sid:f,...Vpe(l.get(f).map(p=>p.id),t,s,o,a,i)})),gap:SD(e,o)}}const t8=e=>e.reduce((t,n)=>Math.max(t,n.width),0)+$l,Gpe=e=>e.reduce((t,n)=>t+n.height,0)+Ml*Math.max(0,e.length-1);function jj(e,t,n,s){const a=u=>{const d=[[]];let f=0;for(const p of e)f>0&&f+p.height>u&&(d.push([]),f=0),d[d.length-1].push(p),f+=p.height+Ml;return d},o=[];for(let u=0;u<e.length;u++){let d=-Ml;for(let f=u;f<e.length;f++)o.push(d+=e[f].height+Ml)}o.sort((u,d)=>u-d);const i=u=>{let d=0,f=o.length-1;for(;d<f;){const p=d+f>>1;a(o[p]).length<=u?f=p:d=p+1}return a(o[d])};let l=[e];if(n>0&&s>0){const u=f=>aJ(f.reduce((p,m)=>p+t8(m),0)+t*(f.length-1),Math.max(...f.map(Gpe)),n,s);let d=u(l);for(let f=2;f<=e.length;f++){const p=i(f),m=u(p);m>d+1e-9&&(d=m,l=p)}}return l}function Kpe(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}=e8(e,t,n);return o.length<2?!1:jj(o,i,s.width,s.height).length!==jj(o,i,a.width,a.height).length}function Ype(e,t,n={}){const s=n.pinned??new Map,{laid:a,gap:o}=e8(e,t,n),i=jj(a,o,n.availableWidth??0,n.availableHeight??0),l=new Map;let u=0;for(const d of i){const f=t8(d);let p=0;for(const{positions:m,height:w,pinnedBox:x}of d){for(const[j,k]of m)l.set(j,{x:k.x+u,y:k.y+p});let b=p+w;x&&x.maxY>b&&x.minX<u+f&&u<x.maxX&&(b=x.maxY),p=b+Ml}u+=f+o}return e.map(d=>{const f=s.get(d.id);if(f)return{...d,position:f};const p=l.get(d.id);return p?{...d,position:p}:d})}function Fu(e,t,n){return!t.has(e)||n.has(e)}function Xpe(e,t,n,s){return!t.has(e)&&Fu(e,n,s)}function Zpe(e,t,n){const s={x:0,y:0};return t.set(e,s),n.add(e),s}function fO(e,t,n,s){n.set(e,t),s.delete(e)}const Jpe=e=>e.type==="recapNote",Qpe=e=>{var t;return(t=e.data)==null?void 0:t.sessionId};function eme(e,t,n,s,a,o,i){if(i.size===0)return[];const l=new Set;for(const m of e){const w=Qpe(m);w&&i.has(w)&&(l.add(un(m)),i.delete(w))}if(l.size===0)return[];const u=m=>{const w=s.get(m.id)??(Fu(m.id,t,n)?void 0:t.get(m.id));if(!w)return;const{w:x,h:b}=rc(m.id,a,o);return{x:w.x,y:w.y,w:x,h:b}},d=[];for(const m of e){if(l.has(un(m)))continue;const w=u(m);w&&d.push(w)}const f=m=>d.some(w=>m.x<w.x+w.w+pp&&w.x<m.x+m.w+pp&&m.y<w.y+w.h+Kl&&w.y<m.y+m.h+Kl),p=[];for(const m of l){const w=e.filter(x=>un(x)===m&&!Jpe(x));if(w.some(x=>{const b=u(x);return b!=null&&f(b)})){for(const x of w)s.has(x.id)||(t.delete(x.id),n.delete(x.id));p.push(m)}}return p}const pO=new WeakMap;function tme(e,t){let n=pO.get(e);(!n||n.revision!==e.revision||n.open!==t)&&(n={revision:e.revision,open:t,byId:new Map,branches:AK(e.agents.values()),groups:Zp(e.agents.values())},pO.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 FS(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 nme(e,t){const n=i=>un(i),s=new Map;for(const i of e){const l=n(i),u=i.position.x+(i.width??nd),d=s.get(l);d?(d.minX=Math.min(d.minX,i.position.x),d.maxX=Math.max(d.maxX,u),d.minY=Math.min(d.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,d)=>u[1].minX-d[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,d)=>u.top-d.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 sme(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 rme(e,t,n,s,a,o,i,l,u,d,f,p,m,w,x,b,j,k,v,S,C=new Set){var H,D,O,V;const _=[],R=[],A=tme(e,k);for(const Z of e.agents.values()){if(!j.has(Z.id))continue;const W=Z.exitAt!=null,X=b!=null&&!b.has(Z.id),Y=[W?"rf-exiting":"",X?"rf-spotlit-out":"",x.has(Z.id)?"rf-selected":""].filter(Boolean).join(" ")||void 0,J=o.get(Z.id);if(_.push({id:Z.id,type:"agent",position:{x:0,y:0},data:A(Z),className:Y,ariaLabel:UG(Z,t,x.has(Z.id)),...J?{width:J.width,height:J.height}:null}),Z.parentId&&j.has(Z.parentId)){const de=Ju(Z.sessionId),oe=W,re=x.size>0&&(x.has(Z.id)||x.has(Z.parentId)),he=b!=null&&!b.has(Z.id)&&!b.has(Z.parentId),fe=Z.state==="active"?2:1.5,$e=re?fe+1.5:fe,ye=oe?.2:he?.12:1,ge=["sess-edge",Z.state==="active"?"sess-live":"sess-idle",oe?"rf-edge-exiting":"",re?"rf-edge-selected":""].filter(Boolean).join(" ");R.push({id:`e:${Z.parentId}->${Z.id}`,source:Z.parentId,target:Z.id,animated:(Z.state==="active"||re)&&!oe,type:"smoothstep",style:{"--session-hue":de,strokeWidth:`calc(${$e}px * var(--edge-k, 1))`,opacity:ye,transition:"var(--edge-transition)"},className:ge})}const Q=Z.kind==="root"?UP(Z):null,te=(Q==null?void 0:Q.note)??null,le=Q?Q.key:null;if(Q&&le&&!vK(le)){const de=bN(Z.id),oe=Ju(Z.sessionId),re=o.get(de);_.push({id:de,type:"recapNote",position:{x:0,y:0},data:{sessionId:Z.sessionId,canvasSessionId:A(Z).canvasSessionId,parentId:Z.id,note:te,plan:Q.plan,noteKey:le,hue:oe},className:X?"rf-spotlit-out":void 0,selectable:!1,focusable:!1,ariaLabel:te?te.kind==="recap"?`Claude Code's recap for ${Z.label}`:`${Z.label}: ${sc(te.kind)}`:`${Z.label}: plan`,...re?{width:re.width,height:re.height}:null}),R.push({id:`e:recap:${Z.id}`,source:de,target:Z.id,type:"recapTie",className:"recap-edge",focusable:!1,style:{"--session-hue":oe}})}}const I=FS(e),$=S.size>0&&!(u&&v);$||S.clear();const U=_.filter(Z=>Z.data.provider==="codex"&&Z.data.parentId).map(Z=>`${Z.id}:${un(Z)}:${Z.data.parentId}`).sort().join("|"),F=`${m}${U?`#codex:${U}`:""}#lanes:${lJ(I)}${$?"#held":""}`,M=new Set(_.filter(Z=>Z.type==="recapNote").map(Z=>Z.id));for(const Z of Array.from(f.keys()))v&&NK(Z)&&!M.has(Z)&&!a.has(Z)&&(f.delete(Z),p.delete(Z));v&&eme(_,f,p,a,o,I,C);const B=_.filter(Z=>Xpe(Z.id,a,f,p));if(B.length>0||F!==w.current){if(B.length>0){for(const W of B)S.delete(W.id);const Z=Bpe(Ype(_,R,{direction:"LR",pinned:a,measured:o,availableWidth:n,availableHeight:s,lanes:I}),a,W=>Fu(W,f,p)?void 0:f.get(W),W=>rc(W,o,I));for(const W of Z)Fu(W.id,f,p)&&fO(W.id,W.position,f,p);qpe(_,f,a,o,new Set(B.filter(W=>W.type!=="recapNote").map(W=>W.id)),I,{width:n,height:s});for(const W of B){if(W.type!=="recapNote")continue;const X=(H=W.data)==null?void 0:H.parentId;if(!X)continue;const Y=a.get(X)??(Fu(X,f,p)?void 0:f.get(X));if(!Y)continue;const J=((D=o.get(W.id))==null?void 0:D.width)??Df,Q=((O=o.get(W.id))==null?void 0:O.height)??mp,te=((V=o.get(X))==null?void 0:V.height)??mp;fO(W.id,{x:Y.x-CD-J,y:Y.y+(te-Q)/2},f,p)}}Upe(_,f,a,o,I,$?S:void 0),w.current=F}const T=Wpe(_,f,a,o,i,!u||d,I);T.length>0&&l(T);const P=xde(e.agents.values());v&&pu(f,P),pu(p,P),pu(C,P),v&&pu(a,P),pu(o,wde(e.agents.values()));const q=[];let K=!1;for(const Z of _){let W=a.get(Z.id)??f.get(Z.id);W||(W=Zpe(Z.id,f,p),K=!0),q.push({...Z,position:W})}return K&&(w.current=""),{nodes:nme(q,Z=>{if(Z.type==="recapNote")return-1;const W=e.agents.get(Z.id);return W?sme(e,W):0}),edges:R}}function ame(e){return e.slice().sort((t,n)=>t.y-n.y||t.x-n.x)}function ome(e,t,n){var i;if(e.length===0)return null;const s=ame(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 ime=new Set(["ArrowUp","ArrowDown","ArrowLeft","ArrowRight","Escape","Backspace"]);function lme(e,t){return t==null?{kind:"deck",nodeId:null}:e.key==="Enter"||e.key===" "?{kind:"activate",nodeId:t,additive:e.shiftKey}:ime.has(e.key)?{kind:"node",nodeId:t}:{kind:"deck",nodeId:t}}const cme=new Set(["","BODY","HTML","#DOCUMENT"]);function ume(e){return!e||ti(e)?!1:!cme.has(String(e.tagName??"").toUpperCase())}const n8="react-flow__node";function BS(e){var t,n;return!!e&&((n=(t=e.classList)==null?void 0:t.contains)==null?void 0:n.call(t,n8))===!0}function s8(e){try{const t=document.querySelector(`.${n8}[data-id="${CSS.escape(e)}"]`);t==null||t.focus({preventScroll:!0})}catch{}}let ri=null,Sl=null;const Nj=new Set,Sj=()=>{for(const e of Nj)e()},dme=e=>(Nj.add(e),()=>{Nj.delete(e)}),mO=()=>ri,hme=90;function r8(e){!Sl||e!=null&&Sl.at.id!==e||(clearTimeout(Sl.timer),Sl=null)}function a8(e,t,n="pointer"){r8();const s={id:e,anchor:t,by:n};if(ri||n==="focus"){ri=s,Sj();return}Sl={at:s,timer:setTimeout(()=>{Sl=null,ri=s,Sj()},hme)}}function ro(e){r8(e),!(!ri||e!=null&&ri.id!==e)&&(ri=null,Sj())}function fme({agentFor:e,recapFor:t,labelFor:n,bounds:s}){const a=g.useSyncExternalStore(dme,mO,mO),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&&ro(a.id)},[l,a]),!a||l?null:o?r.jsx(mme,{a:o,anchor:a.anchor,parentLabel:o.parentId?n(o.parentId):void 0,bounds:s},a.id):i?r.jsx(pme,{r:i,anchor:a.anchor,bounds:s},a.id):null}function o8(e,t){const n=g.useRef(null),s=g.useCallback(()=>{const a=n.current;if(!a||!e.isConnected)return;a.style.maxHeight="";const o=pm(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 pme({r:e,anchor:t,bounds:n}){var d;const s=o8(t,n),a=Sr(3e4),o=e.note,i=Nr(e.plan),l=(o==null?void 0:o.kind)==="recap",u=ip((o==null?void 0:o.at)??((d=e.plan)==null?void 0:d.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(ap,{recap:l}),o?sc(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?`${im(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 ",pN(i),i.allDone?"":`
|
|
107
|
+
${Xp(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 mme({a:e,anchor:t,parentLabel:n,bounds:s}){const a=o8(t,s),o=Sr(1e3),i=sm(e.sessionName,e.sessionTitle),l=e.toolErrorCount??0,u=e.tools.filter(b=>!b.endedAt).length,d=Wn(e,o).total,f=e.usage.inputTokens+e.usage.outputTokens,p=e.kind==="root"&&Tn(e.waiting),m=_P(e),w=e.kind==="root"?"session":n?`subagent of ${n}`:"subagent",x=[`${e.toolCount} ${e.toolCount===1?"tool":"tools"}`,u>0?`${u} in-flight`:null,f>0?`${St(f)} tok`:null,d>0?`${lt(d)}${Ul(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?"≥ ":"",zl(e.startedAt,e.endedAt,o)]})]}),r.jsxs("div",{className:"node-peek-kind",children:[r.jsxs("span",{className:"node-peek-state","data-kind":R1(Al(e)),children:[r.jsx(XP,{kind:R1(Al(e))}),Wl(Al(e))]}),r.jsx("span",{children:w}),e.model?r.jsx("span",{children:em(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(SN,{}),r.jsxs("span",{className:"node-peek-said",title:sp(e.waiting),children:[r.jsx("span",{className:"node-peek-since",children:r.jsx("b",{children:zl(e.waiting.since,void 0,o)})}),sp(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:[x,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:WP(e.branch)}),r.jsx("p",{className:"node-peek-hint",children:"Click to go to the session · double-click for details"})]}),document.body)}function gme(e){const t=e.minZoom??nde,n=e.maxZoom??sde,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,d=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,x,b,j,k,v)=>{let S=w+(x-j*p)/2-b*p;const C=k*p+S,_=(k+v)*p+S;return v*p<=x?C<w?S+=w-C:_>w+x&&(S-=_-(w+x)):S+=w-C,S};return{x:m(a,i,u.x,u.width,d.x,d.width),y:m(o,l,u.y,u.height,d.y,d.height),zoom:p}}function yme(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 Bn(e){const t=g.useRef(e);return t.current=e,t}const Cj=80,_j=.86;function i8(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 wme({canvasRef:e,canvasSize:t,machinePhase:n,usagePhase:s,usagePanelOpen:a,detailShown:o}){const[i,l]=g.useState(0);g.useEffect(()=>{const p=i8(e.current);l(m=>Math.abs(m-p)>40?p:m)},[n,s,a,o,t.w]);const u=Bn(i),d=t.w>0?Math.max(0,(t.w-i-Cj*2)*_j):0,f=t.h>0?Math.max(0,(t.h-Cj*2)*_j):0;return{railInsetRef:u,availableWidth:d,availableHeight:f}}const gO=1e-6;function Bu(e){return Number.isFinite(e[0])&&Number.isFinite(e[1])&&Number.isFinite(e[2])&&e[2]>0}function yO(e,t,n){return Math.abs(e[2]-t[2])<=gO*t[2]&&Math.hypot(e[0]-t[0],e[1]-t[1])<=gO*n}function xme(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 vme(e,t,n){const s=e(0),a=e(.5),o=e(1);if(!Bu(s)||!Bu(a)||!Bu(o))return!1;const i=Math.max(t[2],n[2]);return yO(s,t,i)&&yO(o,n,i)}function bme(e){return(t,n)=>{const s=e(t,n),a=vme(s,t,n)?s:xme(t,n);let o=Bu(t)?t:n;return i=>{const l=a(i);return Bu(l)&&(o=l),o}}}function kme(e){return Number.isFinite(e.x)&&Number.isFinite(e.y)&&Number.isFinite(e.zoom)&&e.zoom>0}const wO=new WeakSet,l8=420;function jme(){const e=Ql(),t=Ht(),n=g.useCallback((d,f)=>{if(!kme(d))return;if(S1({durationMs:f,documentHidden:document.hidden})){e.setViewport(d,{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&&d.zoom>0){p.transform(m,w.scale(d.zoom/w.k).translate((d.x-w.x)/d.zoom,(d.y-w.y)/d.zoom));return}e.setViewport(d,{duration:0})},[e,t]);g.useEffect(()=>{const d=f=>{!f||wO.has(f)||(wO.add(f),f.interpolate(bme(f.interpolate())))};return d(t.getState().d3Zoom),t.subscribe(f=>d(f.d3Zoom))},[t]);const s=g.useRef(null),a=g.useRef(0),o=g.useRef(0),i=g.useCallback((d,f)=>{const p=++a.current;return o.current=Date.now(),n(d,f),s.current=S1({durationMs:f,documentHidden:document.hidden})?{target:d,until:Date.now()+f+60}:null,p},[n]),l=g.useCallback((d=500)=>{const f=Cj,p=1,m=.2,w=_j;try{const x=document.querySelector(".canvas-wrap"),b=Array.from(document.querySelectorAll(".react-flow__node")).filter(P=>P.offsetWidth>0);if(!x||b.length===0)return;const j=x.getBoundingClientRect(),k=e.getViewport();if(!Number.isFinite(k.zoom)||k.zoom<=0)return;const v=new Map(e.getNodes().map(P=>[P.id,P])),S=b.flatMap(P=>{const q=v.get(P.dataset.id??"");if(!q)return[];const K=q.positionAbsolute??q.position,z=q.width??P.offsetWidth,H=q.height??P.offsetHeight;return z>0&&H>0?[{left:K.x,right:K.x+z,top:K.y,bottom:K.y+H}]:[]});if(S.length===0)return;const C=Math.min(...S.map(P=>P.left)),_=Math.max(...S.map(P=>P.right)),R=Math.min(...S.map(P=>P.top)),A=Math.max(...S.map(P=>P.bottom)),I=_-C,$=A-R;if(!(I>0&&$>0))return;const U=i8(x),F=P=>Math.max(m,Math.min(p,(j.width-U-f*2)/(I+P)*w,(j.height-f*2)/$*w)),M=tde(F(l8),F(0),X6(VN[GN()])),B={x:f-C*M,y:(j.height>j.width-U?f:Math.max(f,(j.height-$*M)/2))-R*M,zoom:M},T=i(B,d);window.setTimeout(()=>{var P;try{if(((P=s.current)==null?void 0:P.target)===B&&(s.current=null),a.current!==T)return;const q=e.getViewport();(Math.abs(q.zoom-M)>.01||Math.abs(q.x-B.x)>2||Math.abs(q.y-B.y)>2)&&n(B,0)}catch{}},d+60)}catch{}},[e,n,i]);g.useEffect(()=>{const d=()=>{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",d),()=>document.removeEventListener("visibilitychange",d)},[n]);const u=g.useCallback(()=>e.getViewport(),[e]);return{applyViewport:n,moveCamera:i,fitLeft:l,currentViewport:u,cameraEpochRef:a,lastFitTimeRef:o}}const Nme=450;function Sme({canvasRef:e,stateRef:t,measuredRef:n,nodesRef:s,railInsetRef:a,moveCamera:o,disableAutoFit:i,lastFocusRef:l,focusAgentRef:u,selectAgent:d,primarySelectedIdRef:f}){const p=g.useCallback(x=>{const b=e.current,j=t.current.agents.get(x);if(!b||!j)return;const k=FS(t.current),v=(I,$)=>{const U=n.current.get(I.id);if(!U)return null;const F=$&&k.has(I.id)?l8:0;return{x:I.position.x,y:I.position.y,width:U.width+F,height:U.height}},S=s.current.find(I=>I.id===x),C=S?v(S,!1):null;if(!C)return;const _=[];for(const I of s.current){if(I.type!=="agent"&&I.type!=="recapNote"||un(I)!==un(S))continue;const $=v(I,I.type==="agent");$&&_.push($)}const R=b.getBoundingClientRect(),A=gme({pane:{width:R.width,height:R.height},insets:{top:56,left:72,bottom:32,right:a.current+32},context:yme(_)??C,anchor:C});ro(),i(),l.current={id:x,at:Date.now()},o(A,Nme)},[o,i]);u.current=p;const m=g.useCallback(x=>{const b=s.current.filter(S=>S.type==="agent"),j=ome(b.map(S=>({id:S.id,x:S.position.x,y:S.position.y})),f.current,x),k=j?b.find(S=>S.id===j):void 0;if(!k)return;const v=BS(document.activeElement);d(k.id,!1),window.setTimeout(()=>{try{p(k.id)}catch{}v&&s8(k.id)},30)},[d,p]),w=g.useCallback(x=>{d(x,!1),window.setTimeout(()=>{try{p(x)}catch{}},60)},[d,p]);return{focusAgent:p,stepAgent:m,focusSession:w}}function Cme({nodesRef:e,stateRef:t,canvasRef:n,railInsetRef:s}){const a=g.useCallback(u=>{const d=e.current.find(f=>f.id===u&&f.type==="agent");return d?d.data:void 0},[]),o=g.useCallback(u=>{var d;return(d=t.current.agents.get(u))==null?void 0:d.label},[]),i=g.useCallback(u=>{var p;const d=e.current.find(m=>m.id===u&&m.type==="recapNote");if(!d)return;const f=d.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(),d=document.documentElement;return u?{width:u.right-s.current,height:u.bottom}:{width:d.clientWidth,height:d.clientHeight}},[]);return{peekAgent:a,peekLabel:o,peekRecap:i,peekBounds:l}}function _me(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 xO(e){return Object.entries(e??{}).filter(([,t])=>t&&typeof t.x=="number"&&typeof t.y=="number")}function Eme(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=xO(n);return{positions:a,pins:a.map(([o])=>o)}}const s=n;return{positions:xO(s.positions),pins:Array.isArray(s.pins)?s.pins:[]}}function Tme(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 Ame(e){if(!e)return null;let t;try{t=JSON.parse(e)}catch{return null}return!(typeof(t==null?void 0:t.width)=="number"&&typeof(t==null?void 0:t.height)=="number")||!(t.width>0&&t.height>0)?null:{width:t.width,height:t.height}}const Rd="agent-dag.layout",Md="agent-dag.layoutFrame",$d="agent-dag.viewport";function Rme(){return Eme(nt(Rd))}function Ol(e,t){st(Rd,Tme(e,t))}function Mme(){return Ame(nt(Md))}function c8(e){st(Md,JSON.stringify(e))}function $me(){return P9(nt($d))}function Lme(e){st($d,JSON.stringify(e))}function Ime(){return{layout:nt(Rd),frame:nt(Md),viewport:nt($d)}}function Ome(e){const t=(n,s)=>s===null?vs(n):st(n,s);t(Rd,e.layout),t(Md,e.frame),t($d,e.viewport)}function u8(){vs(Rd),vs($d),vs(Md)}function Pme({fitLeft:e,moveCamera:t,currentViewport:n}){const s=g.useState(()=>_me(Rme()))[0],a=g.useRef(s.pinned),o=g.useRef(s.positions),i=g.useRef(new Set),l=g.useRef(new Set),u=g.useRef(""),[d,f]=g.useState(0),p=g.useState(Mme)[0],m=g.useRef(p),[w,x]=g.useState(!1),[b,j]=g.useState(""),k=g.useState(()=>XZ(U=>{x(U),U||j(F=>F===nA?F:"")}))[0];g.useEffect(()=>()=>k.close(),[k]),g.useEffect(()=>{if(typeof document>"u")return;const U=()=>document.hidden?k.hold("hidden"):k.release("hidden");return document.addEventListener("visibilitychange",U),()=>document.removeEventListener("visibilitychange",U)},[k]);const v=g.useRef(null),S=()=>({positions:o.current,pinned:a.current,provisional:i.current,layoutSig:u}),C=g.useCallback(()=>{k.open(k.snapshot??WZ(S(),Ime(),n())),j(KZ),a.current.clear(),o.current.clear(),u.current="",u8(),f(U=>U+1),v.current!=null&&window.clearTimeout(v.current),v.current=window.setTimeout(()=>{v.current=null,Ol(o.current,a.current),m.current&&c8(m.current),e(500)},80)},[e,n,k]),_=g.useCallback(()=>{const U=k.take();return U?(v.current!=null&&window.clearTimeout(v.current),v.current=null,HZ(U,S()),Ome(U.stored),f(F=>F+1),U.viewport&&t(U.viewport,500),j(nA),!0):!1},[t,k]),R=g.useCallback(()=>k.close(),[k]),A=g.useCallback(U=>k.hold(U),[k]),I=g.useCallback(U=>k.release(U),[k]);return{restoredLayout:s,pinnedRef:a,positionsRef:o,provisionalRef:i,returningRef:l,lastLayoutSigRef:u,layoutEpoch:d,setLayoutEpoch:f,lastLayoutFrameRef:m,handleRelayout:C,rearrangeUndo:{open:w,said:b,undo:_,dismiss:R,hold:A,release:I}}}function Dme(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(()=>{Ol(n.current,s.current)},1500),()=>{a.current!=null&&window.clearTimeout(a.current)}),[e])}function Fme({nodes:e,edges:t,settled:n,dragging:s,availableWidth:a,availableHeight:o,layout:i,camera:l,rf:u,measuredRef:d,stateRef:f,lastFocusRef:p,primarySelectedIdRef:m,focusAgentRef:w,autoFitDisabledRef:x}){const{lastLayoutFrameRef:b,pinnedRef:j,positionsRef:k,provisionalRef:v,lastLayoutSigRef:S,setLayoutEpoch:C}=i,{applyViewport:_,fitLeft:R,cameraEpochRef:A,lastFitTimeRef:I}=l;g.useEffect(()=>{if(!n||s)return;const $={width:a,height:o};if(!($.width>0&&$.height>0))return;const U=b.current;if(b.current=$,c8($),!U||U.width===$.width&&U.height===$.height)return;const F={direction:"LR",pinned:j.current,measured:d.current,lanes:FS(f.current)},M=p.current&&Date.now()-p.current.at<1500?p.current.id:null;if(!Kpe(e,t,F,U,$)){const P=A.current,q=window.setTimeout(()=>{var K;A.current===P&&(x.current?M&&((K=p.current)==null?void 0:K.id)===M&&w.current(M):R(500))},80);return()=>window.clearTimeout(q)}const B=M??m.current,T=B?j.current.get(B)??k.current.get(B):void 0;for(const P of Array.from(k.current.keys()))j.current.has(P)||k.current.delete(P);v.current.clear(),S.current="",C(P=>P+1),window.setTimeout(()=>{if(Ol(k.current,j.current),x.current){if(M){w.current(M);return}const P=B?j.current.get(B)??k.current.get(B):void 0;if(T&&P&&(P.x!==T.x||P.y!==T.y)){const q=u.getViewport();A.current+=1,_({x:q.x-(P.x-T.x)*q.zoom,y:q.y-(P.y-T.y)*q.zoom,zoom:q.zoom},0),I.current=Date.now()}return}R(500)},80)},[a,o,n,s,R,u,_])}function Bme(e,t,n,s,a){const o=[];for(const i of e)!fm(i,t)||n.has(i.id)||o.push(i.id+(i.parentId?`>${i.parentId}`:""));return o.sort(),`${o.join("|")}#sv${s}.${a}`}const qS="agent-dag.removedNodes";function qme(e){try{const t=JSON.parse((e==null?void 0:e.getItem(qS))??"[]");return new Set(Array.isArray(t)?t.filter(n=>typeof n=="string"):[])}catch{return new Set}}function z0(e,t){try{e==null||e.setItem(qS,JSON.stringify([...t]))}catch{}}function d8(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 Ume(e,t){if(t.size===0)return new Set;const n=[...e],s=d8(n,t);return new Set(n.filter(s).map(a=>a.id))}function Wme(e,t,n){const s=l=>({id:l.id,parentId:l.data.parentId,sessionId:l.data.sessionId}),a=d8(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 Hme(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 zme(e,t){return t.size===0?[]:[...e].filter(n=>t.has(n.id)).map(n=>n.id)}function h8(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=h8(l);if(u<=a)continue;const d=[],f=new Set,p=w=>{var x;for(let b=w;b&&!f.has(b);b=(x=e.get(b))==null?void 0:x.parentId)f.add(b),n.has(b)&&d.push(b)};p(l.id),p(l.sessionId);let m=-1/0;for(const w of d)m=Math.max(m,s.get(w)??1/0);if(u>m)for(const w of d)o.add(w)}return[...o]}const Mp="sessionGroup";function Kme(e,t){var s,a;if(e.type===Mp)return"transparent";if(Tn((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 Cf=Zo;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,d=l+o,f=u+i,p=t.get(un(s));p?(p.minX=Math.min(p.minX,l),p.minY=Math.min(p.minY,u),p.maxX=Math.max(p.maxX,d),p.maxY=Math.max(p.maxY,f)):t.set(un(s),{minX:l,minY:u,maxX:d,maxY:f})}const n=[];for(const[s,a]of t){const o=a.maxX-a.minX+Cf*2,i=a.maxY-a.minY+Cf*2;n.push({id:`group:${s}`,type:Mp,position:{x:a.minX-Cf,y:a.minY-Cf},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(()=>Bme(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:d,selectedIds:f,openContext:p,historyReplayed:m,removedNodes:w,removedAgentIds:x,dragTick:b,dragPatchRef:j,dragMoveTick:k}){const{pinnedRef:v,positionsRef:S,provisionalRef:C,returningRef:_,lastLayoutSigRef:R,restoredLayout:A,layoutEpoch:I}=a,$=g.useMemo(()=>Zme(e.current,f),[e.current,e.current.revision,f]),U=g.useMemo(()=>{const K=sQ(e.current,t);for(const z of x)K.delete(z);return K},[e.current,e.current.revision,t,x]),F=g.useRef(new Map),M=SK(),{nodes:B,edges:T}=g.useMemo(()=>{const K=rme(e.current,t,n,s,v.current,o.current,F.current,i,l,u,S.current,C.current,d,R,f,$,U,p,m,A.restored,_.current);return Wme(K.nodes,K.edges,w)},[e.current,e.current.revision,t,n,s,l,u,d,f,$,U,p,b,M,w,I,m]),P=g.useMemo(()=>Yme(B),[B]),q=g.useMemo(()=>{const K=[...P,...B],z=j.current;return!z||z.size===0?K:K.map(H=>{const D=z.get(H.id);return D?{...H,position:D}:H})},[P,B,k]);return{spotlightSet:$,visibleAgentIds:U,nodes:B,edges:T,allNodes:q}}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:d,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 x=n.current,b=Date.now(),j=[];for(const v of x.agents.values())fm(v,b)&&j.push({id:v.id});if(j.length===0)return;const k=[];for(const{id:v}of j){const S=s.current.get(v),C=a.current.get(v)??o.current.get(v);!S||!C||k.push({x:C.x,y:C.y,width:S.width,height:S.height})}tge({pane:i.current,viewport:t.getViewport(),boxes:k})&&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()-d.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,returningRef:s,canvasRef:a,clearSelection:o,primarySelectedId:i}){const[l,u]=g.useState(()=>qme(gr())),[d,f]=g.useState(null),p=g.useMemo(()=>Ume(e.current.agents.values(),l),[e.current,e.current.revision,l]),m=g.useCallback(S=>{const C=e.current.agents.get(S);C&&(u(_=>{const R=new Set(_);return R.add(S),z0(gr(),R),R}),f({id:S,label:C.label}),t.current.delete(S),n.current.delete(S),o())},[o]),w=g.useCallback(()=>{i&&m(i)},[i,m]),x=d&&l.has(d.id)?d:null;g.useEffect(()=>{var S;d&&((S=a.current)==null||S.focus())},[d]);const b=g.useCallback(S=>{const C=[...S];u(_=>{let R=null;for(const A of C)_.has(A)||(R??(R=new Set(_)),R.add(A));return R?(z0(gr(),R),R):_})},[]),j=g.useCallback(S=>{const C=[...S];u(_=>{var A;const R=Hme(_,C);R!==_&&z0(gr(),R);for(const I of C)R!==_&&_.has(I)&&((A=e.current.agents.get(I))==null?void 0:A.kind)==="root"&&s.current.add(I);return R})},[]),k=g.useCallback(()=>{j([...l]),f(null)},[j,l]),v=g.useCallback(()=>{u(new Set),f(null),vs(qS)},[]);return{removedNodes:l,lastRemoval:d,removedAgentIds:p,removeNode:m,removeSelectedNode:w,removalNotice:x,hideSessions:b,bringBack:j,bringBackAll:k,forgetRemovals:v}}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=[...zme(t,n),...Gme(e.current.agents,n,s,o.current)];i.length>0&&a(i)},[t,n,s,a])}const f8=[0,5,15,30,60],US="agent-dag.hide-finished-after",p8="agent-dag.hide-finished-turns",age=300,oge=1e4;function WS(e){const t=Number(e);return f8.includes(t)?t:0}function ige(e){return e===0?"Never":`${e} min`}let ai=null;const Eu=new Set;function m8(){for(const e of Eu)e()}function vO(){return ai===null&&(ai=WS(nt(US))),ai}function lge(e){const t=WS(String(e));ai!==t&&(ai=t,st(US,String(t)),m8())}function bO(e){if(e.key!==US)return;const t=WS(e.newValue);t!==ai&&(ai=t,m8())}function cge(e){var t;return Eu.add(e),Eu.size===1&&typeof window<"u"&&((t=window.addEventListener)==null||t.call(window,"storage",bO)),()=>{var n;Eu.delete(e),Eu.size===0&&typeof window<"u"&&((n=window.removeEventListener)==null||n.call(window,"storage",bO))}}function uge(e){try{const t=JSON.parse((e==null?void 0:e.getItem(p8))??"{}");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 kO(e,t){const n=[...t].sort((s,a)=>a[1]-s[1]).slice(0,age);try{e==null||e.setItem(p8,JSON.stringify(Object.fromEntries(n)))}catch{}}function g8(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"&&Tn(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 g8(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=g8(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 fge(e,t){if(t.size===0)return!1;const n=new Map;for(const a of e.agents.values()){if(!t.has(a.sessionId))continue;const o=h8(a);o>(n.get(a.sessionId)??-1/0)&&n.set(a.sessionId,o)}let s=!1;for(const a of e.agents.values()){if(a.kind!=="subagent"||a.state!=="done"||a.endedAt==null||a.exitAt!=null)continue;const o=t.get(a.sessionId);o==null||a.endedAt>o||!((n.get(a.sessionId)??-1/0)>o)||(a.exitAt=o,s=!0)}return s&&(e.revision+=1),s}function y8(){return g.useSyncExternalStore(cge,vO,vO)}function pge({stateRef:e,removedNodes:t,hideSessions:n,keepSessionId:s,ready:a}){const o=y8(),[i]=g.useState(()=>uge(gr())),l=g.useRef(i),u=g.useRef(t);g.useEffect(()=>{const d=hge(l.current,u.current,t,e.current.agents.values());u.current=t,d!==l.current&&(l.current=d,kO(gr(),d))},[t]),g.useEffect(()=>{a&&fge(e.current,l.current)},[a,e.current,e.current.revision]),g.useEffect(()=>{if(!a||o===0)return;const d=()=>{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:x}of p)m.set(w,x);l.current=m,kO(gr(),m),n(p.map(w=>w.id))};d();const f=window.setInterval(d,oge);return()=>window.clearInterval(f)},[a,o,t,s,n])}function mge({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 w8=Object.freeze({offline:"/state/favicon-error.svg",waiting:"/state/favicon-waiting.svg",running:"/state/favicon-syncing.svg",idle:"/favicon.svg"}),x8=Object.freeze({offline:"/state/favicon-error-32.png",waiting:"/state/favicon-waiting-32.png",running:"/state/favicon-syncing-32.png",idle:"/favicon.ico"}),gge=Object.freeze([...new Set([...Object.values(w8),...Object.values(x8)])]),Ej=new Map;function jO(e){return Ej.get(e)??e}async function yge(e,t=n=>fetch(n)){await Promise.all(e.map(async n=>{if(!Ej.has(n))try{const s=await t(n),a=(s.headers.get("Content-Type")??"").split(";")[0].trim();if(!s.ok||!a.startsWith("image/"))return;Ej.set(n,`data:${a};base64,${wge(new Uint8Array(await s.arrayBuffer()))}`)}catch{}}))}function wge(e){let t="";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return btoa(t)}function xge({stateRef:e,waitingSessions:t,live:n}){const s=g.useMemo(()=>_G(e.current.agents.values()),[e.current,e.current.revision]),a=g.useRef(null);g.useEffect(()=>{n&&yge(gge)},[n]),g.useEffect(()=>{const o=mge({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&&v8(o.icon)},[t.length,s,n])}function v8(e){const t=document.querySelector('link[rel="icon"][type="image/svg+xml"]');t&&(t.href=jO(w8[e]));const n=document.querySelector('link[rel="icon"][sizes="32x32"]');n&&(n.href=jO(x8[e]))}const vge=1200,bge=1e3;function V0(e){return e.lastDeckFitAt>0&&e.at-e.lastDeckFitAt<vge?!1:e.hasSourceEvent?!0:e.lastCanvasInputAt>0&&e.at-e.lastCanvasInputAt<bge}function kge({applyViewport:e,lastFitTimeRef:t,cameraEpochRef:n,disableAutoFit:s,markInteract:a,canvasRef:o,applyZoom:i}){const l=g.useState(()=>$me())[0];g.useEffect(()=>{if(!l)return;const x=window.setTimeout(()=>{try{e(l,0)}catch{}t.current=Date.now()},60);return()=>window.clearTimeout(x)},[e,l]);const u=g.useRef(null),d=g.useRef(0),f=g.useCallback(()=>{d.current=Date.now()},[]),p=g.useCallback(x=>({hasSourceEvent:!!x,at:Date.now(),lastDeckFitAt:t.current,lastCanvasInputAt:d.current}),[]);return{restoredViewport:l,markCanvasInput:f,onMoveStart:x=>{ro(),V0(p(x))&&(n.current+=1),V0(p(x))&&s()},onMove:(x,b)=>{var j;a(),V0(p(x))&&s(),(j=o.current)==null||j.style.setProperty("--zoom",String(b.zoom)),i(b.zoom)==="detail"&&ro(),u.current&&window.clearTimeout(u.current),u.current=window.setTimeout(()=>Lme(b),250)}}}function jge({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[d]=g.useState(()=>AD({focus:b=>u.current(b),setTimeout:(b,j)=>window.setTimeout(b,j),clearTimeout:b=>window.clearTimeout(b)}));return g.useEffect(()=>()=>d.cancel(),[d]),{onNodeClick:(b,j)=>{if(j.type==="sessionGroup"){d.cancel(),e();return}const k=j.type==="recapNote"?j.data.parentId:j.id;t(k,b.shiftKey,!1),!b.shiftKey&&(n&&s(!1),xd()?d.hold(k):a?window.setTimeout(()=>{try{o(k)}catch{}},80):o(k))},onPaneClick:()=>{d.cancel(),ro(),e()},onNodeDoubleClick:(b,j)=>{if(j.type!=="agent"&&j.type!=="recapNote")return;d.cancel();const k=j.type==="recapNote"?j.data.parentId:j.id;t(k,!1),window.setTimeout(()=>{try{o(k)}catch{}},80)},onNodeMouseEnter:(b,j)=>{j.type!=="agent"&&j.type!=="recapNote"||i.current||l.current==null||l.current==="detail"||a8(j.id,b.currentTarget)},onNodeMouseLeave:(b,j)=>ro(j.id)}}function Nge({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 d=e()-t();if(d>0){o=s(()=>{o=null,n(l,u)},d);return}n(l,u)},dispose:i}}function Sge(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=Nge({settleAt:()=>(e==null?void 0:e.current)??0,now:()=>performance.now(),take:(u,d)=>a(f=>Math.abs(f.w-u)>40||Math.abs(f.h-d)>40?{w:u,h:d}:f),schedule:(u,d)=>window.setTimeout(u,d),cancel:u=>window.clearTimeout(u)}),l=new ResizeObserver(u=>{var f;const d=(f=u[0])==null?void 0:f.contentRect;d&&(t.current={width:d.width,height:d.height},i.read(d.width,d.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 Cge(e){const t=Ht(),n=g.useRef(new Map),s=g.useRef(0),a=g.useRef(new Map),[o,i]=g.useState(0),[l,u]=g.useState(0),d=g.useRef(null),f=g.useCallback(()=>{d.current=null;let m=!1;for(const x of t.getState().nodeInternals.values()){if(x.type===Mp)continue;const b=x.width,j=x.height;if(b==null||j==null)continue;const k=a.current.get(x.id);(!k||Math.abs(k.width-b)>4||Math.abs(k.height-j)>4)&&(a.current.set(x.id,{width:b,height:j}),n.current.set(x.id,{width:b,height:j}),m=!0)}if(m&&(s.current+=1,i(s.current)),e.current)return;let w=!1;for(const x of document.querySelectorAll(".react-flow__node[data-id]")){if(x.classList.contains(`react-flow__node-${Mp}`))continue;const b=x.getAttribute("data-id");if(!b)continue;const j=x.offsetWidth,k=x.offsetHeight;if(!j||!k)continue;const v=n.current.get(b);(!v||Math.abs(v.width-j)>4||Math.abs(v.height-k)>4)&&(n.current.set(b,{width:j,height:k}),w=!0)}w&&u(x=>x+1)},[t,e]),p=g.useCallback(()=>{d.current||(d.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=d.current;w&&(cancelAnimationFrame(w.frame),window.clearTimeout(w.timer),d.current=null)}},[t,p]),g.useEffect(p),{measuredRef:n,measuredVersionRef:s,sizeVersion:o,domSizeVersion:l}}function _ge(){const[e,t]=g.useState(!1);return g.useEffect(()=>{const n=window.setTimeout(()=>t(!0),2500);return()=>window.clearTimeout(n)},[]),e}function Ege(){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 Tge({pointerFocusRef:e,nodesRef:t,stateRef:n,primarySelectedIdRef:s,providersRef:a,soundOnRef:o,keyHelpOpenRef:i,modalOpenRef:l,waitingCursorRef:u,removeSelectedRef:d,activateSoundRef:f,clearSelection:p,selectAgent:m,focusAgent:w,stepAgent:x,focusSession:b,requestClear:j,handleRelayout:k,undoRearrange:v,handleFit:S,togglePause:C,toggleSessionList:_,toggleAccountsPanel:R,setDetailOpen:A,setUsageHistoryOpen:I,setUsagePanelOpen:$,setMachinePanelOpen:U,setBrowserWatchOpen:F,setKeyHelpOpen:M,setTheme:B,openSettings:T,openIntegrationRef:P,openQuickOpen:q}){g.useEffect(()=>{const K=z=>{var W,X;const H=z.target,D={tagName:H==null?void 0:H.tagName,isContentEditable:H==null?void 0:H.isContentEditable,role:(W=H==null?void 0:H.getAttribute)==null?void 0:W.call(H,"role"),type:H==null?void 0:H.type,pointerFocused:H!=null&&H===e.current};if(z.key==="Escape"){const Y=YG({overlayOpen:ln.depth()>0,typing:ti(D)});Y==="dismiss"?ln.dismissTop():Y==="blur"?H==null||H.blur():(ume(D)&&(H==null||H.blur()),p());return}if(DD(z,co(to()))){if(ml({appModal:l.current,dialogDepth:ln.dialogDepth()}))return;z.preventDefault(),z.repeat||q();return}if(z.key===","&&yee(z)){if(ti(D)||ml({appModal:l.current,dialogDepth:ln.dialogDepth()}))return;z.preventDefault(),z.repeat||T();return}if(ZZ(z)){if(ti(D)||ml({appModal:l.current,dialogDepth:ln.dialogDepth()}))return;!z.repeat&&v()&&z.preventDefault();return}if(am(z))return;const O=BS(H)?(X=H==null?void 0:H.getAttribute)==null?void 0:X.call(H,"data-id"):null,V=O&&t.current.some(Y=>Y.id===O)?O:null,Z=lme(z,V);if(Z.kind==="activate"){z.preventDefault(),m(Z.nodeId,Z.additive);return}if(Z.kind!=="node"&&!FY(z.key,O1())){if(rK({key:z.key,sheetOpen:i.current,target:D})){z.repeat||M(!1);return}if(z.key==="t"||z.key==="T"){const Y=ml({appModal:l.current,dialogDepth:ln.dialogDepth()});if(Z.nodeId==null&&aK({target:D,modalOpen:Y}))return;z.repeat||B(cte);return}if(!(Z.nodeId==null&&IP(D,z.key))&&!sK({key:z.key,modalOpen:ml({appModal:l.current,dialogDepth:ln.dialogDepth()}),sheetOpen:i.current})&&!(z.repeat&&!/^[ jkJK]$/.test(z.key))){if(z.key===" "&&(z.preventDefault(),z.repeat||C()),(z.key==="c"||z.key==="C")&&j("shortcut"),(z.key==="r"||z.key==="R")&&k(),(z.key==="f"||z.key==="F")&&S(),(z.key==="z"||z.key==="Z")&&s.current&&w(s.current),z.key==="Delete"&&d.current(),(z.key==="l"||z.key==="L")&&_(),z.key==="d"||z.key==="D")if(s.current)A(Y=>!Y);else{const Y=T1(n.current.agents.values());Y.length>0?b(Y[0].id):x(1)}if((z.key==="h"||z.key==="H")&&I(Y=>!Y),(z.key==="u"||z.key==="U")&&$(Y=>!Y),(z.key==="a"||z.key==="A")&&a.current.claude&&R(),(z.key==="j"||z.key==="J")&&x(1),(z.key==="k"||z.key==="K")&&x(-1),z.key==="w"||z.key==="W"){const Y=CG(T1(n.current.agents.values()),u.current);Y&&(u.current=Y.id,b(Y.id))}(z.key==="m"||z.key==="M")&&o.current!==null&&f.current(z.shiftKey),(z.key==="s"||z.key==="S")&&U(Y=>!Y),(z.key==="b"||z.key==="B")&&F(Y=>!Y),(z.key==="v"||z.key==="V")&&T("sounds"),(z.key==="i"||z.key==="I")&&(P==null||P.current("jira")),z.key==="?"&&M(Y=>!Y)}}};return window.addEventListener("keydown",K),()=>window.removeEventListener("keydown",K)},[j,k,v,S,p,m,x,b,w,C])}function Age(){var e,t;return((t=(e=document.activeElement)==null?void 0:e.matches)==null?void 0:t.call(e,":focus-visible"))===!0}function Rge({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=d=>()=>{Age()&&d()};return{toggles:l,sessionList:u(ea(!e,l.sessionList)),usage:u(ea(!t,l.usage)),machine:u(ea(!n,l.machine)),accounts:u(ea(!s,l.accounts)),detail:u(ea(!a,()=>{var d,f;o&&s8(o),Hn(((d=document.activeElement)==null?void 0:d.tagName)??null)&&((f=i.current)==null||f.focus({preventScroll:!0}))}))}}function Mge({nodes:e,stateRef:t,pinnedRef:n,positionsRef:s,draggingRef:a,dragPatchRef:o,setDragging:i,setDragMoveTick:l,setDragTick:u,endBubble:d,markInteract:f,disableAutoFit:p,beginTrashDrag:m,trackTrashDrag:w,endTrashDrag:x,removeNode:b}){const j=g.useRef(null);return{onNodeDragStart:(C,_)=>{var R,A;if(_){if(ro(),d(),a.current=!0,o.current=new Map,i(!0),f(),p(),_.type==="sessionGroup"){const I=(R=_.data)==null?void 0:R.sessionId,$=new Map,U=new Map;if(I)for(const M of e)!M.data||un(M)!==I||($.set(M.id,{x:M.position.x,y:M.position.y}),U.set(M.id,n.current.get(M.id)));j.current={sessionId:I,start:{x:_.position.x,y:_.position.y},members:$,pinsBefore:U};const F=I?t.current.agents.get(I):void 0;m(F?F.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:(C,_)=>{var R;if(_){if(f(),(_.type==="agent"||_.type==="sessionGroup")&&w(C),_.type==="sessionGroup"){const A=j.current;if(!A)return;const I=_.position.x-A.start.x,$=_.position.y-A.start.y;for(const[F,M]of A.members){const B={x:M.x+I,y:M.y+$};n.current.set(F,B),s.current.set(F,B)}const U=o.current;if(U){for(const[F,M]of A.members)U.set(F,{x:M.x+I,y:M.y+$});U.set(_.id,{x:_.position.x,y:_.position.y})}l(F=>F+1);return}n.current.set(_.id,{x:_.position.x,y:_.position.y}),s.current.set(_.id,{x:_.position.x,y:_.position.y}),(R=o.current)==null||R.set(_.id,{x:_.position.x,y:_.position.y}),l(A=>A+1)}},onNodeDragStop:(C,_)=>{f();const R=x(C,(_==null?void 0:_.type)==="agent"||(_==null?void 0:_.type)==="sessionGroup");if(a.current=!1,o.current=null,i(!1),u(A=>A+1),!_){j.current=null,Ol(s.current,n.current);return}if(_.type==="sessionGroup"){const A=j.current;if(A&&R&&A.sessionId){for(const[I,$]of A.members){const U=A.pinsBefore.get(I);U?n.current.set(I,U):n.current.delete(I),s.current.set(I,$)}j.current=null,b(A.sessionId);return}if(A){const I=_.position.x-A.start.x,$=_.position.y-A.start.y;for(const[U,F]of A.members){const M={x:F.x+I,y:F.y+$};n.current.set(U,M),s.current.set(U,M)}}j.current=null,Ol(s.current,n.current),u(I=>I+1);return}if(n.current.set(_.id,{x:_.position.x,y:_.position.y}),s.current.set(_.id,{x:_.position.x,y:_.position.y}),R){b(_.id);return}Ol(s.current,n.current)}}}function $ge(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 b8({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 Lge({reservedRight:e=0}){return r.jsx("div",{className:"empty-stage",style:{right:e},children:r.jsxs("div",{className:"empty-hero",children:[r.jsx(b8,{}),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 Ige({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(b8,{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."]})]}):Oge(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(ld,{film:"tour",action:!0})]})]})})}function Oge(e,t){const n=$ge(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?"}),vse(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 Pge=1;function Dge(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 Fge(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:Pge,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(Dge)}))}}function Bge(e,t){const n=(e||"session").replace(/[^a-z0-9._-]/gi,"_");return`${Pt}-${n}-${fp(t,8)}.json`}const k8={file:"📁",shell:"⚡",web:"🌐",agent:"🤖",task:"📋",plan:"🧭",mcp:"🔌",other:"✨"},qge={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 Uge({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:qge[e]})})}const $p={file:"file",shell:"shell",web:"web",agent:"agent",task:"task",plan:"plan",mcp:"mcp",other:"other"},j8=zP;function Wge({agent:e,now:t,onOpenTool:n,onShowSummary:s,onExportSession:a,onRemove:o,singleKeys:i=!0}){var j;const l=`${e.synthetic?"≥ ":""}${zl(e.startedAt,e.endedAt,t)}`,u=Wn(e),d=u.total>0,f=e.usage.inputTokens+e.usage.outputTokens,p=new Map;for(const[k,v]of e.toolCountByName??[]){const S=j8(k);p.set(S,(p.get(S)??0)+v)}const m=e.toolErrorCount??0,w=e.tools.filter(k=>!k.endedAt).length,x=Array.from(p.entries()).sort((k,v)=>v[1]-k[1]),b=p.has("mcp")?iY(((j=e.toolCountByName)==null?void 0:j.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:nm(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 k=wN(e);return r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"hero-sep",children:"·"}),r.jsxs("span",{className:"model-chip","data-family":Qp(e.model),title:k.length>0?`${ed(e.model,e.effort)}
|
|
108
|
+
spend on this panel also covers:
|
|
109
|
+
${k.join(`
|
|
110
|
+
`)}`:ed(e.model,e.effort),children:[em(e.model,e.effort),k.length>0?` +${k.length}`:""]})]})})()]}),d&&r.jsxs("div",{className:"hero-cost",children:[r.jsxs("div",{className:"hero-cost-headline",children:[r.jsx("span",{className:"hero-cost-value",children:lt(u.total)}),r.jsx("span",{className:"hero-cost-label",children:"spend"})]}),r.jsx(ZN,{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; ${En("the session list","L",i)} brings it back`:`Take this card and the ones under it off the board (Delete). ${En("The session list","L",i)} brings it back`,children:"Remove from board"})]})]}),r.jsx(EY,{agent:e}),(()=>{const k=kN(e);if(!k)return null;const v=ip(k.at,t),S=k.kind==="recap"?"Recap":sc(k.kind).replace(/^./,C=>C.toUpperCase());return r.jsxs("section",{className:"detail-section",children:[r.jsxs("h3",{children:[S," ",r.jsx("span",{className:"section-count",title:v.title,children:v.label})]}),r.jsx("p",{className:"detail-recap",title:im(k),children:k.text}),k.reply&&r.jsxs("p",{className:"detail-recap detail-note-reply",children:["Suggested reply: “",k.reply,"”"]})]})})(),(()=>{const k=Nr(e.plan);return!k||!e.plan?null:r.jsxs("section",{className:"detail-section",children:[r.jsxs("h3",{children:["Plan"," ",r.jsxs("span",{className:"section-count","aria-hidden":!0,children:[k.done,"/",k.total]}),r.jsxs("span",{className:"vis-hidden",children:[k.done," of ",k.total," done"]})]}),e.plan.note&&r.jsx("p",{className:"detail-plan-note",children:e.plan.note}),r.jsx("ol",{className:"plan-list",children:e.plan.items.map((v,S)=>r.jsxs("li",{className:"plan-item","data-status":v.status,children:[r.jsx("span",{className:"plan-mark","aria-hidden":!0}),r.jsxs("span",{className:"vis-hidden",children:[Gge[v.status],": "]}),r.jsx("span",{className:"plan-text",children:v.status==="in_progress"&&v.active?v.active:v.text}),v.status==="in_progress"&&r.jsx("span",{className:"plan-now","aria-hidden":!0,children:"now"})]},v.id??`${S}:${v.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:x.map(([k,v])=>{const S=k==="mcp"?b:null,C=S==null?void 0:S.hue,_=`${v} ${$p[k]} call${v===1?"":"s"}`;return r.jsxs("span",{className:`cat-chip cat-${k}${C!=null?" mcp-hue":""}`,style:C!=null?{"--mcp-hue":C}:void 0,title:S?`${_}, all to ${S.label}`:_,children:[r.jsx("span",{className:"cat-emoji","aria-hidden":!0,children:k8[k]}),r.jsx("span",{className:"cat-name",children:$p[k]}),r.jsx("span",{className:"cat-count",children:v}),S&&r.jsx("span",{className:"cat-server",children:S.label})]},k)})})]})]}),f>0&&r.jsxs("section",{className:"detail-section",children:[r.jsx("h3",{children:"Tokens"}),r.jsxs("div",{className:"tokens-grid",children:[r.jsxs("div",{children:[r.jsx("span",{className:"k",children:"in"}),r.jsx("b",{title:e.usage.inputTokens.toLocaleString(),children:St(e.usage.inputTokens)})]}),r.jsxs("div",{children:[r.jsx("span",{className:"k",children:"out"}),r.jsx("b",{title:e.usage.outputTokens.toLocaleString(),children:St(e.usage.outputTokens)})]}),r.jsxs("div",{children:[r.jsx("span",{className:"k",children:"cache r"}),r.jsx("b",{title:e.usage.cacheReadTokens.toLocaleString(),children:St(e.usage.cacheReadTokens)})]}),r.jsxs("div",{children:[r.jsx("span",{className:"k",children:"cache c"}),r.jsx("b",{title:e.usage.cacheCreateTokens.toLocaleString(),children:St(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:aP(e.prompts).length})]}),r.jsx("div",{className:"prompts",children:Hge(e.prompts).reverse().map(({pr:k,key:v})=>{const S=ip(k.at,t),C=Yp(k.text);return C?r.jsxs("details",{className:"prompt-entry prompt-injected",children:[r.jsxs("summary",{children:[r.jsx("span",{className:"prompt-time",title:S.title,children:S.label}),r.jsx("span",{className:"prompt-injected-label",children:C.label})]}),C.detail&&r.jsx("div",{className:"prompt-injected-detail",children:C.detail})]},v):r.jsxs("div",{className:"prompt-entry",children:[r.jsx("div",{className:"prompt-time",title:S.title,children:S.label}),r.jsx("div",{className:"prompt-text",children:k.text})]},v)})})]}),r.jsxs("section",{className:"detail-section",children:[r.jsxs("h3",{children:["Tool calls ",r.jsx("span",{className:"section-count",children:e.tools.length})]}),e.tools.length===0&&r.jsx("div",{className:"empty",children:"No tool calls yet."}),r.jsx("div",{children:e.tools.slice().reverse().map(k=>r.jsx(Vge,{t:k,onClick:()=>n(e.id,k.id)},k.id))})]})]})}function Hge(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 zge={inflight:"in-flight",done:"done",err:"error"};function Vge({t:e,onClick:t}){const n=e.endedAt==null?"inflight":e.ok===!1?"err":"done",s=MP(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:zge[n]}),e.name]}),r.jsx("span",{style:{color:"var(--muted)"},children:s})]})}const Gge={completed:"done",in_progress:"now",pending:"to do"};function Kge(e,t){const n=Fge(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=Bge(n.label,t),document.body.appendChild(i),i.click(),document.body.removeChild(i),setTimeout(()=>URL.revokeObjectURL(o),1e3)}function Yge({selected:e,now:t,openTool:n,setSummaryFor:s,onClose:a,stateRef:o,removeSelectedNode:i}){cn("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(Wge,{agent:e,now:t,onOpenTool:n,onShowSummary:s,onExportSession:u=>Kge(o.current,u),onRemove:i,singleKeys:l})]})}function Xge(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 _f(e,t){return t.map(n=>({...n,group:e}))}function Zge({providers:e,sessionListOpen:t,toggleSessionList:n,accountsPanelOpen:s,toggleAccountsPanel:a,usagePanelOpen:o,setUsagePanelOpen:i,machinePanelOpen:l,setMachinePanelOpen:u,setUsageHistoryOpen:d,watchOn:f,watchUnseen:p,setBrowserWatchOpen:m,setTrafficRadarOpen:w,setRadioOpen:x,openToolActivity:b,openSettings:j,onFeedback:k,toggles:v,openCapacity:S,integrations:C=[],openExploreIntegrations:_,openQuickOpen:R}){const A=wee(to()),I=co(to()),$={id:"session-list",label:"Session list",short:"Sessions",key:{cap:"L",aria:"L",single:!0},ariaLabel:"Session list",glyph:r.jsx(FD,{}),kind:"panel",open:t,controls:"session-list",onPress:n,buttonRef:v.sessionList},U={id:"accounts",label:"Accounts",short:"Accounts",key:{cap:"A",aria:"A",single:!0},ariaLabel:"Accounts",hint:"Claude accounts",glyph:r.jsx(BD,{}),kind:"panel",open:s,controls:"accounts-panel",onPress:a,buttonRef:v.accounts},F=S?[{id:"account-capacity",label:"Account capacity",short:"Capacity",ariaLabel:"Account capacity",detail:"How many accounts are ready, and what the 5h and 7d windows have left",glyph:r.jsx(RQ,{}),kind:"dialog",onPress:()=>S("accounts")},{id:"reset-calendar",label:"Reset calendar",short:"Calendar",ariaLabel:"Reset calendar",detail:"When each account's 5h and 7d windows come back",glyph:r.jsx(MQ,{}),kind:"dialog",onPress:()=>S("calendar")}]:[],M={id:"usage",label:"Usage",short:"Usage",key:{cap:"U",aria:"U",single:!0},ariaLabel:"Usage",glyph:r.jsx(xQ,{}),kind:"panel",open:o,controls:"usage-panel",onPress:()=>i(V=>!V),buttonRef:v.usage},B={id:"machine",label:"Machine",short:"Machine",key:{cap:"S",aria:"S",single:!0},ariaLabel:"Machine",hint:"This machine",glyph:r.jsx(bQ,{}),kind:"panel",open:l,controls:"system-panel",onPress:()=>u(V=>!V),buttonRef:v.machine},T={id:"history",label:"Usage history",short:"History",key:{cap:"H",aria:"H",single:!0},ariaLabel:"Usage history",glyph:r.jsx(vQ,{}),kind:"dialog",onPress:()=>d(V=>!V)},P={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:Xge(f,p),glyph:r.jsx(jQ,{watching:f===!0||p>0}),kind:"dialog",onPress:()=>m(V=>!V),badge:p},q={id:"settings",label:"Settings",short:"Settings",key:{cap:A,aria:"Control+, Meta+,",single:!1},ariaLabel:"Settings",glyph:r.jsx(NQ,{}),kind:"dialog",onPress:()=>j()},K={id:"quick-open",label:"Search",short:"Search",key:{cap:yQ(I),aria:I?"Meta+K":"Control+K",single:!1},ariaLabel:"Search",detail:"Panels, sessions, settings, actions and themes",glyph:r.jsx(UD,{}),kind:"dialog",onPress:R},z={id:"feedback",label:"Feedback",short:"Feedback",menu:"Send feedback",ariaLabel:"Send feedback",glyph:r.jsx(SQ,{}),kind:"dialog",onPress:k},H=b?[{id:"tool-activity",label:"Tool activity",short:"Tools",ariaLabel:"Tool activity",glyph:r.jsx(AQ,{}),kind:"dialog",detail:"Which tools your agents run, how long they take and what fails",onPress:()=>b("tools")},{id:"skill-activity",label:"Skill activity",short:"Skills",ariaLabel:"Skill activity",glyph:r.jsx(qD,{}),kind:"dialog",detail:"Which skills your agents use, whether you typed them or the agent called them",onPress:()=>b("skills")}]:[],D=w?[{id:"traffic-radar",label:"Telemetry Radar",short:"Radar",ariaLabel:"Telemetry Radar",glyph:r.jsx(kQ,{}),kind:"dialog",detail:"Claude telemetry configuration and observed connections",onPress:()=>w(!0)}]:[],O=x?[{id:"radio",label:"Radio",short:"Radio",ariaLabel:"Radio",glyph:r.jsx(TQ,{}),kind:"dialog",detail:"Explore stations around the world",onPress:()=>x(!0)}]:[];return{left:e.claude?[U,$]:[$],leftStripe:e.claude?[_f("Claude accounts",[U,...F]),[$]]:[[$]],capacity:e.claude?F:[],right:[_f("Usage and machine",[M,B]),_f("Activity history",[T,...H]),_f("Watchers",[P,...D]),O].filter(V=>V.length>0),utilities:[q,z],search:K,explore:_?[{id:"explore-integrations",label:"Explore integrations",short:"Integrations",ariaLabel:"Explore integrations",glyph:r.jsx(wQ,{}),kind:"dialog",onPress:_}]:[],integrations:C.map(({provider:V,onPress:Z})=>({id:`integration-${V.kind}`,label:V.label,short:V.label,ariaLabel:V.label,detail:V.detail,key:V.shortcut?{cap:V.shortcut.toUpperCase(),aria:V.shortcut.toUpperCase(),single:!0}:void 0,glyph:r.jsx(V.Glyph,{}),kind:"dialog",onPress:Z}))}}const Lp=[{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 N8(e){return Lp.find(t=>t.value===e)??Lp[0]}const Tj=3,G0=120,S8=1e4,C8=200,Jge="Write something first.";function NO(e){return e.trim()!==""}function Qge(e){var o;const t=e.trim();if(t==="")return"";const n=SO(t.split(/\r?\n/,1)[0]),s=((o=/^(.+?[.!?])(?=\s|$)/.exec(n))==null?void 0:o[1])??n,a=K0(s).length>=Tj?K0(s):K0(n);return tye(a.length>=Tj?a:SO(t))}function eye(e,t){const n=Qge(t);return n.length>=Tj?n:`${N8(e).label}: ${n}`}function SO(e){return e.replace(/\s+/g," ").trim()}function K0(e){return/[^.]\.$/.test(e)?e.slice(0,-1):e}function tye(e){if(e.length<=G0)return e;const t=e.slice(0,G0-1),n=t.lastIndexOf(" ");return`${(n>=G0/2?t.slice(0,n):t).replace(/[\uD800-\uDBFF]$/,"").replace(/[\s,;:.\-–—]+$/,"")}…`}function nye({kind:e,body:t,contact:n}){const s={kind:e,title:eye(e,t),body:t.trim()};return n.trim()!==""&&(s.contact=n.trim()),s}function sye(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 rye={darwin:"macOS",win32:"Windows",linux:"Linux"};function aye(e){const t=e.indexOf("-"),n=t===-1?e:e.slice(0,t),s=t===-1?"":e.slice(t+1),a=rye[n]??n;return s?`${a} · ${s}`:a}function oye(e){return e?`ccdeck ${e.appVersion} · ${aye(e.platform)}`:null}const iye="sent with it",lye="Your ccdeck version and system are sent with it.",cye="Add details",uye="How to reach you",dye="Email or GitHub @name",hye="Only if you would like an answer.",fye=["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 pye(e){return e.key==="Enter"&&(e.metaKey||e.ctrlKey)&&!e.altKey&&!e.shiftKey&&!e.isComposing}function HS(e){return e.key==="Enter"&&!e.metaKey&&!e.ctrlKey&&!e.altKey&&!e.shiftKey&&!e.isComposing}function mye(e){return co(e)?["⌘","Enter"]:["Ctrl","Enter"]}function gye(e){return[...e].length===1}const _8="Thanks — feedback sent.";function CO(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 yye(e){return e==="sending"?"Sending…":e==="sent"?_8:""}const _O=1400,wye=160,E8=g.createContext({values:{}});function T8(){return g.useContext(E8)}function xye(e,t){const n=e.variants;return n?{...e,...n.by[t[n.field]??""]??{}}:e}const EO=(e,t)=>!e.when||e.when.is.includes(t[e.when.field]??"");function vye({def:e,existing:t,busy:n,error:s,onSubmit:a,onCancel:o,onDirtyChange:i}){var B,T;const l=g.useId(),[u,d]=g.useState(()=>Object.fromEntries(e.fields.map(P=>{var q,K,z;return[P.name,P.secret?"":((q=P.initial)==null?void 0:q.call(P,t))??(P.type==="choice"?((z=(K=P.options)==null?void 0:K[0])==null?void 0:z.value)??"":"")]}))),[f,p]=g.useState((t==null?void 0:t.name)??""),m=g.useRef(null),w=g.useRef(new Map),x=!!t,b=g.useRef(u),j=g.useRef(f);g.useEffect(()=>{i==null||i(f!==j.current||Object.keys(u).some(P=>u[P]!==b.current[P]))},[f,u,i]);const k=e.fields.filter(P=>P.type==="choice").every(P=>u[P.name]===b.current[P.name]),v=x&&t.tokenSaved&&k,S=(P,q)=>{n||d(K=>({...K,[P]:q}))},C=P=>{var K;if(P.preventDefault(),n)return;const q={};for(const z of e.fields)EO(z,u)&&(q[z.name]=(u[z.name]??"").trim());(K=P.currentTarget.querySelector('button[type="submit"]'))==null||K.focus(),a(q,f.trim()),d(z=>Object.fromEntries(Object.entries(z).map(([H,D])=>{var O;return[H,(O=e.fields.find(V=>V.name===H))!=null&&O.secret?"":D]})))},_=g.useMemo(()=>{const P=u.baseUrl??"";try{return P?new URL(/^[a-z]+:\/\//i.test(P)?P:`https://${P}`).host:""}catch{return""}},[u.baseUrl]),R=g.useMemo(()=>({values:u,existing:t}),[u,t]),A=e.fields.filter(P=>EO(P,u)),I=(B=A.find(P=>!P.secret&&P.type!=="choice"))==null?void 0:B.name,$=(T=A.find(P=>P.secret))==null?void 0:T.name,U=s!=null&&s.field&&A.some(P=>P.name===s.field&&P.type!=="choice")?s.field:null,F=`${l}-error`;g.useEffect(()=>{var q,K,z;const P=x?$:I??$;P&&((q=w.current.get(P))==null||q.focus()),(z=(K=m.current)==null?void 0:K.scrollIntoView)==null||z.call(K,{block:"nearest"})},[x]),g.useEffect(()=>{var P;U&&((P=w.current.get(U))==null||P.focus())},[s,U]);const M=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(E8.Provider,{value:R,children:r.jsxs("form",{ref:m,className:"ig-form",onSubmit:C,"aria-labelledby":`${l}-title`,noValidate:!0,children:[r.jsxs("header",{className:"ig-managed-header",children:[r.jsx("span",{className:"ig-provider-glyph","aria-hidden":!0,children:r.jsx(e.Glyph,{})}),r.jsxs("div",{className:"ig-managed-identity",children:[r.jsx("h2",{className:"ig-form-title",id:`${l}-title`,children:x?`Edit ${t.name}`:`Connect ${e.label}`}),x&&r.jsxs("p",{children:[e.label," connection"]})]})]}),A.map(P=>{const q=xye(P,u),K=(s==null?void 0:s.field)===q.name,z=[q.hint?`${l}-${q.name}-hint`:"",K?F:""].filter(Boolean).join(" ")||void 0;if(q.type==="choice")return r.jsxs("fieldset",{className:"fb-kinds","aria-invalid":K||void 0,children:[r.jsx("legend",{className:"vis-hidden",children:q.label}),(q.options??[]).map(O=>r.jsxs("label",{className:"fb-kind",children:[r.jsx("input",{type:"radio",name:`${l}-${q.name}`,value:O.value,checked:u[q.name]===O.value,"aria-disabled":n||void 0,onChange:()=>S(q.name,O.value),onKeyDown:V=>{HS(V.nativeEvent)&&V.preventDefault()}}),O.label]},O.value))]},q.name);const H=q.secret&&v,D=`${l}-${q.name}`;return r.jsxs("div",{className:"fb-field",children:[r.jsxs("label",{className:"fb-field-label",htmlFor:D,children:[q.label,q.optional&&r.jsx("span",{className:"fb-optional",children:" optional"})]}),r.jsx("input",{id:D,className:`ap-manage-input ig-input${q.secret?" ig-mono":""}`,ref:O=>{O?w.current.set(q.name,O):w.current.delete(q.name)},type:q.type,inputMode:q.type==="url"?"url":q.type==="email"?"email":void 0,autoComplete:q.autoComplete??"off",spellCheck:!1,value:u[q.name]??"",onChange:O=>S(q.name,O.target.value),placeholder:H?"Saved. Leave blank to keep it":q.placeholder,readOnly:n,"aria-invalid":K||void 0,"aria-describedby":z,"aria-required":!q.optional&&!H||void 0}),q.hint&&r.jsx("span",{className:"ig-hint",id:`${l}-${q.name}-hint`,children:q.hint}),K&&U===q.name&&r.jsx("span",{className:"ig-form-error",id:F,role:"alert",children:M})]},q.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:P=>p(P.target.value),placeholder:_||e.label})]}),s&&!U&&r.jsx("p",{className:"ig-form-error",id:F,role:"alert",children:M}),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…":x?"Save":"Connect"}),r.jsx("button",{type:"button",className:"btn","aria-disabled":n||void 0,onClick:()=>{n||o()},children:"Cancel"})]})]})})}const bye="https://id.atlassian.com/manage-profile/security/api-tokens",kye="https://support.atlassian.com/atlassian-account/docs/manage-api-tokens-for-your-atlassian-account/",jye="https://confluence.atlassian.com/enterprise/using-personal-access-tokens-1026032365.html",Nye=[{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 Sye(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 Cye(){const{values:e}=T8(),t=e.deployment==="cloud",n=t?null:Sye(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:bye,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:Nye.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:kye,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:jye,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 Y0(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 X0({href:e,children:t}){return e?r.jsxs("a",{className:"fg-token-link",href:e,target:"_blank",rel:"noreferrer noopener",children:[t," ",r.jsx(Zl,{})]}):null}function A8({kind:e,baseUrl:t}){const{values:n}=T8();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(X0,{href:Y0("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(X0,{href:Y0("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=Y0("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(X0,{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 R8={name:"token",label:"Personal access token",type:"password",secret:!0,placeholder:"Paste the token"},_ye=[R8],TO=e=>{try{return e?new URL(e.baseUrl).host!=="gitlab.com":!1}catch{return!1}},Eye=[{name:"where",label:"Which GitLab",type:"choice",options:[{value:"cloud",label:"GitLab.com"},{value:"self",label:"Self-managed"}],initial:e=>TO(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=>TO(e)?e.baseUrl:""},R8],Tye=g.createElement(A8,{kind:"github"}),Aye=g.createElement(A8,{kind:"gitlab"}),Rye=e=>{var t;return((t=e==null?void 0:e.meta)==null?void 0:t.deployment)==="cloud"?"cloud":"server"},Mye={kind:"jira",label:"Jira",Glyph:LQ,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:Rye},{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(Cye)},$ye={kind:"github",label:"GitHub",Glyph:IQ,detail:"Repositories, pull requests, and Actions",blurb:"github.com, read-only, with a personal access token.",fields:_ye,tokenHelp:Tye},Lye={kind:"gitlab",label:"GitLab",Glyph:OQ,detail:"Projects, merge requests, and pipelines",blurb:"GitLab.com or your own instance, read-only.",fields:Eye,tokenHelp:Aye},Aj={jira:Mye,github:$ye,gitlab:Lye},zS=()=>Object.values(Aj).filter(e=>!!e);function Tu(e){return(Object.hasOwn(Aj,e)?Aj[e]:void 0)??null}function Km(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(Iye,{name:n(a),onClose:a.onClose})})))}function Iye({name:e,onClose:t}){const n=g.useRef(null),s=gt(t,{focusRef:n}),a=wt(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 M8=()=>gi(()=>import("./IntegrationModal-B8t53aE5.js"),[]);function Oye(){M8().catch(()=>{})}const Pye=Km(M8,e=>{var t;return((t=Tu(e.kind))==null?void 0:t.label)??"The tracker"});function Dye({onClose:e}){return g.useEffect(()=>ln.push(e,0,"dialog"),[e]),null}function Fye(e){return r.jsx(g.Suspense,{fallback:r.jsx(Dye,{onClose:e.onClose}),children:r.jsx(Pye,{...e})})}class wr extends Error{constructor(n,s,a={}){super(s);Da(this,"kind");Da(this,"status");Da(this,"retryAfter");Da(this,"field");Da(this,"detail");this.name="IntegrationFailure",this.kind=n,Object.assign(this,a)}}async function $8(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 wr(n.kind,n.message,{status:n.status,retryAfter:n.retryAfter,field:n.field,detail:n.detail})}catch{}return new wr(e.status===401?"auth":"upstream",`The deck answered ${e.status}.`)}async function Ld(e,t={}){const{timeoutMs:n=3e4,...s}=t,a=new AbortController,o=window.setTimeout(()=>a.abort(),n),i=s.signal,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(d){throw i!=null&&i.aborted?d:new wr("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 $8(u);return u.json()}const L8=e=>`/api/integrations/${encodeURIComponent(e.kind)}/${encodeURIComponent(e.id)}/`;function xje(e){const t=L8(e);return(n,s)=>fetch(`${t}${n.replace(/^\/+/,"")}`,s)}function vje(e){const t=L8(e);return n=>`${t}asset?url=${encodeURIComponent(n)}`}function bje(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 kje(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 jje(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 wr("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 $8(l);try{return await l.json()}catch{throw new wr("upstream","The deck answered with something that is not JSON.")}}let aa={connections:null,providers:[],error:""};const Cl=new Set;let Ef=null,mu=null,Pl=null,AO=0;const Bye=5e3,qye=3;function Ip(e){aa={...aa,...e},Cl.forEach(t=>t(aa))}function Ym(){return mu||(mu=(async()=>{try{const e=await Ld("/api/integrations",{timeoutMs:1e4}),t=e==null?void 0:e.connections,n=e==null?void 0:e.providers;if(!Array.isArray(t)||!Array.isArray(n))throw new wr("upstream","The deck answered with something that is not the list of connections.");Ip({connections:t,providers:n,error:""})}catch(e){Ip({error:e instanceof Error?e.message:"Could not read the connections."}),aa.connections===null&&Cl.size>0&&Pl===null&&AO<qye&&(Pl=window.setTimeout(()=>{Pl=null,Ym()},Bye*2**AO++))}finally{mu=null}})(),mu)}function Uye(e){return e.connections===null||e.providers.length>0||e.connections.length>0}function RO(){Uye(aa)&&Ym()}function VS(e){const t=aa.connections??[],n=t.findIndex(s=>s.id===e.id);Ip({connections:n<0?[...t,e]:t.map(s=>s.id===e.id?e:s)})}function Wye(e){Ip({connections:(aa.connections??[]).filter(t=>t.id!==e)})}function Id(){const[e,t]=g.useState(aa);return g.useEffect(()=>{Cl.add(t),t(aa);const n=()=>{document.visibilityState==="visible"&&RO()};return Cl.size===1&&(Ym(),Ef=window.setInterval(RO,6e4),document.addEventListener("visibilitychange",n)),()=>{Cl.delete(t),Cl.size===0&&(Ef!==null&&window.clearInterval(Ef),Ef=null,Pl!==null&&window.clearTimeout(Pl),Pl=null,document.removeEventListener("visibilitychange",n))}},[]),e}function Op(e,t){return(e.connections??[]).filter(n=>n.kind===t)}function Od(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 na(e,t){return Od(e).has(t)}function Rj(e,t){return na(e,t)&&Op(e,t).length>0}function GS(e){return Od(e).size>0?"all":(e.connections??[]).length>0?"connections":"none"}async function Hye(e,t,n){const s=await Ld("/api/integrations/connections",{method:"POST",body:JSON.stringify({kind:e,name:n,input:t}),timeoutMs:6e4});return VS(s.connection),s.connection}async function zye(e,t){const n=await Ld(`/api/integrations/connections/${encodeURIComponent(e)}`,{method:"PATCH",body:JSON.stringify(t),timeoutMs:6e4});return VS(n.connection),n}async function Vye(e){const t=await Ld(`/api/integrations/connections/${encodeURIComponent(e)}/test`,{method:"POST",body:"{}",timeoutMs:6e4});return VS(t.connection),t.connection}async function Gye(e){await Ld(`/api/integrations/connections/${encodeURIComponent(e)}`,{method:"DELETE"}),Wye(e)}function Uo(e){try{return new URL(e.baseUrl).host}catch{return e.baseUrl}}function Nje(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 Pp=null,Dp=null;function MO(e){Dp=null,Pp=e}function Kye(e){Pp=null,Dp=e}function Yye(){const e=Dp;return Dp=null,e}function Xye(){const e=Pp;return Pp=null,e}const Zye={jira:"Boards, sprints, backlog and issues",github:"Repositories, pull requests and Actions",gitlab:"Projects, merge requests and pipelines"},Jye={jira:"Can move issues",github:"Read only",gitlab:"Read only"};function Qye(){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 ewe({integrations:e,onClose:t,onOpen:n,onConnect:s,onManage:a}){const o=gt(t,{restoreFocusFallback:Qye}),i=wt(t),l=zS().filter(f=>e.providers.some(p=>p.kind===f.kind)||Op(e,f.kind).length>0),u=l.filter(f=>Rj(e,f.kind)).length,d=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=na(e,f.kind),m=Rj(e,f.kind),w=Op(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:Zye[f.kind]}),r.jsxs("span",{className:"explore-connection","data-connected":m||void 0,children:[p?m?"Connected":"Not connected":"Unavailable on this deck"," · ",Jye[f.kind]]})]}),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:()=>d(()=>n(f.kind)),children:["Open ",r.jsx(Zl,{})]}),r.jsx("button",{type:"button",className:"btn explore-text-action","aria-label":`Manage ${f.label}`,onClick:()=>d(()=>a(w==null?void 0:w.id)),children:"Manage"})]}):p?r.jsx("button",{type:"button",className:"btn primary","aria-label":`Connect ${f.label}`,onClick:()=>d(()=>s(f.kind)),children:"Connect"}):w?r.jsx("button",{type:"button",className:"btn explore-text-action","aria-label":`Manage ${f.label}`,onClick:()=>d(()=>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:"Browsing only reads · Tokens stay on this machine"}),r.jsxs("button",{type:"button",className:"btn explore-text-action",onClick:()=>d(()=>a()),children:["Manage in Settings ",r.jsx(Zl,{})]})]})]})}),document.body)}function twe({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 I8(e){return e.tool?e.tool.name:e.kind==="asked"?"question":"permission"}const nwe=20;function swe(e,t=nwe){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 rwe(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 awe(e,t,n){const s=t.tool?`on ${t.tool.name}`:t.kind==="asked"?"for an answer":"for permission";return`${e}, waiting ${rwe(n)} ${s}; go to session`}function owe(e){const t=Hl(e),n=RP(e,t);return n?`${t}
|
|
113
|
+
${n}`:t}const iwe=new Set(["idle","checking","current","downloading","ready","error"]);function $O(e){if(!e||typeof e!="object")return null;const t=e;if(typeof t.status!="string"||!iwe.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 lwe(e){return(e==null?void 0:e.status)==="ready"&&e.version?{version:e.version}:null}function O8(e=typeof navigator>"u"?"":navigator.userAgent){var t;return((t=/\bccdeck-desktop\/(\d[^\s]*)/.exec(e))==null?void 0:t[1])??null}const Jl="Restart to update",P8=3e4;function D8(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 cwe(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 ${Jl} comes first`}}function F8(e,t=!1){return{text:t?"Restarting…":Jl,label:t?void 0:`${Jl} 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 uwe(e){const t=e==null?void 0:e.reason;return t==="app_disconnected"||t==="update_not_ready"?t:"refused"}function B8(e,t,n=typeof navigator>"u"?"":navigator.userAgent){const s=D8(n),a=`Use ${Jl} 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, ${Jl} is in ${s}.`;case"timeout":return`ccdeck has not restarted after ${P8/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 dwe="Update checks are off (AGENTS_DECK_NO_UPDATE_CHECK=1)",Z0="click for what's new";function hwe(e){if(e.checkDisabled)return`${dwe} · ${Z0}`;if(e.checking)return`Asking npm for the newest release… · ${Z0}`;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 · ${Z0}, and to check npm now`}function fwe(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 pwe(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 q8(e){return e?`${e.kind}:${e.to}`:""}function mwe(e,t){return e!=null&&t!==q8(e)}function gwe({readyAppUpdate:e,notice:t,noticeOpen:n,version:s,chipVersion:a,versionChecking:o,now:i,openReleaseNotes:l,showNotice:u,loadVersion:d,restartToUpdate:f,updateRestarting:p=!1}){return r.jsx(r.Fragment,{children:e?(()=>{const m=cwe(O8()??a,e.version),w=f&&F8(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":pwe({...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?op(i-s.checkedAt):null,checkFailedAgo:s!=null&&s.checkFailedAt&&s.checkFailedAt>(s.checkedAt??0)?op(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(),d(!0)},"aria-busy":o||void 0,"aria-haspopup":"dialog","aria-label":fwe(m),title:hwe(m),children:["v",m.running]})})()})}function ywe({live:e,paused:t,pauseGate:n}){const s=An();return r.jsx("span",{className:"status",children:(()=>{const a=GY({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 wwe(e,t){return`${e.label} — ${I8(e.waiting)} · ${rd(e.waiting.since,void 0,t)}`}function U8(e,t){const n=e.slice(0,6).map(s=>wwe(s,t));return e.length>6&&n.push(`and ${e.length-6} more`),n.join(`
|
|
114
|
+
`)}function xwe({waitingSessions:e,waitingCursorRef:t,focusSession:n,now:s,named:a}){const o=An(),i=oc("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?U8(l,s):void 0}),children:[r.jsx("span",{className:"ap-pulse","aria-hidden":!0}),r.jsx("b",{children:u})," waiting"]}),i.node]})}function LO({w:e,now:t}){return r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"we-name",children:swe(e.label)}),r.jsx("span",{className:"we-wait",children:rd(e.waiting.since,void 0,t)}),r.jsxs("span",{className:"we-what",children:["· ",I8(e.waiting)]})]})}const vwe=12,bwe=2e3,kwe=4;function jwe({waitingSessions:e,waitingCursorRef:t,focusSession:n,now:s,onFit:a,onMore:o}){const i=An(),l=oc("below"),u=g.useRef(null),d=g.useRef(null),[f,p]=g.useState(0),m=e.map(j=>j.id).join(`
|
|
115
|
+
`);g.useLayoutEffect(()=>{const j=u.current,k=d.current;if(!j||!k)return;const v=()=>{const C=Array.from(k.children),_=C.pop();p(twe({widths:C.map(R=>R.getBoundingClientRect().width),room:j.clientWidth-vwe,gap:kwe,more:(_==null?void 0:_.getBoundingClientRect().width)??0}))};if(v(),typeof ResizeObserver>"u")return;const S=new ResizeObserver(v);return S.observe(j),S.observe(k),()=>S.disconnect()},[m]);const w=e.slice(0,f),x=e.slice(f);g.useEffect(()=>{a(w.length)},[w.length,a]);const b=j=>{t.current=j,n(j)};return r.jsxs("div",{className:"wait-names",ref:u,children:[r.jsxs("ul",{className:"wait-list",children:[w.map(j=>r.jsx("li",{"data-fresh":s-j.waiting.since<bwe||void 0,children:r.jsx("button",{type:"button",className:"wait-entry",onClick:()=>b(j.id),"aria-label":awe(j.label,j.waiting,s-j.waiting.since),...l.bind({label:j.label,detail:owe(j.waiting)}),children:r.jsx(LO,{w:j,now:s})})},j.id)),w.length>0&&x.length>0&&r.jsx("li",{children:r.jsxs("button",{type:"button",className:"wait-more",onClick:o,"aria-label":`${x.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:U8(x,s)}),children:["+",x.length," more"]})})]}),e.length>0&&r.jsxs("span",{className:"wait-ruler",ref:d,"aria-hidden":!0,children:[e.map(j=>r.jsx("span",{className:"wait-entry",children:r.jsx(LO,{w:j,now:s})},j.id)),r.jsxs("span",{className:"wait-more",children:["+",e.length," more"]})]}),l.node]})}const Mj={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 Nwe(e){return e==="on"?`Notifications on. ${Mj.on}.`:e==="blocked"?`${Mj.blocked}.`:""}function Swe({notifySaid:e}){return r.jsx("span",{className:e==="on"?"notify-said":"notify-said notify-said-blocked","aria-hidden":!0,title:Mj[e],children:e==="on"?"notifications on":"notifications blocked"})}function Cwe({versionCheck:e,welcome:t,desktopUpdate:n,pause:s,announcements:a,notify:o,waitingSessions:i,waitingCursorRef:l,focusSession:u,live:d,now:f,incidents:p,queueNamed:m}){const{version:w,notice:x,noticeOpen:b,showNotice:j,versionChecking:k,loadVersion:v}=e,{chipVersion:S,openReleaseNotes:C}=t,{readyAppUpdate:_,desktopUpdateRestarting:R,desktopUpdateFailure:A,askDesktopUpdateRestart:I}=n,$=g.useRef(!1);g.useEffect(()=>{R||!$.current||($.current=!1,A&&C())},[R,A,C]);const U=K=>{$.current=!0,I(K)},{paused:F,pauseGate:M}=s,{blockedSaid:B,watchSaid:T,incidentSaid:P}=a,{notifySaid:q}=o;return r.jsxs("div",{className:"readout",children:[r.jsxs("div",{className:"brand",children:[r.jsx("img",{className:"logo logo-on-dark",src:Kne,width:19,height:16,alt:""}),r.jsx("img",{className:"logo logo-on-light",src:Yne,width:19,height:16,alt:""}),r.jsx("h1",{children:Pt}),r.jsx(gwe,{readyAppUpdate:_,notice:x,noticeOpen:b,version:w,chipVersion:S,versionChecking:k,now:f,openReleaseNotes:C,showNotice:j,loadVersion:v,restartToUpdate:U,updateRestarting:R})]}),r.jsx(ywe,{live:d,paused:F,pauseGate:M}),r.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:B}),r.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:T}),r.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:P}),r.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:Nwe(q)}),r.jsx(ase,{incidents:p}),i.length>0&&r.jsx(xwe,{waitingSessions:i,waitingCursorRef:l,focusSession:u,now:f,named:m}),q&&r.jsx(Swe,{notifySaid:q})]})}function _we({selected:e,now:t,selectedIds:n,focusAgent:s,clearSelection:a}){const o=An(),i=Wn(e),l=Math.max(0,((e.endedAt??t)-e.startedAt)/1e3),u=e.state==="active"&&!e.synthetic?yN(i.total,l):null,d=n.size-1;return r.jsxs("button",{type:"button",className:"selected-ribbon",title:`${En(`Zoom to ${e.label} and its session`,"Z",o)}${i.total>0?`
|
|
116
|
+
${lt(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:[lt(i.total),u?r.jsxs("span",{className:"selected-rate",children:[" · ",u]}):null]}),d>0&&r.jsxs("span",{className:"selected-extra",children:["+",d]}),r.jsx("span",{"aria-hidden":!0,className:"selected-close",onClick:f=>{f.stopPropagation(),a()},children:"×"})]})}function Ewe({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"} ${$p[o]} tools`,children:[r.jsx(Uge,{cat:o}),r.jsx("span",{className:"cat-name",children:$p[o]})]},o)})})}const Twe=["a[href]","button:not(:disabled)","input:not(:disabled)","select:not(:disabled)","textarea:not(:disabled)","summary","[tabindex]"].join(",");function Awe(e){var n,s;const t=e.target;!(t!=null&&t.closest)||t.closest(Twe)!==e.currentTarget||(e.preventDefault(),(s=(n=document.activeElement)==null?void 0:n.blur)==null||s.call(n))}function Rwe({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"?`${En("The session list","L",a)} brings it back`:"The session keeps running"})]})]})}function Mwe({canvasRef:e,bubbling:t,dragging:n,trash:s,zoom:a,viewport:o,stateRef:i,peek:l,children:u}){const{trashDragging:d,trashState:f,trashPhase:p,trashZoneRef:m,trashLabel:w}=s,{lod:x,lodRef:b}=a,{markCanvasInput:j}=o,{peekAgent:k,peekLabel:v,peekRecap:S,peekBounds:C}=l;return r.jsxs("main",{id:"canvas",tabIndex:-1,className:`canvas-wrap${t?" bubbling":""}${n?" dragging-any":""}${d&&f==="over"?" trash-hover":""}`,"data-lod":x,ref:e,onMouseDownCapture:Awe,onPointerDownCapture:j,onPointerUpCapture:j,onWheelCapture:j,onFocusCapture:_=>{const R=_.target;if(!BS(R)||b.current==null||b.current==="detail")return;const A=R.getAttribute("data-id");A&&i.current.agents.has(A)&&R.matches(":focus-visible")&&a8(A,R,"focus")},onBlurCapture:_=>{var A,I;const R=(I=(A=_.target).getAttribute)==null?void 0:I.call(A,"data-id");R&&ro(R)},children:[u,Ya(p)&&r.jsx(Rwe,{trashZoneRef:m,trashState:f,trashPhase:p,trashLabel:w}),r.jsx(fme,{agentFor:k,recapFor:S,labelFor:v,bounds:C})]})}function $we({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=zY({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 Lwe({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 W8="Thanks — that helps.",Iwe=Array.from({length:11},(e,t)=>t);function Owe(e){return e===0?"0 out of 10, not useful":e===10?"10 out of 10, extremely useful":`${e} out of 10`}const Pwe=6;function Dwe(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 Fwe(){var e;(e=document.getElementById("canvas"))==null||e.focus()}function Bwe({phase:e,score:t,onAnswer:n,onLater:s,onClose:a,onFeedback:o,onHold:i}){const l=Dwe(e),u=g.useRef(null),d=g.useRef(null),f=g.useRef(!1);g.useEffect(()=>{var m,w;e!=="thanks"||!f.current||(f.current=!1,Hn(((m=document.activeElement)==null?void 0:m.tagName)??null)&&((w=u.current??d.current)==null||w.focus()))},[e]);const p=m=>{var w;(w=l.current)!=null&&w.contains(document.activeElement)&&Fwe(),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:W8}),t!==null&&t<=Pwe?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:d,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:Iwe.map(m=>r.jsx("button",{type:"button",className:"rating-pick","aria-label":Owe(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 qwe=3e4;function Uwe({bundle:e,running:t,lastTried:n}){return!t||e===t?!1:n!==t}function Wwe({bundle:e,running:t,pending:n,lastTried:s}){return t?Uwe({bundle:e,running:t,lastTried:s})?"reload":n==null||n&&n!==t?"wait":"confirm":"wait"}function Hwe(e){return!e||e.state!=="failed"?null:`${typeof e.at=="number"?e.at:0}:${e.error??""}`}function zwe({asked:e,reported:t}){return t?t!==e:!1}function H8(e){const t=e.thresholdMs??qwe;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 Vwe(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 Gwe(e,t){return e?t==null?"auto when idle":`auto in ${Vwe(t)}`:"auto-restart off"}function IO(e){let t=0;for(const n of e)n.state==="active"&&t++;return t}function Kwe(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 Ywe(e){const t=H8(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 $j={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 Xwe({notice:e,version:t,dismissNotice:n,upgradeState:s,startUpgrade:a,copyCommand:o,cmdCopied:i,autoRestart:l,toggleAutoRestart:u,askRestart:d,restartCopy:f,restartFuseMs:p,restarting:m}){var w,x,b;return r.jsxs("div",{className:`ver-banner ${e.kind}`,role:"status",children:[r.jsx("span",{className:`ver-dot${p==null?"":" armed"}`}),e.kind==="restart"?r.jsxs(r.Fragment,{children:[r.jsxs("strong",{children:["v",e.to," is installed — this deck still runs v",e.from,"."]}),t!=null&&t.canRestart?r.jsxs(r.Fragment,{children:[r.jsx("button",{type:"button",className:"ver-act",onClick:()=>d(),...qn(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:Gwe(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,...qn(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:()=>d({upgrade:!0}),...qn(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:((x=t==null?void 0:t.upgrade)==null?void 0:x.error)??"",children:[(t==null?void 0:t.upgradeMode)==="npx"?"update failed":"install failed",": ",((b=t==null?void 0:t.upgrade)==null?void 0:b.error)??"unknown error"," — run it yourself:"]}):(t==null?void 0:t.upgradeMode)==="npx"?r.jsx("span",{className:"ver-sub",children:t!=null&&t.canRestart?"npx cannot upgrade in place, so the deck re-runs:":$j.npx}):t!=null&&t.upgradeBlocked?r.jsx("span",{className:"ver-sub",children:Kt($j,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 Zwe({restart:e,versionCheck:t,upgrade:n,oldNameNotice:s,rating:a,onFeedback:o,everConnected:i,live:l,paused:u}){const{autoRestart:d,toggleAutoRestart:f,restarting:p,restartMode:m,restartedTo:w,askRestart:x,restartCopy:b,restartFuseMs:j}=e,{version:k,notice:v,noticeOpen:S,dismissNotice:C}=t,{upgradeState:_,startUpgrade:R,copyCommand:A,cmdCopied:I}=n,{oldName:$,oldNameOpen:U,dismissOldName:F}=s,{ratingPhase:M,ratingScore:B,answerRating:T,rateLater:P,closeRating:q,holdThanks:K}=a,z=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($we,{restarting:p,restartMode:m,live:l,paused:u}):S&&v?r.jsx(Xwe,{notice:v,version:k,dismissNotice:C,upgradeState:_,startUpgrade:R,copyCommand:A,cmdCopied:I,autoRestart:d,toggleAutoRestart:f,askRestart:x,restartCopy:b,restartFuseMs:j,restarting:p}):U&&$?r.jsx(Lwe,{oldName:$,version:k,dismissOldName:F}):M!=="hidden"?r.jsx(Bwe,{phase:M,score:B,onAnswer:T,onLater:P,onClose:q,onFeedback:o,onHold:K}):null;return r.jsxs(r.Fragment,{children:[z,r.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:M==="thanks"?W8:""})]})}function Jwe(e,t){return e==="confirmation"?t.confirmOpen?"clear":"ignore":t.modalOpen||t.confirmOpen?"ignore":"confirm"}function Qwe(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 exe(e){return e<=0?null:e===1?"the one agent":`all ${e} agents`}function txe(e,t){const n=exe(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 nxe({agentCount:e,onConfirm:t,onCancel:n}){const s=g.useRef(null),a=gt(n,{focusRef:s,layer:GG}),o=wt(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(Qwe(w))}).catch(()=>{}),()=>{m=!0}},[]);const{goes:u,stays:d,final:f,confirm:p}=txe(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:d.length>0?d.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 sxe({kind:e,onChange:t}){return r.jsxs("fieldset",{className:"fb-kinds",children:[r.jsx("legend",{className:"vis-hidden",children:"Kind of feedback"}),Lp.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=>{HS(s.nativeEvent)&&s.preventDefault()}}),n.label]},n.value))]})}const z8="fb-details";function rxe({open:e,onToggle:t}){return r.jsxs("button",{type:"button",className:"fb-tool fb-more","aria-expanded":e,"aria-controls":z8,onClick:t,children:[cye,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 axe({open:e,contact:t,onContact:n}){const s=g.useId();return r.jsx("div",{id:z8,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:[uye,r.jsx("span",{className:"fb-optional",children:"optional"})]}),r.jsx("input",{id:"fb-contact",className:"ap-manage-input",type:"text",value:t,maxLength:C8,autoComplete:"email",placeholder:dye,"aria-describedby":s,onChange:a=>n(a.target.value),onKeyDown:a=>{HS(a.nativeEvent)&&a.preventDefault()}}),r.jsx("p",{id:s,className:"fb-hint",children:hye})]}),r.jsx("div",{className:"fb-where",children:fye.map(a=>r.jsx("p",{children:a},a))})]})})})}const Jo=3,oxe=5*1024*1024,ixe=12*1024*1024,Lj=8192,lxe=64*1024,cxe=256*1024,uxe=.92,dxe=640,V8=.9,hxe=.85,fxe=6,pxe=512*1024,Fp={png:"image/png",jpeg:"image/jpeg"},mxe={png:"png",jpeg:"jpg"},gxe=[137,80,78,71,13,10,26,10],yxe=[255,216,255];function G8(e){const t=n=>e.length>=n.length&&n.every((s,a)=>e[a]===s);return t(gxe)?"png":t(yxe)?"jpeg":null}function wxe(e){const t=G8(e);return t==="png"?xxe(e):t==="jpeg"?bxe(e):null}function xxe(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 vxe(e){return e>=192&&e<=207&&e!==196&&e!==200&&e!==204}function bxe(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(vxe(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 OO(e,t){return e.bytes>t||e.width>Lj||e.height>Lj}function kxe(e){return Math.min(oxe,ixe-lxe-e)}function K8(e,t){return{width:Math.max(1,Math.floor(e.width*t)),height:Math.max(1,Math.floor(e.height*t))}}function jxe(e,t){const n=Lj/Math.max(e.width,e.height),s=e.bytes>t?Math.sqrt(t/e.bytes)*V8:1;return K8(e,Math.min(1,n,s))}async function Nxe(e,t,n){let s=jxe(e,t),a=e.format;for(let o=0;o<fxe;o++){const i=await n(s,a,a==="jpeg"?uxe:void 0);if(!i)return null;if(i.size<=t)return{...s,blob:i,format:a};if(a==="png"){a="jpeg";continue}if(s=K8(s,Math.min(hxe,Math.sqrt(t/i.size)*V8)),Math.max(s.width,s.height)<dxe)return null}return null}async function Sxe(e,t,n){const s=new Uint8Array(await e.slice(0,pxe).arrayBuffer()),a=G8(s);if(!a)return{ok:!1,problem:"type"};if(t<cxe)return{ok:!1,problem:"no_room"};const o=e.type===Fp[a]?e:new Blob([e],{type:Fp[a]}),i=wxe(s);if(i&&!OO({...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(!OO(u,t))return{ok:!0,blob:o,resized:null};const d=await Nxe(u,t,l.encoder);return d?{ok:!0,blob:d.blob,resized:{width:d.width,height:d.height}}:{ok:!1,problem:"too_large"}}finally{l.release()}}function Cxe(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)},Fp[s],a)})}const _xe=async e=>{const t=await createImageBitmap(e);return{width:t.width,height:t.height,encoder:Cxe(t),release:()=>t.close()}};function Exe(e){return e.includes("Files")}function Txe({files:e,hasText:t,intoTextField:n}){return e>0&&(!t||!n)}function Axe(e,t){const n=e.indexOf(t);return e[n+1]??e[n-1]??null}function Rxe(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===Fp.jpeg?"jpeg":"png";n.append("images",s,`image-${a+1}.${mxe[o]}`)}),{method:"POST",body:n}}const Mxe="Add screenshot",PO="PNG or JPEG, up to three. You can also paste one, or drop it on this dialog.",$xe="A screenshot can show emails, costs and paths. Crop out what should not be seen.",DO="Three images at most. Remove one to add another.",Lxe="An image could not be attached, so nothing was sent. Check the images and send again; your text is still here.";function Ixe(e,t,n){const s=n?`, resized to ${n.width} × ${n.height} to fit`:"";return`Replace image ${e+1}: ${t}${s}`}function Oxe(e,t){const n=`${e} of ${Jo}`;return t>0?`${n} · ${t} resized to fit`:n}function Pxe(e){return`Three images at most, so ${e===1?"one was":`${e} were`} left out.`}function Dxe(e){return`“${e.length>40?`${e.slice(0,30)}…${e.slice(-9)}`:e}”`}function Fxe(e,t){const n=Dxe(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 Y8="image/png,image/jpeg";function X8({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 Bxe({images:e,buttonRef:t}){const n=g.useRef(null),s=e.shots.length>=Jo;return r.jsxs(r.Fragment,{children:[r.jsxs("button",{ref:t,type:"button",className:"fb-tool",title:PO,"aria-describedby":"fb-attach-hint",onClick:()=>{var a;return s?e.sayFull():(a=n.current)==null?void 0:a.click()},children:[r.jsx(X8,{}),Mxe]}),r.jsx("span",{id:"fb-attach-hint",hidden:!0,children:PO}),r.jsx("input",{ref:n,type:"file",accept:Y8,multiple:!0,hidden:!0,onChange:a=>{e.add(Array.from(a.target.files??[])),a.target.value=""}})]})}function qxe({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,d=Oxe(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(Axe(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:Y8,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":Ixe(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:x=>{x?n.current.set(m.id,x):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:d})]}),r.jsx("p",{className:"fb-hint",children:$xe})]}),e.problem&&r.jsx("p",{ref:s,className:"fb-error",role:"alert",children:e.problem},e.problemId)]})}function Uxe(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 Wxe(e,t,n){return n?e.map(s=>s.id===t.id?t:s):[...e,t]}function Hxe(e,t,n){return n?e.map(s=>s.id===t?n:s):e.filter(s=>s.id!==t)}function zxe(e){const[t,n]=g.useState(()=>Uxe((e==null?void 0:e.ready)??[],1)),[s,a]=g.useState({problem:"",id:0}),o=g.useRef(0),i=g.useCallback(M=>{M&&o.current++,a(B=>M?{problem:M,id:B.id+1}:B.problem?{problem:"",id:B.id}:B)},[]),[l,u]=g.useState(""),d=g.useRef(t),f=g.useRef(null),p=g.useRef(t.length),m=g.useRef(!0),w=g.useRef(new Map),x=g.useRef([]),b=g.useRef(0),j=g.useCallback(M=>{d.current=M(d.current),n(d.current)},[]);g.useEffect(()=>(m.current=!0,()=>{m.current=!1;for(const M of d.current)URL.revokeObjectURL(M.url)}),[]);const k=g.useCallback(async(M,B)=>{const T=d.current.reduce((Z,W)=>{var X;return Z+(W.id===(B==null?void 0:B.id)?0:((X=W.blob)==null?void 0:X.size)??0)},0),P=(B==null?void 0:B.id)??++p.current,q=URL.createObjectURL(M),K={id:P,name:M.name||"image",url:q,blob:null,resized:null},z=b.current;w.current.set(P,M);let H=!1;const D=()=>{H||(H=!0,j(Z=>Wxe(Z,K,B!==void 0)))},O=await Sxe(M,kxe(T),async Z=>(D(),_xe(Z))).catch(()=>({ok:!1,problem:"unreadable"})),V=d.current.some(Z=>Z.id===P);return!m.current||b.current!==z||!V&&(H||B)?(URL.revokeObjectURL(q),B&&URL.revokeObjectURL(B.url),m.current&&w.current.delete(P),""):(w.current.delete(P),O.ok?(D(),B&&URL.revokeObjectURL(B.url),j(Z=>Z.map(W=>W.id===P?{...W,blob:O.blob,resized:O.resized}:W)),""):(URL.revokeObjectURL(q),H&&j(Z=>Hxe(Z,P,B)),Fxe(O.problem,M.name||"image")))},[j]),v=g.useCallback(async M=>{i("");const B=b.current,T=[];let P=0,q=0;for(const z of M){if(!m.current||b.current!==B)return;const H=x.current.indexOf(z);if(H!==-1&&x.current.splice(H,1),d.current.length>=Jo){P++;continue}const D=d.current.length,O=await k(z);O&&T.push(O),d.current.length>D&&q++}if(!m.current||b.current!==B)return;P>0&&T.push(q===0&&T.length===0?DO:Pxe(P)),i(T.join(" "));const K=d.current.length;q>0&&u(`${q===1?"Image":`${q} images`} added, ${K} of ${Jo}.`)},[k,i]),S=g.useCallback(async(M,B)=>{i("");const T=d.current.find(K=>K.id===M);if(!T)return v([B]);const P=await k(B,T);if(!m.current)return;i(P);const q=d.current.findIndex(K=>K.id===M);!P&&q!==-1&&u(`Image ${q+1} replaced, ${d.current.length} of ${Jo}.`)},[v,k,i]),C=g.useCallback(M=>{const B=b.current;f.current=(f.current??Promise.resolve()).then(()=>b.current===B?M():void 0).catch(()=>{})},[]),_=g.useCallback(M=>{M.length!==0&&(x.current.push(...M),C(()=>v(M)))},[v,C]);g.useEffect(()=>{e&&e.waiting.length>0&&_(e.waiting)},[]);const R=g.useCallback((M,B)=>{const T=B[0];T&&C(()=>S(M,T))},[C,S]),A=g.useCallback(M=>{const B=d.current.find(T=>T.id===M);B&&(URL.revokeObjectURL(B.url),w.current.delete(M),j(T=>T.filter(P=>P.id!==M)),i(""),u(`Image removed, ${d.current.length} of ${Jo}.`))},[j,i]),I=g.useCallback(()=>i(DO),[i]),$=g.useCallback(async()=>{const M=o.current;return await f.current,o.current!==M?null:d.current.flatMap(B=>B.blob?[B.blob]:[])},[]),U=g.useCallback(()=>({ready:d.current.flatMap(M=>M.blob&&!w.current.has(M.id)?[{name:M.name,blob:M.blob,resized:M.resized}]:[]),waiting:[...w.current.values(),...x.current]}),[]),F=g.useCallback(()=>{b.current++;for(const M of d.current)URL.revokeObjectURL(M.url);w.current.clear(),x.current=[],j(()=>[]),i("")},[j,i]);return{shots:t,problem:s.problem,problemId:s.id,announcement:l,add:_,replace:R,remove:A,sayFull:I,ready:$,kept:U,clear:F}}function Vxe(){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(sye(s))}).catch(()=>{}),()=>{n=!1}},[]),e}function Gxe(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(!_n(s.current))return;s.current=!0;const{signal:u}=a.current=new AbortController;n({state:"sending"});try{const d=await e.ready();if(u.aborted)return;if(!d){n({state:"failed",message:Lxe});return}const f=await fetch("/api/feedback",{...Rxe(nye(l),d),signal:u}),p=await f.json().catch(()=>null);n(f.ok&&(p!=null&&p.ok)?{state:"sent"}:{state:"failed",message:CO(f.status,p==null?void 0:p.reason,p==null?void 0:p.errors)})}catch{u.aborted||n({state:"failed",message:CO(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 Kxe(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),_O),i=window.setTimeout(()=>a.current(),_O+wye);return()=>{window.clearTimeout(o),window.clearTimeout(i)}},[e]),n}const J0="agent-dag.feedbackDrafts",FO=4;function Yxe({initialKind:e,initialBody:t}){return{kind:e??"bug",body:t??""}}function Xxe(e){return JSON.stringify([e.kind,e.body])}function Zxe(e){return e.ready.length+e.waiting.length}function Z8(e,t){return e.body.trim()!==t.body.trim()||e.contact.trim()!==""||e.images>0}function Jxe(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 Qxe="Discard",eve="Confirm discard",tve="Clear the message, the screenshots and the contact",BO="Press again to clear this draft. It cannot be brought back.",nve={ready:[],waiting:[]};function sve(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!Lp.some(i=>i.value===n)||typeof s!="string"||s.length>S8||typeof a!="string"||a.length>C8||typeof o!="number"||!Number.isInteger(o)||o<0||o>Jo?null:[e[0],{kind:n,body:s,contact:a,images:o}]}function rve(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(J0),l=i?JSON.parse(i):[];if(Array.isArray(l))for(const u of l.slice(-FO)){const d=sve(u);d&&t.set(d[0],{...d[1],images:null,imageCount:d[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(J0):o.setItem(J0,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??nve,imagesLost:i.images?0:i.imageCount}:null},keep(o,i,l){const u=Zxe(i.images);if(!Z8({body:i.body,contact:i.contact,images:u},l)){a(o);return}const d=n();d.delete(o),d.set(o,{kind:i.kind,body:i.body,contact:i.contact,images:i.images,imageCount:u});for(const f of d.keys()){if(d.size<=FO)break;d.delete(f)}s()},forget:a}}function ave(){try{return typeof window>"u"?null:window.sessionStorage}catch{return null}}const Ij=rve(ave),ove=4e3;function ive(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||Ij.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&&Ij.forget(e)},[a,e])}const qO="draft";function lve(e){const[t,n]=g.useState(!1),s=g.useRef(0);g.useEffect(()=>{if(!t)return;const o=window.setTimeout(()=>n(!1),ove);return()=>window.clearTimeout(o)},[t]);function a(){const o=Date.now(),i=fi({armedFor:t?qO:null,target:qO,armedAt:s.current,now:o,gapMs:hi});if(i==="arm"){n(!0),s.current=o;return}i!=="ignore"&&(n(!1),e())}return{armed:t,press:a}}function J8({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),d=g.useRef(null),f=g.useRef(null),p=g.useRef(0),m=gt(e,{focusRef:s}),w=wt(e),x=Yxe({initialKind:t,initialBody:n}),b=Xxe(x),[j]=g.useState(()=>Ij.read(b)),[k,v]=g.useState((j==null?void 0:j.kind)??x.kind),[S,C]=g.useState((j==null?void 0:j.body)??x.body),[_,R]=g.useState((j==null?void 0:j.contact)??""),[A,I]=g.useState((j==null?void 0:j.imagesLost)??0),[$,U]=g.useState(!1),[F,M]=g.useState(!1),[B,T]=g.useState(!1),P=zxe(j==null?void 0:j.images),q=oye(Vxe()),{outcome:K,sending:z,send:H,clearFailure:D}=Gxe(P),O=K.state==="sent",V=Kxe(O,e);ive(b,x,{kind:k,body:S,contact:_},P,O);const Z=Z8({body:S,contact:_,images:P.shots.length},x),W=lve(()=>{var ke;v(x.kind),C(x.body),R(""),I(0),M(!1),P.clear(),D(),(ke=s.current)==null||ke.focus()}),X=N8(k),Y=F&&!NO(S),J=A>0&&P.shots.length===0,Q=[Y&&"fb-body-error",J&&"fb-images-lost"].filter(Boolean).join(" ")||void 0,[te,le]=mye(to());g.useEffect(()=>{var De,Ue;const ke=i.current;if(!ke)return;const Ie=ke.contains(document.activeElement)||Hn(((De=document.activeElement)==null?void 0:De.tagName)??null);ke.inert=O,O&&Ie&&((Ue=a.current)==null||Ue.focus())},[O]),g.useEffect(()=>{var Ke,we;const ke=l.current;if(!ke)return;const Ie=d.current;if(z){const Fe=document.activeElement,Re=Fe!=null&&(ke.contains(Fe)||Fe===Ie);f.current=Re?Fe:null,ke.inert=!0,Ie&&(Ie.inert=!0),f.current&&((Ke=u.current)==null||Ke.focus());return}ke.inert=!1,Ie&&(Ie.inert=!1);const De=f.current;f.current=null;const Ue=document.activeElement===u.current||Hn(((we=document.activeElement)==null?void 0:we.tagName)??null);!O&&De&&Ue&&De.focus()},[z,O]);function de(ke){var Ie;if(ke.preventDefault(),!NO(S)){M(!0),(Ie=s.current)==null||Ie.focus();return}H({kind:k,body:S,contact:_})}const oe=!O&&!z,re=ke=>Exe(Array.from(ke.dataTransfer.types));function he(ke){!re(ke)||!oe||(ke.preventDefault(),p.current++,T(!0))}function fe(ke){re(ke)&&(ke.preventDefault(),ke.dataTransfer.dropEffect=oe?"copy":"none")}function $e(ke){re(ke)&&(p.current=Math.max(0,p.current-1),p.current===0&&T(!1))}function ye(ke){re(ke)&&(ke.preventDefault(),p.current=0,T(!1),oe&&P.add(Array.from(ke.dataTransfer.files)))}function ge(ke){ke.target!==ke.currentTarget||!re(ke)||(ke.preventDefault(),ke.dataTransfer.dropEffect="none")}function je(ke){re(ke)&&ke.preventDefault()}function Le(ke){if(!oe)return;const Ie=Array.from(ke.clipboardData.files),De=ke.target,Ue=De instanceof HTMLTextAreaElement||De instanceof HTMLInputElement,Ke=Array.from(ke.clipboardData.types).includes("text/plain");Txe({files:Ie.length,hasText:Ke,intoTextField:Ue})&&(ke.preventDefault(),P.add(Ie))}return r.jsx("div",{className:"modal-backdrop",...w,role:"presentation",onDragOver:ge,onDrop:je,"data-leaving":V||void 0,children:r.jsxs("div",{ref:m,className:"modal feedback-dialog",onClick:ke=>ke.stopPropagation(),onDragEnter:he,onDragOver:fe,onDragLeave:$e,onDrop:ye,onPaste:Le,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:W.armed?BO:yye(K.state)}),r.jsxs("div",{className:"fb-stage",children:[r.jsxs("form",{ref:i,className:"fb-form",onSubmit:de,onKeyDown:ke=>{pye(ke.nativeEvent)&&(ke.preventDefault(),ke.currentTarget.requestSubmit())},noValidate:!0,children:[r.jsxs("section",{ref:l,className:"modal-body fb-body",children:[r.jsx(sxe,{kind:k,onChange:v}),r.jsxs("div",{className:"fb-compose",children:[r.jsx("label",{className:"fb-label",htmlFor:"fb-body",children:X.question}),r.jsx("textarea",{ref:s,id:"fb-body",className:"ap-manage-input fb-message",value:S,maxLength:S8,rows:5,placeholder:X.placeholder,onChange:ke=>C(ke.target.value),"aria-invalid":Y||void 0,"aria-describedby":Q,required:!0}),Y&&r.jsx("p",{id:"fb-body-error",className:"fb-error",children:Jge}),r.jsx(qxe,{images:P,addRef:o}),J&&r.jsx("p",{id:"fb-images-lost",className:"fb-hint",children:Jxe(A)}),r.jsxs("div",{className:"fb-tools",children:[r.jsx(Bxe,{images:P,buttonRef:o}),r.jsx(rxe,{open:$,onToggle:()=>U(ke=>!ke)})]}),r.jsx(axe,{open:$,contact:_,onContact:R})]}),r.jsx("p",{className:"fb-facts",children:q?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"fb-facts-value",children:q})," — ",iye]}):lye}),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:d,type:"button",className:`btn danger fb-discard${W.armed?" armed":""}`,onKeyDown:ke=>{ke.repeat&&ke.preventDefault()},onClick:W.press,title:W.armed?BO:tve,children:W.armed?eve:Qxe}),r.jsxs("span",{className:"fb-shortcut","aria-hidden":"true",children:[r.jsx("kbd",{"data-symbol":gye(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",...qn(z),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…"})]})})]})]}),O&&r.jsxs("div",{className:"fb-done",children:[r.jsx(Cp,{}),r.jsx("p",{className:"fb-done-line",children:_8})]})]}),r.jsx("div",{className:"fb-drop","aria-hidden":"true","data-active":B||void 0,children:r.jsxs("div",{className:"fb-drop-frame",children:[r.jsx(X8,{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 Q8="Press Esc first if a key does nothing.",Q0=[{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:[]}]}],cve=/ \([A-Z?]\)/g;function eB(e,t=()=>!0){const n=s=>s.integration===void 0||t(s.integration);return e&&Q0.every(s=>s.rows.every(n))?Q0:Q0.map(s=>({...s,rows:s.rows.filter(n).filter(a=>e||a.chord||!a.binds.some(iD)).map(a=>e?a:{...a,action:a.action.replace(cve,"")})})).filter(s=>s.rows.length>0)}const uve="Single-key shortcuts are off.",tB="Settings › Keyboard",dve=`Single-key shortcuts can be turned off in ${tB}.`;function hve({onClose:e,onTour:t,onSettings:n}){const s=gt(e),a=wt(e),o=co(to()),i=An(),l=Id(),u=eB(i,d=>na(l,d));return r.jsx("div",{className:"modal-backdrop",...a,role:"presentation",children:r.jsxs("div",{ref:s,className:"modal key-help",onClick:d=>d.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"key-help-title","aria-describedby":i?void 0:"key-help-off",children:[r.jsxs("header",{className:"modal-head",children:[r.jsx("div",{className:"modal-title",children:r.jsx("span",{id:"key-help-title",className:"modal-tool-name",children:"Keyboard shortcuts"})}),r.jsx("div",{className:"modal-actions",children:r.jsx("button",{type:"button",className:"glyph-btn",onClick:e,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})})]}),r.jsxs("section",{className:"modal-body",children:[!i&&r.jsxs("div",{className:"kh-off",children:[r.jsxs("p",{className:"kh-off-text",id:"key-help-off",children:[r.jsx("strong",{children:uve})," Turn them back on in"," ",r.jsx("span",{className:"kh-place",children:tB}),". 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(d=>r.jsxs(g.Fragment,{children:[r.jsx("h3",{className:"kh-group",children:d.title}),d.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})]},`${d.title}:${f.cap}:${f.action}`))]},d.title))}),i&&r.jsxs("p",{className:"kh-foot",children:[Q8," ",dve]})]})]})})}function fve(e,t){return`${e}#${t}`}function pve(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=fve(i.key,i.since);if(s.has(l)||Noe(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 mve(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 nB({rows:e,ours:t,dialogs:n}){return e===0?!1:t||n===0}function gve(e){return e===1?"Account needs your attention":"Accounts need your attention"}function yve(e){return`${e===1?"One Claude account needs":`${e} Claude accounts need`} you to sign in again.`}const wve="Login expired",xve="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.",vve="The account stays marked in the Accounts panel. This will not ask again until it has worked and stopped again.";function bve(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 kve({request:e,waiting:t,busy:n,now:s,onAccept:a,onDecline:o,onLater:i}){const l=g.useRef(null),u=gt(i,{focusRef:l}),d=wt(i),f=eo(n,"accept"),p=eo(n,"dismiss");return r.jsx("div",{className:"modal-backdrop",...d,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 ",hS(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 jve(e){const t=g.useRef(!1),n=Nve(e),s=nB({rows:n?1:0,ours:t.current,dialogs:ln.dialogDepth()});return t.current=s,s?n:null}function Nve({lanPending:e,lanDeferred:t,lanBusy:n,answerLanPair:s,deferLanPair:a}){const{request:o,waiting:i}=bve(e,t.current);return o?r.jsx(kve,{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 Sve({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:xve})]}):r.jsxs(r.Fragment,{children:[r.jsx("p",{id:"reauth-lead",className:"reauth-lead",children:yve(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:wve}),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:vve,onClick:n,children:"Not now"}),a&&r.jsx("button",{type:"button",className:"btn primary",ref:s,onClick:()=>t(a),children:"Sign in again"})]})]})}function Cve({rows:e,onSignIn:t,onLater:n}){const s=g.useRef(null),a=gt(n,{focusRef:s}),o=wt(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:gve(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(Sve,{rows:e,onSignIn:t,onLater:n,firstRef:s})]})})}function _ve({rows:e,signingIn:t,signIn:n,signedIn:s,refresh:a,closeSignIn:o,later:i,pairing:l=!1}){const u=g.useRef(!1),d=ln.dialogDepth()+(l?1:0),f=t!=null||nB({rows:e.length,ours:u.current,dialogs:d});return u.current=f,t?r.jsx(x6,{email:t.email||null,onClose:o,onChanged:a,onSignedIn:s}):f?r.jsx(Cve,{rows:e,onSignIn:n,onLater:i},e.length===1?"one":"many"):null}const Eve={"//":["What a user would NOTICE. One key per version that has something to say,","and no key at all for a version that has nothing — which is most of them.","","The rule this file exists to serve: before every release, ask 'what would a","user notice?' and write the answer here. 'Nothing user-visible' is a valid","and expected answer, and it is spelled by adding no key. A release with no","key shows no modal, and that silence is what keeps the modal worth reading","on the day it is not silent.","","What belongs here: something that changed on the user's machine or under","their hands — a hook written to or removed from settings.json, a default","that flipped, a control that moved or went away, a stored preference that","changed meaning. What does not: bounds, races, assertions that could not","fire, anything that is invisible when it is correct.","","Write it for the person running the deck, not for the person reading the","diff. `title` is the sentence they scan; `body` is what they need in order","to act on it, or to stop worrying about it.","","Keys are versions exactly as package.json spells them. A key that is not a","version, or an entry missing either field, fails the suite rather than","being quietly dropped — see src/web/__tests__/release-notes-file.test.ts.","Ordering here is for humans; the deck sorts by version itself.","","A title may open with an emoji, and if it does, put exactly ONE space after","it. Not two: the dialog gives a leading emoji its own optical gap, because","a colour glyph is drawn edge to edge inside its advance and one word space","after one reads as none. A second space here would be a lie in the data","about a defect in the type, and the suite refuses both it and no space at","all.","","A release that genuinely has nothing to say is spelled TWICE: no key here,",'and its version written into "//nothing-to-say" below. One spelling on its',"own is ambiguous — a missing key reads the same whether it was a decision","or a forgotten step, and five releases in a row were once forgotten. The list","is what tells the two apart, and release-notes-current-version.test.ts fails","the release whose version is in neither place. Any key opening with // is","author metadata and never a release.","","Editorial metadata: optional //summaries maps a release version to one","specific, verified headline (1–120 characters). No generic marketing claims.","A note may have priority: highlight or required. Choose at most 3 highlights,","only when warranted. Unmarked notes go under More improvements when highlights","exist. Legacy notes stay unabridged; legacy upgrade notes stay visible.","Use required for breaking changes, changed settings, privacy/security impact,","compatibility requirements or mandatory actions. A highlight with any such","impact must also carry a notice with all essential qualifications: highlight","alone is editorial placement, not an instruction to surface it across upgrades.","Required notes and notices stay visible across upgrades, never in a closed section.","Write a short benefit-led title and one useful sentence where possible; keep","opt-outs and limits. Avoid inflated adjectives, filler and generic claims.","Preserve original factual meaning. Never invent capabilities or results.","Retain setup instructions and compatibility minimums. Say only what a user","sees in the app: usage reports, telemetry and environment variables are for","README to explain, not for a note.","Verify each claim against the released diff and tests. No promotion","for invisible fixes. Do not rewrite historical releases to fit the layout.","","Keep highlight titles within 72 characters (excluding a leading emoji) and","benefit descriptions within 240 characters. These limits are validated.","Put essential compatibility, privacy or configuration details in optional","notice text, outside More improvements. Current/upgrade notices stay visible and","have no truncation limit. A notice also keeps its change visible across upgrades.","Optional noticeLabel gives it a short factual heading (1–32 characters), such","as Setup change or Compatibility. It requires notice text; default is Important.","Optional details holds secondary context, shown under the same improvements","disclosure for highlights and beside other notes. Keep the body to one useful","sentence. Never move setup, safety, privacy or compatibility conditions into","details: use notice for those, so they remain visible across upgrades.","The disclosure counts other improvements, not extra details of highlights.","Mark any other mandatory action as required. The manual digest shows only the","running release; Release history opens the full changelog. Upgrade notes keep","required/noticed changes visible and disclose the other notes in that range.","Unclassified legacy upgrade notes stay visible rather than guessing safety.","Before adding editorial metadata to a release, review every note: unmarked","changes will be treated as optional in later upgrades. Never infer safety","from a title, keyword, emoji, position or a shortened description.","","Optional icon is a semantic key: plans, accounts or skills. Use it only when","it matches the change; do not infer icons from versions, titles or emoji.","The modal shows a title's leading emoji; the glyph stands in only for a title","without one."],"//summaries":{"3.46.0":"Plans, accounts and skills at a glance"},"//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.1","3.49.1"],"3.49.0":[{title:"🗞️ What's new is shorter and easier to scan",body:"Up to three main changes come first and the rest wait under Show details; Check for updates moved to the dialog's More options menu."},{title:"👥 No warning when one account is in use on several decks",body:"The account row and the desktop no longer flag it, and the Login active on another deck switch is gone from Settings › Notifications; expired logins are still shown.",priority:"required"},{title:"📍 Auto-hidden sessions come back where they were",body:"With Hide finished sessions after on, a session that works again returns to its place, with its new subagents beside it rather than further down the board."},{title:"💻 Windows: About flags an outdated terminal CLI",body:"When the npm ccdeck on PATH is older than the desktop app, Settings › About shows the command that updates it."},{title:"✏️ Texts that fell behind are up to date",body:"Explore integrations says Jira can move issues, and the Radar and Where the time went tips match what the app does."}],"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:"🗺️ Follow plans at any zoom",body:"See plan progress on session notes and directly on the canvas.",priority:"highlight",icon:"plans",details:"Subagents stay in one column beside their parent."},{title:"✅ Keep your Claude account in sync",body:"After `/login`, Accounts, Switch, Auto-switch and Usage follow your active Claude Code account.",priority:"highlight",icon:"accounts",details:"Auto-switch can also 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:"🧩 See which skills your agents use",body:"Review skill activity from the right sidebar, including typed slash commands.",priority:"highlight",notice:"Counting typed slash commands adds a `UserPromptExpansion` hook to Claude Code's `settings.json` on supported versions (2.1.116+). Set `AGENTS_DECK_SKILL_HOOK=0` to opt out.",icon:"skills",noticeLabel:"Setup change"},{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.`}]},KS="agent-dag.releaseNotesSeen";function UO(e){return e.split(/[.\-+]/).map(t=>parseInt(t,10)).map(t=>Number.isNaN(t)?0:t)}function ha(e,t){const n=UO(e),s=UO(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 ks(e){return typeof e=="string"&&/^\d+\.\d+\.\d+/.test(e)}function Tve(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 Ave(e){if(!e||typeof e!="object")return[];const t=[];for(const[n,s]of Object.entries(e)){if(!ks(n)||!Array.isArray(s))continue;const a=s.filter(Tve).map(l=>({title:l.title,body:l.body,...typeof l.details=="string"&&l.details.trim()?{details:l.details}:{},...l.priority==="highlight"||l.priority==="required"?{priority:l.priority}:{},...typeof l.notice=="string"&&l.notice.trim()?{notice:l.notice}:{},...typeof l.notice=="string"&&l.notice.trim()&&typeof l.noticeLabel=="string"&&l.noticeLabel.trim()&&l.noticeLabel.length<=32?{noticeLabel:l.noticeLabel}:{},...l.icon==="plans"||l.icon==="accounts"||l.icon==="skills"?{icon:l.icon}:{}})),o=e["//summaries"],i=o&&typeof o=="object"&&Object.hasOwn(o,n)?o[n]:void 0;a.length&&t.push({version:n,notes:a,...typeof i=="string"&&i.trim()?{summary:i}:{}})}return t.sort((n,s)=>ha(s.version,n.version))}function Rve(e){const t=e.filter(o=>o.priority==="highlight").slice(0,3),n=t.length>0,s=e.filter(o=>!t.includes(o)&&(!n||o.priority==="required"||o.priority==="highlight"||!!o.notice)),a=e.filter(o=>!t.includes(o)&&!s.includes(o));return{highlights:t,visible:s,more:a}}function Mve(e,t,n){const[s,...a]=e;if(!t)return{latest:ks(n)?e.find(l=>ha(l.version,n)===0):s,visiblePrevious:[],history:[]};const o=[],i=[];for(const l of a){const u=l.notes.some(p=>p.priority==="highlight"||p.priority==="required"||!!p.notice),d=l.notes.filter(p=>!u||p.priority==="required"||!!p.notice);d.length&&o.push({version:l.version,notes:d});const f=l.notes.filter(p=>!d.includes(p));f.length&&i.push({...l,notes:f})}return{latest:s,visiblePrevious:o,history:i}}const WO=Ave(Eve);function sB(e,t,n){return e.filter(s=>ha(s.version,n)<=0&&(t===null||ha(s.version,t)>0))}function $ve(e,t){return e.filter(n=>ha(n.version,t)===0)}function Lve(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}`}const Ive=new RegExp("^(?:\\p{Extended_Pictographic}|\\p{Emoji_Modifier}|\\p{Regional_Indicator}|[\\u200D\\uFE0F])+(?= \\S)","u");function rB(e){const t=Ive.exec(e);return t?{icon:t[0],rest:e.slice(t[0].length)}:{icon:null,rest:e}}function Ove(e){if(!e)return null;let t=null;try{t=e.getItem(KS)}catch{return null}return ks(t)?t:null}function Pve(e){if(!e)return!1;try{return e.getItem(KS),!0}catch{return!1}}function Dve(e,t){if(!e)return!1;try{return e.setItem(KS,t),!0}catch{return!1}}const aB="agent-dag.tourSeen";function Fve(e){if(!e)return!1;try{return e.getItem(aB)==="1"}catch{return!1}}function Bve(e){if(!e)return!1;try{return e.setItem(aB,"1"),!0}catch{return!1}}function qve({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 Uve({stored:e,running:t,notes:n,remembers:s=!0}){if(!ks(t))return{show:[],record:null,reason:"no-version"};if(!ks(e)){if(!s)return{show:[],record:t,reason:"cannot-remember"};const i=$ve(n,t);return i.length?{show:i,record:t,reason:"welcome"}:{show:[],record:t,reason:"first-run"}}const a=ha(e,t);if(a===0)return{show:[],record:null,reason:"seen"};if(a>0)return{show:[],record:null,reason:"ahead"};const o=sB(n,e,t);return o.length?{show:o,record:t,reason:"new-notes"}:{show:[],record:t,reason:"nothing-new"}}function Wve(e,t){if(/\s|^$/.test(e[t+2]??""))return-1;let n=t+2;for(;n<e.length;){if(e[n]==="`"){const s=e.indexOf("`",n+1);if(s<0)break;n=s+1;continue}if(e.startsWith("**",n)&&!/\s/.test(e[n-1]??" "))return n;n++}return-1}function qu(e,t=!0){const n=[];let s="";const a=()=>{s&&(n.push({kind:"text",text:s}),s="")};let o=0;for(;o<e.length;){if(e[o]==="`"){const i=e.indexOf("`",o+1);if(i>o+1){a(),n.push({kind:"code",text:e.slice(o+1,i)}),o=i+1;continue}}else if(t&&e.startsWith("**",o)){const i=Wve(e,o);if(i>0){a(),n.push({kind:"bold",kids:qu(e.slice(o+2,i),!1)}),o=i+2;continue}}s+=e[o],o+=1}return a(),n}function ao(e=typeof navigator>"u"?"":navigator.userAgent){return/\bccdeck-desktop\/\d/.test(e)}function Sje(e,t,n){if(e===null)return null;const s=e+t-n;return s>0?s:null}function Cje(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 Hve(e){return(e??[]).filter(t=>t.installed&&t.profiles>0)}function _je(e){return!Number.isFinite(e)||e<=0?"empty":Jn(e)}function Eje(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 zve(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 Tje(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=Hve(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 Vve="Ask npm now whether a newer ccdeck is out.",HO="Checking…",Gve="Couldn't reach npm. Try again.",Kve="Couldn't reach the deck. Try again.",oB="Update checks are off on this deck (AGENTS_DECK_NO_UPDATE_CHECK or AGENTS_DECK_NO_INSTALL).",Yve="The deck looks again in five minutes.";function Xve(e,t,n,s){const a=s?t.npx:n?Kt(t,n):void 0;return a?`${e} is out, but ${a}`:`${e} is out. Run:`}const Dn=(e,t={})=>({said:e,tone:"answer",age:null,command:null,action:null,...t}),Vo=e=>Dn(e,{tone:"note"});function zO(e,t){return zve(e,t)??"just now"}function Zve(e,t){const n=e.update;return(n==null?void 0:n.status)==="ready"?Vo(`${n.version} is ready. Restart to update.`):(n==null?void 0:n.status)==="checking"?Vo("The app is checking for updates…"):(n==null?void 0:n.status)==="downloading"?Vo(n.version?`${n.version} is out. The app is downloading it.`:"The app is downloading an update."):(n==null?void 0:n.status)==="current"?Vo(`You're on the latest, ${e.version??t}. You can check again here.`):(n==null?void 0:n.status)==="error"?Vo("The app's last update check failed. Try Check for updates again."):Vo("The app keeps itself up to date. Check for updates here.")}function Jve(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 Dn(`${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 Dn(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 Dn(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:`:Xve(t,n,s==null?void 0:s.upgradeBlocked,(s==null?void 0:s.upgradeMode)==="npx"),o=(s==null?void 0:s.command)??null;return Dn(a,{command:o,action:o?{kind:"copy",label:e.copied?"Copied":"Copy",busy:!1}:null})}function Qve(e){const t=e.version;if(e.unreachable)return Dn(Kve,{tone:"warn"});const n=t!=null&&t.checkFailedAt&&t.checkFailedAt>(t.checkedAt??0)?t.checkFailedAt:null;if(n)return Dn(Gve,{tone:"warn",age:e.answered?null:`Last tried ${zO(n,e.now)}.`});const s=t!=null&&t.latestPending&&t.latestPending!==e.running?t.latestPending:null;if(s)return Dn(`${s} is tagged on npm but can't be installed yet. ${Yve}`);const a=t!=null&&t.checkedAt?zO(t.checkedAt,e.now):null;if((t==null?void 0:t.checkedAt)&&e.now>=t.checkedAt&&e.now-t.checkedAt<=60*6e4&&(t!=null&&t.latest)&&ks(t.latest)&&ks(e.running)){const i=ha(t.latest,e.running),l=i===0?`You're on the latest, ${e.running}.`:i<0?`You're on ${e.running}, ahead of npm's ${t.latest}.`:`${t.latest} is out.`;return Dn(l,{age:a?`Checked ${a}.`:null})}return Dn(a?"Update status may have changed.":"No update check yet.",{age:a?`Last checked ${a}.`:null})}function ebe(e,t){var a,o;const n=e.version;if((a=e.app)!=null&&a.inApp&&(n!=null&&n.checkDisabled)){const i=Zve(e.app,e.running);return i&&{canCheck:!0,checking:e.checking||((o=e.app.update)==null?void 0:o.status)==="checking",line:e.unreachable?Dn("The desktop updater did not accept the check. Try the ccdeck menu or update the desktop app.",{tone:"warn"}):e.checking?Dn(HO):i}}if(n!=null&&n.checkDisabled)return{canCheck:!1,checking:!1,line:Vo(oB)};const s=(n==null?void 0:n.notice)??null;if((s==null?void 0:s.kind)==="upgrade")return{canCheck:!0,checking:e.checking,line:Jve(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:Dn(i)}}return e.checking?{canCheck:!0,checking:!0,line:Dn(HO)}:{canCheck:!0,checking:!1,line:Qve(e)}}const iB=450;async function tbe(e,t=n=>new Promise(s=>setTimeout(s,n))){const[n]=await Promise.all([e(!0),t(iB)]);return n?"answered":"unreachable"}async function nbe(e=fetch){try{const[t]=await Promise.all([e("/api/desktop-update/check",{method:"POST",signal:AbortSignal.timeout(8e3)}),new Promise(n=>setTimeout(n,iB))]);return t.ok?"answered":"unreachable"}catch{return"unreachable"}}const sbe="Eight pictures of what the deck shows.",VO="Restart the deck. Sessions, settings and pairings come back as they were.";function rbe(e){var A,I,$;const t=(e==null?void 0:e.versionCheck.versionChecking)??!1,n=Sr(3e4),[s,a]=g.useState(!1),o=g.useRef(!1),[i,l]=g.useState(!1),[u,d]=g.useState(!1),f=g.useRef(t);if(g.useEffect(()=>{f.current&&!t&&d(!0),f.current=t},[t]),!e)return null;const{versionCheck:p,upgrade:m,restart:w,desktopUpdate:x,running:b,onHandOff:j}=e,k=ebe({version:p.version,running:b,checking:s||t,answered:u,unreachable:i,now:Math.max(n,Date.now()),upgradeState:m.upgradeState,copied:m.cmdCopied,restarting:w.restarting,app:{inApp:ao(),update:x.appUpdate,version:O8(),menu:D8()}},$j);if(!k)return null;const v=ao()&&((A=p.version)==null?void 0:A.checkDisabled),S=v?"Ask the desktop app whether a newer ccdeck is out.":Vve,C=async()=>{var F;if(!_n(o.current||t)||v&&((F=x.appUpdate)==null?void 0:F.status)==="checking")return;o.current=!0,a(!0);const U=v?await nbe():await tbe(p.loadVersion);o.current=!1,a(!1),l(U==="unreachable"),d(!0)},_=U=>{if(U.kind==="copy")return void m.copyCommand();j(),p.showNotice(),U.kind==="install"?m.startUpgrade():w.askRestart({upgrade:!0})},R=k.line.tone==="warn"||!!k.line.action||!!((I=p.version)!=null&&I.notice)||(($=x.appUpdate)==null?void 0:$.status)==="downloading";return{state:k,check:C,act:_,checkWhy:S,needsAttention:R}}function abe({update:e}){const t=oc("above","dialog"),n=g.useId();return r.jsxs("div",{className:"rn-status-row",children:[e?r.jsx(obe,{line:e.state.line,onAct:e.act,bindHint:t.bind,whyId:`${n}-action`,announce:!1}):r.jsx("p",{className:"rn-update-line",children:r.jsx("span",{role:"status",children:"Update status unavailable."})}),t.node]})}function obe({line:e,onAct:t,bindHint:n,whyId:s,announce:a=!0}){const{action:o}=e,i=o&&r.jsx(ibe,{action:o,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:a?"status":void 0,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}),i]}):i]})}function ibe({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 lbe({entries:e,since:t,running:n,firstRun:s,onClose:a,onTour:o,updateVersion:i,updateBusy:l,onUpdateRestart:u,updateFailure:d,onRestart:f,updateCheck:p}){var B,T;const m=gt(a),w=g.useRef(null),x=wt(a),b=g.useId(),[j,k]=g.useState(null),v=rbe(p),S=((B=v==null?void 0:v.state.line.action)==null?void 0:B.kind)==="install"||((T=v==null?void 0:v.state.line.action)==null?void 0:T.kind)==="npx",C=f&&!i&&!S,{latest:_,visiblePrevious:R,history:A}=Mve(e,t!==null,n),I=`${b}-history`,$=!!C||!!(v!=null&&v.state.canCheck)&&!i;g.useEffect(()=>{var P;!$&&j&&(k(null),document.activeElement===document.body&&((P=w.current)==null||P.focus()))},[$,j]);const U=ks(n)?`v${n}`:Lve(e.slice(0,1)),F=s&&n?`New in v${n}.`:t?`Changes since v${t}.`:null,M=R.some(P=>P.notes.some(q=>!q.priority&&!q.notice));return r.jsx("div",{className:"modal-backdrop",...x,role:"presentation",children:r.jsxs("div",{ref:m,className:"modal release-notes",id:`${b}-dialog`,onClick:P=>P.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"}),U&&r.jsx("span",{className:"modal-tool-id",children:U})]}),r.jsxs("div",{className:"modal-actions",children:[$&&r.jsx("button",{id:`${b}-options`,type:"button",className:"glyph-btn","aria-label":"More options","aria-haspopup":"menu","aria-expanded":j!==null,"aria-controls":j?`${b}-menu`:void 0,onClick:()=>k(j?null:"first"),onKeyDown:P=>{(P.key==="ArrowDown"||P.key==="ArrowUp")&&(P.preventDefault(),k(P.key==="ArrowUp"?"last":"first"))},children:r.jsxs("svg",{className:"glyph",viewBox:"0 0 14 14",width:"14",height:"14",fill:"currentColor","aria-hidden":"true",children:[r.jsx("circle",{cx:"3",cy:"7",r:"1"}),r.jsx("circle",{cx:"7",cy:"7",r:"1"}),r.jsx("circle",{cx:"11",cy:"7",r:"1"})]})}),r.jsx("button",{ref:w,type:"button",className:"glyph-btn",onClick:a,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),r.jsx("span",{className:"rn-live-status",role:"status",children:i?`ccdeck v${i} is downloaded and verified.`:v==null?void 0:v.state.line.said}),r.jsxs("section",{className:"modal-body",role:"region","aria-label":"Release notes",tabIndex:0,children:[i?r.jsxs("div",{className:"rn-ready",children:[r.jsxs("p",{children:["ccdeck v",i," is downloaded and verified."]}),r.jsx("p",{className:"rn-update-said",role:"status",children:d})]}):r.jsxs(r.Fragment,{children:[(v==null?void 0:v.needsAttention)&&r.jsx(abe,{update:v}),r.jsx("p",{className:"rn-update-said",role:"status",children:d})]}),F&&r.jsx("p",{className:"rn-context",children:F}),!(_!=null&&_.notes.length)&&!R.length&&r.jsx("p",{className:"rn-empty",children:"No release notes for this build."}),_&&r.jsx(e1,{entry:_,showVersion:t!==null&&e.length>1},_.version),R.length>0&&r.jsxs("section",{className:"rn-upgrade-history","aria-label":"Earlier changes in this upgrade",children:[r.jsx("h2",{className:"rn-group-title",children:"Earlier in this upgrade"}),M&&r.jsx("p",{className:"rn-context",children:"Older notes are shown in full so setup and other important changes stay visible."}),R.map(P=>r.jsx(e1,{entry:P,showVersion:!0},P.version))]}),A.length>0&&r.jsxs("details",{className:"rn-history",children:[r.jsxs("summary",{"aria-controls":I,children:["Other changes since v",t]}),r.jsx("div",{id:I,children:A.map(P=>r.jsx(e1,{entry:P,showVersion:!0},P.version))})]})]}),r.jsxs("footer",{className:"rn-footer",children:[r.jsxs("div",{className:"rn-footer-links",children:[r.jsxs("a",{href:"https://ccdeck.dev/changelog/",target:"_blank",rel:"noopener noreferrer","aria-label":"Release history (opens in a new tab)",children:["Release history ",r.jsx(Zl,{})]}),o&&!i&&r.jsx("button",{className:"rn-text-button",type:"button",onClick:o,children:"Take the tour"})]}),i&&u?r.jsx("button",{className:"btn primary",type:"button",onClick:u,"aria-busy":l||void 0,children:l?"Restarting…":Jl}):r.jsx("button",{className:"btn primary",type:"button",onClick:a,children:"Done"})]}),j&&$&&r.jsxs(ac,{anchorId:`${b}-options`,portalRootId:`${b}-dialog`,id:`${b}-menu`,role:"menu",labelledBy:`${b}-options`,start:j,className:"ap-pop rn-options-menu",onClose:()=>k(null),children:[v&&r.jsxs("p",{className:"rn-menu-status",id:`${b}-check-status`,children:[v.state.line.said,v.state.line.age&&r.jsx("span",{children:v.state.line.age})]}),(v==null?void 0:v.state.canCheck)&&r.jsxs("button",{type:"button",className:"ap-menu-item rn-act",role:"menuitem",title:v.checkWhy,"aria-describedby":`${b}-check-status`,"aria-busy":v.state.checking||void 0,onClick:()=>void v.check(),children:[r.jsx(_Q,{}),"Check for updates"]}),(v==null?void 0:v.state.canCheck)&&C&&r.jsx("div",{className:"rn-menu-separator",role:"separator"}),C&&r.jsxs("button",{type:"button",className:"ap-menu-item",role:"menuitem",title:VO,"aria-describedby":`${b}-restart-why`,onClick:()=>{k(null),f==null||f()},children:[r.jsx(EQ,{}),"Restart ccdeck"]}),r.jsx("span",{hidden:!0,id:`${b}-restart-why`,children:VO})]})]})})}function e1({entry:e,showVersion:t}){const{highlights:n,visible:s,more:a}=Rve(e.notes),o=n.filter(l=>l.details),i=g.useId();return r.jsxs("section",{className:"rn-release",children:[t&&r.jsxs("h2",{className:"rn-version",children:["v",e.version]}),e.summary&&r.jsx("h2",{className:"rn-summary",children:e.summary}),r.jsxs("ul",{className:"rn-notes",children:[n.map((l,u)=>r.jsx(t1,{note:l,highlight:!0},`h${u}`)),s.map((l,u)=>r.jsx(t1,{note:l},`v${u}`))]}),(a.length>0||o.length>0)&&r.jsxs("details",{className:"rn-more",children:[r.jsxs("summary",{"aria-controls":i,children:[r.jsxs("span",{className:"rn-more-start",children:[r.jsx("span",{className:"rn-chevron","aria-hidden":"true",children:"›"}),r.jsx("span",{className:"rn-more-label",children:a.length?`${a.length} more ${a.length===1?"improvement":"improvements"}`:"More details"})]}),r.jsxs("span",{className:"rn-more-hint",children:[r.jsx("span",{className:"rn-show-details",children:"Show details"}),r.jsx("span",{className:"rn-hide-details",children:"Hide details"})]})]}),r.jsxs("div",{id:i,children:[r.jsx("ul",{className:"rn-notes",children:a.map((l,u)=>r.jsx(t1,{note:l},u))}),o.length>0&&r.jsxs("div",{className:"rn-highlight-details",role:"group","aria-labelledby":`${i}-highlights`,children:[r.jsx("h3",{id:`${i}-highlights`,className:"rn-details-title",children:"More about the highlights"}),o.map((l,u)=>r.jsxs("p",{className:"rn-note-body",children:[r.jsxs("strong",{className:"rn-strong",children:[rB(l.title).rest.trimStart(),": "]}),Uu(qu(l.details))]},u))]})]})]})]})}const cbe={plans:FD,accounts:BD,skills:qD};function t1({note:e,highlight:t}){const{icon:n,rest:s}=rB(e.title),a=!n&&e.icon?Kt(cbe,e.icon):void 0;return r.jsxs("li",{className:"rn-note","data-highlight":t||void 0,"data-required":e.priority==="required"||void 0,"data-has-icon":!!a||void 0,children:[a&&r.jsx("span",{className:"rn-title-icon","aria-hidden":"true",children:r.jsx(a,{})}),r.jsxs("div",{children:[r.jsxs("h3",{className:"rn-note-title",children:[n&&r.jsx("span",{className:"rn-note-icon",children:n}),n?s:s.trimStart()]}),r.jsx("p",{className:"rn-note-body",children:Uu(qu(e.body))}),!t&&e.details&&r.jsx("p",{className:"rn-note-body rn-extra-detail",children:Uu(qu(e.details))}),e.notice&&r.jsxs("p",{className:"rn-note-notice",children:[r.jsxs("strong",{children:[e.noticeLabel??"Important",": "]}),Uu(qu(e.notice))]})]})]})}function Uu(e){return e.map((t,n)=>t.kind==="text"?t.text:t.kind==="code"?r.jsx("code",{className:"rn-code",children:t.text},n):r.jsx("strong",{className:"rn-strong",children:Uu(t.kids)},n))}function ube({state:e,sessionId:t,onClose:n}){const s=g.useMemo(()=>dbe(e,t),[e,e.revision,t]),a=g.useRef(null),o=gt(n,{focusRef:a}),i=wt(n);return s?r.jsx("div",{className:"modal-backdrop",...i,role:"presentation",children:r.jsxs("div",{ref:o,className:"modal session-summary",onClick:l=>l.stopPropagation(),role:"dialog","aria-modal":"true","aria-labelledby":"ss-title",children:[r.jsxs("div",{className:"modal-head",children:[r.jsxs("div",{className:"modal-title",children:[r.jsx("span",{className:"state-pill state-done","aria-hidden":!0,children:"done"}),r.jsx("span",{id:"ss-title",className:"modal-tool-name",title:s.cwd??s.sessionId,children:s.label}),r.jsxs("span",{className:"modal-tool-id",children:["· ",s.sessionId.slice(0,8)]})]}),r.jsxs("div",{className:"modal-actions",children:[r.jsx("span",{className:"modal-dur",title:"Total wall time",children:s.durationLabel}),r.jsx("button",{type:"button",ref:a,className:"glyph-btn",onClick:n,"aria-label":"Close (Esc)",title:"Close (Esc)",children:"×"})]})]}),r.jsxs("div",{className:"modal-body",children:[r.jsxs("section",{className:"ss-hero",children:[r.jsxs("div",{className:"ss-hero-left",children:[r.jsx("div",{className:"ss-cost-label",children:$D}),r.jsx("div",{className:"ss-cost",children:lt(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":Qp(l),title:l,children:Qa(l)},l))})]}),r.jsx("div",{className:"ss-hero-right",children:s.cost.total>0&&r.jsxs(r.Fragment,{children:[r.jsx(ZN,{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:lt(s.cost.input)})]}),r.jsxs("span",{className:"ssl ssl-out",children:["output ",r.jsx("b",{children:lt(s.cost.output)})]}),r.jsxs("span",{className:"ssl ssl-cr",children:["cache r ",r.jsx("b",{children:lt(s.cost.cacheRead)})]}),r.jsxs("span",{className:"ssl ssl-cw",children:["cache w ",r.jsx("b",{children:lt(s.cost.cacheWrite)})]})]})]})})]}),r.jsxs("section",{className:"ss-stats",children:[r.jsx(pl,{label:"agents",value:s.agentCount}),r.jsx(pl,{label:"subagents",value:s.subagentCount}),r.jsx(pl,{label:"tool calls",value:s.toolCount}),r.jsx(pl,{label:"prompts",value:s.promptCount}),r.jsx(pl,{label:"tokens",value:s.tokensSum.toLocaleString()}),s.errCount>0&&r.jsx(pl,{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 pl({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 dbe(e,t){const n=e.agents.get(t);if(!n)return null;const s=[];for(const S of e.agents.values())S.sessionId===t&&s.push(S);if(s.length===0)return null;const a={input:0,output:0,cacheRead:0,cacheWrite:0,total:0},o=new Set,i=new Map;let l=0,u=0,d=0,f=0,p=0,m,w=1/0,x=0;for(const S of s){const C=Wn(S);a.input+=C.input,a.output+=C.output,a.cacheRead+=C.cacheRead,a.cacheWrite+=C.cacheWrite,a.total+=C.total;for(const R of SP(S))o.add(R);S.model&&o.add(S.model),S.kind==="subagent"&&p++;const _=aP(S.prompts);u+=_.length,!m&&_.length>0&&(m=_[0].text),d+=S.usage.inputTokens+S.usage.outputTokens,l+=S.toolCount,f+=S.toolErrorCount??0;for(const[R,A]of S.toolCountByName??[])i.set(R,(i.get(R)??0)+A);w=Math.min(w,S.startedAt),x=Math.max(x,S.endedAt??Date.now())}const b=Math.max(0,x-w),j=Math.floor(b/1e3),k=j<60?`${j}s`:j<3600?`${Math.floor(j/60)}m ${String(j%60).padStart(2,"0")}s`:`${Math.floor(j/3600)}h ${Math.floor(j%3600/60)}m`,v=Array.from(i.entries()).sort((S,C)=>C[1]-S[1]).slice(0,5);return{sessionId:t,label:n.label||n.cwdBasename||"session",cwd:n.cwd,durationLabel:k,cost:a,modelChips:Array.from(o),agentCount:s.length,subagentCount:p,toolCount:l,promptCount:u,tokensSum:d,errCount:f,topTools:v,firstPrompt:m}}function Bt({id:e,title:t,note:n,noteId:s,aside:a,list:o=!0,settingId:i,className:l,children:u}){const d=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:d,"data-setting":i,children:f}):r.jsxs("section",{className:d,"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:d}){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}),d]});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 lB(e,t){const[n,s]=g.useState(null),[a,o]=g.useState(!1),[i,l]=g.useState(""),u=g.useRef(!1),d=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(d((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||!_n(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(d(m.prefs[e]))}catch{l("Could not save this setting. Try again.")}finally{u.current=!1,o(!1)}}}}}function GO({provider:e}){const t=e==="Codex"?"recoverCodexSessions":"recoverClaudeSessions",n=`${e.toLowerCase()}-session-recovery`,s=lB(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,...qn(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(hbe,{})]})}function hbe(){const e=lB("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,...qn(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 fbe="Hide finished sessions after",pbe="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 mbe(){const e=y8();return r.jsx(Bt,{id:"settings-board-caption",title:"Board",children:r.jsx(mt,{settingId:"hide-finished",name:fbe,nameId:"settings-hide-finished-label",note:"Hidden sessions stay available in the session list.",details:pbe,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:f8.map(t=>r.jsx("option",{value:t,children:ige(t)},t))})})})}const gbe="Accounts and auto-switch",ybe="Your Claude accounts, and Auto-switch, which moves Claude Code to another one before the account in use runs out.",wbe="Local network",xbe="Pairing with the decks on your other machines, so a login that expires on one is repaired from another.",vbe="Browser Watch",bbe="Whether something drove your browser while you were away, and what the deck does about it.";function kbe({claudeHere:e,singleKeys:t,doors:n}){return r.jsxs(Bt,{id:"settings-elsewhere-caption",title:"Elsewhere on the deck",children:[e&&r.jsx(n1,{settingId:"accounts",name:gbe,note:ybe,onOpen:n.accounts,cap:t?{key:"A",title:"Press A anywhere to show or hide the accounts panel"}:null}),e&&r.jsx(n1,{settingId:"local-network",name:wbe,note:xbe,onOpen:n.localNetwork,cap:null}),r.jsx(n1,{settingId:"browser-watch",name:vbe,note:bbe,onOpen:n.browserWatch,dialog:!0,cap:t?{key:"B",title:"Press B anywhere to open or close Browser Watch"}:null})]})}function n1({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 jbe="Single-key shortcuts",Nbe="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 Sbe(e){const t=e.binds.includes("?")?"the keyboard shortcuts sheet":e.action;return t.charAt(0).toUpperCase()+t.slice(1)}function Cbe(e,t){const n=t.trim().toLowerCase();return n?[e.action,e.cap,e.macCap??""].some(s=>s.toLowerCase().includes(n)):!0}function _be({singleKeys:e,onToggleSingleKeys:t}){const n=co(to()),[s,a]=g.useState(""),o=g.useId(),i=Id(),l=eB(e,u=>na(i,u)).map(u=>({...u,rows:u.rows.filter(d=>Cbe(d,s))})).filter(u=>u.rows.length>0);return r.jsxs(r.Fragment,{children:[r.jsx(Bt,{children:r.jsx(mt,{settingId:"single-keys",name:jbe,nameId:"settings-single-keys-label",note:Nbe,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=>{rm(u.key)&&s&&(u.stopPropagation(),a(""))}})]}),l.map(u=>{const d=`settings-keys-${u.title.toLowerCase().replace(/[^a-z]+/g,"-")}`;return r.jsx(Bt,{id:d,title:u.title,className:"settings-keys",children:u.rows.map(f=>r.jsx(mt,{as:"div",name:Sbe(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:Q8})]})}function Ebe({notifyOn:e,onToggleNotify:t,notifyVetoed:n,notifyPermission:s,onAskNotify:a,accountNotify:o,onToggleAccountNotify:i}){const l=Tee(s),u=ao(),d=e&&!n&&!u,f=g.useRef(null),p=ea(!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?Cee:See(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"})})}),d&&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?Eee:_ee,children:XD.map(({kind:m,label:w,title:x})=>r.jsx(mt,{settingId:m,name:w,nameId:`sm-${m}-label`,note:x,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 Tbe=["audio/webm;codecs=opus","audio/ogg;codecs=opus","audio/mp4"];function Abe(e){return Tbe.find(t=>e(t))}const Rbe=4400;function Mbe(e){const t=e.split(";")[0];return{name:`Recorded voice.${t==="audio/mp4"?"m4a":t==="audio/ogg"?"ogg":"webm"}`,type:t}}function $be({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),d=()=>{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=Abe(j=>MediaRecorder.isTypeSupported(j)),x=new MediaRecorder(p,w?{mimeType:w}:void 0),b=[];i.current=x,x.ondataavailable=j=>{j.data.size&&b.push(j.data)},x.onerror=()=>t("Recording failed. Please try again."),x.onstop=()=>{p.getTracks().forEach(S=>S.stop()),l.current!==null&&clearTimeout(l.current),l.current=null;const j=i.current===x;if(j&&(i.current=null),o(!1),!j||!b.length)return;const k=Mbe(x.mimeType),v=new File(b,k.name,{type:k.type});n(()=>s(v))},x.start(200),o(!0),l.current=setTimeout(d,Rbe)}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:d}}function Lbe({full:e,fullProps:t,runCustom:n,onCreateVoice:s}){const[a,o]=g.useState("Custom voice"),[i,l]=g.useState("Your turn"),[u,d]=g.useState(""),[f,p]=g.useState("1"),[m,w]=g.useState("1"),[x,b]=g.useState([]);return g.useEffect(()=>{if(typeof window>"u"||!("speechSynthesis"in window))return;const j=()=>{b(window.speechSynthesis.getVoices())};return j(),window.speechSynthesis.addEventListener("voiceschanged",j),()=>window.speechSynthesis.removeEventListener("voiceschanged",j)},[]),r.jsxs("details",{className:"sm-voice",children:[r.jsxs("summary",{className:"settings-row",...t,onClick:j=>{const k=j.currentTarget.parentElement;e&&k&&!k.open&&j.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:j=>o(j.target.value)})]}),r.jsxs("label",{children:[r.jsx("span",{children:"Text"}),r.jsx("input",{className:"ap-manage-input",value:i,maxLength:180,onChange:j=>l(j.target.value)})]}),r.jsxs("label",{children:[r.jsx("span",{children:"Voice"}),r.jsxs("select",{className:"sm-select",value:u,onChange:j=>d(j.target.value),children:[r.jsx("option",{value:"",children:"System default"}),x.map(j=>r.jsx("option",{value:j.voiceURI,children:j.name},j.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:j=>p(j.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:j=>w(j.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 Ibe({customAssets:e,onImportCustom:t,onCreateVoice:n,onRenameCustom:s,onPreviewCustom:a,onDeleteCustom:o}){const[i,l]=g.useState(""),u=e.length,d=G1(u),f=d!==null,p=f?{"aria-disabled":!0,"aria-describedby":"sm-custom-full"}:{},[m,w]=g.useState(null),x=g.useRef(0),b=g.useRef(new Map),j=g.useRef(null),k=g.useRef(null);g.useEffect(()=>{if(!m)return;const A=window.setTimeout(()=>w(null),4e3);return()=>window.clearTimeout(A)},[m]);const v=async A=>{l("");try{await A()}catch(I){l(I instanceof Error?I.message:"Custom audio could not be saved.")}},S=(A,I)=>{const $=Date.now(),U=fi({armedFor:m,target:A,armedAt:x.current,now:$,gapMs:hi});if(U==="arm"){w(A),x.current=$;return}if(U==="ignore")return;w(null);const F=Pee(e.map(M=>M.id),A);v(async()=>{var B;await o(A);const M=document.activeElement;M!==I&&!Hn((M==null?void 0:M.tagName)??null)||(B=F?b.current.get(F):j.current)==null||B.focus()})},{recording:C,startRecording:_,stopRecording:R}=$be({full:f,setCustomError:l,runCustom:v,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 ",V1]}),className:"sm-custom",settingId:"custom-sounds",children:[f&&r.jsx("p",{className:"settings-row settings-row-status",id:"sm-custom-full",children:d}),r.jsx(mt,{as:"div",settingId:"custom-import",name:"Import audio",note:"WAV, MP3 or OGG",control:r.jsx("button",{ref:j,type:"button",className:"btn sm-custom-action",...p,onClick:()=>{var A;f||(A=k.current)==null||A.click()},children:"Choose file"}),children:r.jsx("input",{ref:k,type:"file",hidden:!0,accept:"audio/wav,audio/x-wav,audio/mpeg,audio/mp3,audio/ogg,.wav,.mp3,.ogg",onChange:A=>{var $;const I=($=A.target.files)==null?void 0:$[0];A.currentTarget.value="",I&&!f&&v(()=>t(I))}})}),r.jsx(mt,{as:"div",settingId:"custom-record",name:"Record a clip",note:C?"Recording…":"Up to 5 seconds",control:C?r.jsx("button",{type:"button",className:"btn sm-custom-action",onClick:R,children:"Stop & save"}):r.jsx("button",{type:"button",className:"btn sm-custom-action",...p,onClick:()=>void _(),children:"Record"})}),r.jsx(Lbe,{full:f,fullProps:p,runCustom:v,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:I=>{if(!I.target.value.trim()){I.target.value=A.name;return}v(()=>s(A.id,I.target.value))},onKeyDown:I=>{I.key==="Enter"&&I.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:I=>{I?b.current.set(A.id,I):b.current.delete(A.id)},className:`btn sm-custom-icon${m===A.id?" armed":""}`,onKeyDown:I=>{I.repeat&&I.preventDefault()},onClick:I=>S(A.id,I.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 Obe="A tone when a turn finishes, and when Claude asks for something.";function Pbe({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:Obe,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 Oj="custom:";function KO(e){return`${Oj}${e}`}function Dbe(e){return e.startsWith(Oj)?e.slice(Oj.length):null}function Fbe({id:e,label:t="Volume",value:n,step:s=UN,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:Bf,max:yp,step:s,value:n,"aria-describedby":o,onChange:i=>a(Number(i.target.value)),style:{"--sm-level":`${(n-Bf)/(yp-Bf)*100}%`}}),r.jsxs("span",{className:"sm-read",children:[n,"%"]})]})}const YO={done:"Turn finished","needs-input":"Claude is asking"},Bbe={done:"Plays when Claude or Codex finishes a turn.","needs-input":"Available in Claude Code only."};function qbe({chime:e,tone:t,soundOn:n,customAssets:s,customSelections:a,onLevel:o,onFigure:i,onPreview:l,onBuiltInSelected:u,onCustomSelected:d}){const f=`sm-level-${e}`,p=`sm-figure-${e}`,m=a[e];return r.jsxs(Bt,{id:`sm-name-${e}`,title:YO[e],note:Bbe[e],settingId:`tone-${e}`,aside:r.jsxs("button",{type:"button",className:"btn sm-hear",onClick:()=>l(e),"aria-label":`Hear the ${YO[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(Fbe,{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?KO(m):t.figure,onChange:w=>{const x=w.target.value,b=Dbe(x);b!==null?d(e,b):(u(e),i(e,x))},children:[qN[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:KO(w.id),children:w.name},w.id))})]})]})]})}const Ube="Claude Code isn't on this machine, so only Turn finished plays here — for Codex turns.";function Wbe({soundOn:e,onToggleSound:t,prefs:n,claudeHere:s,onLevel:a,onFigure:o,onPreview:i,customAssets:l,customSelections:u,onBuiltInSelected:d,onCustomSelected:f,onImportCustom:p,onCreateVoice:m,onRenameCustom:w,onPreviewCustom:x,onDeleteCustom:b}){var S;const j=Iee(u),k=((S=l.find(C=>C.id===j))==null?void 0:S.name)??"the same custom sound",v=j?`Both tones use “${k}”. They may be harder to tell apart.`:"";return r.jsxs("div",{className:"sm-sounds",children:[r.jsx(Pbe,{soundOn:e,onToggleSound:t}),!s&&r.jsx("p",{className:"sm-note",children:Ube}),!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:Lu.map(C=>r.jsx(qbe,{chime:C,tone:n[C],soundOn:e,customAssets:l,customSelections:u,onLevel:a,onFigure:o,onPreview:i,onBuiltInSelected:d,onCustomSelected:f},C))}),v&&r.jsx("p",{className:"sm-note","aria-hidden":!0,children:v}),r.jsx("p",{className:"vis-hidden",role:"status",children:v}),r.jsx(Ibe,{customAssets:l,onImportCustom:p,onCreateVoice:m,onRenameCustom:w,onPreviewCustom:x,onDeleteCustom:b})]})}const Hbe="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 zbe({onOpen:e}){return r.jsx(Bt,{children:r.jsx(mt,{as:"div",settingId:"radar-open",name:"Radar",nameId:"settings-radar-open-name",note:Hbe,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 Vbe=6500,Gbe=1e4;let oi={reading:null,saving:null,error:"",undone:null};const zf=new Set;let gu=null,yu=null,oa=null,s1=!1,Vf=0;const Ko=e=>{oi={...oi,...e},zf.forEach(t=>t(oi))};function cB(e){const t=e;return!!t&&t.ok===!0&&Array.isArray(t.settings)&&typeof t.present=="object"}async function uB(e){const t=await fetch("/api/claude-settings",{signal:e}),n=await t.json();if(!t.ok||!cB(n))throw new Error;return n}async function Pj(){if(s1||oi.saving)return;s1=!0;const e=Vf,t=new AbortController;oa=t;let n=!1;const s=setTimeout(()=>{n=!0,t.abort()},5e3);try{const a=await uB(t.signal);e===Vf&&!t.signal.aborted&&Ko({reading:a,error:""})}catch{e===Vf&&(n||!t.signal.aborted)&&Ko({error:"Could not read Claude Code settings. Try again."})}finally{clearTimeout(s),s1=!1,oa===t&&(oa=null)}}function XO(e,t){var n;return(n=e==null?void 0:e.settings.find(s=>s.id===t))==null?void 0:n.value}async function ZO(e,t){if(oi.saving)return;Vf++,oa==null||oa.abort(),yu&&(clearTimeout(yu),yu=null),Ko({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||!cB(o))throw new Error(typeof(o==null?void 0:o.error)=="string"?o.error:"Could not save the change. Try again.");Ko({reading:o});const i=XO(o,e);yu=setTimeout(()=>{yu=null;const l=new AbortController,u=setTimeout(()=>l.abort(),5e3);uB(l.signal).then(d=>{Ko({reading:d,undone:XO(d,e)===i?null:{id:e}})}).catch(()=>{}).finally(()=>clearTimeout(u))},Vbe)}catch(a){Ko({error:a instanceof Error&&a.message?a.message:"Could not save the change. Try again."})}finally{clearTimeout(s),Ko({saving:null})}}function Kbe(){const[e,t]=g.useState(oi);return g.useEffect(()=>(zf.add(t),t(oi),gu||(Pj(),gu=setInterval(()=>void Pj(),Gbe)),()=>{zf.delete(t),zf.size||(gu&&clearInterval(gu),gu=null,oa==null||oa.abort())}),[]),e}const r1=40,Ybe={boolean:"on or off",choice:"a choice",number:"a number",text:"text",structured:"a list or object"};function Xbe(e){const t=e.scope==="Global config"?"kept in ~/.claude.json":e.scope==="Managed"?"managed settings only":null;return[e.topic,Ybe[e.kind],t,e.since?`Claude Code ${e.since}+`:null].filter(Boolean).join(" · ")}function Zbe(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 dB=null;const Jbe=()=>dB??(dB=gi(()=>import("./claude-settings-index-1Qg1AUda.js"),[]).then(e=>e.default.keys));function Qbe({present:e,noFile:t=!1}){const[n,s]=g.useState(null),[a,o]=g.useState(""),i=g.useId();g.useEffect(()=>{let f=!0;return Jbe().then(p=>{f&&s(p)},()=>{dB=null}),()=>{f=!1}},[]);const l=g.useMemo(()=>{if(!n)return[];if(a.trim())return Zbe(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,r1),d=a.trim()!=="";return r.jsxs(Bt,{id:"claude-group-all",settingId:"claude-all-settings",title:"All Claude Code settings",note:d?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=>{rm(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:Xbe(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:`${vee}#${f.anchor}`,target:"_blank",rel:"noreferrer","aria-label":`${f.key} in Claude Code's settings reference`,children:"Reference"})]})},f.key)})}),d&&l.length===0&&n&&r.jsxs("p",{className:"settings-empty",role:"status",children:["No setting matches “",a.trim(),"”."]}),l.length>r1&&r.jsxs("p",{className:"settings-foot",role:"status",children:[l.length-r1," more. Type more of the name to narrow the list."]}),!d&&e&&!t&&n&&l.length===0&&r.jsx("p",{className:"settings-empty",children:"Your settings.json sets nothing yet."})]})}const eke="Changed back after saving, most likely by a running Claude Code session. Set it again to keep it.",tke="There is no settings.json yet, so Claude Code uses its defaults. The first change here creates it.";function nke(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 ske(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 JO="\0custom";function rke({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 d=e.kind==="days"?e.options.map(m=>({value:String(m),label:yA(m)})):e.options,f=t?t.custom?JO:t.value===null?"":String(t.value):"",p=e.kind==="days"&&t&&!t.custom&&!d.some(m=>m.value===f)?[...d,{value:f,label:yA(Number(f))}].sort((m,w)=>Number(m.value)-Number(w.value)):d;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;ZO(e.id,e.kind==="days"?Number(w):w===""?null:w)},children:[(t==null?void 0:t.custom)&&r.jsx("option",{value:JO,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&&ZO(e.id,!u)},children:r.jsx("span",{className:"switch-knob"})})}function ake(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 oke(){return r.jsx(ike,{state:Kbe()})}function ike({state:e}){const{reading:t,saving:n,error:s,undone:a}=e,o=ake(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:tke}),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 Pj(),children:"Retry"})})]})]}),l&&GD.map(u=>r.jsx(Bt,{id:`claude-group-${u.id}`,title:u.title,children:KD.filter(d=>d.group===u.id).map(d=>{const f=t==null?void 0:t.settings.find(x=>x.id===d.id),p=`claude-${d.id}-label`,m=`claude-${d.id}-note`,w=f&&!f.editable&&!o?f.reason:(a==null?void 0:a.id)===d.id?eke:f!=null&&f.override?ske(f.override):"";return r.jsx(mt,{settingId:`claude-${d.id}`,name:d.label,nameId:p,note:d.note,noteId:m,control:r.jsx(rke,{entry:d,row:f,saving:n,nameId:p,noteId:m}),children:r.jsx("span",{className:"settings-row-said settings-row-said-quiet",role:"status",children:w})},d.id)})},u.id)),l&&r.jsx("p",{className:"settings-foot",children:nke(t==null?void 0:t.fileShown)}),r.jsx(Qbe,{present:(t==null?void 0:t.present)??null,noFile:i})]})}const lke="Local statistics for Claude and Codex on this device. Commands are grouped by operation; raw arguments and outputs are not saved.";function cke(){const[e,t]=g.useState(null),[n,s]=g.useState(""),[a,o]=g.useState(!1),[i,l]=g.useState(null),[u,d]=g.useState(""),f=g.useRef(!1),p=g.useRef(!0),m=async()=>{if(f.current)return;f.current=!0,o(!0),s("");const b=new AbortController,j=window.setTimeout(()=>b.abort(),12e3);try{const k=await fetch("/api/tool-audit/storage",{signal:b.signal}),v=await k.json();if(!k.ok||!v.ok)throw new Error;p.current&&t(v)}catch{p.current&&s("Could not read tool history storage. Try again.")}finally{window.clearTimeout(j),f.current=!1,p.current&&o(!1)}};g.useEffect(()=>(p.current=!0,m(),()=>{p.current=!1}),[]);const w=async(b,j)=>{if(f.current)return;f.current=!0,o(!0),s(""),d("");let k=!1;const v=new AbortController,S=window.setTimeout(()=>v.abort(),15e3);try{const C=await fetch("/api/tool-audit/storage",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(b==="clear"?{action:b,confirm:!0}:{action:b,days:j}),signal:v.signal}),_=await C.json();if(!C.ok||!_.ok)throw new Error;k=!0,p.current&&(l(null),d(b==="clear"?"Tool history cleared. New calls will continue to be recorded.":`Retention changed to ${j} days.`))}catch{p.current&&s("Could not update tool history. Check storage permissions and try again.")}finally{window.clearTimeout(S),f.current=!1,p.current&&(o(!1),k&&m())}},x=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:lke,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:b=>{if(f.current)return;const j=Number(b.target.value);j<e.retentionDays?l(j):w("retention",j)},children:[30,60,90].map(b=>r.jsxs("option",{value:b,children:[b," days"]},b))})}),typeof i=="number"&&x,r.jsx(mt,{as:"div",settingId:"tool-history-size",name:"Space used",note:`Collected since ${Ate(e.startedAt)}`,control:r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"settings-read",children:Tte(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"&&x,!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 Dj="agent-dag.integrations.active",YS=(e,t)=>`agent-dag.integrations.prefs.${e}:${t}`,uke=32e3;function QO(e,t){const n=nt(YS(e,t));if(!n)return{};try{const s=JSON.parse(n);return s&&typeof s=="object"&&!Array.isArray(s)?s:{}}catch{return{}}}function Aje(e,t){return{read(n,s){const a=QO(e,t)[n];return s(a)?a:void 0},write(n,s){const a=QO(e,t);s===void 0?delete a[n]:a[n]=s;const o=JSON.stringify(a);o.length<=uke&&st(YS(e,t),o)}}}function dke(e,t){vs(YS(e,t))}function Rje(e){const t=nt(Dj);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 Mje(e,t){let n={};try{const s=nt(Dj),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(Dj,JSON.stringify(n))}function Fj(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 Bj(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 hke({connection:e,provider:t,available:n,busy:s,armed:a,note:o,headingRef:i,onTest:l,onEdit:u,onDisconnect:d,onCancelDisconnect:f}){var C;const p=g.useRef(null),m=(t==null?void 0:t.label)??e.kind,w=e.account.name||e.account.login||"No account read yet",x=e.account.name&&e.account.login!==e.account.name?e.account.login:"",b=Fj(e),j=Bj(e),k=Array.isArray((C=e.meta)==null?void 0:C.warnings)?e.meta.warnings.filter(_=>typeof _=="string"):[],v=s===`test:${e.id}`,S=s===`delete:${e.id}`;return r.jsxs("section",{className:"ig-connection-details","aria-labelledby":"ig-managed-title",children:[r.jsxs("header",{className:"ig-managed-header",children:[t&&r.jsx("span",{className:"ig-provider-glyph","aria-hidden":!0,children:r.jsx(t.Glyph,{})}),r.jsxs("div",{className:"ig-managed-identity",children:[r.jsx("h2",{ref:i,tabIndex:-1,id:"ig-managed-title",className:"ig-managed-title",children:e.name||e.baseUrl}),r.jsxs("p",{children:[m," · Saved connection"]})]})]}),r.jsxs("dl",{className:"ig-detail-facts",children:[r.jsxs("div",{children:[r.jsx("dt",{children:"Host"}),r.jsx("dd",{children:e.baseUrl})]}),r.jsxs("div",{children:[r.jsx("dt",{children:"Account"}),r.jsxs("dd",{children:[w,x?` (${x})`:""]})]}),r.jsxs("div",{children:[r.jsx("dt",{children:"Last verified"}),r.jsx("dd",{children:b??"No verification time available"})]}),r.jsxs("div",{children:[r.jsx("dt",{children:"Credentials"}),r.jsx("dd",{children:e.tokenSaved?"Stored locally":"No token saved"})]}),j&&r.jsxs("div",{children:[r.jsx("dt",{children:"Server"}),r.jsx("dd",{children:j})]})]}),!n&&r.jsxs("p",{className:"ig-stranded",children:[m," is not available on this deck. Disconnect deletes this connection and its saved token."]}),k.length>0&&r.jsx("ul",{className:"ig-warnings",children:k.map(_=>r.jsx("li",{children:_},_))}),n&&r.jsxs("div",{className:"ig-manage-actions",children:[r.jsx("button",{type:"button",className:"btn","aria-busy":v,"aria-disabled":s!==null||void 0,onClick:l,children:v?"Testing…":"Test connection"}),r.jsx("button",{type:"button",className:"btn","aria-disabled":s!==null||void 0,onClick:_=>{s===null&&u(_.currentTarget)},children:"Edit connection"})]}),o&&o.scope!=="disconnect"&&r.jsx("p",{className:"ig-note","data-tone":o.tone,role:o.tone==="err"?"alert":"status",children:o.text}),r.jsxs("div",{className:"ig-disconnect-section",children:[r.jsx("h3",{children:"Remove connection"}),r.jsx("p",{children:"Remove this connection and its saved token from this machine."}),r.jsxs("div",{className:"ig-manage-actions","data-integration-disconnect-actions":!0,onBlur:_=>{a&&!_.currentTarget.contains(_.relatedTarget)&&f()},children:[r.jsx("button",{ref:p,type:"button","data-integration-disconnect":!0,className:`btn danger${a?" armed":""}`,"aria-busy":S,"aria-disabled":s!==null||void 0,onKeyDown:_=>{_.repeat&&_.preventDefault()},"aria-label":a?`Confirm disconnecting ${e.name}`:`Disconnect ${e.name}`,onClick:_=>d(_.currentTarget),children:S?"Disconnecting…":a?"Confirm disconnect":"Disconnect"}),a&&r.jsx("button",{type:"button",className:"btn","aria-disabled":s!==null||void 0,"aria-label":"Cancel disconnect",onClick:()=>{var _;s===null&&(f(),(_=p.current)==null||_.focus())},children:"Cancel"})]}),a&&r.jsx("p",{className:"ig-note",role:"status",children:"Press Confirm disconnect to delete this connection and its saved token, or Cancel to keep it."}),(o==null?void 0:o.scope)==="disconnect"&&r.jsx("p",{className:"ig-note","data-tone":o.tone,role:o.tone==="err"?"alert":"status",children:o.text})]})]})}function fke({onBeforeLeaveChange:e}={}){var We;const t=Id(),{connections:n,error:s}=t,[a,o]=g.useState(null),i=g.useRef(null),l=g.useRef(new Map),u=g.useRef(null),d=g.useRef(0),[f,p]=g.useState(null),[m,w]=g.useState(""),x=g.useRef(null),b=g.useRef(null),[j,k]=g.useState(null),[v,S]=g.useState(null),C=g.useRef(null),[_,R]=g.useState(null),[A,I]=g.useState([]),[$,U]=g.useState(null),F=g.useRef(0),[M,B]=g.useState(null),T=g.useRef(null),P=g.useRef(new Map),q=g.useRef(null),K=g.useRef(0),[z,H]=g.useState(!1),[D,O]=g.useState(null),V=g.useRef(null),Z=g.useRef(new Map),W=g.useRef(new Map);g.useEffect(()=>{const se=Xye();se&&(q.current=Z.current.get(se)??null,p(se),B(se),k({mode:"edit",id:se}));const be=Yye();be&&k({mode:"add",kind:be})},[]),g.useEffect(()=>{var se,be;!M||!n||(be=(se=W.current.get(M))==null?void 0:se.scrollIntoView)==null||be.call(se,{block:"nearest"})},[M,n]),g.useEffect(()=>{if(!$)return;const se=()=>{var Oe,ve;((Oe=document.activeElement)==null?void 0:Oe.getAttribute("aria-label"))==="Cancel disconnect"&&((ve=document.querySelector(".ig-manage-view [data-integration-disconnect]"))==null||ve.focus()),U(null)},be=()=>{document.hidden&&se()},Te=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",be),()=>{window.clearTimeout(Te),window.removeEventListener("blur",se),document.removeEventListener("visibilitychange",be)}},[$]);const X=(se,be,Te,Oe)=>I(ve=>[...ve.filter(pe=>pe.id!==se),{id:se,tone:be,text:Te,scope:Oe}]),Y=se=>I(be=>be.filter(Te=>Te.id!==se)),J=async(se,be)=>{if(!C.current){C.current=se,S(se);try{await be()}finally{C.current=null,S(null)}}},Q=se=>(be,Te)=>void J("form",async()=>{R(null);try{const Oe=await Hye(se,be,Te||void 0);k(null),O(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}.`),B(Oe.id),T.current=()=>{var pe;const ve=l.current.get(Oe.kind)??Z.current.get(Oe.id);return(pe=ve==null?void 0:ve.scrollIntoView)==null||pe.call(ve,{block:"nearest"}),ve}}catch(Oe){R(Oe instanceof wr?Oe:new wr("upstream","The connection could not be saved."))}}),te=se=>(be,Te)=>void J("form",async()=>{R(null);try{const{connection:Oe,validated:ve}=await zye(se.id,{name:Te,input:be});k(null),O(null),H(!1),T.current=()=>b.current??(f?x.current:Z.current.get(Oe.id)),X(Oe.id,"ok",ve?`Saved. Connection test passed as ${Oe.account.name||Oe.account.login}.`:"Saved.")}catch(Oe){R(Oe instanceof wr?Oe:new wr("upstream","The change could not be saved."))}}),le=se=>void J(`test:${se.id}`,async()=>{U(null),Y(se.id);try{const be=await Vye(se.id);X(se.id,"ok",`Connection test passed. Signed in as ${be.account.name||be.account.login}.`)}catch(be){X(se.id,"err",be instanceof Error?be.message:"The test failed.")}}),de=(se,be)=>{if(C.current)return;const Te=Date.now(),Oe=fi({armedFor:$,target:se.id,armedAt:F.current,now:Te,gapMs:hi});if(Oe==="arm"){be.focus({preventScroll:!0}),U(se.id),F.current=Te;return}Oe!=="ignore"&&(U(null),J(`delete:${se.id}`,async()=>{try{await Gye(se.id),dke(se.kind,se.id),Y(se.id),(j==null?void 0:j.mode)==="edit"&&j.id===se.id&&k(null),p(null);const ve=(n??[]).filter(_e=>_e.kind===se.kind&&_e.id!==se.id);(!a||ve.length===0)&&o(null),w("Connection disconnected.");const pe=document.activeElement;(pe===be||Hn((pe==null?void 0:pe.tagName)??null))&&(T.current=()=>{var ze;const _e=(a&&ve[0]?Z.current.get(ve[0].id):l.current.get(se.kind))??P.current.get(se.kind)??document.getElementById("settings-tab-integrations");return(ze=_e==null?void 0:_e.scrollIntoView)==null||ze.call(_e,{block:"nearest"}),_e})}catch(ve){X(se.id,"err",ve instanceof Error?ve.message:"The connection could not be removed. Try again.","disconnect")}}))};g.useEffect(()=>{if(v!==null||D||!T.current)return;const se=T.current();T.current=null,se!=null&&se.isConnected&&(se.checkVisibility?se.checkVisibility():se.getClientRects().length>0)&&se.focus({preventScroll:!0})},[n,f,a,j,v,D]);const oe=n??[],re=Od(t),he=["github","gitlab","jira"],fe=zS().filter(se=>re.has(se.kind)||oe.some(be=>be.kind===se.kind)).sort((se,be)=>he.indexOf(se.kind)-he.indexOf(be.kind)),$e=GS(t),ye=g.useCallback(()=>{k(null),p(null),o(null),H(!1),O(null),R(null),U(null),T.current=()=>{const se=q.current,be=se==null?void 0:se.closest(".settings-pane");return be&&(be.scrollTop=K.current),se!=null&&se.isConnected?se:document.getElementById("settings-tab-integrations")}},[]),ge=g.useCallback(()=>{if(!a){ye();return}p(null),k(null),H(!1),O(null),R(null),U(null),T.current=()=>{var Te;const se=(Te=u.current)!=null&&Te.isConnected?u.current:i.current,be=se==null?void 0:se.closest(".settings-pane");return be&&(be.scrollTop=se===i.current?0:d.current),se}},[a,ye]),je=g.useCallback(()=>{if(!f&&!a){ye();return}k(null),H(!1),O(null),R(null),T.current=()=>b.current??(f?x.current:i.current)},[f,a,ye]),Le=g.useCallback((se,be=!1)=>{if(C.current)return;if(D&&be){O(null),requestAnimationFrame(()=>{var Oe;return(Oe=document.querySelector(".ig-config-view input:not([disabled])"))==null?void 0:Oe.focus()});return}const Te=be?j?je:f?ge:ye:()=>{k(null),p(null),o(null),se()};z?O(()=>Te):(H(!1),Te())},[z,D,j,f,je,ge,ye]);g.useEffect(()=>(e==null||e(j||f||a?Le:null),()=>e==null?void 0:e(null)),[j,f,a,Le,e]),g.useEffect(()=>{var se;D&&((se=V.current)==null||se.focus())},[D]),g.useEffect(()=>{var se;f&&((se=x.current)==null||se.focus())},[f]),g.useEffect(()=>{var se;a&&((se=i.current)==null||se.focus())},[a]);const ke=(se,be)=>{var Oe;if(C.current)return;T.current=null,O(null),w(""),U(null),f||a?b.current=be:(K.current=((Oe=be.closest(".settings-pane"))==null?void 0:Oe.scrollTop)??0,q.current=be,b.current=null),H(!1),R(null),k(se);const Te=be.closest(".settings-pane");Te&&(Te.scrollTop=0)},Ie=(se,be)=>{var Oe,ve;if(C.current)return;T.current=null,a?(u.current=be,d.current=((Oe=be.closest(".settings-pane"))==null?void 0:Oe.scrollTop)??0):(K.current=((ve=be.closest(".settings-pane"))==null?void 0:ve.scrollTop)??0,q.current=be),b.current=null,w(""),U(null),p(se.id);const Te=be.closest(".settings-pane");Te&&(Te.scrollTop=0)},De=(se,be)=>{var ve;const Te=oe.filter(pe=>pe.kind===se);if(Te.length===1){Ie(Te[0],be);return}if(C.current)return;T.current=null,K.current=((ve=be.closest(".settings-pane"))==null?void 0:ve.scrollTop)??0,q.current=be,u.current=null,d.current=0,w(""),U(null),o(se);const Oe=be.closest(".settings-pane");Oe&&(Oe.scrollTop=0)},Ue=(se,be=!1)=>{const Te=Tu(se.kind),Oe=!na(t,se.kind),ve=Fj(se),pe=se.account.login||se.account.name,_e=se.kind==="jira"?Bj(se):null;return r.jsx("div",{className:"ig-conn",ref:ze=>{ze?W.current.set(se.id,ze):W.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:be&&se.name||Uo(se)}),r.jsx("span",{className:"ig-conn-line",children:[be&&se.name!==Uo(se)?Uo(se):"",pe,_e||(ve?`Last verified ${ve}`:"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:[(Te==null?void 0:Te.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:ze=>{ze?Z.current.set(se.id,ze):Z.current.delete(se.id)},"aria-label":`Manage ${(Te==null?void 0:Te.label)??se.kind}: ${se.name} (${pe||Uo(se)})`,onClick:ze=>Ie(se,ze.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=>!fe.some(be=>be.kind===se.kind)),we=a?Tu(a):null,Fe=oe.filter(se=>se.kind===a),Re=oe.find(se=>se.id===f),Ae=(j==null?void 0:j.mode)==="edit"?oe.find(se=>se.id===j.id):void 0,rt=(j==null?void 0:j.mode)==="add"?fe.find(se=>re.has(se.kind)&&se.kind===j.kind):Ae&&fe.find(se=>re.has(se.kind)&&se.kind===Ae.kind);return r.jsxs("div",{className:"ig-settings","data-view":j?"form":f?"connection":a?"provider":"overview",children:[j&&r.jsxs("div",{className:"ig-config-view",children:[r.jsxs("button",{type:"button",className:"btn ig-back-to-overview","aria-disabled":v!==null||void 0,onClick:()=>Le(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 ${(we==null?void 0:we.label)??a} connections`:"All integrations"]}),D&&r.jsxs("div",{className:"ig-leave-confirm",role:"group","aria-labelledby":"ig-leave-title",children:[r.jsx("strong",{id:"ig-leave-title",children:"Discard unsaved changes?"}),r.jsx("p",{children:"Your changes have not been saved. Discarding clears this form, including any token you entered."}),r.jsxs("div",{className:"ig-form-actions",children:[r.jsx("button",{ref:V,type:"button",className:"btn",onClick:()=>{O(null),requestAnimationFrame(()=>{var se;return(se=document.querySelector(".ig-config-view input:not([disabled])"))==null?void 0:se.focus()})},children:"Keep editing"}),r.jsx("button",{type:"button",className:"btn danger",onClick:()=>{const se=D;O(null),H(!1),k(null),se()},children:"Discard changes"})]})]}),r.jsx("div",{hidden:!!D,children:rt?r.jsx(vye,{def:rt,existing:Ae,busy:v==="form",error:_,onDirtyChange:H,onSubmit:j.mode==="add"?Q(j.kind):te(Ae),onCancel:()=>Le(je,!0)},j.mode==="add"?j.kind:j.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:j!==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":v!==null||void 0,onClick:()=>Le(ye,!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"]}),na(t,a)&&r.jsxs("button",{type:"button",className:"btn","aria-disabled":v!==null||void 0,onClick:se=>ke({mode:"add",kind:a},se.currentTarget),children:["Add ",(we==null?void 0:we.label)??a," connection"]})]}),r.jsxs("h2",{ref:i,tabIndex:-1,className:"ig-managed-title",children:[(we==null?void 0:we.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=>Ue(se,!0))}):r.jsx("p",{role:"status",children:"No saved connections."})]}),f&&r.jsxs("div",{className:"ig-manage-view",hidden:j!==null,children:[r.jsxs("div",{className:"ig-manage-navigation",children:[r.jsxs("button",{type:"button",className:"btn ig-back-to-overview","aria-disabled":v!==null||void 0,onClick:()=>Le(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"})}),a?`Back to ${(we==null?void 0:we.label)??a} connections`:"All integrations"]}),Re&&na(t,Re.kind)&&r.jsxs("button",{type:"button",className:"btn","aria-disabled":v!==null||void 0,onClick:se=>ke({mode:"add",kind:Re.kind},se.currentTarget),children:["Add ",((We=Tu(Re.kind))==null?void 0:We.label)??Re.kind," connection"]})]}),Re?r.jsx(hke,{connection:Re,provider:Tu(Re.kind),available:na(t,Re.kind),busy:v,armed:$===f,note:A.find(se=>se.id===f),headingRef:x,onTest:()=>le(Re),onEdit:se=>ke({mode:"edit",id:Re.id},se),onDisconnect:se=>de(Re,se),onCancelDisconnect:()=>U(null)}):r.jsx("p",{role:"status",children:"This connection is no longer saved."})]}),r.jsxs("div",{className:"ig-overview",hidden:j!==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 Ym(),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:$e==="all"?"integrations-add-title":void 0,children:fe.map(se=>{const be=oe.filter(_e=>_e.kind===se.kind),Te=be.length===1?be[0]:null,Oe=[...new Set(be.map(Uo))],ve=Te&&Fj(Te),pe=(Te==null?void 0:Te.kind)==="jira"?Bj(Te):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}),be.length===0?r.jsx("span",{className:"ig-conn-line",children:"Not connected"}):Te?r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"ig-conn-name",children:Uo(Te)}),r.jsx("span",{className:"ig-conn-line",children:[Te.account.login||Te.account.name,pe||(ve?`Last verified ${ve}`:"Not verified yet")].filter(Boolean).join(" · ")}),!Te.tokenSaved&&r.jsx("span",{className:"ig-bad",children:"No token saved"})]}):r.jsxs(r.Fragment,{children:[r.jsxs("span",{className:"ig-conn-name",children:[be.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${be.length?"":" primary"}`,"aria-disabled":v!==null||void 0,ref:_e=>{const ze=be.length?l.current:P.current;_e?ze.set(se.kind,_e):ze.delete(se.kind)},"aria-label":`${be.length?"Manage":"Connect"} ${se.label}`,onClick:_e=>be.length?De(se.kind,_e.currentTarget):ke({mode:"add",kind:se.kind},_e.currentTarget),children:be.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||fe.length===0&&$e!=="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=>Ue(se,!0)),oe.length===0&&r.jsx("p",{className:"settings-row settings-row-status",children:"Nothing connected."})]})]}),$e==="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 pke({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 mke({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,d=(pr.indexOf(l??e)+(i.key==="ArrowLeft"||i.key==="ArrowUp"?-1:1)+pr.length)%pr.length;t(pr[d]),(p=i.currentTarget.querySelectorAll('[role="radio"]')[d])==null||p.focus()},a=g.useRef(null),o=g.useRef(e);return g.useEffect(()=>{var u,d;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||(d=a.current.querySelector(`[data-theme-choice="${e}"]`))==null||d.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:pr.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(pke,{theme:i}),r.jsxs("span",{className:"appearance-theme-name",children:[ic[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 gke=[["smallest","Smallest","11 px"],["smaller","Smaller","12 px"],["default","Default","13 px"],["larger","Larger","15 px"],["largest","Largest","17 px"]],yke=[["tightest","Tightest","30%"],["tighter","Tighter","50%"],["compact","Compact","70%"],["default","Default","100%"],["comfortable","Comfortable","140%"]];function e3(){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 wke({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 xke({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":_A.length,"--reading-selected":_A.indexOf(e)},children:gke.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(e3,{})]},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":EA.length,"--reading-selected":EA.indexOf(t)},children:yke.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(e3,{})]},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."})]})}function vke(e){return!!e&&ks(e.version)&&ks(e.desktopVersion)&&ha(e.version,e.desktopVersion)<0}function bke({info:e}){return r.jsx(mt,{as:"div",name:"Terminal CLI",note:`The npm CLI on Windows PATH is v${e.version}; the desktop app is v${e.desktopVersion}. Desktop updates do not update the npm CLI.`,control:r.jsx("span",{className:"settings-read",children:"Update needed"}),children:r.jsxs("span",{className:"settings-row-said",children:["Run ",r.jsx("code",{children:"npm install -g ccdeck@latest"}),", then reopen PowerShell and run ",r.jsx("code",{children:"ccdeck tui"}),"."]})})}function kke(){const[e,t]=g.useState(null);return g.useEffect(()=>{var s;let n=!0;return(s=window.ccdeckTerminalCli)==null||s.version().then(a=>{n&&vke(a)&&t(a)}).catch(()=>{}),()=>{n=!1}},[]),e?r.jsx(bke,{info:e}):null}const jke="AGPL-3.0-only",Nke="GNU Affero General Public License, version 3 only.",Ske="https://github.com/BarganConstantin/ccdeck",Cke="What changed in each release, newest first.",_ke="Tell the people who make ccdeck what works and what does not.";function Eke(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 Tke(e,t){return ks(e)&&ks(t)&&ha(e,t)<0}function Ake(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 Rke({version:e,notice:t,readyAppUpdate:n,updateRestarting:s,updateFailure:a,onUpdateRestart:o,doors:i,bundle:l="3.49.1"}){const u=(e==null?void 0:e.running)??l,d=Ake(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:Tke(l,e==null?void 0:e.running)?Eke(l):void 0,control:r.jsx("span",{className:"settings-read",children:u})}),typeof window<"u"&&window.ccdeckTerminalCli&&r.jsx(kke,{}),d&&r.jsx(Mke,{offer:d,restarting:s,failure:a,onRestart:o,onUpdate:i.update}),r.jsx(mt,{as:"div",settingId:"whats-new",name:"What's new",note:Cke,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:Nke,control:r.jsxs(r.Fragment,{children:[r.jsx("span",{className:"settings-read",children:jke}),r.jsxs("a",{className:"settings-link",href:Ske,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:sbe,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:_ke,control:r.jsx("button",{type:"button",className:"btn","aria-haspopup":"dialog","aria-label":"Open the feedback dialog",onClick:i.feedback,children:"Open"})})]})]})}function Mke({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=F8(e.to,t),i=n&&n.version===e.to?B8(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 $ke="Update when idle",Lke="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.",Ike=`${oB} 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.`,Oke="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.",Pke="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 Dke(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 Fke={plain:Lke,"checks-off":Ike,"no-restart":Oke};function Bke({autoRestart:e,onToggleAutoRestart:t,version:n,inApp:s=ao()}){const a=Dke(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:Pke}):r.jsx(mt,{settingId:"auto-update",name:$ke,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:Fke[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 qke({character:e,onCharacter:t}){const n=g.useRef([]);function s(a,o){var l;const i=pS(a,o,Ff.length,"vertical");i.kind==="select"&&(a.preventDefault(),t(Ff[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:Ff.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(bD,{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 Uke="Stands beside the minimap. Press it to play the radio.";function Wke({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:Uke,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(qke,{character:n,onCharacter:s})]})}const t3="settings-search-field",hB="settings-search-results",qj=e=>`settings-result-${e}`;function Hke({inputRef:e,query:t,onQuery:n,results:s,active:a,onActive:o,onOpen:i}){const l=t.trim()!=="",u=l&&s.length>0,d=f=>{if(f.nativeEvent.isComposing)return;const p=kte(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:t3,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:t3,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?hB:void 0,"aria-activedescendant":u?qj(Math.min(a,s.length-1)):void 0,"aria-keyshortcuts":"Control+F Meta+F",value:t,onChange:f=>n(f.target.value),onKeyDown:d})]})}function zke({query:e,results:t,active:n,onOpen:s}){const a=l5(t.length,e);return g.useEffect(()=>{var o,i;(i=(o=document.getElementById(qj(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:hB,role:"listbox","aria-label":"Matching settings",children:t.map((o,i)=>r.jsxs("button",{type:"button",role:"option",id:qj(i),className:"settings-result",tabIndex:-1,"aria-selected":i===n,"aria-label":wte(o),"data-highlighted":i===n,onMouseDown:l=>l.preventDefault(),onClick:()=>s(o),children:[r.jsx(wm,{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:zN(o)})]})]},o.id))})})]})}function Vke({query:e,count:t}){return r.jsx("p",{className:"vis-hidden",role:"status",children:e.trim()?l5(t,e):""})}const Gke=1500,Kke=3e3,Yke=e=>e.checkVisibility?e.checkVisibility():e.getClientRects().length>0;function Xke(e){if(e.matches(rp)&&!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(rp)).filter(s=>LP({disabled:s.disabled,tabIndex:s.tabIndex,rendered:Yke(s)}));return n.find(s=>s.closest(".settings-list")!=null)??n[0]??null}function Zke(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)}"]`),d=w=>{var b,j;a(null);const x=w.offsetHeight>l.clientHeight-48;w.scrollIntoView({block:x?"start":"center"}),(b=Xke(w))==null||b.focus({preventScroll:!0}),window.clearTimeout(o.current),(j=i.current)==null||j.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)},Gke)},f=u();if(f){d(f);return}const p=new MutationObserver(()=>{const w=u();w&&(p.disconnect(),window.clearTimeout(m),d(w))});p.observe(l,{childList:!0,subtree:!0});const m=window.setTimeout(()=>{p.disconnect(),a(null)},Kke);return()=>{p.disconnect(),window.clearTimeout(m)}},[e,s,t,n]),a}function Jke({section:e,landOn:t,onSection:n,onClose:s,providers:a,sound:o,tones:i,customTones:l,notify:u,appearance:d,versionCheck:f,desktopUpdate:p,restart:m,doors:w}){const x=g.useRef(null),b=g.useCallback(ve=>{x.current=ve},[]);function j(ve,pe=!1){x.current?(D(""),x.current(ve,pe),requestAnimationFrame(()=>{var _e,ze;return(ze=(_e=v.current)==null?void 0:_e.scrollIntoView)==null?void 0:ze.call(_e,{block:"nearest",inline:"nearest"})})):ve()}const k=()=>j(s,!0),v=g.useRef(null),S=gt(k,{focusRef:v}),C=wt(()=>j(s)),_=g.useRef([]),R=Id(),A=GS(R),I=fee(A,e,a.claude),$=Math.max(0,I.findIndex(ve=>ve.id===e)),U=lc("(max-width: 640px)"),[F,M]=g.useState(""),[B,T]=g.useState(0),P=g.useRef(null),q=g.useRef(null),K=F.trim()!=="",z=g.useMemo(()=>bte(F,i5(a.claude,A,Od(R))),[F,a.claude,A,R]),H=Zke(q,!K,e),D=ve=>{M(ve),T(0)};g.useEffect(()=>{t&&H(t)},[t,H]);const O=ve=>{j(()=>{D(""),n(ve),requestAnimationFrame(()=>{var pe;return(pe=document.getElementById(`settings-tab-${ve}`))==null?void 0:pe.focus()})})},V=ve=>{j(()=>{D(""),n(ve.section),ym(ve)||H(ve.id)})};g.useEffect(()=>{const ve=pe=>{var at,tt;if(!xee(pe))return;const _e=S.current,ze=pe.target;!_e||!(ze===document.body||ze===document.documentElement||ze&&_e.contains(ze))||(pe.preventDefault(),(at=P.current)==null||at.focus(),(tt=P.current)==null||tt.select())};return window.addEventListener("keydown",ve),()=>window.removeEventListener("keydown",ve)},[S]),g.useEffect(()=>{var ve,pe,_e,ze;pee((ve=document.activeElement)==null?void 0:ve.id,e)&&((pe=v.current)==null||pe.focus()),(ze=(_e=v.current)==null?void 0:_e.scrollIntoView)==null||ze.call(_e,{block:"nearest",inline:"nearest"})},[e]);const{theme:Z,setTheme:W,characterEnabled:X,setCharacterEnabled:Y,character:J,setCharacter:Q}=d,te=An(),le=ve=>{const pe=pS(ve,$,I.length,"vertical");pe.kind!=="pass"&&(ve.preventDefault(),j(()=>{var _e;D(""),n(I[pe.index].id),(_e=_.current[pe.index])==null||_e.focus()}))},de=ve=>{ve.key===" "&&ve.stopPropagation()},{soundOn:oe,toggleSound:re}=o,{tonePrefs:he,previewTone:fe,changeTone:$e}=i,{customSelections:ye,customAssets:ge,clearCustomOnly:je,selectCustomTone:Le,importNotificationAudio:ke,createNotificationVoice:Ie,renameCustomAsset:De,deleteCustomAsset:Ue,previewCustomAsset:Ke}=l,{notifyPermission:we,notifyOn:Fe,notifyVetoed:Re,toggleNotify:Ae,notifySupported:rt,askForNotifications:We,accountNotify:se,toggleAccountNotify:be}=u,Te=(()=>{switch(e){case"radar":return r.jsx(zbe,{onOpen:w.radar});case"claude":return r.jsx(oke,{});case"appearance":return r.jsxs(r.Fragment,{children:[r.jsx(mke,{theme:Z,onTheme:W,singleKeys:te}),r.jsx(Wke,{characterEnabled:X,character:J,onCharacter:Q,onToggleCharacter:()=>Y(ve=>!ve)})]});case"reading":return r.jsx(xke,{textSize:d.textSize,density:d.density,onTextSize:d.setTextSize,onDensity:d.setDensity});case"keyboard":return r.jsx(_be,{singleKeys:te,onToggleSingleKeys:()=>BY(!te)});case"notifications":return r.jsx(Ebe,{notifyOn:Fe,onToggleNotify:Ae,notifyVetoed:Re,notifyPermission:rt?we:"unsupported",onAskNotify:We,accountNotify:se,onToggleAccountNotify:be});case"sounds":return r.jsx(Wbe,{soundOn:oe===!0,onToggleSound:re,prefs:he,claudeHere:a.claude,onLevel:(ve,pe)=>$e(ve,{level:pe}),onFigure:(ve,pe)=>$e(ve,{figure:pe}),onPreview:ve=>fe(ve),customAssets:ge,customSelections:ye,onBuiltInSelected:je,onCustomSelected:Le,onImportCustom:ke,onCreateVoice:Ie,onRenameCustom:De,onPreviewCustom:Ke,onDeleteCustom:Ue});case"integrations":return r.jsx(fke,{onBeforeLeaveChange:b});case"data":return r.jsx(cke,{});case"about":return r.jsx(Rke,{version:f.version,notice:f.notice,readyAppUpdate:p.readyAppUpdate,updateRestarting:p.desktopUpdateRestarting,updateFailure:p.desktopUpdateFailure,onUpdateRestart:ve=>{p.askDesktopUpdateRestart(ve)},doors:w});default:return r.jsxs(r.Fragment,{children:[r.jsx(mbe,{}),r.jsx(GO,{provider:"Codex"}),a.claude&&r.jsx(GO,{provider:"Claude"}),r.jsx(Bke,{autoRestart:m.autoRestart,onToggleAutoRestart:m.toggleAutoRestart,version:f.version}),r.jsx(kbe,{claudeHere:a.claude,singleKeys:te,doors:w})]})}})(),Oe=e==="reading"?r.jsx(wke,{textSize:d.textSize,density:d.density,onTextSize:d.setTextSize,onDensity:d.setDensity}):e==="integrations"&&R.connections!==null?r.jsxs("span",{className:"ig-total",children:[R.connections.length," saved connection",R.connections.length===1?"":"s"]}):null;return r.jsx("div",{className:"modal-backdrop",...C,role:"presentation",children:r.jsxs("div",{ref:S,id:"settings",className:"modal settings-modal",role:"dialog","aria-modal":"true","aria-labelledby":"settings-title",onClick:ve=>ve.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:()=>j(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(Hke,{inputRef:P,query:F,onQuery:D,results:z,active:B,onActive:T,onOpen:V}),r.jsx(Vke,{query:F,count:z.length}),r.jsx("div",{className:"settings-nav",role:"tablist","aria-label":"Settings sections","aria-orientation":U?"horizontal":"vertical",onKeyDown:le,children:I.map((ve,pe)=>r.jsxs("button",{ref:_e=>{_.current[pe]=_e,ve.id===e&&(v.current=_e)},type:"button",role:"tab",id:`settings-tab-${ve.id}`,className:"settings-tab","aria-selected":ve.id===e,"aria-controls":"settings-pane",tabIndex:ve.id===e?0:-1,onClick:()=>O(ve.id),children:[r.jsx(wm,{section:ve.id}),r.jsx("span",{className:"settings-tab-label",children:ve.label})]},ve.id))})]}),r.jsxs("div",{ref:q,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:I[$].label}),r.jsx("p",{className:"settings-pane-note",children:I[$].note})]}),Oe]}),Te]},e),K&&r.jsx(zke,{query:F,results:z,active:B,onOpen:V})]})]})})}function Qke({tool:e,onClose:t}){const n=gt(t),s=wt(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,d=g.useMemo(()=>{const f=pV(e.name,i,l);return{input:f.input.map((p,m)=>r.jsx(n3,{block:p},m)),response:f.response.map((p,m)=>r.jsx(n3,{block:p},m)),copyInput:nT(e.name,"input",i),copyResponse:nT(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:MP(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(s3,{text:d.copyInput,what:"input"})]}),d.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(s3,{text:d.copyResponse,what:"response"})]}),e.endedAt==null?r.jsx("pre",{children:"(waiting…)"}):d.response]})]})]})})}const e0e={del:"tm-del",add:"tm-add",ctx:"tm-ctx"};function n3({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(()=>iV(e),[e]),{shown:a}=oP(s,t),o=lV(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?e0e[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 s3({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 io(e).then(o=>{!o||!a.current||(s(!0),window.setTimeout(()=>{a.current&&s(!1)},1600))}),children:n?"copied":"copy"})}const t0e=Km(()=>gi(()=>import("./UsageHistoryModal-DvYWhsYv.js"),[]),"Usage history"),n0e=Km(()=>gi(()=>import("./BrowserWatchModal-CCARqAMn.js"),[]),"Browser Watch"),s0e=Km(()=>gi(()=>import("./TrafficRadar-B9MfKca4.js"),[]),"Telemetry Radar");function r0e({dialogs:e,welcome:t,desktopUpdate:n,versionCheck:s,restart:a,upgrade:o,lanPairs:i,attention:l,clearFlow:u,watchBadge:d,announcements:f,appearance:p,providers:m,stateRef:w,agentCount:x,menus:b,sound:j,tones:k,customTones:v,notify:S,panelDoors:C}){const{openedTool:_,setOpenedToolKey:R,usageHistoryOpen:A,setUsageHistoryOpen:I,browserWatchOpen:$,setBrowserWatchOpen:U,contextAgent:F,setContextFor:M,summaryFor:B,setSummaryFor:T,keyHelpOpen:P,setKeyHelpOpen:q,feedbackOpen:K,setFeedbackOpen:z,feedbackPrefill:H,setFeedbackPrefill:D,openFeedback:O}=e,{trafficRadarOpen:V,setTrafficRadarOpen:Z}=e,{tourOpen:W,openTour:X,closeTour:Y,releaseNotes:J,closeReleaseNotes:Q,chipVersion:te,openReleaseNotes:le}=t,{desktopUpdateRestarting:de,desktopUpdateFailure:oe,readyAppUpdate:re,askDesktopUpdateRestart:he}=n,{version:fe,showNotice:$e}=s,{askRestart:ye}=a,{clearConfirmOpen:ge,setClearConfirmOpen:je,requestClear:Le}=u,{setWatchOn:ke,markWatchSeen:Ie}=d,{setWatchSaid:De}=f,{palette:Ue}=p,{settingsOpen:Ke,settingsSection:we,settingsLandOn:Fe,showSection:Re,closeSettings:Ae,openSettings:rt}=b;return r.jsxs(r.Fragment,{children:[_&&r.jsx(Qke,{tool:_,onClose:()=>R(null)}),A&&r.jsx(g.Suspense,{fallback:null,children:r.jsx(t0e,{providers:m,onClose:()=>I(!1)})}),$&&r.jsx(g.Suspense,{fallback:null,children:r.jsx(n0e,{onClose:()=>U(!1),onSeen:We=>{De(""),Ie(We)},onWatching:ke,palette:Ue})}),F&&r.jsx(uK,{agent:F,onClose:()=>M(null)}),V&&r.jsx(g.Suspense,{fallback:null,children:r.jsx(s0e,{sessions:[...w.current.agents.values()].filter(We=>We.kind==="root"&&We.provider!=="codex").map(We=>({id:We.sessionId,label:sm(We.sessionName,We.sessionTitle).face??We.cwdBasename??We.label,project:We.cwdBasename??We.label,workspace:We.cwd})),onClose:()=>Z(!1)})}),K&&r.jsx(J8,{initialKind:H==null?void 0:H.initialKind,initialBody:H==null?void 0:H.initialBody,onClose:()=>{z(!1),D(null)}}),B&&r.jsx(ube,{state:w.current,sessionId:B,onClose:()=>T(null)}),Ke&&r.jsx(Jke,{section:we,landOn:Fe,onSection:Re,onClose:Ae,providers:m,sound:j,tones:k,customTones:v,notify:S,appearance:p,versionCheck:s,desktopUpdate:n,restart:a,doors:{whatsNew:Ba(Ae,le),update:Ba(Ae,()=>{le(),$e()}),tour:Ba(Ae,X),feedback:Ba(Ae,()=>O()),accounts:Ba(Ae,C.accounts),localNetwork:Ba(Ae,C.localNetwork),browserWatch:Ba(Ae,()=>U(!0)),radar:Ba(Ae,()=>Z(!0))}}),J&&r.jsx(lbe,{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)?B8(oe.failure,oe.version):void 0,onUpdateRestart:re?()=>{he(re.version)}:void 0,onRestart:!re&&(fe!=null&&fe.canRestart)?()=>{Q(),ye()}:void 0,updateCheck:{versionCheck:s,upgrade:o,restart:a,desktopUpdate:n,running:te,onHandOff:Q}}),r.jsx(a0e,{lanPairs:i,attention:l}),P&&r.jsx(hve,{onClose:()=>q(!1),onTour:()=>{q(!1),X()},onSettings:()=>{q(!1),rt("keyboard")}}),W&&r.jsx(j6,{title:"What the deck shows you",steps:ele,onClose:Y}),ge&&r.jsx(nxe,{agentCount:x,onConfirm:()=>Le("confirmation"),onCancel:()=>je(!1)})]})}function a0e({lanPairs:e,attention:t}){const n=jve(e);return r.jsxs(r.Fragment,{children:[n,r.jsx(_ve,{...t,pairing:n!=null})]})}const o0e=10,fB=500,pB=4e3,i0e=[/ResizeObserver loop/i,/^Script error\.?$/i],r3=/^(?:[a-z][\w+.-]*-extension|webkit-masked-url):\/\//i,l0e=/[a-z][\w+.-]*:\/\/[^\s()]+/gi;function c0e(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(l0e)??[]:[]);return a.length?a.every(o=>r3.test(o)):typeof t=="string"&&r3.test(t)}const Bp=String.raw`[^\s\\/:'"\`<>|?*;,]`,u0e=String.raw`${Bp}(?:[^\\/\r\n:'"\`<>|?*;,]*${Bp})?[\\/]`,d0e=String.raw`[^\s\\/:'"\`<>|?*;,()]+`,wu=String.raw`(?:${u0e})*(?:${d0e})?`,h0e=String.raw`(?<![\w.~/\\\]-]|<(?:deck|host)>)(?:file://(?:/[A-Za-z]:)?[^\s:'"\`<>()]*|~[\\/]${wu}|[A-Za-z]:[\\/]${wu}|\\\\(?:[?.]\\)?(?:[A-Za-z]:\\)?${wu}|/(?=${Bp})${wu}|(?<!:)//(?=${Bp})${wu})`,f0e=String.raw`(?<![\w-])(?:[A-Za-z]--|-[A-Za-z0-9][\w.]*-)[\w.-]*`,p0e=new Set([".claude",".codex"]);function m0e(e){if(!e.startsWith("~"))return"<path>";const t=e[1],[n,...s]=e.slice(2).split(/[\\/]/);return n?p0e.has(n)?s.join("")?`~${t}${n}${t}<path>`:e:`~${t}<path>`:e}const g0e=String.raw`\b(https?|wss?)://[^\s/?#\\'"\x60<>(),;]+(?=(/assets/)?)`;function y0e(e,t,n){return n?"<deck>":`${t}://<host>`}const a3=String.raw`(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)`,mB=String.raw`${a3}(?:\.${a3}){3}`,a1=String.raw`[0-9A-Fa-f]{1,4}`,o3=String.raw`(?=[0-9A-Fa-f:]*\d)(?=[0-9A-Fa-f:]*::|(?:${a1}:){7})(?:(?:${a1})?:)+(?:${mB}|${a1})?`,i3=String.raw`%[\w-]+(?:\.[\w-]+)*`,l3=String.raw`(?:::1?|::ffff:(?:127(?:\.\d{1,3}){3}|0\.0\.0\.0))`,w0e=String.raw`(?<![\w:.%-])(?:\[(?!${l3}\])${o3}(?:${i3})?\]|(?!${l3}(?::\d{1,5})?(?![\w:%]|\.\d))${o3}(?:${i3})?(?![\w%]|\.\d))|(?<![\w./-])(?!127\.|0\.0\.0\.0\b)${mB}(?![\w-]|\.\d)`,o1=String.raw`(?=[\w.-]*[A-Za-z])[A-Za-z0-9][\w-]*(?:\.[\w-]+)*`,x0e=String.raw`(?<![\w.@/\\%-])(?!localhost(?![\w-]|\.\w))(?:(?<=\b(?:(?:getaddrinfo|connect) E[A-Z_]+|ENOTFOUND|EAI_AGAIN) )${o1}|${o1}(?=:\d{1,5}(?![\w:-]|\.\w))|${o1}\.(?:local|lan|home|internal|ts\.net)(?![\w-]|\.\w))`;function c3(e){return String(e??"").replace(/\/(?:home|Users)\/[^/\s:'"]+/g,"~").replace(/[A-Za-z]:\\(?:Users|Documents and Settings)\\[^\\\r\n:'"]+/gi,"~").replace(new RegExp(h0e,"g"),m0e).replace(new RegExp(f0e,"g"),"<project>").replace(new RegExp(g0e,"g"),y0e).replace(new RegExp(w0e,"g"),"<host>").replace(new RegExp(x0e,"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 gB=e=>{fetch("/api/client-error",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e),keepalive:!0}).catch(()=>{})};function v0e(e,t,n=gB){const s=String(e??"").slice(0,fB).trim();s&&n({message:s,stack:typeof t=="string"?t.slice(0,pB):void 0})}function b0e(e,t=window,n=gB){let s=0;const a=new Set,o=(u,d,f)=>{const p=String(u??"").slice(0,fB).trim();!e()||!p||s>=o0e||a.has(p)||i0e.some(m=>m.test(p))||c0e(d,f)||(a.add(p),s++,n({message:p,stack:typeof d=="string"?d.slice(0,pB):void 0}))},i=u=>{var d,f;return o(((d=u.error)==null?void 0:d.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 k0e=12;function j0e(e,t){const n=[c3(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,k0e).join(`
|
|
319
|
+
`);n.push("",c3(a).trim())}return n.join(`
|
|
320
|
+
`)}class N0e extends g.Component{constructor(){super(...arguments);Da(this,"state",{error:null,componentStack:null,reportOpen:!1});Da(this,"onKey",n=>{rm(n.key)&&ln.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}),v0e(n.message,n.stack),v8("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(J8,{initialKind:"bug",initialBody:j0e(n.message,s),onClose:()=>this.setState({reportOpen:!1})})]}):this.props.children}}const S0e=1e3;function C0e(e={}){const t=Math.max(1,Math.floor(e.limit??S0e)),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(d){const f=typeof(d==null?void 0:d.seq)=="number"?d.seq:null,p=(d==null?void 0:d.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(d),n!=null&&n(d)&&o.add(d),a.length>t){let x=0;if(o.size<a.length)for(;o.has(a[x]);)x++;const[b]=a.splice(x,1);o.delete(b),i++}return!1},setPaused(d){if(s=d,d)return[];const f=a;return a=[],o=new Set,i=0,f}}}function _0e(e){const t=g.useState(()=>C0e({protect:o=>SV(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&&uG(e.current);for(const l of i)e.current=wP(e.current,l);s(t.paused)},[t,e]);return{pauseGate:t,paused:n,togglePause:a}}const Uj={kind:"assumed",claude:!0,codex:!0};function E0e(e){if(!e||typeof e!="object")return Uj;const t=e.providers;if(!t||typeof t!="object")return Uj;const n=t;return{kind:"reported",claude:n.claude!==!1,codex:n.codex!==!1}}function T0e(e){const[t,n]=g.useState(null),[s,a]=g.useState(Uj);g.useEffect(()=>{let i=!1;return fetch("/api/health").then(l=>l.ok?l.json():null).then(l=>{i||(a(E0e(l)),!(!l||typeof l.workspace!="string")&&n(l.workspace))}).catch(()=>{}),()=>{i=!0}},[e]);const o=Bn(s);return{workspace:t,providers:s,providersRef:o}}const yB=3*6e4,A0e=2e4;function R0e({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>=yB&&await i()},stop:()=>{o=!1}}}async function M0e(){try{const e=await fetch("/api/provider-status",{signal:AbortSignal.timeout(A0e)});return e.ok?await e.json():null}catch{return null}}function $0e(e){const[t,n]=g.useState(null);return g.useEffect(()=>{if(!e){n(null);return}const s=R0e({fetchReport:M0e,visible:()=>document.visibilityState==="visible",now:()=>Date.now(),onReport:n});s.tick();const a=window.setInterval(s.tick,yB),o=()=>{s.wake()};return document.addEventListener("visibilitychange",o),()=>{s.stop(),window.clearInterval(a),document.removeEventListener("visibilitychange",o)}},[e]),t}const L0e={degraded:"degraded performance",partial_outage:"partial outage",major_outage:"major outage",maintenance:"maintenance"},I0e={degraded:"degraded",partial_outage:"partial outage",major_outage:"major outage",maintenance:"maintenance"},O0e={degraded:"degraded",partial_outage:"outage",major_outage:"outage",maintenance:"maint."},P0e={claude:"Claude",codex:"Codex"},D0e=new Set(["status.claude.com","status.openai.com"]),F0e=30*6e4,B0e=10*6e4;function q0e(e){if(typeof e!="string")return null;try{const t=new URL(e);return t.protocol==="https:"&&D0e.has(t.hostname)?t:null}catch{return null}}function u3(e){return new Date(e).toLocaleTimeString([],{hour:"2-digit",minute:"2-digit",hourCycle:"h23"})}function U0e(e){const t=Math.floor(e/6e4);return t<1?"just now":t<60?`${t} min ago`:`${Math.floor(t/60)} h ago`}function W0e(e,t){if(!e||typeof e!="object")return null;const n=Kt(L0e,e.state),s=Kt(P0e,e.provider);if(!n||!s||typeof e.checkedAt!="number"||t-e.checkedAt>F0e)return null;const a=q0e(e.statusPageUrl);if(!a)return null;const o=Array.isArray(e.components)?e.components:[],i=e.stale===!0||t-e.checkedAt>B0e,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 ${u3(e.checkedAt)}; this is the last thing it said`:`Reported by ${a.hostname}, checked ${U0e(t-e.checkedAt)}`,"Opens the status page"],u=i?u3(e.checkedAt):null;return{provider:e.provider,state:e.state,name:s,label:`${s} · ${n}${u?` · as of ${u}`:""}`,words:n,chipWords:Kt(I0e,e.state)??n,shortWords:Kt(O0e,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 H0e(e,t){return!(e!=null&&e.ok)||e.disabled||!Array.isArray(e.providers)?[]:e.providers.map(n=>W0e(n,t)).filter(n=>n!==null)}function z0e(e){return e.map(t=>`${t.name}'s status page reports ${t.state.endsWith("outage")?`a ${t.words}`:t.words}.`).join(" ")}const V0e="The providers' status pages report no incident.";function G0e({version:e,loadVersion:t}){var d;const[n,s]=g.useState(!1),a=((d=e==null?void 0:e.upgrade)==null?void 0:d.state)??"idle",o=Hwe(e==null?void 0:e.upgrade),i=g.useRef(!1),l=g.useCallback(async()=>{if(_n(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 io(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 d3="agent-dag.browserWatch.seenMs";function K0e(e,t){return e.filter(n=>n.startMs>t)}function Y0e(){const[e,t]=g.useState(()=>Number(nt(d3))||0),[n,s]=g.useState([]),[a,o]=g.useState(!1);g.useEffect(()=>{let u=!0;const d=()=>{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(()=>{})};d();const f=setInterval(d,5*6e4);return()=>{u=!1,clearInterval(f)}},[]);const i=g.useMemo(()=>K0e(n,e).length,[n,e]),l=g.useCallback(u=>{t(u),st(d3,String(u))},[]);return{watchOn:a,setWatchOn:o,watchUnseen:i,markWatchSeen:l}}const wB="agent-dag.character-enabled",xB="agent-dag.fm-volume",X0e=1,h3="agent-dag.fm-source",$je=[{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 Z0e(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 J0e(e){return e!=="0"}function Q0e(){return J0e(nt(wB))}function e1e(e){return s5(e,X0e)}function t1e(){return e1e(nt(xB))}const vB=["--err","--inflight","--ok","--warn","--muted","--grid-line","--minimap-mask","--panel","--line","--accent","--text-dim","--bg"];function f3(e){const t={};for(const n of vB)t[n]=e(n);return t}function n1e(e){return t=>e[t]??""}function s1e(e,t){return vB.every(n=>e[n]===t[n])}function r1e(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 d=e.startViewTransition(u);n=d,d.ready.catch(()=>{}),d.updateCallbackDone.catch(()=>{u()}),d.finished.then(()=>{n===d&&(n=null,delete e.documentElement.dataset.themeTransition)},()=>{n===d&&(u(),n=null,delete e.documentElement.dataset.themeTransition)})}catch{delete e.documentElement.dataset.themeTransition,u()}}}}function p3(e){return typeof window>"u"?"":getComputedStyle(document.documentElement).getPropertyValue(e).trim()||""}function a1e(){const[e,t]=g.useState(Hte),[n,s]=g.useState(zte),[a,o]=g.useState(dte),i=g.useRef(a),[l]=g.useState(()=>r1e(document,()=>{try{return window.matchMedia("(prefers-reduced-motion: reduce)").matches}catch{return!0}})),u=g.useCallback(k=>{const v=typeof k=="function"?k(i.current):k;v!==i.current&&(i.current=v,l.run(()=>vt.flushSync(()=>o(v))))},[l]);g.useEffect(()=>()=>l.cancel(),[l]);const[d,f]=g.useState(Q0e),[p,m]=g.useState(kee),[w,x]=g.useState(()=>f3(p3)),b=g.useMemo(()=>n1e(w),[w]),j=g.useCallback(k=>Kme(k,b),[b]);return g.useEffect(()=>{document.documentElement.dataset.textSize=e,st(Z1,e)},[e]),g.useEffect(()=>{document.documentElement.dataset.density=n,st(J1,n)},[n]),g.useEffect(()=>{const k=v=>{v.storageArea===gr()&&((v.key===Z1||v.key===null)&&t(KN(v.newValue)),(v.key===J1||v.key===null)&&s(m5(v.newValue)))};return window.addEventListener("storage",k),()=>window.removeEventListener("storage",k)},[]),g.useLayoutEffect(()=>{document.documentElement.dataset.theme=a,document.documentElement.dataset.colorScheme=ic[a].colorScheme,st(a5,a),x(k=>{const v=f3(p3);return s1e(k,v)?k:v})},[a]),g.useEffect(()=>{st(wB,d?"1":"0")},[d]),g.useEffect(()=>{st(YD,p)},[p]),g.useEffect(()=>{const k=document.querySelector('meta[name="theme-color"]'),v=w["--panel"];k&&v&&k.setAttribute("content",v)},[w]),{textSize:e,setTextSize:t,density:n,setDensity:s,theme:a,setTheme:u,characterEnabled:d,setCharacterEnabled:f,character:p,setCharacter:m,palette:w,minimapNodeFill:j}}function o1e(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 d of e.current.agents.values())for(const f of d.tools)u.add(j8(f.name));return Object.keys(k8).filter(d=>u.has(d))},[e.current,e.current.revision]);g.useEffect(()=>{if(i.length<=1){s(!1);return}let u=0;const d=()=>{const f=t.current;if(f&&!document.hidden){const p=f.getBoundingClientRect(),m=Array.from(document.querySelectorAll(".react-flow__node, .tool-burst")).map(x=>x.getBoundingClientRect()),w=aQ(p,m,8);s(x=>x===w?x:w)}u=window.setTimeout(d,300)};return d(),()=>window.clearTimeout(u)},[i.length]);const l=g.useCallback(u=>{o(d=>{const f=new Set(d);return f.has(u)?f.delete(u):f.add(u),f})},[]);return{presentCats:i,hiddenCats:a,toggleCat:l,catBarRef:t,catBarOccluded:n}}function i1e(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,x=w.figure){if(!n||n.state!=="running")return!1;const b=K1(m,x),j=Xee(w.level,b),k=n.currentTime;for(const v of b.notes){const S=n.createOscillator(),C=n.createGain();S.type=b.type??"sine",S.frequency.value=v.hz;const _=k+v.at,R=_+v.ms/1e3;C.gain.setValueAtTime(NA,_),C.gain.exponentialRampToValueAtTime(j,_+Zee),C.gain.exponentialRampToValueAtTime(NA,R),S.connect(C).connect(n.destination),S.start(_),S.stop(R+.02)}return!0}async function u(m,w){var j;if(!e.loadCustom)return"unavailable";let x;try{x=await e.loadCustom(m)}catch{return"unavailable"}if(!x)return"missing";if(x.kind==="tts"){if(typeof window>"u"||!("speechSynthesis"in window)||typeof SpeechSynthesisUtterance>"u")return"unavailable";const k=new SpeechSynthesisUtterance(x.text),v=window.speechSynthesis.getVoices();k.voice=v.find(S=>S.voiceURI===x.voiceURI)??null,k.rate=x.rate,k.pitch=x.pitch,k.volume=Jee(w.level);try{return window.speechSynthesis.cancel(),window.speechSynthesis.speak(k),"played"}catch{return"unavailable"}}if(!n||n.state!=="running")return"locked";let b;try{b=await n.decodeAudioData(x.bytes.slice(0))}catch{return"broken"}try{const k=n.createBufferSource(),v=n.createGain();return k.buffer=b,v.gain.setValueAtTime(Qee(x.normalizationGain,w.level),n.currentTime),k.connect(v).connect(n.destination),s.add(k),(j=k.addEventListener)==null||j.call(k,"ended",()=>s.delete(k)),k.start(n.currentTime),"played"}catch{return"unavailable"}}function d(m,w=!1){var j,k;if(!w&&!e.enabled())return!1;const x=ote((j=e.prefs)==null?void 0:j.call(e),m),b=((k=e.customSelection)==null?void 0:k.call(e)[m])??null;return b&&e.loadCustom?(u(b,x).then(v=>{var S;v==="played"||v==="locked"||((v==="missing"||v==="broken")&&((S=e.onCustomFailure)==null||S.call(e,m,b)),l(m,{...x,figure:Qn},Qn))}),!0):!n||n.state!=="running"?!1:l(m,x)}function f(m,w=pi){return u(m,{level:gm(w),figure:Qn}),!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:d,previewCustom:f,silence:p,state:a,get context(){return n}}}function l1e({chimesRef:e,soundOnRef:t,tonePrefsRef:n,customSelectionsRef:s,fallbackCustomRef:a}){g.useEffect(()=>{const o=i1e({enabled:()=>t.current===!0,prefs:()=>n.current,customSelection:()=>s.current,loadCustom:zee,onCustomFailure:(d,f)=>a.current(d,f)});e.current=o;const i=["pointerdown","pointerup","keydown"],l=()=>{for(const d of i)window.removeEventListener(d,u,{capture:!0})},u=()=>{var d;o.unlock(),((d=o.context)==null?void 0:d.state)==="running"&&l()};for(const d of i)window.addEventListener(d,u,{capture:!0});return l},[])}function c1e(){const[e,t]=g.useState(t1e),[n,s]=g.useState(()=>aX(nt(RT))),[a,o]=g.useState(()=>rX(nt(MT))),[i,l]=g.useState(()=>oX(nt(h3),n,Z0e)),[u,d]=g.useState(()=>new Set),[f,p]=g.useState(0);g.useEffect(()=>{st(xB,String(e))},[e]),g.useEffect(()=>{st(MT,a?"1":"0")},[a]),g.useEffect(()=>{st(RT,JSON.stringify(n))},[n]),g.useEffect(()=>{st(h3,i)},[i]);const m=g.useCallback((k,v=!1)=>{s(S=>{const C=S.find(_=>_.id===k.id);return C?!v||!k.radio||!C.radio||C.url===k.url&&JSON.stringify(C.radio)===JSON.stringify(k.radio)?S:S.map(_=>_.id===k.id?{..._,url:k.url,radio:k.radio}:_):[...S,k]}),d(S=>{if(!S.has(k.id))return S;const C=new Set(S);return C.delete(k.id),C})},[]),w=g.useCallback((k,v)=>{const S=v.trim();!S||S.length>dD||s(C=>C.map(_=>_.id===k?{..._,name:S}:_))},[]),x=g.useCallback(k=>{s(v=>v.filter(S=>S.id!==k)),l(v=>iX(v,k)),d(v=>{if(!v.has(k))return v;const S=new Set(v);return S.delete(k),S})},[]),b=g.useCallback((k,v=!1)=>{const S=$T(k),C=u.has(S);k===i&&!C&&!v||(C&&d(_=>{const R=new Set(_);return R.delete(S),R}),l(k),p(_=>_+1))},[i,u]),j=g.useCallback((k,v)=>{const S=$T(k);d(C=>{if(C.has(S)===v)return C;const R=new Set(C);return v?R.add(S):R.delete(S),R})},[]);return{fmVolume:e,setFmVolume:t,fmMuted:a,setFmMuted:o,fmSource:i,customFmStations:n,unavailableFmStations:u,fmPlayRequest:f,addFmStation:m,renameFmStation:w,removeFmStation:x,pickFmSource:b,markFmStationAvailability:j}}function u1e(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||!ao())return;let x=!1;const b=l.current;return fetch("/api/desktop-update").then(j=>j.ok?j.json():null).then(j=>{if(x||l.current!==b)return;const k=$O(j);k&&n(k)}).catch(()=>{}),()=>{x=!0}},[e]);const u=lwe(t),d=g.useRef(!1),f=g.useRef(0),p=g.useRef(0);g.useEffect(()=>()=>window.clearTimeout(f.current),[]);const m=g.useCallback(async x=>{if(!_n(d.current))return;const b=++p.current;window.clearTimeout(f.current),d.current=!0,a(!0),i(null);const j=k=>{b===p.current&&(window.clearTimeout(f.current),d.current=!1,a(!1),i({failure:k,version:x}))};try{const k=await fetch("/api/desktop-update/restart",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({version:x})});if(!k.ok)return j(uwe(await k.json().catch(()=>null)))}catch{return j("unreachable")}b===p.current&&(f.current=window.setTimeout(()=>j("timeout"),P8))},[]),w=g.useCallback(x=>{if(ao())try{const b=$O(JSON.parse(x));b&&(l.current++,n(b),b.status!=="ready"&&(p.current++,window.clearTimeout(f.current),d.current=!1,a(!1)))}catch{}},[]);return{desktopUpdateRestarting:s,desktopUpdateFailure:o,readyAppUpdate:u,appUpdate:t,askDesktopUpdateRestart:m,onDesktopUpdateEvent:w}}const Tf="agent-dag.autoRestart",m3="agent-dag.bundleReloadedFor";function d1e({now:e,stateRef:t,version:n,notice:s,noticeOpen:a,upgradeFailure:o,paused:i}){const[l,u]=g.useState(()=>nt(Tf)!=="0"),d=g.useRef(!1),f=g.useCallback(()=>{const U=!l;d.current=!0,vs(Tf),u(U),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:U})}).then(F=>F.ok?F.json():null).then(F=>{var M;F!=null&&F.ok&&u(((M=F.prefs)==null?void 0:M.autoUpdate)!==!1)}).catch(()=>{})},[l]),[p,m]=g.useState(!1),[w,x]=g.useState("restart"),[b,j]=g.useState(null),k=g.useRef(!1),v=g.useRef(null),S=g.useRef(0),C=g.useRef(null),_=g.useCallback(async U=>{if(!_n(k.current))return;const F=(U==null?void 0:U.upgrade)===!0,M=(U==null?void 0:U.whenIdle)===!0;k.current=!0,v.current=o;const B=++S.current,T=()=>{x(F?"npx":"restart"),m(!0)};M||T();try{window.sessionStorage.setItem("agent-dag.restartPending",(s==null?void 0:s.to)??"")}catch{}let P=!1;try{const q=await fetch("/api/restart",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(M?{upgrade:F,whenIdle:M}:{upgrade:F})});P=M&&q.status===409}catch{}if(P){k.current=!1,C.current=null;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}return}M&&T(),window.setTimeout(()=>{if(S.current===B&&k.current){k.current=!1,m(!1);try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}}},F?18e4:3e4)},[s==null?void 0:s.to,o]);g.useEffect(()=>{const U=IO(t.current.agents.values())>0,F=Ywe({enabled:l,kind:s==null?void 0:s.kind,canRestart:(n==null?void 0:n.canRestart)===!0,noticeOpen:a,visible:document.visibilityState==="visible",busy:U,idleSince:C.current,now:e});C.current=F.idleSince,F.restart&&_({whenIdle:!0})},[l,s==null?void 0:s.kind,n==null?void 0:n.canRestart,a,e,_]);const R=IO(t.current.agents.values()),A=Kwe(R,i),I=H8({enabled:l,kind:s==null?void 0:s.kind,canRestart:(n==null?void 0:n.canRestart)===!0,noticeOpen:a,visible:document.visibilityState==="visible",busy:R>0,idleSince:C.current,now:e});g.useEffect(()=>{const U=n==null?void 0:n.running;let F=null,M=null;try{F=window.sessionStorage.getItem("agent-dag.restartPending"),M=window.sessionStorage.getItem(m3)}catch{return}const B=Wwe({bundle:"3.49.1",running:U,pending:F,lastTried:M});if(B==="reload"){try{window.sessionStorage.setItem(m3,U??"")}catch{return}window.location.reload();return}if(B!=="confirm")return;try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}k.current=!1,m(!1),j(U??null);const T=window.setTimeout(()=>j(null),6e3);return()=>window.clearTimeout(T)},[n==null?void 0:n.running]),g.useEffect(()=>{if(p&&zwe({asked:v.current,reported:o})){try{window.sessionStorage.removeItem("agent-dag.restartPending")}catch{}k.current=!1,m(!1)}},[p,o]);const $=g.useCallback(U=>{var F,M;if(!d.current){const B=nt(Tf)==="0";vs(Tf),B&&((F=U.prefs)==null?void 0:F.autoUpdate)!==!1?(u(!1),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({autoUpdate:!1})}).catch(()=>{})):u(((M=U.prefs)==null?void 0:M.autoUpdate)!==!1)}},[]);return{autoRestart:l,toggleAutoRestart:f,restarting:p,restartMode:w,restartedTo:b,askRestart:_,restartCopy:A,restartFuseMs:I,loadAutoRestartPrefs:$}}function h1e(){const[e,t]=g.useState([]),n=g.useRef(new Set),[s,a]=g.useState(null),[o,i]=g.useState(void 0);g.useEffect(()=>{let d=!0,f=0;const p=()=>{fetch("/api/lan").then(m=>m.ok?m.json():null).then(m=>d?(m!=null&&m.ok&&t(uR(Array.isArray(m.pending)?m.pending:[],m.aliases)),m):null).catch(()=>null).then(m=>{d&&(i(w=>m!=null&&m.ok?m:w===void 0?null:w),f=window.setTimeout(p,(m==null?void 0:m.enabled)===!0?yj:k6))})};return p(),()=>{d=!1,window.clearTimeout(f)}},[]);const l=g.useCallback(async(d,f)=>{if(!s){a(d);try{const m=await(await fetch("/api/lan/peer",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:d,fp:f})})).json().catch(()=>null);m&&Array.isArray(m.pending)?t(uR(m.pending,m.aliases)):t(w=>w.filter(x=>x.fp!==f))}catch{}finally{a(null)}}},[s]),u=g.useCallback(d=>{s||(n.current.add(d),t(f=>[...f]))},[s]);return{lanPending:e,lanDeferred:n,lanBusy:s,answerLanPair:l,deferLanPair:u,lanStatus:o}}const f1e=6e4;function p1e({enabled:e,lanStatus:t,now:n}){const[s,a]=g.useState(null),[o,i]=g.useState(()=>new Set),[l,u]=g.useState(null),d=g.useCallback(k=>{k!=null&&k.ok&&Array.isArray(k.accounts)&&a(k.accounts)},[]),f=g.useCallback(async k=>{try{const v=await fetch(`/api/claude-accounts${k?"?refresh=1":""}`);v.ok&&d(await v.json())}catch{}},[d]);g.useEffect(()=>{e&&f(!1)},[e,f]),g.useEffect(()=>{if(!e)return;let k=Date.now();const v=()=>{document.visibilityState!=="visible"||Date.now()-k<f1e||(k=Date.now(),f(!1))};return document.addEventListener("visibilitychange",v),window.addEventListener("focus",v),()=>{document.removeEventListener("visibilitychange",v),window.removeEventListener("focus",v)}},[e,f]);const p=g.useMemo(()=>e?pve(s,{lan:t,now:n,closed:o}):[],[e,s,t,n,o]),m=g.useRef(p);m.current=p;const w=g.useCallback(k=>{k.length&&i(v=>new Set([...v,...k]))},[]),x=g.useCallback(()=>{const k=m.current;k.length&&(w(k.map(v=>v.id)),fetch("/api/claude-accounts/admin",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({action:"reauth-later",incidents:k.map(v=>({key:v.key,since:v.since}))})}).catch(()=>{}))},[w]),b=g.useRef(l);b.current=l;const j=g.useCallback(k=>{const v=b.current;w(mve(v?[v,...m.current]:m.current,k))},[w]);return{rows:p,signingIn:l,observe:d,signIn:u,signedIn:j,refresh:g.useCallback(()=>{f(!0)},[f]),closeSignIn:g.useCallback(()=>u(null),[]),later:x}}const bB=288,m1e=bB;function g1e(e,t,n){return e?"session-list":t||n?"accounts":null}function g3(e){return e==="session-list"?m1e:e==="accounts"?bB:0}const y1e=240,w1e=20;function x1e(e){const t=g.useRef(0),n=g.useRef(e);return g.useLayoutEffect(()=>{n.current!==e&&(n.current=e,t.current=xd()?0:performance.now()+y1e+w1e)},[e]),t}const kB="agent-dag.sessionListOpen",jB="agent-dag.accountsPanelOpen";function v1e(){return nt(kB)==="1"}function b1e(e){st(kB,e?"1":"0")}function k1e(){const e=nt(jB);return e===null?!0:e==="1"}function j1e(){const e=g.useRef(!1),t=g.useRef(!1),[n,s]=g.useState(()=>{const x=v1e();return x&&z1()?(e.current=!0,!1):x});g.useEffect(()=>{if(n)e.current=!1;else if(e.current)return;b1e(n)},[n]);const a=g.useRef(!1),[o,i]=g.useState(()=>{const x=k1e();return x&&n?(a.current=!0,!1):x&&z1()?(t.current=!0,!1):x});g.useEffect(()=>{if(o)t.current=!1;else if(t.current)return;!o&&a.current||st(jB,o?"1":"0")},[o]),g.useEffect(()=>{!n&&a.current&&(a.current=!1,i(!0))},[n]);const l=g.useCallback(()=>{s(x=>(x||i(b=>(b&&(a.current=!0),!1)),!x))},[]),u=g.useCallback(()=>{a.current=!1,i(x=>(x||s(!1),!x))},[]),d=g.useCallback(()=>{a.current=!1,i(x=>(x||s(!1),!0))},[]),f=g.useCallback(()=>s(!1),[]),p=g.useCallback(()=>{a.current=!1,s(!1)},[]),m=g.useCallback(()=>i(!1),[]),w=g1e(n,o,a.current);return{sessionListOpen:n,accountsPanelOpen:o,panel:w,toggleSessionList:l,toggleAccountsPanel:u,openAccountsPanel:d,closeSessionList:f,closeSessionListToCanvas:p,closeAccountsPanel:m}}const NB="agent-dag.detailOpen",SB="agent-dag.usagePanelOpen",CB="agent-dag.systemPanelOpen";function N1e(){return nt(NB)==="1"}function S1e(e){st(NB,e?"1":"0")}function C1e(){const e=nt(SB);return e===null?!0:e==="1"}function _1e(e){st(SB,e?"1":"0")}function E1e(){const e=nt(CB);return e===null?!0:e==="1"}function T1e(e){st(CB,e?"1":"0")}function A1e(e=0){const[t,n]=g.useState(N1e);g.useEffect(()=>{S1e(t)},[t]);const[s,a]=g.useState(C1e);g.useEffect(()=>{_1e(s)},[s]);const o=g.useRef(!1),[i,l]=g.useState(()=>{const u=E1e();return u&&s&&(z1()||ree(e))?(o.current=!0,!1):u});return g.useEffect(()=>{if(i)o.current=!1;else if(o.current)return;T1e(i)},[i]),cn("usage-panel",s),cn("machine-panel",i),{detailOpen:t,setDetailOpen:n,usagePanelOpen:s,setUsagePanelOpen:a,machinePanelOpen:i,setMachinePanelOpen:l}}const R1e={permission:"your permission",asked:"your answer"},M1e="No sessions are waiting for you.";function $1e(e){if(e.length===0)return"";const[t,...n]=e,s=t.waiting.kind,a=n.every(i=>i.waiting.kind===s)?R1e[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 i1(e,t,n=M1e){return t!==""?t:e===""?"":n}function L1e({waitingSessions:e,watchUnseen:t,incidents:n=[]}){const[s,a]=g.useState(""),o=$1e(e);g.useEffect(()=>{a(m=>i1(m,o))},[o]);const[i,l]=g.useState(""),u=t>0?`Browser watch has ${t} unread ${t===1?"finding":"findings"}.`:"";g.useEffect(()=>{l(m=>i1(m,u,"Browser watch has no unread findings."))},[u]);const[d,f]=g.useState(""),p=z0e(n);return g.useEffect(()=>{f(m=>i1(m,p,V0e))},[p]),{blockedSaid:s,watchSaid:i,setWatchSaid:l,incidentSaid:d}}const I1e="/icon-192.png",_B=Object.freeze({notifySwap:!0,notifyQuota:!1,notifyReset:!1,notifyStopped:!0});function y3(e){const t=n=>typeof(e==null?void 0:e[n])=="boolean"?e[n]:_B[n];return{notifySwap:t("notifySwap"),notifyQuota:t("notifyQuota"),notifyReset:t("notifyReset"),notifyStopped:t("notifyStopped")}}function O1e({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),[d,f]=g.useState(!1),[p,m]=g.useState(_B),w=g.useCallback(I=>{const $=!p[I];m(U=>({...U,[I]:$})),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({[I]:$})}).then(U=>U.ok?U.json():null).then(U=>{U!=null&&U.ok&&m(y3(U.prefs))}).catch(()=>{})},[p]),x=g.useRef(()=>{}),b=g.useRef(new Set),j=Bn(e),k=g.useCallback(()=>{const I=!l;u(I),I&&(b.current=rf(j.current)),I&&typeof Notification<"u"&&Notification.permission==="default"&&x.current(),fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({notifications:I})}).then($=>$.ok?$.json():null).then($=>{var U;$!=null&&$.ok&&(u(((U=$.prefs)==null?void 0:U.notifications)===!0),f($.notificationsVetoed===!0))}).catch(()=>{})},[l]),v=typeof Notification<"u";g.useEffect(()=>{if(!o)return;const $=setTimeout(()=>i(null),o==="blocked"?8e3:4e3);return()=>clearTimeout($)},[o]);const S=g.useCallback(()=>{typeof Notification>"u"||Notification.requestPermission().then(I=>{const $=I;a($),$==="granted"?i("on"):$==="denied"&&i("blocked")})},[]);x.current=S;const C=g.useRef(null),_=e.map(I=>tm(I.id,I.waiting)).join("|");g.useEffect(()=>{RG(C.current,s)&&(C.current=s,b.current=rf(e))},[s]);const R=g.useRef(!1);g.useEffect(()=>{MG(R.current,t)&&(R.current=!0,b.current=rf(e))},[t]),g.useEffect(()=>{if(typeof Notification>"u"||Notification.permission!=="granted"||!$G(C.current,t))return;const I=typeof document>"u"||!document.hidden,$=TG(e,b.current,I,l);for(const U of $)try{const F=new Notification(U.title,{body:U.body,tag:U.key,icon:I1e});F.onclick=()=>{window.focus(),n(U.sessionId),F.close()}}catch{}b.current=I?rf(e):AG(e,$,b.current)},[_,t]);const A=g.useCallback(I=>{var $;u((($=I.prefs)==null?void 0:$.notifications)===!0),f(I.notificationsVetoed===!0),m(y3(I.prefs))},[]);return{notifyPermission:s,notifySaid:o,notifyOn:l,notifyVetoed:d,toggleNotify:k,notifySupported:v,askForNotifications:S,loadNotifyPrefs:A,accountNotify:p,toggleAccountNotify:w}}function P1e({openedTool:e,usageHistoryOpen:t,contextFor:n,tourOpen:s,summaryFor:a,browserWatchOpen:o,keyHelpOpen:i,releaseNotes:l,feedbackOpen:u,trafficRadarOpen:d=!1}){const f=Bn(i),p=g.useRef(!1);return p.current=e!=null||t||n!=null||s||a!=null||o||i||l!=null||u||d,{keyHelpOpenRef:f,modalOpenRef:p}}function D1e({stateRef:e,tourOpen:t,releaseNotes:n}){const[s,a]=g.useState(null),o=g.useCallback((M,B)=>a({agentId:M,toolId:B}),[]),[i,l]=g.useState(null),[u,d]=g.useState(null),f=g.useCallback(M=>d(M),[]),[p,m]=g.useState(!1),[w,x]=g.useState(!1),[b,j]=g.useState(!1),[k,v]=g.useState(!1),[S,C]=g.useState(!1),[_,R]=g.useState(null),A=g.useCallback(M=>{R(M??null),C(!0)},[]);cn("tool-detail",s!==null),cn("session-summary",i!==null),cn("context-window",u!==null),cn("keyboard-help",p),cn("usage-history",w),cn("browser-watch",b),cn("feedback",S);const I=s?bV(e.current.agents,s.agentId,s.toolId):null,$=u?e.current.agents.get(u):void 0,{keyHelpOpenRef:U,modalOpenRef:F}=P1e({openedTool:I,usageHistoryOpen:w,contextFor:u,tourOpen:t,summaryFor:i,browserWatchOpen:b,keyHelpOpen:p,releaseNotes:n,feedbackOpen:S,trafficRadarOpen:k});return{setOpenedToolKey:a,openTool:o,openedTool:I,summaryFor:i,setSummaryFor:l,contextFor:u,setContextFor:d,openContext:f,contextAgent:$,keyHelpOpen:p,setKeyHelpOpen:m,usageHistoryOpen:w,setUsageHistoryOpen:x,browserWatchOpen:b,setBrowserWatchOpen:j,trafficRadarOpen:k,setTrafficRadarOpen:v,feedbackOpen:S,setFeedbackOpen:C,feedbackPrefill:_,setFeedbackPrefill:R,openFeedback:A,keyHelpOpenRef:U,modalOpenRef:F}}function F1e({stateRef:e,pinnedRef:t,measuredRef:n,positionsRef:s,lastLayoutSigRef:a,forgetRemovals:o,clearSelection:i,rerender:l,modalOpenRef:u}){const[d,f]=g.useState(!1),p=g.useCallback(async()=>{try{await fetch("/api/clear",{method:"POST"})}catch{}e.current=lN(),t.current.clear(),n.current.clear(),s.current.clear(),a.current="",u8(),o(),i(),l()},[l,i,o]),m=Bn(d),w=g.useCallback(x=>{const b=Jwe(x,{confirmOpen:m.current,modalOpen:u.current});b==="confirm"?f(!0):b==="clear"&&(f(!1),p())},[p]);return{clearConfirmOpen:d,setClearConfirmOpen:f,requestClear:w}}const w3="agent-dag.oldNameNoticeDismissed";function B1e(e){const[t,n]=g.useState(()=>nt(w3)??""),s=e!=null&&e.invokedAs&&e.invokedAs!==Pt?e.invokedAs:null,a=s!=null&&t!==s,o=g.useCallback(()=>{s&&(n(s),st(w3,s))},[s]);return{oldName:s,oldNameOpen:a,dismissOldName:o}}const q1e=300*1e3,U1e=1800*1e3,W1e=8e3,H1e=3e4;function x3(e){return fetch("/api/rating",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify(e)}).catch(()=>null)}function z1e({modalOpenRef:e}){const t=g.useCallback(()=>ml({appModal:e.current,dialogDepth:ln.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 x=async()=>{if(u.current==="thanks"||u.current==="hidden"&&(document.hidden||t()))return;const k=await fetch("/api/rating").then(v=>v.ok?v.json():null).catch(()=>null);w||!k||s(v=>v==="thanks"?v:k.ask===!0?"asking":"hidden")},b=window.setTimeout(x,q1e),j=window.setInterval(x,U1e);return()=>{w=!0,window.clearTimeout(b),window.clearInterval(j)}},[t]),g.useEffect(()=>{if(n!=="thanks"||i)return;const w=a!==null&&a<=6?H1e:W1e;let x=0;const b=()=>{t()?x=window.setTimeout(b,w):s("hidden")};return x=window.setTimeout(b,w),()=>window.clearTimeout(x)},[n,a,i,t]);const d=g.useCallback(w=>{o(w),l(!1),s("thanks"),x3({score:w})},[]),f=g.useCallback(w=>l(w),[]),p=g.useCallback(()=>{s("hidden"),x3({later:!0})},[]),m=g.useCallback(()=>s("hidden"),[]);return{ratingPhase:n,ratingScore:a,answerRating:d,rateLater:p,closeRating:m,holdThanks:f}}function V1e({chimesRef:e,setTonePrefs:t,tonePrefsRef:n,previewTone:s}){const[a,o]=g.useState(()=>$ee(nt)),i=Bn(a),[l,u]=g.useState([]),d=g.useCallback(v=>{o(S=>{const C={...S,[v]:null};return i.current=C,C}),vs($u[v])},[]),f=g.useCallback((v,S)=>{const C=i.current[v];S&&C!==S||(d(v),t(_=>{const R={..._,[v]:{..._[v],figure:Qn}};return n.current=R,R}),st(wp[v],Qn))},[d]),p=Bn(f);g.useEffect(()=>{let v=!0;return Hee().then(S=>{if(!v)return;u(S);const C=new Set(S.map(_=>_.id));for(const _ of Lu){const R=i.current[_];R&&!C.has(R)&&p.current(_,R)}},()=>{}),()=>{v=!1}},[]);const m=g.useCallback((v,S)=>{if(!l.some(_=>_.id===S))return;const C={...i.current,[v]:S};i.current=C,o(C),st($u[v],S),s(v,!0)},[l,s]),w=g.useCallback(async v=>{var R;const S=G1(l.length);if(S)throw new Error(S);const C=window.AudioContext??window.webkitAudioContext;if(!C)throw new Error("This browser cannot decode audio files.");const _=new C;try{const A=await Fee(v,$=>_.decodeAudioData($));await kA(A);const I=od(A);u($=>[...$.filter(U=>U.id!==I.id),I])}finally{(R=_.close)==null||R.call(_)}},[l.length]),x=g.useCallback(async v=>{const S=G1(l.length);if(S)throw new Error(S);const C=Bee(v);await kA(C);const _=od(C);u(R=>[...R.filter(A=>A.id!==_.id),_])},[l.length]),b=g.useCallback(async(v,S)=>{const C=l.find(R=>R.id===v),_=S.trim().slice(0,80);!C||!_||_===C.name||(await Vee(v,_),u(R=>R.map(A=>A.id===v?{...A,name:_}:A)))},[l]),j=g.useCallback(async v=>{await Gee(v),u(R=>R.filter(A=>A.id!==v));const S=i.current,C=Lee(S,v);i.current=C,o(C);const _=Lu.filter(R=>S[R]===v);for(const R of _)vs($u[R]),st(wp[R],Qn);_.length>0&&t(R=>{const A={...R};for(const I of _)A[I]={...A[I],figure:Qn};return n.current=A,A})},[]),k=g.useCallback(v=>{var _,R;const S=Lu.find(A=>i.current[A]===v),C=S?n.current[S].level:pi;(_=e.current)==null||_.unlock(),(R=e.current)==null||R.previewCustom(v,C)},[]);return{customSelections:a,customSelectionsRef:i,customAssets:l,clearCustomOnly:d,fallbackCustomRef:p,selectCustomTone:m,importNotificationAudio:w,createNotificationVoice:x,renameCustomAsset:b,deleteCustomAsset:j,previewCustomAsset:k}}function G1e(e){const[t,n]=g.useState(()=>ate(nt)),s=Bn(t),a=g.useRef(null),o=g.useCallback((l,u=!1)=>{var d,f;if((d=e.current)==null||d.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)},ete)},[]),i=g.useCallback((l,u)=>{n(d=>{const f={level:gm(u.level??d[l].level),figure:t5(l,u.figure??d[l].figure)};return st(r5[l],String(f.level)),st(wp[l],f.figure),{...d,[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 K1e=15e3;function Y1e(e){return e.visibilityState==="visible"&&e.hasFocus()}function X1e(e,t){return t||e===!0}function Z1e(){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 J1e(){g.useEffect(()=>{const e=Z1e();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=Y1e(document);X1e(t,i)&&n(i),t=i},a=()=>{t&&n(!1),t=!1};s();const o=window.setInterval(s,K1e);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 Q1e({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 l1="agent-dag.versionNoticeDismissed",eje=15*6e4;function tje(e){const[t,n]=g.useState(null),[s,a]=g.useState(()=>nt(l1)??""),o=g.useRef(0),[i,l]=g.useState(!1),u=g.useCallback((b=!1)=>(b&&(o.current=Date.now(),l(!0)),fetch(b?"/api/version?refresh=1":"/api/version").then(j=>j.ok?j.json():null).then(j=>(j&&n(j),j??null)).catch(()=>null).finally(()=>{b&&l(!1)})),[]),d=g.useCallback(()=>{u(Date.now()-o.current>=eje)},[u]);g.useEffect(()=>{u();const b=window.setInterval(d,5*6e4),j=()=>{document.visibilityState==="visible"&&d()};return document.addEventListener("visibilitychange",j),()=>{window.clearInterval(b),document.removeEventListener("visibilitychange",j)}},[u,d]),g.useEffect(()=>{e&&u()},[e,u]);const f=(t==null?void 0:t.notice)??null,p=q8(f),m=mwe(f,s),w=g.useCallback(()=>{a(""),st(l1,"")},[]),x=g.useCallback(()=>{f&&(a(p),st(l1,p))},[f,p]);return{version:t,notice:f,noticeOpen:m,showNotice:w,dismissNotice:x,versionChecking:i,loadVersion:u}}function nje({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 d=g.useRef(!1);g.useEffect(()=>{if(d.current)return;const j=gr(),k=Ove(j),v=Uve({stored:k,running:(e==null?void 0:e.running)??null,notes:WO,remembers:Pve(j)});if(v.reason==="no-version")return;d.current=!0,v.record&&Dve(j,v.record);let S=!0;return(async()=>{var I;let _=Fve(j);if(ao())try{const $=await fetch("/api/prefs");if(!$.ok)throw new Error("desktop tour preferences unavailable");const U=await $.json();if(!(U!=null&&U.ok))throw new Error("desktop tour preferences unavailable");const F=((I=U.prefs)==null?void 0:I.tourSeen)===!0;_&&!F&&fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tourSeen:!0}),keepalive:!0}).catch(()=>{}),_=_||F}catch{_=!0}if(!S)return;const R=qve({tourSeen:_,decision:v}),A=v.show.length?{entries:v.show,since:k,firstRun:!1}:null;R.tour&&s(!0),R.notes==="now"?i(A):R.notes==="after"&&(a.current=A)})(),()=>{S=!1}},[e==null?void 0:e.running]);const f=(e==null?void 0:e.running)??"3.49.1",p=g.useMemo(()=>sB(WO,null,f),[f]),m=g.useCallback(()=>{i({entries:p,since:null,firstRun:!1})},[p]),w=g.useCallback(()=>s(!0),[]),x=g.useCallback(()=>i(null),[]),b=g.useCallback(()=>{s(!1),Bve(gr()),ao()&&fetch("/api/prefs",{method:"POST",headers:{"content-type":"application/json"},body:JSON.stringify({tourSeen:!0}),keepalive:!0}).catch(()=>{});const j=a.current;a.current=null,j&&i(j)},[]);return{tourOpen:n,openTour:w,closeTour:b,releaseNotes:o,closeReleaseNotes:x,chipVersion:f,openReleaseNotes:m}}function sje(){const[e,t]=g.useState(void 0),[n,s]=g.useState(!1),a=g.useRef(!1);return a.current=e===!0&&!n,g.useEffect(()=>b0e(()=>a.current),[]),{loadReportsPrefs:g.useCallback(i=>{var l;t(((l=i.prefs)==null?void 0:l.reports)!==!1),s(i.reportsVetoed===!0)},[])}}function rje(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 d,f;const u=l!==!0;return st("agent-dag.sound",u?"on":"off"),u?(d=e.current)==null||d.unlock():(f=e.current)==null||f.silence(),u})},[]),a=g.useCallback(l=>{s()},[s]),o=Bn(a),i=Bn(t);return{soundOn:t,toggleSound:s,activateSoundRef:o,soundOnRef:i}}function aje(){const[e,t]=g.useState(mee),n=g.useCallback((o,i)=>{t(l=>gee(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 oje="agent-dag.autoFitDisabled";function ije(e){const t=g.useRef(!1),[n,s]=g.useState(!1);g.useEffect(()=>{vs(oje)},[]);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 lje(){return r.jsx(iN,{children:r.jsx(N0e,{children:r.jsx(cje,{})})})}function cje(){var $c;const e=Ql(),t=g.useState(lN)[0],n=g.useRef(t),[,s]=g.useState(0),a=g.useCallback(()=>s(dt=>dt+1),[]),{sessionListOpen:o,accountsPanelOpen:i,panel:l,toggleSessionList:u,toggleAccountsPanel:d,openAccountsPanel:f,closeSessionList:p,closeSessionListToCanvas:m,closeAccountsPanel:w}=j1e(),{detailOpen:x,setDetailOpen:b,usagePanelOpen:j,setUsagePanelOpen:k,machinePanelOpen:v,setMachinePanelOpen:S}=A1e(g3(l)),{selectedIds:C,primarySelectedId:_,selectAgent:R,clearSelection:A,pruneSelectionToBoard:I}=kde(n,b),$=bl(i,200),U=bl(o,200),F=YE(o,U),M=bl(j,130),B=bl(v,130),T=g.useRef(null),P=rje(T),{activateSoundRef:q,soundOnRef:K}=P,z=G1e(T),{setTonePrefs:H,tonePrefsRef:D,previewTone:O}=z,V=V1e({chimesRef:T,setTonePrefs:H,tonePrefsRef:D,previewTone:O}),{customSelectionsRef:Z,fallbackCustomRef:W}=V,X=aje(),{openSettings:Y}=X;l1e({chimesRef:T,soundOnRef:K,tonePrefsRef:D,customSelectionsRef:Z,fallbackCustomRef:W});const J=_0e(n),{pauseGate:Q,paused:te,togglePause:le}=J,de=g.useRef(()=>{}),{live:oe,tabCapped:re,everConnected:he,liveSince:fe}=hde({stateRef:n,rerender:a,pauseGate:Q,chimesRef:T,desktopUpdateRef:de}),$e=tje(oe),{version:ye,notice:ge,noticeOpen:je,loadVersion:Le}=$e,ke=u1e(oe),{readyAppUpdate:Ie,onDesktopUpdateEvent:De}=ke;de.current=De,J1e();const Ue=nje({version:ye,readyAppUpdate:Ie}),{tourOpen:Ke,openTour:we,releaseNotes:Fe}=Ue,{workspace:Re,providers:Ae,providersRef:rt}=T0e(oe),We=g3(l==="accounts"&&!Ae.claude?null:l),se=x1e(We),be=YE(i,$)&&Ae.claude,[Te,Oe]=g.useState(!1),ve=g.useCallback(()=>{f(),Oe(!0)},[f]);g.useEffect(()=>{i||Oe(!1)},[i]);const pe=g.useCallback(()=>Oe(!1),[]),_e=B1e(ye),ze=G0e({version:ye,loadVersion:Le}),{upgradeFailure:at}=ze,tt=D1e({stateRef:n,tourOpen:Ke,releaseNotes:Fe}),xt=z1e({modalOpenRef:tt.modalOpenRef}),{openTool:Mt,setSummaryFor:Xt,setContextFor:tr,openContext:Cs,setKeyHelpOpen:zn,setUsageHistoryOpen:ts,setBrowserWatchOpen:_s,keyHelpOpenRef:sn,modalOpenRef:zt}=tt,Me=sje(),Ve=Y0e(),{watchOn:Xe,watchUnseen:Tt}=Ve,Ct=Id(),[qt,Vn]=g.useState(null),[nr,Es]=g.useState(!1),gn=g.useCallback(()=>Es(!1),[]),_r=dt=>{Kye(dt),Y("integrations")},ga=dt=>{dt&&MO(dt),Y("integrations")},Er=g.useCallback(()=>Vn(null),[]),Ts=zS().filter(dt=>Rj(Ct,dt.kind)),Tr=Bn(dt=>{const Br=Ts.find(fg=>fg.kind===dt);Br&&Vn(Br.kind)}),ya=g.useCallback(dt=>{MO(dt),Y("integrations")},[Y]),Ar=Ts.length>0;g.useEffect(()=>{Ar&&Oye()},[Ar]);const Rr=h1e(),[ho,yt]=g.useState(0),{presentCats:wa,hiddenCats:ns,toggleCat:xa,catBarRef:As,catBarOccluded:Mr}=o1e(n),sr=g.useRef(null),[Rs,dn]=g.useState(0),$t=jde({stateRef:n,rerender:a,pruneSelectionToBoard:I,setContextFor:tr,setSummaryFor:Xt});SY({stateRef:n,now:$t,enabled:Ae.claude});const yn=$0e(Ae.claude||Ae.codex),xe=H0e(yn,$t),Qe=p1e({enabled:Ae.claude,lanStatus:Rr.lanStatus,now:$t}),ut=d1e({now:$t,stateRef:n,version:ye,notice:ge,noticeOpen:je,upgradeFailure:at,paused:J.paused}),{askRestart:Lt,loadAutoRestartPrefs:ss}=ut,Rn=a1e(),{setTheme:$r,palette:Pd}=Rn,ki=c1e(),Ms=jme(),{applyViewport:Dd,moveCamera:pc,fitLeft:rr,cameraEpochRef:Xm,lastFitTimeRef:ji}=Ms,ct=Pme(Ms),{pinnedRef:fo,positionsRef:po,lastLayoutSigRef:mc,handleRelayout:gc,rearrangeUndo:Fd}=ct,yc=g.useRef(null),Ni=g.useRef(()=>{}),mo=fe!==null,$s=g.useRef(0),Ls=g.useCallback(()=>{$s.current=Date.now()},[]),{canvasRef:hn,canvasSize:go,paneSizeRef:yo}=Sge(se),Is=ije(rr),{autoFitDisabledRef:Bd,disableAutoFit:Si}=Is,Lr=g.useRef(!1),{measuredRef:Ir,measuredVersionRef:qd,sizeVersion:Ci,domSizeVersion:Ud}=Cge(Lr),{removedNodes:wc,removedAgentIds:rs,removeNode:wo,removeSelectedNode:Or,removalNotice:xo,hideSessions:Zm,bringBack:xc,bringBackAll:vc,forgetRemovals:_i}=sge({stateRef:n,pinnedRef:fo,positionsRef:po,returningRef:ct.returningRef,canvasRef:hn,clearSelection:A,primarySelectedId:_});pge({stateRef:n,removedNodes:wc,hideSessions:Zm,ready:mo,keepSessionId:_?(($c=n.current.agents.get(_))==null?void 0:$c.sessionId)??_:null});const vo=Jme({stateRef:n,now:$t,removedAgentIds:rs,sizeVersion:Ci,domSizeVersion:Ud});Dme(vo,ct),nge({layoutSig:vo,rf:e,stateRef:n,measuredRef:Ir,pinnedRef:fo,positionsRef:po,paneSizeRef:yo,lastInteractRef:$s,autoFitDisabledRef:Bd,lastFitTimeRef:ji,fitLeft:rr});const bc=_ge(),{bubbling:ar,endBubble:kc,onBubble:Ei}=Zue(),[Ti,Ai]=g.useState(!1),bo=Yue(),{beginTrashDrag:Wd,trackTrashDrag:kn,endTrashDrag:va}=bo,Ri=rde({stateRef:n,measuredRef:Ir,measuredVersionRef:qd,canvasRef:hn}),{lodRef:ko,applyZoom:Jm}=Ri,Mi=kge({applyViewport:Dd,lastFitTimeRef:ji,cameraEpochRef:Xm,disableAutoFit:Si,markInteract:Ls,canvasRef:hn,applyZoom:Jm}),Pr=_?n.current.agents.get(_):null,Dr=x&&Pr!=null,Os=Rge({sessionListShown:F,usageShown:Ya(M),machineShown:Ya(B),accountsShown:be,detailShown:Dr,primarySelectedId:_,canvasRef:hn}),{railInsetRef:jo,availableWidth:Hd,availableHeight:zd}=wme({canvasRef:hn,canvasSize:go,machinePhase:B,usagePhase:M,usagePanelOpen:j,detailShown:Dr}),Vd=Qme({stateRef:n,now:$t,availableWidth:Hd,availableHeight:zd,layout:ct,measuredRef:Ir,onBubble:Ei,settled:bc,dragging:Ti,layoutSig:vo,selectedIds:C,openContext:Cs,historyReplayed:mo,removedNodes:wc,removedAgentIds:rs,dragTick:ho,dragPatchRef:sr,dragMoveTick:Rs}),{nodes:No,edges:Qm}=Vd,jc=Bn(_);Fme({nodes:No,edges:Qm,settled:bc,dragging:Ti,availableWidth:Hd,availableHeight:zd,layout:ct,camera:Ms,rf:e,measuredRef:Ir,stateRef:n,lastFocusRef:yc,primarySelectedIdRef:jc,focusAgentRef:Ni,autoFitDisabledRef:Bd});const Gd=F1e({stateRef:n,pinnedRef:fo,measuredRef:Ir,positionsRef:po,lastLayoutSigRef:mc,forgetRemovals:_i,clearSelection:A,rerender:a,modalOpenRef:zt}),{requestClear:Nc}=Gd,eg=Mge({nodes:No,stateRef:n,pinnedRef:fo,positionsRef:po,draggingRef:Lr,dragPatchRef:sr,setDragging:Ai,setDragMoveTick:dn,setDragTick:yt,endBubble:kc,markInteract:Ls,disableAutoFit:Si,beginTrashDrag:Wd,trackTrashDrag:kn,endTrashDrag:va,removeNode:wo}),Sc=g.useCallback(()=>rr(500),[rr]),Cc=Bn(No),{focusAgent:$i,stepAgent:tg,focusSession:ba}=Sme({canvasRef:hn,stateRef:n,measuredRef:Ir,nodesRef:Cc,railInsetRef:jo,moveCamera:pc,disableAutoFit:Si,lastFocusRef:yc,focusAgentRef:Ni,selectAgent:R,primarySelectedIdRef:jc}),_c=jge({clearSelection:A,selectAgent:R,detailOpen:x,setDetailOpen:b,detailShown:Dr,focusAgent:$i,draggingRef:Lr,lodRef:ko}),ng=Cme({nodesRef:Cc,stateRef:n,canvasRef:hn,railInsetRef:jo}),sg=Bn(Or),Ec=g.useRef(null),So=g.useCallback(dt=>{rs.has(dt)&&xc([dt]),ba(dt)},[rs,xc,ba]),rg=Ege(),[ag,Tc]=g.useState(!1),Kd=g.useCallback(()=>Tc(!0),[]),og=g.useCallback(()=>Tc(!1),[]),ig=g.useCallback(dt=>{Tc(!1),dt.run()},[]),lg=An();Tge({pointerFocusRef:rg,nodesRef:Cc,stateRef:n,primarySelectedIdRef:jc,providersRef:rt,soundOnRef:K,keyHelpOpenRef:sn,modalOpenRef:zt,waitingCursorRef:Ec,removeSelectedRef:sg,activateSoundRef:q,clearSelection:A,selectAgent:R,focusAgent:$i,stepAgent:tg,focusSession:ba,requestClear:Nc,handleRelayout:gc,undoRearrange:Fd.undo,handleFit:Sc,togglePause:le,toggleSessionList:u,toggleAccountsPanel:d,setDetailOpen:b,setUsageHistoryOpen:ts,setUsagePanelOpen:k,setMachinePanelOpen:S,setBrowserWatchOpen:_s,setKeyHelpOpen:zn,setTheme:$r,openSettings:Y,openIntegrationRef:Tr,openQuickOpen:Kd});const Co=n.current.agents.size,as=g.useMemo(()=>T1(n.current.agents.values()),[n.current,n.current.revision]);rge({stateRef:n,waitingSessions:as,removedAgentIds:rs,removedNodes:wc,bringBack:xc}),xge({stateRef:n,waitingSessions:as,live:oe});const Yd=L1e({waitingSessions:as,watchUnseen:Tt,incidents:xe}),Li=O1e({waitingSessions:as,liveSince:fe,focusSession:ba}),{loadNotifyPrefs:Xd}=Li;Q1e({loadAutoRestartPrefs:ss,loadNotifyPrefs:Xd,loadReportsPrefs:Me.loadReportsPrefs});const or=lc(mm),[Zd,Ac]=g.useState(!1),[Fr,Rc]=g.useState(null),cg=g.useCallback(()=>Rc(null),[]),ug=g.useCallback(dt=>{const Br=n.current.agents.get(dt);return Br?Br.label||Br.cwdBasename||"session":null},[]),Jd=g.useCallback(dt=>{Rc(null),So(dt)},[So]),Qd=g.useCallback(()=>Ac(!1),[]),[ka,ja]=g.useState(null),dg=g.useCallback(()=>ja(null),[]),Ut=Zge({providers:Ae,sessionListOpen:o,toggleSessionList:u,accountsPanelOpen:i,toggleAccountsPanel:d,usagePanelOpen:j,setUsagePanelOpen:k,machinePanelOpen:v,setMachinePanelOpen:S,setUsageHistoryOpen:ts,watchOn:Xe,watchUnseen:Tt,setBrowserWatchOpen:_s,setTrafficRadarOpen:tt.setTrafficRadarOpen,openSettings:Y,onFeedback:tt.openFeedback,setRadioOpen:Ac,openToolActivity:Rc,openCapacity:ja,toggles:Os.toggles,integrations:Ts.map(dt=>({provider:dt,onPress:()=>Vn(dt.kind)})),openExploreIntegrations:()=>Es(!0),openQuickOpen:Kd}),[hg,eh]=g.useState(0),Ii=g.useCallback(dt=>{So(dt),or&&m()},[So,or,m]),Mc=g.useCallback(()=>{o||u(),requestAnimationFrame(()=>{var dt;return(dt=document.querySelector("#session-list .sl-row"))==null?void 0:dt.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(KJ,{}),r.jsx(Cwe,{versionCheck:$e,welcome:Ue,desktopUpdate:ke,pause:J,announcements:Yd,notify:Li,waitingSessions:as,waitingCursorRef:Ec,focusSession:ba,live:oe,now:$t,incidents:xe,queueNamed:or?0:hg}),!or&&r.jsx(jwe,{waitingSessions:as,waitingCursorRef:Ec,focusSession:ba,now:$t,onFit:eh,onMore:Mc}),Pr&&r.jsx(_we,{selected:Pr,now:$t,selectedIds:C,focusAgent:$i,clearSelection:A}),!or&&r.jsx("div",{className:"actions",children:r.jsx(dee,{items:[Ut.search,...Ut.utilities]})})]}),or?r.jsx(uee,{items:[...Ut.left,...Ut.right[0],Ut.utilities[0]],more:[Ut.search,...Ut.capacity,...Ut.right.slice(1).flat(),...Ut.integrations,...Ut.explore,Ut.utilities[1]]}):r.jsx(pA,{side:"left",label:"Accounts and sessions",groups:[...Ut.leftStripe,Ut.integrations,Ut.explore]}),r.jsx("div",{className:"vis-hidden",role:"status","aria-atomic":"true",children:xo?`${xo.label} removed from the board.`:""}),r.jsx(Zwe,{restart:ut,versionCheck:$e,upgrade:ze,oldNameNotice:_e,rating:xt,onFeedback:tt.openFeedback,everConnected:he,live:oe,paused:te}),(F||be)&&r.jsxs(Uue,{width:We,children:[be&&r.jsx(Sue,{leaving:XE(i,$),onReport:tt.openFeedback,onRoster:Qe.observe,onClose:()=>{Os.accounts(),w()},lanWanted:Te,onLanShown:pe}),F&&r.jsx(iQ,{leaving:XE(o,U),state:n.current,now:$t,selectedIds:C,onSelect:Ii,onClose:()=>{Os.sessionList(),p()},removedIds:rs,onBringBackAll:vc})]}),r.jsxs(Mwe,{canvasRef:hn,bubbling:ar,dragging:Ti,trash:bo,zoom:Ri,viewport:Mi,stateRef:n,peek:ng,children:[Co===0&&(!oe&&re?r.jsx(Lge,{reservedRight:jo.current}):r.jsx(Ige,{live:oe,everConnected:he,providers:Ae,workspace:Re,onTour:we,reservedRight:jo.current})),(wa.length>1||ns.size>0)&&r.jsx(Ewe,{catBarRef:As,catBarOccluded:Mr,presentCats:wa,hiddenCats:ns,toggleCat:xa}),r.jsx(GJ,{graph:Vd,layout:ct,viewport:Mi,clicks:_c,drag:eg,appearance:Rn,fm:ki,radioOpen:Zd,onRadioClose:Qd,autoFit:Is,pause:J,stateRef:n,measuredRef:Ir,hiddenCats:ns,now:$t,openTool:Mt,focusAgent:$i,requestClear:Nc,setKeyHelpOpen:zn})]}),!or&&r.jsx(pA,{side:"right",label:"Usage and activity",groups:Ut.right}),Fr&&r.jsx(Rne,{view:Fr,onClose:cg,sessionLabel:ug,onOpenSession:Jd}),ka&&r.jsx(que,{view:ka,onClose:dg}),qt&&r.jsx(Fye,{kind:qt,connections:na(Ct,qt)?Op(Ct,qt):[],onClose:Er,onReconnect:ya}),nr&&r.jsx(ewe,{integrations:Ct,onClose:gn,onOpen:Vn,onConnect:_r,onManage:ga}),ag&&r.jsx(WQ,{onClose:og,onRun:ig,items:Ete({rails:Ut,sessions:LD(n.current),now:$t,openSession:Ii,settings:i5(Ae.claude,GS(Ct),Od(Ct)),openSettings:Y,singleKeys:lg,fit:Sc,rearrange:gc,paused:te,togglePause:le,clear:Co>0?()=>Nc("button"):void 0,keyHelp:()=>zn(!0),tour:we,theme:Rn.theme,setTheme:$r})}),Ya(M)&&r.jsx(tre,{state:n.current,now:$t,providers:Ae,incidents:xe,liveSince:fe,leaving:M==="leaving",onClose:()=>{Os.usage(),k(!1)}}),Ya(B)&&r.jsx(Pre,{usageOpen:j,leaving:B==="leaving",onClose:()=>{Os.machine(),S(!1)}}),x&&Pr?r.jsx(Yge,{selected:Pr,now:$t,openTool:Mt,setSummaryFor:Xt,stateRef:n,removeSelectedNode:Or,onClose:()=>{Os.detail(),b(!1)}}):null,r.jsx(r0e,{dialogs:tt,welcome:Ue,desktopUpdate:ke,versionCheck:$e,restart:ut,upgrade:ze,lanPairs:Rr,attention:Qe,clearFlow:Gd,watchBadge:Ve,announcements:Yd,appearance:Rn,providers:Ae,stateRef:n,agentCount:Co,menus:X,sound:P,tones:z,customTones:V,notify:Li,panelDoors:{accounts:f,localNetwork:ve}})]})}try{yK(window.localStorage)}catch{}const uje=Lq.createRoot(document.getElementById("root"));window.ccdeckWindow&&(document.documentElement.dataset.desktopChrome="true",document.documentElement.dataset.desktopPlatform=window.ccdeckWindow.platform);uje.render(r.jsx(lje,{}));export{Cje as $,ac as A,xje as B,vt as C,Tu as D,Zl as E,Mje as F,L5 as G,gae as H,wr as I,lt as J,tj as K,IA as L,nj as M,gje as N,St as O,Qa as P,ea as Q,A5 as R,yje as S,rp as T,wje as U,fd as V,Hn as W,Pee as X,Sje as Y,Eje as Z,zve as _,vs as a,_je as a0,Hve as a1,Tje as a2,cm as a3,me as a4,fi as a5,eo as a6,OZ as a7,$je as a8,MN as a9,Gl as aa,yX as ab,mje as ac,fje as ad,pje as ae,um as af,JG as ag,Fbe as ah,X0e as ai,hje as aj,PZ as ak,g as b,jje as c,qn as d,op as e,$8 as f,Uo as g,io as h,Nje as i,r as j,pS as k,LP as l,ln as m,gt as n,wt as o,xd as p,kje as q,nt as r,_n as s,bje as t,lc as u,cn as v,st as w,Rje as x,Aje as y,vje as z};
|